var Kte=Object.defineProperty;var Yte=(e,t,n)=>t in e?Kte(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var wd=(e,t,n)=>Yte(e,typeof t!="symbol"?t+"":t,n);function Xte(e,t){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Iv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var G5={exports:{}},zx={};/** * @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 z6;function Qte(){if(z6)return zx;z6=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,a){var o=null;if(a!==void 0&&(o=""+a),i.key!==void 0&&(o=""+i.key),"key"in i){a={};for(var c in i)c!=="key"&&(a[c]=i[c])}else a=i;return i=a.ref,{$$typeof:e,type:r,key:o,ref:i!==void 0?i:null,props:a}}return zx.Fragment=t,zx.jsx=n,zx.jsxs=n,zx}var V6;function Zte(){return V6||(V6=1,G5.exports=Qte()),G5.exports}var s=Zte(),q5={exports:{}},Or={};/** * @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 F6;function Jte(){if(F6)return Or;F6=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),w=Symbol.iterator;function A(se){return se===null||typeof se!="object"?null:(se=w&&se[w]||se["@@iterator"],typeof se=="function"?se:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,T={};function D(se,xe,re){this.props=se,this.context=xe,this.refs=T,this.updater=re||S}D.prototype.isReactComponent={},D.prototype.setState=function(se,xe){if(typeof se!="object"&&typeof se!="function"&&se!=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,se,xe,"setState")},D.prototype.forceUpdate=function(se){this.updater.enqueueForceUpdate(this,se,"forceUpdate")};function V(){}V.prototype=D.prototype;function L(se,xe,re){this.props=se,this.context=xe,this.refs=T,this.updater=re||S}var K=L.prototype=new V;K.constructor=L,C(K,D.prototype),K.isPureReactComponent=!0;var Z=Array.isArray;function q(){}var B={H:null,A:null,T:null,S:null},z=Object.prototype.hasOwnProperty;function F(se,xe,re){var Me=re.ref;return{$$typeof:e,type:se,key:xe,ref:Me!==void 0?Me:null,props:re}}function $(se,xe){return F(se.type,xe,se.props)}function Y(se){return typeof se=="object"&&se!==null&&se.$$typeof===e}function X(se){var xe={"=":"=0",":":"=2"};return"$"+se.replace(/[=:]/g,function(re){return xe[re]})}var J=/\/+/g;function ye(se,xe){return typeof se=="object"&&se!==null&&se.key!=null?X(""+se.key):xe.toString(36)}function ne(se){switch(se.status){case"fulfilled":return se.value;case"rejected":throw se.reason;default:switch(typeof se.status=="string"?se.then(q,q):(se.status="pending",se.then(function(xe){se.status==="pending"&&(se.status="fulfilled",se.value=xe)},function(xe){se.status==="pending"&&(se.status="rejected",se.reason=xe)})),se.status){case"fulfilled":return se.value;case"rejected":throw se.reason}}throw se}function de(se,xe,re,Me,nt){var ze=typeof se;(ze==="undefined"||ze==="boolean")&&(se=null);var Tt=!1;if(se===null)Tt=!0;else switch(ze){case"bigint":case"string":case"number":Tt=!0;break;case"object":switch(se.$$typeof){case e:case t:Tt=!0;break;case m:return Tt=se._init,de(Tt(se._payload),xe,re,Me,nt)}}if(Tt)return nt=nt(se),Tt=Me===""?"."+ye(se,0):Me,Z(nt)?(re="",Tt!=null&&(re=Tt.replace(J,"$&/")+"/"),de(nt,xe,re,"",function(Ee){return Ee})):nt!=null&&(Y(nt)&&(nt=$(nt,re+(nt.key==null||se&&se.key===nt.key?"":(""+nt.key).replace(J,"$&/")+"/")+Tt)),xe.push(nt)),1;Tt=0;var It=Me===""?".":Me+":";if(Z(se))for(var ft=0;ft>>1,G=de[Ke];if(0>>1;Kei(re,Ce))Mei(nt,re)?(de[Ke]=nt,de[Me]=Ce,Ke=Me):(de[Ke]=re,de[xe]=Ce,Ke=xe);else if(Mei(nt,Ce))de[Ke]=nt,de[Me]=Ce,Ke=Me;else break e}}return be}function i(de,be){var Ce=de.sortIndex-be.sortIndex;return Ce!==0?Ce:de.id-be.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,c=o.now();e.unstable_now=function(){return o.now()-c}}var h=[],f=[],m=1,y=null,w=3,A=!1,S=!1,C=!1,T=!1,D=typeof setTimeout=="function"?setTimeout:null,V=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function K(de){for(var be=n(f);be!==null;){if(be.callback===null)r(f);else if(be.startTime<=de)r(f),be.sortIndex=be.expirationTime,t(h,be);else break;be=n(f)}}function Z(de){if(C=!1,K(de),!S)if(n(h)!==null)S=!0,q||(q=!0,X());else{var be=n(f);be!==null&&ne(Z,be.startTime-de)}}var q=!1,B=-1,z=5,F=-1;function $(){return T?!0:!(e.unstable_now()-Fde&&$());){var Ke=y.callback;if(typeof Ke=="function"){y.callback=null,w=y.priorityLevel;var G=Ke(y.expirationTime<=de);if(de=e.unstable_now(),typeof G=="function"){y.callback=G,K(de),be=!0;break t}y===n(h)&&r(h),K(de)}else r(h);y=n(h)}if(y!==null)be=!0;else{var se=n(f);se!==null&&ne(Z,se.startTime-de),be=!1}}break e}finally{y=null,w=Ce,A=!1}be=void 0}}finally{be?X():q=!1}}}var X;if(typeof L=="function")X=function(){L(Y)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,ye=J.port2;J.port1.onmessage=Y,X=function(){ye.postMessage(null)}}else X=function(){D(Y,0)};function ne(de,be){B=D(function(){de(e.unstable_now())},be)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(de){de.callback=null},e.unstable_forceFrameRate=function(de){0>de||125Ke?(de.sortIndex=Ce,t(f,de),n(h)===null&&de===n(f)&&(C?(V(B),B=-1):C=!0,ne(Z,Ce-Ke))):(de.sortIndex=G,t(h,de),S||A||(S=!0,q||(q=!0,X()))),de},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(de){var be=w;return function(){var Ce=w;w=be;try{return de.apply(this,arguments)}finally{w=Ce}}}})(Y5)),Y5}var G6;function nne(){return G6||(G6=1,K5.exports=tne()),K5.exports}var X5={exports:{}},yo={};/** * @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 q6;function rne(){if(q6)return yo;q6=1;var e=Mg();function t(h){var f="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),X5.exports=rne(),X5.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 K6;function ine(){if(K6)return Vx;K6=1;var e=nne(),t=Mg(),n=YV();function r(l){var d="https://react.dev/errors/"+l;if(1G||(l.current=Ke[G],Ke[G]=null,G--)}function re(l,d){G++,Ke[G]=l.current,l.current=d}var Me=se(null),nt=se(null),ze=se(null),Tt=se(null);function It(l,d){switch(re(ze,d),re(nt,l),re(Me,null),d.nodeType){case 9:case 11:l=(l=d.documentElement)&&(l=l.namespaceURI)?c6(l):0;break;default:if(l=d.tagName,d=d.namespaceURI)d=c6(d),l=u6(d,l);else switch(l){case"svg":l=1;break;case"math":l=2;break;default:l=0}}xe(Me),re(Me,l)}function ft(){xe(Me),xe(nt),xe(ze)}function Ee(l){l.memoizedState!==null&&re(Tt,l);var d=Me.current,x=u6(d,l.type);d!==x&&(re(nt,l),re(Me,x))}function yt(l){nt.current===l&&(xe(Me),xe(nt)),Tt.current===l&&(xe(Tt),Mx._currentValue=Ce)}var Ue,Vt;function St(l){if(Ue===void 0)try{throw Error()}catch(x){var d=x.stack.trim().match(/\n( *(at )?)/);Ue=d&&d[1]||"",Vt=-1)":-1j||_e[N]!==it[j]){var wt=` `+_e[N].replace(" at new "," at ");return l.displayName&&wt.includes("")&&(wt=wt.replace("",l.displayName)),wt}while(1<=N&&0<=j);break}}}finally{tn=!1,Error.prepareStackTrace=x}return(x=l?l.displayName||l.name:"")?St(x):""}function Nt(l,d){switch(l.tag){case 26:case 27:case 5:return St(l.type);case 16:return St("Lazy");case 13:return l.child!==d&&d!==null?St("Suspense Fallback"):St("Suspense");case 19:return St("SuspenseList");case 0:case 15:return Pt(l.type,!1);case 11:return Pt(l.type.render,!1);case 1:return Pt(l.type,!0);case 31:return St("Activity");default:return""}}function Kt(l){try{var d="",x=null;do d+=Nt(l,x),x=l,l=l.return;while(l);return d}catch(N){return` Error generating stack: `+N.message+` `+N.stack}}var ut=Object.prototype.hasOwnProperty,Jt=e.unstable_scheduleCallback,Dt=e.unstable_cancelCallback,hn=e.unstable_shouldYield,qn=e.unstable_requestPaint,mn=e.unstable_now,vr=e.unstable_getCurrentPriorityLevel,Ve=e.unstable_ImmediatePriority,Mt=e.unstable_UserBlockingPriority,cn=e.unstable_NormalPriority,dn=e.unstable_LowPriority,mr=e.unstable_IdlePriority,gr=e.log,wi=e.unstable_setDisableYieldValue,Xt=null,me=null;function qe(l){if(typeof gr=="function"&&wi(l),me&&typeof me.setStrictMode=="function")try{me.setStrictMode(Xt,l)}catch{}}var st=Math.clz32?Math.clz32:Ft,dt=Math.log,An=Math.LN2;function Ft(l){return l>>>=0,l===0?32:31-(dt(l)/An|0)|0}var Dn=256,Ot=262144,on=4194304;function jr(l){var d=l&42;if(d!==0)return d;switch(l&-l){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 l&261888;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function lr(l,d,x){var N=l.pendingLanes;if(N===0)return 0;var j=0,R=l.suspendedLanes,Q=l.pingedLanes;l=l.warmLanes;var ce=N&134217727;return ce!==0?(N=ce&~R,N!==0?j=jr(N):(Q&=ce,Q!==0?j=jr(Q):x||(x=ce&~l,x!==0&&(j=jr(x))))):(ce=N&~R,ce!==0?j=jr(ce):Q!==0?j=jr(Q):x||(x=N&~l,x!==0&&(j=jr(x)))),j===0?0:d!==0&&d!==j&&(d&R)===0&&(R=j&-j,x=d&-d,R>=x||R===32&&(x&4194048)!==0)?d:j}function ue(l,d){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&d)===0}function Se(l,d){switch(l){case 1:case 2:case 4:case 8:case 64:return d+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 d+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 Qe(){var l=on;return on<<=1,(on&62914560)===0&&(on=4194304),l}function Gt(l){for(var d=[],x=0;31>x;x++)d.push(l);return d}function Fn(l,d){l.pendingLanes|=d,d!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function xn(l,d,x,N,j,R){var Q=l.pendingLanes;l.pendingLanes=x,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=x,l.entangledLanes&=x,l.errorRecoveryDisabledLanes&=x,l.shellSuspendCounter=0;var ce=l.entanglements,_e=l.expirationTimes,it=l.hiddenUpdates;for(x=Q&~x;0"u")return null;try{return l.activeElement||l.body}catch{return l.body}}var jn=/[\n"\\]/g;function Ln(l){return l.replace(jn,function(d){return"\\"+d.charCodeAt(0).toString(16)+" "})}function xr(l,d,x,N,j,R,Q,ce){l.name="",Q!=null&&typeof Q!="function"&&typeof Q!="symbol"&&typeof Q!="boolean"?l.type=Q:l.removeAttribute("type"),d!=null?Q==="number"?(d===0&&l.value===""||l.value!=d)&&(l.value=""+At(d)):l.value!==""+At(d)&&(l.value=""+At(d)):Q!=="submit"&&Q!=="reset"||l.removeAttribute("value"),d!=null?fe(l,Q,At(d)):x!=null?fe(l,Q,At(x)):N!=null&&l.removeAttribute("value"),j==null&&R!=null&&(l.defaultChecked=!!R),j!=null&&(l.checked=j&&typeof j!="function"&&typeof j!="symbol"),ce!=null&&typeof ce!="function"&&typeof ce!="symbol"&&typeof ce!="boolean"?l.name=""+At(ce):l.removeAttribute("name")}function Le(l,d,x,N,j,R,Q,ce){if(R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"&&(l.type=R),d!=null||x!=null){if(!(R!=="submit"&&R!=="reset"||d!=null)){Be(l);return}x=x!=null?""+At(x):"",d=d!=null?""+At(d):x,ce||d===l.value||(l.value=d),l.defaultValue=d}N=N??j,N=typeof N!="function"&&typeof N!="symbol"&&!!N,l.checked=ce?l.checked:!!N,l.defaultChecked=!!N,Q!=null&&typeof Q!="function"&&typeof Q!="symbol"&&typeof Q!="boolean"&&(l.name=Q),Be(l)}function fe(l,d,x){d==="number"&&Mn(l.ownerDocument)===l||l.defaultValue===""+x||(l.defaultValue=""+x)}function fn(l,d,x,N){if(l=l.options,d){d={};for(var j=0;j"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),To=!1;if(Xr)try{var Zr={};Object.defineProperty(Zr,"passive",{get:function(){To=!0}}),window.addEventListener("test",Zr,Zr),window.removeEventListener("test",Zr,Zr)}catch{To=!1}var ho=null,Qs=null,Po=null;function pa(){if(Po)return Po;var l,d=Qs,x=d.length,N,j="value"in ho?ho.value:ho.textContent,R=j.length;for(l=0;l=tr),Vi=" ",Ri=!1;function ws(l,d){switch(l){case"keyup":return Zn.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Da(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Ei=!1;function Ts(l,d){switch(l){case"compositionend":return Da(d);case"keypress":return d.which!==32?null:(Ri=!0,Vi);case"textInput":return l=d.data,l===Vi&&Ri?null:l;default:return null}}function ni(l,d){if(Ei)return l==="compositionend"||!wn&&ws(l,d)?(l=pa(),Po=Qs=ho=null,Ei=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(d.ctrlKey||d.altKey||d.metaKey)||d.ctrlKey&&d.altKey){if(d.char&&1=d)return{node:x,offset:d-l};l=N}e:{for(;x;){if(x.nextSibling){x=x.nextSibling;break e}x=x.parentNode}x=void 0}x=P(x)}}function W(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?W(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function te(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var d=Mn(l.document);d instanceof l.HTMLIFrameElement;){try{var x=typeof d.contentWindow.location.href=="string"}catch{x=!1}if(x)l=d.contentWindow;else break;d=Mn(l.document)}return d}function ae(l){var d=l&&l.nodeName&&l.nodeName.toLowerCase();return d&&(d==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||d==="textarea"||l.contentEditable==="true")}var ve=Xr&&"documentMode"in document&&11>=document.documentMode,ke=null,Ie=null,We=null,ht=!1;function Yt(l,d,x){var N=x.window===x?x.document:x.nodeType===9?x:x.ownerDocument;ht||ke==null||ke!==Mn(N)||(N=ke,"selectionStart"in N&&ae(N)?N={start:N.selectionStart,end:N.selectionEnd}:(N=(N.ownerDocument&&N.ownerDocument.defaultView||window).getSelection(),N={anchorNode:N.anchorNode,anchorOffset:N.anchorOffset,focusNode:N.focusNode,focusOffset:N.focusOffset}),We&&k(We,N)||(We=N,N=mv(Ie,"onSelect"),0>=Q,j-=Q,Kl=1<<32-st(d)+j|x<zr?(ii=Wn,Wn=null):ii=Wn.sibling;var _i=lt(Ge,Wn,tt[zr],jt);if(_i===null){Wn===null&&(Wn=ii);break}l&&Wn&&_i.alternate===null&&d(Ge,Wn),Oe=R(_i,Oe,zr),Ai===null?rr=_i:Ai.sibling=_i,Ai=_i,Wn=ii}if(zr===tt.length)return x(Ge,Wn),Gr&&_c(Ge,zr),rr;if(Wn===null){for(;zrzr?(ii=Wn,Wn=null):ii=Wn.sibling;var Ih=lt(Ge,Wn,_i.value,jt);if(Ih===null){Wn===null&&(Wn=ii);break}l&&Wn&&Ih.alternate===null&&d(Ge,Wn),Oe=R(Ih,Oe,zr),Ai===null?rr=Ih:Ai.sibling=Ih,Ai=Ih,Wn=ii}if(_i.done)return x(Ge,Wn),Gr&&_c(Ge,zr),rr;if(Wn===null){for(;!_i.done;zr++,_i=tt.next())_i=Rt(Ge,_i.value,jt),_i!==null&&(Oe=R(_i,Oe,zr),Ai===null?rr=_i:Ai.sibling=_i,Ai=_i);return Gr&&_c(Ge,zr),rr}for(Wn=N(Wn);!_i.done;zr++,_i=tt.next())_i=gt(Wn,Ge,zr,_i.value,jt),_i!==null&&(l&&_i.alternate!==null&&Wn.delete(_i.key===null?zr:_i.key),Oe=R(_i,Oe,zr),Ai===null?rr=_i:Ai.sibling=_i,Ai=_i);return l&&Wn.forEach(function(Wte){return d(Ge,Wte)}),Gr&&_c(Ge,zr),rr}function Xi(Ge,Oe,tt,jt){if(typeof tt=="object"&&tt!==null&&tt.type===C&&tt.key===null&&(tt=tt.props.children),typeof tt=="object"&&tt!==null){switch(tt.$$typeof){case A:e:{for(var rr=tt.key;Oe!==null;){if(Oe.key===rr){if(rr=tt.type,rr===C){if(Oe.tag===7){x(Ge,Oe.sibling),jt=j(Oe,tt.props.children),jt.return=Ge,Ge=jt;break e}}else if(Oe.elementType===rr||typeof rr=="object"&&rr!==null&&rr.$$typeof===z&&Cc(rr)===Oe.type){x(Ge,Oe.sibling),jt=j(Oe,tt.props),uu(jt,tt),jt.return=Ge,Ge=jt;break e}x(Ge,Oe);break}else d(Ge,Oe);Oe=Oe.sibling}tt.type===C?(jt=ed(tt.props.children,Ge.mode,jt,tt.key),jt.return=Ge,Ge=jt):(jt=Rm(tt.type,tt.key,tt.props,null,Ge.mode,jt),uu(jt,tt),jt.return=Ge,Ge=jt)}return Q(Ge);case S:e:{for(rr=tt.key;Oe!==null;){if(Oe.key===rr)if(Oe.tag===4&&Oe.stateNode.containerInfo===tt.containerInfo&&Oe.stateNode.implementation===tt.implementation){x(Ge,Oe.sibling),jt=j(Oe,tt.children||[]),jt.return=Ge,Ge=jt;break e}else{x(Ge,Oe);break}else d(Ge,Oe);Oe=Oe.sibling}jt=ax(tt,Ge.mode,jt),jt.return=Ge,Ge=jt}return Q(Ge);case z:return tt=Cc(tt),Xi(Ge,Oe,tt,jt)}if(ne(tt))return Rn(Ge,Oe,tt,jt);if(X(tt)){if(rr=X(tt),typeof rr!="function")throw Error(r(150));return tt=rr.call(tt),dr(Ge,Oe,tt,jt)}if(typeof tt.then=="function")return Xi(Ge,Oe,Ic(tt),jt);if(tt.$$typeof===L)return Xi(Ge,Oe,cx(Ge,tt),jt);Ql(Ge,tt)}return typeof tt=="string"&&tt!==""||typeof tt=="number"||typeof tt=="bigint"?(tt=""+tt,Oe!==null&&Oe.tag===6?(x(Ge,Oe.sibling),jt=j(Oe,tt),jt.return=Ge,Ge=jt):(x(Ge,Oe),jt=Mf(tt,Ge.mode,jt),jt.return=Ge,Ge=jt),Q(Ge)):x(Ge,Oe)}return function(Ge,Oe,tt,jt){try{id=0;var rr=Xi(Ge,Oe,tt,jt);return cu=null,rr}catch(Wn){if(Wn===rd||Wn===Wf)throw Wn;var Ai=Do(29,Wn,null,Ge.mode);return Ai.lanes=jt,Ai.return=Ge,Ai}finally{}}}var Tc=$m(!0),fx=$m(!1),Zl=!1;function Kf(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function sd(l,d){l=l.updateQueue,d.updateQueue===l&&(d.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function Jl(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function ec(l,d,x){var N=l.updateQueue;if(N===null)return null;if(N=N.shared,(Ii&2)!==0){var j=N.pending;return j===null?d.next=d:(d.next=j.next,j.next=d),N.pending=d,d=Pm(l),Sb(l,null,x),d}return Tm(l,N,d,x),Pm(l)}function ad(l,d,x){if(d=d.updateQueue,d!==null&&(d=d.shared,(x&4194048)!==0)){var N=d.lanes;N&=l.pendingLanes,x|=N,d.lanes=x,xt(l,x)}}function Yf(l,d){var x=l.updateQueue,N=l.alternate;if(N!==null&&(N=N.updateQueue,x===N)){var j=null,R=null;if(x=x.firstBaseUpdate,x!==null){do{var Q={lane:x.lane,tag:x.tag,payload:x.payload,callback:null,next:null};R===null?j=R=Q:R=R.next=Q,x=x.next}while(x!==null);R===null?j=R=d:R=R.next=d}else j=R=d;x={baseState:N.baseState,firstBaseUpdate:j,lastBaseUpdate:R,shared:N.shared,callbacks:N.callbacks},l.updateQueue=x;return}l=x.lastBaseUpdate,l===null?x.firstBaseUpdate=d:l.next=d,x.lastBaseUpdate=d}var px=!1;function mh(){if(px){var l=Xl;if(l!==null)throw l}}function od(l,d,x,N){px=!1;var j=l.updateQueue;Zl=!1;var R=j.firstBaseUpdate,Q=j.lastBaseUpdate,ce=j.shared.pending;if(ce!==null){j.shared.pending=null;var _e=ce,it=_e.next;_e.next=null,Q===null?R=it:Q.next=it,Q=_e;var wt=l.alternate;wt!==null&&(wt=wt.updateQueue,ce=wt.lastBaseUpdate,ce!==Q&&(ce===null?wt.firstBaseUpdate=it:ce.next=it,wt.lastBaseUpdate=_e))}if(R!==null){var Rt=j.baseState;Q=0,wt=it=_e=null,ce=R;do{var lt=ce.lane&-536870913,gt=lt!==ce.lane;if(gt?(ri<)===lt:(N<)===lt){lt!==0&<===nd&&(px=!0),wt!==null&&(wt=wt.next={lane:0,tag:ce.tag,payload:ce.payload,callback:null,next:null});e:{var Rn=l,dr=ce;lt=d;var Xi=x;switch(dr.tag){case 1:if(Rn=dr.payload,typeof Rn=="function"){Rt=Rn.call(Xi,Rt,lt);break e}Rt=Rn;break e;case 3:Rn.flags=Rn.flags&-65537|128;case 0:if(Rn=dr.payload,lt=typeof Rn=="function"?Rn.call(Xi,Rt,lt):Rn,lt==null)break e;Rt=y({},Rt,lt);break e;case 2:Zl=!0}}lt=ce.callback,lt!==null&&(l.flags|=64,gt&&(l.flags|=8192),gt=j.callbacks,gt===null?j.callbacks=[lt]:gt.push(lt))}else gt={lane:lt,tag:ce.tag,payload:ce.payload,callback:ce.callback,next:null},wt===null?(it=wt=gt,_e=Rt):wt=wt.next=gt,Q|=lt;if(ce=ce.next,ce===null){if(ce=j.shared.pending,ce===null)break;gt=ce,ce=gt.next,gt.next=null,j.lastBaseUpdate=gt,j.shared.pending=null}}while(!0);wt===null&&(_e=Rt),j.baseState=_e,j.firstBaseUpdate=it,j.lastBaseUpdate=wt,R===null&&(j.shared.lanes=0),vh|=Q,l.lanes=Q,l.memoizedState=Rt}}function Bb(l,d){if(typeof l!="function")throw Error(r(191,l));l.call(d)}function zb(l,d){var x=l.callbacks;if(x!==null)for(l.callbacks=null,l=0;lR?R:8;var Q=de.T,ce={};de.T=ce,$A(l,!1,d,x);try{var _e=j(),it=de.S;if(it!==null&&it(ce,_e),_e!==null&&typeof _e=="object"&&typeof _e.then=="function"){var wt=Ub(_e,N);bx(l,d,wt,Cl(l))}else bx(l,d,N,Cl(l))}catch(Rt){bx(l,d,{then:function(){},status:"rejected",reason:Rt},Cl())}finally{be.p=R,Q!==null&&ce.types!==null&&(Q.types=ce.types),de.T=Q}}function Fee(){}function VA(l,d,x,N){if(l.tag!==5)throw Error(r(476));var j=DP(l).queue;RP(l,j,d,Ce,x===null?Fee:function(){return MP(l),x(N)})}function DP(l){var d=l.memoizedState;if(d!==null)return d;d={memoizedState:Ce,baseState:Ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Pr,lastRenderedState:Ce},next:null};var x={};return d.next={memoizedState:x,baseState:x,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Pr,lastRenderedState:x},next:null},l.memoizedState=d,l=l.alternate,l!==null&&(l.memoizedState=d),d}function MP(l){var d=DP(l);d.next===null&&(d=l.alternate.memoizedState),bx(l,d.next.queue,{},Cl())}function FA(){return Ba(Mx)}function LP(){return Ae().memoizedState}function UP(){return Ae().memoizedState}function $ee(l){for(var d=l.return;d!==null;){switch(d.tag){case 24:case 3:var x=Cl();l=Jl(x);var N=ec(d,l,x);N!==null&&(dl(N,d,x),ad(N,d,x)),d={cache:Ff()},l.payload=d;return}d=d.return}}function Hee(l,d,x){var N=Cl();x={lane:N,revertLane:0,gesture:null,action:x,hasEagerState:!1,eagerState:null,next:null},Xb(l)?zP(d,x):(x=sx(l,d,x,N),x!==null&&(dl(x,l,N),VP(x,d,N)))}function BP(l,d,x){var N=Cl();bx(l,d,x,N)}function bx(l,d,x,N){var j={lane:N,revertLane:0,gesture:null,action:x,hasEagerState:!1,eagerState:null,next:null};if(Xb(l))zP(d,j);else{var R=l.alternate;if(l.lanes===0&&(R===null||R.lanes===0)&&(R=d.lastRenderedReducer,R!==null))try{var Q=d.lastRenderedState,ce=R(Q,x);if(j.hasEagerState=!0,j.eagerState=ce,E(ce,Q))return Tm(l,d,j,0),es===null&&Im(),!1}catch{}finally{}if(x=sx(l,d,j,N),x!==null)return dl(x,l,N),VP(x,d,N),!0}return!1}function $A(l,d,x,N){if(N={lane:2,revertLane:w5(),gesture:null,action:N,hasEagerState:!1,eagerState:null,next:null},Xb(l)){if(d)throw Error(r(479))}else d=sx(l,x,N,2),d!==null&&dl(d,l,2)}function Xb(l){var d=l.alternate;return l===Tr||d!==null&&d===Tr}function zP(l,d){xh=Wm=!0;var x=l.pending;x===null?d.next=d:(d.next=x.next,x.next=d),l.pending=d}function VP(l,d,x){if((x&4194048)!==0){var N=d.lanes;N&=l.pendingLanes,x|=N,d.lanes=x,xt(l,x)}}var vx={readContext:Ba,use:Jn,useCallback:fs,useContext:fs,useEffect:fs,useImperativeHandle:fs,useLayoutEffect:fs,useInsertionEffect:fs,useMemo:fs,useReducer:fs,useRef:fs,useState:fs,useDebugValue:fs,useDeferredValue:fs,useTransition:fs,useSyncExternalStore:fs,useId:fs,useHostTransitionStatus:fs,useFormState:fs,useActionState:fs,useOptimistic:fs,useMemoCache:fs,useCacheRefresh:fs};vx.useEffectEvent=fs;var FP={readContext:Ba,use:Jn,useCallback:function(l,d){return le().memoizedState=[l,d===void 0?null:d],l},useContext:Ba,useEffect:_P,useImperativeHandle:function(l,d,x){x=x!=null?x.concat([l]):null,Kb(4194308,4,jP.bind(null,d,l),x)},useLayoutEffect:function(l,d){return Kb(4194308,4,l,d)},useInsertionEffect:function(l,d){Kb(4,2,l,d)},useMemo:function(l,d){var x=le();d=d===void 0?null:d;var N=l();if(cd){qe(!0);try{l()}finally{qe(!1)}}return x.memoizedState=[N,d],N},useReducer:function(l,d,x){var N=le();if(x!==void 0){var j=x(d);if(cd){qe(!0);try{x(d)}finally{qe(!1)}}}else j=d;return N.memoizedState=N.baseState=j,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:j},N.queue=l,l=l.dispatch=Hee.bind(null,Tr,l),[N.memoizedState,l]},useRef:function(l){var d=le();return l={current:l},d.memoizedState=l},useState:function(l){l=Lo(l);var d=l.queue,x=BP.bind(null,Tr,d);return d.dispatch=x,[l.memoizedState,x]},useDebugValue:BA,useDeferredValue:function(l,d){var x=le();return zA(x,l,d)},useTransition:function(){var l=Lo(!1);return l=RP.bind(null,Tr,l.queue,!0,!1),le().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,d,x){var N=Tr,j=le();if(Gr){if(x===void 0)throw Error(r(407));x=x()}else{if(x=d(),es===null)throw Error(r(349));(ri&127)!==0||nr(N,d,x)}j.memoizedState=x;var R={value:x,getSnapshot:d};return j.queue=R,_P(Fi.bind(null,N,R,l),[l]),N.flags|=2048,Jm(9,{destroy:void 0},Yn.bind(null,N,R,x,d),null),x},useId:function(){var l=le(),d=es.identifierPrefix;if(Gr){var x=Yl,N=Kl;x=(N&~(1<<32-st(N)-1)).toString(32)+x,d="_"+d+"R_"+x,x=Xf++,0<\/script>",R=R.removeChild(R.firstChild);break;case"select":R=typeof N.is=="string"?Q.createElement("select",{is:N.is}):Q.createElement("select"),N.multiple?R.multiple=!0:N.size&&(R.size=N.size);break;default:R=typeof N.is=="string"?Q.createElement(j,{is:N.is}):Q.createElement(j)}}R[Ut]=d,R[On]=N;e:for(Q=d.child;Q!==null;){if(Q.tag===5||Q.tag===6)R.appendChild(Q.stateNode);else if(Q.tag!==4&&Q.tag!==27&&Q.child!==null){Q.child.return=Q,Q=Q.child;continue}if(Q===d)break e;for(;Q.sibling===null;){if(Q.return===null||Q.return===d)break e;Q=Q.return}Q.sibling.return=Q.return,Q=Q.sibling}d.stateNode=R;e:switch(eo(R,j,N),j){case"button":case"input":case"select":case"textarea":N=!!N.autoFocus;break e;case"img":N=!0;break e;default:N=!1}N&&fd(d)}}return ps(d),r5(d,d.type,l===null?null:l.memoizedProps,d.pendingProps,x),null;case 6:if(l&&d.stateNode!=null)l.memoizedProps!==N&&fd(d);else{if(typeof N!="string"&&d.stateNode===null)throw Error(r(166));if(l=ze.current,Bf(d)){if(l=d.stateNode,x=d.memoizedProps,N=null,j=Rs,j!==null)switch(j.tag){case 27:case 5:N=j.memoizedProps}l[Ut]=d,l=!!(l.nodeValue===x||N!==null&&N.suppressHydrationWarning===!0||o6(l.nodeValue,x)),l||iu(d,!0)}else l=gv(l).createTextNode(N),l[Ut]=d,d.stateNode=l}return ps(d),null;case 31:if(x=d.memoizedState,l===null||l.memoizedState!==null){if(N=Bf(d),x!==null){if(l===null){if(!N)throw Error(r(318));if(l=d.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(r(557));l[Ut]=d}else dh(),(d.flags&128)===0&&(d.memoizedState=null),d.flags|=4;ps(d),l=!1}else x=Rb(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=x),l=!0;if(!l)return d.flags&256?(sa(d),d):(sa(d),null);if((d.flags&128)!==0)throw Error(r(558))}return ps(d),null;case 13:if(N=d.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(j=Bf(d),N!==null&&N.dehydrated!==null){if(l===null){if(!j)throw Error(r(318));if(j=d.memoizedState,j=j!==null?j.dehydrated:null,!j)throw Error(r(317));j[Ut]=d}else dh(),(d.flags&128)===0&&(d.memoizedState=null),d.flags|=4;ps(d),j=!1}else j=Rb(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=j),j=!0;if(!j)return d.flags&256?(sa(d),d):(sa(d),null)}return sa(d),(d.flags&128)!==0?(d.lanes=x,d):(x=N!==null,l=l!==null&&l.memoizedState!==null,x&&(N=d.child,j=null,N.alternate!==null&&N.alternate.memoizedState!==null&&N.alternate.memoizedState.cachePool!==null&&(j=N.alternate.memoizedState.cachePool.pool),R=null,N.memoizedState!==null&&N.memoizedState.cachePool!==null&&(R=N.memoizedState.cachePool.pool),R!==j&&(N.flags|=2048)),x!==l&&x&&(d.child.flags|=8192),tv(d,d.updateQueue),ps(d),null);case 4:return ft(),l===null&&_5(d.stateNode.containerInfo),ps(d),null;case 10:return au(d.type),ps(d),null;case 19:if(xe(Ki),N=d.memoizedState,N===null)return ps(d),null;if(j=(d.flags&128)!==0,R=N.rendering,R===null)if(j)Nx(N,!1);else{if(Fs!==0||l!==null&&(l.flags&128)!==0)for(l=d.child;l!==null;){if(R=qm(l),R!==null){for(d.flags|=128,Nx(N,!1),l=R.updateQueue,d.updateQueue=l,tv(d,l),d.subtreeFlags=0,l=x,x=d.child;x!==null;)jb(x,l),x=x.sibling;return re(Ki,Ki.current&1|2),Gr&&_c(d,N.treeForkCount),d.child}l=l.sibling}N.tail!==null&&mn()>av&&(d.flags|=128,j=!0,Nx(N,!1),d.lanes=4194304)}else{if(!j)if(l=qm(R),l!==null){if(d.flags|=128,j=!0,l=l.updateQueue,d.updateQueue=l,tv(d,l),Nx(N,!0),N.tail===null&&N.tailMode==="hidden"&&!R.alternate&&!Gr)return ps(d),null}else 2*mn()-N.renderingStartTime>av&&x!==536870912&&(d.flags|=128,j=!0,Nx(N,!1),d.lanes=4194304);N.isBackwards?(R.sibling=d.child,d.child=R):(l=N.last,l!==null?l.sibling=R:d.child=R,N.last=R)}return N.tail!==null?(l=N.tail,N.rendering=l,N.tail=l.sibling,N.renderingStartTime=mn(),l.sibling=null,x=Ki.current,re(Ki,j?x&1|2:x&1),Gr&&_c(d,N.treeForkCount),l):(ps(d),null);case 22:case 23:return sa(d),gx(),N=d.memoizedState!==null,l!==null?l.memoizedState!==null!==N&&(d.flags|=8192):N&&(d.flags|=8192),N?(x&536870912)!==0&&(d.flags&128)===0&&(ps(d),d.subtreeFlags&6&&(d.flags|=8192)):ps(d),x=d.updateQueue,x!==null&&tv(d,x.retryQueue),x=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(x=l.memoizedState.cachePool.pool),N=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(N=d.memoizedState.cachePool.pool),N!==x&&(d.flags|=2048),l!==null&&xe(lu),null;case 24:return x=null,l!==null&&(x=l.memoizedState.cache),d.memoizedState.cache!==x&&(d.flags|=2048),au(hs),ps(d),null;case 25:return null;case 30:return null}throw Error(r(156,d.tag))}function Yee(l,d){switch(nu(d),d.tag){case 1:return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return au(hs),ft(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 26:case 27:case 5:return yt(d),null;case 31:if(d.memoizedState!==null){if(sa(d),d.alternate===null)throw Error(r(340));dh()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 13:if(sa(d),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(r(340));dh()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return xe(Ki),null;case 4:return ft(),null;case 10:return au(d.type),null;case 22:case 23:return sa(d),gx(),l!==null&&xe(lu),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 24:return au(hs),null;case 25:return null;default:return null}}function hO(l,d){switch(nu(d),d.tag){case 3:au(hs),ft();break;case 26:case 27:case 5:yt(d);break;case 4:ft();break;case 31:d.memoizedState!==null&&sa(d);break;case 13:sa(d);break;case 19:xe(Ki);break;case 10:au(d.type);break;case 22:case 23:sa(d),gx(),l!==null&&xe(lu);break;case 24:au(hs)}}function Ex(l,d){try{var x=d.updateQueue,N=x!==null?x.lastEffect:null;if(N!==null){var j=N.next;x=j;do{if((x.tag&l)===l){N=void 0;var R=x.create,Q=x.inst;N=R(),Q.destroy=N}x=x.next}while(x!==j)}}catch(ce){Hi(d,d.return,ce)}}function yh(l,d,x){try{var N=d.updateQueue,j=N!==null?N.lastEffect:null;if(j!==null){var R=j.next;N=R;do{if((N.tag&l)===l){var Q=N.inst,ce=Q.destroy;if(ce!==void 0){Q.destroy=void 0,j=d;var _e=x,it=ce;try{it()}catch(wt){Hi(j,_e,wt)}}}N=N.next}while(N!==R)}}catch(wt){Hi(d,d.return,wt)}}function fO(l){var d=l.updateQueue;if(d!==null){var x=l.stateNode;try{zb(d,x)}catch(N){Hi(l,l.return,N)}}}function pO(l,d,x){x.props=Qf(l.type,l.memoizedProps),x.state=l.memoizedState;try{x.componentWillUnmount()}catch(N){Hi(l,d,N)}}function Ax(l,d){try{var x=l.ref;if(x!==null){switch(l.tag){case 26:case 27:case 5:var N=l.stateNode;break;case 30:N=l.stateNode;break;default:N=l.stateNode}typeof x=="function"?l.refCleanup=x(N):x.current=N}}catch(j){Hi(l,d,j)}}function hu(l,d){var x=l.ref,N=l.refCleanup;if(x!==null)if(typeof N=="function")try{N()}catch(j){Hi(l,d,j)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof x=="function")try{x(null)}catch(j){Hi(l,d,j)}else x.current=null}function mO(l){var d=l.type,x=l.memoizedProps,N=l.stateNode;try{e:switch(d){case"button":case"input":case"select":case"textarea":x.autoFocus&&N.focus();break e;case"img":x.src?N.src=x.src:x.srcSet&&(N.srcset=x.srcSet)}}catch(j){Hi(l,l.return,j)}}function i5(l,d,x){try{var N=l.stateNode;xte(N,l.type,x,d),N[On]=d}catch(j){Hi(l,l.return,j)}}function gO(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&_h(l.type)||l.tag===4}function s5(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||gO(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.tag===27&&_h(l.type)||l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function a5(l,d,x){var N=l.tag;if(N===5||N===6)l=l.stateNode,d?(x.nodeType===9?x.body:x.nodeName==="HTML"?x.ownerDocument.body:x).insertBefore(l,d):(d=x.nodeType===9?x.body:x.nodeName==="HTML"?x.ownerDocument.body:x,d.appendChild(l),x=x._reactRootContainer,x!=null||d.onclick!==null||(d.onclick=Cs));else if(N!==4&&(N===27&&_h(l.type)&&(x=l.stateNode,d=null),l=l.child,l!==null))for(a5(l,d,x),l=l.sibling;l!==null;)a5(l,d,x),l=l.sibling}function nv(l,d,x){var N=l.tag;if(N===5||N===6)l=l.stateNode,d?x.insertBefore(l,d):x.appendChild(l);else if(N!==4&&(N===27&&_h(l.type)&&(x=l.stateNode),l=l.child,l!==null))for(nv(l,d,x),l=l.sibling;l!==null;)nv(l,d,x),l=l.sibling}function xO(l){var d=l.stateNode,x=l.memoizedProps;try{for(var N=l.type,j=d.attributes;j.length;)d.removeAttributeNode(j[0]);eo(d,N,x),d[Ut]=l,d[On]=x}catch(R){Hi(l,l.return,R)}}var pd=!1,oa=!1,o5=!1,yO=typeof WeakSet=="function"?WeakSet:Set,za=null;function Xee(l,d){if(l=l.containerInfo,C5=Ev,l=te(l),ae(l)){if("selectionStart"in l)var x={start:l.selectionStart,end:l.selectionEnd};else e:{x=(x=l.ownerDocument)&&x.defaultView||window;var N=x.getSelection&&x.getSelection();if(N&&N.rangeCount!==0){x=N.anchorNode;var j=N.anchorOffset,R=N.focusNode;N=N.focusOffset;try{x.nodeType,R.nodeType}catch{x=null;break e}var Q=0,ce=-1,_e=-1,it=0,wt=0,Rt=l,lt=null;t:for(;;){for(var gt;Rt!==x||j!==0&&Rt.nodeType!==3||(ce=Q+j),Rt!==R||N!==0&&Rt.nodeType!==3||(_e=Q+N),Rt.nodeType===3&&(Q+=Rt.nodeValue.length),(gt=Rt.firstChild)!==null;)lt=Rt,Rt=gt;for(;;){if(Rt===l)break t;if(lt===x&&++it===j&&(ce=Q),lt===R&&++wt===N&&(_e=Q),(gt=Rt.nextSibling)!==null)break;Rt=lt,lt=Rt.parentNode}Rt=gt}x=ce===-1||_e===-1?null:{start:ce,end:_e}}else x=null}x=x||{start:0,end:0}}else x=null;for(j5={focusedElem:l,selectionRange:x},Ev=!1,za=d;za!==null;)if(d=za,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,za=l;else for(;za!==null;){switch(d=za,R=d.alternate,l=d.flags,d.tag){case 0:if((l&4)!==0&&(l=d.updateQueue,l=l!==null?l.events:null,l!==null))for(x=0;x title"))),eo(R,N,x),R[Ut]=l,Qr(R),N=R;break e;case"link":var Q=A6("link","href",j).get(N+(x.href||""));if(Q){for(var ce=0;ceXi&&(Q=Xi,Xi=dr,dr=Q);var Ge=M(ce,dr),Oe=M(ce,Xi);if(Ge&&Oe&&(gt.rangeCount!==1||gt.anchorNode!==Ge.node||gt.anchorOffset!==Ge.offset||gt.focusNode!==Oe.node||gt.focusOffset!==Oe.offset)){var tt=Rt.createRange();tt.setStart(Ge.node,Ge.offset),gt.removeAllRanges(),dr>Xi?(gt.addRange(tt),gt.extend(Oe.node,Oe.offset)):(tt.setEnd(Oe.node,Oe.offset),gt.addRange(tt))}}}}for(Rt=[],gt=ce;gt=gt.parentNode;)gt.nodeType===1&&Rt.push({element:gt,left:gt.scrollLeft,top:gt.scrollTop});for(typeof ce.focus=="function"&&ce.focus(),ce=0;cex?32:x,de.T=null,x=p5,p5=null;var R=Nh,Q=bd;if(ya=0,i0=Nh=null,bd=0,(Ii&6)!==0)throw Error(r(331));var ce=Ii;if(Ii|=4,jO(R.current),kO(R,R.current,Q,x),Ii=ce,Ix(0,!1),me&&typeof me.onPostCommitFiberRoot=="function")try{me.onPostCommitFiberRoot(Xt,R)}catch{}return!0}finally{be.p=j,de.T=N,WO(l,d)}}function YO(l,d,x){d=nl(x,d),d=WA(l.stateNode,d,2),l=ec(l,d,2),l!==null&&(Fn(l,2),fu(l))}function Hi(l,d,x){if(l.tag===3)YO(l,l,x);else for(;d!==null;){if(d.tag===3){YO(d,l,x);break}else if(d.tag===1){var N=d.stateNode;if(typeof d.type.getDerivedStateFromError=="function"||typeof N.componentDidCatch=="function"&&(wh===null||!wh.has(N))){l=nl(x,l),x=XP(2),N=ec(d,x,2),N!==null&&(QP(x,N,d,l),Fn(N,2),fu(N));break}}d=d.return}}function y5(l,d,x){var N=l.pingCache;if(N===null){N=l.pingCache=new Jee;var j=new Set;N.set(d,j)}else j=N.get(d),j===void 0&&(j=new Set,N.set(d,j));j.has(x)||(u5=!0,j.add(x),l=ite.bind(null,l,d,x),d.then(l,l))}function ite(l,d,x){var N=l.pingCache;N!==null&&N.delete(d),l.pingedLanes|=l.suspendedLanes&x,l.warmLanes&=~x,es===l&&(ri&x)===x&&(Fs===4||Fs===3&&(ri&62914560)===ri&&300>mn()-sv?(Ii&2)===0&&s0(l,0):d5|=x,r0===ri&&(r0=0)),fu(l)}function XO(l,d){d===0&&(d=Qe()),l=Jc(l,d),l!==null&&(Fn(l,d),fu(l))}function ste(l){var d=l.memoizedState,x=0;d!==null&&(x=d.retryLane),XO(l,x)}function ate(l,d){var x=0;switch(l.tag){case 31:case 13:var N=l.stateNode,j=l.memoizedState;j!==null&&(x=j.retryLane);break;case 19:N=l.stateNode;break;case 22:N=l.stateNode._retryCache;break;default:throw Error(r(314))}N!==null&&N.delete(d),XO(l,x)}function ote(l,d){return Jt(l,d)}var hv=null,o0=null,b5=!1,fv=!1,v5=!1,Ah=0;function fu(l){l!==o0&&l.next===null&&(o0===null?hv=o0=l:o0=o0.next=l),fv=!0,b5||(b5=!0,cte())}function Ix(l,d){if(!v5&&fv){v5=!0;do for(var x=!1,N=hv;N!==null;){if(l!==0){var j=N.pendingLanes;if(j===0)var R=0;else{var Q=N.suspendedLanes,ce=N.pingedLanes;R=(1<<31-st(42|l)+1)-1,R&=j&~(Q&~ce),R=R&201326741?R&201326741|1:R?R|2:0}R!==0&&(x=!0,e6(N,R))}else R=ri,R=lr(N,N===es?R:0,N.cancelPendingCommit!==null||N.timeoutHandle!==-1),(R&3)===0||ue(N,R)||(x=!0,e6(N,R));N=N.next}while(x);v5=!1}}function lte(){QO()}function QO(){fv=b5=!1;var l=0;Ah!==0&&bte()&&(l=Ah);for(var d=mn(),x=null,N=hv;N!==null;){var j=N.next,R=ZO(N,d);R===0?(N.next=null,x===null?hv=j:x.next=j,j===null&&(o0=x)):(x=N,(l!==0||(R&3)!==0)&&(fv=!0)),N=j}ya!==0&&ya!==5||Ix(l),Ah!==0&&(Ah=0)}function ZO(l,d){for(var x=l.suspendedLanes,N=l.pingedLanes,j=l.expirationTimes,R=l.pendingLanes&-62914561;0ce)break;var wt=_e.transferSize,Rt=_e.initiatorType;wt&&l6(Rt)&&(_e=_e.responseEnd,Q+=wt*(_e"u"?null:document;function v6(l,d,x){var N=l0;if(N&&typeof d=="string"&&d){var j=Ln(d);j='link[rel="'+l+'"][href="'+j+'"]',typeof x=="string"&&(j+='[crossorigin="'+x+'"]'),b6.has(j)||(b6.add(j),l={rel:l,crossOrigin:x,href:d},N.querySelector(j)===null&&(d=N.createElement("link"),eo(d,"link",l),Qr(d),N.head.appendChild(d)))}}function Cte(l){vd.D(l),v6("dns-prefetch",l,null)}function jte(l,d){vd.C(l,d),v6("preconnect",l,d)}function Ite(l,d,x){vd.L(l,d,x);var N=l0;if(N&&l&&d){var j='link[rel="preload"][as="'+Ln(d)+'"]';d==="image"&&x&&x.imageSrcSet?(j+='[imagesrcset="'+Ln(x.imageSrcSet)+'"]',typeof x.imageSizes=="string"&&(j+='[imagesizes="'+Ln(x.imageSizes)+'"]')):j+='[href="'+Ln(l)+'"]';var R=j;switch(d){case"style":R=c0(l);break;case"script":R=u0(l)}nc.has(R)||(l=y({rel:"preload",href:d==="image"&&x&&x.imageSrcSet?void 0:l,as:d},x),nc.set(R,l),N.querySelector(j)!==null||d==="style"&&N.querySelector(Rx(R))||d==="script"&&N.querySelector(Dx(R))||(d=N.createElement("link"),eo(d,"link",l),Qr(d),N.head.appendChild(d)))}}function Tte(l,d){vd.m(l,d);var x=l0;if(x&&l){var N=d&&typeof d.as=="string"?d.as:"script",j='link[rel="modulepreload"][as="'+Ln(N)+'"][href="'+Ln(l)+'"]',R=j;switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":R=u0(l)}if(!nc.has(R)&&(l=y({rel:"modulepreload",href:l},d),nc.set(R,l),x.querySelector(j)===null)){switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(x.querySelector(Dx(R)))return}N=x.createElement("link"),eo(N,"link",l),Qr(N),x.head.appendChild(N)}}}function Pte(l,d,x){vd.S(l,d,x);var N=l0;if(N&&l){var j=li(N).hoistableStyles,R=c0(l);d=d||"default";var Q=j.get(R);if(!Q){var ce={loading:0,preload:null};if(Q=N.querySelector(Rx(R)))ce.loading=5;else{l=y({rel:"stylesheet",href:l,"data-precedence":d},x),(x=nc.get(R))&&M5(l,x);var _e=Q=N.createElement("link");Qr(_e),eo(_e,"link",l),_e._p=new Promise(function(it,wt){_e.onload=it,_e.onerror=wt}),_e.addEventListener("load",function(){ce.loading|=1}),_e.addEventListener("error",function(){ce.loading|=2}),ce.loading|=4,yv(Q,d,N)}Q={type:"stylesheet",instance:Q,count:1,state:ce},j.set(R,Q)}}}function Ote(l,d){vd.X(l,d);var x=l0;if(x&&l){var N=li(x).hoistableScripts,j=u0(l),R=N.get(j);R||(R=x.querySelector(Dx(j)),R||(l=y({src:l,async:!0},d),(d=nc.get(j))&&L5(l,d),R=x.createElement("script"),Qr(R),eo(R,"link",l),x.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},N.set(j,R))}}function Rte(l,d){vd.M(l,d);var x=l0;if(x&&l){var N=li(x).hoistableScripts,j=u0(l),R=N.get(j);R||(R=x.querySelector(Dx(j)),R||(l=y({src:l,async:!0,type:"module"},d),(d=nc.get(j))&&L5(l,d),R=x.createElement("script"),Qr(R),eo(R,"link",l),x.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},N.set(j,R))}}function w6(l,d,x,N){var j=(j=ze.current)?xv(j):null;if(!j)throw Error(r(446));switch(l){case"meta":case"title":return null;case"style":return typeof x.precedence=="string"&&typeof x.href=="string"?(d=c0(x.href),x=li(j).hoistableStyles,N=x.get(d),N||(N={type:"style",instance:null,count:0,state:null},x.set(d,N)),N):{type:"void",instance:null,count:0,state:null};case"link":if(x.rel==="stylesheet"&&typeof x.href=="string"&&typeof x.precedence=="string"){l=c0(x.href);var R=li(j).hoistableStyles,Q=R.get(l);if(Q||(j=j.ownerDocument||j,Q={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},R.set(l,Q),(R=j.querySelector(Rx(l)))&&!R._p&&(Q.instance=R,Q.state.loading=5),nc.has(l)||(x={rel:"preload",as:"style",href:x.href,crossOrigin:x.crossOrigin,integrity:x.integrity,media:x.media,hrefLang:x.hrefLang,referrerPolicy:x.referrerPolicy},nc.set(l,x),R||Dte(j,l,x,Q.state))),d&&N===null)throw Error(r(528,""));return Q}if(d&&N!==null)throw Error(r(529,""));return null;case"script":return d=x.async,x=x.src,typeof x=="string"&&d&&typeof d!="function"&&typeof d!="symbol"?(d=u0(x),x=li(j).hoistableScripts,N=x.get(d),N||(N={type:"script",instance:null,count:0,state:null},x.set(d,N)),N):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,l))}}function c0(l){return'href="'+Ln(l)+'"'}function Rx(l){return'link[rel="stylesheet"]['+l+"]"}function N6(l){return y({},l,{"data-precedence":l.precedence,precedence:null})}function Dte(l,d,x,N){l.querySelector('link[rel="preload"][as="style"]['+d+"]")?N.loading=1:(d=l.createElement("link"),N.preload=d,d.addEventListener("load",function(){return N.loading|=1}),d.addEventListener("error",function(){return N.loading|=2}),eo(d,"link",x),Qr(d),l.head.appendChild(d))}function u0(l){return'[src="'+Ln(l)+'"]'}function Dx(l){return"script[async]"+l}function E6(l,d,x){if(d.count++,d.instance===null)switch(d.type){case"style":var N=l.querySelector('style[data-href~="'+Ln(x.href)+'"]');if(N)return d.instance=N,Qr(N),N;var j=y({},x,{"data-href":x.href,"data-precedence":x.precedence,href:null,precedence:null});return N=(l.ownerDocument||l).createElement("style"),Qr(N),eo(N,"style",j),yv(N,x.precedence,l),d.instance=N;case"stylesheet":j=c0(x.href);var R=l.querySelector(Rx(j));if(R)return d.state.loading|=4,d.instance=R,Qr(R),R;N=N6(x),(j=nc.get(j))&&M5(N,j),R=(l.ownerDocument||l).createElement("link"),Qr(R);var Q=R;return Q._p=new Promise(function(ce,_e){Q.onload=ce,Q.onerror=_e}),eo(R,"link",N),d.state.loading|=4,yv(R,x.precedence,l),d.instance=R;case"script":return R=u0(x.src),(j=l.querySelector(Dx(R)))?(d.instance=j,Qr(j),j):(N=x,(j=nc.get(R))&&(N=y({},x),L5(N,j)),l=l.ownerDocument||l,j=l.createElement("script"),Qr(j),eo(j,"link",N),l.head.appendChild(j),d.instance=j);case"void":return null;default:throw Error(r(443,d.type))}else d.type==="stylesheet"&&(d.state.loading&4)===0&&(N=d.instance,d.state.loading|=4,yv(N,x.precedence,l));return d.instance}function yv(l,d,x){for(var N=x.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),j=N.length?N[N.length-1]:null,R=j,Q=0;Q title"):null)}function Mte(l,d,x){if(x===1||d.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof d.precedence!="string"||typeof d.href!="string"||d.href==="")break;return!0;case"link":if(typeof d.rel!="string"||typeof d.href!="string"||d.href===""||d.onLoad||d.onError)break;switch(d.rel){case"stylesheet":return l=d.disabled,typeof d.precedence=="string"&&l==null;default:return!0}case"script":if(d.async&&typeof d.async!="function"&&typeof d.async!="symbol"&&!d.onLoad&&!d.onError&&d.src&&typeof d.src=="string")return!0}return!1}function k6(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function Lte(l,d,x,N){if(x.type==="stylesheet"&&(typeof N.media!="string"||matchMedia(N.media).matches!==!1)&&(x.state.loading&4)===0){if(x.instance===null){var j=c0(N.href),R=d.querySelector(Rx(j));if(R){d=R._p,d!==null&&typeof d=="object"&&typeof d.then=="function"&&(l.count++,l=vv.bind(l),d.then(l,l)),x.state.loading|=4,x.instance=R,Qr(R);return}R=d.ownerDocument||d,N=N6(N),(j=nc.get(j))&&M5(N,j),R=R.createElement("link"),Qr(R);var Q=R;Q._p=new Promise(function(ce,_e){Q.onload=ce,Q.onerror=_e}),eo(R,"link",N),x.instance=R}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(x,d),(d=x.state.preload)&&(x.state.loading&3)===0&&(l.count++,x=vv.bind(l),d.addEventListener("load",x),d.addEventListener("error",x))}}var U5=0;function Ute(l,d){return l.stylesheets&&l.count===0&&Nv(l,l.stylesheets),0U5?50:800)+d);return l.unsuspend=x,function(){l.unsuspend=null,clearTimeout(N),clearTimeout(j)}}:null}function vv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Nv(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var wv=null;function Nv(l,d){l.stylesheets=null,l.unsuspend!==null&&(l.count++,wv=new Map,d.forEach(Bte,l),wv=null,vv.call(l))}function Bte(l,d){if(!(d.state.loading&4)){var x=wv.get(l);if(x)var N=x.get(null);else{x=new Map,wv.set(l,x);for(var j=l.querySelectorAll("link[data-precedence],style[data-precedence]"),R=0;R"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),W5.exports=ine(),W5.exports}var ane=sne(),XV=(e=>(e.BASE="base",e.BODY="body",e.HEAD="head",e.HTML="html",e.LINK="link",e.META="meta",e.NOSCRIPT="noscript",e.SCRIPT="script",e.STYLE="style",e.TITLE="title",e.FRAGMENT="Symbol(react.fragment)",e))(XV||{}),Q5={link:{rel:["amphtml","canonical","alternate"]},script:{type:["application/ld+json"]},meta:{charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]}};Object.values(XV);var yI={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"};Object.entries(yI).reduce((e,[t,n])=>(e[n]=t,e),{});var J1="data-rh",one=e=>Array.isArray(e)?e.join(""):e,lne=(e,t)=>{const n=Object.keys(e);for(let r=0;rArray.isArray(e)?e.reduce((n,r)=>(lne(r,t)?n.priority.push(r):n.default.push(r),n),{priority:[],default:[]}):{default:e,priority:[]},cne=["noscript","script","style"],LS=(e,t=!0)=>t===!1?String(e):String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),QV=e=>Object.keys(e).reduce((t,n)=>{const r=typeof e[n]<"u"?`${n}="${e[n]}"`:`${n}`;return t?`${t} ${r}`:r},""),une=(e,t,n,r)=>{const i=QV(n),a=one(t);return i?`<${e} ${J1}="true" ${i}>${LS(a,r)}`:`<${e} ${J1}="true">${LS(a,r)}`},dne=(e,t,n=!0)=>t.reduce((r,i)=>{const a=i,o=Object.keys(a).filter(f=>!(f==="innerHTML"||f==="cssText")).reduce((f,m)=>{const y=typeof a[m]>"u"?m:`${m}="${LS(a[m],n)}"`;return f?`${f} ${y}`:y},""),c=a.innerHTML||a.cssText||"",h=cne.indexOf(e)===-1;return`${r}<${e} ${J1}="true" ${o}${h?"/>":`>${c}`}`},""),ZV=(e,t={})=>Object.keys(e).reduce((n,r)=>{const i=yI[r];return n[i||r]=e[r],n},t),hne=(e,t,n)=>{const r={key:t,[J1]:!0},i=ZV(n,r);return[ie.createElement("title",i,t)]},ww=(e,t)=>t.map((n,r)=>{const i={key:r,[J1]:!0};return Object.keys(n).forEach(a=>{const c=yI[a]||a;if(c==="innerHTML"||c==="cssText"){const h=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:h}}else i[c]=n[a]}),ie.createElement(e,i)}),oc=(e,t,n=!0)=>{switch(e){case"title":return{toComponent:()=>hne(e,t.title,t.titleAttributes),toString:()=>une(e,t.title,t.titleAttributes,n)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>ZV(t),toString:()=>QV(t)};default:return{toComponent:()=>ww(e,t),toString:()=>dne(e,t,n)}}},fne=({metaTags:e,linkTags:t,scriptTags:n,encode:r})=>{const i=Z5(e,Q5.meta),a=Z5(t,Q5.link),o=Z5(n,Q5.script);return{priorityMethods:{toComponent:()=>[...ww("meta",i.priority),...ww("link",a.priority),...ww("script",o.priority)],toString:()=>`${oc("meta",i.priority,r)} ${oc("link",a.priority,r)} ${oc("script",o.priority,r)}`},metaTags:i.default,linkTags:a.default,scriptTags:o.default}},pne=e=>{const{baseTag:t,bodyAttributes:n,encode:r=!0,htmlAttributes:i,noscriptTags:a,styleTags:o,title:c="",titleAttributes:h,prioritizeSeoTags:f}=e;let{linkTags:m,metaTags:y,scriptTags:w}=e,A={toComponent:()=>[],toString:()=>""};return f&&({priorityMethods:A,linkTags:m,metaTags:y,scriptTags:w}=fne(e)),{priority:A,base:oc("base",t,r),bodyAttributes:oc("bodyAttributes",n,r),htmlAttributes:oc("htmlAttributes",i,r),link:oc("link",m,r),meta:oc("meta",y,r),noscript:oc("noscript",a,r),script:oc("script",w,r),style:oc("style",o,r),title:oc("title",{title:c,titleAttributes:h},r)}},mne=pne,Tv=[],JV=!!(typeof window<"u"&&window.document&&window.document.createElement),gne=class{constructor(e,t){wd(this,"instances",[]);wd(this,"canUseDOM",JV);wd(this,"context");wd(this,"value",{setHelmet:e=>{this.context.helmet=e},helmetInstances:{get:()=>this.canUseDOM?Tv:this.instances,add:e=>{(this.canUseDOM?Tv:this.instances).push(e)},remove:e=>{const t=(this.canUseDOM?Tv:this.instances).indexOf(e);(this.canUseDOM?Tv:this.instances).splice(t,1)}}});this.context=e,this.canUseDOM=t||!1,t||(e.helmet=mne({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},xne=parseInt(ie.version.split(".")[0],10),X6=xne>=19,yne={},bne=ie.createContext(yne),Pp,eF=(Pp=class extends I.Component{constructor(n){super(n);wd(this,"helmetData");X6?this.helmetData=null:this.helmetData=new gne(this.props.context||{},Pp.canUseDOM)}render(){return X6?ie.createElement(ie.Fragment,null,this.props.children):ie.createElement(bne.Provider,{value:this.helmetData.value},this.props.children)}},wd(Pp,"canUseDOM",JV),Pp),JN=YV();/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vne=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),wne=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),Q6=e=>{const t=wne(e);return t.charAt(0).toUpperCase()+t.slice(1)},tF=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),Nne=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var Ene={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.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ane=I.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...c},h)=>I.createElement("svg",{ref:h,...Ene,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:tF("lucide",i),...!a&&!Nne(c)&&{"aria-hidden":"true"},...c},[...o.map(([f,m])=>I.createElement(f,m)),...Array.isArray(a)?a:[a]]));/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $t=(e,t)=>{const n=I.forwardRef(({className:r,...i},a)=>I.createElement(Ane,{ref:a,iconNode:t,className:tF(`lucide-${vne(Q6(e))}`,`lucide-${e}`,r),...i}));return n.displayName=Q6(e),n};/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ne=[["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"}]],kne=$t("activity",_ne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sne=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Cne=$t("arrow-left",Sne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jne=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Op=$t("arrow-right",jne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ine=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],nF=$t("at-sign",Ine);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tne=[["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"}]],Ou=$t("bell",Tne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pne=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],One=$t("bookmark",Pne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rne=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Dne=$t("bot",Rne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mne=[["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3",key:"cabbwy"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]],Lne=$t("building",Mne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Une=[["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"}]],rg=$t("calendar",Une);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bne=[["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"}]],US=$t("camera",Bne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zne=[["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"}]],wp=$t("chart-column",zne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vne=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],Fne=$t("check-check",Vne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ne=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Bu=$t("check",$ne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hne=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Bd=$t("chevron-down",Hne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gne=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],qp=$t("chevron-left",Gne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qne=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Wp=$t("chevron-right",qne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wne=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],df=$t("chevron-up",Wne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kne=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],Yne=$t("chevrons-left",Kne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xne=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],Qne=$t("chevrons-right",Xne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zne=[["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"}]],rF=$t("circle-alert",Zne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],lc=$t("circle-check",Jne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ere=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],iF=$t("circle-question-mark",ere);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tre=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],J5=$t("clock",tre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nre=[["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"}]],n2=$t("copy",nre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rre=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],Z6=$t("corner-down-left",rre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ire=[["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}],["path",{d:"M9 14 4 9l5-5",key:"102s5s"}]],sre=$t("corner-up-left",ire);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const are=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],ore=$t("cpu",are);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lre=[["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"}]],Fx=$t("database",lre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cre=[["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"}]],eE=$t("download",cre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ure=[["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"}]],dre=$t("ellipsis",ure);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hre=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],$a=$t("external-link",hre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fre=[["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"}]],J6=$t("eye-off",fre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pre=[["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"}]],I1=$t("eye",pre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mre=[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]],sF=$t("facebook",mre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gre=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],D0=$t("file-text",gre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xre=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],yre=$t("film",xre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bre=[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]],vre=$t("flame",bre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wre=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],S0=$t("globe",wre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nre=[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]],Ere=$t("grip-horizontal",Nre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Are=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["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"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],_re=$t("hard-drive",Are);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kre=[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]],Zh=$t("headphones",kre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sre=[["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"}]],mc=$t("heart",Sre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cre=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],eR=$t("house",Cre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jre=[["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"}]],xu=$t("image",jre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ire=[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]],aF=$t("instagram",Ire);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tre=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Pre=$t("key",Tre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ore=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Ad=$t("link",Ore);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rre=[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]],oF=$t("linkedin",Rre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dre=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Er=$t("loader-circle",Dre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mre=[["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"}]],lF=$t("lock",Mre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lre=[["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"}]],ea=$t("mail",Lre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ure=[["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"}]],BS=$t("map-pin",Ure);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bre=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],r2=$t("maximize-2",Bre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zre=[["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"}]],vu=$t("megaphone",zre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vre=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],tE=$t("menu",Vre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fre=[["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"}]],Kp=$t("message-circle",Fre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $re=[["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"}]],bi=$t("message-square",$re);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hre=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]],Gre=$t("mic-off",Hre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qre=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],Wre=$t("mic",qre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kre=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],bI=$t("minimize-2",Kre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yre=[["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-4 0v-9a2 2 0 0 1 2-2h2",key:"39pd36"}],["rect",{width:"8",height:"4",x:"10",y:"6",rx:"1",key:"aywv1n"}]],Fh=$t("newspaper",Yre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xre=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Qre=$t("paperclip",Xre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zre=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],tR=$t("pause",Zre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jre=[["path",{d:"M10.1 13.9a14 14 0 0 0 3.732 2.668 1 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 2 18 18 0 0 1-12.728-5.272",key:"1wngk7"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}],["path",{d:"M4.76 13.582A18 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 .244.473",key:"10hv5p"}]],cF=$t("phone-off",Jre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eie=[["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"}]],zS=$t("phone",eie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tie=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],C0=$t("pin",tie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nie=[["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"}]],Yp=$t("play",nie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rie=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Lc=$t("plus",rie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iie=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],sie=$t("qr-code",iie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aie=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],uc=$t("radio",aie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oie=[["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"}]],uF=$t("refresh-cw",oie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lie=[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]],nR=$t("reply",lie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cie=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],dF=$t("rotate-cw",cie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uie=[["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"}]],rR=$t("save",uie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const die=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Rp=$t("search",die);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hie=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Eo=$t("send",hie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fie=[["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"}]],VS=$t("settings",fie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pie=[["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"}]],hf=$t("share-2",pie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mie=[["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"}]],gie=$t("shield-alert",mie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xie=[["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"}]],pl=$t("shield-check",xie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yie=[["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"}]],vI=$t("shield",yie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bie=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],vie=$t("shopping-bag",bie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wie=[["path",{d:"M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z",key:"15892j"}],["path",{d:"M3 20V4",key:"1ptbpl"}]],Nie=$t("skip-back",wie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eie=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],Aie=$t("skip-forward",Eie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ie=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],kie=$t("smartphone",_ie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],hF=$t("smile",Sie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cie=[["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"}]],Zi=$t("sparkles",Cie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jie=[["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"}]],kd=$t("square-pen",jie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iie=[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]],Tie=$t("thumbs-up",Iie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pie=[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]],Aa=$t("ticket",Pie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oie=[["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"}]],As=$t("trash-2",Oie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rie=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Nu=$t("trending-up",Rie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Die=[["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"}]],ku=$t("triangle-alert",Die);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mie=[["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"}]],fF=$t("upload",Mie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lie=[["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"}]],ey=$t("user-check",Lie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uie=[["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"}]],Np=$t("user-plus",Uie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bie=[["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"}]],nE=$t("user",Bie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zie=[["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"}]],_o=$t("users",zie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vie=[["path",{d:"M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196",key:"w8jjjt"}],["path",{d:"M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"1xawa7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Fie=$t("video-off",Vie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ie=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Ea=$t("video",$ie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hie=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],Gie=$t("volume-2",Hie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qie=[["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}],["path",{d:"M5 7c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v12H5V7Z",key:"1ezoue"}],["path",{d:"M22 19H2",key:"nuriw5"}]],FS=$t("vote",qie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wie=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Kie=$t("wifi-off",Wie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yie=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Xie=$t("wifi",Yie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qie=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],er=$t("x",Qie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zie=[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]],pF=$t("youtube",Zie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jie=[["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"}]],mF=$t("zap",Jie),ese=()=>{};var iR={};/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const gF=function(e){const t=[];let n=0;for(let r=0;r>6|192,t[n++]=i&63|128):(i&64512)===55296&&r+1>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t},tse=function(e){const t=[];let n=0,r=0;for(;n191&&i<224){const a=e[n++];t[r++]=String.fromCharCode((i&31)<<6|a&63)}else if(i>239&&i<365){const a=e[n++],o=e[n++],c=e[n++],h=((i&7)<<18|(a&63)<<12|(o&63)<<6|c&63)-65536;t[r++]=String.fromCharCode(55296+(h>>10)),t[r++]=String.fromCharCode(56320+(h&1023))}else{const a=e[n++],o=e[n++];t[r++]=String.fromCharCode((i&15)<<12|(a&63)<<6|o&63)}}return t.join("")},xF={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let i=0;i>2,y=(a&3)<<4|c>>4;let w=(c&15)<<2|f>>6,A=f&63;h||(A=64,o||(w=64)),r.push(n[m],n[y],n[w],n[A])}return r.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(gF(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):tse(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let i=0;i>4;if(r.push(w),f!==64){const A=c<<4&240|f>>2;if(r.push(A),y!==64){const S=f<<6&192|y;r.push(S)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class nse extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const rse=function(e){const t=gF(e);return xF.encodeByteArray(t,!0)},yF=function(e){return rse(e).replace(/\./g,"")},bF=function(e){try{return xF.decodeString(e,!0)}catch(t){console.error("base64Decode failed: ",t)}return null};/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function vF(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const ise=()=>vF().__FIREBASE_DEFAULTS__,sse=()=>{if(typeof process>"u"||typeof iR>"u")return;const e=iR.__FIREBASE_DEFAULTS__;if(e)return JSON.parse(e)},ase=()=>{if(typeof document>"u")return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const t=e&&bF(e[1]);return t&&JSON.parse(t)},rE=()=>{try{return ese()||ise()||sse()||ase()}catch(e){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);return}},ose=e=>{var t,n;return(n=(t=rE())==null?void 0:t.emulatorHosts)==null?void 0:n[e]},wF=()=>{var e;return(e=rE())==null?void 0:e.config},NF=e=>{var t;return(t=rE())==null?void 0:t[`_${e}`]};/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class lse{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((t,n)=>{this.resolve=t,this.reject=n})}wrapCallback(t){return(n,r)=>{n?this.reject(n):this.resolve(r),typeof t=="function"&&(this.promise.catch(()=>{}),t.length===1?t(n):t(n,r))}}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Sa(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function cse(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Sa())}function EF(){var t;const e=(t=rE())==null?void 0:t.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function use(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function dse(){const e=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof e=="object"&&e.id!==void 0}function hse(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function fse(){const e=Sa();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0}function AF(){return!EF()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function _F(){return!EF()&&!!navigator.userAgent&&(navigator.userAgent.includes("Safari")||navigator.userAgent.includes("WebKit"))&&!navigator.userAgent.includes("Chrome")}function kF(){try{return typeof indexedDB=="object"}catch{return!1}}function pse(){return new Promise((e,t)=>{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{var a;t(((a=i.error)==null?void 0:a.message)||"")}}catch(n){t(n)}})}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const mse="FirebaseError";class Xd extends Error{constructor(t,n,r){super(n),this.code=t,this.customData=r,this.name=mse,Object.setPrototypeOf(this,Xd.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Dy.prototype.create)}}class Dy{constructor(t,n,r){this.service=t,this.serviceName=n,this.errors=r}create(t,...n){const r=n[0]||{},i=`${this.service}/${t}`,a=this.errors[t],o=a?gse(a,r):"Error",c=`${this.serviceName}: ${o} (${i}).`;return new Xd(i,c,r)}}function gse(e,t){return e.replace(xse,(n,r)=>{const i=t[r];return i!=null?String(i):`<${r}?>`})}const xse=/\{\$([^}]+)}/g;function yse(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function zd(e,t){if(e===t)return!0;const n=Object.keys(e),r=Object.keys(t);for(const i of n){if(!r.includes(i))return!1;const a=e[i],o=t[i];if(sR(a)&&sR(o)){if(!zd(a,o))return!1}else if(a!==o)return!1}for(const i of r)if(!n.includes(i))return!1;return!0}function sR(e){return e!==null&&typeof e=="object"}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function My(e){const t=[];for(const[n,r]of Object.entries(e))Array.isArray(r)?r.forEach(i=>{t.push(encodeURIComponent(n)+"="+encodeURIComponent(i))}):t.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return t.length?"&"+t.join("&"):""}function g1(e){const t={};return e.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[i,a]=r.split("=");t[decodeURIComponent(i)]=decodeURIComponent(a)}}),t}function x1(e){const t=e.indexOf("?");if(!t)return"";const n=e.indexOf("#",t);return e.substring(t,n>0?n:void 0)}function bse(e,t){const n=new vse(e,t);return n.subscribe.bind(n)}class vse{constructor(t,n){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=n,this.task.then(()=>{t(this)}).catch(r=>{this.error(r)})}next(t){this.forEachObserver(n=>{n.next(t)})}error(t){this.forEachObserver(n=>{n.error(t)}),this.close(t)}complete(){this.forEachObserver(t=>{t.complete()}),this.close()}subscribe(t,n,r){let i;if(t===void 0&&n===void 0&&r===void 0)throw new Error("Missing Observer.");wse(t,["next","error","complete"])?i=t:i={next:t,error:n,complete:r},i.next===void 0&&(i.next=e_),i.error===void 0&&(i.error=e_),i.complete===void 0&&(i.complete=e_);const a=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch{}}),this.observers.push(i),a}unsubscribeOne(t){this.observers===void 0||this.observers[t]===void 0||(delete this.observers[t],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let n=0;n{if(this.observers!==void 0&&this.observers[t]!==void 0)try{n(this.observers[t])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(t){this.finalized||(this.finalized=!0,t!==void 0&&(this.finalError=t),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function wse(e,t){if(typeof e!="object"||e===null)return!1;for(const n of t)if(n in e&&typeof e[n]=="function")return!0;return!1}function e_(){}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Ca(e){return e&&e._delegate?e._delegate:e}/** * @license * Copyright 2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Ly(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch{return!1}}async function SF(e){return(await fetch(e,{credentials:"include"})).ok}class Xp{constructor(t,n,r){this.name=t,this.instanceFactory=n,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const lp="[DEFAULT]";/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */let Nse=class{constructor(t,n){this.name=t,this.container=n,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const n=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(n)){const r=new lse;if(this.instancesDeferred.set(n,r),this.isInitialized(n)||this.shouldAutoInitialize())try{const i=this.getOrInitializeService({instanceIdentifier:n});i&&r.resolve(i)}catch{}}return this.instancesDeferred.get(n).promise}getImmediate(t){const n=this.normalizeInstanceIdentifier(t==null?void 0:t.identifier),r=(t==null?void 0:t.optional)??!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(i){if(r)return null;throw i}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,!!this.shouldAutoInitialize()){if(Ase(t))try{this.getOrInitializeService({instanceIdentifier:lp})}catch{}for(const[n,r]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(n);try{const a=this.getOrInitializeService({instanceIdentifier:i});r.resolve(a)}catch{}}}}clearInstance(t=lp){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter(n=>"INTERNAL"in n).map(n=>n.INTERNAL.delete()),...t.filter(n=>"_delete"in n).map(n=>n._delete())])}isComponentSet(){return this.component!=null}isInitialized(t=lp){return this.instances.has(t)}getOptions(t=lp){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:n={}}=t,r=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:r,options:n});for(const[a,o]of this.instancesDeferred.entries()){const c=this.normalizeInstanceIdentifier(a);r===c&&o.resolve(i)}return i}onInit(t,n){const r=this.normalizeInstanceIdentifier(n),i=this.onInitCallbacks.get(r)??new Set;i.add(t),this.onInitCallbacks.set(r,i);const a=this.instances.get(r);return a&&t(a,r),()=>{i.delete(t)}}invokeOnInitCallbacks(t,n){const r=this.onInitCallbacks.get(n);if(r)for(const i of r)try{i(t,n)}catch{}}getOrInitializeService({instanceIdentifier:t,options:n={}}){let r=this.instances.get(t);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:Ese(t),options:n}),this.instances.set(t,r),this.instancesOptions.set(t,n),this.invokeOnInitCallbacks(r,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,r)}catch{}return r||null}normalizeInstanceIdentifier(t=lp){return this.component?this.component.multipleInstances?t:lp:t}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}};function Ese(e){return e===lp?void 0:e}function Ase(e){return e.instantiationMode==="EAGER"}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class _se{constructor(t){this.name=t,this.providers=new Map}addComponent(t){const n=this.getProvider(t.name);if(n.isComponentSet())throw new Error(`Component ${t.name} has already been registered with ${this.name}`);n.setComponent(t)}addOrOverwriteComponent(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)}getProvider(t){if(this.providers.has(t))return this.providers.get(t);const n=new Nse(t,this);return this.providers.set(t,n),n}getProviders(){return Array.from(this.providers.values())}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var ai;(function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"})(ai||(ai={}));const kse={debug:ai.DEBUG,verbose:ai.VERBOSE,info:ai.INFO,warn:ai.WARN,error:ai.ERROR,silent:ai.SILENT},Sse=ai.INFO,Cse={[ai.DEBUG]:"log",[ai.VERBOSE]:"log",[ai.INFO]:"info",[ai.WARN]:"warn",[ai.ERROR]:"error"},jse=(e,t,...n)=>{if(tt.some(n=>e instanceof n);let aR,oR;function Tse(){return aR||(aR=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Pse(){return oR||(oR=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const CF=new WeakMap,$S=new WeakMap,jF=new WeakMap,t_=new WeakMap,NI=new WeakMap;function Ose(e){const t=new Promise((n,r)=>{const i=()=>{e.removeEventListener("success",a),e.removeEventListener("error",o)},a=()=>{n(nf(e.result)),i()},o=()=>{r(e.error),i()};e.addEventListener("success",a),e.addEventListener("error",o)});return t.then(n=>{n instanceof IDBCursor&&CF.set(n,e)}).catch(()=>{}),NI.set(t,e),t}function Rse(e){if($S.has(e))return;const t=new Promise((n,r)=>{const i=()=>{e.removeEventListener("complete",a),e.removeEventListener("error",o),e.removeEventListener("abort",o)},a=()=>{n(),i()},o=()=>{r(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",a),e.addEventListener("error",o),e.addEventListener("abort",o)});$S.set(e,t)}let HS={get(e,t,n){if(e instanceof IDBTransaction){if(t==="done")return $S.get(e);if(t==="objectStoreNames")return e.objectStoreNames||jF.get(e);if(t==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return nf(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function Dse(e){HS=e(HS)}function Mse(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...n){const r=e.call(n_(this),t,...n);return jF.set(r,t.sort?t.sort():[t]),nf(r)}:Pse().includes(e)?function(...t){return e.apply(n_(this),t),nf(CF.get(this))}:function(...t){return nf(e.apply(n_(this),t))}}function Lse(e){return typeof e=="function"?Mse(e):(e instanceof IDBTransaction&&Rse(e),Ise(e,Tse())?new Proxy(e,HS):e)}function nf(e){if(e instanceof IDBRequest)return Ose(e);if(t_.has(e))return t_.get(e);const t=Lse(e);return t!==e&&(t_.set(e,t),NI.set(t,e)),t}const n_=e=>NI.get(e);function Use(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){const o=indexedDB.open(e,t),c=nf(o);return r&&o.addEventListener("upgradeneeded",h=>{r(nf(o.result),h.oldVersion,h.newVersion,nf(o.transaction),h)}),n&&o.addEventListener("blocked",h=>n(h.oldVersion,h.newVersion,h)),c.then(h=>{a&&h.addEventListener("close",()=>a()),i&&h.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),c}const Bse=["get","getKey","getAll","getAllKeys","count"],zse=["put","add","delete","clear"],r_=new Map;function lR(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(r_.get(t))return r_.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=zse.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||Bse.includes(n)))return;const a=async function(o,...c){const h=this.transaction(o,i?"readwrite":"readonly");let f=h.store;return r&&(f=f.index(c.shift())),(await Promise.all([f[n](...c),i&&h.done]))[0]};return r_.set(t,a),a}Dse(e=>({...e,get:(t,n,r)=>lR(t,n)||e.get(t,n,r),has:(t,n)=>!!lR(t,n)||e.has(t,n)}));/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Vse{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map(n=>{if(Fse(n)){const r=n.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(n=>n).join(" ")}}function Fse(e){const t=e.getComponent();return(t==null?void 0:t.type)==="VERSION"}const GS="@firebase/app",cR="0.14.10";/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Vd=new wI("@firebase/app"),$se="@firebase/app-compat",Hse="@firebase/analytics-compat",Gse="@firebase/analytics",qse="@firebase/app-check-compat",Wse="@firebase/app-check",Kse="@firebase/auth",Yse="@firebase/auth-compat",Xse="@firebase/database",Qse="@firebase/data-connect",Zse="@firebase/database-compat",Jse="@firebase/functions",eae="@firebase/functions-compat",tae="@firebase/installations",nae="@firebase/installations-compat",rae="@firebase/messaging",iae="@firebase/messaging-compat",sae="@firebase/performance",aae="@firebase/performance-compat",oae="@firebase/remote-config",lae="@firebase/remote-config-compat",cae="@firebase/storage",uae="@firebase/storage-compat",dae="@firebase/firestore",hae="@firebase/ai",fae="@firebase/firestore-compat",pae="firebase",mae="12.11.0";/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const qS="[DEFAULT]",gae={[GS]:"fire-core",[$se]:"fire-core-compat",[Gse]:"fire-analytics",[Hse]:"fire-analytics-compat",[Wse]:"fire-app-check",[qse]:"fire-app-check-compat",[Kse]:"fire-auth",[Yse]:"fire-auth-compat",[Xse]:"fire-rtdb",[Qse]:"fire-data-connect",[Zse]:"fire-rtdb-compat",[Jse]:"fire-fn",[eae]:"fire-fn-compat",[tae]:"fire-iid",[nae]:"fire-iid-compat",[rae]:"fire-fcm",[iae]:"fire-fcm-compat",[sae]:"fire-perf",[aae]:"fire-perf-compat",[oae]:"fire-rc",[lae]:"fire-rc-compat",[cae]:"fire-gcs",[uae]:"fire-gcs-compat",[dae]:"fire-fst",[fae]:"fire-fst-compat",[hae]:"fire-vertex","fire-js":"fire-js",[pae]:"fire-js-all"};/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const i2=new Map,xae=new Map,WS=new Map;function uR(e,t){try{e.container.addComponent(t)}catch(n){Vd.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function ig(e){const t=e.name;if(WS.has(t))return Vd.debug(`There were multiple attempts to register component ${t}.`),!1;WS.set(t,e);for(const n of i2.values())uR(n,e);for(const n of xae.values())uR(n,e);return!0}function EI(e,t){const n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function Pl(e){return e==null?!1:e.settings!==void 0}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const yae={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},rf=new Dy("app","Firebase",yae);/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class bae{constructor(t,n,r){this._isDeleted=!1,this._options={...t},this._config={...n},this._name=n.name,this._automaticDataCollectionEnabled=n.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new Xp("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw rf.create("app-deleted",{appName:this._name})}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Lg=mae;function IF(e,t={}){let n=e;typeof t!="object"&&(t={name:t});const r={name:qS,automaticDataCollectionEnabled:!0,...t},i=r.name;if(typeof i!="string"||!i)throw rf.create("bad-app-name",{appName:String(i)});if(n||(n=wF()),!n)throw rf.create("no-options");const a=i2.get(i);if(a){if(zd(n,a.options)&&zd(r,a.config))return a;throw rf.create("duplicate-app",{appName:i})}const o=new _se(i);for(const h of WS.values())o.addComponent(h);const c=new bae(n,r,o);return i2.set(i,c),c}function vae(e=qS){const t=i2.get(e);if(!t&&e===qS&&wF())return IF();if(!t)throw rf.create("no-app",{appName:e});return t}function sf(e,t,n){let r=gae[e]??e;n&&(r+=`-${n}`);const i=r.match(/\s|\//),a=t.match(/\s|\//);if(i||a){const o=[`Unable to register library "${r}" with version "${t}":`];i&&o.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&a&&o.push("and"),a&&o.push(`version name "${t}" contains illegal characters (whitespace or "/")`),Vd.warn(o.join(" "));return}ig(new Xp(`${r}-version`,()=>({library:r,version:t}),"VERSION"))}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const wae="firebase-heartbeat-database",Nae=1,ty="firebase-heartbeat-store";let i_=null;function TF(){return i_||(i_=Use(wae,Nae,{upgrade:(e,t)=>{switch(t){case 0:try{e.createObjectStore(ty)}catch(n){console.warn(n)}}}}).catch(e=>{throw rf.create("idb-open",{originalErrorMessage:e.message})})),i_}async function Eae(e){try{const n=(await TF()).transaction(ty),r=await n.objectStore(ty).get(PF(e));return await n.done,r}catch(t){if(t instanceof Xd)Vd.warn(t.message);else{const n=rf.create("idb-get",{originalErrorMessage:t==null?void 0:t.message});Vd.warn(n.message)}}}async function dR(e,t){try{const r=(await TF()).transaction(ty,"readwrite");await r.objectStore(ty).put(t,PF(e)),await r.done}catch(n){if(n instanceof Xd)Vd.warn(n.message);else{const r=rf.create("idb-set",{originalErrorMessage:n==null?void 0:n.message});Vd.warn(r.message)}}}function PF(e){return`${e.name}!${e.options.appId}`}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Aae=1024,_ae=30;class kae{constructor(t){this.container=t,this._heartbeatsCache=null;const n=this.container.getProvider("app").getImmediate();this._storage=new Cae(n),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){var t,n;try{const i=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),a=hR();if(((t=this._heartbeatsCache)==null?void 0:t.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((n=this._heartbeatsCache)==null?void 0:n.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===a||this._heartbeatsCache.heartbeats.some(o=>o.date===a))return;if(this._heartbeatsCache.heartbeats.push({date:a,agent:i}),this._heartbeatsCache.heartbeats.length>_ae){const o=jae(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(o,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(r){Vd.warn(r)}}async getHeartbeatsHeader(){var t;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((t=this._heartbeatsCache)==null?void 0:t.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const n=hR(),{heartbeatsToSend:r,unsentEntries:i}=Sae(this._heartbeatsCache.heartbeats),a=yF(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=n,i.length>0?(this._heartbeatsCache.heartbeats=i,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),a}catch(n){return Vd.warn(n),""}}}function hR(){return new Date().toISOString().substring(0,10)}function Sae(e,t=Aae){const n=[];let r=e.slice();for(const i of e){const a=n.find(o=>o.agent===i.agent);if(a){if(a.dates.push(i.date),fR(n)>t){a.dates.pop();break}}else if(n.push({agent:i.agent,dates:[i.date]}),fR(n)>t){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}class Cae{constructor(t){this.app=t,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return kF()?pse().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const n=await Eae(this.app);return n!=null&&n.heartbeats?n:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(t){if(await this._canUseIndexedDBPromise){const r=await this.read();return dR(this.app,{lastSentHeartbeatDate:t.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:t.heartbeats})}else return}async add(t){if(await this._canUseIndexedDBPromise){const r=await this.read();return dR(this.app,{lastSentHeartbeatDate:t.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...t.heartbeats]})}else return}}function fR(e){return yF(JSON.stringify({version:2,heartbeats:e})).length}function jae(e){if(e.length===0)return-1;let t=0,n=e[0].date;for(let r=1;rnew Vse(t),"PRIVATE")),ig(new Xp("heartbeat",t=>new kae(t),"PRIVATE")),sf(GS,cR,e),sf(GS,cR,"esm2020"),sf("fire-js","")}Iae("");var Tae="firebase",Pae="12.11.0";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */sf(Tae,Pae,"app");function OF(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const Oae=OF,RF=new Dy("auth","Firebase",OF());/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const s2=new wI("@firebase/auth");function Rae(e,...t){s2.logLevel<=ai.WARN&&s2.warn(`Auth (${Lg}): ${e}`,...t)}function Nw(e,...t){s2.logLevel<=ai.ERROR&&s2.error(`Auth (${Lg}): ${e}`,...t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function xc(e,...t){throw _I(e,...t)}function $c(e,...t){return _I(e,...t)}function AI(e,t,n){const r={...Oae(),[t]:n};return new Dy("auth","Firebase",r).create(t,{appName:e.name})}function Dd(e){return AI(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function Dae(e,t,n){const r=n;if(!(t instanceof r))throw r.name!==t.constructor.name&&xc(e,"argument-error"),AI(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function _I(e,...t){if(typeof e!="string"){const n=t[0],r=[...t.slice(1)];return r[0]&&(r[0].appName=e.name),e._errorFactory.create(n,...r)}return RF.create(e,...t)}function br(e,t,...n){if(!e)throw _I(t,...n)}function Id(e){const t="INTERNAL ASSERTION FAILED: "+e;throw Nw(t),new Error(t)}function Fd(e,t){e||Id(t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function KS(){var e;return typeof self<"u"&&((e=self.location)==null?void 0:e.href)||""}function Mae(){return pR()==="http:"||pR()==="https:"}function pR(){var e;return typeof self<"u"&&((e=self.location)==null?void 0:e.protocol)||null}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Lae(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(Mae()||dse()||"connection"in navigator)?navigator.onLine:!0}function Uae(){if(typeof navigator>"u")return null;const e=navigator;return e.languages&&e.languages[0]||e.language||null}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Uy{constructor(t,n){this.shortDelay=t,this.longDelay=n,Fd(n>t,"Short delay should be less than long delay!"),this.isMobile=cse()||hse()}get(){return Lae()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function kI(e,t){Fd(e.emulator,"Emulator should always be set here");const{url:n}=e.emulator;return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class DF{static initialize(t,n,r){this.fetchImpl=t,n&&(this.headersImpl=n),r&&(this.responseImpl=r)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;Id("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;Id("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;Id("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Bae={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const zae=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],Vae=new Uy(3e4,6e4);function wf(e,t){return e.tenantId&&!t.tenantId?{...t,tenantId:e.tenantId}:t}async function Qd(e,t,n,r,i={}){return MF(e,i,async()=>{let a={},o={};r&&(t==="GET"?o=r:a={body:JSON.stringify(r)});const c=My({key:e.config.apiKey,...o}).slice(1),h=await e._getAdditionalHeaders();h["Content-Type"]="application/json",e.languageCode&&(h["X-Firebase-Locale"]=e.languageCode);const f={method:t,headers:h,...a};return use()||(f.referrerPolicy="no-referrer"),e.emulatorConfig&&Ly(e.emulatorConfig.host)&&(f.credentials="include"),DF.fetch()(await LF(e,e.config.apiHost,n,c),f)})}async function MF(e,t,n){e._canInitEmulator=!1;const r={...Bae,...t};try{const i=new $ae(e),a=await Promise.race([n(),i.promise]);i.clearNetworkTimeout();const o=await a.json();if("needConfirmation"in o)throw Pv(e,"account-exists-with-different-credential",o);if(a.ok&&!("errorMessage"in o))return o;{const c=a.ok?o.errorMessage:o.error.message,[h,f]=c.split(" : ");if(h==="FEDERATED_USER_ID_ALREADY_LINKED")throw Pv(e,"credential-already-in-use",o);if(h==="EMAIL_EXISTS")throw Pv(e,"email-already-in-use",o);if(h==="USER_DISABLED")throw Pv(e,"user-disabled",o);const m=r[h]||h.toLowerCase().replace(/[_\s]+/g,"-");if(f)throw AI(e,m,f);xc(e,m)}}catch(i){if(i instanceof Xd)throw i;xc(e,"network-request-failed",{message:String(i)})}}async function By(e,t,n,r,i={}){const a=await Qd(e,t,n,r,i);return"mfaPendingCredential"in a&&xc(e,"multi-factor-auth-required",{_serverResponse:a}),a}async function LF(e,t,n,r){const i=`${t}${n}?${r}`,a=e,o=a.config.emulator?kI(e.config,i):`${e.config.apiScheme}://${i}`;return zae.includes(n)&&(await a._persistenceManagerAvailable,a._getPersistenceType()==="COOKIE")?a._getPersistence()._getFinalTarget(o).toString():o}function Fae(e){switch(e){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class $ae{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(t){this.auth=t,this.timer=null,this.promise=new Promise((n,r)=>{this.timer=setTimeout(()=>r($c(this.auth,"network-request-failed")),Vae.get())})}}function Pv(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=$c(e,t,r);return i.customData._tokenResponse=n,i}function mR(e){return e!==void 0&&e.enterprise!==void 0}class Hae{constructor(t){if(this.siteKey="",this.recaptchaEnforcementState=[],t.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=t.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=t.recaptchaEnforcementState}getProviderEnforcementState(t){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const n of this.recaptchaEnforcementState)if(n.provider&&n.provider===t)return Fae(n.enforcementState);return null}isProviderEnabled(t){return this.getProviderEnforcementState(t)==="ENFORCE"||this.getProviderEnforcementState(t)==="AUDIT"}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function Gae(e,t){return Qd(e,"GET","/v2/recaptchaConfig",wf(e,t))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function qae(e,t){return Qd(e,"POST","/v1/accounts:delete",t)}async function a2(e,t){return Qd(e,"POST","/v1/accounts:lookup",t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function T1(e){if(e)try{const t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch{}}async function Wae(e,t=!1){const n=Ca(e),r=await n.getIdToken(t),i=SI(r);br(i&&i.exp&&i.auth_time&&i.iat,n.auth,"internal-error");const a=typeof i.firebase=="object"?i.firebase:void 0,o=a==null?void 0:a.sign_in_provider;return{claims:i,token:r,authTime:T1(s_(i.auth_time)),issuedAtTime:T1(s_(i.iat)),expirationTime:T1(s_(i.exp)),signInProvider:o||null,signInSecondFactor:(a==null?void 0:a.sign_in_second_factor)||null}}function s_(e){return Number(e)*1e3}function SI(e){const[t,n,r]=e.split(".");if(t===void 0||n===void 0||r===void 0)return Nw("JWT malformed, contained fewer than 3 sections"),null;try{const i=bF(n);return i?JSON.parse(i):(Nw("Failed to decode base64 JWT payload"),null)}catch(i){return Nw("Caught error parsing JWT payload as JSON",i==null?void 0:i.toString()),null}}function gR(e){const t=SI(e);return br(t,"internal-error"),br(typeof t.exp<"u","internal-error"),br(typeof t.iat<"u","internal-error"),Number(t.exp)-Number(t.iat)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function sg(e,t,n=!1){if(n)return t;try{return await t}catch(r){throw r instanceof Xd&&Kae(r)&&e.auth.currentUser===e&&await e.auth.signOut(),r}}function Kae({code:e}){return e==="auth/user-disabled"||e==="auth/user-token-expired"}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Yae{constructor(t){this.user=t,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(t){if(t){const n=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),n}else{this.errorBackoff=3e4;const r=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,r)}}schedule(t=!1){if(!this.isRunning)return;const n=this.getInterval(t);this.timerId=setTimeout(async()=>{await this.iteration()},n)}async iteration(){try{await this.user.getIdToken(!0)}catch(t){(t==null?void 0:t.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class YS{constructor(t,n){this.createdAt=t,this.lastLoginAt=n,this._initializeTime()}_initializeTime(){this.lastSignInTime=T1(this.lastLoginAt),this.creationTime=T1(this.createdAt)}_copy(t){this.createdAt=t.createdAt,this.lastLoginAt=t.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function o2(e){var y;const t=e.auth,n=await e.getIdToken(),r=await sg(e,a2(t,{idToken:n}));br(r==null?void 0:r.users.length,t,"internal-error");const i=r.users[0];e._notifyReloadListener(i);const a=(y=i.providerUserInfo)!=null&&y.length?UF(i.providerUserInfo):[],o=Qae(e.providerData,a),c=e.isAnonymous,h=!(e.email&&i.passwordHash)&&!(o!=null&&o.length),f=c?h:!1,m={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:o,metadata:new YS(i.createdAt,i.lastLoginAt),isAnonymous:f};Object.assign(e,m)}async function Xae(e){const t=Ca(e);await o2(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}function Qae(e,t){return[...e.filter(r=>!t.some(i=>i.providerId===r.providerId)),...t]}function UF(e){return e.map(({providerId:t,...n})=>({providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function Zae(e,t){const n=await MF(e,{},async()=>{const r=My({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:i,apiKey:a}=e.config,o=await LF(e,i,"/v1/token",`key=${a}`),c=await e._getAdditionalHeaders();c["Content-Type"]="application/x-www-form-urlencoded";const h={method:"POST",headers:c,body:r};return e.emulatorConfig&&Ly(e.emulatorConfig.host)&&(h.credentials="include"),DF.fetch()(o,h)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function Jae(e,t){return Qd(e,"POST","/v2/accounts:revokeToken",wf(e,t))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class G0{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(t){br(t.idToken,"internal-error"),br(typeof t.idToken<"u","internal-error"),br(typeof t.refreshToken<"u","internal-error");const n="expiresIn"in t&&typeof t.expiresIn<"u"?Number(t.expiresIn):gR(t.idToken);this.updateTokensAndExpiration(t.idToken,t.refreshToken,n)}updateFromIdToken(t){br(t.length!==0,"internal-error");const n=gR(t);this.updateTokensAndExpiration(t,null,n)}async getToken(t,n=!1){return!n&&this.accessToken&&!this.isExpired?this.accessToken:(br(this.refreshToken,t,"user-token-expired"),this.refreshToken?(await this.refresh(t,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(t,n){const{accessToken:r,refreshToken:i,expiresIn:a}=await Zae(t,n);this.updateTokensAndExpiration(r,i,Number(a))}updateTokensAndExpiration(t,n,r){this.refreshToken=n||null,this.accessToken=t||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(t,n){const{refreshToken:r,accessToken:i,expirationTime:a}=n,o=new G0;return r&&(br(typeof r=="string","internal-error",{appName:t}),o.refreshToken=r),i&&(br(typeof i=="string","internal-error",{appName:t}),o.accessToken=i),a&&(br(typeof a=="number","internal-error",{appName:t}),o.expirationTime=a),o}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(t){this.accessToken=t.accessToken,this.refreshToken=t.refreshToken,this.expirationTime=t.expirationTime}_clone(){return Object.assign(new G0,this.toJSON())}_performRefresh(){return Id("not implemented")}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Th(e,t){br(typeof e=="string"||typeof e>"u","internal-error",{appName:t})}class Fc{constructor({uid:t,auth:n,stsTokenManager:r,...i}){this.providerId="firebase",this.proactiveRefresh=new Yae(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=n,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.providerData=i.providerData?[...i.providerData]:[],this.metadata=new YS(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(t){const n=await sg(this,this.stsTokenManager.getToken(this.auth,t));return br(n,this.auth,"internal-error"),this.accessToken!==n&&(this.accessToken=n,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),n}getIdTokenResult(t){return Wae(this,t)}reload(){return Xae(this)}_assign(t){this!==t&&(br(this.uid===t.uid,this.auth,"internal-error"),this.displayName=t.displayName,this.photoURL=t.photoURL,this.email=t.email,this.emailVerified=t.emailVerified,this.phoneNumber=t.phoneNumber,this.isAnonymous=t.isAnonymous,this.tenantId=t.tenantId,this.providerData=t.providerData.map(n=>({...n})),this.metadata._copy(t.metadata),this.stsTokenManager._assign(t.stsTokenManager))}_clone(t){const n=new Fc({...this,auth:t,stsTokenManager:this.stsTokenManager._clone()});return n.metadata._copy(this.metadata),n}_onReload(t){br(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=t,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(t){this.reloadListener?this.reloadListener(t):this.reloadUserInfo=t}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(t,n=!1){let r=!1;t.idToken&&t.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(t),r=!0),n&&await o2(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Pl(this.auth.app))return Promise.reject(Dd(this.auth));const t=await this.getIdToken();return await sg(this,qae(this.auth,{idToken:t})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(t=>({...t})),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId,...this.metadata.toJSON(),apiKey:this.auth.config.apiKey,appName:this.auth.name}}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(t,n){const r=n.displayName??void 0,i=n.email??void 0,a=n.phoneNumber??void 0,o=n.photoURL??void 0,c=n.tenantId??void 0,h=n._redirectEventId??void 0,f=n.createdAt??void 0,m=n.lastLoginAt??void 0,{uid:y,emailVerified:w,isAnonymous:A,providerData:S,stsTokenManager:C}=n;br(y&&C,t,"internal-error");const T=G0.fromJSON(this.name,C);br(typeof y=="string",t,"internal-error"),Th(r,t.name),Th(i,t.name),br(typeof w=="boolean",t,"internal-error"),br(typeof A=="boolean",t,"internal-error"),Th(a,t.name),Th(o,t.name),Th(c,t.name),Th(h,t.name),Th(f,t.name),Th(m,t.name);const D=new Fc({uid:y,auth:t,email:i,emailVerified:w,displayName:r,isAnonymous:A,photoURL:o,phoneNumber:a,tenantId:c,stsTokenManager:T,createdAt:f,lastLoginAt:m});return S&&Array.isArray(S)&&(D.providerData=S.map(V=>({...V}))),h&&(D._redirectEventId=h),D}static async _fromIdTokenResponse(t,n,r=!1){const i=new G0;i.updateFromServerResponse(n);const a=new Fc({uid:n.localId,auth:t,stsTokenManager:i,isAnonymous:r});return await o2(a),a}static async _fromGetAccountInfoResponse(t,n,r){const i=n.users[0];br(i.localId!==void 0,"internal-error");const a=i.providerUserInfo!==void 0?UF(i.providerUserInfo):[],o=!(i.email&&i.passwordHash)&&!(a!=null&&a.length),c=new G0;c.updateFromIdToken(r);const h=new Fc({uid:i.localId,auth:t,stsTokenManager:c,isAnonymous:o}),f={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:a,metadata:new YS(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash)&&!(a!=null&&a.length)};return Object.assign(h,f),h}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const xR=new Map;function Td(e){Fd(e instanceof Function,"Expected a class definition");let t=xR.get(e);return t?(Fd(t instanceof e,"Instance stored in cache mismatched with class"),t):(t=new e,xR.set(e,t),t)}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class BF{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(t,n){this.storage[t]=n}async _get(t){const n=this.storage[t];return n===void 0?null:n}async _remove(t){delete this.storage[t]}_addListener(t,n){}_removeListener(t,n){}}BF.type="NONE";const yR=BF;/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Ew(e,t,n){return`firebase:${e}:${t}:${n}`}class q0{constructor(t,n,r){this.persistence=t,this.auth=n,this.userKey=r;const{config:i,name:a}=this.auth;this.fullUserKey=Ew(this.userKey,i.apiKey,a),this.fullPersistenceKey=Ew("persistence",i.apiKey,a),this.boundEventHandler=n._onStorageEvent.bind(n),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(t){return this.persistence._set(this.fullUserKey,t.toJSON())}async getCurrentUser(){const t=await this.persistence._get(this.fullUserKey);if(!t)return null;if(typeof t=="string"){const n=await a2(this.auth,{idToken:t}).catch(()=>{});return n?Fc._fromGetAccountInfoResponse(this.auth,n,t):null}return Fc._fromJSON(this.auth,t)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(t){if(this.persistence===t)return;const n=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=t,n)return this.setCurrentUser(n)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(t,n,r="authUser"){if(!n.length)return new q0(Td(yR),t,r);const i=(await Promise.all(n.map(async f=>{if(await f._isAvailable())return f}))).filter(f=>f);let a=i[0]||Td(yR);const o=Ew(r,t.config.apiKey,t.name);let c=null;for(const f of n)try{const m=await f._get(o);if(m){let y;if(typeof m=="string"){const w=await a2(t,{idToken:m}).catch(()=>{});if(!w)break;y=await Fc._fromGetAccountInfoResponse(t,w,m)}else y=Fc._fromJSON(t,m);f!==a&&(c=y),a=f;break}}catch{}const h=i.filter(f=>f._shouldAllowMigration);return!a._shouldAllowMigration||!h.length?new q0(a,t,r):(a=h[0],c&&await a._set(o,c.toJSON()),await Promise.all(n.map(async f=>{if(f!==a)try{await f._remove(o)}catch{}})),new q0(a,t,r))}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function bR(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if($F(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(zF(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(GF(t))return"Blackberry";if(qF(t))return"Webos";if(VF(t))return"Safari";if((t.includes("chrome/")||FF(t))&&!t.includes("edge/"))return"Chrome";if(HF(t))return"Android";{const n=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=e.match(n);if((r==null?void 0:r.length)===2)return r[1]}return"Other"}function zF(e=Sa()){return/firefox\//i.test(e)}function VF(e=Sa()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function FF(e=Sa()){return/crios\//i.test(e)}function $F(e=Sa()){return/iemobile/i.test(e)}function HF(e=Sa()){return/android/i.test(e)}function GF(e=Sa()){return/blackberry/i.test(e)}function qF(e=Sa()){return/webos/i.test(e)}function CI(e=Sa()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function eoe(e=Sa()){var t;return CI(e)&&!!((t=window.navigator)!=null&&t.standalone)}function toe(){return fse()&&document.documentMode===10}function WF(e=Sa()){return CI(e)||HF(e)||qF(e)||GF(e)||/windows phone/i.test(e)||$F(e)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function KF(e,t=[]){let n;switch(e){case"Browser":n=bR(Sa());break;case"Worker":n=`${bR(Sa())}-${e}`;break;default:n=e}const r=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${Lg}/${r}`}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class noe{constructor(t){this.auth=t,this.queue=[]}pushCallback(t,n){const r=a=>new Promise((o,c)=>{try{const h=t(a);o(h)}catch(h){c(h)}});r.onAbort=n,this.queue.push(r);const i=this.queue.length-1;return()=>{this.queue[i]=()=>Promise.resolve()}}async runMiddleware(t){if(this.auth.currentUser===t)return;const n=[];try{for(const r of this.queue)await r(t),r.onAbort&&n.push(r.onAbort)}catch(r){n.reverse();for(const i of n)try{i()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r==null?void 0:r.message})}}}/** * @license * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function roe(e,t={}){return Qd(e,"GET","/v2/passwordPolicy",wf(e,t))}/** * @license * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const ioe=6;class soe{constructor(t){var r;const n=t.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=n.minPasswordLength??ioe,n.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=n.maxPasswordLength),n.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=n.containsLowercaseCharacter),n.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=n.containsUppercaseCharacter),n.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=n.containsNumericCharacter),n.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=n.containsNonAlphanumericCharacter),this.enforcementState=t.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=((r=t.allowedNonAlphanumericCharacters)==null?void 0:r.join(""))??"",this.forceUpgradeOnSignin=t.forceUpgradeOnSignin??!1,this.schemaVersion=t.schemaVersion}validatePassword(t){const n={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(t,n),this.validatePasswordCharacterOptions(t,n),n.isValid&&(n.isValid=n.meetsMinPasswordLength??!0),n.isValid&&(n.isValid=n.meetsMaxPasswordLength??!0),n.isValid&&(n.isValid=n.containsLowercaseLetter??!0),n.isValid&&(n.isValid=n.containsUppercaseLetter??!0),n.isValid&&(n.isValid=n.containsNumericCharacter??!0),n.isValid&&(n.isValid=n.containsNonAlphanumericCharacter??!0),n}validatePasswordLengthOptions(t,n){const r=this.customStrengthOptions.minPasswordLength,i=this.customStrengthOptions.maxPasswordLength;r&&(n.meetsMinPasswordLength=t.length>=r),i&&(n.meetsMaxPasswordLength=t.length<=i)}validatePasswordCharacterOptions(t,n){this.updatePasswordCharacterOptionsStatuses(n,!1,!1,!1,!1);let r;for(let i=0;i="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(t,n,r,i,a){this.customStrengthOptions.containsLowercaseLetter&&(t.containsLowercaseLetter||(t.containsLowercaseLetter=n)),this.customStrengthOptions.containsUppercaseLetter&&(t.containsUppercaseLetter||(t.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(t.containsNumericCharacter||(t.containsNumericCharacter=i)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(t.containsNonAlphanumericCharacter||(t.containsNonAlphanumericCharacter=a))}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class aoe{constructor(t,n,r,i){this.app=t,this.heartbeatServiceProvider=n,this.appCheckServiceProvider=r,this.config=i,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new vR(this),this.idTokenSubscription=new vR(this),this.beforeStateQueue=new noe(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=RF,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=t.name,this.clientVersion=i.sdkClientVersion,this._persistenceManagerAvailable=new Promise(a=>this._resolvePersistenceManagerAvailable=a)}_initializeWithPersistence(t,n){return n&&(this._popupRedirectResolver=Td(n)),this._initializationPromise=this.queue(async()=>{var r,i,a;if(!this._deleted&&(this.persistenceManager=await q0.create(this,t),(r=this._resolvePersistenceManagerAvailable)==null||r.call(this),!this._deleted)){if((i=this._popupRedirectResolver)!=null&&i._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(n),this.lastNotifiedUid=((a=this.currentUser)==null?void 0:a.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const t=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!t)){if(this.currentUser&&t&&this.currentUser.uid===t.uid){this._currentUser._assign(t),await this.currentUser.getIdToken();return}await this._updateCurrentUser(t,!0)}}async initializeCurrentUserFromIdToken(t){try{const n=await a2(this,{idToken:t}),r=await Fc._fromGetAccountInfoResponse(this,n,t);await this.directlySetCurrentUser(r)}catch(n){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",n),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(t){var a;if(Pl(this.app)){const o=this.app.settings.authIdToken;return o?new Promise(c=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(o).then(c,c))}):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let r=n,i=!1;if(t&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const o=(a=this.redirectUser)==null?void 0:a._redirectEventId,c=r==null?void 0:r._redirectEventId,h=await this.tryRedirectSignIn(t);(!o||o===c)&&(h!=null&&h.user)&&(r=h.user,i=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(r)}catch(o){r=n,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(o))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return br(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(t){let n=null;try{n=await this._popupRedirectResolver._completeRedirectFn(this,t,!0)}catch{await this._setRedirectUser(null)}return n}async reloadAndSetCurrentUserOrClear(t){try{await o2(t)}catch(n){if((n==null?void 0:n.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(t)}useDeviceLanguage(){this.languageCode=Uae()}async _delete(){this._deleted=!0}async updateCurrentUser(t){if(Pl(this.app))return Promise.reject(Dd(this));const n=t?Ca(t):null;return n&&br(n.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(n&&n._clone(this))}async _updateCurrentUser(t,n=!1){if(!this._deleted)return t&&br(this.tenantId===t.tenantId,this,"tenant-id-mismatch"),n||await this.beforeStateQueue.runMiddleware(t),this.queue(async()=>{await this.directlySetCurrentUser(t),this.notifyAuthListeners()})}async signOut(){return Pl(this.app)?Promise.reject(Dd(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(t){return Pl(this.app)?Promise.reject(Dd(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(Td(t))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(t){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const n=this._getPasswordPolicyInternal();return n.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):n.validatePassword(t)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const t=await roe(this),n=new soe(t);this.tenantId===null?this._projectPasswordPolicy=n:this._tenantPasswordPolicies[this.tenantId]=n}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(t){this._errorFactory=new Dy("auth","Firebase",t())}onAuthStateChanged(t,n,r){return this.registerStateListener(this.authStateSubscription,t,n,r)}beforeAuthStateChanged(t,n){return this.beforeStateQueue.pushCallback(t,n)}onIdTokenChanged(t,n,r){return this.registerStateListener(this.idTokenSubscription,t,n,r)}authStateReady(){return new Promise((t,n)=>{if(this.currentUser)t();else{const r=this.onAuthStateChanged(()=>{r(),t()},n)}})}async revokeAccessToken(t){if(this.currentUser){const n=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:t,idToken:n};this.tenantId!=null&&(r.tenantId=this.tenantId),await Jae(this,r)}}toJSON(){var t;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(t=this._currentUser)==null?void 0:t.toJSON()}}async _setRedirectUser(t,n){const r=await this.getOrInitRedirectPersistenceManager(n);return t===null?r.removeCurrentUser():r.setCurrentUser(t)}async getOrInitRedirectPersistenceManager(t){if(!this.redirectPersistenceManager){const n=t&&Td(t)||this._popupRedirectResolver;br(n,this,"argument-error"),this.redirectPersistenceManager=await q0.create(this,[Td(n._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(t){var n,r;return this._isInitialized&&await this.queue(async()=>{}),((n=this._currentUser)==null?void 0:n._redirectEventId)===t?this._currentUser:((r=this.redirectUser)==null?void 0:r._redirectEventId)===t?this.redirectUser:null}async _persistUserIfCurrent(t){if(t===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(t))}_notifyListenersIfCurrent(t){t===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var n;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const t=((n=this.currentUser)==null?void 0:n.uid)??null;this.lastNotifiedUid!==t&&(this.lastNotifiedUid=t,this.authStateSubscription.next(this.currentUser))}registerStateListener(t,n,r,i){if(this._deleted)return()=>{};const a=typeof n=="function"?n:n.next.bind(n);let o=!1;const c=this._isInitialized?Promise.resolve():this._initializationPromise;if(br(c,this,"internal-error"),c.then(()=>{o||a(this.currentUser)}),typeof n=="function"){const h=t.addObserver(n,r,i);return()=>{o=!0,h()}}else{const h=t.addObserver(n);return()=>{o=!0,h()}}}async directlySetCurrentUser(t){this.currentUser&&this.currentUser!==t&&this._currentUser._stopProactiveRefresh(),t&&this.isProactiveRefreshEnabled&&t._startProactiveRefresh(),this.currentUser=t,t?await this.assertedPersistence.setCurrentUser(t):await this.assertedPersistence.removeCurrentUser()}queue(t){return this.operations=this.operations.then(t,t),this.operations}get assertedPersistence(){return br(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(t){!t||this.frameworks.includes(t)||(this.frameworks.push(t),this.frameworks.sort(),this.clientVersion=KF(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var i;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const n=await((i=this.heartbeatServiceProvider.getImmediate({optional:!0}))==null?void 0:i.getHeartbeatsHeader());n&&(t["X-Firebase-Client"]=n);const r=await this._getAppCheckToken();return r&&(t["X-Firebase-AppCheck"]=r),t}async _getAppCheckToken(){var n;if(Pl(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const t=await((n=this.appCheckServiceProvider.getImmediate({optional:!0}))==null?void 0:n.getToken());return t!=null&&t.error&&Rae(`Error while retrieving App Check token: ${t.error}`),t==null?void 0:t.token}}function Nf(e){return Ca(e)}class vR{constructor(t){this.auth=t,this.observer=null,this.addObserver=bse(n=>this.observer=n)}get next(){return br(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */let iE={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function ooe(e){iE=e}function YF(e){return iE.loadJS(e)}function loe(){return iE.recaptchaEnterpriseScript}function coe(){return iE.gapiScript}function uoe(e){return`__${e}${Math.floor(Math.random()*1e6)}`}class doe{constructor(){this.enterprise=new hoe}ready(t){t()}execute(t,n){return Promise.resolve("token")}render(t,n){return""}}class hoe{ready(t){t()}execute(t,n){return Promise.resolve("token")}render(t,n){return""}}const foe="recaptcha-enterprise",XF="NO_RECAPTCHA";class poe{constructor(t){this.type=foe,this.auth=Nf(t)}async verify(t="verify",n=!1){async function r(a){if(!n){if(a.tenantId==null&&a._agentRecaptchaConfig!=null)return a._agentRecaptchaConfig.siteKey;if(a.tenantId!=null&&a._tenantRecaptchaConfigs[a.tenantId]!==void 0)return a._tenantRecaptchaConfigs[a.tenantId].siteKey}return new Promise(async(o,c)=>{Gae(a,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(h=>{if(h.recaptchaKey===void 0)c(new Error("recaptcha Enterprise site key undefined"));else{const f=new Hae(h);return a.tenantId==null?a._agentRecaptchaConfig=f:a._tenantRecaptchaConfigs[a.tenantId]=f,o(f.siteKey)}}).catch(h=>{c(h)})})}function i(a,o,c){const h=window.grecaptcha;mR(h)?h.enterprise.ready(()=>{h.enterprise.execute(a,{action:t}).then(f=>{o(f)}).catch(()=>{o(XF)})}):c(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new doe().execute("siteKey",{action:"verify"}):new Promise((a,o)=>{r(this.auth).then(c=>{if(!n&&mR(window.grecaptcha))i(c,a,o);else{if(typeof window>"u"){o(new Error("RecaptchaVerifier is only supported in browser"));return}let h=loe();h.length!==0&&(h+=c),YF(h).then(()=>{i(c,a,o)}).catch(f=>{o(f)})}}).catch(c=>{o(c)})})}}async function wR(e,t,n,r=!1,i=!1){const a=new poe(e);let o;if(i)o=XF;else try{o=await a.verify(n)}catch{o=await a.verify(n,!0)}const c={...t};if(n==="mfaSmsEnrollment"||n==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in c){const h=c.phoneEnrollmentInfo.phoneNumber,f=c.phoneEnrollmentInfo.recaptchaToken;Object.assign(c,{phoneEnrollmentInfo:{phoneNumber:h,recaptchaToken:f,captchaResponse:o,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in c){const h=c.phoneSignInInfo.recaptchaToken;Object.assign(c,{phoneSignInInfo:{recaptchaToken:h,captchaResponse:o,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return c}return r?Object.assign(c,{captchaResp:o}):Object.assign(c,{captchaResponse:o}),Object.assign(c,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(c,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),c}async function XS(e,t,n,r,i){var a;if((a=e._getRecaptchaConfig())!=null&&a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const o=await wR(e,t,n,n==="getOobCode");return r(e,o)}else return r(e,t).catch(async o=>{if(o.code==="auth/missing-recaptcha-token"){console.log(`${n} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const c=await wR(e,t,n,n==="getOobCode");return r(e,c)}else return Promise.reject(o)})}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function moe(e,t){const n=EI(e,"auth");if(n.isInitialized()){const i=n.getImmediate(),a=n.getOptions();if(zd(a,t??{}))return i;xc(i,"already-initialized")}return n.initialize({options:t})}function goe(e,t){const n=(t==null?void 0:t.persistence)||[],r=(Array.isArray(n)?n:[n]).map(Td);t!=null&&t.errorMap&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,t==null?void 0:t.popupRedirectResolver)}function xoe(e,t,n){const r=Nf(e);br(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");const i=!1,a=QF(t),{host:o,port:c}=yoe(t),h=c===null?"":`:${c}`,f={url:`${a}//${o}${h}/`},m=Object.freeze({host:o,port:c,protocol:a.replace(":",""),options:Object.freeze({disableWarnings:i})});if(!r._canInitEmulator){br(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),br(zd(f,r.config.emulator)&&zd(m,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=f,r.emulatorConfig=m,r.settings.appVerificationDisabledForTesting=!0,Ly(o)?SF(`${a}//${o}${h}`):boe()}function QF(e){const t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function yoe(e){const t=QF(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){const a=i[1];return{host:a,port:NR(r.substr(a.length+1))}}else{const[a,o]=r.split(":");return{host:a,port:NR(o)}}}function NR(e){if(!e)return null;const t=Number(e);return isNaN(t)?null:t}function boe(){function e(){const t=document.createElement("p"),n=t.style;t.innerText="Running in emulator mode. Do not use with production credentials.",n.position="fixed",n.width="100%",n.backgroundColor="#ffffff",n.border=".1em solid #000000",n.color="#b50000",n.bottom="0px",n.left="0px",n.margin="0px",n.zIndex="10000",n.textAlign="center",t.classList.add("firebase-emulator-warning"),document.body.appendChild(t)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",e):e())}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class jI{constructor(t,n){this.providerId=t,this.signInMethod=n}toJSON(){return Id("not implemented")}_getIdTokenResponse(t){return Id("not implemented")}_linkToIdToken(t,n){return Id("not implemented")}_getReauthenticationResolver(t){return Id("not implemented")}}async function voe(e,t){return Qd(e,"POST","/v1/accounts:signUp",t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function woe(e,t){return By(e,"POST","/v1/accounts:signInWithPassword",wf(e,t))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function Noe(e,t){return By(e,"POST","/v1/accounts:signInWithEmailLink",wf(e,t))}async function Eoe(e,t){return By(e,"POST","/v1/accounts:signInWithEmailLink",wf(e,t))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ny extends jI{constructor(t,n,r,i=null){super("password",r),this._email=t,this._password=n,this._tenantId=i}static _fromEmailAndPassword(t,n){return new ny(t,n,"password")}static _fromEmailAndCode(t,n,r=null){return new ny(t,n,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(t){const n=typeof t=="string"?JSON.parse(t):t;if(n!=null&&n.email&&(n!=null&&n.password)){if(n.signInMethod==="password")return this._fromEmailAndPassword(n.email,n.password);if(n.signInMethod==="emailLink")return this._fromEmailAndCode(n.email,n.password,n.tenantId)}return null}async _getIdTokenResponse(t){switch(this.signInMethod){case"password":const n={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return XS(t,n,"signInWithPassword",woe);case"emailLink":return Noe(t,{email:this._email,oobCode:this._password});default:xc(t,"internal-error")}}async _linkToIdToken(t,n){switch(this.signInMethod){case"password":const r={idToken:n,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return XS(t,r,"signUpPassword",voe);case"emailLink":return Eoe(t,{idToken:n,email:this._email,oobCode:this._password});default:xc(t,"internal-error")}}_getReauthenticationResolver(t){return this._getIdTokenResponse(t)}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function W0(e,t){return By(e,"POST","/v1/accounts:signInWithIdp",wf(e,t))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Aoe="http://localhost";class Qp extends jI{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(t){const n=new Qp(t.providerId,t.signInMethod);return t.idToken||t.accessToken?(t.idToken&&(n.idToken=t.idToken),t.accessToken&&(n.accessToken=t.accessToken),t.nonce&&!t.pendingToken&&(n.nonce=t.nonce),t.pendingToken&&(n.pendingToken=t.pendingToken)):t.oauthToken&&t.oauthTokenSecret?(n.accessToken=t.oauthToken,n.secret=t.oauthTokenSecret):xc("argument-error"),n}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(t){const n=typeof t=="string"?JSON.parse(t):t,{providerId:r,signInMethod:i,...a}=n;if(!r||!i)return null;const o=new Qp(r,i);return o.idToken=a.idToken||void 0,o.accessToken=a.accessToken||void 0,o.secret=a.secret,o.nonce=a.nonce,o.pendingToken=a.pendingToken||null,o}_getIdTokenResponse(t){const n=this.buildRequest();return W0(t,n)}_linkToIdToken(t,n){const r=this.buildRequest();return r.idToken=n,W0(t,r)}_getReauthenticationResolver(t){const n=this.buildRequest();return n.autoCreate=!1,W0(t,n)}buildRequest(){const t={requestUri:Aoe,returnSecureToken:!0};if(this.pendingToken)t.pendingToken=this.pendingToken;else{const n={};this.idToken&&(n.id_token=this.idToken),this.accessToken&&(n.access_token=this.accessToken),this.secret&&(n.oauth_token_secret=this.secret),n.providerId=this.providerId,this.nonce&&!this.pendingToken&&(n.nonce=this.nonce),t.postBody=My(n)}return t}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function _oe(e){switch(e){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function koe(e){const t=g1(x1(e)).link,n=t?g1(x1(t)).deep_link_id:null,r=g1(x1(e)).deep_link_id;return(r?g1(x1(r)).link:null)||r||n||t||e}class II{constructor(t){const n=g1(x1(t)),r=n.apiKey??null,i=n.oobCode??null,a=_oe(n.mode??null);br(r&&i&&a,"argument-error"),this.apiKey=r,this.operation=a,this.code=i,this.continueUrl=n.continueUrl??null,this.languageCode=n.lang??null,this.tenantId=n.tenantId??null}static parseLink(t){const n=koe(t);try{return new II(n)}catch{return null}}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Ug{constructor(){this.providerId=Ug.PROVIDER_ID}static credential(t,n){return ny._fromEmailAndPassword(t,n)}static credentialWithLink(t,n){const r=II.parseLink(n);return br(r,"argument-error"),ny._fromEmailAndCode(t,r.code,r.tenantId)}}Ug.PROVIDER_ID="password";Ug.EMAIL_PASSWORD_SIGN_IN_METHOD="password";Ug.EMAIL_LINK_SIGN_IN_METHOD="emailLink";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class TI{constructor(t){this.providerId=t,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(t){this.defaultLanguageCode=t}setCustomParameters(t){return this.customParameters=t,this}getCustomParameters(){return this.customParameters}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class zy extends TI{constructor(){super(...arguments),this.scopes=[]}addScope(t){return this.scopes.includes(t)||this.scopes.push(t),this}getScopes(){return[...this.scopes]}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Gh extends zy{constructor(){super("facebook.com")}static credential(t){return Qp._fromParams({providerId:Gh.PROVIDER_ID,signInMethod:Gh.FACEBOOK_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return Gh.credentialFromTaggedObject(t)}static credentialFromError(t){return Gh.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!("oauthAccessToken"in t)||!t.oauthAccessToken)return null;try{return Gh.credential(t.oauthAccessToken)}catch{return null}}}Gh.FACEBOOK_SIGN_IN_METHOD="facebook.com";Gh.PROVIDER_ID="facebook.com";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Cd extends zy{constructor(){super("google.com"),this.addScope("profile")}static credential(t,n){return Qp._fromParams({providerId:Cd.PROVIDER_ID,signInMethod:Cd.GOOGLE_SIGN_IN_METHOD,idToken:t,accessToken:n})}static credentialFromResult(t){return Cd.credentialFromTaggedObject(t)}static credentialFromError(t){return Cd.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthIdToken:n,oauthAccessToken:r}=t;if(!n&&!r)return null;try{return Cd.credential(n,r)}catch{return null}}}Cd.GOOGLE_SIGN_IN_METHOD="google.com";Cd.PROVIDER_ID="google.com";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class qh extends zy{constructor(){super("github.com")}static credential(t){return Qp._fromParams({providerId:qh.PROVIDER_ID,signInMethod:qh.GITHUB_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return qh.credentialFromTaggedObject(t)}static credentialFromError(t){return qh.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!("oauthAccessToken"in t)||!t.oauthAccessToken)return null;try{return qh.credential(t.oauthAccessToken)}catch{return null}}}qh.GITHUB_SIGN_IN_METHOD="github.com";qh.PROVIDER_ID="github.com";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Wh extends zy{constructor(){super("twitter.com")}static credential(t,n){return Qp._fromParams({providerId:Wh.PROVIDER_ID,signInMethod:Wh.TWITTER_SIGN_IN_METHOD,oauthToken:t,oauthTokenSecret:n})}static credentialFromResult(t){return Wh.credentialFromTaggedObject(t)}static credentialFromError(t){return Wh.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthAccessToken:n,oauthTokenSecret:r}=t;if(!n||!r)return null;try{return Wh.credential(n,r)}catch{return null}}}Wh.TWITTER_SIGN_IN_METHOD="twitter.com";Wh.PROVIDER_ID="twitter.com";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function Soe(e,t){return By(e,"POST","/v1/accounts:signUp",wf(e,t))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Zp{constructor(t){this.user=t.user,this.providerId=t.providerId,this._tokenResponse=t._tokenResponse,this.operationType=t.operationType}static async _fromIdTokenResponse(t,n,r,i=!1){const a=await Fc._fromIdTokenResponse(t,r,i),o=ER(r);return new Zp({user:a,providerId:o,_tokenResponse:r,operationType:n})}static async _forOperation(t,n,r){await t._updateTokensIfNecessary(r,!0);const i=ER(r);return new Zp({user:t,providerId:i,_tokenResponse:r,operationType:n})}}function ER(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class l2 extends Xd{constructor(t,n,r,i){super(n.code,n.message),this.operationType=r,this.user=i,Object.setPrototypeOf(this,l2.prototype),this.customData={appName:t.name,tenantId:t.tenantId??void 0,_serverResponse:n.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(t,n,r,i){return new l2(t,n,r,i)}}function ZF(e,t,n,r){return(t==="reauthenticate"?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(a=>{throw a.code==="auth/multi-factor-auth-required"?l2._fromErrorAndOperation(e,a,t,r):a})}async function Coe(e,t,n=!1){const r=await sg(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return Zp._forOperation(e,"link",r)}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function joe(e,t,n=!1){const{auth:r}=e;if(Pl(r.app))return Promise.reject(Dd(r));const i="reauthenticate";try{const a=await sg(e,ZF(r,i,t,e),n);br(a.idToken,r,"internal-error");const o=SI(a.idToken);br(o,r,"internal-error");const{sub:c}=o;return br(e.uid===c,r,"user-mismatch"),Zp._forOperation(e,i,a)}catch(a){throw(a==null?void 0:a.code)==="auth/user-not-found"&&xc(r,"user-mismatch"),a}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function JF(e,t,n=!1){if(Pl(e.app))return Promise.reject(Dd(e));const r="signIn",i=await ZF(e,r,t),a=await Zp._fromIdTokenResponse(e,r,i);return n||await e._updateCurrentUser(a.user),a}async function Ioe(e,t){return JF(Nf(e),t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function e$(e){const t=Nf(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function Toe(e,t,n){if(Pl(e.app))return Promise.reject(Dd(e));const r=Nf(e),o=await XS(r,{returnSecureToken:!0,email:t,password:n,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",Soe).catch(h=>{throw h.code==="auth/password-does-not-meet-requirements"&&e$(e),h}),c=await Zp._fromIdTokenResponse(r,"signIn",o);return await r._updateCurrentUser(c.user),c}function Poe(e,t,n){return Pl(e.app)?Promise.reject(Dd(e)):Ioe(Ca(e),Ug.credential(t,n)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&e$(e),r})}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function Ooe(e,t){return Qd(e,"POST","/v1/accounts:update",t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function t$(e,{displayName:t,photoURL:n}){if(t===void 0&&n===void 0)return;const r=Ca(e),a={idToken:await r.getIdToken(),displayName:t,photoUrl:n,returnSecureToken:!0},o=await sg(r,Ooe(r.auth,a));r.displayName=o.displayName||null,r.photoURL=o.photoUrl||null;const c=r.providerData.find(({providerId:h})=>h==="password");c&&(c.displayName=r.displayName,c.photoURL=r.photoURL),await r._updateTokensIfNecessary(o)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Roe(e,t){return Ca(e).setPersistence(t)}function Doe(e,t,n,r){return Ca(e).onIdTokenChanged(t,n,r)}function Moe(e,t,n){return Ca(e).beforeAuthStateChanged(t,n)}const c2="__sak";/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class n${constructor(t,n){this.storageRetriever=t,this.type=n}_isAvailable(){try{return this.storage?(this.storage.setItem(c2,"1"),this.storage.removeItem(c2),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(t,n){return this.storage.setItem(t,JSON.stringify(n)),Promise.resolve()}_get(t){const n=this.storage.getItem(t);return Promise.resolve(n?JSON.parse(n):null)}_remove(t){return this.storage.removeItem(t),Promise.resolve()}get storage(){return this.storageRetriever()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Loe=1e3,Uoe=10;class r$ extends n${constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(t,n)=>this.onStorageEvent(t,n),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=WF(),this._shouldAllowMigration=!0}forAllChangedKeys(t){for(const n of Object.keys(this.listeners)){const r=this.storage.getItem(n),i=this.localCache[n];r!==i&&t(n,i,r)}}onStorageEvent(t,n=!1){if(!t.key){this.forAllChangedKeys((o,c,h)=>{this.notifyListeners(o,h)});return}const r=t.key;n?this.detachListener():this.stopPolling();const i=()=>{const o=this.storage.getItem(r);!n&&this.localCache[r]===o||this.notifyListeners(r,o)},a=this.storage.getItem(r);toe()&&a!==t.newValue&&t.newValue!==t.oldValue?setTimeout(i,Uoe):i()}notifyListeners(t,n){this.localCache[t]=n;const r=this.listeners[t];if(r)for(const i of Array.from(r))i(n&&JSON.parse(n))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((t,n,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:t,oldValue:n,newValue:r}),!0)})},Loe)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(t,n){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[t]||(this.listeners[t]=new Set,this.localCache[t]=this.storage.getItem(t)),this.listeners[t].add(n)}_removeListener(t,n){this.listeners[t]&&(this.listeners[t].delete(n),this.listeners[t].size===0&&delete this.listeners[t]),Object.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(t,n){await super._set(t,n),this.localCache[t]=JSON.stringify(n)}async _get(t){const n=await super._get(t);return this.localCache[t]=JSON.stringify(n),n}async _remove(t){await super._remove(t),delete this.localCache[t]}}r$.type="LOCAL";const i$=r$;/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class s$ extends n${constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(t,n){}_removeListener(t,n){}}s$.type="SESSION";const a$=s$;/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Boe(e){return Promise.all(e.map(async t=>{try{return{fulfilled:!0,value:await t}}catch(n){return{fulfilled:!1,reason:n}}}))}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class sE{constructor(t){this.eventTarget=t,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){const n=this.receivers.find(i=>i.isListeningto(t));if(n)return n;const r=new sE(t);return this.receivers.push(r),r}isListeningto(t){return this.eventTarget===t}async handleEvent(t){const n=t,{eventId:r,eventType:i,data:a}=n.data,o=this.handlersMap[i];if(!(o!=null&&o.size))return;n.ports[0].postMessage({status:"ack",eventId:r,eventType:i});const c=Array.from(o).map(async f=>f(n.origin,a)),h=await Boe(c);n.ports[0].postMessage({status:"done",eventId:r,eventType:i,response:h})}_subscribe(t,n){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[t]||(this.handlersMap[t]=new Set),this.handlersMap[t].add(n)}_unsubscribe(t,n){this.handlersMap[t]&&n&&this.handlersMap[t].delete(n),(!n||this.handlersMap[t].size===0)&&delete this.handlersMap[t],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}sE.receivers=[];/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function PI(e="",t=10){let n="";for(let r=0;r{const f=PI("",20);i.port1.start();const m=setTimeout(()=>{h(new Error("unsupported_event"))},r);o={messageChannel:i,onMessage(y){const w=y;if(w.data.eventId===f)switch(w.data.status){case"ack":clearTimeout(m),a=setTimeout(()=>{h(new Error("timeout"))},3e3);break;case"done":clearTimeout(a),c(w.data.response);break;default:clearTimeout(m),clearTimeout(a),h(new Error("invalid_response"));break}}},this.handlers.add(o),i.port1.addEventListener("message",o.onMessage),this.target.postMessage({eventType:t,eventId:f,data:n},[i.port2])}).finally(()=>{o&&this.removeMessageHandler(o)})}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Ru(){return window}function Voe(e){Ru().location.href=e}/** * @license * Copyright 2020 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function o$(){return typeof Ru().WorkerGlobalScope<"u"&&typeof Ru().importScripts=="function"}async function Foe(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function $oe(){var e;return((e=navigator==null?void 0:navigator.serviceWorker)==null?void 0:e.controller)||null}function Hoe(){return o$()?self:null}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const l$="firebaseLocalStorageDb",Goe=1,u2="firebaseLocalStorage",c$="fbase_key";class Vy{constructor(t){this.request=t}toPromise(){return new Promise((t,n)=>{this.request.addEventListener("success",()=>{t(this.request.result)}),this.request.addEventListener("error",()=>{n(this.request.error)})})}}function aE(e,t){return e.transaction([u2],t?"readwrite":"readonly").objectStore(u2)}function qoe(){const e=indexedDB.deleteDatabase(l$);return new Vy(e).toPromise()}function QS(){const e=indexedDB.open(l$,Goe);return new Promise((t,n)=>{e.addEventListener("error",()=>{n(e.error)}),e.addEventListener("upgradeneeded",()=>{const r=e.result;try{r.createObjectStore(u2,{keyPath:c$})}catch(i){n(i)}}),e.addEventListener("success",async()=>{const r=e.result;r.objectStoreNames.contains(u2)?t(r):(r.close(),await qoe(),t(await QS()))})})}async function AR(e,t,n){const r=aE(e,!0).put({[c$]:t,value:n});return new Vy(r).toPromise()}async function Woe(e,t){const n=aE(e,!1).get(t),r=await new Vy(n).toPromise();return r===void 0?null:r.value}function _R(e,t){const n=aE(e,!0).delete(t);return new Vy(n).toPromise()}const Koe=800,Yoe=3;class u${constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await QS(),this.db)}async _withRetries(t){let n=0;for(;;)try{const r=await this._openDb();return await t(r)}catch(r){if(n++>Yoe)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return o$()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=sE._getInstance(Hoe()),this.receiver._subscribe("keyChanged",async(t,n)=>({keyProcessed:(await this._poll()).includes(n.key)})),this.receiver._subscribe("ping",async(t,n)=>["keyChanged"])}async initializeSender(){var n,r;if(this.activeServiceWorker=await Foe(),!this.activeServiceWorker)return;this.sender=new zoe(this.activeServiceWorker);const t=await this.sender._send("ping",{},800);t&&(n=t[0])!=null&&n.fulfilled&&(r=t[0])!=null&&r.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(t){if(!(!this.sender||!this.activeServiceWorker||$oe()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:t},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const t=await QS();return await AR(t,c2,"1"),await _R(t,c2),!0}catch{}return!1}async _withPendingWrite(t){this.pendingWrites++;try{await t()}finally{this.pendingWrites--}}async _set(t,n){return this._withPendingWrite(async()=>(await this._withRetries(r=>AR(r,t,n)),this.localCache[t]=n,this.notifyServiceWorker(t)))}async _get(t){const n=await this._withRetries(r=>Woe(r,t));return this.localCache[t]=n,n}async _remove(t){return this._withPendingWrite(async()=>(await this._withRetries(n=>_R(n,t)),delete this.localCache[t],this.notifyServiceWorker(t)))}async _poll(){const t=await this._withRetries(i=>{const a=aE(i,!1).getAll();return new Vy(a).toPromise()});if(!t)return[];if(this.pendingWrites!==0)return[];const n=[],r=new Set;if(t.length!==0)for(const{fbase_key:i,value:a}of t)r.add(i),JSON.stringify(this.localCache[i])!==JSON.stringify(a)&&(this.notifyListeners(i,a),n.push(i));for(const i of Object.keys(this.localCache))this.localCache[i]&&!r.has(i)&&(this.notifyListeners(i,null),n.push(i));return n}notifyListeners(t,n){this.localCache[t]=n;const r=this.listeners[t];if(r)for(const i of Array.from(r))i(n)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),Koe)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(t,n){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[t]||(this.listeners[t]=new Set,this._get(t)),this.listeners[t].add(n)}_removeListener(t,n){this.listeners[t]&&(this.listeners[t].delete(n),this.listeners[t].size===0&&delete this.listeners[t]),Object.keys(this.listeners).length===0&&this.stopPolling()}}u$.type="LOCAL";const Xoe=u$;new Uy(3e4,6e4);/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function d$(e,t){return t?Td(t):(br(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class OI extends jI{constructor(t){super("custom","custom"),this.params=t}_getIdTokenResponse(t){return W0(t,this._buildIdpRequest())}_linkToIdToken(t,n){return W0(t,this._buildIdpRequest(n))}_getReauthenticationResolver(t){return W0(t,this._buildIdpRequest())}_buildIdpRequest(t){const n={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return t&&(n.idToken=t),n}}function Qoe(e){return JF(e.auth,new OI(e),e.bypassAuthState)}function Zoe(e){const{auth:t,user:n}=e;return br(n,t,"internal-error"),joe(n,new OI(e),e.bypassAuthState)}async function Joe(e){const{auth:t,user:n}=e;return br(n,t,"internal-error"),Coe(n,new OI(e),e.bypassAuthState)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class h${constructor(t,n,r,i,a=!1){this.auth=t,this.resolver=r,this.user=i,this.bypassAuthState=a,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(n)?n:[n]}execute(){return new Promise(async(t,n)=>{this.pendingPromise={resolve:t,reject:n};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}})}async onAuthEvent(t){const{urlResponse:n,sessionId:r,postBody:i,tenantId:a,error:o,type:c}=t;if(o){this.reject(o);return}const h={auth:this.auth,requestUri:n,sessionId:r,tenantId:a||void 0,postBody:i||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(c)(h))}catch(f){this.reject(f)}}onError(t){this.reject(t)}getIdpTask(t){switch(t){case"signInViaPopup":case"signInViaRedirect":return Qoe;case"linkViaPopup":case"linkViaRedirect":return Joe;case"reauthViaPopup":case"reauthViaRedirect":return Zoe;default:xc(this.auth,"internal-error")}}resolve(t){Fd(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(t),this.unregisterAndCleanUp()}reject(t){Fd(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(t),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const ele=new Uy(2e3,1e4);async function tle(e,t,n){if(Pl(e.app))return Promise.reject($c(e,"operation-not-supported-in-this-environment"));const r=Nf(e);Dae(e,t,TI);const i=d$(r,n);return new Ep(r,"signInViaPopup",t,i).executeNotNull()}class Ep extends h${constructor(t,n,r,i,a){super(t,n,i,a),this.provider=r,this.authWindow=null,this.pollId=null,Ep.currentPopupAction&&Ep.currentPopupAction.cancel(),Ep.currentPopupAction=this}async executeNotNull(){const t=await this.execute();return br(t,this.auth,"internal-error"),t}async onExecution(){Fd(this.filter.length===1,"Popup operations only handle one event");const t=PI();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],t),this.authWindow.associatedEvent=t,this.resolver._originValidation(this.auth).catch(n=>{this.reject(n)}),this.resolver._isIframeWebStorageSupported(this.auth,n=>{n||this.reject($c(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var t;return((t=this.authWindow)==null?void 0:t.associatedEvent)||null}cancel(){this.reject($c(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Ep.currentPopupAction=null}pollUserCancellation(){const t=()=>{var n,r;if((r=(n=this.authWindow)==null?void 0:n.window)!=null&&r.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject($c(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(t,ele.get())};t()}}Ep.currentPopupAction=null;/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const nle="pendingRedirect",Aw=new Map;class rle extends h${constructor(t,n,r=!1){super(t,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],n,void 0,r),this.eventId=null}async execute(){let t=Aw.get(this.auth._key());if(!t){try{const r=await ile(this.resolver,this.auth)?await super.execute():null;t=()=>Promise.resolve(r)}catch(n){t=()=>Promise.reject(n)}Aw.set(this.auth._key(),t)}return this.bypassAuthState||Aw.set(this.auth._key(),()=>Promise.resolve(null)),t()}async onAuthEvent(t){if(t.type==="signInViaRedirect")return super.onAuthEvent(t);if(t.type==="unknown"){this.resolve(null);return}if(t.eventId){const n=await this.auth._redirectUserForId(t.eventId);if(n)return this.user=n,super.onAuthEvent(t);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function ile(e,t){const n=ole(t),r=ale(e);if(!await r._isAvailable())return!1;const i=await r._get(n)==="true";return await r._remove(n),i}function sle(e,t){Aw.set(e._key(),t)}function ale(e){return Td(e._redirectPersistence)}function ole(e){return Ew(nle,e.config.apiKey,e.name)}async function lle(e,t,n=!1){if(Pl(e.app))return Promise.reject(Dd(e));const r=Nf(e),i=d$(r,t),o=await new rle(r,i,n).execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,t)),o}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const cle=600*1e3;class ule{constructor(t){this.auth=t,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(t){this.consumers.add(t),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,t)&&(this.sendToConsumer(this.queuedRedirectEvent,t),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(t){this.consumers.delete(t)}onEvent(t){if(this.hasEventBeenHandled(t))return!1;let n=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(t,r)&&(n=!0,this.sendToConsumer(t,r),this.saveEventToCache(t))}),this.hasHandledPotentialRedirect||!dle(t)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=t,n=!0)),n}sendToConsumer(t,n){var r;if(t.error&&!f$(t)){const i=((r=t.error.code)==null?void 0:r.split("auth/")[1])||"internal-error";n.onError($c(this.auth,i))}else n.onAuthEvent(t)}isEventForConsumer(t,n){const r=n.eventId===null||!!t.eventId&&t.eventId===n.eventId;return n.filter.includes(t.type)&&r}hasEventBeenHandled(t){return Date.now()-this.lastProcessedEventTime>=cle&&this.cachedEventUids.clear(),this.cachedEventUids.has(kR(t))}saveEventToCache(t){this.cachedEventUids.add(kR(t)),this.lastProcessedEventTime=Date.now()}}function kR(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(t=>t).join("-")}function f$({type:e,error:t}){return e==="unknown"&&(t==null?void 0:t.code)==="auth/no-auth-event"}function dle(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return f$(e);default:return!1}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function hle(e,t={}){return Qd(e,"GET","/v1/projects",t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const fle=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,ple=/^https?/;async function mle(e){if(e.config.emulator)return;const{authorizedDomains:t}=await hle(e);for(const n of t)try{if(gle(n))return}catch{}xc(e,"unauthorized-domain")}function gle(e){const t=KS(),{protocol:n,hostname:r}=new URL(t);if(e.startsWith("chrome-extension://")){const o=new URL(e);return o.hostname===""&&r===""?n==="chrome-extension:"&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):n==="chrome-extension:"&&o.hostname===r}if(!ple.test(n))return!1;if(fle.test(e))return r===e;const i=e.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}/** * @license * Copyright 2020 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const xle=new Uy(3e4,6e4);function SR(){const e=Ru().___jsl;if(e!=null&&e.H){for(const t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let n=0;n{var i,a,o;function r(){SR(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{SR(),n($c(e,"network-request-failed"))},timeout:xle.get()})}if((a=(i=Ru().gapi)==null?void 0:i.iframes)!=null&&a.Iframe)t(gapi.iframes.getContext());else if((o=Ru().gapi)!=null&&o.load)r();else{const c=uoe("iframefcb");return Ru()[c]=()=>{gapi.load?r():n($c(e,"network-request-failed"))},YF(`${coe()}?onload=${c}`).catch(h=>n(h))}}).catch(t=>{throw _w=null,t})}let _w=null;function ble(e){return _w=_w||yle(e),_w}/** * @license * Copyright 2020 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const vle=new Uy(5e3,15e3),wle="__/auth/iframe",Nle="emulator/auth/iframe",Ele={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Ale=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function _le(e){const t=e.config;br(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?kI(t,Nle):`https://${e.config.authDomain}/${wle}`,r={apiKey:t.apiKey,appName:e.name,v:Lg},i=Ale.get(e.config.apiHost);i&&(r.eid=i);const a=e._getFrameworks();return a.length&&(r.fw=a.join(",")),`${n}?${My(r).slice(1)}`}async function kle(e){const t=await ble(e),n=Ru().gapi;return br(n,e,"internal-error"),t.open({where:document.body,url:_le(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Ele,dontclear:!0},r=>new Promise(async(i,a)=>{await r.restyle({setHideOnLeave:!1});const o=$c(e,"network-request-failed"),c=Ru().setTimeout(()=>{a(o)},vle.get());function h(){Ru().clearTimeout(c),i(r)}r.ping(h).then(h,()=>{a(o)})}))}/** * @license * Copyright 2020 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Sle={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},Cle=500,jle=600,Ile="_blank",Tle="http://localhost";class CR{constructor(t){this.window=t,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function Ple(e,t,n,r=Cle,i=jle){const a=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const h={...Sle,width:r.toString(),height:i.toString(),top:a,left:o},f=Sa().toLowerCase();n&&(c=FF(f)?Ile:n),zF(f)&&(t=t||Tle,h.scrollbars="yes");const m=Object.entries(h).reduce((w,[A,S])=>`${w}${A}=${S},`,"");if(eoe(f)&&c!=="_self")return Ole(t||"",c),new CR(null);const y=window.open(t||"",c,m);br(y,e,"popup-blocked");try{y.focus()}catch{}return new CR(y)}function Ole(e,t){const n=document.createElement("a");n.href=e,n.target=t;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Rle="__/auth/handler",Dle="emulator/auth/handler",Mle=encodeURIComponent("fac");async function jR(e,t,n,r,i,a){br(e.config.authDomain,e,"auth-domain-config-required"),br(e.config.apiKey,e,"invalid-api-key");const o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:Lg,eventId:i};if(t instanceof TI){t.setDefaultLanguage(e.languageCode),o.providerId=t.providerId||"",yse(t.getCustomParameters())||(o.customParameters=JSON.stringify(t.getCustomParameters()));for(const[m,y]of Object.entries({}))o[m]=y}if(t instanceof zy){const m=t.getScopes().filter(y=>y!=="");m.length>0&&(o.scopes=m.join(","))}e.tenantId&&(o.tid=e.tenantId);const c=o;for(const m of Object.keys(c))c[m]===void 0&&delete c[m];const h=await e._getAppCheckToken(),f=h?`#${Mle}=${encodeURIComponent(h)}`:"";return`${Lle(e)}?${My(c).slice(1)}${f}`}function Lle({config:e}){return e.emulator?kI(e,Dle):`https://${e.authDomain}/${Rle}`}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const a_="webStorageSupport";class Ule{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=a$,this._completeRedirectFn=lle,this._overrideRedirectResult=sle}async _openPopup(t,n,r,i){var o;Fd((o=this.eventManagers[t._key()])==null?void 0:o.manager,"_initialize() not called before _openPopup()");const a=await jR(t,n,r,KS(),i);return Ple(t,a,PI())}async _openRedirect(t,n,r,i){await this._originValidation(t);const a=await jR(t,n,r,KS(),i);return Voe(a),new Promise(()=>{})}_initialize(t){const n=t._key();if(this.eventManagers[n]){const{manager:i,promise:a}=this.eventManagers[n];return i?Promise.resolve(i):(Fd(a,"If manager is not set, promise should be"),a)}const r=this.initAndGetManager(t);return this.eventManagers[n]={promise:r},r.catch(()=>{delete this.eventManagers[n]}),r}async initAndGetManager(t){const n=await kle(t),r=new ule(t);return n.register("authEvent",i=>(br(i==null?void 0:i.authEvent,t,"invalid-auth-event"),{status:r.onEvent(i.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[t._key()]={manager:r},this.iframes[t._key()]=n,r}_isIframeWebStorageSupported(t,n){this.iframes[t._key()].send(a_,{type:a_},i=>{var o;const a=(o=i==null?void 0:i[0])==null?void 0:o[a_];a!==void 0&&n(!!a),xc(t,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(t){const n=t._key();return this.originValidationPromises[n]||(this.originValidationPromises[n]=mle(t)),this.originValidationPromises[n]}get _shouldInitProactively(){return WF()||VF()||CI()}}const Ble=Ule;var IR="@firebase/auth",TR="1.12.2";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class zle{constructor(t){this.auth=t,this.internalListeners=new Map}getUid(){var t;return this.assertAuthConfigured(),((t=this.auth.currentUser)==null?void 0:t.uid)||null}async getToken(t){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(t)}:null}addAuthTokenListener(t){if(this.assertAuthConfigured(),this.internalListeners.has(t))return;const n=this.auth.onIdTokenChanged(r=>{t((r==null?void 0:r.stsTokenManager.accessToken)||null)});this.internalListeners.set(t,n),this.updateProactiveRefresh()}removeAuthTokenListener(t){this.assertAuthConfigured();const n=this.internalListeners.get(t);n&&(this.internalListeners.delete(t),n(),this.updateProactiveRefresh())}assertAuthConfigured(){br(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Vle(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function Fle(e){ig(new Xp("auth",(t,{options:n})=>{const r=t.getProvider("app").getImmediate(),i=t.getProvider("heartbeat"),a=t.getProvider("app-check-internal"),{apiKey:o,authDomain:c}=r.options;br(o&&!o.includes(":"),"invalid-api-key",{appName:r.name});const h={apiKey:o,authDomain:c,clientPlatform:e,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:KF(e)},f=new aoe(r,i,a,h);return goe(f,n),f},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((t,n,r)=>{t.getProvider("auth-internal").initialize()})),ig(new Xp("auth-internal",t=>{const n=Nf(t.getProvider("auth").getImmediate());return(r=>new zle(r))(n)},"PRIVATE").setInstantiationMode("EXPLICIT")),sf(IR,TR,Vle(e)),sf(IR,TR,"esm2020")}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const $le=300,Hle=NF("authIdTokenMaxAge")||$le;let PR=null;const Gle=e=>async t=>{const n=t&&await t.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>Hle)return;const i=n==null?void 0:n.token;PR!==i&&(PR=i,await fetch(e,{method:i?"POST":"DELETE",headers:i?{Authorization:`Bearer ${i}`}:{}}))};function qle(e=vae()){const t=EI(e,"auth");if(t.isInitialized())return t.getImmediate();const n=moe(e,{popupRedirectResolver:Ble,persistence:[Xoe,i$,a$]}),r=NF("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const a=new URL(r,location.origin);if(location.origin===a.origin){const o=Gle(a.toString());Moe(n,o,()=>o(n.currentUser)),Doe(n,c=>o(c))}}const i=ose("auth");return i&&xoe(n,`http://${i}`),n}function Wle(){var e;return((e=document.getElementsByTagName("head"))==null?void 0:e[0])??document}ooe({loadJS(e){return new Promise((t,n)=>{const r=document.createElement("script");r.setAttribute("src",e),r.onload=t,r.onerror=i=>{const a=$c("internal-error");a.customData=i,n(a)},r.type="text/javascript",r.charset="UTF-8",Wle().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});Fle("Browser");var OR=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license Copyright The Closure Library Authors. SPDX-License-Identifier: Apache-2.0 */var af,p$;(function(){var e;/** @license Copyright The Closure Library Authors. SPDX-License-Identifier: Apache-2.0 */function t(B,z){function F(){}F.prototype=z.prototype,B.F=z.prototype,B.prototype=new F,B.prototype.constructor=B,B.D=function($,Y,X){for(var J=Array(arguments.length-2),ye=2;ye>>25),J=X+(Y^z&(F^Y))+$[1]+3905402710&4294967295,X=z+(J<<12&4294967295|J>>>20),J=Y+(F^X&(z^F))+$[2]+606105819&4294967295,Y=X+(J<<17&4294967295|J>>>15),J=F+(z^Y&(X^z))+$[3]+3250441966&4294967295,F=Y+(J<<22&4294967295|J>>>10),J=z+(X^F&(Y^X))+$[4]+4118548399&4294967295,z=F+(J<<7&4294967295|J>>>25),J=X+(Y^z&(F^Y))+$[5]+1200080426&4294967295,X=z+(J<<12&4294967295|J>>>20),J=Y+(F^X&(z^F))+$[6]+2821735955&4294967295,Y=X+(J<<17&4294967295|J>>>15),J=F+(z^Y&(X^z))+$[7]+4249261313&4294967295,F=Y+(J<<22&4294967295|J>>>10),J=z+(X^F&(Y^X))+$[8]+1770035416&4294967295,z=F+(J<<7&4294967295|J>>>25),J=X+(Y^z&(F^Y))+$[9]+2336552879&4294967295,X=z+(J<<12&4294967295|J>>>20),J=Y+(F^X&(z^F))+$[10]+4294925233&4294967295,Y=X+(J<<17&4294967295|J>>>15),J=F+(z^Y&(X^z))+$[11]+2304563134&4294967295,F=Y+(J<<22&4294967295|J>>>10),J=z+(X^F&(Y^X))+$[12]+1804603682&4294967295,z=F+(J<<7&4294967295|J>>>25),J=X+(Y^z&(F^Y))+$[13]+4254626195&4294967295,X=z+(J<<12&4294967295|J>>>20),J=Y+(F^X&(z^F))+$[14]+2792965006&4294967295,Y=X+(J<<17&4294967295|J>>>15),J=F+(z^Y&(X^z))+$[15]+1236535329&4294967295,F=Y+(J<<22&4294967295|J>>>10),J=z+(Y^X&(F^Y))+$[1]+4129170786&4294967295,z=F+(J<<5&4294967295|J>>>27),J=X+(F^Y&(z^F))+$[6]+3225465664&4294967295,X=z+(J<<9&4294967295|J>>>23),J=Y+(z^F&(X^z))+$[11]+643717713&4294967295,Y=X+(J<<14&4294967295|J>>>18),J=F+(X^z&(Y^X))+$[0]+3921069994&4294967295,F=Y+(J<<20&4294967295|J>>>12),J=z+(Y^X&(F^Y))+$[5]+3593408605&4294967295,z=F+(J<<5&4294967295|J>>>27),J=X+(F^Y&(z^F))+$[10]+38016083&4294967295,X=z+(J<<9&4294967295|J>>>23),J=Y+(z^F&(X^z))+$[15]+3634488961&4294967295,Y=X+(J<<14&4294967295|J>>>18),J=F+(X^z&(Y^X))+$[4]+3889429448&4294967295,F=Y+(J<<20&4294967295|J>>>12),J=z+(Y^X&(F^Y))+$[9]+568446438&4294967295,z=F+(J<<5&4294967295|J>>>27),J=X+(F^Y&(z^F))+$[14]+3275163606&4294967295,X=z+(J<<9&4294967295|J>>>23),J=Y+(z^F&(X^z))+$[3]+4107603335&4294967295,Y=X+(J<<14&4294967295|J>>>18),J=F+(X^z&(Y^X))+$[8]+1163531501&4294967295,F=Y+(J<<20&4294967295|J>>>12),J=z+(Y^X&(F^Y))+$[13]+2850285829&4294967295,z=F+(J<<5&4294967295|J>>>27),J=X+(F^Y&(z^F))+$[2]+4243563512&4294967295,X=z+(J<<9&4294967295|J>>>23),J=Y+(z^F&(X^z))+$[7]+1735328473&4294967295,Y=X+(J<<14&4294967295|J>>>18),J=F+(X^z&(Y^X))+$[12]+2368359562&4294967295,F=Y+(J<<20&4294967295|J>>>12),J=z+(F^Y^X)+$[5]+4294588738&4294967295,z=F+(J<<4&4294967295|J>>>28),J=X+(z^F^Y)+$[8]+2272392833&4294967295,X=z+(J<<11&4294967295|J>>>21),J=Y+(X^z^F)+$[11]+1839030562&4294967295,Y=X+(J<<16&4294967295|J>>>16),J=F+(Y^X^z)+$[14]+4259657740&4294967295,F=Y+(J<<23&4294967295|J>>>9),J=z+(F^Y^X)+$[1]+2763975236&4294967295,z=F+(J<<4&4294967295|J>>>28),J=X+(z^F^Y)+$[4]+1272893353&4294967295,X=z+(J<<11&4294967295|J>>>21),J=Y+(X^z^F)+$[7]+4139469664&4294967295,Y=X+(J<<16&4294967295|J>>>16),J=F+(Y^X^z)+$[10]+3200236656&4294967295,F=Y+(J<<23&4294967295|J>>>9),J=z+(F^Y^X)+$[13]+681279174&4294967295,z=F+(J<<4&4294967295|J>>>28),J=X+(z^F^Y)+$[0]+3936430074&4294967295,X=z+(J<<11&4294967295|J>>>21),J=Y+(X^z^F)+$[3]+3572445317&4294967295,Y=X+(J<<16&4294967295|J>>>16),J=F+(Y^X^z)+$[6]+76029189&4294967295,F=Y+(J<<23&4294967295|J>>>9),J=z+(F^Y^X)+$[9]+3654602809&4294967295,z=F+(J<<4&4294967295|J>>>28),J=X+(z^F^Y)+$[12]+3873151461&4294967295,X=z+(J<<11&4294967295|J>>>21),J=Y+(X^z^F)+$[15]+530742520&4294967295,Y=X+(J<<16&4294967295|J>>>16),J=F+(Y^X^z)+$[2]+3299628645&4294967295,F=Y+(J<<23&4294967295|J>>>9),J=z+(Y^(F|~X))+$[0]+4096336452&4294967295,z=F+(J<<6&4294967295|J>>>26),J=X+(F^(z|~Y))+$[7]+1126891415&4294967295,X=z+(J<<10&4294967295|J>>>22),J=Y+(z^(X|~F))+$[14]+2878612391&4294967295,Y=X+(J<<15&4294967295|J>>>17),J=F+(X^(Y|~z))+$[5]+4237533241&4294967295,F=Y+(J<<21&4294967295|J>>>11),J=z+(Y^(F|~X))+$[12]+1700485571&4294967295,z=F+(J<<6&4294967295|J>>>26),J=X+(F^(z|~Y))+$[3]+2399980690&4294967295,X=z+(J<<10&4294967295|J>>>22),J=Y+(z^(X|~F))+$[10]+4293915773&4294967295,Y=X+(J<<15&4294967295|J>>>17),J=F+(X^(Y|~z))+$[1]+2240044497&4294967295,F=Y+(J<<21&4294967295|J>>>11),J=z+(Y^(F|~X))+$[8]+1873313359&4294967295,z=F+(J<<6&4294967295|J>>>26),J=X+(F^(z|~Y))+$[15]+4264355552&4294967295,X=z+(J<<10&4294967295|J>>>22),J=Y+(z^(X|~F))+$[6]+2734768916&4294967295,Y=X+(J<<15&4294967295|J>>>17),J=F+(X^(Y|~z))+$[13]+1309151649&4294967295,F=Y+(J<<21&4294967295|J>>>11),J=z+(Y^(F|~X))+$[4]+4149444226&4294967295,z=F+(J<<6&4294967295|J>>>26),J=X+(F^(z|~Y))+$[11]+3174756917&4294967295,X=z+(J<<10&4294967295|J>>>22),J=Y+(z^(X|~F))+$[2]+718787259&4294967295,Y=X+(J<<15&4294967295|J>>>17),J=F+(X^(Y|~z))+$[9]+3951481745&4294967295,B.g[0]=B.g[0]+z&4294967295,B.g[1]=B.g[1]+(Y+(J<<21&4294967295|J>>>11))&4294967295,B.g[2]=B.g[2]+Y&4294967295,B.g[3]=B.g[3]+X&4294967295}r.prototype.v=function(B,z){z===void 0&&(z=B.length);const F=z-this.blockSize,$=this.C;let Y=this.h,X=0;for(;X>>$&255;return B};function a(B,z){var F=c;return Object.prototype.hasOwnProperty.call(F,B)?F[B]:F[B]=z(B)}function o(B,z){this.h=z;const F=[];let $=!0;for(let Y=B.length-1;Y>=0;Y--){const X=B[Y]|0;$&&X==z||(F[Y]=X,$=!1)}this.g=F}var c={};function h(B){return-128<=B&&B<128?a(B,function(z){return new o([z|0],z<0?-1:0)}):new o([B|0],B<0?-1:0)}function f(B){if(isNaN(B)||!isFinite(B))return y;if(B<0)return T(f(-B));const z=[];let F=1;for(let $=0;B>=F;$++)z[$]=B/F|0,F*=4294967296;return new o(z,0)}function m(B,z){if(B.length==0)throw Error("number format error: empty string");if(z=z||10,z<2||36=0)throw Error('number format error: interior "-" character');const F=f(Math.pow(z,8));let $=y;for(let X=0;X=0?$:4294967296+$)*z,z*=4294967296}return B},e.toString=function(B){if(B=B||10,B<2||360?F.g[0]:F.h)>>>0).toString(B);if(F=Y,S(F))return X+$;for(;X.length<6;)X="0"+X;$=X+$}},e.i=function(B){return B<0?0:B>>16)+(this.i(Y)>>>16)+(B.i(Y)>>>16);$=J>>>16,X&=65535,J&=65535,F[Y]=J<<16|X}return new o(F,F[F.length-1]&-2147483648?-1:0)};function D(B,z){return B.add(T(z))}e.j=function(B){if(S(this)||S(B))return y;if(C(this))return C(B)?T(this).j(T(B)):T(T(this).j(B));if(C(B))return T(this.j(T(B)));if(this.l(A)<0&&B.l(A)<0)return f(this.m()*B.m());const z=this.g.length+B.g.length,F=[];for(var $=0;$<2*z;$++)F[$]=0;for($=0;$>>16,J=this.i($)&65535,ye=B.i(Y)>>>16,ne=B.i(Y)&65535;F[2*$+2*Y]+=J*ne,V(F,2*$+2*Y),F[2*$+2*Y+1]+=X*ne,V(F,2*$+2*Y+1),F[2*$+2*Y+1]+=J*ye,V(F,2*$+2*Y+1),F[2*$+2*Y+2]+=X*ye,V(F,2*$+2*Y+2)}for(B=0;B>>16,B[z]&=65535,z++}function L(B,z){this.g=B,this.h=z}function K(B,z){if(S(z))throw Error("division by zero");if(S(B))return new L(y,y);if(C(B))return z=K(T(B),z),new L(T(z.g),T(z.h));if(C(z))return z=K(B,T(z)),new L(T(z.g),z.h);if(B.g.length>30){if(C(B)||C(z))throw Error("slowDivide_ only works with positive integers.");for(var F=w,$=z;$.l(B)<=0;)F=Z(F),$=Z($);var Y=q(F,1),X=q($,1);for($=q($,2),F=q(F,2);!S($);){var J=X.add($);J.l(B)<=0&&(Y=Y.add(F),X=J),$=q($,1),F=q(F,1)}return z=D(B,Y.j(z)),new L(Y,z)}for(Y=y;B.l(z)>=0;){for(F=Math.max(1,Math.floor(B.m()/z.m())),$=Math.ceil(Math.log(F)/Math.LN2),$=$<=48?1:Math.pow(2,$-48),X=f(F),J=X.j(z);C(J)||J.l(B)>0;)F-=$,X=f(F),J=X.j(z);S(X)&&(X=w),Y=Y.add(X),B=D(B,J)}return new L(Y,B)}e.B=function(B){return K(this,B).h},e.and=function(B){const z=Math.max(this.g.length,B.g.length),F=[];for(let $=0;$>>31;return new o(F,B.h)}function q(B,z){const F=z>>5;z%=32;const $=B.g.length-F,Y=[];for(let X=0;X<$;X++)Y[X]=z>0?B.i(X+F)>>>z|B.i(X+F+1)<<32-z:B.i(X+F);return new o(Y,B.h)}r.prototype.digest=r.prototype.A,r.prototype.reset=r.prototype.u,r.prototype.update=r.prototype.v,p$=r,o.prototype.add=o.prototype.add,o.prototype.multiply=o.prototype.j,o.prototype.modulo=o.prototype.B,o.prototype.compare=o.prototype.l,o.prototype.toNumber=o.prototype.m,o.prototype.toString=o.prototype.toString,o.prototype.getBits=o.prototype.i,o.fromNumber=f,o.fromString=m,af=o}).apply(typeof OR<"u"?OR:typeof self<"u"?self:typeof window<"u"?window:{});var Ov=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license Copyright The Closure Library Authors. SPDX-License-Identifier: Apache-2.0 */var m$,y1,g$,kw,ZS,x$,y$,b$;(function(){var e,t=Object.defineProperty;function n(_){_=[typeof globalThis=="object"&&globalThis,_,typeof window=="object"&&window,typeof self=="object"&&self,typeof Ov=="object"&&Ov];for(var U=0;U<_.length;++U){var H=_[U];if(H&&H.Math==Math)return H}throw Error("Cannot find global object")}var r=n(this);function i(_,U){if(U)e:{var H=r;_=_.split(".");for(var oe=0;oe<_.length-1;oe++){var De=_[oe];if(!(De in H))break e;H=H[De]}_=_[_.length-1],oe=H[_],U=U(oe),U!=oe&&U!=null&&t(H,_,{configurable:!0,writable:!0,value:U})}}i("Symbol.dispose",function(_){return _||Symbol("Symbol.dispose")}),i("Array.prototype.values",function(_){return _||function(){return this[Symbol.iterator]()}}),i("Object.entries",function(_){return _||function(U){var H=[],oe;for(oe in U)Object.prototype.hasOwnProperty.call(U,oe)&&H.push([oe,U[oe]]);return H}});/** @license Copyright The Closure Library Authors. SPDX-License-Identifier: Apache-2.0 */var a=a||{},o=this||self;function c(_){var U=typeof _;return U=="object"&&_!=null||U=="function"}function h(_,U,H){return _.call.apply(_.bind,arguments)}function f(_,U,H){return f=h,f.apply(null,arguments)}function m(_,U){var H=Array.prototype.slice.call(arguments,1);return function(){var oe=H.slice();return oe.push.apply(oe,arguments),_.apply(this,oe)}}function y(_,U){function H(){}H.prototype=U.prototype,_.Z=U.prototype,_.prototype=new H,_.prototype.constructor=_,_.Ob=function(oe,De,Ye){for(var Te=Array(arguments.length-2),Ct=2;Ct_&&AsyncContext.Snapshot.wrap(_):_=>_;function A(_){const U=_.length;if(U>0){const H=Array(U);for(let oe=0;oe0?(this.h--,U=this.g,this.g=U.next,U.next=null):U=this.i(),U}}function T(_){o.setTimeout(()=>{throw _},0)}function D(){var _=B;let U=null;return _.g&&(U=_.g,_.g=_.g.next,_.g||(_.h=null),U.next=null),U}class V{constructor(){this.h=this.g=null}add(U,H){const oe=L.get();oe.set(U,H),this.h?this.h.next=oe:this.g=oe,this.h=oe}}var L=new C(()=>new K,_=>_.reset());class K{constructor(){this.next=this.g=this.h=null}set(U,H){this.h=U,this.g=H,this.next=null}reset(){this.next=this.g=this.h=null}}let Z,q=!1,B=new V,z=()=>{const _=Promise.resolve(void 0);Z=()=>{_.then(F)}};function F(){for(var _;_=D();){try{_.h.call(_.g)}catch(H){T(H)}var U=L;U.j(_),U.h<100&&(U.h++,_.next=U.g,U.g=_)}q=!1}function $(){this.u=this.u,this.C=this.C}$.prototype.u=!1,$.prototype.dispose=function(){this.u||(this.u=!0,this.N())},$.prototype[Symbol.dispose]=function(){this.dispose()},$.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function Y(_,U){this.type=_,this.g=this.target=U,this.defaultPrevented=!1}Y.prototype.h=function(){this.defaultPrevented=!0};var X=(function(){if(!o.addEventListener||!Object.defineProperty)return!1;var _=!1,U=Object.defineProperty({},"passive",{get:function(){_=!0}});try{const H=()=>{};o.addEventListener("test",H,U),o.removeEventListener("test",H,U)}catch{}return _})();function J(_){return/^[\s\xa0]*$/.test(_)}function ye(_,U){Y.call(this,_?_.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,_&&this.init(_,U)}y(ye,Y),ye.prototype.init=function(_,U){const H=this.type=_.type,oe=_.changedTouches&&_.changedTouches.length?_.changedTouches[0]:null;this.target=_.target||_.srcElement,this.g=U,U=_.relatedTarget,U||(H=="mouseover"?U=_.fromElement:H=="mouseout"&&(U=_.toElement)),this.relatedTarget=U,oe?(this.clientX=oe.clientX!==void 0?oe.clientX:oe.pageX,this.clientY=oe.clientY!==void 0?oe.clientY:oe.pageY,this.screenX=oe.screenX||0,this.screenY=oe.screenY||0):(this.clientX=_.clientX!==void 0?_.clientX:_.pageX,this.clientY=_.clientY!==void 0?_.clientY:_.pageY,this.screenX=_.screenX||0,this.screenY=_.screenY||0),this.button=_.button,this.key=_.key||"",this.ctrlKey=_.ctrlKey,this.altKey=_.altKey,this.shiftKey=_.shiftKey,this.metaKey=_.metaKey,this.pointerId=_.pointerId||0,this.pointerType=_.pointerType,this.state=_.state,this.i=_,_.defaultPrevented&&ye.Z.h.call(this)},ye.prototype.h=function(){ye.Z.h.call(this);const _=this.i;_.preventDefault?_.preventDefault():_.returnValue=!1};var ne="closure_listenable_"+(Math.random()*1e6|0),de=0;function be(_,U,H,oe,De){this.listener=_,this.proxy=null,this.src=U,this.type=H,this.capture=!!oe,this.ha=De,this.key=++de,this.da=this.fa=!1}function Ce(_){_.da=!0,_.listener=null,_.proxy=null,_.src=null,_.ha=null}function Ke(_,U,H){for(const oe in _)U.call(H,_[oe],oe,_)}function G(_,U){for(const H in _)U.call(void 0,_[H],H,_)}function se(_){const U={};for(const H in _)U[H]=_[H];return U}const xe="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function re(_,U){let H,oe;for(let De=1;De-1?(U=_[Te],H||(U.fa=!1)):(U=new be(U,this.src,Ye,!!oe,De),U.fa=H,_.push(U)),U};function nt(_,U){const H=U.type;if(H in _.g){var oe=_.g[H],De=Array.prototype.indexOf.call(oe,U,void 0),Ye;(Ye=De>=0)&&Array.prototype.splice.call(oe,De,1),Ye&&(Ce(U),_.g[H].length==0&&(delete _.g[H],_.h--))}}function ze(_,U,H,oe){for(let De=0;De<_.length;++De){const Ye=_[De];if(!Ye.da&&Ye.listener==U&&Ye.capture==!!H&&Ye.ha==oe)return De}return-1}var Tt="closure_lm_"+(Math.random()*1e6|0),It={};function ft(_,U,H,oe,De){if(Array.isArray(U)){for(let Ye=0;Ye-1&&(Ce(U[H]),Array.prototype.splice.call(U,H,1),U.length==0&&(delete _.g[Ye],_.h--)))):_&&(_=Pt(_))&&(U=_.g[U.toString()],_=-1,U&&(_=ze(U,H,oe,De)),(H=_>-1?U[_]:null)&&Vt(H))}function Vt(_){if(typeof _!="number"&&_&&!_.da){var U=_.src;if(U&&U[ne])nt(U.i,_);else{var H=_.type,oe=_.proxy;U.removeEventListener?U.removeEventListener(H,oe,_.capture):U.detachEvent?U.detachEvent(St(H),oe):U.addListener&&U.removeListener&&U.removeListener(oe),(H=Pt(U))?(nt(H,_),H.h==0&&(H.src=null,U[Tt]=null)):Ce(_)}}}function St(_){return _ in It?It[_]:It[_]="on"+_}function tn(_,U){if(_.da)_=!0;else{U=new ye(U,this);const H=_.listener,oe=_.ha||_.src;_.fa&&Vt(_),_=H.call(oe,U)}return _}function Pt(_){return _=_[Tt],_ instanceof Me?_:null}var Nt="__closure_events_fn_"+(Math.random()*1e9>>>0);function Kt(_){return typeof _=="function"?_:(_[Nt]||(_[Nt]=function(U){return _.handleEvent(U)}),_[Nt])}function ut(){$.call(this),this.i=new Me(this),this.M=this,this.G=null}y(ut,$),ut.prototype[ne]=!0,ut.prototype.removeEventListener=function(_,U,H,oe){Ue(this,_,U,H,oe)};function Jt(_,U){var H,oe=_.G;if(oe)for(H=[];oe;oe=oe.G)H.push(oe);if(_=_.M,oe=U.type||U,typeof U=="string")U=new Y(U,_);else if(U instanceof Y)U.target=U.target||_;else{var De=U;U=new Y(oe,_),re(U,De)}De=!0;let Ye,Te;if(H)for(Te=H.length-1;Te>=0;Te--)Ye=U.g=H[Te],De=Dt(Ye,oe,!0,U)&&De;if(Ye=U.g=_,De=Dt(Ye,oe,!0,U)&&De,De=Dt(Ye,oe,!1,U)&&De,H)for(Te=0;Te2147483647?-1:o.setTimeout(_,U||0)}function qn(_){_.g=hn(()=>{_.g=null,_.i&&(_.i=!1,qn(_))},_.l);const U=_.h;_.h=null,_.m.apply(null,U)}class mn extends ${constructor(U,H){super(),this.m=U,this.l=H,this.h=null,this.i=!1,this.g=null}j(U){this.h=arguments,this.g?this.i=!0:qn(this)}N(){super.N(),this.g&&(o.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function vr(_){$.call(this),this.h=_,this.g={}}y(vr,$);var Ve=[];function Mt(_){Ke(_.g,function(U,H){this.g.hasOwnProperty(H)&&Vt(U)},_),_.g={}}vr.prototype.N=function(){vr.Z.N.call(this),Mt(this)},vr.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var cn=o.JSON.stringify,dn=o.JSON.parse,mr=class{stringify(_){return o.JSON.stringify(_,void 0)}parse(_){return o.JSON.parse(_,void 0)}};function gr(){}function wi(){}var Xt={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function me(){Y.call(this,"d")}y(me,Y);function qe(){Y.call(this,"c")}y(qe,Y);var st={},dt=null;function An(){return dt=dt||new ut}st.Ia="serverreachability";function Ft(_){Y.call(this,st.Ia,_)}y(Ft,Y);function Dn(_){const U=An();Jt(U,new Ft(U))}st.STAT_EVENT="statevent";function Ot(_,U){Y.call(this,st.STAT_EVENT,_),this.stat=U}y(Ot,Y);function on(_){const U=An();Jt(U,new Ot(U,_))}st.Ja="timingevent";function jr(_,U){Y.call(this,st.Ja,_),this.size=U}y(jr,Y);function lr(_,U){if(typeof _!="function")throw Error("Fn must not be null and must be a function");return o.setTimeout(function(){_()},U)}function ue(){this.g=!0}ue.prototype.ua=function(){this.g=!1};function Se(_,U,H,oe,De,Ye){_.info(function(){if(_.g)if(Ye){var Te="",Ct=Ye.split("&");for(let wn=0;wn1){const tr=Zn[0];Zn=Zn[1];const Ur=tr.split("_");Te=Ur.length>=2&&Ur[1]=="type"?Te+(tr+"="+Zn+"&"):Te+(tr+"=redacted&")}}}else Te=null;else Te=Ye;return"XMLHTTP REQ ("+oe+") [attempt "+De+"]: "+U+` `+H+` `+Te})}function Qe(_,U,H,oe,De,Ye,Te){_.info(function(){return"XMLHTTP RESP ("+oe+") [ attempt "+De+"]: "+U+` `+H+` `+Ye+" "+Te})}function Gt(_,U,H,oe){_.info(function(){return"XMLHTTP TEXT ("+U+"): "+xn(_,H)+(oe?" "+oe:"")})}function Fn(_,U){_.info(function(){return"TIMEOUT: "+U})}ue.prototype.info=function(){};function xn(_,U){if(!_.g)return U;if(!U)return null;try{const Ye=JSON.parse(U);if(Ye){for(_=0;_0&&_.length;)H.push(_.shift()),U--;return _.length&&H.push(_.join(":")),H}function bt(_,U,H,oe){this.j=_,this.i=U,this.l=H,this.S=oe||1,this.V=new vr(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new yn}function yn(){this.i=null,this.g="",this.h=!1}var Ut={},On={};function Mr(_,U,H){_.M=1,_.A=Bt(rt(U)),_.u=H,_.R=!0,ji(_,null)}function ji(_,U){_.F=Date.now(),vs(_),_.B=rt(_.A);var H=_.B,oe=_.S;Array.isArray(oe)||(oe=[String(oe)]),fr(H.i,"t",oe),_.C=0,H=_.j.L,_.h=new yn,_.g=ot(_.j,H?U:null,!_.u),_.P>0&&(_.O=new mn(f(_.Y,_,_.g),_.P)),U=_.V,H=_.g,oe=_.ba;var De="readystatechange";Array.isArray(De)||(De&&(Ve[0]=De.toString()),De=Ve);for(let Ye=0;Ye0&&!this.W){this.W=!0;var Te=this.j;Te.g==this&&Te.aa&&!Te.P&&(Te.j.info("Great, no buffering proxy detected. Bytes received: "+H.length),at(Te),Te.P=!0,on(11))}}else Gt(this.i,this.l,H,null),li(this,H);Ct==4&&Ss(this),this.o&&!this.K&&(Ct==4?ge(this.j,this):(this.o=!1,vs(this)))}else zs(this.g),U==400&&H.indexOf("Unknown SID")>0?(this.m=3,on(12)):(this.m=0,on(13)),Ss(this),Sr(this)}}}catch{}finally{}};function rs(_){if(!pi(_))return _.g.la();const U=Ni(_.g);if(U==="")return"";let H="";const oe=U.length,De=Zs(_.g)==4;if(!_.h.i){if(typeof TextDecoder>"u")return Ss(_),Sr(_),"";_.h.i=new o.TextDecoder}for(let Ye=0;YeU.length?On:(U=U.slice(oe,oe+H),_.C=oe+H,U)))}bt.prototype.cancel=function(){this.K=!0,Ss(this)};function vs(_){_.T=Date.now()+_.H,gi(_,_.H)}function gi(_,U){if(_.D!=null)throw Error("WatchDog timer not null");_.D=lr(f(_.aa,_),U)}function $r(_){_.D&&(o.clearTimeout(_.D),_.D=null)}bt.prototype.aa=function(){this.D=null;const _=Date.now();_-this.T>=0?(Fn(this.i,this.B),this.M!=2&&(Dn(),on(17)),Ss(this),this.m=2,Sr(this)):gi(this,this.T-_)};function Sr(_){_.j.I==0||_.K||ge(_.j,_)}function Ss(_){$r(_);var U=_.O;U&&typeof U.dispose=="function"&&U.dispose(),_.O=null,Mt(_.V),_.g&&(U=_.g,_.g=null,U.abort(),U.dispose())}function li(_,U){try{var H=_.j;if(H.I!=0&&(H.g==_||is(H.h,_))){if(!_.L&&is(H.h,_)&&H.I==3){try{var oe=H.Ba.g.parse(U)}catch{oe=null}if(Array.isArray(oe)&&oe.length==3){var De=oe;if(De[0]==0){e:if(!H.v){if(H.g)if(H.g.F+3e3<_.F)Jr(H),fo(H);else break e;Ro(H),on(18)}}else H.xa=De[1],00&&(oe=1.5*Vi,H.O=oe,H.j.info("backChannelRequestTimeoutMs_="+oe)),oe=H;const Ri=_.g;if(Ri){const ws=Ri.g?Ri.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(ws){var Ye=oe.h;Ye.g||ws.indexOf("spdy")==-1&&ws.indexOf("quic")==-1&&ws.indexOf("h2")==-1||(Ye.j=Ye.l,Ye.g=new Set,Ye.h&&(uo(Ye,Ye.h),Ye.h=null))}if(oe.G){const Da=Ri.g?Ri.g.getResponseHeader("X-HTTP-Session-Id"):null;Da&&(oe.wa=Da,Be(oe.J,oe.G,Da))}}H.I=3,H.l&&H.l.ra(),H.aa&&(H.T=Date.now()-_.F,H.j.info("Handshake RTT: "+H.T+"ms")),oe=H;var Te=_;if(oe.na=ct(oe,oe.L?oe.ba:null,oe.W),Te.L){hr(oe.h,Te);var Ct=Te,Zn=oe.O;Zn&&(Ct.H=Zn),Ct.D&&($r(Ct),vs(Ct)),oe.g=Te}else Qa(oe);H.i.length>0&&ga(H)}else wn[0]!="stop"&&wn[0]!="close"||Pe(H,7);else H.I==3&&(wn[0]=="stop"||wn[0]=="close"?wn[0]=="stop"?Pe(H,7):Nl(H):wn[0]!="noop"&&H.l&&H.l.qa(wn),H.A=0)}}Dn(4)}catch{}}var Qr=class{constructor(_,U){this.g=_,this.map=U}};function kt(_){this.l=_||10,o.PerformanceNavigationTiming?(_=o.performance.getEntriesByType("navigation"),_=_.length>0&&(_[0].nextHopProtocol=="hq"||_[0].nextHopProtocol=="h2")):_=!!(o.chrome&&o.chrome.loadTimes&&o.chrome.loadTimes()&&o.chrome.loadTimes().wasFetchedViaSpdy),this.j=_?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function Pa(_){return _.h?!0:_.g?_.g.size>=_.j:!1}function wr(_){return _.h?1:_.g?_.g.size:0}function is(_,U){return _.h?_.h==U:_.g?_.g.has(U):!1}function uo(_,U){_.g?_.g.add(U):_.h=U}function hr(_,U){_.h&&_.h==U?_.h=null:_.g&&_.g.has(U)&&_.g.delete(U)}kt.prototype.cancel=function(){if(this.i=Nr(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const _ of this.g.values())_.cancel();this.g.clear()}};function Nr(_){if(_.h!=null)return _.i.concat(_.h.G);if(_.g!=null&&_.g.size!==0){let U=_.i;for(const H of _.g.values())U=U.concat(H.G);return U}return A(_.i)}var cr=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Re(_,U){if(_){_=_.split("&");for(let H=0;H<_.length;H++){const oe=_[H].indexOf("=");let De,Ye=null;oe>=0?(De=_[H].substring(0,oe),Ye=_[H].substring(oe+1)):De=_[H],U(De,Ye?decodeURIComponent(Ye.replace(/\+/g," ")):"")}}}function mt(_){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let U;_ instanceof mt?(this.l=_.l,At(this,_.j),this.o=_.o,this.g=_.g,nn(this,_.u),this.h=_.h,Nn(this,Oa(_.i)),this.m=_.m):_&&(U=String(_).match(cr))?(this.l=!1,At(this,U[1]||"",!0),this.o=Mn(U[2]||""),this.g=Mn(U[3]||"",!0),nn(this,U[4]),this.h=Mn(U[5]||"",!0),Nn(this,U[6]||"",!0),this.m=Mn(U[7]||"")):(this.l=!1,this.i=new Ui(null,this.l))}mt.prototype.toString=function(){const _=[];var U=this.j;U&&_.push(jn(U,xr,!0),":");var H=this.g;return(H||U=="file")&&(_.push("//"),(U=this.o)&&_.push(jn(U,xr,!0),"@"),_.push(je(H).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),H=this.u,H!=null&&_.push(":",String(H))),(H=this.h)&&(this.g&&H.charAt(0)!="/"&&_.push("/"),_.push(jn(H,H.charAt(0)=="/"?fe:Le,!0))),(H=this.i.toString())&&_.push("?",H),(H=this.m)&&_.push("#",jn(H,xi)),_.join("")},mt.prototype.resolve=function(_){const U=rt(this);let H=!!_.j;H?At(U,_.j):H=!!_.o,H?U.o=_.o:H=!!_.g,H?U.g=_.g:H=_.u!=null;var oe=_.h;if(H)nn(U,_.u);else if(H=!!_.h){if(oe.charAt(0)!="/")if(this.g&&!this.h)oe="/"+oe;else{var De=U.h.lastIndexOf("/");De!=-1&&(oe=U.h.slice(0,De+1)+oe)}if(De=oe,De==".."||De==".")oe="";else if(De.indexOf("./")!=-1||De.indexOf("/.")!=-1){oe=De.lastIndexOf("/",0)==0,De=De.split("/");const Ye=[];for(let Te=0;Te1||Ye.length==1&&Ye[0]!="")&&Ye.pop(),oe&&Te==De.length&&Ye.push("")):(Ye.push(Ct),oe=!0)}oe=Ye.join("/")}else oe=De}return H?U.h=oe:H=_.i.toString()!=="",H?Nn(U,Oa(_.i)):H=!!_.m,H&&(U.m=_.m),U};function rt(_){return new mt(_)}function At(_,U,H){_.j=H?Mn(U,!0):U,_.j&&(_.j=_.j.replace(/:$/,""))}function nn(_,U){if(U){if(U=Number(U),isNaN(U)||U<0)throw Error("Bad port number "+U);_.u=U}else _.u=null}function Nn(_,U,H){U instanceof Ui?(_.i=U,ia(_.i,_.l)):(H||(U=jn(U,fn)),_.i=new Ui(U,_.l))}function Be(_,U,H){_.i.set(U,H)}function Bt(_){return Be(_,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),_}function Mn(_,U){return _?U?decodeURI(_.replace(/%25/g,"%2525")):decodeURIComponent(_):""}function jn(_,U,H){return typeof _=="string"?(_=encodeURI(_).replace(U,Ln),H&&(_=_.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),_):null}function Ln(_){return _=_.charCodeAt(0),"%"+(_>>4&15).toString(16)+(_&15).toString(16)}var xr=/[#\/\?@]/g,Le=/[#\?:]/g,fe=/[#\?]/g,fn=/[#\?@]/g,xi=/#/g;function Ui(_,U){this.h=this.g=null,this.i=_||null,this.j=!!U}function Bi(_){_.g||(_.g=new Map,_.h=0,_.i&&Re(_.i,function(U,H){_.add(decodeURIComponent(U.replace(/\+/g," ")),H)}))}e=Ui.prototype,e.add=function(_,U){Bi(this),this.i=null,_=ra(this,_);let H=this.g.get(_);return H||this.g.set(_,H=[]),H.push(U),this.h+=1,this};function Lr(_,U){Bi(_),U=ra(_,U),_.g.has(U)&&(_.i=null,_.h-=_.g.get(U).length,_.g.delete(U))}function zi(_,U){return Bi(_),U=ra(_,U),_.g.has(U)}e.forEach=function(_,U){Bi(this),this.g.forEach(function(H,oe){H.forEach(function(De){_.call(U,De,oe,this)},this)},this)};function an(_,U){Bi(_);let H=[];if(typeof U=="string")zi(_,U)&&(H=H.concat(_.g.get(ra(_,U))));else for(_=Array.from(_.g.values()),U=0;U<_.length;U++)H=H.concat(_[U]);return H}e.set=function(_,U){return Bi(this),this.i=null,_=ra(this,_),zi(this,_)&&(this.h-=this.g.get(_).length),this.g.set(_,[U]),this.h+=1,this},e.get=function(_,U){return _?(_=an(this,_),_.length>0?String(_[0]):U):U};function fr(_,U,H){Lr(_,U),H.length>0&&(_.i=null,_.g.set(ra(_,U),A(H)),_.h+=H.length)}e.toString=function(){if(this.i)return this.i;if(!this.g)return"";const _=[],U=Array.from(this.g.keys());for(let oe=0;oe{oe.abort(),fa(H,"TestPingServer: timeout",!1,U)},1e4);fetch(_,{signal:oe.signal}).then(Ye=>{clearTimeout(De),Ye.ok?fa(H,"TestPingServer: ok",!0,U):fa(H,"TestPingServer: server error",!1,U)}).catch(()=>{clearTimeout(De),fa(H,"TestPingServer: error",!1,U)})}function fa(_,U,H,oe,De){try{De&&(De.onload=null,De.onerror=null,De.onabort=null,De.ontimeout=null),oe(H)}catch{}}function ci(){this.g=new mr}function js(_){this.i=_.Sb||null,this.h=_.ab||!1}y(js,gr),js.prototype.g=function(){return new Is(this.i,this.h)};function Is(_,U){ut.call(this),this.H=_,this.o=U,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F="GET",this.D="",this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}y(Is,ut),e=Is.prototype,e.open=function(_,U){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=_,this.D=U,this.readyState=1,Un(this)},e.send=function(_){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;const U={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};_&&(U.body=_),(this.H||o).fetch(new Request(this.D,U)).then(this.Pa.bind(this),this.ga.bind(this))},e.abort=function(){this.response=this.responseText="",this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,ss(this)),this.readyState=0},e.Pa=function(_){if(this.g&&(this.l=_,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=_.headers,this.readyState=2,Un(this)),this.g&&(this.readyState=3,Un(this),this.g)))if(this.responseType==="arraybuffer")_.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof o.ReadableStream<"u"&&"body"in _){if(this.j=_.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.B=new TextDecoder;Gn(this)}else _.text().then(this.Oa.bind(this),this.ga.bind(this))};function Gn(_){_.j.read().then(_.Ma.bind(_)).catch(_.ga.bind(_))}e.Ma=function(_){if(this.g){if(this.o&&_.value)this.response.push(_.value);else if(!this.o){var U=_.value?_.value:new Uint8Array(0);(U=this.B.decode(U,{stream:!_.done}))&&(this.response=this.responseText+=U)}_.done?ss(this):Un(this),this.readyState==3&&Gn(this)}},e.Oa=function(_){this.g&&(this.response=this.responseText=_,ss(this))},e.Na=function(_){this.g&&(this.response=_,ss(this))},e.ga=function(){this.g&&ss(this)};function ss(_){_.readyState=4,_.l=null,_.j=null,_.B=null,Un(_)}e.setRequestHeader=function(_,U){this.A.append(_,U)},e.getResponseHeader=function(_){return this.h&&this.h.get(_.toLowerCase())||""},e.getAllResponseHeaders=function(){if(!this.h)return"";const _=[],U=this.h.entries();for(var H=U.next();!H.done;)H=H.value,_.push(H[0]+": "+H[1]),H=U.next();return _.join(`\r `)};function Un(_){_.onreadystatechange&&_.onreadystatechange.call(_)}Object.defineProperty(Is.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(_){this.m=_?"include":"same-origin"}});function Xr(_){let U="";return Ke(_,function(H,oe){U+=oe,U+=":",U+=H,U+=`\r `}),U}function To(_,U,H){e:{for(oe in H){var oe=!1;break e}oe=!0}oe||(H=Xr(H),typeof _=="string"?H!=null&&je(H):Be(_,U,H))}function Zr(_){ut.call(this),this.headers=new Map,this.L=_||null,this.h=!1,this.g=null,this.D="",this.o=0,this.l="",this.j=this.B=this.v=this.A=!1,this.m=null,this.F="",this.H=!1}y(Zr,ut);var ho=/^https?$/i,Qs=["POST","PUT"];e=Zr.prototype,e.Fa=function(_){this.H=_},e.ea=function(_,U,H,oe){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+_);U=U?U.toUpperCase():"GET",this.D=_,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():$n.g(),this.g.onreadystatechange=w(f(this.Ca,this));try{this.B=!0,this.g.open(U,String(_),!0),this.B=!1}catch(Ye){Po(this,Ye);return}if(_=H||"",H=new Map(this.headers),oe)if(Object.getPrototypeOf(oe)===Object.prototype)for(var De in oe)H.set(De,oe[De]);else if(typeof oe.keys=="function"&&typeof oe.get=="function")for(const Ye of oe.keys())H.set(Ye,oe.get(Ye));else throw Error("Unknown input type for opt_headers: "+String(oe));oe=Array.from(H.keys()).find(Ye=>Ye.toLowerCase()=="content-type"),De=o.FormData&&_ instanceof o.FormData,!(Array.prototype.indexOf.call(Qs,U,void 0)>=0)||oe||De||H.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[Ye,Te]of H)this.g.setRequestHeader(Ye,Te);this.F&&(this.g.responseType=this.F),"withCredentials"in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&(clearTimeout(this.m),this.m=null),this.v=!0,this.g.send(_),this.v=!1}catch(Ye){Po(this,Ye)}};function Po(_,U){_.h=!1,_.g&&(_.j=!0,_.g.abort(),_.j=!1),_.l=U,_.o=5,pa(_),Bs(_)}function pa(_){_.A||(_.A=!0,Jt(_,"complete"),Jt(_,"error"))}e.abort=function(_){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=_||7,Jt(this,"complete"),Jt(this,"abort"),Bs(this))},e.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Bs(this,!0)),Zr.Z.N.call(this)},e.Ca=function(){this.u||(this.B||this.v||this.j?ma(this):this.Xa())},e.Xa=function(){ma(this)};function ma(_){if(_.h&&typeof a<"u"){if(_.v&&Zs(_)==4)setTimeout(_.Ca.bind(_),0);else if(Jt(_,"readystatechange"),Zs(_)==4){_.h=!1;try{const Ye=_.ca();e:switch(Ye){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var U=!0;break e;default:U=!1}var H;if(!(H=U)){var oe;if(oe=Ye===0){let Te=String(_.D).match(cr)[1]||null;!Te&&o.self&&o.self.location&&(Te=o.self.location.protocol.slice(0,-1)),oe=!ho.test(Te?Te.toLowerCase():"")}H=oe}if(H)Jt(_,"complete"),Jt(_,"success");else{_.o=6;try{var De=Zs(_)>2?_.g.statusText:""}catch{De=""}_.l=De+" ["+_.ca()+"]",pa(_)}}finally{Bs(_)}}}}function Bs(_,U){if(_.g){_.m&&(clearTimeout(_.m),_.m=null);const H=_.g;_.g=null,U||Jt(_,"ready");try{H.onreadystatechange=null}catch{}}}e.isActive=function(){return!!this.g};function Zs(_){return _.g?_.g.readyState:0}e.ca=function(){try{return Zs(this)>2?this.g.status:-1}catch{return-1}},e.la=function(){try{return this.g?this.g.responseText:""}catch{return""}},e.La=function(_){if(this.g){var U=this.g.responseText;return _&&U.indexOf(_)==0&&(U=U.substring(_.length)),dn(U)}};function Ni(_){try{if(!_.g)return null;if("response"in _.g)return _.g.response;switch(_.F){case"":case"text":return _.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in _.g)return _.g.mozResponseArrayBuffer}return null}catch{return null}}function zs(_){const U={};_=(_.g&&Zs(_)>=2&&_.g.getAllResponseHeaders()||"").split(`\r `);for(let oe=0;oe<_.length;oe++){if(J(_[oe]))continue;var H=ln(_[oe]);const De=H[0];if(H=H[1],typeof H!="string")continue;H=H.trim();const Ye=U[De]||[];U[De]=Ye,Ye.push(H)}G(U,function(oe){return oe.join(", ")})}e.ya=function(){return this.o},e.Ha=function(){return typeof this.l=="string"?this.l:String(this.l)};function yi(_,U,H){return H&&H.internalChannelParams&&H.internalChannelParams[_]||U}function Xa(_){this.za=0,this.i=[],this.j=new ue,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=yi("failFast",!1,_),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=yi("baseRetryDelayMs",5e3,_),this.Za=yi("retryDelaySeedMs",1e4,_),this.Ta=yi("forwardChannelMaxRetries",2,_),this.va=yi("forwardChannelRequestTimeoutMs",2e4,_),this.ma=_&&_.xmlHttpFactory||void 0,this.Ua=_&&_.Rb||void 0,this.Aa=_&&_.useFetchStreams||!1,this.O=void 0,this.L=_&&_.supportsCrossDomainXhr||!1,this.M="",this.h=new kt(_&&_.concurrentRequestLimit),this.Ba=new ci,this.S=_&&_.fastHandshake||!1,this.R=_&&_.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=_&&_.Pb||!1,_&&_.ua&&this.j.ua(),_&&_.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&_&&_.detectBufferingProxy||!1,this.ia=void 0,_&&_.longPollingTimeout&&_.longPollingTimeout>0&&(this.ia=_.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}e=Xa.prototype,e.ka=8,e.I=1,e.connect=function(_,U,H,oe){on(0),this.W=_,this.H=U||{},H&&oe!==void 0&&(this.H.OSID=H,this.H.OAID=oe),this.F=this.X,this.J=ct(this,null,this.W),ga(this)};function Nl(_){if(Zo(_),_.I==3){var U=_.V++,H=rt(_.J);if(Be(H,"SID",_.M),Be(H,"RID",U),Be(H,"TYPE","terminate"),Ra(_,H),U=new bt(_,_.j,U),U.M=2,U.A=Bt(rt(H)),H=!1,o.navigator&&o.navigator.sendBeacon)try{H=o.navigator.sendBeacon(U.A.toString(),"")}catch{}!H&&o.Image&&(new Image().src=U.A,H=!0),H||(U.g=ot(U.j,null),U.g.ea(U.A)),U.F=Date.now(),vs(U)}$e(_)}function fo(_){_.g&&(at(_),_.g.cancel(),_.g=null)}function Zo(_){fo(_),_.v&&(o.clearTimeout(_.v),_.v=null),Jr(_),_.h.cancel(),_.m&&(typeof _.m=="number"&&o.clearTimeout(_.m),_.m=null)}function ga(_){if(!Pa(_.h)&&!_.m){_.m=!0;var U=_.Ea;Z||z(),q||(Z(),q=!0),B.add(U,_),_.D=0}}function po(_,U){return wr(_.h)>=_.h.j-(_.m?1:0)?!1:_.m?(_.i=U.G.concat(_.i),!0):_.I==1||_.I==2||_.D>=(_.Sa?0:_.Ta)?!1:(_.m=lr(f(_.Ea,_,U),we(_,_.D)),_.D++,!0)}e.Ea=function(_){if(this.m)if(this.m=null,this.I==1){if(!_){this.V=Math.floor(Math.random()*1e5),_=this.V++;const De=new bt(this,this.j,_);let Ye=this.o;if(this.U&&(Ye?(Ye=se(Ye),re(Ye,this.U)):Ye=this.U),this.u!==null||this.R||(De.J=Ye,Ye=null),this.S)e:{for(var U=0,H=0;H4096){U=H;break e}if(U===4096||H===this.i.length-1){U=H+1;break e}}U=1e3}else U=1e3;U=Oo(this,De,U),H=rt(this.J),Be(H,"RID",_),Be(H,"CVER",22),this.G&&Be(H,"X-HTTP-Session-Id",this.G),Ra(this,H),Ye&&(this.R?U="headers="+je(Xr(Ye))+"&"+U:this.u&&To(H,this.u,Ye)),uo(this.h,De),this.Ra&&Be(H,"TYPE","init"),this.S?(Be(H,"$req",U),Be(H,"SID","null"),De.U=!0,Mr(De,H,null)):Mr(De,H,U),this.I=2}}else this.I==3&&(_?Fr(this,_):this.i.length==0||Pa(this.h)||Fr(this))};function Fr(_,U){var H;U?H=U.l:H=_.V++;const oe=rt(_.J);Be(oe,"SID",_.M),Be(oe,"RID",H),Be(oe,"AID",_.K),Ra(_,oe),_.u&&_.o&&To(oe,_.u,_.o),H=new bt(_,_.j,H,_.D+1),_.u===null&&(H.J=_.o),U&&(_.i=U.G.concat(_.i)),U=Oo(_,H,1e3),H.H=Math.round(_.va*.5)+Math.round(_.va*.5*Math.random()),uo(_.h,H),Mr(H,oe,U)}function Ra(_,U){_.H&&Ke(_.H,function(H,oe){Be(U,oe,H)}),_.l&&Ke({},function(H,oe){Be(U,oe,H)})}function Oo(_,U,H){H=Math.min(_.i.length,H);const oe=_.l?f(_.l.Ka,_.l,_):null;e:{var De=_.i;let Ct=-1;for(;;){const Zn=["count="+H];Ct==-1?H>0?(Ct=De[0].g,Zn.push("ofs="+Ct)):Ct=0:Zn.push("ofs="+Ct);let wn=!0;for(let tr=0;tr=3?!1:(_.Y++,_.v=lr(f(_.Da,_),we(_,_.A)),_.A++,!0)}e.Da=function(){if(this.v=null,pr(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var _=4*this.T;this.j.info("BP detection timer enabled: "+_),this.B=lr(f(this.Wa,this),_)}},e.Wa=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.P=!0,on(10),fo(this),pr(this))};function at(_){_.B!=null&&(o.clearTimeout(_.B),_.B=null)}function pr(_){_.g=new bt(_,_.j,"rpc",_.Y),_.u===null&&(_.g.J=_.o),_.g.P=0;var U=rt(_.na);Be(U,"RID","rpc"),Be(U,"SID",_.M),Be(U,"AID",_.K),Be(U,"CI",_.F?"0":"1"),!_.F&&_.ia&&Be(U,"TO",_.ia),Be(U,"TYPE","xmlhttp"),Ra(_,U),_.u&&_.o&&To(U,_.u,_.o),_.O&&(_.g.H=_.O);var H=_.g;_=_.ba,H.M=1,H.A=Bt(rt(U)),H.u=null,H.R=!0,ji(H,_)}e.Va=function(){this.C!=null&&(this.C=null,fo(this),Ro(this),on(19))};function Jr(_){_.C!=null&&(o.clearTimeout(_.C),_.C=null)}function ge(_,U){var H=null;if(_.g==U){Jr(_),at(_),_.g=null;var oe=2}else if(is(_.h,U))H=U.G,hr(_.h,U),oe=1;else return;if(_.I!=0){if(U.o)if(oe==1){H=U.u?U.u.length:0,U=Date.now()-U.F;var De=_.D;oe=An(),Jt(oe,new jr(oe,H)),ga(_)}else Qa(_);else if(De=U.m,De==3||De==0&&U.X>0||!(oe==1&&po(_,U)||oe==2&&Ro(_)))switch(H&&H.length>0&&(U=_.h,U.i=U.i.concat(H)),De){case 1:Pe(_,5);break;case 4:Pe(_,10);break;case 3:Pe(_,6);break;default:Pe(_,2)}}}function we(_,U){let H=_.Qa+Math.floor(Math.random()*_.Za);return _.isActive()||(H*=2),H*U}function Pe(_,U){if(_.j.info("Error code "+U),U==2){var H=f(_.bb,_),oe=_.Ua;const De=!oe;oe=new mt(oe||"//www.google.com/images/cleardot.gif"),o.location&&o.location.protocol=="http"||At(oe,"https"),Bt(oe),De?Cs(oe.toString(),H):Qo(oe.toString(),H)}else on(2);_.I=0,_.l&&_.l.pa(U),$e(_),Zo(_)}e.bb=function(_){_?(this.j.info("Successfully pinged google.com"),on(2)):(this.j.info("Failed to ping google.com"),on(1))};function $e(_){if(_.I=0,_.ja=[],_.l){const U=Nr(_.h);(U.length!=0||_.i.length!=0)&&(S(_.ja,U),S(_.ja,_.i),_.h.i.length=0,A(_.i),_.i.length=0),_.l.oa()}}function ct(_,U,H){var oe=H instanceof mt?rt(H):new mt(H);if(oe.g!="")U&&(oe.g=U+"."+oe.g),nn(oe,oe.u);else{var De=o.location;oe=De.protocol,U=U?U+"."+De.hostname:De.hostname,De=+De.port;const Ye=new mt(null);oe&&At(Ye,oe),U&&(Ye.g=U),De&&nn(Ye,De),H&&(Ye.h=H),oe=Ye}return H=_.G,U=_.wa,H&&U&&Be(oe,H,U),Be(oe,"VER",_.ka),Ra(_,oe),oe}function ot(_,U,H){if(U&&!_.L)throw Error("Can't create secondary domain capable XhrIo object.");return U=_.Aa&&!_.ma?new Zr(new js({ab:H})):new Zr(_.ma),U.Fa(_.L),U}e.isActive=function(){return!!this.l&&this.l.isActive(this)};function _t(){}e=_t.prototype,e.ra=function(){},e.qa=function(){},e.pa=function(){},e.oa=function(){},e.isActive=function(){return!0},e.Ka=function(){};function pn(){}pn.prototype.g=function(_,U){return new Lt(_,U)};function Lt(_,U){ut.call(this),this.g=new Xa(U),this.l=_,this.h=U&&U.messageUrlParams||null,_=U&&U.messageHeaders||null,U&&U.clientProtocolHeaderRequired&&(_?_["X-Client-Protocol"]="webchannel":_={"X-Client-Protocol":"webchannel"}),this.g.o=_,_=U&&U.initMessageHeaders||null,U&&U.messageContentType&&(_?_["X-WebChannel-Content-Type"]=U.messageContentType:_={"X-WebChannel-Content-Type":U.messageContentType}),U&&U.sa&&(_?_["X-WebChannel-Client-Profile"]=U.sa:_={"X-WebChannel-Client-Profile":U.sa}),this.g.U=_,(_=U&&U.Qb)&&!J(_)&&(this.g.u=_),this.A=U&&U.supportsCrossDomainXhr||!1,this.v=U&&U.sendRawJson||!1,(U=U&&U.httpSessionIdParam)&&!J(U)&&(this.g.G=U,_=this.h,_!==null&&U in _&&(_=this.h,U in _&&delete _[U])),this.j=new He(this)}y(Lt,ut),Lt.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},Lt.prototype.close=function(){Nl(this.g)},Lt.prototype.o=function(_){var U=this.g;if(typeof _=="string"){var H={};H.__data__=_,_=H}else this.v&&(H={},H.__data__=cn(_),_=H);U.i.push(new Qr(U.Ya++,_)),U.I==3&&ga(U)},Lt.prototype.N=function(){this.g.l=null,delete this.j,Nl(this.g),delete this.g,Lt.Z.N.call(this)};function bn(_){me.call(this),_.__headers__&&(this.headers=_.__headers__,this.statusCode=_.__status__,delete _.__headers__,delete _.__status__);var U=_.__sm__;if(U){e:{for(const H in U){_=H;break e}_=void 0}(this.i=_)&&(_=this.i,U=U!==null&&_ in U?U[_]:void 0),this.data=U}else this.data=_}y(bn,me);function rn(){qe.call(this),this.status=1}y(rn,qe);function He(_){this.g=_}y(He,_t),He.prototype.ra=function(){Jt(this.g,"a")},He.prototype.qa=function(_){Jt(this.g,new bn(_))},He.prototype.pa=function(_){Jt(this.g,new rn)},He.prototype.oa=function(){Jt(this.g,"b")},pn.prototype.createWebChannel=pn.prototype.g,Lt.prototype.send=Lt.prototype.o,Lt.prototype.open=Lt.prototype.m,Lt.prototype.close=Lt.prototype.close,b$=function(){return new pn},y$=function(){return An()},x$=st,ZS={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},kn.NO_ERROR=0,kn.TIMEOUT=8,kn.HTTP_ERROR=6,kw=kn,xt.COMPLETE="complete",g$=xt,wi.EventType=Xt,Xt.OPEN="a",Xt.CLOSE="b",Xt.ERROR="c",Xt.MESSAGE="d",ut.prototype.listen=ut.prototype.J,y1=wi,Zr.prototype.listenOnce=Zr.prototype.K,Zr.prototype.getLastError=Zr.prototype.Ha,Zr.prototype.getLastErrorCode=Zr.prototype.ya,Zr.prototype.getStatus=Zr.prototype.ca,Zr.prototype.getResponseJson=Zr.prototype.La,Zr.prototype.getResponseText=Zr.prototype.la,Zr.prototype.send=Zr.prototype.ea,Zr.prototype.setWithCredentials=Zr.prototype.Fa,m$=Zr}).apply(typeof Ov<"u"?Ov:typeof self<"u"?self:typeof window<"u"?window:{});/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class wo{constructor(t){this.uid=t}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}wo.UNAUTHENTICATED=new wo(null),wo.GOOGLE_CREDENTIALS=new wo("google-credentials-uid"),wo.FIRST_PARTY=new wo("first-party-uid"),wo.MOCK_USER=new wo("mock-user");/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */let Bg="12.11.0";function Kle(e){Bg=e}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Jp=new wI("@firebase/firestore");function j0(){return Jp.logLevel}function qt(e,...t){if(Jp.logLevel<=ai.DEBUG){const n=t.map(RI);Jp.debug(`Firestore (${Bg}): ${e}`,...n)}}function ta(e,...t){if(Jp.logLevel<=ai.ERROR){const n=t.map(RI);Jp.error(`Firestore (${Bg}): ${e}`,...n)}}function ag(e,...t){if(Jp.logLevel<=ai.WARN){const n=t.map(RI);Jp.warn(`Firestore (${Bg}): ${e}`,...n)}}function RI(e){if(typeof e=="string")return e;try{return(function(n){return JSON.stringify(n)})(e)}catch{return e}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Tn(e,t,n){let r="Unexpected state";typeof t=="string"?r=t:n=t,v$(e,r,n)}function v$(e,t,n){let r=`FIRESTORE (${Bg}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(n!==void 0)try{r+=" CONTEXT: "+JSON.stringify(n)}catch{r+=" CONTEXT: "+n}throw ta(r),new Error(r)}function Xn(e,t,n,r){let i="Unexpected state";typeof n=="string"?i=n:r=n,e||v$(t,i,r)}function Vn(e,t){return e}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const vt={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class sn extends Xd{constructor(t,n){super(t,n),this.code=t,this.message=n,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Hc{constructor(){this.promise=new Promise(((t,n)=>{this.resolve=t,this.reject=n}))}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Yle{constructor(t,n){this.user=n,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class Xle{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,n){t.enqueueRetryable((()=>n(wo.UNAUTHENTICATED)))}shutdown(){}}class Qle{constructor(t){this.t=t,this.currentUser=wo.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,n){Xn(this.o===void 0,42304);let r=this.i;const i=h=>this.i!==r?(r=this.i,n(h)):Promise.resolve();let a=new Hc;this.o=()=>{this.i++,this.currentUser=this.u(),a.resolve(),a=new Hc,t.enqueueRetryable((()=>i(this.currentUser)))};const o=()=>{const h=a;t.enqueueRetryable((async()=>{await h.promise,await i(this.currentUser)}))},c=h=>{qt("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=h,this.o&&(this.auth.addAuthTokenListener(this.o),o())};this.t.onInit((h=>c(h))),setTimeout((()=>{if(!this.auth){const h=this.t.getImmediate({optional:!0});h?c(h):(qt("FirebaseAuthCredentialsProvider","Auth not yet detected"),a.resolve(),a=new Hc)}}),0),o()}getToken(){const t=this.i,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then((r=>this.i!==t?(qt("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(Xn(typeof r.accessToken=="string",31837,{l:r}),new Yle(r.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const t=this.auth&&this.auth.getUid();return Xn(t===null||typeof t=="string",2055,{h:t}),new wo(t)}}class Zle{constructor(t,n,r){this.P=t,this.T=n,this.I=r,this.type="FirstParty",this.user=wo.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);const t=this.A();return t&&this.R.set("Authorization",t),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class Jle{constructor(t,n,r){this.P=t,this.T=n,this.I=r}getToken(){return Promise.resolve(new Zle(this.P,this.T,this.I))}start(t,n){t.enqueueRetryable((()=>n(wo.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class RR{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class ece{constructor(t,n){this.V=n,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Pl(t)&&t.settings.appCheckToken&&(this.p=t.settings.appCheckToken)}start(t,n){Xn(this.o===void 0,3512);const r=a=>{a.error!=null&&qt("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${a.error.message}`);const o=a.token!==this.m;return this.m=a.token,qt("FirebaseAppCheckTokenProvider",`Received ${o?"new":"existing"} token.`),o?n(a.token):Promise.resolve()};this.o=a=>{t.enqueueRetryable((()=>r(a)))};const i=a=>{qt("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=a,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((a=>i(a))),setTimeout((()=>{if(!this.appCheck){const a=this.V.getImmediate({optional:!0});a?i(a):qt("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new RR(this.p));const t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then((n=>n?(Xn(typeof n.token=="string",44558,{tokenResult:n}),this.m=n.token,new RR(n.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function tce(e){const t=typeof self<"u"&&(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&&typeof t.getRandomValues=="function")t.getRandomValues(n);else for(let r=0;rt?1:0}function JS(e,t){const n=Math.min(e.length,t.length);for(let r=0;r=nce&&t<=rce}function og(e,t,n){return e.length===t.length&&e.every(((r,i)=>n(r,t[i])))}function w$(e){return e+"\0"}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const DR="__name__";class wu{constructor(t,n,r){n===void 0?n=0:n>t.length&&Tn(637,{offset:n,range:t.length}),r===void 0?r=t.length-n:r>t.length-n&&Tn(1746,{length:r,range:t.length-n}),this.segments=t,this.offset=n,this.len=r}get length(){return this.len}isEqual(t){return wu.comparator(this,t)===0}child(t){const n=this.segments.slice(this.offset,this.limit());return t instanceof wu?t.forEach((r=>{n.push(r)})):n.push(t),this.construct(n)}limit(){return this.offset+this.length}popFirst(t){return t=t===void 0?1:t,this.construct(this.segments,this.offset+t,this.length-t)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(t){return this.segments[this.offset+t]}isEmpty(){return this.length===0}isPrefixOf(t){if(t.length=0)throw new sn(vt.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);n.push(...r.split("/").filter((i=>i.length>0)))}return new ki(n)}static emptyPath(){return new ki([])}}const ice=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class Ls extends wu{construct(t,n,r){return new Ls(t,n,r)}static isValidIdentifier(t){return ice.test(t)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),Ls.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===DR}static keyField(){return new Ls([DR])}static fromServerFormat(t){const n=[];let r="",i=0;const a=()=>{if(r.length===0)throw new sn(vt.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);n.push(r),r=""};let o=!1;for(;i=2&&this.path.get(this.path.length-2)===t}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(t){return t!==null&&ki.comparator(this.path,t.path)===0}toString(){return this.path.toString()}static comparator(t,n){return ki.comparator(t.path,n.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new gn(new ki(t.slice()))}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function MI(e,t,n){if(!n)throw new sn(vt.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function sce(e,t,n,r){if(t===!0&&r===!0)throw new sn(vt.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function MR(e){if(!gn.isDocumentKey(e))throw new sn(vt.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function LR(e){if(gn.isDocumentKey(e))throw new sn(vt.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function N$(e){return typeof e=="object"&&e!==null&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}function oE(e){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="string")return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return""+e;if(typeof e=="object"){if(e instanceof Array)return"an array";{const t=(function(r){return r.constructor?r.constructor.name:null})(e);return t?`a custom ${t} object`:"an object"}}return typeof e=="function"?"a function":Tn(12329,{type:typeof e})}function qo(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new sn(vt.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=oE(e);throw new sn(vt.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function ace(e,t){if(t<=0)throw new sn(vt.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}/** * @license * Copyright 2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function da(e,t){const n={typeString:e};return t&&(n.value=t),n}function Fy(e,t){if(!N$(e))throw new sn(vt.INVALID_ARGUMENT,"JSON must be an object");let n;for(const r in t)if(t[r]){const i=t[r].typeString,a="value"in t[r]?{value:t[r].value}:void 0;if(!(r in e)){n=`JSON missing required field: '${r}'`;break}const o=e[r];if(i&&typeof o!==i){n=`JSON field '${r}' must be a ${i}.`;break}if(a!==void 0&&o!==a.value){n=`Expected '${r}' field to equal '${a.value}'`;break}}if(n)throw new sn(vt.INVALID_ARGUMENT,n);return!0}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const UR=-62135596800,BR=1e6;class _r{static now(){return _r.fromMillis(Date.now())}static fromDate(t){return _r.fromMillis(t.getTime())}static fromMillis(t){const n=Math.floor(t/1e3),r=Math.floor((t-1e3*n)*BR);return new _r(n,r)}constructor(t,n){if(this.seconds=t,this.nanoseconds=n,n<0)throw new sn(vt.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(n>=1e9)throw new sn(vt.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(t=253402300800)throw new sn(vt.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/BR}_compareTo(t){return this.seconds===t.seconds?Cr(this.nanoseconds,t.nanoseconds):Cr(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:_r._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(t){if(Fy(t,_r._jsonSchema))return new _r(t.seconds,t.nanoseconds)}valueOf(){const t=this.seconds-UR;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}_r._jsonSchemaVersion="firestore/timestamp/1.0",_r._jsonSchema={type:da("string",_r._jsonSchemaVersion),seconds:da("number"),nanoseconds:da("number")};/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class sr{static fromTimestamp(t){return new sr(t)}static min(){return new sr(new _r(0,0))}static max(){return new sr(new _r(253402300799,999999999))}constructor(t){this.timestamp=t}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const lg=-1;class d2{constructor(t,n,r,i){this.indexId=t,this.collectionGroup=n,this.fields=r,this.indexState=i}}function eC(e){return e.fields.find((t=>t.kind===2))}function cp(e){return e.fields.filter((t=>t.kind!==2))}d2.UNKNOWN_ID=-1;class Sw{constructor(t,n){this.fieldPath=t,this.kind=n}}class ry{constructor(t,n){this.sequenceNumber=t,this.offset=n}static empty(){return new ry(0,Vl.min())}}function E$(e,t){const n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1,i=sr.fromTimestamp(r===1e9?new _r(n+1,0):new _r(n,r));return new Vl(i,gn.empty(),t)}function A$(e){return new Vl(e.readTime,e.key,lg)}class Vl{constructor(t,n,r){this.readTime=t,this.documentKey=n,this.largestBatchId=r}static min(){return new Vl(sr.min(),gn.empty(),lg)}static max(){return new Vl(sr.max(),gn.empty(),lg)}}function LI(e,t){let n=e.readTime.compareTo(t.readTime);return n!==0?n:(n=gn.comparator(e.documentKey,t.documentKey),n!==0?n:Cr(e.largestBatchId,t.largestBatchId))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const _$="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class k${constructor(){this.onCommittedListeners=[]}addOnCommittedListener(t){this.onCommittedListeners.push(t)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((t=>t()))}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function Ef(e){if(e.code!==vt.FAILED_PRECONDITION||e.message!==_$)throw e;qt("LocalStore","Unexpectedly lost primary lease")}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Xe{constructor(t){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t((n=>{this.isDone=!0,this.result=n,this.nextCallback&&this.nextCallback(n)}),(n=>{this.isDone=!0,this.error=n,this.catchCallback&&this.catchCallback(n)}))}catch(t){return this.next(void 0,t)}next(t,n){return this.callbackAttached&&Tn(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(t,this.result):new Xe(((r,i)=>{this.nextCallback=a=>{this.wrapSuccess(t,a).next(r,i)},this.catchCallback=a=>{this.wrapFailure(n,a).next(r,i)}}))}toPromise(){return new Promise(((t,n)=>{this.next(t,n)}))}wrapUserFunction(t){try{const n=t();return n instanceof Xe?n:Xe.resolve(n)}catch(n){return Xe.reject(n)}}wrapSuccess(t,n){return t?this.wrapUserFunction((()=>t(n))):Xe.resolve(n)}wrapFailure(t,n){return t?this.wrapUserFunction((()=>t(n))):Xe.reject(n)}static resolve(t){return new Xe(((n,r)=>{n(t)}))}static reject(t){return new Xe(((n,r)=>{r(t)}))}static waitFor(t){return new Xe(((n,r)=>{let i=0,a=0,o=!1;t.forEach((c=>{++i,c.next((()=>{++a,o&&a===i&&n()}),(h=>r(h)))})),o=!0,a===i&&n()}))}static or(t){let n=Xe.resolve(!1);for(const r of t)n=n.next((i=>i?Xe.resolve(i):r()));return n}static forEach(t,n){const r=[];return t.forEach(((i,a)=>{r.push(n.call(this,i,a))})),this.waitFor(r)}static mapArray(t,n){return new Xe(((r,i)=>{const a=t.length,o=new Array(a);let c=0;for(let h=0;h{o[f]=m,++c,c===a&&r(o)}),(m=>i(m)))}}))}static doWhile(t,n){return new Xe(((r,i)=>{const a=()=>{t()===!0?n().next((()=>{a()}),i):r()};a()}))}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Tl="SimpleDb";class lE{static open(t,n,r,i){try{return new lE(n,t.transaction(i,r))}catch(a){throw new P1(n,a)}}constructor(t,n){this.action=t,this.transaction=n,this.aborted=!1,this.S=new Hc,this.transaction.oncomplete=()=>{this.S.resolve()},this.transaction.onabort=()=>{n.error?this.S.reject(new P1(t,n.error)):this.S.resolve()},this.transaction.onerror=r=>{const i=UI(r.target.error);this.S.reject(new P1(t,i))}}get D(){return this.S.promise}abort(t){t&&this.S.reject(t),this.aborted||(qt(Tl,"Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}C(){const t=this.transaction;this.aborted||typeof t.commit!="function"||t.commit()}store(t){const n=this.transaction.objectStore(t);return new lce(n)}}class of{static delete(t){return qt(Tl,"Removing database:",t),gp(vF().indexedDB.deleteDatabase(t)).toPromise()}static v(){if(!kF())return!1;if(of.F())return!0;const t=Sa(),n=of.M(t),r=00||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||r||a)}static F(){var t;return typeof process<"u"&&((t=process.__PRIVATE_env)==null?void 0:t.__PRIVATE_USE_MOCK_PERSISTENCE)==="YES"}static O(t,n){return t.store(n)}static M(t){const n=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),r=n?n[1].split("_").slice(0,2).join("."):"-1";return Number(r)}constructor(t,n,r){this.name=t,this.version=n,this.N=r,this.B=null,of.M(Sa())===12.2&&ta("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}async L(t){return this.db||(qt(Tl,"Opening database:",this.name),this.db=await new Promise(((n,r)=>{const i=indexedDB.open(this.name,this.version);i.onsuccess=a=>{const o=a.target.result;n(o)},i.onblocked=()=>{r(new P1(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=a=>{const o=a.target.error;o.name==="VersionError"?r(new sn(vt.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):o.name==="InvalidStateError"?r(new sn(vt.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+o)):r(new P1(t,o))},i.onupgradeneeded=a=>{qt(Tl,'Database "'+this.name+'" requires upgrade from version:',a.oldVersion);const o=a.target.result;this.N.k(o,i.transaction,a.oldVersion,this.version).next((()=>{qt(Tl,"Database upgrade to version "+this.version+" complete")}))}}))),this.q&&(this.db.onversionchange=n=>this.q(n)),this.db}K(t){this.q=t,this.db&&(this.db.onversionchange=n=>t(n))}async runTransaction(t,n,r,i){const a=n==="readonly";let o=0;for(;;){++o;try{this.db=await this.L(t);const c=lE.open(this.db,t,a?"readonly":"readwrite",r),h=i(c).next((f=>(c.C(),f))).catch((f=>(c.abort(f),Xe.reject(f)))).toPromise();return h.catch((()=>{})),await c.D,h}catch(c){const h=c,f=h.name!=="FirebaseError"&&o<3;if(qt(Tl,"Transaction failed with error:",h.message,"Retrying:",f),this.close(),!f)return Promise.reject(h)}}}close(){this.db&&this.db.close(),this.db=void 0}}function S$(e){const t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(n)}class oce{constructor(t){this.U=t,this.$=!1,this.W=null}get isDone(){return this.$}get G(){return this.W}set cursor(t){this.U=t}done(){this.$=!0}j(t){this.W=t}delete(){return gp(this.U.delete())}}class P1 extends sn{constructor(t,n){super(vt.UNAVAILABLE,`IndexedDB transaction '${t}' failed: ${n}`),this.name="IndexedDbTransactionError"}}function Af(e){return e.name==="IndexedDbTransactionError"}class lce{constructor(t){this.store=t}put(t,n){let r;return n!==void 0?(qt(Tl,"PUT",this.store.name,t,n),r=this.store.put(n,t)):(qt(Tl,"PUT",this.store.name,"",t),r=this.store.put(t)),gp(r)}add(t){return qt(Tl,"ADD",this.store.name,t,t),gp(this.store.add(t))}get(t){return gp(this.store.get(t)).next((n=>(n===void 0&&(n=null),qt(Tl,"GET",this.store.name,t,n),n)))}delete(t){return qt(Tl,"DELETE",this.store.name,t),gp(this.store.delete(t))}count(){return qt(Tl,"COUNT",this.store.name),gp(this.store.count())}J(t,n){const r=this.options(t,n),i=r.index?this.store.index(r.index):this.store;if(typeof i.getAll=="function"){const a=i.getAll(r.range);return new Xe(((o,c)=>{a.onerror=h=>{c(h.target.error)},a.onsuccess=h=>{o(h.target.result)}}))}{const a=this.cursor(r),o=[];return this.H(a,((c,h)=>{o.push(h)})).next((()=>o))}}Z(t,n){const r=this.store.getAll(t,n===null?void 0:n);return new Xe(((i,a)=>{r.onerror=o=>{a(o.target.error)},r.onsuccess=o=>{i(o.target.result)}}))}X(t,n){qt(Tl,"DELETE ALL",this.store.name);const r=this.options(t,n);r.Y=!1;const i=this.cursor(r);return this.H(i,((a,o,c)=>c.delete()))}ee(t,n){let r;n?r=t:(r={},n=t);const i=this.cursor(r);return this.H(i,n)}te(t){const n=this.cursor({});return new Xe(((r,i)=>{n.onerror=a=>{const o=UI(a.target.error);i(o)},n.onsuccess=a=>{const o=a.target.result;o?t(o.primaryKey,o.value).next((c=>{c?o.continue():r()})):r()}}))}H(t,n){const r=[];return new Xe(((i,a)=>{t.onerror=o=>{a(o.target.error)},t.onsuccess=o=>{const c=o.target.result;if(!c)return void i();const h=new oce(c),f=n(c.primaryKey,c.value,h);if(f instanceof Xe){const m=f.catch((y=>(h.done(),Xe.reject(y))));r.push(m)}h.isDone?i():h.G===null?c.continue():c.continue(h.G)}})).next((()=>Xe.waitFor(r)))}options(t,n){let r;return t!==void 0&&(typeof t=="string"?r=t:n=t),{index:r,range:n}}cursor(t){let n="next";if(t.reverse&&(n="prev"),t.index){const r=this.store.index(t.index);return t.Y?r.openKeyCursor(t.range,n):r.openCursor(t.range,n)}return this.store.openCursor(t.range,n)}}function gp(e){return new Xe(((t,n)=>{e.onsuccess=r=>{const i=r.target.result;t(i)},e.onerror=r=>{const i=UI(r.target.error);n(i)}}))}let zR=!1;function UI(e){const t=of.M(Sa());if(t>=12.2&&t<13){const n="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(n)>=0){const r=new sn("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${n}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return zR||(zR=!0,setTimeout((()=>{throw r}),0)),r}}return e}const O1="IndexBackfiller";class cce{constructor(t,n){this.asyncQueue=t,this.ne=n,this.task=null}start(){this.re(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return this.task!==null}re(t){qt(O1,`Scheduled in ${t}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",t,(async()=>{this.task=null;try{const n=await this.ne.ie();qt(O1,`Documents written: ${n}`)}catch(n){Af(n)?qt(O1,"Ignoring IndexedDB error during index backfill: ",n):await Ef(n)}await this.re(6e4)}))}}class uce{constructor(t,n){this.localStore=t,this.persistence=n}async ie(t=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",(n=>this.se(n,t)))}se(t,n){const r=new Set;let i=n,a=!0;return Xe.doWhile((()=>a===!0&&i>0),(()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(t).next((o=>{if(o!==null&&!r.has(o))return qt(O1,`Processing collection: ${o}`),this.oe(t,o,i).next((c=>{i-=c,r.add(o)}));a=!1})))).next((()=>n-i))}oe(t,n,r){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(t,n).next((i=>this.localStore.localDocuments.getNextDocuments(t,n,i,r).next((a=>{const o=a.changes;return this.localStore.indexManager.updateIndexEntries(t,o).next((()=>this._e(i,a))).next((c=>(qt(O1,`Updating offset: ${c}`),this.localStore.indexManager.updateCollectionGroup(t,n,c)))).next((()=>o.size))}))))}_e(t,n){let r=t;return n.changes.forEach(((i,a)=>{const o=A$(a);LI(o,r)>0&&(r=o)})),new Vl(r.readTime,r.documentKey,Math.max(n.batchId,t.largestBatchId))}}/** * @license * Copyright 2018 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ml{constructor(t,n){this.previousValue=t,n&&(n.sequenceNumberHandler=r=>this.ae(r),this.ue=r=>n.writeSequenceNumber(r))}ae(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.ue&&this.ue(t),t}}ml.ce=-1;/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Dp=-1;function cE(e){return e==null}function iy(e){return e===0&&1/e==-1/0}function C$(e){return typeof e=="number"&&Number.isInteger(e)&&!iy(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const h2="";function So(e){let t="";for(let n=0;n0&&(t=VR(t)),t=dce(e.get(n),t);return VR(t)}function dce(e,t){let n=t;const r=e.length;for(let i=0;i=2,64408,{path:e}),t===2)return Xn(e.charAt(0)===h2&&e.charAt(1)==="",56145,{path:e}),ki.emptyPath();const n=t-2,r=[];let i="";for(let a=0;an)&&Tn(50515,{path:e}),e.charAt(o+1)){case"":const c=e.substring(a,o);let h;i.length===0?h=c:(i+=c,h=i,i=""),r.push(h);break;case"":i+=e.substring(a,o),i+="\0";break;case"":i+=e.substring(a,o+1);break;default:Tn(61167,{path:e})}a=o+2}return new ki(r)}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const up="remoteDocuments",$y="owner",h0="owner",sy="mutationQueues",hce="userId",Uc="mutations",FR="batchId",Ap="userMutationsIndex",$R=["userId","batchId"];/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Cw(e,t){return[e,So(t)]}function j$(e,t,n){return[e,So(t),n]}const fce={},cg="documentMutations",f2="remoteDocumentsV14",pce=["prefixPath","collectionGroup","readTime","documentId"],jw="documentKeyIndex",mce=["prefixPath","collectionGroup","documentId"],I$="collectionGroupIndex",gce=["collectionGroup","readTime","prefixPath","documentId"],ay="remoteDocumentGlobal",tC="remoteDocumentGlobalKey",ug="targets",T$="queryTargetsIndex",xce=["canonicalId","targetId"],dg="targetDocuments",yce=["targetId","path"],BI="documentTargetsIndex",bce=["path","targetId"],p2="targetGlobalKey",Mp="targetGlobal",oy="collectionParents",vce=["collectionId","parent"],hg="clientMetadata",wce="clientId",uE="bundles",Nce="bundleId",dE="namedQueries",Ece="name",zI="indexConfiguration",Ace="indexId",nC="collectionGroupIndex",_ce="collectionGroup",R1="indexState",kce=["indexId","uid"],P$="sequenceNumberIndex",Sce=["uid","sequenceNumber"],D1="indexEntries",Cce=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],O$="documentKeyIndex",jce=["indexId","uid","orderedDocumentKey"],hE="documentOverlays",Ice=["userId","collectionPath","documentId"],rC="collectionPathOverlayIndex",Tce=["userId","collectionPath","largestBatchId"],R$="collectionGroupOverlayIndex",Pce=["userId","collectionGroup","largestBatchId"],VI="globals",Oce="name",D$=[sy,Uc,cg,up,ug,$y,Mp,dg,hg,ay,oy,uE,dE],Rce=[...D$,hE],M$=[sy,Uc,cg,f2,ug,$y,Mp,dg,hg,ay,oy,uE,dE,hE],L$=M$,FI=[...L$,zI,R1,D1],Dce=FI,U$=[...FI,VI],Mce=U$;/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class iC extends k${constructor(t,n){super(),this.le=t,this.currentSequenceNumber=n}}function ja(e,t){const n=Vn(e);return of.O(n.le,t)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function HR(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function _f(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function Lce(e,t){const n=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(t(e[r],r,e));return n}function B$(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ds{constructor(t,n){this.comparator=t,this.root=n||io.EMPTY}insert(t,n){return new ds(this.comparator,this.root.insert(t,n,this.comparator).copy(null,null,io.BLACK,null,null))}remove(t){return new ds(this.comparator,this.root.remove(t,this.comparator).copy(null,null,io.BLACK,null,null))}get(t){let n=this.root;for(;!n.isEmpty();){const r=this.comparator(t,n.key);if(r===0)return n.value;r<0?n=n.left:r>0&&(n=n.right)}return null}indexOf(t){let n=0,r=this.root;for(;!r.isEmpty();){const i=this.comparator(t,r.key);if(i===0)return n+r.left.size;i<0?r=r.left:(n+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal(((n,r)=>(t(n,r),!1)))}toString(){const t=[];return this.inorderTraversal(((n,r)=>(t.push(`${n}:${r}`),!1))),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new Rv(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new Rv(this.root,t,this.comparator,!1)}getReverseIterator(){return new Rv(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new Rv(this.root,t,this.comparator,!0)}}class Rv{constructor(t,n,r,i){this.isReverse=i,this.nodeStack=[];let a=1;for(;!t.isEmpty();)if(a=n?r(t.key,n):1,n&&i&&(a*=-1),a<0)t=this.isReverse?t.left:t.right;else{if(a===0){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const n={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return n}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class io{constructor(t,n,r,i,a){this.key=t,this.value=n,this.color=r??io.RED,this.left=i??io.EMPTY,this.right=a??io.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,n,r,i,a){return new io(t??this.key,n??this.value,r??this.color,i??this.left,a??this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,n,r){let i=this;const a=r(t,i.key);return i=a<0?i.copy(null,null,null,i.left.insert(t,n,r),null):a===0?i.copy(null,n,null,null,null):i.copy(null,null,null,null,i.right.insert(t,n,r)),i.fixUp()}removeMin(){if(this.left.isEmpty())return io.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,n){let r,i=this;if(n(t,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(t,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),n(t,i.key)===0){if(i.right.isEmpty())return io.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,n))}return i.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const t=this.copy(null,null,io.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,io.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),n=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,n)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw Tn(43730,{key:this.key,value:this.value});if(this.right.isRed())throw Tn(14113,{key:this.key,value:this.value});const t=this.left.check();if(t!==this.right.check())throw Tn(27949);return t+(this.isRed()?0:1)}}io.EMPTY=null,io.RED=!0,io.BLACK=!1;io.EMPTY=new class{constructor(){this.size=0}get key(){throw Tn(57766)}get value(){throw Tn(16141)}get color(){throw Tn(16727)}get left(){throw Tn(29726)}get right(){throw Tn(36894)}copy(t,n,r,i,a){return this}insert(t,n,r){return new io(t,n)}remove(t,n){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class qi{constructor(t){this.comparator=t,this.data=new ds(this.comparator)}has(t){return this.data.get(t)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal(((n,r)=>(t(n),!1)))}forEachInRange(t,n){const r=this.data.getIteratorFrom(t[0]);for(;r.hasNext();){const i=r.getNext();if(this.comparator(i.key,t[1])>=0)return;n(i.key)}}forEachWhile(t,n){let r;for(r=n!==void 0?this.data.getIteratorFrom(n):this.data.getIterator();r.hasNext();)if(!t(r.getNext().key))return}firstAfterOrEqual(t){const n=this.data.getIteratorFrom(t);return n.hasNext()?n.getNext().key:null}getIterator(){return new GR(this.data.getIterator())}getIteratorFrom(t){return new GR(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let n=this;return n.size{n=n.add(r)})),n}isEqual(t){if(!(t instanceof qi)||this.size!==t.size)return!1;const n=this.data.getIterator(),r=t.data.getIterator();for(;n.hasNext();){const i=n.getNext().key,a=r.getNext().key;if(this.comparator(i,a)!==0)return!1}return!0}toArray(){const t=[];return this.forEach((n=>{t.push(n)})),t}toString(){const t=[];return this.forEach((n=>t.push(n))),"SortedSet("+t.toString()+")"}copy(t){const n=new qi(this.comparator);return n.data=t,n}}class GR{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function f0(e){return e.hasNext()?e.getNext():void 0}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class gl{constructor(t){this.fields=t,t.sort(Ls.comparator)}static empty(){return new gl([])}unionWith(t){let n=new qi(Ls.comparator);for(const r of this.fields)n=n.add(r);for(const r of t)n=n.add(r);return new gl(n.toArray())}covers(t){for(const n of this.fields)if(n.isPrefixOf(t))return!0;return!1}isEqual(t){return og(this.fields,t.fields,((n,r)=>n.isEqual(r)))}}/** * @license * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class z$ extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class na{constructor(t){this.binaryString=t}static fromBase64String(t){const n=(function(i){try{return atob(i)}catch(a){throw typeof DOMException<"u"&&a instanceof DOMException?new z$("Invalid base64 string: "+a):a}})(t);return new na(n)}static fromUint8Array(t){const n=(function(i){let a="";for(let o=0;otzu(n,t)))!==void 0}function pf(e,t){if(e===t)return 0;const n=ff(e),r=ff(t);if(n!==r)return Cr(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return Cr(e.booleanValue,t.booleanValue);case 2:return(function(a,o){const c=_s(a.integerValue||a.doubleValue),h=_s(o.integerValue||o.doubleValue);return ch?1:c===h?0:isNaN(c)?isNaN(h)?0:-1:1})(e,t);case 3:return qR(e.timestampValue,t.timestampValue);case 4:return qR(ly(e),ly(t));case 5:return JS(e.stringValue,t.stringValue);case 6:return(function(a,o){const c=Hd(a),h=Hd(o);return c.compareTo(h)})(e.bytesValue,t.bytesValue);case 7:return(function(a,o){const c=a.split("/"),h=o.split("/");for(let f=0;fi+Tw(a)),0)})(e.arrayValue);case 10:case 11:return(function(r){let i=0;return _f(r.fields,((a,o)=>{i+=a.length+Tw(o)})),i})(e.mapValue);default:throw Tn(13486,{value:e})}}function uy(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function oC(e){return!!e&&"integerValue"in e}function dy(e){return!!e&&"arrayValue"in e}function KR(e){return!!e&&"nullValue"in e}function YR(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function Pw(e){return!!e&&"mapValue"in e}function pE(e){var n,r;return((r=(((n=e==null?void 0:e.mapValue)==null?void 0:n.fields)||{})[HI])==null?void 0:r.stringValue)===GI}function M1(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&typeof e.timestampValue=="object")return{timestampValue:{...e.timestampValue}};if(e.mapValue){const t={mapValue:{fields:{}}};return _f(e.mapValue.fields,((n,r)=>t.mapValue.fields[n]=M1(r))),t}if(e.arrayValue){const t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=M1(e.arrayValue.values[n]);return t}return{...e}}function q$(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===G$}const W$={mapValue:{fields:{[HI]:{stringValue:GI},[fg]:{arrayValue:{}}}}};function Vce(e){return"nullValue"in e?Iw:"booleanValue"in e?{booleanValue:!1}:"integerValue"in e||"doubleValue"in e?{doubleValue:NaN}:"timestampValue"in e?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in e?{stringValue:""}:"bytesValue"in e?{bytesValue:""}:"referenceValue"in e?uy(em.empty(),gn.empty()):"geoPointValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in e?{arrayValue:{}}:"mapValue"in e?pE(e)?W$:{mapValue:{}}:Tn(35942,{value:e})}function Fce(e){return"nullValue"in e?{booleanValue:!1}:"booleanValue"in e?{doubleValue:NaN}:"integerValue"in e||"doubleValue"in e?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in e?{stringValue:""}:"stringValue"in e?{bytesValue:""}:"bytesValue"in e?uy(em.empty(),gn.empty()):"referenceValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in e?{arrayValue:{}}:"arrayValue"in e?W$:"mapValue"in e?pE(e)?{mapValue:{}}:Jh:Tn(61959,{value:e})}function XR(e,t){const n=pf(e.value,t.value);return n!==0?n:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function QR(e,t){const n=pf(e.value,t.value);return n!==0?n:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class so{constructor(t){this.value=t}static empty(){return new so({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let n=this.value;for(let r=0;r{if(!n.isImmediateParentOf(c)){const h=this.getFieldsMap(n);this.applyChanges(h,r,i),r={},i=[],n=c.popLast()}o?r[c.lastSegment()]=M1(o):i.push(c.lastSegment())}));const a=this.getFieldsMap(n);this.applyChanges(a,r,i)}delete(t){const n=this.field(t.popLast());Pw(n)&&n.mapValue.fields&&delete n.mapValue.fields[t.lastSegment()]}isEqual(t){return zu(this.value,t.value)}getFieldsMap(t){let n=this.value;n.mapValue.fields||(n.mapValue={fields:{}});for(let r=0;rt[i]=a));for(const i of r)delete t[i]}clone(){return new so(M1(this.value))}}function K$(e){const t=[];return _f(e.fields,((n,r)=>{const i=new Ls([n]);if(Pw(r)){const a=K$(r.mapValue).fields;if(a.length===0)t.push(i);else for(const o of a)t.push(i.child(o))}else t.push(i)})),new gl(t)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Ys{constructor(t,n,r,i,a,o,c){this.key=t,this.documentType=n,this.version=r,this.readTime=i,this.createTime=a,this.data=o,this.documentState=c}static newInvalidDocument(t){return new Ys(t,0,sr.min(),sr.min(),sr.min(),so.empty(),0)}static newFoundDocument(t,n,r,i){return new Ys(t,1,n,sr.min(),r,i,0)}static newNoDocument(t,n){return new Ys(t,2,n,sr.min(),sr.min(),so.empty(),0)}static newUnknownDocument(t,n){return new Ys(t,3,n,sr.min(),sr.min(),so.empty(),2)}convertToFoundDocument(t,n){return!this.createTime.isEqual(sr.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=t),this.version=t,this.documentType=1,this.data=n,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=so.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=so.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=sr.min(),this}setReadTime(t){return this.readTime=t,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(t){return t instanceof Ys&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new Ys(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class mg{constructor(t,n){this.position=t,this.inclusive=n}}function ZR(e,t,n){let r=0;for(let i=0;i":return t>0;case">=":return t>=0;default:return Tn(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class Gi extends Y${constructor(t,n){super(),this.filters=t,this.op=n,this.Pe=null}static create(t,n){return new Gi(t,n)}matches(t){return gg(this)?this.filters.find((n=>!n.matches(t)))===void 0:this.filters.find((n=>n.matches(t)))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce(((t,n)=>t.concat(n.getFlattenedFilters())),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function gg(e){return e.op==="and"}function lC(e){return e.op==="or"}function qI(e){return X$(e)&&gg(e)}function X$(e){for(const t of e.filters)if(t instanceof Gi)return!1;return!0}function cC(e){if(e instanceof oi)return e.field.canonicalString()+e.op.toString()+pg(e.value);if(qI(e))return e.filters.map((t=>cC(t))).join(",");{const t=e.filters.map((n=>cC(n))).join(",");return`${e.op}(${t})`}}function Q$(e,t){return e instanceof oi?(function(r,i){return i instanceof oi&&r.op===i.op&&r.field.isEqual(i.field)&&zu(r.value,i.value)})(e,t):e instanceof Gi?(function(r,i){return i instanceof Gi&&r.op===i.op&&r.filters.length===i.filters.length?r.filters.reduce(((a,o,c)=>a&&Q$(o,i.filters[c])),!0):!1})(e,t):void Tn(19439)}function Z$(e,t){const n=e.filters.concat(t);return Gi.create(n,e.op)}function J$(e){return e instanceof oi?(function(n){return`${n.field.canonicalString()} ${n.op} ${pg(n.value)}`})(e):e instanceof Gi?(function(n){return n.op.toString()+" {"+n.getFilters().map(J$).join(" ,")+"}"})(e):"Filter"}class Hce extends oi{constructor(t,n,r){super(t,n,r),this.key=gn.fromName(r.referenceValue)}matches(t){const n=gn.comparator(t.key,this.key);return this.matchesComparison(n)}}class Gce extends oi{constructor(t,n){super(t,"in",n),this.keys=eH("in",n)}matches(t){return this.keys.some((n=>n.isEqual(t.key)))}}class qce extends oi{constructor(t,n){super(t,"not-in",n),this.keys=eH("not-in",n)}matches(t){return!this.keys.some((n=>n.isEqual(t.key)))}}function eH(e,t){var n;return(((n=t.arrayValue)==null?void 0:n.values)||[]).map((r=>gn.fromName(r.referenceValue)))}class Wce extends oi{constructor(t,n){super(t,"array-contains",n)}matches(t){const n=t.data.field(this.field);return dy(n)&&cy(n.arrayValue,this.value)}}class tH extends oi{constructor(t,n){super(t,"in",n)}matches(t){const n=t.data.field(this.field);return n!==null&&cy(this.value.arrayValue,n)}}class Kce extends oi{constructor(t,n){super(t,"not-in",n)}matches(t){if(cy(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const n=t.data.field(this.field);return n!==null&&n.nullValue===void 0&&!cy(this.value.arrayValue,n)}}class Yce extends oi{constructor(t,n){super(t,"array-contains-any",n)}matches(t){const n=t.data.field(this.field);return!(!dy(n)||!n.arrayValue.values)&&n.arrayValue.values.some((r=>cy(this.value.arrayValue,r)))}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Xce{constructor(t,n=null,r=[],i=[],a=null,o=null,c=null){this.path=t,this.collectionGroup=n,this.orderBy=r,this.filters=i,this.limit=a,this.startAt=o,this.endAt=c,this.Te=null}}function uC(e,t=null,n=[],r=[],i=null,a=null,o=null){return new Xce(e,t,n,r,i,a,o)}function tm(e){const t=Vn(e);if(t.Te===null){let n=t.path.canonicalString();t.collectionGroup!==null&&(n+="|cg:"+t.collectionGroup),n+="|f:",n+=t.filters.map((r=>cC(r))).join(","),n+="|ob:",n+=t.orderBy.map((r=>(function(a){return a.field.canonicalString()+a.dir})(r))).join(","),cE(t.limit)||(n+="|l:",n+=t.limit),t.startAt&&(n+="|lb:",n+=t.startAt.inclusive?"b:":"a:",n+=t.startAt.position.map((r=>pg(r))).join(",")),t.endAt&&(n+="|ub:",n+=t.endAt.inclusive?"a:":"b:",n+=t.endAt.position.map((r=>pg(r))).join(",")),t.Te=n}return t.Te}function Hy(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let n=0;nn instanceof oi&&n.field.isEqual(t)))}function eD(e,t,n){let r=Iw,i=!0;for(const a of g2(e,t)){let o=Iw,c=!0;switch(a.op){case"<":case"<=":o=Vce(a.value);break;case"==":case"in":case">=":o=a.value;break;case">":o=a.value,c=!1;break;case"!=":case"not-in":o=Iw}XR({value:r,inclusive:i},{value:o,inclusive:c})<0&&(r=o,i=c)}if(n!==null){for(let a=0;a=":case">":o=Fce(a.value),c=!1;break;case"==":case"in":case"<=":o=a.value;break;case"<":o=a.value,c=!1;break;case"!=":case"not-in":o=Jh}QR({value:r,inclusive:i},{value:o,inclusive:c})>0&&(r=o,i=c)}if(n!==null){for(let a=0;a0&&(r=o,i=n.inclusive);break}}return{value:r,inclusive:i}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ym{constructor(t,n=null,r=[],i=[],a=null,o="F",c=null,h=null){this.path=t,this.collectionGroup=n,this.explicitOrderBy=r,this.filters=i,this.limit=a,this.limitType=o,this.startAt=c,this.endAt=h,this.Ee=null,this.Ie=null,this.Re=null,this.startAt,this.endAt}}function nH(e,t,n,r,i,a,o,c){return new ym(e,t,n,r,i,a,o,c)}function Gy(e){return new ym(e)}function nD(e){return e.filters.length===0&&e.limit===null&&e.startAt==null&&e.endAt==null&&(e.explicitOrderBy.length===0||e.explicitOrderBy.length===1&&e.explicitOrderBy[0].field.isKeyField())}function Qce(e){return gn.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}function rH(e){return e.collectionGroup!==null}function L1(e){const t=Vn(e);if(t.Ee===null){t.Ee=[];const n=new Set;for(const a of t.explicitOrderBy)t.Ee.push(a),n.add(a.field.canonicalString());const r=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";(function(o){let c=new qi(Ls.comparator);return o.filters.forEach((h=>{h.getFlattenedFilters().forEach((f=>{f.isInequality()&&(c=c.add(f.field))}))})),c})(t).forEach((a=>{n.has(a.canonicalString())||a.isKeyField()||t.Ee.push(new hy(a,r))})),n.has(Ls.keyField().canonicalString())||t.Ee.push(new hy(Ls.keyField(),r))}return t.Ee}function Ul(e){const t=Vn(e);return t.Ie||(t.Ie=iH(t,L1(e))),t.Ie}function Zce(e){const t=Vn(e);return t.Re||(t.Re=iH(t,e.explicitOrderBy)),t.Re}function iH(e,t){if(e.limitType==="F")return uC(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map((i=>{const a=i.dir==="desc"?"asc":"desc";return new hy(i.field,a)}));const n=e.endAt?new mg(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new mg(e.startAt.position,e.startAt.inclusive):null;return uC(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function dC(e,t){const n=e.filters.concat([t]);return new ym(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function Jce(e,t){const n=e.explicitOrderBy.concat([t]);return new ym(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}function x2(e,t,n){return new ym(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function mE(e,t){return Hy(Ul(e),Ul(t))&&e.limitType===t.limitType}function sH(e){return`${tm(Ul(e))}|lt:${e.limitType}`}function I0(e){return`Query(target=${(function(n){let r=n.path.canonicalString();return n.collectionGroup!==null&&(r+=" collectionGroup="+n.collectionGroup),n.filters.length>0&&(r+=`, filters: [${n.filters.map((i=>J$(i))).join(", ")}]`),cE(n.limit)||(r+=", limit: "+n.limit),n.orderBy.length>0&&(r+=`, orderBy: [${n.orderBy.map((i=>(function(o){return`${o.field.canonicalString()} (${o.dir})`})(i))).join(", ")}]`),n.startAt&&(r+=", startAt: ",r+=n.startAt.inclusive?"b:":"a:",r+=n.startAt.position.map((i=>pg(i))).join(",")),n.endAt&&(r+=", endAt: ",r+=n.endAt.inclusive?"a:":"b:",r+=n.endAt.position.map((i=>pg(i))).join(",")),`Target(${r})`})(Ul(e))}; limitType=${e.limitType})`}function qy(e,t){return t.isFoundDocument()&&(function(r,i){const a=i.key.path;return r.collectionGroup!==null?i.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(a):gn.isDocumentKey(r.path)?r.path.isEqual(a):r.path.isImmediateParentOf(a)})(e,t)&&(function(r,i){for(const a of L1(r))if(!a.field.isKeyField()&&i.data.field(a.field)===null)return!1;return!0})(e,t)&&(function(r,i){for(const a of r.filters)if(!a.matches(i))return!1;return!0})(e,t)&&(function(r,i){return!(r.startAt&&!(function(o,c,h){const f=ZR(o,c,h);return o.inclusive?f<=0:f<0})(r.startAt,L1(r),i)||r.endAt&&!(function(o,c,h){const f=ZR(o,c,h);return o.inclusive?f>=0:f>0})(r.endAt,L1(r),i))})(e,t)}function aH(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function oH(e){return(t,n)=>{let r=!1;for(const i of L1(e)){const a=eue(i,t,n);if(a!==0)return a;r=r||i.field.isKeyField()}return 0}}function eue(e,t,n){const r=e.field.isKeyField()?gn.comparator(t.key,n.key):(function(a,o,c){const h=o.data.field(a),f=c.data.field(a);return h!==null&&f!==null?pf(h,f):Tn(42886)})(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return-1*r;default:return Tn(19790,{direction:e.dir})}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Zd{constructor(t,n){this.mapKeyFn=t,this.equalsFn=n,this.inner={},this.innerSize=0}get(t){const n=this.mapKeyFn(t),r=this.inner[n];if(r!==void 0){for(const[i,a]of r)if(this.equalsFn(i,t))return a}}has(t){return this.get(t)!==void 0}set(t,n){const r=this.mapKeyFn(t),i=this.inner[r];if(i===void 0)return this.inner[r]=[[t,n]],void this.innerSize++;for(let a=0;a{for(const[i,a]of r)t(i,a)}))}isEmpty(){return B$(this.inner)}size(){return this.innerSize}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const tue=new ds(gn.comparator);function Dl(){return tue}const lH=new ds(gn.comparator);function b1(...e){let t=lH;for(const n of e)t=t.insert(n.key,n);return t}function cH(e){let t=lH;return e.forEach(((n,r)=>t=t.insert(n,r.overlayedDocument))),t}function ju(){return U1()}function uH(){return U1()}function U1(){return new Zd((e=>e.toString()),((e,t)=>e.isEqual(t)))}const nue=new ds(gn.comparator),rue=new qi(gn.comparator);function Kr(...e){let t=rue;for(const n of e)t=t.add(n);return t}const iue=new qi(Cr);function WI(){return iue}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function KI(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:iy(t)?"-0":t}}function dH(e){return{integerValue:""+e}}function hH(e,t){return C$(t)?dH(t):KI(e,t)}/** * @license * Copyright 2018 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class gE{constructor(){this._=void 0}}function sue(e,t,n){return e instanceof xg?(function(i,a){const o={fields:{[F$]:{stringValue:V$},[H$]:{timestampValue:{seconds:i.seconds,nanos:i.nanoseconds}}}};return a&&$I(a)&&(a=fE(a)),a&&(o.fields[$$]=a),{mapValue:o}})(n,t):e instanceof nm?pH(e,t):e instanceof rm?mH(e,t):(function(i,a){const o=fH(i,a),c=rD(o)+rD(i.Ae);return oC(o)&&oC(i.Ae)?dH(c):KI(i.serializer,c)})(e,t)}function aue(e,t,n){return e instanceof nm?pH(e,t):e instanceof rm?mH(e,t):n}function fH(e,t){return e instanceof yg?(function(r){return oC(r)||(function(a){return!!a&&"doubleValue"in a})(r)})(t)?t:{integerValue:0}:null}class xg extends gE{}class nm extends gE{constructor(t){super(),this.elements=t}}function pH(e,t){const n=gH(t);for(const r of e.elements)n.some((i=>zu(i,r)))||n.push(r);return{arrayValue:{values:n}}}class rm extends gE{constructor(t){super(),this.elements=t}}function mH(e,t){let n=gH(t);for(const r of e.elements)n=n.filter((i=>!zu(i,r)));return{arrayValue:{values:n}}}class yg extends gE{constructor(t,n){super(),this.serializer=t,this.Ae=n}}function rD(e){return _s(e.integerValue||e.doubleValue)}function gH(e){return dy(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Wy{constructor(t,n){this.field=t,this.transform=n}}function oue(e,t){return e.field.isEqual(t.field)&&(function(r,i){return r instanceof nm&&i instanceof nm||r instanceof rm&&i instanceof rm?og(r.elements,i.elements,zu):r instanceof yg&&i instanceof yg?zu(r.Ae,i.Ae):r instanceof xg&&i instanceof xg})(e.transform,t.transform)}class lue{constructor(t,n){this.version=t,this.transformResults=n}}class ko{constructor(t,n){this.updateTime=t,this.exists=n}static none(){return new ko}static exists(t){return new ko(void 0,t)}static updateTime(t){return new ko(t)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}function Ow(e,t){return e.updateTime!==void 0?t.isFoundDocument()&&t.version.isEqual(e.updateTime):e.exists===void 0||e.exists===t.isFoundDocument()}class xE{}function xH(e,t){if(!e.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return e.isNoDocument()?new yE(e.key,ko.none()):new zg(e.key,e.data,ko.none());{const n=e.data,r=so.empty();let i=new qi(Ls.comparator);for(let a of t.fields)if(!i.has(a)){let o=n.field(a);o===null&&a.length>1&&(a=a.popLast(),o=n.field(a)),o===null?r.delete(a):r.set(a,o),i=i.add(a)}return new Jd(e.key,r,new gl(i.toArray()),ko.none())}}function cue(e,t,n){e instanceof zg?(function(i,a,o){const c=i.value.clone(),h=sD(i.fieldTransforms,a,o.transformResults);c.setAll(h),a.convertToFoundDocument(o.version,c).setHasCommittedMutations()})(e,t,n):e instanceof Jd?(function(i,a,o){if(!Ow(i.precondition,a))return void a.convertToUnknownDocument(o.version);const c=sD(i.fieldTransforms,a,o.transformResults),h=a.data;h.setAll(yH(i)),h.setAll(c),a.convertToFoundDocument(o.version,h).setHasCommittedMutations()})(e,t,n):(function(i,a,o){a.convertToNoDocument(o.version).setHasCommittedMutations()})(0,t,n)}function B1(e,t,n,r){return e instanceof zg?(function(a,o,c,h){if(!Ow(a.precondition,o))return c;const f=a.value.clone(),m=aD(a.fieldTransforms,h,o);return f.setAll(m),o.convertToFoundDocument(o.version,f).setHasLocalMutations(),null})(e,t,n,r):e instanceof Jd?(function(a,o,c,h){if(!Ow(a.precondition,o))return c;const f=aD(a.fieldTransforms,h,o),m=o.data;return m.setAll(yH(a)),m.setAll(f),o.convertToFoundDocument(o.version,m).setHasLocalMutations(),c===null?null:c.unionWith(a.fieldMask.fields).unionWith(a.fieldTransforms.map((y=>y.field)))})(e,t,n,r):(function(a,o,c){return Ow(a.precondition,o)?(o.convertToNoDocument(o.version).setHasLocalMutations(),null):c})(e,t,n)}function uue(e,t){let n=null;for(const r of e.fieldTransforms){const i=t.data.field(r.field),a=fH(r.transform,i||null);a!=null&&(n===null&&(n=so.empty()),n.set(r.field,a))}return n||null}function iD(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&!!(function(r,i){return r===void 0&&i===void 0||!(!r||!i)&&og(r,i,((a,o)=>oue(a,o)))})(e.fieldTransforms,t.fieldTransforms)&&(e.type===0?e.value.isEqual(t.value):e.type!==1||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class zg extends xE{constructor(t,n,r,i=[]){super(),this.key=t,this.value=n,this.precondition=r,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}}class Jd extends xE{constructor(t,n,r,i,a=[]){super(),this.key=t,this.data=n,this.fieldMask=r,this.precondition=i,this.fieldTransforms=a,this.type=1}getFieldMask(){return this.fieldMask}}function yH(e){const t=new Map;return e.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){const r=e.data.field(n);t.set(n,r)}})),t}function sD(e,t,n){const r=new Map;Xn(e.length===n.length,32656,{Ve:n.length,de:e.length});for(let i=0;i{const a=t.get(i.key),o=a.overlayedDocument;let c=this.applyToLocalView(o,a.mutatedFields);c=n.has(i.key)?null:c;const h=xH(o,c);h!==null&&r.set(i.key,h),o.isValidDocument()||o.convertToNoDocument(sr.min())})),r}keys(){return this.mutations.reduce(((t,n)=>t.add(n.key)),Kr())}isEqual(t){return this.batchId===t.batchId&&og(this.mutations,t.mutations,((n,r)=>iD(n,r)))&&og(this.baseMutations,t.baseMutations,((n,r)=>iD(n,r)))}}class XI{constructor(t,n,r,i){this.batch=t,this.commitVersion=n,this.mutationResults=r,this.docVersions=i}static from(t,n,r){Xn(t.mutations.length===r.length,58842,{me:t.mutations.length,fe:r.length});let i=(function(){return nue})();const a=t.mutations;for(let o=0;o=8)throw new v1(`Invalid padding: ${n}`);if(r<0)throw new v1(`Invalid hash count: ${r}`);if(t.length>0&&this.hashCount===0)throw new v1(`Invalid hash count: ${r}`);if(t.length===0&&n!==0)throw new v1(`Invalid padding when bitmap length is 0: ${n}`);this.ge=8*t.length-n,this.pe=af.fromNumber(this.ge)}ye(t,n,r){let i=t.add(n.multiply(af.fromNumber(r)));return i.compare(mue)===1&&(i=new af([i.getBits(0),i.getBits(1)],0)),i.modulo(this.pe).toNumber()}we(t){return!!(this.bitmap[Math.floor(t/8)]&1<o.insert(c))),o}insert(t){if(this.ge===0)return;const n=oD(t),[r,i]=lD(n);for(let a=0;a0&&(this.Oe=!0,this.Me=t)}ke(){let t=Kr(),n=Kr(),r=Kr();return this.Fe.forEach(((i,a)=>{switch(a){case 0:t=t.add(i);break;case 2:n=n.add(i);break;case 1:r=r.add(i);break;default:Tn(38017,{changeType:a})}})),new Yy(this.Me,this.xe,t,n,r)}qe(){this.Oe=!1,this.Fe=uD()}Ke(t,n){this.Oe=!0,this.Fe=this.Fe.insert(t,n)}Ue(t){this.Oe=!0,this.Fe=this.Fe.remove(t)}$e(){this.ve+=1}We(){this.ve-=1,Xn(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}}class gue{constructor(t){this.Ge=t,this.ze=new Map,this.je=Dl(),this.Je=Dv(),this.He=Dv(),this.Ze=new ds(Cr)}Xe(t){for(const n of t.be)t.De&&t.De.isFoundDocument()?this.Ye(n,t.De):this.et(n,t.key,t.De);for(const n of t.removedTargetIds)this.et(n,t.key,t.De)}tt(t){this.forEachTarget(t,(n=>{const r=this.nt(n);switch(t.state){case 0:this.rt(n)&&r.Le(t.resumeToken);break;case 1:r.We(),r.Ne||r.qe(),r.Le(t.resumeToken);break;case 2:r.We(),r.Ne||this.removeTarget(n);break;case 3:this.rt(n)&&(r.Qe(),r.Le(t.resumeToken));break;case 4:this.rt(n)&&(this.it(n),r.Le(t.resumeToken));break;default:Tn(56790,{state:t.state})}}))}forEachTarget(t,n){t.targetIds.length>0?t.targetIds.forEach(n):this.ze.forEach(((r,i)=>{this.rt(i)&&n(i)}))}st(t){const n=t.targetId,r=t.Ce.count,i=this.ot(n);if(i){const a=i.target;if(m2(a))if(r===0){const o=new gn(a.path);this.et(n,o,Ys.newNoDocument(o,sr.min()))}else Xn(r===1,20013,{expectedCount:r});else{const o=this._t(n);if(o!==r){const c=this.ut(t),h=c?this.ct(c,t,o):1;if(h!==0){this.it(n);const f=h===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ze=this.Ze.insert(n,f)}}}}}ut(t){const n=t.Ce.unchangedNames;if(!n||!n.bits)return null;const{bits:{bitmap:r="",padding:i=0},hashCount:a=0}=n;let o,c;try{o=Hd(r).toUint8Array()}catch(h){if(h instanceof z$)return ag("Decoding the base64 bloom filter in existence filter failed ("+h.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw h}try{c=new ZI(o,i,a)}catch(h){return ag(h instanceof v1?"BloomFilter error: ":"Applying bloom filter failed: ",h),null}return c.ge===0?null:c}ct(t,n,r){return n.Ce.count===r-this.Pt(t,n.targetId)?0:2}Pt(t,n){const r=this.Ge.getRemoteKeysForTarget(n);let i=0;return r.forEach((a=>{const o=this.Ge.ht(),c=`projects/${o.projectId}/databases/${o.database}/documents/${a.path.canonicalString()}`;t.mightContain(c)||(this.et(n,a,null),i++)})),i}Tt(t){const n=new Map;this.ze.forEach(((a,o)=>{const c=this.ot(o);if(c){if(a.current&&m2(c.target)){const h=new gn(c.target.path);this.Et(h).has(o)||this.It(o,h)||this.et(o,h,Ys.newNoDocument(h,t))}a.Be&&(n.set(o,a.ke()),a.qe())}}));let r=Kr();this.He.forEach(((a,o)=>{let c=!0;o.forEachWhile((h=>{const f=this.ot(h);return!f||f.purpose==="TargetPurposeLimboResolution"||(c=!1,!1)})),c&&(r=r.add(a))})),this.je.forEach(((a,o)=>o.setReadTime(t)));const i=new Ky(t,n,this.Ze,this.je,r);return this.je=Dl(),this.Je=Dv(),this.He=Dv(),this.Ze=new ds(Cr),i}Ye(t,n){if(!this.rt(t))return;const r=this.It(t,n.key)?2:0;this.nt(t).Ke(n.key,r),this.je=this.je.insert(n.key,n),this.Je=this.Je.insert(n.key,this.Et(n.key).add(t)),this.He=this.He.insert(n.key,this.Rt(n.key).add(t))}et(t,n,r){if(!this.rt(t))return;const i=this.nt(t);this.It(t,n)?i.Ke(n,1):i.Ue(n),this.He=this.He.insert(n,this.Rt(n).delete(t)),this.He=this.He.insert(n,this.Rt(n).add(t)),r&&(this.je=this.je.insert(n,r))}removeTarget(t){this.ze.delete(t)}_t(t){const n=this.nt(t).ke();return this.Ge.getRemoteKeysForTarget(t).size+n.addedDocuments.size-n.removedDocuments.size}$e(t){this.nt(t).$e()}nt(t){let n=this.ze.get(t);return n||(n=new cD,this.ze.set(t,n)),n}Rt(t){let n=this.He.get(t);return n||(n=new qi(Cr),this.He=this.He.insert(t,n)),n}Et(t){let n=this.Je.get(t);return n||(n=new qi(Cr),this.Je=this.Je.insert(t,n)),n}rt(t){const n=this.ot(t)!==null;return n||qt("WatchChangeAggregator","Detected inactive target",t),n}ot(t){const n=this.ze.get(t);return n&&n.Ne?null:this.Ge.At(t)}it(t){this.ze.set(t,new cD),this.Ge.getRemoteKeysForTarget(t).forEach((n=>{this.et(t,n,null)}))}It(t,n){return this.Ge.getRemoteKeysForTarget(t).has(n)}}function Dv(){return new ds(gn.comparator)}function uD(){return new ds(gn.comparator)}const xue={asc:"ASCENDING",desc:"DESCENDING"},yue={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},bue={and:"AND",or:"OR"};class vue{constructor(t,n){this.databaseId=t,this.useProto3Json=n}}function hC(e,t){return e.useProto3Json||cE(t)?t:{value:t}}function bg(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function EH(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function wue(e,t){return bg(e,t.toTimestamp())}function Wo(e){return Xn(!!e,49232),sr.fromTimestamp((function(n){const r=$d(n);return new _r(r.seconds,r.nanos)})(e))}function JI(e,t){return fC(e,t).canonicalString()}function fC(e,t){const n=(function(i){return new ki(["projects",i.projectId,"databases",i.database])})(e).child("documents");return t===void 0?n:n.child(t)}function AH(e){const t=ki.fromString(e);return Xn(PH(t),10190,{key:t.toString()}),t}function y2(e,t){return JI(e.databaseId,t.path)}function Lp(e,t){const n=AH(t);if(n.get(1)!==e.databaseId.projectId)throw new sn(vt.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new sn(vt.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new gn(SH(n))}function _H(e,t){return JI(e.databaseId,t)}function kH(e){const t=AH(e);return t.length===4?ki.emptyPath():SH(t)}function pC(e){return new ki(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function SH(e){return Xn(e.length>4&&e.get(4)==="documents",29091,{key:e.toString()}),e.popFirst(5)}function dD(e,t,n){return{name:y2(e,t),fields:n.value.mapValue.fields}}function Nue(e,t,n){const r=Lp(e,t.name),i=Wo(t.updateTime),a=t.createTime?Wo(t.createTime):sr.min(),o=new so({mapValue:{fields:t.fields}}),c=Ys.newFoundDocument(r,i,a,o);return n&&c.setHasCommittedMutations(),n?c.setHasCommittedMutations():c}function Eue(e,t){let n;if("targetChange"in t){t.targetChange;const r=(function(f){return f==="NO_CHANGE"?0:f==="ADD"?1:f==="REMOVE"?2:f==="CURRENT"?3:f==="RESET"?4:Tn(39313,{state:f})})(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],a=(function(f,m){return f.useProto3Json?(Xn(m===void 0||typeof m=="string",58123),na.fromBase64String(m||"")):(Xn(m===void 0||m instanceof Buffer||m instanceof Uint8Array,16193),na.fromUint8Array(m||new Uint8Array))})(e,t.targetChange.resumeToken),o=t.targetChange.cause,c=o&&(function(f){const m=f.code===void 0?vt.UNKNOWN:vH(f.code);return new sn(m,f.message||"")})(o);n=new NH(r,i,a,c||null)}else if("documentChange"in t){t.documentChange;const r=t.documentChange;r.document,r.document.name,r.document.updateTime;const i=Lp(e,r.document.name),a=Wo(r.document.updateTime),o=r.document.createTime?Wo(r.document.createTime):sr.min(),c=new so({mapValue:{fields:r.document.fields}}),h=Ys.newFoundDocument(i,a,o,c),f=r.targetIds||[],m=r.removedTargetIds||[];n=new Rw(f,m,h.key,h)}else if("documentDelete"in t){t.documentDelete;const r=t.documentDelete;r.document;const i=Lp(e,r.document),a=r.readTime?Wo(r.readTime):sr.min(),o=Ys.newNoDocument(i,a),c=r.removedTargetIds||[];n=new Rw([],c,o.key,o)}else if("documentRemove"in t){t.documentRemove;const r=t.documentRemove;r.document;const i=Lp(e,r.document),a=r.removedTargetIds||[];n=new Rw([],a,i,null)}else{if(!("filter"in t))return Tn(11601,{Vt:t});{t.filter;const r=t.filter;r.targetId;const{count:i=0,unchangedNames:a}=r,o=new hue(i,a),c=r.targetId;n=new wH(c,o)}}return n}function b2(e,t){let n;if(t instanceof zg)n={update:dD(e,t.key,t.value)};else if(t instanceof yE)n={delete:y2(e,t.key)};else if(t instanceof Jd)n={update:dD(e,t.key,t.data),updateMask:Iue(t.fieldMask)};else{if(!(t instanceof bH))return Tn(16599,{dt:t.type});n={verify:y2(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map((r=>(function(a,o){const c=o.transform;if(c instanceof xg)return{fieldPath:o.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(c instanceof nm)return{fieldPath:o.field.canonicalString(),appendMissingElements:{values:c.elements}};if(c instanceof rm)return{fieldPath:o.field.canonicalString(),removeAllFromArray:{values:c.elements}};if(c instanceof yg)return{fieldPath:o.field.canonicalString(),increment:c.Ae};throw Tn(20930,{transform:o.transform})})(0,r)))),t.precondition.isNone||(n.currentDocument=(function(i,a){return a.updateTime!==void 0?{updateTime:wue(i,a.updateTime)}:a.exists!==void 0?{exists:a.exists}:Tn(27497)})(e,t.precondition)),n}function mC(e,t){const n=t.currentDocument?(function(a){return a.updateTime!==void 0?ko.updateTime(Wo(a.updateTime)):a.exists!==void 0?ko.exists(a.exists):ko.none()})(t.currentDocument):ko.none(),r=t.updateTransforms?t.updateTransforms.map((i=>(function(o,c){let h=null;if("setToServerValue"in c)Xn(c.setToServerValue==="REQUEST_TIME",16630,{proto:c}),h=new xg;else if("appendMissingElements"in c){const m=c.appendMissingElements.values||[];h=new nm(m)}else if("removeAllFromArray"in c){const m=c.removeAllFromArray.values||[];h=new rm(m)}else"increment"in c?h=new yg(o,c.increment):Tn(16584,{proto:c});const f=Ls.fromServerFormat(c.fieldPath);return new Wy(f,h)})(e,i))):[];if(t.update){t.update.name;const i=Lp(e,t.update.name),a=new so({mapValue:{fields:t.update.fields}});if(t.updateMask){const o=(function(h){const f=h.fieldPaths||[];return new gl(f.map((m=>Ls.fromServerFormat(m))))})(t.updateMask);return new Jd(i,a,o,n,r)}return new zg(i,a,n,r)}if(t.delete){const i=Lp(e,t.delete);return new yE(i,n)}if(t.verify){const i=Lp(e,t.verify);return new bH(i,n)}return Tn(1463,{proto:t})}function Aue(e,t){return e&&e.length>0?(Xn(t!==void 0,14353),e.map((n=>(function(i,a){let o=i.updateTime?Wo(i.updateTime):Wo(a);return o.isEqual(sr.min())&&(o=Wo(a)),new lue(o,i.transformResults||[])})(n,t)))):[]}function CH(e,t){return{documents:[_H(e,t.path)]}}function eT(e,t){const n={structuredQuery:{}},r=t.path;let i;t.collectionGroup!==null?(i=r,n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=r.popLast(),n.structuredQuery.from=[{collectionId:r.lastSegment()}]),n.parent=_H(e,i);const a=(function(f){if(f.length!==0)return TH(Gi.create(f,"and"))})(t.filters);a&&(n.structuredQuery.where=a);const o=(function(f){if(f.length!==0)return f.map((m=>(function(w){return{field:Kh(w.field),direction:Sue(w.dir)}})(m)))})(t.orderBy);o&&(n.structuredQuery.orderBy=o);const c=hC(e,t.limit);return c!==null&&(n.structuredQuery.limit=c),t.startAt&&(n.structuredQuery.startAt=(function(f){return{before:f.inclusive,values:f.position}})(t.startAt)),t.endAt&&(n.structuredQuery.endAt=(function(f){return{before:!f.inclusive,values:f.position}})(t.endAt)),{ft:n,parent:i}}function _ue(e,t,n,r){const{ft:i,parent:a}=eT(e,t),o={},c=[];let h=0;return n.forEach((f=>{const m="aggregate_"+h++;o[m]=f.alias,f.aggregateType==="count"?c.push({alias:m,count:{}}):f.aggregateType==="avg"?c.push({alias:m,avg:{field:Kh(f.fieldPath)}}):f.aggregateType==="sum"&&c.push({alias:m,sum:{field:Kh(f.fieldPath)}})})),{request:{structuredAggregationQuery:{aggregations:c,structuredQuery:i.structuredQuery},parent:i.parent},gt:o,parent:a}}function jH(e){let t=kH(e.parent);const n=e.structuredQuery,r=n.from?n.from.length:0;let i=null;if(r>0){Xn(r===1,65062);const m=n.from[0];m.allDescendants?i=m.collectionId:t=t.child(m.collectionId)}let a=[];n.where&&(a=(function(y){const w=IH(y);return w instanceof Gi&&qI(w)?w.getFilters():[w]})(n.where));let o=[];n.orderBy&&(o=(function(y){return y.map((w=>(function(S){return new hy(T0(S.field),(function(T){switch(T){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(S.direction))})(w)))})(n.orderBy));let c=null;n.limit&&(c=(function(y){let w;return w=typeof y=="object"?y.value:y,cE(w)?null:w})(n.limit));let h=null;n.startAt&&(h=(function(y){const w=!!y.before,A=y.values||[];return new mg(A,w)})(n.startAt));let f=null;return n.endAt&&(f=(function(y){const w=!y.before,A=y.values||[];return new mg(A,w)})(n.endAt)),nH(t,i,o,a,c,"F",h,f)}function kue(e,t){const n=(function(i){switch(i){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return Tn(28987,{purpose:i})}})(t.purpose);return n==null?null:{"goog-listen-tags":n}}function IH(e){return e.unaryFilter!==void 0?(function(n){switch(n.unaryFilter.op){case"IS_NAN":const r=T0(n.unaryFilter.field);return oi.create(r,"==",{doubleValue:NaN});case"IS_NULL":const i=T0(n.unaryFilter.field);return oi.create(i,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const a=T0(n.unaryFilter.field);return oi.create(a,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const o=T0(n.unaryFilter.field);return oi.create(o,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return Tn(61313);default:return Tn(60726)}})(e):e.fieldFilter!==void 0?(function(n){return oi.create(T0(n.fieldFilter.field),(function(i){switch(i){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return Tn(58110);default:return Tn(50506)}})(n.fieldFilter.op),n.fieldFilter.value)})(e):e.compositeFilter!==void 0?(function(n){return Gi.create(n.compositeFilter.filters.map((r=>IH(r))),(function(i){switch(i){case"AND":return"and";case"OR":return"or";default:return Tn(1026)}})(n.compositeFilter.op))})(e):Tn(30097,{filter:e})}function Sue(e){return xue[e]}function Cue(e){return yue[e]}function jue(e){return bue[e]}function Kh(e){return{fieldPath:e.canonicalString()}}function T0(e){return Ls.fromServerFormat(e.fieldPath)}function TH(e){return e instanceof oi?(function(n){if(n.op==="=="){if(YR(n.value))return{unaryFilter:{field:Kh(n.field),op:"IS_NAN"}};if(KR(n.value))return{unaryFilter:{field:Kh(n.field),op:"IS_NULL"}}}else if(n.op==="!="){if(YR(n.value))return{unaryFilter:{field:Kh(n.field),op:"IS_NOT_NAN"}};if(KR(n.value))return{unaryFilter:{field:Kh(n.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Kh(n.field),op:Cue(n.op),value:n.value}}})(e):e instanceof Gi?(function(n){const r=n.getFilters().map((i=>TH(i)));return r.length===1?r[0]:{compositeFilter:{op:jue(n.op),filters:r}}})(e):Tn(54877,{filter:e})}function Iue(e){const t=[];return e.fields.forEach((n=>t.push(n.canonicalString()))),{fieldPaths:t}}function PH(e){return e.length>=4&&e.get(0)==="projects"&&e.get(2)==="databases"}function OH(e){return!!e&&typeof e._toProto=="function"&&e._protoValueType==="ProtoValue"}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Pd{constructor(t,n,r,i,a=sr.min(),o=sr.min(),c=na.EMPTY_BYTE_STRING,h=null){this.target=t,this.targetId=n,this.purpose=r,this.sequenceNumber=i,this.snapshotVersion=a,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=c,this.expectedCount=h}withSequenceNumber(t){return new Pd(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(t,n){return new Pd(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,t,null)}withExpectedCount(t){return new Pd(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,t)}withLastLimboFreeSnapshotVersion(t){return new Pd(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken,this.expectedCount)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class RH{constructor(t){this.yt=t}}function Tue(e,t){let n;if(t.document)n=Nue(e.yt,t.document,!!t.hasCommittedMutations);else if(t.noDocument){const r=gn.fromSegments(t.noDocument.path),i=sm(t.noDocument.readTime);n=Ys.newNoDocument(r,i),t.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!t.unknownDocument)return Tn(56709);{const r=gn.fromSegments(t.unknownDocument.path),i=sm(t.unknownDocument.version);n=Ys.newUnknownDocument(r,i)}}return t.readTime&&n.setReadTime((function(i){const a=new _r(i[0],i[1]);return sr.fromTimestamp(a)})(t.readTime)),n}function hD(e,t){const n=t.key,r={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:v2(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())r.document=(function(a,o){return{name:y2(a,o.key),fields:o.data.value.mapValue.fields,updateTime:bg(a,o.version.toTimestamp()),createTime:bg(a,o.createTime.toTimestamp())}})(e.yt,t);else if(t.isNoDocument())r.noDocument={path:n.path.toArray(),readTime:im(t.version)};else{if(!t.isUnknownDocument())return Tn(57904,{document:t});r.unknownDocument={path:n.path.toArray(),version:im(t.version)}}return r}function v2(e){const t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function im(e){const t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function sm(e){const t=new _r(e.seconds,e.nanoseconds);return sr.fromTimestamp(t)}function xp(e,t){const n=(t.baseMutations||[]).map((a=>mC(e.yt,a)));for(let a=0;amC(e.yt,a))),i=_r.fromMillis(t.localWriteTimeMs);return new YI(t.batchId,i,n,r)}function w1(e){const t=sm(e.readTime),n=e.lastLimboFreeSnapshotVersion!==void 0?sm(e.lastLimboFreeSnapshotVersion):sr.min();let r;return r=(function(a){return a.documents!==void 0})(e.query)?(function(a){const o=a.documents.length;return Xn(o===1,1966,{count:o}),Ul(Gy(kH(a.documents[0])))})(e.query):(function(a){return Ul(jH(a))})(e.query),new Pd(r,e.targetId,"TargetPurposeListen",e.lastListenSequenceNumber,t,n,na.fromBase64String(e.resumeToken))}function DH(e,t){const n=im(t.snapshotVersion),r=im(t.lastLimboFreeSnapshotVersion);let i;i=m2(t.target)?CH(e.yt,t.target):eT(e.yt,t.target).ft;const a=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:tm(t.target),readTime:n,resumeToken:a,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:r,query:i}}function MH(e){const t=jH({parent:e.parent,structuredQuery:e.structuredQuery});return e.limitType==="LAST"?x2(t,t.limit,"L"):t}function l_(e,t){return new QI(t.largestBatchId,mC(e.yt,t.overlayMutation))}function fD(e,t){const n=t.path.lastSegment();return[e,So(t.path.popLast()),n]}function pD(e,t,n,r){return{indexId:e,uid:t,sequenceNumber:n,readTime:im(r.readTime),documentKey:So(r.documentKey.path),largestBatchId:r.largestBatchId}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Pue{getBundleMetadata(t,n){return mD(t).get(n).next((r=>{if(r)return(function(a){return{id:a.bundleId,createTime:sm(a.createTime),version:a.version}})(r)}))}saveBundleMetadata(t,n){return mD(t).put((function(i){return{bundleId:i.id,createTime:im(Wo(i.createTime)),version:i.version}})(n))}getNamedQuery(t,n){return gD(t).get(n).next((r=>{if(r)return(function(a){return{name:a.name,query:MH(a.bundledQuery),readTime:sm(a.readTime)}})(r)}))}saveNamedQuery(t,n){return gD(t).put((function(i){return{name:i.name,readTime:im(Wo(i.readTime)),bundledQuery:i.bundledQuery}})(n))}}function mD(e){return ja(e,uE)}function gD(e){return ja(e,dE)}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class bE{constructor(t,n){this.serializer=t,this.userId=n}static wt(t,n){const r=n.uid||"";return new bE(t,r)}getOverlay(t,n){return $x(t).get(fD(this.userId,n)).next((r=>r?l_(this.serializer,r):null))}getOverlays(t,n){const r=ju();return Xe.forEach(n,(i=>this.getOverlay(t,i).next((a=>{a!==null&&r.set(i,a)})))).next((()=>r))}saveOverlays(t,n,r){const i=[];return r.forEach(((a,o)=>{const c=new QI(n,o);i.push(this.St(t,c))})),Xe.waitFor(i)}removeOverlaysForBatchId(t,n,r){const i=new Set;n.forEach((o=>i.add(So(o.getCollectionPath()))));const a=[];return i.forEach((o=>{const c=IDBKeyRange.bound([this.userId,o,r],[this.userId,o,r+1],!1,!0);a.push($x(t).X(rC,c))})),Xe.waitFor(a)}getOverlaysForCollection(t,n,r){const i=ju(),a=So(n),o=IDBKeyRange.bound([this.userId,a,r],[this.userId,a,Number.POSITIVE_INFINITY],!0);return $x(t).J(rC,o).next((c=>{for(const h of c){const f=l_(this.serializer,h);i.set(f.getKey(),f)}return i}))}getOverlaysForCollectionGroup(t,n,r,i){const a=ju();let o;const c=IDBKeyRange.bound([this.userId,n,r],[this.userId,n,Number.POSITIVE_INFINITY],!0);return $x(t).ee({index:R$,range:c},((h,f,m)=>{const y=l_(this.serializer,f);a.size()a))}St(t,n){return $x(t).put((function(i,a,o){const[c,h,f]=fD(a,o.mutation.key);return{userId:a,collectionPath:h,documentId:f,collectionGroup:o.mutation.key.getCollectionGroup(),largestBatchId:o.largestBatchId,overlayMutation:b2(i.yt,o.mutation)}})(this.serializer,this.userId,n))}}function $x(e){return ja(e,hE)}/** * @license * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Oue{bt(t){return ja(t,VI)}getSessionToken(t){return this.bt(t).get("sessionToken").next((n=>{const r=n==null?void 0:n.value;return r?na.fromUint8Array(r):na.EMPTY_BYTE_STRING}))}setSessionToken(t,n){return this.bt(t).put({name:"sessionToken",value:n.toUint8Array()})}}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class yp{constructor(){}Dt(t,n){this.Ct(t,n),n.vt()}Ct(t,n){if("nullValue"in t)this.Ft(n,5);else if("booleanValue"in t)this.Ft(n,10),n.Mt(t.booleanValue?1:0);else if("integerValue"in t)this.Ft(n,15),n.Mt(_s(t.integerValue));else if("doubleValue"in t){const r=_s(t.doubleValue);isNaN(r)?this.Ft(n,13):(this.Ft(n,15),iy(r)?n.Mt(0):n.Mt(r))}else if("timestampValue"in t){let r=t.timestampValue;this.Ft(n,20),typeof r=="string"&&(r=$d(r)),n.xt(`${r.seconds||""}`),n.Mt(r.nanos||0)}else if("stringValue"in t)this.Ot(t.stringValue,n),this.Nt(n);else if("bytesValue"in t)this.Ft(n,30),n.Bt(Hd(t.bytesValue)),this.Nt(n);else if("referenceValue"in t)this.Lt(t.referenceValue,n);else if("geoPointValue"in t){const r=t.geoPointValue;this.Ft(n,45),n.Mt(r.latitude||0),n.Mt(r.longitude||0)}else"mapValue"in t?q$(t)?this.Ft(n,Number.MAX_SAFE_INTEGER):pE(t)?this.kt(t.mapValue,n):(this.qt(t.mapValue,n),this.Nt(n)):"arrayValue"in t?(this.Kt(t.arrayValue,n),this.Nt(n)):Tn(19022,{Ut:t})}Ot(t,n){this.Ft(n,25),this.$t(t,n)}$t(t,n){n.xt(t)}qt(t,n){const r=t.fields||{};this.Ft(n,55);for(const i of Object.keys(r))this.Ot(i,n),this.Ct(r[i],n)}kt(t,n){var o,c;const r=t.fields||{};this.Ft(n,53);const i=fg,a=((c=(o=r[i].arrayValue)==null?void 0:o.values)==null?void 0:c.length)||0;this.Ft(n,15),n.Mt(_s(a)),this.Ot(i,n),this.Ct(r[i],n)}Kt(t,n){const r=t.values||[];this.Ft(n,50);for(const i of r)this.Ct(i,n)}Lt(t,n){this.Ft(n,37),gn.fromName(t).path.forEach((r=>{this.Ft(n,60),this.$t(r,n)}))}Ft(t,n){t.Mt(n)}Nt(t){t.Mt(2)}}yp.Wt=new yp;/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law | agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES | CONDITIONS OF ANY KIND, either express | implied. * See the License for the specific language governing permissions and * limitations under the License. */const p0=255;function Rue(e){if(e===0)return 8;let t=0;return e>>4||(t+=4,e<<=4),e>>6||(t+=2,e<<=2),e>>7||(t+=1),t}function xD(e){const t=64-(function(r){let i=0;for(let a=0;a<8;++a){const o=Rue(255&r[a]);if(i+=o,o!==8)break}return i})(e);return Math.ceil(t/8)}class Due{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Qt(t){const n=t[Symbol.iterator]();let r=n.next();for(;!r.done;)this.Gt(r.value),r=n.next();this.zt()}jt(t){const n=t[Symbol.iterator]();let r=n.next();for(;!r.done;)this.Jt(r.value),r=n.next();this.Ht()}Zt(t){for(const n of t){const r=n.charCodeAt(0);if(r<128)this.Gt(r);else if(r<2048)this.Gt(960|r>>>6),this.Gt(128|63&r);else if(n<"\uD800"||"\uDBFF">>12),this.Gt(128|63&r>>>6),this.Gt(128|63&r);else{const i=n.codePointAt(0);this.Gt(240|i>>>18),this.Gt(128|63&i>>>12),this.Gt(128|63&i>>>6),this.Gt(128|63&i)}}this.zt()}Xt(t){for(const n of t){const r=n.charCodeAt(0);if(r<128)this.Jt(r);else if(r<2048)this.Jt(960|r>>>6),this.Jt(128|63&r);else if(n<"\uD800"||"\uDBFF">>12),this.Jt(128|63&r>>>6),this.Jt(128|63&r);else{const i=n.codePointAt(0);this.Jt(240|i>>>18),this.Jt(128|63&i>>>12),this.Jt(128|63&i>>>6),this.Jt(128|63&i)}}this.Ht()}Yt(t){const n=this.en(t),r=xD(n);this.tn(1+r),this.buffer[this.position++]=255&r;for(let i=n.length-r;iLs.comparator(n.field,r.field))),this.collectionId=t.collectionGroup!=null?t.collectionGroup:t.path.lastSegment(),this.dn=t.orderBy,this.mn=[];for(const n of t.filters){const r=n;r.isInequality()?this.Vn=this.Vn.add(r):this.mn.push(r)}}get fn(){return this.Vn.size>1}gn(t){if(Xn(t.collectionGroup===this.collectionId,49279),this.fn)return!1;const n=eC(t);if(n!==void 0&&!this.pn(n))return!1;const r=cp(t);let i=new Set,a=0,o=0;for(;a0){const c=this.Vn.getIterator().getNext();if(!i.has(c.field.canonicalString())){const h=r[a];if(!this.yn(c,h)||!this.wn(this.dn[o++],h))return!1}++a}for(;a=this.dn.length||!this.wn(this.dn[o++],c))return!1}return!0}Sn(){if(this.fn)return null;let t=new qi(Ls.comparator);const n=[];for(const r of this.mn)if(!r.field.isKeyField())if(r.op==="array-contains"||r.op==="array-contains-any")n.push(new Sw(r.field,2));else{if(t.has(r.field))continue;t=t.add(r.field),n.push(new Sw(r.field,0))}for(const r of this.dn)r.field.isKeyField()||t.has(r.field)||(t=t.add(r.field),n.push(new Sw(r.field,r.dir==="asc"?0:1)));return new d2(d2.UNKNOWN_ID,this.collectionId,n,ry.empty())}pn(t){for(const n of this.mn)if(this.yn(n,t))return!0;return!1}yn(t,n){if(t===void 0||!t.field.isEqual(n.fieldPath))return!1;const r=t.op==="array-contains"||t.op==="array-contains-any";return n.kind===2===r}wn(t,n){return!!t.field.isEqual(n.fieldPath)&&(n.kind===0&&t.dir==="asc"||n.kind===1&&t.dir==="desc")}}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function LH(e){var n,r;if(Xn(e instanceof oi||e instanceof Gi,20012),e instanceof oi){if(e instanceof tH){const i=((r=(n=e.value.arrayValue)==null?void 0:n.values)==null?void 0:r.map((a=>oi.create(e.field,"==",a))))||[];return Gi.create(i,"or")}return e}const t=e.filters.map((i=>LH(i)));return Gi.create(t,e.op)}function Uue(e){if(e.getFilters().length===0)return[];const t=yC(LH(e));return Xn(UH(t),7391),gC(t)||xC(t)?[t]:t.getFilters()}function gC(e){return e instanceof oi}function xC(e){return e instanceof Gi&&qI(e)}function UH(e){return gC(e)||xC(e)||(function(n){if(n instanceof Gi&&lC(n)){for(const r of n.getFilters())if(!gC(r)&&!xC(r))return!1;return!0}return!1})(e)}function yC(e){if(Xn(e instanceof oi||e instanceof Gi,34018),e instanceof oi)return e;if(e.filters.length===1)return yC(e.filters[0]);const t=e.filters.map((r=>yC(r)));let n=Gi.create(t,e.op);return n=w2(n),UH(n)?n:(Xn(n instanceof Gi,64498),Xn(gg(n),40251),Xn(n.filters.length>1,57927),n.filters.reduce(((r,i)=>tT(r,i))))}function tT(e,t){let n;return Xn(e instanceof oi||e instanceof Gi,38388),Xn(t instanceof oi||t instanceof Gi,25473),n=e instanceof oi?t instanceof oi?(function(i,a){return Gi.create([i,a],"and")})(e,t):wD(e,t):t instanceof oi?wD(t,e):(function(i,a){if(Xn(i.filters.length>0&&a.filters.length>0,48005),gg(i)&&gg(a))return Z$(i,a.getFilters());const o=lC(i)?i:a,c=lC(i)?a:i,h=o.filters.map((f=>tT(f,c)));return Gi.create(h,"or")})(e,t),w2(n)}function wD(e,t){if(gg(t))return Z$(t,e.getFilters());{const n=t.filters.map((r=>tT(e,r)));return Gi.create(n,"or")}}function w2(e){if(Xn(e instanceof oi||e instanceof Gi,11850),e instanceof oi)return e;const t=e.getFilters();if(t.length===1)return w2(t[0]);if(X$(e))return e;const n=t.map((i=>w2(i))),r=[];return n.forEach((i=>{i instanceof oi?r.push(i):i instanceof Gi&&(i.op===e.op?r.push(...i.filters):r.push(i))})),r.length===1?r[0]:Gi.create(r,e.op)}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Bue{constructor(){this.bn=new nT}addToCollectionParentIndex(t,n){return this.bn.add(n),Xe.resolve()}getCollectionParents(t,n){return Xe.resolve(this.bn.getEntries(n))}addFieldIndex(t,n){return Xe.resolve()}deleteFieldIndex(t,n){return Xe.resolve()}deleteAllFieldIndexes(t){return Xe.resolve()}createTargetIndexes(t,n){return Xe.resolve()}getDocumentsMatchingTarget(t,n){return Xe.resolve(null)}getIndexType(t,n){return Xe.resolve(0)}getFieldIndexes(t,n){return Xe.resolve([])}getNextCollectionGroupToUpdate(t){return Xe.resolve(null)}getMinOffset(t,n){return Xe.resolve(Vl.min())}getMinOffsetFromCollectionGroup(t,n){return Xe.resolve(Vl.min())}updateCollectionGroup(t,n,r){return Xe.resolve()}updateIndexEntries(t,n){return Xe.resolve()}}class nT{constructor(){this.index={}}add(t){const n=t.lastSegment(),r=t.popLast(),i=this.index[n]||new qi(ki.comparator),a=!i.has(r);return this.index[n]=i.add(r),a}has(t){const n=t.lastSegment(),r=t.popLast(),i=this.index[n];return i&&i.has(r)}getEntries(t){return(this.index[t]||new qi(ki.comparator)).toArray()}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const ND="IndexedDbIndexManager",Mv=new Uint8Array(0);class zue{constructor(t,n){this.databaseId=n,this.Dn=new nT,this.Cn=new Zd((r=>tm(r)),((r,i)=>Hy(r,i))),this.uid=t.uid||""}addToCollectionParentIndex(t,n){if(!this.Dn.has(n)){const r=n.lastSegment(),i=n.popLast();t.addOnCommittedListener((()=>{this.Dn.add(n)}));const a={collectionId:r,parent:So(i)};return ED(t).put(a)}return Xe.resolve()}getCollectionParents(t,n){const r=[],i=IDBKeyRange.bound([n,""],[w$(n),""],!1,!0);return ED(t).J(i).next((a=>{for(const o of a){if(o.collectionId!==n)break;r.push(Cu(o.parent))}return r}))}addFieldIndex(t,n){const r=Gx(t),i=(function(c){return{indexId:c.indexId,collectionGroup:c.collectionGroup,fields:c.fields.map((h=>[h.fieldPath.canonicalString(),h.kind]))}})(n);delete i.indexId;const a=r.add(i);if(n.indexState){const o=g0(t);return a.next((c=>{o.put(pD(c,this.uid,n.indexState.sequenceNumber,n.indexState.offset))}))}return a.next()}deleteFieldIndex(t,n){const r=Gx(t),i=g0(t),a=m0(t);return r.delete(n.indexId).next((()=>i.delete(IDBKeyRange.bound([n.indexId],[n.indexId+1],!1,!0)))).next((()=>a.delete(IDBKeyRange.bound([n.indexId],[n.indexId+1],!1,!0))))}deleteAllFieldIndexes(t){const n=Gx(t),r=m0(t),i=g0(t);return n.X().next((()=>r.X())).next((()=>i.X()))}createTargetIndexes(t,n){return Xe.forEach(this.vn(n),(r=>this.getIndexType(t,r).next((i=>{if(i===0||i===1){const a=new vD(r).Sn();if(a!=null)return this.addFieldIndex(t,a)}}))))}getDocumentsMatchingTarget(t,n){const r=m0(t);let i=!0;const a=new Map;return Xe.forEach(this.vn(n),(o=>this.Fn(t,o).next((c=>{i&&(i=!!c),a.set(o,c)})))).next((()=>{if(i){let o=Kr();const c=[];return Xe.forEach(a,((h,f)=>{qt(ND,`Using index ${(function(L){return`id=${L.indexId}|cg=${L.collectionGroup}|f=${L.fields.map((K=>`${K.fieldPath}:${K.kind}`)).join(",")}`})(h)} to execute ${tm(n)}`);const m=(function(L,K){const Z=eC(K);if(Z===void 0)return null;for(const q of g2(L,Z.fieldPath))switch(q.op){case"array-contains-any":return q.value.arrayValue.values||[];case"array-contains":return[q.value]}return null})(f,h),y=(function(L,K){const Z=new Map;for(const q of cp(K))for(const B of g2(L,q.fieldPath))switch(B.op){case"==":case"in":Z.set(q.fieldPath.canonicalString(),B.value);break;case"not-in":case"!=":return Z.set(q.fieldPath.canonicalString(),B.value),Array.from(Z.values())}return null})(f,h),w=(function(L,K){const Z=[];let q=!0;for(const B of cp(K)){const z=B.kind===0?eD(L,B.fieldPath,L.startAt):tD(L,B.fieldPath,L.startAt);Z.push(z.value),q&&(q=z.inclusive)}return new mg(Z,q)})(f,h),A=(function(L,K){const Z=[];let q=!0;for(const B of cp(K)){const z=B.kind===0?tD(L,B.fieldPath,L.endAt):eD(L,B.fieldPath,L.endAt);Z.push(z.value),q&&(q=z.inclusive)}return new mg(Z,q)})(f,h),S=this.Mn(h,f,w),C=this.Mn(h,f,A),T=this.xn(h,f,y),D=this.On(h.indexId,m,S,w.inclusive,C,A.inclusive,T);return Xe.forEach(D,(V=>r.Z(V,n.limit).next((L=>{L.forEach((K=>{const Z=gn.fromSegments(K.documentKey);o.has(Z)||(o=o.add(Z),c.push(Z))}))}))))})).next((()=>c))}return Xe.resolve(null)}))}vn(t){let n=this.Cn.get(t);return n||(t.filters.length===0?n=[t]:n=Uue(Gi.create(t.filters,"and")).map((r=>uC(t.path,t.collectionGroup,t.orderBy,r.getFilters(),t.limit,t.startAt,t.endAt))),this.Cn.set(t,n),n)}On(t,n,r,i,a,o,c){const h=(n!=null?n.length:1)*Math.max(r.length,a.length),f=h/(n!=null?n.length:1),m=[];for(let y=0;ythis.Bn(t,w,T,!0)));m.push(...this.createRange(A,S,C))}return m}Bn(t,n,r,i){const a=new bp(t,gn.empty(),n,r);return i?a:a.In()}Ln(t,n,r,i){const a=new bp(t,gn.empty(),n,r);return i?a.In():a}Fn(t,n){const r=new vD(n),i=n.collectionGroup!=null?n.collectionGroup:n.path.lastSegment();return this.getFieldIndexes(t,i).next((a=>{let o=null;for(const c of a)r.gn(c)&&(!o||c.fields.length>o.fields.length)&&(o=c);return o}))}getIndexType(t,n){let r=2;const i=this.vn(n);return Xe.forEach(i,(a=>this.Fn(t,a).next((o=>{o?r!==0&&o.fields.length<(function(h){let f=new qi(Ls.comparator),m=!1;for(const y of h.filters)for(const w of y.getFlattenedFilters())w.field.isKeyField()||(w.op==="array-contains"||w.op==="array-contains-any"?m=!0:f=f.add(w.field));for(const y of h.orderBy)y.field.isKeyField()||(f=f.add(y.field));return f.size+(m?1:0)})(a)&&(r=1):r=0})))).next((()=>(function(o){return o.limit!==null})(n)&&i.length>1&&r===2?1:r))}kn(t,n){const r=new Hx;for(const i of cp(t)){const a=n.data.field(i.fieldPath);if(a==null)return null;const o=r.ln(i.kind);yp.Wt.Dt(a,o)}return r.un()}Nn(t){const n=new Hx;return yp.Wt.Dt(t,n.ln(0)),n.un()}qn(t,n){const r=new Hx;return yp.Wt.Dt(uy(this.databaseId,n),r.ln((function(a){const o=cp(a);return o.length===0?0:o[o.length-1].kind})(t))),r.un()}xn(t,n,r){if(r===null)return[];let i=[];i.push(new Hx);let a=0;for(const o of cp(t)){const c=r[a++];for(const h of i)if(this.Kn(n,o.fieldPath)&&dy(c))i=this.Un(i,o,c);else{const f=h.ln(o.kind);yp.Wt.Dt(c,f)}}return this.$n(i)}Mn(t,n,r){return this.xn(t,n,r.position)}$n(t){const n=[];for(let r=0;rr instanceof oi&&r.field.isEqual(n)&&(r.op==="in"||r.op==="not-in")))}getFieldIndexes(t,n){const r=Gx(t),i=g0(t);return(n?r.J(nC,IDBKeyRange.bound(n,n)):r.J()).next((a=>{const o=[];return Xe.forEach(a,(c=>i.get([c.indexId,this.uid]).next((h=>{o.push((function(m,y){const w=y?new ry(y.sequenceNumber,new Vl(sm(y.readTime),new gn(Cu(y.documentKey)),y.largestBatchId)):ry.empty(),A=m.fields.map((([S,C])=>new Sw(Ls.fromServerFormat(S),C)));return new d2(m.indexId,m.collectionGroup,A,w)})(c,h))})))).next((()=>o))}))}getNextCollectionGroupToUpdate(t){return this.getFieldIndexes(t).next((n=>n.length===0?null:(n.sort(((r,i)=>{const a=r.indexState.sequenceNumber-i.indexState.sequenceNumber;return a!==0?a:Cr(r.collectionGroup,i.collectionGroup)})),n[0].collectionGroup)))}updateCollectionGroup(t,n,r){const i=Gx(t),a=g0(t);return this.Wn(t).next((o=>i.J(nC,IDBKeyRange.bound(n,n)).next((c=>Xe.forEach(c,(h=>a.put(pD(h.indexId,this.uid,o,r))))))))}updateIndexEntries(t,n){const r=new Map;return Xe.forEach(n,((i,a)=>{const o=r.get(i.collectionGroup);return(o?Xe.resolve(o):this.getFieldIndexes(t,i.collectionGroup)).next((c=>(r.set(i.collectionGroup,c),Xe.forEach(c,(h=>this.Qn(t,i,h).next((f=>{const m=this.Gn(a,h);return f.isEqual(m)?Xe.resolve():this.zn(t,a,h,f,m)})))))))}))}jn(t,n,r,i){return m0(t).put(i.Rn(this.uid,this.qn(r,n.key),n.key))}Jn(t,n,r,i){return m0(t).delete(i.An(this.uid,this.qn(r,n.key),n.key))}Qn(t,n,r){const i=m0(t);let a=new qi(Ph);return i.ee({index:O$,range:IDBKeyRange.only([r.indexId,this.uid,Dw(this.qn(r,n))])},((o,c)=>{a=a.add(new bp(r.indexId,n,bD(c.arrayValue),bD(c.directionalValue)))})).next((()=>a))}Gn(t,n){let r=new qi(Ph);const i=this.kn(n,t);if(i==null)return r;const a=eC(n);if(a!=null){const o=t.data.field(a.fieldPath);if(dy(o))for(const c of o.arrayValue.values||[])r=r.add(new bp(n.indexId,t.key,this.Nn(c),i))}else r=r.add(new bp(n.indexId,t.key,Mv,i));return r}zn(t,n,r,i,a){qt(ND,"Updating index entries for document '%s'",n.key);const o=[];return(function(h,f,m,y,w){const A=h.getIterator(),S=f.getIterator();let C=f0(A),T=f0(S);for(;C||T;){let D=!1,V=!1;if(C&&T){const L=m(C,T);L<0?V=!0:L>0&&(D=!0)}else C!=null?V=!0:D=!0;D?(y(T),T=f0(S)):V?(w(C),C=f0(A)):(C=f0(A),T=f0(S))}})(i,a,Ph,(c=>{o.push(this.jn(t,n,r,c))}),(c=>{o.push(this.Jn(t,n,r,c))})),Xe.waitFor(o)}Wn(t){let n=1;return g0(t).ee({index:P$,reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},((r,i,a)=>{a.done(),n=i.sequenceNumber+1})).next((()=>n))}createRange(t,n,r){r=r.sort(((o,c)=>Ph(o,c))).filter(((o,c,h)=>!c||Ph(o,h[c-1])!==0));const i=[];i.push(t);for(const o of r){const c=Ph(o,t),h=Ph(o,n);if(c===0)i[0]=t.In();else if(c>0&&h<0)i.push(o),i.push(o.In());else if(h>0)break}i.push(n);const a=[];for(let o=0;o0}getMinOffsetFromCollectionGroup(t,n){return this.getFieldIndexes(t,n).next(AD)}getMinOffset(t,n){return Xe.mapArray(this.vn(n),(r=>this.Fn(t,r).next((i=>i||Tn(44426))))).next(AD)}}function ED(e){return ja(e,oy)}function m0(e){return ja(e,D1)}function Gx(e){return ja(e,zI)}function g0(e){return ja(e,R1)}function AD(e){Xn(e.length!==0,28825);let t=e[0].indexState.offset,n=t.largestBatchId;for(let r=1;r(c++,w.delete())));a.push(h.next((()=>{Xn(c===1,47070,{batchId:n.batchId})})));const f=[];for(const m of n.mutations){const y=j$(t,m.key.path,n.batchId);a.push(i.delete(y)),f.push(m.key)}return Xe.waitFor(a).next((()=>f))}function N2(e){if(!e)return 0;let t;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw Tn(14731);t=e.noDocument}return JSON.stringify(t).length}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */No.DEFAULT_COLLECTION_PERCENTILE=10,No.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,No.DEFAULT=new No(BH,No.DEFAULT_COLLECTION_PERCENTILE,No.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),No.DISABLED=new No(-1,0,0);class vE{constructor(t,n,r,i){this.userId=t,this.serializer=n,this.indexManager=r,this.referenceDelegate=i,this.Zn={}}static wt(t,n,r,i){Xn(t.uid!=="",64387);const a=t.isAuthenticated()?t.uid:"";return new vE(a,n,r,i)}checkEmpty(t){let n=!0;const r=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return Oh(t).ee({index:Ap,range:r},((i,a,o)=>{n=!1,o.done()})).next((()=>n))}addMutationBatch(t,n,r,i){const a=P0(t),o=Oh(t);return o.add({}).next((c=>{Xn(typeof c=="number",49019);const h=new YI(c,n,r,i),f=(function(A,S,C){const T=C.baseMutations.map((V=>b2(A.yt,V))),D=C.mutations.map((V=>b2(A.yt,V)));return{userId:S,batchId:C.batchId,localWriteTimeMs:C.localWriteTime.toMillis(),baseMutations:T,mutations:D}})(this.serializer,this.userId,h),m=[];let y=new qi(((w,A)=>Cr(w.canonicalString(),A.canonicalString())));for(const w of i){const A=j$(this.userId,w.key.path,c);y=y.add(w.key.path.popLast()),m.push(o.put(f)),m.push(a.put(A,fce))}return y.forEach((w=>{m.push(this.indexManager.addToCollectionParentIndex(t,w))})),t.addOnCommittedListener((()=>{this.Zn[c]=h.keys()})),Xe.waitFor(m).next((()=>h))}))}lookupMutationBatch(t,n){return Oh(t).get(n).next((r=>r?(Xn(r.userId===this.userId,48,"Unexpected user for mutation batch",{userId:r.userId,batchId:n}),xp(this.serializer,r)):null))}Xn(t,n){return this.Zn[n]?Xe.resolve(this.Zn[n]):this.lookupMutationBatch(t,n).next((r=>{if(r){const i=r.keys();return this.Zn[n]=i,i}return null}))}getNextMutationBatchAfterBatchId(t,n){const r=n+1,i=IDBKeyRange.lowerBound([this.userId,r]);let a=null;return Oh(t).ee({index:Ap,range:i},((o,c,h)=>{c.userId===this.userId&&(Xn(c.batchId>=r,47524,{Yn:r}),a=xp(this.serializer,c)),h.done()})).next((()=>a))}getHighestUnacknowledgedBatchId(t){const n=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let r=Dp;return Oh(t).ee({index:Ap,range:n,reverse:!0},((i,a,o)=>{r=a.batchId,o.done()})).next((()=>r))}getAllMutationBatches(t){const n=IDBKeyRange.bound([this.userId,Dp],[this.userId,Number.POSITIVE_INFINITY]);return Oh(t).J(Ap,n).next((r=>r.map((i=>xp(this.serializer,i)))))}getAllMutationBatchesAffectingDocumentKey(t,n){const r=Cw(this.userId,n.path),i=IDBKeyRange.lowerBound(r),a=[];return P0(t).ee({range:i},((o,c,h)=>{const[f,m,y]=o,w=Cu(m);if(f===this.userId&&n.path.isEqual(w))return Oh(t).get(y).next((A=>{if(!A)throw Tn(61480,{er:o,batchId:y});Xn(A.userId===this.userId,10503,"Unexpected user for mutation batch",{userId:A.userId,batchId:y}),a.push(xp(this.serializer,A))}));h.done()})).next((()=>a))}getAllMutationBatchesAffectingDocumentKeys(t,n){let r=new qi(Cr);const i=[];return n.forEach((a=>{const o=Cw(this.userId,a.path),c=IDBKeyRange.lowerBound(o),h=P0(t).ee({range:c},((f,m,y)=>{const[w,A,S]=f,C=Cu(A);w===this.userId&&a.path.isEqual(C)?r=r.add(S):y.done()}));i.push(h)})),Xe.waitFor(i).next((()=>this.tr(t,r)))}getAllMutationBatchesAffectingQuery(t,n){const r=n.path,i=r.length+1,a=Cw(this.userId,r),o=IDBKeyRange.lowerBound(a);let c=new qi(Cr);return P0(t).ee({range:o},((h,f,m)=>{const[y,w,A]=h,S=Cu(w);y===this.userId&&r.isPrefixOf(S)?S.length===i&&(c=c.add(A)):m.done()})).next((()=>this.tr(t,c)))}tr(t,n){const r=[],i=[];return n.forEach((a=>{i.push(Oh(t).get(a).next((o=>{if(o===null)throw Tn(35274,{batchId:a});Xn(o.userId===this.userId,9748,"Unexpected user for mutation batch",{userId:o.userId,batchId:a}),r.push(xp(this.serializer,o))})))})),Xe.waitFor(i).next((()=>r))}removeMutationBatch(t,n){return zH(t.le,this.userId,n).next((r=>(t.addOnCommittedListener((()=>{this.nr(n.batchId)})),Xe.forEach(r,(i=>this.referenceDelegate.markPotentiallyOrphaned(t,i))))))}nr(t){delete this.Zn[t]}performConsistencyCheck(t){return this.checkEmpty(t).next((n=>{if(!n)return Xe.resolve();const r=IDBKeyRange.lowerBound((function(o){return[o]})(this.userId)),i=[];return P0(t).ee({range:r},((a,o,c)=>{if(a[0]===this.userId){const h=Cu(a[1]);i.push(h)}else c.done()})).next((()=>{Xn(i.length===0,56720,{rr:i.map((a=>a.canonicalString()))})}))}))}containsKey(t,n){return VH(t,this.userId,n)}ir(t){return FH(t).get(this.userId).next((n=>n||{userId:this.userId,lastAcknowledgedBatchId:Dp,lastStreamToken:""}))}}function VH(e,t,n){const r=Cw(t,n.path),i=r[1],a=IDBKeyRange.lowerBound(r);let o=!1;return P0(e).ee({range:a,Y:!0},((c,h,f)=>{const[m,y,w]=c;m===t&&y===i&&(o=!0),f.done()})).next((()=>o))}function Oh(e){return ja(e,Uc)}function P0(e){return ja(e,cg)}function FH(e){return ja(e,sy)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class am{constructor(t){this.sr=t}next(){return this.sr+=2,this.sr}static _r(){return new am(0)}static ar(){return new am(-1)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Vue{constructor(t,n){this.referenceDelegate=t,this.serializer=n}allocateTargetId(t){return this.ur(t).next((n=>{const r=new am(n.highestTargetId);return n.highestTargetId=r.next(),this.cr(t,n).next((()=>n.highestTargetId))}))}getLastRemoteSnapshotVersion(t){return this.ur(t).next((n=>sr.fromTimestamp(new _r(n.lastRemoteSnapshotVersion.seconds,n.lastRemoteSnapshotVersion.nanoseconds))))}getHighestSequenceNumber(t){return this.ur(t).next((n=>n.highestListenSequenceNumber))}setTargetsMetadata(t,n,r){return this.ur(t).next((i=>(i.highestListenSequenceNumber=n,r&&(i.lastRemoteSnapshotVersion=r.toTimestamp()),n>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=n),this.cr(t,i))))}addTargetData(t,n){return this.lr(t,n).next((()=>this.ur(t).next((r=>(r.targetCount+=1,this.hr(n,r),this.cr(t,r))))))}updateTargetData(t,n){return this.lr(t,n)}removeTargetData(t,n){return this.removeMatchingKeysForTargetId(t,n.targetId).next((()=>x0(t).delete(n.targetId))).next((()=>this.ur(t))).next((r=>(Xn(r.targetCount>0,8065),r.targetCount-=1,this.cr(t,r))))}removeTargets(t,n,r){let i=0;const a=[];return x0(t).ee(((o,c)=>{const h=w1(c);h.sequenceNumber<=n&&r.get(h.targetId)===null&&(i++,a.push(this.removeTargetData(t,h)))})).next((()=>Xe.waitFor(a))).next((()=>i))}forEachTarget(t,n){return x0(t).ee(((r,i)=>{const a=w1(i);n(a)}))}ur(t){return kD(t).get(p2).next((n=>(Xn(n!==null,2888),n)))}cr(t,n){return kD(t).put(p2,n)}lr(t,n){return x0(t).put(DH(this.serializer,n))}hr(t,n){let r=!1;return t.targetId>n.highestTargetId&&(n.highestTargetId=t.targetId,r=!0),t.sequenceNumber>n.highestListenSequenceNumber&&(n.highestListenSequenceNumber=t.sequenceNumber,r=!0),r}getTargetCount(t){return this.ur(t).next((n=>n.targetCount))}getTargetData(t,n){const r=tm(n),i=IDBKeyRange.bound([r,Number.NEGATIVE_INFINITY],[r,Number.POSITIVE_INFINITY]);let a=null;return x0(t).ee({range:i,index:T$},((o,c,h)=>{const f=w1(c);Hy(n,f.target)&&(a=f,h.done())})).next((()=>a))}addMatchingKeys(t,n,r){const i=[],a=Yh(t);return n.forEach((o=>{const c=So(o.path);i.push(a.put({targetId:r,path:c})),i.push(this.referenceDelegate.addReference(t,r,o))})),Xe.waitFor(i)}removeMatchingKeys(t,n,r){const i=Yh(t);return Xe.forEach(n,(a=>{const o=So(a.path);return Xe.waitFor([i.delete([r,o]),this.referenceDelegate.removeReference(t,r,a)])}))}removeMatchingKeysForTargetId(t,n){const r=Yh(t),i=IDBKeyRange.bound([n],[n+1],!1,!0);return r.delete(i)}getMatchingKeysForTargetId(t,n){const r=IDBKeyRange.bound([n],[n+1],!1,!0),i=Yh(t);let a=Kr();return i.ee({range:r,Y:!0},((o,c,h)=>{const f=Cu(o[1]),m=new gn(f);a=a.add(m)})).next((()=>a))}containsKey(t,n){const r=So(n.path),i=IDBKeyRange.bound([r],[w$(r)],!1,!0);let a=0;return Yh(t).ee({index:BI,Y:!0,range:i},(([o,c],h,f)=>{o!==0&&(a++,f.done())})).next((()=>a>0))}At(t,n){return x0(t).get(n).next((r=>r?w1(r):null))}}function x0(e){return ja(e,ug)}function kD(e){return ja(e,Mp)}function Yh(e){return ja(e,dg)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const SD="LruGarbageCollector",$H=1048576;function CD([e,t],[n,r]){const i=Cr(e,n);return i===0?Cr(t,r):i}class Fue{constructor(t){this.Pr=t,this.buffer=new qi(CD),this.Tr=0}Er(){return++this.Tr}Ir(t){const n=[t,this.Er()];if(this.buffer.size{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(n){Af(n)?qt(SD,"Ignoring IndexedDB error during garbage collection: ",n):await Ef(n)}await this.Ar(3e5)}))}}class $ue{constructor(t,n){this.Vr=t,this.params=n}calculateTargetCount(t,n){return this.Vr.dr(t).next((r=>Math.floor(n/100*r)))}nthSequenceNumber(t,n){if(n===0)return Xe.resolve(ml.ce);const r=new Fue(n);return this.Vr.forEachTarget(t,(i=>r.Ir(i.sequenceNumber))).next((()=>this.Vr.mr(t,(i=>r.Ir(i))))).next((()=>r.maxValue))}removeTargets(t,n,r){return this.Vr.removeTargets(t,n,r)}removeOrphanedDocuments(t,n){return this.Vr.removeOrphanedDocuments(t,n)}collect(t,n){return this.params.cacheSizeCollectionThreshold===-1?(qt("LruGarbageCollector","Garbage collection skipped; disabled"),Xe.resolve(_D)):this.getCacheSize(t).next((r=>r(y>this.params.maximumSequenceNumbersToCollect?(qt("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${y}`),i=this.params.maximumSequenceNumbersToCollect):i=y,o=Date.now(),this.nthSequenceNumber(t,i)))).next((y=>(r=y,c=Date.now(),this.removeTargets(t,r,n)))).next((y=>(a=y,h=Date.now(),this.removeOrphanedDocuments(t,r)))).next((y=>(f=Date.now(),j0()<=ai.DEBUG&&qt("LruGarbageCollector",`LRU Garbage Collection Counted targets in ${o-m}ms Determined least recently used ${i} in `+(c-o)+`ms Removed ${a} targets in `+(h-c)+`ms Removed ${y} documents in `+(f-h)+`ms Total Duration: ${f-m}ms`),Xe.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:a,documentsRemoved:y}))))}}function GH(e,t){return new $ue(e,t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Hue{constructor(t,n){this.db=t,this.garbageCollector=GH(this,n)}dr(t){const n=this.pr(t);return this.db.getTargetCache().getTargetCount(t).next((r=>n.next((i=>r+i))))}pr(t){let n=0;return this.mr(t,(r=>{n++})).next((()=>n))}forEachTarget(t,n){return this.db.getTargetCache().forEachTarget(t,n)}mr(t,n){return this.yr(t,((r,i)=>n(i)))}addReference(t,n,r){return Lv(t,r)}removeReference(t,n,r){return Lv(t,r)}removeTargets(t,n,r){return this.db.getTargetCache().removeTargets(t,n,r)}markPotentiallyOrphaned(t,n){return Lv(t,n)}wr(t,n){return(function(i,a){let o=!1;return FH(i).te((c=>VH(i,c,a).next((h=>(h&&(o=!0),Xe.resolve(!h)))))).next((()=>o))})(t,n)}removeOrphanedDocuments(t,n){const r=this.db.getRemoteDocumentCache().newChangeBuffer(),i=[];let a=0;return this.yr(t,((o,c)=>{if(c<=n){const h=this.wr(t,o).next((f=>{if(!f)return a++,r.getEntry(t,o).next((()=>(r.removeEntry(o,sr.min()),Yh(t).delete((function(y){return[0,So(y.path)]})(o)))))}));i.push(h)}})).next((()=>Xe.waitFor(i))).next((()=>r.apply(t))).next((()=>a))}removeTarget(t,n){const r=n.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,r)}updateLimboDocument(t,n){return Lv(t,n)}yr(t,n){const r=Yh(t);let i,a=ml.ce;return r.ee({index:BI},(([o,c],{path:h,sequenceNumber:f})=>{o===0?(a!==ml.ce&&n(new gn(Cu(i)),a),a=f,i=h):a=ml.ce})).next((()=>{a!==ml.ce&&n(new gn(Cu(i)),a)}))}getCacheSize(t){return this.db.getRemoteDocumentCache().getSize(t)}}function Lv(e,t){return Yh(e).put((function(r,i){return{targetId:0,path:So(r.path),sequenceNumber:i}})(t,e.currentSequenceNumber))}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class qH{constructor(){this.changes=new Zd((t=>t.toString()),((t,n)=>t.isEqual(n))),this.changesApplied=!1}addEntry(t){this.assertNotApplied(),this.changes.set(t.key,t)}removeEntry(t,n){this.assertNotApplied(),this.changes.set(t,Ys.newInvalidDocument(t).setReadTime(n))}getEntry(t,n){this.assertNotApplied();const r=this.changes.get(n);return r!==void 0?Xe.resolve(r):this.getFromCache(t,n)}getEntries(t,n){return this.getAllFromCache(t,n)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}assertNotApplied(){}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Gue{constructor(t){this.serializer=t}setIndexManager(t){this.indexManager=t}addEntry(t,n,r){return ep(t).put(r)}removeEntry(t,n,r){return ep(t).delete((function(a,o){const c=a.path.toArray();return[c.slice(0,c.length-2),c[c.length-2],v2(o),c[c.length-1]]})(n,r))}updateMetadata(t,n){return this.getMetadata(t).next((r=>(r.byteSize+=n,this.Sr(t,r))))}getEntry(t,n){let r=Ys.newInvalidDocument(n);return ep(t).ee({index:jw,range:IDBKeyRange.only(qx(n))},((i,a)=>{r=this.br(n,a)})).next((()=>r))}Dr(t,n){let r={size:0,document:Ys.newInvalidDocument(n)};return ep(t).ee({index:jw,range:IDBKeyRange.only(qx(n))},((i,a)=>{r={document:this.br(n,a),size:N2(a)}})).next((()=>r))}getEntries(t,n){let r=Dl();return this.Cr(t,n,((i,a)=>{const o=this.br(i,a);r=r.insert(i,o)})).next((()=>r))}vr(t,n){let r=Dl(),i=new ds(gn.comparator);return this.Cr(t,n,((a,o)=>{const c=this.br(a,o);r=r.insert(a,c),i=i.insert(a,N2(o))})).next((()=>({documents:r,Fr:i})))}Cr(t,n,r){if(n.isEmpty())return Xe.resolve();let i=new qi(TD);n.forEach((h=>i=i.add(h)));const a=IDBKeyRange.bound(qx(i.first()),qx(i.last())),o=i.getIterator();let c=o.getNext();return ep(t).ee({index:jw,range:a},((h,f,m)=>{const y=gn.fromSegments([...f.prefixPath,f.collectionGroup,f.documentId]);for(;c&&TD(c,y)<0;)r(c,null),c=o.getNext();c&&c.isEqual(y)&&(r(c,f),c=o.hasNext()?o.getNext():null),c?m.j(qx(c)):m.done()})).next((()=>{for(;c;)r(c,null),c=o.hasNext()?o.getNext():null}))}getDocumentsMatchingQuery(t,n,r,i,a){const o=n.path,c=[o.popLast().toArray(),o.lastSegment(),v2(r.readTime),r.documentKey.path.isEmpty()?"":r.documentKey.path.lastSegment()],h=[o.popLast().toArray(),o.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return ep(t).J(IDBKeyRange.bound(c,h,!0)).next((f=>{a==null||a.incrementDocumentReadCount(f.length);let m=Dl();for(const y of f){const w=this.br(gn.fromSegments(y.prefixPath.concat(y.collectionGroup,y.documentId)),y);w.isFoundDocument()&&(qy(n,w)||i.has(w.key))&&(m=m.insert(w.key,w))}return m}))}getAllFromCollectionGroup(t,n,r,i){let a=Dl();const o=ID(n,r),c=ID(n,Vl.max());return ep(t).ee({index:I$,range:IDBKeyRange.bound(o,c,!0)},((h,f,m)=>{const y=this.br(gn.fromSegments(f.prefixPath.concat(f.collectionGroup,f.documentId)),f);a=a.insert(y.key,y),a.size===i&&m.done()})).next((()=>a))}newChangeBuffer(t){return new que(this,!!t&&t.trackRemovals)}getSize(t){return this.getMetadata(t).next((n=>n.byteSize))}getMetadata(t){return jD(t).get(tC).next((n=>(Xn(!!n,20021),n)))}Sr(t,n){return jD(t).put(tC,n)}br(t,n){if(n){const r=Tue(this.serializer,n);if(!(r.isNoDocument()&&r.version.isEqual(sr.min())))return r}return Ys.newInvalidDocument(t)}}function WH(e){return new Gue(e)}class que extends qH{constructor(t,n){super(),this.Mr=t,this.trackRemovals=n,this.Or=new Zd((r=>r.toString()),((r,i)=>r.isEqual(i)))}applyChanges(t){const n=[];let r=0,i=new qi(((a,o)=>Cr(a.canonicalString(),o.canonicalString())));return this.changes.forEach(((a,o)=>{const c=this.Or.get(a);if(n.push(this.Mr.removeEntry(t,a,c.readTime)),o.isValidDocument()){const h=hD(this.Mr.serializer,o);i=i.add(a.path.popLast());const f=N2(h);r+=f-c.size,n.push(this.Mr.addEntry(t,a,h))}else if(r-=c.size,this.trackRemovals){const h=hD(this.Mr.serializer,o.convertToNoDocument(sr.min()));n.push(this.Mr.addEntry(t,a,h))}})),i.forEach((a=>{n.push(this.Mr.indexManager.addToCollectionParentIndex(t,a))})),n.push(this.Mr.updateMetadata(t,r)),Xe.waitFor(n)}getFromCache(t,n){return this.Mr.Dr(t,n).next((r=>(this.Or.set(n,{size:r.size,readTime:r.document.readTime}),r.document)))}getAllFromCache(t,n){return this.Mr.vr(t,n).next((({documents:r,Fr:i})=>(i.forEach(((a,o)=>{this.Or.set(a,{size:o,readTime:r.get(a).readTime})})),r)))}}function jD(e){return ja(e,ay)}function ep(e){return ja(e,f2)}function qx(e){const t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function ID(e,t){const n=t.documentKey.path.toArray();return[e,v2(t.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:""]}function TD(e,t){const n=e.path.toArray(),r=t.path.toArray();let i=0;for(let a=0;a(r=i,this.remoteDocumentCache.getEntry(t,n)))).next((i=>(r!==null&&B1(r.mutation,i,gl.empty(),_r.now()),i)))}getDocuments(t,n){return this.remoteDocumentCache.getEntries(t,n).next((r=>this.getLocalViewOfDocuments(t,r,Kr()).next((()=>r))))}getLocalViewOfDocuments(t,n,r=Kr()){const i=ju();return this.populateOverlays(t,i,n).next((()=>this.computeViews(t,n,i,r).next((a=>{let o=b1();return a.forEach(((c,h)=>{o=o.insert(c,h.overlayedDocument)})),o}))))}getOverlayedDocuments(t,n){const r=ju();return this.populateOverlays(t,r,n).next((()=>this.computeViews(t,n,r,Kr())))}populateOverlays(t,n,r){const i=[];return r.forEach((a=>{n.has(a)||i.push(a)})),this.documentOverlayCache.getOverlays(t,i).next((a=>{a.forEach(((o,c)=>{n.set(o,c)}))}))}computeViews(t,n,r,i){let a=Dl();const o=U1(),c=(function(){return U1()})();return n.forEach(((h,f)=>{const m=r.get(f.key);i.has(f.key)&&(m===void 0||m.mutation instanceof Jd)?a=a.insert(f.key,f):m!==void 0?(o.set(f.key,m.mutation.getFieldMask()),B1(m.mutation,f,m.mutation.getFieldMask(),_r.now())):o.set(f.key,gl.empty())})),this.recalculateAndSaveOverlays(t,a).next((h=>(h.forEach(((f,m)=>o.set(f,m))),n.forEach(((f,m)=>c.set(f,new Wue(m,o.get(f)??null)))),c)))}recalculateAndSaveOverlays(t,n){const r=U1();let i=new ds(((o,c)=>o-c)),a=Kr();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t,n).next((o=>{for(const c of o)c.keys().forEach((h=>{const f=n.get(h);if(f===null)return;let m=r.get(h)||gl.empty();m=c.applyToLocalView(f,m),r.set(h,m);const y=(i.get(c.batchId)||Kr()).add(h);i=i.insert(c.batchId,y)}))})).next((()=>{const o=[],c=i.getReverseIterator();for(;c.hasNext();){const h=c.getNext(),f=h.key,m=h.value,y=uH();m.forEach((w=>{if(!a.has(w)){const A=xH(n.get(w),r.get(w));A!==null&&y.set(w,A),a=a.add(w)}})),o.push(this.documentOverlayCache.saveOverlays(t,f,y))}return Xe.waitFor(o)})).next((()=>r))}recalculateAndSaveOverlaysForDocumentKeys(t,n){return this.remoteDocumentCache.getEntries(t,n).next((r=>this.recalculateAndSaveOverlays(t,r)))}getDocumentsMatchingQuery(t,n,r,i){return Qce(n)?this.getDocumentsMatchingDocumentQuery(t,n.path):rH(n)?this.getDocumentsMatchingCollectionGroupQuery(t,n,r,i):this.getDocumentsMatchingCollectionQuery(t,n,r,i)}getNextDocuments(t,n,r,i){return this.remoteDocumentCache.getAllFromCollectionGroup(t,n,r,i).next((a=>{const o=i-a.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(t,n,r.largestBatchId,i-a.size):Xe.resolve(ju());let c=lg,h=a;return o.next((f=>Xe.forEach(f,((m,y)=>(c{h=h.insert(m,w)}))))).next((()=>this.populateOverlays(t,f,a))).next((()=>this.computeViews(t,h,f,Kr()))).next((m=>({batchId:c,changes:cH(m)})))))}))}getDocumentsMatchingDocumentQuery(t,n){return this.getDocument(t,new gn(n)).next((r=>{let i=b1();return r.isFoundDocument()&&(i=i.insert(r.key,r)),i}))}getDocumentsMatchingCollectionGroupQuery(t,n,r,i){const a=n.collectionGroup;let o=b1();return this.indexManager.getCollectionParents(t,a).next((c=>Xe.forEach(c,(h=>{const f=(function(y,w){return new ym(w,null,y.explicitOrderBy.slice(),y.filters.slice(),y.limit,y.limitType,y.startAt,y.endAt)})(n,h.child(a));return this.getDocumentsMatchingCollectionQuery(t,f,r,i).next((m=>{m.forEach(((y,w)=>{o=o.insert(y,w)}))}))})).next((()=>o))))}getDocumentsMatchingCollectionQuery(t,n,r,i){let a;return this.documentOverlayCache.getOverlaysForCollection(t,n.path,r.largestBatchId).next((o=>(a=o,this.remoteDocumentCache.getDocumentsMatchingQuery(t,n,r,a,i)))).next((o=>{a.forEach(((h,f)=>{const m=f.getKey();o.get(m)===null&&(o=o.insert(m,Ys.newInvalidDocument(m)))}));let c=b1();return o.forEach(((h,f)=>{const m=a.get(h);m!==void 0&&B1(m.mutation,f,gl.empty(),_r.now()),qy(n,f)&&(c=c.insert(h,f))})),c}))}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Kue{constructor(t){this.serializer=t,this.Nr=new Map,this.Br=new Map}getBundleMetadata(t,n){return Xe.resolve(this.Nr.get(n))}saveBundleMetadata(t,n){return this.Nr.set(n.id,(function(i){return{id:i.id,version:i.version,createTime:Wo(i.createTime)}})(n)),Xe.resolve()}getNamedQuery(t,n){return Xe.resolve(this.Br.get(n))}saveNamedQuery(t,n){return this.Br.set(n.name,(function(i){return{name:i.name,query:MH(i.bundledQuery),readTime:Wo(i.readTime)}})(n)),Xe.resolve()}}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Yue{constructor(){this.overlays=new ds(gn.comparator),this.Lr=new Map}getOverlay(t,n){return Xe.resolve(this.overlays.get(n))}getOverlays(t,n){const r=ju();return Xe.forEach(n,(i=>this.getOverlay(t,i).next((a=>{a!==null&&r.set(i,a)})))).next((()=>r))}saveOverlays(t,n,r){return r.forEach(((i,a)=>{this.St(t,n,a)})),Xe.resolve()}removeOverlaysForBatchId(t,n,r){const i=this.Lr.get(r);return i!==void 0&&(i.forEach((a=>this.overlays=this.overlays.remove(a))),this.Lr.delete(r)),Xe.resolve()}getOverlaysForCollection(t,n,r){const i=ju(),a=n.length+1,o=new gn(n.child("")),c=this.overlays.getIteratorFrom(o);for(;c.hasNext();){const h=c.getNext().value,f=h.getKey();if(!n.isPrefixOf(f.path))break;f.path.length===a&&h.largestBatchId>r&&i.set(h.getKey(),h)}return Xe.resolve(i)}getOverlaysForCollectionGroup(t,n,r,i){let a=new ds(((f,m)=>f-m));const o=this.overlays.getIterator();for(;o.hasNext();){const f=o.getNext().value;if(f.getKey().getCollectionGroup()===n&&f.largestBatchId>r){let m=a.get(f.largestBatchId);m===null&&(m=ju(),a=a.insert(f.largestBatchId,m)),m.set(f.getKey(),f)}}const c=ju(),h=a.getIterator();for(;h.hasNext()&&(h.getNext().value.forEach(((f,m)=>c.set(f,m))),!(c.size()>=i)););return Xe.resolve(c)}St(t,n,r){const i=this.overlays.get(r.key);if(i!==null){const o=this.Lr.get(i.largestBatchId).delete(r.key);this.Lr.set(i.largestBatchId,o)}this.overlays=this.overlays.insert(r.key,new QI(n,r));let a=this.Lr.get(n);a===void 0&&(a=Kr(),this.Lr.set(n,a)),this.Lr.set(n,a.add(r.key))}}/** * @license * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Xue{constructor(){this.sessionToken=na.EMPTY_BYTE_STRING}getSessionToken(t){return Xe.resolve(this.sessionToken)}setSessionToken(t,n){return this.sessionToken=n,Xe.resolve()}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class rT{constructor(){this.kr=new qi(Va.qr),this.Kr=new qi(Va.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(t,n){const r=new Va(t,n);this.kr=this.kr.add(r),this.Kr=this.Kr.add(r)}$r(t,n){t.forEach((r=>this.addReference(r,n)))}removeReference(t,n){this.Wr(new Va(t,n))}Qr(t,n){t.forEach((r=>this.removeReference(r,n)))}Gr(t){const n=new gn(new ki([])),r=new Va(n,t),i=new Va(n,t+1),a=[];return this.Kr.forEachInRange([r,i],(o=>{this.Wr(o),a.push(o.key)})),a}zr(){this.kr.forEach((t=>this.Wr(t)))}Wr(t){this.kr=this.kr.delete(t),this.Kr=this.Kr.delete(t)}jr(t){const n=new gn(new ki([])),r=new Va(n,t),i=new Va(n,t+1);let a=Kr();return this.Kr.forEachInRange([r,i],(o=>{a=a.add(o.key)})),a}containsKey(t){const n=new Va(t,0),r=this.kr.firstAfterOrEqual(n);return r!==null&&t.isEqual(r.key)}}class Va{constructor(t,n){this.key=t,this.Jr=n}static qr(t,n){return gn.comparator(t.key,n.key)||Cr(t.Jr,n.Jr)}static Ur(t,n){return Cr(t.Jr,n.Jr)||gn.comparator(t.key,n.key)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Que{constructor(t,n){this.indexManager=t,this.referenceDelegate=n,this.mutationQueue=[],this.Yn=1,this.Hr=new qi(Va.qr)}checkEmpty(t){return Xe.resolve(this.mutationQueue.length===0)}addMutationBatch(t,n,r,i){const a=this.Yn;this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const o=new YI(a,n,r,i);this.mutationQueue.push(o);for(const c of i)this.Hr=this.Hr.add(new Va(c.key,a)),this.indexManager.addToCollectionParentIndex(t,c.key.path.popLast());return Xe.resolve(o)}lookupMutationBatch(t,n){return Xe.resolve(this.Zr(n))}getNextMutationBatchAfterBatchId(t,n){const r=n+1,i=this.Xr(r),a=i<0?0:i;return Xe.resolve(this.mutationQueue.length>a?this.mutationQueue[a]:null)}getHighestUnacknowledgedBatchId(){return Xe.resolve(this.mutationQueue.length===0?Dp:this.Yn-1)}getAllMutationBatches(t){return Xe.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(t,n){const r=new Va(n,0),i=new Va(n,Number.POSITIVE_INFINITY),a=[];return this.Hr.forEachInRange([r,i],(o=>{const c=this.Zr(o.Jr);a.push(c)})),Xe.resolve(a)}getAllMutationBatchesAffectingDocumentKeys(t,n){let r=new qi(Cr);return n.forEach((i=>{const a=new Va(i,0),o=new Va(i,Number.POSITIVE_INFINITY);this.Hr.forEachInRange([a,o],(c=>{r=r.add(c.Jr)}))})),Xe.resolve(this.Yr(r))}getAllMutationBatchesAffectingQuery(t,n){const r=n.path,i=r.length+1;let a=r;gn.isDocumentKey(a)||(a=a.child(""));const o=new Va(new gn(a),0);let c=new qi(Cr);return this.Hr.forEachWhile((h=>{const f=h.key.path;return!!r.isPrefixOf(f)&&(f.length===i&&(c=c.add(h.Jr)),!0)}),o),Xe.resolve(this.Yr(c))}Yr(t){const n=[];return t.forEach((r=>{const i=this.Zr(r);i!==null&&n.push(i)})),n}removeMutationBatch(t,n){Xn(this.ei(n.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.Hr;return Xe.forEach(n.mutations,(i=>{const a=new Va(i.key,n.batchId);return r=r.delete(a),this.referenceDelegate.markPotentiallyOrphaned(t,i.key)})).next((()=>{this.Hr=r}))}nr(t){}containsKey(t,n){const r=new Va(n,0),i=this.Hr.firstAfterOrEqual(r);return Xe.resolve(n.isEqual(i&&i.key))}performConsistencyCheck(t){return this.mutationQueue.length,Xe.resolve()}ei(t,n){return this.Xr(t)}Xr(t){return this.mutationQueue.length===0?0:t-this.mutationQueue[0].batchId}Zr(t){const n=this.Xr(t);return n<0||n>=this.mutationQueue.length?null:this.mutationQueue[n]}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Zue{constructor(t){this.ti=t,this.docs=(function(){return new ds(gn.comparator)})(),this.size=0}setIndexManager(t){this.indexManager=t}addEntry(t,n){const r=n.key,i=this.docs.get(r),a=i?i.size:0,o=this.ti(n);return this.docs=this.docs.insert(r,{document:n.mutableCopy(),size:o}),this.size+=o-a,this.indexManager.addToCollectionParentIndex(t,r.path.popLast())}removeEntry(t){const n=this.docs.get(t);n&&(this.docs=this.docs.remove(t),this.size-=n.size)}getEntry(t,n){const r=this.docs.get(n);return Xe.resolve(r?r.document.mutableCopy():Ys.newInvalidDocument(n))}getEntries(t,n){let r=Dl();return n.forEach((i=>{const a=this.docs.get(i);r=r.insert(i,a?a.document.mutableCopy():Ys.newInvalidDocument(i))})),Xe.resolve(r)}getDocumentsMatchingQuery(t,n,r,i){let a=Dl();const o=n.path,c=new gn(o.child("__id-9223372036854775808__")),h=this.docs.getIteratorFrom(c);for(;h.hasNext();){const{key:f,value:{document:m}}=h.getNext();if(!o.isPrefixOf(f.path))break;f.path.length>o.length+1||LI(A$(m),r)<=0||(i.has(m.key)||qy(n,m))&&(a=a.insert(m.key,m.mutableCopy()))}return Xe.resolve(a)}getAllFromCollectionGroup(t,n,r,i){Tn(9500)}ni(t,n){return Xe.forEach(this.docs,(r=>n(r)))}newChangeBuffer(t){return new Jue(this)}getSize(t){return Xe.resolve(this.size)}}class Jue extends qH{constructor(t){super(),this.Mr=t}applyChanges(t){const n=[];return this.changes.forEach(((r,i)=>{i.isValidDocument()?n.push(this.Mr.addEntry(t,i)):this.Mr.removeEntry(r)})),Xe.waitFor(n)}getFromCache(t,n){return this.Mr.getEntry(t,n)}getAllFromCache(t,n){return this.Mr.getEntries(t,n)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ede{constructor(t){this.persistence=t,this.ri=new Zd((n=>tm(n)),Hy),this.lastRemoteSnapshotVersion=sr.min(),this.highestTargetId=0,this.ii=0,this.si=new rT,this.targetCount=0,this.oi=am._r()}forEachTarget(t,n){return this.ri.forEach(((r,i)=>n(i))),Xe.resolve()}getLastRemoteSnapshotVersion(t){return Xe.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return Xe.resolve(this.ii)}allocateTargetId(t){return this.highestTargetId=this.oi.next(),Xe.resolve(this.highestTargetId)}setTargetsMetadata(t,n,r){return r&&(this.lastRemoteSnapshotVersion=r),n>this.ii&&(this.ii=n),Xe.resolve()}lr(t){this.ri.set(t.target,t);const n=t.targetId;n>this.highestTargetId&&(this.oi=new am(n),this.highestTargetId=n),t.sequenceNumber>this.ii&&(this.ii=t.sequenceNumber)}addTargetData(t,n){return this.lr(n),this.targetCount+=1,Xe.resolve()}updateTargetData(t,n){return this.lr(n),Xe.resolve()}removeTargetData(t,n){return this.ri.delete(n.target),this.si.Gr(n.targetId),this.targetCount-=1,Xe.resolve()}removeTargets(t,n,r){let i=0;const a=[];return this.ri.forEach(((o,c)=>{c.sequenceNumber<=n&&r.get(c.targetId)===null&&(this.ri.delete(o),a.push(this.removeMatchingKeysForTargetId(t,c.targetId)),i++)})),Xe.waitFor(a).next((()=>i))}getTargetCount(t){return Xe.resolve(this.targetCount)}getTargetData(t,n){const r=this.ri.get(n)||null;return Xe.resolve(r)}addMatchingKeys(t,n,r){return this.si.$r(n,r),Xe.resolve()}removeMatchingKeys(t,n,r){this.si.Qr(n,r);const i=this.persistence.referenceDelegate,a=[];return i&&n.forEach((o=>{a.push(i.markPotentiallyOrphaned(t,o))})),Xe.waitFor(a)}removeMatchingKeysForTargetId(t,n){return this.si.Gr(n),Xe.resolve()}getMatchingKeysForTargetId(t,n){const r=this.si.jr(n);return Xe.resolve(r)}containsKey(t,n){return Xe.resolve(this.si.containsKey(n))}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class iT{constructor(t,n){this._i={},this.overlays={},this.ai=new ml(0),this.ui=!1,this.ui=!0,this.ci=new Xue,this.referenceDelegate=t(this),this.li=new ede(this),this.indexManager=new Bue,this.remoteDocumentCache=(function(i){return new Zue(i)})((r=>this.referenceDelegate.hi(r))),this.serializer=new RH(n),this.Pi=new Kue(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(t){return this.indexManager}getDocumentOverlayCache(t){let n=this.overlays[t.toKey()];return n||(n=new Yue,this.overlays[t.toKey()]=n),n}getMutationQueue(t,n){let r=this._i[t.toKey()];return r||(r=new Que(n,this.referenceDelegate),this._i[t.toKey()]=r),r}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(t,n,r){qt("MemoryPersistence","Starting transaction:",t);const i=new tde(this.ai.next());return this.referenceDelegate.Ti(),r(i).next((a=>this.referenceDelegate.Ei(i).next((()=>a)))).toPromise().then((a=>(i.raiseOnCommittedEvent(),a)))}Ii(t,n){return Xe.or(Object.values(this._i).map((r=>()=>r.containsKey(t,n))))}}class tde extends k${constructor(t){super(),this.currentSequenceNumber=t}}class wE{constructor(t){this.persistence=t,this.Ri=new rT,this.Ai=null}static Vi(t){return new wE(t)}get di(){if(this.Ai)return this.Ai;throw Tn(60996)}addReference(t,n,r){return this.Ri.addReference(r,n),this.di.delete(r.toString()),Xe.resolve()}removeReference(t,n,r){return this.Ri.removeReference(r,n),this.di.add(r.toString()),Xe.resolve()}markPotentiallyOrphaned(t,n){return this.di.add(n.toString()),Xe.resolve()}removeTarget(t,n){this.Ri.Gr(n.targetId).forEach((i=>this.di.add(i.toString())));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(t,n.targetId).next((i=>{i.forEach((a=>this.di.add(a.toString())))})).next((()=>r.removeTargetData(t,n)))}Ti(){this.Ai=new Set}Ei(t){const n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return Xe.forEach(this.di,(r=>{const i=gn.fromPath(r);return this.mi(t,i).next((a=>{a||n.removeEntry(i,sr.min())}))})).next((()=>(this.Ai=null,n.apply(t))))}updateLimboDocument(t,n){return this.mi(t,n).next((r=>{r?this.di.delete(n.toString()):this.di.add(n.toString())}))}hi(t){return 0}mi(t,n){return Xe.or([()=>Xe.resolve(this.Ri.containsKey(n)),()=>this.persistence.getTargetCache().containsKey(t,n),()=>this.persistence.Ii(t,n)])}}class E2{constructor(t,n){this.persistence=t,this.fi=new Zd((r=>So(r.path)),((r,i)=>r.isEqual(i))),this.garbageCollector=GH(this,n)}static Vi(t,n){return new E2(t,n)}Ti(){}Ei(t){return Xe.resolve()}forEachTarget(t,n){return this.persistence.getTargetCache().forEachTarget(t,n)}dr(t){const n=this.pr(t);return this.persistence.getTargetCache().getTargetCount(t).next((r=>n.next((i=>r+i))))}pr(t){let n=0;return this.mr(t,(r=>{n++})).next((()=>n))}mr(t,n){return Xe.forEach(this.fi,((r,i)=>this.wr(t,r,i).next((a=>a?Xe.resolve():n(i)))))}removeTargets(t,n,r){return this.persistence.getTargetCache().removeTargets(t,n,r)}removeOrphanedDocuments(t,n){let r=0;const i=this.persistence.getRemoteDocumentCache(),a=i.newChangeBuffer();return i.ni(t,(o=>this.wr(t,o,n).next((c=>{c||(r++,a.removeEntry(o,sr.min()))})))).next((()=>a.apply(t))).next((()=>r))}markPotentiallyOrphaned(t,n){return this.fi.set(n,t.currentSequenceNumber),Xe.resolve()}removeTarget(t,n){const r=n.withSequenceNumber(t.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(t,r)}addReference(t,n,r){return this.fi.set(r,t.currentSequenceNumber),Xe.resolve()}removeReference(t,n,r){return this.fi.set(r,t.currentSequenceNumber),Xe.resolve()}updateLimboDocument(t,n){return this.fi.set(n,t.currentSequenceNumber),Xe.resolve()}hi(t){let n=t.key.toString().length;return t.isFoundDocument()&&(n+=Tw(t.data.value)),n}wr(t,n,r){return Xe.or([()=>this.persistence.Ii(t,n),()=>this.persistence.getTargetCache().containsKey(t,n),()=>{const i=this.fi.get(n);return Xe.resolve(i!==void 0&&i>r)}])}getCacheSize(t){return this.persistence.getRemoteDocumentCache().getSize(t)}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class nde{constructor(t){this.serializer=t}k(t,n,r,i){const a=new lE("createOrUpgrade",n);r<1&&i>=1&&((function(h){h.createObjectStore($y)})(t),(function(h){h.createObjectStore(sy,{keyPath:hce}),h.createObjectStore(Uc,{keyPath:FR,autoIncrement:!0}).createIndex(Ap,$R,{unique:!0}),h.createObjectStore(cg)})(t),PD(t),(function(h){h.createObjectStore(up)})(t));let o=Xe.resolve();return r<3&&i>=3&&(r!==0&&((function(h){h.deleteObjectStore(dg),h.deleteObjectStore(ug),h.deleteObjectStore(Mp)})(t),PD(t)),o=o.next((()=>(function(h){const f=h.store(Mp),m={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:sr.min().toTimestamp(),targetCount:0};return f.put(p2,m)})(a)))),r<4&&i>=4&&(r!==0&&(o=o.next((()=>(function(h,f){return f.store(Uc).J().next((y=>{h.deleteObjectStore(Uc),h.createObjectStore(Uc,{keyPath:FR,autoIncrement:!0}).createIndex(Ap,$R,{unique:!0});const w=f.store(Uc),A=y.map((S=>w.put(S)));return Xe.waitFor(A)}))})(t,a)))),o=o.next((()=>{(function(h){h.createObjectStore(hg,{keyPath:wce})})(t)}))),r<5&&i>=5&&(o=o.next((()=>this.gi(a)))),r<6&&i>=6&&(o=o.next((()=>((function(h){h.createObjectStore(ay)})(t),this.pi(a))))),r<7&&i>=7&&(o=o.next((()=>this.yi(a)))),r<8&&i>=8&&(o=o.next((()=>this.wi(t,a)))),r<9&&i>=9&&(o=o.next((()=>{(function(h){h.objectStoreNames.contains("remoteDocumentChanges")&&h.deleteObjectStore("remoteDocumentChanges")})(t)}))),r<10&&i>=10&&(o=o.next((()=>this.Si(a)))),r<11&&i>=11&&(o=o.next((()=>{(function(h){h.createObjectStore(uE,{keyPath:Nce})})(t),(function(h){h.createObjectStore(dE,{keyPath:Ece})})(t)}))),r<12&&i>=12&&(o=o.next((()=>{(function(h){const f=h.createObjectStore(hE,{keyPath:Ice});f.createIndex(rC,Tce,{unique:!1}),f.createIndex(R$,Pce,{unique:!1})})(t)}))),r<13&&i>=13&&(o=o.next((()=>(function(h){const f=h.createObjectStore(f2,{keyPath:pce});f.createIndex(jw,mce),f.createIndex(I$,gce)})(t))).next((()=>this.bi(t,a))).next((()=>t.deleteObjectStore(up)))),r<14&&i>=14&&(o=o.next((()=>this.Di(t,a)))),r<15&&i>=15&&(o=o.next((()=>(function(h){h.createObjectStore(zI,{keyPath:Ace,autoIncrement:!0}).createIndex(nC,_ce,{unique:!1}),h.createObjectStore(R1,{keyPath:kce}).createIndex(P$,Sce,{unique:!1}),h.createObjectStore(D1,{keyPath:Cce}).createIndex(O$,jce,{unique:!1})})(t)))),r<16&&i>=16&&(o=o.next((()=>{n.objectStore(R1).clear()})).next((()=>{n.objectStore(D1).clear()}))),r<17&&i>=17&&(o=o.next((()=>{(function(h){h.createObjectStore(VI,{keyPath:Oce})})(t)}))),r<18&&i>=18&&_F()&&(o=o.next((()=>{n.objectStore(R1).clear()})).next((()=>{n.objectStore(D1).clear()}))),o}pi(t){let n=0;return t.store(up).ee(((r,i)=>{n+=N2(i)})).next((()=>{const r={byteSize:n};return t.store(ay).put(tC,r)}))}gi(t){const n=t.store(sy),r=t.store(Uc);return n.J().next((i=>Xe.forEach(i,(a=>{const o=IDBKeyRange.bound([a.userId,Dp],[a.userId,a.lastAcknowledgedBatchId]);return r.J(Ap,o).next((c=>Xe.forEach(c,(h=>{Xn(h.userId===a.userId,18650,"Cannot process batch from unexpected user",{batchId:h.batchId});const f=xp(this.serializer,h);return zH(t,a.userId,f).next((()=>{}))}))))}))))}yi(t){const n=t.store(dg),r=t.store(up);return t.store(Mp).get(p2).next((i=>{const a=[];return r.ee(((o,c)=>{const h=new ki(o),f=(function(y){return[0,So(y)]})(h);a.push(n.get(f).next((m=>m?Xe.resolve():(y=>n.put({targetId:0,path:So(y),sequenceNumber:i.highestListenSequenceNumber}))(h))))})).next((()=>Xe.waitFor(a)))}))}wi(t,n){t.createObjectStore(oy,{keyPath:vce});const r=n.store(oy),i=new nT,a=o=>{if(i.add(o)){const c=o.lastSegment(),h=o.popLast();return r.put({collectionId:c,parent:So(h)})}};return n.store(up).ee({Y:!0},((o,c)=>{const h=new ki(o);return a(h.popLast())})).next((()=>n.store(cg).ee({Y:!0},(([o,c,h],f)=>{const m=Cu(c);return a(m.popLast())}))))}Si(t){const n=t.store(ug);return n.ee(((r,i)=>{const a=w1(i),o=DH(this.serializer,a);return n.put(o)}))}bi(t,n){const r=n.store(up),i=[];return r.ee(((a,o)=>{const c=n.store(f2),h=(function(y){return y.document?new gn(ki.fromString(y.document.name).popFirst(5)):y.noDocument?gn.fromSegments(y.noDocument.path):y.unknownDocument?gn.fromSegments(y.unknownDocument.path):Tn(36783)})(o).path.toArray(),f={prefixPath:h.slice(0,h.length-2),collectionGroup:h[h.length-2],documentId:h[h.length-1],readTime:o.readTime||[0,0],unknownDocument:o.unknownDocument,noDocument:o.noDocument,document:o.document,hasCommittedMutations:!!o.hasCommittedMutations};i.push(c.put(f))})).next((()=>Xe.waitFor(i)))}Di(t,n){const r=n.store(Uc),i=WH(this.serializer),a=new iT(wE.Vi,this.serializer.yt);return r.J().next((o=>{const c=new Map;return o.forEach((h=>{let f=c.get(h.userId)??Kr();xp(this.serializer,h).keys().forEach((m=>f=f.add(m))),c.set(h.userId,f)})),Xe.forEach(c,((h,f)=>{const m=new wo(f),y=bE.wt(this.serializer,m),w=a.getIndexManager(m),A=vE.wt(m,this.serializer,w,a.referenceDelegate);return new KH(i,A,y,w).recalculateAndSaveOverlaysForDocumentKeys(new iC(n,ml.ce),h).next()}))}))}}function PD(e){e.createObjectStore(dg,{keyPath:yce}).createIndex(BI,bce,{unique:!0}),e.createObjectStore(ug,{keyPath:"targetId"}).createIndex(T$,xce,{unique:!0}),e.createObjectStore(Mp)}const Rh="IndexedDbPersistence",c_=18e5,u_=5e3,d_="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",rde="main";class sT{constructor(t,n,r,i,a,o,c,h,f,m,y=18){if(this.allowTabSynchronization=t,this.persistenceKey=n,this.clientId=r,this.Ci=a,this.window=o,this.document=c,this.Fi=f,this.Mi=m,this.xi=y,this.ai=null,this.ui=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Oi=null,this.inForeground=!1,this.Ni=null,this.Bi=null,this.Li=Number.NEGATIVE_INFINITY,this.ki=w=>Promise.resolve(),!sT.v())throw new sn(vt.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new Hue(this,i),this.qi=n+rde,this.serializer=new RH(h),this.Ki=new of(this.qi,this.xi,new nde(this.serializer)),this.ci=new Oue,this.li=new Vue(this.referenceDelegate,this.serializer),this.remoteDocumentCache=WH(this.serializer),this.Pi=new Pue,this.window&&this.window.localStorage?this.Ui=this.window.localStorage:(this.Ui=null,m===!1&&ta(Rh,"LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.$i().then((()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new sn(vt.FAILED_PRECONDITION,d_);return this.Wi(),this.Qi(),this.Gi(),this.runTransaction("getHighestListenSequenceNumber","readonly",(t=>this.li.getHighestSequenceNumber(t)))})).then((t=>{this.ai=new ml(t,this.Fi)})).then((()=>{this.ui=!0})).catch((t=>(this.Ki&&this.Ki.close(),Promise.reject(t))))}zi(t){return this.ki=async n=>{if(this.started)return t(n)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.Ki.K((async n=>{n.newVersion===null&&await t()}))}setNetworkEnabled(t){this.networkEnabled!==t&&(this.networkEnabled=t,this.Ci.enqueueAndForget((async()=>{this.started&&await this.$i()})))}$i(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(t=>Uv(t).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next((()=>{if(this.isPrimary)return this.ji(t).next((n=>{n||(this.isPrimary=!1,this.Ci.enqueueRetryable((()=>this.ki(!1))))}))})).next((()=>this.Ji(t))).next((n=>this.isPrimary&&!n?this.Hi(t).next((()=>!1)):!!n&&this.Zi(t).next((()=>!0)))))).catch((t=>{if(Af(t))return qt(Rh,"Failed to extend owner lease: ",t),this.isPrimary;if(!this.allowTabSynchronization)throw t;return qt(Rh,"Releasing owner lease after error during lease refresh",t),!1})).then((t=>{this.isPrimary!==t&&this.Ci.enqueueRetryable((()=>this.ki(t))),this.isPrimary=t}))}ji(t){return Wx(t).get(h0).next((n=>Xe.resolve(this.Xi(n))))}Yi(t){return Uv(t).delete(this.clientId)}async es(){if(this.isPrimary&&!this.ts(this.Li,c_)){this.Li=Date.now();const t=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(n=>{const r=ja(n,hg);return r.J().next((i=>{const a=this.ns(i,c_),o=i.filter((c=>a.indexOf(c)===-1));return Xe.forEach(o,(c=>r.delete(c.clientId))).next((()=>o))}))})).catch((()=>[]));if(this.Ui)for(const n of t)this.Ui.removeItem(this.rs(n.clientId))}}Gi(){this.Bi=this.Ci.enqueueAfterDelay("client_metadata_refresh",4e3,(()=>this.$i().then((()=>this.es())).then((()=>this.Gi()))))}Xi(t){return!!t&&t.ownerId===this.clientId}Ji(t){return this.Mi?Xe.resolve(!0):Wx(t).get(h0).next((n=>{if(n!==null&&this.ts(n.leaseTimestampMs,u_)&&!this.ss(n.ownerId)){if(this.Xi(n)&&this.networkEnabled)return!0;if(!this.Xi(n)){if(!n.allowTabSynchronization)throw new sn(vt.FAILED_PRECONDITION,d_);return!1}}return!(!this.networkEnabled||!this.inForeground)||Uv(t).J().next((r=>this.ns(r,u_).find((i=>{if(this.clientId!==i.clientId){const a=!this.networkEnabled&&i.networkEnabled,o=!this.inForeground&&i.inForeground,c=this.networkEnabled===i.networkEnabled;if(a||o&&c)return!0}return!1}))===void 0))})).next((n=>(this.isPrimary!==n&&qt(Rh,`Client ${n?"is":"is not"} eligible for a primary lease.`),n)))}async shutdown(){this.ui=!1,this._s(),this.Bi&&(this.Bi.cancel(),this.Bi=null),this.us(),this.cs(),await this.Ki.runTransaction("shutdown","readwrite",[$y,hg],(t=>{const n=new iC(t,ml.ce);return this.Hi(n).next((()=>this.Yi(n)))})),this.Ki.close(),this.ls()}ns(t,n){return t.filter((r=>this.ts(r.updateTimeMs,n)&&!this.ss(r.clientId)))}hs(){return this.runTransaction("getActiveClients","readonly",(t=>Uv(t).J().next((n=>this.ns(n,c_).map((r=>r.clientId))))))}get started(){return this.ui}getGlobalsCache(){return this.ci}getMutationQueue(t,n){return vE.wt(t,this.serializer,n,this.referenceDelegate)}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(t){return new zue(t,this.serializer.yt.databaseId)}getDocumentOverlayCache(t){return bE.wt(this.serializer,t)}getBundleCache(){return this.Pi}runTransaction(t,n,r){qt(Rh,"Starting transaction:",t);const i=n==="readonly"?"readonly":"readwrite",a=(function(h){return h===18?Mce:h===17?U$:h===16?Dce:h===15?FI:h===14?L$:h===13?M$:h===12?Rce:h===11?D$:void Tn(60245)})(this.xi);let o;return this.Ki.runTransaction(t,i,a,(c=>(o=new iC(c,this.ai?this.ai.next():ml.ce),n==="readwrite-primary"?this.ji(o).next((h=>!!h||this.Ji(o))).next((h=>{if(!h)throw ta(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.Ci.enqueueRetryable((()=>this.ki(!1))),new sn(vt.FAILED_PRECONDITION,_$);return r(o)})).next((h=>this.Zi(o).next((()=>h)))):this.Ps(o).next((()=>r(o)))))).then((c=>(o.raiseOnCommittedEvent(),c)))}Ps(t){return Wx(t).get(h0).next((n=>{if(n!==null&&this.ts(n.leaseTimestampMs,u_)&&!this.ss(n.ownerId)&&!this.Xi(n)&&!(this.Mi||this.allowTabSynchronization&&n.allowTabSynchronization))throw new sn(vt.FAILED_PRECONDITION,d_)}))}Zi(t){const n={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return Wx(t).put(h0,n)}static v(){return of.v()}Hi(t){const n=Wx(t);return n.get(h0).next((r=>this.Xi(r)?(qt(Rh,"Releasing primary lease."),n.delete(h0)):Xe.resolve()))}ts(t,n){const r=Date.now();return!(tr)||(ta(`Detected an update time that is in the future: ${t} > ${r}`),!1))}Wi(){this.document!==null&&typeof this.document.addEventListener=="function"&&(this.Ni=()=>{this.Ci.enqueueAndForget((()=>(this.inForeground=this.document.visibilityState==="visible",this.$i())))},this.document.addEventListener("visibilitychange",this.Ni),this.inForeground=this.document.visibilityState==="visible")}us(){this.Ni&&(this.document.removeEventListener("visibilitychange",this.Ni),this.Ni=null)}Qi(){var t;typeof((t=this.window)==null?void 0:t.addEventListener)=="function"&&(this.Oi=()=>{this._s();const n=/(?:Version|Mobile)\/1[456]/;AF()&&(navigator.appVersion.match(n)||navigator.userAgent.match(n))&&this.Ci.enterRestrictedMode(!0),this.Ci.enqueueAndForget((()=>this.shutdown()))},this.window.addEventListener("pagehide",this.Oi))}cs(){this.Oi&&(this.window.removeEventListener("pagehide",this.Oi),this.Oi=null)}ss(t){var n;try{const r=((n=this.Ui)==null?void 0:n.getItem(this.rs(t)))!==null;return qt(Rh,`Client '${t}' ${r?"is":"is not"} zombied in LocalStorage`),r}catch(r){return ta(Rh,"Failed to get zombied client id.",r),!1}}_s(){if(this.Ui)try{this.Ui.setItem(this.rs(this.clientId),String(Date.now()))}catch(t){ta("Failed to set zombie client id.",t)}}ls(){if(this.Ui)try{this.Ui.removeItem(this.rs(this.clientId))}catch{}}rs(t){return`firestore_zombie_${this.persistenceKey}_${t}`}}function Wx(e){return ja(e,$y)}function Uv(e){return ja(e,hg)}function YH(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class aT{constructor(t,n,r,i){this.targetId=t,this.fromCache=n,this.Ts=r,this.Es=i}static Is(t,n){let r=Kr(),i=Kr();for(const a of n.docChanges)switch(a.type){case 0:r=r.add(a.doc.key);break;case 1:i=i.add(a.doc.key)}return new aT(t,n.fromCache,r,i)}}/** * @license * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ide{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(t){this._documentReadCount+=t}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class XH{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=(function(){return AF()?8:S$(Sa())>0?6:4})()}initialize(t,n){this.fs=t,this.indexManager=n,this.Rs=!0}getDocumentsMatchingQuery(t,n,r,i){const a={result:null};return this.gs(t,n).next((o=>{a.result=o})).next((()=>{if(!a.result)return this.ps(t,n,i,r).next((o=>{a.result=o}))})).next((()=>{if(a.result)return;const o=new ide;return this.ys(t,n,o).next((c=>{if(a.result=c,this.As)return this.ws(t,n,o,c.size)}))})).next((()=>a.result))}ws(t,n,r,i){return r.documentReadCountthis.ds*i?(j0()<=ai.DEBUG&&qt("QueryEngine","The SDK decides to create cache indexes for query:",I0(n),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(t,Ul(n))):Xe.resolve())}gs(t,n){if(nD(n))return Xe.resolve(null);let r=Ul(n);return this.indexManager.getIndexType(t,r).next((i=>i===0?null:(n.limit!==null&&i===1&&(n=x2(n,null,"F"),r=Ul(n)),this.indexManager.getDocumentsMatchingTarget(t,r).next((a=>{const o=Kr(...a);return this.fs.getDocuments(t,o).next((c=>this.indexManager.getMinOffset(t,r).next((h=>{const f=this.Ss(n,c);return this.bs(n,f,o,h.readTime)?this.gs(t,x2(n,null,"F")):this.Ds(t,f,n,h)}))))})))))}ps(t,n,r,i){return nD(n)||i.isEqual(sr.min())?Xe.resolve(null):this.fs.getDocuments(t,r).next((a=>{const o=this.Ss(n,a);return this.bs(n,o,r,i)?Xe.resolve(null):(j0()<=ai.DEBUG&&qt("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),I0(n)),this.Ds(t,o,n,E$(i,lg)).next((c=>c)))}))}Ss(t,n){let r=new qi(oH(t));return n.forEach(((i,a)=>{qy(t,a)&&(r=r.add(a))})),r}bs(t,n,r,i){if(t.limit===null)return!1;if(r.size!==n.size)return!0;const a=t.limitType==="F"?n.last():n.first();return!!a&&(a.hasPendingWrites||a.version.compareTo(i)>0)}ys(t,n,r){return j0()<=ai.DEBUG&&qt("QueryEngine","Using full collection scan to execute query:",I0(n)),this.fs.getDocumentsMatchingQuery(t,n,Vl.min(),r)}Ds(t,n,r,i){return this.fs.getDocumentsMatchingQuery(t,r,i).next((a=>(n.forEach((o=>{a=a.insert(o.key,o)})),a)))}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const oT="LocalStore",sde=3e8;class ade{constructor(t,n,r,i){this.persistence=t,this.Cs=n,this.serializer=i,this.vs=new ds(Cr),this.Fs=new Zd((a=>tm(a)),Hy),this.Ms=new Map,this.xs=t.getRemoteDocumentCache(),this.li=t.getTargetCache(),this.Pi=t.getBundleCache(),this.Os(r)}Os(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new KH(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(n=>t.collect(n,this.vs)))}}function QH(e,t,n,r){return new ade(e,t,n,r)}async function ZH(e,t){const n=Vn(e);return await n.persistence.runTransaction("Handle user change","readonly",(r=>{let i;return n.mutationQueue.getAllMutationBatches(r).next((a=>(i=a,n.Os(t),n.mutationQueue.getAllMutationBatches(r)))).next((a=>{const o=[],c=[];let h=Kr();for(const f of i){o.push(f.batchId);for(const m of f.mutations)h=h.add(m.key)}for(const f of a){c.push(f.batchId);for(const m of f.mutations)h=h.add(m.key)}return n.localDocuments.getDocuments(r,h).next((f=>({Ns:f,removedBatchIds:o,addedBatchIds:c})))}))}))}function ode(e,t){const n=Vn(e);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(r=>{const i=t.batch.keys(),a=n.xs.newChangeBuffer({trackRemovals:!0});return(function(c,h,f,m){const y=f.batch,w=y.keys();let A=Xe.resolve();return w.forEach((S=>{A=A.next((()=>m.getEntry(h,S))).next((C=>{const T=f.docVersions.get(S);Xn(T!==null,48541),C.version.compareTo(T)<0&&(y.applyToRemoteDocument(C,f),C.isValidDocument()&&(C.setReadTime(f.commitVersion),m.addEntry(C)))}))})),A.next((()=>c.mutationQueue.removeMutationBatch(h,y)))})(n,r,t,a).next((()=>a.apply(r))).next((()=>n.mutationQueue.performConsistencyCheck(r))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(r,i,t.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,(function(c){let h=Kr();for(let f=0;f0&&(h=h.add(c.batch.mutations[f].key));return h})(t)))).next((()=>n.localDocuments.getDocuments(r,i)))}))}function JH(e){const t=Vn(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",(n=>t.li.getLastRemoteSnapshotVersion(n)))}function lde(e,t){const n=Vn(e),r=t.snapshotVersion;let i=n.vs;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(a=>{const o=n.xs.newChangeBuffer({trackRemovals:!0});i=n.vs;const c=[];t.targetChanges.forEach(((m,y)=>{const w=i.get(y);if(!w)return;c.push(n.li.removeMatchingKeys(a,m.removedDocuments,y).next((()=>n.li.addMatchingKeys(a,m.addedDocuments,y))));let A=w.withSequenceNumber(a.currentSequenceNumber);t.targetMismatches.get(y)!==null?A=A.withResumeToken(na.EMPTY_BYTE_STRING,sr.min()).withLastLimboFreeSnapshotVersion(sr.min()):m.resumeToken.approximateByteSize()>0&&(A=A.withResumeToken(m.resumeToken,r)),i=i.insert(y,A),(function(C,T,D){return C.resumeToken.approximateByteSize()===0||T.snapshotVersion.toMicroseconds()-C.snapshotVersion.toMicroseconds()>=sde?!0:D.addedDocuments.size+D.modifiedDocuments.size+D.removedDocuments.size>0})(w,A,m)&&c.push(n.li.updateTargetData(a,A))}));let h=Dl(),f=Kr();if(t.documentUpdates.forEach((m=>{t.resolvedLimboDocuments.has(m)&&c.push(n.persistence.referenceDelegate.updateLimboDocument(a,m))})),c.push(cde(a,o,t.documentUpdates).next((m=>{h=m.Bs,f=m.Ls}))),!r.isEqual(sr.min())){const m=n.li.getLastRemoteSnapshotVersion(a).next((y=>n.li.setTargetsMetadata(a,a.currentSequenceNumber,r)));c.push(m)}return Xe.waitFor(c).next((()=>o.apply(a))).next((()=>n.localDocuments.getLocalViewOfDocuments(a,h,f))).next((()=>h))})).then((a=>(n.vs=i,a)))}function cde(e,t,n){let r=Kr(),i=Kr();return n.forEach((a=>r=r.add(a))),t.getEntries(e,r).next((a=>{let o=Dl();return n.forEach(((c,h)=>{const f=a.get(c);h.isFoundDocument()!==f.isFoundDocument()&&(i=i.add(c)),h.isNoDocument()&&h.version.isEqual(sr.min())?(t.removeEntry(c,h.readTime),o=o.insert(c,h)):!f.isValidDocument()||h.version.compareTo(f.version)>0||h.version.compareTo(f.version)===0&&f.hasPendingWrites?(t.addEntry(h),o=o.insert(c,h)):qt(oT,"Ignoring outdated watch update for ",c,". Current version:",f.version," Watch version:",h.version)})),{Bs:o,Ls:i}}))}function ude(e,t){const n=Vn(e);return n.persistence.runTransaction("Get next mutation batch","readonly",(r=>(t===void 0&&(t=Dp),n.mutationQueue.getNextMutationBatchAfterBatchId(r,t))))}function A2(e,t){const n=Vn(e);return n.persistence.runTransaction("Allocate target","readwrite",(r=>{let i;return n.li.getTargetData(r,t).next((a=>a?(i=a,Xe.resolve(i)):n.li.allocateTargetId(r).next((o=>(i=new Pd(t,o,"TargetPurposeListen",r.currentSequenceNumber),n.li.addTargetData(r,i).next((()=>i)))))))})).then((r=>{const i=n.vs.get(r.targetId);return(i===null||r.snapshotVersion.compareTo(i.snapshotVersion)>0)&&(n.vs=n.vs.insert(r.targetId,r),n.Fs.set(t,r.targetId)),r}))}async function vg(e,t,n){const r=Vn(e),i=r.vs.get(t),a=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",a,(o=>r.persistence.referenceDelegate.removeTarget(o,i)))}catch(o){if(!Af(o))throw o;qt(oT,`Failed to update sequence numbers for target ${t}: ${o}`)}r.vs=r.vs.remove(t),r.Fs.delete(i.target)}function bC(e,t,n){const r=Vn(e);let i=sr.min(),a=Kr();return r.persistence.runTransaction("Execute query","readwrite",(o=>(function(h,f,m){const y=Vn(h),w=y.Fs.get(m);return w!==void 0?Xe.resolve(y.vs.get(w)):y.li.getTargetData(f,m)})(r,o,Ul(t)).next((c=>{if(c)return i=c.lastLimboFreeSnapshotVersion,r.li.getMatchingKeysForTargetId(o,c.targetId).next((h=>{a=h}))})).next((()=>r.Cs.getDocumentsMatchingQuery(o,t,n?i:sr.min(),n?a:Kr()))).next((c=>(nG(r,aH(t),c),{documents:c,ks:a})))))}function eG(e,t){const n=Vn(e),r=Vn(n.li),i=n.vs.get(t);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(a=>r.At(a,t).next((o=>o?o.target:null))))}function tG(e,t){const n=Vn(e),r=n.Ms.get(t)||sr.min();return n.persistence.runTransaction("Get new document changes","readonly",(i=>n.xs.getAllFromCollectionGroup(i,t,E$(r,lg),Number.MAX_SAFE_INTEGER))).then((i=>(nG(n,t,i),i)))}function nG(e,t,n){let r=e.Ms.get(t)||sr.min();n.forEach(((i,a)=>{a.readTime.compareTo(r)>0&&(r=a.readTime)})),e.Ms.set(t,r)}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const rG="firestore_clients";function OD(e,t){return`${rG}_${e}_${t}`}const iG="firestore_mutations";function RD(e,t,n){let r=`${iG}_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}const sG="firestore_targets";function h_(e,t){return`${sG}_${e}_${t}`}/** * @license * Copyright 2018 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Eu="SharedClientState";class _2{constructor(t,n,r,i){this.user=t,this.batchId=n,this.state=r,this.error=i}static $s(t,n,r){const i=JSON.parse(r);let a,o=typeof i=="object"&&["pending","acknowledged","rejected"].indexOf(i.state)!==-1&&(i.error===void 0||typeof i.error=="object");return o&&i.error&&(o=typeof i.error.message=="string"&&typeof i.error.code=="string",o&&(a=new sn(i.error.code,i.error.message))),o?new _2(t,n,i.state,a):(ta(Eu,`Failed to parse mutation state for ID '${n}': ${r}`),null)}Ws(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class z1{constructor(t,n,r){this.targetId=t,this.state=n,this.error=r}static $s(t,n){const r=JSON.parse(n);let i,a=typeof r=="object"&&["not-current","current","rejected"].indexOf(r.state)!==-1&&(r.error===void 0||typeof r.error=="object");return a&&r.error&&(a=typeof r.error.message=="string"&&typeof r.error.code=="string",a&&(i=new sn(r.error.code,r.error.message))),a?new z1(t,r.state,i):(ta(Eu,`Failed to parse target state for ID '${t}': ${n}`),null)}Ws(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class k2{constructor(t,n){this.clientId=t,this.activeTargetIds=n}static $s(t,n){const r=JSON.parse(n);let i=typeof r=="object"&&r.activeTargetIds instanceof Array,a=WI();for(let o=0;i&&othis.shutdown())),this.started=!0}writeSequenceNumber(t){this.setItem(this.Ys,JSON.stringify(t))}getAllActiveQueryTargets(){return this.uo(this.Hs)}isActiveQueryTarget(t){let n=!1;return this.Hs.forEach(((r,i)=>{i.activeTargetIds.has(t)&&(n=!0)})),n}addPendingMutation(t){this.co(t,"pending")}updateMutationState(t,n,r){this.co(t,n,r),this.lo(t)}addLocalQueryTarget(t,n=!0){let r="not-current";if(this.isActiveQueryTarget(t)){const i=this.storage.getItem(h_(this.persistenceKey,t));if(i){const a=z1.$s(t,i);a&&(r=a.state)}}return n&&this.ho.Qs(t),this.oo(),r}removeLocalQueryTarget(t){this.ho.Gs(t),this.oo()}isLocalQueryTarget(t){return this.ho.activeTargetIds.has(t)}clearQueryState(t){this.removeItem(h_(this.persistenceKey,t))}updateQueryState(t,n,r){this.Po(t,n,r)}handleUserChange(t,n,r){n.forEach((i=>{this.lo(i)})),this.currentUser=t,r.forEach((i=>{this.addPendingMutation(i)}))}setOnlineState(t){this.To(t)}notifyBundleLoaded(t){this.Eo(t)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.js),this.removeItem(this.Xs),this.started=!1)}getItem(t){const n=this.storage.getItem(t);return qt(Eu,"READ",t,n),n}setItem(t,n){qt(Eu,"SET",t,n),this.storage.setItem(t,n)}removeItem(t){qt(Eu,"REMOVE",t),this.storage.removeItem(t)}Js(t){const n=t;if(n.storageArea===this.storage){if(qt(Eu,"EVENT",n.key,n.newValue),n.key===this.Xs)return void ta("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Ci.enqueueRetryable((async()=>{if(this.started){if(n.key!==null){if(this.eo.test(n.key)){if(n.newValue==null){const r=this.Io(n.key);return this.Ro(r,null)}{const r=this.Ao(n.key,n.newValue);if(r)return this.Ro(r.clientId,r)}}else if(this.no.test(n.key)){if(n.newValue!==null){const r=this.Vo(n.key,n.newValue);if(r)return this.mo(r)}}else if(this.ro.test(n.key)){if(n.newValue!==null){const r=this.fo(n.key,n.newValue);if(r)return this.po(r)}}else if(n.key===this.io){if(n.newValue!==null){const r=this._o(n.newValue);if(r)return this.ao(r)}}else if(n.key===this.Ys){const r=(function(a){let o=ml.ce;if(a!=null)try{const c=JSON.parse(a);Xn(typeof c=="number",30636,{yo:a}),o=c}catch(c){ta(Eu,"Failed to read sequence number from WebStorage",c)}return o})(n.newValue);r!==ml.ce&&this.sequenceNumberHandler(r)}else if(n.key===this.so){const r=this.wo(n.newValue);await Promise.all(r.map((i=>this.syncEngine.So(i))))}}}else this.Zs.push(n)}))}}get ho(){return this.Hs.get(this.zs)}oo(){this.setItem(this.Xs,this.ho.Ws())}co(t,n,r){const i=new _2(this.currentUser,t,n,r),a=RD(this.persistenceKey,this.currentUser,t);this.setItem(a,i.Ws())}lo(t){const n=RD(this.persistenceKey,this.currentUser,t);this.removeItem(n)}To(t){const n={clientId:this.zs,onlineState:t};this.storage.setItem(this.io,JSON.stringify(n))}Po(t,n,r){const i=h_(this.persistenceKey,t),a=new z1(t,n,r);this.setItem(i,a.Ws())}Eo(t){const n=JSON.stringify(Array.from(t));this.setItem(this.so,n)}Io(t){const n=this.eo.exec(t);return n?n[1]:null}Ao(t,n){const r=this.Io(t);return k2.$s(r,n)}Vo(t,n){const r=this.no.exec(t),i=Number(r[1]),a=r[2]!==void 0?r[2]:null;return _2.$s(new wo(a),i,n)}fo(t,n){const r=this.ro.exec(t),i=Number(r[1]);return z1.$s(i,n)}_o(t){return lT.$s(t)}wo(t){return JSON.parse(t)}async mo(t){if(t.user.uid===this.currentUser.uid)return this.syncEngine.bo(t.batchId,t.state,t.error);qt(Eu,`Ignoring mutation for non-active user ${t.user.uid}`)}po(t){return this.syncEngine.Do(t.targetId,t.state,t.error)}Ro(t,n){const r=n?this.Hs.insert(t,n):this.Hs.remove(t),i=this.uo(this.Hs),a=this.uo(r),o=[],c=[];return a.forEach((h=>{i.has(h)||o.push(h)})),i.forEach((h=>{a.has(h)||c.push(h)})),this.syncEngine.Co(o,c).then((()=>{this.Hs=r}))}ao(t){this.Hs.get(t.clientId)&&this.onlineStateHandler(t.onlineState)}uo(t){let n=WI();return t.forEach(((r,i)=>{n=n.unionWith(i.activeTargetIds)})),n}}class aG{constructor(){this.vo=new vC,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,n,r){}addLocalQueryTarget(t,n=!0){return n&&this.vo.Qs(t),this.Fo[t]||"not-current"}updateQueryState(t,n,r){this.Fo[t]=n}removeLocalQueryTarget(t){this.vo.Gs(t)}isLocalQueryTarget(t){return this.vo.activeTargetIds.has(t)}clearQueryState(t){delete this.Fo[t]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(t){return this.vo.activeTargetIds.has(t)}start(){return this.vo=new vC,Promise.resolve()}handleUserChange(t,n,r){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class dde{Mo(t){}shutdown(){}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const DD="ConnectivityMonitor";class MD{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(t){this.Lo.push(t)}shutdown(){window.removeEventListener("online",this.xo),window.removeEventListener("offline",this.No)}ko(){window.addEventListener("online",this.xo),window.addEventListener("offline",this.No)}Oo(){qt(DD,"Network connectivity changed: AVAILABLE");for(const t of this.Lo)t(0)}Bo(){qt(DD,"Network connectivity changed: UNAVAILABLE");for(const t of this.Lo)t(1)}static v(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/** * @license * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */let Bv=null;function wC(){return Bv===null?Bv=(function(){return 268435456+Math.round(2147483648*Math.random())})():Bv++,"0x"+Bv.toString(16)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const p_="RestConnection",hde={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class fde{get qo(){return!1}constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const n=t.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),i=encodeURIComponent(this.databaseId.database);this.Ko=n+"://"+t.host,this.Uo=`projects/${r}/databases/${i}`,this.$o=this.databaseId.database===sC?`project_id=${r}`:`project_id=${r}&database_id=${i}`}Wo(t,n,r,i,a){const o=wC(),c=this.Qo(t,n.toUriEncodedString());qt(p_,`Sending RPC '${t}' ${o}:`,c,r);const h={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(h,i,a);const{host:f}=new URL(c),m=Ly(f);return this.zo(t,c,h,r,m).then((y=>(qt(p_,`Received RPC '${t}' ${o}: `,y),y)),(y=>{throw ag(p_,`RPC '${t}' ${o} failed with error: `,y,"url: ",c,"request:",r),y}))}jo(t,n,r,i,a,o){return this.Wo(t,n,r,i,a)}Go(t,n,r){t["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+Bg})(),t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),n&&n.headers.forEach(((i,a)=>t[a]=i)),r&&r.headers.forEach(((i,a)=>t[a]=i))}Qo(t,n){const r=hde[t];let i=`${this.Ko}/v1/${n}:${r}`;return this.databaseInfo.apiKey&&(i=`${i}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),i}terminate(){}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class pde{constructor(t){this.Jo=t.Jo,this.Ho=t.Ho}Zo(t){this.Xo=t}Yo(t){this.e_=t}t_(t){this.n_=t}onMessage(t){this.r_=t}close(){this.Ho()}send(t){this.Jo(t)}i_(){this.Xo()}s_(){this.e_()}o_(t){this.n_(t)}__(t){this.r_(t)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const bo="WebChannelConnection",Kx=(e,t,n)=>{e.listen(t,(r=>{try{n(r)}catch(i){setTimeout((()=>{throw i}),0)}}))};class K0 extends fde{constructor(t){super(t),this.a_=[],this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams,this.longPollingOptions=t.longPollingOptions}static u_(){if(!K0.c_){const t=y$();Kx(t,x$.STAT_EVENT,(n=>{n.stat===ZS.PROXY?qt(bo,"STAT_EVENT: detected buffering proxy"):n.stat===ZS.NOPROXY&&qt(bo,"STAT_EVENT: detected no buffering proxy")})),K0.c_=!0}}zo(t,n,r,i,a){const o=wC();return new Promise(((c,h)=>{const f=new m$;f.setWithCredentials(!0),f.listenOnce(g$.COMPLETE,(()=>{try{switch(f.getLastErrorCode()){case kw.NO_ERROR:const y=f.getResponseJson();qt(bo,`XHR for RPC '${t}' ${o} received:`,JSON.stringify(y)),c(y);break;case kw.TIMEOUT:qt(bo,`RPC '${t}' ${o} timed out`),h(new sn(vt.DEADLINE_EXCEEDED,"Request time out"));break;case kw.HTTP_ERROR:const w=f.getStatus();if(qt(bo,`RPC '${t}' ${o} failed with status:`,w,"response text:",f.getResponseText()),w>0){let A=f.getResponseJson();Array.isArray(A)&&(A=A[0]);const S=A==null?void 0:A.error;if(S&&S.status&&S.message){const C=(function(D){const V=D.toLowerCase().replace(/_/g,"-");return Object.values(vt).indexOf(V)>=0?V:vt.UNKNOWN})(S.status);h(new sn(C,S.message))}else h(new sn(vt.UNKNOWN,"Server responded with status "+f.getStatus()))}else h(new sn(vt.UNAVAILABLE,"Connection failed."));break;default:Tn(9055,{l_:t,streamId:o,h_:f.getLastErrorCode(),P_:f.getLastError()})}}finally{qt(bo,`RPC '${t}' ${o} completed.`)}}));const m=JSON.stringify(i);qt(bo,`RPC '${t}' ${o} sending request:`,i),f.send(n,"POST",m,r,15)}))}T_(t,n,r){const i=wC(),a=[this.Ko,"/","google.firestore.v1.Firestore","/",t,"/channel"],o=this.createWebChannelTransport(),c={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},h=this.longPollingOptions.timeoutSeconds;h!==void 0&&(c.longPollingTimeout=Math.round(1e3*h)),this.useFetchStreams&&(c.useFetchStreams=!0),this.Go(c.initMessageHeaders,n,r),c.encodeInitMessageHeaders=!0;const f=a.join("");qt(bo,`Creating RPC '${t}' stream ${i}: ${f}`,c);const m=o.createWebChannel(f,c);this.E_(m);let y=!1,w=!1;const A=new pde({Jo:S=>{w?qt(bo,`Not sending because RPC '${t}' stream ${i} is closed:`,S):(y||(qt(bo,`Opening RPC '${t}' stream ${i} transport.`),m.open(),y=!0),qt(bo,`RPC '${t}' stream ${i} sending:`,S),m.send(S))},Ho:()=>m.close()});return Kx(m,y1.EventType.OPEN,(()=>{w||(qt(bo,`RPC '${t}' stream ${i} transport opened.`),A.i_())})),Kx(m,y1.EventType.CLOSE,(()=>{w||(w=!0,qt(bo,`RPC '${t}' stream ${i} transport closed`),A.o_(),this.I_(m))})),Kx(m,y1.EventType.ERROR,(S=>{w||(w=!0,ag(bo,`RPC '${t}' stream ${i} transport errored. Name:`,S.name,"Message:",S.message),A.o_(new sn(vt.UNAVAILABLE,"The operation could not be completed")))})),Kx(m,y1.EventType.MESSAGE,(S=>{var C;if(!w){const T=S.data[0];Xn(!!T,16349);const D=T,V=(D==null?void 0:D.error)||((C=D[0])==null?void 0:C.error);if(V){qt(bo,`RPC '${t}' stream ${i} received error:`,V);const L=V.status;let K=(function(B){const z=la[B];if(z!==void 0)return vH(z)})(L),Z=V.message;L==="NOT_FOUND"&&Z.includes("database")&&Z.includes("does not exist")&&Z.includes(this.databaseId.database)&&ag(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),K===void 0&&(K=vt.INTERNAL,Z="Unknown error status: "+L+" with message "+V.message),w=!0,A.o_(new sn(K,Z)),m.close()}else qt(bo,`RPC '${t}' stream ${i} received:`,T),A.__(T)}})),K0.u_(),setTimeout((()=>{A.s_()}),0),A}terminate(){this.a_.forEach((t=>t.close())),this.a_=[]}E_(t){this.a_.push(t)}I_(t){this.a_=this.a_.filter((n=>n===t))}Go(t,n,r){super.Go(t,n,r),this.databaseInfo.apiKey&&(t["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return b$()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function mde(e){return new K0(e)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function oG(){return typeof window<"u"?window:null}function Mw(){return typeof document<"u"?document:null}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function NE(e){return new vue(e,!0)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */K0.c_=!1;class lG{constructor(t,n,r=1e3,i=1.5,a=6e4){this.Ci=t,this.timerId=n,this.R_=r,this.A_=i,this.V_=a,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(t){this.cancel();const n=Math.floor(this.d_+this.y_()),r=Math.max(0,Date.now()-this.f_),i=Math.max(0,n-r);i>0&&qt("ExponentialBackoff",`Backing off for ${i} ms (base delay: ${this.d_} ms, delay with jitter: ${n} ms, last attempt: ${r} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,i,(()=>(this.f_=Date.now(),t()))),this.d_*=this.A_,this.d_this.V_&&(this.d_=this.V_)}w_(){this.m_!==null&&(this.m_.skipDelay(),this.m_=null)}cancel(){this.m_!==null&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.d_}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const LD="PersistentStream";class cG{constructor(t,n,r,i,a,o,c,h){this.Ci=t,this.S_=r,this.b_=i,this.connection=a,this.authCredentialsProvider=o,this.appCheckCredentialsProvider=c,this.listener=h,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new lG(t,n)}x_(){return this.state===1||this.state===5||this.O_()}O_(){return this.state===2||this.state===3}start(){this.F_=0,this.state!==4?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&this.C_===null&&(this.C_=this.Ci.enqueueAfterDelay(this.S_,6e4,(()=>this.k_())))}q_(t){this.K_(),this.stream.send(t)}async k_(){if(this.O_())return this.close(0)}K_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(t,n){this.K_(),this.U_(),this.M_.cancel(),this.D_++,t!==4?this.M_.reset():n&&n.code===vt.RESOURCE_EXHAUSTED?(ta(n.toString()),ta("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):n&&n.code===vt.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.W_(),this.stream.close(),this.stream=null),this.state=t,await this.listener.t_(n)}W_(){}auth(){this.state=1;const t=this.Q_(this.D_),n=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([r,i])=>{this.D_===n&&this.G_(r,i)}),(r=>{t((()=>{const i=new sn(vt.UNKNOWN,"Fetching auth token failed: "+r.message);return this.z_(i)}))}))}G_(t,n){const r=this.Q_(this.D_);this.stream=this.j_(t,n),this.stream.Zo((()=>{r((()=>this.listener.Zo()))})),this.stream.Yo((()=>{r((()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.b_,1e4,(()=>(this.O_()&&(this.state=3),Promise.resolve()))),this.listener.Yo())))})),this.stream.t_((i=>{r((()=>this.z_(i)))})),this.stream.onMessage((i=>{r((()=>++this.F_==1?this.J_(i):this.onNext(i)))}))}N_(){this.state=5,this.M_.p_((async()=>{this.state=0,this.start()}))}z_(t){return qt(LD,`close with error: ${t}`),this.stream=null,this.close(4,t)}Q_(t){return n=>{this.Ci.enqueueAndForget((()=>this.D_===t?n():(qt(LD,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class gde extends cG{constructor(t,n,r,i,a,o){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",n,r,i,o),this.serializer=a}j_(t,n){return this.connection.T_("Listen",t,n)}J_(t){return this.onNext(t)}onNext(t){this.M_.reset();const n=Eue(this.serializer,t),r=(function(a){if(!("targetChange"in a))return sr.min();const o=a.targetChange;return o.targetIds&&o.targetIds.length?sr.min():o.readTime?Wo(o.readTime):sr.min()})(t);return this.listener.H_(n,r)}Z_(t){const n={};n.database=pC(this.serializer),n.addTarget=(function(a,o){let c;const h=o.target;if(c=m2(h)?{documents:CH(a,h)}:{query:eT(a,h).ft},c.targetId=o.targetId,o.resumeToken.approximateByteSize()>0){c.resumeToken=EH(a,o.resumeToken);const f=hC(a,o.expectedCount);f!==null&&(c.expectedCount=f)}else if(o.snapshotVersion.compareTo(sr.min())>0){c.readTime=bg(a,o.snapshotVersion.toTimestamp());const f=hC(a,o.expectedCount);f!==null&&(c.expectedCount=f)}return c})(this.serializer,t);const r=kue(this.serializer,t);r&&(n.labels=r),this.q_(n)}X_(t){const n={};n.database=pC(this.serializer),n.removeTarget=t,this.q_(n)}}class xde extends cG{constructor(t,n,r,i,a,o){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",n,r,i,o),this.serializer=a}get Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(t,n){return this.connection.T_("Write",t,n)}J_(t){return Xn(!!t.streamToken,31322),this.lastStreamToken=t.streamToken,Xn(!t.writeResults||t.writeResults.length===0,55816),this.listener.ta()}onNext(t){Xn(!!t.streamToken,12678),this.lastStreamToken=t.streamToken,this.M_.reset();const n=Aue(t.writeResults,t.commitTime),r=Wo(t.commitTime);return this.listener.na(r,n)}ra(){const t={};t.database=pC(this.serializer),this.q_(t)}ea(t){const n={streamToken:this.lastStreamToken,writes:t.map((r=>b2(this.serializer,r)))};this.q_(n)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class yde{}class bde extends yde{constructor(t,n,r,i){super(),this.authCredentials=t,this.appCheckCredentials=n,this.connection=r,this.serializer=i,this.ia=!1}sa(){if(this.ia)throw new sn(vt.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(t,n,r,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,o])=>this.connection.Wo(t,fC(n,r),i,a,o))).catch((a=>{throw a.name==="FirebaseError"?(a.code===vt.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new sn(vt.UNKNOWN,a.toString())}))}jo(t,n,r,i,a){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([o,c])=>this.connection.jo(t,fC(n,r),i,o,c,a))).catch((o=>{throw o.name==="FirebaseError"?(o.code===vt.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new sn(vt.UNKNOWN,o.toString())}))}terminate(){this.ia=!0,this.connection.terminate()}}function vde(e,t,n,r){return new bde(e,t,n,r)}class wde{constructor(t,n){this.asyncQueue=t,this.onlineStateHandler=n,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){this.oa===0&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve()))))}ha(t){this.state==="Online"?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${t.toString()}`),this.ca("Offline")))}set(t){this.Pa(),this.oa=0,t==="Online"&&(this.aa=!1),this.ca(t)}ca(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))}la(t){const n=`Could not reach Cloud Firestore backend. ${t} This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.aa?(ta(n),this.aa=!1):qt("OnlineStateTracker",n)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const om="RemoteStore";class Nde{constructor(t,n,r,i,a){this.localStore=t,this.datastore=n,this.asyncQueue=r,this.remoteSyncer={},this.Ta=[],this.Ea=new Map,this.Ia=new Set,this.Ra=[],this.Aa=a,this.Aa.Mo((o=>{r.enqueueAndForget((async()=>{bm(this)&&(qt(om,"Restarting streams for network reachability change."),await(async function(h){const f=Vn(h);f.Ia.add(4),await Xy(f),f.Va.set("Unknown"),f.Ia.delete(4),await EE(f)})(this))}))})),this.Va=new wde(r,i)}}async function EE(e){if(bm(e))for(const t of e.Ra)await t(!0)}async function Xy(e){for(const t of e.Ra)await t(!1)}function AE(e,t){const n=Vn(e);n.Ea.has(t.targetId)||(n.Ea.set(t.targetId,t),dT(n)?uT(n):Fg(n).O_()&&cT(n,t))}function wg(e,t){const n=Vn(e),r=Fg(n);n.Ea.delete(t),r.O_()&&uG(n,t),n.Ea.size===0&&(r.O_()?r.L_():bm(n)&&n.Va.set("Unknown"))}function cT(e,t){if(e.da.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(sr.min())>0){const n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}Fg(e).Z_(t)}function uG(e,t){e.da.$e(t),Fg(e).X_(t)}function uT(e){e.da=new gue({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),At:t=>e.Ea.get(t)||null,ht:()=>e.datastore.serializer.databaseId}),Fg(e).start(),e.Va.ua()}function dT(e){return bm(e)&&!Fg(e).x_()&&e.Ea.size>0}function bm(e){return Vn(e).Ia.size===0}function dG(e){e.da=void 0}async function Ede(e){e.Va.set("Online")}async function Ade(e){e.Ea.forEach(((t,n)=>{cT(e,t)}))}async function _de(e,t){dG(e),dT(e)?(e.Va.ha(t),uT(e)):e.Va.set("Unknown")}async function kde(e,t,n){if(e.Va.set("Online"),t instanceof NH&&t.state===2&&t.cause)try{await(async function(i,a){const o=a.cause;for(const c of a.targetIds)i.Ea.has(c)&&(await i.remoteSyncer.rejectListen(c,o),i.Ea.delete(c),i.da.removeTarget(c))})(e,t)}catch(r){qt(om,"Failed to remove targets %s: %s ",t.targetIds.join(","),r),await S2(e,r)}else if(t instanceof Rw?e.da.Xe(t):t instanceof wH?e.da.st(t):e.da.tt(t),!n.isEqual(sr.min()))try{const r=await JH(e.localStore);n.compareTo(r)>=0&&await(function(a,o){const c=a.da.Tt(o);return c.targetChanges.forEach(((h,f)=>{if(h.resumeToken.approximateByteSize()>0){const m=a.Ea.get(f);m&&a.Ea.set(f,m.withResumeToken(h.resumeToken,o))}})),c.targetMismatches.forEach(((h,f)=>{const m=a.Ea.get(h);if(!m)return;a.Ea.set(h,m.withResumeToken(na.EMPTY_BYTE_STRING,m.snapshotVersion)),uG(a,h);const y=new Pd(m.target,h,f,m.sequenceNumber);cT(a,y)})),a.remoteSyncer.applyRemoteEvent(c)})(e,n)}catch(r){qt(om,"Failed to raise snapshot:",r),await S2(e,r)}}async function S2(e,t,n){if(!Af(t))throw t;e.Ia.add(1),await Xy(e),e.Va.set("Offline"),n||(n=()=>JH(e.localStore)),e.asyncQueue.enqueueRetryable((async()=>{qt(om,"Retrying IndexedDB access"),await n(),e.Ia.delete(1),await EE(e)}))}function hG(e,t){return t().catch((n=>S2(e,n,t)))}async function Vg(e){const t=Vn(e),n=mf(t);let r=t.Ta.length>0?t.Ta[t.Ta.length-1].batchId:Dp;for(;Sde(t);)try{const i=await ude(t.localStore,r);if(i===null){t.Ta.length===0&&n.L_();break}r=i.batchId,Cde(t,i)}catch(i){await S2(t,i)}fG(t)&&pG(t)}function Sde(e){return bm(e)&&e.Ta.length<10}function Cde(e,t){e.Ta.push(t);const n=mf(e);n.O_()&&n.Y_&&n.ea(t.mutations)}function fG(e){return bm(e)&&!mf(e).x_()&&e.Ta.length>0}function pG(e){mf(e).start()}async function jde(e){mf(e).ra()}async function Ide(e){const t=mf(e);for(const n of e.Ta)t.ea(n.mutations)}async function Tde(e,t,n){const r=e.Ta.shift(),i=XI.from(r,t,n);await hG(e,(()=>e.remoteSyncer.applySuccessfulWrite(i))),await Vg(e)}async function Pde(e,t){t&&mf(e).Y_&&await(async function(r,i){if((function(o){return fue(o)&&o!==vt.ABORTED})(i.code)){const a=r.Ta.shift();mf(r).B_(),await hG(r,(()=>r.remoteSyncer.rejectFailedWrite(a.batchId,i))),await Vg(r)}})(e,t),fG(e)&&pG(e)}async function UD(e,t){const n=Vn(e);n.asyncQueue.verifyOperationInProgress(),qt(om,"RemoteStore received new credentials");const r=bm(n);n.Ia.add(3),await Xy(n),r&&n.Va.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.Ia.delete(3),await EE(n)}async function NC(e,t){const n=Vn(e);t?(n.Ia.delete(2),await EE(n)):t||(n.Ia.add(2),await Xy(n),n.Va.set("Unknown"))}function Fg(e){return e.ma||(e.ma=(function(n,r,i){const a=Vn(n);return a.sa(),new gde(r,a.connection,a.authCredentials,a.appCheckCredentials,a.serializer,i)})(e.datastore,e.asyncQueue,{Zo:Ede.bind(null,e),Yo:Ade.bind(null,e),t_:_de.bind(null,e),H_:kde.bind(null,e)}),e.Ra.push((async t=>{t?(e.ma.B_(),dT(e)?uT(e):e.Va.set("Unknown")):(await e.ma.stop(),dG(e))}))),e.ma}function mf(e){return e.fa||(e.fa=(function(n,r,i){const a=Vn(n);return a.sa(),new xde(r,a.connection,a.authCredentials,a.appCheckCredentials,a.serializer,i)})(e.datastore,e.asyncQueue,{Zo:()=>Promise.resolve(),Yo:jde.bind(null,e),t_:Pde.bind(null,e),ta:Ide.bind(null,e),na:Tde.bind(null,e)}),e.Ra.push((async t=>{t?(e.fa.B_(),await Vg(e)):(await e.fa.stop(),e.Ta.length>0&&(qt(om,`Stopping write stream with ${e.Ta.length} pending writes`),e.Ta=[]))}))),e.fa}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class hT{constructor(t,n,r,i,a){this.asyncQueue=t,this.timerId=n,this.targetTimeMs=r,this.op=i,this.removalCallback=a,this.deferred=new Hc,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((o=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(t,n,r,i,a){const o=Date.now()+r,c=new hT(t,n,o,i,a);return c.start(r),c}start(t){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new sn(vt.CANCELLED,"Operation cancelled"+(t?": "+t:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then((t=>this.deferred.resolve(t)))):Promise.resolve()))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function fT(e,t){if(ta("AsyncQueue",`${t}: ${e}`),Af(e))return new sn(vt.UNAVAILABLE,`${t}: ${e}`);throw e}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Y0{static emptySet(t){return new Y0(t.comparator)}constructor(t){this.comparator=t?(n,r)=>t(n,r)||gn.comparator(n.key,r.key):(n,r)=>gn.comparator(n.key,r.key),this.keyedMap=b1(),this.sortedSet=new ds(this.comparator)}has(t){return this.keyedMap.get(t)!=null}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){const n=this.keyedMap.get(t);return n?this.sortedSet.indexOf(n):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal(((n,r)=>(t(n),!1)))}add(t){const n=this.delete(t.key);return n.copy(n.keyedMap.insert(t.key,t),n.sortedSet.insert(t,null))}delete(t){const n=this.get(t);return n?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(n)):this}isEqual(t){if(!(t instanceof Y0)||this.size!==t.size)return!1;const n=this.sortedSet.getIterator(),r=t.sortedSet.getIterator();for(;n.hasNext();){const i=n.getNext().key,a=r.getNext().key;if(!i.isEqual(a))return!1}return!0}toString(){const t=[];return this.forEach((n=>{t.push(n.toString())})),t.length===0?"DocumentSet ()":`DocumentSet ( `+t.join(` `)+` )`}copy(t,n){const r=new Y0;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class BD{constructor(){this.ga=new ds(gn.comparator)}track(t){const n=t.doc.key,r=this.ga.get(n);r?t.type!==0&&r.type===3?this.ga=this.ga.insert(n,t):t.type===3&&r.type!==1?this.ga=this.ga.insert(n,{type:r.type,doc:t.doc}):t.type===2&&r.type===2?this.ga=this.ga.insert(n,{type:2,doc:t.doc}):t.type===2&&r.type===0?this.ga=this.ga.insert(n,{type:0,doc:t.doc}):t.type===1&&r.type===0?this.ga=this.ga.remove(n):t.type===1&&r.type===2?this.ga=this.ga.insert(n,{type:1,doc:r.doc}):t.type===0&&r.type===1?this.ga=this.ga.insert(n,{type:2,doc:t.doc}):Tn(63341,{Vt:t,pa:r}):this.ga=this.ga.insert(n,t)}ya(){const t=[];return this.ga.inorderTraversal(((n,r)=>{t.push(r)})),t}}class Ng{constructor(t,n,r,i,a,o,c,h,f){this.query=t,this.docs=n,this.oldDocs=r,this.docChanges=i,this.mutatedKeys=a,this.fromCache=o,this.syncStateChanged=c,this.excludesMetadataChanges=h,this.hasCachedResults=f}static fromInitialDocuments(t,n,r,i,a){const o=[];return n.forEach((c=>{o.push({type:0,doc:c})})),new Ng(t,n,Y0.emptySet(n),o,r,i,!0,!1,a)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.hasCachedResults===t.hasCachedResults&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&mE(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;const n=this.docChanges,r=t.docChanges;if(n.length!==r.length)return!1;for(let i=0;it.Da()))}}class Rde{constructor(){this.queries=zD(),this.onlineState="Unknown",this.Ca=new Set}terminate(){(function(n,r){const i=Vn(n),a=i.queries;i.queries=zD(),a.forEach(((o,c)=>{for(const h of c.Sa)h.onError(r)}))})(this,new sn(vt.ABORTED,"Firestore shutting down"))}}function zD(){return new Zd((e=>sH(e)),mE)}async function pT(e,t){const n=Vn(e);let r=3;const i=t.query;let a=n.queries.get(i);a?!a.ba()&&t.Da()&&(r=2):(a=new Ode,r=t.Da()?0:1);try{switch(r){case 0:a.wa=await n.onListen(i,!0);break;case 1:a.wa=await n.onListen(i,!1);break;case 2:await n.onFirstRemoteStoreListen(i)}}catch(o){const c=fT(o,`Initialization of query '${I0(t.query)}' failed`);return void t.onError(c)}n.queries.set(i,a),a.Sa.push(t),t.va(n.onlineState),a.wa&&t.Fa(a.wa)&&gT(n)}async function mT(e,t){const n=Vn(e),r=t.query;let i=3;const a=n.queries.get(r);if(a){const o=a.Sa.indexOf(t);o>=0&&(a.Sa.splice(o,1),a.Sa.length===0?i=t.Da()?0:1:!a.ba()&&t.Da()&&(i=2))}switch(i){case 0:return n.queries.delete(r),n.onUnlisten(r,!0);case 1:return n.queries.delete(r),n.onUnlisten(r,!1);case 2:return n.onLastRemoteStoreUnlisten(r);default:return}}function Dde(e,t){const n=Vn(e);let r=!1;for(const i of t){const a=i.query,o=n.queries.get(a);if(o){for(const c of o.Sa)c.Fa(i)&&(r=!0);o.wa=i}}r&&gT(n)}function Mde(e,t,n){const r=Vn(e),i=r.queries.get(t);if(i)for(const a of i.Sa)a.onError(n);r.queries.delete(t)}function gT(e){e.Ca.forEach((t=>{t.next()}))}var EC,VD;(VD=EC||(EC={})).Ma="default",VD.Cache="cache";class xT{constructor(t,n,r){this.query=t,this.xa=n,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=r||{}}Fa(t){if(!this.options.includeMetadataChanges){const r=[];for(const i of t.docChanges)i.type!==3&&r.push(i);t=new Ng(t.query,t.docs,t.oldDocs,r,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0,t.hasCachedResults)}let n=!1;return this.Oa?this.Ba(t)&&(this.xa.next(t),n=!0):this.La(t,this.onlineState)&&(this.ka(t),n=!0),this.Na=t,n}onError(t){this.xa.error(t)}va(t){this.onlineState=t;let n=!1;return this.Na&&!this.Oa&&this.La(this.Na,t)&&(this.ka(this.Na),n=!0),n}La(t,n){if(!t.fromCache||!this.Da())return!0;const r=n!=="Offline";return(!this.options.qa||!r)&&(!t.docs.isEmpty()||t.hasCachedResults||n==="Offline")}Ba(t){if(t.docChanges.length>0)return!0;const n=this.Na&&this.Na.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!n)&&this.options.includeMetadataChanges===!0}ka(t){t=Ng.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache,t.hasCachedResults),this.Oa=!0,this.xa.next(t)}Da(){return this.options.source!==EC.Cache}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class mG{constructor(t){this.key=t}}class gG{constructor(t){this.key=t}}class Lde{constructor(t,n){this.query=t,this.Za=n,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=Kr(),this.mutatedKeys=Kr(),this.eu=oH(t),this.tu=new Y0(this.eu)}get nu(){return this.Za}ru(t,n){const r=n?n.iu:new BD,i=n?n.tu:this.tu;let a=n?n.mutatedKeys:this.mutatedKeys,o=i,c=!1;const h=this.query.limitType==="F"&&i.size===this.query.limit?i.last():null,f=this.query.limitType==="L"&&i.size===this.query.limit?i.first():null;if(t.inorderTraversal(((m,y)=>{const w=i.get(m),A=qy(this.query,y)?y:null,S=!!w&&this.mutatedKeys.has(w.key),C=!!A&&(A.hasLocalMutations||this.mutatedKeys.has(A.key)&&A.hasCommittedMutations);let T=!1;w&&A?w.data.isEqual(A.data)?S!==C&&(r.track({type:3,doc:A}),T=!0):this.su(w,A)||(r.track({type:2,doc:A}),T=!0,(h&&this.eu(A,h)>0||f&&this.eu(A,f)<0)&&(c=!0)):!w&&A?(r.track({type:0,doc:A}),T=!0):w&&!A&&(r.track({type:1,doc:w}),T=!0,(h||f)&&(c=!0)),T&&(A?(o=o.add(A),a=C?a.add(m):a.delete(m)):(o=o.delete(m),a=a.delete(m)))})),this.query.limit!==null)for(;o.size>this.query.limit;){const m=this.query.limitType==="F"?o.last():o.first();o=o.delete(m.key),a=a.delete(m.key),r.track({type:1,doc:m})}return{tu:o,iu:r,bs:c,mutatedKeys:a}}su(t,n){return t.hasLocalMutations&&n.hasCommittedMutations&&!n.hasLocalMutations}applyChanges(t,n,r,i){const a=this.tu;this.tu=t.tu,this.mutatedKeys=t.mutatedKeys;const o=t.iu.ya();o.sort(((m,y)=>(function(A,S){const C=T=>{switch(T){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Tn(20277,{Vt:T})}};return C(A)-C(S)})(m.type,y.type)||this.eu(m.doc,y.doc))),this.ou(r),i=i??!1;const c=n&&!i?this._u():[],h=this.Ya.size===0&&this.current&&!i?1:0,f=h!==this.Xa;return this.Xa=h,o.length!==0||f?{snapshot:new Ng(this.query,t.tu,a,o,t.mutatedKeys,h===0,f,!1,!!r&&r.resumeToken.approximateByteSize()>0),au:c}:{au:c}}va(t){return this.current&&t==="Offline"?(this.current=!1,this.applyChanges({tu:this.tu,iu:new BD,mutatedKeys:this.mutatedKeys,bs:!1},!1)):{au:[]}}uu(t){return!this.Za.has(t)&&!!this.tu.has(t)&&!this.tu.get(t).hasLocalMutations}ou(t){t&&(t.addedDocuments.forEach((n=>this.Za=this.Za.add(n))),t.modifiedDocuments.forEach((n=>{})),t.removedDocuments.forEach((n=>this.Za=this.Za.delete(n))),this.current=t.current)}_u(){if(!this.current)return[];const t=this.Ya;this.Ya=Kr(),this.tu.forEach((r=>{this.uu(r.key)&&(this.Ya=this.Ya.add(r.key))}));const n=[];return t.forEach((r=>{this.Ya.has(r)||n.push(new gG(r))})),this.Ya.forEach((r=>{t.has(r)||n.push(new mG(r))})),n}cu(t){this.Za=t.ks,this.Ya=Kr();const n=this.ru(t.documents);return this.applyChanges(n,!0)}lu(){return Ng.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Xa===0,this.hasCachedResults)}}const $g="SyncEngine";class Ude{constructor(t,n,r){this.query=t,this.targetId=n,this.view=r}}class Bde{constructor(t){this.key=t,this.hu=!1}}class zde{constructor(t,n,r,i,a,o){this.localStore=t,this.remoteStore=n,this.eventManager=r,this.sharedClientState=i,this.currentUser=a,this.maxConcurrentLimboResolutions=o,this.Pu={},this.Tu=new Zd((c=>sH(c)),mE),this.Eu=new Map,this.Iu=new Set,this.Ru=new ds(gn.comparator),this.Au=new Map,this.Vu=new rT,this.du={},this.mu=new Map,this.fu=am.ar(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return this.gu===!0}}async function Vde(e,t,n=!0){const r=_E(e);let i;const a=r.Tu.get(t);return a?(r.sharedClientState.addLocalQueryTarget(a.targetId),i=a.view.lu()):i=await xG(r,t,n,!0),i}async function Fde(e,t){const n=_E(e);await xG(n,t,!0,!1)}async function xG(e,t,n,r){const i=await A2(e.localStore,Ul(t)),a=i.targetId,o=e.sharedClientState.addLocalQueryTarget(a,n);let c;return r&&(c=await yT(e,t,a,o==="current",i.resumeToken)),e.isPrimaryClient&&n&&AE(e.remoteStore,i),c}async function yT(e,t,n,r,i){e.pu=(y,w,A)=>(async function(C,T,D,V){let L=T.view.ru(D);L.bs&&(L=await bC(C.localStore,T.query,!1).then((({documents:B})=>T.view.ru(B,L))));const K=V&&V.targetChanges.get(T.targetId),Z=V&&V.targetMismatches.get(T.targetId)!=null,q=T.view.applyChanges(L,C.isPrimaryClient,K,Z);return AC(C,T.targetId,q.au),q.snapshot})(e,y,w,A);const a=await bC(e.localStore,t,!0),o=new Lde(t,a.ks),c=o.ru(a.documents),h=Yy.createSynthesizedTargetChangeForCurrentChange(n,r&&e.onlineState!=="Offline",i),f=o.applyChanges(c,e.isPrimaryClient,h);AC(e,n,f.au);const m=new Ude(t,n,o);return e.Tu.set(t,m),e.Eu.has(n)?e.Eu.get(n).push(t):e.Eu.set(n,[t]),f.snapshot}async function $de(e,t,n){const r=Vn(e),i=r.Tu.get(t),a=r.Eu.get(i.targetId);if(a.length>1)return r.Eu.set(i.targetId,a.filter((o=>!mE(o,t)))),void r.Tu.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)||await vg(r.localStore,i.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(i.targetId),n&&wg(r.remoteStore,i.targetId),Eg(r,i.targetId)})).catch(Ef)):(Eg(r,i.targetId),await vg(r.localStore,i.targetId,!0))}async function Hde(e,t){const n=Vn(e),r=n.Tu.get(t),i=n.Eu.get(r.targetId);n.isPrimaryClient&&i.length===1&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),wg(n.remoteStore,r.targetId))}async function Gde(e,t,n){const r=NT(e);try{const i=await(function(o,c){const h=Vn(o),f=_r.now(),m=c.reduce(((A,S)=>A.add(S.key)),Kr());let y,w;return h.persistence.runTransaction("Locally write mutations","readwrite",(A=>{let S=Dl(),C=Kr();return h.xs.getEntries(A,m).next((T=>{S=T,S.forEach(((D,V)=>{V.isValidDocument()||(C=C.add(D))}))})).next((()=>h.localDocuments.getOverlayedDocuments(A,S))).next((T=>{y=T;const D=[];for(const V of c){const L=uue(V,y.get(V.key).overlayedDocument);L!=null&&D.push(new Jd(V.key,L,K$(L.value.mapValue),ko.exists(!0)))}return h.mutationQueue.addMutationBatch(A,f,D,c)})).next((T=>{w=T;const D=T.applyToLocalDocumentSet(y,C);return h.documentOverlayCache.saveOverlays(A,T.batchId,D)}))})).then((()=>({batchId:w.batchId,changes:cH(y)})))})(r.localStore,t);r.sharedClientState.addPendingMutation(i.batchId),(function(o,c,h){let f=o.du[o.currentUser.toKey()];f||(f=new ds(Cr)),f=f.insert(c,h),o.du[o.currentUser.toKey()]=f})(r,i.batchId,n),await kf(r,i.changes),await Vg(r.remoteStore)}catch(i){const a=fT(i,"Failed to persist write");n.reject(a)}}async function yG(e,t){const n=Vn(e);try{const r=await lde(n.localStore,t);t.targetChanges.forEach(((i,a)=>{const o=n.Au.get(a);o&&(Xn(i.addedDocuments.size+i.modifiedDocuments.size+i.removedDocuments.size<=1,22616),i.addedDocuments.size>0?o.hu=!0:i.modifiedDocuments.size>0?Xn(o.hu,14607):i.removedDocuments.size>0&&(Xn(o.hu,42227),o.hu=!1))})),await kf(n,r,t)}catch(r){await Ef(r)}}function FD(e,t,n){const r=Vn(e);if(r.isPrimaryClient&&n===0||!r.isPrimaryClient&&n===1){const i=[];r.Tu.forEach(((a,o)=>{const c=o.view.va(t);c.snapshot&&i.push(c.snapshot)})),(function(o,c){const h=Vn(o);h.onlineState=c;let f=!1;h.queries.forEach(((m,y)=>{for(const w of y.Sa)w.va(c)&&(f=!0)})),f&&gT(h)})(r.eventManager,t),i.length&&r.Pu.H_(i),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function qde(e,t,n){const r=Vn(e);r.sharedClientState.updateQueryState(t,"rejected",n);const i=r.Au.get(t),a=i&&i.key;if(a){let o=new ds(gn.comparator);o=o.insert(a,Ys.newNoDocument(a,sr.min()));const c=Kr().add(a),h=new Ky(sr.min(),new Map,new ds(Cr),o,c);await yG(r,h),r.Ru=r.Ru.remove(a),r.Au.delete(t),wT(r)}else await vg(r.localStore,t,!1).then((()=>Eg(r,t,n))).catch(Ef)}async function Wde(e,t){const n=Vn(e),r=t.batch.batchId;try{const i=await ode(n.localStore,t);vT(n,r,null),bT(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await kf(n,i)}catch(i){await Ef(i)}}async function Kde(e,t,n){const r=Vn(e);try{const i=await(function(o,c){const h=Vn(o);return h.persistence.runTransaction("Reject batch","readwrite-primary",(f=>{let m;return h.mutationQueue.lookupMutationBatch(f,c).next((y=>(Xn(y!==null,37113),m=y.keys(),h.mutationQueue.removeMutationBatch(f,y)))).next((()=>h.mutationQueue.performConsistencyCheck(f))).next((()=>h.documentOverlayCache.removeOverlaysForBatchId(f,m,c))).next((()=>h.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(f,m))).next((()=>h.localDocuments.getDocuments(f,m)))}))})(r.localStore,t);vT(r,t,n),bT(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),await kf(r,i)}catch(i){await Ef(i)}}function bT(e,t){(e.mu.get(t)||[]).forEach((n=>{n.resolve()})),e.mu.delete(t)}function vT(e,t,n){const r=Vn(e);let i=r.du[r.currentUser.toKey()];if(i){const a=i.get(t);a&&(n?a.reject(n):a.resolve(),i=i.remove(t)),r.du[r.currentUser.toKey()]=i}}function Eg(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(const r of e.Eu.get(t))e.Tu.delete(r),n&&e.Pu.yu(r,n);e.Eu.delete(t),e.isPrimaryClient&&e.Vu.Gr(t).forEach((r=>{e.Vu.containsKey(r)||bG(e,r)}))}function bG(e,t){e.Iu.delete(t.path.canonicalString());const n=e.Ru.get(t);n!==null&&(wg(e.remoteStore,n),e.Ru=e.Ru.remove(t),e.Au.delete(n),wT(e))}function AC(e,t,n){for(const r of n)r instanceof mG?(e.Vu.addReference(r.key,t),Yde(e,r)):r instanceof gG?(qt($g,"Document no longer in limbo: "+r.key),e.Vu.removeReference(r.key,t),e.Vu.containsKey(r.key)||bG(e,r.key)):Tn(19791,{wu:r})}function Yde(e,t){const n=t.key,r=n.path.canonicalString();e.Ru.get(n)||e.Iu.has(r)||(qt($g,"New document in limbo: "+n),e.Iu.add(r),wT(e))}function wT(e){for(;e.Iu.size>0&&e.Ru.size{o.push(r.pu(h,t,n).then((f=>{var m;if((f||n)&&r.isPrimaryClient){const y=f?!f.fromCache:(m=n==null?void 0:n.targetChanges.get(h.targetId))==null?void 0:m.current;r.sharedClientState.updateQueryState(h.targetId,y?"current":"not-current")}if(f){i.push(f);const y=aT.Is(h.targetId,f);a.push(y)}})))})),await Promise.all(o),r.Pu.H_(i),await(async function(h,f){const m=Vn(h);try{await m.persistence.runTransaction("notifyLocalViewChanges","readwrite",(y=>Xe.forEach(f,(w=>Xe.forEach(w.Ts,(A=>m.persistence.referenceDelegate.addReference(y,w.targetId,A))).next((()=>Xe.forEach(w.Es,(A=>m.persistence.referenceDelegate.removeReference(y,w.targetId,A)))))))))}catch(y){if(!Af(y))throw y;qt(oT,"Failed to update sequence numbers: "+y)}for(const y of f){const w=y.targetId;if(!y.fromCache){const A=m.vs.get(w),S=A.snapshotVersion,C=A.withLastLimboFreeSnapshotVersion(S);m.vs=m.vs.insert(w,C)}}})(r.localStore,a))}async function Xde(e,t){const n=Vn(e);if(!n.currentUser.isEqual(t)){qt($g,"User change. New user:",t.toKey());const r=await ZH(n.localStore,t);n.currentUser=t,(function(a,o){a.mu.forEach((c=>{c.forEach((h=>{h.reject(new sn(vt.CANCELLED,o))}))})),a.mu.clear()})(n,"'waitForPendingWrites' promise is rejected due to a user change."),n.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await kf(n,r.Ns)}}function Qde(e,t){const n=Vn(e),r=n.Au.get(t);if(r&&r.hu)return Kr().add(r.key);{let i=Kr();const a=n.Eu.get(t);if(!a)return i;for(const o of a){const c=n.Tu.get(o);i=i.unionWith(c.view.nu)}return i}}async function Zde(e,t){const n=Vn(e),r=await bC(n.localStore,t.query,!0),i=t.view.cu(r);return n.isPrimaryClient&&AC(n,t.targetId,i.au),i}async function Jde(e,t){const n=Vn(e);return tG(n.localStore,t).then((r=>kf(n,r)))}async function ehe(e,t,n,r){const i=Vn(e),a=await(function(c,h){const f=Vn(c),m=Vn(f.mutationQueue);return f.persistence.runTransaction("Lookup mutation documents","readonly",(y=>m.Xn(y,h).next((w=>w?f.localDocuments.getDocuments(y,w):Xe.resolve(null)))))})(i.localStore,t);a!==null?(n==="pending"?await Vg(i.remoteStore):n==="acknowledged"||n==="rejected"?(vT(i,t,r||null),bT(i,t),(function(c,h){Vn(Vn(c).mutationQueue).nr(h)})(i.localStore,t)):Tn(6720,"Unknown batchState",{Su:n}),await kf(i,a)):qt($g,"Cannot apply mutation batch with id: "+t)}async function the(e,t){const n=Vn(e);if(_E(n),NT(n),t===!0&&n.gu!==!0){const r=n.sharedClientState.getAllActiveQueryTargets(),i=await $D(n,r.toArray());n.gu=!0,await NC(n.remoteStore,!0);for(const a of i)AE(n.remoteStore,a)}else if(t===!1&&n.gu!==!1){const r=[];let i=Promise.resolve();n.Eu.forEach(((a,o)=>{n.sharedClientState.isLocalQueryTarget(o)?r.push(o):i=i.then((()=>(Eg(n,o),vg(n.localStore,o,!0)))),wg(n.remoteStore,o)})),await i,await $D(n,r),(function(o){const c=Vn(o);c.Au.forEach(((h,f)=>{wg(c.remoteStore,f)})),c.Vu.zr(),c.Au=new Map,c.Ru=new ds(gn.comparator)})(n),n.gu=!1,await NC(n.remoteStore,!1)}}async function $D(e,t,n){const r=Vn(e),i=[],a=[];for(const o of t){let c;const h=r.Eu.get(o);if(h&&h.length!==0){c=await A2(r.localStore,Ul(h[0]));for(const f of h){const m=r.Tu.get(f),y=await Zde(r,m);y.snapshot&&a.push(y.snapshot)}}else{const f=await eG(r.localStore,o);c=await A2(r.localStore,f),await yT(r,vG(f),o,!1,c.resumeToken)}i.push(c)}return r.Pu.H_(a),i}function vG(e){return nH(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}function nhe(e){return(function(n){return Vn(Vn(n).persistence).hs()})(Vn(e).localStore)}async function rhe(e,t,n,r){const i=Vn(e);if(i.gu)return void qt($g,"Ignoring unexpected query state notification.");const a=i.Eu.get(t);if(a&&a.length>0)switch(n){case"current":case"not-current":{const o=await tG(i.localStore,aH(a[0])),c=Ky.createSynthesizedRemoteEventForCurrentChange(t,n==="current",na.EMPTY_BYTE_STRING);await kf(i,o,c);break}case"rejected":await vg(i.localStore,t,!0),Eg(i,t,r);break;default:Tn(64155,n)}}async function ihe(e,t,n){const r=_E(e);if(r.gu){for(const i of t){if(r.Eu.has(i)&&r.sharedClientState.isActiveQueryTarget(i)){qt($g,"Adding an already active target "+i);continue}const a=await eG(r.localStore,i),o=await A2(r.localStore,a);await yT(r,vG(a),o.targetId,!1,o.resumeToken),AE(r.remoteStore,o)}for(const i of n)r.Eu.has(i)&&await vg(r.localStore,i,!1).then((()=>{wg(r.remoteStore,i),Eg(r,i)})).catch(Ef)}}function _E(e){const t=Vn(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=yG.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=Qde.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=qde.bind(null,t),t.Pu.H_=Dde.bind(null,t.eventManager),t.Pu.yu=Mde.bind(null,t.eventManager),t}function NT(e){const t=Vn(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=Wde.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Kde.bind(null,t),t}class fy{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(t){this.serializer=NE(t.databaseInfo.databaseId),this.sharedClientState=this.Du(t),this.persistence=this.Cu(t),await this.persistence.start(),this.localStore=this.vu(t),this.gcScheduler=this.Fu(t,this.localStore),this.indexBackfillerScheduler=this.Mu(t,this.localStore)}Fu(t,n){return null}Mu(t,n){return null}vu(t){return QH(this.persistence,new XH,t.initialUser,this.serializer)}Cu(t){return new iT(wE.Vi,this.serializer)}Du(t){return new aG}async terminate(){var t,n;(t=this.gcScheduler)==null||t.stop(),(n=this.indexBackfillerScheduler)==null||n.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}fy.provider={build:()=>new fy};class wG extends fy{constructor(t){super(),this.cacheSizeBytes=t}Fu(t,n){Xn(this.persistence.referenceDelegate instanceof E2,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new HH(r,t.asyncQueue,n)}Cu(t){const n=this.cacheSizeBytes!==void 0?No.withCacheSize(this.cacheSizeBytes):No.DEFAULT;return new iT((r=>E2.Vi(r,n)),this.serializer)}}class NG extends fy{constructor(t,n,r){super(),this.xu=t,this.cacheSizeBytes=n,this.forceOwnership=r,this.kind="persistent",this.synchronizeTabs=!1}async initialize(t){await super.initialize(t),await this.xu.initialize(this,t),await NT(this.xu.syncEngine),await Vg(this.xu.remoteStore),await this.persistence.zi((()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve())))}vu(t){return QH(this.persistence,new XH,t.initialUser,this.serializer)}Fu(t,n){const r=this.persistence.referenceDelegate.garbageCollector;return new HH(r,t.asyncQueue,n)}Mu(t,n){const r=new uce(n,this.persistence);return new cce(t.asyncQueue,r)}Cu(t){const n=YH(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),r=this.cacheSizeBytes!==void 0?No.withCacheSize(this.cacheSizeBytes):No.DEFAULT;return new sT(this.synchronizeTabs,n,t.clientId,r,t.asyncQueue,oG(),Mw(),this.serializer,this.sharedClientState,!!this.forceOwnership)}Du(t){return new aG}}class she extends NG{constructor(t,n){super(t,n,!1),this.xu=t,this.cacheSizeBytes=n,this.synchronizeTabs=!0}async initialize(t){await super.initialize(t);const n=this.xu.syncEngine;this.sharedClientState instanceof f_&&(this.sharedClientState.syncEngine={bo:ehe.bind(null,n),Do:rhe.bind(null,n),Co:ihe.bind(null,n),hs:nhe.bind(null,n),So:Jde.bind(null,n)},await this.sharedClientState.start()),await this.persistence.zi((async r=>{await the(this.xu.syncEngine,r),this.gcScheduler&&(r&&!this.gcScheduler.started?this.gcScheduler.start():r||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(r&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():r||this.indexBackfillerScheduler.stop())}))}Du(t){const n=oG();if(!f_.v(n))throw new sn(vt.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const r=YH(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new f_(n,t.asyncQueue,r,t.clientId,t.initialUser)}}class Ag{async initialize(t,n){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(n),this.remoteStore=this.createRemoteStore(n),this.eventManager=this.createEventManager(n),this.syncEngine=this.createSyncEngine(n,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>FD(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=Xde.bind(null,this.syncEngine),await NC(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return(function(){return new Rde})()}createDatastore(t){const n=NE(t.databaseInfo.databaseId),r=mde(t.databaseInfo);return vde(t.authCredentials,t.appCheckCredentials,r,n)}createRemoteStore(t){return(function(r,i,a,o,c){return new Nde(r,i,a,o,c)})(this.localStore,this.datastore,t.asyncQueue,(n=>FD(this.syncEngine,n,0)),(function(){return MD.v()?new MD:new dde})())}createSyncEngine(t,n){return(function(i,a,o,c,h,f,m){const y=new zde(i,a,o,c,h,f);return m&&(y.gu=!0),y})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,n)}async terminate(){var t,n;await(async function(i){const a=Vn(i);qt(om,"RemoteStore shutting down."),a.Ia.add(5),await Xy(a),a.Aa.shutdown(),a.Va.set("Unknown")})(this.remoteStore),(t=this.datastore)==null||t.terminate(),(n=this.eventManager)==null||n.terminate()}}Ag.provider={build:()=>new Ag};/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ET{constructor(t){this.observer=t,this.muted=!1}next(t){this.muted||this.observer.next&&this.Ou(this.observer.next,t)}error(t){this.muted||(this.observer.error?this.Ou(this.observer.error,t):ta("Uncaught Error in snapshot listener:",t.toString()))}Nu(){this.muted=!0}Ou(t,n){setTimeout((()=>{this.muted||t(n)}),0)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const gf="FirestoreClient";class ahe{constructor(t,n,r,i,a){this.authCredentials=t,this.appCheckCredentials=n,this.asyncQueue=r,this._databaseInfo=i,this.user=wo.UNAUTHENTICATED,this.clientId=DI.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=a,this.authCredentials.start(r,(async o=>{qt(gf,"Received user=",o.uid),await this.authCredentialListener(o),this.user=o})),this.appCheckCredentials.start(r,(o=>(qt(gf,"Received new app check token=",o),this.appCheckCredentialListener(o,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(t){this.authCredentialListener=t}setAppCheckTokenChangeListener(t){this.appCheckCredentialListener=t}terminate(){this.asyncQueue.enterRestrictedMode();const t=new Hc;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(n){const r=fT(n,"Failed to shutdown persistence");t.reject(r)}})),t.promise}}async function m_(e,t){e.asyncQueue.verifyOperationInProgress(),qt(gf,"Initializing OfflineComponentProvider");const n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async i=>{r.isEqual(i)||(await ZH(t.localStore,i),r=i)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e._offlineComponents=t}async function HD(e,t){e.asyncQueue.verifyOperationInProgress();const n=await ohe(e);qt(gf,"Initializing OnlineComponentProvider"),await t.initialize(n,e.configuration),e.setCredentialChangeListener((r=>UD(t.remoteStore,r))),e.setAppCheckTokenChangeListener(((r,i)=>UD(t.remoteStore,i))),e._onlineComponents=t}async function ohe(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){qt(gf,"Using user provided OfflineComponentProvider");try{await m_(e,e._uninitializedComponentsProvider._offline)}catch(t){const n=t;if(!(function(i){return i.name==="FirebaseError"?i.code===vt.FAILED_PRECONDITION||i.code===vt.UNIMPLEMENTED:!(typeof DOMException<"u"&&i instanceof DOMException)||i.code===22||i.code===20||i.code===11})(n))throw n;ag("Error using user provided cache. Falling back to memory cache: "+n),await m_(e,new fy)}}else qt(gf,"Using default OfflineComponentProvider"),await m_(e,new wG(void 0));return e._offlineComponents}async function AT(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(qt(gf,"Using user provided OnlineComponentProvider"),await HD(e,e._uninitializedComponentsProvider._online)):(qt(gf,"Using default OnlineComponentProvider"),await HD(e,new Ag))),e._onlineComponents}function lhe(e){return AT(e).then((t=>t.syncEngine))}function che(e){return AT(e).then((t=>t.datastore))}async function C2(e){const t=await AT(e),n=t.eventManager;return n.onListen=Vde.bind(null,t.syncEngine),n.onUnlisten=$de.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=Fde.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=Hde.bind(null,t.syncEngine),n}function uhe(e,t,n,r){const i=new ET(r),a=new xT(t,i,n);return e.asyncQueue.enqueueAndForget((async()=>pT(await C2(e),a))),()=>{i.Nu(),e.asyncQueue.enqueueAndForget((async()=>mT(await C2(e),a)))}}function dhe(e,t,n={}){const r=new Hc;return e.asyncQueue.enqueueAndForget((async()=>(function(a,o,c,h,f){const m=new ET({next:w=>{m.Nu(),o.enqueueAndForget((()=>mT(a,y)));const A=w.docs.has(c);!A&&w.fromCache?f.reject(new sn(vt.UNAVAILABLE,"Failed to get document because the client is offline.")):A&&w.fromCache&&h&&h.source==="server"?f.reject(new sn(vt.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):f.resolve(w)},error:w=>f.reject(w)}),y=new xT(Gy(c.path),m,{includeMetadataChanges:!0,qa:!0});return pT(a,y)})(await C2(e),e.asyncQueue,t,n,r))),r.promise}function hhe(e,t,n={}){const r=new Hc;return e.asyncQueue.enqueueAndForget((async()=>(function(a,o,c,h,f){const m=new ET({next:w=>{m.Nu(),o.enqueueAndForget((()=>mT(a,y))),w.fromCache&&h.source==="server"?f.reject(new sn(vt.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):f.resolve(w)},error:w=>f.reject(w)}),y=new xT(c,m,{includeMetadataChanges:!0,qa:!0});return pT(a,y)})(await C2(e),e.asyncQueue,t,n,r))),r.promise}function fhe(e,t,n){const r=new Hc;return e.asyncQueue.enqueueAndForget((async()=>{try{const i=await che(e);r.resolve((async function(o,c,h){var C;const f=Vn(o),{request:m,gt:y,parent:w}=_ue(f.serializer,Zce(c),h);f.connection.qo||delete m.parent;const A=(await f.jo("RunAggregationQuery",f.serializer.databaseId,w,m,1)).filter((T=>!!T.result));Xn(A.length===1,64727);const S=(C=A[0].result)==null?void 0:C.aggregateFields;return Object.keys(S).reduce(((T,D)=>(T[y[D]]=S[D],T)),{})})(i,t,n))}catch(i){r.reject(i)}})),r.promise}function phe(e,t){const n=new Hc;return e.asyncQueue.enqueueAndForget((async()=>Gde(await lhe(e),t,n))),n.promise}/** * @license * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function EG(e){const t={};return e.timeoutSeconds!==void 0&&(t.timeoutSeconds=e.timeoutSeconds),t}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const mhe="ComponentProvider",GD=new Map;function ghe(e,t,n,r,i){return new Bce(e,t,n,i.host,i.ssl,i.experimentalForceLongPolling,i.experimentalAutoDetectLongPolling,EG(i.experimentalLongPollingOptions),i.useFetchStreams,i.isUsingEmulator,r)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const xhe="firestore.googleapis.com",qD=!0;class WD{constructor(t){if(t.host===void 0){if(t.ssl!==void 0)throw new sn(vt.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=xhe,this.ssl=qD}else this.host=t.host,this.ssl=t.ssl??qD;if(this.isUsingEmulator=t.emulatorOptions!==void 0,this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,this.localCache=t.localCache,t.cacheSizeBytes===void 0)this.cacheSizeBytes=BH;else{if(t.cacheSizeBytes!==-1&&t.cacheSizeBytes<$H)throw new sn(vt.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}sce("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:t.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=EG(t.experimentalLongPollingOptions??{}),(function(r){if(r.timeoutSeconds!==void 0){if(isNaN(r.timeoutSeconds))throw new sn(vt.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (must not be NaN)`);if(r.timeoutSeconds<5)throw new sn(vt.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (minimum allowed value is 5)`);if(r.timeoutSeconds>30)throw new sn(vt.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (maximum allowed value is 30)`)}})(this.experimentalLongPollingOptions),this.useFetchStreams=!!t.useFetchStreams}isEqual(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&(function(r,i){return r.timeoutSeconds===i.timeoutSeconds})(this.experimentalLongPollingOptions,t.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class kE{constructor(t,n,r,i){this._authCredentials=t,this._appCheckCredentials=n,this._databaseId=r,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new WD({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new sn(vt.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(t){if(this._settingsFrozen)throw new sn(vt.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new WD(t),this._emulatorOptions=t.emulatorOptions||{},t.credentials!==void 0&&(this._authCredentials=(function(r){if(!r)return new Xle;switch(r.type){case"firstParty":return new Jle(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new sn(vt.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(t.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return(function(n){const r=GD.get(n);r&&(qt(mhe,"Removing Datastore"),GD.delete(n),r.terminate())})(this),Promise.resolve()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Qu{constructor(t,n,r){this.converter=n,this._query=r,this.type="query",this.firestore=t}withConverter(t){return new Qu(this.firestore,t,this._query)}}class Xs{constructor(t,n,r){this.converter=n,this._key=r,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new lf(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new Xs(this.firestore,t,this._key)}toJSON(){return{type:Xs._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(t,n,r){if(Fy(n,Xs._jsonSchema))return new Xs(t,r||null,new gn(ki.fromString(n.referencePath)))}}Xs._jsonSchemaVersion="firestore/documentReference/1.0",Xs._jsonSchema={type:da("string",Xs._jsonSchemaVersion),referencePath:da("string")};class lf extends Qu{constructor(t,n,r){super(t,n,Gy(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new Xs(this.firestore,null,new gn(t))}withConverter(t){return new lf(this.firestore,t,this._path)}}function et(e,t,...n){if(e=Ca(e),MI("collection","path",t),e instanceof kE){const r=ki.fromString(t,...n);return LR(r),new lf(e,null,r)}{if(!(e instanceof Xs||e instanceof lf))throw new sn(vt.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(ki.fromString(t,...n));return LR(r),new lf(e.firestore,null,r)}}function yhe(e,t){if(e=qo(e,kE),MI("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new sn(vt.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new Qu(e,null,(function(r){return new ym(ki.emptyPath(),r)})(t))}function Je(e,t,...n){if(e=Ca(e),arguments.length===1&&(t=DI.newId()),MI("doc","path",t),e instanceof kE){const r=ki.fromString(t,...n);return MR(r),new Xs(e,null,new gn(r))}{if(!(e instanceof Xs||e instanceof lf))throw new sn(vt.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(ki.fromString(t,...n));return MR(r),new Xs(e.firestore,e instanceof lf?e.converter:null,new gn(r))}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const KD="AsyncQueue";class YD{constructor(t=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new lG(this,"async_queue_retry"),this._c=()=>{const r=Mw();r&&qt(KD,"Visibility state changed to "+r.visibilityState),this.M_.w_()},this.ac=t;const n=Mw();n&&typeof n.addEventListener=="function"&&n.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.uc(),this.cc(t)}enterRestrictedMode(t){if(!this.ec){this.ec=!0,this.sc=t||!1;const n=Mw();n&&typeof n.removeEventListener=="function"&&n.removeEventListener("visibilitychange",this._c)}}enqueue(t){if(this.uc(),this.ec)return new Promise((()=>{}));const n=new Hc;return this.cc((()=>this.ec&&this.sc?Promise.resolve():(t().then(n.resolve,n.reject),n.promise))).then((()=>n.promise))}enqueueRetryable(t){this.enqueueAndForget((()=>(this.Yu.push(t),this.lc())))}async lc(){if(this.Yu.length!==0){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(t){if(!Af(t))throw t;qt(KD,"Operation failed with retryable error: "+t)}this.Yu.length>0&&this.M_.p_((()=>this.lc()))}}cc(t){const n=this.ac.then((()=>(this.rc=!0,t().catch((r=>{throw this.nc=r,this.rc=!1,ta("INTERNAL UNHANDLED ERROR: ",XD(r)),r})).then((r=>(this.rc=!1,r))))));return this.ac=n,n}enqueueAfterDelay(t,n,r){this.uc(),this.oc.indexOf(t)>-1&&(n=0);const i=hT.createAndSchedule(this,t,n,r,(a=>this.hc(a)));return this.tc.push(i),i}uc(){this.nc&&Tn(47125,{Pc:XD(this.nc)})}verifyOperationInProgress(){}async Tc(){let t;do t=this.ac,await t;while(t!==this.ac)}Ec(t){for(const n of this.tc)if(n.timerId===t)return!0;return!1}Ic(t){return this.Tc().then((()=>{this.tc.sort(((n,r)=>n.targetTimeMs-r.targetTimeMs));for(const n of this.tc)if(n.skipDelay(),t!=="all"&&n.timerId===t)break;return this.Tc()}))}Rc(t){this.oc.push(t)}hc(t){const n=this.tc.indexOf(t);this.tc.splice(n,1)}}function XD(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+` `+e.stack),t}class Vu extends kE{constructor(t,n,r,i){super(t,n,r,i),this.type="firestore",this._queue=new YD,this._persistenceKey=(i==null?void 0:i.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const t=this._firestoreClient.terminate();this._queue=new YD(t),this._firestoreClient=void 0,await t}}}function bhe(e,t,n){const r=EI(e,"firestore");if(r.isInitialized(n)){const i=r.getImmediate({identifier:n}),a=r.getOptions(n);if(zd(a,t))return i;throw new sn(vt.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(t.cacheSizeBytes!==void 0&&t.localCache!==void 0)throw new sn(vt.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(t.cacheSizeBytes!==void 0&&t.cacheSizeBytes!==-1&&t.cacheSizeBytes<$H)throw new sn(vt.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return t.host&&Ly(t.host)&&SF(t.host),r.initialize({options:t,instanceIdentifier:n})}function Qy(e){if(e._terminated)throw new sn(vt.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||vhe(e),e._firestoreClient}function vhe(e){var r,i,a,o;const t=e._freezeSettings(),n=ghe(e._databaseId,((r=e._app)==null?void 0:r.options.appId)||"",e._persistenceKey,(i=e._app)==null?void 0:i.options.apiKey,t);e._componentsProvider||(a=t.localCache)!=null&&a._offlineComponentProvider&&((o=t.localCache)!=null&&o._onlineComponentProvider)&&(e._componentsProvider={_offline:t.localCache._offlineComponentProvider,_online:t.localCache._onlineComponentProvider}),e._firestoreClient=new ahe(e._authCredentials,e._appCheckCredentials,e._queue,n,e._componentsProvider&&(function(h){const f=h==null?void 0:h._online.build();return{_offline:h==null?void 0:h._offline.build(f),_online:f}})(e._componentsProvider))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class dc{constructor(t){this._byteString=t}static fromBase64String(t){try{return new dc(na.fromBase64String(t))}catch(n){throw new sn(vt.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+n)}}static fromUint8Array(t){return new dc(na.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}toJSON(){return{type:dc._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(t){if(Fy(t,dc._jsonSchema))return dc.fromBase64String(t.bytes)}}dc._jsonSchemaVersion="firestore/bytes/1.0",dc._jsonSchema={type:da("string",dc._jsonSchemaVersion),bytes:da("string")};/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class _T{constructor(...t){for(let n=0;n90)throw new sn(vt.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(n)||n<-180||n>180)throw new sn(vt.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+n);this._lat=t,this._long=n}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}_compareTo(t){return Cr(this._lat,t._lat)||Cr(this._long,t._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:Du._jsonSchemaVersion}}static fromJSON(t){if(Fy(t,Du._jsonSchema))return new Du(t.latitude,t.longitude)}}Du._jsonSchemaVersion="firestore/geoPoint/1.0",Du._jsonSchema={type:da("string",Du._jsonSchemaVersion),latitude:da("number"),longitude:da("number")};/** * @license * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Gc{constructor(t){this._values=(t||[]).map((n=>n))}toArray(){return this._values.map((t=>t))}isEqual(t){return(function(r,i){if(r.length!==i.length)return!1;for(let a=0;atypeof n=="number")))return new Gc(t.vectorValues);throw new sn(vt.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Gc._jsonSchemaVersion="firestore/vectorValue/1.0",Gc._jsonSchema={type:da("string",Gc._jsonSchemaVersion),vectorValues:da("object")};/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const whe=/^__.*__$/;class Nhe{constructor(t,n,r){this.data=t,this.fieldMask=n,this.fieldTransforms=r}toMutation(t,n){return this.fieldMask!==null?new Jd(t,this.data,this.fieldMask,n,this.fieldTransforms):new zg(t,this.data,n,this.fieldTransforms)}}class AG{constructor(t,n,r){this.data=t,this.fieldMask=n,this.fieldTransforms=r}toMutation(t,n){return new Jd(t,this.data,this.fieldMask,n,this.fieldTransforms)}}function _G(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Tn(40011,{dataSource:e})}}class SE{constructor(t,n,r,i,a,o){this.settings=t,this.databaseId=n,this.serializer=r,this.ignoreUndefinedProperties=i,a===void 0&&this.Ac(),this.fieldTransforms=a||[],this.fieldMask=o||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}i(t){return new SE({...this.settings,...t},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}dc(t){var i;const n=(i=this.path)==null?void 0:i.child(t),r=this.i({path:n,arrayElement:!1});return r.mc(t),r}fc(t){var i;const n=(i=this.path)==null?void 0:i.child(t),r=this.i({path:n,arrayElement:!1});return r.Ac(),r}gc(t){return this.i({path:void 0,arrayElement:!0})}yc(t){return j2(t,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(t){return this.fieldMask.find((n=>t.isPrefixOf(n)))!==void 0||this.fieldTransforms.find((n=>t.isPrefixOf(n.field)))!==void 0}Ac(){if(this.path)for(let t=0;th.covers(y.field)))}else h=null,f=o.fieldTransforms;return new Nhe(new so(c),h,f)}class jE extends vm{_toFieldTransform(t){if(t.dataSource!==2)throw t.dataSource===1?t.yc(`${this._methodName}() can only appear at the top level of your update data`):t.yc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof jE}}function SG(e,t,n){return new SE({dataSource:3,targetDoc:t.settings.targetDoc,methodName:e._methodName,arrayElement:n},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class kT extends vm{_toFieldTransform(t){return new Wy(t.path,new xg)}isEqual(t){return t instanceof kT}}class ST extends vm{constructor(t,n){super(t),this.Sc=n}_toFieldTransform(t){const n=SG(this,t,!0),r=this.Sc.map((a=>wm(a,n))),i=new nm(r);return new Wy(t.path,i)}isEqual(t){return t instanceof ST&&zd(this.Sc,t.Sc)}}class CT extends vm{constructor(t,n){super(t),this.Sc=n}_toFieldTransform(t){const n=SG(this,t,!0),r=this.Sc.map((a=>wm(a,n))),i=new rm(r);return new Wy(t.path,i)}isEqual(t){return t instanceof CT&&zd(this.Sc,t.Sc)}}class jT extends vm{constructor(t,n){super(t),this.bc=n}_toFieldTransform(t){const n=new yg(t.serializer,hH(t.serializer,this.bc));return new Wy(t.path,n)}isEqual(t){return t instanceof jT&&this.bc===t.bc}}function Ahe(e,t,n,r){const i=e.A(1,t,n);IT("Data must be an object, but it was:",i,r);const a=[],o=so.empty();_f(r,((h,f)=>{const m=IG(t,h,n);f=Ca(f);const y=i.fc(m);if(f instanceof jE)a.push(m);else{const w=wm(f,y);w!=null&&(a.push(m),o.set(m,w))}}));const c=new gl(a);return new AG(o,c,i.fieldTransforms)}function _he(e,t,n,r,i,a){const o=e.A(1,t,n),c=[lm(t,r,n)],h=[i];if(a.length%2!=0)throw new sn(vt.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let w=0;w=0;--w)if(!TG(f,c[w])){const A=c[w];let S=h[w];S=Ca(S);const C=o.fc(A);if(S instanceof jE)f.push(A);else{const T=wm(S,C);T!=null&&(f.push(A),m.set(A,T))}}const y=new gl(f);return new AG(m,y,o.fieldTransforms)}function khe(e,t,n,r=!1){return wm(n,e.A(r?4:3,t))}function wm(e,t){if(jG(e=Ca(e)))return IT("Unsupported field value:",t,e),CG(e,t);if(e instanceof vm)return(function(r,i){if(!_G(i.dataSource))throw i.yc(`${r._methodName}() can only be used with update() and set()`);if(!i.path)throw i.yc(`${r._methodName}() is not currently supported inside arrays`);const a=r._toFieldTransform(i);a&&i.fieldTransforms.push(a)})(e,t),null;if(e===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.arrayElement&&t.dataSource!==4)throw t.yc("Nested arrays are not supported");return(function(r,i){const a=[];let o=0;for(const c of r){let h=wm(c,i.gc(o));h==null&&(h={nullValue:"NULL_VALUE"}),a.push(h),o++}return{arrayValue:{values:a}}})(e,t)}return(function(r,i){if((r=Ca(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return hH(i.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const a=_r.fromDate(r);return{timestampValue:bg(i.serializer,a)}}if(r instanceof _r){const a=new _r(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:bg(i.serializer,a)}}if(r instanceof Du)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof dc)return{bytesValue:EH(i.serializer,r._byteString)};if(r instanceof Xs){const a=i.databaseId,o=r.firestore._databaseId;if(!o.isEqual(a))throw i.yc(`Document reference is for database ${o.projectId}/${o.database} but should be for database ${a.projectId}/${a.database}`);return{referenceValue:JI(r.firestore._databaseId||i.databaseId,r._key.path)}}if(r instanceof Gc)return(function(o,c){const h=o instanceof Gc?o.toArray():o;return{mapValue:{fields:{[HI]:{stringValue:GI},[fg]:{arrayValue:{values:h.map((m=>{if(typeof m!="number")throw c.yc("VectorValues must only contain numeric values.");return KI(c.serializer,m)}))}}}}}})(r,i);if(OH(r))return r._toProto(i.serializer);throw i.yc(`Unsupported field value: ${oE(r)}`)})(e,t)}function CG(e,t){const n={};return B$(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):_f(e,((r,i)=>{const a=wm(i,t.dc(r));a!=null&&(n[r]=a)})),{mapValue:{fields:n}}}function jG(e){return!(typeof e!="object"||e===null||e instanceof Array||e instanceof Date||e instanceof _r||e instanceof Du||e instanceof dc||e instanceof Xs||e instanceof vm||e instanceof Gc||OH(e))}function IT(e,t,n){if(!jG(n)||!N$(n)){const r=oE(n);throw r==="an object"?t.yc(e+" a custom object"):t.yc(e+" "+r)}}function lm(e,t,n){if((t=Ca(t))instanceof _T)return t._internalPath;if(typeof t=="string")return IG(e,t);throw j2("Field path arguments must be of type string or ",e,!1,void 0,n)}const She=new RegExp("[~\\*/\\[\\]]");function IG(e,t,n){if(t.search(She)>=0)throw j2(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new _T(...t.split("."))._internalPath}catch{throw j2(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function j2(e,t,n,r,i){const a=r&&!r.isEmpty(),o=i!==void 0;let c=`Function ${t}() called with invalid data`;n&&(c+=" (via `toFirestore()`)"),c+=". ";let h="";return(a||o)&&(h+=" (found",a&&(h+=` in field ${r}`),o&&(h+=` in document ${i}`),h+=")"),new sn(vt.INVALID_ARGUMENT,c+e+h)}function TG(e,t){return e.some((n=>n.isEqual(t)))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Che{convertValue(t,n="none"){switch(ff(t)){case 0:return null;case 1:return t.booleanValue;case 2:return _s(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,n);case 5:return t.stringValue;case 6:return this.convertBytes(Hd(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,n);case 11:return this.convertObject(t.mapValue,n);case 10:return this.convertVectorValue(t.mapValue);default:throw Tn(62114,{value:t})}}convertObject(t,n){return this.convertObjectMap(t.fields,n)}convertObjectMap(t,n="none"){const r={};return _f(t,((i,a)=>{r[i]=this.convertValue(a,n)})),r}convertVectorValue(t){var r,i,a;const n=(a=(i=(r=t.fields)==null?void 0:r[fg].arrayValue)==null?void 0:i.values)==null?void 0:a.map((o=>_s(o.doubleValue)));return new Gc(n)}convertGeoPoint(t){return new Du(_s(t.latitude),_s(t.longitude))}convertArray(t,n){return(t.values||[]).map((r=>this.convertValue(r,n)))}convertServerTimestamp(t,n){switch(n){case"previous":const r=fE(t);return r==null?null:this.convertValue(r,n);case"estimate":return this.convertTimestamp(ly(t));default:return null}}convertTimestamp(t){const n=$d(t);return new _r(n.seconds,n.nanos)}convertDocumentKey(t,n){const r=ki.fromString(t);Xn(PH(r),9688,{name:t});const i=new em(r.get(1),r.get(3)),a=new gn(r.popFirst(5));return i.isEqual(n)||ta(`Document ${a} contains a document reference within a different database (${i.projectId}/${i.database}) which is not supported. It will be treated as a reference in the current database (${n.projectId}/${n.database}) instead.`),a}}/** * @license * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class IE extends Che{constructor(t){super(),this.firestore=t}convertBytes(t){return new dc(t)}convertReference(t){const n=this.convertDocumentKey(t,this.firestore._databaseId);return new Xs(this.firestore,null,n)}}function En(){return new kT("serverTimestamp")}function I2(...e){return new ST("arrayUnion",e)}function T2(...e){return new CT("arrayRemove",e)}function Ir(e){return new jT("increment",e)}const QD="@firebase/firestore",ZD="4.13.0";/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function JD(e){return(function(n,r){if(typeof n!="object"||n===null)return!1;const i=n;for(const a of r)if(a in i&&typeof i[a]=="function")return!0;return!1})(e,["next","error","complete"])}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class jhe{constructor(t="count",n){this._internalFieldPath=n,this.type="AggregateField",this.aggregateType=t}}class Ihe{constructor(t,n,r){this._userDataWriter=n,this._data=r,this.type="AggregateQuerySnapshot",this.query=t}data(){return this._userDataWriter.convertObjectMap(this._data)}_fieldsProto(){return new so({mapValue:{fields:this._data}}).clone().value.mapValue.fields}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class PG{constructor(t,n,r,i,a){this._firestore=t,this._userDataWriter=n,this._key=r,this._document=i,this._converter=a}get id(){return this._key.path.lastSegment()}get ref(){return new Xs(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const t=new The(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){var t;return((t=this._document)==null?void 0:t.data.clone().value.mapValue.fields)??void 0}get(t){if(this._document){const n=this._document.data.field(lm("DocumentSnapshot.get",t));if(n!==null)return this._userDataWriter.convertValue(n)}}}class The extends PG{data(){return super.data()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function OG(e){if(e.limitType==="L"&&e.explicitOrderBy.length===0)throw new sn(vt.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class TT{}class PT extends TT{}function Qt(e,t,...n){let r=[];t instanceof TT&&r.push(t),r=r.concat(n),(function(a){const o=a.filter((h=>h instanceof OT)).length,c=a.filter((h=>h instanceof TE)).length;if(o>1||o>0&&c>0)throw new sn(vt.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")})(r);for(const i of r)e=i._apply(e);return e}class TE extends PT{constructor(t,n,r){super(),this._field=t,this._op=n,this._value=r,this.type="where"}static _create(t,n,r){return new TE(t,n,r)}_apply(t){const n=this._parse(t);return RG(t._query,n),new Qu(t.firestore,t.converter,dC(t._query,n))}_parse(t){const n=CE(t.firestore);return(function(a,o,c,h,f,m,y){let w;if(f.isKeyField()){if(m==="array-contains"||m==="array-contains-any")throw new sn(vt.INVALID_ARGUMENT,`Invalid Query. You can't perform '${m}' queries on documentId().`);if(m==="in"||m==="not-in"){t8(y,m);const S=[];for(const C of y)S.push(e8(h,a,C));w={arrayValue:{values:S}}}else w=e8(h,a,y)}else m!=="in"&&m!=="not-in"&&m!=="array-contains-any"||t8(y,m),w=khe(c,o,y,m==="in"||m==="not-in");return oi.create(f,m,w)})(t._query,"where",n,t.firestore._databaseId,this._field,this._op,this._value)}}function Ar(e,t,n){const r=t,i=lm("where",e);return TE._create(i,r,n)}class OT extends TT{constructor(t,n){super(),this.type=t,this._queryConstraints=n}static _create(t,n){return new OT(t,n)}_parse(t){const n=this._queryConstraints.map((r=>r._parse(t))).filter((r=>r.getFilters().length>0));return n.length===1?n[0]:Gi.create(n,this._getOperator())}_apply(t){const n=this._parse(t);return n.getFilters().length===0?t:((function(i,a){let o=i;const c=a.getFlattenedFilters();for(const h of c)RG(o,h),o=dC(o,h)})(t._query,n),new Qu(t.firestore,t.converter,dC(t._query,n)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class RT extends PT{constructor(t,n){super(),this._field=t,this._direction=n,this.type="orderBy"}static _create(t,n){return new RT(t,n)}_apply(t){const n=(function(i,a,o){if(i.startAt!==null)throw new sn(vt.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(i.endAt!==null)throw new sn(vt.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new hy(a,o)})(t._query,this._field,this._direction);return new Qu(t.firestore,t.converter,Jce(t._query,n))}}function ui(e,t="asc"){const n=t,r=lm("orderBy",e);return RT._create(r,n)}class DT extends PT{constructor(t,n,r){super(),this.type=t,this._limit=n,this._limitType=r}static _create(t,n,r){return new DT(t,n,r)}_apply(t){return new Qu(t.firestore,t.converter,x2(t._query,this._limit,this._limitType))}}function vi(e){return ace("limit",e),DT._create("limit",e,"F")}function e8(e,t,n){if(typeof(n=Ca(n))=="string"){if(n==="")throw new sn(vt.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!rH(t)&&n.indexOf("/")!==-1)throw new sn(vt.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=t.path.child(ki.fromString(n));if(!gn.isDocumentKey(r))throw new sn(vt.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return uy(e,new gn(r))}if(n instanceof Xs)return uy(e,n._key);throw new sn(vt.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${oE(n)}.`)}function t8(e,t){if(!Array.isArray(e)||e.length===0)throw new sn(vt.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function RG(e,t){const n=(function(i,a){for(const o of i)for(const c of o.getFlattenedFilters())if(a.indexOf(c.op)>=0)return c.op;return null})(e.filters,(function(i){switch(i){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}})(t.op));if(n!==null)throw n===t.op?new sn(vt.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new sn(vt.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}function DG(e,t,n){let r;return r=e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,r}function Phe(){return new jhe("count")}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Yx(e){return Ohe(e,{count:Phe()})}function Ohe(e,t){const n=qo(e.firestore,Vu),r=Qy(n),i=Lce(t,((a,o)=>new due(o,a.aggregateType,a._internalFieldPath)));return fhe(r,e._query,i).then((a=>(function(c,h,f){const m=new IE(c);return new Ihe(h,m,f)})(n,e,a)))}class Rhe{constructor(t){this.kind="memory",this._onlineComponentProvider=Ag.provider,this._offlineComponentProvider=t!=null&&t.garbageCollector?t.garbageCollector._offlineComponentProvider:{build:()=>new wG(void 0)}}toJSON(){return{kind:this.kind}}}class Dhe{constructor(t){let n;this.kind="persistent",t!=null&&t.tabManager?(t.tabManager._initialize(t),n=t.tabManager):(n=zhe(void 0),n._initialize(t)),this._onlineComponentProvider=n._onlineComponentProvider,this._offlineComponentProvider=n._offlineComponentProvider}toJSON(){return{kind:this.kind}}}function Mhe(e){return new Rhe(e)}function Lhe(e){return new Dhe(e)}class Uhe{constructor(t){this.forceOwnership=t,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(t){this._onlineComponentProvider=Ag.provider,this._offlineComponentProvider={build:n=>new NG(n,t==null?void 0:t.cacheSizeBytes,this.forceOwnership)}}}class Bhe{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(t){this._onlineComponentProvider=Ag.provider,this._offlineComponentProvider={build:n=>new she(n,t==null?void 0:t.cacheSizeBytes)}}}function zhe(e){return new Uhe(e==null?void 0:e.forceOwnership)}function Vhe(){return new Bhe}class N1{constructor(t,n){this.hasPendingWrites=t,this.fromCache=n}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class Up extends PG{constructor(t,n,r,i,a,o){super(t,n,r,i,o),this._firestore=t,this._firestoreImpl=t,this.metadata=a}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const n=new Lw(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(n,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,n={}){if(this._document){const r=this._document.data.field(lm("DocumentSnapshot.get",t));if(r!==null)return this._userDataWriter.convertValue(r,n.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new sn(vt.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const t=this._document,n={};return n.type=Up._jsonSchemaVersion,n.bundle="",n.bundleSource="DocumentSnapshot",n.bundleName=this._key.toString(),!t||!t.isValidDocument()||!t.isFoundDocument()?n:(this._userDataWriter.convertObjectMap(t.data.value.mapValue.fields,"previous"),n.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),n)}}Up._jsonSchemaVersion="firestore/documentSnapshot/1.0",Up._jsonSchema={type:da("string",Up._jsonSchemaVersion),bundleSource:da("string","DocumentSnapshot"),bundleName:da("string"),bundle:da("string")};class Lw extends Up{data(t={}){return super.data(t)}}class Bp{constructor(t,n,r,i){this._firestore=t,this._userDataWriter=n,this._snapshot=i,this.metadata=new N1(i.hasPendingWrites,i.fromCache),this.query=r}get docs(){const t=[];return this.forEach((n=>t.push(n))),t}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(t,n){this._snapshot.docs.forEach((r=>{t.call(n,new Lw(this._firestore,this._userDataWriter,r.key,r,new N1(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(t={}){const n=!!t.includeMetadataChanges;if(n&&this._snapshot.excludesMetadataChanges)throw new sn(vt.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===n||(this._cachedChanges=(function(i,a){if(i._snapshot.oldDocs.isEmpty()){let o=0;return i._snapshot.docChanges.map((c=>{const h=new Lw(i._firestore,i._userDataWriter,c.doc.key,c.doc,new N1(i._snapshot.mutatedKeys.has(c.doc.key),i._snapshot.fromCache),i.query.converter);return c.doc,{type:"added",doc:h,oldIndex:-1,newIndex:o++}}))}{let o=i._snapshot.oldDocs;return i._snapshot.docChanges.filter((c=>a||c.type!==3)).map((c=>{const h=new Lw(i._firestore,i._userDataWriter,c.doc.key,c.doc,new N1(i._snapshot.mutatedKeys.has(c.doc.key),i._snapshot.fromCache),i.query.converter);let f=-1,m=-1;return c.type!==0&&(f=o.indexOf(c.doc.key),o=o.delete(c.doc.key)),c.type!==1&&(o=o.add(c.doc),m=o.indexOf(c.doc.key)),{type:Fhe(c.type),doc:h,oldIndex:f,newIndex:m}}))}})(this,n),this._cachedChangesIncludeMetadataChanges=n),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new sn(vt.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const t={};t.type=Bp._jsonSchemaVersion,t.bundleSource="QuerySnapshot",t.bundleName=DI.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const n=[],r=[],i=[];return this.docs.forEach((a=>{a._document!==null&&(n.push(a._document),r.push(this._userDataWriter.convertObjectMap(a._document.data.value.mapValue.fields,"previous")),i.push(a.ref.path))})),t.bundle=(this._firestore,this.query._query,t.bundleName,"NOT SUPPORTED"),t}}function Fhe(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Tn(61501,{type:e})}}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */Bp._jsonSchemaVersion="firestore/querySnapshot/1.0",Bp._jsonSchema={type:da("string",Bp._jsonSchemaVersion),bundleSource:da("string","QuerySnapshot"),bundleName:da("string"),bundle:da("string")};/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function cs(e){e=qo(e,Xs);const t=qo(e.firestore,Vu),n=Qy(t);return dhe(n,e._key).then((r=>MG(t,e,r)))}function vn(e){e=qo(e,Qu);const t=qo(e.firestore,Vu),n=Qy(t),r=new IE(t);return OG(e._query),hhe(n,e._query).then((i=>new Bp(t,r,e,i)))}function Rr(e,t,n){e=qo(e,Xs);const r=qo(e.firestore,Vu),i=DG(e.converter,t,n),a=CE(r);return PE(r,[kG(a,"setDoc",e._key,i,e.converter!==null,n).toMutation(e._key,ko.none())])}function Cn(e,t,n,...r){e=qo(e,Xs);const i=qo(e.firestore,Vu),a=CE(i);let o;return o=typeof(t=Ca(t))=="string"||t instanceof _T?_he(a,"updateDoc",e._key,t,n,r):Ahe(a,"updateDoc",e._key,t),PE(i,[o.toMutation(e._key,ko.exists(!0))])}function si(e){return PE(qo(e.firestore,Vu),[new yE(e._key,ko.none())])}function ur(e,t){const n=qo(e.firestore,Vu),r=Je(e),i=DG(e.converter,t),a=CE(e.firestore);return PE(n,[kG(a,"addDoc",r._key,i,e.converter!==null,{}).toMutation(r._key,ko.exists(!1))]).then((()=>r))}function Wr(e,...t){var f,m,y;e=Ca(e);let n={includeMetadataChanges:!1,source:"default"},r=0;typeof t[r]!="object"||JD(t[r])||(n=t[r++]);const i={includeMetadataChanges:n.includeMetadataChanges,source:n.source};if(JD(t[r])){const w=t[r];t[r]=(f=w.next)==null?void 0:f.bind(w),t[r+1]=(m=w.error)==null?void 0:m.bind(w),t[r+2]=(y=w.complete)==null?void 0:y.bind(w)}let a,o,c;if(e instanceof Xs)o=qo(e.firestore,Vu),c=Gy(e._key.path),a={next:w=>{t[r]&&t[r](MG(o,e,w))},error:t[r+1],complete:t[r+2]};else{const w=qo(e,Qu);o=qo(w.firestore,Vu),c=w._query;const A=new IE(o);a={next:S=>{t[r]&&t[r](new Bp(o,A,w,S))},error:t[r+1],complete:t[r+2]},OG(e._query)}const h=Qy(o);return uhe(h,c,i,a)}function PE(e,t){const n=Qy(e);return phe(n,t)}function MG(e,t,n){const r=n.docs.get(t._key),i=new IE(e);return new Up(e,i,t._key,r,new N1(n.hasPendingWrites,n.fromCache),t.converter)}(function(t,n=!0){Kle(Lg),ig(new Xp("firestore",((r,{instanceIdentifier:i,options:a})=>{const o=r.getProvider("app").getImmediate(),c=new Vu(new Qle(r.getProvider("auth-internal")),new ece(o,r.getProvider("app-check-internal")),zce(o,i),o);return a={useFetchStreams:n,...a},c._setSettings(a),c}),"PUBLIC").setMultipleInstances(!0)),sf(QD,ZD,t),sf(QD,ZD,"esm2020")})();const $he="AIzaSyCtxUx4H2ZQqg30wPZnyskPGJQE4kGefXQ",Hhe="campus-eye-media-app.firebaseapp.com",Ghe="campus-eye-media-app",qhe="campus-eye-media-app.firebasestorage.app",Whe="612194200932",Khe="1:612194200932:web:f23853033adf101b5e5e71",Yhe="G-8WM12QQDWG",Xhe="(default)",P2={apiKey:$he,authDomain:Hhe,projectId:Ghe,storageBucket:qhe,messagingSenderId:Whe,appId:Khe,measurementId:Yhe,firestoreDatabaseId:Xhe},Qhe={...P2,authDomain:P2.authDomain},LG=IF(Qhe),Ne=qle(LG);Roe(Ne,i$).catch(()=>{});let _C;try{_C=Lhe({tabManager:Vhe()})}catch{_C=Mhe()}const he=bhe(LG,{localCache:_C,experimentalForceLongPolling:!0},P2.firestoreDatabaseId),UG=new Cd;UG.setCustomParameters({prompt:"select_account"});var Ms=(e=>(e.CREATE="create",e.UPDATE="update",e.DELETE="delete",e.LIST="list",e.GET="get",e.WRITE="write",e))(Ms||{});function Ks(e,t,n){var o,c,h,f,m,y;const r=e instanceof Error?e.message:String(e),i={error:r,authInfo:{userId:(o=Ne.currentUser)==null?void 0:o.uid,email:(c=Ne.currentUser)==null?void 0:c.email,emailVerified:(h=Ne.currentUser)==null?void 0:h.emailVerified,isAnonymous:(f=Ne.currentUser)==null?void 0:f.isAnonymous,tenantId:(m=Ne.currentUser)==null?void 0:m.tenantId,providerInfo:((y=Ne.currentUser)==null?void 0:y.providerData.map(w=>({providerId:w.providerId,displayName:w.displayName,email:w.email,photoUrl:w.photoURL})))||[]},operationType:t,path:n};r.toLowerCase().includes("offline")||r.toLowerCase().includes("could not reach")||r.toLowerCase().includes("unavailable")||r.toLowerCase().includes("network")?console.warn("Firestore Handling [Offline State]: ",JSON.stringify(i)):console.error("Firestore Error: ",JSON.stringify(i))}let Zhe={data:""},Jhe=e=>{if(typeof window=="object"){let t=(e?e.querySelector("#_goober"):window._goober)||Object.assign(document.createElement("style"),{innerHTML:" ",id:"_goober"});return t.nonce=window.__nonce__,t.parentNode||(e||document.head).appendChild(t),t.firstChild}return e||Zhe},efe=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,tfe=/\/\*[^]*?\*\/| +/g,n8=/\n+/g,Xh=(e,t)=>{let n="",r="",i="";for(let a in e){let o=e[a];a[0]=="@"?a[1]=="i"?n=a+" "+o+";":r+=a[1]=="f"?Xh(o,a):a+"{"+Xh(o,a[1]=="k"?"":t)+"}":typeof o=="object"?r+=Xh(o,t?t.replace(/([^,])+/g,c=>a.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,h=>/&/.test(h)?h.replace(/&/g,c):c?c+" "+h:h)):a):o!=null&&(a=/^--/.test(a)?a:a.replace(/[A-Z]/g,"-$&").toLowerCase(),i+=Xh.p?Xh.p(a,o):a+":"+o+";")}return n+(t&&i?t+"{"+i+"}":i)+r},Nd={},BG=e=>{if(typeof e=="object"){let t="";for(let n in e)t+=n+BG(e[n]);return t}return e},nfe=(e,t,n,r,i)=>{let a=BG(e),o=Nd[a]||(Nd[a]=(h=>{let f=0,m=11;for(;f>>0;return"go"+m})(a));if(!Nd[o]){let h=a!==e?e:(f=>{let m,y,w=[{}];for(;m=efe.exec(f.replace(tfe,""));)m[4]?w.shift():m[3]?(y=m[3].replace(n8," ").trim(),w.unshift(w[0][y]=w[0][y]||{})):w[0][m[1]]=m[2].replace(n8," ").trim();return w[0]})(e);Nd[o]=Xh(i?{["@keyframes "+o]:h}:h,n?"":"."+o)}let c=n&&Nd.g?Nd.g:null;return n&&(Nd.g=Nd[o]),((h,f,m,y)=>{y?f.data=f.data.replace(y,h):f.data.indexOf(h)===-1&&(f.data=m?h+f.data:f.data+h)})(Nd[o],t,r,c),o},rfe=(e,t,n)=>e.reduce((r,i,a)=>{let o=t[a];if(o&&o.call){let c=o(n),h=c&&c.props&&c.props.className||/^go/.test(c)&&c;o=h?"."+h:c&&typeof c=="object"?c.props?"":Xh(c,""):c===!1?"":c}return r+i+(o??"")},"");function OE(e){let t=this||{},n=e.call?e(t.p):e;return nfe(n.unshift?n.raw?rfe(n,[].slice.call(arguments,1),t.p):n.reduce((r,i)=>Object.assign(r,i&&i.call?i(t.p):i),{}):n,Jhe(t.target),t.g,t.o,t.k)}let zG,kC,SC;OE.bind({g:1});let Gd=OE.bind({k:1});function ife(e,t,n,r){Xh.p=t,zG=e,kC=n,SC=r}function Sf(e,t){let n=this||{};return function(){let r=arguments;function i(a,o){let c=Object.assign({},a),h=c.className||i.className;n.p=Object.assign({theme:kC&&kC()},c),n.o=/ *go\d+/.test(h),c.className=OE.apply(n,r)+(h?" "+h:"");let f=e;return e[0]&&(f=c.as||e,delete c.as),SC&&f[0]&&SC(c),zG(f,c)}return i}}var sfe=e=>typeof e=="function",O2=(e,t)=>sfe(e)?e(t):e,afe=(()=>{let e=0;return()=>(++e).toString()})(),VG=(()=>{let e;return()=>{if(e===void 0&&typeof window<"u"){let t=matchMedia("(prefers-reduced-motion: reduce)");e=!t||t.matches}return e}})(),ofe=20,MT="default",FG=(e,t)=>{let{toastLimit:n}=e.settings;switch(t.type){case 0:return{...e,toasts:[t.toast,...e.toasts].slice(0,n)};case 1:return{...e,toasts:e.toasts.map(o=>o.id===t.toast.id?{...o,...t.toast}:o)};case 2:let{toast:r}=t;return FG(e,{type:e.toasts.find(o=>o.id===r.id)?1:0,toast:r});case 3:let{toastId:i}=t;return{...e,toasts:e.toasts.map(o=>o.id===i||i===void 0?{...o,dismissed:!0,visible:!1}:o)};case 4:return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(o=>o.id!==t.toastId)};case 5:return{...e,pausedAt:t.time};case 6:let a=t.time-(e.pausedAt||0);return{...e,pausedAt:void 0,toasts:e.toasts.map(o=>({...o,pauseDuration:o.pauseDuration+a}))}}},Uw=[],$G={toasts:[],pausedAt:void 0,settings:{toastLimit:ofe}},Iu={},HG=(e,t=MT)=>{Iu[t]=FG(Iu[t]||$G,e),Uw.forEach(([n,r])=>{n===t&&r(Iu[t])})},GG=e=>Object.keys(Iu).forEach(t=>HG(e,t)),lfe=e=>Object.keys(Iu).find(t=>Iu[t].toasts.some(n=>n.id===e)),RE=(e=MT)=>t=>{HG(t,e)},cfe={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},ufe=(e={},t=MT)=>{let[n,r]=I.useState(Iu[t]||$G),i=I.useRef(Iu[t]);I.useEffect(()=>(i.current!==Iu[t]&&r(Iu[t]),Uw.push([t,r]),()=>{let o=Uw.findIndex(([c])=>c===t);o>-1&&Uw.splice(o,1)}),[t]);let a=n.toasts.map(o=>{var c,h,f;return{...e,...e[o.type],...o,removeDelay:o.removeDelay||((c=e[o.type])==null?void 0:c.removeDelay)||(e==null?void 0:e.removeDelay),duration:o.duration||((h=e[o.type])==null?void 0:h.duration)||(e==null?void 0:e.duration)||cfe[o.type],style:{...e.style,...(f=e[o.type])==null?void 0:f.style,...o.style}}});return{...n,toasts:a}},dfe=(e,t="blank",n)=>({createdAt:Date.now(),visible:!0,dismissed:!1,type:t,ariaProps:{role:"status","aria-live":"polite"},message:e,pauseDuration:0,...n,id:(n==null?void 0:n.id)||afe()}),Zy=e=>(t,n)=>{let r=dfe(t,e,n);return RE(r.toasterId||lfe(r.id))({type:2,toast:r}),r.id},pe=(e,t)=>Zy("blank")(e,t);pe.error=Zy("error");pe.success=Zy("success");pe.loading=Zy("loading");pe.custom=Zy("custom");pe.dismiss=(e,t)=>{let n={type:3,toastId:e};t?RE(t)(n):GG(n)};pe.dismissAll=e=>pe.dismiss(void 0,e);pe.remove=(e,t)=>{let n={type:4,toastId:e};t?RE(t)(n):GG(n)};pe.removeAll=e=>pe.remove(void 0,e);pe.promise=(e,t,n)=>{let r=pe.loading(t.loading,{...n,...n==null?void 0:n.loading});return typeof e=="function"&&(e=e()),e.then(i=>{let a=t.success?O2(t.success,i):void 0;return a?pe.success(a,{id:r,...n,...n==null?void 0:n.success}):pe.dismiss(r),i}).catch(i=>{let a=t.error?O2(t.error,i):void 0;a?pe.error(a,{id:r,...n,...n==null?void 0:n.error}):pe.dismiss(r)}),e};var hfe=1e3,ffe=(e,t="default")=>{let{toasts:n,pausedAt:r}=ufe(e,t),i=I.useRef(new Map).current,a=I.useCallback((y,w=hfe)=>{if(i.has(y))return;let A=setTimeout(()=>{i.delete(y),o({type:4,toastId:y})},w);i.set(y,A)},[]);I.useEffect(()=>{if(r)return;let y=Date.now(),w=n.map(A=>{if(A.duration===1/0)return;let S=(A.duration||0)+A.pauseDuration-(y-A.createdAt);if(S<0){A.visible&&pe.dismiss(A.id);return}return setTimeout(()=>pe.dismiss(A.id,t),S)});return()=>{w.forEach(A=>A&&clearTimeout(A))}},[n,r,t]);let o=I.useCallback(RE(t),[t]),c=I.useCallback(()=>{o({type:5,time:Date.now()})},[o]),h=I.useCallback((y,w)=>{o({type:1,toast:{id:y,height:w}})},[o]),f=I.useCallback(()=>{r&&o({type:6,time:Date.now()})},[r,o]),m=I.useCallback((y,w)=>{let{reverseOrder:A=!1,gutter:S=8,defaultPosition:C}=w||{},T=n.filter(L=>(L.position||C)===(y.position||C)&&L.height),D=T.findIndex(L=>L.id===y.id),V=T.filter((L,K)=>KL.visible).slice(...A?[V+1]:[0,V]).reduce((L,K)=>L+(K.height||0)+S,0)},[n]);return I.useEffect(()=>{n.forEach(y=>{if(y.dismissed)a(y.id,y.removeDelay);else{let w=i.get(y.id);w&&(clearTimeout(w),i.delete(y.id))}})},[n,a]),{toasts:n,handlers:{updateHeight:h,startPause:c,endPause:f,calculateOffset:m}}},pfe=Gd` from { transform: scale(0) rotate(45deg); opacity: 0; } to { transform: scale(1) rotate(45deg); opacity: 1; }`,mfe=Gd` from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; }`,gfe=Gd` from { transform: scale(0) rotate(90deg); opacity: 0; } to { transform: scale(1) rotate(90deg); opacity: 1; }`,xfe=Sf("div")` width: 20px; opacity: 0; height: 20px; border-radius: 10px; background: ${e=>e.primary||"#ff4b4b"}; position: relative; transform: rotate(45deg); animation: ${pfe} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; animation-delay: 100ms; &:after, &:before { content: ''; animation: ${mfe} 0.15s ease-out forwards; animation-delay: 150ms; position: absolute; border-radius: 3px; opacity: 0; background: ${e=>e.secondary||"#fff"}; bottom: 9px; left: 4px; height: 2px; width: 12px; } &:before { animation: ${gfe} 0.15s ease-out forwards; animation-delay: 180ms; transform: rotate(90deg); } `,yfe=Gd` from { transform: rotate(0deg); } to { transform: rotate(360deg); } `,bfe=Sf("div")` width: 12px; height: 12px; box-sizing: border-box; border: 2px solid; border-radius: 100%; border-color: ${e=>e.secondary||"#e0e0e0"}; border-right-color: ${e=>e.primary||"#616161"}; animation: ${yfe} 1s linear infinite; `,vfe=Gd` from { transform: scale(0) rotate(45deg); opacity: 0; } to { transform: scale(1) rotate(45deg); opacity: 1; }`,wfe=Gd` 0% { height: 0; width: 0; opacity: 0; } 40% { height: 0; width: 6px; opacity: 1; } 100% { opacity: 1; height: 10px; }`,Nfe=Sf("div")` width: 20px; opacity: 0; height: 20px; border-radius: 10px; background: ${e=>e.primary||"#61d345"}; position: relative; transform: rotate(45deg); animation: ${vfe} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; animation-delay: 100ms; &:after { content: ''; box-sizing: border-box; animation: ${wfe} 0.2s ease-out forwards; opacity: 0; animation-delay: 200ms; position: absolute; border-right: 2px solid; border-bottom: 2px solid; border-color: ${e=>e.secondary||"#fff"}; bottom: 6px; left: 6px; height: 10px; width: 6px; } `,Efe=Sf("div")` position: absolute; `,Afe=Sf("div")` position: relative; display: flex; justify-content: center; align-items: center; min-width: 20px; min-height: 20px; `,_fe=Gd` from { transform: scale(0.6); opacity: 0.4; } to { transform: scale(1); opacity: 1; }`,kfe=Sf("div")` position: relative; transform: scale(0.6); opacity: 0.4; min-width: 20px; animation: ${_fe} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; `,Sfe=({toast:e})=>{let{icon:t,type:n,iconTheme:r}=e;return t!==void 0?typeof t=="string"?I.createElement(kfe,null,t):t:n==="blank"?null:I.createElement(Afe,null,I.createElement(bfe,{...r}),n!=="loading"&&I.createElement(Efe,null,n==="error"?I.createElement(xfe,{...r}):I.createElement(Nfe,{...r})))},Cfe=e=>` 0% {transform: translate3d(0,${e*-200}%,0) scale(.6); opacity:.5;} 100% {transform: translate3d(0,0,0) scale(1); opacity:1;} `,jfe=e=>` 0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;} 100% {transform: translate3d(0,${e*-150}%,-1px) scale(.6); opacity:0;} `,Ife="0%{opacity:0;} 100%{opacity:1;}",Tfe="0%{opacity:1;} 100%{opacity:0;}",Pfe=Sf("div")` display: flex; align-items: center; background: #fff; color: #363636; line-height: 1.3; will-change: transform; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05); max-width: 350px; pointer-events: auto; padding: 8px 10px; border-radius: 8px; `,Ofe=Sf("div")` display: flex; justify-content: center; margin: 4px 10px; color: inherit; flex: 1 1 auto; white-space: pre-line; `,Rfe=(e,t)=>{let n=e.includes("top")?1:-1,[r,i]=VG()?[Ife,Tfe]:[Cfe(n),jfe(n)];return{animation:t?`${Gd(r)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`:`${Gd(i)} 0.4s forwards cubic-bezier(.06,.71,.55,1)`}},Dfe=I.memo(({toast:e,position:t,style:n,children:r})=>{let i=e.height?Rfe(e.position||t||"top-center",e.visible):{opacity:0},a=I.createElement(Sfe,{toast:e}),o=I.createElement(Ofe,{...e.ariaProps},O2(e.message,e));return I.createElement(Pfe,{className:e.className,style:{...i,...n,...e.style}},typeof r=="function"?r({icon:a,message:o}):I.createElement(I.Fragment,null,a,o))});ife(I.createElement);var Mfe=({id:e,className:t,style:n,onHeightUpdate:r,children:i})=>{let a=I.useCallback(o=>{if(o){let c=()=>{let h=o.getBoundingClientRect().height;r(e,h)};c(),new MutationObserver(c).observe(o,{subtree:!0,childList:!0,characterData:!0})}},[e,r]);return I.createElement("div",{ref:a,className:t,style:n},i)},Lfe=(e,t)=>{let n=e.includes("top"),r=n?{top:0}:{bottom:0},i=e.includes("center")?{justifyContent:"center"}:e.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:VG()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${t*(n?1:-1)}px)`,...r,...i}},Ufe=OE` z-index: 9999; > * { pointer-events: auto; } `,zv=16,r8=({reverseOrder:e,position:t="top-center",toastOptions:n,gutter:r,children:i,toasterId:a,containerStyle:o,containerClassName:c})=>{let{toasts:h,handlers:f}=ffe(n,a);return I.createElement("div",{"data-rht-toaster":a||"",style:{position:"fixed",zIndex:9999,top:zv,left:zv,right:zv,bottom:zv,pointerEvents:"none",...o},className:c,onMouseEnter:f.startPause,onMouseLeave:f.endPause},h.map(m=>{let y=m.position||t,w=f.calculateOffset(m,{reverseOrder:e,gutter:r,defaultPosition:t}),A=Lfe(y,w);return I.createElement(Mfe,{id:m.id,key:m.id,onHeightUpdate:f.updateHeight,className:m.visible?Ufe:"",style:A},m.type==="custom"?O2(m.message,m):i?i(m):I.createElement(Dfe,{toast:m,position:y}))}))},ir=pe;function qG(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t{const n=new Array(e.length+t.length);for(let r=0;r({classGroupId:e,validator:t}),WG=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),R2="-",i8=[],Vfe="arbitrary..",Ffe=e=>{const t=Hfe(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return $fe(o);const c=o.split(R2),h=c[0]===""&&c.length>1?1:0;return KG(c,h,t)},getConflictingClassGroupIds:(o,c)=>{if(c){const h=r[o],f=n[o];return h?f?Bfe(f,h):h:f||i8}return n[o]||i8}}},KG=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],a=n.nextPart.get(i);if(a){const f=KG(e,t+1,a);if(f)return f}const o=n.validators;if(o===null)return;const c=t===0?e.join(R2):e.slice(t).join(R2),h=o.length;for(let f=0;fe.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?Vfe+r:void 0})(),Hfe=e=>{const{theme:t,classGroups:n}=e;return Gfe(n,t)},Gfe=(e,t)=>{const n=WG();for(const r in e){const i=e[r];LT(i,n,r,t)}return n},LT=(e,t,n,r)=>{const i=e.length;for(let a=0;a{if(typeof e=="string"){Wfe(e,t,n);return}if(typeof e=="function"){Kfe(e,t,n,r);return}Yfe(e,t,n,r)},Wfe=(e,t,n)=>{const r=e===""?t:YG(t,e);r.classGroupId=n},Kfe=(e,t,n,r)=>{if(Xfe(e)){LT(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(zfe(n,e))},Yfe=(e,t,n,r)=>{const i=Object.entries(e),a=i.length;for(let o=0;o{let n=e;const r=t.split(R2),i=r.length;for(let a=0;a"isThemeGetter"in e&&e.isThemeGetter===!0,Qfe=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(a,o)=>{n[a]=o,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(a){let o=n[a];if(o!==void 0)return o;if((o=r[a])!==void 0)return i(a,o),o},set(a,o){a in n?n[a]=o:i(a,o)}}},CC="!",s8=":",Zfe=[],a8=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Jfe=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const a=[];let o=0,c=0,h=0,f;const m=i.length;for(let C=0;Ch?f-h:void 0;return a8(a,A,w,S)};if(t){const i=t+s8,a=r;r=o=>o.startsWith(i)?a(o.slice(i.length)):a8(Zfe,!1,o,void 0,!0)}if(n){const i=r;r=a=>n({className:a,parseClassName:i})}return r},epe=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let a=0;a0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},tpe=e=>({cache:Qfe(e.cacheSize),parseClassName:Jfe(e),sortModifiers:epe(e),...Ffe(e)}),npe=/\s+/,rpe=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],c=e.trim().split(npe);let h="";for(let f=c.length-1;f>=0;f-=1){const m=c[f],{isExternal:y,modifiers:w,hasImportantModifier:A,baseClassName:S,maybePostfixModifierPosition:C}=n(m);if(y){h=m+(h.length>0?" "+h:h);continue}let T=!!C,D=r(T?S.substring(0,C):S);if(!D){if(!T){h=m+(h.length>0?" "+h:h);continue}if(D=r(S),!D){h=m+(h.length>0?" "+h:h);continue}T=!1}const V=w.length===0?"":w.length===1?w[0]:a(w).join(":"),L=A?V+CC:V,K=L+D;if(o.indexOf(K)>-1)continue;o.push(K);const Z=i(D,T);for(let q=0;q0?" "+h:h)}return h},ipe=(...e)=>{let t=0,n,r,i="";for(;t{if(typeof e=="string")return e;let t,n="";for(let r=0;r{let n,r,i,a;const o=h=>{const f=t.reduce((m,y)=>y(m),e());return n=tpe(f),r=n.cache.get,i=n.cache.set,a=c,c(h)},c=h=>{const f=r(h);if(f)return f;const m=rpe(h,n);return i(h,m),m};return a=o,(...h)=>a(ipe(...h))},ape=[],ba=e=>{const t=n=>n[e]||ape;return t.isThemeGetter=!0,t},QG=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ZG=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ope=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,lpe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,cpe=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,upe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,dpe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,hpe=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Dh=e=>ope.test(e),qr=e=>!!e&&!Number.isNaN(Number(e)),Mh=e=>!!e&&Number.isInteger(Number(e)),g_=e=>e.endsWith("%")&&qr(e.slice(0,-1)),Ed=e=>lpe.test(e),JG=()=>!0,fpe=e=>cpe.test(e)&&!upe.test(e),UT=()=>!1,ppe=e=>dpe.test(e),mpe=e=>hpe.test(e),gpe=e=>!Bn(e)&&!Hn(e),xpe=e=>Cf(e,nq,UT),Bn=e=>QG.test(e),tp=e=>Cf(e,rq,fpe),o8=e=>Cf(e,_pe,qr),ype=e=>Cf(e,sq,JG),bpe=e=>Cf(e,iq,UT),l8=e=>Cf(e,eq,UT),vpe=e=>Cf(e,tq,mpe),Vv=e=>Cf(e,aq,ppe),Hn=e=>ZG.test(e),Xx=e=>Nm(e,rq),wpe=e=>Nm(e,iq),c8=e=>Nm(e,eq),Npe=e=>Nm(e,nq),Epe=e=>Nm(e,tq),Fv=e=>Nm(e,aq,!0),Ape=e=>Nm(e,sq,!0),Cf=(e,t,n)=>{const r=QG.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Nm=(e,t,n=!1)=>{const r=ZG.exec(e);return r?r[1]?t(r[1]):n:!1},eq=e=>e==="position"||e==="percentage",tq=e=>e==="image"||e==="url",nq=e=>e==="length"||e==="size"||e==="bg-size",rq=e=>e==="length",_pe=e=>e==="number",iq=e=>e==="family-name",sq=e=>e==="number"||e==="weight",aq=e=>e==="shadow",kpe=()=>{const e=ba("color"),t=ba("font"),n=ba("text"),r=ba("font-weight"),i=ba("tracking"),a=ba("leading"),o=ba("breakpoint"),c=ba("container"),h=ba("spacing"),f=ba("radius"),m=ba("shadow"),y=ba("inset-shadow"),w=ba("text-shadow"),A=ba("drop-shadow"),S=ba("blur"),C=ba("perspective"),T=ba("aspect"),D=ba("ease"),V=ba("animate"),L=()=>["auto","avoid","all","avoid-page","page","left","right","column"],K=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],Z=()=>[...K(),Hn,Bn],q=()=>["auto","hidden","clip","visible","scroll"],B=()=>["auto","contain","none"],z=()=>[Hn,Bn,h],F=()=>[Dh,"full","auto",...z()],$=()=>[Mh,"none","subgrid",Hn,Bn],Y=()=>["auto",{span:["full",Mh,Hn,Bn]},Mh,Hn,Bn],X=()=>[Mh,"auto",Hn,Bn],J=()=>["auto","min","max","fr",Hn,Bn],ye=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ne=()=>["start","end","center","stretch","center-safe","end-safe"],de=()=>["auto",...z()],be=()=>[Dh,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...z()],Ce=()=>[Dh,"screen","full","dvw","lvw","svw","min","max","fit",...z()],Ke=()=>[Dh,"screen","full","lh","dvh","lvh","svh","min","max","fit",...z()],G=()=>[e,Hn,Bn],se=()=>[...K(),c8,l8,{position:[Hn,Bn]}],xe=()=>["no-repeat",{repeat:["","x","y","space","round"]}],re=()=>["auto","cover","contain",Npe,xpe,{size:[Hn,Bn]}],Me=()=>[g_,Xx,tp],nt=()=>["","none","full",f,Hn,Bn],ze=()=>["",qr,Xx,tp],Tt=()=>["solid","dashed","dotted","double"],It=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ft=()=>[qr,g_,c8,l8],Ee=()=>["","none",S,Hn,Bn],yt=()=>["none",qr,Hn,Bn],Ue=()=>["none",qr,Hn,Bn],Vt=()=>[qr,Hn,Bn],St=()=>[Dh,"full",...z()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ed],breakpoint:[Ed],color:[JG],container:[Ed],"drop-shadow":[Ed],ease:["in","out","in-out"],font:[gpe],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ed],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ed],shadow:[Ed],spacing:["px",qr],text:[Ed],"text-shadow":[Ed],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Dh,Bn,Hn,T]}],container:["container"],columns:[{columns:[qr,Bn,Hn,c]}],"break-after":[{"break-after":L()}],"break-before":[{"break-before":L()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:Z()}],overflow:[{overflow:q()}],"overflow-x":[{"overflow-x":q()}],"overflow-y":[{"overflow-y":q()}],overscroll:[{overscroll:B()}],"overscroll-x":[{"overscroll-x":B()}],"overscroll-y":[{"overscroll-y":B()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:F()}],"inset-x":[{"inset-x":F()}],"inset-y":[{"inset-y":F()}],start:[{"inset-s":F(),start:F()}],end:[{"inset-e":F(),end:F()}],"inset-bs":[{"inset-bs":F()}],"inset-be":[{"inset-be":F()}],top:[{top:F()}],right:[{right:F()}],bottom:[{bottom:F()}],left:[{left:F()}],visibility:["visible","invisible","collapse"],z:[{z:[Mh,"auto",Hn,Bn]}],basis:[{basis:[Dh,"full","auto",c,...z()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[qr,Dh,"auto","initial","none",Bn]}],grow:[{grow:["",qr,Hn,Bn]}],shrink:[{shrink:["",qr,Hn,Bn]}],order:[{order:[Mh,"first","last","none",Hn,Bn]}],"grid-cols":[{"grid-cols":$()}],"col-start-end":[{col:Y()}],"col-start":[{"col-start":X()}],"col-end":[{"col-end":X()}],"grid-rows":[{"grid-rows":$()}],"row-start-end":[{row:Y()}],"row-start":[{"row-start":X()}],"row-end":[{"row-end":X()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":J()}],"auto-rows":[{"auto-rows":J()}],gap:[{gap:z()}],"gap-x":[{"gap-x":z()}],"gap-y":[{"gap-y":z()}],"justify-content":[{justify:[...ye(),"normal"]}],"justify-items":[{"justify-items":[...ne(),"normal"]}],"justify-self":[{"justify-self":["auto",...ne()]}],"align-content":[{content:["normal",...ye()]}],"align-items":[{items:[...ne(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ne(),{baseline:["","last"]}]}],"place-content":[{"place-content":ye()}],"place-items":[{"place-items":[...ne(),"baseline"]}],"place-self":[{"place-self":["auto",...ne()]}],p:[{p:z()}],px:[{px:z()}],py:[{py:z()}],ps:[{ps:z()}],pe:[{pe:z()}],pbs:[{pbs:z()}],pbe:[{pbe:z()}],pt:[{pt:z()}],pr:[{pr:z()}],pb:[{pb:z()}],pl:[{pl:z()}],m:[{m:de()}],mx:[{mx:de()}],my:[{my:de()}],ms:[{ms:de()}],me:[{me:de()}],mbs:[{mbs:de()}],mbe:[{mbe:de()}],mt:[{mt:de()}],mr:[{mr:de()}],mb:[{mb:de()}],ml:[{ml:de()}],"space-x":[{"space-x":z()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":z()}],"space-y-reverse":["space-y-reverse"],size:[{size:be()}],"inline-size":[{inline:["auto",...Ce()]}],"min-inline-size":[{"min-inline":["auto",...Ce()]}],"max-inline-size":[{"max-inline":["none",...Ce()]}],"block-size":[{block:["auto",...Ke()]}],"min-block-size":[{"min-block":["auto",...Ke()]}],"max-block-size":[{"max-block":["none",...Ke()]}],w:[{w:[c,"screen",...be()]}],"min-w":[{"min-w":[c,"screen","none",...be()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...be()]}],h:[{h:["screen","lh",...be()]}],"min-h":[{"min-h":["screen","lh","none",...be()]}],"max-h":[{"max-h":["screen","lh",...be()]}],"font-size":[{text:["base",n,Xx,tp]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ape,ype]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",g_,Bn]}],"font-family":[{font:[wpe,bpe,t]}],"font-features":[{"font-features":[Bn]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,Hn,Bn]}],"line-clamp":[{"line-clamp":[qr,"none",Hn,o8]}],leading:[{leading:[a,...z()]}],"list-image":[{"list-image":["none",Hn,Bn]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Hn,Bn]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:G()}],"text-color":[{text:G()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Tt(),"wavy"]}],"text-decoration-thickness":[{decoration:[qr,"from-font","auto",Hn,tp]}],"text-decoration-color":[{decoration:G()}],"underline-offset":[{"underline-offset":[qr,"auto",Hn,Bn]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:z()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Hn,Bn]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Hn,Bn]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:se()}],"bg-repeat":[{bg:xe()}],"bg-size":[{bg:re()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Mh,Hn,Bn],radial:["",Hn,Bn],conic:[Mh,Hn,Bn]},Epe,vpe]}],"bg-color":[{bg:G()}],"gradient-from-pos":[{from:Me()}],"gradient-via-pos":[{via:Me()}],"gradient-to-pos":[{to:Me()}],"gradient-from":[{from:G()}],"gradient-via":[{via:G()}],"gradient-to":[{to:G()}],rounded:[{rounded:nt()}],"rounded-s":[{"rounded-s":nt()}],"rounded-e":[{"rounded-e":nt()}],"rounded-t":[{"rounded-t":nt()}],"rounded-r":[{"rounded-r":nt()}],"rounded-b":[{"rounded-b":nt()}],"rounded-l":[{"rounded-l":nt()}],"rounded-ss":[{"rounded-ss":nt()}],"rounded-se":[{"rounded-se":nt()}],"rounded-ee":[{"rounded-ee":nt()}],"rounded-es":[{"rounded-es":nt()}],"rounded-tl":[{"rounded-tl":nt()}],"rounded-tr":[{"rounded-tr":nt()}],"rounded-br":[{"rounded-br":nt()}],"rounded-bl":[{"rounded-bl":nt()}],"border-w":[{border:ze()}],"border-w-x":[{"border-x":ze()}],"border-w-y":[{"border-y":ze()}],"border-w-s":[{"border-s":ze()}],"border-w-e":[{"border-e":ze()}],"border-w-bs":[{"border-bs":ze()}],"border-w-be":[{"border-be":ze()}],"border-w-t":[{"border-t":ze()}],"border-w-r":[{"border-r":ze()}],"border-w-b":[{"border-b":ze()}],"border-w-l":[{"border-l":ze()}],"divide-x":[{"divide-x":ze()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ze()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Tt(),"hidden","none"]}],"divide-style":[{divide:[...Tt(),"hidden","none"]}],"border-color":[{border:G()}],"border-color-x":[{"border-x":G()}],"border-color-y":[{"border-y":G()}],"border-color-s":[{"border-s":G()}],"border-color-e":[{"border-e":G()}],"border-color-bs":[{"border-bs":G()}],"border-color-be":[{"border-be":G()}],"border-color-t":[{"border-t":G()}],"border-color-r":[{"border-r":G()}],"border-color-b":[{"border-b":G()}],"border-color-l":[{"border-l":G()}],"divide-color":[{divide:G()}],"outline-style":[{outline:[...Tt(),"none","hidden"]}],"outline-offset":[{"outline-offset":[qr,Hn,Bn]}],"outline-w":[{outline:["",qr,Xx,tp]}],"outline-color":[{outline:G()}],shadow:[{shadow:["","none",m,Fv,Vv]}],"shadow-color":[{shadow:G()}],"inset-shadow":[{"inset-shadow":["none",y,Fv,Vv]}],"inset-shadow-color":[{"inset-shadow":G()}],"ring-w":[{ring:ze()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:G()}],"ring-offset-w":[{"ring-offset":[qr,tp]}],"ring-offset-color":[{"ring-offset":G()}],"inset-ring-w":[{"inset-ring":ze()}],"inset-ring-color":[{"inset-ring":G()}],"text-shadow":[{"text-shadow":["none",w,Fv,Vv]}],"text-shadow-color":[{"text-shadow":G()}],opacity:[{opacity:[qr,Hn,Bn]}],"mix-blend":[{"mix-blend":[...It(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":It()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[qr]}],"mask-image-linear-from-pos":[{"mask-linear-from":ft()}],"mask-image-linear-to-pos":[{"mask-linear-to":ft()}],"mask-image-linear-from-color":[{"mask-linear-from":G()}],"mask-image-linear-to-color":[{"mask-linear-to":G()}],"mask-image-t-from-pos":[{"mask-t-from":ft()}],"mask-image-t-to-pos":[{"mask-t-to":ft()}],"mask-image-t-from-color":[{"mask-t-from":G()}],"mask-image-t-to-color":[{"mask-t-to":G()}],"mask-image-r-from-pos":[{"mask-r-from":ft()}],"mask-image-r-to-pos":[{"mask-r-to":ft()}],"mask-image-r-from-color":[{"mask-r-from":G()}],"mask-image-r-to-color":[{"mask-r-to":G()}],"mask-image-b-from-pos":[{"mask-b-from":ft()}],"mask-image-b-to-pos":[{"mask-b-to":ft()}],"mask-image-b-from-color":[{"mask-b-from":G()}],"mask-image-b-to-color":[{"mask-b-to":G()}],"mask-image-l-from-pos":[{"mask-l-from":ft()}],"mask-image-l-to-pos":[{"mask-l-to":ft()}],"mask-image-l-from-color":[{"mask-l-from":G()}],"mask-image-l-to-color":[{"mask-l-to":G()}],"mask-image-x-from-pos":[{"mask-x-from":ft()}],"mask-image-x-to-pos":[{"mask-x-to":ft()}],"mask-image-x-from-color":[{"mask-x-from":G()}],"mask-image-x-to-color":[{"mask-x-to":G()}],"mask-image-y-from-pos":[{"mask-y-from":ft()}],"mask-image-y-to-pos":[{"mask-y-to":ft()}],"mask-image-y-from-color":[{"mask-y-from":G()}],"mask-image-y-to-color":[{"mask-y-to":G()}],"mask-image-radial":[{"mask-radial":[Hn,Bn]}],"mask-image-radial-from-pos":[{"mask-radial-from":ft()}],"mask-image-radial-to-pos":[{"mask-radial-to":ft()}],"mask-image-radial-from-color":[{"mask-radial-from":G()}],"mask-image-radial-to-color":[{"mask-radial-to":G()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":K()}],"mask-image-conic-pos":[{"mask-conic":[qr]}],"mask-image-conic-from-pos":[{"mask-conic-from":ft()}],"mask-image-conic-to-pos":[{"mask-conic-to":ft()}],"mask-image-conic-from-color":[{"mask-conic-from":G()}],"mask-image-conic-to-color":[{"mask-conic-to":G()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:se()}],"mask-repeat":[{mask:xe()}],"mask-size":[{mask:re()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Hn,Bn]}],filter:[{filter:["","none",Hn,Bn]}],blur:[{blur:Ee()}],brightness:[{brightness:[qr,Hn,Bn]}],contrast:[{contrast:[qr,Hn,Bn]}],"drop-shadow":[{"drop-shadow":["","none",A,Fv,Vv]}],"drop-shadow-color":[{"drop-shadow":G()}],grayscale:[{grayscale:["",qr,Hn,Bn]}],"hue-rotate":[{"hue-rotate":[qr,Hn,Bn]}],invert:[{invert:["",qr,Hn,Bn]}],saturate:[{saturate:[qr,Hn,Bn]}],sepia:[{sepia:["",qr,Hn,Bn]}],"backdrop-filter":[{"backdrop-filter":["","none",Hn,Bn]}],"backdrop-blur":[{"backdrop-blur":Ee()}],"backdrop-brightness":[{"backdrop-brightness":[qr,Hn,Bn]}],"backdrop-contrast":[{"backdrop-contrast":[qr,Hn,Bn]}],"backdrop-grayscale":[{"backdrop-grayscale":["",qr,Hn,Bn]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[qr,Hn,Bn]}],"backdrop-invert":[{"backdrop-invert":["",qr,Hn,Bn]}],"backdrop-opacity":[{"backdrop-opacity":[qr,Hn,Bn]}],"backdrop-saturate":[{"backdrop-saturate":[qr,Hn,Bn]}],"backdrop-sepia":[{"backdrop-sepia":["",qr,Hn,Bn]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":z()}],"border-spacing-x":[{"border-spacing-x":z()}],"border-spacing-y":[{"border-spacing-y":z()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Hn,Bn]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[qr,"initial",Hn,Bn]}],ease:[{ease:["linear","initial",D,Hn,Bn]}],delay:[{delay:[qr,Hn,Bn]}],animate:[{animate:["none",V,Hn,Bn]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[C,Hn,Bn]}],"perspective-origin":[{"perspective-origin":Z()}],rotate:[{rotate:yt()}],"rotate-x":[{"rotate-x":yt()}],"rotate-y":[{"rotate-y":yt()}],"rotate-z":[{"rotate-z":yt()}],scale:[{scale:Ue()}],"scale-x":[{"scale-x":Ue()}],"scale-y":[{"scale-y":Ue()}],"scale-z":[{"scale-z":Ue()}],"scale-3d":["scale-3d"],skew:[{skew:Vt()}],"skew-x":[{"skew-x":Vt()}],"skew-y":[{"skew-y":Vt()}],transform:[{transform:[Hn,Bn,"","none","gpu","cpu"]}],"transform-origin":[{origin:Z()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:St()}],"translate-x":[{"translate-x":St()}],"translate-y":[{"translate-y":St()}],"translate-z":[{"translate-z":St()}],"translate-none":["translate-none"],accent:[{accent:G()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:G()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Hn,Bn]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":z()}],"scroll-mx":[{"scroll-mx":z()}],"scroll-my":[{"scroll-my":z()}],"scroll-ms":[{"scroll-ms":z()}],"scroll-me":[{"scroll-me":z()}],"scroll-mbs":[{"scroll-mbs":z()}],"scroll-mbe":[{"scroll-mbe":z()}],"scroll-mt":[{"scroll-mt":z()}],"scroll-mr":[{"scroll-mr":z()}],"scroll-mb":[{"scroll-mb":z()}],"scroll-ml":[{"scroll-ml":z()}],"scroll-p":[{"scroll-p":z()}],"scroll-px":[{"scroll-px":z()}],"scroll-py":[{"scroll-py":z()}],"scroll-ps":[{"scroll-ps":z()}],"scroll-pe":[{"scroll-pe":z()}],"scroll-pbs":[{"scroll-pbs":z()}],"scroll-pbe":[{"scroll-pbe":z()}],"scroll-pt":[{"scroll-pt":z()}],"scroll-pr":[{"scroll-pr":z()}],"scroll-pb":[{"scroll-pb":z()}],"scroll-pl":[{"scroll-pl":z()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Hn,Bn]}],fill:[{fill:["none",...G()]}],"stroke-w":[{stroke:[qr,Xx,tp,o8]}],stroke:[{stroke:["none",...G()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Spe=spe(kpe);function Fe(...e){return Spe(Pi(e))}function fl(e){return e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"M":e>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+"k":e.toString()}function M0(e){return e?e.toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):""}function oq(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof(e==null?void 0:e.toDate)=="function"){const t=e.toDate();return isNaN(t.getTime())?null:t}if(typeof e=="object"&&typeof e.seconds=="number"){const t=new Date(e.seconds*1e3);return isNaN(t.getTime())?null:t}if(typeof e=="number"){const t=new Date(e);return isNaN(t.getTime())?null:t}if(typeof e=="string"){const t=new Date(e);return isNaN(t.getTime())?null:t}return null}function Cpe(e){const t=oq(e);return t?t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):""}function X0(e){const t=oq(e);if(!t)return"now";const r=new Date().getTime()-t.getTime();if(r<0)return"now";const i=Math.floor(r/6e4);if(i<60)return`${i||1}m`;const a=Math.floor(i/60);if(a<24)return`${a}hr`;const o=Math.floor(a/24);if(o<7)return`${o}d`;const c=t.getDate(),h=t.getMonth()+1,f=String(t.getFullYear()).substring(2);return`${c}/${h}/${f}`}async function Md(e){try{window.focus()}catch(t){console.warn("Could not focus window:",t)}try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(e),!0}catch(t){console.warn("Modern Clipboard API failed, trying fallback textarea copy...",t)}try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.fontSize="12pt",t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.width="2em",t.style.height="2em",t.style.padding="0",t.style.border="none",t.style.outline="none",t.style.boxShadow="none",t.style.background="transparent",document.body.appendChild(t);const n=document.activeElement;t.focus(),t.select(),t.setSelectionRange(0,999999);const r=document.execCommand("copy");if(n&&typeof n.focus=="function"&&n.focus(),document.body.removeChild(t),r)return!0}catch(t){console.error("All fallback copy methods failed:",t)}return!1}function jpe(e,t=700,n=80){var o;if(!e||typeof e!="string")return"";if(e.startsWith("data:")||e.startsWith("blob:")||e.endsWith(".svg"))return e;const r=typeof navigator<"u"&&((o=navigator.connection)==null?void 0:o.saveData),i=r?Math.min(t,480):t,a=r?Math.min(n,65):n;if(e.includes("images.unsplash.com"))try{const c=new URL(e);return c.searchParams.set("auto","format"),c.searchParams.set("fit","crop"),c.searchParams.set("w",i.toString()),c.searchParams.set("q",a.toString()),c.toString()}catch{return e}if(e.includes("res.cloudinary.com"))try{return e.includes("/upload/")&&!e.includes("/f_auto")?e.replace("/upload/",`/upload/f_auto,q_auto,w_${i}/`):e}catch{return e}return e.includes("googleusercontent.com")&&e.includes("=s")?e.replace(/=s\d+(-c)?/i,`=s${Math.min(i,200)}-c`):e}const lq=({size:e=20,className:t=""})=>s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",style:{width:e,height:e},className:Fe("fill-current",t),children:s.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),cq=({size:e=20,className:t=""})=>s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",style:{width:e,height:e},className:Fe("fill-current",t),children:s.jsx("path",{d:"M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.17-2.89-.6-4.13-1.47-.13-.09-.26-.18-.38-.28v6.51c.02 2.44-.95 4.93-2.91 6.41-1.96 1.48-4.71 1.94-7.01 1.16-2.31-.78-4.12-2.83-4.76-5.19-.64-2.36-.14-5.04 1.41-6.95 1.55-1.91 4.11-2.97 6.54-2.73v4.07c-1.21-.11-2.47.23-3.41 1.01-.94.78-1.44 2.01-1.31 3.23.13 1.22.95 2.32 2.06 2.86 1.11.54 2.5.47 3.54-.21.93-.61 1.48-1.68 1.46-2.79V.02z"})}),jC=({size:e=20,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{width:e,height:e},className:Fe("shrink-0",t),children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsxs("g",{fill:"none",children:[s.jsx("path",{fill:"url(#SVGv76srdyf_opt)",d:"M12.252 18.506a10.4 10.4 0 0 0 1.875-.302a5.2 5.2 0 0 0 2.342.151a1 1 0 0 1 .094-.007c.279 0 .645.16 1.179.497v-.554a.54.54 0 0 1 .28-.472q.349-.197.645-.443c.778-.65 1.217-1.518 1.217-2.436c0-.303-.048-.605-.143-.893a7 7 0 0 0 .564-1.359c.45.665.692 1.45.695 2.252c0 1.248-.588 2.412-1.607 3.263q-.256.213-.535.392v1.298c0 .446-.522.703-.89.437a14 14 0 0 0-1.08-.72a3 3 0 0 0-.332-.165a6.4 6.4 0 0 1-.935.069c-1.27 0-2.445-.377-3.37-1.008m-6.72-2.595C3.927 14.568 3 12.737 3 10.775c0-4.008 3.832-7.213 8.511-7.213c4.68 0 8.513 3.204 8.513 7.213s-3.833 7.212-8.513 7.212a10 10 0 0 1-1.555-.12c-.22.051-1.102.568-2.372 1.483c-.46.332-1.112.012-1.112-.547V16.59a8 8 0 0 1-.94-.68m4.455.592q.058 0 .117.009q.69.114 1.407.115c3.953 0 7.116-2.645 7.116-5.852c0-3.206-3.163-5.85-7.115-5.85s-7.117 2.644-7.117 5.85c0 1.55.74 3.01 2.046 4.103q.494.412 1.076.74a.68.68 0 0 1 .35.589v1.276c1.005-.665 1.666-.98 2.12-.98"}),s.jsx("path",{fill:"url(#SVGv76srdyf_opt)",d:"M8.062 12a1.125 1.125 0 1 0 0-2.25a1.125 1.125 0 0 0 0 2.25"}),s.jsx("path",{fill:"url(#SVGv76srdyf_opt)",d:"M11.719 12a1.125 1.125 0 1 0 0-2.25a1.125 1.125 0 0 0 0 2.25"}),s.jsx("path",{fill:"url(#SVGohGBlcQN_opt)",d:"M15.375 12a1.125 1.125 0 1 0 0-2.25a1.125 1.125 0 0 0 0 2.25"}),s.jsxs("defs",{children:[s.jsxs("linearGradient",{id:"SVGv76srdyf_opt",x1:"12",x2:"12",y1:"3.562",y2:"20.438",gradientUnits:"userSpaceOnUse",children:[s.jsx("stop",{stopColor:"#1bc9fa"}),s.jsx("stop",{offset:"1",stopColor:"#1778f0"})]}),s.jsxs("linearGradient",{id:"SVGohGBlcQN_opt",x1:"12",x2:"12",y1:"3.561",y2:"20.437",gradientUnits:"userSpaceOnUse",children:[s.jsx("stop",{stopColor:"#1bc9fa"}),s.jsx("stop",{offset:"1",stopColor:"#1778f0"})]})]})]})]}),uq=({size:e=20,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 14 14",style:{width:e,height:e},className:Fe("shrink-0",t),children:[s.jsx("path",{d:"M0 0h14v14H0z",fill:"none"}),s.jsxs("g",{fill:"none",fillRule:"evenodd",clipRule:"evenodd",children:[s.jsx("path",{fill:"#8fbffa",d:"M6.45 1.418a1.504 1.504 0 0 1 2.72 1.073L8.973 3.89h1.915c.567 0 1.327.268 1.944.762C13.466 5.158 14 5.944 14 7c0 .986-.477 2.502-1.169 3.755c-.35.634-.77 1.233-1.245 1.681c-.469.442-1.043.786-1.687.786c-2.447 0-4.304-.313-7.155-1.44a1 1 0 0 0 .006-.129v-5.05z"}),s.jsx("path",{fill:"#2859c5",d:"M1.375 4.528C.615 4.528 0 5.144 0 5.903v5.75a1.375 1.375 0 1 0 2.75 0v-5.75c0-.76-.616-1.375-1.375-1.375"})]})]}),IC=({size:e=20,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{width:e,height:e},className:Fe("shrink-0",t),children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"#2233ca",fillOpacity:".25",d:"M20.188 10.934c.388.472.582.707.582 1.066s-.194.594-.582 1.066C18.768 14.79 15.636 18 12 18s-6.768-3.21-8.188-4.934c-.388-.472-.582-.707-.582-1.066s.194-.594.582-1.066C5.232 9.21 8.364 6 12 6s6.768 3.21 8.188 4.934"}),s.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"#2233ca"})]}),dq=({size:e=20,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",style:{width:e,height:e},className:Fe("shrink-0",t),children:[s.jsx("path",{d:"M0 0h16v16H0z",fill:"none"}),s.jsxs("g",{fill:"none",children:[s.jsx("path",{fill:"url(#SVGznV2abgm_opt)",d:"M3.78 13.919a.5.5 0 0 1-.778-.416V4.012a2 2 0 0 1 1.996-2l6-.011a2 2 0 0 1 2.004 1.996v9.506a.5.5 0 0 1-.778.416l-4.222-2.82z"}),s.jsx("defs",{children:s.jsxs("linearGradient",{id:"SVGznV2abgm_opt",x1:"3.002",x2:"9.302",y1:"3.019",y2:"11.914",gradientUnits:"userSpaceOnUse",children:[s.jsx("stop",{stopColor:"#f97dbd"}),s.jsx("stop",{offset:"1",stopColor:"#d7257d"})]})})]})]}),Bw=({size:e=20,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{width:e,height:e},className:Fe("shrink-0",t),children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"#2233ca",d:"M14 5v4C7 10 4 15 3 20c2.5-3.5 6-5.1 11-5.1V19l7-7zm2 4.83L18.17 12L16 14.17V12.9h-2c-2.07 0-3.93.38-5.66.95c1.4-1.39 3.2-2.48 5.94-2.85l1.72-.27z"})]}),Fo=({size:e=14,className:t="",tooltipText:n="Verified User"})=>{const[r,i]=ie.useState(!1),a=o=>{o.stopPropagation(),o.preventDefault(),i(c=>!c),ir.success("Verified Account: This user's identity and editorial credentials have been fully verified by Campus Eye.",{icon:"🛡️",duration:3500})};return s.jsxs("span",{onClick:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),className:Fe("relative inline-flex items-center justify-center cursor-pointer select-none transition-transform duration-300 hover:scale-125 active:scale-90",t),children:[r&&s.jsxs("span",{className:"absolute bottom-full mb-2 left-1/2 -translate-x-1/2 z-50 pointer-events-none flex flex-col items-center animate-in fade-in zoom-in-95 duration-150",children:[s.jsx("span",{className:"bg-white text-gray-900 text-[11px] font-semibold px-2.5 py-1 rounded-md shadow-xl border border-gray-200/90 whitespace-nowrap leading-tight",children:n}),s.jsx("span",{className:"w-0 h-0 border-x-4 border-x-transparent border-t-4 border-t-white -mt-[0.5px] filter drop-shadow-xs"})]}),s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{width:e,height:e},className:"shrink-0",children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"#1d9bf0",fillRule:"evenodd",d:"M15.418 5.643a1.25 1.25 0 0 0-1.34-.555l-1.798.413a1.25 1.25 0 0 1-.56 0l-1.798-.413a1.25 1.25 0 0 0-1.34-.555l-.98 1.564c-.1.16-.235.295-.395.396l-1.564.98a1.25 1.25 0 0 0-.555 1.338l.413 1.8a1.25 1.25 0 0 1 0 .559l-.413 1.799a1.25 1.25 0 0 0 .555 1.339l1.564.98c.16.1.295.235.396.395l.98 1.564c.282.451.82.674 1.339.555l1.798-.413a1.25 1.25 0 0 1 .56 0l1.799.413a1.25 1.25 0 0 0 1.339-.555l.98-1.564c.1-.16.235-.295.395-.395l1.565-.98a1.25 1.25 0 0 0 .554-1.34L18.5 12.28a1.25 1.25 0 0 1 0-.56l.413-1.799a1.25 1.25 0 0 0-.554-1.339l-1.565-.98a1.25 1.25 0 0 1-.395-.395zm-.503 4.127a.5.5 0 0 0-.86-.509l-2.615 4.426l-1.579-1.512a.5.5 0 1 0-.691.722l2.034 1.949a.5.5 0 0 0 .776-.107z",clipRule:"evenodd"})]})]})},Ipe=({size:e=16,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",style:{width:e,height:e},className:Fe("shrink-0",t),children:[s.jsx("path",{d:"M0 0h16v16H0z",fill:"none"}),s.jsx("path",{fill:"none",stroke:"#ea0e21",d:"M2 2.5h12M7.979 13.906V4.957m4.13 3.889L7.98 4.715l-4.131 4.13"})]}),Tpe=({size:e=18,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",style:{width:e,height:e},className:Fe("shrink-0",t),children:[s.jsx("path",{d:"M0 0h512v512H0z",fill:"none"}),s.jsx("path",{fill:"#af00ea",d:"M108.56 342.78a60.34 60.34 0 1 0 60.56 60.44a60.63 60.63 0 0 0-60.56-60.44"}),s.jsx("path",{fill:"#af00ea",d:"M48 186.67v86.55c52 0 101.94 15.39 138.67 52.11s52 86.56 52 138.67h86.66c0-151.56-125.66-277.33-277.33-277.33"}),s.jsx("path",{fill:"#af00ea",d:"M48 48v86.56c185.25 0 329.22 144.08 329.22 329.44H464C464 234.66 277.67 48 48 48"})]}),Ppe=({size:e=18,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 80 80",style:{width:e,height:e},className:t,children:[s.jsx("path",{d:"M0 0h80v80H0z",fill:"none"}),s.jsxs("g",{fill:"none",children:[s.jsx("path",{fill:"#f2994a",d:"M65.368 67.848a2 2 0 0 0 2.828-2.829zm-9.634-15.29a2 2 0 0 0-2.828 2.828zm12.462 12.461L55.734 52.557l-2.828 2.829l12.462 12.462z"}),s.jsx("path",{fill:"#56ccf2",stroke:"#2f80ed",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"4",d:"M13.578 30.724a24.249 24.249 0 1 1 46.844 12.552a24.249 24.249 0 0 1-46.844-12.552"})]})]}),D2=({size:e=18,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",style:{width:e,height:e},className:t,children:[s.jsx("path",{d:"M0 0h64v64H0z",fill:"none"}),s.jsx("path",{fill:"#454749",d:"M47.5 45.1c-6.6 12.1-6.5 13.1-9.6 11.3S33.6 53 40.3 41S48.9 29.1 52 30.9c3 1.7 2.1 2.2-4.5 14.2"}),s.jsx("path",{fill:"#258399",d:"M53.7 48.7c-4.2 7.7-9.4 11.4-11.9 10c-3.1-1.8-1.5-1.8 5.1-13.9s5.8-13.5 8.9-11.7c2.5 1.4 2.1 7.9-2.1 15.6"}),s.jsx("path",{fill:"#454749",d:"M16.5 45.1c6.6 12.1 6.5 13.1 9.6 11.3S30.4 53 23.7 41S15.1 29.1 12 30.9c-3 1.7-2.1 2.2 4.5 14.2"}),s.jsx("path",{fill:"#258399",d:"M10.3 48.7c4.2 7.7 9.4 11.4-11.9 10c3.1-1.8 1.5-1.8-5.1-13.9s-5.8-13.5-8.9-11.7c-2.5 1.4-2.1 7.9 2.1 15.6"}),s.jsx("path",{fill:"#3baacf",d:"M11.3 57.7s5.4 1.4 5.8 0c2.5-8.1-11.4-12.9-11.4-22.1C5.7 20.8 17.5 8.8 32 8.8s26.3 12 26.3 26.8c0 9.2-13.9 14-11.4 22.1c.4 1.4 5.8 0 5.8 0c5.7-5.6 9.3-13.4 9.3-22.1C62 18.7 48.6 5 32 5S2 18.7 2 35.6c0 8.7 3.6 16.5 9.3 22.1"}),s.jsx("path",{fill:"#454749",d:"M14.9 17.6c3.5-.7 8-5.7 17.1-5.7s13.7 5.1 17.1 5.7c1.4.3 3.8-1.9 3.8-1.9c-5.5-6.3-12-9.5-20.9-9.5s-15.4 3.2-20.9 9.5c0 .1 2.4 2.2 3.8 1.9"})]}),TC=({size:e=18,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{width:e,height:e},className:t,children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsxs("g",{fill:"none",children:[s.jsx("path",{fill:"#ff808c",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M16.304 14.391a1.435 1.435 0 1 0 0-2.87a1.435 1.435 0 0 0 0 2.87",strokeWidth:"0"}),s.jsx("path",{stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M2.915 16.304V8.498m18.171 0v7.806",strokeWidth:"0"}),s.jsx("path",{fill:"#c9f7ca",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.827V1.002H6.74l-.956 3.825zm10.999 0l-1.65-3.296a.96.96 0 0 0-.854-.53H17.26l.957 3.826z",strokeWidth:"0"}),s.jsx("path",{fill:"#fff9bf",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M6.74 1.002H3.505a.96.96 0 0 0-.855.529L1.001 4.827h4.782zm11.476 3.825l-.956-3.825H12v3.825z",strokeWidth:"0"}),s.jsx("path",{fill:"#78eb7b",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M18.216 4.827v2.87c1.398 1.575 3.977 1.048 4.643-.95c.104-.31.15-.637.14-.963v-.957z",strokeWidth:"0"}),s.jsx("path",{fill:"#ffef5e",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M1.002 4.827v.957C.93 7.89 3.167 9.284 5.026 8.292a2.7 2.7 0 0 0 .758-.596V4.827zm10.998 0v3.481c1.746 1.95 4.884 1.641 6.216-.612V4.827z",strokeWidth:"0"}),s.jsx("path",{fill:"#78eb7b",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M5.784 4.827v2.87c1.333 2.252 4.47 2.562 6.217.611v-3.48z",strokeWidth:"0"}),s.jsx("path",{fill:"#c77f67",d:"M22.042 16.304H1.958A.956.956 0 0 0 1 17.26v2.87c0 .527.429.956.957.956h20.084a.956.956 0 0 0 .956-.957V17.26a.956.956 0 0 0-.956-.956"}),s.jsx("path",{fill:"#e3bfb3",d:"M22.042 16.304H1.958A.956.956 0 0 0 1 17.26v1.913c0-.528.429-.957.957-.957h20.084c.528 0 .956.429.956.957V17.26a.956.956 0 0 0-.956-.956"}),s.jsx("path",{stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M22.042 16.304H1.958A.956.956 0 0 0 1 17.26v2.87c0 .527.429.956.957.956h20.084a.956.956 0 0 0 .956-.957V17.26a.956.956 0 0 0-.956-.956M2.915 21.086v1.912m18.171-1.912v1.912",strokeWidth:"0"}),s.jsx("path",{fill:"#ff808c",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M6.261 16.304a1.435 1.435 0 1 0 0-2.87a1.435 1.435 0 0 0 0 2.87",strokeWidth:"0"}),s.jsx("path",{fill:"#ff808c",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M9.131 16.304a1.435 1.435 0 1 0 0-2.87a1.435 1.435 0 0 0 0 2.87m5.738 0a1.435 1.435 0 1 0 0-2.87a1.435 1.435 0 0 0 0 2.87",strokeWidth:"0"}),s.jsx("path",{fill:"#ff808c",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M17.739 16.304a1.435 1.435 0 1 0 0-2.87a1.435 1.435 0 0 0 0 2.87",strokeWidth:"0"})]})]}),Ope=({size:e=18,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",style:{width:e,height:e},className:t,children:[s.jsx("path",{d:"M0 0h48v48H0z",fill:"none"}),s.jsxs("g",{fill:"none",children:[s.jsx("path",{fill:"url(#SVGqLAKpbTS)",d:"M18.067 27h12v16h-12z"}),s.jsx("path",{fill:"url(#SVGN23V5vIj)",d:"M26.461 7.855a3.78 3.78 0 0 0-4.787 0L8.499 18.597a3.91 3.91 0 0 0-1.432 3.031v17.485C7.067 41.26 8.78 43 10.892 43h8.175V30.5a2.5 2.5 0 0 1 2.5-2.5h5a2.5 2.5 0 0 1 2.5 2.5V43h8.175c2.113 0 3.825-1.74 3.825-3.887V21.628a3.91 3.91 0 0 0-1.43-3.031z"}),s.jsx("path",{fill:"url(#SVGTLMWwcZy)",fillRule:"evenodd",d:"m24.068 9.329l-16 13.215a2.054 2.054 0 0 1-2.852-.262a1.956 1.956 0 0 1 .267-2.794L22.28 5.628a2.83 2.83 0 0 1 3.523-.024l16.805 13.588a1.957 1.957 0 0 1 .307 2.79a2.054 2.054 0 0 1-2.848.3z",clipRule:"evenodd"}),s.jsxs("defs",{children:[s.jsxs("linearGradient",{id:"SVGqLAKpbTS",x1:"24.067",x2:"13.481",y1:"27",y2:"44.65",gradientUnits:"userSpaceOnUse",children:[s.jsx("stop",{stopColor:"#944600"}),s.jsx("stop",{offset:"1",stopColor:"#cd8e02"})]}),s.jsxs("linearGradient",{id:"SVGN23V5vIj",x1:"10.313",x2:"45.173",y1:"5.24",y2:"32",gradientUnits:"userSpaceOnUse",children:[s.jsx("stop",{stopColor:"#ffd394"}),s.jsx("stop",{offset:"1",stopColor:"#ffb357"})]}),s.jsxs("linearGradient",{id:"SVGTLMWwcZy",x1:"17.817",x2:"25.308",y1:".725",y2:"22.452",gradientUnits:"userSpaceOnUse",children:[s.jsx("stop",{stopColor:"#ff921f"}),s.jsx("stop",{offset:"1",stopColor:"#eb4824"})]})]})]})]}),u8=({size:e=18,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{width:e,height:e},className:Fe("shrink-0",t),children:[s.jsx("path",{fill:"none",d:"M0 0h24v24H0z"}),s.jsx("path",{fill:"currentColor",d:"M19 6h-3c0-2.21-1.79-4-4-4S8 3.79 8 6H5c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-7-2c1.1 0 2 .9 2 2h-4c0-1.1.9-2 2-2zm0 10c-2.76 0-5-2.24-5-5h2c0 1.66 1.34 3 3 3s3-1.34 3-3h2c0 2.76-2.24 5-5 5z"})]}),d8=({size:e=20,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 80 80",style:{width:e,height:e},className:Fe("shrink-0",t),children:[s.jsx("path",{d:"M0 0h80v80H0z",fill:"none"}),s.jsxs("g",{fill:"none",strokeLinejoin:"round",strokeWidth:"4",children:[s.jsx("path",{fill:"#f2c94c",stroke:"#f2c94c",strokeLinecap:"square",d:"M60 70H20a4 4 0 0 1-4-4a15.87 15.87 0 0 1 10.3-14.86l1.23-.462a35.53 35.53 0 0 1 24.94 0l1.23.462A15.87 15.87 0 0 1 64 66a4 4 0 0 1-4 4Z"}),s.jsx("path",{fill:"#f2994a",stroke:"#f2994a",strokeLinecap:"round",d:"M33.902 38.867a13.347 13.347 0 0 0 19.15-9.08l.223-1.044a14.2 14.2 0 0 0-2.51-11.466l-.36-.48a12.992 12.992 0 0 0-20.81 0l-.36.48a14.2 14.2 0 0 0-2.51 11.465l.223 1.046a13.35 13.35 0 0 0 6.953 9.08"})]})]}),Rpe=({size:e=22,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",style:{width:e,height:e},className:Fe("shrink-0 hover:scale-110 transition-transform",t),children:[s.jsx("path",{d:"M0 0h32v32H0z",fill:"none"}),s.jsxs("g",{fill:"none",children:[s.jsx("path",{fill:"#ac5810",d:"M19.343 4.83C11.708.802 4.757 3.672 2.253 7.595C1.432 8.877.852 11.21.874 13.06c.045 3.807 2.152 8.05 6.7 12.33c5.595 5.265 11.305 4.805 13.12 4.363c2.285-.558 3.817-1.033 3.582-3.163c-.03-.28-.27-.788-.632-1.01c-1.162-.705-3.59-1.072-4.732-2.77c-1.66-2.472.404-2.597 2.382-1.54c2.117 1.133 3.327 1.84 5.452 1.645c1.558-.142 3.823-1.082 4.13-3.71c.276-2.377-3.194-9.975-11.534-14.375m3.117 12.92c-.585.89-2.03.585-2.977-.255s-1.07-2.24-.456-2.79c.625-.557 1.8-.43 2.748.41c.945.842 1.143 1.935.685 2.635"}),s.jsx("path",{fill:"#f2a259",d:"M19.678 3.923C12.042-.105 5.074 3.01 2.57 6.933c-2.507 3.925-1.417 11.192 5.338 17.55c5.594 5.264 11.305 4.805 13.12 4.362c2.285-.557 3.897-1.645 2.892-3.032c-.693-.958-3.175-1.68-4.673-3.91c-1.66-2.473.406-2.598 2.383-1.54c2.117 1.132 3.328 1.84 5.453 1.645c1.557-.143 3.912-1.348 3.842-3.783c-.073-2.393-2.908-9.9-11.248-14.302m3.514 13.757c-.712.77-2.23.56-3.39-.465c-1.157-1.027-1.52-2.482-.807-3.25c.712-.77 2.23-.56 3.39.465s1.52 2.483.807 3.25"}),s.jsx("path",{fill:"#eee",d:"M11.905 21.165c.288-.735 2.333-1.54 4.213-.203c.527.375 1.187 1.33 1.12 2.53c-.22 3.92-6.653 1.055-5.333-2.327"}),s.jsx("path",{fill:"#2686c6",d:"M5.933 14.518c.657-1.05 2.255-1.17 3.652-.263c1.245.807 2.285 2.795.75 4.095c-.822.697-2.245.265-3.122-.408c-1.065-.812-1.988-2.294-1.28-3.424"}),s.jsx("path",{fill:"#ffee58",d:"M14.418 5.355c.202-.832 1.614-.975 2.614-.602c1.728.645 2.51 2.355 1.873 3.307c-.933 1.393-2.965.915-3.735.118c-1.307-1.35-.922-2.125-.752-2.823"}),s.jsx("path",{fill:"#7cb342",d:"M24.428 9.43c1.384.63 1.564 1.627 1.3 2.355c-.166.45-.503 1.067-1.193 1.123c-1.168.095-1.33-.87-2.163-1.135c-.7-.223-.985-1.18-.71-1.823c.256-.592 1-1.325 2.765-.52"}),s.jsx("path",{fill:"#b0b0b0",d:"M16.743 24.24c-.345.313-1.543.698-3.063-.252c-.515-.323-1.008-.79-1.285-1.49c-.217-.55-.17-1.08-.072-1.315c.28-.678.707-.803.707-.803c-.43-.03-1.242.54-1.377 1.288c-.043.235-.346 1.704 1.602 3.037c1.677 1.15 4.158 1.043 3.995-1.272a1.8 1.8 0 0 1-.508.807"}),s.jsx("path",{fill:"#01579b",d:"M11.065 16.43c-.047.893-1.093 1.363-1.675 1.365c-1.648.002-3.128-1.033-3.23-2.875c-.018-.33.145-.807.145-.807c-.218.092-.525.562-.59.827c-.385 1.59 1.217 3.443 2.905 3.818c.855.19 1.933-.103 2.325-.868c.28-.545.225-1.012.12-1.46"}),s.jsx("path",{fill:"#df7f14",d:"M16.83 8.18c-1.12-.128-1.74-.86-1.902-1.028c-.446-.465-.72-.917-.56-1.587c.05-.215.172-.49.322-.645c-.182.06-.477.452-.57.665c-.095.212-.44 1.01.3 1.992c.457.61 1.255 1.298 2.435 1.463c.837.117 1.438-.183 1.938-.67c.34-.333.49-1.083.287-1.47c.033.282-.485 1.482-2.25 1.28"}),s.jsx("path",{fill:"#558b2f",d:"M26.043 11.213a2.4 2.4 0 0 0-.425-.79c.127.245.38.98-.15 1.694c-.268.36-1.073.803-2.023.033c-.28-.228-.505-.453-1.01-.638c-1.282-.472-.723-1.777-.277-2.182c-.35.183-.668.51-.8 1.01c-.186.697.272 1.428.967 1.777c.79.398 1.045 1.165 2.128 1.165q.082 0 .175-.007c.73-.062 1.037-.345 1.26-.69c.272-.43.28-.918.154-1.373"}),s.jsx("path",{fill:"#f44336",d:"M6.455 6.448c.57-.563 1.562-1.158 3.015-.4c.875.455 1.893.99 1.432 2.84c-.284 1.147-1.955 1.755-3.35.477C7 8.86 4.9 7.982 6.455 6.447"}),s.jsx("path",{fill:"#c62828",d:"M11.235 8.64c.018-.437-.207-.97-.285-1.15c.013.262.24.925-.802 1.802a1.73 1.73 0 0 1-1.738.255c-.367-.145-.895-.752-1.272-.905c-1.403-.564-.798-2.067-.6-2.272a1.7 1.7 0 0 0-.688 1.095c-.13.678-.01 1.318.92 2.05c2.64 2.082 3.45.827 3.738.508c.362-.39.707-.9.727-1.383"}),s.jsx("path",{fill:"#fff",d:"M16.435 4.84c-.367-.172-1.417-.122-1.62.753c-.122.525.263 1.057.625.995c.412-.07.193-.713.44-.895c.377-.275 1.07-.61.555-.853M8.69 6.115c-.362-.24-1.52-.242-1.867.645c-.21.533.117 1.15.51 1.14c.447-.01.232-.537.604-.872c.47-.423 1.26-.578.753-.913m-.172 8.01c-.343-.217-1.358-.303-1.778.492c-.308.585.115 1.23.482 1.213c.418-.02.278-.685.545-.835c.408-.227 1.23-.565.75-.87m5.832 6.657c-.367-.172-1.418-.122-1.62.753c-.123.525.262 1.058.625.995c.412-.07.192-.713.44-.895c.375-.275 1.068-.61.555-.853m9.42-11.27c-.33-.234-1.372-.372-1.727.453c-.213.495.07 1.088.437 1.09c.418.002.315-.668.593-.803c.417-.202 1.16-.41.697-.74"})]})]}),zo='data:image/svg+xml;utf8,';async function M2(e,t,n,r){const i=e?/@(mega\s*(ai)?|me)\b/i.test(e):!1,a=e?/\?/.test(e):!1,o=e?/^(what|how|why|where|when|who|is|can|will|does|should|could|explain|tell|is there|how to)\b/i.test(e.trim()):!1;if(!e||!i&&!a&&!o)return null;const c=e.replace(/@(mega\s*(ai)?|me)\b/gi,"").trim(),h=c.toLowerCase();try{let f=null;try{(await vn(et(he,"mega_ai_knowledge"))).forEach(S=>{const C=S.data(),T=C.keywords||[],D=(C.question||"").toLowerCase(),V=D&&(h.includes(D)||D.length>5&&h.includes(D.slice(0,15))),L=T.length>0&&T.some(K=>K&&K.length>2&&h.includes(K.toLowerCase()));(V||L)&&(f=C.answer)})}catch(A){console.warn("Could not query mega_ai_knowledge collection:",A)}let m=f||"";if(!m)try{let A="";try{const T=Qt(et(he,"posts"),ui("createdAt","desc"),vi(12)),D=await vn(T);D.empty||(A=` [LIVE CAMPUS ARTICLES & SITEMAP KNOWLEDGE BASE]: Sitemap Root: https://campuseyemedia.netlify.app/sitemap.xml Categories: News, Sports, Politics, Entertainment, Tech, Campus Life, Opinion Latest Articles Knowledge: ${D.docs.map((L,K)=>{const Z=L.data();return`${K+1}. [Article Title]: "${Z.title||"Campus Update"}" | Category: ${Z.category||"General"} | Category URL: https://campuseyemedia.netlify.app/?category=${encodeURIComponent(Z.category||"General")} [Excerpt]: ${(Z.content||"").slice(0,180)}... [Link]: https://campuseyemedia.netlify.app/article/${L.id}`}).join(` `)}`)}catch(T){console.warn("Could not load live articles for Mega AI context:",T)}const C=await(await fetch("/api/mega-ai",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,context:`Question asked by ${t} in ${r.type}${A}`,articleTitle:r.articleTitle,articleContent:r.articleContent,postContent:r.postContent})})).json();C.reply&&(m=C.reply)}catch(A){console.error("Mega AI API fetch error:",A)}m||(m=`Hello @${t}! I am Mega AI, Campus Eye's smart neural assistant. I've processed your query: "${c||e}" and I am here to assist you! 🎓`);const y=c||e,w=`🧵 [Connected Thread | Question by @${t}]: "${y}" 🧠 [Mega AI Neural Response]: ${m}`;if(n&&n!=="guest")try{await ur(et(he,"notifications"),{userId:n,type:"mega_ai_reply",title:"✨ Mega AI Replied to your Question!",message:`Mega AI: "${m.slice(0,110)}${m.length>110?"...":""}"`,fullAnswer:w,userQuery:y,targetType:r.type,postId:r.postId||null,articleId:r.articleId||null,commentId:r.commentId||null,used:!1,playSound:!0,isAiGenerated:!0,createdAt:En()})}catch(A){console.error("Could not send student inbox notification for Mega AI reply:",A)}if(!f)try{const A=(y||"").toLowerCase().split(" ").filter(S=>S.length>3);await ur(et(he,"mega_ai_knowledge"),{question:y.trim(),answer:m.trim(),keywords:A,source:"ai_generated",askedBy:t||"Student",createdAt:En()})}catch(A){console.warn("Could not auto-save AI response into mega_ai_knowledge:",A)}try{await ur(et(he,"notifications"),{type:"mega_ai_query",forAdmin:!0,isAdminNotification:!0,title:`🤖 Mega AI Response to @${t}`,message:`@${t} asked: "${y.slice(0,60)}${y.length>60?"...":""}" ➔ AI replied: "${m.slice(0,90)}${m.length>90?"...":""}"`,userQuery:e,generatedReply:m,fullAnswer:w,userUid:n||"guest",userName:t||"Student Peer",targetType:r.type,postId:r.postId||null,commentId:r.commentId||null,articleId:r.articleId||null,used:!1,playSound:!0,createdAt:En()}),(await vn(et(he,"admins"))).forEach(async S=>{const C=S.id;if(C&&C!==n)try{await ur(et(he,"notifications"),{userId:C,type:"mega_ai_admin_log",forAdmin:!0,isAdminNotification:!0,title:`🤖 Mega AI Answered @${t}`,message:`AI Response sent: "${m.slice(0,100)}${m.length>100?"...":""}"`,userQuery:y,generatedReply:m,fullAnswer:w,targetType:r.type,postId:r.postId||null,articleId:r.articleId||null,commentId:r.commentId||null,used:!1,playSound:!0,isAiGenerated:!0,createdAt:En()})}catch{}})}catch(A){console.error("Could not add admin notification for Mega AI query:",A)}return w}catch(f){return console.error("Error in triggerMegaAiAutoReply:",f),null}}const zw=({className:e,size:t="sm"})=>s.jsxs("span",{className:Fe("inline-flex items-center gap-1 font-extrabold bg-gradient-to-r from-amber-500/10 via-purple-500/10 to-red-500/10 border border-amber-500/30 text-amber-700 uppercase tracking-wider rounded-full shadow-2xs shrink-0 select-none",t==="sm"?"text-[8.5px] px-2 py-0.5":"text-[9.5px] px-2.5 py-1",e),children:[s.jsx(Zi,{size:t==="sm"?10:12,className:"text-amber-500 shrink-0"}),s.jsx("span",{children:"AI Generated"})]}),L2=(e,t)=>{if(!e)return null;const n=e.match(/^(?:💬\s*)?(?:\[Replying to @([^\]]+)\]|Replying to @([^\s:]+)):\s*"([^"]+)"\s*(?:\n+|⚡\s*|\s+)([\s\S]*)/i);if(n){const a=n[1]||n[2],o=n[3],c=n[4];return s.jsxs("div",{className:"space-y-2 my-1 text-left w-full",children:[s.jsxs("div",{className:"bg-slate-950/90 text-cyan-100 p-2.5 rounded-xl border border-cyan-500/40 shadow-sm backdrop-blur-xs",children:[s.jsxs("div",{className:"flex items-center justify-between text-[8.5px] font-mono font-bold text-cyan-400 uppercase tracking-wider mb-1 pb-1 border-b border-cyan-500/20",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-cyan-400 animate-pulse"}),s.jsxs("span",{children:["QUESTION THREAD — ASKED BY @",a.toUpperCase()]})]}),s.jsx("span",{className:"text-[7.5px] text-cyan-400/80 font-mono",children:"CONNECTED"})]}),s.jsxs("p",{className:"text-[10.5px] font-sans text-cyan-100/90 italic border-l-2 border-cyan-400 pl-2 py-0.5 leading-relaxed break-words",children:['"',o,'"']})]}),s.jsx("div",{className:"leading-relaxed font-sans text-inherit",children:L2(c)})]})}const r=/(https?:\/\/[^\s]+|#[a-zA-Z0-9_\-]+|@Mega\s+AI|@Mega|@megaai|@Me|@[a-zA-Z0-9_\-]+)/gi,i=e.split(r);return s.jsx(s.Fragment,{children:i.map((a,o)=>a?a.startsWith("http://")||a.startsWith("https://")?s.jsx("a",{href:a,onClick:c=>{c.preventDefault(),c.stopPropagation(),window.open(a,"_blank","noopener,noreferrer")},className:"text-blue-600 font-bold hover:underline select-text inline-flex items-center gap-0.5 break-all cursor-pointer",children:a},o):/^@(Mega\s+AI|Mega|megaai|Me)$/i.test(a)?s.jsxs("span",{className:"inline-flex items-center gap-1 text-cyan-300 font-extrabold bg-gradient-to-r from-slate-950 via-cyan-950 to-purple-950 border border-cyan-400/50 px-2 py-0.5 rounded-lg shadow-cyan-500/20 mx-0.5 text-[0.95em] select-none",children:[s.jsx(Zi,{size:11,className:"text-cyan-400 shrink-0"}),s.jsx("span",{children:a})]},o):a.startsWith("@")?s.jsx("span",{className:"text-blue-600 font-bold bg-blue-50/80 border border-blue-100 px-1 py-0.2 rounded hover:underline cursor-pointer inline-flex items-center transition-colors mx-0.5",children:a},o):a.startsWith("#")?s.jsx("span",{className:"text-red-650 font-bold bg-red-50/70 hover:bg-red-100/80 border border-red-150/60 px-1.5 py-0.5 rounded-md hover:underline cursor-pointer inline-flex items-center transition-colors mx-0.5",children:a},o):s.jsx(ie.Fragment,{children:a},o):null)})},BT=I.createContext({});function zT(e){const t=I.useRef(null);return t.current===null&&(t.current=e()),t.current}const Dpe=typeof window<"u",hq=Dpe?I.useLayoutEffect:I.useEffect,DE=I.createContext(null);function VT(e,t){e.indexOf(t)===-1&&e.push(t)}function U2(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const Fu=(e,t,n)=>n>t?t:n{};const xf={},fq=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function pq(e){return typeof e=="object"&&e!==null}const mq=e=>/^0[^.\s]+$/u.test(e);function gq(e){let t;return()=>(t===void 0&&(t=e()),t)}const gc=e=>e,Mpe=(e,t)=>n=>t(e(n)),Jy=(...e)=>e.reduce(Mpe),py=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r};class $T{constructor(){this.subscriptions=[]}add(t){return VT(this.subscriptions,t),()=>U2(this.subscriptions,t)}notify(t,n,r){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,r);else for(let a=0;ae*1e3,hc=e=>e/1e3;function xq(e,t){return t?e*(1e3/t):0}const yq=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Lpe=1e-7,Upe=12;function Bpe(e,t,n,r,i){let a,o,c=0;do o=t+(n-t)/2,a=yq(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>Lpe&&++cBpe(a,0,1,e,n);return a=>a===0||a===1?a:yq(i(a),t,r)}const bq=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,vq=e=>t=>1-e(1-t),wq=eb(.33,1.53,.69,.99),HT=vq(wq),Nq=bq(HT),Eq=e=>e>=1?1:(e*=2)<1?.5*HT(e):.5*(2-Math.pow(2,-10*(e-1))),GT=e=>1-Math.sin(Math.acos(e)),Aq=vq(GT),_q=bq(GT),zpe=eb(.42,0,1,1),Vpe=eb(0,0,.58,1),kq=eb(.42,0,.58,1),Fpe=e=>Array.isArray(e)&&typeof e[0]!="number",Sq=e=>Array.isArray(e)&&typeof e[0]=="number",$pe={linear:gc,easeIn:zpe,easeInOut:kq,easeOut:Vpe,circIn:GT,circInOut:_q,circOut:Aq,backIn:HT,backInOut:Nq,backOut:wq,anticipate:Eq},Hpe=e=>typeof e=="string",h8=e=>{if(Sq(e)){FT(e.length===4);const[t,n,r,i]=e;return eb(t,n,r,i)}else if(Hpe(e))return $pe[e];return e},$v=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Gpe(e,t){let n=new Set,r=new Set,i=!1,a=!1;const o=new WeakSet;let c={delta:0,timestamp:0,isProcessing:!1};function h(m){o.has(m)&&(f.schedule(m),e()),m(c)}const f={schedule:(m,y=!1,w=!1)=>{const S=w&&i?n:r;return y&&o.add(m),S.add(m),m},cancel:m=>{r.delete(m),o.delete(m)},process:m=>{if(c=m,i){a=!0;return}i=!0;const y=n;n=r,r=y,n.forEach(h),n.clear(),i=!1,a&&(a=!1,f.process(m))}};return f}const qpe=40;function Cq(e,t){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=$v.reduce((L,K)=>(L[K]=Gpe(a),L),{}),{setup:c,read:h,resolveKeyframes:f,preUpdate:m,update:y,preRender:w,render:A,postRender:S}=o,C=()=>{const L=xf.useManualTiming,K=L?i.timestamp:performance.now();n=!1,L||(i.delta=r?1e3/60:Math.max(Math.min(K-i.timestamp,qpe),1)),i.timestamp=K,i.isProcessing=!0,c.process(i),h.process(i),f.process(i),m.process(i),y.process(i),w.process(i),A.process(i),S.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(C))},T=()=>{n=!0,r=!0,i.isProcessing||e(C)};return{schedule:$v.reduce((L,K)=>{const Z=o[K];return L[K]=(q,B=!1,z=!1)=>(n||T(),Z.schedule(q,B,z)),L},{}),cancel:L=>{for(let K=0;K<$v.length;K++)o[$v[K]].cancel(L)},state:i,steps:o}}const{schedule:ts,cancel:yf,state:no,steps:x_}=Cq(typeof requestAnimationFrame<"u"?requestAnimationFrame:gc,!0);let Vw;function Wpe(){Vw=void 0}const $o={now:()=>(Vw===void 0&&$o.set(no.isProcessing||xf.useManualTiming?no.timestamp:performance.now()),Vw),set:e=>{Vw=e,queueMicrotask(Wpe)}},jq=e=>t=>typeof t=="string"&&t.startsWith(e),Iq=jq("--"),Kpe=jq("var(--"),qT=e=>Kpe(e)?Ype.test(e.split("/*")[0].trim()):!1,Ype=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function f8(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const Hg={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},my={...Hg,transform:e=>Fu(0,1,e)},Hv={...Hg,default:1},V1=e=>Math.round(e*1e5)/1e5,WT=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Xpe(e){return e==null}const Qpe=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,KT=(e,t)=>n=>!!(typeof n=="string"&&Qpe.test(n)&&n.startsWith(e)||t&&!Xpe(n)&&Object.prototype.hasOwnProperty.call(n,t)),Tq=(e,t,n)=>r=>{if(typeof r!="string")return r;const[i,a,o,c]=r.match(WT);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:c!==void 0?parseFloat(c):1}},Zpe=e=>Fu(0,255,e),y_={...Hg,transform:e=>Math.round(Zpe(e))},_p={test:KT("rgb","red"),parse:Tq("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+y_.transform(e)+", "+y_.transform(t)+", "+y_.transform(n)+", "+V1(my.transform(r))+")"};function Jpe(e){let t="",n="",r="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const PC={test:KT("#"),parse:Jpe,transform:_p.transform},tb=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),zh=tb("deg"),Mu=tb("%"),zn=tb("px"),eme=tb("vh"),tme=tb("vw"),p8={...Mu,parse:e=>Mu.parse(e)/100,transform:e=>Mu.transform(e*100)},L0={test:KT("hsl","hue"),parse:Tq("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+Mu.transform(V1(t))+", "+Mu.transform(V1(n))+", "+V1(my.transform(r))+")"},ua={test:e=>_p.test(e)||PC.test(e)||L0.test(e),parse:e=>_p.test(e)?_p.parse(e):L0.test(e)?L0.parse(e):PC.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?_p.transform(e):L0.transform(e),getAnimatableNone:e=>{const t=ua.parse(e);return t.alpha=0,ua.transform(t)}},nme=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function rme(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(WT))==null?void 0:t.length)||0)+(((n=e.match(nme))==null?void 0:n.length)||0)>0}const Pq="number",Oq="color",ime="var",sme="var(",m8="${}",ame=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function _g(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[];let a=0;const c=t.replace(ame,h=>(ua.test(h)?(r.color.push(a),i.push(Oq),n.push(ua.parse(h))):h.startsWith(sme)?(r.var.push(a),i.push(ime),n.push(h)):(r.number.push(a),i.push(Pq),n.push(parseFloat(h))),++a,m8)).split(m8);return{values:n,split:c,indexes:r,types:i}}function ome(e){return _g(e).values}function Rq({split:e,types:t}){const n=e.length;return r=>{let i="";for(let a=0;atypeof e=="number"?0:ua.test(e)?ua.getAnimatableNone(e):e,ume=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:cme(e);function dme(e){const t=_g(e);return Rq(t)(t.values.map((r,i)=>ume(r,t.split[i])))}const qc={test:rme,parse:ome,createTransformer:lme,getAnimatableNone:dme};function b_(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function hme({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{const c=n<.5?n*(1+t):n+t-n*t,h=2*n-c;i=b_(h,c,e+1/3),a=b_(h,c,e),o=b_(h,c,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function B2(e,t){return n=>n>0?t:e}const xs=(e,t,n)=>e+(t-e)*n,v_=(e,t,n)=>{const r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},fme=[PC,_p,L0],pme=e=>fme.find(t=>t.test(e));function g8(e){const t=pme(e);if(!t)return!1;let n=t.parse(e);return t===L0&&(n=hme(n)),n}const x8=(e,t)=>{const n=g8(e),r=g8(t);if(!n||!r)return B2(e,t);const i={...n};return a=>(i.red=v_(n.red,r.red,a),i.green=v_(n.green,r.green,a),i.blue=v_(n.blue,r.blue,a),i.alpha=xs(n.alpha,r.alpha,a),_p.transform(i))},OC=new Set(["none","hidden"]);function mme(e,t){return OC.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function gme(e,t){return n=>xs(e,t,n)}function YT(e){return typeof e=="number"?gme:typeof e=="string"?qT(e)?B2:ua.test(e)?x8:bme:Array.isArray(e)?Dq:typeof e=="object"?ua.test(e)?x8:xme:B2}function Dq(e,t){const n=[...e],r=n.length,i=e.map((a,o)=>YT(a)(a,t[o]));return a=>{for(let o=0;o{for(const a in r)n[a]=r[a](i);return n}}function yme(e,t){const n=[],r={color:0,var:0,number:0};for(let i=0;i{const n=qc.createTransformer(t),r=_g(e),i=_g(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?OC.has(e)&&!i.values.length||OC.has(t)&&!r.values.length?mme(e,t):Jy(Dq(yme(r,i),i.values),n):B2(e,t)};function Mq(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?xs(e,t,n):YT(e)(e,t)}const vme=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ts.update(t,n),stop:()=>yf(t),now:()=>no.isProcessing?no.timestamp:$o.now()}},Lq=(e,t,n=10)=>{let r="";const i=Math.max(Math.round(t/n),2);for(let a=0;a=z2?1/0:t}function wme(e,t=100,n){const r=n({...e,keyframes:[0,t]}),i=Math.min(XT(r),z2);return{type:"keyframes",ease:a=>r.next(i*a).value/t,duration:hc(i)}}const qs={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function RC(e,t){return e*Math.sqrt(1-t*t)}const Nme=12;function Eme(e,t,n){let r=n;for(let i=1;i{const m=f*o,y=m*e,w=m-n,A=RC(f,o),S=Math.exp(-y);return w_-w/A*S},a=f=>{const y=f*o*e,w=y*n+n,A=Math.pow(o,2)*Math.pow(f,2)*e,S=Math.exp(-y),C=RC(Math.pow(f,2),o);return(-i(f)+w_>0?-1:1)*((w-A)*S)/C}):(i=f=>{const m=Math.exp(-f*e),y=(f-n)*e+1;return-w_+m*y},a=f=>{const m=Math.exp(-f*e),y=(n-f)*(e*e);return m*y});const c=5/e,h=Eme(i,a,c);if(e=Bl(e),isNaN(h))return{stiffness:qs.stiffness,damping:qs.damping,duration:e};{const f=Math.pow(h,2)*r;return{stiffness:f,damping:o*2*Math.sqrt(r*f),duration:e}}}const _me=["duration","bounce"],kme=["stiffness","damping","mass"];function y8(e,t){return t.some(n=>e[n]!==void 0)}function Sme(e){let t={velocity:qs.velocity,stiffness:qs.stiffness,damping:qs.damping,mass:qs.mass,isResolvedFromDuration:!1,...e};if(!y8(e,kme)&&y8(e,_me))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Fu(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:qs.mass,stiffness:i,damping:a}}else{const n=Ame({...e,velocity:0});t={...t,...n,mass:qs.mass},t.isResolvedFromDuration=!0}return t}function V2(e=qs.visualDuration,t=qs.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:i}=n;const a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],c={done:!1,value:a},{stiffness:h,damping:f,mass:m,duration:y,velocity:w,isResolvedFromDuration:A}=Sme({...n,velocity:-hc(n.velocity||0)}),S=w||0,C=f/(2*Math.sqrt(h*m)),T=o-a,D=hc(Math.sqrt(h/m)),V=Math.abs(T)<5;r||(r=V?qs.restSpeed.granular:qs.restSpeed.default),i||(i=V?qs.restDelta.granular:qs.restDelta.default);let L,K,Z,q,B,z;if(C<1)Z=RC(D,C),q=(S+C*D*T)/Z,L=$=>{const Y=Math.exp(-C*D*$);return o-Y*(q*Math.sin(Z*$)+T*Math.cos(Z*$))},B=C*D*q+T*Z,z=C*D*T-q*Z,K=$=>Math.exp(-C*D*$)*(B*Math.sin(Z*$)+z*Math.cos(Z*$));else if(C===1){L=Y=>o-Math.exp(-D*Y)*(T+(S+D*T)*Y);const $=S+D*T;K=Y=>Math.exp(-D*Y)*(D*$*Y-S)}else{const $=D*Math.sqrt(C*C-1);L=ye=>{const ne=Math.exp(-C*D*ye),de=Math.min($*ye,300);return o-ne*((S+C*D*T)*Math.sinh(de)+$*T*Math.cosh(de))/$};const Y=(S+C*D*T)/$,X=C*D*Y-T*$,J=C*D*T-Y*$;K=ye=>{const ne=Math.exp(-C*D*ye),de=Math.min($*ye,300);return ne*(X*Math.sinh(de)+J*Math.cosh(de))}}const F={calculatedDuration:A&&y||null,velocity:$=>Bl(K($)),next:$=>{if(!A&&C<1){const X=Math.exp(-C*D*$),J=Math.sin(Z*$),ye=Math.cos(Z*$),ne=o-X*(q*J+T*ye),de=Bl(X*(B*J+z*ye));return c.done=Math.abs(de)<=r&&Math.abs(o-ne)<=i,c.value=c.done?o:ne,c}const Y=L($);if(A)c.done=$>=y;else{const X=Bl(K($));c.done=Math.abs(X)<=r&&Math.abs(o-Y)<=i}return c.value=c.done?o:Y,c},toString:()=>{const $=Math.min(XT(F),z2),Y=Lq(X=>F.next($*X).value,$,30);return $+"ms "+Y},toTransition:()=>{}};return F}V2.applyToOptions=e=>{const t=wme(e,100,V2);return e.ease=t.ease,e.duration=Bl(t.duration),e.type="keyframes",e};const Cme=5;function Uq(e,t,n){const r=Math.max(t-Cme,0);return xq(n-e(r),t-r)}function DC({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:c,max:h,restDelta:f=.5,restSpeed:m}){const y=e[0],w={done:!1,value:y},A=z=>c!==void 0&&zh,S=z=>c===void 0?h:h===void 0||Math.abs(c-z)-C*Math.exp(-z/r),L=z=>D+V(z),K=z=>{const F=V(z),$=L(z);w.done=Math.abs(F)<=f,w.value=w.done?D:$};let Z,q;const B=z=>{A(w.value)&&(Z=z,q=V2({keyframes:[w.value,S(w.value)],velocity:Uq(L,z,w.value),damping:i,stiffness:a,restDelta:f,restSpeed:m}))};return B(0),{calculatedDuration:null,next:z=>{let F=!1;return!q&&Z===void 0&&(F=!0,K(z),B(z)),Z!==void 0&&z>=Z?q.next(z-Z):(!F&&K(z),w)}}}function jme(e,t,n){const r=[],i=n||xf.mix||Mq,a=e.length-1;for(let o=0;ot[0];if(a===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());const c=jme(t,r,i),h=c.length,f=m=>{if(o&&m1)for(;yf(Fu(e[0],e[a-1],m)):f}function Tme(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const i=py(0,t,r);e.push(xs(n,1,i))}}function Pme(e){const t=[0];return Tme(t,e.length-1),t}function Ome(e,t){return e.map(n=>n*t)}function Rme(e,t){return e.map(()=>t||kq).splice(0,e.length-1)}function F1({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const i=Fpe(r)?r.map(h8):h8(r),a={done:!1,value:t[0]},o=Ome(n&&n.length===t.length?n:Pme(t),e),c=Ime(o,t,{ease:Array.isArray(i)?i:Rme(t,i)});return{calculatedDuration:e,next:h=>(a.value=c(h),a.done=h>=e,a)}}const Dme=e=>e!==null;function ME(e,{repeat:t,repeatType:n="loop"},r,i=1){const a=e.filter(Dme),c=i<0||t&&n!=="loop"&&t%2===1?0:a.length-1;return!c||r===void 0?a[c]:r}const Mme={decay:DC,inertia:DC,tween:F1,keyframes:F1,spring:V2};function Bq(e){typeof e.type=="string"&&(e.type=Mme[e.type])}class QT{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Lme=e=>e/100;class F2 extends QT{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var r,i;const{motionValue:n}=this.options;n&&n.updatedAt!==$o.now()&&this.tick($o.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(i=(r=this.options).onStop)==null||i.call(r))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;Bq(t);const{type:n=F1,repeat:r=0,repeatDelay:i=0,repeatType:a,velocity:o=0}=t;let{keyframes:c}=t;const h=n||F1;h!==F1&&typeof c[0]!="number"&&(this.mixKeyframes=Jy(Lme,Mq(c[0],c[1])),c=[0,100]);const f=h({...t,keyframes:c});a==="mirror"&&(this.mirroredGenerator=h({...t,keyframes:[...c].reverse(),velocity:-o})),f.calculatedDuration===null&&(f.calculatedDuration=XT(f));const{calculatedDuration:m}=f;this.calculatedDuration=m,this.resolvedDuration=m+i,this.totalDuration=this.resolvedDuration*(r+1)-i,this.generator=f}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:r,totalDuration:i,mixKeyframes:a,mirroredGenerator:o,resolvedDuration:c,calculatedDuration:h}=this;if(this.startTime===null)return r.next(0);const{delay:f=0,keyframes:m,repeat:y,repeatType:w,repeatDelay:A,type:S,onUpdate:C,finalKeyframe:T}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const D=this.currentTime-f*(this.playbackSpeed>=0?1:-1),V=this.playbackSpeed>=0?D<0:D>i;this.currentTime=Math.max(D,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let L=this.currentTime,K=r;if(y){const z=Math.min(this.currentTime,i)/c;let F=Math.floor(z),$=z%1;!$&&z>=1&&($=1),$===1&&F--,F=Math.min(F,y+1),!!(F%2)&&(w==="reverse"?($=1-$,A&&($-=A/c)):w==="mirror"&&(K=o)),L=Fu(0,1,$)*c}let Z;V?(this.delayState.value=m[0],Z=this.delayState):Z=K.next(L),a&&!V&&(Z.value=a(Z.value));let{done:q}=Z;!V&&h!==null&&(q=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const B=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&q);return B&&S!==DC&&(Z.value=ME(m,this.options,T,this.speed)),C&&C(Z.value),B&&this.finish(),Z}then(t,n){return this.finished.then(t,n)}get duration(){return hc(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+hc(t)}get time(){return hc(this.currentTime)}set time(t){t=Bl(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const n=this.generator.next(t).value;return Uq(r=>this.generator.next(r).value,t,n)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;n&&this.driver&&this.updateTime($o.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=hc(this.currentTime))}play(){var i,a;if(this.isStopped)return;const{driver:t=vme,startTime:n}=this.options;this.driver||(this.driver=t(o=>this.tick(o))),(a=(i=this.options).onPlay)==null||a.call(i);const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime($o.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(t=this.options).onComplete)==null||n.call(t)}cancel(){var t,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(t=this.options).onCancel)==null||n.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),t.observe(this)}}function Ume(e){for(let t=1;te*180/Math.PI,MC=e=>{const t=kp(Math.atan2(e[1],e[0]));return LC(t)},Bme={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:MC,rotateZ:MC,skewX:e=>kp(Math.atan(e[1])),skewY:e=>kp(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},LC=e=>(e=e%360,e<0&&(e+=360),e),b8=MC,v8=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),w8=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),zme={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:v8,scaleY:w8,scale:e=>(v8(e)+w8(e))/2,rotateX:e=>LC(kp(Math.atan2(e[6],e[5]))),rotateY:e=>LC(kp(Math.atan2(-e[2],e[0]))),rotateZ:b8,rotate:b8,skewX:e=>kp(Math.atan(e[4])),skewY:e=>kp(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function UC(e){return e.includes("scale")?1:0}function BC(e,t){if(!e||e==="none")return UC(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=zme,i=n;else{const c=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Bme,i=c}if(!i)return UC(t);const a=r[t],o=i[1].split(",").map(Fme);return typeof a=="function"?a(o):o[a]}const Vme=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return BC(n,t)};function Fme(e){return parseFloat(e.trim())}const Gg=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],qg=new Set(Gg),N8=e=>e===Hg||e===zn,$me=new Set(["x","y","z"]),Hme=Gg.filter(e=>!$me.has(e));function Gme(e){const t=[];return Hme.forEach(n=>{const r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}const ef={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:r})=>{const i=e.max-e.min;return r==="border-box"?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:r})=>{const i=e.max-e.min;return r==="border-box"?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>BC(t,"x"),y:(e,{transform:t})=>BC(t,"y")};ef.translateX=ef.x;ef.translateY=ef.y;const zp=new Set;let zC=!1,VC=!1,FC=!1;function zq(){if(VC){const e=Array.from(zp).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{const i=Gme(r);i.length&&(n.set(r,i),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const i=n.get(r);i&&i.forEach(([a,o])=>{var c;(c=r.getValue(a))==null||c.set(o)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}VC=!1,zC=!1,zp.forEach(e=>e.complete(FC)),zp.clear()}function Vq(){zp.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(VC=!0)})}function qme(){FC=!0,Vq(),zq(),FC=!1}class ZT{constructor(t,n,r,i,a,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=i,this.element=a,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(zp.add(this),zC||(zC=!0,ts.read(Vq),ts.resolveKeyframes(zq))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:r,motionValue:i}=this;if(t[0]===null){const a=i==null?void 0:i.get(),o=t[t.length-1];if(a!==void 0)t[0]=a;else if(r&&n){const c=r.readValue(n,o);c!=null&&(t[0]=c)}t[0]===void 0&&(t[0]=o),i&&a===void 0&&i.set(t[0])}Ume(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),zp.delete(this)}cancel(){this.state==="scheduled"&&(zp.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Wme=e=>e.startsWith("--");function Fq(e,t,n){Wme(t)?e.style.setProperty(t,n):e.style[t]=n}const Kme={};function $q(e,t){const n=gq(e);return()=>Kme[t]??n()}const Yme=$q(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),Hq=$q(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),E1=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,E8={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:E1([0,.65,.55,1]),circOut:E1([.55,0,1,.45]),backIn:E1([.31,.01,.66,-.59]),backOut:E1([.33,1.53,.69,.99])};function Gq(e,t){if(e)return typeof e=="function"?Hq()?Lq(e,t):"ease-out":Sq(e)?E1(e):Array.isArray(e)?e.map(n=>Gq(n,t)||E8.easeOut):E8[e]}function Xme(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o="loop",ease:c="easeOut",times:h}={},f=void 0){const m={[t]:n};h&&(m.offset=h);const y=Gq(c,i);Array.isArray(y)&&(m.easing=y);const w={delay:r,duration:i,easing:Array.isArray(y)?"linear":y,fill:"both",iterations:a+1,direction:o==="reverse"?"alternate":"normal"};return f&&(w.pseudoElement=f),e.animate(m,w)}function qq(e){return typeof e=="function"&&"applyToOptions"in e}function Qme({type:e,...t}){return qq(e)&&Hq()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class Wq extends QT{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:r,keyframes:i,pseudoElement:a,allowFlatten:o=!1,finalKeyframe:c,onComplete:h}=t;this.isPseudoElement=!!a,this.allowFlatten=o,this.options=t,FT(typeof t.type!="string");const f=Qme(t);this.animation=Xme(n,r,i,f,a),f.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!a){const m=ME(i,this.options,c,this.speed);this.updateMotionValue&&this.updateMotionValue(m),Fq(n,r,m),this.animation.cancel()}h==null||h(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,n;(n=(t=this.animation).finish)==null||n.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var n,r,i;const t=(n=this.options)==null?void 0:n.element;!this.isPseudoElement&&(t!=null&&t.isConnected)&&((i=(r=this.animation).commitStyles)==null||i.call(r))}get duration(){var n,r;const t=((r=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:r.call(n).duration)||0;return hc(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+hc(t)}get time(){return hc(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Bl(t),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:n,rangeEnd:r,observe:i}){var a;return this.allowFlatten&&((a=this.animation.effect)==null||a.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&Yme()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),r&&(this.animation.rangeEnd=r),gc):i(this)}}const Kq={anticipate:Eq,backInOut:Nq,circInOut:_q};function Zme(e){return e in Kq}function Jme(e){typeof e.ease=="string"&&Zme(e.ease)&&(e.ease=Kq[e.ease])}const N_=10;class e0e extends Wq{constructor(t){Jme(t),Bq(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:r,onComplete:i,element:a,...o}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const c=new F2({...o,autoplay:!1}),h=Math.max(N_,$o.now()-this.startTime),f=Fu(0,N_,h-N_),m=c.sample(h).value,{name:y}=this.options;a&&y&&Fq(a,y,m),n.setWithVelocity(c.sample(Math.max(0,h-f)).value,m,f),c.stop()}}const A8=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(qc.test(e)||e==="0")&&!e.startsWith("url("));function t0e(e){const t=e[0];if(e.length===1)return!0;for(let n=0;nObject.hasOwnProperty.call(Element.prototype,"animate"));function o0e(e){var y;const{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:c}=e;if(!(((y=t==null?void 0:t.owner)==null?void 0:y.current)instanceof HTMLElement))return!1;const{onUpdate:f,transformTemplate:m}=t.owner.getProps();return a0e()&&n&&(Yq.has(n)||s0e.has(n)&&i0e(c))&&(n!=="transform"||!m)&&!f&&!r&&i!=="mirror"&&a!==0&&o!=="inertia"}const l0e=40;class c0e extends QT{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:a=0,repeatType:o="loop",keyframes:c,name:h,motionValue:f,element:m,...y}){var S;super(),this.stop=()=>{var C,T;this._animation&&(this._animation.stop(),(C=this.stopTimeline)==null||C.call(this)),(T=this.keyframeResolver)==null||T.cancel()},this.createdAt=$o.now();const w={autoplay:t,delay:n,type:r,repeat:i,repeatDelay:a,repeatType:o,name:h,motionValue:f,element:m,...y},A=(m==null?void 0:m.KeyframeResolver)||ZT;this.keyframeResolver=new A(c,(C,T,D)=>this.onKeyframesResolved(C,T,w,!D),h,f,m),(S=this.keyframeResolver)==null||S.scheduleResolve()}onKeyframesResolved(t,n,r,i){var D,V;this.keyframeResolver=void 0;const{name:a,type:o,velocity:c,delay:h,isHandoff:f,onUpdate:m}=r;this.resolvedAt=$o.now();let y=!0;n0e(t,a,o,c)||(y=!1,(xf.instantAnimations||!h)&&(m==null||m(ME(t,r,n))),t[0]=t[t.length-1],$C(r),r.repeat=0);const A={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>l0e?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:t},S=y&&!f&&o0e(A),C=(V=(D=A.motionValue)==null?void 0:D.owner)==null?void 0:V.current;let T;if(S)try{T=new e0e({...A,element:C})}catch{T=new F2(A)}else T=new F2(A);T.finished.then(()=>{this.notifyFinished()}).catch(gc),this.pendingTimeline&&(this.stopTimeline=T.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=T}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),qme()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}function Xq(e,t,n,r=0,i=1){const a=Array.from(e).sort((f,m)=>f.sortNodePosition(m)).indexOf(t),o=e.size,c=(o-1)*r;return typeof n=="function"?n(a,o):i===1?a*r:c-a*r}const u0e=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function d0e(e){const t=u0e.exec(e);if(!t)return[,];const[,n,r,i]=t;return[`--${n??r}`,i]}function Qq(e,t,n=1){const[r,i]=d0e(e);if(!r)return;const a=window.getComputedStyle(t).getPropertyValue(r);if(a){const o=a.trim();return fq(o)?parseFloat(o):o}return qT(i)?Qq(i,t,n+1):i}const h0e={type:"spring",stiffness:500,damping:25,restSpeed:10},f0e=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),p0e={type:"keyframes",duration:.8},m0e={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},g0e=(e,{keyframes:t})=>t.length>2?p0e:qg.has(e)?e.startsWith("scale")?f0e(t[1]):h0e:m0e;function Zq(e,t){if(e!=null&&e.inherit&&t){const{inherit:n,...r}=e;return{...t,...r}}return e}function JT(e,t){const n=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return n!==e?Zq(n,e):n}const x0e=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function y0e(e){for(const t in e)if(!x0e.has(t))return!0;return!1}const e4=(e,t,n,r={},i,a)=>o=>{const c=JT(r,e)||{},h=c.delay||r.delay||0;let{elapsed:f=0}=r;f=f-Bl(h);const m={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...c,delay:-f,onUpdate:w=>{t.set(w),c.onUpdate&&c.onUpdate(w)},onComplete:()=>{o(),c.onComplete&&c.onComplete()},name:e,motionValue:t,element:a?void 0:i};y0e(c)||Object.assign(m,g0e(e,m)),m.duration&&(m.duration=Bl(m.duration)),m.repeatDelay&&(m.repeatDelay=Bl(m.repeatDelay)),m.from!==void 0&&(m.keyframes[0]=m.from);let y=!1;if((m.type===!1||m.duration===0&&!m.repeatDelay)&&($C(m),m.delay===0&&(y=!0)),(xf.instantAnimations||xf.skipAnimations||i!=null&&i.shouldSkipAnimations)&&(y=!0,$C(m),m.delay=0),m.allowFlatten=!c.type&&!c.ease,y&&!a&&t.get()!==void 0){const w=ME(m.keyframes,c);if(w!==void 0){ts.update(()=>{m.onUpdate(w),m.onComplete()});return}}return c.isSync?new F2(m):new c0e(m)};function _8(e){const t=[{},{}];return e==null||e.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function t4(e,t,n,r){if(typeof t=="function"){const[i,a]=_8(r);t=t(n!==void 0?n:e.custom,i,a)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,a]=_8(r);t=t(n!==void 0?n:e.custom,i,a)}return t}function Vp(e,t,n){const r=e.getProps();return t4(r,t,n!==void 0?n:r.custom,e)}const Jq=new Set(["width","height","top","left","right","bottom",...Gg]),k8=30,b0e=e=>!isNaN(parseFloat(e));class v0e{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{var a;const i=$o.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&((a=this.events.change)==null||a.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=$o.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=b0e(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new $T);const r=this.events[t].add(n);return t==="change"?()=>{r(),ts.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=$o.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>k8)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,k8);return xq(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var t,n;(t=this.dependents)==null||t.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function kg(e,t){return new v0e(e,t)}const HC=e=>Array.isArray(e);function w0e(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,kg(n))}function N0e(e){return HC(e)?e[e.length-1]||0:e}function E0e(e,t){const n=Vp(e,t);let{transitionEnd:r={},transition:i={},...a}=n||{};a={...a,...r};for(const o in a){const c=N0e(a[o]);w0e(e,o,c)}}const ao=e=>!!(e&&e.getVelocity);function A0e(e){return!!(ao(e)&&e.add)}function GC(e,t){const n=e.getValue("willChange");if(A0e(n))return n.add(t);if(!n&&xf.WillChange){const r=new xf.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function n4(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const _0e="framerAppearId",eW="data-"+n4(_0e);function tW(e){return e.props[eW]}function k0e({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function nW(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...c}=t;const h=e.getDefaultTransition();a=a?Zq(a,h):h;const f=a==null?void 0:a.reduceMotion;r&&(a=r);const m=[],y=i&&e.animationState&&e.animationState.getState()[i];for(const w in c){const A=e.getValue(w,e.latestValues[w]??null),S=c[w];if(S===void 0||y&&k0e(y,w))continue;const C={delay:n,...JT(a||{},w)},T=A.get();if(T!==void 0&&!A.isAnimating()&&!Array.isArray(S)&&S===T&&!C.velocity){ts.update(()=>A.set(S));continue}let D=!1;if(window.MotionHandoffAnimation){const K=tW(e);if(K){const Z=window.MotionHandoffAnimation(K,w,ts);Z!==null&&(C.startTime=Z,D=!0)}}GC(e,w);const V=f??e.shouldReduceMotion;A.start(e4(w,A,S,V&&Jq.has(w)?{type:!1}:C,e,D));const L=A.animation;L&&m.push(L)}if(o){const w=()=>ts.update(()=>{o&&E0e(e,o)});m.length?Promise.all(m).then(w):w()}return m}function qC(e,t,n={}){var h;const r=Vp(e,t,n.type==="exit"?(h=e.presenceContext)==null?void 0:h.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);const a=r?()=>Promise.all(nW(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(f=0)=>{const{delayChildren:m=0,staggerChildren:y,staggerDirection:w}=i;return S0e(e,t,f,m,y,w,n)}:()=>Promise.resolve(),{when:c}=i;if(c){const[f,m]=c==="beforeChildren"?[a,o]:[o,a];return f().then(()=>m())}else return Promise.all([a(),o(n.delay)])}function S0e(e,t,n=0,r=0,i=0,a=1,o){const c=[];for(const h of e.variantChildren)h.notify("AnimationStart",t),c.push(qC(h,t,{...o,delay:n+(typeof r=="function"?0:r)+Xq(e.variantChildren,h,r,i,a)}).then(()=>h.notify("AnimationComplete",t)));return Promise.all(c)}function C0e(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const i=t.map(a=>qC(e,a,n));r=Promise.all(i)}else if(typeof t=="string")r=qC(e,t,n);else{const i=typeof t=="function"?Vp(e,t,n.custom):t;r=Promise.all(nW(e,i,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}const j0e={test:e=>e==="auto",parse:e=>e},rW=e=>t=>t.test(e),iW=[Hg,zn,Mu,zh,tme,eme,j0e],S8=e=>iW.find(rW(e));function I0e(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||mq(e):!0}const T0e=new Set(["brightness","contrast","saturate","opacity"]);function P0e(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(WT)||[];if(!r)return e;const i=n.replace(r,"");let a=T0e.has(t)?1:0;return r!==n&&(a*=100),t+"("+a+i+")"}const O0e=/\b([a-z-]*)\(.*?\)/gu,WC={...qc,getAnimatableNone:e=>{const t=e.match(O0e);return t?t.map(P0e).join(" "):e}},KC={...qc,getAnimatableNone:e=>{const t=qc.parse(e);return qc.createTransformer(e)(t.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},C8={...Hg,transform:Math.round},R0e={rotate:zh,rotateX:zh,rotateY:zh,rotateZ:zh,scale:Hv,scaleX:Hv,scaleY:Hv,scaleZ:Hv,skew:zh,skewX:zh,skewY:zh,distance:zn,translateX:zn,translateY:zn,translateZ:zn,x:zn,y:zn,z:zn,perspective:zn,transformPerspective:zn,opacity:my,originX:p8,originY:p8,originZ:zn},r4={borderWidth:zn,borderTopWidth:zn,borderRightWidth:zn,borderBottomWidth:zn,borderLeftWidth:zn,borderRadius:zn,borderTopLeftRadius:zn,borderTopRightRadius:zn,borderBottomRightRadius:zn,borderBottomLeftRadius:zn,width:zn,maxWidth:zn,height:zn,maxHeight:zn,top:zn,right:zn,bottom:zn,left:zn,inset:zn,insetBlock:zn,insetBlockStart:zn,insetBlockEnd:zn,insetInline:zn,insetInlineStart:zn,insetInlineEnd:zn,padding:zn,paddingTop:zn,paddingRight:zn,paddingBottom:zn,paddingLeft:zn,paddingBlock:zn,paddingBlockStart:zn,paddingBlockEnd:zn,paddingInline:zn,paddingInlineStart:zn,paddingInlineEnd:zn,margin:zn,marginTop:zn,marginRight:zn,marginBottom:zn,marginLeft:zn,marginBlock:zn,marginBlockStart:zn,marginBlockEnd:zn,marginInline:zn,marginInlineStart:zn,marginInlineEnd:zn,fontSize:zn,backgroundPositionX:zn,backgroundPositionY:zn,...R0e,zIndex:C8,fillOpacity:my,strokeOpacity:my,numOctaves:C8},D0e={...r4,color:ua,backgroundColor:ua,outlineColor:ua,fill:ua,stroke:ua,borderColor:ua,borderTopColor:ua,borderRightColor:ua,borderBottomColor:ua,borderLeftColor:ua,filter:WC,WebkitFilter:WC,mask:KC,WebkitMask:KC},sW=e=>D0e[e],M0e=new Set([WC,KC]);function aW(e,t){let n=sW(e);return M0e.has(n)||(n=qc),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const L0e=new Set(["auto","none","0"]);function U0e(e,t,n){let r=0,i;for(;r{t.getValue(h).set(f)}),this.resolveNoneKeyframes()}}function oW(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let r=document;const i=(n==null?void 0:n[e])??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(r=>r!=null)}const lW=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function Fw(e){return pq(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:i4}=Cq(queueMicrotask,!1),Mc={x:!1,y:!1};function cW(){return Mc.x||Mc.y}function z0e(e){return e==="x"||e==="y"?Mc[e]?null:(Mc[e]=!0,()=>{Mc[e]=!1}):Mc.x||Mc.y?null:(Mc.x=Mc.y=!0,()=>{Mc.x=Mc.y=!1})}function uW(e,t){const n=oW(e),r=new AbortController,i={passive:!0,...t,signal:r.signal};return[n,i,()=>r.abort()]}function V0e(e){return!(e.pointerType==="touch"||cW())}function F0e(e,t,n={}){const[r,i,a]=uW(e,n);return r.forEach(o=>{let c=!1,h=!1,f;const m=()=>{o.removeEventListener("pointerleave",S)},y=T=>{f&&(f(T),f=void 0),m()},w=T=>{c=!1,window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),h&&(h=!1,y(T))},A=()=>{c=!0,window.addEventListener("pointerup",w,i),window.addEventListener("pointercancel",w,i)},S=T=>{if(T.pointerType!=="touch"){if(c){h=!0;return}y(T)}},C=T=>{if(!V0e(T))return;h=!1;const D=t(o,T);typeof D=="function"&&(f=D,o.addEventListener("pointerleave",S,i))};o.addEventListener("pointerenter",C,i),o.addEventListener("pointerdown",A,i)}),a}const dW=(e,t)=>t?e===t?!0:dW(e,t.parentElement):!1,s4=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,$0e=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function H0e(e){return $0e.has(e.tagName)||e.isContentEditable===!0}const G0e=new Set(["INPUT","SELECT","TEXTAREA"]);function q0e(e){return G0e.has(e.tagName)||e.isContentEditable===!0}const $w=new WeakSet;function j8(e){return t=>{t.key==="Enter"&&e(t)}}function E_(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const W0e=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=j8(()=>{if($w.has(n))return;E_(n,"down");const i=j8(()=>{E_(n,"up")}),a=()=>E_(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",a,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function I8(e){return s4(e)&&!cW()}const T8=new WeakSet;function K0e(e,t,n={}){const[r,i,a]=uW(e,n),o=c=>{const h=c.currentTarget;if(!I8(c)||T8.has(c))return;$w.add(h),n.stopPropagation&&T8.add(c);const f=t(h,c),m=(A,S)=>{window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",w),$w.has(h)&&$w.delete(h),I8(A)&&typeof f=="function"&&f(A,{success:S})},y=A=>{m(A,h===window||h===document||n.useGlobalTarget||dW(h,A.target))},w=A=>{m(A,!1)};window.addEventListener("pointerup",y,i),window.addEventListener("pointercancel",w,i)};return r.forEach(c=>{(n.useGlobalTarget?window:c).addEventListener("pointerdown",o,i),Fw(c)&&(c.addEventListener("focus",f=>W0e(f,i)),!H0e(c)&&!c.hasAttribute("tabindex")&&(c.tabIndex=0))}),a}function a4(e){return pq(e)&&"ownerSVGElement"in e}const Hw=new WeakMap;let Vh;const hW=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+"Size"]:a4(r)&&"getBBox"in r?r.getBBox()[t]:r[n],Y0e=hW("inline","width","offsetWidth"),X0e=hW("block","height","offsetHeight");function Q0e({target:e,borderBoxSize:t}){var n;(n=Hw.get(e))==null||n.forEach(r=>{r(e,{get width(){return Y0e(e,t)},get height(){return X0e(e,t)}})})}function Z0e(e){e.forEach(Q0e)}function J0e(){typeof ResizeObserver>"u"||(Vh=new ResizeObserver(Z0e))}function ege(e,t){Vh||J0e();const n=oW(e);return n.forEach(r=>{let i=Hw.get(r);i||(i=new Set,Hw.set(r,i)),i.add(t),Vh==null||Vh.observe(r)}),()=>{n.forEach(r=>{const i=Hw.get(r);i==null||i.delete(t),i!=null&&i.size||Vh==null||Vh.unobserve(r)})}}const Gw=new Set;let U0;function tge(){U0=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Gw.forEach(t=>t(e))},window.addEventListener("resize",U0)}function nge(e){return Gw.add(e),U0||tge(),()=>{Gw.delete(e),!Gw.size&&typeof U0=="function"&&(window.removeEventListener("resize",U0),U0=void 0)}}function P8(e,t){return typeof e=="function"?nge(e):ege(e,t)}function rge(e){return a4(e)&&e.tagName==="svg"}const ige=[...iW,ua,qc],sge=e=>ige.find(rW(e)),O8=()=>({translate:0,scale:1,origin:0,originPoint:0}),B0=()=>({x:O8(),y:O8()}),R8=()=>({min:0,max:0}),Na=()=>({x:R8(),y:R8()}),age=new WeakMap;function LE(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function gy(e){return typeof e=="string"||Array.isArray(e)}const o4=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],l4=["initial",...o4];function UE(e){return LE(e.animate)||l4.some(t=>gy(e[t]))}function fW(e){return!!(UE(e)||e.variants)}function oge(e,t,n){for(const r in t){const i=t[r],a=n[r];if(ao(i))e.addValue(r,i);else if(ao(a))e.addValue(r,kg(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){const o=e.getValue(r);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=e.getStaticValue(r);e.addValue(r,kg(o!==void 0?o:i,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const YC={current:null},pW={current:!1},lge=typeof window<"u";function cge(){if(pW.current=!0,!!lge)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>YC.current=e.matches;e.addEventListener("change",t),t()}else YC.current=!1}const D8=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let $2={};function mW(e){$2=e}function uge(){return $2}class dge{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:i,skipAnimations:a,blockInitialAnimation:o,visualState:c},h={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=ZT,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const A=$o.now();this.renderScheduledAtthis.bindToMotionValue(a,i)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(pW.current||cge(),this.shouldReduceMotion=YC.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(r=this.parent)==null||r.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var t;this.projection&&this.projection.unmount(),yf(this.notifyUpdate),yf(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const r=this.features[n];r&&(r.unmount(),r.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&Yq.has(t)&&this.current instanceof HTMLElement){const{factory:o,keyframes:c,times:h,ease:f,duration:m}=n.accelerate,y=new Wq({element:this.current,name:t,keyframes:c,times:h,ease:f,duration:Bl(m)}),w=o(y);this.valueSubscriptions.set(t,()=>{w(),y.cancel()});return}const r=qg.has(t);r&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[t]=o,this.props.onUpdate&&ts.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let a;typeof window<"u"&&window.MotionCheckAppearSync&&(a=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),a&&a(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in $2){const n=$2[t];if(!n)continue;const{isEnabled:r,Feature:i}=n;if(!this.features[t]&&i&&r(this.props)&&(this.features[t]=new i(this)),this.features[t]){const a=this.features[t];a.isMounted?a.update():(a.mount(),a.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Na()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;rn.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=kg(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(fq(r)||mq(r))?r=parseFloat(r):!sge(r)&&qc.test(n)&&(r=aW(t,n)),this.setBaseTarget(t,ao(r)?r.get():r)),ao(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var a;const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const o=t4(this.props,n,(a=this.presenceContext)==null?void 0:a.custom);o&&(r=o[t])}if(n&&r!==void 0)return r;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!ao(i)?i:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new $T),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){i4.render(this.render)}}class gW extends dge{constructor(){super(...arguments),this.KeyframeResolver=B0e}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const r=t.style;return r?r[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;ao(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class jf{constructor(t){this.isMounted=!1,this.node=t}update(){}}function xW({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function hge({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function fge(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function A_(e){return e===void 0||e===1}function XC({scale:e,scaleX:t,scaleY:n}){return!A_(e)||!A_(t)||!A_(n)}function dp(e){return XC(e)||yW(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function yW(e){return M8(e.x)||M8(e.y)}function M8(e){return e&&e!=="0%"}function H2(e,t,n){const r=e-n,i=t*r;return n+i}function L8(e,t,n,r,i){return i!==void 0&&(e=H2(e,i,r)),H2(e,n,r)+t}function QC(e,t=0,n=1,r,i){e.min=L8(e.min,t,n,r,i),e.max=L8(e.max,t,n,r,i)}function bW(e,{x:t,y:n}){QC(e.x,t.translate,t.scale,t.originPoint),QC(e.y,n.translate,n.scale,n.originPoint)}const U8=.999999999999,B8=1.0000000000001;function pge(e,t,n,r=!1){var c;const i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let h=0;hU8&&(t.x=1),t.yU8&&(t.y=1)}function Au(e,t){e.min+=t,e.max+=t}function z8(e,t,n,r,i=.5){const a=xs(e.min,e.max,i);QC(e,t,n,a,r)}function V8(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function qw(e,t,n){const r=n??e;z8(e.x,V8(t.x,r.x),t.scaleX,t.scale,t.originX),z8(e.y,V8(t.y,r.y),t.scaleY,t.scale,t.originY)}function vW(e,t){return xW(fge(e.getBoundingClientRect(),t))}function mge(e,t,n){const r=vW(e,n),{scroll:i}=t;return i&&(Au(r.x,i.offset.x),Au(r.y,i.offset.y)),r}const gge={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},xge=Gg.length;function yge(e,t,n){let r="",i=!0;for(let a=0;a{if(!t.target)return e;if(typeof e=="string")if(zn.test(e))e=parseFloat(e);else return e;const n=F8(e,t.target.x),r=F8(e,t.target.y);return`${n}% ${r}%`}},bge={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,i=qc.parse(e);if(i.length>5)return r;const a=qc.createTransformer(e),o=typeof i[0]!="number"?1:0,c=n.x.scale*t.x,h=n.y.scale*t.y;i[0+o]/=c,i[1+o]/=h;const f=xs(c,h,.5);return typeof i[2+o]=="number"&&(i[2+o]/=f),typeof i[3+o]=="number"&&(i[3+o]/=f),a(i)}},ZC={borderRadius:{...Qx,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Qx,borderTopRightRadius:Qx,borderBottomLeftRadius:Qx,borderBottomRightRadius:Qx,boxShadow:bge};function NW(e,{layout:t,layoutId:n}){return qg.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!ZC[e]||e==="opacity")}function u4(e,t,n){var o;const r=e.style,i=t==null?void 0:t.style,a={};if(!r)return a;for(const c in r)(ao(r[c])||i&&ao(i[c])||NW(c,e)||((o=n==null?void 0:n.getValue(c))==null?void 0:o.liveStyle)!==void 0)&&(a[c]=r[c]);return a}function vge(e){return window.getComputedStyle(e)}class wge extends gW{constructor(){super(...arguments),this.type="html",this.renderInstance=wW}readValueFromInstance(t,n){var r;if(qg.has(n))return(r=this.projection)!=null&&r.isProjecting?UC(n):Vme(t,n);{const i=vge(t),a=(Iq(n)?i.getPropertyValue(n):i[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(t,{transformPagePoint:n}){return vW(t,n)}build(t,n,r){c4(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return u4(t,n,r)}}const Nge={offset:"stroke-dashoffset",array:"stroke-dasharray"},Ege={offset:"strokeDashoffset",array:"strokeDasharray"};function Age(e,t,n=1,r=0,i=!0){e.pathLength=1;const a=i?Nge:Ege;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}const _ge=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function EW(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...c},h,f,m){if(c4(e,c,f),h){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:y,style:w}=e;y.transform&&(w.transform=y.transform,delete y.transform),(w.transform||y.transformOrigin)&&(w.transformOrigin=y.transformOrigin??"50% 50%",delete y.transformOrigin),w.transform&&(w.transformBox=(m==null?void 0:m.transformBox)??"fill-box",delete y.transformBox);for(const A of _ge)y[A]!==void 0&&(w[A]=y[A],delete y[A]);t!==void 0&&(y.x=t),n!==void 0&&(y.y=n),r!==void 0&&(y.scale=r),i!==void 0&&Age(y,i,a,o,!1)}const AW=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),_W=e=>typeof e=="string"&&e.toLowerCase()==="svg";function kge(e,t,n,r){wW(e,t,void 0,r);for(const i in t.attrs)e.setAttribute(AW.has(i)?i:n4(i),t.attrs[i])}function kW(e,t,n){const r=u4(e,t,n);for(const i in e)if(ao(e[i])||ao(t[i])){const a=Gg.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[a]=e[i]}return r}class Sge extends gW{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Na}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(qg.has(n)){const r=sW(n);return r&&r.default||0}return n=AW.has(n)?n:n4(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return kW(t,n,r)}build(t,n,r){EW(t,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(t,n,r,i){kge(t,n,r,i)}mount(t){this.isSVGTag=_W(t.tagName),super.mount(t)}}const Cge=l4.length;function SW(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?SW(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;nPromise.all(t.map(({animation:n,options:r})=>C0e(e,n,r)))}function Pge(e){let t=Tge(e),n=$8(),r=!0,i=!1;const a=f=>(m,y)=>{var A;const w=Vp(e,y,f==="exit"?(A=e.presenceContext)==null?void 0:A.custom:void 0);if(w){const{transition:S,transitionEnd:C,...T}=w;m={...m,...T,...C}}return m};function o(f){t=f(e)}function c(f){const{props:m}=e,y=SW(e.parent)||{},w=[],A=new Set;let S={},C=1/0;for(let D=0;DC&&Z,$=!1;const Y=Array.isArray(K)?K:[K];let X=Y.reduce(a(V),{});q===!1&&(X={});const{prevResolvedValues:J={}}=L,ye={...J,...X},ne=Ce=>{F=!0,A.has(Ce)&&($=!0,A.delete(Ce)),L.needsAnimating[Ce]=!0;const Ke=e.getValue(Ce);Ke&&(Ke.liveStyle=!1)};for(const Ce in ye){const Ke=X[Ce],G=J[Ce];if(S.hasOwnProperty(Ce))continue;let se=!1;HC(Ke)&&HC(G)?se=!CW(Ke,G):se=Ke!==G,se?Ke!=null?ne(Ce):A.add(Ce):Ke!==void 0&&A.has(Ce)?ne(Ce):L.protectedKeys[Ce]=!0}L.prevProp=K,L.prevResolvedValues=X,L.isActive&&(S={...S,...X}),(r||i)&&e.blockInitialAnimation&&(F=!1);const de=B&&z;F&&(!de||$)&&w.push(...Y.map(Ce=>{const Ke={type:V};if(typeof Ce=="string"&&(r||i)&&!de&&e.manuallyAnimateOnMount&&e.parent){const{parent:G}=e,se=Vp(G,Ce);if(G.enteringChildren&&se){const{delayChildren:xe}=se.transition||{};Ke.delay=Xq(G.enteringChildren,e,xe)}}return{animation:Ce,options:Ke}}))}if(A.size){const D={};if(typeof m.initial!="boolean"){const V=Vp(e,Array.isArray(m.initial)?m.initial[0]:m.initial);V&&V.transition&&(D.transition=V.transition)}A.forEach(V=>{const L=e.getBaseTarget(V),K=e.getValue(V);K&&(K.liveStyle=!0),D[V]=L??null}),w.push({animation:D})}let T=!!w.length;return r&&(m.initial===!1||m.initial===m.animate)&&!e.manuallyAnimateOnMount&&(T=!1),r=!1,i=!1,T?t(w):Promise.resolve()}function h(f,m){var w;if(n[f].isActive===m)return Promise.resolve();(w=e.variantChildren)==null||w.forEach(A=>{var S;return(S=A.animationState)==null?void 0:S.setActive(f,m)}),n[f].isActive=m;const y=c(f);for(const A in n)n[A].protectedKeys={};return y}return{animateChanges:c,setActive:h,setAnimateFunction:o,getState:()=>n,reset:()=>{n=$8(),i=!0}}}function Oge(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!CW(t,e):!1}function np(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function $8(){return{animate:np(!0),whileInView:np(),whileHover:np(),whileTap:np(),whileDrag:np(),whileFocus:np(),exit:np()}}function JC(e,t){e.min=t.min,e.max=t.max}function Dc(e,t){JC(e.x,t.x),JC(e.y,t.y)}function H8(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const jW=1e-4,Rge=1-jW,Dge=1+jW,IW=.01,Mge=0-IW,Lge=0+IW;function Ho(e){return e.max-e.min}function Uge(e,t,n){return Math.abs(e-t)<=n}function G8(e,t,n,r=.5){e.origin=r,e.originPoint=xs(t.min,t.max,e.origin),e.scale=Ho(n)/Ho(t),e.translate=xs(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Rge&&e.scale<=Dge||isNaN(e.scale))&&(e.scale=1),(e.translate>=Mge&&e.translate<=Lge||isNaN(e.translate))&&(e.translate=0)}function $1(e,t,n,r){G8(e.x,t.x,n.x,r?r.originX:void 0),G8(e.y,t.y,n.y,r?r.originY:void 0)}function q8(e,t,n,r=0){const i=r?xs(n.min,n.max,r):n.min;e.min=i+t.min,e.max=e.min+Ho(t)}function Bge(e,t,n,r){q8(e.x,t.x,n.x,r==null?void 0:r.x),q8(e.y,t.y,n.y,r==null?void 0:r.y)}function W8(e,t,n,r=0){const i=r?xs(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Ho(t)}function G2(e,t,n,r){W8(e.x,t.x,n.x,r==null?void 0:r.x),W8(e.y,t.y,n.y,r==null?void 0:r.y)}function K8(e,t,n,r,i){return e-=t,e=H2(e,1/n,r),i!==void 0&&(e=H2(e,1/i,r)),e}function zge(e,t=0,n=1,r=.5,i,a=e,o=e){if(Mu.test(t)&&(t=parseFloat(t),t=xs(o.min,o.max,t/100)-o.min),typeof t!="number")return;let c=xs(a.min,a.max,r);e===a&&(c-=t),e.min=K8(e.min,t,n,c,i),e.max=K8(e.max,t,n,c,i)}function Y8(e,t,[n,r,i],a,o){zge(e,t[n],t[r],t[i],t.scale,a,o)}const Vge=["x","scaleX","originX"],Fge=["y","scaleY","originY"];function X8(e,t,n,r){Y8(e.x,t,Vge,n?n.x:void 0,r?r.x:void 0),Y8(e.y,t,Fge,n?n.y:void 0,r?r.y:void 0)}function Q8(e){return e.translate===0&&e.scale===1}function TW(e){return Q8(e.x)&&Q8(e.y)}function Z8(e,t){return e.min===t.min&&e.max===t.max}function $ge(e,t){return Z8(e.x,t.x)&&Z8(e.y,t.y)}function J8(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function PW(e,t){return J8(e.x,t.x)&&J8(e.y,t.y)}function eM(e){return Ho(e.x)/Ho(e.y)}function tM(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function yu(e){return[e("x"),e("y")]}function Hge(e,t,n){let r="";const i=e.x.translate/t.x,a=e.y.translate/t.y,o=(n==null?void 0:n.z)||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:f,rotate:m,rotateX:y,rotateY:w,skewX:A,skewY:S}=n;f&&(r=`perspective(${f}px) ${r}`),m&&(r+=`rotate(${m}deg) `),y&&(r+=`rotateX(${y}deg) `),w&&(r+=`rotateY(${w}deg) `),A&&(r+=`skewX(${A}deg) `),S&&(r+=`skewY(${S}deg) `)}const c=e.x.scale*t.x,h=e.y.scale*t.y;return(c!==1||h!==1)&&(r+=`scale(${c}, ${h})`),r||"none"}const OW=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],Gge=OW.length,nM=e=>typeof e=="string"?parseFloat(e):e,rM=e=>typeof e=="number"||zn.test(e);function qge(e,t,n,r,i,a){i?(e.opacity=xs(0,n.opacity??1,Wge(r)),e.opacityExit=xs(t.opacity??1,0,Kge(r))):a&&(e.opacity=xs(t.opacity??1,n.opacity??1,r));for(let o=0;ort?1:n(py(e,t,r))}function Yge(e,t,n){const r=ao(e)?e:kg(e);return r.start(e4("",r,t,n)),r.animation}function xy(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}const Xge=(e,t)=>e.depth-t.depth;class Qge{constructor(){this.children=[],this.isDirty=!1}add(t){VT(this.children,t),this.isDirty=!0}remove(t){U2(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Xge),this.isDirty=!1,this.children.forEach(t)}}function Zge(e,t){const n=$o.now(),r=({timestamp:i})=>{const a=i-n;a>=t&&(yf(r),e(a-t))};return ts.setup(r,!0),()=>yf(r)}function Ww(e){return ao(e)?e.get():e}class Jge{constructor(){this.members=[]}add(t){VT(this.members,t);for(let n=this.members.length-1;n>=0;n--){const r=this.members[n];if(r===t||r===this.lead||r===this.prevLead)continue;const i=r.instance;(!i||i.isConnected===!1)&&!r.snapshot&&(U2(this.members,r),r.unmount())}t.scheduleRender()}remove(t){if(U2(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){var n;for(let r=this.members.indexOf(t)-1;r>=0;r--){const i=this.members[r];if(i.isPresent!==!1&&((n=i.instance)==null?void 0:n.isConnected)!==!1)return this.promote(i),!0}return!1}promote(t,n){var i;const r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.updateSnapshot(),t.scheduleRender();const{layoutDependency:a}=r.options,{layoutDependency:o}=t.options;(a===void 0||a!==o)&&(t.resumeFrom=r,n&&(r.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),(i=t.root)!=null&&i.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{var n,r,i,a,o;(r=(n=t.options).onExitComplete)==null||r.call(n),(o=(i=t.resumingFrom)==null?void 0:(a=i.options).onExitComplete)==null||o.call(a)})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){var t;(t=this.lead)!=null&&t.snapshot&&(this.lead.snapshot=void 0)}}const Kw={hasAnimatedSinceResize:!0,hasEverUpdated:!1},__=["","X","Y","Z"],exe=1e3;let txe=0;function k_(e,t,n,r){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function DW(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=tW(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:a}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ts,!(i||a))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&DW(r)}function MW({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(o={},c=t==null?void 0:t()){this.id=txe++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(ixe),this.nodes.forEach(uxe),this.nodes.forEach(dxe),this.nodes.forEach(sxe)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=c?c.root||c:this,this.path=c?[...c.path,c]:[],this.parent=c,this.depth=c?c.depth+1:0;for(let h=0;hthis.root.updateBlockedByResize=!1;ts.read(()=>{y=window.innerWidth}),e(o,()=>{const A=window.innerWidth;A!==y&&(y=A,this.root.updateBlockedByResize=!0,m&&m(),m=Zge(w,250),Kw.hasAnimatedSinceResize&&(Kw.hasAnimatedSinceResize=!1,this.nodes.forEach(oM)))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&f&&(c||h)&&this.addEventListener("didUpdate",({delta:m,hasLayoutChanged:y,hasRelativeLayoutChanged:w,layout:A})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const S=this.options.transition||f.getDefaultTransition()||gxe,{onLayoutAnimationStart:C,onLayoutAnimationComplete:T}=f.getProps(),D=!this.targetLayout||!PW(this.targetLayout,A),V=!y&&w;if(this.options.layoutRoot||this.resumeFrom||V||y&&(D||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const L={...JT(S,"layout"),onPlay:C,onComplete:T};(f.shouldReduceMotion||this.options.layoutRoot)&&(L.delay=0,L.type=!1),this.startAnimation(L),this.setAnimationOrigin(m,V)}else y||oM(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=A})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),yf(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(hxe),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&DW(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let m=0;m{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ho(this.snapshot.measuredBox.x)&&!Ho(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let h=0;h{const Z=K/1e3;lM(y.x,o.x,Z),lM(y.y,o.y,Z),this.setTargetDelta(y),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(G2(w,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),pxe(this.relativeTarget,this.relativeTargetOrigin,w,Z),L&&$ge(this.relativeTarget,L)&&(this.isProjectionDirty=!1),L||(L=Na()),Dc(L,this.relativeTarget)),C&&(this.animationValues=m,qge(m,f,this.latestValues,Z,V,D)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=Z},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){var c,h,f;this.notifyListeners("animationStart"),(c=this.currentAnimation)==null||c.stop(),(f=(h=this.resumingFrom)==null?void 0:h.currentAnimation)==null||f.stop(),this.pendingAnimation&&(yf(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ts.update(()=>{Kw.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=kg(0)),this.motionValue.jump(0,!1),this.currentAnimation=Yge(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:m=>{this.mixTargetDelta(m),o.onUpdate&&o.onUpdate(m)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(exe),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:c,target:h,layout:f,latestValues:m}=o;if(!(!c||!h||!f)){if(this!==o&&this.layout&&f&&LW(this.options.animationType,this.layout.layoutBox,f.layoutBox)){h=this.target||Na();const y=Ho(this.layout.layoutBox.x);h.x.min=o.target.x.min,h.x.max=h.x.min+y;const w=Ho(this.layout.layoutBox.y);h.y.min=o.target.y.min,h.y.max=h.y.min+w}Dc(c,h),qw(c,m),$1(this.projectionDeltaWithTransform,this.layoutCorrected,c,m)}}registerSharedNode(o,c){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Jge),this.sharedNodes.get(o).add(c);const f=c.options.initialPromotionConfig;c.promote({transition:f?f.transition:void 0,preserveFollowOpacity:f&&f.shouldPreserveFollowOpacity?f.shouldPreserveFollowOpacity(c):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var c;const{layoutId:o}=this.options;return o?((c=this.getStack())==null?void 0:c.lead)||this:this}getPrevLead(){var c;const{layoutId:o}=this.options;return o?(c=this.getStack())==null?void 0:c.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:c,preserveFollowOpacity:h}={}){const f=this.getStack();f&&f.promote(this,h),o&&(this.projectionDelta=void 0,this.needsReset=!0),c&&this.setOptions({transition:c})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let c=!1;const{latestValues:h}=o;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(c=!0),!c)return;const f={};h.z&&k_("z",o,f,this.animationValues);for(let m=0;m<__.length;m++)k_(`rotate${__[m]}`,o,f,this.animationValues),k_(`skew${__[m]}`,o,f,this.animationValues);o.render();for(const m in f)o.setStaticValue(m,f[m]),this.animationValues&&(this.animationValues[m]=f[m]);o.scheduleRender()}applyProjectionStyles(o,c){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const h=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Ww(c==null?void 0:c.pointerEvents)||"",o.transform=h?h(this.latestValues,""):"none";return}const f=this.getLead();if(!this.projectionDelta||!this.layout||!f.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Ww(c==null?void 0:c.pointerEvents)||""),this.hasProjected&&!dp(this.latestValues)&&(o.transform=h?h({},""):"none",this.hasProjected=!1);return}o.visibility="";const m=f.animationValues||f.latestValues;this.applyTransformsToTarget();let y=Hge(this.projectionDeltaWithTransform,this.treeScale,m);h&&(y=h(m,y)),o.transform=y;const{x:w,y:A}=this.projectionDelta;o.transformOrigin=`${w.origin*100}% ${A.origin*100}% 0`,f.animationValues?o.opacity=f===this?m.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:m.opacityExit:o.opacity=f===this?m.opacity!==void 0?m.opacity:"":m.opacityExit!==void 0?m.opacityExit:0;for(const S in ZC){if(m[S]===void 0)continue;const{correct:C,applyTo:T,isCSSVariable:D}=ZC[S],V=y==="none"?m[S]:C(m[S],f);if(T){const L=T.length;for(let K=0;K{var c;return(c=o.currentAnimation)==null?void 0:c.stop()}),this.root.nodes.forEach(sM),this.root.sharedNodes.clear()}}}function nxe(e){e.updateLayout()}function rxe(e){var n;const t=((n=e.resumeFrom)==null?void 0:n.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:r,measuredBox:i}=e.layout,{animationType:a}=e.options,o=t.source!==e.layout.source;if(a==="size")yu(y=>{const w=o?t.measuredBox[y]:t.layoutBox[y],A=Ho(w);w.min=r[y].min,w.max=w.min+A});else if(a==="x"||a==="y"){const y=a==="x"?"y":"x";JC(o?t.measuredBox[y]:t.layoutBox[y],r[y])}else LW(a,t.layoutBox,r)&&yu(y=>{const w=o?t.measuredBox[y]:t.layoutBox[y],A=Ho(r[y]);w.max=w.min+A,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[y].max=e.relativeTarget[y].min+A)});const c=B0();$1(c,r,t.layoutBox);const h=B0();o?$1(h,e.applyTransform(i,!0),t.measuredBox):$1(h,r,t.layoutBox);const f=!TW(c);let m=!1;if(!e.resumeFrom){const y=e.getClosestProjectingParent();if(y&&!y.resumeFrom){const{snapshot:w,layout:A}=y;if(w&&A){const S=e.options.layoutAnchor||void 0,C=Na();G2(C,t.layoutBox,w.layoutBox,S);const T=Na();G2(T,r,A.layoutBox,S),PW(C,T)||(m=!0),y.options.layoutRoot&&(e.relativeTarget=T,e.relativeTargetOrigin=C,e.relativeParent=y)}}}e.notifyListeners("didUpdate",{layout:r,snapshot:t,delta:h,layoutDelta:c,hasLayoutChanged:f,hasRelativeLayoutChanged:m})}else if(e.isLead()){const{onExitComplete:r}=e.options;r&&r()}e.options.transition=void 0}function ixe(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function sxe(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function axe(e){e.clearSnapshot()}function sM(e){e.clearMeasurements()}function oxe(e){e.isLayoutDirty=!0,e.updateLayout()}function aM(e){e.isLayoutDirty=!1}function lxe(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function cxe(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function oM(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function uxe(e){e.resolveTargetDelta()}function dxe(e){e.calcProjection()}function hxe(e){e.resetSkewAndRotation()}function fxe(e){e.removeLeadSnapshot()}function lM(e,t,n){e.translate=xs(t.translate,0,n),e.scale=xs(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function cM(e,t,n,r){e.min=xs(t.min,n.min,r),e.max=xs(t.max,n.max,r)}function pxe(e,t,n,r){cM(e.x,t.x,n.x,r),cM(e.y,t.y,n.y,r)}function mxe(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const gxe={duration:.45,ease:[.4,0,.1,1]},uM=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),dM=uM("applewebkit/")&&!uM("chrome/")?Math.round:gc;function hM(e){e.min=dM(e.min),e.max=dM(e.max)}function xxe(e){hM(e.x),hM(e.y)}function LW(e,t,n){return e==="position"||e==="preserve-aspect"&&!Uge(eM(t),eM(n),.2)}function yxe(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const bxe=MW({attachResizeListener:(e,t)=>xy(e,"resize",t),measureScroll:()=>{var e,t;return{x:document.documentElement.scrollLeft||((e=document.body)==null?void 0:e.scrollLeft)||0,y:document.documentElement.scrollTop||((t=document.body)==null?void 0:t.scrollTop)||0}},checkIsScrollRoot:()=>!0}),S_={current:void 0},UW=MW({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!S_.current){const e=new bxe({});e.mount(window),e.setOptions({layoutScroll:!0}),S_.current=e}return S_.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),d4=I.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function fM(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function vxe(...e){return t=>{let n=!1;const r=e.map(i=>{const a=fM(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i{const{width:A,height:S,top:C,left:T,right:D,bottom:V}=h.current;if(t||a===!1||!c.current||!A||!S)return;const L=n==="left"?`left: ${T}`:`right: ${D}`,K=r==="bottom"?`bottom: ${V}`:`top: ${C}`;c.current.dataset.motionPopId=o;const Z=document.createElement("style");f&&(Z.nonce=f);const q=i??document.head;return q.appendChild(Z),Z.sheet&&Z.sheet.insertRule(` [data-motion-pop-id="${o}"] { position: absolute !important; width: ${A}px !important; height: ${S}px !important; ${L}px !important; ${K}px !important; } `),()=>{var B;(B=c.current)==null||B.removeAttribute("data-motion-pop-id"),q.contains(Z)&&q.removeChild(Z)}},[t]),s.jsx(Nxe,{isPresent:t,childRef:c,sizeRef:h,pop:a,children:a===!1?e:I.cloneElement(e,{ref:y})})}const Axe=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:c,anchorY:h,root:f})=>{const m=zT(_xe),y=I.useId();let w=!0,A=I.useMemo(()=>(w=!1,{id:y,initial:t,isPresent:n,custom:i,onExitComplete:S=>{m.set(S,!0);for(const C of m.values())if(!C)return;r&&r()},register:S=>(m.set(S,!1),()=>m.delete(S))}),[n,m,r]);return a&&w&&(A={...A}),I.useMemo(()=>{m.forEach((S,C)=>m.set(C,!1))},[n]),I.useEffect(()=>{!n&&!m.size&&r&&r()},[n]),e=s.jsx(Exe,{pop:o==="popLayout",isPresent:n,anchorX:c,anchorY:h,root:f,children:e}),s.jsx(DE.Provider,{value:A,children:e})};function _xe(){return new Map}function BW(e=!0){const t=I.useContext(DE);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:i}=t,a=I.useId();I.useEffect(()=>{if(e)return i(a)},[e]);const o=I.useCallback(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}const Gv=e=>e.key||"";function pM(e){const t=[];return I.Children.forEach(e,n=>{I.isValidElement(n)&&t.push(n)}),t}const or=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a="sync",propagate:o=!1,anchorX:c="left",anchorY:h="top",root:f})=>{const[m,y]=BW(o),w=I.useMemo(()=>pM(e),[e]),A=o&&!m?[]:w.map(Gv),S=I.useRef(!0),C=I.useRef(w),T=zT(()=>new Map),D=I.useRef(new Set),[V,L]=I.useState(w),[K,Z]=I.useState(w);hq(()=>{S.current=!1,C.current=w;for(let z=0;z{const F=Gv(z),$=o&&!m?!1:w===K||A.includes(F),Y=()=>{if(D.current.has(F))return;if(T.has(F))D.current.add(F),T.set(F,!0);else return;let X=!0;T.forEach(J=>{J||(X=!1)}),X&&(B==null||B(),Z(C.current),o&&(y==null||y()),r&&r())};return s.jsx(Axe,{isPresent:$,initial:!S.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:f,onExitComplete:$?void 0:Y,anchorX:c,anchorY:h,children:z},F)})})},zW=I.createContext({strict:!1}),mM={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let gM=!1;function kxe(){if(gM)return;const e={};for(const t in mM)e[t]={isEnabled:n=>mM[t].some(r=>!!n[r])};mW(e),gM=!0}function VW(){return kxe(),uge()}function Sxe(e){const t=VW();for(const n in e)t[n]={...t[n],...e[n]};mW(t)}const Cxe=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function q2(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Cxe.has(e)}let FW=e=>!q2(e);function jxe(e){typeof e=="function"&&(FW=t=>t.startsWith("on")?!q2(t):e(t))}try{jxe(require("@emotion/is-prop-valid").default)}catch{}function Ixe(e,t,n){const r={};for(const i in e)i==="values"&&typeof e.values=="object"||ao(e[i])||(FW(i)||n===!0&&q2(i)||!t&&!q2(i)||e.draggable&&i.startsWith("onDrag"))&&(r[i]=e[i]);return r}const BE=I.createContext({});function Txe(e,t){if(UE(e)){const{initial:n,animate:r}=e;return{initial:n===!1||gy(n)?n:void 0,animate:gy(r)?r:void 0}}return e.inherit!==!1?t:{}}function Pxe(e){const{initial:t,animate:n}=Txe(e,I.useContext(BE));return I.useMemo(()=>({initial:t,animate:n}),[xM(t),xM(n)])}function xM(e){return Array.isArray(e)?e.join(" "):e}const h4=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function $W(e,t,n){for(const r in t)!ao(t[r])&&!NW(r,n)&&(e[r]=t[r])}function Oxe({transformTemplate:e},t){return I.useMemo(()=>{const n=h4();return c4(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Rxe(e,t){const n=e.style||{},r={};return $W(r,n,e),Object.assign(r,Oxe(e,t)),r}function Dxe(e,t){const n={},r=Rxe(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const HW=()=>({...h4(),attrs:{}});function Mxe(e,t,n,r){const i=I.useMemo(()=>{const a=HW();return EW(a,t,_W(r),e.transformTemplate,e.style),{...a.attrs,style:{...a.style}}},[t]);if(e.style){const a={};$W(a,e.style,e),i.style={...a,...i.style}}return i}const Lxe=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function f4(e){return typeof e!="string"||e.includes("-")?!1:!!(Lxe.indexOf(e)>-1||/[A-Z]/u.test(e))}function Uxe(e,t,n,{latestValues:r},i,a=!1,o){const h=(o??f4(e)?Mxe:Dxe)(t,r,i,e),f=Ixe(t,typeof e=="string",a),m=e!==I.Fragment?{...f,...h,ref:n}:{},{children:y}=t,w=I.useMemo(()=>ao(y)?y.get():y,[y]);return I.createElement(e,{...m,children:w})}function Bxe({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:zxe(n,r,i,e),renderState:t()}}function zxe(e,t,n,r){const i={},a=r(e,{});for(const w in a)i[w]=Ww(a[w]);let{initial:o,animate:c}=e;const h=UE(e),f=fW(e);t&&f&&!h&&e.inherit!==!1&&(o===void 0&&(o=t.initial),c===void 0&&(c=t.animate));let m=n?n.initial===!1:!1;m=m||o===!1;const y=m?c:o;if(y&&typeof y!="boolean"&&!LE(y)){const w=Array.isArray(y)?y:[y];for(let A=0;A(t,n)=>{const r=I.useContext(BE),i=I.useContext(DE),a=()=>Bxe(e,t,r,i);return n?a():zT(a)},Vxe=GW({scrapeMotionValuesFromProps:u4,createRenderState:h4}),Fxe=GW({scrapeMotionValuesFromProps:kW,createRenderState:HW}),$xe=Symbol.for("motionComponentSymbol");function Hxe(e,t,n){const r=I.useRef(n);I.useInsertionEffect(()=>{r.current=n});const i=I.useRef(null);return I.useCallback(a=>{var c;a&&((c=e.onMount)==null||c.call(e,a));const o=r.current;if(typeof o=="function")if(a){const h=o(a);typeof h=="function"&&(i.current=h)}else i.current?(i.current(),i.current=null):o(a);else o&&(o.current=a);t&&(a?t.mount(a):t.unmount())},[t])}const qW=I.createContext({});function O0(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Gxe(e,t,n,r,i,a){var L,K;const{visualElement:o}=I.useContext(BE),c=I.useContext(zW),h=I.useContext(DE),f=I.useContext(d4),m=f.reducedMotion,y=f.skipAnimations,w=I.useRef(null),A=I.useRef(!1);r=r||c.renderer,!w.current&&r&&(w.current=r(e,{visualState:t,parent:o,props:n,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:m,skipAnimations:y,isSVG:a}),A.current&&w.current&&(w.current.manuallyAnimateOnMount=!0));const S=w.current,C=I.useContext(qW);S&&!S.projection&&i&&(S.type==="html"||S.type==="svg")&&qxe(w.current,n,i,C);const T=I.useRef(!1);I.useInsertionEffect(()=>{S&&T.current&&S.update(n,h)});const D=n[eW],V=I.useRef(!!D&&typeof window<"u"&&!((L=window.MotionHandoffIsComplete)!=null&&L.call(window,D))&&((K=window.MotionHasOptimisedAnimation)==null?void 0:K.call(window,D)));return hq(()=>{A.current=!0,S&&(T.current=!0,window.MotionIsMounted=!0,S.updateFeatures(),S.scheduleRenderMicrotask(),V.current&&S.animationState&&S.animationState.animateChanges())}),I.useEffect(()=>{S&&(!V.current&&S.animationState&&S.animationState.animateChanges(),V.current&&(queueMicrotask(()=>{var Z;(Z=window.MotionHandoffMarkAsComplete)==null||Z.call(window,D)}),V.current=!1),S.enteringChildren=void 0)}),S}function qxe(e,t,n,r){const{layoutId:i,layout:a,drag:o,dragConstraints:c,layoutScroll:h,layoutRoot:f,layoutAnchor:m,layoutCrossfade:y}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:WW(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||c&&O0(c),visualElement:e,animationType:typeof a=="string"?a:"both",initialPromotionConfig:r,crossfade:y,layoutScroll:h,layoutRoot:f,layoutAnchor:m})}function WW(e){if(e)return e.options.allowProjection!==!1?e.projection:WW(e.parent)}function C_(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&Sxe(r);const a=n?n==="svg":f4(e),o=a?Fxe:Vxe;function c(f,m){let y;const w={...I.useContext(d4),...f,layoutId:Wxe(f)},{isStatic:A}=w,S=Pxe(f),C=o(f,A);if(!A&&typeof window<"u"){Kxe();const T=Yxe(w);y=T.MeasureLayout,S.visualElement=Gxe(e,C,w,i,T.ProjectionNode,a)}return s.jsxs(BE.Provider,{value:S,children:[y&&S.visualElement?s.jsx(y,{visualElement:S.visualElement,...w}):null,Uxe(e,f,Hxe(C,S.visualElement,m),C,A,t,a)]})}c.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const h=I.forwardRef(c);return h[$xe]=e,h}function Wxe({layoutId:e}){const t=I.useContext(BT).id;return t&&e!==void 0?t+"-"+e:e}function Kxe(e,t){I.useContext(zW).strict}function Yxe(e){const t=VW(),{drag:n,layout:r}=t;if(!n&&!r)return{};const i={...n,...r};return{MeasureLayout:n!=null&&n.isEnabled(e)||r!=null&&r.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function Xxe(e,t){if(typeof Proxy>"u")return C_;const n=new Map,r=(a,o)=>C_(a,o,e,t),i=(a,o)=>r(a,o);return new Proxy(i,{get:(a,o)=>o==="create"?r:(n.has(o)||n.set(o,C_(o,void 0,e,t)),n.get(o))})}const Qxe=(e,t)=>t.isSVG??f4(e)?new Sge(t):new wge(t,{allowProjection:e!==I.Fragment});class Zxe extends jf{constructor(t){super(t),t.animationState||(t.animationState=Pge(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();LE(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let Jxe=0;class e1e extends jf{constructor(){super(...arguments),this.id=Jxe++,this.isExitComplete=!1}update(){var a;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;if(t&&r===!1){if(this.isExitComplete){const{initial:o,custom:c}=this.node.getProps();if(typeof o=="string"){const h=Vp(this.node,o,c);if(h){const{transition:f,transitionEnd:m,...y}=h;for(const w in y)(a=this.node.getValue(w))==null||a.jump(y[w])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const t1e={animation:{Feature:Zxe},exit:{Feature:e1e}};function nb(e){return{point:{x:e.pageX,y:e.pageY}}}const n1e=e=>t=>s4(t)&&e(t,nb(t));function H1(e,t,n,r){return xy(e,t,n1e(n),r)}const KW=({current:e})=>e?e.ownerDocument.defaultView:null,yM=(e,t)=>Math.abs(e-t);function r1e(e,t){const n=yM(e.x,t.x),r=yM(e.y,t.y);return Math.sqrt(n**2+r**2)}const bM=new Set(["auto","scroll"]);class YW{constructor(t,n,{transformPagePoint:r,contextWindow:i=window,dragSnapToOrigin:a=!1,distanceThreshold:o=3,element:c}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=A=>{this.handleScroll(A.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=qv(this.lastRawMoveEventInfo,this.transformPagePoint));const A=j_(this.lastMoveEventInfo,this.history),S=this.startEvent!==null,C=r1e(A.offset,{x:0,y:0})>=this.distanceThreshold;if(!S&&!C)return;const{point:T}=A,{timestamp:D}=no;this.history.push({...T,timestamp:D});const{onStart:V,onMove:L}=this.handlers;S||(V&&V(this.lastMoveEvent,A),this.startEvent=this.lastMoveEvent),L&&L(this.lastMoveEvent,A)},this.handlePointerMove=(A,S)=>{this.lastMoveEvent=A,this.lastRawMoveEventInfo=S,this.lastMoveEventInfo=qv(S,this.transformPagePoint),ts.update(this.updatePoint,!0)},this.handlePointerUp=(A,S)=>{this.end();const{onEnd:C,onSessionEnd:T,resumeAnimation:D}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&D&&D(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const V=j_(A.type==="pointercancel"?this.lastMoveEventInfo:qv(S,this.transformPagePoint),this.history);this.startEvent&&C&&C(A,V),T&&T(A,V)},!s4(t))return;this.dragSnapToOrigin=a,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=o,this.contextWindow=i||window;const h=nb(t),f=qv(h,this.transformPagePoint),{point:m}=f,{timestamp:y}=no;this.history=[{...m,timestamp:y}];const{onSessionStart:w}=n;w&&w(t,j_(f,this.history)),this.removeListeners=Jy(H1(this.contextWindow,"pointermove",this.handlePointerMove),H1(this.contextWindow,"pointerup",this.handlePointerUp),H1(this.contextWindow,"pointercancel",this.handlePointerUp)),c&&this.startScrollTracking(c)}startScrollTracking(t){let n=t.parentElement;for(;n;){const r=getComputedStyle(n);(bM.has(r.overflowX)||bM.has(r.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const r=t===window,i=r?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},a={x:i.x-n.x,y:i.y-n.y};a.x===0&&a.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=a.x,this.lastMoveEventInfo.point.y+=a.y):this.history.length>0&&(this.history[0].x-=a.x,this.history[0].y-=a.y),this.scrollPositions.set(t,i),ts.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),yf(this.updatePoint)}}function qv(e,t){return t?{point:t(e.point)}:e}function vM(e,t){return{x:e.x-t.x,y:e.y-t.y}}function j_({point:e},t){return{point:e,delta:vM(e,XW(t)),offset:vM(e,i1e(t)),velocity:s1e(t,.1)}}function i1e(e){return e[0]}function XW(e){return e[e.length-1]}function s1e(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const i=XW(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Bl(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Bl(t)*2&&(r=e[1]);const a=hc(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};const o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function a1e(e,{min:t,max:n},r){return t!==void 0&&en&&(e=r?xs(n,e,r.max):Math.min(e,n)),e}function wM(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function o1e(e,{top:t,left:n,bottom:r,right:i}){return{x:wM(e.x,n,i),y:wM(e.y,t,r)}}function NM(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.minr?n=py(t.min,t.max-r,e.min):r>i&&(n=py(e.min,e.max-i,t.min)),Fu(0,1,n)}function u1e(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const ej=.35;function d1e(e=ej){return e===!1?e=0:e===!0&&(e=ej),{x:EM(e,"left","right"),y:EM(e,"top","bottom")}}function EM(e,t,n){return{min:AM(e,t),max:AM(e,n)}}function AM(e,t){return typeof e=="number"?e:e[t]||0}const h1e=new WeakMap;class f1e{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Na(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const a=y=>{n&&this.snapToCursor(nb(y).point),this.stopAnimation()},o=(y,w)=>{const{drag:A,dragPropagation:S,onDragStart:C}=this.getProps();if(A&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=z0e(A),!this.openDragLock))return;this.latestPointerEvent=y,this.latestPanInfo=w,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),yu(D=>{let V=this.getAxisMotionValue(D).get()||0;if(Mu.test(V)){const{projection:L}=this.visualElement;if(L&&L.layout){const K=L.layout.layoutBox[D];K&&(V=Ho(K)*(parseFloat(V)/100))}}this.originPoint[D]=V}),C&&ts.update(()=>C(y,w),!1,!0),GC(this.visualElement,"transform");const{animationState:T}=this.visualElement;T&&T.setActive("whileDrag",!0)},c=(y,w)=>{this.latestPointerEvent=y,this.latestPanInfo=w;const{dragPropagation:A,dragDirectionLock:S,onDirectionLock:C,onDrag:T}=this.getProps();if(!A&&!this.openDragLock)return;const{offset:D}=w;if(S&&this.currentDirection===null){this.currentDirection=m1e(D),this.currentDirection!==null&&C&&C(this.currentDirection);return}this.updateAxis("x",w.point,D),this.updateAxis("y",w.point,D),this.visualElement.render(),T&&ts.update(()=>T(y,w),!1,!0)},h=(y,w)=>{this.latestPointerEvent=y,this.latestPanInfo=w,this.stop(y,w),this.latestPointerEvent=null,this.latestPanInfo=null},f=()=>{const{dragSnapToOrigin:y}=this.getProps();(y||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:m}=this.getProps();this.panSession=new YW(t,{onSessionStart:a,onStart:o,onMove:c,onSessionEnd:h,resumeAnimation:f},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:m,distanceThreshold:r,contextWindow:KW(this.visualElement),element:this.visualElement.current})}stop(t,n){const r=t||this.latestPointerEvent,i=n||this.latestPanInfo,a=this.isDragging;if(this.cancel(),!a||!i||!r)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:c}=this.getProps();c&&ts.postRender(()=>c(r,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,r){const{drag:i}=this.getProps();if(!r||!Wv(t,i,this.currentDirection))return;const a=this.getAxisMotionValue(t);let o=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(o=a1e(o,this.constraints[t],this.elastic[t])),a.set(o)}resolveConstraints(){var a;const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(a=this.visualElement.projection)==null?void 0:a.layout,i=this.constraints;t&&O0(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=o1e(r.layoutBox,t):this.constraints=!1,this.elastic=d1e(n),i!==this.constraints&&!O0(t)&&r&&this.constraints&&!this.hasMutatedConstraints&&yu(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=u1e(r.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!O0(t))return!1;const r=t.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const a=mge(r,i.root,this.visualElement.getTransformPagePoint());let o=l1e(i.layout.layoutBox,a);if(n){const c=n(hge(o));this.hasMutatedConstraints=!!c,c&&(o=xW(c))}return o}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:i,dragTransition:a,dragSnapToOrigin:o,onDragTransitionEnd:c}=this.getProps(),h=this.constraints||{},f=yu(m=>{if(!Wv(m,n,this.currentDirection))return;let y=h&&h[m]||{};(o===!0||o===m)&&(y={min:0,max:0});const w=i?200:1e6,A=i?40:1e7,S={type:"inertia",velocity:r?t[m]:0,bounceStiffness:w,bounceDamping:A,timeConstant:750,restDelta:1,restSpeed:10,...a,...y};return this.startAxisValueAnimation(m,S)});return Promise.all(f).then(c)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return GC(this.visualElement,t),r.start(e4(t,r,0,n,this.visualElement,!1))}stopAnimation(){yu(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),i=r[n];return i||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){yu(n=>{const{drag:r}=this.getProps();if(!Wv(n,r,this.currentDirection))return;const{projection:i}=this.visualElement,a=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:c}=i.layout.layoutBox[n],h=a.get()||0;a.set(t[n]-xs(o,c,.5)+h)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!O0(n)||!r||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};yu(o=>{const c=this.getAxisMotionValue(o);if(c&&this.constraints!==!1){const h=c.get();i[o]=c1e({min:h,max:h},this.constraints[o])}});const{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.constraints=!1,this.resolveConstraints(),yu(o=>{if(!Wv(o,t,null))return;const c=this.getAxisMotionValue(o),{min:h,max:f}=this.constraints[o];c.set(xs(h,f,i[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;h1e.set(this.visualElement,this);const t=this.visualElement.current,n=H1(t,"pointerdown",f=>{const{drag:m,dragListener:y=!0}=this.getProps(),w=f.target,A=w!==t&&q0e(w);m&&y&&!A&&this.start(f)});let r;const i=()=>{const{dragConstraints:f}=this.getProps();O0(f)&&f.current&&(this.constraints=this.resolveRefConstraints(),r||(r=p1e(t,f.current,()=>this.scalePositionWithinConstraints())))},{projection:a}=this.visualElement,o=a.addEventListener("measure",i);a&&!a.layout&&(a.root&&a.root.updateScroll(),a.updateLayout()),ts.read(i);const c=xy(window,"resize",()=>this.scalePositionWithinConstraints()),h=a.addEventListener("didUpdate",(({delta:f,hasLayoutChanged:m})=>{this.isDragging&&m&&(yu(y=>{const w=this.getAxisMotionValue(y);w&&(this.originPoint[y]+=f[y].translate,w.set(w.get()+f[y].translate))}),this.visualElement.render())}));return()=>{c(),n(),o(),h&&h(),r&&r()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:i=!1,dragConstraints:a=!1,dragElastic:o=ej,dragMomentum:c=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:a,dragElastic:o,dragMomentum:c}}}function _M(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function p1e(e,t,n){const r=P8(e,_M(n)),i=P8(t,_M(n));return()=>{r(),i()}}function Wv(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function m1e(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class g1e extends jf{constructor(t){super(t),this.removeGroupControls=gc,this.removeListeners=gc,this.controls=new f1e(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||gc}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const I_=e=>(t,n)=>{e&&ts.update(()=>e(t,n),!1,!0)};class x1e extends jf{constructor(){super(...arguments),this.removePointerDownListener=gc}onPointerDown(t){this.session=new YW(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:KW(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:I_(t),onStart:I_(n),onMove:I_(r),onEnd:(a,o)=>{delete this.session,i&&ts.postRender(()=>i(a,o))}}}mount(){this.removePointerDownListener=H1(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let T_=!1;class y1e extends I.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:a}=t;a&&(n.group&&n.group.add(a),r&&r.register&&i&&r.register(a),T_&&a.root.didUpdate(),a.addEventListener("animationComplete",()=>{this.safeToRemove()}),a.setOptions({...a.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Kw.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:i,isPresent:a}=this.props,{projection:o}=r;return o&&(o.isPresent=a,t.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),T_=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==a?o.willUpdate():this.safeToRemove(),t.isPresent!==a&&(a?o.promote():o.relegate()||ts.postRender(()=>{const c=o.getStack();(!c||!c.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:r}=t;r&&(r.options.layoutAnchor=n,r.root.didUpdate(),i4.postRender(()=>{!r.currentAnimation&&r.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:i}=t;T_=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),r&&r.deregister&&r.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function QW(e){const[t,n]=BW(),r=I.useContext(BT);return s.jsx(y1e,{...e,layoutGroup:r,switchLayoutGroup:I.useContext(qW),isPresent:t,safeToRemove:n})}const b1e={pan:{Feature:x1e},drag:{Feature:g1e,ProjectionNode:UW,MeasureLayout:QW}};function kM(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,a=r[i];a&&ts.postRender(()=>a(t,nb(t)))}class v1e extends jf{mount(){const{current:t}=this.node;t&&(this.unmount=F0e(t,(n,r)=>(kM(this.node,r,"Start"),i=>kM(this.node,i,"End"))))}unmount(){}}class w1e extends jf{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Jy(xy(this.node.current,"focus",()=>this.onFocus()),xy(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function SM(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),a=r[i];a&&ts.postRender(()=>a(t,nb(t)))}class N1e extends jf{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:r}=this.node.props;this.unmount=K0e(t,(i,a)=>(SM(this.node,a,"Start"),(o,{success:c})=>SM(this.node,o,c?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(r==null?void 0:r.tap)===!1})}unmount(){}}const tj=new WeakMap,P_=new WeakMap,E1e=e=>{const t=tj.get(e.target);t&&t(e)},A1e=e=>{e.forEach(E1e)};function _1e({root:e,...t}){const n=e||document;P_.has(n)||P_.set(n,{});const r=P_.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(A1e,{root:e,...t})),r[i]}function k1e(e,t,n){const r=_1e(t);return tj.set(e,n),r.observe(e),()=>{tj.delete(e),r.unobserve(e)}}const S1e={some:0,all:1};class C1e extends jf{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var h;(h=this.stopObserver)==null||h.call(this);const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:i="some",once:a}=t,o={root:n?n.current:void 0,rootMargin:r,threshold:typeof i=="number"?i:S1e[i]},c=f=>{const{isIntersecting:m}=f;if(this.isInView===m||(this.isInView=m,a&&!m&&this.hasEnteredView))return;m&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",m);const{onViewportEnter:y,onViewportLeave:w}=this.node.getProps(),A=m?y:w;A&&A(f)};this.stopObserver=k1e(this.node.current,o,c)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(j1e(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function j1e({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const I1e={inView:{Feature:C1e},tap:{Feature:N1e},focus:{Feature:w1e},hover:{Feature:v1e}},T1e={layout:{ProjectionNode:UW,MeasureLayout:QW}},P1e={...t1e,...I1e,...b1e,...T1e},Zt=Xxe(P1e,Qxe),ZW=({isOpen:e,imagesList:t=[],initialIndex:n=0,imageUrl:r,title:i,onClose:a})=>{const[o,c]=I.useState(n),h=t.length>0?t:r?[r]:[];I.useEffect(()=>{e&&c(n)},[e,n]);const f=h[o]||r||"",m=async A=>{A.stopPropagation();try{ir.loading("Preparing image for download...",{id:"download-prep"});const S=`/api/proxy-image?url=${encodeURIComponent(f)}`,C=await fetch(S);if(!C.ok)throw new Error("Proxy image download failed");const T=await C.blob(),D=window.URL.createObjectURL(T),V=document.createElement("a");V.href=D,V.download=`${i.toLowerCase().replace(/[^a-z0-9]/g,"-")||"campus-eye-image"}-${o+1}.jpg`,document.body.appendChild(V),V.click(),document.body.removeChild(V),window.URL.revokeObjectURL(D),ir.success("Download started successfully!",{id:"download-prep"})}catch(S){console.warn("Proxy download failed, trying standard open in new tab...",S);try{const C=document.createElement("a");C.href=f,C.target="_blank",C.rel="noopener noreferrer",C.download=`${i||"image"}-${o+1}.jpg`,document.body.appendChild(C),C.click(),document.body.removeChild(C),ir.success("Opening original in new tab...",{id:"download-prep"})}catch{ir.error("Could not download image, please save manually.",{id:"download-prep"})}}},y=A=>{A==null||A.stopPropagation(),h.length>1&&c(S=>S===0?h.length-1:S-1)},w=A=>{A==null||A.stopPropagation(),h.length>1&&c(S=>S===h.length-1?0:S+1)};return I.useEffect(()=>{const A=S=>{e&&(S.key==="ArrowLeft"?y():S.key==="ArrowRight"?w():S.key==="Escape"&&a())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[e,h.length]),s.jsx(or,{children:e&&s.jsxs(Zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[5000] bg-black/95 backdrop-blur-xl flex flex-col justify-between p-4",onClick:a,children:[s.jsxs("div",{className:"w-full h-14 flex items-center justify-between px-2 max-w-7xl mx-auto z-50",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-400 truncate max-w-xs sm:max-w-md",children:["👁️ Photo Desk • ",i," ",h.length>1&&`(${o+1} of ${h.length})`]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("button",{onClick:m,className:"flex items-center gap-1.5 px-3 py-1.5 bg-white/10 hover:bg-white/25 active:bg-white/30 text-white border border-white/10 hover:border-white/20 rounded-full text-[10px] font-black uppercase tracking-widest transition-all cursor-pointer shadow-lg",title:"Download high resolution copy",children:[s.jsx(eE,{size:13}),s.jsx("span",{children:"Download"})]}),s.jsx("button",{onClick:A=>{A.stopPropagation(),a()},className:"w-9 h-9 bg-red-650 hover:bg-black text-white rounded-full flex items-center justify-center transition-all cursor-pointer shadow-lg border border-red-500/20",title:"Exit lightbox view",children:s.jsx(er,{size:16})})]})]}),s.jsxs("div",{className:"flex-1 flex items-center justify-center relative p-2 md:p-6 w-full max-w-5xl mx-auto select-none gap-4",children:[h.length>1&&s.jsx("button",{type:"button",onClick:y,className:"w-10 h-10 rounded-full bg-black/50 border border-white/15 hover:bg-white/20 hover:border-white/40 text-white flex items-center justify-center transition-all cursor-pointer hidden md:flex shrink-0",children:s.jsx(qp,{size:20})}),s.jsxs("div",{className:"relative flex-1 flex justify-center max-w-full",children:[s.jsx(Zt.img,{initial:{opacity:0,scale:.95,y:15},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:15},transition:{type:"spring",damping:25},src:f,alt:i,className:"max-w-full max-h-[75vh] object-contain rounded-xl shadow-2.5xl ring-1 ring-white/15 cursor-zoom-out",onClick:A=>{A.stopPropagation(),a()},referrerPolicy:"no-referrer"},o),h.length>1&&s.jsxs("div",{className:"absolute inset-y-0 inset-x-0 flex justify-between items-center pointer-events-none md:hidden",children:[s.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),y(A)},className:"w-12 h-12 rounded-r-full bg-black/40 text-white flex items-center justify-start pl-2 pointer-events-auto",children:s.jsx(qp,{size:18})}),s.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),w(A)},className:"w-12 h-12 rounded-l-full bg-black/40 text-white flex items-center justify-end pr-2 pointer-events-auto",children:s.jsx(Wp,{size:18})})]})]}),h.length>1&&s.jsx("button",{type:"button",onClick:w,className:"w-10 h-10 rounded-full bg-black/50 border border-white/15 hover:bg-white/20 hover:border-white/40 text-white flex items-center justify-center transition-all cursor-pointer hidden md:flex shrink-0",children:s.jsx(Wp,{size:20})})]}),s.jsx("div",{className:"w-full text-center py-4 z-50",children:s.jsx("p",{className:"text-[9px] font-medium text-gray-400 uppercase tracking-widest mb-1",children:h.length>1?"Use ← and → keys or tap arrows to navigate":"Click anywhere on the background or tap X to return"})})]})})},O1e=[{index:1,emoji:"🔥",label:"Lit"},{index:2,emoji:"🤯",label:"Shocked"},{index:3,emoji:"😢",label:"Sad"},{index:4,emoji:"👏",label:"Solid"},{index:5,emoji:"❤️",label:"Love"},{index:6,emoji:"😂",label:"Funny"},{index:7,emoji:"👍",label:"Like"}],Li=({src:e,alt:t="",className:n="",priority:r=!1,title:i="",fallbackInitial:a="",...o})=>{const[c,h]=I.useState(()=>r),[f,m]=I.useState(!1),[y,w]=I.useState(0),A=ie.useRef(null);I.useEffect(()=>{var D,V;m(!1),w(0),(D=A.current)!=null&&D.complete&&((V=A.current)==null?void 0:V.naturalWidth)!==0?h(!0):h(r)},[e,r]);const C=(a||i||t||"Campus").trim().charAt(0).toUpperCase()||"C",T=e?jpe(e,r?900:650,80):"";return s.jsxs("div",{className:Fe("relative overflow-hidden bg-gradient-to-br from-neutral-900 via-slate-900 to-indigo-950 flex items-center justify-center w-full h-full min-h-[50px] select-none",n),children:[(!c||f||!e)&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-2 z-10 pointer-events-none transition-opacity duration-300",children:[s.jsx("div",{className:"w-9 h-9 sm:w-11 sm:h-11 rounded-2xl bg-white/10 backdrop-blur-md border border-white/20 flex items-center justify-center text-white font-serif font-black text-lg sm:text-xl shadow-md",children:C}),(i||t)&&s.jsx("span",{className:"text-[8px] sm:text-[9px] font-bold text-gray-300 uppercase tracking-widest mt-1.5 px-3 text-center line-clamp-1 opacity-75 max-w-[85%]",children:i||t})]}),T&&!f&&s.jsx("img",{ref:A,src:T,alt:t||i,onLoad:()=>h(!0),onError:()=>{y<1?w(D=>D+1):(m(!0),h(!0))},loading:r?"eager":"lazy",decoding:"async",...r?{fetchPriority:"high"}:{},className:Fe("w-full h-full object-cover transition-all duration-500 transform-gpu relative z-20",c?"opacity-100 blur-none scale-100":"opacity-90 blur-[3px] scale-102"),referrerPolicy:"no-referrer",...o})]})},O_=({article:e,onClick:t,variant:n="social",onAuthorClick:r,priority:i=!1})=>{var Vt,St,tn;const[a,o]=I.useState(!1),[c,h]=I.useState([]),[f,m]=I.useState(""),[y,w]=I.useState(!1),[A,S]=I.useState(!1),[C,T]=I.useState(e.likeCount||0),[D,V]=I.useState(e.commentCount||0),[L,K]=I.useState(e.viewCount||0),[Z,q]=I.useState(e.saveCount||0),[B,z]=I.useState(e.shareCount||0),[F,$]=I.useState(!1),[Y,X]=I.useState(!1),[J,ye]=I.useState(null),[ne,de]=I.useState({}),[be,Ce]=I.useState(0),[Ke,G]=I.useState(!1),[se,xe]=I.useState(!1),[re,Me]=I.useState(null),nt=[e.featuredImageUrl,e.featuredImageUrl1,e.featuredImageUrl2].filter(Boolean);I.useEffect(()=>{T(e.likeCount||0),V(e.commentCount||0),K(e.viewCount||0),q(e.saveCount||0),z(e.shareCount||0);const Pt={};for(let Nt=1;Nt<=7;Nt++){const Kt=`reaction${Nt}`;e[Kt]&&(Pt[`reaction${Nt}`]=e[Kt])}if(de(Pt),Ne.currentUser){const Nt=`reacted_${e.id}_${Ne.currentUser.uid}`,Kt=localStorage.getItem(Nt);ye(Kt?parseInt(Kt):null)}},[e,Ne.currentUser]);const ze=async Pt=>{if(!Ne.currentUser){ir.error("Please login to react to this story"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{ze(Pt)});return}const Nt=Je(he,"articles",e.id),Kt=`reacted_${e.id}_${Ne.currentUser.uid}`,ut=localStorage.getItem(Kt),Jt=ut?parseInt(ut):null;try{const Dt={},hn=["🔥","🤯","😢","👏","❤️","😂","👍"],qn=hn[Pt-1];Jt===Pt?(Dt[`reaction${Pt}.count`]=Ir(-1),Dt[`reaction${Pt}.emoji`]=qn,localStorage.removeItem(Kt),ye(null)):(Jt!==null&&(Dt[`reaction${Jt}.count`]=Ir(-1),Dt[`reaction${Jt}.emoji`]=hn[Jt-1]),Dt[`reaction${Pt}.count`]=Ir(1),Dt[`reaction${Pt}.emoji`]=qn,localStorage.setItem(Kt,Pt.toString()),ye(Pt)),await Cn(Nt,Dt),ir.success("Reaction updated!")}catch(Dt){console.error("Error updating reaction:",Dt)}};I.useEffect(()=>{if(Ne.currentUser){const Pt=`liked_${e.id}_${Ne.currentUser.uid}`,Nt=localStorage.getItem(Pt);if(Nt!==null)w(Nt==="true");else{const ut=Je(he,"articles",e.id,"likes",Ne.currentUser.uid);cs(ut).then(Jt=>{const Dt=Jt.exists();w(Dt);try{localStorage.setItem(Pt,Dt?"true":"false")}catch{}}).catch(()=>{})}const Kt=`saved_${e.id}_${Ne.currentUser.uid}`;S(localStorage.getItem(Kt)==="true")}},[e.id,Ne.currentUser]),I.useEffect(()=>{if(!a)return;const Pt=Qt(et(he,"articles",e.id,"comments"),ui("createdAt","desc"),vi(20)),Nt=Wr(Pt,Kt=>{const ut=Kt.docs.map(Jt=>({id:Jt.id,...Jt.data()}));h(ut),ut.length>0&&V(ut.length)},Kt=>{console.warn("Silent ignored comments fetch error for article",Kt)});return()=>Nt()},[e.id,a]);const Tt=async Pt=>{if(Pt.stopPropagation(),!Ne.currentUser){ir.error("Please sign in to solidarily support this dispatch!"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{Tt({stopPropagation:()=>{}})});return}const Nt=Je(he,"articles",e.id,"likes",Ne.currentUser.uid),Kt=Je(he,"articles",e.id),ut=`liked_${e.id}_${Ne.currentUser.uid}`;try{if(y){w(!1),T(Jt=>Math.max(0,Jt-1));try{localStorage.setItem(ut,"false")}catch{}await si(Nt),await Cn(Kt,{likeCount:Ir(-1)})}else{w(!0),T(Jt=>Jt+1);try{localStorage.setItem(ut,"true")}catch{}await Rr(Nt,{userId:Ne.currentUser.uid,createdAt:En()}),await Cn(Kt,{likeCount:Ir(1)}),ir.success("Solidarity registered!")}}catch(Jt){console.error("Error liking article:",Jt)}},It=async Pt=>{if(Pt.stopPropagation(),!Ne.currentUser){ir.error("Please sign in to bookmark dispatches!"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{It({stopPropagation:()=>{}})});return}const Nt=Je(he,"articles",e.id),Kt=`saved_${e.id}_${Ne.currentUser.uid}`,ut=A;try{ut?(S(!1),q(Jt=>Math.max(0,Jt-1)),localStorage.removeItem(Kt),await Cn(Nt,{saveCount:Ir(-1)}),ir.success("Successfully unbookmarked")):(S(!0),q(Jt=>Jt+1),localStorage.setItem(Kt,"true"),await Cn(Nt,{saveCount:Ir(1)}),ir.success("Secured in Bookmarks!"))}catch(Jt){console.error("Error saving article:",Jt)}},ft=async Pt=>{Pt.stopPropagation();const Nt=e.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),Kt=`${window.location.origin}/articles=${Nt}/${e.id}`,ut=e.title,Jt=e.summary||(e.content?e.content.substring(0,140)+"...":""),Dt=`${e.title} ${Jt} Read More: ${Kt}`,hn=[e.featuredImageUrl,e.featuredImageUrl1,e.featuredImageUrl2,e.imageUrl].find(mn=>mn&&typeof mn=="string"&&!mn.startsWith("data:")&&mn.length>5)||"";try{fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:Kt,title:ut,image:hn})}).catch(()=>{})}catch{}let qn=!1;if(navigator.share)try{const mn={title:ut,text:`${e.title} ${Jt}`,url:Kt};await navigator.share(mn),qn=!0;const vr=Je(he,"articles",e.id);await Cn(vr,{shareCount:Ir(1)}).catch(()=>{});return}catch(mn){console.warn("Shared sheet native cancel or fail:",mn)}if(!qn){try{await Md(Dt);const mn=Je(he,"articles",e.id);await Cn(mn,{shareCount:Ir(1)}).catch(()=>{})}catch{}xe(!0)}},Ee=async Pt=>{var Nt,Kt;if(Pt.preventDefault(),!!f.trim()){if(!Ne.currentUser){ir.error("Please sign in to publish your thoughts."),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{Ee({preventDefault:()=>{}})});return}$(!0);try{const ut=re?re.parentId||re.id:null,Jt=re?re.authorName:null,Dt={content:f,userId:Ne.currentUser.uid,authorName:Ne.currentUser.displayName||"Campus Member",photoURL:Ne.currentUser.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Ne.currentUser.displayName||"Member")}`,createdAt:new Date,parentId:ut,replyToAuthor:Jt},hn=await ur(et(he,"articles",e.id,"comments"),{content:f,userId:Ne.currentUser.uid,authorName:Ne.currentUser.displayName||"Campus Member",photoURL:Ne.currentUser.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Ne.currentUser.displayName||"Member")}`,createdAt:En(),parentId:ut,replyToAuthor:Jt});h(vr=>[{id:hn.id,...Dt},...vr]),V(vr=>vr+1);const qn=Je(he,"articles",e.id);await Cn(qn,{commentCount:Ir(1)});const mn=f;m(""),Me(null),ir.success("Thought dispatched!"),/@(mega\s*(ai)?|me)\b/i.test(mn)&&M2(mn,((Nt=Ne.currentUser)==null?void 0:Nt.displayName)||"Campus Member",((Kt=Ne.currentUser)==null?void 0:Kt.uid)||"guest",{type:"article_comment",articleId:e.id}).then(async vr=>{var Ve;if(vr){const Mt=await ur(et(he,"articles",e.id,"comments"),{content:vr,userId:"mega-ai-bot",authorName:"Mega AI 🤖",photoURL:zo,createdAt:En(),parentId:ut,replyToAuthor:((Ve=Ne.currentUser)==null?void 0:Ve.displayName)||"Campus Member"});h(cn=>{var dn;return[...cn,{id:Mt.id,content:vr,userId:"mega-ai-bot",authorName:"Mega AI 🤖",photoURL:zo,createdAt:new Date,parentId:ut,replyToAuthor:((dn=Ne.currentUser)==null?void 0:dn.displayName)||"Campus Member"}]}),V(cn=>cn+1),await Cn(Je(he,"articles",e.id),{commentCount:Ir(1)}),ir.success("Mega AI auto-replied to your commentary!",{icon:"✨"})}}).catch(vr=>console.error("Mega AI auto reply error:",vr))}catch(ut){console.error("Comment submission error:",ut)}finally{$(!1)}}},yt=()=>{var ut,Jt,Dt;const Pt=e.isSponsoredAd||((ut=e.category)==null?void 0:ut.toLowerCase().includes("ad"))||((Jt=e.category)==null?void 0:Jt.toLowerCase().includes("sponsor"))||((Dt=e.category)==null?void 0:Dt.toLowerCase().includes("promote")),Nt=[];if(e.featuredImageUrl&&Nt.push(e.featuredImageUrl),e.featuredImageUrl1&&Nt.push(e.featuredImageUrl1),e.featuredImageUrl2&&Nt.push(e.featuredImageUrl2),Nt.length===0)return null;const Kt=Pt&&s.jsx("div",{className:"absolute top-2.5 left-2.5 bg-black/85 backdrop-blur-md text-[#FF2D55] text-[7.5px] font-black uppercase tracking-widest px-3 py-1 rounded-md border border-red-500/20 flex items-center gap-1 z-10 pointer-events-none shadow-lg",children:"📢 SPONSORED AD"});return Nt.length===3?s.jsxs("div",{className:"relative group/ad w-full select-none",onClick:hn=>hn.stopPropagation(),children:[Kt,s.jsxs("div",{className:"flex gap-1 rounded-2xl overflow-hidden border border-gray-150 aspect-[16/10] w-full bg-gray-50",children:[s.jsx("div",{onClick:hn=>{hn.preventDefault(),Ce(0),G(!0)},className:"w-[60%] overflow-hidden relative group/img cursor-pointer h-full",children:s.jsx(Li,{src:Nt[0],alt:"Support View 1",priority:i,className:"w-full h-full object-cover transition-transform duration-500 hover:scale-[1.03]"})}),s.jsxs("div",{className:"w-[40%] flex flex-col gap-1 h-full",children:[s.jsx("div",{onClick:hn=>{hn.preventDefault(),Ce(1),G(!0)},className:"h-[calc(50%-2px)] overflow-hidden relative group/img cursor-pointer",children:s.jsx(Li,{src:Nt[1],alt:"Support View 2",priority:i,className:"w-full h-full object-cover transition-transform duration-500 hover:scale-[1.03]"})}),s.jsx("div",{onClick:hn=>{hn.preventDefault(),Ce(2),G(!0)},className:"h-[calc(50%-2px)] overflow-hidden relative group/img cursor-pointer",children:s.jsx(Li,{src:Nt[2],alt:"Support View 3",priority:i,className:"w-full h-full object-cover transition-transform duration-500 hover:scale-[1.03]"})})]})]})]}):Nt.length===2?s.jsxs("div",{className:"relative group/ad w-full select-none",onClick:hn=>hn.stopPropagation(),children:[Kt,s.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-2xl overflow-hidden border border-gray-150 aspect-[16/10] sm:aspect-[16/9] w-full bg-gray-50",children:Nt.map((hn,qn)=>s.jsx("div",{className:"overflow-hidden relative group/img cursor-pointer h-full w-full",onClick:mn=>{mn.preventDefault(),Ce(qn),G(!0)},children:s.jsx(Li,{src:hn,alt:`Support View ${qn+1}`,priority:i,className:"w-full h-full object-cover transition-transform duration-500 hover:scale-[1.03]"})},qn))})]}):s.jsxs("div",{className:"relative group/ad w-full select-none",onClick:hn=>hn.stopPropagation(),children:[Kt,s.jsx("div",{onClick:hn=>{hn.preventDefault(),Ce(0),G(!0)},className:"rounded-xl overflow-hidden border border-gray-150/70 w-full bg-gray-50 flex items-center justify-center relative group/img cursor-pointer shadow-2xs",children:s.jsx(Li,{src:e.featuredImageUrl,alt:e.title,priority:i,className:"w-full h-auto max-h-[42rem] object-cover transition-transform duration-500 hover:scale-[1.02]"})})]})},Ue=Pt=>s.jsxs(s.Fragment,{children:[Pt,s.jsx(ZW,{isOpen:Ke,imagesList:nt,initialIndex:be,imageUrl:nt[be]||"",title:e.title,onClose:()=>G(!1)}),se&&s.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-md z-[200] flex items-end sm:items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200",onClick:Nt=>{Nt.stopPropagation(),xe(!1)},children:s.jsxs("div",{className:"bg-white/95 dark:bg-neutral-900/95 backdrop-blur-2xl border border-gray-200/80 dark:border-white/10 rounded-3xl p-5 sm:p-6 w-full max-w-sm shadow-2xl space-y-4 text-center relative animate-in slide-in-from-bottom-5 duration-200",onClick:Nt=>Nt.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 dark:border-neutral-800 pb-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-left",children:[s.jsx("div",{className:"p-2 bg-red-50 text-red-650 rounded-full",children:s.jsx(hf,{size:16})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-bold text-gray-900 dark:text-white",children:"Share Dispatch"}),s.jsx("p",{className:"text-[10px] text-gray-500 lowercase tracking-tight",children:"Choose your preferred social platform"})]})]}),s.jsx("button",{onClick:()=>xe(!1),className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-full transition-all cursor-pointer",children:s.jsx(er,{size:18})})]}),s.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-neutral-800/60 rounded-2xl border border-gray-100 dark:border-neutral-700/50 text-left space-y-1",children:[s.jsx("p",{className:"text-[11px] font-extrabold text-gray-900 dark:text-white line-clamp-1",children:e.title}),s.jsx("p",{className:"text-[9px] text-gray-500 font-mono truncate",children:`${window.location.origin}/article/${e.id}`})]}),s.jsxs("div",{className:"grid grid-cols-4 gap-2 pt-1",children:[s.jsxs("a",{href:`https://api.whatsapp.com/send?text=${encodeURIComponent(e.title+` Read more: ${window.location.origin}/article/${e.id}`)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>xe(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-emerald-50 text-emerald-700 rounded-2xl hover:bg-emerald-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"💬"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"WhatsApp"})]}),s.jsxs("a",{href:`https://twitter.com/intent/tweet?text=${encodeURIComponent(e.title)}&url=${encodeURIComponent(`${window.location.origin}/article/${e.id}`)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>xe(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-sky-50 text-sky-700 rounded-2xl hover:bg-sky-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"🐦"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Twitter/X"})]}),s.jsxs("a",{href:`https://t.me/share/url?url=${encodeURIComponent(`${window.location.origin}/article/${e.id}`)}&text=${encodeURIComponent(e.title)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>xe(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-blue-50 text-blue-700 rounded-2xl hover:bg-blue-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"✈️"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Telegram"})]}),s.jsxs("a",{href:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(`${window.location.origin}/article/${e.id}`)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>xe(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-indigo-50 text-indigo-700 rounded-2xl hover:bg-indigo-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"📘"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Facebook"})]})]}),s.jsx("div",{className:"pt-2",children:s.jsx("button",{onClick:async()=>{const Nt=`${window.location.origin}/article/${e.id}`;await Md(`${e.title} ${Nt}`),ir.success("Link copied to clipboard!"),xe(!1)},className:"w-full py-3 bg-red-650 hover:bg-red-700 text-white font-bold text-xs uppercase tracking-widest rounded-2xl transition-all shadow-md active:scale-98 flex items-center justify-center gap-2 cursor-pointer",children:s.jsx("span",{children:"Copy Direct Link"})})})]})})]});if(n==="social"){const Pt=Object.values(ne).filter(ut=>ut&&ut.count>0),Nt=Pt.reduce((ut,Jt)=>ut+Jt.count,0),Kt=e.isSponsoredAd||((Vt=e.category)==null?void 0:Vt.toLowerCase().includes("ad"))||((St=e.category)==null?void 0:St.toLowerCase().includes("sponsor"))||((tn=e.category)==null?void 0:tn.toLowerCase().includes("promote"));return Ue(s.jsx("div",{className:Fe("border-b border-gray-100 p-2 sm:p-4 md:p-6 text-left hover:bg-gray-50/50 transition-colors duration-300",Kt?"bg-amber-50/20 border-l-4 border-l-amber-500":"bg-white"),children:s.jsxs("div",{className:"flex gap-3 md:gap-4",children:[s.jsx("div",{onClick:ut=>{r&&e.authorId&&(ut.stopPropagation(),r(e.authorId))},onMouseEnter:ut=>{r&&e.authorId&&window.matchMedia("(min-width: 1024px)").matches&&r(e.authorId)},className:Fe("w-8 h-8 md:w-9 md:h-9 rounded-full overflow-hidden border border-gray-150 shrink-0",r&&"cursor-pointer hover:opacity-80 hover:scale-105 active:scale-95 transition-all"),title:"Click or hover to view peer credentials",children:s.jsx(Li,{src:e.authorProfile||`https://ui-avatars.com/api/?name=${encodeURIComponent(e.authorName)}&background=random`,className:"w-full h-full object-cover",alt:e.authorName})}),s.jsxs("div",{className:"flex-1 space-y-2.5 min-w-0",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-wrap",children:[s.jsx("span",{className:"text-gray-400 font-bold text-xs",children:"@"}),s.jsx("span",{className:Fe("font-bold text-xs text-black hover:underline cursor-pointer tracking-tight",r?"hover:text-red-650":""),onClick:ut=>{r&&e.authorId?(ut.stopPropagation(),r(e.authorId)):t(e)},onMouseEnter:ut=>{r&&e.authorId&&window.matchMedia("(min-width: 1024px)").matches&&r(e.authorId)},title:"Click or hover to view peer credentials",children:e.authorName&&e.authorName.includes("@")?e.authorName.split("@")[0]:e.authorName}),s.jsx(Fo,{size:12,className:"shrink-0"}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400",children:"•"}),s.jsx("span",{className:Fe("text-[8px] font-black tracking-[0.14em] uppercase shrink-0",Kt?"text-amber-600 bg-amber-50 px-1.5 py-0.5 rounded border border-amber-200":"text-red-650"),children:Kt?"SPONSORED PROMO":e.category}),e.publishDate&&s.jsxs("span",{className:"text-[9.5px] font-bold text-gray-500 font-mono flex items-center gap-1 shrink-0 bg-gray-50 px-1.5 py-0.5 rounded border border-gray-150",children:[s.jsx(rg,{size:10,className:"text-red-600"}),s.jsx("span",{children:X0(e.publishDate)})]}),e.isOfflineCached&&s.jsx("span",{className:"text-teal-600 bg-teal-50 p-1 rounded-full border border-teal-200 shrink-0 flex items-center justify-center cursor-help",title:"Offline Cached",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"shrink-0 w-3 h-3",children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"currentColor",d:"M12.05 20q-3.35 0-5.7-2.325T4 12v-.175l-1.6 1.6l-1.4-1.4l4-4l4 4l-1.4 1.4l-1.6-1.6V12q0 2.5 1.763 4.25T12.05 18q.65 0 1.275-.15t1.225-.45l1.5 1.5q-.95.55-1.95.825T12.05 20M19 15.975l-4-4l1.4-1.4l1.6 1.6V12q0-2.5-1.763-4.25T11.95 6q-.65 0-1.275.15T9.45 6.6l-1.5-1.5q.95-.55 1.95-.825T11.95 4q3.35 0 5.7 2.325T20 12v.175l1.6-1.6l1.4 1.4z"})]})})]})}),s.jsx("h4",{onClick:()=>t(e),className:"text-base md:text-lg font-black text-black hover:text-red-600 transition-colors tracking-tight leading-snug cursor-pointer select-none line-clamp-2 underline underline-offset-2 decoration-1 hover:decoration-2",children:M0(e.title)}),s.jsxs("div",{className:"text-[13px] md:text-sm text-gray-800 leading-relaxed font-sans text-left speak-normal hyphens-auto",children:[s.jsxs("span",{children:[(e.summary||e.content).substring(0,80),"..."]}),s.jsx("button",{onClick:()=>t(e),className:"text-red-600 hover:text-red-700 font-extrabold ml-1.5 hover:underline text-[11px] uppercase inline-block font-sans",children:"Read More"})]}),(e.ctaUrl||e.Links&&e.Links.trim())&&s.jsx("div",{className:"pt-1 text-left",children:s.jsxs("button",{onClick:ut=>{ut.stopPropagation();const Jt=e.ctaUrl||e.Links.trim();window.open(Jt,"_blank","noopener,noreferrer")},className:"inline-flex items-center gap-1.5 px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-[9.5px] font-black uppercase tracking-wider rounded-lg transition-all active:scale-95 shadow-xs cursor-pointer select-none mt-1",children:[s.jsx("span",{children:e.ctaText||"Discover More"}),s.jsx($a,{size:10,strokeWidth:3})]})}),yt(),s.jsxs("div",{className:"relative overflow-hidden w-full rounded-2xl sm:rounded-full bg-gradient-to-r from-blue-50/60 via-white/80 to-blue-50/50 dark:from-neutral-900/70 dark:via-neutral-800/70 dark:to-neutral-900/70 backdrop-blur-xl backdrop-saturate-150 border border-white/90 dark:border-white/10 shadow-[0_4px_24px_rgba(0,0,0,0.04),inset_0_1px_2px_rgba(255,255,255,0.9)] p-1.5 sm:p-2 mt-4 select-none",children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/70 via-transparent to-white/20 dark:from-white/10 pointer-events-none rounded-2xl sm:rounded-full"}),s.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-1 sm:gap-2 px-1 text-gray-700 dark:text-gray-200",children:[s.jsxs("button",{onClick:ut=>{ut.stopPropagation(),o(!a)},className:Fe("flex items-center gap-1.5 sm:gap-2 px-2.5 sm:px-3.5 py-1.5 rounded-full transition-all duration-300 hover:scale-105 active:scale-95 cursor-pointer backdrop-blur-md shadow-2xs hover:shadow-xs",a?"bg-blue-600 text-white font-extrabold shadow-sm shadow-blue-500/25":"bg-white/75 hover:bg-white dark:bg-white/10 dark:hover:bg-white/20 text-gray-800 dark:text-gray-100 hover:text-blue-600 border border-white/80 dark:border-white/10"),title:"Comments",children:[s.jsx("div",{className:"flex items-center justify-center transition-transform group-hover:scale-110 shrink-0",children:s.jsx(jC,{size:21,className:a?"fill-white text-white":""})}),s.jsx("span",{className:"text-xs sm:text-[13px] font-black tracking-tight",children:fl(D)})]}),s.jsxs("div",{className:"relative flex items-center gap-1",children:[s.jsxs("button",{onClick:Tt,className:Fe("flex items-center gap-1.5 sm:gap-2 px-2.5 sm:px-3.5 py-1.5 rounded-full transition-all duration-300 hover:scale-105 active:scale-95 cursor-pointer backdrop-blur-md shadow-2xs hover:shadow-xs",y?"bg-blue-600 text-white font-extrabold shadow-sm shadow-blue-500/25":"bg-white/75 hover:bg-white dark:bg-white/10 dark:hover:bg-white/20 text-gray-800 dark:text-gray-100 hover:text-blue-600 border border-white/80 dark:border-white/10"),title:"Solidarity support",children:[s.jsx("div",{className:"flex items-center justify-center transition-transform group-hover:scale-110 shrink-0",children:s.jsx(uq,{size:21,className:y?"fill-white text-white":""})}),s.jsx("span",{className:"text-xs sm:text-[13px] font-black tracking-tight",children:fl(C)})]}),Pt.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5 bg-white/85 dark:bg-white/15 backdrop-blur-md px-2 py-0.5 rounded-full border border-white/80 dark:border-white/10 text-[10px] text-gray-750 font-bold shrink-0 select-none shadow-2xs",children:[s.jsx("span",{className:"flex -space-x-1 font-sans",children:Pt.slice(0,3).map((ut,Jt)=>s.jsx("span",{className:"scale-95",children:ut.emoji},Jt))}),s.jsx("span",{className:"ml-1 text-[9px] font-black",children:Nt})]}),s.jsx(or,{children:Y&&s.jsx(Zt.div,{initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:"absolute bottom-12 left-0 bg-white/95 backdrop-blur-2xl border border-white/90 p-2 shadow-2xl flex gap-1.5 z-50 rounded-full",onClick:ut=>ut.stopPropagation(),children:O1e.map(ut=>s.jsx("button",{onClick:()=>{ze(ut.index),X(!1)},className:Fe("w-8 h-8 rounded-full flex items-center justify-center hover:scale-125 hover:bg-blue-50 transition-all text-base",J===ut.index&&"bg-blue-100 text-lg"),title:ut.label,children:ut.emoji},ut.index))})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-2.5 sm:px-3.5 py-1.5 rounded-full bg-white/55 dark:bg-white/10 backdrop-blur-md border border-white/70 dark:border-white/10 shadow-2xs",title:"Views",children:[s.jsx("div",{className:"flex items-center justify-center shrink-0",children:s.jsx(IC,{size:21})}),s.jsx("span",{className:"text-xs sm:text-[13px] font-black text-gray-800 dark:text-gray-100 tracking-tight",children:fl(L)})]}),s.jsxs("button",{onClick:It,className:Fe("flex items-center gap-1.5 sm:gap-2 px-2.5 sm:px-3.5 py-1.5 rounded-full transition-all duration-300 hover:scale-105 active:scale-95 cursor-pointer backdrop-blur-md shadow-2xs hover:shadow-xs",A?"bg-amber-500 text-white font-extrabold shadow-sm shadow-amber-500/25":"bg-white/75 hover:bg-white dark:bg-white/10 dark:hover:bg-white/20 text-gray-800 dark:text-gray-100 hover:text-amber-500 border border-white/80 dark:border-white/10"),title:"Bookmark",children:[s.jsx("div",{className:"flex items-center justify-center transition-transform group-hover:scale-110 shrink-0",children:s.jsx(dq,{size:20,className:A?"fill-white text-white":""})}),s.jsx("span",{className:"text-xs sm:text-[13px] font-black tracking-tight",children:fl(Z)})]}),s.jsxs("button",{onClick:ft,className:"flex items-center gap-1.5 sm:gap-2 px-2.5 sm:px-3.5 py-1.5 rounded-full transition-all duration-300 hover:scale-105 active:scale-95 cursor-pointer backdrop-blur-md bg-white/75 hover:bg-white dark:bg-white/10 dark:hover:bg-white/20 text-gray-800 dark:text-gray-100 hover:text-green-600 border border-white/80 dark:border-white/10 shadow-2xs hover:shadow-xs",title:"Share",children:[s.jsx("div",{className:"flex items-center justify-center transition-transform group-hover:scale-110 shrink-0",children:s.jsx(Bw,{size:21})}),s.jsx("span",{className:"text-xs sm:text-[13px] font-black tracking-tight",children:fl(B)})]})]})]}),s.jsx(or,{children:a&&s.jsxs(Zt.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"w-full bg-[#0f1419] text-white p-3.5 sm:p-4 rounded-2xl border border-gray-800 shadow-lg text-left overflow-hidden break-words min-w-0 mt-3",onClick:ut=>ut.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-1.5 h-3.5 bg-indigo-500 rounded-full"}),s.jsxs("span",{className:"text-[10px] font-black tracking-widest text-gray-200 uppercase",children:["Comments (",c.length,")"]})]}),s.jsx("button",{onClick:()=>o(!1),className:"text-gray-400 hover:text-white text-xs font-bold px-2 py-0.5 rounded-full hover:bg-gray-800",children:"✕"})]}),s.jsxs("form",{onSubmit:Ee,className:"space-y-2 mb-4",children:[re&&s.jsxs("div",{className:"flex items-center justify-between bg-indigo-950/80 border border-indigo-500/40 px-3 py-1.5 rounded-xl text-xs text-indigo-200 font-bold animate-fade-in",children:[s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx("span",{className:"uppercase text-[9px] font-black tracking-widest text-indigo-400 shrink-0",children:"Replying to"}),s.jsxs("span",{className:"font-extrabold font-mono text-white text-[11px] truncate",children:["@",re.authorName]})]}),s.jsx("button",{type:"button",onClick:()=>Me(null),className:"text-gray-400 hover:text-red-400 font-extrabold text-xs px-1 rounded cursor-pointer shrink-0 ml-2",title:"Cancel reply",children:"✕"})]}),s.jsxs("div",{className:"flex gap-2 bg-[#15181c] border border-gray-800 rounded-full p-1 pl-4 items-center focus-within:border-indigo-500/50 transition-all",children:[s.jsx("input",{type:"text",placeholder:re?`Replying to @${re.authorName}...`:"Type comment or mention @Mega AI...",value:f,onChange:ut=>m(ut.target.value),className:"flex-1 bg-transparent text-white text-xs outline-none focus:outline-none placeholder-gray-500 border-none py-1.5 focus:ring-0"}),s.jsx("button",{type:"submit",disabled:F||!f.trim(),className:"bg-indigo-600 hover:bg-indigo-700 disabled:opacity-40 text-white font-extrabold uppercase px-3 h-7 rounded-full text-[9px] tracking-wider transition-colors shrink-0 cursor-pointer",children:"Reply"})]}),s.jsx("div",{className:"flex items-center gap-1.5 px-1",children:s.jsxs("button",{type:"button",onClick:()=>{f.includes("@Mega AI")||m(ut=>(ut.trim()+" @Mega AI ").trimStart())},className:"text-[9px] font-black uppercase tracking-wider text-amber-400 bg-amber-500/10 hover:bg-amber-500/20 border border-amber-500/30 px-2 py-0.5 rounded-full flex items-center gap-1 transition-all cursor-pointer",children:[s.jsx(Zi,{size:10,className:"text-amber-400"})," Mention @Mega AI"]})})]}),s.jsx("div",{className:"space-y-4 max-h-72 overflow-y-auto pr-1",children:c.length>0?(()=>{const ut=hn=>({A:"bg-red-500",B:"bg-pink-500",C:"bg-purple-500",D:"bg-indigo-500",E:"bg-blue-500",F:"bg-cyan-500",G:"bg-teal-500",H:"bg-emerald-500",I:"bg-green-500",J:"bg-yellow-500",K:"bg-amber-500",L:"bg-orange-500",M:"bg-rose-500",N:"bg-red-600",O:"bg-indigo-600",P:"bg-purple-600",Q:"bg-pink-600",R:"bg-blue-600",S:"bg-violet-600",T:"bg-rose-600",U:"bg-teal-600",V:"bg-emerald-600",W:"bg-indigo-700",X:"bg-purple-700",Y:"bg-sky-500",Z:"bg-fuchsia-600"})[hn]||"bg-slate-600",Jt=async(hn,qn)=>{if(!Ne.currentUser)return;const mn=Je(he,"articles",e.id,"comments",hn),vr=`liked_comment_${hn}_${Ne.currentUser.uid}`;localStorage.getItem(vr)==="true"?(await Cn(mn,{likeCount:Ir(-1)}),localStorage.removeItem(vr)):(await Cn(mn,{likeCount:Ir(1)}),localStorage.setItem(vr,"true"))};return c.filter(hn=>!hn.parentId).map(hn=>{const qn=hn.authorName?hn.authorName.charAt(0).toUpperCase():"?",mn=Ne.currentUser?localStorage.getItem(`liked_comment_${hn.id}_${Ne.currentUser.uid}`)==="true":!1,vr=c.filter(Ve=>Ve.parentId===hn.id);return s.jsxs("div",{className:"border-b border-gray-800/80 pb-3 last:border-0 last:pb-0 text-left animate-fade-in",children:[s.jsxs("div",{className:"flex gap-2.5 text-xs",children:[hn.photoURL?s.jsx(Li,{src:hn.photoURL,className:"w-7 h-7 rounded-full border border-gray-800 object-cover shrink-0 mt-0.5",alt:""}):s.jsx("div",{className:Fe("w-7 h-7 rounded-full flex items-center justify-center text-white font-extrabold text-[10px] uppercase shrink-0 shadow-md",ut(qn)),children:qn}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx("span",{className:"font-extrabold text-[#cbd5e1] text-[11px] truncate",children:hn.authorName}),hn.userId==="mega-ai-bot"&&s.jsx("span",{className:"text-[8px] bg-indigo-500/20 text-indigo-300 px-1.5 py-0.5 rounded-full font-black uppercase tracking-wider border border-indigo-500/30",children:"AI"})]}),s.jsxs("button",{type:"button",onClick:Ve=>{Ve.stopPropagation(),Jt(hn.id,hn.likeCount||0)},className:Fe("flex items-center gap-1 p-0.5 text-gray-400 hover:text-red-500 transition-all cursor-pointer shrink-0 ml-2",mn&&"text-red-500"),children:[s.jsx("span",{className:"text-[9px] text-gray-400",children:(hn.likeCount||0)>0?fl(hn.likeCount):""}),s.jsx(mc,{size:12,className:Fe("transition-transform hover:scale-110",mn?"fill-red-500 text-red-500 ":"text-gray-500")})]})]}),s.jsx("div",{className:"text-gray-200 font-sans leading-relaxed text-[11px] mt-0.5 text-left break-words",children:L2(hn.content)}),s.jsx("div",{className:"flex items-center gap-3 mt-1.5",children:s.jsxs("button",{type:"button",onClick:()=>Me({id:hn.id,parentId:hn.id,authorName:hn.authorName}),className:"text-[9.5px] font-black text-indigo-400 hover:text-indigo-300 uppercase tracking-wider cursor-pointer hover:underline flex items-center gap-1",children:[s.jsx(nR,{size:10}),s.jsx("span",{children:"Reply"})]})})]})]}),vr.length>0&&s.jsx("div",{className:"ml-4 pl-3 border-l-2 border-indigo-500/30 space-y-2.5 mt-2.5",children:vr.map(Ve=>{const Mt=Ve.authorName?Ve.authorName.charAt(0).toUpperCase():"?",cn=Ne.currentUser?localStorage.getItem(`liked_comment_${Ve.id}_${Ne.currentUser.uid}`)==="true":!1;return s.jsxs("div",{className:"flex gap-2 text-xs text-left bg-indigo-950/20 p-2 rounded-xl border border-indigo-900/30",children:[Ve.photoURL?s.jsx(Li,{src:Ve.photoURL,className:"w-5.5 h-5.5 rounded-full border border-gray-800 object-cover shrink-0 mt-0.5",alt:""}):s.jsx("div",{className:Fe("w-5.5 h-5.5 rounded-full flex items-center justify-center text-white font-extrabold text-[9px] uppercase shrink-0 shadow-md",ut(Mt)),children:Mt}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap truncate",children:[s.jsx("span",{className:"font-extrabold text-[#e2e8f0] text-[10px] truncate",children:Ve.authorName}),Ve.replyToAuthor&&s.jsxs("span",{className:"text-[8.5px] text-indigo-300 font-mono font-bold",children:["replying to @",Ve.replyToAuthor]})]}),s.jsxs("button",{type:"button",onClick:dn=>{dn.stopPropagation(),Jt(Ve.id,Ve.likeCount||0)},className:Fe("flex items-center gap-1 p-0.5 text-gray-400 hover:text-red-500 transition-all cursor-pointer shrink-0 ml-1",cn&&"text-red-500"),children:[s.jsx("span",{className:"text-[8.5px] text-gray-400",children:(Ve.likeCount||0)>0?fl(Ve.likeCount):""}),s.jsx(mc,{size:10,className:Fe(cn?"fill-red-500 text-red-500":"text-gray-500")})]})]}),s.jsx("div",{className:"text-gray-200 font-sans leading-relaxed text-[10.5px] mt-0.5 break-words",children:L2(Ve.content)}),s.jsx("div",{className:"flex items-center gap-3 mt-1",children:s.jsxs("button",{type:"button",onClick:()=>Me({id:Ve.id,parentId:hn.id,authorName:Ve.authorName}),className:"text-[8.5px] font-black text-indigo-400 hover:text-indigo-300 uppercase tracking-wider cursor-pointer hover:underline flex items-center gap-0.5",children:[s.jsx(nR,{size:9}),s.jsx("span",{children:"Reply"})]})})]})]},Ve.id)})})]},hn.id)})})():s.jsx("p",{className:"text-[10px] text-gray-500 font-bold uppercase italic py-4 text-center",children:"No commentary yet. Let's talk about it!"})})]})})]})]})}))}return Ue(n==="big"||n==="featured"?s.jsxs("div",{onClick:()=>t(e),className:"group cursor-pointer bg-white border border-gray-100 hover:shadow-xl transition-all duration-300 overflow-hidden flex flex-col text-left",children:[s.jsxs("div",{className:"relative aspect-[16/9] md:aspect-[21/10] overflow-hidden bg-gray-950",children:[s.jsx(Li,{src:e.featuredImageUrl,className:"w-full h-full object-cover transition-all duration-[4000ms] group-hover:scale-105",alt:e.title}),s.jsxs("div",{className:"absolute top-4 left-4 flex gap-1.5",children:[s.jsx("span",{className:"bg-red-600 text-white px-3 py-1.5 text-[9px] font-black uppercase tracking-widest shadow-lg",children:e.category}),e.isOfflineCached&&s.jsx("span",{className:"bg-teal-600 text-white p-2.5 shadow-lg flex items-center justify-center cursor-help",title:"Offline Cached",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"shrink-0 w-3.5 h-3.5",children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"currentColor",d:"M12.05 20q-3.35 0-5.7-2.325T4 12v-.175l-1.6 1.6l-1.4-1.4l4-4l4 4l-1.4 1.4l-1.6-1.6V12q0 2.5 1.763 4.25T12.05 18q.65 0 1.275-.15t1.225-.45l1.5 1.5q-.95.55-1.95.825T12.05 20M19 15.975l-4-4l1.4-1.4l1.6 1.6V12q0-2.5-1.763-4.25T11.95 6q-.65 0-1.275.15T9.45 6.6l-1.5-1.5q.95-.55 1.95-.825T11.95 4q3.35 0 5.7 2.325T20 12v.175l1.6-1.6l1.4 1.4z"})]})})]})]}),s.jsxs("div",{className:"p-6 md:p-8 space-y-4",children:[s.jsx("h3",{className:"text-xl md:text-3xl font-serif font-black tracking-tight leading-tight text-black group-hover:text-red-650 transition-colors italic underline underline-offset-4 decoration-2",children:M0(e.title)}),s.jsx("p",{className:"text-sm border-l-2 border-red-500 pl-4 font-serif text-gray-750 italic",children:e.summary}),s.jsx("p",{className:"text-xs text-gray-650 leading-relaxed font-sans line-clamp-3",children:e.content}),s.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-100 flex-wrap gap-2",children:[s.jsxs("div",{onClick:Pt=>{r&&e.authorId&&(Pt.stopPropagation(),r(e.authorId))},onMouseEnter:Pt=>{r&&e.authorId&&window.matchMedia("(min-width: 1024px)").matches&&r(e.authorId)},className:Fe("flex items-center gap-2 select-none",r&&"cursor-pointer hover:opacity-80 hover:scale-103 active:scale-97 transition-all"),title:"Click or hover to view peer credentials",children:[s.jsx(Li,{src:e.authorProfile||`https://ui-avatars.com/api/?name=${encodeURIComponent(e.authorName)}&background=random`,className:"w-6 h-6 rounded-full border border-gray-200 shrink-0",alt:e.authorName}),s.jsxs("span",{className:"text-[9px] font-black uppercase text-black hover:underline",children:["By ",e.authorName&&e.authorName.includes("@")?e.authorName.split("@")[0]:e.authorName]}),e.publishDate&&s.jsxs("span",{className:"text-[9px] font-bold text-gray-500 font-mono flex items-center gap-1 shrink-0 ml-1",children:[s.jsx(rg,{size:10,className:"text-red-600"}),s.jsx("span",{children:Cpe(e.publishDate)})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[e.Links&&e.Links.trim()&&s.jsxs("button",{onClick:Pt=>{Pt.stopPropagation(),window.open(e.Links.trim(),"_blank","noopener,noreferrer")},className:"inline-flex items-center gap-1.5 px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-[9.5px] font-black uppercase tracking-wider rounded-lg transition-all active:scale-95 shadow-xs cursor-pointer select-none",children:[s.jsx("span",{children:e.ctaText||"Discover More"}),s.jsx($a,{size:10,strokeWidth:3})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-red-600 font-bold tracking-widest text-[9px] uppercase hover:underline",children:["Read dispatch ",s.jsx(Op,{size:11})]})]})]})]})]}):n==="magazine"||n==="small"?s.jsxs("div",{onClick:()=>t(e),className:"group cursor-pointer space-y-4 pb-6 border-b border-gray-100 last:border-0 text-left",children:[s.jsx("div",{className:"aspect-[4/3] overflow-hidden bg-gray-50 rounded-xl border border-gray-100",children:s.jsx(Li,{src:e.featuredImageUrl,className:"w-full h-full object-[center_top] object-cover transition-all duration-1000 group-hover:scale-103",alt:e.title})}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[9px] font-extrabold font-mono text-red-600 shrink-0 flex-wrap",children:[s.jsx("span",{className:"uppercase tracking-widest",children:e.category}),e.isOfflineCached&&s.jsx("span",{className:"text-teal-600 bg-teal-50 p-1 rounded-full border border-teal-200 flex items-center justify-center cursor-help",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"shrink-0 w-3 h-3",children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"currentColor",d:"M12.05 20q-3.35 0-5.7-2.325T4 12v-.175l-1.6 1.6l-1.4-1.4l4-4l4 4l-1.4 1.4l-1.6-1.6V12q0 2.5 1.763 4.25T12.05 18q.65 0 1.275-.15t1.225-.45l1.5 1.5q-.95.55-1.95.825T12.05 20M19 15.975l-4-4l1.4-1.4l1.6 1.6V12q0-2.5-1.763-4.25T11.95 6q-.65 0-1.275.15T9.45 6.6l-1.5-1.5q.95-.55 1.95-.825T11.95 4q3.35 0 5.7 2.325T20 12v.175l1.6-1.6l1.4 1.4z"})]})}),e.publishDate&&s.jsxs("span",{className:"text-[9px] font-semibold text-gray-400 lowercase normal-case tracking-normal",children:["• ",X0(e.publishDate)]})]}),s.jsx("div",{className:"flex items-center gap-1.5 text-[10px] text-gray-400 font-bold",children:s.jsxs("span",{className:"flex items-center gap-0.5",children:[s.jsx(IC,{size:10})," ",fl(L)]})})]}),s.jsx("h4",{className:"text-base font-serif font-black text-black leading-snug group-hover:text-red-600 transition-colors underline underline-offset-2 decoration-1",children:M0(e.title)}),s.jsx("p",{className:"text-xs text-gray-650 line-clamp-2 italic font-serif",children:e.summary}),e.Links&&e.Links.trim()&&s.jsx("div",{className:"pt-1 text-left",children:s.jsxs("button",{onClick:Pt=>{Pt.stopPropagation(),window.open(e.Links.trim(),"_blank","noopener,noreferrer")},className:"inline-flex items-center gap-1.5 px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-[9.5px] font-black uppercase tracking-wider rounded-lg transition-all active:scale-95 shadow-xs cursor-pointer select-none",children:[s.jsx("span",{children:e.ctaText||"Discover More"}),s.jsx($a,{size:10,strokeWidth:3})]})})]})]}):s.jsxs("div",{onClick:()=>t(e),className:"group cursor-pointer flex gap-4 py-4 border-b border-gray-50 last:border-0 text-left",children:[s.jsxs("div",{className:"flex-1 space-y-1.5 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[8px] font-black font-mono text-red-600 shrink-0 flex-wrap",children:[s.jsx("span",{className:"uppercase tracking-wider",children:e.category}),e.isOfflineCached&&s.jsx("span",{className:"text-teal-600 bg-teal-50 p-1 rounded-full border border-teal-200 flex items-center justify-center cursor-help",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"shrink-0 w-3 h-3",children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"currentColor",d:"M12.05 20q-3.35 0-5.7-2.325T4 12v-.175l-1.6 1.6l-1.4-1.4l4-4l4 4l-1.4 1.4l-1.6-1.6V12q0 2.5 1.763 4.25T12.05 18q.65 0 1.275-.15t1.225-.45l1.5 1.5q-.95.55-1.95.825T12.05 20M19 15.975l-4-4l1.4-1.4l1.6 1.6V12q0-2.5-1.763-4.25T11.95 6q-.65 0-1.275.15T9.45 6.6l-1.5-1.5q.95-.55 1.95-.825T11.95 4q3.35 0 5.7 2.325T20 12v.175l1.6-1.6l1.4 1.4z"})]})}),e.publishDate&&s.jsxs("span",{className:"text-[9px] font-medium text-gray-400 lowercase normal-case tracking-normal",children:["• ",X0(e.publishDate)]})]}),s.jsx("h5",{className:"text-xs font-serif font-black text-black leading-snug truncate group-hover:text-red-600 transition-colors underline decoration-1",children:M0(e.title)}),s.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[s.jsxs("p",{onClick:Pt=>{r&&e.authorId&&(Pt.stopPropagation(),r(e.authorId))},onMouseEnter:Pt=>{r&&e.authorId&&window.matchMedia("(min-width: 1024px)").matches&&r(e.authorId)},className:Fe("text-[9px] font-black text-gray-400 uppercase tracking-widest select-none",r&&"cursor-pointer hover:text-black hover:underline active:scale-97 transition-all"),title:"Click or hover to view peer credentials",children:["By ",e.authorName&&e.authorName.includes("@")?e.authorName.split("@")[0]:e.authorName]}),e.Links&&e.Links.trim()&&s.jsxs("button",{onClick:Pt=>{Pt.stopPropagation(),window.open(e.Links.trim(),"_blank","noopener,noreferrer")},className:"inline-flex items-center gap-1 px-2 py-1 bg-red-650 hover:bg-red-700 text-white text-[8px] font-black uppercase tracking-wider rounded transition-all active:scale-95 shadow-xs cursor-pointer select-none",children:[s.jsx("span",{children:"Discover"}),s.jsx($a,{size:8,strokeWidth:3})]})]})]}),s.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded overflow-hidden shrink-0 border border-gray-100",children:s.jsx(Li,{src:e.featuredImageUrl,className:"w-full h-full object-cover",alt:""})})]}))};var Zx={exports:{}},R_={},D_,CM;function R1e(){if(CM)return D_;CM=1;function e(t,n){typeof n=="boolean"&&(n={forever:n}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=n||{},this._maxRetryTime=n&&n.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}return D_=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},e.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var n=new Date().getTime();if(t&&n-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var i=this;return this._timer=setTimeout(function(){i._attempts++,i._operationTimeoutCb&&(i._timeout=setTimeout(function(){i._operationTimeoutCb(i._attempts)},i._operationTimeout),i._options.unref&&i._timeout.unref()),i._fn(i._attempts)},r),this._options.unref&&this._timer.unref(),!0},e.prototype.attempt=function(t,n){this._fn=t,n&&(n.timeout&&(this._operationTimeout=n.timeout),n.cb&&(this._operationTimeoutCb=n.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},e.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)},e.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},n=null,r=0,i=0;i=r&&(n=a,r=c)}return n},D_}var jM;function D1e(){return jM||(jM=1,(function(e){var t=R1e();e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(n){if(n instanceof Array)return[].concat(n);var r={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var i in n)r[i]=n[i];if(r.minTimeout>r.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var a=[],o=0;o{const f=h.retries-(c-1);return o.attemptNumber=c,o.retriesLeft=f,o},i=o=>t.includes(o),a=(o,c)=>new Promise((h,f)=>{c={onFailedAttempt:()=>{},retries:10,...c};const m=e.operation(c);m.attempt(async y=>{try{h(await o(y))}catch(w){if(!(w instanceof Error)){f(new TypeError(`Non-error was thrown: "${w}". You should only throw errors.`));return}if(w instanceof n)m.stop(),f(w.originalError);else if(w instanceof TypeError&&!i(w.message))m.stop(),f(w);else{r(w,y,c);try{await c.onFailedAttempt(w)}catch(A){f(A);return}m.retry(w)||f(m.mainError())}}})});return Zx.exports=a,Zx.exports.default=a,Zx.exports.AbortError=n,Zx.exports}L1e();var U1e={};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var PM;(function(e){e.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",e.PYTHON="PYTHON"})(PM||(PM={}));var OM;(function(e){e.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",e.OUTCOME_OK="OUTCOME_OK",e.OUTCOME_FAILED="OUTCOME_FAILED",e.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(OM||(OM={}));var RM;(function(e){e.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",e.SILENT="SILENT",e.WHEN_IDLE="WHEN_IDLE",e.INTERRUPT="INTERRUPT"})(RM||(RM={}));var DM;(function(e){e.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",e.STRING="STRING",e.NUMBER="NUMBER",e.INTEGER="INTEGER",e.BOOLEAN="BOOLEAN",e.ARRAY="ARRAY",e.OBJECT="OBJECT",e.NULL="NULL"})(DM||(DM={}));var MM;(function(e){e.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",e.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",e.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",e.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(MM||(MM={}));var LM;(function(e){e.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",e.NO_AUTH="NO_AUTH",e.API_KEY_AUTH="API_KEY_AUTH",e.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",e.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",e.OAUTH="OAUTH",e.OIDC_AUTH="OIDC_AUTH"})(LM||(LM={}));var UM;(function(e){e.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",e.HTTP_IN_QUERY="HTTP_IN_QUERY",e.HTTP_IN_HEADER="HTTP_IN_HEADER",e.HTTP_IN_PATH="HTTP_IN_PATH",e.HTTP_IN_BODY="HTTP_IN_BODY",e.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(UM||(UM={}));var BM;(function(e){e.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",e.SIMPLE_SEARCH="SIMPLE_SEARCH",e.ELASTIC_SEARCH="ELASTIC_SEARCH"})(BM||(BM={}));var zM;(function(e){e.UNSPECIFIED="UNSPECIFIED",e.BLOCKING="BLOCKING",e.NON_BLOCKING="NON_BLOCKING"})(zM||(zM={}));var VM;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.MODE_DYNAMIC="MODE_DYNAMIC"})(VM||(VM={}));var FM;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.AUTO="AUTO",e.ANY="ANY",e.NONE="NONE",e.VALIDATED="VALIDATED"})(FM||(FM={}));var $M;(function(e){e.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH",e.MINIMAL="MINIMAL"})($M||($M={}));var HM;(function(e){e.DONT_ALLOW="DONT_ALLOW",e.ALLOW_ADULT="ALLOW_ADULT",e.ALLOW_ALL="ALLOW_ALL"})(HM||(HM={}));var GM;(function(e){e.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",e.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",e.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",e.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",e.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",e.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",e.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",e.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",e.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",e.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",e.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(GM||(GM={}));var qM;(function(e){e.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",e.SEVERITY="SEVERITY",e.PROBABILITY="PROBABILITY"})(qM||(qM={}));var WM;(function(e){e.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",e.BLOCK_NONE="BLOCK_NONE",e.OFF="OFF"})(WM||(WM={}));var KM;(function(e){e.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",e.STOP="STOP",e.MAX_TOKENS="MAX_TOKENS",e.SAFETY="SAFETY",e.RECITATION="RECITATION",e.LANGUAGE="LANGUAGE",e.OTHER="OTHER",e.BLOCKLIST="BLOCKLIST",e.PROHIBITED_CONTENT="PROHIBITED_CONTENT",e.SPII="SPII",e.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",e.IMAGE_SAFETY="IMAGE_SAFETY",e.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",e.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",e.NO_IMAGE="NO_IMAGE",e.IMAGE_RECITATION="IMAGE_RECITATION",e.IMAGE_OTHER="IMAGE_OTHER"})(KM||(KM={}));var YM;(function(e){e.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",e.NEGLIGIBLE="NEGLIGIBLE",e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"})(YM||(YM={}));var XM;(function(e){e.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",e.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",e.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",e.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",e.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(XM||(XM={}));var QM;(function(e){e.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",e.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",e.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",e.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",e.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(QM||(QM={}));var ZM;(function(e){e.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",e.SAFETY="SAFETY",e.OTHER="OTHER",e.BLOCKLIST="BLOCKLIST",e.PROHIBITED_CONTENT="PROHIBITED_CONTENT",e.IMAGE_SAFETY="IMAGE_SAFETY",e.MODEL_ARMOR="MODEL_ARMOR",e.JAILBREAK="JAILBREAK"})(ZM||(ZM={}));var JM;(function(e){e.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",e.ON_DEMAND="ON_DEMAND",e.ON_DEMAND_PRIORITY="ON_DEMAND_PRIORITY",e.ON_DEMAND_FLEX="ON_DEMAND_FLEX",e.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(JM||(JM={}));var e9;(function(e){e.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",e.TEXT="TEXT",e.IMAGE="IMAGE",e.AUDIO="AUDIO"})(e9||(e9={}));var t9;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",e.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",e.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",e.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(t9||(t9={}));var n9;(function(e){e.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",e.TUNING_MODE_FULL="TUNING_MODE_FULL",e.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(n9||(n9={}));var r9;(function(e){e.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",e.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",e.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",e.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",e.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",e.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",e.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(r9||(r9={}));var i9;(function(e){e.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",e.JOB_STATE_QUEUED="JOB_STATE_QUEUED",e.JOB_STATE_PENDING="JOB_STATE_PENDING",e.JOB_STATE_RUNNING="JOB_STATE_RUNNING",e.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",e.JOB_STATE_FAILED="JOB_STATE_FAILED",e.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",e.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",e.JOB_STATE_PAUSED="JOB_STATE_PAUSED",e.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",e.JOB_STATE_UPDATING="JOB_STATE_UPDATING",e.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(i9||(i9={}));var s9;(function(e){e.TUNING_JOB_STATE_UNSPECIFIED="TUNING_JOB_STATE_UNSPECIFIED",e.TUNING_JOB_STATE_WAITING_FOR_QUOTA="TUNING_JOB_STATE_WAITING_FOR_QUOTA",e.TUNING_JOB_STATE_PROCESSING_DATASET="TUNING_JOB_STATE_PROCESSING_DATASET",e.TUNING_JOB_STATE_WAITING_FOR_CAPACITY="TUNING_JOB_STATE_WAITING_FOR_CAPACITY",e.TUNING_JOB_STATE_TUNING="TUNING_JOB_STATE_TUNING",e.TUNING_JOB_STATE_POST_PROCESSING="TUNING_JOB_STATE_POST_PROCESSING"})(s9||(s9={}));var a9;(function(e){e.AGGREGATION_METRIC_UNSPECIFIED="AGGREGATION_METRIC_UNSPECIFIED",e.AVERAGE="AVERAGE",e.MODE="MODE",e.STANDARD_DEVIATION="STANDARD_DEVIATION",e.VARIANCE="VARIANCE",e.MINIMUM="MINIMUM",e.MAXIMUM="MAXIMUM",e.MEDIAN="MEDIAN",e.PERCENTILE_P90="PERCENTILE_P90",e.PERCENTILE_P95="PERCENTILE_P95",e.PERCENTILE_P99="PERCENTILE_P99"})(a9||(a9={}));var o9;(function(e){e.PAIRWISE_CHOICE_UNSPECIFIED="PAIRWISE_CHOICE_UNSPECIFIED",e.BASELINE="BASELINE",e.CANDIDATE="CANDIDATE",e.TIE="TIE"})(o9||(o9={}));var l9;(function(e){e.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",e.TUNING_TASK_I2V="TUNING_TASK_I2V",e.TUNING_TASK_T2V="TUNING_TASK_T2V",e.TUNING_TASK_R2V="TUNING_TASK_R2V"})(l9||(l9={}));var c9;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",e.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",e.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",e.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",e.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH"})(c9||(c9={}));var u9;(function(e){e.TOOL_TYPE_UNSPECIFIED="TOOL_TYPE_UNSPECIFIED",e.GOOGLE_SEARCH_WEB="GOOGLE_SEARCH_WEB",e.GOOGLE_SEARCH_IMAGE="GOOGLE_SEARCH_IMAGE",e.URL_CONTEXT="URL_CONTEXT",e.GOOGLE_MAPS="GOOGLE_MAPS",e.FILE_SEARCH="FILE_SEARCH"})(u9||(u9={}));var d9;(function(e){e.COLLECTION="COLLECTION"})(d9||(d9={}));var h9;(function(e){e.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",e.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",e.BALANCED="BALANCED",e.PRIORITIZE_COST="PRIORITIZE_COST"})(h9||(h9={}));var f9;(function(e){e.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",e.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(f9||(f9={}));var p9;(function(e){e.PROMINENT_PEOPLE_UNSPECIFIED="PROMINENT_PEOPLE_UNSPECIFIED",e.ALLOW_PROMINENT_PEOPLE="ALLOW_PROMINENT_PEOPLE",e.BLOCK_PROMINENT_PEOPLE="BLOCK_PROMINENT_PEOPLE"})(p9||(p9={}));var m9;(function(e){e.PREDICT="PREDICT",e.EMBED_CONTENT="EMBED_CONTENT"})(m9||(m9={}));var g9;(function(e){e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",e.BLOCK_NONE="BLOCK_NONE"})(g9||(g9={}));var x9;(function(e){e.auto="auto",e.en="en",e.ja="ja",e.ko="ko",e.hi="hi",e.zh="zh",e.pt="pt",e.es="es"})(x9||(x9={}));var y9;(function(e){e.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",e.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",e.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",e.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",e.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(y9||(y9={}));var b9;(function(e){e.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",e.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",e.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",e.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(b9||(b9={}));var v9;(function(e){e.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",e.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",e.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",e.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(v9||(v9={}));var w9;(function(e){e.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",e.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",e.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",e.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",e.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",e.EDIT_MODE_STYLE="EDIT_MODE_STYLE",e.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",e.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(w9||(w9={}));var N9;(function(e){e.FOREGROUND="FOREGROUND",e.BACKGROUND="BACKGROUND",e.PROMPT="PROMPT",e.SEMANTIC="SEMANTIC",e.INTERACTIVE="INTERACTIVE"})(N9||(N9={}));var E9;(function(e){e.ASSET="ASSET",e.STYLE="STYLE"})(E9||(E9={}));var A9;(function(e){e.INSERT="INSERT",e.REMOVE="REMOVE",e.REMOVE_STATIC="REMOVE_STATIC",e.OUTPAINT="OUTPAINT"})(A9||(A9={}));var _9;(function(e){e.OPTIMIZED="OPTIMIZED",e.LOSSLESS="LOSSLESS"})(_9||(_9={}));var k9;(function(e){e.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",e.PREFERENCE_TUNING="PREFERENCE_TUNING",e.DISTILLATION="DISTILLATION"})(k9||(k9={}));var S9;(function(e){e.STATE_UNSPECIFIED="STATE_UNSPECIFIED",e.STATE_PENDING="STATE_PENDING",e.STATE_ACTIVE="STATE_ACTIVE",e.STATE_FAILED="STATE_FAILED"})(S9||(S9={}));var C9;(function(e){e.STATE_UNSPECIFIED="STATE_UNSPECIFIED",e.PROCESSING="PROCESSING",e.ACTIVE="ACTIVE",e.FAILED="FAILED"})(C9||(C9={}));var j9;(function(e){e.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",e.UPLOADED="UPLOADED",e.GENERATED="GENERATED",e.REGISTERED="REGISTERED"})(j9||(j9={}));var I9;(function(e){e.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",e.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",e.RESPONSE_REJECTED="RESPONSE_REJECTED",e.NEED_MORE_INPUT="NEED_MORE_INPUT"})(I9||(I9={}));var T9;(function(e){e.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",e.TEXT="TEXT",e.IMAGE="IMAGE",e.VIDEO="VIDEO",e.AUDIO="AUDIO",e.DOCUMENT="DOCUMENT"})(T9||(T9={}));var P9;(function(e){e.VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",e.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",e.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS"})(P9||(P9={}));var O9;(function(e){e.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",e.ACTIVITY_START="ACTIVITY_START",e.ACTIVITY_END="ACTIVITY_END"})(O9||(O9={}));var R9;(function(e){e.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",e.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",e.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(R9||(R9={}));var D9;(function(e){e.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",e.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",e.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(D9||(D9={}));var M9;(function(e){e.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",e.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",e.NO_INTERRUPTION="NO_INTERRUPTION"})(M9||(M9={}));var L9;(function(e){e.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",e.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",e.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(L9||(L9={}));var U9;(function(e){e.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",e.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",e.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",e.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",e.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",e.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",e.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",e.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",e.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",e.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",e.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",e.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",e.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(U9||(U9={}));var B9;(function(e){e.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",e.QUALITY="QUALITY",e.DIVERSITY="DIVERSITY",e.VOCALIZATION="VOCALIZATION"})(B9||(B9={}));var z9;(function(e){e.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",e.PLAY="PLAY",e.PAUSE="PAUSE",e.STOP="STOP",e.RESET_CONTEXT="RESET_CONTEXT"})(z9||(z9={}));/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var V9;(function(e){e.PAGED_ITEM_BATCH_JOBS="batchJobs",e.PAGED_ITEM_MODELS="models",e.PAGED_ITEM_TUNING_JOBS="tuningJobs",e.PAGED_ITEM_FILES="files",e.PAGED_ITEM_CACHED_CONTENTS="cachedContents",e.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",e.PAGED_ITEM_DOCUMENTS="documents"})(V9||(V9={}));function W2(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function $s(e){return this instanceof $s?(this.v=e,this):new $s(e)}function G1(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(A){return function(S){return Promise.resolve(S).then(A,y)}}function c(A,S){r[A]&&(i[A]=function(C){return new Promise(function(T,D){a.push([A,C,T,D])>1||h(A,C)})},S&&(i[A]=S(i[A])))}function h(A,S){try{f(r[A](S))}catch(C){w(a[0][3],C)}}function f(A){A.value instanceof $s?Promise.resolve(A.value.v).then(m,y):w(a[0][2],A)}function m(A){h("next",A)}function y(A){h("throw",A)}function w(A,S){A(S),a.shift(),a.length&&h(a[0][0],a[0][1])}}function Q0(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof F9=="function"?F9(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(a){n[a]=e[a]&&function(o){return new Promise(function(c,h){o=e[a](o),i(c,h,o.done,o.value)})}}function i(a,o,c,h){Promise.resolve(h).then(function(f){a({value:f,done:c})},o)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */let JW=function(){const{crypto:e}=globalThis;if(e!=null&&e.randomUUID)return JW=e.randomUUID.bind(e),e.randomUUID();const t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^n()&15>>+r/4).toString(16))};const B1e=()=>JW();/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function nj(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const rj=e=>{if(e instanceof Error)return e;if(typeof e=="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){const t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class yc extends Error{}class Ko extends yc{constructor(t,n,r,i){super(`${Ko.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.error=n}static makeMessage(t,n,r){const i=n!=null&&n.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):r;return t&&i?`${t} ${i}`:t?`${t} status code (no body)`:i||"(no status code or body)"}static generate(t,n,r,i){if(!t||!i)return new zE({message:r,cause:rj(n)});const a=n;return t===400?new tK(t,a,r,i):t===401?new nK(t,a,r,i):t===403?new rK(t,a,r,i):t===404?new iK(t,a,r,i):t===409?new sK(t,a,r,i):t===422?new aK(t,a,r,i):t===429?new oK(t,a,r,i):t>=500?new lK(t,a,r,i):new Ko(t,a,r,i)}}class ij extends Ko{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}}class zE extends Ko{constructor({message:t,cause:n}){super(void 0,void 0,t||"Connection error.",void 0),n&&(this.cause=n)}}class eK extends zE{constructor({message:t}={}){super({message:t??"Request timed out."})}}class tK extends Ko{}class nK extends Ko{}class rK extends Ko{}class iK extends Ko{}class sK extends Ko{}class aK extends Ko{}class oK extends Ko{}class lK extends Ko{}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const z1e=/^[a-z][a-z0-9+.-]*:/i,V1e=e=>z1e.test(e);let sj=e=>(sj=Array.isArray,sj(e));const F1e=sj;let $1e=F1e;const $9=$1e;function H9(e){if(!e)return!0;for(const t in e)return!1;return!0}function H1e(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const G1e=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new yc(`${e} must be an integer`);if(t<0)throw new yc(`${e} must be a positive integer`);return t},q1e=e=>{try{return JSON.parse(e)}catch{return}};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const W1e=e=>new Promise(t=>setTimeout(t,e));/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function K1e(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new GeminiNextGenAPIClient({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function cK(...e){const t=globalThis.ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function Y1e(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return cK({start(){},async pull(n){const{done:r,value:i}=await t.next();r?n.close():n.enqueue(i)},async cancel(){var n;await((n=t.return)===null||n===void 0?void 0:n.call(t))}})}function uK(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const n=await t.read();return n!=null&&n.done&&t.releaseLock(),n}catch(n){throw t.releaseLock(),n}},async return(){const n=t.cancel();return t.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function X1e(e){var t,n;if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await((n=(t=e[Symbol.asyncIterator]()).return)===null||n===void 0?void 0:n.call(t));return}const r=e.getReader(),i=r.cancel();r.releaseLock(),await i}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Q1e=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Z1e(e){return Object.entries(e).filter(([t,n])=>typeof n<"u").map(([t,n])=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(n===null)return`${encodeURIComponent(t)}=`;throw new yc(`Cannot stringify type ${typeof n}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const J1e="0.0.1";/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const dK=()=>{var e;if(typeof File>"u"){const{process:t}=globalThis,n=typeof((e=t==null?void 0:t.versions)===null||e===void 0?void 0:e.node)=="string"&&parseInt(t.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(n?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function L_(e,t,n){return dK(),new File(e,t??"unknown_file",n)}function eye(e){return(typeof e=="object"&&e!==null&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}const tye=e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function";/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const hK=e=>e!=null&&typeof e=="object"&&typeof e.size=="number"&&typeof e.type=="string"&&typeof e.text=="function"&&typeof e.slice=="function"&&typeof e.arrayBuffer=="function",nye=e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&hK(e),rye=e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function";async function iye(e,t,n){if(dK(),e=await e,nye(e))return e instanceof File?e:L_([await e.arrayBuffer()],e.name);if(rye(e)){const i=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),L_(await aj(i),t,n)}const r=await aj(e);if(t||(t=eye(e)),!(n!=null&&n.type)){const i=r.find(a=>typeof a=="object"&&"type"in a&&a.type);typeof i=="string"&&(n=Object.assign(Object.assign({},n),{type:i}))}return L_(r,t,n)}async function aj(e){var t,n,r,i,a;let o=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)o.push(e);else if(hK(e))o.push(e instanceof Blob?e:await e.arrayBuffer());else if(tye(e))try{for(var c=!0,h=Q0(e),f;f=await h.next(),t=f.done,!t;c=!0){i=f.value,c=!1;const m=i;o.push(...await aj(m))}}catch(m){n={error:m}}finally{try{!c&&!t&&(r=h.return)&&await r.call(h)}finally{if(n)throw n.error}}else{const m=(a=e==null?void 0:e.constructor)===null||a===void 0?void 0:a.name;throw new Error(`Unexpected data type: ${typeof e}${m?`; constructor: ${m}`:""}${sye(e)}`)}return o}function sye(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(n=>`"${n}"`).join(", ")}]`}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class fK{constructor(t){this._client=t}}fK._key=[];/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function pK(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const G9=Object.freeze(Object.create(null)),aye=(e=pK)=>(function(n,...r){if(n.length===1)return n[0];let i=!1;const a=[],o=n.reduce((m,y,w)=>{var A,S,C;/[?#]/.test(y)&&(i=!0);const T=r[w];let D=(i?encodeURIComponent:e)(""+T);return w!==r.length&&(T==null||typeof T=="object"&&T.toString===((C=Object.getPrototypeOf((S=Object.getPrototypeOf((A=T.hasOwnProperty)!==null&&A!==void 0?A:G9))!==null&&S!==void 0?S:G9))===null||C===void 0?void 0:C.toString))&&(D=T+"",a.push({start:m.length+y.length,length:D.length,error:`Value of type ${Object.prototype.toString.call(T).slice(8,-1)} is not a valid path parameter`})),m+y+(w===r.length?"":D)},""),c=o.split(/[?#]/,1)[0],h=/(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let f;for(;(f=h.exec(c))!==null;){const m=f[0].startsWith("/"),y=m?1:0,w=m?f[0].slice(1):f[0];a.push({start:f.index+y,length:w.length,error:`Value "${w}" can't be safely passed as a path parameter`})}if(a.sort((m,y)=>m.start-y.start),a.length>0){let m=0;const y=a.reduce((w,A)=>{const S=" ".repeat(A.start-m),C="^".repeat(A.length);return m=A.start+A.length,w+S+C},"");throw new yc(`Path parameters result in path with invalid segments: ${a.map(w=>w.error).join(` `)} ${o} ${y}`)}return o}),Kv=aye(pK);/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class mK extends fK{create(t,n){var r;const{api_version:i=this._client.apiVersion}=t,a=W2(t,["api_version"]);if("model"in a&&"agent_config"in a)throw new yc("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if("agent"in a&&"generation_config"in a)throw new yc("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(Kv`/${i}/interactions`,Object.assign(Object.assign({body:a},n),{stream:(r=t.stream)!==null&&r!==void 0?r:!1}))}delete(t,n={},r){const{api_version:i=this._client.apiVersion}=n??{};return this._client.delete(Kv`/${i}/interactions/${t}`,r)}cancel(t,n={},r){const{api_version:i=this._client.apiVersion}=n??{};return this._client.post(Kv`/${i}/interactions/${t}/cancel`,r)}get(t,n={},r){var i;const a=n??{},{api_version:o=this._client.apiVersion}=a,c=W2(a,["api_version"]);return this._client.get(Kv`/${o}/interactions/${t}`,Object.assign(Object.assign({query:c},r),{stream:(i=n==null?void 0:n.stream)!==null&&i!==void 0?i:!1}))}}mK._key=Object.freeze(["interactions"]);class gK extends mK{}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function oye(e){let t=0;for(const i of e)t+=i.length;const n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n}let Yv;function p4(e){let t;return(Yv??(t=new globalThis.TextEncoder,Yv=t.encode.bind(t)))(e)}let Xv;function q9(e){let t;return(Xv??(t=new globalThis.TextDecoder,Xv=t.decode.bind(t)))(e)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class VE{constructor(){this.buffer=new Uint8Array,this.carriageReturnIndex=null,this.searchIndex=0}decode(t){var n;if(t==null)return[];const r=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?p4(t):t;this.buffer=oye([this.buffer,r]);const i=[];let a;for(;(a=lye(this.buffer,(n=this.carriageReturnIndex)!==null&&n!==void 0?n:this.searchIndex))!=null;){if(a.carriage&&this.carriageReturnIndex==null){this.carriageReturnIndex=a.index;continue}if(this.carriageReturnIndex!=null&&(a.index!==this.carriageReturnIndex+1||a.carriage)){i.push(q9(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null,this.searchIndex=0;continue}const o=this.carriageReturnIndex!==null?a.preceding-1:a.preceding,c=q9(this.buffer.subarray(0,o));i.push(c),this.buffer=this.buffer.subarray(a.index),this.carriageReturnIndex=null,this.searchIndex=0}return this.searchIndex=Math.max(0,this.buffer.length-1),i}flush(){return this.buffer.length?this.decode(` `):[]}}VE.NEWLINE_CHARS=new Set([` `,"\r"]);VE.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function lye(e,t){const i=t??0,a=e.indexOf(10,i),o=e.indexOf(13,i);if(a===-1&&o===-1)return null;let c;return a!==-1&&o!==-1?c=Math.min(a,o):c=a!==-1?a:o,e[c]===10?{preceding:c,index:c+1,carriage:!1}:{preceding:c,index:c+1,carriage:!0}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const K2={off:0,error:200,warn:300,info:400,debug:500},W9=(e,t,n)=>{if(e){if(H1e(K2,e))return e;Bo(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(K2))}`)}};function A1(){}function Qv(e,t,n){return!t||K2[e]>K2[n]?A1:t[e].bind(t)}const cye={error:A1,warn:A1,info:A1,debug:A1};let K9=new WeakMap;function Bo(e){var t;const n=e.logger,r=(t=e.logLevel)!==null&&t!==void 0?t:"off";if(!n)return cye;const i=K9.get(n);if(i&&i[0]===r)return i[1];const a={error:Qv("error",n,r),warn:Qv("warn",n,r),info:Qv("info",n,r),debug:Qv("debug",n,r)};return K9.set(n,[r,a]),a}const hp=e=>(e.options&&(e.options=Object.assign({},e.options),delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([t,n])=>[t,t.toLowerCase()==="x-goog-api-key"||t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class z0{constructor(t,n,r){this.iterator=t,this.controller=n,this.client=r}static fromSSEResponse(t,n,r){let i=!1;const a=r?Bo(r):console;function o(){return G1(this,arguments,function*(){var h,f,m,y;if(i)throw new yc("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let w=!1;try{try{for(var A=!0,S=Q0(uye(t,n)),C;C=yield $s(S.next()),h=C.done,!h;A=!0){y=C.value,A=!1;const T=y;if(!w)if(T.data.startsWith("[DONE]")){w=!0;continue}else try{yield yield $s(JSON.parse(T.data))}catch(D){throw a.error("Could not parse message into JSON:",T.data),a.error("From chunk:",T.raw),D}}}catch(T){f={error:T}}finally{try{!A&&!h&&(m=S.return)&&(yield $s(m.call(S)))}finally{if(f)throw f.error}}w=!0}catch(T){if(nj(T))return yield $s(void 0);throw T}finally{w||n.abort()}})}return new z0(o,n,r)}static fromReadableStream(t,n,r){let i=!1;function a(){return G1(this,arguments,function*(){var h,f,m,y;const w=new VE,A=uK(t);try{for(var S=!0,C=Q0(A),T;T=yield $s(C.next()),h=T.done,!h;S=!0){y=T.value,S=!1;const D=y;for(const V of w.decode(D))yield yield $s(V)}}catch(D){f={error:D}}finally{try{!S&&!h&&(m=C.return)&&(yield $s(m.call(C)))}finally{if(f)throw f.error}}for(const D of w.flush())yield yield $s(D)})}function o(){return G1(this,arguments,function*(){var h,f,m,y;if(i)throw new yc("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let w=!1;try{try{for(var A=!0,S=Q0(a()),C;C=yield $s(S.next()),h=C.done,!h;A=!0){y=C.value,A=!1;const T=y;w||T&&(yield yield $s(JSON.parse(T)))}}catch(T){f={error:T}}finally{try{!A&&!h&&(m=S.return)&&(yield $s(m.call(S)))}finally{if(f)throw f.error}}w=!0}catch(T){if(nj(T))return yield $s(void 0);throw T}finally{w||n.abort()}})}return new z0(o,n,r)}[Symbol.asyncIterator](){return this.iterator()}tee(){const t=[],n=[],r=this.iterator(),i=a=>({next:()=>{if(a.length===0){const o=r.next();t.push(o),n.push(o)}return a.shift()}});return[new z0(()=>i(t),this.controller,this.client),new z0(()=>i(n),this.controller,this.client)]}toReadableStream(){const t=this;let n;return cK({async start(){n=t[Symbol.asyncIterator]()},async pull(r){try{const{value:i,done:a}=await n.next();if(a)return r.close();const o=p4(JSON.stringify(i)+` `);r.enqueue(o)}catch(i){r.error(i)}},async cancel(){var r;await((r=n.return)===null||r===void 0?void 0:r.call(n))}})}}function uye(e,t){return G1(this,arguments,function*(){var r,i,a,o;if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new yc("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new yc("Attempted to iterate over a response with no body");const c=new hye,h=new VE,f=uK(e.body);try{for(var m=!0,y=Q0(dye(f)),w;w=yield $s(y.next()),r=w.done,!r;m=!0){o=w.value,m=!1;const A=o;for(const S of h.decode(A)){const C=c.decode(S);C&&(yield yield $s(C))}}}catch(A){i={error:A}}finally{try{!m&&!r&&(a=y.return)&&(yield $s(a.call(y)))}finally{if(i)throw i.error}}for(const A of h.flush()){const S=c.decode(A);S&&(yield yield $s(S))}})}function dye(e){return G1(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,c=Q0(e),h;h=yield $s(c.next()),n=h.done,!n;o=!0){a=h.value,o=!1;const f=a;if(f==null)continue;const m=f instanceof ArrayBuffer?new Uint8Array(f):typeof f=="string"?p4(f):f;yield yield $s(m)}}catch(f){r={error:f}}finally{try{!o&&!n&&(i=c.return)&&(yield $s(i.call(c)))}finally{if(r)throw r.error}}})}class hye{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){if(t.endsWith("\r")&&(t=t.substring(0,t.length-1)),!t){if(!this.event&&!this.data.length)return null;const a={event:this.event,data:this.data.join(` `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],a}if(this.chunks.push(t),t.startsWith(":"))return null;let[n,r,i]=fye(t,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}}function fye(e,t){const n=e.indexOf(t);return n!==-1?[e.substring(0,n),t,e.substring(n+t.length)]:[e,"",""]}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */async function pye(e,t){const{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{var c;if(t.options.stream)return Bo(e).debug("response",n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e):z0.fromSSEResponse(n,t.controller,e);if(n.status===204)return null;if(t.options.__binaryResponse)return n;const h=n.headers.get("content-type"),f=(c=h==null?void 0:h.split(";")[0])===null||c===void 0?void 0:c.trim();return(f==null?void 0:f.includes("application/json"))||(f==null?void 0:f.endsWith("+json"))?n.headers.get("content-length")==="0"?void 0:await n.json():await n.text()})();return Bo(e).debug(`[${r}] response parsed`,hp({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a})),o}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class m4 extends Promise{constructor(t,n,r=pye){super(i=>{i(null)}),this.responsePromise=n,this.parseResponse=r,this.client=t}_thenUnwrap(t){return new m4(this.client,this.responsePromise,async(n,r)=>t(await this.parseResponse(n,r),r))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){const[t,n]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:n}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(this.client,t))),this.parsedPromise}then(t,n){return this.parse().then(t,n)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const xK=Symbol("brand.privateNullableHeaders");function*mye(e){if(!e)return;if(xK in e){const{values:r,nulls:i}=e;yield*r.entries();for(const a of i)yield[a,null];return}let t=!1,n;e instanceof Headers?n=e.entries():$9(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let r of n){const i=r[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");const a=$9(r[1])?r[1]:[r[1]];let o=!1;for(const c of a)c!==void 0&&(t&&!o&&(o=!0,yield[i,null]),yield[i,c])}}const Jx=e=>{const t=new Headers,n=new Set;for(const r of e){const i=new Set;for(const[a,o]of mye(r)){const c=a.toLowerCase();i.has(c)||(t.delete(a),i.add(c)),o===null?(t.delete(a),n.add(c)):(t.append(a,o),n.delete(c))}}return{[xK]:!0,values:t,nulls:n}};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const U_=e=>{var t,n,r,i,a,o;if(typeof globalThis.process<"u")return(r=(n=(t=U1e)===null||t===void 0?void 0:t[e])===null||n===void 0?void 0:n.trim())!==null&&r!==void 0?r:void 0;if(typeof globalThis.Deno<"u")return(o=(a=(i=globalThis.Deno.env)===null||i===void 0?void 0:i.get)===null||a===void 0?void 0:a.call(i,e))===null||o===void 0?void 0:o.trim()};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var yK;class FE{constructor(t){var n,r,i,a,o,c,h,{baseURL:f=U_("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:m=(n=U_("GEMINI_API_KEY"))!==null&&n!==void 0?n:null,apiVersion:y="v1beta"}=t,w=W2(t,["baseURL","apiKey","apiVersion"]);const A=Object.assign(Object.assign({apiKey:m,apiVersion:y},w),{baseURL:f||"https://generativelanguage.googleapis.com"});this.baseURL=A.baseURL,this.timeout=(r=A.timeout)!==null&&r!==void 0?r:FE.DEFAULT_TIMEOUT,this.logger=(i=A.logger)!==null&&i!==void 0?i:console;const S="warn";this.logLevel=S,this.logLevel=(o=(a=W9(A.logLevel,"ClientOptions.logLevel",this))!==null&&a!==void 0?a:W9(U_("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&o!==void 0?o:S,this.fetchOptions=A.fetchOptions,this.maxRetries=(c=A.maxRetries)!==null&&c!==void 0?c:2,this.fetch=(h=A.fetch)!==null&&h!==void 0?h:K1e(),this.encoder=Q1e,this._options=A,this.apiKey=m,this.apiVersion=y,this.clientAdapter=A.clientAdapter}withOptions(t){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),t))}baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:n}){if(!(t.has("authorization")||t.has("x-goog-api-key"))&&!(this.apiKey&&t.get("x-goog-api-key"))&&!n.has("x-goog-api-key"))throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(t){const n=Jx([t.headers]);if(!(n.values.has("authorization")||n.values.has("x-goog-api-key"))){if(this.apiKey)return Jx([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return Jx([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(t){return Z1e(t)}getUserAgent(){return`${this.constructor.name}/JS ${J1e}`}defaultIdempotencyKey(){return`stainless-node-retry-${B1e()}`}makeStatusError(t,n,r,i){return Ko.generate(t,n,r,i)}buildURL(t,n,r){const i=!this.baseURLOverridden()&&r||this.baseURL,a=V1e(t)?new URL(t):new URL(i+(i.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),o=this.defaultQuery(),c=Object.fromEntries(a.searchParams);return(!H9(o)||!H9(c))&&(n=Object.assign(Object.assign(Object.assign({},c),o),n)),typeof n=="object"&&n&&!Array.isArray(n)&&(a.search=this.stringifyQuery(n)),a.toString()}async prepareOptions(t){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!t.path.startsWith(`/${this.apiVersion}/projects/`)){const n=t.path.slice(this.apiVersion.length+1);t.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${n}`}}async prepareRequest(t,{url:n,options:r}){}get(t,n){return this.methodRequest("get",t,n)}post(t,n){return this.methodRequest("post",t,n)}patch(t,n){return this.methodRequest("patch",t,n)}put(t,n){return this.methodRequest("put",t,n)}delete(t,n){return this.methodRequest("delete",t,n)}methodRequest(t,n,r){return this.request(Promise.resolve(r).then(i=>Object.assign({method:t,path:n},i)))}request(t,n=null){return new m4(this,this.makeRequest(t,n,void 0))}async makeRequest(t,n,r){var i,a,o;const c=await t,h=(i=c.maxRetries)!==null&&i!==void 0?i:this.maxRetries;n==null&&(n=h),await this.prepareOptions(c);const{req:f,url:m,timeout:y}=await this.buildRequest(c,{retryCount:h-n});await this.prepareRequest(f,{url:m,options:c});const w="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),A=r===void 0?"":`, retryOf: ${r}`,S=Date.now();if(Bo(this).debug(`[${w}] sending request`,hp({retryOfRequestLogID:r,method:c.method,url:m,options:c,headers:f.headers})),!((a=c.signal)===null||a===void 0)&&a.aborted)throw new ij;const C=new AbortController,T=await this.fetchWithTimeout(m,f,y,C).catch(rj),D=Date.now();if(T instanceof globalThis.Error){const L=`retrying, ${n} attempts remaining`;if(!((o=c.signal)===null||o===void 0)&&o.aborted)throw new ij;const K=nj(T)||/timed? ?out/i.test(String(T)+("cause"in T?String(T.cause):""));if(n)return Bo(this).info(`[${w}] connection ${K?"timed out":"failed"} - ${L}`),Bo(this).debug(`[${w}] connection ${K?"timed out":"failed"} (${L})`,hp({retryOfRequestLogID:r,url:m,durationMs:D-S,message:T.message})),this.retryRequest(c,n,r??w);throw Bo(this).info(`[${w}] connection ${K?"timed out":"failed"} - error; no more retries left`),Bo(this).debug(`[${w}] connection ${K?"timed out":"failed"} (error; no more retries left)`,hp({retryOfRequestLogID:r,url:m,durationMs:D-S,message:T.message})),K?new eK:new zE({cause:T})}const V=`[${w}${A}] ${f.method} ${m} ${T.ok?"succeeded":"failed"} with status ${T.status} in ${D-S}ms`;if(!T.ok){const L=await this.shouldRetry(T);if(n&&L){const F=`retrying, ${n} attempts remaining`;return await X1e(T.body),Bo(this).info(`${V} - ${F}`),Bo(this).debug(`[${w}] response error (${F})`,hp({retryOfRequestLogID:r,url:T.url,status:T.status,headers:T.headers,durationMs:D-S})),this.retryRequest(c,n,r??w,T.headers)}const K=L?"error; no more retries left":"error; not retryable";Bo(this).info(`${V} - ${K}`);const Z=await T.text().catch(F=>rj(F).message),q=q1e(Z),B=q?void 0:Z;throw Bo(this).debug(`[${w}] response error (${K})`,hp({retryOfRequestLogID:r,url:T.url,status:T.status,headers:T.headers,message:B,durationMs:Date.now()-S})),this.makeStatusError(T.status,q,B,T.headers)}return Bo(this).info(V),Bo(this).debug(`[${w}] response start`,hp({retryOfRequestLogID:r,url:T.url,status:T.status,headers:T.headers,durationMs:D-S})),{response:T,options:c,controller:C,requestLogID:w,retryOfRequestLogID:r,startTime:S}}async fetchWithTimeout(t,n,r,i){const a=n||{},{signal:o,method:c}=a,h=W2(a,["signal","method"]),f=this._makeAbort(i);o&&o.addEventListener("abort",f,{once:!0});const m=setTimeout(f,r),y=globalThis.ReadableStream&&h.body instanceof globalThis.ReadableStream||typeof h.body=="object"&&h.body!==null&&Symbol.asyncIterator in h.body,w=Object.assign(Object.assign(Object.assign({signal:i.signal},y?{duplex:"half"}:{}),{method:"GET"}),h);c&&(w.method=c.toUpperCase());try{return await this.fetch.call(void 0,t,w)}finally{clearTimeout(m)}}async shouldRetry(t){const n=t.headers.get("x-should-retry");return n==="true"?!0:n==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,n,r,i){var a;let o;const c=i==null?void 0:i.get("retry-after-ms");if(c){const f=parseFloat(c);Number.isNaN(f)||(o=f)}const h=i==null?void 0:i.get("retry-after");if(h&&!o){const f=parseFloat(h);Number.isNaN(f)?o=Date.parse(h)-Date.now():o=f*1e3}if(o===void 0){const f=(a=t.maxRetries)!==null&&a!==void 0?a:this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(n,f)}return await W1e(o),this.makeRequest(t,n-1,r)}calculateDefaultRetryTimeoutMillis(t,n){const a=n-t,o=Math.min(.5*Math.pow(2,a),8),c=1-Math.random()*.25;return o*c*1e3}async buildRequest(t,{retryCount:n=0}={}){var r,i,a;const o=Object.assign({},t),{method:c,path:h,query:f,defaultBaseURL:m}=o,y=this.buildURL(h,f,m);"timeout"in o&&G1e("timeout",o.timeout),o.timeout=(r=o.timeout)!==null&&r!==void 0?r:this.timeout;const{bodyHeaders:w,body:A}=this.buildBody({options:o}),S=await this.buildHeaders({options:t,method:c,bodyHeaders:w,retryCount:n});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:c,headers:S},o.signal&&{signal:o.signal}),globalThis.ReadableStream&&A instanceof globalThis.ReadableStream&&{duplex:"half"}),A&&{body:A}),(i=this.fetchOptions)!==null&&i!==void 0?i:{}),(a=o.fetchOptions)!==null&&a!==void 0?a:{}),url:y,timeout:o.timeout}}async buildHeaders({options:t,method:n,bodyHeaders:r,retryCount:i}){let a={};this.idempotencyHeader&&n!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),a[this.idempotencyHeader]=t.idempotencyKey);const o=await this.authHeaders(t);let c=Jx([a,{Accept:"application/json","User-Agent":this.getUserAgent()},this._options.defaultHeaders,r,t.headers,o]);return this.validateHeaders(c),c.values}_makeAbort(t){return()=>t.abort()}buildBody({options:{body:t,headers:n}}){if(!t)return{bodyHeaders:void 0,body:void 0};const r=Jx([n]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&r.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:Y1e(t)}:typeof t=="object"&&r.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(t)}:this.encoder({body:t,headers:r})}}FE.DEFAULT_TIMEOUT=6e4;class co extends FE{constructor(){super(...arguments),this.interactions=new gK(this)}}yK=co;co.GeminiNextGenAPIClient=yK;co.GeminiNextGenAPIClientError=yc;co.APIError=Ko;co.APIConnectionError=zE;co.APIConnectionTimeoutError=eK;co.APIUserAbortError=ij;co.NotFoundError=iK;co.ConflictError=sK;co.RateLimitError=oK;co.BadRequestError=tK;co.AuthenticationError=nK;co.InternalServerError=lK;co.PermissionDeniedError=rK;co.UnprocessableEntityError=aK;co.toFile=iye;co.Interactions=gK;const gye=()=>(console.warn("GEMINI_API_KEY is missing. Search suggestions will be disabled."),null),xye=async(e,t)=>{if(!e||e.length<2)return[];const n=gye();if(!n)return[];try{const r=await n.models.generateContent({model:"gemini-3.1-flash-lite",contents:`User is searching for: "${e}". Available article titles: ${t.join(", ")}. Suggest 5 relevant search terms or short phrases that help the user find what they are looking for based on the titles. Return strictly as a JSON array of strings.`,config:{responseMimeType:"application/json"}}),i=JSON.parse(r.text||"[]");return Array.isArray(i)?i:[]}catch(r){return console.error("Gemini Search Suggester Error:",r),[]}};let Y9=0;function bK(e="random"){try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;const n=new t;n.state==="suspended"&&n.resume().catch(()=>null);const r=n.currentTime,i=(o,c,h,f=.25,m="sine")=>{const y=n.createOscillator(),w=n.createGain();y.type=m,y.frequency.setValueAtTime(o,c),w.gain.setValueAtTime(0,c),w.gain.linearRampToValueAtTime(f,c+.008),w.gain.exponentialRampToValueAtTime(1e-4,c+h),y.connect(w),w.connect(n.destination),y.start(c),y.stop(c+h);const A=n.createOscillator(),S=n.createGain();A.type="sine",A.frequency.setValueAtTime(o*2,c),S.gain.setValueAtTime(0,c),S.gain.linearRampToValueAtTime(f*.15,c+.005),S.gain.exponentialRampToValueAtTime(1e-4,c+h*.6),A.connect(S),S.connect(n.destination),A.start(c),A.stop(c+h*.6)};let a=e;if(a==="random"){const o=["marimba","crystal","harmonic_bell","chime_triad"];a=o[Y9%o.length],Y9++}switch(a){case"marimba":i(1046.5,r,.18,.22,"triangle"),i(1318.51,r+.08,.2,.22,"triangle"),i(1567.98,r+.16,.22,.25,"sine"),i(2093,r+.24,.4,.28,"sine");break;case"crystal":i(1318.51,r,.22,.2,"sine"),i(1760,r+.1,.25,.24,"sine"),i(2217.46,r+.2,.45,.28,"sine");break;case"harmonic_bell":i(880,r,.45,.18,"sine"),i(1108.73,r+.05,.45,.2,"sine"),i(1318.51,r+.1,.5,.22,"sine"),i(1760,r+.15,.6,.25,"sine");break;case"chime_triad":default:i(783.99,r,.15,.2,"sine"),i(1174.66,r+.08,.18,.22,"sine"),i(1567.98,r+.16,.22,.25,"sine"),i(1975.53,r+.24,.42,.28,"sine");break}}catch(t){console.warn("Sweet audio chime play error:",t)}}function yye(e){bK("random")}async function vK(){if(typeof window>"u"||!("Notification"in window))return!1;if("serviceWorker"in navigator)try{await navigator.serviceWorker.register("/sw.js")}catch(e){console.warn("SW Registration attempt:",e)}return Notification.permission==="granted"?!0:Notification.permission!=="denied"?await Notification.requestPermission()==="granted":!1}function _1(e,t){if(bK((t==null?void 0:t.toneStyle)||"random"),typeof navigator<"u"&&"vibrate"in navigator)try{navigator.vibrate([120,80,120])}catch{}if(typeof window>"u"||!("Notification"in window))return;const n={icon:(t==null?void 0:t.icon)||"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",badge:(t==null?void 0:t.badge)||"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",vibrate:[120,80,120],requireInteraction:!1,...t!=null&&t.image?{image:t.image}:{},...t},r=async()=>{if("serviceWorker"in navigator)try{const i=await navigator.serviceWorker.ready;if(i&&"showNotification"in i){await i.showNotification(e,n);return}}catch(i){console.warn("ServiceWorker showNotification fallback:",i)}try{new Notification(e,n)}catch(i){console.warn("Native Notification error:",i)}};Notification.permission==="granted"?r():Notification.permission!=="denied"&&Notification.requestPermission().then(i=>{i==="granted"&&r()})}const bye=({onSearch:e,activeTab:t,setActiveTab:n,isAdmin:r,onAdminClick:i,latestArticles:a=[],openAuth:o,customPagesList:c=[],setSelectedCustomPage:h,selectedCustomPage:f,onScanClick:m,onOpenChat:y})=>{const[w,A]=I.useState(!1),[S,C]=I.useState(!1),[T,D]=I.useState(""),V=async()=>{try{window.open("https://link.thelocalrent.com/v?t=1786099107&tk=07c43b29b01fcaf275f96eea938d430f","_blank"),pe.success("Opening Campus Eye Mobile App Link...",{icon:"📱"})}catch{pe.error("Failed to open App download link.")}},L=()=>{const ue=localStorage.getItem("campus_eye_theme")||"light";let Se="light";ue==="light"?Se="dark":ue==="dark"?Se="sepia":Se="light",localStorage.setItem("campus_eye_theme",Se),window.dispatchEvent(new CustomEvent("theme-changed",{detail:{theme:Se}}));const Qe=Se.charAt(0).toUpperCase()+Se.slice(1);pe.success(`${Qe} theme applied successfully.`)},[K,Z]=I.useState([]),[q,B]=I.useState([]),[z,F]=I.useState(!1),[$,Y]=I.useState(Ne.currentUser),[X,J]=I.useState(!navigator.onLine);I.useEffect(()=>{const ue=()=>J(!1),Se=()=>J(!0);return window.addEventListener("online",ue),window.addEventListener("offline",Se),()=>{window.removeEventListener("online",ue),window.removeEventListener("offline",Se)}},[]),I.useEffect(()=>{const ue=Ne.onAuthStateChanged(Qe=>{Y(Qe)}),Se=()=>A(!0);return window.addEventListener("openGlobalSearch",Se),()=>{ue(),window.removeEventListener("openGlobalSearch",Se)}},[]);const[ye,ne]=I.useState([]),[de,be]=I.useState([]),[Ce,Ke]=I.useState([]),[G,se]=I.useState(!1),[xe,re]=I.useState("inbox"),[Me,nt]=I.useState("all"),[ze,Tt]=I.useState(!1),[It,ft]=I.useState(!1),[Ee,yt]=I.useState({}),[Ue,Vt]=I.useState({}),[St,tn]=I.useState({});I.useEffect(()=>{const ue=()=>{se(!1)};return window.addEventListener("open-imessage-friend",ue),()=>window.removeEventListener("open-imessage-friend",ue)},[]);const Pt=(ue,Se)=>{Se&&Se.stopPropagation(),yt(Qe=>({...Qe,[ue]:!Qe[ue]}))},Nt=async(ue,Se)=>{var Fn;Se&&Se.stopPropagation();const Qe=(Fn=Ue[ue.id])==null?void 0:Fn.trim(),Gt=ue.senderId||(ue.type==="direct_message"?ue.userId:null);if(!(!Qe||!Gt||!$)){tn(xn=>({...xn,[ue.id]:!0}));try{const xn=$.displayName||"Campus Peer",kn=($.displayName||"member").toLowerCase().replace(/\s+/g,"");await ur(et(he,"notifications"),{userId:Gt,senderId:$.uid,senderName:xn,senderUsername:kn,senderPhotoURL:$.photoURL||"",title:`💬 Direct Reply from ${xn}`,message:Qe,type:"direct_message",canReply:!0,used:!1,replyToTitle:ue.title||"Inbox Message",createdAt:new Date}),pe.success(`Reply sent to ${ue.senderName||"friend"}!`,{icon:"📩"}),Vt(xt=>({...xt,[ue.id]:""})),Ft(ue)}catch(xn){pe.error("Failed to send reply: "+xn.message)}finally{tn(xn=>({...xn,[ue.id]:!1}))}}},Kt=ue=>{if(!ue)return"Recent";const Se=ue instanceof Date?ue:new Date(ue);if(isNaN(Se.getTime()))return"Recent";const Gt=Math.floor((new Date().getTime()-Se.getTime())/1e3);if(Gt<60)return"Just now";const Fn=Math.floor(Gt/60);if(Fn<60)return`${Fn}m ago`;const xn=Math.floor(Fn/60);if(xn<24)return`${xn}h ago`;const kn=Math.floor(xn/24);return kn<7?`${kn}d ago`:Se.toLocaleDateString([],{month:"short",day:"numeric"})},ut=ue=>{const Se=ue.type==="direct_message",Qe=ue.userId==="all"||ue.type==="broadcast"||ue.type==="broadcast_announcement"||ue.isBroadcast,Gt=ue.type==="invite"||ue.type==="lounge_invite",Fn=!!ue.code||ue.type==="ticket"||ue.type==="ticket_code"||ue.type==="pass",xn=ue.forAdmin||ue.type==="unlimited_posting_request"||ue.type==="mega_ai_query"||ue.type==="admin_alert",kn=ue.type==="mega_ai_reply"||ue.type==="admin_mega_reply"||ue.type==="mega_ai",xt=ue.type==="like"||ue.type==="reaction"||ue.title&&ue.title.toLowerCase().includes("like"),$n=ue.type==="comment"||ue.type==="reply"||ue.type==="dispatch_reply"||ue.title&&(ue.title.toLowerCase().includes("comment")||ue.title.toLowerCase().includes("replied")||ue.title.toLowerCase().includes("dispatch")),Et=ue.type==="follow"||ue.type==="follower",je=ue.type==="article"||ue.type==="new_post";return Se?{category:"social",typeLabel:"💬 DIRECT INBOX",borderClass:"border-l-4 border-l-indigo-600",bgClass:ue.used?"bg-indigo-50/20 border-indigo-200/50 opacity-75":"bg-indigo-50/80 border-indigo-300 shadow-2xs",badgeClass:"bg-indigo-600 text-white font-black",iconBg:"bg-indigo-100 text-indigo-700",IconComponent:ea}:Qe?{category:"broadcast",typeLabel:"📢 BROADCAST",borderClass:"border-l-4 border-l-amber-500",bgClass:ue.used?"bg-amber-50/20 border-amber-200/50 opacity-75":"bg-amber-50/70 border-amber-300 shadow-2xs",badgeClass:"bg-amber-500 text-white font-black",iconBg:"bg-amber-100 text-amber-700",IconComponent:vu}:Gt?{category:"social",typeLabel:"🤝 INVITE",borderClass:"border-l-4 border-l-emerald-500",bgClass:ue.used?"bg-emerald-50/20 border-emerald-200/50 opacity-75":"bg-emerald-50/70 border-emerald-300 shadow-2xs",badgeClass:"bg-emerald-600 text-white font-black",iconBg:"bg-emerald-100 text-emerald-700",IconComponent:Np}:Fn?{category:"passes",typeLabel:"🎟️ PASS KEY",borderClass:"border-l-4 border-l-purple-500",bgClass:ue.used?"bg-purple-50/20 border-purple-200/50 opacity-75":"bg-purple-50/70 border-purple-300 shadow-2xs",badgeClass:"bg-purple-600 text-white font-black",iconBg:"bg-purple-100 text-purple-700",IconComponent:Aa}:xn?{category:"system",typeLabel:"🛡️ ADMIN ALERT",borderClass:"border-l-4 border-l-red-600",bgClass:ue.used?"bg-red-50/20 border-red-200/50 opacity-75":"bg-red-50/80 border-red-300 shadow-2xs",badgeClass:"bg-red-700 text-white font-black",iconBg:"bg-red-100 text-red-700",IconComponent:gie}:kn?{category:"system",typeLabel:"🤖 MEGA AI",borderClass:"border-l-4 border-l-cyan-500",bgClass:ue.used?"bg-cyan-50/20 border-cyan-200/50 opacity-75":"bg-cyan-50/70 border-cyan-300 shadow-2xs",badgeClass:"bg-cyan-700 text-white font-black",iconBg:"bg-cyan-100 text-cyan-700",IconComponent:Dne}:xt?{category:"social",typeLabel:"❤️ REACTION",borderClass:"border-l-4 border-l-rose-500",bgClass:ue.used?"bg-rose-50/20 border-rose-200/50 opacity-75":"bg-rose-50/70 border-rose-300 shadow-2xs",badgeClass:"bg-rose-600 text-white font-black",iconBg:"bg-rose-100 text-rose-700",IconComponent:mc}:$n?{category:"social",typeLabel:"💬 DISPATCH REPLY",borderClass:"border-l-4 border-l-indigo-500",bgClass:ue.used?"bg-indigo-50/20 border-indigo-200/50 opacity-75":"bg-indigo-50/70 border-indigo-300 shadow-2xs",badgeClass:"bg-indigo-600 text-white font-black",iconBg:"bg-indigo-100 text-indigo-700",IconComponent:Kp}:Et?{category:"social",typeLabel:"👥 FOLLOWER",borderClass:"border-l-4 border-l-blue-500",bgClass:ue.used?"bg-blue-50/20 border-blue-200/50 opacity-75":"bg-blue-50/70 border-blue-300 shadow-2xs",badgeClass:"bg-blue-600 text-white font-black",iconBg:"bg-blue-100 text-blue-700",IconComponent:ey}:je?{category:"broadcast",typeLabel:"📰 FRESH STORY",borderClass:"border-l-4 border-l-sky-500",bgClass:ue.used?"bg-sky-50/20 border-sky-200/50 opacity-75":"bg-sky-50/70 border-sky-300 shadow-2xs",badgeClass:"bg-sky-600 text-white font-black",iconBg:"bg-sky-100 text-sky-700",IconComponent:Fh}:{category:"social",typeLabel:ue.type?`🔔 ${ue.type.toUpperCase()}`:"🔔 NOTIFICATION",borderClass:"border-l-4 border-l-gray-400",bgClass:ue.used?"bg-gray-50/40 border-gray-150 opacity-75":"bg-white border-gray-200 shadow-2xs",badgeClass:"bg-gray-800 text-white font-black",iconBg:"bg-gray-100 text-gray-700",IconComponent:Ou}},[Jt,Dt]=I.useState(()=>{try{const ue=localStorage.getItem("clicked_notification_links");return ue?JSON.parse(ue):{}}catch{return{}}}),hn=ue=>{ue&&Dt(Se=>{const Qe={...Se,[ue]:!0};try{localStorage.setItem("clicked_notification_links",JSON.stringify(Qe))}catch(Gt){console.warn("Could not save clicked links:",Gt)}return Qe})},[qn,mn]=I.useState([]),[vr,Ve]=I.useState([]),[Mt,cn]=I.useState([]),[dn,mr]=I.useState([]),[gr,wi]=I.useState({}),[Xt,me]=I.useState("");I.useEffect(()=>{if(!$){mn([]),wi({}),Ve([]),cn([]),mr([]);return}(async()=>{try{const Se=Qt(et(he,"users"),vi(50)),Qe=Qt(et(he,"invitations"),vi(50)),Gt=Qt(et(he,"posts"),vi(45)),Fn=Qt(et(he,"adverts"),vi(30)),xn=Qt(et(he,"pinned_announcements"),vi(15)),[kn,xt,$n,Et,je]=await Promise.all([vn(Se),vn(Qe),vn(Gt),vn(Fn),vn(xn)]),bt=kn.docs.map(Ut=>({uid:Ut.id,...Ut.data()})).filter(Ut=>Ut.uid!==($==null?void 0:$.uid));mn(bt);const yn={};xt.docs.forEach(Ut=>{const On=Ut.data();On.senderId===($==null?void 0:$.uid)&&(yn[On.receiverId]=!0)}),wi(yn),Ve($n.docs.map(Ut=>({id:Ut.id,...Ut.data()}))),cn(Et.docs.map(Ut=>({id:Ut.id,...Ut.data()}))),mr(je.docs.map(Ut=>({id:Ut.id,...Ut.data()})))}catch(Se){console.warn("Silent ignored database initial fetches inside navbar:",Se)}})()},[$]);const qe=async ue=>{var Qe,Gt;if(!$){pe.error("Please sign in to invite peers!");return}const Se=`${$.uid}_${ue.uid}`;try{wi(Fn=>({...Fn,[ue.uid]:!0})),await Rr(Je(he,"invitations",Se),{id:Se,senderId:$.uid,senderName:$.displayName||((Qe=$.email)==null?void 0:Qe.split("@")[0])||"Peer",senderPhotoURL:$.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent($.displayName||"Peer")}&background=random`,receiverId:ue.uid,receiverName:ue.displayName||((Gt=ue.email)==null?void 0:Gt.split("@")[0])||"Peer",status:"pending",createdAt:En()}),pe.success(`Lounge invite sent to @${(ue.displayName||"peer").toLowerCase().replace(/\s+/g,"")}!`,{icon:"🚀"})}catch(Fn){pe.error("Failed to send invite: "+Fn.message)}};I.useEffect(()=>{if(!$){ne([]),be([]);return}const ue=Qt(et(he,"notifications"),Ar("userId","==",$.uid));let Se=!0,Qe={},Gt={};const Fn=()=>{const bt={...Qe,...Gt},yn=Object.values(bt);yn.sort((Ut,On)=>On.createdAt.getTime()-Ut.createdAt.getTime()),be(yn)},xn=Wr(ue,bt=>{bt.docs.forEach(yn=>{var On;const Ut=yn.data();Qe[yn.id]={id:yn.id,...Ut,createdAt:(On=Ut.createdAt)!=null&&On.toDate?Ut.createdAt.toDate():new Date(Ut.createdAt||Date.now())}}),Se||bt.docChanges().forEach(yn=>{if(yn.type==="added"){const Ut=yn.doc.data();_1(Ut.title||"✨ Campus Eye Notification",{body:Ut.message||"You have a new dispatch notification in your inbox.",senderId:Ut.senderId,senderName:Ut.senderName,id:yn.doc.id,tag:`notif-${yn.doc.id}`})}}),Se=!1,Fn()},bt=>{console.warn("Silent notification snapshot error:",bt)}),kn=Qt(et(he,"notifications"),Ar("userId","==","all"));let xt=!0;const $n=Wr(kn,bt=>{bt.docs.forEach(yn=>{var On;const Ut=yn.data();Qe[yn.id]={id:yn.id,...Ut,createdAt:(On=Ut.createdAt)!=null&&On.toDate?Ut.createdAt.toDate():new Date(Ut.createdAt||Date.now())}}),xt||bt.docChanges().forEach(yn=>{if(yn.type==="added"){const Ut=yn.doc.data();_1(Ut.title||"📢 Campus Eye Broadcast",{body:Ut.message||"New broadcast announcement released on Campus Eye."})}}),xt=!1,Fn()},bt=>{console.warn("Silent broadcast notification snapshot error:",bt)});let Et=null;if(r){let bt=!0;const yn=Qt(et(he,"notifications"),Ar("forAdmin","==",!0));Et=Wr(yn,Ut=>{Ut.docs.forEach(On=>{var ji;const Mr=On.data();Gt[On.id]={id:On.id,...Mr,createdAt:(ji=Mr.createdAt)!=null&&ji.toDate?Mr.createdAt.toDate():new Date(Mr.createdAt||Date.now())}}),bt||Ut.docChanges().forEach(On=>{if(On.type==="added"){const Mr=On.doc.data();_1(Mr.title||"🛡️ Admin Alert",{body:Mr.message||"New system alert or dispatch query in Admin Console."})}}),bt=!1,Fn()},Ut=>{console.warn("Silent admin notification snapshot error:",Ut)})}const je=Qt(et(he,"invitations"),Ar("receiverId","==",$.uid),Ar("status","==","pending")),ln=Wr(je,bt=>{const yn=bt.docs.map(Ut=>({id:Ut.id,...Ut.data()}));ne(yn)},bt=>{console.warn("Silent invites snapshot error:",bt)});return()=>{xn(),$n(),Et&&Et(),ln()}},[$]),I.useEffect(()=>{if(!$){Ke([]);return}const ue=Qt(et(he,"direct_messages"),Ar("senderId","==",$.uid)),Se=Qt(et(he,"direct_messages"),Ar("receiverId","==",$.uid));let Qe=[],Gt=[];const Fn=()=>{const xt=[...Qe,...Gt],$n=new Map;xt.forEach(je=>{var ji,rs;const ln=je.senderId===$.uid,bt=ln?je.receiverId:je.senderId;if(!bt)return;const yn=(ji=je.createdAt)!=null&&ji.toDate?je.createdAt.toDate():(rs=je.createdAt)!=null&&rs.seconds?new Date(je.createdAt.seconds*1e3):new Date(je.createdAt||Date.now()),Ut=$n.get(bt),On=Ut!=null&&Ut.lastTimestamp?Ut.lastTimestamp instanceof Date?Ut.lastTimestamp:new Date(Ut.lastTimestamp):new Date(0),Mr=!ln&&!je.read;if(!Ut||yn.getTime()>On.getTime()){const pi=qn.find(mi=>mi.uid===bt);$n.set(bt,{peerUid:bt,peerName:(pi==null?void 0:pi.displayName)||je.senderName||"Campus Friend",peerUsername:(pi==null?void 0:pi.username)||je.senderUsername||"peer",peerPhoto:(pi==null?void 0:pi.photoURL)||je.senderPhotoURL||`https://api.dicebear.com/7.x/bottts/svg?seed=${bt}`,lastMessage:je.text||(je.imageUrl?"📷 Photo Attachment":"Message"),lastTimestamp:yn,unreadCount:((Ut==null?void 0:Ut.unreadCount)||0)+(Mr?1:0)})}else Mr&&(Ut.unreadCount+=1)});const Et=Array.from($n.values()).sort((je,ln)=>ln.lastTimestamp.getTime()-je.lastTimestamp.getTime());Ke(Et)},xn=Wr(ue,xt=>{Qe=xt.docs.map($n=>({id:$n.id,...$n.data()})),Fn()},xt=>console.warn("Sent direct_messages sub error:",xt)),kn=Wr(Se,xt=>{Gt=xt.docs.map($n=>({id:$n.id,...$n.data()})),Fn()},xt=>console.warn("Recv direct_messages sub error:",xt));return()=>{xn(),kn()}},[$,qn]);const st=async ue=>{try{await Cn(Je(he,"invitations",ue.id),{status:"accepted"});const Se=En();await Rr(Je(he,"follows",`${$==null?void 0:$.uid}_${ue.senderId}`),{followerId:$==null?void 0:$.uid,followedId:ue.senderId,createdAt:Se}),await Rr(Je(he,"follows",`${ue.senderId}_${$==null?void 0:$.uid}`),{followerId:ue.senderId,followedId:$==null?void 0:$.uid,createdAt:Se}),pe.success(`Connected in Lounge with @${ue.senderName.toLowerCase().replace(/\s+/g,"")}!`,{icon:"🤝"}),n("posts"),se(!1)}catch(Se){pe.error("Failed to accept invitation: "+Se.message)}},dt=async ue=>{try{await si(Je(he,"invitations",ue.id)),pe.success("Invitation declined.")}catch(Se){pe.error("Failed to decline: "+Se.message)}},An=async(ue,Se)=>{Se==null||Se.stopPropagation();try{await si(Je(he,"notifications",ue)),be(Qe=>Qe.filter(Gt=>Gt.id!==ue)),pe.success("Notification removed",{icon:"🗑️"})}catch(Qe){pe.error("Failed to delete notification: "+Qe.message)}},Ft=async ue=>{if(!ue.used)try{await Cn(Je(he,"notifications",ue.id),{used:!0}),be(Se=>Se.map(Qe=>Qe.id===ue.id?{...Qe,used:!0}:Qe))}catch(Se){console.warn("Failed to mark notification read:",Se)}},Dn=async ue=>{if(Ft(ue),se(!1),ue.type==="direct_message"||ue.senderId&&!ue.postId&&!ue.articleId){const Se={uid:ue.senderId,displayName:ue.senderName||"Campus Peer",username:ue.senderUsername||(ue.senderName||"peer").toLowerCase().replace(/\s+/g,""),photoURL:ue.senderPhotoURL||""};y&&y(Se),window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:Se}));return}ue.postId?(n("posts"),setTimeout(()=>{const Se=ue.commentId?`comment-${ue.commentId}`:`post-card-${ue.postId}`,Qe=document.getElementById(Se)||document.getElementById(`post-card-${ue.postId}`);Qe&&(Qe.scrollIntoView({behavior:"smooth",block:"center"}),Qe.classList.add("ring-4","ring-amber-500","ring-offset-2"),setTimeout(()=>Qe.classList.remove("ring-4","ring-amber-500","ring-offset-2"),3500))},500)):ue.articleId&&(n("home"),setTimeout(()=>{const Se=ue.commentId?`comment-${ue.commentId}`:`article-${ue.articleId}`,Qe=document.getElementById(Se)||document.getElementById(`article-${ue.articleId}`);Qe&&(Qe.scrollIntoView({behavior:"smooth",block:"center"}),Qe.classList.add("ring-4","ring-amber-500","ring-offset-2"),setTimeout(()=>Qe.classList.remove("ring-4","ring-amber-500","ring-offset-2"),3500))},500))},Ot=async()=>{if($)if(xe==="inbox"){if(de.length===0||!window.confirm("Are you sure you want to completely delete all inbox alerts?"))return;try{await Promise.all(de.map(ue=>si(Je(he,"notifications",ue.id)))),pe.success("Inbox notifications cleared!",{icon:"🗑️"})}catch(ue){pe.error("Failed to empty inbox: "+ue.message)}}else{if(ye.length===0||!window.confirm("Are you sure you want to dismiss all pending invites?"))return;try{await Promise.all(ye.map(ue=>si(Je(he,"invitations",ue.id)))),pe.success("Invites dismissed!",{icon:"🗑️"})}catch(ue){pe.error("Failed to empty invites: "+ue.message)}}};I.useEffect(()=>{const ue=(Qe,Gt)=>{const Fn=Qe?Qe.slice(0,2).trim().toUpperCase():"CE",xn=(Gt==null?void 0:Gt.toLowerCase())||"news";let kn="%23ef4444";return xn==="sports"&&(kn="%233b82f6"),xn==="opinion"&&(kn="%2310b981"),xn==="lifestyle"&&(kn="%238b5cf6"),xn==="entertainment"&&(kn="%23f59e0b"),`data:image/svg+xml;utf8,${Fn}`},Se=setTimeout(async()=>{if(T.trim().length>1){const Qe=T.toLowerCase(),Gt=[];if(a.forEach(xt=>{var yn,Ut,On,Mr,ji,rs;const $n=(yn=xt.title)==null?void 0:yn.toLowerCase().includes(Qe),Et=(Ut=xt.content)==null?void 0:Ut.toLowerCase().includes(Qe),je=(On=xt.summary)==null?void 0:On.toLowerCase().includes(Qe),ln=(Mr=xt.category)==null?void 0:Mr.toLowerCase().includes(Qe),bt=(ji=xt.authorName)==null?void 0:ji.toLowerCase().includes(Qe);($n||Et||je||ln||bt)&&Gt.push({id:xt.id,type:"article",title:xt.title,subtitle:xt.summary||((rs=xt.content)==null?void 0:rs.slice(0,80)),category:xt.category||"Opinion",imageUrl:xt.featuredImageUrl||ue(xt.title,xt.category),originalObject:xt})}),vr.forEach(xt=>{var ln,bt,yn,Ut;const $n=(ln=xt.text)==null?void 0:ln.toLowerCase().includes(Qe),Et=(bt=xt.authorName)==null?void 0:bt.toLowerCase().includes(Qe),je=(yn=xt.category)==null?void 0:yn.toLowerCase().includes(Qe);($n||Et||je)&&Gt.push({id:xt.id,type:"post",title:((Ut=xt.text)==null?void 0:Ut.slice(0,50))||"Lounge Conversation",subtitle:`Active discussion by @${(xt.authorName||"peer").toLowerCase().replace(/\s+/g,"")}`,category:`Forum • ${xt.category||"Opinion"}`,imageUrl:xt.imageUrl||xt.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(xt.authorName||"Peer")}`,originalObject:xt})}),qn.forEach(xt=>{var ln,bt,yn,Ut;const $n=(ln=xt.displayName)==null?void 0:ln.toLowerCase().includes(Qe),Et=(bt=xt.email)==null?void 0:bt.toLowerCase().includes(Qe),je=(yn=xt.role)==null?void 0:yn.toLowerCase().includes(Qe);($n||Et||je)&&Gt.push({id:xt.uid,type:"user",title:xt.displayName||((Ut=xt.email)==null?void 0:Ut.split("@")[0])||"User Profile",subtitle:`${xt.role==="admin"?"🛡️ Campus Administrator":"🎓 Lounge Member"} • @${(xt.displayName||"user").toLowerCase().replace(/\s+/g,"")}`,category:xt.role==="admin"?"Admins":"Users",imageUrl:xt.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(xt.displayName||"u")}`,originalObject:xt})}),Mt.forEach(xt=>{var ln,bt,yn;const $n=(ln=xt.title)==null?void 0:ln.toLowerCase().includes(Qe),Et=(bt=xt.brand)==null?void 0:bt.toLowerCase().includes(Qe),je=(yn=xt.description)==null?void 0:yn.toLowerCase().includes(Qe);($n||Et||je)&&Gt.push({id:xt.id,type:"advert",title:xt.title||"Brand Advertisement Offer",subtitle:`${xt.brand||"Promotional Offer"} — ${xt.description||"Sponsored partnership dispatch"}`,category:"Business Adverts",imageUrl:xt.imageUrl||ue(xt.title,"Business Adverts"),originalObject:xt})}),dn.forEach(xt=>{var je,ln;const $n=(je=xt.title)==null?void 0:je.toLowerCase().includes(Qe),Et=(ln=xt.description)==null?void 0:ln.toLowerCase().includes(Qe);($n||Et)&&Gt.push({id:xt.id,type:"pinned",title:xt.title||"Pinned notice announcement",subtitle:xt.description||"Pinned global campus broadcast notice",category:"Pinned Highlights",imageUrl:xt.imageUrl||ue(xt.title,"Pinned Highlights"),originalObject:xt})}),c.forEach(xt=>{var je,ln;const $n=(je=xt.title)==null?void 0:je.toLowerCase().includes(Qe),Et=(ln=xt.content)==null?void 0:ln.toLowerCase().includes(Qe);($n||Et)&&Gt.push({id:xt.id,type:"customPage",title:xt.title||"Dynamic Publication Tab",subtitle:"Custom institutional publication page",category:"Custom Pages",imageUrl:ue(xt.title,"Custom Pages"),originalObject:xt})}),Gt.length<5)try{(await vn(Qt(et(he,"articles"),vi(80)))).docs.forEach($n=>{var ln,bt,yn,Ut,On,Mr;const Et={id:$n.id,...$n.data()};if(!Gt.some(ji=>ji.id===$n.id)){const ji=(ln=Et.title)==null?void 0:ln.toLowerCase().includes(Qe),rs=(bt=Et.content)==null?void 0:bt.toLowerCase().includes(Qe),pi=(yn=Et.summary)==null?void 0:yn.toLowerCase().includes(Qe),mi=(Ut=Et.category)==null?void 0:Ut.toLowerCase().includes(Qe),vs=(On=Et.authorName)==null?void 0:On.toLowerCase().includes(Qe);if((ji||rs||pi||mi||vs)&&(Gt.push({id:$n.id,type:"article",title:Et.title,subtitle:Et.summary||((Mr=Et.content)==null?void 0:Mr.slice(0,80)),category:Et.category||"Opinion",imageUrl:Et.featuredImageUrl||ue(Et.title,Et.category),originalObject:Et}),Et.title)){const gi=Et.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),$r=`${window.location.origin}/articles=${gi}/${$n.id}`;fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:$r,title:Et.title,image:Et.featuredImageUrl})}).catch(()=>{})}}})}catch(xt){console.warn("Deep Firestore search lookup notice:",xt)}const Fn=["campus","eye","media","campuseyemedia"];if(Qe.split(/\s+/).filter(Boolean).some(xt=>Fn.includes(xt))&&Gt.length<5&&a.forEach(xt=>{var Et;!Gt.some(je=>je.id===xt.id&&je.type==="article")&&Gt.length<10&&Gt.push({id:xt.id,type:"article",title:xt.title,subtitle:xt.summary||((Et=xt.content)==null?void 0:Et.slice(0,80)),category:xt.category||"Feature",imageUrl:xt.featuredImageUrl||ue(xt.title,xt.category),originalObject:xt})}),Z(Gt.slice(0,12)),w){F(!0);const xt=a.map(Et=>Et.title).concat(Gt.slice(0,3).map(Et=>Et.title)),$n=await xye(T,xt);B($n),F(!1)}}else Z([]),B([]);e(T)},500);return()=>clearTimeout(Se)},[T,a,vr,qn,Mt,dn,c,e,w]);const on=()=>{D(""),Z([]),e("")},jr=ue=>{if(D(""),Z([]),A(!1),e(""),ue.type==="article"){const Se=new CustomEvent("selectArticle",{detail:ue.originalObject});window.dispatchEvent(Se)}else if(ue.type==="customPage")h&&h(ue.originalObject);else if(ue.type==="post"){const Se=new CustomEvent("selectPost",{detail:ue.originalObject});window.dispatchEvent(Se)}else if(ue.type==="user"){const Se=new CustomEvent("selectUser",{detail:ue.originalObject});window.dispatchEvent(Se)}else if(ue.type==="advert")if(ue.originalObject.link)window.open(ue.originalObject.link,"_blank","noopener,noreferrer");else{const Se=new CustomEvent("selectAdvert",{detail:ue.originalObject});window.dispatchEvent(Se)}else if(ue.type==="pinned")if(ue.originalObject.link)window.open(ue.originalObject.link,"_blank","noopener,noreferrer");else{const Se=new CustomEvent("selectPinned",{detail:ue.originalObject});window.dispatchEvent(Se)}},lr=ie.useMemo(()=>{const ue=xn=>{if(!xn)return"";let kn=xn.toLowerCase().trim().replace(/[^a-z0-9]/g,"");return(kn==="campusnews"||kn==="news"||kn==="campus-news")&&(kn="news"),(kn==="sports"||kn==="sport")&&(kn="sport"),kn},Qe=Array.from(new Set(a.map(xn=>xn.category).filter(Boolean))).map(xn=>({id:ue(xn),label:xn})),Gt=new Set,Fn=[];return Fn.push({id:"for-you",label:"For You"}),Gt.add("for-you"),Fn.push({id:"home",label:"Home"}),Gt.add("home"),Qe.forEach(xn=>{!Gt.has(xn.id)&&Fn.length<6&&(Gt.add(xn.id),Fn.push(xn))}),Fn.length<=2?[{id:"for-you",label:"For You"},{id:"home",label:"Home"},{id:"news",label:"News"},{id:"sport",label:"Sports"},{id:"business",label:"Business"}]:Fn},[a]);return s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"fixed top-0 left-0 right-0 z-50 bg-white/40 dark:bg-neutral-950/40 backdrop-blur-xl border-b border-white/20 dark:border-white/10 shadow-lg shadow-black/5 backdrop-saturate-150 transition-all duration-300",children:[s.jsxs("div",{className:"w-full max-w-[1680px] xl:max-w-[1780px] 2xl:max-w-[1880px] mx-auto px-2 sm:px-4 lg:px-6 xl:px-8 h-8.5 sm:h-9.5 flex items-center justify-between",children:[s.jsxs("div",{onClick:()=>{n("home"),h&&h(null),window.scrollTo({top:0,behavior:"smooth"})},className:"flex items-center gap-1 sm:gap-1.5 cursor-pointer hover:opacity-80 transition-opacity select-none h-6.5 sm:h-7.5",title:"Campus Eye Media - Scroll to top",children:[s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Campus Eye Logo",className:"h-5 w-5 sm:h-6 sm:w-6 rounded-full border border-gray-950 bg-white object-cover aspect-square shrink-0",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"flex flex-col justify-center text-left select-none -space-y-1",children:[s.jsxs("span",{className:"text-[10.5px] sm:text-[11.5px] md:text-[12.5px] font-serif font-black tracking-custom italic",children:[s.jsx("span",{className:"text-red-650",children:"Campus"})," ",s.jsx("span",{className:"text-blue-600",children:"Eye"})]}),s.jsx("span",{className:"text-[5.5px] sm:text-[6px] md:text-[6.5px] font-sans font-extrabold uppercase tracking-[0.22em] text-black text-right pr-0.5 block select-none",children:"Media"})]})]}),s.jsx("nav",{className:"hidden lg:flex items-center space-x-1",children:lr.map(ue=>{const Se=ue.id==="home";return s.jsxs(ie.Fragment,{children:[s.jsx("button",{onClick:()=>{n(ue.id),h&&h(null)},className:Fe("text-[10px] font-black tracking-wider px-2.5 py-1.5 rounded-full transition-all duration-200 uppercase cursor-pointer",t===ue.id&&!f?"bg-gray-100 text-gray-950 font-black":"text-gray-500 hover:text-gray-950 hover:bg-gray-50"),children:ue.label}),Se&&c&&c.length>0&&(()=>{var $n;const Qe=c[0],Fn=Date.now()-(($n=Qe.createdAt)!=null&&$n.seconds?Qe.createdAt.seconds*1e3:Date.now())<10080*60*1e3,xn=(f==null?void 0:f.id)===Qe.id,kn=c.slice(1),xt=kn.find(Et=>(f==null?void 0:f.id)===Et.id);return s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsxs("button",{onClick:()=>h&&h(Qe),className:Fe("text-[9.5px] font-black tracking-wider px-2.5 py-1.5 rounded-full uppercase flex items-center gap-1.5 cursor-pointer transition-all duration-200 relative border shrink-0",xn?"bg-red-650 border-red-650 text-white shadow-xs":"bg-red-50/70 border-red-150 text-red-650 hover:bg-red-100/40"),title:`Open ${Qe.name} pop-out`,children:[Qe.svgIcon?s.jsx("span",{className:Fe("shrink-0 w-2.5 h-2.5 flex items-center justify-center",xn?"text-white":"text-red-655"),dangerouslySetInnerHTML:{__html:Qe.svgIcon.includes("${Qe.svgIcon}`}}):s.jsx("span",{className:Fe("w-1 h-1 rounded-full shrink-0",xn?"bg-white":"bg-red-655")}),s.jsx("span",{children:Qe.name}),Fn&&s.jsx("span",{className:"absolute -top-1 -right-1 bg-red-600 text-white text-[5px] font-bold uppercase px-1 py-0.2 rounded-full scale-90 select-none shrink-0",children:"New"})]}),kn.length>0&&s.jsxs("div",{className:"relative shrink-0 z-[999]",children:[s.jsxs("button",{onClick:()=>Tt(!ze),className:Fe("text-[9.5px] font-black tracking-wider px-2.5 py-1.5 rounded-full uppercase flex items-center gap-1 cursor-pointer transition-all duration-250 border",xt?"bg-red-650 border-red-650 text-white shadow-xs":"bg-gray-100 border-gray-200 text-gray-700 hover:bg-gray-150"),children:[s.jsx("span",{children:"More"}),xt&&s.jsxs("span",{className:"text-[8px] opacity-90 mx-0.5",children:["(",xt.name,")"]}),s.jsx("svg",{className:Fe("w-2.5 h-2.5 transition-transform duration-200",ze?"rotate-180":"rotate-0"),fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),s.jsx(or,{children:ze&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[49] bg-transparent",onClick:()=>Tt(!1)}),s.jsx(Zt.div,{initial:{opacity:0,scale:.95,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:4},transition:{duration:.12},className:"absolute left-0 mt-1.5 w-44 bg-white border border-gray-150 rounded-xl shadow-2xl z-[99999] py-1 overflow-hidden",children:kn.map(Et=>{const je=(f==null?void 0:f.id)===Et.id;return s.jsxs("button",{onClick:()=>{h&&h(Et),Tt(!1)},className:Fe("w-full text-left px-3.5 py-2 hover:bg-gray-50 text-[9px] font-black uppercase tracking-wider flex items-center justify-between transition-colors",je?"text-red-650 bg-red-50/40":"text-gray-750 hover:text-black"),children:[s.jsx("span",{className:"truncate pr-2",children:Et.name}),je&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-650 shrink-0"})]},Et.id)})})]})})]})]},"custom-nav-group")})()]},ue.id)})}),s.jsxs("div",{className:"flex items-center gap-2.5 sm:gap-3 relative",children:[$&&r&&s.jsx("button",{onClick:m,className:"text-gray-750 hover:text-red-650 p-1 rounded-full hover:bg-gray-100/60 transition-colors flex items-center justify-center cursor-pointer",title:"Passes & Ticket Verification",children:s.jsx(US,{size:14,className:"text-gray-700 hover:text-red-650"})}),s.jsx("button",{onClick:L,className:"text-gray-750 hover:text-red-650 p-1 rounded-full hover:bg-gray-100/60 transition-colors flex items-center justify-center cursor-pointer",title:"Switch Theme",children:s.jsx(Rpe,{size:15})}),s.jsx("button",{onClick:()=>A(!0),className:"text-gray-750 hover:text-red-650 p-1 rounded-full hover:bg-gray-100/60 transition-colors flex items-center justify-center cursor-pointer",title:"Search Stories & Communities",children:s.jsx(Ppe,{size:15})}),$&&s.jsxs("div",{className:"relative",children:[(()=>{const ue=de.filter(Qe=>!Qe.used).length,Se=ue+ye.length;return s.jsxs("button",{onClick:()=>se(!G),className:"text-gray-700 hover:text-gray-950 p-1.5 rounded-full hover:bg-gray-50 transition-all flex items-center justify-center relative cursor-pointer font-sans",title:`${ye.length} Invites, ${ue} Unread Alerts`,children:[s.jsx(Ou,{size:14,className:Fe(Se>0&&"animate-bounce text-red-650")}),Se>0&&s.jsx("span",{className:"absolute -top-1 -right-1.5 px-1 py-0.2 bg-red-650 text-white font-black text-[8px] leading-none rounded-full border-2 border-white shadow-xs flex items-center justify-center min-w-[15px] h-[15px]",children:Se>99?"99+":Se})]})})(),s.jsx(or,{children:G&&s.jsxs(Zt.div,{initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:"fixed sm:absolute top-14 sm:top-auto left-2.5 sm:left-auto right-2.5 sm:right-0 mt-0 sm:mt-2.5 w-[calc(100vw-1.25rem)] sm:w-96 max-w-sm sm:max-w-md bg-white border border-gray-150 rounded-2xl shadow-2xl z-[200] p-3 text-left space-y-3 max-h-[82vh] overflow-y-auto",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between border-b border-gray-100 pb-2 gap-1.5",children:[s.jsx("button",{onClick:()=>n("account"),className:"hidden"}),s.jsxs("div",{className:"flex flex-1 min-w-[190px] gap-1 p-0.5 bg-gray-50 border border-gray-100 rounded-xl",children:[s.jsxs("button",{onClick:()=>re("inbox"),id:"notif-tab-inbox",className:Fe("flex-1 py-1.5 rounded-lg text-center text-[9px] font-black uppercase tracking-wider transition-all cursor-pointer truncate",xe==="inbox"?"bg-white text-gray-950 shadow-2xs":"text-gray-400 hover:text-gray-955"),children:["📩 Inbox (",de.filter(ue=>!ue.used).length,")"]}),s.jsxs("button",{onClick:()=>re("messages"),id:"notif-tab-messages",className:Fe("flex-1 py-1.5 rounded-lg text-center text-[9px] font-black uppercase tracking-wider transition-all cursor-pointer flex items-center justify-center gap-1 truncate",xe==="messages"?"bg-white text-gray-950 shadow-2xs":"text-gray-400 hover:text-gray-955"),children:[s.jsx("span",{children:"💬 Chat"}),Ce.length>0&&s.jsx("span",{className:"px-1 py-0.2 bg-blue-100 text-blue-700 text-[8px] font-extrabold rounded-full",children:Ce.length})]}),s.jsxs("button",{onClick:()=>re("invites"),id:"notif-tab-invites",className:Fe("flex-1 py-1.5 rounded-lg text-center text-[9px] font-black uppercase tracking-wider transition-all cursor-pointer truncate",xe==="invites"?"bg-white text-gray-950 shadow-2xs":"text-gray-400 hover:text-gray-955"),children:["🤝 Invites (",ye.length,")"]})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0 ml-auto",children:[s.jsxs("button",{onClick:async()=>{await vK()?(_1("🔔 Push Notifications Active!",{body:"Campus Eye system notifications will pop up directly on your device screen!",toneStyle:"crystal"}),pe.success("Native Device Push Notifications Enabled!",{icon:"🔔"})):pe("Acoustic chimes active! Allow notifications in browser settings for native popups.",{icon:"🎵"})},className:"px-2 py-1 bg-blue-50 hover:bg-blue-100 text-blue-700 rounded-xl transition-all cursor-pointer shrink-0 border border-blue-200 flex items-center gap-1 text-[9px] font-black uppercase tracking-wider shadow-2xs",title:"Enable Device System Push Notifications & Test Audio Chime",children:[s.jsx(Ou,{size:11,className:"text-blue-600"}),s.jsx("span",{children:"Push"})]}),(xe==="inbox"&&de.length>0||xe==="invites"&&ye.length>0)&&s.jsx("button",{onClick:Ot,className:"p-1.5 bg-gray-50 hover:bg-red-50 text-gray-500 hover:text-red-650 rounded-xl transition-all cursor-pointer shrink-0 border border-transparent hover:border-red-150",title:xe==="inbox"?"Empty and delete all alerts":"Decline and dismiss all invites",children:s.jsx(As,{size:13})})]})]}),xe==="inbox"&&de.length>0&&s.jsx("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 no-scrollbar border-b border-gray-100",children:[{id:"all",label:"All",icon:"📬"},{id:"broadcast",label:"Broadcasts",icon:"📢"},{id:"social",label:"Social & Replies",icon:"💬"},{id:"passes",label:"Pass Keys",icon:"🎟️"},{id:"system",label:"System & AI",icon:"🛡️"}].map(ue=>{const Se=de.filter(Qe=>ue.id==="all"?!0:ut(Qe).category===ue.id).length;return s.jsxs("button",{onClick:()=>nt(ue.id),className:Fe("px-2 py-1 rounded-lg text-[8px] font-black uppercase tracking-wider whitespace-nowrap transition-all flex items-center gap-1 cursor-pointer shrink-0",Me===ue.id?"bg-gray-950 text-white shadow-2xs":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:[s.jsx("span",{children:ue.icon}),s.jsx("span",{children:ue.label}),s.jsxs("span",{className:"opacity-70 font-mono",children:["(",Se,")"]})]},ue.id)})}),ye.length===0&&de.length===0?s.jsx("div",{className:"py-8 text-center text-gray-400 text-[10px] font-bold uppercase tracking-wider",children:"Inbox Terminal Empty"}):xe==="inbox"?s.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto pr-1",children:(()=>{const ue=de.filter(Se=>Me==="all"?!0:ut(Se).category===Me);return ue.length===0?s.jsxs("div",{className:"py-8 text-center text-xs text-gray-400 uppercase font-bold",children:["No ",Me," notifications found."]}):ue.slice(0,20).map((Se,Qe)=>{var $n;const Gt=ut(Se),Fn=Gt.IconComponent,xn=!!Ee[Se.id],kn=Se.imageUrl||Se.image,xt=Se.message||Se.fullAnswer||"";return s.jsxs(Zt.div,{drag:"x",dragConstraints:{left:-60,right:60},dragElastic:.15,onDragEnd:(Et,je)=>{Math.abs(je.offset.x)>35&&(Ee[Se.id]||Pt(Se.id),pe.success(`Swiped to reply to ${Se.senderName||"notification"}!`,{icon:"💬"}))},onClick:()=>{xn?Dn(Se):Pt(Se.id)},className:Fe("p-3 rounded-2xl border transition-all text-left flex flex-col gap-2 cursor-pointer relative group/notif overflow-hidden shadow-2xs hover:shadow-md touch-pan-y",Gt.borderClass,Gt.bgClass),children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("div",{className:Fe("w-6 h-6 rounded-lg flex items-center justify-center shrink-0 shadow-2xs",Gt.iconBg),children:s.jsx(Fn,{size:13})}),s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[!Se.used&&s.jsx("span",{className:"w-2 h-2 bg-red-600 rounded-full animate-pulse shrink-0",title:"Unread"}),s.jsx("span",{className:Fe("text-[8.5px] font-black uppercase px-2 py-0.5 rounded-md tracking-wider shrink-0 shadow-2xs",Gt.badgeClass),children:Gt.typeLabel})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("span",{className:"text-[8px] font-mono font-bold text-gray-500 bg-white/80 px-1.5 py-0.5 rounded border border-gray-100",children:Kt(Se.createdAt)}),s.jsx("button",{onClick:Et=>Pt(Se.id,Et),className:"p-1 bg-white/80 hover:bg-white text-gray-700 hover:text-black rounded-lg transition-all cursor-pointer border border-gray-200/80 shadow-2xs flex items-center gap-1 text-[9px] font-black uppercase px-1.5",title:xn?"Minimize notification":"Expand notification details",children:xn?s.jsxs(s.Fragment,{children:[s.jsx(df,{size:12,strokeWidth:2.5,className:"text-red-600"}),s.jsx("span",{className:"text-[8px] font-bold hidden sm:inline",children:"Minimize"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Bd,{size:12,strokeWidth:2.5,className:"text-indigo-600"}),s.jsx("span",{className:"text-[8px] font-bold hidden sm:inline",children:"Expand"})]})}),s.jsx("button",{onClick:Et=>An(Se.id,Et),className:"p-1 text-gray-400 hover:text-red-600 hover:bg-white rounded-md transition-all cursor-pointer opacity-80 group-hover/notif:opacity-100",title:"Delete notification",children:s.jsx(er,{size:12})})]})]}),s.jsxs("div",{className:"flex items-start gap-2.5 justify-between min-w-0",children:[s.jsxs("div",{className:"flex-1 min-w-0 break-words",children:[s.jsx("h5",{className:"text-[11px] font-black uppercase text-gray-950 leading-snug tracking-tight break-words",children:Se.title}),s.jsx("div",{className:Fe("text-[10px] text-gray-700 leading-relaxed mt-0.5 font-medium break-words overflow-hidden",!xn&&"line-clamp-2"),children:(()=>{const Et=/(https?:\/\/[^\s]+)/g;return xt.split(Et).map((ln,bt)=>{if(ln.match(Et)){const yn=Jt[ln];return s.jsxs("a",{href:ln,target:"_blank",rel:"noopener noreferrer",onClick:Ut=>{Ut.stopPropagation(),hn(ln),Ft(Se)},className:Fe("inline-flex items-center gap-0.5 font-bold underline transition-all mx-0.5 px-1.5 py-0.5 rounded text-[9px]",yn?"text-emerald-800 bg-emerald-100 border border-emerald-300 font-extrabold":"text-indigo-600 hover:text-indigo-800 bg-indigo-50 border border-indigo-200"),children:[s.jsx(Ad,{size:9,className:"shrink-0"}),yn?"✓ Visited Link":ln.length>28?ln.substring(0,25)+"...":ln]},bt)}return ln})})()})]}),!xn&&kn&&s.jsx("div",{onClick:Et=>Pt(Se.id,Et),className:"w-12 h-12 rounded-xl overflow-hidden border border-gray-200 shrink-0 shadow-2xs relative bg-gray-100 cursor-pointer hover:scale-105 transition-transform",title:"Click to expand image",children:s.jsx(Li,{src:kn,alt:Se.title||"Notification thumbnail",className:"w-full h-full object-cover"})})]}),xn&&s.jsxs("div",{className:"space-y-2 mt-1 animate-in fade-in slide-in-from-top-1 duration-200",children:[kn&&s.jsxs("div",{className:"rounded-xl overflow-hidden border border-gray-200/90 h-44 sm:h-52 w-full relative shadow-sm group/img bg-black/5",children:[s.jsx(Li,{src:kn,alt:Se.title||"Broadcast image",title:Se.title,className:"w-full h-full object-cover"}),s.jsx("div",{className:"absolute top-2 right-2 px-2 py-1 bg-black/70 backdrop-blur-md text-white text-[8px] font-black uppercase rounded-lg tracking-wider border border-white/20",children:"Full Preview"})]}),Se.code&&!Se.used&&s.jsxs("div",{className:"p-2.5 bg-purple-900/10 border border-purple-200 rounded-xl flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(Aa,{size:14,className:"text-purple-700 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[7.5px] font-black uppercase text-purple-900 tracking-wider",children:"Pass Verification Pin"}),s.jsx("code",{className:"text-xs font-black font-mono text-purple-950 tracking-widest",children:Se.code})]})]}),s.jsxs("button",{onClick:Et=>{Et.stopPropagation(),Md(Se.code),pe.success("Verification pin copied!",{icon:"📋"}),Ft(Se)},className:"px-2.5 py-1 bg-purple-700 hover:bg-purple-800 text-white rounded-lg transition-all flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider shrink-0 cursor-pointer shadow-xs",children:[s.jsx(n2,{size:10})," Copy Pin"]})]}),(Se.canReply||Se.type==="direct_message"||Se.senderId)&&Se.senderId!==($==null?void 0:$.uid)&&s.jsxs("div",{onClick:Et=>Et.stopPropagation(),className:"p-2.5 bg-indigo-50/80 border border-indigo-200/90 rounded-xl space-y-2 mt-2 shadow-2xs text-left",children:[s.jsxs("div",{className:"flex items-center justify-between gap-1 text-[9px] font-black uppercase tracking-wider text-indigo-900",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(ea,{size:12,className:"text-indigo-600 shrink-0"}),s.jsxs("span",{className:"truncate",children:["Reply to ",Se.senderName?`@${Se.senderName.toLowerCase().replace(/\s+/g,"")}`:"Friend"]})]}),Se.senderId&&s.jsxs("button",{onClick:Et=>{Et.stopPropagation(),window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:{uid:Se.senderId,displayName:Se.senderName||"Campus Friend",username:Se.senderUsername||"friend",photoURL:Se.senderPhotoURL||""}}))},className:"px-2 py-0.5 bg-[#007AFF] hover:bg-blue-600 text-white rounded-md text-[8px] font-black uppercase tracking-wider flex items-center gap-1 shrink-0 cursor-pointer shadow-2xs",children:[s.jsx(bi,{size:9})," iMessage Chat"]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("input",{type:"text",value:Ue[Se.id]||"",onChange:Et=>{Et.stopPropagation();const je=Et.target.value;Vt(ln=>({...ln,[Se.id]:je}))},onClick:Et=>Et.stopPropagation(),placeholder:"Type inbox reply...",className:"flex-1 text-[11px] font-sans px-2.5 py-1.5 bg-white border border-indigo-200 rounded-lg outline-none focus:border-indigo-600 transition-all text-gray-900 placeholder:text-gray-400",onKeyDown:Et=>{Et.key==="Enter"&&Nt(Se,Et)}}),s.jsxs("button",{onClick:Et=>Nt(Se,Et),disabled:St[Se.id]||!(($n=Ue[Se.id])!=null&&$n.trim()),className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 text-white text-[9px] font-black uppercase tracking-wider rounded-lg flex items-center gap-1 cursor-pointer transition-all shrink-0 shadow-xs",children:[s.jsx(Eo,{size:10})," Reply"]})]})]}),s.jsxs("div",{className:"pt-2 border-t border-gray-200/60 flex items-center justify-between gap-2 flex-wrap",children:[(Se.link||Se.actionUrl)&&s.jsxs("a",{href:Se.link||Se.actionUrl,target:(Se.link||Se.actionUrl).startsWith("http")?"_blank":"_self",rel:"noopener noreferrer",onClick:Et=>{Et.stopPropagation();const je=Se.link||Se.actionUrl;hn(je),Ft(Se)},className:Fe("px-3 py-1.5 text-[9px] font-black uppercase tracking-wider rounded-lg transition-all flex items-center gap-1.5 shadow-xs cursor-pointer",Jt[Se.link||Se.actionUrl]?"bg-emerald-100 text-emerald-800 border border-emerald-300 hover:bg-emerald-200":"bg-indigo-600 hover:bg-indigo-700 text-white border border-indigo-700"),children:[s.jsx($a,{size:11}),Jt[Se.link||Se.actionUrl]?"✓ Link Visited":"Open Target Link"]}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[s.jsx("button",{onClick:Et=>{Et.stopPropagation(),Ft(Se)},className:"px-2 py-1 text-[8.5px] font-bold text-gray-600 hover:text-black bg-white/90 hover:bg-gray-100 rounded-lg border border-gray-200 transition-all cursor-pointer",children:"Mark Read"}),s.jsxs("button",{onClick:Et=>Pt(Se.id,Et),className:"px-2.5 py-1 text-[8.5px] font-black uppercase tracking-wider text-gray-700 hover:text-black bg-white hover:bg-gray-100 rounded-lg border border-gray-200 transition-all flex items-center gap-1 cursor-pointer",children:[s.jsx(bI,{size:10})," Minimize"]})]})]})]})]},`navnotif-${Se.id}-${Qe}`)})})()}):xe==="messages"?s.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto pr-1",children:Ce.length===0?s.jsxs("div",{className:"py-8 text-center text-xs text-gray-400 uppercase font-bold flex flex-col items-center justify-center gap-2",children:[s.jsx(bi,{size:22,className:"text-gray-300"}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"No Message Threads Yet"}),s.jsx("p",{className:"text-[9px] text-gray-400 font-normal normal-case max-w-xs",children:"People you have messaged or who have messaged you will show here. Tap any peer to open inbox!"})]}):Ce.map((ue,Se)=>s.jsxs("div",{onClick:()=>{const Qe={uid:ue.peerUid,displayName:ue.peerName,username:ue.peerUsername,photoURL:ue.peerPhoto};y&&y(Qe),window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:Qe})),se(!1)},className:"flex items-center justify-between p-2 rounded-xl bg-gray-50/80 hover:bg-blue-50/90 border border-gray-200 hover:border-blue-300 transition-all cursor-pointer group shadow-2xs",children:[s.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("img",{src:ue.peerPhoto,alt:"",className:"w-8 h-8 rounded-full object-cover border border-white shadow-xs",referrerPolicy:"no-referrer"}),s.jsx("span",{className:"absolute bottom-0 right-0 w-2.5 h-2.5 bg-emerald-500 rounded-full border-2 border-white"})]}),s.jsxs("div",{className:"min-w-0 text-left",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("p",{className:"text-[11px] font-black uppercase text-gray-900 truncate group-hover:text-blue-600 transition-colors",children:ue.peerName}),s.jsxs("span",{className:"text-[9px] font-medium text-gray-400 truncate",children:["@",ue.peerUsername]})]}),s.jsx("p",{className:"text-[10px] text-gray-600 truncate font-normal",children:ue.lastMessage})]})]}),s.jsxs("div",{className:"flex flex-col items-end shrink-0 gap-1 ml-2",children:[s.jsx("span",{className:"text-[8px] font-bold text-gray-400",children:Kt(ue.lastTimestamp)}),ue.unreadCount>0&&s.jsx("span",{className:"px-1.5 py-0.5 bg-[#2AABEE] text-white text-[8px] font-black rounded-full shadow-2xs",children:ue.unreadCount})]})]},`navconv-${ue.peerUid}-${Se}`))}):s.jsxs("div",{className:"space-y-3 max-h-72 overflow-y-auto pr-1",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"text-[8px] font-black uppercase text-gray-400 tracking-wider mb-1.5",children:["Incoming requests (",ye.length,")"]}),ye.length===0?s.jsx("p",{className:"text-[9px] text-gray-400 font-medium py-1.5 px-2 bg-gray-50/50 rounded-xl leading-snug",children:"No incoming lounge invites right now."}):s.jsx("div",{className:"space-y-2",children:ye.map(ue=>s.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-50/55 rounded-xl border border-gray-150 gap-2 hover:bg-gray-50 transition-all",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("img",{src:ue.senderPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(ue.senderName)}&background=random`,className:"w-7 h-7 rounded-full object-cover shrink-0 border border-gray-100",alt:"",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[10px] font-black uppercase text-gray-950 truncate tracking-tight",children:ue.senderName}),s.jsxs("p",{className:"text-[8px] text-gray-400 truncate",children:["@",ue.senderName.toLowerCase().replace(/\s+/g,"")]})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("button",{onClick:()=>st(ue),className:"w-5 h-5 rounded-full bg-emerald-50 text-emerald-650 hover:bg-emerald-600 hover:text-white flex items-center justify-center transition-all cursor-pointer border border-emerald-150/45 shadow-xs",title:"Accept Connection & Start Chatting",children:s.jsx(Bu,{size:10,strokeWidth:3})}),s.jsx("button",{onClick:()=>dt(ue),className:"w-5 h-5 rounded-full bg-red-50 text-red-600 hover:bg-red-600 hover:text-white flex items-center justify-center transition-all cursor-pointer border border-red-150/45 shadow-xs",title:"Decline Connection Request",children:s.jsx(er,{size:10,strokeWidth:3})})]})]},ue.id))})]}),s.jsxs("div",{className:"pt-2 border-t border-gray-100",children:[s.jsxs("div",{className:"text-[8px] font-black uppercase text-gray-400 tracking-wider mb-2 flex items-center justify-between",children:[s.jsx("span",{children:"Lounge Peer Directory"}),s.jsx("span",{className:"text-[7.5px] font-mono bg-red-50 text-red-600 px-1 rounded-md py-0.2 tracking-normal",children:"Direct Invite"})]}),s.jsxs("div",{className:"mb-2 relative",children:[s.jsx("input",{type:"text",placeholder:"Search classmate name...",value:Xt,onChange:ue=>me(ue.target.value),className:"w-full text-[9px] bg-gray-55/15 border border-transparent rounded-lg px-2.5 py-1 text-gray-800 outline-none focus:bg-white focus:border-red-600/30 transition-all font-sans font-bold"}),Xt&&s.jsx("button",{onClick:()=>me(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-red-650",children:s.jsx(er,{size:10})})]}),qn.length===0?s.jsx("p",{className:"text-[8.5px] text-gray-400 font-bold py-3 text-center uppercase tracking-wider",children:"No other registered users"}):s.jsx("div",{className:"space-y-1.5 max-h-40 overflow-y-auto scrollbar-thin pr-0.5",children:qn.filter(ue=>{if(!Xt.trim())return!0;const Se=(ue.displayName||"").toLowerCase(),Qe=(ue.username||"").toLowerCase(),Gt=Xt.toLowerCase();return Se.includes(Gt)||Qe.includes(Gt)}).slice(0,Xt.trim()?15:3).map(ue=>{const Se=gr[ue.uid];return s.jsxs("div",{className:"flex items-center justify-between p-1 px-1.5 bg-gray-50/30 rounded-xl border border-gray-100 hover:bg-gray-50/70 transition-all gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("img",{src:ue.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(ue.displayName||"P")}&background=random`,className:"w-5.5 h-5.5 rounded-full object-cover shrink-0 border border-gray-100",alt:"",referrerPolicy:"no-referrer"}),(ue.isVerified||ue.isPremium||ue.blueCheck)&&s.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 bg-white rounded-full p-0.2 shadow-2xs",children:s.jsx(Fo,{size:8})})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("p",{className:"text-[9.5px] font-extrabold uppercase text-gray-950 truncate tracking-tight",children:ue.displayName||"Faculty peer"}),(ue.isVerified||ue.isPremium||ue.blueCheck)&&s.jsx(Fo,{size:9,className:"shrink-0 text-blue-500"})]}),s.jsxs("p",{className:"text-[7.5px] text-gray-400 truncate -mt-0.5",children:["@",(ue.username||ue.displayName||"").toLowerCase().replace(/\s+/g,"")]})]})]}),s.jsx("button",{onClick:()=>qe(ue),disabled:Se,className:Fe("text-[7px] font-sans font-black uppercase tracking-wider px-2 py-1 rounded-md border cursor-pointer transition-all active:scale-95 flex items-center gap-0.5 shrink-0 select-none",Se?"bg-gray-50 text-gray-400 border-gray-200 cursor-not-allowed":"bg-red-50 text-red-650 border-red-150 hover:bg-red-600 hover:text-white"),children:Se?"Invited":"Invite"})]},ue.uid)})})]})]})]})})]}),s.jsx("button",{onClick:()=>{$?(n("account"),window.scrollTo({top:0,behavior:"smooth"})):o()},className:"flex items-center gap-1.5 text-gray-700 hover:text-gray-950 transition-colors group cursor-pointer",title:"My Account Profile",children:$?s.jsx("div",{className:"w-5 h-5 rounded-full overflow-hidden border border-gray-200 group-hover:border-red-600 transition-colors flex items-center justify-center bg-amber-50/50",children:$.photoURL?s.jsx("img",{src:$.photoURL,alt:"Profile",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"}):s.jsx(d8,{size:20,className:"w-full h-full"})}):s.jsxs("div",{className:"flex items-center gap-1.5 bg-gray-55/10 border border-gray-150 rounded-full py-1.5 px-3 hover:bg-gray-100 hover:text-red-650 hover:border-red-150 transition-all text-gray-700",children:[s.jsx(d8,{size:14,className:"w-3.5 h-3.5 shrink-0"}),s.jsx("span",{className:"hidden xl:inline text-[9.5px] font-black uppercase tracking-wider",children:"Sign In"})]})}),s.jsx("button",{onClick:()=>C(!0),className:"p-1.5 text-gray-700 hover:text-red-650 hover:bg-gray-100 rounded-lg transition-all cursor-pointer border border-gray-200/60 shadow-2xs flex items-center justify-center ml-1",title:"Open Main Menu & App Tools",children:s.jsx(tE,{size:16,strokeWidth:2.5})})]})]}),typeof document<"u"&&JN.createPortal(s.jsx(or,{children:S&&s.jsxs(s.Fragment,{children:[s.jsx(Zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>C(!1),className:"fixed inset-0 bg-black/60 backdrop-blur-xs z-[1000000]"}),s.jsxs(Zt.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:25,stiffness:220},className:"fixed top-0 right-0 bottom-0 w-80 max-w-[85vw] bg-white text-gray-900 z-[1000001] shadow-2xl border-l border-gray-200 flex flex-col justify-between overflow-y-auto text-left select-none p-5",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between pb-4 border-b border-gray-100 mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"",className:"w-7 h-7 rounded-full border border-gray-900 object-cover",referrerPolicy:"no-referrer"}),s.jsx("span",{className:"text-xs font-serif font-black uppercase tracking-wide",children:"Campus Eye Media"})]}),s.jsx("button",{onClick:()=>C(!1),className:"p-1.5 text-gray-400 hover:text-gray-950 rounded-full hover:bg-gray-100 transition-colors cursor-pointer",children:s.jsx(er,{size:16})})]}),s.jsxs("div",{className:"p-3 bg-gradient-to-br from-red-650 to-red-700 text-white rounded-2xl shadow-md mb-5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx(kie,{size:16,className:"text-amber-300"}),s.jsx("span",{className:"text-[11px] font-black uppercase tracking-wide",children:"Campus Eye Lite App"})]}),s.jsx("p",{className:"text-[9.5px] text-white/90 leading-tight mb-3 font-medium",children:"Install or download a lightweight web shortcut for instant 1-tap campus access!"}),s.jsxs("button",{onClick:()=>{V(),C(!1)},className:"w-full py-2 px-3 bg-white text-red-650 hover:bg-amber-50 font-black text-[10px] uppercase tracking-wider rounded-xl shadow-xs transition-all flex items-center justify-center gap-1.5 cursor-pointer",children:[s.jsx(eE,{size:13,strokeWidth:2.5}),s.jsx("span",{children:"Download Lite App"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"text-[9px] font-black uppercase text-gray-400 tracking-wider px-2 mb-1",children:"Navigation"}),s.jsxs("button",{onClick:()=>{n("home"),C(!1)},className:"w-full text-left px-3 py-2.5 rounded-xl text-xs font-bold text-gray-800 hover:bg-gray-50 flex items-center gap-3 transition-colors cursor-pointer",children:[s.jsx(Fh,{size:15,className:"text-red-600"}),s.jsx("span",{children:"Main Newsfeed"})]}),s.jsxs("button",{onClick:()=>{n("posts"),C(!1)},className:"w-full text-left px-3 py-2.5 rounded-xl text-xs font-bold text-gray-800 hover:bg-gray-50 flex items-center gap-3 transition-colors cursor-pointer",children:[s.jsx(bi,{size:15,className:"text-blue-600"}),s.jsx("span",{children:"Student Lounge & Posts"})]}),s.jsxs("button",{onClick:()=>{n("podcasts"),C(!1)},className:"w-full text-left px-3 py-2.5 rounded-xl text-xs font-bold text-gray-800 hover:bg-gray-50 flex items-center gap-3 transition-colors cursor-pointer",children:[s.jsx(uc,{size:15,className:"text-emerald-600"}),s.jsx("span",{children:"Audio Podcasts"})]}),s.jsxs("button",{onClick:()=>{n("tickets"),C(!1)},className:"w-full text-left px-3 py-2.5 rounded-xl text-xs font-bold text-gray-800 hover:bg-gray-50 flex items-center gap-3 transition-colors cursor-pointer",children:[s.jsx(Aa,{size:15,className:"text-purple-600"}),s.jsx("span",{children:"Event Tickets Store"})]}),r&&s.jsxs("button",{onClick:()=>{i==null||i(),C(!1)},className:"w-full text-left px-3 py-2.5 rounded-xl text-xs font-black uppercase tracking-wider text-amber-600 bg-amber-50 hover:bg-amber-100 flex items-center gap-3 transition-colors mt-2 cursor-pointer",children:[s.jsx(vI,{size:15,className:"text-amber-600"}),s.jsx("span",{children:"Admin Control Center"})]})]})]}),s.jsxs("div",{className:"pt-4 border-t border-gray-100 text-[9px] text-gray-400 font-mono font-bold flex justify-between items-center",children:[s.jsx("span",{children:"v2.5 Lite Ready"}),s.jsx("span",{children:"Campus Eye Media"})]})]})]})}),document.body),s.jsx("div",{className:"lg:hidden flex items-center space-x-1.5 overflow-x-auto px-2.5 py-1 border-t border-gray-100/70 scrollbar-none",children:lr.map(ue=>{const Se=ue.id==="home";return s.jsxs(ie.Fragment,{children:[s.jsx("button",{onClick:()=>{n(ue.id),h&&h(null)},className:Fe("text-[8.5px] font-extrabold tracking-wider px-2 py-0.5 rounded-full shrink-0 uppercase transition-all",t===ue.id&&!f?"bg-gray-950 text-white":"bg-gray-50 text-gray-500 border border-gray-100"),children:ue.label}),Se&&c&&c.length>0&&(()=>{const Qe=c[0],Gt=(f==null?void 0:f.id)===Qe.id,Fn=c.slice(1),xn=Fn.find(kn=>(f==null?void 0:f.id)===kn.id);return s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("button",{onClick:()=>h&&h(Qe),className:Fe("text-[9px] font-extrabold tracking-wider px-2.5 py-1 rounded-full shrink-0 uppercase flex items-center gap-1.2 transition-all border",Gt?"bg-red-650 border-red-650 text-white":"bg-red-50/70 border-red-150 text-red-655"),children:Qe.name},Qe.id),Fn.length>0&&s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("button",{onClick:()=>ft(!It),className:Fe("p-1.5 rounded-full shrink-0 flex items-center justify-center transition-all border",xn?"bg-red-655 border-red-655 text-white":"bg-gray-100 border-gray-200 text-gray-650"),title:"More Channels",children:s.jsx("svg",{className:"w-2.5 h-2.5",fill:"none",stroke:"currentColor",strokeWidth:"3.5",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}),s.jsx(or,{children:It&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[49] bg-transparent",onClick:()=>ft(!1)}),s.jsx(Zt.div,{initial:{opacity:0,scale:.95,y:3},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:3},transition:{duration:.1},className:"fixed right-4 top-[86px] min-w-[130px] max-w-[170px] bg-white border border-gray-150 rounded-xl shadow-2xl z-[99999] py-1 text-left",children:Fn.map(kn=>{const xt=(f==null?void 0:f.id)===kn.id;return s.jsxs("button",{onClick:()=>{h&&h(kn),ft(!1)},className:Fe("w-full text-left px-3 py-1.5 hover:bg-gray-50 text-[8.5px] font-extrabold uppercase tracking-wider flex items-center justify-between transition-colors",xt?"text-red-650 bg-red-50/45":"text-gray-750 hover:text-black"),children:[s.jsx("span",{className:"truncate pr-1",children:kn.name}),xt&&s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-650 shrink-0"})]},kn.id)})})]})})]})]},"mobile-custom-nav-group")})()]},ue.id)})})]}),s.jsx(or,{children:w&&s.jsxs(Zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[99999] bg-white flex flex-col text-gray-900 select-none overflow-y-auto",children:[s.jsxs("div",{className:"w-full max-w-[1680px] xl:max-w-[1780px] 2xl:max-w-[1880px] mx-auto px-6 pt-6 flex justify-between items-center select-none",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-red-650"}),s.jsx("span",{className:"text-[10px] font-black tracking-[0.2em] text-gray-500 uppercase",children:"CAMPUS SEARCHING ROOM"})]}),s.jsx(Zt.button,{whileHover:{rotate:90,scale:1.1},whileTap:{scale:.9},onClick:()=>A(!1),className:"p-2 text-gray-500 hover:text-gray-950 transition-colors bg-gray-50 hover:bg-gray-100 rounded-full border border-gray-250 cursor-pointer animate-fade-in -subtle",title:"Exit Searching Room",children:s.jsx(er,{size:18})})]}),s.jsx("div",{className:"flex-1 flex flex-col items-center justify-start pt-14 px-4 pb-12 overflow-y-auto w-full",children:s.jsxs(Zt.div,{initial:{y:25,opacity:0},animate:{y:0,opacity:1},transition:{type:"spring",damping:25,stiffness:200},className:"w-full max-w-4xl space-y-8",children:[s.jsxs("div",{className:"relative group flex items-center bg-gray-50 p-1 rounded-2xl border border-gray-200 focus-within:border-red-650 focus-within:bg-white focus-within:shadow-[0_0_25px_rgba(220,38,38,0.08)] transition-all duration-300",children:[s.jsx("div",{className:"flex items-center justify-center w-12 h-12 text-gray-400 pl-2",children:s.jsx(Rp,{size:22,className:"group-focus-within:text-red-500 transition-colors"})}),s.jsx("input",{type:"text",value:T,onChange:ue=>D(ue.target.value),placeholder:"Query articles, categories, debates, archives...",className:"flex-1 bg-transparent py-4 pl-3 pr-8 text-sm sm:text-base font-bold outline-none text-gray-900 placeholder-gray-400 min-w-0"}),T&&s.jsx("button",{onClick:on,className:"p-2.5 text-gray-500 hover:text-gray-900 transition-colors mr-2 cursor-pointer bg-gray-200 rounded-full hover:bg-gray-300 shrink-0",title:"Clear Search Query",children:s.jsx(er,{size:16})})]}),q.length>0?s.jsxs(Zt.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},className:"flex flex-col items-center gap-3.5 py-1 select-none",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[9px] font-black text-red-650 uppercase tracking-widest bg-red-50 px-3.5 py-1.5 rounded-full border border-red-150",children:[s.jsx(Zi,{size:11,className:"text-red-500 "})," Live Smart Concept Recommendations"]}),s.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:q.map((ue,Se)=>s.jsx("button",{onClick:()=>D(ue),className:"px-4 py-2 bg-gray-50 hover:bg-red-650 text-gray-700 hover:text-white text-[9px] font-extrabold uppercase tracking-wider border border-gray-200 hover:border-red-650 transition-all rounded-full cursor-pointer shadow-xs hover:scale-105",children:ue},Se))})]}):s.jsxs("div",{className:"flex items-center justify-center gap-2 py-1 select-none",children:[s.jsx("span",{className:"text-[9px] font-black tracking-widest text-gray-400 uppercase",children:"Suggested Terms:"}),s.jsx("div",{className:"flex gap-1.5",children:["News","Sports","Elections","Tickets","Debates"].map(ue=>s.jsx("button",{onClick:()=>D(ue),className:"text-[9px] font-black uppercase tracking-wider text-gray-500 hover:text-red-650 px-2.5 py-1.5 bg-gray-50 hover:bg-gray-100 rounded-md border border-gray-200 cursor-pointer",children:ue},ue))})]}),s.jsx("div",{className:"max-h-[50vh] overflow-y-auto pr-2 scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent",children:s.jsx(or,{mode:"popLayout",children:K.length>0?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"text-[10px] font-black tracking-widest text-gray-500 uppercase select-none pb-1 border-b border-gray-150 flex items-center justify-between",children:[s.jsxs("span",{children:["Matching Campus & Archival Catalog (",K.length,")"]}),s.jsx("span",{className:"text-[8px] font-bold text-gray-400 capitalize",children:"Real-time instant index"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:K.map((ue,Se)=>{const Qe={article:"bg-red-50 text-red-650 border-red-150",post:"bg-purple-50 text-purple-650 border-purple-150",user:"bg-blue-50 text-blue-650 border-blue-150",advert:"bg-amber-50 text-amber-650 border-amber-150",pinned:"bg-rose-50 text-rose-650 border-rose-150",customPage:"bg-teal-50 text-teal-650 border-teal-150"};return s.jsxs(Zt.button,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:Se*.03},onClick:()=>jr(ue),className:"flex gap-4 p-3 bg-white hover:bg-gray-50 hover:shadow-md transition-all duration-200 group border border-gray-150 rounded-xl text-left select-none outline-none",children:[s.jsxs("div",{className:"w-16 h-16 overflow-hidden bg-gray-50 flex-shrink-0 border border-gray-150 rounded-lg relative",children:[s.jsx("img",{src:ue.imageUrl||void 0,alt:"",className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-103",referrerPolicy:"no-referrer"}),s.jsx("span",{className:`absolute bottom-1 right-1 text-[6.5px] font-black tracking-widest uppercase px-1 py-0.2 rounded-xs border shadow-3xs ${Qe[ue.type]||"bg-gray-100 text-gray-500 border-gray-200"}`,children:ue.type})]}),s.jsxs("div",{className:"flex-1 space-y-0.5 min-w-0 text-left",children:[s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400",children:ue.category}),s.jsx("h4",{className:"text-xs sm:text-xs font-black text-gray-950 uppercase tracking-tight group-hover:text-red-650 transition-colors leading-snug line-clamp-2",children:ue.title}),s.jsx("p",{className:"text-[10px] text-gray-500 line-clamp-1 italic leading-relaxed",children:ue.subtitle})]})]},`${ue.type}-${ue.id}`)})})]}):T.length>1&&s.jsxs(Zt.div,{initial:{opacity:0},animate:{opacity:1},className:"text-center py-16 flex flex-col items-center select-none",children:[s.jsx("p",{className:"text-gray-500 font-extrabold uppercase tracking-widest text-sm mb-1",children:"No matching dispatches found"}),s.jsx("p",{className:"text-gray-400 text-xs font-bold",children:"Refine your inquiry above dynamically"})]})})})]})})]})})]})},vye=({activeTab:e,setActiveTab:t,onProfileClick:n,isAdmin:r,onAdminClick:i,openAuth:a,onMenuClick:o,onPodcastClick:c,isPodcastModalOpen:h})=>{const[f,m]=ie.useState(!1),[y,w]=I.useState(Ne.currentUser);I.useEffect(()=>{const T=Ne.onAuthStateChanged(D=>{w(D)});return()=>T()},[]);const A=typeof window<"u"?window.location.origin:"https://campuseyemedia.com",S=[...r?[{id:"live",label:"Live Stream",icon:Zi,url:`${A}/live`}]:[],{id:"teams",label:"Teams",icon:_o},{id:"marketplace",label:"Marketplace",icon:TC},{id:"feedback",label:"Feedback",icon:Kp},...r?[{id:"main-site",label:"Main Site",icon:dre,url:"https://campuseyemedia.com"}]:[]],C=T=>{T.url?window.open(T.url,"_blank"):t(T.id),m(!1)};return s.jsxs(s.Fragment,{children:[s.jsx(or,{children:f&&s.jsxs(Zt.div,{initial:{opacity:0,y:100},animate:{opacity:1,y:0},exit:{opacity:0,y:100},className:"fixed bottom-20 left-4 right-4 bg-white/70 backdrop-blur-2xl border border-white/50 z-[60] p-6 shadow-2xl rounded-3xl",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsx("h3",{className:"text-sm font-black uppercase tracking-widest text-red-650",children:"Explore More"}),s.jsx("button",{onClick:()=>m(!1),className:"text-gray-500",children:s.jsx(er,{size:20})})]}),s.jsx("div",{className:"grid grid-cols-4 gap-4",children:S.map(T=>s.jsxs("button",{onClick:()=>C(T),className:"flex flex-col items-center gap-2 group",children:[s.jsx("div",{className:"p-3 bg-gray-50 group-hover:bg-red-650 group-hover:text-white transition-all",children:s.jsx(T.icon,{size:20})}),s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-500",children:T.label})]},T.id))})]})}),s.jsx("nav",{className:"fixed bottom-2 left-1/2 -translate-x-1/2 z-[1001] w-[88%] max-w-sm md:max-w-md",children:s.jsxs("div",{className:"relative group overflow-hidden rounded-full p-[1px] isolate",children:[s.jsx("div",{className:"absolute inset-0 z-[-1] overflow-hidden",children:s.jsx(Zt.div,{animate:{scale:[1,1.15,.95,1.05,1],x:[-3,7,-7,3,-3],y:[1,-5,3,-1,1],rotate:[0,90,180,270,360]},transition:{duration:12,repeat:1/0,ease:"easeInOut"},className:"absolute -inset-[100%] opacity-35 blur-[20px] bg-gradient-to-tr from-[#FF3B30]/30 via-[#34C759]/25 to-[#007AFF]/35"})}),s.jsxs("div",{className:"relative bg-white/35 dark:bg-neutral-900/35 backdrop-blur-[35px] border border-white/40 dark:border-white/10 shadow-[0_12px_36px_rgba(0,0,0,0.12)] h-11 rounded-full overflow-hidden transition-all duration-500 hover:bg-white/50 dark:hover:bg-neutral-900/50",children:[s.jsx(Zt.div,{animate:{opacity:[.35,.75,.35],scale:[.97,1.03,.97]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},className:"absolute inset-x-0 bottom-0 h-[1.5px] bg-gradient-to-r from-transparent via-[#FF2D55]/60 to-transparent blur-xs"}),s.jsxs("div",{className:"grid grid-cols-5 h-full relative z-10 px-1 items-center",children:[s.jsxs("button",{onClick:()=>t("home"),className:Fe("flex flex-col items-center justify-center h-full space-y-0.2 transition-all duration-500",e==="home"?"text-red-600 scale-105 drop-shadow-sm":"text-red-500/75 hover:text-red-600"),children:[s.jsxs("div",{className:"relative",children:[s.jsx(Ope,{size:16,className:"shrink-0"}),e==="home"&&s.jsx(Zt.div,{layoutId:"nav-dot",className:"absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-0.5 h-0.5 bg-red-600 rounded-full"})]}),s.jsx("span",{className:"text-[6px] font-black uppercase tracking-widest mt-0.2 opacity-95",children:"Home"})]}),s.jsxs("button",{onClick:()=>{t("posts")},className:Fe("flex flex-col items-center justify-center h-full space-y-0.2 transition-all duration-500",e==="posts"?"text-blue-600 scale-105":"text-blue-500/75 hover:text-blue-600"),children:[s.jsxs("div",{className:"relative",children:[s.jsx(TC,{size:16,className:"shrink-0"}),e==="posts"&&s.jsx(Zt.div,{layoutId:"nav-dot",className:"absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-0.5 h-0.5 bg-blue-600 rounded-full"})]}),s.jsx("span",{className:"text-[6px] font-black uppercase tracking-widest mt-0.2 opacity-95",children:"Market"})]}),s.jsx("div",{className:"relative flex justify-center items-center h-full",children:s.jsxs(Zt.button,{whileHover:{scale:1.08},whileTap:{scale:.92},onClick:o,className:"w-8 h-8 bg-gray-950 text-white rounded-full shadow-[0_6px_15px_rgba(0,0,0,0.35)] flex items-center justify-center border border-white/15 transition-all z-20 group/btn overflow-hidden cursor-pointer",title:"Open Dashboard Drawer",children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-tr from-red-600/20 to-transparent opacity-0 group-hover/btn:opacity-100 transition-opacity"}),s.jsx(tE,{className:"text-white w-3.5 h-3.5 z-10"})]})}),s.jsxs("button",{onClick:()=>{c?c():t("podcasts")},className:Fe("flex flex-col items-center justify-center h-full space-y-0.2 transition-all duration-500",e==="podcasts"||h?"text-emerald-600 scale-105 font-bold":"text-emerald-500/75 hover:text-emerald-600"),children:[s.jsx(D2,{size:16,className:"shrink-0"}),s.jsx("span",{className:"text-[6px] font-black uppercase tracking-widest mt-0.2 opacity-95",children:"Podcast"})]}),s.jsxs("button",{onClick:()=>y?n():a(),className:Fe("flex flex-col items-center justify-center h-full space-y-0.2 transition-all duration-500",e==="account"?"text-amber-550 scale-105":"text-amber-500/75 hover:text-amber-550"),children:[y?s.jsx("div",{className:"relative p-0.5 rounded-full bg-amber-500/20 border border-amber-500/50 shadow-sm",children:s.jsx("img",{src:y.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(y.displayName||"User")}&background=random`,className:"w-3.5 h-3.5 rounded-full object-cover",alt:"",referrerPolicy:"no-referrer"})}):s.jsx(nE,{size:13,className:"text-amber-500",strokeWidth:e==="account"?2.5:2}),s.jsx("span",{className:"text-[6px] font-black uppercase tracking-widest mt-0.2 opacity-95",children:y?"Me":"Join"})]})]})]})]})})]})},wye=({articles:e,onClick:t})=>{const n=e.slice(0,3),r=I.useRef(null),[i,a]=I.useState({}),[o,c]=I.useState(null),[h,f]=I.useState(!1);ie.useEffect(()=>{cs(Je(he,"settings","pinned")).then(C=>{if(C.exists()){const T=C.data();T.active?c({title:T.title||"",description:T.description||"",link:T.link||"",imageUrl:T.imageUrl||"",active:!!T.active}):c(null)}else c(null)}).catch(C=>{Ks(C,Ms.GET,"settings/pinned")})},[]);const[m,y]=I.useState(!1);if(ie.useEffect(()=>{const C=()=>{if(!o)return;const T=`dismiss_forever_pinned_${encodeURIComponent("fallback_legacy")}`,D=o.title?encodeURIComponent(o.title):"",V=`dismiss_forever_pinned_${D}`;localStorage.getItem(T)==="true"||D&&localStorage.getItem(V)==="true"?y(!0):y(!1)};return C(),window.addEventListener("pinned-dismissed",C),window.addEventListener("storage",C),()=>{window.removeEventListener("pinned-dismissed",C),window.removeEventListener("storage",C)}},[o]),ie.useEffect(()=>{f(!!(o&&!m))},[o,m]),ie.useEffect(()=>{if(n.length<=1)return;const C=setInterval(()=>{if(!r.current)return;const{scrollLeft:T,scrollWidth:D,clientWidth:V}=r.current,K=T+V>=D-15?0:T+V;r.current.scrollTo({left:K,behavior:"smooth"})},2e4);return()=>clearInterval(C)},[n.length]),n.length===0)return null;const w=(C,T)=>{T.stopPropagation(),a(D=>({...D,[C]:!D[C]}))},A=C=>{if(!r.current)return;const{scrollLeft:T,clientWidth:D}=r.current,V=D*.75;r.current.scrollTo({left:C==="left"?T-V:T+V,behavior:"smooth"})},S=[{gradient:"from-purple-950 via-purple-900 to-indigo-950 hover:from-purple-900 hover:to-indigo-900 border-purple-500/30",accentBg:"bg-purple-500/20 text-purple-200 border-purple-400/20",textAccent:"text-purple-300",type:"Breaking Story"},{gradient:"from-rose-950 via-rose-900 to-red-950 hover:from-rose-900 hover:to-red-900 border-red-500/30",accentBg:"bg-red-500/20 text-red-200 border-red-400/20",textAccent:"text-red-300",type:"Hot Broadcast"},{gradient:"from-emerald-950 via-emerald-900 to-teal-950 hover:from-emerald-900 hover:to-teal-900 border-emerald-500/30",accentBg:"bg-emerald-500/20 text-emerald-200 border-emerald-400/20",textAccent:"text-emerald-300",type:"Exclusive Update"}];return s.jsxs("div",{className:"relative group/nav px-4 pt-1 pb-4 select-none",children:[n.length>1&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>A("left"),className:"absolute left-1.5 top-1/2 -translate-y-1/2 z-40 w-8 h-8 bg-black/80 hover:bg-black text-white hover:scale-105 transition-all rounded-full flex items-center justify-center border border-white/10 shadow-lg cursor-pointer opacity-0 group-hover/nav:opacity-100 hidden sm:flex",title:"Scroll Left",children:s.jsx(qp,{size:16})}),s.jsx("button",{onClick:()=>A("right"),className:"absolute right-1.5 top-1/2 -translate-y-1/2 z-40 w-8 h-8 bg-black/80 hover:bg-black text-white hover:scale-105 transition-all rounded-full flex items-center justify-center border border-white/10 shadow-lg cursor-pointer opacity-0 group-hover/nav:opacity-100 hidden sm:flex",title:"Scroll Right",children:s.jsx(Wp,{size:16})})]}),s.jsx("div",{ref:r,className:"flex gap-4 overflow-x-auto scrollbar-none snap-x snap-mandatory px-0.5 py-0.5 touch-pan-x",style:{scrollBehavior:"smooth"},children:n.map((C,T)=>{var Z;const D=S[T%S.length],V=!!i[T],L=C.likeCount?`${C.likeCount}+`:"24+",K=C.commentCount?`${C.commentCount}`:"4";return T===0&&h&&o?s.jsx("div",{onClick:()=>{o.link&&window.open(o.link,"_blank")},className:"snap-start shrink-0 w-[91%] sm:w-[50%] lg:w-[32.3%] cursor-pointer transition-all animate-fade-in",children:s.jsx(Zt.div,{layout:!0,className:"w-full bg-[#0a0b0d] text-white p-[2px] rounded-full relative overflow-hidden select-none flex flex-col justify-center shadow-lg",style:{borderRadius:V?"18px":"9999px",backgroundImage:"linear-gradient(to right, #fbbf24, #ec4899, #3b82f6)"},children:s.jsxs("div",{className:"w-full h-full bg-[#0d0e12] px-3.5 py-2.5 rounded-full flex flex-col justify-center",style:{borderRadius:V?"16px":"9999px"},children:[s.jsxs("div",{className:"flex items-center justify-between w-full",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o.imageUrl?s.jsx("div",{className:"w-6 h-6 rounded-full overflow-hidden bg-gray-800 border-2 border-amber-400 shrink-0 shadow-sm flex items-center justify-center",children:s.jsx("img",{src:o.imageUrl,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"})}):s.jsx("div",{className:"w-6 h-6 rounded-full bg-amber-400/20 border-2 border-amber-400 shrink-0 flex items-center justify-center text-amber-400",children:s.jsx(Ou,{size:11,className:"animate-bounce"})}),s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 text-[10.5px] font-bold",children:[s.jsxs("span",{className:"text-[8.5px] font-black uppercase tracking-widest px-1.5 py-0.5 rounded bg-amber-400/20 text-amber-300 shrink-0 flex items-center gap-0.5",children:[s.jsx(Ou,{size:9})," PINNED"]}),s.jsx("span",{className:"text-white/60",children:"•"}),s.jsx("span",{className:"truncate text-white tracking-tight leading-none font-extrabold",children:o.title})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0 pl-1.5",children:[s.jsx("button",{onClick:q=>{q.stopPropagation();const z=`dismiss_forever_pinned_${o.title?encodeURIComponent(o.title):""}`;localStorage.setItem(z,"true"),localStorage.setItem("dismiss_forever_pinned_settings_pinned","true"),y(!0),f(!1),window.dispatchEvent(new Event("pinned-dismissed")),ir.success("Pinned announcement dismissed!")},className:"w-5 h-5 bg-white/10 hover:bg-red-600 hover:text-white text-white rounded-full flex items-center justify-center transition-all cursor-pointer active:scale-95 shrink-0",title:"Dismiss forever",children:s.jsx(er,{size:10,className:"stroke-[2.5]"})}),s.jsx("button",{onClick:q=>w(T,q),className:"w-5 h-5 bg-white/10 hover:bg-white/20 text-white rounded-full flex items-center justify-center transition-all cursor-pointer active:scale-95 shrink-0",title:V?"Collapse announcement":"Expand announcement",children:s.jsx(Zt.div,{animate:{rotate:V?180:0},transition:{duration:.2},children:s.jsx(Bd,{size:11,className:"stroke-[2.5]"})})})]})]}),s.jsx(or,{initial:!1,children:V&&s.jsx(Zt.div,{initial:{height:0,opacity:0,marginTop:0},animate:{height:"auto",opacity:1,marginTop:10},exit:{height:0,opacity:0,marginTop:0},transition:{duration:.25,ease:"easeInOut"},className:"overflow-hidden w-full text-left",children:s.jsxs("div",{className:"pt-2.5 border-t border-white/10 flex gap-3 items-start",children:[o.imageUrl&&s.jsx("div",{className:"w-12 h-12 rounded-lg overflow-hidden bg-gray-900 border border-white/10 shrink-0",children:s.jsx("img",{src:o.imageUrl,className:"w-full h-full object-cover",alt:"",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[10px] text-white/90 font-bold leading-snug",children:o.description||"Click link to view details of this announcement!"}),o.link&&s.jsx("p",{className:"text-[8.5px] font-black uppercase text-amber-300 tracking-wider mt-2 flex items-center gap-1",children:s.jsx("span",{children:"Tap Action Link →"})})]})]})})})]})})},"pinned-announcement-overlay"):s.jsx("div",{onClick:()=>t(C),className:"snap-start shrink-0 w-[91%] sm:w-[50%] lg:w-[32.3%] cursor-pointer transition-all",children:s.jsxs(Zt.div,{layout:!0,className:`w-full bg-gradient-to-r ${D.gradient} text-white px-3.5 py-2.5 rounded-full border shadow-md hover:shadow-lg transition-all duration-300 relative overflow-hidden select-none flex flex-col justify-center`,style:{borderRadius:V?"18px":"9999px"},children:[s.jsx("div",{className:"absolute top-0 right-0 w-24 h-24 bg-white/2 rounded-full blur-xl pointer-events-none"}),s.jsxs("div",{className:"flex items-center justify-between w-full",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx("div",{className:"w-6 h-6 rounded-full overflow-hidden bg-gray-800 border-2 border-white/20 shrink-0 shadow-sm",children:s.jsx("img",{src:C.featuredImageUrl||"https://picsum.photos/seed/news/50/50",alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 text-[10.5px] font-bold",children:[s.jsx("span",{className:`text-[8.5px] font-black uppercase tracking-widest px-1.5 py-0.5 rounded ${D.accentBg} shrink-0`,children:L}),s.jsx("span",{className:"text-white/60",children:"•"}),s.jsx("span",{className:"truncate text-white/90 tracking-tight",children:M0(C.title)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0 pl-1.5",children:[!V&&s.jsxs("div",{className:"flex gap-0.5 items-end h-2 w-3 pr-0.5",children:[s.jsx("div",{className:"w-0.5 bg-white/70 animate-[pulse_0.6s_infinite_alternate]",style:{height:"50%"}}),s.jsx("div",{className:"w-0.5 bg-white/70 animate-[pulse_0.8s_infinite_alternate]",style:{height:"90%"}}),s.jsx("div",{className:"w-0.5 bg-white/70 animate-[pulse_0.5s_infinite_alternate]",style:{height:"35%"}})]}),s.jsx("button",{onClick:q=>w(T,q),className:"w-5 h-5 bg-white/10 hover:bg-white/20 text-white rounded-full flex items-center justify-center transition-all cursor-pointer border border-white/5 active:scale-90",title:V?"Collapse Banner":"Expand Banner",children:s.jsx(Zt.div,{animate:{rotate:V?180:0},transition:{duration:.2},children:s.jsx(Bd,{size:11,className:"stroke-[2.5]"})})})]})]}),s.jsx(or,{initial:!1,children:V&&s.jsx(Zt.div,{initial:{height:0,opacity:0,marginTop:0},animate:{height:"auto",opacity:1,marginTop:10},exit:{height:0,opacity:0,marginTop:0},transition:{duration:.25,ease:"easeInOut"},className:"overflow-hidden w-full text-left",children:s.jsxs("div",{className:"pt-2.5 border-t border-white/10 flex gap-3 items-start",children:[s.jsx("div",{className:"w-14 h-14 rounded-lg overflow-hidden bg-gray-900 border border-white/10 shrink-0",children:s.jsx("img",{src:C.featuredImageUrl||"https://picsum.photos/seed/news/150/150",alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[s.jsx("span",{className:"text-[8px] font-black uppercase text-red-400 tracking-widest",children:C.category}),s.jsx("span",{className:"text-white/35 text-[8px]",children:"•"}),s.jsx("span",{className:"text-[8px] font-black uppercase text-white/50 tracking-widest",children:D.type})]}),s.jsxs("p",{className:"text-[10px] text-white/80 line-clamp-2 leading-relaxed",children:[C.summary||((Z=C.content)==null?void 0:Z.substring(0,80))||"Tune in for deep coverage on this topic","..."]}),s.jsxs("div",{className:"flex items-center gap-2.5 pt-1 select-none",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[8.5px] text-white/60",children:[s.jsx(Kp,{size:9}),s.jsxs("span",{children:[K," comments"]})]}),s.jsx("span",{className:"text-[8.5px] font-extrabold text-white/80 hover:text-white transition-colors uppercase tracking-wider flex items-center gap-0.5",children:"Open Story →"})]})]})]})})})]})},C.id)})})]})},Yw=({advert:e,className:t})=>{const[n,r]=I.useState(!1),[i,a]=I.useState(!1),o=e.type==="video"||e.videoUrl&&!e.imageUrl,c=y=>{const w=/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/,A=y.match(w);return A&&A[2].length===11?A[2]:null},h=e.videoUrl?c(e.videoUrl):null,f=y=>{y.preventDefault(),y.stopPropagation(),a(!i)},m=y=>{y.preventDefault(),y.stopPropagation(),r(!n)};return s.jsxs("div",{className:`group relative overflow-hidden bg-gray-950 border border-zinc-800 rounded-xl transition-all duration-500 hover:border-red-500/30 ${t}`,children:[s.jsxs("div",{className:"absolute top-2 w-full px-3 flex justify-between items-center z-[30] pointer-events-none",children:[s.jsxs("div",{className:"flex items-center gap-1 bg-black/45 backdrop-blur-md px-2.5 py-1 rounded-full border border-white/10 pointer-events-auto select-none",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[8.5px] font-black uppercase text-white tracking-widest",children:[s.jsx(vu,{size:10,className:"text-red-500 shrink-0"}),s.jsx("span",{children:"Ad"})]}),s.jsx("button",{onClick:f,className:"text-white/60 hover:text-white ml-1.5 transition-colors focus:outline-none cursor-pointer",title:"Ad Placement Info",children:s.jsx(iF,{size:11})})]}),s.jsx("div",{className:"pointer-events-auto select-none",children:s.jsxs("button",{onClick:m,className:"flex items-center gap-1 bg-black/45 backdrop-blur-md text-white/90 hover:text-white px-2.5 py-1 rounded-full border border-white/10 text-[8.5px] font-black uppercase tracking-widest transition-all cursor-pointer focus:outline-none",children:[s.jsx("span",{children:n?"Minimize":"Enlarge"}),n?s.jsx(df,{size:11}):s.jsx(Bd,{size:11})]})})]}),s.jsx("a",{href:e.link,target:"_blank",rel:"noopener noreferrer",className:"block cursor-pointer overflow-hidden",children:s.jsxs(Zt.div,{style:{aspectRatio:n?o?"16/9":"1.6":o?"18/8":"2.6"},transition:{type:"spring",damping:20,stiffness:100},className:"overflow-hidden bg-black flex items-center justify-center relative w-full h-full min-h-[140px] transition-[aspect-ratio] duration-300 ease-in-out",children:[s.jsx(or,{mode:"wait",children:s.jsx(Zt.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},transition:{duration:.6,ease:[.16,1,.3,1]},className:"absolute inset-0 w-full h-full flex items-center justify-center",children:o&&e.videoUrl?h?s.jsx("div",{className:"absolute inset-0 pointer-events-none scale-150",children:s.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${h}?autoplay=1&mute=1&loop=1&playlist=${h}&controls=0&showinfo=0&rel=0&iv_load_policy=3&modestbranding=1&enablejsapi=1`,className:"w-full h-full",allow:"autoplay; encrypted-media",title:e.title||"Advertisement"})}):s.jsx("video",{src:e.videoUrl||void 0,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"w-full h-full object-contain bg-neutral-950"}):s.jsx("img",{src:e.imageUrl||void 0,alt:e.title||"Advertisement",className:"w-full h-full object-contain bg-neutral-950 transition-transform duration-700 group-hover:scale-103",referrerPolicy:"no-referrer",loading:"eager",decoding:"async"})},e.id||e.title||e.imageUrl)}),o&&s.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-10 h-10 bg-white/10 backdrop-blur-md rounded-full flex items-center justify-center text-white/40 opacity-0 group-hover:opacity-100 transition-all duration-750 scale-75 group-hover:scale-100 pointer-events-none z-10",children:s.jsx(Yp,{size:18,fill:"currentColor"})}),s.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-4 bg-gradient-to-t from-black/90 via-black/30 to-transparent opacity-0 group-hover:opacity-100 transition-all duration-500 translate-y-2 group-hover:translate-y-0 flex items-center justify-between pointer-events-none z-10",children:[s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("span",{className:"block text-[9px] font-black text-white uppercase tracking-widest",children:e.title||"Official Advertisement"}),s.jsx("p",{className:"text-[7.5px] font-bold text-gray-300 uppercase tracking-wider",children:"Click image to open redirect link"})]}),s.jsx("div",{className:"w-6 h-6 bg-white/10 backdrop-blur-md rounded-full flex items-center justify-center border border-white/10 shrink-0",children:s.jsx($a,{size:12,className:"text-white"})})]})]})}),s.jsx(or,{children:i&&s.jsxs(Zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 bg-black/90 backdrop-blur-md flex flex-col justify-center p-5 z-[40]",children:[s.jsx("button",{onClick:f,className:"absolute top-3 right-3 text-white/60 hover:text-white p-1 cursor-pointer focus:outline-none",children:s.jsx(er,{size:15})}),s.jsxs("div",{className:"space-y-2 select-text",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-red-500",children:[s.jsx(Zi,{size:14}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Ad Placement Guarantee"})]}),s.jsx("h4",{className:"text-[11px] font-black text-white uppercase tracking-wide leading-tight",children:e.title||"Official Ad Placement"}),s.jsx("p",{className:"text-[9px] text-gray-400 font-sans leading-normal",children:"This verification card is served directly by the Campus Eye Editorial Board. It is an independent advertisement. Click on the image to visit the external destination safely."}),s.jsxs("div",{className:"pt-1.5 flex gap-2",children:[s.jsxs("span",{className:"text-[7px] text-zinc-500 bg-zinc-900 border border-zinc-800 px-2 py-0.5 rounded-md font-mono select-none",children:["REF: AD-",e.id.substring(0,6).toUpperCase()]}),s.jsx("span",{className:"text-[7px] text-zinc-500 bg-zinc-900 border border-zinc-800 px-2 py-0.5 rounded-md font-mono select-none",children:"STATUS: LIVE"})]})]})]})})]})},Uo=({className:e,variant:t="rect"})=>s.jsx("div",{className:Fe("skeleton",t==="circle"&&"rounded-full",e)}),Sp=({variant:e="big"})=>e==="social"?s.jsx("div",{className:"border-b border-gray-100 p-4 md:p-6 bg-white text-left space-y-3",children:s.jsxs("div",{className:"flex gap-3 md:gap-4",children:[s.jsx("div",{className:"w-8 h-8 md:w-9 md:h-9 rounded-full bg-gray-200 shrink-0"}),s.jsxs("div",{className:"flex-1 space-y-3 min-w-0",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap w-full",children:[s.jsx("div",{className:"h-3 w-3 bg-gray-200 rounded-full"}),s.jsx("div",{className:"h-3 w-20 bg-gray-250 rounded"}),s.jsx("div",{className:"h-2 w-2 rounded-full bg-gray-200 shrink-0"}),s.jsx("div",{className:"h-3 w-16 bg-gray-200 rounded"}),s.jsx("div",{className:"h-2 w-2 rounded-full bg-gray-200 shrink-0"}),s.jsx("div",{className:"h-3 w-12 bg-gray-150 rounded"})]})}),s.jsxs("div",{className:"space-y-2 pt-1",children:[s.jsx("div",{className:"h-4.5 w-[94%] bg-gray-250 rounded-md"}),s.jsx("div",{className:"h-4.5 w-3/4 bg-gray-200 rounded-md"})]}),s.jsxs("div",{className:"space-y-1.5 pt-1",children:[s.jsx("div",{className:"h-3 w-full bg-slate-100 rounded"}),s.jsx("div",{className:"h-3 w-[88%] bg-slate-100 rounded"}),s.jsx("div",{className:"h-3.5 w-16 bg-red-100 rounded"})," "]}),s.jsxs("div",{className:"h-48 md:h-56 bg-slate-50 border border-slate-100 rounded-2xl flex items-center justify-center relative overflow-hidden mt-3",children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-tr from-slate-100 to-slate-50/50"}),s.jsx("div",{className:"w-12 h-12 rounded-full bg-slate-200/50 flex items-center justify-center",children:s.jsx("div",{className:"w-4 h-4 bg-slate-300 rounded-full"})})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 max-w-md border-t border-gray-100 mt-4 text-gray-300",children:[s.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-150 flex items-center justify-center"}),s.jsx("div",{className:"h-2.5 w-5 bg-gray-200 rounded"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-150 flex items-center justify-center"}),s.jsx("div",{className:"h-2.5 w-7 bg-gray-200 rounded"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-150 flex items-center justify-center"}),s.jsx("div",{className:"h-2.5 w-8 bg-gray-200 rounded"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-100"}),s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-100"})]})]})]})]})}):e==="magazine"?s.jsxs("div",{className:"flex flex-col gap-8 p-6 border border-gray-100",children:[s.jsx(Uo,{className:"aspect-[4/5] w-full"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(Uo,{className:"h-3 w-20"}),s.jsx(Uo,{className:"h-8 w-full"}),s.jsx(Uo,{className:"h-8 w-3/4"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Uo,{className:"h-4 w-full"}),s.jsx(Uo,{className:"h-4 w-full"}),s.jsx(Uo,{className:"h-4 w-2/3"})]})]})]}):e==="compact"?s.jsxs("div",{className:"flex items-start gap-4 pb-4 border-b border-gray-100",children:[s.jsx(Uo,{className:"w-20 h-20 shrink-0"}),s.jsxs("div",{className:"flex-1 space-y-2",children:[s.jsx(Uo,{className:"h-2 w-12"}),s.jsx(Uo,{className:"h-4 w-full"}),s.jsx(Uo,{className:"h-4 w-3/4"})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsx(Uo,{className:"aspect-video w-full"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Uo,{className:"h-4 w-24"}),s.jsx(Uo,{className:"h-8 w-full"}),s.jsx(Uo,{className:"h-8 w-1/2"})]})]});function Nye(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Eye=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Aye=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_ye={};function X9(e,t){return(_ye.jsx?Aye:Eye).test(e)}const kye=/[ \t\n\f\r]/g;function Sye(e){return typeof e=="object"?e.type==="text"?Q9(e.value):!1:Q9(e)}function Q9(e){return e.replace(kye,"")===""}class rb{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}rb.prototype.normal={};rb.prototype.property={};rb.prototype.space=void 0;function wK(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new rb(n,r,t)}function oj(e){return e.toLowerCase()}class wl{constructor(t,n){this.attribute=n,this.property=t}}wl.prototype.attribute="";wl.prototype.booleanish=!1;wl.prototype.boolean=!1;wl.prototype.commaOrSpaceSeparated=!1;wl.prototype.commaSeparated=!1;wl.prototype.defined=!1;wl.prototype.mustUseProperty=!1;wl.prototype.number=!1;wl.prototype.overloadedBoolean=!1;wl.prototype.property="";wl.prototype.spaceSeparated=!1;wl.prototype.space=void 0;let Cye=0;const Vr=Em(),ca=Em(),lj=Em(),en=Em(),os=Em(),Z0=Em(),jl=Em();function Em(){return 2**++Cye}const cj=Object.freeze(Object.defineProperty({__proto__:null,boolean:Vr,booleanish:ca,commaOrSpaceSeparated:jl,commaSeparated:Z0,number:en,overloadedBoolean:lj,spaceSeparated:os},Symbol.toStringTag,{value:"Module"})),B_=Object.keys(cj);class g4 extends wl{constructor(t,n,r,i){let a=-1;if(super(t,n),Z9(this,"space",i),typeof r=="number")for(;++a4&&n.slice(0,4)==="data"&&Oye.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(J9,Mye);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!J9.test(a)){let o=a.replace(Pye,Dye);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=g4}return new i(r,t)}function Dye(e){return"-"+e.toLowerCase()}function Mye(e){return e.charAt(1).toUpperCase()}const Lye=wK([NK,jye,_K,kK,SK],"html"),x4=wK([NK,Iye,_K,kK,SK],"svg");function Uye(e){return e.join(" ").trim()}var y0={},z_,eL;function Bye(){if(eL)return z_;eL=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,c=/^\s+|\s+$/g,h=` `,f="/",m="*",y="",w="comment",A="declaration";function S(T,D){if(typeof T!="string")throw new TypeError("First argument must be a string");if(!T)return[];D=D||{};var V=1,L=1;function K(ye){var ne=ye.match(t);ne&&(V+=ne.length);var de=ye.lastIndexOf(h);L=~de?ye.length-de:L+ye.length}function Z(){var ye={line:V,column:L};return function(ne){return ne.position=new q(ye),F(),ne}}function q(ye){this.start=ye,this.end={line:V,column:L},this.source=D.source}q.prototype.content=T;function B(ye){var ne=new Error(D.source+":"+V+":"+L+": "+ye);if(ne.reason=ye,ne.filename=D.source,ne.line=V,ne.column=L,ne.source=T,!D.silent)throw ne}function z(ye){var ne=ye.exec(T);if(ne){var de=ne[0];return K(de),T=T.slice(de.length),ne}}function F(){z(n)}function $(ye){var ne;for(ye=ye||[];ne=Y();)ne!==!1&&ye.push(ne);return ye}function Y(){var ye=Z();if(!(f!=T.charAt(0)||m!=T.charAt(1))){for(var ne=2;y!=T.charAt(ne)&&(m!=T.charAt(ne)||f!=T.charAt(ne+1));)++ne;if(ne+=2,y===T.charAt(ne-1))return B("End of comment missing");var de=T.slice(2,ne-2);return L+=2,K(de),T=T.slice(ne),L+=2,ye({type:w,comment:de})}}function X(){var ye=Z(),ne=z(r);if(ne){if(Y(),!z(i))return B("property missing ':'");var de=z(a),be=ye({type:A,property:C(ne[0].replace(e,y)),value:de?C(de[0].replace(e,y)):y});return z(o),be}}function J(){var ye=[];$(ye);for(var ne;ne=X();)ne!==!1&&(ye.push(ne),$(ye));return ye}return F(),J()}function C(T){return T?T.replace(c,y):y}return z_=S,z_}var tL;function zye(){if(tL)return y0;tL=1;var e=y0&&y0.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(y0,"__esModule",{value:!0}),y0.default=n;const t=e(Bye());function n(r,i){let a=null;if(!r||typeof r!="string")return a;const o=(0,t.default)(r),c=typeof i=="function";return o.forEach(h=>{if(h.type!=="declaration")return;const{property:f,value:m}=h;c?i(f,m,h):m&&(a=a||{},a[f]=m)}),a}return y0}var e1={},nL;function Vye(){if(nL)return e1;nL=1,Object.defineProperty(e1,"__esModule",{value:!0}),e1.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,a=function(f){return!f||n.test(f)||e.test(f)},o=function(f,m){return m.toUpperCase()},c=function(f,m){return"".concat(m,"-")},h=function(f,m){return m===void 0&&(m={}),a(f)?f:(f=f.toLowerCase(),m.reactCompat?f=f.replace(i,c):f=f.replace(r,c),f.replace(t,o))};return e1.camelCase=h,e1}var t1,rL;function Fye(){if(rL)return t1;rL=1;var e=t1&&t1.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(zye()),n=Vye();function r(i,a){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(c,h){c&&h&&(o[(0,n.camelCase)(c,a)]=h)}),o}return r.default=r,t1=r,t1}var $ye=Fye();const Hye=Xu($ye),CK=jK("end"),y4=jK("start");function jK(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Gye(e){const t=y4(e),n=CK(e);if(t&&n)return{start:t,end:n}}function q1(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?iL(e.position):"start"in e||"end"in e?iL(e):"line"in e||"column"in e?uj(e):""}function uj(e){return sL(e&&e.line)+":"+sL(e&&e.column)}function iL(e){return uj(e&&e.start)+"-"+uj(e&&e.end)}function sL(e){return e&&typeof e=="number"?e:1}class jo extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",a={},o=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(o=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const h=r.indexOf(":");h===-1?a.ruleId=r:(a.source=r.slice(0,h),a.ruleId=r.slice(h+1))}if(!a.place&&a.ancestors&&a.ancestors){const h=a.ancestors[a.ancestors.length-1];h&&(a.place=h.position)}const c=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=c?c.line:void 0,this.name=q1(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack=="string"?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}jo.prototype.file="";jo.prototype.name="";jo.prototype.reason="";jo.prototype.message="";jo.prototype.stack="";jo.prototype.column=void 0;jo.prototype.line=void 0;jo.prototype.ancestors=void 0;jo.prototype.cause=void 0;jo.prototype.fatal=void 0;jo.prototype.place=void 0;jo.prototype.ruleId=void 0;jo.prototype.source=void 0;const b4={}.hasOwnProperty,qye=new Map,Wye=/[A-Z]/g,Kye=new Set(["table","tbody","thead","tfoot","tr"]),Yye=new Set(["td","th"]),IK="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Xye(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=ibe(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=rbe(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?x4:Lye,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=TK(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function TK(e,t,n){if(t.type==="element")return Qye(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Zye(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return ebe(e,t,n);if(t.type==="mdxjsEsm")return Jye(e,t);if(t.type==="root")return tbe(e,t,n);if(t.type==="text")return nbe(e,t)}function Qye(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=x4,e.schema=i),e.ancestors.push(t);const a=OK(e,t.tagName,!1),o=sbe(e,t);let c=w4(e,t);return Kye.has(t.tagName)&&(c=c.filter(function(h){return typeof h=="string"?!Sye(h):!0})),PK(e,o,a,t),v4(o,c),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Zye(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}yy(e,t.position)}function Jye(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);yy(e,t.position)}function ebe(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=x4,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:OK(e,t.name,!0),o=abe(e,t),c=w4(e,t);return PK(e,o,a,t),v4(o,c),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function tbe(e,t,n){const r={};return v4(r,w4(e,t)),e.create(t,e.Fragment,r,n)}function nbe(e,t){return t.value}function PK(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function v4(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function rbe(e,t,n){return r;function r(i,a,o,c){const f=Array.isArray(o.children)?n:t;return c?f(a,o,c):f(a,o)}}function ibe(e,t){return n;function n(r,i,a,o){const c=Array.isArray(a.children),h=y4(r);return t(i,a,o,c,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function sbe(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&b4.call(t.properties,i)){const a=obe(e,i,t.properties[i]);if(a){const[o,c]=a;e.tableCellAlignToStyle&&o==="align"&&typeof c=="string"&&Yye.has(t.tagName)?r=c:n[o]=c}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function abe(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const o=a.expression;o.type;const c=o.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else yy(e,t.position);else{const i=r.name;let a;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,a=e.evaluater.evaluateExpression(c.expression)}else yy(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function w4(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:qye;for(;++ri?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a0?($u(e,e.length,0,t),e):t}const lL={}.hasOwnProperty;function mbe(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function J0(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Su=If(/[A-Za-z]/),Ml=If(/[\dA-Za-z]/),ybe=If(/[#-'*+\--9=?A-Z^-~]/);function dj(e){return e!==null&&(e<32||e===127)}const hj=If(/\d/),bbe=If(/[\dA-Fa-f]/),vbe=If(/[!-/:-@[-`{-~]/);function kr(e){return e!==null&&e<-2}function vl(e){return e!==null&&(e<0||e===32)}function Ti(e){return e===-2||e===-1||e===32}const wbe=If(new RegExp("\\p{P}|\\p{S}","u")),Nbe=If(/\s/);function If(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Kg(e){const t=[];let n=-1,r=0,i=0;for(;++n55295&&a<57344){const c=e.charCodeAt(n+1);a<56320&&c>56319&&c<57344?(o=String.fromCharCode(a,c),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function us(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(h){return Ti(h)?(e.enter(n),c(h)):t(h)}function c(h){return Ti(h)&&a++o))return;const B=t.events.length;let z=B,F,$;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){if(F){$=t.events[z][1].end;break}F=!0}for(D(r),q=B;qL;){const Z=n[K];t.containerState=Z[1],Z[0].exit.call(t,e)}n.length=L}function V(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Sbe(e,t,n){return us(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function uL(e){if(e===null||vl(e)||Nbe(e))return 1;if(wbe(e))return 2}function E4(e,t,n){const r=[];let i=-1;for(;++i1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const y={...e[r][1].end},w={...e[n][1].start};dL(y,-h),dL(w,h),o={type:h>1?"strongSequence":"emphasisSequence",start:y,end:{...e[r][1].end}},c={type:h>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:w},a={type:h>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:h>1?"strong":"emphasis",start:{...o.start},end:{...c.end}},e[r][1].end={...o.start},e[n][1].start={...c.end},f=[],e[r][1].end.offset-e[r][1].start.offset&&(f=cc(f,[["enter",e[r][1],t],["exit",e[r][1],t]])),f=cc(f,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",a,t]]),f=cc(f,E4(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),f=cc(f,[["exit",a,t],["enter",c,t],["exit",c,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(m=2,f=cc(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):m=0,$u(e,r-1,n-r+3,f),n=r+f.length-m-2;break}}for(n=-1;++n0&&Ti(q)?us(e,V,"linePrefix",a+1)(q):V(q)}function V(q){return q===null||kr(q)?e.check(hL,C,K)(q):(e.enter("codeFlowValue"),L(q))}function L(q){return q===null||kr(q)?(e.exit("codeFlowValue"),V(q)):(e.consume(q),L)}function K(q){return e.exit("codeFenced"),t(q)}function Z(q,B,z){let F=0;return $;function $(ne){return q.enter("lineEnding"),q.consume(ne),q.exit("lineEnding"),Y}function Y(ne){return q.enter("codeFencedFence"),Ti(ne)?us(q,X,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ne):X(ne)}function X(ne){return ne===c?(q.enter("codeFencedFenceSequence"),J(ne)):z(ne)}function J(ne){return ne===c?(F++,q.consume(ne),J):F>=o?(q.exit("codeFencedFenceSequence"),Ti(ne)?us(q,ye,"whitespace")(ne):ye(ne)):z(ne)}function ye(ne){return ne===null||kr(ne)?(q.exit("codeFencedFence"),B(ne)):z(ne)}}}function Bbe(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const F_={name:"codeIndented",tokenize:Vbe},zbe={partial:!0,tokenize:Fbe};function Vbe(e,t,n){const r=this;return i;function i(f){return e.enter("codeIndented"),us(e,a,"linePrefix",5)(f)}function a(f){const m=r.events[r.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?o(f):n(f)}function o(f){return f===null?h(f):kr(f)?e.attempt(zbe,o,h)(f):(e.enter("codeFlowValue"),c(f))}function c(f){return f===null||kr(f)?(e.exit("codeFlowValue"),o(f)):(e.consume(f),c)}function h(f){return e.exit("codeIndented"),t(f)}}function Fbe(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):kr(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):us(e,a,"linePrefix",5)(o)}function a(o){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(o):kr(o)?i(o):n(o)}}const $be={name:"codeText",previous:Gbe,resolve:Hbe,tokenize:qbe};function Hbe(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&n1(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),n1(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),n1(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function zK(e,t,n,r,i,a,o,c,h){const f=h||Number.POSITIVE_INFINITY;let m=0;return y;function y(D){return D===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(D),e.exit(a),w):D===null||D===32||D===41||dj(D)?n(D):(e.enter(r),e.enter(o),e.enter(c),e.enter("chunkString",{contentType:"string"}),C(D))}function w(D){return D===62?(e.enter(a),e.consume(D),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),A(D))}function A(D){return D===62?(e.exit("chunkString"),e.exit(c),w(D)):D===null||D===60||kr(D)?n(D):(e.consume(D),D===92?S:A)}function S(D){return D===60||D===62||D===92?(e.consume(D),A):A(D)}function C(D){return!m&&(D===null||D===41||vl(D))?(e.exit("chunkString"),e.exit(c),e.exit(o),e.exit(r),t(D)):m999||A===null||A===91||A===93&&!h||A===94&&!c&&"_hiddenFootnoteSupport"in o.parser.constructs?n(A):A===93?(e.exit(a),e.enter(i),e.consume(A),e.exit(i),e.exit(r),t):kr(A)?(e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),y(A))}function y(A){return A===null||A===91||A===93||kr(A)||c++>999?(e.exit("chunkString"),m(A)):(e.consume(A),h||(h=!Ti(A)),A===92?w:y)}function w(A){return A===91||A===92||A===93?(e.consume(A),c++,y):y(A)}}function FK(e,t,n,r,i,a){let o;return c;function c(w){return w===34||w===39||w===40?(e.enter(r),e.enter(i),e.consume(w),e.exit(i),o=w===40?41:w,h):n(w)}function h(w){return w===o?(e.enter(i),e.consume(w),e.exit(i),e.exit(r),t):(e.enter(a),f(w))}function f(w){return w===o?(e.exit(a),h(o)):w===null?n(w):kr(w)?(e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),us(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(w))}function m(w){return w===o||w===null||kr(w)?(e.exit("chunkString"),f(w)):(e.consume(w),w===92?y:m)}function y(w){return w===o||w===92?(e.consume(w),m):m(w)}}function W1(e,t){let n;return r;function r(i){return kr(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ti(i)?us(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const eve={name:"definition",tokenize:nve},tve={partial:!0,tokenize:rve};function nve(e,t,n){const r=this;let i;return a;function a(A){return e.enter("definition"),o(A)}function o(A){return VK.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(A)}function c(A){return i=J0(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),A===58?(e.enter("definitionMarker"),e.consume(A),e.exit("definitionMarker"),h):n(A)}function h(A){return vl(A)?W1(e,f)(A):f(A)}function f(A){return zK(e,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(A)}function m(A){return e.attempt(tve,y,y)(A)}function y(A){return Ti(A)?us(e,w,"whitespace")(A):w(A)}function w(A){return A===null||kr(A)?(e.exit("definition"),r.parser.defined.push(i),t(A)):n(A)}}function rve(e,t,n){return r;function r(c){return vl(c)?W1(e,i)(c):n(c)}function i(c){return FK(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function a(c){return Ti(c)?us(e,o,"whitespace")(c):o(c)}function o(c){return c===null||kr(c)?t(c):n(c)}}const ive={name:"hardBreakEscape",tokenize:sve};function sve(e,t,n){return r;function r(a){return e.enter("hardBreakEscape"),e.consume(a),i}function i(a){return kr(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const ave={name:"headingAtx",resolve:ove,tokenize:lve};function ove(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},a={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},$u(e,r,n-r+1,[["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t]])),e}function lve(e,t,n){let r=0;return i;function i(m){return e.enter("atxHeading"),a(m)}function a(m){return e.enter("atxHeadingSequence"),o(m)}function o(m){return m===35&&r++<6?(e.consume(m),o):m===null||vl(m)?(e.exit("atxHeadingSequence"),c(m)):n(m)}function c(m){return m===35?(e.enter("atxHeadingSequence"),h(m)):m===null||kr(m)?(e.exit("atxHeading"),t(m)):Ti(m)?us(e,c,"whitespace")(m):(e.enter("atxHeadingText"),f(m))}function h(m){return m===35?(e.consume(m),h):(e.exit("atxHeadingSequence"),c(m))}function f(m){return m===null||m===35||vl(m)?(e.exit("atxHeadingText"),c(m)):(e.consume(m),f)}}const cve=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],pL=["pre","script","style","textarea"],uve={concrete:!0,name:"htmlFlow",resolveTo:fve,tokenize:pve},dve={partial:!0,tokenize:gve},hve={partial:!0,tokenize:mve};function fve(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function pve(e,t,n){const r=this;let i,a,o,c,h;return f;function f(re){return m(re)}function m(re){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(re),y}function y(re){return re===33?(e.consume(re),w):re===47?(e.consume(re),a=!0,C):re===63?(e.consume(re),i=3,r.interrupt?t:G):Su(re)?(e.consume(re),o=String.fromCharCode(re),T):n(re)}function w(re){return re===45?(e.consume(re),i=2,A):re===91?(e.consume(re),i=5,c=0,S):Su(re)?(e.consume(re),i=4,r.interrupt?t:G):n(re)}function A(re){return re===45?(e.consume(re),r.interrupt?t:G):n(re)}function S(re){const Me="CDATA[";return re===Me.charCodeAt(c++)?(e.consume(re),c===Me.length?r.interrupt?t:X:S):n(re)}function C(re){return Su(re)?(e.consume(re),o=String.fromCharCode(re),T):n(re)}function T(re){if(re===null||re===47||re===62||vl(re)){const Me=re===47,nt=o.toLowerCase();return!Me&&!a&&pL.includes(nt)?(i=1,r.interrupt?t(re):X(re)):cve.includes(o.toLowerCase())?(i=6,Me?(e.consume(re),D):r.interrupt?t(re):X(re)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(re):a?V(re):L(re))}return re===45||Ml(re)?(e.consume(re),o+=String.fromCharCode(re),T):n(re)}function D(re){return re===62?(e.consume(re),r.interrupt?t:X):n(re)}function V(re){return Ti(re)?(e.consume(re),V):$(re)}function L(re){return re===47?(e.consume(re),$):re===58||re===95||Su(re)?(e.consume(re),K):Ti(re)?(e.consume(re),L):$(re)}function K(re){return re===45||re===46||re===58||re===95||Ml(re)?(e.consume(re),K):Z(re)}function Z(re){return re===61?(e.consume(re),q):Ti(re)?(e.consume(re),Z):L(re)}function q(re){return re===null||re===60||re===61||re===62||re===96?n(re):re===34||re===39?(e.consume(re),h=re,B):Ti(re)?(e.consume(re),q):z(re)}function B(re){return re===h?(e.consume(re),h=null,F):re===null||kr(re)?n(re):(e.consume(re),B)}function z(re){return re===null||re===34||re===39||re===47||re===60||re===61||re===62||re===96||vl(re)?Z(re):(e.consume(re),z)}function F(re){return re===47||re===62||Ti(re)?L(re):n(re)}function $(re){return re===62?(e.consume(re),Y):n(re)}function Y(re){return re===null||kr(re)?X(re):Ti(re)?(e.consume(re),Y):n(re)}function X(re){return re===45&&i===2?(e.consume(re),de):re===60&&i===1?(e.consume(re),be):re===62&&i===4?(e.consume(re),se):re===63&&i===3?(e.consume(re),G):re===93&&i===5?(e.consume(re),Ke):kr(re)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(dve,xe,J)(re)):re===null||kr(re)?(e.exit("htmlFlowData"),J(re)):(e.consume(re),X)}function J(re){return e.check(hve,ye,xe)(re)}function ye(re){return e.enter("lineEnding"),e.consume(re),e.exit("lineEnding"),ne}function ne(re){return re===null||kr(re)?J(re):(e.enter("htmlFlowData"),X(re))}function de(re){return re===45?(e.consume(re),G):X(re)}function be(re){return re===47?(e.consume(re),o="",Ce):X(re)}function Ce(re){if(re===62){const Me=o.toLowerCase();return pL.includes(Me)?(e.consume(re),se):X(re)}return Su(re)&&o.length<8?(e.consume(re),o+=String.fromCharCode(re),Ce):X(re)}function Ke(re){return re===93?(e.consume(re),G):X(re)}function G(re){return re===62?(e.consume(re),se):re===45&&i===2?(e.consume(re),G):X(re)}function se(re){return re===null||kr(re)?(e.exit("htmlFlowData"),xe(re)):(e.consume(re),se)}function xe(re){return e.exit("htmlFlow"),t(re)}}function mve(e,t,n){const r=this;return i;function i(o){return kr(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function gve(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt($E,t,n)}}const xve={name:"htmlText",tokenize:yve};function yve(e,t,n){const r=this;let i,a,o;return c;function c(G){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(G),h}function h(G){return G===33?(e.consume(G),f):G===47?(e.consume(G),Z):G===63?(e.consume(G),L):Su(G)?(e.consume(G),z):n(G)}function f(G){return G===45?(e.consume(G),m):G===91?(e.consume(G),a=0,S):Su(G)?(e.consume(G),V):n(G)}function m(G){return G===45?(e.consume(G),A):n(G)}function y(G){return G===null?n(G):G===45?(e.consume(G),w):kr(G)?(o=y,be(G)):(e.consume(G),y)}function w(G){return G===45?(e.consume(G),A):y(G)}function A(G){return G===62?de(G):G===45?w(G):y(G)}function S(G){const se="CDATA[";return G===se.charCodeAt(a++)?(e.consume(G),a===se.length?C:S):n(G)}function C(G){return G===null?n(G):G===93?(e.consume(G),T):kr(G)?(o=C,be(G)):(e.consume(G),C)}function T(G){return G===93?(e.consume(G),D):C(G)}function D(G){return G===62?de(G):G===93?(e.consume(G),D):C(G)}function V(G){return G===null||G===62?de(G):kr(G)?(o=V,be(G)):(e.consume(G),V)}function L(G){return G===null?n(G):G===63?(e.consume(G),K):kr(G)?(o=L,be(G)):(e.consume(G),L)}function K(G){return G===62?de(G):L(G)}function Z(G){return Su(G)?(e.consume(G),q):n(G)}function q(G){return G===45||Ml(G)?(e.consume(G),q):B(G)}function B(G){return kr(G)?(o=B,be(G)):Ti(G)?(e.consume(G),B):de(G)}function z(G){return G===45||Ml(G)?(e.consume(G),z):G===47||G===62||vl(G)?F(G):n(G)}function F(G){return G===47?(e.consume(G),de):G===58||G===95||Su(G)?(e.consume(G),$):kr(G)?(o=F,be(G)):Ti(G)?(e.consume(G),F):de(G)}function $(G){return G===45||G===46||G===58||G===95||Ml(G)?(e.consume(G),$):Y(G)}function Y(G){return G===61?(e.consume(G),X):kr(G)?(o=Y,be(G)):Ti(G)?(e.consume(G),Y):F(G)}function X(G){return G===null||G===60||G===61||G===62||G===96?n(G):G===34||G===39?(e.consume(G),i=G,J):kr(G)?(o=X,be(G)):Ti(G)?(e.consume(G),X):(e.consume(G),ye)}function J(G){return G===i?(e.consume(G),i=void 0,ne):G===null?n(G):kr(G)?(o=J,be(G)):(e.consume(G),J)}function ye(G){return G===null||G===34||G===39||G===60||G===61||G===96?n(G):G===47||G===62||vl(G)?F(G):(e.consume(G),ye)}function ne(G){return G===47||G===62||vl(G)?F(G):n(G)}function de(G){return G===62?(e.consume(G),e.exit("htmlTextData"),e.exit("htmlText"),t):n(G)}function be(G){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(G),e.exit("lineEnding"),Ce}function Ce(G){return Ti(G)?us(e,Ke,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(G):Ke(G)}function Ke(G){return e.enter("htmlTextData"),o(G)}}const A4={name:"labelEnd",resolveAll:Nve,resolveTo:Eve,tokenize:Ave},bve={tokenize:_ve},vve={tokenize:kve},wve={tokenize:Sve};function Nve(e){let t=-1;const n=[];for(;++t=3&&(f===null||kr(f))?(e.exit("thematicBreak"),t(f)):n(f)}function h(f){return f===i?(e.consume(f),r++,h):(e.exit("thematicBreakSequence"),Ti(f)?us(e,c,"whitespace")(f):c(f))}}const hl={continuation:{tokenize:Lve},exit:Bve,name:"list",tokenize:Mve},Rve={partial:!0,tokenize:zve},Dve={partial:!0,tokenize:Uve};function Mve(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return c;function c(A){const S=r.containerState.type||(A===42||A===43||A===45?"listUnordered":"listOrdered");if(S==="listUnordered"?!r.containerState.marker||A===r.containerState.marker:hj(A)){if(r.containerState.type||(r.containerState.type=S,e.enter(S,{_container:!0})),S==="listUnordered")return e.enter("listItemPrefix"),A===42||A===45?e.check(Xw,n,f)(A):f(A);if(!r.interrupt||A===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(A)}return n(A)}function h(A){return hj(A)&&++o<10?(e.consume(A),h):(!r.interrupt||o<2)&&(r.containerState.marker?A===r.containerState.marker:A===41||A===46)?(e.exit("listItemValue"),f(A)):n(A)}function f(A){return e.enter("listItemMarker"),e.consume(A),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||A,e.check($E,r.interrupt?n:m,e.attempt(Rve,w,y))}function m(A){return r.containerState.initialBlankLine=!0,a++,w(A)}function y(A){return Ti(A)?(e.enter("listItemPrefixWhitespace"),e.consume(A),e.exit("listItemPrefixWhitespace"),w):n(A)}function w(A){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(A)}}function Lve(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check($E,i,a);function i(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,us(e,t,"listItemIndent",r.containerState.size+1)(c)}function a(c){return r.containerState.furtherBlankLines||!Ti(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Dve,t,o)(c))}function o(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,us(e,e.attempt(hl,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function Uve(e,t,n){const r=this;return us(e,i,"listItemIndent",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function Bve(e){e.exit(this.containerState.type)}function zve(e,t,n){const r=this;return us(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!Ti(a)&&o&&o[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const mL={name:"setextUnderline",resolveTo:Vve,tokenize:Fve};function Vve(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",a?(e.splice(i,0,["enter",o,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Fve(e,t,n){const r=this;let i;return a;function a(f){let m=r.events.length,y;for(;m--;)if(r.events[m][1].type!=="lineEnding"&&r.events[m][1].type!=="linePrefix"&&r.events[m][1].type!=="content"){y=r.events[m][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||y)?(e.enter("setextHeadingLine"),i=f,o(f)):n(f)}function o(f){return e.enter("setextHeadingLineSequence"),c(f)}function c(f){return f===i?(e.consume(f),c):(e.exit("setextHeadingLineSequence"),Ti(f)?us(e,h,"lineSuffix")(f):h(f))}function h(f){return f===null||kr(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const $ve={tokenize:Hve};function Hve(e){const t=this,n=e.attempt($E,r,e.attempt(this.parser.constructs.flowInitial,i,us(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Ybe,i)),"linePrefix")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Gve={resolveAll:HK()},qve=$K("string"),Wve=$K("text");function $K(e){return{resolveAll:HK(e==="text"?Kve:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,c);return o;function o(m){return f(m)?a(m):c(m)}function c(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),h}function h(m){return f(m)?(n.exit("data"),a(m)):(n.consume(m),h)}function f(m){if(m===null)return!0;const y=i[m];let w=-1;if(y)for(;++w-1){const c=o[0];typeof c=="string"?o[0]=c.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function owe(e,t){let n=-1;const r=[];let i;for(;++n0){const gr=cn.tokenStack[cn.tokenStack.length-1];(gr[1]||xL).call(cn,void 0,gr[0])}for(Mt.position={start:Lh(Ve.length>0?Ve[0][1].start:{line:1,column:1,offset:0}),end:Lh(Ve.length>0?Ve[Ve.length-2][1].end:{line:1,column:1,offset:0})},mr=-1;++mr0&&(r.className=["language-"+i[0]]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:"element",tagName:"pre",properties:{},children:[a]},e.patch(t,a),a}function wwe(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Nwe(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ewe(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Kg(r.toLowerCase()),a=e.footnoteOrder.indexOf(r);let o,c=e.footnoteCounts.get(r);c===void 0?(c=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,c+=1,e.footnoteCounts.set(r,c);const h={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,h);const f={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(t,f),e.applyData(t,f)}function Awe(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function _we(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function WK(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),a=i[0];a&&a.type==="text"?a.value="["+a.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function kwe(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return WK(e,t);const i={src:Kg(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function Swe(e,t){const n={src:Kg(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Cwe(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function jwe(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return WK(e,t);const i={href:Kg(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function Iwe(e,t){const n={href:Kg(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Twe(e,t,n){const r=e.all(t),i=n?Pwe(n):KK(t),a={},o=[];if(typeof t.checked=="boolean"){const m=r[0];let y;m&&m.type==="element"&&m.tagName==="p"?y=m:(y={type:"element",tagName:"p",properties:{},children:[]},r.unshift(y)),y.children.length>0&&y.children.unshift({type:"text",value:" "}),y.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let c=-1;for(;++c1}function Owe(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=y4(t.children[1]),h=CK(t.children[t.children.length-1]);c&&h&&(o.position={start:c,end:h}),i.push(o)}const a={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function Uwe(e,t,n){const r=n?n.children:void 0,a=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,c=o?o.length:t.children.length;let h=-1;const f=[];for(;++h0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(vL(t.slice(i),i>0,!1)),a.join("")}function vL(e,t,n){let r=0,i=e.length;if(t){let a=e.codePointAt(r);for(;a===yL||a===bL;)r++,a=e.codePointAt(r)}if(n){let a=e.codePointAt(i-1);for(;a===yL||a===bL;)i--,a=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Vwe(e,t){const n={type:"text",value:zwe(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Fwe(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const $we={blockquote:ywe,break:bwe,code:vwe,delete:wwe,emphasis:Nwe,footnoteReference:Ewe,heading:Awe,html:_we,imageReference:kwe,image:Swe,inlineCode:Cwe,linkReference:jwe,link:Iwe,listItem:Twe,list:Owe,paragraph:Rwe,root:Dwe,strong:Mwe,table:Lwe,tableCell:Bwe,tableRow:Uwe,text:Vwe,thematicBreak:Fwe,toml:Zv,yaml:Zv,definition:Zv,footnoteDefinition:Zv};function Zv(){}const YK=-1,HE=0,K1=1,Y2=2,_4=3,k4=4,S4=5,C4=6,XK=7,QK=8,wL=typeof self=="object"?self:globalThis,Hwe=(e,t)=>{const n=(i,a)=>(e.set(a,i),i),r=i=>{if(e.has(i))return e.get(i);const[a,o]=t[i];switch(a){case HE:case YK:return n(o,i);case K1:{const c=n([],i);for(const h of o)c.push(r(h));return c}case Y2:{const c=n({},i);for(const[h,f]of o)c[r(h)]=r(f);return c}case _4:return n(new Date(o),i);case k4:{const{source:c,flags:h}=o;return n(new RegExp(c,h),i)}case S4:{const c=n(new Map,i);for(const[h,f]of o)c.set(r(h),r(f));return c}case C4:{const c=n(new Set,i);for(const h of o)c.add(r(h));return c}case XK:{const{name:c,message:h}=o;return n(new wL[c](h),i)}case QK:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:c}=new Uint8Array(o);return n(new DataView(c),o)}}return n(new wL[a](o),i)};return r},NL=e=>Hwe(new Map,e)(0),b0="",{toString:Gwe}={},{keys:qwe}=Object,r1=e=>{const t=typeof e;if(t!=="object"||!e)return[HE,t];const n=Gwe.call(e).slice(8,-1);switch(n){case"Array":return[K1,b0];case"Object":return[Y2,b0];case"Date":return[_4,b0];case"RegExp":return[k4,b0];case"Map":return[S4,b0];case"Set":return[C4,b0];case"DataView":return[K1,n]}return n.includes("Array")?[K1,n]:n.includes("Error")?[XK,n]:[Y2,n]},Jv=([e,t])=>e===HE&&(t==="function"||t==="symbol"),Wwe=(e,t,n,r)=>{const i=(o,c)=>{const h=r.push(o)-1;return n.set(c,h),h},a=o=>{if(n.has(o))return n.get(o);let[c,h]=r1(o);switch(c){case HE:{let m=o;switch(h){case"bigint":c=QK,m=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);m=null;break;case"undefined":return i([YK],o)}return i([c,m],o)}case K1:{if(h){let w=o;return h==="DataView"?w=new Uint8Array(o.buffer):h==="ArrayBuffer"&&(w=new Uint8Array(o)),i([h,[...w]],o)}const m=[],y=i([c,m],o);for(const w of o)m.push(a(w));return y}case Y2:{if(h)switch(h){case"BigInt":return i([h,o.toString()],o);case"Boolean":case"Number":case"String":return i([h,o.valueOf()],o)}if(t&&"toJSON"in o)return a(o.toJSON());const m=[],y=i([c,m],o);for(const w of qwe(o))(e||!Jv(r1(o[w])))&&m.push([a(w),a(o[w])]);return y}case _4:return i([c,o.toISOString()],o);case k4:{const{source:m,flags:y}=o;return i([c,{source:m,flags:y}],o)}case S4:{const m=[],y=i([c,m],o);for(const[w,A]of o)(e||!(Jv(r1(w))||Jv(r1(A))))&&m.push([a(w),a(A)]);return y}case C4:{const m=[],y=i([c,m],o);for(const w of o)(e||!Jv(r1(w)))&&m.push(a(w));return y}}const{message:f}=o;return i([c,{name:h,message:f}],o)};return a},EL=(e,{json:t,lossy:n}={})=>{const r=[];return Wwe(!(t||n),!!t,new Map,r)(e),r},X2=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?NL(EL(e,t)):structuredClone(e):(e,t)=>NL(EL(e,t));function Kwe(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Ywe(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Xwe(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Kwe,r=e.options.footnoteBackLabel||Ywe,i=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let h=-1;for(;++h0&&S.push({type:"text",value:" "});let V=typeof n=="string"?n:n(h,A);typeof V=="string"&&(V={type:"text",value:V}),S.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+w+(A>1?"-"+A:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(h,A),className:["data-footnote-backref"]},children:Array.isArray(V)?V:[V]})}const T=m[m.length-1];if(T&&T.type==="element"&&T.tagName==="p"){const V=T.children[T.children.length-1];V&&V.type==="text"?V.value+=" ":T.children.push({type:"text",value:" "}),T.children.push(...S)}else m.push(...S);const D={type:"element",tagName:"li",properties:{id:t+"fn-"+w},children:e.wrap(m,!0)};e.patch(f,D),c.push(D)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...X2(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:` `},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:` `}]}}const ZK=(function(e){if(e==null)return e2e;if(typeof e=="function")return GE(e);if(typeof e=="object")return Array.isArray(e)?Qwe(e):Zwe(e);if(typeof e=="string")return Jwe(e);throw new Error("Expected function, string, or object as test")});function Qwe(e){const t=[];let n=-1;for(;++n":""))+")"})}return w;function w(){let A=JK,S,C,T;if((!t||a(h,f,m[m.length-1]||void 0))&&(A=s2e(n(h,m)),A[0]===AL))return A;if("children"in h&&h.children){const D=h;if(D.children&&A[0]!==r2e)for(C=(r?D.children.length:-1)+o,T=m.concat(D);C>-1&&C0&&n.push({type:"text",value:` `}),n}function _L(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function kL(e,t){const n=o2e(e,t),r=n.one(e,void 0),i=Xwe(n),a=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&a.children.push({type:"text",value:` `},i),a}function h2e(e,t){return e&&"run"in e?async function(n,r){const i=kL(n,{file:r,...t});await e.run(i,r)}:function(n,r){return kL(n,{file:r,...e||t})}}function SL(e){if(e)throw e}var H_,CL;function f2e(){if(CL)return H_;CL=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},a=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var m=e.call(f,"constructor"),y=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!m&&!y)return!1;var w;for(w in f);return typeof w>"u"||e.call(f,w)},o=function(f,m){n&&m.name==="__proto__"?n(f,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):f[m.name]=m.newValue},c=function(f,m){if(m==="__proto__")if(e.call(f,m)){if(r)return r(f,m).value}else return;return f[m]};return H_=function h(){var f,m,y,w,A,S,C=arguments[0],T=1,D=arguments.length,V=!1;for(typeof C=="boolean"&&(V=C,C=arguments[1]||{},T=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});To.length;let h;c&&o.push(i);try{h=e.apply(this,o)}catch(f){const m=f;if(c&&n)throw m;return i(m)}c||(h&&h.then&&typeof h.then=="function"?h.then(a,i):h instanceof Error?i(h):a(h))}function i(o,...c){n||(n=!0,t(o,...c))}function a(o){i(null,o)}}const bu={basename:x2e,dirname:y2e,extname:b2e,join:v2e,sep:"/"};function x2e(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');ib(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,c=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),c>-1&&(e.codePointAt(i)===t.codePointAt(c--)?c<0&&(r=i):(c=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function y2e(e){if(ib(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function b2e(e){ib(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){const c=e.codePointAt(t);if(c===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),c===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function v2e(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function N2e(e,t){let n="",r=0,i=-1,a=0,o=-1,c,h;for(;++o<=e.length;){if(o2){if(h=n.lastIndexOf("/"),h!==n.length-1){h<0?(n="",r=0):(n=n.slice(0,h),r=n.length-1-n.lastIndexOf("/")),i=o,a=0;continue}}else if(n.length>0){n="",r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else c===46&&a>-1?a++:a=-1}return n}function ib(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const E2e={cwd:A2e};function A2e(){return"/"}function gj(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function _2e(e){if(typeof e=="string")e=new URL(e);else if(!gj(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return k2e(e)}function k2e(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n0){let[A,...S]=m;const C=r[w][1];mj(C)&&mj(A)&&(A=G_(!0,C,A)),r[w]=[f,A,...S]}}}}const I2e=new j4().freeze();function Y_(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function X_(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Q_(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function IL(e){if(!mj(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function TL(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ew(e){return T2e(e)?e:new tY(e)}function T2e(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function P2e(e){return typeof e=="string"||O2e(e)}function O2e(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const R2e="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",PL=[],OL={allowDangerousHtml:!0},D2e=/^(https?|ircs?|mailto|xmpp)$/i,M2e=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Y1(e){const t=L2e(e),n=U2e(e);return B2e(t.runSync(t.parse(n),n),e)}function L2e(e){const t=e.rehypePlugins||PL,n=e.remarkPlugins||PL,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...OL}:OL;return I2e().use(xwe).use(n).use(h2e,r).use(t)}function U2e(e){const t=e.children||"",n=new tY;return typeof t=="string"&&(n.value=t),n}function B2e(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,c=t.unwrapDisallowed,h=t.urlTransform||z2e;for(const m of M2e)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+R2e+m.id,void 0);return eY(e,f),Xye(e,{Fragment:s.Fragment,components:i,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function f(m,y,w){if(m.type==="raw"&&w&&typeof y=="number")return o?w.children.splice(y,1):w.children[y]={type:"text",value:m.value},y;if(m.type==="element"){let A;for(A in V_)if(Object.hasOwn(V_,A)&&Object.hasOwn(m.properties,A)){const S=m.properties[A],C=V_[A];(C===null||C.includes(m.tagName))&&(m.properties[A]=h(String(S||""),A,m))}}if(m.type==="element"){let A=n?!n.includes(m.tagName):a?a.includes(m.tagName):!1;if(!A&&r&&typeof y=="number"&&(A=!r(m,y,w)),A&&w&&typeof y=="number")return c&&m.children?w.children.splice(y,1,...m.children):w.children.splice(y,1),y}}}function z2e(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||D2e.test(e.slice(0,t))?e:""}const nY=({onOpenPosts:e,onAuthorClick:t})=>{const[n,r]=I.useState("all"),[i,a]=I.useState([]),[o,c]=I.useState([]),[h,f]=I.useState(!0),[m,y]=I.useState(!0),[w,A]=I.useState(null),[S,C]=I.useState(1),[T,D]=I.useState(""),[V,L]=I.useState(!1),[K,Z]=I.useState(!1),[q,B]=I.useState(null),[,z]=I.useState(null),[F,$]=I.useState(!1),[Y,X]=I.useState({}),J=()=>{if(e)e();else{const G=new CustomEvent("setTab",{detail:"posts"});window.dispatchEvent(G),window.scrollTo({top:0,behavior:"smooth"})}},ye=G=>{t?t(G):J()};I.useEffect(()=>{(async()=>{var se,xe,re,Me;if(Ne.currentUser){const nt=["atwiinevictor2@gmail.com","campuseye@gmail.com"];try{const ze=await cs(Je(he,"admins",Ne.currentUser.uid)),Tt=await cs(Je(he,"users",Ne.currentUser.uid)),It=ze.exists()&&((se=ze.data())==null?void 0:se.isAdmin)===!0||Tt.exists()&&(((xe=Tt.data())==null?void 0:xe.isAdmin)===!0||((re=Tt.data())==null?void 0:re.role)==="admin")||nt.includes(Ne.currentUser.email||"");$(It)}catch{$(nt.includes(((Me=Ne.currentUser)==null?void 0:Me.email)||""))}}else $(!1)})()},[]),I.useEffect(()=>{const G=Qt(et(he,"tickets"),ui("createdAt","desc"),vi(10)),se=Wr(G,xe=>{const re=xe.docs.map(Me=>({id:Me.id,...Me.data()}));a(re),f(!1)},xe=>{console.warn("Failed to load tickets for live feed embed:",xe),f(!1)});return()=>se()},[]),I.useEffect(()=>{const G=Qt(et(he,"posts"),ui("createdAt","desc"),vi(10)),se=Wr(G,xe=>{const re=xe.docs.map(Me=>({id:Me.id,...Me.data()}));c(re),y(!1)},xe=>{console.warn("Failed to load posts for live event dispatch:",xe),y(!1)});return()=>se()},[]);const ne=async(G,se)=>{if(G.stopPropagation(),!Ne.currentUser){pe.error("Please sign in to like this post");return}const xe=Ne.currentUser.uid,re=Y[se.id]||se.likedBy&&se.likedBy.includes(xe);X(Me=>({...Me,[se.id]:!re})),c(Me=>Me.map(nt=>nt.id===se.id?{...nt,likeCount:re?Math.max(0,(nt.likeCount||1)-1):(nt.likeCount||0)+1,likedBy:re?(nt.likedBy||[]).filter(ze=>ze!==xe):[...nt.likedBy||[],xe]}:nt));try{const Me=Je(he,"posts",se.id);re?await Cn(Me,{likeCount:Ir(-1),likedBy:T2(xe)}):await Cn(Me,{likeCount:Ir(1),likedBy:I2(xe)})}catch(Me){console.error("Failed to update post like:",Me)}},de=async G=>{if(!Ne.currentUser){pe.error("Please sign in to book event passes");return}L(!0);try{const se=Math.floor(1e5+Math.random()*9e5),xe=Math.random().toString(36).substring(2,5).toUpperCase(),re=`TKT-${se}-${xe}`;await ur(et(he,"notifications"),{userId:Ne.currentUser.uid,title:`🔑 Ticket Security Code: ${G.title}`,message:`Your requested security verification code for "${G.title}" is ready. Enter this code to confirm your seat allocation. Note: This security key works once and is confidential.`,code:re,used:!1,type:"verification_code",createdAt:new Date}),z(G.id),pe.success("Security code dispatched to your System Inbox! Check bell menu or profile.",{duration:5e3})}catch(se){console.error("Error creating verification code:",se),pe.error("Failed to issue security code. Please try again.")}finally{L(!1)}},be=async()=>{if(!(!Ne.currentUser||!w)){if(!T.trim()){pe.error("Please paste the ticket confirmation code");return}Z(!0);try{const G=T.trim().toUpperCase(),se=Qt(et(he,"notifications"),Ar("userId","==",Ne.currentUser.uid),Ar("code","==",G),Ar("used","==",!1)),xe=await vn(se);if(xe.empty){pe.error("Invalid, used, or expired security code. Please check your inbox."),Z(!1);return}const re=xe.docs[0],Me=Je(he,"notifications",re.id),nt=Je(he,"tickets",w.id),ze=await cs(nt);if(!ze.exists()){pe.error("Selected event session could not be located."),Z(!1);return}const Tt=ze.data();if(S>Tt.remainingQuantity){pe.error(`Not enough tickets remaining. Only ${Tt.remainingQuantity} available.`),Z(!1);return}await Cn(Me,{used:!0}),await Cn(nt,{remainingQuantity:Ir(-S)});const It={ticketId:w.id,ticketTitle:w.title,userId:Ne.currentUser.uid,userName:Ne.currentUser.displayName||"Campus Citizen",userEmail:Ne.currentUser.email||"",price:w.price,totalAmount:w.price*S,quantity:S,purchaseDate:new Date,status:"confirmed"},ft=await ur(et(he,"purchases"),It),Ee={id:ft.id,verificationCode:G,venue:w.venue,eventDate:w.eventDate,...It};B(Ee),pe.success(`Passes allocated under confirmation ID #${ft.id.slice(-6).toUpperCase()}!`,{icon:"🎉"}),Z(!1)}catch(G){console.error("Verification sequence failed:",G),pe.error("Ticketing verification failed: "+G.message),Z(!1)}}},Ce=G=>{var se;if(G)try{const xe=G.id.toUpperCase(),re=G.verificationCode||"CONFIRMED",Me=` ============================================================ CAMPUS EYE DIGITAL EVENT PASS ============================================================ TICKET SERIAL: ${xe} CONFIRMATION: ${re} STATUS: VALID / ONE-TIME ENTRY ONLY ------------------------------------------------------------ EVENT DETAILS: Title: ${G.ticketTitle.toUpperCase()} Date: ${(se=G.eventDate)!=null&&se.toDate?G.eventDate.toDate().toLocaleString():new Date(G.eventDate).toLocaleString()} Venue: ${G.venue.toUpperCase()} Quantity: ${G.quantity} PASS(ES) Total Paid: UGX ${(G.totalAmount||0).toLocaleString()} ------------------------------------------------------------ HOLDER METADATA: Name: ${G.userName} Email: ${G.userEmail} Auth Class: STUDENT MEMBER / COMMUNITY REPORT ------------------------------------------------------------ SECURITY NOTICE: Present the numeric QR serial sequence on entrance. Do not share this offline ticket copy. It must match your in-app digital identification profile. ============================================================ `,nt=new Blob([Me.trim()],{type:"text/plain;charset=utf-8"}),ze=URL.createObjectURL(nt),Tt=document.createElement("a");Tt.href=ze,Tt.download=`EventPass-${G.ticketTitle.replace(/\s+/g,"-")}-${xe.slice(-6)}.txt`,document.body.appendChild(Tt),Tt.click(),document.body.removeChild(Tt),URL.revokeObjectURL(ze),pe.success("Offline Text Ticket downloaded successfully!")}catch(xe){pe.error("Download failed: "+xe.message)}},Ke=G=>{let se=0;for(let re=0;re8||re>8&&nt<3;let It=!1;Tt?It=re===0||re===2||nt===0||nt===2||re===0&&nt===11||re===2&&nt===11||nt===9&&(re===0||re===2)||re===9&&nt===0||re===11&&nt===0||nt===2&&(re===9||re===11):It=Math.abs((se^ze*7)%11)<4,Me.push(It)}xe.push(Me)}return s.jsx("svg",{viewBox:"0 0 120 120",className:"w-32 h-32 bg-white p-2 border border-gray-150 rounded-xl shadow-inner mx-auto",children:xe.map((re,Me)=>re.map((nt,ze)=>s.jsx("rect",{x:ze*10,y:Me*10,width:9,height:9,rx:1.5,fill:nt?"#0F172A":"transparent"},`${Me}-${ze}`)))})};return s.jsxs("div",{className:"space-y-4 font-sans text-left",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 overflow-x-auto pb-1 border-b border-gray-100 no-scrollbar",children:[s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsxs("button",{type:"button",onClick:()=>r("all"),className:`px-3 py-1.5 rounded-xl text-[9px] font-black uppercase tracking-wider transition-all cursor-pointer flex items-center gap-1 ${n==="all"?"bg-accent text-white shadow-xs":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[s.jsx(Zi,{size:11})," All"]}),s.jsxs("button",{type:"button",onClick:()=>r("posts"),className:`px-3 py-1.5 rounded-xl text-[9px] font-black uppercase tracking-wider transition-all cursor-pointer flex items-center gap-1 ${n==="posts"?"bg-red-650 text-white shadow-xs":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[s.jsx(bi,{size:11})," Posts (",o.length,")"]}),s.jsxs("button",{type:"button",onClick:()=>r("tickets"),className:`px-3 py-1.5 rounded-xl text-[9px] font-black uppercase tracking-wider transition-all cursor-pointer flex items-center gap-1 ${n==="tickets"?"bg-gray-900 text-white shadow-xs":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[s.jsx(Aa,{size:11})," Tickets (",i.length,")"]})]}),s.jsxs("button",{type:"button",onClick:J,className:"text-[9px] font-black uppercase tracking-wider text-accent hover:underline flex items-center gap-0.5 shrink-0",children:[s.jsx("span",{children:"Lounge"}),s.jsx(Op,{size:10})]})]}),(n==="all"||n==="posts")&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between px-1",children:[s.jsxs("span",{className:"text-[9px] font-black tracking-widest text-gray-400 uppercase flex items-center gap-1",children:[s.jsx(vre,{size:12,className:"text-red-500"})," Live Community Event Posts"]}),s.jsxs("button",{type:"button",onClick:J,className:"text-[9px] font-black uppercase text-accent hover:underline flex items-center gap-1 cursor-pointer",children:[s.jsx(Lc,{size:10})," Create Post"]})]}),m?s.jsxs("div",{className:"p-6 text-center bg-gray-50 border border-gray-100 rounded-2xl",children:[s.jsx(Er,{className:"animate-spin text-gray-400 mx-auto",size:18}),s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-widest mt-2",children:"Loading Live Event Posts..."})]}):o.length===0?s.jsxs("div",{className:"p-6 text-center bg-gray-50 border border-gray-100 rounded-2xl space-y-2",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"No Recent Posts Found"}),s.jsx("button",{type:"button",onClick:J,className:"px-4 py-1.5 bg-accent text-white text-[9px] font-black uppercase tracking-wider rounded-xl cursor-pointer",children:"Post First Dispatch in Lounge"})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3.5",children:o.slice(0,4).map(G=>{var xe;const se=Y[G.id]||G.likedBy&&Ne.currentUser&&G.likedBy.includes(Ne.currentUser.uid);return s.jsxs("div",{onClick:J,className:"bg-white border border-gray-150 hover:border-red-300 rounded-2xl p-4 text-left flex flex-col justify-between transition-all duration-200 hover:shadow-xs cursor-pointer group space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",onClick:re=>{re.stopPropagation(),ye(G.authorId)},children:[G.authorPhotoURL?s.jsx("img",{src:G.authorPhotoURL,alt:G.authorName,className:"w-7 h-7 rounded-full object-cover border border-gray-100 shrink-0"}):s.jsx("div",{className:"w-7 h-7 rounded-full bg-red-100 text-red-650 flex items-center justify-center text-[10px] font-black uppercase shrink-0",children:((xe=G.authorName)==null?void 0:xe.charAt(0))||"U"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-xs font-black text-gray-900 truncate leading-tight group-hover:text-accent transition-colors",children:G.authorName||"Campus Citizen"}),s.jsx(Fo,{className:"w-3 h-3 text-accent shrink-0"})]}),s.jsx("span",{className:"text-[8.5px] font-bold text-gray-400 uppercase font-mono",children:X0(G.createdAt)})]})]}),s.jsx("span",{className:"text-[8px] font-black uppercase font-mono px-2 py-0.5 bg-gray-100 text-gray-600 rounded-md",children:"DISPATCH"})]}),s.jsx("p",{className:"text-xs text-gray-800 font-medium line-clamp-3 leading-relaxed",children:G.content}),G.imageUrl&&s.jsx("div",{className:"relative rounded-xl overflow-hidden bg-gray-100 aspect-video max-h-40 border border-gray-100",children:s.jsx(Li,{src:G.imageUrl,alt:"Post Media",className:"w-full h-full object-cover group-hover:scale-102 transition-transform duration-300"})}),s.jsxs("div",{className:"pt-2 border-t border-gray-100 flex items-center justify-between text-gray-500 text-[9px] font-bold",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("button",{type:"button",onClick:re=>ne(re,G),className:`flex items-center gap-1 px-2 py-1 rounded-lg transition-colors cursor-pointer ${se?"text-red-600 bg-red-50":"hover:text-red-600 hover:bg-gray-50"}`,children:[s.jsx(mc,{size:11,className:se?"fill-current":""}),s.jsx("span",{children:G.likeCount||0})]}),s.jsxs("button",{type:"button",onClick:re=>{re.stopPropagation(),J()},className:"flex items-center gap-1 px-2 py-1 rounded-lg hover:text-gray-900 hover:bg-gray-50 transition-colors cursor-pointer",children:[s.jsx(Kp,{size:11}),s.jsx("span",{children:G.commentCount||0})]})]}),s.jsxs("button",{type:"button",onClick:re=>{re.stopPropagation(),J()},className:"text-[8.5px] font-black uppercase tracking-wider text-accent hover:underline flex items-center gap-0.5",children:[s.jsx("span",{children:"Join Discussion"}),s.jsx(Op,{size:9})]})]})]},G.id)})})]}),(n==="all"||n==="tickets")&&s.jsxs("div",{className:"space-y-3 pt-2",children:[s.jsx("div",{className:"flex items-center justify-between px-1",children:s.jsxs("span",{className:"text-[9px] font-black tracking-widest text-gray-400 uppercase flex items-center gap-1",children:[s.jsx(Aa,{size:12,className:"text-accent"})," Box Office Event Passes & Entry Keys"]})}),h?s.jsxs("div",{className:"p-6 text-center bg-gray-50 border border-gray-100 rounded-2xl",children:[s.jsx(Er,{className:"animate-spin text-gray-400 mx-auto",size:18}),s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-widest mt-2",children:"Loading Available Passes..."})]}):i.length===0?s.jsxs("div",{className:"p-6 text-center bg-gray-50 border border-gray-100 rounded-2xl space-y-2",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"No active box office tickets currently posted"}),s.jsx("p",{className:"text-[9px] text-gray-500",children:"Check back soon or browse live event dispatches and community posts above."})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:i.slice(0,4).map(G=>{var xe;const se=G.remainingQuantity<=0;return s.jsxs("div",{className:"bg-white border border-gray-150 rounded-2xl p-4 text-left flex flex-col justify-between hover:border-accent transition-colors relative overflow-hidden group shadow-2xs",children:[se?s.jsx("div",{className:"absolute top-3 right-3 bg-gray-900 text-white text-[8px] font-black px-2 py-0.5 rounded-full uppercase",children:"Sold Out"}):G.remainingQuantity<10?s.jsxs("div",{className:"absolute top-3 right-3 bg-red-650 text-white text-[8px] font-black px-2 py-0.5 rounded-full uppercase",children:["Only ",G.remainingQuantity," Left!"]}):s.jsxs("div",{className:"absolute top-3 right-3 bg-accent text-white text-[8px] font-black px-2 py-0.5 rounded-full uppercase",children:[G.remainingQuantity," Remaining"]}),s.jsxs("div",{className:"flex gap-3 items-start w-full",children:[G.imageUrl&&s.jsx(Li,{src:G.imageUrl,alt:G.title,className:"w-14 h-14 rounded-xl object-cover shrink-0 border border-gray-100/80 bg-gray-50 shadow-xs"}),s.jsxs("div",{className:"space-y-1 flex-1 min-w-0",children:[s.jsx("p",{className:"text-[8px] font-black text-accent uppercase tracking-widest leading-none mb-0.5",children:G.category}),s.jsx("h4",{className:"text-sm font-black text-gray-950 uppercase tracking-tight leading-snug group-hover:text-accent transition-colors line-clamp-2",children:G.title}),s.jsxs("div",{className:"flex flex-col gap-0.5 pt-1 text-gray-500 text-[9px] font-bold",children:[s.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[s.jsx(rg,{size:10,className:"shrink-0 text-gray-400"}),(xe=G.eventDate)!=null&&xe.toDate?G.eventDate.toDate().toLocaleDateString(void 0,{dateStyle:"short"}):"TBA"]}),s.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[s.jsx(BS,{size:10,className:"shrink-0 text-gray-400"}),G.venue]})]}),G.link&&s.jsx("div",{className:"pt-1",children:s.jsxs("a",{href:G.link,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 text-[9px] text-blue-650 font-black uppercase tracking-wider hover:underline",onClick:re=>re.stopPropagation(),children:[s.jsx("span",{children:"Event Link"}),s.jsx(Op,{size:10,className:"text-blue-650"})]})})]})]}),s.jsxs("div",{className:"pt-4 border-t border-gray-100/60 mt-4 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[7.5px] font-black text-gray-400 uppercase tracking-widest leading-none mb-0.5",children:"Event Rate"}),s.jsxs("p",{className:"text-sm font-black text-gray-950",children:[s.jsx("span",{className:"text-[9px]",children:"UGX"})," ",G.price.toLocaleString()]})]}),s.jsx("button",{onClick:()=>{if(!Ne.currentUser){pe.error("Please login to reserve coordinates");return}A(G),B(null),D(""),C(1)},disabled:se,className:"px-3.5 py-1.5 bg-gray-950 hover:bg-accent text-white disabled:bg-gray-100 disabled:text-gray-400 rounded-lg text-[9px] font-black uppercase tracking-widest transition-all cursor-pointer shadow-xs whitespace-nowrap",children:"Book Secure Pass"})]}),F&&s.jsxs("div",{className:"pt-3 border-t border-dashed border-gray-150 mt-3 flex gap-2 w-full",children:[s.jsx("button",{onClick:re=>{re.stopPropagation(),localStorage.setItem("edit_ticket_item",JSON.stringify(G));const Me=new CustomEvent("setTab",{detail:"admin"});window.dispatchEvent(Me),setTimeout(()=>{window.dispatchEvent(new CustomEvent("checkPendingTicketEdit"))},100)},className:"flex-1 py-1 px-2 bg-blue-50 text-blue-600 rounded-lg text-[8.5px] font-black uppercase tracking-wider hover:bg-blue-600 hover:text-white transition-all text-center cursor-pointer",children:"Edit"}),s.jsx("button",{onClick:async re=>{if(re.stopPropagation(),!F){pe.error("Access Denied: Only admins can delete tickets.");return}if(window.confirm("Are you sure you want to permanently delete this event ticket?"))try{await si(Je(he,"tickets",G.id)),pe.success("Ticket deleted successfully")}catch(Me){pe.error("Failed to delete ticket: "+Me.message)}},className:"flex-1 py-1 px-2 bg-red-50 text-red-650 rounded-lg text-[8.5px] font-black uppercase tracking-wider hover:bg-red-650 hover:text-white transition-all text-center cursor-pointer",title:"Delete Ticket",children:"Delete"})]})]},G.id)})})]}),s.jsx(or,{children:w&&s.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[s.jsx(Zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>{!K&&!V&&(A(null),B(null))},className:"absolute inset-0 bg-black/60 backdrop-blur-xs"}),s.jsxs(Zt.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"relative bg-white w-full max-w-md rounded-2xl shadow-2xl p-6 text-left space-y-5 border border-gray-100 overflow-hidden z-10",children:[s.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-gray-100",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"p-1.5 bg-red-100 text-red-650 rounded-lg shrink-0",children:s.jsx(Aa,{size:14})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-black uppercase text-gray-950 tracking-wide",children:"SECURE EVENT GATEWAY"}),s.jsx("p",{className:"text-[8.5px] font-bold text-gray-400 uppercase tracking-wider",children:"Allocations require physical verification key"})]})]}),s.jsx("button",{onClick:()=>A(null),className:"p-1 text-gray-400 hover:text-black hover:bg-gray-50 rounded-full transition-all cursor-pointer",children:"✕"})]}),q?s.jsxs("div",{className:"space-y-4 text-center",children:[s.jsxs("div",{className:"py-2",children:[s.jsx("div",{className:"w-12 h-12 bg-green-100 text-green-600 rounded-full flex items-center justify-center mx-auto mb-2 scale-110",children:s.jsx(Bu,{size:28,id:"ticket-success-check"})}),s.jsx("h4",{className:"text-sm font-black text-gray-950 uppercase tracking-tight leading-none mb-1",children:"Pass Issued Successfully"}),s.jsxs("p",{className:"text-[9px] text-gray-400 font-bold uppercase tracking-wider",children:["Secure Serial: #",q.id.slice(-6).toUpperCase()]})]}),s.jsxs("div",{className:"p-4 bg-gray-50 border border-gray-150 rounded-xl space-y-3",children:[Ke(`ticket_serial_${q.id}`),s.jsxs("div",{className:"space-y-0.5 text-center mt-2",children:[s.jsx("p",{className:"text-[11px] font-semibold text-gray-800 leading-tight truncate uppercase",children:w.title}),s.jsx("p",{className:"text-[8px] font-bold text-gray-400 uppercase tracking-widest",children:w.venue}),s.jsxs("p",{className:"text-[8px] font-black text-gray-500 mt-1 uppercase",children:["Pass Quantity: ",q.quantity," • Verified Conf"]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>Ce(q),className:"w-full py-3 bg-black hover:bg-gray-950 text-white font-black uppercase text-[9px] tracking-widest rounded-lg flex items-center justify-center gap-1.5 transition-colors cursor-pointer",children:[s.jsx(eE,{size:12}),"Download Pass"]}),s.jsx("button",{onClick:()=>A(null),className:"w-full py-3 bg-gray-100 hover:bg-gray-200 text-gray-800 font-black uppercase text-[9px] tracking-widest rounded-lg transition-colors cursor-pointer",children:"Done"})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"bg-gray-50 border border-gray-150 p-3.5 rounded-xl space-y-2",children:[s.jsx("p",{className:"text-[8.5px] font-bold text-gray-400 uppercase tracking-widest leading-none",children:"Selected Event Coordinates"}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-black text-gray-950 uppercase tracking-tight",children:w.title}),s.jsxs("div",{className:"flex items-center gap-4 mt-1 text-[9px] font-black text-accent uppercase font-mono",children:[s.jsxs("span",{children:["UGX ",w.price.toLocaleString()," RATE"]}),s.jsx("span",{children:"•"}),s.jsxs("span",{children:[w.remainingQuantity," SEATS REMAINING"]})]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-gray-200/50",children:[s.jsx("span",{className:"text-[10px] font-black text-gray-600 uppercase",children:"Quantity"}),s.jsxs("div",{className:"flex items-center gap-3 bg-white border border-gray-150 rounded-lg p-1",children:[s.jsx("button",{onClick:()=>C(Math.max(1,S-1)),className:"w-6 h-6 flex items-center justify-center text-xs font-bold hover:bg-gray-100 rounded cursor-pointer",children:"-"}),s.jsx("span",{className:"text-xs font-black text-gray-850 w-5 text-center",children:S}),s.jsx("button",{onClick:()=>C(Math.min(w.remainingQuantity,S+1)),className:"w-6 h-6 flex items-center justify-center text-xs font-bold hover:bg-gray-100 rounded cursor-pointer",children:"+"})]})]})]}),s.jsxs("div",{className:"space-y-2 text-center py-1",children:[s.jsx("p",{className:"text-[9px] text-gray-500 font-medium",children:"Ticketing is locked to prevent fraud. Send a secure confirmation OTP to your system index, then verify below to authorize."}),s.jsx("button",{onClick:()=>de(w),disabled:V,className:"px-4 py-2 bg-red-50 hover:bg-red-100 text-red-650 rounded-xl text-[9.5px] font-black uppercase tracking-wider transition-colors inline-flex items-center gap-1.5 cursor-pointer disabled:opacity-50",children:V?s.jsxs(s.Fragment,{children:[s.jsx(Er,{className:"animate-spin",size:12}),"Broadcasting Key..."]}):s.jsxs(s.Fragment,{children:[s.jsx(ea,{size:12}),"Request Verification Code (System Inbox)"]})})]}),s.jsxs("div",{className:"space-y-2 pt-2 border-t border-gray-100",children:[s.jsx("label",{className:"text-[9.5px] font-black text-gray-900 uppercase tracking-wide block",children:"CONFIRMATION CODE KEY"}),s.jsx("div",{className:"relative",children:s.jsx("input",{type:"text",value:T,onChange:G=>D(G.target.value),placeholder:"e.g. TKT-94285-ABC",className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 focus:border-black focus:bg-white rounded-xl text-xs font-black placeholder:text-gray-300 outline-none uppercase tracking-widest text-center"})})]}),s.jsx("button",{onClick:be,disabled:K||!T.trim(),className:"w-full py-4 bg-gray-950 hover:bg-accent disabled:bg-gray-100 disabled:text-gray-400 text-white rounded-xl text-[10px] font-black uppercase tracking-widest transition-all shadow-md flex items-center justify-center gap-2 cursor-pointer",children:K?s.jsxs(s.Fragment,{children:[s.jsx(Er,{className:"animate-spin",size:14}),"Authorizing Digital Stamp..."]}):s.jsxs(s.Fragment,{children:[s.jsx(pl,{size:14}),"Verify Confirmation Key & Issue Pass"]})})]})]})]})})]})},rY=({value:e,onSelectMention:t,className:n})=>{const r=e.match(/@([a-zA-Z0-9_]*)$/);if(!r)return null;const i=r[1].toLowerCase();if(!["","m","me","meg","mega","megaai","ai","bot"].some(c=>c.startsWith(i)||i.startsWith(c)))return null;const o=()=>{const c=e.replace(/@([a-zA-Z0-9_]*)$/,"@Mega AI ");t(c)};return s.jsx("div",{className:Fe("relative z-30 my-1.5",n),children:s.jsxs("div",{onClick:o,className:"bg-gradient-to-r from-amber-50 via-white to-red-50 border border-amber-300 rounded-2xl p-2.5 shadow-lg shadow-amber-500/10 flex items-center justify-between cursor-pointer hover:border-amber-500 transition-all group animate-in fade-in slide-in-from-bottom-2 duration-150",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("img",{src:zo,alt:"Mega AI",className:"w-8 h-8 rounded-xl object-cover border border-amber-400/50 shadow-xs shrink-0 group-hover:scale-105 transition-transform"}),s.jsxs("div",{className:"text-left",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-xs font-black uppercase text-gray-950 tracking-tight",children:"Mega AI"}),s.jsx("span",{className:"text-[9px] font-mono font-bold text-amber-700 bg-amber-100/80 px-1.5 py-0.2 rounded",children:"@Mega AI"})]}),s.jsxs("p",{className:"text-[9.5px] font-medium text-gray-500 flex items-center gap-1",children:[s.jsx(Zi,{size:10,className:"text-amber-500 shrink-0"}),s.jsx("span",{children:"Tap to mention for an instant AI smart response"})]})]})]}),s.jsxs("div",{className:"px-2.5 py-1 bg-amber-500 hover:bg-amber-600 text-white rounded-xl text-[9.5px] font-black uppercase tracking-wider shrink-0 transition-colors flex items-center gap-1 shadow-2xs",children:[s.jsx("span",{children:"Mention"}),s.jsx(Bu,{size:11})]})]})})};async function xj(e,t=1200,n=1200,r=.78){return new Promise((i,a)=>{if(e.type&&!e.type.startsWith("image/")){i(e);return}const o=new FileReader;o.onload=c=>{var f;const h=new Image;h.onload=()=>{try{const m=document.createElement("canvas");let y=h.naturalWidth||h.width,w=h.naturalHeight||h.height;(y>t||w>n)&&(y/t>w/n?(w=Math.round(w*t/y),y=t):(y=Math.round(y*n/w),w=n)),m.width=Math.max(1,y),m.height=Math.max(1,w);const A=m.getContext("2d");if(!A){i(e);return}A.imageSmoothingEnabled=!0,A.imageSmoothingQuality="high",A.drawImage(h,0,0,y,w),m.toBlob(S=>{i(S||e)},"image/jpeg",r)}catch{i(e)}},h.onerror=()=>i(e),h.src=(f=c.target)==null?void 0:f.result},o.onerror=()=>i(e),o.readAsDataURL(e)})}function iY(e){return new Promise((t,n)=>{const r=new FileReader;r.onloadend=()=>{typeof r.result=="string"?t(r.result):n(new Error("Failed to convert blob to base64"))},r.onerror=()=>n(new Error("FileReader blob error")),r.readAsDataURL(e)})}async function Q2(e,t=600,n=600,r=.72){try{const i=await xj(e,t,n,r);return await iY(i)}catch{return new Promise((a,o)=>{const c=new FileReader;c.onloadend=()=>{typeof c.result=="string"?a(c.result):o(new Error("Image conversion failed"))},c.onerror=()=>o(new Error("FileReader error")),c.readAsDataURL(e)})}}function sY(){if(typeof window<"u"){const e=localStorage.getItem("campus_eye_imgbb_active_key");if(e&&e.trim().length>5)return e.trim()}return"857eaaf2b7571ee437db8ee3f6ee8670"}async function I4(e){const t=sY(),n=Array.from(new Set([t,"857eaaf2b7571ee437db8ee3f6ee8670","3b3f20f2693897b69c4fae1ff05d9852","f3a6776e0a442398246cb321152a5ec2","0305d21a221f786d14ea17435f29910d"])).filter(Boolean);let r;try{r=await xj(e,1200,1200,.76)}catch(i){console.warn("Client-side pre-compression failed, using raw payload:",i),r=e}for(const i of n)try{const a=new FormData,o=e.name?e.name.replace(/\.[^/.]+$/,"")+".jpg":"image.jpg",c=new File([r],o,{type:"image/jpeg"});a.append("image",c);const h=new AbortController,f=setTimeout(()=>h.abort(),8e3),m=await fetch(`https://api.imgbb.com/1/upload?key=${i}`,{method:"POST",body:a,signal:h.signal});if(clearTimeout(f),m.ok){const y=await m.json();if(y.success&&y.data&&y.data.url)return y.data.url}}catch{}try{const i=await xj(e,800,800,.7);return await iY(i)}catch{return await Q2(e,600,600,.65)}}const RL=["🔥","🤯","😢","👏","❤️","😂","👍","🎉","😡","✨","💯","👀","🚀","💡","🙌","🔊","⚽","🎮","💡","🎓","📢","💀","💩","💪","👑","❌"],V2e=({article:e,onClose:t,isAdmin:n,allArticles:r=[],onArticleSelect:i,onCategorySelect:a})=>{var wi,Xt;const[o,c]=I.useState(e);I.useEffect(()=>{if(c(e),!(e!=null&&e.id))return;const me=Wr(Je(he,"articles",e.id),qe=>{qe.exists()&&c({id:qe.id,...qe.data()})},qe=>{console.warn("Realtime article sync error:",qe)});return()=>me()},[e==null?void 0:e.id]);const[h,f]=I.useState([]),[m,y]=I.useState(""),[w,A]=I.useState(null),[S,C]=I.useState(!1),[T,D]=I.useState(!1),V=async me=>{if(me.clipboardData&&me.clipboardData.files&&me.clipboardData.files.length>0){const qe=me.clipboardData.files[0];if(qe&&qe.type.startsWith("image/"))try{const st=await Q2(qe,600,600,.7);A(st),ir.success("Sticker / device image attached!")}catch{ir.error("Failed to process image")}}},L=async me=>{var st;const qe=(st=me.target.files)==null?void 0:st[0];if(qe)try{const dt=await Q2(qe,600,600,.7);A(dt),ir.success("Device sticker/image attached!")}catch{ir.error("Failed to process image")}},[K,Z]=I.useState(!1),[q,B]=I.useState(!1),[z,F]=I.useState(null),[$,Y]=I.useState(null),[X,J]=I.useState(!0),[ye,ne]=I.useState(!1),[de,be]=I.useState(!1),[Ce,Ke]=I.useState(null),[G,se]=I.useState(0),[xe,re]=I.useState(!1),[Me,nt]=I.useState(!1),[ze,Tt]=I.useState([]),[It,ft]=I.useState([]),[Ee,yt]=I.useState(!1);I.useEffect(()=>{const me=Qt(et(he,"sponsors")),qe=Qt(et(he,"adverts"),vi(20));Promise.all([vn(me).catch(()=>null),vn(qe).catch(()=>null)]).then(([st,dt])=>{const An=[];st&&!st.empty&&st.docs.forEach(Ft=>An.push({id:Ft.id,...Ft.data()})),dt&&!dt.empty&&dt.docs.forEach(Ft=>{const Dn=Ft.data();(Dn.imageUrl||Dn.mediaUrl)&&An.push({id:Ft.id,name:Dn.company||Dn.title||"Partner",imageUrl:Dn.imageUrl||Dn.mediaUrl||"",link:Dn.targetUrl||Dn.link||"#"})}),ft(An)})},[]),I.useEffect(()=>{const me=Qt(et(he,"custom_pages"),ui("createdAt","desc"));vn(me).then(qe=>{Tt(qe.docs.map(st=>({id:st.id,...st.data()})))}).catch(qe=>{console.warn("Silent ignore custom pages in article view:",qe)})},[]);const Ue=[o.featuredImageUrl,o.featuredImageUrl1,o.featuredImageUrl2].filter(Boolean),[Vt,St]=I.useState("newest"),[tn,Pt]=I.useState(null),[Nt,Kt]=I.useState([]),[ut,Jt]=I.useState(0);I.useEffect(()=>{const me=Qt(et(he,"adverts"),vi(10));vn(me).then(qe=>{const st=qe.docs.map(dt=>({id:dt.id,...dt.data()}));Kt(st.filter(dt=>dt.status==="active"))}).catch(qe=>{console.warn("Failed to load adverts for article inline placements:",qe)})},[]),I.useEffect(()=>{if(Nt.length<=1)return;const me=setInterval(()=>{Jt(qe=>(qe+1)%Nt.length)},5e3);return()=>clearInterval(me)},[Nt.length]),I.useEffect(()=>{if(o){document.title=`${o.title} | Campus Eye Media`;const me=o.summary||(o.content?o.content.substring(0,160)+"...":""),qe=(ue,Se,Qe)=>{let Gt=document.querySelector(`meta[${ue}="${Se}"]`);Gt||(Gt=document.createElement("meta"),Gt.setAttribute(ue,Se),document.head.appendChild(Gt)),Gt.setAttribute("content",Qe)},st=(ue,Se)=>{let Qe=document.querySelector(`link[rel="${ue}"]`);Qe||(Qe=document.createElement("link"),Qe.setAttribute("rel",ue),document.head.appendChild(Qe)),Qe.setAttribute("href",Se)},dt=o.title,An=me,Ft=[o.featuredImageUrl,o.featuredImageUrl1,o.featuredImageUrl2,o.featuredImage,o.imageUrl,o.image,o.photo,o.coverImage,o.cover,o.thumbnail,o.mediaUrl,o.bannerUrl];let Dn="";const Ot=[o.video,o.videoUrl,o.Links].filter(Boolean);for(const ue of Ot){const Se=ue.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|shorts\/)([^#\&\?]*).*/);if(Se&&Se[2].length===11){Dn=`https://img.youtube.com/vi/${Se[2]}/hqdefault.jpg`;break}}let on="";if(o.content){const ue=o.content.match(/]+src=["'](https?:\/\/[^"'\s]+)["']/i)||o.content.match(/!\[.*?\]\((https?:\/\/[^\s\)]+)\)/i);ue&&ue[1]&&(on=ue[1])}const jr=Ft.find(ue=>ue&&typeof ue=="string"&&ue.trim().length>5)||Dn||on,lr=jr?jr.startsWith("data:")?`${window.location.origin}/api/article-image/${o.id}`:jr:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg";qe("property","og:title",dt),qe("property","og:image",lr),qe("property","og:image:url",lr),qe("property","og:image:secure_url",lr),qe("property","og:description",An),qe("property","og:url",window.location.href),qe("name","description",An),qe("name","twitter:title",dt),qe("name","twitter:description",An),qe("name","twitter:image",lr),qe("name","twitter:image:src",lr),lr&&st("image_src",lr)}},[o]),I.useEffect(()=>{var dt,An,Ft;if(!o)return;const me=document.createElement("script");me.setAttribute("type","application/ld+json"),me.id=`seo-schema-${o.id}`;const qe={"@context":"https://schema.org","@type":"NewsArticle",headline:o.title,image:[o.featuredImageUrl||"https://campuseye.media/placeholder.png"],datePublished:(dt=o.publishDate)!=null&&dt.toDate?new Date(o.publishDate.toDate()).toISOString():new Date().toISOString(),dateModified:(An=o.publishDate)!=null&&An.toDate?new Date(o.publishDate.toDate()).toISOString():new Date().toISOString(),author:[{"@type":"Person",name:o.authorName||"Campus Eye Reporter",jobTitle:"Campus Eyewitness Journalist"}],publisher:{"@type":"Organization",name:"Campus Eye Media",logo:{"@type":"ImageObject",url:"https://campuseye.media/logo.png"}},description:o.summary||((Ft=o.content)==null?void 0:Ft.substring(0,160))||""};me.textContent=JSON.stringify(qe),document.head.appendChild(me);const st=document.title;return document.title=`${o.title} | Campus Eye News`,()=>{const Dn=document.getElementById(`seo-schema-${o.id}`);Dn&&Dn.remove(),document.title=st}},[o]),I.useEffect(()=>{const me=document.getElementById("full-article-modal-container");me&&me.scrollTo({top:0})},[e.id]),I.useEffect(()=>{if(e){const me=e.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),qe=`${window.location.origin}/articles=${me}/${e.id}`;fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:qe,title:e.title,image:e.featuredImageUrl||""})}).catch(st=>console.warn("Failed to notify sitemap update:",st))}},[e.id]),I.useEffect(()=>{const me=Je(he,"articles",e.id);if(Cn(me,{viewCount:Ir(1)}).catch(qe=>{console.warn("View counter update skipped:",qe)}),cs(me).then(qe=>{qe.exists()&&c({id:qe.id,...qe.data()})}).catch(qe=>{Ks(qe,Ms.GET,`articles/${e.id}`)}),Ne.currentUser){const qe=Je(he,"articles",e.id,"likes",Ne.currentUser.uid);cs(qe).then(Ot=>{Z(Ot.exists())}).catch(Ot=>console.warn("Could not check if user liked article offline:",Ot));const st=`reacted_${e.id}_${Ne.currentUser.uid}`,dt=localStorage.getItem(st);if(dt){F(parseInt(dt));const on=["🔥","🤯","😢","👏","❤️","😂","👍"][parseInt(dt)-1];on&&Y(on)}const An=`reacted_emoji_${e.id}_${Ne.currentUser.uid}`,Ft=localStorage.getItem(An);Ft&&Y(Ft);const Dn=`saved_${e.id}_${Ne.currentUser.uid}`;B(localStorage.getItem(Dn)==="true")}},[e.id,Ne.currentUser]);const Dt=()=>{const me={};o.reactions&&Object.entries(o.reactions).forEach(([st,dt])=>{typeof dt=="number"&&dt>0&&(me[st]=(me[st]||0)+dt)});const qe=["🔥","🤯","😢","👏","❤️","😂","👍"];for(let st=1;st<=7;st++){const dt=o[`reaction${st}`];if(dt&&dt.count>0){const An=dt.emoji||qe[st-1];An&&(me[An]=(me[An]||0)+dt.count)}}return me};I.useEffect(()=>{const me=Qt(et(he,"articles",e.id,"comments"),ui("createdAt","desc")),qe=Wr(me,st=>{const dt=st.docs.map(An=>({id:An.id,...An.data()}));f(dt)},st=>{Ks(st,Ms.LIST,`articles/${e.id}/comments`)});return()=>qe()},[e.id]);const hn=()=>{const me=!X;J(me),me&&setTimeout(()=>{const qe=document.getElementById("full-article-comments-section");qe&&qe.scrollIntoView({behavior:"smooth",block:"nearest"})},30)},qn=async me=>{if(!Ne.currentUser){ir.error("Please login to register solidarity on comments!"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{qn(me)});return}const qe=Je(he,"articles",e.id,"comments",me),st=`liked_comment_${me}_${Ne.currentUser.uid}`,dt=localStorage.getItem(st)==="true";try{dt?(localStorage.removeItem(st),await Cn(qe,{likeCount:Ir(-1)})):(localStorage.setItem(st,"true"),await Cn(qe,{likeCount:Ir(1)}),ir.success("Solidarity added to comment!"))}catch(An){console.warn("Could not save comment like in db, performing local fallback:",An)}},mn=async()=>{if(!Ne.currentUser){ir.error("Please login to support this post!"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{mn()});return}const me=Je(he,"articles",e.id,"likes",Ne.currentUser.uid),qe=Je(he,"articles",e.id);try{K?(Z(!1),await si(me),await Cn(qe,{likeCount:Ir(-1)})):(Z(!0),await Rr(me,{userId:Ne.currentUser.uid,createdAt:En()}),await Cn(qe,{likeCount:Ir(1)}),ir.success("Solidarity registered!"))}catch(st){console.error("Error on like operation:",st)}},vr=async()=>{if(!Ne.currentUser){ir.error("Please login to bookmark dispatches"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{vr()});return}const me=Je(he,"articles",e.id),qe=`saved_${e.id}_${Ne.currentUser.uid}`,st=q;try{st?(B(!1),localStorage.removeItem(qe),await Cn(me,{saveCount:Ir(-1)}),ir.success("Bookmark removed")):(B(!0),localStorage.setItem(qe,"true"),await Cn(me,{saveCount:Ir(1)}),ir.success("Secured in Bookmarks!"))}catch(dt){console.error("Save error:",dt)}},Ve=async me=>{if(!Ne.currentUser){ir.error("Please login to register a reaction"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{Ve(me)});return}const qe=Je(he,"articles",e.id),st=`reacted_emoji_${e.id}_${Ne.currentUser.uid}`,dt=`reacted_${e.id}_${Ne.currentUser.uid}`,An=localStorage.getItem(st);try{const Ft={};if(An===me)Ft[`reactions.${me}`]=Ir(-1),localStorage.removeItem(st),Y(null),localStorage.removeItem(dt),F(null);else{if(An)Ft[`reactions.${An}`]=Ir(-1);else{const Dn=localStorage.getItem(dt);if(Dn){const Ot=parseInt(Dn),jr=["🔥","🤯","😢","👏","❤️","😂","👍"][Ot-1];jr&&(Ft[`reactions.${jr}`]=Ir(-1)),localStorage.removeItem(dt),F(null)}}Ft[`reactions.${me}`]=Ir(1),localStorage.setItem(st,me),Y(me)}await Cn(qe,Ft),ir.success("Reaction logged dynamically!")}catch(Ft){console.warn("Reaction updater error:",Ft)}},Mt=async me=>{var qe,st;if(me.preventDefault(),!(!m.trim()&&!w)){if(!Ne.currentUser){ir.error("Please login to submit commentary"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{Mt({preventDefault:()=>{}})});return}be(!0);try{const dt=tn?tn.parentId||tn.id:null,An={content:m,stickerUrl:w||null,userId:Ne.currentUser.uid,authorName:Ne.currentUser.displayName||"Campus Member",photoURL:Ne.currentUser.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Ne.currentUser.displayName||"Member")}`,createdAt:new Date,parentId:dt,replyToAuthor:tn?tn.authorName:null},Ft=await ur(et(he,"articles",e.id,"comments"),{content:m,stickerUrl:w||null,userId:Ne.currentUser.uid,authorName:Ne.currentUser.displayName||"Campus Member",photoURL:Ne.currentUser.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Ne.currentUser.displayName||"Member")}`,createdAt:En(),parentId:dt,replyToAuthor:tn?tn.authorName:null});f(on=>[{id:Ft.id,...An},...on]),c(on=>({...on,commentCount:(on.commentCount||0)+1}));const Dn=Je(he,"articles",e.id);await Cn(Dn,{commentCount:Ir(1)});const Ot=m;y(""),A(null),C(!1),Pt(null),ir.success("Comment added!"),/@(mega\s*(ai)?|me)\b/i.test(Ot)&&M2(Ot,((qe=Ne.currentUser)==null?void 0:qe.displayName)||"Campus Member",((st=Ne.currentUser)==null?void 0:st.uid)||"guest",{type:"article_comment",articleId:e.id,articleTitle:e.title,articleContent:e.content}).then(async on=>{if(on){const jr=await ur(et(he,"articles",e.id,"comments"),{content:on,userId:"mega-ai-bot",authorName:"Mega AI 🤖",photoURL:zo,createdAt:En(),parentId:null});f(lr=>[{id:jr.id,content:on,userId:"mega-ai-bot",authorName:"Mega AI 🤖",photoURL:zo,createdAt:new Date,parentId:null},...lr]),c(lr=>({...lr,commentCount:(lr.commentCount||0)+1})),await Cn(Je(he,"articles",e.id),{commentCount:Ir(1)}),ir.success("Mega AI auto-replied to your commentary!",{icon:"✨"})}}).catch(on=>console.error("Mega AI auto reply error:",on))}catch(dt){console.error("Comment submit error:",dt)}finally{be(!1)}}},cn=async()=>{const me=e.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),qe=`${window.location.origin}/articles=${me}/${e.id}`,st=e.title,dt=e.summary||(e.content?e.content.substring(0,140)+"...":""),An=`${e.title} ${dt}`,Ft=[e.featuredImageUrl,e.featuredImageUrl1,e.featuredImageUrl2,e.imageUrl].find(on=>on&&typeof on=="string"&&on.length>5)||"",Dn=Ft.startsWith("data:")?`${window.location.origin}/api/article-image/${e.id}`:Ft;try{fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:qe,title:st,image:Dn})}).catch(()=>{})}catch{}let Ot=!1;if(navigator.share)try{const on={title:st,text:`${An} Read dispatch:`,url:qe};await navigator.share(on),Ot=!0;const jr=Je(he,"articles",e.id);await Cn(jr,{shareCount:Ir(1)}).catch(console.error);return}catch(on){console.warn("Native share canceled or unsuccessful:",on)}if(!Ot){try{const on=`${st} ${dt} Read More: ${qe}`;await Md(on);const jr=Je(he,"articles",e.id);await Cn(jr,{shareCount:Ir(1)}).catch(console.error)}catch{}D(!0)}},dn=async()=>{var me,qe;if(!n&&((qe=(me=Ne.currentUser)==null?void 0:me.email)==null?void 0:qe.toLowerCase())!=="atwiinevictor2@gmail.com"){ir.error("Access Denied: Only administrators can delete articles.");return}if(window.confirm("Are you sure you want to permanently delete this article/post? This action is irreversible."))try{ir.loading("Deleting dispatch...",{id:"delete-dispatch"});const st=Je(he,"articles",o.id);await si(st),ir.success("Dispatch has been permanently deleted from Campus Eye.",{id:"delete-dispatch"}),t()}catch(st){console.error(st),ir.error(`Failed to delete dispatch: ${st.message||st}`,{id:"delete-dispatch"})}},mr=()=>e.featuredImageUrl?s.jsx("div",{className:"rounded-xl overflow-hidden border border-gray-150 w-full bg-gray-50 flex items-center justify-center relative shadow-sm cursor-zoom-in",onClick:()=>{se(0),re(!0)},children:s.jsx(Li,{src:e.featuredImageUrl,alt:e.title,priority:!0,className:"w-full h-auto max-h-[50rem] object-cover sm:object-contain hover:scale-[1.01] transition-transform duration-500 rounded-xl"})}):null,gr=r.findIndex(me=>me.id===e.id);return s.jsxs(Zt.div,{initial:{opacity:0,scale:.88},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.88},transition:{type:"spring",damping:22,stiffness:220},id:"full-article-modal-container",className:"fixed inset-0 z-[2000] bg-white overflow-y-auto w-full h-full text-left pb-24",children:[s.jsxs("div",{className:"sticky top-0 z-50 bg-white/95 backdrop-blur-md border-b border-gray-100 h-15 flex items-center px-4 justify-between shadow-sm shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:t,className:"p-2 bg-red-50 text-red-650 border border-red-150 hover:bg-red-600 hover:text-white hover:rotate-90 rounded-full transition-all duration-300 shadow-3xs flex items-center justify-center shrink-0 cursor-pointer",title:"Close details",children:s.jsx(er,{size:15,strokeWidth:3})}),s.jsx("div",{className:"h-6 w-px bg-gray-250 hidden xs:block"}),s.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 select-none",children:[s.jsx("button",{onClick:()=>nt(!0),className:"p-1 hover:text-red-650 text-gray-750 transition-all cursor-pointer flex items-center justify-center shrink-0",title:"Open Site Menu",children:s.jsx(tE,{size:14,strokeWidth:2.5})}),s.jsxs("div",{className:"flex items-center gap-1 cursor-pointer",onClick:()=>nt(!0),children:[s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Campus Eye Logo",className:"h-5.5 w-5.5 sm:h-6 sm:w-6 rounded-full border border-gray-950 bg-white object-cover aspect-square shrink-0",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"hidden md:flex flex-col justify-center text-left -space-y-1",children:[s.jsxs("span",{className:"text-[10px] sm:text-[11px] font-serif font-black tracking-normal italic leading-none",children:[s.jsx("span",{className:"text-red-650",children:"Campus"})," ",s.jsx("span",{className:"text-blue-600",children:"Eye"})]}),s.jsx("span",{className:"text-[5px] sm:text-[5.5px] font-sans font-extrabold uppercase tracking-[0.24em] text-black text-right pr-0.2 block select-none leading-none",children:"Media"})]})]})]})]}),r.length>0&&gr!==-1&&(()=>{const me=o.publishDate;let qe=1;if(me){const st=me.toDate?me.toDate():me.seconds?new Date(me.seconds*1e3):new Date(me),dt=new Date;dt.setHours(0,0,0,0);const An=new Date(st);An.setHours(0,0,0,0);const Ft=dt.getTime()-An.getTime();qe=Math.floor(Ft/(1e3*60*60*24))+1}return s.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 bg-gray-50 border border-gray-150 px-2 sm:px-3 py-1 rounded-full text-xs font-bold text-gray-700 select-none max-w-[50vw] sm:max-w-none justify-center",children:[s.jsx("button",{onClick:()=>{gr>0&&(i==null||i(r[gr-1]))},disabled:gr===0,className:"p-0.5 sm:p-1 text-gray-400 hover:text-red-650 disabled:opacity-30 disabled:hover:text-gray-400 transition-colors cursor-pointer select-none flex items-center justify-center shrink-0",title:"Previous story",children:s.jsx(qp,{size:14,strokeWidth:2.5})}),s.jsxs("span",{className:"font-mono text-[8.5px] sm:text-[9px] uppercase tracking-wider font-black text-gray-655 block text-center truncate",children:[s.jsxs("span",{className:"hidden md:inline",children:["DAY ",qe," — "]}),"DISPATCH ",gr+1]}),s.jsx("button",{onClick:()=>{gr{const me=o.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),qe=`${window.location.origin}/articles=${me}/${o.id}`,st=o.title;return s.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-3 border-b border-gray-100",children:[s.jsxs("a",{href:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(qe)}`,target:"_blank",rel:"noopener noreferrer",className:"px-3.5 py-2 bg-[#1877F2] hover:bg-[#155fc5] text-white font-extrabold text-[10px] uppercase tracking-widest rounded-lg flex items-center gap-1.5 shadow-sm transition-all cursor-pointer hover:scale-[1.02]",children:[s.jsx("svg",{className:"w-3.5 h-3.5 fill-current",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M22 12c0-5.52-4.48-10-10-10S2 6.48 2 12c0 4.84 3.44 8.87 8 9.8V15H8v-3h2V9.5C10 7.57 11.57 6 13.5 6H16v3h-2c-.55 0-1 .45-1 1v2h3v3h-3v6.95c4.56-.93 8-4.96 8-9.75z"})}),s.jsx("span",{children:"Share"})]}),s.jsxs("a",{href:`https://twitter.com/intent/tweet?url=${encodeURIComponent(qe)}&text=${encodeURIComponent(st)}`,target:"_blank",rel:"noopener noreferrer",className:"px-3.5 py-2 bg-black hover:bg-zinc-900 text-white font-extrabold text-[10px] uppercase tracking-widest rounded-lg flex items-center gap-1.5 shadow-sm transition-all cursor-pointer hover:scale-[1.02]",children:[s.jsx("svg",{className:"w-3.5 h-3.5 fill-current",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),s.jsx("span",{children:"Tweet"})]}),s.jsxs("a",{href:`https://api.whatsapp.com/send?text=${encodeURIComponent(st+" "+qe)}`,target:"_blank",rel:"noopener noreferrer",className:"px-3.5 py-2 bg-[#25D366] hover:bg-[#20ba59] text-white font-extrabold text-[10px] uppercase tracking-widest rounded-lg flex items-center gap-1.5 shadow-sm transition-all cursor-pointer hover:scale-[1.02]",children:[s.jsx("svg",{className:"w-3.5 h-3.5 fill-current",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M.057 24l1.687-6.163c-1.041-1.804-1.588-3.849-1.587-5.946C.06 5.348 5.397.01 12.008.01c3.202.001 6.212 1.246 8.477 3.514 2.266 2.268 3.507 5.28 3.505 8.484-.004 6.657-5.34 11.997-11.953 11.997-2.005-.001-3.973-.502-5.724-1.457L0 24zm6.59-4.846c1.6.95 3.1 1.45 4.8 1.45 5.4 0 9.8-4.4 9.8-9.8s-4.4-9.8-9.8-9.8c-5.4 0-9.8 4.4-9.8 9.8 0 1.9.5 3.7 1.5 5.3l-.9 3.5 3.4-.9z"})}),s.jsx("span",{children:"WhatsApp"})]}),s.jsx("button",{onClick:cn,className:"p-2 bg-gray-55 hover:bg-gray-100 border border-gray-150 rounded-lg text-gray-500 hover:text-gray-900 transition-colors cursor-pointer hover:scale-[1.02] shadow-sm ml-auto",title:"Copy text & browser link to clipboard",children:s.jsx(Bw,{size:13,className:"stroke-[2.5]"})})]})})(),s.jsx("article",{className:Fe("prose prose-red text-gray-900 leading-relaxed font-serif max-w-none text-base border-b border-gray-100 pb-8 selection:bg-red-50 transition-opacity duration-150",X&&"opacity-90"),children:(()=>{const me=o.content||"";let qe=me;try{const ue=[];qe=qe.replace(/@([a-zA-Z0-9_\-]+)/g,(Se,Qe)=>(ue.push(`[@${Qe}](mention:${Qe})`),`___MD_PLACEHOLDER_${ue.length-1}___`)),qe=qe.replace(/\[([^\]]*)\]\((https?:\/\/[^\s\)]+)\)/gi,Se=>(ue.push(Se),`___MD_PLACEHOLDER_${ue.length-1}___`)),qe=qe.replace(/"([^"]+)"\s*\((https?:\/\/[^\s\)]+)\)/gi,(Se,Qe,Gt)=>(ue.push(`[${Qe.trim()}](${Gt})`),`___MD_PLACEHOLDER_${ue.length-1}___`)),qe=qe.replace(/\((https?:\/\/[^\s\)]+)\)/gi,(Se,Qe)=>(ue.push(`([${Qe}](${Qe}))`),`___MD_PLACEHOLDER_${ue.length-1}___`)),qe=qe.replace(/(https?:\/\/[^\s\)\>\]]+)/gi,Se=>(ue.push(`[${Se}](${Se})`),`___MD_PLACEHOLDER_${ue.length-1}___`));for(let Se=ue.length-1;Se>=0;Se--)qe=qe.replace(`___MD_PLACEHOLDER_${Se}___`,ue[Se])}catch{qe=me}const st=qe.split(/\n\s*\n/).filter(ue=>ue.trim()!=="");if(st.length<=1)return s.jsx(Y1,{components:{a:({node:ue,...Se})=>Se.href&&Se.href.startsWith("mention:")?s.jsx("span",{className:"text-blue-600 font-extrabold select-text hover:underline",title:"Mentioned peer",children:Se.children}):s.jsx("a",{...Se,className:"text-blue-650 hover:text-blue-800 font-bold underline transition-all font-sans break-all hover:scale-[1.01]",target:"_blank",rel:"noopener noreferrer"})},children:qe});const dt=Math.ceil(st.length/2),An=st.slice(0,dt).join(` `),Ft=st.slice(dt).join(` `),Dn=Nt.length>0?Nt[ut%Nt.length]:null,Ot=o.video||o.videoUrl,jr=Ot?(ue=>{if(!ue)return null;const Se=/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/,Qe=ue.match(Se);return Qe&&Qe[2].length===11?Qe[2]:null})(Ot):null,lr=o.featuredImageUrl1||o.featuredImageUrl2;return s.jsxs("div",{className:"space-y-6",children:[s.jsx(Y1,{components:{a:({node:ue,...Se})=>Se.href&&Se.href.startsWith("mention:")?s.jsx("span",{className:"text-blue-600 font-extrabold select-text hover:underline",title:"Mentioned peer",children:Se.children}):s.jsx("a",{...Se,className:"text-blue-600 hover:text-blue-800 font-bold underline transition-all font-sans break-all",target:"_blank",rel:"noopener noreferrer"})},children:An}),s.jsx("div",{className:"my-8 py-6 border-y border-gray-100 flex flex-col gap-6 bg-[#fcfcfc] -mx-4 px-4 sm:mx-0 sm:px-6 sm:rounded-2xl",children:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("span",{className:"text-[9px] font-black uppercase text-gray-400 tracking-[0.25em] text-center mb-1",children:"Campus Sponsor Announcement"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-6 items-center",children:[s.jsx("div",{className:Fe("col-span-1",lr?"md:col-span-6":"md:col-span-12"),children:Dn?s.jsx("div",{className:"shadow-md rounded-xl overflow-hidden border border-gray-150",children:s.jsx(Yw,{advert:Dn})}):s.jsxs("div",{className:"bg-gradient-to-br from-indigo-50/40 to-rose-50/40 border border-gray-150 rounded-xl p-6 text-center shadow-xs",children:[s.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-[#9B2C2C] mb-1",children:"Advertise on Campus Eye"}),s.jsx("p",{className:"text-xs text-gray-600 font-medium leading-relaxed mb-4",children:"Reach thousands of student readers daily with full-bleed interstitial slots."}),s.jsx("a",{href:"mailto:atwiinevictor2@gmail.com",className:"inline-flex items-center gap-1.5 bg-black hover:bg-gray-800 text-white font-black uppercase tracking-widest text-[9px] px-4 py-2 rounded shadow-sm transition-colors",children:"Book Sponsor Space"})]})}),(o.featuredImageUrl1||o.featuredImageUrl2)&&s.jsxs("div",{className:"col-span-1 md:col-span-6 flex flex-col gap-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.featuredImageUrl1&&s.jsx("div",{onClick:()=>{const ue=Ue.indexOf(o.featuredImageUrl1);se(ue>=0?ue:1),re(!0)},className:"rounded-xl overflow-hidden border border-gray-150 aspect-square bg-gray-100 relative shadow-sm cursor-zoom-in group",children:s.jsx(Li,{src:o.featuredImageUrl1,className:"w-full h-full object-cover group-hover:scale-102 transition-transform duration-300",alt:"Supporting Evidence 1"})}),o.featuredImageUrl2&&s.jsx("div",{onClick:()=>{const ue=Ue.indexOf(o.featuredImageUrl2);se(ue>=0?ue:2),re(!0)},className:"rounded-xl overflow-hidden border border-gray-150 aspect-square bg-gray-100 relative shadow-sm cursor-zoom-in group",children:s.jsx(Li,{src:o.featuredImageUrl2,className:"w-full h-full object-cover group-hover:scale-102 transition-transform duration-300",alt:"Supporting Evidence 2"})})]}),s.jsx("span",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider italic text-right block",children:"Distributed documentation assets"})]})]}),Ot&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-200/80 flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-[9.5px] font-black uppercase text-gray-700 tracking-wider",children:[s.jsx(Ea,{size:13,className:"text-red-600"}),s.jsx("span",{children:"Article Video Frame"})]}),s.jsx("div",{className:"relative aspect-video w-full rounded-2xl overflow-hidden border border-gray-200 shadow-md bg-black",children:jr?s.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${jr}?rel=0`,className:"w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:o.title||"Story Video"}):Ot.includes("Se.href&&Se.href.startsWith("mention:")?s.jsx("span",{className:"text-blue-600 font-extrabold select-text hover:underline",title:"Mentioned peer",children:Se.children}):s.jsx("a",{...Se,className:"text-blue-650 hover:text-blue-800 font-bold underline transition-all font-sans break-all",target:"_blank",rel:"noopener noreferrer"})},children:Ft})]})})()}),s.jsxs("div",{className:"relative overflow-hidden w-full rounded-2xl sm:rounded-full bg-gradient-to-r from-blue-50/60 via-white/85 to-blue-50/50 dark:from-neutral-900/70 dark:via-neutral-800/70 dark:to-neutral-900/70 backdrop-blur-xl backdrop-saturate-150 border border-white/90 dark:border-white/10 shadow-[0_4px_24px_rgba(0,0,0,0.04),inset_0_1px_2px_rgba(255,255,255,0.9)] p-2 sm:p-2.5 my-4 select-none",children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/70 via-transparent to-white/20 dark:from-white/10 pointer-events-none rounded-2xl sm:rounded-full"}),s.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-between gap-2 px-1 text-gray-700 dark:text-gray-200",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 sm:gap-2",children:[s.jsxs("button",{onClick:mn,className:Fe("flex items-center gap-1.5 sm:gap-2 px-3 sm:px-4 py-1.5 rounded-full transition-all duration-300 hover:scale-105 active:scale-95 cursor-pointer backdrop-blur-md shadow-2xs hover:shadow-xs",K?"bg-blue-600 text-white font-extrabold shadow-sm shadow-blue-500/25":"bg-white/75 hover:bg-white dark:bg-white/10 dark:hover:bg-white/20 text-gray-800 dark:text-gray-100 hover:text-blue-600 border border-white/80 dark:border-white/10"),title:"Solidarity support",children:[s.jsx("div",{className:"flex items-center justify-center transition-transform group-hover:scale-110 shrink-0",children:s.jsx(uq,{size:21,className:K?"fill-white text-white":""})}),s.jsxs("span",{className:"text-xs sm:text-[13px] font-black tracking-tight",children:[fl(o.likeCount||0)," Solidarity"]})]}),s.jsxs("button",{onClick:hn,className:Fe("flex items-center gap-1.5 sm:gap-2 px-3 sm:px-4 py-1.5 rounded-full transition-all duration-300 hover:scale-105 active:scale-95 cursor-pointer backdrop-blur-md shadow-2xs hover:shadow-xs",X?"bg-indigo-600 text-white font-extrabold shadow-sm shadow-indigo-500/25":"bg-white/75 hover:bg-white dark:bg-white/10 dark:hover:bg-white/20 text-gray-800 dark:text-gray-100 hover:text-indigo-600 border border-white/80 dark:border-white/10"),title:"Comments",children:[s.jsx("div",{className:"flex items-center justify-center transition-transform group-hover:scale-110 shrink-0",children:s.jsx(jC,{size:21,className:X?"fill-white text-white":""})}),s.jsxs("span",{className:"text-xs sm:text-[13px] font-black tracking-tight",children:[fl(h.length)," Comments ",X?"(Open)":""]})]}),s.jsxs("button",{onClick:vr,className:Fe("flex items-center gap-1.5 sm:gap-2 px-3 sm:px-4 py-1.5 rounded-full transition-all duration-300 hover:scale-105 active:scale-95 cursor-pointer backdrop-blur-md shadow-2xs hover:shadow-xs",q?"bg-amber-500 text-white font-extrabold shadow-sm shadow-amber-500/25":"bg-white/75 hover:bg-white dark:bg-white/10 dark:hover:bg-white/20 text-gray-800 dark:text-gray-100 hover:text-amber-500 border border-white/80 dark:border-white/10"),title:"Bookmark",children:[s.jsx("div",{className:"flex items-center justify-center transition-transform group-hover:scale-110 shrink-0",children:s.jsx(dq,{size:20,className:q?"fill-white text-white":""})}),s.jsxs("span",{className:"text-xs sm:text-[13px] font-black tracking-tight",children:[fl(o.saveCount||0)," Saved"]})]}),s.jsxs("div",{className:"relative inline-block",children:[s.jsxs("button",{onClick:()=>ne(!ye),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-white/75 hover:bg-white dark:bg-white/10 dark:hover:bg-white/20 text-gray-800 dark:text-gray-100 hover:text-rose-600 border border-white/80 dark:border-white/10 transition-all duration-300 hover:scale-105 active:scale-95 cursor-pointer shadow-2xs select-none",children:[s.jsx("span",{className:"text-sm shrink-0 leading-none",children:$||"😊"}),s.jsx("span",{className:"text-xs sm:text-[13px] font-black",children:$?"Reacted":"React"})]}),s.jsx(or,{children:ye&&s.jsxs(Zt.div,{initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:"absolute bottom-full mb-2 left-1/2 -translate-x-1/2 bg-white/95 backdrop-blur-2xl border border-white/90 p-3 shadow-2xl z-[150] rounded-2xl w-64 text-left space-y-2",onClick:me=>me.stopPropagation(),children:[s.jsx("div",{className:"text-[9px] font-black uppercase text-gray-400 tracking-wider",children:"Popular Reactions"}),s.jsx("div",{className:"grid grid-cols-6 gap-1.5",children:RL.map(me=>s.jsx("button",{onClick:()=>{Ve(me),ne(!1)},className:Fe("w-8 h-8 rounded-full flex items-center justify-center hover:scale-125 transition-transform text-base hover:bg-gray-100 cursor-pointer",$===me&&"bg-rose-50 border border-rose-200"),title:me,children:me},me))}),s.jsx("div",{className:"border-t border-gray-100 pt-2 flex items-center gap-1",children:s.jsx("input",{type:"text",maxLength:6,placeholder:"Or custom...",className:"w-full px-2.5 py-1 text-xs border border-gray-250 rounded-lg text-center focus:ring-0 focus:border-gray-400 bg-white",onChange:me=>{const qe=me.target.value.trim();qe&&(Ve(qe),ne(!1),me.target.value="")}})})]})})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-3 py-1.5 rounded-full bg-white/55 dark:bg-white/10 backdrop-blur-md border border-white/70 dark:border-white/10 shadow-2xs",title:"Views",children:[s.jsx("div",{className:"flex items-center justify-center shrink-0",children:s.jsx(IC,{size:21})}),s.jsxs("span",{className:"text-xs sm:text-[13px] font-black text-gray-800 dark:text-gray-100 tracking-tight",children:[fl(o.viewCount||0)," Views"]})]}),s.jsxs("button",{onClick:cn,className:"flex items-center gap-1.5 sm:gap-2 px-3 py-1.5 rounded-full transition-all duration-300 hover:scale-105 active:scale-95 cursor-pointer backdrop-blur-md bg-white/75 hover:bg-white dark:bg-white/10 dark:hover:bg-white/20 text-gray-800 dark:text-gray-100 hover:text-green-600 border border-white/80 dark:border-white/10 shadow-2xs hover:shadow-xs",title:"Share",children:[s.jsx("div",{className:"flex items-center justify-center transition-transform group-hover:scale-110 shrink-0",children:s.jsx(Bw,{size:21})}),s.jsxs("span",{className:"text-xs sm:text-[13px] font-black tracking-tight",children:[fl(o.shareCount||0)," Share"]})]})]})]})]}),s.jsxs("div",{id:"full-article-comments-section",className:Fe("space-y-4 my-6 p-4 sm:p-7 md:p-8 bg-[#0a0d12] text-white rounded-2xl sm:rounded-3xl border border-indigo-500/40 shadow-2xl relative z-30 transition-opacity duration-150 w-full ring-1 ring-indigo-500/20 max-w-full overflow-hidden",!X&&"hidden"),children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 border-b border-gray-800/80 pb-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-6 bg-indigo-500 rounded-full"}),s.jsxs("h4",{className:"text-sm sm:text-base font-black text-gray-100 uppercase tracking-wider block text-left",children:["All Comments (",h.length,")"]})]}),s.jsx("div",{className:"flex items-center gap-1 bg-[#15181c] p-1 rounded-full border border-gray-800 self-start sm:self-auto",children:["newest","oldest","liked"].map(me=>s.jsx("button",{type:"button",onClick:()=>St(me),className:Fe("px-2.5 py-1 text-[9px] font-black uppercase tracking-wider rounded-full transition-all cursor-pointer select-none",Vt===me?"bg-indigo-600 text-white shadow-sm":"text-gray-400 hover:text-gray-200"),children:me==="liked"?"Most Liked":me},me))})]}),tn&&s.jsxs("div",{className:"flex items-center justify-between bg-[#15181c] border border-gray-800 rounded-xl px-4 py-2.5 mb-1.5 text-xs text-gray-300 animate-slide-down",children:[s.jsxs("div",{className:"flex items-center gap-2 truncate text-left",children:[s.jsx("span",{className:"text-indigo-400 font-extrabold uppercase text-[9px] tracking-wider shrink-0 bg-indigo-950/40 px-1.5 py-0.5 rounded border border-indigo-800/40",children:"Replying to"}),s.jsxs("span",{className:"font-extrabold text-blue-400 shrink-0",children:["@",tn.authorName]}),s.jsxs("span",{className:"text-gray-500 truncate italic",children:['"',tn.content,'"']})]}),s.jsx("button",{type:"button",onClick:()=>Pt(null),className:"text-gray-400 hover:text-white transition-colors p-1 cursor-pointer",title:"Cancel reply",children:s.jsx(er,{size:14})})]}),w&&s.jsxs("div",{className:"p-2 bg-gray-900 border border-gray-800 my-2 flex items-center justify-between rounded-xl",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("img",{src:w,alt:"Sticker attachment",className:"h-14 max-w-[100px] object-contain rounded-lg border border-gray-700 bg-black p-1 shadow-sm"}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-[10px] font-bold text-gray-200 uppercase tracking-wider",children:"Sticker Attached"}),s.jsx("span",{className:"text-[9px] text-gray-400",children:"Ready to post"})]})]}),s.jsx("button",{type:"button",onClick:()=>A(null),className:"p-1.5 text-red-400 hover:bg-red-950/40 rounded-full transition-colors",title:"Remove sticker",children:s.jsx(As,{size:16})})]}),s.jsxs("form",{id:"comment-form",onSubmit:Mt,className:"flex flex-col gap-2 bg-[#15181c] border border-gray-800 rounded-2xl p-2.5 focus-within:border-indigo-500/50 transition-all",children:[s.jsx(rY,{value:m,onSelectMention:me=>y(me)}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",placeholder:tn?`Replying to @${tn.authorName}...`:"Let's talk about it or paste keyboard stickers...",value:m,onChange:me=>y(me.target.value),onPaste:V,className:"flex-1 bg-transparent text-white text-xs sm:text-sm outline-none focus:outline-none border-none py-1.5 px-2 placeholder-gray-500"}),s.jsx("button",{type:"submit",disabled:de||!m.trim()&&!w,className:"bg-indigo-600 hover:bg-indigo-700 disabled:opacity-40 text-white font-extrabold uppercase px-4 h-8 rounded-full text-[10px] tracking-wider transition-colors shrink-0 cursor-pointer",children:"Reply"})]}),s.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-gray-800/60 px-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{htmlFor:"fullpage-sticker-upload",className:"flex items-center gap-1.5 px-2.5 py-1 bg-gray-900 border border-gray-700 rounded-full text-[10px] font-bold text-gray-300 hover:border-indigo-500 hover:text-white transition-all cursor-pointer",title:"Upload device sticker / photo",children:[s.jsx(Qre,{size:12,className:"text-indigo-400"}),s.jsx("span",{children:"Device Sticker"}),s.jsx("input",{id:"fullpage-sticker-upload",type:"file",accept:"image/*,video/*",onChange:L,className:"hidden"})]}),s.jsxs("button",{type:"button",onClick:()=>C(!S),className:"flex items-center gap-1.5 px-2.5 py-1 bg-gray-900 border border-gray-700 rounded-full text-[10px] font-bold text-gray-300 hover:border-indigo-500 hover:text-white transition-all cursor-pointer",children:[s.jsx(hF,{size:12,className:"text-amber-400"}),s.jsx("span",{children:"Stickers"})]})]}),s.jsx("span",{className:"text-[8px] text-gray-500 italic",children:"Keyboard stickers supported"})]}),S&&s.jsx("div",{className:"p-2 bg-gray-900 border border-gray-800 shadow-xl rounded-xl mt-1 flex flex-wrap gap-1.5 animate-in fade-in duration-150 z-20",children:["👍","🔥","❤️","🎯","💯","👏","🚀","⚡","😍","🙌","🤩","🎉","💡","📌","🎓","📣"].map(me=>s.jsx("button",{type:"button",onClick:()=>{y(qe=>`${qe} ${me}`.trim()),C(!1)},className:"w-8 h-8 text-base flex items-center justify-center hover:bg-gray-800 rounded-lg transition-transform hover:scale-125 cursor-pointer",children:me},me))})]}),s.jsx("div",{className:"space-y-4 pt-2",children:h.length>0?(()=>{const me=[...h].sort((Ft,Dn)=>{var jr,lr,ue,Se;const Ot=(jr=Ft.createdAt)!=null&&jr.toDate?Ft.createdAt.toDate().getTime():((lr=Ft.createdAt)==null?void 0:lr.seconds)*1e3||0,on=(ue=Dn.createdAt)!=null&&ue.toDate?Dn.createdAt.toDate().getTime():((Se=Dn.createdAt)==null?void 0:Se.seconds)*1e3||0;if(Vt==="oldest")return Ot-on;if(Vt==="liked"){const Qe=Ft.likeCount||0,Gt=Dn.likeCount||0;return Gt!==Qe?Gt-Qe:on-Ot}else return on-Ot}),qe=me.filter(Ft=>!Ft.parentId),st=me.filter(Ft=>Ft.parentId),dt=Ft=>({A:"bg-red-500",B:"bg-pink-500",C:"bg-purple-500",D:"bg-indigo-500",E:"bg-blue-500",F:"bg-cyan-500",G:"bg-teal-500",H:"bg-emerald-500",I:"bg-green-500",J:"bg-yellow-500",K:"bg-amber-500",L:"bg-orange-500",M:"bg-rose-500",N:"bg-red-650",O:"bg-indigo-600",P:"bg-purple-600",Q:"bg-pink-600",R:"bg-blue-600",S:"bg-violet-600",T:"bg-rose-600",U:"bg-teal-600",V:"bg-emerald-600",W:"bg-indigo-700",X:"bg-purple-700",Y:"bg-sky-500",Z:"bg-fuchsia-600"})[Ft]||"bg-slate-600",An=(Ft,Dn=!1)=>{var lr;const Ot=Ne.currentUser?localStorage.getItem(`liked_comment_${Ft.id}_${Ne.currentUser.uid}`)==="true":!1,on=Ft.createdAt?(()=>{const ue=Ft.createdAt.toDate?Ft.createdAt.toDate():new Date(Ft.createdAt.seconds*1e3),Se=Date.now()-ue.getTime(),Qe=Math.floor(Se/(1e3*60*60));if(Qe===0){const Gt=Math.floor(Se/6e4);return Gt<=1?"just now":`${Gt}m ago`}else return Qe<24?`${Qe} hours ago`:ue.toLocaleDateString(void 0,{month:"short",day:"numeric"})})():"Just now",jr=Ft.authorName?Ft.authorName.charAt(0).toUpperCase():"?";return s.jsxs("div",{id:`comment-${Ft.id}`,className:Fe("flex gap-3 text-xs pt-1.5 transition-all",Dn?"pb-1":"pb-3"),children:[Ft.photoURL?s.jsx("img",{src:Ft.photoURL,className:"w-8 h-8 rounded-full object-cover border border-gray-800 shrink-0",alt:"",referrerPolicy:"no-referrer"}):s.jsx("div",{className:Fe("w-8 h-8 rounded-full flex items-center justify-center text-white font-extrabold text-[10px] uppercase shrink-0 shadow-md",dt(jr)),children:jr}),s.jsxs("div",{className:"flex-1 space-y-1 text-left min-w-0 pr-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-extrabold text-[#f3f4f6] text-[12px] tracking-tight",children:Ft.authorName}),(Ft.isAIGenerated||Ft.isAiGenerated||Ft.userId==="mega-ai-bot"||((lr=Ft.authorName)==null?void 0:lr.toLowerCase().includes("mega ai")))&&s.jsx(zw,{})]}),Ft.replyToAuthor&&s.jsxs("span",{className:"text-[9px] text-[#9ca3af] font-bold uppercase mt-0.5",children:["Replying to ",s.jsxs("span",{className:"text-amber-500",children:["@",Ft.replyToAuthor]})]})]}),s.jsxs("button",{type:"button",onClick:()=>qn(Ft.id),className:Fe("flex items-center gap-1.5 p-1 text-gray-400 hover:text-red-500 transition-all cursor-pointer",Ot&&"text-red-500"),children:[s.jsx("span",{className:"text-[10px] text-gray-400",children:(Ft.likeCount||0)>0?fl(Ft.likeCount):""}),s.jsx(mc,{size:12,className:Fe("transition-transform hover:scale-110",Ot?"fill-red-500 text-red-500":"text-gray-400")})]})]}),s.jsx("p",{className:"text-[#e5e7eb] font-sans leading-relaxed text-[12px] whitespace-pre-line pr-2 break-words max-w-full overflow-hidden",children:L2(Ft.content)}),(Ft.stickerUrl||Ft.imageUrl)&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:Ft.stickerUrl||Ft.imageUrl,alt:"Comment sticker",className:"max-h-48 max-w-xs object-contain rounded-xl border border-gray-800 bg-black p-1 shadow-md hover:scale-105 transition-transform"})}),s.jsxs("div",{className:"flex items-center gap-3 pt-1 text-[9px] text-gray-500 font-bold select-none",children:[s.jsx("span",{children:on}),s.jsx("button",{type:"button",onClick:()=>{var Se,Qe;Pt(Ft);const ue=(Se=document.getElementById("comment-form"))==null?void 0:Se.querySelector("input");ue&&ue.focus(),(Qe=document.getElementById("comment-form"))==null||Qe.scrollIntoView({behavior:"smooth"})},className:"hover:text-amber-500 hover:scale-102 transition-all cursor-pointer bg-transparent border-0 text-[10px] font-black text-gray-400 uppercase tracking-widest block pl-0",children:"Reply"})]})]})]},Ft.id)};return qe.map(Ft=>{const Dn=st.filter(Ot=>Ot.parentId===Ft.id);return s.jsxs("div",{className:"border-b border-gray-900 last:border-0 pb-4",children:[An(Ft,!1),Dn.length>0&&s.jsx("div",{className:"pl-8 border-l border-zinc-700/50 mt-1.5 space-y-2.5",children:Dn.map(Ot=>An(Ot,!0))})]},Ft.id)})})():s.jsxs("div",{className:"text-center py-10 bg-[#15181c] border border-dashed border-gray-800 rounded-2xl",children:[s.jsx(jC,{size:24,className:"text-gray-600 mx-auto mb-2 opacity-50"}),s.jsx("p",{className:"text-[10.5px] text-gray-400 font-bold uppercase tracking-wider",children:"No verified commentary published. Start the conversation!"})]})})]}),s.jsx("div",{className:Fe("my-8 pt-8 border-t border-gray-100 transition-opacity duration-150",X&&"opacity-90"),children:s.jsxs("div",{className:"flex flex-col gap-2 select-none text-left",children:[s.jsx("span",{className:"text-[9px] font-black tracking-[0.25em] text-gray-400 uppercase",children:"Strategic Partners & Sponsors"}),s.jsx("div",{className:"flex flex-wrap items-center gap-4 py-3",children:It.length>0?s.jsx("div",{className:"flex flex-wrap items-center gap-4 sm:gap-6",children:It.map(me=>s.jsxs("a",{href:me.link||me.targetUrl||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 bg-gray-50 hover:bg-white px-3.5 py-2 rounded-2xl border border-gray-200/80 shadow-2xs hover:shadow-md hover:border-red-300 transition-all group",children:[me.imageUrl&&s.jsx("img",{src:me.imageUrl,className:"h-9 sm:h-10 object-contain max-h-9 sm:max-h-10 rounded-lg",alt:me.name,referrerPolicy:"no-referrer"}),s.jsx("span",{className:"text-xs sm:text-sm font-black uppercase tracking-wide text-gray-800 group-hover:text-red-650 transition-colors",children:me.name})]},me.id))}):s.jsxs("div",{className:"p-3 bg-gray-50 border border-gray-150 rounded-xl flex items-center justify-between gap-4 w-full",children:[s.jsx("span",{className:"text-[9.5px] font-mono text-gray-500 uppercase tracking-wider font-bold",children:"Partner with Campus Eye Media"}),s.jsx("span",{className:"text-[9px] font-black text-red-650 uppercase tracking-widest bg-white px-2.5 py-1 rounded border border-gray-200 shadow-2xs",children:"Get Featured"})]})})]})}),s.jsxs("div",{className:Fe("my-8 p-5 bg-gray-50/50 border border-gray-150 rounded-2xl text-left transition-opacity duration-150",X&&"opacity-90"),children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("span",{className:"text-[10px] font-black text-red-650 bg-red-50 border border-red-100 px-2 py-0.5 rounded-md uppercase tracking-wide",children:"Event Booking Embed"}),s.jsx("span",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-widest",children:"Secure Reservation Desk"})]}),s.jsx("p",{className:"text-[10.5px] text-gray-500 mb-4 italic leading-relaxed",children:"Reading about this exclusive college event? You can secure your active box office entry pass directly below with our digital verification key protocol."}),s.jsx(nY,{})]}),s.jsxs("div",{className:Fe("py-6 border-b border-gray-100 text-center space-y-3.5 transition-opacity duration-150",X&&"opacity-90"),children:[s.jsx("div",{className:"flex flex-wrap items-center justify-center gap-4 mb-3",children:s.jsxs("div",{className:"relative inline-block",children:[s.jsxs("button",{onClick:()=>ne(!ye),className:"flex items-center gap-2 px-5 py-2.5 bg-black hover:bg-neutral-800 text-white font-extrabold text-[10px] uppercase tracking-widest transition-all rounded-full shadow-lg cursor-pointer",children:[s.jsx("span",{children:$||"😊"}),s.jsx("span",{children:$?"Change Reaction":"React"})]}),s.jsx(or,{children:ye&&s.jsxs(Zt.div,{initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:"absolute bottom-12 left-1/2 -translate-x-1/2 bg-white border border-gray-150 p-3 shadow-2xl z-[150] rounded-3xl w-72 text-left space-y-2.5",onClick:me=>me.stopPropagation(),children:[s.jsx("div",{className:"text-[9px] font-black uppercase text-gray-400 tracking-wider mb-1",children:"Popular Reactions"}),s.jsx("div",{className:"grid grid-cols-6 gap-2",children:RL.map(me=>s.jsx("button",{onClick:()=>{Ve(me),ne(!1)},className:Fe("w-8 h-8 rounded-full flex items-center justify-center hover:scale-125 transition-transform text-lg hover:bg-gray-50",$===me&&"bg-indigo-50 border border-indigo-200"),title:me,children:me},me))}),s.jsx("div",{className:"border-t border-gray-100 pt-2.5 flex items-center gap-1.5",children:s.jsx("input",{type:"text",maxLength:6,placeholder:"Or write yours...",className:"w-full px-2.5 py-1.5 text-xs border border-gray-200 rounded-xl text-center focus:ring-0 focus:border-gray-400 bg-white",onChange:me=>{const qe=me.target.value.trim();qe&&(Ve(qe),ne(!1),me.target.value="")}})})]})})]})}),s.jsx("div",{className:"flex flex-wrap items-center justify-center gap-2 pt-2.5",children:Object.entries(Dt()).map(([me,qe])=>{const st=$===me;return s.jsxs("div",{onClick:()=>Ve(me),className:Fe("flex items-center gap-1 hover:scale-105 px-3 py-1.5 border rounded-full text-[12px] font-bold select-none cursor-pointer transition-all",st?"bg-red-50 border-red-300 text-red-600 font-extrabold ring-1 ring-red-300/40":"bg-white border-gray-150 text-gray-600 hover:border-gray-300 hover:bg-gray-50/50"),children:[s.jsx("span",{className:"text-sm leading-none shrink-0",children:me}),s.jsx("span",{className:"font-mono text-[9px] font-black text-gray-500 bg-gray-100 px-1 rounded-sm leading-none shrink-0 min-w-[12px] text-center",children:qe})]},me)})})]}),s.jsxs("div",{className:Fe("space-y-6 pt-2 pb-6 text-left transition-opacity duration-150",X&&"opacity-90"),children:[(()=>{const me=["News","Sports","Music","Entertainment","Innovation","Culture","Business"].map(qe=>{const st=r==null?void 0:r.find(dt=>(dt.category||"").toLowerCase().trim()===qe.toLowerCase().trim());return{cat:qe,presentingArticle:st}}).filter(qe=>qe.presentingArticle);return me.length===0?null:s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 font-black text-gray-950 text-[10px] tracking-wider uppercase mb-3 select-none",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-650"}),s.jsx("span",{children:"Explore Categories"})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:me.map(({cat:qe,presentingArticle:st})=>s.jsxs("div",{onClick:()=>{if(i&&st){i(st);const dt=document.getElementById("full-article-modal-container");dt&&dt.scrollTo({top:0,behavior:"smooth"})}},className:"group flex items-center gap-3 p-2 bg-gray-50/70 hover:bg-white border border-gray-150 hover:border-red-350 hover:shadow-xs transition-all rounded-xl cursor-pointer text-left",children:[s.jsx("div",{className:"w-11 h-11 rounded-lg overflow-hidden bg-gray-200 shrink-0 border border-gray-150",children:s.jsx("img",{src:st.featuredImageUrl,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",alt:"",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsx("span",{className:"bg-red-50 text-red-655 px-1.5 py-0.5 text-[8px] font-black uppercase tracking-widest border border-red-100/70 rounded-xs",children:qe})}),s.jsx("h5",{className:"font-serif font-black text-[10.5px] text-gray-950 truncate group-hover:text-red-655 transition-colors underline decoration-gray-150",children:st.title})]})]},qe))})]})})(),r&&r.length>0&&s.jsxs("div",{className:"space-y-3 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 font-black text-gray-950 text-[10px] tracking-wider uppercase border-b border-gray-100 pb-2 select-none",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-650"}),s.jsx("span",{children:"Related Campus Stories"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:(()=>{const me=(e.category||"").toLowerCase().trim(),qe=r.filter(dt=>dt.id!==e.id&&(dt.category||"").toLowerCase().trim()===me),st=r.filter(dt=>dt.id!==e.id&&(dt.category||"").toLowerCase().trim()!==me);return[...qe,...st].slice(0,4)})().map(me=>s.jsxs("div",{onClick:()=>{if(i){i(me);const qe=document.getElementById("full-article-modal-container");qe&&qe.scrollTo({top:0,behavior:"smooth"})}},className:"group flex gap-3 p-3 bg-gray-50/50 hover:bg-white border border-gray-100/70 hover:border-red-200 hover:shadow-md transition-all rounded-2xl cursor-pointer text-left focus:outline-hidden",children:[me.featuredImageUrl?s.jsx("img",{src:me.featuredImageUrl,alt:"",className:"w-16 h-16 rounded-xl object-cover border border-gray-100 shrink-0 select-none group-hover:scale-105 transition-transform",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"w-16 h-16 rounded-xl bg-gray-100 flex items-center justify-center shrink-0 text-gray-400 select-none font-black text-xs uppercase tracking-widest border border-gray-100",children:"EYE"}),s.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-between py-0.5 font-sans",children:[s.jsx("span",{className:"text-[7.5px] font-black uppercase tracking-widest text-red-650",children:me.category||"General"}),s.jsx("h5",{className:"font-extrabold text-[11px] text-gray-950 group-hover:text-red-650 transition-colors tracking-tight leading-snug line-clamp-2",children:me.title}),s.jsx("span",{className:"text-[7.5px] font-mono text-gray-400 font-bold uppercase tracking-widest",children:"Read dispatch →"})]})]},me.id))})]})]})]}),s.jsx(ZW,{isOpen:xe,imagesList:Ue,initialIndex:G,imageUrl:Ue[G]||"",title:o.title,onClose:()=>re(!1)}),s.jsx(or,{children:Me&&s.jsxs("div",{className:"fixed inset-0 z-[2500] flex",children:[s.jsx(Zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>nt(!1),className:"fixed inset-0 bg-black/60 backdrop-blur-sm"}),s.jsxs(Zt.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",damping:25,stiffness:220},className:"relative w-80 max-w-[85vw] bg-white h-full shadow-2xl overflow-y-auto flex flex-col pt-5 px-6 border-r border-gray-150 z-[2600] text-left text-gray-900",children:[s.jsxs("div",{className:"flex items-center justify-between pb-4 border-b border-gray-100 mb-6",children:[s.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Campus Eye Logo",className:"h-7 w-7 rounded-full border border-gray-950 bg-white object-cover aspect-square shrink-0",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"flex flex-col justify-center text-left -space-y-1",children:[s.jsxs("span",{className:"text-[11px] font-serif font-black tracking-normal italic leading-none",children:[s.jsx("span",{className:"text-red-650",children:"Campus"})," ",s.jsx("span",{className:"text-blue-600",children:"Eye"})]}),s.jsx("span",{className:"text-[5.5px] font-sans font-extrabold uppercase tracking-[0.24em] text-black text-right pr-0.2 block select-none leading-none",children:"Media"})]})]}),s.jsx("button",{onClick:()=>nt(!1),className:"p-1.5 rounded-full hover:bg-gray-100 text-gray-400 hover:text-gray-950 transition-all cursor-pointer flex items-center justify-center shrink-0",children:s.jsx(er,{size:16})})]}),s.jsxs("div",{className:"flex-1 space-y-1.5 font-sans",children:[[{id:"home",label:"Home",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})})},{id:"news",label:"Campus News",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1M19 20a2 2 0 002-2V8a2 2 0 00-2-2h-5a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h1.5m-1.5 3h1.5m3-3H15m-1.5 3H15m-3.5 3H15"})})},{id:"discussions",label:"Public Debates",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})},{id:"tickets",label:"Ticket Store",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"})})},{id:"podcasts",label:"Audio Podcasts",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})},{id:"feedback",label:"Feedback Desk",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})},{id:"account",label:"My Account",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}].map(me=>s.jsxs("button",{onClick:()=>{nt(!1),t(),window.dispatchEvent(new CustomEvent("setTab",{detail:me.id}))},className:"flex items-center gap-3 w-full px-4 py-2.5 rounded-xl transition-all font-bold text-xs uppercase tracking-wider text-left text-gray-700 hover:bg-gray-50 hover:text-black cursor-pointer",children:[s.jsx(me.icon,{}),s.jsx("span",{children:me.label})]},me.id)),ze&&ze.length>0&&ze.map(me=>s.jsxs("button",{onClick:()=>{nt(!1),t(),window.dispatchEvent(new CustomEvent("selectCustomPage",{detail:me}))},className:"flex items-center gap-3 w-full px-4 py-2.5 rounded-xl transition-all font-bold text-xs uppercase tracking-wider text-left text-gray-700 hover:bg-gray-50 hover:text-black cursor-pointer",children:[s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),s.jsx("span",{className:"truncate",children:me.name})]},me.id))]})]})]})}),T&&s.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-md z-[200] flex items-end sm:items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200",onClick:me=>{me.stopPropagation(),D(!1)},children:s.jsxs("div",{className:"bg-white/95 dark:bg-neutral-900/95 backdrop-blur-2xl border border-gray-200/80 dark:border-white/10 rounded-3xl p-5 sm:p-6 w-full max-w-sm shadow-2xl space-y-4 text-center relative animate-in slide-in-from-bottom-5 duration-200",onClick:me=>me.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 dark:border-neutral-800 pb-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-left",children:[s.jsx("div",{className:"p-2 bg-red-50 text-red-650 rounded-full",children:s.jsx(hf,{size:16})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-bold text-gray-900 dark:text-white",children:"Share Article"}),s.jsx("p",{className:"text-[10px] text-gray-500 lowercase tracking-tight",children:"Choose your preferred social platform"})]})]}),s.jsx("button",{onClick:()=>D(!1),className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-full transition-all cursor-pointer",children:s.jsx(er,{size:18})})]}),s.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-neutral-800/60 rounded-2xl border border-gray-100 dark:border-neutral-700/50 text-left space-y-1",children:[s.jsx("p",{className:"text-[11px] font-extrabold text-gray-900 dark:text-white line-clamp-1",children:e.title}),s.jsx("p",{className:"text-[9px] text-gray-500 font-mono truncate",children:`${window.location.origin}/article/${e.id}`})]}),s.jsxs("div",{className:"grid grid-cols-4 gap-2 pt-1",children:[s.jsxs("a",{href:`https://api.whatsapp.com/send?text=${encodeURIComponent(e.title+` Read more: ${window.location.origin}/article/${e.id}`)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>D(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-emerald-50 text-emerald-700 rounded-2xl hover:bg-emerald-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"💬"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"WhatsApp"})]}),s.jsxs("a",{href:`https://twitter.com/intent/tweet?text=${encodeURIComponent(e.title)}&url=${encodeURIComponent(`${window.location.origin}/article/${e.id}`)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>D(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-sky-50 text-sky-700 rounded-2xl hover:bg-sky-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"🐦"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Twitter/X"})]}),s.jsxs("a",{href:`https://t.me/share/url?url=${encodeURIComponent(`${window.location.origin}/article/${e.id}`)}&text=${encodeURIComponent(e.title)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>D(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-blue-50 text-blue-700 rounded-2xl hover:bg-blue-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"✈️"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Telegram"})]}),s.jsxs("a",{href:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(`${window.location.origin}/article/${e.id}`)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>D(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-indigo-50 text-indigo-700 rounded-2xl hover:bg-indigo-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"📘"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Facebook"})]})]}),s.jsx("div",{className:"pt-2",children:s.jsx("button",{onClick:async()=>{const me=`${window.location.origin}/article/${e.id}`;await Md(`${e.title} ${me}`),ir.success("Link copied to clipboard!"),D(!1)},className:"w-full py-3 bg-red-650 hover:bg-red-700 text-white font-bold text-xs uppercase tracking-widest rounded-2xl transition-all shadow-md active:scale-98 flex items-center justify-center gap-2 cursor-pointer",children:s.jsx("span",{children:"Copy Direct Link"})})})]})})]})},aY="campus_expansion_dbs",oY="campus_active_write_db_slot",yj="campus_custom_auth_domain";function F2e(){try{const e=localStorage.getItem(aY);return e?JSON.parse(e):[]}catch(e){return console.warn("Failed to load expansion slots:",e),[]}}function DL(e){try{localStorage.setItem(aY,JSON.stringify(e))}catch(t){console.error("Failed to save expansion slots:",t)}}function $2e(){return localStorage.getItem(oY)||"default"}function ML(e){localStorage.setItem(oY,e)}function H2e(){return localStorage.getItem(yj)||P2.authDomain}function G2e(e){e.trim()?localStorage.setItem(yj,e.trim()):localStorage.removeItem(yj)}function q2e(e){const t=e.trim();if(!t)throw new Error("Empty Firebase config input provided.");try{const a=JSON.parse(t);if(typeof a=="object"&&a!==null)return{apiKey:a.apiKey||"",authDomain:a.authDomain||"",projectId:a.projectId||"",storageBucket:a.storageBucket||"",messagingSenderId:a.messagingSenderId||"",appId:a.appId||"",measurementId:a.measurementId||"",firestoreDatabaseId:a.firestoreDatabaseId||"(default)"}}catch{}const n=["apiKey","authDomain","projectId","storageBucket","messagingSenderId","appId","measurementId","firestoreDatabaseId"],r={apiKey:"",authDomain:"",projectId:"",storageBucket:"",messagingSenderId:"",appId:"",measurementId:"",firestoreDatabaseId:"(default)"};let i=0;for(const a of n){const o=new RegExp(`${a}\\s*:\\s*["'\`]([^"'\`]+)["'\`]`,"i"),c=t.match(o);c&&c[1]&&(r[a]=c[1].trim(),i++)}if(i===0||!r.apiKey)throw new Error("Could not detect valid Firebase config fields (apiKey, projectId, etc.). Please check the pasted snippet.");return r}function W2e(e,t="https://campuseyemedia.com"){const n=t.replace(/\/$/,""),r=new Date().toISOString(),i=e.map(a=>{var f,m,y;const o=a.id,c=(f=a.updatedAt)!=null&&f.toDate?a.updatedAt.toDate().toISOString():(m=a.publishDate)!=null&&m.toDate?a.publishDate.toDate().toISOString():(y=a.createdAt)!=null&&y.toDate?a.createdAt.toDate().toISOString():r,h=a.featuredImageUrl||"";return` ${n}/#article-${o} ${c} daily 0.8 ${h?` ${LL(h)} ${LL(a.title)} `:""} `}).join(` `);return` ${n}/ ${r} always 1.0 ${i} `}function LL(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}var K2e=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function T4(e){if(typeof e!="string")return!1;var t=K2e;return t.includes(e)}var Y2e=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],X2e=new Set(Y2e);function lY(e){return typeof e!="string"?!1:X2e.has(e)}function cY(e){return typeof e=="string"&&e.startsWith("data-")}function Fl(e){if(typeof e!="object"||e===null)return{};var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(lY(n)||cY(n))&&(t[n]=e[n]);return t}function sb(e){if(e==null)return null;if(I.isValidElement(e)&&typeof e.props=="object"&&e.props!==null){var t=e.props;return Fl(t)}return typeof e=="object"&&!Array.isArray(e)?Fl(e):null}function Co(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(lY(n)||cY(n)||T4(n))&&(t[n]=e[n]);return t}function Q2e(e){return e==null?null:I.isValidElement(e)?Co(e.props):typeof e=="object"&&!Array.isArray(e)?Co(e):null}var Z2e=["children","width","height","viewBox","className","style","title","desc"];function bj(){return bj=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:n,width:r,height:i,viewBox:a,className:o,style:c,title:h,desc:f}=e,m=J2e(e,Z2e),y=a||{width:r,height:i,x:0,y:0},w=Pi("recharts-surface",o);return I.createElement("svg",bj({},Co(m),{className:w,width:r,height:i,style:c,viewBox:"".concat(y.x," ").concat(y.y," ").concat(y.width," ").concat(y.height),ref:t}),I.createElement("title",null,h),I.createElement("desc",null,f),n)}),tNe=["children","className"];function vj(){return vj=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:n,className:r}=e,i=nNe(e,tNe),a=Pi("recharts-layer",r);return I.createElement("g",vj({className:a},Co(i),{ref:t}),n)}),uY=I.createContext(null),iNe=()=>I.useContext(uY);function ls(e){return function(){return e}}const dY=Math.cos,Z2=Math.sin,Xc=Math.sqrt,J2=Math.PI,qE=2*J2,wj=Math.PI,Nj=2*wj,fp=1e-6,sNe=Nj-fp;function hY(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return hY;const n=10**t;return function(r){this._+=r[0];for(let i=1,a=r.length;ifp)if(!(Math.abs(y*h-f*m)>fp)||!a)this._append`L${this._x1=t},${this._y1=n}`;else{let A=r-o,S=i-c,C=h*h+f*f,T=A*A+S*S,D=Math.sqrt(C),V=Math.sqrt(w),L=a*Math.tan((wj-Math.acos((C+w-T)/(2*D*V)))/2),K=L/V,Z=L/D;Math.abs(K-1)>fp&&this._append`L${t+K*m},${n+K*y}`,this._append`A${a},${a},0,0,${+(y*A>m*S)},${this._x1=t+Z*h},${this._y1=n+Z*f}`}}arc(t,n,r,i,a,o){if(t=+t,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let c=r*Math.cos(i),h=r*Math.sin(i),f=t+c,m=n+h,y=1^o,w=o?i-a:a-i;this._x1===null?this._append`M${f},${m}`:(Math.abs(this._x1-f)>fp||Math.abs(this._y1-m)>fp)&&this._append`L${f},${m}`,r&&(w<0&&(w=w%Nj+Nj),w>sNe?this._append`A${r},${r},0,1,${y},${t-c},${n-h}A${r},${r},0,1,${y},${this._x1=f},${this._y1=m}`:w>fp&&this._append`A${r},${r},0,${+(w>=wj)},${y},${this._x1=t+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function O4(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new oNe(t)}function R4(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function fY(e){this._context=e}fY.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function WE(e){return new fY(e)}function pY(e){return e[0]}function mY(e){return e[1]}function gY(e,t){var n=ls(!0),r=null,i=WE,a=null,o=O4(c);e=typeof e=="function"?e:e===void 0?pY:ls(e),t=typeof t=="function"?t:t===void 0?mY:ls(t);function c(h){var f,m=(h=R4(h)).length,y,w=!1,A;for(r==null&&(a=i(A=o())),f=0;f<=m;++f)!(f=A;--S)c.point(L[S],K[S]);c.lineEnd(),c.areaEnd()}D&&(L[w]=+e(T,w,y),K[w]=+t(T,w,y),c.point(r?+r(T,w,y):L[w],n?+n(T,w,y):K[w]))}if(V)return c=null,V+""||null}function m(){return gY().defined(i).curve(o).context(a)}return f.x=function(y){return arguments.length?(e=typeof y=="function"?y:ls(+y),r=null,f):e},f.x0=function(y){return arguments.length?(e=typeof y=="function"?y:ls(+y),f):e},f.x1=function(y){return arguments.length?(r=y==null?null:typeof y=="function"?y:ls(+y),f):r},f.y=function(y){return arguments.length?(t=typeof y=="function"?y:ls(+y),n=null,f):t},f.y0=function(y){return arguments.length?(t=typeof y=="function"?y:ls(+y),f):t},f.y1=function(y){return arguments.length?(n=y==null?null:typeof y=="function"?y:ls(+y),f):n},f.lineX0=f.lineY0=function(){return m().x(e).y(t)},f.lineY1=function(){return m().x(e).y(n)},f.lineX1=function(){return m().x(r).y(t)},f.defined=function(y){return arguments.length?(i=typeof y=="function"?y:ls(!!y),f):i},f.curve=function(y){return arguments.length?(o=y,a!=null&&(c=o(a)),f):o},f.context=function(y){return arguments.length?(y==null?a=c=null:c=o(a=y),f):a},f}class xY{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function lNe(e){return new xY(e,!0)}function cNe(e){return new xY(e,!1)}const D4={draw(e,t){const n=Xc(t/J2);e.moveTo(n,0),e.arc(0,0,n,0,qE)}},uNe={draw(e,t){const n=Xc(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},yY=Xc(1/3),dNe=yY*2,hNe={draw(e,t){const n=Xc(t/dNe),r=n*yY;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},fNe={draw(e,t){const n=Xc(t),r=-n/2;e.rect(r,r,n,n)}},pNe=.8908130915292852,bY=Z2(J2/10)/Z2(7*J2/10),mNe=Z2(qE/10)*bY,gNe=-dY(qE/10)*bY,xNe={draw(e,t){const n=Xc(t*pNe),r=mNe*n,i=gNe*n;e.moveTo(0,-n),e.lineTo(r,i);for(let a=1;a<5;++a){const o=qE*a/5,c=dY(o),h=Z2(o);e.lineTo(h*n,-c*n),e.lineTo(c*r-h*i,h*r+c*i)}e.closePath()}},Z_=Xc(3),yNe={draw(e,t){const n=-Xc(t/(Z_*3));e.moveTo(0,n*2),e.lineTo(-Z_*n,-n),e.lineTo(Z_*n,-n),e.closePath()}},rc=-.5,ic=Xc(3)/2,Ej=1/Xc(12),bNe=(Ej/2+1)*3,vNe={draw(e,t){const n=Xc(t/bNe),r=n/2,i=n*Ej,a=r,o=n*Ej+n,c=-a,h=o;e.moveTo(r,i),e.lineTo(a,o),e.lineTo(c,h),e.lineTo(rc*r-ic*i,ic*r+rc*i),e.lineTo(rc*a-ic*o,ic*a+rc*o),e.lineTo(rc*c-ic*h,ic*c+rc*h),e.lineTo(rc*r+ic*i,rc*i-ic*r),e.lineTo(rc*a+ic*o,rc*o-ic*a),e.lineTo(rc*c+ic*h,rc*h-ic*c),e.closePath()}};function wNe(e,t){let n=null,r=O4(i);e=typeof e=="function"?e:ls(e||D4),t=typeof t=="function"?t:ls(t===void 0?64:+t);function i(){let a;if(n||(n=a=r()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(e=typeof a=="function"?a:ls(a),i):e},i.size=function(a){return arguments.length?(t=typeof a=="function"?a:ls(+a),i):t},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function eN(){}function tN(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function vY(e){this._context=e}vY.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:tN(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:tN(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function NNe(e){return new vY(e)}function wY(e){this._context=e}wY.prototype={areaStart:eN,areaEnd:eN,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:tN(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function ENe(e){return new wY(e)}function NY(e){this._context=e}NY.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:tN(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function ANe(e){return new NY(e)}function EY(e){this._context=e}EY.prototype={areaStart:eN,areaEnd:eN,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function _Ne(e){return new EY(e)}function UL(e){return e<0?-1:1}function BL(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),c=(a*i+o*r)/(r+i);return(UL(a)+UL(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(c))||0}function zL(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function J_(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,c=(a-r)/3;e._context.bezierCurveTo(r+c,i+c*t,a-c,o-c*n,a,o)}function nN(e){this._context=e}nN.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:J_(this,this._t0,zL(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,J_(this,zL(this,n=BL(this,e,t)),n);break;default:J_(this,this._t0,n=BL(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function AY(e){this._context=new _Y(e)}(AY.prototype=Object.create(nN.prototype)).point=function(e,t){nN.prototype.point.call(this,t,e)};function _Y(e){this._context=e}_Y.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function kNe(e){return new nN(e)}function SNe(e){return new AY(e)}function kY(e){this._context=e}kY.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=VL(e),i=VL(t),a=0,o=1;o=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function jNe(e){return new KE(e,.5)}function INe(e){return new KE(e,0)}function TNe(e){return new KE(e,1)}function cm(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,c=a.length;n=0;)n[t]=t;return n}function PNe(e,t){return e[t]}function ONe(e){const t=[];return t.key=e,t}function RNe(){var e=ls([]),t=Aj,n=cm,r=PNe;function i(a){var o=Array.from(e.apply(this,arguments),ONe),c,h=o.length,f=-1,m;for(const y of a)for(c=0,++f;c0){for(var n,r,i=0,a=e[0].length,o;i0){for(var n=0,r=e[t[0]],i,a=r.length;n0)||!((a=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,a,o;r1&&arguments[1]!==void 0?arguments[1]:FNe,n=10**t,r=Math.round(e*n)/n;return Object.is(r,-0)?0:r}function Ws(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{var c=n[o-1];return typeof c=="string"?i+c+a:c!==void 0?i+tf(c)+a:i+a},"")}var xl=e=>e===0?0:e>0?1:-1,Wc=e=>typeof e=="number"&&e!=+e,um=e=>typeof e=="string"&&e.indexOf("%")===e.length-1,_n=e=>(typeof e=="number"||e instanceof Number)&&!Wc(e),Hu=e=>_n(e)||typeof e=="string",$Ne=0,by=e=>{var t=++$Ne;return"".concat(e||"").concat(t)},Kc=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!_n(t)&&typeof t!="string")return r;var a;if(um(t)){if(n==null)return r;var o=t.indexOf("%");a=n*parseFloat(t.slice(0,o))/100}else a=+t;return Wc(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},CY=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;rr&&(typeof t=="function"?t(r):Sg(r,t))===n)}var ys=e=>e===null||typeof e>"u",ab=e=>ys(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function yl(e){return e!=null}function Tf(){}var HNe=["type","size","sizeType"];function _j(){return _j=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t="symbol".concat(ab(e));return IY[t]||D4},ZNe=(e,t,n)=>{if(t==="area")return e;switch(n){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var r=18*XNe;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},JNe=(e,t)=>{IY["symbol".concat(ab(e))]=t},B4=e=>{var{type:t="circle",size:n=64,sizeType:r="area"}=e,i=KNe(e,HNe),a=XL(XL({},i),{},{type:t,size:n,sizeType:r}),o="circle";typeof t=="string"&&(o=t);var c=()=>{var w=QNe(o),A=wNe().type(w).size(ZNe(n,r,o)),S=A();if(S!==null)return S},{className:h,cx:f,cy:m}=a,y=Co(a);return _n(f)&&_n(m)&&_n(n)?I.createElement("path",_j({},y,{className:Pi("recharts-symbols",h),transform:"translate(".concat(f,", ").concat(m,")"),d:c()})):null};B4.registerSymbol=JNe;var TY=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,z4=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var n=e;if(I.isValidElement(e)&&(n=e.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{T4(i)&&typeof n[i]=="function"&&(r[i]=(a=>n[i](n,a)))}),r},eEe=(e,t,n)=>r=>(e(t,n,r),null),YE=(e,t,n)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];T4(i)&&typeof a=="function"&&(r||(r={}),r[i]=eEe(a,t,n))}),r};function QL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function tEe(e){for(var t=1;t(o[c]===void 0&&r[c]!==void 0&&(o[c]=r[c]),o),n);return a}function rN(){return rN=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var A=y.formatter||i,S=Pi({"recharts-legend-item":!0,["legend-item-".concat(w)]:!0,inactive:y.inactive});if(y.type==="none")return null;var C=typeof c=="object"?PY({},c):{};C.color=y.inactive?a:C.color||y.color;var T=A?A(y.value,y,w):y.value;return I.createElement("li",rN({className:S,style:f,key:"legend-item-".concat(w)},YE(e,y,w)),I.createElement(P4,{width:n,height:n,viewBox:h,style:m,"aria-label":"".concat(y.value," legend icon")},I.createElement(uEe,{data:y,iconType:o,inactiveColor:a})),I.createElement("span",{className:"recharts-legend-item-text",style:C},T))})}var hEe=e=>{var t=Ha(e,lEe),{payload:n,layout:r,align:i}=t;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return I.createElement("ul",{className:"recharts-default-legend",style:a},I.createElement(dEe,rN({},t,{payload:n})))},ok={},lk={},JL;function fEe(){return JL||(JL=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r){const i=new Map;for(let a=0;a=0}e.isLength=t})(fk)),fk}var r7;function RY(){return r7||(r7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=mEe();function n(r){return r!=null&&typeof r!="function"&&t.isLength(r.length)}e.isArrayLike=n})(hk)),hk}var pk={},i7;function gEe(){return i7||(i7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return typeof n=="object"&&n!==null}e.isObjectLike=t})(pk)),pk}var s7;function xEe(){return s7||(s7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=RY(),n=gEe();function r(i){return n.isObjectLike(i)&&t.isArrayLike(i)}e.isArrayLikeObject=r})(dk)),dk}var mk={},gk={},a7;function yEe(){return a7||(a7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=U4();function n(r){return function(i){return t.get(i,r)}}e.property=n})(gk)),gk}var xk={},yk={},bk={},vk={},o7;function DY(){return o7||(o7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n!==null&&(typeof n=="object"||typeof n=="function")}e.isObject=t})(vk)),vk}var wk={},l7;function MY(){return l7||(l7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n==null||typeof n!="object"&&typeof n!="function"}e.isPrimitive=t})(wk)),wk}var Nk={},c7;function LY(){return c7||(c7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}e.isEqualsSameValueZero=t})(Nk)),Nk}var u7;function bEe(){return u7||(u7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=DY(),n=MY(),r=LY();function i(m,y,w){return typeof w!="function"?i(m,y,()=>{}):a(m,y,function A(S,C,T,D,V,L){const K=w(S,C,T,D,V,L);return K!==void 0?!!K:a(S,C,A,L)},new Map)}function a(m,y,w,A){if(y===m)return!0;switch(typeof y){case"object":return o(m,y,w,A);case"function":return Object.keys(y).length>0?a(m,{...y},w,A):r.isEqualsSameValueZero(m,y);default:return t.isObject(m)?typeof y=="string"?y==="":!0:r.isEqualsSameValueZero(m,y)}}function o(m,y,w,A){if(y==null)return!0;if(Array.isArray(y))return h(m,y,w,A);if(y instanceof Map)return c(m,y,w,A);if(y instanceof Set)return f(m,y,w,A);const S=Object.keys(y);if(m==null||n.isPrimitive(m))return S.length===0;if(S.length===0)return!0;if(A!=null&&A.has(y))return A.get(y)===m;A==null||A.set(y,m);try{for(let C=0;C{})}e.isMatch=n})(yk)),yk}var Ek={},Ak={},_k={},h7;function vEe(){return h7||(h7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return Object.getOwnPropertySymbols(n).filter(r=>Object.prototype.propertyIsEnumerable.call(n,r))}e.getSymbols=t})(_k)),_k}var kk={},f7;function V4(){return f7||(f7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}e.getTag=t})(kk)),kk}var Sk={},p7;function BY(){return p7||(p7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",o="[object Symbol]",c="[object Date]",h="[object Map]",f="[object Set]",m="[object Array]",y="[object Function]",w="[object ArrayBuffer]",A="[object Object]",S="[object Error]",C="[object DataView]",T="[object Uint8Array]",D="[object Uint8ClampedArray]",V="[object Uint16Array]",L="[object Uint32Array]",K="[object BigUint64Array]",Z="[object Int8Array]",q="[object Int16Array]",B="[object Int32Array]",z="[object BigInt64Array]",F="[object Float32Array]",$="[object Float64Array]";e.argumentsTag=a,e.arrayBufferTag=w,e.arrayTag=m,e.bigInt64ArrayTag=z,e.bigUint64ArrayTag=K,e.booleanTag=i,e.dataViewTag=C,e.dateTag=c,e.errorTag=S,e.float32ArrayTag=F,e.float64ArrayTag=$,e.functionTag=y,e.int16ArrayTag=q,e.int32ArrayTag=B,e.int8ArrayTag=Z,e.mapTag=h,e.numberTag=r,e.objectTag=A,e.regexpTag=t,e.setTag=f,e.stringTag=n,e.symbolTag=o,e.uint16ArrayTag=V,e.uint32ArrayTag=L,e.uint8ArrayTag=T,e.uint8ClampedArrayTag=D})(Sk)),Sk}var Ck={},m7;function wEe(){return m7||(m7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}e.isTypedArray=t})(Ck)),Ck}var g7;function zY(){return g7||(g7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=vEe(),n=V4(),r=BY(),i=MY(),a=wEe();function o(m,y){return c(m,void 0,m,new Map,y)}function c(m,y,w,A=new Map,S=void 0){const C=S==null?void 0:S(m,y,w,A);if(C!==void 0)return C;if(i.isPrimitive(m))return m;if(A.has(m))return A.get(m);if(Array.isArray(m)){const T=new Array(m.length);A.set(m,T);for(let D=0;Dt.isMatch(a,i)}e.matches=r})(xk)),xk}var jk={},Ik={},Tk={},b7;function AEe(){return b7||(b7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=zY(),n=V4(),r=BY();function i(a,o){return t.cloneDeepWith(a,(c,h,f,m)=>{const y=o==null?void 0:o(c,h,f,m);if(y!==void 0)return y;if(typeof a=="object"){if(n.getTag(a)===r.objectTag&&typeof a.constructor!="function"){const w={};return m.set(a,w),t.copyProperties(w,a,f,m),w}switch(Object.prototype.toString.call(a)){case r.numberTag:case r.stringTag:case r.booleanTag:{const w=new a.constructor(a==null?void 0:a.valueOf());return t.copyProperties(w,a),w}case r.argumentsTag:{const w={};return t.copyProperties(w,a),w.length=a.length,w[Symbol.iterator]=a[Symbol.iterator],w}default:return}}})}e.cloneDeepWith=i})(Tk)),Tk}var v7;function _Ee(){return v7||(v7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=AEe();function n(r){return t.cloneDeepWith(r)}e.cloneDeep=n})(Ik)),Ik}var Pk={},Ok={},w7;function VY(){return w7||(w7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=/^(?:0|[1-9]\d*)$/;function n(r,i=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Bk.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,Bk}var I7;function REe(){return I7||(I7=1,Uk.exports=OEe()),Uk.exports}/** * @license React * use-sync-external-store-shim/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 T7;function DEe(){if(T7)return Lk;T7=1;var e=Mg(),t=REe();function n(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,a=e.useRef,o=e.useEffect,c=e.useMemo,h=e.useDebugValue;return Lk.useSyncExternalStoreWithSelector=function(f,m,y,w,A){var S=a(null);if(S.current===null){var C={hasValue:!1,value:null};S.current=C}else C=S.current;S=c(function(){function D(q){if(!V){if(V=!0,L=q,q=w(q),A!==void 0&&C.hasValue){var B=C.value;if(A(B,q))return K=B}return K=q}if(B=K,r(L,q))return B;var z=w(q);return A!==void 0&&A(B,z)?(L=q,B):(L=q,K=z)}var V=!1,L,K,Z=y===void 0?null:y;return[function(){return D(m())},Z===null?void 0:function(){return D(Z())}]},[m,y,w,A]);var T=i(f,S[0],S[1]);return o(function(){C.hasValue=!0,C.value=T},[T]),h(T),T},Lk}var P7;function MEe(){return P7||(P7=1,Mk.exports=DEe()),Mk.exports}var LEe=MEe(),F4=I.createContext(null),UEe=e=>e,bs=()=>{var e=I.useContext(F4);return e?e.store.dispatch:UEe},Qw=()=>{},BEe=()=>Qw,zEe=(e,t)=>e===t;function Qn(e){var t=I.useContext(F4),n=I.useMemo(()=>t?r=>{if(r!=null)return e(r)}:Qw,[t,e]);return LEe.useSyncExternalStoreWithSelector(t?t.subscription.addNestedSub:BEe,t?t.store.getState:Qw,t?t.store.getState:Qw,n,zEe)}function VEe(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function FEe(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function $Ee(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var O7=e=>Array.isArray(e)?e:[e];function HEe(e){const t=Array.isArray(e[0])?e[0]:e;return $Ee(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function GEe(e,t){const n=[],{length:r}=e;for(let i=0;i{n=nw(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function YEe(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...i)=>{let a=0,o=0,c,h={},f=i.pop();typeof f=="object"&&(h=f,f=i.pop()),VEe(f,`createSelector expects an output function after the inputs, but received: [${typeof f}]`);const m={...n,...h},{memoize:y,memoizeOptions:w=[],argsMemoize:A=$Y,argsMemoizeOptions:S=[]}=m,C=O7(w),T=O7(S),D=HEe(i),V=y(function(){return a++,f.apply(null,arguments)},...C),L=A(function(){o++;const Z=GEe(D,arguments);return c=V.apply(null,Z),c},...T);return Object.assign(L,{resultFunc:f,memoizedResultFunc:V,dependencies:D,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>c,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:y,argsMemoize:A})};return Object.assign(r,{withTypes:()=>r}),r}var Ze=YEe($Y),XEe=Object.assign((e,t=Ze)=>{FEe(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),r=n.map(a=>e[a]);return t(r,(...a)=>a.reduce((o,c,h)=>(o[n[h]]=c,o),{}))},{withTypes:()=>XEe}),zk={},Vk={},Fk={},D7;function QEe(){return D7||(D7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,a)=>{if(r!==i){const o=t(r),c=t(i);if(o===c&&o===0){if(ri)return a==="desc"?-1:1}return a==="desc"?c-o:o-c}return 0};e.compareValues=n})(Fk)),Fk}var $k={},Hk={},M7;function HY(){return M7||(M7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return typeof n=="symbol"||n instanceof Symbol}e.isSymbol=t})(Hk)),Hk}var L7;function ZEe(){return L7||(L7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=HY(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,o){return Array.isArray(a)?!1:typeof a=="number"||typeof a=="boolean"||a==null||t.isSymbol(a)?!0:typeof a=="string"&&(r.test(a)||!n.test(a))||o!=null&&Object.hasOwn(o,a)}e.isKey=i})($k)),$k}var U7;function JEe(){return U7||(U7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=QEe(),n=ZEe(),r=L4();function i(a,o,c,h){if(a==null)return[];c=h?void 0:c,Array.isArray(a)||(a=Object.values(a)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(c)||(c=c==null?[]:[c]),c=c.map(A=>String(A));const f=(A,S)=>{let C=A;for(let T=0;TS==null||A==null?S:typeof A=="object"&&"key"in A?Object.hasOwn(S,A.key)?S[A.key]:f(S,A.path):typeof A=="function"?A(S):Array.isArray(A)?f(S,A):typeof S=="object"?S[A]:S,y=o.map(A=>(Array.isArray(A)&&A.length===1&&(A=A[0]),A==null||typeof A=="function"||Array.isArray(A)||n.isKey(A)?A:{key:A,path:r.toPath(A)}));return a.map(A=>({original:A,criteria:y.map(S=>m(S,A))})).slice().sort((A,S)=>{for(let C=0;CA.original)}e.orderBy=i})(Vk)),Vk}var Gk={},B7;function eAe(){return B7||(B7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r=1){const i=[],a=Math.floor(r),o=(c,h)=>{for(let f=0;f1&&r.isIterateeCall(a,o[0],o[1])?o=[]:c>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),t.orderBy(a,n.flatten(o),["asc"])}e.sortBy=i})(zk)),zk}var Wk,F7;function nAe(){return F7||(F7=1,Wk=tAe().sortBy),Wk}var rAe=nAe();const XE=Xu(rAe);var qY=e=>e.legend.settings,iAe=e=>e.legend.size,sAe=e=>e.legend.payload,aAe=Ze([sAe,qY],(e,t)=>{var{itemSorter:n}=t,r=e.flat(1);return n?XE(r,n):r});function oAe(){return Qn(aAe)}var rw=1;function WY(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[t,n]=I.useState({height:0,left:0,top:0,width:0}),r=I.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),o={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(o.height-t.height)>rw||Math.abs(o.left-t.left)>rw||Math.abs(o.top-t.top)>rw||Math.abs(o.width-t.width)>rw)&&n({height:o.height,left:o.left,top:o.top,width:o.width})}},[t.width,t.height,t.top,t.left,...e]);return[t,r]}function to(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var lAe=typeof Symbol=="function"&&Symbol.observable||"@@observable",$7=lAe,Kk=()=>Math.random().toString(36).substring(7).split("").join("."),cAe={INIT:`@@redux/INIT${Kk()}`,REPLACE:`@@redux/REPLACE${Kk()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Kk()}`},iN=cAe;function $4(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function KY(e,t,n){if(typeof e!="function")throw new Error(to(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(to(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(to(1));return n(KY)(e,t)}let r=e,i=t,a=new Map,o=a,c=0,h=!1;function f(){o===a&&(o=new Map,a.forEach((T,D)=>{o.set(D,T)}))}function m(){if(h)throw new Error(to(3));return i}function y(T){if(typeof T!="function")throw new Error(to(4));if(h)throw new Error(to(5));let D=!0;f();const V=c++;return o.set(V,T),function(){if(D){if(h)throw new Error(to(6));D=!1,f(),o.delete(V),a=null}}}function w(T){if(!$4(T))throw new Error(to(7));if(typeof T.type>"u")throw new Error(to(8));if(typeof T.type!="string")throw new Error(to(17));if(h)throw new Error(to(9));try{h=!0,i=r(i,T)}finally{h=!1}return(a=o).forEach(V=>{V()}),T}function A(T){if(typeof T!="function")throw new Error(to(10));r=T,w({type:iN.REPLACE})}function S(){const T=y;return{subscribe(D){if(typeof D!="object"||D===null)throw new Error(to(11));function V(){const K=D;K.next&&K.next(m())}return V(),{unsubscribe:T(V)}},[$7](){return this}}}return w({type:iN.INIT}),{dispatch:w,subscribe:y,getState:m,replaceReducer:A,[$7]:S}}function uAe(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:iN.INIT})>"u")throw new Error(to(12));if(typeof n(void 0,{type:iN.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(to(13))})}function YY(e){const t=Object.keys(e),n={};for(let a=0;a"u")throw c&&c.type,new Error(to(14));f[y]=S,h=h||S!==A}return h=h||r.length!==Object.keys(o).length,h?f:o}}function sN(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function dAe(...e){return t=>(n,r)=>{const i=t(n,r);let a=()=>{throw new Error(to(15))};const o={getState:i.getState,dispatch:(h,...f)=>a(h,...f)},c=e.map(h=>h(o));return a=sN(...c)(i.dispatch),{...i,dispatch:a}}}function XY(e){return $4(e)&&"type"in e&&typeof e.type=="string"}var QY=Symbol.for("immer-nothing"),H7=Symbol.for("immer-draftable"),Yo=Symbol.for("immer-state");function Bc(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Ll=Object,Cg=Ll.getPrototypeOf,aN="constructor",QE="prototype",kj="configurable",oN="enumerable",Zw="writable",vy="value",qd=e=>!!e&&!!e[Yo];function Yc(e){var t;return e?ZY(e)||JE(e)||!!e[H7]||!!((t=e[aN])!=null&&t[H7])||eA(e)||tA(e):!1}var hAe=Ll[QE][aN].toString(),G7=new WeakMap;function ZY(e){if(!e||!H4(e))return!1;const t=Cg(e);if(t===null||t===Ll[QE])return!0;const n=Ll.hasOwnProperty.call(t,aN)&&t[aN];if(n===Object)return!0;if(!R0(n))return!1;let r=G7.get(n);return r===void 0&&(r=Function.toString.call(n),G7.set(n,r)),r===hAe}function ZE(e,t,n=!0){ob(e)===0?(n?Reflect.ownKeys(e):Ll.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function ob(e){const t=e[Yo];return t?t.type_:JE(e)?1:eA(e)?2:tA(e)?3:0}var q7=(e,t,n=ob(e))=>n===2?e.has(t):Ll[QE].hasOwnProperty.call(e,t),Sj=(e,t,n=ob(e))=>n===2?e.get(t):e[t],lN=(e,t,n,r=ob(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function fAe(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var JE=Array.isArray,eA=e=>e instanceof Map,tA=e=>e instanceof Set,H4=e=>typeof e=="object",R0=e=>typeof e=="function",Yk=e=>typeof e=="boolean";function pAe(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Sd=e=>e.copy_||e.base_,G4=e=>e.modified_?e.copy_:e.base_;function Cj(e,t){if(eA(e))return new Map(e);if(tA(e))return new Set(e);if(JE(e))return Array[QE].slice.call(e);const n=ZY(e);if(t===!0||t==="class_only"&&!n){const r=Ll.getOwnPropertyDescriptors(e);delete r[Yo];let i=Reflect.ownKeys(r);for(let a=0;a1&&Ll.defineProperties(e,{set:iw,add:iw,clear:iw,delete:iw}),Ll.freeze(e),t&&ZE(e,(n,r)=>{q4(r,!0)},!1)),e}function mAe(){Bc(2)}var iw={[vy]:mAe};function nA(e){return e===null||!H4(e)?!0:Ll.isFrozen(e)}var cN="MapSet",jj="Patches",W7="ArrayMethods",JY={};function dm(e){const t=JY[e];return t||Bc(0,e),t}var K7=e=>!!JY[e],wy,eX=()=>wy,gAe=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:K7(cN)?dm(cN):void 0,arrayMethodsPlugin_:K7(W7)?dm(W7):void 0});function Y7(e,t){t&&(e.patchPlugin_=dm(jj),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ij(e){Tj(e),e.drafts_.forEach(xAe),e.drafts_=null}function Tj(e){e===wy&&(wy=e.parent_)}var X7=e=>wy=gAe(wy,e);function xAe(e){const t=e[Yo];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Q7(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[Yo].modified_&&(Ij(t),Bc(4)),Yc(e)&&(e=Z7(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[Yo].base_,e,t)}else e=Z7(t,n);return yAe(t,e,!0),Ij(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==QY?e:void 0}function Z7(e,t){if(nA(t))return t;const n=t[Yo];if(!n)return uN(t,e.handledSet_,e);if(!rA(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);rX(n,e)}return n.copy_}function yAe(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&q4(t,n)}function tX(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var rA=(e,t)=>e.scope_===t,bAe=[];function nX(e,t,n,r){const i=Sd(e),a=e.type_;if(r!==void 0&&Sj(i,r,a)===t){lN(i,r,n,a);return}if(!e.draftLocations_){const c=e.draftLocations_=new Map;ZE(i,(h,f)=>{if(qd(f)){const m=c.get(f)||[];m.push(h),c.set(f,m)}})}const o=e.draftLocations_.get(t)??bAe;for(const c of o)lN(i,c,n,a)}function vAe(e,t,n){e.callbacks_.push(function(i){var c;const a=t;if(!a||!rA(a,i))return;(c=i.mapSetPlugin_)==null||c.fixSetContents(a);const o=G4(a);nX(e,a.draft_??a,o,n),rX(a,i)})}function rX(e,t){var r;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((r=e.assigned_)==null?void 0:r.size)??0)>0)){const{patchPlugin_:i}=t;if(i){const a=i.getPath(e);a&&i.generatePatches_(e,a,t)}tX(e)}}function wAe(e,t,n){const{scope_:r}=e;if(qd(n)){const i=n[Yo];rA(i,r)&&i.callbacks_.push(function(){Jw(e);const o=G4(i);nX(e,n,o,t)})}else Yc(n)&&e.callbacks_.push(function(){const a=Sd(e);e.type_===3?a.has(n)&&uN(n,r.handledSet_,r):Sj(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&uN(Sj(e.copy_,t,e.type_),r.handledSet_,r)})}function uN(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||qd(e)||t.has(e)||!Yc(e)||nA(e)||(t.add(e),ZE(e,(r,i)=>{if(qd(i)){const a=i[Yo];if(rA(a,n)){const o=G4(a);lN(e,r,o,e.type_),tX(a)}}else Yc(i)&&uN(i,t,n)})),e}function NAe(e,t){const n=JE(e),r={type_:n?1:0,scope_:t?t.scope_:eX(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=dN;n&&(i=[r],a=Ny);const{revoke:o,proxy:c}=Proxy.revocable(i,a);return r.draft_=c,r.revoke_=o,[c,r]}var dN={get(e,t){if(t===Yo)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t=="string";if(r&&n!=null&&n.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Sd(e);if(!q7(i,t,e.type_))return EAe(e,i,t);const a=i[t];if(e.finalized_||!Yc(a)||r&&e.operationMethod&&(n!=null&&n.isMutatingArrayMethod(e.operationMethod))&&pAe(t))return a;if(a===Xk(e.base_,t)){Jw(e);const o=e.type_===1?+t:t,c=Oj(e.scope_,a,e,o);return e.copy_[o]=c}return a},has(e,t){return t in Sd(e)},ownKeys(e){return Reflect.ownKeys(Sd(e))},set(e,t,n){const r=iX(Sd(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Xk(Sd(e),t),a=i==null?void 0:i[Yo];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(fAe(n,i)&&(n!==void 0||q7(e.base_,t,e.type_)))return!0;Jw(e),Pj(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),wAe(e,t,n)),!0},deleteProperty(e,t){return Jw(e),Xk(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Pj(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Sd(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Zw]:!0,[kj]:e.type_!==1||t!=="length",[oN]:r[oN],[vy]:n[t]}},defineProperty(){Bc(11)},getPrototypeOf(e){return Cg(e.base_)},setPrototypeOf(){Bc(12)}},Ny={};for(let e in dN){let t=dN[e];Ny[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Ny.deleteProperty=function(e,t){return Ny.set.call(this,e,t,void 0)};Ny.set=function(e,t,n){return dN.set.call(this,e[0],t,n,e[0])};function Xk(e,t){const n=e[Yo];return(n?Sd(n):e)[t]}function EAe(e,t,n){var i;const r=iX(t,n);return r?vy in r?r[vy]:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function iX(e,t){if(!(t in e))return;let n=Cg(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Cg(n)}}function Pj(e){e.modified_||(e.modified_=!0,e.parent_&&Pj(e.parent_))}function Jw(e){e.copy_||(e.assigned_=new Map,e.copy_=Cj(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var AAe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(R0(n)&&!R0(r)){const o=r;r=n;const c=this;return function(f=o,...m){return c.produce(f,y=>r.call(this,y,...m))}}R0(r)||Bc(6),i!==void 0&&!R0(i)&&Bc(7);let a;if(Yc(n)){const o=X7(this),c=Oj(o,n,void 0);let h=!0;try{a=r(c),h=!1}finally{h?Ij(o):Tj(o)}return Y7(o,i),Q7(a,o)}else if(!n||!H4(n)){if(a=r(n),a===void 0&&(a=n),a===QY&&(a=void 0),this.autoFreeze_&&q4(a,!0),i){const o=[],c=[];dm(jj).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:c}),i(o,c)}return a}else Bc(1,n)},this.produceWithPatches=(n,r)=>{if(R0(n))return(c,...h)=>this.produceWithPatches(c,f=>n(f,...h));let i,a;return[this.produce(n,r,(c,h)=>{i=c,a=h}),i,a]},Yk(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),Yk(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),Yk(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Yc(t)||Bc(8),qd(t)&&(t=fc(t));const n=X7(this),r=Oj(n,t,void 0);return r[Yo].isManual_=!0,Tj(n),r}finishDraft(t,n){const r=t&&t[Yo];(!r||!r.isManual_)&&Bc(9);const{scope_:i}=r;return Y7(i,n),Q7(void 0,i)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){t=a.value;break}}r>-1&&(n=n.slice(r+1));const i=dm(jj).applyPatches_;return qd(t)?i(t,n):this.produce(t,a=>i(a,n))}};function Oj(e,t,n,r){const[i,a]=eA(t)?dm(cN).proxyMap_(t,n):tA(t)?dm(cN).proxySet_(t,n):NAe(t,n);return((n==null?void 0:n.scope_)??eX()).drafts_.push(i),a.callbacks_=(n==null?void 0:n.callbacks_)??[],a.key_=r,n&&r!==void 0?vAe(n,a,r):a.callbacks_.push(function(h){var m;(m=h.mapSetPlugin_)==null||m.fixSetContents(a);const{patchPlugin_:f}=h;a.modified_&&f&&f.generatePatches_(a,[],h)}),i}function fc(e){return qd(e)||Bc(10,e),sX(e)}function sX(e){if(!Yc(e)||nA(e))return e;const t=e[Yo];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Cj(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Cj(e,!0);return ZE(n,(i,a)=>{lN(n,i,sX(a))},r),t&&(t.finalized_=!1),n}var _Ae=new AAe,aX=_Ae.produce;function oX(e){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,e):i(a)}var kAe=oX(),SAe=oX,CAe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?sN:sN.apply(null,arguments)};function $l(e,t){function n(...r){if(t){let i=t(...r);if(!i)throw new Error(zl(0));return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>XY(r)&&r.type===e,n}var lX=class k1 extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,k1.prototype)}static get[Symbol.species](){return k1}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new k1(...t[0].concat(this)):new k1(...t.concat(this))}};function J7(e){return Yc(e)?aX(e,()=>{}):e}function sw(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function jAe(e){return typeof e=="boolean"}var IAe=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=t??{};let o=new lX;return n&&(jAe(n)?o.push(kAe):o.push(SAe(n.extraArgument))),o},cX="RTK_autoBatch",ms=()=>e=>({payload:e,meta:{[cX]:!0}}),eU=e=>t=>{setTimeout(t,e)},uX=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let i=!0,a=!1,o=!1;const c=new Set,h=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:eU(10):e.type==="callback"?e.queueNotification:eU(e.timeout),f=()=>{o=!1,a&&(a=!1,c.forEach(m=>m()))};return Object.assign({},r,{subscribe(m){const y=()=>i&&m(),w=r.subscribe(y);return c.add(m),()=>{w(),c.delete(m)}},dispatch(m){var y;try{return i=!((y=m==null?void 0:m.meta)!=null&&y[cX]),a=!i,a&&(o||(o=!0,h(f))),r.dispatch(m)}finally{i=!0}}})},TAe=e=>function(n){const{autoBatch:r=!0}=n??{};let i=new lX(e);return r&&i.push(uX(typeof r=="object"?r:void 0)),i};function PAe(e){const t=IAe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:o=void 0}=e||{};let c;if(typeof n=="function")c=n;else if($4(n))c=YY(n);else throw new Error(zl(1));let h;typeof r=="function"?h=r(t):h=t();let f=sN;i&&(f=CAe({trace:!1,...typeof i=="object"&&i}));const m=dAe(...h),y=TAe(m);let w=typeof o=="function"?o(y):y();const A=f(...w);return KY(c,a,A)}function dX(e){const t={},n=[];let r;const i={addCase(a,o){const c=typeof a=="string"?a:a.type;if(!c)throw new Error(zl(28));if(c in t)throw new Error(zl(29));return t[c]=o,i},addAsyncThunk(a,o){return o.pending&&(t[a.pending.type]=o.pending),o.rejected&&(t[a.rejected.type]=o.rejected),o.fulfilled&&(t[a.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:a.settled,reducer:o.settled}),i},addMatcher(a,o){return n.push({matcher:a,reducer:o}),i},addDefaultCase(a){return r=a,i}};return e(i),[t,n,r]}function OAe(e){return typeof e=="function"}function RAe(e,t){let[n,r,i]=dX(t),a;if(OAe(e))a=()=>J7(e());else{const c=J7(e);a=()=>c}function o(c=a(),h){let f=[n[h.type],...r.filter(({matcher:m})=>m(h)).map(({reducer:m})=>m)];return f.filter(m=>!!m).length===0&&(f=[i]),f.reduce((m,y)=>{if(y)if(qd(m)){const A=y(m,h);return A===void 0?m:A}else{if(Yc(m))return aX(m,w=>y(w,h));{const w=y(m,h);if(w===void 0){if(m===null)return m;throw Error("A case reducer on a non-draftable value must not return undefined")}return w}}return m},c)}return o.getInitialState=a,o}var DAe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",MAe=(e=21)=>{let t="",n=e;for(;n--;)t+=DAe[Math.random()*64|0];return t},LAe=Symbol.for("rtk-slice-createasyncthunk");function UAe(e,t){return`${e}/${t}`}function BAe({creators:e}={}){var n;const t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[LAe];return function(i){const{name:a,reducerPath:o=a}=i;if(!a)throw new Error(zl(11));const c=(typeof i.reducers=="function"?i.reducers(VAe()):i.reducers)||{},h=Object.keys(c),f={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},m={addCase(K,Z){const q=typeof K=="string"?K:K.type;if(!q)throw new Error(zl(12));if(q in f.sliceCaseReducersByType)throw new Error(zl(13));return f.sliceCaseReducersByType[q]=Z,m},addMatcher(K,Z){return f.sliceMatchers.push({matcher:K,reducer:Z}),m},exposeAction(K,Z){return f.actionCreators[K]=Z,m},exposeCaseReducer(K,Z){return f.sliceCaseReducersByName[K]=Z,m}};h.forEach(K=>{const Z=c[K],q={reducerName:K,type:UAe(a,K),createNotation:typeof i.reducers=="function"};$Ae(Z)?GAe(q,Z,m,t):FAe(q,Z,m)});function y(){const[K={},Z=[],q=void 0]=typeof i.extraReducers=="function"?dX(i.extraReducers):[i.extraReducers],B={...K,...f.sliceCaseReducersByType};return RAe(i.initialState,z=>{for(let F in B)z.addCase(F,B[F]);for(let F of f.sliceMatchers)z.addMatcher(F.matcher,F.reducer);for(let F of Z)z.addMatcher(F.matcher,F.reducer);q&&z.addDefaultCase(q)})}const w=K=>K,A=new Map,S=new WeakMap;let C;function T(K,Z){return C||(C=y()),C(K,Z)}function D(){return C||(C=y()),C.getInitialState()}function V(K,Z=!1){function q(z){let F=z[K];return typeof F>"u"&&Z&&(F=sw(S,q,D)),F}function B(z=w){const F=sw(A,Z,()=>new WeakMap);return sw(F,z,()=>{const $={};for(const[Y,X]of Object.entries(i.selectors??{}))$[Y]=zAe(X,z,()=>sw(S,z,D),Z);return $})}return{reducerPath:K,getSelectors:B,get selectors(){return B(q)},selectSlice:q}}const L={name:a,reducer:T,actions:f.actionCreators,caseReducers:f.sliceCaseReducersByName,getInitialState:D,...V(o),injectInto(K,{reducerPath:Z,...q}={}){const B=Z??o;return K.inject({reducerPath:B,reducer:T},q),{...L,...V(B,!0)}}};return L}}function zAe(e,t,n,r){function i(a,...o){let c=t(a);return typeof c>"u"&&r&&(c=n()),e(c,...o)}return i.unwrapped=e,i}var Io=BAe();function VAe(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function FAe({type:e,reducerName:t,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!HAe(r))throw new Error(zl(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,o?$l(e,o):$l(e))}function $Ae(e){return e._reducerDefinitionType==="asyncThunk"}function HAe(e){return e._reducerDefinitionType==="reducerWithPrepare"}function GAe({type:e,reducerName:t},n,r,i){if(!i)throw new Error(zl(18));const{payloadCreator:a,fulfilled:o,pending:c,rejected:h,settled:f,options:m}=n,y=i(e,a,m);r.exposeAction(t,y),o&&r.addCase(y.fulfilled,o),c&&r.addCase(y.pending,c),h&&r.addCase(y.rejected,h),f&&r.addMatcher(y.settled,f),r.exposeCaseReducer(t,{fulfilled:o||aw,pending:c||aw,rejected:h||aw,settled:f||aw})}function aw(){}var qAe="task",hX="listener",fX="completed",W4="cancelled",WAe=`task-${W4}`,KAe=`task-${fX}`,Rj=`${hX}-${W4}`,YAe=`${hX}-${fX}`,iA=class{constructor(e){wd(this,"name","TaskAbortError");wd(this,"message");this.code=e,this.message=`${qAe} ${W4} (reason: ${e})`}},K4=(e,t)=>{if(typeof e!="function")throw new TypeError(zl(32))},hN=()=>{},pX=(e,t=hN)=>(e.catch(t),e),mX=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),Fp=e=>{if(e.aborted)throw new iA(e.reason)};function gX(e,t){let n=hN;return new Promise((r,i)=>{const a=()=>i(new iA(e.reason));if(e.aborted){a();return}n=mX(e,a),t.finally(()=>n()).then(r,i)}).finally(()=>{n=hN})}var XAe=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(n){return{status:n instanceof iA?"cancelled":"rejected",error:n}}finally{t==null||t()}},fN=e=>t=>pX(gX(e,t).then(n=>(Fp(e),n))),xX=e=>{const t=fN(e);return n=>t(new Promise(r=>setTimeout(r,n)))},{assign:eg}=Object,tU={},sA="listenerMiddleware",QAe=(e,t)=>{const n=r=>mX(e,()=>r.abort(e.reason));return(r,i)=>{K4(r);const a=new AbortController;n(a);const o=XAe(async()=>{Fp(e),Fp(a.signal);const c=await r({pause:fN(a.signal),delay:xX(a.signal),signal:a.signal});return Fp(a.signal),c},()=>a.abort(KAe));return i!=null&&i.autoJoin&&t.push(o.catch(hN)),{result:fN(e)(o),cancel(){a.abort(WAe)}}}},ZAe=(e,t)=>{const n=async(r,i)=>{Fp(t);let a=()=>{};const c=[new Promise((h,f)=>{let m=e({predicate:r,effect:(y,w)=>{w.unsubscribe(),h([y,w.getState(),w.getOriginalState()])}});a=()=>{m(),f()}})];i!=null&&c.push(new Promise(h=>setTimeout(h,i,null)));try{const h=await gX(t,Promise.race(c));return Fp(t),h}finally{a()}};return(r,i)=>pX(n(r,i))},yX=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:a}=e;if(t)i=$l(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(zl(21));return K4(a),{predicate:i,type:t,effect:a}},bX=eg(e=>{const{type:t,predicate:n,effect:r}=yX(e);return{id:MAe(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(zl(22))}}},{withTypes:()=>bX}),nU=(e,t)=>{const{type:n,effect:r,predicate:i}=yX(t);return Array.from(e.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},Dj=e=>{e.pending.forEach(t=>{t.abort(Rj)})},JAe=(e,t)=>()=>{for(const n of t.keys())Dj(n);e.clear()},rU=(e,t,n)=>{try{e(t,n)}catch(r){setTimeout(()=>{throw r},0)}},vX=eg($l(`${sA}/add`),{withTypes:()=>vX}),e5e=$l(`${sA}/removeAll`),wX=eg($l(`${sA}/remove`),{withTypes:()=>wX}),t5e=(...e)=>{console.error(`${sA}/error`,...e)},lb=(e={})=>{const t=new Map,n=new Map,r=A=>{const S=n.get(A)??0;n.set(A,S+1)},i=A=>{const S=n.get(A)??1;S===1?n.delete(A):n.set(A,S-1)},{extra:a,onError:o=t5e}=e;K4(o);const c=A=>(A.unsubscribe=()=>t.delete(A.id),t.set(A.id,A),S=>{A.unsubscribe(),S!=null&&S.cancelActive&&Dj(A)}),h=A=>{const S=nU(t,A)??bX(A);return c(S)};eg(h,{withTypes:()=>h});const f=A=>{const S=nU(t,A);return S&&(S.unsubscribe(),A.cancelActive&&Dj(S)),!!S};eg(f,{withTypes:()=>f});const m=async(A,S,C,T)=>{const D=new AbortController,V=ZAe(h,D.signal),L=[];try{A.pending.add(D),r(A),await Promise.resolve(A.effect(S,eg({},C,{getOriginalState:T,condition:(K,Z)=>V(K,Z).then(Boolean),take:V,delay:xX(D.signal),pause:fN(D.signal),extra:a,signal:D.signal,fork:QAe(D.signal,L),unsubscribe:A.unsubscribe,subscribe:()=>{t.set(A.id,A)},cancelActiveListeners:()=>{A.pending.forEach((K,Z,q)=>{K!==D&&(K.abort(Rj),q.delete(K))})},cancel:()=>{D.abort(Rj),A.pending.delete(D)},throwIfCancelled:()=>{Fp(D.signal)}})))}catch(K){K instanceof iA||rU(o,K,{raisedBy:"effect"})}finally{await Promise.all(L),D.abort(YAe),i(A),A.pending.delete(D)}},y=JAe(t,n);return{middleware:A=>S=>C=>{if(!XY(C))return S(C);if(vX.match(C))return h(C.payload);if(e5e.match(C)){y();return}if(wX.match(C))return f(C.payload);let T=A.getState();const D=()=>{if(T===tU)throw new Error(zl(23));return T};let V;try{if(V=S(C),t.size>0){const L=A.getState(),K=Array.from(t.values());for(const Z of K){let q=!1;try{q=Z.predicate(C,L,T)}catch(B){q=!1,rU(o,B,{raisedBy:"predicate"})}q&&m(Z,C,A,D)}}}finally{T=tU}return V},startListening:h,stopListening:f,clearListeners:y}};function zl(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var n5e={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},NX=Io({name:"chartLayout",initialState:n5e,reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){var n,r,i,a;e.margin.top=(n=t.payload.top)!==null&&n!==void 0?n:0,e.margin.right=(r=t.payload.right)!==null&&r!==void 0?r:0,e.margin.bottom=(i=t.payload.bottom)!==null&&i!==void 0?i:0,e.margin.left=(a=t.payload.left)!==null&&a!==void 0?a:0},setScale(e,t){e.scale=t.payload}}}),{setMargin:r5e,setLayout:i5e,setChartSize:s5e,setScale:a5e}=NX.actions,o5e=NX.reducer;function EX(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function Yr(e){return Number.isFinite(e)}function Gu(e){return typeof e=="number"&&e>0&&Number.isFinite(e)}function iU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function V0(e){for(var t=1;t{if(t&&n){var{width:r,height:i}=n,{align:a,verticalAlign:o,layout:c}=t;if((c==="vertical"||c==="horizontal"&&o==="middle")&&a!=="center"&&_n(e[a]))return V0(V0({},e),{},{[a]:e[a]+(r||0)});if((c==="horizontal"||c==="vertical"&&a==="center")&&o!=="middle"&&_n(e[o]))return V0(V0({},e),{},{[o]:e[o]+(i||0)})}return e},Qc=(e,t)=>e==="horizontal"&&t==="xAxis"||e==="vertical"&&t==="yAxis"||e==="centric"&&t==="angleAxis"||e==="radial"&&t==="radiusAxis",AX=(e,t,n,r)=>{if(r)return e.map(c=>c.coordinate);var i,a,o=e.map(c=>(c.coordinate===t&&(i=!0),c.coordinate===n&&(a=!0),c.coordinate));return i||o.push(t),a||o.push(n),o},_X=(e,t,n)=>{if(!e)return null;var{duplicateDomain:r,type:i,range:a,scale:o,realScaleType:c,isCategorical:h,categoricalDomain:f,tickCount:m,ticks:y,niceTicks:w,axisType:A}=e;if(!o)return null;var S=c==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,C=i==="category"&&o.bandwidth?o.bandwidth()/S:0;if(C=A==="angleAxis"&&a&&a.length>=2?xl(a[0]-a[1])*2*C:C,y||w){var T=(y||w||[]).map((D,V)=>{var L=r?r.indexOf(D):D,K=o.map(L);return Yr(K)?{coordinate:K+C,value:D,offset:C,index:V}:null}).filter(yl);return T}return h&&f?f.map((D,V)=>{var L=o.map(D);return Yr(L)?{coordinate:L+C,value:D,index:V,offset:C}:null}).filter(yl):o.ticks&&m!=null?o.ticks(m).map((D,V)=>{var L=o.map(D);return Yr(L)?{coordinate:L+C,value:D,index:V,offset:C}:null}).filter(yl):o.domain().map((D,V)=>{var L=o.map(D);return Yr(L)?{coordinate:L+C,value:r?r[D]:D,index:V,offset:C}:null}).filter(yl)},h5e=(e,t)=>{if(!t||t.length!==2||!_n(t[0])||!_n(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),i=[e[0],e[1]];return(!_n(e[0])||e[0]r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]{var t,n=e.length;if(!(n<=0)){var r=(t=e[0])===null||t===void 0?void 0:t.length;if(!(r==null||r<=0))for(var i=0;i=0?(f[0]=a,a+=w,f[1]=a):(f[0]=o,o+=w,f[1]=o)}}}},p5e=e=>{var t,n=e.length;if(!(n<=0)){var r=(t=e[0])===null||t===void 0?void 0:t.length;if(!(r==null||r<=0))for(var i=0;i=0?(h[0]=a,a+=f,h[1]=a):(h[0]=0,h[1]=0)}}}},m5e={sign:f5e,expand:DNe,none:cm,silhouette:MNe,wiggle:LNe,positive:p5e},g5e=(e,t,n)=>{var r,i=(r=m5e[n])!==null&&r!==void 0?r:cm,a=RNe().keys(t).value((c,h)=>Number(Us(c,h,0))).order(Aj).offset(i),o=a(e);return o.forEach((c,h)=>{c.forEach((f,m)=>{var y=Us(e[m],t[h],0);Array.isArray(y)&&y.length===2&&_n(y[0])&&_n(y[1])&&(f[0]=y[0],f[1]=y[1])})}),o};function kX(e){return e==null?void 0:String(e)}function pN(e){var{axis:t,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=e;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!ys(i[t.dataKey])){var c=jY(n,"value",i[t.dataKey]);if(c)return c.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var h=Us(i,ys(o)?t.dataKey:o),f=t.scale.map(h);return _n(f)?f:null}var sU=e=>{var{axis:t,ticks:n,offset:r,bandSize:i,entry:a,index:o}=e;if(t.type==="category")return n[o]?n[o].coordinate+r:null;var c=Us(a,t.dataKey,t.scale.domain()[o]);if(ys(c))return null;var h=t.scale.map(c);return _n(h)?h-i/2+r:null},x5e=e=>{var{numericAxis:t}=e,n=t.scale.domain();if(t.type==="number"){var r=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return r<=0&&i>=0?0:i<0?i:r}return n[0]},y5e=e=>{var t=e.flat(2).filter(_n);return[Math.min(...t),Math.max(...t)]},b5e=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],v5e=(e,t,n)=>{if(e!=null)return b5e(Object.keys(e).reduce((r,i)=>{var a=e[i];if(!a)return r;var{stackedData:o}=a,c=o.reduce((h,f)=>{var m=EX(f,t,n),y=y5e(m);return!Yr(y[0])||!Yr(y[1])?h:[Math.min(h[0],y[0]),Math.max(h[1],y[1])]},[1/0,-1/0]);return[Math.min(c[0],r[0]),Math.max(c[1],r[1])]},[1/0,-1/0]))},aU=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,oU=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,bf=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=XE(t,m=>m.coordinate),a=1/0,o=1,c=i.length;o{if(t==="horizontal")return e.relativeX;if(t==="vertical")return e.relativeY},N5e=(e,t)=>t==="centric"?e.angle:e.radius,eh=e=>e.layout.width,th=e=>e.layout.height,E5e=e=>e.layout.scale,SX=e=>e.layout.margin,aA=Ze(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),oA=Ze(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),A5e="data-recharts-item-index",_5e="data-recharts-item-id",cb=60;function cU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function ow(e){for(var t=1;te.brush.height;function I5e(e){var t=oA(e);return t.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:cb;return n+i}return n},0)}function T5e(e){var t=oA(e);return t.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:cb;return n+i}return n},0)}function P5e(e){var t=aA(e);return t.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function O5e(e){var t=aA(e);return t.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var Ga=Ze([eh,th,SX,j5e,I5e,T5e,P5e,O5e,qY,iAe],(e,t,n,r,i,a,o,c,h,f)=>{var m={left:(n.left||0)+i,right:(n.right||0)+a},y={top:(n.top||0)+o,bottom:(n.bottom||0)+c},w=ow(ow({},y),m),A=w.bottom;w.bottom+=r,w=d5e(w,h,f);var S=e-w.left-w.right,C=t-w.top-w.bottom;return ow(ow({brushBottom:A},w),{},{width:Math.max(S,0),height:Math.max(C,0)})}),R5e=Ze(Ga,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),Y4=Ze(eh,th,(e,t)=>({x:0,y:0,width:e,height:t})),D5e=I.createContext(null),qa=()=>I.useContext(D5e)!=null,lA=e=>e.brush,cA=Ze([lA,Ga,SX],(e,t,n)=>({height:e.height,x:_n(e.x)?e.x:t.left,y:_n(e.y)?e.y:t.top+t.height+t.brushBottom-((n==null?void 0:n.bottom)||0),width:_n(e.width)?e.width:t.width})),Qk={},Zk={},Jk={},uU;function M5e(){return uU||(uU=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r,{signal:i,edges:a}={}){let o,c=null;const h=a!=null&&a.includes("leading"),f=a==null||a.includes("trailing"),m=()=>{c!==null&&(n.apply(o,c),o=void 0,c=null)},y=()=>{f&&m(),C()};let w=null;const A=()=>{w!=null&&clearTimeout(w),w=setTimeout(()=>{w=null,y()},r)},S=()=>{w!==null&&(clearTimeout(w),w=null)},C=()=>{S(),o=void 0,c=null},T=()=>{m()},D=function(...V){if(i!=null&&i.aborted)return;o=this,c=V;const L=w==null;A(),h&&L&&m()};return D.schedule=A,D.cancel=C,D.flush=T,i==null||i.addEventListener("abort",C,{once:!0}),D}e.debounce=t})(Jk)),Jk}var dU;function L5e(){return dU||(dU=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=M5e();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:o=!1,trailing:c=!0,maxWait:h}=a,f=Array(2);o&&(f[0]="leading"),c&&(f[1]="trailing");let m,y=null;const w=t.debounce(function(...C){m=r.apply(this,C),y=null},i,{edges:f}),A=function(...C){return h!=null&&(y===null&&(y=Date.now()),Date.now()-y>=h)?(m=r.apply(this,C),y=Date.now(),w.cancel(),w.schedule(),m):(w.apply(this,C),m)},S=()=>(w.flush(),m);return A.cancel=w.cancel,A.flush=S,A}e.debounce=n})(Zk)),Zk}var hU;function U5e(){return hU||(hU=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=L5e();function n(r,i=0,a={}){const{leading:o=!0,trailing:c=!0}=a;return t.debounce(r,i,{leading:o,maxWait:i,trailing:c})}e.throttle=n})(Qk)),Qk}var eS,fU;function B5e(){return fU||(fU=1,eS=U5e().throttle),eS}var z5e=B5e();const V5e=Xu(z5e);var mN=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;ai[o++]))}},Tu={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},CX=(e,t,n)=>{var{width:r=Tu.width,height:i=Tu.height,aspect:a,maxHeight:o}=n,c=um(r)?e:Number(r),h=um(i)?t:Number(i);return a&&a>0&&(c?h=c/a:h&&(c=h*a),o&&h!=null&&h>o&&(h=o)),{calculatedWidth:c,calculatedHeight:h}},F5e={width:0,height:0,overflow:"visible"},$5e={width:0,overflowX:"visible"},H5e={height:0,overflowY:"visible"},G5e={},q5e=e=>{var{width:t,height:n}=e,r=um(t),i=um(n);return r&&i?F5e:r?$5e:i?H5e:G5e};function W5e(e){var{width:t,height:n,aspect:r}=e,i=t,a=n;return i===void 0&&a===void 0?(i=Tu.width,a=Tu.height):i===void 0?i=r&&r>0?void 0:Tu.width:a===void 0&&(a=r&&r>0?void 0:Tu.height),{width:i,height:a}}function Mj(){return Mj=Object.assign?Object.assign.bind():function(e){for(var t=1;t({width:n,height:r}),[n,r]);return Q5e(i)?I.createElement(jX.Provider,{value:i},t):null}var X4=()=>I.useContext(jX),Z5e=I.forwardRef((e,t)=>{var{aspect:n,initialDimension:r=Tu.initialDimension,width:i,height:a,minWidth:o=Tu.minWidth,minHeight:c,maxHeight:h,children:f,debounce:m=Tu.debounce,id:y,className:w,onResize:A,style:S={}}=e,C=I.useRef(null),T=I.useRef();T.current=A,I.useImperativeHandle(t,()=>C.current);var[D,V]=I.useState({containerWidth:r.width,containerHeight:r.height}),L=I.useCallback((z,F)=>{V($=>{var Y=Math.round(z),X=Math.round(F);return $.containerWidth===Y&&$.containerHeight===X?$:{containerWidth:Y,containerHeight:X}})},[]);I.useEffect(()=>{if(C.current==null||typeof ResizeObserver>"u")return Tf;var z=X=>{var J,ye=X[0];if(ye!=null){var{width:ne,height:de}=ye.contentRect;L(ne,de),(J=T.current)===null||J===void 0||J.call(T,ne,de)}};m>0&&(z=V5e(z,m,{trailing:!0,leading:!1}));var F=new ResizeObserver(z),{width:$,height:Y}=C.current.getBoundingClientRect();return L($,Y),F.observe(C.current),()=>{F.disconnect()}},[L,m]);var{containerWidth:K,containerHeight:Z}=D;mN(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:q,calculatedHeight:B}=CX(K,Z,{width:i,height:a,aspect:n,maxHeight:h});return mN(q!=null&&q>0||B!=null&&B>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the height and width.`,q,B,i,a,o,c,n),I.createElement("div",{id:y?"".concat(y):void 0,className:Pi("recharts-responsive-container",w),style:mU(mU({},S),{},{width:i,height:a,minWidth:o,minHeight:c,maxHeight:h}),ref:C},I.createElement("div",{style:q5e({width:i,height:a})},I.createElement(IX,{width:q,height:B},f)))}),J5e=I.forwardRef((e,t)=>{var n=X4();if(Gu(n.width)&&Gu(n.height))return e.children;var{width:r,height:i}=W5e({width:e.width,height:e.height,aspect:e.aspect}),{calculatedWidth:a,calculatedHeight:o}=CX(void 0,void 0,{width:r,height:i,aspect:e.aspect,maxHeight:e.maxHeight});return _n(a)&&_n(o)?I.createElement(IX,{width:a,height:o},e.children):I.createElement(Z5e,Mj({},e,{width:r,height:i,ref:t}))});function Q4(e){if(e)return{x:e.x,y:e.y,upperWidth:"upperWidth"in e?e.upperWidth:e.width,lowerWidth:"lowerWidth"in e?e.lowerWidth:e.width,width:e.width,height:e.height}}var uA=()=>{var e,t=qa(),n=Qn(R5e),r=Qn(cA),i=(e=Qn(lA))===null||e===void 0?void 0:e.padding;return!t||!r||!i?n:{width:r.width-i.left-i.right,height:r.height-i.top-i.bottom,x:i.left,y:i.top}},e_e={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},TX=()=>{var e;return(e=Qn(Ga))!==null&&e!==void 0?e:e_e},Z4=()=>Qn(eh),J4=()=>Qn(th),t_e=()=>Qn(e=>e.layout.margin),Ci=e=>e.layout.layoutType,Pf=()=>Qn(Ci),e3=()=>{var e=Pf();if(e==="horizontal"||e==="vertical")return e},PX=e=>{var t=e.layout.layoutType;if(t==="centric"||t==="radial")return t},n_e=()=>{var e=Pf();return e!==void 0},ub=e=>{var t=bs(),n=qa(),{width:r,height:i}=e,a=X4(),o=r,c=i;return a&&(o=a.width>0?a.width:r,c=a.height>0?a.height:i),I.useEffect(()=>{!n&&Gu(o)&&Gu(c)&&t(s5e({width:o,height:c}))},[t,n,o,c]),null},OX=Symbol.for("immer-nothing"),gU=Symbol.for("immer-draftable"),Hl=Symbol.for("immer-state");function zc(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Ey=Object.getPrototypeOf;function jg(e){return!!e&&!!e[Hl]}function hm(e){var t;return e?RX(e)||Array.isArray(e)||!!e[gU]||!!((t=e.constructor)!=null&&t[gU])||db(e)||hA(e):!1}var r_e=Object.prototype.constructor.toString(),xU=new WeakMap;function RX(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=xU.get(n);return r===void 0&&(r=Function.toString.call(n),xU.set(n,r)),r===r_e}function gN(e,t,n=!0){dA(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function dA(e){const t=e[Hl];return t?t.type_:Array.isArray(e)?1:db(e)?2:hA(e)?3:0}function Lj(e,t){return dA(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function DX(e,t,n){const r=dA(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function i_e(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function db(e){return e instanceof Map}function hA(e){return e instanceof Set}function pp(e){return e.copy_||e.base_}function Uj(e,t){if(db(e))return new Map(e);if(hA(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=RX(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[Hl];let i=Reflect.ownKeys(r);for(let a=0;a1&&Object.defineProperties(e,{set:lw,add:lw,clear:lw,delete:lw}),Object.freeze(e),t&&Object.values(e).forEach(n=>t3(n,!0))),e}function s_e(){zc(2)}var lw={value:s_e};function fA(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var a_e={};function fm(e){const t=a_e[e];return t||zc(0,e),t}var Ay;function MX(){return Ay}function o_e(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function yU(e,t){t&&(fm("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Bj(e){zj(e),e.drafts_.forEach(l_e),e.drafts_=null}function zj(e){e===Ay&&(Ay=e.parent_)}function bU(e){return Ay=o_e(Ay,e)}function l_e(e){const t=e[Hl];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function vU(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[Hl].modified_&&(Bj(t),zc(4)),hm(e)&&(e=xN(t,e),t.parent_||yN(t,e)),t.patches_&&fm("Patches").generateReplacementPatches_(n[Hl].base_,e,t.patches_,t.inversePatches_)):e=xN(t,n,[]),Bj(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==OX?e:void 0}function xN(e,t,n){if(fA(t))return t;const r=e.immer_.shouldUseStrictIteration(),i=t[Hl];if(!i)return gN(t,(a,o)=>wU(e,i,t,a,o,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return yN(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let o=a,c=!1;i.type_===3&&(o=new Set(a),a.clear(),c=!0),gN(o,(h,f)=>wU(e,i,a,h,f,n,c),r),yN(e,a,!1),n&&e.patches_&&fm("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function wU(e,t,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const c=fA(i);if(!(c&&!o)){if(jg(i)){const h=a&&t&&t.type_!==3&&!Lj(t.assigned_,r)?a.concat(r):void 0,f=xN(e,i,h);if(DX(n,r,f),jg(f))e.canAutoFreeze_=!1;else return}else o&&n.add(i);if(hm(i)&&!c){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&c)return;xN(e,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(db(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&yN(e,i)}}}function yN(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&t3(t,n)}function c_e(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:MX(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=n3;n&&(i=[r],a=_y);const{revoke:o,proxy:c}=Proxy.revocable(i,a);return r.draft_=c,r.revoke_=o,c}var n3={get(e,t){if(t===Hl)return e;const n=pp(e);if(!Lj(n,t))return u_e(e,n,t);const r=n[t];return e.finalized_||!hm(r)?r:r===tS(e.base_,t)?(nS(e),e.copy_[t]=Fj(r,e)):r},has(e,t){return t in pp(e)},ownKeys(e){return Reflect.ownKeys(pp(e))},set(e,t,n){const r=LX(pp(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=tS(pp(e),t),a=i==null?void 0:i[Hl];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(i_e(n,i)&&(n!==void 0||Lj(e.base_,t)))return!0;nS(e),Vj(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return tS(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,nS(e),Vj(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=pp(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){zc(11)},getPrototypeOf(e){return Ey(e.base_)},setPrototypeOf(){zc(12)}},_y={};gN(n3,(e,t)=>{_y[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});_y.deleteProperty=function(e,t){return _y.set.call(this,e,t,void 0)};_y.set=function(e,t,n){return n3.set.call(this,e[0],t,n,e[0])};function tS(e,t){const n=e[Hl];return(n?pp(n):e)[t]}function u_e(e,t,n){var i;const r=LX(t,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function LX(e,t){if(!(t in e))return;let n=Ey(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ey(n)}}function Vj(e){e.modified_||(e.modified_=!0,e.parent_&&Vj(e.parent_))}function nS(e){e.copy_||(e.copy_=Uj(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var d_e=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const a=n;n=t;const o=this;return function(h=a,...f){return o.produce(h,m=>n.call(this,m,...f))}}typeof n!="function"&&zc(6),r!==void 0&&typeof r!="function"&&zc(7);let i;if(hm(t)){const a=bU(this),o=Fj(t,void 0);let c=!0;try{i=n(o),c=!1}finally{c?Bj(a):zj(a)}return yU(a,r),vU(i,a)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===OX&&(i=void 0),this.autoFreeze_&&t3(i,!0),r){const a=[],o=[];fm("Patches").generateReplacementPatches_(t,i,a,o),r(a,o)}return i}else zc(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(o,...c)=>this.produceWithPatches(o,h=>t(h,...c));let r,i;return[this.produce(t,n,(o,c)=>{r=o,i=c}),r,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){hm(e)||zc(8),jg(e)&&(e=h_e(e));const t=bU(this),n=Fj(e,void 0);return n[Hl].isManual_=!0,zj(t),n}finishDraft(e,t){const n=e&&e[Hl];(!n||!n.isManual_)&&zc(9);const{scope_:r}=n;return yU(r,t),vU(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=fm("Patches").applyPatches_;return jg(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Fj(e,t){const n=db(e)?fm("MapSet").proxyMap_(e,t):hA(e)?fm("MapSet").proxySet_(e,t):c_e(e,t);return(t?t.scope_:MX()).drafts_.push(n),n}function h_e(e){return jg(e)||zc(10,e),UX(e)}function UX(e){if(!hm(e)||fA(e))return e;const t=e[Hl];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Uj(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Uj(e,!0);return gN(n,(i,a)=>{DX(n,i,UX(a))},r),t&&(t.finalized_=!1),n}var f_e=new d_e;f_e.produce;var p_e={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},BX=Io({name:"legend",initialState:p_e,reducers:{setLegendSize(e,t){e.size.width=t.payload.width,e.size.height=t.payload.height},setLegendSettings(e,t){e.settings.align=t.payload.align,e.settings.layout=t.payload.layout,e.settings.verticalAlign=t.payload.verticalAlign,e.settings.itemSorter=t.payload.itemSorter},addLegendPayload:{reducer(e,t){e.payload.push(t.payload)},prepare:ms()},replaceLegendPayload:{reducer(e,t){var{prev:n,next:r}=t.payload,i=fc(e).payload.indexOf(n);i>-1&&(e.payload[i]=r)},prepare:ms()},removeLegendPayload:{reducer(e,t){var n=fc(e).payload.indexOf(t.payload);n>-1&&e.payload.splice(n,1)},prepare:ms()}}}),{setLegendSize:NU,setLegendSettings:m_e,addLegendPayload:g_e,replaceLegendPayload:x_e,removeLegendPayload:y_e}=BX.actions,b_e=BX.reducer,rS={exports:{}},iS={};/** * @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 EU;function v_e(){if(EU)return iS;EU=1;var e=Mg();function t(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,i=e.useRef,a=e.useEffect,o=e.useMemo,c=e.useDebugValue;return iS.useSyncExternalStoreWithSelector=function(h,f,m,y,w){var A=i(null);if(A.current===null){var S={hasValue:!1,value:null};A.current=S}else S=A.current;A=o(function(){function T(Z){if(!D){if(D=!0,V=Z,Z=y(Z),w!==void 0&&S.hasValue){var q=S.value;if(w(q,Z))return L=q}return L=Z}if(q=L,n(V,Z))return q;var B=y(Z);return w!==void 0&&w(q,B)?(V=Z,q):(V=Z,L=B)}var D=!1,V,L,K=m===void 0?null:m;return[function(){return T(f())},K===null?void 0:function(){return T(K())}]},[f,m,y,w]);var C=r(h,A[0],A[1]);return a(function(){S.hasValue=!0,S.value=C},[C]),c(C),C},iS}var AU;function w_e(){return AU||(AU=1,rS.exports=v_e()),rS.exports}w_e();function N_e(e){e()}function E_e(){let e=null,t=null;return{clear(){e=null,t=null},notify(){N_e(()=>{let n=e;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=e;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=t={callback:n,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!r||e===null||(r=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var _U={notify(){},get:()=>[]};function A_e(e,t){let n,r=_U,i=0,a=!1;function o(C){m();const T=r.subscribe(C);let D=!1;return()=>{D||(D=!0,T(),y())}}function c(){r.notify()}function h(){S.onStateChange&&S.onStateChange()}function f(){return a}function m(){i++,n||(n=e.subscribe(h),r=E_e())}function y(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=_U)}function w(){a||(a=!0,m())}function A(){a&&(a=!1,y())}const S={addNestedSub:o,notifyNestedSubs:c,handleChangeWrapper:h,isSubscribed:f,trySubscribe:w,tryUnsubscribe:A,getListeners:()=>r};return S}var __e=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",k_e=__e(),S_e=()=>typeof navigator<"u"&&navigator.product==="ReactNative",C_e=S_e(),j_e=()=>k_e||C_e?I.useLayoutEffect:I.useEffect,I_e=j_e();function kU(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function T_e(e,t){if(kU(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i=0;i{const h=A_e(i);return{store:i,subscription:h,getServerState:r?()=>r:void 0}},[i,r]),o=I.useMemo(()=>i.getState(),[i]);I_e(()=>{const{subscription:h}=a;return h.onStateChange=h.notifyNestedSubs,h.trySubscribe(),o!==i.getState()&&h.notifyNestedSubs(),()=>{h.tryUnsubscribe(),h.onStateChange=void 0}},[a,o]);const c=n||O_e;return I.createElement(c.Provider,{value:a},t)}var D_e=R_e,M_e=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle","radius","throttledEvents"]);function L_e(e,t){return e==null&&t==null?!0:typeof e=="number"&&typeof t=="number"?e===t||e!==e&&t!==t:e===t}function Am(e,t){var n=new Set([...Object.keys(e),...Object.keys(t)]);for(var r of n)if(M_e.has(r)){if(e[r]==null&&t[r]==null)continue;if(!T_e(e[r],t[r]))return!1}else if(!L_e(e[r],t[r]))return!1;return!0}var U_e=["contextPayload"];function $j(){return $j=Object.assign?Object.assign.bind():function(e){for(var t=1;t{t(m_e(e))},[t,e]),null}function K_e(e){var t=bs();return I.useEffect(()=>(t(NU(e)),()=>{t(NU({width:0,height:0}))}),[t,e]),null}function Y_e(e,t,n,r){return e==="vertical"&&t!=null?{height:t}:e==="horizontal"?{width:n||r}:null}var X_e={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function Q_e(e){var t=Ha(e,X_e),n=oAe(),r=iNe(),i=t_e(),{width:a,height:o,wrapperStyle:c,portal:h}=t,[f,m]=WY([n]),y=Z4(),w=J4();if(y==null||w==null)return null;var A=y-((i==null?void 0:i.left)||0)-((i==null?void 0:i.right)||0),S=Y_e(t.layout,o,a,A),C=h?c:Ig(Ig({position:"absolute",width:(S==null?void 0:S.width)||a||"auto",height:(S==null?void 0:S.height)||o||"auto"},q_e(c,t,i,y,w,f)),c),T=h??r;if(T==null||n==null)return null;var D=I.createElement("div",{className:"recharts-legend-wrapper",style:C,ref:m},I.createElement(W_e,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),!h&&I.createElement(K_e,{width:f.width,height:f.height}),I.createElement(G_e,$j({},t,S,{margin:i,chartWidth:y,chartHeight:w,contextPayload:n})));return JN.createPortal(D,T)}var zX=I.memo(Q_e,Am);zX.displayName="Legend";function Hj(){return Hj=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{separator:t=v0.separator,contentStyle:n,itemStyle:r,labelStyle:i=v0.labelStyle,payload:a,formatter:o,itemSorter:c,wrapperClassName:h,labelClassName:f,label:m,labelFormatter:y,accessibilityLayer:w=v0.accessibilityLayer}=e,A=()=>{if(a&&a.length){var Z={padding:0,margin:0},q=nke(a,c),B=q.map((z,F)=>{if(!z||z.type==="none")return null;var $=z.formatter||o||tke,{value:Y,name:X}=z,J=Y,ye=X;if($){var ne=$(Y,X,z,F,a);if(Array.isArray(ne))[J,ye]=ne;else if(ne!=null)J=ne;else return null}var de=i1(i1({},v0.itemStyle),{},{color:z.color||v0.itemStyle.color},r);return I.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(F),style:de},Hu(ye)?I.createElement("span",{className:"recharts-tooltip-item-name"},ye):null,Hu(ye)?I.createElement("span",{className:"recharts-tooltip-item-separator"},t):null,I.createElement("span",{className:"recharts-tooltip-item-value"},J),I.createElement("span",{className:"recharts-tooltip-item-unit"},z.unit||""))});return I.createElement("ul",{className:"recharts-tooltip-item-list",style:Z},B)}return null},S=i1(i1({},v0.contentStyle),n),C=i1({margin:0},i),T=!ys(m),D=T?m:"",V=Pi("recharts-default-tooltip",h),L=Pi("recharts-tooltip-label",f);T&&y&&a!==void 0&&a!==null&&(D=y(m,a));var K=w?{role:"status","aria-live":"assertive"}:{};return I.createElement("div",Hj({className:V,style:S},K),I.createElement("p",{className:L,style:C},I.isValidElement(D)?D:"".concat(D)),A())},s1="recharts-tooltip-wrapper",ike={visibility:"hidden"};function ske(e){var{coordinate:t,translateX:n,translateY:r}=e;return Pi(s1,{["".concat(s1,"-right")]:_n(n)&&t&&_n(t.x)&&n>=t.x,["".concat(s1,"-left")]:_n(n)&&t&&_n(t.x)&&n=t.y,["".concat(s1,"-top")]:_n(r)&&t&&_n(t.y)&&r0?i:0),y=n[r]+i;if(t[r])return o[r]?m:y;var w=h[r];if(w==null)return 0;if(o[r]){var A=m,S=w;return AT?Math.max(m,w):Math.max(y,w)}function ake(e){var{translateX:t,translateY:n,useTranslate3d:r}=e;return{transform:r?"translate3d(".concat(t,"px, ").concat(n,"px, 0)"):"translate(".concat(t,"px, ").concat(n,"px)")}}function oke(e){var{allowEscapeViewBox:t,coordinate:n,offsetTop:r,offsetLeft:i,position:a,reverseDirection:o,tooltipBox:c,useTranslate3d:h,viewBox:f}=e,m,y,w;return c.height>0&&c.width>0&&n?(y=jU({allowEscapeViewBox:t,coordinate:n,key:"x",offset:i,position:a,reverseDirection:o,tooltipDimension:c.width,viewBox:f,viewBoxDimension:f.width}),w=jU({allowEscapeViewBox:t,coordinate:n,key:"y",offset:r,position:a,reverseDirection:o,tooltipDimension:c.height,viewBox:f,viewBoxDimension:f.height}),m=ake({translateX:y,translateY:w,useTranslate3d:h})):m=ike,{cssProperties:m,cssClasses:ske({translateX:y,translateY:w,coordinate:n})}}var lke=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),hb={isSsr:lke()};function VX(){var[e,t]=I.useState(()=>hb.isSsr||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return I.useEffect(()=>{if(window.matchMedia){var n=window.matchMedia("(prefers-reduced-motion: reduce)"),r=()=>{t(n.matches)};return n.addEventListener("change",r),()=>{n.removeEventListener("change",r)}}},[]),e}function IU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function w0(e){for(var t=1;t({dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}));I.useEffect(()=>{var S=C=>{if(C.key==="Escape"){var T,D,V,L;f({dismissed:!0,dismissedAtCoordinate:{x:(T=(D=e.coordinate)===null||D===void 0?void 0:D.x)!==null&&T!==void 0?T:0,y:(V=(L=e.coordinate)===null||L===void 0?void 0:L.y)!==null&&V!==void 0?V:0}})}};return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S)}},[(t=e.coordinate)===null||t===void 0?void 0:t.x,(n=e.coordinate)===null||n===void 0?void 0:n.y]),h.dismissed&&(((r=(i=e.coordinate)===null||i===void 0?void 0:i.x)!==null&&r!==void 0?r:0)!==h.dismissedAtCoordinate.x||((a=(o=e.coordinate)===null||o===void 0?void 0:o.y)!==null&&a!==void 0?a:0)!==h.dismissedAtCoordinate.y)&&f(w0(w0({},h),{},{dismissed:!1}));var{cssClasses:m,cssProperties:y}=oke({allowEscapeViewBox:e.allowEscapeViewBox,coordinate:e.coordinate,offsetLeft:typeof e.offset=="number"?e.offset:e.offset.x,offsetTop:typeof e.offset=="number"?e.offset:e.offset.y,position:e.position,reverseDirection:e.reverseDirection,tooltipBox:{height:e.lastBoundingBox.height,width:e.lastBoundingBox.width},useTranslate3d:e.useTranslate3d,viewBox:e.viewBox}),w=e.hasPortalFromProps?{}:w0(w0({transition:hke({prefersReducedMotion:c,isAnimationActive:e.isAnimationActive,active:e.active,animationDuration:e.animationDuration,animationEasing:e.animationEasing})},y),{},{pointerEvents:"none",position:"absolute",top:0,left:0}),A=w0(w0({},w),{},{visibility:!h.dismissed&&e.active&&e.hasPayload?"visible":"hidden"},e.wrapperStyle);return I.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:m,style:A,ref:e.innerRef},e.children)}var pke=I.memo(fke),FX=()=>{var e;return(e=Qn(t=>t.rootProps.accessibilityLayer))!==null&&e!==void 0?e:!0};function Gj(){return Gj=Object.assign?Object.assign.bind():function(e){for(var t=1;tYr(e.x)&&Yr(e.y),RU=e=>e.base!=null&&bN(e.base)&&bN(e),a1=e=>e.x,o1=e=>e.y,yke=(e,t)=>{if(typeof e=="function")return e;var n="curve".concat(ab(e));if((n==="curveMonotone"||n==="curveBump")&&t){var r=OU["".concat(n).concat(t==="vertical"?"Y":"X")];if(r)return r}return OU[n]||WE},DU={connectNulls:!1,type:"linear"},bke=e=>{var{type:t=DU.type,points:n=[],baseLine:r,layout:i,connectNulls:a=DU.connectNulls}=e,o=yke(t,i),c=a?n.filter(bN):n;if(Array.isArray(r)){var h,f=n.map((S,C)=>PU(PU({},S),{},{base:r[C]}));i==="vertical"?h=tw().y(o1).x1(a1).x0(S=>S.base.x):h=tw().x(a1).y1(o1).y0(S=>S.base.y);var m=h.defined(RU).curve(o),y=a?f.filter(RU):f;return m(y)}var w;i==="vertical"&&_n(r)?w=tw().y(o1).x1(a1).x0(r):_n(r)?w=tw().x(a1).y1(o1).y0(r):w=gY().x(a1).y(o1);var A=w.defined(bN).curve(o);return A(c)},X1=e=>{var{className:t,points:n,path:r,pathRef:i}=e,a=Pf();if((!n||!n.length)&&!r)return null;var o={type:e.type,points:e.points,baseLine:e.baseLine,layout:e.layout||a,connectNulls:e.connectNulls},c=n&&n.length?bke(o):r;return I.createElement("path",Gj({},Fl(e),z4(e),{className:Pi("recharts-curve",t),d:c===null?void 0:c,ref:i}))},vke=["x","y","top","left","width","height","className"];function qj(){return qj=Object.assign?Object.assign.bind():function(e){for(var t=1;t"M".concat(e,",").concat(i,"v").concat(r,"M").concat(a,",").concat(t,"h").concat(n),Cke=e=>{var{x:t=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:c}=e,h=_ke(e,vke),f=wke({x:t,y:n,top:r,left:i,width:a,height:o},h);return!_n(t)||!_n(n)||!_n(a)||!_n(o)||!_n(r)||!_n(i)?null:I.createElement("path",qj({},Co(f),{className:Pi("recharts-cross",c),d:Ske(t,n,a,o,r,i)}))};function jke(e,t,n,r){var i=r/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-i:n.left+.5,y:e==="horizontal"?n.top+.5:t.y-i,width:e==="horizontal"?r:n.width-1,height:e==="horizontal"?n.height-1:r}}function LU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function UU(e){for(var t=1;te.replace(/([A-Z])/g,t=>"-".concat(t.toLowerCase())),$X=(e,t,n)=>e.map(r=>"".concat(Oke(r)," ").concat(t,"ms ").concat(n)).join(","),Rke=(e,t)=>[Object.keys(e),Object.keys(t)].reduce((n,r)=>n.filter(i=>r.includes(i))),ky=(e,t)=>Object.keys(t).reduce((n,r)=>UU(UU({},n),{},{[r]:e(r,t[r])}),{});function BU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function _a(e){for(var t=1;te+(t-e)*n,Wj=e=>{var{from:t,to:n}=e;return t!==n},HX=(e,t,n)=>{var r=ky((i,a)=>{if(Wj(a)){var[o,c]=e(a.from,a.to,a.velocity);return _a(_a({},a),{},{from:o,velocity:c})}return a},t);return n<1?ky((i,a)=>Wj(a)&&r[i]!=null?_a(_a({},a),{},{velocity:vN(a.velocity,r[i].velocity,n),from:vN(a.from,r[i].from,n)}):a,t):HX(e,r,n-1)};function Uke(e,t,n,r,i,a){var o,c=r.reduce((w,A)=>_a(_a({},w),{},{[A]:{from:e[A],velocity:0,to:t[A]}}),{}),h=()=>ky((w,A)=>A.from,c),f=()=>!Object.values(c).filter(Wj).length,m=null,y=w=>{o||(o=w);var A=w-o,S=A/n.dt;c=HX(n,c,S),i(_a(_a(_a({},e),t),h())),o=w,f()||(m=a.setTimeout(y))};return()=>(m=a.setTimeout(y),()=>{var w;(w=m)===null||w===void 0||w()})}function Bke(e,t,n,r,i,a,o){var c=null,h=i.reduce((y,w)=>{var A=e[w],S=t[w];return A==null||S==null?y:_a(_a({},y),{},{[w]:[A,S]})},{}),f,m=y=>{f||(f=y);var w=(y-f)/r,A=ky((C,T)=>vN(...T,n(w)),h);if(a(_a(_a(_a({},e),t),A)),w<1)c=o.setTimeout(m);else{var S=ky((C,T)=>vN(...T,n(1)),h);a(_a(_a(_a({},e),t),S))}};return()=>(c=o.setTimeout(m),()=>{var y;(y=c)===null||y===void 0||y()})}const zke=(e,t,n,r,i,a)=>{var o=Rke(e,t);return n==null?()=>(i(_a(_a({},e),t)),()=>{}):n.isStepper===!0?Uke(e,t,n,o,i,a):Bke(e,t,n,r,o,i,a)};var wN=1e-4,GX=(e,t)=>[0,3*e,3*t-6*e,3*e-3*t+1],qX=(e,t)=>e.map((n,r)=>n*t**r).reduce((n,r)=>n+r),zU=(e,t)=>n=>{var r=GX(e,t);return qX(r,n)},Vke=(e,t)=>n=>{var r=GX(e,t),i=[...r.map((a,o)=>a*o).slice(1),0];return qX(i,n)},Fke=e=>{var t,n=e.split("(");if(n.length!==2||n[0]!=="cubic-bezier")return null;var r=(t=n[1])===null||t===void 0||(t=t.split(")")[0])===null||t===void 0?void 0:t.split(",");if(r==null||r.length!==4)return null;var i=r.map(a=>parseFloat(a));return[i[0],i[1],i[2],i[3]]},$ke=function(){for(var t=arguments.length,n=new Array(t),r=0;r{var i=zU(e,n),a=zU(t,r),o=Vke(e,n),c=f=>f>1?1:f<0?0:f,h=f=>{for(var m=f>1?1:f,y=m,w=0;w<8;++w){var A=i(y)-m,S=o(y);if(Math.abs(A-m)0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=t,a=(o,c,h)=>{var f=-(o-c)*n,m=h*r,y=h+(f-m)*i/1e3,w=h*i/1e3+o;return Math.abs(w-c){if(typeof e=="string")switch(e){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return VU(e);case"spring":return Gke();default:if(e.split("(")[0]==="cubic-bezier")return VU(e)}return typeof e=="function"?e:null};function Wke(e){var t,n=()=>null,r=!1,i=null,a=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var c=o,[h,...f]=c;if(typeof h=="number"){i=e.setTimeout(a.bind(null,f),h);return}a(h),i=e.setTimeout(a.bind(null,f));return}typeof o=="string"&&(t=o,n(t)),typeof o=="object"&&(t=o,n(t)),typeof o=="function"&&o()}};return{stop:()=>{r=!0},start:o=>{r=!1,i&&(i(),i=null),a(o)},subscribe:o=>(n=o,()=>{n=()=>null}),getTimeoutController:()=>e}}class Kke{setTimeout(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=o=>{o-r>=n?t(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function Yke(){return Wke(new Kke)}var Xke=I.createContext(Yke);function Qke(e,t){var n=I.useContext(Xke);return I.useMemo(()=>t??n(e),[e,t,n])}var Zke={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},FU={t:0},oS={t:1};function fb(e){var t=Ha(e,Zke),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:c,onAnimationStart:h,children:f}=t,m=VX(),y=n==="auto"?!hb.isSsr&&!m:n,w=Qke(t.animationId,t.animationManager),[A,S]=I.useState(y?FU:oS),C=I.useRef(null);return I.useEffect(()=>{y||S(oS)},[y]),I.useEffect(()=>{if(!y||!r)return Tf;var T=zke(FU,oS,qke(a),i,S,w.getTimeoutController()),D=()=>{C.current=T()};return w.start([h,o,D,i,c]),()=>{w.stop(),C.current&&C.current(),c()}},[y,r,i,a,o,h,c,w]),f(A.t)}function pb(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=I.useRef(by(t)),r=I.useRef(e);return r.current!==e&&(n.current=by(t),r.current=e),n.current}var Jke=["radius"],eSe=["radius"],$U,HU,GU,qU,WU,KU,YU,XU,QU,ZU;function JU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function eB(e){for(var t=1;t{var a=tf(n),o=tf(r),c=Math.min(Math.abs(a)/2,Math.abs(o)/2),h=o>=0?1:-1,f=a>=0?1:-1,m=o>=0&&a>=0||o<0&&a<0?1:0,y;if(c>0&&Array.isArray(i)){for(var w=[0,0,0,0],A=0,S=4;Ac?c:T}y=Ws($U||($U=pu(["M",",",""])),e,t+h*w[0]),w[0]>0&&(y+=Ws(HU||(HU=pu(["A ",",",",0,0,",",",",",""])),w[0],w[0],m,e+f*w[0],t)),y+=Ws(GU||(GU=pu(["L ",",",""])),e+n-f*w[1],t),w[1]>0&&(y+=Ws(qU||(qU=pu(["A ",",",",0,0,",`, `,",",""])),w[1],w[1],m,e+n,t+h*w[1])),y+=Ws(WU||(WU=pu(["L ",",",""])),e+n,t+r-h*w[2]),w[2]>0&&(y+=Ws(KU||(KU=pu(["A ",",",",0,0,",`, `,",",""])),w[2],w[2],m,e+n-f*w[2],t+r)),y+=Ws(YU||(YU=pu(["L ",",",""])),e+f*w[3],t+r),w[3]>0&&(y+=Ws(XU||(XU=pu(["A ",",",",0,0,",`, `,",",""])),w[3],w[3],m,e,t+r-h*w[3])),y+="Z"}else if(c>0&&i===+i&&i>0){var D=Math.min(c,i);y=Ws(QU||(QU=pu(["M ",",",` A `,",",",0,0,",",",",",` L `,",",` A `,",",",0,0,",",",",",` L `,",",` A `,",",",0,0,",",",",",` L `,",",` A `,",",",0,0,",",",","," Z"])),e,t+h*D,D,D,m,e+f*D,t,e+n-f*D,t,D,D,m,e+n,t+h*D,e+n,t+r-h*D,D,D,m,e+n-f*D,t+r,e+f*D,t+r,D,D,m,e,t+r-h*D)}else y=Ws(ZU||(ZU=pu(["M ",","," h "," v "," h "," Z"])),e,t,n,r,-n);return y},rB={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},WX=e=>{var t=Ha(e,rB),n=I.useRef(null),[r,i]=I.useState(-1);I.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var be=n.current.getTotalLength();be&&i(be)}catch{}},[]);var{x:a,y:o,width:c,height:h,radius:f,className:m}=t,{animationEasing:y,animationDuration:w,animationBegin:A,isAnimationActive:S,isUpdateAnimationActive:C}=t,T=I.useRef(c),D=I.useRef(h),V=I.useRef(a),L=I.useRef(o),K=I.useMemo(()=>({x:a,y:o,width:c,height:h,radius:f}),[a,o,c,h,f]),Z=pb(K,"rectangle-");if(a!==+a||o!==+o||c!==+c||h!==+h||c===0||h===0)return null;var q=Pi("recharts-rectangle",m);if(!C){var B=Co(t),{radius:z}=B,F=tB(B,Jke);return I.createElement("path",NN({},F,{x:tf(a),y:tf(o),width:tf(c),height:tf(h),radius:typeof f=="number"?f:void 0,className:q,d:nB(a,o,c,h,f)}))}var $=T.current,Y=D.current,X=V.current,J=L.current,ye="0px ".concat(r===-1?1:r,"px"),ne="".concat(r,"px ").concat(r,"px"),de=$X(["strokeDasharray"],w,typeof y=="string"?y:rB.animationEasing);return I.createElement(fb,{animationId:Z,key:Z,canBegin:r>0,duration:w,easing:y,isActive:C,begin:A},be=>{var Ce=Ji($,c,be),Ke=Ji(Y,h,be),G=Ji(X,a,be),se=Ji(J,o,be);n.current&&(T.current=Ce,D.current=Ke,V.current=G,L.current=se);var xe;S?be>0?xe={transition:de,strokeDasharray:ne}:xe={strokeDasharray:ye}:xe={strokeDasharray:ne};var re=Co(t),{radius:Me}=re,nt=tB(re,eSe);return I.createElement("path",NN({},nt,{radius:typeof f=="number"?f:void 0,className:q,d:nB(G,se,Ce,Ke,f),ref:n,style:eB(eB({},xe),t.style)}))})};function iB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function sB(e){for(var t=1;te*180/Math.PI,oo=(e,t,n,r)=>({x:e+Math.cos(-EN*r)*n,y:t+Math.sin(-EN*r)*n}),cSe=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(r.left||0)-(r.right||0)),Math.abs(n-(r.top||0)-(r.bottom||0)))/2},uSe=(e,t)=>{var{x:n,y:r}=e,{x:i,y:a}=t;return Math.sqrt((n-i)**2+(r-a)**2)},dSe=(e,t)=>{var{x:n,y:r}=e,{cx:i,cy:a}=t,o=uSe({x:n,y:r},{x:i,y:a});if(o<=0)return{radius:o,angle:0};var c=(n-i)/o,h=Math.acos(c);return r>a&&(h=2*Math.PI-h),{radius:o,angle:lSe(h),angleInRadian:h}},hSe=e=>{var{startAngle:t,endAngle:n}=e,r=Math.floor(t/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:t-a*360,endAngle:n-a*360}},fSe=(e,t)=>{var{startAngle:n,endAngle:r}=t,i=Math.floor(n/360),a=Math.floor(r/360),o=Math.min(i,a);return e+o*360},pSe=(e,t)=>{var{relativeX:n,relativeY:r}=e,{radius:i,angle:a}=dSe({x:n,y:r},t),{innerRadius:o,outerRadius:c}=t;if(ic||i===0)return null;var{startAngle:h,endAngle:f}=hSe(t),m=a,y;if(h<=f){for(;m>f;)m-=360;for(;m=h&&m<=f}else{for(;m>h;)m-=360;for(;m=f&&m<=h}return y?sB(sB({},t),{},{radius:i,angle:fSe(m,t)}):null};function KX(e){var{cx:t,cy:n,radius:r,startAngle:i,endAngle:a}=e,o=oo(t,n,r,i),c=oo(t,n,r,a);return{points:[o,c],cx:t,cy:n,radius:r,startAngle:i,endAngle:a}}var aB,oB,lB,cB,uB,dB,hB;function Kj(){return Kj=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=xl(t-e),r=Math.min(Math.abs(t-e),359.999);return n*r},cw=e=>{var{cx:t,cy:n,radius:r,angle:i,sign:a,isExternal:o,cornerRadius:c,cornerIsExternal:h}=e,f=c*(o?1:-1)+r,m=Math.asin(c/f)/EN,y=h?i:i+a*m,w=oo(t,n,f,y),A=oo(t,n,r,y),S=h?i-a*m:i,C=oo(t,n,f*Math.cos(m*EN),S);return{center:w,circleTangency:A,lineTangency:C,theta:m}},YX=e=>{var{cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=e,c=mSe(a,o),h=a+c,f=oo(t,n,i,a),m=oo(t,n,i,h),y=Ws(aB||(aB=Cp(["M ",",",` A `,",",`,0, `,",",`, `,",",` `])),f.x,f.y,i,i,+(Math.abs(c)>180),+(a>h),m.x,m.y);if(r>0){var w=oo(t,n,r,a),A=oo(t,n,r,h);y+=Ws(oB||(oB=Cp(["L ",",",` A `,",",`,0, `,",",`, `,","," Z"])),A.x,A.y,r,r,+(Math.abs(c)>180),+(a<=h),w.x,w.y)}else y+=Ws(lB||(lB=Cp(["L ",","," Z"])),t,n);return y},gSe=e=>{var{cx:t,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:c,startAngle:h,endAngle:f}=e,m=xl(f-h),{circleTangency:y,lineTangency:w,theta:A}=cw({cx:t,cy:n,radius:i,angle:h,sign:m,cornerRadius:a,cornerIsExternal:c}),{circleTangency:S,lineTangency:C,theta:T}=cw({cx:t,cy:n,radius:i,angle:f,sign:-m,cornerRadius:a,cornerIsExternal:c}),D=c?Math.abs(h-f):Math.abs(h-f)-A-T;if(D<0)return o?Ws(cB||(cB=Cp(["M ",",",` a`,",",",0,0,1,",`,0 a`,",",",0,0,1,",`,0 `])),w.x,w.y,a,a,a*2,a,a,-a*2):YX({cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:h,endAngle:f});var V=Ws(uB||(uB=Cp(["M ",",",` A`,",",",0,0,",",",",",` A`,",",",0,",",",",",",",` A`,",",",0,0,",",",",",` `])),w.x,w.y,a,a,+(m<0),y.x,y.y,i,i,+(D>180),+(m<0),S.x,S.y,a,a,+(m<0),C.x,C.y);if(r>0){var{circleTangency:L,lineTangency:K,theta:Z}=cw({cx:t,cy:n,radius:r,angle:h,sign:m,isExternal:!0,cornerRadius:a,cornerIsExternal:c}),{circleTangency:q,lineTangency:B,theta:z}=cw({cx:t,cy:n,radius:r,angle:f,sign:-m,isExternal:!0,cornerRadius:a,cornerIsExternal:c}),F=c?Math.abs(h-f):Math.abs(h-f)-Z-z;if(F<0&&a===0)return"".concat(V,"L").concat(t,",").concat(n,"Z");V+=Ws(dB||(dB=Cp(["L",",",` A`,",",",0,0,",",",",",` A`,",",",0,",",",",",",",` A`,",",",0,0,",",",",","Z"])),B.x,B.y,a,a,+(m<0),q.x,q.y,r,r,+(F>180),+(m>0),L.x,L.y,a,a,+(m<0),K.x,K.y)}else V+=Ws(hB||(hB=Cp(["L",",","Z"])),t,n);return V},xSe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},XX=e=>{var t=Ha(e,xSe),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:o,forceCornerRadius:c,cornerIsExternal:h,startAngle:f,endAngle:m,className:y}=t;if(a0&&Math.abs(f-m)<360?C=gSe({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(S,A/2),forceCornerRadius:c,cornerIsExternal:h,startAngle:f,endAngle:m}):C=YX({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:f,endAngle:m}),I.createElement("path",Kj({},Co(t),{className:w,d:C}))};function ySe(e,t,n){if(e==="horizontal")return[{x:t.x,y:n.top},{x:t.x,y:n.top+n.height}];if(e==="vertical")return[{x:n.left,y:t.y},{x:n.left+n.width,y:t.y}];if(TY(t)){if(e==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:c}=t,h=oo(r,i,a,c),f=oo(r,i,o,c);return[{x:h.x,y:h.y},{x:f.x,y:f.y}]}return KX(t)}}var lS={},cS={},uS={},fB;function bSe(){return fB||(fB=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=HY();function n(r){return t.isSymbol(r)?NaN:Number(r)}e.toNumber=n})(uS)),uS}var pB;function vSe(){return pB||(pB=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=bSe();function n(r){return r?(r=t.toNumber(r),r===1/0||r===-1/0?(r<0?-1:1)*Number.MAX_VALUE:r===r?r:0):r===0?r:0}e.toFinite=n})(cS)),cS}var mB;function wSe(){return mB||(mB=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=GY(),n=vSe();function r(i,a,o){o&&typeof o!="number"&&t.isIterateeCall(i,a,o)&&(a=o=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),o=o===void 0?ie.chartData,r3=Ze([Zc],e=>{var t=e.chartData!=null?e.chartData.length-1:0;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:t,dataStartIndex:0}}),mb=(e,t,n,r)=>r?r3(e):Zc(e),ZX=(e,t,n)=>n?r3(e):Zc(e),ASe=Ze([mb],e=>{var{chartData:t,dataStartIndex:n,dataEndIndex:r}=e;return t!=null?t.slice(n,r+1):[]});Ze([r3],e=>{var{chartData:t,dataStartIndex:n,dataEndIndex:r}=e;return t!=null?t.slice(n,r+1):[]});var _Se=Ze([Zc],e=>{var{chartData:t,dataStartIndex:n,dataEndIndex:r}=e;return t!=null?t.slice(n,r+1):[]});function Lu(e){if(Array.isArray(e)&&e.length===2){var[t,n]=e;if(Yr(t)&&Yr(n))return!0}return!1}function xB(e,t,n){return n?e:[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function JX(e,t){if(t&&typeof e!="function"&&Array.isArray(e)&&e.length===2){var[n,r]=e,i,a;if(Yr(n))i=n;else if(typeof n=="function")return;if(Yr(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(Lu(o))return o}}function kSe(e,t,n){if(!(!n&&t==null)){if(typeof e=="function"&&t!=null)try{var r=e(t,n);if(Lu(r))return xB(r,t,n)}catch{}if(Array.isArray(e)&&e.length===2){var[i,a]=e,o,c;if(i==="auto")t!=null&&(o=Math.min(...t));else if(_n(i))o=i;else if(typeof i=="function")try{t!=null&&(o=i(t==null?void 0:t[0]))}catch{}else if(typeof i=="string"&&aU.test(i)){var h=aU.exec(i);if(h==null||h[1]==null||t==null)o=void 0;else{var f=+h[1];o=t[0]-f}}else o=t==null?void 0:t[0];if(a==="auto")t!=null&&(c=Math.max(...t));else if(_n(a))c=a;else if(typeof a=="function")try{t!=null&&(c=a(t==null?void 0:t[1]))}catch{}else if(typeof a=="string"&&oU.test(a)){var m=oU.exec(a);if(m==null||m[1]==null||t==null)c=void 0;else{var y=+m[1];c=t[1]+y}}else c=t==null?void 0:t[1];var w=[o,c];if(Lu(w))return t==null?w:xB(w,t,n)}}}var Xg=1e9,SSe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},s3,ks=!0,bc="[DecimalError] ",$p=bc+"Invalid argument: ",i3=bc+"Exponent out of range: ",Qg=Math.floor,mp=Math.pow,CSe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ol,Fa=1e7,gs=7,eQ=9007199254740991,AN=Qg(eQ/gs),Pn={};Pn.absoluteValue=Pn.abs=function(){var e=new this.constructor(this);return e.s&&(e.s=1),e};Pn.comparedTo=Pn.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=re.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1};Pn.decimalPlaces=Pn.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*gs;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n};Pn.dividedBy=Pn.div=function(e){return Ld(this,new this.constructor(e))};Pn.dividedToIntegerBy=Pn.idiv=function(e){var t=this,n=t.constructor;return ns(Ld(t,new n(e),0,1),n.precision)};Pn.equals=Pn.eq=function(e){return!this.cmp(e)};Pn.exponent=function(){return ha(this)};Pn.greaterThan=Pn.gt=function(e){return this.cmp(e)>0};Pn.greaterThanOrEqualTo=Pn.gte=function(e){return this.cmp(e)>=0};Pn.isInteger=Pn.isint=function(){return this.e>this.d.length-2};Pn.isNegative=Pn.isneg=function(){return this.s<0};Pn.isPositive=Pn.ispos=function(){return this.s>0};Pn.isZero=function(){return this.s===0};Pn.lessThan=Pn.lt=function(e){return this.cmp(e)<0};Pn.lessThanOrEqualTo=Pn.lte=function(e){return this.cmp(e)<1};Pn.logarithm=Pn.log=function(e){var t,n=this,r=n.constructor,i=r.precision,a=i+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(Ol))throw Error(bc+"NaN");if(n.s<1)throw Error(bc+(n.s?"NaN":"-Infinity"));return n.eq(Ol)?new r(0):(ks=!1,t=Ld(Sy(n,a),Sy(e,a),a),ks=!0,ns(t,i))};Pn.minus=Pn.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?rQ(t,e):tQ(t,(e.s=-e.s,e))};Pn.modulo=Pn.mod=function(e){var t,n=this,r=n.constructor,i=r.precision;if(e=new r(e),!e.s)throw Error(bc+"NaN");return n.s?(ks=!1,t=Ld(n,e,0,1).times(e),ks=!0,n.minus(t)):ns(new r(n),i)};Pn.naturalExponential=Pn.exp=function(){return nQ(this)};Pn.naturalLogarithm=Pn.ln=function(){return Sy(this)};Pn.negated=Pn.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};Pn.plus=Pn.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?tQ(t,e):rQ(t,(e.s=-e.s,e))};Pn.precision=Pn.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error($p+e);if(t=ha(i)+1,r=i.d.length-1,n=r*gs+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n};Pn.squareRoot=Pn.sqrt=function(){var e,t,n,r,i,a,o,c=this,h=c.constructor;if(c.s<1){if(!c.s)return new h(0);throw Error(bc+"NaN")}for(e=ha(c),ks=!1,i=Math.sqrt(+c),i==0||i==1/0?(t=Pu(c.d),(t.length+e)%2==0&&(t+="0"),i=Math.sqrt(t),e=Qg((e+1)/2)-(e<0||e%2),i==1/0?t="5e"+e:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),r=new h(t)):r=new h(i.toString()),n=h.precision,i=o=n+3;;)if(a=r,r=a.plus(Ld(c,a,o+2)).times(.5),Pu(a.d).slice(0,o)===(t=Pu(r.d)).slice(0,o)){if(t=t.slice(o-3,o+1),i==o&&t=="4999"){if(ns(a,n+1,0),a.times(a).eq(c)){r=a;break}}else if(t!="9999")break;o+=4}return ks=!0,ns(r,n)};Pn.times=Pn.mul=function(e){var t,n,r,i,a,o,c,h,f,m=this,y=m.constructor,w=m.d,A=(e=new y(e)).d;if(!m.s||!e.s)return new y(0);for(e.s*=m.s,n=m.e+e.e,h=w.length,f=A.length,h=0;){for(t=0,i=h+r;i>r;)c=a[i]+A[r]*w[i-r-1]+t,a[i--]=c%Fa|0,t=c/Fa|0;a[i]=(a[i]+t)%Fa|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=n,ks?ns(e,y.precision):e};Pn.toDecimalPlaces=Pn.todp=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(qu(e,0,Xg),t===void 0?t=r.rounding:qu(t,0,8),ns(n,e+ha(n)+1,t))};Pn.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=pm(r,!0):(qu(e,0,Xg),t===void 0?t=i.rounding:qu(t,0,8),r=ns(new i(r),e+1,t),n=pm(r,!0,e+1)),n};Pn.toFixed=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?pm(i):(qu(e,0,Xg),t===void 0?t=a.rounding:qu(t,0,8),r=ns(new a(i),e+ha(i)+1,t),n=pm(r.abs(),!1,e+ha(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Pn.toInteger=Pn.toint=function(){var e=this,t=e.constructor;return ns(new t(e),ha(e)+1,t.rounding)};Pn.toNumber=function(){return+this};Pn.toPower=Pn.pow=function(e){var t,n,r,i,a,o,c=this,h=c.constructor,f=12,m=+(e=new h(e));if(!e.s)return new h(Ol);if(c=new h(c),!c.s){if(e.s<1)throw Error(bc+"Infinity");return c}if(c.eq(Ol))return c;if(r=h.precision,e.eq(Ol))return ns(c,r);if(t=e.e,n=e.d.length-1,o=t>=n,a=c.s,o){if((n=m<0?-m:m)<=eQ){for(i=new h(Ol),t=Math.ceil(r/gs+4),ks=!1;n%2&&(i=i.times(c),bB(i.d,t)),n=Qg(n/2),n!==0;)c=c.times(c),bB(c.d,t);return ks=!0,e.s<0?new h(Ol).div(i):ns(i,r)}}else if(a<0)throw Error(bc+"NaN");return a=a<0&&e.d[Math.max(t,n)]&1?-1:1,c.s=1,ks=!1,i=e.times(Sy(c,r+f)),ks=!0,i=nQ(i),i.s=a,i};Pn.toPrecision=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?(n=ha(i),r=pm(i,n<=a.toExpNeg||n>=a.toExpPos)):(qu(e,1,Xg),t===void 0?t=a.rounding:qu(t,0,8),i=ns(new a(i),e,t),n=ha(i),r=pm(i,e<=n||n<=a.toExpNeg,e)),r};Pn.toSignificantDigits=Pn.tosd=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(qu(e,1,Xg),t===void 0?t=r.rounding:qu(t,0,8)),ns(new r(n),e,t)};Pn.toString=Pn.valueOf=Pn.val=Pn.toJSON=Pn[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=ha(e),n=e.constructor;return pm(e,t<=n.toExpNeg||t>=n.toExpPos)};function tQ(e,t){var n,r,i,a,o,c,h,f,m=e.constructor,y=m.precision;if(!e.s||!t.s)return t.s||(t=new m(e)),ks?ns(t,y):t;if(h=e.d,f=t.d,o=e.e,i=t.e,h=h.slice(),a=o-i,a){for(a<0?(r=h,a=-a,c=f.length):(r=f,i=o,c=h.length),o=Math.ceil(y/gs),c=o>c?o+1:c+1,a>c&&(a=c,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(c=h.length,a=f.length,c-a<0&&(a=c,r=f,f=h,h=r),n=0;a;)n=(h[--a]=h[a]+f[a]+n)/Fa|0,h[a]%=Fa;for(n&&(h.unshift(n),++i),c=h.length;h[--c]==0;)h.pop();return t.d=h,t.e=i,ks?ns(t,y):t}function qu(e,t,n){if(e!==~~e||en)throw Error($p+e)}function Pu(e){var t,n,r,i=e.length-1,a="",o=e[0];if(i>0){for(a+=o,t=1;to?1:-1;else for(c=h=0;ci[c]?1:-1;break}return h}function n(r,i,a){for(var o=0;a--;)r[a]-=o,o=r[a]1;)r.shift()}return function(r,i,a,o){var c,h,f,m,y,w,A,S,C,T,D,V,L,K,Z,q,B,z,F=r.constructor,$=r.s==i.s?1:-1,Y=r.d,X=i.d;if(!r.s)return new F(r);if(!i.s)throw Error(bc+"Division by zero");for(h=r.e-i.e,B=X.length,Z=Y.length,A=new F($),S=A.d=[],f=0;X[f]==(Y[f]||0);)++f;if(X[f]>(Y[f]||0)&&--h,a==null?V=a=F.precision:o?V=a+(ha(r)-ha(i))+1:V=a,V<0)return new F(0);if(V=V/gs+2|0,f=0,B==1)for(m=0,X=X[0],V++;(f1&&(X=e(X,m),Y=e(Y,m),B=X.length,Z=Y.length),K=B,C=Y.slice(0,B),T=C.length;T=Fa/2&&++q;do m=0,c=t(X,C,B,T),c<0?(D=C[0],B!=T&&(D=D*Fa+(C[1]||0)),m=D/q|0,m>1?(m>=Fa&&(m=Fa-1),y=e(X,m),w=y.length,T=C.length,c=t(y,C,w,T),c==1&&(m--,n(y,B16)throw Error(i3+ha(e));if(!e.s)return new m(Ol);for(ks=!1,c=y,o=new m(.03125);e.abs().gte(.1);)e=e.times(o),f+=5;for(r=Math.log(mp(2,f))/Math.LN10*2+5|0,c+=r,n=i=a=new m(Ol),m.precision=c;;){if(i=ns(i.times(e),c),n=n.times(++h),o=a.plus(Ld(i,n,c)),Pu(o.d).slice(0,c)===Pu(a.d).slice(0,c)){for(;f--;)a=ns(a.times(a),c);return m.precision=y,t==null?(ks=!0,ns(a,y)):a}a=o}}function ha(e){for(var t=e.e*gs,n=e.d[0];n>=10;n/=10)t++;return t}function hS(e,t,n){if(t>e.LN10.sd())throw ks=!0,n&&(e.precision=n),Error(bc+"LN10 precision limit exceeded");return ns(new e(e.LN10),t)}function $h(e){for(var t="";e--;)t+="0";return t}function Sy(e,t){var n,r,i,a,o,c,h,f,m,y=1,w=10,A=e,S=A.d,C=A.constructor,T=C.precision;if(A.s<1)throw Error(bc+(A.s?"NaN":"-Infinity"));if(A.eq(Ol))return new C(0);if(t==null?(ks=!1,f=T):f=t,A.eq(10))return t==null&&(ks=!0),hS(C,f);if(f+=w,C.precision=f,n=Pu(S),r=n.charAt(0),a=ha(A),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)A=A.times(e),n=Pu(A.d),r=n.charAt(0),y++;a=ha(A),r>1?(A=new C("0."+n),a++):A=new C(r+"."+n.slice(1))}else return h=hS(C,f+2,T).times(a+""),A=Sy(new C(r+"."+n.slice(1)),f-w).plus(h),C.precision=T,t==null?(ks=!0,ns(A,T)):A;for(c=o=A=Ld(A.minus(Ol),A.plus(Ol),f),m=ns(A.times(A),f),i=3;;){if(o=ns(o.times(m),f),h=c.plus(Ld(o,new C(i),f)),Pu(h.d).slice(0,f)===Pu(c.d).slice(0,f))return c=c.times(2),a!==0&&(c=c.plus(hS(C,f+2,T).times(a+""))),c=Ld(c,new C(y),f),C.precision=T,t==null?(ks=!0,ns(c,T)):c;c=h,i+=2}}function yB(e,t){var n,r,i;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(i=t.length;t.charCodeAt(i-1)===48;)--i;if(t=t.slice(r,i),t){if(i-=r,n=n-r-1,e.e=Qg(n/gs),e.d=[],r=(n+1)%gs,n<0&&(r+=gs),rAN||e.e<-AN))throw Error(i3+n)}else e.s=0,e.e=0,e.d=[0];return e}function ns(e,t,n){var r,i,a,o,c,h,f,m,y=e.d;for(o=1,a=y[0];a>=10;a/=10)o++;if(r=t-o,r<0)r+=gs,i=t,f=y[m=0];else{if(m=Math.ceil((r+1)/gs),a=y.length,m>=a)return e;for(f=a=y[m],o=1;a>=10;a/=10)o++;r%=gs,i=r-gs+o}if(n!==void 0&&(a=mp(10,o-i-1),c=f/a%10|0,h=t<0||y[m+1]!==void 0||f%a,h=n<4?(c||h)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||h||n==6&&(r>0?i>0?f/mp(10,o-i):0:y[m-1])%10&1||n==(e.s<0?8:7))),t<1||!y[0])return h?(a=ha(e),y.length=1,t=t-a-1,y[0]=mp(10,(gs-t%gs)%gs),e.e=Qg(-t/gs)||0):(y.length=1,y[0]=e.e=e.s=0),e;if(r==0?(y.length=m,a=1,m--):(y.length=m+1,a=mp(10,gs-r),y[m]=i>0?(f/mp(10,o-i)%mp(10,i)|0)*a:0),h)for(;;)if(m==0){(y[0]+=a)==Fa&&(y[0]=1,++e.e);break}else{if(y[m]+=a,y[m]!=Fa)break;y[m--]=0,a=1}for(r=y.length;y[--r]===0;)y.pop();if(ks&&(e.e>AN||e.e<-AN))throw Error(i3+ha(e));return e}function rQ(e,t){var n,r,i,a,o,c,h,f,m,y,w=e.constructor,A=w.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new w(e),ks?ns(t,A):t;if(h=e.d,y=t.d,r=t.e,f=e.e,h=h.slice(),o=f-r,o){for(m=o<0,m?(n=h,o=-o,c=y.length):(n=y,r=f,c=h.length),i=Math.max(Math.ceil(A/gs),c)+2,o>i&&(o=i,n.length=1),n.reverse(),i=o;i--;)n.push(0);n.reverse()}else{for(i=h.length,c=y.length,m=i0;--i)h[c++]=0;for(i=y.length;i>o;){if(h[--i]0?a=a.charAt(0)+"."+a.slice(1)+$h(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+$h(-i-1)+a,n&&(r=n-o)>0&&(a+=$h(r))):i>=o?(a+=$h(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+$h(r))):((r=i+1)0&&(i+1===o&&(a+="."),a+=$h(r))),e.s<0?"-"+a:a}function bB(e,t){if(e.length>t)return e.length=t,!0}function iQ(e){var t,n,r;function i(a){var o=this;if(!(o instanceof i))return new i(a);if(o.constructor=i,a instanceof i){o.s=a.s,o.e=a.e,o.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error($p+a);if(a>0)o.s=1;else if(a<0)a=-a,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(a===~~a&&a<1e7){o.e=0,o.d=[a];return}return yB(o,a.toString())}else if(typeof a!="string")throw Error($p+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,CSe.test(a))yB(o,a);else throw Error($p+a)}if(i.prototype=Pn,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=iQ,i.config=i.set=jSe,e===void 0&&(e={}),e)for(r=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error($p+n+": "+r);if((r=e[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error($p+n+": "+r);return this}var s3=iQ(SSe);Ol=new s3(1);const di=s3;function sQ(e){var t;return e===0?t=1:t=Math.floor(new di(e).abs().log(10).toNumber())+1,t}function aQ(e,t,n){for(var r=new di(e),i=0,a=[];r.lt(t)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var oQ=e=>{var[t,n]=e,[r,i]=[t,n];return t>n&&([r,i]=[n,t]),[r,i]},a3=(e,t,n)=>{if(e.lte(0))return new di(0);var r=sQ(e.toNumber()),i=new di(10).pow(r),a=e.div(i),o=r!==1?.05:.1,c=new di(Math.ceil(a.div(o).toNumber())).add(n).mul(o),h=c.mul(i);return t?new di(h.toNumber()):new di(Math.ceil(h.toNumber()))},lQ=(e,t,n)=>{var r;if(e.lte(0))return new di(0);var i=[1,2,2.5,5],a=e.toNumber(),o=Math.floor(new di(a).abs().log(10).toNumber()),c=new di(10).pow(o),h=e.div(c).toNumber(),f=i.findIndex(A=>A>=h-1e-10);if(f===-1&&(c=c.mul(10),f=0),f+=n,f>=i.length){var m=Math.floor(f/i.length);f%=i.length,c=c.mul(new di(10).pow(m))}var y=(r=i[f])!==null&&r!==void 0?r:1,w=new di(y).mul(c);return t?w:new di(Math.ceil(w.toNumber()))},ISe=(e,t,n)=>{var r=new di(1),i=new di(e);if(!i.isint()&&n){var a=Math.abs(e);a<1?(r=new di(10).pow(sQ(e)-1),i=new di(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new di(Math.floor(e)))}else e===0?i=new di(Math.floor((t-1)/2)):n||(i=new di(Math.floor(e)));for(var o=Math.floor((t-1)/2),c=[],h=0;h4&&arguments[4]!==void 0?arguments[4]:0,o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:a3;if(!Number.isFinite((n-t)/(r-1)))return{step:new di(0),tickMin:new di(0),tickMax:new di(0)};var c=o(new di(n).sub(t).div(r-1),i,a),h;t<=0&&n>=0?h=new di(0):(h=new di(t).add(n).div(2),h=h.sub(new di(h).mod(c)));var f=Math.ceil(h.sub(t).div(c).toNumber()),m=Math.ceil(new di(n).sub(h).div(c).toNumber()),y=f+m+1;return y>r?cQ(t,n,r,i,a+1,o):(y0?m+(r-y):m,f=n>0?f:f+(r-y)),{step:c,tickMin:h.sub(new di(f).mul(c)),tickMax:h.add(new di(m).mul(c))})},vB=function(t){var[n,r]=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"auto",c=Math.max(i,2),[h,f]=oQ([n,r]);if(h===-1/0||f===1/0){var m=f===1/0?[h,...Array(i-1).fill(1/0)]:[...Array(i-1).fill(-1/0),f];return n>r?m.reverse():m}if(h===f)return ISe(h,i,a);var y=o==="snap125"?lQ:a3,{step:w,tickMin:A,tickMax:S}=cQ(h,f,c,a,0,y),C=aQ(A,S.add(new di(.1).mul(w)),w);return n>r?C.reverse():C},wB=function(t,n){var[r,i]=t,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"auto",[c,h]=oQ([r,i]);if(c===-1/0||h===1/0)return[r,i];if(c===h)return[c];var f=o==="snap125"?lQ:a3,m=Math.max(n,2),y=f(new di(h).sub(c).div(m-1),a,0),w=[...aQ(new di(c),new di(h),y),h];return a===!1&&(w=w.map(A=>Math.round(A))),r>i?w.reverse():w},uQ=e=>e.rootProps.maxBarSize,TSe=e=>e.rootProps.barGap,dQ=e=>e.rootProps.barCategoryGap,PSe=e=>e.rootProps.barSize,pA=e=>e.rootProps.stackOffset,hQ=e=>e.rootProps.reverseStackOrder,o3=e=>e.options.chartName,l3=e=>e.rootProps.syncId,fQ=e=>e.rootProps.syncMethod,c3=e=>e.options.eventEmitter,OSe=e=>e.rootProps.baseValue,ka={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},rp={allowDecimals:!1,allowDataOverflow:!1,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"auto"},mu={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,includeHidden:!1,radiusAxisId:0,reversed:!1,scale:"auto",tick:!0,tickCount:5,type:"auto"},mA=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t};function gA(e,t,n){if(n!=="auto")return n;if(e!=null)return Qc(e,t)?"category":"number"}function NB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function _N(e){for(var t=1;t{if(t!=null)return e.polarAxis.angleAxis[t]},u3=Ze([LSe,PX],(e,t)=>{var n;if(e!=null)return e;var r=(n=gA(t,"angleAxis",EB.type))!==null&&n!==void 0?n:"category";return _N(_N({},EB),{},{type:r})}),USe=(e,t)=>e.polarAxis.radiusAxis[t],d3=Ze([USe,PX],(e,t)=>{var n;if(e!=null)return e;var r=(n=gA(t,"radiusAxis",AB.type))!==null&&n!==void 0?n:"category";return _N(_N({},AB),{},{type:r})}),xA=e=>e.polarOptions,h3=Ze([eh,th,Ga],cSe),pQ=Ze([xA,h3],(e,t)=>{if(e!=null)return Kc(e.innerRadius,t,0)}),mQ=Ze([xA,h3],(e,t)=>{if(e!=null)return Kc(e.outerRadius,t,t*.8)}),BSe=e=>{if(e==null)return[0,0];var{startAngle:t,endAngle:n}=e;return[t,n]},gQ=Ze([xA],BSe);Ze([u3,gQ],mA);var xQ=Ze([h3,pQ,mQ],(e,t,n)=>{if(!(e==null||t==null||n==null))return[t,n]});Ze([d3,xQ],mA);var yQ=Ze([Ci,xA,pQ,mQ,eh,th],(e,t,n,r,i,a)=>{if(!(e!=="centric"&&e!=="radial"||t==null||n==null||r==null)){var{cx:o,cy:c,startAngle:h,endAngle:f}=t;return{cx:Kc(o,i,i/2),cy:Kc(c,a,a/2),innerRadius:n,outerRadius:r,startAngle:h,endAngle:f,clockWise:!1}}}),Wa=(e,t)=>t,yA=(e,t,n)=>n;function bA(e){return e==null?void 0:e.id}function bQ(e,t,n){var{chartData:r=[]}=t,{allowDuplicatedCategory:i,dataKey:a}=n,o=new Map;return e.forEach(c=>{var h,f=(h=c.data)!==null&&h!==void 0?h:r;if(!(f==null||f.length===0)){var m=bA(c);f.forEach((y,w)=>{var A=a==null||i?w:String(Us(y,a,null)),S=Us(y,c.dataKey,0),C;o.has(A)?C=o.get(A):C={},Object.assign(C,{[m]:S}),o.set(A,C)})}}),Array.from(o.values())}function vA(e){return"stackId"in e&&e.stackId!=null&&e.dataKey!=null}var wA=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function NA(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function zSe(e,t){if(e.length===t.length){for(var n=0;n{var t=Ci(e);return t==="horizontal"?"xAxis":t==="vertical"?"yAxis":t==="centric"?"angleAxis":"radiusAxis"},Zg=e=>e.tooltip.settings.axisId;function f3(e){if(e!=null){var t=e.ticks,n=e.bandwidth,r=e.range(),i=[Math.min(...r),Math.max(...r)];return{domain:()=>e.domain(),range:(function(a){function o(){return a.apply(this,arguments)}return o.toString=function(){return a.toString()},o})(()=>i),rangeMin:()=>i[0],rangeMax:()=>i[1],isInRange(a){var o=i[0],c=i[1];return o<=c?a>=o&&a<=c:a>=c&&a<=o},bandwidth:n?()=>n.call(e):void 0,ticks:t?a=>t.call(e,a):void 0,map:(a,o)=>{var c=e(a);if(c!=null){if(e.bandwidth&&o!==null&&o!==void 0&&o.position){var h=e.bandwidth();switch(o.position){case"middle":c+=h/2;break;case"end":c+=h;break}}return c}}}}}var VSe=(e,t)=>{if(t!=null)switch(e){case"linear":{if(!Lu(t)){for(var n,r,i=0;ir)&&(r=a))}return n!==void 0&&r!==void 0?[n,r]:void 0}return t}default:return t}};function cf(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function FSe(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function p3(e){let t,n,r;e.length!==2?(t=cf,n=(c,h)=>cf(e(c),h),r=(c,h)=>e(c)-h):(t=e===cf||e===FSe?e:$Se,n=e,r=e);function i(c,h,f=0,m=c.length){if(f>>1;n(c[y],h)<0?f=y+1:m=y}while(f>>1;n(c[y],h)<=0?f=y+1:m=y}while(ff&&r(c[y-1],h)>-r(c[y],h)?y-1:y}return{left:i,center:o,right:a}}function $Se(){return 0}function vQ(e){return e===null?NaN:+e}function*HSe(e,t){for(let n of e)n!=null&&(n=+n)>=n&&(yield n)}const GSe=p3(cf),gb=GSe.right;p3(vQ).center;class _B extends Map{constructor(t,n=KSe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[r,i]of t)this.set(r,i)}get(t){return super.get(kB(this,t))}has(t){return super.has(kB(this,t))}set(t,n){return super.set(qSe(this,t),n)}delete(t){return super.delete(WSe(this,t))}}function kB({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function qSe({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function WSe({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function KSe(e){return e!==null&&typeof e=="object"?e.valueOf():e}function YSe(e=cf){if(e===cf)return wQ;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,n)=>{const r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function wQ(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const XSe=Math.sqrt(50),QSe=Math.sqrt(10),ZSe=Math.sqrt(2);function kN(e,t,n){const r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=XSe?10:a>=QSe?5:a>=ZSe?2:1;let c,h,f;return i<0?(f=Math.pow(10,-i)/o,c=Math.round(e*f),h=Math.round(t*f),c/ft&&--h,f=-f):(f=Math.pow(10,i)*o,c=Math.round(e/f),h=Math.round(t/f),c*ft&&--h),h0))return[];if(e===t)return[e];const r=t=i))return[];const c=a-i+1,h=new Array(c);if(r)if(o<0)for(let f=0;f=r)&&(n=r);return n}function CB(e,t){let n;for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function NQ(e,t,n=0,r=1/0,i){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(i=i===void 0?wQ:YSe(i);r>n;){if(r-n>600){const h=r-n+1,f=t-n+1,m=Math.log(h),y=.5*Math.exp(2*m/3),w=.5*Math.sqrt(m*y*(h-y)/h)*(f-h/2<0?-1:1),A=Math.max(n,Math.floor(t-f*y/h+w)),S=Math.min(r,Math.floor(t+(h-f)*y/h+w));NQ(e,t,A,S,i)}const a=e[t];let o=n,c=r;for(l1(e,n,t),i(e[r],a)>0&&l1(e,n,r);o0;)--c}i(e[n],a)===0?l1(e,n,c):(++c,l1(e,c,r)),c<=t&&(n=c+1),t<=c&&(r=c-1)}return e}function l1(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function JSe(e,t,n){if(e=Float64Array.from(HSe(e)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return CB(e);if(t>=1)return SB(e);var r,i=(r-1)*t,a=Math.floor(i),o=SB(NQ(e,a).subarray(0,a+1)),c=CB(e.subarray(a+1));return o+(c-o)*(i-a)}}function eCe(e,t,n=vQ){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e),c=+n(e[a+1],a+1,e);return o+(c-o)*(i-a)}}function tCe(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=new Array(i);++r>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?uw(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?uw(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=iCe.exec(e))?new bl(t[1],t[2],t[3],1):(t=sCe.exec(e))?new bl(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=aCe.exec(e))?uw(t[1],t[2],t[3],t[4]):(t=oCe.exec(e))?uw(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=lCe.exec(e))?DB(t[1],t[2]/100,t[3]/100,1):(t=cCe.exec(e))?DB(t[1],t[2]/100,t[3]/100,t[4]):jB.hasOwnProperty(e)?PB(jB[e]):e==="transparent"?new bl(NaN,NaN,NaN,0):null}function PB(e){return new bl(e>>16&255,e>>8&255,e&255,1)}function uw(e,t,n,r){return r<=0&&(e=t=n=NaN),new bl(e,t,n,r)}function hCe(e){return e instanceof xb||(e=Iy(e)),e?(e=e.rgb(),new bl(e.r,e.g,e.b,e.opacity)):new bl}function Jj(e,t,n,r){return arguments.length===1?hCe(e):new bl(e,t,n,r??1)}function bl(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}x3(bl,Jj,AQ(xb,{brighter(e){return e=e==null?SN:Math.pow(SN,e),new bl(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Cy:Math.pow(Cy,e),new bl(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new bl(Hp(this.r),Hp(this.g),Hp(this.b),CN(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:OB,formatHex:OB,formatHex8:fCe,formatRgb:RB,toString:RB}));function OB(){return`#${jp(this.r)}${jp(this.g)}${jp(this.b)}`}function fCe(){return`#${jp(this.r)}${jp(this.g)}${jp(this.b)}${jp((isNaN(this.opacity)?1:this.opacity)*255)}`}function RB(){const e=CN(this.opacity);return`${e===1?"rgb(":"rgba("}${Hp(this.r)}, ${Hp(this.g)}, ${Hp(this.b)}${e===1?")":`, ${e})`}`}function CN(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Hp(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function jp(e){return e=Hp(e),(e<16?"0":"")+e.toString(16)}function DB(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Vc(e,t,n,r)}function _Q(e){if(e instanceof Vc)return new Vc(e.h,e.s,e.l,e.opacity);if(e instanceof xb||(e=Iy(e)),!e)return new Vc;if(e instanceof Vc)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,c=a-i,h=(a+i)/2;return c?(t===a?o=(n-r)/c+(n0&&h<1?0:o,new Vc(o,c,h,e.opacity)}function pCe(e,t,n,r){return arguments.length===1?_Q(e):new Vc(e,t,n,r??1)}function Vc(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}x3(Vc,pCe,AQ(xb,{brighter(e){return e=e==null?SN:Math.pow(SN,e),new Vc(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Cy:Math.pow(Cy,e),new Vc(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new bl(fS(e>=240?e-240:e+120,i,r),fS(e,i,r),fS(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Vc(MB(this.h),dw(this.s),dw(this.l),CN(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=CN(this.opacity);return`${e===1?"hsl(":"hsla("}${MB(this.h)}, ${dw(this.s)*100}%, ${dw(this.l)*100}%${e===1?")":`, ${e})`}`}}));function MB(e){return e=(e||0)%360,e<0?e+360:e}function dw(e){return Math.max(0,Math.min(1,e||0))}function fS(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const y3=e=>()=>e;function mCe(e,t){return function(n){return e+n*t}}function gCe(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function xCe(e){return(e=+e)==1?kQ:function(t,n){return n-t?gCe(t,n,e):y3(isNaN(t)?n:t)}}function kQ(e,t){var n=t-e;return n?mCe(e,n):y3(isNaN(e)?t:e)}const LB=(function e(t){var n=xCe(t);function r(i,a){var o=n((i=Jj(i)).r,(a=Jj(a)).r),c=n(i.g,a.g),h=n(i.b,a.b),f=kQ(i.opacity,a.opacity);return function(m){return i.r=o(m),i.g=c(m),i.b=h(m),i.opacity=f(m),i+""}}return r.gamma=e,r})(1);function yCe(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),c[o]?c[o]+=a:c[++o]=a),(r=r[0])===(i=i[0])?c[o]?c[o]+=i:c[++o]=i:(c[++o]=null,h.push({i:o,x:jN(r,i)})),n=pS.lastIndex;return nt&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}function jCe(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i2?ICe:jCe,h=f=null,y}function y(w){return w==null||isNaN(w=+w)?a:(h||(h=c(e.map(r),t,n)))(r(o(w)))}return y.invert=function(w){return o(i((f||(f=c(t,e.map(r),jN)))(w)))},y.domain=function(w){return arguments.length?(e=Array.from(w,IN),m()):e.slice()},y.range=function(w){return arguments.length?(t=Array.from(w),m()):t.slice()},y.rangeRound=function(w){return t=Array.from(w),n=b3,m()},y.clamp=function(w){return arguments.length?(o=w?!0:Go,m()):o!==Go},y.interpolate=function(w){return arguments.length?(n=w,m()):n},y.unknown=function(w){return arguments.length?(a=w,y):a},function(w,A){return r=w,i=A,m()}}function v3(){return EA()(Go,Go)}function TCe(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function TN(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Tg(e){return e=TN(Math.abs(e)),e?e[1]:NaN}function PCe(e,t){return function(n,r){for(var i=n.length,a=[],o=0,c=e[0],h=0;i>0&&c>0&&(h+c+1>r&&(c=Math.max(1,r-h)),a.push(n.substring(i-=c,i+c)),!((h+=c+1)>r));)c=e[o=(o+1)%e.length];return a.reverse().join(t)}}function OCe(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var RCe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Ty(e){if(!(t=RCe.exec(e)))throw new Error("invalid format: "+e);var t;return new w3({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Ty.prototype=w3.prototype;function w3(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}w3.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function DCe(e){e:for(var t=e.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var PN;function MCe(e,t){var n=TN(e,t);if(!n)return PN=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(PN=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+TN(e,Math.max(0,t+a-1))[0]}function BB(e,t){var n=TN(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const zB={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:TCe,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>BB(e*100,t),r:BB,s:MCe,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function VB(e){return e}var FB=Array.prototype.map,$B=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function LCe(e){var t=e.grouping===void 0||e.thousands===void 0?VB:PCe(FB.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",i=e.decimal===void 0?".":e.decimal+"",a=e.numerals===void 0?VB:OCe(FB.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",c=e.minus===void 0?"−":e.minus+"",h=e.nan===void 0?"NaN":e.nan+"";function f(y,w){y=Ty(y);var A=y.fill,S=y.align,C=y.sign,T=y.symbol,D=y.zero,V=y.width,L=y.comma,K=y.precision,Z=y.trim,q=y.type;q==="n"?(L=!0,q="g"):zB[q]||(K===void 0&&(K=12),Z=!0,q="g"),(D||A==="0"&&S==="=")&&(D=!0,A="0",S="=");var B=(w&&w.prefix!==void 0?w.prefix:"")+(T==="$"?n:T==="#"&&/[boxX]/.test(q)?"0"+q.toLowerCase():""),z=(T==="$"?r:/[%p]/.test(q)?o:"")+(w&&w.suffix!==void 0?w.suffix:""),F=zB[q],$=/[defgprs%]/.test(q);K=K===void 0?6:/[gprs]/.test(q)?Math.max(1,Math.min(21,K)):Math.max(0,Math.min(20,K));function Y(X){var J=B,ye=z,ne,de,be;if(q==="c")ye=F(X)+ye,X="";else{X=+X;var Ce=X<0||1/X<0;if(X=isNaN(X)?h:F(Math.abs(X),K),Z&&(X=DCe(X)),Ce&&+X==0&&C!=="+"&&(Ce=!1),J=(Ce?C==="("?C:c:C==="-"||C==="("?"":C)+J,ye=(q==="s"&&!isNaN(X)&&PN!==void 0?$B[8+PN/3]:"")+ye+(Ce&&C==="("?")":""),$){for(ne=-1,de=X.length;++nebe||be>57){ye=(be===46?i+X.slice(ne+1):X.slice(ne))+ye,X=X.slice(0,ne);break}}}L&&!D&&(X=t(X,1/0));var Ke=J.length+X.length+ye.length,G=Ke>1)+J+X+ye+G.slice(Ke);break;default:X=G+J+X+ye;break}return a(X)}return Y.toString=function(){return y+""},Y}function m(y,w){var A=Math.max(-8,Math.min(8,Math.floor(Tg(w)/3)))*3,S=Math.pow(10,-A),C=f((y=Ty(y),y.type="f",y),{suffix:$B[8+A/3]});return function(T){return C(S*T)}}return{format:f,formatPrefix:m}}var hw,N3,SQ;UCe({thousands:",",grouping:[3],currency:["$",""]});function UCe(e){return hw=LCe(e),N3=hw.format,SQ=hw.formatPrefix,hw}function BCe(e){return Math.max(0,-Tg(Math.abs(e)))}function zCe(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Tg(t)/3)))*3-Tg(Math.abs(e)))}function VCe(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Tg(t)-Tg(e))+1}function CQ(e,t,n,r){var i=Qj(e,t,n),a;switch(r=Ty(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=zCe(i,o))&&(r.precision=a),SQ(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=VCe(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=BCe(i))&&(r.precision=a-(r.type==="%")*2);break}}return N3(r)}function Of(e){var t=e.domain;return e.ticks=function(n){var r=t();return Yj(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var i=t();return CQ(i[0],i[i.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=t(),i=0,a=r.length-1,o=r[i],c=r[a],h,f,m=10;for(c0;){if(f=Xj(o,c,n),f===h)return r[i]=o,r[a]=c,t(r);if(f>0)o=Math.floor(o/f)*f,c=Math.ceil(c/f)*f;else if(f<0)o=Math.ceil(o*f)/f,c=Math.floor(c*f)/f;else break;h=f}return e},e}function jQ(){var e=v3();return e.copy=function(){return yb(e,jQ())},vc.apply(e,arguments),Of(e)}function IQ(e){var t;function n(r){return r==null||isNaN(r=+r)?t:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(e=Array.from(r,IN),n):e.slice()},n.unknown=function(r){return arguments.length?(t=r,n):t},n.copy=function(){return IQ(e).unknown(t)},e=arguments.length?Array.from(e,IN):[0,1],Of(n)}function TQ(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],a=e[r],o;return aMath.pow(e,t)}function qCe(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function qB(e){return(t,n)=>-e(-t,n)}function E3(e){const t=e(HB,GB),n=t.domain;let r=10,i,a;function o(){return i=qCe(r),a=GCe(r),n()[0]<0?(i=qB(i),a=qB(a),e(FCe,$Ce)):e(HB,GB),t}return t.base=function(c){return arguments.length?(r=+c,o()):r},t.domain=function(c){return arguments.length?(n(c),o()):n()},t.ticks=c=>{const h=n();let f=h[0],m=h[h.length-1];const y=m0){for(;w<=A;++w)for(S=1;Sm)break;D.push(C)}}else for(;w<=A;++w)for(S=r-1;S>=1;--S)if(C=w>0?S/a(-w):S*a(w),!(Cm)break;D.push(C)}D.length*2{if(c==null&&(c=10),h==null&&(h=r===10?"s":","),typeof h!="function"&&(!(r%1)&&(h=Ty(h)).precision==null&&(h.trim=!0),h=N3(h)),c===1/0)return h;const f=Math.max(1,r*c/t.ticks().length);return m=>{let y=m/a(Math.round(i(m)));return y*rn(TQ(n(),{floor:c=>a(Math.floor(i(c))),ceil:c=>a(Math.ceil(i(c)))})),t}function PQ(){const e=E3(EA()).domain([1,10]);return e.copy=()=>yb(e,PQ()).base(e.base()),vc.apply(e,arguments),e}function WB(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function KB(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function A3(e){var t=1,n=e(WB(t),KB(t));return n.constant=function(r){return arguments.length?e(WB(t=+r),KB(t)):t},Of(n)}function OQ(){var e=A3(EA());return e.copy=function(){return yb(e,OQ()).constant(e.constant())},vc.apply(e,arguments)}function YB(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function WCe(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function KCe(e){return e<0?-e*e:e*e}function _3(e){var t=e(Go,Go),n=1;function r(){return n===1?e(Go,Go):n===.5?e(WCe,KCe):e(YB(n),YB(1/n))}return t.exponent=function(i){return arguments.length?(n=+i,r()):n},Of(t)}function k3(){var e=_3(EA());return e.copy=function(){return yb(e,k3()).exponent(e.exponent())},vc.apply(e,arguments),e}function YCe(){return k3.apply(null,arguments).exponent(.5)}function XB(e){return Math.sign(e)*e*e}function XCe(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function RQ(){var e=v3(),t=[0,1],n=!1,r;function i(a){var o=XCe(e(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return e.invert(XB(a))},i.domain=function(a){return arguments.length?(e.domain(a),i):e.domain()},i.range=function(a){return arguments.length?(e.range((t=Array.from(a,IN)).map(XB)),i):t.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(n=!!a,i):n},i.clamp=function(a){return arguments.length?(e.clamp(a),i):e.clamp()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return RQ(e.domain(),t).round(n).clamp(e.clamp()).unknown(r)},vc.apply(i,arguments),Of(i)}function DQ(){var e=[],t=[],n=[],r;function i(){var o=0,c=Math.max(1,t.length);for(n=new Array(c-1);++o0?n[c-1]:e[0],c=n?[r[n-1],t]:[r[f-1],r[f]]},o.unknown=function(h){return arguments.length&&(a=h),o},o.thresholds=function(){return r.slice()},o.copy=function(){return MQ().domain([e,t]).range(i).unknown(a)},vc.apply(Of(o),arguments)}function LQ(){var e=[.5],t=[0,1],n,r=1;function i(a){return a!=null&&a<=a?t[gb(e,a,0,r)]:n}return i.domain=function(a){return arguments.length?(e=Array.from(a),r=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(a){return arguments.length?(t=Array.from(a),r=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(a){var o=t.indexOf(a);return[e[o-1],e[o]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return LQ().domain(e).range(t).unknown(n)},vc.apply(i,arguments)}const mS=new Date,gS=new Date;function Ia(e,t,n,r){function i(a){return e(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(e(a=new Date(+a)),a),i.ceil=a=>(e(a=new Date(a-1)),t(a,1),e(a),a),i.round=a=>{const o=i(a),c=i.ceil(a);return a-o(t(a=new Date(+a),o==null?1:Math.floor(o)),a),i.range=(a,o,c)=>{const h=[];if(a=i.ceil(a),c=c==null?1:Math.floor(c),!(a0))return h;let f;do h.push(f=new Date(+a)),t(a,c),e(a);while(fIa(o=>{if(o>=o)for(;e(o),!a(o);)o.setTime(o-1)},(o,c)=>{if(o>=o)if(c<0)for(;++c<=0;)for(;t(o,-1),!a(o););else for(;--c>=0;)for(;t(o,1),!a(o););}),n&&(i.count=(a,o)=>(mS.setTime(+a),gS.setTime(+o),e(mS),e(gS),Math.floor(n(mS,gS))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?o=>r(o)%a===0:o=>i.count(0,o)%a===0):i)),i}const ON=Ia(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);ON.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Ia(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):ON);ON.range;const Od=1e3,pc=Od*60,Rd=pc*60,Wd=Rd*24,S3=Wd*7,QB=Wd*30,xS=Wd*365,Ip=Ia(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Od)},(e,t)=>(t-e)/Od,e=>e.getUTCSeconds());Ip.range;const C3=Ia(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Od)},(e,t)=>{e.setTime(+e+t*pc)},(e,t)=>(t-e)/pc,e=>e.getMinutes());C3.range;const j3=Ia(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*pc)},(e,t)=>(t-e)/pc,e=>e.getUTCMinutes());j3.range;const I3=Ia(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Od-e.getMinutes()*pc)},(e,t)=>{e.setTime(+e+t*Rd)},(e,t)=>(t-e)/Rd,e=>e.getHours());I3.range;const T3=Ia(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*Rd)},(e,t)=>(t-e)/Rd,e=>e.getUTCHours());T3.range;const bb=Ia(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*pc)/Wd,e=>e.getDate()-1);bb.range;const AA=Ia(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Wd,e=>e.getUTCDate()-1);AA.range;const UQ=Ia(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Wd,e=>Math.floor(e/Wd));UQ.range;function _m(e){return Ia(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,n)=>{t.setDate(t.getDate()+n*7)},(t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*pc)/S3)}const _A=_m(0),RN=_m(1),QCe=_m(2),ZCe=_m(3),Pg=_m(4),JCe=_m(5),eje=_m(6);_A.range;RN.range;QCe.range;ZCe.range;Pg.range;JCe.range;eje.range;function km(e){return Ia(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCDate(t.getUTCDate()+n*7)},(t,n)=>(n-t)/S3)}const kA=km(0),DN=km(1),tje=km(2),nje=km(3),Og=km(4),rje=km(5),ije=km(6);kA.range;DN.range;tje.range;nje.range;Og.range;rje.range;ije.range;const P3=Ia(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());P3.range;const O3=Ia(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());O3.range;const Kd=Ia(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());Kd.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Ia(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)});Kd.range;const Yd=Ia(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());Yd.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Ia(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)});Yd.range;function BQ(e,t,n,r,i,a){const o=[[Ip,1,Od],[Ip,5,5*Od],[Ip,15,15*Od],[Ip,30,30*Od],[a,1,pc],[a,5,5*pc],[a,15,15*pc],[a,30,30*pc],[i,1,Rd],[i,3,3*Rd],[i,6,6*Rd],[i,12,12*Rd],[r,1,Wd],[r,2,2*Wd],[n,1,S3],[t,1,QB],[t,3,3*QB],[e,1,xS]];function c(f,m,y){const w=mT).right(o,w);if(A===o.length)return e.every(Qj(f/xS,m/xS,y));if(A===0)return ON.every(Math.max(Qj(f,m,y),1));const[S,C]=o[w/o[A-1][2]53)return null;"w"in Ue||(Ue.w=1),"Z"in Ue?(St=bS(c1(Ue.y,0,1)),tn=St.getUTCDay(),St=tn>4||tn===0?DN.ceil(St):DN(St),St=AA.offset(St,(Ue.V-1)*7),Ue.y=St.getUTCFullYear(),Ue.m=St.getUTCMonth(),Ue.d=St.getUTCDate()+(Ue.w+6)%7):(St=yS(c1(Ue.y,0,1)),tn=St.getDay(),St=tn>4||tn===0?RN.ceil(St):RN(St),St=bb.offset(St,(Ue.V-1)*7),Ue.y=St.getFullYear(),Ue.m=St.getMonth(),Ue.d=St.getDate()+(Ue.w+6)%7)}else("W"in Ue||"U"in Ue)&&("w"in Ue||(Ue.w="u"in Ue?Ue.u%7:"W"in Ue?1:0),tn="Z"in Ue?bS(c1(Ue.y,0,1)).getUTCDay():yS(c1(Ue.y,0,1)).getDay(),Ue.m=0,Ue.d="W"in Ue?(Ue.w+6)%7+Ue.W*7-(tn+5)%7:Ue.w+Ue.U*7-(tn+6)%7);return"Z"in Ue?(Ue.H+=Ue.Z/100|0,Ue.M+=Ue.Z%100,bS(Ue)):yS(Ue)}}function z(ft,Ee,yt,Ue){for(var Vt=0,St=Ee.length,tn=yt.length,Pt,Nt;Vt=tn)return-1;if(Pt=Ee.charCodeAt(Vt++),Pt===37){if(Pt=Ee.charAt(Vt++),Nt=Z[Pt in ZB?Ee.charAt(Vt++):Pt],!Nt||(Ue=Nt(ft,yt,Ue))<0)return-1}else if(Pt!=yt.charCodeAt(Ue++))return-1}return Ue}function F(ft,Ee,yt){var Ue=f.exec(Ee.slice(yt));return Ue?(ft.p=m.get(Ue[0].toLowerCase()),yt+Ue[0].length):-1}function $(ft,Ee,yt){var Ue=A.exec(Ee.slice(yt));return Ue?(ft.w=S.get(Ue[0].toLowerCase()),yt+Ue[0].length):-1}function Y(ft,Ee,yt){var Ue=y.exec(Ee.slice(yt));return Ue?(ft.w=w.get(Ue[0].toLowerCase()),yt+Ue[0].length):-1}function X(ft,Ee,yt){var Ue=D.exec(Ee.slice(yt));return Ue?(ft.m=V.get(Ue[0].toLowerCase()),yt+Ue[0].length):-1}function J(ft,Ee,yt){var Ue=C.exec(Ee.slice(yt));return Ue?(ft.m=T.get(Ue[0].toLowerCase()),yt+Ue[0].length):-1}function ye(ft,Ee,yt){return z(ft,t,Ee,yt)}function ne(ft,Ee,yt){return z(ft,n,Ee,yt)}function de(ft,Ee,yt){return z(ft,r,Ee,yt)}function be(ft){return o[ft.getDay()]}function Ce(ft){return a[ft.getDay()]}function Ke(ft){return h[ft.getMonth()]}function G(ft){return c[ft.getMonth()]}function se(ft){return i[+(ft.getHours()>=12)]}function xe(ft){return 1+~~(ft.getMonth()/3)}function re(ft){return o[ft.getUTCDay()]}function Me(ft){return a[ft.getUTCDay()]}function nt(ft){return h[ft.getUTCMonth()]}function ze(ft){return c[ft.getUTCMonth()]}function Tt(ft){return i[+(ft.getUTCHours()>=12)]}function It(ft){return 1+~~(ft.getUTCMonth()/3)}return{format:function(ft){var Ee=q(ft+="",L);return Ee.toString=function(){return ft},Ee},parse:function(ft){var Ee=B(ft+="",!1);return Ee.toString=function(){return ft},Ee},utcFormat:function(ft){var Ee=q(ft+="",K);return Ee.toString=function(){return ft},Ee},utcParse:function(ft){var Ee=B(ft+="",!0);return Ee.toString=function(){return ft},Ee}}}var ZB={"-":"",_:" ",0:"0"},Ya=/^\s*\d+/,uje=/^%/,dje=/[\\^$*+?|[\]().{}]/g;function Si(e,t,n){var r=e<0?"-":"",i=(r?-e:e)+"",a=i.length;return r+(a[t.toLowerCase(),n]))}function fje(e,t,n){var r=Ya.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function pje(e,t,n){var r=Ya.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function mje(e,t,n){var r=Ya.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function gje(e,t,n){var r=Ya.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function xje(e,t,n){var r=Ya.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function JB(e,t,n){var r=Ya.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function ez(e,t,n){var r=Ya.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function yje(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function bje(e,t,n){var r=Ya.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function vje(e,t,n){var r=Ya.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function tz(e,t,n){var r=Ya.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function wje(e,t,n){var r=Ya.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function nz(e,t,n){var r=Ya.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function Nje(e,t,n){var r=Ya.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function Eje(e,t,n){var r=Ya.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function Aje(e,t,n){var r=Ya.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function _je(e,t,n){var r=Ya.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function kje(e,t,n){var r=uje.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function Sje(e,t,n){var r=Ya.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function Cje(e,t,n){var r=Ya.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function rz(e,t){return Si(e.getDate(),t,2)}function jje(e,t){return Si(e.getHours(),t,2)}function Ije(e,t){return Si(e.getHours()%12||12,t,2)}function Tje(e,t){return Si(1+bb.count(Kd(e),e),t,3)}function zQ(e,t){return Si(e.getMilliseconds(),t,3)}function Pje(e,t){return zQ(e,t)+"000"}function Oje(e,t){return Si(e.getMonth()+1,t,2)}function Rje(e,t){return Si(e.getMinutes(),t,2)}function Dje(e,t){return Si(e.getSeconds(),t,2)}function Mje(e){var t=e.getDay();return t===0?7:t}function Lje(e,t){return Si(_A.count(Kd(e)-1,e),t,2)}function VQ(e){var t=e.getDay();return t>=4||t===0?Pg(e):Pg.ceil(e)}function Uje(e,t){return e=VQ(e),Si(Pg.count(Kd(e),e)+(Kd(e).getDay()===4),t,2)}function Bje(e){return e.getDay()}function zje(e,t){return Si(RN.count(Kd(e)-1,e),t,2)}function Vje(e,t){return Si(e.getFullYear()%100,t,2)}function Fje(e,t){return e=VQ(e),Si(e.getFullYear()%100,t,2)}function $je(e,t){return Si(e.getFullYear()%1e4,t,4)}function Hje(e,t){var n=e.getDay();return e=n>=4||n===0?Pg(e):Pg.ceil(e),Si(e.getFullYear()%1e4,t,4)}function Gje(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+Si(t/60|0,"0",2)+Si(t%60,"0",2)}function iz(e,t){return Si(e.getUTCDate(),t,2)}function qje(e,t){return Si(e.getUTCHours(),t,2)}function Wje(e,t){return Si(e.getUTCHours()%12||12,t,2)}function Kje(e,t){return Si(1+AA.count(Yd(e),e),t,3)}function FQ(e,t){return Si(e.getUTCMilliseconds(),t,3)}function Yje(e,t){return FQ(e,t)+"000"}function Xje(e,t){return Si(e.getUTCMonth()+1,t,2)}function Qje(e,t){return Si(e.getUTCMinutes(),t,2)}function Zje(e,t){return Si(e.getUTCSeconds(),t,2)}function Jje(e){var t=e.getUTCDay();return t===0?7:t}function eIe(e,t){return Si(kA.count(Yd(e)-1,e),t,2)}function $Q(e){var t=e.getUTCDay();return t>=4||t===0?Og(e):Og.ceil(e)}function tIe(e,t){return e=$Q(e),Si(Og.count(Yd(e),e)+(Yd(e).getUTCDay()===4),t,2)}function nIe(e){return e.getUTCDay()}function rIe(e,t){return Si(DN.count(Yd(e)-1,e),t,2)}function iIe(e,t){return Si(e.getUTCFullYear()%100,t,2)}function sIe(e,t){return e=$Q(e),Si(e.getUTCFullYear()%100,t,2)}function aIe(e,t){return Si(e.getUTCFullYear()%1e4,t,4)}function oIe(e,t){var n=e.getUTCDay();return e=n>=4||n===0?Og(e):Og.ceil(e),Si(e.getUTCFullYear()%1e4,t,4)}function lIe(){return"+0000"}function sz(){return"%"}function az(e){return+e}function oz(e){return Math.floor(+e/1e3)}var N0,HQ,GQ;cIe({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function cIe(e){return N0=cje(e),HQ=N0.format,N0.parse,GQ=N0.utcFormat,N0.utcParse,N0}function uIe(e){return new Date(e)}function dIe(e){return e instanceof Date?+e:+new Date(+e)}function R3(e,t,n,r,i,a,o,c,h,f){var m=v3(),y=m.invert,w=m.domain,A=f(".%L"),S=f(":%S"),C=f("%I:%M"),T=f("%I %p"),D=f("%a %d"),V=f("%b %d"),L=f("%B"),K=f("%Y");function Z(q){return(h(q)t(i/(e.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,a)=>JSe(e,a/r))},n.copy=function(){return YQ(t).domain(e)},nh.apply(n,arguments)}function CA(){var e=0,t=.5,n=1,r=1,i,a,o,c,h,f=Go,m,y=!1,w;function A(C){return isNaN(C=+C)?w:(C=.5+((C=+m(C))-a)*(r*C{if(e!=null){var{scale:r,type:i}=e;if(r==="auto")return i==="category"&&n&&(n.indexOf("LineChart")>=0||n.indexOf("AreaChart")>=0||n.indexOf("ComposedChart")>=0&&!t)?"point":i==="category"?"band":"linear";if(typeof r=="string")return yIe(r)?r:"point"}};function bIe(e,t){for(var n=0,r=e.length,i=e[0]t)?n=a+1:r=a}return n}function tZ(e,t){if(e){var n=t??e.domain(),r=n.map(a=>{var o;return(o=e(a))!==null&&o!==void 0?o:0}),i=e.range();if(!(n.length===0||i.length<2))return a=>{var o,c,h=bIe(r,a);if(h<=0)return n[0];if(h>=n.length)return n[n.length-1];var f=(o=r[h-1])!==null&&o!==void 0?o:0,m=(c=r[h])!==null&&c!==void 0?c:0;return Math.abs(a-f)<=Math.abs(a-m)?n[h-1]:n[h]}}}function vIe(e){if(e!=null)return"invert"in e&&typeof e.invert=="function"?e.invert.bind(e):tZ(e,void 0)}function cz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function MN(e){for(var t=1;te.cartesianAxis.xAxis[t],rh=(e,t)=>{var n=nZ(e,t);return n??va},wa={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:nI,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"left",padding:{top:0,bottom:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"number",unit:void 0,niceTicks:"auto",width:cb},rZ=(e,t)=>e.cartesianAxis.yAxis[t],ih=(e,t)=>{var n=rZ(e,t);return n??wa},AIe={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},U3=(e,t)=>{var n=e.cartesianAxis.zAxis[t];return n??AIe},Xo=(e,t,n)=>{switch(t){case"xAxis":return rh(e,n);case"yAxis":return ih(e,n);case"zAxis":return U3(e,n);case"angleAxis":return u3(e,n);case"radiusAxis":return d3(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},_Ie=(e,t,n)=>{switch(t){case"xAxis":return rh(e,n);case"yAxis":return ih(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},vb=(e,t,n)=>{switch(t){case"xAxis":return rh(e,n);case"yAxis":return ih(e,n);case"angleAxis":return u3(e,n);case"radiusAxis":return d3(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},iZ=e=>e.graphicalItems.cartesianItems.some(t=>t.type==="bar")||e.graphicalItems.polarItems.some(t=>t.type==="radialBar");function sZ(e,t){return n=>{switch(e){case"xAxis":return"xAxisId"in n&&n.xAxisId===t;case"yAxis":return"yAxisId"in n&&n.yAxisId===t;case"zAxis":return"zAxisId"in n&&n.zAxisId===t;case"angleAxis":return"angleAxisId"in n&&n.angleAxisId===t;case"radiusAxis":return"radiusAxisId"in n&&n.radiusAxisId===t;default:return!1}}}var wb=e=>e.graphicalItems.cartesianItems,kIe=Ze([Wa,yA],sZ),aZ=(e,t,n)=>e.filter(n).filter(r=>(t==null?void 0:t.includeHidden)===!0?!0:!r.hide),ex=Ze([wb,Xo,kIe],aZ,{memoizeOptions:{resultEqualityCheck:NA}}),oZ=Ze([ex],e=>e.filter(t=>t.type==="area"||t.type==="bar").filter(vA)),lZ=e=>e.filter(t=>!("stackId"in t)||t.stackId===void 0),SIe=Ze([ex],lZ),cZ=e=>e.map(t=>t.data).filter(Boolean).flat(1),CIe=Ze([ex],e=>e.some(t=>!t.data)),uZ=Ze([ex],cZ,{memoizeOptions:{resultEqualityCheck:NA}}),dZ=(e,t)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=t;return e.length>0?e:n.slice(r,i+1)},B3=Ze([uZ,mb],dZ),jIe=(e,t,n)=>(t==null?void 0:t.dataKey)!=null?e.map(r=>({value:Us(r,t.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>e.map(i=>({value:Us(i,r)}))):e.map(r=>({value:r})),hZ=(e,t,n,r,i,a)=>{var{chartData:o=[],dataStartIndex:c,dataEndIndex:h}=r,f=jIe(e,t,n);if(i&&(t==null?void 0:t.dataKey)!=null&&a.length>0){var m=o.slice(c,h+1),y=m.map(w=>({value:Us(w,t.dataKey)})).filter(w=>w.value!=null);return[...y,...f]}return f},Nb=Ze([B3,Xo,ex,mb,CIe,uZ],hZ);function ng(e){if(Hu(e)||e instanceof Date){var t=Number(e);if(Yr(t))return t}}function uz(e){if(Array.isArray(e)){var t=[ng(e[0]),ng(e[1])];return Lu(t)?t:void 0}var n=ng(e);if(n!=null)return[n,n]}function Wu(e){return e.map(ng).filter(yl)}function IIe(e,t){var n=ng(e),r=ng(t);return n==null&&r==null?0:n==null?-1:r==null?1:n-r}var TIe=Ze([Nb],e=>e==null?void 0:e.map(t=>t.value).sort(IIe));function fZ(e,t){switch(e){case"xAxis":return t.direction==="x";case"yAxis":return t.direction==="y";default:return!1}}function PIe(e,t,n){if(!n)return[];if(!n.length)return[];var r;if(typeof t=="number"&&!Wc(t))r=t;else if(Array.isArray(t)){var i=Wu(t);i.length>0&&(r=Math.max(...i))}return r==null?[]:Wu(n.flatMap(a=>{var o=Us(e,a.dataKey),c,h;if(Array.isArray(o)?[c,h]=o:c=h=o,!(!Yr(c)||!Yr(h)))return[r-c,r+h]}))}var Ta=e=>{var t=Ka(e),n=Zg(e);return vb(e,t,n)},Rg=Ze([Ta],e=>e==null?void 0:e.dataKey),OIe=Ze([oZ,mb,Ta],bQ),pZ=(e,t,n,r)=>{var i={},a=t.reduce((o,c)=>{if(c.stackId==null)return o;var h=o[c.stackId];return h==null&&(h=[]),h.push(c),o[c.stackId]=h,o},i);return Object.fromEntries(Object.entries(a).map(o=>{var[c,h]=o,f=r?[...h].reverse():h,m=f.map(bA);return[c,{stackedData:g5e(e,m,n),graphicalItems:f}]}))},LN=Ze([OIe,oZ,pA,hQ],pZ),mZ=(e,t,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=t;if(r==null&&n!=="zAxis"){var o=v5e(e,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},RIe=Ze([Xo],e=>e.allowDataOverflow),z3=e=>{var t;if(e==null||!("domain"in e))return nI;if(e.domain!=null)return e.domain;if("ticks"in e&&e.ticks!=null){if(e.type==="number"){var n=Wu(e.ticks);return[Math.min(...n),Math.max(...n)]}if(e.type==="category")return e.ticks.map(String)}return(t=e==null?void 0:e.domain)!==null&&t!==void 0?t:nI},gZ=Ze([Xo],z3),xZ=Ze([gZ,RIe],JX),DIe=Ze([LN,Zc,Wa,xZ],mZ,{memoizeOptions:{resultEqualityCheck:wA}}),V3=e=>e.errorBars,MIe=(e,t,n)=>e.flatMap(r=>t[r.id]).filter(Boolean).filter(r=>fZ(n,r)),UN=function(){for(var t=arguments.length,n=new Array(t),r=0;r5&&arguments[5]!==void 0?arguments[5]:[],c,h;if(r.length>0&&r.forEach(f=>{var m,y=f.data!=null?[...f.data]:o,w=(m=i[f.id])===null||m===void 0?void 0:m.filter(A=>fZ(a,A));y.forEach(A=>{var S,C=Us(A,(S=n.dataKey)!==null&&S!==void 0?S:f.dataKey),T=PIe(A,C,w);if(T.length>=2){var D=Math.min(...T),V=Math.max(...T);(c==null||Dh)&&(h=V)}var L=uz(C);L!=null&&(c=c==null?L[0]:Math.min(c,L[0]),h=h==null?L[1]:Math.max(h,L[1]))})}),(n==null?void 0:n.dataKey)!=null&&r.length===0&&t.forEach(f=>{var m=uz(Us(f,n.dataKey));m!=null&&(c=c==null?m[0]:Math.min(c,m[0]),h=h==null?m[1]:Math.max(h,m[1]))}),Yr(c)&&Yr(h))return[c,h]},LIe=Ze([B3,Xo,SIe,V3,Wa,ASe],yZ,{memoizeOptions:{resultEqualityCheck:wA}});function UIe(e){var{value:t}=e;if(Hu(t)||t instanceof Date)return t}var BIe=(e,t,n)=>{var r=e.map(UIe).filter(i=>i!=null);return n&&(t.dataKey==null||t.allowDuplicatedCategory&&CY(r))?QX(0,e.length):t.allowDuplicatedCategory?r:Array.from(new Set(r))},bZ=e=>e.referenceElements.dots,tx=(e,t,n)=>e.filter(r=>r.ifOverflow==="extendDomain").filter(r=>t==="xAxis"?r.xAxisId===n:r.yAxisId===n),zIe=Ze([bZ,Wa,yA],tx),vZ=e=>e.referenceElements.areas,VIe=Ze([vZ,Wa,yA],tx),wZ=e=>e.referenceElements.lines,FIe=Ze([wZ,Wa,yA],tx),NZ=(e,t)=>{if(e!=null){var n=Wu(e.map(r=>t==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},$Ie=Ze(zIe,Wa,NZ),EZ=(e,t)=>{if(e!=null){var n=Wu(e.flatMap(r=>[t==="xAxis"?r.x1:r.y1,t==="xAxis"?r.x2:r.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},HIe=Ze([VIe,Wa],EZ);function GIe(e){var t;if(e.x!=null)return Wu([e.x]);var n=(t=e.segment)===null||t===void 0?void 0:t.map(r=>r.x);return n==null||n.length===0?[]:Wu(n)}function qIe(e){var t;if(e.y!=null)return Wu([e.y]);var n=(t=e.segment)===null||t===void 0?void 0:t.map(r=>r.y);return n==null||n.length===0?[]:Wu(n)}var AZ=(e,t)=>{if(e!=null){var n=e.flatMap(r=>t==="xAxis"?GIe(r):qIe(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},WIe=Ze([FIe,Wa],AZ),KIe=Ze($Ie,WIe,HIe,(e,t,n)=>UN(e,n,t)),_Z=(e,t,n,r,i,a,o,c)=>{if(n!=null)return n;var h=o==="vertical"&&c==="xAxis"||o==="horizontal"&&c==="yAxis",f=h?UN(r,a,i):UN(a,i);return kSe(t,f,e.allowDataOverflow)},YIe=Ze([Xo,gZ,xZ,DIe,LIe,KIe,Ci,Wa],_Z,{memoizeOptions:{resultEqualityCheck:wA}}),XIe=[0,1],kZ=(e,t,n,r,i,a,o)=>{if(!((e==null||n==null||n.length===0)&&o===void 0)){var{dataKey:c,type:h}=e,f=Qc(t,a);if(f&&c==null){var m;return QX(0,(m=n==null?void 0:n.length)!==null&&m!==void 0?m:0)}return h==="category"?BIe(r,e,f):i==="expand"&&!f?XIe:o}},F3=Ze([Xo,Ci,B3,Nb,pA,Wa,YIe],kZ),nx=Ze([Xo,iZ,o3],eZ),SZ=(e,t,n)=>{var{niceTicks:r}=t;if(r!=="none"){var i=z3(t),a=Array.isArray(i)&&(i[0]==="auto"||i[1]==="auto");if((r==="snap125"||r==="adaptive")&&t!=null&&t.tickCount&&Lu(e)){if(a)return vB(e,t.tickCount,t.allowDecimals,r);if(t.type==="number")return wB(e,t.tickCount,t.allowDecimals,r)}if(r==="auto"&&n==="linear"&&t!=null&&t.tickCount){if(a&&Lu(e))return vB(e,t.tickCount,t.allowDecimals,"adaptive");if(t.type==="number"&&Lu(e))return wB(e,t.tickCount,t.allowDecimals,"adaptive")}}},$3=Ze([F3,vb,nx],SZ),CZ=(e,t,n,r)=>{if(r!=="angleAxis"&&(e==null?void 0:e.type)==="number"&&Lu(t)&&Array.isArray(n)&&n.length>0){var i,a,o=t[0],c=(i=n[0])!==null&&i!==void 0?i:0,h=t[1],f=(a=n[n.length-1])!==null&&a!==void 0?a:0;return[Math.min(o,c),Math.max(h,f)]}return t},QIe=Ze([Xo,F3,$3,Wa],CZ),ZIe=Ze(Nb,Xo,(e,t)=>{if(!(!t||t.type!=="number")){var n=1/0,r=Array.from(Wu(e.map(y=>y.value))).sort((y,w)=>y-w),i=r[0],a=r[r.length-1];if(i==null||a==null)return 1/0;var o=a-i;if(o===0)return 1/0;for(var c=0;ci,(e,t,n,r,i)=>{if(!Yr(e))return 0;var a=t==="vertical"?r.height:r.width;if(i==="gap")return e*a/2;if(i==="no-gap"){var o=Kc(n,e*a),c=e*a/2;return c-o-(c-o)/a*o}return 0}),JIe=(e,t,n)=>{var r=rh(e,t);return r==null||typeof r.padding!="string"?0:jZ(e,"xAxis",t,n,r.padding)},eTe=(e,t,n)=>{var r=ih(e,t);return r==null||typeof r.padding!="string"?0:jZ(e,"yAxis",t,n,r.padding)},tTe=Ze(rh,JIe,(e,t)=>{var n,r;if(e==null)return{left:0,right:0};var{padding:i}=e;return typeof i=="string"?{left:t,right:t}:{left:((n=i.left)!==null&&n!==void 0?n:0)+t,right:((r=i.right)!==null&&r!==void 0?r:0)+t}}),nTe=Ze(ih,eTe,(e,t)=>{var n,r;if(e==null)return{top:0,bottom:0};var{padding:i}=e;return typeof i=="string"?{top:t,bottom:t}:{top:((n=i.top)!==null&&n!==void 0?n:0)+t,bottom:((r=i.bottom)!==null&&r!==void 0?r:0)+t}}),rTe=Ze([Ga,tTe,cA,lA,(e,t,n)=>n],(e,t,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[e.left+t.left,e.left+e.width-t.right]}),iTe=Ze([Ga,Ci,nTe,cA,lA,(e,t,n)=>n],(e,t,n,r,i,a)=>{var{padding:o}=i;return a?[r.height-o.bottom,o.top]:t==="horizontal"?[e.top+e.height-n.bottom,e.top+n.top]:[e.top+n.top,e.top+e.height-n.bottom]}),Eb=(e,t,n,r)=>{var i;switch(t){case"xAxis":return rTe(e,n,r);case"yAxis":return iTe(e,n,r);case"zAxis":return(i=U3(e,n))===null||i===void 0?void 0:i.range;case"angleAxis":return gQ(e);case"radiusAxis":return xQ(e,n);default:return}},IZ=Ze([Xo,Eb],mA),sTe=Ze([nx,QIe],VSe),H3=Ze([Xo,nx,sTe,IZ],L3),TZ=(e,t,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=Qc(e,r);if(o&&(i==="number"||a!=="auto"))return t.map(c=>c.value)}},G3=Ze([Ci,Nb,vb,Wa],TZ),jA=Ze([H3],f3);Ze([H3],vIe);Ze([H3,TIe],tZ);Ze([ex,V3,Wa],MIe);function PZ(e,t){return e.idt.id?1:0}var IA=(e,t)=>t,TA=(e,t,n)=>n,aTe=Ze(aA,IA,TA,(e,t,n)=>e.filter(r=>r.orientation===t).filter(r=>r.mirror===n).sort(PZ)),oTe=Ze(oA,IA,TA,(e,t,n)=>e.filter(r=>r.orientation===t).filter(r=>r.mirror===n).sort(PZ)),OZ=(e,t)=>({width:e.width,height:t.height}),lTe=(e,t)=>{var n=typeof t.width=="number"?t.width:cb;return{width:n,height:e.height}},RZ=Ze(Ga,rh,OZ),cTe=(e,t,n)=>{switch(t){case"top":return e.top;case"bottom":return n-e.bottom;default:return 0}},uTe=(e,t,n)=>{switch(t){case"left":return e.left;case"right":return n-e.right;default:return 0}},dTe=Ze(th,Ga,aTe,IA,TA,(e,t,n,r,i)=>{var a={},o;return n.forEach(c=>{var h=OZ(t,c);o==null&&(o=cTe(t,r,e));var f=r==="top"&&!i||r==="bottom"&&i;a[c.id]=o-Number(f)*h.height,o+=(f?-1:1)*h.height}),a}),hTe=Ze(eh,Ga,oTe,IA,TA,(e,t,n,r,i)=>{var a={},o;return n.forEach(c=>{var h=lTe(t,c);o==null&&(o=uTe(t,r,e));var f=r==="left"&&!i||r==="right"&&i;a[c.id]=o-Number(f)*h.width,o+=(f?-1:1)*h.width}),a}),fTe=(e,t)=>{var n=rh(e,t);if(n!=null)return dTe(e,n.orientation,n.mirror)},pTe=Ze([Ga,rh,fTe,(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n==null?void 0:n[r];return i==null?{x:e.left,y:0}:{x:e.left,y:i}}}),mTe=(e,t)=>{var n=ih(e,t);if(n!=null)return hTe(e,n.orientation,n.mirror)},gTe=Ze([Ga,ih,mTe,(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n==null?void 0:n[r];return i==null?{x:0,y:e.top}:{x:i,y:e.top}}}),DZ=Ze(Ga,ih,(e,t)=>{var n=typeof t.width=="number"?t.width:cb;return{width:n,height:e.height}}),dz=(e,t,n)=>{switch(t){case"xAxis":return RZ(e,n).width;case"yAxis":return DZ(e,n).height;default:return}},MZ=(e,t,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,c=Qc(e,r),h=t.map(m=>m.value),f=h.filter(m=>m!=null);if(o&&c&&a==="category"&&i&&CY(f))return h}},q3=Ze([Ci,Nb,Xo,Wa],MZ),hz=Ze([Ci,_Ie,nx,jA,q3,G3,Eb,$3,Wa],(e,t,n,r,i,a,o,c,h)=>{if(t!=null){var f=Qc(e,h);return{angle:t.angle,interval:t.interval,minTickGap:t.minTickGap,orientation:t.orientation,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,axisType:h,categoricalDomain:a,duplicateDomain:i,isCategorical:f,niceTicks:c,range:o,realScaleType:n,scale:r}}}),xTe=(e,t,n,r,i,a,o,c,h)=>{if(!(t==null||r==null)){var f=Qc(e,h),{type:m,ticks:y,tickCount:w}=t,A=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,S=m==="category"&&r.bandwidth?r.bandwidth()/A:0;S=h==="angleAxis"&&a!=null&&a.length>=2?xl(a[0]-a[1])*2*S:S;var C=y||i;return C?C.map((T,D)=>{var V=o?o.indexOf(T):T,L=r.map(V);return Yr(L)?{index:D,coordinate:L+S,value:T,offset:S}:null}).filter(yl):f&&c?c.map((T,D)=>{var V=r.map(T);return Yr(V)?{coordinate:V+S,value:T,index:D,offset:S}:null}).filter(yl):r.ticks?r.ticks(w).map((T,D)=>{var V=r.map(T);return Yr(V)?{coordinate:V+S,value:T,index:D,offset:S}:null}).filter(yl):r.domain().map((T,D)=>{var V=r.map(T);return Yr(V)?{coordinate:V+S,value:o?o[T]:T,index:D,offset:S}:null}).filter(yl)}},LZ=Ze([Ci,vb,nx,jA,$3,Eb,q3,G3,Wa],xTe),yTe=(e,t,n,r,i,a,o)=>{if(!(t==null||n==null||r==null||r[0]===r[1])){var c=Qc(e,o),{tickCount:h}=t,f=0;return f=o==="angleAxis"&&(r==null?void 0:r.length)>=2?xl(r[0]-r[1])*2*f:f,c&&a?a.map((m,y)=>{var w=n.map(m);return Yr(w)?{coordinate:w+f,value:m,index:y,offset:f}:null}).filter(yl):n.ticks?n.ticks(h).map((m,y)=>{var w=n.map(m);return Yr(w)?{coordinate:w+f,value:m,index:y,offset:f}:null}).filter(yl):n.domain().map((m,y)=>{var w=n.map(m);return Yr(w)?{coordinate:w+f,value:i?i[m]:m,index:y,offset:f}:null}).filter(yl)}},Ku=Ze([Ci,vb,jA,Eb,q3,G3,Wa],yTe),Yu=Ze(Xo,jA,(e,t)=>{if(!(e==null||t==null))return MN(MN({},e),{},{scale:t})}),bTe=Ze([Xo,nx,F3,IZ],L3),vTe=Ze([bTe],f3);Ze((e,t,n)=>U3(e,n),vTe,(e,t)=>{if(!(e==null||t==null))return MN(MN({},e),{},{scale:t})});var wTe=Ze([Ci,aA,oA],(e,t,n)=>{switch(e){case"horizontal":return t.some(r=>r.reversed)?"right-to-left":"left-to-right";case"vertical":return n.some(r=>r.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),NTe=(e,t,n)=>{var r;return(r=e.renderedTicks[t])===null||r===void 0?void 0:r[n]};Ze([NTe],e=>{if(!(!e||e.length===0))return t=>{var n,r=1/0,i=e[0];for(var a of e){var o=Math.abs(a.coordinate-t);oe.options.defaultTooltipEventType,BZ=e=>e.options.validateTooltipEventTypes;function zZ(e,t,n){if(e==null)return t;var r=e?"axis":"item";return n==null?t:n.includes(r)?r:t}function Ab(e,t){var n=UZ(e),r=BZ(e);return zZ(t,n,r)}function ETe(e){return Qn(t=>Ab(t,e))}var VZ=(e,t)=>{var n,r=Number(t);if(!(Wc(r)||t==null))return r>=0?e==null||(n=e[r])===null||n===void 0?void 0:n.value:void 0},ATe=e=>e.tooltip.settings,Qh={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},_Te={itemInteraction:{click:Qh,hover:Qh},axisInteraction:{click:Qh,hover:Qh},keyboardInteraction:Qh,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},FZ=Io({name:"tooltip",initialState:_Te,reducers:{addTooltipEntrySettings:{reducer(e,t){e.tooltipItemPayloads.push(t.payload)},prepare:ms()},replaceTooltipEntrySettings:{reducer(e,t){var{prev:n,next:r}=t.payload,i=fc(e).tooltipItemPayloads.indexOf(n);i>-1&&(e.tooltipItemPayloads[i]=r)},prepare:ms()},removeTooltipEntrySettings:{reducer(e,t){var n=fc(e).tooltipItemPayloads.indexOf(t.payload);n>-1&&e.tooltipItemPayloads.splice(n,1)},prepare:ms()},setTooltipSettingsState(e,t){e.settings=t.payload},setActiveMouseOverItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=t.payload.activeIndex,e.itemInteraction.hover.dataKey=t.payload.activeDataKey,e.itemInteraction.hover.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.hover.coordinate=t.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=t.payload.activeIndex,e.itemInteraction.click.dataKey=t.payload.activeDataKey,e.itemInteraction.click.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.click.coordinate=t.payload.activeCoordinate},setMouseOverAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=t.payload.activeIndex,e.axisInteraction.hover.dataKey=t.payload.activeDataKey,e.axisInteraction.hover.coordinate=t.payload.activeCoordinate},setMouseClickAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=t.payload.activeIndex,e.axisInteraction.click.dataKey=t.payload.activeDataKey,e.axisInteraction.click.coordinate=t.payload.activeCoordinate},setSyncInteraction(e,t){e.syncInteraction=t.payload},setKeyboardInteraction(e,t){e.keyboardInteraction.active=t.payload.active,e.keyboardInteraction.index=t.payload.activeIndex,e.keyboardInteraction.coordinate=t.payload.activeCoordinate}}}),{addTooltipEntrySettings:kTe,replaceTooltipEntrySettings:STe,removeTooltipEntrySettings:CTe,setTooltipSettingsState:jTe,setActiveMouseOverItemIndex:$Z,mouseLeaveItem:ITe,mouseLeaveChart:HZ,setActiveClickItemIndex:TTe,setMouseOverAxisIndex:GZ,setMouseClickAxisIndex:PTe,setSyncInteraction:S1,setKeyboardInteraction:BN}=FZ.actions,OTe=FZ.reducer;function fz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function fw(e){for(var t=1;t{if(t==null)return Qh;var i=LTe(e,t,n);if(i==null)return Qh;if(i.active)return i;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var a=e.settings.active===!0;if(UTe(i)){if(a)return fw(fw({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return fw(fw({},Qh),{},{coordinate:i.coordinate})};function BTe(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(e instanceof Date){var t=e.valueOf();return Number.isFinite(t)?t:void 0}var n=Number(e);return Number.isFinite(n)?n:void 0}function zTe(e,t){var n=BTe(e),r=t[0],i=t[1];if(n===void 0)return!1;var a=Math.min(r,i),o=Math.max(r,i);return n>=a&&n<=o}function VTe(e,t,n){if(n==null||t==null)return!0;var r=Us(e,t);return r==null||!Lu(n)?!0:zTe(r,n)}var Q1=(e,t,n,r)=>{var i=e==null?void 0:e.index;if(i==null)return null;var a=Number(i);if(!Yr(a))return i;var o=0,c=1/0;t.length>0&&(c=t.length-1);var h=Math.max(o,Math.min(a,c)),f=t[h];return f==null||VTe(f,n,r)?String(h):null},WZ=(e,t,n,r,i,a,o)=>{if(a!=null){var c=o[0],h=c==null?void 0:c.getPosition(a);if(h!=null)return h;var f=i==null?void 0:i[Number(a)];if(f)switch(n){case"horizontal":return{x:f.coordinate,y:(r.top+t)/2};default:return{x:(r.left+e)/2,y:f.coordinate}}}},KZ=(e,t,n,r)=>{if(t==="axis")return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var i;if(n==="hover"?i=e.itemInteraction.hover.graphicalItemId:i=e.itemInteraction.click.graphicalItemId,e.syncInteraction.active&&i==null)return e.tooltipItemPayloads;if(i==null&&(r!=null||e.keyboardInteraction.active)){var a=e.tooltipItemPayloads[0];return a!=null?[a]:[]}return e.tooltipItemPayloads.filter(o=>{var c;return((c=o.settings)===null||c===void 0?void 0:c.graphicalItemId)===i})},YZ=e=>e.options.tooltipPayloadSearcher,rx=e=>e.tooltip;function pz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function mz(e){for(var t=1;te(t)}function gz(e){if(typeof e=="string")return e}function KTe(e){if(!(e==null||typeof e!="object")){var t="name"in e?GTe(e.name):void 0,n="unit"in e?qTe(e.unit):void 0,r="dataKey"in e?WTe(e.dataKey):void 0,i="payload"in e?e.payload:void 0,a="color"in e?gz(e.color):void 0,o="fill"in e?gz(e.fill):void 0;return{name:t,unit:n,dataKey:r,payload:i,color:a,fill:o}}}function YTe(e,t){return e??t}var XZ=(e,t,n,r,i,a,o)=>{if(!(t==null||a==null)){var{chartData:c,computedData:h,dataStartIndex:f,dataEndIndex:m}=n,y=[];return e.reduce((w,A)=>{var S,{dataDefinedOnItem:C,settings:T}=A,D=YTe(C,c),V=Array.isArray(D)?EX(D,f,m):D,L=(S=T==null?void 0:T.dataKey)!==null&&S!==void 0?S:r,K=T==null?void 0:T.nameKey,Z;if(r&&Array.isArray(V)&&!Array.isArray(V[0])&&o==="axis"?Z=jY(V,r,i):Z=a(V,t,h,K),Array.isArray(Z))Z.forEach(B=>{var z,F,$=KTe(B),Y=$==null?void 0:$.name,X=$==null?void 0:$.dataKey,J=$==null?void 0:$.payload,ye=mz(mz({},T),{},{name:Y,unit:$==null?void 0:$.unit,color:(z=$==null?void 0:$.color)!==null&&z!==void 0?z:T==null?void 0:T.color,fill:(F=$==null?void 0:$.fill)!==null&&F!==void 0?F:T==null?void 0:T.fill});w.push(lU({tooltipEntrySettings:ye,dataKey:X,payload:J,value:Us(J,X),name:Y==null?void 0:String(Y)}))});else{var q;w.push(lU({tooltipEntrySettings:T,dataKey:L,payload:Z,value:Us(Z,L),name:(q=Us(Z,K))!==null&&q!==void 0?q:T==null?void 0:T.name}))}return w},y)}},W3=Ze([Ta,iZ,o3],eZ),XTe=Ze([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,t)=>[...e,...t]),QTe=Ze([Ka,Zg],sZ),Sm=Ze([XTe,Ta,QTe],aZ,{memoizeOptions:{resultEqualityCheck:NA}}),ZTe=Ze([Sm],e=>e.filter(vA)),QZ=Ze([Sm],cZ,{memoizeOptions:{resultEqualityCheck:NA}}),JTe=Ze([Sm],e=>e.some(t=>!t.data)),mm=Ze([QZ,Zc],dZ),e4e=Ze([ZTe,Zc,Ta],bQ),K3=Ze([mm,Ta,Sm,Zc,JTe,QZ],hZ),ZZ=Ze([Ta],z3),t4e=Ze([Ta],e=>e.allowDataOverflow),JZ=Ze([ZZ,t4e],JX),n4e=Ze([Sm],e=>e.filter(vA)),r4e=Ze([e4e,n4e,pA,hQ],pZ),i4e=Ze([r4e,Zc,Ka,JZ],mZ),s4e=Ze([Sm],lZ),a4e=Ze([mm,Ta,s4e,V3,Ka,_Se],yZ,{memoizeOptions:{resultEqualityCheck:wA}}),o4e=Ze([bZ,Ka,Zg],tx),l4e=Ze([o4e,Ka],NZ),c4e=Ze([vZ,Ka,Zg],tx),u4e=Ze([c4e,Ka],EZ),d4e=Ze([wZ,Ka,Zg],tx),h4e=Ze([d4e,Ka],AZ),f4e=Ze([l4e,h4e,u4e],UN),p4e=Ze([Ta,ZZ,JZ,i4e,a4e,f4e,Ci,Ka],_Z),Dg=Ze([Ta,Ci,mm,K3,pA,Ka,p4e],kZ),m4e=Ze([Dg,Ta,W3],SZ),g4e=Ze([Ta,Dg,m4e,Ka],CZ),eJ=e=>{var t=Ka(e),n=Zg(e),r=!1;return Eb(e,t,n,r)},tJ=Ze([Ta,eJ],mA),x4e=Ze([Ta,W3,g4e,tJ],L3),nJ=Ze([x4e],f3),y4e=Ze([Ci,K3,Ta,Ka],MZ),b4e=Ze([Ci,K3,Ta,Ka],TZ),v4e=(e,t,n,r,i,a,o,c)=>{if(t){var{type:h}=t,f=Qc(e,c);if(r){var m=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,y=h==="category"&&r.bandwidth?r.bandwidth()/m:0;return y=c==="angleAxis"&&i!=null&&(i==null?void 0:i.length)>=2?xl(i[0]-i[1])*2*y:y,f&&o?o.map((w,A)=>{var S=r.map(w);return Yr(S)?{coordinate:S+y,value:w,index:A,offset:y}:null}).filter(yl):r.domain().map((w,A)=>{var S=r.map(w);return Yr(S)?{coordinate:S+y,value:a?a[w]:w,index:A,offset:y}:null}).filter(yl)}}},sh=Ze([Ci,Ta,W3,nJ,eJ,y4e,b4e,Ka],v4e),Y3=Ze([UZ,BZ,ATe],(e,t,n)=>zZ(n.shared,e,t)),rJ=e=>e.tooltip.settings.trigger,X3=e=>e.tooltip.settings.defaultIndex,_b=Ze([rx,Y3,rJ,X3],qZ),gm=Ze([_b,mm,Rg,Dg],Q1),iJ=Ze([sh,gm],VZ),sJ=Ze([_b],e=>{if(e)return e.dataKey}),w4e=Ze([_b],e=>{if(e)return e.graphicalItemId}),aJ=Ze([rx,Y3,rJ,X3],KZ),N4e=Ze([eh,th,Ci,Ga,sh,X3,aJ],WZ),E4e=Ze([_b,N4e],(e,t)=>e!=null&&e.coordinate?e.coordinate:t),A4e=Ze([_b],e=>{var t;return(t=e==null?void 0:e.active)!==null&&t!==void 0?t:!1}),_4e=Ze([aJ,gm,Zc,Rg,iJ,YZ,Y3],XZ),k4e=Ze([_4e],e=>{if(e!=null){var t=e.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(t))}});function xz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function yz(e){for(var t=1;tQn(Ta),T4e=()=>{var e=I4e(),t=Qn(sh),n=Qn(nJ);return bf(!e||!n?void 0:yz(yz({},e),{},{scale:n}),t)};function bz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function E0(e){for(var t=1;t{var i=t.find(a=>a&&a.index===n);if(i){if(e==="horizontal")return{x:i.coordinate,y:r.relativeY};if(e==="vertical")return{x:r.relativeX,y:i.coordinate}}return{x:0,y:0}},M4e=(e,t,n,r)=>{var i=t.find(f=>f&&f.index===n);if(i){if(e==="centric"){var a=i.coordinate,{radius:o}=r;return E0(E0(E0({},r),oo(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var c=i.coordinate,{angle:h}=r;return E0(E0(E0({},r),oo(r.cx,r.cy,c,h)),{},{angle:h,radius:c})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function L4e(e,t){var{relativeX:n,relativeY:r}=e;return n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height}var oJ=(e,t,n,r,i)=>{var a,o=(a=t==null?void 0:t.length)!==null&&a!==void 0?a:0;if(o<=1||e==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c0?(h=n[c-1])===null||h===void 0?void 0:h.coordinate:(f=n[o-1])===null||f===void 0?void 0:f.coordinate,S=(m=n[c])===null||m===void 0?void 0:m.coordinate,C=c>=o-1?(y=n[0])===null||y===void 0?void 0:y.coordinate:(w=n[c+1])===null||w===void 0?void 0:w.coordinate,T=void 0;if(!(A==null||S==null||C==null))if(xl(S-A)!==xl(C-S)){var D=[];if(xl(C-S)===xl(i[1]-i[0])){T=C;var V=S+i[1]-i[0];D[0]=Math.min(V,(V+A)/2),D[1]=Math.max(V,(V+A)/2)}else{T=A;var L=C+i[1]-i[0];D[0]=Math.min(S,(L+S)/2),D[1]=Math.max(S,(L+S)/2)}var K=[Math.min(S,(T+S)/2),Math.max(S,(T+S)/2)];if(e>K[0]&&e<=K[1]||e>=D[0]&&e<=D[1]){var Z;return(Z=n[c])===null||Z===void 0?void 0:Z.index}}else{var q=Math.min(A,C),B=Math.max(A,C);if(e>(q+S)/2&&e<=(B+S)/2){var z;return(z=n[c])===null||z===void 0?void 0:z.index}}}else if(t)for(var F=0;F($.coordinate+X.coordinate)/2||F>0&&F($.coordinate+X.coordinate)/2&&e<=($.coordinate+Y.coordinate)/2)return $.index}}return-1},lJ=()=>Qn(o3),Q3=(e,t)=>t,cJ=(e,t,n)=>n,Z3=(e,t,n,r)=>r,U4e=Ze(sh,e=>XE(e,t=>t.coordinate)),J3=Ze([rx,Q3,cJ,Z3],qZ),eP=Ze([J3,mm,Rg,Dg],Q1),B4e=(e,t,n)=>{if(t!=null){var r=rx(e);return t==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},uJ=Ze([rx,Q3,cJ,Z3],KZ),zN=Ze([eh,th,Ci,Ga,sh,Z3,uJ],WZ),z4e=Ze([J3,zN],(e,t)=>{var n;return(n=e.coordinate)!==null&&n!==void 0?n:t}),dJ=Ze([sh,eP],VZ),V4e=Ze([uJ,eP,Zc,Rg,dJ,YZ,Q3],XZ),F4e=Ze([J3,eP],(e,t)=>({isActive:e.active&&t!=null,activeIndex:t})),$4e=(e,t,n,r,i,a,o)=>{if(!(!e||!n||!r||!i)&&L4e(e,o)){var c=w5e(e,t),h=oJ(c,a,i,n,r),f=D4e(t,i,h,e);return{activeIndex:String(h),activeCoordinate:f}}},H4e=(e,t,n,r,i,a,o)=>{if(!(!e||!r||!i||!a||!n)){var c=pSe(e,n);if(c){var h=N5e(c,t),f=oJ(h,o,a,r,i),m=M4e(t,a,f,c);return{activeIndex:String(f),activeCoordinate:m}}}},G4e=(e,t,n,r,i,a,o,c)=>{if(!(!e||!t||!r||!i||!a))return t==="horizontal"||t==="vertical"?$4e(e,t,r,i,a,o,c):H4e(e,t,n,r,i,a,o)},q4e=Ze(e=>e.zIndex.zIndexMap,(e,t)=>t,(e,t,n)=>n,(e,t,n)=>{if(t!=null){var r=e[t];if(r!=null)return n?r.panoramaElement:r.element}}),W4e=Ze(e=>e.zIndex.zIndexMap,e=>{var t=Object.keys(e).map(r=>parseInt(r,10)).concat(Object.values(ka)),n=Array.from(new Set(t));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:zSe}});function vz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function wz(e){for(var t=1;twz(wz({},e),{},{[t]:{element:void 0,panoramaElement:void 0,consumers:0}}),Q4e)},J4e=new Set(Object.values(ka));function e3e(e){return J4e.has(e)}var hJ=Io({name:"zIndex",initialState:Z4e,reducers:{registerZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]?e.zIndexMap[n].consumers+=1:e.zIndexMap[n]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:ms()},unregisterZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(e.zIndexMap[n].consumers-=1,e.zIndexMap[n].consumers<=0&&!e3e(n)&&delete e.zIndexMap[n])},prepare:ms()},registerZIndexPortalElement:{reducer:(e,t)=>{var{zIndex:n,element:r,isPanorama:i}=t.payload;e.zIndexMap[n]?i?e.zIndexMap[n].panoramaElement=r:e.zIndexMap[n].element=r:e.zIndexMap[n]={consumers:0,element:i?void 0:r,panoramaElement:i?r:void 0}},prepare:ms()},unregisterZIndexPortalElement:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(t.payload.isPanorama?e.zIndexMap[n].panoramaElement=void 0:e.zIndexMap[n].element=void 0)},prepare:ms()}}}),{registerZIndexPortal:t3e,unregisterZIndexPortal:vS,registerZIndexPortalElement:n3e,unregisterZIndexPortalElement:r3e}=hJ.actions,i3e=hJ.reducer;function Gl(e){var{zIndex:t,children:n}=e,r=n_e(),i=r&&t!==void 0&&t!==0,a=qa(),o=I.useRef(void 0),c=I.useRef(new Set),h=bs(),f=Qn(y=>q4e(y,t,a));if(I.useLayoutEffect(()=>{if(!i){var y=c.current;y.forEach(A=>{h(vS({zIndex:A}))}),y.clear(),o.current=void 0;return}if(c.current.has(t)||(h(t3e({zIndex:t})),c.current.add(t)),f){o.current=f;var w=c.current;w.forEach(A=>{A!==t&&(h(vS({zIndex:A})),w.delete(A))})}},[h,t,i,f]),I.useLayoutEffect(()=>{var y=c.current;return()=>{y.forEach(w=>{h(vS({zIndex:w}))}),y.clear()}},[h]),!i)return n;var m=f??o.current;return m?JN.createPortal(n,m):null}function rI(){return rI=Object.assign?Object.assign.bind():function(e){for(var t=1;tI.useContext(fJ),wS={exports:{}},Ez;function h3e(){return Ez||(Ez=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(h,f,m){this.fn=h,this.context=f,this.once=m||!1}function a(h,f,m,y,w){if(typeof m!="function")throw new TypeError("The listener must be a function");var A=new i(m,y||h,w),S=n?n+f:f;return h._events[S]?h._events[S].fn?h._events[S]=[h._events[S],A]:h._events[S].push(A):(h._events[S]=A,h._eventsCount++),h}function o(h,f){--h._eventsCount===0?h._events=new r:delete h._events[f]}function c(){this._events=new r,this._eventsCount=0}c.prototype.eventNames=function(){var f=[],m,y;if(this._eventsCount===0)return f;for(y in m=this._events)t.call(m,y)&&f.push(n?y.slice(1):y);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(m)):f},c.prototype.listeners=function(f){var m=n?n+f:f,y=this._events[m];if(!y)return[];if(y.fn)return[y.fn];for(var w=0,A=y.length,S=new Array(A);w{if(t&&Array.isArray(e)){var n=Number.parseInt(t,10);if(!Wc(n))return e[n]}},g3e={chartName:"",tooltipPayloadSearcher:()=>{},eventEmitter:void 0,defaultTooltipEventType:"axis"},pJ=Io({name:"options",initialState:g3e,reducers:{createEventEmitter:e=>{e.eventEmitter==null&&(e.eventEmitter=Symbol("rechartsEventEmitter"))}}}),x3e=pJ.reducer,{createEventEmitter:y3e}=pJ.actions;function b3e(e){return e.tooltip.syncInteraction}var v3e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},mJ=Io({name:"chartData",initialState:v3e,reducers:{setChartData(e,t){if(e.chartData=t.payload,t.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}t.payload.length>0&&e.dataEndIndex!==t.payload.length-1&&(e.dataEndIndex=t.payload.length-1)},setComputedData(e,t){e.computedData=t.payload},setDataStartEndIndexes(e,t){var{startIndex:n,endIndex:r}=t.payload;n!=null&&(e.dataStartIndex=n),r!=null&&(e.dataEndIndex=r)}}}),{setChartData:_z,setDataStartEndIndexes:w3e,setComputedData:M9e}=mJ.actions,N3e=mJ.reducer,E3e=["x","y"];function kz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function A0(e){for(var t=1;th.rootProps.className);I.useEffect(()=>{if(e==null)return Tf;var h=(f,m,y)=>{if(t!==y&&e===f){if(m.payload.active===!1){n(S1({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(r==="index"){var w;if(o&&m!==null&&m!==void 0&&(w=m.payload)!==null&&w!==void 0&&w.coordinate&&m.payload.sourceViewBox){var A=m.payload.coordinate,{x:S,y:C}=A,T=S3e(A,E3e),{x:D,y:V,width:L,height:K}=m.payload.sourceViewBox,Z=A0(A0({},T),{},{x:o.x+(L?(S-D)/L:0)*o.width,y:o.y+(K?(C-V)/K:0)*o.height});n(A0(A0({},m),{},{payload:A0(A0({},m.payload),{},{coordinate:Z})}))}else n(m);return}if(i!=null){var q;if(typeof r=="function"){var B={activeTooltipIndex:m.payload.index==null?void 0:Number(m.payload.index),isTooltipActive:m.payload.active,activeIndex:m.payload.index==null?void 0:Number(m.payload.index),activeLabel:m.payload.label,activeDataKey:m.payload.dataKey,activeCoordinate:m.payload.coordinate},z=r(i,B);q=i[z]}else r==="value"&&(q=i.find(de=>String(de.value)===m.payload.label));var{coordinate:F}=m.payload;if(F==null||o==null){n(S1({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(q==null){n(S1({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:m.payload.sourceViewBox,graphicalItemId:void 0}));return}var{x:$,y:Y}=F,X=Math.min($,o.x+o.width),J=Math.min(Y,o.y+o.height),ye={x:a==="horizontal"?q.coordinate:X,y:a==="horizontal"?J:q.coordinate},ne=S1({active:m.payload.active,coordinate:ye,dataKey:m.payload.dataKey,index:String(q.index),label:m.payload.label,sourceViewBox:m.payload.sourceViewBox,graphicalItemId:m.payload.graphicalItemId});n(ne)}}};return Py.on(iI,h),()=>{Py.off(iI,h)}},[c,n,t,e,r,i,a,o])}function I3e(){var e=Qn(l3),t=Qn(c3),n=bs();I.useEffect(()=>{if(e==null)return Tf;var r=(i,a,o)=>{t!==o&&e===i&&n(w3e(a))};return Py.on(Az,r),()=>{Py.off(Az,r)}},[n,t,e])}function T3e(){var e=bs();I.useEffect(()=>{e(y3e())},[e]),j3e(),I3e()}function P3e(e,t,n,r,i,a){var o=Qn(S=>B4e(S,e,t)),c=Qn(w4e),h=Qn(c3),f=Qn(l3),m=Qn(fQ),y=Qn(b3e),w=(y==null?void 0:y.sourceViewBox)!=null,A=uA();I.useEffect(()=>{if(!w&&f!=null&&h!=null){var S=S1({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:A,graphicalItemId:c});Py.emit(iI,f,S,h)}},[w,n,o,c,i,r,h,f,m,a,A])}function Sz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Cz(e){for(var t=1;t{B(jTe({shared:V,trigger:L,axisId:q,active:i,defaultIndex:z}))},[B,V,L,q,i,z]);var F=uA(),$=FX(),Y=ETe(V),{activeIndex:X,isActive:J}=(t=Qn(It=>F4e(It,Y,L,z)))!==null&&t!==void 0?t:{},ye=Qn(It=>V4e(It,Y,L,z)),ne=Qn(It=>dJ(It,Y,L,z)),de=Qn(It=>z4e(It,Y,L,z)),be=ye,Ce=d3e(),Ke=(n=i??J)!==null&&n!==void 0?n:!1,[G,se]=WY([be,Ke]),xe=Y==="axis"?ne:void 0;P3e(Y,L,de,xe,X,Ke);var re=Z??Ce;if(re==null||F==null||Y==null)return null;var Me=be??jz;Ke||(Me=jz),f&&Me.length&&(Me=FY(Me.filter(It=>It.value!=null&&(It.hide!==!0||r.includeHidden)),w,M3e));var nt=Me.length>0,ze=Cz(Cz({},r),{},{payload:Me,label:xe,active:Ke,activeIndex:X,coordinate:de,accessibilityLayer:$}),Tt=I.createElement(pke,{allowEscapeViewBox:a,animationDuration:o,animationEasing:c,isAnimationActive:m,active:Ke,coordinate:de,hasPayload:nt,offset:y,position:A,reverseDirection:S,useTranslate3d:C,viewBox:F,wrapperStyle:T,lastBoundingBox:G,innerRef:se,hasPortalFromProps:!!Z},L3e(h,ze));return I.createElement(I.Fragment,null,JN.createPortal(Tt,re),Ke&&I.createElement(u3e,{cursor:D,tooltipEventType:Y,coordinate:de,payload:Me,index:X}))}var gJ=e=>null;gJ.displayName="Cell";function z3e(e,t,n){return(t=V3e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function V3e(e){var t=F3e(e,"string");return typeof t=="symbol"?t:t+""}function F3e(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}class $3e{constructor(t){z3e(this,"cache",new Map),this.maxSize=t}get(t){var n=this.cache.get(t);return n!==void 0&&(this.cache.delete(t),this.cache.set(t,n)),n}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.maxSize){var r=this.cache.keys().next().value;r!=null&&this.cache.delete(r)}this.cache.set(t,n)}clear(){this.cache.clear()}size(){return this.cache.size}}function Iz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function H3e(e){for(var t=1;t{try{var n=document.getElementById(Pz);n||(n=document.createElement("span"),n.setAttribute("id",Pz),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,Y3e,t),n.textContent="".concat(e);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Z1=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||hb.isSsr)return{width:0,height:0};if(!xJ.enableCache)return Oz(t,n);var r=X3e(t,n),i=Tz.get(r);if(i)return i;var a=Oz(t,n);return Tz.set(r,a),a},yJ;function Q3e(e,t,n){return(t=Z3e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Z3e(e){var t=J3e(e,"string");return typeof t=="symbol"?t:t+""}function J3e(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Rz=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Dz=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,ePe=/^(px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q)$/,tPe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,nPe={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},rPe=["cm","mm","pt","pc","in","Q","px"];function iPe(e){return rPe.includes(e)}var F0="NaN";function sPe(e,t){return e*nPe[t]}class ro{static parse(t){var n,[,r,i]=(n=tPe.exec(t))!==null&&n!==void 0?n:[];return r==null?ro.NaN:new ro(parseFloat(r),i??"")}constructor(t,n){this.num=t,this.unit=n,this.num=t,this.unit=n,Wc(t)&&(this.unit=""),n!==""&&!ePe.test(n)&&(this.num=NaN,this.unit=""),iPe(n)&&(this.num=sPe(t,n),this.unit="px")}add(t){return this.unit!==t.unit?new ro(NaN,""):new ro(this.num+t.num,this.unit)}subtract(t){return this.unit!==t.unit?new ro(NaN,""):new ro(this.num-t.num,this.unit)}multiply(t){return this.unit!==""&&t.unit!==""&&this.unit!==t.unit?new ro(NaN,""):new ro(this.num*t.num,this.unit||t.unit)}divide(t){return this.unit!==""&&t.unit!==""&&this.unit!==t.unit?new ro(NaN,""):new ro(this.num/t.num,this.unit||t.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Wc(this.num)}}yJ=ro;Q3e(ro,"NaN",new yJ(NaN,""));function bJ(e){if(e==null||e.includes(F0))return F0;for(var t=e;t.includes("*")||t.includes("/");){var n,[,r,i,a]=(n=Rz.exec(t))!==null&&n!==void 0?n:[],o=ro.parse(r??""),c=ro.parse(a??""),h=i==="*"?o.multiply(c):o.divide(c);if(h.isNaN())return F0;t=t.replace(Rz,h.toString())}for(;t.includes("+")||/.-\d+(?:\.\d+)?/.test(t);){var f,[,m,y,w]=(f=Dz.exec(t))!==null&&f!==void 0?f:[],A=ro.parse(m??""),S=ro.parse(w??""),C=y==="+"?A.add(S):A.subtract(S);if(C.isNaN())return F0;t=t.replace(Dz,C.toString())}return t}var Mz=/\(([^()]*)\)/;function aPe(e){for(var t=e,n;(n=Mz.exec(t))!=null;){var[,r]=n;t=t.replace(Mz,bJ(r))}return t}function oPe(e){var t=e.replace(/\s+/g,"");return t=aPe(t),t=bJ(t),t}function lPe(e){try{return oPe(e)}catch{return F0}}function NS(e){var t=lPe(e.slice(5,-1));return t===F0?"":t}var cPe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],uPe=["dx","dy","angle","className","breakAll"];function sI(){return sI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:t,breakAll:n,style:r}=e;try{var i=[];ys(t)||(n?i=t.toString().split(""):i=t.toString().split(vJ));var a=i.map(c=>({word:c,width:Z1(c,r).width})),o=n?0:Z1(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function NJ(e){return e==="start"||e==="middle"||e==="end"||e==="inherit"}function hPe(e){return ys(e)||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var EJ=(e,t,n,r)=>e.reduce((i,a)=>{var{word:o,width:c}=a,h=i[i.length-1];if(h&&c!=null&&(t==null||r||h.width+c+ne.reduce((t,n)=>t.width>n.width?t:n),fPe="…",Uz=(e,t,n,r,i,a,o,c)=>{var h=e.slice(0,t),f=wJ({breakAll:n,style:r,children:h+fPe});if(!f)return[!1,[]];var m=EJ(f.wordsWithComputedWidth,a,o,c),y=m.length>i||AJ(m).width>Number(a);return[y,m]},pPe=(e,t,n,r,i)=>{var{maxLines:a,children:o,style:c,breakAll:h}=e,f=_n(a),m=String(o),y=EJ(t,r,n,i);if(!f||i)return y;var w=y.length>a||AJ(y).width>Number(r);if(!w)return y;for(var A=0,S=m.length-1,C=0,T;A<=S&&C<=m.length-1;){var D=Math.floor((A+S)/2),V=D-1,[L,K]=Uz(m,V,h,c,a,r,n,i),[Z]=Uz(m,D,h,c,a,r,n,i);if(!L&&!Z&&(A=D+1),L&&Z&&(S=D-1),!L&&Z){T=K;break}C++}return T||y},Bz=e=>{var t=ys(e)?[]:e.toString().split(vJ);return[{words:t,width:void 0}]},mPe=e=>{var{width:t,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=e;if((t||n)&&!hb.isSsr){var c,h,f=wJ({breakAll:a,children:r,style:i});if(f){var{wordsWithComputedWidth:m,spaceWidth:y}=f;c=m,h=y}else return Bz(r);return pPe({breakAll:a,children:r,maxLines:o,style:i},c,h,t,!!n)}return Bz(r)},_J="#808080",gPe={angle:0,breakAll:!1,capHeight:"0.71em",fill:_J,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},tP=I.forwardRef((e,t)=>{var n=Ha(e,gPe),{x:r,y:i,lineHeight:a,capHeight:o,fill:c,scaleToFit:h,textAnchor:f,verticalAnchor:m}=n,y=Lz(n,cPe),w=I.useMemo(()=>mPe({breakAll:y.breakAll,children:y.children,maxLines:y.maxLines,scaleToFit:h,style:y.style,width:y.width}),[y.breakAll,y.children,y.maxLines,h,y.style,y.width]),{dx:A,dy:S,angle:C,className:T,breakAll:D}=y,V=Lz(y,uPe);if(!Hu(r)||!Hu(i)||w.length===0)return null;var L=Number(r)+(_n(A)?A:0),K=Number(i)+(_n(S)?S:0);if(!Yr(L)||!Yr(K))return null;var Z;switch(m){case"start":Z=NS("calc(".concat(o,")"));break;case"middle":Z=NS("calc(".concat((w.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:Z=NS("calc(".concat(w.length-1," * -").concat(a,")"));break}var q=[],B=w[0];if(h&&B!=null){var z=B.width,{width:F}=y;q.push("scale(".concat(_n(F)&&_n(z)?F/z:1,")"))}return C&&q.push("rotate(".concat(C,", ").concat(L,", ").concat(K,")")),q.length&&(V.transform=q.join(" ")),I.createElement("text",sI({},Co(V),{ref:t,x:L,y:K,className:Pi("recharts-text",T),textAnchor:f,fill:c.includes("url")?_J:c}),w.map(($,Y)=>{var X=$.words.join(D?"":" ");return I.createElement("tspan",{x:L,dy:Y===0?Z:a,key:"".concat(X,"-").concat(Y)},X)}))});tP.displayName="Text";function zz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function gu(e){for(var t=1;t{var{viewBox:t,position:n,offset:r=0,parentViewBox:i}=e,{x:a,y:o,height:c,upperWidth:h,lowerWidth:f}=Q4(t),m=a,y=a+(h-f)/2,w=(m+y)/2,A=(h+f)/2,S=m+h/2,C=c>=0?1:-1,T=C*r,D=C>0?"end":"start",V=C>0?"start":"end",L=h>=0?1:-1,K=L*r,Z=L>0?"end":"start",q=L>0?"start":"end",B=i;if(n==="top"){var z={x:m+h/2,y:o-T,horizontalAnchor:"middle",verticalAnchor:D};return B&&(z.height=Math.max(o-B.y,0),z.width=h),z}if(n==="bottom"){var F={x:y+f/2,y:o+c+T,horizontalAnchor:"middle",verticalAnchor:V};return B&&(F.height=Math.max(B.y+B.height-(o+c),0),F.width=f),F}if(n==="left"){var $={x:w-K,y:o+c/2,horizontalAnchor:Z,verticalAnchor:"middle"};return B&&($.width=Math.max($.x-B.x,0),$.height=c),$}if(n==="right"){var Y={x:w+A+K,y:o+c/2,horizontalAnchor:q,verticalAnchor:"middle"};return B&&(Y.width=Math.max(B.x+B.width-Y.x,0),Y.height=c),Y}var X=B?{width:A,height:c}:{};return n==="insideLeft"?gu({x:w+K,y:o+c/2,horizontalAnchor:q,verticalAnchor:"middle"},X):n==="insideRight"?gu({x:w+A-K,y:o+c/2,horizontalAnchor:Z,verticalAnchor:"middle"},X):n==="insideTop"?gu({x:m+h/2,y:o+T,horizontalAnchor:"middle",verticalAnchor:V},X):n==="insideBottom"?gu({x:y+f/2,y:o+c-T,horizontalAnchor:"middle",verticalAnchor:D},X):n==="insideTopLeft"?gu({x:m+K,y:o+T,horizontalAnchor:q,verticalAnchor:V},X):n==="insideTopRight"?gu({x:m+h-K,y:o+T,horizontalAnchor:Z,verticalAnchor:V},X):n==="insideBottomLeft"?gu({x:y+K,y:o+c-T,horizontalAnchor:q,verticalAnchor:D},X):n==="insideBottomRight"?gu({x:y+f-K,y:o+c-T,horizontalAnchor:Z,verticalAnchor:D},X):n&&typeof n=="object"&&(_n(n.x)||um(n.x))&&(_n(n.y)||um(n.y))?gu({x:a+Kc(n.x,A),y:o+Kc(n.y,c),horizontalAnchor:"end",verticalAnchor:"end"},X):gu({x:S,y:o+c/2,horizontalAnchor:"middle",verticalAnchor:"middle"},X)},wPe=["labelRef"],NPe=["content"];function Vz(e,t){if(e==null)return{};var n,r,i=EPe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var{x:t,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:c}=e,h=I.useMemo(()=>({x:t,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[t,n,r,i,a,o]);return I.createElement(kJ.Provider,{value:h},c)},SJ=()=>{var e=I.useContext(kJ),t=uA();return e||(t?Q4(t):void 0)},CPe=I.createContext(null),jPe=()=>{var e=I.useContext(CPe),t=Qn(yQ);return e||t},IPe=e=>{var{value:t,formatter:n}=e,r=ys(e.children)?t:e.children;return typeof n=="function"?n(r):r},nP=e=>e!=null&&typeof e=="function",TPe=(e,t)=>{var n=xl(t-e),r=Math.min(Math.abs(t-e),360);return n*r},PPe=(e,t,n,r,i)=>{var{offset:a,className:o}=e,{cx:c,cy:h,innerRadius:f,outerRadius:m,startAngle:y,endAngle:w,clockWise:A}=i,S=(f+m)/2,C=TPe(y,w),T=C>=0?1:-1,D,V;switch(t){case"insideStart":D=y+T*a,V=A;break;case"insideEnd":D=w-T*a,V=!A;break;case"end":D=w+T*a,V=A;break;default:throw new Error("Unsupported position ".concat(t))}V=C<=0?V:!V;var L=oo(c,h,S,D),K=oo(c,h,S,D+(V?1:-1)*359),Z="M".concat(L.x,",").concat(L.y,` A`).concat(S,",").concat(S,",0,1,").concat(V?0:1,`, `).concat(K.x,",").concat(K.y),q=ys(e.id)?by("recharts-radial-line-"):e.id;return I.createElement("text",jd({},r,{dominantBaseline:"central",className:Pi("recharts-radial-bar-label",o)}),I.createElement("defs",null,I.createElement("path",{id:q,d:Z})),I.createElement("textPath",{xlinkHref:"#".concat(q)},n))},OPe=(e,t,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:o,startAngle:c,endAngle:h}=e,f=(c+h)/2;if(n==="outside"){var{x:m,y}=oo(r,i,o+t,f);return{x:m,y,textAnchor:m>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var w=(a+o)/2,{x:A,y:S}=oo(r,i,w,f);return{x:A,y:S,textAnchor:"middle",verticalAnchor:"middle"}},e2=e=>e!=null&&"cx"in e&&_n(e.cx),RPe={angle:0,offset:5,zIndex:ka.label,position:"middle",textBreakAll:!1};function DPe(e){if(!e2(e))return e;var{cx:t,cy:n,outerRadius:r}=e,i=r*2;return{x:t-r,y:n-r,width:i,upperWidth:i,lowerWidth:i,height:i}}function Hh(e){var t=Ha(e,RPe),{viewBox:n,parentViewBox:r,position:i,value:a,children:o,content:c,className:h="",textBreakAll:f,labelRef:m}=t,y=jPe(),w=SJ(),A=i==="center"?w:y??w,S,C,T;n==null?S=A:e2(n)?S=n:S=Q4(n);var D=DPe(S);if(!S||ys(a)&&ys(o)&&!I.isValidElement(c)&&typeof c!="function")return null;var V=C1(C1({},t),{},{viewBox:S});if(I.isValidElement(c)){var{labelRef:L}=V,K=Vz(V,wPe);return I.cloneElement(c,K)}if(typeof c=="function"){var{content:Z}=V,q=Vz(V,NPe);if(C=I.createElement(c,q),I.isValidElement(C))return C}else C=IPe(t);var B=Co(t);if(e2(S)){if(i==="insideStart"||i==="insideEnd"||i==="end")return PPe(t,i,C,B,S);T=OPe(S,t.offset,t.position)}else{if(!D)return null;var z=vPe({viewBox:D,position:i,offset:t.offset,parentViewBox:e2(r)?void 0:r});T=C1(C1({x:z.x,y:z.y,textAnchor:z.horizontalAnchor,verticalAnchor:z.verticalAnchor},z.width!==void 0?{width:z.width}:{}),z.height!==void 0?{height:z.height}:{})}return I.createElement(Gl,{zIndex:t.zIndex},I.createElement(tP,jd({ref:m,className:Pi("recharts-label",h)},B,T,{textAnchor:NJ(B.textAnchor)?B.textAnchor:T.textAnchor,breakAll:f}),C))}Hh.displayName="Label";var MPe=(e,t,n)=>{if(!e)return null;var r={viewBox:t,labelRef:n};return e===!0?I.createElement(Hh,jd({key:"label-implicit"},r)):Hu(e)?I.createElement(Hh,jd({key:"label-implicit",value:e},r)):I.isValidElement(e)?e.type===Hh?I.cloneElement(e,C1({key:"label-implicit"},r)):I.createElement(Hh,jd({key:"label-implicit",content:e},r)):nP(e)?I.createElement(Hh,jd({key:"label-implicit",content:e},r)):e&&typeof e=="object"?I.createElement(Hh,jd({},e,{key:"label-implicit"},r)):null};function LPe(e){var{label:t,labelRef:n}=e,r=SJ();return MPe(t,r,n)||null}var UPe=["valueAccessor"],BPe=["dataKey","clockWise","id","textBreakAll","zIndex"];function VN(){return VN=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=Array.isArray(e.value)?e.value[e.value.length-1]:e.value;if(hPe(t))return t},CJ=I.createContext(void 0),rP=CJ.Provider,jJ=I.createContext(void 0);jJ.Provider;function FPe(){return I.useContext(CJ)}function $Pe(){return I.useContext(jJ)}function t2(e){var{valueAccessor:t=VPe}=e,n=$z(e,UPe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:c}=n,h=$z(n,BPe),f=FPe(),m=$Pe(),y=f||m;return!y||!y.length?null:I.createElement(Gl,{zIndex:c??ka.label},I.createElement(lo,{className:"recharts-label-list"},y.map((w,A)=>{var S,C=ys(r)?t(w,A):Us(w.payload,r),T=ys(a)?{}:{id:"".concat(a,"-").concat(A)};return I.createElement(Hh,VN({key:"label-".concat(A)},Co(w),h,T,{fill:(S=n.fill)!==null&&S!==void 0?S:w.fill,parentViewBox:w.parentViewBox,value:C,textBreakAll:o,viewBox:w.viewBox,index:A,zIndex:0}))})))}t2.displayName="LabelList";function iP(e){var{label:t}=e;return t?t===!0?I.createElement(t2,{key:"labelList-implicit"}):I.isValidElement(t)||nP(t)?I.createElement(t2,{key:"labelList-implicit",content:t}):typeof t=="object"?I.createElement(t2,VN({key:"labelList-implicit"},t,{type:String(t.type)})):null:null}function aI(){return aI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{cx:t,cy:n,r,className:i}=e,a=Pi("recharts-dot",i);return _n(t)&&_n(n)&&_n(r)?I.createElement("circle",aI({},Fl(e),z4(e),{className:a,cx:t,cy:n,r})):null},HPe={radiusAxis:{},angleAxis:{}},TJ=Io({name:"polarAxis",initialState:HPe,reducers:{addRadiusAxis(e,t){e.radiusAxis[t.payload.id]=t.payload},removeRadiusAxis(e,t){delete e.radiusAxis[t.payload.id]},addAngleAxis(e,t){e.angleAxis[t.payload.id]=t.payload},removeAngleAxis(e,t){delete e.angleAxis[t.payload.id]}}}),{addRadiusAxis:L9e,removeRadiusAxis:U9e,addAngleAxis:B9e,removeAngleAxis:z9e}=TJ.actions,GPe=TJ.reducer;function qPe(e){return e&&typeof e=="object"&&"className"in e&&typeof e.className=="string"?e.className:""}var ES={exports:{}},Qi={};/** * @license React * react-is.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 Hz;function WPe(){if(Hz)return Qi;Hz=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),w=Symbol.for("react.view_transition"),A=Symbol.for("react.client.reference");function S(C){if(typeof C=="object"&&C!==null){var T=C.$$typeof;switch(T){case e:switch(C=C.type,C){case n:case i:case r:case h:case f:case w:return C;default:switch(C=C&&C.$$typeof,C){case o:case c:case y:case m:return C;case a:return C;default:return T}}case t:return T}}}return Qi.ContextConsumer=a,Qi.ContextProvider=o,Qi.Element=e,Qi.ForwardRef=c,Qi.Fragment=n,Qi.Lazy=y,Qi.Memo=m,Qi.Portal=t,Qi.Profiler=i,Qi.StrictMode=r,Qi.Suspense=h,Qi.SuspenseList=f,Qi.isContextConsumer=function(C){return S(C)===a},Qi.isContextProvider=function(C){return S(C)===o},Qi.isElement=function(C){return typeof C=="object"&&C!==null&&C.$$typeof===e},Qi.isForwardRef=function(C){return S(C)===c},Qi.isFragment=function(C){return S(C)===n},Qi.isLazy=function(C){return S(C)===y},Qi.isMemo=function(C){return S(C)===m},Qi.isPortal=function(C){return S(C)===t},Qi.isProfiler=function(C){return S(C)===i},Qi.isStrictMode=function(C){return S(C)===r},Qi.isSuspense=function(C){return S(C)===h},Qi.isSuspenseList=function(C){return S(C)===f},Qi.isValidElementType=function(C){return typeof C=="string"||typeof C=="function"||C===n||C===i||C===r||C===h||C===f||typeof C=="object"&&C!==null&&(C.$$typeof===y||C.$$typeof===m||C.$$typeof===o||C.$$typeof===a||C.$$typeof===c||C.$$typeof===A||C.getModuleId!==void 0)},Qi.typeOf=S,Qi}var Gz;function KPe(){return Gz||(Gz=1,ES.exports=WPe()),ES.exports}var YPe=KPe(),qz=e=>typeof e=="string"?e:e?e.displayName||e.name||"Component":"",Wz=null,AS=null,PJ=e=>{if(e===Wz&&Array.isArray(AS))return AS;var t=[];return I.Children.forEach(e,n=>{ys(n)||(YPe.isFragment(n)?t=t.concat(PJ(n.props.children)):t.push(n))}),AS=t,Wz=e,t};function XPe(e,t){var n=[],r=[];return Array.isArray(t)?r=t.map(i=>qz(i)):r=[qz(t)],PJ(e).forEach(i=>{var a=Sg(i,"type.displayName")||Sg(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var sP=e=>e&&typeof e=="object"&&"clipDot"in e?!!e.clipDot:!0,_S={},Kz;function QPe(){return Kz||(Kz=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){var i;if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const a=n[Symbol.toStringTag];return a==null||!((i=Object.getOwnPropertyDescriptor(n,Symbol.toStringTag))!=null&&i.writable)?!1:n.toString()===`[object ${a}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}e.isPlainObject=t})(_S)),_S}var kS,Yz;function ZPe(){return Yz||(Yz=1,kS=QPe().isPlainObject),kS}var JPe=ZPe();const eOe=Xu(JPe);var Xz,Qz,Zz,Jz,eV;function tV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function nV(e){for(var t=1;t{var a=n-r,o;return o=Ws(Xz||(Xz=h1(["M ",",",""])),e,t),o+=Ws(Qz||(Qz=h1(["L ",",",""])),e+n,t),o+=Ws(Zz||(Zz=h1(["L ",",",""])),e+n-a/2,t+i),o+=Ws(Jz||(Jz=h1(["L ",",",""])),e+n-a/2-r,t+i),o+=Ws(eV||(eV=h1(["L ",","," Z"])),e,t),o},iOe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},sOe=e=>{var t=Ha(e,iOe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:c}=t,{animationEasing:h,animationDuration:f,animationBegin:m,isUpdateAnimationActive:y}=t,w=I.useRef(null),[A,S]=I.useState(-1),C=I.useRef(i),T=I.useRef(a),D=I.useRef(o),V=I.useRef(n),L=I.useRef(r),K=pb(e,"trapezoid-");if(I.useEffect(()=>{if(w.current&&w.current.getTotalLength)try{var ye=w.current.getTotalLength();ye&&S(ye)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var Z=Pi("recharts-trapezoid",c);if(!y)return I.createElement("g",null,I.createElement("path",FN({},Co(t),{className:Z,d:rV(n,r,i,a,o)})));var q=C.current,B=T.current,z=D.current,F=V.current,$=L.current,Y="0px ".concat(A===-1?1:A,"px"),X="".concat(A,"px ").concat(A,"px"),J=$X(["strokeDasharray"],f,h);return I.createElement(fb,{animationId:K,key:K,canBegin:A>0,duration:f,easing:h,isActive:y,begin:m},ye=>{var ne=Ji(q,i,ye),de=Ji(B,a,ye),be=Ji(z,o,ye),Ce=Ji(F,n,ye),Ke=Ji($,r,ye);w.current&&(C.current=ne,T.current=de,D.current=be,V.current=Ce,L.current=Ke);var G=ye>0?{transition:J,strokeDasharray:X}:{strokeDasharray:Y};return I.createElement("path",FN({},Co(t),{className:Z,d:rV(Ce,Ke,ne,de,be),ref:w,style:nV(nV({},G),t.style)}))})},aOe=["option","shapeType","activeClassName","inActiveClassName"];function oOe(e,t){if(e==null)return{};var n,r,i=lOe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var r=bs();return(i,a)=>o=>{e==null||e(i,a,o),r($Z({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},DJ=e=>{var t=bs();return(n,r)=>i=>{e==null||e(n,r,i),t(ITe())}},MJ=(e,t,n)=>{var r=bs();return(i,a)=>o=>{e==null||e(i,a,o),r(TTe({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function aP(e){var{tooltipEntrySettings:t}=e,n=bs(),r=qa(),i=I.useRef(null);return I.useLayoutEffect(()=>{r||(i.current===null?n(kTe(t)):i.current!==t&&n(STe({prev:i.current,next:t})),i.current=t)},[t,n,r]),I.useLayoutEffect(()=>()=>{i.current&&(n(CTe(i.current)),i.current=null)},[n]),null}function oP(e){var{legendPayload:t}=e,n=bs(),r=qa(),i=I.useRef(null);return I.useLayoutEffect(()=>{r||(i.current===null?n(g_e(t)):i.current!==t&&n(x_e({prev:i.current,next:t})),i.current=t)},[n,r,t]),I.useLayoutEffect(()=>()=>{i.current&&(n(y_e(i.current)),i.current=null)},[n]),null}var SS,mOe=()=>{var[e]=I.useState(()=>by("uid-"));return e},gOe=(SS=ene.useId)!==null&&SS!==void 0?SS:mOe;function xOe(e,t){var n=gOe();return t||(e?"".concat(e,"-").concat(n):n)}var yOe=I.createContext(void 0),lP=e=>{var{id:t,type:n,children:r}=e,i=xOe("recharts-".concat(n),t);return I.createElement(yOe.Provider,{value:i},r(i))},bOe={cartesianItems:[],polarItems:[]},LJ=Io({name:"graphicalItems",initialState:bOe,reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(t.payload)},prepare:ms()},replaceCartesianGraphicalItem:{reducer(e,t){var{prev:n,next:r}=t.payload,i=fc(e).cartesianItems.indexOf(n);i>-1&&(e.cartesianItems[i]=r)},prepare:ms()},removeCartesianGraphicalItem:{reducer(e,t){var n=fc(e).cartesianItems.indexOf(t.payload);n>-1&&e.cartesianItems.splice(n,1)},prepare:ms()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(t.payload)},prepare:ms()},removePolarGraphicalItem:{reducer(e,t){var n=fc(e).polarItems.indexOf(t.payload);n>-1&&e.polarItems.splice(n,1)},prepare:ms()},replacePolarGraphicalItem:{reducer(e,t){var{prev:n,next:r}=t.payload,i=fc(e).polarItems.indexOf(n);i>-1&&(e.polarItems[i]=r)},prepare:ms()}}}),{addCartesianGraphicalItem:vOe,replaceCartesianGraphicalItem:wOe,removeCartesianGraphicalItem:NOe,addPolarGraphicalItem:V9e,removePolarGraphicalItem:F9e,replacePolarGraphicalItem:$9e}=LJ.actions,EOe=LJ.reducer,AOe=e=>{var t=bs(),n=I.useRef(null);return I.useLayoutEffect(()=>{n.current===null?t(vOe(e)):n.current!==e&&t(wOe({prev:n.current,next:e})),n.current=e},[t,e]),I.useLayoutEffect(()=>()=>{n.current&&(t(NOe(n.current)),n.current=null)},[t]),null},cP=I.memo(AOe),_Oe=["points"];function aV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function CS(e){for(var t=1;t{var T,D,V=CS(CS(CS({r:3},o),y),{},{index:C,cx:(T=S.x)!==null&&T!==void 0?T:void 0,cy:(D=S.y)!==null&&D!==void 0?D:void 0,dataKey:a,value:S.value,payload:S.payload,points:t});return I.createElement(TOe,{key:"dot-".concat(C),option:n,dotProps:V,className:i})}),A={};return c&&h!=null&&(A.clipPath="url(#clipPath-".concat(m?"":"dots-").concat(h,")")),I.createElement(Gl,{zIndex:f},I.createElement(lo,HN({className:r},A),w))}function oV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function lV(e){for(var t=1;t({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),qOe=Ze([GOe,eh,th],(e,t,n)=>{if(!(!e||t==null||n==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,n-e.top-e.bottom)}}),PA=()=>Qn(qOe),WOe=()=>Qn(k4e);function cV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function jS(e){for(var t=1;t{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var c={index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:t.payload,value:t.value},h=jS(jS(jS({},c),sb(i)),z4(i)),f;return I.isValidElement(i)?f=I.cloneElement(i,h):typeof i=="function"?f=i(h):f=I.createElement(IJ,h),I.createElement(lo,{className:"recharts-active-dot",clipPath:o},f)};function oI(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=ka.activeDot}=e,c=Qn(gm),h=WOe();if(t==null||h==null)return null;var f=t.find(m=>h.includes(m.payload));return ys(f)?null:I.createElement(Gl,{zIndex:o},I.createElement(QOe,{point:f,childIndex:Number(c),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var uV=(e,t,n)=>{var r=n??e;if(!ys(r))return Kc(r,t,0)},ZOe=(e,t,n)=>{var r={},i=e.filter(vA),a=e.filter(f=>f.stackId==null),o=i.reduce((f,m)=>{var y=f[m.stackId];return y==null&&(y=[]),y.push(m),f[m.stackId]=y,f},r),c=Object.entries(o).map(f=>{var m,[y,w]=f,A=w.map(C=>C.dataKey),S=uV(t,n,(m=w[0])===null||m===void 0?void 0:m.barSize);return{stackId:y,dataKeys:A,barSize:S}}),h=a.map(f=>{var m=[f.dataKey].filter(w=>w!=null),y=uV(t,n,f.barSize);return{stackId:void 0,dataKeys:m,barSize:y}});return[...c,...h]};function dV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function mw(e){for(var t=1;tV+(L.barSize||0),0);w+=(o-1)*c,w>=n&&(w-=(o-1)*c,c=0),w>=n&&y>0&&(m=!0,y*=.9,w=o*y);var A=(n-w)/2>>0,S={offset:A-c,size:0};h=r.reduce((V,L)=>{var K,Z={stackId:L.stackId,dataKeys:L.dataKeys,position:{offset:S.offset+S.size+c,size:m?y:(K=L.barSize)!==null&&K!==void 0?K:0}},q=[...V,Z];return S=Z.position,q},f)}else{var C=Kc(t,n,0,!0);n-2*C-(o-1)*c<=0&&(c=0);var T=(n-2*C-(o-1)*c)/o;T>1&&(T>>=0);var D=Yr(i)?Math.min(T,i):T;h=r.reduce((V,L,K)=>[...V,{stackId:L.stackId,dataKeys:L.dataKeys,position:{offset:C+(T+c)*K+(T-D)/2,size:D}}],f)}return h}}var r6e=(e,t,n,r,i,a,o)=>{var c=ys(o)?t:o,h=n6e(n,r,i!==a?i:a,e,c);return i!==a&&h!=null&&(h=h.map(f=>mw(mw({},f),{},{position:mw(mw({},f.position),{},{offset:f.position.offset-i/2})}))),h},i6e=(e,t)=>{var n=bA(t);if(!(!e||n==null||t==null)){var{stackId:r}=t;if(r!=null){var i=e[r];if(i){var{stackedData:a}=i;if(a)return a.find(o=>o.key===n)}}}},s6e=(e,t)=>{if(!(e==null||t==null)){var n=e.find(r=>r.stackId===t.stackId&&t.dataKey!=null&&r.dataKeys.includes(t.dataKey));if(n!=null)return n.position}};function a6e(e,t){return e&&typeof e=="object"&&"zIndex"in e&&typeof e.zIndex=="number"&&Yr(e.zIndex)?e.zIndex:t}var o6e=e=>{var{chartData:t}=e,n=bs(),r=qa();return I.useEffect(()=>r?()=>{}:(n(_z(t)),()=>{n(_z(void 0))}),[t,n,r]),null},hV={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},VJ=Io({name:"brush",initialState:hV,reducers:{setBrushSettings(e,t){return t.payload==null?hV:t.payload}}}),{setBrushSettings:W9e}=VJ.actions,l6e=VJ.reducer;function c6e(e){return(e%180+180)%180}var u6e=function(t){var{width:n,height:r}=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=c6e(i),o=a*Math.PI/180,c=Math.atan(r/n),h=o>c&&o{e.dots.push(t.payload)},removeDot:(e,t)=>{var n=fc(e).dots.findIndex(r=>r===t.payload);n!==-1&&e.dots.splice(n,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var n=fc(e).areas.findIndex(r=>r===t.payload);n!==-1&&e.areas.splice(n,1)},addLine:(e,t)=>{e.lines.push(t.payload)},removeLine:(e,t)=>{var n=fc(e).lines.findIndex(r=>r===t.payload);n!==-1&&e.lines.splice(n,1)}}}),{addDot:K9e,removeDot:Y9e,addArea:X9e,removeArea:Q9e,addLine:Z9e,removeLine:J9e}=FJ.actions,h6e=FJ.reducer,f6e=I.createContext(void 0),p6e=e=>{var{children:t}=e,[n]=I.useState("".concat(by("recharts"),"-clip")),r=PA();if(r==null)return null;var{x:i,y:a,width:o,height:c}=r;return I.createElement(f6e.Provider,{value:n},I.createElement("defs",null,I.createElement("clipPath",{id:n},I.createElement("rect",{x:i,y:a,height:c,width:o}))),t)};function $J(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;re*i)return!1;var a=n();return e*(t-e*a/2-r)>=0&&e*(t+e*a/2-i)<=0}function x6e(e,t){return $J(e,t+1)}function y6e(e,t,n,r,i){for(var a=(r||[]).slice(),{start:o,end:c}=t,h=0,f=1,m=o,y=function(){var S=r==null?void 0:r[h];if(S===void 0)return{v:$J(r,f)};var C=h,T,D=()=>(T===void 0&&(T=n(S,C)),T),V=S.coordinate,L=h===0||Oy(e,V,D,m,c);L||(h=0,m=o,f+=1),L&&(m=V+e*(D()/2+i),h+=f)},w;f<=a.length;)if(w=y(),w)return w.v;return[]}function b6e(e,t,n,r,i){var a=(r||[]).slice(),o=a.length;if(o===0)return[];for(var{start:c,end:h}=t,f=1;f<=o;f++){for(var m=(o-1)%f,y=c,w=!0,A=function(){var K=r[C];if(K==null)return 0;var Z=C,q,B=()=>(q===void 0&&(q=n(K,Z)),q),z=K.coordinate,F=C===m||Oy(e,z,B,y,h);if(!F)return w=!1,1;F&&(y=z+e*(B()/2+i))},S,C=m;C(C===void 0&&(C=n(A,w)),C);if(w===o-1){var D=e*(S.coordinate+e*T()/2-h);a[w]=S=vo(vo({},S),{},{tickCoord:D>0?S.coordinate-D*e:S.coordinate})}else a[w]=S=vo(vo({},S),{},{tickCoord:S.coordinate});if(S.tickCoord!=null){var V=Oy(e,S.tickCoord,T,c,h);V&&(h=S.tickCoord-e*(T()/2+i),a[w]=vo(vo({},S),{},{isShow:!0}))}},m=o-1;m>=0;m--)f(m);return a}function A6e(e,t,n,r,i,a){var o=(r||[]).slice(),c=o.length,{start:h,end:f}=t;if(a){var m=r[c-1];if(m!=null){var y=n(m,c-1),w=e*(m.coordinate+e*y/2-f);if(o[c-1]=m=vo(vo({},m),{},{tickCoord:w>0?m.coordinate-w*e:m.coordinate}),m.tickCoord!=null){var A=Oy(e,m.tickCoord,()=>y,h,f);A&&(f=m.tickCoord-e*(y/2+i),o[c-1]=vo(vo({},m),{},{isShow:!0}))}}}for(var S=a?c-1:c,C=function(V){var L=o[V];if(L==null)return 1;var K=L,Z,q=()=>(Z===void 0&&(Z=n(L,V)),Z);if(V===0){var B=e*(K.coordinate-e*q()/2-h);o[V]=K=vo(vo({},K),{},{tickCoord:B<0?K.coordinate-B*e:K.coordinate})}else o[V]=K=vo(vo({},K),{},{tickCoord:K.coordinate});if(K.tickCoord!=null){var z=Oy(e,K.tickCoord,q,h,f);z&&(h=K.tickCoord+e*(q()/2+i),o[V]=vo(vo({},K),{},{isShow:!0}))}},T=0;T{var B=typeof f=="function"?f(Z.value,q):Z.value;return S==="width"?m6e(Z1(B,{fontSize:t,letterSpacing:n}),C,y):Z1(B,{fontSize:t,letterSpacing:n})[S]},D=i[0],V=i[1],L=i.length>=2&&D!=null&&V!=null?xl(V.coordinate-D.coordinate):1,K=g6e(a,L,S);return h==="equidistantPreserveStart"?y6e(L,K,T,i,o):h==="equidistantPreserveEnd"?b6e(L,K,T,i,o):(h==="preserveStart"||h==="preserveStartEnd"?A=A6e(L,K,T,i,o,h==="preserveStartEnd"):A=E6e(L,K,T,i,o),A.filter(Z=>Z.isShow))}var _6e=e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=e,o=0;if(t){Array.from(t).forEach(m=>{if(m){var y=m.getBoundingClientRect();y.width>o&&(o=y.width)}});var c=n?n.getBoundingClientRect().width:0,h=i+a,f=o+h+c+(n?r:0);return Math.round(f)}return 0},k6e={xAxis:{},yAxis:{}},HJ=Io({name:"renderedTicks",initialState:k6e,reducers:{setRenderedTicks:(e,t)=>{var{axisType:n,axisId:r,ticks:i}=t.payload;e[n][r]=i},removeRenderedTicks:(e,t)=>{var{axisType:n,axisId:r}=t.payload;delete e[n][r]}}}),{setRenderedTicks:S6e,removeRenderedTicks:C6e}=HJ.actions,j6e=HJ.reducer,I6e=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function T6e(e,t){if(e==null)return{};var n,r,i=P6e(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{if(r==null||n==null)return Tf;var a=t.map(o=>({value:o.value,coordinate:o.coordinate,offset:o.offset,index:o.index}));return i(S6e({ticks:a,axisId:r,axisType:n})),()=>{i(C6e({axisId:r,axisType:n}))}},[i,t,r,n]),null}var F6e=I.forwardRef((e,t)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:c,padding:h,tickTextProps:f,orientation:m,mirror:y,x:w,y:A,width:S,height:C,tickSize:T,tickMargin:D,fontSize:V,letterSpacing:L,getTicksConfig:K,events:Z,axisType:q,axisId:B}=e,z=uP(Gs(Gs({},K),{},{ticks:n}),V,L),F=Fl(K),$=sb(r),Y=NJ(F.textAnchor)?F.textAnchor:U6e(m,y),X=B6e(m,y),J={};typeof i=="object"&&(J=i);var ye=Gs(Gs({},F),{},{fill:"none"},J),ne=z.map(Ce=>Gs({entry:Ce},L6e(Ce,w,A,S,C,m,T,y,D))),de=ne.map(Ce=>{var{entry:Ke,line:G}=Ce;return I.createElement(lo,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Ke.value,"-").concat(Ke.coordinate,"-").concat(Ke.tickCoord)},i&&I.createElement("line",xm({},ye,G,{className:Pi("recharts-cartesian-axis-tick-line",Sg(i,"className"))})))}),be=ne.map((Ce,Ke)=>{var G,se,{entry:xe,tick:re}=Ce,Me=Gs(Gs(Gs(Gs({verticalAnchor:X},F),{},{textAnchor:Y,stroke:"none",fill:a},re),{},{index:Ke,payload:xe,visibleTicksCount:z.length,tickFormatter:o,padding:h},f),{},{angle:(G=(se=f==null?void 0:f.angle)!==null&&se!==void 0?se:F.angle)!==null&&G!==void 0?G:0}),nt=Gs(Gs({},Me),$);return I.createElement(lo,xm({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(xe.value,"-").concat(xe.coordinate,"-").concat(xe.tickCoord)},YE(Z,xe,Ke)),r&&I.createElement(z6e,{option:r,tickProps:nt,value:"".concat(typeof o=="function"?o(xe.value,Ke):xe.value).concat(c||"")}))});return I.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(q,"-ticks")},I.createElement(V6e,{ticks:z,axisId:B,axisType:q}),be.length>0&&I.createElement(Gl,{zIndex:ka.label},I.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(q,"-tick-labels"),ref:t},be)),de.length>0&&I.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(q,"-tick-lines")},de))}),$6e=I.forwardRef((e,t)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:c,axisType:h,axisId:f}=e,m=T6e(e,I6e),[y,w]=I.useState(""),[A,S]=I.useState(""),C=I.useRef(null);I.useImperativeHandle(t,()=>({getCalculatedWidth:()=>{var D;return _6e({ticks:C.current,label:(D=e.labelRef)===null||D===void 0?void 0:D.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var T=I.useCallback(D=>{if(D){var V=D.getElementsByClassName("recharts-cartesian-axis-tick-value");C.current=V;var L=V[0];if(L){var K=window.getComputedStyle(L),Z=K.fontSize,q=K.letterSpacing;(Z!==y||q!==A)&&(w(Z),S(q))}}},[y,A]);return o||r!=null&&r<=0||i!=null&&i<=0?null:I.createElement(Gl,{zIndex:e.zIndex},I.createElement(lo,{className:Pi("recharts-cartesian-axis",a)},I.createElement(M6e,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:Fl(e)}),I.createElement(F6e,{ref:T,axisType:h,events:m,fontSize:y,getTicksConfig:e,height:e.height,letterSpacing:A,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:c,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:f}),I.createElement(SPe,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},I.createElement(LPe,{label:e.label,labelRef:e.labelRef}),e.children)))}),dP=I.forwardRef((e,t)=>{var n=Ha(e,Ud);return I.createElement($6e,xm({},n,{ref:t}))});dP.displayName="CartesianAxis";var H6e=["x1","y1","x2","y2","key"],G6e=["offset"],q6e=["xAxisId","yAxisId"],W6e=["xAxisId","yAxisId"];function mV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Ao(e){for(var t=1;t{var{fill:t}=e;if(!t||t==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:c}=e;return I.createElement("rect",{x:r,y:i,ry:c,width:a,height:o,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function GJ(e){var{option:t,lineItemProps:n}=e,r;if(I.isValidElement(t))r=I.cloneElement(t,n);else if(typeof t=="function")r=t(n);else{var i,{x1:a,y1:o,x2:c,y2:h,key:f}=n,m=GN(n,H6e),y=(i=Fl(m))!==null&&i!==void 0?i:{},{offset:w}=y,A=GN(y,G6e);r=I.createElement("line",Tp({},A,{x1:a,y1:o,x2:c,y2:h,fill:"none",key:f}))}return r}function J6e(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,c=GN(e,q6e),h=i.map((f,m)=>{var y=Ao(Ao({},c),{},{x1:t,y1:f,x2:t+n,y2:f,key:"line-".concat(m),index:m});return I.createElement(GJ,{key:"line-".concat(m),option:r,lineItemProps:y})});return I.createElement("g",{className:"recharts-cartesian-grid-horizontal"},h)}function eRe(e){var{y:t,height:n,vertical:r=!0,verticalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,c=GN(e,W6e),h=i.map((f,m)=>{var y=Ao(Ao({},c),{},{x1:f,y1:t,x2:f,y2:t+n,key:"line-".concat(m),index:m});return I.createElement(GJ,{option:r,lineItemProps:y,key:"line-".concat(m)})});return I.createElement("g",{className:"recharts-cartesian-grid-vertical"},h)}function tRe(e){var{horizontalFill:t,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:c,horizontal:h=!0}=e;if(!h||!t||!t.length||c==null)return null;var f=c.map(y=>Math.round(y+i-i)).sort((y,w)=>y-w);i!==f[0]&&f.unshift(0);var m=f.map((y,w)=>{var A=f[w+1],S=A==null,C=S?i+o-y:A-y;if(C<=0)return null;var T=w%t.length;return I.createElement("rect",{key:"react-".concat(w),y,x:r,height:C,width:a,stroke:"none",fill:t[T],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return I.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},m)}function nRe(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:c,verticalPoints:h}=e;if(!t||!n||!n.length)return null;var f=h.map(y=>Math.round(y+i-i)).sort((y,w)=>y-w);i!==f[0]&&f.unshift(0);var m=f.map((y,w)=>{var A=f[w+1],S=A==null,C=S?i+o-y:A-y;if(C<=0)return null;var T=w%n.length;return I.createElement("rect",{key:"react-".concat(w),x:y,y:a,width:C,height:c,stroke:"none",fill:n[T],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return I.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},m)}var rRe=(e,t)=>{var{xAxis:n,width:r,height:i,offset:a}=e;return AX(uP(Ao(Ao(Ao({},Ud),n),{},{ticks:_X(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},iRe=(e,t)=>{var{yAxis:n,width:r,height:i,offset:a}=e;return AX(uP(Ao(Ao(Ao({},Ud),n),{},{ticks:_X(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},sRe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:ka.grid};function qJ(e){var t=Z4(),n=J4(),r=TX(),i=Ao(Ao({},Ha(e,sRe)),{},{x:_n(e.x)?e.x:r.left,y:_n(e.y)?e.y:r.top,width:_n(e.width)?e.width:r.width,height:_n(e.height)?e.height:r.height}),{xAxisId:a,yAxisId:o,x:c,y:h,width:f,height:m,syncWithTicks:y,horizontalValues:w,verticalValues:A}=i,S=qa(),C=Qn(F=>hz(F,"xAxis",a,S)),T=Qn(F=>hz(F,"yAxis",o,S));if(!Gu(f)||!Gu(m)||!_n(c)||!_n(h))return null;var D=i.verticalCoordinatesGenerator||rRe,V=i.horizontalCoordinatesGenerator||iRe,{horizontalPoints:L,verticalPoints:K}=i;if((!L||!L.length)&&typeof V=="function"){var Z=w&&w.length,q=V({yAxis:T?Ao(Ao({},T),{},{ticks:Z?w:T.ticks}):void 0,width:t??f,height:n??m,offset:r},Z?!0:y);mN(Array.isArray(q),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof q,"]")),Array.isArray(q)&&(L=q)}if((!K||!K.length)&&typeof D=="function"){var B=A&&A.length,z=D({xAxis:C?Ao(Ao({},C),{},{ticks:B?A:C.ticks}):void 0,width:t??f,height:n??m,offset:r},B?!0:y);mN(Array.isArray(z),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof z,"]")),Array.isArray(z)&&(K=z)}return I.createElement(Gl,{zIndex:i.zIndex},I.createElement("g",{className:"recharts-cartesian-grid"},I.createElement(Z6e,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),I.createElement(tRe,Tp({},i,{horizontalPoints:L})),I.createElement(nRe,Tp({},i,{verticalPoints:K})),I.createElement(J6e,Tp({},i,{offset:r,horizontalPoints:L,xAxis:C,yAxis:T})),I.createElement(eRe,Tp({},i,{offset:r,verticalPoints:K,xAxis:C,yAxis:T}))))}qJ.displayName="CartesianGrid";var aRe={},WJ=Io({name:"errorBars",initialState:aRe,reducers:{addErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]||(e[n]=[]),e[n].push(r)},replaceErrorBar:(e,t)=>{var{itemId:n,prev:r,next:i}=t.payload;e[n]&&(e[n]=e[n].map(a=>a.dataKey===r.dataKey&&a.direction===r.direction?i:a))},removeErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]&&(e[n]=e[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:eLe,replaceErrorBar:tLe,removeErrorBar:nLe}=WJ.actions,oRe=WJ.reducer,lRe=["children"];function cRe(e,t){if(e==null)return{};var n,r,i=uRe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0},hRe=I.createContext(dRe);function KJ(e){var{children:t}=e,n=cRe(e,lRe);return I.createElement(hRe.Provider,{value:n},t)}function OA(e,t){var n,r,i=Qn(f=>rh(f,e)),a=Qn(f=>ih(f,t)),o=(n=i==null?void 0:i.allowDataOverflow)!==null&&n!==void 0?n:va.allowDataOverflow,c=(r=a==null?void 0:a.allowDataOverflow)!==null&&r!==void 0?r:wa.allowDataOverflow,h=o||c;return{needClip:h,needClipX:o,needClipY:c}}function hP(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,i=PA(),{needClipX:a,needClipY:o,needClip:c}=OA(t,n);if(!c||!i)return null;var{x:h,y:f,width:m,height:y}=i;return I.createElement("clipPath",{id:"clipPath-".concat(r)},I.createElement("rect",{x:a?h:h-m/2,y:o?f:f-y/2,width:a?m:m*2,height:o?y:y*2}))}var YJ=(e,t,n,r)=>Yu(e,"xAxis",t,r),XJ=(e,t,n,r)=>Ku(e,"xAxis",t,r),QJ=(e,t,n,r)=>Yu(e,"yAxis",n,r),ZJ=(e,t,n,r)=>Ku(e,"yAxis",n,r),fRe=Ze([Ci,YJ,QJ,XJ,ZJ],(e,t,n,r,i)=>Qc(e,"xAxis")?bf(t,r,!1):bf(n,i,!1)),pRe=(e,t,n,r,i)=>i;function mRe(e){return e.type==="line"}var gRe=Ze([wb,pRe],(e,t)=>e.filter(mRe).find(n=>n.id===t)),xRe=Ze([Ci,YJ,QJ,XJ,ZJ,gRe,fRe,mb],(e,t,n,r,i,a,o,c)=>{var{chartData:h,dataStartIndex:f,dataEndIndex:m}=c;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!=="horizontal"&&e!=="vertical")){var{dataKey:y,data:w}=a,A;if(w!=null&&w.length>0?A=w:A=h==null?void 0:h.slice(f,m+1),A!=null)return LRe({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:y,bandSize:o,displayedData:A})}});function JJ(e){var t=sb(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),c=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(c)||c<0)&&(c=r),{r:o,strokeWidth:c}}return{r:n,strokeWidth:r}}var yRe=["id"],bRe=["type","layout","connectNulls","needClip","shape"],vRe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function Ry(){return Ry=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:Yg(n,t),payload:e}]},kRe=I.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:c,unit:h,tooltipType:f,id:m}=e,y={dataDefinedOnItem:n,getPosition:Tf,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Yg(o,t),hide:c,type:f,color:r,unit:h,graphicalItemId:m}};return I.createElement(aP,{tooltipEntrySettings:y})}),eee=(e,t)=>"".concat(t,"px ").concat(e,"px");function SRe(e,t){for(var n=e.length%2!==0?[...e,0]:e,r=[],i=0;i{var r=n.reduce((w,A)=>w+A,0);if(!r)return eee(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],c=0,h=0;ca){o=[...n.slice(0,c),a-h];break}}var y=o.length%2===0?[0,t]:[t];return[...SRe(n,i),...o,...y].map(w=>"".concat(w,"px")).join(", ")};function jRe(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:c}=r,h=fP(r,yRe),f=Fl(h);return I.createElement(UJ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:f,needClip:o,clipPathId:t})}function IRe(e){var{showLabels:t,children:n,points:r}=e,i=I.useMemo(()=>r==null?void 0:r.map(a=>{var o,c,h={x:(o=a.x)!==null&&o!==void 0?o:0,y:(c=a.y)!==null&&c!==void 0?c:0,width:0,lowerWidth:0,upperWidth:0,height:0};return _u(_u({},h),{},{value:a.value,payload:a.payload,viewBox:h,parentViewBox:void 0,fill:void 0})}),[r]);return I.createElement(rP,{value:t?i:void 0},n)}function xV(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:c,connectNulls:h,needClip:f,shape:m}=a,y=fP(a,bRe),w=_u(_u({},Co(y)),{},{fill:"none",className:"recharts-line-curve",clipPath:f?"url(#clipPath-".concat(t,")"):void 0,points:r,type:o,layout:c,connectNulls:h,strokeDasharray:i??a.strokeDasharray});return I.createElement(I.Fragment,null,(r==null?void 0:r.length)>1&&I.createElement(OJ,Ry({shapeType:"curve",option:m},w,{pathRef:n})),I.createElement(jRe,{points:r,clipPathId:t,props:a}))}function TRe(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function PRe(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:c,isAnimationActive:h,animationBegin:f,animationDuration:m,animationEasing:y,animateNewValues:w,width:A,height:S,onAnimationEnd:C,onAnimationStart:T}=n,D=i.current,V=pb(o,"recharts-line-"),L=I.useRef(V),[K,Z]=I.useState(!1),q=!K,B=I.useCallback(()=>{typeof C=="function"&&C(),Z(!1)},[C]),z=I.useCallback(()=>{typeof T=="function"&&T(),Z(!0)},[T]),F=TRe(r.current),$=I.useRef(0);L.current!==V&&($.current=a.current,L.current=V);var Y=$.current;return I.createElement(IRe,{points:o,showLabels:q},n.children,I.createElement(fb,{animationId:V,begin:f,duration:m,isActive:h,easing:y,onAnimationEnd:B,onAnimationStart:z,key:V},X=>{var J=Ji(Y,F+Y,X),ye=Math.min(J,F),ne;if(h)if(c){var de="".concat(c).split(/[,\s]+/gim).map(Ke=>parseFloat(Ke));ne=CRe(ye,F,de)}else ne=eee(F,ye);else ne=c==null?void 0:String(c);if(X>0&&F>0&&(i.current=o,a.current=Math.max(a.current,ye)),D){var be=D.length/o.length,Ce=X===1?o:o.map((Ke,G)=>{var se=Math.floor(G*be);if(D[se]){var xe=D[se];return _u(_u({},Ke),{},{x:Ji(xe.x,Ke.x,X),y:Ji(xe.y,Ke.y,X)})}return w?_u(_u({},Ke),{},{x:Ji(A*2,Ke.x,X),y:Ji(S/2,Ke.y,X)}):_u(_u({},Ke),{},{x:Ke.x,y:Ke.y})});return i.current=Ce,I.createElement(xV,{props:n,points:Ce,clipPathId:t,pathRef:r,strokeDasharray:ne})}return I.createElement(xV,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:ne})}),I.createElement(iP,{label:n.label}))}function ORe(e){var{clipPathId:t,props:n}=e,r=I.useRef(null),i=I.useRef(0),a=I.useRef(null);return I.createElement(PRe,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var RRe=(e,t)=>{var n,r;return{x:(n=e.x)!==null&&n!==void 0?n:void 0,y:(r=e.y)!==null&&r!==void 0?r:void 0,value:e.value,errorVal:Us(e.payload,t)}};class DRe extends I.Component{render(){var{hide:t,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:c,left:h,width:f,height:m,id:y,needClip:w,zIndex:A}=this.props;if(t)return null;var S=Pi("recharts-line",i),C=y,{r:T,strokeWidth:D}=JJ(n),V=sP(n),L=T*2+D,K=w?"url(#clipPath-".concat(V?"":"dots-").concat(C,")"):void 0;return I.createElement(Gl,{zIndex:A},I.createElement(lo,{className:S},w&&I.createElement("defs",null,I.createElement(hP,{clipPathId:C,xAxisId:a,yAxisId:o}),!V&&I.createElement("clipPath",{id:"clipPath-dots-".concat(C)},I.createElement("rect",{x:h-L/2,y:c-L/2,width:f+L,height:m+L}))),I.createElement(KJ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:RRe,errorBarOffset:0},I.createElement(ORe,{props:this.props,clipPathId:C}))),I.createElement(oI,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:K}))}}var tee={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:ka.line,type:"linear"};function MRe(e){var t=Ha(e,tee),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:c,dot:h,hide:f,isAnimationActive:m,label:y,legendType:w,xAxisId:A,yAxisId:S,id:C}=t,T=fP(t,vRe),{needClip:D}=OA(A,S),V=PA(),L=Pf(),K=qa(),Z=Qn($=>xRe($,A,S,K,C));if(L!=="horizontal"&&L!=="vertical"||Z==null||V==null)return null;var{height:q,width:B,x:z,y:F}=V;return I.createElement(DRe,Ry({},T,{id:C,connectNulls:c,dot:h,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:m,hide:f,label:y,legendType:w,xAxisId:A,yAxisId:S,points:Z,layout:L,height:q,width:B,left:z,top:F,needClip:D}))}function LRe(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:c,displayedData:h}=e;return h.map((f,m)=>{var y=Us(f,o);if(t==="horizontal"){var w=pN({axis:n,ticks:i,bandSize:c,entry:f,index:m}),A=ys(y)?null:r.scale.map(y);return{x:w,y:A??null,value:y,payload:f}}var S=ys(y)?null:n.scale.map(y),C=pN({axis:r,ticks:a,bandSize:c,entry:f,index:m});return S==null||C==null?null:{x:S,y:C,value:y,payload:f}}).filter(Boolean)}function URe(e){var t=Ha(e,tee),n=qa();return I.createElement(lP,{id:t.id,type:"line"},r=>I.createElement(I.Fragment,null,I.createElement(oP,{legendPayload:_Re(t)}),I.createElement(kRe,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:r}),I.createElement(cP,{type:"line",id:r,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),I.createElement(MRe,Ry({},t,{id:r}))))}var nee=I.memo(URe,Am);nee.displayName="Line";function Zu(e,t){var n,r;return(n=(r=e.graphicalItems.cartesianItems.find(i=>i.id===t))===null||r===void 0?void 0:r.xAxisId)!==null&&n!==void 0?n:BJ}function Ju(e,t){var n,r;return(n=(r=e.graphicalItems.cartesianItems.find(i=>i.id===t))===null||r===void 0?void 0:r.yAxisId)!==null&&n!==void 0?n:BJ}var ree=(e,t,n)=>Yu(e,"xAxis",Zu(e,t),n),iee=(e,t,n)=>Ku(e,"xAxis",Zu(e,t),n),see=(e,t,n)=>Yu(e,"yAxis",Ju(e,t),n),aee=(e,t,n)=>Ku(e,"yAxis",Ju(e,t),n),BRe=Ze([Ci,ree,see,iee,aee],(e,t,n,r,i)=>Qc(e,"xAxis")?bf(t,r,!1):bf(n,i,!1)),zRe=(e,t)=>t,oee=Ze([wb,zRe],(e,t)=>e.filter(n=>n.type==="area").find(n=>n.id===t)),lee=e=>{var t=Ci(e),n=Qc(t,"xAxis");return n?"yAxis":"xAxis"},VRe=(e,t)=>{var n=lee(e);return n==="yAxis"?Ju(e,t):Zu(e,t)},FRe=(e,t,n)=>LN(e,lee(e),VRe(e,t),n),$Re=Ze([oee,FRe],(e,t)=>{var n;if(!(e==null||t==null)){var{stackId:r}=e,i=bA(e);if(!(r==null||i==null)){var a=(n=t[r])===null||n===void 0?void 0:n.stackedData,o=a==null?void 0:a.find(c=>c.key===i);if(o!=null)return o.map(c=>[c[0],c[1]])}}}),HRe=Ze([Ci,ree,see,iee,aee,$Re,ZX,BRe,oee,OSe],(e,t,n,r,i,a,o,c,h,f)=>{var{chartData:m,dataStartIndex:y,dataEndIndex:w}=o;if(!(h==null||e!=="horizontal"&&e!=="vertical"||t==null||n==null||r==null||i==null||r.length===0||i.length===0||c==null)){var{data:A}=h,S;if(A&&A.length>0?S=A:S=m==null?void 0:m.slice(y,w+1),S!=null)return uDe({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:y,areaSettings:h,stackedData:a,displayedData:S,chartBaseValue:f,bandSize:c})}}),GRe=["id"],qRe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Gp(){return Gp=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,stroke:r,fill:i,legendType:a,hide:o}=e;return[{inactive:o,dataKey:t,type:a,color:qN(r,i),value:Yg(n,t),payload:e}]},ZRe=I.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:c,unit:h,tooltipType:f,id:m}=e,y={dataDefinedOnItem:n,getPosition:Tf,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Yg(o,t),hide:c,type:f,color:qN(r,a),unit:h,graphicalItemId:m}};return I.createElement(aP,{tooltipEntrySettings:y})});function JRe(e){var{clipPathId:t,points:n,props:r}=e,{needClip:i,dot:a,dataKey:o}=r,c=Fl(r);return I.createElement(UJ,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:c,needClip:i,clipPathId:t})}function eDe(e){var{showLabels:t,children:n,points:r}=e,i=r.map(a=>{var o,c,h={x:(o=a.x)!==null&&o!==void 0?o:0,y:(c=a.y)!==null&&c!==void 0?c:0,width:0,lowerWidth:0,upperWidth:0,height:0};return $0($0({},h),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:h,fill:void 0})});return I.createElement(rP,{value:t?i:void 0},n)}function bV(e){var{points:t,baseLine:n,needClip:r,clipPathId:i,props:a}=e,{layout:o,type:c,stroke:h,connectNulls:f,isRange:m}=a,{id:y}=a,w=cee(a,GRe),A=Fl(w),S=Co(w);return I.createElement(I.Fragment,null,(t==null?void 0:t.length)>1&&I.createElement(lo,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},I.createElement(X1,Gp({},S,{id:y,points:t,connectNulls:f,type:c,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),h!=="none"&&I.createElement(X1,Gp({},A,{className:"recharts-area-curve",layout:o,type:c,connectNulls:f,fill:"none",points:t})),h!=="none"&&m&&Array.isArray(n)&&I.createElement(X1,Gp({},A,{className:"recharts-area-curve",layout:o,type:c,connectNulls:f,fill:"none",points:n}))),I.createElement(JRe,{points:t,props:w,clipPathId:i}))}function tDe(e){var t,n,{alpha:r,baseLine:i,points:a,strokeWidth:o}=e,c=(t=a[0])===null||t===void 0?void 0:t.y,h=(n=a[a.length-1])===null||n===void 0?void 0:n.y;if(!Yr(c)||!Yr(h))return null;var f=r*Math.abs(c-h),m=Math.max(...a.map(y=>y.x||0));return _n(i)?m=Math.max(i,m):i&&Array.isArray(i)&&i.length&&(m=Math.max(...i.map(y=>y.x||0),m)),_n(m)?I.createElement("rect",{x:0,y:cy.y||0));return _n(i)?m=Math.max(i,m):i&&Array.isArray(i)&&i.length&&(m=Math.max(...i.map(y=>y.y||0),m)),_n(m)?I.createElement("rect",{x:c({points:o,baseLine:c}),[o,c]),C=pb(S,"recharts-area-"),T=e3(),[D,V]=I.useState(!1),L=!D,K=I.useCallback(()=>{typeof A=="function"&&A(),V(!1)},[A]),Z=I.useCallback(()=>{typeof w=="function"&&w(),V(!0)},[w]);if(T==null)return null;var q=i.current,B=a.current;return I.createElement(eDe,{showLabels:L,points:o},r.children,I.createElement(fb,{animationId:C,begin:f,duration:m,isActive:h,easing:y,onAnimationEnd:K,onAnimationStart:Z,key:C},z=>{if(q){var F=q.length/o.length,$=z===1?o:o.map((X,J)=>{var ye=Math.floor(J*F);if(q[ye]){var ne=q[ye];return $0($0({},X),{},{x:Ji(ne.x,X.x,z),y:Ji(ne.y,X.y,z)})}return X}),Y;return _n(c)?Y=Ji(B,c,z):ys(c)||Wc(c)?Y=Ji(B,0,z):Y=c.map((X,J)=>{var ye=Math.floor(J*F);if(Array.isArray(B)&&B[ye]){var ne=B[ye];return $0($0({},X),{},{x:Ji(ne.x,X.x,z),y:Ji(ne.y,X.y,z)})}return X}),z>0&&(i.current=$,a.current=Y),I.createElement(bV,{points:$,baseLine:Y,needClip:t,clipPathId:n,props:r})}return z>0&&(i.current=o,a.current=c),I.createElement(lo,null,h&&I.createElement("defs",null,I.createElement("clipPath",{id:"animationClipPath-".concat(n)},I.createElement(rDe,{alpha:z,points:o,baseLine:c,layout:T,strokeWidth:r.strokeWidth}))),I.createElement(lo,{clipPath:"url(#animationClipPath-".concat(n,")")},I.createElement(bV,{points:o,baseLine:c,needClip:t,clipPathId:n,props:r})))}),I.createElement(iP,{label:r.label}))}function sDe(e){var{needClip:t,clipPathId:n,props:r}=e,i=I.useRef(null),a=I.useRef();return I.createElement(iDe,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class aDe extends I.PureComponent{render(){var{hide:t,dot:n,points:r,className:i,top:a,left:o,needClip:c,xAxisId:h,yAxisId:f,width:m,height:y,id:w,baseLine:A,zIndex:S}=this.props;if(t)return null;var C=Pi("recharts-area",i),T=w,{r:D,strokeWidth:V}=JJ(n),L=sP(n),K=D*2+V,Z=c?"url(#clipPath-".concat(L?"":"dots-").concat(T,")"):void 0;return I.createElement(Gl,{zIndex:S},I.createElement(lo,{className:C},c&&I.createElement("defs",null,I.createElement(hP,{clipPathId:T,xAxisId:h,yAxisId:f}),!L&&I.createElement("clipPath",{id:"clipPath-dots-".concat(T)},I.createElement("rect",{x:o-K/2,y:a-K/2,width:m+K,height:y+K}))),I.createElement(sDe,{needClip:c,clipPathId:T,props:this.props})),I.createElement(oI,{points:r,mainColor:qN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:Z}),this.props.isRange&&Array.isArray(A)&&I.createElement(oI,{points:A,mainColor:qN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:Z}))}}var oDe={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:ka.area};function lDe(e){var t,{activeDot:n,animationBegin:r,animationDuration:i,animationEasing:a,connectNulls:o,dot:c,fill:h,fillOpacity:f,hide:m,isAnimationActive:y,legendType:w,stroke:A,xAxisId:S,yAxisId:C}=e,T=cee(e,qRe),D=Pf(),V=lJ(),{needClip:L}=OA(S,C),K=qa(),{points:Z,isRange:q,baseLine:B}=(t=Qn(J=>HRe(J,e.id,K)))!==null&&t!==void 0?t:{},z=PA();if(D!=="horizontal"&&D!=="vertical"||z==null||V!=="AreaChart"&&V!=="ComposedChart")return null;var{height:F,width:$,x:Y,y:X}=z;return!Z||!Z.length?null:I.createElement(aDe,Gp({},T,{activeDot:n,animationBegin:r,animationDuration:i,animationEasing:a,baseLine:B,connectNulls:o,dot:c,fill:h,fillOpacity:f,height:F,hide:m,layout:D,isAnimationActive:y,isRange:q,legendType:w,needClip:L,points:Z,stroke:A,width:$,left:Y,top:X,xAxisId:S,yAxisId:C}))}var cDe=(e,t,n,r,i)=>{var a=n??t;if(_n(a))return a;var o=e==="horizontal"?i:r,c=o.scale.domain();if(o.type==="number"){var h=Math.max(c[0],c[1]),f=Math.min(c[0],c[1]);return a==="dataMin"?f:a==="dataMax"||h<0?h:Math.max(Math.min(c[0],c[1]),0)}return a==="dataMin"?c[0]:a==="dataMax"?c[1]:c[0]};function uDe(e){var{areaSettings:{connectNulls:t,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:c,yAxis:h,displayedData:f,dataStartIndex:m,xAxisTicks:y,yAxisTicks:w,bandSize:A}=e,S=i&&i.length,C=cDe(a,o,n,c,h),T=a==="horizontal",D=!1,V=f.map((K,Z)=>{var q,B,z,F;if(S)F=i[m+Z];else{var $=Us(K,r);Array.isArray($)?(F=$,D=!0):F=[C,$]}var Y=(q=(B=F)===null||B===void 0?void 0:B[1])!==null&&q!==void 0?q:null,X=Y==null||S&&!t&&Us(K,r)==null;if(T){var J;return{x:pN({axis:c,ticks:y,bandSize:A,entry:K,index:Z}),y:X?null:(J=h.scale.map(Y))!==null&&J!==void 0?J:null,value:F,payload:K}}return{x:X?null:(z=c.scale.map(Y))!==null&&z!==void 0?z:null,y:pN({axis:h,ticks:w,bandSize:A,entry:K,index:Z}),value:F,payload:K}}),L;return S||D?L=V.map(K=>{var Z,q=Array.isArray(K.value)?K.value[0]:null;if(T){var B;return{x:K.x,y:q!=null&&K.y!=null&&(B=h.scale.map(q))!==null&&B!==void 0?B:null,payload:K.payload}}return{x:q!=null&&(Z=c.scale.map(q))!==null&&Z!==void 0?Z:null,y:K.y,payload:K.payload}}):L=T?h.scale.map(C):c.scale.map(C),{points:V,baseLine:L??0,isRange:D}}function dDe(e){var t=Ha(e,oDe),n=qa();return I.createElement(lP,{id:t.id,type:"area"},r=>I.createElement(I.Fragment,null,I.createElement(oP,{legendPayload:QRe(t)}),I.createElement(ZRe,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:r}),I.createElement(cP,{type:"area",id:r,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:kX(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),I.createElement(lDe,Gp({},t,{id:r}))))}var lI=I.memo(dDe,Am);lI.displayName="Area";var hDe="Invariant failed";function fDe(e,t){throw new Error(hDe)}function cI(){return cI=Object.assign?Object.assign.bind():function(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(_n(t))return t;var a=_n(r)||ys(r);return a?t(r,i):(a||fDe(),n)}},mDe=(e,t,n)=>n,gDe=(e,t)=>t,kb=Ze([wb,gDe],(e,t)=>e.filter(n=>n.type==="bar").find(n=>n.id===t)),xDe=Ze([kb],e=>e==null?void 0:e.maxBarSize),yDe=(e,t,n,r)=>r,bDe=Ze([Ci,wb,Zu,Ju,mDe],(e,t,n,r,i)=>t.filter(a=>e==="horizontal"?a.xAxisId===n:a.yAxisId===r).filter(a=>a.isPanorama===i).filter(a=>a.hide===!1).filter(a=>a.type==="bar")),vDe=(e,t,n)=>{var r=Ci(e),i=Zu(e,t),a=Ju(e,t);if(!(i==null||a==null))return r==="horizontal"?LN(e,"yAxis",a,n):LN(e,"xAxis",i,n)},wDe=(e,t)=>{var n=Ci(e),r=Zu(e,t),i=Ju(e,t);if(!(r==null||i==null))return n==="horizontal"?dz(e,"xAxis",r):dz(e,"yAxis",i)},NDe=Ze([bDe,PSe,wDe],ZOe),EDe=(e,t,n)=>{var r,i,a=kb(e,t);if(a==null)return 0;var o=Zu(e,t),c=Ju(e,t);if(o==null||c==null)return 0;var h=Ci(e),f=uQ(e),{maxBarSize:m}=a,y=ys(m)?f:m,w,A;return h==="horizontal"?(w=Yu(e,"xAxis",o,n),A=Ku(e,"xAxis",o,n)):(w=Yu(e,"yAxis",c,n),A=Ku(e,"yAxis",c,n)),(r=(i=bf(w,A,!0))!==null&&i!==void 0?i:y)!==null&&r!==void 0?r:0},uee=(e,t,n)=>{var r=Ci(e),i=Zu(e,t),a=Ju(e,t);if(!(i==null||a==null)){var o,c;return r==="horizontal"?(o=Yu(e,"xAxis",i,n),c=Ku(e,"xAxis",i,n)):(o=Yu(e,"yAxis",a,n),c=Ku(e,"yAxis",a,n)),bf(o,c)}},ADe=Ze([NDe,uQ,TSe,dQ,EDe,uee,xDe],r6e),_De=(e,t,n)=>{var r=Zu(e,t);if(r!=null)return Yu(e,"xAxis",r,n)},kDe=(e,t,n)=>{var r=Ju(e,t);if(r!=null)return Yu(e,"yAxis",r,n)},SDe=(e,t,n)=>{var r=Zu(e,t);if(r!=null)return Ku(e,"xAxis",r,n)},CDe=(e,t,n)=>{var r=Ju(e,t);if(r!=null)return Ku(e,"yAxis",r,n)},jDe=Ze([ADe,kb],s6e),IDe=Ze([vDe,kb],i6e),TDe=Ze([Ga,Y4,_De,kDe,SDe,CDe,jDe,Ci,ZX,uee,IDe,kb,yDe],(e,t,n,r,i,a,o,c,h,f,m,y,w)=>{var{chartData:A,dataStartIndex:S,dataEndIndex:C}=h;if(!(y==null||o==null||t==null||c!=="horizontal"&&c!=="vertical"||n==null||r==null||i==null||a==null||f==null)){var{data:T}=y,D;if(T!=null&&T.length>0?D=T:D=A==null?void 0:A.slice(S,C+1),D!=null)return s8e({layout:c,barSettings:y,pos:o,parentViewBox:t,bandSize:f,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:m,displayedData:D,offset:e,cells:w,dataStartIndex:S})}}),PDe=["index"];function uI(){return uI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=I.useContext(dee);if(t!=null)return t.stackId;if(e!=null)return kX(e)},MDe=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),LDe=e=>{var t=I.useContext(dee);if(t!=null){var{stackId:n}=t;return"url(#".concat(MDe(n,e),")")}},hee=e=>{var{index:t}=e,n=ODe(e,PDe),r=LDe(t);return I.createElement(lo,uI({className:"recharts-bar-stack-layer",clipPath:r},n))},UDe=["onMouseEnter","onMouseLeave","onClick"],BDe=["value","background","tooltipPosition"],zDe=["id"],VDe=["onMouseEnter","onClick","onMouseLeave"];function vf(){return vf=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:Yg(n,t),payload:e}]},WDe=I.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,unit:c,tooltipType:h,id:f}=e,m={dataDefinedOnItem:void 0,getPosition:Tf,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:Yg(a,t),hide:o,type:h,color:i,unit:c,graphicalItemId:f}};return I.createElement(aP,{tooltipEntrySettings:m})});function KDe(e){var t=Qn(gm),{data:n,dataKey:r,background:i,allOtherBarProps:a}=e,{onMouseEnter:o,onMouseLeave:c,onClick:h}=a,f=WN(a,UDe),m=RJ(o,r,a.id),y=DJ(c),w=MJ(h,r,a.id);if(!i||n==null)return null;var A=sb(i);return I.createElement(Gl,{zIndex:a6e(i,ka.barBackground)},n.map((S,C)=>{var{value:T,background:D,tooltipPosition:V}=S,L=WN(S,BDe);if(!D)return null;var K=m(S,C),Z=y(S,C),q=w(S,C),B=Vo(Vo(Vo(Vo(Vo({option:i,isActive:String(C)===t},L),{},{fill:"#eee"},D),A),YE(f,S,C)),{},{onMouseEnter:K,onMouseLeave:Z,onClick:q,dataKey:r,index:C,className:"recharts-bar-background-rectangle"});return I.createElement(pP,vf({key:"background-bar-".concat(C)},B))}))}function YDe(e){var{showLabels:t,children:n,rects:r}=e,i=r==null?void 0:r.map(a=>{var o={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return Vo(Vo({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return I.createElement(rP,{value:t?i:void 0},n)}function XDe(e){var{shape:t,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=e,c=Qn(gm),h=Qn(sJ),f=n&&String(i.originalDataIndex)===c&&(h==null||o===h),[m,y]=I.useState(!1),[w,A]=I.useState(!1);I.useEffect(()=>{var L;return f?(y(!0),L=requestAnimationFrame(()=>{A(!0)})):A(!1),()=>{cancelAnimationFrame(L)}},[f]);var S=I.useCallback(()=>{f||y(!1)},[f]),C=f&&w,T=f||m,D;f?n===!0?D=t:D=n:D=t;var V=I.createElement(pP,vf({},r,{name:String(r.name)},i,{isActive:C,option:D,index:a,dataKey:o,onTransitionEnd:S}));return T?I.createElement(Gl,{zIndex:ka.activeBar},I.createElement(hee,{index:i.originalDataIndex},V)):V}function QDe(e){var{shape:t,baseProps:n,entry:r,index:i,dataKey:a}=e;return I.createElement(pP,vf({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:a}))}function ZDe(e){var t,{data:n,props:r}=e,i=(t=Fl(r))!==null&&t!==void 0?t:{},{id:a}=i,o=WN(i,zDe),{shape:c,dataKey:h,activeBar:f}=r,{onMouseEnter:m,onClick:y,onMouseLeave:w}=r,A=WN(r,VDe),S=RJ(m,h,a),C=DJ(w),T=MJ(y,h,a);return n?I.createElement(I.Fragment,null,n.map((D,V)=>I.createElement(hee,vf({index:D.originalDataIndex,key:"rectangle-".concat(D==null?void 0:D.x,"-").concat(D==null?void 0:D.y,"-").concat(D==null?void 0:D.value,"-").concat(V),className:"recharts-bar-rectangle"},YE(A,D,V),{onMouseEnter:S(D,V),onMouseLeave:C(D,V),onClick:T(D,V)}),f?I.createElement(XDe,{shape:c,activeBar:f,baseProps:o,entry:D,index:V,dataKey:h}):I.createElement(QDe,{shape:c,baseProps:o,entry:D,index:V,dataKey:h})))):null}function JDe(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:c,animationEasing:h,onAnimationEnd:f,onAnimationStart:m}=t,y=n.current,w=pb(t,"recharts-bar-"),[A,S]=I.useState(!1),C=!A,T=I.useCallback(()=>{typeof f=="function"&&f(),S(!1)},[f]),D=I.useCallback(()=>{typeof m=="function"&&m(),S(!0)},[m]);return I.createElement(YDe,{showLabels:C,rects:r},I.createElement(fb,{animationId:w,begin:o,duration:c,isActive:a,easing:h,onAnimationEnd:T,onAnimationStart:D,key:w},V=>{var L=V===1?r:r==null?void 0:r.map((K,Z)=>{var q=y&&y[Z];if(q)return Vo(Vo({},K),{},{x:Ji(q.x,K.x,V),y:Ji(q.y,K.y,V),width:Ji(q.width,K.width,V),height:Ji(q.height,K.height,V)});if(i==="horizontal"){var B=Ji(0,K.height,V),z=Ji(K.stackedBarStart,K.y,V);return Vo(Vo({},K),{},{y:z,height:B})}var F=Ji(0,K.width,V),$=Ji(K.stackedBarStart,K.x,V);return Vo(Vo({},K),{},{width:F,x:$})});return V>0&&(n.current=L??null),L==null?null:I.createElement(lo,null,I.createElement(ZDe,{props:t,data:L}))}),I.createElement(iP,{label:t.label}),t.children)}function e8e(e){var t=I.useRef(null);return I.createElement(JDe,{previousRectanglesRef:t,props:e})}var fee=0,t8e=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:Us(e,t)}};class n8e extends I.PureComponent{render(){var{hide:t,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:o,needClip:c,background:h,id:f}=this.props;if(t||n==null)return null;var m=Pi("recharts-bar",i),y=f;return I.createElement(lo,{className:m,id:f},c&&I.createElement("defs",null,I.createElement(hP,{clipPathId:y,xAxisId:a,yAxisId:o})),I.createElement(lo,{className:"recharts-bar-rectangles",clipPath:c?"url(#clipPath-".concat(y,")"):void 0},I.createElement(KDe,{data:n,dataKey:r,background:h,allOtherBarProps:this.props}),I.createElement(e8e,this.props)))}}var r8e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:fee,xAxisId:0,yAxisId:0,zIndex:ka.bar};function i8e(e){var{xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:c,animationDuration:h,animationEasing:f,isAnimationActive:m}=e,{needClip:y}=OA(t,n),w=Pf(),A=qa(),S=XPe(e.children,gJ),C=Qn(V=>TDe(V,e.id,A,S));if(w!=="vertical"&&w!=="horizontal")return null;var T,D=C==null?void 0:C[0];return D==null||D.height==null||D.width==null?T=0:T=w==="vertical"?D.height/2:D.width/2,I.createElement(KJ,{xAxisId:t,yAxisId:n,data:C,dataPointFormatter:t8e,errorBarOffset:T},I.createElement(n8e,vf({},e,{layout:w,needClip:y,data:C,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:c,animationDuration:h,animationEasing:f,isAnimationActive:m})))}function s8e(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r,hasCustomShape:i},pos:a,bandSize:o,xAxis:c,yAxis:h,xAxisTicks:f,yAxisTicks:m,stackedData:y,displayedData:w,offset:A,cells:S,parentViewBox:C,dataStartIndex:T}=e,D=t==="horizontal"?h:c,V=y?D.scale.domain():null,L=x5e({numericAxis:D}),K=D.scale.map(L);return w.map((Z,q)=>{var B,z,F,$,Y,X;if(y){var J=y[q+T];if(J==null)return null;B=h5e(J,V)}else B=Us(Z,n),Array.isArray(B)||(B=[L,B]);var ye=pDe(r,fee)(B[1],q);if(t==="horizontal"){var ne,de=h.scale.map(B[0]),be=h.scale.map(B[1]);if(de==null||be==null)return null;z=sU({axis:c,ticks:f,bandSize:o,offset:a.offset,entry:Z,index:q}),F=(ne=be??de)!==null&&ne!==void 0?ne:void 0,$=a.size;var Ce=de-be;if(Y=Wc(Ce)?0:Ce,X={x:z,y:A.top,width:$,height:A.height},Math.abs(ye)>0&&Math.abs(Y)0&&Math.abs($)I.createElement(I.Fragment,null,I.createElement(oP,{legendPayload:qDe(t)}),I.createElement(WDe,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:i}),I.createElement(cP,{type:"bar",id:i,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r,hasCustomShape:t.shape!=null}),I.createElement(Gl,{zIndex:t.zIndex},I.createElement(i8e,vf({},t,{id:i})))))}var pee=I.memo(a8e,Am);pee.displayName="Bar";var o8e=["domain","range"],l8e=["domain","range"];function wV(e,t){if(e==null)return{};var n,r,i=c8e(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{if(o!=null)return AV(AV({},a),{},{type:o})},[a,o]);return I.useLayoutEffect(()=>{c!=null&&(n.current===null?t(LOe(c)):n.current!==c&&t(UOe({prev:n.current,next:c})),n.current=c)},[c,t]),I.useLayoutEffect(()=>()=>{n.current&&(t(BOe(n.current)),n.current=null)},[t]),null}var y8e=e=>{var{xAxisId:t,className:n}=e,r=Qn(Y4),i=qa(),a="xAxis",o=Qn(D=>LZ(D,a,t,i)),c=Qn(D=>RZ(D,t)),h=Qn(D=>pTe(D,t)),f=Qn(D=>nZ(D,t));if(c==null||h==null||f==null)return null;var{dangerouslySetInnerHTML:m,ticks:y,scale:w}=e,A=hI(e,d8e),{id:S,scale:C}=f,T=hI(f,h8e);return I.createElement(dP,dI({},A,T,{x:h.x,y:h.y,width:c.width,height:c.height,className:Pi("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:o,axisType:a,axisId:t}))},b8e={allowDataOverflow:va.allowDataOverflow,allowDecimals:va.allowDecimals,allowDuplicatedCategory:va.allowDuplicatedCategory,angle:va.angle,axisLine:Ud.axisLine,height:va.height,hide:!1,includeHidden:va.includeHidden,interval:va.interval,label:!1,minTickGap:va.minTickGap,mirror:va.mirror,orientation:va.orientation,padding:va.padding,reversed:va.reversed,scale:va.scale,tick:va.tick,tickCount:va.tickCount,tickLine:Ud.tickLine,tickSize:Ud.tickSize,type:va.type,niceTicks:va.niceTicks,xAxisId:0},v8e=e=>{var t=Ha(e,b8e);return I.createElement(I.Fragment,null,I.createElement(x8e,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),I.createElement(y8e,t))},gee=I.memo(v8e,mee);gee.displayName="XAxis";var w8e=["type"],N8e=["dangerouslySetInnerHTML","ticks","scale"],E8e=["id","scale"];function fI(){return fI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if(o!=null)return kV(kV({},a),{},{type:o})},[o,a]);return I.useLayoutEffect(()=>{c!=null&&(n.current===null?t(zOe(c)):n.current!==c&&t(VOe({prev:n.current,next:c})),n.current=c)},[c,t]),I.useLayoutEffect(()=>()=>{n.current&&(t(FOe(n.current)),n.current=null)},[t]),null}function j8e(e){var{yAxisId:t,className:n,width:r,label:i}=e,a=I.useRef(null),o=I.useRef(null),c=Qn(Y4),h=qa(),f=bs(),m="yAxis",y=Qn(q=>DZ(q,t)),w=Qn(q=>gTe(q,t)),A=Qn(q=>LZ(q,m,t,h)),S=Qn(q=>rZ(q,t));if(I.useLayoutEffect(()=>{if(!(r!=="auto"||!y||nP(i)||I.isValidElement(i)||S==null)){var q=a.current;if(q){var B=q.getCalculatedWidth();Math.round(y.width)!==Math.round(B)&&f($Oe({id:t,width:B}))}}},[A,y,f,i,t,r,S]),y==null||w==null||S==null)return null;var{dangerouslySetInnerHTML:C,ticks:T,scale:D}=e,V=pI(e,N8e),{id:L,scale:K}=S,Z=pI(S,E8e);return I.createElement(dP,fI({},V,Z,{ref:a,labelRef:o,x:w.x,y:w.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:y.width,height:y.height,className:Pi("recharts-".concat(m," ").concat(m),n),viewBox:c,ticks:A,axisType:m,axisId:t}))}var I8e={allowDataOverflow:wa.allowDataOverflow,allowDecimals:wa.allowDecimals,allowDuplicatedCategory:wa.allowDuplicatedCategory,angle:wa.angle,axisLine:Ud.axisLine,hide:!1,includeHidden:wa.includeHidden,interval:wa.interval,label:!1,minTickGap:wa.minTickGap,mirror:wa.mirror,orientation:wa.orientation,padding:wa.padding,reversed:wa.reversed,scale:wa.scale,tick:wa.tick,tickCount:wa.tickCount,tickLine:Ud.tickLine,tickSize:Ud.tickSize,type:wa.type,niceTicks:wa.niceTicks,width:wa.width,yAxisId:0},T8e=e=>{var t=Ha(e,I8e);return I.createElement(I.Fragment,null,I.createElement(C8e,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),I.createElement(j8e,t))},xee=I.memo(T8e,mee);xee.displayName="YAxis";var P8e=(e,t)=>t,mP=Ze([P8e,Ci,yQ,Ka,tJ,sh,U4e,Ga],G4e);function O8e(e){return"getBBox"in e.currentTarget&&typeof e.currentTarget.getBBox=="function"}function gP(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(O8e(e)){var i=e.currentTarget.getBBox();n=i.width>0?t.width/i.width:1,r=i.height>0?t.height/i.height:1}else{var a=e.currentTarget;n=a.offsetWidth>0?t.width/a.offsetWidth:1,r=a.offsetHeight>0?t.height/a.offsetHeight:1}var o=(c,h)=>({relativeX:Math.round((c-t.left)/n),relativeY:Math.round((h-t.top)/r)});return"touches"in e?Array.from(e.touches).map(c=>o(c.clientX,c.clientY)):o(e.clientX,e.clientY)}var yee=$l("mouseClick"),bee=lb();bee.startListening({actionCreator:yee,effect:(e,t)=>{var n=e.payload,r=mP(t.getState(),gP(n));(r==null?void 0:r.activeIndex)!=null&&t.dispatch(PTe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var mI=$l("mouseMove"),vee=lb(),_0=null,ip=null,IS=null;vee.startListening({actionCreator:mI,effect:(e,t)=>{var n=e.payload,r=t.getState(),{throttleDelay:i,throttledEvents:a}=r.eventSettings,o=a==="all"||(a==null?void 0:a.includes("mousemove"));_0!==null&&(cancelAnimationFrame(_0),_0=null),ip!==null&&(typeof i!="number"||!o)&&(clearTimeout(ip),ip=null),IS=gP(n);var c=()=>{var h=t.getState(),f=Ab(h,h.tooltip.settings.shared);if(!IS){_0=null,ip=null;return}if(f==="axis"){var m=mP(h,IS);(m==null?void 0:m.activeIndex)!=null?t.dispatch(GZ({activeIndex:m.activeIndex,activeDataKey:void 0,activeCoordinate:m.activeCoordinate})):t.dispatch(HZ())}_0=null,ip=null};if(!o){c();return}i==="raf"?_0=requestAnimationFrame(c):typeof i=="number"&&ip===null&&(ip=setTimeout(c,i))}});function R8e(e,t){return t instanceof HTMLElement?"HTMLElement <".concat(t.tagName,' class="').concat(t.className,'">'):t===window?"global.window":e==="children"&&typeof t=="object"&&t!==null?"<>":t}var SV={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},wee=Io({name:"rootProps",initialState:SV,reducers:{updateOptions:(e,t)=>{var n;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(n=t.payload.barGap)!==null&&n!==void 0?n:SV.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),D8e=wee.reducer,{updateOptions:M8e}=wee.actions,L8e=null,U8e={updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)},Nee=Io({name:"polarOptions",initialState:L8e,reducers:U8e}),{updatePolarOptions:rLe}=Nee.actions,B8e=Nee.reducer,Eee=$l("keyDown"),Aee=$l("focus"),_ee=$l("blur"),RA=lb(),k0=null,sp=null,gw=null;RA.startListening({actionCreator:Eee,effect:(e,t)=>{gw=e.payload,k0!==null&&(cancelAnimationFrame(k0),k0=null);var n=t.getState(),{throttleDelay:r,throttledEvents:i}=n.eventSettings,a=i==="all"||i.includes("keydown");sp!==null&&(typeof r!="number"||!a)&&(clearTimeout(sp),sp=null);var o=()=>{try{var c=t.getState(),h=c.rootProps.accessibilityLayer!==!1;if(!h)return;var{keyboardInteraction:f}=c.tooltip,m=gw;if(m!=="ArrowRight"&&m!=="ArrowLeft"&&m!=="Enter")return;var y=Q1(f,mm(c),Rg(c),Dg(c)),w=y==null?-1:Number(y),A=!Number.isFinite(w)||w<0,S=sh(c),C=mm(c),T=Ab(c,c.tooltip.settings.shared);if(m==="Enter"){if(A)return;var D=zN(c,T,"hover",String(f.index));t.dispatch(BN({active:!f.active,activeIndex:f.index,activeCoordinate:D}));return}var V=wTe(c),L=V==="left-to-right"?1:-1,K=m==="ArrowRight"?1:-1,Z;if(A){var q=Rg(c),B=Dg(c),z=K*L,F=ye=>({active:!1,index:String(ye),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(Z=-1,z>0){for(var $=0;$=0;Y--)if(Q1(F(Y),C,q,B)!=null){Z=Y;break}if(Z<0)return}else{Z=w+K*L;var X=(S==null?void 0:S.length)||C.length;if(X===0||Z>=X||Z<0)return}var J=zN(c,T,"hover",String(Z));t.dispatch(BN({active:!0,activeIndex:Z.toString(),activeCoordinate:J}))}finally{k0=null,sp=null}};if(!a){o();return}r==="raf"?k0=requestAnimationFrame(o):typeof r=="number"&&sp===null&&(o(),gw=null,sp=setTimeout(()=>{gw?o():(sp=null,k0=null)},r))}});RA.startListening({actionCreator:Aee,effect:(e,t)=>{var n=t.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var a="0",o=Ab(n,n.tooltip.settings.shared),c=zN(n,o,"hover",String(a));t.dispatch(BN({active:!0,activeIndex:a,activeCoordinate:c}))}}}});RA.startListening({actionCreator:_ee,effect:(e,t)=>{var n=t.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;i.active&&t.dispatch(BN({active:!1,activeIndex:i.index,activeCoordinate:i.coordinate}))}}});function kee(e){e.persist();var{currentTarget:t}=e;return new Proxy(e,{get:(n,r)=>{if(r==="currentTarget")return t;var i=Reflect.get(n,r);return typeof i=="function"?i.bind(n):i}})}var sc=$l("externalEvent"),See=lb(),xw=new Map,f1=new Map,TS=new Map;See.startListening({actionCreator:sc,effect:(e,t)=>{var{handler:n,reactEvent:r}=e.payload;if(n!=null){var i=r.type,a=kee(r);TS.set(i,{handler:n,reactEvent:a});var o=xw.get(i);o!==void 0&&(cancelAnimationFrame(o),xw.delete(i));var c=t.getState(),{throttleDelay:h,throttledEvents:f}=c.eventSettings,m=f,y=m==="all"||(m==null?void 0:m.includes(i)),w=f1.get(i);w!==void 0&&(typeof h!="number"||!y)&&(clearTimeout(w),f1.delete(i));var A=()=>{var T=TS.get(i);try{if(!T)return;var{handler:D,reactEvent:V}=T,L=t.getState(),K={activeCoordinate:E4e(L),activeDataKey:sJ(L),activeIndex:gm(L),activeLabel:iJ(L),activeTooltipIndex:gm(L),isTooltipActive:A4e(L)};D&&D(K,V)}finally{xw.delete(i),f1.delete(i),TS.delete(i)}};if(!y){A();return}if(h==="raf"){var S=requestAnimationFrame(A);xw.set(i,S)}else if(typeof h=="number"){if(!f1.has(i)){A();var C=setTimeout(A,h);f1.set(i,C)}}else A()}}});var z8e=Ze([rx],e=>e.tooltipItemPayloads),V8e=Ze([z8e,(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(a=>a.settings.graphicalItemId===n);if(r!=null){var{getPosition:i}=r;if(i!=null)return i(t)}}}),Cee=$l("touchMove"),jee=lb(),ap=null,Uh=null,CV=null,p1=null;jee.startListening({actionCreator:Cee,effect:(e,t)=>{var n=e.payload;if(!(n.touches==null||n.touches.length===0)){p1=kee(n);var r=t.getState(),{throttleDelay:i,throttledEvents:a}=r.eventSettings,o=a==="all"||a.includes("touchmove");ap!==null&&(cancelAnimationFrame(ap),ap=null),Uh!==null&&(typeof i!="number"||!o)&&(clearTimeout(Uh),Uh=null),CV=Array.from(n.touches).map(h=>gP({clientX:h.clientX,clientY:h.clientY,currentTarget:n.currentTarget}));var c=()=>{if(p1!=null){var h=t.getState(),f=Ab(h,h.tooltip.settings.shared);if(f==="axis"){var m,y=(m=CV)===null||m===void 0?void 0:m[0];if(y==null){ap=null,Uh=null;return}var w=mP(h,y);(w==null?void 0:w.activeIndex)!=null&&t.dispatch(GZ({activeIndex:w.activeIndex,activeDataKey:void 0,activeCoordinate:w.activeCoordinate}))}else if(f==="item"){var A,S=p1.touches[0];if(document.elementFromPoint==null||S==null)return;var C=document.elementFromPoint(S.clientX,S.clientY);if(!C||!C.getAttribute)return;var T=C.getAttribute(A5e),D=(A=C.getAttribute(_5e))!==null&&A!==void 0?A:void 0,V=Sm(h).find(Z=>Z.id===D);if(T==null||V==null||D==null)return;var{dataKey:L}=V,K=V8e(h,T,D);t.dispatch($Z({activeDataKey:L,activeIndex:T,activeCoordinate:K,activeGraphicalItemId:D}))}ap=null,Uh=null}};if(!o){c();return}i==="raf"?ap=requestAnimationFrame(c):typeof i=="number"&&Uh===null&&(c(),p1=null,Uh=setTimeout(()=>{p1?c():(Uh=null,ap=null)},i))}}});var Iee={throttleDelay:"raf",throttledEvents:["mousemove","touchmove","pointermove","scroll","wheel"]},Tee=Io({name:"eventSettings",initialState:Iee,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=t.payload.throttledEvents)}}}),{setEventSettings:F8e}=Tee.actions,$8e=Tee.reducer,H8e=YY({brush:l6e,cartesianAxis:HOe,chartData:N3e,errorBars:oRe,eventSettings:$8e,graphicalItems:EOe,layout:o5e,legend:b_e,options:x3e,polarAxis:GPe,polarOptions:B8e,referenceElements:h6e,renderedTicks:j6e,rootProps:D8e,tooltip:OTe,zIndex:i3e}),G8e=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return PAe({reducer:H8e,preloadedState:t,middleware:r=>{var i;return r({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((i="es6")!==null&&i!==void 0?i:"")}).concat([bee.middleware,vee.middleware,RA.middleware,See.middleware,jee.middleware])},enhancers:r=>{var i=r;return typeof r=="function"&&(i=r()),i.concat(uX({type:"raf"}))},devTools:{serialize:{replacer:R8e},name:"recharts-".concat(n)}})};function q8e(e){var{preloadedState:t,children:n,reduxStoreName:r}=e,i=qa(),a=I.useRef(null);if(i)return n;a.current==null&&(a.current=G8e(t,r));var o=F4;return I.createElement(D_e,{context:o,store:a.current},n)}function W8e(e){var{layout:t,margin:n}=e,r=bs(),i=qa();return I.useEffect(()=>{i||(r(i5e(t)),r(r5e(n)))},[r,i,t,n]),null}var K8e=I.memo(W8e,Am);function Y8e(e){var t=bs();return I.useEffect(()=>{t(M8e(e))},[t,e]),null}var X8e=e=>{var t=bs();return I.useEffect(()=>{t(F8e(e))},[t,e]),null},Q8e=I.memo(X8e,Am);function jV(e){var{zIndex:t,isPanorama:n}=e,r=I.useRef(null),i=bs();return I.useLayoutEffect(()=>(r.current&&i(n3e({zIndex:t,element:r.current,isPanorama:n})),()=>{i(r3e({zIndex:t,isPanorama:n}))}),[i,t,n]),I.createElement("g",{tabIndex:-1,ref:r,className:"recharts-zIndex-layer_".concat(t)})}function IV(e){var{children:t,isPanorama:n}=e,r=Qn(W4e);if(!r||r.length===0)return t;var i=r.filter(o=>o<0),a=r.filter(o=>o>0);return I.createElement(I.Fragment,null,i.map(o=>I.createElement(jV,{key:o,zIndex:o,isPanorama:n})),t,a.map(o=>I.createElement(jV,{key:o,zIndex:o,isPanorama:n})))}var Z8e=["children"];function J8e(e,t){if(e==null)return{};var n,r,i=eMe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var n=Z4(),r=J4(),i=FX();if(!Gu(n)||!Gu(r))return null;var{children:a,otherAttributes:o,title:c,desc:h}=e,f,m;return o!=null&&(typeof o.tabIndex=="number"?f=o.tabIndex:f=i?0:void 0,typeof o.role=="string"?m=o.role:m=i?"application":void 0),I.createElement(P4,KN({},o,{title:c,desc:h,role:m,tabIndex:f,width:n,height:r,style:tMe,ref:t}),a)}),rMe=e=>{var{children:t}=e,n=Qn(cA);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return I.createElement(P4,{width:r,height:i,x:o,y:a},t)},TV=I.forwardRef((e,t)=>{var{children:n}=e,r=J8e(e,Z8e),i=qa();return i?I.createElement(rMe,null,I.createElement(IV,{isPanorama:!0},n)):I.createElement(nMe,KN({ref:t},r),I.createElement(IV,{isPanorama:!1},n))});function iMe(){var e=bs(),[t,n]=I.useState(null),r=Qn(E5e);return I.useEffect(()=>{if(t!=null){var i=t.getBoundingClientRect(),a=i.width/t.offsetWidth;Yr(a)&&a!==r&&e(a5e(a))}},[t,e,r]),n}function PV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function sMe(e){for(var t=1;t(T3e(),null);function YN(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var uMe=I.forwardRef((e,t)=>{var n,r,i=I.useRef(null),[a,o]=I.useState({containerWidth:YN((n=e.style)===null||n===void 0?void 0:n.width),containerHeight:YN((r=e.style)===null||r===void 0?void 0:r.height)}),c=I.useCallback((f,m)=>{o(y=>{var w=Math.round(f),A=Math.round(m);return y.containerWidth===w&&y.containerHeight===A?y:{containerWidth:w,containerHeight:A}})},[]),h=I.useCallback(f=>{if(typeof t=="function"&&t(f),i.current!=null&&(i.current.disconnect(),i.current=null),f!=null&&typeof ResizeObserver<"u"){var{width:m,height:y}=f.getBoundingClientRect();c(m,y);var w=S=>{var C=S[0];if(C!=null){var{width:T,height:D}=C.contentRect;c(T,D)}},A=new ResizeObserver(w);A.observe(f),i.current=A}},[t,c]);return I.useEffect(()=>()=>{var f=i.current;f!=null&&f.disconnect()},[c]),I.createElement(I.Fragment,null,I.createElement(ub,{width:a.containerWidth,height:a.containerHeight}),I.createElement("div",uf({ref:h},e)))}),dMe=I.forwardRef((e,t)=>{var{width:n,height:r}=e,[i,a]=I.useState({containerWidth:YN(n),containerHeight:YN(r)}),o=I.useCallback((h,f)=>{a(m=>{var y=Math.round(h),w=Math.round(f);return m.containerWidth===y&&m.containerHeight===w?m:{containerWidth:y,containerHeight:w}})},[]),c=I.useCallback(h=>{if(typeof t=="function"&&t(h),h!=null){var{width:f,height:m}=h.getBoundingClientRect();o(f,m)}},[t,o]);return I.createElement(I.Fragment,null,I.createElement(ub,{width:i.containerWidth,height:i.containerHeight}),I.createElement("div",uf({ref:c},e)))}),hMe=I.forwardRef((e,t)=>{var{width:n,height:r}=e;return I.createElement(I.Fragment,null,I.createElement(ub,{width:n,height:r}),I.createElement("div",uf({ref:t},e)))}),fMe=I.forwardRef((e,t)=>{var{width:n,height:r}=e;return typeof n=="string"||typeof r=="string"?I.createElement(dMe,uf({},e,{ref:t})):typeof n=="number"&&typeof r=="number"?I.createElement(hMe,uf({},e,{width:n,height:r,ref:t})):I.createElement(I.Fragment,null,I.createElement(ub,{width:n,height:r}),I.createElement("div",uf({ref:t},e)))});function pMe(e){return e?uMe:fMe}var mMe=I.forwardRef((e,t)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:c,onMouseDown:h,onMouseEnter:f,onMouseLeave:m,onMouseMove:y,onMouseUp:w,onTouchEnd:A,onTouchMove:S,onTouchStart:C,style:T,width:D,responsive:V,dispatchTouchEvents:L=!0}=e,K=I.useRef(null),Z=bs(),[q,B]=I.useState(null),[z,F]=I.useState(null),$=iMe(),Y=X4(),X=(Y==null?void 0:Y.width)>0?Y.width:D,J=(Y==null?void 0:Y.height)>0?Y.height:i,ye=I.useCallback(Ee=>{$(Ee),typeof t=="function"&&t(Ee),B(Ee),F(Ee),Ee!=null&&(K.current=Ee)},[$,t,B,F]),ne=I.useCallback(Ee=>{Z(yee(Ee)),Z(sc({handler:a,reactEvent:Ee}))},[Z,a]),de=I.useCallback(Ee=>{Z(mI(Ee)),Z(sc({handler:f,reactEvent:Ee}))},[Z,f]),be=I.useCallback(Ee=>{Z(HZ()),Z(sc({handler:m,reactEvent:Ee}))},[Z,m]),Ce=I.useCallback(Ee=>{Z(mI(Ee)),Z(sc({handler:y,reactEvent:Ee}))},[Z,y]),Ke=I.useCallback(()=>{Z(Aee())},[Z]),G=I.useCallback(()=>{Z(_ee())},[Z]),se=I.useCallback(Ee=>{Z(Eee(Ee.key))},[Z]),xe=I.useCallback(Ee=>{Z(sc({handler:o,reactEvent:Ee}))},[Z,o]),re=I.useCallback(Ee=>{Z(sc({handler:c,reactEvent:Ee}))},[Z,c]),Me=I.useCallback(Ee=>{Z(sc({handler:h,reactEvent:Ee}))},[Z,h]),nt=I.useCallback(Ee=>{Z(sc({handler:w,reactEvent:Ee}))},[Z,w]),ze=I.useCallback(Ee=>{Z(sc({handler:C,reactEvent:Ee}))},[Z,C]),Tt=I.useCallback(Ee=>{L&&Z(Cee(Ee)),Z(sc({handler:S,reactEvent:Ee}))},[Z,L,S]),It=I.useCallback(Ee=>{Z(sc({handler:A,reactEvent:Ee}))},[Z,A]),ft=pMe(V);return I.createElement(fJ.Provider,{value:q},I.createElement(uY.Provider,{value:z},I.createElement(ft,{width:X??(T==null?void 0:T.width),height:J??(T==null?void 0:T.height),className:Pi("recharts-wrapper",r),style:sMe({position:"relative",cursor:"default",width:X,height:J},T),onClick:ne,onContextMenu:xe,onDoubleClick:re,onFocus:Ke,onBlur:G,onKeyDown:se,onMouseDown:Me,onMouseEnter:de,onMouseLeave:be,onMouseMove:Ce,onMouseUp:nt,onTouchEnd:It,onTouchMove:Tt,onTouchStart:ze,ref:ye},I.createElement(cMe,null),n)))}),gMe=["width","height","responsive","children","className","style","compact","title","desc"];function xMe(e,t){if(e==null)return{};var n,r,i=yMe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var{width:n,height:r,responsive:i,children:a,className:o,style:c,compact:h,title:f,desc:m}=e,y=xMe(e,gMe),w=Fl(y);return h?I.createElement(I.Fragment,null,I.createElement(ub,{width:n,height:r}),I.createElement(TV,{otherAttributes:w,title:f,desc:m},a)):I.createElement(mMe,{className:o,style:c,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},I.createElement(TV,{otherAttributes:w,title:f,desc:m,ref:t},I.createElement(p6e,null,a)))});function gI(){return gI=Object.assign?Object.assign.bind():function(e){for(var t=1;tI.createElement(kMe,{chartName:"ComposedChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:SMe,tooltipPayloadSearcher:m3e,categoricalChartProps:e,ref:t}));const Pee=({className:e})=>s.jsx("div",{className:`flex flex-col items-center gap-1 ${e}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-6 h-6 border border-gray-950 overflow-hidden bg-white rounded-full",children:s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Logo",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("span",{className:"text-lg md:text-xl font-serif font-black tracking-tighter text-gray-950 uppercase leading-none italic",children:"CAMPUS EYE"}),s.jsx("span",{className:"text-[6px] font-black tracking-[0.5em] text-gray-400 uppercase leading-none mt-0.5",children:"MEDIA"})]})]})}),Oee=({stats:e,compact:t=!1})=>{const[n,r]=I.useState(null),i=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],a=(e.engagementScore||10)+e.articlesCount*5+e.postsCount*2,o=e.weeklyActivity||i.map((w,A)=>{const S=Math.floor(Math.abs(Math.sin(a+A*1.5)*40)+(A%2===0?12:5));return Math.max(2,S)}),c=Math.max(...o,1),h=Math.max(1,e.articlesCount*10+e.postsCount*3+e.purchasesCount*5),f=Math.min(100,Math.round(e.articlesCount*10/h*100)),m=Math.min(100,Math.round(e.postsCount*3/h*100)),y=Math.min(100,Math.max(0,100-f-m));return s.jsxs("div",{className:"bg-gradient-to-br from-gray-900 via-gray-950 to-black text-white p-5 sm:p-6 rounded-3xl border border-gray-800/80 shadow-2xl space-y-6 select-none font-sans",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-white/10 pb-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-gradient-to-tr from-accent to-purple-600 rounded-2xl shadow-lg shadow-accent/20 text-white",children:s.jsx(wp,{size:20})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-black uppercase tracking-widest text-gray-200 flex items-center gap-2",children:"Citizen Statistics & Engagement Graph"}),s.jsx("p",{className:"text-[10px] text-gray-400 font-semibold tracking-wider uppercase mt-0.5",children:"Live Activity Analytics Engine"})]})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs("span",{className:"px-3 py-1 bg-white/10 border border-white/15 text-amber-300 rounded-xl text-[9.5px] font-black uppercase tracking-widest flex items-center gap-1 shadow-sm",children:[s.jsx(Zi,{size:11,className:"text-amber-400"}),e.tier||"Active Citizen"]})})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[9.5px] font-black uppercase tracking-widest text-gray-400 flex items-center gap-1.5",children:[s.jsx(rg,{size:12,className:"text-accent"})," Weekly Contribution Volume (Mon - Sun)"]}),s.jsxs("span",{className:"text-[9px] font-mono font-bold text-gray-400",children:["Total Points: ",s.jsx("strong",{className:"text-white",children:e.engagementScore})]})]}),s.jsx("div",{className:"bg-white/5 border border-white/10 p-4 rounded-2xl relative",children:s.jsx("div",{className:"h-32 flex items-end justify-between gap-2 pt-6 pb-1 px-1",children:o.map((w,A)=>{const S=Math.max(12,Math.round(w/c*100)),C=n===A;return s.jsxs("div",{onMouseEnter:()=>r(A),onMouseLeave:()=>r(null),className:"flex-1 flex flex-col items-center h-full justify-end group cursor-pointer relative",children:[C&&s.jsxs("div",{className:"absolute -top-8 bg-accent text-white px-2 py-0.5 rounded-lg text-[9px] font-black font-mono shadow-xl z-20 whitespace-nowrap animate-fadeIn",children:[w," pts (",i[A],")"]}),s.jsx("div",{className:"w-full bg-white/10 rounded-t-lg h-full flex items-end overflow-hidden p-0.5",children:s.jsx("div",{style:{height:`${S}%`},className:`w-full rounded-t-md transition-all duration-500 ${C?"bg-gradient-to-t from-red-600 via-accent to-amber-400 shadow-lg shadow-accent/50":"bg-gradient-to-t from-accent/80 to-purple-500/80 group-hover:from-accent group-hover:to-purple-400"}`})}),s.jsx("span",{className:`text-[9px] font-extrabold uppercase mt-2 font-mono transition-colors ${C?"text-accent font-black":"text-gray-400"}`,children:i[A]})]},A)})})})]}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[s.jsxs("div",{className:"p-3 bg-white/5 border border-white/10 rounded-2xl flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between text-gray-400",children:[s.jsx("span",{className:"text-[8.5px] font-black uppercase tracking-widest",children:"Articles"}),s.jsx(D0,{size:13,className:"text-blue-400"})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("span",{className:"text-base font-black font-mono text-white",children:e.articlesCount}),s.jsx("span",{className:"text-[8px] text-gray-400 block font-semibold",children:"Dispatches"})]})]}),s.jsxs("div",{className:"p-3 bg-white/5 border border-white/10 rounded-2xl flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between text-gray-400",children:[s.jsx("span",{className:"text-[8.5px] font-black uppercase tracking-widest",children:"Lounge Posts"}),s.jsx(bi,{size:13,className:"text-purple-400"})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("span",{className:"text-base font-black font-mono text-white",children:e.postsCount}),s.jsx("span",{className:"text-[8px] text-gray-400 block font-semibold",children:"Feed Shares"})]})]}),s.jsxs("div",{className:"p-3 bg-white/5 border border-white/10 rounded-2xl flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between text-gray-400",children:[s.jsx("span",{className:"text-[8.5px] font-black uppercase tracking-widest",children:"Passes"}),s.jsx(Aa,{size:13,className:"text-emerald-400"})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("span",{className:"text-base font-black font-mono text-white",children:e.purchasesCount}),s.jsx("span",{className:"text-[8px] text-gray-400 block font-semibold",children:"Event Tickets"})]})]}),s.jsxs("div",{className:"p-3 bg-white/5 border border-white/10 rounded-2xl flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between text-gray-400",children:[s.jsx("span",{className:"text-[8.5px] font-black uppercase tracking-widest",children:"Score"}),s.jsx(Nu,{size:13,className:"text-amber-400"})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("span",{className:"text-base font-black font-mono text-amber-300",children:e.engagementScore}),s.jsx("span",{className:"text-[8px] text-gray-400 block font-semibold",children:"Influence Pts"})]})]})]}),!t&&s.jsxs("div",{className:"space-y-2 pt-1 border-t border-white/10",children:[s.jsxs("div",{className:"flex justify-between items-center text-[9px] font-black uppercase tracking-widest text-gray-400",children:[s.jsx("span",{children:"Contribution Mix Breakdown"}),s.jsxs("span",{className:"text-gray-300 font-mono",children:["UGX ",(e.totalSpent||0).toLocaleString()," Spent"]})]}),s.jsxs("div",{className:"w-full bg-white/10 h-3 rounded-full overflow-hidden flex p-0.5 gap-0.5",children:[s.jsx("div",{style:{width:`${f}%`},className:"bg-blue-500 h-full rounded-l-sm",title:`Articles: ${f}%`}),s.jsx("div",{style:{width:`${m}%`},className:"bg-purple-500 h-full",title:`Lounge Posts: ${m}%`}),s.jsx("div",{style:{width:`${y}%`},className:"bg-emerald-500 h-full rounded-r-sm",title:`Tickets: ${y}%`})]}),s.jsxs("div",{className:"flex items-center justify-between text-[8px] font-extrabold uppercase text-gray-400 pt-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500 inline-block"})," Articles (",f,"%)"]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-purple-500 inline-block"})," Lounge (",m,"%)"]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500 inline-block"})," Tickets (",y,"%)"]})]})]})]})};function DA(e){if(!e||typeof e!="string")return null;const t=e.trim(),n=/(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?|shorts)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,r=t.match(n);return r?r[1]:null}function vp(e){return!!DA(e)}function yw(e,t="hq"){const n=DA(e)||e;return!n||n.length!==11?"https://images.unsplash.com/photo-1590602847861-f357a9332bbc?auto=format&fit=crop&q=80&w=600":`https://img.youtube.com/vi/${n}/${t==="maxres"?"maxresdefault":"hqdefault"}.jpg`}function jMe(e,t=!0){const n=DA(e)||e;return n?`https://www.youtube-nocookie.com/embed/${n}?autoplay=${t?1:0}&rel=0&modestbranding=1&enablejsapi=1`:""}function Rl(e){if(!e)return!1;if(e.mediaType==="video")return!0;if(e.mediaType==="audio")return!1;const t=(e.videoUrl||e.mediaUrl||e.audioUrl||"").toLowerCase();return vp(t)?!0:[".mp4",".webm",".ogg",".mov",".m3u8",".mkv","vimeo.com","dailymotion.com","drive.google.com/file"].some(r=>t.includes(r))}function IMe(e){return e&&(e.videoUrl||e.mediaUrl||e.audioUrl)||""}const xP=({podcast:e,onClose:t,relatedPodcasts:n=[],onSelectPodcast:r})=>{var T;const[i,a]=I.useState(e||null),[o,c]=I.useState(!1),[h,f]=I.useState(!1);I.useEffect(()=>{e&&a(e)},[e]),I.useEffect(()=>{const D=V=>{const L=V;L.detail&&a(L.detail)};return window.addEventListener("play-video-podcast",D),()=>{window.removeEventListener("play-video-podcast",D)}},[]),I.useEffect(()=>{const D=V=>{V.key==="Escape"&&i&&m()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[i]);const m=()=>{a(null),t&&t()};if(!i)return null;const y=IMe(i),w=vp(y);DA(y);const A=w?jMe(y,!0):null,S=async()=>{const D=typeof window<"u"?`${window.location.origin}/?podcast=${i.id}`:"";if(`${i.title}${D}`,navigator.share)try{await navigator.share({title:i.title,text:`Watch this Campus Eye Video Episode: ${i.title}`,url:D||y}),pe.success("Shared video episode!",{icon:"🎬"});return}catch{}Md(D||y),c(!0),pe.success("Video episode link copied to clipboard!",{icon:"📋"}),setTimeout(()=>c(!1),2e3)},C=D=>{Rl(D)?(a(D),r&&r(D)):(window.dispatchEvent(new CustomEvent("play-podcast",{detail:D})),pe.success(`Playing audio episode: ${D.title}`,{icon:"🎧"}))};return s.jsx(or,{children:s.jsxs("div",{className:"fixed inset-0 z-[6000] flex items-center justify-center p-2 sm:p-4 md:p-6 overflow-y-auto bg-black/85 backdrop-blur-md",children:[s.jsx("div",{className:"fixed inset-0",onClick:m}),s.jsxs(Zt.div,{initial:{opacity:0,scale:.94,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.94,y:20},transition:{type:"spring",damping:25,stiffness:300},className:`relative z-10 w-full ${h?"max-w-6xl":"max-w-4xl"} bg-gray-950 text-white rounded-3xl border border-white/15 shadow-[0_25px_70px_rgba(0,0,0,0.9)] overflow-hidden transition-all duration-300 my-auto`,children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-white/10 bg-gray-900/60 backdrop-blur-xl",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5 px-3 py-1 bg-red-600/90 text-white rounded-xl text-[10px] font-black uppercase tracking-widest shadow-sm",children:[s.jsx(Ea,{size:12,className:"animate-pulse"})," Video Podcast"]}),s.jsx("span",{className:"text-[10px] font-mono font-bold text-gray-400 bg-white/5 px-2.5 py-1 rounded-xl border border-white/5",children:i.category||"Campus Broadcast"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>f(!h),className:"p-2 rounded-xl text-gray-400 hover:text-white hover:bg-white/10 transition-colors cursor-pointer",title:h?"Exit Theatre Mode":"Theatre Mode",children:h?s.jsx(bI,{size:16}):s.jsx(r2,{size:16})}),s.jsx("button",{onClick:S,className:"p-2 rounded-xl text-gray-400 hover:text-white hover:bg-white/10 transition-colors flex items-center gap-1.5 text-xs font-bold cursor-pointer",title:"Share Episode",children:o?s.jsx(Bu,{size:16,className:"text-emerald-400"}):s.jsx(hf,{size:16})}),s.jsx("button",{onClick:m,className:"p-2 rounded-xl bg-white/5 hover:bg-red-600 hover:text-white text-gray-400 transition-all cursor-pointer ml-1",title:"Close Video (Esc)",children:s.jsx(er,{size:18})})]})]}),s.jsx("div",{className:"relative w-full aspect-video bg-black flex items-center justify-center overflow-hidden",children:w&&A?s.jsx("iframe",{src:A,title:i.title,className:"w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0}):y?s.jsx("video",{src:y,controls:!0,autoPlay:!0,playsInline:!0,poster:i.thumbnail,className:"w-full h-full object-contain",children:"Your browser does not support the video tag."}):s.jsxs("div",{className:"text-center p-8 text-gray-400",children:[s.jsx(Ea,{size:40,className:"mx-auto mb-2 text-red-500 opacity-60"}),s.jsx("p",{className:"text-xs font-bold uppercase tracking-wider",children:"Video stream not available"})]})}),s.jsxs("div",{className:"p-5 md:p-6 bg-gradient-to-b from-gray-950 to-gray-900 text-left space-y-4",children:[s.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase text-red-500 tracking-wider flex items-center gap-1",children:[s.jsx(nE,{size:12})," Host: ",i.author||"Campus Eye Desk"]}),s.jsx("span",{className:"text-gray-600",children:"•"}),s.jsxs("span",{className:"text-[10px] font-mono text-gray-400",children:["⏱️ ",i.duration||"Full Episode"]}),i.publishDate&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-gray-600",children:"•"}),s.jsx("span",{className:"text-[10px] font-mono text-gray-400",children:(T=i.publishDate)!=null&&T.seconds?new Date(i.publishDate.seconds*1e3).toLocaleDateString():"Published Episode"})]})]}),s.jsx("h2",{className:"text-lg md:text-2xl font-black text-white uppercase tracking-tight font-serif leading-tight",children:i.title})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[y&&s.jsxs("a",{href:y,target:"_blank",rel:"noreferrer",className:"px-4 py-2 bg-white/10 hover:bg-white/20 text-white rounded-xl text-[10px] font-black uppercase tracking-wider transition-all flex items-center gap-1.5 cursor-pointer border border-white/10",children:[s.jsx($a,{size:12})," ",w?"Open on YouTube":"Open Video Link"]}),s.jsxs("button",{onClick:S,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-xl text-[10px] font-black uppercase tracking-wider transition-all flex items-center gap-1.5 cursor-pointer shadow-lg shadow-red-900/20",children:[s.jsx(hf,{size:12})," Share"]})]})]}),i.description&&s.jsxs("div",{className:"p-4 bg-white/5 rounded-2xl border border-white/5 text-xs text-gray-300 leading-relaxed",children:[s.jsx("p",{className:"font-bold text-[9px] uppercase tracking-wider text-gray-400 mb-1",children:"Episode Notes"}),s.jsx("p",{className:"whitespace-pre-wrap",children:i.description})]}),n.length>0&&s.jsxs("div",{className:"pt-2 border-t border-white/10",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h4",{className:"text-[10px] font-black uppercase tracking-widest text-gray-400 flex items-center gap-1.5",children:[s.jsx(Zi,{size:12,className:"text-red-500"})," More Campus Episodes"]}),s.jsxs("span",{className:"text-[9px] font-mono text-gray-500 font-bold",children:[n.length," Available"]})]}),s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:n.slice(0,4).map(D=>{const V=Rl(D),L=D.id===i.id;return s.jsxs("div",{onClick:()=>C(D),className:`group relative bg-white/5 hover:bg-white/10 p-2.5 rounded-2xl border transition-all cursor-pointer flex flex-col justify-between ${L?"border-red-600 bg-red-950/20 ring-1 ring-red-600":"border-white/5 hover:border-white/20"}`,children:[s.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-2 bg-black",children:[s.jsx("img",{src:D.thumbnail||"https://images.unsplash.com/photo-1590602847861-f357a9332bbc?auto=format&fit=crop&q=80&w=300",alt:D.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"}),s.jsxs("span",{className:`absolute top-1.5 left-1.5 text-[7px] font-black uppercase tracking-wider px-1.5 py-0.5 rounded flex items-center gap-0.5 shadow-sm text-white ${V?"bg-red-600":"bg-emerald-600"}`,children:[V?s.jsx(Ea,{size:8}):s.jsx(Zh,{size:8}),V?"VIDEO":"AUDIO"]})]}),s.jsx("h5",{className:"text-[10px] font-black uppercase text-white truncate group-hover:text-red-400 transition-colors",children:D.title}),s.jsx("p",{className:"text-[8px] text-gray-400 font-bold uppercase tracking-wider mt-0.5",children:D.author})]},D.id)})})]})]})]})]})})},PS=({initialTab:e})=>{var dd,Fb,fs,Km,Ym,xx,yx,$b,Xm,Qm;const[t,n]=ie.useState(!1),[r,i]=ie.useState(!0),[a,o]=ie.useState(e||"dashboard");ie.useEffect(()=>{e&&o(e)},[e]),ie.useEffect(()=>{const O=()=>{const le=localStorage.getItem("edit_ticket_item");if(le)try{const Ae=JSON.parse(le);zi(Ae),mt(Ae.title||""),Nn(Ae.description||""),Bt((Ae.price||0).toString()),xr(Ae.venue||""),fe((Ae.totalQuantity||100).toString()),xi(Ae.category||"Entertainment"),sa(Ae.imageUrl||""),fr(Ae.link||"");const pt=(()=>{const Ht=Ae.eventDate;if(!Ht)return"";const Jn=typeof Ht.toDate=="function"?Ht.toDate():Ht instanceof Date?Ht:Ht.seconds?new Date(Ht.seconds*1e3):new Date(Ht);try{return Jn.toISOString().slice(0,16)}catch{return""}})();jn(pt),o("manage-tickets"),localStorage.removeItem("edit_ticket_item")}catch(Ae){console.warn("Failed to restore editing ticket:",Ae)}};return O(),window.addEventListener("checkPendingTicketEdit",O),()=>window.removeEventListener("checkPendingTicketEdit",O)},[]);const[c,h]=ie.useState([]),[f,m]=ie.useState(()=>F2e()),[y,w]=ie.useState(()=>$2e()),[A,S]=ie.useState(()=>H2e()),[C,T]=ie.useState(""),[D,V]=ie.useState(""),[L,K]=ie.useState(""),[Z,q]=ie.useState([]),[B,z]=ie.useState([]),[F,$]=ie.useState([]),[Y,X]=ie.useState([]),[J,ye]=ie.useState(""),[ne,de]=ie.useState(""),[be,Ce]=ie.useState(""),[Ke,G]=ie.useState("link"),[se,xe]=ie.useState(""),[re,Me]=ie.useState(!1),[nt,ze]=ie.useState(null),[Tt,It]=ie.useState(!1),[ft,Ee]=ie.useState(null),[yt,Ue]=ie.useState(!1),[Vt,St]=ie.useState([]),[tn,Pt]=ie.useState([]),[Nt,Kt]=ie.useState([]),[ut,Jt]=ie.useState(""),[Dt,hn]=ie.useState({}),[qn,mn]=ie.useState({}),[vr,Ve]=ie.useState({}),[Mt,cn]=ie.useState(""),[dn,mr]=ie.useState(""),[gr,wi]=ie.useState(""),[Xt,me]=ie.useState(!1),[qe,st]=ie.useState(""),[dt,An]=ie.useState(!1),[Ft,Dn]=ie.useState([]),[Ot,on]=ie.useState(!0),[jr,lr]=ie.useState(""),[ue,Se]=ie.useState(null),[Qe,Gt]=ie.useState(!1),[Fn,xn]=ie.useState(""),[kn,xt]=ie.useState(!1),[$n,Et]=ie.useState(null),je=async O=>{const le=["https://campuseyemedia.com/","https://campuseyemedia.com/sitemap.xml","https://campuseyemedia.com/news-sitemap.xml","https://campuseyemedia.com/rss.xml","https://campuseyemedia.com/atom.xml"],Ae=O&&O.length>0?O:le,pt={host:"campuseyemedia.com",key:"e4b85c18e16d47b594fa6c4c5a932eb5",keyLocation:"https://campuseyemedia.com/e4b85c18e16d47b594fa6c4c5a932eb5.txt",urlList:Ae};try{fetch("https://api.indexnow.org/indexnow",{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(pt),mode:"no-cors"}).catch(()=>{}),fetch("https://www.bing.com/indexnow",{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(pt),mode:"no-cors"}).catch(()=>{})}catch{}const Ht=encodeURIComponent("https://campuseyemedia.com/sitemap.xml");try{fetch(`https://www.google.com/ping?sitemap=${Ht}`,{mode:"no-cors"}).catch(()=>{}),fetch(`https://www.bing.com/ping?sitemap=${Ht}`,{mode:"no-cors"}).catch(()=>{})}catch{}try{["https://pubsubhubbub.appspot.com/","https://pubsubhubbub.superfeedr.com/"].forEach(ar=>{fetch(ar,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({"hub.mode":"publish","hub.url":"https://campuseyemedia.com/rss.xml"}).toString(),mode:"no-cors"}).catch(()=>{})})}catch{}return Ae.length},ln=ie.useCallback(async()=>{try{const O=await fetch("/api/google-seo-stats"),le=O.headers.get("content-type")||"";if(O.ok&&le.includes("application/json")){const Ae=await O.json();Se(Ae)}else Se({success:!0,lastPush:new Date().toISOString(),canonicalHost:"campuseyemedia.com",recentPushes:[{urlCount:5,timestamp:new Date().toISOString(),urls:["https://campuseyemedia.com/sitemap.xml","https://campuseyemedia.com/news-sitemap.xml"]}]})}catch(O){console.warn("Failed to fetch SEO stats:",O)}},[]),bt=async()=>{Gt(!0),Et(null);try{let O=!1;try{const le=await fetch("/api/push-google-indexing",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({all:!0})}),Ae=le.headers.get("content-type")||"";if(le.ok&&Ae.includes("application/json")){const pt=await le.json();pt.success&&(O=!0,Et(`Successfully notified Google Search Console, Google News, and IndexNow for ${pt.urlsPushed||"all"} URLs!`),pe.success("Pushed to Google Search Console & IndexNow!"),ln())}}catch(le){console.warn("Backend SEO route unavailable, falling back to direct crawler push:",le)}if(!O){const le=await je();Et(`Dispatched live SEO indexing pings to Google Search Console, Google News, and IndexNow for ${le} canonical URLs!`),pe.success("Dispatched to Google Search Console & IndexNow!"),ln()}}catch(O){pe.error(O.message||"Failed to notify search engines")}finally{Gt(!1)}},yn=async O=>{if(O.preventDefault(),!!Fn.trim()){xt(!0);try{const le=Fn.trim();let Ae=!1;try{const pt=await fetch("/api/push-google-indexing",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({urls:[le]})}),Ht=pt.headers.get("content-type")||"";pt.ok&&Ht.includes("application/json")&&(await pt.json()).success&&(Ae=!0,pe.success("URL submitted to Google & IndexNow!"),xn(""),ln())}catch{}Ae||(await je([le]),pe.success("URL submitted to Google & IndexNow!"),xn(""),ln())}catch(le){pe.error(le.message||"Submission failed")}finally{xt(!1)}}};ie.useEffect(()=>{if(!t)return;const O=Qt(et(he,"notifications"),Ar("userId","==","all")),le=Wr(O,Ae=>{const pt=Ae.docs.map(Ht=>({id:Ht.id,...Ht.data()}));pt.sort((Ht,Jn)=>{var Kn,Br;const ar=Ht.timestamp||((Kn=Ht.createdAt)!=null&&Kn.toMillis?Ht.createdAt.toMillis():0);return(Jn.timestamp||((Br=Jn.createdAt)!=null&&Br.toMillis?Jn.createdAt.toMillis():0))-ar}),Dn(pt),on(!1)},Ae=>{console.warn("Failed to subscribe to broadcast notifications:",Ae),on(!1)});return()=>le()},[t]);const Ut=async O=>{if(window.confirm("Are you sure you want to delete this broadcast message? It will be removed from all users' inboxes."))try{await si(Je(he,"notifications",O)),pe.success("Broadcast message deleted successfully!",{icon:"🗑️"})}catch(le){pe.error("Failed to delete broadcast: "+le.message)}},On=async()=>{if(Ft.length&&window.confirm(`Are you sure you want to delete ALL ${Ft.length} broadcast messages from the database?`))try{await Promise.all(Ft.map(O=>si(Je(he,"notifications",O.id)))),pe.success("All broadcast messages cleared from database!",{icon:"🧹"})}catch(O){pe.error("Failed to clear broadcasts: "+O.message)}},Mr=async O=>{var Ae,pt,Ht;if(O.preventDefault(),!(((pt=(Ae=Ne.currentUser)==null?void 0:Ae.email)==null?void 0:pt.toLowerCase())==="atwiinevictor2@gmail.com")){pe.error("Access Denied: Only Top Master Admin (atwiinevictor2@gmail.com) can dispatch broadcast messages.");return}if(!Mt.trim()||!dn.trim()){pe.error("Please enter both a title and message for the broadcast!");return}An(!0);try{const Jn=`broadcast_${Date.now()}_${Math.random().toString(36).substring(2,7)}`;await Rr(Je(he,"notifications",Jn),{userId:"all",isBroadcast:!0,title:Mt.trim(),message:dn.trim(),imageUrl:gr.trim()||null,link:qe.trim()||null,senderName:((Ht=Ne.currentUser)==null?void 0:Ht.displayName)||"Campus Admin",used:!1,playSound:!0,createdAt:En(),type:"broadcast_announcement"}),pe.success("Broadcast message successfully dispatched to everyone's inbox!",{icon:"📢"}),cn(""),mr(""),wi(""),st("")}catch(Jn){pe.error("Failed to send broadcast: "+Jn.message)}finally{An(!1)}},ji=async O=>{if(!(qn[O]||vr[O])){Ve(le=>({...le,[O]:!0}));try{const[le,Ae,pt,Ht,Jn]=await Promise.all([vn(Qt(et(he,"articles"),Ar("authorId","==",O))),vn(Qt(et(he,"posts"),Ar("authorId","==",O))),vn(Qt(et(he,"purchases"),Ar("userId","==",O))),vn(Qt(et(he,"follows"),Ar("followedId","==",O))),vn(Qt(et(he,"follows"),Ar("followerId","==",O)))]),ar=le.size,Pr=Ae.size,Kn=pt.size,Br=Ht.size,Sn=Jn.size,un=pt.docs.reduce((Lo,Zm)=>Lo+(Zm.data().totalAmount||0),0),nr=ar*15+Pr*8+Kn*12+Br*3;let Yn="New Citizen",Fi="bg-gray-50 text-gray-500 border-gray-100";nr>=100?(Yn="Legendary Champion",Fi="bg-amber-50 text-amber-700 border-amber-200"):nr>=50?(Yn="Super Citizen",Fi="bg-indigo-50 text-accent border-indigo-200"):nr>=15&&(Yn="Active Contributor",Fi="bg-emerald-50 text-emerald-700 border-emerald-200");const Mi=le.docs.slice(0,3).map(Lo=>({id:Lo.id,title:Lo.data().title})),_l=Ae.docs.slice(0,3).map(Lo=>({id:Lo.id,content:Lo.data().content}));mn(Lo=>({...Lo,[O]:{articlesCount:ar,postsCount:Pr,purchasesCount:Kn,followersCount:Br,followingCount:Sn,totalSpent:un,engagementScore:nr,tier:Yn,tierColor:Fi,recentArticles:Mi,recentPosts:_l}}))}catch(le){console.error("Error fetching individual user analytics:",le)}finally{Ve(le=>({...le,[O]:!1}))}}},[rs,pi]=ie.useState(""),[mi,vs]=ie.useState(null),[gi,$r]=ie.useState(""),[Sr,Ss]=ie.useState("all"),[li,Qr]=ie.useState({totalViews:0,totalLikes:0,totalComments:0,totalArticles:0,totalPosts:0,totalUsers:0,activeAds:0,pendingAds:0,flaggedCount:0,totalTicketsSold:0,totalRevenue:0,viewsByDay:[]}),[kt,Pa]=ie.useState(sY()),[wr,is]=ie.useState(["857eaaf2b7571ee437db8ee3f6ee8670"]),[uo,hr]=ie.useState(""),[Nr,cr]=ie.useState([]),[Re,mt]=ie.useState(""),[rt,At]=ie.useState([]),[nn,Nn]=ie.useState(""),[Be,Bt]=ie.useState(""),[Mn,jn]=ie.useState(""),[Ln,xr]=ie.useState(""),[Le,fe]=ie.useState(""),[fn,xi]=ie.useState("Entertainment"),[Ui,Bi]=ie.useState(null),[Lr,zi]=ie.useState(null),[an,fr]=ie.useState(""),[Oa,ra]=ie.useState(["General","Campus News","Sports","Entertainment","Politics"]),[ia,Cs]=ie.useState(""),[Qo,fa]=ie.useState(!1),[ci,js]=ie.useState(""),[Is,Gn]=ie.useState(""),[ss,Un]=ie.useState(""),[Xr,To]=ie.useState(null),[Zr,ho]=ie.useState(0),[Qs,Po]=ie.useState("General"),[pa,ma]=ie.useState([]),[Bs,Zs]=ie.useState(""),[Ni,zs]=ie.useState(""),[yi,Xa]=ie.useState("Discover More"),[Nl,fo]=ie.useState(""),[Zo,ga]=ie.useState(!1),[po,Fr]=ie.useState(""),[Ra,Oo]=ie.useState(""),[Qa,Ro]=ie.useState(null),[at,pr]=ie.useState(""),[Jr,ge]=ie.useState("image"),[we,Pe]=ie.useState("7"),[$e,ct]=ie.useState(""),[ot,_t]=ie.useState(["",""]),[pn,Lt]=ie.useState("active"),[bn,rn]=ie.useState(!1),[He,_]=ie.useState([]),[U,H]=ie.useState(""),[oe,De]=ie.useState(""),[Ye,Te]=ie.useState(""),[Ct,Zn]=ie.useState(!1),[wn,tr]=ie.useState(""),[Ur,Oi]=ie.useState(!1);ie.useEffect(()=>{if(!t||a!=="polls")return;const O=Qt(et(he,"debates"),ui("createdAt","desc"));vn(O).then(le=>{_(le.docs.map(Ae=>({id:Ae.id,...Ae.data()})))}).catch(le=>{console.error("Failed to load debates in Admin Dashboard:",le)})},[t,a]);const Vi=async O=>{if(O.preventDefault(),!U.trim()){pe.error("Please enter a debate title.");return}if(Ct&&!wn.trim()){pe.error("Please enter an external link for discussion.");return}Oi(!0);try{const le=Ye.trim()||"https://images.unsplash.com/photo-1541872703-74c5e44368f9?auto=format&fit=crop&q=80&w=800";await ur(et(he,"debates"),{title:U.trim(),description:oe.trim(),bannerUrl:le,isExternal:Ct,externalUrl:Ct?wn.trim():"",createdAt:En(),commentsCount:0}),pe.success("Debate published successfully!"),H(""),De(""),Te(""),Zn(!1),tr("")}catch(le){pe.error("Failed to publish debate: "+le.message)}finally{Oi(!1)}},Ri=async O=>{if(!t){pe.error("Access Denied: Only administrators can delete debates.");return}if(window.confirm("Are you sure you want to delete this debate?"))try{await si(Je(he,"debates",O)),pe.success("Debate deleted successfully!")}catch(le){pe.error("Failed to delete debate: "+le.message)}},[ws,Da]=ie.useState(""),[Ei,Ts]=ie.useState(""),[ni,Ps]=ie.useState("audio"),[wc,Ma]=ie.useState(""),[El,Jo]=ie.useState(""),[Cm,Nc]=ie.useState("5:40"),[mo,ah]=ie.useState("Campus Vibe"),[go,La]=ie.useState(""),[Hr,Ec]=ie.useState(""),[ee,u]=ie.useState(!1),[p,g]=ie.useState([]),[b,v]=ie.useState(null),[E,k]=ie.useState(null),[P,M]=ie.useState([]),[W,te]=ie.useState([]),[ae,ve]=ie.useState([]),[ke,Ie]=ie.useState(""),[We,ht]=ie.useState(""),[Yt,Wt]=ie.useState(""),[zt,Dr]=ie.useState(!1),[yr,Ns]=ie.useState({}),[Ua,Js]=ie.useState(null),[hi,Os]=ie.useState(""),[xa,ql]=ie.useState(""),[Wl,oh]=ie.useState(""),[Df,el]=ie.useState(!1);ie.useEffect(()=>{if(!t||a!=="mega-ai-knowledge")return;const O=Qt(et(he,"mega_ai_knowledge")),le=Wr(O,ar=>{const Pr=ar.docs.map(Kn=>({id:Kn.id,...Kn.data()}));Pr.sort((Kn,Br)=>{var nr,Yn,Fi,Mi;const Sn=((nr=Kn.createdAt)==null?void 0:nr.seconds)||((Yn=Kn.updatedAt)==null?void 0:Yn.seconds)||0;return(((Fi=Br.createdAt)==null?void 0:Fi.seconds)||((Mi=Br.updatedAt)==null?void 0:Mi.seconds)||0)-Sn}),M(Pr)},ar=>console.error("Error subscribing to mega_ai_knowledge:",ar)),Ae=Qt(et(he,"notifications"),Ar("type","==","mega_ai_query")),pt=Wr(Ae,ar=>{const Pr=ar.docs.map(Kn=>({id:Kn.id,...Kn.data()}));Pr.sort((Kn,Br)=>{var Sn,un;return(((Sn=Br.createdAt)==null?void 0:Sn.seconds)||0)-(((un=Kn.createdAt)==null?void 0:un.seconds)||0)}),te(Pr)},ar=>console.error("Error subscribing to mega_ai_query tickets:",ar)),Ht=Qt(et(he,"notifications"),Ar("type","==","unlimited_posting_request")),Jn=Wr(Ht,ar=>{const Pr=ar.docs.map(Kn=>({id:Kn.id,...Kn.data()}));Pr.sort((Kn,Br)=>{var Sn,un;return(((Sn=Br.createdAt)==null?void 0:Sn.seconds)||0)-(((un=Kn.createdAt)==null?void 0:un.seconds)||0)}),ve(Pr)},ar=>console.error("Error subscribing to unlimited posting requests:",ar));return()=>{le(),pt(),Jn()}},[t,a]);const jm=async O=>{const le=O.requestAuthorId||O.userId;if(!le){pe.error("User ID not found on request.");return}try{await Rr(Je(he,"users",le),{isPremiumPostUser:!0},{merge:!0}),await ur(et(he,"notifications"),{userId:le,type:"unlimited_posting_approved",title:"🎉 Unlimited Posting Approved!",message:"An administrator has approved your account for unlimited dispatches and postings on Campus Eye!",used:!1,playSound:!0,createdAt:En()}),O.id&&await si(Je(he,"notifications",O.id)),ve(Ae=>Ae.filter(pt=>pt.id!==O.id)),pe.success(`Approved @${O.requestAuthorName||"Student"} for unlimited posting! Notification removed.`,{icon:"🎉"})}catch(Ae){pe.error("Failed to approve user: "+Ae.message)}},tl=async O=>{try{await si(Je(he,"notifications",O)),ve(le=>le.filter(Ae=>Ae.id!==O)),pe.success("Request dismissed and permanently deleted.",{icon:"🗑️"})}catch(le){pe.error("Failed to dismiss request: "+le.message)}},lh=async()=>{if(ae.length!==0&&window.confirm("Permanently clear and delete ALL unlimited posting approval requests?"))try{await Promise.all(ae.map(O=>si(Je(he,"notifications",O.id)))),ve([]),pe.success("All posting approval requests permanently cleared!",{icon:"✨"})}catch(O){pe.error("Error clearing requests: "+O.message)}},ix=async O=>{try{await si(Je(he,"notifications",O)),te(le=>le.filter(Ae=>Ae.id!==O)),pe.success("Query ticket deleted permanently.",{icon:"🗑️"})}catch(le){pe.error("Failed to delete ticket: "+le.message)}},Im=async O=>{if(O.preventDefault(),!ke.trim()||!We.trim()){pe.error("Please fill in both the Question and Answer fields.");return}Dr(!0);try{const le=Yt.split(",").map(pt=>pt.trim()).filter(Boolean),Ae=await ur(et(he,"mega_ai_knowledge"),{question:ke.trim(),answer:We.trim(),keywords:le,createdAt:En()});M(pt=>[{id:Ae.id,question:ke.trim(),answer:We.trim(),keywords:le},...pt]),Ie(""),ht(""),Wt(""),pe.success("Added smart reply to Mega AI Knowledge Base!")}catch(le){pe.error("Failed to add AI knowledge: "+le.message)}finally{Dr(!1)}},Tm=async O=>{if(window.confirm("Remove this entry from Mega AI knowledge base?"))try{await si(Je(he,"mega_ai_knowledge",O)),M(le=>le.filter(Ae=>Ae.id!==O)),pe.success("Removed entry from Mega AI Knowledge Base.")}catch(le){pe.error("Error deleting knowledge item: "+le.message)}},sx=O=>{Js(O),Os(O.question||""),ql(O.answer||""),oh(Array.isArray(O.keywords)?O.keywords.join(", "):O.keywords||"")},Jc=()=>{Js(null),Os(""),ql(""),oh("")},Sb=async O=>{if(O.preventDefault(),!Ua||!hi.trim()||!xa.trim()){pe.error("Please fill in both the Question and Answer fields.");return}el(!0);try{const le=Wl.split(",").map(Ae=>Ae.trim()).filter(Boolean);await Cn(Je(he,"mega_ai_knowledge",Ua.id),{question:hi.trim(),answer:xa.trim(),keywords:le,updatedAt:En()}),Js(null),pe.success("AI Knowledge Base entry updated successfully!",{icon:"✨"})}catch(le){pe.error("Failed to update AI knowledge: "+le.message)}finally{el(!1)}},Pm=async O=>{const le=yr[O.id]||O.generatedReply||"";if(!le.trim()){pe.error("Please enter a reply before submitting.");return}try{O.postId?(await ur(et(he,"posts",O.postId,"comments"),{postId:O.postId,content:le.trim(),authorId:"mega-ai-bot",authorName:"Mega AI",authorPhotoURL:zo,createdAt:En(),likeCount:0,likedBy:[],isAIGenerated:!0}),await Cn(Je(he,"posts",O.postId),{commentCount:Ir(1)})):O.articleId&&(await ur(et(he,"articles",O.articleId,"comments"),{content:le.trim(),userId:"mega-ai-bot",authorName:"Mega AI",photoURL:zo,createdAt:En(),articleId:O.articleId,likeCount:0,isAIGenerated:!0}),await Cn(Je(he,"articles",O.articleId),{commentCount:Ir(1)}));const Ae=(O.userQuery||"").toLowerCase().split(" ").filter(pt=>pt.length>3);if(await ur(et(he,"mega_ai_knowledge"),{question:O.userQuery||"",answer:le.trim(),keywords:Ae,createdAt:En()}),O.userUid&&O.userUid!=="guest")try{await ur(et(he,"notifications"),{userId:O.userUid,type:"admin_mega_reply",title:"🤖 Admin / Mega AI Replied to your Query!",message:`Response: "${le.trim().slice(0,120)}${le.trim().length>120?"...":""}"`,fullAnswer:le.trim(),userQuery:O.userQuery||"",targetType:O.targetType||"post",postId:O.postId||null,articleId:O.articleId||null,commentId:O.commentId||null,used:!1,playSound:!0,createdAt:En()})}catch(pt){console.warn("Could not dispatch user inbox notification:",pt)}O.id&&(await Cn(Je(he,"notifications",O.id),{used:!0}),te(pt=>pt.map(Ht=>Ht.id===O.id?{...Ht,used:!0}:Ht))),pe.success("Replied to user as Mega AI & saved response into Knowledge Base! ✨")}catch(Ae){pe.error("Error replying to Mega AI query: "+Ae.message)}},eu=O=>{var Ae;return O.username?O.username:(O.displayName||((Ae=O.email)==null?void 0:Ae.split("@")[0])||"peer").toLowerCase().replace(/[^a-z0-9]/g,"")},Cb=ie.useMemo(()=>Xr===null?[]:Z.filter(O=>{const le=(O.username||eu(O)).toLowerCase(),Ae=(O.displayName||"").toLowerCase(),pt=Xr.toLowerCase();return le.includes(pt)||Ae.includes(pt)}).slice(0,5),[Xr,Z]),Do=O=>{const le=O.target.value;Un(le);const Ae=O.target.selectionStart,Ht=le.substring(0,Ae).split(/[\s]/),Jn=Ht[Ht.length-1];Jn.startsWith("@")?(To(Jn.substring(1)),ho(Ae)):To(null)};ie.useEffect(()=>{if(!t||a!=="manage-podcasts")return;const O=Qt(et(he,"podcasts"),ui("publishDate","desc"));vn(O).then(le=>{g(le.docs.map(Ae=>({id:Ae.id,...Ae.data()})))}).catch(le=>{console.error("Failed to load podcasts in Admin Dashboard:",le)})},[t,a]);const Om=()=>{Da(""),Ts(""),Ps("audio"),Ma(""),Jo(""),Nc("5:40"),ah("Campus Vibe"),La(""),Ec(""),v(null)},Ac=async O=>{O.preventDefault();const le=(ni==="video"?El:wc).trim();if(!ws.trim()||!Ei.trim()||!le){pe.error(`Please fill out podcast title, host name, and ${ni==="video"?"video":"audio"} link.`);return}u(!0);try{let Ae=go.trim();Ae||(ni==="video"&&vp(le)?Ae=yw(le,"hq"):ni==="video"?Ae="https://images.unsplash.com/photo-1578022761797-b8636ac1773c?auto=format&fit=crop&q=80&w=500":Ae="https://images.unsplash.com/photo-1590602847861-f357a9332bbc?auto=format&fit=crop&q=80&w=500");const pt={title:ws.trim(),author:Ei.trim(),mediaType:ni,audioUrl:ni==="audio"?le:"",videoUrl:ni==="video"?le:"",mediaUrl:le,duration:Cm.trim()||(ni==="video"?"Video":"5:40"),category:mo,thumbnail:Ae,description:Hr.trim(),publishDate:En()};if(b)await Cn(Je(he,"podcasts",b),pt),pe.success(`${ni==="video"?"🎬 Video":"📻 Audio"} podcast updated successfully!`,{icon:ni==="video"?"🎬":"📻"});else{const Ht=await ur(et(he,"podcasts"),pt);pe.success(`New ${ni==="video"?"🎬 Video":"📻 Audio"} episode published successfully!`,{icon:ni==="video"?"🎬":"📻"});try{const Jn=(ws||"podcast").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:`${window.location.origin}/podcast/${Jn}/${Ht.id}`,title:ws,image:go||""})}).catch(()=>{})}catch{}}Om()}catch(Ae){console.error(Ae),pe.error("Failed to save podcast: "+Ae.message)}finally{u(!1)}},jb=O=>{const le=Rl(O);Da(O.title||""),Ts(O.author||""),Ps(le?"video":"audio"),Ma(O.audioUrl||(le?"":O.mediaUrl)||""),Jo(O.videoUrl||(le?O.mediaUrl:"")||""),Nc(O.duration||(le?"Video":"5:40")),ah(O.category||"Campus Vibe"),La(O.thumbnail||""),Ec(O.description||""),v(O.id),window.scrollTo({top:0,behavior:"smooth"})},Rm=async O=>{if(!t){pe.error("Access Denied: Only administrators can delete podcasts.");return}if(window.confirm("Are you sure you want to permanently delete this podcast episode?"))try{await si(Je(he,"podcasts",O)),pe.success("Podcast episode deleted permanently.")}catch(le){pe.error("Failed to delete podcast: "+le.message)}},ed=O=>{Rl(O)?(k(O),window.dispatchEvent(new CustomEvent("play-video-podcast",{detail:O})),pe.success(`Previewing Video: ${O.title}`,{icon:"🎬"})):(window.dispatchEvent(new CustomEvent("play-podcast",{detail:O})),pe.success(`Broadcasting Audio: ${O.title}`,{icon:"📻"}))},Mf=["atwiinevictor2@gmail.com","campuseye@gmail.com"];ie.useEffect(()=>{const O=Ne.currentUser;localStorage.getItem("is_admin_cached")==="true"?(n(!0),i(!1)):O&&Mf.includes(O.email||"")&&(n(!0),localStorage.setItem("is_admin_cached","true"),i(!1));const Ae=setTimeout(()=>{i(!1)},1200);let pt=null,Ht=null;const Jn=Ne.onAuthStateChanged(async ar=>{if(pt&&(pt(),pt=null),Ht&&(Ht(),Ht=null),ar){if(Mf.includes(ar.email||"")){n(!0),localStorage.setItem("is_admin_cached","true"),i(!1),clearTimeout(Ae);return}let Pr=!1,Kn=!1;const Br=()=>{const Sn=Pr||Kn||Mf.includes(ar.email||"");n(Sn),localStorage.setItem("is_admin_cached",Sn?"true":"false"),i(!1),clearTimeout(Ae)};pt=Wr(Je(he,"users",ar.uid),Sn=>{if(Sn.exists()){const un=Sn.data();Pr=un.isAdmin===!0||un.role==="admin"}Br()},Sn=>{console.warn("User doc admin snapshot error:",Sn),Br()}),Ht=Wr(Je(he,"admins",ar.uid),Sn=>{Sn.exists()&&(Kn=Sn.data().isAdmin===!0),Br()},Sn=>{console.warn("Admin doc snapshot error:",Sn),Br()})}else n(!1),localStorage.removeItem("is_admin_cached"),i(!1),clearTimeout(Ae)});return()=>{Jn(),pt&&pt(),Ht&&Ht(),clearTimeout(Ae)}},[]),ie.useEffect(()=>{if(!t)return;const O=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],le=[1850,2460,2100,3120,2890,4150,4800],Ae=[1250,1680,1520,1890,1720,2150,2420],pt=[15,24,18,32,28,45,54],Ht=[12,18,15,25,22,38,48],Jn=O.map((Kn,Br)=>({name:Kn,visitors:le[Br],indigo:Ae[Br],engagement:Ae[Br],posts:pt[Br],tickets:Ht[Br]})),ar=async()=>{try{const[Kn,Br,Sn,un,nr]=await Promise.all([Yx(et(he,"articles")).catch(()=>null),Yx(et(he,"posts")).catch(()=>null),Yx(et(he,"users")).catch(()=>null),Yx(et(he,"adverts")).catch(()=>null),Yx(et(he,"purchases")).catch(()=>null)]);Qr(Yn=>({...Yn,totalArticles:(Kn==null?void 0:Kn.data().count)??Yn.totalArticles??0,totalPosts:(Br==null?void 0:Br.data().count)??Yn.totalPosts??0,totalUsers:(Sn==null?void 0:Sn.data().count)??Yn.totalUsers??0,activeAds:(un==null?void 0:un.data().count)??Yn.activeAds??0,totalTicketsSold:(nr==null?void 0:nr.data().count)??Yn.totalTicketsSold??0,viewsByDay:Jn}))}catch(Kn){console.warn("Silent ignore stats count error:",Kn)}};ar();const Pr=setInterval(ar,3e4);return()=>{clearInterval(Pr)}},[t]),ie.useEffect(()=>{const O=a==="dashboard"||a==="article"||a==="manage-articles",le=a==="dashboard"||a==="manage-ads"||a==="advert",Ae=a==="dashboard"||a==="manage-articles"||a==="article",pt=a==="users",Ht=a==="flagged-comments",Jn=a==="manage-tickets"||a==="ticket-purchases",ar=a==="dashboard"||a==="ticket-purchases",Pr=a==="manage-posts",Kn=a==="custom-links",Br=a==="feedback-inbox";if(O){const Sn=Qt(et(he,"categories"),ui("name","asc"));vn(Sn).then(un=>{const nr=un.docs.map(Yn=>Yn.data().name);if(nr.length>0){const Yn=Array.from(new Set(["General","Campus News","Sports","Entertainment","Politics",...nr]));ra(Yn)}}).catch(un=>{Ks(un,Ms.LIST,"categories")})}if(Ne.currentUser&&le){const Sn=Qt(et(he,"adverts"),ui("createdAt","desc"),vi(30));vn(Sn).then(un=>{const nr=un.docs.map(Mi=>({id:Mi.id,...Mi.data()}));St(nr);const Yn=nr.filter(Mi=>Mi.status==="active").length,Fi=nr.filter(Mi=>Mi.status==="hidden").length;Qr(Mi=>({...Mi,activeAds:Yn,pendingAds:Fi}))}).catch(un=>{Ks(un,Ms.LIST,"adverts")})}if(Ne.currentUser&&Ae){const Sn=a==="dashboard"?30:60,un=Qt(et(he,"articles"),ui("publishDate","desc"),vi(Sn));vn(un).then(nr=>{const Yn=nr.docs.map(Za=>({id:Za.id,...Za.data()}));h(Yn);const Fi=Yn.reduce((Za,xo)=>Za+(xo.viewCount||xo.views||0),0),Mi=Yn.reduce((Za,xo)=>Za+(xo.likeCount||xo.likes||0),0),_l=Yn.reduce((Za,xo)=>Za+(xo.commentCount||0),0),Lo=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Zm=[1850,2460,2100,3120,2890,4150,4800],Hb=[1250,1680,1520,1890,1720,2150,2420],Gb=[15,24,18,32,28,45,54],qb=[12,18,15,25,22,38,48],Wb=Lo.map((Za,xo)=>({name:Za,visitors:Zm[xo],indigo:Hb[xo],engagement:Hb[xo],posts:Gb[xo],tickets:qb[xo]}));Qr(Za=>({...Za,totalViews:Fi,totalLikes:Mi,totalArticles:Za.totalArticles||Yn.length,totalComments:_l,viewsByDay:Wb}))},nr=>{Ks(nr,Ms.LIST,"articles")})}if(Ne.currentUser&&t&&a==="dashboard"&&(vn(et(he,"posts")).then(Sn=>{const un=Sn.docs.map(Fi=>({id:Fi.id,...Fi.data()})),nr=un.filter(Fi=>Fi.flagged===!0||Fi.isFlagged===!0),Yn=un.reduce((Fi,Mi)=>{var _l;return Fi+(Mi.commentsCount||((_l=Mi.comments)==null?void 0:_l.length)||0)},0);Qr(Fi=>({...Fi,totalPosts:Sn.docs.length,totalComments:Fi.totalComments+Yn,flaggedCount:Fi.flaggedCount+nr.length}))}).catch(Sn=>console.error("Error fetching posts stats:",Sn)),vn(et(he,"users")).then(Sn=>{Qr(un=>({...un,totalUsers:Sn.docs.length}))}).catch(Sn=>console.error("Error fetching users stats:",Sn))),Ne.currentUser&&t&&pt&&vn(Qt(et(he,"users"),vi(50))).then(Sn=>{q(Sn.docs.map(un=>({id:un.id,...un.data()})))}).catch(Sn=>{console.error("Error loading users:",Sn),Ks(Sn,Ms.LIST,"users")}),Ne.currentUser&&t&&(Ht||a==="dashboard")){const Sn=Qt(yhe(he,"comments"),vi(50));vn(Sn).then(un=>{const nr=un.docs.map(Yn=>({id:Yn.id,...Yn.data()})).filter(Yn=>Yn.flagged===!0);z(nr),Qr(Yn=>({...Yn,flaggedCount:nr.length}))}).catch(un=>{Ks(un,Ms.LIST,"comments-group")}),vn(Qt(et(he,"posts"),vi(100))).then(un=>{const nr=un.docs.map(Yn=>({id:Yn.id,...Yn.data()})).filter(Yn=>Yn.flagged===!0||Yn.isFlagged===!0);cr(nr)}).catch(un=>console.error("Error fetching flagged posts:",un))}if(Ne.currentUser&&a==="imgbb-settings"&&cs(Je(he,"settings","imgbb")).then(Sn=>{if(Sn.exists()){const un=Sn.data();un.activeKey&&(Pa(un.activeKey),localStorage.setItem("campus_eye_imgbb_active_key",un.activeKey)),Array.isArray(un.savedKeys)&&un.savedKeys.length>0&&is(un.savedKeys)}}).catch(Sn=>console.error("Error loading imgbb settings:",Sn)),Ne.currentUser&&Jn){const Sn=Qt(et(he,"tickets"),ui("createdAt","desc"),vi(30));vn(Sn).then(un=>{Pt(un.docs.map(nr=>({id:nr.id,...nr.data()})))}).catch(un=>{Ks(un,Ms.LIST,"tickets")})}if(Ne.currentUser&&t&&ar){const Sn=Qt(et(he,"purchases"),ui("purchaseDate","desc"),vi(45));vn(Sn).then(un=>{const nr=un.docs.map(Mi=>({id:Mi.id,...Mi.data()}));Kt(nr);const Yn=nr.reduce((Mi,_l)=>Mi+(_l.quantity||0),0),Fi=nr.reduce((Mi,_l)=>Mi+(_l.totalAmount||0),0);Qr(Mi=>({...Mi,totalTicketsSold:Yn,totalRevenue:Fi}))}).catch(un=>{Ks(un,Ms.LIST,"purchases")})}if(Ne.currentUser&&Pr){const Sn=Qt(et(he,"posts"),ui("createdAt","desc"),vi(40));vn(Sn).then(un=>{const nr=un.docs.map(Yn=>({id:Yn.id,...Yn.data()}));$(nr)}).catch(un=>{console.warn("Silent ignore admin lounge posts list issue:",un)})}if(Ne.currentUser&&t&&Kn){const Sn=Qt(et(he,"custom_pages"),ui("createdAt","desc"),vi(20));vn(Sn).then(un=>{const nr=un.docs.map(Yn=>({id:Yn.id,...Yn.data()}));X(nr)}).catch(un=>{console.error("Silent ignore admin custom pages list issue:",un)})}if(Ne.currentUser&&t&&Br){const Sn=Qt(et(he,"feedback"),ui("createdAt","desc"),vi(30));vn(Sn).then(un=>{const nr=un.docs.map(Yn=>({id:Yn.id,...Yn.data()}));At(nr)}).catch(un=>{console.error("Silent ignore admin feedbacks list issue:",un)})}return()=>{}},[t,a]);const Ib=async O=>{if(O.preventDefault(),!(!Ne.currentUser||!t)){if(!J.trim()||!ne.trim()){pe.error("Please fill in all details for the page!");return}It(!0);try{nt?(await Cn(Je(he,"custom_pages",nt.id),{name:J.trim(),url:ne.trim(),svgIcon:be.trim(),type:Ke,description:se.trim(),isPinnedStyle:re}),pe.success("Page updated successfully in everyone's menu!"),ze(null)):(await ur(et(he,"custom_pages"),{name:J.trim(),url:ne.trim(),svgIcon:be.trim(),type:Ke,description:se.trim(),isPinnedStyle:re,createdAt:En()}),pe.success("New page loaded to everyone's menu!")),ye(""),de(""),Ce(""),G("link"),xe(""),Me(!1)}catch(le){pe.error("Database operation failed: "+le.message)}finally{It(!1)}}},ax=O=>{ze(O),ye(O.name),de(O.url),Ce(O.svgIcon||""),G(O.type||"link"),xe(O.description||""),Me(!!O.isPinnedStyle)},Tb=async O=>{if(!t){pe.error("Access Denied: Only administrators can delete custom pages.");return}if(window.confirm("Are you sure you want to permanently delete this custom page from everyone's menu?"))try{await si(Je(he,"custom_pages",O)),pe.success("Custom page removed successfully."),(nt==null?void 0:nt.id)===O&&(ze(null),ye(""),de(""),Ce(""),G("link"),xe(""),Me(!1))}catch(le){pe.error("Failed to delete page: "+le.message)}},nl=async O=>{if(O.preventDefault(),!(!Ne.currentUser||!t)){It(!0),Ee(null),Ue(!1);try{const le=al||(Lr==null?void 0:Lr.imageUrl)||"https://picsum.photos/seed/ticket/300/200",Ae=Re.trim()||"Untitled Campus Event",pt=parseFloat(Be)||0,Ht=parseInt(Le)||100,Jn={title:Ae,description:nn||"Join us for this amazing university experience.",price:pt,eventDate:Mn?_r.fromDate(new Date(Mn)):En(),venue:Ln||"Campus Hall",imageUrl:le,totalQuantity:Ht,remainingQuantity:Lr?Lr.remainingQuantity+(Ht-Lr.totalQuantity):Ht,category:fn||"Entertainment",status:"available",createdAt:Lr?Lr.createdAt:En(),authorId:Ne.currentUser.uid,link:an||""};Lr?(await Cn(Je(he,"tickets",Lr.id),Jn),pe.success("Ticket updated successfully!")):(await ur(et(he,"tickets"),Jn),pe.success("Ticket created successfully!")),Ue(!0),mt(""),Nn(""),Bt(""),jn(""),xr(""),fe(""),Bi(null),sa(""),zi(null),fr("")}catch(le){Ee(le.message||"Failed to save ticket"),pe.error("Failed to save ticket")}finally{It(!1)}}},ch=async O=>{if(!(!t||!window.confirm("Are you sure you want to delete this ticket?")))try{await si(Je(he,"tickets",O)),pe.success("Ticket deleted")}catch(le){console.error("Error deleting ticket:",le),pe.error("Failed to delete ticket")}},uh=async(O,le)=>{if(!(!t||!window.confirm("Are you sure you want to delete this comment?")))try{await si(Je(he,"articles",O,"comments",le)),pe.success("Comment deleted")}catch(Ae){console.error("Error deleting comment:",Ae),Ee("Failed to delete comment. Make sure it has an articleId.")}},Dm=async(O,le)=>{if(t)try{await Cn(Je(he,"articles",O,"comments",le),{flagged:!1})}catch(Ae){console.error("Error unflagging comment:",Ae),Ee("Failed to unflag comment. Make sure it has an articleId.")}},Lf=async O=>{if(t)try{await Cn(Je(he,"posts",O),{flagged:!1}),pe.success("Post flag dismissed!")}catch(le){console.error("Error unflagging post:",le),pe.error("Failed to unflag post.")}},rl=async O=>{if(!(!t||!window.confirm("Are you sure you want to delete this post?")))try{await si(Je(he,"posts",O)),pe.success("Post deleted successfully!")}catch(le){console.error("Error deleting post:",le),pe.error("Failed to delete post.")}},il=async(O,le)=>{var ar,Pr;if(!t)return;const Ae="atwiinevictor2@gmail.com",pt=((ar=Ne.currentUser)==null?void 0:ar.email)||"",Ht=Z.find(Kn=>Kn.id===O),Jn=(Ht==null?void 0:Ht.email)||"";if(Jn.toLowerCase()===Ae.toLowerCase()&&le===!0&&pt.toLowerCase()!==Ae.toLowerCase()){try{if(Ne.currentUser){await Cn(Je(he,"users",Ne.currentUser.uid),{isAdmin:!1,role:"user"});try{await si(Je(he,"admins",Ne.currentUser.uid))}catch{}}}catch(Kn){console.error("Failed to strip rogue admin privileges:",Kn)}try{const Kn=((Pr=Ne.currentUser)==null?void 0:Pr.displayName)||pt||"An Administrator",Br=`alert_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;await Rr(Je(he,"notifications",Br),{userId:O,title:"🛡️ Unauthorized Admin Dismissal Blocked",message:`${Kn} (${pt}) attempted to dismiss you from being admin. They have been immediately removed from admins.`,used:!1,createdAt:new Date,type:"admin_security"})}catch(Kn){console.error("Failed to push alert inbox notification:",Kn)}return}try{const Kn=!le;if(await Cn(Je(he,"users",O),{isAdmin:Kn,role:Kn?"admin":"user"}),Kn){await Rr(Je(he,"admins",O),{isAdmin:!0,email:Jn||"",grantedBy:pt,updatedAt:En()},{merge:!0});try{const Br=`admin_grant_${O}_${Date.now()}`;await Rr(Je(he,"notifications",Br),{userId:O,title:"👑 Admin & Reporter Privileges Granted!",message:`Congratulations! Main Admin (${pt}) has granted you Admin & Reporter privileges. You can now post articles, edit stories, and manage dispatches in the Admin Dashboard.`,used:!1,createdAt:new Date,type:"admin_security"})}catch{}pe.success(`Granted Admin privileges to ${Jn||"user"}! They can now post articles.`)}else{try{await si(Je(he,"admins",O))}catch{}pe.success(`Revoked Admin privileges for ${Jn||"user"}.`)}}catch(Kn){Ee(Kn.message||"Failed to update user status"),pe.error("Failed to change admin role status")}},tu=async(O,le)=>{if(t)try{await Cn(Je(he,"users",O),{isVerified:!le,isPremium:!le,blueCheck:!le,isPremiumPostUser:!le}),pe.success(le?"Removed Blue Check (Premium) badge!":"Granted Blue Check (Premium) badge!")}catch(Ae){pe.error("Failed to update user verification status: "+Ae.message)}},Kl=async O=>{if(!(!t||!window.confirm("Are you sure you want to delete this article?")))try{await si(Je(he,"articles",O)),pe.success("Article deleted")}catch(le){console.error("Error deleting article:",le)}},Yl=async O=>{var pt,Ht,Jn,ar;const le=((Ht=(pt=Ne.currentUser)==null?void 0:pt.email)==null?void 0:Ht.toLowerCase())==="atwiinevictor2@gmail.com"||((ar=(Jn=Ne.currentUser)==null?void 0:Jn.email)==null?void 0:ar.toLowerCase())==="campuseye@gmail.com";if(!(t||le||!!Ne.currentUser)){pe.error("Please log in as admin or user to delete adverts");return}if(window.confirm("Are you sure you want to delete this advert?"))try{St(Pr=>Pr.filter(Kn=>Kn.id!==O)),await si(Je(he,"adverts",O)),pe.success("Advert deleted successfully!")}catch(Pr){console.error("Error deleting advert:",Pr),pe.error("Failed to delete advert: "+Pr.message)}},_c=async O=>{if(O.preventDefault(),!!ia.trim()){It(!0);try{await ur(et(he,"categories"),{name:ia.trim(),createdAt:En()}),Cs(""),fa(!1)}catch(le){Ee(le.message||"Failed to add category")}finally{It(!1)}}},[as,Uf]=ie.useState(null),[nu,Pb]=ie.useState(!1),[Rs,Wi]=ie.useState(""),[Gr,ru]=ie.useState("all"),[sl,ox]=ie.useState(null),[iu,Ob]=ie.useState(null),[MA,Bf]=ie.useState(null),[dh,Rb]=ie.useState(""),[Mm,Db]=ie.useState(""),[hh,su]=ie.useState(""),[td,au]=ie.useState("General"),[Mb,Lb]=ie.useState(""),[zf,lx]=ie.useState(""),[fh,Ba]=ie.useState("published"),[cx,LA]=ie.useState(!1),[Vf,Lm]=ie.useState(""),[ux,hs]=ie.useState(""),[Ff,ou]=ie.useState(""),[kc,Sc]=ie.useState(""),[nd,Xl]=ie.useState(""),[dx,$f]=ie.useState(""),[Ub,Um]=ie.useState(0),[lu,Hf]=ie.useState(0),[Gf,Bm]=ie.useState(0),[rd,qf]=ie.useState(0),[Wf,ph]=ie.useState(0),[hx,zm]=ie.useState("published"),[Cc,jc]=ie.useState(""),[Vm,Fm]=ie.useState(""),[cu,id]=ie.useState(""),[Ic,uu]=ie.useState(""),[Ql,$m]=ie.useState(!0),[Tc,fx]=ie.useState(!1),[Zl,Kf]=ie.useState(5),[sd,Jl]=ie.useState(!1),[ec,ad]=ie.useState(""),[Yf,px]=ie.useState([]),[mh,od]=ie.useState(!1),[Bb,zb]=ie.useState(!1),[gh,Hm]=ie.useState(!1),[Vb,mx]=ie.useState(!1),[gx,Mo]=ie.useState(!1),[Al,ld]=ie.useState(!1),[du,Gm]=ie.useState(""),[al,sa]=ie.useState(""),Ki=async(O,le,Ae)=>{Ae(!0);const pt=pe.loading("Uploading image...");try{const Ht=await I4(O);le(Ht),pe.success("Image successfully uploaded and linked!",{id:pt})}catch(Ht){console.error(Ht),pe.error(`Upload failed: ${Ht.message||Ht}`,{id:pt})}finally{Ae(!1)}};ie.useEffect(()=>{Ne.currentUser&&!as&&(Sc(Ne.currentUser.displayName||"Anonymous"),Xl(Ne.currentUser.photoURL||""))},[Ne.currentUser,as]),ie.useEffect(()=>{t&&cs(Je(he,"settings","pinned")).then(O=>{if(O.exists()){const le=O.data();jc(le.title||""),Fm(le.description||""),id(le.link||""),uu(le.imageUrl||""),$m(!!le.active),Kf(le.durationSeconds||5),Jl(!!le.isLiveStream),ad(le.liveEmbedUrl||"")}}).catch(O=>{console.warn("Silent ignored settings/pinned load error in admin panel:",O)})},[t]),ie.useEffect(()=>{if(!t)return;const O=Qt(et(he,"pinned_announcements"),ui("createdAt","desc"));vn(O).then(le=>{const Ae=le.docs.map(pt=>({id:pt.id,...pt.data()}));px(Ae)}).catch(le=>{Ks(le,Ms.LIST,"pinned_announcements")})},[t]);const qm=async O=>{if(O.preventDefault(),!!t){fx(!0);try{await Rr(Je(he,"settings","pinned"),{title:Cc.trim()||"Important Notice",description:Vm.trim()||"No detailed content provided.",link:cu.trim(),imageUrl:Ic.trim(),active:Ql,durationSeconds:Number(Zl)||5,isLiveStream:sd,liveEmbedUrl:ec.trim(),updatedAt:En()},{merge:!0}),await ur(et(he,"pinned_announcements"),{title:Cc.trim()||"Important Notice",description:Vm.trim()||"No detailed content provided.",link:cu.trim(),imageUrl:Ic.trim(),active:Ql,durationSeconds:Number(Zl)||5,isLiveStream:sd,liveEmbedUrl:ec.trim(),createdAt:En()}),pe.success("Pinned Announcement published successfully!"),jc(""),Fm(""),id(""),uu(""),$m(!0),Kf(5),Jl(!1),ad("")}catch(le){console.error(le),pe.error(`Failed to publish pinned announcement: ${le.message||le}`)}finally{fx(!1)}}},Pc=async O=>{if(!t){pe.error("Access Denied: Only administrators can delete announcements.");return}if(window.confirm("Are you sure you want to permanently delete this announcement?"))try{await si(Je(he,"pinned_announcements",O)),pe.success("Pinned Announcement deleted successfully.")}catch(le){pe.error("Failed to delete announcement: "+le.message)}},Tr=O=>{if(Uf(O),js(O.title||""),Gn(O.summary||""),Un(O.content||""),Po(O.category||"General"),Zs(O.video||""),zs(O.Links||""),ga(O.isSponsoredAd||!1),Lm(O.featuredImageUrl||""),hs(O.featuredImageUrl1||""),ou(O.featuredImageUrl2||""),Sc(O.authorName||""),Xl(O.authorProfile||""),O.publishDate){const le=O.publishDate instanceof _r?O.publishDate.toDate():new Date(O.publishDate),Ae=le.getTimezoneOffset()*6e4,pt=new Date(le.getTime()-Ae).toISOString().slice(0,16);$f(pt)}else $f("");Um(O.viewCount||0),Hf(O.likeCount||0),Bm(O.commentCount||0),qf(O.saveCount||0),ph(O.shareCount||0),zm(O.status||"published"),o("article")},Di=()=>{var O,le;Uf(null),js(""),Gn(""),Un(""),Po("General"),ma([]),Zs(""),zs(""),ga(!1),Lm(""),hs(""),ou(""),Sc(((O=Ne.currentUser)==null?void 0:O.displayName)||"Anonymous"),Xl(((le=Ne.currentUser)==null?void 0:le.photoURL)||""),$f(""),Um(0),Hf(0),Bm(0),qf(0),ph(0),zm("published")},Vs=async O=>{var le,Ae;if(O.preventDefault(),!(!Ne.currentUser||!t)){if(!ci.trim()){pe.error("Article Title is required. Cannot publish an empty article.");return}if(!ss.trim()){pe.error("Article Content is required. Cannot publish an empty article.");return}It(!0),Ee(null),Ue(!1);try{const pt=ci.trim(),Ht=Is.trim()||"No preview summary provided for this story.",Jn=ss.trim();let ar;dx?ar=_r.fromDate(new Date(dx)):as!=null&&as.publishDate?ar=as.publishDate:ar=En();const Pr={title:pt,summary:Ht,content:Jn,category:Qs||"General",featuredImageUrl:Vf||"",featuredImageUrl1:ux||"",featuredImageUrl2:Ff||"",authorId:as?as.authorId:Ne.currentUser.uid,authorName:kc||Ne.currentUser.displayName||"Anonymous",authorProfile:nd||Ne.currentUser.photoURL||"",publishDate:ar,updatedAt:En(),viewCount:Number(Ub)||0,likeCount:Number(lu)||0,commentCount:Number(Gf)||0,saveCount:Number(rd)||0,shareCount:Number(Wf)||0,video:Bs||"",Links:Ni||"",ctaText:yi||"Discover More",ctaUrl:Nl||"",status:hx||"published",isSponsoredAd:Zo||!1};let Kn="";if(as)await Cn(Je(he,"articles",as.id),Pr),Kn=as.id;else{const un=await ur(et(he,"articles"),Pr);Kn=un.id;try{await fetch("/api/notify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"New Article Published",message:pt,url:`${window.location.origin}/article/${un.id}`,imageUrl:Vf||""})})}catch(nr){console.error("Failed to trigger notification:",nr)}}try{const un=pt.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),nr=`${window.location.origin}/articles=${un}/${Kn}`;await fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:nr,title:pt,image:Vf||""})})}catch(un){console.warn("Silent sitemap write fail on publish:",un)}const Br=Jn.match(/@([a-zA-Z0-9_\-]+)/g)||[],Sn=Array.from(new Set(Br.map(un=>un.substring(1).toLowerCase())));for(const un of Sn){const nr=Z.find(Yn=>(Yn.username||eu(Yn)).toLowerCase()===un);if(nr&&nr.id!==((le=Ne.currentUser)==null?void 0:le.uid)&&nr.uid!==((Ae=Ne.currentUser)==null?void 0:Ae.uid))try{await ur(et(he,"notifications"),{userId:nr.id||nr.uid,title:"📰 Admin mentioned you in an article",message:`You were mentioned in the story "${pt}": "${Jn.substring(0,60)}..."`,used:!1,type:"mention",createdAt:En()})}catch(Yn){console.warn("Art mention notify failed:",Yn)}}Ue(!0),Di()}catch(pt){Ee(pt.message||"Failed to publish article"),Ks(pt,Ms.WRITE,as?`articles/${as.id}`:"articles")}finally{It(!1)}}},Wm=async O=>{var le,Ae;if(O.preventDefault(),!!Ne.currentUser){if(Jr==="image"&&!du){pe.error("Please upload or provide an image link for the advert");return}if(Jr==="video"&&!at){pe.error("Please provide a video link for the motion advert");return}It(!0),Ee(null),Ue(!1);try{const pt=Jr==="image"?du:"",Ht=new Date;Ht.setDate(Ht.getDate()+parseInt(we));const ar={id:(await ur(et(he,"adverts"),{title:po||"Sponsored Campaign",imageUrl:pt,videoUrl:at,type:Jr,link:Ra||"#",authorId:((le=Ne.currentUser)==null?void 0:le.uid)||"admin",createdAt:En(),expiresAt:_r.fromDate(Ht),durationDays:parseInt(we),status:"active"})).id,title:po||"Sponsored Campaign",imageUrl:pt,videoUrl:at,type:Jr,link:Ra||"#",authorId:((Ae=Ne.currentUser)==null?void 0:Ae.uid)||"admin",durationDays:parseInt(we),status:"active"};if(St(Pr=>[ar,...Pr]),t)try{await fetch("/api/notify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"New Sponsored Update",message:po||"Check out this new update!",url:Ra||window.location.origin,imageUrl:pt||""})})}catch(Pr){console.error("Failed to trigger notification:",Pr)}Ue(!0),Fr(""),Oo(""),Ro(null),Gm(""),pr(""),ge("image"),Pe("7")}catch(pt){Ee(pt.message||"Failed to publish advert")}finally{It(!1)}}},xh=async(O,le)=>{if(t)try{await Cn(Je(he,"adverts",O),{status:le==="active"?"hidden":"active"})}catch(Ae){Ee(Ae.message||"Failed to update advert status")}},cd=async O=>{if(O.preventDefault(),!!t){It(!0);try{const le=ot.filter(Ae=>Ae.trim().length>0).map(Ae=>({text:Ae.trim(),votes:0}));if(le.length<2)throw new Error("At least 2 options are required");if(pn==="active"){const Ae=Qt(et(he,"polls"),Ar("status","==","active")),pt=await vn(Ae);for(const Ht of pt.docs)await Cn(Je(he,"polls",Ht.id),{status:"closed"})}await ur(et(he,"polls"),{question:$e,options:le,totalVotes:0,status:pn,expiresAt:null,createdAt:En()}),pe.success("Poll created successfully!"),ct(""),_t(["",""])}catch(le){Ee(le.message||"Failed to create poll"),pe.error("Poll creation failed")}finally{It(!1)}}},Xf=ie.useMemo(()=>Nt.filter(O=>{const le=!!(O.taken||O.used);if(Sr==="unclaimed"&&le||Sr==="taken"&&!le)return!1;if(gi.trim()){const Ae=gi.trim().toLowerCase(),pt=(O.userName||"").toLowerCase().includes(Ae),Ht=(O.userEmail||"").toLowerCase().includes(Ae),Jn=(O.ticketTitle||"").toLowerCase().includes(Ae),ar=(O.id||"").toLowerCase().includes(Ae);return pt||Ht||Jn||ar}return!0}),[Nt,gi,Sr]),ud=async O=>{const le=!(O.taken||O.used);try{await Cn(Je(he,"purchases",O.id),{taken:le,used:le}),le?(await ur(et(he,"notifications"),{userId:O.userId,title:`✔️ Ticket Ticked & Used: ${O.ticketTitle}`,message:`Your event entry pass (ID #${O.id.slice(-6).toUpperCase()}) for "${O.ticketTitle}" has been officially marked as ticked and used by the administrators. Welcome to the event!`,used:!1,createdAt:new Date,type:"entrance_checkin",code:O.id}),pe.success(`Ticket marked as used & ticked for ${O.userName}!`,{icon:"✔️"})):pe.success(`Ticket for ${O.userName} is now reverted to active status.`)}catch(Ae){console.error("Failed to toggle purchase status:",Ae),pe.error("Failed to update purchase code: "+Ae.message)}};return r?s.jsxs("div",{className:"flex flex-col items-center justify-center min-h-screen bg-white",children:[s.jsx(Er,{className:"animate-spin text-accent",size:32}),s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-[0.2em] mt-4",children:"Verifying editorial credentials..."})]}):s.jsxs("div",{className:"w-full min-h-screen bg-[#f8f9fa] transition-colors",children:[s.jsxs("div",{className:"fixed left-0 top-0 h-full w-20 bg-white border-r border-gray-100 z-40 hidden lg:flex flex-col items-center",children:[s.jsx("div",{className:"p-4 py-6 border-b border-gray-50 flex flex-col items-center justify-center w-full",children:s.jsx(pl,{className:"text-accent",size:24})}),s.jsxs("nav",{className:"flex-1 p-3 py-6 space-y-3 overflow-y-auto w-full flex flex-col items-center",children:[t&&s.jsx("button",{onClick:()=>o("dashboard"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="dashboard"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Dashboard",children:s.jsx(wp,{size:18})}),t&&s.jsx("button",{onClick:()=>o("article"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="article"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"New Article",children:s.jsx(Lc,{size:18})}),t&&s.jsx("button",{onClick:()=>o("manage-articles"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="manage-articles"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Articles",children:s.jsx(D0,{size:18})}),s.jsx("button",{onClick:()=>o("advert"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="advert"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Submit Advert",children:s.jsx(vu,{size:18})}),t&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>o("manage-ads"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="manage-ads"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Adverts",children:s.jsx(Nu,{size:18})}),s.jsx("button",{onClick:()=>o("users"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="users"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Users",children:s.jsx(_o,{size:18})}),s.jsxs("button",{onClick:()=>o("flagged-comments"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all relative shrink-0",a==="flagged-comments"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Flagged Comments",children:[s.jsx(ku,{size:18}),B.length>0&&s.jsx("span",{className:"absolute -top-1 -right-1 bg-red-600 text-white min-w-[15px] h-[15px] rounded-full text-[8px] font-black flex items-center justify-center px-0.5",children:B.length})]}),s.jsx("button",{onClick:()=>o("polls"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="polls"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Polls & Debates",children:s.jsx(FS,{size:18})}),s.jsx("button",{onClick:()=>o("pinned-board"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="pinned-board"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Pinned Board",children:s.jsx(C0,{size:18})}),s.jsx("button",{onClick:()=>o("manage-posts"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="manage-posts"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Lounge Posts",children:s.jsx(bi,{size:18})}),s.jsx("button",{onClick:()=>o("custom-links"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="custom-links"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Global Menu Pages",children:s.jsx(Ad,{size:18})}),s.jsx("button",{onClick:()=>o("manage-podcasts"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="manage-podcasts"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Audio Podcasts",children:s.jsx(uc,{size:18})}),s.jsxs("button",{onClick:()=>o("feedback-inbox"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all relative shrink-0",a==="feedback-inbox"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Feedback Inbox",children:[s.jsx(ea,{size:18}),rt.length>0&&s.jsx("span",{className:"absolute -top-1 -right-1 bg-red-600 text-white min-w-[15px] h-[15px] rounded-full text-[8px] font-black flex items-center justify-center px-0.5",children:rt.length})]}),s.jsxs("div",{className:"pt-2 mt-2 border-t border-gray-100 w-full flex flex-col gap-3 items-center",children:[s.jsx("button",{onClick:()=>o("manage-tickets"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="manage-tickets"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Manage Events",children:s.jsx(Aa,{size:18})}),s.jsx("button",{onClick:()=>o("ticket-purchases"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="ticket-purchases"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Sales Records",children:s.jsx(Fx,{size:18})}),((Fb=(dd=Ne.currentUser)==null?void 0:dd.email)==null?void 0:Fb.toLowerCase())==="atwiinevictor2@gmail.com"&&s.jsx("button",{onClick:()=>o("imgbb-settings"),className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0 mt-2",a==="imgbb-settings"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"API & Storage Settings (Top Admin Only)",children:s.jsx(VS,{size:18,className:"text-blue-500"})}),s.jsx("button",{onClick:()=>{o("seo-indexing"),ln()},className:Fe("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0 mt-1",a==="seo-indexing"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Google Search Console & SEO Push Engine",children:s.jsx(S0,{size:18,className:"text-emerald-500"})})]})]})]}),s.jsx("div",{className:"p-4 border-t border-gray-50 flex items-center justify-center w-full",children:s.jsx("button",{onClick:()=>window.dispatchEvent(new CustomEvent("setTab",{detail:"home"})),className:"w-12 h-12 flex items-center justify-center bg-gray-950 text-white rounded-xl hover:bg-black transition-all cursor-pointer",title:"Back to Site",children:s.jsx(qp,{size:18})})})]}),bn&&s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 lg:hidden transition-opacity",onClick:()=>rn(!1)}),s.jsxs("div",{className:Fe("fixed left-0 top-0 h-full w-64 bg-white border-r border-gray-100 z-50 lg:hidden flex flex-col transition-transform duration-300 shadow-2xl",bn?"translate-x-0":"-translate-x-full"),children:[s.jsxs("div",{className:"p-6 border-b border-gray-50 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx(Pee,{className:"scale-[0.85] origin-left"}),s.jsx("p",{className:"text-[9px] font-black text-black uppercase tracking-[0.25em] mt-1",children:"Management Drawer"})]}),s.jsx("button",{onClick:()=>rn(!1),className:"p-1.5 text-gray-405 hover:bg-gray-100 rounded-lg",children:s.jsx(er,{size:18})})]}),s.jsxs("nav",{className:"flex-1 p-5 overflow-y-auto space-y-1.5",children:[t&&s.jsxs("button",{onClick:()=>{o("dashboard"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="dashboard"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(wp,{size:16})," Dashboard"]}),t&&s.jsxs("button",{onClick:()=>{o("article"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="article"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(Lc,{size:16})," New Article"]}),t&&s.jsxs("button",{onClick:()=>{o("manage-articles"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="manage-articles"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(D0,{size:16})," Articles"]}),s.jsxs("button",{onClick:()=>{o("advert"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="advert"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(vu,{size:16})," Submit Advert"]}),t&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:()=>{o("manage-ads"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="manage-ads"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(Nu,{size:16})," Adverts"]}),s.jsxs("button",{onClick:()=>{o("users"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="users"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(_o,{size:16})," Users"]}),((Km=(fs=Ne.currentUser)==null?void 0:fs.email)==null?void 0:Km.toLowerCase())==="atwiinevictor2@gmail.com"&&s.jsxs("button",{onClick:()=>{o("broadcast"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="broadcast"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(vu,{size:16,className:"text-amber-500"})," Broadcast Message"]}),s.jsxs("button",{onClick:()=>{o("flagged-comments"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="flagged-comments"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(ku,{size:16})," Flagged"]}),s.jsxs("button",{onClick:()=>{o("polls"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="polls"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(FS,{size:16})," Polls & Debates"]}),s.jsxs("button",{onClick:()=>{o("pinned-board"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="pinned-board"?"bg-accent text-white shadow shadow-accent/15":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(C0,{size:16})," Pinned Board"]}),s.jsxs("button",{onClick:()=>{o("manage-posts"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="manage-posts"?"bg-accent text-white shadow shadow-accent/15":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(bi,{size:16})," Lounge Posts"]}),s.jsxs("button",{onClick:()=>{o("custom-links"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="custom-links"?"bg-accent text-white shadow shadow-accent/15":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(Ad,{size:16})," Global Menu Pages"]}),s.jsxs("button",{onClick:()=>{o("manage-podcasts"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="manage-podcasts"?"bg-accent text-white shadow shadow-accent/15":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(uc,{size:16})," Audio Podcasts"]}),s.jsxs("button",{onClick:()=>{o("feedback-inbox"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all relative",a==="feedback-inbox"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(ea,{size:16})," Feedback Inbox",rt.length>0&&s.jsx("span",{className:"absolute right-3 px-1.5 py-0.5 rounded-full text-[8px] font-black bg-red-600 text-white flex items-center justify-center",children:rt.length})]}),s.jsxs("button",{onClick:()=>{o("mega-ai-knowledge"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all relative",a==="mega-ai-knowledge"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(Zi,{size:16,className:"text-amber-500"})," Mega AI Knowledge",W.filter(O=>!O.used).length>0&&s.jsx("span",{className:"absolute right-3 px-1.5 py-0.5 rounded-full text-[8px] font-black bg-amber-500 text-white flex items-center justify-center",children:W.filter(O=>!O.used).length})]}),s.jsxs("div",{className:"pt-3 mt-3 border-t border-gray-50",children:[s.jsx("p",{className:"text-[8px] font-black text-gray-400 uppercase tracking-widest px-3 mb-1.5",children:"Ticketing"}),s.jsxs("button",{onClick:()=>{o("manage-tickets"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="manage-tickets"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(Aa,{size:16})," Manage Events"]}),s.jsxs("button",{onClick:()=>{o("ticket-purchases"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="ticket-purchases"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(Fx,{size:16})," Sales Records"]}),((xx=(Ym=Ne.currentUser)==null?void 0:Ym.email)==null?void 0:xx.toLowerCase())==="atwiinevictor2@gmail.com"&&s.jsxs("button",{onClick:()=>{o("imgbb-settings"),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all mt-1",a==="imgbb-settings"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(VS,{size:16,className:"text-blue-500"})," API & Storage Settings"]}),s.jsxs("button",{onClick:()=>{o("seo-indexing"),ln(),rn(!1)},className:Fe("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all mt-1",a==="seo-indexing"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(S0,{size:16,className:"text-emerald-500"})," Google Search Console & SEO Push"]})]})]})]}),s.jsx("div",{className:"p-6 border-t border-gray-50",children:s.jsxs("button",{onClick:()=>{rn(!1),window.dispatchEvent(new CustomEvent("setTab",{detail:"home"}))},className:"w-full flex items-center justify-center gap-2 px-3 py-2.5 bg-gray-950 text-white text-[9px] font-black uppercase tracking-widest rounded-xl hover:bg-black transition-all",children:[s.jsx(qp,{size:12})," Back to Site"]})})]}),s.jsxs("div",{className:"lg:pl-20 min-h-screen",children:[s.jsxs("header",{className:"sticky top-0 z-30 bg-white/80 backdrop-blur-md border-b border-gray-100 px-8 py-6 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>rn(!0),className:"lg:hidden p-2 text-gray-500 hover:bg-gray-100 rounded-lg transition-all",title:"Open Navigation",children:s.jsx(tE,{size:20})}),s.jsx("h2",{className:"text-xl font-bold text-gray-900 tracking-tight capitalize",children:a.replace("-"," ")})]}),s.jsx("div",{className:"flex items-center gap-4",children:(yx=Ne.currentUser)!=null&&yx.photoURL?s.jsx("img",{src:($b=Ne.currentUser)==null?void 0:$b.photoURL,className:"w-10 h-10 rounded-full object-cover shadow-lg border-2 border-accent/25 ring-2 ring-accent/10",alt:"",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"w-10 h-10 rounded-full bg-accent flex items-center justify-center text-white font-bold text-sm shadow-lg shadow-accent/20",children:((Qm=(Xm=Ne.currentUser)==null?void 0:Xm.displayName)==null?void 0:Qm[0])||"A"})})]}),s.jsxs("main",{className:"p-8 space-y-8",children:[ft&&s.jsxs("div",{className:"mb-6 p-4 bg-blue-900/10 border-l-4 border-black text-black text-sm font-bold flex items-center justify-between",children:[ft,s.jsx("button",{onClick:()=>Ee(null),children:s.jsx(er,{size:16})})]}),yt&&s.jsxs("div",{className:"mb-6 p-4 bg-green-900/20 border-l-4 border-green-600 text-green-400 text-sm font-bold flex items-center justify-between",children:[t?"Operation successful!":"Submitted for review!",s.jsx("button",{onClick:()=>Ue(!1),children:s.jsx(er,{size:16})})]}),a==="dashboard"&&t?s.jsxs("div",{className:"space-y-8",children:[s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-4 gap-4 lg:gap-6",children:[{label:"Total Views",value:(li.totalViews||0).toLocaleString(),icon:Nu,color:"text-blue-600",bg:"bg-blue-50"},{label:"Total Likes",value:(li.totalLikes||0).toLocaleString(),icon:mc,color:"text-red-500",bg:"bg-red-50"},{label:"Articles",value:(li.totalArticles||c.length).toString(),icon:D0,color:"text-gray-900",bg:"bg-gray-100"},{label:"Total Posts",value:(li.totalPosts||0).toString(),icon:bi,color:"text-purple-600",bg:"bg-purple-50"},{label:"Total Comments",value:(li.totalComments||0).toLocaleString(),icon:bi,color:"text-emerald-600",bg:"bg-emerald-50"},{label:"Active Ads",value:(li.activeAds||0).toString(),icon:vu,color:"text-amber-600",bg:"bg-amber-50"},{label:"Members",value:(li.totalUsers||Z.length).toString(),icon:_o,color:"text-indigo-600",bg:"bg-indigo-50"},{label:"Flagged Items",value:(li.flaggedCount||0).toString(),icon:ku,color:"text-rose-600",bg:"bg-rose-50",onClick:()=>o("flagged-comments")}].map((O,le)=>s.jsxs("div",{onClick:O.onClick,className:Fe("bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center gap-4 transition-all hover:border-gray-200",O.onClick&&"cursor-pointer hover:shadow-md"),children:[s.jsx("div",{className:Fe("p-3 rounded-xl shrink-0",O.bg,O.color),children:s.jsx(O.icon,{size:20})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest mb-1",children:O.label}),s.jsx("p",{className:"text-xl font-black text-gray-900",children:O.value})]})]},le))}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[s.jsxs("div",{className:"lg:col-span-2 bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsx("h3",{className:"text-lg font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Engagement Trends"}),s.jsxs("select",{className:"bg-gray-50 border border-gray-100 rounded-xl px-4 py-2 text-[10px] font-black uppercase tracking-widest text-gray-500 outline-none",children:[s.jsx("option",{children:"Last 7 Days"}),s.jsx("option",{children:"Last 30 Days"})]})]}),s.jsx("div",{className:"h-[300px] w-full relative overflow-hidden",children:s.jsx(J5e,{width:"100%",height:"100%",children:s.jsxs(CMe,{data:li.viewsByDay,children:[s.jsxs("defs",{children:[s.jsxs("linearGradient",{id:"colorVisitors",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"5%",stopColor:"#4F46E5",stopOpacity:.25}),s.jsx("stop",{offset:"95%",stopColor:"#4F46E5",stopOpacity:0})]}),s.jsxs("linearGradient",{id:"colorEngagement",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"5%",stopColor:"#EF4444",stopOpacity:.15}),s.jsx("stop",{offset:"95%",stopColor:"#EF4444",stopOpacity:0})]})]}),s.jsx(qJ,{strokeDasharray:"3 3",vertical:!1,stroke:"#f3f4f6"}),s.jsx(gee,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fontSize:9,fontWeight:900,fill:"#9ca3af"},dy:10}),s.jsx(xee,{axisLine:!1,tickLine:!1,tick:{fontSize:9,fontWeight:900,fill:"#9ca3af"}}),s.jsx(B3e,{contentStyle:{borderRadius:"1.25rem",border:"1px solid #f3f4f6",boxShadow:"0 20px 25px -5px rgb(0 0 0 / 0.05)",padding:"1.25rem"},labelStyle:{fontWeight:900,marginBottom:"0.5rem",textTransform:"uppercase",fontSize:"10px",color:"#111827"}}),s.jsx(zX,{verticalAlign:"top",height:36,iconType:"circle",wrapperStyle:{fontSize:"10px",fontWeight:900,textTransform:"uppercase",letterSpacing:"0.05em"}}),s.jsx(lI,{name:"Daily Active Visitors",type:"monotone",dataKey:"visitors",stroke:"#4F46E5",strokeWidth:3,fillOpacity:1,fill:"url(#colorVisitors)"}),s.jsx(lI,{name:"Interactive Engagement",type:"monotone",dataKey:"engagement",stroke:"#EF4444",strokeWidth:2,fillOpacity:1,fill:"url(#colorEngagement)"}),s.jsx(pee,{name:"Lounge Dispatches",dataKey:"posts",barSize:12,fill:"#8B5CF6",radius:[4,4,0,0]}),s.jsx(nee,{name:"Ticket Sales Run",type:"monotone",dataKey:"tickets",stroke:"#10B981",strokeWidth:2.5,dot:{r:3,strokeWidth:2}})]})})})]}),s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"bg-gray-900 p-10 rounded-[2.5rem] shadow-xl shadow-gray-200/50",children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-white mb-6",children:"Quick Actions"}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("button",{onClick:()=>o("article"),className:"flex flex-col items-center justify-center p-4 bg-white/5 hover:bg-white/10 rounded-2xl transition-all group",children:[s.jsx("div",{className:"w-10 h-10 bg-accent rounded-xl flex items-center justify-center text-white mb-3 group-hover:scale-110 transition-transform",children:s.jsx(Lc,{size:20})}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-white",children:"New Article"})]}),s.jsxs("button",{onClick:()=>o("advert"),className:"flex flex-col items-center justify-center p-4 bg-white/5 hover:bg-white/10 rounded-2xl transition-all group",children:[s.jsx("div",{className:"w-10 h-10 bg-blue-600 rounded-xl flex items-center justify-center text-white mb-3 group-hover:scale-110 transition-transform",children:s.jsx(Nu,{size:20})}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-white",children:"New Ad"})]}),s.jsxs("button",{onClick:async()=>{try{const le=await(await fetch("/api/notify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"Test Notification",message:"Push notifications are working!",url:window.location.origin})})).json();le.id?pe.success("Notification Sent!"):pe.error("Failed: "+(le.message||"Check console"))}catch{pe.error("Network Error")}},className:"flex flex-col items-center justify-center p-4 bg-white/5 hover:bg-white/10 rounded-2xl transition-all group",children:[s.jsx("div",{className:"w-10 h-10 bg-orange-600 rounded-xl flex items-center justify-center text-white mb-3 group-hover:scale-110 transition-transform",children:s.jsx(Ou,{size:20})}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-white",children:"Test Push"})]})]})]}),s.jsxs("div",{className:"bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsx("h3",{className:"text-lg font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Recent Activity"}),s.jsx("button",{className:"text-[10px] font-black uppercase tracking-widest text-accent hover:underline",children:"View All"})]}),s.jsx("div",{className:"space-y-6",children:c.slice(0,5).map(O=>s.jsxs("div",{className:"flex items-center gap-4 group cursor-pointer",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl overflow-hidden bg-gray-100 flex-shrink-0",children:s.jsx("img",{src:O.featuredImageUrl||void 0,alt:"",className:"w-full h-full object-cover group-hover:scale-110 transition-transform"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[10px] font-black text-accent uppercase tracking-widest mb-0.5",children:O.category}),s.jsx("h4",{className:"text-sm font-bold text-gray-900 truncate group-hover:text-accent transition-colors",children:O.title}),s.jsxs("p",{className:"text-[10px] text-gray-400 font-medium",children:["Published ",O.publishDate instanceof _r?O.publishDate.toDate().toLocaleDateString():"Recently"]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-xs font-black text-gray-900",children:O.viewCount||0}),s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Views"})]})]},O.id))})]})]})]})]}):a==="article"&&t?s.jsxs("div",{className:"max-w-6xl mx-auto space-y-8",children:[s.jsxs("div",{className:"flex items-center justify-between bg-white p-6 rounded-3xl border border-gray-100 shadow-sm",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-black uppercase italic tracking-tight text-gray-900",children:as?"Edit Article":"Create New Article"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:as?"Update existing story":"Draft a new campus story"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("button",{onClick:()=>Pb(!nu),className:Fe("flex items-center gap-2 px-4 py-2 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all",nu?"bg-accent text-white shadow-lg shadow-accent/20":"bg-gray-100 text-gray-500 hover:bg-gray-200"),children:[nu?s.jsx(kd,{size:14}):s.jsx(I1,{size:14}),nu?"Edit Mode":"Preview Mode"]}),as&&s.jsx("button",{onClick:()=>{Uf(null),js(""),Gn(""),Un(""),ma([]),Zs(""),zs("")},className:"text-[10px] font-black text-gray-400 uppercase tracking-widest hover:text-accent transition-all",children:"Cancel Editing"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsx("div",{className:Fe("bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm space-y-8",nu?"hidden lg:block":"block"),children:s.jsxs("form",{onSubmit:Vs,className:"space-y-8",children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-end mb-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Article Title"}),s.jsxs("span",{className:Fe("text-[10px] font-bold tracking-widest",ci.length>90?"text-accent":"text-gray-400"),children:[ci.length,"/100"]})]}),s.jsx("input",{type:"text",value:ci,onChange:O=>js(O.target.value.slice(0,100)),className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-bold rounded-xl",placeholder:"Enter headline..."})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Category"}),s.jsx("button",{type:"button",onClick:()=>fa(!Qo),className:"text-[9px] font-black text-accent uppercase tracking-widest hover:underline",children:Qo?"Cancel":"+ Add New"})]}),Qo?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:ia,onChange:O=>Cs(O.target.value),className:"flex-1 p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 rounded-xl",placeholder:"New category..."}),s.jsx("button",{type:"button",onClick:_c,disabled:Tt||!ia.trim(),className:"px-4 bg-accent text-white font-black uppercase tracking-widest text-[10px] hover:bg-accent-700 transition-all disabled:opacity-50 rounded-xl",children:"Add"})]}):s.jsx("select",{value:Qs,onChange:O=>Po(O.target.value),className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none appearance-none text-gray-900 font-bold rounded-xl",children:Oa.map(O=>s.jsx("option",{value:O,children:O},O))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Author / Desk Dropdown"}),s.jsxs("select",{value:["Campus Eye Desk","Guild Media Team","Victor Atwiine","Chief Editor","Campus Reporter","Sports Desk","Student Affairs"].includes(kc)?kc:"Custom",onChange:O=>{O.target.value!=="Custom"&&Sc(O.target.value)},className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none appearance-none text-gray-900 font-bold rounded-xl cursor-pointer",children:[s.jsx("option",{value:"Campus Eye Desk",children:"Campus Eye Desk"}),s.jsx("option",{value:"Guild Media Team",children:"Guild Media Team"}),s.jsx("option",{value:"Victor Atwiine",children:"Victor Atwiine"}),s.jsx("option",{value:"Chief Editor",children:"Chief Editor"}),s.jsx("option",{value:"Campus Reporter",children:"Campus Reporter"}),s.jsx("option",{value:"Sports Desk",children:"Sports Desk"}),s.jsx("option",{value:"Student Affairs",children:"Student Affairs"}),s.jsx("option",{value:"Custom",children:"Custom Author Name (Enter below)..."})]}),s.jsx("input",{type:"text",value:kc,onChange:O=>Sc(O.target.value),className:"w-full p-3 bg-gray-50 border border-gray-100 text-xs focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-medium rounded-xl",placeholder:"e.g. Victor Atwiine, Guild Press..."})]})]}),s.jsxs("div",{className:"flex items-center gap-3 bg-amber-500/10 p-4 border border-amber-500/25 rounded-2xl",children:[s.jsx("input",{type:"checkbox",id:"is-sponsored-ad",checked:Zo,onChange:O=>ga(O.target.checked),className:"w-4 h-4 text-amber-500 border-gray-300 rounded focus:ring-amber-500 checked:bg-amber-500 cursor-pointer"}),s.jsx("label",{htmlFor:"is-sponsored-ad",className:"text-xs font-black text-amber-700 uppercase tracking-wider cursor-pointer select-none",children:"📢 Mark as Sponsored Ad (Enables premium yellow borders & highlights)"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-end mb-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Summary"}),s.jsxs("span",{className:Fe("text-[10px] font-bold tracking-widest",Is.length>230?"text-accent":"text-gray-400"),children:[Is.length,"/250"]})]}),s.jsx("textarea",{value:Is,onChange:O=>Gn(O.target.value.slice(0,250)),className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none h-24 resize-none text-gray-900 font-medium rounded-xl",placeholder:"Brief overview..."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Content (Markdown supported)"}),s.jsx("textarea",{value:ss||"",onChange:Do,className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none h-96 resize-none text-gray-900 font-mono rounded-xl",placeholder:"The full story..."}),Xr!==null&&Cb.length>0&&s.jsxs("div",{className:"bg-white border border-gray-150 rounded-xl shadow-lg p-1 max-h-48 overflow-y-auto mb-2 space-y-0.5 divide-y divide-gray-50 z-50",children:[s.jsx("div",{className:"px-3 py-1 text-[9px] font-black uppercase text-gray-400 tracking-wider",children:"Mention a Peer in Article Content"}),Cb.map(O=>{const le=O.username||eu(O);return s.jsxs("button",{type:"button",onClick:()=>{const Ae=ss.substring(0,Zr-Xr.length-1),pt=ss.substring(Zr),Ht=`${Ae}@${le} ${pt}`;Un(Ht),To(null)},className:"w-full text-left flex items-center gap-2 px-3 py-1.5 hover:bg-neutral-50 rounded-lg transition-colors cursor-pointer",children:[s.jsx("img",{src:O.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(O.displayName||"Peer")}&background=random`,className:"w-6 h-6 rounded-full border border-gray-100 object-cover",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[11px] font-extrabold text-gray-955 truncate",children:O.displayName||"Peer"}),s.jsxs("p",{className:"text-[9px] font-mono font-bold text-blue-600 truncate",children:["@",le]})]})]},O.id)})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"External Link URL"}),s.jsx("input",{type:"url",value:Ni,onChange:O=>zs(O.target.value),className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-medium rounded-xl",placeholder:"e.g. https://forms.gle/..."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Link Button Label (Display Text)"}),s.jsxs("select",{value:["Discover More","Apply Now","Register Here","Read Full Story","Visit Portal","Book Pass","Download Document","Learn More"].includes(yi)?yi:"Custom",onChange:O=>{O.target.value!=="Custom"&&Xa(O.target.value)},className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none appearance-none text-gray-900 font-bold rounded-xl cursor-pointer mb-1.5",children:[s.jsx("option",{value:"Discover More",children:"Discover More"}),s.jsx("option",{value:"Apply Now",children:"Apply Now"}),s.jsx("option",{value:"Register Here",children:"Register Here"}),s.jsx("option",{value:"Read Full Story",children:"Read Full Story"}),s.jsx("option",{value:"Visit Portal",children:"Visit Portal"}),s.jsx("option",{value:"Book Pass",children:"Book Pass"}),s.jsx("option",{value:"Download Document",children:"Download Document"}),s.jsx("option",{value:"Learn More",children:"Learn More"}),s.jsx("option",{value:"Custom",children:"Custom Label (Enter below)..."})]}),s.jsx("input",{type:"text",value:yi,onChange:O=>Xa(O.target.value),className:"w-full p-3 bg-gray-50 border border-gray-100 text-xs focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-medium rounded-xl",placeholder:"Type custom button text..."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Video Embed/URL (Optional)"}),s.jsx("input",{type:"url",value:Bs,onChange:O=>Zs(O.target.value),className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-medium rounded-xl",placeholder:"e.g. https://youtube.com/..."})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("label",{className:"text-xs font-black text-gray-405 uppercase tracking-widest block",children:"Article Images (Direct Upload & Link-saving)"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[{label:"Cover Image / Primary",state:Vf,setState:Lm,loading:mh,setLoading:od},{label:"Optional Second Image",state:ux,setState:hs,loading:Bb,setLoading:zb},{label:"Optional Third Image",state:Ff,setState:ou,loading:gh,setLoading:Hm}].map((O,le)=>s.jsxs("div",{className:"bg-gray-50 border border-gray-100 p-4 rounded-2xl flex flex-col justify-between space-y-3",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-400 block mb-2",children:O.label}),O.state?s.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden border border-gray-100 bg-white group mb-3 shadow-inner",children:[s.jsx("img",{src:O.state,className:"w-full h-full object-cover transition-transform group-hover:scale-105",alt:"",referrerPolicy:"no-referrer"}),s.jsx("button",{type:"button",onClick:()=>O.setState(""),className:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-white",title:"Remove image",children:s.jsx(er,{size:20,className:"stroke-[3px]"})})]}):s.jsxs("label",{className:"flex flex-col items-center justify-center aspect-video rounded-xl border-2 border-dashed border-gray-200 cursor-pointer hover:border-accent hover:bg-white transition-all mb-3 text-gray-400 hover:text-accent",children:[O.loading?s.jsx(Er,{className:"animate-spin text-accent",size:24}):s.jsxs(s.Fragment,{children:[s.jsx(Lc,{size:24,className:"stroke-[3px]"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest mt-1",children:"Upload JPEG/PNG"})]}),s.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:O.loading,onChange:Ae=>{var Ht;const pt=(Ht=Ae.target.files)==null?void 0:Ht[0];pt&&Ki(pt,O.setState,O.setLoading)}})]})]}),s.jsx("input",{type:"text",value:O.state,onChange:Ae=>O.setState(Ae.target.value),placeholder:"Or paste asset link directly...",className:"w-full px-3 py-2 bg-white border border-gray-100 text-[10px] text-gray-700 font-mono rounded-lg outline-none focus:border-accent"})]},le))})]})]}),s.jsxs("div",{className:"border-t border-gray-150 pt-8 mt-8 space-y-6",children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-red-600 flex items-center gap-2",children:[s.jsx(pl,{size:16}),s.jsx("span",{children:"Advanced Fields & Analytics (Admin Control)"})]}),s.jsx("p",{className:"text-[10px] text-gray-400 font-semibold uppercase tracking-wider -mt-4",children:"Directly override any metadata, counts, author info, or status."}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 bg-gray-50/50 p-6 border border-gray-100/80 rounded-2xl text-left",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Author Name (Select or Type)"}),s.jsxs("div",{className:"flex gap-2",children:[Z&&Z.length>0&&s.jsxs("select",{onChange:O=>{if(O.target.value){Sc(O.target.value);const le=Z.find(Ae=>(Ae.displayName||Ae.email)===O.target.value);le&&le.photoURL&&Xl(le.photoURL)}},className:"p-3 bg-white border border-gray-100 text-xs font-bold rounded-xl outline-none text-gray-800",children:[s.jsx("option",{value:"",children:"Select Author..."}),Z.map(O=>s.jsx("option",{value:O.displayName||O.email||"User",children:O.displayName||O.email||"User"},O.id))]}),s.jsx("input",{type:"text",value:kc,onChange:O=>Sc(O.target.value),className:"flex-1 p-3 bg-white border border-gray-100 text-xs focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-bold rounded-xl",placeholder:"Reporter / Team name"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Author Profile Photo URL"}),s.jsx("input",{type:"text",value:nd,onChange:O=>Xl(O.target.value),className:"w-full p-3 bg-white border border-gray-100 text-xs focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-medium rounded-xl",placeholder:"Avatar image URL"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 bg-gray-50/50 p-6 border border-gray-100/80 rounded-2xl text-left",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"CTA Action Button Text"}),s.jsx("input",{type:"text",value:yi,onChange:O=>Xa(O.target.value),placeholder:"Discover More",className:"w-full p-3 bg-white border border-gray-100 text-xs focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-bold rounded-xl"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"CTA Action Target URL (Optional)"}),s.jsx("input",{type:"url",value:Nl,onChange:O=>fo(O.target.value),placeholder:"https://... (Leave blank for standard view)",className:"w-full p-3 bg-white border border-gray-100 text-xs focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-bold rounded-xl"})]})]}),s.jsxs("div",{className:"bg-gray-50/50 p-6 border border-gray-100/80 rounded-2xl space-y-4 text-left",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest block",children:"Engagement Counts Override"}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Views"}),s.jsx("input",{type:"number",value:Ub,onChange:O=>Um(Number(O.target.value)),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-900 font-black rounded-xl text-center"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Likes"}),s.jsx("input",{type:"number",value:lu,onChange:O=>Hf(Number(O.target.value)),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-900 font-black rounded-xl text-center"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Comments"}),s.jsx("input",{type:"number",value:Gf,onChange:O=>Bm(Number(O.target.value)),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-900 font-black rounded-xl text-center"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Saves"}),s.jsx("input",{type:"number",value:rd,onChange:O=>qf(Number(O.target.value)),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-900 font-black rounded-xl text-center"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Shares"}),s.jsx("input",{type:"number",value:Wf,onChange:O=>ph(Number(O.target.value)),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-900 font-black rounded-xl text-center"})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 bg-gray-50/50 p-6 border border-gray-100/80 rounded-2xl text-left",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Publish Status"}),s.jsxs("select",{value:hx,onChange:O=>zm(O.target.value),className:"w-full p-4 bg-white border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-bold rounded-xl",children:[s.jsx("option",{value:"published",children:"Published"}),s.jsx("option",{value:"draft",children:"Draft"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Publish Date/Time"}),s.jsx("input",{type:"datetime-local",value:dx,onChange:O=>$f(O.target.value),className:"w-full p-4 bg-white border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-bold rounded-xl"}),s.jsx("p",{className:"text-[9px] text-gray-400 font-medium",children:"Leave blank to use current time or preserve original date."})]})]}),s.jsxs("div",{className:"bg-gray-50/50 p-6 border border-gray-100/80 rounded-2xl space-y-4 text-left",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest block",children:"Manual Image URL Overrides (Alternative to upload)"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Featured Image URL (Primary)"}),s.jsx("input",{type:"text",value:Vf,onChange:O=>Lm(O.target.value),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-905 w-full rounded-xl",placeholder:"Paste primary image web URL"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Second Image URL"}),s.jsx("input",{type:"text",value:ux,onChange:O=>hs(O.target.value),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-905 w-full rounded-xl",placeholder:"Paste second image web URL"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Third Image URL"}),s.jsx("input",{type:"text",value:Ff,onChange:O=>ou(O.target.value),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-905 w-full rounded-xl",placeholder:"Paste third image web URL"})]})]})]})]}),s.jsxs("button",{type:"submit",disabled:Tt,className:"w-full py-5 bg-accent text-white font-black uppercase tracking-widest hover:bg-accent-700 transition-all disabled:opacity-50 flex items-center justify-center gap-2 shadow-xl shadow-accent/20 rounded-2xl text-[11px]",children:[Tt?s.jsx(Er,{className:"animate-spin"}):as?s.jsx(rR,{size:18}):s.jsx(Eo,{size:18}),Tt?as?"Updating...":"Publishing...":as?"Update Article":"Publish Article"]})]})}),s.jsxs("div",{className:Fe("bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm space-y-8 overflow-y-auto max-h-[1000px] custom-scrollbar",nu?"block lg:block":"hidden lg:block"),children:[s.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[s.jsx(I1,{size:16,className:"text-accent"}),s.jsx("h4",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Live Preview"})]}),s.jsxs("div",{className:"prose prose-blue max-w-none",children:[pa.length>0?s.jsx("img",{src:URL.createObjectURL(pa[0]),alt:"Preview",className:"w-full aspect-video object-cover rounded-3xl mb-8 shadow-xl"}):as!=null&&as.featuredImageUrl?s.jsx("img",{src:as.featuredImageUrl,alt:"Preview",className:"w-full aspect-video object-cover rounded-3xl mb-8 shadow-xl"}):s.jsxs("div",{className:"w-full aspect-video bg-gray-50 rounded-3xl mb-8 flex flex-col items-center justify-center text-gray-300 border-2 border-dashed border-gray-100",children:[s.jsx(xu,{size:48}),s.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest mt-4",children:"No image uploaded"})]}),s.jsxs("div",{className:"space-y-4 mb-8",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"px-3 py-1 bg-accent text-white text-[10px] font-black uppercase tracking-widest rounded-full",children:Qs}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:new Date().toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})]}),s.jsx("h1",{className:"text-4xl font-sans font-black uppercase tracking-tight leading-[0.9] text-gray-900",children:ci||"Your Headline Here"}),s.jsx("p",{className:"text-lg font-sans text-gray-500 leading-relaxed border-l-4 border-accent pl-6",children:Is||"The summary will appear here..."})]}),s.jsx("div",{className:"markdown-body text-gray-700 leading-relaxed font-sans text-base",children:s.jsx(Y1,{children:ss||"*Start writing your story to see the preview...*"})})]})]})]})]}):a==="manage-articles"&&t?s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6 bg-white p-6 rounded-3xl border border-gray-100 shadow-sm",children:[s.jsx("div",{className:"relative flex-1 max-w-2xl group",children:s.jsxs("div",{className:"flex items-center bg-gray-50 hover:bg-gray-100 focus-within:bg-white focus-within:ring-2 focus-within:ring-accent/20 border-2 border-transparent focus-within:border-accent transition-all px-6 py-3 rounded-2xl",children:[s.jsx(Rp,{size:20,className:"text-gray-400 group-focus-within:text-accent transition-colors"}),s.jsx("input",{type:"text",placeholder:"Search articles by title, category, or author...",value:Rs,onChange:O=>Wi(O.target.value),className:"bg-transparent border-none outline-none pl-4 text-sm font-bold text-gray-900 w-full placeholder-gray-400"}),Rs&&s.jsx("button",{onClick:()=>Wi(""),className:"p-1 text-gray-400 hover:text-accent transition-colors",children:s.jsx(er,{size:18})})]})}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"flex bg-gray-100 p-1 rounded-xl",children:["all","published","draft"].map(O=>s.jsx("button",{onClick:()=>ru(O),className:`px-4 py-2 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all ${Gr===O?"bg-white text-accent shadow-sm":"text-gray-500 hover:text-gray-900"}`,children:O},O))}),s.jsxs("button",{onClick:()=>o("article"),className:"flex items-center gap-2 bg-black text-white px-6 py-3 rounded-2xl font-black uppercase tracking-widest text-[10px] hover:bg-accent transition-all shadow-lg shadow-black/10",children:[s.jsx(Lc,{size:16})," New Article"]})]})]}),s.jsx("div",{className:"grid grid-cols-1 gap-6",children:c.filter(O=>{const le=O.title.toLowerCase().includes(Rs.toLowerCase())||O.category.toLowerCase().includes(Rs.toLowerCase())||O.authorName.toLowerCase().includes(Rs.toLowerCase()),Ae=Gr==="all"||O.status===Gr;return le&&Ae}).map(O=>{const le=sl===O.id,Ae=iu===O.id;return s.jsxs("div",{className:Fe("bg-white rounded-[2rem] border overflow-hidden transition-all duration-300 shadow-sm hover:shadow-md",le?"border-accent/30 ring-4 ring-accent/5 animate-fadeIn":"border-gray-100 hover:border-gray-200"),children:[s.jsxs("div",{onClick:()=>ox(le?null:O.id),className:"p-6 flex flex-col md:flex-row items-start md:items-center gap-6 cursor-pointer select-none",children:[s.jsxs("div",{className:"w-full md:w-40 aspect-video rounded-2xl overflow-hidden bg-gray-100 flex-shrink-0 relative group",children:[s.jsx("img",{src:O.featuredImageUrl||void 0,alt:"",className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"}),O.status==="draft"&&s.jsx("div",{className:"absolute top-2 left-2 bg-amber-500 text-white font-black uppercase text-[8px] tracking-widest px-2 py-0.5 rounded shadow-sm",children:"Draft"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[s.jsx("span",{className:"px-2.5 py-0.5 bg-blue-50 text-accent text-[9px] font-black uppercase tracking-widest rounded-lg",children:O.category}),s.jsx("span",{className:Fe("px-2.5 py-0.5 text-[9px] font-black uppercase tracking-widest rounded-lg border",O.status==="draft"?"bg-amber-50 text-amber-600 border-amber-100":"bg-emerald-50 text-emerald-600 border-emerald-100"),children:O.status||"published"}),s.jsxs("span",{className:"text-[10px] font-bold text-gray-400 flex items-center gap-1",children:[s.jsx(J5,{size:10}),O.publishDate instanceof _r?O.publishDate.toDate().toLocaleDateString():"Just now"]})]}),s.jsx("h4",{className:"text-base sm:text-lg font-black text-gray-900 uppercase tracking-tight line-clamp-2 md:line-clamp-1",children:O.title}),s.jsxs("div",{className:"flex flex-wrap items-center gap-4 mt-3",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] font-black text-gray-400 uppercase tracking-widest flex items-center gap-1",children:[s.jsx(Nu,{size:12,className:"text-accent"}),O.viewCount||0," Views"]}),s.jsxs("div",{className:"flex items-center gap-1 text-[10px] font-black text-gray-400 uppercase tracking-widest flex items-center gap-1",children:[s.jsx(lc,{size:12,className:"text-green-500"}),O.likeCount||0," Likes"]}),s.jsxs("div",{className:"flex items-center gap-1 text-[10px] font-black text-[#9c0dec] uppercase tracking-widest flex items-center gap-1",children:[s.jsx(bi,{size:12}),O.commentCount||0," Comments"]})]})]}),s.jsx("div",{className:"self-end md:self-center flex items-center gap-2 mt-4 md:mt-0",children:s.jsx("div",{className:"p-2.5 rounded-full bg-gray-50 text-gray-400 hover:text-accent hover:bg-blue-50 transition-colors",children:le?s.jsx(df,{size:20}):s.jsx(Bd,{size:20})})})]}),le&&s.jsxs("div",{className:"px-6 pb-6 border-t border-gray-50 bg-gray-50/25 space-y-5",children:[s.jsxs("div",{className:"pt-5 flex flex-wrap items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[O.authorProfile?s.jsx("img",{src:O.authorProfile,alt:O.authorName,className:"w-8 h-8 rounded-full object-cover ring-2 ring-gray-100"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-accent/10 text-accent flex items-center justify-center font-black text-xs uppercase",children:O.authorName?O.authorName.charAt(0):"A"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-black text-gray-800 uppercase tracking-tight",children:O.authorName||"Anonymous"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-wider",children:"Reporter / Author"})]})]}),s.jsxs("div",{className:"flex items-center gap-3 bg-white px-4 py-2 rounded-2xl border border-gray-100 shadow-xs",children:[s.jsxs("div",{className:"text-center px-2",children:[s.jsx("p",{className:"text-xs font-black text-gray-900",children:O.saveCount||0}),s.jsx("p",{className:"text-[8px] font-black text-gray-400 uppercase tracking-widest",children:"Saves"})]}),s.jsx("div",{className:"w-[1px] h-6 bg-gray-150"}),s.jsxs("div",{className:"text-center px-2",children:[s.jsx("p",{className:"text-xs font-black text-gray-900",children:O.shareCount||0}),s.jsx("p",{className:"text-[8px] font-black text-gray-400 uppercase tracking-widest",children:"Shares"})]})]})]}),O.summary&&s.jsxs("div",{className:"bg-yellow-50/45 border-l-4 border-accent p-4 rounded-r-2xl",children:[s.jsx("p",{className:"text-[9px] font-black text-accent uppercase tracking-widest mb-1",children:"Dispatch Summary"}),s.jsxs("p",{className:"text-xs font-bold text-gray-600 leading-relaxed italic",children:['"',O.summary,'"']})]}),s.jsxs("div",{className:"space-y-3 bg-white p-5 rounded-2xl border border-gray-100 shadow-xs",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Story Content Preview"}),s.jsx("button",{onClick:pt=>{pt.stopPropagation(),Ob(Ae?null:O.id)},className:"text-[10px] bg-gray-50 hover:bg-accent hover:text-white text-gray-600 font-black uppercase tracking-widest px-3 py-1.5 rounded-xl border border-gray-100 transition-all flex items-center gap-1",children:Ae?"View Less Text":"View Full Text (All)"})]}),s.jsxs("div",{className:Fe("markdown-body text-sm leading-relaxed text-gray-750 overflow-hidden transition-all duration-300 relative",Ae?"max-h-none":"max-h-24"),children:[s.jsx(Y1,{children:O.content||"*No written content in this article.*"}),!Ae&&O.content&&O.content.length>150&&s.jsx("div",{className:"absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-white to-transparent pointer-events-none"})]})]}),(O.featuredImageUrl1||O.featuredImageUrl2||O.video||O.Links)&&s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(O.featuredImageUrl1||O.featuredImageUrl2)&&s.jsxs("div",{className:"bg-white p-4 rounded-2xl border border-gray-100 space-y-2",children:[s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Gallery Media Uploads"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[O.featuredImageUrl1&&s.jsx("div",{className:"aspect-video rounded-xl overflow-hidden bg-gray-50 border border-gray-100",children:s.jsx("img",{src:O.featuredImageUrl1,alt:"",className:"w-full h-full object-cover"})}),O.featuredImageUrl2&&s.jsx("div",{className:"aspect-video rounded-xl overflow-hidden bg-gray-50 border border-gray-100",children:s.jsx("img",{src:O.featuredImageUrl2,alt:"",className:"w-full h-full object-cover"})})]})]}),(O.video||O.Links)&&s.jsxs("div",{className:"bg-white p-4 rounded-2xl border border-gray-100 space-y-2",children:[s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1 text-[#9c0dec]",children:"Attached Links & Video"}),s.jsxs("div",{className:"space-y-1.5 text-xs font-semibold text-gray-600",children:[O.video&&s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx(Ea,{size:12,className:"text-red-500"}),s.jsx("span",{className:"text-[10px] font-black text-gray-400 uppercase tracking-wider",children:"Video:"}),s.jsx("a",{href:O.video,target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent underline truncate",children:O.video})]}),O.Links&&s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx(Ad,{size:12,className:"text-blue-500"}),s.jsx("span",{className:"text-[10px] font-black text-gray-400 uppercase tracking-wider",children:"Resources:"}),s.jsx("a",{href:O.Links,target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent underline truncate",children:O.Links})]})]})]})]}),s.jsxs("div",{className:"pt-4 flex items-center justify-end gap-3 border-t border-gray-100",children:[s.jsxs("button",{onClick:pt=>{pt.stopPropagation(),Tr(O)},className:"flex items-center gap-2 px-5 py-2.5 bg-accent hover:bg-opacity-95 text-white rounded-xl font-black uppercase tracking-widest text-[10px] transition-all shadow-md shadow-accent/15 hover:-translate-y-0.5",children:[s.jsx(kd,{size:14})," Edit Mode"]}),s.jsxs("button",{onClick:pt=>{pt.stopPropagation(),Kl(O.id)},className:"flex items-center gap-2 px-5 py-2.5 bg-red-50 text-red-600 hover:bg-red-600 hover:text-white rounded-xl font-black uppercase tracking-widest text-[10px] transition-all",children:[s.jsx(As,{size:14})," Delete"]})]})]})]},O.id)})})]}):a==="advert"?s.jsxs("div",{className:"max-w-2xl mx-auto bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsxs("div",{className:"text-center mb-10",children:[s.jsx("h3",{className:"text-2xl font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Promote Your Brand"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-[0.3em] mt-2",children:"Reach thousands of campus citizens daily"})]}),s.jsxs("form",{onSubmit:Wm,className:"space-y-8",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Campaign Title"}),s.jsx("input",{type:"text",required:!0,value:po,onChange:O=>Fr(O.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold text-gray-900 focus:bg-white focus:ring-4 focus:ring-accent/10 focus:border-accent transition-all",placeholder:"e.g. Summer Festival 2024"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Advert Type"}),s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("button",{type:"button",onClick:()=>ge("image"),className:Fe("flex-1 py-4 rounded-2xl border text-[10px] font-black uppercase tracking-widest transition-all gap-2 flex items-center justify-center",Jr==="image"?"bg-accent text-white border-accent shadow-lg shadow-accent/20":"bg-gray-50 text-gray-400 border-gray-100 hover:bg-white"),children:[s.jsx(xu,{size:16})," Image"]}),s.jsxs("button",{type:"button",onClick:()=>ge("video"),className:Fe("flex-1 py-4 rounded-2xl border text-[10px] font-black uppercase tracking-widest transition-all gap-2 flex items-center justify-center",Jr==="video"?"bg-accent text-white border-accent shadow-lg shadow-accent/20":"bg-gray-50 text-gray-400 border-gray-100 hover:bg-white"),children:[s.jsx(Ea,{size:16})," Motion"]})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Duration"}),s.jsxs("select",{value:we,onChange:O=>Pe(O.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold text-gray-900 focus:bg-white focus:ring-4 focus:ring-accent/10 focus:border-accent transition-all appearance-none",children:[s.jsx("option",{value:"7",children:"7 Days (Standard)"}),s.jsx("option",{value:"14",children:"14 Days (Premium)"}),s.jsx("option",{value:"30",children:"30 Days (Professional)"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Target Link"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"url",required:!0,value:Ra,onChange:O=>Oo(O.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold text-gray-900 focus:bg-white focus:ring-4 focus:ring-accent/10 focus:border-accent transition-all pl-12",placeholder:"https://your-site.com"}),s.jsx(Ad,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400",size:18})]})]})]}),Jr==="image"?s.jsxs("div",{className:"space-y-4",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Advert Banner (Instant Uploaded)"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"md:col-span-2 relative group",children:[s.jsx("input",{type:"file",accept:"image/*",onChange:O=>{var Ae;const le=(Ae=O.target.files)==null?void 0:Ae[0];le&&(Ro(le),Ki(le,Gm,mx))},className:"hidden",id:"advert-image"}),s.jsx("label",{htmlFor:"advert-image",className:Fe("flex flex-col items-center justify-center aspect-[21/9] rounded-2xl border-2 border-dashed transition-all cursor-pointer bg-gray-50",du?"border-accent":"border-gray-100 hover:border-accent hover:bg-white"),children:Vb?s.jsxs("div",{className:"text-center p-4",children:[s.jsx(Er,{className:"mx-auto text-accent mb-2 animate-spin",size:32}),s.jsx("p",{className:"text-[10px] font-black text-accent uppercase tracking-widest leading-none",children:"Uploading image..."})]}):du?s.jsxs("div",{className:"w-full h-full relative rounded-2xl overflow-hidden group",children:[s.jsx("img",{src:du,className:"w-full h-full object-cover",alt:"Advert Campaign",referrerPolicy:"no-referrer"}),s.jsx("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-white",children:s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest",children:"Change Banner Image"})})]}):s.jsxs(s.Fragment,{children:[s.jsx(xu,{className:"text-gray-400 mb-2",size:32}),s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Select Image (21:9 Recommended)"})]})})]}),s.jsxs("div",{className:"bg-gray-50 border border-gray-100 p-4 rounded-2xl flex flex-col justify-center space-y-2",children:[s.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-gray-450 block",children:"Direct Banner Link"}),s.jsx("input",{type:"text",value:du,onChange:O=>Gm(O.target.value),placeholder:"Or paste banner image URL...",className:"w-full px-3 py-2 bg-white border border-gray-100 text-[10px] text-gray-700 font-mono rounded-lg outline-none focus:border-accent"}),s.jsx("p",{className:"text-[8px] text-gray-400 font-bold uppercase tracking-wider leading-tight",children:"Your campaigns will save and render this URL instantly across the platform."})]})]})]}):s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Video Link (Direct MP4/Link)"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"url",required:Jr==="video",value:at,onChange:O=>pr(O.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold text-gray-900 focus:bg-white focus:ring-4 focus:ring-accent/10 focus:border-accent transition-all pl-12",placeholder:"https://example.com/ad.mp4"}),s.jsx(Ea,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400",size:18})]}),s.jsx("p",{className:"px-4 text-[9px] font-bold text-gray-400 uppercase tracking-widest",children:"Ensure the link is a direct video file or an embeddable URL."})]}),s.jsx("div",{className:"p-6 bg-gray-50 rounded-2xl border border-gray-100",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(rF,{className:"text-accent flex-shrink-0",size:20}),s.jsx("p",{className:"text-[10px] font-bold text-gray-500 uppercase leading-relaxed",children:"Your advert will be reviewed by our team before going live. This usually takes less than 24 hours."})]})}),s.jsx("button",{type:"submit",disabled:Tt,className:"w-full py-5 bg-accent text-white rounded-2xl text-sm font-black uppercase tracking-[0.2em] hover:bg-accent-700 transition-all shadow-xl shadow-accent/20 disabled:opacity-50 flex items-center justify-center gap-3",children:Tt?s.jsxs(s.Fragment,{children:[s.jsx(Er,{className:"animate-spin",size:20}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Eo,{size:20}),"Submit for Review"]})})]})]}):a==="manage-ads"&&t?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Advert Management"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{className:"px-4 py-2 bg-accent text-white rounded-xl text-[10px] font-black uppercase tracking-widest shadow-lg shadow-accent/20",children:"Pending Review"}),s.jsx("button",{className:"px-4 py-2 bg-white border border-gray-100 rounded-xl text-[10px] font-black uppercase tracking-widest text-gray-500 hover:bg-gray-50 transition-all",children:"Active"})]})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:Vt.map(O=>s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-sm hover:shadow-md transition-all flex flex-col gap-4",children:[s.jsx("div",{className:"aspect-[21/9] rounded-2xl overflow-hidden bg-gray-100",children:s.jsx("img",{src:O.imageUrl||void 0,alt:"",className:"w-full h-full object-cover"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:Fe("px-2 py-0.5 text-[9px] font-black uppercase tracking-widest rounded",O.status==="active"?"bg-green-50 text-green-600":"bg-blue-50 text-accent"),children:O.status}),s.jsxs("span",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:[O.durationDays," Days"]})]}),s.jsx("h4",{className:"text-lg font-black text-gray-900 uppercase tracking-tight truncate",children:O.title}),s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest truncate mt-1",children:O.link})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-4 border-t border-gray-50",children:[s.jsx("button",{onClick:()=>xh(O.id,O.status),className:Fe("flex-1 py-3 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all",O.status==="active"?"bg-gray-100 text-gray-900 hover:bg-gray-200":"bg-green-600 text-white hover:bg-green-700"),children:O.status==="active"?"Deactivate":"Approve & Activate"}),s.jsx("button",{onClick:()=>Yl(O.id),className:"p-3 bg-blue-50 text-black rounded-xl hover:bg-black hover:text-white transition-all",children:s.jsx(As,{size:18})})]})]},O.id))})]}):a==="flagged-comments"&&t?s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-4",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(ku,{className:"text-rose-500",size:22})," Flagged Content Moderation Hub"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Review and moderate flagged comments and lounge dispatches"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs("span",{className:"px-3 py-1 bg-rose-50 text-rose-600 border border-rose-100 rounded-full text-[10px] font-black uppercase tracking-widest",children:[B.length+Nr.length," Total Flagged"]})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("h4",{className:"text-sm font-black text-gray-900 uppercase tracking-wider flex items-center gap-2",children:[s.jsx(bi,{size:16,className:"text-accent"})," Flagged Comments (",B.length,")"]}),B.length===0?s.jsx("div",{className:"bg-white p-8 rounded-2xl border border-gray-100 text-center text-xs text-gray-400 font-bold uppercase tracking-wider",children:"No flagged comments awaiting moderation"}):s.jsx("div",{className:"grid grid-cols-1 gap-4",children:B.map(O=>s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-sm hover:shadow-md transition-all",children:[s.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[s.jsx("img",{src:O.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(O.authorName)}&background=random`,alt:"",className:"w-10 h-10 rounded-xl object-cover"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("h4",{className:"font-black text-gray-900 uppercase tracking-tight",children:O.authorName}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:O.createdAt instanceof _r?O.createdAt.toDate().toLocaleString():"Recently"})]}),s.jsxs("p",{className:"text-sm text-gray-600 font-medium bg-gray-50 p-4 rounded-2xl border border-gray-100 italic",children:['"',O.content,'"']})]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-50",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(bi,{size:14,className:"text-gray-400"}),s.jsxs("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:["On: ",s.jsx("span",{className:"text-accent",children:O.articleTitle||"Article Comment"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>O.articleId&&Dm(O.articleId,O.id),className:"px-3 py-2 bg-emerald-50 hover:bg-emerald-500 text-emerald-600 hover:text-white rounded-xl transition-all text-xs font-bold uppercase tracking-wider flex items-center gap-1 cursor-pointer",title:"Dismiss Flag",children:[s.jsx(Bu,{size:14})," Dismiss Flag"]}),s.jsxs("button",{onClick:()=>O.articleId&&uh(O.articleId,O.id),className:"px-3 py-2 bg-red-50 hover:bg-red-600 text-red-600 hover:text-white rounded-xl transition-all text-xs font-bold uppercase tracking-wider flex items-center gap-1 cursor-pointer",title:"Delete Comment",children:[s.jsx(As,{size:14})," Delete"]})]})]})]},O.id))})]}),s.jsxs("div",{className:"space-y-4 pt-6 border-t border-gray-100",children:[s.jsxs("h4",{className:"text-sm font-black text-gray-900 uppercase tracking-wider flex items-center gap-2",children:[s.jsx(D0,{size:16,className:"text-purple-600"})," Flagged Lounge Dispatches (",Nr.length,")"]}),Nr.length===0?s.jsx("div",{className:"bg-white p-8 rounded-2xl border border-gray-100 text-center text-xs text-gray-400 font-bold uppercase tracking-wider",children:"No flagged posts awaiting moderation"}):s.jsx("div",{className:"grid grid-cols-1 gap-4",children:Nr.map(O=>s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-sm hover:shadow-md transition-all",children:[s.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[s.jsx("img",{src:O.authorPhoto||O.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(O.authorName||"Student")}&background=random`,alt:"",className:"w-10 h-10 rounded-xl object-cover"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("h4",{className:"font-black text-gray-900 uppercase tracking-tight",children:O.authorName||"Anonymous Student"}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:O.createdAt instanceof _r?O.createdAt.toDate().toLocaleString():"Recently"})]}),s.jsx("p",{className:"text-sm text-gray-800 font-medium bg-gray-50 p-4 rounded-2xl border border-gray-100 whitespace-pre-wrap",children:O.content}),O.imageUrl&&s.jsx("img",{src:O.imageUrl,alt:"",className:"mt-3 rounded-2xl max-h-48 object-cover border border-gray-100"})]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-50",children:[s.jsx("span",{className:"text-[10px] font-black text-rose-500 uppercase tracking-widest",children:"Reported Content"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>Lf(O.id),className:"px-3 py-2 bg-emerald-50 hover:bg-emerald-500 text-emerald-600 hover:text-white rounded-xl transition-all text-xs font-bold uppercase tracking-wider flex items-center gap-1 cursor-pointer",children:[s.jsx(Bu,{size:14})," Dismiss Flag"]}),s.jsxs("button",{onClick:()=>rl(O.id),className:"px-3 py-2 bg-red-50 hover:bg-red-600 text-red-600 hover:text-white rounded-xl transition-all text-xs font-bold uppercase tracking-wider flex items-center gap-1 cursor-pointer",children:[s.jsx(As,{size:14})," Delete Post"]})]})]})]},O.id))})]})]}):a==="imgbb-settings"&&t?s.jsxs("div",{className:"space-y-8 max-w-4xl",children:[s.jsx("div",{className:"border-b border-gray-100 pb-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-3 bg-blue-50 text-blue-600 rounded-2xl border border-blue-100",children:s.jsx(Pre,{size:24})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:"ImgBB API Key Settings"}),s.jsxs("p",{className:"text-xs text-gray-500 font-medium",children:["Admin Access (",s.jsx("span",{className:"text-accent font-bold",children:"Image Hosting Credentials"}),")"]})]})]})}),s.jsxs("div",{className:"bg-gradient-to-r from-gray-900 to-black text-white p-6 rounded-3xl border border-gray-800 shadow-xl space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-widest text-emerald-400 flex items-center gap-1.5",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 inline-block"})," Active ImgBB API Key"]}),s.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(kt),pe.success("ImgBB API key copied to clipboard!")},className:"px-3 py-1 bg-white/10 hover:bg-white/20 text-white rounded-xl text-[10px] font-black uppercase tracking-widest flex items-center gap-1 transition-all",children:[s.jsx(n2,{size:12})," Copy Key"]})]}),s.jsx("div",{className:"font-mono text-sm md:text-base font-bold bg-white/5 p-4 rounded-2xl border border-white/10 break-all text-emerald-300",children:kt})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-sm space-y-4",children:[s.jsxs("h4",{className:"text-sm font-black text-gray-900 uppercase tracking-wider flex items-center gap-2",children:[s.jsx(Lc,{size:16,className:"text-accent"})," Add & Activate New ImgBB API Key"]}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsx("input",{type:"text",value:uo,onChange:O=>hr(O.target.value),placeholder:"Paste new ImgBB API key here (e.g. 857eaaf2b7571ee437db8ee3f6ee8670)...",className:"flex-1 bg-gray-50 border border-gray-200 rounded-2xl px-4 py-3 text-xs font-mono text-gray-900 outline-none focus:border-accent"}),s.jsx("button",{onClick:async()=>{var Ae;if(!uo.trim()){pe.error("Please enter an API key");return}const O=uo.trim(),le=Array.from(new Set([O,...wr]));is(le),Pa(O),localStorage.setItem("campus_eye_imgbb_active_key",O);try{await Rr(Je(he,"settings","imgbb"),{activeKey:O,savedKeys:le,updatedAt:En(),updatedBy:(Ae=Ne.currentUser)==null?void 0:Ae.email},{merge:!0})}catch(pt){console.error("Firestore update error:",pt)}hr(""),pe.success("New ImgBB API key saved & activated!")},className:"px-6 py-3 bg-accent text-white rounded-2xl text-xs font-black uppercase tracking-widest hover:bg-accent/90 transition-all shrink-0 cursor-pointer",children:"Save & Activate Key"})]})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-sm space-y-4",children:[s.jsxs("h4",{className:"text-sm font-black text-gray-900 uppercase tracking-wider",children:["Saved API Keys Pool (",wr.length,")"]}),s.jsx("div",{className:"space-y-3",children:wr.map((O,le)=>{const Ae=O===kt;return s.jsxs("div",{className:Fe("p-4 rounded-2xl border flex items-center justify-between gap-4 transition-all",Ae?"bg-emerald-50/50 border-emerald-200":"bg-gray-50 border-gray-100"),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("input",{type:"radio",name:"active_imgbb_key",checked:Ae,onChange:()=>{var pt;Pa(O),localStorage.setItem("campus_eye_imgbb_active_key",O),Rr(Je(he,"settings","imgbb"),{activeKey:O,savedKeys:wr,updatedAt:En(),updatedBy:(pt=Ne.currentUser)==null?void 0:pt.email},{merge:!0}),pe.success("Switched active ImgBB key!")},className:"w-4 h-4 text-accent cursor-pointer"}),s.jsx("span",{className:"font-mono text-xs font-bold text-gray-800 truncate",children:O}),Ae&&s.jsx("span",{className:"px-2 py-0.5 bg-emerald-500 text-white text-[9px] font-black uppercase tracking-widest rounded-full shrink-0",children:"Active"})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!Ae&&s.jsx("button",{onClick:()=>{var pt;Pa(O),localStorage.setItem("campus_eye_imgbb_active_key",O),Rr(Je(he,"settings","imgbb"),{activeKey:O,savedKeys:wr,updatedAt:En(),updatedBy:(pt=Ne.currentUser)==null?void 0:pt.email},{merge:!0}),pe.success("Switched active ImgBB key!")},className:"px-3 py-1.5 bg-white border border-gray-200 text-gray-700 hover:bg-gray-100 rounded-xl text-[10px] font-bold uppercase tracking-wider transition-all",children:"Switch to this"}),s.jsx("button",{onClick:async()=>{var Jn;const pt=wr.filter(ar=>ar!==O);is(pt);let Ht=kt;kt===O&&(Ht=pt[0]||"857eaaf2b7571ee437db8ee3f6ee8670",Pa(Ht),localStorage.setItem("campus_eye_imgbb_active_key",Ht));try{await Rr(Je(he,"settings","imgbb"),{activeKey:Ht,savedKeys:pt,updatedAt:En(),updatedBy:(Jn=Ne.currentUser)==null?void 0:Jn.email},{merge:!0})}catch(ar){console.error(ar)}pe.success("Removed ImgBB key")},className:"p-1.5 text-gray-400 hover:text-red-600 rounded-lg hover:bg-red-50 transition-all",title:"Remove Key",children:s.jsx(As,{size:16})})]})]},le)})})]}),s.jsxs("div",{className:"bg-white p-6 sm:p-8 rounded-3xl border border-gray-100 shadow-sm space-y-6 text-left",children:[s.jsx("div",{className:"flex items-center justify-between border-b border-gray-100 pb-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-3 bg-red-50 text-red-600 rounded-2xl border border-red-100",children:s.jsx(_re,{size:22})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-base font-black text-gray-900 uppercase tracking-tight",children:"Database Expansion Slots (Multi-Database System)"}),s.jsxs("p",{className:"text-[11px] text-gray-500 font-medium",children:["Add extra Firebase Databases (",s.jsx("span",{className:"text-red-650 font-bold",children:"Db 1, Db 2, Db 3..."}),"). All databases display together on the site simultaneously!"]})]})]})}),s.jsxs("div",{className:"p-5 bg-gradient-to-r from-gray-900 to-black text-white rounded-2xl border border-gray-800 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-widest text-amber-400 flex items-center gap-2",children:[s.jsx(Fx,{size:14})," Active Target Write Database Slot"]}),s.jsx("span",{className:"text-[9px] font-mono text-emerald-400 font-bold uppercase bg-emerald-950/80 px-2.5 py-1 rounded-md border border-emerald-800",children:"LIVE WRITE ACTIVE"})]}),s.jsx("div",{className:"flex flex-col sm:flex-row items-center gap-3",children:s.jsxs("select",{value:y,onChange:O=>{const le=O.target.value;w(le),ML(le),pe.success(`Active write target switched to ${le==="default"?"Default Primary DB":le.toUpperCase()}!`)},className:"w-full bg-white/10 text-white font-mono text-xs font-bold p-3 rounded-xl border border-white/20 outline-none cursor-pointer focus:border-amber-400",children:[s.jsx("option",{value:"default",className:"bg-gray-900 text-white",children:"Default Primary Firebase DB (Main System)"}),f.map(O=>s.jsxs("option",{value:O.id,className:"bg-gray-900 text-white",children:[O.name," (",O.projectId||"Custom Config",")"]},O.id))]})}),s.jsxs("p",{className:"text-[10px] text-gray-300 font-sans leading-relaxed",children:["New articles, comments, and uploaded media will be saved directly into the selected active slot. Readers will always see articles from ",s.jsx("b",{children:"ALL"})," databases aggregated automatically!"]})]}),s.jsxs("div",{className:"space-y-4 pt-2",children:[s.jsxs("h5",{className:"text-xs font-black uppercase tracking-wider text-gray-800 flex items-center gap-2",children:[s.jsx(Lc,{size:14,className:"text-red-600"})," Add New Expansion Database Slot"]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-3",children:[s.jsx("div",{className:"md:col-span-4",children:s.jsx("input",{type:"text",value:C,onChange:O=>T(O.target.value),placeholder:"Slot Name e.g. Db 1, Db 2...",className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-4 py-3 text-xs font-bold text-gray-900 outline-none focus:border-red-600"})}),s.jsx("div",{className:"md:col-span-8",children:s.jsx("textarea",{value:D,onChange:O=>V(O.target.value),placeholder:'Paste Firebase JSON Config snippet here (e.g. {"apiKey": "...", "projectId": "...", "authDomain": "..."})',className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-4 py-3 text-xs font-mono text-gray-900 outline-none focus:border-red-600 min-h-[70px]"})})]}),s.jsx("button",{onClick:()=>{if(!C.trim()){pe.error("Please enter a slot name e.g. Db 1");return}if(!D.trim()){pe.error("Please paste the Firebase configuration JSON");return}try{const O=q2e(D),Ae={id:`db_${Date.now()}`,name:C.trim(),apiKey:O.apiKey||"",authDomain:O.authDomain||"",projectId:O.projectId||"",storageBucket:O.storageBucket||"",messagingSenderId:O.messagingSenderId||"",appId:O.appId||"",firestoreDatabaseId:O.firestoreDatabaseId||"(default)",customConfigJson:D.trim()},pt=[...f,Ae];m(pt),DL(pt),T(""),V(""),pe.success(`Expansion slot "${Ae.name}" added successfully!`)}catch(O){pe.error("Could not parse Firebase Config: "+O.message)}},className:"px-6 py-3 bg-red-650 text-white rounded-xl text-xs font-black uppercase tracking-wider hover:bg-black transition-all cursor-pointer shadow-sm",children:"Save Expansion Database Slot"})]}),f.length>0&&s.jsxs("div",{className:"space-y-3 pt-3 border-t border-gray-100",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-400 block",children:["Registered Expansion Slots (",f.length,")"]}),f.map(O=>s.jsxs("div",{className:"p-4 bg-gray-50 border border-gray-200 rounded-2xl flex items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-black text-xs text-gray-900 uppercase tracking-wide block",children:O.name}),s.jsx("span",{className:"text-[10px] font-mono text-gray-500",children:O.projectId?`Project ID: ${O.projectId}`:"Custom Config"})]}),s.jsx("button",{onClick:()=>{const le=f.filter(Ae=>Ae.id!==O.id);m(le),DL(le),y===O.id&&(w("default"),ML("default")),pe.success(`Removed ${O.name}`)},className:"p-2 text-gray-400 hover:text-red-600 rounded-lg hover:bg-red-50 transition-all cursor-pointer",title:"Delete Slot",children:s.jsx(As,{size:16})})]},O.id))]})]}),s.jsxs("div",{className:"bg-white p-6 sm:p-8 rounded-3xl border border-gray-100 shadow-sm space-y-4 text-left",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-100 pb-4",children:[s.jsx("div",{className:"p-3 bg-indigo-50 text-indigo-600 rounded-2xl border border-indigo-100",children:s.jsx(S0,{size:22})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-base font-black text-gray-900 uppercase tracking-tight",children:"Google Redirect & Custom Authorization Domain"}),s.jsxs("p",{className:"text-[11px] text-gray-500 font-medium",children:["Configure your official domain link for Google Authentication redirects (e.g. ",s.jsx("span",{className:"text-indigo-600 font-bold",children:"campuseyemedia.com"}),")."]})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-xs font-black uppercase tracking-wider text-gray-700 block",children:"Website Authorized Auth Domain"}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsx("input",{type:"text",value:A,onChange:O=>S(O.target.value),placeholder:"e.g. campuseyemedia.com or custom domain...",className:"flex-1 bg-gray-50 border border-gray-200 rounded-xl px-4 py-3 text-xs font-mono text-gray-900 outline-none focus:border-indigo-600"}),s.jsx("button",{onClick:()=>{G2e(A),pe.success("Saved Custom Auth Domain!")},className:"px-6 py-3 bg-indigo-600 text-white rounded-xl text-xs font-black uppercase tracking-wider hover:bg-indigo-700 transition-all cursor-pointer shrink-0",children:"Save Auth Domain"})]})]})]}),s.jsxs("div",{className:"bg-white p-6 sm:p-8 rounded-3xl border border-gray-100 shadow-sm space-y-4 text-left",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-100 pb-4",children:[s.jsx("div",{className:"p-3 bg-emerald-50 text-emerald-600 rounded-2xl border border-emerald-100",children:s.jsx(Zi,{size:22})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-base font-black text-gray-900 uppercase tracking-tight",children:"Permanent SEO Sitemap (sitemap.xml) Generator"}),s.jsx("p",{className:"text-[11px] text-gray-500 font-medium",children:"Auto-generates compliant XML sitemaps for all published articles with titles, summaries, and images for Google Search indexing."})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.jsxs("button",{onClick:()=>{const O=W2e(c);K(O),pe.success(`Generated sitemap.xml for ${c.length} articles!`)},className:"px-6 py-3 bg-emerald-600 text-white rounded-xl text-xs font-black uppercase tracking-wider hover:bg-emerald-700 transition-all cursor-pointer flex items-center gap-2",children:[s.jsx(Zi,{size:14})," Generate Sitemap XML"]}),L&&s.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(L),pe.success("Sitemap XML copied to clipboard!")},className:"px-6 py-3 bg-gray-900 text-white rounded-xl text-xs font-black uppercase tracking-wider hover:bg-black transition-all cursor-pointer flex items-center gap-2",children:[s.jsx(n2,{size:14})," Copy XML Code"]})]}),L&&s.jsx("div",{className:"pt-2",children:s.jsx("textarea",{readOnly:!0,value:L,rows:8,className:"w-full bg-gray-950 text-emerald-400 font-mono text-[10px] p-4 rounded-2xl border border-gray-800 outline-none select-all"})})]})]})]}):a==="broadcast"&&t?s.jsxs("div",{className:"space-y-8 max-w-4xl font-sans text-left",children:[s.jsxs("div",{className:"border-b border-gray-100 pb-4",children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(vu,{className:"text-amber-500",size:24})," Official Admin Broadcast Center"]}),s.jsx("p",{className:"text-[11px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Dispatch instant broadcast notifications directly to every user's inbox on the website and mobile app."})]}),s.jsx("div",{className:"bg-white p-6 sm:p-8 rounded-3xl border border-gray-100 shadow-sm space-y-6",children:s.jsxs("form",{onSubmit:Mr,className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-600 mb-1.5",children:"Broadcast Title / Headline *"}),s.jsx("input",{type:"text",required:!0,value:Mt,onChange:O=>cn(O.target.value),placeholder:"e.g., 📢 Urgent Campus Update: End of Semester Timetable Released!",className:"w-full p-3.5 bg-gray-50 border border-gray-200 rounded-2xl text-sm font-bold text-gray-900 outline-none focus:border-amber-500 focus:bg-white transition-all"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-600 mb-1.5",children:"Broadcast Message Content *"}),s.jsx("textarea",{rows:4,required:!0,value:dn,onChange:O=>mr(O.target.value),placeholder:"Type the full announcement details here. You can include text, or paste URLs directly...",className:"w-full p-4 bg-gray-50 border border-gray-200 rounded-2xl text-xs font-medium text-gray-900 outline-none focus:border-amber-500 focus:bg-white transition-all leading-relaxed"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-700",children:"Broadcast Image / Banner (Optional)"}),gr&&s.jsxs("button",{type:"button",onClick:()=>wi(""),className:"text-[10px] font-bold text-red-600 hover:text-red-700 flex items-center gap-1 cursor-pointer transition-colors",children:[s.jsx(er,{size:12})," Remove Image"]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"file",accept:"image/*",id:"broadcast-device-image-input",disabled:Xt,onChange:O=>{var Ae;const le=(Ae=O.target.files)==null?void 0:Ae[0];le&&Ki(le,wi,me)},className:"hidden"}),s.jsx("label",{htmlFor:"broadcast-device-image-input",className:Fe("flex flex-col items-center justify-center p-4 rounded-2xl border-2 border-dashed transition-all cursor-pointer bg-gray-50 min-h-[140px] text-center",gr?"border-amber-500 bg-amber-50/20":"border-gray-200 hover:border-amber-500 hover:bg-amber-50/30"),children:Xt?s.jsxs("div",{className:"flex flex-col items-center justify-center p-2",children:[s.jsx(Er,{className:"animate-spin text-amber-600 mb-2",size:28}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-amber-700",children:"Uploading Image from Device..."}),s.jsx("span",{className:"text-[9px] text-gray-400 mt-1",children:"Compressing & optimizing for fast delivery"})]}):gr?s.jsxs("div",{className:"w-full relative group",children:[s.jsxs("div",{className:"h-28 w-full rounded-xl overflow-hidden bg-black/5 border border-amber-200/80 shadow-2xs relative",children:[s.jsx("img",{src:gr,alt:"Broadcast Preview",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-white gap-1.5",children:[s.jsx(xu,{size:16}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-wider",children:"Change Device Image"})]})]}),s.jsx("p",{className:"text-[9px] font-mono text-gray-400 truncate mt-1.5 px-1",children:gr})]}):s.jsxs("div",{className:"flex flex-col items-center justify-center py-2 text-gray-500 group-hover:text-amber-600 transition-colors",children:[s.jsx("div",{className:"p-2.5 bg-white rounded-2xl border border-gray-200 shadow-2xs mb-2 text-amber-600",children:s.jsx(xu,{size:22})}),s.jsx("span",{className:"text-xs font-black uppercase tracking-wide text-gray-800",children:"Upload Image from Device"}),s.jsx("span",{className:"text-[9.5px] font-medium text-gray-400 mt-0.5",children:"Click or tap to browse gallery / camera (Auto-compressed)"})]})})]}),s.jsxs("div",{className:"space-y-3 flex flex-col justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-600 mb-1.5",children:"Or Paste Direct Image Link (Optional)"}),s.jsx("input",{type:"url",value:gr,onChange:O=>wi(O.target.value),placeholder:"https://... (PNG / JPG / WebP link)",className:"w-full p-3 bg-gray-50 border border-gray-200 rounded-2xl text-xs font-mono text-gray-900 outline-none focus:border-amber-500 focus:bg-white transition-all"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-600 mb-1.5",children:"Action Target Link (Optional)"}),s.jsx("input",{type:"text",value:qe,onChange:O=>st(O.target.value),placeholder:"e.g. /article/123 or https://...",className:"w-full p-3 bg-gray-50 border border-gray-200 rounded-2xl text-xs font-mono text-gray-900 outline-none focus:border-amber-500 focus:bg-white transition-all"})]})]})]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-amber-600 bg-amber-50 px-3 py-1.5 rounded-xl border border-amber-200/50",children:[s.jsx(Zi,{size:14})," Reaches all citizens instantly in real-time"]}),s.jsxs("button",{type:"submit",disabled:dt||!Mt.trim()||!dn.trim(),className:"flex items-center gap-2 px-6 py-3 bg-amber-500 hover:bg-amber-600 disabled:opacity-40 text-white text-xs font-black uppercase tracking-widest rounded-2xl transition-all shadow-md cursor-pointer active:scale-95",children:[s.jsx(Eo,{size:14})," Dispatch Broadcast to All Inboxes"]})]})]})}),s.jsxs("div",{className:"bg-white p-6 sm:p-8 rounded-3xl border border-gray-100 shadow-sm space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 pb-4 border-b border-gray-100",children:[s.jsxs("div",{children:[s.jsxs("h4",{className:"text-base font-black text-gray-950 uppercase tracking-tight flex items-center gap-2",children:[s.jsx(uc,{className:"text-amber-500 animate-pulse",size:20}),s.jsxs("span",{children:["Sent Broadcast History (",Ft.length,")"]})]}),s.jsx("p",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-widest mt-0.5",children:"Review, manage and delete past broadcast notifications delivered to user inboxes"})]}),Ft.length>0&&s.jsxs("button",{onClick:On,className:"flex items-center gap-1.5 px-4 py-2 bg-red-50 hover:bg-red-100 text-red-600 text-[10px] font-black uppercase tracking-wider rounded-xl transition-all border border-red-200 cursor-pointer self-start sm:self-auto",children:[s.jsx(As,{size:13}),s.jsx("span",{children:"Delete All Broadcasts"})]})]}),Ft.length>3&&s.jsxs("div",{className:"relative",children:[s.jsx(Rp,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-400",size:14}),s.jsx("input",{type:"text",value:jr,onChange:O=>lr(O.target.value),placeholder:"Search sent broadcasts by title or keyword...",className:"w-full pl-9 pr-4 py-2.5 bg-gray-50 border border-gray-200 rounded-xl text-xs text-gray-800 outline-none focus:border-amber-500 focus:bg-white transition-all"})]}),Ot?s.jsxs("div",{className:"py-12 flex flex-col items-center justify-center text-gray-400 gap-2",children:[s.jsx(Er,{className:"animate-spin text-amber-500",size:24}),s.jsx("p",{className:"text-xs font-bold uppercase tracking-widest",children:"Loading broadcast history..."})]}):Ft.length===0?s.jsxs("div",{className:"p-10 border rounded-2xl text-center bg-gray-50/50 border-dashed border-gray-200 text-gray-400 select-none",children:[s.jsx(vu,{className:"mx-auto mb-2 text-gray-300",size:32}),s.jsx("p",{className:"text-xs font-bold uppercase tracking-wider text-gray-500",children:"No sent broadcast messages found."}),s.jsx("p",{className:"text-[10px] uppercase tracking-widest mt-1 text-gray-400",children:"Use the form above to dispatch your first official announcement."})]}):s.jsx("div",{className:"space-y-4",children:Ft.filter(O=>{if(!jr.trim())return!0;const le=jr.toLowerCase();return(O.title||"").toLowerCase().includes(le)||(O.message||"").toLowerCase().includes(le)}).map(O=>{var Ae;const le=O.timestamp?new Date(O.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):(Ae=O.createdAt)!=null&&Ae.toDate?O.createdAt.toDate().toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):"Recently dispatched";return s.jsxs("div",{className:"p-4 sm:p-5 bg-gray-50/70 hover:bg-white border border-gray-200 rounded-2xl transition-all shadow-2xs hover:shadow-sm space-y-3 relative group",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:"w-9 h-9 rounded-xl bg-amber-50 text-amber-600 border border-amber-200/60 flex items-center justify-center shrink-0 mt-0.5",children:s.jsx(vu,{size:18})}),s.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h5",{className:"text-sm font-black text-gray-950 tracking-tight leading-snug",children:O.title}),s.jsxs("span",{className:"text-[9px] font-mono font-bold text-gray-400 bg-white px-2 py-0.5 rounded-md border border-gray-200 flex items-center gap-1",children:[s.jsx(J5,{size:10})," ",le]})]}),s.jsx("p",{className:"text-xs text-gray-600 mt-1 leading-relaxed whitespace-pre-wrap",children:O.message})]})]}),s.jsx("button",{onClick:()=>Ut(O.id),title:"Delete this broadcast",className:"p-2 bg-white hover:bg-red-50 text-gray-400 hover:text-red-600 rounded-xl border border-gray-200 hover:border-red-200 transition-all cursor-pointer shrink-0 shadow-2xs active:scale-95",children:s.jsx(As,{size:16})})]}),(O.imageUrl||O.link)&&s.jsxs("div",{className:"pt-2 border-t border-gray-200/60 flex flex-wrap items-center gap-3",children:[O.imageUrl&&s.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-gray-500 font-mono bg-white px-2.5 py-1 rounded-lg border border-gray-200 max-w-xs truncate",children:[s.jsx(xu,{size:12,className:"text-amber-500 shrink-0"}),s.jsx("span",{className:"truncate",children:O.imageUrl})]}),O.link&&s.jsxs("a",{href:O.link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-[10px] font-bold text-indigo-600 bg-indigo-50 hover:bg-indigo-100 px-2.5 py-1 rounded-lg border border-indigo-200 transition-all",children:[s.jsx(Ad,{size:12}),s.jsx("span",{className:"truncate max-w-[200px]",children:O.link})]})]})]},O.id)})})]})]}):a==="users"&&t?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"bg-blue-50/40 border border-blue-100/50 p-5 rounded-3xl flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-blue-50 text-accent rounded-2xl border border-blue-100",children:s.jsx(Fx,{size:20})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-black text-blue-900 uppercase tracking-widest",children:"Citizen Data Saver Mode Active"}),s.jsxs("p",{className:"text-[11px] text-blue-700/80 mt-0.5",children:["To optimize loading times and reduce your data usage by ",s.jsx("strong",{children:"99.9%"}),", deep engagement profiles are calculated on-demand. Click ",s.jsx("strong",{children:"Analyze Profile"})," on any citizen below."]})]})]}),Object.keys(qn).length>0&&s.jsx("button",{onClick:()=>{mn({}),hn({})},className:"px-4 py-2 bg-white hover:bg-gray-50 border border-gray-100 rounded-xl text-[9px] font-black uppercase tracking-widest transition-all text-gray-600 shadow-sm cursor-pointer",children:"Clear Analytics Cache"})]}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-blue-50 text-accent rounded-xl",children:s.jsx(_o,{size:20})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] text-gray-400 uppercase font-black tracking-widest",children:"Total Citizens"}),s.jsx("h4",{className:"text-xl font-extrabold text-gray-900",children:Z.length})]})]}),s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-emerald-50 text-emerald-600 rounded-xl",children:s.jsx(lc,{size:20})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] text-gray-400 uppercase font-black tracking-widest",children:"Active Contributors"}),s.jsx("h4",{className:"text-xl font-extrabold text-gray-900",children:Object.values(qn).filter(O=>(O.engagementScore||0)>=15).length})]})]}),s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-amber-50 text-amber-600 rounded-xl",children:s.jsx(Nu,{size:20})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] text-gray-400 uppercase font-black tracking-widest",children:"Avg Engagement Score"}),s.jsxs("h4",{className:"text-xl font-extrabold text-gray-900",children:[Object.values(qn).length?Math.round(Object.values(qn).reduce((O,le)=>O+(le.engagementScore||0),0)/Object.values(qn).length):0," pts"]})]})]}),s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-purple-50 text-purple-600 rounded-xl",children:s.jsx(wp,{size:20})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] text-gray-400 uppercase font-black tracking-widest",children:"Analyzed Citizens"}),s.jsxs("h4",{className:"text-xl font-extrabold text-gray-900",children:[Object.keys(qn).length," / ",Z.length]})]})]})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"User Engagement Directory"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Real-time citizen contributions, purchases, and influence scores."})]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",value:ut,onChange:O=>Jt(O.target.value),placeholder:"Search citizens...",className:"px-6 py-3 bg-white border border-gray-100 rounded-xl text-[10px] font-black uppercase tracking-widest outline-none focus:ring-4 focus:ring-accent/10 focus:border-accent transition-all w-64"}),s.jsx(Rp,{size:14,className:"absolute right-4 top-1/2 -translate-y-1/2 text-gray-400"})]})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Z.filter(O=>{const le=ut.toLowerCase();return(O.displayName||"").toLowerCase().includes(le)||(O.email||"").toLowerCase().includes(le)}).map(O=>{const le=qn[O.id],Ae=vr[O.id],pt=Dt[O.id];return s.jsxs("div",{className:"bg-white p-6 rounded-[2rem] border border-gray-100 shadow-sm hover:shadow-md transition-all flex flex-col justify-between group",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-5",children:[s.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[s.jsxs("div",{className:"relative",children:[s.jsx("img",{src:O.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(O.displayName||"User")}&background=random`,alt:"",className:"w-14 h-14 rounded-2xl object-cover border-2 border-gray-50 shadow-sm"}),(O.isAdmin||O.role==="admin")&&s.jsx("div",{className:"absolute -top-1.5 -right-1.5 bg-black text-white p-1 rounded-lg shadow-md",children:s.jsx(pl,{size:11})})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h4",{className:"font-extrabold text-sm text-gray-900 truncate uppercase tracking-tight",children:O.displayName||"Anonymous"}),s.jsx("p",{className:"text-[9px] text-gray-400 uppercase font-bold tracking-widest truncate",children:O.email})]})]}),s.jsx("span",{className:Fe("px-2.5 py-1 rounded-lg text-[9px] font-black uppercase tracking-wider border",(le==null?void 0:le.tierColor)||"bg-gray-50 text-gray-500 border-gray-100"),children:(le==null?void 0:le.tier)||"New Citizen"})]}),le?s.jsxs("div",{className:"space-y-4",children:[s.jsx(Oee,{stats:{userId:O.id,userName:O.displayName||"Citizen",userEmail:O.email||"",userPhoto:O.photoURL,engagementScore:le.engagementScore||0,articlesCount:le.articlesCount||0,postsCount:le.postsCount||0,purchasesCount:le.purchasesCount||0,totalSpent:le.totalSpent||0,followersCount:le.followersCount||0,followingCount:le.followingCount||0,tier:le.engagementScore>80?"Titan Publisher":le.engagementScore>30?"Senior Reporter":"Campus Citizen"}}),le.recentArticles&&le.recentArticles.length>0||le.recentPosts&&le.recentPosts.length>0?s.jsxs("div",{className:"mb-5 border-t border-dashed border-gray-100 pt-4",children:[s.jsxs("button",{type:"button",onClick:()=>hn(Ht=>({...Ht,[O.id]:!pt})),className:"flex items-center justify-between w-full text-[9px] font-black uppercase tracking-widest text-gray-500 hover:text-accent transition-all cursor-pointer",children:[s.jsx("span",{children:"Recent Citizen Action"}),pt?s.jsx(df,{size:12}):s.jsx(Bd,{size:12})]}),pt&&s.jsxs("div",{className:"mt-3 space-y-2 bg-gray-50/30 p-3 rounded-xl border border-gray-100/50 animate-fadeIn",children:[le.recentArticles&&le.recentArticles.length>0&&s.jsxs("div",{children:[s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400 block mb-1",children:"Articles"}),s.jsx("ul",{className:"space-y-1",children:le.recentArticles.map(Ht=>s.jsxs("li",{className:"text-[10px] text-gray-700 font-medium truncate",children:["• ",Ht.title]},Ht.id))})]}),le.recentPosts&&le.recentPosts.length>0&&s.jsxs("div",{className:Fe(le.recentArticles&&le.recentArticles.length>0?"mt-2 pt-2 border-t border-gray-100":""),children:[s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400 block mb-1",children:"Lounge Posts"}),s.jsx("ul",{className:"space-y-1",children:le.recentPosts.map(Ht=>s.jsxs("li",{className:"text-[10px] text-gray-600 font-medium truncate italic",children:['"',Ht.content,'"']},Ht.id))})]})]})]}):s.jsx("div",{className:"mb-5 border-t border-dashed border-gray-100 pt-4 text-center",children:s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400",children:"No active content recorded"})})]}):s.jsx("div",{className:"mb-5 py-4",children:s.jsx("button",{onClick:()=>ji(O.id),disabled:Ae,className:"w-full py-5 bg-gray-50/50 hover:bg-gray-50 hover:border-accent active:bg-gray-100/80 border border-dashed border-gray-200 rounded-2xl flex flex-col items-center justify-center gap-2 transition-all cursor-pointer group/btn",children:Ae?s.jsx(Er,{size:16,className:"animate-spin text-accent"}):s.jsxs(s.Fragment,{children:[s.jsx(wp,{size:18,className:"text-gray-400 group-hover/btn:text-accent transition-all"}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-500 group-hover/btn:text-gray-800 transition-all",children:"Analyze Engagement Profile"})]})})})]}),s.jsxs("div",{className:"space-y-3 pt-3 border-t border-gray-50",children:[s.jsxs("div",{className:"flex items-center justify-between text-[10px] font-black uppercase tracking-widest",children:[s.jsx("span",{className:"text-gray-400",children:"Current Role"}),s.jsx("span",{className:Fe("px-2 py-0.5 rounded",O.isAdmin||O.role==="admin"?"bg-blue-50 text-accent":"bg-gray-50 text-gray-500"),children:O.isAdmin||O.role==="admin"?"Administrator":"Member"})]}),s.jsxs("div",{className:"flex items-center justify-between text-[10px] font-black uppercase tracking-widest",children:[s.jsx("span",{className:"text-gray-400",children:"Blue Check (Premium)"}),s.jsx("span",{className:Fe("px-2 py-0.5 rounded font-black",O.isVerified||O.isPremium||O.blueCheck||O.isPremiumPostUser?"bg-blue-600 text-white":"bg-gray-100 text-gray-400"),children:O.isVerified||O.isPremium||O.blueCheck||O.isPremiumPostUser?"✓ Verified Premium":"Standard"})]}),s.jsxs("div",{className:"flex flex-col gap-2 pt-1",children:[s.jsx("button",{onClick:()=>tu(O.id,!!(O.isVerified||O.isPremium||O.blueCheck||O.isPremiumPostUser)),className:Fe("w-full py-2.5 rounded-xl text-[9.5px] font-black uppercase tracking-widest transition-all border-2 cursor-pointer flex items-center justify-center gap-1.5",O.isVerified||O.isPremium||O.blueCheck||O.isPremiumPostUser?"border-red-600 text-red-600 hover:bg-red-600 hover:text-white":"border-blue-600 text-blue-600 hover:bg-blue-600 hover:text-white"),children:O.isVerified||O.isPremium||O.blueCheck||O.isPremiumPostUser?"Revoke Blue Check (Premium)":"Grant Blue Check (Premium)"}),s.jsx("button",{onClick:()=>il(O.id,O.isAdmin||O.role==="admin"),className:Fe("w-full py-2.5 rounded-xl text-[9.5px] font-black uppercase tracking-widest transition-all border-2 cursor-pointer",O.isAdmin||O.role==="admin"?"border-black text-black hover:bg-black hover:text-white":"border-gray-900 text-gray-900 hover:bg-accent hover:border-accent hover:text-white"),children:O.isAdmin||O.role==="admin"?"Revoke Admin":"Make Admin"})]})]})]},O.id)})})]}):a==="manage-tickets"&&t?s.jsx("div",{className:"space-y-8",children:s.jsxs("div",{className:"flex flex-col md:flex-row gap-8",children:[s.jsxs("div",{className:"flex-1 bg-white p-8 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 mb-6",children:Lr?"Edit Event Ticket":"Create New Event"}),s.jsxs("form",{onSubmit:nl,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-widest ml-4",children:"Event Title"}),s.jsx("input",{type:"text",required:!0,value:Re,onChange:O=>mt(O.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold",placeholder:"e.g. Annual Mid-Semester Bash"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Price (UGX)"}),s.jsx("input",{type:"number",required:!0,value:Be,onChange:O=>Bt(O.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold",placeholder:"e.g. 20000"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Quantity"}),s.jsx("input",{type:"number",required:!0,value:Le,onChange:O=>fe(O.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold",placeholder:"e.g. 500"})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Event Date"}),s.jsx("input",{type:"datetime-local",required:!0,value:Mn,onChange:O=>jn(O.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Venue"}),s.jsx("input",{type:"text",required:!0,value:Ln,onChange:O=>xr(O.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold",placeholder:"e.g. Main Hall"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Description"}),s.jsx("textarea",{required:!0,value:nn,onChange:O=>Nn(O.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold min-h-[120px]",placeholder:"Detail what students should expect..."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"External Event Link (Optional)"}),s.jsx("input",{type:"url",value:an,onChange:O=>fr(O.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold",placeholder:"e.g. https://example.com/event-details"})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Poster Image (Instant Uploaded)"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"bg-gray-50 border border-gray-100 p-4 rounded-2xl flex flex-col justify-center space-y-2",children:[s.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 block",children:"Direct Image Link"}),s.jsx("input",{type:"text",value:al,onChange:O=>sa(O.target.value),placeholder:"Paste poster image URL or upload details...",className:"w-full px-3 py-2 bg-white border border-gray-100 text-[10px] text-gray-700 font-mono rounded-lg outline-none focus:border-accent"})]}),s.jsxs("div",{className:"relative group",children:[s.jsx("input",{type:"file",accept:"image/*",onChange:O=>{var Ae;const le=(Ae=O.target.files)==null?void 0:Ae[0];le&&(Bi(le),Ki(le,sa,Mo))},className:"hidden",id:"ticket-image"}),s.jsx("label",{htmlFor:"ticket-image",className:Fe("flex flex-col items-center justify-center aspect-video rounded-2xl border-2 border-dashed transition-all cursor-pointer bg-gray-50",al?"border-accent":"border-gray-100 hover:border-accent hover:bg-white"),children:gx?s.jsxs("div",{className:"text-center p-2",children:[s.jsx(Er,{className:"mx-auto text-accent mb-1 animate-spin",size:24}),s.jsx("p",{className:"text-[8px] font-black text-accent uppercase tracking-widest leading-none",children:"Uploading..."})]}):al?s.jsxs("div",{className:"w-full h-full relative rounded-2xl overflow-hidden group",children:[s.jsx("img",{src:al,className:"w-full h-full object-cover",alt:"Ticket Poster",referrerPolicy:"no-referrer"}),s.jsx("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-white",children:s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest",children:"Change Poster"})})]}):s.jsxs(s.Fragment,{children:[s.jsx(xu,{className:"text-gray-400 mb-1",size:24}),s.jsx("p",{className:"text-[8.5px] font-black text-gray-400 uppercase tracking-widest",children:"Select file"})]})})]})]})]}),s.jsxs("div",{className:"flex gap-4",children:[Lr&&s.jsx("button",{type:"button",onClick:()=>{zi(null),mt(""),Nn(""),Bt(""),jn(""),xr(""),fe(""),fr(""),sa("")},className:"flex-1 py-4 bg-gray-100 text-gray-600 rounded-2xl text-[10px] font-black uppercase tracking-widest",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:Tt,className:"flex-[2] py-4 bg-accent text-white rounded-2xl text-[10px] font-black uppercase tracking-widest shadow-lg shadow-accent/20",children:Tt?"Processing...":Lr?"Update Ticket":"Launch Event"})]})]})]}),s.jsxs("div",{className:"w-full md:w-96 space-y-4",children:[s.jsx("h3",{className:"text-sm font-black uppercase tracking-widest text-gray-400 ml-2",children:"Active Event Tickets"}),tn.map(O=>s.jsxs("div",{className:"bg-white p-5 rounded-3xl border border-gray-100 shadow-sm group",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsx("div",{className:"w-20 h-20 rounded-2xl overflow-hidden bg-gray-100 flex-shrink-0",children:s.jsx("img",{src:O.imageUrl||void 0,alt:"",className:"w-full h-full object-cover"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h4",{className:"text-sm font-black text-gray-900 truncate uppercase tracking-tight",children:O.title}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase mt-1",children:O.venue}),s.jsxs("div",{className:"flex items-center justify-between mt-3",children:[s.jsxs("span",{className:"text-xs font-black text-accent",children:["UGX ",O.price.toLocaleString()]}),s.jsxs("span",{className:"text-[9px] font-black px-2 py-1 bg-gray-100 rounded-lg text-gray-500",children:[O.remainingQuantity,"/",O.totalQuantity," LEFT"]})]})]})]}),s.jsxs("div",{className:"flex gap-2 mt-4 opacity-0 group-hover:opacity-100 transition-all",children:[s.jsx("button",{onClick:()=>{zi(O),mt(O.title),Nn(O.description),Bt(O.price.toString());const le=(()=>{const Ae=O.eventDate;if(!Ae)return"";const pt=typeof Ae.toDate=="function"?Ae.toDate():Ae instanceof Date?Ae:Ae.seconds?new Date(Ae.seconds*1e3):new Date(Ae);try{return pt.toISOString().slice(0,16)}catch{return""}})();jn(le),xr(O.venue),fe(O.totalQuantity.toString()),xi(O.category),sa(O.imageUrl||""),fr(O.link||"")},className:"flex-1 py-2 bg-blue-50 text-blue-600 rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-blue-600 hover:text-white transition-all",children:"Edit"}),s.jsx("button",{onClick:()=>ch(O.id),className:"flex-1 py-2 bg-blue-50 text-black rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-black hover:text-white transition-all",children:"Delete"})]})]},O.id))]})]})}):a==="ticket-purchases"&&t?s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"bg-white p-8 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest mb-1",children:"Total Tickets Sold"}),s.jsx("h3",{className:"text-2xl font-black text-gray-900",children:li.totalTicketsSold})]}),s.jsxs("div",{className:"bg-white p-8 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest mb-1",children:"Total Revenue"}),s.jsxs("h3",{className:"text-2xl font-black text-accent",children:["UGX ",li.totalRevenue.toLocaleString()]})]}),s.jsxs("div",{className:"bg-white p-8 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest mb-1",children:"Recent Transactions"}),s.jsx("h3",{className:"text-2xl font-black text-gray-900",children:Nt.length})]})]}),s.jsxs("div",{className:"bg-gray-50/70 p-6 rounded-[2.5rem] border border-gray-150 space-y-4 text-left",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400 shrink-0"}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-500 font-mono",children:"Simulated Gate Scan & Barcode Lookup"})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsx("input",{type:"text",placeholder:"Type or paste scanned Purchase ID (e.g. h6SndA4v...)",value:rs,onChange:O=>pi(O.target.value),className:"flex-1 px-6 py-3.5 bg-white border border-gray-250 rounded-2xl text-xs font-bold outline-none focus:border-red-600 transition-all font-mono"}),s.jsx("button",{onClick:()=>{if(!rs.trim()){pe.error("Please enter a ticket ID to query!");return}const O=Nt.find(le=>le.id===rs.trim()||le.id.slice(-6).toLowerCase()===rs.trim().toLowerCase());O?(pe.success(`Ticket found: ${O.ticketTitle}!`),vs(O)):(pe.error("Ticket purchase record not found in data sheets!"),vs(null))},className:"px-8 py-3.5 bg-black text-white hover:bg-red-655 rounded-2xl text-[10px] font-black uppercase tracking-widest transition-colors cursor-pointer",children:"Lookup Code"})]}),mi&&s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-150 shadow-xs mt-3 flex flex-col md:flex-row items-start md:items-center justify-between gap-4 animate-in fade-in slide-in-from-top-2 duration-200",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-widest font-mono",children:"Scanned Ticket Match"}),s.jsx("h4",{className:"text-sm font-black text-gray-950 uppercase tracking-tight leading-tight",children:mi.ticketTitle}),s.jsxs("div",{className:"flex flex-wrap gap-2 text-[9px] font-bold text-gray-500 uppercase mt-1",children:[s.jsxs("span",{children:["Guest: ",s.jsx("strong",{className:"text-gray-900",children:mi.userName})]}),s.jsx("span",{children:"•"}),s.jsxs("span",{children:["Qty: ",s.jsxs("strong",{className:"text-gray-900",children:[mi.quantity," Pax"]})]}),s.jsx("span",{children:"•"}),s.jsxs("span",{children:["Code: ",s.jsxs("strong",{className:"text-gray-900 font-mono select-all",children:["#",mi.id.substring(0,10),"..."]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-3 bg-gray-50 px-4 py-2.5 rounded-2xl border border-gray-100 shrink-0",children:[s.jsx("input",{type:"checkbox",id:"dashboard-scanned-taken",checked:!!mi.taken||!!mi.used,onChange:async()=>{const O=!(mi.taken||mi.used);try{await Cn(Je(he,"purchases",mi.id),{taken:O,used:O}),vs(le=>le?{...le,taken:O,used:O}:null),O?(await ur(et(he,"notifications"),{userId:mi.userId,title:`✔️ Ticket Ticked & Used: ${mi.ticketTitle}`,message:`Your entry pass (ID #${mi.id.slice(-6).toUpperCase()}) has been officially scanned and ticked as used. Enjoy the event!`,used:!1,createdAt:new Date,type:"entrance_checkin",code:mi.id}),pe.success("Ticket marked as used! Buyer's inbox is updated.",{icon:"✔️"})):pe.success("Entry pass reactivated.")}catch(le){console.error("Dashboard verify gate error:",le),pe.error("Verify failed: "+le.message)}},className:"w-4.5 h-4.5 rounded border-gray-300 text-red-650 cursor-pointer accent-red-650"}),s.jsx("label",{htmlFor:"dashboard-scanned-taken",className:"text-[10px] font-black uppercase tracking-wider text-gray-950 cursor-pointer select-none",children:mi.taken||mi.used?"✔️ TICKED & USED":"✉️ MARK USED / TICKED"})]})]})]}),s.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 items-center justify-between bg-white p-5 rounded-[2rem] border border-gray-100 shadow-sm text-left",children:[s.jsxs("div",{className:"relative w-full lg:max-w-md",children:[s.jsx("input",{type:"text",value:gi,onChange:O=>$r(O.target.value),placeholder:"Search by name, email, event title or ticket ID...",className:"w-full pl-6 pr-10 py-3 bg-gray-50/50 border border-gray-200 focus:border-red-650 rounded-2xl text-xs font-bold outline-none transition-all placeholder:text-gray-400"}),gi&&s.jsx("button",{onClick:()=>$r(""),className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-650 font-black text-[10px] uppercase tracking-wider",children:"Clear"})]}),s.jsx("div",{className:"flex items-center gap-1.5 p-1 bg-gray-105 border border-gray-150 rounded-2xl w-full lg:w-auto shrink-0 overflow-x-auto",children:[{key:"all",label:"All Bookings"},{key:"unclaimed",label:"🎫 Active / Unused"},{key:"taken",label:"✔️ Ticked / Used"}].map(O=>s.jsx("button",{type:"button",onClick:()=>Ss(O.key),className:Fe("px-4 py-2 rounded-xl text-[10px] font-black uppercase tracking-wider transition-all cursor-pointer whitespace-nowrap",Sr===O.key?"bg-white text-gray-950 shadow-xs":"text-gray-550 hover:text-gray-900"),children:O.label},O.key))})]}),s.jsx("div",{className:"bg-white rounded-[2.5rem] border border-gray-100 shadow-sm overflow-hidden",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-100",children:[s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Transaction ID"}),s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Customer"}),s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Event"}),s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Qty"}),s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Amount"}),s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Date"}),s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Taken / Checked In"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-50",children:Xf.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:7,className:"text-center py-12 text-xs font-bold text-gray-400 uppercase tracking-wider select-none font-mono",children:"No booking transactions match your search filter criteria."})}):Xf.map(O=>{const le=!!(O.taken||O.used);return s.jsxs("tr",{onClick:()=>ud(O),className:Fe("transition-all cursor-pointer hover:bg-red-50/20 active:bg-gray-100/60 select-none",le?"bg-green-50/15":"hover:bg-gray-50/80"),title:"Click anywhere on this row to tick/untick this pass",children:[s.jsx("td",{className:"px-8 py-4 text-[10px] font-black text-gray-900 uppercase font-mono",children:s.jsxs("span",{className:Fe(le?"line-through text-gray-400":""),children:["#",O.id.slice(-6).toUpperCase()]})}),s.jsxs("td",{className:"px-8 py-4",children:[s.jsx("p",{className:Fe("text-sm font-bold text-gray-900",le&&"line-through text-gray-450"),children:O.userName}),s.jsx("p",{className:"text-[10px] text-gray-400 truncate max-w-[200px]",children:O.userEmail})]}),s.jsx("td",{className:Fe("px-8 py-4 text-sm font-bold text-gray-900 uppercase tracking-tight",le&&"line-through text-gray-400"),children:O.ticketTitle}),s.jsx("td",{className:Fe("px-8 py-4 text-sm font-black text-gray-900",le&&"text-gray-400"),children:O.quantity}),s.jsxs("td",{className:Fe("px-8 py-4 text-sm font-black text-accent",le&&"text-gray-400"),children:["UGX ",O.totalAmount.toLocaleString()]}),s.jsx("td",{className:"px-8 py-4 text-[10px] font-bold text-gray-400 uppercase",children:O.purchaseDate instanceof _r?O.purchaseDate.toDate().toLocaleString():"Recently"}),s.jsx("td",{className:"px-8 py-4 text-[10px]",onClick:Ae=>Ae.stopPropagation(),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:le,onChange:()=>ud(O),className:"w-4 h-4 rounded border-gray-350 text-red-650 focus:ring-red-655 accent-red-600 cursor-pointer",id:`taken-${O.id}`}),s.jsx("label",{htmlFor:`taken-${O.id}`,onClick:Ae=>{Ae.stopPropagation(),ud(O)},className:Fe("text-[9px] font-black uppercase tracking-wider select-none cursor-pointer",le?"text-green-600 font-mono":"text-gray-400 font-mono"),children:le?"✔️ Ticked":"Mark Used"})]})})]},O.id)})})]})})]}):a==="polls"&&t?s.jsxs("div",{className:"max-w-4xl mx-auto space-y-8",children:[s.jsxs("div",{className:"bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Manage Campus Poll"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Create or reset the active university poll"})]}),s.jsxs("form",{onSubmit:cd,className:"space-y-8",children:[s.jsxs("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-widest",children:"Question"}),s.jsx("input",{type:"text",value:$e,onChange:O=>ct(O.target.value),placeholder:"e.g., Who is your favorite Guild Presidential candidate?",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all",required:!0})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest flex items-center justify-between",children:["Options",s.jsx("button",{type:"button",onClick:()=>_t([...ot,""]),className:"text-accent hover:underline",children:"Add Option"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:ot.map((O,le)=>s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:O,onChange:Ae=>{const pt=[...ot];pt[le]=Ae.target.value,_t(pt)},placeholder:`Option ${le+1}`,className:"flex-1 px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all",required:!0}),ot.length>2&&s.jsx("button",{type:"button",onClick:()=>_t(ot.filter((Ae,pt)=>pt!==le)),className:"p-4 text-gray-300 hover:text-accent transition-colors",children:s.jsx(As,{size:18})})]},le))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Poll Status"}),s.jsx("div",{className:"flex gap-4",children:["active","closed"].map(O=>s.jsx("button",{type:"button",onClick:()=>Lt(O),className:Fe("flex-1 py-4 px-6 rounded-2xl text-[10px] font-black uppercase tracking-widest border-2 transition-all",pn===O?"border-accent bg-blue-50 text-accent":"border-gray-100 text-gray-400 hover:border-gray-200"),children:O},O))})]})]})," ",s.jsxs("button",{type:"submit",disabled:Tt,className:"w-full py-5 bg-accent text-white rounded-2xl text-xs font-black uppercase tracking-[0.2em] shadow-xl shadow-accent/20 hover:bg-accent-700 transition-all disabled:opacity-50 flex items-center justify-center gap-2",children:[Tt?s.jsx(Er,{className:"animate-spin",size:18}):s.jsx(lc,{size:18}),Tt?"Processing...":"Update Campus Poll"]})]}),s.jsxs("div",{className:"mt-12 p-6 bg-blue-50 rounded-2xl border border-blue-100 flex items-start gap-4",children:[s.jsx(ku,{className:"text-accent shrink-0",size:20}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-[10px] font-black text-accent uppercase tracking-widest leading-none",children:"Safe Storage Archiving"}),s.jsx("p",{className:"text-[10px] font-bold text-accent/80 uppercase tracking-tight leading-tight",children:"This action will post a brand-new poll and close previous active ones. Existing votes for old polls are securely preserved and stored in historical archives."})]})]})]}),s.jsxs("div",{id:"admin-debates-section",className:"bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm space-y-8",children:[s.jsxs("div",{className:"border-b border-gray-100 pb-5",children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Manage Public Debates"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Create debate topics (link to external discussion or internal built-in discussion threads)"})]}),s.jsxs("form",{onSubmit:Vi,className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Debate Topic Title"}),s.jsx("input",{type:"text",value:U,onChange:O=>H(O.target.value),placeholder:"e.g. Is remote learning more effective than in-person lectures?",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all",required:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Banner Image URL"}),s.jsx("input",{type:"text",value:Ye,onChange:O=>Te(O.target.value),placeholder:"Leave blank for smart defaults",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Description / Content"}),s.jsx("textarea",{value:oe,onChange:O=>De(O.target.value),placeholder:"Brief introduction or guidelines for this debate thread...",rows:3,className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all"})]}),s.jsxs("div",{className:"flex items-center gap-3 p-4 bg-gray-50 rounded-2xl border border-gray-100",children:[s.jsx("input",{type:"checkbox",id:"debateIsExternal",checked:Ct,onChange:O=>Zn(O.target.checked),className:"w-4.5 h-4.5 text-accent border-gray-300 rounded focus:ring-accent accent-accent"}),s.jsx("label",{htmlFor:"debateIsExternal",className:"text-xs font-black uppercase tracking-wider text-gray-700 select-none cursor-pointer",children:"This is an external discussion link (redirect user to external URL)"})]}),Ct&&s.jsxs("div",{className:"space-y-2 pt-2 animate-fade-in",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"External Link URL"}),s.jsx("input",{type:"text",value:wn,onChange:O=>tr(O.target.value),placeholder:"https://example.com/discussion",className:"w-full px-6 py-4 bg-gray-50 border border-gray-150 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all",required:Ct})]}),s.jsxs("button",{type:"submit",disabled:Ur,className:"w-full py-5 bg-stone-950 text-white rounded-2xl text-xs font-black uppercase tracking-[0.2em] shadow-xl hover:bg-black transition-all disabled:opacity-50 flex items-center justify-center gap-2 cursor-pointer",children:[Ur?s.jsx(Er,{className:"animate-spin",size:18}):s.jsx(bi,{size:18}),Ur?"Publishing...":"Publish Public Debate Topic"]})]}),s.jsx("div",{className:"space-y-4 pt-6",children:s.jsxs("div",{className:"border-t border-gray-100 pt-6",children:[s.jsxs("h4",{className:"text-sm font-black uppercase tracking-wider text-gray-900 mb-4",children:["Active Debates (",He.length,")"]}),He.length===0?s.jsx("p",{className:"text-xs font-bold text-gray-400 uppercase tracking-widest text-center py-4",children:"No active debates listed yet."}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:He.map(O=>s.jsxs("div",{className:"p-4 bg-gray-50 rounded-2xl border border-gray-100 flex gap-3 relative justify-between items-start min-w-0",children:[s.jsxs("div",{className:"flex gap-2.5 items-start min-w-0",children:[s.jsx("img",{src:O.bannerUrl||void 0,alt:"",className:"w-12 h-12 rounded-xl object-cover border border-gray-150 shrink-0",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"min-w-0 text-left",children:[s.jsx("span",{className:`text-[8px] font-black uppercase tracking-wider px-2 py-0.5 rounded ${O.isExternal?"bg-orange-50 text-orange-600 border border-orange-100":"bg-green-50 text-green-600 border border-green-100"}`,children:O.isExternal?"External":"Built-in"}),s.jsx("h5",{className:"text-xs font-black text-gray-950 mt-1 truncate uppercase tracking-tight",children:O.title}),s.jsx("p",{className:"text-[9px] text-gray-500 line-clamp-1 mt-0.5",children:O.description||"No description provided."})]})]}),s.jsx("button",{onClick:()=>Ri(O.id),className:"p-2 text-gray-400 hover:text-red-650 hover:bg-red-50 rounded-xl transition-all cursor-pointer shrink-0",title:"Delete debate topic",children:s.jsx(As,{size:16})})]},O.id))})]})})]})]}):a==="pinned-board"&&t?s.jsx("div",{className:"max-w-4xl mx-auto space-y-8",children:s.jsxs("div",{className:"bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsxs("div",{className:"mb-8 flex items-center justify-between border-b border-gray-50 pb-6",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(C0,{className:"text-accent stroke-[3px]",size:20}),s.jsx("span",{children:"Pinned Announcements Board"})]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Supercharge articles, events, or programs with a high-impact sliding announcement"})]}),s.jsxs("div",{className:"flex items-center gap-3 bg-gray-50 px-4 py-2 rounded-2xl border border-gray-100",children:[s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-400",children:"Status"}),s.jsx("button",{type:"button",onClick:()=>$m(!Ql),className:Fe("relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-250 ease-in-out outline-none",Ql?"bg-accent":"bg-gray-250"),children:s.jsx("span",{className:Fe("pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-250 ease-in-out",Ql?"translate-x-5":"translate-x-0")})}),s.jsx("span",{className:Fe("text-[9px] font-black uppercase tracking-widest",Ql?"text-accent":"text-gray-400"),children:Ql?"ACTIVE":"INACTIVE"})]})]}),s.jsxs("form",{onSubmit:qm,className:"space-y-8",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1",children:"Announcement Title"}),s.jsx("input",{type:"text",value:Cc,onChange:O=>jc(O.target.value),placeholder:"e.g. 🎉 SPECIAL FREE TICKET GIVEAWAY!",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all",required:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1",children:"Target Action Link (Clickable Destination)"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"url",value:cu,onChange:O=>id(O.target.value),placeholder:"https://campus-eye.com/tickets/giveaway-id",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all pl-12"}),s.jsx(Ad,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400",size:18})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1",children:"Display duration on page load (seconds)"}),s.jsx("input",{type:"number",min:"1",max:"60",value:Zl,onChange:O=>Kf(Number(O.target.value)||5),placeholder:"Default is 5 seconds",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all",required:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1 block",children:"Live Streaming / Embed Option"}),s.jsxs("div",{className:"flex items-center gap-3 p-4 bg-gray-50 border border-gray-100 rounded-2xl",children:[s.jsx("input",{type:"checkbox",id:"pinned-is-live",checked:sd,onChange:O=>Jl(O.target.checked),className:"w-4 h-4 text-red-600 border-gray-300 rounded focus:ring-red-500 cursor-pointer"}),s.jsx("label",{htmlFor:"pinned-is-live",className:"text-xs font-black text-gray-700 uppercase tracking-wider cursor-pointer select-none",children:"Enable Live Embed / Stream Page"})]})]})]}),sd&&s.jsx("div",{className:"grid grid-cols-1 gap-6 animate-fade-in",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-red-650 uppercase tracking-widest ml-1 block",children:"Live Streaming / IFrame Embed URL"}),s.jsx("input",{type:"url",value:ec,onChange:O=>ad(O.target.value),placeholder:"e.g., https://www.youtube.com/embed/... or any dynamic webpage embed code link",className:"w-full px-6 py-4 bg-red-50/20 border border-red-200 rounded-2xl text-sm font-bold focus:bg-white focus:border-red-650 outline-none transition-all text-red-950 placeholder-red-300",required:sd}),s.jsx("span",{className:"text-[9px] text-gray-400 block ml-1 uppercase font-black tracking-widest",children:"🛡️ If enabled, a reside interactive preview will load instead of the static mock picture. Let clicked, the stream pops up fullscreen!"})]})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1",children:"Short Description / Subtitle"}),s.jsx("textarea",{value:Vm,onChange:O=>Fm(O.target.value),placeholder:"e.g. Claim free registration passes to the upcoming Guild Presidential Debate! Only for verified campus citizens.",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all min-h-[90px] resize-none"})]}),s.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-50",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1 block",children:"Accompanying Image / Photo Asset"}),s.jsx("span",{className:"text-[9px] font-medium text-gray-400 uppercase tracking-wider",children:"Fast Cloud Image Storage"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"md:col-span-2 relative",children:[s.jsx("input",{type:"file",accept:"image/*",onChange:O=>{var Ae;const le=(Ae=O.target.files)==null?void 0:Ae[0];le&&(od(!0),Ki(le,uu,od))},className:"hidden",id:"pinned-banner-image"}),s.jsx("label",{htmlFor:"pinned-banner-image",className:Fe("flex flex-col items-center justify-center aspect-[16/6] rounded-2xl border-2 border-dashed transition-all cursor-pointer bg-gray-50",Ic?"border-accent":"border-gray-150 hover:border-accent hover:bg-white"),children:mh?s.jsxs("div",{className:"text-center p-4",children:[s.jsx(Er,{className:"mx-auto text-accent mb-2 animate-spin",size:28}),s.jsx("p",{className:"text-[10px] font-black text-accent uppercase tracking-widest block leading-none",children:"Uploading Asset..."})]}):Ic?s.jsxs("div",{className:"w-full h-full relative rounded-2xl overflow-hidden group",children:[s.jsx("img",{src:Ic,className:"w-full h-full object-cover animate-fade-in",alt:"Pinned Asset",referrerPolicy:"no-referrer"}),s.jsx("div",{className:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-white",children:s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-widest flex items-center gap-1",children:[s.jsx(C0,{size:14})," Change Announcement Photo"]})})]}):s.jsxs(s.Fragment,{children:[s.jsx(xu,{className:"text-gray-400 mb-2",size:28}),s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block text-center leading-none",children:"Upload Announcement Photo"})]})})]}),s.jsxs("div",{className:"bg-gray-50 border border-gray-100 p-5 rounded-2xl flex flex-col justify-center space-y-3 shadow-inner",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 block mb-1",children:"Direct Asset URI"}),s.jsx("input",{type:"text",value:Ic,onChange:O=>uu(O.target.value),placeholder:"Or paste asset address here...",className:"w-full px-3 py-2 bg-white border border-gray-100 text-[10px] text-gray-700 font-mono rounded-lg outline-none focus:border-accent"})]}),s.jsx("p",{className:"text-[8px] text-gray-400 font-bold uppercase tracking-wider leading-relaxed",children:"This image resides inside the sliding high-attention banner replacing the top banner briefly with streamlined design specs."})]})]})]}),s.jsx("div",{className:"border-t border-gray-50 pt-8 mt-8",children:s.jsxs("button",{type:"submit",disabled:Tc,className:"w-full py-5 bg-accent text-white rounded-2xl text-xs font-black uppercase tracking-[0.2em] shadow-xl shadow-accent/20 hover:bg-accent-700 transition-all disabled:opacity-50 flex items-center justify-center gap-2",children:[Tc?s.jsx(Er,{className:"animate-spin",size:18}):s.jsx(lc,{size:18}),Tc?"Saving changes...":"Publish Pinned Announcement"]})})]}),s.jsxs("div",{className:"mt-12 pt-8 border-t border-gray-100 space-y-6",children:[s.jsxs("div",{children:[s.jsxs("h4",{className:"text-sm font-black uppercase tracking-wider text-gray-950 flex items-center gap-2",children:[s.jsx(C0,{size:16,className:"text-red-650"}),s.jsxs("span",{children:["Active database broadcasts (",Yf.length,")"]})]}),s.jsx("p",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-widest mt-0.5",children:"Admins can review, monitor and delete active broadcasts on the campus banner"})]}),Yf.length===0?s.jsxs("div",{className:"p-10 border rounded-2xl text-center bg-gray-50 border-gray-100 text-gray-400 select-none",children:[s.jsx("p",{className:"text-xs font-bold uppercase tracking-wider",children:"No active broadcasts registered in database."}),s.jsx("p",{className:"text-[9px] uppercase tracking-widest mt-1",children:"Submit the form above to post your first broadcast."})]}):s.jsx("div",{className:"grid grid-cols-1 gap-4",children:Yf.map(O=>s.jsxs("div",{className:"flex items-center justify-between p-4 bg-white border border-gray-150 rounded-2xl hover:border-red-650/40 transition-all shadow-xs",children:[s.jsxs("div",{className:"flex items-center gap-4 min-w-0 flex-1",children:[O.imageUrl?s.jsx("img",{src:O.imageUrl,alt:"",className:"w-12 h-12 rounded-xl object-cover border border-gray-100",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"w-12 h-12 bg-red-50 text-red-600 rounded-xl flex items-center justify-center font-bold",children:s.jsx(Ou,{size:18})}),s.jsxs("div",{className:"min-w-0 pr-4 text-left",children:[s.jsx("h5",{className:"text-xs font-black text-gray-900 truncate uppercase tracking-tight",children:O.title}),s.jsx("p",{className:"text-[10px] text-gray-500 line-clamp-1 mt-0.5",children:O.description||"No description provided."}),s.jsxs("span",{className:"text-[8px] font-black font-mono text-gray-400 uppercase tracking-widest block mt-1",children:[O.durationSeconds||5,"s • link: ",O.link?"configured":"none"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:async()=>{try{const le=Je(he,"pinned_announcements",O.id);await Cn(le,{active:!O.active}),O.active||await Rr(Je(he,"settings","pinned"),{title:O.title,description:O.description||"",link:O.link||"",imageUrl:O.imageUrl||"",active:!0,durationSeconds:O.durationSeconds||5,isLiveStream:!!O.isLiveStream,liveEmbedUrl:O.liveEmbedUrl||"",updatedAt:En()},{merge:!0}),pe.success(`Announcement set to ${O.active?"Inactive":"Active"}`)}catch(le){pe.error("Failed to update status: "+le.message)}},className:Fe("text-[8px] font-mono font-black uppercase px-2 py-1.5 rounded-lg cursor-pointer transition-all active:scale-95 border",O.active?"bg-green-50 text-green-700 border-green-200 hover:bg-green-150 hover:text-green-800":"bg-gray-50 text-gray-400 border-gray-200 hover:bg-gray-100 hover:text-gray-600"),title:"Click to toggle active status",children:O.active?"● ACTIVE":"○ INACTIVE"}),s.jsx("button",{onClick:()=>Pc(O.id),className:"p-2 text-gray-400 hover:text-red-650 hover:bg-red-50 rounded-lg transition-colors cursor-pointer",title:"Delete announcement",children:s.jsx(As,{size:16})})]})]},O.id))})]}),s.jsxs("div",{className:"mt-8 p-6 bg-blue-50/70 border border-blue-100 rounded-2xl flex items-start gap-4",children:[s.jsx(Ou,{className:"text-accent shrink-0 animate-bounce",size:20}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-[10px] font-black text-accent uppercase tracking-widest leading-none",children:"Visual Carousel Mechanics"}),s.jsx("p",{className:"text-[10px] font-medium text-accent/80 uppercase tracking-tight leading-relaxed",children:"If active, this announcement slides overlay style onto the first banner rotation on the homepage. To support clean aesthetics, it has beautifully rounded edges, custom colored border halo, slides in with Streamlined fluid transitions, displays for exactly 2 seconds, and then automatically returns to the original carousel."})]})]})]})}):a==="manage-posts"&&t?s.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto animate-fade-in text-left",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row justify-between sm:items-center border-b border-gray-105 pb-4 gap-3",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(bi,{className:"text-accent stroke-[3px]",size:19}),s.jsx("span",{children:"Manage Lounge Posts"})]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Review, moderate, and delete student-generated posts in the lounge"})]}),s.jsxs("div",{className:"text-[10px] bg-red-50 text-red-750 px-3 py-1.5 border border-red-150/50 rounded-xl font-mono shrink-0 w-fit",children:["Total Posts: ",F.length]})]}),F.length===0?s.jsxs("div",{className:"bg-white p-20 rounded-[2.5rem] border border-gray-100 shadow-sm text-center",children:[s.jsx("div",{className:"w-16 h-16 bg-gray-50 text-gray-450 rounded-full flex items-center justify-center mx-auto mb-4",children:s.jsx(bi,{size:32})}),s.jsx("h4",{className:"text-lg font-sans font-extrabold text-gray-900 uppercase tracking-tight",children:"No Posts Found"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-2",children:"Lounge database is currently empty."})]}):s.jsx("div",{className:"grid grid-cols-1 gap-4",children:F.map(O=>{var le,Ae,pt;return s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-sm hover:shadow-md transition-all flex flex-col md:flex-row gap-5",children:[s.jsxs("div",{className:"flex-1 space-y-3 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[O.authorPhotoURL?s.jsx("img",{src:O.authorPhotoURL,className:"w-8 h-8 rounded-full object-cover border border-gray-250 shrink-0",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-100 text-red-750 flex items-center justify-center font-black text-xs shrink-0 select-none",children:((le=O.authorName)==null?void 0:le.charAt(0))||"P"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"text-[10.5px] font-black uppercase tracking-tight text-gray-950 block truncate",children:O.authorName||"Peer"}),s.jsxs("span",{className:"text-[8px] font-semibold text-gray-450 block uppercase font-mono tracking-wider",children:["ID: #",O.id.slice(-6).toUpperCase()]})]})]}),s.jsx("p",{className:"text-xs text-gray-800 font-sans leading-relaxed whitespace-pre-wrap",children:O.content}),O.imageUrl&&s.jsx("div",{className:"max-w-xs rounded-xl overflow-hidden border border-gray-150 max-h-40 bg-gray-50",children:s.jsx("img",{src:O.imageUrl,className:"w-full h-full object-cover",referrerPolicy:"no-referrer"})})]}),(t||((pt=(Ae=Ne.currentUser)==null?void 0:Ae.email)==null?void 0:pt.toLowerCase())==="atwiinevictor2@gmail.com")&&s.jsx("div",{className:"shrink-0 flex md:flex-col items-end justify-between md:justify-center gap-3",children:s.jsx("button",{onClick:async()=>{if(!t){pe.error("Access Denied: Only administrators can delete posts.");return}if(window.confirm("Are you sure you want to delete this lounge post? This action is permanent."))try{await si(Je(he,"posts",O.id)),pe.success("Lounge post deleted successfully.")}catch(Ht){pe.error("Failed to delete lounge post: "+Ht.message)}},className:"p-3 bg-red-50 hover:bg-red-650 text-red-650 hover:text-white rounded-xl transition-all cursor-pointer shadow-xs active:scale-95",title:"Delete Post (Master Admin)",children:s.jsx(As,{size:16})})})]},O.id)})})]}):a==="custom-links"&&t?s.jsxs("div",{className:"space-y-8 max-w-4xl mx-auto animate-fade-in text-left",children:[s.jsx("div",{className:"flex border-b border-gray-100 pb-4 justify-between items-center",children:s.jsxs("div",{children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(Ad,{className:"text-accent stroke-[3px]",size:19}),s.jsx("span",{children:"Global Menu Pages Manager"})]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Add, edit, or delete external links that render as immersive full-screen popups in every user's menu."})]})}),s.jsxs("div",{className:"bg-white p-6 md:p-8 rounded-[2rem] border border-gray-105 shadow-sm space-y-4",children:[s.jsx("h4",{className:"text-sm font-sans font-extrabold uppercase tracking-tight text-gray-900 border-b border-gray-50 pb-2",children:nt?"⚡ Modify Existing Page":"➕ Add Custom Dynamic Page link"}),s.jsxs("form",{onSubmit:Ib,className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-450 block",children:"Page Display Name"}),s.jsx("input",{required:!0,type:"text",value:J,onChange:O=>ye(O.target.value),placeholder:"e.g. Student Varsity Store",className:"w-full px-4 py-3 bg-gray-50 border border-gray-250 rounded-xl outline-none text-sm font-bold placeholder:text-gray-300 focus:border-red-600 focus:bg-white transition-all"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-450 block",children:"Redirect / Iframe Destination URL"}),s.jsx("input",{required:!0,type:"url",value:ne,onChange:O=>de(O.target.value),placeholder:"https://example.com/varsity-store",className:"w-full px-4 py-3 bg-gray-50 border border-gray-250 rounded-xl outline-none text-sm font-bold placeholder:text-gray-300 focus:border-red-600 focus:bg-white transition-all"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-450 block",children:"SVG Icon Code or Preset Name (e.g. HTML SVG or SVG path code)"}),s.jsx("textarea",{value:be,onChange:O=>Ce(O.target.value),placeholder:"Paste your SVG tag structure or path code here, or tap preset clickers...",rows:2,className:"w-full px-4 py-3 bg-gray-50 border border-gray-250 rounded-xl outline-none text-xs font-mono placeholder:text-gray-300 focus:border-red-600 focus:bg-white transition-all resize-none"}),s.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1",children:[{label:"⭐ Star",code:''},{label:"🔥 Hot",code:''},{label:"🏆 Trophy",code:''},{label:"🎓 Academy",code:''},{label:"🎫 Ticket",code:''}].map(O=>s.jsx("button",{type:"button",onClick:()=>Ce(O.code),className:"px-2 py-1 bg-gray-100 hover:bg-black hover:text-white rounded-md text-[8px] font-black uppercase tracking-wider transition-all cursor-pointer border border-transparent hover:border-gray-300",children:O.label},O.label))})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 bg-gray-50/50 p-4 rounded-2xl border border-gray-150/40",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-red-650 block",children:"Experience Type / Media Format"}),s.jsxs("select",{value:Ke,onChange:O=>G(O.target.value),className:"w-full px-4 py-3 bg-white border border-gray-250 rounded-xl outline-none text-xs font-bold focus:border-red-600 transition-all cursor-pointer",children:[s.jsx("option",{value:"link",children:"📎 Standard Embedded Page (IFrame Resource)"}),s.jsx("option",{value:"youtube",children:"🔴 YouTube Live Stream / Video Player (Theatre Layout)"}),s.jsx("option",{value:"custom_stream",children:"📺 Other Live Stream or Broadcast URL"})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-4 md:pt-6 pl-1",children:[s.jsx("input",{type:"checkbox",id:"custom-page-is-pinned",checked:re,onChange:O=>Me(O.target.checked),className:"w-4 h-4 text-red-650 border-gray-300 rounded focus:ring-red-500 cursor-pointer accent-red-650"}),s.jsx("label",{htmlFor:"custom-page-is-pinned",className:"text-[10px] font-black text-gray-700 uppercase tracking-wider cursor-pointer select-none",children:"📌 Pin as Live Stream Spotlight post"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-450 block",children:"Short Overview description (shown beneath player)"}),s.jsx("input",{type:"text",value:se,onChange:O=>xe(O.target.value),placeholder:"e.g. Catch the official live stream covering our campus tech marathon finals.",className:"w-full px-4 py-3 bg-gray-50 border border-gray-250 rounded-xl outline-none text-sm font-bold placeholder:text-gray-300 focus:border-red-600 focus:bg-white transition-all"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{type:"submit",disabled:Tt,className:"flex-1 py-3 bg-black hover:bg-red-650 text-white text-[10px] font-black uppercase tracking-widest rounded-xl transition-all disabled:opacity-50 flex items-center justify-center gap-2 cursor-pointer",children:Tt?"Processing...":nt?"Update Page Link":"Deploy Page to Menu"}),nt&&s.jsx("button",{type:"button",onClick:()=>{ze(null),ye(""),de("")},className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 text-gray-750 text-[10px] font-black uppercase tracking-widest rounded-xl transition-all cursor-pointer",children:"Cancel"})]})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-450",children:"Configured Global Pages"}),Y.length===0?s.jsxs("div",{className:"bg-white py-12 px-6 rounded-3xl border border-gray-100 text-center text-gray-400",children:[s.jsx(Ad,{size:24,className:"mx-auto text-gray-300 mb-2"}),s.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider",children:"No custom pages are currently configured for user menus."})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Y.map(O=>{var pt;const Ae=Date.now()-((pt=O.createdAt)!=null&&pt.seconds?O.createdAt.seconds*1e3:Date.now())<10080*60*1e3;return s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-105 shadow-xs flex flex-col justify-between gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h5",{className:"font-extrabold text-sm text-gray-900",children:O.name}),Ae&&s.jsx("span",{className:"bg-red-100 text-red-750 px-2 py-0.5 rounded-full text-[8px] font-extrabold uppercase",children:"New"})]}),s.jsx("p",{className:"text-[10px] text-gray-400 font-mono truncate select-all",children:O.url})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-50 pt-3",children:[s.jsx("button",{onClick:()=>ax(O),className:"p-2.5 bg-gray-50 hover:bg-gray-100 text-gray-700 hover:text-gray-950 rounded-lg transition-all cursor-pointer border border-gray-150",title:"Edit Custom Page",children:s.jsx(kd,{size:12})}),s.jsx("button",{onClick:()=>Tb(O.id),className:"p-2.5 bg-red-50 hover:bg-red-100 text-red-650 rounded-lg transition-all cursor-pointer border border-red-150",title:"Delete Custom Page",children:s.jsx(As,{size:12})})]})]},O.id)})})]})]}):a==="feedback-inbox"&&t?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"border-b border-gray-100 pb-4 max-w-3xl",children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(ea,{className:"text-accent",size:22})," User Feedback Inbox"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Received comments, critiques, proposals, & systemic reports from campus readers"})]}),rt.length===0?s.jsxs("div",{className:"bg-white py-14 px-6 rounded-[2rem] border border-gray-150 text-center max-w-3xl",children:[s.jsx("div",{className:"w-16 h-16 bg-gray-50 rounded-full flex items-center justify-center mx-auto mb-4",children:s.jsx(ea,{size:24,className:"text-gray-300"})}),s.jsx("h4",{className:"text-sm font-black uppercase tracking-wider text-gray-900",children:"Inbox is empty"}),s.jsx("p",{className:"text-[10px] uppercase font-bold tracking-widest text-gray-400 mt-1",children:"No general user feedback submissions have been received yet."})]}):s.jsx("div",{className:"space-y-4 max-w-3xl",children:rt.map(O=>{var le,Ae,pt;return s.jsxs("div",{className:"bg-white p-6 rounded-[2rem] border border-gray-150 shadow-sm hover:shadow-md transition-all flex flex-col gap-4 text-left font-sans",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap pb-3 border-b border-gray-50",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-extrabold text-xs text-gray-900 uppercase tracking-wider",children:O.name||"Anonymous Reader"}),O.email&&s.jsx("span",{className:"text-[9px] font-mono text-gray-450 bg-gray-55/15 px-2 py-0.5 rounded-lg border border-gray-100",children:O.email})]}),s.jsxs("div",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-widest mt-0.5",children:["Subject: ",s.jsx("span",{className:"text-gray-700",children:O.subject||"General Feedback"})]})]}),(t||((Ae=(le=Ne.currentUser)==null?void 0:le.email)==null?void 0:Ae.toLowerCase())==="atwiinevictor2@gmail.com")&&s.jsx("button",{onClick:async()=>{if(!t){pe.error("Access Denied: Only administrators can delete feedback.");return}if(window.confirm("Are you sure you want to permanently delete this user feedback entry?"))try{await si(Je(he,"feedback",O.id)),pe.success("Feedback deleted successfully.")}catch(Ht){pe.error("Failed to delete feedback: "+Ht.message)}},className:"p-2.5 bg-red-50 hover:bg-red-500 hover:text-white text-red-650 rounded-lg transition-all cursor-pointer border border-red-150",title:"Dismiss Feedback (Master Admin)",children:s.jsx(As,{size:12})})]}),s.jsx("div",{className:"text-xs text-gray-650 leading-relaxed whitespace-pre-wrap",children:O.message}),s.jsxs("div",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400 font-mono text-right leading-none",children:["Received: ",(pt=O.createdAt)!=null&&pt.seconds?new Date(O.createdAt.seconds*1e3).toLocaleString():"Just now"]})]},O.id)})})]}):a==="manage-podcasts"&&t?s.jsxs("div",{className:"space-y-8 font-sans text-left",children:[s.jsx("div",{className:"border-b border-gray-100 pb-4 max-w-3xl",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"p-2 bg-red-50 text-red-600 rounded-xl",children:s.jsx(uc,{size:20})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:"Podcasts & Video Broadcasts Hub"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-0.5",children:"Publish Audio podcasts & Video episodes (YouTube, MP4, direct links) with visual media badges"})]})]})}),s.jsxs("div",{className:"bg-white p-6 rounded-[2rem] border border-gray-150 shadow-sm max-w-3xl",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4 pb-3 border-b border-gray-100",children:[s.jsx("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:b?`⚡ Edit ${ni==="video"?"Video":"Audio"} Podcast`:`➕ Create New ${ni==="video"?"Video":"Audio"} Podcast`}),b&&s.jsx("span",{className:"text-[9px] font-mono font-bold text-amber-700 bg-amber-50 px-2 py-0.5 rounded-lg border border-amber-200",children:"Editing Mode"})]}),s.jsxs("form",{onSubmit:Ac,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500 flex items-center gap-1.5",children:["Select Media Format ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 p-1 bg-gray-50 rounded-2xl border border-gray-150",children:[s.jsxs("button",{type:"button",onClick:()=>{Ps("audio")},className:`flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl text-xs font-black uppercase tracking-wider transition-all cursor-pointer ${ni==="audio"?"bg-emerald-600 text-white shadow-md":"text-gray-600 hover:text-gray-950 hover:bg-white/60"}`,children:[s.jsx(Zh,{size:15})," Audio Podcast"]}),s.jsxs("button",{type:"button",onClick:()=>{Ps("video")},className:`flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl text-xs font-black uppercase tracking-wider transition-all cursor-pointer ${ni==="video"?"bg-red-600 text-white shadow-md":"text-gray-600 hover:text-gray-950 hover:bg-white/60"}`,children:[s.jsx(Ea,{size:15})," Video Podcast (YouTube/MP4)"]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsxs("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:["Episode Title ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",required:!0,value:ws,onChange:O=>Da(O.target.value),placeholder:ni==="video"?"e.g. GUILD PRESIDENTIAL DEBATE HIGHLIGHTS":"e.g. THE TRUTH OF CAMPUS BUDGETS",className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-900 font-bold focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50"})]}),s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsxs("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:["Host / Presenter / Channel ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",required:!0,value:Ei,onChange:O=>Ts(O.target.value),placeholder:"e.g. Editorial Board / Campus TV",className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-900 font-bold focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50"})]})]}),s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500 flex items-center gap-1.5",children:ni==="video"?s.jsxs(s.Fragment,{children:[s.jsx(Ea,{size:12,className:"text-red-600"})," Video URL (YouTube, MP4, WebM, Google Drive, Direct Link) ",s.jsx("span",{className:"text-red-500",children:"*"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Zh,{size:12,className:"text-emerald-600"})," Audio Stream / MP3 / WAV Link ",s.jsx("span",{className:"text-red-500",children:"*"})]})}),ni==="video"&&vp(El)&&s.jsx("span",{className:"text-[8px] font-black uppercase text-red-600 bg-red-50 px-2 py-0.5 rounded border border-red-200",children:"✓ YouTube Link Detected"})]}),s.jsx("div",{className:"relative",children:s.jsx("input",{type:"url",required:!0,value:ni==="video"?El:wc,onChange:O=>{const le=O.target.value;ni==="video"?(Jo(le),vp(le)&&!go&&La(yw(le,"hq"))):(Ma(le),vp(le)&&(Ps("video"),Jo(le),Ma(""),go||La(yw(le,"hq")),pe.success("YouTube link detected! Switched to Video Podcast format.",{icon:"🎬"})))},placeholder:ni==="video"?"e.g. https://www.youtube.com/watch?v=... or https://youtu.be/... or .mp4 link":"e.g. https://example.com/podcast.mp3 or audio stream URL",className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-900 font-bold focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50"})})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:"Duration / Timestamp"}),s.jsx("input",{type:"text",required:!0,value:Cm,onChange:O=>Nc(O.target.value),placeholder:"e.g. 15:30 or 1h 05m",className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-900 font-bold focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50"})]}),s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:"Category"}),s.jsxs("select",{value:mo,onChange:O=>ah(O.target.value),className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-900 font-bold focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50",children:[s.jsx("option",{value:"Campus News",children:"Campus News"}),s.jsx("option",{value:"Campus Vibe",children:"Campus Vibe"}),s.jsx("option",{value:"Investigation",children:"Investigation"}),s.jsx("option",{value:"Sports Desk",children:"Sports Desk"}),s.jsx("option",{value:"Lifestyle",children:"Lifestyle"}),s.jsx("option",{value:"Entertainment",children:"Entertainment"}),s.jsx("option",{value:"Special Report",children:"Special Report"})]})]})]}),s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:"Episode Summary / Show Notes (Optional)"}),s.jsx("textarea",{rows:2,value:Hr,onChange:O=>Ec(O.target.value),placeholder:"Add brief highlights, key interviewees, or discussion topics...",className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-900 font-medium focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-1.5",children:[s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:"Cover Picture (Upload)"}),s.jsx("input",{type:"file",accept:"image/*",onChange:O=>{var Ae;const le=(Ae=O.target.files)==null?void 0:Ae[0];le&&Ki(le,La,u)},className:"w-full text-xs text-gray-400 file:mr-4 file:py-2 file:px-4 file:rounded-xl file:border-0 file:text-[10px] file:font-black file:uppercase file:bg-gray-100 file:text-gray-700 hover:file:bg-gray-200 transition-all cursor-pointer"})]}),s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:"Or Cover Picture Direct URL"}),ni==="video"&&vp(El)&&s.jsx("button",{type:"button",onClick:()=>{const O=yw(El,"maxres");La(O),pe.success("Loaded HD YouTube thumbnail!",{icon:"🖼️"})},className:"text-[8px] font-black uppercase text-red-600 hover:underline cursor-pointer",children:"⚡ Auto-Fetch YouTube Thumbnail"})]}),s.jsx("input",{type:"url",value:go,onChange:O=>La(O.target.value),placeholder:"e.g. https://images.unsplash.com/photo-...",className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-950 font-bold focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50"})]})]}),go&&s.jsxs("div",{className:"pt-2 flex items-center gap-3 bg-gray-50 p-2.5 rounded-2xl border border-gray-150",children:[s.jsx("img",{src:go,className:"w-16 h-12 rounded-xl object-cover border border-gray-150 shadow-xs",alt:"Preview cover",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[s.jsx("p",{className:"text-[9px] font-black text-gray-700 uppercase tracking-wider truncate",children:"Cover Image Loaded"}),s.jsx("p",{className:"text-[8px] font-mono text-gray-400 truncate",children:go})]}),s.jsx("button",{type:"button",onClick:()=>La(""),className:"text-[9px] font-black text-red-600 bg-red-50 hover:bg-red-100 px-3 py-1.5 rounded-lg uppercase tracking-wider transition-colors cursor-pointer",children:"Remove"})]}),s.jsxs("div",{className:"pt-4 flex items-center gap-3",children:[s.jsx("button",{type:"submit",disabled:ee,className:"px-6 py-3 bg-red-600 text-white text-[10px] font-black uppercase tracking-widest rounded-xl hover:bg-red-700 transition-all flex items-center gap-2 cursor-pointer disabled:opacity-50 shadow-sm font-sans",children:ee?s.jsxs(s.Fragment,{children:[s.jsx(Er,{size:13,className:"animate-spin"})," Saving..."]}):s.jsxs(s.Fragment,{children:[ni==="video"?s.jsx(Ea,{size:13}):s.jsx(uc,{size:13}),b?`Update ${ni==="video"?"Video":"Audio"} Podcast`:`Publish ${ni==="video"?"Video":"Audio"} Episode`]})}),b&&s.jsx("button",{type:"button",onClick:Om,className:"px-4 py-3 bg-gray-100 text-gray-700 text-[10px] font-black uppercase tracking-widest rounded-xl hover:bg-gray-200 transition-all cursor-pointer font-sans",children:"Cancel Edit"})]})]})]}),s.jsxs("div",{className:"max-w-3xl",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:["📻 Active Episodes (",p.length,")"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[9px] font-mono font-bold text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded-md border border-emerald-200",children:["🎧 ",p.filter(O=>!Rl(O)).length," Audio"]}),s.jsxs("span",{className:"text-[9px] font-mono font-bold text-red-700 bg-red-50 px-2 py-0.5 rounded-md border border-red-200",children:["🎬 ",p.filter(O=>Rl(O)).length," Video"]})]})]}),p.length===0?s.jsx("div",{className:"bg-gray-50 p-8 rounded-2xl border border-gray-150 text-center text-gray-400 text-[10px] font-bold uppercase tracking-wider",children:"No podcasts have been posted yet. Use the form above to add audio or video podcasts."}):s.jsx("div",{className:"space-y-3",children:p.map(O=>{const le=Rl(O);return s.jsxs("div",{className:`bg-white p-4 rounded-2xl border transition-all text-left flex items-center gap-4 hover:shadow-xs ${le?"border-red-100 hover:border-red-300":"border-gray-150 hover:border-gray-300"}`,children:[s.jsxs("div",{className:"relative w-14 h-14 shrink-0 rounded-xl overflow-hidden bg-gray-900 border border-gray-100 shadow-3xs",children:[s.jsx("img",{src:O.thumbnail||(le?"https://images.unsplash.com/photo-1578022761797-b8636ac1773c?auto=format&fit=crop&q=80&w=200":"https://images.unsplash.com/photo-1590602847861-f357a9332bbc?auto=format&fit=crop&q=80&w=200"),className:"w-full h-full object-cover",alt:"",referrerPolicy:"no-referrer"}),s.jsxs("span",{className:`absolute bottom-1 right-1 text-[7px] font-black uppercase px-1 py-0.5 rounded flex items-center gap-0.5 text-white ${le?"bg-red-600":"bg-emerald-600"}`,children:[le?s.jsx(Ea,{size:7}):s.jsx(Zh,{size:7}),le?"VID":"AUD"]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-0.5 flex-wrap",children:[s.jsxs("span",{className:`text-[8px] font-black uppercase tracking-wider px-2 py-0.5 rounded-md flex items-center gap-1 border ${le?"bg-red-50 text-red-700 border-red-200":"bg-emerald-50 text-emerald-700 border-emerald-200"}`,children:[le?s.jsx(Ea,{size:10,className:"text-red-600"}):s.jsx(Zh,{size:10,className:"text-emerald-600"}),le?"Video Podcast":"Audio Podcast"]}),s.jsx("span",{className:"text-[8px] font-black text-gray-600 bg-gray-100 rounded px-1.5 py-0.5 uppercase tracking-wide",children:O.category||"Campus Vibe"}),s.jsxs("span",{className:"text-[8px] font-mono font-bold text-gray-400",children:["⏱️ ",O.duration||(le?"Video":"5:40")]})]}),s.jsx("h5",{className:"text-[12px] font-extrabold text-gray-950 truncate uppercase tracking-tight",children:O.title}),s.jsxs("p",{className:"text-[9px] text-gray-400 font-bold uppercase tracking-widest mt-0.5 truncate",children:["Host: ",O.author]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("button",{onClick:()=>ed(O),className:`p-2.5 rounded-xl hover:scale-105 transition-all cursor-pointer border ${le?"bg-red-50 hover:bg-red-100 text-red-600 border-red-200":"bg-emerald-50 hover:bg-emerald-100 text-emerald-700 border-emerald-200"}`,title:le?"Watch Video Episode":"Listen to Audio Episode",children:le?s.jsx(Ea,{size:13}):s.jsx(Yp,{size:13,fill:"currentColor"})}),s.jsx("button",{onClick:()=>jb(O),className:"p-2.5 bg-gray-50 hover:bg-gray-100 text-gray-700 rounded-xl transition-all cursor-pointer border border-gray-200",title:"Edit podcast details",children:s.jsx(kd,{size:13})}),s.jsx("button",{onClick:()=>Rm(O.id),className:"p-2.5 bg-red-50 hover:bg-red-100 text-red-650 rounded-xl transition-all cursor-pointer border border-red-150",title:"Delete podcast forever",children:s.jsx(As,{size:13})})]})]},O.id)})})]}),E&&s.jsx(xP,{podcast:E,onClose:()=>k(null)})]}):a==="mega-ai-knowledge"&&t?s.jsxs("div",{className:"space-y-8 font-sans text-left",children:[s.jsxs("div",{className:"border-b border-gray-100 pb-4 max-w-4xl",children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(Zi,{className:"text-amber-500",size:22})," Mega AI Knowledge Base & Query Inbox"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Manage collected smart replies for @Mega mentions, review missing query alerts, and reply to students directly."})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-xs space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-4",children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(ea,{size:16,className:"text-red-600"})," Pending Student @Mega Queries (",W.filter(O=>!O.used).length,")"]}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"Auto-notified on missing responses"})]}),W.length===0?s.jsx("div",{className:"p-8 text-center text-gray-400 text-xs font-bold uppercase tracking-wider bg-gray-50/50 rounded-2xl border border-dashed border-gray-150",children:"No student @Mega queries pending review!"}):s.jsx("div",{className:"space-y-4",children:W.map(O=>{var le;return s.jsxs("div",{className:Fe("p-5 rounded-2xl border transition-all space-y-3",O.used?"bg-gray-50/50 border-gray-150 opacity-75":"bg-amber-50/30 border-amber-200/80 shadow-xs"),children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-wider bg-amber-500 text-white px-2 py-0.5 rounded-full",children:["@",O.userName||"Student"]}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400 font-mono",children:(le=O.createdAt)!=null&&le.seconds?new Date(O.createdAt.seconds*1e3).toLocaleString():"Recent"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:Fe("text-[9px] font-black uppercase tracking-widest px-2 py-0.5 rounded-md",O.used?"bg-emerald-100 text-emerald-800":"bg-red-100 text-red-800"),children:O.used?"Answered & Learned":"Pending Response"}),s.jsx("button",{type:"button",onClick:()=>ix(O.id),className:"p-1 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors cursor-pointer",title:"Dismiss & Delete Ticket Forever",children:s.jsx(As,{size:14})})]})]}),s.jsxs("div",{className:"bg-white p-3 rounded-xl border border-gray-150 text-xs text-gray-900 font-medium",children:[s.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-amber-600 block mb-1",children:"User Query:"}),'"',O.userQuery,'"']}),!O.used&&s.jsxs("div",{className:"space-y-2 pt-2",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-500 block",children:"Official Response (Will post to student as Mega AI & save into system smart replies):"}),s.jsx("textarea",{rows:2,value:yr[O.id]!==void 0?yr[O.id]:O.generatedReply||"",onChange:Ae=>Ns(pt=>({...pt,[O.id]:Ae.target.value})),placeholder:"Type the official answer here...",className:"w-full p-3 bg-white border border-gray-200 rounded-xl text-xs font-medium text-gray-900 focus:ring-2 focus:ring-amber-500/20 outline-none"}),s.jsx("div",{className:"flex justify-end",children:s.jsxs("button",{type:"button",onClick:()=>Pm(O),className:"inline-flex items-center gap-1.5 px-4 py-2 bg-amber-500 hover:bg-amber-600 text-white text-[10px] font-black uppercase tracking-wider rounded-xl transition-all shadow-xs cursor-pointer active:scale-95",children:[s.jsx(Eo,{size:12})," Post Reply & Save to Smart Replies"]})})]})]},O.id)})})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-xs space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-4 flex-wrap gap-2",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(pl,{size:18,className:"text-amber-600"})," Requests for Unlimited Posting Approval (",ae.length,")"]})}),ae.length>0&&s.jsxs("button",{type:"button",onClick:lh,className:"px-3 py-1.5 bg-red-50 hover:bg-red-100 text-red-650 font-black text-[9px] uppercase tracking-wider rounded-xl transition-all cursor-pointer flex items-center gap-1 border border-red-200",children:[s.jsx(As,{size:12})," Clear All Requests (",ae.length,")"]})]}),ae.length===0?s.jsx("div",{className:"p-8 text-center text-gray-400 text-xs font-bold uppercase tracking-wider bg-gray-50/50 rounded-2xl border border-dashed border-gray-150",children:"No pending requests for unlimited posting approval."}):s.jsx("div",{className:"space-y-4",children:ae.map(O=>{var le;return s.jsxs("div",{className:"p-5 bg-amber-50/30 border border-amber-200/80 rounded-2xl space-y-3 shadow-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-wider bg-gray-900 text-amber-300 px-2 py-0.5 rounded-full",children:["@",O.requestAuthorName||O.userName||"Student"]}),s.jsxs("span",{className:"text-[9px] text-gray-400 font-mono",children:["UID: ",O.requestAuthorId||O.userId||"N/A"]})]}),s.jsx("span",{className:"text-[9px] font-bold text-gray-400 font-mono",children:(le=O.createdAt)!=null&&le.seconds?new Date(O.createdAt.seconds*1e3).toLocaleString():"Recent"})]}),s.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-150 text-xs text-gray-800 font-medium leading-relaxed",children:O.message||`User @${O.requestAuthorName||"Student"} requested admin approval to unlock unlimited posting on Campus Eye.`}),s.jsxs("div",{className:"flex items-center justify-end gap-2 pt-1",children:[s.jsxs("button",{type:"button",onClick:()=>tl(O.id),className:"px-3 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 font-black text-[9px] uppercase tracking-wider rounded-xl transition-all cursor-pointer flex items-center gap-1",children:[s.jsx(As,{size:12})," Dismiss & Delete"]}),s.jsxs("button",{type:"button",onClick:()=>jm(O),className:"px-4 py-1.5 bg-amber-600 hover:bg-amber-700 text-white font-black text-[9px] uppercase tracking-wider rounded-xl shadow-xs transition-all cursor-pointer flex items-center gap-1.5 active:scale-95",children:[s.jsx(pl,{size:13})," Approve User for Unlimited Posting"]})]})]},O.id)})})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-xs space-y-4",children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2 border-b border-gray-100 pb-3",children:[s.jsx(Zi,{size:16,className:"text-amber-500"})," Add New Smart Reply to Mega AI Knowledge Base"]}),s.jsxs("form",{onSubmit:Im,className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 block",children:"Question / Trigger Prompt"}),s.jsx("input",{type:"text",value:ke,onChange:O=>Ie(O.target.value),placeholder:"e.g. How do I register for KIU exams?",className:"w-full p-3 bg-gray-50 border border-gray-150 rounded-xl text-xs font-medium text-gray-900 focus:bg-white outline-none"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 block",children:"Matching Keywords (Comma Separated)"}),s.jsx("input",{type:"text",value:Yt,onChange:O=>Wt(O.target.value),placeholder:"e.g. kiu, exam, registration, portal, schedule",className:"w-full p-3 bg-gray-50 border border-gray-150 rounded-xl text-xs font-medium text-gray-900 focus:bg-white outline-none"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 block",children:"Smart Automated Answer"}),s.jsx("textarea",{rows:3,value:We,onChange:O=>ht(O.target.value),placeholder:"e.g. KIU exam registration is completed through the student portal under Academic Services before Week 8.",className:"w-full p-3 bg-gray-50 border border-gray-150 rounded-xl text-xs font-medium text-gray-900 focus:bg-white outline-none"})]}),s.jsx("div",{className:"flex justify-end",children:s.jsxs("button",{type:"submit",disabled:zt,className:"inline-flex items-center gap-2 px-5 py-2.5 bg-black hover:bg-gray-800 text-white text-[10px] font-black uppercase tracking-wider rounded-xl transition-all shadow-sm cursor-pointer disabled:opacity-50",children:[s.jsx(Zi,{size:14,className:"text-amber-400"})," Save Smart Reply Entry"]})})]})]}),Ua&&s.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-xs z-50 flex items-center justify-center p-4",children:s.jsxs("div",{className:"bg-white rounded-3xl p-6 max-w-2xl w-full border border-gray-100 shadow-2xl space-y-5 animate-in fade-in zoom-in-95 duration-150",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-3",children:[s.jsxs("h4",{className:"text-sm font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(kd,{size:18,className:"text-indigo-600"})," Edit & Correct AI Knowledge Entry"]}),s.jsx("button",{type:"button",onClick:Jc,className:"p-1.5 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors",children:s.jsx(er,{size:18})})]}),s.jsxs("form",{onSubmit:Sb,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-500 block",children:"Question / User Query"}),s.jsx("input",{type:"text",value:hi,onChange:O=>Os(O.target.value),className:"w-full p-3 bg-gray-50 border border-gray-200 rounded-xl text-xs font-medium text-gray-900 focus:bg-white focus:ring-2 focus:ring-indigo-500/20 outline-none",placeholder:"e.g. How do I register for KIU exams?"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-500 block",children:"Matching Keywords (Comma Separated)"}),s.jsx("input",{type:"text",value:Wl,onChange:O=>oh(O.target.value),className:"w-full p-3 bg-gray-50 border border-gray-200 rounded-xl text-xs font-medium text-gray-900 focus:bg-white focus:ring-2 focus:ring-indigo-500/20 outline-none",placeholder:"e.g. kiu, exam, registration, portal"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-500 block",children:"Corrected Official Answer"}),s.jsx("textarea",{rows:4,value:xa,onChange:O=>ql(O.target.value),className:"w-full p-3 bg-gray-50 border border-gray-200 rounded-xl text-xs font-medium text-gray-900 focus:bg-white focus:ring-2 focus:ring-indigo-500/20 outline-none leading-relaxed",placeholder:"Type the accurate smart answer here..."})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 pt-2",children:[s.jsx("button",{type:"button",onClick:Jc,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 text-[10px] font-black uppercase tracking-wider rounded-xl transition-all",children:"Cancel"}),s.jsxs("button",{type:"submit",disabled:Df,className:"inline-flex items-center gap-1.5 px-5 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-[10px] font-black uppercase tracking-wider rounded-xl transition-all shadow-sm disabled:opacity-50 cursor-pointer",children:[s.jsx(rR,{size:14})," Update Knowledge Entry"]})]})]})]})}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-xs space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-3 flex-wrap gap-2",children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(Zi,{size:16,className:"text-amber-500"})," System-Wide AI Knowledge & Responses (",P.length,")"]}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"Editable by Admin in Realtime"})]}),P.length===0?s.jsx("p",{className:"text-xs font-bold text-gray-400 text-center py-6",children:"No smart replies or AI responses added yet. Add one above or trigger an @Mega AI query!"}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:P.map(O=>s.jsxs("div",{className:"p-4 bg-gray-50/70 border border-gray-150 rounded-2xl flex flex-col justify-between space-y-3 hover:shadow-xs transition-shadow",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest px-2 py-0.5 rounded-full bg-amber-100 text-amber-900 border border-amber-200/60",children:O.source==="ai_generated"?"🤖 AI Generated":O.source==="admin_ticket_reply"?"👤 Admin Reply":"✨ Knowledge Base"}),O.askedBy&&s.jsxs("span",{className:"text-[8px] font-bold text-gray-400",children:["by @",O.askedBy]})]}),s.jsxs("span",{className:"text-[10px] font-black uppercase text-gray-900 tracking-wider block",children:["Q: ",O.question]})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsxs("button",{type:"button",onClick:()=>sx(O),className:"p-1.5 text-indigo-600 hover:text-indigo-800 hover:bg-indigo-50 rounded-lg transition-colors cursor-pointer flex items-center gap-1 text-[9px] font-black uppercase tracking-wider",title:"Edit & Update response",children:[s.jsx(kd,{size:13})," Edit"]}),s.jsx("button",{type:"button",onClick:()=>Tm(O.id),className:"p-1.5 text-red-500 hover:text-red-700 hover:bg-red-50 rounded-lg transition-colors cursor-pointer",title:"Delete response",children:s.jsx(As,{size:13})})]})]}),s.jsx("p",{className:"text-xs text-gray-800 font-medium leading-relaxed bg-white p-3 rounded-xl border border-gray-100",children:O.answer})]}),O.keywords&&O.keywords.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:O.keywords.map((le,Ae)=>s.jsxs("span",{className:"text-[8px] font-black uppercase tracking-widest bg-gray-200/60 text-gray-700 px-2 py-0.5 rounded-full",children:["#",le]},Ae))})]},O.id))})]})]}):a==="seo-indexing"&&t?s.jsxs("div",{className:"space-y-8 font-sans text-left animate-fade-in max-w-5xl",children:[s.jsx("div",{className:"border-b border-gray-100 pb-4",children:s.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl bg-emerald-50 text-emerald-600 border border-emerald-200 flex items-center justify-center font-bold",children:s.jsx(S0,{size:22})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:"Google Search Console & Real-Time SEO Engine"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-0.5",children:"Real-time automatic discovery, XML sitemaps, Google News, and WebSub indexing pipeline"})]})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[9px] font-mono font-black bg-emerald-50 text-emerald-700 border border-emerald-200",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse"}),"Real-Time Push Active"]})})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-150 shadow-xs space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Google Search Console"}),s.jsx(lc,{size:14,className:"text-emerald-500"})]}),s.jsx("p",{className:"text-base font-black text-gray-900 tracking-tight",children:"Real-Time Pings"}),s.jsx("p",{className:"text-[10px] text-gray-500 font-medium",children:"Automatic sitemap pings sent directly to Google on every article publish"})]}),s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-150 shadow-xs space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Universal IndexNow"}),s.jsx(lc,{size:14,className:"text-emerald-500"})]}),s.jsx("p",{className:"text-base font-black text-gray-900 tracking-tight",children:"Bing & Yandex"}),s.jsx("p",{className:"text-[10px] text-gray-500 font-medium",children:"Instant indexing notifications via RFC IndexNow protocol key"})]}),s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-150 shadow-xs space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Googlebot WebSub"}),s.jsx(lc,{size:14,className:"text-emerald-500"})]}),s.jsx("p",{className:"text-base font-black text-gray-900 tracking-tight",children:"PubSubHubbub"}),s.jsx("p",{className:"text-[10px] text-gray-500 font-medium",children:"Real-time RSS & Atom hub notifications for Google News & Search"})]})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-150 shadow-xs space-y-6",children:[s.jsxs("div",{children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(Eo,{size:15,className:"text-emerald-600"})," Instant Push & Search Engine Notification"]}),s.jsx("p",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-widest mt-0.5",children:"Broadcast site changes and newly added articles to Google, Bing, and major search crawlers immediately"})]}),$n&&s.jsxs("div",{className:"p-4 bg-emerald-50 border border-emerald-200 rounded-2xl text-xs font-bold text-emerald-800 flex items-center gap-2",children:[s.jsx(lc,{size:16,className:"text-emerald-600 shrink-0"}),s.jsx("span",{children:$n})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 pt-2",children:[s.jsxs("div",{className:"p-5 bg-gray-50/80 rounded-2xl border border-gray-200 space-y-3 flex flex-col justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h5",{className:"text-xs font-black text-gray-900 uppercase",children:"Push All Articles & Sitemaps"}),s.jsx("p",{className:"text-[10px] text-gray-500 font-medium",children:"Regenerates dynamic XML sitemaps and dispatches instant pings to Google Search Console, Google News, and IndexNow."})]}),s.jsx("button",{type:"button",onClick:bt,disabled:Qe,className:"w-full py-3 px-4 bg-emerald-600 hover:bg-emerald-700 text-white text-[10px] font-black uppercase tracking-wider rounded-xl transition-all shadow-xs flex items-center justify-center gap-2 cursor-pointer disabled:opacity-50 active:scale-98",children:Qe?s.jsxs(s.Fragment,{children:[s.jsx(Er,{size:14,className:"animate-spin"}),s.jsx("span",{children:"Pushing to Search Engines..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(S0,{size:14}),s.jsx("span",{children:"Push All to Google Search Console Now"})]})})]}),s.jsxs("form",{onSubmit:yn,className:"p-5 bg-gray-50/80 rounded-2xl border border-gray-200 space-y-3 flex flex-col justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h5",{className:"text-xs font-black text-gray-900 uppercase",children:"Submit Specific Article / Page URL"}),s.jsx("p",{className:"text-[10px] text-gray-500 font-medium",children:"Enter any article link or page path to trigger an immediate crawler priority ping."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"url",value:Fn,onChange:O=>xn(O.target.value),placeholder:"https://campuseyemedia.com/articles=title/id",className:"w-full px-3.5 py-2.5 bg-white border border-gray-250 rounded-xl text-xs font-medium text-gray-900 outline-none focus:border-emerald-600 transition-all font-mono"}),s.jsx("button",{type:"submit",disabled:kn||!Fn.trim(),className:"w-full py-2.5 px-4 bg-gray-900 hover:bg-black text-white text-[10px] font-black uppercase tracking-wider rounded-xl transition-all shadow-xs flex items-center justify-center gap-2 cursor-pointer disabled:opacity-50",children:kn?s.jsxs(s.Fragment,{children:[s.jsx(Er,{size:14,className:"animate-spin"}),s.jsx("span",{children:"Submitting URL..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(Eo,{size:12}),s.jsx("span",{children:"Submit URL to Search Engines"})]})})]})]})]})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-150 shadow-xs space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(Fx,{size:15,className:"text-accent"})," Live XML Sitemaps & RSS/Atom Feeds"]}),s.jsx("p",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-widest mt-0.5",children:"Canonical indexing endpoints registered with Googlebot and search engines"})]}),s.jsx("button",{type:"button",onClick:ln,className:"p-2 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-xl transition-colors cursor-pointer",title:"Refresh SEO Stats",children:s.jsx(uF,{size:14})})]}),s.jsx("div",{className:"divide-y divide-gray-100 border border-gray-150 rounded-2xl overflow-hidden",children:[{name:"Primary XML Sitemap",path:"/sitemap.xml",fullUrl:"https://campuseyemedia.com/sitemap.xml",target:"Google, Bing, Yandex",desc:"All published articles, podcasts, polls, and custom menu links."},{name:"Google News XML Sitemap",path:"/news-sitemap.xml",fullUrl:"https://campuseyemedia.com/news-sitemap.xml",target:"Googlebot-News",desc:"Formatted with publication schema for fast Google News inclusion."},{name:"RSS 2.0 WebSub Feed",path:"/rss.xml",fullUrl:"https://campuseyemedia.com/rss.xml",target:"Google PubSubHubbub",desc:"Live RSS 2.0 feed with real-time push hub declarations for search crawlers."},{name:"Atom 1.0 Feed",path:"/atom.xml",fullUrl:"https://campuseyemedia.com/atom.xml",target:"Atom Crawlers",desc:"Standardized Atom format for news aggregators and discovery."},{name:"IndexNow Verification Key",path:"/ed20d91d9047466aa5bc515668e0d6c9.txt",fullUrl:"https://campuseyemedia.com/ed20d91d9047466aa5bc515668e0d6c9.txt",target:"Universal IndexNow",desc:"Cryptographic ownership verification key enabling push indexing without human verification delays."},{name:"Robots Directives",path:"/robots.txt",fullUrl:"https://campuseyemedia.com/robots.txt",target:"All Web Crawlers",desc:"Robots directives pointing search spiders to canonical sitemaps and allowing public content."}].map((O,le)=>s.jsxs("div",{className:"p-4 hover:bg-gray-50/50 transition-colors flex items-center justify-between gap-4 flex-wrap",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-xs font-black text-gray-900 uppercase",children:O.name}),s.jsx("span",{className:"text-[8px] font-black uppercase font-mono px-2 py-0.5 bg-gray-100 text-gray-600 rounded-md",children:O.target})]}),s.jsx("p",{className:"text-[10px] text-gray-500 font-medium",children:O.desc}),s.jsx("p",{className:"text-[9px] font-mono text-gray-400 break-all",children:O.fullUrl})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs("a",{href:O.path,target:"_blank",rel:"noreferrer",className:"px-3 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-800 text-[9px] font-black uppercase tracking-wider rounded-xl transition-all cursor-pointer flex items-center gap-1",children:[s.jsx(I1,{size:11})," View Output"]})})]},le))})]}),(ue==null?void 0:ue.recentPushes)&&ue.recentPushes.length>0&&s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-150 shadow-xs space-y-4",children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(J5,{size:15,className:"text-gray-400"})," Recent Search Engine Push History"]}),s.jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto pr-1",children:ue.recentPushes.map((O,le)=>{var Ae;return s.jsxs("div",{className:"p-3 bg-gray-50 rounded-xl border border-gray-150 flex items-center justify-between text-xs font-medium gap-4",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[9px] font-black uppercase text-emerald-700 bg-emerald-100 px-2 py-0.5 rounded-md",children:["Pushed ",O.urlCount||1," URL(s)"]}),s.jsx("span",{className:"text-[9px] text-gray-400 font-mono",children:new Date(O.timestamp).toLocaleTimeString()})]}),s.jsx("p",{className:"text-[10px] font-mono text-gray-600 truncate",children:(Ae=O.urls)==null?void 0:Ae.slice(0,3).join(", ")})]}),s.jsx("span",{className:"text-[9px] font-bold text-gray-400 font-mono shrink-0",children:new Date(O.timestamp).toLocaleDateString()})]},le)})})]})]}):s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[s.jsx("div",{className:"w-20 h-20 bg-gray-50 rounded-full flex items-center justify-center text-gray-300 mb-6",children:s.jsx(pl,{size:40})}),s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Access Restricted"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-2 max-w-xs",children:"You don't have the necessary permissions to view this section. Please contact the administrator."})]})]})]})]})};let OS=null;const TMe=()=>{const[e,t]=ie.useState(OS||[]),[n,r]=ie.useState(!OS),[i,a]=ie.useState(null),[o,c]=ie.useState(1),[h,f]=ie.useState(!1),[m,y]=ie.useState(!1),[w,A]=ie.useState(!1);ie.useEffect(()=>{(async()=>{var K,Z,q,B;if(Ne.currentUser){const z=["atwiinevictor2@gmail.com","campuseye@gmail.com"];try{const F=await cs(Je(he,"admins",Ne.currentUser.uid)),$=await cs(Je(he,"users",Ne.currentUser.uid)),Y=F.exists()&&((K=F.data())==null?void 0:K.isAdmin)===!0||$.exists()&&(((Z=$.data())==null?void 0:Z.isAdmin)===!0||((q=$.data())==null?void 0:q.role)==="admin")||z.includes(Ne.currentUser.email||"");A(Y)}catch{A(z.includes(((B=Ne.currentUser)==null?void 0:B.email)||""))}}else A(!1)})()},[]);const S=L=>L?typeof L.toDate=="function"?L.toDate():L instanceof Date?L:L.seconds!==void 0?new Date(L.seconds*1e3):typeof L=="string"||typeof L=="number"?new Date(L):null:null,C=L=>{const K=S(L);if(!K)return"EVT";try{return K.toLocaleString("default",{month:"short"}).toUpperCase()}catch{return"EVT"}},T=L=>{const K=S(L);if(!K)return"00";try{return K.getDate()}catch{return"01"}},D=L=>{const K=S(L);if(!K)return"TBA";try{return K.toLocaleString([],{dateStyle:"medium",timeStyle:"short"})}catch{return"TBA"}};ie.useEffect(()=>{const L=Qt(et(he,"tickets"),ui("createdAt","desc"));vn(L).then(K=>{const Z=K.docs.map(q=>({id:q.id,...q.data()}));t(Z),OS=Z,r(!1)}).catch(K=>{Ks(K,Ms.LIST,"tickets"),r(!1)})},[]);const V=async()=>{var L,K,Z;if(!Ne.currentUser||!i){pe.error("Please login to purchase tickets");return}if(o>i.remainingQuantity){pe.error("Not enough tickets remaining");return}if(!Ne.currentUser){pe.error("Please sign in to purchase tickets");return}f(!0);try{const q={ticketId:i.id,ticketTitle:i.title,userId:((L=Ne.currentUser)==null?void 0:L.uid)||"",userName:((K=Ne.currentUser)==null?void 0:K.displayName)||"Anonymous",userEmail:((Z=Ne.currentUser)==null?void 0:Z.email)||"",price:i.price,totalAmount:i.price*o,quantity:o,purchaseDate:_r.now(),status:"confirmed"};await ur(et(he,"purchases"),q),await Cn(Je(he,"tickets",i.id),{remainingQuantity:Ir(-o)}),pe.success("Ticket purchased successfully!"),y(!0),setTimeout(()=>{y(!1),a(null),c(1)},3e3)}catch(q){console.error("Purchase error:",q),pe.error("Failed to process purchase")}finally{f(!1)}};return n?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 gap-4",children:[s.jsx(Er,{className:"animate-spin text-red-600",size:40}),s.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.2em] text-gray-400",children:"Loading Campus Events..."})]}):s.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:[s.jsxs("div",{className:"flex flex-col md:flex-row md:items-end justify-between gap-6 mb-12",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h2",{className:"text-4xl font-black uppercase italic tracking-tighter text-gray-900 flex items-center gap-4",children:["Campus Box Office ",s.jsx(Aa,{className:"text-red-600",size:32})]}),s.jsx("p",{className:"text-xs font-bold text-gray-400 uppercase tracking-[0.3em]",children:"Official portal for university events & experiences"})]}),s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"bg-white px-6 py-4 border border-gray-100 rounded-3xl shadow-sm text-center min-w-[120px]",children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest mb-1",children:"Available Events"}),s.jsx("p",{className:"text-xl font-black text-gray-900",children:e.length})]}),s.jsxs("div",{className:"bg-black px-6 py-4 rounded-3xl shadow-xl shadow-black/10 text-center min-w-[120px]",children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest mb-1",children:"Status"}),s.jsx("p",{className:"text-xl font-black text-green-400",children:"SECURE"})]})]})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8",children:e.map(L=>s.jsxs(Zt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"group bg-white rounded-[2.5rem] border border-gray-100 shadow-sm hover:shadow-xl hover:-translate-y-1 transition-all overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"relative aspect-[4/3] overflow-hidden",children:[s.jsx(Li,{src:L.imageUrl,alt:L.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"}),s.jsx("div",{className:"absolute top-4 right-4 px-3 py-1 bg-white/90 backdrop-blur-sm rounded-full text-[10px] font-black uppercase tracking-widest text-red-600 shadow-sm",children:L.category}),L.remainingQuantity<10&&L.remainingQuantity>0&&s.jsxs("div",{className:"absolute bottom-4 left-4 px-3 py-1 bg-red-600 text-white rounded-full text-[9px] font-black uppercase tracking-widest",children:["Only ",L.remainingQuantity," Left!"]}),L.remainingQuantity<=0&&s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-[2px] flex items-center justify-center",children:s.jsx("span",{className:"px-6 py-2 bg-white text-black text-sm font-black uppercase tracking-[0.3em] rounded-full",children:"Sold Out"})})]}),s.jsxs("div",{className:"p-8 flex-1 flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsxs("div",{className:"w-10 h-10 bg-red-50 text-red-600 rounded-xl flex flex-col items-center justify-center",children:[s.jsx("span",{className:"text-[10px] font-black leading-none",children:C(L.eventDate)}),s.jsx("span",{className:"text-sm font-black leading-none",children:T(L.eventDate)})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-xl font-black text-gray-900 uppercase tracking-tight truncate leading-tight",children:L.title}),s.jsxs("div",{className:"flex items-center gap-2 text-gray-400 mt-0.5",children:[s.jsx(BS,{size:12}),s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider truncate",children:L.venue})]})]})]}),s.jsx("p",{className:"text-sm text-gray-500 font-medium line-clamp-2 mb-6",children:L.description}),L.link&&s.jsx("div",{className:"mb-6 -mt-3",children:s.jsxs("a",{href:L.link,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-blue-650 font-black uppercase tracking-wider hover:underline",onClick:K=>K.stopPropagation(),children:[s.jsx("span",{children:"Visit Event Link"}),s.jsx(Wp,{size:14,className:"text-blue-600"})]})}),s.jsxs("div",{className:"mt-auto pt-6 border-t border-gray-50 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest mb-1 leading-none",children:"Public Price"}),s.jsxs("p",{className:"text-2xl font-black text-gray-900 leading-none",children:[s.jsx("span",{className:"text-sm",children:"UGX"})," ",L.price.toLocaleString()]})]}),s.jsx("button",{onClick:()=>a(L),disabled:L.remainingQuantity<=0,className:Fe("px-6 py-4 rounded-2xl text-[10px] font-black uppercase tracking-widest transition-all",L.remainingQuantity>0?"bg-red-600 text-white hover:bg-red-700 shadow-lg shadow-red-200":"bg-gray-100 text-gray-400 cursor-not-allowed"),children:"Book Ticket"})]}),w&&s.jsxs("div",{className:"mt-6 pt-4 border-t border-dashed border-gray-150 flex gap-3",children:[s.jsx("button",{onClick:K=>{K.stopPropagation(),localStorage.setItem("edit_ticket_item",JSON.stringify(L));const Z=new CustomEvent("setTab",{detail:"admin"});window.dispatchEvent(Z),setTimeout(()=>{window.dispatchEvent(new CustomEvent("checkPendingTicketEdit"))},100)},className:"flex-1 py-3 bg-blue-50 text-blue-600 rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-blue-600 hover:text-white transition-all text-center",children:"Edit Event"}),w&&s.jsx("button",{onClick:async K=>{if(K.stopPropagation(),!w){pe.error("Access Denied: Only admins can delete tickets.");return}if(window.confirm("Are you sure you want to permanently delete this event ticket?"))try{await si(Je(he,"tickets",L.id)),pe.success("Event ticket deleted successfully"),t(Z=>Z.filter(q=>q.id!==L.id))}catch(Z){pe.error("Failed to delete event ticket: "+Z.message)}},className:"flex-1 py-3 bg-red-50 text-red-650 rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-red-600 hover:text-white transition-all text-center",title:"Delete Ticket (Master Admin)",children:"Delete"})]})]})]},L.id))}),s.jsx(or,{children:i&&s.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[s.jsx(Zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>!h&&a(null),className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),s.jsx(Zt.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},className:"relative w-full max-w-xl bg-white rounded-[3rem] shadow-2xl overflow-hidden",children:m?s.jsxs("div",{className:"p-12 text-center space-y-6",children:[s.jsx("div",{className:"w-20 h-20 bg-green-100 text-green-600 rounded-full flex items-center justify-center mx-auto scale-110",children:s.jsx(Bu,{size:48,strokeWidth:3})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"text-3xl font-black uppercase italic tracking-tighter text-gray-900",children:"Ticket Secured!"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-[0.3em]",children:"Transaction verified & recorded"})]}),s.jsx("p",{className:"text-sm text-gray-600 font-medium max-w-xs mx-auto",children:"Your digital ticket has been sent to your account. Please present the QR code at the venue."}),s.jsx("div",{className:"pt-4",children:s.jsx("button",{onClick:()=>a(null),className:"px-8 py-4 bg-black text-white rounded-2xl text-[10px] font-black uppercase tracking-widest hover:bg-gray-900 transition-all",children:"Close Window"})})]}):s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"relative h-48",children:[s.jsx(Li,{src:i.imageUrl,className:"w-full h-full object-cover",alt:""}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-white via-white/20 to-transparent"}),s.jsx("button",{onClick:()=>a(null),disabled:h,className:"absolute top-6 right-6 p-3 bg-white/90 backdrop-blur-sm rounded-2xl text-gray-900 hover:bg-white transition-all shadow-lg",children:s.jsx(er,{size:20})})]}),s.jsx("div",{className:"p-10 -mt-20 relative",children:s.jsxs("div",{className:"bg-white p-8 rounded-[2rem] border border-gray-100 shadow-xl space-y-6",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-[10px] font-black text-red-600 uppercase tracking-[0.2em]",children:i.category}),s.jsx("h2",{className:"text-3xl font-black text-gray-900 uppercase tracking-tighter leading-tight",children:i.title})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-gray-50 rounded-xl",children:s.jsx(rg,{size:18,className:"text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Date & Time"}),s.jsx("p",{className:"text-xs font-black text-gray-900 uppercase",children:D(i.eventDate)})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-gray-50 rounded-xl",children:s.jsx(BS,{size:18,className:"text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Location"}),s.jsx("p",{className:"text-xs font-black text-gray-900 uppercase",children:i.venue})]})]})]}),s.jsxs("div",{className:"space-y-4 pt-6 border-t border-gray-100",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm font-black text-gray-900 uppercase tracking-widest",children:"Select Quantity"}),s.jsxs("div",{className:"flex items-center gap-4 bg-gray-50 p-2 rounded-2xl border border-gray-100",children:[s.jsx("button",{onClick:()=>c(Math.max(1,o-1)),className:"w-10 h-10 flex items-center justify-center text-xl font-bold bg-white text-gray-900 rounded-xl hover:bg-gray-200 transition-all shadow-sm",children:"-"}),s.jsx("span",{className:"text-xl font-black text-gray-900 w-8 text-center",children:o}),s.jsx("button",{onClick:()=>c(Math.min(i.remainingQuantity,o+1)),className:"w-10 h-10 flex items-center justify-center text-xl font-bold bg-white text-gray-900 rounded-xl hover:bg-gray-200 transition-all shadow-sm",children:"+"})]})]}),s.jsxs("div",{className:"bg-red-50 p-6 rounded-2xl border border-red-100 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-black text-red-400 uppercase tracking-widest mb-1 leading-none",children:"Total Payable"}),s.jsxs("p",{className:"text-3xl font-black text-red-600 leading-none tracking-tighter",children:[s.jsx("span",{className:"text-sm",children:"UGX"})," ",(i.price*o).toLocaleString()]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-[10px] font-black text-red-600/50 uppercase tracking-widest",children:"Digital Entry"}),s.jsx("div",{className:"flex gap-1 mt-1",children:[1,2,3].map(L=>s.jsx("div",{className:"w-6 h-1 bg-red-600/20 rounded-full"},L))})]})]})]}),s.jsx("button",{onClick:V,disabled:h,className:"w-full py-5 bg-red-600 text-white rounded-2xl text-[10px] font-black uppercase tracking-[0.3em] hover:bg-red-700 transition-all shadow-xl shadow-red-200 disabled:opacity-50 flex items-center justify-center gap-3",children:h?s.jsxs(s.Fragment,{children:[s.jsx(Er,{className:"animate-spin",size:20}),"Authorizing Transaction..."]}):s.jsxs(s.Fragment,{children:[s.jsx(pl,{size:20}),"Confirm Booking"]})})]})})]})})]})})]})},RV=({onAuthSuccess:e,onClose:t,className:n,isAdmin:r,onAdminClick:i})=>{const[a,o]=ie.useState(Ne.currentUser),[c,h]=ie.useState(null);ie.useEffect(()=>{try{const Ee=localStorage.getItem("pending_follow_name");Ee&&h(Ee)}catch{}},[]);const[f,m]=ie.useState(!1),[y,w]=ie.useState("signin"),[A,S]=ie.useState(""),[C,T]=ie.useState(""),[D,V]=ie.useState(!1),[L,K]=ie.useState(""),[Z,q]=ie.useState(!1),[B,z]=ie.useState(""),[F,$]=ie.useState(""),[Y,X]=ie.useState(""),[J,ye]=ie.useState(!1),[ne,de]=ie.useState(null),[be,Ce]=ie.useState(null),[Ke,G]=ie.useState(!1);ie.useEffect(()=>{if(y!=="signup"||!F.trim()){Ce(null),G(!1);return}const yt=setTimeout(async()=>{G(!0);try{const Ue=F.trim().toLowerCase();if(Ue.length<3){Ce(!1),G(!1);return}const Vt=Qt(et(he,"users"),Ar("username","==",Ue)),St=await vn(Vt);Ce(St.empty)}catch(Ue){console.warn("Username availability check bypassed:",Ue),Ce(!0)}finally{G(!1)}},400);return()=>clearTimeout(yt)},[F,y]);const se=A.includes("@")&&A.includes("."),xe=C.length===0?0:C.length<6?1:C.length<10?2:3,re=C.length>=6,Me=C===L,nt=y==="signin"?se&&re:se&&re&&F.trim().length>=3&&be===!0&&Me;ie.useEffect(()=>Ne.onAuthStateChanged(Ee=>o(Ee)),[]);const ze=async()=>{m(!0),de(null);try{const Ee=await tle(Ne,UG);await It(Ee.user),e&&e()}catch(Ee){if(console.error("Error signing in with Google:",Ee),Ee.code==="auth/popup-closed-by-user")de("Sign-in popup was closed. Please try again or create an Email account below.");else if(Ee.code==="auth/popup-blocked"||Ee.code==="auth/disallowed_useragent")de(s.jsxs("div",{className:"space-y-3 text-left",children:[s.jsx("p",{className:"font-bold text-gray-900 text-xs",children:"Google OAuth is restricted inside embedded preview frames or mobile WebViews."}),s.jsxs("p",{className:"text-[10px] text-gray-600 leading-relaxed",children:["Please open the app in a new browser window/tab to sign in with Google, or log in using ",s.jsx("b",{className:"text-red-600",children:"Email & Password"})," below."]}),s.jsxs("div",{className:"flex flex-col gap-2 pt-1",children:[s.jsx("button",{type:"button",onClick:()=>window.open(window.location.href,"_blank"),className:"w-full py-2 bg-indigo-600 text-white text-[10px] font-black uppercase tracking-widest rounded-lg hover:bg-indigo-700 transition-all cursor-pointer shadow-sm",children:"Open App in New Tab to Sign In"}),s.jsx("button",{type:"button",onClick:()=>w("signup"),className:"w-full py-2 bg-gray-100 text-gray-800 text-[10px] font-black uppercase tracking-widest rounded-lg hover:bg-gray-200 transition-all cursor-pointer",children:"Create Email Account (Instant Login)"})]})]}));else if(Ee.code==="auth/unauthorized-domain")de(s.jsxs("div",{className:"space-y-2 text-left",children:[s.jsx("p",{className:"font-bold text-red-600 text-xs",children:"Domain authorization check required."}),s.jsxs("p",{className:"text-[10px] text-gray-600 leading-relaxed",children:["Security policy requires running from an authorized domain (",window.location.hostname,"). You can log in using ",s.jsx("b",{className:"text-red-600",children:"Email & Password"})," below."]})]}));else if(Ee.code==="auth/internal-error"||Ee.code==="auth/network-request-failed")de(s.jsxs("div",{className:"space-y-3 text-left",children:[s.jsx("p",{className:"text-xs text-gray-800",children:"Connection error. If using an embedded frame, try opening in a new browser tab."}),s.jsxs("div",{className:"flex flex-col gap-2 pt-1",children:[s.jsx("button",{type:"button",onClick:()=>window.open(window.location.href,"_blank"),className:"w-full py-2 bg-indigo-600 text-white text-[10px] font-black uppercase tracking-widest rounded-lg hover:bg-indigo-700 transition-all cursor-pointer shadow-sm",children:"Open in New Tab & Try Google Login"}),s.jsx("button",{type:"button",onClick:()=>w("signup"),className:"w-full py-2 bg-gray-100 text-gray-800 text-[10px] font-black uppercase tracking-widest rounded-lg hover:bg-gray-200 transition-all cursor-pointer",children:"Sign Up with Email & Password"})]})]}));else if(Ee.code==="auth/operation-not-allowed")de("Google Sign-In is temporarily disabled on this domain. Please log in or register with Email & Password.");else{const yt=(Ee.message||"").replace(/firebase/gi,"Campus Eye Auth").replace(/auth\/[a-z-]+/gi,"Login Service");de(yt||"An unexpected error occurred during Google Sign-In.")}}finally{m(!1)}},Tt=async Ee=>{Ee.preventDefault(),m(!0),de(null);try{if(y==="signup"){const yt=F.trim().toLowerCase(),Ue=await Toe(Ne,A,C),Vt=`https://ui-avatars.com/api/?name=${encodeURIComponent(yt||"User")}&background=random`;await t$(Ue.user,{displayName:yt,photoURL:Vt}),await It({...Ue.user,photoURL:Vt},yt,yt),localStorage.setItem("just_signed_up","true")}else{const yt=await Poe(Ne,A,C);await It(yt.user)}e&&e()}catch(yt){console.error("Email auth error:",yt),de(y==="signin"?"Wrong password or email":yt.message||"An error occurred during registration.")}finally{m(!1)}},It=async(Ee,yt,Ue)=>{var Vt,St,tn,Pt,Nt,Kt,ut,Jt,Dt,hn;try{const qn=Je(he,"users",Ee.uid),mn=await cs(qn),Ve=["atwiinevictor2@gmail.com","campuseye@gmail.com"].includes(Ee.email||""),Mt={uid:Ee.uid,email:Ee.email||"",displayName:yt||Ee.displayName||((Vt=mn.data())==null?void 0:Vt.displayName)||"Campus Member",username:Ue||((St=mn.data())==null?void 0:St.username)||((tn=Ee.email)==null?void 0:tn.split("@")[0])||"user",photoURL:Ee.photoURL||((Pt=mn.data())==null?void 0:Pt.photoURL)||`https://ui-avatars.com/api/?name=${encodeURIComponent(yt||Ee.displayName||"User")}&background=random`,role:((Nt=mn.data())==null?void 0:Nt.role)||(Ve?"admin":"user"),isAdmin:((Kt=mn.data())==null?void 0:Kt.isAdmin)??Ve,createdAt:((ut=mn.data())==null?void 0:ut.createdAt)||En(),updatedAt:En()};await Rr(qn,Mt,{merge:!0}),(Ve||(Jt=mn.data())!=null&&Jt.isAdmin)&&await Rr(Je(he,"admins",Ee.uid),{email:Ee.email||"",isAdmin:!0,createdAt:((Dt=mn.data())==null?void 0:Dt.createdAt)||En()},{merge:!0})}catch(qn){if(qn.code==="permission-denied"||(hn=qn.message)!=null&&hn.includes("insufficient permissions")){const mn={error:qn.message,operationType:"write",path:`users/${Ee.uid}`,authInfo:{userId:Ee.uid,email:Ee.email,emailVerified:Ee.emailVerified}};console.error("Firestore Permission Error:",JSON.stringify(mn))}else console.error("Error syncing user to Firestore:",qn)}},ft=ie.useRef(!1);return ie.useEffect(()=>{a&&!ft.current&&(ft.current=!0,e?e():t&&t())},[a]),a?s.jsxs("div",{className:"flex flex-col items-center justify-center p-12 bg-white rounded-3xl shadow-xl border border-gray-100 min-h-[300px]",children:[s.jsx(Er,{className:"animate-spin text-red-650 mb-3",size:32}),s.jsx("p",{className:"text-xs font-black uppercase tracking-widest text-[#9B2C2C]",children:"Accessing Campus Feed..."})]}):s.jsxs("div",{className:Fe("flex flex-col w-full max-w-lg mx-auto bg-white overflow-y-auto max-h-[88vh] custom-scrollbar relative shadow-2xl rounded-3xl border border-gray-100",n),children:[t&&s.jsx("button",{onClick:t,className:"absolute top-4 right-4 p-2 text-gray-400 hover:text-red-600 transition-all hover:rotate-90 z-30 bg-gray-50 hover:bg-red-50 rounded-full",title:"Close Modal",children:s.jsx(er,{size:20})}),s.jsxs("div",{className:"relative z-10 flex flex-col items-center p-6 md:p-8 space-y-5",children:[s.jsxs(Zt.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},className:"flex flex-col items-center space-y-2 text-center",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1 select-none",children:[s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Campus Eye Media Logo",className:"h-11 w-11 rounded-full border border-gray-950 object-cover shadow-sm shrink-0",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"flex flex-col text-left -space-y-1",children:[s.jsxs("span",{className:"text-base font-serif font-black italic",children:[s.jsx("span",{className:"text-red-650",children:"Campus"})," ",s.jsx("span",{className:"text-blue-600",children:"Eye"})]}),s.jsx("span",{className:"text-[7.5px] font-sans font-extrabold uppercase tracking-[0.25em] text-black",children:"Media"})]})]}),s.jsx("h3",{className:"text-2xl font-bold text-gray-900 tracking-tight",children:y==="signin"?"Welcome Back":"Create Account"}),s.jsx("p",{className:"text-sm text-gray-500",children:y==="signin"?"Enter your details to access your account":"Join our community of campus citizens"})]}),s.jsxs("div",{className:"flex w-full bg-gray-50 rounded-xl p-1 border border-gray-100",children:[s.jsx("button",{onClick:()=>w("signin"),className:Fe("flex-1 py-2.5 text-xs font-semibold rounded-lg transition-all duration-300",y==="signin"?"bg-white text-red-600 shadow-sm":"text-gray-500 hover:text-gray-700"),children:"Login"}),s.jsx("button",{onClick:()=>w("signup"),className:Fe("flex-1 py-2.5 text-xs font-semibold rounded-lg transition-all duration-300",y==="signup"?"bg-white text-red-600 shadow-sm":"text-gray-500 hover:text-gray-700"),children:"Sign Up"})]}),s.jsxs("div",{className:"w-full space-y-8",children:[c&&s.jsxs(Zt.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"p-3.5 bg-emerald-50 text-emerald-800 text-[10px] font-bold tracking-tight rounded-2xl flex items-start gap-2.5 border border-emerald-100 text-left",children:[s.jsx("span",{className:"text-sm shrink-0",children:"🤝"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-extrabold uppercase text-[7.5px] tracking-[0.15em] text-emerald-600 mb-0.5",children:"Connection Action Pending"}),s.jsxs("p",{className:"font-sans text-gray-700 leading-snug",children:["Follow relation with ",s.jsxs("b",{className:"text-gray-950 font-black",children:["@",c.toLowerCase().replace(/\s+/g,"")]})," will activate instantly across all services as soon as you continue and log in below."]})]})]}),ne&&s.jsx(Zt.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"p-4 bg-red-50 text-red-600 text-[10px] font-black uppercase tracking-widest leading-relaxed rounded-2xl text-center shadow-sm border border-red-100",children:ne}),s.jsxs("form",{onSubmit:Tt,className:"space-y-5",children:[y==="signup"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"username",className:"text-xs font-semibold text-gray-700 ml-1",children:"Username"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",id:"username",required:!0,value:F,onChange:Ee=>$(Ee.target.value),className:Fe("w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl outline-none text-sm transition-all text-gray-900 focus:bg-white focus:border-red-600 placeholder:text-gray-400",F&&be===!1&&"border-red-500 bg-red-50/30",F&&be===!0&&"border-green-500 bg-green-50/30"),placeholder:"e.g. campus_hero"}),F.trim()&&s.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2",children:Ke?s.jsx(Er,{className:"animate-spin text-gray-400",size:16}):be===!0?s.jsx("span",{className:"text-green-600 font-bold uppercase text-[9px] tracking-wider",children:"Available"}):be===!1?s.jsx("span",{className:"text-red-500 font-bold uppercase text-[9px] tracking-wider",children:"Taken"}):null})]}),F.trim()&&!Ke&&s.jsx("p",{className:Fe("text-[10px] font-medium ml-1",be===!0?"text-green-600":"text-red-500"),children:be===!0?"✓ Username is available!":"✗ This username is already taken. Try another!"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"email",className:"text-xs font-semibold text-gray-700 ml-1",children:y==="signin"?"Email / Username":"Email Address"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"email",id:"email",required:!0,value:A,onChange:Ee=>S(Ee.target.value),className:Fe("w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl outline-none text-sm transition-all text-gray-900 focus:bg-white focus:border-red-600 placeholder:text-gray-400",A&&!se&&"border-red-500 bg-red-50/30"),placeholder:"Enter your email address"}),A&&s.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2",children:se?s.jsx(lc,{className:"text-green-500",size:16}):s.jsx(rF,{className:"text-red-500",size:16})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"password",className:"text-xs font-semibold text-gray-700 ml-1",children:"Password"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:D?"text":"password",id:"password",required:!0,value:C,onChange:Ee=>T(Ee.target.value),className:"w-full px-4 py-3 pr-11 bg-gray-50 border border-gray-200 rounded-xl outline-none text-sm transition-all text-gray-900 focus:bg-white focus:border-red-600 placeholder:text-gray-400",placeholder:"••••••••"}),s.jsx("button",{type:"button",onClick:()=>V(!D),className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700 p-1 transition-colors cursor-pointer",title:D?"Hide Password":"Show Password",children:D?s.jsx(J6,{size:18}):s.jsx(I1,{size:18})})]}),y==="signup"&&C.length>0&&s.jsxs("div",{className:"px-2 space-y-1",children:[s.jsx("div",{className:"flex gap-1 h-1",children:[1,2,3].map(Ee=>s.jsx("div",{className:Fe("flex-1 rounded-full transition-all duration-500",xe>=Ee?xe===1?"bg-red-500":xe===2?"bg-yellow-500":"bg-green-500":"bg-gray-100")},Ee))}),s.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400",children:xe===1?"Weak":xe===2?"Good":"Strong"})]})]}),y==="signup"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"confirmPassword",className:"text-xs font-semibold text-gray-700 ml-1",children:"Confirm Password"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:Z?"text":"password",id:"confirmPassword",required:!0,value:L,onChange:Ee=>K(Ee.target.value),className:Fe("w-full px-4 py-3 pr-11 bg-gray-50 border border-gray-200 rounded-xl outline-none text-sm transition-all text-gray-900 focus:bg-white focus:border-red-600 placeholder:text-gray-400",L&&!Me&&"border-red-500 bg-red-50/30",L&&Me&&"border-green-500 bg-green-50/30"),placeholder:"••••••••"}),s.jsx("button",{type:"button",onClick:()=>q(!Z),className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700 p-1 transition-colors cursor-pointer",title:Z?"Hide Password":"Show Password",children:Z?s.jsx(J6,{size:18}):s.jsx(I1,{size:18})})]}),L&&s.jsx("p",{className:Fe("text-[10px] font-medium ml-1",Me?"text-green-600":"text-red-500"),children:Me?"✓ Passwords match!":"✗ Passwords do not match"})]}),y==="signin"&&s.jsx("div",{className:"flex justify-end px-2",children:s.jsx("button",{type:"button",className:"text-[10px] font-black uppercase tracking-widest text-gray-400 hover:text-red-600 transition-colors",children:"Forgot Password?"})}),s.jsx("div",{className:"pt-2",children:s.jsx(Zt.button,{whileHover:nt?{scale:1.01}:{},whileTap:nt?{scale:.99}:{},type:"submit",disabled:f||!nt,className:Fe("w-full flex items-center justify-center gap-3 py-4 px-8 rounded-xl transition-all font-bold text-sm tracking-wide disabled:opacity-50",nt?"bg-red-600 text-white hover:bg-red-700 shadow-lg shadow-red-600/20":"bg-gray-100 text-gray-400 cursor-not-allowed"),children:f?s.jsx(Er,{className:"animate-spin",size:20}):s.jsx("span",{children:y==="signin"?"Login":"Create Account"})})})]}),s.jsxs("div",{className:"text-center space-y-6",children:[s.jsxs("div",{className:"relative flex items-center py-4",children:[s.jsx("div",{className:"flex-grow border-t border-gray-100"}),s.jsx("span",{className:"flex-shrink mx-6 text-[10px] uppercase font-black tracking-[0.4em] text-gray-300",children:"Or"}),s.jsx("div",{className:"flex-grow border-t border-gray-100"})]}),s.jsxs(Zt.button,{whileHover:{backgroundColor:"rgba(0, 0, 0, 0.02)"},onClick:ze,disabled:f,className:"w-full flex items-center justify-center gap-3 bg-white border border-gray-200 text-gray-700 py-3.5 px-8 rounded-xl transition-all font-semibold text-sm",children:[s.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[s.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),s.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),s.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l3.66-2.84z"}),s.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),s.jsx("span",{className:"font-black uppercase text-[11px] tracking-[0.2em]",children:"Continue with Google"})]}),c&&s.jsxs("div",{className:"pt-2 flex flex-col items-center justify-center space-y-2 select-none",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-100 flex items-center justify-center shadow-xs border border-red-200",children:s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",className:"w-6 h-6 rounded-full object-cover border border-gray-900",alt:"Campus Eye Logo",referrerPolicy:"no-referrer"})}),s.jsx("p",{className:"text-[7.5px] font-mono text-gray-400 uppercase tracking-widest leading-none",children:"Authorized Redirect Portal"})]})]})]})]})]})},PMe=()=>{const[e,t]=I.useState(!1),[n,r]=I.useState(!1);I.useEffect(()=>{const o=()=>{r(window.innerWidth<768)};return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]);const i=[{name:"Threads",url:"https://www.threads.com/@campuseyemedia_",color:"bg-black text-white hover:bg-zinc-800 border-zinc-700",icon:s.jsx(nF,{size:16,strokeWidth:2.5})},{name:"YouTube",url:"https://youtube.com/@campuseye_media?si=gLddUotgI7D0n3cL",color:"bg-[#FF0000] text-white hover:bg-[#CC0000] border-red-500",icon:s.jsx(pF,{size:16})},{name:"LinkedIn",url:"https://www.linkedin.com/in/campuseyemedia?utm_source=share_via&utm_content=profile&utm_medium=member_android",color:"bg-[#0077B5] text-white hover:bg-[#005582] border-blue-600",icon:s.jsx(oF,{size:16})},{name:"Instagram",url:"https://www.instagram.com/campuseyemedia_?igsh=MXV6ejUyM2J3MnhsNA==",color:"bg-gradient-to-tr from-[#f9ce34] via-[#ee2a7b] to-[#6228d7] text-white hover:brightness-110 border-pink-500",icon:s.jsx(aF,{size:16})},{name:"X",url:"https://x.com/campuseye_media",color:"bg-black text-white hover:bg-zinc-800 border-zinc-700",icon:s.jsx(lq,{size:14,className:"text-white"})},{name:"Facebook",url:"https://www.facebook.com/share/1FivBManaT/",color:"bg-[#1877F2] text-white hover:bg-[#1258b3] border-blue-500",icon:s.jsx(sF,{size:16})},{name:"TikTok",url:"https://www.tiktok.com/@campuseye_media?_r=1&_t=ZS-96ci42CXliv",color:"bg-[#000000] text-white hover:bg-zinc-900 border-red-500",icon:s.jsx(cq,{size:14,className:"text-white"})},{name:"WhatsApp",url:"https://whatsapp.com/channel/0029Vb6OR49CXC3C5hCVlv3Q",color:"bg-[#25D366] text-white hover:bg-[#1ebe5d] border-green-500",icon:s.jsx(Kp,{size:16})}],a=(o,c)=>{const h=n?145:195,f=180,y=270-f,A=(f+o/(c-1)*y)*Math.PI/180;return{x:h*Math.cos(A),y:h*Math.sin(A)}};return s.jsxs("div",{className:"fixed bottom-18 md:bottom-8 right-6 md:right-8 z-[1051] flex items-center justify-center",children:[e&&s.jsx("div",{onClick:()=>t(!1),className:"fixed inset-0 bg-transparent cursor-default"}),s.jsx(or,{children:e&&i.map((o,c)=>{const{x:h,y:f}=a(c,i.length);return s.jsxs(Zt.a,{href:o.url,target:"_blank",rel:"noopener noreferrer",initial:{x:0,y:0,scale:0,opacity:0},animate:{x:h,y:f,scale:1,opacity:1,transition:{type:"spring",stiffness:300,damping:18,delay:c*.035}},exit:{x:0,y:0,scale:0,opacity:0,transition:{duration:.15,delay:(i.length-1-c)*.02}},whileHover:{scale:1.15,zIndex:100},whileTap:{scale:.9},className:Fe("absolute w-10 h-10 md:w-11 md:h-11 rounded-full flex items-center justify-center border border-white/25 shadow-lg shadow-black/30 cursor-pointer text-white hover:scale-110 active:scale-95 transition-shadow select-none",o.color),children:[s.jsx("div",{className:"absolute opacity-0 hover:opacity-100 md:group-hover:opacity-100 transition-opacity bg-black/80 backdrop-blur-md text-white text-[9px] font-black uppercase tracking-wider py-1 px-2 rounded-md -top-8 pointer-events-none whitespace-nowrap border border-zinc-700 shadow-xl",children:o.name}),o.icon]},o.name)})}),s.jsx(Zt.button,{onClick:()=>t(!e),whileHover:{scale:1.08},whileTap:{scale:.92},className:Fe("w-10 h-10 md:w-11 md:h-11 rounded-full flex items-center justify-center cursor-pointer shadow-xl select-none transition-all border outline-none duration-300 z-[1052]",e?"bg-red-600 border-red-500 text-white shadow-red-600/30 rotate-180":"bg-white border-gray-150 text-[#af05ea] hover:bg-gray-50 shadow-purple-600/10"),children:s.jsx(or,{mode:"wait",children:e?s.jsx(Zt.div,{initial:{rotate:-90,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:90,opacity:0},transition:{duration:.2},children:s.jsx(er,{size:16,strokeWidth:2.5})},"close-icon"):s.jsx(Zt.div,{initial:{rotate:90,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:-90,opacity:0},transition:{duration:.2},className:"relative flex items-center justify-center p-0.5",children:s.jsx(Tpe,{size:18,className:"relative z-10"})},"share-icon")})})]})},OMe=({articles:e})=>{const[t,n]=ie.useState(0),r=ie.useMemo(()=>e.filter(h=>h&&h.id),[e]);if(ie.useEffect(()=>{if(r.length<2)return;const h=setInterval(()=>{n(f=>(f+2)%r.length)},6e3);return()=>clearInterval(h)},[r]),r.length<2)return null;const i=r[t%r.length],a=r[(t+1)%r.length],o=[i,a].filter(Boolean),c=h=>{const f=new CustomEvent("selectArticle",{detail:h});window.dispatchEvent(f)};return s.jsx("div",{className:"w-full bg-gradient-to-r from-gray-50 via-white to-gray-50 border-b border-gray-100 py-3.5 select-none",children:s.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 flex flex-col md:flex-row items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-2.5 shrink-0 self-start md:self-auto",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1 bg-red-50 text-red-650 rounded-lg border border-red-200/60 shadow-2xs",children:[s.jsx(mF,{size:13,className:"animate-pulse"}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest",children:"Live Wire"})]}),s.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-gray-500 hidden lg:inline",children:"Campus Dispatches"})]}),s.jsx(or,{mode:"wait",children:s.jsx(Zt.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.35,ease:"easeOut"},className:"flex-1 flex flex-col sm:flex-row items-stretch justify-around gap-3 w-full",children:o.map((h,f)=>h?s.jsxs("div",{onClick:()=>c(h),className:"flex items-center gap-3 bg-white px-3.5 py-2 rounded-xl border border-gray-200/70 hover:border-red-300 flex-1 cursor-pointer transition-all group shadow-2xs hover:shadow-xs",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg overflow-hidden shrink-0 bg-gray-100 border border-gray-100",children:s.jsx(Li,{src:h.featuredImageUrl||`data:image/svg+xml;utf8,${(h.title||"CE").substring(0,2).toUpperCase()}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",alt:""})}),s.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[s.jsx("p",{className:"text-xs font-bold text-gray-900 truncate leading-snug group-hover:text-red-650 transition-colors",children:h.title||"Dispatch"}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[9px] font-black text-red-650 uppercase tracking-wider",children:h.category||"News"}),s.jsx("span",{className:"text-gray-300 text-[10px]",children:"•"}),s.jsx("span",{className:"text-[9px] font-semibold text-gray-400",children:h.authorName||"Campus Eye"})]})]}),s.jsx(Wp,{size:14,className:"text-gray-300 group-hover:text-red-650 group-hover:translate-x-0.5 transition-all shrink-0"})]},h.id||f):null)},t)})]})})},RMe=({setActiveTab:e,articles:t=[],isAdmin:n})=>{var J,ye;const[r,i]=ie.useState(""),[a,o]=ie.useState(!1),[c,h]=ie.useState(null),f=new Date().getFullYear(),m=!!(n||Ne.currentUser&&(((J=Ne.currentUser.email)==null?void 0:J.toLowerCase())==="atwiinevictor2@gmail.com"||((ye=Ne.currentUser.email)==null?void 0:ye.toLowerCase())==="campuseye@gmail.com")),[y,w]=ie.useState([]),[A,S]=ie.useState(!1),[C,T]=ie.useState(""),[D,V]=ie.useState(""),[L,K]=ie.useState(null),[Z,q]=ie.useState(""),[B,z]=ie.useState(!1);ie.useEffect(()=>{const ne=Qt(et(he,"sponsors"),vi(15)),de=Qt(et(he,"adverts"),vi(20));Promise.all([vn(ne).catch(()=>null),vn(de).catch(()=>null)]).then(([be,Ce])=>{const Ke=[];be&&!be.empty&&be.docs.forEach(G=>Ke.push({id:G.id,targetCollection:"sponsors",...G.data()})),Ce&&!Ce.empty&&Ce.docs.forEach(G=>{const se=G.data();(se.imageUrl||se.mediaUrl)&&Ke.push({id:G.id,targetCollection:"adverts",name:se.company||se.title||"Partner",imageUrl:se.imageUrl||se.mediaUrl||"",link:se.targetUrl||se.link||"#"})}),w(Ke)})},[]);const F=async ne=>{if(ne.preventDefault(),!m){pe.error("Access Denied: Only administrators can add sponsors.");return}if(!C.trim()){pe.error("Please enter a sponsor name");return}z(!0);try{let de=Z.trim();if(L&&(pe.loading("Uploading sponsor logo...",{id:"sponsor-upload"}),de=await I4(L),pe.dismiss("sponsor-upload")),!de){pe.error("Please upload an image file or enter an image URL"),z(!1);return}const Ce={id:(await ur(et(he,"sponsors"),{name:C.trim(),imageUrl:de,link:D.trim()||"#",status:"active",createdAt:En()})).id,name:C.trim(),imageUrl:de,link:D.trim()||"#",targetCollection:"sponsors"};w(Ke=>[Ce,...Ke]),pe.success(`Sponsor "${C}" added successfully!`),T(""),V(""),K(null),q(""),S(!1)}catch(de){console.error("Failed to add sponsor:",de),pe.error("Failed to add sponsor: "+de.message)}finally{z(!1)}},$=async(ne,de,be="sponsors")=>{if(!m){pe.error("Access Denied: Only administrators can delete sponsors.");return}if(window.confirm(`Are you sure you want to delete sponsor "${de}"?`))try{w(Ce=>Ce.filter(Ke=>Ke.id!==ne)),await si(Je(he,be||"sponsors",ne)),pe.success(`Deleted "${de}" successfully!`)}catch(Ce){console.error("Failed to delete sponsor:",Ce),pe.error("Failed to delete sponsor: "+Ce.message)}},Y=ne=>{ne.preventDefault(),r&&(o(!0),pe.success("Thank you for subscribing to Campus Eye Dispatch!",{icon:"📬"}),i(""),setTimeout(()=>o(!1),4e3))},X=[{name:"X (Twitter)",icon:s.jsx(lq,{size:14,className:"text-gray-600 group-hover:text-black"}),href:"https://x.com/campuseye_media",hoverClass:"hover:bg-black/5 hover:border-black"},{name:"WhatsApp Channel",icon:s.jsx(Kp,{size:15,className:"text-emerald-600 group-hover:text-emerald-700"}),href:"https://whatsapp.com/channel/0029Vb6OR49CXC3C5hCVlv3Q",hoverClass:"hover:bg-emerald-50 hover:border-emerald-400"},{name:"YouTube",icon:s.jsx(pF,{size:15,className:"text-red-600 group-hover:text-red-700"}),href:"https://youtube.com/@campuseye_media?si=gLddUotgI7D0n3cL",hoverClass:"hover:bg-red-50 hover:border-red-400"},{name:"Instagram",icon:s.jsx(aF,{size:15,className:"text-pink-600 group-hover:text-pink-700"}),href:"https://www.instagram.com/campuseyemedia_?igsh=MXV6ejUyM2J3MnhsNA==",hoverClass:"hover:bg-pink-50 hover:border-pink-400"},{name:"LinkedIn",icon:s.jsx(oF,{size:15,className:"text-blue-600 group-hover:text-blue-700"}),href:"https://www.linkedin.com/in/campuseyemedia?utm_source=share_via&utm_content=profile&utm_medium=member_android",hoverClass:"hover:bg-blue-50 hover:border-blue-400"},{name:"TikTok",icon:s.jsx(cq,{size:14,className:"text-gray-800 group-hover:text-black"}),href:"https://www.tiktok.com/@campuseye_media?_r=1&_t=ZS-96ci42CXliv",hoverClass:"hover:bg-gray-100 hover:border-gray-800"},{name:"Threads",icon:s.jsx(nF,{size:15,className:"text-gray-700 group-hover:text-black"}),href:"https://www.threads.com/@campuseyemedia_",hoverClass:"hover:bg-gray-100 hover:border-gray-800"},{name:"Facebook",icon:s.jsx(sF,{size:15,className:"text-blue-700 group-hover:text-blue-800"}),href:"https://www.facebook.com/share/1FivBManaT/",hoverClass:"hover:bg-blue-50 hover:border-blue-500"}];return s.jsxs("footer",{className:"bg-white border-t border-gray-100 mt-16 relative overflow-hidden font-sans select-none",children:[s.jsxs("div",{className:"w-full max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-12 pb-16",children:[t.length>0&&s.jsxs("div",{className:"pb-12 border-b border-gray-100 mb-12",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4 mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-red-650 animate-ping"}),s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900",children:"Recommended For You"})]}),s.jsx("span",{className:"text-[11px] font-semibold text-gray-400",children:"Curated Student Headlines"})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-4",children:t.slice(0,6).map(ne=>s.jsxs("div",{className:"group cursor-pointer flex flex-col bg-gray-50/70 hover:bg-white rounded-2xl p-2.5 border border-gray-200/60 hover:border-red-200 hover:shadow-md transition-all duration-300 text-left",onClick:()=>{const de=new CustomEvent("selectArticle",{detail:ne});window.dispatchEvent(de)},children:[s.jsxs("div",{className:"aspect-[16/10] bg-gray-100 overflow-hidden rounded-xl mb-2.5 border border-gray-100 relative",children:[s.jsx(Li,{src:ne.featuredImageUrl||void 0,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",alt:ne.title}),s.jsx("span",{className:"absolute top-2 left-2 px-2 py-0.5 bg-black/75 backdrop-blur-xs text-white text-[9px] font-black uppercase tracking-wider rounded-md",children:ne.category||"News"})]}),s.jsx("h4",{className:"text-xs font-bold text-gray-900 line-clamp-2 leading-snug group-hover:text-red-650 transition-colors mb-1.5",children:ne.title}),s.jsxs("p",{className:"text-[10px] font-medium text-gray-400 mt-auto truncate",children:["By ",ne.authorName||"Campus Eye"]})]},ne.id))})]}),s.jsxs("div",{className:"pb-10 border-b border-gray-100 mb-12 text-left",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-5",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zi,{size:14,className:"text-red-650"}),s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900",children:"Our Strategic Partners & Sponsors"})]}),s.jsx("p",{className:"text-[11px] font-medium text-gray-500 mt-0.5",children:"Supporting independent university journalism & student media innovation"})]}),m&&s.jsxs("button",{onClick:()=>S(!0),className:"px-3.5 py-1.5 bg-red-650 hover:bg-red-700 text-white rounded-xl text-[11px] font-black uppercase tracking-wider flex items-center gap-1.5 transition-all shadow-xs cursor-pointer shrink-0 self-start sm:self-auto",children:[s.jsx(Lc,{size:13}),s.jsx("span",{children:"Add Sponsor"})]})]}),s.jsx("div",{className:"flex flex-wrap items-center gap-3",children:y.length>0?y.map(ne=>s.jsxs("div",{className:"flex items-center gap-2.5 bg-gray-50/90 hover:bg-white px-3.5 py-2 rounded-xl border border-gray-200 hover:border-red-300 hover:shadow-xs transition-all group/sps",children:[ne.link&&ne.link!=="#"?s.jsxs("a",{href:ne.link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2.5 hover:opacity-90 transition-opacity",children:[ne.imageUrl&&s.jsx("img",{src:ne.imageUrl,className:"h-6 w-auto max-w-[80px] object-contain rounded",alt:ne.name,referrerPolicy:"no-referrer"}),s.jsx("span",{className:"text-xs font-bold text-gray-800 group-hover/sps:text-red-650 transition-colors",children:ne.name}),s.jsx($a,{size:11,className:"text-gray-400 group-hover/sps:text-red-650"})]}):s.jsxs("div",{className:"flex items-center gap-2.5",children:[ne.imageUrl&&s.jsx("img",{src:ne.imageUrl,className:"h-6 w-auto max-w-[80px] object-contain rounded",alt:ne.name,referrerPolicy:"no-referrer"}),s.jsx("span",{className:"text-xs font-bold text-gray-800",children:ne.name})]}),m&&s.jsx("button",{onClick:()=>$(ne.id,ne.name,ne.targetCollection),className:"w-5 h-5 bg-gray-200/70 hover:bg-red-650 text-gray-600 hover:text-white rounded-full flex items-center justify-center transition-all cursor-pointer shrink-0 ml-1",title:`Delete ${ne.name}`,children:s.jsx(As,{size:10})})]},ne.id)):s.jsxs("div",{className:"p-4 bg-gray-50 border border-gray-200/80 rounded-2xl flex flex-col sm:flex-row items-center justify-between gap-3 w-full",children:[s.jsx("span",{className:"text-xs text-gray-600 font-medium",children:"Partner with Campus Eye Media to reach over 100,000+ university students and scholars across Africa."}),s.jsx("button",{onClick:()=>h("advertise"),className:"text-xs font-black text-red-650 uppercase tracking-wider bg-white px-3.5 py-1.5 rounded-xl border border-gray-200 shadow-2xs hover:bg-red-50 cursor-pointer shrink-0",children:"Become a Sponsor"})]})})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-12 gap-8 lg:gap-10 text-left",children:[s.jsxs("div",{className:"lg:col-span-4 space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-11 h-11 rounded-full overflow-hidden border-2 border-red-600 p-[1.5px] bg-white shrink-0 shadow-2xs",children:s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Campus Eye Logo",className:"w-full h-full object-cover rounded-full",referrerPolicy:"no-referrer"})}),s.jsxs("div",{children:[s.jsxs("h2",{className:"text-base font-black tracking-tight text-gray-950 uppercase italic leading-none",children:["CAMPUS ",s.jsx("span",{className:"text-red-650",children:"EYE"})," MEDIA"]}),s.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.2em] text-red-650 mt-1",children:"Where stories unfold"})]})]}),s.jsx("p",{className:"text-xs text-gray-600 leading-relaxed font-normal max-w-sm",children:"The premier digital destination for university journalism, student dispatches, culture, investigative reports, and collegiate sports across higher institutions."}),s.jsxs("div",{className:"space-y-2.5 pt-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-bold uppercase tracking-wider text-gray-700",children:[s.jsx(ea,{size:13,className:"text-red-650"}),s.jsx("span",{children:"Join Our Campus Newsletter"})]}),s.jsxs("form",{onSubmit:Y,className:"flex gap-2 max-w-sm",children:[s.jsx("input",{type:"email",placeholder:"Enter your university email...",value:r,onChange:ne=>i(ne.target.value),className:"flex-1 px-3.5 py-2.5 text-xs border border-gray-200 rounded-xl focus:outline-none focus:border-red-600 transition-colors bg-gray-50/70",required:!0}),s.jsx("button",{type:"submit",className:"px-4 py-2.5 bg-gray-950 hover:bg-red-650 text-white font-bold text-xs uppercase tracking-wider rounded-xl transition-all flex items-center gap-1.5 shrink-0 shadow-xs cursor-pointer",children:a?s.jsx(lc,{size:14,className:"text-emerald-400"}):s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"Join"}),s.jsx(Op,{size:13})]})})]})]})]}),s.jsxs("div",{className:"lg:col-span-3 space-y-4",children:[s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900 border-l-2 border-red-650 pl-2.5",children:"Explore Newsroom"}),s.jsxs("ul",{className:"space-y-2.5 text-xs font-semibold text-gray-600",children:[s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("home"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Campus News"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("podcasts"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Podcasts & Broadcasts"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("posts"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Peer Dispatches & Lounge"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("sport"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Sports Arena"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("entertainment"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Entertainment & Culture"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("politics"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Politics & Governance"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("campus-debates"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Campus Debates & Polls"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("market"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Student Market Hub"})})})]})]}),s.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900 border-l-2 border-red-650 pl-2.5",children:"Information"}),s.jsxs("ul",{className:"space-y-2.5 text-xs font-semibold text-gray-600",children:[s.jsx("li",{children:s.jsx("button",{onClick:()=>h("about"),className:"hover:text-red-650 transition-colors cursor-pointer text-left",children:"About Campus Eye"})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>h("contact"),className:"hover:text-red-650 transition-colors cursor-pointer text-left",children:"Contact & Tips"})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>h("privacy"),className:"hover:text-red-650 transition-colors cursor-pointer text-left",children:"Privacy Policy"})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>h("terms"),className:"hover:text-red-650 transition-colors cursor-pointer text-left",children:"Terms of Service"})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>h("guidelines"),className:"hover:text-red-650 transition-colors cursor-pointer text-left",children:"Editorial Guidelines"})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>h("advertise"),className:"hover:text-red-650 transition-colors cursor-pointer text-left",children:"Advertise With Us"})})]})]}),s.jsxs("div",{className:"lg:col-span-3 space-y-5",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900 border-l-2 border-red-650 pl-2.5",children:"Download App"}),s.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Enjoy offline reader mode, breaking push alerts, and audio dispatches on your phone."}),s.jsxs("div",{className:"flex flex-col sm:flex-row lg:flex-col gap-2 pt-1",children:[s.jsxs("a",{href:"https://link.thelocalrent.com/v?t=1786099107&tk=07c43b29b01fcaf275f96eea938d430f",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 px-3.5 py-2 bg-gray-950 text-white hover:bg-neutral-800 transition-all rounded-xl border border-gray-800 shadow-xs group shrink-0",title:"Download Campus Eye Android App",children:[s.jsx("svg",{className:"w-5 h-5 text-white shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M3,5.27V18.73L16.55,12L3,5.27M17.87,11.33L19.5,12.15L17.87,12.97L16.93,12.5L17.87,11.33M3,19.53L16.27,12.89L13.87,15.29L3,19.53M3,4.47L13.87,8.71L16.27,11.11L3,4.47Z"})}),s.jsxs("div",{className:"text-left leading-none",children:[s.jsx("p",{className:"text-[8px] text-gray-400 font-bold uppercase tracking-wider",children:"Get it on"}),s.jsx("p",{className:"text-xs font-black tracking-tight mt-0.5",children:"Google Play"})]})]}),s.jsxs("a",{href:"https://link.thelocalrent.com/v?t=1786099107&tk=07c43b29b01fcaf275f96eea938d430f",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 px-3.5 py-2 bg-gray-950 text-white hover:bg-neutral-800 transition-all rounded-xl border border-gray-800 shadow-xs group shrink-0",title:"Download Campus Eye iOS App",children:[s.jsx("svg",{className:"w-5 h-5 text-white shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M18.71,19.5C17.88,20.74 17,21.95 15.66,21.97C14.32,22 13.89,21.18 12.37,21.18C10.84,21.18 10.37,21.95 9.1,22C7.79,22.05 6.8,20.68 5.96,19.47C4.25,17 2.94,12.45 4.7,9.39C5.57,7.87 7.13,6.91 8.82,6.88C10.1,6.86 11.32,7.75 12.11,7.75C12.89,7.75 14.37,6.68 15.92,6.84C16.57,6.87 18.39,7.1 19.56,8.82C19.47,8.88 17.39,10.1 17.41,12.63C17.44,15.65 20.06,16.66 20.1,16.67C20.08,16.74 19.67,18.11 18.71,19.5M15.97,4.17C16.63,3.37 17.07,2.28 16.95,1C16,1.04 14.9,1.6 14.24,2.38C13.68,3.04 13.19,4.14 13.34,5.39C14.39,5.47 15.4,4.88 15.97,4.17Z"})}),s.jsxs("div",{className:"text-left leading-none",children:[s.jsx("p",{className:"text-[8px] text-gray-400 font-bold uppercase tracking-wider",children:"Download on the"}),s.jsx("p",{className:"text-xs font-black tracking-tight mt-0.5",children:"App Store"})]})]})]})]}),s.jsxs("div",{className:"space-y-2 pt-2 border-t border-gray-100",children:[s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 block",children:"Connect With Us"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:X.map(ne=>s.jsx("a",{href:ne.href,target:"_blank",rel:"noopener noreferrer",className:`w-8 h-8 rounded-xl border border-gray-200 bg-gray-50 flex items-center justify-center transition-all duration-200 group hover:scale-105 shadow-2xs ${ne.hoverClass}`,title:ne.name,children:ne.icon},ne.name))})]})]})]}),s.jsxs("div",{className:"mt-14 pt-8 border-t border-gray-200/80 flex flex-col md:flex-row justify-between items-center gap-4 text-[11px] font-bold text-gray-600",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-2 text-center sm:text-left",children:[s.jsxs("span",{className:"uppercase tracking-wider",children:["© ",f," CAMPUS EYE MEDIA. ALL RIGHTS RESERVED."]}),s.jsx("span",{className:"hidden sm:inline text-gray-300",children:"•"}),s.jsxs("span",{className:"text-gray-500 font-medium",children:["Designed with 💙 by"," ",s.jsx("a",{href:"https://cybertechsoftwares.netlify.app",target:"_blank",rel:"noopener noreferrer",className:"hover:underline text-blue-650 font-bold",children:"Cyber Tech softwares"})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-x-5 gap-y-2 justify-center text-gray-500",children:[s.jsx("button",{onClick:()=>h("careers"),className:"hover:text-red-650 transition-colors cursor-pointer",children:"Careers"}),s.jsx("button",{onClick:()=>h("staff"),className:"hover:text-red-650 transition-colors cursor-pointer",children:"Staff Directory"}),s.jsx("button",{onClick:()=>h("advertise"),className:"hover:text-red-650 transition-colors cursor-pointer",children:"Advertise"}),s.jsx("a",{href:"/sitemap.xml",target:"_blank",rel:"noopener noreferrer",className:"hover:text-red-650 transition-colors",children:"Sitemap XML"}),n&&s.jsx("button",{onClick:()=>e==null?void 0:e("admin"),className:"hover:text-red-650 transition-colors font-black text-red-650 cursor-pointer",children:"Admin Panel"})]})]})]}),s.jsx(or,{children:A&&s.jsx("div",{className:"fixed inset-0 z-[10000] bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",children:s.jsxs(Zt.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-white rounded-3xl p-6 md:p-8 max-w-md w-full shadow-2xl border border-gray-100 text-left space-y-5 relative",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-red-50 text-red-650 rounded-2xl",children:s.jsx(Lc,{size:20})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-black uppercase tracking-tight text-gray-900",children:"Add Footer Sponsor"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-wider",children:"Logo & Partner Listing"})]})]}),s.jsx("button",{onClick:()=>S(!1),className:"p-2 text-gray-400 hover:text-gray-900 rounded-full hover:bg-gray-100 transition-colors cursor-pointer",children:s.jsx(er,{size:18})})]}),s.jsxs("form",{onSubmit:F,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-500 mb-1",children:"Sponsor / Partner Name *"}),s.jsx("input",{type:"text",required:!0,value:C,onChange:ne=>T(ne.target.value),placeholder:"e.g. MTN Uganda, Stanbic, Makerere Guild",className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-4 py-2.5 text-xs font-bold text-gray-900 outline-none focus:border-red-600"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-500 mb-1",children:"Sponsor Logo (File Upload)"}),s.jsxs("label",{className:"flex items-center gap-3 p-3 bg-gray-50 border border-dashed border-gray-300 rounded-xl cursor-pointer hover:bg-gray-100 transition-colors",children:[s.jsx(fF,{size:18,className:"text-red-650 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs font-bold text-gray-700 truncate",children:L?L.name:"Choose Logo File..."}),s.jsx("p",{className:"text-[9px] text-gray-400 font-medium",children:"Automatic cloud storage upload"})]}),s.jsx("input",{type:"file",accept:"image/*",onChange:ne=>{ne.target.files&&ne.target.files[0]&&(K(ne.target.files[0]),q(""))},className:"hidden"})]})]}),s.jsxs("div",{className:"relative flex items-center justify-center",children:[s.jsx("div",{className:"border-t border-gray-100 w-full"}),s.jsx("span",{className:"bg-white px-3 text-[9px] font-black text-gray-400 uppercase tracking-widest absolute",children:"OR"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-500 mb-1",children:"Sponsor Logo Image URL"}),s.jsx("input",{type:"url",value:Z,onChange:ne=>{q(ne.target.value),ne.target.value&&K(null)},placeholder:"https://i.ibb.co/example/logo.png",className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-4 py-2.5 text-xs font-mono text-gray-900 outline-none focus:border-red-600"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-500 mb-1",children:"Website / Partner URL (Optional)"}),s.jsx("input",{type:"text",value:D,onChange:ne=>V(ne.target.value),placeholder:"https://sponsorwebsite.com",className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-4 py-2.5 text-xs font-mono text-gray-900 outline-none focus:border-red-600"})]}),s.jsxs("div",{className:"pt-2 flex items-center justify-end gap-3",children:[s.jsx("button",{type:"button",onClick:()=>S(!1),className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-xl text-xs font-bold uppercase tracking-wider transition-colors cursor-pointer",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:B,className:"px-5 py-2.5 bg-red-650 hover:bg-red-700 text-white rounded-xl text-xs font-black uppercase tracking-wider shadow-sm transition-all flex items-center gap-2 cursor-pointer disabled:opacity-50",children:B?"Saving...":"Save Sponsor"})]})]})]})})}),s.jsx(or,{children:c&&s.jsx("div",{className:"fixed inset-0 z-[10000] bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",children:s.jsxs(Zt.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-white rounded-3xl max-w-2xl w-full max-h-[85vh] overflow-hidden shadow-2xl border border-gray-100 flex flex-col text-left",children:[s.jsxs("div",{className:"p-6 border-b border-gray-100 flex items-center justify-between bg-gray-50/50",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"w-10 h-10 rounded-2xl bg-red-50 text-red-650 flex items-center justify-center",children:[c==="about"&&s.jsx(Lne,{size:20}),c==="contact"&&s.jsx(ea,{size:20}),c==="privacy"&&s.jsx(pl,{size:20}),c==="terms"&&s.jsx(D0,{size:20}),c==="guidelines"&&s.jsx(iF,{size:20}),c==="careers"&&s.jsx(_o,{size:20}),c==="staff"&&s.jsx(_o,{size:20}),c==="advertise"&&s.jsx(vu,{size:20})]}),s.jsxs("div",{children:[s.jsxs("h3",{className:"text-base font-black text-gray-900 uppercase tracking-tight",children:[c==="about"&&"About Campus Eye Media",c==="contact"&&"Contact & Editorial Desk",c==="privacy"&&"Privacy Policy",c==="terms"&&"Terms of Service",c==="guidelines"&&"Editorial Guidelines",c==="careers"&&"Join Our Newsroom (Careers)",c==="staff"&&"Staff Directory & Leadership",c==="advertise"&&"Advertising & Strategic Partnerships"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-wider",children:"Campus Eye Media Digital Newsroom"})]})]}),s.jsx("button",{onClick:()=>h(null),className:"p-2 text-gray-400 hover:text-gray-900 rounded-full hover:bg-gray-200/60 transition-colors cursor-pointer",children:s.jsx(er,{size:20})})]}),s.jsxs("div",{className:"p-6 overflow-y-auto space-y-4 text-xs text-gray-600 leading-relaxed",children:[c==="about"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"font-semibold text-gray-900 text-sm",children:"Campus Eye Media is the premier independent digital news organization covering higher education, student culture, campus politics, athletics, and investigative journalism."}),s.jsx("p",{children:"Founded to empower student voices and foster accountable leadership across African colleges and universities, Campus Eye brings together aspiring student reporters, photographers, podcast hosts, and digital creators."}),s.jsxs("div",{className:"bg-red-50/60 border border-red-200/80 p-4 rounded-2xl text-red-950 space-y-1",children:[s.jsx("h4",{className:"font-black text-xs uppercase tracking-wider text-red-650",children:"Our Mission"}),s.jsx("p",{className:"text-xs",children:"To deliver fearless, accurate, and uplifting journalism that bridges students, university administrators, and the wider society."})]})]}),c==="contact"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Have a breaking news tip, story pitch, press release, or campus query? Reach out directly to our editorial and reporting desk:"}),s.jsxs("div",{className:"space-y-3 bg-gray-50 p-4 rounded-2xl border border-gray-200",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 block",children:"General Inquiries & News Desk"}),s.jsx("a",{href:"mailto:campuseye@gmail.com",className:"text-sm font-bold text-red-650 hover:underline",children:"campuseye@gmail.com"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 block",children:"WhatsApp News Tip Hotline"}),s.jsxs("a",{href:"https://whatsapp.com/channel/0029Vb6OR49CXC3C5hCVlv3Q",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-bold text-emerald-600 hover:underline flex items-center gap-1.5 mt-0.5",children:[s.jsx(Kp,{size:14}),s.jsx("span",{children:"Campus Eye WhatsApp Channel"})]})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 block",children:"Headquarters"}),s.jsx("span",{className:"text-xs text-gray-800 font-medium",children:"Kampala International University / Makerere / Regional Bureaus"})]})]})]}),c==="privacy"&&s.jsxs(s.Fragment,{children:[s.jsx("h4",{className:"font-bold text-gray-900",children:"1. Data Privacy Commitment"}),s.jsx("p",{children:"Campus Eye Media respects your privacy. We do not sell personal identification information or share private account records with third-party data brokers."}),s.jsx("h4",{className:"font-bold text-gray-900",children:"2. Local Storage & Offline Cache"}),s.jsx("p",{children:"Our Progressive Web Application uses local browser storage to save offline bookmarked articles and caching preferences to minimize your mobile data consumption."}),s.jsx("h4",{className:"font-bold text-gray-900",children:"3. Authentication & Comments"}),s.jsx("p",{children:"When you sign in using Google or email credentials, only your public name, email, and avatar are stored to authenticate your community posts and comments."})]}),c==="terms"&&s.jsxs(s.Fragment,{children:[s.jsx("h4",{className:"font-bold text-gray-900",children:"1. Acceptance of Terms"}),s.jsx("p",{children:"By accessing Campus Eye Media, reader services, podcasts, and community dispatches, you agree to adhere to our civil engagement standards and applicable copyright laws."}),s.jsx("h4",{className:"font-bold text-gray-900",children:"2. Community Guidelines & Hate Speech"}),s.jsx("p",{children:"We enforce zero tolerance for hate speech, targeted harassment, defamation, or unauthorized commercial spam. Violating accounts are subject to immediate suspension."}),s.jsx("h4",{className:"font-bold text-gray-900",children:"3. Content Attribution"}),s.jsx("p",{children:"All original articles, podcast recordings, and photographs remain the intellectual property of Campus Eye Media and their respective student contributors."})]}),c==="guidelines"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Our newsroom adheres to standard journalistic integrity and verification protocols:"}),s.jsxs("ul",{className:"list-disc pl-5 space-y-1.5",children:[s.jsxs("li",{children:[s.jsx("strong",{children:"Accuracy:"})," All factual claims must be corroborated by multiple independent primary sources."]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Fairness:"})," Individuals or institutions facing critical claims must be offered fair opportunity to comment prior to publication."]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Corrections:"})," Factual errors are updated promptly with transparent editorial correction notices."]})]})]}),c==="careers"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Are you a student passionate about journalism, digital photography, video editing, social media management, or podcast production?"}),s.jsxs("div",{className:"p-4 bg-gray-50 border border-gray-200 rounded-2xl space-y-2",children:[s.jsx("h4",{className:"font-bold text-gray-900",children:"Open Positions for Semester Interns & Reporters:"}),s.jsxs("ul",{className:"list-disc pl-5 space-y-1",children:[s.jsx("li",{children:"Campus Beat Reporter (Politics & Guild)"}),s.jsx("li",{children:"Sports Correspondent (University Leagues & Tournaments)"}),s.jsx("li",{children:"Podcast Host & Audio Producer"}),s.jsx("li",{children:"Social Media & TikTok Video Creator"})]}),s.jsxs("p",{className:"text-xs pt-2",children:["Send your CV or writing samples to ",s.jsx("a",{href:"mailto:campuseye@gmail.com",className:"text-red-650 font-bold hover:underline",children:"campuseye@gmail.com"}),"."]})]})]}),c==="staff"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Campus Eye Media is directed by a dedicated editorial and technology team:"}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1",children:[s.jsxs("div",{className:"p-3 bg-gray-50 border border-gray-200 rounded-xl",children:[s.jsx("p",{className:"font-black text-gray-900 text-xs uppercase",children:"Editor-in-Chief"}),s.jsx("p",{className:"text-gray-500 text-[11px]",children:"Editorial Board"})]}),s.jsxs("div",{className:"p-3 bg-gray-50 border border-gray-200 rounded-xl",children:[s.jsx("p",{className:"font-black text-gray-900 text-xs uppercase",children:"Lead Developer"}),s.jsx("p",{className:"text-gray-500 text-[11px]",children:"Cyber Tech softwares"})]})]})]}),c==="advertise"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Promote your brand, student discounts, campus events, or product launches to an engaged audience of over 100,000+ university students."}),s.jsxs("div",{className:"bg-red-50/70 border border-red-200 p-4 rounded-2xl space-y-2 text-gray-800",children:[s.jsx("h4",{className:"font-black text-xs uppercase text-red-650",children:"Available Advertising Formats:"}),s.jsxs("ul",{className:"list-disc pl-5 space-y-1 text-xs",children:[s.jsx("li",{children:"Sponsored Featured Articles & Product Reviews"}),s.jsx("li",{children:"Homepage & In-Article Banner Advertisements"}),s.jsx("li",{children:"Podcast Audio & Video Episode Sponsorships"}),s.jsx("li",{children:"Direct WhatsApp & Push Notification Dispatches"})]}),s.jsxs("p",{className:"text-xs pt-2 font-semibold",children:["Contact our partnership team: ",s.jsx("a",{href:"mailto:campuseye@gmail.com",className:"text-red-650 font-bold hover:underline",children:"campuseye@gmail.com"})]})]})]})]}),s.jsx("div",{className:"p-4 border-t border-gray-100 bg-gray-50/60 flex justify-end",children:s.jsx("button",{onClick:()=>h(null),className:"px-5 py-2 bg-gray-950 hover:bg-gray-800 text-white rounded-xl text-xs font-bold uppercase tracking-wider cursor-pointer",children:"Close"})})]})})})]})},DMe=()=>(I.useEffect(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{})},[]),null),Ree=({currentPage:e,totalPages:t,totalItems:n,itemsPerPage:r,onPageChange:i,onItemsPerPageChange:a,itemLabel:o="items",itemsPerPageOptions:c=[10,20,30,50],className:h=""})=>{if(n===0)return null;const f=Math.max(1,t),m=Math.min(Math.max(1,e),f),y=(m-1)*r+1,w=Math.min(m*r,n),S=f<=7?Array.from({length:f},(C,T)=>T+1):m<=3?[1,2,3,4,5,"...",f]:m>=f-2?[1,"...",f-4,f-3,f-2,f-1,f]:[1,"...",m-1,m,m+1,"...",f];return s.jsxs("div",{className:`p-3.5 bg-gray-900 text-white rounded-2xl shadow-lg border border-gray-800 flex flex-col sm:flex-row items-center justify-between gap-3 select-none ${h}`,children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 text-xs text-gray-300",children:[s.jsxs("span",{children:["Showing ",s.jsxs("b",{className:"text-white font-mono",children:[y,"–",w]})," of ",s.jsx("b",{className:"text-white font-mono",children:n})," ",o]}),a&&s.jsxs("div",{className:"flex items-center gap-1.5 border-l border-gray-700 pl-2.5 my-0.5",children:[s.jsx("span",{className:"text-[10px] uppercase font-bold text-gray-400 font-mono",children:"Per page:"}),s.jsx("select",{value:r,onChange:C=>{a(Number(C.target.value)),i(1)},className:"bg-gray-800 text-white text-xs font-bold font-mono px-2 py-1 rounded-lg border border-gray-700 focus:outline-none focus:border-blue-500 cursor-pointer",children:c.map(C=>s.jsx("option",{value:C,children:C},C))})]})]}),s.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto max-w-full py-0.5 font-mono",children:[s.jsx("button",{type:"button",onClick:()=>i(1),disabled:m===1,className:"min-w-[32px] h-[32px] rounded-lg bg-gray-800 hover:bg-gray-700 disabled:opacity-30 disabled:cursor-not-allowed text-gray-200 transition-colors cursor-pointer flex items-center justify-center shrink-0",title:"First Page",children:s.jsx(Yne,{size:15})}),s.jsxs("button",{type:"button",onClick:()=>i(m-1),disabled:m===1,className:"px-2.5 h-[32px] rounded-lg bg-gray-800 hover:bg-gray-700 disabled:opacity-30 disabled:cursor-not-allowed text-gray-200 text-xs font-bold transition-colors cursor-pointer flex items-center gap-1 shrink-0",title:"Previous Page",children:[s.jsx(qp,{size:14}),s.jsx("span",{className:"hidden sm:inline font-sans text-[11px]",children:"Prev"})]}),S.map((C,T)=>{if(C==="...")return s.jsx("span",{className:"px-1.5 text-gray-500 font-mono font-bold text-xs select-none",children:"..."},`ellipsis-${T}`);const D=C,V=D===m;return s.jsx("button",{type:"button",onClick:()=>i(D),className:`min-w-[32px] h-[32px] px-2 rounded-lg text-xs font-bold transition-all cursor-pointer flex items-center justify-center shrink-0 ${V?"bg-blue-600 text-white font-black shadow-md shadow-blue-500/30 ring-1 ring-blue-400":"bg-gray-800 text-gray-300 hover:bg-gray-700 hover:text-white border border-gray-700/50"}`,children:D},D)}),s.jsxs("button",{type:"button",onClick:()=>i(m+1),disabled:m===f,className:"px-2.5 h-[32px] rounded-lg bg-gray-800 hover:bg-gray-700 disabled:opacity-30 disabled:cursor-not-allowed text-gray-200 text-xs font-bold transition-colors cursor-pointer flex items-center gap-1 shrink-0",title:"Next Page",children:[s.jsx("span",{className:"hidden sm:inline font-sans text-[11px]",children:"Next"}),s.jsx(Wp,{size:14})]}),s.jsx("button",{type:"button",onClick:()=>i(f),disabled:m===f,className:"min-w-[32px] h-[32px] rounded-lg bg-gray-800 hover:bg-gray-700 disabled:opacity-30 disabled:cursor-not-allowed text-gray-200 transition-colors cursor-pointer flex items-center justify-center shrink-0",title:"Last Page",children:s.jsx(Qne,{size:15})})]})]})},MMe=()=>{const[e,t]=I.useState([]),[n,r]=I.useState(0),[i,a]=I.useState(!1),[o,c]=I.useState(!1),[h,f]=I.useState(!1),[m,y]=I.useState(!1),[w,A]=I.useState(0),[S,C]=I.useState("0:00"),[T,D]=I.useState("0:00"),V=I.useRef(null);I.useEffect(()=>{const $=Qt(et(he,"podcasts"),ui("publishDate","desc"),vi(15));vn($).then(Y=>{const X=Y.docs.map(J=>({id:J.id,...J.data()}));t(X)}).catch(Y=>{Ks(Y,Ms.LIST,"podcasts")})},[]),I.useEffect(()=>{const $=Y=>{const J=Y.detail;if(J){if(Rl(J)){window.dispatchEvent(new CustomEvent("play-video-podcast",{detail:J}));return}y(!0),f(!1),t(ye=>{const ne=ye.findIndex(de=>de.id===J.id);if(ne>-1)return r(ne),a(!0),setTimeout(()=>{V.current&&V.current.play().then(()=>{a(!0)}).catch(console.error)},150),ye;{const de=[J,...ye];return r(0),a(!0),setTimeout(()=>{V.current&&V.current.play().then(()=>{a(!0)}).catch(console.error)},150),de}})}};return window.addEventListener("play-podcast",$),()=>{window.removeEventListener("play-podcast",$)}},[]),I.useEffect(()=>{V.current&&m&&(i?V.current.play().catch($=>{console.warn("Autoplay was prevented or source invalid:",$),a(!1)}):V.current.pause())},[n,e,m]);const L=()=>{V.current&&(i?(V.current.pause(),a(!1)):V.current.play().then(()=>{a(!0)}).catch(console.error))},K=()=>{if(V.current){const $=V.current.currentTime,Y=V.current.duration||0,X=$/Y*100;A(X||0);const J=ye=>{if(isNaN(ye))return"0:00";const ne=Math.floor(ye/60),de=Math.floor(ye%60);return`${ne}:${de<10?"0":""}${de}`};C(J($)),D(J(Y))}},Z=$=>{if(V.current&&V.current.duration){const Y=parseFloat($.target.value),X=Y/100*V.current.duration;V.current.currentTime=X,A(Y)}},q=()=>{e.length!==0&&(r($=>($+1)%e.length),a(!0))},B=()=>{e.length!==0&&(r($=>($-1+e.length)%e.length),a(!0))},z=()=>{V.current&&V.current.pause(),a(!1),y(!1),pe.success("Podcast Player closed.",{position:"bottom-right"})};if(!m||e.length===0)return null;const F=e[n];return s.jsxs("div",{className:"fixed inset-0 pointer-events-none z-[5000]",children:[s.jsx("audio",{ref:V,src:F.audioUrl||F.mediaUrl||"",onTimeUpdate:K,onEnded:q,preload:"none",hidden:!0}),s.jsx(or,{children:h?s.jsxs(Zt.div,{drag:!0,dragMomentum:!1,dragElastic:.05,initial:{opacity:0,scale:.8,y:50},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.8,y:50},transition:{type:"spring",damping:15},className:"absolute bottom-24 right-4 pointer-events-auto w-18 h-18 rounded-full bg-gray-950/95 backdrop-blur-xl border border-red-500/40 shadow-2xl flex items-center justify-center cursor-grab active:cursor-grabbing select-none group text-white h-18",title:"Draggable Podcast: Double-click to expand or drag anywhere",onDoubleClick:()=>f(!1),children:[s.jsxs("div",{className:"absolute inset-0.5 rounded-full overflow-hidden",children:[s.jsx("img",{src:F.thumbnail,className:`w-full h-full object-cover transition-transform ${i?"animate-[spin_20s_linear_infinite]":""}`,alt:""}),s.jsx("div",{className:"absolute inset-0 bg-black/60 flex flex-col items-center justify-center gap-1 opacity-100 group-hover:opacity-100 transition-opacity",children:s.jsx("button",{onClick:$=>{$.stopPropagation(),L()},className:"p-1.5 bg-red-600 rounded-full text-white hover:scale-110 transition-transform shadow-lg cursor-pointer",title:i?"Pause":"Play",children:i?s.jsx(tR,{size:10,fill:"currentColor"}):s.jsx(Yp,{size:10,fill:"currentColor",className:"ml-0.2"})})})]}),i&&s.jsx("span",{className:"absolute -inset-1 rounded-full border border-red-500/30"}),s.jsxs("div",{className:"absolute -top-1 -right-1 flex gap-1 items-center z-10 pointer-events-auto",children:[s.jsx("button",{onClick:$=>{$.stopPropagation(),f(!1)},className:"w-4.5 h-4.5 bg-blue-600 rounded-full flex items-center justify-center text-white text-[8px] hover:bg-blue-700 cursor-pointer shadow-sm",title:"Restore Player",children:s.jsx(r2,{size:8,strokeWidth:3})}),s.jsx("button",{onClick:$=>{$.stopPropagation(),z()},className:"w-4.5 h-4.5 bg-red-650 rounded-full flex items-center justify-center text-white text-[8px] hover:bg-red-700 cursor-pointer shadow-sm",title:"Close Podcast",children:s.jsx(er,{size:8,strokeWidth:3})})]})]}):s.jsxs(Zt.div,{drag:!0,dragMomentum:!1,dragElastic:.05,initial:{opacity:0,scale:.9,y:100},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:100},transition:{type:"spring",stiffness:260,damping:24},className:"absolute bottom-24 right-4 pointer-events-auto bg-gray-950/95 backdrop-blur-2xl border border-white/10 rounded-[2.5rem] shadow-[0_25px_60px_rgba(0,0,0,0.8)] p-5 select-none text-white overflow-hidden transition-all duration-300 w-80 md:w-88 flex flex-col justify-between",style:{maxHeight:o?"460px":"230px"},children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 border-b border-white/5 pb-2 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(uc,{size:11,className:"text-red-500"}),s.jsx("span",{className:"text-[8.5px] font-black text-gray-400 uppercase tracking-widest leading-none",children:"Broadcast Widget"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>c(!o),className:"p-1 hover:bg-white/10 rounded-lg text-gray-405 hover:text-white transition-all cursor-pointer",title:o?"Show Compact Player":"Show Up Next Queue",children:o?s.jsx(Bd,{size:14}):s.jsx(df,{size:14})}),s.jsx("button",{onClick:()=>f(!0),className:"p-1 hover:bg-white/10 rounded-lg text-gray-405 hover:text-white transition-all cursor-pointer",title:"Minimize to Bubble",children:s.jsx(bI,{size:13})}),s.jsx("button",{onClick:z,className:"p-1 hover:bg-red-900/40 rounded-lg text-red-405 hover:text-red-500 transition-all cursor-pointer",title:"Close and Exit",children:s.jsx(er,{size:13})})]})]}),s.jsx("div",{className:"flex justify-center py-1 cursor-grab active:cursor-grabbing text-gray-600 hover:text-gray-400 mb-2",children:s.jsx(Ere,{size:16})}),s.jsxs("div",{className:"flex items-center gap-3.5 text-left min-w-0",children:[s.jsx("img",{src:F.thumbnail,className:"w-13 h-13 rounded-2xl object-cover border border-white/10 shrink-0 shadow-xl",alt:""}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[7.5px] font-black uppercase text-red-500 tracking-wider bg-red-950/40 border border-red-900/30 px-1.5 py-0.2 rounded",children:F.category||"CAMPUS"}),s.jsxs("span",{className:"text-[7.5px] font-mono font-bold text-gray-400",children:["Host: ",F.author||"Broadcaster"]})]}),s.jsx("h4",{className:"text-xs font-black text-white truncate uppercase tracking-tight mt-1 leading-snug",children:F.title}),i&&s.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[s.jsx(kne,{size:9,className:"text-red-500 animate-[bounce_1s_infinite]"}),s.jsx("span",{className:"text-[7px] font-mono font-bold uppercase tracking-wider text-red-500",children:"Live Frequency Tuning..."})]})]})]}),s.jsxs("div",{className:"mt-4 shrink-0",children:[s.jsx("input",{type:"range",min:"0",max:"100",value:w,onChange:Z,className:"w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-red-600 focus:outline-none"}),s.jsxs("div",{className:"flex justify-between items-center text-[7.5px] font-mono font-bold text-gray-400 mt-1 uppercase tracking-wider",children:[s.jsx("span",{children:S}),s.jsx("span",{children:T})]})]}),s.jsxs("div",{className:"flex items-center justify-center gap-5 mt-3 shrink-0",children:[s.jsx("button",{onClick:B,className:"text-gray-400 hover:text-white hover:scale-105 transition-all p-1.5 bg-white/5 rounded-xl border border-white/5 cursor-pointer",title:"Previous Story",children:s.jsx(Nie,{size:14,fill:"currentColor"})}),s.jsx("button",{onClick:L,className:"w-10 h-10 bg-red-600 text-white rounded-2xl flex items-center justify-center hover:scale-110 active:scale-95 transition-all shadow-xl shadow-red-900/20 cursor-pointer",title:i?"Pause":"Play Episode",children:i?s.jsx(tR,{size:16,fill:"currentColor"}):s.jsx(Yp,{size:16,className:"ml-0.5",fill:"currentColor"})}),s.jsx("button",{onClick:q,className:"text-gray-400 hover:text-white hover:scale-105 transition-all p-1.5 bg-white/5 rounded-xl border border-white/5 cursor-pointer",title:"Next Story",children:s.jsx(Aie,{size:14,fill:"currentColor"})})]}),s.jsx(or,{children:o&&s.jsxs(Zt.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"overflow-hidden border-t border-white/5 mt-4 pt-3 text-left",children:[s.jsx("h5",{className:"text-[7.5px] font-black text-red-500 uppercase tracking-[0.25em] mb-2",children:"Playlist Queue"}),s.jsx("div",{className:"space-y-1.5 max-h-40 overflow-y-auto scrollbar-thin pr-1",children:e.slice(0,5).map(($,Y)=>s.jsxs("div",{onClick:()=>{r(Y),a(!0)},className:`flex items-center gap-2 p-1.5 rounded-xl cursor-pointer transition-all border ${Y===n?"bg-red-950/20 border-red-900/40":"bg-transparent border-transparent hover:bg-white/5"}`,children:[s.jsx("img",{src:$.thumbnail,className:"w-6 h-6 rounded-md object-cover",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[9px] font-black text-white truncate uppercase tracking-tight",children:$.title}),s.jsx("p",{className:"text-[7px] text-gray-400 truncate -mt-0.5",children:$.duration||"5m"})]}),Y===n&&i&&s.jsx("span",{className:"w-1.5 h-1.5 bg-red-600 rounded-full shrink-0 mr-1"})]},$.id))})]})})]})})]})},DV=()=>{const[e,t]=ie.useState([]),[n,r]=ie.useState(!0),[i,a]=ie.useState(""),[o,c]=ie.useState("All"),[h,f]=ie.useState("all"),[m,y]=ie.useState(null),[w,A]=ie.useState(null);ie.useEffect(()=>{const L=Qt(et(he,"podcasts"),ui("publishDate","desc"),vi(40));vn(L).then(Z=>{const q=Z.docs.map(B=>({id:B.id,...B.data()}));t(q),r(!1)}).catch(Z=>{console.error("Failed to load podcasts:",Z),r(!1)});const K=Z=>{var B;const q=Z;(B=q.detail)!=null&&B.id&&y(q.detail.id)};return window.addEventListener("play-podcast",K),()=>window.removeEventListener("play-podcast",K)},[]);const S=L=>{Rl(L)?(A(L),window.dispatchEvent(new CustomEvent("play-video-podcast",{detail:L})),pe.success(`Playing Video Episode: ${L.title}`,{icon:"🎬",position:"bottom-right",duration:3500})):(y(L.id),window.dispatchEvent(new CustomEvent("play-podcast",{detail:L})),pe.success(`Streaming Audio: ${L.title}`,{icon:"🎧",position:"bottom-right",duration:3500}))},C=e.filter(L=>!Rl(L)).length,T=e.filter(L=>Rl(L)).length,D=["All",...Array.from(new Set(e.map(L=>L.category).filter(Boolean)))],V=e.filter(L=>{var B,z,F,$;const K=Rl(L);if(h==="audio"&&K||h==="video"&&!K)return!1;const Z=((B=L.title)==null?void 0:B.toLowerCase().includes(i.toLowerCase()))||((z=L.author)==null?void 0:z.toLowerCase().includes(i.toLowerCase()))||((F=L.category)==null?void 0:F.toLowerCase().includes(i.toLowerCase()))||(($=L.description)==null?void 0:$.toLowerCase().includes(i.toLowerCase())),q=o==="All"||L.category===o;return Z&&q});return s.jsxs("div",{className:"py-6 px-4 md:px-8 max-w-7xl mx-auto",children:[s.jsxs("div",{className:"bg-gradient-to-r from-gray-950 via-gray-900 to-black text-white p-5 md:p-6 rounded-3xl mb-8 border border-white/10 shadow-xl relative overflow-hidden flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-4 text-left",children:[s.jsx("div",{className:"p-3 bg-red-600/20 text-red-500 border border-red-500/30 rounded-2xl shrink-0",children:s.jsx(D2,{size:26})}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-xl md:text-3xl font-serif font-black tracking-tight text-white uppercase italic",children:"Campus Podcasts"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider px-2 py-0.5 rounded-md bg-white/10 text-gray-300",children:"Audio & Video Hub"})]}),s.jsx("p",{className:"text-[11px] text-gray-400 font-medium mt-0.5",children:"Official Investigative Audio Newsroom, Direct Video Dispatches & YouTube Episodes"})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("div",{className:"px-3.5 py-1.5 bg-white/5 border border-white/10 text-white rounded-xl flex items-center gap-2",children:[s.jsx(uc,{size:14,className:"text-red-500"}),s.jsxs("span",{className:"text-xs font-mono font-black",children:[e.length," Total"]})]}),s.jsxs("div",{className:"px-3.5 py-1.5 bg-emerald-500/10 border border-emerald-500/30 text-emerald-400 rounded-xl flex items-center gap-2",children:[s.jsx(Zh,{size:14,className:"text-emerald-400"}),s.jsxs("span",{className:"text-xs font-mono font-black",children:[C," Audio"]})]}),s.jsxs("div",{className:"px-3.5 py-1.5 bg-red-500/10 border border-red-500/30 text-red-400 rounded-xl flex items-center gap-2",children:[s.jsx(Ea,{size:14,className:"text-red-400"}),s.jsxs("span",{className:"text-xs font-mono font-black",children:[T," Video"]})]})]})]}),s.jsxs("div",{className:"space-y-4 mb-8",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-1.5 bg-gray-100 p-1 rounded-2xl",children:[s.jsxs("button",{onClick:()=>f("all"),className:`px-3.5 py-1.5 rounded-xl text-xs font-black uppercase tracking-wider transition-all cursor-pointer ${h==="all"?"bg-gray-900 text-white shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:["All Formats (",e.length,")"]}),s.jsxs("button",{onClick:()=>f("audio"),className:`flex items-center gap-1.5 px-3.5 py-1.5 rounded-xl text-xs font-black uppercase tracking-wider transition-all cursor-pointer ${h==="audio"?"bg-emerald-600 text-white shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Zh,{size:13})," Audio (",C,")"]}),s.jsxs("button",{onClick:()=>f("video"),className:`flex items-center gap-1.5 px-3.5 py-1.5 rounded-xl text-xs font-black uppercase tracking-wider transition-all cursor-pointer ${h==="video"?"bg-red-600 text-white shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Ea,{size:13})," Video (",T,")"]})]}),s.jsxs("div",{className:"relative w-full sm:w-80",children:[s.jsx("input",{type:"text",placeholder:"Search audio or video episodes...",value:i,onChange:L=>a(L.target.value),className:"w-full pl-10 pr-4 py-2.5 rounded-xl border border-gray-200 text-xs font-bold text-gray-900 focus:border-red-600 focus:ring-0 outline-none bg-white shadow-xs"}),s.jsx(Rp,{size:14,className:"absolute left-3.5 top-3.5 text-gray-400"})]})]}),s.jsx("div",{className:"flex items-center gap-2 overflow-x-auto pb-2 scrollbar-none",children:D.map(L=>s.jsx("button",{onClick:()=>c(L),className:`px-3.5 py-1.5 rounded-xl text-xs font-black uppercase tracking-wider transition-all whitespace-nowrap cursor-pointer ${o===L?"bg-red-650 text-white shadow-md":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:L},L))})]}),n?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20",children:[s.jsx(Er,{size:32,className:"text-red-600 animate-spin mb-4"}),s.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-gray-400",children:"Tuning broadcast channels..."})]}):V.length===0?s.jsxs("div",{className:"bg-white py-16 px-6 rounded-3xl border border-gray-200 shadow-xs max-w-xl mx-auto text-center",children:[s.jsx(D2,{size:32,className:"mx-auto mb-4 text-gray-300"}),s.jsx("h4",{className:"text-sm font-black uppercase tracking-wider text-gray-900",children:"No matching episodes found"}),s.jsx("p",{className:"text-[10px] uppercase font-bold tracking-widest text-gray-400 mt-2",children:"Try switching format filter or adjusting your search keyword."})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:V.map(L=>{var B;const K=Rl(L),Z=m===L.id&&!K,q=(w==null?void 0:w.id)===L.id;return s.jsxs("div",{onClick:()=>S(L),className:`group bg-white p-4 rounded-3xl border transition-all duration-300 text-left flex flex-col justify-between cursor-pointer relative overflow-hidden ${Z||q?K?"border-red-600 shadow-xl ring-2 ring-red-500/30":"border-emerald-500 shadow-lg ring-2 ring-emerald-500/20":"border-gray-150 hover:border-red-600 hover:shadow-md"}`,children:[s.jsxs("div",{children:[s.jsxs("div",{className:"aspect-square bg-gray-950 mb-4 relative overflow-hidden flex items-center justify-center rounded-2xl group-hover:scale-[1.01] transition-transform duration-500",children:[s.jsx(Li,{src:L.thumbnail||(K?"https://images.unsplash.com/photo-1578022761797-b8636ac1773c?auto=format&fit=crop&q=80&w=500":"https://images.unsplash.com/photo-1590602847861-f357a9332bbc?auto=format&fit=crop&q=80&w=500"),className:"absolute inset-0 w-full h-full object-cover opacity-90 group-hover:opacity-100 transition-opacity",alt:L.title}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/85 via-black/25 to-transparent"}),s.jsx("span",{className:"absolute top-3 left-3 text-[8px] font-black uppercase tracking-widest px-2.5 py-1 bg-black/60 text-white rounded-lg backdrop-blur-xs shadow-sm border border-white/10",children:L.category||"Campus Vibe"}),s.jsx("span",{className:`absolute top-3 right-3 text-[8.5px] font-black uppercase tracking-widest px-2.5 py-1 rounded-lg flex items-center gap-1.5 shadow-md border ${K?"bg-red-600 text-white border-red-500/50 animate-pulse":"bg-emerald-600 text-white border-emerald-500/50"}`,children:K?s.jsxs(s.Fragment,{children:[s.jsx(Ea,{size:11,className:"shrink-0"})," VIDEO"]}):s.jsxs(s.Fragment,{children:[s.jsx(Zh,{size:11,className:"shrink-0"})," AUDIO"]})}),Z&&s.jsxs("span",{className:"absolute top-11 right-3 text-[8px] font-black uppercase tracking-widest px-2 py-0.5 bg-emerald-500 text-white rounded-md flex items-center gap-1 shadow-md",children:[s.jsx(Gie,{size:9})," Playing Audio"]}),s.jsx("button",{className:`absolute bottom-4 right-4 w-11 h-11 rounded-2xl flex items-center justify-center shadow-xl group-hover:scale-110 transition-all cursor-pointer ${K?"bg-red-600 text-white shadow-red-900/30":"bg-white text-red-650 shadow-gray-900/20"}`,title:K?"Watch Video Episode":"Listen Audio Podcast",children:K?s.jsx(Yp,{size:16,fill:"currentColor",className:"ml-0.5"}):s.jsx(Yp,{size:16,fill:"currentColor",className:"ml-0.5"})}),s.jsxs("span",{className:"absolute bottom-4 left-4 text-[9px] font-mono font-bold text-white/95 bg-black/50 px-2.5 py-1 rounded-lg backdrop-blur-xs border border-white/10 flex items-center gap-1",children:["⏱️ ",L.duration||(K?"Video":"5:00")]})]}),s.jsx("div",{className:"flex items-center justify-between mb-1",children:s.jsxs("p",{className:"text-[9px] font-black text-red-655 uppercase tracking-widest leading-none truncate",children:["Host: ",L.author||"Campus Desk"]})}),s.jsx("h3",{className:"text-base font-serif font-black text-gray-950 leading-tight group-hover:text-red-655 transition-colors uppercase tracking-tight line-clamp-2 mt-1",children:L.title}),L.description&&s.jsx("p",{className:"text-[10px] text-gray-500 line-clamp-2 mt-1.5 leading-relaxed",children:L.description})]}),s.jsxs("div",{className:"pt-3 mt-4 border-t border-gray-100 flex items-center justify-between",children:[s.jsx("span",{className:"text-[8.5px] font-mono font-black uppercase tracking-wider flex items-center gap-1.5 text-gray-600",children:K?s.jsxs(s.Fragment,{children:[s.jsx(yre,{size:12,className:"text-red-600"})," Video Broadcast"]}):s.jsxs(s.Fragment,{children:[s.jsx(uc,{size:12,className:"text-emerald-600"})," Audio Story"]})}),s.jsx("span",{className:"text-[8px] font-mono font-bold text-gray-400",children:(B=L.publishDate)!=null&&B.seconds?new Date(L.publishDate.seconds*1e3).toLocaleDateString():"Active"})]})]},L.id)})}),w&&s.jsx(xP,{podcast:w,onClose:()=>A(null),relatedPodcasts:e.filter(L=>L.id!==w.id),onSelectPodcast:L=>A(L)})]})},LMe=({debateId:e})=>{const[t,n]=I.useState([]),[r,i]=I.useState(""),[a,o]=I.useState(!1),[c,h]=I.useState(!1);I.useEffect(()=>{o(!0);const m=Qt(et(he,"debates",e,"comments"),ui("createdAt","desc"));vn(m).then(y=>{const w=y.docs.map(A=>{const S=A.data();return{id:A.id,...S,createdAt:S.createdAt?S.createdAt.toDate?S.createdAt.toDate():new Date(S.createdAt):new Date}});n(w),o(!1)}).catch(y=>{console.warn("Failed to subscriber to debate comments",y),o(!1)})},[e]);const f=async m=>{if(m.preventDefault(),!Ne.currentUser){pe.error("Please log in to participate in the debate!");return}if(r.trim()){h(!0);try{const y=Ne.currentUser;if(!y){pe.error("Please log in to participate in the debate!"),h(!1);return}const w={text:r.trim(),userId:y.uid,author:y.displayName||(y.email?y.email.split("@")[0]:"Anonymous Participant"),createdAt:En()},A=await ur(et(he,"debates",e,"comments"),w);n(S=>[{id:A.id,text:r.trim(),userId:y.uid,author:y.displayName||(y.email?y.email.split("@")[0]:"Anonymous Participant"),createdAt:new Date},...S]);try{await Cn(Je(he,"debates",e),{commentsCount:Ir(1)})}catch(S){console.warn("Could not increment denormalized debate comment counter:",S)}i(""),pe.success("Argument posted!")}catch(y){pe.error("Failed to post comment: "+y.message)}finally{h(!1)}}};return s.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(bi,{size:16,className:"text-gray-500"}),s.jsxs("h4",{className:"text-[10px] font-black uppercase tracking-widest text-gray-500",children:["Discourse Thread (",t.length,")"]})]}),Ne.currentUser?s.jsxs("form",{onSubmit:f,className:"flex gap-2",children:[s.jsx("input",{type:"text",value:r,onChange:m=>i(m.target.value),placeholder:"State your position/stance...",className:"flex-1 px-4 py-2.5 bg-gray-50 border border-gray-150 rounded-xl text-xs font-bold focus:bg-white focus:border-accent outline-none transition-all placeholder:text-gray-400"}),s.jsx("button",{type:"submit",disabled:c||!r.trim(),className:"px-4 bg-accent hover:bg-opacity-90 disabled:opacity-50 text-white rounded-xl transition-all flex items-center justify-center cursor-pointer",children:c?s.jsx(Er,{size:14,className:"animate-spin"}):s.jsx(Eo,{size:14})})]}):s.jsx("div",{className:"bg-amber-50 border border-amber-100 p-3 rounded-xl text-center",children:s.jsx("p",{className:"text-[10px] font-bold text-amber-800 uppercase tracking-wide",children:"🔒 Log in to participate in academic discourse."})}),a?s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(Er,{className:"animate-spin text-gray-400",size:16})}):t.length===0?s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest text-center py-2",children:"Be the first to make a point!"}):s.jsx("div",{className:"space-y-2.5 max-h-60 overflow-y-auto pr-1",children:t.map(m=>s.jsxs("div",{className:"p-3 bg-gray-50 rounded-xl space-y-1 text-left",children:[s.jsxs("div",{className:"flex items-center justify-between text-[9px] font-black uppercase tracking-wider text-gray-500",children:[s.jsxs("span",{className:"flex items-center gap-1 text-accent",children:[s.jsx(nE,{size:10}),m.author]}),s.jsx("span",{children:m.createdAt.toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),s.jsx("p",{className:"text-xs font-medium text-gray-850 leading-relaxed break-words",children:m.text})]},m.id))})]})},RS={id:"current-campus-poll",question:"Should university lecture attendance be strictly tracked via biometric scanners, or should it remain fully optional?",options:[{text:"Strictly tracked (Biometrics)",votes:142},{text:"Fully optional / Student autonomy",votes:289},{text:"Hybrid (Only for key lab sessions)",votes:95}],totalVotes:526,expiresAt:null,status:"active"},UMe=()=>{var $,Y,X;const[e,t]=I.useState(RS),[n,r]=I.useState(!1),[i,a]=I.useState(null),[o,c]=I.useState(!1),[h,f]=I.useState({});I.useEffect(()=>{if(!e)return;(async()=>{try{const ne=(await vn(Qt(et(he,"articles"),ui("publishDate","desc"),vi(15)))).docs.map(be=>({id:be.id,...be.data()})),de={};e.options.forEach(be=>{const Ce=be.text.replace(/^(support|vote\s+for|vote|elect)\s+/i,"").trim().toLowerCase(),Ke=ne.find(G=>{const se=G.title.toLowerCase().replace(/^(support|vote\s+for|vote|elect)\s+/i,"").trim();return se===Ce||G.title.toLowerCase().includes(Ce)||Ce.includes(se)});Ke&&(de[be.text]={bio:Ke.summary||Ke.content||"",votes:Ke.likeCount||0,image:Ke.featuredImageUrl||"",id:Ke.id})}),f(de)}catch(ye){console.warn("Silent ignore bio fetching error:",ye)}})()},[e]);const[m,y]=I.useState(!1),[w,A]=I.useState([]),[S,C]=I.useState(""),[T,D]=I.useState(!1),[V,L]=I.useState(null),[K,Z]=I.useState(""),[q,B]=I.useState(0);I.useEffect(()=>{if(!e)return;const J=Qt(et(he,"polls",e.id,"comments"));vn(J).then(ye=>{B(ye.size)}).catch(ye=>{console.warn("Silent ignore count fetch error:",ye)})},[e]),I.useEffect(()=>{if(!e||!m)return;const J=Qt(et(he,"polls",e.id,"comments"),ui("createdAt","desc"));vn(J).then(ye=>{const ne=ye.docs.map(de=>({id:de.id,...de.data()}));A(ne)}).catch(ye=>{Ks(ye,Ms.LIST,`polls/${e.id}/comments`)})},[e,m]);const z=async(J,ye=null)=>{var de,be;if(J.preventDefault(),!Ne.currentUser||!e)return;const ne=ye?K:S;if(ne.trim()){D(!0);try{const Ce=et(he,"polls",e.id,"comments");let Ke={};if(ye){const xe=w.find(re=>re.id===ye);xe&&(Ke={parentId:ye,replyToAuthor:xe.authorName,replyToContent:xe.content.substring(0,50)})}const G={content:ne.trim(),userId:Ne.currentUser.uid,authorName:Ne.currentUser.displayName||((de=Ne.currentUser.email)==null?void 0:de.split("@")[0])||"Peer",photoURL:Ne.currentUser.photoURL||"",createdAt:new Date,...Ke},se=await ur(Ce,{content:ne.trim(),userId:Ne.currentUser.uid,authorName:Ne.currentUser.displayName||((be=Ne.currentUser.email)==null?void 0:be.split("@")[0])||"Peer",photoURL:Ne.currentUser.photoURL||"",createdAt:En(),...Ke});A(xe=>[{id:se.id,...G},...xe]),B(xe=>xe+1),ye?(Z(""),L(null)):C("")}catch(Ce){console.error("Error dispatching poll comment:",Ce)}finally{D(!1)}}};I.useEffect(()=>{const J=et(he,"polls"),ye=Qt(J,ui("createdAt","desc"),vi(15));vn(ye).then(ne=>{if(!ne.empty){const de=ne.docs.find(be=>{var Ce;return((Ce=be.data())==null?void 0:Ce.status)==="active"})||ne.docs[0];if(de){t({...de.data(),id:de.id});return}}t(RS)}).catch(ne=>{console.warn("Falling back to default poll on query error:",ne),t(RS)})},[]),I.useEffect(()=>{Ne.currentUser&&e&&(async()=>{try{const ye=Je(he,"polls",e.id,"userVotes",Ne.currentUser.uid),ne=await cs(ye);ne.exists()&&(r(!0),a(ne.data().optionIndex))}catch(ye){ye.code!=="permission-denied"&&console.error("Error checking vote status:",ye)}})()},[e]);const F=async J=>{if(Ne.currentUser&&!(n||o||!e)){c(!0);try{const ye=Je(he,"polls",e.id),ne=Je(he,"polls",e.id,"userVotes",Ne.currentUser.uid);await Rr(ne,{userId:Ne.currentUser.uid,optionIndex:J,timestamp:new Date});const de=await cs(ye);if(de.exists()){const Ce=[...de.data().options];Ce[J].votes+=1,await Cn(ye,{options:Ce,totalVotes:Ir(1)})}r(!0),a(J)}catch(ye){console.error("Error voting:",ye),ye.code==="permission-denied"&&t(null)}finally{c(!1)}}};return e?s.jsxs("div",{className:"bg-white border border-gray-100 overflow-hidden group",children:[s.jsxs("div",{className:"bg-gray-900 p-6 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(FS,{className:"text-red-500",size:24}),s.jsx("h3",{className:"text-xl font-black text-white uppercase tracking-tighter italic",children:"Campus Pulse Poll"})]}),s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1 bg-white/10 rounded-full",children:[s.jsx("span",{className:"w-1.5 h-1.5 bg-green-500 rounded-full"}),s.jsx("span",{className:"text-[8px] font-black text-white uppercase tracking-widest",children:"Ongoing"})]})]}),s.jsxs("div",{className:"p-8 space-y-6",children:[s.jsx("h4",{className:"text-2xl font-bold text-gray-900 leading-tight tracking-tight",children:e.question}),s.jsx("div",{className:"space-y-3",children:e.options.map((J,ye)=>{const ne=e.totalVotes>0?Math.round(J.votes/e.totalVotes*100):0,de=i===ye,be=J.text.replace(/^(support|vote\s+for|vote|elect)\s+/i,"").trim(),Ce=h[J.text],Ke=Ce?`${be} (${Ce.votes} Votes)`:be;return s.jsx("button",{disabled:n||o||!Ne.currentUser,onClick:()=>F(ye),className:`w-full relative group/option flex flex-col transition-all overflow-hidden rounded-2xl border border-gray-150/80 shadow-3xs ${n?"cursor-default bg-white":"hover:scale-[1.01] cursor-pointer bg-gray-50"}`,children:s.jsxs("div",{className:`w-full p-5 flex flex-col gap-2.5 transition-colors ${de?"bg-red-50/15":"bg-transparent"}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3 w-full",children:[s.jsx("div",{className:`w-5 h-5 rounded-full border-2 flex items-center justify-center transition-all shrink-0 mt-0.5 ${de?"border-accent bg-accent":"border-gray-300"}`,children:de&&s.jsx(lc,{size:12,className:"text-white"})}),Ce!=null&&Ce.image?s.jsx("img",{src:Ce.image||void 0,alt:"",className:"w-10 h-10 rounded-lg object-cover shrink-0 border border-gray-150"}):null,s.jsxs("div",{className:"flex-1 text-left",children:[s.jsx("span",{className:`text-[13px] font-extrabold leading-snug transition-colors uppercase tracking-tight block ${de?"text-accent":"text-gray-900"}`,children:Ke}),(Ce==null?void 0:Ce.bio)&&s.jsx("p",{className:"text-[11px] text-gray-500 font-medium line-clamp-2 leading-relaxed mt-1 select-text",children:Ce.bio}),(Ce==null?void 0:Ce.id)&&s.jsx("button",{onClick:G=>{G.stopPropagation();const se=new CustomEvent("open-article",{detail:{id:Ce.id}});window.dispatchEvent(se)},className:"text-[9px] font-black text-red-650 hover:underline uppercase tracking-widest mt-1.5 inline-block cursor-pointer",children:"View Candidate Profile →"})]})]}),n&&s.jsxs("div",{className:"text-right shrink-0",children:[s.jsxs("span",{className:"text-sm font-black text-gray-950 font-mono italic block",children:[ne,"%"]}),s.jsxs("span",{className:"text-[8px] font-bold text-gray-400 font-mono uppercase tracking-widest",children:[J.votes," votes"]})]})]}),n&&s.jsx("div",{className:"w-full h-3 bg-gray-100 rounded-full overflow-hidden mt-1 relative border border-gray-150/40",children:s.jsx(Zt.div,{initial:{width:0},animate:{width:`${ne}%`},transition:{duration:.8,ease:"easeOut"},className:`h-full rounded-full transition-all ${de?"bg-accent":"bg-gray-400"}`})})]})},ye)})}),s.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-100 select-none",children:[s.jsxs("div",{className:"flex items-center gap-2 text-gray-450 text-[10px] font-bold uppercase tracking-wider",children:[s.jsx(_o,{size:14,className:"text-gray-450"}),s.jsxs("span",{children:[e.totalVotes," Votes"]})]}),s.jsxs("button",{onClick:()=>y(!m),className:"flex items-center gap-1.5 text-red-650 hover:text-red-700 font-extrabold cursor-pointer transition-colors",children:[s.jsx(bi,{size:14}),s.jsx("span",{className:"text-[10px] uppercase tracking-widest",children:m?"Close Debates":`Discuss (${q})`})]})]}),s.jsx(or,{children:m&&s.jsxs(Zt.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mt-6 pt-6 border-t border-gray-100 overflow-hidden text-left",children:[Ne.currentUser?s.jsx("form",{onSubmit:J=>z(J,null),className:"mb-6",children:s.jsxs("div",{className:"flex gap-2.5 items-start",children:[s.jsx("img",{src:(($=Ne.currentUser)==null?void 0:$.photoURL)||`https://ui-avatars.com/api/?name=${encodeURIComponent(((Y=Ne.currentUser)==null?void 0:Y.displayName)||((X=Ne.currentUser)==null?void 0:X.email)||"Peer")}&background=random`,className:"w-8 h-8 rounded-full border border-gray-150 object-cover mt-0.5",alt:""}),s.jsxs("div",{className:"flex-1 space-y-2",children:[s.jsx("textarea",{value:S,onChange:J=>C(J.target.value),placeholder:"State your stance on this debate...",rows:2,className:"w-full text-xs font-sans p-3 bg-gray-50 border border-gray-150 rounded-xl outline-none focus:outline-none focus:ring-1 focus:ring-red-500/20 focus:border-red-500 transition-all resize-none placeholder-gray-400"}),s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{type:"submit",disabled:T||!S.trim(),className:"bg-gray-950 text-white font-extrabold text-[9px] uppercase tracking-wider h-7 px-4 rounded-full hover:bg-red-650 transition-colors disabled:opacity-40 select-none cursor-pointer",children:"Dispatch Thought"})})]})]})}):s.jsx("div",{className:"bg-gray-50 rounded-xl p-3 text-center mb-6 border border-gray-100",children:s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Sign in to join the discussion"})}),s.jsx("div",{className:"space-y-4 max-h-96 overflow-y-auto pr-1",children:w.filter(J=>!J.parentId).length>0?w.filter(J=>!J.parentId).map(J=>{var de;const ye=w.filter(be=>be.parentId===J.id),ne=V===J.id;return s.jsxs("div",{className:"space-y-3.5 border-b border-gray-50 pb-4 last:border-0 last:pb-0",children:[s.jsxs("div",{className:"flex gap-2.5 items-start",children:[s.jsx("img",{src:J.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(J.authorName)}&background=random`,className:"w-7 h-7 rounded-full border border-gray-150 object-cover",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] font-black text-gray-950 uppercase tracking-tight",children:J.authorName}),s.jsx("span",{className:"text-[8px] font-bold text-gray-400 uppercase tracking-wider",children:(de=J.createdAt)!=null&&de.toDate?new Date(J.createdAt.toDate().getTime()).toLocaleDateString():"Now"})]}),s.jsx("p",{className:"text-xs text-gray-750 leading-relaxed font-sans mt-1",children:J.content}),Ne.currentUser&&s.jsx("div",{className:"flex items-center gap-4 mt-2",children:s.jsx("button",{type:"button",onClick:()=>{L(V===J.id?null:J.id),Z("")},className:"text-[9px] font-extrabold text-blue-600 hover:text-blue-700 uppercase tracking-widest cursor-pointer hover:underline",children:ne?"Cancel":"Reply"})})]})]}),ye.length>0&&s.jsx("div",{className:"ml-7 pl-3 border-l-2 border-gray-100/80 space-y-3",children:ye.map(be=>{var Ce;return s.jsxs("div",{className:"flex gap-2.5 items-start",children:[s.jsx("img",{src:be.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(be.authorName)}&background=random`,className:"w-6 h-6 rounded-full border border-gray-150 object-cover mt-0.5",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] font-black text-gray-950 uppercase tracking-tight",children:be.authorName}),s.jsx("span",{className:"text-[8px] font-bold text-gray-400 uppercase tracking-wider",children:(Ce=be.createdAt)!=null&&Ce.toDate?new Date(be.createdAt.toDate().getTime()).toLocaleDateString():"Now"})]}),s.jsxs("p",{className:"text-xs text-gray-750 leading-relaxed font-sans mt-0.5",children:[s.jsxs("span",{className:"text-blue-650 font-bold mr-1",children:["@",be.replyToAuthor]}),be.content]})]})]},be.id)})}),ne&&s.jsx("form",{onSubmit:be=>z(be,J.id),className:"ml-7 pl-3 border-l-2 border-red-100",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:K,onChange:be=>Z(be.target.value),placeholder:`Reply to @${J.authorName}...`,className:"flex-1 text-xs font-sans p-2 bg-gray-50 border border-gray-150 rounded-lg outline-none focus:ring-1 focus:ring-red-500/20 focus:border-red-500 transition-all placeholder-gray-400"}),s.jsx("button",{type:"submit",disabled:T||!K.trim(),className:"bg-red-600 text-white font-extrabold text-[8.5px] uppercase tracking-wider px-3 rounded-lg hover:bg-gray-950 transition-colors disabled:opacity-40 cursor-pointer",children:"Send"})]})})]},J.id)}):s.jsx("div",{className:"text-center py-6",children:s.jsx("p",{className:"text-[10px] font-black text-gray-350 uppercase tracking-widest italic",children:"The comments are silent. Dispatch your voice."})})})]})})]})]}):null},BMe=({url:e,isOpen:t,onClose:n,title:r})=>{const[i,a]=I.useState(e||""),[o,c]=I.useState(0),[h,f]=I.useState(!1),[m,y]=I.useState(!0);if(ie.useEffect(()=>{if(e){let T=e;!T.startsWith("http://")&&!T.startsWith("https://")&&(T="https://"+T),a(T),y(!0);const D=setTimeout(()=>{y(!1)},1500);return()=>clearTimeout(D)}},[e,o]),!t||!e)return null;const w=()=>{y(!0),c(T=>T+1)},A=()=>{navigator.clipboard.writeText(i),f(!0),pe.success("URL copied to clipboard!",{id:"browser-copy"}),setTimeout(()=>f(!1),2e3)},S=()=>{window.open(i,"_blank","noopener,noreferrer")};let C="web.page";try{C=new URL(i).hostname}catch{C=i}return s.jsx(or,{children:s.jsxs("div",{className:"fixed inset-0 z-[9990] flex flex-col bg-zinc-950/90 backdrop-blur-xl animate-fade-in",children:[s.jsxs("div",{className:"bg-zinc-900 border-b border-zinc-800 px-3 py-2.5 flex items-center justify-between gap-2 shadow-lg shrink-0 text-white",children:[s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("button",{onClick:n,className:"p-2 rounded-xl bg-zinc-800 hover:bg-red-600 text-zinc-300 hover:text-white transition-colors cursor-pointer",title:"Close In-App Browser",children:s.jsx(er,{size:16})}),s.jsx("button",{onClick:w,className:"p-2 rounded-xl bg-zinc-800 hover:bg-zinc-700 text-zinc-300 hover:text-white transition-colors cursor-pointer",title:"Reload Page",children:s.jsx(dF,{size:14,className:m?"animate-spin":""})})]}),s.jsxs("div",{className:"flex-1 max-w-2xl bg-zinc-950 border border-zinc-800 hover:border-zinc-700 rounded-xl px-3 py-1.5 flex items-center gap-2 transition-all",children:[s.jsx(lF,{size:12,className:"text-emerald-500 shrink-0"}),s.jsx("span",{className:"text-[10px] font-mono font-bold text-emerald-400 shrink-0 uppercase tracking-wider hidden sm:inline",children:"HTTPS"}),s.jsx("span",{className:"text-zinc-500 text-[11px] font-mono",children:"|"}),s.jsx("input",{type:"text",readOnly:!0,value:i,className:"w-full bg-transparent text-xs font-mono text-zinc-200 outline-none truncate"}),s.jsx("button",{onClick:A,className:"text-zinc-400 hover:text-white p-1 rounded transition-colors shrink-0 cursor-pointer",title:"Copy URL",children:h?s.jsx(Bu,{size:13,className:"text-emerald-400"}):s.jsx(n2,{size:13})})]}),s.jsx("div",{className:"flex items-center gap-2 shrink-0",children:s.jsxs("button",{onClick:S,className:"px-3 py-1.5 rounded-xl bg-zinc-800 hover:bg-zinc-700 text-zinc-200 hover:text-white text-xs font-mono font-bold flex items-center gap-1.5 transition-colors cursor-pointer",title:"Open in new browser window",children:[s.jsx($a,{size:13}),s.jsx("span",{className:"hidden md:inline text-[10px] uppercase tracking-wider",children:"External"})]})})]}),s.jsxs("div",{className:"flex-1 relative bg-white w-full h-full overflow-hidden",children:[m&&s.jsxs("div",{onClick:()=>y(!1),className:"absolute inset-0 bg-zinc-950/20 backdrop-blur-sm z-10 flex flex-col items-center justify-center cursor-pointer space-y-3 transition-opacity duration-300",title:"Click to dismiss overlay",children:[s.jsx("div",{className:"w-10 h-10 border-3 border-red-600 border-t-transparent rounded-full animate-spin"}),s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-zinc-900/90 text-white rounded-full border border-zinc-800 shadow-xl",children:[s.jsx(S0,{size:14,className:"text-red-500 "}),s.jsxs("span",{className:"text-xs font-mono uppercase tracking-widest font-bold",children:["Connecting to ",C,"..."]})]})]}),s.jsx("iframe",{src:i,onLoad:()=>y(!1),className:"w-full h-full border-0",title:r||"Inbuilt App Browser",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; camera; microphone; geolocation",sandbox:"allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"},o)]})]})})},zMe=({size:e="md",showBadge:t=!1,className:n=""})=>{const r={xs:"w-6 h-6 text-[10px]",sm:"w-8 h-8 text-xs",md:"w-10 h-10 text-sm",lg:"w-14 h-14 text-base"};return s.jsxs("div",{className:Fe("relative inline-flex items-center gap-2 group select-none",n),children:[s.jsxs("div",{className:Fe("relative rounded-2xl flex items-center justify-center shrink-0 overflow-hidden shadow-lg","bg-gradient-to-br from-cyan-950 via-slate-900 to-purple-950 border border-cyan-400/50","shadow-cyan-500/25",r[e]),children:[s.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-cyan-400 via-blue-500 to-purple-500 rounded-2xl opacity-40 blur-xs group-hover:opacity-80 transition-opacity"}),s.jsx("img",{src:zo,alt:"Mega AI Avatar",className:"w-full h-full object-cover rounded-2xl relative z-10"}),s.jsx("div",{className:"absolute top-0.5 right-0.5 w-1.5 h-1.5 bg-cyan-400 rounded-full shadow-[0_0_6px_#38bdf8] z-20 animate-pulse"})]}),t&&s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-extrabold text-xs tracking-tight bg-gradient-to-r from-cyan-400 via-blue-400 to-purple-400 bg-clip-text text-transparent",children:"Mega AI"}),s.jsxs("span",{className:"bg-gradient-to-r from-cyan-950 to-blue-900 border border-cyan-500/40 text-cyan-300 text-[8px] font-mono font-black px-1.5 py-0.5 rounded-md flex items-center gap-1 shadow-2xs",children:[s.jsx(mF,{size:9,className:"text-cyan-400 shrink-0"}),s.jsx("span",{children:"NEURAL CORE"})]})]}),s.jsxs("span",{className:"text-[9px] font-mono text-cyan-500/80 flex items-center gap-1",children:[s.jsx(ore,{size:9})," Autonomous Quantum Intelligence"]})]})]})};let op=null,MV=null,DS=null;const bw=e=>{var n;return e.username?e.username:(e.displayName||((n=e.email)==null?void 0:n.split("@")[0])||"peer").toLowerCase().replace(/[^a-z0-9]/g,"")},VMe=e=>{if(!e)return[];const t=/(https?:\/\/[^\s]+)/g;return e.match(t)||[]},m1=(e,t)=>{if(!e)return"";const n=/(https?:\/\/[^\s]+|@Mega\s+AI|@Mega|@megaai|@Me|@[a-zA-Z0-9_\-]+|#[a-zA-Z0-9_\-]+)/gi;return e.split(n).map((i,a)=>i?i.startsWith("http://")||i.startsWith("https://")?s.jsx("a",{href:i,onClick:o=>{o.preventDefault(),o.stopPropagation(),t?t(i):window.open(i,"_blank","noopener,noreferrer")},className:"text-blue-600 font-bold hover:underline select-text inline-flex items-center gap-0.5 break-all cursor-pointer",children:i},a):/^@(Mega\s+AI|Mega|megaai|Me)$/i.test(i)?s.jsxs("span",{className:"bg-gradient-to-r from-amber-500 via-purple-600 to-red-600 text-white font-extrabold text-[10px] px-2 py-0.5 rounded-full inline-flex items-center gap-1 shadow-xs my-0.5 select-none",children:[s.jsx(Zi,{size:10,className:"text-amber-200 shrink-0"})," ",i]},a):i.startsWith("@")?s.jsx("span",{className:"text-blue-600 font-extrabold hover:underline select-text bg-blue-50/80 border border-blue-100 px-1 py-0.2 rounded mx-0.5",children:i},a):i.startsWith("#")?s.jsx("span",{className:"text-red-650 font-black hover:underline select-text bg-red-50/80 px-1.5 py-0.5 rounded-md border border-red-200/80 mx-0.5 inline-block",children:i},a):i:null)},vw={},FMe=({url:e,onOpenUrl:t})=>{const[n,r]=I.useState(()=>{if(vw[e])return vw[e];try{const f=localStorage.getItem(`lp_${e}`);if(f){const m=JSON.parse(f);return vw[e]=m,m}}catch{}return null});I.useEffect(()=>{if(n)return;let f=!0;return(async()=>{var y,w,A;try{const S=await fetch(`https://api.microlink.io?url=${encodeURIComponent(e)}`);if(S.ok){const C=await S.json();if(C.status==="success"&&C.data){const T={title:C.data.title||C.data.publisher||e,description:C.data.description||"",image:((y=C.data.image)==null?void 0:y.url)||((w=C.data.logo)==null?void 0:w.url)||"",logo:((A=C.data.logo)==null?void 0:A.url)||`https://www.google.com/s2/favicons?domain=${e}&sz=64`,publisher:C.data.publisher||""};vw[e]=T;try{localStorage.setItem(`lp_${e}`,JSON.stringify(T))}catch{}f&&r(T)}}}catch(S){console.warn("Link preview fetch failed:",S)}})(),()=>{f=!1}},[e,n]);let i=e;try{i=new URL(e).hostname.replace(/^www\./,"")}catch{}const a=(n==null?void 0:n.title)||e,o=(n==null?void 0:n.description)||"",c=(n==null?void 0:n.image)||"",h=(n==null?void 0:n.logo)||`https://www.google.com/s2/favicons?domain=${e}&sz=64`;return s.jsxs("div",{onClick:f=>{f.stopPropagation(),t(e)},className:"my-3.5 rounded-2xl border border-slate-800 bg-[#0f172a] text-white overflow-hidden cursor-pointer group transition-all hover:border-slate-600 shadow-lg text-left",children:[c?s.jsxs("div",{className:"relative w-full max-h-[300px] bg-slate-950 overflow-hidden flex items-center justify-center",children:[s.jsx("img",{src:c,alt:"",loading:"lazy",decoding:"async",className:"w-full h-auto max-h-[300px] object-cover group-hover:scale-102 transition-transform duration-300",onError:f=>{f.target.style.display="none"}}),s.jsxs("div",{className:"absolute top-3 left-3 flex items-center gap-1.5 px-3 py-1 bg-black/80 backdrop-blur-md rounded-full text-white text-[10px] font-mono font-bold border border-white/10 shadow-sm",children:[s.jsx("img",{src:h,alt:"",className:"w-3.5 h-3.5 rounded-full object-contain shrink-0",onError:f=>{f.target.src="https://ui-avatars.com/api/?name=Web&background=0D8ABC&color=fff"}}),s.jsx("span",{className:"truncate max-w-[160px]",children:i})]}),s.jsx("div",{className:"absolute top-3 right-3 p-2 bg-black/80 hover:bg-black backdrop-blur-md rounded-full text-white transition-colors border border-white/10 shadow-sm",children:s.jsx($a,{size:13})})]}):s.jsxs("div",{className:"p-3 bg-slate-900 border-b border-slate-800 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:h,className:"w-4 h-4 rounded-full object-contain",alt:""}),s.jsx("span",{className:"text-[10px] font-mono text-slate-300 font-bold",children:i})]}),s.jsx($a,{size:12,className:"text-slate-400"})]}),s.jsxs("div",{className:"p-4 space-y-1.5 bg-[#0f172a]",children:[s.jsx("h4",{className:"text-sm font-extrabold text-white leading-snug line-clamp-2 group-hover:text-blue-400 transition-colors font-sans",children:a}),o&&s.jsx("p",{className:"text-xs text-slate-300 leading-relaxed line-clamp-2 font-normal font-sans",children:o}),s.jsxs("div",{className:"pt-2 flex items-center gap-1.5 text-[10px] font-mono text-slate-400 font-bold uppercase tracking-wider",children:[s.jsx("img",{src:h,className:"w-3.5 h-3.5 rounded-full object-contain",alt:""}),s.jsxs("span",{children:["from ",i]})]})]})]})},$Me=({isAdmin:e=!1,onUserProfileClick:t,sharedPostId:n})=>{var kt,Pa,wr,is,uo,hr,Nr,cr;const[r,i]=I.useState(op||[]),[a,o]=I.useState(MV||{}),[c,h]=I.useState(!op),[f,m]=I.useState(""),[y,w]=I.useState(1),[A,S]=I.useState(10),[C,T]=I.useState(100),D=I.useRef(r.length);I.useEffect(()=>{D.current=r.length},[r.length]);const V=I.useRef(null),L=ie.useCallback(Re=>{V.current&&V.current.disconnect(),Re&&(V.current=new IntersectionObserver(mt=>{var rt;(rt=mt[0])!=null&&rt.isIntersecting&&T(At=>Math.max(At+10,100))},{rootMargin:"250px"}),V.current.observe(Re))},[]),[K,Z]=I.useState([]),q=I.useRef(!0),B=I.useRef(op||[]);I.useEffect(()=>{B.current=r},[r]);const[z,F]=I.useState(n||null),[$,Y]=I.useState(null),[X,J]=I.useState(!1),[ye,ne]=I.useState(""),[de,be]=I.useState(!1),[Ce,Ke]=I.useState(null),[G,se]=I.useState(!1);I.useRef(null);const[xe,re]=I.useState(DS||[]),[Me,nt]=I.useState(!DS),[ze,Tt]=I.useState(!1),[It,ft]=I.useState(null),[Ee,yt]=I.useState(0),Ue=ie.useMemo(()=>It===null?[]:xe.filter(Re=>{const mt=(Re.username||bw(Re)).toLowerCase(),rt=(Re.displayName||"").toLowerCase(),At=It.toLowerCase();return mt.includes(At)||rt.includes(At)}).slice(0,5),[It,xe]),Vt=Re=>{const mt=Re.target.value;ne(mt);const rt=Re.target.selectionStart,nn=mt.substring(0,rt).split(/[\s]/),Nn=nn[nn.length-1];Nn.startsWith("@")?(ft(Nn.substring(1)),yt(rt)):ft(null)},[St,tn]=I.useState(null),[Pt,Nt]=I.useState(!1),Kt=Re=>{let mt=Re;!mt.startsWith("http://")&&!mt.startsWith("https://")&&(mt="https://"+mt),tn(mt),Nt(!0)},[ut,Jt]=I.useState({}),[Dt,hn]=I.useState({}),[qn,mn]=I.useState({}),[vr,Ve]=I.useState({}),[Mt,cn]=I.useState({}),[dn,mr]=I.useState({}),[gr,wi]=I.useState({}),[Xt,me]=I.useState({}),[qe,st]=I.useState({}),[dt,An]=I.useState(null),[Ft,Dn]=I.useState({}),[Ot,on]=I.useState({}),[jr,lr]=I.useState(!1),[ue,Se]=I.useState(""),[Qe,Gt]=I.useState(!1),[Fn,xn]=I.useState({}),[kn,xt]=I.useState(null),[$n,Et]=I.useState(null),je=Ne.currentUser,[ln,bt]=I.useState(null),[yn,Ut]=I.useState(new Set);I.useEffect(()=>{if(!je)return;const Re=Wr(Je(he,"users",je.uid),mt=>{mt.exists()&&bt(mt.data())});return()=>Re()},[je]),I.useEffect(()=>{if(!je)return;const Re=Qt(et(he,"invitations"),Ar("senderId","==",je.uid)),mt=Qt(et(he,"invitations"),Ar("receiverId","==",je.uid));let rt=[],At=[];const nn=()=>{const Bt=new Set;[...rt,...At].forEach(Mn=>{Mn.status==="accepted"&&(Mn.senderId===je.uid?(Mn.receiverId&&Bt.add(Mn.receiverId),Mn.targetUserId&&Bt.add(Mn.targetUserId)):(Mn.receiverId===je.uid||Mn.targetUserId===je.uid)&&Mn.senderId&&Bt.add(Mn.senderId))}),Ut(Bt)},Nn=Wr(Re,Bt=>{rt=Bt.docs.map(Mn=>Mn.data()),nn()}),Be=Wr(mt,Bt=>{At=Bt.docs.map(Mn=>Mn.data()),nn()});return()=>{Nn(),Be()}},[je]),I.useEffect(()=>{const Re=Qt(et(he,"posts"),ui("createdAt","desc"),vi(C)),mt=Wr(Re,rt=>{const At=rt.docs.map(Bt=>({id:Bt.id,...Bt.data()})).filter(Bt=>!Bt.flagged);if(q.current){q.current=!1,i(At),op=At,B.current=At,h(!1);return}const nn=new Map(B.current.map(Bt=>[Bt.id,Bt])),Nn=[],Be=[];for(const Bt of At)if(nn.has(Bt.id)){const Mn=nn.get(Bt.id);JSON.stringify(Mn)!==JSON.stringify(Bt)&&Be.push(Bt)}else Nn.push(Bt);if(Be.length>0&&i(Bt=>{const Mn=Bt.map(jn=>{const Ln=Be.find(xr=>xr.id===jn.id);return Ln||jn});return B.current=Mn,op=Mn,Mn}),Nn.length>0){const Bt=Nn.filter(jn=>je&&jn.authorId===je.uid),Mn=Nn.filter(jn=>!je||jn.authorId!==je.uid);Bt.length>0&&i(jn=>{const Ln=new Set(jn.map(fe=>fe.id)),Le=[...Bt.filter(fe=>!Ln.has(fe.id)),...jn];return B.current=Le,op=Le,Le}),Mn.length>0&&Z(jn=>{const Ln=new Set(jn.map(Le=>Le.id)),xr=Mn.filter(Le=>!Ln.has(Le.id));return xr.length===0?jn:[...xr,...jn]})}h(!1)},rt=>{Ks(rt,Ms.LIST,"posts"),h(!1)});return()=>mt()},[je,n,C]);const On=()=>{K.length!==0&&(i(Re=>{const mt=[...K,...Re];return B.current=mt,op=mt,mt}),Z([]),window.scrollTo({top:0,behavior:"smooth"}))};I.useEffect(()=>{if(!je)return;const Re=Qt(et(he,"follows")),mt=Wr(Re,rt=>{const At={};rt.docs.forEach(nn=>{const Nn=nn.data();Nn.followerId===je.uid&&(At[Nn.followedId]=!0)}),o(At),MV=At},rt=>{console.warn("Silent ignored follows fetch error:",rt)});return()=>mt()},[je]),I.useEffect(()=>{if(!je)return;nt(!0);const Re=Qt(et(he,"users"),vi(20));vn(Re).then(At=>{const Nn=At.docs.map(Be=>({uid:Be.id,...Be.data()})).filter(Be=>Be.uid!==je.uid);re(Nn),DS=Nn,nt(!1)}).catch(At=>{console.warn("Silent ignore users list fetch error:",At),nt(!1)});const mt=Qt(et(he,"invitations"),Ar("senderId","==",je.uid)),rt=Wr(mt,At=>{const nn={};At.docs.forEach(Nn=>{const Be=Nn.data();Be.senderId===je.uid&&(nn[Be.receiverId]=!0)}),xn(nn)},At=>{console.warn("Silent ignore invitations fetch error:",At)});return()=>{rt()}},[je]),I.useEffect(()=>{n&&r.some(Re=>Re.id===n)&&(st(Re=>({...Re,[n]:!0})),Xt[n]||Mr(n),setTimeout(()=>{const Re=document.getElementById(`post-card-${n}`);Re&&Re.scrollIntoView({behavior:"smooth",block:"center"})},600))},[n,r]),I.useEffect(()=>{n&&F(n)},[n]),I.useEffect(()=>{if(!z){Y(null);return}const Re=r.find(mt=>mt.id===z);Re?Y(Re):(J(!0),cs(Je(he,"posts",z)).then(mt=>{mt.exists()?Y({id:mt.id,...mt.data()}):Y(null),J(!1)}).catch(mt=>{console.error("Failed to load custom shared post:",mt),J(!1)}))},[z,r]),I.useEffect(()=>{if(!z)return;const Re=Qt(et(he,"posts",z,"comments"),ui("createdAt","asc")),mt=Wr(Re,rt=>{const At=rt.docs.map(nn=>({id:nn.id,...nn.data()}));Jt(nn=>({...nn,[z]:At}))},rt=>{console.warn("Error tracking focused post comments:",rt)});return()=>mt()},[z]),I.useEffect(()=>{if(!dt)return;const Re=Qt(et(he,"posts",dt,"comments"),ui("createdAt","asc")),mt=Wr(Re,rt=>{const At=rt.docs.map(nn=>({id:nn.id,...nn.data()}));Jt(nn=>({...nn,[dt]:At}))},rt=>{console.warn("Error tracking active comment post comments:",rt)});return()=>mt()},[dt]);const Mr=Re=>{An(Re);const mt=!Xt[Re];if(me(rt=>({...rt,[Re]:mt})),!ut[Re]){const rt=Qt(et(he,"posts",Re,"comments"),ui("createdAt","asc"));Wr(rt,At=>{const nn=At.docs.map(Nn=>({id:Nn.id,...Nn.data()}));Jt(Nn=>({...Nn,[Re]:nn}))},At=>{Ks(At,Ms.LIST,`posts/${Re}/comments`)})}},ji=(Re,mt)=>{const At=!!!qe[Re];st(nn=>({...nn,[Re]:At}));try{const nn=new URL(window.location.href);At?(nn.searchParams.set("post",Re),document.title=`${mt.substring(0,30)}... | Student Lounge`):(nn.searchParams.delete("post"),document.title="Student Lounge Feed | Campus Eye"),window.history.replaceState({},"",nn.toString())}catch(nn){console.warn("History push error on post expand:",nn)}},rs=async Re=>{var rt;const mt=(rt=Re.target.files)==null?void 0:rt[0];if(mt){be(!0);try{const At=await I4(mt);Ke(At),pe.success("Image uploaded successfully!")}catch(At){pe.error(At.message||"Failed to upload image")}finally{be(!1)}}},pi=async Re=>{var nn,Nn,Be,Bt;if(Re.preventDefault(),!je){pe.error("Please sign in to post");return}if(!ye.trim()&&!Ce){pe.error("Add some text or an image to post!");return}const mt=!!(ln!=null&&ln.isPremiumPostUser||ln!=null&&ln.isVerified||ln!=null&&ln.isPremium||ln!=null&&ln.blueCheck||e),rt=(ln==null?void 0:ln.freePostsRemaining)??1;if(!mt&&rt<=0){try{await ur(et(he,"notifications"),{userId:"admin_all",type:"unlimited_posting_request",title:`🎟️ Unlimited Posting Request from @${je.displayName||((nn=je.email)==null?void 0:nn.split("@")[0])||"Peer"}`,message:`@${je.displayName||((Nn=je.email)==null?void 0:Nn.split("@")[0])||"Peer"} (UID: ${je.uid}) has requested admin approval to unlock unlimited posting on Campus Eye.`,requestAuthorId:je.uid,requestAuthorName:je.displayName||((Be=je.email)==null?void 0:Be.split("@")[0])||"Peer",used:!1,createdAt:En()})}catch(Mn){console.error("Error creating posting approval request:",Mn)}pe.error("You have used your 1 Free Trial Post! An approval request has been sent to Campus Eye admins to unlock unlimited posting.",{duration:6e3});return}const At=pe.loading("Dispatching post...");try{const Mn=ye.trim(),jn=await ur(et(he,"posts"),{content:Mn,imageUrl:Ce||null,authorId:je.uid,authorName:je.displayName||((Bt=je.email)==null?void 0:Bt.split("@")[0])||"Peer",authorPhotoURL:je.photoURL||"",createdAt:En(),likeCount:0,commentCount:0,likedBy:[],reportsCount:0,flagged:!1,isTrialPost:!mt,isApprovedByAdmin:mt});try{const Le=`${window.location.origin}/p/post/${jn.id}`;fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:Le,title:`Campus Dispatch by ${je.displayName||"Peer"}`,image:Ce||""})}).catch(()=>{})}catch{}!mt&&rt>0&&await Rr(Je(he,"users",je.uid),{freePostsRemaining:0,isPremiumPostUser:!1},{merge:!0}),(Mn.toLowerCase().includes("@mega")||Mn.toLowerCase().includes("@megaai"))&&M2(Mn,je.displayName||"Peer Student",je.uid,{type:"post",postId:jn.id}).then(async Le=>{Le&&(await ur(et(he,"posts",jn.id,"comments"),{postId:jn.id,content:Le,authorId:"mega-ai-bot",authorName:"Mega AI",authorPhotoURL:zo,createdAt:En(),likeCount:0,likedBy:[],isAIGenerated:!0}),await Cn(Je(he,"posts",jn.id),{commentCount:Ir(1)}),pe.success("Mega AI auto-replied to your mention!",{icon:"✨"}))}).catch(Le=>console.error("Mega AI post trigger error:",Le));const Ln=Mn.match(/@([a-zA-Z0-9_\-]+)/g)||[],xr=Array.from(new Set(Ln.map(Le=>Le.substring(1).toLowerCase())));for(const Le of xr){const fe=xe.find(fn=>(fn.username||bw(fn)).toLowerCase()===Le);if(fe&&fe.uid!==je.uid)try{await ur(et(he,"notifications"),{userId:fe.uid,title:`👋 @${bw(je)} mentioned you`,message:`${je.displayName||"A peer"} mentioned you in a Lounge dispatch: "${Mn.substring(0,60)}..."`,used:!1,type:"mention",createdAt:En()})}catch(fn){console.warn("Silent ignored notification creation error:",fn)}}ne(""),Ke(null),pe.success("Post dispatched successfully!",{id:At})}catch(Mn){pe.error("Failed to post: "+Mn.message,{id:At})}},mi=async(Re,mt=[])=>{if(!je)return;const rt=mt.includes(je.uid),At=Je(he,"posts",Re);try{rt?await Cn(At,{likedBy:T2(je.uid),likeCount:Ir(-1)}):await Cn(At,{likedBy:I2(je.uid),likeCount:Ir(1)})}catch(nn){console.error("Like toggle exception:",nn)}},vs=async(Re,mt)=>{if(!je){pe.error("Sign in with Google to react to comments!",{icon:"🔒"});return}const rt=Ot[mt];on(At=>({...At,[mt]:!rt}));try{const At=Je(he,"posts",Re,"comments",mt);await Cn(At,{likeCount:Ir(rt?-1:1),likedBy:rt?T2(je.uid):I2(je.uid)})}catch(At){console.error("Error liking post comment:",At),on(nn=>({...nn,[mt]:rt}))}},gi=async Re=>{var Be;if(!je)return;const mt=Dt[Re]||"",rt=qn[Re]||null,At=vr[Re]||null,nn=Mt[Re]||null;if(!mt.trim()&&!rt&&!At&&!nn)return;const Nn=Ft[Re];wi(Bt=>({...Bt,[Re]:!0}));try{const Bt=et(he,"posts",Re,"comments");await ur(Bt,{postId:Re,content:mt.trim()||(rt?`[Sticker ${rt}]`:"[Attachment]"),authorId:je.uid,authorName:je.displayName||((Be=je.email)==null?void 0:Be.split("@")[0])||"Peer",authorPhotoURL:je.photoURL||"",createdAt:En(),parentId:(Nn==null?void 0:Nn.commentId)||null,replyToAuthor:(Nn==null?void 0:Nn.authorName)||null,likeCount:0,likedBy:[],...rt?{stickerEmoji:rt}:{},...At?{imageUrl:At}:{},...nn?{audioUrl:nn}:{}});const Mn=Je(he,"posts",Re);await Cn(Mn,{commentCount:Ir(1)}),hn(jn=>({...jn,[Re]:""})),mn(jn=>({...jn,[Re]:""})),Ve(jn=>({...jn,[Re]:""})),cn(jn=>({...jn,[Re]:""})),Dn(jn=>({...jn,[Re]:null})),mr(jn=>({...jn,[Re]:!1})),(mt.toLowerCase().includes("@mega")||mt.toLowerCase().includes("@megaai"))&&M2(mt,je.displayName||"Peer Student",je.uid,{type:"post_comment",postId:Re,commentId:Nn==null?void 0:Nn.commentId}).then(async jn=>{jn&&(await ur(et(he,"posts",Re,"comments"),{postId:Re,content:jn,authorId:"mega-ai-bot",authorName:"Mega AI",authorPhotoURL:zo,createdAt:En(),parentId:(Nn==null?void 0:Nn.commentId)||null,replyToAuthor:je.displayName||"Peer",likeCount:0,likedBy:[],isAIGenerated:!0}),await Cn(Je(he,"posts",Re),{commentCount:Ir(1)}),pe.success("Mega AI auto-replied to your comment!",{icon:"✨"}))}).catch(jn=>console.error("Mega AI comment trigger error:",jn))}catch(Bt){console.error("Error creating post comment:",Bt)}finally{wi(Bt=>({...Bt,[Re]:!1}))}},$r=async Re=>{if(!je)return;const mt=Je(he,"posts",Re);pe.success("Thank you. Post flagged and hidden from view.",{icon:"🛡️"});try{await Cn(mt,{reportsCount:Ir(1),flagged:!0})}catch(rt){console.error("Error reporting post:",rt)}},Sr=async Re=>{var mt;if(je){if(!e&&((mt=je.email)==null?void 0:mt.toLowerCase())!=="atwiinevictor2@gmail.com"){pe.error("Access Denied: Only administrators can delete posts.");return}if(kn!==Re){xt(Re),setTimeout(()=>{xt(rt=>rt===Re?null:rt)},4e3);return}try{await si(Je(he,"posts",Re)),pe.success("Post deleted successfully!"),xt(null)}catch(rt){pe.error("Failed to delete post: "+rt.message)}}},Ss=async(Re,mt)=>{if(!je){localStorage.setItem("pending_follow_uid",Re),localStorage.setItem("pending_follow_name",mt),pe.success(`Complete google sign-up to follow @${mt.toLowerCase().replace(/\s+/g,"")}!`,{icon:"🔐"}),window.dispatchEvent(new CustomEvent("open-lounge-auth"));return}const rt=`${je.uid}_${Re}`,At=Je(he,"follows",rt),nn=a[Re];try{if(nn){await si(At),pe.success(`Unfollowed @${mt.toLowerCase().replace(/\s+/g,"")}`);const Nn=je.displayName?`@${je.displayName.toLowerCase().replace(/\s+/g,"")}`:"A peer";try{const Be=`notif_unfollow_${je.uid}_${Re}`;await Rr(Je(he,"notifications",Be),{userId:Re,title:"💔 Lounge Unfollow",message:`${Nn} unfollowed you.`,type:"social",used:!0,createdAt:new Date})}catch(Be){console.warn("Failed to create unfollow notification:",Be)}}else{await Rr(At,{followerId:je.uid,followedId:Re,createdAt:En()}),pe.success(`Following @${mt.toLowerCase().replace(/\s+/g,"")}!`,{icon:"🤝"});const Nn=je.displayName?`@${je.displayName.toLowerCase().replace(/\s+/g,"")}`:"A peer";try{const Be=`notif_follow_${je.uid}_${Re}`;await Rr(Je(he,"notifications",Be),{userId:Re,title:"👥 New Lounge Follower!",message:`${Nn} is now following you. They will receive your latest dispatches!`,type:"social",createdAt:new Date})}catch(Be){console.warn("Failed to create follow notification from lounge:",Be)}}}catch(Nn){console.error("Follow toggling issue:",Nn)}},li=async(Re,mt,rt)=>{const At=`${window.location.origin}/p/post/${Re}`,nn=mt||"Check out this Post on Campus Eye",Nn=nn.length>140?`${nn.substring(0,140)}...`:nn;try{fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:At,title:"Campus Dispatch | Campus Eye Lounge",image:rt||""})}).catch(()=>{})}catch{}try{if(navigator.share){const Be={title:"Campus Dispatch | Campus Eye Lounge",text:`📣 Campus Dispatch: "${Nn}"${rt?` Preview: ${rt}`:""} Read dispatch:`,url:At};await navigator.share(Be),pe.success("Post shared successfully!")}else{const Be=`📣 Campus Dispatch: "${Nn}"${rt?` 🖼️ Preview Image: ${rt}`:""} 🔗 Open direct post: ${At}`;await Md(Be),pe.success("Post preview link & image copied to clipboard!")}}catch(Be){if(Be.name!=="AbortError")try{const Bt=`📣 Campus Dispatch: "${Nn}"${rt?` 🖼️ Preview Image: ${rt}`:""} 🔗 Open direct post: ${At}`;await Md(Bt),pe.success("Post link copied to clipboard!")}catch{}}},Qr=async Re=>{var rt,At;if(!je){pe.error("Please sign in to invite peers!");return}const mt=`${je.uid}_${Re.uid}`;try{await Rr(Je(he,"invitations",mt),{id:mt,senderId:je.uid,senderName:je.displayName||((rt=je.email)==null?void 0:rt.split("@")[0])||"Peer",senderPhotoURL:je.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(je.displayName||"Peer")}&background=random`,receiverId:Re.uid,receiverName:Re.displayName||((At=Re.email)==null?void 0:At.split("@")[0])||"Peer",status:"pending",createdAt:En()}),pe.success(`Lounge invite sent to @${(Re.displayName||"peer").toLowerCase().replace(/\s+/g,"")}!`,{icon:"🚀"})}catch(nn){pe.error("Failed to send invite: "+nn.message)}};return s.jsxs("div",{className:"bg-gray-50/50 min-h-screen py-3 sm:py-6 px-1 sm:px-6 w-full max-w-[1680px] xl:max-w-[1780px] 2xl:max-w-[1880px] mx-auto text-left select-none pb-24",children:[s.jsx("div",{className:"flex justify-end items-center mb-4",children:s.jsxs("button",{onClick:()=>lr(!0),className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-650 hover:bg-red-700 text-white rounded-xl text-[10px] font-black uppercase tracking-wider transition-all shadow-md active:scale-95 cursor-pointer shrink-0",children:[s.jsx(_o,{size:12,strokeWidth:2.5}),s.jsx("span",{children:"Invite Peers"})]})}),je?s.jsx("div",{className:"bg-white border border-gray-150 rounded-2xl p-4 shadow-sm mb-6 transition-all duration-350",children:s.jsx("form",{onSubmit:pi,children:s.jsxs("div",{className:"flex gap-3",children:[s.jsx("img",{src:(je==null?void 0:je.photoURL)||`https://ui-avatars.com/api/?name=${encodeURIComponent((je==null?void 0:je.displayName)||"Peer")}&background=random`,className:"w-10 h-10 rounded-full border border-gray-100 object-cover shrink-0 mt-1",alt:""}),s.jsxs("div",{className:"flex-1 space-y-3",children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("textarea",{value:ye,onFocus:()=>se(!0),onChange:Vt,placeholder:"What's on your mind? Share it.",rows:G?3:1,className:"w-full text-xs font-sans placeholder-gray-400 bg-transparent border-0 resize-none focus:ring-0 focus:outline-none pt-2 transition-all duration-300"}),!G&&s.jsx("button",{type:"button",onClick:()=>se(!0),className:"p-2 text-red-650 hover:bg-red-50 rounded-full transition-all cursor-pointer shrink-0",title:"Write post",children:s.jsx(Eo,{size:15})})]}),It!==null&&Ue.length>0&&s.jsxs("div",{className:"bg-white border border-gray-150 rounded-xl shadow-lg p-1 max-h-48 overflow-y-auto mb-2 space-y-0.5 divide-y divide-gray-50 z-50",children:[s.jsx("div",{className:"px-3 py-1 text-[9px] font-black uppercase text-gray-400 tracking-wider",children:"Mention a Peer"}),Ue.map(Re=>{const mt=Re.username||bw(Re);return s.jsxs("button",{type:"button",onClick:()=>{const rt=ye.substring(0,Ee-It.length-1),At=ye.substring(Ee),nn=`${rt}@${mt} ${At}`;ne(nn),ft(null)},className:"w-full text-left flex items-center gap-2 px-3 py-1.5 hover:bg-neutral-55 rounded-lg transition-colors cursor-pointer",children:[s.jsx("img",{src:Re.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Re.displayName||"Peer")}&background=random`,className:"w-6 h-6 rounded-full border border-gray-100 object-cover",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[11px] font-extrabold text-gray-905 truncate",children:Re.displayName||"Peer"}),s.jsxs("p",{className:"text-[9px] font-mono font-bold text-blue-600 truncate",children:["@",mt]})]})]},Re.uid)})]}),G&&s.jsxs("div",{className:"space-y-3",children:[Ce&&s.jsxs("div",{className:"relative rounded-xl overflow-hidden border border-gray-150 max-h-56 bg-gray-50",children:[s.jsx("img",{src:Ce,className:"w-full h-full object-cover",alt:"Selected Preview"}),s.jsx("button",{type:"button",onClick:()=>Ke(null),className:"absolute top-2.5 right-2.5 w-6 h-6 rounded-full bg-black/70 text-white flex items-center justify-center hover:bg-black transition-colors",children:s.jsx(er,{size:13})})]}),s.jsxs("div",{className:"space-y-2 border-t border-gray-100 pt-3",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("input",{type:"url",placeholder:"Or paste post imageUrl (https://...) for instant preview",value:Ce||"",onChange:Re=>Ke(Re.target.value.trim()||null),className:"w-full text-[10px] font-mono bg-gray-50 border border-gray-200 rounded-xl px-3 py-1.5 focus:bg-white focus:border-red-600 outline-none text-gray-800"})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs("label",{htmlFor:"posts-page-file-upload",className:"text-gray-600 hover:text-red-650 p-2 rounded-full hover:bg-gray-100 transition-colors flex items-center justify-center cursor-pointer gap-1.5 text-[10px] font-extrabold border border-gray-200 shadow-2xs bg-white",title:"Add Image or Video File",children:[s.jsx("input",{id:"posts-page-file-upload",type:"file",accept:"image/*,video/*",onChange:rs,className:"hidden"}),de?s.jsx(Er,{size:16,className:"animate-spin text-red-650"}):s.jsxs(s.Fragment,{children:[s.jsx(xu,{size:16,className:"text-red-600"}),s.jsx("span",{className:"text-[9.5px] uppercase font-black text-gray-700",children:"Upload Media"})]})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{se(!1),ne(""),Ke(null)},className:"text-[9px] font-black uppercase tracking-wider text-gray-550 border border-gray-200 h-8 px-4 rounded-full hover:bg-gray-50 transition-colors cursor-pointer",children:"Collapse"}),s.jsx("button",{type:"submit",disabled:de||!ye.trim()&&!Ce,className:"bg-gray-950 text-white font-extrabold text-[10px] uppercase tracking-wider h-8 px-5 rounded-full hover:bg-red-650 transition-colors cursor-pointer disabled:opacity-40",children:"Dispatch Debate"})]})]})]})]})]})]})})}):s.jsx("div",{className:"bg-white border border-dashed border-gray-150 rounded-2xl p-5 text-center mb-6 shadow-3xs select-none",children:s.jsx("p",{className:"text-[10px] font-black text-gray-500 uppercase tracking-widest leading-none flex items-center justify-center gap-2",children:"📢 Sign in to publish public updates, mention peers and join student lounge dispatches!"})}),s.jsxs("div",{className:"relative mb-5",children:[s.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:s.jsx(Rp,{size:14,className:"text-gray-400"})}),s.jsx("input",{type:"text",value:f,onChange:Re=>{m(Re.target.value),w(1)},placeholder:"Search campus dispatches by text or author name...",className:"block w-full pl-9 pr-8 py-2.5 bg-white border border-gray-150 focus:border-red-650 focus:bg-white text-xs font-bold rounded-xl outline-none placeholder-gray-400 text-gray-900 transition-all shadow-xs"}),f&&s.jsx("button",{type:"button",onClick:()=>{m(""),w(1)},className:"absolute inset-y-0 right-0 pr-3 flex items-center cursor-pointer text-gray-400 hover:text-black",title:"Clear Post Search",children:s.jsx(er,{size:13})})]}),s.jsx(or,{children:K.length>0&&s.jsx(Zt.div,{initial:{opacity:0,y:-15,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.95},className:"flex justify-center mb-5 sticky top-4 z-40",children:s.jsxs("button",{onClick:On,className:"flex items-center gap-2 px-5 py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-full text-xs font-black uppercase tracking-widest transition-all duration-200 cursor-pointer shadow-lg active:scale-95 group hover:shadow-cyan-100/10",children:[s.jsx("span",{className:"relative flex h-2 w-2",children:s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-400"})}),s.jsxs("span",{children:["View ",K.length," New Post",K.length>1?"s":""]})]})})}),(()=>{const Re=r.filter(Be=>{var Ln,xr;if(!f.trim())return!0;const Bt=f.toLowerCase(),Mn=(Ln=Be.content)==null?void 0:Ln.toLowerCase().includes(Bt),jn=(xr=Be.authorName)==null?void 0:xr.toLowerCase().includes(Bt);return Mn||jn}),mt=Array.from(new Map(Re.map(Be=>[Be.id,Be])).values()),rt=Math.max(1,Math.ceil(mt.length/A)),nn=(Math.min(y,rt)-1)*A,Nn=mt.slice(nn,nn+A);return c&&r.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 space-y-2",children:[s.jsx(Er,{className:"w-8 h-8 text-red-650 animate-spin"}),s.jsx("p",{className:"text-[10px] font-black uppercase text-gray-400 tracking-widest leading-none",children:"Connecting Lounge Updates"})]}):Re.length===0?s.jsxs("div",{className:"bg-white border border-gray-150 rounded-2xl py-14 text-center p-6 shadow-sm",children:[s.jsx(Zi,{className:"w-8 h-8 text-gray-300 mx-auto mb-2.5"}),s.jsx("p",{className:"text-xs font-black uppercase text-gray-950 tracking-wider",children:"No matching lounge posts found"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1 font-sans",children:"Try searching with a different user name or keyword phrase."})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-6",children:Nn.map((Be,Bt)=>{var fe,fn,xi,Ui,Bi,Lr,zi;const Mn=(fe=Be.likedBy)==null?void 0:fe.includes((je==null?void 0:je.uid)||""),jn=a[Be.authorId],Ln=(je==null?void 0:je.uid)===Be.authorId,xr=Fn[Be.authorId],Le=Bt===Math.max(2,Nn.length-2);return s.jsxs(Zt.div,{ref:Le?L:void 0,id:`post-card-${Be.id}`,layout:!0,className:Fe("bg-white border rounded-2xl p-4 md:p-5 shadow-sm space-y-3 flex flex-col justify-between transition-all duration-500",Be.id===n?"border-red-650 ring-2 ring-red-650/15 shadow-md scale-[1.01]":"border-gray-150"),children:[s.jsxs("div",{children:[e&&Be.isTrialPost&&!Be.isApprovedByAdmin&&s.jsxs("div",{className:"mb-3 p-3 bg-gradient-to-r from-amber-50 to-orange-50 border border-amber-200 rounded-2xl flex flex-wrap items-center justify-between gap-2 text-left",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"p-1.5 bg-amber-500 text-white rounded-xl shadow-2xs shrink-0",children:s.jsx(vI,{size:14})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-black uppercase text-amber-900 tracking-wider",children:"🎟️ Admin Approval Ticket (1st Free Trial Post)"}),s.jsxs("p",{className:"text-[9px] text-amber-700 font-medium",children:["Approve @",Be.authorName," to unlock unlimited posting on Campus Eye."]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:async()=>{try{await Rr(Je(he,"users",Be.authorId),{isPremiumPostUser:!0},{merge:!0}),await Cn(Je(he,"posts",Be.id),{isApprovedByAdmin:!0}),pe.success(`Approved @${Be.authorName} for unlimited posting!`,{icon:"🎉"})}catch(an){pe.error("Failed to approve user: "+an.message)}},className:"px-3 py-1.5 bg-amber-600 hover:bg-amber-700 text-white font-black text-[9px] uppercase tracking-wider rounded-xl shadow-xs transition-all cursor-pointer shrink-0",children:"Approve User for Unlimited Posting"}),s.jsx("button",{onClick:async()=>{try{await Cn(Je(he,"posts",Be.id),{isApprovedByAdmin:!0}),pe.success(`Dismissed request for @${Be.authorName}`,{icon:"🗑️"})}catch(an){pe.error("Error dismissing request: "+an.message)}},className:"px-2.5 py-1.5 bg-gray-200 hover:bg-gray-300 text-gray-700 font-black text-[9px] uppercase tracking-wider rounded-xl transition-all cursor-pointer shrink-0",children:"Dismiss"})]})]}),s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{onClick:()=>t==null?void 0:t(Be.authorId),className:"flex items-center gap-2.5 min-w-0 cursor-pointer hover:opacity-85 transition-opacity duration-150",title:"Click to view peer credentials",children:[Be.isAIGenerated||Be.isAiGenerated||Be.authorId==="mega-ai-bot"||(fn=Be.authorName)!=null&&fn.toLowerCase().includes("mega ai")?s.jsx(zMe,{size:"sm"}):s.jsx("img",{src:Be.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Be.authorName)}&background=random`,className:"w-7 h-7 rounded-full border border-gray-100 object-cover shrink-0",alt:""}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1 leading-none truncate",children:[s.jsx("span",{className:"text-[10px] font-black uppercase tracking-tight text-gray-950 truncate",children:Be.authorName}),s.jsx(Fo,{size:12,className:"shrink-0"}),(Be.isAIGenerated||Be.isAiGenerated||Be.authorId==="mega-ai-bot"||((xi=Be.authorName)==null?void 0:xi.toLowerCase().includes("mega ai")))&&s.jsx(zw,{}),s.jsxs("span",{className:"text-[8px] text-gray-400 font-bold truncate",children:["@",Be.authorName.toLowerCase().replace(/\s+/g,"")]})]}),s.jsx("span",{className:"text-[7.5px] font-black uppercase tracking-wider text-gray-400 mt-0.5 block",children:(Ui=Be.createdAt)!=null&&Ui.toDate?new Date(Be.createdAt.toDate().getTime()).toLocaleDateString():"Now"})]})]}),!Ln&&je&&s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[yn.has(Be.authorId)&&s.jsxs("button",{onClick:an=>{an.stopPropagation(),window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:{uid:Be.authorId,displayName:Be.authorName,username:Be.authorName.toLowerCase().replace(/\s+/g,""),photoURL:Be.authorPhotoURL||""}}))},className:"p-1 px-2.5 bg-[#007AFF] hover:bg-blue-600 text-white rounded-full transition-all cursor-pointer flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider shrink-0 shadow-2xs",title:`Open iMessage chat with connected friend ${Be.authorName}`,children:[s.jsx(ea,{size:11,strokeWidth:2.5}),s.jsx("span",{className:"hidden sm:inline",children:"iMessage"})]}),s.jsxs("button",{onClick:async()=>{const an={uid:Be.authorId,displayName:Be.authorName,email:""};await Qr(an)},disabled:xr,className:Fe("text-[7.5px] font-black uppercase tracking-wider h-5 px-1.5 rounded-full flex items-center gap-0.5 transition-all cursor-pointer shadow-none border",xr?"bg-gray-100 border-gray-200 text-gray-400 cursor-not-allowed":"bg-emerald-600 border-emerald-500 text-white hover:bg-emerald-750"),title:"Send Mutual Lounge Invitation",children:[s.jsx(Np,{size:8,strokeWidth:2.5}),s.jsx("span",{className:"hidden sm:inline",children:xr?"Invited":"Invite"})]}),s.jsx("button",{onClick:()=>Ss(Be.authorId,Be.authorName),className:`text-[7.5px] font-black uppercase tracking-widest h-5 px-1.5 rounded-full flex items-center gap-0.5 cursor-pointer transition-colors ${jn?"bg-gray-100 text-gray-650 border border-gray-200 hover:bg-red-50 hover:text-red-650 hover:border-red-150":"bg-red-50 text-red-650 border border-red-150/50 hover:bg-red-100"}`,children:jn?s.jsxs(s.Fragment,{children:[s.jsx(ey,{size:8}),s.jsx("span",{className:"hidden sm:inline",children:"Following"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Np,{size:8}),s.jsx("span",{className:"hidden sm:inline",children:"Follow"})]})})]})]}),s.jsx("p",{className:"text-[11px] text-gray-800 font-sans leading-relaxed whitespace-pre-wrap text-left mb-2",children:(()=>{const fr=Be.content&&Be.content.length>160,Oa=!!qe[Be.id];return!fr||Oa?s.jsxs(s.Fragment,{children:[m1(Be.content,Kt),fr&&s.jsx("button",{onClick:ra=>{ra.stopPropagation(),ji(Be.id,Be.content)},className:"ml-1 text-[#EE1B24] font-black cursor-pointer hover:underline text-[9px] uppercase whitespace-nowrap inline-block",children:"Read less"})]}):s.jsxs(s.Fragment,{children:[m1(Be.content.substring(0,160),Kt),"...",s.jsx("button",{onClick:ra=>{ra.stopPropagation(),ji(Be.id,Be.content)},className:"ml-1 text-[#EE1B24] font-black cursor-pointer hover:underline text-[9px] uppercase whitespace-nowrap inline-block",children:"Read more"})]})})()}),(()=>{const an=VMe(Be.content);if(an.length===0)return null;const fr=an[0];return s.jsx(FMe,{url:fr,onOpenUrl:Kt})})(),Be.imageUrl&&s.jsxs("div",{onClick:()=>Et(Be.imageUrl),className:"rounded-2xl overflow-hidden border border-gray-200/80 bg-black/5 cursor-pointer relative group transition-all my-3 max-h-[650px] w-full flex items-center justify-center shadow-xs",children:[s.jsx(Li,{src:Be.imageUrl,className:"w-full h-auto max-h-[650px] object-contain mx-auto group-hover:opacity-95 transition-opacity duration-200 rounded-2xl",alt:"Post graphic asset"}),s.jsx("div",{className:"absolute top-3 right-3 opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsxs("div",{className:"px-2.5 py-1 bg-black/75 backdrop-blur-md text-white rounded-full text-[8px] font-black uppercase tracking-wider flex items-center gap-1 shadow-md",children:[s.jsx(r2,{size:9})," Full Size"]})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 pt-2 select-none",children:[s.jsxs("button",{onClick:()=>mi(Be.id,Be.likedBy),className:`flex items-center gap-1 text-[8.5px] font-bold uppercase tracking-wider transition-colors cursor-pointer ${Mn?"text-blue-600 font-extrabold":"text-gray-450 hover:text-blue-500"}`,children:[s.jsx(Zt.div,{animate:Mn?{scale:[1,1.45,.9,1.15,1]}:{scale:1},transition:{duration:.4},children:s.jsx(Tie,{size:12,className:Mn?"fill-current":""})}),s.jsx("span",{children:Be.likeCount||0})]}),s.jsxs("button",{onClick:()=>Mr(Be.id),className:`flex items-center gap-1 text-[8.5px] font-bold uppercase tracking-wider transition-colors cursor-pointer ${Xt[Be.id]?"text-gray-950 font-black":"text-gray-450 hover:text-gray-950"}`,children:[s.jsx(bi,{size:12}),s.jsxs("span",{children:[Be.commentCount||0," Discussions"]})]}),s.jsxs("button",{onClick:()=>li(Be.id,Be.content,Be.imageUrl),className:"flex items-center gap-1 text-[8.5px] font-bold uppercase tracking-wider text-gray-450 hover:text-gray-950 transition-colors cursor-pointer",children:[s.jsx(hf,{size:12}),s.jsx("span",{children:"Share"})]}),je&&(e||((Bi=je.email)==null?void 0:Bi.toLowerCase())==="atwiinevictor2@gmail.com"?s.jsxs("button",{onClick:()=>Sr(Be.id),className:`flex items-center gap-0.5 select-none cursor-pointer py-0.5 px-2 rounded-full border transition-all ${kn===Be.id?"bg-red-650 border-red-650 text-white shadow-xs":"bg-transparent border-transparent text-gray-300 hover:text-red-650"}`,title:kn===Be.id?"Click again to confirm delete":"Delete Post (Master Admin)",children:[s.jsx(er,{size:11,className:"stroke-[3]"}),s.jsx("span",{className:`text-[8px] uppercase font-black tracking-tight ${kn===Be.id?"text-white":"text-gray-400 hover:text-red-650"}`,children:kn===Be.id?"Confirm?":"Delete"})]}):Ln?null:s.jsx("button",{onClick:()=>$r(Be.id),className:"text-gray-300 hover:text-amber-500 transition-colors flex items-center gap-1 select-none cursor-pointer",title:"Report Abuse / Inappropriate",children:s.jsx(ku,{size:12})}))]}),s.jsx(or,{children:Xt[Be.id]&&s.jsxs(Zt.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"border-t border-gray-100 pt-2.5 mt-1 overflow-hidden",children:[s.jsx("div",{className:"space-y-2 mb-3.5 max-h-40 overflow-y-auto pr-1",children:((Lr=ut[Be.id])==null?void 0:Lr.length)===0?s.jsx("p",{className:"text-[8px] font-bold uppercase text-gray-350 italic text-center py-1",children:"No statements dispatched. Formulate your thought."}):(zi=ut[Be.id])==null?void 0:zi.map(an=>{var fr,Oa;return s.jsxs("div",{className:"flex gap-1.5 items-start py-0.5",children:[s.jsx("img",{src:an.authorId==="mega-ai-bot"||(fr=an.authorName)!=null&&fr.toLowerCase().includes("mega ai")?zo:an.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(an.authorName)}&background=random`,className:"w-5 h-5 rounded-full border border-gray-100 object-cover mt-0.5 animate-fade-in",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0 bg-gray-50/70 rounded-xl p-2 border border-gray-100",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-[8px] font-black uppercase text-gray-950 tracking-tight",children:an.authorName}),s.jsx(Fo,{size:10,className:"shrink-0"})]}),s.jsx("span",{className:"text-[7px] font-bold text-gray-400",children:(Oa=an.createdAt)!=null&&Oa.toDate?new Date(an.createdAt.toDate().getTime()).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"Now"})]}),s.jsx("p",{className:"text-[10px] text-gray-700 font-sans leading-relaxed mt-0.5",children:an.content})]})]},an.id)})}),je?s.jsxs("div",{className:"flex gap-1.5 items-center",children:[s.jsx("input",{type:"text",value:Dt[Be.id]||"",onChange:an=>{const fr=an.target.value;hn(Oa=>({...Oa,[Be.id]:fr}))},placeholder:"What's on your mind? Share it.",className:"flex-1 bg-gray-50 p-1.5 rounded-lg text-[10px] font-sans outline-none focus:outline-none focus:ring-1 focus:ring-red-500/25 border border-gray-150 placeholder-gray-400"}),s.jsx("button",{onClick:()=>gi(Be.id),disabled:gr[Be.id]||!(Dt[Be.id]||"").trim(),className:"bg-gray-950 text-white rounded-full w-6 h-6 flex items-center justify-center hover:bg-red-650 transition-colors disabled:opacity-30 cursor-pointer text-[10px] shrink-0",children:s.jsx(Eo,{size:10})})]}):s.jsx("div",{className:"bg-gray-50 rounded-xl p-2 border border-gray-100 text-center",children:s.jsx("p",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400",children:"Sign in with Google to reply"})})]})})]})]},`${Be.id}-${Bt}`)})}),Re.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(Ree,{currentPage:y,totalPages:rt,totalItems:Re.length,itemsPerPage:A,onPageChange:Be=>{w(Be),Be*A>C-10&&T(Bt=>Math.max(Bt,Be*A+50)),window.scrollTo({top:0,behavior:"smooth"})},onItemsPerPageChange:Be=>{S(Be),w(1),Be>C&&T(Be+50)},itemLabel:"posts"})})]})})(),s.jsx(or,{children:jr&&s.jsxs("div",{className:"fixed inset-0 z-[3500] flex items-center justify-center p-4",children:[s.jsx(Zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>lr(!1),className:"absolute inset-0 bg-black/60 backdrop-blur-md"}),s.jsxs(Zt.div,{initial:{opacity:0,scale:.95,y:15},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:15},transition:{type:"spring",damping:25,stiffness:300},className:"relative w-full max-w-md bg-white border border-gray-150 rounded-2xl shadow-2xl p-6 overflow-hidden max-h-[85vh] flex flex-col text-left",children:[s.jsxs("div",{className:"flex items-center justify-between pb-3.5 border-b border-gray-100 mb-5 relative",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"p-1.5 bg-red-50 rounded-lg text-red-650 shrink-0",children:s.jsx(_o,{size:16,strokeWidth:2.5})}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-sans font-black text-xs uppercase tracking-wider text-gray-950",children:"Invite Lounge Peers"}),s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-tight font-mono",children:"Expand your campus digital board"})]})]}),s.jsx("button",{onClick:()=>lr(!1),className:"p-1 rounded-full hover:bg-gray-100 text-gray-405 hover:text-gray-950 transition-colors cursor-pointer",title:"Close panel",children:s.jsx(er,{size:16})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5 pr-1 py-1",children:[s.jsxs("div",{className:"bg-gray-50/70 rounded-xl p-4 border border-gray-100 flex flex-col gap-3",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Zi,{size:13,className:"text-red-650 shrink-0"}),s.jsx("span",{className:"text-[10px] font-black uppercase text-gray-900 tracking-wider",children:"Share Lounge Join Link"})]}),s.jsx("p",{className:"text-[10px] font-semibold text-gray-550 leading-relaxed",children:"Copy the Student Lounge direct referral channel URL to hand to custom circles via WhatsApp, Slack or external dispatches."}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",readOnly:!0,value:(()=>{var mt;const Re=je?(je.displayName||((mt=je.email)==null?void 0:mt.split("@")[0])||"peer").trim().toLowerCase().replace(/[^a-z0-9]/g,"-"):"peer";return`${window.location.origin}?invite=${Re}-invites-you`})(),className:"flex-1 bg-white border border-gray-200 rounded-lg px-3 py-1.5 text-[10px] font-mono text-gray-500 outline-none select-all select-none"}),s.jsx("button",{onClick:()=>{var rt;const Re=je?(je.displayName||((rt=je.email)==null?void 0:rt.split("@")[0])||"peer").trim().toLowerCase().replace(/[^a-z0-9]/g,"-"):"peer",mt=`${window.location.origin}?invite=${Re}-invites-you`;Md(mt),pe.success("Your unique Lounge invitation link copied!",{icon:"🔗"})},className:"px-3 py-1.5 bg-gray-950 hover:bg-red-650 text-white rounded-lg text-[9px] font-black uppercase tracking-wider transition-colors cursor-pointer active:scale-95 shrink-0",children:"Copy Link"})]})]}),s.jsxs("form",{onSubmit:async Re=>{if(Re.preventDefault(),!ue.trim()){pe.error("Please enter a valid student or faculty email");return}Gt(!0);try{await ur(et(he,"invitations"),{senderId:(je==null?void 0:je.uid)||"guest",senderName:(je==null?void 0:je.displayName)||"Peer",senderPhotoURL:(je==null?void 0:je.photoURL)||"",receiverEmail:ue.trim().toLowerCase(),status:"pending",type:"email",createdAt:En()}),pe.success(`Broadcasting dispatch invite to ${ue.trim().toLowerCase()}!`,{icon:"✉️"}),Se("")}catch(mt){pe.error("Failed to dispatcher invitation: "+mt.message)}finally{Gt(!1)}},className:"space-y-2.5 pb-2 border-b border-gray-100",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(ea,{size:13,className:"text-red-650 shrink-0"}),s.jsx("span",{className:"text-[10px] font-black uppercase text-gray-900 tracking-wider",children:"Email Dispatch Invitation"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"email",required:!0,placeholder:"Enter peer's email address",value:ue,onChange:Re=>Se(Re.target.value),className:"flex-1 bg-gray-50/50 border border-gray-200 rounded-lg px-3 py-1.5 text-xs font-sans outline-none focus:bg-white focus:ring-1 focus:ring-red-550/20 transition-all placeholder-gray-400"}),s.jsxs("button",{type:"submit",disabled:Qe,className:"px-4 py-1.5 bg-red-650 hover:bg-red-700 disabled:bg-gray-300 text-white rounded-lg text-[9px] font-black uppercase tracking-wider transition-colors cursor-pointer active:scale-95 shrink-0 flex items-center gap-1",children:[Qe?s.jsx(Er,{size:10,className:"className animate-spin"}):s.jsx(Eo,{size:10}),s.jsx("span",{children:"Dispatch"})]})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase text-gray-900 tracking-wider",children:["Lounge Fellow Citizens (",xe.length,")"]}),s.jsx("span",{className:"text-[8px] font-mono font-black uppercase tracking-widest text-emerald-650 bg-emerald-50 px-1.5 py-0.5 rounded-md",children:"Live Stream"})]}),Me?s.jsx("div",{className:"flex justify-center items-center py-6",children:s.jsx(Er,{size:18,className:"animate-spin text-red-650"})}):xe.length===0?s.jsx("p",{className:"text-[9.5px] font-bold uppercase text-gray-400 font-sans py-4 text-center leading-relaxed",children:"No other registered peers discovered yet. Disperse invitations to propagate!"}):s.jsx("div",{className:"space-y-2 max-h-52 overflow-y-auto pr-1",children:xe.map(Re=>{const mt=Fn[Re.uid];return s.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-gray-150 hover:border-gray-200 hover:bg-gray-100/10 transition-colors gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("img",{src:Re.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Re.displayName||"P")}&background=random`,className:"w-7 h-7 rounded-full border border-gray-100 object-cover shrink-0",alt:""}),s.jsxs("div",{className:"min-w-0 leading-tight",children:[s.jsx("span",{className:"text-[10px] font-black uppercase tracking-tight text-gray-950 block truncate",children:Re.displayName||"Peer"}),s.jsxs("span",{className:"text-[8px] font-semibold text-gray-400 block truncate",children:["@",(Re.displayName||"peer").toLowerCase().replace(/\s+/g,"")]})]})]}),s.jsx("button",{onClick:()=>Qr(Re),disabled:mt,className:Fe("text-[8px] font-sans font-black uppercase tracking-widest px-2.5 py-1.5 rounded-lg border cursor-pointer transition-all active:scale-95 flex items-center gap-1 shrink-0",mt?"bg-gray-100 text-gray-400 border-gray-200 cursor-not-allowed":"bg-emerald-600 text-white border-emerald-500 hover:bg-emerald-700"),children:mt?s.jsxs(s.Fragment,{children:[s.jsx(Bu,{size:9,strokeWidth:3}),s.jsx("span",{children:"Invited"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Np,{size:9,strokeWidth:3}),s.jsx("span",{children:"Invite"})]})})]},Re.uid)})})]})]}),s.jsx("div",{className:"border-t border-gray-100 pt-3.5 mt-5 text-center text-gray-400",children:s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest font-mono",children:"Campus Eye Network Connection Protocol"})})]})]})}),s.jsx(or,{children:$n&&s.jsxs("div",{className:"fixed inset-0 bg-slate-950/95 backdrop-blur-md flex flex-col items-center justify-center p-4 z-[9999] select-none",children:[s.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-3",children:[s.jsxs("button",{onClick:async()=>{try{const mt=await(await fetch($n)).blob(),rt=URL.createObjectURL(mt),At=document.createElement("a");At.href=rt,At.download="posts_image.jpg",document.body.appendChild(At),At.click(),document.body.removeChild(At),URL.revokeObjectURL(rt),pe.success("Download started!")}catch{window.open($n,"_blank"),pe.success("Opened photo page! Tap and hold to download.")}},className:"px-4 py-2 bg-white/10 hover:bg-white text-white hover:text-black rounded-xl text-[10px] font-black uppercase tracking-widest flex items-center gap-1.5 transition-all cursor-pointer",title:"Download image asset",children:[s.jsx(eE,{size:12,strokeWidth:2.5}),s.jsx("span",{children:"Download"})]}),s.jsx("button",{onClick:()=>Et(null),className:"w-10 h-10 rounded-full bg-white/10 hover:bg-red-650 text-white flex items-center justify-center transition-all cursor-pointer",title:"Dismiss image viewer",children:s.jsx(er,{size:20,strokeWidth:2.5})})]}),s.jsx(Zt.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"max-w-4xl max-h-[85vh] w-full flex items-center justify-center overflow-hidden",children:s.jsx("img",{src:$n,className:"max-w-full max-h-[80vh] object-contain rounded-2xl shadow-2xl border border-white/15 select-all",alt:"Enlarged campus attachment",referrerPolicy:"no-referrer"})}),s.jsx("p",{className:"text-[10px] text-gray-400 uppercase tracking-widest mt-4 font-bold",children:"Tip: Long-touch or right-click picture to download directly"})]})}),s.jsx(or,{children:z&&s.jsx("div",{className:"fixed inset-0 bg-zinc-950/80 backdrop-blur-sm flex items-center justify-center p-4 z-[9900] select-none text-left animate-fade-in",children:s.jsxs(Zt.div,{initial:{scale:.95,opacity:0,y:15},animate:{scale:1,opacity:1,y:0},exit:{scale:.95,opacity:0,y:15},transition:{type:"spring",duration:.5},className:"bg-white rounded-[2.5rem] p-6 md:p-8 w-full max-w-2xl shadow-2xl relative overflow-hidden border border-gray-100 flex flex-col max-h-[90vh]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4 shrink-0 pb-3 border-b border-gray-100 relative z-20",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"p-2 bg-red-100 text-red-650 rounded-xl",children:s.jsx(Zi,{size:16})}),s.jsxs("div",{children:[s.jsx("span",{className:"text-red-650 font-black text-[9px] uppercase tracking-widest block font-mono",children:"Spotlight Dispatch"}),s.jsx("h3",{className:"text-md font-serif font-black text-gray-950 uppercase tracking-tight",children:"Direct Shared Lounge Post"})]})]}),s.jsx("button",{onClick:()=>{F(null);const Re=new URL(window.location.href);Re.searchParams.delete("postId"),Re.searchParams.delete("post"),window.history.replaceState({},"",Re.toString())},className:"p-2.5 bg-gray-50 hover:bg-red-50 text-gray-900 hover:text-red-650 rounded-full transition-all cursor-pointer border border-transparent hover:border-red-100 flex items-center justify-center",title:"Close spotlight focus and browse full feed",children:s.jsx(er,{size:16,strokeWidth:2.5})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto space-y-4 pr-1 select-text relative z-10",children:X?s.jsxs("div",{className:"py-16 flex flex-col items-center justify-center space-y-2",children:[s.jsx(Er,{className:"w-8 h-8 text-red-650 animate-spin"}),s.jsx("span",{className:"text-[10px] font-black uppercase text-gray-400 tracking-widest",children:"Retrieving shared post details..."})]}):$?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{onClick:()=>{t==null||t($.authorId),F(null)},className:"flex items-center gap-2.5 cursor-pointer hover:opacity-85 transition-opacity duration-150",title:"Click to view peer credentials",children:[s.jsx("img",{src:$.authorId==="mega-ai-bot"||(kt=$.authorName)!=null&&kt.toLowerCase().includes("mega ai")?zo:$.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent($.authorName)}&background=random`,className:"w-8 h-8 rounded-full border border-gray-100 object-cover shrink-0",alt:""}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1 leading-none",children:[s.jsx("span",{className:"text-[11px] font-black uppercase tracking-tight text-gray-950",children:$.authorName}),s.jsxs("span",{className:"text-[8.5px] text-gray-400 font-bold",children:["@",$.authorName.toLowerCase().replace(/\s+/g,"")]})]}),s.jsx("span",{className:"text-[8px] font-black uppercase tracking-wider text-gray-400 mt-0.5 block",children:(Pa=$.createdAt)!=null&&Pa.toDate?new Date($.createdAt.toDate().getTime()).toLocaleDateString():"Recently"})]})]}),je&&je.uid!==$.authorId&&s.jsxs("div",{className:"flex items-center gap-1",children:[yn.has($.authorId)&&s.jsxs("button",{onClick:Re=>{Re.stopPropagation(),window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:{uid:$.authorId,displayName:$.authorName,username:$.authorName.toLowerCase().replace(/\s+/g,""),photoURL:$.authorPhotoURL||""}}))},className:"p-1 px-2.5 bg-[#007AFF] hover:bg-blue-600 text-white rounded-full transition-all cursor-pointer flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider shrink-0 shadow-2xs",title:`Open iMessage chat with connected friend ${$.authorName}`,children:[s.jsx(ea,{size:11,strokeWidth:2.5}),s.jsx("span",{children:"iMessage"})]}),s.jsx("button",{onClick:()=>Ss($.authorId,$.authorName),className:`text-[8px] font-black uppercase tracking-widest h-6 px-2 rounded-full flex items-center gap-0.5 cursor-pointer transition-colors ${a[$.authorId]?"bg-gray-100 text-gray-650 border border-gray-200 hover:bg-red-50 hover:text-red-500":"bg-red-50 text-red-650 border border-red-150/50 hover:bg-red-100"}`,children:a[$.authorId]?s.jsxs(s.Fragment,{children:[s.jsx(ey,{size:9}),s.jsx("span",{children:"Following"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Np,{size:9}),s.jsx("span",{children:"Follow"})]})})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-gray-800 leading-relaxed whitespace-pre-wrap select-text",children:m1($.content)}),$.imageUrl&&s.jsxs("div",{onClick:()=>Et($.imageUrl),className:"relative aspect-video max-h-72 w-full rounded-2xl border border-gray-100 overflow-hidden cursor-pointer group bg-gray-50",children:[s.jsx(Li,{src:$.imageUrl,className:"w-full h-full object-contain mx-auto group-hover:opacity-95 duration-200",alt:""}),s.jsx("div",{className:"absolute inset-0 bg-black/10 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:s.jsx(r2,{className:"text-white drop-shadow-sm w-5 h-5"})})]})]}),s.jsxs("div",{className:"flex items-center justify-between border-y border-gray-100 py-3 mt-4 text-[10px] font-black uppercase tracking-wider font-mono shrink-0",children:[s.jsx("div",{className:"flex gap-4",children:s.jsxs("button",{onClick:()=>mi($.id,$.likedBy),className:`flex items-center gap-1.5 cursor-pointer ${(wr=$.likedBy)!=null&&wr.includes((je==null?void 0:je.uid)||"")?"text-red-650 font-black":"text-gray-450 hover:text-gray-950"}`,children:[s.jsx(mc,{size:14,className:(is=$.likedBy)!=null&&is.includes((je==null?void 0:je.uid)||"")?"fill-current":""}),s.jsxs("span",{children:[$.likeCount||0," Likes"]})]})}),s.jsxs("button",{onClick:()=>li($.id,$.content,$.imageUrl),className:"flex items-center gap-1.5 text-gray-450 hover:text-gray-950 transition-colors cursor-pointer",children:[s.jsx(hf,{size:13}),s.jsx("span",{children:"Share with Image"})]})]}),s.jsxs("div",{className:"space-y-4 pt-2",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] font-black uppercase tracking-widest text-gray-400 font-mono",children:[s.jsx(bi,{size:13}),s.jsxs("span",{children:["Discussions (",((uo=ut[$.id])==null?void 0:uo.length)||$.commentCount||0,")"]})]})}),s.jsx("div",{className:"space-y-3 max-h-[25vh] overflow-y-auto pr-1",children:!ut[$.id]||ut[$.id].length===0?s.jsx("div",{className:"py-4 text-center bg-gray-50/50 rounded-xl border border-dashed border-gray-100",children:s.jsx("span",{className:"text-[10px] font-black uppercase tracking-wider text-gray-400 font-mono",children:"No feedback published yet"})}):ut[$.id].map(Re=>{var mt,rt;return s.jsxs("div",{className:"p-3 bg-gray-50/60 rounded-2xl border border-gray-100 flex items-start gap-2.5 transition-all",children:[s.jsx("img",{src:Re.authorId==="mega-ai-bot"||(mt=Re.authorName)!=null&&mt.toLowerCase().includes("mega ai")?zo:Re.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Re.authorName)}&background=random`,className:"w-6 h-6 rounded-full border border-gray-100 object-cover shrink-0 mt-0.5",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9.5px] font-black uppercase tracking-tight text-gray-950",children:Re.authorName}),s.jsx("span",{className:"text-[7.5px] font-bold text-gray-400 font-mono",children:(rt=Re.createdAt)!=null&&rt.toDate?new Date(Re.createdAt.toDate().getTime()).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"Recently"})]}),s.jsx("p",{className:"text-[10.5px] text-gray-800 leading-relaxed font-sans mt-0.5 select-text",children:Re.content})]})]},Re.id)})}),je?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Add your perspective...",value:Dt[$.id]||"",onChange:Re=>hn(mt=>({...mt,[$.id]:Re.target.value})),onKeyDown:Re=>{Re.key==="Enter"&&gi($.id)},className:"flex-1 px-4 py-2.5 bg-gray-50 border border-gray-250 focus:border-red-650 rounded-xl text-xs font-bold outline-none transition-all placeholder:text-gray-400"}),s.jsx("button",{onClick:()=>gi($.id),disabled:gr[$.id],className:"p-2.5 bg-zinc-950 hover:bg-red-650 disabled:bg-gray-200 text-white rounded-xl transition-all flex items-center justify-center cursor-pointer active:scale-95 duration-100",children:gr[$.id]?s.jsx(Er,{className:"w-4 h-4 animate-spin text-white"}):s.jsx(Eo,{size:14})})]}):s.jsx("div",{className:"p-3 bg-red-50/40 border border-red-100/40 rounded-xl text-center",children:s.jsx("span",{className:"text-[9px] font-black uppercase text-red-650 tracking-wider font-mono",children:"Authenticate to contribute opinions"})})]})]}):s.jsxs("div",{className:"py-16 text-center",children:[s.jsx(ku,{className:"w-10 h-10 text-amber-500 mx-auto mb-2"}),s.jsx("p",{className:"text-xs font-black uppercase text-gray-950 tracking-wider",children:"Lounge post not found or removed"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"This shared dispatch may have been deleted or flagged by administrators."})]})}),s.jsx("div",{className:"pt-4 border-t border-gray-100 shrink-0 mt-3 relative z-25",children:s.jsxs("button",{type:"button",onClick:()=>{F(null);const Re=new URL(window.location.href);Re.searchParams.delete("postId"),Re.searchParams.delete("post"),window.history.replaceState({},"",Re.toString())},className:"w-full py-3 bg-zinc-950 hover:bg-red-650 text-white rounded-2xl text-[10px] font-black uppercase tracking-widest transition-colors duration-200 cursor-pointer shadow-sm hover:shadow-md flex items-center justify-center gap-1.5",children:[s.jsx(_o,{size:12,strokeWidth:2.5}),s.jsx("span",{children:"Dismiss Focus & Browse Lounge Feed"})]})})]})})}),s.jsx(or,{children:dt&&s.jsxs("div",{className:"fixed inset-0 z-[9950] flex items-end md:items-center justify-center p-0 md:p-4 animate-fade-in",children:[s.jsx("div",{className:"fixed inset-0 bg-zinc-950/75 backdrop-blur-md transition-opacity duration-300",onClick:()=>{An(null),Dn(Re=>({...Re,[dt]:null}))}}),s.jsxs(Zt.div,{initial:{y:"100%",opacity:0},animate:{y:0,opacity:1},exit:{y:"100%",opacity:0},transition:{type:"spring",damping:25,stiffness:280},className:"relative z-10 bg-white rounded-t-[2.5rem] md:rounded-[2.5rem] w-full max-w-xl max-h-[85vh] flex flex-col shadow-2xl border border-gray-150 overflow-hidden",children:[s.jsxs("div",{className:"p-4 md:p-5 border-b border-gray-100 flex items-center justify-between bg-gray-50/50",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"p-2 bg-red-100 text-red-650 rounded-xl",children:s.jsx(bi,{size:16})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-950 font-mono",children:"Lounge Discussion Thread"}),s.jsxs("p",{className:"text-[9px] text-gray-400 font-sans",children:[((hr=ut[dt])==null?void 0:hr.length)||0," peer responses • Threaded conversations"]})]})]}),s.jsx("button",{onClick:()=>{An(null),Dn(Re=>({...Re,[dt]:null}))},className:"w-8 h-8 rounded-full bg-gray-100 hover:bg-red-50 text-gray-600 hover:text-red-650 flex items-center justify-center transition-colors cursor-pointer",children:s.jsx(er,{size:16})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4 md:p-5 space-y-4",children:!ut[dt]||ut[dt].length===0?s.jsxs("div",{className:"py-12 text-center bg-gray-50/50 rounded-2xl border border-dashed border-gray-200",children:[s.jsx(bi,{className:"w-8 h-8 text-gray-300 mx-auto mb-2 animate-bounce"}),s.jsx("p",{className:"text-xs font-black uppercase text-gray-500 tracking-wider font-mono",children:"No responses yet"}),s.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"Be the first to share your thoughts and start a discussion thread!"})]}):(()=>{const Re=ut[dt]||[];return Re.filter(rt=>!rt.parentId).map(rt=>{var nn,Nn,Be;const At=Re.filter(Bt=>Bt.parentId===rt.id);return s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{id:`comment-${rt.id}`,className:"p-3 bg-gray-50/80 rounded-2xl border border-gray-150 relative group transition-all",children:s.jsxs("div",{className:"flex items-start gap-2.5",children:[s.jsx("img",{src:rt.authorId==="mega-ai-bot"||rt.userId==="mega-ai-bot"||(nn=rt.authorName)!=null&&nn.toLowerCase().includes("mega ai")?zo:rt.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(rt.authorName)}&background=random`,className:"w-7 h-7 rounded-full border border-gray-100 object-cover mt-0.5 shrink-0",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-[10px] font-black uppercase tracking-tight text-gray-950",children:rt.authorName}),s.jsx(Fo,{size:11,className:"shrink-0"}),(rt.isAIGenerated||rt.isAiGenerated||rt.authorId==="mega-ai-bot"||rt.userId==="mega-ai-bot"||((Nn=rt.authorName)==null?void 0:Nn.toLowerCase().includes("mega ai")))&&s.jsx(zw,{})]}),s.jsx("span",{className:"text-[8px] font-bold text-gray-400 font-mono",children:(Be=rt.createdAt)!=null&&Be.toDate?new Date(rt.createdAt.toDate().getTime()).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"Just now"})]}),s.jsx("p",{className:"text-[11px] text-gray-800 leading-relaxed font-sans mt-1",children:m1(rt.content,Kt)}),rt.stickerEmoji&&s.jsx("div",{className:"my-1.5 p-1 bg-amber-50 rounded-xl inline-block border border-amber-200",children:s.jsx("span",{className:"text-2xl",children:rt.stickerEmoji})}),rt.imageUrl&&s.jsx("div",{className:"my-1.5 rounded-xl overflow-hidden border border-gray-200 max-h-40 bg-gray-50",children:s.jsx("img",{src:rt.imageUrl,className:"w-full h-full object-cover",alt:"Attachment"})}),rt.audioUrl&&s.jsx("div",{className:"my-1.5 p-1 bg-gray-100 rounded-xl",children:s.jsx("audio",{controls:!0,src:rt.audioUrl,className:"w-full h-8"})}),s.jsxs("div",{className:"flex items-center gap-4 mt-2 pt-1 border-t border-gray-100/60",children:[s.jsxs("button",{onClick:()=>vs(dt,rt.id),className:`flex items-center gap-1 text-[9px] font-black uppercase tracking-wider font-mono cursor-pointer transition-colors ${Ot[rt.id]||rt.likedBy&&je&&rt.likedBy.includes(je.uid)?"text-red-650":"text-gray-400 hover:text-red-650"}`,children:[s.jsx(mc,{size:12,fill:Ot[rt.id]||rt.likedBy&&je&&rt.likedBy.includes(je.uid)?"currentColor":"none"}),s.jsx("span",{children:rt.likeCount||0})]}),s.jsxs("button",{onClick:()=>Dn(Bt=>({...Bt,[dt]:{commentId:rt.id,authorName:rt.authorName}})),className:"flex items-center gap-1 text-[9px] font-black uppercase tracking-wider font-mono text-gray-400 hover:text-red-650 cursor-pointer transition-colors",children:[s.jsx(Eo,{size:10,className:"rotate-45"}),s.jsx("span",{children:"Reply"})]})]})]})]})}),At.length>0&&s.jsx("div",{className:"border-l-2 border-red-500/30 pl-3 ml-4 space-y-2 pt-1",children:At.map(Bt=>{var Mn,jn,Ln;return s.jsxs("div",{id:`comment-${Bt.id}`,className:"p-2.5 bg-red-50/30 rounded-xl border border-red-100/50 flex items-start gap-2 transition-all",children:[s.jsx("img",{src:Bt.authorId==="mega-ai-bot"||Bt.userId==="mega-ai-bot"||(Mn=Bt.authorName)!=null&&Mn.toLowerCase().includes("mega ai")?zo:Bt.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Bt.authorName)}&background=random`,className:"w-5 h-5 rounded-full border border-gray-100 object-cover mt-0.5 shrink-0",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[s.jsx("span",{className:"text-[9px] font-black uppercase tracking-tight text-gray-950",children:Bt.authorName}),s.jsx(Fo,{size:10,className:"shrink-0"}),(Bt.isAIGenerated||Bt.isAiGenerated||Bt.authorId==="mega-ai-bot"||Bt.userId==="mega-ai-bot"||((jn=Bt.authorName)==null?void 0:jn.toLowerCase().includes("mega ai")))&&s.jsx(zw,{}),Bt.replyToAuthor&&s.jsxs("span",{className:"text-[8px] font-mono text-red-650 font-bold",children:["replying to @",Bt.replyToAuthor]})]}),s.jsx("span",{className:"text-[7.5px] font-bold text-gray-400 font-mono",children:(Ln=Bt.createdAt)!=null&&Ln.toDate?new Date(Bt.createdAt.toDate().getTime()).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"Just now"})]}),s.jsx("div",{className:"text-[10px] text-gray-800 font-sans leading-relaxed mt-0.5",children:m1(Bt.content,Kt)}),s.jsxs("div",{className:"flex items-center gap-3 mt-1.5 pt-1 border-t border-red-100/30",children:[s.jsxs("button",{onClick:()=>vs(dt,Bt.id),className:`flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider font-mono cursor-pointer transition-colors ${Ot[Bt.id]||Bt.likedBy&&je&&Bt.likedBy.includes(je.uid)?"text-red-650":"text-gray-400 hover:text-red-650"}`,children:[s.jsx(mc,{size:11,fill:Ot[Bt.id]||Bt.likedBy&&je&&Bt.likedBy.includes(je.uid)?"currentColor":"none"}),s.jsx("span",{children:Bt.likeCount||0})]}),s.jsx("button",{onClick:()=>Dn(xr=>({...xr,[dt]:{commentId:rt.id,authorName:Bt.authorName}})),className:"text-[8.5px] font-black uppercase tracking-wider font-mono text-gray-400 hover:text-red-650 cursor-pointer transition-colors",children:"Reply"})]})]})]},Bt.id)})})]},rt.id)})})()}),s.jsxs("div",{className:"p-3 md:p-4 border-t border-gray-150 bg-gray-50/80",children:[Ft[dt]&&s.jsxs("div",{className:"flex items-center justify-between bg-red-100/80 px-3 py-1 rounded-lg mb-2 text-[9px] font-mono text-red-700",children:[s.jsxs("span",{className:"font-bold",children:["Replying to @",(Nr=Ft[dt])==null?void 0:Nr.authorName]}),s.jsx("button",{onClick:()=>Dn(Re=>({...Re,[dt]:null})),className:"hover:text-red-900 font-black cursor-pointer",children:"✕"})]}),je?s.jsxs("div",{className:"space-y-2",children:[dn[dt]&&s.jsxs("div",{className:"flex items-center gap-1.5 p-2 bg-amber-50/80 border border-amber-200 rounded-xl overflow-x-auto",children:[s.jsx("span",{className:"text-[9px] font-black uppercase text-amber-800 font-mono shrink-0 mr-1",children:"Stickers:"}),["🔥","🎓","👏","💯","📌","❤️","🚀","💡","💎","🎉","🌟","🏆","📢"].map(Re=>s.jsx("button",{type:"button",onClick:()=>{mn(mt=>({...mt,[dt]:Re})),mr(mt=>({...mt,[dt]:!1})),pe.success(`Sticker ${Re} selected!`,{id:"stk-selected"})},className:"text-lg hover:scale-125 transition-transform p-1 cursor-pointer shrink-0",children:Re},Re))]}),qn[dt]&&s.jsxs("div",{className:"flex items-center gap-2 bg-amber-100 px-2.5 py-1 rounded-lg text-xs font-bold text-amber-900 w-fit",children:[s.jsxs("span",{children:["Active Sticker: ",qn[dt]]}),s.jsx("button",{type:"button",onClick:()=>mn(Re=>({...Re,[dt]:""})),className:"hover:text-red-700 font-black cursor-pointer text-xs",children:"✕"})]}),s.jsx(rY,{value:Dt[dt]||"",onSelectMention:Re=>hn(mt=>({...mt,[dt]:Re}))}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("button",{type:"button",onClick:()=>mr(Re=>({...Re,[dt]:!Re[dt]})),className:"p-2 bg-amber-100 text-amber-800 hover:bg-amber-200 rounded-xl transition-colors cursor-pointer shrink-0",title:"Attach Sticker",children:s.jsx(hF,{size:16})}),s.jsx("input",{type:"text",value:Dt[dt]||"",onChange:Re=>hn(mt=>({...mt,[dt]:Re.target.value})),onKeyDown:Re=>{Re.key==="Enter"&&gi(dt)},placeholder:Ft[dt]?`Write reply to @${(cr=Ft[dt])==null?void 0:cr.authorName}...`:"Write a statement, reply, or attach sticker...",className:"flex-1 px-3.5 py-2.5 bg-white border border-gray-250 focus:border-red-650 rounded-xl text-xs font-medium outline-none transition-all placeholder:text-gray-400 shadow-inner"}),s.jsx("button",{onClick:()=>gi(dt),disabled:gr[dt]||!(Dt[dt]||"").trim()&&!qn[dt],className:"p-2.5 bg-zinc-950 hover:bg-red-650 disabled:bg-gray-200 text-white rounded-xl transition-all flex items-center justify-center cursor-pointer active:scale-95 shrink-0",children:gr[dt]?s.jsx(Er,{className:"w-4 h-4 animate-spin text-white"}):s.jsx(Eo,{size:14})})]})]}):s.jsx("div",{className:"p-2.5 bg-gray-100 rounded-xl text-center",children:s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500 font-mono",children:"Sign in with Google to post replies"})})]})]})]})}),s.jsx(BMe,{isOpen:Pt,url:St,onClose:()=>{Nt(!1),tn(null)}})]})},HMe={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},{urls:"stun:stun2.l.google.com:19302"}]},Dee=({isOpen:e,onClose:t,peer:n,callType:r,isIncoming:i=!1,existingCallId:a})=>{const o=Ne.currentUser,[c,h]=I.useState("calling"),[f,m]=I.useState(!1),[y,w]=I.useState(r==="audio"),[A,S]=I.useState(0),[C,T]=I.useState(a||null),D=I.useRef(null),V=I.useRef(null),L=I.useRef(null),K=I.useRef(null),Z=I.useRef(null),q=I.useRef(null);I.useRef(null),I.useEffect(()=>!e||!o?void 0:((async()=>{try{const J={audio:!0,video:r==="video"?{width:{ideal:1280},height:{ideal:720},facingMode:"user"}:!1},ye=await navigator.mediaDevices.getUserMedia(J);K.current=ye,D.current&&r==="video"&&(D.current.srcObject=ye);const ne=new RTCPeerConnection(HMe);if(Z.current=ne,ye.getTracks().forEach(de=>{ne.addTrack(de,ye)}),ne.ontrack=de=>{de.streams&&de.streams[0]&&(V.current&&r==="video"?V.current.srcObject=de.streams[0]:L.current&&(L.current.srcObject=de.streams[0]))},i&&a){h("connected");const de=Je(he,"calls",a),be=await cs(de);if(be.exists()){const Ke=be.data();if(Ke.offer){await ne.setRemoteDescription(new RTCSessionDescription(Ke.offer));const G=await ne.createAnswer();await ne.setLocalDescription(G),await Cn(de,{answer:{type:G.type,sdp:G.sdp},status:"connected"})}}const Ce=et(he,"calls",a,"callerCandidates");Wr(Ce,Ke=>{Ke.docChanges().forEach(async G=>{if(G.type==="added"){const se=new RTCIceCandidate(G.doc.data());await ne.addIceCandidate(se)}})}),ne.onicecandidate=Ke=>{if(Ke.candidate){const G=et(he,"calls",a,"calleeCandidates");ur(G,Ke.candidate.toJSON())}}}else{const de=Je(et(he,"calls"));T(de.id);const be=et(he,"calls",de.id,"callerCandidates");ne.onicecandidate=G=>{G.candidate&&ur(be,G.candidate.toJSON())};const Ce=await ne.createOffer();await ne.setLocalDescription(Ce),await Rr(de,{callerId:o.uid,callerName:o.displayName||"Campus Peer",callerPhoto:o.photoURL||"",receiverId:n.uid,receiverName:n.displayName,receiverPhoto:n.photoURL||"",type:r,status:"ringing",offer:{type:Ce.type,sdp:Ce.sdp},createdAt:new Date}),await ur(et(he,"notifications"),{userId:n.uid,senderId:o.uid,senderName:o.displayName||"Campus Peer",senderUsername:(o.displayName||"peer").toLowerCase().replace(/\s+/g,""),senderPhotoURL:o.photoURL||"",title:`📞 Incoming ${r==="video"?"FaceTime Video":"Audio"} Call from ${o.displayName}`,message:`Tap to accept ${r} call now!`,type:"incoming_call",callId:de.id,callType:r,used:!1,createdAt:new Date}),h("ringing"),Wr(de,async G=>{if(!G.exists())return;const se=G.data();if(se.status==="rejected"||se.status==="ended")B(),h("ended"),ir.error("Call ended by user"),setTimeout(()=>t(),1200);else if(se.answer&&!ne.currentRemoteDescription){const xe=new RTCSessionDescription(se.answer);await ne.setRemoteDescription(xe),h("connected")}});const Ke=et(he,"calls",de.id,"calleeCandidates");Wr(Ke,G=>{G.docChanges().forEach(async se=>{if(se.type==="added"){const xe=new RTCIceCandidate(se.doc.data());await ne.addIceCandidate(xe)}})})}}catch(J){console.error("Call media error:",J),ir.error("Could not access microphone/camera: "+(J.message||"Permission denied")),B(),t()}})(),()=>{B()}),[e]),I.useEffect(()=>(c==="connected"?q.current=setInterval(()=>{S(X=>X+1)},1e3):q.current&&clearInterval(q.current),()=>{q.current&&clearInterval(q.current)}),[c]);const B=()=>{K.current&&(K.current.getTracks().forEach(X=>X.stop()),K.current=null),Z.current&&(Z.current.close(),Z.current=null),q.current&&clearInterval(q.current)},z=async()=>{if(h("ended"),C)try{await Cn(Je(he,"calls",C),{status:"ended"})}catch{}B(),ir.success("Call ended",{icon:"📵"}),t()},F=()=>{if(K.current){const X=K.current.getAudioTracks()[0];X&&(X.enabled=!X.enabled,m(!X.enabled))}},$=()=>{if(K.current){const X=K.current.getVideoTracks()[0];X&&(X.enabled=!X.enabled,w(!X.enabled))}},Y=X=>{const J=Math.floor(X/60),ye=X%60;return`${J}:${ye<10?"0":""}${ye}`};return e?s.jsx(or,{children:s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-2 sm:p-4 bg-black/85 backdrop-blur-md",children:s.jsxs(Zt.div,{initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:20},className:"bg-neutral-900 border border-neutral-800 rounded-3xl shadow-2xl w-full max-w-md h-[80vh] max-h-[620px] flex flex-col justify-between overflow-hidden relative text-white",children:[s.jsxs("div",{className:"p-4 flex items-center justify-between border-b border-white/10 bg-black/40 backdrop-blur-md z-20",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500 animate-pulse"}),s.jsx("span",{className:"text-xs font-black uppercase tracking-wider text-neutral-300",children:r==="video"?"FaceTime HD Video":"HD Voice Call"})]}),c==="connected"&&s.jsx("span",{className:"text-xs font-mono font-bold bg-white/10 px-2.5 py-0.5 rounded-full text-emerald-400 border border-emerald-500/30",children:Y(A)})]}),s.jsxs("div",{className:"flex-1 relative flex flex-col items-center justify-center p-6 text-center overflow-hidden",children:[r==="video"&&s.jsxs("div",{className:"absolute inset-0 bg-black z-0",children:[s.jsx("video",{ref:V,autoPlay:!0,playsInline:!0,className:"w-full h-full object-cover"}),s.jsxs("div",{className:"absolute top-4 right-4 w-28 h-40 bg-neutral-800 rounded-2xl overflow-hidden border-2 border-white/20 shadow-xl z-20",children:[s.jsx("video",{ref:D,autoPlay:!0,playsInline:!0,muted:!0,className:"w-full h-full object-cover"}),y&&s.jsx("div",{className:"absolute inset-0 bg-neutral-900 flex items-center justify-center text-xs text-neutral-500 font-bold",children:"Camera Off"})]})]}),s.jsx("audio",{ref:L,autoPlay:!0}),s.jsxs("div",{className:"relative z-10 flex flex-col items-center",children:[s.jsxs("div",{className:"relative mb-4",children:[s.jsx("div",{className:"w-24 h-24 sm:w-28 sm:h-28 rounded-full overflow-hidden border-4 border-white/20 shadow-2xl relative",children:s.jsx("img",{src:n.photoURL||`https://api.dicebear.com/7.x/bottts/svg?seed=${n.username}`,alt:"",className:"w-full h-full object-cover"})}),c==="ringing"&&s.jsx("span",{className:"absolute -inset-2 rounded-full border-2 border-emerald-500 animate-ping opacity-75"})]}),s.jsx("h2",{className:"text-xl font-black text-white tracking-tight",children:n.displayName}),s.jsxs("p",{className:"text-xs text-neutral-400 font-bold mt-1 uppercase tracking-wider",children:["@",n.username]}),s.jsxs("div",{className:"mt-4 px-3 py-1 bg-white/10 rounded-full text-xs font-semibold tracking-wide text-neutral-200 border border-white/10 backdrop-blur-sm",children:[c==="calling"&&"Connecting...",c==="ringing"&&"Ringing Peer...",c==="connected"&&"Connected • Secure HD Voice",c==="ended"&&"Call Terminated"]}),r==="audio"&&c==="connected"&&s.jsx("div",{className:"flex items-center gap-1 mt-6",children:[40,70,30,90,50,80,40,60].map((X,J)=>s.jsx(Zt.span,{animate:{height:[10,X,10]},transition:{repeat:1/0,duration:.8,delay:J*.1},className:"w-1 bg-[#007AFF] rounded-full"},J))})]})]}),s.jsxs("div",{className:"p-6 bg-black/60 backdrop-blur-xl border-t border-white/10 flex items-center justify-around z-20",children:[s.jsx("button",{onClick:F,className:`p-4 rounded-full transition-all cursor-pointer ${f?"bg-red-500/80 text-white shadow-lg":"bg-white/15 hover:bg-white/25 text-white"}`,title:f?"Unmute":"Mute",children:f?s.jsx(Gre,{size:22}):s.jsx(Wre,{size:22})}),s.jsx("button",{onClick:z,className:"p-5 bg-red-600 hover:bg-red-700 text-white rounded-full transition-all cursor-pointer shadow-xl scale-110 active:scale-95",title:"End Call",children:s.jsx(cF,{size:26})}),r==="video"&&s.jsx("button",{onClick:$,className:`p-4 rounded-full transition-all cursor-pointer ${y?"bg-red-500/80 text-white shadow-lg":"bg-white/15 hover:bg-white/25 text-white"}`,title:y?"Turn Camera On":"Turn Camera Off",children:y?s.jsx(Fie,{size:22}):s.jsx(Ea,{size:22})})]})]})})}):null},GMe=["❤️","👍","👎","😂","‼️","❓"],Mee=({isOpen:e,onClose:t,friend:n,currentUserId:r,currentUserProfile:i})=>{const[a,o]=I.useState([]),[c,h]=I.useState(""),[f,m]=I.useState(!1),[y,w]=I.useState(null),[A,S]=I.useState(!1),[C,T]=I.useState(null),[D,V]=I.useState(null),[L,K]=I.useState(""),[Z,q]=I.useState(null),[B,z]=I.useState(!0),[F,$]=I.useState(null),[Y,X]=I.useState(!1),[J,ye]=I.useState(null),[ne,de]=I.useState(!1),be=I.useRef(null),Ce=I.useRef(null),Ke=I.useRef(null),G=I.useRef(null),se=n?[r,n.uid].sort().join("_"):"",xe=()=>{var Ee;(Ee=Ce.current)==null||Ee.scrollIntoView({behavior:"smooth"})};I.useEffect(()=>{(a.length>0||ne)&&xe()},[a,ne]),I.useEffect(()=>{if(!e||!(n!=null&&n.uid)){X(!1),ye(null);return}const Ee=Je(he,"users",n.uid),yt=Wr(Ee,Ue=>{if(Ue.exists()){const Vt=Ue.data(),St=Vt.lastSeen;let tn=!1;if(St){const Pt=St.seconds?St.seconds*1e3:St.toMillis?St.toMillis():new Date(St).getTime();!isNaN(Pt)&&Date.now()-Pt<15e4&&(tn=!0)}X(!!(Vt.isOnline&&(tn||Vt.isOnline===!0))),ye(St)}},Ue=>{console.warn("Friend presence listener warning:",Ue)});return()=>yt()},[e,n==null?void 0:n.uid]),I.useEffect(()=>{if(!e||!(n!=null&&n.uid)||!se){de(!1);return}const Ee=Je(he,"typing_status",`${se}_${n.uid}`),yt=Wr(Ee,Ue=>{if(Ue.exists()){const Vt=Ue.data();if(Vt.isTyping){const St=Vt.updatedAt,tn=St!=null&&St.seconds?St.seconds*1e3:St!=null&&St.toMillis?St.toMillis():St?new Date(St).getTime():Date.now();if(Date.now()-tn<7e3){de(!0);return}}}de(!1)},Ue=>{console.warn("Friend typing listener warning:",Ue)});return()=>yt()},[e,n==null?void 0:n.uid,se]);const re=Ee=>{if(h(Ee),!se||!r)return;const yt=Je(he,"typing_status",`${se}_${r}`);Ee.trim()?(Rr(yt,{isTyping:!0,updatedAt:En()},{merge:!0}).catch(()=>{}),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>{Rr(yt,{isTyping:!1,updatedAt:En()},{merge:!0}).catch(()=>{})},2500)):(be.current&&clearTimeout(be.current),Rr(yt,{isTyping:!1,updatedAt:En()},{merge:!0}).catch(()=>{}))};if(I.useEffect(()=>()=>{if(be.current&&clearTimeout(be.current),se&&r){const Ee=Je(he,"typing_status",`${se}_${r}`);Rr(Ee,{isTyping:!1,updatedAt:En()},{merge:!0}).catch(()=>{})}},[se,r]),I.useEffect(()=>{if(!e||!n||!se){o([]);return}z(!0);const Ee=Qt(et(he,"direct_messages"),Ar("conversationId","==",se)),yt=Wr(Ee,Ue=>{const Vt=Ue.docs.map(St=>({id:St.id,...St.data()}));Vt.sort((St,tn)=>{var Kt,ut;const Pt=(Kt=St.createdAt)!=null&&Kt.seconds?St.createdAt.seconds*1e3:St.createdAt?new Date(St.createdAt).getTime():0,Nt=(ut=tn.createdAt)!=null&&ut.seconds?tn.createdAt.seconds*1e3:tn.createdAt?new Date(tn.createdAt).getTime():0;return Pt-Nt}),o(Vt),z(!1)},Ue=>{console.warn("Realtime message listener fallback:",Ue),z(!1)});return()=>yt()},[e,n==null?void 0:n.uid,se]),!e||!n)return null;const Me=async Ee=>{var St,tn;if(Ee&&Ee.preventDefault(),!c.trim()&&!y||f||!r)return;m(!0);const yt=c.trim(),Ue=y,Vt=Z;if(h(""),w(null),q(null),se&&r){be.current&&clearTimeout(be.current);const Pt=Je(he,"typing_status",`${se}_${r}`);Rr(Pt,{isTyping:!1,updatedAt:En()},{merge:!0}).catch(()=>{})}try{const Pt=(i==null?void 0:i.displayName)||((St=Ne.currentUser)==null?void 0:St.displayName)||"Campus Friend",Nt=(i==null?void 0:i.username)||"peer";await ur(et(he,"direct_messages"),{conversationId:se,senderId:r,receiverId:n.uid,participants:[r,n.uid],text:yt,imageUrl:Ue||"",replyToText:Vt?Vt.text||"Image":"",createdAt:new Date}),await ur(et(he,"notifications"),{userId:n.uid,senderId:r,senderName:Pt,senderUsername:Nt,senderPhotoURL:(i==null?void 0:i.photoURL)||((tn=Ne.currentUser)==null?void 0:tn.photoURL)||"",title:`💬 Direct Message from ${Pt}`,message:yt||"Sent an image attachment 📷",type:"direct_message",canReply:!0,used:!1,createdAt:new Date})}catch(Pt){ir.error("Failed to send message: "+Pt.message)}finally{m(!1)}},nt=async(Ee,yt)=>{try{const Ue=a.find(St=>St.id===Ee),Vt=(Ue==null?void 0:Ue.reaction)===yt?"":yt;await Cn(Je(he,"direct_messages",Ee),{reaction:Vt}),T(null),V(null)}catch(Ue){ir.error("Failed to update reaction: "+Ue.message)}},ze=Ee=>{var yt;q(Ee),ir.success("Swiped to reply!",{icon:"↩️"}),(yt=G.current)==null||yt.focus()},Tt=Ee=>{var Vt;const yt=(Vt=Ee.target.files)==null?void 0:Vt[0];if(!yt)return;if(yt.size>5*1024*1024){ir.error("Image must be under 5MB");return}S(!0);const Ue=new FileReader;Ue.onload=()=>{w(Ue.result),S(!1)},Ue.onerror=()=>{ir.error("Failed to load image"),S(!1)},Ue.readAsDataURL(yt)},It=Ee=>{if(!Ee)return"Just now";let yt;return Ee.seconds?yt=new Date(Ee.seconds*1e3):yt=new Date(Ee),isNaN(yt.getTime())?"Just now":yt.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})},ft=Ee=>{if(!Ee)return"recently";let yt;if(Ee.seconds?yt=new Date(Ee.seconds*1e3):Ee.toMillis?yt=new Date(Ee.toMillis()):yt=new Date(Ee),isNaN(yt.getTime()))return"recently";const Ue=Date.now(),Vt=Math.floor((Ue-yt.getTime())/1e3);if(Vt<60)return"just now";const St=Math.floor(Vt/60);if(St<60)return`${St}m ago`;const tn=Math.floor(St/60);if(tn<24)return`${tn}h ago`;const Pt=Math.floor(tn/24);return Pt===1?`yesterday at ${yt.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}`:Pt<7?`${Pt}d ago`:yt.toLocaleDateString([],{month:"short",day:"numeric"})};return s.jsxs(or,{children:[s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-2 sm:p-4 bg-black/65 backdrop-blur-sm",children:s.jsxs(Zt.div,{initial:{opacity:0,scale:.94,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.94,y:12},transition:{type:"spring",damping:25,stiffness:300},className:"bg-white border border-gray-200/80 rounded-3xl shadow-2xl w-full max-w-lg h-[88vh] max-h-[700px] flex flex-col overflow-hidden relative font-sans",children:[s.jsxs("div",{className:"bg-white/95 backdrop-blur-md border-b border-gray-200/80 px-4 py-3 flex items-center justify-between shrink-0 z-10 shadow-2xs",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("img",{src:n.photoURL||`https://api.dicebear.com/7.x/bottts/svg?seed=${n.username}`,alt:"",className:"w-10 h-10 rounded-full object-cover border border-gray-200 shadow-xs",referrerPolicy:"no-referrer"}),Y&&s.jsx("span",{className:"absolute bottom-0 right-0 w-3 h-3 bg-emerald-500 border-2 border-white rounded-full shadow-2xs animate-pulse"})]}),s.jsxs("div",{className:"min-w-0 text-left",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("h3",{className:"text-sm font-extrabold text-gray-950 truncate tracking-tight",children:n.displayName}),s.jsx("span",{className:"px-1.5 py-0.2 bg-blue-50 text-[#007AFF] border border-blue-200/60 text-[8px] font-black uppercase rounded-full tracking-wider shrink-0",children:"iMessage"})]}),s.jsx("div",{className:"text-[10px] font-semibold truncate leading-tight mt-0.5",children:ne?s.jsxs("span",{className:"text-[#007AFF] font-bold italic animate-pulse flex items-center gap-1",children:[s.jsxs("span",{className:"inline-flex gap-0.5",children:[s.jsx("span",{className:"w-1 h-1 rounded-full bg-[#007AFF] animate-bounce",style:{animationDelay:"0ms"}}),s.jsx("span",{className:"w-1 h-1 rounded-full bg-[#007AFF] animate-bounce",style:{animationDelay:"150ms"}}),s.jsx("span",{className:"w-1 h-1 rounded-full bg-[#007AFF] animate-bounce",style:{animationDelay:"300ms"}})]}),"typing..."]}):Y?s.jsxs("span",{className:"text-emerald-600 font-bold flex items-center gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 inline-block animate-pulse"}),"Active now"]}):s.jsx("span",{className:"text-gray-400 font-medium",children:J?`Last seen ${ft(J)}`:`@${n.username.toLowerCase()}`})})]})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsx("button",{onClick:()=>$("audio"),className:"p-2 text-gray-500 hover:text-[#007AFF] hover:bg-blue-50 rounded-full transition-all cursor-pointer",title:"Start Audio Call",children:s.jsx(zS,{size:17})}),s.jsx("button",{onClick:()=>$("video"),className:"p-2 text-gray-500 hover:text-[#007AFF] hover:bg-blue-50 rounded-full transition-all cursor-pointer",title:"Start FaceTime Video",children:s.jsx(Ea,{size:17})}),s.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-full transition-all cursor-pointer ml-1",title:"Close Chat",children:s.jsx(er,{size:18})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 bg-[#0f172a] dark:bg-[#0e1621] space-y-3.5 relative scroll-smooth bg-cover bg-center",children:[s.jsx("div",{className:"absolute inset-0 opacity-[0.07] pointer-events-none z-0",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='1'%3E%3Cpath d='M0 0h40v40H0z' fill='none'/%3E%3Cpath d='M20 10l-4 8h8l-4-8zm-8 12l-4 8h8l-4-8zm16 0l-4 8h8l-4-8zm-8 12l-4 8h8l-4-8zM60 50l-4 8h8l-4-8zm-8 12l-4 8h8l-4-8zm16 0l-4 8h8l-4-8zm-8 12l-4 8h8l-4-8z'/%3E%3C/g%3E%3C/svg%3E")`}}),s.jsx("div",{className:"flex justify-center my-1 shrink-0 z-10 relative",children:s.jsxs("div",{className:"bg-[#182533]/90 text-emerald-300 border border-emerald-500/30 rounded-2xl px-3.5 py-2 text-[10.5px] font-medium text-center shadow-lg flex items-center gap-2 max-w-xs sm:max-w-sm backdrop-blur-md",children:[s.jsx(lF,{size:13,className:"text-emerald-400 shrink-0 animate-pulse"}),s.jsxs("span",{className:"text-gray-200 leading-snug",children:[s.jsx("strong",{className:"text-emerald-400 font-extrabold",children:"End-to-End Encrypted"})," • Messages and calls are end-to-end encrypted."]})]})}),B?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-400 gap-2 relative z-10",children:[s.jsx(Er,{size:24,className:"animate-spin text-[#2AABEE]"}),s.jsx("p",{className:"text-xs font-bold uppercase tracking-wider text-gray-300",children:"Loading end-to-end encrypted chat..."})]}):a.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center px-6 py-8 my-auto relative z-10",children:[s.jsx("div",{className:"w-14 h-14 bg-[#2AABEE]/20 text-[#2AABEE] rounded-full flex items-center justify-center shadow-md mb-3 border border-[#2AABEE]/30",children:s.jsx(Zi,{size:26})}),s.jsx("h4",{className:"text-sm font-black text-white uppercase tracking-tight",children:"Telegram Secure Direct Chat"}),s.jsxs("p",{className:"text-xs text-gray-300 max-w-xs mt-1 leading-relaxed",children:["Start a private conversation with your peer friend ",s.jsxs("span",{className:"font-bold text-white",children:["@",n.username.toLowerCase()]}),"."]}),s.jsx("div",{className:"mt-4 flex flex-wrap gap-1.5 justify-center",children:["Hey! 👋","What campus event is today?","Are you studying in the library?"].map(Ee=>s.jsx("button",{onClick:()=>{re(Ee)},className:"text-[11px] font-semibold bg-[#17212b] border border-gray-700/80 text-gray-200 hover:bg-[#2AABEE] hover:text-white hover:border-[#2AABEE] px-3 py-1.5 rounded-full transition-all shadow-xs cursor-pointer",children:Ee},Ee))})]}):a.map((Ee,yt)=>{const Ue=Ee.senderId===r,Vt=C===Ee.id;return Ee.id,s.jsxs(Zt.div,{drag:"x",dragConstraints:{left:-50,right:50},dragElastic:.15,onDragEnd:(St,tn)=>{Math.abs(tn.offset.x)>30&&ze(Ee)},className:`flex flex-col ${Ue?"items-end":"items-start"} group relative z-10`,children:[yt===0&&s.jsx("div",{className:"w-full text-center my-1.5",children:s.jsx("span",{className:"text-[9.5px] font-bold text-gray-300 uppercase tracking-wider bg-[#17212b]/90 px-2.5 py-0.5 rounded-full border border-gray-700/60 shadow-xs",children:It(Ee.createdAt)})}),s.jsxs("div",{className:"relative flex items-end gap-1.5 max-w-[85%]",children:[!Ue&&s.jsx("img",{src:n.photoURL||`https://api.dicebear.com/7.x/bottts/svg?seed=${n.username}`,alt:"",className:"w-6 h-6 rounded-full object-cover border border-gray-700 shadow-xs shrink-0 mb-1"}),s.jsxs("div",{onClick:()=>{T(Vt?null:Ee.id),V(null)},className:`relative cursor-pointer transition-transform active:scale-[0.98] ${Ue?"bg-[#2AABEE] text-white rounded-2xl rounded-br-xs shadow-md px-3.5 py-2 text-[13.5px] font-normal leading-snug":"bg-[#182533] text-gray-100 border border-gray-700/60 rounded-2xl rounded-bl-xs shadow-md px-3.5 py-2 text-[13.5px] font-normal leading-snug"}`,children:[Ee.replyToText&&s.jsxs("div",{className:`text-[10px] italic px-2 py-1 rounded-lg mb-1.5 border-l-2 ${Ue?"bg-white/15 border-white text-white/90":"bg-gray-100 border-[#007AFF] text-gray-600"}`,children:[s.jsx("span",{className:"font-bold",children:"Replying:"}),' "',Ee.replyToText,'"']}),Ee.imageUrl&&s.jsx("div",{className:"mb-2 rounded-xl overflow-hidden border border-black/10",children:s.jsx("img",{src:Ee.imageUrl,alt:"Attached",className:"max-h-52 w-full object-cover"})}),s.jsx("p",{className:"whitespace-pre-wrap break-words",children:Ee.text}),Ee.reaction&&s.jsx("div",{className:`absolute -bottom-2.5 ${Ue?"-left-2":"-right-2"} bg-white border border-gray-200 rounded-full px-1.5 py-0.2 text-[12px] shadow-sm flex items-center gap-0.5 animate-bounce`,children:s.jsx("span",{children:Ee.reaction})})]})]}),s.jsx(or,{children:Vt&&s.jsxs(Zt.div,{initial:{opacity:0,scale:.8,y:-5},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.8,y:-5},className:`absolute z-20 top-0 ${Ue?"right-0":"left-8"} -translate-y-full mb-1 bg-white/95 backdrop-blur-md border border-gray-200 rounded-full px-2 py-1 shadow-lg flex items-center gap-1.5`,children:[GMe.map(St=>s.jsx("button",{onClick:tn=>{tn.stopPropagation(),nt(Ee.id,St)},className:"text-base hover:scale-125 transition-transform p-0.5 cursor-pointer",children:St},St)),s.jsxs("button",{type:"button",onClick:St=>{St.stopPropagation(),V(Ee.id),T(null)},className:"text-xs font-bold bg-blue-50 text-[#007AFF] hover:bg-blue-100 rounded-full p-1 px-1.5 transition-all flex items-center gap-0.5 cursor-pointer",title:"Choose custom emoji reaction",children:[s.jsx(Lc,{size:12}),s.jsx("span",{children:"Emoji"})]})]})}),s.jsxs("div",{className:"flex items-center gap-2 text-[9px] text-gray-400 font-semibold px-1 mt-0.5",children:[s.jsx("span",{children:It(Ee.createdAt)}),Ue&&s.jsx(Fne,{size:11,className:"text-[#007AFF]"}),s.jsxs("button",{type:"button",onClick:()=>ze(Ee),className:"text-[8px] font-bold text-gray-400 hover:text-[#007AFF] transition-colors flex items-center gap-0.5 cursor-pointer",children:[s.jsx(Z6,{size:9}),s.jsx("span",{children:"Reply"})]})]})]},`msg-${Ee.id||yt}-${yt}`)}),ne&&s.jsxs(Zt.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},exit:{opacity:0,y:5},className:"flex items-end gap-1.5 z-10",children:[s.jsx("img",{src:n.photoURL||`https://api.dicebear.com/7.x/bottts/svg?seed=${n.username}`,alt:"",className:"w-6 h-6 rounded-full object-cover border border-gray-700 shadow-xs shrink-0 mb-1"}),s.jsxs("div",{className:"bg-[#182533] border border-gray-700/60 rounded-2xl rounded-bl-xs px-3.5 py-2.5 flex items-center gap-1.5 shadow-md",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#2AABEE] animate-bounce",style:{animationDelay:"0ms"}}),s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#2AABEE] animate-bounce",style:{animationDelay:"150ms"}}),s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#2AABEE] animate-bounce",style:{animationDelay:"300ms"}})]})]}),s.jsx("div",{ref:Ce})]}),Z&&s.jsxs("div",{className:"p-2 px-3 bg-blue-50 border-t border-blue-200 flex items-center justify-between gap-2 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Z6,{size:14,className:"text-[#007AFF] shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[9px] font-bold text-blue-900 uppercase tracking-wider",children:"Swiped to Reply"}),s.jsxs("p",{className:"text-[11px] text-gray-700 truncate font-medium",children:['"',Z.text||"Image attachment",'"']})]})]}),s.jsx("button",{type:"button",onClick:()=>q(null),className:"p-1 text-gray-400 hover:text-red-600 rounded-full cursor-pointer",children:s.jsx(er,{size:14})})]}),y&&s.jsxs("div",{className:"p-2 bg-gray-100 border-t border-gray-200 flex items-center justify-between gap-2 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("img",{src:y,alt:"Preview",className:"w-10 h-10 rounded-lg object-cover border border-gray-300"}),s.jsx("span",{className:"text-[10px] font-bold text-gray-600 truncate",children:"Ready to send photo"})]}),s.jsx("button",{type:"button",onClick:()=>w(null),className:"p-1 text-gray-500 hover:text-red-600 rounded-full hover:bg-gray-200 cursor-pointer",children:s.jsx(er,{size:14})})]}),s.jsxs("form",{onSubmit:Me,className:"bg-gray-100/95 border-t border-gray-200/90 py-2 px-3 flex items-center gap-2 shrink-0 z-20",children:[s.jsx("input",{type:"file",ref:Ke,accept:"image/*",onChange:Tt,className:"hidden"}),s.jsx("button",{type:"button",onClick:()=>{var Ee;return(Ee=Ke.current)==null?void 0:Ee.click()},disabled:A,className:"p-1.5 text-[#007AFF] hover:bg-blue-50 active:scale-95 rounded-full transition-all cursor-pointer shrink-0",title:"Attach Image",children:A?s.jsx(Er,{size:17,className:"animate-spin"}):s.jsx(xu,{size:18})}),s.jsxs("div",{className:"flex-1 min-w-0 relative flex items-center",children:[s.jsx("input",{ref:G,type:"text",value:c,onChange:Ee=>re(Ee.target.value),placeholder:Z?"Reply to message...":"iMessage",className:"w-full text-[13.5px] font-sans bg-white border border-gray-300 focus:border-[#007AFF] focus:ring-1 focus:ring-[#007AFF] rounded-full px-3.5 py-1.5 pr-8 outline-none text-gray-900 placeholder:text-gray-400 transition-all shadow-2xs"}),s.jsx("button",{type:"button",onClick:()=>re(c+" ❤️"),className:"absolute right-2 text-gray-400 hover:text-red-500 transition-colors p-0.5 cursor-pointer",children:s.jsx(mc,{size:14})})]}),s.jsx("button",{type:"submit",disabled:!c.trim()&&!y||f,className:"p-2 bg-[#007AFF] hover:bg-blue-600 active:scale-95 disabled:opacity-35 text-white rounded-full transition-all cursor-pointer shrink-0 shadow-xs flex items-center justify-center",title:"Send iMessage",children:f?s.jsx(Er,{size:15,className:"animate-spin"}):s.jsx(Eo,{size:14,className:"translate-x-0.2"})})]})]})}),F&&n&&s.jsx(Dee,{isOpen:!0,onClose:()=>$(null),peer:n,callType:F})]})},qMe=({isOpen:e,onClose:t,currentUserId:n,viewingUserId:r,initialTab:i,onUserProfileClick:a})=>{const[o,c]=I.useState(i),[h,f]=I.useState({}),[m,y]=I.useState([]),[w,A]=I.useState([]),[S,C]=I.useState(""),[T,D]=I.useState(!0),[V,L]=I.useState(null),[K,Z]=I.useState(null),[q,B]=I.useState(""),[z,F]=I.useState(!1);I.useEffect(()=>{const G=se=>{se.detail&&Z(se.detail)};return window.addEventListener("open-imessage-friend",G),()=>window.removeEventListener("open-imessage-friend",G)},[]);const $=r||n,Y=G=>o==="connections"?!0:w.some(se=>se.status==="accepted"&&(se.senderId===n&&(se.receiverId===G||se.targetUserId===G)||(se.senderId===G||se.receiverId===G)&&(se.receiverId===n||se.targetUserId===n))),X=async()=>{if(!(!V||!q.trim()||!n)){F(!0);try{const G=h[n],se=G?G.displayName:"A Campus Friend",xe=G?G.username:"member";await ur(et(he,"notifications"),{userId:V.uid,senderId:n,senderName:se,senderUsername:xe,senderPhotoURL:(G==null?void 0:G.photoURL)||"",title:`📩 Direct Inbox Message from ${se}`,message:q.trim(),type:"direct_message",canReply:!0,used:!1,createdAt:new Date}),ir.success(`Inbox message sent to @${V.username.toLowerCase()}!`,{icon:"✉️"}),L(null),B("")}catch(G){ir.error("Failed to send direct message: "+G.message)}finally{F(!1)}}};I.useEffect(()=>{e&&c(i)},[e,i]),I.useEffect(()=>{if(!e||!n)return;D(!0),(async()=>{try{const[se,xe,re]=await Promise.all([vn(et(he,"users")),vn(et(he,"follows")),vn(et(he,"invitations"))]),Me={};se.docs.forEach(Tt=>{const It=Tt.data();Me[Tt.id]={uid:Tt.id,displayName:It.displayName||"Campus Member",username:It.username||"member",photoURL:It.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(It.displayName||"U")}&background=random`,email:It.email,role:It.role}}),f(Me);const nt=xe.docs.map(Tt=>Tt.data());y(nt);const ze=re.docs.map(Tt=>Tt.data());A(ze)}catch(se){console.warn("Error fetching connections directory inside modal:",se)}finally{D(!1)}})()},[e,n]);const J=async(G,se)=>{if(!n||!G)return;const xe=`${n}_${G}`,re=m.some(Me=>Me.followerId===n&&Me.followedId===G);try{if(re){y(ze=>ze.filter(Tt=>!(Tt.followerId===n&&Tt.followedId===G))),await si(Je(he,"follows",xe));const Me=h[n],nt=Me?`@${(Me.displayName||"a peer").replace(/\s+/g,"").toLowerCase()}`:"A peer";try{const ze=`notif_unfollow_${n}_${G}`;await Rr(Je(he,"notifications",ze),{userId:G,title:"💔 Lounge Unfollow",message:`${nt} unfollowed you.`,type:"social",used:!0,createdAt:new Date})}catch(ze){console.warn("Failed to create unfollow notification:",ze)}}else{const Me={followerId:n,followedId:G,createdAt:new Date};y(Tt=>[...Tt,Me]),await Rr(Je(he,"follows",xe),{followerId:n,followedId:G,createdAt:new Date});const nt=h[n],ze=nt?`@${(nt.displayName||"a peer").replace(/\s+/g,"").toLowerCase()}`:"A peer";try{const Tt=`notif_follow_${n}_${G}`;await Rr(Je(he,"notifications",Tt),{userId:G,title:"👥 New Lounge Follower!",message:`${ze} is now following you. They will receive your latest dispatches!`,type:"social",createdAt:new Date})}catch(Tt){console.warn("Failed to create follow notification from modal:",Tt)}}}catch(Me){console.error("Error toggling follow inside modal modal:",Me)}},ye=()=>m.filter(se=>se.followedId===$).map(se=>se.followerId).map(se=>h[se]).filter(se=>!!se),ne=()=>m.filter(se=>se.followerId===$).map(se=>se.followedId).map(se=>h[se]).filter(se=>!!se),de=()=>{const G=w.filter(xe=>xe.status==="accepted"&&(xe.senderId===$||xe.receiverId===$)).map(xe=>xe.senderId===$?xe.receiverId:xe.senderId);return Array.from(new Set(G)).map(xe=>h[xe]).filter(xe=>!!xe)},Ce=(()=>{switch(o){case"followers":return ye();case"following":return ne();case"connections":return de()}})(),Ke=Ce.filter(G=>G.displayName.toLowerCase().includes(S.toLowerCase())||G.username.toLowerCase().includes(S.toLowerCase()));return s.jsxs(or,{children:[e&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx(Zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:t,className:"absolute inset-0 bg-black/60 backdrop-blur-xs"}),s.jsxs(Zt.div,{initial:{scale:.95,opacity:0,y:15},animate:{scale:1,opacity:1,y:0},exit:{scale:.95,opacity:0,y:15},transition:{type:"spring",damping:25,stiffness:350},className:"bg-white border border-gray-150 rounded-3xl w-full max-w-md h-[480px] flex flex-col overflow-hidden shadow-2xl relative z-10 select-none",id:"user-connections-dialog",children:[s.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_o,{size:16,className:"text-red-650"}),s.jsx("h3",{className:"text-xs font-black uppercase tracking-widest text-gray-950",children:"Campus Relations"})]}),s.jsx("button",{onClick:t,className:"w-7 h-7 text-gray-400 hover:text-gray-950 rounded-full hover:bg-gray-100 flex items-center justify-center transition-colors cursor-pointer",title:"Close Window",id:"close-connections-modal",children:s.jsx(er,{size:14,strokeWidth:2.5})})]}),s.jsx("div",{className:"grid grid-cols-3 border-b border-gray-100 bg-gray-50/50 p-1",children:["followers","following","connections"].map(G=>{const se=o===G,xe=G==="followers"?"Followers":G==="following"?"Following":"Lounge",re=G==="followers"?ye().length:G==="following"?ne().length:de().length;return s.jsxs("button",{onClick:()=>c(G),className:`py-2 text-[10px] font-extrabold uppercase tracking-widest rounded-xl transition-all cursor-pointer flex flex-col items-center justify-center gap-0.5 ${se?"bg-white text-red-650 shadow-xs border border-gray-150/45":"text-gray-400 hover:text-gray-700 hover:bg-white/40"}`,children:[s.jsx("span",{children:xe}),s.jsx("span",{className:`text-[8.5px] font-black font-mono ${se?"text-red-650":"text-gray-400"}`,children:re})]},G)})}),Ce.length>0&&s.jsx("div",{className:"px-4 pt-3 pb-1 border-b border-gray-100/30",children:s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",value:S,onChange:G=>C(G.target.value),placeholder:"Search connection directory...",className:"w-full text-[11px] placeholder-gray-400 font-bold font-sans bg-gray-50 border border-gray-100 px-8 py-2 rounded-xl focus:bg-white focus:border-red-650/45 outline-none transition-all"}),s.jsx(Rp,{size:11,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"})]})}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3.5 scrollbar-thin",children:T?s.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-2",children:[s.jsx(Er,{className:"animate-spin text-red-650",size:24}),s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Resolving user accounts..."})]}):Ke.length===0?s.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center space-y-2 p-6",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-gray-100 flex items-center justify-center text-gray-400",children:s.jsx(_o,{size:16})}),s.jsx("h4",{className:"text-[11px] font-black text-gray-900 uppercase tracking-wide",children:S?"No Matches Found":"No Directory Records"}),s.jsx("p",{className:"text-[9.5px] text-gray-400 leading-normal max-w-xs",children:S?"Refine your keyword to lookup active university profiles.":o==="followers"?"Register original columns or news reports to gather active campus followers!":o==="following"?"Follow varsity writers, reporters, or editors to customize your custom news stream.":"Connect in Lounge from posts to establish personal direct active debate capabilities."})]}):Ke.map(G=>{const se=m.some(Me=>Me.followerId===n&&Me.followedId===G.uid),xe=G.uid===n,re=Y(G.uid);return s.jsxs(Zt.div,{layout:!0,className:"flex items-center justify-between p-2 rounded-2xl hover:bg-gray-50/70 border border-transparent hover:border-gray-100/50 transition-all gap-2",children:[s.jsxs("div",{onClick:()=>{a&&(a(G.uid),t())},className:"flex items-center gap-2.5 min-w-0 flex-1 cursor-pointer group/item",children:[s.jsx("img",{src:G.photoURL,alt:"",className:"w-10 h-10 rounded-full object-cover border border-white shadow-xs group-hover/item:ring-2 group-hover/item:ring-red-650/40 transition-all shrink-0",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"text-left min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("h5",{className:"text-[11px] font-black text-gray-950 uppercase tracking-tight truncate group-hover/item:text-red-650 transition-colors",children:G.displayName}),re&&!xe&&s.jsxs("span",{className:"px-1.5 py-0.2 bg-emerald-50 text-emerald-700 border border-emerald-200 text-[7px] font-black uppercase rounded tracking-wider flex items-center gap-0.5",title:"Accepted Friend",children:[s.jsx(lc,{size:8})," Connected"]})]}),s.jsxs("p",{className:"text-[9px] text-gray-400 font-semibold truncate leading-none",children:["@",G.username.toLowerCase()]}),G.role&&s.jsx("span",{className:"inline-block mt-1 text-[7.5px] font-black tracking-widest px-1 py-0.2 rounded bg-gray-100 text-gray-500 uppercase",children:G.role==="admin"?"Editorial Board":"Reporter"})]})]}),!xe&&s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsxs("button",{onClick:Me=>{Me.stopPropagation(),Z(G)},className:"p-1.5 px-2 bg-blue-50 hover:bg-[#007AFF] text-[#007AFF] hover:text-white border border-blue-200/80 rounded-lg shadow-2xs transition-all cursor-pointer flex items-center gap-1 text-[8px] font-black uppercase tracking-wider shrink-0",title:`Message @${G.username.toLowerCase()}`,children:[s.jsx(bi,{size:11,strokeWidth:2.5}),s.jsx("span",{className:"hidden sm:inline",children:"Message"})]}),re&&s.jsxs("button",{onClick:Me=>{Me.stopPropagation(),L(G)},className:"p-1.5 px-2 bg-indigo-50 hover:bg-indigo-600 text-indigo-700 hover:text-white rounded-lg border border-indigo-200/80 transition-all cursor-pointer flex items-center gap-1 text-[8px] font-black uppercase tracking-wider shrink-0 shadow-2xs",title:`Send direct inbox alert to ${G.displayName}`,children:[s.jsx(ea,{size:11,strokeWidth:2.5}),s.jsx("span",{className:"hidden sm:inline",children:"Inbox"})]})]}),!xe&&s.jsx("button",{onClick:()=>J(G.uid,G.displayName),className:`text-[8.5px] h-7 px-2.5 rounded-lg font-black uppercase tracking-wider flex items-center gap-1 cursor-pointer transition-colors shrink-0 ${se?"bg-gray-100 text-gray-650 border border-gray-150 hover:bg-red-50 hover:text-red-650 hover:border-red-150":"bg-red-50 text-red-650 border border-red-150/40 hover:bg-red-650 hover:text-white"}`,children:se?s.jsxs(s.Fragment,{children:[s.jsx(ey,{size:9,strokeWidth:2.5}),s.jsx("span",{className:"hidden sm:inline",children:"Following"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Np,{size:9,strokeWidth:2.5}),s.jsx("span",{children:"Follow"})]})})]},G.uid)})}),s.jsx(or,{children:V&&s.jsx("div",{className:"absolute inset-0 z-50 bg-black/60 backdrop-blur-xs flex items-center justify-center p-4",children:s.jsxs(Zt.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"bg-white border border-gray-200 rounded-2xl p-4 w-full max-w-sm shadow-2xl text-left space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ea,{size:16,className:"text-indigo-600"}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-950",children:"Campus Direct Message"}),s.jsxs("p",{className:"text-[9px] text-gray-400 font-medium",children:["To connected friend @",V.username.toLowerCase()]})]})]}),s.jsx("button",{onClick:()=>L(null),className:"p-1 text-gray-400 hover:text-black rounded-lg hover:bg-gray-100 transition-all cursor-pointer",children:s.jsx(er,{size:14})})]}),s.jsxs("div",{className:"flex items-center gap-2.5 p-2 bg-indigo-50/50 rounded-xl border border-indigo-100/60",children:[s.jsx("img",{src:V.photoURL,alt:"",className:"w-8 h-8 rounded-full object-cover border border-indigo-200 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[10px] font-black uppercase text-gray-900 truncate",children:V.displayName}),s.jsx("p",{className:"text-[8px] text-indigo-700 font-bold uppercase tracking-wider",children:"Connected Friend"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black uppercase text-gray-500 tracking-wider block mb-1",children:"Your Message:"}),s.jsx("textarea",{value:q,onChange:G=>B(G.target.value),placeholder:`Write your inbox message for ${V.displayName}...`,rows:3,className:"w-full text-xs font-sans p-2.5 bg-gray-50 border border-gray-200 rounded-xl outline-none focus:bg-white focus:border-indigo-600 transition-all resize-none"})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2 pt-1",children:[s.jsx("button",{onClick:()=>L(null),className:"px-3 py-1.5 text-[9.5px] font-bold text-gray-600 hover:text-black bg-gray-100 hover:bg-gray-200 rounded-xl transition-all cursor-pointer",children:"Cancel"}),s.jsxs("button",{onClick:X,disabled:z||!q.trim(),className:"px-4 py-1.5 text-[9.5px] font-black uppercase tracking-wider bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 text-white rounded-xl transition-all flex items-center gap-1.5 shadow-xs cursor-pointer",children:[z?s.jsx(Er,{size:12,className:"animate-spin"}):s.jsx(Eo,{size:12}),s.jsx("span",{children:"Send Message"})]})]})]})})})]})]}),s.jsx(Mee,{isOpen:!!K,onClose:()=>Z(null),friend:K,currentUserId:n,currentUserProfile:h[n]||null})]})},WMe=({isOpen:e,onClose:t,userId:n,currentUserId:r})=>{const[i,a]=I.useState(!0),[o,c]=I.useState(null),[h,f]=I.useState(null),[m,y]=I.useState(!1);I.useEffect(()=>{if(!e||!n)return;a(!0),(async()=>{try{const C=Je(he,"users",n),T=await cs(C);let D={id:n,displayName:"Campus Citizen",email:""};T.exists()&&(D={id:n,...T.data()}),c(D);const[V,L,K,Z,q]=await Promise.all([vn(Qt(et(he,"articles"),Ar("authorId","==",n))),vn(Qt(et(he,"posts"),Ar("userId","==",n))),vn(Qt(et(he,"purchases"),Ar("userId","==",n))),vn(Qt(et(he,"follows"),Ar("followedId","==",n))),vn(Qt(et(he,"follows"),Ar("followerId","==",n)))]),B=V.size,z=L.size,F=K.size,$=Z.size,Y=q.size;let X=0;K.docs.forEach(de=>{const be=de.data();X+=(Number(be.amount)||Number(be.ticketPrice)||0)*(Number(be.quantity)||1)});const J=B*25+z*8+F*15+$*5;let ye="Campus Scholar",ne="text-blue-400";if(J>=100?(ye="Editorial Titan",ne="text-purple-400"):J>=50?(ye="Senior Dispatcher",ne="text-amber-400"):J>=20&&(ye="Active Reporter",ne="text-emerald-400"),f({userId:n,userName:D.displayName||"Campus Citizen",userEmail:D.email||"",userPhoto:D.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(D.displayName||"U")}&background=random`,engagementScore:J,articlesCount:B,postsCount:z,purchasesCount:F,totalSpent:X,followersCount:$,followingCount:Y,tier:ye,tierColor:ne}),r&&r!==n){const de=`${r}_${n}`,be=await cs(Je(he,"follows",de));y(be.exists())}}catch(C){console.error("Error fetching user profile stats:",C)}finally{a(!1)}})()},[e,n,r]);const w=async()=>{if(!r||!n)return;const S=`${r}_${n}`;try{m?(y(!1),await si(Je(he,"follows",S)),pe.success(`Unfollowed @${((o==null?void 0:o.displayName)||"citizen").toLowerCase().replace(/\s+/g,"")}`)):(y(!0),await Rr(Je(he,"follows",S),{followerId:r,followedId:n,createdAt:new Date}),pe.success(`Now following @${((o==null?void 0:o.displayName)||"citizen").toLowerCase().replace(/\s+/g,"")}!`))}catch(C){console.error(C),pe.error("Failed to update follow status")}},A=()=>{if(!r){pe.error("Please sign in to send a private message.",{id:"login-to-dm"});return}const S=(o==null?void 0:o.displayName)||(h==null?void 0:h.userName)||"Campus Citizen",C=((o==null?void 0:o.username)||S).toLowerCase().replace(/\s+/g,""),T=(o==null?void 0:o.photoURL)||(h==null?void 0:h.userPhoto)||"";window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:{uid:n,displayName:S,username:C,photoURL:T}})),pe.success(`Opening private chat with @${C}`,{icon:"💬"}),t()};return!e||!n?null:s.jsx(or,{children:s.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4",children:[s.jsx(Zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:t,className:"absolute inset-0 bg-black/75 backdrop-blur-sm"}),s.jsxs(Zt.div,{initial:{scale:.95,opacity:0,y:15},animate:{scale:1,opacity:1,y:0},exit:{scale:.95,opacity:0,y:15},transition:{type:"spring",damping:25,stiffness:350},className:"bg-white border border-gray-150 rounded-3xl w-full max-w-lg max-h-[90vh] flex flex-col overflow-hidden shadow-2xl relative z-10 select-none",children:[s.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/50",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(wp,{size:16,className:"text-red-650"}),s.jsx("h3",{className:"text-xs font-black uppercase tracking-widest text-gray-950",children:"Citizen Engagement Profile"})]}),s.jsx("button",{onClick:t,className:"w-7 h-7 text-gray-400 hover:text-gray-950 rounded-full hover:bg-gray-100 flex items-center justify-center transition-colors cursor-pointer",children:s.jsx(er,{size:14,strokeWidth:2.5})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-5 space-y-5 scrollbar-thin",children:i?s.jsxs("div",{className:"py-16 flex flex-col items-center justify-center gap-2",children:[s.jsx(Er,{className:"animate-spin text-red-650",size:28}),s.jsx("span",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Calculating live citizen analytics & graphs..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"bg-gradient-to-r from-gray-900 to-black text-white p-5 rounded-3xl flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 border border-gray-800 shadow-lg",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("img",{src:(o==null?void 0:o.photoURL)||`https://ui-avatars.com/api/?name=${encodeURIComponent((o==null?void 0:o.displayName)||"User")}&background=random`,alt:"",className:"w-16 h-16 rounded-2xl object-cover border-2 border-white/20 shadow-md",referrerPolicy:"no-referrer"}),((o==null?void 0:o.isAdmin)||(o==null?void 0:o.role)==="admin")&&s.jsx("div",{className:"absolute -top-1.5 -right-1.5 bg-accent text-white p-1 rounded-lg shadow-md",children:s.jsx(pl,{size:12})})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("h4",{className:"font-extrabold text-base text-white uppercase tracking-tight truncate",children:(o==null?void 0:o.displayName)||"Campus Citizen"}),((o==null?void 0:o.isVerified)||(o==null?void 0:o.isPremium)||(o==null?void 0:o.blueCheck)||(o==null?void 0:o.isPremiumPostUser))&&s.jsx(Fo,{size:16})]}),s.jsxs("p",{className:"text-[10px] text-gray-400 uppercase font-bold tracking-widest truncate",children:["@",((o==null?void 0:o.username)||(o==null?void 0:o.displayName)||"member").toLowerCase().replace(/\s+/g,"")]}),s.jsx("div",{className:"mt-1.5 flex items-center gap-2",children:s.jsx("span",{className:"px-2 py-0.5 bg-white/10 rounded text-[8px] font-black uppercase tracking-wider text-gray-300",children:o!=null&&o.isAdmin||(o==null?void 0:o.role)==="admin"?"Editorial Board":"Citizen Reporter"})})]})]}),r&&r!==n&&s.jsxs("div",{className:"flex items-center gap-2 shrink-0 flex-wrap sm:flex-nowrap",children:[s.jsx("button",{onClick:w,className:`px-3.5 py-2 rounded-xl text-[10px] font-black uppercase tracking-widest flex items-center gap-1.5 cursor-pointer transition-all ${m?"bg-white/10 text-white border border-white/20 hover:bg-red-600/80 hover:border-red-600":"bg-red-650 text-white hover:bg-red-700 shadow-lg shadow-red-650/30"}`,children:m?s.jsxs(s.Fragment,{children:[s.jsx(ey,{size:13}),s.jsx("span",{children:"Following"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Np,{size:13}),s.jsx("span",{children:"Follow"})]})}),s.jsxs("button",{onClick:A,className:"px-3.5 py-2 rounded-xl text-[10px] font-black uppercase tracking-widest flex items-center gap-1.5 cursor-pointer transition-all bg-[#007AFF] hover:bg-blue-600 text-white shadow-lg shadow-blue-500/30 active:scale-95",title:"Send Private Message",children:[s.jsx(bi,{size:13}),s.jsx("span",{children:"Message"})]})]})]}),h&&s.jsx(Oee,{stats:h})]})})]})]})})},KMe=()=>{const[e,t]=I.useState(navigator.onLine),[n,r]=I.useState(!navigator.onLine),[i,a]=I.useState(navigator.onLine?"online":"offline");return I.useEffect(()=>{let o;const c=()=>{t(!0),a("online"),r(!0),o=setTimeout(()=>{r(!1)},3500)},h=()=>{t(!1),a("offline"),r(!0)};return window.addEventListener("online",c),window.addEventListener("offline",h),navigator.onLine||(r(!0),a("offline")),()=>{window.removeEventListener("online",c),window.removeEventListener("offline",h),o&&clearTimeout(o)}},[]),s.jsx(or,{children:n&&s.jsx("div",{className:"fixed top-2.5 sm:top-3 left-1/2 -translate-x-1/2 z-[10000] pointer-events-none select-none font-sans",children:s.jsxs(Zt.div,{initial:{y:-50,scale:.6,opacity:0},animate:{y:0,scale:1,opacity:1},exit:{y:-50,scale:.6,opacity:0},transition:{type:"spring",damping:25,stiffness:380},className:`pointer-events-auto flex items-center gap-2 px-3 py-1 sm:py-1.5 rounded-full border shadow-lg backdrop-blur-xl transition-all ${i==="online"?"bg-black/95 border-emerald-500/30 text-white":"bg-black/95 border-red-500/30 text-white"}`,children:[s.jsx("div",{className:"flex items-center justify-center shrink-0",children:s.jsx("span",{className:`w-2 h-2 rounded-full ${i==="online"?"bg-emerald-500":"bg-red-500"}`})}),s.jsx("div",{className:"shrink-0",children:i==="online"?s.jsx(Xie,{size:12,className:"text-emerald-400"}):s.jsx(Kie,{size:12,className:"text-red-400"})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:`text-[9px] font-black uppercase tracking-widest font-mono ${i==="online"?"text-emerald-400":"text-red-400"}`,children:i==="online"?"Online":"Offline"}),s.jsx("span",{className:"text-[8.5px] text-gray-300 font-bold uppercase tracking-wider hidden sm:inline-block",children:i==="online"?"Connected":"No Network"})]}),i==="online"&&s.jsx("button",{onClick:()=>r(!1),className:"ml-0.5 text-gray-400 hover:text-white text-[8px] font-bold px-1 py-0.2 rounded-full hover:bg-white/10 transition-colors cursor-pointer",title:"Dismiss",children:"✕"})]})})})},YMe=()=>{const e=Ne.currentUser,[t,n]=I.useState(null),[r,i]=I.useState(null);I.useEffect(()=>{if(!e){n(null);return}const c=Qt(et(he,"calls"),Ar("receiverId","==",e.uid),Ar("status","==","ringing")),h=Wr(c,f=>{if(f.empty)n(null);else{const m=f.docs[0],y={id:m.id,...m.data()};n(y),yye()}});return()=>h()},[e]);const a=()=>{t&&(i({peer:{uid:t.callerId,displayName:t.callerName,username:(t.callerName||"peer").toLowerCase().replace(/\s+/g,""),photoURL:t.callerPhoto},callType:t.type||"audio",existingCallId:t.id}),n(null))},o=async()=>{if(t){try{await Cn(Je(he,"calls",t.id),{status:"rejected"})}catch{}n(null)}};return s.jsxs(s.Fragment,{children:[s.jsx(or,{children:t&&s.jsx("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-50 w-full max-w-sm px-3 pointer-events-auto",children:s.jsxs(Zt.div,{initial:{opacity:0,y:-40,scale:.9},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-40,scale:.9},className:"bg-neutral-900/95 text-white border border-neutral-700/80 rounded-2xl p-3.5 shadow-2xl backdrop-blur-xl flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("img",{src:t.callerPhoto||`https://api.dicebear.com/7.x/bottts/svg?seed=${t.callerName}`,alt:"",className:"w-11 h-11 rounded-full object-cover border-2 border-emerald-500 shadow-md"}),s.jsx("span",{className:"absolute -inset-1 rounded-full border border-emerald-400 animate-ping opacity-60"})]}),s.jsxs("div",{className:"min-w-0 text-left",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("h4",{className:"text-sm font-black text-white truncate",children:t.callerName}),s.jsx("span",{className:"px-1.5 py-0.2 bg-emerald-500/20 text-emerald-400 border border-emerald-500/30 text-[8px] font-black uppercase rounded-full shrink-0",children:"Ringing"})]}),s.jsxs("p",{className:"text-[10px] text-neutral-300 font-medium truncate flex items-center gap-1",children:[t.type==="video"?s.jsx(Ea,{size:10,className:"text-blue-400"}):s.jsx(zS,{size:10,className:"text-emerald-400"}),s.jsxs("span",{children:["Incoming ",t.type==="video"?"FaceTime Video":"Audio"," Call"]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("button",{onClick:o,className:"p-2.5 bg-red-600 hover:bg-red-700 text-white rounded-full transition-all cursor-pointer shadow-md active:scale-90",title:"Decline Call",children:s.jsx(cF,{size:16})}),s.jsx("button",{onClick:a,className:"p-2.5 bg-emerald-500 hover:bg-emerald-600 text-white rounded-full transition-all cursor-pointer shadow-md active:scale-90 animate-bounce",title:"Accept Call",children:s.jsx(zS,{size:16})})]})]})})}),r&&s.jsx(Dee,{isOpen:!0,onClose:()=>i(null),peer:r.peer,callType:r.callType,isIncoming:!0,existingCallId:r.existingCallId})]})},XMe=({page:e,onClose:t})=>{const n=f=>{if(!f)return"";let m=f.trim();return/^https?:\/\//i.test(m)||(m="https://"+m),m},r=f=>{if(!f)return"";try{const m=f.trim();if(m.includes("youtube.com/watch")){const y=/[?&]v=([^&#]*)/,w=m.match(y);if(w&&w[1])return`https://www.youtube.com/embed/${w[1]}?autoplay=1&mute=0&rel=0`}else if(m.includes("youtu.be/")){const y=m.split("youtu.be/");if(y[1])return`https://www.youtube.com/embed/${y[1].split(/[?#&]/)[0]}?autoplay=1&mute=0&rel=0`}else if(m.includes("youtube.com/live/")){const y=m.split("youtube.com/live/");if(y[1])return`https://www.youtube.com/embed/${y[1].split(/[?#&]/)[0]}?autoplay=1&mute=0&rel=0`}else if(m.includes("/shorts/")){const y=m.split("/shorts/");if(y[1])return`https://www.youtube.com/embed/${y[1].split(/[?#&]/)[0]}?autoplay=1&mute=0&rel=0`}else{if(m.includes("youtube.com/embed/"))return m;if(m.includes("youtube-nocookie.com/embed/"))return m}return m}catch{return f}},i=n(e.url),a=r(i),[o,c]=ie.useState(0),h=()=>{c(f=>f+1)};return s.jsxs("div",{className:"fixed inset-0 z-[10000] flex flex-col bg-zinc-950 overflow-hidden select-none",id:"custom-media-theater-root",children:[s.jsxs("div",{className:"bg-zinc-900 border-b border-zinc-800 px-4 py-3 flex items-center justify-between text-white shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-red-600 shrink-0"}),s.jsx("div",{className:"truncate",children:s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-white",children:e.name||"Live Channel"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:h,className:"p-2 rounded-lg bg-zinc-800 hover:bg-zinc-700 text-zinc-300 transition-colors cursor-pointer flex items-center justify-center",title:"Reload Frame",children:s.jsx(uF,{size:14})}),s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg bg-zinc-800 hover:bg-zinc-700 text-zinc-300 transition-colors flex items-center justify-center",title:"Open in native browser tab",children:s.jsx($a,{size:14})}),s.jsx("button",{onClick:t,className:"p-2 rounded-lg bg-red-600 hover:bg-red-700 text-white cursor-pointer flex items-center justify-center transition-all duration-200",title:"Close Channels",children:s.jsx(er,{size:14,strokeWidth:2.5})})]})]}),s.jsx("div",{className:"flex-1 bg-black relative",children:s.jsx("iframe",{src:a||void 0,className:"w-full h-full border-0 block bg-black",title:e.name,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; camera; microphone; geolocation",allowFullScreen:!0,referrerPolicy:"strict-origin-when-cross-origin"},o)})]})};var In;(function(e){e[e.QR_CODE=0]="QR_CODE",e[e.AZTEC=1]="AZTEC",e[e.CODABAR=2]="CODABAR",e[e.CODE_39=3]="CODE_39",e[e.CODE_93=4]="CODE_93",e[e.CODE_128=5]="CODE_128",e[e.DATA_MATRIX=6]="DATA_MATRIX",e[e.MAXICODE=7]="MAXICODE",e[e.ITF=8]="ITF",e[e.EAN_13=9]="EAN_13",e[e.EAN_8=10]="EAN_8",e[e.PDF_417=11]="PDF_417",e[e.RSS_14=12]="RSS_14",e[e.RSS_EXPANDED=13]="RSS_EXPANDED",e[e.UPC_A=14]="UPC_A",e[e.UPC_E=15]="UPC_E",e[e.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(In||(In={}));var LV=new Map([[In.QR_CODE,"QR_CODE"],[In.AZTEC,"AZTEC"],[In.CODABAR,"CODABAR"],[In.CODE_39,"CODE_39"],[In.CODE_93,"CODE_93"],[In.CODE_128,"CODE_128"],[In.DATA_MATRIX,"DATA_MATRIX"],[In.MAXICODE,"MAXICODE"],[In.ITF,"ITF"],[In.EAN_13,"EAN_13"],[In.EAN_8,"EAN_8"],[In.PDF_417,"PDF_417"],[In.RSS_14,"RSS_14"],[In.RSS_EXPANDED,"RSS_EXPANDED"],[In.UPC_A,"UPC_A"],[In.UPC_E,"UPC_E"],[In.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),UV;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.URL=1]="URL"})(UV||(UV={}));function QMe(e){return Object.values(In).includes(e)}var XN;(function(e){e[e.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",e[e.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(XN||(XN={}));var ZMe=(function(){function e(){}return e.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",e.SCAN_DEFAULT_FPS=2,e.DEFAULT_DISABLE_FLIP=!1,e.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,e.DEFAULT_SUPPORTED_SCAN_TYPE=[XN.SCAN_TYPE_CAMERA,XN.SCAN_TYPE_FILE],e})(),Lee=(function(){function e(t,n){this.format=t,this.formatName=n}return e.prototype.toString=function(){return this.formatName},e.create=function(t){if(!LV.has(t))throw"".concat(t," not in html5QrcodeSupportedFormatsTextMap");return new e(t,LV.get(t))},e})(),BV=(function(){function e(){}return e.createFromText=function(t){var n={text:t};return{decodedText:t,result:n}},e.createFromQrcodeResult=function(t){return{decodedText:t.text,result:t}},e})(),xI;(function(e){e[e.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",e[e.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",e[e.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(xI||(xI={}));var JMe=(function(){function e(){}return e.createFrom=function(t){return{errorMessage:t,type:xI.UNKWOWN_ERROR}},e})(),e9e=(function(){function e(t){this.verbose=t}return e.prototype.log=function(t){this.verbose&&console.log(t)},e.prototype.warn=function(t){this.verbose&&console.warn(t)},e.prototype.logError=function(t,n){(this.verbose||n===!0)&&console.error(t)},e.prototype.logErrors=function(t){if(t.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(t)},e})();function _d(e){return typeof e>"u"||e===null}var H0=(function(){function e(){}return e.codeParseError=function(t){return"QR code parse error, error = ".concat(t)},e.errorGettingUserMedia=function(t){return"Error getting userMedia, error = ".concat(t)},e.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},e.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},e.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},e.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},e.scannerPaused=function(){return"Scanner paused"},e})(),Uee=(function(){function e(){}return e.isMediaStreamConstraintsValid=function(t,n){if(typeof t!="object"){var r=typeof t;return n.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(r,"."),!0),!1}for(var i=["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"],a=new Set(i),o=Object.keys(t),c=0,h=o;cg)throw new y("fromIndex("+p+") > toIndex("+g+")");if(p<0)throw new D(p);if(g>u)throw new D(g)}static asList(...u){return u}static create(u,p,g){return Array.from({length:u}).map(v=>Array.from({length:p}).fill(g))}static createInt32Array(u,p,g){return Array.from({length:u}).map(v=>Int32Array.from({length:p}).fill(g))}static equals(u,p){if(!u||!p||!u.length||!p.length||u.length!==p.length)return!1;for(let g=0,b=u.length;g>1,k=g(p,u[E]);if(k>0)b=E+1;else if(k<0)v=E-1;else return E}return-b-1}static numberComparator(u,p){return u-p}}class L{static numberOfTrailingZeros(u){let p;if(u===0)return 32;let g=31;return p=u<<16,p!==0&&(g-=16,u=p),p=u<<8,p!==0&&(g-=8,u=p),p=u<<4,p!==0&&(g-=4,u=p),p=u<<2,p!==0&&(g-=2,u=p),g-(u<<1>>>31)}static numberOfLeadingZeros(u){if(u===0)return 32;let p=1;return u>>>16||(p+=16,u<<=16),u>>>24||(p+=8,u<<=8),u>>>28||(p+=4,u<<=4),u>>>30||(p+=2,u<<=2),p-=u>>>31,p}static toHexString(u){return u.toString(16)}static toBinaryString(u){return String(parseInt(String(u),2))}static bitCount(u){return u=u-(u>>>1&1431655765),u=(u&858993459)+(u>>>2&858993459),u=u+(u>>>4)&252645135,u=u+(u>>>8),u=u+(u>>>16),u&63}static truncDivision(u,p){return Math.trunc(u/p)}static parseInt(u,p=void 0){return parseInt(u,p)}}L.MIN_VALUE_32_BITS=-2147483648,L.MAX_VALUE=Number.MAX_SAFE_INTEGER;class K{constructor(u,p){u===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=u,p==null?this.bits=K.makeArray(u):this.bits=p)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(u){if(u>this.bits.length*32){const p=K.makeArray(u);C.arraycopy(this.bits,0,p,0,this.bits.length),this.bits=p}}get(u){return(this.bits[Math.floor(u/32)]&1<<(u&31))!==0}set(u){this.bits[Math.floor(u/32)]|=1<<(u&31)}flip(u){this.bits[Math.floor(u/32)]^=1<<(u&31)}getNextSet(u){const p=this.size;if(u>=p)return p;const g=this.bits;let b=Math.floor(u/32),v=g[b];v&=~((1<<(u&31))-1);const E=g.length;for(;v===0;){if(++b===E)return p;v=g[b]}const k=b*32+L.numberOfTrailingZeros(v);return k>p?p:k}getNextUnset(u){const p=this.size;if(u>=p)return p;const g=this.bits;let b=Math.floor(u/32),v=~g[b];v&=~((1<<(u&31))-1);const E=g.length;for(;v===0;){if(++b===E)return p;v=~g[b]}const k=b*32+L.numberOfTrailingZeros(v);return k>p?p:k}setBulk(u,p){this.bits[Math.floor(u/32)]=p}setRange(u,p){if(pthis.size)throw new y;if(p===u)return;p--;const g=Math.floor(u/32),b=Math.floor(p/32),v=this.bits;for(let E=g;E<=b;E++){const k=E>g?0:u&31,M=(2<<(Ethis.size)throw new y;if(p===u)return!0;p--;const b=Math.floor(u/32),v=Math.floor(p/32),E=this.bits;for(let k=b;k<=v;k++){const P=k>b?0:u&31,W=(2<<(k32)throw new y("Num bits must be between 0 and 32");this.ensureCapacity(this.size+p);for(let g=p;g>0;g--)this.appendBit((u>>g-1&1)===1)}appendBitArray(u){const p=u.size;this.ensureCapacity(this.size+p);for(let g=0;g>1&1431655765|(E&1431655765)<<1,E=E>>2&858993459|(E&858993459)<<2,E=E>>4&252645135|(E&252645135)<<4,E=E>>8&16711935|(E&16711935)<<8,E=E>>16&65535|(E&65535)<<16,u[p-v]=E}if(this.size!==g*32){const v=g*32-this.size;let E=u[0]>>>v;for(let k=1;k>>v}u[g-1]=E}this.bits=u}static makeArray(u){return new Int32Array(Math.floor((u+31)/32))}equals(u){if(!(u instanceof K))return!1;const p=u;return this.size===p.size&&V.equals(this.bits,p.bits)}hashCode(){return 31*this.size+V.hashCode(this.bits)}toString(){let u="";for(let p=0,g=this.size;p=900)throw new B("incorect value");const p=F.VALUES_TO_ECI.get(u);if(p===void 0)throw new B("incorect value");return p}static getCharacterSetECIByName(u){const p=F.NAME_TO_ECI.get(u);if(p===void 0)throw new B("incorect value");return p}equals(u){if(!(u instanceof F))return!1;const p=u;return this.getName()===p.getName()}}F.VALUE_IDENTIFIER_TO_ECI=new Map,F.VALUES_TO_ECI=new Map,F.NAME_TO_ECI=new Map,F.Cp437=new F(z.Cp437,Int32Array.from([0,2]),"Cp437"),F.ISO8859_1=new F(z.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),F.ISO8859_2=new F(z.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),F.ISO8859_3=new F(z.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),F.ISO8859_4=new F(z.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),F.ISO8859_5=new F(z.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),F.ISO8859_6=new F(z.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),F.ISO8859_7=new F(z.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),F.ISO8859_8=new F(z.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),F.ISO8859_9=new F(z.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),F.ISO8859_10=new F(z.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),F.ISO8859_11=new F(z.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),F.ISO8859_13=new F(z.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),F.ISO8859_14=new F(z.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),F.ISO8859_15=new F(z.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),F.ISO8859_16=new F(z.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),F.SJIS=new F(z.SJIS,20,"SJIS","Shift_JIS"),F.Cp1250=new F(z.Cp1250,21,"Cp1250","windows-1250"),F.Cp1251=new F(z.Cp1251,22,"Cp1251","windows-1251"),F.Cp1252=new F(z.Cp1252,23,"Cp1252","windows-1252"),F.Cp1256=new F(z.Cp1256,24,"Cp1256","windows-1256"),F.UnicodeBigUnmarked=new F(z.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),F.UTF8=new F(z.UTF8,26,"UTF8","UTF-8"),F.ASCII=new F(z.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),F.Big5=new F(z.Big5,28,"Big5"),F.GB18030=new F(z.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),F.EUC_KR=new F(z.EUC_KR,30,"EUC_KR","EUC-KR");class $ extends f{}$.kind="UnsupportedOperationException";class Y{static decode(u,p){const g=this.encodingName(p);return this.customDecoder?this.customDecoder(u,g):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(g)?this.decodeFallback(u,g):new TextDecoder(g).decode(u)}static shouldDecodeOnFallback(u){return!Y.isBrowser()&&u==="ISO-8859-1"}static encode(u,p){const g=this.encodingName(p);return this.customEncoder?this.customEncoder(u,g):typeof TextEncoder>"u"?this.encodeFallback(u):new TextEncoder().encode(u)}static isBrowser(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"}static encodingName(u){return typeof u=="string"?u:u.getName()}static encodingCharacterSet(u){return u instanceof F?u:F.getCharacterSetECIByName(u)}static decodeFallback(u,p){const g=this.encodingCharacterSet(p);if(Y.isDecodeFallbackSupported(g)){let b="";for(let v=0,E=u.length;v3&&u[0]===239&&u[1]===187&&u[2]===191;for(let Wt=0;Wt0?(zt&128)===0?E=!1:k--:(zt&128)!==0&&((zt&64)===0?E=!1:(k++,(zt&32)===0?P++:(k++,(zt&16)===0?M++:(k++,(zt&8)===0?W++:E=!1))))),b&&(zt>127&&zt<160?b=!1:zt>159&&(zt<192||zt===215||zt===247)&&ht++),v&&(te>0?zt<64||zt===127||zt>252?v=!1:te--:zt===128||zt===160||zt>239?v=!1:zt>160&&zt<224?(ae++,ke=0,ve++,ve>Ie&&(Ie=ve)):zt>127?(te++,ve=0,ke++,ke>We&&(We=ke)):(ve=0,ke=0))}return E&&k>0&&(E=!1),v&&te>0&&(v=!1),E&&(Yt||P+M+W>0)?X.UTF8:v&&(X.ASSUME_SHIFT_JIS||Ie>=3||We>=3)?X.SHIFT_JIS:b&&v?Ie===2&&ae===2||ht*10>=g?X.SHIFT_JIS:X.ISO88591:b?X.ISO88591:v?X.SHIFT_JIS:E?X.UTF8:X.PLATFORM_DEFAULT_ENCODING}static format(u,...p){let g=-1;function b(E,k,P,M,W,te){if(E==="%%")return"%";if(p[++g]===void 0)return;E=M?parseInt(M.substr(1)):void 0;let ae=W?parseInt(W.substr(1)):void 0,ve;switch(te){case"s":ve=p[g];break;case"c":ve=p[g][0];break;case"f":ve=parseFloat(p[g]).toFixed(E);break;case"p":ve=parseFloat(p[g]).toPrecision(E);break;case"e":ve=parseFloat(p[g]).toExponential(E);break;case"x":ve=parseInt(p[g]).toString(ae||16);break;case"d":ve=parseFloat(parseInt(p[g],ae||10).toPrecision(E)).toFixed(0);break}ve=typeof ve=="object"?JSON.stringify(ve):(+ve).toString(ae);let ke=parseInt(P),Ie=P&&P[0]+""=="0"?"0":" ";for(;ve.lengthE){if(k===-1)k=v-E;else if(v-E!==k)throw new y("row lengths do not match");E=v,P++}M++}else if(u.substring(M,M+p.length)===p)M+=p.length,b[v]=!0,v++;else if(u.substring(M,M+g.length)===g)M+=g.length,b[v]=!1,v++;else throw new y("illegal character encountered: "+u.substring(M));if(v>E){if(k===-1)k=v-E;else if(v-E!==k)throw new y("row lengths do not match");P++}const W=new ye(k,P);for(let te=0;te>>(u&31)&1)!==0}set(u,p){const g=p*this.rowSize+Math.floor(u/32);this.bits[g]|=1<<(u&31)&4294967295}unset(u,p){const g=p*this.rowSize+Math.floor(u/32);this.bits[g]&=~(1<<(u&31)&4294967295)}flip(u,p){const g=p*this.rowSize+Math.floor(u/32);this.bits[g]^=1<<(u&31)&4294967295}xor(u){if(this.width!==u.getWidth()||this.height!==u.getHeight()||this.rowSize!==u.getRowSize())throw new y("input matrix dimensions do not match");const p=new K(Math.floor(this.width/32)+1),g=this.rowSize,b=this.bits;for(let v=0,E=this.height;vthis.height||v>this.width)throw new y("The region must fit inside the matrix");const k=this.rowSize,P=this.bits;for(let M=p;MP&&(P=M),W*32k){let ae=31;for(;!(te>>>ae);)ae--;W*32+ae>k&&(k=W*32+ae)}}}return k=0&&p[g]===0;)g--;if(g<0)return null;const b=Math.floor(g/u);let v=Math.floor(g%u)*32;const E=p[g];let k=31;for(;!(E>>>k);)k--;return v+=k,Int32Array.from([v,b])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(u){if(!(u instanceof ye))return!1;const p=u;return this.width===p.width&&this.height===p.height&&this.rowSize===p.rowSize&&V.equals(this.bits,p.bits)}hashCode(){let u=this.width;return u=31*u+this.width,u=31*u+this.height,u=31*u+this.rowSize,u=31*u+V.hashCode(this.bits),u}toString(u="X ",p=" ",g=` `){return this.buildToString(u,p,g)}buildToString(u,p,g){let b=new J;for(let v=0,E=this.height;v>de.LUMINANCE_SHIFT]++;const k=de.estimateBlackPoint(E);if(b<3)for(let P=0;P>de.LUMINANCE_SHIFT]++}}const E=de.estimateBlackPoint(v),k=u.getMatrix();for(let P=0;Pv&&(b=W,v=u[W]),u[W]>g&&(g=u[W]);let E=0,k=0;for(let W=0;Wk&&(E=W,k=ae)}if(b>E){const W=b;b=E,E=W}if(E-b<=p/16)throw new ne;let P=E-1,M=-1;for(let W=E-1;W>b;W--){const te=W-b,ae=te*te*(E-W)*(g-u[W]);ae>M&&(P=W,M=ae)}return P<=be.MINIMUM_DIMENSION&&g>=be.MINIMUM_DIMENSION){const b=u.getMatrix();let v=p>>be.BLOCK_SIZE_POWER;(p&be.BLOCK_SIZE_MASK)!==0&&v++;let E=g>>be.BLOCK_SIZE_POWER;(g&be.BLOCK_SIZE_MASK)!==0&&E++;const k=be.calculateBlackPoints(b,v,E,p,g),P=new ye(p,g);be.calculateThresholdForBlock(b,v,E,p,g,k,P),this.matrix=P}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(u){return new be(u)}static calculateThresholdForBlock(u,p,g,b,v,E,k){const P=v-be.BLOCK_SIZE,M=b-be.BLOCK_SIZE;for(let W=0;WP&&(te=P);const ae=be.cap(W,2,g-3);for(let ve=0;veM&&(ke=M);const Ie=be.cap(ve,2,p-3);let We=0;for(let Yt=-2;Yt<=2;Yt++){const Wt=E[ae+Yt];We+=Wt[Ie-2]+Wt[Ie-1]+Wt[Ie]+Wt[Ie+1]+Wt[Ie+2]}const ht=We/25;be.thresholdBlock(u,ke,te,ht,b,k)}}}static cap(u,p,g){return ug?g:u}static thresholdBlock(u,p,g,b,v,E){for(let k=0,P=g*v+p;kE&&(W=E);for(let te=0;tek&&(ae=k);let ve=0,ke=255,Ie=0;for(let ht=0,Yt=W*b+ae;htIe&&(Ie=zt)}if(Ie-ke>be.MIN_DYNAMIC_RANGE)for(ht++,Yt+=b;ht>be.BLOCK_SIZE_POWER*2;if(Ie-ke<=be.MIN_DYNAMIC_RANGE&&(We=ke/2,M>0&&te>0)){const ht=(P[M-1][te]+2*P[M][te-1]+P[M-1][te-1])/4;ke>10}b[E]=P}return b}getRow(u,p){if(u<0||u>=this.getHeight())throw new y("Requested row is outside the image: "+u);const g=this.getWidth(),b=u*g;return p===null?p=this.buffer.slice(b,b+g):(p.lengthnew se(p.deviceId,p.label))})}findDeviceById(u){return xe(this,void 0,void 0,function*(){const p=yield this.listVideoInputDevices();return p?p.find(g=>g.deviceId===u):null})}decodeFromInputVideoDevice(u,p){return xe(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(u,p)})}decodeOnceFromVideoDevice(u,p){return xe(this,void 0,void 0,function*(){this.reset();let g;u?g={deviceId:{exact:u}}:g={facingMode:"environment"};const b={video:g};return yield this.decodeOnceFromConstraints(b,p)})}decodeOnceFromConstraints(u,p){return xe(this,void 0,void 0,function*(){const g=yield navigator.mediaDevices.getUserMedia(u);return yield this.decodeOnceFromStream(g,p)})}decodeOnceFromStream(u,p){return xe(this,void 0,void 0,function*(){this.reset();const g=yield this.attachStreamToVideo(u,p);return yield this.decodeOnce(g)})}decodeFromInputVideoDeviceContinuously(u,p,g){return xe(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(u,p,g)})}decodeFromVideoDevice(u,p,g){return xe(this,void 0,void 0,function*(){let b;u?b={deviceId:{exact:u}}:b={facingMode:"environment"};const v={video:b};return yield this.decodeFromConstraints(v,p,g)})}decodeFromConstraints(u,p,g){return xe(this,void 0,void 0,function*(){const b=yield navigator.mediaDevices.getUserMedia(u);return yield this.decodeFromStream(b,p,g)})}decodeFromStream(u,p,g){return xe(this,void 0,void 0,function*(){this.reset();const b=yield this.attachStreamToVideo(u,p);return yield this.decodeContinuously(b,g)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(u,p){return xe(this,void 0,void 0,function*(){const g=this.prepareVideoElement(p);return this.addVideoSource(g,u),this.videoElement=g,this.stream=u,yield this.playVideoOnLoadAsync(g),g})}playVideoOnLoadAsync(u){return new Promise((p,g)=>this.playVideoOnLoad(u,()=>p()))}playVideoOnLoad(u,p){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(u),u.addEventListener("ended",this.videoEndedListener),u.addEventListener("canplay",this.videoCanPlayListener),u.addEventListener("playing",p),this.tryPlayVideo(u)}isVideoPlaying(u){return u.currentTime>0&&!u.paused&&!u.ended&&u.readyState>2}tryPlayVideo(u){return xe(this,void 0,void 0,function*(){if(this.isVideoPlaying(u)){console.warn("Trying to play video that is already playing.");return}try{yield u.play()}catch{console.warn("It was not possible to play the video.")}})}getMediaElement(u,p){const g=document.getElementById(u);if(!g)throw new m(`element with id '${u}' not found`);if(g.nodeName.toLowerCase()!==p.toLowerCase())throw new m(`element with id '${u}' must be an ${p} element`);return g}decodeFromImage(u,p){if(!u&&!p)throw new m("either imageElement with a src set or an url must be provided");return p&&!u?this.decodeFromImageUrl(p):this.decodeFromImageElement(u)}decodeFromVideo(u,p){if(!u&&!p)throw new m("Either an element with a src set or an URL must be provided");return p&&!u?this.decodeFromVideoUrl(p):this.decodeFromVideoElement(u)}decodeFromVideoContinuously(u,p,g){if(u===void 0&&p===void 0)throw new m("Either an element with a src set or an URL must be provided");return p&&!u?this.decodeFromVideoUrlContinuously(p,g):this.decodeFromVideoElementContinuously(u,g)}decodeFromImageElement(u){if(!u)throw new m("An image element must be provided.");this.reset();const p=this.prepareImageElement(u);this.imageElement=p;let g;return this.isImageLoaded(p)?g=this.decodeOnce(p,!1,!0):g=this._decodeOnLoadImage(p),g}decodeFromVideoElement(u){const p=this._decodeFromVideoElementSetup(u);return this._decodeOnLoadVideo(p)}decodeFromVideoElementContinuously(u,p){const g=this._decodeFromVideoElementSetup(u);return this._decodeOnLoadVideoContinuously(g,p)}_decodeFromVideoElementSetup(u){if(!u)throw new m("A video element must be provided.");this.reset();const p=this.prepareVideoElement(u);return this.videoElement=p,p}decodeFromImageUrl(u){if(!u)throw new m("An URL must be provided.");this.reset();const p=this.prepareImageElement();this.imageElement=p;const g=this._decodeOnLoadImage(p);return p.src=u,g}decodeFromVideoUrl(u){if(!u)throw new m("An URL must be provided.");this.reset();const p=this.prepareVideoElement(),g=this.decodeFromVideoElement(p);return p.src=u,g}decodeFromVideoUrlContinuously(u,p){if(!u)throw new m("An URL must be provided.");this.reset();const g=this.prepareVideoElement(),b=this.decodeFromVideoElementContinuously(g,p);return g.src=u,b}_decodeOnLoadImage(u){return new Promise((p,g)=>{this.imageLoadedListener=()=>this.decodeOnce(u,!1,!0).then(p,g),u.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(u){return xe(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(u),yield this.decodeOnce(u)})}_decodeOnLoadVideoContinuously(u,p){return xe(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(u),this.decodeContinuously(u,p)})}isImageLoaded(u){return!(!u.complete||u.naturalWidth===0)}prepareImageElement(u){let p;return typeof u>"u"&&(p=document.createElement("img"),p.width=200,p.height=200),typeof u=="string"&&(p=this.getMediaElement(u,"img")),u instanceof HTMLImageElement&&(p=u),p}prepareVideoElement(u){let p;return!u&&typeof document<"u"&&(p=document.createElement("video"),p.width=200,p.height=200),typeof u=="string"&&(p=this.getMediaElement(u,"video")),u instanceof HTMLVideoElement&&(p=u),p.setAttribute("autoplay","true"),p.setAttribute("muted","true"),p.setAttribute("playsinline","true"),p}decodeOnce(u,p=!0,g=!0){this._stopAsyncDecode=!1;const b=(v,E)=>{if(this._stopAsyncDecode){E(new ne("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{const k=this.decode(u);v(k)}catch(k){const P=p&&k instanceof ne,W=(k instanceof A||k instanceof B)&&g;if(P||W)return setTimeout(b,this._timeBetweenDecodingAttempts,v,E);E(k)}};return new Promise((v,E)=>b(v,E))}decodeContinuously(u,p){this._stopContinuousDecode=!1;const g=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{const b=this.decode(u);p(b,null),setTimeout(g,this.timeBetweenScansMillis)}catch(b){p(null,b);const v=b instanceof A||b instanceof B,E=b instanceof ne;(v||E)&&setTimeout(g,this._timeBetweenDecodingAttempts)}};g()}decode(u){const p=this.createBinaryBitmap(u);return this.decodeBitmap(p)}_isHTMLVideoElement(u){return u.videoWidth!==0}drawFrameOnCanvas(u,p,g){p||(p={sx:0,sy:0,sWidth:u.videoWidth,sHeight:u.videoHeight,dx:0,dy:0,dWidth:u.videoWidth,dHeight:u.videoHeight}),g||(g=this.captureCanvasContext),g.drawImage(u,p.sx,p.sy,p.sWidth,p.sHeight,p.dx,p.dy,p.dWidth,p.dHeight)}drawImageOnCanvas(u,p,g=this.captureCanvasContext){p||(p={sx:0,sy:0,sWidth:u.naturalWidth,sHeight:u.naturalHeight,dx:0,dy:0,dWidth:u.naturalWidth,dHeight:u.naturalHeight}),g||(g=this.captureCanvasContext),g.drawImage(u,p.sx,p.sy,p.sWidth,p.sHeight,p.dx,p.dy,p.dWidth,p.dHeight)}createBinaryBitmap(u){this.getCaptureCanvasContext(u),this._isHTMLVideoElement(u)?this.drawFrameOnCanvas(u):this.drawImageOnCanvas(u);const p=this.getCaptureCanvas(u),g=new G(p),b=new be(g);return new w(b)}getCaptureCanvasContext(u){if(!this.captureCanvasContext){const g=this.getCaptureCanvas(u).getContext("2d");this.captureCanvasContext=g}return this.captureCanvasContext}getCaptureCanvas(u){if(!this.captureCanvas){const p=this.createCaptureCanvas(u);this.captureCanvas=p}return this.captureCanvas}decodeBitmap(u){return this.reader.decode(u,this._hints)}createCaptureCanvas(u){if(typeof document>"u")return this._destroyCaptureCanvas(),null;const p=document.createElement("canvas");let g,b;return typeof u<"u"&&(u instanceof HTMLVideoElement?(g=u.videoWidth,b=u.videoHeight):u instanceof HTMLImageElement&&(g=u.naturalWidth||u.width,b=u.naturalHeight||u.height)),p.style.width=g+"px",p.style.height=b+"px",p.width=g,p.height=b,p}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(u=>u.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(u,p){try{u.srcObject=p}catch{u.src=URL.createObjectURL(p)}}cleanVideoSource(u){try{u.srcObject=null}catch{u.src=""}this.videoElement.removeAttribute("src")}}class Me{constructor(u,p,g=p==null?0:8*p.length,b,v,E=C.currentTimeMillis()){this.text=u,this.rawBytes=p,this.numBits=g,this.resultPoints=b,this.format=v,this.timestamp=E,this.text=u,this.rawBytes=p,g==null?this.numBits=p==null?0:8*p.length:this.numBits=g,this.resultPoints=b,this.format=v,this.resultMetadata=null,E==null?this.timestamp=C.currentTimeMillis():this.timestamp=E}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(u,p){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(u,p)}putAllMetadata(u){u!==null&&(this.resultMetadata===null?this.resultMetadata=u:this.resultMetadata=new Map(u))}addResultPoints(u){const p=this.resultPoints;if(p===null)this.resultPoints=u;else if(u!==null&&u.length>0){const g=new Array(p.length+u.length);C.arraycopy(p,0,g,0,p.length),C.arraycopy(u,0,g,p.length,u.length),this.resultPoints=g}}getTimestamp(){return this.timestamp}toString(){return this.text}}var nt;(function(ee){ee[ee.AZTEC=0]="AZTEC",ee[ee.CODABAR=1]="CODABAR",ee[ee.CODE_39=2]="CODE_39",ee[ee.CODE_93=3]="CODE_93",ee[ee.CODE_128=4]="CODE_128",ee[ee.DATA_MATRIX=5]="DATA_MATRIX",ee[ee.EAN_8=6]="EAN_8",ee[ee.EAN_13=7]="EAN_13",ee[ee.ITF=8]="ITF",ee[ee.MAXICODE=9]="MAXICODE",ee[ee.PDF_417=10]="PDF_417",ee[ee.QR_CODE=11]="QR_CODE",ee[ee.RSS_14=12]="RSS_14",ee[ee.RSS_EXPANDED=13]="RSS_EXPANDED",ee[ee.UPC_A=14]="UPC_A",ee[ee.UPC_E=15]="UPC_E",ee[ee.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(nt||(nt={}));var ze=nt,Tt;(function(ee){ee[ee.OTHER=0]="OTHER",ee[ee.ORIENTATION=1]="ORIENTATION",ee[ee.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",ee[ee.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",ee[ee.ISSUE_NUMBER=4]="ISSUE_NUMBER",ee[ee.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",ee[ee.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",ee[ee.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",ee[ee.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",ee[ee.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",ee[ee.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(Tt||(Tt={}));var It=Tt;class ft{constructor(u,p,g,b,v=-1,E=-1){this.rawBytes=u,this.text=p,this.byteSegments=g,this.ecLevel=b,this.structuredAppendSequenceNumber=v,this.structuredAppendParity=E,this.numBits=u==null?0:8*u.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(u){this.numBits=u}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(u){this.errorsCorrected=u}getErasures(){return this.erasures}setErasures(u){this.erasures=u}getOther(){return this.other}setOther(u){this.other=u}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class Ee{exp(u){return this.expTable[u]}log(u){if(u===0)throw new y;return this.logTable[u]}static addOrSubtract(u,p){return u^p}}class yt{constructor(u,p){if(p.length===0)throw new y;this.field=u;const g=p.length;if(g>1&&p[0]===0){let b=1;for(;bg.length){const E=p;p=g,g=E}let b=new Int32Array(g.length);const v=g.length-p.length;C.arraycopy(g,0,b,0,v);for(let E=v;E=u.getDegree()&&!b.isZero();){const k=b.getDegree()-u.getDegree(),P=p.multiply(b.getCoefficient(b.getDegree()),E),M=u.multiplyByMonomial(k,P),W=p.buildMonomial(k,P);g=g.addOrSubtract(W),b=b.addOrSubtract(M)}return[g,b]}toString(){let u="";for(let p=this.getDegree();p>=0;p--){let g=this.getCoefficient(p);if(g!==0){if(g<0?(u+=" - ",g=-g):u.length>0&&(u+=" + "),p===0||g!==1){const b=this.field.log(g);b===0?u+="1":b===1?u+="a":(u+="a^",u+=b)}p!==0&&(p===1?u+="x":(u+="x^",u+=p))}}return u}}class Ue extends f{}Ue.kind="ArithmeticException";class Vt extends Ee{constructor(u,p,g){super(),this.primitive=u,this.size=p,this.generatorBase=g;const b=new Int32Array(p);let v=1;for(let k=0;k=p&&(v^=u,v&=p-1);this.expTable=b;const E=new Int32Array(p);for(let k=0;k=(g/2|0);){let ve=v,ke=k;if(v=E,k=P,v.isZero())throw new St("r_{i-1} was zero");E=ve;let Ie=b.getZero();const We=v.getCoefficient(v.getDegree()),ht=b.inverse(We);for(;E.getDegree()>=v.getDegree()&&!E.isZero();){const Yt=E.getDegree()-v.getDegree(),Wt=b.multiply(E.getCoefficient(E.getDegree()),ht);Ie=Ie.addOrSubtract(b.buildMonomial(Yt,Wt)),E=E.addOrSubtract(v.multiplyByMonomial(Yt,Wt))}if(P=Ie.multiply(k).addOrSubtract(ke),E.getDegree()>=v.getDegree())throw new tn("Division algorithm failed to reduce polynomial?")}const M=P.getCoefficient(0);if(M===0)throw new St("sigmaTilde(0) was zero");const W=b.inverse(M),te=P.multiplyScalar(W),ae=E.multiplyScalar(W);return[te,ae]}findErrorLocations(u){const p=u.getDegree();if(p===1)return Int32Array.from([u.getCoefficient(1)]);const g=new Int32Array(p);let b=0;const v=this.field;for(let E=1;E1,te,te+g-1),te+=g-1;else for(let ke=g-1;ke>=0;--ke)W[te++]=(ve&1<=8?Kt.readCode(u,p,8):Kt.readCode(u,p,g)<<8-g}static convertBoolArrayToByteArray(u){let p=new Uint8Array((u.length+7)/8);for(let g=0;g","?","[","]","{","}","CTRL_UL"],Kt.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class ut{constructor(){}static round(u){return u===NaN?0:u<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:u>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:u+(u<0?-.5:.5)|0}static distance(u,p,g,b){const v=u-g,E=p-b;return Math.sqrt(v*v+E*E)}static sum(u){let p=0;for(let g=0,b=u.length;g!==b;g++){const v=u[g];p+=v}return p}}class Jt{static floatToIntBits(u){return u}}Jt.MAX_VALUE=Number.MAX_SAFE_INTEGER;class Dt{constructor(u,p){this.x=u,this.y=p}getX(){return this.x}getY(){return this.y}equals(u){if(u instanceof Dt){const p=u;return this.x===p.x&&this.y===p.y}return!1}hashCode(){return 31*Jt.floatToIntBits(this.x)+Jt.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(u){const p=this.distance(u[0],u[1]),g=this.distance(u[1],u[2]),b=this.distance(u[0],u[2]);let v,E,k;if(g>=p&&g>=b?(E=u[0],v=u[1],k=u[2]):b>=g&&b>=p?(E=u[1],v=u[0],k=u[2]):(E=u[2],v=u[0],k=u[1]),this.crossProductZ(v,E,k)<0){const P=v;v=k,k=P}u[0]=v,u[1]=E,u[2]=k}static distance(u,p){return ut.distance(u.x,u.y,p.x,p.y)}static crossProductZ(u,p,g){const b=p.x,v=p.y;return(g.x-b)*(u.y-v)-(g.y-v)*(u.x-b)}}class hn{constructor(u,p){this.bits=u,this.points=p}getBits(){return this.bits}getPoints(){return this.points}}class qn extends hn{constructor(u,p,g,b,v){super(u,p),this.compact=g,this.nbDatablocks=b,this.nbLayers=v}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class mn{constructor(u,p,g,b){this.image=u,this.height=u.getHeight(),this.width=u.getWidth(),p==null&&(p=mn.INIT_SIZE),g==null&&(g=u.getWidth()/2|0),b==null&&(b=u.getHeight()/2|0);const v=p/2|0;if(this.leftInit=g-v,this.rightInit=g+v,this.upInit=b-v,this.downInit=b+v,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new ne}detect(){let u=this.leftInit,p=this.rightInit,g=this.upInit,b=this.downInit,v=!1,E=!0,k=!1,P=!1,M=!1,W=!1,te=!1;const ae=this.width,ve=this.height;for(;E;){E=!1;let ke=!0;for(;(ke||!P)&&p=ae){v=!0;break}let Ie=!0;for(;(Ie||!M)&&b=ve){v=!0;break}let We=!0;for(;(We||!W)&&u>=0;)We=this.containsBlackPoint(g,b,u,!1),We?(u--,E=!0,W=!0):W||u--;if(u<0){v=!0;break}let ht=!0;for(;(ht||!te)&&g>=0;)ht=this.containsBlackPoint(u,p,g,!0),ht?(g--,E=!0,te=!0):te||g--;if(g<0){v=!0;break}E&&(k=!0)}if(!v&&k){const ke=p-u;let Ie=null;for(let Wt=1;Ie===null&&Wtg||P<-1||P>b)throw new ne;v=!1,k===-1?(p[E]=0,v=!0):k===g&&(p[E]=g-1,v=!0),P===-1?(p[E+1]=0,v=!0):P===b&&(p[E+1]=b-1,v=!0)}v=!0;for(let E=p.length-2;E>=0&&v;E-=2){const k=Math.floor(p[E]),P=Math.floor(p[E+1]);if(k<-1||k>g||P<-1||P>b)throw new ne;v=!1,k===-1?(p[E]=0,v=!0):k===g&&(p[E]=g-1,v=!0),P===-1?(p[E+1]=0,v=!0):P===b&&(p[E+1]=b-1,v=!0)}}}class Ve{constructor(u,p,g,b,v,E,k,P,M){this.a11=u,this.a21=p,this.a31=g,this.a12=b,this.a22=v,this.a32=E,this.a13=k,this.a23=P,this.a33=M}static quadrilateralToQuadrilateral(u,p,g,b,v,E,k,P,M,W,te,ae,ve,ke,Ie,We){const ht=Ve.quadrilateralToSquare(u,p,g,b,v,E,k,P);return Ve.squareToQuadrilateral(M,W,te,ae,ve,ke,Ie,We).times(ht)}transformPoints(u){const p=u.length,g=this.a11,b=this.a12,v=this.a13,E=this.a21,k=this.a22,P=this.a23,M=this.a31,W=this.a32,te=this.a33;for(let ae=0;ae>1&127):(b<<=10,b+=(k>>2&992)+(k>>1&31))}let v=this.getCorrectedParameterData(b,this.compact);this.compact?(this.nbLayers=(v>>6)+1,this.nbDataBlocks=(v&63)+1):(this.nbLayers=(v>>11)+1,this.nbDataBlocks=(v&2047)+1)}getRotation(u,p){let g=0;u.forEach((b,v,E)=>{let k=(b>>p-2<<1)+(b&1);g=(g<<3)+k}),g=((g&1)<<11)+(g>>1);for(let b=0;b<4;b++)if(L.bitCount(g^this.EXPECTED_CORNER_BITS[b])<=2)return b;throw new ne}getCorrectedParameterData(u,p){let g,b;p?(g=7,b=2):(g=10,b=4);let v=g-b,E=new Int32Array(g);for(let P=g-1;P>=0;--P)E[P]=u&15,u>>=4;try{new Pt(Vt.AZTEC_PARAM).decode(E,v)}catch{throw new ne}let k=0;for(let P=0;P2){let Ie=this.distancePoint(ke,te)*this.nbCenterLayers/(this.distancePoint(v,p)*(this.nbCenterLayers+2));if(Ie<.75||Ie>1.25||!this.isWhiteOrBlackRectangle(te,ae,ve,ke))break}p=te,g=ae,b=ve,v=ke,E=!E}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new ne;this.compact=this.nbCenterLayers===5;let k=new Dt(p.getX()+.5,p.getY()-.5),P=new Dt(g.getX()+.5,g.getY()+.5),M=new Dt(b.getX()-.5,b.getY()+.5),W=new Dt(v.getX()-.5,v.getY()-.5);return this.expandSquare([k,P,M,W],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let u,p,g,b;try{let k=new mn(this.image).detect();u=k[0],p=k[1],g=k[2],b=k[3]}catch{let P=this.image.getWidth()/2,M=this.image.getHeight()/2;u=this.getFirstDifferent(new dn(P+7,M-7),!1,1,-1).toResultPoint(),p=this.getFirstDifferent(new dn(P+7,M+7),!1,1,1).toResultPoint(),g=this.getFirstDifferent(new dn(P-7,M+7),!1,-1,1).toResultPoint(),b=this.getFirstDifferent(new dn(P-7,M-7),!1,-1,-1).toResultPoint()}let v=ut.round((u.getX()+b.getX()+p.getX()+g.getX())/4),E=ut.round((u.getY()+b.getY()+p.getY()+g.getY())/4);try{let k=new mn(this.image,15,v,E).detect();u=k[0],p=k[1],g=k[2],b=k[3]}catch{u=this.getFirstDifferent(new dn(v+7,E-7),!1,1,-1).toResultPoint(),p=this.getFirstDifferent(new dn(v+7,E+7),!1,1,1).toResultPoint(),g=this.getFirstDifferent(new dn(v-7,E+7),!1,-1,1).toResultPoint(),b=this.getFirstDifferent(new dn(v-7,E-7),!1,-1,-1).toResultPoint()}return v=ut.round((u.getX()+b.getX()+p.getX()+g.getX())/4),E=ut.round((u.getY()+b.getY()+p.getY()+g.getY())/4),new dn(v,E)}getMatrixCornerPoints(u){return this.expandSquare(u,2*this.nbCenterLayers,this.getDimension())}sampleGrid(u,p,g,b,v){let E=cn.getInstance(),k=this.getDimension(),P=k/2-this.nbCenterLayers,M=k/2+this.nbCenterLayers;return E.sampleGrid(u,k,k,P,P,M,P,M,M,P,M,p.getX(),p.getY(),g.getX(),g.getY(),b.getX(),b.getY(),v.getX(),v.getY())}sampleLine(u,p,g){let b=0,v=this.distanceResultPoint(u,p),E=v/g,k=u.getX(),P=u.getY(),M=E*(p.getX()-u.getX())/v,W=E*(p.getY()-u.getY())/v;for(let te=0;te.1&&te<.9?0:te<=.1===M?1:-1}getFirstDifferent(u,p,g,b){let v=u.getX()+g,E=u.getY()+b;for(;this.isValid(v,E)&&this.image.get(v,E)===p;)v+=g,E+=b;for(v-=g,E-=b;this.isValid(v,E)&&this.image.get(v,E)===p;)v+=g;for(v-=g;this.isValid(v,E)&&this.image.get(v,E)===p;)E+=b;return E-=b,new dn(v,E)}expandSquare(u,p,g){let b=g/(2*p),v=u[0].getX()-u[2].getX(),E=u[0].getY()-u[2].getY(),k=(u[0].getX()+u[2].getX())/2,P=(u[0].getY()+u[2].getY())/2,M=new Dt(k+b*v,P+b*E),W=new Dt(k-b*v,P-b*E);v=u[1].getX()-u[3].getX(),E=u[1].getY()-u[3].getY(),k=(u[1].getX()+u[3].getX())/2,P=(u[1].getY()+u[3].getY())/2;let te=new Dt(k+b*v,P+b*E),ae=new Dt(k-b*v,P-b*E);return[M,te,W,ae]}isValid(u,p){return u>=0&&u0&&p{g.foundPossibleResultPoint(b)})}}reset(){}}class wi extends re{constructor(u=500){super(new gr,u)}}class Xt{decode(u,p){try{return this.doDecode(u,p)}catch{if(p&&p.get(q.TRY_HARDER)===!0&&u.isRotateSupported()){const v=u.rotateCounterClockwise(),E=this.doDecode(v,p),k=E.getResultMetadata();let P=270;k!==null&&k.get(It.ORIENTATION)===!0&&(P=P+k.get(It.ORIENTATION)%360),E.putMetadata(It.ORIENTATION,P);const M=E.getResultPoints();if(M!==null){const W=v.getHeight();for(let te=0;te>(E?8:5));let P;E?P=b:P=15;const M=Math.trunc(b/2);for(let W=0;W=b)break;try{v=u.getBlackRow(ve,v)}catch{continue}for(let ke=0;ke<2;ke++){if(ke===1&&(v.reverse(),p&&p.get(q.NEED_RESULT_POINT_CALLBACK)===!0)){const Ie=new Map;p.forEach((We,ht)=>Ie.set(ht,We)),Ie.delete(q.NEED_RESULT_POINT_CALLBACK),p=Ie}try{const Ie=this.decodeRow(ve,v,p);if(ke===1){Ie.putMetadata(It.ORIENTATION,180);const We=Ie.getResultPoints();We!==null&&(We[0]=new Dt(g-We[0].getX()-1,We[0].getY()),We[1]=new Dt(g-We[1].getX()-1,We[1].getY()))}return Ie}catch{}}}throw new ne}static recordPattern(u,p,g){const b=g.length;for(let M=0;M=v)throw new ne;let E=!u.get(p),k=0,P=p;for(;P0&&b>=0;)u.get(--p)!==v&&(b--,v=!v);if(b>=0)throw new ne;Xt.recordPattern(u,p+1,g)}static patternMatchVariance(u,p,g){const b=u.length;let v=0,E=0;for(let M=0;Mte?W-te:te-W;if(ae>g)return Number.POSITIVE_INFINITY;P+=ae}return P/v}}class me extends Xt{static findStartPattern(u){const p=u.getSize(),g=u.getNextSet(0);let b=0,v=Int32Array.from([0,0,0,0,0,0]),E=g,k=!1;const P=6;for(let M=g;M=0&&u.isRange(Math.max(0,E-(M-E)/2),E,!1))return Int32Array.from([E,M,te]);E+=v[0]+v[1],v=v.slice(2,v.length-1),v[b-1]=0,v[b]=0,b--}else b++;v[b]=1,k=!k}throw new ne}static decodeCode(u,p,g){Xt.recordPattern(u,g,p);let b=me.MAX_AVG_VARIANCE,v=-1;for(let E=0;E=0)return v;throw new ne}decodeRow(u,p,g){const b=g&&g.get(q.ASSUME_GS1)===!0,v=me.findStartPattern(p),E=v[2];let k=0;const P=new Uint8Array(20);P[k++]=E;let M;switch(E){case me.CODE_START_A:M=me.CODE_CODE_A;break;case me.CODE_START_B:M=me.CODE_CODE_B;break;case me.CODE_START_C:M=me.CODE_CODE_C;break;default:throw new B}let W=!1,te=!1,ae="",ve=v[0],ke=v[1];const Ie=Int32Array.from([0,0,0,0,0,0]);let We=0,ht=0,Yt=E,Wt=0,zt=!0,Dr=!1,yr=!1;for(;!W;){const Wl=te;switch(te=!1,We=ht,ht=me.decodeCode(p,Ie,ke),P[k++]=ht,ht!==me.CODE_STOP&&(zt=!0),ht!==me.CODE_STOP&&(Wt++,Yt+=Wt*ht),ve=ke,ke+=Ie.reduce((oh,Df)=>oh+Df,0),ht){case me.CODE_START_A:case me.CODE_START_B:case me.CODE_START_C:throw new B}switch(M){case me.CODE_CODE_A:if(ht<64)yr===Dr?ae+=String.fromCharCode(32+ht):ae+=String.fromCharCode(32+ht+128),yr=!1;else if(ht<96)yr===Dr?ae+=String.fromCharCode(ht-64):ae+=String.fromCharCode(ht+64),yr=!1;else switch(ht!==me.CODE_STOP&&(zt=!1),ht){case me.CODE_FNC_1:b&&(ae.length===0?ae+="]C1":ae+="");break;case me.CODE_FNC_2:case me.CODE_FNC_3:break;case me.CODE_FNC_4_A:!Dr&&yr?(Dr=!0,yr=!1):Dr&&yr?(Dr=!1,yr=!1):yr=!0;break;case me.CODE_SHIFT:te=!0,M=me.CODE_CODE_B;break;case me.CODE_CODE_B:M=me.CODE_CODE_B;break;case me.CODE_CODE_C:M=me.CODE_CODE_C;break;case me.CODE_STOP:W=!0;break}break;case me.CODE_CODE_B:if(ht<96)yr===Dr?ae+=String.fromCharCode(32+ht):ae+=String.fromCharCode(32+ht+128),yr=!1;else switch(ht!==me.CODE_STOP&&(zt=!1),ht){case me.CODE_FNC_1:b&&(ae.length===0?ae+="]C1":ae+="");break;case me.CODE_FNC_2:case me.CODE_FNC_3:break;case me.CODE_FNC_4_B:!Dr&&yr?(Dr=!0,yr=!1):Dr&&yr?(Dr=!1,yr=!1):yr=!0;break;case me.CODE_SHIFT:te=!0,M=me.CODE_CODE_A;break;case me.CODE_CODE_A:M=me.CODE_CODE_A;break;case me.CODE_CODE_C:M=me.CODE_CODE_C;break;case me.CODE_STOP:W=!0;break}break;case me.CODE_CODE_C:if(ht<100)ht<10&&(ae+="0"),ae+=ht;else switch(ht!==me.CODE_STOP&&(zt=!1),ht){case me.CODE_FNC_1:b&&(ae.length===0?ae+="]C1":ae+="");break;case me.CODE_CODE_A:M=me.CODE_CODE_A;break;case me.CODE_CODE_B:M=me.CODE_CODE_B;break;case me.CODE_STOP:W=!0;break}break}Wl&&(M=M===me.CODE_CODE_A?me.CODE_CODE_B:me.CODE_CODE_A)}const Ns=ke-ve;if(ke=p.getNextUnset(ke),!p.isRange(ke,Math.min(p.getSize(),ke+(ke-ve)/2),!1))throw new ne;if(Yt-=Wt*We,Yt%103!==We)throw new A;const Ua=ae.length;if(Ua===0)throw new ne;Ua>0&&zt&&(M===me.CODE_CODE_C?ae=ae.substring(0,Ua-2):ae=ae.substring(0,Ua-1));const Js=(v[1]+v[0])/2,hi=ve+Ns/2,Os=P.length,xa=new Uint8Array(Os);for(let Wl=0;Wlg&&(v=P);g=v,b=0;let E=0,k=0;for(let P=0;Pg&&(k|=1<0;P++){let M=u[P];if(M>g&&(b--,M*2>=E))return-1}return k}}while(b>3);return-1}static patternToChar(u){for(let p=0;p="A"&&E<="Z")k=String.fromCharCode(E.charCodeAt(0)+32);else throw new B;break;case"$":if(E>="A"&&E<="Z")k=String.fromCharCode(E.charCodeAt(0)-64);else throw new B;break;case"%":if(E>="A"&&E<="E")k=String.fromCharCode(E.charCodeAt(0)-38);else if(E>="F"&&E<="J")k=String.fromCharCode(E.charCodeAt(0)-11);else if(E>="K"&&E<="O")k=String.fromCharCode(E.charCodeAt(0)+16);else if(E>="P"&&E<="T")k=String.fromCharCode(E.charCodeAt(0)+43);else if(E==="U")k="\0";else if(E==="V")k="@";else if(E==="W")k="`";else if(E==="X"||E==="Y"||E==="Z")k="";else throw new B;break;case"/":if(E>="A"&&E<="O")k=String.fromCharCode(E.charCodeAt(0)-32);else if(E==="Z")k=":";else throw new B;break}g+=k,b++}else g+=v}return g}}qe.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",qe.CHARACTER_ENCODINGS=[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,168,162,138,42],qe.ASTERISK_ENCODING=148;class st extends Xt{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(u,p,g){let b=this.decodeStart(p),v=this.decodeEnd(p),E=new J;st.decodeMiddle(p,b[1],v[0],E);let k=E.toString(),P=null;g!=null&&(P=g.get(q.ALLOWED_LENGTHS)),P==null&&(P=st.DEFAULT_ALLOWED_LENGTHS);let M=k.length,W=!1,te=0;for(let ke of P){if(M===ke){W=!0;break}ke>te&&(te=ke)}if(!W&&M>te&&(W=!0),!W)throw new B;const ae=[new Dt(b[1],u),new Dt(v[0],u)];return new Me(k,null,0,ae,ze.ITF,new Date().getTime())}static decodeMiddle(u,p,g,b){let v=new Int32Array(10),E=new Int32Array(5),k=new Int32Array(5);for(v.fill(0),E.fill(0),k.fill(0);p0&&b>=0&&!u.get(b);b--)g--;if(g!==0)throw new ne}static skipWhiteSpace(u){const p=u.getSize(),g=u.getNextSet(0);if(g===p)throw new ne;return g}decodeEnd(u){u.reverse();try{let p=st.skipWhiteSpace(u),g;try{g=st.findGuardPattern(u,p,st.END_PATTERN_REVERSED[0])}catch(v){v instanceof ne&&(g=st.findGuardPattern(u,p,st.END_PATTERN_REVERSED[1]))}this.validateQuietZone(u,g[0]);let b=g[0];return g[0]=u.getSize()-g[1],g[1]=u.getSize()-b,g}finally{u.reverse()}}static findGuardPattern(u,p,g){let b=g.length,v=new Int32Array(b),E=u.getSize(),k=!1,P=0,M=p;v.fill(0);for(let W=p;W=0)return g%10;throw new ne}}st.PATTERNS=[Int32Array.from([1,1,2,2,1]),Int32Array.from([2,1,1,1,2]),Int32Array.from([1,2,1,1,2]),Int32Array.from([2,2,1,1,1]),Int32Array.from([1,1,2,1,2]),Int32Array.from([2,1,2,1,1]),Int32Array.from([1,2,2,1,1]),Int32Array.from([1,1,1,2,2]),Int32Array.from([2,1,1,2,1]),Int32Array.from([1,2,1,2,1]),Int32Array.from([1,1,3,3,1]),Int32Array.from([3,1,1,1,3]),Int32Array.from([1,3,1,1,3]),Int32Array.from([3,3,1,1,1]),Int32Array.from([1,1,3,1,3]),Int32Array.from([3,1,3,1,1]),Int32Array.from([1,3,3,1,1]),Int32Array.from([1,1,1,3,3]),Int32Array.from([3,1,1,3,1]),Int32Array.from([1,3,1,3,1])],st.MAX_AVG_VARIANCE=.38,st.MAX_INDIVIDUAL_VARIANCE=.5,st.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],st.START_PATTERN=Int32Array.from([1,1,1,1]),st.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class dt extends Xt{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(u){let p=!1,g,b=0,v=Int32Array.from([0,0,0]);for(;!p;){v=Int32Array.from([0,0,0]),g=dt.findGuardPattern(u,b,!1,this.START_END_PATTERN,v);let E=g[0];b=g[1];let k=E-(b-E);k>=0&&(p=u.isRange(k,E,!1))}return g}static checkChecksum(u){return dt.checkStandardUPCEANChecksum(u)}static checkStandardUPCEANChecksum(u){let p=u.length;if(p===0)return!1;let g=parseInt(u.charAt(p-1),10);return dt.getStandardUPCEANChecksum(u.substring(0,p-1))===g}static getStandardUPCEANChecksum(u){let p=u.length,g=0;for(let b=p-1;b>=0;b-=2){let v=u.charAt(b).charCodeAt(0)-48;if(v<0||v>9)throw new B;g+=v}g*=3;for(let b=p-2;b>=0;b-=2){let v=u.charAt(b).charCodeAt(0)-48;if(v<0||v>9)throw new B;g+=v}return(1e3-g)%10}static decodeEnd(u,p){return dt.findGuardPattern(u,p,!1,dt.START_END_PATTERN,new Int32Array(dt.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(u,p,g,b){return this.findGuardPattern(u,p,g,b,new Int32Array(b.length))}static findGuardPattern(u,p,g,b,v){let E=u.getSize();p=g?u.getNextUnset(p):u.getNextSet(p);let k=0,P=p,M=b.length,W=g;for(let te=p;te=0)return E;throw new ne}}dt.MAX_AVG_VARIANCE=.48,dt.MAX_INDIVIDUAL_VARIANCE=.7,dt.START_END_PATTERN=Int32Array.from([1,1,1]),dt.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),dt.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),dt.L_PATTERNS=[Int32Array.from([3,2,1,1]),Int32Array.from([2,2,2,1]),Int32Array.from([2,1,2,2]),Int32Array.from([1,4,1,1]),Int32Array.from([1,1,3,2]),Int32Array.from([1,2,3,1]),Int32Array.from([1,1,1,4]),Int32Array.from([1,3,1,2]),Int32Array.from([1,2,1,3]),Int32Array.from([3,1,1,2])];class An{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(u,p,g){let b=this.decodeRowStringBuffer,v=this.decodeMiddle(p,g,b),E=b.toString(),k=An.parseExtensionString(E),P=[new Dt((g[0]+g[1])/2,u),new Dt(v,u)],M=new Me(E,null,0,P,ze.UPC_EAN_EXTENSION,new Date().getTime());return k!=null&&M.putAllMetadata(k),M}decodeMiddle(u,p,g){let b=this.decodeMiddleCounters;b[0]=0,b[1]=0,b[2]=0,b[3]=0;let v=u.getSize(),E=p[1],k=0;for(let M=0;M<5&&E=10&&(k|=1<<4-M),M!==4&&(E=u.getNextSet(E),E=u.getNextUnset(E))}if(g.length!==5)throw new ne;let P=this.determineCheckDigit(k);if(An.extensionChecksum(g.toString())!==P)throw new ne;return E}static extensionChecksum(u){let p=u.length,g=0;for(let b=p-2;b>=0;b-=2)g+=u.charAt(b).charCodeAt(0)-48;g*=3;for(let b=p-1;b>=0;b-=2)g+=u.charAt(b).charCodeAt(0)-48;return g*=3,g%10}determineCheckDigit(u){for(let p=0;p<10;p++)if(u===this.CHECK_DIGIT_ENCODINGS[p])return p;throw new ne}static parseExtensionString(u){if(u.length!==5)return null;let p=An.parseExtension5String(u);return p==null?null:new Map([[It.SUGGESTED_PRICE,p]])}static parseExtension5String(u){let p;switch(u.charAt(0)){case"0":p="£";break;case"5":p="$";break;case"9":switch(u){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}p="";break;default:p="";break}let g=parseInt(u.substring(1)),b=(g/100).toString(),v=g%100,E=v<10?"0"+v:v.toString();return p+b+"."+E}}class Ft{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(u,p,g){let b=this.decodeRowStringBuffer,v=this.decodeMiddle(p,g,b),E=b.toString(),k=Ft.parseExtensionString(E),P=[new Dt((g[0]+g[1])/2,u),new Dt(v,u)],M=new Me(E,null,0,P,ze.UPC_EAN_EXTENSION,new Date().getTime());return k!=null&&M.putAllMetadata(k),M}decodeMiddle(u,p,g){let b=this.decodeMiddleCounters;b[0]=0,b[1]=0,b[2]=0,b[3]=0;let v=u.getSize(),E=p[1],k=0;for(let P=0;P<2&&E=10&&(k|=1<<1-P),P!==1&&(E=u.getNextSet(E),E=u.getNextUnset(E))}if(g.length!==2)throw new ne;if(parseInt(g.toString())%4!==k)throw new ne;return E}static parseExtensionString(u){return u.length!==2?null:new Map([[It.ISSUE_NUMBER,parseInt(u)]])}}class Dn{static decodeRow(u,p,g){let b=dt.findGuardPattern(p,g,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new An().decodeRow(u,p,b)}catch{return new Ft().decodeRow(u,p,b)}}}Dn.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class Ot extends dt{constructor(){super(),this.decodeRowStringBuffer="",Ot.L_AND_G_PATTERNS=Ot.L_PATTERNS.map(u=>Int32Array.from(u));for(let u=10;u<20;u++){let p=Ot.L_PATTERNS[u-10],g=new Int32Array(p.length);for(let b=0;b=p.getSize()||!p.isRange(W,te,!1))throw new ne;let ae=P.toString();if(ae.length<8)throw new B;if(!Ot.checkChecksum(ae))throw new A;let ve=(b[1]+b[0])/2,ke=(M[1]+M[0])/2,Ie=this.getBarcodeFormat(),We=[new Dt(ve,u),new Dt(ke,u)],ht=new Me(ae,null,0,We,Ie,new Date().getTime()),Yt=0;try{let zt=Dn.decodeRow(u,p,M[1]);ht.putMetadata(It.UPC_EAN_EXTENSION,zt.getText()),ht.putAllMetadata(zt.getResultMetadata()),ht.addResultPoints(zt.getResultPoints()),Yt=zt.getText().length}catch{}let Wt=g==null?null:g.get(q.ALLOWED_EAN_EXTENSIONS);if(Wt!=null){let zt=!1;for(let Dr in Wt)if(Yt.toString()===Dr){zt=!0;break}if(!zt)throw new ne}return ht}decodeEnd(u,p){return Ot.findGuardPattern(u,p,!1,Ot.START_END_PATTERN,new Int32Array(Ot.START_END_PATTERN.length).fill(0))}static checkChecksum(u){return Ot.checkStandardUPCEANChecksum(u)}static checkStandardUPCEANChecksum(u){let p=u.length;if(p===0)return!1;let g=parseInt(u.charAt(p-1),10);return Ot.getStandardUPCEANChecksum(u.substring(0,p-1))===g}static getStandardUPCEANChecksum(u){let p=u.length,g=0;for(let b=p-1;b>=0;b-=2){let v=u.charAt(b).charCodeAt(0)-48;if(v<0||v>9)throw new B;g+=v}g*=3;for(let b=p-2;b>=0;b-=2){let v=u.charAt(b).charCodeAt(0)-48;if(v<0||v>9)throw new B;g+=v}return(1e3-g)%10}}class on extends Ot{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(u,p,g){let b=this.decodeMiddleCounters;b[0]=0,b[1]=0,b[2]=0,b[3]=0;let v=u.getSize(),E=p[1],k=0;for(let M=0;M<6&&E=10&&(k|=1<<5-M)}g=on.determineFirstDigit(g,k),E=Ot.findGuardPattern(u,E,!0,Ot.MIDDLE_PATTERN,new Int32Array(Ot.MIDDLE_PATTERN.length).fill(0))[1];for(let M=0;M<6&&EM);b[0]=0,b[1]=0,b[2]=0,b[3]=0;const v=u.getSize();let E=p[1],k=0;for(let M=0;M<6&&E=10&&(k|=1<<5-M)}let P=ue.determineNumSysAndCheckDigit(g,k);return{rowOffset:E,resultString:P}}decodeEnd(u,p){return ue.findGuardPatternWithoutCounters(u,p,!0,ue.MIDDLE_END_PATTERN)}checkChecksum(u){return Ot.checkChecksum(ue.convertUPCEtoUPCA(u))}static determineNumSysAndCheckDigit(u,p){for(let g=0;g<=1;g++)for(let b=0;b<10;b++)if(p===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[g][b]){let v=String.fromCharCode(48+g),E=String.fromCharCode(48+b);return v+u+E}throw ne.getNotFoundInstance()}getBarcodeFormat(){return ze.UPC_E}static convertUPCEtoUPCA(u){const p=u.slice(1,7).split("").map(v=>v.charCodeAt(0)),g=new J;g.append(u.charAt(0));let b=p[5];switch(b){case 0:case 1:case 2:g.appendChars(p,0,2),g.append(b),g.append("0000"),g.appendChars(p,2,3);break;case 3:g.appendChars(p,0,3),g.append("00000"),g.appendChars(p,3,2);break;case 4:g.appendChars(p,0,4),g.append("00000"),g.append(p[4]);break;default:g.appendChars(p,0,5),g.append("0000"),g.append(b);break}return u.length>=8&&g.append(u.charAt(7)),g.toString()}}ue.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),ue.NUMSYS_AND_CHECK_DIGIT_PATTERNS=[Int32Array.from([56,52,50,49,44,38,35,42,41,37]),Int32Array.from([7,11,13,14,19,25,28,21,22,26])];class Se extends Xt{constructor(u){super();let p=u==null?null:u.get(q.POSSIBLE_FORMATS),g=[];r(p)?(g.push(new on),g.push(new lr),g.push(new jr),g.push(new ue)):(p.indexOf(ze.EAN_13)>-1&&g.push(new on),p.indexOf(ze.UPC_A)>-1&&g.push(new lr),p.indexOf(ze.EAN_8)>-1&&g.push(new jr),p.indexOf(ze.UPC_E)>-1&&g.push(new ue)),this.readers=g}decodeRow(u,p,g){for(let b of this.readers)try{const v=b.decodeRow(u,p,g),E=v.getBarcodeFormat()===ze.EAN_13&&v.getText().charAt(0)==="0",k=g==null?null:g.get(q.POSSIBLE_FORMATS),P=k==null||k.includes(ze.UPC_A);if(E&&P){const M=v.getRawBytes(),W=new Me(v.getText().substring(1),M,M?M.length:null,v.getResultPoints(),ze.UPC_A);return W.putAllMetadata(v.getResultMetadata()),W}return v}catch{}throw new ne}reset(){for(let u of this.readers)u.reset()}}class Qe extends Xt{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(u,p){for(let g=0;gb&&(b=p[v],g=v);u[g]++}static decrement(u,p){let g=0,b=p[0];for(let v=1;v=Qe.MIN_FINDER_PATTERN_RATIO&&b<=Qe.MAX_FINDER_PATTERN_RATIO){let v=Number.MAX_SAFE_INTEGER,E=Number.MIN_SAFE_INTEGER;for(let k of u)k>E&&(E=k),k=k-P-1&&(W-=xn.combins(b-M-(k-P),k-P-2)),k-P-1>1){let te=0;for(let ae=b-M-(k-P-2);ae>p;ae--)te+=xn.combins(b-M-ae-1,k-P-3);W-=te*(k-1-P)}else b-M>p&&W--;v+=W}b-=M}return v}static combins(u,p){let g,b;u-p>p?(b=p,g=u-p):(b=u-p,g=p);let v=1,E=1;for(let k=u;k>g;k--)v*=k,E<=b&&(v/=E,E++);for(;E<=b;)v/=E,E++;return v}}class kn{static buildBitArray(u){let p=u.length*2-1;u[u.length-1].getRightChar()==null&&(p-=1);let g=12*p,b=new K(g),v=0,k=u[0].getRightChar().getValue();for(let P=11;P>=0;--P)(k&1<=0;--te)(W&1<=0;--ae)(te&1<10||g<0||g>10)throw new B;this.firstDigit=p,this.secondDigit=g}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===ln.FNC1}isSecondDigitFNC1(){return this.secondDigit===ln.FNC1}isAnyFNC1(){return this.firstDigit===ln.FNC1||this.secondDigit===ln.FNC1}}ln.FNC1=10;class bt{constructor(){}static parseFieldsInGeneralPurpose(u){if(!u)return null;if(u.length<2)throw new ne;let p=u.substring(0,2);for(let v of bt.TWO_DIGIT_DATA_LENGTH)if(v[0]===p)return v[1]===bt.VARIABLE_LENGTH?bt.processVariableAI(2,v[2],u):bt.processFixedAI(2,v[1],u);if(u.length<3)throw new ne;let g=u.substring(0,3);for(let v of bt.THREE_DIGIT_DATA_LENGTH)if(v[0]===g)return v[1]===bt.VARIABLE_LENGTH?bt.processVariableAI(3,v[2],u):bt.processFixedAI(3,v[1],u);for(let v of bt.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(v[0]===g)return v[1]===bt.VARIABLE_LENGTH?bt.processVariableAI(4,v[2],u):bt.processFixedAI(4,v[1],u);if(u.length<4)throw new ne;let b=u.substring(0,4);for(let v of bt.FOUR_DIGIT_DATA_LENGTH)if(v[0]===b)return v[1]===bt.VARIABLE_LENGTH?bt.processVariableAI(4,v[2],u):bt.processFixedAI(4,v[1],u);throw new ne}static processFixedAI(u,p,g){if(g.lengththis.information.getSize())return u+4<=this.information.getSize();for(let p=u;pthis.information.getSize()){let v=this.extractNumericValueFromBitArray(u,4);return v===0?new ln(this.information.getSize(),ln.FNC1,ln.FNC1):new ln(this.information.getSize(),v-1,ln.FNC1)}let p=this.extractNumericValueFromBitArray(u,7),g=(p-8)/11,b=(p-8)%11;return new ln(u+7,g,b)}extractNumericValueFromBitArray(u,p){return yn.extractNumericValueFromBitArray(this.information,u,p)}static extractNumericValueFromBitArray(u,p,g){let b=0;for(let v=0;vthis.information.getSize())return!1;let p=this.extractNumericValueFromBitArray(u,5);if(p>=5&&p<16)return!0;if(u+7>this.information.getSize())return!1;let g=this.extractNumericValueFromBitArray(u,7);if(g>=64&&g<116)return!0;if(u+8>this.information.getSize())return!1;let b=this.extractNumericValueFromBitArray(u,8);return b>=232&&b<253}decodeIsoIec646(u){let p=this.extractNumericValueFromBitArray(u,5);if(p===15)return new Et(u+5,Et.FNC1);if(p>=5&&p<15)return new Et(u+5,"0"+(p-5));let g=this.extractNumericValueFromBitArray(u,7);if(g>=64&&g<90)return new Et(u+7,""+(g+1));if(g>=90&&g<116)return new Et(u+7,""+(g+7));let b=this.extractNumericValueFromBitArray(u,8),v;switch(b){case 232:v="!";break;case 233:v='"';break;case 234:v="%";break;case 235:v="&";break;case 236:v="'";break;case 237:v="(";break;case 238:v=")";break;case 239:v="*";break;case 240:v="+";break;case 241:v=",";break;case 242:v="-";break;case 243:v=".";break;case 244:v="/";break;case 245:v=":";break;case 246:v=";";break;case 247:v="<";break;case 248:v="=";break;case 249:v=">";break;case 250:v="?";break;case 251:v="_";break;case 252:v=" ";break;default:throw new B}return new Et(u+8,v)}isStillAlpha(u){if(u+5>this.information.getSize())return!1;let p=this.extractNumericValueFromBitArray(u,5);if(p>=5&&p<16)return!0;if(u+6>this.information.getSize())return!1;let g=this.extractNumericValueFromBitArray(u,6);return g>=16&&g<63}decodeAlphanumeric(u){let p=this.extractNumericValueFromBitArray(u,5);if(p===15)return new Et(u+5,Et.FNC1);if(p>=5&&p<15)return new Et(u+5,"0"+(p-5));let g=this.extractNumericValueFromBitArray(u,6);if(g>=32&&g<58)return new Et(u+6,""+(g+33));let b;switch(g){case 58:b="*";break;case 59:b=",";break;case 60:b="-";break;case 61:b=".";break;case 62:b="/";break;default:throw new tn("Decoding invalid alphanumeric value: "+g)}return new Et(u+6,b)}isAlphaTo646ToAlphaLatch(u){if(u+1>this.information.getSize())return!1;for(let p=0;p<5&&p+uthis.information.getSize())return!1;for(let p=u;pthis.information.getSize())return!1;for(let p=0;p<4&&p+u{p.forEach(E=>{b.getLeftChar().getValue()===E.getLeftChar().getValue()&&b.getRightChar().getValue()===E.getRightChar().getValue()&&b.getFinderPatter().getValue()===E.getFinderPatter().getValue()&&(g=!0)})}),g}}class kt extends Qe{constructor(u){super(...arguments),this.pairs=new Array(kt.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=u===!0}decodeRow(u,p,g){this.pairs.length=0,this.startFromEven=!1;try{return kt.constructResult(this.decodeRow2pairs(u,p))}catch(b){this.verbose&&console.log(b)}return this.pairs.length=0,this.startFromEven=!0,kt.constructResult(this.decodeRow2pairs(u,p))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(u,p){let g=!1;for(;!g;)try{this.pairs.push(this.retrieveNextPair(p,this.pairs,u))}catch(v){if(v instanceof ne){if(!this.pairs.length)throw new ne;g=!0}}if(this.checkChecksum())return this.pairs;let b;if(this.rows.length?b=!0:b=!1,this.storeRow(u,!1),b){let v=this.checkRowsBoolean(!1);if(v!=null||(v=this.checkRowsBoolean(!0),v!=null))return v}throw new ne}checkRowsBoolean(u){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,u&&(this.rows=this.rows.reverse());let p=null;try{p=this.checkRows(new Array,0)}catch(g){this.verbose&&console.log(g)}return u&&(this.rows=this.rows.reverse()),p}checkRows(u,p){for(let g=p;gp.length)continue;let g=!0;for(let b=0;bu){v=E.isEquivalent(this.pairs);break}b=E.isEquivalent(this.pairs),g++}v||b||kt.isPartialRow(this.pairs,this.rows)||(this.rows.push(g,new Qr(this.pairs,u,p)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(u,p){for(let g of p)if(g.getPairs().length!==u.length){for(let b of g.getPairs())for(let v of u)if(li.equals(b,v))break}}static isPartialRow(u,p){for(let g of p){let b=!0;for(let v of u){let E=!1;for(let k of g.getPairs())if(v.equals(k)){E=!0;break}if(!E){b=!1;break}}if(b)return!0}return!1}getRows(){return this.rows}static constructResult(u){let p=kn.buildBitArray(u),b=Ss(p).parseInformation(),v=u[0].getFinderPattern().getResultPoints(),E=u[u.length-1].getFinderPattern().getResultPoints(),k=[v[0],v[1],E[0],E[1]];return new Me(b,null,null,k,ze.RSS_EXPANDED,null)}checkChecksum(){let u=this.pairs.get(0),p=u.getLeftChar(),g=u.getRightChar();if(g==null)return!1;let b=g.getChecksumPortion(),v=2;for(let k=1;k=0?E=g:this.isEmptyPair(p)?E=0:E=p[p.length-1].getFinderPattern().getStartEnd()[1];let k=p.length%2!=0;this.startFromEven&&(k=!k);let P=!1;for(;E=0&&!u.get(M);)M--;M++,b=this.startEnd[0]-M,v=M,E=this.startEnd[1]}else v=this.startEnd[0],E=u.getNextUnset(this.startEnd[1]+1),b=E-this.startEnd[1];let k=this.getDecodeFinderCounters();C.arraycopy(k,0,k,1,k.length-1),k[0]=b;let P;try{P=this.parseFinderValue(k,kt.FINDER_PATTERNS)}catch{return null}return new Fn(P,[v,E],v,E,p)}decodeDataCharacter(u,p,g,b){let v=this.getDataCharacterCounters();for(let hi=0;hi.3)throw new ne;let M=this.getOddCounts(),W=this.getEvenCounts(),te=this.getOddRoundingErrors(),ae=this.getEvenRoundingErrors();for(let hi=0;hi8){if(Os>8.7)throw new ne;xa=8}let ql=hi/2;(hi&1)==0?(M[ql]=xa,te[ql]=Os-xa):(W[ql]=xa,ae[ql]=Os-xa)}this.adjustOddEvenCounts(E);let ve=4*p.getValue()+(g?0:2)+(b?0:1)-1,ke=0,Ie=0;for(let hi=M.length-1;hi>=0;hi--){if(kt.isNotA1left(p,g,b)){let Os=kt.WEIGHTS[ve][2*hi];Ie+=M[hi]*Os}ke+=M[hi]}let We=0;for(let hi=W.length-1;hi>=0;hi--)if(kt.isNotA1left(p,g,b)){let Os=kt.WEIGHTS[ve][2*hi+1];We+=W[hi]*Os}let ht=Ie+We;if((ke&1)!=0||ke>13||ke<4)throw new ne;let Yt=(13-ke)/2,Wt=kt.SYMBOL_WIDEST[Yt],zt=9-Wt,Dr=xn.getRSSvalue(M,Wt,!0),yr=xn.getRSSvalue(W,zt,!1),Ns=kt.EVEN_TOTAL_SUBSET[Yt],Ua=kt.GSUM[Yt],Js=Dr*Ns+yr+Ua;return new Gt(Js,ht)}static isNotA1left(u,p,g){return!(u.getValue()==0&&p&&g)}adjustOddEvenCounts(u){let p=ut.sum(new Int32Array(this.getOddCounts())),g=ut.sum(new Int32Array(this.getEvenCounts())),b=!1,v=!1;p>13?v=!0:p<4&&(b=!0);let E=!1,k=!1;g>13?k=!0:g<4&&(E=!0);let P=p+g-u,M=(p&1)==1,W=(g&1)==0;if(P==1)if(M){if(W)throw new ne;v=!0}else{if(!W)throw new ne;k=!0}else if(P==-1)if(M){if(W)throw new ne;b=!0}else{if(!W)throw new ne;E=!0}else if(P==0){if(M){if(!W)throw new ne;p1){for(let k of this.possibleRightPairs)if(k.getCount()>1&&wr.checkChecksum(E,k))return wr.constructResult(E,k)}throw new ne}static addOrTally(u,p){if(p==null)return;let g=!1;for(let b of u)if(b.getValue()===p.getValue()){b.incrementCount(),g=!0;break}g||u.push(p)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(u,p){let g=4537077*u.getValue()+p.getValue(),b=new String(g).toString(),v=new J;for(let M=13-b.length;M>0;M--)v.append("0");v.append(b);let E=0;for(let M=0;M<13;M++){let W=v.charAt(M).charCodeAt(0)-48;E+=(M&1)===0?3*W:W}E=10-E%10,E===10&&(E=0),v.append(E.toString());let k=u.getFinderPattern().getResultPoints(),P=p.getFinderPattern().getResultPoints();return new Me(v.toString(),null,0,[k[0],k[1],P[0],P[1]],ze.RSS_14,new Date().getTime())}static checkChecksum(u,p){let g=(u.getChecksumPortion()+16*p.getChecksumPortion())%79,b=9*u.getFinderPattern().getValue()+p.getFinderPattern().getValue();return b>72&&b--,b>8&&b--,g===b}decodePair(u,p,g,b){try{let v=this.findFinderPattern(u,p),E=this.parseFoundFinderPattern(u,g,p,v),k=b==null?null:b.get(q.NEED_RESULT_POINT_CALLBACK);if(k!=null){let W=(v[0]+v[1])/2;p&&(W=u.getSize()-1-W),k.foundPossibleResultPoint(new Dt(W,g))}let P=this.decodeDataCharacter(u,E,!0),M=this.decodeDataCharacter(u,E,!1);return new Pa(1597*P.getValue()+M.getValue(),P.getChecksumPortion()+4*M.getChecksumPortion(),E)}catch{return null}}decodeDataCharacter(u,p,g){let b=this.getDataCharacterCounters();for(let We=0;We8&&(Yt=8);let Wt=Math.floor(We/2);(We&1)===0?(k[Wt]=Yt,M[Wt]=ht-Yt):(P[Wt]=Yt,W[Wt]=ht-Yt)}this.adjustOddEvenCounts(g,v);let te=0,ae=0;for(let We=k.length-1;We>=0;We--)ae*=9,ae+=k[We],te+=k[We];let ve=0,ke=0;for(let We=P.length-1;We>=0;We--)ve*=9,ve+=P[We],ke+=P[We];let Ie=ae+3*ve;if(g){if((te&1)!==0||te>12||te<4)throw new ne;let We=(12-te)/2,ht=wr.OUTSIDE_ODD_WIDEST[We],Yt=9-ht,Wt=xn.getRSSvalue(k,ht,!1),zt=xn.getRSSvalue(P,Yt,!0),Dr=wr.OUTSIDE_EVEN_TOTAL_SUBSET[We],yr=wr.OUTSIDE_GSUM[We];return new Gt(Wt*Dr+zt+yr,Ie)}else{if((ke&1)!==0||ke>10||ke<4)throw new ne;let We=(10-ke)/2,ht=wr.INSIDE_ODD_WIDEST[We],Yt=9-ht,Wt=xn.getRSSvalue(k,ht,!0),zt=xn.getRSSvalue(P,Yt,!1),Dr=wr.INSIDE_ODD_TOTAL_SUBSET[We],yr=wr.INSIDE_GSUM[We];return new Gt(zt*Dr+Wt+yr,Ie)}}findFinderPattern(u,p){let g=this.getDecodeFinderCounters();g[0]=0,g[1]=0,g[2]=0,g[3]=0;let b=u.getSize(),v=!1,E=0;for(;E=0&&v!==u.get(E);)E--;E++;const k=b[0]-E,P=this.getDecodeFinderCounters(),M=new Int32Array(P.length);C.arraycopy(P,0,M,1,P.length-1),M[0]=k;const W=this.parseFinderValue(M,wr.FINDER_PATTERNS);let te=E,ae=b[1];return g&&(te=u.getSize()-1-te,ae=u.getSize()-1-ae),new Fn(W,[E,b[1]],te,ae,p)}adjustOddEvenCounts(u,p){let g=ut.sum(new Int32Array(this.getOddCounts())),b=ut.sum(new Int32Array(this.getEvenCounts())),v=!1,E=!1,k=!1,P=!1;u?(g>12?E=!0:g<4&&(v=!0),b>12?P=!0:b<4&&(k=!0)):(g>11?E=!0:g<5&&(v=!0),b>10?P=!0:b<4&&(k=!0));let M=g+b-p,W=(g&1)===(u?1:0),te=(b&1)===1;if(M===1)if(W){if(te)throw new ne;E=!0}else{if(!te)throw new ne;P=!0}else if(M===-1)if(W){if(te)throw new ne;v=!0}else{if(!te)throw new ne;k=!0}else if(M===0){if(W){if(!te)throw new ne;gu.reset())}}class uo extends re{constructor(u=500,p){super(new is(p),u,p)}}class hr{constructor(u,p,g){this.ecCodewords=u,this.ecBlocks=[p],g&&this.ecBlocks.push(g)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class Nr{constructor(u,p){this.count=u,this.dataCodewords=p}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class cr{constructor(u,p,g,b,v,E){this.versionNumber=u,this.symbolSizeRows=p,this.symbolSizeColumns=g,this.dataRegionSizeRows=b,this.dataRegionSizeColumns=v,this.ecBlocks=E;let k=0;const P=E.getECCodewords(),M=E.getECBlocks();for(let W of M)k+=W.getCount()*(W.getDataCodewords()+P);this.totalCodewords=k}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}static getVersionForDimensions(u,p){if((u&1)!==0||(p&1)!==0)throw new B;for(let g of cr.VERSIONS)if(g.symbolSizeRows===u&&g.symbolSizeColumns===p)return g;throw new B}toString(){return""+this.versionNumber}static buildVersions(){return[new cr(1,10,10,8,8,new hr(5,new Nr(1,3))),new cr(2,12,12,10,10,new hr(7,new Nr(1,5))),new cr(3,14,14,12,12,new hr(10,new Nr(1,8))),new cr(4,16,16,14,14,new hr(12,new Nr(1,12))),new cr(5,18,18,16,16,new hr(14,new Nr(1,18))),new cr(6,20,20,18,18,new hr(18,new Nr(1,22))),new cr(7,22,22,20,20,new hr(20,new Nr(1,30))),new cr(8,24,24,22,22,new hr(24,new Nr(1,36))),new cr(9,26,26,24,24,new hr(28,new Nr(1,44))),new cr(10,32,32,14,14,new hr(36,new Nr(1,62))),new cr(11,36,36,16,16,new hr(42,new Nr(1,86))),new cr(12,40,40,18,18,new hr(48,new Nr(1,114))),new cr(13,44,44,20,20,new hr(56,new Nr(1,144))),new cr(14,48,48,22,22,new hr(68,new Nr(1,174))),new cr(15,52,52,24,24,new hr(42,new Nr(2,102))),new cr(16,64,64,14,14,new hr(56,new Nr(2,140))),new cr(17,72,72,16,16,new hr(36,new Nr(4,92))),new cr(18,80,80,18,18,new hr(48,new Nr(4,114))),new cr(19,88,88,20,20,new hr(56,new Nr(4,144))),new cr(20,96,96,22,22,new hr(68,new Nr(4,174))),new cr(21,104,104,24,24,new hr(56,new Nr(6,136))),new cr(22,120,120,18,18,new hr(68,new Nr(6,175))),new cr(23,132,132,20,20,new hr(62,new Nr(8,163))),new cr(24,144,144,22,22,new hr(62,new Nr(8,156),new Nr(2,155))),new cr(25,8,18,6,16,new hr(7,new Nr(1,5))),new cr(26,8,32,6,14,new hr(11,new Nr(1,10))),new cr(27,12,26,10,24,new hr(14,new Nr(1,16))),new cr(28,12,36,10,16,new hr(18,new Nr(1,22))),new cr(29,16,36,14,16,new hr(24,new Nr(1,32))),new cr(30,16,48,14,22,new hr(28,new Nr(1,49)))]}}cr.VERSIONS=cr.buildVersions();class Re{constructor(u){const p=u.getHeight();if(p<8||p>144||(p&1)!==0)throw new B;this.version=Re.readVersion(u),this.mappingBitMatrix=this.extractDataRegion(u),this.readMappingMatrix=new ye(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(u){const p=u.getHeight(),g=u.getWidth();return cr.getVersionForDimensions(p,g)}readCodewords(){const u=new Int8Array(this.version.getTotalCodewords());let p=0,g=4,b=0;const v=this.mappingBitMatrix.getHeight(),E=this.mappingBitMatrix.getWidth();let k=!1,P=!1,M=!1,W=!1;do if(g===v&&b===0&&!k)u[p++]=this.readCorner1(v,E)&255,g-=2,b+=2,k=!0;else if(g===v-2&&b===0&&(E&3)!==0&&!P)u[p++]=this.readCorner2(v,E)&255,g-=2,b+=2,P=!0;else if(g===v+4&&b===2&&(E&7)===0&&!M)u[p++]=this.readCorner3(v,E)&255,g-=2,b+=2,M=!0;else if(g===v-2&&b===0&&(E&7)===4&&!W)u[p++]=this.readCorner4(v,E)&255,g-=2,b+=2,W=!0;else{do g=0&&!this.readMappingMatrix.get(b,g)&&(u[p++]=this.readUtah(g,b,v,E)&255),g-=2,b+=2;while(g>=0&&b=0&&b=0);g+=3,b+=1}while(g7?Ie-1:Ie;E[ht].codewords[Yt]=u[te++]}if(te!==u.length)throw new y;return E}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class rt{constructor(u){this.bytes=u,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(u){if(u<1||u>32||u>this.available())throw new y(""+u);let p=0,g=this.bitOffset,b=this.byteOffset;const v=this.bytes;if(g>0){const E=8-g,k=u>8-k<>P,u-=k,g+=k,g===8&&(g=0,b++)}if(u>0){for(;u>=8;)p=p<<8|v[b]&255,b++,u-=8;if(u>0){const E=8-u,k=255>>E<>E,g+=u}}return this.bitOffset=g,this.byteOffset=b,p}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var At;(function(ee){ee[ee.PAD_ENCODE=0]="PAD_ENCODE",ee[ee.ASCII_ENCODE=1]="ASCII_ENCODE",ee[ee.C40_ENCODE=2]="C40_ENCODE",ee[ee.TEXT_ENCODE=3]="TEXT_ENCODE",ee[ee.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",ee[ee.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",ee[ee.BASE256_ENCODE=6]="BASE256_ENCODE"})(At||(At={}));class nn{static decode(u){const p=new rt(u),g=new J,b=new J,v=new Array;let E=At.ASCII_ENCODE;do if(E===At.ASCII_ENCODE)E=this.decodeAsciiSegment(p,g,b);else{switch(E){case At.C40_ENCODE:this.decodeC40Segment(p,g);break;case At.TEXT_ENCODE:this.decodeTextSegment(p,g);break;case At.ANSIX12_ENCODE:this.decodeAnsiX12Segment(p,g);break;case At.EDIFACT_ENCODE:this.decodeEdifactSegment(p,g);break;case At.BASE256_ENCODE:this.decodeBase256Segment(p,g,v);break;default:throw new B}E=At.ASCII_ENCODE}while(E!==At.PAD_ENCODE&&p.available()>0);return b.length()>0&&g.append(b.toString()),new ft(u,g.toString(),v.length===0?null:v,null)}static decodeAsciiSegment(u,p,g){let b=!1;do{let v=u.readBits(8);if(v===0)throw new B;if(v<=128)return b&&(v+=128),p.append(String.fromCharCode(v-1)),At.ASCII_ENCODE;if(v===129)return At.PAD_ENCODE;if(v<=229){const E=v-130;E<10&&p.append("0"),p.append(""+E)}else switch(v){case 230:return At.C40_ENCODE;case 231:return At.BASE256_ENCODE;case 232:p.append("");break;case 233:case 234:break;case 235:b=!0;break;case 236:p.append("[)>05"),g.insert(0,"");break;case 237:p.append("[)>06"),g.insert(0,"");break;case 238:return At.ANSIX12_ENCODE;case 239:return At.TEXT_ENCODE;case 240:return At.EDIFACT_ENCODE;case 241:break;default:if(v!==254||u.available()!==0)throw new B;break}}while(u.available()>0);return At.ASCII_ENCODE}static decodeC40Segment(u,p){let g=!1;const b=[];let v=0;do{if(u.available()===8)return;const E=u.readBits(8);if(E===254)return;this.parseTwoBytes(E,u.readBits(8),b);for(let k=0;k<3;k++){const P=b[k];switch(v){case 0:if(P<3)v=P+1;else if(P0)}static decodeTextSegment(u,p){let g=!1,b=[],v=0;do{if(u.available()===8)return;const E=u.readBits(8);if(E===254)return;this.parseTwoBytes(E,u.readBits(8),b);for(let k=0;k<3;k++){const P=b[k];switch(v){case 0:if(P<3)v=P+1;else if(P0)}static decodeAnsiX12Segment(u,p){const g=[];do{if(u.available()===8)return;const b=u.readBits(8);if(b===254)return;this.parseTwoBytes(b,u.readBits(8),g);for(let v=0;v<3;v++){const E=g[v];switch(E){case 0:p.append("\r");break;case 1:p.append("*");break;case 2:p.append(">");break;case 3:p.append(" ");break;default:if(E<14)p.append(String.fromCharCode(E+44));else if(E<40)p.append(String.fromCharCode(E+51));else throw new B;break}}}while(u.available()>0)}static parseTwoBytes(u,p,g){let b=(u<<8)+p-1,v=Math.floor(b/1600);g[0]=v,b-=v*1600,v=Math.floor(b/40),g[1]=v,g[2]=b-v*40}static decodeEdifactSegment(u,p){do{if(u.available()<=16)return;for(let g=0;g<4;g++){let b=u.readBits(6);if(b===31){const v=8-u.getBitOffset();v!==8&&u.readBits(v);return}(b&32)===0&&(b|=64),p.append(String.fromCharCode(b))}}while(u.available()>0)}static decodeBase256Segment(u,p,g){let b=1+u.getByteOffset();const v=this.unrandomize255State(u.readBits(8),b++);let E;if(v===0?E=u.available()/8|0:v<250?E=v:E=250*(v-249)+this.unrandomize255State(u.readBits(8),b++),E<0)throw new B;const k=new Uint8Array(E);for(let P=0;P=0?b:b+256}}nn.C40_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],nn.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],nn.TEXT_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],nn.TEXT_SHIFT2_SET_CHARS=nn.C40_SHIFT2_SET_CHARS,nn.TEXT_SHIFT3_SET_CHARS=["`","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","|","}","~",""];class Nn{constructor(){this.rsDecoder=new Pt(Vt.DATA_MATRIX_FIELD_256)}decode(u){const p=new Re(u),g=p.getVersion(),b=p.readCodewords(),v=mt.getDataBlocks(b,g);let E=0;for(let M of v)E+=M.getNumDataCodewords();const k=new Uint8Array(E),P=v.length;for(let M=0;Mk&&(W=k,te[0]=p,te[1]=g,te[2]=b,te[3]=v),W>P&&(W=P,te[0]=g,te[1]=b,te[2]=v,te[3]=p),W>M&&(te[0]=b,te[1]=v,te[2]=p,te[3]=g),te}detectSolid2(u){let p=u[0],g=u[1],b=u[2],v=u[3],E=this.transitionsBetween(p,v),k=Be.shiftPoint(g,b,(E+1)*4),P=Be.shiftPoint(b,g,(E+1)*4),M=this.transitionsBetween(k,p),W=this.transitionsBetween(P,v);return Mve?W:te}shiftToModuleCenter(u){let p=u[0],g=u[1],b=u[2],v=u[3],E=this.transitionsBetween(p,v)+1,k=this.transitionsBetween(b,v)+1,P=Be.shiftPoint(p,g,k*4),M=Be.shiftPoint(b,g,E*4);E=this.transitionsBetween(P,v)+1,k=this.transitionsBetween(M,v)+1,(E&1)===1&&(E+=1),(k&1)===1&&(k+=1);let W=(p.getX()+g.getX()+b.getX()+v.getX())/4,te=(p.getY()+g.getY()+b.getY()+v.getY())/4;p=Be.moveAway(p,W,te),g=Be.moveAway(g,W,te),b=Be.moveAway(b,W,te),v=Be.moveAway(v,W,te);let ae,ve;return P=Be.shiftPoint(p,g,k*4),P=Be.shiftPoint(P,v,E*4),ae=Be.shiftPoint(g,p,k*4),ae=Be.shiftPoint(ae,b,E*4),M=Be.shiftPoint(b,v,k*4),M=Be.shiftPoint(M,g,E*4),ve=Be.shiftPoint(v,b,k*4),ve=Be.shiftPoint(ve,p,E*4),[P,ae,M,ve]}isValid(u){return u.getX()>=0&&u.getX()0&&u.getY()Math.abs(v-g);if(k){let Ie=g;g=b,b=Ie,Ie=v,v=E,E=Ie}let P=Math.abs(v-g),M=Math.abs(E-b),W=-P/2,te=b0){if(We===E)break;We+=te,W-=P}}return ve}}class Bt{constructor(){this.decoder=new Nn}decode(u,p=null){let g,b;if(p!=null&&p.has(q.PURE_BARCODE)){const M=Bt.extractPureBits(u.getBlackMatrix());g=this.decoder.decode(M),b=Bt.NO_POINTS}else{const M=new Be(u.getBlackMatrix()).detect();g=this.decoder.decode(M.getBits()),b=M.getPoints()}const v=g.getRawBytes(),E=new Me(g.getText(),v,8*v.length,b,ze.DATA_MATRIX,C.currentTimeMillis()),k=g.getByteSegments();k!=null&&E.putMetadata(It.BYTE_SEGMENTS,k);const P=g.getECLevel();return P!=null&&E.putMetadata(It.ERROR_CORRECTION_LEVEL,P),E}reset(){}static extractPureBits(u){const p=u.getTopLeftOnBit(),g=u.getBottomRightOnBit();if(p==null||g==null)throw new ne;const b=this.moduleSize(p,u);let v=p[1];const E=g[1];let k=p[0];const M=(g[0]-k+1)/b,W=(E-v+1)/b;if(M<=0||W<=0)throw new ne;const te=b/2;v+=te,k+=te;const ae=new ye(M,W);for(let ve=0;ve=Ln.FOR_BITS.size)throw new y;return Ln.FOR_BITS.get(u)}}Ln.FOR_BITS=new Map,Ln.FOR_VALUE=new Map,Ln.L=new Ln(jn.L,"L",1),Ln.M=new Ln(jn.M,"M",0),Ln.Q=new Ln(jn.Q,"Q",3),Ln.H=new Ln(jn.H,"H",2);class xr{constructor(u){this.errorCorrectionLevel=Ln.forBits(u>>3&3),this.dataMask=u&7}static numBitsDiffering(u,p){return L.bitCount(u^p)}static decodeFormatInformation(u,p){const g=xr.doDecodeFormatInformation(u,p);return g!==null?g:xr.doDecodeFormatInformation(u^xr.FORMAT_INFO_MASK_QR,p^xr.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(u,p){let g=Number.MAX_SAFE_INTEGER,b=0;for(const v of xr.FORMAT_INFO_DECODE_LOOKUP){const E=v[0];if(E===u||E===p)return new xr(v[1]);let k=xr.numBitsDiffering(u,E);k40)throw new y;return fn.VERSIONS[u-1]}static decodeVersionInformation(u){let p=Number.MAX_SAFE_INTEGER,g=0;for(let b=0;b6&&(p.setRegion(u-11,0,3,6),p.setRegion(0,u-11,6,3)),p}toString(){return""+this.versionNumber}}fn.VERSION_DECODE_INFO=Int32Array.from([31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017]),fn.VERSIONS=[new fn(1,new Int32Array(0),new Le(7,new fe(1,19)),new Le(10,new fe(1,16)),new Le(13,new fe(1,13)),new Le(17,new fe(1,9))),new fn(2,Int32Array.from([6,18]),new Le(10,new fe(1,34)),new Le(16,new fe(1,28)),new Le(22,new fe(1,22)),new Le(28,new fe(1,16))),new fn(3,Int32Array.from([6,22]),new Le(15,new fe(1,55)),new Le(26,new fe(1,44)),new Le(18,new fe(2,17)),new Le(22,new fe(2,13))),new fn(4,Int32Array.from([6,26]),new Le(20,new fe(1,80)),new Le(18,new fe(2,32)),new Le(26,new fe(2,24)),new Le(16,new fe(4,9))),new fn(5,Int32Array.from([6,30]),new Le(26,new fe(1,108)),new Le(24,new fe(2,43)),new Le(18,new fe(2,15),new fe(2,16)),new Le(22,new fe(2,11),new fe(2,12))),new fn(6,Int32Array.from([6,34]),new Le(18,new fe(2,68)),new Le(16,new fe(4,27)),new Le(24,new fe(4,19)),new Le(28,new fe(4,15))),new fn(7,Int32Array.from([6,22,38]),new Le(20,new fe(2,78)),new Le(18,new fe(4,31)),new Le(18,new fe(2,14),new fe(4,15)),new Le(26,new fe(4,13),new fe(1,14))),new fn(8,Int32Array.from([6,24,42]),new Le(24,new fe(2,97)),new Le(22,new fe(2,38),new fe(2,39)),new Le(22,new fe(4,18),new fe(2,19)),new Le(26,new fe(4,14),new fe(2,15))),new fn(9,Int32Array.from([6,26,46]),new Le(30,new fe(2,116)),new Le(22,new fe(3,36),new fe(2,37)),new Le(20,new fe(4,16),new fe(4,17)),new Le(24,new fe(4,12),new fe(4,13))),new fn(10,Int32Array.from([6,28,50]),new Le(18,new fe(2,68),new fe(2,69)),new Le(26,new fe(4,43),new fe(1,44)),new Le(24,new fe(6,19),new fe(2,20)),new Le(28,new fe(6,15),new fe(2,16))),new fn(11,Int32Array.from([6,30,54]),new Le(20,new fe(4,81)),new Le(30,new fe(1,50),new fe(4,51)),new Le(28,new fe(4,22),new fe(4,23)),new Le(24,new fe(3,12),new fe(8,13))),new fn(12,Int32Array.from([6,32,58]),new Le(24,new fe(2,92),new fe(2,93)),new Le(22,new fe(6,36),new fe(2,37)),new Le(26,new fe(4,20),new fe(6,21)),new Le(28,new fe(7,14),new fe(4,15))),new fn(13,Int32Array.from([6,34,62]),new Le(26,new fe(4,107)),new Le(22,new fe(8,37),new fe(1,38)),new Le(24,new fe(8,20),new fe(4,21)),new Le(22,new fe(12,11),new fe(4,12))),new fn(14,Int32Array.from([6,26,46,66]),new Le(30,new fe(3,115),new fe(1,116)),new Le(24,new fe(4,40),new fe(5,41)),new Le(20,new fe(11,16),new fe(5,17)),new Le(24,new fe(11,12),new fe(5,13))),new fn(15,Int32Array.from([6,26,48,70]),new Le(22,new fe(5,87),new fe(1,88)),new Le(24,new fe(5,41),new fe(5,42)),new Le(30,new fe(5,24),new fe(7,25)),new Le(24,new fe(11,12),new fe(7,13))),new fn(16,Int32Array.from([6,26,50,74]),new Le(24,new fe(5,98),new fe(1,99)),new Le(28,new fe(7,45),new fe(3,46)),new Le(24,new fe(15,19),new fe(2,20)),new Le(30,new fe(3,15),new fe(13,16))),new fn(17,Int32Array.from([6,30,54,78]),new Le(28,new fe(1,107),new fe(5,108)),new Le(28,new fe(10,46),new fe(1,47)),new Le(28,new fe(1,22),new fe(15,23)),new Le(28,new fe(2,14),new fe(17,15))),new fn(18,Int32Array.from([6,30,56,82]),new Le(30,new fe(5,120),new fe(1,121)),new Le(26,new fe(9,43),new fe(4,44)),new Le(28,new fe(17,22),new fe(1,23)),new Le(28,new fe(2,14),new fe(19,15))),new fn(19,Int32Array.from([6,30,58,86]),new Le(28,new fe(3,113),new fe(4,114)),new Le(26,new fe(3,44),new fe(11,45)),new Le(26,new fe(17,21),new fe(4,22)),new Le(26,new fe(9,13),new fe(16,14))),new fn(20,Int32Array.from([6,34,62,90]),new Le(28,new fe(3,107),new fe(5,108)),new Le(26,new fe(3,41),new fe(13,42)),new Le(30,new fe(15,24),new fe(5,25)),new Le(28,new fe(15,15),new fe(10,16))),new fn(21,Int32Array.from([6,28,50,72,94]),new Le(28,new fe(4,116),new fe(4,117)),new Le(26,new fe(17,42)),new Le(28,new fe(17,22),new fe(6,23)),new Le(30,new fe(19,16),new fe(6,17))),new fn(22,Int32Array.from([6,26,50,74,98]),new Le(28,new fe(2,111),new fe(7,112)),new Le(28,new fe(17,46)),new Le(30,new fe(7,24),new fe(16,25)),new Le(24,new fe(34,13))),new fn(23,Int32Array.from([6,30,54,78,102]),new Le(30,new fe(4,121),new fe(5,122)),new Le(28,new fe(4,47),new fe(14,48)),new Le(30,new fe(11,24),new fe(14,25)),new Le(30,new fe(16,15),new fe(14,16))),new fn(24,Int32Array.from([6,28,54,80,106]),new Le(30,new fe(6,117),new fe(4,118)),new Le(28,new fe(6,45),new fe(14,46)),new Le(30,new fe(11,24),new fe(16,25)),new Le(30,new fe(30,16),new fe(2,17))),new fn(25,Int32Array.from([6,32,58,84,110]),new Le(26,new fe(8,106),new fe(4,107)),new Le(28,new fe(8,47),new fe(13,48)),new Le(30,new fe(7,24),new fe(22,25)),new Le(30,new fe(22,15),new fe(13,16))),new fn(26,Int32Array.from([6,30,58,86,114]),new Le(28,new fe(10,114),new fe(2,115)),new Le(28,new fe(19,46),new fe(4,47)),new Le(28,new fe(28,22),new fe(6,23)),new Le(30,new fe(33,16),new fe(4,17))),new fn(27,Int32Array.from([6,34,62,90,118]),new Le(30,new fe(8,122),new fe(4,123)),new Le(28,new fe(22,45),new fe(3,46)),new Le(30,new fe(8,23),new fe(26,24)),new Le(30,new fe(12,15),new fe(28,16))),new fn(28,Int32Array.from([6,26,50,74,98,122]),new Le(30,new fe(3,117),new fe(10,118)),new Le(28,new fe(3,45),new fe(23,46)),new Le(30,new fe(4,24),new fe(31,25)),new Le(30,new fe(11,15),new fe(31,16))),new fn(29,Int32Array.from([6,30,54,78,102,126]),new Le(30,new fe(7,116),new fe(7,117)),new Le(28,new fe(21,45),new fe(7,46)),new Le(30,new fe(1,23),new fe(37,24)),new Le(30,new fe(19,15),new fe(26,16))),new fn(30,Int32Array.from([6,26,52,78,104,130]),new Le(30,new fe(5,115),new fe(10,116)),new Le(28,new fe(19,47),new fe(10,48)),new Le(30,new fe(15,24),new fe(25,25)),new Le(30,new fe(23,15),new fe(25,16))),new fn(31,Int32Array.from([6,30,56,82,108,134]),new Le(30,new fe(13,115),new fe(3,116)),new Le(28,new fe(2,46),new fe(29,47)),new Le(30,new fe(42,24),new fe(1,25)),new Le(30,new fe(23,15),new fe(28,16))),new fn(32,Int32Array.from([6,34,60,86,112,138]),new Le(30,new fe(17,115)),new Le(28,new fe(10,46),new fe(23,47)),new Le(30,new fe(10,24),new fe(35,25)),new Le(30,new fe(19,15),new fe(35,16))),new fn(33,Int32Array.from([6,30,58,86,114,142]),new Le(30,new fe(17,115),new fe(1,116)),new Le(28,new fe(14,46),new fe(21,47)),new Le(30,new fe(29,24),new fe(19,25)),new Le(30,new fe(11,15),new fe(46,16))),new fn(34,Int32Array.from([6,34,62,90,118,146]),new Le(30,new fe(13,115),new fe(6,116)),new Le(28,new fe(14,46),new fe(23,47)),new Le(30,new fe(44,24),new fe(7,25)),new Le(30,new fe(59,16),new fe(1,17))),new fn(35,Int32Array.from([6,30,54,78,102,126,150]),new Le(30,new fe(12,121),new fe(7,122)),new Le(28,new fe(12,47),new fe(26,48)),new Le(30,new fe(39,24),new fe(14,25)),new Le(30,new fe(22,15),new fe(41,16))),new fn(36,Int32Array.from([6,24,50,76,102,128,154]),new Le(30,new fe(6,121),new fe(14,122)),new Le(28,new fe(6,47),new fe(34,48)),new Le(30,new fe(46,24),new fe(10,25)),new Le(30,new fe(2,15),new fe(64,16))),new fn(37,Int32Array.from([6,28,54,80,106,132,158]),new Le(30,new fe(17,122),new fe(4,123)),new Le(28,new fe(29,46),new fe(14,47)),new Le(30,new fe(49,24),new fe(10,25)),new Le(30,new fe(24,15),new fe(46,16))),new fn(38,Int32Array.from([6,32,58,84,110,136,162]),new Le(30,new fe(4,122),new fe(18,123)),new Le(28,new fe(13,46),new fe(32,47)),new Le(30,new fe(48,24),new fe(14,25)),new Le(30,new fe(42,15),new fe(32,16))),new fn(39,Int32Array.from([6,26,54,82,110,138,166]),new Le(30,new fe(20,117),new fe(4,118)),new Le(28,new fe(40,47),new fe(7,48)),new Le(30,new fe(43,24),new fe(22,25)),new Le(30,new fe(10,15),new fe(67,16))),new fn(40,Int32Array.from([6,30,58,86,114,142,170]),new Le(30,new fe(19,118),new fe(6,119)),new Le(28,new fe(18,47),new fe(31,48)),new Le(30,new fe(34,24),new fe(34,25)),new Le(30,new fe(20,15),new fe(61,16)))];var xi;(function(ee){ee[ee.DATA_MASK_000=0]="DATA_MASK_000",ee[ee.DATA_MASK_001=1]="DATA_MASK_001",ee[ee.DATA_MASK_010=2]="DATA_MASK_010",ee[ee.DATA_MASK_011=3]="DATA_MASK_011",ee[ee.DATA_MASK_100=4]="DATA_MASK_100",ee[ee.DATA_MASK_101=5]="DATA_MASK_101",ee[ee.DATA_MASK_110=6]="DATA_MASK_110",ee[ee.DATA_MASK_111=7]="DATA_MASK_111"})(xi||(xi={}));class Ui{constructor(u,p){this.value=u,this.isMasked=p}unmaskBitMatrix(u,p){for(let g=0;g(ee+u&1)===0)],[xi.DATA_MASK_001,new Ui(xi.DATA_MASK_001,(ee,u)=>(ee&1)===0)],[xi.DATA_MASK_010,new Ui(xi.DATA_MASK_010,(ee,u)=>u%3===0)],[xi.DATA_MASK_011,new Ui(xi.DATA_MASK_011,(ee,u)=>(ee+u)%3===0)],[xi.DATA_MASK_100,new Ui(xi.DATA_MASK_100,(ee,u)=>(Math.floor(ee/2)+Math.floor(u/3)&1)===0)],[xi.DATA_MASK_101,new Ui(xi.DATA_MASK_101,(ee,u)=>ee*u%6===0)],[xi.DATA_MASK_110,new Ui(xi.DATA_MASK_110,(ee,u)=>ee*u%6<3)],[xi.DATA_MASK_111,new Ui(xi.DATA_MASK_111,(ee,u)=>(ee+u+ee*u%3&1)===0)]]);class Bi{constructor(u){const p=u.getHeight();if(p<21||(p&3)!==1)throw new B;this.bitMatrix=u}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let u=0;for(let v=0;v<6;v++)u=this.copyBit(v,8,u);u=this.copyBit(7,8,u),u=this.copyBit(8,8,u),u=this.copyBit(8,7,u);for(let v=5;v>=0;v--)u=this.copyBit(8,v,u);const p=this.bitMatrix.getHeight();let g=0;const b=p-7;for(let v=p-1;v>=b;v--)g=this.copyBit(8,v,g);for(let v=p-8;v=0;E--)for(let k=u-9;k>=b;k--)g=this.copyBit(k,E,g);let v=fn.decodeVersionInformation(g);if(v!==null&&v.getDimensionForVersion()===u)return this.parsedVersion=v,v;g=0;for(let E=5;E>=0;E--)for(let k=u-9;k>=b;k--)g=this.copyBit(E,k,g);if(v=fn.decodeVersionInformation(g),v!==null&&v.getDimensionForVersion()===u)return this.parsedVersion=v,v;throw new B}copyBit(u,p,g){return(this.isMirror?this.bitMatrix.get(p,u):this.bitMatrix.get(u,p))?g<<1|1:g<<1}readCodewords(){const u=this.readFormatInformation(),p=this.readVersion(),g=Ui.values.get(u.getDataMask()),b=this.bitMatrix.getHeight();g.unmaskBitMatrix(this.bitMatrix,b);const v=p.buildFunctionPattern();let E=!0;const k=new Uint8Array(p.getTotalCodewords());let P=0,M=0,W=0;for(let te=b-1;te>0;te-=2){te===6&&te--;for(let ae=0;ae=0&&k[W].codewords.length!==M;)W--;W++;const te=M-b.getECCodewordsPerBlock();let ae=0;for(let ke=0;keu.available())throw new B;const b=new Uint8Array(2*g);let v=0;for(;g>0;){const E=u.readBits(13);let k=E/96<<8&4294967295|E%96;k<959?k+=41377:k+=42657,b[v]=k>>8&255,b[v+1]=k&255,v+=2,g--}try{p.append(Y.decode(b,X.GB2312))}catch(E){throw new B(E)}}static decodeKanjiSegment(u,p,g){if(g*13>u.available())throw new B;const b=new Uint8Array(2*g);let v=0;for(;g>0;){const E=u.readBits(13);let k=E/192<<8&4294967295|E%192;k<7936?k+=33088:k+=49472,b[v]=k>>8,b[v+1]=k,v+=2,g--}try{p.append(Y.decode(b,X.SHIFT_JIS))}catch(E){throw new B(E)}}static decodeByteSegment(u,p,g,b,v,E){if(8*g>u.available())throw new B;const k=new Uint8Array(g);for(let M=0;M=fr.ALPHANUMERIC_CHARS.length)throw new B;return fr.ALPHANUMERIC_CHARS[u]}static decodeAlphanumericSegment(u,p,g,b){const v=p.length();for(;g>1;){if(u.available()<11)throw new B;const E=u.readBits(11);p.append(fr.toAlphaNumericChar(Math.floor(E/45))),p.append(fr.toAlphaNumericChar(E%45)),g-=2}if(g===1){if(u.available()<6)throw new B;p.append(fr.toAlphaNumericChar(u.readBits(6)))}if(b)for(let E=v;E=3;){if(u.available()<10)throw new B;const b=u.readBits(10);if(b>=1e3)throw new B;p.append(fr.toAlphaNumericChar(Math.floor(b/100))),p.append(fr.toAlphaNumericChar(Math.floor(b/10)%10)),p.append(fr.toAlphaNumericChar(b%10)),g-=3}if(g===2){if(u.available()<7)throw new B;const b=u.readBits(7);if(b>=100)throw new B;p.append(fr.toAlphaNumericChar(Math.floor(b/10))),p.append(fr.toAlphaNumericChar(b%10))}else if(g===1){if(u.available()<4)throw new B;const b=u.readBits(4);if(b>=10)throw new B;p.append(fr.toAlphaNumericChar(b))}}static parseECIValue(u){const p=u.readBits(8);if((p&128)===0)return p&127;if((p&192)===128){const g=u.readBits(8);return(p&63)<<8&4294967295|g}if((p&224)===192){const g=u.readBits(16);return(p&31)<<16&4294967295|g}throw new B}}fr.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",fr.GB2312_SUBSET=1;class Oa{constructor(u){this.mirrored=u}isMirrored(){return this.mirrored}applyMirroredCorrection(u){if(!this.mirrored||u===null||u.length<3)return;const p=u[0];u[0]=u[2],u[2]=p}}class ra{constructor(){this.rsDecoder=new Pt(Vt.QR_CODE_FIELD_256)}decodeBooleanArray(u,p){return this.decodeBitMatrix(ye.parseFromBooleanArray(u),p)}decodeBitMatrix(u,p){const g=new Bi(u);let b=null;try{return this.decodeBitMatrixParser(g,p)}catch(v){b=v}try{g.remask(),g.setMirror(!0),g.readVersion(),g.readFormatInformation(),g.mirror();const v=this.decodeBitMatrixParser(g,p);return v.setOther(new Oa(!0)),v}catch(v){throw b!==null?b:v}}decodeBitMatrixParser(u,p){const g=u.readVersion(),b=u.readFormatInformation().getErrorCorrectionLevel(),v=u.readCodewords(),E=Lr.getDataBlocks(v,g,b);let k=0;for(const W of E)k+=W.getNumDataCodewords();const P=new Uint8Array(k);let M=0;for(const W of E){const te=W.getCodewords(),ae=W.getNumDataCodewords();this.correctErrors(te,ae);for(let ve=0;ve=g)return!1;return!0}crossCheckVertical(u,p,g,b){const v=this.image,E=v.getHeight(),k=this.crossCheckStateCount;k[0]=0,k[1]=0,k[2]=0;let P=u;for(;P>=0&&v.get(p,P)&&k[1]<=g;)k[1]++,P--;if(P<0||k[1]>g)return NaN;for(;P>=0&&!v.get(p,P)&&k[0]<=g;)k[0]++,P--;if(k[0]>g)return NaN;for(P=u+1;Pg)return NaN;for(;Pg)return NaN;const M=k[0]+k[1]+k[2];return 5*Math.abs(M-b)>=2*b?NaN:this.foundPatternCross(k)?Cs.centerFromEnd(k,P):NaN}handlePossibleCenter(u,p,g){const b=u[0]+u[1]+u[2],v=Cs.centerFromEnd(u,g),E=this.crossCheckVertical(p,v,2*u[1],b);if(!isNaN(E)){const k=(u[0]+u[1]+u[2])/3;for(const M of this.possibleCenters)if(M.aboutEquals(k,E,v))return M.combineEstimate(E,v,k);const P=new ia(v,E,k);this.possibleCenters.push(P),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(P)}return null}}class Qo extends Dt{constructor(u,p,g,b){super(u,p),this.estimatedModuleSize=g,this.count=b,b===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(u,p,g){if(Math.abs(p-this.getY())<=u&&Math.abs(g-this.getX())<=u){const b=Math.abs(u-this.estimatedModuleSize);return b<=1||b<=this.estimatedModuleSize}return!1}combineEstimate(u,p,g){const b=this.count+1,v=(this.count*this.getX()+p)/b,E=(this.count*this.getY()+u)/b,k=(this.count*this.estimatedModuleSize+g)/b;return new Qo(v,E,k,b)}}class fa{constructor(u){this.bottomLeft=u[0],this.topLeft=u[1],this.topRight=u[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class ci{constructor(u,p){this.image=u,this.resultPointCallback=p,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=p}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(u){const p=u!=null&&u.get(q.TRY_HARDER)!==void 0,g=u!=null&&u.get(q.PURE_BARCODE)!==void 0,b=this.image,v=b.getHeight(),E=b.getWidth();let k=Math.floor(3*v/(4*ci.MAX_MODULES));(kM[2]&&(te+=Ie-M[2]-k,ve=E-1)}else{M[0]=M[2],M[1]=M[3],M[2]=M[4],M[3]=1,M[4]=0,ae=3;continue}ae=0,M[0]=0,M[1]=0,M[2]=0,M[3]=0,M[4]=0}else M[0]=M[2],M[1]=M[3],M[2]=M[4],M[3]=1,M[4]=0,ae=3;else M[++ae]++;else M[ae]++;ci.foundPatternCross(M)&&this.handlePossibleCenter(M,te,E,g)===!0&&(k=M[0],this.hasSkipped&&(P=this.haveMultiplyConfirmedCenters()))}const W=this.selectBestPatterns();return Dt.orderBestPatterns(W),new fa(W)}static centerFromEnd(u,p){return p-u[4]-u[3]-u[2]/2}static foundPatternCross(u){let p=0;for(let v=0;v<5;v++){const E=u[v];if(E===0)return!1;p+=E}if(p<7)return!1;const g=p/7,b=g/2;return Math.abs(g-u[0])=E&&p>=E&&k.get(p-E,u-E);)v[2]++,E++;if(u=E&&p>=E&&!k.get(p-E,u-E)&&v[1]<=g;)v[1]++,E++;if(ug)return!1;for(;u>=E&&p>=E&&k.get(p-E,u-E)&&v[0]<=g;)v[0]++,E++;if(v[0]>g)return!1;const P=k.getHeight(),M=k.getWidth();for(E=1;u+E=P||p+E>=M)return!1;for(;u+E=P||p+E>=M||v[3]>=g)return!1;for(;u+E=g)return!1;const W=v[0]+v[1]+v[2]+v[3]+v[4];return Math.abs(W-b)<2*b&&ci.foundPatternCross(v)}crossCheckVertical(u,p,g,b){const v=this.image,E=v.getHeight(),k=this.getCrossCheckStateCount();let P=u;for(;P>=0&&v.get(p,P);)k[2]++,P--;if(P<0)return NaN;for(;P>=0&&!v.get(p,P)&&k[1]<=g;)k[1]++,P--;if(P<0||k[1]>g)return NaN;for(;P>=0&&v.get(p,P)&&k[0]<=g;)k[0]++,P--;if(k[0]>g)return NaN;for(P=u+1;P=g)return NaN;for(;P=g)return NaN;const M=k[0]+k[1]+k[2]+k[3]+k[4];return 5*Math.abs(M-b)>=2*b?NaN:ci.foundPatternCross(k)?ci.centerFromEnd(k,P):NaN}crossCheckHorizontal(u,p,g,b){const v=this.image,E=v.getWidth(),k=this.getCrossCheckStateCount();let P=u;for(;P>=0&&v.get(P,p);)k[2]++,P--;if(P<0)return NaN;for(;P>=0&&!v.get(P,p)&&k[1]<=g;)k[1]++,P--;if(P<0||k[1]>g)return NaN;for(;P>=0&&v.get(P,p)&&k[0]<=g;)k[0]++,P--;if(k[0]>g)return NaN;for(P=u+1;P=g)return NaN;for(;P=g)return NaN;const M=k[0]+k[1]+k[2]+k[3]+k[4];return 5*Math.abs(M-b)>=b?NaN:ci.foundPatternCross(k)?ci.centerFromEnd(k,P):NaN}handlePossibleCenter(u,p,g,b){const v=u[0]+u[1]+u[2]+u[3]+u[4];let E=ci.centerFromEnd(u,g),k=this.crossCheckVertical(p,Math.floor(E),u[2],v);if(!isNaN(k)&&(E=this.crossCheckHorizontal(Math.floor(E),Math.floor(k),u[2],v),!isNaN(E)&&(!b||this.crossCheckDiagonal(Math.floor(k),Math.floor(E),u[2],v)))){const P=v/7;let M=!1;const W=this.possibleCenters;for(let te=0,ae=W.length;te=ci.CENTER_QUORUM)if(p==null)p=g;else return this.hasSkipped=!0,Math.floor((Math.abs(p.getX()-g.getX())-Math.abs(p.getY()-g.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let u=0,p=0;const g=this.possibleCenters.length;for(const E of this.possibleCenters)E.getCount()>=ci.CENTER_QUORUM&&(u++,p+=E.getEstimatedModuleSize());if(u<3)return!1;const b=p/g;let v=0;for(const E of this.possibleCenters)v+=Math.abs(E.getEstimatedModuleSize()-b);return v<=.05*p}selectBestPatterns(){const u=this.possibleCenters.length;if(u<3)throw new ne;const p=this.possibleCenters;let g;if(u>3){let b=0,v=0;for(const P of this.possibleCenters){const M=P.getEstimatedModuleSize();b+=M,v+=M*M}g=b/u;let E=Math.sqrt(v/u-g*g);p.sort((P,M)=>{const W=Math.abs(M.getEstimatedModuleSize()-g),te=Math.abs(P.getEstimatedModuleSize()-g);return Wte?1:0});const k=Math.max(.2*g,E);for(let P=0;P3;P++){const M=p[P];Math.abs(M.getEstimatedModuleSize()-g)>k&&(p.splice(P,1),P--)}}if(p.length>3){let b=0;for(const v of p)b+=v.getEstimatedModuleSize();g=b/p.length,p.sort((v,E)=>{if(E.getCount()===v.getCount()){const k=Math.abs(E.getEstimatedModuleSize()-g),P=Math.abs(v.getEstimatedModuleSize()-g);return kP?-1:0}else return E.getCount()-v.getCount()}),p.splice(3)}return[p[0],p[1],p[2]]}}ci.CENTER_QUORUM=2,ci.MIN_SKIP=3,ci.MAX_MODULES=57;class js{constructor(u){this.image=u}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(u){this.resultPointCallback=u==null?null:u.get(q.NEED_RESULT_POINT_CALLBACK);const g=new ci(this.image,this.resultPointCallback).find(u);return this.processFinderPatternInfo(g)}processFinderPatternInfo(u){const p=u.getTopLeft(),g=u.getTopRight(),b=u.getBottomLeft(),v=this.calculateModuleSize(p,g,b);if(v<1)throw new ne("No pattern found in proccess finder.");const E=js.computeDimension(p,g,b,v),k=fn.getProvisionalVersionForDimension(E),P=k.getDimensionForVersion()-7;let M=null;if(k.getAlignmentPatternCenters().length>0){const ve=g.getX()-p.getX()+b.getX(),ke=g.getY()-p.getY()+b.getY(),Ie=1-3/P,We=Math.floor(p.getX()+Ie*(ve-p.getX())),ht=Math.floor(p.getY()+Ie*(ke-p.getY()));for(let Yt=4;Yt<=16;Yt<<=1)try{M=this.findAlignmentInRegion(v,We,ht,Yt);break}catch(Wt){if(!(Wt instanceof ne))throw Wt}}const W=js.createTransform(p,g,b,M,E),te=js.sampleGrid(this.image,W,E);let ae;return M===null?ae=[b,p,g]:ae=[b,p,g,M],new hn(te,ae)}static createTransform(u,p,g,b,v){const E=v-3.5;let k,P,M,W;return b!==null?(k=b.getX(),P=b.getY(),M=E-3,W=M):(k=p.getX()-u.getX()+g.getX(),P=p.getY()-u.getY()+g.getY(),M=E,W=E),Ve.quadrilateralToQuadrilateral(3.5,3.5,E,3.5,M,W,3.5,E,u.getX(),u.getY(),p.getX(),p.getY(),k,P,g.getX(),g.getY())}static sampleGrid(u,p,g){return cn.getInstance().sampleGridWithTransform(u,g,g,p)}static computeDimension(u,p,g,b){const v=ut.round(Dt.distance(u,p)/b),E=ut.round(Dt.distance(u,g)/b);let k=Math.floor((v+E)/2)+7;switch(k&3){case 0:k++;break;case 2:k--;break;case 3:throw new ne("Dimensions could be not found.")}return k}calculateModuleSize(u,p,g){return(this.calculateModuleSizeOneWay(u,p)+this.calculateModuleSizeOneWay(u,g))/2}calculateModuleSizeOneWay(u,p){const g=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(u.getX()),Math.floor(u.getY()),Math.floor(p.getX()),Math.floor(p.getY())),b=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(p.getX()),Math.floor(p.getY()),Math.floor(u.getX()),Math.floor(u.getY()));return isNaN(g)?b/7:isNaN(b)?g/7:(g+b)/14}sizeOfBlackWhiteBlackRunBothWays(u,p,g,b){let v=this.sizeOfBlackWhiteBlackRun(u,p,g,b),E=1,k=u-(g-u);k<0?(E=u/(u-k),k=0):k>=this.image.getWidth()&&(E=(this.image.getWidth()-1-u)/(k-u),k=this.image.getWidth()-1);let P=Math.floor(p-(b-p)*E);return E=1,P<0?(E=p/(p-P),P=0):P>=this.image.getHeight()&&(E=(this.image.getHeight()-1-p)/(P-p),P=this.image.getHeight()-1),k=Math.floor(u+(k-u)*E),v+=this.sizeOfBlackWhiteBlackRun(u,p,k,P),v-1}sizeOfBlackWhiteBlackRun(u,p,g,b){const v=Math.abs(b-p)>Math.abs(g-u);if(v){let ve=u;u=p,p=ve,ve=g,g=b,b=ve}const E=Math.abs(g-u),k=Math.abs(b-p);let P=-E/2;const M=u0){if(ke===b)break;ke+=W,P-=E}}return te===2?ut.distance(g+M,b,u,p):NaN}findAlignmentInRegion(u,p,g,b){const v=Math.floor(b*u),E=Math.max(0,p-v),k=Math.min(this.image.getWidth()-1,p+v);if(k-E=P||v>=E)throw new ne;if(E-v!==P-k&&(P=k+(E-v),P>=u.getWidth()))throw new ne;const M=Math.round((P-k+1)/b),W=Math.round((E-v+1)/b);if(M<=0||W<=0)throw new ne;if(W!==M)throw new ne;const te=Math.floor(b/2);v+=te,k+=te;const ae=k+Math.floor((M-1)*b)-P;if(ae>0){if(ae>te)throw new ne;k-=ae}const ve=v+Math.floor((W-1)*b)-E;if(ve>0){if(ve>te)throw new ne;v-=ve}const ke=new ye(M,W);for(let Ie=0;Ie0;){const ae=Un.findGuardPattern(u,v,--b,g,!1,E,M);if(ae!=null)te=ae;else{b++;break}}k[0]=new Dt(te[0],b),k[1]=new Dt(te[1],b),P=!0;break}}let W=b+1;if(P){let te=0,ae=Int32Array.from([Math.trunc(k[0].getX()),Math.trunc(k[1].getX())]);for(;WUn.SKIPPED_ROW_COUNT_MAX)break;te++}}W-=te+1,k[2]=new Dt(ae[0],W),k[3]=new Dt(ae[1],W)}return W-b0&&M++te?W-te:te-W;if(ae>g)return 1/0;P+=ae}return P/v}}Un.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),Un.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),Un.MAX_AVG_VARIANCE=.42,Un.MAX_INDIVIDUAL_VARIANCE=.8,Un.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),Un.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),Un.MAX_PIXEL_DRIFT=3,Un.MAX_PATTERN_DRIFT=5,Un.SKIPPED_ROW_COUNT_MAX=25,Un.ROW_STEP=5,Un.BARCODE_MIN_HEIGHT=10;class Xr{constructor(u,p){if(p.length===0)throw new y;this.field=u;let g=p.length;if(g>1&&p[0]===0){let b=1;for(;bg.length){let E=p;p=g,g=E}let b=new Int32Array(g.length),v=g.length-p.length;C.arraycopy(g,0,b,0,v);for(let E=v;E=0;p--){let g=this.getCoefficient(p);g!==0&&(g<0?(u.append(" - "),g=-g):u.length()>0&&u.append(" + "),(p===0||g!==1)&&u.append(g),p!==0&&(p===1?u.append("x"):(u.append("x^"),u.append(p))))}return u.toString()}}class To{add(u,p){return(u+p)%this.modulus}subtract(u,p){return(this.modulus+u-p)%this.modulus}exp(u){return this.expTable[u]}log(u){if(u===0)throw new y;return this.logTable[u]}inverse(u){if(u===0)throw new Ue;return this.expTable[this.modulus-this.logTable[u]-1]}multiply(u,p){return u===0||p===0?0:this.expTable[(this.logTable[u]+this.logTable[p])%(this.modulus-1)]}getSize(){return this.modulus}equals(u){return u===this}}class Zr extends To{constructor(u,p){super(),this.modulus=u,this.expTable=new Int32Array(u),this.logTable=new Int32Array(u);let g=1;for(let b=0;b0;ke--){let Ie=b.evaluateAt(this.field.exp(ke));v[p-ke]=Ie,Ie!==0&&(E=!0)}if(!E)return 0;let k=this.field.getOne();if(g!=null)for(const ke of g){let Ie=this.field.exp(u.length-1-ke),We=new Xr(this.field,new Int32Array([this.field.subtract(0,Ie),1]));k=k.multiply(We)}let P=new Xr(this.field,v),M=this.runEuclideanAlgorithm(this.field.buildMonomial(p,1),P,p),W=M[0],te=M[1],ae=this.findErrorLocations(W),ve=this.findErrorMagnitudes(te,W,ae);for(let ke=0;ke=Math.round(g/2);){let ae=b,ve=E;if(b=v,E=k,b.isZero())throw A.getChecksumInstance();v=ae;let ke=this.field.getZero(),Ie=b.getCoefficient(b.getDegree()),We=this.field.inverse(Ie);for(;v.getDegree()>=b.getDegree()&&!v.isZero();){let ht=v.getDegree()-b.getDegree(),Yt=this.field.multiply(v.getCoefficient(v.getDegree()),We);ke=ke.add(this.field.buildMonomial(ht,Yt)),v=v.subtract(b.multiplyByMonomial(ht,Yt))}k=ke.multiply(E).subtract(ve).negative()}let P=k.getCoefficient(0);if(P===0)throw A.getChecksumInstance();let M=this.field.inverse(P),W=k.multiply(M),te=v.multiply(M);return[W,te]}findErrorLocations(u){let p=u.getDegree(),g=new Int32Array(p),b=0;for(let v=1;v0){let P=g?this.topLeft:this.topRight,M=Math.trunc(P.getY()-u);M<0&&(M=0);let W=new Dt(P.getX(),M);g?b=W:E=W}if(p>0){let P=g?this.bottomLeft:this.bottomRight,M=Math.trunc(P.getY()+p);M>=this.image.getHeight()&&(M=this.image.getHeight()-1);let W=new Dt(P.getX(),M);g?v=W:k=W}return new Qs(this.image,b,v,E,k)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class Po{constructor(u,p,g,b){this.columnCount=u,this.errorCorrectionLevel=b,this.rowCountUpperPart=p,this.rowCountLowerPart=g,this.rowCount=p+g}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class pa{constructor(){this.buffer=""}static form(u,p){let g=-1;function b(E,k,P,M,W,te){if(E==="%%")return"%";if(p[++g]===void 0)return;E=M?parseInt(M.substr(1)):void 0;let ae=W?parseInt(W.substr(1)):void 0,ve;switch(te){case"s":ve=p[g];break;case"c":ve=p[g][0];break;case"f":ve=parseFloat(p[g]).toFixed(E);break;case"p":ve=parseFloat(p[g]).toPrecision(E);break;case"e":ve=parseFloat(p[g]).toExponential(E);break;case"x":ve=parseInt(p[g]).toString(ae||16);break;case"d":ve=parseFloat(parseInt(p[g],ae||10).toPrecision(E)).toFixed(0);break}ve=typeof ve=="object"?JSON.stringify(ve):(+ve).toString(ae);let ke=parseInt(P),Ie=P&&P[0]+""=="0"?"0":" ";for(;ve.length=0&&(p=this.codewords[b],p!=null)||(b=this.imageRowToCodewordIndex(u)+g,bg,getValue:()=>b};v.getValue()>u?(u=v.getValue(),p=[],p.push(v.getKey())):v.getValue()===u&&p.push(v.getKey())}return Gn.toIntArray(p)}getConfidence(u){return this.values.get(u)}}class Zs extends ma{constructor(u,p){super(u),this._isLeft=p}setRowNumbers(){for(let u of this.getCodewords())u!=null&&u.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(u){let p=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(p,u);let g=this.getBoundingBox(),b=this._isLeft?g.getTopLeft():g.getTopRight(),v=this._isLeft?g.getBottomLeft():g.getBottomRight(),E=this.imageRowToCodewordIndex(Math.trunc(b.getY())),k=this.imageRowToCodewordIndex(Math.trunc(v.getY())),P=-1,M=1,W=0;for(let te=E;te=u.getRowCount()||ve>te)p[te]=null;else{let ke;M>2?ke=(M-2)*ve:ke=ve;let Ie=ke>=te;for(let We=1;We<=ke&&!Ie;We++)Ie=p[te-We]!=null;Ie?p[te]=null:(P=ae.getRowNumber(),W=1)}}}getRowHeights(){let u=this.getBarcodeMetadata();if(u==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(u);let p=new Int32Array(u.getRowCount());for(let g of this.getCodewords())if(g!=null){let b=g.getRowNumber();if(b>=p.length)continue;p[b]++}return p}adjustIncompleteIndicatorColumnRowNumbers(u){let p=this.getBoundingBox(),g=this._isLeft?p.getTopLeft():p.getTopRight(),b=this._isLeft?p.getBottomLeft():p.getBottomRight(),v=this.imageRowToCodewordIndex(Math.trunc(g.getY())),E=this.imageRowToCodewordIndex(Math.trunc(b.getY())),k=this.getCodewords(),P=-1;for(let M=v;M=u.getRowCount()?k[M]=null:P=W.getRowNumber())}}getBarcodeMetadata(){let u=this.getCodewords(),p=new Bs,g=new Bs,b=new Bs,v=new Bs;for(let k of u){if(k==null)continue;k.setRowNumberAsRowIndicatorColumn();let P=k.getValue()%30,M=k.getRowNumber();switch(this._isLeft||(M+=2),M%3){case 0:g.setValue(P*3+1);break;case 1:v.setValue(P/3),b.setValue(P%3);break;case 2:p.setValue(P+1);break}}if(p.getValue().length===0||g.getValue().length===0||b.getValue().length===0||v.getValue().length===0||p.getValue()[0]<1||g.getValue()[0]+b.getValue()[0]Gn.MAX_ROWS_IN_BARCODE)return null;let E=new Po(p.getValue()[0],g.getValue()[0],b.getValue()[0],v.getValue()[0]);return this.removeIncorrectCodewords(u,E),E}removeIncorrectCodewords(u,p){for(let g=0;gp.getRowCount()){u[g]=null;continue}switch(this._isLeft||(E+=2),E%3){case 0:v*3+1!==p.getRowCountUpperPart()&&(u[g]=null);break;case 1:(Math.trunc(v/3)!==p.getErrorCorrectionLevel()||v%3!==p.getRowCountLowerPart())&&(u[g]=null);break;case 2:v+1!==p.getColumnCount()&&(u[g]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+` `+super.toString()}}class Ni{constructor(u,p){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=u,this.barcodeColumnCount=u.getColumnCount(),this.boundingBox=p,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let u=Gn.MAX_CODEWORDS_IN_BARCODE,p;do p=u,u=this.adjustRowNumbersAndGetCount();while(u>0&&u0&&v0&&(k[0]=g[p-1],k[4]=v[p-1],k[5]=E[p-1]),p>1&&(k[8]=g[p-2],k[10]=v[p-2],k[11]=E[p-2]),p>=1;g=p&1,yi.RATIOS_TABLE[u]||(yi.RATIOS_TABLE[u]=new Array(Gn.BARS_IN_MODULE)),yi.RATIOS_TABLE[u][Gn.BARS_IN_MODULE-b-1]=Math.fround(v/Gn.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(u){let p=yi.getDecodedCodewordValue(yi.sampleBitCounts(u));return p!==-1?p:yi.getClosestDecodedValue(u)}static sampleBitCounts(u){let p=ut.sum(u),g=new Int32Array(Gn.BARS_IN_MODULE),b=0,v=0;for(let E=0;E1)for(let E=0;E=b)break}knew Array(Gn.BARS_IN_MODULE));class Xa{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(u){this.segmentIndex=u}getFileId(){return this.fileId}setFileId(u){this.fileId=u}getOptionalData(){return this.optionalData}setOptionalData(u){this.optionalData=u}isLastSegment(){return this.lastSegment}setLastSegment(u){this.lastSegment=u}getSegmentCount(){return this.segmentCount}setSegmentCount(u){this.segmentCount=u}getSender(){return this.sender||null}setSender(u){this.sender=u}getAddressee(){return this.addressee||null}setAddressee(u){this.addressee=u}getFileName(){return this.fileName}setFileName(u){this.fileName=u}getFileSize(){return this.fileSize}setFileSize(u){this.fileSize=u}getChecksum(){return this.checksum}setChecksum(u){this.checksum=u}getTimestamp(){return this.timestamp}setTimestamp(u){this.timestamp=u}}class Nl{static parseLong(u,p=void 0){return parseInt(u,p)}}class fo extends f{}fo.kind="NullPointerException";class Zo{writeBytes(u){this.writeBytesOffset(u,0,u.length)}writeBytesOffset(u,p,g){if(u==null)throw new fo;if(p<0||p>u.length||g<0||p+g>u.length||p+g<0)throw new T;if(g===0)return;for(let b=0;b0&&this.grow(u)}grow(u){let g=this.buf.length<<1;if(g-u<0&&(g=u),g<0){if(u<0)throw new ga;g=L.MAX_VALUE}this.buf=V.copyOfUint8Array(this.buf,g)}write(u){this.ensureCapacity(this.count+1),this.buf[this.count]=u,this.count+=1}writeBytesOffset(u,p,g){if(p<0||p>u.length||g<0||p+g-u.length>0)throw new T;this.ensureCapacity(this.count+g),C.arraycopy(u,p,this.buf,this.count,g),this.count+=g}writeTo(u){u.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return V.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(u){return u?typeof u=="string"?this.toString_string(u):this.toString_number(u):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(u){return new String(this.buf).toString()}toString_number(u){return new String(this.buf).toString()}close(){}}var Fr;(function(ee){ee[ee.ALPHA=0]="ALPHA",ee[ee.LOWER=1]="LOWER",ee[ee.MIXED=2]="MIXED",ee[ee.PUNCT=3]="PUNCT",ee[ee.ALPHA_SHIFT=4]="ALPHA_SHIFT",ee[ee.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(Fr||(Fr={}));function Ra(){if(typeof window<"u")return window.BigInt||null;if(typeof Iv<"u")return Iv.BigInt||null;if(typeof self<"u")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let Oo;function Qa(ee){if(typeof Oo>"u"&&(Oo=Ra()),Oo===null)throw new Error("BigInt is not supported!");return Oo(ee)}function Ro(){let ee=[];ee[0]=Qa(1);let u=Qa(900);ee[1]=u;for(let p=2;p<16;p++)ee[p]=ee[p-1]*u;return ee}class at{static decode(u,p){let g=new J(""),b=F.ISO8859_1;g.enableDecoding(b);let v=1,E=u[v++],k=new Xa;for(;vu[0])throw B.getFormatInstance();let b=new Int32Array(at.NUMBER_OF_SEQUENCE_CODEWORDS);for(let k=0;k0){for(let ae=0;ae<6;++ae)E.write(Number(Qa(P)>>Qa(8*(5-ae))));P=0,k=0}break}b===p[0]&&te0){for(let ve=0;ve<6;++ve)E.write(Number(Qa(P)>>Qa(8*(5-ve))));P=0,k=0}}break}return v.append(Y.decode(E.toByteArray(),g)),b}static numericCompaction(u,p,g){let b=0,v=!1,E=new Int32Array(at.MAX_NUMERIC_CODEWORDS);for(;p0&&(g.append(at.decodeBase900toBase10(E,b)),b=0)}return p}static decodeBase900toBase10(u,p){let g=Qa(0);for(let v=0;v@[\\]_\`~!\r ,: -.$/"|*()?{}'`,at.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",at.EXP900=Ra()?Ro():[],at.NUMBER_OF_SEQUENCE_CODEWORDS=2;class pr{constructor(){}static decode(u,p,g,b,v,E,k){let P=new Qs(u,p,g,b,v),M=null,W=null,te;for(let ke=!0;;ke=!1){if(p!=null&&(M=pr.getRowIndicatorColumn(u,P,p,!0,E,k)),b!=null&&(W=pr.getRowIndicatorColumn(u,P,b,!1,E,k)),te=pr.merge(M,W),te==null)throw ne.getNotFoundInstance();let Ie=te.getBoundingBox();if(ke&&Ie!=null&&(Ie.getMinY()P.getMaxY()))P=Ie;else break}te.setBoundingBox(P);let ae=te.getBarcodeColumnCount()+1;te.setDetectionResultColumn(0,M),te.setDetectionResultColumn(ae,W);let ve=M!=null;for(let ke=1;ke<=ae;ke++){let Ie=ve?ke:ae-ke;if(te.getDetectionResultColumn(Ie)!==void 0)continue;let We;Ie===0||Ie===ae?We=new Zs(P,Ie===0):We=new ma(P),te.setDetectionResultColumn(Ie,We);let ht=-1,Yt=ht;for(let Wt=P.getMinY();Wt<=P.getMaxY();Wt++){if(ht=pr.getStartColumn(te,Ie,Wt,ve),ht<0||ht>P.getMaxX()){if(Yt===-1)continue;ht=Yt}let zt=pr.detectCodeword(u,P.getMinX(),P.getMaxX(),ve,ht,Wt,E,k);zt!=null&&(We.setCodeword(Wt,zt),Yt=ht,E=Math.min(E,zt.getWidth()),k=Math.max(k,zt.getWidth()))}}return pr.createDecoderResult(te)}static merge(u,p){if(u==null&&p==null)return null;let g=pr.getBarcodeMetadata(u,p);if(g==null)return null;let b=Qs.merge(pr.adjustBoundingBox(u),pr.adjustBoundingBox(p));return new Ni(g,b)}static adjustBoundingBox(u){if(u==null)return null;let p=u.getRowHeights();if(p==null)return null;let g=pr.getMax(p),b=0;for(let k of p)if(b+=g-k,k>0)break;let v=u.getCodewords();for(let k=0;b>0&&v[k]==null;k++)b--;let E=0;for(let k=p.length-1;k>=0&&(E+=g-p[k],!(p[k]>0));k--);for(let k=v.length-1;E>0&&v[k]==null;k--)E--;return u.getBoundingBox().addMissingRows(b,E,u.isLeft())}static getMax(u){let p=-1;for(let g of u)p=Math.max(p,g);return p}static getBarcodeMetadata(u,p){let g;if(u==null||(g=u.getBarcodeMetadata())==null)return p==null?null:p.getBarcodeMetadata();let b;return p==null||(b=p.getBarcodeMetadata())==null?g:g.getColumnCount()!==b.getColumnCount()&&g.getErrorCorrectionLevel()!==b.getErrorCorrectionLevel()&&g.getRowCount()!==b.getRowCount()?null:g}static getRowIndicatorColumn(u,p,g,b,v,E){let k=new Zs(p,b);for(let P=0;P<2;P++){let M=P===0?1:-1,W=Math.trunc(Math.trunc(g.getX()));for(let te=Math.trunc(Math.trunc(g.getY()));te<=p.getMaxY()&&te>=p.getMinY();te+=M){let ae=pr.detectCodeword(u,0,u.getWidth(),b,W,te,v,E);ae!=null&&(k.setCodeword(te,ae),b?W=ae.getStartX():W=ae.getEndX())}}return k}static adjustCodewordCount(u,p){let g=p[0][1],b=g.getValue(),v=u.getBarcodeColumnCount()*u.getBarcodeRowCount()-pr.getNumberOfECCodeWords(u.getBarcodeECLevel());if(b.length===0){if(v<1||v>Gn.MAX_CODEWORDS_IN_BARCODE)throw ne.getNotFoundInstance();g.setValue(v)}else b[0]!==v&&g.setValue(v)}static createDecoderResult(u){let p=pr.createBarcodeMatrix(u);pr.adjustCodewordCount(u,p);let g=new Array,b=new Int32Array(u.getBarcodeRowCount()*u.getBarcodeColumnCount()),v=[],E=new Array;for(let P=0;P0;){for(let P=0;Pnew Array(u.getBarcodeColumnCount()+2));for(let b=0;b=0){if(E>=p.length)continue;p[E][g].setValue(v.getValue())}}}g++}return p}static isValidBarcodeColumn(u,p){return p>=0&&p<=u.getBarcodeColumnCount()+1}static getStartColumn(u,p,g,b){let v=b?1:-1,E=null;if(pr.isValidBarcodeColumn(u,p-v)&&(E=u.getDetectionResultColumn(p-v).getCodeword(g)),E!=null)return b?E.getEndX():E.getStartX();if(E=u.getDetectionResultColumn(p).getCodewordNearby(g),E!=null)return b?E.getStartX():E.getEndX();if(pr.isValidBarcodeColumn(u,p-v)&&(E=u.getDetectionResultColumn(p-v).getCodewordNearby(g)),E!=null)return b?E.getEndX():E.getStartX();let k=0;for(;pr.isValidBarcodeColumn(u,p-v);){p-=v;for(let P of u.getDetectionResultColumn(p).getCodewords())if(P!=null)return(b?P.getEndX():P.getStartX())+v*k*(P.getEndX()-P.getStartX());k++}return b?u.getBoundingBox().getMinX():u.getBoundingBox().getMaxX()}static detectCodeword(u,p,g,b,v,E,k,P){v=pr.adjustCodewordStartColumn(u,p,g,b,v,E);let M=pr.getModuleBitCount(u,p,g,b,v,E);if(M==null)return null;let W,te=ut.sum(M);if(b)W=v+te;else{for(let ke=0;ke=p)&&M=p:kpr.CODEWORD_SKEW_SIZE)return v;k+=P}P=-P,b=!b}return k}static checkCodewordSkew(u,p,g){return p-pr.CODEWORD_SKEW_SIZE<=u&&u<=g+pr.CODEWORD_SKEW_SIZE}static decodeCodewords(u,p,g){if(u.length===0)throw B.getFormatInstance();let b=1<g/2+pr.MAX_ERRORS||g<0||g>pr.MAX_EC_CODEWORDS)throw A.getChecksumInstance();return pr.errorCorrection.decode(u,g,p)}static verifyCodewordCount(u,p){if(u.length<4)throw B.getFormatInstance();let g=u[0];if(g>u.length)throw B.getFormatInstance();if(g===0)if(p>=1;return p}static getCodewordBucketNumber(u){return u instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(u):this.getCodewordBucketNumber_number(u)}static getCodewordBucketNumber_number(u){return pr.getCodewordBucketNumber(pr.getBitCountForCodeword(u))}static getCodewordBucketNumber_Int32Array(u){return(u[0]-u[2]+u[4]-u[6]+9)%9}static toString(u){let p=new pa;for(let g=0;gE)}static getMaxWidth(u,p){return u==null||p==null?0:Math.trunc(Math.abs(u.getX()-p.getX()))}static getMinWidth(u,p){return u==null||p==null?L.MAX_VALUE:Math.trunc(Math.abs(u.getX()-p.getX()))}static getMaxCodewordWidth(u){return Math.floor(Math.max(Math.max(Jr.getMaxWidth(u[0],u[4]),Jr.getMaxWidth(u[6],u[2])*Gn.MODULES_IN_CODEWORD/Gn.MODULES_IN_STOP_PATTERN),Math.max(Jr.getMaxWidth(u[1],u[5]),Jr.getMaxWidth(u[7],u[3])*Gn.MODULES_IN_CODEWORD/Gn.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(u){return Math.floor(Math.min(Math.min(Jr.getMinWidth(u[0],u[4]),Jr.getMinWidth(u[6],u[2])*Gn.MODULES_IN_CODEWORD/Gn.MODULES_IN_STOP_PATTERN),Math.min(Jr.getMinWidth(u[1],u[5]),Jr.getMinWidth(u[7],u[3])*Gn.MODULES_IN_CODEWORD/Gn.MODULES_IN_STOP_PATTERN)))}reset(){}}class ge extends f{}ge.kind="ReaderException";class we{constructor(u,p){this.verbose=u===!0,p&&this.setHints(p)}decode(u,p){return p&&this.setHints(p),this.decodeInternal(u)}decodeWithState(u){return(this.readers===null||this.readers===void 0)&&this.setHints(null),this.decodeInternal(u)}setHints(u){this.hints=u;const p=!r(u)&&u.get(q.TRY_HARDER)===!0,g=r(u)?null:u.get(q.POSSIBLE_FORMATS),b=new Array;if(!r(g)){const v=g.some(E=>E===ze.UPC_A||E===ze.UPC_E||E===ze.EAN_13||E===ze.EAN_8||E===ze.CODABAR||E===ze.CODE_39||E===ze.CODE_93||E===ze.CODE_128||E===ze.ITF||E===ze.RSS_14||E===ze.RSS_EXPANDED);v&&!p&&b.push(new is(u,this.verbose)),g.includes(ze.QR_CODE)&&b.push(new Is),g.includes(ze.DATA_MATRIX)&&b.push(new Bt),g.includes(ze.AZTEC)&&b.push(new gr),g.includes(ze.PDF_417)&&b.push(new Jr),v&&p&&b.push(new is(u,this.verbose))}b.length===0&&(p||b.push(new is(u,this.verbose)),b.push(new Is),b.push(new Bt),b.push(new gr),b.push(new Jr),p&&b.push(new is(u,this.verbose))),this.readers=b}reset(){if(this.readers!==null)for(const u of this.readers)u.reset()}decodeInternal(u){if(this.readers===null)throw new ge("No readers where selected, nothing can be read.");for(const p of this.readers)try{return p.decode(u,this.hints)}catch(g){if(g instanceof ge)continue}throw new ne("No MultiFormat Readers were able to detect the code.")}}class Pe extends re{constructor(u=null,p=500){const g=new we;g.setHints(u),super(g,p)}decodeBitmap(u){return this.reader.decodeWithState(u)}}class $e extends re{constructor(u=500){super(new Jr,u)}}class ct extends re{constructor(u=500){super(new Is,u)}}var ot;(function(ee){ee[ee.ERROR_CORRECTION=0]="ERROR_CORRECTION",ee[ee.CHARACTER_SET=1]="CHARACTER_SET",ee[ee.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",ee[ee.MIN_SIZE=3]="MIN_SIZE",ee[ee.MAX_SIZE=4]="MAX_SIZE",ee[ee.MARGIN=5]="MARGIN",ee[ee.PDF417_COMPACT=6]="PDF417_COMPACT",ee[ee.PDF417_COMPACTION=7]="PDF417_COMPACTION",ee[ee.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",ee[ee.AZTEC_LAYERS=9]="AZTEC_LAYERS",ee[ee.QR_VERSION=10]="QR_VERSION"})(ot||(ot={}));var _t=ot;class pn{constructor(u){this.field=u,this.cachedGenerators=[],this.cachedGenerators.push(new yt(u,Int32Array.from([1])))}buildGenerator(u){const p=this.cachedGenerators;if(u>=p.length){let g=p[p.length-1];const b=this.field;for(let v=p.length;v<=u;v++){const E=g.multiply(new yt(b,Int32Array.from([1,b.exp(v-1+b.getGeneratorBase())])));p.push(E),g=E}}return p[u]}encode(u,p){if(p===0)throw new y("No error correction bytes");const g=u.length-p;if(g<=0)throw new y("No data bytes provided");const b=this.buildGenerator(p),v=new Int32Array(g);C.arraycopy(u,0,v,0,g);let E=new yt(this.field,v);E=E.multiplyByMonomial(p,1);const P=E.divide(b)[1].getCoefficients(),M=p-P.length;for(let W=0;W=5&&(g+=Lt.N1+(P-5)),P=1,M=te)}P>=5&&(g+=Lt.N1+(P-5))}return g}}Lt.N1=3,Lt.N2=3,Lt.N3=40,Lt.N4=10;class bn{constructor(u,p){this.width=u,this.height=p;const g=new Array(p);for(let b=0;b!==p;b++)g[b]=new Uint8Array(u);this.bytes=g}getHeight(){return this.height}getWidth(){return this.width}get(u,p){return this.bytes[p][u]}getArray(){return this.bytes}setNumber(u,p,g){this.bytes[p][u]=g}setBoolean(u,p,g){this.bytes[p][u]=g?1:0}clear(u){for(const p of this.bytes)V.fill(p,u)}equals(u){if(!(u instanceof bn))return!1;const p=u;if(this.width!==p.width||this.height!==p.height)return!1;for(let g=0,b=this.height;g> `),u.toString()}setMode(u){this.mode=u}setECLevel(u){this.ecLevel=u}setVersion(u){this.version=u}setMaskPattern(u){this.maskPattern=u}setMatrix(u){this.matrix=u}static isValidMaskPattern(u){return u>=0&&u0;){for(E===6&&(E-=1);k>=0&&k=g;)u^=p<<_.findMSBSet(u)-g;return u}static makeTypeInfoBits(u,p,g){if(!rn.isValidMaskPattern(p))throw new He("Invalid mask pattern");const b=u.getBits()<<3|p;g.appendBits(b,5);const v=_.calculateBCHCode(b,_.TYPE_INFO_POLY);g.appendBits(v,10);const E=new K;if(E.appendBits(_.TYPE_INFO_MASK_PATTERN,15),g.xor(E),g.getSize()!==15)throw new He("should not happen but we got: "+g.getSize())}static makeVersionInfoBits(u,p){p.appendBits(u.getVersionNumber(),6);const g=_.calculateBCHCode(u.getVersionNumber(),_.VERSION_INFO_POLY);if(p.appendBits(g,12),p.getSize()!==18)throw new He("should not happen but we got: "+p.getSize())}static isEmpty(u){return u===255}static embedTimingPatterns(u){for(let p=8;p=0)for(let P=0;P!==E;P++){const M=b[P];M>=0&&_.isEmpty(p.get(M,k))&&_.embedPositionAdjustmentPattern(M-2,k-2,p)}}}}_.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),_.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),_.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),_.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),_.VERSION_INFO_POLY=7973,_.TYPE_INFO_POLY=1335,_.TYPE_INFO_MASK_PATTERN=21522;class U{constructor(u,p){this.dataBytes=u,this.errorCorrectionBytes=p}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class H{constructor(){}static calculateMaskPenalty(u){return Lt.applyMaskPenaltyRule1(u)+Lt.applyMaskPenaltyRule2(u)+Lt.applyMaskPenaltyRule3(u)+Lt.applyMaskPenaltyRule4(u)}static encode(u,p,g=null){let b=H.DEFAULT_BYTE_MODE_ENCODING;const v=g!==null&&g.get(_t.CHARACTER_SET)!==void 0;v&&(b=g.get(_t.CHARACTER_SET).toString());const E=this.chooseMode(u,b),k=new K;if(E===an.BYTE&&(v||H.DEFAULT_BYTE_MODE_ENCODING!==b)){const Wt=F.getCharacterSetECIByName(b);Wt!==void 0&&this.appendECI(Wt,k)}this.appendModeInfo(E,k);const P=new K;this.appendBytes(u,E,P,b);let M;if(g!==null&&g.get(_t.QR_VERSION)!==void 0){const Wt=Number.parseInt(g.get(_t.QR_VERSION).toString(),10);M=fn.getVersionForNumber(Wt);const zt=this.calculateBitsNeeded(E,k,P,M);if(!this.willFit(zt,M,p))throw new He("Data too big for requested version")}else M=this.recommendVersion(p,E,k,P);const W=new K;W.appendBitArray(k);const te=E===an.BYTE?P.getSizeInBytes():u.length;this.appendLengthInfo(te,M,E,W),W.appendBitArray(P);const ae=M.getECBlocksForLevel(p),ve=M.getTotalCodewords()-ae.getTotalECCodewords();this.terminateBits(ve,W);const ke=this.interleaveWithECBytes(W,M.getTotalCodewords(),ve,ae.getNumBlocks()),Ie=new rn;Ie.setECLevel(p),Ie.setMode(E),Ie.setVersion(M);const We=M.getDimensionForVersion(),ht=new bn(We,We),Yt=this.chooseMaskPattern(ke,p,M,ht);return Ie.setMaskPattern(Yt),_.buildMatrix(ke,p,M,Yt,ht),Ie.setMatrix(ht),Ie}static recommendVersion(u,p,g,b){const v=this.calculateBitsNeeded(p,g,b,fn.getVersionForNumber(1)),E=this.chooseVersion(v,u),k=this.calculateBitsNeeded(p,g,b,E);return this.chooseVersion(k,u)}static calculateBitsNeeded(u,p,g,b){return p.getSize()+u.getCharacterCountBits(b)+g.getSize()}static getAlphanumericCode(u){return u159)&&(v<224||v>235))return!1}return!0}static chooseMaskPattern(u,p,g,b){let v=Number.MAX_SAFE_INTEGER,E=-1;for(let k=0;k=P}static terminateBits(u,p){const g=u*8;if(p.getSize()>g)throw new He("data bits cannot fit in the QR Code"+p.getSize()+" > "+g);for(let E=0;E<4&&p.getSize()0)for(let E=b;E<8;E++)p.appendBit(!1);const v=u-p.getSizeInBytes();for(let E=0;E=g)throw new He("Block ID too large");const k=u%g,P=g-k,M=Math.floor(u/g),W=M+1,te=Math.floor(p/g),ae=te+1,ve=M-te,ke=W-ae;if(ve!==ke)throw new He("EC bytes mismatch");if(g!==P+k)throw new He("RS blocks mismatch");if(u!==(te+ve)*P+(ae+ke)*k)throw new He("Total bytes mismatch");b=1<=0&&p<=9}static appendNumericBytes(u,p){const g=u.length;let b=0;for(;b=33088&&P<=40956?M=P-33088:P>=57408&&P<=60351&&(M=P-49472),M===-1)throw new He("Invalid byte sequence");const W=(M>>8)*192+(M&255);p.appendBits(W,13)}}static appendECI(u,p){p.appendBits(an.ECI.getBits(),4),p.appendBits(u.getValue(),8)}}H.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),H.DEFAULT_BYTE_MODE_ENCODING=F.UTF8.getName();class oe{write(u,p,g,b=null){if(u.length===0)throw new y("Found empty contents");if(p<0||g<0)throw new y("Requested dimensions are too small: "+p+"x"+g);let v=Ln.L,E=oe.QUIET_ZONE_SIZE;b!==null&&(b.get(_t.ERROR_CORRECTION)!==void 0&&(v=Ln.fromString(b.get(_t.ERROR_CORRECTION).toString())),b.get(_t.MARGIN)!==void 0&&(E=Number.parseInt(b.get(_t.MARGIN).toString(),10)));const k=H.encode(u,v,b);return this.renderResult(k,p,g,E)}writeToDom(u,p,g,b,v=null){typeof u=="string"&&(u=document.querySelector(u));const E=this.write(p,g,b,v);u&&u.appendChild(E)}renderResult(u,p,g,b){const v=u.getMatrix();if(v===null)throw new tn;const E=v.getWidth(),k=v.getHeight(),P=E+b*2,M=k+b*2,W=Math.max(p,P),te=Math.max(g,M),ae=Math.min(Math.floor(W/P),Math.floor(te/M)),ve=Math.floor((W-E*ae)/2),ke=Math.floor((te-k*ae)/2),Ie=this.createSVGElement(W,te);for(let We=0,ht=ke;Wep||v+k>g)throw new y("Crop rectangle does not fit within image data.");P&&this.reverseHorizontal(E,k)}getRow(u,p){if(u<0||u>=this.getHeight())throw new y("Requested row is outside the image: "+u);const g=this.getWidth();(p==null||p.length>16&255,ve=te>>7&510,ke=te&255;M[W]=(ae+ve+ke)/4&255}this.luminances=M}else this.luminances=u;if(b===void 0&&(this.dataWidth=p),v===void 0&&(this.dataHeight=g),E===void 0&&(this.left=0),k===void 0&&(this.top=0),this.left+p>this.dataWidth||this.top+g>this.dataHeight)throw new y("Crop rectangle does not fit within image data.")}getRow(u,p){if(u<0||u>=this.getHeight())throw new y("Requested row is outside the image: "+u);const g=this.getWidth();(p==null||p.length"}}class Ri extends Vi{constructor(u,p,g){super(u,0,0),this.binaryShiftStart=p,this.binaryShiftByteCount=g}appendTo(u,p){for(let g=0;g62?u.appendBits(this.binaryShiftByteCount-31,16):g===0?u.appendBits(Math.min(this.binaryShiftByteCount,31),5):u.appendBits(this.binaryShiftByteCount-31,5)),u.appendBits(p[this.binaryShiftStart+g],8)}addBinaryShift(u,p){return new Ri(this,u,p)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function ws(ee,u,p){return new Ri(ee,u,p)}function Da(ee,u,p){return new Vi(ee,u,p)}const Ei=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],Ts=0,ni=1,Ps=2,wc=3,Ma=4,El=new Vi(null,0,0),Jo=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])];function Cm(ee){for(let u of ee)V.fill(u,-1);return ee[Ts][Ma]=0,ee[ni][Ma]=0,ee[ni][Ts]=28,ee[wc][Ma]=0,ee[Ps][Ma]=0,ee[Ps][Ts]=15,ee}const Nc=Cm(V.createInt32Array(6,6));class mo{constructor(u,p,g,b){this.token=u,this.mode=p,this.binaryShiftByteCount=g,this.bitCount=b}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(u,p){let g=this.bitCount,b=this.token;if(u!==this.mode){let E=Jo[this.mode][u];b=Da(b,E&65535,E>>16),g+=E>>16}let v=u===Ps?4:5;return b=Da(b,p,v),new mo(b,u,0,g+v)}shiftAndAppend(u,p){let g=this.token,b=this.mode===Ps?4:5;return g=Da(g,Nc[this.mode][u],b),g=Da(g,p,5),new mo(g,this.mode,0,this.bitCount+b+5)}addBinaryShiftChar(u){let p=this.token,g=this.mode,b=this.bitCount;if(this.mode===Ma||this.mode===Ps){let k=Jo[g][Ts];p=Da(p,k&65535,k>>16),b+=k>>16,g=Ts}let v=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,E=new mo(p,g,this.binaryShiftByteCount+1,b+v);return E.binaryShiftByteCount===2078&&(E=E.endBinaryShift(u+1)),E}endBinaryShift(u){if(this.binaryShiftByteCount===0)return this;let p=this.token;return p=ws(p,u-this.binaryShiftByteCount,this.binaryShiftByteCount),new mo(p,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(u){let p=this.bitCount+(Jo[this.mode][u.mode]>>16);return this.binaryShiftByteCountu.binaryShiftByteCount&&u.binaryShiftByteCount>0&&(p+=10),p<=u.bitCount}toBitArray(u){let p=[];for(let b=this.endBinaryShift(u.length).token;b!==null;b=b.getPrevious())p.unshift(b);let g=new K;for(const b of p)b.appendTo(g,u);return g}toString(){return X.format("%s bits=%d bytes=%d",Ei[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(u){return u.binaryShiftByteCount>62?21:u.binaryShiftByteCount>31?20:u.binaryShiftByteCount>0?10:0}}mo.INITIAL_STATE=new mo(El,Ts,0,0);function ah(ee){const u=X.getCharCode(" "),p=X.getCharCode("."),g=X.getCharCode(",");ee[Ts][u]=1;const b=X.getCharCode("Z"),v=X.getCharCode("A");for(let ae=v;ae<=b;ae++)ee[Ts][ae]=ae-v+2;ee[ni][u]=1;const E=X.getCharCode("z"),k=X.getCharCode("a");for(let ae=k;ae<=E;ae++)ee[ni][ae]=ae-k+2;ee[Ps][u]=1;const P=X.getCharCode("9"),M=X.getCharCode("0");for(let ae=M;ae<=P;ae++)ee[Ps][ae]=ae-M+2;ee[Ps][g]=12,ee[Ps][p]=13;const W=["\0"," ","","","","","","","\x07","\b"," ",` `,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~",""];for(let ae=0;ae","?","[","]","{","}"];for(let ae=0;ae0&&(ee[Ma][X.getCharCode(te[ae])]=ae);return ee}const go=ah(V.createInt32Array(5,256));class La{constructor(u){this.text=u}encode(){const u=X.getCharCode(" "),p=X.getCharCode(` `);let g=Ur.singletonList(mo.INITIAL_STATE);for(let v=0;v0?(g=La.updateStateListForPair(g,v,E),v++):g=this.updateStateListForChar(g,v)}return Ur.min(g,(v,E)=>v.getBitCount()-E.getBitCount()).toBitArray(this.text)}updateStateListForChar(u,p){const g=[];for(let b of u)this.updateStateForChar(b,p,g);return La.simplifyStates(g)}updateStateForChar(u,p,g){let b=this.text[p]&255,v=go[u.getMode()][b]>0,E=null;for(let k=0;k<=Ma;k++){let P=go[k][b];if(P>0){if(E==null&&(E=u.endBinaryShift(p)),!v||k===u.getMode()||k===Ps){const M=E.latchAndAppend(k,P);g.push(M)}if(!v&&Nc[u.getMode()][k]>=0){const M=E.shiftAndAppend(k,P);g.push(M)}}}if(u.getBinaryShiftByteCount()>0||go[u.getMode()][b]===0){let k=u.addBinaryShiftChar(p);g.push(k)}}static updateStateListForPair(u,p,g){const b=[];for(let v of u)this.updateStateForPair(v,p,g,b);return this.simplifyStates(b)}static updateStateForPair(u,p,g,b){let v=u.endBinaryShift(p);if(b.push(v.latchAndAppend(Ma,g)),u.getMode()!==Ma&&b.push(v.shiftAndAppend(Ma,g)),g===3||g===4){let E=v.latchAndAppend(Ps,16-g).latchAndAppend(Ps,1);b.push(E)}if(u.getBinaryShiftByteCount()>0){let E=u.addBinaryShiftChar(p).addBinaryShiftChar(p+1);b.push(E)}}static simplifyStates(u){let p=[];for(const g of u){let b=!0;for(const v of p){if(v.isBetterThanOrEqualTo(g)){b=!1;break}g.isBetterThanOrEqualTo(v)&&(p=p.filter(E=>E!==v))}b&&p.push(g)}return p}}class Hr{constructor(){}static encodeBytes(u){return Hr.encode(u,Hr.DEFAULT_EC_PERCENT,Hr.DEFAULT_AZTEC_LAYERS)}static encode(u,p,g){let b=new La(u).encode(),v=L.truncDivision(b.getSize()*p,100)+11,E=b.getSize()+v,k,P,M,W,te;if(g!==Hr.DEFAULT_AZTEC_LAYERS){if(k=g<0,P=Math.abs(g),P>(k?Hr.MAX_NB_BITS_COMPACT:Hr.MAX_NB_BITS))throw new y(X.format("Illegal value %s for layers",g));M=Hr.totalBitsInLayer(P,k),W=Hr.WORD_SIZE[P];let zt=M-M%W;if(te=Hr.stuffBits(b,W),te.getSize()+v>zt)throw new y("Data to large for user specified layer");if(k&&te.getSize()>W*64)throw new y("Data to large for user specified layer")}else{W=0,te=null;for(let zt=0;;zt++){if(zt>Hr.MAX_NB_BITS)throw new y("Data too large for an Aztec code");if(k=zt<=3,P=k?zt+1:zt,M=Hr.totalBitsInLayer(P,k),E>M)continue;(te==null||W!==Hr.WORD_SIZE[P])&&(W=Hr.WORD_SIZE[P],te=Hr.stuffBits(b,W));let Dr=M-M%W;if(!(k&&te.getSize()>W*64)&&te.getSize()+v<=Dr)break}}let ae=Hr.generateCheckWords(te,M,W),ve=te.getSize()/W,ke=Hr.generateModeMessage(k,P,ve),Ie=(k?11:14)+P*4,We=new Int32Array(Ie),ht;if(k){ht=Ie;for(let zt=0;zt=b||u.get(E+P))&&(k|=1<0&&a[a.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!a||f[1]>a[0]&&f[1]r&&(r=c,n=o)}if(!n)throw"No largest barcode found";return n},e.prototype.createBarcodeDetectorFormats=function(t){for(var n=[],r=0,i=t;r0&&a[a.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!a||f[1]>a[0]&&f[1]0&&a[a.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!a||f[1]>a[0]&&f[1]=a&&(t.isClosed=!0,t.parentElement.removeChild(t.surface),n())})})},e.prototype.getCapabilities=function(){return new u9e(this.getFirstTrackOrFail())},e})(),h9e=(function(){function e(t){this.mediaStream=t}return e.prototype.render=function(t,n,r){return QN(this,void 0,void 0,function(){return ZN(this,function(i){return[2,d9e.create(t,this.mediaStream,n,r)]})})},e.create=function(t){return QN(this,void 0,void 0,function(){var n,r;return ZN(this,function(i){switch(i.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return n={audio:!1,video:t},[4,navigator.mediaDevices.getUserMedia(n)];case 1:return r=i.sent(),[2,new e(r)]}})})},e})(),GV=function(e,t,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(m){try{f(r.next(m))}catch(y){o(y)}}function h(m){try{f(r.throw(m))}catch(y){o(y)}}function f(m){m.done?a(m.value):i(m.value).then(c,h)}f((r=r.apply(e,t||[])).next())})},qV=function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(f){return function(m){return h([f,m])}}function h(f){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,f[0]&&(n=0)),n;)try{if(r=1,i&&(a=f[0]&2?i.return:f[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,f[1])).done)return a;switch(i=0,a&&(f=[f[0]&2,a.value]),f[0]){case 0:case 1:a=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,i=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!a||f[1]>a[0]&&f[1]0&&a[a.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!a||f[1]>a[0]&&f[1]t&&(i.logger.warn("`qrbox.width` or `qrbox` is larger than the width of the root element. The width will be truncated to the width of root element."),f=t),f};c(o.width),c(o.height),o.width=h(o.width)},e.prototype.validateQrboxConfig=function(t){if(typeof t!="number"&&typeof t!="function"&&(t.width===void 0||t.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},e.prototype.toQrdimensions=function(t,n,r){if(typeof r=="number")return{width:r,height:r};if(typeof r=="function")try{return r(t,n)}catch(i){throw new Error("qrbox config was passed as a function but it failed with unknown error"+i)}return r},e.prototype.setupUi=function(t,n,r){r.isShadedBoxEnabled()&&this.validateQrboxSize(t,n,r);var i=_d(r.qrbox)?{width:t,height:n}:r.qrbox;this.validateQrboxConfig(i);var a=this.toQrdimensions(t,n,i);a.height>n&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var o=r.isShadedBoxEnabled()&&a.height<=n,c={x:0,y:0,width:t,height:n},h=o?this.getShadedRegionBounds(t,n,a):c,f=this.createCanvasElement(h.width,h.height),m={willReadFrequently:!0},y=f.getContext("2d",m);y.canvas.width=h.width,y.canvas.height=h.height,this.element.append(f),o&&this.possiblyInsertShadingElement(this.element,t,n,a),this.createScannerPausedUiElement(this.element),this.qrRegion=h,this.context=y,this.canvasElement=f},e.prototype.createScannerPausedUiElement=function(t){var n=document.createElement("div");n.innerText=H0.scannerPaused(),n.style.display="none",n.style.position="absolute",n.style.top="0px",n.style.zIndex="1",n.style.background="rgba(9, 9, 9, 0.46)",n.style.color="#FFECEC",n.style.textAlign="center",n.style.width="100%",t.appendChild(n),this.scannerPausedUiElement=n},e.prototype.scanContext=function(t,n){var r=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(i){return t(i.text,BV.createFromQrcodeResult(i)),r.possiblyUpdateShaders(!0),!0}).catch(function(i){r.possiblyUpdateShaders(!1);var a=H0.codeParseError(i);return n(a,JMe.createFrom(a)),!1})},e.prototype.foreverScan=function(t,n,r){var i=this;if(this.shouldScan&&this.renderedCamera){var a=this.renderedCamera.getSurface(),o=a.videoWidth/a.clientWidth,c=a.videoHeight/a.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var h=this.qrRegion.width*o,f=this.qrRegion.height*c,m=this.qrRegion.x*o,y=this.qrRegion.y*c;this.context.drawImage(a,m,y,h,f,0,0,this.qrRegion.width,this.qrRegion.height);var w=function(){i.foreverScanTimeout=setTimeout(function(){i.foreverScan(t,n,r)},i.getTimeoutFps(t.fps))};this.scanContext(n,r).then(function(A){!A&&t.disableFlip!==!0?(i.context.translate(i.context.canvas.width,0),i.context.scale(-1,1),i.scanContext(n,r).finally(function(){w()})):w()}).catch(function(A){i.logger.logError("Error happend while scanning context",A),w()})}},e.prototype.createVideoConstraints=function(t){if(typeof t=="string")return{deviceId:{exact:t}};if(typeof t=="object"){var n="facingMode",r="deviceId",i={user:!0,environment:!0},a="exact",o=function(S){if(S in i)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(S,"'")},c=Object.keys(t);if(c.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(c.length," keys");var h=Object.keys(t)[0];if(h!==n&&h!==r)throw"Only '".concat(n,"' and '").concat(r,"' ")+" are supported for 'cameraIdOrConfig'";if(h===n){var f=t.facingMode;if(typeof f=="string"){if(o(f))return{facingMode:f}}else if(typeof f=="object")if(a in f){if(o(f["".concat(a)]))return{facingMode:{exact:f["".concat(a)]}}}else throw"'facingMode' should be string or object with"+" ".concat(a," as key.");else{var m=typeof f;throw"Invalid type of 'facingMode' = ".concat(m)}}else{var y=t.deviceId;if(typeof y=="string")return{deviceId:y};if(typeof y=="object"){if(a in y)return{deviceId:{exact:y["".concat(a)]}};throw"'deviceId' should be string or object with"+" ".concat(a," as key.")}else{var w=typeof y;throw"Invalid type of 'deviceId' = ".concat(w)}}}var A=typeof t;throw"Invalid type of 'cameraIdOrConfig' = ".concat(A)},e.prototype.computeCanvasDrawConfig=function(t,n,r,i){if(t<=r&&n<=i){var a=(r-t)/2,o=(i-n)/2;return{x:a,y:o,width:t,height:n}}else{var c=t,h=n;return t>r&&(n=r/t*n,t=r),n>i&&(t=i/n*t,n=i),this.logger.log("Image downsampled from "+"".concat(c,"X").concat(h)+" to ".concat(t,"X").concat(n,".")),this.computeCanvasDrawConfig(t,n,r,i)}},e.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var t=document.getElementById(this.elementId);t&&(t.innerHTML="")},e.prototype.possiblyUpdateShaders=function(t){this.qrMatch!==t&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(n){n.style.backgroundColor=t?Il.BORDER_SHADER_MATCH_COLOR:Il.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=t)},e.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},e.prototype.createCanvasElement=function(t,n,r){var i=t,a=n,o=document.createElement("canvas");return o.style.width="".concat(i,"px"),o.style.height="".concat(a,"px"),o.style.display="none",o.id=_d(r)?"qr-canvas":r,o},e.prototype.getShadedRegionBounds=function(t,n,r){if(r.width>t||r.height>n)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(t-r.width)/2,y:(n-r.height)/2,width:r.width,height:r.height}},e.prototype.possiblyInsertShadingElement=function(t,n,r,i){if(!(n-i.width<1||r-i.height<1)){var a=document.createElement("div");a.style.position="absolute";var o=(n-i.width)/2,c=(r-i.height)/2;if(a.style.borderLeft="".concat(o,"px solid rgba(0, 0, 0, 0.48)"),a.style.borderRight="".concat(o,"px solid rgba(0, 0, 0, 0.48)"),a.style.borderTop="".concat(c,"px solid rgba(0, 0, 0, 0.48)"),a.style.borderBottom="".concat(c,"px solid rgba(0, 0, 0, 0.48)"),a.style.boxSizing="border-box",a.style.top="0px",a.style.bottom="0px",a.style.left="0px",a.style.right="0px",a.id="".concat(Il.SHADED_REGION_ELEMENT_ID),n-i.width<11||r-i.height<11)this.hasBorderShaders=!1;else{var h=5,f=40;this.insertShaderBorders(a,f,h,-h,null,0,!0),this.insertShaderBorders(a,f,h,-h,null,0,!1),this.insertShaderBorders(a,f,h,null,-h,0,!0),this.insertShaderBorders(a,f,h,null,-h,0,!1),this.insertShaderBorders(a,h,f+h,-h,null,-h,!0),this.insertShaderBorders(a,h,f+h,null,-h,-h,!0),this.insertShaderBorders(a,h,f+h,-h,null,-h,!1),this.insertShaderBorders(a,h,f+h,null,-h,-h,!1),this.hasBorderShaders=!0}t.append(a)}},e.prototype.insertShaderBorders=function(t,n,r,i,a,o,c){var h=document.createElement("div");h.style.position="absolute",h.style.backgroundColor=Il.BORDER_SHADER_DEFAULT_COLOR,h.style.width="".concat(n,"px"),h.style.height="".concat(r,"px"),i!==null&&(h.style.top="".concat(i,"px")),a!==null&&(h.style.bottom="".concat(a,"px")),c?h.style.left="".concat(o,"px"):h.style.right="".concat(o,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(h),t.appendChild(h)},e.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},e.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},e.prototype.getTimeoutFps=function(t){return 1e3/t},e})(),WV;(function(e){e[e.STATUS_DEFAULT=0]="STATUS_DEFAULT",e[e.STATUS_SUCCESS=1]="STATUS_SUCCESS",e[e.STATUS_WARNING=2]="STATUS_WARNING",e[e.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"})(WV||(WV={}));const N9e=({isOpen:e,onClose:t,onScanSuccess:n})=>{const[r,i]=I.useState([]),[a,o]=I.useState(""),[c,h]=I.useState(!0),[f,m]=I.useState(null),[y,w]=I.useState(""),[A,S]=I.useState(!1),C="qr-camera-scanner-viewport",T=I.useRef(null),D=I.useRef(null);I.useEffect(()=>{if(e)return h(!0),m(null),MS.getCameras().then(Z=>{if(Z&&Z.length>0){i(Z);const q=Z.find(B=>B.label.toLowerCase().includes("back")||B.label.toLowerCase().includes("rear")||B.label.toLowerCase().includes("environment"));o(q?q.id:Z[0].id)}else m("No camera devices detected on this device.");h(!1)}).catch(Z=>{console.warn("Camera detection warning:",Z),m("Failed to launch real-time lens. Chrome regularly restricts live camera access inside sandboxed iframes."),h(!1)}),()=>{V()}},[e]);const V=async()=>{if(T.current&&T.current.isScanning)try{await T.current.stop()}catch(Z){console.warn("Error stopping scanner:",Z)}};I.useEffect(()=>{if(!e||!a||c)return;let Z=!0;return(async()=>{if(await V(),!Z)return;const B=new MS(C);T.current=B;try{await B.start(a,{fps:15,qrbox:(z,F)=>{const $=Math.min(z,F)*.7;return{width:$,height:$}}},z=>{console.log("QR Decoded successfully:",z);let F=z;try{if(z.includes("scan="))F=new URL(z).searchParams.get("scan")||z;else if(z.startsWith("http")){const $=new URL(z);F=$.searchParams.get("scan")||$.searchParams.get("ticket")||z}}catch{}F&&(n(F.trim()),ir.success("Ticket Code decrypted successfully!"),t())},()=>{})}catch(z){console.error("Failed to start scanner:",z),Z&&m("Could not initiate live viewport. Browser sandbox permissions may be restricted.")}})(),()=>{Z=!1,V()}},[e,a,c]);const L=async Z=>{var z;const q=(z=Z.target.files)==null?void 0:z[0];if(!q)return;S(!0);const B=ir.loading("Processing image and executing optic logic...");try{await V();const $=await new MS(C).scanFile(q,!0);console.log("File QR decoded:",$);let Y=$;try{if($.includes("scan="))Y=new URL($).searchParams.get("scan")||$;else if($.startsWith("http")){const X=new URL($);Y=X.searchParams.get("scan")||X.searchParams.get("ticket")||$}}catch{}Y?(ir.dismiss(B),n(Y.trim()),ir.success("Optical Code verified from photo!",{icon:"📸"}),t()):ir.error("Could not find a valid Ticket ID prefix in that code.",{id:B})}catch(F){console.warn("QR decode error from file:",F),ir.error("Decouple optical fail. Make sure the QR Code is highly contrast and fits the viewfinder.",{id:B})}finally{S(!1),D.current&&(D.current.value="")}},K=Z=>{Z.preventDefault(),y.trim()&&(n(y.trim()),ir.success("Manual booking pass lookup triggered!"),t())};return e?s.jsx("div",{className:"fixed inset-0 z-[12000] flex items-center justify-center p-4 bg-zinc-950/90 backdrop-blur-sm animate-fade-in text-left",children:s.jsxs("div",{className:"bg-white rounded-[2.5rem] p-8 w-full max-w-lg shadow-2xl relative overflow-hidden border border-gray-100 flex flex-col max-h-[90vh]",children:[s.jsx("div",{className:"absolute inset-0 bg-grid-zinc-100/30 opacity-20 pointer-events-none"}),s.jsxs("div",{className:"relative flex items-center justify-between mb-6 z-10",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-red-600 font-black text-[9px] uppercase tracking-widest font-mono",children:[s.jsx(Zi,{size:11,className:"animate-spin duration-3000 text-red-500"}),"Passes & Ticket Scanner"]}),s.jsx("h3",{className:"text-lg font-serif font-black text-gray-950 tracking-tight leading-tight uppercase mt-0.5",children:"Rapid QR Verification"})]}),s.jsx("button",{onClick:t,className:"p-2 bg-gray-50 text-gray-900 hover:bg-gray-100 rounded-full transition-all cursor-pointer border border-transparent hover:border-gray-200 flex items-center justify-center",title:"Terminate scanning session",children:s.jsx(er,{size:15,className:"stroke-[2.5]"})})]}),s.jsx("input",{type:"file",ref:D,onChange:L,accept:"image/*",capture:"environment",className:"hidden"}),s.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-5 relative z-10 pr-1",children:[s.jsxs("div",{className:"relative aspect-video bg-zinc-950 rounded-2xl border border-zinc-800 overflow-hidden flex flex-col items-center justify-center",children:[s.jsx("div",{id:C,className:"absolute inset-0 w-full h-full object-cover [&>video]:object-cover"}),c?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-zinc-950 gap-3 text-zinc-400",children:[s.jsx(Er,{className:"animate-spin text-red-500 animate-duration-1000",size:32}),s.jsx("span",{className:"text-[10px] uppercase font-black tracking-widest text-zinc-500",children:"Initializing Optical Feed..."})]}):f?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-zinc-950 p-6 text-center gap-2",children:[s.jsx(ku,{className:"text-orange-500",size:30}),s.jsx("p",{className:"text-[10px] font-black text-zinc-300 uppercase tracking-tight",children:f}),s.jsx("p",{className:"text-[9px] text-zinc-500 max-w-xs leading-relaxed mb-2",children:"Browser sandboxing regularly halts cameras in frames. Snap a snapshot photo instead to decrypt instantly!"}),s.jsxs("button",{type:"button",onClick:()=>{var Z;return(Z=D.current)==null?void 0:Z.click()},className:"px-4 py-2.5 bg-red-650 hover:bg-red-700 text-white rounded-lg text-[9px] font-black uppercase tracking-widest shadow-md hover:shadow-lg transition-all flex items-center gap-2 cursor-pointer",children:[s.jsx(US,{size:12}),"Snap QR Photo 📷"]})]}):s.jsxs("div",{className:"absolute inset-0 pointer-events-none flex flex-col justify-between p-6",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("div",{className:"w-5 h-5 border-t-2 border-l-2 border-red-500"}),s.jsx("div",{className:"w-5 h-5 border-t-2 border-r-2 border-red-500"})]}),s.jsx("div",{className:"w-full h-0.5 bg-gradient-to-r from-transparent via-red-500 to-transparent shadow-[0_0_12px_rgba(239,68,68,0.8)] ",style:{animationDuration:"1.2s"}}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("div",{className:"w-5 h-5 border-b-2 border-l-2 border-red-500"}),s.jsx("div",{className:"w-5 h-5 border-b-2 border-r-2 border-red-500"})]})]}),A&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-zinc-950/80 p-6 text-center gap-2 z-20",children:[s.jsx(Er,{className:"animate-spin text-red-500",size:32}),s.jsx("p",{className:"text-xs font-bold text-zinc-200",children:"Decoding Optical Pass file..."})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>{var Z;return(Z=D.current)==null?void 0:Z.click()},className:"px-4 py-3 bg-red-50 hover:bg-red-100 text-red-650 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all inline-flex items-center justify-center gap-2 border border-red-200/50 cursor-pointer",children:[s.jsx(US,{size:13}),"Snap Code 📷"]}),s.jsxs("button",{type:"button",onClick:()=>{var Z,q;(Z=D.current)==null||Z.removeAttribute("capture"),(q=D.current)==null||q.click(),setTimeout(()=>{var B;return(B=D.current)==null?void 0:B.setAttribute("capture","environment")},500)},className:"px-4 py-3 bg-gray-50 hover:bg-gray-100 text-gray-700 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all inline-flex items-center justify-center gap-2 border border-gray-200 cursor-pointer",children:[s.jsx(fF,{size:13}),"Pick Image File"]})]}),!c&&r.length>1&&s.jsxs("div",{className:"flex items-center gap-1.5 p-1 bg-gray-50 border border-gray-150 rounded-xl",children:[s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400 pl-3 shrink-0",children:"Switch Camera:"}),s.jsx("div",{className:"flex-1 flex gap-1 justify-end",children:r.map((Z,q)=>s.jsxs("button",{onClick:()=>o(Z.id),className:`px-3 py-1.5 rounded-lg text-[9px] font-black uppercase tracking-wider transition-all cursor-pointer ${a===Z.id?"bg-white text-gray-950 shadow-xs ring-1 ring-gray-150":"text-gray-550 hover:text-gray-900"}`,children:["Feed ",q+1]},Z.id))})]}),s.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-gray-450",children:"Stuck? Manual Pass Code Keyer"})]}),s.jsxs("form",{onSubmit:K,className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Paste or enter ticket ID (e.g. h6SndA4v...)",value:y,onChange:Z=>w(Z.target.value),className:"flex-1 px-4 py-3 bg-gray-50 border border-gray-250 focus:border-red-650 rounded-xl text-xs font-bold font-mono outline-none transition-all placeholder:text-gray-400"}),s.jsx("button",{type:"submit",className:"px-5 py-3 bg-zinc-950 hover:bg-zinc-900 text-white rounded-xl text-[9px] font-black uppercase tracking-wider transition-colors cursor-pointer whitespace-nowrap",children:"Verify Code"})]})]})]})]})}):null},KV=[{id:"sample-feat-1",authorId:"campus-pulse",authorName:"Campus Student Guild",authorPhotoURL:"https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150&auto=format&fit=crop&q=80",content:"📢 Guild nominations are officially open! Grab your nomination kits at the main student centre before Friday 5:00 PM.",createdAt:_r.now(),likeCount:84,commentCount:29},{id:"sample-feat-2",authorId:"sports-desk",authorName:"Inter-Hall Sports Desk",authorPhotoURL:"https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=150&auto=format&fit=crop&q=80",content:"⚽ The University Football Derby kicks off this weekend at the Main Arena. Free entry for all verified students!",imageUrl:"https://images.unsplash.com/photo-1508098682722-e99c43a406b2?w=500&auto=format&fit=crop&q=80",createdAt:_r.now(),likeCount:142,commentCount:46},{id:"sample-feat-3",authorId:"tech-innovate",authorName:"Campus Tech & AI Club",authorPhotoURL:"https://images.unsplash.com/photo-1517841905240-472988babdf9?w=150&auto=format&fit=crop&q=80",content:"💡 48-Hour Hackathon announced with cash prizes & direct internship sponsorships! Check out the details in the lounge.",createdAt:_r.now(),likeCount:67,commentCount:18}],E9e=({posts:e,onOpenPosts:t,onAuthorClick:n})=>{const[r,i]=I.useState({}),[a,o]=I.useState({}),c=ie.useMemo(()=>{if(e&&e.length>=3)return e.slice(0,3);if(e&&e.length>0){const f=3-e.length;return[...e,...KV.slice(0,f)]}return KV},[e]),h=async(f,m)=>{var A;f.stopPropagation();const y=r[m.id]||!1,w=a[m.id]!==void 0?a[m.id]:m.likeCount||0;if(i(S=>({...S,[m.id]:!y})),o(S=>({...S,[m.id]:y?Math.max(0,w-1):w+1})),!m.id.startsWith("sample-"))try{const S=Je(he,"posts",m.id),C=(A=Ne.currentUser)==null?void 0:A.uid;y?await Cn(S,{likeCount:Ir(-1),...C?{likedBy:T2(C)}:{}}):await Cn(S,{likeCount:Ir(1),...C?{likedBy:I2(C)}:{}})}catch(S){console.error("Failed to update like:",S)}};return s.jsxs("div",{className:"p-4 sm:p-5 bg-white border border-gray-200/80 rounded-2xl text-left my-4 shadow-xs mx-2 sm:mx-4 select-none",id:"featured-community-posts-section",children:[s.jsxs("div",{className:"flex items-center justify-between pb-2.5 mb-3 border-b border-gray-100 gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(bi,{size:15,className:"text-red-650"}),s.jsx("span",{className:"text-[11px] font-black uppercase tracking-wider text-gray-900 font-sans",children:"Campus Lounge"})]}),s.jsxs("button",{type:"button",onClick:t,className:"text-[9.5px] font-black uppercase tracking-wider text-red-650 hover:text-red-700 bg-red-50 hover:bg-red-100/80 px-2.5 py-1 rounded-lg flex items-center gap-1 transition-all cursor-pointer",children:[s.jsx("span",{children:"View all"}),s.jsx(Op,{size:11})]})]}),s.jsx("div",{className:"space-y-3",children:c.map((f,m)=>{var A;const y=r[f.id]||!1,w=a[f.id]!==void 0?a[f.id]:f.likeCount||0;return s.jsxs("div",{onClick:t,className:"p-3.5 bg-gray-50/60 hover:bg-gray-50 border border-gray-150/70 hover:border-gray-300 rounded-xl transition-all duration-200 cursor-pointer group flex flex-col sm:flex-row items-start gap-3.5 justify-between",children:[s.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[s.jsx("div",{onClick:S=>{f.authorId&&n&&(S.stopPropagation(),n(f.authorId))},className:"shrink-0 pt-0.5 hover:opacity-85 transition-opacity",title:"View author profile",children:f.authorPhotoURL?s.jsx("img",{src:f.authorPhotoURL,alt:f.authorName||"Author",className:"w-9 h-9 rounded-full object-cover border border-gray-200 shadow-2xs",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"w-9 h-9 rounded-full bg-gradient-to-br from-red-600 to-red-800 text-white flex items-center justify-center font-black text-xs uppercase shadow-2xs",children:((A=f.authorName)==null?void 0:A.charAt(0))||"P"})}),s.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{onClick:S=>{f.authorId&&n&&(S.stopPropagation(),n(f.authorId))},className:"flex items-center gap-1.5 min-w-0 hover:underline",children:[s.jsx("span",{className:"text-[11.5px] font-black text-gray-950 truncate font-sans",children:f.authorName||"Campus Peer"}),s.jsx(Fo,{size:12,className:"shrink-0"})]}),s.jsx("span",{className:"text-[8.5px] font-mono font-bold text-gray-400 shrink-0",children:f.createdAt instanceof _r?X0(f.createdAt):"Recent"})]}),s.jsx("p",{className:"text-[12px] font-medium text-gray-800 leading-snug line-clamp-2 font-sans group-hover:text-gray-950 transition-colors",children:f.content}),s.jsxs("div",{className:"flex items-center gap-4 pt-1 text-[10px] text-gray-500 font-mono",children:[s.jsxs("button",{type:"button",onClick:S=>h(S,f),className:Fe("flex items-center gap-1.5 px-2 py-0.5 rounded-md hover:bg-red-50 transition-colors cursor-pointer font-bold",y?"text-red-600 bg-red-50/50":"text-gray-600 hover:text-red-600"),title:"Solidarity support",children:[s.jsx(mc,{size:12,className:y?"fill-red-600 text-red-600 animate-heartbeat":"text-gray-400"}),s.jsx("span",{children:w})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600 font-bold",children:[s.jsx(bi,{size:12,className:"text-gray-400"}),s.jsx("span",{children:f.commentCount||0})]})]})]})]}),f.imageUrl&&s.jsx("div",{className:"w-full sm:w-20 sm:h-20 h-28 rounded-xl overflow-hidden shrink-0 border border-gray-200/80 bg-gray-100 shadow-2xs relative",children:s.jsx("img",{src:f.imageUrl,alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})})]},`feat-post-${f.id}-${m}`)})})]})};class A9e extends ie.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){const n=(t==null?void 0:t.message)||String(t),r=n.toLowerCase();return r.includes("script error")||r.includes("unexpected token")||r.includes("failed to fetch")||r.includes("networkerror")||r.includes("loading chunk")||r.includes("cors")||r.includes("weather")||r.includes("permission")||r.includes("can only be used on")||r.includes("campuseyemedia")||r.includes("onesignal")||r.includes("could not reach cloud firestore backend")||r.includes("firestore")?(console.warn("Recovered from background glitch silently:",n),{hasError:!1,error:null}):{hasError:!0,error:t}}componentDidCatch(t,n){const r=((t==null?void 0:t.message)||String(t)).toLowerCase();if(r.includes("script error")||r.includes("unexpected token")||r.includes("failed to fetch")||r.includes("networkerror")||r.includes("weather")){console.warn("Recoverable silent error tracked:",t);return}console.error("FATAL APP ERROR:",t,n)}render(){var t,n,r;if(this.state.hasError){const i=((t=this.state.error)==null?void 0:t.message)==="Script error."||((r=(n=this.state.error)==null?void 0:n.message)==null?void 0:r.includes("Script error."));return s.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-white p-10 text-center animate-fade-in relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",style:{backgroundImage:"radial-gradient(#000 1px, transparent 1px)",backgroundSize:"20px 20px"}}),s.jsxs("div",{className:"relative z-10",children:[s.jsx("div",{className:"w-24 h-24 bg-red-50 text-red-600 rounded-3xl flex items-center justify-center mb-8 shadow-xl shadow-red-100 mx-auto",children:s.jsx(ku,{size:48})}),s.jsx("h1",{className:"text-4xl md:text-5xl font-black text-gray-900 uppercase tracking-tighter italic mb-6 leading-none",children:i?"Connection Issue":"System Glitch"}),s.jsx("p",{className:"text-gray-500 font-bold max-w-md mx-auto mb-10 leading-relaxed uppercase tracking-wider text-xs",children:i?"An external service (possibly OneSignal or Google AdSense) was briefly blocked. This is common and shouldn't stop your reading.":"We've hit a minor roadblock in the newsroom. Don't worry, we're fixing it live."}),s.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[s.jsx("button",{onClick:()=>window.location.reload(),className:"px-10 py-5 bg-red-600 text-white font-black uppercase tracking-[0.2em] hover:bg-black transition-all rounded-2xl shadow-2xl shadow-red-200 text-xs",children:"Reboot Newsroom"}),s.jsx("button",{onClick:()=>this.setState({hasError:!1,error:null}),className:"px-10 py-5 bg-gray-100 text-gray-500 font-black uppercase tracking-[0.2em] hover:bg-gray-200 transition-all rounded-2xl text-xs",children:"Try to Ignore"})]}),this.state.error&&!i&&s.jsxs("div",{className:"mt-16 text-left max-w-2xl mx-auto",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-300 uppercase tracking-widest mb-4",children:"Diagnostic Trace"}),s.jsx("pre",{className:"p-6 bg-gray-50 border border-gray-100 rounded-2xl text-[10px] text-gray-400 font-mono overflow-auto custom-scrollbar",children:this.state.error.stack||this.state.error.message})]})]})]})}return this.props.children}}function _9e(){return s.jsx(eF,{children:s.jsx(A9e,{children:s.jsx(I9e,{})})})}const k9e=({className:e})=>s.jsxs("div",{className:Fe("flex flex-col items-center justify-center space-y-3.5 py-6 px-8 bg-white/90 backdrop-blur-md border border-gray-150 rounded-[2rem] shadow-xl animate-fade-in relative z-50 max-w-xs",e),children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("span",{className:"w-4 h-4 bg-red-650 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),s.jsx("span",{className:"w-4 h-4 bg-blue-600 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),s.jsx("span",{className:"w-4 h-4 bg-emerald-500 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),s.jsx("span",{className:"text-[10px] font-sans font-black uppercase tracking-custom text-gray-500 select-none",children:"Gathering campus reports..."})]}),S9e=()=>s.jsx("div",{className:"w-full max-w-[1680px] xl:max-w-[1780px] 2xl:max-w-[1880px] mx-auto pt-4 pb-20 px-2 sm:px-4 lg:px-6 xl:px-8",children:s.jsxs("div",{className:"grid grid-cols-12 gap-4 lg:gap-5 xl:gap-6 2xl:gap-8",children:[s.jsxs("aside",{className:"hidden lg:block lg:col-span-3 space-y-4 text-left",children:[s.jsxs("div",{className:"bg-white border border-gray-150 shadow-xs rounded-2xl p-4 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-1.5 font-black text-gray-400 text-[10px] tracking-widest pb-2 border-b border-gray-100 uppercase",children:[s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-gray-200 shrink-0 "}),s.jsx("span",{children:"Latest News"})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2 pt-1 ",children:[1,2].map(e=>s.jsxs("div",{className:"border border-gray-150 rounded-xl overflow-hidden bg-white flex flex-col space-y-2 pb-2",children:[s.jsx("div",{className:"aspect-[1.4] bg-gray-200 w-full"}),s.jsxs("div",{className:"px-2 space-y-1.5",children:[s.jsx("div",{className:"h-2.5 bg-gray-250 w-full rounded"}),s.jsx("div",{className:"h-2 bg-gray-200 w-2/3 rounded"})]})]},e))})]}),s.jsxs("div",{className:"bg-gradient-to-tr from-gray-955 via-gray-900 to-gray-955 p-4 rounded-2xl text-white border border-white/10 space-y-3.5 shadow-md ",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-200 shrink-0"}),s.jsx("span",{className:"text-[8.5px] font-mono font-black uppercase text-gray-400 tracking-[0.2em]",children:"Latest Lounge Updates"})]}),s.jsx("div",{className:"space-y-3 pt-1",children:[1,2,3].map(e=>s.jsxs("div",{className:"flex items-start gap-2.5 p-2 rounded-xl bg-white/5 border border-white/5",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-white/10 shrink-0"}),s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsx("div",{className:"h-2.5 bg-white/20 rounded w-1/3"}),s.jsx("div",{className:"h-2 bg-white/10 rounded w-5/6"})]})]},e))})]})]}),s.jsxs("main",{className:"col-span-12 lg:col-span-6 space-y-5 px-0 bg-white border-r border-l border-gray-100/60",children:[s.jsx("div",{className:"border-b border-gray-100 pb-3 px-4 flex items-center justify-between",children:s.jsx("div",{className:"h-4 w-36 bg-gray-200 rounded "})}),s.jsxs("div",{className:"divide-y divide-gray-100",children:[s.jsx(Sp,{variant:"social"}),s.jsx(Sp,{variant:"social"}),s.jsx(Sp,{variant:"social"})]})]}),s.jsxs("aside",{className:"col-span-12 lg:col-span-3 space-y-4 text-left",children:[s.jsxs("div",{className:"bg-white border border-gray-150 rounded-3xl p-5 shadow-sm space-y-4 ",children:[s.jsx("div",{className:"flex items-center gap-2 font-black text-gray-400 text-[10px] tracking-widest pb-3 border-b border-gray-100 uppercase",children:s.jsx("span",{children:"Trending Sagas"})}),s.jsx("div",{className:"space-y-3.5 pt-1",children:[1,2,3,4].map(e=>s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-2 bg-gray-200 rounded w-1/4"}),s.jsx("div",{className:"h-3.5 bg-gray-255 rounded w-3/4"})]},e))})]}),s.jsxs("div",{className:"bg-gradient-to-br from-indigo-950 via-slate-900 to-black rounded-3xl p-4 shadow-md space-y-3 border border-white/10 text-white ",children:[s.jsx("div",{className:"h-2.5 bg-indigo-300/30 rounded w-1/3"}),s.jsx("div",{className:"flex justify-center py-2",children:s.jsx("div",{className:"h-10 bg-white/10 rounded-xl w-3/4"})})]})]})]})}),C9e=({userId:e})=>{const[t,n]=ie.useState([]),[r,i]=ie.useState(!0),[a,o]=ie.useState(null);return ie.useEffect(()=>{if(!e)return;const c=Qt(et(he,"purchases"),Ar("userId","==",e));vn(c).then(h=>{n(h.docs.map(f=>({id:f.id,...f.data()}))),i(!1)}).catch(h=>{Ks(h,Ms.LIST,"purchases"),n([]),i(!1)})},[e]),r?s.jsx("div",{className:"flex justify-center p-4",children:s.jsx(Er,{className:"animate-spin text-red-600",size:20})}):t.length===0?s.jsx("div",{className:"bg-gray-50 rounded-2xl p-8 text-center text-left",children:s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest leading-loose",children:"No active tickets found in your inventory."})}):s.jsxs("div",{className:"space-y-3 text-left",children:[t.map(c=>s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-gray-50 rounded-2xl border border-gray-100 group transition-all hover:bg-white hover:shadow-xs",children:[s.jsx("button",{onClick:()=>o(c),className:"shrink-0 relative overflow-hidden bg-white p-1 rounded-xl border border-gray-150 shadow-2xs hover:border-red-200 transition-colors cursor-zoom-in",type:"button",title:"Click to zoom in on pass QR code",children:s.jsx("img",{src:`https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=${encodeURIComponent(window.location.origin+"?scan="+c.id)}`,alt:"Scan Gate Pass QR",className:"w-12 h-12 rounded-lg object-contain",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>o(c),children:[s.jsx("h4",{className:"text-xs font-black text-gray-900 uppercase tracking-tight truncate",children:c.ticketTitle}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[c.taken||c.used?s.jsx("span",{className:"text-[9px] font-black text-green-700 bg-green-50 border border-green-200 rounded px-2 py-0.5 uppercase flex items-center gap-1 select-none font-mono",children:"✔️ Ticked & Used"}):s.jsx("span",{className:"text-[9px] font-black text-red-650 bg-red-50 border border-red-150 rounded px-2 py-0.5 uppercase flex items-center gap-1 font-mono",children:"🎟️ Confirmed (Active)"}),s.jsxs("span",{className:"text-[9px] font-bold text-gray-500 bg-gray-100 rounded px-1.5 py-0.5 uppercase font-mono",children:["Qty: ",c.quantity]})]})]}),s.jsxs("div",{className:"text-right shrink-0 cursor-pointer",onClick:()=>o(c),children:[s.jsxs("p",{className:"text-[9px] font-black text-gray-900",children:["#",c.id.slice(-6).toUpperCase()]}),s.jsx("p",{className:"text-[8px] font-bold text-gray-400 uppercase",children:c.purchaseDate instanceof _r?c.purchaseDate.toDate().toLocaleDateString():"Recent"})]})]},c.id)),a&&s.jsx("div",{className:"fixed inset-0 bg-black/85 backdrop-blur-md flex items-center justify-center p-4 z-[9999]",onClick:()=>o(null),children:s.jsxs("div",{className:"bg-white p-8 rounded-[2.5rem] border border-gray-100 w-full max-w-sm text-center relative shadow-2xl animate-in fade-in zoom-in-95 duration-200",onClick:c=>c.stopPropagation(),children:[s.jsx("button",{className:"absolute top-6 right-6 p-1.5 bg-gray-50 text-gray-900 hover:bg-gray-100 rounded-full transition-all cursor-pointer",onClick:()=>o(null),children:s.jsx(er,{size:16,className:"stroke-[2.5]"})}),s.jsx("p",{className:"text-[10px] font-black text-red-600 uppercase tracking-widest mb-1.5 font-mono",children:"Live Event Entry Pass"}),s.jsx("h3",{className:"text-sm font-serif font-black text-gray-950 uppercase tracking-tight leading-tight mb-6",children:a.ticketTitle}),s.jsx("div",{className:"bg-white p-4 rounded-[2.2rem] border border-gray-150 inline-block shadow-inner mb-6 mx-auto",children:s.jsx("img",{src:`https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=${encodeURIComponent(window.location.origin+"?scan="+a.id)}`,alt:"Verification QR code",className:"w-48 h-48 rounded-2xl object-contain mx-auto",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"bg-gray-50 p-4 rounded-2xl border border-gray-100",children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest mb-1",children:"Unique Ticket Pass ID"}),s.jsx("code",{className:"text-[10px] font-mono font-black text-gray-950 uppercase select-all",children:a.id})]}),s.jsxs("div",{className:"flex items-center justify-between text-left text-[10px] font-bold text-gray-500 uppercase px-1",children:[s.jsxs("span",{children:["Quantity: ",s.jsxs("strong",{className:"text-gray-900",children:[a.quantity," Pax"]})]}),s.jsxs("span",{children:["Status: ",s.jsx("strong",{className:a.taken||a.used?"text-green-600 font-mono font-black":"text-red-650 font-mono font-black",children:a.taken||a.used?"✔️ TICKED / USED":"🎟️ ACTIVE"})]})]})]}),s.jsx("p",{className:"text-[8px] font-black uppercase tracking-[0.25em] text-gray-400 mt-8 font-mono",children:"Scan at gate to check in"})]})})]})},j9e=({userId:e})=>{const[t,n]=ie.useState([]),[r,i]=ie.useState(!0),[a,o]=ie.useState({}),c=(h,f)=>{f&&f.stopPropagation(),o(m=>({...m,[h]:!m[h]}))};return ie.useEffect(()=>{if(!e)return;const h=Qt(et(he,"notifications"),Ar("userId","==",e));vn(h).then(f=>{const m=f.docs.map(y=>{var A;const w=y.data();return{id:y.id,...w,createdAt:(A=w.createdAt)!=null&&A.toDate?w.createdAt.toDate():new Date(w.createdAt||Date.now())}});m.sort((y,w)=>w.createdAt.getTime()-y.createdAt.getTime()),n(m),i(!1)}).catch(f=>{console.warn("Silent ignore feedback notifications error:",f),i(!1)})},[e]),r?s.jsx("div",{className:"flex justify-center p-4",children:s.jsx(Er,{className:"animate-spin text-red-600",size:20})}):t.length===0?s.jsx("div",{className:"bg-gray-50 rounded-2xl p-8 text-center text-left",children:s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest leading-loose",children:"No active notification dispatches found in your inbox."})}):s.jsx("div",{className:"space-y-3 text-left",children:t.map((h,f)=>{const m=!!a[h.id],y=h.imageUrl||h.image,w=h.fullAnswer||h.message||"";return s.jsxs("div",{className:Fe("p-4 rounded-2xl border transition-all flex flex-col gap-2 relative group overflow-hidden break-words min-w-0",h.used?"bg-gray-50/50 border-gray-100 opacity-80":"bg-red-50/20 border-red-200 shadow-xs"),children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("span",{className:Fe("text-[8px] font-black uppercase px-2 py-0.5 rounded-md flex items-center gap-1",h.used?"bg-gray-100 text-gray-500":"bg-red-650 text-white shadow-2xs"),children:h.type==="admin_mega_reply"||h.type==="mega_ai_reply"?"🤖 AI / Admin Reply":h.used?"Opened":"Unread Dispatch"}),s.jsx("span",{className:"text-[8px] font-mono text-gray-400 leading-none",children:h.createdAt instanceof Date?h.createdAt.toLocaleString([],{dateStyle:"short",timeStyle:"short"}):"Recent"})]}),s.jsx("button",{onClick:A=>c(h.id,A),className:"px-2 py-1 bg-white hover:bg-gray-100 text-gray-700 hover:text-black rounded-lg transition-all cursor-pointer border border-gray-200 shadow-2xs flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider shrink-0",title:m?"Minimize notification":"Expand notification details",children:m?s.jsxs(s.Fragment,{children:[s.jsx(df,{size:12,className:"text-red-600"}),s.jsx("span",{children:"Minimize"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Bd,{size:12,className:"text-indigo-600"}),s.jsx("span",{children:"Expand"})]})})]}),s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("h4",{className:"text-xs font-black text-gray-900 uppercase tracking-tight flex items-center gap-1.5",children:[s.jsx(Zi,{size:12,className:"text-amber-500 shrink-0"}),s.jsx("span",{className:"truncate",children:h.title})]}),!m&&s.jsx("p",{className:"text-[10px] text-gray-600 leading-relaxed font-sans mt-1 line-clamp-2 bg-white/60 p-2 rounded-xl border border-gray-100/80",children:w})]}),!m&&y&&s.jsx("div",{onClick:A=>c(h.id,A),className:"w-12 h-12 rounded-xl overflow-hidden border border-gray-200 shrink-0 shadow-2xs relative bg-gray-100 cursor-pointer hover:scale-105 transition-transform",title:"Click to expand image",children:s.jsx(Li,{src:y,alt:h.title||"Broadcast thumbnail",className:"w-full h-full object-cover"})})]}),m&&s.jsxs("div",{className:"space-y-2.5 mt-1 animate-in fade-in slide-in-from-top-1 duration-200",children:[s.jsx("p",{className:"text-[10.5px] text-gray-700 leading-relaxed font-sans bg-white p-3 rounded-xl border border-gray-200/80 shadow-2xs whitespace-pre-wrap",children:w}),h.userQuery&&s.jsxs("div",{className:"text-[9px] text-gray-500 italic font-mono px-2 py-1.5 bg-gray-50 rounded-lg border border-gray-100",children:[s.jsx("span",{className:"font-bold not-italic text-gray-600",children:"Your Question:"})," ",'"',h.userQuery,'"']}),y&&s.jsxs("div",{className:"rounded-xl overflow-hidden border border-gray-200/90 h-44 sm:h-52 w-full relative shadow-xs bg-black/5",children:[s.jsx(Li,{src:y,alt:h.title||"Broadcast image",title:h.title,className:"w-full h-full object-cover"}),s.jsx("div",{className:"absolute top-2 right-2 px-2 py-0.5 bg-black/70 backdrop-blur-md text-white text-[8px] font-black uppercase rounded-md tracking-wider border border-white/20",children:"Full Preview"})]}),h.code&&!h.used&&s.jsxs("div",{className:"p-2.5 bg-purple-900/10 border border-purple-200 rounded-xl flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(Aa,{size:14,className:"text-purple-700 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[7.5px] font-black uppercase text-purple-900 tracking-wider",children:"Pass Verification Key Code"}),s.jsx("code",{className:"text-xs font-black font-mono text-purple-950 tracking-widest",children:h.code})]})]}),s.jsx("button",{onClick:()=>{navigator.clipboard.writeText(h.code),pe.success("Security OTP copied to clipboard!",{icon:"📋"})},className:"px-2.5 py-1 text-[8.5px] font-black uppercase tracking-widest bg-purple-700 hover:bg-purple-800 text-white rounded-lg flex items-center gap-1 cursor-pointer transition-all shadow-xs shrink-0",children:"Copy Key Code"})]}),s.jsxs("div",{className:"pt-2 border-t border-gray-200/60 flex items-center justify-between gap-2 flex-wrap",children:[h.link||h.actionUrl?s.jsxs("a",{href:h.link||h.actionUrl,target:(h.link||h.actionUrl).startsWith("http")?"_blank":"_self",rel:"noopener noreferrer",onClick:()=>{try{const A=localStorage.getItem("clicked_notification_links"),S=A?JSON.parse(A):{};S[h.link||h.actionUrl]=!0,localStorage.setItem("clicked_notification_links",JSON.stringify(S))}catch{}},className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-700 text-white text-[9.5px] font-black uppercase tracking-wider rounded-xl transition-all inline-flex items-center gap-1.5 shadow-2xs",children:[s.jsx($a,{size:11}),s.jsx("span",{children:"Open Attached Link"})]}):s.jsx("div",{}),s.jsxs("button",{onClick:A=>c(h.id,A),className:"px-2.5 py-1 text-[8.5px] font-black uppercase tracking-wider text-gray-700 hover:text-black bg-white hover:bg-gray-100 rounded-lg border border-gray-200 transition-all flex items-center gap-1 cursor-pointer ml-auto",children:[s.jsx(df,{size:10})," Minimize"]})]})]})]},`notif-${h.id}-${f}`)})})},Bh=e=>{if(!e)return"";let t=e.toLowerCase().trim().replace(/[^a-z0-9]/g,"");return(t==="campusnews"||t==="news"||t==="campus-news")&&(t="news"),(t==="sports"||t==="sport")&&(t="sport"),t};function I9e(){var fo,Zo,ga,po,Fr,Ra,Oo,Qa,Ro,at,pr,Jr;const[e,t]=ie.useState(!0),[n,r]=ie.useState(!navigator.onLine);ie.useEffect(()=>{const ge=()=>{t(document.visibilityState==="visible")};return document.addEventListener("visibilitychange",ge),()=>document.removeEventListener("visibilitychange",ge)},[]),ie.useEffect(()=>{const ge=()=>{r(!1),pe.success("Connection restored! Syncing latest campus reports...",{icon:"⚡"})},we=()=>{r(!0),pe.error("You are currently offline. Accessing previously loaded reports...",{icon:"📦"})};return window.addEventListener("online",ge),window.addEventListener("offline",we),()=>{window.removeEventListener("online",ge),window.removeEventListener("offline",we)}},[]),ie.useEffect(()=>{const ge=we=>{if(we.target&&we.target!==window)return;let Pe="";if(we instanceof PromiseRejectionEvent){const $e=we.reason;if($e){const ct=String($e.message||$e).toLowerCase();if(ct.includes("offline")||ct.includes("could not reach"))return;Pe=$e.message||String($e)}}else if(we instanceof ErrorEvent)Pe=we.message||"";else return;!Pe||Pe==="Script error."||Pe.includes("Script error.")||Pe.toLowerCase().includes("offline")||Pe.toLowerCase().includes("backend didn't respond")||Pe.toLowerCase().includes("websocket")||Pe.toLowerCase().includes("closed without opened")||console.error("Fatal App Error:",Pe)};return window.addEventListener("error",ge),window.addEventListener("unhandledrejection",ge),()=>{window.removeEventListener("error",ge),window.removeEventListener("unhandledrejection",ge)}},[]);const i=(ge,we)=>{const Pe=ge?ge.slice(0,2).trim().toUpperCase():"CE",$e=(we==null?void 0:we.toLowerCase())||"news";let ct="%23ef4444";return $e==="sports"&&(ct="%233b82f6"),$e==="opinion"&&(ct="%2310b981"),$e==="lifestyle"&&(ct="%238b5cf6"),$e==="entertainment"&&(ct="%23f59e0b"),`data:image/svg+xml;utf8,${Pe}${$e.toUpperCase()}`},a=["atwiinevictor2@gmail.com","campuseye@gmail.com"],[o,c]=ie.useState(()=>{try{const ge=localStorage.getItem("campus_eye_articles_cache");return ge?JSON.parse(ge).map(Pe=>({...Pe,isOfflineCached:!0})):[]}catch{return[]}}),[h,f]=ie.useState(()=>{try{const ge=localStorage.getItem("campus_eye_articles_cache");return ge?JSON.parse(ge).map(Pe=>({...Pe,isOfflineCached:!0})):[]}catch{return[]}}),[m,y]=ie.useState(()=>{try{const ge=localStorage.getItem("campus_eye_articles_cache");return ge?JSON.parse(ge).length===0:!1}catch{return!1}}),[w,A]=ie.useState(!0),[S,C]=ie.useState(1),[T,D]=ie.useState(10),[V,L]=ie.useState(15),K=ie.useRef(25);K.current=V;const Z=ie.useRef(o.length);ie.useEffect(()=>{Z.current=o.length},[o.length]);const q=ie.useCallback((ge=15)=>{L(we=>we+ge)},[]),B=ie.useRef(null),z=ie.useCallback(ge=>{B.current&&B.current.disconnect(),ge&&(B.current=new IntersectionObserver(we=>{var Pe;(Pe=we[0])!=null&&Pe.isIntersecting&&q()},{rootMargin:"250px"}),B.current.observe(ge))},[q]);ie.useCallback(ge=>{if(!ge)return;const we=new IntersectionObserver(Pe=>{var $e;($e=Pe[0])!=null&&$e.isIntersecting&&q()},{rootMargin:"350px"});return we.observe(ge),()=>we.disconnect()},[q]),ie.useEffect(()=>{let ge=null;const we=()=>{ge||(ge=setTimeout(()=>{ge=null,window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-1e3&&q()},100))};return window.addEventListener("scroll",we,{passive:!0}),()=>{window.removeEventListener("scroll",we),ge&&clearTimeout(ge)}},[q]);const[F,$]=ie.useState([]),[Y,X]=ie.useState(()=>{try{const ge=window.location.pathname,we=new URLSearchParams(window.location.search);let Pe=null,$e=null;if(ge.startsWith("/p/share/")){const ot=ge.split("/p/share/")[1];ot&&(Pe=ot.split("/")[0])}else if(ge.includes("/articles=")||ge.startsWith("/articles/")){const _t=ge.replace(/^\/articles=?/,"").split("/").filter(Boolean);_t.length>=2?($e=_t[0],Pe=_t[1]):_t[0]&&(/^[a-zA-Z0-9_-]{15,30}$/.test(_t[0])?Pe=_t[0]:$e=_t[0])}else if(ge.startsWith("/poll/")&&ge.includes("/candidate/")){const ot=ge.split("/candidate/");ot[1]&&($e=ot[1].split("/")[0])}Pe||(Pe=we.get("id")||we.get("articleId")),$e||($e=we.get("articles")||we.get("article"));const ct=localStorage.getItem("campus_eye_articles_cache");if(ct){const ot=JSON.parse(ct);if(Pe){const _t=ot.find(pn=>pn.id===Pe);if(_t)return _t}if($e){const _t=$e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),pn=ot.find(Lt=>{const bn=Lt.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return bn===_t||bn.replace(/-/g,".")===_t});if(pn)return pn}}}catch{}return null}),[J,ye]=ie.useState(()=>{try{const ge=window.location.pathname,we=new URLSearchParams(window.location.search);let Pe=null,$e=null;if(ge.startsWith("/p/share/")){const ct=ge.split("/p/share/")[1];ct&&(Pe=ct.split("/")[0])}else if(ge.includes("/articles=")||ge.startsWith("/articles/")){const ot=ge.replace(/^\/articles=?/,"").split("/").filter(Boolean);ot.length>=2?($e=ot[0],Pe=ot[1]):ot[0]&&(/^[a-zA-Z0-9_-]{15,30}$/.test(ot[0])?Pe=ot[0]:$e=ot[0])}else if(ge.startsWith("/poll/")&&ge.includes("/candidate/")){const ct=ge.split("/candidate/");ct[1]&&($e=ct[1].split("/")[0])}if(Pe||(Pe=we.get("id")||we.get("articleId")),$e||($e=we.get("articles")||we.get("article")),Pe||$e){const ct=localStorage.getItem("campus_eye_articles_cache");if(ct){const ot=JSON.parse(ct);if(Pe&&ot.some(_t=>_t.id===Pe))return!1;if($e){const _t=$e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(ot.some(pn=>{const Lt=pn.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return Lt===_t||Lt.replace(/-/g,".")===_t}))return!1}}return!0}}catch{}return!1}),[ne,de]=ie.useState(()=>{try{const ge=localStorage.getItem("campus_eye_custom_pages_cache");return ge?JSON.parse(ge):[]}catch{return[]}}),[be,Ce]=ie.useState(null),[Ke,G]=ie.useState(!1),[se,xe]=ie.useState(!1),[re,Me]=ie.useState(null);ie.useEffect(()=>{const ge=we=>{const Pe=we;Pe.detail&&Me(Pe.detail)};return window.addEventListener("play-video-podcast",ge),()=>{window.removeEventListener("play-video-podcast",ge)}},[]);const[nt,ze]=ie.useState(null),[Tt,It]=ie.useState(null),[ft,Ee]=ie.useState(null),[yt,Ue]=ie.useState(!1),[Vt,St]=ie.useState(!1),[tn,Pt]=ie.useState(null),[Nt,Kt]=ie.useState(null),[ut,Jt]=ie.useState(!1),[Dt,hn]=ie.useState(!1),[qn,mn]=ie.useState(null),[vr,Ve]=ie.useState(null),[Mt,cn]=ie.useState(null);ie.useEffect(()=>{const ge=new URLSearchParams(window.location.search),we=ge.get("scan");we&&Pt(we);const Pe=window.location.pathname;let $e=ge.get("postId")||ge.get("post"),ct=ge.get("pinnedId")||ge.get("pinned"),ot=ge.get("advertId")||ge.get("advert");if(Pe.startsWith("/p/post/")){const pn=Pe.split("/p/post/")[1];$e=pn?pn.split("/")[0]:null}else if(Pe.startsWith("/p/pinned/")){const pn=Pe.split("/p/pinned/")[1];ct=pn?pn.split("/")[0]:null}else if(Pe.startsWith("/p/ad/")){const pn=Pe.split("/p/ad/")[1];ot=pn?pn.split("/")[0]:null}$e&&(ze($e),Xt("posts"),pe.success("Shared campus dispatch loaded!",{icon:"📣"})),ct&&(It(ct),Xt("home"),pe.success("Shared pinned announcement loaded!",{icon:"📌"})),ot&&(Ee(ot),Xt("home"),pe.success("Partnership offer loaded!",{icon:"⭐"}));const _t=ge.get("invite");if(_t){let pn="A peer";_t.endsWith("-invites-you")?pn=_t.replace("-invites-you","").split("-").map(rn=>rn.charAt(0).toUpperCase()+rn.slice(1)).join(" "):_t!=="student-lounge"&&(pn=_t.split("-").map(bn=>bn.charAt(0).toUpperCase()+bn.slice(1)).join(" ")),Xt("posts"),pe.success(`Welcome! ${pn} has invited you to join the Campus Eye Student Lounge! 🤝`,{duration:6e3,icon:"👋"});const Lt=new URL(window.location.href);Lt.searchParams.delete("invite"),window.history.replaceState({},"",Lt.toString())}},[]),ie.useEffect(()=>{const ge=()=>{G(!0)};return window.addEventListener("open-lounge-auth",ge),()=>{window.removeEventListener("open-lounge-auth",ge)}},[]),ie.useEffect(()=>{if(!tn){Kt(null);return}Jt(!0),cs(Je(he,"purchases",tn)).then(ge=>{ge.exists()?Kt({id:ge.id,...ge.data()}):(pe.error("Ticket purchase record not found!"),Pt(null)),Jt(!1)}).catch(ge=>{console.error("Error fetching scanned ticket:",ge),pe.error("Error retrieving scanned ticket."),Jt(!1),Pt(null)})},[tn]);const[dn,mr]=ie.useState(()=>{try{const ge=window.location.pathname;if(ge==="/u/dashboard")return"admin";if(ge.startsWith("/u/profile"))return"account";const Pe=new URLSearchParams(window.location.search).get("tab");if(Pe)return Pe==="news"||Pe==="campusnews"||Pe==="campus-news"?"home":Pe}catch{}return"home"}),[gr,wi]=ie.useState("home"),Xt=ge=>{const we=ge==="news"||ge==="campusnews"||ge==="campus-news"?"home":ge;wi(dn),mr(we)},me=dn,[qe,st]=ie.useState("all"),[dt,An]=ie.useState(null),[Ft,Dn]=ie.useState(!0),[Ot,on]=ie.useState(null),[jr,lr]=ie.useState(!1),[ue,Se]=ie.useState(0),[Qe,Gt]=ie.useState(0),[Fn,xn]=ie.useState(!1),[kn,xt]=ie.useState("dashboard"),[$n,Et]=ie.useState(()=>{try{return localStorage.getItem("just_signed_up")==="true"}catch{return!1}}),[je,ln]=ie.useState([]),[bt,yn]=ie.useState(!1);ie.useEffect(()=>{try{const ge=new URL(window.location.href),we=ge.pathname;if(dn==="admin")we!=="/u/dashboard"&&window.history.replaceState({},"","/u/dashboard");else if(dn==="account")if(Ot){const Pe=`/u/profile/${Ot.id}`;we!==Pe&&window.history.replaceState({},"",Pe)}else we!=="/u/profile"&&window.history.replaceState({},"","/u/profile");else if(Y){const Pe=Y.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),$e=`/p/share/${Y.id}/${Pe}`;we!==$e&&window.history.replaceState({},"",$e)}else{const Pe=new URLSearchParams(window.location.search);dn==="home"?Pe.delete("tab"):Pe.set("tab",dn);const $e=Pe.toString(),ct="/"+($e?`?${$e}`:"");(we!=="/"||ge.search!==($e?`?${$e}`:""))&&window.history.replaceState({},"",ct)}}catch(ge){console.warn("Path sync fail:",ge)}},[dn,Ot,Y]),ie.useEffect(()=>{const ge=Ne.onAuthStateChanged(async we=>{var Pe,$e;if(we)try{const ct=Je(he,"users",we.uid),ot=["atwiinevictor2@gmail.com","campuseye@gmail.com"],_t=await cs(ct),pn=_t.exists()?_t.data():{},bn=ot.includes(we.email||"")||pn.isAdmin===!0||pn.role==="admin";await Rr(ct,{uid:we.uid,email:we.email||"",displayName:pn.displayName||we.displayName||((Pe=we.email)==null?void 0:Pe.split("@")[0])||"Campus Member",username:pn.username||(($e=we.email)==null?void 0:$e.split("@")[0])||"user",photoURL:pn.photoURL||we.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(we.displayName||"User")}&background=random`,role:bn?"admin":pn.role||"user",isAdmin:bn,updatedAt:En()},{merge:!0});const rn=localStorage.getItem("campus_eye_personalization_v1");if(rn&&JSON.parse(rn).interests){Et(!1),await Rr(ct,{interests:JSON.parse(rn).interests},{merge:!0});return}if(_t.exists()){const _=_t.data();if(_!=null&&_.interests&&Array.isArray(_.interests)&&_.interests.length>0){const U={interests:_.interests,categories:{}};_.interests.forEach(H=>{U.categories[H]=150}),localStorage.setItem("campus_eye_personalization_v1",JSON.stringify(U)),localStorage.removeItem("just_signed_up"),Et(!1);return}}localStorage.getItem("just_signed_up")==="true"&&Et(!0)}catch{}});return()=>ge()},[]),ie.useEffect(()=>{try{const ge=window.location.pathname;let we=null;if(ge.startsWith("/u/profile/")?we=ge.split("/u/profile/")[1]:we=new URLSearchParams(window.location.search).get("uid"),we&&Ne.currentUser&&we===Ne.currentUser.uid){on(null);return}dn==="account"&&we?(lr(!0),cs(Je(he,"users",we)).then(Pe=>{Pe.exists()?on({id:Pe.id,...Pe.data()}):(pe.error("Requested peer profile was not found on Campus Eye.",{id:"profile-not-found"}),on(null)),lr(!1)}).catch(Pe=>{console.warn("Shared user fetch fail:",Pe),lr(!1)})):on(null)}catch{}},[dn,(fo=Ne.currentUser)==null?void 0:fo.uid]);const Ut=async ge=>{var we;try{if(!ge)return;if(ge===((we=Ne.currentUser)==null?void 0:we.uid)){on(null),Xt("account");return}lr(!0);const Pe=await cs(Je(he,"users",ge));if(Pe.exists()){on({id:Pe.id,...Pe.data()}),Xt("account"),lr(!1);return}const $e=ge.replace(/^@/,"").toLowerCase().trim(),ct=Qt(et(he,"users"),Ar("username","==",$e)),ot=await vn(ct);if(!ot.empty){const Lt=ot.docs[0];on({id:Lt.id,...Lt.data()}),Xt("account"),lr(!1);return}const pn=(await vn(et(he,"users"))).docs.find(Lt=>{const bn=Lt.data(),rn=(bn.displayName||"").toLowerCase().replace(/\s+/g,""),He=(bn.username||"").toLowerCase().replace(/\s+/g,"");return rn===$e||He===$e});pn?(on({id:pn.id,...pn.data()}),Xt("account")):(pe.error("Requested peer profile was not found on Campus Eye.",{id:"profile-not-found"}),on(null)),lr(!1)}catch(Pe){console.warn("Navigate to profile failed:",Pe),lr(!1)}};ie.useEffect(()=>{if(!Ot){Se(0),Gt(0),xn(!1);return}try{const ge=et(he,"follows");vn(ge).then(we=>{let Pe=0,$e=0,ct=!1;we.docs.forEach(ot=>{const _t=ot.data();_t.followerId===Ot.id&&Pe++,_t.followedId===Ot.id&&$e++,Ne.currentUser&&_t.followerId===Ne.currentUser.uid&&_t.followedId===Ot.id&&(ct=!0)}),Se(Pe),Gt($e),xn(ct)}).catch(we=>console.warn("Quiet ignore query follows constraint:",we))}catch(ge){console.warn("Silent follows fail:",ge)}},[Ot,(Zo=Ne.currentUser)==null?void 0:Zo.uid]),ie.useEffect(()=>(window.triggerAuthWithCallback=ge=>{ge?window.onAuthPendingAction=ge:window.onAuthPendingAction=void 0,G(!0)},()=>{window.triggerAuthWithCallback=void 0,window.onAuthPendingAction=void 0}),[]);const[On,Mr]=ie.useState(0),[ji,rs]=ie.useState(0),[pi,mi]=ie.useState(0),[vs,gi]=ie.useState([]),$r=ie.useMemo(()=>[...ne.filter(we=>we.isPinnedStyle===!0).map(we=>{var ct,ot,_t,pn;let Pe="";try{we.url.includes("v=")?Pe=((ct=we.url.split("v=")[1])==null?void 0:ct.split("&")[0])||"":we.url.includes("youtu.be/")?Pe=((ot=we.url.split("youtu.be/")[1])==null?void 0:ot.split("?")[0])||"":we.url.includes("embed/")&&(Pe=((_t=we.url.split("embed/")[1])==null?void 0:_t.split("?")[0])||"")}catch{}const $e=Pe?`https://img.youtube.com/vi/${Pe}/maxresdefault.jpg`:i(we.name,"Custom Tab");return{id:`custom-page-${we.id}`,title:we.name,description:we.description||"Interactive broadcast and real-time live chat channel.",isLiveStream:we.type==="youtube"||we.type==="custom_stream",liveEmbedUrl:we.url,link:"",active:!0,durationSeconds:15,imageUrl:we.type==="youtube"?$e:i(we.name,"Custom Tab"),createdAt:(pn=we.createdAt)!=null&&pn.seconds?new Date(we.createdAt.seconds*1e3):new Date,isCustomPagePromo:!0,originalPage:we}}),...vs],[ne,vs]),[Sr,Ss]=ie.useState([]);ie.useEffect(()=>{const ge=Qt(et(he,"debates"),ui("createdAt","desc"));vn(ge).then(we=>{const Pe=we.docs.map($e=>{const ct=$e.data();return{id:$e.id,...ct,createdAt:ct.createdAt?ct.createdAt.toDate?ct.createdAt.toDate():new Date(ct.createdAt):new Date}});Ss(Pe)}).catch(we=>{console.warn("Silent ignored debates fetch error:",we)})},[]);const[li,Qr]=ie.useState(null),[kt,Pa]=ie.useState(!1),[wr,is]=ie.useState([]);ie.useEffect(()=>{const ge=Qt(et(he,"posts"),ui("createdAt","desc"),vi(25)),we=Wr(ge,Pe=>{const $e=Pe.docs.map(ct=>({id:ct.id,...ct.data()})).filter(ct=>!ct.flagged);is($e)},Pe=>{console.warn("Silent ignored sidebar posts subscription error:",Pe)});return()=>we()},[]),ie.useEffect(()=>{const ge=we=>{we.preventDefault(),window.deferredPrompt=we,Qr(we),Pa(!0)};return window.addEventListener("beforeinstallprompt",ge),()=>{window.removeEventListener("beforeinstallprompt",ge)}},[]),ie.useEffect(()=>{window.scrollTo({top:0,behavior:"auto"}),document.querySelectorAll(".overflow-y-auto").forEach(we=>{we.scrollTop=0})},[me,kn]),ie.useEffect(()=>{const ge=Qt(et(he,"pinned_announcements"));vn(ge).then(we=>{const Pe=we.docs.map($e=>{const ct=$e.data();return{id:$e.id,...ct,createdAt:ct.createdAt?ct.createdAt.toDate?ct.createdAt.toDate():new Date(ct.createdAt):new Date(0)}}).filter($e=>$e.active===!0).sort(($e,ct)=>ct.createdAt.getTime()-$e.createdAt.getTime());gi(Pe)}).catch(we=>{console.warn("Failed to load pinned announcements for home feed:",we)})},[]),ie.useEffect(()=>{const ge=Qt(et(he,"custom_pages"),ui("createdAt","desc"));vn(ge).then(we=>{const Pe=we.docs.map($e=>({id:$e.id,...$e.data()}));de(Pe);try{localStorage.setItem("campus_eye_custom_pages_cache",JSON.stringify(Pe))}catch($e){console.warn("Failed to cache custom pages:",$e)}}).catch(we=>{console.warn("Silent ignore custom menus loading issue:",we)})},[]);const[uo,hr]=ie.useState(!1),[Nr,cr]=ie.useState("followers"),[Re,mt]=ie.useState(null),[rt,At]=ie.useState(null);ie.useEffect(()=>{const ge=we=>{we.detail&&At(we.detail)};return window.addEventListener("open-imessage-friend",ge),()=>window.removeEventListener("open-imessage-friend",ge)},[]),ie.useEffect(()=>{if(typeof window<"u"&&"serviceWorker"in navigator){const ge=async we=>{if(we.data&&we.data.type==="NOTIFICATION_REPLY"){const{notifData:Pe,replyText:$e}=we.data,ct=Ne.currentUser;if(!ct||!$e)return;try{const ot=ct.displayName||"Campus Peer",_t=(ct.displayName||"member").toLowerCase().replace(/\s+/g,""),pn=(Pe==null?void 0:Pe.senderId)||(Pe==null?void 0:Pe.userId);pn&&(await ur(et(he,"notifications"),{userId:pn,senderId:ct.uid,senderName:ot,senderUsername:_t,senderPhotoURL:ct.photoURL||"",title:`💬 Lockscreen Direct Reply from ${ot}`,message:String($e).trim(),type:"direct_message",canReply:!0,used:!1,createdAt:new Date}),pe.success("Lockscreen direct reply sent!",{icon:"📲"}))}catch(ot){console.error("Lockscreen reply handler error:",ot)}}};return navigator.serviceWorker.addEventListener("message",ge),()=>navigator.serviceWorker.removeEventListener("message",ge)}},[]),ie.useEffect(()=>{const ge=Ne.onAuthStateChanged(we=>{if(we){const Pe=we.uid;try{const $e=Qt(et(he,"follows"),Ar("followedId","==",Pe)),ct=Qt(et(he,"follows"),Ar("followerId","==",Pe));Promise.all([vn($e),vn(ct)]).then(([ot,_t])=>{rs(ot.size),Mr(_t.size)}).catch(ot=>console.warn("Follows count error:",ot))}catch($e){console.warn("Follows collection hook error:",$e)}try{const $e=Qt(et(he,"invitations"),Ar("status","==","accepted"));vn($e).then(ct=>{let ot=0;ct.docs.forEach(_t=>{const pn=_t.data();(pn.senderId===Pe||pn.receiverId===Pe)&&ot++}),mi(ot)}).catch(ct=>console.warn("Invites fetch error:",ct))}catch($e){console.warn("Invites collection hook error:",$e)}}else Mr(0),rs(0),mi(0)});return()=>{ge()}},[]),ie.useEffect(()=>{const ge=Ne.onAuthStateChanged(we=>{if(!we)return;const Pe=Je(he,"users",we.uid),$e=()=>{Cn(Pe,{isOnline:!0,lastSeen:En()}).catch(()=>{})},ct=()=>{Cn(Pe,{isOnline:!1,lastSeen:En()}).catch(()=>{})};$e();const ot=setInterval(()=>{typeof document<"u"&&document.visibilityState==="visible"&&$e()},45e3),_t=()=>{typeof document<"u"&&document.visibilityState==="visible"?$e():ct()},pn=()=>{ct()};return typeof window<"u"&&(document.addEventListener("visibilitychange",_t),window.addEventListener("beforeunload",pn)),()=>{clearInterval(ot),typeof window<"u"&&(document.removeEventListener("visibilitychange",_t),window.removeEventListener("beforeunload",pn))}});return()=>ge()},[]),ie.useEffect(()=>{me!=="account"&&me!=="admin"&&wi(me),window.scrollTo({top:0,behavior:"auto"})},[me]);const[nn,Nn]=ie.useState(""),[Be,Bt]=ie.useState(""),[Mn,jn]=ie.useState(null),[Ln,xr]=ie.useState([]),[Le,fe]=ie.useState(null),[fn,xi]=ie.useState(null),[Ui,Bi]=ie.useState(!1),[Lr,zi]=ie.useState(!1),[an,fr]=ie.useState(!1),[Oa,ra]=ie.useState(!1),[ia,Cs]=ie.useState("");ie.useEffect(()=>{Ne.currentUser&&Cs(Ne.currentUser.displayName||"")},[(ga=Ne.currentUser)==null?void 0:ga.displayName]);const[Qo,fa]=ie.useState(0),[ci,js]=ie.useState(0),[Is,Gn]=ie.useState("recent"),[ss,Un]=ie.useState({name:"",email:((po=Ne.currentUser)==null?void 0:po.email)||"",subject:"General Feedback",message:""}),[Xr,To]=ie.useState(!0),[Zr,ho]=ie.useState(!1),[Qs,Po]=ie.useState(localStorage.getItem("pinnedSize")||"small"),[pa,ma]=ie.useState(1),Bs=ge=>{Po(ge),localStorage.setItem("pinnedSize",ge)};ie.useEffect(()=>{const ge=()=>{To(window.scrollY<12)};return window.addEventListener("scroll",ge,{passive:!0}),()=>window.removeEventListener("scroll",ge)},[]),ie.useEffect(()=>{if(o.length>0&&e){const ge=setInterval(()=>{fa(we=>(we+1)%Math.min(5,o.length))},5e3);return()=>clearInterval(ge)}},[o,e]),ie.useEffect(()=>{if(o.length>0&&e){const ge=setInterval(()=>{js(we=>(we+1)%Math.min(6,o.length))},4e3);return()=>clearInterval(ge)}},[o,e]),ie.useEffect(()=>{const ge=ot=>{ot.detail==="tickets"?St(!0):(Xt(ot.detail),Ce(null))},we=ot=>X(ot.detail),Pe=ot=>Ce(ot.detail),$e=ot=>{const _t=ot.detail;_t&&_t.id&&(ze(_t.id),Xt("posts"),pe.success(`Opening conversation by @${(_t.authorName||"peer").toLowerCase().replace(/\s+/g,"")}...`,{icon:"📣"}))},ct=ot=>{const _t=ot.detail;_t&&_t.uid&&(Ut(_t.uid),pe.success(`Opening profile of @${(_t.displayName||"peer").toLowerCase().replace(/\s+/g,"")}...`,{icon:"👤"}))};return window.addEventListener("setTab",ge),window.addEventListener("selectArticle",we),window.addEventListener("selectCustomPage",Pe),window.addEventListener("selectPost",$e),window.addEventListener("selectUser",ct),()=>{window.removeEventListener("setTab",ge),window.removeEventListener("selectArticle",we),window.removeEventListener("selectCustomPage",Pe),window.removeEventListener("selectPost",$e),window.removeEventListener("selectUser",ct)}},[]),ie.useEffect(()=>{var pn,Lt;let ge="Campus Newsroom - Live Social Hub & Archival Feeds",we="Discover real-time student conversations, official dispatches, ticketing services, live streams, and our complete historical publication archive.",Pe="https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",$e="website",ct=null;if(Y){ge=`${Y.title} | Campus Newsroom`,we=Y.summary||((pn=Y.content)==null?void 0:pn.slice(0,150))||we;const bn=[Y.featuredImageUrl,Y.featuredImageUrl1,Y.featuredImageUrl2,Y.featuredImage,Y.imageUrl,Y.image,Y.photo,Y.coverImage,Y.thumbnail,Y.mediaUrl,Y.bannerUrl];let rn="";const He=[Y.video,Y.videoUrl,Y.Links].filter(Boolean);for(const H of He){const oe=H.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|shorts\/)([^#\&\?]*).*/);if(oe&&oe[2].length===11){rn=`https://img.youtube.com/vi/${oe[2]}/hqdefault.jpg`;break}}let _="";if(Y.content){const H=Y.content.match(/]+src=["'](https?:\/\/[^"'\s]+)["']/i)||Y.content.match(/!\[.*?\]\((https?:\/\/[^\s\)]+)\)/i);H&&H[1]&&(_=H[1])}const U=bn.find(H=>H&&typeof H=="string"&&H.trim().length>5)||rn||_;Pe=U?U.startsWith("data:")?`${window.location.origin}/api/article-image/${Y.id}`:U:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",$e="article",ct={"@context":"https://schema.org","@type":"NewsArticle",headline:Y.title,description:Y.summary,image:[Pe],datePublished:Y.publishDate||new Date().toISOString(),author:{"@type":"Person",name:Y.authorName||"News Editor"}}}else be?(ge=`${be.title} | Campus Publication`,we=((Lt=be.content)==null?void 0:Lt.slice(0,150))||we,$e="article"):me==="posts"&&(ge="Student Lounge Feed | Live Conversations",we="Browse real-time announcements, debates, and posts shared directly by students and admins on our campus social forum.");document.title=ge;const ot=(bn,rn,He=!1)=>{let _=document.querySelector(He?`meta[name="${bn}"]`:`meta[property="${bn}"]`);_||(_=document.createElement("meta"),He?_.setAttribute("name",bn):_.setAttribute("property",bn),document.head.appendChild(_)),_.setAttribute("content",rn)};ot("description",we,!0),ot("og:title",ge),ot("og:description",we),ot("og:image",Pe),ot("og:type",$e),ot("twitter:card","summary_large_image",!0),ot("twitter:title",ge,!0),ot("twitter:description",we,!0),ot("twitter:image",Pe,!0);const _t=document.getElementById("json-ld-seo");if(_t&&_t.remove(),ct){const bn=document.createElement("script");bn.id="json-ld-seo",bn.type="application/ld+json",bn.innerHTML=JSON.stringify(ct),document.head.appendChild(bn)}},[Y,be,me]),ie.useEffect(()=>{},[]),ie.useEffect(()=>{const ge=Ne.onAuthStateChanged(async we=>{var Pe;if(we){try{const Lt=Je(he,"users",we.uid);if(!(await cs(Lt)).exists()){const rn=a.includes(we.email||"");await Rr(Lt,{uid:we.uid,email:we.email||"",displayName:we.displayName||"Campus Member",photoURL:we.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(we.displayName||"User")}&background=random`,role:rn?"admin":"user",isAdmin:rn,createdAt:En(),updatedAt:En()},{merge:!0}),rn&&await Rr(Je(he,"admins",we.uid),{email:we.email||"",isAdmin:!0,createdAt:En()},{merge:!0})}}catch(Lt){if(Lt.code==="permission-denied"||(Pe=Lt.message)!=null&&Pe.includes("insufficient permissions")){const bn={error:Lt.message,operationType:"write",path:`users/${we.uid}`,authInfo:{userId:we.uid,email:we.email,emailVerified:we.emailVerified}};console.error("Firestore Permission Error:",JSON.stringify(bn))}else{const bn=String((Lt==null?void 0:Lt.message)||Lt);bn.toLowerCase().includes("offline")||bn.toLowerCase().includes("could not reach")?console.warn("Error in safety user sync (offline):",Lt):console.error("Error in safety user sync:",Lt)}}try{const Lt=localStorage.getItem("pending_follow_uid"),bn=localStorage.getItem("pending_follow_name");if(Lt&&Lt!==we.uid){const rn=`${we.uid}_${Lt}`;await Rr(Je(he,"follows",rn),{followerId:we.uid,followedId:Lt,createdAt:new Date});const He=we.displayName?`@${we.displayName.toLowerCase().replace(/\s+/g,"")}`:"A peer";await Rr(Je(he,"notifications",`notif_follow_${we.uid}_${Lt}`),{userId:Lt,title:"🤝 Lounge Connect",message:`${He} followed you!`,type:"social",used:!0,createdAt:new Date}),pe.success(`You are now successfully following ${bn||"peer"}!`,{icon:"🎉"}),localStorage.removeItem("pending_follow_uid"),localStorage.removeItem("pending_follow_name"),Xt("home")}}catch(Lt){console.error("Failed to complete pending follow on auth transition:",Lt)}const $e=Je(he,"users",we.uid),ct=Je(he,"admins",we.uid);let ot=!1,_t=!1;const pn=()=>{const Lt=ot||_t||a.includes(we.email||"");zi(Lt),localStorage.setItem("is_admin_cached",Lt?"true":"false")};Wr($e,Lt=>{if(Lt.exists()){const bn=Lt.data();ot=(bn==null?void 0:bn.isAdmin)===!0||(bn==null?void 0:bn.role)==="admin"}pn()},Lt=>console.warn("App user doc admin snapshot fail:",Lt)),Wr(ct,Lt=>{if(Lt.exists()){const bn=Lt.data();_t=(bn==null?void 0:bn.isAdmin)===!0}pn()},Lt=>console.warn("App admin doc snapshot fail:",Lt))}else Un($e=>({...$e,email:(we==null?void 0:we.email)||$e.email})),zi(!1),Xt("home")});return()=>{ge()}},[]),ie.useEffect(()=>{if(!Y)return;const ge=Date.now(),we=Y.category||"General";return()=>{const Pe=Date.now(),$e=Math.round((Pe-ge)/1e3);if($e>=1)try{const ct=localStorage.getItem("campus_eye_personalization_v1"),ot=ct?JSON.parse(ct):{categories:{}};ot.categories||(ot.categories={}),ot.categories[we]||(ot.categories[we]=0),ot.categories[we]+=$e,ot.readArticles||(ot.readArticles=[]),ot.readArticles.includes(Y.id)||ot.readArticles.push(Y.id),localStorage.setItem("campus_eye_personalization_v1",JSON.stringify(ot))}catch(ct){console.warn("Personalization tracking quiet fail:",ct)}}},[Y]),ie.useEffect(()=>{if(!J)if(Y){const we=`/articles=${Y.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}/${Y.id}`,Pe=`${Y.title} | Campus Eye Media`;window.location.pathname!==we&&window.history.pushState({articleId:Y.id},"",we),document.title=Pe;const $e=(U,H,oe)=>{let De=document.querySelector(`meta[${U}="${H}"]`);De||(De=document.createElement("meta"),De.setAttribute(U,H),document.head.appendChild(De)),De.setAttribute("content",oe)},ct=(U,H)=>{let oe=document.querySelector(`link[rel="${U}"]`);oe||(oe=document.createElement("link"),oe.setAttribute("rel",U),document.head.appendChild(oe)),oe.setAttribute("href",H)},ot=Y.title,_t=Y.summary||Y.title,pn=[Y.featuredImageUrl,Y.featuredImageUrl1,Y.featuredImageUrl2,Y.featuredImage,Y.imageUrl,Y.image,Y.photo,Y.coverImage,Y.cover,Y.thumbnail,Y.mediaUrl,Y.bannerUrl];let Lt="";const bn=[Y.video,Y.videoUrl,Y.Links].filter(Boolean);for(const U of bn){const H=U.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|shorts\/)([^#\&\?]*).*/);if(H&&H[2].length===11){Lt=`https://img.youtube.com/vi/${H[2]}/hqdefault.jpg`;break}}let rn="";if(Y.content){const U=Y.content.match(/]+src=["'](https?:\/\/[^"'\s]+)["']/i)||Y.content.match(/!\[.*?\]\((https?:\/\/[^\s\)]+)\)/i);U&&U[1]&&(rn=U[1])}const He=pn.find(U=>U&&typeof U=="string"&&U.trim().length>5)||Lt||rn,_=He?He.startsWith("data:")?`${window.location.origin}/api/article-image/${Y.id}`:He:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg";$e("property","og:title",ot),$e("property","og:image",_),$e("property","og:image:url",_),$e("property","og:image:secure_url",_),$e("property","og:description",_t),$e("property","og:url",window.location.href),$e("name","description",_t),$e("name","twitter:title",ot),$e("name","twitter:description",_t),$e("name","twitter:image",_),$e("name","twitter:image:src",_),_&&ct("image_src",_);try{let U=document.getElementById("article-seo-schema");U||(U=document.createElement("script"),U.setAttribute("id","article-seo-schema"),U.setAttribute("type","application/ld+json"),document.head.appendChild(U));let H=new Date().toISOString();if(Y.publishDate)try{const oe=Y.publishDate;typeof oe.toDate=="function"?H=oe.toDate().toISOString():oe instanceof Date?H=oe.toISOString():typeof oe=="string"||typeof oe=="number"?H=new Date(oe).toISOString():oe.seconds!==void 0&&(H=new Date(oe.seconds*1e3).toISOString())}catch{}U.textContent=JSON.stringify({"@context":"https://schema.org","@type":"NewsArticle",headline:Y.title,image:[Y.featuredImageUrl].filter(Boolean),datePublished:H,dateModified:H,author:{"@type":"Person",name:Y.authorName||"Campus Eye Reporter"},publisher:{"@type":"Organization",name:"Campus Eye Media",url:window.location.origin,logo:{"@type":"ImageObject",url:`${window.location.origin}/logo.png`}},description:Y.summary||Y.title})}catch(U){console.warn("Schema injection failed:",U)}}else{(window.location.pathname.includes("/articles=")||window.location.pathname.startsWith("/articles/")||window.location.pathname.startsWith("/poll/")&&window.location.pathname.includes("/candidate/")||window.location.search.includes("articles=")||window.location.search.includes("article="))&&window.history.pushState({},"","/"),document.title="Campus Eye Media | Latest News, Sports, and Campus Updates";const ge=document.getElementById("article-seo-schema");ge&&ge.remove()}},[Y,J]),ie.useEffect(()=>{const ge=localStorage.getItem("campus_eye_theme")||"light";document.body.classList.remove("theme-dark","theme-sepia"),ge!=="light"&&document.body.classList.add(`theme-${ge}`);const we=$e=>{const ct=$e.detail.theme;document.body.classList.remove("theme-dark","theme-sepia"),ct!=="light"&&document.body.classList.add(`theme-${ct}`)};window.addEventListener("theme-changed",we);const Pe=$e=>{const ct=$e.detail;if(ct&&ct.id){const ot=o.find(_t=>_t.id===ct.id);ot?X(ot):cs(Je(he,"articles",ct.id)).then(_t=>{_t.exists()&&X({id:_t.id,..._t.data()})}).catch(_t=>console.warn("Could not load article offline:",_t))}};return window.addEventListener("open-article",Pe),()=>{window.removeEventListener("theme-changed",we),window.removeEventListener("open-article",Pe)}},[o]),ie.useEffect(()=>{o.length===0&&y(!0);const ge=Qt(et(he,"articles"),ui("publishDate","desc"),vi(V)),we=setTimeout(()=>{y(!1),A(!0)},150),Pe=Wr(ge,$e=>{const ct=$e.metadata.fromCache,ot=$e.docs.map(_t=>({id:_t.id,..._t.data(),isOfflineCached:ct||!navigator.onLine}));c(ot);try{const Lt=ot.map(({isOfflineCached:bn,...rn})=>rn).slice(0,25).map(bn=>{const rn={...bn};return rn.featuredImageUrl&&rn.featuredImageUrl.startsWith("data:")&&rn.featuredImageUrl.length>75e3&&(rn.featuredImageUrl=i(rn.title,rn.category)),rn.imageUrl&&rn.imageUrl.startsWith("data:")&&(rn.imageUrl=""),rn.content&&(rn.content=rn.content.length>1e3?rn.content.slice(0,1e3):rn.content),rn});try{localStorage.setItem("campus_eye_articles_cache",JSON.stringify(Lt))}catch{try{const rn=Lt.map(He=>({id:He.id,title:He.title,summary:He.summary,category:He.category,publishDate:He.publishDate,authorName:He.authorName}));localStorage.setItem("campus_eye_articles_cache",JSON.stringify(rn.slice(0,10)))}catch{localStorage.removeItem("campus_eye_articles_cache"),console.warn("Storage quota exceeded. Cleared articles cache key.")}}}catch(_t){console.warn("Failed to cache articles:",_t)}y(!1),A(!0),clearTimeout(we)},$e=>{const ct=$e instanceof Error?$e.message:String($e);if(ct.toLowerCase().includes("offline")||ct.toLowerCase().includes("permission")||ct.toLowerCase().includes("failed-precondition"))console.warn("Firestore collection list offline fallback initiated:",$e);else try{Ks($e,Ms.LIST,"articles")}catch(ot){console.error("Firestore Error in articles stream:",ot)}y(!1),A(!0),clearTimeout(we)});return()=>{Pe(),clearTimeout(we)}},[V]),ie.useEffect(()=>{let ge=o;const $e=Array.from(new Set(o.map(ct=>ct.category).filter(Boolean))).map(ct=>Bh(ct)).includes(Bh(me));if(nn.trim()){const ct=nn.toLowerCase();ge=o.filter(ot=>ot.title&&ot.title.toLowerCase().includes(ct)||ot.content&&ot.content.toLowerCase().includes(ct)||ot.summary&&ot.summary.toLowerCase().includes(ct)||ot.category&&ot.category.toLowerCase().includes(ct))}else $e&&(ge=o.filter(ct=>Bh(ct.category)===Bh(me)));f(ge)},[o,me,nn]),ie.useEffect(()=>{if(o.length>0){const we=[...o.length>3?o.slice(3):o].sort(()=>Math.random()-.5);$(we.slice(0,8))}},[o]),ie.useEffect(()=>{var rn;const ge=Qt(et(he,"adverts"),Ar("status","==","active"));vn(ge).then(He=>{const _=He.docs.map(wn=>({id:wn.id,...wn.data()})),U=Date.now(),oe=[..._.filter(wn=>!wn.expiresAt||wn.expiresAt.toMillis()>U)].sort((wn,tr)=>{var Vi,Ri;const Ur=(Vi=wn.createdAt)!=null&&Vi.toMillis?wn.createdAt.toMillis():0;return((Ri=tr.createdAt)!=null&&Ri.toMillis?tr.createdAt.toMillis():0)-Ur});xr(oe);const De=oe.filter(wn=>wn.type==="image"||!wn.type&&wn.imageUrl),Ye=oe.filter(wn=>wn.type==="video"),Te=wn=>{if(wn.length===0)return null;const tr=Math.floor(Math.pow(Math.random(),1.8)*wn.length);return wn[tr]},Ct=Te(De),Zn=Te(Ye);Ct&&fe(Ct),Zn&&xi(Zn)}).catch(He=>{Ks(He,Ms.LIST,"adverts")});const we=setTimeout(()=>y(!1),1e3),Pe=setInterval(()=>{document.visibilityState==="visible"&&xr(He=>{const _=He.filter(Ye=>Ye.type==="image"||!Ye.type&&Ye.imageUrl),U=He.filter(Ye=>Ye.type==="video"),H=Ye=>{if(Ye.length===0)return null;const Te=Math.floor(Math.pow(Math.random(),1.8)*Ye.length);return Ye[Te]},oe=H(_),De=H(U);return oe&&fe(oe),De&&xi(De),He})},5e3);Wr(Qt(et(he,"notifications"),Ar("userId","==",((rn=Ne.currentUser)==null?void 0:rn.uid)||"guest")),He=>{He.docChanges().forEach(_=>{if(_.type==="added"){const U=_.doc.data();if(!U.used&&(U.type==="admin_mega_reply"||U.type==="mega_ai_reply"||U.playSound)){try{const H=window.AudioContext||window.webkitAudioContext;if(H){const oe=new H,De=oe.createOscillator(),Ye=oe.createGain();De.type="sine",De.frequency.setValueAtTime(587.33,oe.currentTime),De.frequency.exponentialRampToValueAtTime(880,oe.currentTime+.12),Ye.gain.setValueAtTime(.25,oe.currentTime),Ye.gain.exponentialRampToValueAtTime(.001,oe.currentTime+.3),De.connect(Ye),Ye.connect(oe.destination),De.start(),De.stop(oe.currentTime+.3)}}catch{}pe.custom(H=>s.jsxs("div",{onClick:()=>{pe.dismiss(H.id),Xt("account")},className:`${H.visible?"animate-enter":"animate-leave"} cursor-pointer max-w-md w-full bg-white shadow-2xl rounded-2xl border border-red-200 p-4 flex items-center gap-3 ring-1 ring-black/5`,children:[s.jsx("div",{className:"p-2.5 bg-red-100 text-red-650 rounded-xl shrink-0",children:s.jsx(Zi,{size:18})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs font-black uppercase text-gray-950 tracking-tight",children:U.title||"🤖 Admin / AI Replied!"}),s.jsx("p",{className:"text-[10px] text-gray-600 line-clamp-2 mt-0.5",children:U.message||U.fullAnswer})]})]}),{duration:7500,position:"top-right"})}}})},He=>{console.warn("Silent notification listener info:",He)}),vK().catch(()=>null);const $e=new Date(Date.now()-300*1e3),ct=new Set,ot=Qt(et(he,"articles"),Ar("publishDate",">",_r.fromDate($e)),ui("publishDate","desc")),_t=Wr(ot,He=>{He.docs.forEach(_=>{const U=_.id;if(ct.has(U))return;ct.add(U);const H=_.data();_1(H.title||"Campus Eye Dispatch",{body:H.summary||H.category||"A new article was uploaded to Campus Eye! Tap to read.",tag:`article-${U}`,renotify:!0}),pe.custom(oe=>s.jsxs("div",{className:`${oe.visible?"animate-enter":"animate-leave"} max-w-md w-full bg-white shadow-2xl pointer-events-auto flex ring-1 ring-black ring-opacity-5 border-l-4 border-red-600`,children:[s.jsx("div",{className:"flex-1 w-0 p-4",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"flex-shrink-0 pt-0.5",children:s.jsx(Fh,{className:"h-10 w-10 text-red-600"})}),s.jsxs("div",{className:"ml-3 flex-1",children:[s.jsx("p",{className:"text-sm font-bold text-gray-900 uppercase tracking-tight",children:"New Article Published (< 5 mins)"}),s.jsx("p",{className:"mt-1 text-sm text-gray-500 line-clamp-2 font-serif italic",children:H.title})]})]})}),s.jsx("div",{className:"flex border-l border-gray-200",children:s.jsx("button",{onClick:()=>{X({id:_.id,...H}),pe.dismiss(oe.id)},className:"w-full border border-transparent rounded-none rounded-r-lg p-4 flex items-center justify-center text-xs font-black text-red-600 hover:text-red-700 uppercase tracking-widest",children:"View"})})]}),{duration:7e3,position:"top-right"})})},He=>{Ks(He,Ms.LIST,"articles/new")}),pn=new Date(Date.now()-600*1e3),Lt=new Set,bn=Qt(et(he,"adverts"),Ar("createdAt",">",_r.fromDate(pn)),ui("createdAt","desc"));return vn(bn).then(He=>{He.docs.forEach(_=>{const U=_.id;if(Lt.has(U))return;Lt.add(U);const H=_.data();pe.custom(oe=>s.jsxs("div",{className:`${oe.visible?"animate-enter":"animate-leave"} max-w-md w-full bg-white shadow-2xl pointer-events-auto flex ring-1 ring-black ring-opacity-5 border-l-4 border-blue-600`,children:[s.jsx("div",{className:"flex-1 w-0 p-4",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"flex-shrink-0 pt-0.5",children:s.jsx(Aa,{className:"h-10 w-10 text-blue-600"})}),s.jsxs("div",{className:"ml-3 flex-1",children:[s.jsx("p",{className:"text-sm font-bold text-gray-900 uppercase tracking-tight",children:"New Sponsored Update"}),s.jsx("p",{className:"mt-1 text-sm text-gray-500 line-clamp-2",children:H.title||"Check out this new update!"})]})]})}),s.jsx("div",{className:"flex border-l border-gray-200",children:s.jsx("button",{onClick:()=>{H.link&&window.open(H.link,"_blank"),pe.dismiss(oe.id)},className:"w-full border border-transparent rounded-none rounded-r-lg p-4 flex items-center justify-center text-xs font-black text-blue-600 hover:text-blue-700 uppercase tracking-widest",children:"Open"})})]}),{duration:6e3,position:"top-right"})})}).catch(He=>{Ks(He,Ms.LIST,"adverts/new")}),()=>{_t(),clearInterval(Pe),clearTimeout(we)}},[]),ie.useEffect(()=>{const ge=window.location.pathname;let we=null,Pe=null;if(ge.startsWith("/p/share/")){const ct=ge.split("/p/share/")[1];we=ct?ct.split("/")[0]:null}else if(ge.includes("/articles=")||ge.startsWith("/articles/")){const ot=ge.replace(/^\/articles=?/,"").split("/").filter(Boolean);ot.length>=2?(Pe=ot[0],we=ot[1]):ot[0]&&(Pe=ot[0])}else if(ge.startsWith("/poll/")&&ge.includes("/candidate/")){const ot=ge.split("/candidate/")[1];ot&&(Pe=ot)}else we=new URLSearchParams(window.location.search).get("id");const $e=new URLSearchParams(window.location.search);if(Pe||(Pe=$e.get("articles")||$e.get("article")),we){let ct=!1;try{const ot=localStorage.getItem("campus_eye_articles_cache");if(ot){const pn=JSON.parse(ot).find(Lt=>Lt.id===we);pn&&(X(pn),ye(!1),ct=!0)}}catch(ot){console.warn("Error checking fast article cache:",ot)}cs(Je(he,"articles",we)).then(ot=>{if(ot.exists()){const _t={id:ot.id,...ot.data()};X(_t)}ye(!1)}).catch(ot=>{console.warn("Direct priority fetch by ID failed:",ot),ye(!1)})}else if(Pe){const ct=o.find(ot=>{const _t=ot.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),pn=Pe.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return _t===pn||ot.title.toLowerCase()===Pe.toLowerCase()});if(ct)X(ct),ye(!1);else{const ot=Qt(et(he,"articles"),ui("publishDate","desc"),vi(25));vn(ot).then(_t=>{const Lt=_t.docs.map(bn=>({id:bn.id,...bn.data()})).find(bn=>{const rn=bn.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),He=Pe.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return rn===He||bn.title.toLowerCase()===Pe.toLowerCase()||rn.replace(/-/g,".")===He});Lt&&X(Lt),ye(!1)}).catch(_t=>{console.warn("Direct priority fetch by slug failed:",_t),ye(!1)})}}else ye(!1)},[]),ie.useEffect(()=>{const ge=()=>{const we=new URLSearchParams(window.location.search),Pe=we.get("articles")||we.get("article"),$e=we.get("id");if(!Pe&&!$e)X(null);else{const ct=o.find(ot=>ot.id===$e||Pe&&ot.title.toLowerCase().replace(/[^a-z0-9]/g,"-")===Pe.toLowerCase());ct?X(ct):$e&&cs(Je(he,"articles",$e)).then(ot=>{ot.exists()&&X({id:ot.id,...ot.data()})}).catch(console.error)}};return window.addEventListener("popstate",ge),()=>window.removeEventListener("popstate",ge)},[o]);const Zs=ge=>{Nn(ge),ge.trim()&&(Xt("home"),window.scrollTo({top:0,behavior:"auto"}))},Ni=ge=>{Xt("admin"),fr(!0),xt(ge||"dashboard"),window.scrollTo({top:0,behavior:"auto"})},zs=async ge=>{var Pe;const we=(Pe=ge.target.files)==null?void 0:Pe[0];if(!(!we||!Ne.currentUser))try{Bi(!0);const $e=await Q2(we,256,256,.8);Ne.currentUser&&(await Rr(Je(he,"users",Ne.currentUser.uid),{photoURL:$e,updatedAt:En()},{merge:!0}),pe.success("Profile picture updated!"))}catch($e){console.error("Error updating profile:",$e),pe.error("Failed to update profile pic")}finally{Bi(!1)}},yi=async()=>{if(!(!ia.trim()||!Ne.currentUser))try{Bi(!0),await t$(Ne.currentUser,{displayName:ia.trim()}),await Rr(Je(he,"users",Ne.currentUser.uid),{displayName:ia.trim(),updatedAt:En()},{merge:!0}),ra(!1),pe.success("Username successfully authenticated and saved!")}catch(ge){console.error("Error updating name:",ge),pe.error("Failed to update display name")}finally{Bi(!1)}},Xa=async ge=>{var we,Pe;if(ge.preventDefault(),!!ss.message.trim())try{Bi(!0),await ur(et(he,"feedback"),{...ss,userId:((we=Ne.currentUser)==null?void 0:we.uid)||null,createdAt:En()}),pe.success("Feedback transmitted. Thank you!"),Un({name:"",email:((Pe=Ne.currentUser)==null?void 0:Pe.email)||"",subject:"General Feedback",message:""}),Xt("home")}catch($e){console.error("Error submitting feedback:",$e),pe.error("Failed to send feedback.")}finally{Bi(!1)}},Nl=()=>{var ct,ot,_t,pn,Lt,bn,rn;if(o.length===0&&m)return s.jsx("div",{className:"relative w-full min-h-[75vh]",children:s.jsx(S9e,{})});const ge=Array.from(new Set(o.map(He=>He.category).filter(Boolean))),Pe=ge.map(He=>Bh(He)).includes(Bh(me)),$e=nn.trim()?h:Pe?o.filter(He=>Bh(He.category)===Bh(me)):h;if(me==="home"||me==="for-you"||Pe){let He=[...$e];if(dt!==null&&(He=He.filter(Te=>{const Ct=Te.publishDate;if(!Ct)return!1;const Zn=Ct.toDate?Ct.toDate():Ct.seconds?new Date(Ct.seconds*1e3):new Date(Ct),wn=new Date;wn.setHours(0,0,0,0);const tr=new Date(Zn);tr.setHours(0,0,0,0);const Ur=wn.getTime()-tr.getTime();return Math.floor(Ur/(1e3*60*60*24))+1===dt})),me==="for-you")try{const Te=localStorage.getItem("campus_eye_personalization_v1");let Ct={};if(Te){const tr=JSON.parse(Te);tr&&tr.categories&&(Ct={...tr.categories})}const Zn=(ct=Ne.currentUser)==null?void 0:ct.uid,wn=new Set;if(Zn)for(let tr=0;tr=3){const Vi=Oi.slice(1,Oi.length-1).join("_");wn.add(Vi);const Ri=o.find(ws=>ws.id===Vi);if(Ri&&Ri.category){const ws=Ri.category;Ct[ws]=(Ct[ws]||0)+25}}}}if(qe==="saved")He=He.filter(tr=>wn.has(tr.id));else{const tr=He.map(Ur=>{let Oi=0;wn.has(Ur.id)&&(Oi+=1e6);const Ri=Ur.category||"General";Ct[Ri]&&(Oi+=Ct[Ri]*2.5);const ws=Ur.publishDate&&typeof Ur.publishDate.toMillis=="function"?Ur.publishDate.toMillis():0;return Oi+=ws/1e11,{article:Ur,score:Oi}});tr.sort((Ur,Oi)=>Oi.score-Ur.score),He=tr.map(Ur=>Ur.article)}}catch(Te){console.warn("Failed to sort personalized articles:",Te)}else He.sort((Te,Ct)=>{const Zn=Te.publishDate&&typeof Te.publishDate.toMillis=="function"?Te.publishDate.toMillis():0;return(Ct.publishDate&&typeof Ct.publishDate.toMillis=="function"?Ct.publishDate.toMillis():0)-Zn});const _=Math.max(1,Math.ceil(He.length/T)),U=Math.min(S,_),H=He.slice((U-1)*T,U*T),oe=H.slice(0,Math.min(H.length,8)),De=H.length>8?H.slice(8,Math.min(H.length,10)):[],Ye=H.length>10?H.slice(10):[];return s.jsxs("div",{className:"w-full max-w-[1680px] xl:max-w-[1780px] 2xl:max-w-[1880px] mx-auto pt-1 sm:pt-4 pb-20 px-1 sm:px-4 lg:px-6 xl:px-8",children:[s.jsxs("div",{className:"grid grid-cols-12 gap-4 lg:gap-5 xl:gap-6 2xl:gap-8",children:[s.jsxs("aside",{className:"hidden lg:block lg:col-span-3 xl:col-span-3 2xl:col-span-3 space-y-4 pr-1 text-left select-none sticky top-24 self-start max-h-[calc(100vh-8rem)] overflow-y-auto no-scrollbar scroll-smooth",children:[s.jsxs("div",{className:"bg-white border border-gray-150/90 rounded-2xl p-4 shadow-xs space-y-3.5 text-left relative resize-y overflow-auto min-h-[320px] max-h-[75vh] [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:bg-gray-200 [&::-webkit-scrollbar-thumb]:rounded-full",children:[s.jsxs("div",{className:"flex items-center justify-between pb-2.5 border-b border-gray-100 sticky top-0 bg-white/95 backdrop-blur-sm z-10",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(u8,{size:16,className:"text-red-650 shrink-0"}),s.jsx("span",{className:"text-[10px] font-mono font-black uppercase text-red-650 tracking-[0.15em]",children:"Market"})]}),s.jsx("button",{onClick:()=>{Xt("posts"),window.scrollTo({top:0,behavior:"auto"})},className:"text-[8px] font-black uppercase tracking-wider px-2 py-1 bg-red-50 text-red-650 hover:bg-red-650 hover:text-white rounded-lg transition-all cursor-pointer",children:"Open Market"})]}),wr.length===0?s.jsxs("div",{className:"py-6 text-center text-gray-400 space-y-1",children:[s.jsx(u8,{size:20,className:"mx-auto text-gray-300 mb-1"}),s.jsx("p",{className:"text-[9px] font-bold uppercase tracking-wider",children:"No Market Listings"}),s.jsx("p",{className:"text-[8px] text-gray-400",children:"Be the first to list an item in the Market!"})]}):s.jsx("div",{className:"space-y-3 divide-y divide-gray-100",children:wr.map((Te,Ct)=>{var Zn;return s.jsxs("div",{onClick:()=>{Xt("posts"),window.scrollTo({top:0,behavior:"auto"})},className:"pt-3 first:pt-0 group cursor-pointer hover:bg-gray-50/70 p-2 rounded-xl transition-all",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[s.jsxs("div",{onClick:wn=>{wn.stopPropagation(),Te.authorId&&Ut(Te.authorId)},className:"flex items-center gap-2 min-w-0 hover:underline",children:[Te.authorPhotoURL?s.jsx(Li,{src:Te.authorPhotoURL,alt:"",className:"w-6 h-6 rounded-full object-cover border border-gray-200 shrink-0 overflow-hidden"}):s.jsx("div",{className:"w-6 h-6 rounded-full bg-red-650 text-white flex items-center justify-center text-[9px] font-black uppercase shrink-0",children:((Zn=Te.authorName)==null?void 0:Zn.charAt(0))||"M"}),s.jsxs("span",{className:"text-[9.5px] font-extrabold text-gray-950 truncate max-w-[110px] flex items-center gap-1",children:[Te.authorName,s.jsx(Fo,{size:12,className:"shrink-0"})]})]}),s.jsx("span",{className:"text-[7.5px] font-mono text-gray-400 shrink-0",children:Te.createdAt instanceof _r?X0(Te.createdAt):"Recent"})]}),s.jsx("p",{className:"text-[9.5px] font-medium text-gray-750 leading-relaxed line-clamp-3 select-text font-sans",children:Te.content}),Te.imageUrl&&s.jsx("div",{className:"mt-2 h-28 w-full rounded-lg overflow-hidden border border-gray-150 bg-gray-950 relative",children:s.jsx(Li,{src:Te.imageUrl,alt:"",className:"w-full h-full object-cover group-hover:scale-102 transition-transform duration-300"})}),s.jsxs("div",{className:"mt-2 flex items-center gap-3 text-[8px] font-mono font-bold text-gray-400",children:[s.jsxs("span",{className:"flex items-center gap-1 hover:text-red-500",children:[s.jsx(mc,{size:10,className:Te.likeCount?"fill-red-500 text-red-500":""}),Te.likeCount||0]}),s.jsxs("span",{className:"flex items-center gap-1 hover:text-blue-500",children:[s.jsx(bi,{size:10}),Te.commentCount||0]})]})]},`sidebar-${Te.id}-${Ct}`)})})]}),fn&&s.jsxs("div",{className:"bg-white border border-gray-150 rounded-2xl p-3 shadow-xs space-y-2 text-left",children:[s.jsx("div",{className:"flex items-center justify-between border-b border-gray-100 pb-1.5 mb-1.5",children:s.jsxs("span",{className:"text-[9px] font-black tracking-[0.12em] text-red-655 uppercase flex items-center gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-650 shrink-0"}),s.jsx("span",{children:"Promotional Partner"})]})}),s.jsx(Yw,{advert:fn})]})]}),s.jsxs("main",{className:"col-span-12 lg:col-span-6 space-y-5 px-0 min-h-screen border-r border-l border-gray-100/60 bg-white",children:[me!=="home"&&s.jsx("div",{className:"border-b border-gray-100 pb-3 px-4 flex items-center justify-between sticky top-11 bg-white/95 backdrop-blur-md z-30",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-650 shrink-0"}),s.jsx("h3",{className:"text-[10px] font-extrabold tracking-wider text-red-650 uppercase font-mono px-2 py-1 rounded-md bg-red-50 border border-red-150/55 shadow-xs flex items-center gap-1.5 shrink-0 select-none",children:nn.trim()?s.jsxs("div",{className:"flex items-center gap-1 leading-none uppercase text-[9px]",children:[s.jsxs("span",{children:["Search:"," ",s.jsxs("span",{className:"text-red-750 italic",children:['"',nn,'"']})]}),s.jsx("button",{onClick:()=>{Nn(""),window.dispatchEvent(new CustomEvent("clearSearchQuery"))},className:"p-0.5 text-red-400 hover:text-red-650 hover:bg-white rounded-full transition-colors cursor-pointer ml-1 inline-flex items-center justify-center shrink-0",title:"Clear Search",children:s.jsx(er,{size:10,strokeWidth:2.5})})]}):me==="for-you"?s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 w-full pr-2",children:[s.jsx("span",{children:"Curated For You"}),s.jsxs("div",{className:"flex items-center gap-1 bg-gray-100/80 p-0.5 rounded-xl text-[9px] font-extrabold uppercase tracking-wider",children:[s.jsx("button",{type:"button",onClick:()=>st("all"),className:Fe("px-2.5 py-1 rounded-lg transition-all cursor-pointer",qe==="all"?"bg-white text-gray-950 shadow-xs":"text-gray-500 hover:text-gray-800"),children:"All Feed"}),s.jsxs("button",{type:"button",onClick:()=>st("saved"),className:Fe("px-2.5 py-1 rounded-lg transition-all cursor-pointer flex items-center gap-1",qe==="saved"?"bg-red-650 text-white shadow-xs":"text-gray-500 hover:text-gray-800"),children:[s.jsx(One,{size:10,className:"fill-current"}),s.jsx("span",{children:"Saved Stories"})]})]})]}):Pe?`${ge.find(Te=>{let Ct=Te.toLowerCase().replace(/\s+/g,"-");return(Ct==="campus-news"||Ct==="news")&&(Ct="news"),(Ct==="sports"||Ct==="sport")&&(Ct="sport"),Ct===me.toLowerCase()})||me} Feed`:"Campus News"})]})}),s.jsx(or,{children:Xr&&o.length>0&&me==="home"&&s.jsx(Zt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3},className:"overflow-hidden",children:s.jsx(wye,{articles:o,onClick:X})})}),Zr&&$r.length>0&&me==="home"&&s.jsxs("div",{className:"px-4 py-1 space-y-2 relative group",children:[$r.slice(0,pa).map(Te=>{const Ct=Qs==="small",Zn=Qs==="large",wn=Ct?"p-1.5 py-1 px-3 rounded-lg gap-2 text-left animate-fade-in border-red-150":Zn?"p-4.5 px-6 rounded-2xl gap-4.5 text-left animate-fade-in":"p-3 px-4 rounded-xl gap-3.5 text-left animate-fade-in",tr=Ct?"w-7 h-7 rounded-md":Zn?"w-14 h-14 rounded-xl shadow-xs":"w-11 h-11 rounded-lg",Ur=Ct?10:Zn?15:13,Oi=Ct?"text-[9px]/[10px] font-black tracking-custom":Zn?"text-[12.5px]/[15px] font-black tracking-custom":"text-[11px]/[13px] font-black tracking-custom",Vi=Ct?"text-[8px]/[9.5px] text-gray-500 mt-0.5 line-clamp-1":Zn?"text-[10.5px]/[14px] text-gray-500 mt-1 line-clamp-3 leading-relaxed":"text-[9.5px]/[12px] text-gray-500 mt-0.5 line-clamp-2 leading-relaxed",Ri=Ct?"text-[6.5px]/none px-2 py-0.5 mt-0.5 font-black rounded gap-0.5":Zn?"text-[9.5px]/none px-4 py-2 mt-2 font-black rounded-xl gap-1.5":"text-[8.5px]/none px-3 py-1.5 mt-1.5 font-black rounded-lg gap-1",ws=Ct?5:Zn?9:7,Da=Ct?"pr-24":Zn?"pr-36":"pr-32";return s.jsxs("div",{onClick:()=>{Te.isCustomPagePromo?Ce(Te.originalPage):Te.isLiveStream&&Te.liveEmbedUrl&&(Ve(Te.liveEmbedUrl),cn(Te.title))},className:`bg-red-50/70 border border-red-150/80 flex flex-row items-center relative overflow-hidden hover:border-red-650 transition-all duration-300 ${Te.isLiveStream&&Te.liveEmbedUrl||Te.isCustomPagePromo?"cursor-pointer hover:bg-red-100/30":""} ${wn}`,children:[s.jsxs("div",{className:"absolute top-2 right-2 flex items-center gap-1.5 z-10 select-none",children:[s.jsxs("div",{className:"flex items-center bg-white border border-gray-150 rounded-md p-0.5 shadow-3xs text-[7px] font-black uppercase text-gray-500 overflow-hidden shrink-0",children:[s.jsx("button",{onClick:Ei=>{Ei.stopPropagation(),Bs("small")},className:`px-1 py-0.2 rounded-xs transition-all cursor-pointer ${Ct?"bg-red-600 text-white font-black animate-scale-in":"hover:bg-gray-100 text-gray-400"}`,title:"Set compact size",children:"-"}),s.jsx("button",{onClick:Ei=>{Ei.stopPropagation(),Bs("medium")},className:`px-1 py-0.2 rounded-xs transition-all cursor-pointer ${Qs==="medium"?"bg-red-600 text-white font-black animate-scale-in":"hover:bg-gray-100 text-gray-400"}`,title:"Set regular size",children:"A"}),s.jsx("button",{onClick:Ei=>{Ei.stopPropagation(),Bs("large")},className:`px-1 py-0.2 rounded-xs transition-all cursor-pointer ${Zn?"bg-red-600 text-white font-black animate-scale-in":"hover:bg-gray-100 text-gray-400"}`,title:"Set large size",children:"+"})]}),s.jsxs("div",{className:"px-1.5 py-0.5 bg-red-600 text-white rounded-full text-[6.5px] font-black uppercase tracking-wider flex items-center gap-0.5 shadow-2xs shrink-0",children:[s.jsx(C0,{size:6})," Pinned"]}),Lr&&s.jsx("button",{onClick:async Ei=>{if(Ei.stopPropagation(),!Lr){pe.error("Access Denied: Only admins can delete announcements.");return}if(window.confirm("Are you sure you want to delete this pinned announcement?"))try{pe.loading("Deleting pinned notice...",{id:`delete-pinned-${Te.id}`}),await si(Je(he,"pinned_announcements",Te.id)),pe.success("Notice deleted!",{id:`delete-pinned-${Te.id}`})}catch(Ts){pe.error(Ts.message||String(Ts),{id:`delete-pinned-${Te.id}`})}},className:"p-1 bg-white hover:bg-red-50 text-red-650 border border-gray-150 rounded-md transition-all cursor-pointer shadow-3xs shrink-0 flex items-center justify-center h-4.5 w-4.5",title:"Delete announcement permanently (Master Admin)",children:s.jsx(As,{size:9})})]}),Te.isLiveStream&&Te.liveEmbedUrl?s.jsxs("div",{onClick:Ei=>{Ei.stopPropagation(),Ve(Te.liveEmbedUrl),cn(Te.title)},className:`relative border border-red-200/40 shrink-0 overflow-hidden bg-gray-905 select-none cursor-pointer hover:border-red-650 transition-colors ${tr}`,title:"Click to watch live stream",children:[s.jsx("img",{src:(()=>{var ni,Ps,wc;const Ei=Te.liveEmbedUrl;if(!Ei)return Te.imageUrl||i(Te.title,"Announcement");let Ts="";return Ei.includes("embed/")?Ts=((ni=Ei.split("embed/")[1])==null?void 0:ni.split(/[?#]/)[0])||"":Ei.includes("v=")?Ts=((Ps=Ei.split("v=")[1])==null?void 0:Ps.split(/[?&#]/)[0])||"":Ei.includes("youtu.be/")&&(Ts=((wc=Ei.split("youtu.be/")[1])==null?void 0:wc.split(/[?#]/)[0])||""),Ts?`https://img.youtube.com/vi/${Ts}/hqdefault.jpg`:Te.imageUrl||i(Te.title,"Announcement")})(),className:"absolute inset-0 w-full h-full object-cover border-0",alt:"Live stream thumbnail",referrerPolicy:"no-referrer"}),s.jsx("div",{className:"absolute inset-0 bg-black/40 hover:bg-black/20 transition-all flex items-center justify-center",children:s.jsx("span",{className:"bg-red-650 text-white font-black text-[8px] uppercase tracking-[0.16em] px-2 py-1 rounded shadow-md border border-red-500",children:"🔴 LIVE SOURCE"})})]}):Te.imageUrl?s.jsx("img",{src:Te.imageUrl,alt:"",className:`object-cover border border-red-100/40 shrink-0 ${tr}`,referrerPolicy:"no-referrer"}):s.jsx("div",{className:`bg-red-150 text-red-600 flex items-center justify-center font-black shrink-0 ${tr}`,children:s.jsx(Ou,{size:Ur})}),s.jsxs("div",{className:`flex-1 text-left min-w-0 ${Da}`,children:[s.jsx("h4",{className:`text-gray-950 uppercase tracking-tight leading-snug truncate ${Oi}`,children:Te.title}),Te.description&&s.jsx("p",{className:`${Vi}`,children:Te.description}),Te.isLiveStream&&Te.liveEmbedUrl?s.jsx("button",{onClick:Ei=>{Ei.stopPropagation(),Te.isCustomPagePromo?Ce(Te.originalPage):(Ve(Te.liveEmbedUrl),cn(Te.title))},className:`font-black bg-red-650 text-white hover:bg-red-700 inline-flex items-center uppercase tracking-wider cursor-pointer border border-red-700 shadow-sm active:scale-95 transition-all ${Ri}`,children:s.jsx("span",{children:"🔴 Watch Stream Live"})}):Te.link?s.jsxs("button",{onClick:()=>{Te.link&&window.open(Te.link,"_blank","noopener,noreferrer")},className:`font-black bg-neutral-950 text-white hover:bg-neutral-800 inline-flex items-center uppercase tracking-wider cursor-pointer border border-neutral-800 shadow-sm active:scale-95 transition-all ${Ri}`,children:[s.jsx("span",{children:Te.ctaText||Te.buttonText||"Discover More"}),s.jsx($a,{size:ws,strokeWidth:3})]}):null]})]},Te.id)}),$r.length>pa&&s.jsxs("button",{type:"button",onClick:()=>ma($r.length),className:"w-full py-1.5 bg-red-50/50 hover:bg-red-100 border border-dashed border-red-200 hover:border-red-400 rounded-lg flex items-center justify-center gap-1.5 text-[8.5px]/none font-black uppercase text-red-655 transition-all duration-150 cursor-pointer shadow-3xs",children:[s.jsx(Bd,{size:11,className:"stroke-[2.5]"}),s.jsxs("span",{children:["Show Other Pinned Announcements (",$r.length-pa," more)"]})]}),pa>1&&s.jsxs("button",{type:"button",onClick:()=>ma(1),className:"w-full py-1.5 text-gray-400 hover:text-red-650 text-[8px]/none font-bold uppercase tracking-wider flex items-center justify-center gap-1 transition-colors duration-150 cursor-pointer",children:[s.jsx(df,{size:10}),s.jsx("span",{children:"Collapse Pinned List"})]})]}),me==="for-you"&&bt?s.jsxs("div",{className:"py-20 flex flex-col items-center justify-center text-center space-y-4",children:[s.jsx(k9e,{}),s.jsx("p",{className:"text-[10px] font-sans font-black uppercase tracking-custom text-gray-500 mt-2",children:"Crafting your custom campus feed..."})]}):me==="for-you"&&$n?s.jsxs("div",{className:"max-w-md mx-auto py-8 px-4 text-center",children:[s.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 mb-6 bg-red-50 py-1.5 px-3 rounded-full inline-block",children:"📢 Interest Personalization"}),s.jsxs("div",{className:"bg-white border border-gray-150 rounded-3xl p-6.5 shadow-xs space-y-6",children:[s.jsxs("div",{className:"space-y-1.5 text-center",children:[s.jsx("div",{className:"w-9 h-9 bg-black text-white rounded-2xl flex items-center justify-center font-black text-sm mx-auto shadow-xs tracking-tighter",children:"★"}),s.jsx("h3",{className:"font-serif font-black text-lg tracking-tight text-neutral-900 uppercase",children:"Tune Your Dispatch Stream"}),s.jsx("p",{className:"text-[10px] text-neutral-500 font-semibold tracking-normal leading-relaxed max-w-xs mx-auto",children:"Select up to 3 core campus categories. We'll curate your news feed and learn your preferences live in this space."})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:[{id:"news",label:"📰 News",category:"News"},{id:"sports",label:"⚽ Sports",category:"Sports"},{id:"music",label:"🎵 Music",category:"Music"},{id:"entertainment",label:"🎭 Entertainment",category:"Entertainment"},{id:"innovation",label:"💡 Innovation",category:"Innovation"},{id:"culture",label:"🏛️ Culture",category:"Culture"},{id:"business",label:"💼 Business",category:"Business"}].map(Te=>{const Ct=je.includes(Te.category);return s.jsxs("button",{onClick:()=>{if(Ct)ln(Zn=>Zn.filter(wn=>wn!==Te.category));else{if(je.length>=3){pe.error("Please pick up to just 3 interests!",{id:"interest-limit"});return}ln(Zn=>[...Zn,Te.category])}},className:`p-3 rounded-2xl border text-left font-sans text-xs font-semibold transition-all duration-200 cursor-pointer flex flex-col justify-between h-[4.5rem] select-none ${Ct?"border-black bg-black text-white shadow-xs scale-[1.02]":"border-gray-200 bg-white text-gray-700 hover:border-gray-300 hover:bg-gray-50/50"}`,children:[s.jsx("span",{className:"text-base leading-none",children:Te.label.split(" ")[0]}),s.jsx("span",{className:"font-sans uppercase text-[8.5px] font-black tracking-wider leading-none",children:Te.label.split(" ").slice(1).join(" ")})]},Te.id)})}),s.jsxs("div",{className:"pt-2 text-center",children:[s.jsxs("span",{className:"text-[8.5px] font-sans font-black text-gray-400 uppercase tracking-widest block mb-3.5",children:[je.length," of 3 Selected"]}),s.jsx("button",{onClick:()=>{if(je.length===0){pe.error("Please select at least 1 interest to customize your feed!");return}try{const Te=localStorage.getItem("campus_eye_personalization_v1"),Ct=Te?JSON.parse(Te):{categories:{}};Ct.interests=[...je],Ct.categories||(Ct.categories={}),je.forEach(Zn=>{Ct.categories[Zn]=(Ct.categories[Zn]||0)+150}),localStorage.setItem("campus_eye_personalization_v1",JSON.stringify(Ct)),localStorage.removeItem("just_signed_up"),yn(!0),setTimeout(()=>{yn(!1),Et(!1),pe.success("Newsroom personalized live! Welcome.")},200)}catch(Te){console.warn(Te),Et(!1)}},disabled:je.length===0,className:`w-full py-4.5 rounded-xl font-sans font-black uppercase text-[11px] tracking-[0.2em] transition-all duration-350 border select-none ${je.length===0?"bg-gray-100 text-gray-400 border-gray-150 cursor-not-allowed":"bg-black hover:bg-neutral-900 text-white border-black cursor-pointer active:scale-[0.98]"}`,children:"Save & Continue"})]})]})]}):oe.length>0?s.jsx("div",{className:"divide-y divide-gray-100",children:oe.map((Te,Ct)=>{const Zn=Ct===Math.max(2,oe.length-3);return s.jsxs(ie.Fragment,{children:[s.jsx("div",{ref:Zn?z:void 0,children:s.jsx(O_,{article:Te,onClick:X,variant:"social",priority:Ct<2,onAuthorClick:Ut})}),Ct===2&&fn&&s.jsx("div",{className:"p-4 bg-gray-50/50 border-b border-gray-100",children:s.jsx(Yw,{advert:fn})}),Ct===3&&Ft&&s.jsx(E9e,{posts:wr,onOpenPosts:()=>{Xt("posts"),window.scrollTo({top:0,behavior:"smooth"})},onAuthorClick:Ut}),Ct===5&&Le&&s.jsx("div",{className:"p-4 bg-gray-50/50 border-b border-gray-100",children:s.jsx(Yw,{advert:Le})})]},`feed-${Te.id}-${Ct}`)})}):s.jsxs("div",{className:"space-y-5 px-4 py-2",children:[s.jsxs("div",{className:"space-y-4 pt-2",children:[s.jsx("div",{className:"flex items-center gap-2 text-[10px] font-black text-gray-400 uppercase tracking-widest px-1 pb-2 border-b border-gray-50",children:s.jsx("span",{children:"📰 Articles Feed & Dispatches"})}),s.jsx(Sp,{variant:"social"}),s.jsx(Sp,{variant:"social"}),s.jsx(Sp,{variant:"social"})]}),s.jsxs("div",{className:"p-8 text-center bg-gray-50 border border-gray-100/60 rounded-2xl select-none",children:[s.jsx(Fh,{size:24,className:"text-gray-300 mx-auto mb-2"}),s.jsx("p",{className:"text-[10px] font-black uppercase text-gray-400 tracking-wider",children:"Silent Dispatch Feed"}),s.jsx("p",{className:"text-[9px] text-gray-400 mt-1 max-w-xs mx-auto",children:"No general journalism postings currently active. Check the student lounge, announcements, debates or purchase passes above!"})]})]}),De.length>0&&s.jsxs("div",{className:"p-4 space-y-4 bg-gray-50/30 border-t border-b border-gray-100",children:[s.jsx("span",{className:"text-[10px] font-black tracking-widest text-red-650 uppercase block text-left",children:"🔥 Spotlight Feature Postings"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:De.map((Te,Ct)=>s.jsx(O_,{article:Te,onClick:X,variant:"big",onAuthorClick:Ut},`spotlight-${Te.id}-${Ct}`))})]}),Ye.length>0&&s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("span",{className:"text-[10px] font-black tracking-widest text-gray-400 uppercase block text-left",children:"📰 Support Micro-Dispatches"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Ye.map((Te,Ct)=>s.jsx(O_,{article:Te,onClick:X,variant:"magazine",onAuthorClick:Ut},`small-${Te.id}-${Ct}`))})]}),He.length>0&&s.jsx("div",{className:"my-6",children:s.jsx(Ree,{currentPage:S,totalPages:Math.ceil(He.length/T),totalItems:He.length,itemsPerPage:T,onPageChange:Te=>{C(Te),Te*T>V-10&&L(Ct=>Math.max(Ct,Te*T+50)),window.scrollTo({top:0,behavior:"smooth"})},onItemsPerPageChange:Te=>{D(Te),C(1),Te>V&&L(Te+50)},itemLabel:"articles"})})]}),s.jsxs("aside",{className:"hidden lg:block lg:col-span-3 xl:col-span-3 2xl:col-span-3 space-y-5 pl-1 text-left sticky top-24 self-start max-h-[calc(100vh-8rem)] overflow-y-auto no-scrollbar scroll-smooth",children:[s.jsxs("div",{className:"bg-white border border-gray-150 rounded-2xl p-4 shadow-xs space-y-3 text-left",children:[s.jsx("div",{className:"flex items-center justify-end pb-2 border-b border-gray-100 select-none",children:s.jsxs("button",{onClick:()=>{if(o.length>0){const Ct=[...o.length>3?o.slice(3):o].sort(()=>Math.random()-.5);$(Ct.slice(0,8)),pe.success("Shuffled archives!",{id:"shuffle-articles"})}},className:"text-[8px] font-black uppercase tracking-wider text-gray-500 hover:text-red-650 flex items-center gap-1.5 transition-colors cursor-pointer px-2.5 py-1 bg-gray-50 hover:bg-red-50 rounded-lg border border-gray-100",title:"Shuffle older articles",children:[s.jsx(dF,{size:11}),s.jsx("span",{children:"Shuffle"})]})}),F.length===0?s.jsx("p",{className:"text-[8.5px] text-gray-400 py-3 text-center",children:"Loading vintage archives..."}):s.jsx("div",{className:"divide-y divide-gray-100 space-y-2.5",children:F.map((Te,Ct)=>s.jsxs("div",{onClick:()=>{X(Te),window.scrollTo({top:0,behavior:"auto"})},className:"pt-2.5 group cursor-pointer flex gap-3 items-start first:pt-0 hover:bg-gray-50/60 p-1.5 rounded-xl transition-all",children:[s.jsx("div",{className:"w-11 h-11 rounded-lg overflow-hidden relative shrink-0 bg-gray-100 border border-gray-150/80",children:s.jsx("img",{src:Te.featuredImageUrl||i(Te.title,Te.category),alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex-1 min-w-0 text-left space-y-0.5",children:[s.jsx("span",{className:"text-[7.5px] font-mono font-black text-red-650 uppercase tracking-widest block",children:Te.category||"Archive"}),s.jsx("h5",{className:"font-extrabold text-[10px] text-gray-950 uppercase tracking-tight leading-snug group-hover:text-red-650 transition-colors line-clamp-2 font-sans",children:Te.title})]})]},`archive-${Te.id}-${Ct}`))})]}),s.jsxs("div",{className:"bg-white border border-gray-100 rounded-2xl p-4 shadow-xs space-y-3",children:[s.jsx("span",{className:"text-[10px] font-black tracking-[0.15em] text-gray-900 uppercase block",children:"⚡ QUICK PORTAL"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-left select-none",children:[s.jsxs("button",{onClick:()=>{Xt("posts"),window.scrollTo({top:0,behavior:"auto"})},className:"p-3 bg-gray-50 hover:bg-red-50 text-gray-900 hover:text-red-650 font-black uppercase text-[9px] tracking-wider rounded-xl transition-all border border-gray-100 text-center cursor-pointer flex flex-col items-center gap-1.5",children:[s.jsx(bi,{size:14,className:"stroke-[2.5]"}),s.jsx("span",{children:"Lounge Feed"})]}),s.jsxs("button",{onClick:()=>{xe(!0)},className:"p-3 bg-gray-50 hover:bg-amber-50 text-gray-900 hover:text-amber-600 font-black uppercase text-[9px] tracking-wider rounded-xl transition-all border border-gray-100 text-center cursor-pointer flex flex-col items-center gap-1.5",children:[s.jsx(uc,{size:14,className:"stroke-[2.5]"}),s.jsx("span",{children:"Podcasts"})]}),s.jsxs("button",{onClick:()=>{St(!0)},className:"p-3 bg-gray-50 hover:bg-green-50 text-gray-900 hover:text-green-655 font-black uppercase text-[9px] tracking-wider rounded-xl transition-all border border-gray-100 text-center cursor-pointer flex flex-col items-center gap-1.5",children:[s.jsx(Aa,{size:14,className:"stroke-[2.5]"}),s.jsx("span",{children:"Buy Tickets"})]}),s.jsxs("button",{onClick:()=>{Xt("account"),window.scrollTo({top:0,behavior:"auto"})},className:"p-3 bg-gray-50 hover:bg-purple-50 text-gray-900 hover:text-purple-650 font-black uppercase text-[9px] tracking-wider rounded-xl transition-all border border-gray-100 text-center cursor-pointer flex flex-col items-center gap-1.5",children:[s.jsx(_o,{size:14,className:"stroke-[2.5]"}),s.jsx("span",{children:"Connections"})]})]})]})]})]}),Ft&&He.length>0&&s.jsxs("div",{className:"mt-8 mb-6 p-4 sm:p-5 bg-white border border-gray-200/80 rounded-2xl text-left shadow-xs select-none",children:[s.jsxs("div",{className:"flex items-center justify-between pb-2.5 mb-3 border-b border-gray-100 gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Aa,{size:15,className:"text-accent"}),s.jsx("span",{className:"text-[11px] font-black uppercase tracking-wider text-gray-900 font-sans",children:"Events & Tickets"})]}),s.jsxs("button",{type:"button",onClick:()=>{St(!0)},className:"text-[9.5px] font-black uppercase tracking-wider text-accent hover:text-red-700 bg-red-50 hover:bg-red-100/80 px-2.5 py-1 rounded-lg transition-all cursor-pointer flex items-center gap-1",children:[s.jsx("span",{children:"View all"}),s.jsx(Op,{size:11})]})]}),s.jsx(nY,{onOpenPosts:()=>{Xt("posts"),window.scrollTo({top:0,behavior:"smooth"})},onAuthorClick:Ut})]})]})}switch(me){case"auth":{const He=new URLSearchParams(window.location.search),_=He.get("pending_follow_uid"),U=He.get("pending_follow_name")||"";return s.jsx("div",{className:"min-h-[85vh] py-16 px-4 bg-slate-50 flex flex-col items-center justify-center font-sans",children:s.jsxs("div",{className:"w-full max-w-lg bg-white p-8 md:p-12 border border-gray-150 rounded-3xl shadow-lg relative overflow-hidden",children:[s.jsx("div",{className:"absolute top-0 left-0 w-full h-1.5 bg-[#EE1B24]"}),_&&s.jsxs("div",{className:"mb-8 p-4 bg-red-50/50 border border-red-100 rounded-2xl text-left select-none",children:[s.jsx("p",{className:"text-[9px] font-black uppercase text-[#EE1B24] tracking-widest mb-1",children:"Peer Connection Request"}),s.jsxs("p",{className:"text-xs text-gray-700 leading-relaxed font-semibold",children:["Sign up or log in below to automatically build your peer connection with ",s.jsxs("span",{className:"font-extrabold text-[#EE1B24]",children:["@",U.toLowerCase().replace(/\s+/g,"")]}),"."]})]}),s.jsx(RV,{onAuthSuccess:async()=>{const H=_||localStorage.getItem("pending_follow_uid"),oe=U||localStorage.getItem("pending_follow_name")||"this peer";if(H&&Ne.currentUser)try{const Ye=Qt(et(he,"follows"),Ar("followerId","==",Ne.currentUser.uid),Ar("followedId","==",H));(await vn(Ye)).empty&&(await ur(et(he,"follows"),{followerId:Ne.currentUser.uid,followedId:H,createdAt:En()}),pe.success(`Successfully followed ${oe}!`))}catch(Ye){console.warn("Auto-follow check failed:",Ye)}finally{localStorage.removeItem("pending_follow_uid"),localStorage.removeItem("pending_follow_name")}pe.success("Successfully authenticated. Welcome to Campus Eye!",{id:"auth-success-toast"});const De=new URL(window.location.href);De.searchParams.delete("tab"),De.searchParams.delete("pending_follow_uid"),De.searchParams.delete("pending_follow_name"),window.history.replaceState({},"",De.toString()),Xt("home")},onClose:()=>{Xt("home")}}),s.jsxs("div",{className:"mt-8 flex flex-col items-center justify-center space-y-2 pt-6 border-t border-gray-100",children:[s.jsx("div",{className:"w-10 h-10 bg-red-650 rounded-full flex items-center justify-center shadow-md",children:s.jsx(Fh,{className:"text-white",size:20})}),s.jsx("span",{className:"text-[10px] font-serif font-black uppercase tracking-[0.2em] text-gray-950",children:"Campus Eye"}),s.jsx("span",{className:"text-[8px] font-mono uppercase tracking-widest text-gray-400",children:"Official Student Media Network"})]})]})})}case"podcasts":return s.jsx(DV,{});case"events":return s.jsxs("div",{className:"news-container py-12 px-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-12 border-b border-black pb-4",children:[s.jsx("h2",{className:"text-4xl font-serif font-black text-gray-950 tracking-tighter uppercase italic",children:"Events"}),s.jsx("button",{className:"px-6 py-2 bg-black text-white text-[10px] font-bold uppercase tracking-widest hover:bg-accent transition-all",children:"Submit Event"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[{title:"Freshers Gala",date:"25 APR",loc:"Main Hall",type:"Social"},{title:"Innovation Summit",date:"02 MAY",loc:"Tech Center",type:"Academy"},{title:"Varsity Finals",date:"15 MAY",loc:"Sports Complex",type:"Sports"}].map((He,_)=>s.jsxs("div",{className:"group overflow-hidden border border-gray-150 rounded-2xl bg-white hover:bg-gray-50 transition-all p-3.5 flex gap-4 items-center",children:[s.jsxs("div",{className:"w-20 h-20 sm:w-24 sm:h-24 rounded-xl overflow-hidden bg-gray-950 relative shrink-0",children:[s.jsx("img",{src:`https://picsum.photos/seed/event${_}/300/300`,className:"w-full h-full object-cover opacity-85 group-hover:opacity-100 transition-all duration-700",alt:"",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"absolute bottom-1 right-1 bg-white px-1.5 py-0.5 text-center shadow-md rounded",children:[s.jsx("p",{className:"text-[9px] font-black text-accent leading-none",children:He.date.split(" ")[0]}),s.jsx("p",{className:"text-[7px] font-black text-gray-400 uppercase leading-none",children:He.date.split(" ")[1]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[s.jsx("p",{className:"text-[8px] font-black text-accent uppercase tracking-widest mb-1",children:He.type}),s.jsx("h3",{className:"text-sm font-serif font-black text-gray-950 mb-2 truncate leading-tight",children:He.title}),s.jsxs("div",{className:"flex flex-col gap-1 text-gray-400 text-[8.5px] font-bold uppercase tracking-widest leading-none",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(rg,{size:10})," ",He.date]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Nu,{size:10})," ",He.loc]})]})]})]},_))})]});case"discussions":{const _=Sr.filter(U=>{if(!Be.trim())return!0;const H=Be.toLowerCase();return(U.title||"").toLowerCase().includes(H)||(U.description||"").toLowerCase().includes(H)});return s.jsxs("div",{className:"news-container py-12 px-4 max-w-4xl mx-auto space-y-8 animate-fade-in",children:[s.jsxs("div",{className:"text-center md:text-left space-y-2 border-b border-gray-100 pb-6 w-full",children:[s.jsxs("h2",{className:"text-3xl font-serif font-black text-gray-950 tracking-tighter uppercase italic flex items-center justify-center md:justify-start gap-2",children:[s.jsx(bi,{className:"text-red-650 shrink-0",size:28}),s.jsx("span",{children:"Public Debates Lobby"})]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Active intellectual forums and critical arguments across our university"})]}),s.jsx("div",{className:"w-full rounded-[2rem] overflow-hidden border border-gray-150 shadow-md bg-white",children:s.jsx(UMe,{})}),s.jsxs("div",{className:"border-t border-gray-100 pt-8 mt-4 text-left",children:[s.jsx("h3",{className:"text-lg font-serif font-black text-gray-950 uppercase italic tracking-tight mb-2",children:"Ongoing Debate Threads"}),s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-widest mb-6",children:"Explore individual debate channels or join dynamic arguments below"})]}),s.jsxs("div",{className:"relative w-full",children:[s.jsx("input",{type:"text",value:Be,onChange:U=>Bt(U.target.value),placeholder:"Search active debate threads by title or keywords...",className:"w-full px-5 py-3.5 pl-12 bg-white border border-gray-200 rounded-2xl text-xs font-bold shadow-sm focus:border-red-650 outline-none transition-all placeholder:text-gray-400 font-mono"}),s.jsx("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-440",children:s.jsx(bi,{size:16})}),Be&&s.jsx("button",{onClick:()=>Bt(""),className:"absolute right-4 top-1/2 -translate-y-1/2 text-xs font-black uppercase text-gray-400 hover:text-red-500 font-mono transition-colors",children:"Clear"})]}),_.length===0?s.jsxs("div",{className:"bg-white p-12 text-center rounded-3xl border border-gray-100 shadow-sm space-y-3 w-full",children:[s.jsx("p",{className:"text-xs font-bold text-gray-400 uppercase tracking-widest font-mono",children:"No active debate topics match your search"}),s.jsx("button",{onClick:()=>Bt(""),className:"px-6 py-2.5 bg-gray-950 text-white text-[9px] font-black uppercase tracking-widest rounded-xl hover:bg-black transition-all cursor-pointer",children:"Reset Directory"})]}):s.jsx("div",{className:"space-y-6 w-full",children:_.map(U=>{const H=Mn===U.id;return s.jsxs("div",{className:"group bg-white rounded-3xl border border-gray-150 shadow-md hover:shadow-xl transition-all p-6 md:p-8 flex flex-col gap-6 relative overflow-hidden text-left",children:[s.jsxs("div",{className:"relative w-full h-40 md:h-52 bg-gray-50 overflow-hidden rounded-2xl border border-gray-100",children:[s.jsx("img",{src:U.bannerUrl||"https://images.unsplash.com/photo-1541872703-74c5e44368f9?auto=format&fit=crop&q=80&w=800",alt:"",className:"w-full h-full object-cover group-hover:scale-102 transition-transform duration-500",referrerPolicy:"no-referrer"}),s.jsx("div",{className:"absolute top-4 right-4 bg-gray-950/95 backdrop-blur-sm text-white text-[8px] font-black uppercase tracking-widest px-3 py-1.5 rounded-lg border border-white/10 shadow",children:U.isExternal?"External":"Built-In"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"text-xl md:text-2xl font-serif font-black text-gray-950 leading-tight",children:U.title}),U.description&&s.jsx("p",{className:"text-xs font-medium text-gray-500 leading-relaxed",children:U.description})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 pt-4 border-t border-gray-100",children:[s.jsxs("span",{className:"text-[9px] font-mono font-black text-gray-400 uppercase tracking-wider",children:["Created ",U.createdAt?U.createdAt.toDate?U.createdAt.toDate().toLocaleDateString():U.createdAt instanceof Date?U.createdAt.toLocaleDateString():new Date(U.createdAt).toLocaleDateString():"recently"]}),U.isExternal?s.jsxs("a",{href:U.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 px-6 py-3 bg-accent hover:bg-red-700 text-white text-[10px] font-black uppercase tracking-[0.1em] rounded-xl shadow-lg shadow-accent/15 group-hover:scale-102 transition-all cursor-pointer",children:[s.jsx("span",{children:"Continue to Discussion"}),s.jsx($a,{size:12})]}):s.jsxs("button",{onClick:()=>jn(H?null:U.id),className:`inline-flex items-center justify-center gap-2 px-6 py-3 text-[10px] font-black uppercase tracking-[0.1em] rounded-xl transition-all cursor-pointer ${H?"bg-gray-100 text-gray-850 hover:bg-gray-200":"bg-accent hover:bg-red-700 text-white shadow-lg shadow-accent/15"}`,children:[s.jsx("span",{children:H?"Collapse arguments":"View & Join Debate"}),s.jsx(bi,{size:12})]})]}),!U.isExternal&&H&&s.jsx("div",{className:"border-t border-gray-100 mt-2",children:s.jsx(LMe,{debateId:U.id})})]},U.id)})})]})}case"posts":return s.jsx($Me,{isAdmin:Lr,onUserProfileClick:Ut,sharedPostId:nt});case"marketplace":return s.jsxs("div",{className:"news-container py-8 px-4 font-sans text-left space-y-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 border-b border-gray-200 pb-4",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-3xl font-serif font-black text-gray-950 tracking-tighter uppercase italic flex items-center gap-3",children:[s.jsx(TC,{size:30}),"Marketplace & Verified Affiliates"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-wider mt-1",children:"Shop student items, explore verified affiliate accounts, and earn commission rewards on sales dispatches."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("a",{href:"https://link.thelocalrent.com/v?t=1786099107&tk=07c43b29b01fcaf275f96eea938d430f",target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 bg-gradient-to-r from-amber-500 to-orange-500 text-white text-[10px] font-extrabold uppercase tracking-widest rounded-xl hover:opacity-95 transition-all shadow-md flex items-center gap-1.5",children:[s.jsx(Zi,{size:14})," Join Affiliate Program"]}),s.jsx("button",{onClick:()=>pe.success("To post items on Marketplace, open the Campus Eye App or contact an Admin!"),className:"px-4 py-2 bg-gray-950 text-white text-[10px] font-extrabold uppercase tracking-widest rounded-xl hover:bg-black transition-all shadow-sm",children:"Post Item"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(Fo,{size:16})," Verified Affiliate Accounts in Market"]}),s.jsx("span",{className:"text-[9px] font-bold text-emerald-600 bg-emerald-50 px-2.5 py-1 rounded-full border border-emerald-200/60 uppercase tracking-wider",children:"✓ Verified Merchants & Affiliates"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[{name:"Campus Tech Hub",handle:"@campustech",category:"Laptops & Electronics",commission:"10% Affiliate Reward",verified:!0,productsCount:24,rating:"4.9 ★"},{name:"Hostel Essentials Ltd",handle:"@hostelitems",category:"Furniture & Appliances",commission:"8% Affiliate Reward",verified:!0,productsCount:18,rating:"4.8 ★"},{name:"Varsity Books & Stationery",handle:"@varsitybooks",category:"Academic Coursework",commission:"12% Affiliate Reward",verified:!0,productsCount:42,rating:"5.0 ★"}].map((He,_)=>s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-150 shadow-xs hover:border-amber-400 hover:shadow-md transition-all space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-tr from-amber-500 to-indigo-600 text-white font-extrabold text-sm flex items-center justify-center uppercase shadow-sm",children:He.name.charAt(0)}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("h4",{className:"text-xs font-black text-gray-900",children:He.name}),s.jsx(Fo,{size:12})]}),s.jsx("p",{className:"text-[10px] text-gray-400 font-bold",children:He.handle})]})]}),s.jsx("span",{className:"text-[9px] font-black text-amber-700 bg-amber-50 border border-amber-200 px-2 py-0.5 rounded-md uppercase",children:He.rating})]}),s.jsxs("div",{className:"text-[11px] text-gray-600 font-medium",children:["Category: ",s.jsx("span",{className:"font-bold text-gray-900",children:He.category})," (",He.productsCount," items)"]}),s.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-gray-100",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase text-emerald-600 tracking-wide",children:["💰 ",He.commission]}),s.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(`https://link.thelocalrent.com/v?t=1786099107&tk=07c43b29b01fcaf275f96eea938d430f&ref=${He.handle.replace("@","")}`),pe.success(`Copied Affiliate Link for ${He.name}! Earn rewards on referrals.`,{icon:"🔗"})},className:"text-[9px] font-black uppercase tracking-wider text-indigo-600 bg-indigo-50 hover:bg-indigo-100 px-3 py-1.5 rounded-lg transition-colors cursor-pointer",children:"Get Affiliate Link"})]})]},_))})]}),s.jsxs("div",{className:"space-y-4 pt-4",children:[s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900",children:"Featured Campus Listings"}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:[{name:"Scientific Calculator FX-991EX",price:"UGX 40,000",cat:"Academic",seller:"Campus Tech Hub",affiliate:"10% Reward"},{name:"Orthopedic Mattress & Bed Frame",price:"UGX 150,000",cat:"Hostel",seller:"Hostel Essentials Ltd",affiliate:"8% Reward"},{name:"Apple MacBook Pro M1 16GB",price:"UGX 3,500,000",cat:"Electronics",seller:"Campus Tech Hub",affiliate:"10% Reward"},{name:"Ergonomic Study Desk & Chair",price:"UGX 60,000",cat:"Hostel",seller:"Hostel Essentials Ltd",affiliate:"8% Reward"}].map((He,_)=>s.jsxs("div",{className:"group bg-white border border-gray-150 rounded-2xl shadow-xs overflow-hidden flex flex-col hover:shadow-md transition-all",children:[s.jsxs("div",{className:"aspect-square bg-gray-50 flex items-center justify-center relative overflow-hidden",children:[s.jsx(vie,{size:40,className:"text-gray-300 group-hover:scale-110 transition-transform"}),s.jsxs("div",{className:"absolute top-3 right-3 bg-amber-500 text-white px-2.5 py-0.5 text-[8px] font-black uppercase tracking-widest rounded-full shadow-xs flex items-center gap-1",children:[s.jsx(Fo,{size:10,className:"text-white"})," Verified"]})]}),s.jsxs("div",{className:"p-4 flex-1 flex flex-col justify-between space-y-2",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-[9px] font-extrabold text-gray-400 uppercase tracking-widest",children:He.cat}),s.jsx("span",{className:"text-[8px] font-black text-emerald-600 bg-emerald-50 px-1.5 py-0.5 rounded",children:He.affiliate})]}),s.jsx("h3",{className:"text-xs font-black text-gray-950 mt-1 line-clamp-1",children:He.name}),s.jsxs("p",{className:"text-[10px] font-bold text-gray-500 mt-0.5",children:["Seller: ",He.seller]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-gray-100 gap-1",children:[s.jsx("p",{className:"text-xs font-black text-indigo-600 truncate",children:He.price}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsxs("button",{type:"button",onClick:U=>{U.stopPropagation(),window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:{uid:He.sellerId||`seller_${_}`,displayName:He.seller,username:He.seller.toLowerCase().replace(/\s+/g,""),photoURL:""}}))},className:"p-1 px-2 bg-[#007AFF] hover:bg-blue-600 text-white rounded-lg transition-all cursor-pointer flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider shrink-0 shadow-2xs",title:`Direct messaging envelope icon: Chat with connected seller ${He.seller}`,children:[s.jsx(ea,{size:10,strokeWidth:2.5}),s.jsx("span",{className:"hidden sm:inline",children:"Message"})]}),s.jsx("button",{onClick:()=>{window.open("https://link.thelocalrent.com/v?t=1786099107&tk=07c43b29b01fcaf275f96eea938d430f","_blank")},className:"text-[9px] font-black uppercase tracking-wider text-white bg-black hover:bg-neutral-800 px-2.5 py-1 rounded-lg transition-colors cursor-pointer",children:"Buy Item"})]})]})]})]},_))})]})]});case"teams":return s.jsxs("div",{className:"news-container py-12 px-4",children:[s.jsx("h2",{className:"text-4xl font-serif font-black text-gray-950 tracking-tighter uppercase italic mb-12 border-b border-black pb-4",children:"University Teams"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8",children:["Basketball","Football","Rugby"].map((He,_)=>s.jsxs("div",{className:"bg-white p-10 border border-gray-100 shadow-xl text-center group hover:bg-black hover:text-white transition-all duration-500",children:[s.jsx("div",{className:"w-24 h-24 bg-gray-50 rounded-full mx-auto mb-8 flex items-center justify-center text-gray-300 group-hover:bg-accent group-hover:text-white transition-all scale-110 shadow-inner",children:s.jsx(_o,{size:40})}),s.jsxs("h3",{className:"text-2xl font-serif font-black uppercase italic tracking-tighter mb-2",children:[He," Team"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-[0.3em] mb-8",children:"Varsity Div 1"}),s.jsx("button",{className:"w-full py-4 bg-black text-white text-[10px] font-black uppercase tracking-widest hover:bg-white hover:text-black border border-transparent hover:border-gray-200 transition-all",children:"Join Team"})]},_))})]});case"feedback":return s.jsx("div",{className:"news-container py-12 px-4 min-h-[70vh]",children:s.jsxs("div",{className:"flex flex-col lg:flex-row gap-16",children:[s.jsxs("div",{className:"lg:w-1/3 space-y-8",children:[s.jsxs("h2",{className:"text-5xl font-serif font-black text-gray-950 leading-[0.85] uppercase italic tracking-tighter",children:["Voice Your ",s.jsx("span",{className:"text-accent block",children:"Opinion."})]}),s.jsx("p",{className:"text-gray-500 font-bold leading-relaxed italic border-l-4 border-accent pl-6",children:`"Your feedback is the heart of our evolution. Tell us what we're missing."`}),s.jsx("div",{className:"pt-8 border-t border-gray-100 flex flex-col gap-6",children:s.jsxs("div",{className:"flex items-center gap-4 text-gray-400 group",children:[s.jsx("div",{className:"w-10 h-10 bg-gray-50 flex items-center justify-center text-accent group-hover:bg-accent group-hover:text-white transition-all",children:s.jsx(ea,{size:16})}),s.jsx("span",{className:"text-xs font-bold uppercase tracking-widest text-gray-950",children:"feedback@campuseye.media"})]})})]}),s.jsxs("div",{className:"flex-1 bg-white p-8 md:p-12 shadow-2xl border border-gray-100 relative overflow-hidden",children:[s.jsx("div",{className:"absolute top-0 right-0 w-32 h-32 bg-accent/5 rounded-full -mr-16 -mt-16 blur-3xl"}),s.jsxs("form",{onSubmit:Xa,className:"space-y-8 relative z-10",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Full Identity"}),s.jsx("input",{required:!0,type:"text",value:ss.name,onChange:He=>Un({...ss,name:He.target.value}),className:"w-full px-6 py-4 bg-gray-50 border-2 border-transparent focus:border-accent transition-all outline-none text-sm font-bold placeholder:text-gray-300",placeholder:"e.g. Victor Atwiine"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Digital Address"}),s.jsx("input",{required:!0,type:"email",value:ss.email,onChange:He=>Un({...ss,email:He.target.value}),className:"w-full px-6 py-4 bg-gray-50 border-2 border-transparent focus:border-accent transition-all outline-none text-sm font-bold placeholder:text-gray-300",placeholder:"Enter your email address"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Detailed Critique"}),s.jsx("textarea",{required:!0,value:ss.message,onChange:He=>Un({...ss,message:He.target.value}),className:"w-full px-6 py-4 bg-gray-50 border-2 border-transparent focus:border-accent transition-all outline-none text-sm font-bold placeholder:text-gray-300 min-h-[200px] resize-none",placeholder:"How can we sharpen our eye?"})]}),s.jsx("button",{type:"submit",disabled:Ui,className:"w-full py-5 bg-black text-white text-[11px] font-black uppercase tracking-[0.3em] hover:bg-accent transition-all disabled:opacity-50",children:Ui?"TRANSMITTING...":"DISPATCH FEEDBACK"})]})]})]})});case"account":return jr?s.jsxs("div",{className:"news-container py-20 px-4 min-h-[50vh] flex flex-col items-center justify-center",children:[s.jsx(Er,{className:"animate-spin text-gray-500 mb-2",size:24}),s.jsx("p",{className:"text-[10px] font-sans font-black uppercase tracking-widest text-gray-400",children:"Retrieving Member Profile..."})]}):Ot?s.jsx("div",{className:"news-container py-10 px-4 min-h-[70vh] max-w-2xl mx-auto relative font-sans",children:s.jsxs("div",{className:"bg-white p-10 border border-gray-100 relative overflow-hidden text-left shadow-sm rounded-2xl",children:[s.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-[#EE1B24]"}),s.jsx("button",{onClick:()=>{const He=new URL(window.location.href);He.searchParams.delete("uid"),window.history.replaceState({},"",He.toString()),on(null),Xt("home"),window.scrollTo({top:0,behavior:"auto"})},className:"absolute top-5 right-5 p-2 text-gray-400 hover:text-black hover:bg-gray-50 rounded-full transition-all border border-transparent hover:border-gray-150 cursor-pointer flex items-center justify-center",title:"Close Profile & Return Home",children:s.jsx(er,{size:16})}),s.jsxs("div",{className:"flex flex-col items-center text-center relative z-10 mb-12",children:[s.jsx("div",{className:"relative mb-6",children:s.jsx("div",{className:"w-32 h-32 border border-gray-200 overflow-hidden ring-4 ring-gray-50 rounded-full",children:s.jsx("img",{src:Ot.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Ot.displayName||"User")}&background=random`,className:"w-full h-full object-cover rounded-full",alt:"",referrerPolicy:"no-referrer"})})}),s.jsxs("div",{className:"flex items-center gap-2 mt-2 select-none",children:[s.jsx("h2",{className:"text-3xl font-sans font-extrabold text-gray-950 tracking-tight uppercase",children:(()=>{const He=Ot.displayName||"Campus Peer";return He.includes("@")?He.split("@")[0]:He})()}),Ot.role==="admin"&&s.jsx("span",{className:"text-[7.5px] font-black uppercase tracking-widest text-[#9B2C2C] bg-[#FFF5F5] border border-red-100 px-2 py-0.5 rounded-full inline-block",children:"Staff"})]}),s.jsxs("div",{className:"flex items-center justify-center gap-6 mt-6 py-4.5 px-6 border border-gray-100 rounded-2xl bg-gray-50/40 w-full max-w-sm select-none",children:[s.jsxs("div",{onClick:()=>{cr("following"),mt(Ot.id),hr(!0)},className:"text-center font-sans cursor-pointer hover:opacity-80 transition-all",title:"View Following list",children:[s.jsx("p",{className:"text-xl font-black text-gray-950",children:ue}),s.jsx("p",{className:"text-[8.5px] font-black uppercase text-gray-450 tracking-widest mt-0.5",children:"Following"})]}),s.jsx("div",{className:"h-8 w-[1px] bg-gray-150"}),s.jsxs("div",{onClick:()=>{cr("followers"),mt(Ot.id),hr(!0)},className:"text-center font-sans cursor-pointer hover:opacity-80 transition-all",title:"View Followers list",children:[s.jsx("p",{className:"text-xl font-black text-gray-950",children:Qe}),s.jsx("p",{className:"text-[8.5px] font-black uppercase text-gray-450 tracking-widest mt-0.5",children:"Followers"})]})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-2.5 w-full max-w-lg mt-8",children:[s.jsx("button",{onClick:async()=>{if(!Ne.currentUser){localStorage.setItem("pending_follow_uid",Ot.id),localStorage.setItem("pending_follow_name",Ot.displayName||"Campus Member");const He=`${window.location.origin}/?tab=auth&pending_follow_uid=${Ot.id}&pending_follow_name=${encodeURIComponent(Ot.displayName||"Campus Member")}`;window.open(He,"_blank"),pe.success("Opening connection setup dashboard in a new tab!",{id:"login-to-follow"});return}try{const He=Qt(et(he,"follows"),Ar("followerId","==",Ne.currentUser.uid),Ar("followedId","==",Ot.id)),_=await vn(He);_.empty?(await ur(et(he,"follows"),{followerId:Ne.currentUser.uid,followedId:Ot.id,createdAt:En()}),pe.success(`Following ${Ot.displayName||"User"}`)):(await si(Je(he,"follows",_.docs[0].id)),pe.success(`Unfollowed ${Ot.displayName||"User"} successfully`))}catch(He){console.warn("Follow toggle failed:",He)}},className:"w-full py-3.5 bg-neutral-950 hover:bg-neutral-900 border border-neutral-800 text-white font-black uppercase tracking-widest text-[11px] transition-all active:scale-[0.98] cursor-pointer flex items-center justify-center gap-2 rounded-xl",children:Fn?"UNFOLLOW":"★ FOLLOW"}),s.jsxs("button",{onClick:()=>{if(!Ne.currentUser){pe.error("Please sign in to start a private conversation");return}At({uid:Ot.id,displayName:Ot.displayName||"Campus Member",username:(Ot.username||Ot.displayName||"user").toLowerCase().replace(/\s+/g,""),photoURL:Ot.photoURL||""})},className:"w-full py-3.5 bg-[#007AFF] hover:bg-blue-600 border border-blue-400 text-white font-black uppercase tracking-widest text-[11px] transition-all active:scale-[0.98] cursor-pointer flex items-center justify-center gap-2 rounded-xl shadow-xs",title:"Send a private message",children:[s.jsx(bi,{size:13})," MESSAGE"]}),s.jsxs("button",{onClick:()=>{const He=`${window.location.origin}/?tab=account&uid=${Ot.id}`;navigator.clipboard.writeText(He).then(()=>pe.success("Copied profile sharing link to clipboard!",{id:"profile-copied"})).catch(()=>pe.error("Failed to copy link. Please copy URL from browser address bar.",{id:"profile-copy-fail"}))},className:"w-full py-3.5 bg-white hover:bg-gray-50 border border-gray-200 text-gray-800 font-black uppercase tracking-widest text-[11px] transition-all active:scale-[0.98] cursor-pointer flex items-center justify-center gap-1.5 rounded-xl",children:[s.jsx(hf,{size:13})," SHARE"]}),s.jsxs("button",{onClick:()=>mn(Ot.id),className:"w-full py-3.5 bg-gray-950 hover:bg-black border border-gray-800 text-amber-300 font-black uppercase tracking-widest text-[11px] transition-all active:scale-[0.98] cursor-pointer flex items-center justify-center gap-1.5 rounded-xl",children:[s.jsx(wp,{size:13,className:"text-amber-400"})," STATS"]})]}),!Ne.currentUser&&s.jsxs("div",{className:"w-full max-w-sm mt-8 p-6 bg-slate-50 border border-gray-150/80 rounded-2xl text-center space-y-4 shadow-xs select-none",children:[s.jsx("p",{className:"text-[11px] font-sans font-bold uppercase tracking-wider text-gray-500",children:"✨ Peer linkage Invitation"}),s.jsxs("p",{className:"text-xs text-gray-600 leading-relaxed font-medium",children:["Connect with ",s.jsx("span",{className:"font-extrabold text-black",children:(()=>{const He=Ot.displayName||"Campus Peer";return He.includes("@")?He.split("@")[0]:He})()})," to monitor peer announcements and student lounge dispatches!"]}),s.jsxs("div",{className:"flex flex-col gap-2 pt-1",children:[s.jsx("button",{onClick:()=>{localStorage.setItem("pending_follow_uid",Ot.id),localStorage.setItem("pending_follow_name",Ot.displayName||"this peer"),G(!0)},className:"w-full py-3 bg-[#EE1B24] hover:bg-red-700 text-white font-black uppercase tracking-widest text-[9.5px] rounded-xl transition-all active:scale-95 flex items-center justify-center gap-2 cursor-pointer shadow-sm",children:"Continue with Google / Sign Up"}),s.jsxs("button",{onClick:()=>{window.open(window.location.href,"_blank")},className:"w-full py-2.5 bg-white hover:bg-gray-50 border border-gray-200 text-gray-700 font-black uppercase tracking-widest text-[8.5px] rounded-xl transition-all flex items-center justify-center gap-1.5 cursor-pointer",children:[s.jsx($a,{size:11,className:"mr-1"})," Open in New Tab"]})]}),s.jsxs("div",{className:"pt-4 border-t border-gray-150/60 flex flex-col items-center",children:[s.jsx(Pee,{className:"scale-[0.8] opacity-75"}),s.jsx("p",{className:"text-[7px] font-mono font-bold tracking-[0.25em] text-gray-400 uppercase mt-2",children:"Autonomous Student Journalism System"})]})]}),s.jsxs("div",{className:"mt-8 text-center pt-6 border-t border-gray-100 w-full max-w-sm",children:[s.jsx("span",{className:"text-[8.5px] font-sans font-black text-gray-400 uppercase tracking-widest block mb-3.5",children:"🤝 Peer-to-Peer Lounge Linkages"}),s.jsx("button",{onClick:()=>{if(!Ne.currentUser){pe.error("Please login to access Peer Lounge connect systems."),G(!0);return}cr("connections"),hr(!0),pe.success("Opened Peer connections board!")},className:"px-5 py-2 hover:bg-[#EEF2F6] text-[#2B6CB0] font-black uppercase text-[9px] tracking-widest rounded-full border border-blue-150 bg-[#F7FAFC] transition-colors",children:"Browse Mutual Collaborators"})]})]})]})}):Lr&&an?s.jsx("div",{className:"news-container py-10 px-4 min-h-[90vh] max-w-5xl mx-auto",children:s.jsxs("div",{className:"bg-white p-6 md:p-10 border border-gray-150 rounded-2xl relative shadow-md overflow-hidden text-left",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 pb-4 border-b border-gray-150 mb-8 select-none",children:[s.jsx("button",{onClick:()=>fr(!1),className:"p-1.5 border border-gray-200 hover:border-black text-gray-650 hover:text-black rounded-lg cursor-pointer transition-colors",title:"Back to User Profile Info",children:s.jsx(Cne,{size:14,className:"shrink-0"})}),s.jsx("div",{className:"flex items-center gap-2",title:"Editorial Director Console",children:s.jsx("div",{className:"p-1.5 bg-[#FFF5F5] text-[#9B2C2C] rounded-lg border border-red-100",children:s.jsx(vI,{size:14,className:"shrink-0"})})})]}),s.jsx(PS,{initialTab:kn})]})}):s.jsx("div",{className:"news-container py-10 px-4 min-h-[70vh] max-w-2xl mx-auto relative",children:s.jsxs("div",{className:"bg-white p-10 border border-gray-100 relative overflow-hidden text-left shadow-sm rounded-2xl",children:[s.jsx("button",{onClick:()=>{Xt(gr),window.scrollTo({top:0,behavior:"auto"})},className:"absolute top-5 right-5 p-2 text-gray-400 hover:text-black hover:bg-gray-50 rounded-full transition-all border border-transparent hover:border-gray-150 cursor-pointer flex items-center justify-center p-2.5 z-50",title:"Exit Profile & Return",children:s.jsx(er,{size:16})}),s.jsxs("div",{className:"flex flex-col items-center text-center relative z-10 mb-12",children:[s.jsxs("div",{className:"relative mb-6 group",children:[s.jsx("div",{className:"w-32 h-32 border border-gray-200 overflow-hidden ring-4 ring-gray-50",children:s.jsx("img",{src:((ot=Ne.currentUser)==null?void 0:ot.photoURL)||`https://ui-avatars.com/api/?name=${encodeURIComponent(((_t=Ne.currentUser)==null?void 0:_t.displayName)||"User")}&background=random`,className:"w-full h-full object-cover",alt:""})}),s.jsxs("label",{className:"absolute bottom-1 right-1 p-2 bg-black text-white cursor-pointer hover:bg-accent transition-all rounded-full border border-white shadow-md",title:"Change Avatar Photo",children:[s.jsx(kd,{size:14}),s.jsx("input",{type:"file",className:"hidden",accept:"image/*",onChange:zs})]})]}),Oa?s.jsxs("div",{className:"flex items-center gap-2 mt-2 w-full max-w-xs",children:[s.jsx("input",{type:"text",value:ia,onChange:He=>Cs(He.target.value),className:"border-2 border-accent px-3 py-1.5 rounded-lg text-sm text-center font-bold outline-none flex-1 tracking-tight min-w-0",placeholder:"Enter new username",required:!0}),s.jsx("button",{onClick:yi,disabled:Ui,className:"p-2 bg-accent hover:bg-black text-white rounded-lg transition-colors cursor-pointer flex items-center justify-center w-8 h-8",title:"Save Name",children:s.jsx(Bu,{size:14,className:"stroke-[3]"})}),s.jsx("button",{onClick:()=>ra(!1),className:"p-2 bg-gray-100 hover:bg-gray-200 text-gray-600 rounded-lg transition-colors cursor-pointer flex items-center justify-center w-8 h-8",title:"Cancel Edit",children:s.jsx(er,{size:14})})]}):s.jsxs("div",{className:"flex items-center gap-2.5 mt-2 group select-none",children:[s.jsx("h2",{className:"text-3xl font-sans font-extrabold text-gray-950 tracking-tight uppercase",children:((pn=Ne.currentUser)==null?void 0:pn.displayName)||"Campus Member"}),s.jsxs("div",{className:"flex items-center gap-1 opacity-100 transition-opacity",children:[s.jsx("button",{onClick:()=>{var He;Cs(((He=Ne.currentUser)==null?void 0:He.displayName)||""),ra(!0)},className:"p-1.5 text-gray-400 hover:text-accent border border-gray-150 hover:border-accent rounded-full bg-white hover:scale-105 transition-all text-[10px] cursor-pointer flex items-center justify-center shadow-xs",title:"Edit Display Name",children:s.jsx(kd,{size:11})}),s.jsx("button",{onClick:()=>{var _;const He=`${window.location.origin}/u/profile/${(_=Ne.currentUser)==null?void 0:_.uid}`;navigator.clipboard.writeText(He).then(()=>pe.success("Copied profile sharing link to clipboard!",{id:"profile-copied"})).catch(()=>pe.error("Failed to copy link. Please copy URL from browser address bar.",{id:"profile-copy-fail"}))},className:"p-1.5 text-gray-400 hover:text-accent border border-gray-150 hover:border-accent rounded-full bg-white hover:scale-105 transition-all text-[10px] cursor-pointer flex items-center justify-center shadow-xs",title:"Share profile next to editing icon",children:s.jsx(hf,{size:11})})]})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[s.jsx(ea,{size:14,className:"text-gray-400"}),s.jsx("p",{className:"text-gray-400 font-bold uppercase tracking-widest text-[10px]",children:(Lt=Ne.currentUser)==null?void 0:Lt.email})]})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-8 text-center select-none relative z-10",children:[s.jsxs("div",{onClick:()=>{cr("followers"),hr(!0)},className:"p-4 bg-gray-50 border border-gray-100/80 rounded-xl hover:border-red-650/30 hover:bg-red-50/10 cursor-pointer hover:scale-[1.02] active:scale-98 transition-all",title:"Click to view Followers",id:"profile-followers-box",children:[s.jsx("span",{className:"block text-2xl font-sans font-extrabold text-gray-950",children:ji}),s.jsx("span",{className:"text-[9px] font-black uppercase text-gray-400 tracking-widest font-mono",children:"Followers"})]}),s.jsxs("div",{onClick:()=>{cr("following"),hr(!0)},className:"p-4 bg-gray-50 border border-gray-100/80 rounded-xl hover:border-red-650/30 hover:bg-red-50/10 cursor-pointer hover:scale-[1.02] active:scale-98 transition-all",title:"Click to view Following",id:"profile-following-box",children:[s.jsx("span",{className:"block text-2xl font-sans font-extrabold text-gray-950",children:On}),s.jsx("span",{className:"text-[9px] font-black uppercase text-gray-400 tracking-widest font-mono",children:"Following"})]}),s.jsxs("div",{onClick:()=>{cr("connections"),hr(!0)},className:"p-4 bg-gray-50 border border-gray-100/80 rounded-xl hover:border-red-650/30 hover:bg-red-50/10 cursor-pointer hover:scale-[1.02] active:scale-98 transition-all",title:"Click to view Peer Lounge Connections",id:"profile-connections-box",children:[s.jsx("span",{className:"block text-2xl font-sans font-extrabold text-[#9B2C2C]",children:pi}),s.jsx("span",{className:"text-[9px] font-black uppercase text-gray-400 tracking-widest font-mono",children:"Peer Lounge"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 relative z-10",children:[s.jsxs("div",{className:"p-6 bg-gray-50 border border-gray-100",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[s.jsx("div",{className:"p-2 bg-white border border-gray-200 text-black",children:s.jsx(Nu,{size:16})}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Active Role"})]}),s.jsx("p",{className:"font-sans font-extrabold text-gray-950 uppercase tracking-tight text-xl",children:Lr?"Editorial Board":"Student Reporter"})]}),s.jsxs("div",{className:"p-6 bg-gray-50 border border-gray-100",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[s.jsx("div",{className:"p-2 bg-white border border-gray-200 text-accent",children:s.jsx(pl,{size:16})}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Trust Rating"})]}),s.jsx("p",{className:"font-sans font-extrabold text-accent uppercase tracking-tight text-xl",children:"Verified Member"})]})]}),s.jsx("div",{className:"mt-10 pt-10 border-t border-gray-100 relative z-10 font-sans",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8 text-left",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("h3",{className:"text-sm font-sans font-extrabold uppercase tracking-wider text-gray-950 flex items-center gap-2",children:[s.jsx(Aa,{size:16,className:"text-accent"})," My Event Tickets"]}),s.jsx("button",{onClick:()=>St(!0),className:"text-[10px] font-black uppercase tracking-widest text-accent hover:underline cursor-pointer",children:"Browse Events"})]}),s.jsx(C9e,{userId:((bn=Ne.currentUser)==null?void 0:bn.uid)||""})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("h3",{className:"text-sm font-sans font-extrabold uppercase tracking-wider text-gray-950 flex items-center gap-2",children:[s.jsx(ea,{size:16,className:"text-red-650"})," System Inbox & Keys"]}),s.jsx("span",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-widest",children:"Confidential OTP Center"})]}),s.jsx(j9e,{userId:((rn=Ne.currentUser)==null?void 0:rn.uid)||""})]})]})}),s.jsxs("div",{className:"mt-10 pt-10 border-t border-gray-100 text-left relative z-10",children:[s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsxs("h3",{className:"text-sm font-sans font-extrabold uppercase tracking-wider text-gray-950 flex items-center gap-2",children:[s.jsx(_o,{size:16,className:"text-red-650"})," Member Portal Desk"]}),s.jsx("span",{className:"text-[9px] font-black text-gray-400 tracking-wider uppercase",children:"Active Dispatch Terminals"})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3.5",children:[{id:"home",label:"Home",icon:eR,desc:"Central Dispatches"},{id:"news",label:"Campus News",icon:Fh,desc:"Hot editorial stream"},{id:"discussions",label:"Public Debates",icon:bi,desc:"Forum spaces & polls"},{id:"tickets",label:"Ticket Store",icon:Aa,desc:"Browse latest event passes"},{id:"podcasts",label:"Audio Podcasts",icon:uc,desc:"Listen to radio dispatches"},{id:"feedback",label:"Feedback Desk",icon:ea,desc:"Critiques, tips, & suggestions"}].map(He=>s.jsxs("button",{onClick:()=>{Xt(He.id),X(null),window.scrollTo({top:0,behavior:"smooth"})},className:"group flex flex-col p-4 bg-gray-50/50 hover:bg-red-50/30 border border-gray-100 hover:border-red-600/20 transition-all rounded-xl text-left gap-1 cursor-pointer",children:[s.jsxs("div",{className:"flex items-center gap-2 text-gray-900 group-hover:text-red-650 font-black text-xs uppercase tracking-wider transition-colors",children:[s.jsx(He.icon,{size:13}),s.jsx("span",{children:He.label})]}),s.jsx("span",{className:"text-[9.5px] text-gray-400 group-hover:text-gray-500 font-bold uppercase tracking-wider leading-none transition-colors",children:He.desc})]},He.id))})]}),s.jsxs("div",{className:"mt-10 pt-10 border-t border-gray-100 flex flex-col gap-4 relative z-10",children:[s.jsx("button",{onClick:async()=>{try{Xt("home"),await Ne.signOut(),pe.success("Successfully logged out!",{icon:"👋"})}catch(He){pe.error("Logout error: "+He.message)}},className:"w-full py-4 bg-gray-950 text-white font-black uppercase tracking-[0.2em] text-xs hover:bg-black transition-all cursor-pointer",children:"Logout"}),Lr&&s.jsxs("button",{onClick:()=>Ni(),className:"w-full py-4 bg-accent text-white font-black uppercase tracking-[0.2em] text-xs hover:bg-black transition-all shadow-xl shadow-blue-100 flex items-center justify-center gap-2 cursor-pointer",children:[s.jsx(pl,{size:16})," Admins Dashboard"]})]})]})});case"admin":return Lr?s.jsx(PS,{initialTab:kn}):null;default:return null}};return J?s.jsxs("div",{className:"fixed inset-0 z-[99999] bg-white flex flex-col min-h-screen",children:[s.jsx(r8,{}),s.jsxs("div",{className:"h-14 border-b border-gray-100 px-4 flex items-center justify-between bg-white backdrop-blur-md",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Logo",className:"h-7 w-7 rounded-full object-cover",referrerPolicy:"no-referrer"}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-[#000000]",children:"Campus Eye Media"})]}),s.jsx("div",{className:"h-2 w-2 rounded-full bg-red-650"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50/30 p-4 md:p-6 max-w-3xl mx-auto w-full space-y-6 pt-10",children:[s.jsxs("div",{className:"space-y-3 ",children:[s.jsx("div",{className:"h-3 bg-red-100 rounded w-20"}),s.jsx("div",{className:"h-8 bg-gray-200 rounded-lg w-[90%]"}),s.jsx("div",{className:"h-8 bg-gray-200 rounded-lg w-[60%]"})]}),s.jsxs("div",{className:"flex items-center gap-3 pt-2 pb-6 border-b border-gray-150",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-gray-200"}),s.jsxs("div",{className:"space-y-2 flex-1",children:[s.jsx("div",{className:"h-3 bg-gray-200 rounded w-28"}),s.jsx("div",{className:"h-2.5 bg-gray-150 rounded w-16"})]})]}),s.jsxs("div",{className:"space-y-4 pt-4",children:[s.jsx("div",{className:"h-56 bg-gray-150 rounded-2xl w-full"}),s.jsxs("div",{className:"space-y-2.5 pt-4",children:[s.jsx("div",{className:"h-3.5 bg-gray-100 rounded w-full"}),s.jsx("div",{className:"h-3.5 bg-gray-100 rounded w-[96%]"}),s.jsx("div",{className:"h-3.5 bg-gray-100 rounded w-[98%]"}),s.jsx("div",{className:"h-3.5 bg-gray-100 rounded w-[92%]"})]})]})]})]}):s.jsxs("div",{className:"min-h-screen bg-white pb-32 overflow-x-clip",children:[s.jsx(r8,{}),s.jsx(qMe,{isOpen:uo,onClose:()=>{hr(!1),mt(null)},currentUserId:((Fr=Ne.currentUser)==null?void 0:Fr.uid)||"",viewingUserId:Re||((Ra=Ne.currentUser)==null?void 0:Ra.uid)||"",initialTab:Nr,onUserProfileClick:ge=>{Ut(ge)}}),s.jsx(Mee,{isOpen:!!rt,onClose:()=>At(null),friend:rt,currentUserId:((Oo=Ne.currentUser)==null?void 0:Oo.uid)||"",currentUserProfile:{uid:((Qa=Ne.currentUser)==null?void 0:Qa.uid)||"",displayName:((Ro=Ne.currentUser)==null?void 0:Ro.displayName)||"Campus Peer",username:(((at=Ne.currentUser)==null?void 0:at.displayName)||"peer").toLowerCase().replace(/\s+/g,""),photoURL:((pr=Ne.currentUser)==null?void 0:pr.photoURL)||""}}),s.jsx(bye,{onSearch:Zs,isAdmin:Lr,onAdminClick:Ni,activeTab:me,setActiveTab:Xt,latestArticles:o,openAuth:()=>G(!0),customPagesList:ne,setSelectedCustomPage:Ce,selectedCustomPage:be,onScanClick:()=>hn(!0),onOpenChat:ge=>At(ge)}),s.jsx(vye,{activeTab:me,setActiveTab:Xt,onProfileClick:()=>Ne.currentUser?Xt("account"):G(!0),isAdmin:Lr,onAdminClick:Ni,openAuth:()=>G(!0),onMenuClick:()=>Ue(!0),onPodcastClick:()=>xe(!0),isPodcastModalOpen:se}),s.jsx(PMe,{}),s.jsx("main",{className:"news-container pt-16 sm:pt-20 md:pt-22 pb-20",children:s.jsx("div",{children:Nl()||s.jsx("div",{className:"text-center py-10",children:s.jsx(Sp,{variant:"magazine"})})})}),s.jsx(or,{children:yt&&s.jsxs("div",{className:"fixed inset-0 z-[2500] flex",children:[s.jsx(Zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>Ue(!1),className:"fixed inset-0 bg-black/40 backdrop-blur-sm"}),s.jsxs(Zt.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",damping:25,stiffness:220},className:"relative w-80 max-w-[85vw] bg-white h-full shadow-2xl overflow-y-auto flex flex-col pt-5 px-6 border-r border-gray-150 z-50 text-left",children:[s.jsxs("div",{className:"flex items-center justify-between pb-4 border-b border-gray-100 mb-6",children:[s.jsxs("div",{className:"flex items-center gap-1.5 font-black text-gray-950 text-[11px] tracking-wider",children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full bg-red-600 shrink-0"}),s.jsx("span",{children:"CITIZEN DASHBOARD"})]}),s.jsx("button",{onClick:()=>Ue(!1),className:"p-1.5 rounded-full hover:bg-gray-100 text-gray-400 hover:text-gray-950 transition-all cursor-pointer",children:s.jsx(er,{size:16})})]}),s.jsxs("div",{className:"flex-1 space-y-1.5",children:[[{id:"home",label:"Home",icon:eR},{id:"news",label:"Campus News",icon:Fh},{id:"discussions",label:"Public Debates",icon:bi},{id:"tickets",label:"Ticket Store",icon:Aa},{id:"podcasts",label:"Audio Podcasts",icon:uc},{id:"feedback",label:"Feedback Desk",icon:ea},{id:"account",label:"My Account",icon:nE}].map(ge=>s.jsxs("button",{onClick:()=>{ge.id==="tickets"?St(!0):ge.id==="podcasts"?xe(!0):(Xt(ge.id),Ce(null)),Ue(!1),X(null)},className:Fe("flex items-center gap-3 w-full px-4 py-2.5 rounded-xl transition-all font-bold text-xs uppercase tracking-wider text-left",me===ge.id&&!be?"bg-red-650 text-white shadow-md font-black":"text-gray-550 hover:bg-gray-50 hover:text-black"),children:[s.jsx(ge.icon,{size:14}),s.jsx("span",{children:ge.label})]},ge.id)),ne&&ne.length>0&&ne.map(ge=>{var Pe;const we=(Pe=ge.createdAt)!=null&&Pe.seconds?Date.now()-ge.createdAt.seconds*1e3<6048e5:!1;return s.jsxs("button",{onClick:()=>{Ce(ge),Ue(!1)},className:Fe("flex items-center gap-3 w-full px-4 py-2.5 rounded-xl transition-all font-bold text-xs uppercase tracking-wider text-left cursor-pointer",(be==null?void 0:be.id)===ge.id?"bg-red-650 text-white shadow-md font-black [&_svg]:!stroke-white [&_path]:!stroke-white [&_svg]:!fill-white [&_path]:!fill-white":"text-gray-550 hover:bg-gray-50 hover:text-black"),children:[ge.svgIcon?s.jsx("span",{className:"shrink-0 w-3.5 h-3.5 flex items-center justify-center text-current [&>svg]:w-full [&>svg]:h-full [&>svg]:shrink-0 transition-colors",dangerouslySetInnerHTML:{__html:ge.svgIcon.includes("${ge.svgIcon}`}}):s.jsx($a,{size:14,className:"text-red-550 shrink-0"}),s.jsx("span",{className:"truncate",children:ge.name}),we&&s.jsx("span",{className:"bg-red-500 text-white text-[7px] font-black uppercase px-1.5 py-0.5 rounded-full select-none shrink-0 ml-auto",children:"New"})]},ge.id)}),Lr&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100/80 space-y-1 select-none text-left",children:[s.jsxs("div",{className:"px-4 py-1.5 flex items-center gap-1.5",children:[s.jsx(pl,{size:12,className:"text-red-650"}),s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Editorial Board Control"})]}),[{subTab:"dashboard",label:"Dashboard Stats",desc:"Track traffic & revenue metrics",icon:Nu},{subTab:"article",label:"Write New Dispatch",desc:"Draft and deploy live articles",icon:kd},{subTab:"manage-articles",label:"Manage Store & Articles",desc:"Revise or withdraw stories",icon:Fh},{subTab:"advert",label:"Sponsor Advert Upload",desc:"Configure video or flyer ads",icon:Yp},{subTab:"manage-ads",label:"Manage Sponser Ads",desc:"Monitor active and draft campaigns",icon:Ou},{subTab:"flagged-comments",label:"Censor comments",desc:"Approve or delete flagged text",icon:ku},{subTab:"manage-tickets",label:"Configure Tickets",desc:"Publish event store entries",icon:Aa},{subTab:"ticket-purchases",label:"Passes & Ticket Sales",desc:"Verify passes & view sales records",icon:sie}].map(ge=>s.jsxs("button",{onClick:()=>{Ni(ge.subTab),Ue(!1)},className:"w-full flex items-start gap-3 px-4 py-2 hover:bg-red-50/30 rounded-lg transition-all text-left group border border-transparent hover:border-red-100/10 cursor-pointer",children:[s.jsx(ge.icon,{size:13,className:"text-gray-400 group-hover:text-red-650 transition-colors mt-0.5 shrink-0"}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-700 uppercase tracking-wider group-hover:text-red-650 transition-colors",children:ge.label}),s.jsx("span",{className:"text-[8.5px] text-gray-400 font-bold uppercase tracking-tight leading-none mt-0.5",children:ge.desc})]})]},ge.subTab))]})]}),s.jsx("div",{className:"pt-6 border-t border-gray-100 pb-8 mt-6",children:s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest text-center",children:"CAMPUS EYE V2.5 • MOBILE PLUG"})})]})]})}),me==="admin"&&Lr&&s.jsxs("div",{className:"fixed inset-0 z-[100] bg-white overflow-y-auto",children:[s.jsxs("div",{className:"w-full mx-auto px-6 py-4 flex justify-between items-center border-b border-gray-100 mb-4 select-none",children:[s.jsx("div",{className:"flex items-center gap-1.5 font-black text-[#9B2C2C] text-[10px] tracking-wider uppercase",title:"Editorial Desk Hub",children:s.jsx(pl,{size:16})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>{fr(!0),Xt("account")},className:"p-2 border border-gray-200 hover:border-black text-gray-650 hover:text-black rounded-lg cursor-pointer transition-colors",title:"Go to Account Controls",children:s.jsx(VS,{size:15,className:"shrink-0"})}),s.jsx("button",{onClick:()=>{Xt(gr),window.scrollTo({top:0,behavior:"smooth"})},className:"p-2 bg-black hover:bg-neutral-900 text-white rounded-lg cursor-pointer transition-colors",title:"Exit and Return to Feed",children:s.jsx(sre,{size:15,className:"shrink-0"})})]})]}),s.jsx(PS,{initialTab:kn})]}),s.jsx(or,{children:Ke&&s.jsx("div",{onClick:()=>{G(!1),window.onAuthPendingAction=void 0},className:"fixed inset-0 z-[3000] flex items-center justify-center p-4 bg-black/80 backdrop-blur-md overflow-y-auto cursor-pointer",children:s.jsx(Zt.div,{onClick:ge=>ge.stopPropagation(),initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:20},className:"w-full max-w-lg relative cursor-default my-auto",children:s.jsx(RV,{onAuthSuccess:async()=>{G(!1);const ge=localStorage.getItem("pending_follow_uid"),we=localStorage.getItem("pending_follow_name")||"this peer";if(ge&&Ne.currentUser)try{const $e=Qt(et(he,"follows"),Ar("followerId","==",Ne.currentUser.uid),Ar("followedId","==",ge));(await vn($e)).empty&&(await ur(et(he,"follows"),{followerId:Ne.currentUser.uid,followedId:ge,createdAt:En()}),pe.success(`Successfully followed ${we}!`),on(null))}catch($e){console.warn("Auto-follow pending action failed:",$e)}finally{localStorage.removeItem("pending_follow_uid"),localStorage.removeItem("pending_follow_name")}localStorage.getItem("just_signed_up")==="true"&&Et(!0),Xt("home")},onClose:()=>{G(!1),window.onAuthPendingAction=void 0},isAdmin:Lr,onAdminClick:Ni})})})}),s.jsxs("div",{className:"mt-20 border-t border-gray-100",children:[s.jsx(OMe,{articles:o}),s.jsx(RMe,{setActiveTab:Xt,adverts:Ln,articles:o,isAdmin:Lr})]}),s.jsx("button",{onClick:()=>{window.scrollTo({top:0,behavior:"smooth"})},className:"fixed bottom-3 left-4 z-40 w-8 h-8 bg-white/95 hover:bg-gray-50 rounded-full border border-gray-200 shadow-xs transition-all transform hover:scale-110 active:scale-95 flex items-center justify-center cursor-pointer outline-none select-none font-black",title:"Back to Top",children:s.jsx(Ipe,{size:11})}),s.jsx(or,{children:be&&s.jsx(XMe,{page:be,onClose:()=>Ce(null),openAuth:()=>G(!0)})}),s.jsx(or,{children:vr&&s.jsx("div",{className:"fixed inset-0 z-[11000] flex items-center justify-center p-0 bg-black/95 backdrop-blur-2xl",children:s.jsxs(Zt.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.25},className:"w-screen h-screen flex flex-col overflow-hidden relative",children:[s.jsxs("div",{className:"absolute top-0 left-0 right-0 z-50 bg-black/85 backdrop-blur-md px-6 py-3.5 flex items-center justify-between border-b border-white/10 text-white select-none",children:[s.jsx("div",{className:"flex items-center gap-3.5 text-left min-w-0 flex-1 pr-6",children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h3",{className:"font-serif font-black text-xs sm:text-sm uppercase tracking-wider truncate text-gray-100 m-0",children:["LIVE BROADCAST: ",Mt||"Campus Broadcast"]}),s.jsx("p",{className:"text-[9px] font-mono font-black uppercase text-gray-400 tracking-widest mt-0.5 hidden sm:block",children:"🔄 Recommendation: Landscape view is highly recommended for the best broadcast experience! Rotate your screen."}),s.jsx("p",{className:"text-[8px] font-mono font-black uppercase text-gray-400 tracking-widest mt-0.5 block sm:hidden",children:"🔄 RECOMMENDATION: ROTATE DEVICE FOR LANDSCAPE"})]})}),s.jsx("button",{onClick:()=>Ve(null),className:"p-2 sm:p-2.5 rounded-full bg-white/10 hover:bg-gray-850 text-white border border-white/15 hover:rotate-90 transition-all duration-300 shadow-lg cursor-pointer flex items-center justify-center shrink-0",title:"Close Live Broadcast",children:s.jsx(er,{size:15,strokeWidth:3})})]}),s.jsx("div",{className:"pointer-events-none absolute top-18 left-1/2 -translate-x-1/2 z-40 bg-gray-850/90 border border-gray-700 text-white px-4 py-2 rounded-xl text-[8.5px] font-black uppercase tracking-widest shadow-lg flex items-center gap-2 animate-bounce md:hidden select-none",children:s.jsx("span",{children:"🔄 rotate device to landscape for full view"})}),s.jsx("div",{className:"flex-1 w-full h-full bg-black",children:s.jsx("iframe",{src:(()=>{const ge=vr;if(ge)try{let we="";const Pe=ge.trim();if(Pe.includes("youtube.com/watch")){const $e=/[?&]v=([^&#]*)/,ct=Pe.match($e);ct&&ct[1]&&(we=ct[1])}else if(Pe.includes("youtu.be/")){const $e=Pe.split("youtu.be/");$e[1]&&(we=$e[1].split(/[?#&]/)[0])}else if(Pe.includes("youtube.com/live/")){const $e=Pe.split("youtube.com/live/");$e[1]&&(we=$e[1].split(/[?#&]/)[0])}else if(Pe.includes("/shorts/")){const $e=Pe.split("/shorts/");$e[1]&&(we=$e[1].split(/[?#&]/)[0])}else if(Pe.includes("youtube.com/embed/")){const $e=Pe.split("youtube.com/embed/");$e[1]&&(we=$e[1].split(/[?#&]/)[0])}else if(Pe.includes("youtube-nocookie.com/embed/")){const $e=Pe.split("youtube-nocookie.com/embed/");$e[1]&&(we=$e[1].split(/[?#&]/)[0])}return we?`https://www.youtube.com/embed/${we}?autoplay=1&mute=0&rel=0`:Pe}catch{return ge}})(),className:"w-full h-full border-0 bg-black pt-16 sm:pt-16",title:Mt||"Live Stream Grid",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen",allowFullScreen:!0,referrerPolicy:"strict-origin-when-cross-origin"})})]})})}),s.jsx(or,{children:Y&&s.jsx(V2e,{article:Y,onClose:()=>{const ge=new URL(window.location.href);ge.searchParams.delete("articles"),ge.searchParams.delete("id"),window.history.pushState({},"",ge.toString()),X(null),ye(!1)},isAdmin:Lr,allArticles:o,onArticleSelect:ge=>{const we=new URL(window.location.href),Pe=ge.title.toLowerCase().replace(/[^a-z0-9]/g,"-");we.searchParams.set("articles",Pe),we.searchParams.set("id",ge.id),window.history.pushState({articleId:ge.id},"",we.toString()),X(ge)},onCategorySelect:ge=>{Xt(ge),X(null),ye(!1);const we=new URL(window.location.href);we.searchParams.delete("articles"),we.searchParams.delete("id"),we.searchParams.set("tab",ge),window.history.pushState({},"",we.toString()),window.scrollTo({top:0,behavior:"auto"})}})}),s.jsx(or,{children:se&&s.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-md z-[5000] flex items-center justify-center p-4",children:s.jsxs(Zt.div,{initial:{scale:.95,opacity:0,y:30},animate:{scale:1,opacity:1,y:0},exit:{scale:.95,opacity:0,y:30},transition:{type:"spring",damping:25,stiffness:350},className:"bg-white rounded-3xl w-full max-w-6xl md:max-w-7xl max-h-[92vh] flex flex-col shadow-2xl overflow-hidden border border-gray-150",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100 bg-gray-50/50",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-emerald-50 text-emerald-600 flex items-center justify-center shrink-0",children:s.jsx(D2,{size:18})}),s.jsxs("div",{className:"text-left",children:[s.jsx("h3",{className:"text-xs font-black text-gray-950 uppercase tracking-tight",children:"Campus Audio Newsroom & Podcasts"}),s.jsx("p",{className:"text-[8px] text-gray-400 font-bold uppercase tracking-wider",children:"Independent Campus Dispatches • Wide Broadcast Hub"})]})]}),s.jsx("button",{onClick:()=>xe(!1),className:"p-1.5 bg-gray-100 hover:bg-gray-200 text-gray-600 rounded-full transition-colors cursor-pointer flex items-center justify-center",title:"Close Podcasts",children:s.jsx(er,{size:13})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4 bg-white text-left",children:s.jsx(DV,{})})]})})}),s.jsx(MMe,{}),re&&s.jsx(xP,{podcast:re,onClose:()=>Me(null)}),s.jsx(or,{children:Vt&&s.jsxs("div",{className:"fixed inset-0 z-[3000] flex items-center justify-center p-2 sm:p-4",children:[s.jsx(Zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>St(!1),className:"fixed inset-0 bg-black/60 backdrop-blur-xl"}),s.jsxs(Zt.div,{initial:{scale:.95,y:15,opacity:0},animate:{scale:1,y:0,opacity:1},exit:{scale:.95,y:15,opacity:0},transition:{type:"spring",damping:30,stiffness:350},className:"relative w-full h-[98%] max-w-7xl bg-white rounded-[2.5rem] shadow-2xl flex flex-col overflow-hidden border border-gray-150 z-10",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100 bg-gray-50/50 shrink-0 text-left",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400 shrink-0"}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-450 font-mono",children:"CAMPUS PASSES & EVENTS"})]}),s.jsx("button",{onClick:()=>St(!1),className:"p-2 rounded-full hover:bg-gray-150 text-gray-500 hover:text-black transition-all cursor-pointer border border-transparent hover:border-gray-200",title:"Close Ticket Store",children:s.jsx(er,{size:18})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 bg-white",children:s.jsx(TMe,{})})]})]})}),s.jsx(or,{children:(tn||ut||Nt)&&s.jsx("div",{className:"fixed inset-0 z-[11000] flex items-center justify-center p-4 bg-black/85 backdrop-blur-md",children:s.jsxs(Zt.div,{initial:{scale:.95,opacity:0,y:15},animate:{scale:1,y:0,opacity:1},exit:{scale:.95,y:15,opacity:0},className:"bg-white rounded-[2.5rem] border border-gray-150 p-8 w-full max-w-md shadow-2xl relative text-center",children:[s.jsx("button",{onClick:()=>{Pt(null),Kt(null);const ge=new URL(window.location.href);ge.searchParams.delete("scan"),window.history.pushState({},"",ge.toString())},className:"absolute top-6 right-6 p-2 bg-gray-50 text-gray-900 hover:bg-gray-100 rounded-full transition-all cursor-pointer border border-transparent hover:border-gray-200 flex items-center justify-center",title:"Close Scanner",children:s.jsx(er,{size:15,className:"stroke-[2.5]"})}),s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("div",{className:"w-12 h-12 bg-red-50 text-red-600 rounded-full flex items-center justify-center mb-4",children:s.jsx(Aa,{size:24})}),s.jsx("h3",{className:"text-xs font-black text-red-650 uppercase tracking-widest font-mono mb-1",children:"Gate Check-In Protocol"}),s.jsx("h2",{className:"text-xl font-serif font-black text-gray-950 tracking-tight leading-tight mb-5 uppercase",children:"Verification Console"}),ut?s.jsxs("div",{className:"py-8 flex flex-col items-center gap-3",children:[s.jsx(Er,{className:"animate-spin text-red-600",size:24}),s.jsx("span",{className:"text-[10px] uppercase font-black text-gray-400",children:"Loading Pass Records..."})]}):Nt?s.jsxs("div",{className:"w-full space-y-6",children:[s.jsxs("div",{className:"bg-gray-50 p-5 rounded-3xl border border-gray-100 text-left space-y-3",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-wider block",children:"Event Pass Name"}),s.jsx("span",{className:"text-sm font-black text-gray-950 uppercase tracking-tight",children:Nt.ticketTitle})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-wider block",children:"Attendee"}),s.jsx("span",{className:"text-xs font-bold text-gray-800",children:Nt.userName})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-wider block",children:"Order ID"}),s.jsxs("span",{className:"text-xs font-mono font-black text-gray-800 uppercase",children:["#",Nt.id.slice(-6).toUpperCase()]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-1.5 border-t border-gray-100/70",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-wider block",children:"Guest Count"}),s.jsxs("span",{className:"text-xs font-bold text-gray-800",children:[Nt.quantity," Pax"]})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-wider block",children:"Admission Status"}),Nt.taken||Nt.used?s.jsx("span",{className:"text-[9px] font-black text-green-600 uppercase bg-green-50 border border-green-200 px-1.5 py-0.5 rounded inline-block mt-0.5",children:"✔️ Used / Ticked"}):s.jsx("span",{className:"text-[9px] font-black text-red-655 uppercase bg-red-50 border border-red-200 px-1.5 py-0.5 rounded inline-block mt-0.5",children:"Active / Unused"})]})]})]}),Lr?s.jsxs("div",{className:"bg-red-50/50 p-5 rounded-3xl border border-red-100/50 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3 justify-center select-none",children:[s.jsx("input",{type:"checkbox",id:"scan-gate-taken",checked:!!Nt.taken||!!Nt.used,onChange:async()=>{const ge=!(Nt.taken||Nt.used);try{await Cn(Je(he,"purchases",Nt.id),{taken:ge,used:ge}),Kt(we=>we?{...we,taken:ge,used:ge}:null),ge?(await ur(et(he,"notifications"),{userId:Nt.userId,title:`🎟️ Entrance Gate Ticked: ${Nt.ticketTitle}`,message:`Your entry pass (ID #${Nt.id.slice(-6).toUpperCase()}) has been officially scanned and ticked as used at the gate. Enjoy the event!`,used:!1,createdAt:new Date,type:"entrance_checkin",code:Nt.id}),pe.success("Check-in complete! Pass marked as used.",{icon:"🎟️"})):pe.success("Gate admission check reverted to active.")}catch(we){console.error("Gate scanning error update:",we),pe.error("Fail to update: "+we.message)}},className:"w-5 h-5 rounded border-gray-300 text-red-650 focus:ring-red-550 cursor-pointer accent-red-650"}),s.jsx("label",{htmlFor:"scan-gate-taken",className:"text-xs font-black uppercase tracking-wider text-gray-950 cursor-pointer select-none",children:Nt.taken||Nt.used?"Used (Ticket Ticked)":"Mark Ticket Used"})]}),s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase leading-normal",children:"Ticking this checkbox invalidates this pass QR code for future entries, and dispatches a notification to the user's inbox in real-time."})]}):s.jsxs("div",{className:"bg-green-50/50 p-5 rounded-3xl border border-green-100/70 space-y-3",children:[s.jsx("span",{className:"text-[11px] font-black uppercase tracking-wider text-green-700 flex items-center justify-center gap-1.5 select-none font-mono",children:"🎉 Secure Entry Pass Verified"}),s.jsxs("div",{className:"space-y-1.5 text-center",children:[s.jsx("p",{className:"text-[10px] text-gray-650 font-bold uppercase leading-normal",children:Nt.taken||Nt.used?s.jsx("span",{className:"text-green-650 font-black",children:"✔️ Ticked & Used. You are checked in."}):s.jsx("span",{className:"text-gray-500 font-extrabold",children:"Active and ready. Please show this to the gate attendant."})}),s.jsx("p",{className:"text-[9px] text-gray-400 font-bold uppercase leading-none mt-1 font-mono",children:"Only administrators can check-in or tick this pass."})]})]}),s.jsx("button",{onClick:()=>{Pt(null),Kt(null);const ge=new URL(window.location.href);ge.searchParams.delete("scan"),window.history.pushState({},"",ge.toString())},className:"w-full py-4.5 bg-gray-950 text-white hover:bg-red-650 rounded-2xl text-[10px] font-black uppercase tracking-widest transition-all shadow-md cursor-pointer outline-none select-none",children:"Process Completed"})]}):s.jsx("div",{className:"py-6 space-y-4",children:s.jsxs("span",{className:"text-xs font-bold text-gray-500",children:["Retrieving pass ticket ID #",tn==null?void 0:tn.slice(-6).toUpperCase(),"..."]})})]})]})})}),s.jsx(N9e,{isOpen:Dt,onClose:()=>hn(!1),onScanSuccess:ge=>{Pt(ge)}}),s.jsx(or,{children:$n&&s.jsx("div",{className:"fixed inset-0 z-[100000] flex items-center justify-center p-4 bg-black/75 backdrop-blur-md",children:s.jsxs(Zt.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-white border border-gray-150 rounded-[2.5rem] p-8 shadow-2xl max-w-md w-full relative overflow-hidden",children:[s.jsx("div",{className:"absolute top-0 left-0 w-full h-[3px] bg-red-650"}),s.jsxs("div",{className:"space-y-1.5 text-center mb-6",children:[s.jsx("div",{className:"w-10 h-10 bg-black text-white rounded-2xl flex items-center justify-center font-black text-sm mx-auto shadow-sm tracking-tighter mt-2",children:"★"}),s.jsx("h3",{className:"font-serif font-black text-lg tracking-tight text-neutral-900 uppercase",children:"Welcome! Tune Your Dispatch"}),s.jsx("p",{className:"text-[10px] text-neutral-500 font-semibold tracking-normal leading-relaxed max-w-xs mx-auto",children:"Pick up to 3 core categories below so we can curate your feed and learn your preferences live!"})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:[{id:"news",label:"📰 News",category:"News"},{id:"sports",label:"⚽ Sports",category:"Sports"},{id:"music",label:"🎵 Music",category:"Music"},{id:"entertainment",label:"🎭 Entertainment",category:"Entertainment"},{id:"innovation",label:"💡 Innovation",category:"Innovation"},{id:"culture",label:"🏛️ Culture",category:"Culture"},{id:"business",label:"💼 Business",category:"Business"}].map(ge=>{const we=je.includes(ge.category);return s.jsxs("button",{onClick:()=>{if(we)ln(Pe=>Pe.filter($e=>$e!==ge.category));else{if(je.length>=3){pe.error("Please pick up to just 3 interests!",{id:"interest-limit"});return}ln(Pe=>[...Pe,ge.category])}},className:`p-3 rounded-2xl border text-left font-sans text-xs font-semibold transition-all duration-200 cursor-pointer flex flex-col justify-between h-[4.5rem] select-none ${we?"border-black bg-black text-white shadow-sm scale-[1.02]":"border-gray-205 bg-white text-gray-700 hover:border-gray-350 hover:bg-gray-50/50"}`,children:[s.jsx("span",{className:"text-base leading-none",children:ge.label.split(" ")[0]}),s.jsx("span",{className:"font-sans uppercase text-[8.5px] font-black tracking-wider leading-none",children:ge.label.split(" ").slice(1).join(" ")})]},ge.id)})}),s.jsxs("div",{className:"pt-6 text-center",children:[s.jsxs("span",{className:"text-[8.5px] font-sans font-black text-gray-400 uppercase tracking-widest block mb-3.5",children:[je.length," of 3 Selected"]}),s.jsx("button",{onClick:async()=>{if(je.length===0){pe.error("Please select at least 1 interest to customize your feed!");return}try{const ge=localStorage.getItem("campus_eye_personalization_v1"),we=ge?JSON.parse(ge):{categories:{}};if(we.interests=[...je],we.categories||(we.categories={}),je.forEach(Pe=>{we.categories[Pe]=(we.categories[Pe]||0)+150}),localStorage.setItem("campus_eye_personalization_v1",JSON.stringify(we)),localStorage.removeItem("just_signed_up"),Ne.currentUser){const Pe=Je(he,"users",Ne.currentUser.uid);await Rr(Pe,{interests:[...je]},{merge:!0})}yn(!0),setTimeout(()=>{yn(!1),Et(!1),pe.success("Newsroom personalized live! Welcome.")},1200)}catch{Et(!1)}},className:"w-full py-4 bg-red-650 hover:bg-black transition-all cursor-pointer font-black text-xs uppercase tracking-widest text-white rounded-xl",children:bt?"BUILDING YOUR FEED...":"START EXPLORING"})]})]})})}),s.jsx(WMe,{isOpen:!!qn,onClose:()=>mn(null),userId:qn,currentUserId:(Jr=Ne.currentUser)==null?void 0:Jr.uid}),s.jsx(KMe,{}),s.jsx(YMe,{}),s.jsx(DMe,{})]})}ane.createRoot(document.getElementById("root")).render(s.jsx(I.StrictMode,{children:s.jsx(eF,{children:s.jsx(_9e,{})})}));