PageSourceSearch

https://traveluganda.co.ug/assets/index-BrZNIwJA.js

js traveluganda.co.ug collected 2026-10-02 13:31:43 UTC 1,849,433 bytes, 4,569 lines download raw bytes

vendor: 7,774 bytes, lines 1-17
1var oR=Object.defineProperty;var lR=(n,e,t)=>e in n?oR(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Ie=(n,e,t)=>lR(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const c of a.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function t(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=t(s);fetch(s.href,a)}})();function HN(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var EB={exports:{}},Fd={};/**
2 * @license React
3 * react-jsx-runtime.production.js
4 *
5 * Copyright (c) Meta Platforms, Inc. and affiliates.
6 *
7 * This source code is licensed under the MIT license found in the
8 * LICENSE file in the root directory of this source tree.
9 */var oE;function cR(){if(oE)return Fd;oE=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:n,type:r,key:c,ref:s!==void 0?s:null,props:a}}return Fd.Fragment=e,Fd.jsx=t,Fd.jsxs=t,Fd}var lE;function uR(){return lE||(lE=1,EB.exports=cR()),EB.exports}var o=uR(),_B={exports:{}},Bt={};/**
10 * @license React
11 * react.production.js
12 *
13 * Copyright (c) Meta Platforms, Inc. and affiliates.
14 *
15 * This source code is licensed under the MIT license found in the
16 * LICENSE file in the root directory of this source tree.
17 */var cE;function dR(){if(cE)return Bt;cE=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),b=Symbol.iterator;function w(K){return K===null||typeof K!="object"?null:(K=b&&K[b]||K["@@iterator"],typeof K=="function"?K:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,S={};function I(K,fe,Se){this.props=K,this.context=fe,this.refs=S,this.updater=Se||E}I.prototype.isReactComponent={},I.prototype.setState=function(K,fe){if(typeof K!="object"&&typeof K!="function"&&K!=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,K,fe,"setState")},I.prototype.forceUpdate=function(K){this.updater.enqueueForceUpdate(this,K,"forceUpdate")};function O(){}O.prototype=I.prototype;function F(K,fe,Se){this.props=K,this.context=fe,this.refs=S,this.updater=Se||E}var J=F.prototype=new O;J.constructor=F,N(J,I.prototype),J.isPureReactComponent=!0;var z=Array.isArray;function U(){}var D={H:null,A:null,T:null,S:null},k=Object.prototype.hasOwnProperty;function _(K,fe,Se){var Ae=Se.ref;return{$$typeof:n,type:K,key:fe,ref:Ae!==void 0?Ae:null,props:Se}}function M(K,fe){return _(K.type,fe,K.props)}function j(K){return typeof K=="object"&&K!==null&&K.$$typeof===n}function H(K){var fe={"=":"=0",":":"=2"};return"$"+K.replace(/[=:]/g,function(Se){return fe[Se]})}var L=/\/+/g;function ee(K,fe){return typeof K=="object"&&K!==null&&K.key!=null?H(""+K.key):fe.toString(36)}function ne(K){switch(K.status){case"fulfilled":return K.value;case"rejected":throw K.reason;default:switch(typeof K.status=="string"?K.then(U,U):(K.status="pending",K.then(function(fe){K.status==="pending"&&(K.status="fulfilled",K.value=fe)},function(fe){K.status==="pending"&&(K.status="rejected",K.reason=fe)})),K.status){case"fulfilled":return K.value;case"rejected":throw K.reason}}throw K}function G(K,fe,Se,Ae,ze){var lt=typeof K;(lt==="undefined"||lt==="boolean")&&(K=null);var dt=!1;if(K===null)dt=!0;else switch(lt){case"bigint":case"string":case"number":dt=!0;break;case"object":switch(K.$$typeof){case n:case e:dt=!0;break;case p:return dt=K._init,G(dt(K._payload),fe,Se,Ae,ze)}}if(dt)return ze=ze(K),dt=Ae===""?"."+ee(K,0):Ae,z(ze)?(Se="",dt!=null&&(Se=dt.replace(L,"$&/")+"/"),G(ze,fe,Se,"",function(Mr){return Mr})):ze!=null&&(j(ze)&&(ze=M(ze,Se+(ze.key==null||K&&K.key===ze.key?"":(""+ze.key).replace(L,"$&/")+"/")+dt)),fe.push(ze)),1;dt=0;var Wt=Ae===""?".":Ae+":";if(z(K))for(var Ht=0;Ht<K.length;Ht++)Ae=K[Ht],lt=Wt+ee(Ae,Ht),dt+=G(Ae,fe,Se,lt,ze);else if(Ht=w(K),typeof Ht=="function")for(K=Ht.call(K),Ht=0;!(Ae=K.next()).done;)Ae=Ae.value,lt=Wt+ee(Ae,Ht++),dt+=G(Ae,fe,Se,lt,ze);else if(lt==="object"){if(typeof K.then=="function")return G(ne(K),fe,Se,Ae,ze);throw fe=String(K),Error("Objects are not valid as a React child (found: "+(fe==="[object Object]"?"object with keys {"+Object.keys(K).join(", ")+"}":fe)+"). If you meant to render a collection of children, use an array instead.")}return dt}function W(K,fe,Se){if(K==null)return K;var Ae=[],ze=0;return G(K,Ae,"","",function(lt){return fe.call(Se,lt,ze++)}),Ae}function X(K){if(K._status===-1){var fe=K._result;fe=fe(),fe.then(function(Se){(K._status===0||K._status===-1)&&(K._status=1,K._result=Se)},function(Se){(K._status===0||K._status===-1)&&(K._status=2,K._result=Se)}),K._status===-1&&(K._status=0,K._result=fe)}if(K._status===1)return K._result.default;throw K._result}var ae=typeof reportError=="function"?reportError:function(K){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var fe=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof K=="object"&&K!==null&&typeof K.message=="string"?String(K.message):String(K),error:K});if(!window.dispatchEvent(fe))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",K);return}console.error(K)},Te={map:W,forEach:function(K,fe,Se){W(K,function(){fe.apply(this,arguments)},Se)},count:function(K){var fe=0;return W(K,function(){fe++}),fe},toArray:function(K){return W(K,function(fe){return fe})||[]},only:function(K){if(!j(K))throw Error("React.Children.only expected to receive a single React element child.");return K}};return Bt.Activity=y,Bt.Children=Te,Bt.Component=I,Bt.Fragment=t,Bt.Profiler=s,Bt.PureComponent=F,Bt.StrictMode=r,Bt.Suspense=h,Bt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=D,Bt.__COMPILER_RUNTIME={__proto__:null,c:function(K){return D.H.useMemoCache(K)}},Bt.cache=function(K){return function(){return K.apply(null,arguments)}},Bt.cacheSignal=function(){return null},Bt.cloneElement=function(K,fe,Se){if(K==null)throw Error("The argument must be a React element, but you passed "+K+".");var Ae=N({},K.props),ze=K.key;if(fe!=null)for(lt in fe.key!==void 0&&(ze=""+fe.key),fe)!k.call(fe,lt)||lt==="key"||lt==="__self"||lt==="__source"||lt==="ref"&&fe.ref===void 0||(Ae[lt]=fe[lt]);var lt=arguments.length-2;if(lt===1)Ae.children=Se;else if(1<lt){for(var dt=Array(lt),Wt=0;Wt<lt;Wt++)dt[Wt]=arguments[Wt+2];Ae.children=dt}return _(K.type,ze,Ae)},Bt.createContext=function(K){return K={$$typeof:c,_currentValue:K,_currentValue2:K,_threadCount:0,Provider:null,Consumer:null},K.Provider=K,K.Consumer={$$typeof:a,_context:K},K},Bt.createElement=function(K,fe,Se){var Ae,ze={},lt=null;if(fe!=null)for(Ae in fe.key!==void 0&&(lt=""+fe.key),fe)k.call(fe,Ae)&&Ae!=="
vendor: 10,845 bytes, lines 17-41
17key"&&Ae!=="__self"&&Ae!=="__source"&&(ze[Ae]=fe[Ae]);var dt=arguments.length-2;if(dt===1)ze.children=Se;else if(1<dt){for(var Wt=Array(dt),Ht=0;Ht<dt;Ht++)Wt[Ht]=arguments[Ht+2];ze.children=Wt}if(K&&K.defaultProps)for(Ae in dt=K.defaultProps,dt)ze[Ae]===void 0&&(ze[Ae]=dt[Ae]);return _(K,lt,ze)},Bt.createRef=function(){return{current:null}},Bt.forwardRef=function(K){return{$$typeof:u,render:K}},Bt.isValidElement=j,Bt.lazy=function(K){return{$$typeof:p,_payload:{_status:-1,_result:K},_init:X}},Bt.memo=function(K,fe){return{$$typeof:f,type:K,compare:fe===void 0?null:fe}},Bt.startTransition=function(K){var fe=D.T,Se={};D.T=Se;try{var Ae=K(),ze=D.S;ze!==null&&ze(Se,Ae),typeof Ae=="object"&&Ae!==null&&typeof Ae.then=="function"&&Ae.then(U,ae)}catch(lt){ae(lt)}finally{fe!==null&&Se.types!==null&&(fe.types=Se.types),D.T=fe}},Bt.unstable_useCacheRefresh=function(){return D.H.useCacheRefresh()},Bt.use=function(K){return D.H.use(K)},Bt.useActionState=function(K,fe,Se){return D.H.useActionState(K,fe,Se)},Bt.useCallback=function(K,fe){return D.H.useCallback(K,fe)},Bt.useContext=function(K){return D.H.useContext(K)},Bt.useDebugValue=function(){},Bt.useDeferredValue=function(K,fe){return D.H.useDeferredValue(K,fe)},Bt.useEffect=function(K,fe){return D.H.useEffect(K,fe)},Bt.useEffectEvent=function(K){return D.H.useEffectEvent(K)},Bt.useId=function(){return D.H.useId()},Bt.useImperativeHandle=function(K,fe,Se){return D.H.useImperativeHandle(K,fe,Se)},Bt.useInsertionEffect=function(K,fe){return D.H.useInsertionEffect(K,fe)},Bt.useLayoutEffect=function(K,fe){return D.H.useLayoutEffect(K,fe)},Bt.useMemo=function(K,fe){return D.H.useMemo(K,fe)},Bt.useOptimistic=function(K,fe){return D.H.useOptimistic(K,fe)},Bt.useReducer=function(K,fe,Se){return D.H.useReducer(K,fe,Se)},Bt.useRef=function(K){return D.H.useRef(K)},Bt.useState=function(K){return D.H.useState(K)},Bt.useSyncExternalStore=function(K,fe,Se){return D.H.useSyncExternalStore(K,fe,Se)},Bt.useTransition=function(){return D.H.useTransition()},Bt.version="19.2.8",Bt}var uE;function ix(){return uE||(uE=1,_B.exports=dR()),_B.exports}var R=ix();const cc=HN(R);var TB={exports:{}},Ud={},kB={exports:{}},NB={};/**
18 * @license React
19 * scheduler.production.js
20 *
21 * Copyright (c) Meta Platforms, Inc. and affiliates.
22 *
23 * This source code is licensed under the MIT license found in the
24 * LICENSE file in the root directory of this source tree.
25 */var dE;function hR(){return dE||(dE=1,(function(n){function e(G,W){var X=G.length;G.push(W);e:for(;0<X;){var ae=X-1>>>1,Te=G[ae];if(0<s(Te,W))G[ae]=W,G[X]=Te,X=ae;else break e}}function t(G){return G.length===0?null:G[0]}function r(G){if(G.length===0)return null;var W=G[0],X=G.pop();if(X!==W){G[0]=X;e:for(var ae=0,Te=G.length,K=Te>>>1;ae<K;){var fe=2*(ae+1)-1,Se=G[fe],Ae=fe+1,ze=G[Ae];if(0>s(Se,X))Ae<Te&&0>s(ze,Se)?(G[ae]=ze,G[Ae]=X,ae=Ae):(G[ae]=Se,G[fe]=X,ae=fe);else if(Ae<Te&&0>s(ze,X))G[ae]=ze,G[Ae]=X,ae=Ae;else break e}}return W}function s(G,W){var X=G.sortIndex-W.sortIndex;return X!==0?X:G.id-W.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;n.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();n.unstable_now=function(){return c.now()-u}}var h=[],f=[],p=1,y=null,b=3,w=!1,E=!1,N=!1,S=!1,I=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,F=typeof setImmediate<"u"?setImmediate:null;function J(G){for(var W=t(f);W!==null;){if(W.callback===null)r(f);else if(W.startTime<=G)r(f),W.sortIndex=W.expirationTime,e(h,W);else break;W=t(f)}}function z(G){if(N=!1,J(G),!E)if(t(h)!==null)E=!0,U||(U=!0,H());else{var W=t(f);W!==null&&ne(z,W.startTime-G)}}var U=!1,D=-1,k=5,_=-1;function M(){return S?!0:!(n.unstable_now()-_<k)}function j(){if(S=!1,U){var G=n.unstable_now();_=G;var W=!0;try{e:{E=!1,N&&(N=!1,O(D),D=-1),w=!0;var X=b;try{t:{for(J(G),y=t(h);y!==null&&!(y.expirationTime>G&&M());){var ae=y.callback;if(typeof ae=="function"){y.callback=null,b=y.priorityLevel;var Te=ae(y.expirationTime<=G);if(G=n.unstable_now(),typeof Te=="function"){y.callback=Te,J(G),W=!0;break t}y===t(h)&&r(h),J(G)}else r(h);y=t(h)}if(y!==null)W=!0;else{var K=t(f);K!==null&&ne(z,K.startTime-G),W=!1}}break e}finally{y=null,b=X,w=!1}W=void 0}}finally{W?H():U=!1}}}var H;if(typeof F=="function")H=function(){F(j)};else if(typeof MessageChannel<"u"){var L=new MessageChannel,ee=L.port2;L.port1.onmessage=j,H=function(){ee.postMessage(null)}}else H=function(){I(j,0)};function ne(G,W){D=I(function(){G(n.unstable_now())},W)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(G){G.callback=null},n.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):k=0<G?Math.floor(1e3/G):5},n.unstable_getCurrentPriorityLevel=function(){return b},n.unstable_next=function(G){switch(b){case 1:case 2:case 3:var W=3;break;default:W=b}var X=b;b=W;try{return G()}finally{b=X}},n.unstable_requestPaint=function(){S=!0},n.unstable_runWithPriority=function(G,W){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var X=b;b=G;try{return W()}finally{b=X}},n.unstable_scheduleCallback=function(G,W,X){var ae=n.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?ae+X:ae):X=ae,G){case 1:var Te=-1;break;case 2:Te=250;break;case 5:Te=1073741823;break;case 4:Te=1e4;break;default:Te=5e3}return Te=X+Te,G={id:p++,callback:W,priorityLevel:G,startTime:X,expirationTime:Te,sortIndex:-1},X>ae?(G.sortIndex=X,e(f,G),t(h)===null&&G===t(f)&&(N?(O(D),D=-1):N=!0,ne(z,X-ae))):(G.sortIndex=Te,e(h,G),E||w||(E=!0,U||(U=!0,H()))),G},n.unstable_shouldYield=M,n.unstable_wrapCallback=function(G){var W=b;return function(){var X=b;b=W;try{return G.apply(this,arguments)}finally{b=X}}}})(NB)),NB}var hE;function fR(){return hE||(hE=1,kB.exports=hR()),kB.exports}var SB={exports:{}},Yr={};/**
26 * @license React
27 * react-dom.production.js
28 *
29 * Copyright (c) Meta Platforms, Inc. and affiliates.
30 *
31 * This source code is licensed under the MIT license found in the
32 * LICENSE file in the root directory of this source tree.
33 */var fE;function mR(){if(fE)return Yr;fE=1;var n=ix();function e(h){var f="https://react.dev/errors/"+h;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)f+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+h+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function t(){}var r={d:{f:t,r:function(){throw Error(e(522))},D:t,C:t,L:t,m:t,X:t,S:t,M:t},p:0,findDOMNode:null},s=Symbol.for("react.portal");function a(h,f,p){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:y==null?null:""+y,children:h,containerInfo:f,implementation:p}}var c=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(h,f){if(h==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return Yr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Yr.createPortal=function(h,f){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(e(299));return a(h,f,null,p)},Yr.flushSync=function(h){var f=c.T,p=r.p;try{if(c.T=null,r.p=2,h)return h()}finally{c.T=f,r.p=p,r.d.f()}},Yr.preconnect=function(h,f){typeof h=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,r.d.C(h,f))},Yr.prefetchDNS=function(h){typeof h=="string"&&r.d.D(h)},Yr.preinit=function(h,f){if(typeof h=="string"&&f&&typeof f.as=="string"){var p=f.as,y=u(p,f.crossOrigin),b=typeof f.integrity=="string"?f.integrity:void 0,w=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;p==="style"?r.d.S(h,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:y,integrity:b,fetchPriority:w}):p==="script"&&r.d.X(h,{crossOrigin:y,integrity:b,fetchPriority:w,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},Yr.preinitModule=function(h,f){if(typeof h=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var p=u(f.as,f.crossOrigin);r.d.M(h,{crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&r.d.M(h)},Yr.preload=function(h,f){if(typeof h=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var p=f.as,y=u(p,f.crossOrigin);r.d.L(h,p,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},Yr.preloadModule=function(h,f){if(typeof h=="string")if(f){var p=u(f.as,f.crossOrigin);r.d.m(h,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else r.d.m(h)},Yr.requestFormReset=function(h){r.d.r(h)},Yr.unstable_batchedUpdates=function(h,f){return h(f)},Yr.useFormState=function(h,f,p){return c.H.useFormState(h,f,p)},Yr.useFormStatus=function(){return c.H.useHostTransitionStatus()},Yr.version="19.2.8",Yr}var mE;function gR(){if(mE)return SB.exports;mE=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),SB.exports=mR(),SB.exports}/**
34 * @license React
35 * react-dom-client.production.js
36 *
37 * Copyright (c) Meta Platforms, Inc. and affiliates.
38 *
39 * This source code is licensed under the MIT license found in the
40 * LICENSE file in the root directory of this source tree.
41 */var gE;function pR(){if(gE)return Ud;gE=1;var n=fR(),e=ix(),t=gR();function r(i){var l="https://react.dev/errors/"+i;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)l+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+i+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function a(i){var l=i,d=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,(l.flags&4098)!==0&&(d=l.return),i=l.return;while(i)}return l.tag===3?d:null}
vendor: 14,083 bytes, lines 41-48
41function c(i){if(i.tag===13){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function u(i){if(i.tag===31){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function h(i){if(a(i)!==i)throw Error(r(188))}function f(i){var l=i.alternate;if(!l){if(l=a(i),l===null)throw Error(r(188));return l!==i?null:i}for(var d=i,m=l;;){var C=d.return;if(C===null)break;var v=C.alternate;if(v===null){if(m=C.return,m!==null){d=m;continue}break}if(C.child===v.child){for(v=C.child;v;){if(v===d)return h(C),i;if(v===m)return h(C),l;v=v.sibling}throw Error(r(188))}if(d.return!==m.return)d=C,m=v;else{for(var A=!1,V=C.child;V;){if(V===d){A=!0,d=C,m=v;break}if(V===m){A=!0,m=C,d=v;break}V=V.sibling}if(!A){for(V=v.child;V;){if(V===d){A=!0,d=v,m=C;break}if(V===m){A=!0,m=v,d=C;break}V=V.sibling}if(!A)throw Error(r(189))}}if(d.alternate!==m)throw Error(r(190))}if(d.tag!==3)throw Error(r(188));return d.stateNode.current===d?i:l}function p(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(l=p(i),l!==null)return l;i=i.sibling}return null}var y=Object.assign,b=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),F=Symbol.for("react.context"),J=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),j=Symbol.iterator;function H(i){return i===null||typeof i!="object"?null:(i=j&&i[j]||i["@@iterator"],typeof i=="function"?i:null)}var L=Symbol.for("react.client.reference");function ee(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===L?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case N:return"Fragment";case I:return"Profiler";case S:return"StrictMode";case z:return"Suspense";case U:return"SuspenseList";case _:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case E:return"Portal";case F:return i.displayName||"Context";case O:return(i._context.displayName||"Context")+".Consumer";case J:var l=i.render;return i=i.displayName,i||(i=l.displayName||l.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case D:return l=i.displayName||null,l!==null?l:ee(i.type)||"Memo";case k:l=i._payload,i=i._init;try{return ee(i(l))}catch{}}return null}var ne=Array.isArray,G=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},ae=[],Te=-1;function K(i){return{current:i}}function fe(i){0>Te||(i.current=ae[Te],ae[Te]=null,Te--)}function Se(i,l){Te++,ae[Te]=i.current,i.current=l}var Ae=K(null),ze=K(null),lt=K(null),dt=K(null);function Wt(i,l){switch(Se(lt,l),Se(ze,i),Se(Ae,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?Dw(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=Dw(l),i=Aw(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}fe(Ae),Se(Ae,i)}function Ht(){fe(Ae),fe(ze),fe(lt)}function Mr(i){i.memoizedState!==null&&Se(dt,i);var l=Ae.current,d=Aw(l,i.type);l!==d&&(Se(ze,i),Se(Ae,d))}function br(i){ze.current===i&&(fe(Ae),fe(ze)),dt.current===i&&(fe(dt),Md._currentValue=X)}var Lr,gt;function Ye(i){if(Lr===void 0)try{throw Error()}catch(d){var l=d.stack.trim().match(/\n( *(at )?)/);Lr=l&&l[1]||"",gt=-1<d.stack.indexOf(`
42    at`)?" (<anonymous>)":-1<d.stack.indexOf("@")?"@unknown:0:0":""}return`
43`+Lr+i+gt}var In=!1;function Jr(i,l){if(!i||In)return"";In=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var m={DetermineComponentFrameRoot:function(){try{if(l){var _e=function(){throw Error()};if(Object.defineProperty(_e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_e,[])}catch(pe){var he=pe}Reflect.construct(i,[],_e)}else{try{_e.call()}catch(pe){he=pe}i.call(_e.prototype)}}else{try{throw Error()}catch(pe){he=pe}(_e=i())&&typeof _e.catch=="function"&&_e.catch(function(){})}}catch(pe){if(pe&&he&&typeof pe.stack=="string")return[pe.stack,he.stack]}return[null,null]}};m.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var C=Object.getOwnPropertyDescriptor(m.DetermineComponentFrameRoot,"name");C&&C.configurable&&Object.defineProperty(m.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var v=m.DetermineComponentFrameRoot(),A=v[0],V=v[1];if(A&&V){var Z=A.split(`
44`),ue=V.split(`
45`);for(C=m=0;m<Z.length&&!Z[m].includes("DetermineComponentFrameRoot");)m++;for(;C<ue.length&&!ue[C].includes("DetermineComponentFrameRoot");)C++;if(m===Z.length||C===ue.length)for(m=Z.length-1,C=ue.length-1;1<=m&&0<=C&&Z[m]!==ue[C];)C--;for(;1<=m&&0<=C;m--,C--)if(Z[m]!==ue[C]){if(m!==1||C!==1)do if(m--,C--,0>C||Z[m]!==ue[C]){var be=`
46`+Z[m].replace(" at new "," at ");return i.displayName&&be.includes("<anonymous>")&&(be=be.replace("<anonymous>",i.displayName)),be}while(1<=m&&0<=C);break}}}finally{In=!1,Error.prepareStackTrace=d}return(d=i?i.displayName||i.name:"")?Ye(d):""}function ar(i,l){switch(i.tag){case 26:case 27:case 5:return Ye(i.type);case 16:return Ye("Lazy");case 13:return i.child!==l&&l!==null?Ye("Suspense Fallback"):Ye("Suspense");case 19:return Ye("SuspenseList");case 0:case 15:return Jr(i.type,!1);case 11:return Jr(i.type.render,!1);case 1:return Jr(i.type,!0);case 31:return Ye("Activity");default:return""}}function Rs(i){try{var l="",d=null;do l+=ar(i,d),d=i,i=i.return;while(i);return l}catch(m){return`
47Error generating stack: `+m.message+`
48`+m.stack}}var Ct=Object.prototype.hasOwnProperty,St=n.unstable_scheduleCallback,Un=n.unstable_cancelCallback,Tr=n.unstable_shouldYield,ns=n.unstable_requestPaint,yn=n.unstable_now,kt=n.unstable_getCurrentPriorityLevel,re=n.unstable_ImmediatePriority,Ne=n.unstable_UserBlockingPriority,De=n.unstable_NormalPriority,qe=n.unstable_LowPriority,je=n.unstable_IdlePriority,st=n.log,bt=n.unstable_setDisableYieldValue,ht=null,Qe=null;function it(i){if(typeof st=="function"&&bt(i),Qe&&typeof Qe.setStrictMode=="function")try{Qe.setStrictMode(ht,i)}catch{}}var jt=Math.clz32?Math.clz32:Vn,kr=Math.log,Rn=Math.LN2;function Vn(i){return i>>>=0,i===0?32:31-(kr(i)/Rn|0)|0}var xn=256,Gn=262144,It=4194304;function $n(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Pn(i,l,d){var m=i.pendingLanes;if(m===0)return 0;var C=0,v=i.suspendedLanes,A=i.pingedLanes;i=i.warmLanes;var V=m&134217727;return V!==0?(m=V&~v,m!==0?C=$n(m):(A&=V,A!==0?C=$n(A):d||(d=V&~i,d!==0&&(C=$n(d))))):(V=m&~v,V!==0?C=$n(V):A!==0?C=$n(A):d||(d=m&~i,d!==0&&(C=$n(d)))),C===0?0:l!==0&&l!==C&&(l&v)===0&&(v=C&-C,d=l&-l,v>=d||v===32&&(d&4194048)!==0)?l:C}function or(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Li(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function _n(){var i=It;return It<<=1,(It&62914560)===0&&(It=4194304),i}function Kt(i){for(var l=[],d=0;31>d;d++)l.push(i);return l}function $e(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function un(i,l,d,m,C,v){var A=i.pendingLanes;i.pendingLanes=d,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=d,i.entangledLanes&=d,i.errorRecoveryDisabledLanes&=d,i.shellSuspendCounter=0;var V=i.entanglements,Z=i.expirationTimes,ue=i.hiddenUpdates;for(d=A&~d;0<d;){var be=31-jt(d),_e=1<<be;V[be]=0,Z[be]=-1;var he=ue[be];if(he!==null)for(ue[be]=null,be=0;be<he.length;be++){var pe=he[be];pe!==null&&(pe.lane&=-536870913)}d&=~_e}m!==0&&Kn(i,m,0),v!==0&&C===0&&i.tag!==0&&(i.suspendedLanes|=v&~(A&~l))}function Kn(i,l,d){i.pendingLanes|=l,i.suspendedLanes&=~l;var m=31-jt(l);i.entangledLanes|=l,i.entanglements[m]=i.entanglements[m]|1073741824|d&261930}function rs(i,l){var d=i.entangledLanes|=l;for(i=i.entanglements;d;){var m=31-jt(d),C=1<<m;C&l|i[m]&l&&(i[m]|=l),d&=~C}}function Hn(i,l){var d=l&-l;return d=(d&42)!==0?1:Rt(d),(d&(i.suspendedLanes|l))!==0?0:d}function Rt(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;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:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function Tn(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function $r(){var i=W.p;return i!==0?i:(i=window.event,i===void 0?32:eE(i.type))}function vr(i,l){var d=W.p;try{return W.p=i,l()}finally{W.p=d}}var Yn=Math.random().toString(36).slice(2),on="__reactFiber$"+Yn,Nt="__reactProps$"+Yn,Cn="__reactContainer$"+Yn,jr="__reactEvents$"+Yn,bn="__reactListeners$"+Yn,Nr="__reactHandles$"+Yn,Ps="__reactResources$"+Yn,Sr="__reactMarker$"+Yn;function Ws(i){delete i[on],delete i[Nt],delete i[jr],delete i[bn],delete i[Nr]}function ps(i){var l=i[on];if(l)return l;for(var d=i.parentNode;d;){if(l=d[Cn]||d[on]){if(d=l.alternate,l.child!==null||d!==null&&d.child!==null)for(i=Ow(i);i!==null;){if(d=i[on])return d;i=Ow(i)}return l}i=d,d=i.parentNode}return null}function Kr(i){if(i=i[on]||i[Cn]){var l=i.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return i}return null}function ss(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i.stateNode;throw Error(r(33))}function Xs(i){var l=i[Ps];return l||(l=i[Ps]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function qn(i){i[Sr]=!0}var pl=new Set,Bl={};function Zs(i,l){ei(i,l),ei(i+"Capture",l)}function ei(i,l){for(Bl[i]=l,i=0;i<l.length;i++)pl.add(l[i])}var yl=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),xl={},Cl={};function Nc(i){return Ct.call(Cl,i)?!0:Ct.call(xl,i)?!1:yl.test(i)?Cl[i]=!0:(xl[i]=!0,!1)}function eo(i,l,d){if(Nc(l))if(d===null)i.removeAttribute(l);else{switch(typeof d){case"undefined":case"function":case"symbol":i.removeAttribute(l);return;case"boolean":var m=l.toLowerCase().slice(0,5);if(m!=="data-"&&m!=="aria-"){i.removeAttribute(l);return}}i.setAttribute(l,""+d)}}function is(i,l,d){if(d===null)i.removeAttribute(l);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(l);return}i.setAttribute(l,""+d)}}function Qn(i,l,d,m){if(m===null)i.removeAttribute(d);else{switch(typeof m){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(d);return}i.setAttributeNS(l,d,""+m)}}function lr(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ji(i){var l=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function bl(i,l,d){var m=Object.getOwnPropertyDescriptor(i.constructor.prototype,l);if(!i.hasOwnProperty(l)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var C=m.get,v=m.set;return Object.defineProperty(i,l,{configurable:!0,get:function(){return C.call(this)},set:function(A){d=""+A,v.call(this,A)}}),Object.defineProperty(i,l,{enumerable:m.enumerable}),{getValue:function(){return d},setValue:function(A){d=""+A},stopTracking:function(){i._valueTracker=null,delete i[l]}}}}function Xt(i){if(!i._valueTracker){var l=ji(i)?"checked":"value";i._valueTracker=bl(i,l,""+i[l])}}function la(i){if(!i)return!1;var l=i._valueTracker;if(!l)return!0;var d=l.getValue(),m="";return i&&(m=ji(i)?i.checked?"true":"false":i.value),i=m,i!==d?(l.setValue(i),!0):!1}function as(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var ca=/[\n"\\]/g;function zn(i){return i.replace(ca,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function to(i,l,d,m,C,v,A,V){i.name="",A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?i.type=A:i.removeAttribute("type"),l!=null?A==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+lr(l)):i.value!==""+lr(l)&&(i.value=""+lr(l)):A!=="submit"&&A!=="reset"||i.removeAttribute("value"),l!=null?de(i,A,lr(l)):d!=null?de(i,A,lr(d)):m!=null&&i.removeAttribute("value"),C==null&&v!=null&&(i.defaultChecked=!!v),C!=null&&(i.checked=C&&typeof C!="function"&&typeof C!="symbol"),V!=null&&typeof V!="function"&&typeof V!="symbol"&&typeof V!="boolean"?i.name=""+lr(V):i.removeAttribute("name")}function $(i,l,d,m,C,v,A,V){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(i.type=v),l!=null||d!=null){if(!(v!=="submit"&&v!=="reset"||l!=null)){Xt(i);return}d=d!=null?""+lr(d):"",l=l!=null?""+lr(l):d,V||l===i.value||(i.value=l),i.defaultValue=l}
vendor: 5,261 bytes, line 48
48m=m??C,m=typeof m!="function"&&typeof m!="symbol"&&!!m,i.checked=V?i.checked:!!m,i.defaultChecked=!!m,A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"&&(i.name=A),Xt(i)}function de(i,l,d){l==="number"&&as(i.ownerDocument)===i||i.defaultValue===""+d||(i.defaultValue=""+d)}function Be(i,l,d,m){if(i=i.options,l){l={};for(var C=0;C<d.length;C++)l["$"+d[C]]=!0;for(d=0;d<i.length;d++)C=l.hasOwnProperty("$"+i[d].value),i[d].selected!==C&&(i[d].selected=C),C&&m&&(i[d].defaultSelected=!0)}else{for(d=""+lr(d),l=null,C=0;C<i.length;C++){if(i[C].value===d){i[C].selected=!0,m&&(i[C].defaultSelected=!0);return}l!==null||i[C].disabled||(l=i[C])}l!==null&&(l.selected=!0)}}function et(i,l,d){if(l!=null&&(l=""+lr(l),l!==i.value&&(i.value=l),d==null)){i.defaultValue!==l&&(i.defaultValue=l);return}i.defaultValue=d!=null?""+lr(d):""}function vt(i,l,d,m){if(l==null){if(m!=null){if(d!=null)throw Error(r(92));if(ne(m)){if(1<m.length)throw Error(r(93));m=m[0]}d=m}d==null&&(d=""),l=d}d=lr(l),i.defaultValue=d,m=i.textContent,m===d&&m!==""&&m!==null&&(i.value=m),Xt(i)}function Zt(i,l){if(l){var d=i.firstChild;if(d&&d===i.lastChild&&d.nodeType===3){d.nodeValue=l;return}}i.textContent=l}var en=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function ua(i,l,d){var m=l.indexOf("--")===0;d==null||typeof d=="boolean"||d===""?m?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="":m?i.setProperty(l,d):typeof d!="number"||d===0||en.has(l)?l==="float"?i.cssFloat=d:i[l]=(""+d).trim():i[l]=d+"px"}function tn(i,l,d){if(l!=null&&typeof l!="object")throw Error(r(62));if(i=i.style,d!=null){for(var m in d)!d.hasOwnProperty(m)||l!=null&&l.hasOwnProperty(m)||(m.indexOf("--")===0?i.setProperty(m,""):m==="float"?i.cssFloat="":i[m]="");for(var C in l)m=l[C],l.hasOwnProperty(C)&&d[C]!==m&&ua(i,C,m)}else for(var v in l)l.hasOwnProperty(v)&&ua(i,v,l[v])}function no(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Sc=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode
48-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),ro=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Dc(i){return ro.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function yi(){}var Wu=null;function ti(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var so=null,Oi=null;function vl(i){var l=Kr(i);if(l&&(i=l.stateNode)){var d=i[Nt]||null;e:switch(i=l.stateNode,l.type){case"input":if(to(i,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name),l=d.name,d.type==="radio"&&l!=null){for(d=i;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll('input[name="'+zn(""+l)+'"][type="radio"]'),l=0;l<d.length;l++){var m=d[l];if(m!==i&&m.form===i.form){var C=m[Nt]||null;if(!C)throw Error(r(90));to(m,C.value,C.defaultValue,C.defaultValue,C.checked,C.defaultChecked,C.type,C.name)}}for(l=0;l<d.length;l++)m=d[l],m.form===i.form&&la(m)}break e;case"textarea":et(i,d.value,d.defaultValue);break e;case"select":l=d.value,l!=null&&Be(i,!!d.multiple,l,!1)}}}var Ac=!1;function io(i,l,d){if(Ac)return i(l,d);Ac=!0;try{var m=i(l);return m}finally{if(Ac=!1,(so!==null||Oi!==null)&&(Qf(),so&&(l=so,i=Oi,Oi=so=null,vl(l),i)))for(l=0;l<i.length;l++)vl(i[l])}}function xi(i,l){var d=i.stateNode;if(d===null)return null;var m=d[Nt]||null;if(m===null)return null;d=m[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(m=!m.disabled)||(i=i.type,m=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!m;break e;default:i=!1}if(i)return null;if(d&&typeof d!="function")throw Error(r(231,l,typeof d));return d}var ni=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wl=!1;if(ni)try{var dn={};Object.defineProperty(dn,"passive",{get:function(){wl=!0}}),window.addEventListener("test",dn,dn),window.removeEventListener("test",dn,dn)}catch{wl=!1}var Fi=null,Xu=null,El=null;function Zu(){if(El)return El;var i,l=Xu,d=l.length,m,C="value"in Fi?Fi.value:Fi.textContent,v=C.length;for(i=0;i<d&&l[i]===C[i];i++);var A=d-i;for(m=1;m<=A&&l[d-m]===C[v-m];m++);return El=C.slice(i,1<m?1-m:void 0)}function _l(i){var l=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&l===13&&(i=13)):i=l,i===10&&(i=13),32<=i||i===13?i:0}function da(){return!0}function Ci(){return!1}function Or(i){function l(d,m,C,v,A){this._reactName=d,this._targetInst=C,this.type=m,this.nativeEvent=v,this.target=A,this.currentTarget=null;for(var V in i)i.hasOwnProperty(V)&&(d=i[V],this[V]=d?d(v):v[V]);return this.isDefaultPrevented=(v.defaultPrevented!=null?v.defaultPrevented:v.returnValue===!1)?da:Ci,this.isPropagationStopped=Ci,this}return y(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=da)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=da)},persist:function(){},isPersistent:da}),l}var ha={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ui=Or(ha),ao=y({},ha,{view:0,detail:0}),ed=Or(ao),oo,Ic,Vi,Rc=y({},ao,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:lo,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==Vi&&(Vi&&i.type==="mousemove"?(oo=i.screenX-Vi.screenX,Ic=i.screenY-Vi.screenY):Ic=oo=0,Vi=i),oo)},movementY:function(i){return"movementY"in i?i.movementY:Ic}}),td=Or(Rc),Tl=y({},Rc,{dataTransfer:0}),rf=Or(Tl),sf=y({},ao,{relatedTarget:0}),kl=Or(sf),nd=y({},ha,{animationName:0,elapsedTime:0,pseudoElement:0}),af=Or(nd),Pc=y({},ha,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),of=Or(Pc),lf=y({},ha,{data:0}),Gi=Or(lf),cf={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},uf={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},df={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function hf(i){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(i):(i=df[i])?!!l[i]:!1}function lo(){return hf}var os=y({},ao,{key:function(i){if(i.key){var l=cf[i.key]||i.key;if(l!=="Unidentified")return l}
vendor: 5,180 bytes, line 48
48return i.type==="keypress"?(i=_l(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?uf[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:lo,charCode:function(i){return i.type==="keypress"?_l(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?_l(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),ff=Or(os),mf=y({},Rc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),fa=Or(mf),x=y({},ao,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:lo}),T=Or(x),P=y({},ha,{propertyName:0,elapsedTime:0,pseudoElement:0}),q=Or(P),le=y({},Rc,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),me=Or(le),Me=y({},ha,{newState:0,oldState:0}),wt=Or(Me),rr=[9,13,27,32],nn=ni&&"CompositionEvent"in window,Mn=null;ni&&"documentMode"in document&&(Mn=document.documentMode);var ri=ni&&"TextEvent"in window&&!Mn,Hi=ni&&(!nn||Mn&&8<Mn&&11>=Mn),bi=" ",vi=!1;function Nl(i,l){switch(i){case"keyup":return rr.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Mc(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Lc=!1;function AI(i,l){switch(i){case"compositionend":return Mc(l);case"keypress":return l.which!==32?null:(vi=!0,bi);case"textInput":return i=l.data,i===bi&&vi?null:i;default:return null}}function II(i,l){if(Lc)return i==="compositionend"||!nn&&Nl(i,l)?(i=Zu(),El=Xu=Fi=null,Lc=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return Hi&&l.locale!=="ko"?null:l.data;default:return null}}var RI={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function VC(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l==="input"?!!RI[i.type]:l==="textarea"}function GC(i,l,d,m){so?Oi?Oi.push(m):Oi=[m]:so=m,l=rm(l,"onChange"),0<l.length&&(d=new Ui("onChange","change",null,d,m),i.push({event:d,listeners:l}))}var rd=null,sd=null;function PI(i){Ew(i,0)}function gf(i){var l=ss(i);if(la(l))return i}function HC(i,l){if(i==="change")return l}var qC=!1;if(ni){var Ap;if(ni){var Ip="oninput"in document;if(!Ip){var zC=document.createElement("div");zC.setAttribute("oninput","return;"),Ip=typeof zC.oninput=="function"}Ap=Ip}else Ap=!1;qC=Ap&&(!document.documentMode||9<document.documentMode)}function JC(){rd&&(rd.detachEvent("onpropertychange",$C),sd=rd=null)}function $C(i){if(i.propertyName==="value"&&gf(sd)){var l=[];GC(l,sd,i,ti(i)),io(PI,l)}}function MI(i,l,d){i==="focusin"?(JC(),rd=l,sd=d,rd.attachEvent("onpropertychange",$C)):i==="focusout"&&JC()}function LI(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return gf(sd)}function jI(i,l){if(i==="click")return gf(l)}function OI(i,l){if(i==="input"||i==="change")return gf(l)}function FI(i,l){return i===l&&(i!==0||1/i===1/l)||i!==i&&l!==l}var Ms=typeof Object.is=="function"?Object.is:FI;function id(i,l){if(Ms(i,l))return!0;if(typeof i!="object"||i===null||typeof l!="object"||l===null)return!1;var d=Object.keys(i),m=Object.keys(l);if(d.length!==m.length)return!1;for(m=0;m<d.length;m++){var C=d[m];if(!Ct.call(l,C)||!Ms(i[C],l[C]))return!1}return!0}function KC(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function YC(i,l){var d=KC(i);i=0;for(var m;d;){if(d.nodeType===3){if(m=i+d.textContent.length,i<=l&&m>=l)return{node:d,offset:l-i};i=m}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=KC(d)}}function QC(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?QC(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function WC(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=as(i.document);l instanceof i.HTMLIFrameElement;){try{var d=typeof l.contentWindow.location.href=="string"}catch{d=!1}if(d)i=l.contentWindow;else break;l=as(i.document)}return l}function Rp(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var UI=ni&&"documentMode"in document&&11>=document.documentMode,jc=null,Pp=null,ad=null,Mp=!1;function XC(i,l,d){var m=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Mp||jc==null||jc!==as(m)||(m=jc,"selectionStart"in m&&Rp(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focu
vendor: 22,833 bytes, line 48
48sNode:m.focusNode,focusOffset:m.focusOffset}),ad&&id(ad,m)||(ad=m,m=rm(Pp,"onSelect"),0<m.length&&(l=new Ui("onSelect","select",null,l,d),i.push({event:l,listeners:m}),l.target=jc)))}function Sl(i,l){var d={};return d[i.toLowerCase()]=l.toLowerCase(),d["Webkit"+i]="webkit"+l,d["Moz"+i]="moz"+l,d}var Oc={animationend:Sl("Animation","AnimationEnd"),animationiteration:Sl("Animation","AnimationIteration"),animationstart:Sl("Animation","AnimationStart"),transitionrun:Sl("Transition","TransitionRun"),transitionstart:Sl("Transition","TransitionStart"),transitioncancel:Sl("Transition","TransitionCancel"),transitionend:Sl("Transition","TransitionEnd")},Lp={},ZC={};ni&&(ZC=document.createElement("div").style,"AnimationEvent"in window||(delete Oc.animationend.animation,delete Oc.animationiteration.animation,delete Oc.animationstart.animation),"TransitionEvent"in window||delete Oc.transitionend.transition);function Dl(i){if(Lp[i])return Lp[i];if(!Oc[i])return i;var l=Oc[i],d;for(d in l)if(l.hasOwnProperty(d)&&d in ZC)return Lp[i]=l[d];return i}var eb=Dl("animationend"),tb=Dl("animationiteration"),nb=Dl("animationstart"),VI=Dl("transitionrun"),GI=Dl("transitionstart"),HI=Dl("transitioncancel"),rb=Dl("transitionend"),sb=new Map,jp="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");jp.push("scrollEnd");function wi(i,l){sb.set(i,l),Zs(l,[i])}var pf=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},si=[],Fc=0,Op=0;function Bf(){for(var i=Fc,l=Op=Fc=0;l<i;){var d=si[l];si[l++]=null;var m=si[l];si[l++]=null;var C=si[l];si[l++]=null;var v=si[l];if(si[l++]=null,m!==null&&C!==null){var A=m.pending;A===null?C.next=C:(C.next=A.next,A.next=C),m.pending=C}v!==0&&ib(d,C,v)}}function yf(i,l,d,m){si[Fc++]=i,si[Fc++]=l,si[Fc++]=d,si[Fc++]=m,Op|=m,i.lanes|=m,i=i.alternate,i!==null&&(i.lanes|=m)}function Fp(i,l,d,m){return yf(i,l,d,m),xf(i)}function Al(i,l){return yf(i,null,null,l),xf(i)}function ib(i,l,d){i.lanes|=d;var m=i.alternate;m!==null&&(m.lanes|=d);for(var C=!1,v=i.return;v!==null;)v.childLanes|=d,m=v.alternate,m!==null&&(m.childLanes|=d),v.tag===22&&(i=v.stateNode,i===null||i._visibility&1||(C=!0)),i=v,v=v.return;return i.tag===3?(v=i.stateNode,C&&l!==null&&(C=31-jt(d),i=v.hiddenUpdates,m=i[C],m===null?i[C]=[l]:m.push(l),l.lane=d|536870912),v):null}function xf(i){if(50<Nd)throw Nd=0,K0=null,Error(r(185));for(var l=i.return;l!==null;)i=l,l=i.return;return i.tag===3?i.stateNode:null}var Uc={};function qI(i,l,d,m){this.tag=i,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ls(i,l,d,m){return new qI(i,l,d,m)}function Up(i){return i=i.prototype,!(!i||!i.isReactComponent)}function ma(i,l){var d=i.alternate;return d===null?(d=Ls(i.tag,l,i.key,i.mode),d.elementType=i.elementType,d.type=i.type,d.stateNode=i.stateNode,d.alternate=i,i.alternate=d):(d.pendingProps=l,d.type=i.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=i.flags&65011712,d.childLanes=i.childLanes,d.lanes=i.lanes,d.child=i.child,d.memoizedProps=i.memoizedProps,d.memoizedState=i.memoizedState,d.updateQueue=i.updateQueue,l=i.dependencies,d.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},d.sibling=i.sibling,d.index=i.index,d.ref=i.ref,d.refCleanup=i.refCleanup,d}function ab(i,l){i.flags&=65011714;var d=i.alternate;return d===null?(i.childLanes=0,i.lanes=l,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=d.childLanes,i.lanes=d.lanes,i.child=d.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=d.memoizedProps,i.memoizedState=d.memoizedState,i.updateQueue=d.updateQueue,i.type=d.type,l=d.dependencies,i.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),i}function Cf(i,l,d,m,C,v){var A=0;if(m=i,typeof i=="function")Up(i)&&(A=1);else if(typeof i=="string")A=Y2(i,d,Ae.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case _:return i=Ls(31,d,l,C),i.elementType=_,i.lanes=v,i;case N:return Il(d.children,C,v,l);case S:A=8,C|=24;break;case I:return i=Ls(12,d,l,C|2),i.elementType=I,i.lanes=v,i;case z:return i=Ls(13,d,l,C),i.elementType=z,i.lanes=v,i;case U:return i=Ls(19,d,l,C),i.elementType=U,i.lanes=v,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case F:A=10;break e;case O:A=9;break e;case J:A=11;break e;case D:A=14;break e;case k:A=16,m=null;break e}A=29,d=Error(r(130,i===null?"null":typeof i,"")),m=null}return l=Ls(A,d,l,C),l.elementType=i,l.type=m,l.lanes=v,l}function Il(i,l,d,m){return i=Ls(7,i,m,l),i.lanes=d,i}function Vp(i,l,d){return i=Ls(6,i,null,l),i.lanes=d,i}function ob(i){var l=Ls(18,null,null,0);return l.stateNode=i,l}function Gp(i,l,d){return l=Ls(4,i.children!==null?i.children:[],i.key,l),l.lanes=d,l.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},l}var lb=new WeakMap;function ii(i,l){if(typeof i=="object"&&i!==null){var d=lb.get(i);return d!==void 0?d:(l={value:i,source:l,stack:Rs(l)},lb.set(i,l),l)}return{value:i,source:l,stack:Rs(l)}}var Vc=[],Gc=0,bf=null,od=0,ai=[],oi=0,co=null,qi=1,zi="";function ga(i,l){Vc[Gc++]=od,Vc[Gc++]=bf,bf=i,od=l}function cb(i,l,d){ai[oi++]=qi,ai[oi++]=zi,ai[oi++]=co,co=i;var m=qi;i=zi;var C=32-jt(m)-1;m&=~(1<<C),d+=1;var v=32-jt(l)+C;if(30<v){var A=C-C%5;v=(m&(1<<A)-1).toString(32),m>>=A,C-=A,qi=1<<32-jt(l)+C|d<<C|m,zi=v+i}else qi=1<<v|d<<C|m,zi=i}function Hp(i){i.return!==null&&(ga(i,1),cb(i,1,0))}function qp(i){for(;i===bf;)bf=Vc[--Gc],Vc[Gc]=null,od=Vc[--Gc],Vc[Gc]=null;for(;i===co;)co=ai[--oi],ai[oi]=null,zi=ai[--oi],ai[oi]=null,qi=ai[--oi],ai[oi]=null}function ub(i,l){ai[oi++]=qi,ai[oi++]=zi,ai[oi++]=co,qi=l.id,zi=l.overflow,co=i}var Fr=null,kn=null,Vt=!1,uo=null,li=!1,zp=Error(r(519));function ho(i){var l=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ld(ii(l,i)),zp}function db(i){var l=i.stateNode,d=i.type,m=i.memoizedProps;switch(l[on]=i,l[Nt]=m,d){case"dialog":Mt("cancel",l),Mt("close",l);break;case"iframe":case"object":case"embed":Mt("load",l);break;case"video":case"audio":for(d=0;d<Dd.length;d++)Mt(Dd[d],l);break;case"source":Mt("error",l);break;case"img":case"image":case"link":Mt("error",l),Mt("load",l);break;case"details":Mt("toggle",l);break;case"input":Mt("invalid",l),$(l,m.value,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name,!0);break;case"select":Mt("invalid",l);break;case"textarea":Mt("invalid",l),vt(l,m.value,m.defaultValue,m.children)}d=m.children,typeof d!="string"&&typeof d!="number"&&typeof d!="bigint"||l.textContent===""+d||m.suppressHydrationWarning===!0||Nw(l.textContent,d)?(m.popover!=null&&(Mt("beforetoggle",l),Mt("toggle",l)),m.onScroll!=null&&Mt("scroll",l),m.onScrollEnd!=null&&Mt("scrollend",l),m.onClick!=null&&(l.onclick=yi),l=!0):l=!1,l||ho(i,!0)}function hb(i){for(Fr=i.return;Fr;)switch(Fr.tag){case 5:case 31:case 13:li=!1;return;case 27:case 3:li=!0;return;default:Fr=Fr.return}}function Hc(i){if(i!==Fr)return!1;if(!Vt)return hb(i),Vt=!0,!1;var l=i.tag,d;if((d=l!==3&&l!==27)&&((d=l===5)&&(d=i.type,d=!(d!=="form"&&d!=="button")||cB(i.type,i.memoizedProps)),d=!d),d&&kn&&ho(i),hb(i),l===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));kn=jw(i)}else if(l===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));kn=jw(i)}else l===27?(l=kn,To(i.type)?(i=mB,mB=null,kn=i):kn=l):kn=Fr?ui(i.stateNode.nextSibling):null;return!0}function Rl(){kn=Fr=null,Vt=!1}function Jp(){var i=uo;return i!==null&&(Cs===null?Cs=i:Cs.push.apply(Cs,i),uo=null),i}function ld(i){uo===null?uo=[i]:uo.push(i)}var $p=K(null),Pl=null,pa=null;function fo(i,l,d){Se($p,l._currentValue),l._currentValue=d}function Ba(i){i._currentValue=$p.current,fe($p)}function Kp(i,l,d){for(;i!==null;){var m=i.alternate;if((i.childLanes&l)!==l?(i.childLanes|=l,m!==null&&(m.childLanes|=l)):m!==null&&(m.childLanes&l)!==l&&(m.childLanes|=l),i===d)break;i=i.return}}function Yp(i,l,d,m){var C=i.child;for(C!==null&&(C.return=i);C!==null;){var v=C.dependencies;if(v!==null){var A=C.child;v=v.firstContext;e:for(;v!==null;){var V=v;v=C;for(var Z=0;Z<l.length;Z++)if(V.context===l[Z]){v.lanes|=d,V=v.alternate,V!==null&&(V.lanes|=d),Kp(v.return,d,i),m||(A=null);break e}v=V.next}}else if(C.tag===18){if(A=C.return,A===null)throw Error(r(341));A.lanes|=d,v=A.alternate,v!==null&&(v.lanes|=d),Kp(A,d,i),A=null}else A=C.child;if(A!==null)A.return=C;else for(A=C;A!==null;){if(A===i){A=null;break}if(C=A.sibling,C!==null){C.return=A.return,A=C;break}A=A.return}C=A}}function qc(i,l,d,m){i=null;for(var C=l,v=!1;C!==null;){if(!v){if((C.flags&524288)!==0)v=!0;else if((C.flags&262144)!==0)break}if(C.tag===10){var A=C.alternate;if(A===null)throw Error(r(387));if(A=A.memoizedProps,A!==null){var V=C.type;Ms(C.pendingProps.value,A.value)||(i!==null?i.push(V):i=[V])}}else if(C===dt.current){if(A=C.alternate,A===null)throw Error(r(387));A.memoizedState.memoizedState!==C.memoizedState.memoizedState&&(i!==null?i.push(Md):i=[Md])}C=C.return}i!==null&&Yp(l,i,d,m),l.flags|=262144}function vf(i){for(i=i.firstContext;i!==null;){if(!Ms(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Ml(i){Pl=i,pa=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Ur(i){return fb(Pl,i)}function wf(i,l){return Pl===null&&Ml(i),fb(i,l)}function fb(i,l){var d=l._currentValue;if(l={context:l,memoizedValue:d,next:null},pa===null){if(i===null)throw Error(r(308));pa=l,i.dependencies={lanes:0,firstContext:l},i.flags|=524288}else pa=pa.next=l;return d}var zI=typeof AbortController<"u"?AbortController:function(){var i=[],l=this.signal={aborted:!1,addEventListener:function(d,m){i.push(m)}};this.abort=function(){l.aborted=!0,i.forEach(function(d){return d()})}},JI=n.unstable_scheduleCallback,$I=n.unstable_NormalPriority,cr={$$typeof:F,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Qp(){return{controller:new zI,data:new Map,refCount:0}}function cd(i){i.refCount--,i.refCount===0&&JI($I,function(){i.controller.abort()})}var ud=null,Wp=0,zc=0,Jc=null;function KI(i,l){if(ud===null){var d=ud=[];Wp=0,zc=eB(),Jc={status:"pending",value:void 0,then:function(m){d.push(m)}}}return Wp++,l.then(mb,mb),l}function mb(){if(--Wp===0&&ud!==null){Jc!==null&&(Jc.status="fulfilled");var i=ud;ud=null,zc=0,Jc=null;for(var l=0;l<i.length;l++)(0,i[l])()}}function YI(i,l){var d=[],m={status:"pending",value:null,reason:null,then:function(C){d.push(C)}};return i.then(function(){m.status="fulfilled",m.value=l;for(var C=0;C<d.length;C++)(0,d[C])(l)},function(C){for(m.status="rejected",m.reason=C,C=0;C<d.length;C++)(0,d[C])(void 0)}),m}var gb=G.S;G.S=function(i,l){Xv=yn(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&KI(i,l),gb!==null&&gb(i,l)};var Ll=K(null);function Xp(){var i=Ll.current;return i!==null?i:gn.pooledCache}function Ef(i,l){l===null?Se(Ll,Ll.current):Se(Ll,l.pool)}function pb(){var i=Xp();return i===null?null:{parent:cr._currentValue,pool:i}}var $c=Error(r(460)),Zp=Error(r(474)),_f=Error(r(542)),Tf={then:function(){}};function Bb(i){return i=i.status,i==="fulfilled"||i==="rejected"}function yb(i,l,d){switch(d=i[d],d===void 0?i.push(l):d!==l&&(l.then(yi,yi),l=d),l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,Cb(i),i;default:if(typeof l.status=="string")l.then(yi,yi);else{if(i=gn,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=l,i.status="pending",i.then(function(m){if(l.status==="pending"){var C=l;C.status="fulfilled",C.value=m}},function(m){if(l.status==="pending"){var C=l;C.status="rejected",C.reason=m}})}switch(l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,Cb(i),i}throw Ol=l,$c}}function jl(i){try{var l=i._init;return l(i._payload)}catch(d){throw d!==null&&typeof d=="object"&&typeof d.then=="function"?(Ol=d,$c):d}}var Ol=null;function xb(){if(Ol===null)throw Error(r(459));var i=Ol;return Ol=null,i}function Cb(i){if(i===$c||i===_f)throw Error(r(483))}var Kc=null,dd=0;function kf(i){var l=dd;return dd+=1,Kc===null&&(Kc=[]),yb(Kc,i,l)}function hd(i,l){l=l.props.ref,i.ref=l!==void 0?l:null}function Nf(i,l){throw l.$$typeof===b?Error(r(525)):(i=Object.prototype.toString.call(l),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":i)))}function bb(i){function l(oe,te){if(i){var ce=oe.deletions;ce===null?(oe.deletions=[te],oe.flags|=16):ce.push(te)}}function d(oe,te){if(!i)return null;for(;te!==null;)l(oe,te),te=te.sibling;return null}function m(oe){for(var te=new Map;oe!==null;)oe.key!==null?te.set(oe.key,oe):te.set(oe.index,oe),oe=oe.sibling;return te}function C(oe,te){return oe=ma(oe,te),oe.index=0,oe.sibling=null,oe}function v(oe,te,ce){return oe.index=ce,i?(ce=oe.alternate,ce!==null?(ce=ce.index,ce<te?(oe.flags|=67108866,te):ce):(oe.flags|=67108866,te)):(oe.flags|=1048576,te)}function A(oe){return i&&oe.alternate===null&&(oe.flags|=67108866),oe}function V(oe,te,ce,we){return te===null||te.tag!==6?(te=Vp(ce,oe.mode,we),te.return=oe,te):(te=C(te,ce),te.return=oe,te)}function Z(oe,te,ce,we){var at=ce.type;return at===N?be(oe,te,ce.props.children,we,ce.key):te!==null&&(te.elementType===at||typeof at=="object"&&at!==null&&at.$$typeof===k&&jl(at)===te.type)?(te=C(te,ce.props),hd(te,ce),te.return=oe,te):(te=Cf(ce.type,ce.key,ce.props,null,oe.mode,we),hd(te,ce),te.return=oe,te)}function ue(oe,te,ce,we){return te===null||te.tag!==4||te.stateNode.containerInfo!==ce.containerInfo||te.stateNode.implementation!==ce.implementation?(te=Gp(ce,oe.mode,we),te.return=oe,te):(te=C(te,ce.children||[]),te.return=oe,te)}function be(oe,te,ce,we,at){return te===null||te.tag!==7?(te=Il(ce,oe.mode,we,at),te.return=oe,te):(te=C(te,ce),te.return=oe,te)}function _e(oe,te,ce){if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return te=Vp(""+te,oe.mode,ce),te.return=oe,te;if(typeof te=="object"&&te!==null){switch(te.$$typeof){case w:return ce=Cf(te.type,te.key,te.props,null,oe.mode,ce),hd(ce,te),ce.return=oe,ce;case E:return te=Gp(te,oe.mode,ce),te.return=oe,te;case k:return te=jl(te),_e(oe,te,ce)}if(ne(te)||H(te))return te=Il(te,oe.mode,ce,null),te.return=oe,te;if(typeof te.then=="function")return _e(oe,kf(te),ce);if(te.$$typeof===F)return _e(oe,wf(oe,te),ce);Nf(oe,te)}return null}function he(oe,te,ce,we){var at=te!==null?te.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return at!==null?null:V(oe,te,""+ce,we);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case w:return ce.key===at?Z(oe,te,ce,we):null;case E:return ce.key===at?ue(oe,te,ce,we):null;case k:return ce=jl(ce),he(oe,te,ce,we)}if(ne(ce)||H(ce))return at!==null?null:be(oe,te,ce,we,null);if(typeof ce.then=="function")return he(oe,te,kf(ce),we);if(ce.$$typeof===F)return he(oe,te,wf(oe,ce),we);Nf(oe,ce)}return null}function pe(oe,te,ce,we,at){if(typeof we=="string"&&we!==""||typeof we=="number"||typeof we=="bigint")return oe=oe.get(ce)||null,V(te,oe,""+we,at);if(typeof we=="object"&&we!==null){switch(we.$$typeof){case w:return oe=oe.get(we.key===null?ce:we.key)||null,Z(te,oe,we,at);case E:return oe=oe.get(we.key===null?ce:we.key)||null,ue(te,oe,we,at);case k:return we=jl(we),pe(oe,te,ce,we,at)}if(ne(we)||H(we))return oe=oe.get(ce)||null,be(te,oe,we,at,null);if(typeof we.then=="function")return pe(oe,te,ce,kf(we),at);if(we.$$typeof===F)return pe(oe,te,ce,wf(te,we),at);Nf(te,we)}return null}function Je(oe,te,ce,we){for(var at=null,Yt=null,We=te,Tt=te=0,Ft=null;We!==null&&Tt<ce.length;Tt++){We.index>Tt?(Ft=We,We=null):Ft=We.sibling;var Qt=he(oe,We,ce[Tt],we);if(Qt===null){We===null&&(We=Ft);break}i&&We&&Qt.alternate===null&&l(oe,We),te=v(Qt,te,Tt),Yt===null?at=Qt:Yt.sibling=Qt,Yt=Qt,We=Ft}if(Tt===ce.length)return d(oe,We),Vt&&ga(oe,Tt),at;if(We===null){for(;Tt<ce.length;Tt++)We=_e(oe,ce[Tt],we),We!==null&&(te=v(We,te,Tt),Yt===null?at=We:Yt.sibling=We,Yt=We);return Vt&&ga(oe,Tt),at}for(We=m(We);Tt<ce.length;Tt++)Ft=pe(We,oe,Tt,ce[Tt],we),Ft!==null&&(i&&Ft.alternate!==null&&We.delete(Ft.key===null?Tt:Ft.key),te=v(Ft,te,Tt),Yt===null?at=Ft:Yt.sibling=Ft,Yt=Ft);return i&&We.forEach(function(Ao){return l(oe,Ao)}),Vt&&ga(oe,Tt),at}function ct(oe,te,ce,we){if(ce==null)throw Error(r(151));for(var at=null,Yt=null,We=te,Tt=te=0,Ft=null,Qt=ce.next();We!==null&&!Qt.done;Tt++,Qt=ce.next()){We.index>Tt?(Ft=We,We=null):Ft=We.sibling;var Ao=he(oe,We,Qt.value,we);if(Ao===null){We===null&&(We=Ft);break}i&&We&&Ao.alternate===null&&l(oe,We),te=v(Ao,te,Tt),Yt===null?at=Ao:Yt.sibling=Ao,Yt=Ao,We=Ft}if(Qt.done)return d(oe,We),Vt&&ga(oe,Tt),at;if(We===null){for(;!Qt.done;Tt++,Qt=ce.next())Qt=_e(oe,Qt.value,we),Qt!==null&&(te=v(Qt,te,Tt),Yt===null?at=Qt:Yt.sibling=Qt,Yt=Qt);return Vt&&ga(oe,Tt),at}for(We=m(We);!Qt.done;Tt++,Qt=ce.next())Qt=pe(We,oe,Tt,Qt.value,we),Qt!==null&&(i&&Qt.alternate!==null&&We.delete(Qt.key===null?Tt:Qt.key),te=v(Qt,te,Tt),Yt===null?at=Qt:Yt.sibling=Qt,Yt=Qt);return i&&We.forEach(function(aR){return l(oe,aR)}),Vt&&ga(oe,Tt),at}function mn(oe,te,ce,we){if(typeof ce=="object"&&ce!==null&&ce.type===N&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case w:e:{for(var at=ce.key;te!==null;){if(te.key===at){if(at=ce.type,at===N){if(te.tag===7){d(oe,te.sibling),we=C(te,ce.props.children),we.return=oe,oe=we;break e}}else if(te.elementType===at||typeof at=="object"&&at!==null&&at.$$typeof===k&&jl(at)===te.type){d(oe,te.sibling),we=C(te,ce.props),hd(we,ce),we.return=oe,oe=we;break e}d(oe,te);break}else l(oe,te);te=te.sibling}ce.type===N?(we=Il(ce.props.children,oe.mode,we,ce.key),we.return=oe,oe=we):(we=Cf(ce.type,ce.key,ce.props,null,oe.mode,we),hd(we,ce),we.return=oe,oe=we)}return A(oe);case E:e:{for(at=ce.key;te!==null;){if(te.key===at)if(te.tag===4&&te.stateNode.containerInfo===ce.containerInfo&&te.stateNode.implementation===ce.implementation){d(oe,te.sibling),we=C(te,ce.children||[]),we.return=oe,oe=we;break e}else{d(oe,te);break}else l(oe,te);te=te.sibling}we=Gp(ce,oe.mode,we),we.return=oe,oe=we}return A(oe);case k:return ce=jl(ce),mn(oe,te,ce,we)}if(ne(ce))return Je(oe,te,ce,we);if(H(ce)){if(at=H(ce),typeof at!="function")throw Error(r(150));return ce=at.call(ce),ct(oe,te,ce,we)}if(typeof ce.then=="function")return mn(oe,te,kf(ce),we);if(ce.$$typeof===F)return mn(oe,te,wf(oe,ce),we);Nf(oe,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint"?(ce=""+ce,te!==null&&te.tag===6?(d(oe,te.sibling),we=C(te,ce),we.return=oe,oe=we):(d(oe,te),we=Vp(ce,oe.mode,we),we.return=oe,oe=we),A(oe)):d(oe,te)}return function(oe,te,ce,we){try{dd=0;var at=mn(oe,te,ce,we);return Kc=null,at}catch(We){if(We===$c||We===_f)throw We;var Yt=Ls(29,We,null,oe.mode);return Yt.lanes=we,Yt.return=oe,Yt}finally{}}}var Fl=bb(!0),vb=bb(!1),mo=!1;function e0(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function t0(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function go(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function po(i,l,d){var m=i.updateQueue;if(m===null)return null;if(m=m.shared,(rn&2)!==0){var C=m.pending;return C===null?l.next=l:(l.next=C.next,C.next=l),m.pending=l,l=xf(i),ib(i,null,d),l}return yf(i,m,l,d),xf(i)}function fd(i,l,d){if(l=l.updateQueue,l!==null&&(l=l.shared,(d&4194048)!==0)){var m=l.lanes;m&=i.pendingLanes,d|=m,l.lanes=d,rs(i,d)}}function n0(i,l){var d=i.updateQueue,m=i.alternate;if(m!==null&&(m=m.updateQueue,d===m)){var C=null,v=null;if(d=d.firstBaseUpdate,d!==null){do{var A={lane:d.lane,tag:d.tag,payload:d.payload,callback:null,next:null};v===null?C=v=A:v=v.next=A,d=d.next}while(d!==null);v===null?C=v=l:v=v.next=l}else C=v=l;d={baseState:m.baseState,firstBaseUpdate:C,lastBaseUpdate:v,shared:m.shared,callbacks:m.callbacks},i.updateQueue=d;return}i=d.lastBaseUpdate,i===null?d.firstBaseUpdate=l:i.next=l,d.lastBaseUpdate=l}var r0=!1;function md(){if(r0){var i=Jc;if(i!==null)throw i}}function gd(i,l,d,m){r0=!1;var C=i.updateQueue;mo=!1;var v=C.firstBaseUpdate,A=C.lastBaseUpdate,V=C.shared.pending;if(V!==null){C.shared.pending=null;var Z=V,ue=Z.next;Z.next=null,A===null?v=ue:A.next=ue,A=Z;var be=i.alternate;be!==null&&(be=be.updateQueue,V=be.lastBaseUpdate,V!==A&&(V===null?be.firstBaseUpdate=ue:V.next=ue,be.lastBaseUpdate=Z))}if(v!==null){var _e=C.baseState;A=0,be=ue=Z=null,V=v;do{var he=V.lane&-536870913,pe=he!==V.lane;if(pe?(Ot&he)===he:(m&he)===he){he!==0&&he===zc&&(r0=!0),be!==null&&(be=be.next={lane:0,tag:V.tag,payload:V.payload,callback:null,next:null});e:{var Je=i,ct=V;he=l;var mn=d;switch(ct.tag){case 1:if(Je=ct.payload,typeof Je=="function"){_e=Je.call(mn,_e,he);break e}_e=Je;break e;case 3:Je.flags=Je.flags&-65537|128;case 0:if(Je=ct.payload,he=typeof Je=="function"?Je.call(mn,_e,he):Je,he==null)break e;_e=y({},_e,he);break e;case 2:mo=!0}}he=V.callback,he!==null&&(i.flags|=64,pe&&(i.flags|=8192),pe=C.callbacks,pe===null?C.callbacks=[he]:pe.push(he))}else pe={lane:he,tag:V.tag,payload:V.payload,callback:V.callback,next:null},be===null?(ue=be=pe,Z=_e):be=be.next=pe,A|=he;if(V=V.next,V===null){if(V=C.shared.pending,V===null)break;pe=V,V=pe.next,pe.next=null,C.lastBaseUpdate=pe,C.shared.pending=null}}while(!0);be===null&&(Z=_e),C.baseState=Z,C.firstBaseUpdate=ue,C.lastBaseUpdate=be,v===null&&(C.shared.lanes=0),bo|=A,i.lanes=A,i.memoizedState=_e}}function wb(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Eb(i,l){var d=i.callbacks;
vendor: 4,101 bytes, line 48
48if(d!==null)for(i.callbacks=null,i=0;i<d.length;i++)wb(d[i],l)}var Yc=K(null),Sf=K(0);function _b(i,l){i=Ta,Se(Sf,i),Se(Yc,l),Ta=i|l.baseLanes}function s0(){Se(Sf,Ta),Se(Yc,Yc.current)}function i0(){Ta=Sf.current,fe(Yc),fe(Sf)}var js=K(null),ci=null;function Bo(i){var l=i.alternate;Se(sr,sr.current&1),Se(js,i),ci===null&&(l===null||Yc.current!==null||l.memoizedState!==null)&&(ci=i)}function a0(i){Se(sr,sr.current),Se(js,i),ci===null&&(ci=i)}function Tb(i){i.tag===22?(Se(sr,sr.current),Se(js,i),ci===null&&(ci=i)):yo()}function yo(){Se(sr,sr.current),Se(js,js.current)}function Os(i){fe(js),ci===i&&(ci=null),fe(sr)}var sr=K(0);function Df(i){for(var l=i;l!==null;){if(l.tag===13){var d=l.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||hB(d)||fB(d)))return l}else if(l.tag===19&&(l.memoizedProps.revealOrder==="forwards"||l.memoizedProps.revealOrder==="backwards"||l.memoizedProps.revealOrder==="unstable_legacy-backwards"||l.memoizedProps.revealOrder==="together")){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var ya=0,Et=null,hn=null,ur=null,Af=!1,Qc=!1,Ul=!1,If=0,pd=0,Wc=null,QI=0;function Wn(){throw Error(r(321))}function o0(i,l){if(l===null)return!1;for(var d=0;d<l.length&&d<i.length;d++)if(!Ms(i[d],l[d]))return!1;return!0}function l0(i,l,d,m,C,v){return ya=v,Et=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,G.H=i===null||i.memoizedState===null?cv:w0,Ul=!1,v=d(m,C),Ul=!1,Qc&&(v=Nb(l,d,m,C)),kb(i),v}function kb(i){G.H=xd;var l=hn!==null&&hn.next!==null;if(ya=0,ur=hn=Et=null,Af=!1,pd=0,Wc=null,l)throw Error(r(300));i===null||dr||(i=i.dependencies,i!==null&&vf(i)&&(dr=!0))}function Nb(i,l,d,m){Et=i;var C=0;do{if(Qc&&(Wc=null),pd=0,Qc=!1,25<=C)throw Error(r(301));if(C+=1,ur=hn=null,i.updateQueue!=null){var v=i.updateQueue;v.lastEffect=null,v.events=null,v.stores=null,v.memoCache!=null&&(v.memoCache.index=0)}G.H=uv,v=l(d,m)}while(Qc);return v}function WI(){var i=G.H,l=i.useState()[0];return l=typeof l.then=="function"?Bd(l):l,i=i.useState()[0],(hn!==null?hn.memoizedState:null)!==i&&(Et.flags|=1024),l}function c0(){var i=If!==0;return If=0,i}function u0(i,l,d){l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~d}function d0(i){if(Af){for(i=i.memoizedState;i!==null;){var l=i.queue;l!==null&&(l.pending=null),i=i.next}Af=!1}ya=0,ur=hn=Et=null,Qc=!1,pd=If=0,Wc=null}function ls(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ur===null?Et.memoizedState=ur=i:ur=ur.next=i,ur}function ir(){if(hn===null){var i=Et.alternate;i=i!==null?i.memoizedState:null}else i=hn.next;var l=ur===null?Et.memoizedState:ur.next;if(l!==null)ur=l,hn=i;else{if(i===null)throw Et.alternate===null?Error(r(467)):Error(r(310));hn=i,i={memoizedState:hn.memoizedState,baseState:hn.baseState,baseQueue:hn.baseQueue,queue:hn.queue,next:null},ur===null?Et.memoizedState=ur=i:ur=ur.next=i}return ur}function Rf(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Bd(i){var l=pd;return pd+=1,Wc===null&&(Wc=[]),i=yb(Wc,i,l),l=Et,(ur===null?l.memoizedState:ur.next)===null&&(l=l.alternate,G.H=l===null||l.memoizedState===null?cv:w0),i}function Pf(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Bd(i);if(i.$$typeof===F)return Ur(i)}throw Error(r(438,String(i)))}function h0(i){var l=null,d=Et.updateQueue;if(d!==null&&(l=d.memoCache),l==null){var m=Et.alternate;m!==null&&(m=m.updateQueue,m!==null&&(m=m.memoCache,m!=null&&(l={data:m.data.map(function(C){return C.slice()}),index:0})))}if(l==null&&(l={data:[],index:0}),d===null&&(d=Rf(),Et.updateQueue=d),d.memoCache=l,d=l.data[l.index],d===void 0)for(d=l.data[l.index]=Array(i),m=0;m<i;m++)d[m]=M;return l.index++,d}function xa(i,l){return typeof l=="function"?l(i):l}function Mf(i){var l=ir();return f0(l,hn,i)}function f0(i,l,d){var m=i.queue;if(m===null)throw Error(r(311));m.lastRenderedReducer=d;var C=i.baseQueue,v=m.pending;if(v!==null){if(C!==null){var A=C.next;
vendor: 13,720 bytes, line 48
48C.next=v.next,v.next=A}l.baseQueue=C=v,m.pending=null}if(v=i.baseState,C===null)i.memoizedState=v;else{l=C.next;var V=A=null,Z=null,ue=l,be=!1;do{var _e=ue.lane&-536870913;if(_e!==ue.lane?(Ot&_e)===_e:(ya&_e)===_e){var he=ue.revertLane;if(he===0)Z!==null&&(Z=Z.next={lane:0,revertLane:0,gesture:null,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),_e===zc&&(be=!0);else if((ya&he)===he){ue=ue.next,he===zc&&(be=!0);continue}else _e={lane:0,revertLane:ue.revertLane,gesture:null,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null},Z===null?(V=Z=_e,A=v):Z=Z.next=_e,Et.lanes|=he,bo|=he;_e=ue.action,Ul&&d(v,_e),v=ue.hasEagerState?ue.eagerState:d(v,_e)}else he={lane:_e,revertLane:ue.revertLane,gesture:ue.gesture,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null},Z===null?(V=Z=he,A=v):Z=Z.next=he,Et.lanes|=_e,bo|=_e;ue=ue.next}while(ue!==null&&ue!==l);if(Z===null?A=v:Z.next=V,!Ms(v,i.memoizedState)&&(dr=!0,be&&(d=Jc,d!==null)))throw d;i.memoizedState=v,i.baseState=A,i.baseQueue=Z,m.lastRenderedState=v}return C===null&&(m.lanes=0),[i.memoizedState,m.dispatch]}function m0(i){var l=ir(),d=l.queue;if(d===null)throw Error(r(311));d.lastRenderedReducer=i;var m=d.dispatch,C=d.pending,v=l.memoizedState;if(C!==null){d.pending=null;var A=C=C.next;do v=i(v,A.action),A=A.next;while(A!==C);Ms(v,l.memoizedState)||(dr=!0),l.memoizedState=v,l.baseQueue===null&&(l.baseState=v),d.lastRenderedState=v}return[v,m]}function Sb(i,l,d){var m=Et,C=ir(),v=Vt;if(v){if(d===void 0)throw Error(r(407));d=d()}else d=l();var A=!Ms((hn||C).memoizedState,d);if(A&&(C.memoizedState=d,dr=!0),C=C.queue,B0(Ib.bind(null,m,C,i),[i]),C.getSnapshot!==l||A||ur!==null&&ur.memoizedState.tag&1){if(m.flags|=2048,Xc(9,{destroy:void 0},Ab.bind(null,m,C,d,l),null),gn===null)throw Error(r(349));v||(ya&127)!==0||Db(m,l,d)}return d}function Db(i,l,d){i.flags|=16384,i={getSnapshot:l,value:d},l=Et.updateQueue,l===null?(l=Rf(),Et.updateQueue=l,l.stores=[i]):(d=l.stores,d===null?l.stores=[i]:d.push(i))}function Ab(i,l,d,m){l.value=d,l.getSnapshot=m,Rb(l)&&Pb(i)}function Ib(i,l,d){return d(function(){Rb(l)&&Pb(i)})}function Rb(i){var l=i.getSnapshot;i=i.value;try{var d=l();return!Ms(i,d)}catch{return!0}}function Pb(i){var l=Al(i,2);l!==null&&bs(l,i,2)}function g0(i){var l=ls();if(typeof i=="function"){var d=i;if(i=d(),Ul){it(!0);try{d()}finally{it(!1)}}}return l.memoizedState=l.baseState=i,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:xa,lastRenderedState:i},l}function Mb(i,l,d,m){return i.baseState=d,f0(i,hn,typeof m=="function"?m:xa)}function XI(i,l,d,m,C){if(Of(i))throw Error(r(485));if(i=l.action,i!==null){var v={payload:C,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(A){v.listeners.push(A)}};G.T!==null?d(!0):v.isTransition=!1,m(v),d=l.pending,d===null?(v.next=l.pending=v,Lb(l,v)):(v.next=d.next,l.pending=d.next=v)}}function Lb(i,l){var d=l.action,m=l.payload,C=i.state;if(l.isTransition){var v=G.T,A={};G.T=A;try{var V=d(C,m),Z=G.S;Z!==null&&Z(A,V),jb(i,l,V)}catch(ue){p0(i,l,ue)}finally{v!==null&&A.types!==null&&(v.types=A.types),G.T=v}}else try{v=d(C,m),jb(i,l,v)}catch(ue){p0(i,l,ue)}}function jb(i,l,d){d!==null&&typeof d=="object"&&typeof d.then=="function"?d.then(function(m){Ob(i,l,m)},function(m){return p0(i,l,m)}):Ob(i,l,d)}function Ob(i,l,d){l.status="fulfilled",l.value=d,Fb(l),i.state=d,l=i.pending,l!==null&&(d=l.next,d===l?i.pending=null:(d=d.next,l.next=d,Lb(i,d)))}function p0(i,l,d){var m=i.pending;if(i.pending=null,m!==null){m=m.next;do l.status="rejected",l.reason=d,Fb(l),l=l.next;while(l!==m)}i.action=null}function Fb(i){i=i.listeners;for(var l=0;l<i.length;l++)(0,i[l])()}function Ub(i,l){return l}function Vb(i,l){if(Vt){var d=gn.formState;if(d!==null){e:{var m=Et;if(Vt){if(kn){t:{for(var C=kn,v=li;C.nodeType!==8;){if(!v){C=null;break t}if(C=ui(C.nextSibling),C===null){C=null;break t}}v=C.data,C=v==="F!"||v==="F"?C:null}if(C){kn=ui(C.nextSibling),m=C.data==="F!";break e}}ho(m)}m=!1}m&&(l=d[0])}}return d=ls(),d.memoizedState=d.baseState=l,m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ub,lastRenderedState:l},d.queue=m,d=av.bind(null,Et,m),m.dispatch=d,m=g0(!1),v=v0.bind(null,Et,!1,m.queue),m=ls(),C={state:l,dispatch:null,action:i,pending:null},m.queue=C,d=XI.bind(null,Et,C,v,d),C.dispatch=d,m.memoizedState=i,[l,d,!1]}function Gb(i){var l=ir();return Hb(l,hn,i)}function Hb(i,l,d){if(l=f0(i,l,Ub)[0],i=Mf(xa)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var m=Bd(l)}catch(A){throw A===$c?_f:A}else m=l;l=ir();var C=l.queue,v=C.dispatch;return d!==l.memoizedState&&(Et.flags|=2048,Xc(9,{destroy:void 0},ZI.bind(null,C,d),null)),[m,v,i]}function ZI(i,l){i.action=l}function qb(i){var l=ir(),d=hn;if(d!==null)return Hb(l,d,i);ir(),l=l.memoizedState,d=ir();var m=d.queue.dispatch;return d.memoizedState=i,[l,m,!1]}function Xc(i,l,d,m){return i={tag:i,create:d,deps:m,inst:l,next:null},l=Et.updateQueue,l===null&&(l=Rf(),Et.updateQueue=l),d=l.lastEffect,d===null?l.lastEffect=i.next=i:(m=d.next,d.next=i,i.next=m,l.lastEffect=i),i}function zb(){return ir().memoizedState}function Lf(i,l,d,m){var C=ls();Et.flags|=i,C.memoizedState=Xc(1|l,{destroy:void 0},d,m===void 0?null:m)}function jf(i,l,d,m){var C=ir();m=m===void 0?null:m;var v=C.memoizedState.inst;hn!==null&&m!==null&&o0(m,hn.memoizedState.deps)?C.memoizedState=Xc(l,v,d,m):(Et.flags|=i,C.memoizedState=Xc(1|l,v,d,m))}function Jb(i,l){Lf(8390656,8,i,l)}function B0(i,l){jf(2048,8,i,l)}function e2(i){Et.flags|=4;var l=Et.updateQueue;if(l===null)l=Rf(),Et.updateQueue=l,l.events=[i];else{var d=l.events;d===null?l.events=[i]:d.push(i)}}function $b(i){var l=ir().memoizedState;return e2({ref:l,nextImpl:i}),function(){if((rn&2)!==0)throw Error(r(440));return l.impl.apply(void 0,arguments)}}function Kb(i,l){return jf(4,2,i,l)}function Yb(i,l){return jf(4,4,i,l)}function Qb(i,l){if(typeof l=="function"){i=i();var d=l(i);return function(){typeof d=="function"?d():l(null)}}if(l!=null)return i=i(),l.current=i,function(){l.current=null}}function Wb(i,l,d){d=d!=null?d.concat([i]):null,jf(4,4,Qb.bind(null,l,i),d)}function y0(){}function Xb(i,l){var d=ir();l=l===void 0?null:l;var m=d.memoizedState;return l!==null&&o0(l,m[1])?m[0]:(d.memoizedState=[i,l],i)}function Zb(i,l){var d=ir();l=l===void 0?null:l;var m=d.memoizedState;if(l!==null&&o0(l,m[1]))return m[0];if(m=i(),Ul){it(!0);try{i()}finally{it(!1)}}return d.memoizedState=[m,l],m}function x0(i,l,d){return d===void 0||(ya&1073741824)!==0&&(Ot&261930)===0?i.memoizedState=l:(i.memoizedState=d,i=ew(),Et.lanes|=i,bo|=i,d)}function ev(i,l,d,m){return Ms(d,l)?d:Yc.current!==null?(i=x0(i,d,m),Ms(i,l)||(dr=!0),i):(ya&42)===0||(ya&1073741824)!==0&&(Ot&261930)===0?(dr=!0,i.memoizedState=d):(i=ew(),Et.lanes|=i,bo|=i,l)}function tv(i,l,d,m,C){var v=W.p;W.p=v!==0&&8>v?v:8;var A=G.T,V={};G.T=V,v0(i,!1,l,d);try{var Z=C(),ue=G.S;if(ue!==null&&ue(V,Z),Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var be=YI(Z,m);yd(i,l,be,Vs(i))}else yd(i,l,m,Vs(i))}catch(_e){yd(i,l,{then:function(){},status:"rejected",reason:_e},Vs())}finally{W.p=v,A!==null&&V.types!==null&&(A.types=V.types),G.T=A}}function t2(){}function C0(i,l,d,m){if(i.tag!==5)throw Error(r(476));var C=nv(i).queue;tv(i,C,l,X,d===null?t2:function(){return rv(i),d(m)})}function nv(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:xa,lastRenderedState:X},next:null};var d={};return l.next={memoizedState:d,baseState:d,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:xa,lastRenderedState:d},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function rv(i){var l=nv(i);l.next===null&&(l=i.alternate.memoizedState),yd(i,l.next.queue,{},Vs())}function b0(){return Ur(Md)}function sv(){return ir().memoizedState}function iv(){return ir().memoizedState}function n2(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var d=Vs();i=go(d);var m=po(l,i,d);m!==null&&(bs(m,l,d),fd(m,l,d)),l={cache:Qp()},i.payload=l;return}l=l.return}}function r2(i,l,d){var m=Vs();d={lane:m,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Of(i)?ov(l,d):(d=Fp(i,l,d,m),d!==null&&(bs(d,i,m),lv(d,l,m)))}function av(i,l,d){var m=Vs();yd(i,l,d,m)}function yd(i,l,d,m){var C={lane:m,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null};if(Of(i))ov(l,C);else{var v=i.alternate;if(i.lanes===0&&(v===null||v.lanes===0)&&(v=l.lastRenderedReducer,v!==null))try{var A=l.lastRenderedState,V=v(A,d);if(C.hasEagerState=!0,C.eagerState=V,Ms(V,A))return yf(i,l,C,0),gn===null&&Bf(),!1}catch{}finally{}if(d=Fp(i,l,C,m),d!==null)return bs(d,i,m),lv(d,l,m),!0}return!1}function v0(i,l,d,m){if(m={lane:2,revertLane:eB(),gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},Of(i)){if(l)throw Error(r(479))}else l=Fp(i,d,m,2),l!==null&&bs(l,i,2)}function Of(i){var l=i.alternate;return i===Et||l!==null&&l===Et}function ov(i,l){Qc=Af=!0;var d=i.pending;d===null?l.next=l:(l.next=d.next,d.next=l),i.pending=l}function lv(i,l,d){if((d&4194048)!==0){var m=l.lanes;m&=i.pendingLanes,d|=m,l.lanes=d,rs(i,d)}}var xd={readContext:Ur,use:Pf,useCallback:Wn,useContext:Wn,useEffect:Wn,useImperativeHandle:Wn,useLayoutEffect:Wn,useInsertionEffect:Wn,useMemo:Wn,useReducer:Wn,useRef:Wn,useState:Wn,useDebugValue:Wn,useDeferredValue:Wn,useTransition:Wn,useSyncExternalStore:Wn,useId:Wn,useHostTransitionStatus:Wn,useFormState:Wn,useActionState:Wn,useOptimistic:Wn,useMemoCache:Wn,useCacheRefresh:Wn};xd.useEffectEvent=Wn;var cv={readContext:Ur,use:Pf,useCallback:function(i,l){return ls().memoizedState=[i,l===void 0?null:l],i},useContext:Ur,useEffect:Jb,useImperativeHandle:function(i,l,d){d=d!=null?d.concat([i]):null,Lf(4194308,4,Qb.bind(null,l,i),d)},useLayoutEffect:function(i,l){return Lf(4194308,4,i,l)},useInsertionEffect:function(i,l){Lf(4,2,i,l)},useMemo:function(i,l){var d=ls();l=l===void 0?null:l;var m=i();if(Ul){it(!0);try{i()}finally{it(!1)}}return d.memoizedState=[m,l],m},useReducer:function(i,l,d){var m=ls();if(d!==void 0){var C=d(l);if(Ul){it(!0);try{d(l)}finally{it(!1)}}}else C=l;return m.memoizedState=m.baseState=C,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:C},m.queue=i,i=i.dispatch=r2.bind(null,Et,i),[m.memoizedState,i]},useRef:function(i){var l=ls();return i={current:i},l.memoizedState=i},useState:function(i){i=g0(i);var l=i.queue,d=av.bind(null,Et,l);return l.dispatch=d,[i.memoizedState,d]},useDebugValue:y0,useDeferredValue:function(i,l){var d=ls();return x0(d,i,l)},useTransition:function(){var i=g0(!1);return i=tv.bind(null,Et,i.queue,!0,!1),ls().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,d){var m=Et,C=ls();if(Vt){if(d===void 0)throw Error(r(407));d=d()}else{if(d=l(),gn===null)throw Error(r(349));(Ot&127)!==0||Db(m,l,d)}C.memoizedState=d;var v={value:d,getSnapshot:l};return C.queue=v,Jb(Ib.bind(null,m,v,i),[i]),m.flags|=2048,Xc(9,{destroy:void 0},Ab.bind(null,m,v,d,l),null),d},useId:function(){var i=ls(),l=gn.identifierPrefix;if(Vt){var d=zi,m=qi;d=(m&~(1<<32-jt(m)-1)).toString(32)+d,l="_"+l+"R_"+d,d=If++,0<d&&(l+="H"+d.toString(32)),l+="_"}else d=QI++,l="_"+l+"r_"+d.toString(32)+"_";return i.memoizedState=l},useHostTransitionStatus:b0,useFormState:Vb,useActionState:Vb,useOptimistic:function(i){var l=ls();l.memoizedState=l.baseState=i;var d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=d,l=v0.bind(null,Et,!0,d),d.dispatch=l,[i,l]},useMemoCache:h0,useCacheRefresh:function(){return ls().memoizedState=n2.bind(null,Et)},useEffectEvent:function(i){var l=ls(),d={impl:i};return l.memoizedState=d,function(){if((rn&2)!==0)throw Error(r(440));return d.impl.apply(void 0,arguments)}}},w0={readContext:Ur,use:Pf,useCallback:Xb,useContext:Ur,useEffect:B0,useImperativeHandle:Wb,useInsertionEffect:Kb,useLayoutEffect:Yb,useMemo:Zb,useReducer:Mf,useRef:zb,useState:function(){return Mf(xa)},useDebugValue:y0,useDeferredValue:function(i,l){var d=ir();return ev(d,hn.memoizedState,i,l)},useTransition:function(){var i=Mf(xa)[0],l=ir().memoizedState;return[typeof i=="boolean"?i:Bd(i),l]},useSyncExternalStore:Sb,useId:sv,useHostTransitionStatus:b0,useFormState:Gb,useActionState:Gb,useOptimistic:function(i,l){var d=ir();return Mb(d,hn,i,l)},useMemoCache:h0,useCacheRefresh:iv};w0.useEffectEvent=$b;var uv={readContext:Ur,use:Pf,useCallback:Xb,useContext:Ur,useEffect:B0,useImperativeHandle:Wb,useInsertionEffect:Kb,useLayoutEffect:Yb,useMemo:Zb,useReducer:m0,useRef:zb,useState:function(){return m0(xa)},useDebugValue:y0,useDeferredValue:function(i,l){var d=ir();return hn===null?x0(d,i,l):ev(d,hn.memoizedState,i,l)},useTransition:function(){var i=m0(xa)[0],l=ir().memoizedState;return[typeof i=="boolean"?i:Bd(i),l]},useSyncExternalStore:Sb,useId:sv,useHostTransitionStatus:b0,useFormState:qb,useActionState:qb,useOptimistic:function(i,l){var d=ir();return hn!==null?Mb(d,hn,i,l):(d.baseState=i,[i,d.queue.dispatch])},useMemoCache:h0,useCacheRefresh:iv};uv.useEffectEvent=$b;function E0(i,l,d,m){l=i.memoizedState,d=d(m,l),d=d==null?l:y({},l,d),i.memoizedState=d,i.lanes===0&&(i.updateQueue.baseState=d)}var _0={enqueueSetState:function(i,l,d){i=i._reactInternals;var m=Vs(),C=go(m);C.payload=l,d!=null&&(C.callback=d),l=po(i,C,m),l!==null&&(bs(l,i,m),fd(l,i,m))},enqueueReplaceState:function(i,l,d){i=i._reactInternals;var m=Vs(),C=go(m);C.tag=1,C.payload=l,d!=null&&(C.callback=d),l=po(i,C,m),l!==null&&(bs(l,i,m),fd(l,i,m))},enqueueForceUpdate:function(i,l){i=i._reactInternals;var d=Vs(),m=go(d);
vendor: 16,585 bytes, line 48
48m.tag=2,l!=null&&(m.callback=l),l=po(i,m,d),l!==null&&(bs(l,i,d),fd(l,i,d))}};function dv(i,l,d,m,C,v,A){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(m,v,A):l.prototype&&l.prototype.isPureReactComponent?!id(d,m)||!id(C,v):!0}function hv(i,l,d,m){i=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(d,m),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(d,m),l.state!==i&&_0.enqueueReplaceState(l,l.state,null)}function Vl(i,l){var d=l;if("ref"in l){d={};for(var m in l)m!=="ref"&&(d[m]=l[m])}if(i=i.defaultProps){d===l&&(d=y({},d));for(var C in i)d[C]===void 0&&(d[C]=i[C])}return d}function fv(i){pf(i)}function mv(i){console.error(i)}function gv(i){pf(i)}function Ff(i,l){try{var d=i.onUncaughtError;d(l.value,{componentStack:l.stack})}catch(m){setTimeout(function(){throw m})}}function pv(i,l,d){try{var m=i.onCaughtError;m(d.value,{componentStack:d.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(C){setTimeout(function(){throw C})}}function T0(i,l,d){return d=go(d),d.tag=3,d.payload={element:null},d.callback=function(){Ff(i,l)},d}function Bv(i){return i=go(i),i.tag=3,i}function yv(i,l,d,m){var C=d.type.getDerivedStateFromError;if(typeof C=="function"){var v=m.value;i.payload=function(){return C(v)},i.callback=function(){pv(l,d,m)}}var A=d.stateNode;A!==null&&typeof A.componentDidCatch=="function"&&(i.callback=function(){pv(l,d,m),typeof C!="function"&&(vo===null?vo=new Set([this]):vo.add(this));var V=m.stack;this.componentDidCatch(m.value,{componentStack:V!==null?V:""})})}function s2(i,l,d,m,C){if(d.flags|=32768,m!==null&&typeof m=="object"&&typeof m.then=="function"){if(l=d.alternate,l!==null&&qc(l,d,C,!0),d=js.current,d!==null){switch(d.tag){case 31:case 13:return ci===null?Wf():d.alternate===null&&Xn===0&&(Xn=3),d.flags&=-257,d.flags|=65536,d.lanes=C,m===Tf?d.flags|=16384:(l=d.updateQueue,l===null?d.updateQueue=new Set([m]):l.add(m),W0(i,m,C)),!1;case 22:return d.flags|=65536,m===Tf?d.flags|=16384:(l=d.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([m])},d.updateQueue=l):(d=l.retryQueue,d===null?l.retryQueue=new Set([m]):d.add(m)),W0(i,m,C)),!1}throw Error(r(435,d.tag))}return W0(i,m,C),Wf(),!1}if(Vt)return l=js.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=C,m!==zp&&(i=Error(r(422),{cause:m}),ld(ii(i,d)))):(m!==zp&&(l=Error(r(423),{cause:m}),ld(ii(l,d))),i=i.current.alternate,i.flags|=65536,C&=-C,i.lanes|=C,m=ii(m,d),C=T0(i.stateNode,m,C),n0(i,C),Xn!==4&&(Xn=2)),!1;var v=Error(r(520),{cause:m});if(v=ii(v,d),kd===null?kd=[v]:kd.push(v),Xn!==4&&(Xn=2),l===null)return!0;m=ii(m,d),d=l;do{switch(d.tag){case 3:return d.flags|=65536,i=C&-C,d.lanes|=i,i=T0(d.stateNode,m,i),n0(d,i),!1;case 1:if(l=d.type,v=d.stateNode,(d.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(vo===null||!vo.has(v))))return d.flags|=65536,C&=-C,d.lanes|=C,C=Bv(C),yv(C,i,d,m),n0(d,C),!1}d=d.return}while(d!==null);return!1}var k0=Error(r(461)),dr=!1;function Vr(i,l,d,m){l.child=i===null?vb(l,null,d,m):Fl(l,i.child,d,m)}function xv(i,l,d,m,C){d=d.render;var v=l.ref;if("ref"in m){var A={};for(var V in m)V!=="ref"&&(A[V]=m[V])}else A=m;return Ml(l),m=l0(i,l,d,A,v,C),V=c0(),i!==null&&!dr?(u0(i,l,C),Ca(i,l,C)):(Vt&&V&&Hp(l),l.flags|=1,Vr(i,l,m,C),l.child)}function Cv(i,l,d,m,C){if(i===null){var v=d.type;return typeof v=="function"&&!Up(v)&&v.defaultProps===void 0&&d.compare===null?(l.tag=15,l.type=v,bv(i,l,v,m,C)):(i=Cf(d.type,null,m,l,l.mode,C),i.ref=l.ref,i.return=l,l.child=i)}if(v=i.child,!M0(i,C)){var A=v.memoizedProps;if(d=d.compare,d=d!==null?d:id,d(A,m)&&i.ref===l.ref)return Ca(i,l,C)}return l.flags|=1,i=ma(v,m),i.ref=l.ref,i.return=l,l.child=i}function bv(i,l,d,m,C){if(i!==null){var v=i.memoizedProps;if(id(v,m)&&i.ref===l.ref)if(dr=!1,l.pendingProps=m=v,M0(i,C))(i.flags&131072)!==0&&(dr=!0);else return l.lanes=i.lanes,Ca(i,l,C)}return N0(i,l,d,m,C)}function vv(i,l,d,m){var C=m.children,v=i!==null?i.memoizedState:null;if(i===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.mode==="hidden"){if((l.flags&128)!==0){if(v=v!==null?v.baseLanes|d:d,i!==null){for(m=l.child=i.child,C=0;m!==null;)C=C|m.lanes|m.childLanes,m=m.sibling;m=C&~v}else m=0,l.child=null;return wv(i,l,v,d,m)}if((d&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},i!==null&&Ef(l,v!==null?v.cachePool:null),v!==null?_b(l,v):s0(),Tb(l);else return m=l.lanes=536870912,wv(i,l,v!==null?v.baseLanes|d:d,d,m)}else v!==null?(Ef(l,v.cachePool),_b(l,v),yo(),l.memoizedState=null):(i!==null&&Ef(l,null),s0(),yo());return Vr(i,l,C,d),l.child}function Cd(i,l){return i!==null&&i.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function wv(i,l,d,m,C){var v=Xp();return v=v===null?null:{parent:cr._currentValue,pool:v},l.memoizedState={baseLanes:d,cachePool:v},i!==null&&Ef(l,null),s0(),Tb(l),i!==null&&qc(i,l,m,!0),l.childLanes=C,null}function Uf(i,l){return l=Gf({mode:l.mode,children:l.children},i.mode),l.ref=i.ref,i.child=l,l.return=i,l}function Ev(i,l,d){return Fl(l,i.child,null,d),i=Uf(l,l.pendingProps),i.flags|=2,Os(l),l.memoizedState=null,i}function i2(i,l,d){var m=l.pendingProps,C=(l.flags&128)!==0;if(l.flags&=-129,i===null){if(Vt){if(m.mode==="hidden")return i=Uf(l,m),l.lanes=536870912,Cd(null,i);if(a0(l),(i=kn)?(i=Lw(i,li),i=i!==null&&i.data==="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:co!==null?{id:qi,overflow:zi}:null,retryLane:536870912,hydrationErrors:null},d=ob(i),d.return=l,l.child=d,Fr=l,kn=null)):i=null,i===null)throw ho(l);return l.lanes=536870912,null}return Uf(l,m)}var v=i.memoizedState;if(v!==null){var A=v.dehydrated;if(a0(l),C)if(l.flags&256)l.flags&=-257,l=Ev(i,l,d);else if(l.memoizedState!==null)l.child=i.child,l.flags|=128,l=null;else throw Error(r(558));else if(dr||qc(i,l,d,!1),C=(d&i.childLanes)!==0,dr||C){if(m=gn,m!==null&&(A=Hn(m,d),A!==0&&A!==v.retryLane))throw v.retryLane=A,Al(i,A),bs(m,i,A),k0;Wf(),l=Ev(i,l,d)}else i=v.treeContext,kn=ui(A.nextSibling),Fr=l,Vt=!0,uo=null,li=!1,i!==null&&ub(l,i),l=Uf(l,m),l.flags|=4096;return l}return i=ma(i.child,{mode:m.mode,children:m.children}),i.ref=l.ref,l.child=i,i.return=l,i}function Vf(i,l){var d=l.ref;if(d===null)i!==null&&i.ref!==null&&(l.flags|=4194816);else{if(typeof d!="function"&&typeof d!="object")throw Error(r(284));(i===null||i.ref!==d)&&(l.flags|=4194816)}}function N0(i,l,d,m,C){return Ml(l),d=l0(i,l,d,m,void 0,C),m=c0(),i!==null&&!dr?(u0(i,l,C),Ca(i,l,C)):(Vt&&m&&Hp(l),l.flags|=1,Vr(i,l,d,C),l.child)}function _v(i,l,d,m,C,v){return Ml(l),l.updateQueue=null,d=Nb(l,m,d,C),kb(i),m=c0(),i!==null&&!dr?(u0(i,l,v),Ca(i,l,v)):(Vt&&m&&Hp(l),l.flags|=1,Vr(i,l,d,v),l.child)}function Tv(i,l,d,m,C){if(Ml(l),l.stateNode===null){var v=Uc,A=d.contextType;typeof A=="object"&&A!==null&&(v=Ur(A)),v=new d(m,v),l.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,v.updater=_0,l.stateNode=v,v._reactInternals=l,v=l.stateNode,v.props=m,v.state=l.memoizedState,v.refs={},e0(l),A=d.contextType,v.context=typeof A=="object"&&A!==null?Ur(A):Uc,v.state=l.memoizedState,A=d.getDerivedStateFromProps,typeof A=="function"&&(E0(l,d,A,m),v.state=l.memoizedState),typeof d.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(A=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),A!==v.state&&_0.enqueueReplaceState(v,v.state,null),gd(l,m,v,C),md(),v.state=l.memoizedState),typeof v.componentDidMount=="function"&&(l.flags|=4194308),m=!0}else if(i===null){v=l.stateNode;var V=l.memoizedProps,Z=Vl(d,V);v.props=Z;var ue=v.context,be=d.contextType;A=Uc,typeof be=="object"&&be!==null&&(A=Ur(be));var _e=d.getDerivedStateFromProps;be=typeof _e=="function"||typeof v.getSnapshotBeforeUpdate=="function",V=l.pendingProps!==V,be||typeof v.UNSAFE_componentWillReceiveProps!="function"&&typeof v.componentWillReceiveProps!="function"||(V||ue!==A)&&hv(l,v,m,A),mo=!1;var he=l.memoizedState;v.state=he,gd(l,m,v,C),md(),ue=l.memoizedState,V||he!==ue||mo?(typeof _e=="function"&&(E0(l,d,_e,m),ue=l.memoizedState),(Z=mo||dv(l,d,Z,m,he,ue,A))?(be||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount()),typeof v.componentDidMount=="function"&&(l.flags|=4194308)):(typeof v.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=m,l.memoizedState=ue),v.props=m,v.state=ue,v.context=A,m=Z):(typeof v.componentDidMount=="function"&&(l.flags|=4194308),m=!1)}else{v=l.stateNode,t0(i,l),A=l.memoizedProps,be=Vl(d,A),v.props=be,_e=l.pendingProps,he=v.context,ue=d.contextType,Z=Uc,typeof ue=="object"&&ue!==null&&(Z=Ur(ue)),V=d.getDerivedStateFromProps,(ue=typeof V=="function"||typeof v.getSnapshotBeforeUpdate=="function")||typeof v.UNSAFE_componentWillReceiveProps!="function"&&typeof v.componentWillReceiveProps!="function"||(A!==_e||he!==Z)&&hv(l,v,m,Z),mo=!1,he=l.memoizedState,v.state=he,gd(l,m,v,C),md();var pe=l.memoizedState;A!==_e||he!==pe||mo||i!==null&&i.dependencies!==null&&vf(i.dependencies)?(typeof V=="function"&&(E0(l,d,V,m),pe=l.memoizedState),(be=mo||dv(l,d,be,m,he,pe,Z)||i!==null&&i.dependencies!==null&&vf(i.dependencies))?(ue||typeof v.UNSAFE_componentWillUpdate!="function"&&typeof v.componentWillUpdate!="function"||(typeof v.componentWillUpdate=="function"&&v.componentWillUpdate(m,pe,Z),typeof v.UNSAFE_componentWillUpdate=="function"&&v.UNSAFE_componentWillUpdate(m,pe,Z)),typeof v.componentDidUpdate=="function"&&(l.flags|=4),typeof v.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof v.componentDidUpdate!="function"||A===i.memoizedProps&&he===i.memoizedState||(l.flags|=4),typeof v.getSnapshotBeforeUpdate!="function"||A===i.memoizedProps&&he===i.memoizedState||(l.flags|=1024),l.memoizedProps=m,l.memoizedState=pe),v.props=m,v.state=pe,v.context=Z,m=be):(typeof v.componentDidUpdate!="function"||A===i.memoizedProps&&he===i.memoizedState||(l.flags|=4),typeof v.getSnapshotBeforeUpdate!="function"||A===i.memoizedProps&&he===i.memoizedState||(l.flags|=1024),m=!1)}return v=m,Vf(i,l),m=(l.flags&128)!==0,v||m?(v=l.stateNode,d=m&&typeof d.getDerivedStateFromError!="function"?null:v.render(),l.flags|=1,i!==null&&m?(l.child=Fl(l,i.child,null,C),l.child=Fl(l,null,d,C)):Vr(i,l,d,C),l.memoizedState=v.state,i=l.child):i=Ca(i,l,C),i}function kv(i,l,d,m){return Rl(),l.flags|=256,Vr(i,l,d,m),l.child}var S0={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function D0(i){return{baseLanes:i,cachePool:pb()}}function A0(i,l,d){return i=i!==null?i.childLanes&~d:0,l&&(i|=Us),i}function Nv(i,l,d){var m=l.pendingProps,C=!1,v=(l.flags&128)!==0,A;if((A=v)||(A=i!==null&&i.memoizedState===null?!1:(sr.current&2)!==0),A&&(C=!0,l.flags&=-129),A=(l.flags&32)!==0,l.flags&=-33,i===null){if(Vt){if(C?Bo(l):yo(),(i=kn)?(i=Lw(i,li),i=i!==null&&i.data!=="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:co!==null?{id:qi,overflow:zi}:null,retryLane:536870912,hydrationErrors:null},d=ob(i),d.return=l,l.child=d,Fr=l,kn=null)):i=null,i===null)throw ho(l);return fB(i)?l.lanes=32:l.lanes=536870912,null}var V=m.children;return m=m.fallback,C?(yo(),C=l.mode,V=Gf({mode:"hidden",children:V},C),m=Il(m,C,d,null),V.return=l,m.return=l,V.sibling=m,l.child=V,m=l.child,m.memoizedState=D0(d),m.childLanes=A0(i,A,d),l.memoizedState=S0,Cd(null,m)):(Bo(l),I0(l,V))}var Z=i.memoizedState;if(Z!==null&&(V=Z.dehydrated,V!==null)){if(v)l.flags&256?(Bo(l),l.flags&=-257,l=R0(i,l,d)):l.memoizedState!==null?(yo(),l.child=i.child,l.flags|=128,l=null):(yo(),V=m.fallback,C=l.mode,m=Gf({mode:"visible",children:m.children},C),V=Il(V,C,d,null),V.flags|=2,m.return=l,V.return=l,m.sibling=V,l.child=m,Fl(l,i.child,null,d),m=l.child,m.memoizedState=D0(d),m.childLanes=A0(i,A,d),l.memoizedState=S0,l=Cd(null,m));else if(Bo(l),fB(V)){if(A=V.nextSibling&&V.nextSibling.dataset,A)var ue=A.dgst;A=ue,m=Error(r(419)),m.stack="",m.digest=A,ld({value:m,source:null,stack:null}),l=R0(i,l,d)}else if(dr||qc(i,l,d,!1),A=(d&i.childLanes)!==0,dr||A){if(A=gn,A!==null&&(m=Hn(A,d),m!==0&&m!==Z.retryLane))throw Z.retryLane=m,Al(i,m),bs(A,i,m),k0;hB(V)||Wf(),l=R0(i,l,d)}else hB(V)?(l.flags|=192,l.child=i.child,l=null):(i=Z.treeContext,kn=ui(V.nextSibling),Fr=l,Vt=!0,uo=null,li=!1,i!==null&&ub(l,i),l=I0(l,m.children),l.flags|=4096);return l}return C?(yo(),V=m.fallback,C=l.mode,Z=i.child,ue=Z.sibling,m=ma(Z,{mode:"hidden",children:m.children}),m.subtreeFlags=Z.subtreeFlags&65011712,ue!==null?V=ma(ue,V):(V=Il(V,C,d,null),V.flags|=2),V.return=l,m.return=l,m.sibling=V,l.child=m,Cd(null,m),m=l.child,V=i.child.memoizedState,V===null?V=D0(d):(C=V.cachePool,C!==null?(Z=cr._currentValue,C=C.parent!==Z?{parent:Z,pool:Z}:C):C=pb(),V={baseLanes:V.baseLanes|d,cachePool:C}),m.memoizedState=V,m.childLanes=A0(i,A,d),l.memoizedState=S0,Cd(i.child,m)):(Bo(l),d=i.child,i=d.sibling,d=ma(d,{mode:"visible",children:m.children}),d.return=l,d.sibling=null,i!==null&&(A=l.deletions,A===null?(l.deletions=[i],l.flags|=16):A.push(i)),l.child=d,l.memoizedState=null,d)}function I0(i,l){return l=Gf({mode:"visible",children:l},i.mode),l.return=i,i.child=l}function Gf(i,l){return i=Ls(22,i,null,l),i.lanes=0,i}function R0(i,l,d){return Fl(l,i.child,null,d),i=I0(l,l.pendingProps.children),i.flags|=2,l.memoizedState=null,i}function Sv(i,l,d){i.lanes|=l;var m=i.alternate;m!==null&&(m.lanes|=l),Kp(i.return,l,d)}function P0(i,l,d,m,C,v){var A=i.memoizedState;A===null?i.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:m,tail:d,tailMode:C,treeForkCount:v}:(A.isBackwards=l,A.rendering=null,A.renderingStartTime=0,A.last=m,A.tail=d,A.tailMode=C,A.treeForkCount=v)}function Dv(i,l,d){var m=l.pendingProps,C=m.revealOrder,v=m.tail;m=m.children;var A=sr.current,V=(A&2)!==0;if(V?(A=A&1|2,l.flags|=128):A&=1,Se(sr,A),Vr(i,l,m,d),m=Vt?od:0,!V&&i!==null&&(i.flags&128)!==0)e:for(i=l.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Sv(i,d,l);else if(i.tag===19)Sv(i,d,l);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===l)break e;for(;i.sibling===null;){if(i.return===null||i.return===l)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(C){case"forwards":for(d=l.child,C=null;d!==null;)i=d.alternate,i!==null&&Df(i)===null&&(C=d),d=d.sibling;d=C,d===null?(C=l.child,l.child=null):(C=d.sibling,d.sibling=null),P0(l,!1,C,d,v,m);break;case"backwards":case"unstable_legacy-backwards":for(d=null,C=l.child,l.child=null;C!==null;){if(i=C.alternate,i!==null&&Df(i)===null){l.child=C;break}i=C.sibling,C.sibling=d,d=C,C=i}P0(l,!0,d,null,v,m);break;case"together":P0(l,!1,null,null,void 0,m);break;default:l.memoizedState=null}return l.child}function Ca(i,l,d){if(i!==null&&(l.dependencies=i.dependencies),bo|=l.lanes,(d&l.childLanes)===0)if(i!==null){if(qc(i,l,d,!1),(d&l.childLanes)===0)return null}else return null;if(i!==null&&l.child!==i.child)throw Error(r(153));if(l.child!==null){for(i=l.child,d=ma(i,i.pendingProps),l.child=d,d.return=l;i.sibling!==null;)i=i.sibling,d=d.sibling=ma(i,i.pendingProps),d.return=l;d.sibling=null}return l.child}function M0(i,l){return(i.lanes&l)!==0?!0:(i=i.dependencies,!!(i!==null&&vf(i)))}function a2(i,l,d){switch(l.tag){case 3:Wt(l,l.stateNode.containerInfo),fo(l,cr,i.memoizedState.cache),Rl();break;case 27:case 5:Mr(l);break;case 4:Wt(l,l.stateNode.containerInfo);break;case 10:fo(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,a0(l),null;break;case 13:var m=l.memoizedState;if(m!==null)return m.dehydrated!==null?(Bo(l),l.flags|=128,null):(d&l.child.childLanes)!==0?Nv(i,l,d):(Bo(l),i=Ca(i,l,d),i!==null?i.sibling:null);Bo(l);break;case 19:var C=(i.flags&128)!==0;if(m=(d&l.childLanes)!==0,m||(qc(i,l,d,!1),m=(d&l.childLanes)!==0),C){if(m)return Dv(i,l,d);l.flags|=128}if(C=l.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),Se(sr,sr.current),m)break;return null;case 22:return l.lanes=0,vv(i,l,d,l.pendingProps);case 24:fo(l,cr,i.memoizedState.cache)}return Ca(i,l,d)}function Av(i,l,d){if(i!==null)if(i.memoizedProps!==l.pendingProps)dr=!0;else{if(!M0(i,d)&&(l.flags&128)===0)return dr=!1,a2(i,l,d);dr=(i.flags&131072)!==0}
vendor: 2,830 bytes, line 48
48else dr=!1,Vt&&(l.flags&1048576)!==0&&cb(l,od,l.index);switch(l.lanes=0,l.tag){case 16:e:{var m=l.pendingProps;if(i=jl(l.elementType),l.type=i,typeof i=="function")Up(i)?(m=Vl(i,m),l.tag=1,l=Tv(null,l,i,m,d)):(l.tag=0,l=N0(null,l,i,m,d));else{if(i!=null){var C=i.$$typeof;if(C===J){l.tag=11,l=xv(null,l,i,m,d);break e}else if(C===D){l.tag=14,l=Cv(null,l,i,m,d);break e}}throw l=ee(i)||i,Error(r(306,l,""))}}return l;case 0:return N0(i,l,l.type,l.pendingProps,d);case 1:return m=l.type,C=Vl(m,l.pendingProps),Tv(i,l,m,C,d);case 3:e:{if(Wt(l,l.stateNode.containerInfo),i===null)throw Error(r(387));m=l.pendingProps;var v=l.memoizedState;C=v.element,t0(i,l),gd(l,m,null,d);var A=l.memoizedState;if(m=A.cache,fo(l,cr,m),m!==v.cache&&Yp(l,[cr],d,!0),md(),m=A.element,v.isDehydrated)if(v={element:m,isDehydrated:!1,cache:A.cache},l.updateQueue.baseState=v,l.memoizedState=v,l.flags&256){l=kv(i,l,m,d);break e}else if(m!==C){C=ii(Error(r(424)),l),ld(C),l=kv(i,l,m,d);break e}else{switch(i=l.stateNode.containerInfo,i.nodeType){case 9:i=i.body;break;default:i=i.nodeName==="HTML"?i.ownerDocument.body:i}for(kn=ui(i.firstChild),Fr=l,Vt=!0,uo=null,li=!0,d=vb(l,null,m,d),l.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling}else{if(Rl(),m===C){l=Ca(i,l,d);break e}Vr(i,l,m,d)}l=l.child}return l;case 26:return Vf(i,l),i===null?(d=Gw(l.type,null,l.pendingProps,null))?l.memoizedState=d:Vt||(d=l.type,i=l.pendingProps,m=sm(lt.current).createElement(d),m[on]=l,m[Nt]=i,Gr(m,d,i),qn(m),l.stateNode=m):l.memoizedState=Gw(l.type,i.memoizedProps,l.pendingProps,i.memoizedState),null;case 27:return Mr(l),i===null&&Vt&&(m=l.stateNode=Fw(l.type,l.pendingProps,lt.current),Fr=l,li=!0,C=kn,To(l.type)?(mB=C,kn=ui(m.firstChild)):kn=C),Vr(i,l,l.pendingProps.children,d),Vf(i,l),i===null&&(l.flags|=4194304),l.child;case 5:return i===null&&Vt&&((C=m=kn)&&(m=L2(m,l.type,l.pendingProps,li),m!==null?(l.stateNode=m,Fr=l,kn=ui(m.firstChild),li=!1,C=!0):C=!1),C||ho(l)),Mr(l),C=l.type,v=l.pendingProps,A=i!==null?i.memoizedProps:null,m=v.children,cB(C,v)?m=null:A!==null&&cB(C,A)&&(l.flags|=32),l.memoizedState!==null&&(C=l0(i,l,WI,null,null,d),Md._currentValue=C),Vf(i,l),Vr(i,l,m,d),l.child;case 6:return i===null&&Vt&&((i=d=kn)&&(d=j2(d,l.pendingProps,li),d!==null?(l.stateNode=d,Fr=l,kn=null,i=!0):i=!1),i||ho(l)),null;case 13:return Nv(i,l,d);case 4:return Wt(l,l.stateNode.containerInfo),m=l.pendingProps,i===null?l.child=Fl(l,null,m,d):Vr(i,l,m,d),l.child;case 11:return xv(i,l,l.type,l.pendingProps,d);case 7:return Vr(i,l,l.pendingProps,d),l.child;case 8:return Vr(i,l,l.pendingProps.children,d),l.child;case 12:return Vr(i,l,l.pendingProps.children,d),l.child;case 10:return m=l.pendingProps,fo(l,l.type,m.value),Vr(i,l,m.children,d),l.child;case 9:return C=l.type._context,m=l.pendingProps.children,Ml(l),C=Ur(C),m=m(C),l.flags|=1,Vr(i,l,m,d),l.child;
vendor: 4,424 bytes, line 48
48case 14:return Cv(i,l,l.type,l.pendingProps,d);case 15:return bv(i,l,l.type,l.pendingProps,d);case 19:return Dv(i,l,d);case 31:return i2(i,l,d);case 22:return vv(i,l,d,l.pendingProps);case 24:return Ml(l),m=Ur(cr),i===null?(C=Xp(),C===null&&(C=gn,v=Qp(),C.pooledCache=v,v.refCount++,v!==null&&(C.pooledCacheLanes|=d),C=v),l.memoizedState={parent:m,cache:C},e0(l),fo(l,cr,C)):((i.lanes&d)!==0&&(t0(i,l),gd(l,null,null,d),md()),C=i.memoizedState,v=l.memoizedState,C.parent!==m?(C={parent:m,cache:m},l.memoizedState=C,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=C),fo(l,cr,m)):(m=v.cache,fo(l,cr,m),m!==C.cache&&Yp(l,[cr],d,!0))),Vr(i,l,l.pendingProps.children,d),l.child;case 29:throw l.pendingProps}throw Error(r(156,l.tag))}function ba(i){i.flags|=4}function L0(i,l,d,m,C){if((l=(i.mode&32)!==0)&&(l=!1),l){if(i.flags|=16777216,(C&335544128)===C)if(i.stateNode.complete)i.flags|=8192;else if(sw())i.flags|=8192;else throw Ol=Tf,Zp}else i.flags&=-16777217}function Iv(i,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!$w(l))if(sw())i.flags|=8192;else throw Ol=Tf,Zp}function Hf(i,l){l!==null&&(i.flags|=4),i.flags&16384&&(l=i.tag!==22?_n():536870912,i.lanes|=l,nu|=l)}function bd(i,l){if(!Vt)switch(i.tailMode){case"hidden":l=i.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?i.tail=null:d.sibling=null;break;case"collapsed":d=i.tail;for(var m=null;d!==null;)d.alternate!==null&&(m=d),d=d.sibling;m===null?l||i.tail===null?i.tail=null:i.tail.sibling=null:m.sibling=null}}function Nn(i){var l=i.alternate!==null&&i.alternate.child===i.child,d=0,m=0;if(l)for(var C=i.child;C!==null;)d|=C.lanes|C.childLanes,m|=C.subtreeFlags&65011712,m|=C.flags&65011712,C.return=i,C=C.sibling;else for(C=i.child;C!==null;)d|=C.lanes|C.childLanes,m|=C.subtreeFlags,m|=C.flags,C.return=i,C=C.sibling;return i.subtreeFlags|=m,i.childLanes=d,l}function o2(i,l,d){var m=l.pendingProps;switch(qp(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Nn(l),null;case 1:return Nn(l),null;case 3:return d=l.stateNode,m=null,i!==null&&(m=i.memoizedState.cache),l.memoizedState.cache!==m&&(l.flags|=2048),Ba(cr),Ht(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(i===null||i.child===null)&&(Hc(l)?ba(l):i===null||i.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Jp())),Nn(l),null;case 26:var C=l.type,v=l.memoizedState;return i===null?(ba(l),v!==null?(Nn(l),Iv(l,v)):(Nn(l),L0(l,C,null,m,d))):v?v!==i.memoizedState?(ba(l),Nn(l),Iv(l,v)):(Nn(l),l.flags&=-16777217):(i=i.memoizedProps,i!==m&&ba(l),Nn(l),L0(l,C,i,m,d)),null;case 27:if(br(l),d=lt.current,C=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==m&&ba(l);else{if(!m){if(l.stateNode===null)throw Error(r(166));return Nn(l),null}i=Ae.current,Hc(l)?db(l):(i=Fw(C,m,d),l.stateNode=i,ba(l))}return Nn(l),null;case 5:if(br(l),C=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==m&&ba(l);else{if(!m){if(l.stateNode===null)throw Error(r(166));return Nn(l),null}if(v=Ae.current,Hc(l))db(l);else{var A=sm(lt.current);switch(v){case 1:v=A.createElementNS("http://www.w3.org/2000/svg",C);break;case 2:v=A.createElementNS("http://www.w3.org/1998/Math/MathML",C);break;default:switch(C){case"svg":v=A.createElementNS("http://www.w3.org/2000/svg",C);break;case"math":v=A.createElementNS("http://www.w3.org/1998/Math/MathML",C);break;case"script":v=A.createElement("div"),v.innerHTML="<script><\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof m.is=="string"?A.createElement("select",{is:m.is}):A.createElement("select"),m.multiple?v.multiple=!0:m.size&&(v.size=m.size);break;default:v=typeof m.is=="string"?A.createElement(C,{is:m.is}):A.createElement(C)}}v[on]=l,v[Nt]=m;e:for(A=l.child;A!==null;){if(A.tag===5||A.tag===6)v.appendChild(A.stateNode);else if(A.tag!==4&&A.tag!==27&&A.child!==null){A.child.return=A,A=A.child;continue}if(A===l)break e;for(;A.sibling===null;){if(A.return===null||A.return===l)break e;A=A.return}A.sibling.return=A.return,A=A.sibling}l.stateNode=v;e:switch(Gr(v,C,m),C){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}m&&ba(l)}}return Nn(l),L0(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,d),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==m&&ba(l);else{if(typeof m!="string"&&l.stateNode===null)throw Error(r(166));
vendor: 24,192 bytes, line 48
48if(i=lt.current,Hc(l)){if(i=l.stateNode,d=l.memoizedProps,m=null,C=Fr,C!==null)switch(C.tag){case 27:case 5:m=C.memoizedProps}i[on]=l,i=!!(i.nodeValue===d||m!==null&&m.suppressHydrationWarning===!0||Nw(i.nodeValue,d)),i||ho(l,!0)}else i=sm(i).createTextNode(m),i[on]=l,l.stateNode=i}return Nn(l),null;case 31:if(d=l.memoizedState,i===null||i.memoizedState!==null){if(m=Hc(l),d!==null){if(i===null){if(!m)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[on]=l}else Rl(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Nn(l),i=!1}else d=Jp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),i=!0;if(!i)return l.flags&256?(Os(l),l):(Os(l),null);if((l.flags&128)!==0)throw Error(r(558))}return Nn(l),null;case 13:if(m=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(C=Hc(l),m!==null&&m.dehydrated!==null){if(i===null){if(!C)throw Error(r(318));if(C=l.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(r(317));C[on]=l}else Rl(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Nn(l),C=!1}else C=Jp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=C),C=!0;if(!C)return l.flags&256?(Os(l),l):(Os(l),null)}return Os(l),(l.flags&128)!==0?(l.lanes=d,l):(d=m!==null,i=i!==null&&i.memoizedState!==null,d&&(m=l.child,C=null,m.alternate!==null&&m.alternate.memoizedState!==null&&m.alternate.memoizedState.cachePool!==null&&(C=m.alternate.memoizedState.cachePool.pool),v=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(v=m.memoizedState.cachePool.pool),v!==C&&(m.flags|=2048)),d!==i&&d&&(l.child.flags|=8192),Hf(l,l.updateQueue),Nn(l),null);case 4:return Ht(),i===null&&sB(l.stateNode.containerInfo),Nn(l),null;case 10:return Ba(l.type),Nn(l),null;case 19:if(fe(sr),m=l.memoizedState,m===null)return Nn(l),null;if(C=(l.flags&128)!==0,v=m.rendering,v===null)if(C)bd(m,!1);else{if(Xn!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(v=Df(i),v!==null){for(l.flags|=128,bd(m,!1),i=v.updateQueue,l.updateQueue=i,Hf(l,i),l.subtreeFlags=0,i=d,d=l.child;d!==null;)ab(d,i),d=d.sibling;return Se(sr,sr.current&1|2),Vt&&ga(l,m.treeForkCount),l.child}i=i.sibling}m.tail!==null&&yn()>Kf&&(l.flags|=128,C=!0,bd(m,!1),l.lanes=4194304)}else{if(!C)if(i=Df(v),i!==null){if(l.flags|=128,C=!0,i=i.updateQueue,l.updateQueue=i,Hf(l,i),bd(m,!0),m.tail===null&&m.tailMode==="hidden"&&!v.alternate&&!Vt)return Nn(l),null}else 2*yn()-m.renderingStartTime>Kf&&d!==536870912&&(l.flags|=128,C=!0,bd(m,!1),l.lanes=4194304);m.isBackwards?(v.sibling=l.child,l.child=v):(i=m.last,i!==null?i.sibling=v:l.child=v,m.last=v)}return m.tail!==null?(i=m.tail,m.rendering=i,m.tail=i.sibling,m.renderingStartTime=yn(),i.sibling=null,d=sr.current,Se(sr,C?d&1|2:d&1),Vt&&ga(l,m.treeForkCount),i):(Nn(l),null);case 22:case 23:return Os(l),i0(),m=l.memoizedState!==null,i!==null?i.memoizedState!==null!==m&&(l.flags|=8192):m&&(l.flags|=8192),m?(d&536870912)!==0&&(l.flags&128)===0&&(Nn(l),l.subtreeFlags&6&&(l.flags|=8192)):Nn(l),d=l.updateQueue,d!==null&&Hf(l,d.retryQueue),d=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),m=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(m=l.memoizedState.cachePool.pool),m!==d&&(l.flags|=2048),i!==null&&fe(Ll),null;case 24:return d=null,i!==null&&(d=i.memoizedState.cache),l.memoizedState.cache!==d&&(l.flags|=2048),Ba(cr),Nn(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function l2(i,l){switch(qp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return Ba(cr),Ht(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return br(l),null;case 31:if(l.memoizedState!==null){if(Os(l),l.alternate===null)throw Error(r(340));Rl()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(Os(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Rl()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return fe(sr),null;case 4:return Ht(),null;case 10:return Ba(l.type),null;case 22:case 23:return Os(l),i0(),i!==null&&fe(Ll),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return Ba(cr),null;case 25:return null;default:return null}}function Rv(i,l){switch(qp(l),l.tag){case 3:Ba(cr),Ht();break;case 26:case 27:case 5:br(l);break;case 4:Ht();break;case 31:l.memoizedState!==null&&Os(l);break;case 13:Os(l);break;case 19:fe(sr);break;case 10:Ba(l.type);break;case 22:case 23:Os(l),i0(),i!==null&&fe(Ll);break;case 24:Ba(cr)}}function vd(i,l){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var C=m.next;d=C;do{if((d.tag&i)===i){m=void 0;var v=d.create,A=d.inst;m=v(),A.destroy=m}d=d.next}while(d!==C)}}catch(V){cn(l,l.return,V)}}function xo(i,l,d){try{var m=l.updateQueue,C=m!==null?m.lastEffect:null;if(C!==null){var v=C.next;m=v;do{if((m.tag&i)===i){var A=m.inst,V=A.destroy;if(V!==void 0){A.destroy=void 0,C=l;var Z=d,ue=V;try{ue()}catch(be){cn(C,Z,be)}}}m=m.next}while(m!==v)}}catch(be){cn(l,l.return,be)}}function Pv(i){var l=i.updateQueue;if(l!==null){var d=i.stateNode;try{Eb(l,d)}catch(m){cn(i,i.return,m)}}}function Mv(i,l,d){d.props=Vl(i.type,i.memoizedProps),d.state=i.memoizedState;try{d.componentWillUnmount()}catch(m){cn(i,l,m)}}function wd(i,l){try{var d=i.ref;if(d!==null){switch(i.tag){case 26:case 27:case 5:var m=i.stateNode;break;case 30:m=i.stateNode;break;default:m=i.stateNode}typeof d=="function"?i.refCleanup=d(m):d.current=m}}catch(C){cn(i,l,C)}}function Ji(i,l){var d=i.ref,m=i.refCleanup;if(d!==null)if(typeof m=="function")try{m()}catch(C){cn(i,l,C)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof d=="function")try{d(null)}catch(C){cn(i,l,C)}else d.current=null}function Lv(i){var l=i.type,d=i.memoizedProps,m=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":d.autoFocus&&m.focus();break e;case"img":d.src?m.src=d.src:d.srcSet&&(m.srcset=d.srcSet)}}catch(C){cn(i,i.return,C)}}function j0(i,l,d){try{var m=i.stateNode;D2(m,i.type,d,l),m[Nt]=l}catch(C){cn(i,i.return,C)}}function jv(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&To(i.type)||i.tag===4}function O0(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||jv(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&To(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function F0(i,l,d){var m=i.tag;if(m===5||m===6)i=i.stateNode,l?(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d).insertBefore(i,l):(l=d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,l.appendChild(i),d=d._reactRootContainer,d!=null||l.onclick!==null||(l.onclick=yi));else if(m!==4&&(m===27&&To(i.type)&&(d=i.stateNode,l=null),i=i.child,i!==null))for(F0(i,l,d),i=i.sibling;i!==null;)F0(i,l,d),i=i.sibling}function qf(i,l,d){var m=i.tag;if(m===5||m===6)i=i.stateNode,l?d.insertBefore(i,l):d.appendChild(i);else if(m!==4&&(m===27&&To(i.type)&&(d=i.stateNode),i=i.child,i!==null))for(qf(i,l,d),i=i.sibling;i!==null;)qf(i,l,d),i=i.sibling}function Ov(i){var l=i.stateNode,d=i.memoizedProps;try{for(var m=i.type,C=l.attributes;C.length;)l.removeAttributeNode(C[0]);Gr(l,m,d),l[on]=i,l[Nt]=d}catch(v){cn(i,i.return,v)}}var va=!1,hr=!1,U0=!1,Fv=typeof WeakSet=="function"?WeakSet:Set,Dr=null;function c2(i,l){if(i=i.containerInfo,oB=dm,i=WC(i),Rp(i)){if("selectionStart"in i)var d={start:i.selectionStart,end:i.selectionEnd};else e:{d=(d=i.ownerDocument)&&d.defaultView||window;var m=d.getSelection&&d.getSelection();if(m&&m.rangeCount!==0){d=m.anchorNode;var C=m.anchorOffset,v=m.focusNode;m=m.focusOffset;try{d.nodeType,v.nodeType}catch{d=null;break e}var A=0,V=-1,Z=-1,ue=0,be=0,_e=i,he=null;t:for(;;){for(var pe;_e!==d||C!==0&&_e.nodeType!==3||(V=A+C),_e!==v||m!==0&&_e.nodeType!==3||(Z=A+m),_e.nodeType===3&&(A+=_e.nodeValue.length),(pe=_e.firstChild)!==null;)he=_e,_e=pe;for(;;){if(_e===i)break t;if(he===d&&++ue===C&&(V=A),he===v&&++be===m&&(Z=A),(pe=_e.nextSibling)!==null)break;_e=he,he=_e.parentNode}_e=pe}d=V===-1||Z===-1?null:{start:V,end:Z}}else d=null}d=d||{start:0,end:0}}else d=null;for(lB={focusedElem:i,selectionRange:d},dm=!1,Dr=l;Dr!==null;)if(l=Dr,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,Dr=i;else for(;Dr!==null;){switch(l=Dr,v=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(d=0;d<i.length;d++)C=i[d],C.ref.impl=C.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&v!==null){i=void 0,d=l,C=v.memoizedProps,v=v.memoizedState,m=d.stateNode;try{var Je=Vl(d.type,C);i=m.getSnapshotBeforeUpdate(Je,v),m.__reactInternalSnapshotBeforeUpdate=i}catch(ct){cn(d,d.return,ct)}}break;case 3:if((i&1024)!==0){if(i=l.stateNode.containerInfo,d=i.nodeType,d===9)dB(i);else if(d===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":dB(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=l.sibling,i!==null){i.return=l.return,Dr=i;break}Dr=l.return}}function Uv(i,l,d){var m=d.flags;switch(d.tag){case 0:case 11:case 15:Ea(i,d),m&4&&vd(5,d);break;case 1:if(Ea(i,d),m&4)if(i=d.stateNode,l===null)try{i.componentDidMount()}catch(A){cn(d,d.return,A)}else{var C=Vl(d.type,l.memoizedProps);l=l.memoizedState;try{i.componentDidUpdate(C,l,i.__reactInternalSnapshotBeforeUpdate)}catch(A){cn(d,d.return,A)}}m&64&&Pv(d),m&512&&wd(d,d.return);break;case 3:if(Ea(i,d),m&64&&(i=d.updateQueue,i!==null)){if(l=null,d.child!==null)switch(d.child.tag){case 27:case 5:l=d.child.stateNode;break;case 1:l=d.child.stateNode}try{Eb(i,l)}catch(A){cn(d,d.return,A)}}break;case 27:l===null&&m&4&&Ov(d);case 26:case 5:Ea(i,d),l===null&&m&4&&Lv(d),m&512&&wd(d,d.return);break;case 12:Ea(i,d);break;case 31:Ea(i,d),m&4&&Hv(i,d);break;case 13:Ea(i,d),m&4&&qv(i,d),m&64&&(i=d.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(d=y2.bind(null,d),O2(i,d))));break;case 22:if(m=d.memoizedState!==null||va,!m){l=l!==null&&l.memoizedState!==null||hr,C=va;var v=hr;va=m,(hr=l)&&!v?_a(i,d,(d.subtreeFlags&8772)!==0):Ea(i,d),va=C,hr=v}break;case 30:break;default:Ea(i,d)}}function Vv(i){var l=i.alternate;l!==null&&(i.alternate=null,Vv(l)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(l=i.stateNode,l!==null&&Ws(l)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var Ln=null,Bs=!1;function wa(i,l,d){for(d=d.child;d!==null;)Gv(i,l,d),d=d.sibling}function Gv(i,l,d){if(Qe&&typeof Qe.onCommitFiberUnmount=="function")try{Qe.onCommitFiberUnmount(ht,d)}catch{}switch(d.tag){case 26:hr||Ji(d,l),wa(i,l,d),d.memoizedState?d.memoizedState.count--:d.stateNode&&(d=d.stateNode,d.parentNode.removeChild(d));break;case 27:hr||Ji(d,l);var m=Ln,C=Bs;To(d.type)&&(Ln=d.stateNode,Bs=!1),wa(i,l,d),Id(d.stateNode),Ln=m,Bs=C;break;case 5:hr||Ji(d,l);case 6:if(m=Ln,C=Bs,Ln=null,wa(i,l,d),Ln=m,Bs=C,Ln!==null)if(Bs)try{(Ln.nodeType===9?Ln.body:Ln.nodeName==="HTML"?Ln.ownerDocument.body:Ln).removeChild(d.stateNode)}catch(v){cn(d,l,v)}else try{Ln.removeChild(d.stateNode)}catch(v){cn(d,l,v)}break;case 18:Ln!==null&&(Bs?(i=Ln,Pw(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,d.stateNode),uu(i)):Pw(Ln,d.stateNode));break;case 4:m=Ln,C=Bs,Ln=d.stateNode.containerInfo,Bs=!0,wa(i,l,d),Ln=m,Bs=C;break;case 0:case 11:case 14:case 15:xo(2,d,l),hr||xo(4,d,l),wa(i,l,d);break;case 1:hr||(Ji(d,l),m=d.stateNode,typeof m.componentWillUnmount=="function"&&Mv(d,l,m)),wa(i,l,d);break;case 21:wa(i,l,d);break;case 22:hr=(m=hr)||d.memoizedState!==null,wa(i,l,d),hr=m;break;default:wa(i,l,d)}}function Hv(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{uu(i)}catch(d){cn(l,l.return,d)}}}function qv(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{uu(i)}catch(d){cn(l,l.return,d)}}function u2(i){switch(i.tag){case 31:case 13:case 19:var l=i.stateNode;return l===null&&(l=i.stateNode=new Fv),l;case 22:return i=i.stateNode,l=i._retryCache,l===null&&(l=i._retryCache=new Fv),l;default:throw Error(r(435,i.tag))}}function zf(i,l){var d=u2(i);l.forEach(function(m){if(!d.has(m)){d.add(m);var C=x2.bind(null,i,m);m.then(C,C)}})}function ys(i,l){var d=l.deletions;if(d!==null)for(var m=0;m<d.length;m++){var C=d[m],v=i,A=l,V=A;e:for(;V!==null;){switch(V.tag){case 27:if(To(V.type)){Ln=V.stateNode,Bs=!1;break e}break;case 5:Ln=V.stateNode,Bs=!1;break e;case 3:case 4:Ln=V.stateNode.containerInfo,Bs=!0;break e}V=V.return}if(Ln===null)throw Error(r(160));Gv(v,A,C),Ln=null,Bs=!1,v=C.alternate,v!==null&&(v.return=null),C.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)zv(l,i),l=l.sibling}var Ei=null;function zv(i,l){var d=i.alternate,m=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:ys(l,i),xs(i),m&4&&(xo(3,i,i.return),vd(3,i),xo(5,i,i.return));break;case 1:ys(l,i),xs(i),m&512&&(hr||d===null||Ji(d,d.return)),m&64&&va&&(i=i.updateQueue,i!==null&&(m=i.callbacks,m!==null&&(d=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=d===null?m:d.concat(m))));break;case 26:var C=Ei;if(ys(l,i),xs(i),m&512&&(hr||d===null||Ji(d,d.return)),m&4){var v=d!==null?d.memoizedState:null;if(m=i.memoizedState,d===null)if(m===null)if(i.stateNode===null){e:{m=i.type,d=i.memoizedProps,C=C.ownerDocument||C;t:switch(m){case"title":v=C.getElementsByTagName("title")[0],(!v||v[Sr]||v[on]||v.namespaceURI==="http://www.w3.org/2000/svg"||v.hasAttribute("itemprop"))&&(v=C.createElement(m),C.head.insertBefore(v,C.querySelector("head > title"))),Gr(v,m,d),v[on]=i,qn(v),m=v;break e;case"link":var A=zw("link","href",C).get(m+(d.href||""));if(A){for(var V=0;V<A.length;V++)if(v=A[V],v.getAttribute("href")===(d.href==null||d.href===""?null:d.href)&&v.getAttribute("rel")===(d.rel==null?null:d.rel)&&v.getAttribute("title")===(d.title==null?null:d.title)&&v.getAttribute("crossorigin")===(d.crossOrigin==null?null:d.crossOrigin)){A.splice(V,1);break t}}v=C.createElement(m),Gr(v,m,d),C.head.appendChild(v);break;case"meta":if(A=zw("meta","content",C).get(m+(d.content||""))){for(V=0;V<A.length;V++)if(v=A[V],v.getAttribute("content")===(d.content==null?null:""+d.content)&&v.getAttribute("name")===(d.name==null?null:d.name)&&v.getAttribute("property")===(d.property==null?null:d.property)&&v.getAttribute("http-equiv")===(d.httpEquiv==null?null:d.httpEquiv)&&v.getAttribute("charset")===(d.charSet==null?null:d.charSet)){A.splice(V,1);break t}}v=C.createElement(m),Gr(v,m,d),C.head.appendChild(v);break;default:throw Error(r(468,m))}v[on]=i,qn(v),m=v}i.stateNode=m}else Jw(C,i.type,i.stateNode);else i.stateNode=qw(C,m,i.memoizedProps);else v!==m?(v===null?d.stateNode!==null&&(d=d.stateNode,d.parentNode.removeChild(d)):v.count--,m===null?Jw(C,i.type,i.stateNode):qw(C,m,i.memoizedProps)):m===null&&i.stateNode!==null&&j0(i,i.memoizedProps,d.memoizedProps)}break;case 27:ys(l,i),xs(i),m&512&&(hr||d===null||Ji(d,d.return)),d!==null&&m&4&&j0(i,i.memoizedProps,d.memoizedProps);break;case 5:if(ys(l,i),xs(i),m&512&&(hr||d===null||Ji(d,d.return)),i.flags&32){C=i.stateNode;try{Zt(C,"")}catch(Je){cn(i,i.return,Je)}}m&4&&i.stateNode!=null&&(C=i.memoizedProps,j0(i,C,d!==null?d.memoizedProps:C)),m&1024&&(U0=!0);break;case 6:if(ys(l,i),xs(i),m&4){if(i.stateNode===null)throw Error(r(162));m=i.memoizedProps,d=i.stateNode;try{d.nodeValue=m}catch(Je){cn(i,i.return,Je)}}break;case 3:if(om=null,C=Ei,Ei=im(l.containerInfo),ys(l,i),Ei=C,xs(i),m&4&&d!==null&&d.memoizedState.isDehydrated)try{uu(l.containerInfo)}catch(Je){cn(i,i.return,Je)}U0&&(U0=!1,Jv(i));break;case 4:m=Ei,Ei=im(i.stateNode.containerInfo),ys(l,i),xs(i),Ei=m;break;case 12:ys(l,i),xs(i);break;case 31:ys(l,i),xs(i),m&4&&(m=i.updateQueue,m!==null&&(i.updateQueue=null,zf(i,m)));break;case 13:ys(l,i),xs(i),i.child.flags&8192&&i.memoizedState!==null!=(d!==null&&d.memoizedState!==null)&&($f=yn()),m&4&&(m=i.updateQueue,m!==null&&(i.updateQueue=null,zf(i,m)));break;case 22:C=i.memoizedState!==null;var Z=d!==null&&d.memoizedState!==null,ue=va,be=hr;if(va=ue||C,hr=be||Z,ys(l,i),hr=be,va=ue,xs(i),m&8192)e:for(l=i.stateNode,l._visibility=C?l._visibility&-2:l._visibility|1,C&&(d===null||Z||va||hr||Gl(i)),d=null,l=i;;){if(l.tag===5||l.tag===26){if(d===null){Z=d=l;try{if(v=Z.stateNode,C)A=v.style,typeof A.setProperty=="function"?A.setProperty("display","none","important"):A.display="none";else{V=Z.stateNode;var _e=Z.memoizedProps.style,he=_e!=null&&_e.hasOwnProperty("display")?_e.display:null;V.style.display=he==null||typeof he=="boolean"?"":(""+he).trim()}}catch(Je){cn(Z,Z.return,Je)}}}else if(l.tag===6){if(d===null){Z=l;try{Z.stateNode.nodeValue=C?"":Z.memoizedProps}catch(Je){cn(Z,Z.return,Je)}}}else if(l.tag===18){if(d===null){Z=l;try{var pe=Z.stateNode;C?Mw(pe,!0):Mw(Z.stateNode,!1)}catch(Je){cn(Z,Z.return,Je)}}}else if((l.tag!==22&&l.tag!==23||l.memoizedState===null||l===i)&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break e;for(;l.sibling===null;){if(l.return===null||l.return===i)break e;d===l&&(d=null),l=l.return}d===l&&(d=null),l.sibling.return=l.return,l=l.sibling}m&4&&(m=i.updateQueue,m!==null&&(d=m.retryQueue,d!==null&&(m.retryQueue=null,zf(i,d))));break;case 19:ys(l,i),xs(i),m&4&&(m=i.updateQueue,m!==null&&(i.updateQueue=null,zf(i,m)));break;case 30:break;case 21:break;default:ys(l,i),xs(i)}}function xs(i){var l=i.flags;if(l&2){try{for(var d,m=i.return;m!==null;){if(jv(m)){d=m;break}m=m.return}if(d==null)throw Error(r(160));switch(d.tag){case 27:var C=d.stateNode,v=O0(i);qf(i,v,C);break;case 5:var A=d.stateNode;d.flags&32&&(Zt(A,""),d.flags&=-33);var V=O0(i);qf(i,V,A);break;case 3:case 4:var Z=d.stateNode.containerInfo,ue=O0(i);F0(i,ue,Z);break;default:throw Error(r(161))}}catch(be){cn(i,i.return,be)}i.flags&=-3}l&4096&&(i.flags&=-4097)}function Jv(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var l=i;Jv(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),i=i.sibling}}function Ea(i,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)Uv(i,l.alternate,l),l=l.sibling}function Gl(i){for(i=i.child;i!==null;){var l=i;switch(l.tag){case 0:case 11:case 14:case 15:xo(4,l,l.return),Gl(l);break;case 1:Ji(l,l.return);var d=l.stateNode;typeof d.componentWillUnmount=="function"&&Mv(l,l.return,d),Gl(l);break;case 27:Id(l.stateNode);case 26:case 5:Ji(l,l.return),Gl(l);break;case 22:l.memoizedState===null&&Gl(l);break;case 30:Gl(l);break;default:Gl(l)}i=i.sibling}}function _a(i,l,d){for(d=d&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var m=l.alternate,C=i,v=l,A=v.flags;switch(v.tag){case 0:case 11:case 15:_a(C,v,d),vd(4,v);break;case 1:if(_a(C,v,d),m=v,C=m.stateNode,typeof C.componentDidMount=="function")try{C.componentDidMount()}catch(ue){cn(m,m.return,ue)}if(m=v,C=m.updateQueue,C!==null){var V=m.stateNode;try{var Z=C.shared.hiddenCallbacks;if(Z!==null)for(C.shared.hiddenCallbacks=null,C=0;C<Z.length;C++)wb(Z[C],V)}catch(ue){cn(m,m.return,ue)}}d&&A&64&&Pv(v),wd(v,v.return);break;case 27:Ov(v);case 26:case 5:_a(C,v,d),d&&m===null&&A&4&&Lv(v),wd(v,v.return);break;case 12:_a(C,v,d);break;case 31:_a(C,v,d),d&&A&4&&Hv(C,v);break;case 13:_a(C,v,d),d&&A&4&&qv(C,v);break;case 22:v.memoizedState===null&&_a(C,v,d),wd(v,v.return);break;case 30:break;default:_a(C,v,d)}l=l.sibling}}function V0(i,l){var d=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),i=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(i=l.memoizedState.cachePool.pool),i!==d&&(i!=null&&i.refCount++,d!=null&&cd(d))}function G0(i,l){i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&cd(i))}function _i(i,l,d,m){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)$v(i,l,d,m),l=l.sibling}function $v(i,l,d,m){var C=l.flags;switch(l.tag){case 0:case 11:case 15:_i(i,l,d,m),C&2048&&vd(9,l);break;case 1:_i(i,l,d,m);break;case 3:_i(i,l,d,m),C&2048&&(i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&cd(i)));break;case 12:if(C&2048){_i(i,l,d,m),i=l.stateNode;try{var v=l.memoizedProps,A=v.id,V=v.onPostCommit;typeof V=="function"&&V(A,l.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(Z){cn(l,l.return,Z)}}else _i(i,l,d,m);break;case 31:_i(i,l,d,m);break;case 13:_i(i,l,d,m);break;case 23:break;case 22:v=l.stateNode,A=l.alternate,l.memoizedState!==null?v._visibility&2?_i(i,l,d,m):Ed(i,l):v._visibility&2?_i(i,l,d,m):(v._visibility|=2,Zc(i,l,d,m,(l.subtreeFlags&10256)!==0||!1)),C&2048&&V0(A,l);break;case 24:_i(i,l,d,m),C&2048&&G0(l.alternate,l);break;default:_i(i,l,d,m)}}function Zc(i,l,d,m,C){for(C=C&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var v=i,A=l,V=d,Z=m,ue=A.flags;switch(A.tag){case 0:case 11:case 15:Zc(v,A,V,Z,C),vd(8,A);break;case 23:break;case 22:var be=A.stateNode;A.memoizedState!==null?be._visibility&2?Zc(v,A,V,Z,C):Ed(v,A):(be._visibility|=2,Zc(v,A,V,Z,C)),C&&ue&2048&&V0(A.alternate,A);break;case 24:Zc(v,A,V,Z,C),C&&ue&2048&&G0(A.alternate,A);break;default:Zc(v,A,V,Z,C)}l=l.sibling}}function Ed(i,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var d=i,m=l,C=m.flags;switch(m.tag){case 22:Ed(d,m),C&2048&&V0(m.alternate,m);break;case 24:Ed(d,m),C&2048&&G0(m.alternate,m);break;default:Ed(d,m)}l=l.sibling}}var _d=8192;function eu(i,l,d){if(i.subtreeFlags&_d)for(i=i.child;i!==null;)Kv(i,l,d),i=i.sibling}function Kv(i,l,d){switch(i.tag){case 26:eu(i,l,d),i.flags&_d&&i.memoizedState!==null&&Q2(d,Ei,i.memoizedState,i.memoizedProps);break;case 5:eu(i,l,d);break;case 3:case 4:var m=Ei;Ei=im(i.stateNode.containerInfo),eu(i,l,d),Ei=m;break;case 22:i.memoizedState===null&&(m=i.alternate,m!==null&&m.memoizedState!==null?(m=_d,_d=16777216,eu(i,l,d),_d=m):eu(i,l,d));break;default:eu(i,l,d)}}function Yv(i){var l=i.alternate;if(l!==null&&(i=l.child,i!==null)){l.child=null;do l=i.sibling,i.sibling=null,i=l;while(i!==null)}}function Td(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var d=0;d<l.length;d++){var m=l[d];Dr=m,Wv(m,i)}Yv(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)Qv(i),i=i.sibling}function Qv(i){switch(i.tag){case 0:case 11:case 15:Td(i),i.flags&2048&&xo(9,i,i.return);break;case 3:Td(i);break;case 12:Td(i);break;case 22:var l=i.stateNode;i.memoizedState!==null&&l._visibility&2&&(i.return===null||i.return.tag!==13)?(l._visibility&=-3,Jf(i)):Td(i);break;default:Td(i)}}function Jf(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var d=0;d<l.length;d++){var m=l[d];Dr=m,Wv(m,i)}Yv(i)}for(i=i.child;i!==null;){switch(l=i,l.tag){case 0:case 11:case 15:xo(8,l,l.return),Jf(l);break;case 22:d=l.stateNode,d._visibility&2&&(d._visibility&=-3,Jf(l));break;default:Jf(l)}i=i.sibling}}function Wv(i,l){for(;Dr!==null;){var d=Dr;switch(d.tag){case 0:case 11:case 15:xo(8,d,l);break;case 23:case 22:if(d.memoizedState!==null&&d.memoizedState.cachePool!==null){var m=d.memoizedState.cachePool.pool;m!=null&&m.refCount++}break;case 24:cd(d.memoizedState.cache)}if(m=d.child,m!==null)m.return=d,Dr=m;else e:for(d=i;Dr!==null;){m=Dr;var C=m.sibling,v=m.return;if(Vv(m),m===d){Dr=null;break e}if(C!==null){C.return=v,Dr=C;break e}Dr=v}}}var d2={getCacheForType:function(i){var l=Ur(cr),d=l.data.get(i);return d===void 0&&(d=i(),l.data.set(i,d)),d},cacheSignal:function(){return Ur(cr).controller.signal}},h2=typeof WeakMap=="function"?WeakMap:Map,rn=0,gn=null,Pt=null,Ot=0,ln=0,Fs=null,Co=!1,tu=!1,H0=!1,Ta=0,Xn=0,bo=0,Hl=0,q0=0,Us=0,nu=0,kd=null,Cs=null,z0=!1,$f=0,Xv=0,Kf=1/0,Yf=null,vo=null,wr=0,wo=null,ru=null,ka=0,J0=0,$0=null,Zv=null,Nd=0,K0=null;function Vs(){return(rn&2)!==0&&Ot!==0?Ot&-Ot:G.T!==null?eB():$r()}function ew(){if(Us===0)if((Ot&536870912)===0||Vt){var i=Gn;Gn<<=1,(Gn&3932160)===0&&(Gn=262144),Us=i}else Us=536870912;return i=js.current,i!==null&&(i.flags|=32),Us}function bs(i,l,d){(i===gn&&(ln===2||ln===9)||i.cancelPendingCommit!==null)&&(su(i,0),Eo(i,Ot,Us,!1)),$e(i,d),((rn&2)===0||i!==gn)&&(i===gn&&((rn&2)===0&&(Hl|=d
vendor: 20,590 bytes, line 48
48),Xn===4&&Eo(i,Ot,Us,!1)),$i(i))}function tw(i,l,d){if((rn&6)!==0)throw Error(r(327));var m=!d&&(l&127)===0&&(l&i.expiredLanes)===0||or(i,l),C=m?g2(i,l):Q0(i,l,!0),v=m;do{if(C===0){tu&&!m&&Eo(i,l,0,!1);break}else{if(d=i.current.alternate,v&&!f2(d)){C=Q0(i,l,!1),v=!1;continue}if(C===2){if(v=l,i.errorRecoveryDisabledLanes&v)var A=0;else A=i.pendingLanes&-536870913,A=A!==0?A:A&536870912?536870912:0;if(A!==0){l=A;e:{var V=i;C=kd;var Z=V.current.memoizedState.isDehydrated;if(Z&&(su(V,A).flags|=256),A=Q0(V,A,!1),A!==2){if(H0&&!Z){V.errorRecoveryDisabledLanes|=v,Hl|=v,C=4;break e}v=Cs,Cs=C,v!==null&&(Cs===null?Cs=v:Cs.push.apply(Cs,v))}C=A}if(v=!1,C!==2)continue}}if(C===1){su(i,0),Eo(i,l,0,!0);break}e:{switch(m=i,v=C,v){case 0:case 1:throw Error(r(345));case 4:if((l&4194048)!==l)break;case 6:Eo(m,l,Us,!Co);break e;case 2:Cs=null;break;case 3:case 5:break;default:throw Error(r(329))}if((l&62914560)===l&&(C=$f+300-yn(),10<C)){if(Eo(m,l,Us,!Co),Pn(m,0,!0)!==0)break e;ka=l,m.timeoutHandle=Iw(nw.bind(null,m,d,Cs,Yf,z0,l,Us,Hl,nu,Co,v,"Throttled",-0,0),C);break e}nw(m,d,Cs,Yf,z0,l,Us,Hl,nu,Co,v,null,-0,0)}}break}while(!0);$i(i)}function nw(i,l,d,m,C,v,A,V,Z,ue,be,_e,he,pe){if(i.timeoutHandle=-1,_e=l.subtreeFlags,_e&8192||(_e&16785408)===16785408){_e={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:yi},Kv(l,v,_e);var Je=(v&62914560)===v?$f-yn():(v&4194048)===v?Xv-yn():0;if(Je=W2(_e,Je),Je!==null){ka=v,i.cancelPendingCommit=Je(uw.bind(null,i,l,v,d,m,C,A,V,Z,be,_e,null,he,pe)),Eo(i,v,A,!ue);return}}uw(i,l,v,d,m,C,A,V,Z)}function f2(i){for(var l=i;;){var d=l.tag;if((d===0||d===11||d===15)&&l.flags&16384&&(d=l.updateQueue,d!==null&&(d=d.stores,d!==null)))for(var m=0;m<d.length;m++){var C=d[m],v=C.getSnapshot;C=C.value;try{if(!Ms(v(),C))return!1}catch{return!1}}if(d=l.child,l.subtreeFlags&16384&&d!==null)d.return=l,l=d;else{if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Eo(i,l,d,m){l&=~q0,l&=~Hl,i.suspendedLanes|=l,i.pingedLanes&=~l,m&&(i.warmLanes|=l),m=i.expirationTimes;for(var C=l;0<C;){var v=31-jt(C),A=1<<v;m[v]=-1,C&=~A}d!==0&&Kn(i,d,l)}function Qf(){return(rn&6)===0?(Sd(0),!1):!0}function Y0(){if(Pt!==null){if(ln===0)var i=Pt.return;else i=Pt,pa=Pl=null,d0(i),Kc=null,dd=0,i=Pt;for(;i!==null;)Rv(i.alternate,i),i=i.return;Pt=null}}function su(i,l){var d=i.timeoutHandle;d!==-1&&(i.timeoutHandle=-1,R2(d)),d=i.cancelPendingCommit,d!==null&&(i.cancelPendingCommit=null,d()),ka=0,Y0(),gn=i,Pt=d=ma(i.current,null),Ot=l,ln=0,Fs=null,Co=!1,tu=or(i,l),H0=!1,nu=Us=q0=Hl=bo=Xn=0,Cs=kd=null,z0=!1,(l&8)!==0&&(l|=l&32);var m=i.entangledLanes;if(m!==0)for(i=i.entanglements,m&=l;0<m;){var C=31-jt(m),v=1<<C;l|=i[C],m&=~v}return Ta=l,Bf(),d}function rw(i,l){Et=null,G.H=xd,l===$c||l===_f?(l=xb(),ln=3):l===Zp?(l=xb(),ln=4):ln=l===k0?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,Fs=l,Pt===null&&(Xn=1,Ff(i,ii(l,i.current)))}function sw(){var i=js.current;return i===null?!0:(Ot&4194048)===Ot?ci===null:(Ot&62914560)===Ot||(Ot&536870912)!==0?i===ci:!1}function iw(){var i=G.H;return G.H=xd,i===null?xd:i}function aw(){var i=G.A;return G.A=d2,i}function Wf(){Xn=4,Co||(Ot&4194048)!==Ot&&js.current!==null||(tu=!0),(bo&134217727)===0&&(Hl&134217727)===0||gn===null||Eo(gn,Ot,Us,!1)}function Q0(i,l,d){var m=rn;rn|=2;var C=iw(),v=aw();(gn!==i||Ot!==l)&&(Yf=null,su(i,l)),l=!1;var A=Xn;e:do try{if(ln!==0&&Pt!==null){var V=Pt,Z=Fs;switch(ln){case 8:Y0(),A=6;break e;case 3:case 2:case 9:case 6:js.current===null&&(l=!0);var ue=ln;if(ln=0,Fs=null,iu(i,V,Z,ue),d&&tu){A=0;break e}break;default:ue=ln,ln=0,Fs=null,iu(i,V,Z,ue)}}m2(),A=Xn;break}catch(be){rw(i,be)}while(!0);return l&&i.shellSuspendCounter++,pa=Pl=null,rn=m,G.H=C,G.A=v,Pt===null&&(gn=null,Ot=0,Bf()),A}function m2(){for(;Pt!==null;)ow(Pt)}function g2(i,l){var d=rn;rn|=2;var m=iw(),C=aw();gn!==i||Ot!==l?(Yf=null,Kf=yn()+500,su(i,l)):tu=or(i,l);e:do try{if(ln!==0&&Pt!==null){l=Pt;var v=Fs;t:switch(ln){case 1:ln=0,Fs=null,iu(i,l,v,1);break;case 2:case 9:if(Bb(v)){ln=0,Fs=null,lw(l);break}l=function(){ln!==2&&ln!==9||gn!==i||(ln=7),$i(i)},v.then(l,l);break e;case 3:ln=7;break e;case 4:ln=5;break e;case 7:Bb(v)?(ln=0,Fs=null,lw(l)):(ln=0,Fs=null,iu(i,l,v,7));break;case 5:var A=null;switch(Pt.tag){case 26:A=Pt.memoizedState;case 5:case 27:var V=Pt;if(A?$w(A):V.stateNode.complete){ln=0,Fs=null;var Z=V.sibling;if(Z!==null)Pt=Z;else{var ue=V.return;ue!==null?(Pt=ue,Xf(ue)):Pt=null}break t}}ln=0,Fs=null,iu(i,l,v,5);break;case 6:ln=0,Fs=null,iu(i,l,v,6);break;case 8:Y0(),Xn=6;break e;default:throw Error(r(462))}}p2();break}catch(be){rw(i,be)}while(!0);return pa=Pl=null,G.H=m,G.A=C,rn=d,Pt!==null?0:(gn=null,Ot=0,Bf(),Xn)}function p2(){for(;Pt!==null&&!Tr();)ow(Pt)}function ow(i){var l=Av(i.alternate,i,Ta);i.memoizedProps=i.pendingProps,l===null?Xf(i):Pt=l}function lw(i){var l=i,d=l.alternate;switch(l.tag){case 15:case 0:l=_v(d,l,l.pendingProps,l.type,void 0,Ot);break;case 11:l=_v(d,l,l.pendingProps,l.type.render,l.ref,Ot);break;case 5:d0(l);default:Rv(d,l),l=Pt=ab(l,Ta),l=Av(d,l,Ta)}i.memoizedProps=i.pendingProps,l===null?Xf(i):Pt=l}function iu(i,l,d,m){pa=Pl=null,d0(l),Kc=null,dd=0;var C=l.return;try{if(s2(i,C,l,d,Ot)){Xn=1,Ff(i,ii(d,i.current)),Pt=null;return}}catch(v){if(C!==null)throw Pt=C,v;Xn=1,Ff(i,ii(d,i.current)),Pt=null;return}l.flags&32768?(Vt||m===1?i=!0:tu||(Ot&536870912)!==0?i=!1:(Co=i=!0,(m===2||m===9||m===3||m===6)&&(m=js.current,m!==null&&m.tag===13&&(m.flags|=16384))),cw(l,i)):Xf(l)}function Xf(i){var l=i;do{if((l.flags&32768)!==0){cw(l,Co);return}i=l.return;var d=o2(l.alternate,l,Ta);if(d!==null){Pt=d;return}if(l=l.sibling,l!==null){Pt=l;return}Pt=l=i}while(l!==null);Xn===0&&(Xn=5)}function cw(i,l){do{var d=l2(i.alternate,i);if(d!==null){d.flags&=32767,Pt=d;return}if(d=i.return,d!==null&&(d.flags|=32768,d.subtreeFlags=0,d.deletions=null),!l&&(i=i.sibling,i!==null)){Pt=i;return}Pt=i=d}while(i!==null);Xn=6,Pt=null}function uw(i,l,d,m,C,v,A,V,Z){i.cancelPendingCommit=null;do Zf();while(wr!==0);if((rn&6)!==0)throw Error(r(327));if(l!==null){if(l===i.current)throw Error(r(177));if(v=l.lanes|l.childLanes,v|=Op,un(i,d,v,A,V,Z),i===gn&&(Pt=gn=null,Ot=0),ru=l,wo=i,ka=d,J0=v,$0=C,Zv=m,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,C2(De,function(){return gw(),null})):(i.callbackNode=null,i.callbackPriority=0),m=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||m){m=G.T,G.T=null,C=W.p,W.p=2,A=rn,rn|=4;try{c2(i,l,d)}finally{rn=A,W.p=C,G.T=m}}wr=1,dw(),hw(),fw()}}function dw(){if(wr===1){wr=0;var i=wo,l=ru,d=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||d){d=G.T,G.T=null;var m=W.p;W.p=2;var C=rn;rn|=4;try{zv(l,i);var v=lB,A=WC(i.containerInfo),V=v.focusedElem,Z=v.selectionRange;if(A!==V&&V&&V.ownerDocument&&QC(V.ownerDocument.documentElement,V)){if(Z!==null&&Rp(V)){var ue=Z.start,be=Z.end;if(be===void 0&&(be=ue),"selectionStart"in V)V.selectionStart=ue,V.selectionEnd=Math.min(be,V.value.length);else{var _e=V.ownerDocument||document,he=_e&&_e.defaultView||window;if(he.getSelection){var pe=he.getSelection(),Je=V.textContent.length,ct=Math.min(Z.start,Je),mn=Z.end===void 0?ct:Math.min(Z.end,Je);!pe.extend&&ct>mn&&(A=mn,mn=ct,ct=A);var oe=YC(V,ct),te=YC(V,mn);if(oe&&te&&(pe.rangeCount!==1||pe.anchorNode!==oe.node||pe.anchorOffset!==oe.offset||pe.focusNode!==te.node||pe.focusOffset!==te.offset)){var ce=_e.createRange();ce.setStart(oe.node,oe.offset),pe.removeAllRanges(),ct>mn?(pe.addRange(ce),pe.extend(te.node,te.offset)):(ce.setEnd(te.node,te.offset),pe.addRange(ce))}}}}for(_e=[],pe=V;pe=pe.parentNode;)pe.nodeType===1&&_e.push({element:pe,left:pe.scrollLeft,top:pe.scrollTop});for(typeof V.focus=="function"&&V.focus(),V=0;V<_e.length;V++){var we=_e[V];we.element.scrollLeft=we.left,we.element.scrollTop=we.top}}dm=!!oB,lB=oB=null}finally{rn=C,W.p=m,G.T=d}}i.current=l,wr=2}}function hw(){if(wr===2){wr=0;var i=wo,l=ru,d=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||d){d=G.T,G.T=null;var m=W.p;W.p=2;var C=rn;rn|=4;try{Uv(i,l.alternate,l)}finally{rn=C,W.p=m,G.T=d}}wr=3}}function fw(){if(wr===4||wr===3){wr=0,ns();var i=wo,l=ru,d=ka,m=Zv;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?wr=5:(wr=0,ru=wo=null,mw(i,i.pendingLanes));var C=i.pendingLanes;if(C===0&&(vo=null),Tn(d),l=l.stateNode,Qe&&typeof Qe.onCommitFiberRoot=="function")try{Qe.onCommitFiberRoot(ht,l,void 0,(l.current.flags&128)===128)}catch{}if(m!==null){l=G.T,C=W.p,W.p=2,G.T=null;try{for(var v=i.onRecoverableError,A=0;A<m.length;A++){var V=m[A];v(V.value,{componentStack:V.stack})}}finally{G.T=l,W.p=C}}(ka&3)!==0&&Zf(),$i(i),C=i.pendingLanes,(d&261930)!==0&&(C&42)!==0?i===K0?Nd++:(Nd=0,K0=i):Nd=0,Sd(0)}}function mw(i,l){(i.pooledCacheLanes&=l)===0&&(l=i.pooledCache,l!=null&&(i.pooledCache=null,cd(l)))}function Zf(){return dw(),hw(),fw(),gw()}function gw(){if(wr!==5)return!1;var i=wo,l=J0;J0=0;var d=Tn(ka),m=G.T,C=W.p;try{W.p=32>d?32:d,G.T=null,d=$0,$0=null;var v=wo,A=ka;if(wr=0,ru=wo=null,ka=0,(rn&6)!==0)throw Error(r(331));var V=rn;if(rn|=4,Qv(v.current),$v(v,v.current,A,d),rn=V,Sd(0,!1),Qe&&typeof Qe.onPostCommitFiberRoot=="function")try{Qe.onPostCommitFiberRoot(ht,v)}catch{}return!0}finally{W.p=C,G.T=m,mw(i,l)}}function pw(i,l,d){l=ii(d,l),l=T0(i.stateNode,l,2),i=po(i,l,2),i!==null&&($e(i,2),$i(i))}function cn(i,l,d){if(i.tag===3)pw(i,i,d);else for(;l!==null;){if(l.tag===3){pw(l,i,d);break}else if(l.tag===1){var m=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(vo===null||!vo.has(m))){i=ii(d,i),d=Bv(2),m=po(l,d,2),m!==null&&(yv(d,m,l,i),$e(m,2),$i(m));break}}l=l.return}}function W0(i,l,d){var m=i.pingCache;if(m===null){m=i.pingCache=new h2;var C=new Set;m.set(l,C)}else C=m.get(l),C===void 0&&(C=new Set,m.set(l,C));C.has(d)||(H0=!0,C.add(d),i=B2.bind(null,i,l,d),l.then(i,i))}function B2(i,l,d){var m=i.pingCache;m!==null&&m.delete(l),i.pingedLanes|=i.suspendedLanes&d,i.warmLanes&=~d,gn===i&&(Ot&d)===d&&(Xn===4||Xn===3&&(Ot&62914560)===Ot&&300>yn()-$f?(rn&2)===0&&su(i,0):q0|=d,nu===Ot&&(nu=0)),$i(i)}function Bw(i,l){l===0&&(l=_n()),i=Al(i,l),i!==null&&($e(i,l),$i(i))}function y2(i){var l=i.memoizedState,d=0;l!==null&&(d=l.retryLane),Bw(i,d)}function x2(i,l){var d=0;switch(i.tag){case 31:case 13:var m=i.stateNode,C=i.memoizedState;C!==null&&(d=C.retryLane);break;case 19:m=i.stateNode;break;case 22:m=i.stateNode._retryCache;break;default:throw Error(r(314))}m!==null&&m.delete(l),Bw(i,d)}function C2(i,l){return St(i,l)}var em=null,au=null,X0=!1,tm=!1,Z0=!1,_o=0;function $i(i){i!==au&&i.next===null&&(au===null?em=au=i:au=au.next=i),tm=!0,X0||(X0=!0,v2())}function Sd(i,l){if(!Z0&&tm){Z0=!0;do for(var d=!1,m=em;m!==null;){if(i!==0){var C=m.pendingLanes;if(C===0)var v=0;else{var A=m.suspendedLanes,V=m.pingedLanes;v=(1<<31-jt(42|i)+1)-1,v&=C&~(A&~V),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(d=!0,bw(m,v))}else v=Ot,v=Pn(m,m===gn?v:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),(v&3)===0||or(m,v)||(d=!0,bw(m,v));m=m.next}while(d);Z0=!1}}function b2(){yw()}function yw(){tm=X0=!1;var i=0;_o!==0&&I2()&&(i=_o);for(var l=yn(),d=null,m=em;m!==null;){var C=m.next,v=xw(m,l);v===0?(m.next=null,d===null?em=C:d.next=C,C===null&&(au=d)):(d=m,(i!==0||(v&3)!==0)&&(tm=!0)),m=C}wr!==0&&wr!==5||Sd(i),_o!==0&&(_o=0)}function xw(i,l){for(var d=i.suspendedLanes,m=i.pingedLanes,C=i.expirationTimes,v=i.pendingLanes&-62914561;0<v;){var A=31-jt(v),V=1<<A,Z=C[A];Z===-1?((V&d)===0||(V&m)!==0)&&(C[A]=Li(V,l)):Z<=l&&(i.expiredLanes|=V),v&=~V}if(l=gn,d=Ot,d=Pn(i,i===l?d:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),m=i.callbackNode,d===0||i===l&&(ln===2||ln===9)||i.cancelPendingCommit!==null)return m!==null&&m!==null&&Un(m),i.callbackNode=null,i.callbackPriority=0;if((d&3)===0||or(i,d)){if(l=d&-d,l===i.callbackPriority)return l;switch(m!==null&&Un(m),Tn(d)){case 2:case 8:d=Ne;break;case 32:d=De;break;case 268435456:d=je;break;default:d=De}return m=Cw.bind(null,i),d=St(d,m),i.callbackPriority=l,i.callbackNode=d,l}return m!==null&&m!==null&&Un(m),i.callbackPriority=2,i.callbackNode=null,2}function Cw(i,l){if(wr!==0&&wr!==5)return i.callbackNode=null,i.callbackPriority=0,null;var d=i.callbackNode;if(Zf()&&i.callbackNode!==d)return null;var m=Ot;return m=Pn(i,i===gn?m:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),m===0?null:(tw(i,m,l),xw(i,yn()),i.callbackNode!=null&&i.callbackNode===d?Cw.bind(null,i):null)}function bw(i,l){if(Zf())return null;tw(i,l,!0)}function v2(){P2(function(){(rn&6)!==0?St(re,b2):yw()})}function eB(){if(_o===0){var i=zc;i===0&&(i=xn,xn<<=1,(xn&261888)===0&&(xn=256)),_o=i}return _o}function vw(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Dc(""+i)}function ww(i,l){var d=l.ownerDocument.createElement("input");return d.name=l.name,d.value=l.value,i.id&&d.setAttribute("form",i.id),l.parentNode.insertBefore(d,l),i=new FormData(i),d.parentNode.removeChild(d),i}function w2(i,l,d,m,C){if(l==="submit"&&d&&d.stateNode===C){var v=vw((C[Nt]||null).action),A=m.submitter;A&&(l=(l=A[Nt]||null)?vw(l.formAction):A.getAttribute("formAction"),l!==null&&(v=l,A=null));var V=new Ui("action","action",null,m,C);i.push({event:V,listeners:[{instance:null,listener:function(){if(m.defaultPrevented){if(_o!==0){var Z=A?ww(C,A):new FormData(C);C0(d,{pending:!0,data:Z,method:C.method,action:v},null,Z)}}else typeof v=="function"&&(V.preventDefault(),Z=A?ww(C,A):new FormData(C),C0(d,{pending:!0,data:Z,method:C.method,action:v},v,Z))},currentTarget:C}]})}}for(var tB=0;tB<jp.length;tB++){var nB=jp[tB],E2=nB.toLowerCase(),_2=nB[0].toUpperCase()+nB.slice(1);wi(E2,"on"+_2)}wi(eb,"onAnimationEnd"),wi(tb,"onAnimationIteration"),wi(nb,"onAnimationStart"),wi("dblclick","onDoubleClick"),wi("focusin","onFocus"),wi("focusout","onBlur"),wi(VI,"onTransitionRun"),wi(GI,"onTransitionStart"),wi(HI,"onTransitionCancel"),wi(rb,"onTransitionEnd"),ei("onMouseEnter",["mouseout","mouseover"]),ei("onMouseLeave",["mouseout","mouseover"]),ei("onPointerEnter",["pointerout","pointerover"]),ei("onPointerLeave",["pointerout","pointerover"]),Zs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Zs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Zs("onBeforeInput",["compositionend","keypress","textInput","paste"]),Zs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Zs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Zs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Dd="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),T2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Dd));function Ew(i,l){l=(l&4)!==0;for(var d=0;d<i.length;d++){var m=i[d],C=m.event;m=m.listeners;e:{var v=void 0;if(l)for(var A=m.length-1;0<=A;A--){var V=m[A],Z=V.instance,ue=V.currentTarget;if(V=V.listener,Z!==v&&C.isPropagationStopped())break e;v=V,C.currentTarget=ue;try{v(C)}catch(be){pf(be)}C.currentTarget=null,v=Z}else for(A=0;A<m.length;A++){if(V=m[A],Z=V.instance,ue=V.currentTarget,V=V.listener,Z!==v&&C.isPropagationStopped())break e;v=V,C.currentTarget=ue;try{v(C)}catch(be){pf(be)}C.currentTarget=null,v=Z}}}}function Mt(i,l){var d=l[jr];d===void 0&&(d=l[jr]=new Set);var m=i+"__bubble";d.has(m)||(_w(l,i,2,!1),d.add(m))}function rB(i,l,d){var m=0;l&&(m|=4),_w(d,i,m,l)}var nm="_reactListening"+Math.random().toString(36).slice(2);function sB(i){if(!i[nm]){i[nm]=!0,pl.forEach(function(d){d!=="selectionchange"&&(T2.has(d)||rB(d,!1,i),rB(d,!0,i))});var l=i.nodeType===9?i:i.ownerDocument;l===null||l[nm]||(l[nm]=!0,rB("selectionchange",!1,l))}}function _w(i,l,d,m){switch(eE(l)){case 2:var C=eR;break;case 8:C=tR;break;default:C=xB}d=C.bind(null,l,d,i),C=void 0,!wl||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(C=!0),m?C!==void 0?i.addEventListener(l,d,{capture:!0,passive:C}):i.addEventListener(l,d,!0):C!==void 0?i.addEventListener(l,d,{passive:C}):i.addEventListener(l,d,!1)}function iB(i,l,d,m,C){var v=m;if((l&1)===0&&(l&2)===0&&m!==null)e:for(;;){if(m===null)return;var A=m.tag;if(A===3||A===4){var V=m.stateNode.containerInfo;if(V===C)break;if(A===4)for(A=m.return;A!==null;){var Z=A.tag;if((Z===3||Z===4)&&A.stateNode.containerInfo===C)return;A=A.return}for(;V!==null;){if(A=ps(V),A===null)return;if(Z=A.tag,Z===5||Z===6||Z===26||Z===27){m=v=A;continue e}V=V.parentNode}}m=m.return}io(function(){var ue=v,be=ti(d),_e=[];e:{var he=sb.get(i);if(he!==void 0){var pe=Ui,Je=i;switch(i){case"keypress":if(_l(d)===0)break e;case"keydown":case"keyup":pe=ff;break;case"focusin":Je="focus",pe=kl;break;case"focusout":Je="blur",pe=kl;break;case"beforeblur":case"afterblur":pe=kl;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":pe=td;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":pe=rf;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":pe=T;break;case eb:case tb:case nb:pe=af;break;case rb:pe=q;break;case"scroll":case"scrollend":pe=ed;break;case"wheel":pe=me;break;case"copy":case"cut":case"paste":pe=of;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":pe=fa;break;case"toggle":case"beforetoggle":pe=wt}var ct=(l&4)!==0,mn=!ct&&(i==="scroll"||i==="scrollend"),oe=ct?he!==null?he+"Capture":null:he;ct=[];for(var te=ue,ce;te!==null;){var we=te;if(ce=we.stateNode,we=we.tag,we!==5&&we!==26&&we!==27||ce===null||oe===null||(we=xi(te,oe),we!=null&&ct.push(Ad(te,we,ce))),mn)break;te=te.return}0<ct.length&&(he=new pe(he,Je,null,d,be),_e.push({event:he,listeners:ct}))}}if((l&7)===0){e:{if(he=i==="mouseover"||i==="pointerover",pe=i==="mouseout"||i==="pointerout",he&&d!==Wu&&(Je=d.relatedTarget||d.fromElement)&&(ps(Je)||Je[Cn]))break e;if((pe||he)&&(he=be.window===be?be:(he=be.ownerDocument)?he.defaultView||he.parentWindow:window,pe?(Je=d.relatedTarget||d.toElement,pe=ue,Je=Je?ps(Je):null,Je!==null&&(mn=a(Je),ct=Je.tag,Je!==mn||ct!==5&&ct!==27&&ct!==6)&&(Je=null)):(pe=null,Je=ue),pe!==Je)){if(ct=td,we="onMouseLeave",oe="onMouseEnter",te="mouse",(i==="pointerout"||i==="pointerover")&&(ct=fa,we="onPointerLeave",oe="onPointerEnter",te="pointer"),mn=pe==null?he:ss(pe),ce=Je==null?he:ss(Je),he=new ct(we,te+"leave",pe,d,be),he.target=mn,he.relatedTarget=ce,we=null,ps(be)===ue&&(ct=new ct(oe,te+"enter",Je,d,be),ct.target=ce,ct.relatedTarget=mn,we=ct),mn=we,pe&&Je)t:{for(ct=k2,oe=pe,te=Je,ce=0,we=oe;we;we=ct(we))ce++;we=0;for(var at=te;at;at=ct(at))we++;for(;0<ce-we;)oe=ct(oe),ce--;for(;0<we-ce;)te=ct(te),we--;for(;ce--;){if(oe===te||te!==null&&oe===te.alternate){ct=oe;break t}oe=ct(oe),te=ct(te)}ct=null}else ct=null;pe!==null&&Tw(_e,he,pe,ct,!1),Je!==null&&mn!==null&&Tw(_e,mn,Je,ct,!0)}}e:{if(he=ue?ss(ue):window,pe=he.nodeName&&he.nodeName.toLowerCase(),pe==="select"||pe==="input"&&he.type==="file")var Yt=HC;else if(VC(he))if(qC)Yt=OI;else{Yt=LI;var We=MI}else pe=he.nodeName,!pe||pe.toLowerCase()!=="input"||he.type!=="checkbox"&&he.type!=="radio"?ue&&no(ue.elementType)&&(Yt=HC):Yt=jI;if(Yt&&(Yt=Yt(i,ue))){GC(_e,Yt,d,be);break e}We&&We(i,he,ue),i==="focusout"&&ue&&he.type==="number"&&ue.memoizedProps.value!=null&&de(he,"number",he.value)}switch(We=ue?ss(ue):window,i){case"focusin":(VC(We)||We.contentEditable==="true")&&(jc=We,Pp=ue,ad=null);break;case"focusout":ad=Pp=jc=null;break;case"mousedown":Mp=!0;break;case"contextmenu":case"mouseup":case"dragend":Mp=!1,XC(_e,d,be);break;case"selectionchange":if(UI)break;case"keydown":case"keyup":XC(_e,d,be)}var Tt;if(nn)e:{switch(i){case"compositionstart":var Ft="onCompositionStart";break e;case"compositionend":Ft="onCompositionEnd";break e;case"compositionupdate":Ft="onCompositionUpdate";break e}Ft=void 0}else Lc?Nl(i,d)&&(Ft="onCompositionEnd"):i==="keydown"&&d.keyCode===229&&(Ft="onCompositionStart");Ft&&(Hi&&d.locale!=="ko"&&(Lc||Ft!=="onCompositionStart"?Ft==="onCompositionEnd"&&Lc&&(Tt=Zu()):(Fi=be,Xu="value"in Fi?Fi.value:Fi.textContent,Lc=!0)),We=rm(ue,Ft),0<We.length&&(Ft=new Gi(Ft,i,null,d,be),_e.push({event:Ft,listeners:We}
vendor: 6,913 bytes, lines 48-49
48),Tt?Ft.data=Tt:(Tt=Mc(d),Tt!==null&&(Ft.data=Tt)))),(Tt=ri?AI(i,d):II(i,d))&&(Ft=rm(ue,"onBeforeInput"),0<Ft.length&&(We=new Gi("onBeforeInput","beforeinput",null,d,be),_e.push({event:We,listeners:Ft}),We.data=Tt)),w2(_e,i,ue,d,be)}Ew(_e,l)})}function Ad(i,l,d){return{instance:i,listener:l,currentTarget:d}}function rm(i,l){for(var d=l+"Capture",m=[];i!==null;){var C=i,v=C.stateNode;if(C=C.tag,C!==5&&C!==26&&C!==27||v===null||(C=xi(i,d),C!=null&&m.unshift(Ad(i,C,v)),C=xi(i,l),C!=null&&m.push(Ad(i,C,v))),i.tag===3)return m;i=i.return}return[]}function k2(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function Tw(i,l,d,m,C){for(var v=l._reactName,A=[];d!==null&&d!==m;){var V=d,Z=V.alternate,ue=V.stateNode;if(V=V.tag,Z!==null&&Z===m)break;V!==5&&V!==26&&V!==27||ue===null||(Z=ue,C?(ue=xi(d,v),ue!=null&&A.unshift(Ad(d,ue,Z))):C||(ue=xi(d,v),ue!=null&&A.push(Ad(d,ue,Z)))),d=d.return}A.length!==0&&i.push({event:l,listeners:A})}var N2=/\r\n?/g,S2=/\u0000|\uFFFD/g;function kw(i){return(typeof i=="string"?i:""+i).replace(N2,`
49`).replace(S2,"")}function Nw(i,l){return l=kw(l),kw(i)===l}function fn(i,l,d,m,C,v){switch(d){case"children":typeof m=="string"?l==="body"||l==="textarea"&&m===""||Zt(i,m):(typeof m=="number"||typeof m=="bigint")&&l!=="body"&&Zt(i,""+m);break;case"className":is(i,"class",m);break;case"tabIndex":is(i,"tabindex",m);break;case"dir":case"role":case"viewBox":case"width":case"height":is(i,d,m);break;case"style":tn(i,m,v);break;case"data":if(l!=="object"){is(i,"data",m);break}case"src":case"href":if(m===""&&(l!=="a"||d!=="href")){i.removeAttribute(d);break}if(m==null||typeof m=="function"||typeof m=="symbol"||typeof m=="boolean"){i.removeAttribute(d);break}m=Dc(""+m),i.setAttribute(d,m);break;case"action":case"formAction":if(typeof m=="function"){i.setAttribute(d,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof v=="function"&&(d==="formAction"?(l!=="input"&&fn(i,l,"name",C.name,C,null),fn(i,l,"formEncType",C.formEncType,C,null),fn(i,l,"formMethod",C.formMethod,C,null),fn(i,l,"formTarget",C.formTarget,C,null)):(fn(i,l,"encType",C.encType,C,null),fn(i,l,"method",C.method,C,null),fn(i,l,"target",C.target,C,null)));if(m==null||typeof m=="symbol"||typeof m=="boolean"){i.removeAttribute(d);break}m=Dc(""+m),i.setAttribute(d,m);break;case"onClick":m!=null&&(i.onclick=yi);break;case"onScroll":m!=null&&Mt("scroll",i);break;case"onScrollEnd":m!=null&&Mt("scrollend",i);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(r(61));if(d=m.__html,d!=null){if(C.children!=null)throw Error(r(60));i.innerHTML=d}}break;case"multiple":i.multiple=m&&typeof m!="function"&&typeof m!="symbol";break;case"muted":i.muted=m&&typeof m!="function"&&typeof m!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(m==null||typeof m=="function"||typeof m=="boolean"||typeof m=="symbol"){i.removeAttribute("xlink:href");break}d=Dc(""+m),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",d);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":m!=null&&typeof m!="function"&&typeof m!="symbol"?i.setAttribute(d,""+m):i.removeAttribute(d);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":m&&typeof m!="function"&&typeof m!="symbol"?i.setAttribute(d,""):i.removeAttribute(d);break;case"capture":case"download":m===!0?i.setAttribute(d,""):m!==!1&&m!=null&&typeof m!="function"&&typeof m!="symbol"?i.setAttribute(d,m):i.removeAttribute(d);break;case"cols":case"rows":case"size":case"span":m!=null&&typeof m!="function"&&typeof m!="symbol"&&!isNaN(m)&&1<=m?i.setAttribute(d,m):i.removeAttribute(d);break;case"rowSpan":case"start":m==null||typeof m=="function"||typeof m=="symbol"||isNaN(m)?i.removeAttribute(d):i.setAttribute(d,m);break;case"popover":Mt("beforetoggle",i),Mt("toggle",i),eo(i,"popover",m);break;case"xlinkActuate":Qn(i,"http://www.w3.org/1999/xlink","xlink:actuate",m);break;case"xlinkArcrole":Qn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",m);break;case"xlinkRole":Qn(i,"http://www.w3.org/1999/xlink","xlink:role",m);break;case"xlinkShow":Qn(i,"http://www.w3.org/1999/xlink","xlink:show",m);break;case"xlinkTitle":Qn(i,"http://www.w3.org/1999/xlink","xlink:title",m);break;case"xlinkType":Qn(i,"http://www.w3.org/1999/xlink","xlink:type",m);break;case"xmlBase":Qn(i,"http://www.w3.org/XML/1998/namespace","xml:base",m);break;case"xmlLang":Qn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",m);break;case"xmlSpace":Qn(i,"http://www.w3.org/XML/1998/namespace","xml:space",m);break;case"is":eo(i,"is",m);break;case"innerText":case"textContent":break;default:(!(2<d.length)||d[0]!=="o"&&d[0]!=="O"||d[1]!=="n"&&d[1]!=="N")&&(d=Sc.get(d)||d,eo(i,d,m))}}function aB(i,l,d,m,C,v){switch(d){case"style":tn(i,m,v);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(r(61));if(d=m.__html,d!=null){if(C.children!=null)throw Error(r(60));i.innerHTML=d}}break;case"children":typeof m=="string"?Zt(i,m):(typeof m=="number"||typeof m=="bigint")&&Zt(i,""+m);break;case"onScroll":m!=null&&Mt("scroll",i);break;case"onScrollEnd":m!=null&&Mt("scrollend",i);break;case"onClick":m!=null&&(i.onclick=yi);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Bl.hasOwnProperty(d))e:{if(d[0]==="o"&&d[1]==="n"&&(C=d.endsWith("Capture"),l=d.slice(2,C?d.length-7:void 0),v=i[Nt]||null,v=v!=null?v[d]:null,typeof v=="function"&&i.removeEventListener(l,v,C),typeof m=="function")){typeof v!="function"&&v!==null&&(d in i?i[d]=null:i.hasAttribute(d)&&i.removeAttribute(d)),i.addEventListener(l,m,C);break e}d in i?i[d]=m:m===!0?i.setAttribute(d,""):eo(i,d,m)}}}function Gr(i,l,d){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Mt("error",i),Mt("load",i);var m=!1,C=!1,v;for(v in d)if(d.hasOwnProperty(v)){var A=d[v];if(A!=null)switch(v){case"src":m=!0;break;case"srcSet":C=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,l));default:fn(i,l,v,A,d,null)}}
vendor: 4,916 bytes, line 49
49C&&fn(i,l,"srcSet",d.srcSet,d,null),m&&fn(i,l,"src",d.src,d,null);return;case"input":Mt("invalid",i);var V=v=A=C=null,Z=null,ue=null;for(m in d)if(d.hasOwnProperty(m)){var be=d[m];if(be!=null)switch(m){case"name":C=be;break;case"type":A=be;break;case"checked":Z=be;break;case"defaultChecked":ue=be;break;case"value":v=be;break;case"defaultValue":V=be;break;case"children":case"dangerouslySetInnerHTML":if(be!=null)throw Error(r(137,l));break;default:fn(i,l,m,be,d,null)}}$(i,v,V,Z,ue,A,C,!1);return;case"select":Mt("invalid",i),m=A=v=null;for(C in d)if(d.hasOwnProperty(C)&&(V=d[C],V!=null))switch(C){case"value":v=V;break;case"defaultValue":A=V;break;case"multiple":m=V;default:fn(i,l,C,V,d,null)}l=v,d=A,i.multiple=!!m,l!=null?Be(i,!!m,l,!1):d!=null&&Be(i,!!m,d,!0);return;case"textarea":Mt("invalid",i),v=C=m=null;for(A in d)if(d.hasOwnProperty(A)&&(V=d[A],V!=null))switch(A){case"value":m=V;break;case"defaultValue":C=V;break;case"children":v=V;break;case"dangerouslySetInnerHTML":if(V!=null)throw Error(r(91));break;default:fn(i,l,A,V,d,null)}vt(i,m,C,v);return;case"option":for(Z in d)if(d.hasOwnProperty(Z)&&(m=d[Z],m!=null))switch(Z){case"selected":i.selected=m&&typeof m!="function"&&typeof m!="symbol";break;default:fn(i,l,Z,m,d,null)}return;case"dialog":Mt("beforetoggle",i),Mt("toggle",i),Mt("cancel",i),Mt("close",i);break;case"iframe":case"object":Mt("load",i);break;case"video":case"audio":for(m=0;m<Dd.length;m++)Mt(Dd[m],i);break;case"image":Mt("error",i),Mt("load",i);break;case"details":Mt("toggle",i);break;case"embed":case"source":case"link":Mt("error",i),Mt("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ue in d)if(d.hasOwnProperty(ue)&&(m=d[ue],m!=null))switch(ue){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,l));default:fn(i,l,ue,m,d,null)}return;default:if(no(l)){for(be in d)d.hasOwnProperty(be)&&(m=d[be],m!==void 0&&aB(i,l,be,m,d,void 0));return}}for(V in d)d.hasOwnProperty(V)&&(m=d[V],m!=null&&fn(i,l,V,m,d,null))}function D2(i,l,d,m){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var C=null,v=null,A=null,V=null,Z=null,ue=null,be=null;for(pe in d){var _e=d[pe];if(d.hasOwnProperty(pe)&&_e!=null)switch(pe){case"checked":break;case"value":break;case"defaultValue":Z=_e;default:m.hasOwnProperty(pe)||fn(i,l,pe,null,m,_e)}}for(var he in m){var pe=m[he];if(_e=d[he],m.hasOwnProperty(he)&&(pe!=null||_e!=null))switch(he){case"type":v=pe;break;case"name":C=pe;break;case"checked":ue=pe;break;case"defaultChecked":be=pe;break;case"value":A=pe;break;case"defaultValue":V=pe;break;case"children":case"dangerouslySetInnerHTML":if(pe!=null)throw Error(r(137,l));break;default:pe!==_e&&fn(i,l,he,pe,m,_e)}}to(i,A,V,Z,ue,be,v,C);return;case"select":pe=A=V=he=null;for(v in d)if(Z=d[v],d.hasOwnProperty(v)&&Z!=null)switch(v){case"value":break;case"multiple":pe=Z;default:m.hasOwnProperty(v)||fn(i,l,v,null,m,Z)}for(C in m)if(v=m[C],Z=d[C],m.hasOwnProperty(C)&&(v!=null||Z!=null))switch(C){case"value":he=v;break;case"defaultValue":V=v;break;case"multiple":A=v;default:v!==Z&&fn(i,l,C,v,m,Z)}l=V,d=A,m=pe,he!=null?Be(i,!!d,he,!1):!!m!=!!d&&(l!=null?Be(i,!!d,l,!0):Be(i,!!d,d?[]:"",!1));return;case"textarea":pe=he=null;for(V in d)if(C=d[V],d.hasOwnProperty(V)&&C!=null&&!m.hasOwnProperty(V))switch(V){case"value":break;case"children":break;default:fn(i,l,V,null,m,C)}for(A in m)if(C=m[A],v=d[A],m.hasOwnProperty(A)&&(C!=null||v!=null))switch(A){case"value":he=C;break;case"defaultValue":pe=C;break;case"children":break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(r(91));break;default:C!==v&&fn(i,l,A,C,m,v)}et(i,he,pe);return;case"option":for(var Je in d)if(he=d[Je],d.hasOwnProperty(Je)&&he!=null&&!m.hasOwnProperty(Je))switch(Je){case"selected":i.selected=!1;break;default:fn(i,l,Je,null,m,he)}for(Z in m)if(he=m[Z],pe=d[Z],m.hasOwnProperty(Z)&&he!==pe&&(he!=null||pe!=null))switch(Z){case"selected":i.selected=he&&typeof he!="function"&&typeof he!="symbol";break;default:fn(i,l,Z,he,m,pe)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var ct in d)he=d[ct],d.hasOwnProperty(ct)&&he!=null&&!m.hasOwnProperty(ct)&&fn(i,l,ct,null,m,he);for(ue in m)if(he=m[ue],pe=d[ue],m.hasOwnProperty(ue)&&he!==pe&&(he!=null||pe!=null))switch(ue){case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(r(137,l));break;default:fn(i,l,ue,he,m,pe)}return;default:if(no(l)){for(var mn in d)he=d[mn],d.hasOwnProperty(mn)&&he!==void 0&&!m.hasOwnProperty(mn)&&aB(i,l,mn,void 0,m,he);for(be in m)he=m[be],pe=d[be],!m.hasOwnProperty(be)||he===pe||he===void 0&&pe===void 0||aB(i,l,be,he,m,pe);return}}for(var oe in d)he=d[oe],d.hasOwnProperty(oe)&&he!=null&&!m.hasOwnProperty(oe)&&fn(i,l,oe,null,m,he);
vendor: 14,653 bytes, line 49
49for(_e in m)he=m[_e],pe=d[_e],!m.hasOwnProperty(_e)||he===pe||he==null&&pe==null||fn(i,l,_e,he,m,pe)}function Sw(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function A2(){if(typeof performance.getEntriesByType=="function"){for(var i=0,l=0,d=performance.getEntriesByType("resource"),m=0;m<d.length;m++){var C=d[m],v=C.transferSize,A=C.initiatorType,V=C.duration;if(v&&V&&Sw(A)){for(A=0,V=C.responseEnd,m+=1;m<d.length;m++){var Z=d[m],ue=Z.startTime;if(ue>V)break;var be=Z.transferSize,_e=Z.initiatorType;be&&Sw(_e)&&(Z=Z.responseEnd,A+=be*(Z<V?1:(V-ue)/(Z-ue)))}if(--m,l+=8*(v+A)/(C.duration/1e3),i++,10<i)break}}if(0<i)return l/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var oB=null,lB=null;function sm(i){return i.nodeType===9?i:i.ownerDocument}function Dw(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Aw(i,l){if(i===0)switch(l){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&l==="foreignObject"?0:i}function cB(i,l){return i==="textarea"||i==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.children=="bigint"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var uB=null;function I2(){var i=window.event;return i&&i.type==="popstate"?i===uB?!1:(uB=i,!0):(uB=null,!1)}var Iw=typeof setTimeout=="function"?setTimeout:void 0,R2=typeof clearTimeout=="function"?clearTimeout:void 0,Rw=typeof Promise=="function"?Promise:void 0,P2=typeof queueMicrotask=="function"?queueMicrotask:typeof Rw<"u"?function(i){return Rw.resolve(null).then(i).catch(M2)}:Iw;function M2(i){setTimeout(function(){throw i})}function To(i){return i==="head"}function Pw(i,l){var d=l,m=0;do{var C=d.nextSibling;if(i.removeChild(d),C&&C.nodeType===8)if(d=C.data,d==="/$"||d==="/&"){if(m===0){i.removeChild(C),uu(l);return}m--}else if(d==="$"||d==="$?"||d==="$~"||d==="$!"||d==="&")m++;else if(d==="html")Id(i.ownerDocument.documentElement);else if(d==="head"){d=i.ownerDocument.head,Id(d);for(var v=d.firstChild;v;){var A=v.nextSibling,V=v.nodeName;v[Sr]||V==="SCRIPT"||V==="STYLE"||V==="LINK"&&v.rel.toLowerCase()==="stylesheet"||d.removeChild(v),v=A}}else d==="body"&&Id(i.ownerDocument.body);d=C}while(d);uu(l)}function Mw(i,l){var d=i;i=0;do{var m=d.nextSibling;if(d.nodeType===1?l?(d._stashedDisplay=d.style.display,d.style.display="none"):(d.style.display=d._stashedDisplay||"",d.getAttribute("style")===""&&d.removeAttribute("style")):d.nodeType===3&&(l?(d._stashedText=d.nodeValue,d.nodeValue=""):d.nodeValue=d._stashedText||""),m&&m.nodeType===8)if(d=m.data,d==="/$"){if(i===0)break;i--}else d!=="$"&&d!=="$?"&&d!=="$~"&&d!=="$!"||i++;d=m}while(d)}function dB(i){var l=i.firstChild;for(l&&l.nodeType===10&&(l=l.nextSibling);l;){var d=l;switch(l=l.nextSibling,d.nodeName){case"HTML":case"HEAD":case"BODY":dB(d),Ws(d);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(d.rel.toLowerCase()==="stylesheet")continue}i.removeChild(d)}}function L2(i,l,d,m){for(;i.nodeType===1;){var C=d;if(i.nodeName.toLowerCase()!==l.toLowerCase()){if(!m&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(m){if(!i[Sr])switch(l){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(v=i.getAttribute("rel"),v==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(v!==C.rel||i.getAttribute("href")!==(C.href==null||C.href===""?null:C.href)||i.getAttribute("crossorigin")!==(C.crossOrigin==null?null:C.crossOrigin)||i.getAttribute("title")!==(C.title==null?null:C.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(v=i.getAttribute("src"),(v!==(C.src==null?null:C.src)||i.getAttribute("type")!==(C.type==null?null:C.type)||i.getAttribute("crossorigin")!==(C.crossOrigin==null?null:C.crossOrigin))&&v&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(l==="input"&&i.type==="hidden"){var v=C.name==null?null:""+C.name;if(C.type==="hidden"&&i.getAttribute("name")===v)return i}else return i;if(i=ui(i.nextSibling),i===null)break}return null}function j2(i,l,d){if(l==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!d||(i=ui(i.nextSibling),i===null))return null;return i}function Lw(i,l){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!l||(i=ui(i.nextSibling),i===null))return null;return i}function hB(i){return i.data==="$?"||i.data==="$~"}function fB(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function O2(i,l){var d=i.ownerDocument;if(i.data==="$~")i._reactRetry=l;else if(i.data!=="$?"||d.readyState!=="loading")l();else{var m=function(){l(),d.removeEventListener("DOMContentLoaded",m)};d.addEventListener("DOMContentLoaded",m),i._reactRetry=m}}function ui(i){for(;i!=null;i=i.nextSibling){var l=i.nodeType;if(l===1||l===3)break;if(l===8){if(l=i.data,l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"||l==="F!"||l==="F")break;if(l==="/$"||l==="/&")return null}}return i}var mB=null;function jw(i){i=i.nextSibling;for(var l=0;i;){if(i.nodeType===8){var d=i.data;if(d==="/$"||d==="/&"){if(l===0)return ui(i.nextSibling);l--}else d!=="$"&&d!=="$!"&&d!=="$?"&&d!=="$~"&&d!=="&"||l++}i=i.nextSibling}return null}function Ow(i){i=i.previousSibling;for(var l=0;i;){if(i.nodeType===8){var d=i.data;if(d==="$"||d==="$!"||d==="$?"||d==="$~"||d==="&"){if(l===0)return i;l--}else d!=="/$"&&d!=="/&"||l++}i=i.previousSibling}return null}function Fw(i,l,d){switch(l=sm(d),i){case"html":if(i=l.documentElement,!i)throw Error(r(452));return i;case"head":if(i=l.head,!i)throw Error(r(453));return i;case"body":if(i=l.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function Id(i){for(var l=i.attributes;l.length;)i.removeAttributeNode(l[0]);Ws(i)}var di=new Map,Uw=new Set;function im(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Na=W.d;W.d={f:F2,r:U2,D:V2,C:G2,L:H2,m:q2,X:J2,S:z2,M:$2};function F2(){var i=Na.f(),l=Qf();return i||l}function U2(i){var l=Kr(i);l!==null&&l.tag===5&&l.type==="form"?rv(l):Na.r(i)}var ou=typeof document>"u"?null:document;function Vw(i,l,d){var m=ou;if(m&&typeof l=="string"&&l){var C=zn(l);C='link[rel="'+i+'"][href="'+C+'"]',typeof d=="string"&&(C+='[crossorigin="'+d+'"]'),Uw.has(C)||(Uw.add(C),i={rel:i,crossOrigin:d,href:l},m.querySelector(C)===null&&(l=m.createElement("link"),Gr(l,"link",i),qn(l),m.head.appendChild(l)))}}function V2(i){Na.D(i),Vw("dns-prefetch",i,null)}function G2(i,l){Na.C(i,l),Vw("preconnect",i,l)}function H2(i,l,d){Na.L(i,l,d);var m=ou;if(m&&i&&l){var C='link[rel="preload"][as="'+zn(l)+'"]';l==="image"&&d&&d.imageSrcSet?(C+='[imagesrcset="'+zn(d.imageSrcSet)+'"]',typeof d.imageSizes=="string"&&(C+='[imagesizes="'+zn(d.imageSizes)+'"]')):C+='[href="'+zn(i)+'"]';var v=C;switch(l){case"style":v=lu(i);break;case"script":v=cu(i)}di.has(v)||(i=y({rel:"preload",href:l==="image"&&d&&d.imageSrcSet?void 0:i,as:l},d),di.set(v,i),m.querySelector(C)!==null||l==="style"&&m.querySelector(Rd(v))||l==="script"&&m.querySelector(Pd(v))||(l=m.createElement("link"),Gr(l,"link",i),qn(l),m.head.appendChild(l)))}}function q2(i,l){Na.m(i,l);var d=ou;if(d&&i){var m=l&&typeof l.as=="string"?l.as:"script",C='link[rel="modulepreload"][as="'+zn(m)+'"][href="'+zn(i)+'"]',v=C;switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=cu(i)}if(!di.has(v)&&(i=y({rel:"modulepreload",href:i},l),di.set(v,i),d.querySelector(C)===null)){switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(d.querySelector(Pd(v)))return}m=d.createElement("link"),Gr(m,"link",i),qn(m),d.head.appendChild(m)}}}function z2(i,l,d){Na.S(i,l,d);var m=ou;if(m&&i){var C=Xs(m).hoistableStyles,v=lu(i);l=l||"default";var A=C.get(v);if(!A){var V={loading:0,preload:null};if(A=m.querySelector(Rd(v)))V.loading=5;else{i=y({rel:"stylesheet",href:i,"data-precedence":l},d),(d=di.get(v))&&gB(i,d);var Z=A=m.createElement("link");qn(Z),Gr(Z,"link",i),Z._p=new Promise(function(ue,be){Z.onload=ue,Z.onerror=be}),Z.addEventListener("load",function(){V.loading|=1}),Z.addEventListener("error",function(){V.loading|=2}),V.loading|=4,am(A,l,m)}A={type:"stylesheet",instance:A,count:1,state:V},C.set(v,A)}}}function J2(i,l){Na.X(i,l);var d=ou;if(d&&i){var m=Xs(d).hoistableScripts,C=cu(i),v=m.get(C);v||(v=d.querySelector(Pd(C)),v||(i=y({src:i,async:!0},l),(l=di.get(C))&&pB(i,l),v=d.createElement("script"),qn(v),Gr(v,"link",i),d.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},m.set(C,v))}}function $2(i,l){Na.M(i,l);var d=ou;if(d&&i){var m=Xs(d).hoistableScripts,C=cu(i),v=m.get(C);v||(v=d.querySelector(Pd(C)),v||(i=y({src:i,async:!0,type:"module"},l),(l=di.get(C))&&pB(i,l),v=d.createElement("script"),qn(v),Gr(v,"link",i),d.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},m.set(C,v))}}function Gw(i,l,d,m){var C=(C=lt.current)?im(C):null;if(!C)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof d.precedence=="string"&&typeof d.href=="string"?(l=lu(d.href),d=Xs(C).hoistableStyles,m=d.get(l),m||(m={type:"style",instance:null,count:0,state:null},d.set(l,m)),m):{type:"void",instance:null,count:0,state:null};case"link":if(d.rel==="stylesheet"&&typeof d.href=="string"&&typeof d.precedence=="string"){i=lu(d.href);var v=Xs(C).hoistableStyles,A=v.get(i);if(A||(C=C.ownerDocument||C,A={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(i,A),(v=C.querySelector(Rd(i)))&&!v._p&&(A.instance=v,A.state.loading=5),di.has(i)||(d={rel:"preload",as:"style",href:d.href,crossOrigin:d.crossOrigin,integrity:d.integrity,media:d.media,hrefLang:d.hrefLang,referrerPolicy:d.referrerPolicy},di.set(i,d),v||K2(C,i,d,A.state))),l&&m===null)throw Error(r(528,""));return A}if(l&&m!==null)throw Error(r(529,""));return null;case"script":return l=d.async,d=d.src,typeof d=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=cu(d),d=Xs(C).hoistableScripts,m=d.get(l),m||(m={type:"script",instance:null,count:0,state:null},d.set(l,m)),m):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function lu(i){return'href="'+zn(i)+'"'}function Rd(i){return'link[rel="stylesheet"]['+i+"]"}function Hw(i){return y({},i,{"data-precedence":i.precedence,precedence:null})}function K2(i,l,d,m){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?m.loading=1:(l=i.createElement("link"),m.preload=l,l.addEventListener("load",function(){return m.loading|=1}),l.addEventListener("error",function(){return m.loading|=2}),Gr(l,"link",d),qn(l),i.head.appendChild(l))}function cu(i){return'[src="'+zn(i)+'"]'}function Pd(i){return"script[async]"+i}function qw(i,l,d){if(l.count++,l.instance===null)switch(l.type){case"style":var m=i.querySelector('style[data-href~="'+zn(d.href)+'"]');if(m)return l.instance=m,qn(m),m;var C=y({},d,{"data-href":d.href,"data-precedence":d.precedence,href:null,precedence:null});return m=(i.ownerDocument||i).createElement("style"),qn(m),Gr(m,"style",C),am(m,d.precedence,i),l.instance=m;case"stylesheet":C=lu(d.href);var v=i.querySelector(Rd(C));if(v)return l.state.loading|=4,l.instance=v,qn(v),v;m=Hw(d),(C=di.get(C))&&gB(m,C),v=(i.ownerDocument||i).createElement("link"),qn(v);var A=v;return A._p=new Promise(function(V,Z){A.onload=V,A.onerror=Z}),Gr(v,"link",m),l.state.loading|=4,am(v,d.precedence,i),l.instance=v;case"script":return v=cu(d.src),(C=i.querySelector(Pd(v)))?(l.instance=C,qn(C),C):(m=d,(C=di.get(v))&&(m=y({},d),pB(m,C)),i=i.ownerDocument||i,C=i.createElement("script"),qn(C),Gr(C,"link",m),i.head.appendChild(C),l.instance=C);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(m=l.instance,l.state.loading|=4,am(m,d.precedence,i));return l.instance}function am(i,l,d){for(var m=d.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),C=m.length?m[m.length-1]:null,v=C,A=0;A<m.length;A++){var V=m[A];if(V.dataset.precedence===l)v=V;else if(v!==C)break}v?v.parentNode.insertBefore(i,v.nextSibling):(l=d.nodeType===9?d.head:d,l.insertBefore(i,l.firstChild))}function gB(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.title==null&&(i.title=l.title)}function pB(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.integrity==null&&(i.integrity=l.integrity)}var om=null;function zw(i,l,d){if(om===null){var m=new Map,C=om=new Map;C.set(d,m)}else C=om,m=C.get(d),m||(m=new Map,C.set(d,m));if(m.has(i))return m;for(m.set(i,null),d=d.getElementsByTagName(i),C=0;C<d.length;C++){var v=d[C];if(!(v[Sr]||v[on]||i==="link"&&v.getAttribute("rel")==="stylesheet")&&v.namespaceURI!=="http://www.w3.org/2000/svg"){var A=v.getAttribute(l)||"";A=i+A;var V=m.get(A);V?V.push(v):m.set(A,[v])}}return m}function Jw(i,l,d){i=i.ownerDocument||i,i.head.insertBefore(d,l==="title"?i.querySelector("head > title"):null)}function Y2(i,l,d){if(d===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;switch(l.rel){case"stylesheet":return i=l.disabled,typeof l.precedence=="string"&&i==null;default:return!0}case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function $w(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function Q2(i,l,d,m){if(d.type==="stylesheet"&&(typeof m.media!="string"||matchMedia(m.media).matches!==!1)&&(d.state.loading&4)===0){if(d.instance===null){var C=lu(m.href),v=l.querySelector(Rd(C));if(v){l=v._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=lm.bind(i),l.then(i,i)),d.state.loading|=4,d.instance=v,qn(v);return}v=l.ownerDocument||l,m=Hw(m),(C=di.get(C))&&gB(m,C),v=v.createElement("link"),qn(v);var A=v;A._p=new Promise(function(V,Z){A.onload=V,A.onerror=Z}),Gr(v,"link",m),d.instance=v}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(d,l),(l=d.state.preload)&&(d.state.loading&3)===0&&(i.count++,d=lm.bind(i),l.addEventListener("load",d),l.addEventListener("error",d))}}var BB=0;
vendor: 4,454 bytes, line 49
49function W2(i,l){return i.stylesheets&&i.count===0&&um(i,i.stylesheets),0<i.count||0<i.imgCount?function(d){var m=setTimeout(function(){if(i.stylesheets&&um(i,i.stylesheets),i.unsuspend){var v=i.unsuspend;i.unsuspend=null,v()}},6e4+l);0<i.imgBytes&&BB===0&&(BB=62500*A2());var C=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&um(i,i.stylesheets),i.unsuspend)){var v=i.unsuspend;i.unsuspend=null,v()}},(i.imgBytes>BB?50:800)+l);return i.unsuspend=d,function(){i.unsuspend=null,clearTimeout(m),clearTimeout(C)}}:null}function lm(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)um(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var cm=null;function um(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,cm=new Map,l.forEach(X2,i),cm=null,lm.call(i))}function X2(i,l){if(!(l.state.loading&4)){var d=cm.get(i);if(d)var m=d.get(null);else{d=new Map,cm.set(i,d);for(var C=i.querySelectorAll("link[data-precedence],style[data-precedence]"),v=0;v<C.length;v++){var A=C[v];(A.nodeName==="LINK"||A.getAttribute("media")!=="not all")&&(d.set(A.dataset.precedence,A),m=A)}m&&d.set(null,m)}C=l.instance,A=C.getAttribute("data-precedence"),v=d.get(A)||m,v===m&&d.set(null,C),d.set(A,C),this.count++,m=lm.bind(this),C.addEventListener("load",m),C.addEventListener("error",m),v?v.parentNode.insertBefore(C,v.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(C,i.firstChild)),l.state.loading|=4}}var Md={$$typeof:F,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function Z2(i,l,d,m,C,v,A,V,Z){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Kt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Kt(0),this.hiddenUpdates=Kt(null),this.identifierPrefix=m,this.onUncaughtError=C,this.onCaughtError=v,this.onRecoverableError=A,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Z,this.incompleteTransitions=new Map}function Kw(i,l,d,m,C,v,A,V,Z,ue,be,_e){return i=new Z2(i,l,d,A,Z,ue,be,_e,V),l=1,v===!0&&(l|=24),v=Ls(3,null,null,l),i.current=v,v.stateNode=i,l=Qp(),l.refCount++,i.pooledCache=l,l.refCount++,v.memoizedState={element:m,isDehydrated:d,cache:l},e0(v),i}function Yw(i){return i?(i=Uc,i):Uc}function Qw(i,l,d,m,C,v){C=Yw(C),m.context===null?m.context=C:m.pendingContext=C,m=go(l),m.payload={element:d},v=v===void 0?null:v,v!==null&&(m.callback=v),d=po(i,m,l),d!==null&&(bs(d,i,l),fd(d,i,l))}function Ww(i,l){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var d=i.retryLane;i.retryLane=d!==0&&d<l?d:l}}function yB(i,l){Ww(i,l),(i=i.alternate)&&Ww(i,l)}function Xw(i){if(i.tag===13||i.tag===31){var l=Al(i,67108864);l!==null&&bs(l,i,67108864),yB(i,67108864)}}function Zw(i){if(i.tag===13||i.tag===31){var l=Vs();l=Rt(l);var d=Al(i,l);d!==null&&bs(d,i,l),yB(i,l)}}var dm=!0;function eR(i,l,d,m){var C=G.T;G.T=null;var v=W.p;try{W.p=2,xB(i,l,d,m)}finally{W.p=v,G.T=C}}function tR(i,l,d,m){var C=G.T;G.T=null;var v=W.p;try{W.p=8,xB(i,l,d,m)}finally{W.p=v,G.T=C}}function xB(i,l,d,m){if(dm){var C=CB(m);if(C===null)iB(i,l,m,hm,d),tE(i,m);else if(rR(C,i,l,d,m))m.stopPropagation();else if(tE(i,m),l&4&&-1<nR.indexOf(i)){for(;C!==null;){var v=Kr(C);if(v!==null)switch(v.tag){case 3:if(v=v.stateNode,v.current.memoizedState.isDehydrated){var A=$n(v.pendingLanes);if(A!==0){var V=v;for(V.pendingLanes|=2,V.entangledLanes|=2;A;){var Z=1<<31-jt(A);V.entanglements[1]|=Z,A&=~Z}$i(v),(rn&6)===0&&(Kf=yn()+500,Sd(0))}}break;case 31:case 13:V=Al(v,2),V!==null&&bs(V,v,2),Qf(),yB(v,2)}if(v=CB(m),v===null&&iB(i,l,m,hm,d),v===C)break;C=v}C!==null&&m.stopPropagation()}else iB(i,l,m,null,d)}}function CB(i){return i=ti(i),bB(i)}var hm=null;function bB(i){if(hm=null,i=ps(i),i!==null){var l=a(i);if(l===null)i=null;else{var d=l.tag;if(d===13){if(i=c(l),i!==null)return i;i=null}else if(d===31){if(i=u(l),i!==null)return i;i=null}else if(d===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;i=null}else l!==i&&(i=null)}}return hm=i,null}function eE(i){switch(i){case"beforetoggle":case"cancel":case"click":case"close"
vendor: 4,141 bytes, line 49
49:case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(kt()){case re:return 2;case Ne:return 8;case De:case qe:return 32;case je:return 268435456;default:return 32}default:return 32}}var vB=!1,ko=null,No=null,So=null,Ld=new Map,jd=new Map,Do=[],nR="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function tE(i,l){switch(i){case"focusin":case"focusout":ko=null;break;case"dragenter":case"dragleave":No=null;break;case"mouseover":case"mouseout":So=null;break;case"pointerover":case"pointerout":Ld.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":jd.delete(l.pointerId)}}function Od(i,l,d,m,C,v){return i===null||i.nativeEvent!==v?(i={blockedOn:l,domEventName:d,eventSystemFlags:m,nativeEvent:v,targetContainers:[C]},l!==null&&(l=Kr(l),l!==null&&Xw(l)),i):(i.eventSystemFlags|=m,l=i.targetContainers,C!==null&&l.indexOf(C)===-1&&l.push(C),i)}function rR(i,l,d,m,C){switch(l){case"focusin":return ko=Od(ko,i,l,d,m,C),!0;case"dragenter":return No=Od(No,i,l,d,m,C),!0;case"mouseover":return So=Od(So,i,l,d,m,C),!0;case"pointerover":var v=C.pointerId;return Ld.set(v,Od(Ld.get(v)||null,i,l,d,m,C)),!0;case"gotpointercapture":return v=C.pointerId,jd.set(v,Od(jd.get(v)||null,i,l,d,m,C)),!0}return!1}function nE(i){var l=ps(i.target);if(l!==null){var d=a(l);if(d!==null){if(l=d.tag,l===13){if(l=c(d),l!==null){i.blockedOn=l,vr(i.priority,function(){Zw(d)});return}}else if(l===31){if(l=u(d),l!==null){i.blockedOn=l,vr(i.priority,function(){Zw(d)});return}}else if(l===3&&d.stateNode.current.memoizedState.isDehydrated){i.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}i.blockedOn=null}function fm(i){if(i.blockedOn!==null)return!1;for(var l=i.targetContainers;0<l.length;){var d=CB(i.nativeEvent);if(d===null){d=i.nativeEvent;var m=new d.constructor(d.type,d);Wu=m,d.target.dispatchEvent(m),Wu=null}else return l=Kr(d),l!==null&&Xw(l),i.blockedOn=d,!1;l.shift()}return!0}function rE(i,l,d){fm(i)&&d.delete(l)}function sR(){vB=!1,ko!==null&&fm(ko)&&(ko=null),No!==null&&fm(No)&&(No=null),So!==null&&fm(So)&&(So=null),Ld.forEach(rE),jd.forEach(rE)}function mm(i,l){i.blockedOn===l&&(i.blockedOn=null,vB||(vB=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,sR)))}var gm=null;function sE(i){gm!==i&&(gm=i,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){gm===i&&(gm=null);for(var l=0;l<i.length;l+=3){var d=i[l],m=i[l+1],C=i[l+2];if(typeof m!="function"){if(bB(m||d)===null)continue;break}var v=Kr(d);v!==null&&(i.splice(l,3),l-=3,C0(v,{pending:!0,data:C,method:d.method,action:m},m,C))}}))}function uu(i){function l(Z){return mm(Z,i)}ko!==null&&mm(ko,i),No!==null&&mm(No,i),So!==null&&mm(So,i),Ld.forEach(l),jd.forEach(l);for(var d=0;d<Do.length;d++){var m=Do[d];m.blockedOn===i&&(m.blockedOn=null)}for(;0<Do.length&&(d=Do[0],d.blockedOn===null);)nE(d),d.blockedOn===null&&Do.shift();if(d=(i.ownerDocument||i).$$reactFormReplay,d!=null)for(m=0;m<d.length;
vendor: 4,293 bytes, line 49
49m+=3){var C=d[m],v=d[m+1],A=C[Nt]||null;if(typeof v=="function")A||sE(d);else if(A){var V=null;if(v&&v.hasAttribute("formAction")){if(C=v,A=v[Nt]||null)V=A.formAction;else if(bB(C)!==null)continue}else V=A.action;typeof V=="function"?d[m+1]=V:(d.splice(m,3),m-=3),sE(d)}}}function iE(){function i(v){v.canIntercept&&v.info==="react-transition"&&v.intercept({handler:function(){return new Promise(function(A){return C=A})},focusReset:"manual",scroll:"manual"})}function l(){C!==null&&(C(),C=null),m||setTimeout(d,20)}function d(){if(!m&&!navigation.transition){var v=navigation.currentEntry;v&&v.url!=null&&navigation.navigate(v.url,{state:v.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var m=!1,C=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",l),navigation.addEventListener("navigateerror",l),setTimeout(d,100),function(){m=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),C!==null&&(C(),C=null)}}}function wB(i){this._internalRoot=i}pm.prototype.render=wB.prototype.render=function(i){var l=this._internalRoot;if(l===null)throw Error(r(409));var d=l.current,m=Vs();Qw(d,m,i,l,null,null)},pm.prototype.unmount=wB.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var l=i.containerInfo;Qw(i.current,2,null,i,null,null),Qf(),l[Cn]=null}};function pm(i){this._internalRoot=i}pm.prototype.unstable_scheduleHydration=function(i){if(i){var l=$r();i={blockedOn:null,target:i,priority:l};for(var d=0;d<Do.length&&l!==0&&l<Do[d].priority;d++);Do.splice(d,0,i),d===0&&nE(i)}};var aE=e.version;if(aE!=="19.2.8")throw Error(r(527,aE,"19.2.8"));W.findDOMNode=function(i){var l=i._reactInternals;if(l===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=f(l),i=i!==null?p(i):null,i=i===null?null:i.stateNode,i};var iR={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:G,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Bm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bm.isDisabled&&Bm.supportsFiber)try{ht=Bm.inject(iR),Qe=Bm}catch{}}return Ud.createRoot=function(i,l){if(!s(i))throw Error(r(299));var d=!1,m="",C=fv,v=mv,A=gv;return l!=null&&(l.unstable_strictMode===!0&&(d=!0),l.identifierPrefix!==void 0&&(m=l.identifierPrefix),l.onUncaughtError!==void 0&&(C=l.onUncaughtError),l.onCaughtError!==void 0&&(v=l.onCaughtError),l.onRecoverableError!==void 0&&(A=l.onRecoverableError)),l=Kw(i,1,!1,null,null,d,m,null,C,v,A,iE),i[Cn]=l.current,sB(i),new wB(l)},Ud.hydrateRoot=function(i,l,d){if(!s(i))throw Error(r(299));var m=!1,C="",v=fv,A=mv,V=gv,Z=null;return d!=null&&(d.unstable_strictMode===!0&&(m=!0),d.identifierPrefix!==void 0&&(C=d.identifierPrefix),d.onUncaughtError!==void 0&&(v=d.onUncaughtError),d.onCaughtError!==void 0&&(A=d.onCaughtError),d.onRecoverableError!==void 0&&(V=d.onRecoverableError),d.formState!==void 0&&(Z=d.formState)),l=Kw(i,1,!0,l,d??null,m,C,Z,v,A,V,iE),l.context=Yw(null),d=l.current,m=Vs(),m=Rt(m),C=go(m),C.callback=null,po(d,C,m),d=m,l.current.lanes=d,$e(l,d),$i(l),i[Cn]=l.current,sB(i),new pm(l)},Ud.version="19.2.8",Ud}var pE;function BR(){if(pE)return TB.exports;pE=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),TB.exports=pR(),TB.exports}var yR=BR(),Le=(n=>(n.Home="HOME",n.ItineraryBuilder="ITINERARY_BUILDER",n.ExpertsHub="EXPERTS_HUB",n.ConsultantDashboard="CONSULTANT_DASHBOARD",n.TripManagement="TRIP_MANAGEMENT",n.AdminHub="ADMIN_HUB",n.TripDashboard="TRIP_DASHBOARD",n.Booking="BOOKING",n.EditProfile="EDIT_PROFILE",n.ReviewManagement="REVIEW_MANAGEMENT",n.Help="HELP",n.About="ABOUT",n.Privacy="PRIVACY",n.Terms="TERMS",n.Reports="REPORTS",n.Stories="STORIES",n.Blog="STORIES",n))(Le||{});const nh=[{id:"bwindi",name:"Bwindi Impenetrable National Park",shortCode:"BINP",hint:"Gorillas, Trekking",description:"Step into Bwindi’s misty rainforest for life-changing gorilla trekking in Uganda, where ancient trees shelter the world’s rarest mou
49ntain gorillas. Every trek reveals deep silence, earthy scents, and a soul-stirring bond with nature. Stay at Nkuringo Gorilla Lodge*, an eco-luxury base leading conservation and community-powered tourism.",imageUrl:"https://picsum.photos/seed/bwindi/800/600",parkFee:40,flyInAirstrip:!0,keywords:["mountain gorillas","gorilla trekking","Buhoma","Nkuringo","Ruhija","Rushaga","Batwa pygmies","birding","impenetrable forest","UNESCO World Heritage site","primates","gorillas","trekking","gorilla tracking","apes","rainforest","misty","giants","mountain gorilla","gorilla","forest"],activities:[{id:"binp-gorilla-tracking",name:"Gorilla Tracking",durationTag:"All-day",description:"An unforgettable journey to see mountain gorillas in their natural habitat.",price:800,unit:"per person",includesParkEntryFee:!0,requiresVehicle:!0,isFullDay:!0,permitProcessingFee:30},{id:"binp-gorilla-habituation",name:"Gorilla Habituation Experience",durationTag:"All-day",description:"Spend more time with a gorilla family that is being habituated.",price:1500,unit:"per person",includesParkEntryFee:!0,requiresVehicle:!0,isFullDay:!0,permitProcessingFee:30},{id:"binp-bird-watching",name:"Bird Watching & Nature Walk",durationTag:"Morning",description:"Explore the diverse flora and fauna of the ancient rainforest.",price:40,unit:"per person",includesParkEntryFee:!1,requiresVehicle:!1},{id:"binp-batwa-experience",name:"Batwa Forest Experience",durationTag:"Afternoon",description:"Visit the indigenous Batwa community and learn about their traditional forest life.",price:40,unit:"per person",includesParkEntryFee:!1,requiresVehicle:!1},{id:"binp-long-walk",name:"Long Walk (Buhoma-Nkuringo)",durationTag:"All-day",description:"A scenic guided walk between the Buhoma and Nkuringo sectors of the park.",price:60,unit:"per person",includesParkEntryFee:!1,requiresVehicle:!1}]},{id:"queen-elizabeth",name:"Queen Elizabeth National Park",shortCode:"QENP",hint:"Safari, Lions, Boat Cruise",description:"Uganda's most popular park, boasting diverse ecosystems from savannah to forests and wetlands.",imageUrl:"https://picsum.photos/seed/qenp/800/600",parkFee:40,flyInAirstrip:!0,keywords:["tree-climbing lions","Ishasha","Kazinga Channel","boat cruise","safari","elephants","buffalo","hippo","Kyambura Gorge","chimpanzees","Mweya Peninsula","game drive"],activities:[{id:"qenp-game-drive",name:"Guided Game Drive",description:"Explore the Kasenyi plains, famous for lions, elephants, and vast herds of Uganda Kob.",price:25,unit:"per guide",includesParkEntryFee:!1,requiresVehicle:!0},{id:"qenp-launch-trip",name:"Kazinga Channel Launch Trip",description:"A boat safari with incredible sightings of hippos, crocodiles, buffalo, and diverse birdlife.",price:30,unit:"per person",includesParkEntryFee:!1,requiresVehicle:!0},{id:"qenp-lion-tracking",name:"Lion Tracking Experience",description:"Join researchers to track and learn about the park's famous tree-climbing lions.",price:200,unit:"per person",includesParkEntryFee:!0,requiresVehicle:!0,permitProcessingFee:30},{id:"qenp-chimp-tracking",name:"Chimp Tracking (Kyambura Gorge)",description:'Descend into the "Valley of Apes" to track a troop of habituated chimpanzees.',price:100,unit:"per person",includesParkEntryFee:!0,requiresVehicle:!0,permitProcessingFee:30},{id:"qenp-mongoose-tracking",name:"Mongoose Tracking",description:"An experiential tourism activity on the Mweya Peninsula.",price:30,unit:"per person",includesParkEntryFee:!0,requiresVehicle:!0,permitProcessingFee:30}]},{id:"kibale",name:"Kibale Forest National Park",shortCode:"KNP",hint:"Chimpanzees, Primates",description:'Known as the "Primate Capital of the World," with 13 species of primates.',imageUrl:"https://picsum.photos/seed/kibale/800/600",parkFee:40,flyInAirstrip:!0,keywords:["chimpanzee tracking","chimp habituation","primate capital","Bigodi Wetland Sanctuary","monkeys","red colobus","L'Hoest's monkey","forest walk","chimps"],activities:[{id:"knp-chimp-tracking",name:"Chimpanzee Tracking",description:"An unforgettable trek to find and observe our closest living relatives.",price:250,unit:"per person",includesParkEntryFee:!0,requiresVehicle:!0,permitProcessingFee:30},{id:"knp-chimp-habituation",name:"Chimpanzee Habituation (Full Day)",description:"Spend a full day with researchers and a chimpanzee troop undergoing habituation.",price:300,unit:"per person",includesParkEntryFee:!0,requiresVehicle:!0,isFullDay:!0,permitProcessingFee:30},{id:"knp-children-walk",name:"Guided Short Walk for Children",description:"A safe and educational nature walk for young explorers.",price:5,unit:"per person",includesParkEntryFee:!1,requiresVehicle:!1}]},{id:"murchison-falls",name:"Murchison Falls National Park",shortCode:"MFNP",hint:"Waterfall, Game Drives",description:"Famous for its powerful waterfall where the Nile River forces its way through a narrow gorge.",imageUrl:"https://picsum.photos/seed/murchison/800/600",parkFee:45,flyInAirstrip:!0,keywords:["Nile river","boat cruise","top of the falls hike","Rothschild's g
49iraffe","game drive","delta","shoebill stork","Paraa","waterfall"],activities:[{id:"mfnp-launch-trip",name:"Launch Trip to Falls Bottom",description:"A boat cruise on the Nile to the base of the spectacular Murchison Falls.",price:30,unit:"per person",includesParkEntryFee:!1,requiresVehicle:!0},{id:"mfnp-game-drive",name:"Guided Game Drive",description:"Search for lions, giraffes, elephants, and leopards on the northern bank.",price:25,unit:"per guide",includesParkEntryFee:!1,requiresVehicle:!0},{id:"mfnp-hike-top-falls",name:"Hike to Top of Falls",description:"A rewarding hike to see the powerful waterfall from above.",price:15,unit:"per person",includesParkEntryFee:!1,requiresVehicle:!0},{id:"mfnp-night-drive",name:"Night Game Drive",description:"Discover the park's nocturnal animals with a spotlight.",price:40,unit:"per person",includesParkEntryFee:!1,requiresVehicle:!0},{id:"mfnp-bird-watching",name:"Bird Watching",description:"A guided walk to spot some of the 451 bird species in the park.",price:25,unit:"per person",includesParkEntryFee:!1,requiresVehicle:!1}]},{id:"lake-mburo",name:"Lake Mburo National Park",shortCode:"LMNP",parkFee:40,activities:[],description:"Known for zebras, impalas, and unique walking and horseback safaris.",imageUrl:"https://picsum.photos/seed/mburo/800/600",flyInAirstrip:!0,keywords:["zebras","giraffes","impala","walking safari","horseback riding safari","night game drive","Ankole cattle"]},{id:"mgahinga",name:"Mgahinga Gorilla National Park",shortCode:"MGNP",parkFee:40,activities:[],description:"Where silver meets gold: track gorillas and golden monkeys in the Virunga volcanoes.",imageUrl:"https://picsum.photos/seed/mgahinga/800/600",flyInAirstrip:!0,keywords:["mountain gorillas","golden monkey tracking","Virunga volcanoes","Mount Sabinyo","Mount Gahinga","Mount Muhabura","Batwa trail","three volcanoes"]},{id:"kidepo-valley",name:"Kidepo Valley National Park",shortCode:"KVNP",parkFee:40,activities:[],description:"A remote, rugged wilderness in northern Uganda, home to ostriches and cheetahs.",imageUrl:"https://picsum.photos/seed/kidepo/800/600",flyInAirstrip:!0,keywords:["remote wilderness","ostriches","cheetahs","Narus Valley","Apoka","Karamojong people","rugged savannah","big game"]},{id:"jinja",name:"Jinja",parkFee:0,activities:[],description:"The adventure capital of East Africa, located at the source of the Nile River.",imageUrl:"https://picsum.photos/seed/jinja/800/600",keywords:["source of the Nile","white-water rafting","kayaking","bungee jumping","Owen Falls Dam","adventure capital","quad biking"]},{id:"sipi-falls",name:"Sipi Falls",parkFee:0,activities:[],description:"A series of three stunning waterfalls on the edge of Mount Elgon National Park.",imageUrl:"https://picsum.photos/seed/sipi/800/600",keywords:["Mount Elgon","hiking","waterfalls","abseiling","coffee tours","beautiful scenery","Kapchorwa"]},{id:"semuliki",name:"Semuliki National Park",shortCode:"SNP",parkFee:35,activities:[],description:"Experience the Sempaya hot springs and unique birdlife from the Ituri Forest.",imageUrl:"https://picsum.photos/seed/semuliki/800/600",flyInAirstrip:!0,keywords:["Sempaya hot springs","bird watching","Ituri forest","shoebill stork","Congo basin biome","primates"]},{id:"ziwa-rhino",name:"Ziwa Rhino Sanctuary",parkFee:20,activities:[],description:"The only place in Uganda to track wild southern white rhinos on foot.",imageUrl:"https://picsum.photos/seed/ziwa/800/600",keywords:["rhino tracking","white rhinos","conservation","Nakasongola","breeding program","rhinos"]},{id:"kampala",name:"Kampala",parkFee:0,activities:[],description:"Uganda's vibrant capital city, offering rich cultural and historical experiences.",imageUrl:"https://picsum.photos/seed/kampala/800/600",keywords:["capital city","boda boda tours","Gaddafi National Mosque","Kasubi Tombs","Namugongo Martyrs Shrine","craft markets","nightlife"]},{id:"entebbe",name:"Entebbe",parkFee:0,activities:[],description:"A relaxed town on Lake Victoria, home to the international airport and wildlife sanctuaries.",imageUrl:"https://picsum.photos/seed/entebbe/800/600",flyInAirstrip:!0,keywords:["EBB","airport","Lake Victoria","UWEC","Uganda Wildlife Education Centre","Botanical Gardens","Ngamba Island Chimpanzee Sanctuary"]}
49],rh=[{id:"bwindi-nkuringo",name:"Nkuringo Gorilla Lodge",destinationId:"bwindi",isDefault:!0,imageUrl:"https://picsum.photos/seed/nkuringo-lodge/800/600",keywords:["luxury","gorilla trekking","Nkuringo sector","Bwindi lodge","impenetrable forest","views","high-end","family friendly"],features:["Forest Views","Mountain Views","Local Family-Owned","Close to Trekking","Sustainable"],rooms:[{id:"nk-cottage",name:"Forest Cottage",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:526,lowSeasonPriceDouble:405,highSeasonPriceSingle:745,highSeasonPriceDouble:575},{id:"nk-suite",name:"Forest Suite",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:910,lowSeasonPriceDouble:700,highSeasonPriceSingle:1215,highSeasonPriceDouble:935},{id:"nk-villa",name:"2-Bedroom Villa",maxOccupancy:4,pricingModel:"perNight",lowSeasonPricePerNight:1365,highSeasonPricePerNight:1950}]},{id:"bwindi-clouds",name:"Clouds Mountain Gorilla Lodge",destinationId:"bwindi",isDefault:!1,imageUrl:"https://picsum.photos/seed/clouds-lodge/800/600",keywords:["ultra-luxury","gorilla tracking","Nkuringo","exclusive","butler service","community-owned","honeymoon"],features:["Ultra-Luxury","Personal Butler Service","Community-Owned","Fireplace in Room"],rooms:[{id:"clouds-cottage",name:"Standard Cottage",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:800,lowSeasonPriceDouble:600,highSeasonPriceSingle:1e3,highSeasonPriceDouble:750},{id:"clouds-family",name:"Family Cottage",maxOccupancy:5,pricingModel:"perNight",lowSeasonPricePerNight:2e3,highSeasonPricePerNight:2500}]},{id:"qe-katara",name:"Katara Lodge",destinationId:"queen-elizabeth",isDefault:!0,imageUrl:"https://picsum.photos/seed/katara-lodge/800/600",keywords:["mid-range","views","eco-lodge","QENP","Kazinga Channel","thatched roof","swimming pool"],features:["Valley Views","Eco-Lodge","Swimming Pool","Private Balcony"],rooms:[{id:"katara-banda",name:"Thatched Banda",maxOccupancy:3,pricingModel:"perPerson",lowSeasonPriceSingle:250,lowSeasonPriceDouble:180,highSeasonPriceSingle:320,highSeasonPriceDouble:220}]},{id:"qe-marafiki",name:"Marafiki Safari Lodge",destinationId:"queen-elizabeth",isDefault:!1,imageUrl:"https://picsum.photos/seed/marafiki-lodge/800/600",keywords:["budget","mid-range","safari tents","cabins","Lake George view","Queen Elizabeth lodge"],features:["Lake Views","Safari Tents","Great Value","Restaurant & Bar"],rooms:[{id:"marafiki-cabin",name:"Wooden Cabin",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:280,lowSeasonPriceDouble:200,highSeasonPriceSingle:350,highSeasonPriceDouble:250},{id:"marafiki-tent",name:"Safari Tent",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:200,lowSeasonPriceDouble:150,highSeasonPriceSingle:250,highSeasonPriceDouble:180}]},{id:"kibale-mirima",name:"Mirima Kibale Lodge",destinationId:"kibale",isDefault:!0,imageUrl:"https://picsum.photos/seed/mirima-lodge/800/600",keywords:["budget","chimpanzee tracking","Kibale Forest","eco-friendly","value"],rooms:[{id:"mirima-std",name:"Standard Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:180,lowSeasonPriceDouble:130,highSeasonPriceSingle:220,highSeasonPriceDouble:160}]},{id:"kibale-primate",name:"Primate Lodge Kibale",destinationId:"kibale",isDefault:!1,imageUrl:"https://picsum.photos/seed/primate-lodge/800/600",keywords:["luxury","inside the park","chimps","forest cottages","safari tents","Kibale lodge"],features:["Inside the National Park","Forest Cottages","Close to Chimp Trekking Start"],rooms:[{id:"primate-cottage",name:"Forest Cottage",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:350,lowSeasonPriceDouble:280,highSeasonPriceSingle:420,highSeasonPriceDouble:330},{id:"primate-tent",name:"Luxury Safari Tent",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:450,lowSeasonPriceDouble:350,highSeasonPriceSingle:550,highSeasonPriceDouble:420}]},{id:"murchison-nile",name:"Nile Safari Lodge",destinationId:"murchison-falls",isDefault:!0,imageUrl:"https://picsum.photos/seed/nile-lodge/800/600",keywords:["luxury","Nile river","Murchison Falls lodge","exclusive","swimming pool","high-end"],features:["Direct River Nile Access","Luxury Bandas","Swimming Pool","Exclusive Feel"],rooms:[{id:"nile-banda",name:"Deluxe Banda",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:500,lowSeasonPriceDouble:400,highSeasonPriceSingle:650,highSeasonPriceDouble:500},{id:"nile-exclusive",name:"Exclusive Banda",maxOccupancy:3,pricingModel:"perPerson",lowSeasonPriceSingle:650,lowSeasonPriceDouble:520,highSeasonPriceSingle:800,highSeasonPriceDouble:650}]},{id:"murchison-paraa",name:"Paraa Safari Lodge",destinationId:"murchison-falls",isDefault:!1,imageUrl:"https://picsum.photos/seed/paraa-lodge/800/600",keywords:["large lodge","mid-range","Paraa","Nile river","family friendly","classic safari"],rooms:[{id:"paraa-std",name:"Standard Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:300,lowSeasonPriceDouble:240,highSeasonPriceSingle:380,highSeasonPriceDouble:290}
49,{id:"paraa-suite",name:"Suite",maxOccupancy:4,pricingModel:"perNight",lowSeasonPricePerNight:800,highSeasonPricePerNight:1e3}]},{id:"qe-kasenyi",name:"Kasenyi Safari Lodge",destinationId:"queen-elizabeth",isDefault:!1,rooms:[{id:"kasenyi-std",name:"Standard Cottage",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:300,lowSeasonPriceDouble:220,highSeasonPriceSingle:380,highSeasonPriceDouble:280}],imageUrl:"https://picsum.photos/seed/kasenyi-lodge/800/600",keywords:["mid-range","Kasenyi plains","lion tracking","QENP lodge"]},{id:"qe-meya",name:"Meya Safari Lodge",destinationId:"queen-elizabeth",isDefault:!1,rooms:[{id:"meya-deluxe",name:"Deluxe Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:450,lowSeasonPriceDouble:350,highSeasonPriceSingle:550,highSeasonPriceDouble:420}],imageUrl:"https://picsum.photos/seed/meya-lodge/800/600",keywords:["luxury","Kichwamba escarpment","views","Queen Elizabeth lodge"]},{id:"qe-elephant-plains",name:"Elephant Plains Lodge",destinationId:"queen-elizabeth",isDefault:!1,rooms:[{id:"eplains-cottage",name:"Private Cottage",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:500,lowSeasonPriceDouble:400,highSeasonPriceSingle:620,highSeasonPriceDouble:480}],imageUrl:"https://picsum.photos/seed/e-plains-lodge/800/600",keywords:["luxury","eco-lodge","views","infinity pool","QENP lodge"]},{id:"qe-kyambura",name:"Kyambura Gorge Lodge",destinationId:"queen-elizabeth",isDefault:!1,rooms:[{id:"kyambura-banda",name:"Banda",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:600,lowSeasonPriceDouble:450,highSeasonPriceSingle:750,highSeasonPriceDouble:550}],imageUrl:"https://picsum.photos/seed/kyambura-lodge/800/600",keywords:["luxury","boutique","chimpanzee tracking","Kyambura Gorge","Volcanoes Safaris"]},{id:"qe-ishasha-wilderness",name:"Ishasha Wilderness Lodge",destinationId:"queen-elizabeth",isDefault:!1,rooms:[{id:"ishasha-w-tent",name:"Canvas Tent",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:480,lowSeasonPriceDouble:380,highSeasonPriceSingle:590,highSeasonPriceDouble:450}],imageUrl:"https://picsum.photos/seed/ishasha-w-lodge/800/600",keywords:["luxury","tented camp","Ishasha","tree-climbing lions","remote"]},{id:"qe-enjojo",name:"Enjojo Lodge",destinationId:"queen-elizabeth",isDefault:!1,rooms:[{id:"enjojo-cottage",name:"Thatched Cottage",maxOccupancy:3,pricingModel:"perPerson",lowSeasonPriceSingle:180,lowSeasonPriceDouble:130,highSeasonPriceSingle:220,highSeasonPriceDouble:160}],imageUrl:"https://picsum.photos/seed/enjojo-lodge/800/600",keywords:["budget","mid-range","Ishasha","eco-friendly","family friendly"]},{id:"qe-ishasha-jungle",name:"Ishasha Jungle Lodge",destinationId:"queen-elizabeth",isDefault:!1,rooms:[{id:"ishasha-j-banda",name:"Banda",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:250,lowSeasonPriceDouble:190,highSeasonPriceSingle:310,highSeasonPriceDouble:230}],imageUrl:"https://picsum.photos/seed/ishasha-j-lodge/800/600",keywords:["mid-range","Ishasha","river views","raised platforms"]},{id:"bwindi-erebero",name:"Erebero Hills Lodge",destinationId:"bwindi",isDefault:!1,rooms:[{id:"erebero-std",name:"Standard Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:280,lowSeasonPriceDouble:200,highSeasonPriceSingle:350,highSeasonPriceDouble:250}],imageUrl:"https://picsum.photos/seed/erebero-lodge/800/600",keywords:["mid-range","Bwindi","views","eco-friendly"]},{id:"bwindi-leisure",name:"Gorilla Leisure Lodge",destinationId:"bwindi",isDefault:!1,rooms:[{id:"leisure-std",name:"Standard Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:320,lowSeasonPriceDouble:240,highSeasonPriceSingle:400,highSeasonPriceDouble:290}],imageUrl:"https://picsum.photos/seed/leisure-lodge/800/600",keywords:["mid-range","Rushaga","gorilla trekking","Bwindi lodge"]},{id:"bwindi-four-gorillas",name:"Four Gorillas Lodge",destinationId:"bwindi",isDefault:!1,rooms:[{id:"four-g-villa",name:"Private Villa",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:550,lowSeasonPriceDouble:420,highSeasonPriceSingle:680,highSeasonPriceDouble:520}],imageUrl:"https://picsum.photos/seed/four-g-lodge/800/600",keywords:["luxury","Rushaga","private villas","Bwindi lodge"]},{id:"bwindi-icumbi",name:"Icumbi Gorilla Lodge",destinationId:"bwindi",isDefault:!1,rooms:[{id:"icumbi-std",name:"Standard Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:150,lowSeasonPriceDouble:110,highSeasonPriceSingle:190,highSeasonPriceDouble:140}],imageUrl:"https://picsum.photos/seed/icumbi-lodge/800/600",keywords:["budget","Rushaga","community","value","Bwindi lodge"]},{id:"bwindi-mahogany",name:"Mahogany Springs Lodge",destinationId:"bwindi",isDefault:!1,rooms:[{id:"mah
49ogany-suite",name:"Superior Suite",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:470,lowSeasonPriceDouble:360,highSeasonPriceSingle:580,highSeasonPriceDouble:440}],imageUrl:"https://picsum.photos/seed/mahogany-lodge/800/600",keywords:["luxury","Buhoma","river view","high-end","Bwindi lodge"]},{id:"bwindi-sanctuary",name:"Sanctuary Gorilla forest Lodge",destinationId:"bwindi",isDefault:!1,rooms:[{id:"sanctuary-tent",name:"Luxury Tent",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:850,lowSeasonPriceDouble:650,highSeasonPriceSingle:1050,highSeasonPriceDouble:800}],imageUrl:"https://picsum.photos/seed/sanctuary-lodge/800/600",keywords:["ultra-luxury","Buhoma","inside the park","tented camp","exclusive"]},{id:"bwindi-buhoma-haven",name:"Buhoma Haven Lodge",destinationId:"bwindi",isDefault:!1,rooms:[{id:"haven-banda",name:"Banda",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:290,lowSeasonPriceDouble:210,highSeasonPriceSingle:360,highSeasonPriceDouble:260}],imageUrl:"https://picsum.photos/seed/haven-lodge/800/600",keywords:["mid-range","Buhoma","community-owned","views","Bwindi lodge"]},{id:"bwindi-buhoma",name:"Buhoma Lodge",destinationId:"bwindi",isDefault:!1,rooms:[{id:"buhoma-chalet",name:"Chalet",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:500,lowSeasonPriceDouble:400,highSeasonPriceSingle:620,highSeasonPriceDouble:480}],imageUrl:"https://picsum.photos/seed/buhoma-lodge/800/600",keywords:["luxury","Buhoma","eco-lodge","top-rated","Bwindi lodge"]},{id:"bwindi-volcanoes",name:"Volcanoes Bwindi Lodge",destinationId:"bwindi",isDefault:!1,rooms:[{id:"volcanoes-banda",name:"Banda",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:650,lowSeasonPriceDouble:500,highSeasonPriceSingle:800,highSeasonPriceDouble:620}],imageUrl:"https://picsum.photos/seed/volcanoes-lodge/800/600",keywords:["luxury","Buhoma","classic safari","views","Volcanoes Safaris"]},{id:"mgahinga-mount",name:"Mount Gahinga Lodge",destinationId:"mgahinga",isDefault:!0,rooms:[{id:"gahinga-banda",name:"Luxury Banda",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:600,lowSeasonPriceDouble:450,highSeasonPriceSingle:750,highSeasonPriceDouble:550}],imageUrl:"https://picsum.photos/seed/gahinga-lodge/800/600",keywords:["luxury","gorilla trekking","golden monkeys","Virunga volcanoes","Volcanoes Safaris"]},{id:"mgahinga-chahafi",name:"Lake Chahafi Resort",destinationId:"mgahinga",isDefault:!1,rooms:[{id:"chahafi-cabin",name:"Cabin",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:140,lowSeasonPriceDouble:100,highSeasonPriceSingle:180,highSeasonPriceDouble:130}],imageUrl:"https://picsum.photos/seed/chahafi-lodge/800/600",keywords:["budget","mid-range","lake view","Kisoro"]},{id:"mgahinga-travellers",name:"Travellers Rest Hotel",destinationId:"mgahinga",isDefault:!1,rooms:[{id:"travellers-room",name:"Standard Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:120,lowSeasonPriceDouble:90,highSeasonPriceSingle:150,highSeasonPriceDouble:110}],imageUrl:"https://picsum.photos/seed/travellers-lodge/800/600",keywords:["historic","budget","Kisoro","Dian Fossey"]},{id:"mgahinga-mutanda",name:"Mutanda Lake Resort",destinationId:"mgahinga",isDefault:!1,rooms:[{id:"mutanda-cottage",name:"Cottage",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:280,lowSeasonPriceDouble:210,highSeasonPriceSingle:340,highSeasonPriceDouble:260}],imageUrl:"https://picsum.photos/seed/mutanda-lodge/800/600",keywords:["mid-range","lake view","stunning scenery","Kisoro"]},{id:"mgahinga-chameleon",name:"Chameleon Hill Forest Lodge",destinationId:"mgahinga",isDefault:!1,rooms:[{id:"chameleon-chalet",name:"Chalet",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:450,lowSeasonPriceDouble:350,highSeasonPriceSingle:550,highSeasonPriceDouble:420}],imageUrl:"https://picsum.photos/seed/chameleon-lodge/800/600",keywords:["luxury","unique","colorful","lake view","boutique"]},{id:"mburo-mihingo",name:"Mihingo Lodge",destinationId:"lake-mburo",isDefault:!0,rooms:[{id:"mihingo-tent",name:"Luxury Tent",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:400,lowSeasonPriceDouble:300,highSeasonPriceSingle:500,highSeasonPriceDouble:380}],imageUrl:"https://picsum.photos/seed/mihingo-lodge/800/600",keywords:["luxury","eco-lodge","horseback safari","infinity pool","views"]},{id:"mburo-rwakobo",name:"Rwakobo Rock Lodge",destinationId:"lake-mburo",isDefault:!1,rooms:[{id:"rwakobo-cottage",name:"Cottage",maxOccupancy:4,pricingModel:"perPerson",lowSeasonPriceSingle:200,lowSeasonPriceDouble:150,highSeasonPriceSingle:250,highSeasonPriceDouble:180}],imageUrl:"https://picsum.photos/seed/rwakobo-lodge/800/600",keywords:["mid-range","views","family friendly","eco-friendly"]}
49,{id:"mburo-kigambira",name:"Kigambira Safari Lodge",destinationId:"lake-mburo",isDefault:!1,rooms:[{id:"kigambira-banda",name:"Banda",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:250,lowSeasonPriceDouble:190,highSeasonPriceSingle:310,highSeasonPriceDouble:230}],imageUrl:"https://picsum.photos/seed/kigambira-lodge/800/600",keywords:["mid-range","tented camp","Lake Mburo lodge"]},{id:"mburo-kigarama",name:"Kigarama Wilderness Lodge",destinationId:"lake-mburo",isDefault:!1,rooms:[{id:"kigarama-banda",name:"Banda",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:130,lowSeasonPriceDouble:90,highSeasonPriceSingle:160,highSeasonPriceDouble:110}],imageUrl:"https://picsum.photos/seed/kigarama-lodge/800/600",keywords:["budget","views","eco-friendly","Lake Mburo lodge"]},{id:"mburo-eagles",name:"Eagles Nest",destinationId:"lake-mburo",isDefault:!1,rooms:[{id:"eagles-tent",name:"Safari Tent",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:100,lowSeasonPriceDouble:70,highSeasonPriceSingle:120,highSeasonPriceDouble:85}],imageUrl:"https://picsum.photos/seed/eagles-nest-lodge/800/600",keywords:["budget","tented camp","views","basic"]},{id:"kampala-latitude",name:"Latitude 0",destinationId:"kampala",isDefault:!1,rooms:[{id:"latitude-std",name:"Standard Room",maxOccupancy:2,pricingModel:"perNight",lowSeasonPricePerNight:300,highSeasonPricePerNight:350}],imageUrl:"https://picsum.photos/seed/latitude-lodge/800/600",keywords:["luxury","boutique hotel","Kampala","swimming pool","spa"]},{id:"kampala-petit",name:"Le Petit Village",destinationId:"kampala",isDefault:!0,rooms:[{id:"petit-std",name:"Standard Room",maxOccupancy:2,pricingModel:"perNight",lowSeasonPricePerNight:200,highSeasonPricePerNight:240}],imageUrl:"https://picsum.photos/seed/petit-lodge/800/600",keywords:["boutique hotel","mid-range","Kampala","unique design"]},{id:"kampala-serena",name:"Serena Hotel",destinationId:"kampala",isDefault:!1,rooms:[{id:"serena-deluxe",name:"Deluxe Room",maxOccupancy:2,pricingModel:"perNight",lowSeasonPricePerNight:350,highSeasonPricePerNight:420}],imageUrl:"https://picsum.photos/seed/serena-lodge/800/600",keywords:["luxury","5-star hotel","Kampala","business travel"]},{id:"kidepo-apoka",name:"Apoka Safari Lodge",destinationId:"kidepo-valley",isDefault:!0,rooms:[{id:"apoka-room",name:"Safari Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:700,lowSeasonPriceDouble:550,highSeasonPriceSingle:850,highSeasonPriceDouble:680}],imageUrl:"https://picsum.photos/seed/apoka-lodge/800/600",keywords:["luxury","remote","Kidepo lodge","swimming pool","exclusive"]},{id:"kidepo-savannah",name:"Kidepo Savannah Lodge",destinationId:"kidepo-valley",isDefault:!1,rooms:[{id:"kidepo-s-tent",name:"Safari Tent",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:200,lowSeasonPriceDouble:150,highSeasonPriceSingle:250,highSeasonPriceDouble:180}],imageUrl:"https://picsum.photos/seed/kidepo-s-lodge/800/600",keywords:["mid-range","budget","Kidepo lodge","views","tents"]},{id:"kidepo-adere",name:"Adere Safari Lodge",destinationId:"kidepo-valley",isDefault:!1,rooms:[{id:"adere-cottage",name:"Cottage",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:280,lowSeasonPriceDouble:210,highSeasonPriceSingle:340,highSeasonPriceDouble:260}],imageUrl:"https://picsum.photos/seed/adere-lodge/800/600",keywords:["mid-range","Kidepo lodge","swimming pool"]},{id:"ziwa-amuka",name:"Amuka Lodge",destinationId:"ziwa-rhino",isDefault:!0,rooms:[{id:"amuka-chalet",name:"Chalet",maxOccupancy:4,pricingModel:"perPerson",lowSeasonPriceSingle:220,lowSeasonPriceDouble:170,highSeasonPriceSingle:270,highSeasonPriceDouble:210}],imageUrl:"https://picsum.photos/seed/amuka-lodge/800/600",keywords:["mid-range","rhino tracking","family friendly","swimming pool"]},{id:"sipi-heritage",name:"Sipi Heritage",destinationId:"sipi-falls",isDefault:!0,rooms:[{id:"sipi-h-room",name:"Standard Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:150,lowSeasonPriceDouble:110,highSeasonPriceSingle:180,highSeasonPriceDouble:140}],imageUrl:"https://picsum.photos/seed/sipi-h-lodge/800/600",keywords:["mid-range","Sipi Falls lodge","views","hiking"]},{id:"jinja-lemala",name:"Lemala Wild Waters Lodge",destinationId:"jinja",isDefault:!0,rooms:[{id:"lemala-suite",name:"River Suite",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:480,lowSeasonPriceDouble:380,highSeasonPriceSingle:590,highSeasonPriceDouble:450}],imageUrl:"https://picsum.photos/seed/lemala-lodge/800/600",keywords:["luxury","private island","Nile river","adventure"]},{id:"jinja-adrift",name:"Adrif River Club",destinationId:"jinja",isDefault:!1,rooms:[{id:"adrift-cottage",name:"Cottage",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:250,lowSeasonPriceDouble:190,highSeasonPriceSingle:310,highSeasonPriceDouble:230}],imageUrl:"https://picsum.photos/seed/adrift-lodge/800/600",keywords:["mid-range","bungee jumping","Nile river","adventure"]}
49,{id:"jinja-haven",name:"The Haven Lodge, Jinja",destinationId:"jinja",isDefault:!1,rooms:[{id:"haven-j-banda",name:"Banda",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:220,lowSeasonPriceDouble:170,highSeasonPriceSingle:270,highSeasonPriceDouble:210}],imageUrl:"https://picsum.photos/seed/haven-j-lodge/800/600",keywords:["mid-range","family friendly","Nile river","swimming pool"]},{id:"semuliki-safari",name:"Semuliki Safari Lodge",destinationId:"semuliki",isDefault:!0,rooms:[{id:"semuliki-tent",name:"Canvas Tent",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:450,lowSeasonPriceDouble:350,highSeasonPriceSingle:550,highSeasonPriceDouble:420}],imageUrl:"https://picsum.photos/seed/semuliki-lodge/800/600",keywords:["luxury","remote","tented camp","hot springs"]},{id:"entebbe-papyrus",name:"Papyrus Guesthouse",destinationId:"entebbe",isDefault:!0,rooms:[{id:"papyrus-room",name:"Standard Room",maxOccupancy:2,pricingModel:"perNight",lowSeasonPricePerNight:120,highSeasonPricePerNight:140}],imageUrl:"https://picsum.photos/seed/papyrus-lodge/800/600",keywords:["guesthouse","budget","Entebbe","airport hotel"]},{id:"entebbe-boma",name:"The Boma Hotel",destinationId:"entebbe",isDefault:!1,rooms:[{id:"boma-room",name:"Standard Room",maxOccupancy:2,pricingModel:"perNight",lowSeasonPricePerNight:180,highSeasonPricePerNight:220}],imageUrl:"https://picsum.photos/seed/boma-lodge/800/600",keywords:["mid-range","boutique hotel","Entebbe","colonial style"]},{id:"entebbe-protea",name:"Protea Hotel",destinationId:"entebbe",isDefault:!1,rooms:[{id:"protea-room",name:"Standard Room",maxOccupancy:2,pricingModel:"perNight",lowSeasonPricePerNight:250,highSeasonPricePerNight:300}],imageUrl:"https://picsum.photos/seed/protea-lodge/800/600",keywords:["luxury","Marriott","Entebbe","Lake Victoria"]},{id:"entebbe-no5",name:"No.5 Boutique Hotel",destinationId:"entebbe",isDefault:!1,rooms:[{id:"no5-room",name:"Luxury Room",maxOccupancy:2,pricingModel:"perNight",lowSeasonPricePerNight:320,highSeasonPricePerNight:380}],imageUrl:"https://picsum.photos/seed/no5-lodge/800/600",keywords:["luxury","boutique hotel","Entebbe","spa","exclusive"]},{id:"murchison-fort",name:"Fort Murchison Lodge",destinationId:"murchison-falls",isDefault:!1,rooms:[{id:"fort-m-room",name:"Standard Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:150,lowSeasonPriceDouble:110,highSeasonPriceSingle:180,highSeasonPriceDouble:140}],imageUrl:"https://picsum.photos/seed/fort-m-lodge/800/600",keywords:["budget","mid-range","Murchison lodge","tents","thatched rooms"]},{id:"murchison-river",name:"Murchison River Lodge",destinationId:"murchison-falls",isDefault:!1,rooms:[{id:"m-river-cottage",name:"Thatched Cottage",maxOccupancy:4,pricingModel:"perPerson",lowSeasonPriceSingle:220,lowSeasonPriceDouble:170,highSeasonPriceSingle:270,highSeasonPriceDouble:210}],imageUrl:"https://picsum.photos/seed/m-river-lodge/800/600",keywords:["mid-range","family friendly","Nile river","thatched cottages","tents"]},{id:"murchison-pakuba",name:"Pakuba Safari Lodge",destinationId:"murchison-falls",isDefault:!1,rooms:[{id:"pakuba-room",name:"Standard Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:280,lowSeasonPriceDouble:210,highSeasonPriceSingle:340,highSeasonPriceDouble:260}],imageUrl:"https://picsum.photos/seed/pakuba-lodge/800/600",keywords:["mid-range","game viewing","Albert Nile","Murchison lodge"]},{id:"murchison-entikko",name:"Entikko Safari Lodge",destinationId:"murchison-falls",isDefault:!1,rooms:[{id:"entikko-room",name:"Standard Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:130,lowSeasonPriceDouble:95,highSeasonPriceSingle:160,highSeasonPriceDouble:120}],imageUrl:"https://picsum.photos/seed/entikko-lodge/800/600",keywords:["budget","Murchison lodge","new"]}
49,{id:"murchison-twiga",name:"Twiga Safari Lodge",destinationId:"murchison-falls",isDefault:!1,rooms:[{id:"twiga-tent",name:"Safari Tent",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:300,lowSeasonPriceDouble:230,highSeasonPriceSingle:370,highSeasonPriceDouble:280}],imageUrl:"https://picsum.photos/seed/twiga-lodge/800/600",keywords:["mid-range","safari tents","Nile river","views"]},{id:"kibale-lodge",name:"Kibale Lodge",destinationId:"kibale",isDefault:!1,rooms:[{id:"kibale-l-cottage",name:"Cottage",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:260,lowSeasonPriceDouble:200,highSeasonPriceSingle:320,highSeasonPriceDouble:240}],imageUrl:"https://picsum.photos/seed/kibale-lodge/800/600",keywords:["mid-range","Kibale Forest","chimpanzee tracking"]},{id:"kibale-forest-camp",name:"Kibale Forest Camp",destinationId:"kibale",isDefault:!1,rooms:[{id:"k-f-camp-tent",name:"Safari Tent",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:190,lowSeasonPriceDouble:140,highSeasonPriceSingle:230,highSeasonPriceDouble:170}],imageUrl:"https://picsum.photos/seed/k-f-camp/800/600",keywords:["budget","mid-range","tented camp","Kibale","chimps"]},{id:"kibale-isunga",name:"Isunga Lodge",destinationId:"kibale",isDefault:!1,rooms:[{id:"isunga-cottage",name:"Cottage",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:240,lowSeasonPriceDouble:180,highSeasonPriceSingle:290,highSeasonPriceDouble:220}],imageUrl:"https://picsum.photos/seed/isunga-lodge/800/600",keywords:["mid-range","views","eco-friendly","Kibale lodge"]},{id:"kibale-turaco",name:"Turaco Tree Tops",destinationId:"kibale",isDefault:!1,rooms:[{id:"turaco-treetop",name:"Treetop Cabin",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:270,lowSeasonPriceDouble:210,highSeasonPriceSingle:330,highSeasonPriceDouble:250}],imageUrl:"https://picsum.photos/seed/turaco-lodge/800/600",keywords:["mid-range","treetops","Kibale","unique"]},{id:"kibale-chimpanzee",name:"Chimpanzee Forest Lodge",destinationId:"kibale",isDefault:!1,rooms:[{id:"chimp-f-room",name:"Main House Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:210,lowSeasonPriceDouble:160,highSeasonPriceSingle:260,highSeasonPriceDouble:190}],imageUrl:"https://picsum.photos/seed/chimp-f-lodge/800/600",keywords:["mid-range","guesthouse","tea plantation","Kibale"]},{id:"kibale-papaya",name:"Papaya Lake Lodge",destinationId:"kibale",isDefault:!1,rooms:[{id:"papaya-cottage",name:"Luxury Cottage",maxOccupancy:3,pricingModel:"perPerson",lowSeasonPriceSingle:500,lowSeasonPriceDouble:400,highSeasonPriceSingle:620,highSeasonPriceDouble:480}],imageUrl:"https://picsum.photos/seed/papaya-lodge/800/600",keywords:["luxury","crater lakes","swimming pool","views","boutique"]},{id:"kibale-ndali",name:"Ndali Lodge",destinationId:"kibale",isDefault:!1,rooms:[{id:"ndali-cottage",name:"Cottage",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:480,lowSeasonPriceDouble:380,highSeasonPriceSingle:590,highSeasonPriceDouble:450}],imageUrl:"https://picsum.photos/seed/ndali-lodge/800/600",keywords:["luxury","classic","crater lake","historic","Kibale"]}],$l=[{id:"r1",itineraryId:"TU-COMPLETED1",consultantId:"c1",travelerName:"Sarah J.",rating:5,comment:"Cathy was incredible! Her knowledge of the gorillas in Bwindi was amazing. She made our trip unforgettable. Highly recommended!",consultantReply:"Thank you, Sarah! It was a pleasure planning your adventure. So glad you enjoyed the gorillas!"},{id:"r2",itineraryId:"TU-COMPLETED2",consultantId:"c2",travelerName:"Mike & Lisa",rating:5,comment:"Diana organized a fantastic cultural tour. We learned so much and felt truly welcomed by the local communities. Uganda Safari is a fantastic platform."},{id:"r3",itineraryId:"TU-COMPLETED3",consultantId:"c1",travelerName:"Chen W.",rating:4,comment:"Great trip to Murchison Falls. Cathy was very professional. The boat cruise was the highlight. Only wish we had more time!"}],xR=[{id:"TU-COMPLETED1",title:"Sarah J. x2 Safari",travelerName:"Sarah J.",travelerEmail:"[email protected]",duration:3,stops:[],consultantId:"c1",status:"completed",startDate:"2024-05-10",travelerCount:2,startLocation:"kigali",endLocation:"entebbe",totalPrice:4500},{id:"TU-COMPLETED2",title:"Mike & Lisa x4 Safari",travelerName:"Mike & Lisa",travelerEmail:"[email protected]",duration:7,stops:[],consultantId:"c2",status:"completed",startDate:"2024-06-20",travelerCount:4,startLocation:"entebbe",endLocation:"entebbe",totalPrice:9800},{id:"TU-COMPLETED3",title:"Chen W. x1 Safari",travelerName:"Chen W.",travelerEmail:"[email protected]",duration:4,stops:[],consultantId:"c1",status:"completed",startDate:"2024-0
497-01",travelerCount:1,startLocation:"entebbe",endLocation:"entebbe",totalPrice:2100},{id:"TU-XYZ123",title:"Test User x2 Safari",travelerName:"Test User",travelerEmail:"[email protected]",duration:5,stops:[],consultantId:"c2",status:"confirmed",startDate:"2024-09-15",travelerCount:2,startLocation:"entebbe",endLocation:"kigali",totalPrice:6200},{id:"TU-PLANNING1",title:"Alex Smith x2 Safari",travelerName:"Alex Smith",travelerEmail:"[email protected]",duration:6,stops:[],consultantId:"c3",status:"planning",startDate:"2024-10-05",travelerCount:2,startLocation:"entebbe",endLocation:"entebbe",totalPrice:8500},{id:"TU-CANCELLED1",title:"Jane Doe x3 Safari",travelerName:"Jane Doe",travelerEmail:"[email protected]",duration:3,stops:[],consultantId:"c1",status:"cancelled",startDate:"2024-08-20",travelerCount:3,startLocation:"entebbe",endLocation:"entebbe",totalPrice:4100},{id:"TU-CONFIRMED2",title:"The Miller Family x4 Safari",travelerName:"The Miller Family",travelerEmail:"[email protected]",duration:10,stops:[],consultantId:"c2",status:"confirmed",startDate:"2024-11-15",travelerCount:4,startLocation:"entebbe",endLocation:"entebbe",totalPrice:15500}],Xo={road:{cruiser:300,van:200},flyIn:300},Kl=[{id:"op_aerolink",name:"Aerolink"}],Yl=[{id:"fc_1",from:"entebbe",to:"murchison-falls",cost:260,operatorId:"op_aerolink"},{id:"fc_2",from:"entebbe",to:"kidepo-valley",cost:450,operatorId:"op_aerolink"},{id:"fc_3",from:"entebbe",to:"queen-elizabeth",cost:250,operatorId:"op_aerolink"},{id:"fc_4",from:"entebbe",to:"kibale",cost:250,operatorId:"op_aerolink"},{id:"fc_5",from:"entebbe",to:"bwindi",cost:290,operatorId:"op_aerolink"},{id:"fc_6",from:"entebbe",to:"mgahinga",cost:290,operatorId:"op_aerolink"},{id:"fc_7",from:"bwindi",to:"mgahinga",cost:150,operatorId:"op_aerolink"},{id:"fc_8",from:"bwindi",to:"queen-elizabeth",cost:160,operatorId:"op_aerolink"},{id:"fc_9",from:"bwindi",to:"kibale",cost:160,operatorId:"op_aerolink"},{id:"fc_10",from:"bwindi",to:"murchison-falls",cost:280,operatorId:"op_aerolink"},{id:"fc_11",from:"mgahinga",to:"queen-elizabeth",cost:170,operatorId:"op_aerolink"},{id:"fc_12",from:"mgahinga",to:"kibale",cost:170,operatorId:"op_aerolink"},{id:"fc_13",from:"queen-elizabeth",to:"murchison-falls",cost:280,operatorId:"op_aerolink"},{id:"fc_14",from:"kibale",to:"murchison-falls",cost:280,operatorId:"op_aerolink"}],CR={entebbe:["lake-mburo","kampala","jinja"],kampala:["ziwa-rhino","lake-mburo","jinja"],kigali:["bwindi","mgahinga"],"lake-mburo":["queen-elizabeth","bwindi","kampala","entebbe"],bwindi:["queen-elizabeth","mgahinga","lake-mburo"],mgahinga:["bwindi","lake-mburo"],"queen-elizabeth":["kibale","bwindi","lake-mburo"],kibale:["queen-elizabeth","murchison-falls","semuliki","kampala"],semuliki:["kibale"],"ziwa-rhino":["murchison-falls","kampala"],"murchison-falls":["kibale","kidepo-valley","ziwa-rhino","jinja"],"kidepo-valley":["murchison-falls","sipi-falls"],jinja:["sipi-falls","kampala"],"sipi-falls":["kidepo-valley","jinja"]};/**
50 * @license lucide-react v1.41.0 - ISC
51 *
52 * This source code is licensed under the ISC license.
53 * See the LICENSE file in the root directory of this source tree.
54 */const qN=(...n)=>n.filter((e,t,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===t).join(" ").trim();/**
55 * @license lucide-react v1.41.0 - ISC
56 *
57 * This source code is licensed under the ISC license.
58 * See the LICENSE file in the root directory of this source tree.
59 */const bR=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
60 * @license lucide-react v1.41.0 - ISC
61 *
62 * This source code is licensed under the ISC license.
63 * See the LICENSE file in the root directory of this source tree.
64 */const vR=n=>n.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase());/**
65 * @license lucide-react v1.41.0 - ISC
66 *
67 * This source code is licensed under the ISC license.
68 * See the LICENSE file in the root directory of this source tree.
69 */const BE=n=>{const e=vR(n);return e.charAt(0).toUpperCase()+e.slice(1)};/**
70 * @license lucide-react v1.41.0 - ISC
71 *
72 * This source code is licensed under the ISC license.
73 * See the LICENSE file in the root directory of this source tree.
74 */var DB={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"};/**
75 * @license lucide-react v1.41.0 - ISC
76 *
77 * This source code is licensed under the ISC license.
78 * See the LICENSE file in the root directory of this source tree.
79 */const wR=n=>{for(const e in n)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},ER=R.createContext({}),_R=()=>R.useContext(ER),TR=R.forwardRef(({color:n,size:e,strokeWidth:t,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},h)=>{const{size:f=24,strokeWidth:p=2,absoluteStrokeWidth:y=!1,color:b="
79currentColor",className:w=""}=_R()??{},E=r??y?Number(t??p)*24/Number(e??f):t??p;return R.createElement("svg",{ref:h,...DB,width:e??f??DB.width,height:e??f??DB.height,stroke:n??b,strokeWidth:E,className:qN("lucide",w,s),...!a&&!wR(u)&&{"aria-hidden":"true"},...u},[...c.map(([N,S])=>R.createElement(N,S)),...Array.isArray(a)?a:[a]])});/**
80 * @license lucide-react v1.41.0 - ISC
81 *
82 * This source code is licensed under the ISC license.
83 * See the LICENSE file in the root directory of this source tree.
84 */const Ke=(n,e)=>{const t=R.forwardRef(({className:r,...s},a)=>R.createElement(TR,{ref:a,iconNode:e,className:qN(`lucide-${bR(BE(n))}`,`lucide-${n}`,r),...s}));return t.displayName=BE(n),t};/**
85 * @license lucide-react v1.41.0 - ISC
86 *
87 * This source code is licensed under the ISC license.
88 * See the LICENSE file in the root directory of this source tree.
89 */const kR=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Bh=Ke("arrow-right",kR);/**
90 * @license lucide-react v1.41.0 - ISC
91 *
92 * This source code is licensed under the ISC license.
93 * See the LICENSE file in the root directory of this source tree.
94 */const NR=[["path",{d:"M12 5v16",key:"1f6ucr"}],["path",{d:"M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z",key:"1fyvmf"}]],rg=Ke("book-open",NR);/**
95 * @license lucide-react v1.41.0 - ISC
96 *
97 * This source code is licensed under the ISC license.
98 * See the LICENSE file in the root directory of this source tree.
99 */const SR=[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]],DR=Ke("calendar",SR);/**
100 * @license lucide-react v1.41.0 - ISC
101 *
102 * This source code is licensed under the ISC license.
103 * See the LICENSE file in the root directory of this source tree.
104 */const AR=[["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"}]],IR=Ke("camera",AR);/**
105 * @license lucide-react v1.41.0 - ISC
106 *
107 * This source code is licensed under the ISC license.
108 * See the LICENSE file in the root directory of this source tree.
109 */const RR=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Jg=Ke("check",RR);/**
110 * @license lucide-react v1.41.0 - ISC
111 *
112 * This source code is licensed under the ISC license.
113 * See the LICENSE file in the root directory of this source tree.
114 */const PR=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],MR=Ke("chevron-down",PR);/**
115 * @license lucide-react v1.41.0 - ISC
116 *
117 * This source code is licensed under the ISC license.
118 * See the LICENSE file in the root directory of this source tree.
119 */const LR=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],zN=Ke("chevron-left",LR);/**
120 * @license lucide-react v1.41.0 - ISC
121 *
122 * This source code is licensed under the ISC license.
123 * See the LICENSE file in the root directory of this source tree.
124 */const jR=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ax=Ke("chevron-right",jR);/**
125 * @license lucide-react v1.41.0 - ISC
126 *
127 * This source code is licensed under the ISC license.
128 * See the LICENSE file in the root directory of this source tree.
129 */const OR=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],FR=Ke("chevrons-left",OR);/**
130 * @license lucide-react v1.41.0 - ISC
131 *
132 * This source code is licensed under the ISC license.
133 * See the LICENSE file in the root directory of this source tree.
134 */const UR=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],VR=Ke("chevrons-right",UR);/**
135 * @license lucide-react v1.41.0 - ISC
136 *
137 * This source code is licensed under the ISC license.
138 * See the LICENSE file in the root directory of this source tree.
139 */const GR=[["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"}]],uc=Ke("circle-alert",GR);/**
140 * @license lucide-react v1.41.0 - ISC
141 *
142 * This source code is licensed under the ISC license.
143 * See the LICENSE file in the root directory of this source tree.
144 */const HR=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ox=Ke("circle-check-big",HR);/**
145 * @license lucide-react v1.41.0 - ISC
146 *
147 * This source code is licensed under the ISC license.
148 * See the LICENSE file in the root directory of this source tree.
149 */const qR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 9-5.5 5.5L8 12",key:"xofnsj"}]],Ga=Ke("circle-check",qR);/**
150 * @license lucide-react v1.41.0 - ISC
151 *
152 * This source code is licensed under the ISC license.
153 * See the LICENSE file in the root directory of this source tree.
154 */const zR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],JR=Ke("circle-plus",zR);/**
155 * @license lucide-react v1.41.0 - ISC
156 *
157 * This source code is licensed under the ISC license.
158 * See the LICENSE file in the root directory of this source tree.
159 */const $R=[["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"}]],KR=Ke("circle-question-mark",$R);/**
160 * @license lucide-react v1.41.0 - ISC
161 *
162 * This source code is licensed under the ISC license.
163 * See the LICENSE file in the root directory of this source tree.
164 */const YR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],QR=Ke("circle",YR);/**
165 * @license lucide-react v1.41.0 - ISC
166 *
167 * This source code is licensed under the ISC license.
168 * See the LICENSE file in the root directory of this source tree.
169 */const WR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Si=Ke("clock",WR);/**
170 * @license lucide-react v1.41.0 - ISC
171 *
172 * This source code is licensed under the ISC license.
173 * See the LICENSE file in the root directory of this source tree.
174 */const XR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",ke
174y:"9ktpf1"}]],sg=Ke("compass",XR);/**
175 * @license lucide-react v1.41.0 - ISC
176 *
177 * This source code is licensed under the ISC license.
178 * See the LICENSE file in the root directory of this source tree.
179 */const ZR=[["path",{d:"M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5",key:"laymnq"}],["path",{d:"M8.5 8.5v.01",key:"ue8clq"}],["path",{d:"M16 15.5v.01",key:"14dtrp"}],["path",{d:"M12 12v.01",key:"u5ubse"}],["path",{d:"M11 17v.01",key:"1hyl5a"}],["path",{d:"M7 14v.01",key:"uct60s"}]],JN=Ke("cookie",ZR);/**
180 * @license lucide-react v1.41.0 - ISC
181 *
182 * This source code is licensed under the ISC license.
183 * See the LICENSE file in the root directory of this source tree.
184 */const eP=[["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"}]],$N=Ke("copy",eP);/**
185 * @license lucide-react v1.41.0 - ISC
186 *
187 * This source code is licensed under the ISC license.
188 * See the LICENSE file in the root directory of this source tree.
189 */const tP=[["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"}]],nP=Ke("database",tP);/**
190 * @license lucide-react v1.41.0 - ISC
191 *
192 * This source code is licensed under the ISC license.
193 * See the LICENSE file in the root directory of this source tree.
194 */const rP=[["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"}]],AB=Ke("eye-off",rP);/**
195 * @license lucide-react v1.41.0 - ISC
196 *
197 * This source code is licensed under the ISC license.
198 * See the LICENSE file in the root directory of this source tree.
199 */const sP=[["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"}]],Vm=Ke("eye",sP);/**
200 * @license lucide-react v1.41.0 - ISC
201 *
202 * This source code is licensed under the ISC license.
203 * See the LICENSE file in the root directory of this source tree.
204 */const iP=[["path",{d:"M14.086 18.412A2 2 0 0112.67 19H5v-7.672a2 2 0 01.586-1.414L11.75 3.75a6 6 0 118.49 8.49z",key:"1nq9jb"}],["path",{d:"M16 8 2 22",key:"vp34q"}],["path",{d:"M17.488 15H9",key:"16yirz"}]],KN=Ke("feather",iP);/**
205 * @license lucide-react v1.41.0 - ISC
206 *
207 * This source code is licensed under the ISC license.
208 * See the LICENSE file in the root directory of this source tree.
209 */const aP=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],YN=Ke("funnel",aP);/**
210 * @license lucide-react v1.41.0 - ISC
211 *
212 * This source code is licensed under the ISC license.
213 * See the LICENSE file in the root directory of this source tree.
214 */const oP=[["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"}],["path",{d:"M3.22 13H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"auskq0"}]],lP=Ke("heart-pulse",oP);/**
215 * @license lucide-react v1.41.0 - ISC
216 *
217 * This source code is licensed under the ISC license.
218 * See the LICENSE file in the root directory of this source tree.
219 */const cP=[["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"}]],QN=Ke("heart",cP);/**
220 * @license lucide-react v1.41.0 - ISC
221 *
222 * This source code is licensed under the ISC license.
223 * See the LICENSE file in the root directory of this source tree.
224 */const uP=[["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"}]],WN=Ke("image",uP);/**
225 * @license lucide-react v1.41.0 - ISC
226 *
227 * This source code is licensed under the ISC license.
228 * See the LICENSE file in the root directory of this source tree.
229 */const dP=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],gy=Ke("key-round",dP);/**
230 * @license lucide-react v1.41.0 - ISC
231 *
232 * This source code is licensed under the ISC license.
233 * See the LICENSE file in the root directory of this source tree.
234 */const hP=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],fP=Ke("lightbulb",hP);
234/**
235 * @license lucide-react v1.41.0 - ISC
236 *
237 * This source code is licensed under the ISC license.
238 * See the LICENSE file in the root directory of this source tree.
239 */const mP=[["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"}]],XN=Ke("link",mP);/**
240 * @license lucide-react v1.41.0 - ISC
241 *
242 * This source code is licensed under the ISC license.
243 * See the LICENSE file in the root directory of this source tree.
244 */const gP=[["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"}]],IB=Ke("lock",gP);/**
245 * @license lucide-react v1.41.0 - ISC
246 *
247 * This source code is licensed under the ISC license.
248 * See the LICENSE file in the root directory of this source tree.
249 */const pP=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],BP=Ke("log-out",pP);/**
250 * @license lucide-react v1.41.0 - ISC
251 *
252 * This source code is licensed under the ISC license.
253 * See the LICENSE file in the root directory of this source tree.
254 */const yP=[["path",{d:"M6 20a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1m57jg"}],["path",{d:"M8 18V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v14",key:"1l99gc"}],["path",{d:"M10 20h4",key:"ni2waw"}],["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]],xP=Ke("luggage",yP);/**
255 * @license lucide-react v1.41.0 - ISC
256 *
257 * This source code is licensed under the ISC license.
258 * See the LICENSE file in the root directory of this source tree.
259 */const CP=[["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"}]],$g=Ke("mail",CP);/**
260 * @license lucide-react v1.41.0 - ISC
261 *
262 * This source code is licensed under the ISC license.
263 * See the LICENSE file in the root directory of this source tree.
264 */const bP=[["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"}]],jh=Ke("map-pin",bP);/**
265 * @license lucide-react v1.41.0 - ISC
266 *
267 * This source code is licensed under the ISC license.
268 * See the LICENSE file in the root directory of this source tree.
269 */const vP=[["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"}]],Gm=Ke("message-square",vP);/**
270 * @license lucide-react v1.41.0 - ISC
271 *
272 * This source code is licensed under the ISC license.
273 * See the LICENSE file in the root directory of this source tree.
274 */const wP=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],RB=Ke("moon",wP);/**
275 * @license lucide-react v1.41.0 - ISC
276 *
277 * This source code is licensed under the ISC license.
278 * See the LICENSE file in the root directory of this source tree.
279 */const EP=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],_P=Ke("pen-line",EP);/**
280 * @license lucide-react v1.41.0 - ISC
281 *
282 * This source code is licensed under the ISC license.
283 * See the LICENSE file in the root directory of this source tree.
284 */const TP=[["path",{d:"M13 2a9 9 0 0 1 9 9",key:"1itnx2"}],["path",{d:"M13 6a5 5 0 0 1 5 5",key:"11nki7"}],["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"}]],kP=Ke("phone-call",TP);/**
285 * @license lucide-react v1.41.0 - ISC
286 *
287 * This source code is licensed under the ISC license.
288 * See the LICENSE file in the root directory of this source tree.
289 */const NP=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 
2890 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"}]],SP=Ke("phone",NP);/**
290 * @license lucide-react v1.41.0 - ISC
291 *
292 * This source code is licensed under the ISC license.
293 * See the LICENSE file in the root directory of this source tree.
294 */const DP=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],AP=Ke("plus",DP);/**
295 * @license lucide-react v1.41.0 - ISC
296 *
297 * This source code is licensed under the ISC license.
298 * See the LICENSE file in the root directory of this source tree.
299 */const IP=[["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"}]],RP=Ke("refresh-cw",IP);/**
300 * @license lucide-react v1.41.0 - ISC
301 *
302 * This source code is licensed under the ISC license.
303 * See the LICENSE file in the root directory of this source tree.
304 */const PP=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],MP=Ke("rotate-ccw",PP);/**
305 * @license lucide-react v1.41.0 - ISC
306 *
307 * This source code is licensed under the ISC license.
308 * See the LICENSE file in the root directory of this source tree.
309 */const LP=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],yh=Ke("search",LP);/**
310 * @license lucide-react v1.41.0 - ISC
311 *
312 * This source code is licensed under the ISC license.
313 * See the LICENSE file in the root directory of this source tree.
314 */const jP=[["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"}]],ZN=Ke("send",jP);/**
315 * @license lucide-react v1.41.0 - ISC
316 *
317 * This source code is licensed under the ISC license.
318 * See the LICENSE file in the root directory of this source tree.
319 */const OP=[["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"}]],FP=Ke("share-2",OP);/**
320 * @license lucide-react v1.41.0 - ISC
321 *
322 * This source code is licensed under the ISC license.
323 * See the LICENSE file in the root directory of this source tree.
324 */const UP=[["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"}]],yE=Ke("shield-alert",UP);/**
325 * @license lucide-react v1.41.0 - ISC
326 *
327 * This source code is licensed under the ISC license.
328 * See the LICENSE file in the root directory of this source tree.
329 */const VP=[["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"}]],xh=Ke("shield-check",VP);/**
330 * @license lucide-react v1.41.0 - ISC
331 *
332 * This source code is licensed under the ISC license.
333 * See the LICENSE file in the root directory of this source tree.
334 */const GP=[["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"}]],HP=Ke("shield",GP);/**
335 * @license lucide-react v1.41.0 - ISC
336 *
337 * This source code is licensed under the ISC license.
338 * See the LICENSE file in the root directory of this source tree.
339 */const qP=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],zP=Ke("sliders-horizontal",qP);/**
340 * @license lucide-react v1.41.0 - ISC
341 *
342 * This source code is licensed under the ISC license.
343 * See the LICENSE file in the root directory of this source tree.
344 */const JP=[["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 
3441.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"}]],dc=Ke("sparkles",JP);/**
345 * @license lucide-react v1.41.0 - ISC
346 *
347 * This source code is licensed under the ISC license.
348 * See the LICENSE file in the root directory of this source tree.
349 */const $P=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],eS=Ke("square-check-big",$P);/**
350 * @license lucide-react v1.41.0 - ISC
351 *
352 * This source code is licensed under the ISC license.
353 * See the LICENSE file in the root directory of this source tree.
354 */const KP=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],PB=Ke("sun",KP);/**
355 * @license lucide-react v1.41.0 - ISC
356 *
357 * This source code is licensed under the ISC license.
358 * See the LICENSE file in the root directory of this source tree.
359 */const YP=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],tS=Ke("tag",YP);/**
360 * @license lucide-react v1.41.0 - ISC
361 *
362 * This source code is licensed under the ISC license.
363 * See the LICENSE file in the root directory of this source tree.
364 */const QP=[["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"}]],Kg=Ke("trash",QP);/**
365 * @license lucide-react v1.41.0 - ISC
366 *
367 * This source code is licensed under the ISC license.
368 * See the LICENSE file in the root directory of this source tree.
369 */const WP=[["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"}]],nS=Ke("triangle-alert",WP);/**
370 * @license lucide-react v1.41.0 - ISC
371 *
372 * This source code is licensed under the ISC license.
373 * See the LICENSE file in the root directory of this source tree.
374 */const XP=[["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"}]],ig=Ke("upload",XP);/**
375 * @license lucide-react v1.41.0 - ISC
376 *
377 * This source code is licensed under the ISC license.
378 * See the LICENSE file in the root directory of this source tree.
379 */const ZP=[["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"}]],eM=Ke("user-check",ZP);/**
380 * @license lucide-react v1.41.0 - ISC
381 *
382 * This source code is licensed under the ISC license.
383 * See the LICENSE file in the root directory of this source tree.
384 */const tM=[["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:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],nM=Ke("user-x",tM);/**
385 * @license lucide-react v1.41.0 - ISC
386 *
387 * This source code is licensed under the ISC license.
388 * See the LICENSE file in the root directory of this source tree.
389 */const rM=[["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"}]],rS=Ke("user",rM);/**
390 * @license lucide-react v1.41.0 - ISC
391 *
392 * This source code is licensed under the ISC license.
393 * See the LICENSE file in the root directory of this source tree.
394 */const sM=[["path",{d:"M18 6 6 18",key:"1bl5f8"}
394],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],bc=Ke("x",sM),He=({children:n,variant:e="primary",className:t="",...r})=>{const s="font-bold py-2 px-6 rounded-full transition-transform transform hover:scale-105 disabled:opacity-50 disabled:cursor-not-allowed",a={primary:"bg-blue-600 text-white hover:bg-blue-700",secondary:"bg-gray-200 text-gray-800 hover:bg-gray-300 dark:bg-gray-700 dark:text-gray-200 dark:hover:bg-gray-600",danger:"bg-red-600 text-white hover:bg-red-700"};return o.jsx("button",{className:`${s} ${a[e]} ${t}`,...r,children:n})},At=()=>o.jsx("div",{className:"flex justify-center items-center",children:o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 dark:border-blue-400"})}),iM=()=>{};var xE={};/**
395 * @license
396 * Copyright 2017 Google LLC
397 *
398 * Licensed under the Apache License, Version 2.0 (the "License");
399 * you may not use this file except in compliance with the License.
400 * You may obtain a copy of the License at
401 *
402 *   http://www.apache.org/licenses/LICENSE-2.0
403 *
404 * Unless required by applicable law or agreed to in writing, software
405 * distributed under the License is distributed on an "AS IS" BASIS,
406 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
407 * See the License for the specific language governing permissions and
408 * limitations under the License.
409 */const sS=function(n){const e=[];let t=0;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&r+1<n.length&&(n.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++r)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},aM=function(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const a=n[t++];e[r++]=String.fromCharCode((s&31)<<6|a&63)}else if(s>239&&s<365){const a=n[t++],c=n[t++],u=n[t++],h=((s&7)<<18|(a&63)<<12|(c&63)<<6|u&63)-65536;e[r++]=String.fromCharCode(55296+(h>>10)),e[r++]=String.fromCharCode(56320+(h&1023))}else{const a=n[t++],c=n[t++];e[r++]=String.fromCharCode((s&15)<<12|(a&63)<<6|c&63)}}return e.join("")},iS={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(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let s=0;s<n.length;s+=3){const a=n[s],c=s+1<n.length,u=c?n[s+1]:0,h=s+2<n.length,f=h?n[s+2]:0,p=a>>2,y=(a&3)<<4|u>>4;let b=(u&15)<<2|f>>6,w=f&63;h||(w=64,c||(b=64)),r.push(t[p],t[y],t[b],t[w])}return r.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(sS(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):aM(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<n.length;){const a=t[n.charAt(s++)],u=s<n.length?t[n.charAt(s)]:0;++s;const f=s<n.length?t[n.charAt(s)]:64;++s;const y=s<n.length?t[n.charAt(s)]:64;if(++s,a==null||u==null||f==null||y==null)throw new oM;const b=a<<2|u>>4;if(r.push(b),f!==64){const w=u<<4&240|f>>2;if(r.push(w),y!==64){const E=f<<6&192|y;r.push(E)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};
409class oM extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const lM=function(n){const e=sS(n);return iS.encodeByteArray(e,!0)},ag=function(n){return lM(n).replace(/\./g,"")},aS=function(n){try{return iS.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/**
410 * @license
411 * Copyright 2022 Google LLC
412 *
413 * Licensed under the Apache License, Version 2.0 (the "License");
414 * you may not use this file except in compliance with the License.
415 * You may obtain a copy of the License at
416 *
417 *   http://www.apache.org/licenses/LICENSE-2.0
418 *
419 * Unless required by applicable law or agreed to in writing, software
420 * distributed under the License is distributed on an "AS IS" BASIS,
421 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
422 * See the License for the specific language governing permissions and
423 * limitations under the License.
424 */function cM(){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.")}/**
425 * @license
426 * Copyright 2022 Google LLC
427 *
428 * Licensed under the Apache License, Version 2.0 (the "License");
429 * you may not use this file except in compliance with the License.
430 * You may obtain a copy of the License at
431 *
432 *   http://www.apache.org/licenses/LICENSE-2.0
433 *
434 * Unless required by applicable law or agreed to in writing, software
435 * distributed under the License is distributed on an "AS IS" BASIS,
436 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
437 * See the License for the specific language governing permissions and
438 * limitations under the License.
439 */const uM=()=>cM().__FIREBASE_DEFAULTS__,dM=()=>{if(typeof process>"u"||typeof xE>"u")return;const n=xE.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},hM=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&aS(n[1]);return e&&JSON.parse(e)},Yg=()=>{try{return iM()||uM()||dM()||hM()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},oS=n=>{var e,t;return(t=(e=Yg())==null?void 0:e.emulatorHosts)==null?void 0:t[n]},lS=n=>{const e=oS(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const r=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),r]:[e.substring(0,t),r]},cS=()=>{var n;return(n=Yg())==null?void 0:n.config},uS=n=>{var e;return(e=Yg())==null?void 0:e[`_${n}`]};/**
440 * @license
441 * Copyright 2017 Google LLC
442 *
443 * Licensed under the Apache License, Version 2.0 (the "License");
444 * you may not use this file except in compliance with the License.
445 * You may obtain a copy of the License at
446 *
447 *   http://www.apache.org/licenses/LICENSE-2.0
448 *
449 * Unless required by applicable law or agreed to in writing, software
450 * distributed under the License is distributed on an "AS IS" BASIS,
451 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
452 * See the License for the specific language governing permissions and
453 * limitations under the License.
454 */class dS{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,r))}}}/**
455 * @license
456 * Copyright 2021 Google LLC
457 *
458 * Licensed under the Apache License, Version 2.0 (the "License");
459 * you may not use this file except in compliance with the License.
460 * You may obtain a copy of the License at
461 *
462 *   http://www.apache.org/licenses/LICENSE-2.0
463 *
464 * Unless required by applicable law or agreed to in writing, software
465 * distributed under the License is distributed on an "AS IS" BASIS,
466 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
467 * See the License for the specific language governing permissions and
468 * limitations under the License.
469 */function hS(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},r=e||"demo-project",s=n.iat||0,a=n.sub||n.user_id;if(!a)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const c={iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:a,user_id:a,firebase:{sign_in_provider:"custom",identities:{}},...n};return[ag(JSON.stringify(t)),ag(JSON.stringify(c)),""].join(".")}/**
470 * @license
471 * Copyright 2017 Google LLC
472 *
473 * Licensed under the Apache License, Version 2.0 (the "License");
474 * you may not use this file except in compliance with the License.
475 * You may obtain a copy of the License at
476 *
477 *   http://www.apache.org/licenses/LICENSE-2.0
478 *
479 * Unless required by applicable law or agreed to in writing, software
480 * distributed under the License is distributed on an "AS IS" BASIS,
481 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
482 * See the License for the specific language governing permissions and
483 * limitations under the License.
484 */function es(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function fM(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(es())}function mM(){var e;const n=(e=Yg())==null?void 0:e.forceEnvironment;if(n==="node")return!0;if(n==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function gM(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function pM(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function BM(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function yM(){const n=es();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function xM(){return!mM()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function CM(){try{return typeof indexedDB=="object"}catch{return!1}}function bM(){return new Promise((n,e)=>{try{let t=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(r),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{var a;e(((a=s.error)==null?void 0:a.message)||"")}}catch(t){e(t)}})}/**
485 * @license
486 * Copyright 2017 Google LLC
487 *
488 * Licensed under the Apache License, Version 2.0 (the "License");
489 * you may not use this file except in compliance with the License.
490 * You may obtain a copy of the License at
491 *
492 *   http://www.apache.org/licenses/LICENSE-2.0
493 *
494 * Unless required by applicable law or agreed to in writing, software
495 * distributed under the License is distributed on an "AS IS" BASIS,
496 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
497 * See the License for the specific language governing permissions and
498 * limitations under the License.
499 */const vM="FirebaseError";class aa extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name=vM,Object.setPrototypeOf(this,aa.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Oh.prototype.create)}}class Oh{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},s=`${this.service}/${e}`,a=this.errors[e],c=a?wM(a,r):"Error",u=`${this.serviceName}: ${c} (${s}).`;return new aa(s,u,r)}}function wM(n,e){try{let t=0,r="";for(;t<n.length;){const s=n.indexOf("{$",t);if(s===-1){r+=n.substring(t);break}const a=n.indexOf("}",s+2);if(a===-1){r+=n.substring(t);break}const c=n.substring(s+2,a),u=e[c];r+=n.substring(t,s)+(u!=null?String(u):`<${c}?>`),t=a+1}return r}catch{return n}}function EM(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function hc(n,e){if(n===e)return!0;const t=Object.keys(n),r=Object.keys(e);for(const s of t){if(!r.includes(s))return!1;const a=n[s],c=e[s];if(CE(a)&&CE(c)){if(!hc(a,c))return!1}else if(a!==c)return!1}for(const s of r)if(!t.includes(s))return!1;return!0}function CE(n){return n!==null&&typeof n=="object"}/**
500 * @license
501 * Copyright 2017 Google LLC
502 *
503 * Licensed under the Apache License, Version 2.0 (the "License");
504 * you may not use this file except in compliance with the License.
505 * You may obtain a copy of the License at
506 *
507 *   http://www.apache.org/licenses/LICENSE-2.0
508 *
509 * Unless required by applicable law or agreed to in writing, software
510 * distributed under the License is distributed on an "AS IS" BASIS,
511 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
512 * See the License for the specific language governing permissions and
513 * limitations under the License.
514 */function Fh(n){const e=[];for(const[t,r]of Object.entries(n))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function Kd(n){const e={};return n.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[s,a]=r.split("=");e[decodeURIComponent(s)]=decodeURIComponent(a)}}),e}function Yd(n){const e=n.indexOf("?");if(!e)return"";const t=n.indexOf("#",e);return n.substring(e,t>0?t:void 0)}function _M(n,e){const t=new TM(n,e);return t.subscribe.bind(t)}class TM{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Prom
vendor: 4,142 bytes, lines 514-563
514ise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let s;if(e===void 0&&t===void 0&&r===void 0)throw new Error("Missing Observer.");kM(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:r},s.next===void 0&&(s.next=MB),s.error===void 0&&(s.error=MB),s.complete===void 0&&(s.complete=MB);const a=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),a}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function kM(n,e){if(typeof n!="object"||n===null)return!1;for(const t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function MB(){}/**
515 * @license
516 * Copyright 2021 Google LLC
517 *
518 * Licensed under the Apache License, Version 2.0 (the "License");
519 * you may not use this file except in compliance with the License.
520 * You may obtain a copy of the License at
521 *
522 *   http://www.apache.org/licenses/LICENSE-2.0
523 *
524 * Unless required by applicable law or agreed to in writing, software
525 * distributed under the License is distributed on an "AS IS" BASIS,
526 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
527 * See the License for the specific language governing permissions and
528 * limitations under the License.
529 */function En(n){return n&&n._delegate?n._delegate:n}/**
530 * @license
531 * Copyright 2025 Google LLC
532 *
533 * Licensed under the Apache License, Version 2.0 (the "License");
534 * you may not use this file except in compliance with the License.
535 * You may obtain a copy of the License at
536 *
537 *   http://www.apache.org/licenses/LICENSE-2.0
538 *
539 * Unless required by applicable law or agreed to in writing, software
540 * distributed under the License is distributed on an "AS IS" BASIS,
541 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
542 * See the License for the specific language governing permissions and
543 * limitations under the License.
544 */function vc(n){try{return(n.startsWith("http://")||n.startsWith("https://")?new URL(n).hostname:n).endsWith(".cloudworkstations.dev")}catch{return!1}}async function lx(n){return(await fetch(n,{credentials:"include"})).ok}class Zo{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}/**
545 * @license
546 * Copyright 2019 Google LLC
547 *
548 * Licensed under the Apache License, Version 2.0 (the "License");
549 * you may not use this file except in compliance with the License.
550 * You may obtain a copy of the License at
551 *
552 *   http://www.apache.org/licenses/LICENSE-2.0
553 *
554 * Unless required by applicable law or agreed to in writing, software
555 * distributed under the License is distributed on an "AS IS" BASIS,
556 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
557 * See the License for the specific language governing permissions and
558 * limitations under the License.
559 */const Ql="[DEFAULT]";/**
560 * @license
561 * Copyright 2019 Google LLC
562 *
563 * Licensed under the Apache License, Version 2.0 (the "License");
564 * you may not use this file except in compliance with the License.
565 * You may obtain a copy of the License at
566 *
567 *   http://www.apache.org/licenses/LICENSE-2.0
568 *
569 * Unless required by applicable law or agreed to in writing, software
570 * distributed under the License is distributed on an "AS IS" BASIS,
571 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
572 * See the License for the specific language governing permissions and
573 * limitations under the License.
574 */class NM{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const r=new dS;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),r=(e==null?void 0:e.optional)??!1;if(this.isInitialized(t)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:t})}catch(s){if(r)return null;throw s}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(DM(e))try{this.getOrInitializeService({instanceIdentifier:Ql})}catch{}for(const[t,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(t);try{const a=this.getOrInitializeService({instanceIdentifier:s});r.resolve(a)}catch{}}}}clearInstance(e=Ql){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=Ql){return this.instances.has(e)}getOptions(e=Ql){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,r=this.normalizeInstanceIdentifier(e.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 s=this.getOrInitializeService({instanceIdentifier:r,options:t});for(const[a,c]of this.instancesDeferred.entries()){const u=this.normalizeInstanceIdentifier(a);r===u&&c.resolve(s)}return s}onInit(e,t){const r=this.normalizeInstanceIdentifier(t),s=this.onInitCallbacks.get(r)??new Set;s.add(e),this.onInitCallbacks.set(r,s);const a=this.instances.get(r);return a&&e(a,r),()=>{s.delete(e)}}invokeOnInitCallbacks(e,t){const r=this.onInitCallbacks.get(t);if(r)for(const s of r)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:SM(e),options:t}),this.instances.set(e,r),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=Ql){return this.component?this.component.multipleInstances?e:Ql:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function SM(n){return n===Ql?void 0:n}function DM(n){return n.instantiationMode==="EAGER"}/**
575 * @license
576 * Copyright 2019 Google LLC
577 *
578 * Licensed under the Apache License, Version 2.0 (the "License");
579 * you may not use this file except in compliance with the License.
580 * You may obtain a copy of the License at
581 *
582 *   http://www.apache.org/licenses/LICENSE-2.0
583 *
584 * Unless required by applicable law or agreed to in writing, softw
584are
585 * distributed under the License is distributed on an "AS IS" BASIS,
586 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
587 * See the License for the specific language governing permissions and
588 * limitations under the License.
589 */class AM{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new NM(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}/**
590 * @license
591 * Copyright 2017 Google LLC
592 *
593 * Licensed under the Apache License, Version 2.0 (the "License");
594 * you may not use this file except in compliance with the License.
595 * You may obtain a copy of the License at
596 *
597 *   http://www.apache.org/licenses/LICENSE-2.0
598 *
599 * Unless required by applicable law or agreed to in writing, software
600 * distributed under the License is distributed on an "AS IS" BASIS,
601 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
602 * See the License for the specific language governing permissions and
603 * limitations under the License.
604 */var Ut;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(Ut||(Ut={}));const IM={debug:Ut.DEBUG,verbose:Ut.VERBOSE,info:Ut.INFO,warn:Ut.WARN,error:Ut.ERROR,silent:Ut.SILENT},RM=Ut.INFO,PM={[Ut.DEBUG]:"log",[Ut.VERBOSE]:"log",[Ut.INFO]:"info",[Ut.WARN]:"warn",[Ut.ERROR]:"error"},MM=(n,e,...t)=>{if(e<n.logLevel)return;const r=new Date().toISOString(),s=PM[e];if(s)console[s](`[${r}]  ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class cx{constructor(e){this.name=e,this._logLevel=RM,this._logHandler=MM,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in Ut))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?IM[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,Ut.DEBUG,...e),this._logHandler(this,Ut.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,Ut.VERBOSE,...e),this._logHandler(this,Ut.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,Ut.INFO,...e),this._logHandler(this,Ut.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,Ut.WARN,...e),this._logHandler(this,Ut.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,Ut.ERROR,...e),this._logHandler(this,Ut.ERROR,...e)}}const LM=(n,e)=>e.some(t=>n instanceof t);let bE,vE;function jM(){return bE||(bE=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function OM(){return vE||(vE=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const fS=new WeakMap,py=new WeakMap,mS=new WeakMap,LB=new WeakMap,ux=new WeakMap;function FM(n){const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("success",a),n.removeEventListener("error",c)},a=()=>{t($o(n.result)),s()},c=()=>{r(n.error),s()};n.addEventListener("success",a),n.addEventListener("error",c)});return e.then(t=>{t instanceof IDBCursor&&fS.set(t,n)}).catch(()=>{}),ux.set(e,n),e}function UM(n){if(py.has(n))return;const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("complete",a),n.removeEventListener("error",c),n.removeEventListener("abort",c)},a=()=>{t(),s()},c=()=>{r(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",a),n.addEventListener("error",c),n.addEventListener("abort",c)});py.set(n,e)}let By={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return py.get(n);if(e==="objectStoreNames")return n.objectStoreNames||mS.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return $o(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};
vendor: 4,117 bytes, lines 604-638
604function VM(n){By=n(By)}function GM(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const r=n.call(jB(this),e,...t);return mS.set(r,e.sort?e.sort():[e]),$o(r)}:OM().includes(n)?function(...e){return n.apply(jB(this),e),$o(fS.get(this))}:function(...e){return $o(n.apply(jB(this),e))}}function HM(n){return typeof n=="function"?GM(n):(n instanceof IDBTransaction&&UM(n),LM(n,jM())?new Proxy(n,By):n)}function $o(n){if(n instanceof IDBRequest)return FM(n);if(LB.has(n))return LB.get(n);const e=HM(n);return e!==n&&(LB.set(n,e),ux.set(e,n)),e}const jB=n=>ux.get(n);function qM(n,e,{blocked:t,upgrade:r,blocking:s,terminated:a}={}){const c=indexedDB.open(n,e),u=$o(c);return r&&c.addEventListener("upgradeneeded",h=>{r($o(c.result),h.oldVersion,h.newVersion,$o(c.transaction),h)}),t&&c.addEventListener("blocked",h=>t(h.oldVersion,h.newVersion,h)),u.then(h=>{a&&h.addEventListener("close",()=>a()),s&&h.addEventListener("versionchange",f=>s(f.oldVersion,f.newVersion,f))}).catch(()=>{}),u}const zM=["get","getKey","getAll","getAllKeys","count"],JM=["put","add","delete","clear"],OB=new Map;function wE(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(OB.get(e))return OB.get(e);const t=e.replace(/FromIndex$/,""),r=e!==t,s=JM.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(s||zM.includes(t)))return;const a=async function(c,...u){const h=this.transaction(c,s?"readwrite":"readonly");let f=h.store;return r&&(f=f.index(u.shift())),(await Promise.all([f[t](...u),s&&h.done]))[0]};return OB.set(e,a),a}VM(n=>({...n,get:(e,t,r)=>wE(e,t)||n.get(e,t,r),has:(e,t)=>!!wE(e,t)||n.has(e,t)}));/**
605 * @license
606 * Copyright 2019 Google LLC
607 *
608 * Licensed under the Apache License, Version 2.0 (the "License");
609 * you may not use this file except in compliance with the License.
610 * You may obtain a copy of the License at
611 *
612 *   http://www.apache.org/licenses/LICENSE-2.0
613 *
614 * Unless required by applicable law or agreed to in writing, software
615 * distributed under the License is distributed on an "AS IS" BASIS,
616 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
617 * See the License for the specific language governing permissions and
618 * limitations under the License.
619 */class $M{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(KM(t)){const r=t.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(t=>t).join(" ")}}function KM(n){const e=n.getComponent();return(e==null?void 0:e.type)==="VERSION"}const yy="@firebase/app",EE="0.16.1";/**
620 * @license
621 * Copyright 2019 Google LLC
622 *
623 * Licensed under the Apache License, Version 2.0 (the "License");
624 * you may not use this file except in compliance with the License.
625 * You may obtain a copy of the License at
626 *
627 *   http://www.apache.org/licenses/LICENSE-2.0
628 *
629 * Unless required by applicable law or agreed to in writing, software
630 * distributed under the License is distributed on an "AS IS" BASIS,
631 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
632 * See the License for the specific language governing permissions and
633 * limitations under the License.
634 */const Ha=new cx("@firebase/app"),YM="@firebase/app-compat",QM="@firebase/analytics-compat",WM="@firebase/analytics",XM="@firebase/app-check-compat",ZM="@firebase/app-check",eL="@firebase/auth",tL="@firebase/auth-compat",nL="@firebase/database",rL="@firebase/data-connect",sL="@firebase/database-compat",iL="@firebase/functions",aL="@firebase/functions-compat",oL="@firebase/installations",lL="@firebase/installations-compat",cL="@firebase/messaging",uL="@firebase/messaging-compat",dL="@firebase/performance",hL="@firebase/performance-compat",fL="@firebase/remote-config",mL="@firebase/remote-config-compat",gL="@firebase/storage",pL="@firebase/storage-compat",BL="@firebase/firestore",yL="@firebase/ai",xL="@firebase/firestore-compat",CL="firebase",bL="12.18.0";/**
635 * @license
636 * Copyright 2019 Google LLC
637 *
638 * Licensed under the Apache License, Version 2.0 (the "License");
639 * you may not use this file except in compliance with the License.
640 * You may obtain a copy of the License at
641 *
642 *   http://www.apache.org/licenses/LICENSE-2.0
643 *
644 * Unless required by applicable law or agreed to in writing, software
645 * distributed under the License is distributed on an "AS IS" BASIS,
646 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
647 * See the License for the specific language governing permissions and
648 * limitations under the License.
649 */const xy="[DEFAULT]",vL={[yy]:"fire-core",[YM]:"fire-core-compat",[WM]:"fire-analytics",[QM]:"fire-analytics-compat",[ZM]:"fire-app-check",[XM]:"fire-app-check-compat",[eL]:"fire-auth",[tL]:"fire-auth-compat",[nL]:"fire-rtdb",[rL]:"fire-data-connect",[sL]:"fire-rtdb-compat",[iL]:"fire-fn",[aL]:"fire-fn-compat",[oL]:"fire-iid",[lL]:"fire-iid-compat",[cL]:"fire-fcm",[uL]:"fire-fcm-compat",[dL]:"fire-perf",[hL]:"fire-perf-compat",[fL]:"fire-rc",[mL]:"fire-rc-compat",[gL]:"fire-gcs",[pL]:"fire-gcs-compat",[BL]:"fire-fst",[xL]:"fire-fst-compat",[yL]:"fire-vertex","fire-js":"fire-js",[CL]:"fire-js-all"};/**
650 * @license
651 * Copyright 2019 Google LLC
652 *
653 * Licensed under the Apache License, Version 2.0 (the "License");
654 * you may not use this file except in compliance with the License.
655 * You may obtain a copy of the License at
656 *
657 *   http://www.apache.org/licenses/LICENSE-2.0
658 *
659 * Unless required by applicable law or agreed to in writing, software
660 * distributed under the License is distributed on an "AS IS" BASIS,
661 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
662 * See the License for the specific language governing permissions and
663 * limitations under the License.
664 */const fc=new Map,Cy=new Map,by=new Map;function _E(n,e){try{n.container.addComponent(e)}catch(t){Ha.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function mc(n){const e=n.name;if(by.has(e))return Ha.debug(`There were multiple attempts to register component ${e}.`),!1;by.set(e,n);for(const t of fc.values())_E(t,n);for(const t of Cy.values())_E(t,n);return!0}function Qg(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function Ts(n){return n==null?!1:n.settings!==void 0}/**
665 * @license
666 * Copyright 2019 Google LLC
667 *
668 * Licensed under the Apache License, Version 2.0 (the "License");
669 * you may not use this file except in compliance with the License.
670 * You may obtain a copy of the License at
671 *
672 *   http://www.apache.org/licenses/LICENSE-2.0
673 *
674 * Unless required by applicable law or agreed to in writing, software
675 * distributed under the License is distributed on an "AS IS" BASIS,
676 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
677 * See the License for the specific language governing permissions and
678 * limitations under the License.
679 */const wL={"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 {$mismatchedParam}. Existing: '{$oldValue}'. New: '{$newValue}'.","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.","invali
679d-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."},Pa=new Oh("app","Firebase",wL);/**
680 * @license
681 * Copyright 2019 Google LLC
682 *
683 * Licensed under the Apache License, Version 2.0 (the "License");
684 * you may not use this file except in compliance with the License.
685 * You may obtain a copy of the License at
686 *
687 *   http://www.apache.org/licenses/LICENSE-2.0
688 *
689 * Unless required by applicable law or agreed to in writing, software
690 * distributed under the License is distributed on an "AS IS" BASIS,
691 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
692 * See the License for the specific language governing permissions and
693 * limitations under the License.
694 */class EL{constructor(e,t,r){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new Zo("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}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(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw Pa.create("app-deleted",{appName:this._name})}}/**
695 * @license
696 * Copyright 2019 Google LLC
697 *
698 * Licensed under the Apache License, Version 2.0 (the "License");
699 * you may not use this file except in compliance with the License.
700 * You may obtain a copy of the License at
701 *
702 *   http://www.apache.org/licenses/LICENSE-2.0
703 *
704 * Unless required by applicable law or agreed to in writing, software
705 * distributed under the License is distributed on an "AS IS" BASIS,
706 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
707 * See the License for the specific language governing permissions and
708 * limitations under the License.
709 */const wc=bL;function dx(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const r={name:xy,automaticDataCollectionEnabled:!0,...e},s=r.name;if(typeof s!="string"||!s)throw Pa.create("bad-app-name",{appName:String(s)});if(t||(t=cS()),!t)throw Pa.create("no-options");const a=fc.get(s);if(a)if(hc(t,a.options)){if(hc(r,a.config))return a;throw Pa.create("duplicate-app",{appName:s,mismatchedParam:"config",oldValue:JSON.stringify(a.config),newValue:JSON.stringify(r)})}else throw Pa.create("duplicate-app",{appName:s,mismatchedParam:"options",oldValue:JSON.stringify(a.options),newValue:JSON.stringify(t)});const c=new AM(s);for(const h of by.values())c.addComponent(h);const u=new EL(t,r,c);return fc.set(s,u),u}function Wg(n=xy){const e=fc.get(n);if(!e&&n===xy&&cS())return dx();if(!e)throw Pa.create("no-app",{appName:n});return e}function _L(){return Array.from(fc.values())}async function TE(n){let e=!1;const t=n.name;fc.has(t)?(e=!0,fc.delete(t)):Cy.has(t)&&n.decRefCount()<=0&&(Cy.delete(t),e=!0),e&&(await Promise.all(n.container.getProviders().map(r=>r.delete())),n.isDeleted=!0)}function Zi(n,e,t){let r=vL[n]??n;t&&(r+=`-${t}`);const s=r.match(/\s|\//),a=e.match(/\s|\//);if(s||a){const c=[`Unable to register library "${r}" with version "${e}":`];s&&c.push(`library name "${r}" contains illegal characters (whitespace or "/")`),s&&a&&c.push("and"),a&&c.push(`version name "${e}" contains illegal characters (whitespace or "/")`),Ha.warn(c.join(" "));return}mc(new Zo(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}/**
710 * @license
711 * Copyright 2021 Google LLC
712 *
713 * Licensed under the Apache License, Version 2.0 (the "License");
714 * you may not use this file except in compliance with the License.
715 * You may obtain a copy of the License at
716 *
717 *   http://www.apache.org/licenses/LICENSE-2.0
718 *
719 * Unless required by applicable law or agreed to in writing, software
720 * distributed under the License is distributed on an "AS IS" BASIS,
721 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
722 * See the License for the specific language governing permissions and
723 * limitations under the License.
724 */const TL="firebase-heartbeat-database",kL=1,Ch="firebase-heartbeat-store";let FB=null;function gS(){return FB||(FB=qM(TL,kL,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(Ch)}catch(t){console.warn(t)}}}}).catch(n=>{throw Pa.create("idb-open",{originalErrorMessage:n.message})})),FB}async function NL(n){try{const t=(await gS()).transaction(Ch),r=await t.objectStore(Ch).get(pS(n));return await t.done,r}catch(e){if(e instanceof aa)Ha.warn(e.message);else{const t=Pa.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});Ha.warn(t.message)}}}async function kE(n,e){try{const r=(await gS()).transaction(Ch,"readwrite");await r.objectStore(Ch).put(e,pS(n)),await r.done}catch(t){if(t instanceof aa)Ha.warn(t.message);else{const r=Pa.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});Ha.warn(r.message)}}}function pS(n){return`${n.name}!${n.options.appId}`}/**
725 * @license
726 * Copyright 2021 Google LLC
727 *
728 * Licensed under the Apache License, Version 2.0 (the "License");
729 * you may not use this file except in compliance with the License.
730 * You may obtain a copy of the License at
731 *
732 *   http://www.apache.org/licenses/LICENSE-2.0
733 *
734 * Unless required by applicable law or agreed to in writing, software
735 * distributed under the License is distributed on an "AS IS" BASIS,
736 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
737 * See the License for the specific language governing permissions and
738 * limitations under the License.
739 */const SL=1024,DL=30;class AL{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new RL(t),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){var e,t;try{const s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),a=NE();if(((e=this._heartbeatsCache)==null?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)==null?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===a||this._heartbeatsCache.heartbeats.some(c=>c.date===a))return;if(this._heartbeatsCache.heartbeats.push({date:a,agent:s}),this._heartbeatsCache.heartbeats.length>DL){const c=PL(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(c,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(r){Ha.warn(r)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)==null?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const t=NE(),{heartbeatsToSend:r,unsentEntries:s}=IL(this._heartbeatsCache.heartbeats),a=ag(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=t,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),a}catch(t){return Ha.warn(t),""}}}function NE(){return new Date().toISOString().substring(0,10)}function IL(n,e=SL){const t=[];let r=n.slice();for(const s of n){const a=t.find(c=>c.agent===s.agent);if(a){if(a.dates.push(s.date),SE(t)>e){a.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),SE(t)>e){t.pop();break}r=r.slice(1)}return{heartbeatsToSend:t,unsentEntries:r}}class RL{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return CM()?bM().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await NL(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return kE(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return kE(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function SE(n){return ag(JSON.stringify({version:2,heartbeats:n})).length}
739function PL(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let r=1;r<n.length;r++)n[r].date<t&&(t=n[r].date,e=r);return e}/**
740 * @license
741 * Copyright 2019 Google LLC
742 *
743 * Licensed under the Apache License, Version 2.0 (the "License");
744 * you may not use this file except in compliance with the License.
745 * You may obtain a copy of the License at
746 *
747 *   http://www.apache.org/licenses/LICENSE-2.0
748 *
749 * Unless required by applicable law or agreed to in writing, software
750 * distributed under the License is distributed on an "AS IS" BASIS,
751 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
752 * See the License for the specific language governing permissions and
753 * limitations under the License.
754 */function ML(n){mc(new Zo("platform-logger",e=>new $M(e),"PRIVATE")),mc(new Zo("heartbeat",e=>new AL(e),"PRIVATE")),Zi(yy,EE,n),Zi(yy,EE,"esm2020"),Zi("fire-js","")}/**
755 * @license
756 * Copyright 2019 Google LLC
757 *
758 * Licensed under the Apache License, Version 2.0 (the "License");
759 * you may not use this file except in compliance with the License.
760 * You may obtain a copy of the License at
761 *
762 *   http://www.apache.org/licenses/LICENSE-2.0
763 *
764 * Unless required by applicable law or agreed to in writing, software
765 * distributed under the License is distributed on an "AS IS" BASIS,
766 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
767 * See the License for the specific language governing permissions and
768 * limitations under the License.
769 */ML("");function BS(){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 LL=BS,yS=new Oh("auth","Firebase",BS());/**
770 * @license
771 * Copyright 2020 Google LLC
772 *
773 * Licensed under the Apache License, Version 2.0 (the "License");
774 * you may not use this file except in compliance with the License.
775 * You may obtain a copy of the License at
776 *
777 *   http://www.apache.org/licenses/LICENSE-2.0
778 *
779 * Unless required by applicable law or agreed to in writing, software
780 * distributed under the License is distributed on an "AS IS" BASIS,
781 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
782 * See the License for the specific language governing permissions and
783 * limitations under the License.
784 */const og=new cx("@firebase/auth");function xS(n,...e){og.logLevel<=Ut.WARN&&og.warn(`Auth (${wc}): ${n}`,...e)}function Hm(n,...e){og.logLevel<=Ut.ERROR&&og.error(`Auth (${wc}): ${n}`,...e)}/**
785 * @license
786 * Copyright 2020 Google LLC
787 *
788 * Licensed under the Apache License, Version 2.0 (the "License");
789 * you may not use this file except in compliance with the License.
790 * You may obtain a copy of the License at
791 *
792 *   http://www.apache.org/licenses/LICENSE-2.0
793 *
794 * Unless required by applicable law or agreed to in writing, software
795 * distributed under the License is distributed on an "AS IS" BASIS,
796 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
797 * See the License for the specific language governing permissions and
798 * limitations under the License.
799 */function gi(n,...e){throw fx(n,...e)}function Di(n,...e){return fx(n,...e)}function hx(n,e,t){const r={...LL(),[e]:t};return new Oh("auth","Firebase",r).create(e,{appName:n.name})}function Fa(n){return hx(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function jL(n,e,t){const r=t;if(!(e instanceof r))throw r.name!==e.constructor.name&&gi(n,"argument-error"),hx(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function fx(n,...e){if(typeof n!="string"){const t=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=n.name),n._errorFactory.create(t,...r)}return yS.create(n,...e)}function mt(n,e,...t){if(!n)throw fx(e,...t)}function Ma(n){const e="INTERNAL ASSERTION FAILED: "+n;throw Hm(e),new Error(e)}function qa(n,e){n||Ma(e)}/**
800 * @license
801 * Copyright 2020 Google LLC
802 *
803 * Licensed under the Apache License, Version 2.0 (the "License");
804 * you may not use this file except in compliance with the License.
805 * You may obtain a copy of the License at
806 *
807 *   http://www.apache.org/licenses/LICENSE-2.0
808 *
809 * Unless required by applicable law or agreed to in writing, software
810 * distributed under the License is distributed on an "AS IS" BASIS,
811 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
812 * See the License for the specific language governing permissions and
813 * limitations under the License.
814 */function vy(){var n;return typeof self<"u"&&((n=self.location)==null?void 0:n.href)||""}function OL(){return DE()==="http:"||DE()==="https:"}function DE(){var n;return typeof self<"u"&&((n=self.location)==null?void 0:n.protocol)||null}/**
815 * @license
816 * Copyright 2020 Google LLC
817 *
818 * Licensed under the Apache License, Version 2.0 (the "License");
819 * you may not use this file except in compliance with the License.
820 * You may obtain a copy of the License at
821 *
822 *   http://www.apache.org/licenses/LICENSE-2.0
823 *
824 * Unless required by applicable law or agreed to in writing, software
825 * distributed under the License is distributed on an "AS IS" BASIS,
826 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
827 * See the License for the specific language governing permissions and
828 * limitations under the License.
829 */function FL(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(OL()||pM()||"connection"in navigator)?navigator.onLine:!0}function UL(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}/**
830 * @license
831 * Copyright 2020 Google LLC
832 *
833 * Licensed under the Apache License, Version 2.0 (the "License");
834 * you may not use this file except in compliance with the License.
835 * You may obtain a copy of the License at
836 *
837 *   http://www.apache.org/licenses/LICENSE-2.0
838 *
839 * Unless required by applicable law or agreed to in writing, software
840 * distributed under the License is distributed on an "AS IS" BASIS,
841 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
842 * See the License for the specific language governing permissions and
843 * limitations under the License.
844 */class Uh{constructor(e,t){this.shortDelay=e,this.longDelay=t,qa(t>e,"Short delay should be less than long delay!"),this.isMobile=fM()||BM()}get(){return FL()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/**
845 * @license
846 * Copyright 2020 Google LLC
847 *
848 * Licensed under the Apache License, Version 2.0 (the "License");
849 * you may not use this file except in compliance with the License.
850 * You may obtain a copy of the License at
851 *
852 *   http://www.apache.org/licenses/LICENSE-2.0
853 *
854 * Unless required by applicable law or agreed to in writing, software
855 * distributed under the License is distributed on an "AS IS" BASIS,
856 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
857 * See the License for the specific language governing permissions and
858 * limitations under the License.
859 */function mx(n,e){qa(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}/**
860 * @license
861 * Copyright 2020 Google LLC
862 *
863 * Licensed under the Apache License, Version 2.0 (the "License");
864 * you may not use this file except in compliance with the License.
865 * You may obtain a copy of the License at
866 *
867 *   http://www.apache.org/licenses/LICENSE-2.0
868 *
869 * Unless required by applicable law or agreed to in writing, software
870 * distributed under the License is distributed on an "AS IS" BASIS,
871 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
872 * See the License for the specific language governing permissions and
873 * limitations under the License.
874 */class CS{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),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;Ma("Could not find fetch implementation, make sure you call FetchProvi
874der.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;Ma("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;Ma("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/**
875 * @license
876 * Copyright 2020 Google LLC
877 *
878 * Licensed under the Apache License, Version 2.0 (the "License");
879 * you may not use this file except in compliance with the License.
880 * You may obtain a copy of the License at
881 *
882 *   http://www.apache.org/licenses/LICENSE-2.0
883 *
884 * Unless required by applicable law or agreed to in writing, software
885 * distributed under the License is distributed on an "AS IS" BASIS,
886 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
887 * See the License for the specific language governing permissions and
888 * limitations under the License.
889 */const VL={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"};/**
890 * @license
891 * Copyright 2020 Google LLC
892 *
893 * Licensed under the Apache License, Version 2.0 (the "License");
894 * you may not use this file except in compliance with the License.
895 * You may obtain a copy of the License at
896 *
897 *   http://www.apache.org/licenses/LICENSE-2.0
898 *
899 * Unless required by applicable law or agreed to in writing, software
900 * distributed under the License is distributed on an "AS IS" BASIS,
901 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
902 * See the License for the specific language governing permissions and
903 * limitations under the License.
904 */const GL=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],HL=new Uh(3e4,6e4);function Ka(n,e){return n.tenantId&&!e.tenantId?{...e,tenantId:n.tenantId}:e}async function oa(n,e,t,r,s={}){return bS(n,s,async()=>{let a={},c={};r&&(e==="GET"?c=r:a={body:JSON.stringify(r)});const u=Fh({...c,key:n.config.apiKey}).slice(1),h=await n._getAdditionalHeaders();h["Content-Type"]="application/json",n.languageCode&&(h["X-Firebase-Locale"]=n.languageCode);const f={method:e,headers:h,...a};
904return gM()||(f.referrerPolicy="strict-origin-when-cross-origin"),n.emulatorConfig&&vc(n.emulatorConfig.host)&&(f.credentials="include"),CS.fetch()(await vS(n,n.config.apiHost,t,u),f)})}async function bS(n,e,t){n._canInitEmulator=!1;const r={...VL,...e};try{const s=new zL(n),a=await Promise.race([t(),s.promise]);s.clearNetworkTimeout();const c=await a.json();if("needConfirmation"in c)throw ym(n,"account-exists-with-different-credential",c);if(a.ok&&!("errorMessage"in c))return c;{const u=a.ok?c.errorMessage:c.error.message,[h,f]=u.split(" : ");if(h==="FEDERATED_USER_ID_ALREADY_LINKED")throw ym(n,"credential-already-in-use",c);if(h==="EMAIL_EXISTS")throw ym(n,"email-already-in-use",c);if(h==="USER_DISABLED")throw ym(n,"user-disabled",c);const p=r[h]||h.toLowerCase().replace(/[_\s]+/g,"-");if(f)throw hx(n,p,f);gi(n,p)}}catch(s){if(s instanceof aa)throw s;gi(n,"network-request-failed",{message:String(s)})}}async function Vh(n,e,t,r,s={}){const a=await oa(n,e,t,r,s);return"mfaPendingCredential"in a&&gi(n,"multi-factor-auth-required",{_serverResponse:a}),a}async function vS(n,e,t,r){const s=`${e}${t}?${r}`,a=n,c=a.config.emulator?mx(n.config,s):`${n.config.apiScheme}://${s}`;return GL.includes(t)&&(await a._persistenceManagerAvailable,a._getPersistenceType()==="COOKIE")?a._getPersistence()._getFinalTarget(c).toString():c}function qL(n){switch(n){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class zL{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,r)=>{this.timer=setTimeout(()=>r(Di(this.auth,"network-request-failed")),HL.get())})}}function ym(n,e,t){const r={appName:n.name};t.email&&(r.email=t.email),t.phoneNumber&&(r.phoneNumber=t.phoneNumber);const s=Di(n,e,r);return s.customData._tokenResponse=t,s}function AE(n){return n!==void 0&&n.enterprise!==void 0}class JL{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return qL(t.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function $L(n,e){return oa(n,"GET","/v2/recaptchaConfig",Ka(n,e))}/**
905 * @license
906 * Copyright 2020 Google LLC
907 *
908 * Licensed under the Apache License, Version 2.0 (the "License");
909 * you may not use this file except in compliance with the License.
910 * You may obtain a copy of the License at
911 *
912 *   http://www.apache.org/licenses/LICENSE-2.0
913 *
914 * Unless required by applicable law or agreed to in writing, software
915 * distributed under the License is distributed on an "AS IS" BASIS,
916 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
917 * See the License for the specific language governing permissions and
918 * limitations under the License.
919 */async function KL(n,e){return oa(n,"POST","/v1/accounts:delete",e)}async function lg(n,e){return oa(n,"POST","/v1/accounts:lookup",e)}/**
920 * @license
921 * Copyright 2020 Google LLC
922 *
923 * Licensed under the Apache License, Version 2.0 (the "License");
924 * you may not use this file except in compliance with the License.
925 * You may obtain a copy of the License at
926 *
927 *   http://www.apache.org/licenses/LICENSE-2.0
928 *
929 * Unless required by applicable law or agreed to in writing, software
930 * distributed under the License is distributed on an "AS IS" BASIS,
931 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
932 * See the License for the specific language governing permissions and
933 * limitations under the License.
934 */function sh(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function YL(n,e=!1){const t=En(n),r=await t.getIdToken(e),s=gx(r);mt(s&&s.exp&&s.auth_time&&s.iat,t.auth,"internal-error");const a=typeof s.firebase=="object"?s.firebase:void 0,c=a==null?void 0:a.sign_in_provider;return{claims:s,token:r,authTime:sh(UB(s.auth_time)),issuedAtTime:sh(UB(s.iat)),expirationTime:sh(UB(s.exp)),signInProvider:c||null,signInSecondFactor:(a==null?void 0:a.sign_in_second_factor)||null}}function UB(n){return Number(n)*1e3}function gx(n){const[e,t,r]=n.split(".");if(e===void 0||t===void 0||r===void 0)return Hm("JWT malformed, contained fewer than 3 sections"),null;try{const s=aS(t);return s?JSON.parse(s):(Hm("Failed to decode base64 JWT payload"),null)}catch(s){return Hm("Caught error parsing JWT payload as JSON",s==null?void 0:s.toString()),null}}function IE(n){const e=gx(n);return mt(e,"internal-error"),mt(typeof e.exp<"u","internal-error"),mt(typeof e.iat
934<"u","internal-error"),Number(e.exp)-Number(e.iat)}/**
935 * @license
936 * Copyright 2020 Google LLC
937 *
938 * Licensed under the Apache License, Version 2.0 (the "License");
939 * you may not use this file except in compliance with the License.
940 * You may obtain a copy of the License at
941 *
942 *   http://www.apache.org/licenses/LICENSE-2.0
943 *
944 * Unless required by applicable law or agreed to in writing, software
945 * distributed under the License is distributed on an "AS IS" BASIS,
946 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
947 * See the License for the specific language governing permissions and
948 * limitations under the License.
949 */async function Du(n,e,t=!1){if(t)return e;try{return await e}catch(r){throw r instanceof aa&&QL(r)&&n.auth.currentUser===n&&await n.auth.signOut(),r}}function QL({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}/**
950 * @license
951 * Copyright 2020 Google LLC
952 *
953 * Licensed under the Apache License, Version 2.0 (the "License");
954 * you may not use this file except in compliance with the License.
955 * You may obtain a copy of the License at
956 *
957 *   http://www.apache.org/licenses/LICENSE-2.0
958 *
959 * Unless required by applicable law or agreed to in writing, software
960 * distributed under the License is distributed on an "AS IS" BASIS,
961 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
962 * See the License for the specific language governing permissions and
963 * limitations under the License.
964 */class WL{constructor(e){this.user=e,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(e){if(e){const t=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),t}else{this.errorBackoff=3e4;const r=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,r)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(e==null?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/**
965 * @license
966 * Copyright 2020 Google LLC
967 *
968 * Licensed under the Apache License, Version 2.0 (the "License");
969 * you may not use this file except in compliance with the License.
970 * You may obtain a copy of the License at
971 *
972 *   http://www.apache.org/licenses/LICENSE-2.0
973 *
974 * Unless required by applicable law or agreed to in writing, software
975 * distributed under the License is distributed on an "AS IS" BASIS,
976 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
977 * See the License for the specific language governing permissions and
978 * limitations under the License.
979 */class wy{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=sh(this.lastLoginAt),this.creationTime=sh(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/**
980 * @license
981 * Copyright 2019 Google LLC
982 *
983 * Licensed under the Apache License, Version 2.0 (the "License");
984 * you may not use this file except in compliance with the License.
985 * You may obtain a copy of the License at
986 *
987 *   http://www.apache.org/licenses/LICENSE-2.0
988 *
989 * Unless required by applicable law or agreed to in writing, software
990 * distributed under the License is distributed on an "AS IS" BASIS,
991 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
992 * See the License for the specific language governing permissions and
993 * limitations under the License.
994 */async function cg(n){var y;const e=n.auth,t=await n.getIdToken(),r=await Du(n,lg(e,{idToken:t}));mt(r==null?void 0:r.users.length,e,"internal-error");const s=r.users[0];n._notifyReloadListener(s);const a=(y=s.providerUserInfo)!=null&&y.length?wS(s.providerUserInfo):[],c=ZL(n.providerData,a),u=n.isAnonymous,h=!(n.email&&s.passwordHash)&&!(c!=null&&c.length),f=u?h:!1,p={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:c,metadata:new wy(s.createdAt,s.lastLoginAt),isAnonymous:f};Object.assign(n,p)}async function XL(n){const e=En(n);await cg(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function ZL(n,e){return[...n.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function wS(n){return n.map(({providerId:e,...t})=>
994({providerId:e,uid:t.rawId||"",displayName:t.displayName||null,email:t.email||null,phoneNumber:t.phoneNumber||null,photoURL:t.photoUrl||null}))}/**
995 * @license
996 * Copyright 2020 Google LLC
997 *
998 * Licensed under the Apache License, Version 2.0 (the "License");
999 * you may not use this file except in compliance with the License.
1000 * You may obtain a copy of the License at
1001 *
1002 *   http://www.apache.org/licenses/LICENSE-2.0
1003 *
1004 * Unless required by applicable law or agreed to in writing, software
1005 * distributed under the License is distributed on an "AS IS" BASIS,
1006 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1007 * See the License for the specific language governing permissions and
1008 * limitations under the License.
1009 */async function e4(n,e){const t=await bS(n,{},async()=>{const r=Fh({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:a}=n.config,c=await vS(n,s,"/v1/token",`key=${a}`),u=await n._getAdditionalHeaders();u["Content-Type"]="application/x-www-form-urlencoded";const h={method:"POST",headers:u,body:r};return n.emulatorConfig&&vc(n.emulatorConfig.host)&&(h.credentials="include"),CS.fetch()(c,h)});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function t4(n,e){return oa(n,"POST","/v2/accounts:revokeToken",Ka(n,e))}/**
1010 * @license
1011 * Copyright 2020 Google LLC
1012 *
1013 * Licensed under the Apache License, Version 2.0 (the "License");
1014 * you may not use this file except in compliance with the License.
1015 * You may obtain a copy of the License at
1016 *
1017 *   http://www.apache.org/licenses/LICENSE-2.0
1018 *
1019 * Unless required by applicable law or agreed to in writing, software
1020 * distributed under the License is distributed on an "AS IS" BASIS,
1021 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1022 * See the License for the specific language governing permissions and
1023 * limitations under the License.
1024 */class Eu{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){mt(e.idToken,"internal-error"),mt(typeof e.idToken<"u","internal-error"),mt(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):IE(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){mt(e.length!==0,"internal-error");const t=IE(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(mt(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:r,refreshToken:s,expiresIn:a}=await e4(e,t);this.updateTokensAndExpiration(r,s,Number(a))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,t){const{refreshToken:r,accessToken:s,expirationTime:a}=t,c=new Eu;return r&&(mt(typeof r=="string","internal-error",{appName:e}),c.refreshToken=r),s&&(mt(typeof s=="string","internal-error",{appName:e}),c.accessToken=s),a&&(mt(typeof a=="number","internal-error",{appName:e}),c.expirationTime=a),c}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Eu,this.toJSON())}_performRefresh(){return Ma("not implemented")}}/**
1025 * @license
1026 * Copyright 2020 Google LLC
1027 *
1028 * Licensed under the Apache License, Version 2.0 (the "License");
1029 * you may not use this file except in compliance with the License.
1030 * You may obtain a copy of the License at
1031 *
1032 *   http://www.apache.org/licenses/LICENSE-2.0
1033 *
1034 * Unless required by applicable law or agreed to in writing, software
1035 * distributed under the License is distributed on an "AS IS" BASIS,
1036 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1037 * See the License for the specific language governing permissions and
1038 * limitations under the License.
1039 */function Io(n,e){mt(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class Ni{constructor({uid:e,auth:t,stsTokenManager:r,...s}){this.providerId="firebase",this.proactiveRefresh=new WL(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new wy(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const t=await Du(this,this.stsTokenManager.getToken(this.auth,e));return mt(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return YL(this,e)}reload(){return XL(this)}_assign(e){this!==e&&(mt(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.ph
1039otoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>({...t})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new Ni({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return t.metadata._copy(this.metadata),t}_onReload(e){mt(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await cg(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Ts(this.auth.app))return Promise.reject(Fa(this.auth));const e=await this.getIdToken();return await Du(this,KL(this.auth,{idToken:e})),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(e=>({...e})),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(e,t){const r=t.displayName??void 0,s=t.email??void 0,a=t.phoneNumber??void 0,c=t.photoURL??void 0,u=t.tenantId??void 0,h=t._redirectEventId??void 0,f=t.createdAt??void 0,p=t.lastLoginAt??void 0,{uid:y,emailVerified:b,isAnonymous:w,providerData:E,stsTokenManager:N}=t;mt(y&&N,e,"internal-error");const S=Eu.fromJSON(this.name,N);mt(typeof y=="string",e,"internal-error"),Io(r,e.name),Io(s,e.name),mt(typeof b=="boolean",e,"internal-error"),mt(typeof w=="boolean",e,"internal-error"),Io(a,e.name),Io(c,e.name),Io(u,e.name),Io(h,e.name),Io(f,e.name),Io(p,e.name);const I=new Ni({uid:y,auth:e,email:s,emailVerified:b,displayName:r,isAnonymous:w,photoURL:c,phoneNumber:a,tenantId:u,stsTokenManager:S,createdAt:f,lastLoginAt:p});return E&&Array.isArray(E)&&(I.providerData=E.map(O=>({...O}))),h&&(I._redirectEventId=h),I}static async _fromIdTokenResponse(e,t,r=!1){const s=new Eu;s.updateFromServerResponse(t);const a=new Ni({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await cg(a),a}static async _fromGetAccountInfoResponse(e,t,r){const s=t.users[0];mt(s.localId!==void 0,"internal-error");const a=s.providerUserInfo!==void 0?wS(s.providerUserInfo):[],c=!(s.email&&s.passwordHash)&&!(a!=null&&a.length),u=new Eu;u.updateFromIdToken(r);const h=new Ni({uid:s.localId,auth:e,stsTokenManager:u,isAnonymous:c}),f={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:a,metadata:new wy(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!(a!=null&&a.length)};return Object.assign(h,f),h}}/**
1040 * @license
1041 * Copyright 2020 Google LLC
1042 *
1043 * Licensed under the Apache License, Version 2.0 (the "License");
1044 * you may not use this file except in compliance with the License.
1045 * You may obtain a copy of the License at
1046 *
1047 *   http://www.apache.org/licenses/LICENSE-2.0
1048 *
1049 * Unless required by applicable law or agreed to in writing, software
1050 * distributed under the License is distributed on an "AS IS" BASIS,
1051 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1052 * See the License for the specific language governing permissions and
1053 * limitations under the License.
1054 */const RE=new Map;function La(n){qa(n instanceof Function,"Expected a class definition");let e=RE.get(n);return e?(qa(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,RE.set(n,e),e)}/**
1055 * @license
1056 * Copyright 2019 Google LLC
1057 *
1058 * Licensed under the Apache License, Version 2.0 (the "License");
1059 * you may not use this file except in compliance with the License.
1060 * You may obtain a copy of the License at
1061 *
1062 *   http://www.apache.org/licenses/LICENSE-2.0
1063 *
1064 * Unless required by applicable law or agreed to in writing, software
1065 * distributed under the License is distributed on an "AS IS" BASIS,
1066 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1067 * See the License for the specific language governing permissions and
1068 * limitations under the License.
1069 */class ES{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}ES.type="NONE";const PE=ES;/**
1070 * @license
1071 * Copyright 2019 Google LLC
1072 *
1073 * Licensed under the Apache License, Version 2.0 (the "License");
1074 * you may not use this file except in compliance with the License.
1075 * You may obtain a copy of the License at
1076 *
1077 *   http://www.apache.org/licenses/LICENSE-2.0
1078 *
1079 * Unless required by applicable law or agreed to in writing, software
1080 * distributed under the License is distributed on an "AS IS" BASIS,
1081 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1082 * See the License for the specific language governing permissions and
1083 * limitations under the License.
1084 */function qm(n,e,t){return`firebase:${n}:${e}:${t}`}class _u{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;const{config:s,name:a}=this.auth;this.fullUserKey=qm(this.userKey,s.apiKey,a),this.fullPersistenceKey=qm("persistence",s.apiKey,a),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e=="string"){const t=await lg(this.auth,{idToken:e}).catch(()=>{});return t?Ni._fromGetAccountInfoResponse(this.auth,t,e):null}return Ni._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,r="authUser"){if(!t.length)return new _u(La(PE),e,r);const s=(await Promise.all(t.map(async f=>{if(await f._isAvailable())return f}))).filter(f=>f);let a=s[0]||La(PE);const c=qm(r,e.config.apiKey,e.name);let u=null;for(const f of t)try{const p=await f._get(c);if(p){let y;if(typeof p=="string"){const b=await lg(e,{idToken:p}).catch(()=>{});if(!b)break;y=await Ni._fromGetAccountInfoResponse(e,b,p)}else y=Ni._fromJSON(e,p);f!==a&&(u=y),a=f;break}}catch{}const h=s.filter(f=>f._shouldAllowMigration);return!a._shouldAllowMigration||!h.length?new _u(a,e,r):(a=h[0],u&&await a._set(c,u.toJSON()),await Promise.all(t.map(async f=>{if(f!==a)try{await f._remove(c)}catch{}})),new _u(a,e,r))}}/**
1085 * @license
1086 * Copyright 2020 Google LLC
1087 *
1088 * Licensed under the Apache License, Version 2.0 (the "License");
1089 * you may not use this file except in compliance with the License.
1090 * You may obtain a copy of the License at
1091 *
1092 *   http://www.apache.org/licenses/LICENSE-2.0
1093 *
1094 * Unless required by applicable law or agreed to in writing, software
1095 * distributed under the License is distributed on an "AS IS" BASIS,
1096 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1097 * See the License for the specific language governing permissions and
1098 * limitations under the License.
1099 */function ME(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(NS(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(_S(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(DS(e))return"Blackberry";if(AS(e))return"Webos";if(TS(e))return"Safari";if((e.includes("chrome/")||kS(e))&&!e.includes("edge/"))return"Chrome";if(SS(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=n.match(t);if((r==null?void 0:r.length)===2)return r[1]}return"Other"}function _S(n=es()){return/firefox\//i.test(n)}function TS(n=es()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function kS(n=es()){return/crios\//i.test(n)}function NS(n=es()){return/iemobile/i.test(n)}function SS(n=es()){return/android/i.test(n)}function DS(n=es()){return/blackberry/i.test(n)}function AS(n=es()){return/webos/i.test(n)}function px(n=es()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function n4(n=es()){var e;return px(n)&&!!((e=window.navigator)!=null&&e.standalone)}function r4(){return yM()&&document.documentMode===10}function IS(n=es()){return px(n)||SS(n)||AS(n)||DS(n)||/windows phone/i.test(n)||NS(n)}/**
1100 * @license
1101 * Copyright 2020 Google LLC
1102 *
1103 * Licensed under the Apache License, Version 2.0 (the "License");
1104 * you may not use this file except in compliance with the License.
1105 * You may obtain a copy of the License at
1106 *
1107 *   http://www.apache.org/licenses/LICENSE-2.0
1108 *
1109 * Unless required by applicable law or agreed to in writing, software
1110 * distributed under the License is distributed on an "AS IS" BASIS,
1111 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1112 * See the License for the specific language governing permissions and
1113 * limitations under the License.
1114 */function RS(n,e=[]){let t;switch(n){case"Browser":t=ME(es());break;case"Worker":t=`${ME(es())}-${n}`;break;default:t=n}const r=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${wc}/${r}`}/**
1115 * @license
1116 * Copyright 2022 Google LLC
1117 *
1118 * Licensed under the Apache License, Version 2.0 (the "License");
1119 * you may not use this file except in compliance with the License.
1120 * You may obtain a copy of the License at
1121 *
1122 *   http://www.apache.org/licenses/LICENSE-2.0
1123 *
1124 * Unless required by applicable law or agreed to in writing, software
1125 * distributed under the License is distributed on an "AS IS" BASIS,
1126 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1127 * See the License for the specific language governing permissions and
1128 * limitations under the License.
1129 */class s4{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const r=a=>new Promise((c,u)=>{try{const h=e(a);c(h)}catch(h){u(h)}});r.onAbort=t,this.queue.push(r);const s=this.queue.length-1;return()=>{this.queue[s]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(r){t.reverse();for(const s of t)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r==null?void 0:r.message})}}}/**
1130 * @license
1131 * Copyright 2023 Google LLC
1132 *
1133 * Licensed under the Apache License, Version 2.0 (the "License");
1134 * you may not use this file except in compliance with the License.
1135 * You may obtain a copy of the License at
1136 *
1137 *   http://www.apache.org/licenses/LICENSE-2.0
1138 *
1139 * Unless required by applicable law or agreed to in writing, software
1140 * distributed under the License is distributed on an "AS IS" BASIS,
1141 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1142 * See the License for the specific language governing permissions and
1143 * limitations under the License.
1144 */async function i4(n,e={}){return oa(n,"GET","/v2/passwordPolicy",Ka(n,e))}/**
1145 * @license
1146 * Copyright 2023 Google LLC
1147 *
1148 * Licensed under the Apache License, Version 2.0 (the "License");
1149 * you may not use this file except in compliance with the License.
1150 * You may obtain a copy of the License at
1151 *
1152 *   http://www.apache.org/licenses/LICENSE-2.0
1153 *
1154 * Unless required by applicable law or agreed to in writing, software
1155 * distributed under the License is distributed on an "AS IS" BASIS,
1156 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1157 * See the License for the specific language governing permissions and
1158 * limitations under the License.
1159 */const a4=6;class o4{constructor(e){var r;const t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??a4,t.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=t.maxPasswordLength),t.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=t.containsLowercaseCharacter),t.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=t.containsUppercaseCharacter),t.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=t.containsNumericCharacter),t.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=t.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=((r=e.allowedNonAlphanumericCharacters)==null?void 0:r.join(""))??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){const t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&
1159(t.isValid=t.meetsMinPasswordLength??!0),t.isValid&&(t.isValid=t.meetsMaxPasswordLength??!0),t.isValid&&(t.isValid=t.containsLowercaseLetter??!0),t.isValid&&(t.isValid=t.containsUppercaseLetter??!0),t.isValid&&(t.isValid=t.containsNumericCharacter??!0),t.isValid&&(t.isValid=t.containsNonAlphanumericCharacter??!0),t}validatePasswordLengthOptions(e,t){const r=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),s&&(t.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let r;for(let s=0;s<e.length;s++)r=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(t,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,s,a){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=a))}}/**
1160 * @license
1161 * Copyright 2020 Google LLC
1162 *
1163 * Licensed under the Apache License, Version 2.0 (the "License");
1164 * you may not use this file except in compliance with the License.
1165 * You may obtain a copy of the License at
1166 *
1167 *   http://www.apache.org/licenses/LICENSE-2.0
1168 *
1169 * Unless required by applicable law or agreed to in writing, software
1170 * distributed under the License is distributed on an "AS IS" BASIS,
1171 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1172 * See the License for the specific language governing permissions and
1173 * limitations under the License.
1174 */class l4{constructor(e,t,r,s){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new LE(this),this.idTokenSubscription=new LE(this),this.beforeStateQueue=new s4(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=yS,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=e.name,this.clientVersion=s.sdkClientVersion,this._persistenceManagerAvailable=new Promise(a=>this._resolvePersistenceManagerAvailable=a)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=La(t)),this._initializationPromise=this.queue(async()=>{var r,s,a;if(!this._deleted&&(this.persistenceManager=await _u.create(this,e),(r=this._resolvePersistenceManagerAvailable)==null||r.call(this),!this._deleted)){if((s=this._popupRedirectResolver)!=null&&s._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),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 e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await lg(this,{idToken:e}),r=await Ni._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var a;if(Ts(this.app)){const c=this.app.settings.authIdToken;return c?new Promise(u=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(c).then(u,u))}):this.directlySetCurrentUser(null)}const t=await this.assertedPersistence.getCurrentUser();let r=t,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const c=(a=this.redirectUser)==null?void 0:a._redirectEventId,u=r==null?void 0:r._redirectEventId,h=await this.tryRedirectSignIn(e);(!c||c===u)&&(h!=null&&h.user)&&(r=h.user,s=!0)}if(!r)return this.directlySetCurrentUser(null);
1174if(!r._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(r)}catch(c){r=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(c))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return mt(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await cg(e)}catch(t){if((t==null?void 0:t.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=UL()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(Ts(this.app))return Promise.reject(Fa(this));const t=e?En(e):null;return t&&mt(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&mt(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return Ts(this.app)?Promise.reject(Fa(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Ts(this.app)?Promise.reject(Fa(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(La(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await i4(this),t=new o4(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new Oh("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(r.tenantId=this.tenantId),await t4(this,r)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)==null?void 0:e.toJSON()}}async _setRedirectUser(e,t){const r=await this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&La(e)||this._popupRedirectResolver;mt(t,this,"argument-error"),this.redirectPersistenceManager=await _u.create(this,[La(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,r;return this._isInitialized&&await this.queue(async()=>{}),((t=this._currentUser)==null?void 0:t._redirectEventId)===e?this._currentUser:((r=this.redirectUser)==null?void 0:r._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===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 t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const e=((t=this.currentUser)==null?void 0:t.uid)??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,r,s){if(this._deleted)return()=>{};const a=typeof t=="function"?t:t.next.bind(t);let c=!1;const u=this._isInitialized?Promise.resolve():this._initializationPromise;if(mt(u,this,"internal-error"),u.then(()=>{c||a(this.currentUser)}),typeof t=="function"){const h=e.addObserver(t,r,s);return()=>{c=!0,h()}}else{const h=e.addObserver(t);return()=>{c=!0,h()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return mt(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=RS(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var s;const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const t=await((s=this.heartbeatServiceProvider.getImmediate({optional:!0}))==null?void 0:s.getHeartbeatsHeader());t&&(e["X-Firebase-Client"]=t);const r=await this._getAppCheckToken();return r&&(e["X-Firebase-AppCheck"]=r),e}async _getAppCheckToken(){var t;if(Ts(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await((t=this.appCheckServiceProvider.getImmediate({optional:!0}))==null?void 0:t.getToken());return e!=null&&e.error&&xS(`Error while retrieving App Check token: ${e.error}`),e==null?void 0:e.token}}function Ya(n){return En(n)}class LE{constructor(e){this.auth=e,this.observer=null,this.addObserver=_M(t=>this.observer=t)}get next(){return mt(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/**
1175 * @license
1176 * Copyright 2020 Google LLC
1177 *
1178 * Licensed under the Apache License, Version 2.0 (the "License");
1179 * you may not use this file except in compliance with the License.
1180 * You may obtain a copy of the License at
1181 *
1182 *   http://www.apache.org/licenses/LICENSE-2.0
1183 *
1184 * Unless required by applicable law or agreed to in writing, software
1185 * distributed under the License is distributed on an "AS IS" BASIS,
1186 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1187 * See the License for the specific language governing permissions and
1188 * limitations under the License.
1189 */let Xg={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function c4(n){Xg=n}function PS(n){return Xg.loadJS(n)}function u4(){return Xg.recaptchaEnterpriseScript}function d4(){return Xg.gapiScript}function h4(n){return`__${n}${Math.floor(Math.random()*1e6)}`}class f4{constructor(){this.enterprise=new m4}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class m4{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}/**
1190 * @license
1191 * Copyright 2022 Google LLC
1192 *
1193 * Licensed under the Apache License, Version 2.0 (the "License");
1194 * you may not use this file except in compliance with the License.
1195 * You may obtain a copy of the License at
1196 *
1197 *   http://www.apache.org/licenses/LICENSE-2.0
1198 *
1199 * Unless required by applicable law or agreed to in writing, software
1200 * distributed under the License is distributed on an "AS IS" BASIS,
1201 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1202 * See the License for the specific language governing permissions and
1203 * limitations under the License.
1204 */const g4="recaptcha-enterprise",MS="NO_RECAPTCHA",jE="onFirebaseAuthREInstanceReady";class Fo{constructor(e){this.type=g4,this.auth=Ya(e)}async verify(e="verify",t=!1){async function r(a){if(!t){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(c,u)=>{$L(a,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(h=>{if(h.recaptchaKey===void 0)u(new Error("recaptcha Enterprise site key undefined"));else{const f=new JL(h);return a.tenantId==null?a._agentRecaptchaConfig=f:a._tenantRecaptchaConfigs[a.tenantId]=f,c(f.siteKey)}}).catch(h=>{u(h)})})}function s(a,c,u){const h=window.grecaptcha;AE(h)?h.enterprise.ready(()=>{h.enterprise.execute(a,{action:e}).then(f=>{c(f)}).catch(()=>{c(MS)})}):u(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new f4().execute("siteKey",{action:"verify"}):new Promise((a,c)=>{r(this.auth).then(async u=>{if(!t&&AE(window.grecaptcha)&&Fo.scriptInjectionDeferred)await Fo.scriptInjectionDeferred.promise,s(u,a,c);else{if(typeof window>"u"){c(new Error("RecaptchaVerifier is only supported in browser"));return}let h=u4();h.length!==0&&(h+=u+`&onload=${jE}`),Fo.scriptInjectionDeferred=new dS,window[jE]=()=>{var f;(f=Fo.scriptInjectionDeferred)==null||f.resolve()},PS(h).then(()=>{var f;return(f=Fo.scriptInjectionDeferred)==null?void 0:f.promise}).then(()=>{s(u,a,c)}).catch(f=>{c(f)})}}).catch(u=>{c(u)})})}}Fo.scriptInjectionDeferred=null;async function OE(n,e,t,r=!1,s=!1){const a=new Fo(n);let c;if(s)c=MS;else try{c=await a.verify(t)}catch{c=await a.verify(t,!0)}const u={...e};if(t==="mfaSmsEnrollment"||t==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in u){const h=u.phoneEnrollmentInfo.phoneNumber,f=u.phoneEnrollmentInfo.recaptchaToken;Object.assign(u,{phoneEnrollmentInfo:{phoneNumber:h,recaptchaToken:f,captchaResponse:c,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in u){const h=u.phoneSignInInfo.recaptchaToken;Object.assign(u,{phoneSignInInfo:{recaptchaToken:h,captchaResponse:c,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return u}return r?Object.assign(u,{captchaResp:c}):Object.assign(u,{captchaResponse:c}),Object.assign(u,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(u,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),u}async function ug(n,e,t,r,s){var a;if((a=n._getRecaptchaConfig())!=null&&a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const c=await OE(n,e,t,t==="getOobCode");return r(n,c)}
1204else return r(n,e).catch(async c=>{if(c.code==="auth/missing-recaptcha-token"){console.log(`${t} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const u=await OE(n,e,t,t==="getOobCode");return r(n,u)}else return Promise.reject(c)})}/**
1205 * @license
1206 * Copyright 2020 Google LLC
1207 *
1208 * Licensed under the Apache License, Version 2.0 (the "License");
1209 * you may not use this file except in compliance with the License.
1210 * You may obtain a copy of the License at
1211 *
1212 *   http://www.apache.org/licenses/LICENSE-2.0
1213 *
1214 * Unless required by applicable law or agreed to in writing, software
1215 * distributed under the License is distributed on an "AS IS" BASIS,
1216 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1217 * See the License for the specific language governing permissions and
1218 * limitations under the License.
1219 */function p4(n,e){const t=Qg(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),a=t.getOptions();if(hc(a,e??{}))return s;gi(s,"already-initialized")}return t.initialize({options:e})}function B4(n,e){const t=(e==null?void 0:e.persistence)||[],r=(Array.isArray(t)?t:[t]).map(La);e!=null&&e.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e==null?void 0:e.popupRedirectResolver)}function y4(n,e,t){const r=Ya(n);
1219mt(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,a=LS(e),{host:c,port:u}=x4(e),h=u===null?"":`:${u}`,f={url:`${a}//${c}${h}/`},p=Object.freeze({host:c,port:u,protocol:a.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!r._canInitEmulator){mt(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),mt(hc(f,r.config.emulator)&&hc(p,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=f,r.emulatorConfig=p,r.settings.appVerificationDisabledForTesting=!0,vc(c)?lx(`${a}//${c}${h}`):C4()}function LS(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function x4(n){const e=LS(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const r=t[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const a=s[1];return{host:a,port:FE(r.substr(a.length+1))}}else{const[a,c]=r.split(":");return{host:a,port:FE(c)}}}function FE(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function C4(){function n(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}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",n):n())}/**
1220 * @license
1221 * Copyright 2020 Google LLC
1222 *
1223 * Licensed under the Apache License, Version 2.0 (the "License");
1224 * you may not use this file except in compliance with the License.
1225 * You may obtain a copy of the License at
1226 *
1227 *   http://www.apache.org/licenses/LICENSE-2.0
1228 *
1229 * Unless required by applicable law or agreed to in writing, software
1230 * distributed under the License is distributed on an "AS IS" BASIS,
1231 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1232 * See the License for the specific language governing permissions and
1233 * limitations under the License.
1234 */class Bx{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return Ma("not implemented")}_getIdTokenResponse(e){return Ma("not implemented")}_linkToIdToken(e,t){return Ma("not implemented")}_getReauthenticationResolver(e){return Ma("not implemented")}}async function b4(n,e){return oa(n,"POST","/v1/accounts:signUp",e)}/**
1235 * @license
1236 * Copyright 2020 Google LLC
1237 *
1238 * Licensed under the Apache License, Version 2.0 (the "License");
1239 * you may not use this file except in compliance with the License.
1240 * You may obtain a copy of the License at
1241 *
1242 *   http://www.apache.org/licenses/LICENSE-2.0
1243 *
1244 * Unless required by applicable law or agreed to in writing, software
1245 * distributed under the License is distributed on an "AS IS" BASIS,
1246 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1247 * See the License for the specific language governing permissions and
1248 * limitations under the License.
1249 */async function v4(n,e){return Vh(n,"POST","/v1/accounts:signInWithPassword",Ka(n,e))}async function jS(n,e){return oa(n,"POST","/v1/accounts:sendOobCode",Ka(n,e))}async function w4(n,e){return jS(n,e)}async function E4(n,e){return jS(n,e)}/**
1250 * @license
1251 * Copyright 2020 Google LLC
1252 *
1253 * Licensed under the Apache License, Version 2.0 (the "License");
1254 * you may not use this file except in compliance with the License.
1255 * You may obtain a copy of the License at
1256 *
1257 *   http://www.apache.org/licenses/LICENSE-2.0
1258 *
1259 * Unless required by applicable law or agreed to in writing, software
1260 * distributed under the License is distributed on an "AS IS" BASIS,
1261 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1262 * See the License for the specific language governing permissions and
1263 * limitations under the License.
1264 */async function _4(n,e){return Vh(n,"POST","/v1/accounts:signInWithEmailLink",Ka(n,e))}async function T4(n,e){return Vh(n,"POST","/v1/accounts:signInWithEmailLink",Ka(n,e))}/**
1265 * @license
1266 * Copyright 2020 Google LLC
1267 *
1268 * Licensed under the Apache License, Version 2.0 (the "License");
1269 * you may not use this file except in compliance with the License.
1270 * You may obtain a copy of the License at
1271 *
1272 *   http://www.apache.org/licenses/LICENSE-2.0
1273 *
1274 * Unless required by applicable law or agreed to in writing, software
1275 * distributed under the License is distributed on an "AS IS" BASIS,
1276 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1277 * See the License for the specific language governing permissions and
1278 * limitations under the License.
1279 */class bh extends Bx{constructor(e,t,r,s=null){super("password",r),this._email=e,this._password=t,this._tenantId=s}static _fromEmailAndPassword(e,t){return new bh(e,t,"password")}static _fromEmailAndCode(e,t,r=null){return new bh(e,t,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e;if(t!=null&&t.email&&(t!=null&&t.password)){if(t.signInMethod==="password")return this._fromEmailAndPassword(t.email,t.password);if(t.signInMethod==="emailLink")return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":const t={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return ug(e,t,"signInWithPassword",v4);case"emailLink":return _4(e,{email:this._email,oobCode:this._password});default:gi(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":const r={idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return ug(e,r,"signUpPassword",b4);case"emailLink":return T4(e,{idToken:t,email:this._email,oobCode:this._password});default:gi(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}/**
1280 * @license
1281 * Copyright 2020 Google LLC
1282 *
1283 * Licensed under the Apache License, Version 2.0 (the "License");
1284 * you may not use this file except in compliance with the License.
1285 * You may obtain a copy of the License at
1286 *
1287 *   http://www.apache.org/licenses/LICENSE-2.0
1288 *
1289 * Unless required by applicable law or agreed to in writing, software
1290 * distributed under the License is distributed on an "AS IS" BASIS,
1291 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1292 * See the License for the specific language governing permissions and
1293 * limitations under the License.
1294 */async function Tu(n,e){return Vh(n,"POST","/v1/accounts:signInWithIdp",Ka(n,e))}/**
1295 * @license
1296 * Copyright 2020 Google LLC
1297 *
1298 * Licensed under the Apache License, Version 2.0 (the "License");
1299 * you may not use this file except in compliance with the License.
1300 * You may obtain a copy of the License at
1301 *
1302 *   http://www.apache.org/licenses/LICENSE-2.0
1303 *
1304 * Unless required by applicable law or agreed to in writing, software
1305 * distributed under the License is distributed on an "AS IS" BASIS,
1306 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1307 * See the License for the specific language governing permissions and
1308 * limitations under the License.
1309 */const k4="http://localhost";class gc extends Bx{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new gc(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):gi("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,n
1309once:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:r,signInMethod:s,...a}=t;if(!r||!s)return null;const c=new gc(r,s);return c.idToken=a.idToken||void 0,c.accessToken=a.accessToken||void 0,c.secret=a.secret,c.nonce=a.nonce,c.pendingToken=a.pendingToken||null,c}_getIdTokenResponse(e){const t=this.buildRequest();return Tu(e,t)}_linkToIdToken(e,t){const r=this.buildRequest();return r.idToken=t,Tu(e,r)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Tu(e,t)}buildRequest(){const e={requestUri:k4,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=Fh(t)}return e}}/**
1310 * @license
1311 * Copyright 2020 Google LLC
1312 *
1313 * Licensed under the Apache License, Version 2.0 (the "License");
1314 * you may not use this file except in compliance with the License.
1315 * You may obtain a copy of the License at
1316 *
1317 *   http://www.apache.org/licenses/LICENSE-2.0
1318 *
1319 * Unless required by applicable law or agreed to in writing, software
1320 * distributed under the License is distributed on an "AS IS" BASIS,
1321 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1322 * See the License for the specific language governing permissions and
1323 * limitations under the License.
1324 */function N4(n){switch(n){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 S4(n){const e=Kd(Yd(n)).link,t=e?Kd(Yd(e)).deep_link_id:null,r=Kd(Yd(n)).deep_link_id;return(r?Kd(Yd(r)).link:null)||r||t||e||n}class yx{constructor(e){const t=Kd(Yd(e)),r=t.apiKey??null,s=t.oobCode??null,a=N4(t.mode??null);mt(r&&s&&a,"argument-error"),this.apiKey=r,this.operation=a,this.code=s,this.continueUrl=t.continueUrl??null,this.languageCode=t.lang??null,this.tenantId=t.tenantId??null}static parseLink(e){const t=S4(e);try{return new yx(t)}catch{return null}}}/**
1325 * @license
1326 * Copyright 2020 Google LLC
1327 *
1328 * Licensed under the Apache License, Version 2.0 (the "License");
1329 * you may not use this file except in compliance with the License.
1330 * You may obtain a copy of the License at
1331 *
1332 *   http://www.apache.org/licenses/LICENSE-2.0
1333 *
1334 * Unless required by applicable law or agreed to in writing, software
1335 * distributed under the License is distributed on an "AS IS" BASIS,
1336 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1337 * See the License for the specific language governing permissions and
1338 * limitations under the License.
1339 */class Ou{constructor(){this.providerId=Ou.PROVIDER_ID}static credential(e,t){return bh._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const r=yx.parseLink(t);return mt(r,"argument-error"),bh._fromEmailAndCode(e,r.code,r.tenantId)}}Ou.PROVIDER_ID="password";Ou.EMAIL_PASSWORD_SIGN_IN_METHOD="password";Ou.EMAIL_LINK_SIGN_IN_METHOD="emailLink";/**
1340 * @license
1341 * Copyright 2020 Google LLC
1342 *
1343 * Licensed under the Apache License, Version 2.0 (the "License");
1344 * you may not use this file except in compliance with the License.
1345 * You may obtain a copy of the License at
1346 *
1347 *   http://www.apache.org/licenses/LICENSE-2.0
1348 *
1349 * Unless required by applicable law or agreed to in writing, software
1350 * distributed under the License is distributed on an "AS IS" BASIS,
1351 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1352 * See the License for the specific language governing permissions and
1353 * limitations under the License.
1354 */class xx{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}/**
1355 * @license
1356 * Copyright 2019 Google LLC
1357 *
1358 * Licensed under the Apache License, Version 2.0 (the "License");
1359 * you may not use this file except in compliance with the License.
1360 * You may obtain a copy of the License at
1361 *
1362 *   http://www.apache.org/licenses/LICENSE-2.0
1363 *
1364 * Unless required by applicable law or agreed to in writing, software
1365 * distributed under the License is distributed on an "AS IS" BASIS,
1366 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1367 * See the License for the specific language governing permissions and
1368 * limitations under the License.
1369 */class Gh extends xx{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}/**
1370 * @license
1371 * Copyright 2020 Google LLC
1372 *
1373 * Licensed under the Apache License, Version 2.0 (the "License");
1374 * you may not use this file except in compliance with the License.
1375 * You may obtain a copy of the License at
1376 *
1377 *   http://www.apache.org/licenses/LICENSE-2.0
1378 *
1379 * Unless required by applicable law or agreed to in writing, software
1380 * distributed under the License is distributed on an "AS IS" BASIS,
1381 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1382 * See the License for the specific language governing permissions and
1383 * limitations under the License.
1384 */class Uo extends Gh{constructor(){super("facebook.com")}static credential(e){return gc._fromParams({providerId:Uo.PROVIDER_ID,signInMethod:Uo.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Uo.credentialFromTaggedObject(e)}static credentialFromError(e){return Uo.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Uo.credential(e.oauthAccessToken)}catch{return null}}}Uo.FACEBOOK_SIGN_IN_METHOD="facebook.com";Uo.PROVIDER_ID="facebook.com";/**
1385 * @license
1386 * Copyright 2020 Google LLC
1387 *
1388 * Licensed under the Apache License, Version 2.0 (the "License");
1389 * you may not use this file except in compliance with the License.
1390 * You may obtain a copy of the License at
1391 *
1392 *   http://www.apache.org/licenses/LICENSE-2.0
1393 *
1394 * Unless required by applicable law or agreed to in writing, software
1395 * distributed under the License is distributed on an "AS IS" BASIS,
1396 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1397 * See the License for the specific language governing permissions and
1398 * limitations under the License.
1399 */class Ia extends Gh{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return gc._fromParams({providerId:Ia.PROVIDER_ID,signInMethod:Ia.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return Ia.credentialFromTaggedObject(e)}static credentialFromError(e){return Ia.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:r}=e;if(!t&&!r)return null;try{return Ia.credential(t,r)}catch{return null}}}Ia.GOOGLE_SIGN_IN_METHOD="google.com";Ia.PROVIDER_ID="google.com";/**
1400 * @license
1401 * Copyright 2020 Google LLC
1402 *
1403 * Licensed under the Apache License, Version 2.0 (the "License");
1404 * you may not use this file except in compliance with the License.
1405 * You may obtain a copy of the License at
1406 *
1407 *   http://www.apache.org/licenses/LICENSE-2.0
1408 *
1409 * Unless required by applicable law or agreed to in writing, software
1410 * distributed under the License is distributed on an "AS IS" BASIS,
1411 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1412 * See the License for the specific language governing permissions and
1413 * limitations under the License.
1414 */class Vo extends Gh{constructor(){super("github.com")}static credential(e){return gc._fromParams({providerId:Vo.PROVIDER_ID,signInMethod:Vo.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Vo.credentialFromTaggedObject(e)}static credentialFromError(e){return Vo.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Vo.credential(e.oauthAccessToken)}catch{return null}}}Vo.GITHUB_SIGN_IN_METHOD="github.com";Vo.PROVIDER_ID="github.com";/**
1415 * @license
1416 * Copyright 2020 Google LLC
1417 *
1418 * Licensed under the Apache License, Version 2.0 (the "License");
1419 * you may not use this file except in compliance with the License.
1420 * You may obtain a copy of the License at
1421 *
1422 *   http://www.apache.org/licenses/LICENSE-2.0
1423 *
1424 * Unless required by applicable law or agreed to in writing, software
1425 * distributed under the License is distributed on an "AS IS" BASIS,
1426 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1427 * See the License for the specific language governing permissions and
1428 * limitations under the License.
1429 */class Go extends Gh{constructor(){super("twitter.com")}static credential(e,t){return gc._fromParams({providerId:Go.PROVIDER_ID,signInMethod:Go.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return Go.credentialFromTaggedObject(e)}static credentialFromError(e){return Go.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:r}=e;if(!t||!r)return null;try{return Go.credential(t,r)}catch{return null}}}Go.TWITTER_SIGN_IN_METHOD="twitter.com";Go.PROVIDER_ID="twitter.com";/**
1430 * @license
1431 * Copyright 2020 Google LLC
1432 *
1433 * Licensed under the Apache License, Version 2.0 (the "License");
1434 * you may not use this file except in compliance with the License.
1435 * You may obtain a copy of the License at
1436 *
1437 *   http://www.apache.org/licenses/LICENSE-2.0
1438 *
1439 * Unless required by applicable law or agreed to in writing, software
1440 * distributed under the License is distributed on an "AS IS" BASIS,
1441 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1442 * See the License for the specific language governing permissions and
1443 * limitations under the License.
1444 */async function D4(n,e){return Vh(n,"POST","/v1/accounts:signUp",Ka(n,e))}/**
1445 * @license
1446 * Copyright 2020 Google LLC
1447 *
1448 * Licensed under the Apache License, Version 2.0 (the "License");
1449 * you may not use this file except in compliance with the License.
1450 * You may obtain a copy of the License at
1451 *
1452 *   http://www.apache.org/licenses/LICENSE-2.0
1453 *
1454 * Unless required by applicable law or agreed to in writing, software
1455 * distributed under the License is distributed on an "AS IS" BASIS,
1456 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1457 * See the License for the specific language governing permissions and
1458 * limitations under the License.
1459 */class pc{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,s=!1){const a=await Ni._fromIdTokenResponse(e,r,s),c=UE(r);return new pc({user:a,providerId:c,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);const s=UE(r);return new pc({user:e,providerId:s,_tokenResponse:r,operationType:t})}}function UE(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}/**
1460 * @license
1461 * Copyright 2020 Google LLC
1462 *
1463 * Licensed under the Apache License, Version 2.0 (the "License");
1464 * you may not use this file except in compliance with the License.
1465 * You may obtain a copy of the License at
1466 *
1467 *   http://www.apache.org/licenses/LICENSE-2.0
1468 *
1469 * Unless required by applicable law or agreed to in writing, software
1470 * distributed under the License is distributed on an "AS IS" BASIS,
1471 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1472 * See the License for the specific language governing permissions and
1473 * limitations under the License.
1474 */class dg extends aa{constructor(e,t,r,s){super(t.code,t.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,dg.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,s){return new dg(e,t,r,s)}}function OS(n,e,t,r){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(a=>{throw a.code==="auth/multi-factor-auth-required"?dg._fromErrorAndOperation(n,a,e,r):a})}async function A4(n,e,t=!1){const r=await Du(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return pc._forOperation(n,"link",r)}/**
1475 * @license
1476 * Copyright 2019 Google LLC
1477 *
1478 * Licensed under the Apache License, Version 2.0 (the "License");
1479 * you may not use this file except in compliance with the License.
1480 * You may obtain a copy of the License at
1481 *
1482 *   http://www.apache.org/licenses/LICENSE-2.0
1483 *
1484 * Unless required by applicable law or agreed to in writing, software
1485 * distributed under the License is distributed on an "AS IS" BASIS,
1486 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1487 * See the License for the specific language governing permissions and
1488 * limitations under the License.
1489 */async function I4(n,e,t=!1){const{auth:r}=n;if(Ts(r.app))return Promise.reject(Fa(r));const s="reauthenticate";try{const a=await Du(n,OS(r,s,e,n),t);mt(a.idToken,r,"internal-error");const c=gx(a.idToken);mt(c,r,"internal-error");const{sub:u}=c;return mt(n.uid===u,r,"user-mismatch"),pc._forOperation(n,s,a)}catch(a){throw(a==null?void 0:a.code)==="auth/user-not-found"&&gi(r,"user-mismatch"),a}}/**
1490 * @license
1491 * Copyright 2020 Google LLC
1492 *
1493 * Licensed under the Apache License, Version 2.0 (the "License");
1494 * you may not use this file except in compliance with the License.
1495 * You may obtain a copy of the License at
1496 *
1497 *   http://www.apache.org/licenses/LICENSE-2.0
1498 *
1499 * Unless required by applicable law or agreed to in writing, software
1500 * distributed under the License is distributed on an "AS IS" BASIS,
1501 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1502 * See the License for the specific language governing permissions and
1503 * limitations under the License.
1504 */async function FS(n,e,t=!1){if(Ts(n.app))return Promise.reject(Fa(n));const r="signIn",s=await OS(n,r,e),a=await pc._fromIdTokenResponse(n,r,s);return t||await n._updateCurrentUser(a.user),a}async function R4(n,e){return FS(Ya(n),e)}/**
1505 * @license
1506 * Copyright 2020 Google LLC
1507 *
1508 * Licensed under the Apache License, Version 2.0 (the "License");
1509 * you may not use this file except in compliance with the License.
1510 * You may obtain a copy of the License at
1511 *
1512 *   http://www.apache.org/licenses/LICENSE-2.0
1513 *
1514 * Unless required by applicable law or agreed to in writing, software
1515 * distributed under the License is distributed on an "AS IS" BASIS,
1516 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1517 * See the License for the specific language governing permissions and
1518 * limitations under the License.
1519 */async function US(n){const e=Ya(n);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function VE(n,e,t){const r=Ya(n);await ug(r,{requestType:"PASSWORD_RESET",email:e,clientType:"CLIENT_TYPE_WEB"},"getOobCode",E4)}async function GE(n,e,t){if(Ts(n.app))return Promise.reject(Fa(n));const r=Ya(n),c=await ug(r,{returnSecureToken:!0,email:e,password:t,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",D4).catch(h=>{throw h.code==="auth/password-does-not-meet-requirements"&&US(n),h}),u=await pc._fromIdTokenResponse(r,"signIn",c);return await r._updateCurrentUser(u.user),u}function HE(n,e,t){return Ts(n.app)?Promise.reject(Fa(n)):R4(En(n),Ou.credential(e,t)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&US(n),r})}async function VB(n,e){const t=En(n),s={requestType:"VERIFY_EMAIL",idToken:await n.getIdToken()},{email:a}=await w4(t.auth,s);a!==n.email&&await n.reload()}/**
1520 * @license
1521 * Copyright 2020 Google LLC
1522 *
1523 * Licensed under the Apache License, Version 2.0 (the "License");
1524 * you may not use this file except in compliance with the License.
1525 * You may obtain a copy of the License at
1526 *
1527 *   http://www.apache.org/licenses/LICENSE-2.0
1528 *
1529 * Unless required by applicable law or agreed to in writing, software
1530 * distributed under the License is distributed on an "AS IS" BASIS,
1531 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1532 * See the License for the specific language governing permissions and
1533 * limitations under the License.
1534 */async function P4(n,e){return oa(n,"POST","/v1/accounts:update",e)}/**
1535 * @license
1536 * Copyright 2020 Google LLC
1537 *
1538 * Licensed under the Apache License, Version 2.0 (the "License");
1539 * you may not use this file except in compliance with the License.
1540 * You may obtain a copy of the License at
1541 *
1542 *   http://www.apache.org/licenses/LICENSE-2.0
1543 *
1544 * Unless required by applicable law or agreed to in writing, softw
1544are
1545 * distributed under the License is distributed on an "AS IS" BASIS,
1546 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1547 * See the License for the specific language governing permissions and
1548 * limitations under the License.
1549 */async function qE(n,{displayName:e,photoURL:t}){if(e===void 0&&t===void 0)return;const r=En(n),a={idToken:await r.getIdToken(),displayName:e,photoUrl:t,returnSecureToken:!0},c=await Du(r,P4(r.auth,a));r.displayName=c.displayName||null,r.photoURL=c.photoUrl||null;const u=r.providerData.find(({providerId:h})=>h==="password");u&&(u.displayName=r.displayName,u.photoURL=r.photoURL),await r._updateTokensIfNecessary(c)}function M4(n,e,t,r){return En(n).onIdTokenChanged(e,t,r)}function L4(n,e,t){return En(n).beforeAuthStateChanged(e,t)}function j4(n,e,t,r){return En(n).onAuthStateChanged(e,t,r)}function zE(n){return En(n).signOut()}const hg="__sak";/**
1550 * @license
1551 * Copyright 2019 Google LLC
1552 *
1553 * Licensed under the Apache License, Version 2.0 (the "License");
1554 * you may not use this file except in compliance with the License.
1555 * You may obtain a copy of the License at
1556 *
1557 *   http://www.apache.org/licenses/LICENSE-2.0
1558 *
1559 * Unless required by applicable law or agreed to in writing, software
1560 * distributed under the License is distributed on an "AS IS" BASIS,
1561 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1562 * See the License for the specific language governing permissions and
1563 * limitations under the License.
1564 */class VS{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(hg,"1"),this.storage.removeItem(hg),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}/**
1565 * @license
1566 * Copyright 2020 Google LLC
1567 *
1568 * Licensed under the Apache License, Version 2.0 (the "License");
1569 * you may not use this file except in compliance with the License.
1570 * You may obtain a copy of the License at
1571 *
1572 *   http://www.apache.org/licenses/LICENSE-2.0
1573 *
1574 * Unless required by applicable law or agreed to in writing, software
1575 * distributed under the License is distributed on an "AS IS" BASIS,
1576 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1577 * See the License for the specific language governing permissions and
1578 * limitations under the License.
1579 */const O4=1e3,F4=10;class GS extends VS{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=IS(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const r=this.storage.getItem(t),s=this.localCache[t];r!==s&&e(t,s,r)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((c,u,h)=>{this.notifyListeners(c,h)});return}const r=e.key;t?this.detachListener():this.stopPolling();const s=()=>{const c=this.storage.getItem(r);!t&&this.localCache[r]===c||this.notifyListeners(r,c)},a=this.storage.getItem(r);r4()&&a!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,F4):s()}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:r}),!0)})},O4)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
1579ject.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}GS.type="LOCAL";const U4=GS;/**
1580 * @license
1581 * Copyright 2020 Google LLC
1582 *
1583 * Licensed under the Apache License, Version 2.0 (the "License");
1584 * you may not use this file except in compliance with the License.
1585 * You may obtain a copy of the License at
1586 *
1587 *   http://www.apache.org/licenses/LICENSE-2.0
1588 *
1589 * Unless required by applicable law or agreed to in writing, software
1590 * distributed under the License is distributed on an "AS IS" BASIS,
1591 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1592 * See the License for the specific language governing permissions and
1593 * limitations under the License.
1594 */class HS extends VS{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}HS.type="SESSION";const qS=HS;/**
1595 * @license
1596 * Copyright 2019 Google LLC
1597 *
1598 * Licensed under the Apache License, Version 2.0 (the "License");
1599 * you may not use this file except in compliance with the License.
1600 * You may obtain a copy of the License at
1601 *
1602 *   http://www.apache.org/licenses/LICENSE-2.0
1603 *
1604 * Unless required by applicable law or agreed to in writing, software
1605 * distributed under the License is distributed on an "AS IS" BASIS,
1606 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1607 * See the License for the specific language governing permissions and
1608 * limitations under the License.
1609 */function V4(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}/**
1610 * @license
1611 * Copyright 2019 Google LLC
1612 *
1613 * Licensed under the Apache License, Version 2.0 (the "License");
1614 * you may not use this file except in compliance with the License.
1615 * You may obtain a copy of the License at
1616 *
1617 *   http://www.apache.org/licenses/LICENSE-2.0
1618 *
1619 * Unless required by applicable law or agreed to in writing, software
1620 * distributed under the License is distributed on an "AS IS" BASIS,
1621 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1622 * See the License for the specific language governing permissions and
1623 * limitations under the License.
1624 */class Zg{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(s=>s.isListeningto(e));if(t)return t;const r=new Zg(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:r,eventType:s,data:a}=t.data,c=this.handlersMap[s];if(!(c!=null&&c.size))return;t.ports[0].postMessage({status:"ack",eventId:r,eventType:s});const u=Array.from(c).map(async f=>f(t.origin,a)),h=await V4(u);t.ports[0].postMessage({status:"done",eventId:r,eventType:s,response:h})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),(!t||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}Zg.receivers=[];/**
1625 * @license
1626 * Copyright 2020 Google LLC
1627 *
1628 * Licensed under the Apache License, Version 2.0 (the "License");
1629 * you may not use this file except in compliance with the License.
1630 * You may obtain a copy of the License at
1631 *
1632 *   http://www.apache.org/licenses/LICENSE-2.0
1633 *
1634 * Unless required by applicable law or agreed to in writing, software
1635 * distributed under the License is distributed on an "AS IS" BASIS,
1636 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1637 * See the License for the specific language governing permissions and
1638 * limitations under the License.
1639 */function Cx(n="",e=10){let t="";for(let r=0;r<e;r++)t+=Math.floor(Math.random()*10);return n+t}/**
1640 * @license
1641 * Copyright 2019 Google LLC
1642 *
1643 * Licensed under the Apache License, Version 2.0 (the "License");
1644 * you may not use this file except in compliance with the License.
1645 * You may obtain a copy of the License at
1646 *
1647 *   http://www.apache.org/licenses/LICENSE-2.0
1648 *
1649 * Unless required by applicable law or agreed to in writing, software
1650 * distributed under the License is distributed on an "AS IS" BASIS,
1651 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1652 * See the License for the specific language governing permissions and
1653 * limitations under the License.
1654 */class G4{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,r=50){const s=typeof MessageChannel<"u"?new MessageChannel:null;if(!s)throw new Error("connection_unavailable");let a,c;return new Promise((u,h)=>{const f=Cx("",20);s.port1.start();const p=setTimeout(()=>{h(new Error("unsupported_event"))},r);c={messageChannel:s,onMessage(y){const b=y;if(b.data.eventId===f)switch(b.data.status){case"ack":clearTimeout(p),a=setTimeout(()=>{h(new Error("timeout"))},3e3);break;case"done":clearTimeout(a),u(b.data.response);break;default:clearTimeout(p),clearTimeout(a),h(new Error("invalid_response"));break}}},this.handlers.add(c),s.port1.addEventListener("message",c.onMessage),this.target.postMessage({eventType:e,eventId:f,data:t},[s.port2])}).finally(()=>{c&&this.removeMessageHandler(c)})}}/**
1655 * @license
1656 * Copyright 2020 Google LLC
1657 *
1658 * Licensed under the Apache License, Version 2.0 (the "License");
1659 * you may not use this file except in compliance with the License.
1660 * You may obtain a copy of the License at
1661 *
1662 *   http://www.apache.org/licenses/LICENSE-2.0
1663 *
1664 * Unless required by applicable law or agreed to in writing, software
1665 * distributed under the License is distributed on an "AS IS" BASIS,
1666 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1667 * See the License for the specific language governing permissions and
1668 * limitations under the License.
1669 */function ea(){return window}function H4(n){ea().location.href=n}/**
1670 * @license
1671 * Copyright 2020 Google LLC.
1672 *
1673 * Licensed under the Apache License, Version 2.0 (the "License");
1674 * you may not use this file except in compliance with the License.
1675 * You may obtain a copy of the License at
1676 *
1677 *   http://www.apache.org/licenses/LICENSE-2.0
1678 *
1679 * Unless required by applicable law or agreed to in writing, software
1680 * distributed under the License is distributed on an "AS IS" BASIS,
1681 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1682 * See the License for the specific language governing permissions and
1683 * limitations under the License.
1684 */function zS(){return typeof ea().WorkerGlobalScope<"u"&&typeof ea().importScripts=="function"}async function q4(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function z4(){var n;return((n=navigator==null?void 0:navigator.serviceWorker)==null?void 0:n.controller)||null}function J4(){return zS()?self:null}/**
1685 * @license
1686 * Copyright 2019 Google LLC
1687 *
1688 * Licensed under the Apache License, Version 2.0 (the "License");
1689 * you may not use this file except in compliance with the License.
1690 * You may obtain a copy of the License at
1691 *
1692 *   http://www.apache.org/licenses/LICENSE-2.0
1693 *
1694 * Unless required by applicable law or agreed to in writing, software
1695 * distributed under the License is distributed on an "AS IS" BASIS,
1696 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1697 * See the License for the specific language governing permissions and
1698 * limitations under the License.
1699 */const JS="firebaseLocalStorageDb",$4=1,fg="firebaseLocalStorage",$S="fbase_key";class Hh{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function ep(n,e){return n.transaction([fg],e?"readwrite":"readonly").objectStore(fg)}function K4(){const n=indexedDB.deleteDatabase(JS);return new Hh(n).toPromise()}function KS(){const n=indexedDB.open(JS,$4);return new Promise((e,t)=>
1699{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const r=n.result;try{r.createObjectStore(fg,{keyPath:$S})}catch(s){t(s)}}),n.addEventListener("success",async()=>{const r=n.result;r.objectStoreNames.contains(fg)?e(r):(r.close(),await K4(),e(await KS()))})})}async function JE(n,e,t){const r=ep(n,!0).put({[$S]:e,value:t});return new Hh(r).toPromise()}async function Y4(n,e){const t=ep(n,!1).get(e),r=await new Hh(t).toPromise();return r===void 0?null:r.value}function $E(n,e){const t=ep(n,!0).delete(e);return new Hh(t).toPromise()}const Q4=800,W4=3;class YS{registerLifecycleListeners(){typeof window<"u"&&typeof window.addEventListener=="function"&&(window.addEventListener("pagehide",this.onPageHide),window.addEventListener("pageshow",this.onPageShow))}unregisterLifecycleListeners(){typeof window<"u"&&typeof window.removeEventListener=="function"&&(window.removeEventListener("pagehide",this.onPageHide),window.removeEventListener("pageshow",this.onPageShow))}constructor(){this.type="LOCAL",this.dbPromise=null,this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.isClosing=!1,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this.onPageHide=()=>{this.isClosing=!0,this.stopPolling(),this.dbPromise&&(this.dbPromise.then(e=>e.close()).catch(()=>{}),this.dbPromise=null)},this.onPageShow=()=>{this.isClosing&&(this.isClosing=!1,Object.keys(this.listeners).length>0&&this.startPolling())},this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){if(this.isClosing)throw new Error("Database is closing");return this.dbPromise?this.dbPromise:(this.dbPromise=KS(),this.dbPromise.catch(()=>{this.dbPromise=null}),this.dbPromise)}async _withRetries(e){let t=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(this.isClosing||t++>W4)throw r;this.dbPromise&&((await this.dbPromise).close(),this.dbPromise=null)}}async initializeServiceWorkerMessaging(){return zS()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Zg._getInstance(J4()),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var t,r;if(this.activeServiceWorker=await q4(),!this.activeServiceWorker)return;this.sender=new G4(this.activeServiceWorker);const e=await this.sender._send("ping",{},800);e&&(t=e[0])!=null&&t.fulfilled&&(r=e[0])!=null&&r.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||z4()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{return indexedDB?(await this._withRetries(async e=>{await JE(e,hg,"1"),await $E(e,hg)}),!0):!1}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(r=>JE(r,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(r=>Y4(r,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>$E(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){if(this.isClosing)return[];try{const e=await this._withRetries(s=>{const a=ep(s,!1).getAll();return new Hh(a).toPromise()});if(this.isClosing)return[];if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],r=new Set;if(e.length!==0)for(const{fbase_key:s,value:a}of e)r.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(a)&&(this.notifyListeners(s,a),t.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!r.has(s)&&(this.notifyListeners(s,null),t.push(s));return t}catch(e){return this.isClosing||xS(`Firebase Auth cross-tab polling failed with error: ${e}`),[]}}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),Q4)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.startPolling(),this.registerLifecycleListeners()),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
vendor: 4,356 bytes, lines 1699-1748
1699ject.keys(this.listeners).length===0&&(this.stopPolling(),this.unregisterLifecycleListeners())}}YS.type="LOCAL";const X4=YS;new Uh(3e4,6e4);/**
1700 * @license
1701 * Copyright 2021 Google LLC
1702 *
1703 * Licensed under the Apache License, Version 2.0 (the "License");
1704 * you may not use this file except in compliance with the License.
1705 * You may obtain a copy of the License at
1706 *
1707 *   http://www.apache.org/licenses/LICENSE-2.0
1708 *
1709 * Unless required by applicable law or agreed to in writing, software
1710 * distributed under the License is distributed on an "AS IS" BASIS,
1711 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1712 * See the License for the specific language governing permissions and
1713 * limitations under the License.
1714 */function QS(n,e){return e?La(e):(mt(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}/**
1715 * @license
1716 * Copyright 2019 Google LLC
1717 *
1718 * Licensed under the Apache License, Version 2.0 (the "License");
1719 * you may not use this file except in compliance with the License.
1720 * You may obtain a copy of the License at
1721 *
1722 *   http://www.apache.org/licenses/LICENSE-2.0
1723 *
1724 * Unless required by applicable law or agreed to in writing, software
1725 * distributed under the License is distributed on an "AS IS" BASIS,
1726 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1727 * See the License for the specific language governing permissions and
1728 * limitations under the License.
1729 */class bx extends Bx{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Tu(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Tu(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Tu(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={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 e&&(t.idToken=e),t}}function Z4(n){return FS(n.auth,new bx(n),n.bypassAuthState)}function ej(n){const{auth:e,user:t}=n;return mt(t,e,"internal-error"),I4(t,new bx(n),n.bypassAuthState)}async function tj(n){const{auth:e,user:t}=n;return mt(t,e,"internal-error"),A4(t,new bx(n),n.bypassAuthState)}/**
1730 * @license
1731 * Copyright 2020 Google LLC
1732 *
1733 * Licensed under the Apache License, Version 2.0 (the "License");
1734 * you may not use this file except in compliance with the License.
1735 * You may obtain a copy of the License at
1736 *
1737 *   http://www.apache.org/licenses/LICENSE-2.0
1738 *
1739 * Unless required by applicable law or agreed to in writing, software
1740 * distributed under the License is distributed on an "AS IS" BASIS,
1741 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1742 * See the License for the specific language governing permissions and
1743 * limitations under the License.
1744 */class WS{constructor(e,t,r,s,a=!1){this.auth=e,this.resolver=r,this.user=s,this.bypassAuthState=a,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:r,postBody:s,tenantId:a,error:c,type:u}=e;if(c){this.reject(c);return}const h={auth:this.auth,requestUri:t,sessionId:r,tenantId:a||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(u)(h))}catch(f){this.reject(f)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Z4;case"linkViaPopup":case"linkViaRedirect":return tj;case"reauthViaPopup":case"reauthViaRedirect":return ej;default:gi(this.auth,"internal-error")}}resolve(e){qa(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){qa(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/**
1745 * @license
1746 * Copyright 2020 Google LLC
1747 *
1748 * Licensed under the Apache License, Version 2.0 (the "License");
1749 * you may not use this file except in compliance with the License.
1750 * You may obtain a copy of the License at
1751 *
1752 *   http://www.apache.org/licenses/LICENSE-2.0
1753 *
1754 * Unless required by applicable law or agreed to in writing, software
1755 * distributed under the License is distributed on an "AS IS" BASIS,
1756 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1757 * See the License for the specific language governing permissions and
1758 * limitations under the License.
1759 */const nj=new Uh(2e3,1e4);async function rj(n,e,t){if(Ts(n.app))return Promise.reject(Di(n,"operation-not-supported-in-this-environment"));const r=Ya(n);jL(n,e,xx);const s=QS(r,t);return new ec(r,"signInViaPopup",e,s).executeNotNull()}class ec extends WS{constructor(e,t,r,s,a){super(e,t,s,a),this.provider=r,this.authWindow=null,this.pollId=null,ec.currentPopupAction&&ec.currentPopupAction.cancel(),ec.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return mt(e,this.auth,"internal-error"),e}async onExecution(){qa(this.filter.length===1,"Popup operations only handle one event");const e=Cx();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(Di(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)==null?void 0:e.associatedEvent)||null}cancel(){this.reject(Di(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,ec.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,r;if((r=(t=this.authWindow)==null?void 0:t.window)!=null&&r.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Di(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,nj.get())};e()}}ec.currentPopupAction=null;/**
1760 * @license
1761 * Copyright 2020 Google LLC
1762 *
1763 * Licensed under the Apache License, Version 2.0 (the "License");
1764 * you may not use this file except in compliance with the License.
1765 * You may obtain a copy of the License at
1766 *
1767 *   http://www.apache.org/licenses/LICENSE-2.0
1768 *
1769 * Unless required by applicable law or agreed to in writing, software
1770 * distributed under the License is distributed on an "AS IS" BASIS,
1771 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1772 * See the License for the specific language governing permissions and
1773 * limitations under the License.
1774 */const sj="pendingRedirect",zm=new Map;class ij extends WS{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let e=zm.get(this.auth._key());if(!e){try{const r=await aj(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(t){e=()=>Promise.reject(t)}zm.set(this.auth._key(),e)}return this.bypassAuthState||zm.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function aj(n,e){const t=cj(e),r=lj(n);if(!await r._isAvailable())return!1;const s=await r._get(t)==="true";return await r._remove(t),s}function oj(n,e){zm.set(n._key(),e)}function lj(n){return La(n._redirectPersistence)}function cj(n){return qm(sj,n.config.apiKey,n.name)}async function uj(n,e,t=!1){if(Ts(n.app))return Promise.reject(Fa(n));const r=Ya(n),s=QS(r,e),c=await new ij(r,s,t).execute();return c&&!t&&(delete c.user._redirectEventId,await r._persistUserIfCurrent(c.user),await r._setRedirectUser(null,e)),c}/**
1775 * @license
1776 * Copyright 2020 Google LLC
1777 *
1778 * Licensed under the Apache License, Version 2.0 (the "License");
1779 * you may not use this file except in compliance with the License.
1780 * You may obtain a copy of the License at
1781 *
1782 *   http://www.apache.org/licenses/LICENSE-2.0
1783 *
1784 * Unless required by applicable law or agreed to in writing, softw
1784are
1785 * distributed under the License is distributed on an "AS IS" BASIS,
1786 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1787 * See the License for the specific language governing permissions and
1788 * limitations under the License.
1789 */const dj=600*1e3;class hj{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!fj(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var r;if(e.error&&!XS(e)){const s=((r=e.error.code)==null?void 0:r.split("auth/")[1])||"internal-error";t.onError(Di(this.auth,s))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const r=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=dj&&this.cachedEventUids.clear(),this.cachedEventUids.has(KE(e))}saveEventToCache(e){this.cachedEventUids.add(KE(e)),this.lastProcessedEventTime=Date.now()}}function KE(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function XS({type:n,error:e}){return n==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function fj(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return XS(n);default:return!1}}/**
1790 * @license
1791 * Copyright 2020 Google LLC
1792 *
1793 * Licensed under the Apache License, Version 2.0 (the "License");
1794 * you may not use this file except in compliance with the License.
1795 * You may obtain a copy of the License at
1796 *
1797 *   http://www.apache.org/licenses/LICENSE-2.0
1798 *
1799 * Unless required by applicable law or agreed to in writing, software
1800 * distributed under the License is distributed on an "AS IS" BASIS,
1801 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1802 * See the License for the specific language governing permissions and
1803 * limitations under the License.
1804 */async function mj(n,e={}){return oa(n,"GET","/v1/projects",e)}/**
1805 * @license
1806 * Copyright 2020 Google LLC
1807 *
1808 * Licensed under the Apache License, Version 2.0 (the "License");
1809 * you may not use this file except in compliance with the License.
1810 * You may obtain a copy of the License at
1811 *
1812 *   http://www.apache.org/licenses/LICENSE-2.0
1813 *
1814 * Unless required by applicable law or agreed to in writing, software
1815 * distributed under the License is distributed on an "AS IS" BASIS,
1816 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1817 * See the License for the specific language governing permissions and
1818 * limitations under the License.
1819 */const gj=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,pj=/^https?/;async function Bj(n){if(n.config.emulator)return;const{authorizedDomains:e}=await mj(n);for(const t of e)try{if(yj(t))return}catch{}gi(n,"unauthorized-domain")}function yj(n){const e=vy(),{protocol:t,hostname:r}=new URL(e);if(n.startsWith("chrome-extension://")){const c=new URL(n);return c.hostname===""&&r===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&c.hostname===r}if(!pj.test(t))return!1;if(gj.test(n))return r===n;const s=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}/**
1820 * @license
1821 * Copyright 2020 Google LLC.
1822 *
1823 * Licensed under the Apache License, Version 2.0 (the "License");
1824 * you may not use this file except in compliance with the License.
1825 * You may obtain a copy of the License at
1826 *
1827 *   http://www.apache.org/licenses/LICENSE-2.0
1828 *
1829 * Unless required by applicable law or agreed to in writing, softw
1829are
1830 * distributed under the License is distributed on an "AS IS" BASIS,
1831 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1832 * See the License for the specific language governing permissions and
1833 * limitations under the License.
1834 */const xj=new Uh(3e4,6e4);function YE(){const n=ea().___jsl;if(n!=null&&n.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function Cj(n){return new Promise((e,t)=>{var s,a,c;function r(){YE(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{YE(),t(Di(n,"network-request-failed"))},timeout:xj.get()})}if((a=(s=ea().gapi)==null?void 0:s.iframes)!=null&&a.Iframe)e(gapi.iframes.getContext());else if((c=ea().gapi)!=null&&c.load)r();else{const u=h4("iframefcb");return ea()[u]=()=>{gapi.load?r():t(Di(n,"network-request-failed"))},PS(`${d4()}?onload=${u}`).catch(h=>t(h))}}).catch(e=>{throw Jm=null,e})}let Jm=null;function bj(n){return Jm=Jm||Cj(n),Jm}/**
1835 * @license
1836 * Copyright 2020 Google LLC.
1837 *
1838 * Licensed under the Apache License, Version 2.0 (the "License");
1839 * you may not use this file except in compliance with the License.
1840 * You may obtain a copy of the License at
1841 *
1842 *   http://www.apache.org/licenses/LICENSE-2.0
1843 *
1844 * Unless required by applicable law or agreed to in writing, software
1845 * distributed under the License is distributed on an "AS IS" BASIS,
1846 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1847 * See the License for the specific language governing permissions and
1848 * limitations under the License.
1849 */const vj=new Uh(5e3,15e3),wj="__/auth/iframe",Ej="emulator/auth/iframe",_j={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Tj=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function kj(n){const e=n.config;mt(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?mx(e,Ej):`https://${n.config.authDomain}/${wj}`,r={apiKey:e.apiKey,appName:n.name,v:wc},s=Tj.get(n.config.apiHost);s&&(r.eid=s);const a=n._getFrameworks();return a.length&&(r.fw=a.join(",")),`${t}?${Fh(r).slice(1)}`}async function Nj(n){const e=await bj(n),t=ea().gapi;return mt(t,n,"internal-error"),e.open({where:document.body,url:kj(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:_j,dontclear:!0},r=>new Promise(async(s,a)=>{await r.restyle({setHideOnLeave:!1});const c=Di(n,"network-request-failed"),u=ea().setTimeout(()=>{a(c)},vj.get());function h(){ea().clearTimeout(u),s(r)}r.ping(h).then(h,()=>{a(c)})}))}/**
1850 * @license
1851 * Copyright 2020 Google LLC.
1852 *
1853 * Licensed under the Apache License, Version 2.0 (the "License");
1854 * you may not use this file except in compliance with the License.
1855 * You may obtain a copy of the License at
1856 *
1857 *   http://www.apache.org/licenses/LICENSE-2.0
1858 *
1859 * Unless required by applicable law or agreed to in writing, software
1860 * distributed under the License is distributed on an "AS IS" BASIS,
1861 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1862 * See the License for the specific language governing permissions and
1863 * limitations under the License.
1864 */const Sj={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},Dj=500,Aj=600,Ij="_blank",Rj="http://localhost";class QE{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function Pj(n,e,t,r=Dj,s=Aj){const a=Math.max((window.screen.availHeight-s)/2,0).toString(),c=Math.max((window.screen.availWidth-r)/2,0).toString();let u="";const h={...Sj,width:r.toString(),height:s.toString(),top:a,left:c},f=es().toLowerCase();t&&(u=kS(f)?Ij:t),_S(f)&&(e=e||Rj,h.scrollbars="yes");const p=Object.entries(h).reduce((b,[w,E])=>`${b}${w}=${E},`,"");if(n4(f)&&u!=="_self")return Mj(e||"",u),new QE(null);const y=window.open(e||"",u,p);mt(y,n,"popup-blocked");try{y.focus()}catch{}return new QE(y)}function Mj(n,e){const t=document.createElement("a");t.href=n,t.target=e;const r=document.createEvent("MouseEvent");
1864r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(r)}/**
1865 * @license
1866 * Copyright 2021 Google LLC
1867 *
1868 * Licensed under the Apache License, Version 2.0 (the "License");
1869 * you may not use this file except in compliance with the License.
1870 * You may obtain a copy of the License at
1871 *
1872 *   http://www.apache.org/licenses/LICENSE-2.0
1873 *
1874 * Unless required by applicable law or agreed to in writing, software
1875 * distributed under the License is distributed on an "AS IS" BASIS,
1876 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1877 * See the License for the specific language governing permissions and
1878 * limitations under the License.
1879 */const Lj="__/auth/handler",jj="emulator/auth/handler",Oj=encodeURIComponent("fac");async function WE(n,e,t,r,s,a){mt(n.config.authDomain,n,"auth-domain-config-required"),mt(n.config.apiKey,n,"invalid-api-key");const c={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:r,v:wc,eventId:s};if(e instanceof xx){e.setDefaultLanguage(n.languageCode),c.providerId=e.providerId||"",EM(e.getCustomParameters())||(c.customParameters=JSON.stringify(e.getCustomParameters()));for(const[p,y]of Object.entries({}))c[p]=y}if(e instanceof Gh){const p=e.getScopes().filter(y=>y!=="");p.length>0&&(c.scopes=p.join(","))}n.tenantId&&(c.tid=n.tenantId);const u=c;for(const p of Object.keys(u))u[p]===void 0&&delete u[p];const h=await n._getAppCheckToken(),f=h?`#${Oj}=${encodeURIComponent(h)}`:"";return`${Fj(n)}?${Fh(u).slice(1)}${f}`}function Fj({config:n}){return n.emulator?mx(n,jj):`https://${n.authDomain}/${Lj}`}/**
1880 * @license
1881 * Copyright 2020 Google LLC
1882 *
1883 * Licensed under the Apache License, Version 2.0 (the "License");
1884 * you may not use this file except in compliance with the License.
1885 * You may obtain a copy of the License at
1886 *
1887 *   http://www.apache.org/licenses/LICENSE-2.0
1888 *
1889 * Unless required by applicable law or agreed to in writing, software
1890 * distributed under the License is distributed on an "AS IS" BASIS,
1891 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1892 * See the License for the specific language governing permissions and
1893 * limitations under the License.
1894 */const GB="webStorageSupport";class Uj{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=qS,this._completeRedirectFn=uj,this._overrideRedirectResult=oj}async _openPopup(e,t,r,s){var c;qa((c=this.eventManagers[e._key()])==null?void 0:c.manager,"_initialize() not called before _openPopup()");const a=await WE(e,t,r,vy(),s);return Pj(e,a,Cx())}async _openRedirect(e,t,r,s){await this._originValidation(e);const a=await WE(e,t,r,vy(),s);return H4(a),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:s,promise:a}=this.eventManagers[t];return s?Promise.resolve(s):(qa(a,"If manager is not set, promise should be"),a)}const r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}async initAndGetManager(e){const t=await Nj(e),r=new hj(e);return t.register("authEvent",s=>(mt(s==null?void 0:s.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(GB,{type:GB},s=>{var c;const a=(c=s==null?void 0:s[0])==null?void 0:c[GB];a!==void 0&&t(!!a),gi(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=Bj(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return IS()||TS()||px()}}const Vj=Uj;var XE="@firebase/auth",ZE="1.13.5";/**
1895 * @license
1896 * Copyright 2020 Google LLC
1897 *
1898 * Licensed under the Apache License, Version 2.0 (the "License");
1899 * you may not use this file except in compliance with the License.
1900 * You may obtain a copy of the License at
1901 *
1902 *   http://www.apache.org/licenses/LICENSE-2.0
1903 *
1904 * Unless required by applicable law or agreed to in writing, softw
1904are
1905 * distributed under the License is distributed on an "AS IS" BASIS,
1906 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1907 * See the License for the specific language governing permissions and
1908 * limitations under the License.
1909 */class Gj{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)==null?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(r=>{e((r==null?void 0:r.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){mt(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/**
1910 * @license
1911 * Copyright 2020 Google LLC
1912 *
1913 * Licensed under the Apache License, Version 2.0 (the "License");
1914 * you may not use this file except in compliance with the License.
1915 * You may obtain a copy of the License at
1916 *
1917 *   http://www.apache.org/licenses/LICENSE-2.0
1918 *
1919 * Unless required by applicable law or agreed to in writing, software
1920 * distributed under the License is distributed on an "AS IS" BASIS,
1921 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1922 * See the License for the specific language governing permissions and
1923 * limitations under the License.
1924 */function Hj(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function qj(n){mc(new Zo("auth",(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),a=e.getProvider("app-check-internal"),{apiKey:c,authDomain:u}=r.options;mt(c&&!c.includes(":"),"invalid-api-key",{appName:r.name});const h={apiKey:c,authDomain:u,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:RS(n)},f=new l4(r,s,a,h);return B4(f,t),f},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),mc(new Zo("auth-internal",e=>{const t=Ya(e.getProvider("auth").getImmediate());return(r=>new Gj(r))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),Zi(XE,ZE,Hj(n)),Zi(XE,ZE,"esm2020")}/**
1925 * @license
1926 * Copyright 2021 Google LLC
1927 *
1928 * Licensed under the Apache License, Version 2.0 (the "License");
1929 * you may not use this file except in compliance with the License.
1930 * You may obtain a copy of the License at
1931 *
1932 *   http://www.apache.org/licenses/LICENSE-2.0
1933 *
1934 * Unless required by applicable law or agreed to in writing, software
1935 * distributed under the License is distributed on an "AS IS" BASIS,
1936 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1937 * See the License for the specific language governing permissions and
1938 * limitations under the License.
1939 */const zj=300,Jj=uS("authIdTokenMaxAge")||zj;let e_=null;const $j=n=>async e=>{const t=e&&await e.getIdTokenResult(),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>Jj)return;const s=t==null?void 0:t.token;e_!==s&&(e_=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function ZS(n=Wg()){const e=Qg(n,"auth");if(e.isInitialized())return e.getImmediate();const t=p4(n,{popupRedirectResolver:Vj,persistence:[X4,U4,qS]}),r=uS("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const a=new URL(r,location.origin);if(location.origin===a.origin){const c=$j(a.toString());L4(t,c,()=>c(t.currentUser)),M4(t,u=>c(u))}}const s=oS("auth");return s&&y4(t,`http://${s}`),t}function Kj(){var n;return((n=document.getElementsByTagName("head"))==null?void 0:n[0])??document}c4({loadJS(n){return new Promise((e,t)=>
1939{const r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=s=>{const a=Di("internal-error");a.customData=s,t(a)},r.type="text/javascript",r.charset="UTF-8",Kj().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="});qj("Browser");var Yj="firebase",Qj="12.18.0";/**
1940 * @license
1941 * Copyright 2020 Google LLC
1942 *
1943 * Licensed under the Apache License, Version 2.0 (the "License");
1944 * you may not use this file except in compliance with the License.
1945 * You may obtain a copy of the License at
1946 *
1947 *   http://www.apache.org/licenses/LICENSE-2.0
1948 *
1949 * Unless required by applicable law or agreed to in writing, software
1950 * distributed under the License is distributed on an "AS IS" BASIS,
1951 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1952 * See the License for the specific language governing permissions and
1953 * limitations under the License.
1954 */Zi(Yj,Qj,"app");var t_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
1955Copyright The Closure Library Authors.
1956SPDX-License-Identifier: Apache-2.0
1957*/var Ko,eD;(function(){var n;/** @license
1958
1959 Copyright The Closure Library Authors.
1960 SPDX-License-Identifier: Apache-2.0
1961*/function e(D,k){function _(){}_.prototype=k.prototype,D.F=k.prototype,D.prototype=new _,D.prototype.constructor=D,D.D=function(M,j,H){for(var L=Array(arguments.length-2),ee=2;ee<arguments.length;ee++)L[ee-2]=arguments[ee];return k.prototype[j].apply(M,L)}}function t(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}e(r,t),r.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(D,k,_){_||(_=0);const M=Array(16);if(typeof k=="string")for(var j=0;j<16;++j)M[j]=k.charCodeAt(_++)|k.charCodeAt(_++)<<8|k.charCodeAt(_++)<<16|k.charCodeAt(_++)<<24;else for(j=0;j<16;++j)M[j]=k[_++]|k[_++]<<8|k[_++]<<16|k[_++]<<24;k=D.g[0],_=D.g[1],j=D.g[2];let H=D.g[3],L;L=k+(H^_&(j^H))+M[0]+3614090360&4294967295,k=_+(L<<7&4294967295|L>>>25),L=H+(j^k&(_^j))+M[1]+3905402710&4294967295,H=k+(L<<12&4294967295|L>>>20),L=j+(_^H&(k^_))+M[2]+606105819&4294967295,j=H+(L<<17&4294967295|L>>>15),L=_+(k^j&(H^k))+M[3]+3250441966&4294967295,_=j+(L<<22&4294967295|L>>>10),L=k+(H^_&(j^H))+M[4]+4118548399&4294967295,k=_+(L<<7&4294967295|L>>>25),L=H+(j^k&(_^j))+M[5]+1200080426&4294967295,H=k+(L<<12&4294967295|L>>>20),L=j+(_^H&(k^_))+M[6]+2821735955&4294967295,j=H+(L<<17&4294967295|L>>>15),L=_+(k^j&(H^k))+M[7]+4249261313&4294967295,_=j+(L<<22&4294967295|L>>>10),L=k+(H^_&(j^H))+M[8]+1770035416&4294967295,k=_+(L<<7&4294967295|L>>>25),L=H+(j^k&(_^j))+M[9]+2336552879&4294967295,H=k+(L<<12&4294967295|L>>>20),L=j+(_^H&(k^_))+M[10]+4294925233&4294967295,j=H+(L<<17&4294967295|L>>>15),L=_+(k^j&(H^k))+M[11]+2304563134&4294967295,_=j+(L<<22&4294967295|L>>>10),L=k+(H^_&(j^H))+M[12]+1804603682&4294967295,k=_+(L<<7&4294967295|L>>>25),L=H+(j^k&(_^j))+M[13]+4254626195&4294967295,H=k+(L<<12&4294967295|L>>>20),L=j+(_^H&(k^_))+M[14]+2792965006&4294967295,j=H+(L<<17&4294967295|L>>>15),L=_+(k^j&(H^k))+M[15]+1236535329&4294967295,_=j+(L<<22&4294967295|L>>>10),L=k+(j^H&(_^j))+M[1]+4129170786&4294967295,k=_+(L<<5&4294967295|L>>>27),L=H+(_^j&(k^_))+M[6]+3225465664&4294967295,H=k+(L<<9&4294967295|L>>>23),L=j+(k^_&(H^k))+M[11]+643717713&4294967295,j=H+(L<<14&4294967295|L>>>18),L=_+(H^k&(j^H))+M[0]+3921069994&4294967295,_=j+(L<<20&4294967295|L>>>12),L=k+(j^H&(_^j))+M[5]+3593408605&4294967295,k=_+(L<<5&4294967295|L>>>27),L=H+(_^j&(k^_))+M[10]+38016083&4294967295,H=k+(L<<9&4294967295|L>>>23),L=j+(k^_&(H^k))+M[15]+3634488961&4294967295,j=H+(L<<14&4294967295|L>>>18),L=_+(H^k&(j^H))+M[4]+3889429448&4294967295,_=j+(L<<20&4294967295|L>>>12),L=k+(j^H&(_^j))+M[9]+568446438&4294967295,k=_+(L<<5&4294967295|L>>>27),L=H+(_^j&(k^_))+M[14]+3275163606&4294967295,H=k+(L<<9&4294967295|L>>>23),L=j+(k^_&(H^k))+M[3]+4107603335&4294967295,j=H+(L<<14&4294967295|L>>>
196118),L=_+(H^k&(j^H))+M[8]+1163531501&4294967295,_=j+(L<<20&4294967295|L>>>12),L=k+(j^H&(_^j))+M[13]+2850285829&4294967295,k=_+(L<<5&4294967295|L>>>27),L=H+(_^j&(k^_))+M[2]+4243563512&4294967295,H=k+(L<<9&4294967295|L>>>23),L=j+(k^_&(H^k))+M[7]+1735328473&4294967295,j=H+(L<<14&4294967295|L>>>18),L=_+(H^k&(j^H))+M[12]+2368359562&4294967295,_=j+(L<<20&4294967295|L>>>12),L=k+(_^j^H)+M[5]+4294588738&4294967295,k=_+(L<<4&4294967295|L>>>28),L=H+(k^_^j)+M[8]+2272392833&4294967295,H=k+(L<<11&4294967295|L>>>21),L=j+(H^k^_)+M[11]+1839030562&4294967295,j=H+(L<<16&4294967295|L>>>16),L=_+(j^H^k)+M[14]+4259657740&4294967295,_=j+(L<<23&4294967295|L>>>9),L=k+(_^j^H)+M[1]+2763975236&4294967295,k=_+(L<<4&4294967295|L>>>28),L=H+(k^_^j)+M[4]+1272893353&4294967295,H=k+(L<<11&4294967295|L>>>21),L=j+(H^k^_)+M[7]+4139469664&4294967295,j=H+(L<<16&4294967295|L>>>16),L=_+(j^H^k)+M[10]+3200236656&4294967295,_=j+(L<<23&4294967295|L>>>9),L=k+(_^j^H)+M[13]+681279174&4294967295,k=_+(L<<4&4294967295|L>>>28),L=H+(k^_^j)+M[0]+3936430074&4294967295,H=k+(L<<11&4294967295|L>>>21),L=j+(H^k^_)+M[3]+3572445317&4294967295,j=H+(L<<16&4294967295|L>>>16),L=_+(j^H^k)+M[6]+76029189&4294967295,_=j+(L<<23&4294967295|L>>>9),L=k+(_^j^H)+M[9]+3654602809&4294967295,k=_+(L<<4&4294967295|L>>>28),L=H+(k^_^j)+M[12]+3873151461&4294967295,H=k+(L<<11&4294967295|L>>>21),L=j+(H^k^_)+M[15]+530742520&4294967295,j=H+(L<<16&4294967295|L>>>16),L=_+(j^H^k)+M[2]+3299628645&4294967295,_=j+(L<<23&4294967295|L>>>9),L=k+(j^(_|~H))+M[0]+4096336452&4294967295,k=_+(L<<6&4294967295|L>>>26),L=H+(_^(k|~j))+M[7]+1126891415&4294967295,H=k+(L<<10&4294967295|L>>>22),L=j+(k^(H|~_))+M[14]+2878612391&4294967295,j=H+(L<<15&4294967295|L>>>17),L=_+(H^(j|~k))+M[5]+4237533241&4294967295,_=j+(L<<21&4294967295|L>>>11),L=k+(j^(_|~H))+M[12]+1700485571&4294967295,k=_+(L<<6&4294967295|L>>>26),L=H+(_^(k|~j))+M[3]+2399980690&4294967295,H=k+(L<<10&4294967295|L>>>22),L=j+(k^(H|~_))+M[10]+4293915773&4294967295,j=H+(L<<15&4294967295|L>>>17),L=_+(H^(j|~k))+M[1]+2240044497&4294967295,_=j+(L<<21&4294967295|L>>>11),L=k+(j^(_|~H))+M[8]+1873313359&4294967295,k=_+(L<<6&4294967295|L>>>26),L=H+(_^(k|~j))+M[15]+4264355552&4294967295,H=k+(L<<10&4294967295|L>>>22),L=j+(k^(H|~_))+M[6]+2734768916&4294967295,j=H+(L<<15&4294967295|L>>>17),L=_+(H^(j|~k))+M[13]+1309151649&4294967295,_=j+(L<<21&4294967295|L>>>11),L=k+(j^(_|~H))+M[4]+4149444226&4294967295,k=_+(L<<6&4294967295|L>>>26),L=H+(_^(k|~j))+M[11]+3174756917&4294967295,H=k+(L<<10&4294967295|L>>>22),L=j+(k^(H|~_))+M[2]+718787259&4294967295,j=H+(L<<15&4294967295|L>>>17),L=_+(H^(j|~k))+M[9]+3951481745&4294967295,D.g[0]=D.g[0]+k&4294967295,D.g[1]=D.g[1]+(j+(L<<21&4294967295|L>>>11))&4294967295,D.g[2]=D.g[2]+j&4294967295,D.g[3]=D.g[3]+H&4294967295}r.prototype.v=function(D,k){k===void 0&&(k=D.length);const _=k-this.blockSize,M=this.C;let j=this.h,H=0;for(;H<k;){if(j==0)for(;H<=_;)s(this,D,H),H+=this.blockSize;
1961if(typeof D=="string"){for(;H<k;)if(M[j++]=D.charCodeAt(H++),j==this.blockSize){s(this,M),j=0;break}}else for(;H<k;)if(M[j++]=D[H++],j==this.blockSize){s(this,M),j=0;break}}this.h=j,this.o+=k},r.prototype.A=function(){var D=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);D[0]=128;for(var k=1;k<D.length-8;++k)D[k]=0;k=this.o*8;for(var _=D.length-8;_<D.length;++_)D[_]=k&255,k/=256;for(this.v(D),D=Array(16),k=0,_=0;_<4;++_)for(let M=0;M<32;M+=8)D[k++]=this.g[_]>>>M&255;return D};function a(D,k){var _=u;return Object.prototype.hasOwnProperty.call(_,D)?_[D]:_[D]=k(D)}function c(D,k){this.h=k;const _=[];let M=!0;for(let j=D.length-1;j>=0;j--){const H=D[j]|0;M&&H==k||(_[j]=H,M=!1)}this.g=_}var u={};function h(D){return-128<=D&&D<128?a(D,function(k){return new c([k|0],k<0?-1:0)}):new c([D|0],D<0?-1:0)}function f(D){if(isNaN(D)||!isFinite(D))return y;if(D<0)return S(f(-D));const k=[];let _=1;for(let M=0;D>=_;M++)k[M]=D/_|0,_*=4294967296;return new c(k,0)}function p(D,k){if(D.length==0)throw Error("number format error: empty string");if(k=k||10,k<2||36<k)throw Error("radix out of range: "+k);if(D.charAt(0)=="-")return S(p(D.substring(1),k));if(D.indexOf("-")>=0)throw Error('number format error: interior "-" character');const _=f(Math.pow(k,8));let M=y;for(let H=0;H<D.length;H+=8){var j=Math.min(8,D.length-H);const L=parseInt(D.substring(H,H+j),k);j<8?(j=f(Math.pow(k,j)),M=M.j(j).add(f(L))):(M=M.j(_),M=M.add(f(L)))}return M}var y=h(0),b=h(1),w=h(16777216);n=c.prototype,n.m=function(){if(N(this))return-S(this).m();let D=0,k=1;for(let _=0;_<this.g.length;_++){const M=this.i(_);D+=(M>=0?M:4294967296+M)*k,k*=4294967296}return D},n.toString=function(D){if(D=D||10,D<2||36<D)throw Error("radix out of range: "+D);if(E(this))return"0";if(N(this))return"-"+S(this).toString(D);const k=f(Math.pow(D,6));var _=this;let M="";for(;;){const j=J(_,k).g;_=I(_,j.j(k));let H=((_.g.length>0?_.g[0]:_.h)>>>0).toString(D);if(_=j,E(_))return H+M;for(;H.length<6;)H="0"+H;M=H+M}},n.i=function(D){return D<0?0:D<this.g.length?this.g[D]:this.h};function E(D){if(D.h!=0)return!1;for(let k=0;k<D.g.length;k++)if(D.g[k]!=0)return!1;return!0}function N(D){return D.h==-1}n.l=function(D){return D=I(this,D),N(D)?-1:E(D)?0:1};function S(D){const k=D.g.length,_=[];for(let M=0;M<k;M++)_[M]=~D.g[M];return new c(_,~D.h).add(b)}n.abs=function(){return N(this)?S(this):this},n.add=function(D){const k=Math.max(this.g.length,D.g.length),_=[];let M=0;for(let j=0;j<=k;j++){let H=M+(this.i(j)&65535)+(D.i(j)&65535),L=(H>>>16)+(this.i(j)>>>16)+(D.i(j)>>>16);M=L>>>16,H&=65535,L&=65535,_[j]=L<<16|H}return new c(_,_[_.length-1]&-2147483648?-1:0)};function I(D,k){return D.add(S(k))}n.j=function(D){if(E(this)||E(D))return y;if(N(this))return N(D)?S(this).j(S(D)):S(S(this).j(D));if(N(D))return S(this.j(S(D)));if(this.l(w)<0&&D.l(w)<0)return f(this.m()*D.m());const k=this.g.length+D.g.length,_=[];for(var M=0;M<2*k;M++)_[M]=0;for(M=0;M<this.g.length;M++)for(let j=0;j<D.g.length;j++){const H=this.i(M)>>>16,L=this.i(M)&65535,ee=D.i(j)>>>16,ne=D.i(j)&65535;_[2*M+2*j]+=L*ne,O(_,2*M+2*j),_[2*M+2*j+1]+=H*ne,O(_,2*M+2*j+1),_[2*M+2*j+1]+=L*ee,O(_,2*M+2*j+1),_[2*M+2*j+2]+=H*ee,O(_,2*M+2*j+2)}for(D=0;D<k;D++)_[D]=_[2*D+1]<<16|_[2*D];for(D=k;D<2*k;D++)_[D]=0;return new c(_,0)};function O(D,k){for(;(D[k]&65535)!=D[k];)D[k+1]+=D[k]>>>16,D[k]&=65535,k++}function F(D,k){this.g=D,this.h=k}function J(D,k){if(E(k))throw Error("division by zero");if(E(D))return new F(y,y);if(N(D))return k=J(S(D),k),new F(S(k.g),S(k.h));if(N(k))return k=J(D,S(k)),new F(S(k.g),k.h);if(D.g.length>30){if(N(D)||N(k))throw Error("slowDivide_ only works with positive integers.");for(var _=b,M=k;M.l(D)<=0;)_=z(_),M=z(M);var j=U(_,1),H=U(M,1);for(M=U(M,2),_=U(_,2);!E(M);){var L=H.add(M);L.l(D)<=0&&(j=j.add(_),H=L),M=U(M,1),_=U(_,1)}return k=I(D,j.j(k)),new F(j,k)}for(j=y;D.l(k)>=0;){for(_=Math.max(1,Math.floor(D.m()/k.m())),M=Math.ceil(Math.log(_)/Math.LN2),M=M<=48?1:Math.pow(2,M-48),H=f(_),L=H.j(k);N(L)||L.l(D)>0;)_-=M,H=f(_),L=H.j(k);E(H)&&(H=b),j=j.add(H),D=I(D,L)}return new F(j,D)}n.B=function(D){return J(this,D).h},n.and=function(D){const k=Math.max(this.g.length,D.g.length),_=[];for(let M=0;M<k;M++)_[M]=this.i(M)&D.i(M);return new c(_,this.h&D.h)},n.or=function(D){const k=Math.max(this.g.length,D.g.length),_=[];for(let M=0;M<k;M++)_[M]=this.i(M)|D.i(M);return new c(_,this.h|D.h)},n.xor=function(D){const k=Math.max(this.g.length,D.g.length),_=[];for(let M=0;M<k;M++)_[M]=this.i(M)^D.i(M);return new c(_,this.h^D.h)};function z(D){const k=D.g.length+1,_=[];for(let M=0;M<k;M++)_[M]=D.i(M)<<1|D.i(M-1)>>>31;return new c(_,D.h)}function U(D,k){const _=k>>5;k%=32;const M=D.g.length-_,j=[];for(let H=0;H<M;H++)j[H]=k>0?D.i(H+_)>>>k|D.i(H+_+1)<<32-k:D.i(H+_);return new c(j,D.h)}r.prototype.digest=r.prototype.A,r.prototype.reset=r.prototype.u,r.prototype.update=r.prototype.v,eD=r,c.prototype.add=c.prototype.add,c.prototype.multiply=c.prototype.j,c.prototype.modulo=c.prototype.B,c.prototype.compare=c.prototype.l,c.prototype.toNumber=c.prototype.m,c.prototype.toString=c.prototype.toString,c.prototype.getBits=c.prototype.i,c.fromNumber=f,c.fromString=p,Ko=c}).apply(typeof t_<"u"?t_:typeof self<"u"?self:typeof window<"u"?window:{});
1961var xm=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
1962Copyright The Closure Library Authors.
1963SPDX-License-Identifier: Apache-2.0
1964*/var tD,Qd,nD,$m,Ey,rD,sD,iD;(function(){var n,e=Object.defineProperty;function t(x){x=[typeof globalThis=="object"&&globalThis,x,typeof window=="object"&&window,typeof self=="object"&&self,typeof xm=="object"&&xm];for(var T=0;T<x.length;++T){var P=x[T];if(P&&P.Math==Math)return P}throw Error("Cannot find global object")}var r=t(this);function s(x,T){if(T)e:{var P=r;x=x.split(".");for(var q=0;q<x.length-1;q++){var le=x[q];if(!(le in P))break e;P=P[le]}x=x[x.length-1],q=P[x],T=T(q),T!=q&&T!=null&&e(P,x,{configurable:!0,writable:!0,value:T})}}s("Symbol.dispose",function(x){return x||Symbol("Symbol.dispose")}),s("Array.prototype.values",function(x){return x||function(){return this[Symbol.iterator]()}}),s("Object.entries",function(x){return x||function(T){var P=[],q;for(q in T)Object.prototype.hasOwnProperty.call(T,q)&&P.push([q,T[q]]);return P}});/** @license
1965
1966 Copyright The Closure Library Authors.
1967 SPDX-License-Identifier: Apache-2.0
1968*/var a=a||{},c=this||self;function u(x){var T=typeof x;return T=="object"&&x!=null||T=="function"}function h(x,T,P){return x.call.apply(x.bind,arguments)}function f(x,T,P){return f=h,f.apply(null,arguments)}function p(x,T){var P=Array.prototype.slice.call(arguments,1);return function(){var q=P.slice();return q.push.apply(q,arguments),x.apply(this,q)}}function y(x,T){function P(){}P.prototype=T.prototype,x.Z=T.prototype,x.prototype=new P,x.prototype.constructor=x,x.Ob=function(q,le,me){for(var Me=Array(arguments.length-2),wt=2;wt<arguments.length;wt++)Me[wt-2]=arguments[wt];return T.prototype[le].apply(q,Me)}}var b=typeof AsyncContext<"u"&&typeof AsyncContext.Snapshot=="function"?x=>x&&AsyncContext.Snapshot.wrap(x):x=>x;function w(x){const T=x.length;if(T>0){const P=Array(T);for(let q=0;q<T;q++)P[q]=x[q];return P}return[]}function E(x,T){for(let q=1;q<arguments.length;q++){const le=arguments[q];var P=typeof le;if(P=P!="object"?P:le?Array.isArray(le)?"array":P:"null",P=="array"||P=="object"&&typeof le.length=="number"){P=x.length||0;const me=le.length||0;x.length=P+me;for(let Me=0;Me<me;Me++)x[P+Me]=le[Me]}else x.push(le)}}class N{constructor(T,P){this.i=T,this.j=P,this.h=0,this.g=null}get(){let T;return this.h>0?(this.h--,T=this.g,this.g=T.next,T.next=null):T=this.i(),T}}function S(x){c.setTimeout(()=>{throw x},0)}function I(){var x=D;let T=null;return x.g&&(T=x.g,x.g=x.g.next,x.g||(x.h=null),T.next=null),T}class O{constructor(){this.h=this.g=null}add(T,P){const q=F.get();q.set(T,P),this.h?this.h.next=q:this.g=q,this.h=q}}var F=new N(()=>new J,x=>x.reset());class J{constructor(){this.next=this.g=this.h=null}set(T,P){this.h=T,this.g=P,this.next=null}reset(){this.next=this.g=this.h=null}}let z,U=!1,D=new O,k=()=>{const x=Promise.resolve(void 0);z=()=>{x.then(_)}};function _(){for(var x;x=I();){try{x.h.call(x.g)}catch(P){S(P)}var T=F;T.j(x),T.h<100&&(T.h++,x.next=T.g,T.g=x)}U=!1}function M(){this.u=this.u,this.C=this.C}M.prototype.u=!1,M.prototype.dispose=function(){this.u||(this.u=!0,this.N())},M.prototype[Symbol.dispose]=function(){this.dispose()},M.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function j(x,T){this.type=x,this.g=this.target=T,this.defaultPrevented=!1}j.prototype.h=function(){this.defaultPrevented=!0};var H=(function(){if(!c.addEventListener||!Object.defineProperty)return!1;var x=!1,T=Object.defineProperty({},"passive",{get:function(){x=!0}});try{const P=()=>{};c.addEventListener("test",P,T),c.removeEventListener("test",P,T)}catch{}return x})();function L(x){return/^[\s\xa0]*$/.test(x)}function ee(x,T){j.call(this,x?x.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,x&&this.init(x,T)}y(ee,j),ee.prototype.init=function(x,T){const P=this.type=x.type,q=x.changedTouches&&x.changedTouches.length?x.changedTouches[0]:null;this.target=x.target||x.srcElement,this.g=T,T=x.relatedTarget,T||(P=="mouseover"?T=x.fromElement:P=="mouseout"&&(T=x.toElement)),this.relatedTarget=T,q?(this.clientX=q.clientX!==void 0?q.clientX:q.pageX,this.clientY=q.clientY!==void 0?q.clientY:q.pageY,this.screenX=q.screenX||0,this.screenY=q.screenY||0):(this.clientX=x.clientX!==void 0?x.clientX:x.pageX,this.clientY=x.clientY!==void 0?x.clientY:x.pageY,this.screenX=x.screenX||0,this.screenY=x.screenY||0),this.button=x.button,this.key=x.key||"",this.ctrlKey=x.ctrlKey,this.altKey=x.altKey,this.shiftKey=x.shiftKey,this.metaKey=x.metaKey,this.pointerId=x.pointerId||0,this.pointerType=x.pointerType,this.state=x.state,this.i=x,x.defaultPrevented&&ee.Z.h.call(this)},ee.prototype.h=function(){ee.Z.h.call(this);const x=this.i;x.preventDefault?x.preventDefault():x.returnValue=!1};var ne="closure_listenable_"+(Math.random()*1e6|0),G=0;function W(x,T,P,q,le){this.listener=x,this.proxy=null,this.src=T,this.type=P,this.capture=!!q,this.ha=le,this.key=++G,this.da=this.fa=!1}function X(x){x.da=!0,x.listener=null,x.proxy=null,x.src=null,x.ha=null}
1968function ae(x,T,P){for(const q in x)T.call(P,x[q],q,x)}function Te(x,T){for(const P in x)T.call(void 0,x[P],P,x)}function K(x){const T={};for(const P in x)T[P]=x[P];return T}const fe="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function Se(x,T){let P,q;for(let le=1;le<arguments.length;le++){q=arguments[le];for(P in q)x[P]=q[P];for(let me=0;me<fe.length;me++)P=fe[me],Object.prototype.hasOwnProperty.call(q,P)&&(x[P]=q[P])}}function Ae(x){this.src=x,this.g={},this.h=0}Ae.prototype.add=function(x,T,P,q,le){const me=x.toString();x=this.g[me],x||(x=this.g[me]=[],this.h++);const Me=lt(x,T,q,le);return Me>-1?(T=x[Me],P||(T.fa=!1)):(T=new W(T,this.src,me,!!q,le),T.fa=P,x.push(T)),T};function ze(x,T){const P=T.type;if(P in x.g){var q=x.g[P],le=Array.prototype.indexOf.call(q,T,void 0),me;(me=le>=0)&&Array.prototype.splice.call(q,le,1),me&&(X(T),x.g[P].length==0&&(delete x.g[P],x.h--))}}function lt(x,T,P,q){for(let le=0;le<x.length;++le){const me=x[le];if(!me.da&&me.listener==T&&me.capture==!!P&&me.ha==q)return le}return-1}var dt="closure_lm_"+(Math.random()*1e6|0),Wt={};function Ht(x,T,P,q,le){if(Array.isArray(T)){for(let me=0;me<T.length;me++)Ht(x,T[me],P,q,le);return null}return P=Rs(P),x&&x[ne]?x.J(T,P,u(q)?!!q.capture:!1,le):Mr(x,T,P,!1,q,le)}function Mr(x,T,P,q,le,me){if(!T)throw Error("Invalid event type");const Me=u(le)?!!le.capture:!!le;let wt=Jr(x);if(wt||(x[dt]=wt=new Ae(x)),P=wt.add(T,P,q,Me,me),P.proxy)return P;if(q=br(),P.proxy=q,q.src=x,q.listener=P,x.addEventListener)H||(le=Me),le===void 0&&(le=!1),x.addEventListener(T.toString(),q,le);else if(x.attachEvent)x.attachEvent(Ye(T.toString()),q);else if(x.addListener&&x.removeListener)x.addListener(q);else throw Error("addEventListener and attachEvent are unavailable.");return P}function br(){function x(P){return T.call(x.src,x.listener,P)}const T=In;return x}function Lr(x,T,P,q,le){if(Array.isArray(T))for(var me=0;me<T.length;me++)Lr(x,T[me],P,q,le);else q=u(q)?!!q.capture:!!q,P=Rs(P),x&&x[ne]?(x=x.i,me=String(T).toString(),me in x.g&&(T=x.g[me],P=lt(T,P,q,le),P>-1&&(X(T[P]),Array.prototype.splice.call(T,P,1),T.length==0&&(delete x.g[me],x.h--)))):x&&(x=Jr(x))&&(T=x.g[T.toString()],x=-1,T&&(x=lt(T,P,q,le)),(P=x>-1?T[x]:null)&&gt(P))}function gt(x){if(typeof x!="number"&&x&&!x.da){var T=x.src;if(T&&T[ne])ze(T.i,x);else{var P=x.type,q=x.proxy;T.removeEventListener?T.removeEventListener(P,q,x.capture):T.detachEvent?T.detachEvent(Ye(P),q):T.addListener&&T.removeListener&&T.removeListener(q),(P=Jr(T))?(ze(P,x),P.h==0&&(P.src=null,T[dt]=null)):X(x)}}}function Ye(x){return x in Wt?Wt[x]:Wt[x]="on"+x}function In(x,T){if(x.da)x=!0;else{T=new ee(T,this);const P=x.listener,q=x.ha||x.src;x.fa&&gt(x),x=P.call(q,T)}return x}function Jr(x){return x=x[dt],x instanceof Ae?x:null}var ar="__closure_events_fn_"+(Math.random()*1e9>>>0);function Rs(x){return typeof x=="function"?x:(x[ar]||(x[ar]=function(T){return x.handleEvent(T)}),x[ar])}function Ct(){M.call(this),this.i=new Ae(this),this.M=this,this.G=null}y(Ct,M),Ct.prototype[ne]=!0,Ct.prototype.removeEventListener=function(x,T,P,q){Lr(this,x,T,P,q)};function St(x,T){var P,q=x.G;if(q)for(P=[];q;q=q.G)P.push(q);if(x=x.M,q=T.type||T,typeof T=="string")T=new j(T,x);else if(T instanceof j)T.target=T.target||x;else{var le=T;T=new j(q,x),Se(T,le)}le=!0;let me,Me;if(P)for(Me=P.length-1;Me>=0;Me--)me=T.g=P[Me],le=Un(me,q,!0,T)&&le;if(me=T.g=x,le=Un(me,q,!0,T)&&le,le=Un(me,q,!1,T)&&le,P)for(Me=0;Me<P.length;Me++)me=T.g=P[Me],le=Un(me,q,!1,T)&&le}Ct.prototype.N=function(){if(Ct.Z.N.call(this),this.i){var x=this.i;for(const T in x.g){const P=x.g[T];for(let q=0;q<P.length;q++)X(P[q]);delete x.g[T],x.h--}}this.G=null},Ct.prototype.J=function(x,T,P,q){return this.i.add(String(x),T,!1,P,q)},Ct.prototype.K=function(x,T,P,q){return this.i.add(String(x),T,!0,P,q)};function Un(x,T,P,q){if(T=x.i.g[String(T)],!T)return!0;T=T.concat();let le=!0;for(let me=0;me<T.length;++me){const Me=T[me];if(Me&&!Me.da&&Me.capture==P){const wt=Me.listener,rr=Me.ha||Me.src;Me.fa&&ze(x.i,Me),le=wt.call(rr,q)!==!1&&le}}return le&&!q.defaultPrevented}function Tr(x,T){if(typeof x!="function")if(x&&typeof x.handleEvent=="function")x=f(x.handleEvent,x);else throw Error("Invalid listener argument");return Number(T)>2147483647?-1:c.setTimeout(x,T||0)}function ns(x){x.g=Tr(()=>{x.g=null,x.i&&(x.i=!1,ns(x))},x.l);const T=x.h;x.h=null,x.m.apply(null,T)}class yn extends M{constructor(T,P){super(),this.m=T,this.l=P,this.h=null,this.i=!1,this.g=null}j(T){this.h=arguments,this.g?this.i=!0:ns(this)}N(){super.N(),this.g&&(c.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function kt(x){M.call(this),this.h=x,this.g={}}y(kt,M);var re=[];function Ne(x){ae(x.g,function(T,P){this.g.hasOwnProperty(P)&&gt(T)},x),x.g={}}kt.prototype.N=function(){kt.Z.N.call(this),Ne(this)},kt.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var De=c.JSON.stringify,qe=c.JSON.parse,je=class{stringify(x){return c.JSON.stringify(x,void 0)}parse(x){return c.JSON.parse(x,void 0)}};function st(){}function bt(){}var ht={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function Qe(){j.call(this,"d")}y(Qe,j);function it(){j.call(this,"c")}y(it,j);var jt={},kr=null;function Rn(){return kr=kr||new Ct}jt.Ia="serverreachability";function Vn(x){j.call(this,jt.Ia,x)}y(Vn,j);function xn(x){const T=Rn();St(T,new Vn(T))}jt.STAT_EVENT="statevent";function Gn(x,T){j.call(this,jt.STAT_EVENT,x),this.stat=T}y(Gn,j);function It(x){const T=Rn();St(T,new Gn(T,x))}jt.Ja="timingevent";function $n(x,T){j.call(this,jt.Ja,x),this.size=T}y($n,j);function Pn(x,T){if(typeof x!="function")throw Error("Fn must not be null and must be a function");return c.setTimeout(function(){x()},T)}function or(){this.g=!0}or.prototype.ua=function(){this.g=!1};function Li(x,T,P,q,le,me){x.info(function(){if(x.g)if(me){var Me="",wt=me.split("&");for(let nn=0;nn<wt.length;nn++){var rr=wt[nn].split("=");if(rr.length>1){const Mn=rr[0];rr=rr[1];const ri=Mn.split("_");Me=ri.length>=2&&ri[1]=="type"?Me+(Mn+"="+rr+"&"):Me+(Mn+"=redacted&")}}}else Me=null;else Me=me;return"XMLHTTP REQ ("+q+") [attempt "+le+"]: "+T+`
1969`+P+`
1970`+Me})}function _n(x,T,P,q,le,me,Me){x.info(function(){return"XMLHTTP RESP ("+q+") [ attempt "+le+"]: "+T+`
1971`+P+`
1972`+me+" "+Me})}function Kt(x,T,P,q){x.info(function(){return"XMLHTTP TEXT ("+T+"): "+un(x,P)+(q?" "+q:"")})}function $e(x,T){x.info(function(){return"TIMEOUT: "+T})}or.prototype.info=function(){};function un(x,T){if(!x.g)return T;if(!T)return null;try{const me=JSON.parse(T);if(me){for(x=0;x<me.length;x++)if(Array.isArray(me[x])){var P=me[x];if(!(P.length<2)){var q=P[1];if(Array.isArray(q)&&!(q.length<1)){var le=q[0];if(le!="noop"&&le!="stop"&&le!="close")for(let Me=1;Me<q.length;Me++)q[Me]=""}}}}return De(me)}catch{return T}}var Kn={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},rs={ib:"complete",Fb:"success",ERROR:"error",Ga:"abort",xb:"ready",yb:"readystatechange",TIMEOUT:"timeout",sb:"incrementaldata",wb:"progress",lb:"downloadprogress",Nb:"uploadprogress"},Hn;function Rt(){}y(Rt,st),Rt.prototype.g=function(){return new XMLHttpRequest},Hn=new Rt;function Tn(x){return encodeURIComponent(String(x))}function $r(x){var T=1;x=x.split(":");const P=[];for(;T>0&&x.length;)P.push(x.shift()),T--;return x.length&&P.push(x.join(":")),P}function vr(x,T,P,q){this.j=x,this.i=T,this.l=P,this.S=q||1,this.V=new kt(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 on={},Nt={};function Cn(x,T,P){x.M=1,x.A=la(Qn(T)),x.u=P,x.R=!0,jr(x,null)}function jr(x,T){x.F=Date.now(),Sr(x),x.B=Qn(x.A);var P=x.B,q=x.S;
1972Array.isArray(q)||(q=[String(q)]),no(P.i,"t",q),x.C=0,P=x.j.L,x.h=new Yn,x.g=df(x.j,P?T:null,!x.u),x.P>0&&(x.O=new yn(f(x.Y,x,x.g),x.P)),T=x.V,P=x.g,q=x.ba;var le="readystatechange";Array.isArray(le)||(le&&(re[0]=le.toString()),le=re);for(let me=0;me<le.length;me++){const Me=Ht(P,le[me],q||T.handleEvent,!1,T.h||T);if(!Me)break;T.g[Me.key]=Me}T=x.J?K(x.J):{},x.u?(x.v||(x.v="POST"),T["Content-Type"]="application/x-www-form-urlencoded",x.g.ea(x.B,x.v,x.u,T)):(x.v="GET",x.g.ea(x.B,x.v,null,T)),xn(),Li(x.i,x.v,x.B,x.l,x.S,x.u)}vr.prototype.ba=function(x){x=x.target;const T=this.O;T&&Ci(x)==3?T.j():this.Y(x)},vr.prototype.Y=function(x){try{if(x==this.g)e:{const wt=Ci(this.g),rr=this.g.ya(),nn=this.g.ca();if(!(wt<3)&&(wt!=3||this.g&&(this.h.h||this.g.la()||Or(this.g)))){this.K||wt!=4||rr==7||(rr==8||nn<=0?xn(3):xn(2)),ps(this);var T=this.g.ca();this.X=T;var P=bn(this);if(this.o=T==200,_n(this.i,this.v,this.B,this.l,this.S,wt,T),this.o){if(this.U&&!this.L){t:{if(this.g){var q,le=this.g;if((q=le.g?le.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!L(q)){var me=q;break t}}me=null}if(x=me)Kt(this.i,this.l,x,"Initial handshake response via X-HTTP-Initial-Response"),this.L=!0,Xs(this,x);else{this.o=!1,this.m=3,It(12),ss(this),Kr(this);break e}}if(this.R){x=!0;let Mn;for(;!this.K&&this.C<P.length;)if(Mn=Ps(this,P),Mn==Nt){wt==4&&(this.m=4,It(14),x=!1),Kt(this.i,this.l,null,"[Incomplete Response]");break}else if(Mn==on){this.m=4,It(15),Kt(this.i,this.l,P,"[Invalid Chunk]"),x=!1;break}else Kt(this.i,this.l,Mn,null),Xs(this,Mn);if(Nr(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),wt!=4||P.length!=0||this.h.h||(this.m=1,It(16),x=!1),this.o=this.o&&x,!x)Kt(this.i,this.l,P,"[Invalid Chunked Response]"),ss(this),Kr(this);else if(P.length>0&&!this.W){this.W=!0;var Me=this.j;Me.g==this&&Me.aa&&!Me.P&&(Me.j.info("Great, no buffering proxy detected. Bytes received: "+P.length),nd(Me),Me.P=!0,It(11))}}else Kt(this.i,this.l,P,null),Xs(this,P);wt==4&&ss(this),this.o&&!this.K&&(wt==4?of(this.j,this):(this.o=!1,Sr(this)))}else ha(this.g),T==400&&P.indexOf("Unknown SID")>0?(this.m=3,It(12)):(this.m=0,It(13)),ss(this),Kr(this)}}}catch{}finally{}};function bn(x){if(!Nr(x))return x.g.la();const T=Or(x.g);if(T==="")return"";let P="";const q=T.length,le=Ci(x.g)==4;if(!x.h.i){if(typeof TextDecoder>"u")return ss(x),Kr(x),"";x.h.i=new c.TextDecoder}for(let me=0;me<q;me++)x.h.h=!0,P+=x.h.i.decode(T[me],{stream:!(le&&me==q-1)});return T.length=0,x.h.g+=P,x.C=0,x.h.g}function Nr(x){return x.g?x.v=="GET"&&x.M!=2&&x.j.Aa:!1}function Ps(x,T){var P=x.C,q=T.indexOf(`
1973`,P);return q==-1?Nt:(P=Number(T.substring(P,q)),isNaN(P)?on:(q+=1,q+P>T.length?Nt:(T=T.slice(q,q+P),x.C=q+P,T)))}vr.prototype.cancel=function(){this.K=!0,ss(this)};function Sr(x){x.T=Date.now()+x.H,Ws(x,x.H)}function Ws(x,T){if(x.D!=null)throw Error("WatchDog timer not null");x.D=Pn(f(x.aa,x),T)}function ps(x){x.D&&(c.clearTimeout(x.D),x.D=null)}vr.prototype.aa=function(){this.D=null;const x=Date.now();x-this.T>=0?($e(this.i,this.B),this.M!=2&&(xn(),It(17)),ss(this),this.m=2,Kr(this)):Ws(this,this.T-x)};function Kr(x){x.j.I==0||x.K||of(x.j,x)}function ss(x){ps(x);var T=x.O;T&&typeof T.dispose=="function"&&T.dispose(),x.O=null,Ne(x.V),x.g&&(T=x.g,x.g=null,T.abort(),T.dispose())}function Xs(x,T){try{var P=x.j;if(P.I!=0&&(P.g==x||ei(P.h,x))){if(!x.L&&ei(P.h,x)&&P.I==3){try{var q=P.Ba.g.parse(T)}catch{q=null}if(Array.isArray(q)&&q.length==3){var le=q;if(le[0]==0){e:if(!P.v){if(P.g)if(P.g.F+3e3<x.F)Pc(P),oo(P);else break e;kl(P),It(18)}}else P.xa=le[1],0<P.xa-P.K&&le[2]<37500&&P.F&&P.A==0&&!P.C&&(P.C=Pn(f(P.Va,P),6e3));Zs(P.h)<=1&&P.ta&&(P.ta=void 0)}else Gi(P,11)}else if((x.L||P.g==x)&&Pc(P),!L(T))for(le=P.Ba.g.parse(T),T=0;T<le.length;T++){let nn=le[T];const Mn=nn[0];if(!(Mn<=P.K))if(P.K=Mn,nn=nn[1],P.I==2)if(nn[0]=="c"){P.M=nn[1],P.ba=nn[2];const ri=nn[3];ri!=null&&(P.ka=ri,P.j.info("VER="+P.ka));const Hi=nn[4];Hi!=null&&(P.za=Hi,P.j.info("SVER="+P.za));const bi=nn[5];bi!=null&&typeof bi=="number"&&bi>0&&(q=1.5*bi,P.O=q,P.j.info("backChannelRequestTimeoutMs_="+q)),q=P;const vi=x.g;if(vi){const Nl=vi.g?vi.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Nl){var me=q.h;me.g||Nl.indexOf("spdy")==-1&&Nl.indexOf("quic")==-1&&Nl.indexOf("h2")==-1||(me.j=me.l,me.g=new Set,me.h&&(yl(me,me.h),me.h=null))}if(q.G){const Mc=vi.g?vi.g.getResponseHeader("X-HTTP-Session-Id"):null;Mc&&(q.wa=Mc,Xt(q.J,q.G,Mc))}}P.I=3,P.l&&P.l.ra(),P.aa&&(P.T=Date.now()-x.F,P.j.info("Handshake RTT: "+P.T+"ms")),q=P;var Me=x;if(q.na=uf(q,q.L?q.ba:null,q.W),Me.L){xl(q.h,Me);var wt=Me,rr=q.O;rr&&(wt.H=rr),wt.D&&(ps(wt),Sr(wt)),q.g=Me}else sf(q);P.i.length>0&&Vi(P)}else nn[0]!="stop"&&nn[0]!="close"||Gi(P,7);else P.I==3&&(nn[0]=="stop"||nn[0]=="close"?nn[0]=="stop"?Gi(P,7):ed(P):nn[0]!="noop"&&P.l&&P.l.qa(nn),P.A=0)}}xn(4)}catch{}}var qn=class{constructor(x,T){this.g=x,this.map=T}};function pl(x){this.l=x||10,c.PerformanceNavigationTiming?(x=c.performance.getEntriesByType("navigation"),x=x.length>0&&(x[0].nextHopProtocol=="hq"||x[0].nextHopProtocol=="h2")):x=!!(c.chrome&&c.chrome.loadTimes&&c.chrome.loadTimes()&&c.chrome.loadTimes().wasFetchedViaSpdy),this.j=x?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function Bl(x){return x.h?!0:x.g?x.g.size>=x.j:!1}function Zs(x){return x.h?1:x.g?x.g.size:0}function ei(x,T){return x.h?x.h==T:x.g?x.g.has(T):!1}function yl(x,T){x.g?x.g.add(T):x.h=T}function xl(x,T){x.h&&x.h==T?x.h=null:x.g&&x.g.has(T)&&x.g.delete(T)}pl.prototype.cancel=function(){if(this.i=Cl(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const x of this.g.values())x.cancel();this.g.clear()}};function Cl(x){if(x.h!=null)return x.i.concat(x.h.G);
1973if(x.g!=null&&x.g.size!==0){let T=x.i;for(const P of x.g.values())T=T.concat(P.G);return T}return w(x.i)}var Nc=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function eo(x,T){if(x){x=x.split("&");for(let P=0;P<x.length;P++){const q=x[P].indexOf("=");let le,me=null;q>=0?(le=x[P].substring(0,q),me=x[P].substring(q+1)):le=x[P],T(le,me?decodeURIComponent(me.replace(/\+/g," ")):"")}}}function is(x){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let T;x instanceof is?(this.l=x.l,lr(this,x.j),this.o=x.o,this.g=x.g,ji(this,x.u),this.h=x.h,bl(this,Sc(x.i)),this.m=x.m):x&&(T=String(x).match(Nc))?(this.l=!1,lr(this,T[1]||"",!0),this.o=as(T[2]||""),this.g=as(T[3]||"",!0),ji(this,T[4]),this.h=as(T[5]||"",!0),bl(this,T[6]||"",!0),this.m=as(T[7]||"")):(this.l=!1,this.i=new vt(null,this.l))}is.prototype.toString=function(){const x=[];var T=this.j;T&&x.push(ca(T,to,!0),":");var P=this.g;return(P||T=="file")&&(x.push("//"),(T=this.o)&&x.push(ca(T,to,!0),"@"),x.push(Tn(P).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),P=this.u,P!=null&&x.push(":",String(P))),(P=this.h)&&(this.g&&P.charAt(0)!="/"&&x.push("/"),x.push(ca(P,P.charAt(0)=="/"?de:$,!0))),(P=this.i.toString())&&x.push("?",P),(P=this.m)&&x.push("#",ca(P,et)),x.join("")},is.prototype.resolve=function(x){const T=Qn(this);let P=!!x.j;P?lr(T,x.j):P=!!x.o,P?T.o=x.o:P=!!x.g,P?T.g=x.g:P=x.u!=null;var q=x.h;if(P)ji(T,x.u);else if(P=!!x.h){if(q.charAt(0)!="/")if(this.g&&!this.h)q="/"+q;else{var le=T.h.lastIndexOf("/");le!=-1&&(q=T.h.slice(0,le+1)+q)}if(le=q,le==".."||le==".")q="";else if(le.indexOf("./")!=-1||le.indexOf("/.")!=-1){q=le.lastIndexOf("/",0)==0,le=le.split("/");const me=[];for(let Me=0;Me<le.length;){const wt=le[Me++];wt=="."?q&&Me==le.length&&me.push(""):wt==".."?((me.length>1||me.length==1&&me[0]!="")&&me.pop(),q&&Me==le.length&&me.push("")):(me.push(wt),q=!0)}q=me.join("/")}else q=le}return P?T.h=q:P=x.i.toString()!=="",P?bl(T,Sc(x.i)):P=!!x.m,P&&(T.m=x.m),T};function Qn(x){return new is(x)}function lr(x,T,P){x.j=P?as(T,!0):T,x.j&&(x.j=x.j.replace(/:$/,""))}function ji(x,T){if(T){if(T=Number(T),isNaN(T)||T<0)throw Error("Bad port number "+T);x.u=T}else x.u=null}function bl(x,T,P){T instanceof vt?(x.i=T,Dc(x.i,x.l)):(P||(T=ca(T,Be)),x.i=new vt(T,x.l))}function Xt(x,T,P){x.i.set(T,P)}function la(x){return Xt(x,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),x}function as(x,T){return x?T?decodeURI(x.replace(/%25/g,"%2525")):decodeURIComponent(x):""}function ca(x,T,P){return typeof x=="string"?(x=encodeURI(x).replace(T,zn),P&&(x=x.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),x):null}function zn(x){return x=x.charCodeAt(0),"%"+(x>>4&15).toString(16)+(x&15).toString(16)}var to=/[#\/\?@]/g,$=/[#\?:]/g,de=/[#\?]/g,Be=/[#\?@]/g,et=/#/g;function vt(x,T){this.h=this.g=null,this.i=x||null,this.j=!!T}function Zt(x){x.g||(x.g=new Map,x.h=0,x.i&&eo(x.i,function(T,P){x.add(decodeURIComponent(T.replace(/\+/g," ")),P)}))}n=vt.prototype,n.add=function(x,T){Zt(this),this.i=null,x=ro(this,x);let P=this.g.get(x);return P||this.g.set(x,P=[]),P.push(T),this.h+=1,this};function en(x,T){Zt(x),T=ro(x,T),x.g.has(T)&&(x.i=null,x.h-=x.g.get(T).length,x.g.delete(T))}function ua(x,T){return Zt(x),T=ro(x,T),x.g.has(T)}n.forEach=function(x,T){Zt(this),this.g.forEach(function(P,q){P.forEach(function(le){x.call(T,le,q,this)},this)},this)};function tn(x,T){Zt(x);let P=[];if(typeof T=="string")ua(x,T)&&(P=P.concat(x.g.get(ro(x,T))));else for(x=Array.from(x.g.values()),T=0;T<x.length;T++)P=P.concat(x[T]);return P}n.set=function(x,T){return Zt(this),this.i=null,x=ro(this,x),ua(this,x)&&(this.h-=this.g.get(x).length),this.g.set(x,[T]),this.h+=1,this},n.get=function(x,T){return x?(x=tn(this,x),x.length>0?String(x[0]):T):T};function no(x,T,P){en(x,T),P.length>0&&(x.i=null,x.g.set(ro(x,T),w(P)),x.h+=P.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const x=[],T=Array.from(this.g.keys());for(let q=0;q<T.length;q++){var P=T[q];const le=Tn(P);P=tn(this,P);for(let me=0;me<P.length;me++){let Me=le;P[me]!==""&&(Me+="="+Tn(P[me])),x.push(Me)}}return this.i=x.join("&")};function Sc(x){const T=new vt;return T.i=x.i,x.g&&(T.g=new Map(x.g),T.h=x.h),T}function ro(x,T){return T=String(T),x.j&&(T=T.toLowerCase()),T}function Dc(x,T){T&&!x.j&&(Zt(x),x.i=null,x.g.forEach(function(P,q){const le=q.toLowerCase();q!=le&&(en(this,q),no(this,le,P))},x)),x.j=T}function yi(x,T){const P=new or;if(c.Image){const q=new Image;q.onload=p(ti,P,"TestLoadImage: loaded",!0,T,q),q.onerror=p(ti,P,"TestLoadImage: error",!1,T,q),q.onabort=p(ti,P,"TestLoadImage: abort",!1,T,q),q.ontimeout=p(ti,P,"TestLoadImage: timeout",!1,T,q),c.setTimeout(function(){q.ontimeout&&q.ontimeout()},1e4),q.src=x}else T(!1)}function Wu(x,T){const P=new or,q=new AbortController,le=setTimeout(()=>{q.abort(),ti(P,"TestPingServer: timeout",!1,T)},1e4);fetch(x,{signal:q.signal}).then(me=>{clearTimeout(le),me.ok?ti(P,"TestPingServer: ok",!0,T):ti(P,"TestPingServer: server error",!1,T)}).catch(()=>{clearTimeout(le),ti(P,"TestPingServer: error",!1,T)})}function ti(x,T,P,q,le){try{le&&(le.onload=null,le.onerror=null,le.onabort=null,le.ontimeout=null),q(P)}catch{}}function so(){this.g=new je}function Oi(x){this.i=x.Sb||null,this.h=x.ab||!1}y(Oi,st),Oi.prototype.g=function(){return new vl(this.i,this.h)};function vl(x,T){Ct.call(this),this.H=x,this.o=T,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(vl,Ct),n=vl.prototype,n.open=function(x,T){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=x,this.D=T,this.readyState=1,xi(this)},n.send=function(x){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");
vendor: 8,457 bytes, lines 1973-1976
1973if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;const T={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};x&&(T.body=x),(this.H||c).fetch(new Request(this.D,T)).then(this.Pa.bind(this),this.ga.bind(this))},n.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,io(this)),this.readyState=0},n.Pa=function(x){if(this.g&&(this.l=x,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=x.headers,this.readyState=2,xi(this)),this.g&&(this.readyState=3,xi(this),this.g)))if(this.responseType==="arraybuffer")x.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof c.ReadableStream<"u"&&"body"in x){if(this.j=x.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;Ac(this)}else x.text().then(this.Oa.bind(this),this.ga.bind(this))};function Ac(x){x.j.read().then(x.Ma.bind(x)).catch(x.ga.bind(x))}n.Ma=function(x){if(this.g){if(this.o&&x.value)this.response.push(x.value);else if(!this.o){var T=x.value?x.value:new Uint8Array(0);(T=this.B.decode(T,{stream:!x.done}))&&(this.response=this.responseText+=T)}x.done?io(this):xi(this),this.readyState==3&&Ac(this)}},n.Oa=function(x){this.g&&(this.response=this.responseText=x,io(this))},n.Na=function(x){this.g&&(this.response=x,io(this))},n.ga=function(){this.g&&io(this)};function io(x){x.readyState=4,x.l=null,x.j=null,x.B=null,xi(x)}n.setRequestHeader=function(x,T){this.A.append(x,T)},n.getResponseHeader=function(x){return this.h&&this.h.get(x.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const x=[],T=this.h.entries();for(var P=T.next();!P.done;)P=P.value,x.push(P[0]+": "+P[1]),P=T.next();return x.join(`\r
1974`)};function xi(x){x.onreadystatechange&&x.onreadystatechange.call(x)}Object.defineProperty(vl.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(x){this.m=x?"include":"same-origin"}});function ni(x){let T="";return ae(x,function(P,q){T+=q,T+=":",T+=P,T+=`\r
1975`}),T}function wl(x,T,P){e:{for(q in P){var q=!1;break e}q=!0}q||(P=ni(P),typeof x=="string"?P!=null&&Tn(P):Xt(x,T,P))}function dn(x){Ct.call(this),this.headers=new Map,this.L=x||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(dn,Ct);var Fi=/^https?$/i,Xu=["POST","PUT"];n=dn.prototype,n.Fa=function(x){this.H=x},n.ea=function(x,T,P,q){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+x);T=T?T.toUpperCase():"GET",this.D=x,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():Hn.g(),this.g.onreadystatechange=b(f(this.Ca,this));try{this.B=!0,this.g.open(T,String(x),!0),this.B=!1}catch(me){El(this,me);return}if(x=P||"",P=new Map(this.headers),q)if(Object.getPrototypeOf(q)===Object.prototype)for(var le in q)P.set(le,q[le]);else if(typeof q.keys=="function"&&typeof q.get=="function")for(const me of q.keys())P.set(me,q.get(me));else throw Error("Unknown input type for opt_headers: "+String(q));q=Array.from(P.keys()).find(me=>me.toLowerCase()=="content-type"),le=c.FormData&&x instanceof c.FormData,!(Array.prototype.indexOf.call(Xu,T,void 0)>=0)||q||le||P.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[me,Me]of P)this.g.setRequestHeader(me,Me);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(x),this.v=!1}catch(me){El(this,me)}};function El(x,T){x.h=!1,x.g&&(x.j=!0,x.g.abort(),x.j=!1),x.l=T,x.o=5,Zu(x),da(x)}function Zu(x){x.A||(x.A=!0,St(x,"complete"),St(x,"error"))}n.abort=function(x){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=x||7,St(this,"complete"),St(this,"abort"),da(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),da(this,!0)),dn.Z.N.call(this)},n.Ca=function(){this.u||(this.B||this.v||this.j?_l(this):this.Xa())},n.Xa=function(){_l(this)};function _l(x){if(x.h&&typeof a<"u"){if(x.v&&Ci(x)==4)setTimeout(x.Ca.bind(x),0);else if(St(x,"readystatechange"),Ci(x)==4){x.h=!1;try{const me=x.ca();e:switch(me){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var T=!0;break e;default:T=!1}var P;if(!(P=T)){var q;if(q=me===0){let Me=String(x.D).match(Nc)[1]||null;!Me&&c.self&&c.self.location&&(Me=c.self.location.protocol.slice(0,-1)),q=!Fi.test(Me?Me.toLowerCase():"")}P=q}if(P)St(x,"complete"),St(x,"success");else{x.o=6;try{var le=Ci(x)>2?x.g.statusText:""}catch{le=""}x.l=le+" ["+x.ca()+"]",Zu(x)}}finally{da(x)}}}}function da(x,T){if(x.g){x.m&&(clearTimeout(x.m),x.m=null);const P=x.g;x.g=null,T||St(x,"ready");try{P.onreadystatechange=null}catch{}}}n.isActive=function(){return!!this.g};function Ci(x){return x.g?x.g.readyState:0}n.ca=function(){try{return Ci(this)>2?this.g.status:-1}catch{return-1}},n.la=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.La=function(x){if(this.g){var T=this.g.responseText;return x&&T.indexOf(x)==0&&(T=T.substring(x.length)),qe(T)}};function Or(x){try{if(!x.g)return null;if("response"in x.g)return x.g.response;switch(x.F){case"":case"text":return x.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in x.g)return x.g.mozResponseArrayBuffer}return null}catch{return null}}function ha(x){const T={};x=(x.g&&Ci(x)>=2&&x.g.getAllResponseHeaders()||"").split(`\r
1976`);for(let q=0;q<x.length;q++){if(L(x[q]))continue;var P=$r(x[q]);const le=P[0];if(P=P[1],typeof P!="string")continue;P=P.trim();const me=T[le]||[];T[le]=me,me.push(P)}Te(T,function(q){return q.join(", ")})}n.ya=function(){return this.o},n.Ha=function(){return typeof this.l=="string"?this.l:String(this.l)};function Ui(x,T,P){return P&&P.internalChannelParams&&P.internalChannelParams[x]||T}function ao(x){this.za=0,this.i=[],this.j=new or,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=Ui("failFast",!1,x),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=Ui("baseRetryDelayMs",5e3,x),this.Za=Ui("retryDelaySeedMs",1e4,x),this.Ta=Ui("forwardChannelMaxRetries",2,x),this.va=Ui("forwardChannelRequestTimeoutMs",2e4,x),this.ma=x&&x.xmlHttpFactory||void 0,this.Ua=x&&x.Rb||void 0,this.Aa=x&&x.useFetchStreams||!1,this.O=void 0,this.L=x&&x.supportsCrossDomainXhr||!1,this.M="",this.h=new pl(x&&x.concurrentRequestLimit),this.Ba=new so,this.S=x&&x.fastHandshake||!1,this.R=x&&x.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=x&&x.Pb||!1,x&&x.ua&&this.j.ua(),x&&x.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&x&&x.detectBufferingProxy||!1,this.ia=void 0,x&&x.longPollingTimeout&&x.longPollingTimeout>0&&(this.ia=x.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}n=ao.prototype,n.ka=8,n.I=1,n.connect=function(x,T,P,q){It(0),this.W=x,this.H=T||{},P&&q!==void 0&&(this.H.OSID=P,this.H.OAID=q),this.F=this.X,this.J=uf(this,null,this.W),Vi(this)};function ed(x){if(Ic(x),x.I==3){var T=x.V++,P=Qn(x.J);if(Xt(P,"SID",x.M),Xt(P,"RID",T),Xt(P,"TYPE","terminate"),Tl(x,P),T=new vr(x,x.j,T),T.M=2,T.A=la(Qn(P)),P=!1,c.navigator&&c.navigator.sendBeacon)try{P=c.navigator.sendBeacon(T.A.toString(),"")}catch{}!P&&c.Image&&(new Image().src=T.A,P=!0),P||(T.g=df(T.j,null),T.g.ea(T.A)),T.F=Date.now(),Sr(T)}cf(x)}function oo(x){x.g&&(nd(x),x.g.cancel(),x.g=null)}function Ic(x){oo(x),x.v&&(c.clearTimeout(x.v),x.v=null),Pc(x),x.h.cancel(),x.m&&(typeof x.m=="number"&&c.clearTimeout(x.m),x.m=null)}function Vi(x){if(!Bl(x.h)&&!x.m){x.m=!0;var T=x.Ea;z||k(),U||(z(),U=!0),D.add(T,x),x.D=0}}function Rc(x,T){return Zs(x.h)>=x.h.j-(x.m?1:0)?!1:x.m?(x.i=T.G.concat(x.i),!0):x.I==1||x.I==2||x.D>=(x.Sa?0:x.Ta)?!1:(x.m=Pn(f(x.Ea,x,T),lf(x,x.D)),x.D++,!0)}n.Ea=function(x){if(this.m)if(this.m=null,this.I==1){if(!x){this.V=Math.floor(Math.random()*1e5),x=this.V++;const le=new vr(this,this.j,x);let me=this.o;if(this.U&&(me?(me=K(me),Se(me,this.U)):me=this.U),this.u!==null||this.R||(le.J=me,me=null),this.S)e:{for(var T=0,P=0;P<this.i.length;P++){t:{var q=this.i[P];
vendor: 5,458 bytes, line 1976
1976if("__data__"in q.map&&(q=q.map.__data__,typeof q=="string")){q=q.length;break t}q=void 0}if(q===void 0)break;if(T+=q,T>4096){T=P;break e}if(T===4096||P===this.i.length-1){T=P+1;break e}}T=1e3}else T=1e3;T=rf(this,le,T),P=Qn(this.J),Xt(P,"RID",x),Xt(P,"CVER",22),this.G&&Xt(P,"X-HTTP-Session-Id",this.G),Tl(this,P),me&&(this.R?T="headers="+Tn(ni(me))+"&"+T:this.u&&wl(P,this.u,me)),yl(this.h,le),this.Ra&&Xt(P,"TYPE","init"),this.S?(Xt(P,"$req",T),Xt(P,"SID","null"),le.U=!0,Cn(le,P,null)):Cn(le,P,T),this.I=2}}else this.I==3&&(x?td(this,x):this.i.length==0||Bl(this.h)||td(this))};function td(x,T){var P;T?P=T.l:P=x.V++;const q=Qn(x.J);Xt(q,"SID",x.M),Xt(q,"RID",P),Xt(q,"AID",x.K),Tl(x,q),x.u&&x.o&&wl(q,x.u,x.o),P=new vr(x,x.j,P,x.D+1),x.u===null&&(P.J=x.o),T&&(x.i=T.G.concat(x.i)),T=rf(x,P,1e3),P.H=Math.round(x.va*.5)+Math.round(x.va*.5*Math.random()),yl(x.h,P),Cn(P,q,T)}function Tl(x,T){x.H&&ae(x.H,function(P,q){Xt(T,q,P)}),x.l&&ae({},function(P,q){Xt(T,q,P)})}function rf(x,T,P){P=Math.min(x.i.length,P);const q=x.l?f(x.l.Ka,x.l,x):null;e:{var le=x.i;let wt=-1;for(;;){const rr=["count="+P];wt==-1?P>0?(wt=le[0].g,rr.push("ofs="+wt)):wt=0:rr.push("ofs="+wt);let nn=!0;for(let Mn=0;Mn<P;Mn++){var me=le[Mn].g;const ri=le[Mn].map;if(me-=wt,me<0)wt=Math.max(0,le[Mn].g-100),nn=!1;else try{me="req"+me+"_"||"";try{var Me=ri instanceof Map?ri:Object.entries(ri);for(const[Hi,bi]of Me){let vi=bi;u(bi)&&(vi=De(bi)),rr.push(me+Hi+"="+encodeURIComponent(vi))}}catch(Hi){throw rr.push(me+"type="+encodeURIComponent("_badmap")),Hi}}catch{q&&q(ri)}}if(nn){Me=rr.join("&");break e}}Me=void 0}return x=x.i.splice(0,P),T.G=x,Me}function sf(x){if(!x.g&&!x.v){x.Y=1;var T=x.Da;z||k(),U||(z(),U=!0),D.add(T,x),x.A=0}}function kl(x){return x.g||x.v||x.A>=3?!1:(x.Y++,x.v=Pn(f(x.Da,x),lf(x,x.A)),x.A++,!0)}n.Da=function(){if(this.v=null,af(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var x=4*this.T;this.j.info("BP detection timer enabled: "+x),this.B=Pn(f(this.Wa,this),x)}},n.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,It(10),oo(this),af(this))};function nd(x){x.B!=null&&(c.clearTimeout(x.B),x.B=null)}function af(x){x.g=new vr(x,x.j,"rpc",x.Y),x.u===null&&(x.g.J=x.o),x.g.P=0;var T=Qn(x.na);Xt(T,"RID","rpc"),Xt(T,"SID",x.M),Xt(T,"AID",x.K),Xt(T,"CI",x.F?"0":"1"),!x.F&&x.ia&&Xt(T,"TO",x.ia),Xt(T,"TYPE","xmlhttp"),Tl(x,T),x.u&&x.o&&wl(T,x.u,x.o),x.O&&(x.g.H=x.O);var P=x.g;x=x.ba,P.M=1,P.A=la(Qn(T)),P.u=null,P.R=!0,jr(P,x)}n.Va=function(){this.C!=null&&(this.C=null,oo(this),kl(this),It(19))};function Pc(x){x.C!=null&&(c.clearTimeout(x.C),x.C=null)}function of(x,T){var P=null;if(x.g==T){Pc(x),nd(x),x.g=null;var q=2}else if(ei(x.h,T))P=T.G,xl(x.h,T),q=1;else return;if(x.I!=0){if(T.o)if(q==1){P=T.u?T.u.length:0,T=Date.now()-T.F;var le=x.D;q=Rn(),St(q,new $n(q,P)),Vi(x)}else sf(x);else if(le=T.m,le==3||le==0&&T.X>0||!(q==1&&Rc(x,T)||q==2&&kl(x)))switch(P&&P.length>0&&(T=x.h,T.i=T.i.concat(P)),le){case 1:Gi(x,5);break;case 4:Gi(x,10);break;case 3:Gi(x,6);break;default:Gi(x,2)}}}function lf(x,T){let P=x.Qa+Math.floor(Math.random()*x.Za);return x.isActive()||(P*=2),P*T}function Gi(x,T){if(x.j.info("Error code "+T),T==2){var P=f(x.bb,x),q=x.Ua;const le=!q;q=new is(q||"//www.google.com/images/cleardot.gif"),c.location&&c.location.protocol=="http"||lr(q,"https"),la(q),le?yi(q.toString(),P):Wu(q.toString(),P)}else It(2);x.I=0,x.l&&x.l.pa(T),cf(x),Ic(x)}n.bb=function(x){x?(this.j.info("Successfully pinged google.com"),It(2)):(this.j.info("Failed to ping google.com"),It(1))};function cf(x){if(x.I=0,x.ja=[],x.l){const T=Cl(x.h);(T.length!=0||x.i.length!=0)&&(E(x.ja,T),E(x.ja,x.i),x.h.i.length=0,w(x.i),x.i.length=0),x.l.oa()}}function uf(x,T,P){var q=P instanceof is?Qn(P):new is(P);if(q.g!="")T&&(q.g=T+"."+q.g),ji(q,q.u);else{var le=c.location;q=le.protocol,T=T?T+"."+le.hostname:le.hostname,le=+le.port;const me=new is(null);q&&lr(me,q),T&&(me.g=T),le&&ji(me,le),P&&(me.h=P),q=me}return P=x.G,T=x.wa,P&&T&&Xt(q,P,T),Xt(q,"VER",x.ka),Tl(x,q),q}function df(x,T,P){if(T&&!x.L)throw Error("Can't create secondary domain capable XhrIo object.");return T=x.Aa&&!x.ma?new dn(new Oi({ab:P})):new dn(x.ma),T.Fa(x.L),T}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function hf(){}n=hf.prototype,n.ra=function(){},n.qa=function(){},n.pa=function(){},n.oa=function(){},n.isActive=function(){return!0},n.Ka=function(){};function lo(){}lo.prototype.g=function(x,T){return new os(x,T)};function os(x,T){Ct.call(this),this.g=new ao(T),this.l=x,this.h=T&&T.messageUrlParams||null,x=T&&T.messageHeaders||null,T&&T.clientProtocolHeaderRequired&&(x?x["X-Client-Protocol"]="webchannel":x={"X-Client-Protocol":"webchannel"}),this.g.o=x,x=T&&T.initMessageHeaders||null,T&&T.messageContentType&&(x?x["X-WebChannel-Content-Type"]=T.messageContentType:x={"X-WebChannel-Content-Type":T.messageContentType}),T&&T.sa&&(x?x["X-WebChannel-Client-Profile"]=T.sa:x={"X-WebChannel-Client-Profile":T.sa}),this.g.U=x,(x=T&&T.Qb)&&!L(x)&&(this.g.u=x),this.A=T&&T.supportsCrossDomainXhr||!1,this.v=T&&T.sendRawJson||!1,(T=T&&T.httpSessionIdParam)&&!L(T)&&(this.g.G=T,x=this.h,x!==null&&T in x&&(x=this.h,T in x&&delete x[T])),this.j=new fa(this)}y(os,Ct),os.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},os.prototype.close=function(){ed(this.g)},os.prototype.o=function(x){var T=this.g;
1976if(typeof x=="string"){var P={};P.__data__=x,x=P}else this.v&&(P={},P.__data__=De(x),x=P);T.i.push(new qn(T.Ya++,x)),T.I==3&&Vi(T)},os.prototype.N=function(){this.g.l=null,delete this.j,ed(this.g),delete this.g,os.Z.N.call(this)};function ff(x){Qe.call(this),x.__headers__&&(this.headers=x.__headers__,this.statusCode=x.__status__,delete x.__headers__,delete x.__status__);var T=x.__sm__;if(T){e:{for(const P in T){x=P;break e}x=void 0}(this.i=x)&&(x=this.i,T=T!==null&&x in T?T[x]:void 0),this.data=T}else this.data=x}y(ff,Qe);function mf(){it.call(this),this.status=1}y(mf,it);function fa(x){this.g=x}y(fa,hf),fa.prototype.ra=function(){St(this.g,"a")},fa.prototype.qa=function(x){St(this.g,new ff(x))},fa.prototype.pa=function(x){St(this.g,new mf)},fa.prototype.oa=function(){St(this.g,"b")},lo.prototype.createWebChannel=lo.prototype.g,os.prototype.send=os.prototype.o,os.prototype.open=os.prototype.m,os.prototype.close=os.prototype.close,iD=function(){return new lo},sD=function(){return Rn()},rD=jt,Ey={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,$m=Kn,rs.COMPLETE="complete",nD=rs,bt.EventType=ht,ht.OPEN="a",ht.CLOSE="b",ht.ERROR="c",ht.MESSAGE="d",Ct.prototype.listen=Ct.prototype.J,Qd=bt,dn.prototype.listenOnce=dn.prototype.K,dn.prototype.getLastError=dn.prototype.Ha,dn.prototype.getLastErrorCode=dn.prototype.ya,dn.prototype.getStatus=dn.prototype.ca,dn.prototype.getResponseJson=dn.prototype.La,dn.prototype.getResponseText=dn.prototype.la,dn.prototype.send=dn.prototype.ea,dn.prototype.setWithCredentials=dn.prototype.Fa,tD=dn}).apply(typeof xm<"u"?xm:typeof self<"u"?self:typeof window<"u"?window:{});/*!
1977* re2js
1978* RE2JS is the JavaScript port of RE2, a regular expression engine that provides linear time matching
1979*
1980* @version v2.8.6
1981* @author Oleksii Vasyliev
1982* @homepage https://github.com/le0pard/re2js#readme
1983* @repository github:le0pard/re2js
1984* @license MIT
1985*/var pn,ke=(pn=class{},Ie(pn,"FOLD_CASE",1),Ie(pn,"LITERAL",2),Ie(pn,"CLASS_NL",4),Ie(pn,"DOT_NL",8),Ie(pn,"ONE_LINE",16),Ie(pn,"NON_GREEDY",32),Ie(pn,"PERL_X",64),Ie(pn,"UNICODE_GROUPS",128),Ie(pn,"WAS_DOLLAR",256),Ie(pn,"LOOKBEHIND",512),Ie(pn,"MATCH_NL",pn.CLASS_NL|pn.DOT_NL),Ie(pn,"PERL",pn.CLASS_NL|pn.ONE_LINE|pn.PERL_X|pn.UNICODE_GROUPS),Ie(pn,"POSIX",0),Ie(pn,"UNANCHORED",0),Ie(pn,"ANCHOR_START",1),Ie(pn,"ANCHOR_BOTH",2),pn);const du={CASE_INSENSITIVE:1,DOTALL:2,MULTILINE:4,DISABLE_UNICODE_GROUPS:8,LONGEST_MATCH:16,LOOKBEHINDS:512},vh=128,_y=new Int32Array(vh),Ty=new Int32Array(vh),Cm=65535;for(let n=0;n<vh;n++)n>=97&&n<=122?_y[n]=n-32:_y[n]=n,n>=65&&n<=90?Ty[n]=n+32:Ty[n]=n;var my,ye=(my=class{static toUpperCase(n){if(n<vh)return _y[n];const e=String.fromCodePoint(n).toUpperCase(),t=e.codePointAt(0)>Cm?2:1;if(e.length>t)return n;const r=String.fromCodePoint(e.codePointAt(0)).toLowerCase(),s=r.codePointAt(0)>Cm?2:1;return r.length>s||r.codePointAt(0)!==n?n:e.codePointAt(0)}static toLowerCase(n){if(n<vh)return Ty[n];const e=String.fromCodePoint(n).toLowerCase(),t=e.codePointAt(0)>Cm?2:1;if(e.length>t)return n;const r=String.fromCodePoint(e.codePointAt(0)).toUpperCase(),s=r.codePointAt(0)>Cm?2:1;return r.length>s||r.codePointAt(0)!==n?n:e.codePointAt(0)}},Ie(my,"CODES",new Map([["\x07",7],["\b",8],["	",9],[`
1986`,10],["\v",11],["\f",12],["\r",13],[" ",32],['"',34],["$",36],["&",38],["'",39],["(",40],[")",41],["*",42],["+",43],["-",45],[".",46],["0",48],["1",49],["2",50],["3",51],["4",52],["5",53],["6",54],["7",55],["8",56],["9",57],[":",58],["<",60],[">",62],["?",63],["A",65],["B",66],["C",67],["F",70],["P",80],["Q",81],["U",85],["Z",90],["[",91],["\\",92],["]",93],["^",94],["_",95],["`",96],["a",97],["b",98],["f",102],["i",105],["m",109],["n",110],["r",114],["s",115],["t",116],["v",118],["x",120],["z",122],["{",123],["|",124],["}",125]])),my),Y=class{constructor(n,e=!1){this.data=n,this.isStride1=e,this.SIZE=e?2:3}getLo(n){return this.data[n*this.SIZE]}getHi(n){return this.data[n*this.SIZE+1]}getStride(n){return this.isStride1?1:this.data[n*this.SIZE+2]}get length(){return this.data.length/this.SIZE}};const aD=new Uint8Array(256);for(let n=0,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";n<64;n++)aD[e.charCodeAt(n)]=n;const oD=n=>{const e=[];let t=0,r=0;for(let s=0;s<n.length;s++){let a=aD[n.charCodeAt(s)];t|=(a&31)<<r,(a&32)===0?(e.push(t),t=0,r=0):r+=5}return e},Q=(n,e)=>{const t=oD(n),r=e?t.length/2:t.length/3,s=new Uint32Array(r*3);let a=0,c=0;for(let u=0;u<r;u++)a+=t[c++],s[u*3]=a,a+=t[c++],s[u*3+1]=a,s[u*3+2]=e?1:t[c++];return s},Wj=n=>{const e=oD(n),t=new Map;let r=0;for(let s=0;s<e.length;s+=2){r+=e[s];const a=e[s+1],c=a>>>1^-(a&1);t.set(r,r+c)}return t};var bm=class{constructor(n){this.initializer=n,this.cache=new Map}has(n){return n in this.initializer}get(n){if(this.cache.has(n))return this.cache.get(n);const e=this.initializer[n],t=e?e():null;return this.cache.set(n,t),t}},jo,Es=(jo=class{static get CASE_ORBIT(){return this._CASE_ORBIT||(this._CASE_ORBIT=Wj("rCgCIgCY+rQI4QiCuuBLgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCCgCBgCBgCBgCBgCBgCBgCB+7OB-BB-BB-BB-BB-BBskQB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BC-BB-BB-BB-BB-BB-BB-BByHBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBDCBBBCBBBCBBCCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBCCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBxHBCBBBCBBBCBBB3SBmMBkNBCBBBCBBB8MBCBBB6MB6MBCBBC+EB0MB2MBCBBB6MB+MBiGBmNBiNBCBBBmKBikzCBmNBqNBkIBsNBCBBBCBBBCBBB0NBCBBB0NDCBBB0NBCBBByNByNBCBBBCBBB2NBCBBDCBBCwDFCBCBDBCBCBDBCBCBDBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBB9EBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBCCBCBDBCBBBhGBvDBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBjICCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBH2iVBCBBBlKBwiVB+jVB+jVBCBBBlMBqEBuEBCBBBCBBBCBBBCBBBCBBB+hVB4hVB8hVBjNB7MC5MB5MCzMC1MB+0yCE5MB20yCC9MBu2yCBwyyCBo0yCChNBlNBo0yCBu-UBi0yCDlNC6-UBpNDrNIu+UDzNCm0yCBzNE0yyCBzNBpEBxNBxNBtEG1NLqxyCBkxyCnFoFrBCBBBCBBDCBBEkIBkIBkICoHHsCCqCBqCBqCCgEC+DB+DBmkOBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCC+BBgCBgCBgCBgCBgCBgCBgCBgCBrCBpCBpCBpCBmjOB-BB8BB-B
1986B-BBgEB-BB-BByBBqgOBsDB-BBtwBB-BB-BB-BBsBBgDBCB-BB-BB-BBeB-BB-BB61OB-BB-BB-DB9DB9DBQB7DBmCE9CBrDBPBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBrFB-EBOBnHB3FB-FCCBBBNBCBBCjIBjIBjIBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgFBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCB-BB-BB8kMB-BB6kMB-BB-BB-BB-BB-BB-BB-BB-BB-BBokMB-BB-BBkkMBkkMB-BB-BB-BB-BB-BB-BB-BB4jMB-BB-BB-BB-BB-BB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EB-EBCBBBCBoiMBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBJCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBeBCBBBCBBBCBBBCBBBCBBBCBBBCBBBdBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBCgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDL-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-C64CgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOBgmOCgmOGgmODg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FBg8FDg8FBg8FBg8FhVg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBg9rCBQBQBQBQBQBQDPBPBPBPBPBPjkC7mMB5mMBnmMBjmMBCBlmMB3lMBpiMBk8kCBCBBG-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FB-7FD-7FB-7FB-7F6FoglCEsuHRwjlCyDCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCB0DBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBG1DD97OCCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPBQBQBQBQBQBQDPBPBPBPBPBPDQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPBQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPBQBQBQBQBQBQDPBPBPBPBPBPEQCQCQCQCPCPCPCPBQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPB0EB0EBsFBsFBsFBsFBoGBoGBgIBgIBgHBgHB8HB8HDQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPBQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPBQBQBQBQBQBQBQBQBPBPBPBPBPBPBPBPBQBQCSFPBPBzEBzEBRCxnOFSFrFBrFBrFBrFBREQBQClkOFPBPBnGBnGFQBQCljOCODPBPB-GB-GBNHSF-HB-HB7HB7HBRqJ53OE9tQBrmQH4Bc3BSgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBgBBfBfBfBfBfBfBfBfBfBfBfBfBfBfBfBfECBByZ0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BB0BBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzBBzB34BgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDBgDB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CB-CBCBBBt-UBruHBt+UB1iVBviVBCBBBCBBBCBBB3hVB5-UB9hVB7hVCCBBCCBBI9jVB9jVBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBICBBBCBBECBBN-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOB-lOC-lOG-lOzoeCBBBCBBBCBBBCBBBCBBBCBl8kCBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBTC
1986BBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBnECBBBCBBBCBBBCBBBCBBBCBBBCBBDCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBKCBBBCBBBnglCBCBBBCBBBCBBBCBBBCBBECBBBvyyCDCBBBCBBBgDCCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBn0yCB90yCB10yCBh0yCBn0yCCjxyCBzyyCBpxyCBg6BBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBB-CBl0yCBvjlCBCBBBCBBBt2yCBCBBBCBBBCBBBCBBBCBBBCBBBCBBBCBBBhkzCZCBB9a-5Bd-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCB-8rCm6TCBB7gBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCH-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BmlBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvChDwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCBwCFvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvCBvC1DuCBuCBuCBuCBuCBuCBuCBuCBuCBuCBuCCuCBuCBuCBuCBuCBuCBuCBuCBuCBuCBuCBuCBuCBuCBuCCuCBuCBuCBuCBuCBuCBuCCuCBuCCtCBtCBtCBtCBtCBtCBtCBtCBtCBtCBtCCtCBtCBtCBtCBtCBtCBtCBtCBtCBtCBtCBtCBtCBtCBtCCtCBtCBtCBtCBtCBtCBtCCtCBtCk2BgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEBgEO-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-DB-D+CgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCL-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-B74CgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BhrVgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCBgCB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BB-BhB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BB2BD1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BB1BtxekCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBkCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjCBjC")),this._CASE_ORBIT}static get Print(){return this._Print||(this._Print=new Y(Q("hB9CBjBLBCpWBDFBFGBCCCBSBCsMBClBBDxBBDCBC2BBJaBFFBSVBC-FBCvBBD6BBDkDBP6BBDwBBDOBCbBDCCBJBGfBIqCBCgFBCHBDBBDVBCGBCEEBCBDIBDBBDDBJFFBCCBDBDYBDCBCFBFBBDVBCGBCBBCBBCBBDCCBDBFBBDCBEIIBCBCIIBPBLCBCIBCCBCVBCGBCBBCEBDJBCCBCCBDQQBCBDLBIGBCCBCHBDBBDVBCGBCBBCEBDIBDBBDCBICBFBBCEBDRBLBBCFBECBCDBEBBCCCBEEBEEBBBELBFEBECBCDBDHHPUBGMBCCBCWBCPBDIBCCBCDBIBBCCBCBBDDBDJBIVBCCBCWBCJBCEBDIBCCBCDBIBBGCBCDBDJBCCBNMBCCBCyBBCCBCFBFPBDZBCCBCRBEXBCIBCDDBFBEFFBEBCCCBGBHJBDCBN5BBFcBmBBBCCCBDBCXBCCCBVBDEBCCCBFBCJBDDBhBnCBCjBBFmBBCjBBCOBCMBmBlGBCGGD4LBCDBDGBCCCBCBDoBBCDBDgBBCDBDGBCCCBCBDOBC4BBCDBDiCBDfBEZBH1CBDFBD-TBCbBE4CBIVBKXBKTBNMBCCBCBBN9CBDJBHJBHNBCKBH4CBIqBBGlCBLeBCLBFLBFEEBoBBDEBMrBBFZBHKBE9BBDgCBCcBDKBHJBHNBDtBBDLBVsCBClFBJ7BBEOBE9BBGqBBDKBJqBBG1QBDFBDlBBDFBDHBCGCBdBD0BBCOBCNBDFBCSBDCBCIBSXBJuBBSBBDaBCMBEhBBPgBBQrEBF5UBXKBWz4BBD9LBGsBBCGGD3BBIBBPXBKGBCGBCGBCGBCGBCGBCGBCGBC9DBjBZBC4CBN1GBbPBC+BBC1CBDmDBGqBBC9CBC1CBKvBBCszcBE2BBK7KBV3FBJ8GBV7BBEJBH3BBJlCBJLBHzDBMdBEtCBCKBFgBBC2BBKNBDJBDmDBZbBLFBDFBDFBKGBCGBC7BBF9DBDJBHj9KBNWBFwBBloItLBDpDBnBGBNEBGZBCEBCCCBCCBCCBoUBhBpBBHyBBCSBCDBFEBCmEBF9FBEFBDFBDFBDCBEGBCGBOBBDLBCZBCSBCBBCOBDNBjB6DBGCBFsBBE3CBCMBEwBwBBsBBjEcBEwBBQbBFjBBKdBGqBBGdBCkBBFNBrB9EBDJBHjB
1986BFjBBFnBBJzBBMLBCOBCGBCBBCKBCOBCGBCBBEzBBN2JBKVBLHBZFBCpBBCIBmCFBDCCBqBBCBBEDDBVBCnCBJIBxBSBCBBGgBBEaBGaBnB3BBFTBDxBBCBBGHBCCBCcBDCBFJBIIBI-BBhBmBBFLBK1BBEcBDaBGZBIDBNGBxCoCB4ByBBOyBBItBBJJBHlBBEcBJBBxGeBCpBBCCBDBBRFBJIBiBtBBJpBBXZBnBbBVWBKtCBFjBBK9BBCEBOYBIJBH0BBCRBJmBBK-CBCTBMRBCuBB-BGBCCCBCBCOBCKBH6BBGJBHDBCHBDBBDVBCGBCBBCEBCJBDBBDCBDHHGGBDGBEEBMJBCDDClBBCJBCDDCDBCJBCBBJBBe7CBCEBfnCBJJBnF1BBDlBBjBkCBMJBHMBU5BBHJBHTBdaBDOBFWB6F7BBlDyCBNHBDDDBGBCBBCdBCBBDLBKJBnCHBDtBBDKBcnCBJyCBOoCBIJB3CHB5ChBBPJBHIBCsBBCNBLcBEfBDVBCNBqCGBCBBCrBBECCBCCBHBJJBHFBCBBCkBBCBBCFBIJBHrBBFJB3HYBIQBCoBBEcB2CQQBwBBO6cBnDuDBCEBMjGBtyCiDBOvhBBRVBL68DBGmSB61G5BBn2B4RBIeBCJBFwCBCJBHdBDFBLlCBLJBCGBCUBGSBxN5BBnG6CBGYBDYBtBqCBF4BBIQBhCEBMGBK1mHBqBfBiDyDB+vIDBCGBCBBCiJBQeeBBBDPPBCBJrMBloCqDBGMBEIBIJBDDBh7D8HBEzNBHWBQQBQtBBDWBKzDB9B1HBLmBBDpCBJvDBWlCB7DTBNTBN2CBKYBoE0CBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDjJBD9VBQEBCOBxiBeBHFB2GGBCQBDGBCBBCEBG9BBiBxDxDBrBBENBDJBFBBhKeBS5BBGxOxOBoBB3GqBBFhGhGBdBCVBJBBhHGBCDBCBBCOBCkGBDPBqBrCBFJBFBByYjCBtC8BBjGDBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQB1BBBvIrBBFjDBNOBDOBCOBCkBBLtFB5BcBOrBBFIBIBBPFB7E4eBEQBEMBE5GBHLBFQQBKBF3BBJJBHnBBJdBDLBFBBPIBoB3KBJNBDMBEKBE4BBCFFBOBDLBFJBIyEBCmDBmgB-2pBBhB9oEBDt0FBDwpHBQtTBjtC9QBjvBq6EBGppIBnkzVvHB",!1))),this._Print}static get Upper(){return this.CATEGORIES.get("Lu")}},Ie(jo,"_CASE_ORBIT",null),Ie(jo,"_Print",null),Ie(jo,"CATEGORIES",new bm({C:()=>new Y(Q("AfBgDgBBOrWrWBHHBCBICCVuMuMnBBBzBBBE4B4BBGBcDBHQBXhGhGxBBB8BBBmDNB8BBByBBBQddBCCMEBhBGBsCiFiFJBBDBBXIICCBFBBKBBDBBFHBCDBDGGBaaBEEHDBDBBXIIDGDBCCGDBDBBECBCGBFCCBFBSJBEKKEXXIDDGBBLIEBCCBNBFBBNGBIEEJBBDBBXIIDGGBKKBDDBEEBFBEDBDGGBTTBIBDHHBBBEFFBBBDCCDCBDCBECBNDBGCBEFFBCCBEBCNBWEBOEEYRRBKKEFFBFBDEEDBBFBBLGBXEEYLLGBBKEEFGBDEBEFFBLLELBOEE0BEEHDBRBBbEETCBZKKCBBICBCDBHCCJFBLBBELB7BDBekBBDCCGZZCYYBGGCIILBBFfBpClBlBBCBoBlBlBQOOBjBBnGCCBDBCBB6LFFBIICFFBqBqBFBBiBFFBIICFFBQQ6BFFBkCkCBhBhBBBBbFB3CBBHBB+UCB6CGBXIBZIBVLBOEEDLB-CBBLFBLFBPMMBEB6CGBsBEBnCJBgBNNBCBNDBCCBrBBBGKBtBDBbFBMCB-BBBiCeeBMMBEBLFBPBBvBBBNTBuCnFnFBGB9BCBQCB-BEBsBBBMHBsBEB3QBBHBBnBBBHBBJGCgBBB2BQQPBBHUUBEEKMMBDBbEByBPBDBBcOOBBBjBNBiBOBtEDB7UVBMUB14BBB-LEBuBCCBDBCBB5BGBDNBZIBI4BI-DhBBb6C6CBKB3GZBxC3C3CBoDoDBDBsB-C-C3CIBxBuzcuzcBBB4BIB9KTB5FHB+GTB9BCBLFB5BHBnCHBNFB1DKBfCBvCMMBCBiB4B4BBHBPBBLBBoDXBdJBHBBHBBHIBIII9BDB-DBBLFBl9KLBYDByBjoIBvLBBrDlBBILBGEBbGGCGDrUfBrBFB0BUUFDBGoEoEBCB-FCBHBBHBBHBBECBIIIBLBDBBNbbUDDQBBPhBB8DEBEDBuBCB5COOBBBCuBBvBhEBeCByBOBdDBlBIBfEBsBEBfmBmBBCBPpBB-EBBLFBlBDBlBDBpBHB1BKBNQQIDDMQQIDDBBB1BLB4JIBXJBJXBHrBrBKkCBHBBCtBtBDCBCBBYpCpCBGBKvBBUDDBDBiBCBcEBclBB5BDBVBBzBDDBDBJEEeBBEDBLGBKGBhCfBoBDBNIB3BCBeBBcEBbGBFLBIvCBqC2BB0BMB0BGBvBHBLFBnBCBeHBDvGBgBrBrBEBBDPBHHBKgBBvBHBrBVBblBBdTBYIBvCDBlBIB-BGGBLBaGBLFB2BTTBGBoBIBhDVVBJBTwBwBB8BBICCFQQMFB8BEBLFBFJJBDDBXXIDDGLLBDDBEEBCCBEBCEBIBBICBGKBLCCBCCnBLLCBBCFFLDDBGBDcB9CGGBcBpCHBLlFB3BBBnBhBBmCKBLFBOSB7BFBLFBVbBcBBQDBY4FB9BjDB0CLBJBBCBBJDDfDDBNNBHBLlCBJBBvBBBMaBpCHB0CMBqCGBL1CBJ3CBjBNBLFBKuBuBPJBeCBhBBBXPPBnCBIDDtBCBCDDKHBLFBHDDmBDDHGBLFBtBDBL1HBaGBSqBqBBBBe0CBCOBzBMB8clDBwDGGBJBlGryCBkDMBxhBPBXJB88DEBoS41GB7Bl2BB6RGBgBLLBCByCLLBEBfBBHJBnCJBLIIWEBUvNB7BlGB8CEBaBBarBBsCDB6BGBS-BBGKBIIB3mHoBBhBgDB0D8vIBFIIDkJkJBNBCcBEBBCNBFHBtMjoCBsDEBOCBKGBLBBF-6DB+HCB1NFBYOBSOBvBBBYIB1D7BB3HJBoBBBrCHBxDUBnC5DBVLBVLB4CIBamEB2CoCoCDBBCBBDBBFNNCIIiCFFBJJIddFGGCCBI1K1KBlJlJB-V-VBNBGQQBuiBBgBFBH0GBISSBIIDGGBDB-BgBBCvDBuBCBPBBLDBD-JBgBQB7BEBCvOBrB1GBsBDBC-FBgBXXBGBD-GBIFFDQQmGBBRoBBtCDBLDBDwYBlCrCB+BhGBFccDCCBCCLFFCCCBEBCDBCECEDDCBBCICDCCBFFIKFCLLSEBEGGSzBBDtIBtBDBlDLBQBBQQQmBJBvF3BBeMBtBDBKGBDNBH5EB6eCBSCBOCB7GFBNDBCOBNDB5BHBLFBpBHBfBBNDBDNBKmBB5KHBPBBOCBMCB6BCCBCBRBBND
1986BLGB0EoDoDBjgBBh3pBfB-oEBBv0FBBypHOBvThtCB-QhvBBs6EEBrpIlkzVBxHvw-FB",!1)),Cc:()=>new Y(Q("AfgDgB",!0)),Cf:()=>new Y(Q("tFzqBzqBBEBXhGhGyBhMhMBxCxCs5D9-B9-BBDBbEByBEBCJBw03B6H6HBBBimEQQj7IPBhjiBDBwmFHBn0rYffB+CB",!1)),Cn:()=>new Y(Q("4bBBHDBICCVuMuMnBBBzBBBE4B4BBGBcDBHKBvI9B9BBmDmDBMB8BBByBBBQddBCCMEBjBEBuHJJBDDBXXICCBBBFBBKBBDBBFHBCDBDGGBaaBEEHDBDBBXIIDGDBCCGDBDBBECBCGBFCCBFBSJBEKKEXXIDDGBBLIEBCCBNBFBBNGBIEEJBBDBBXIIDGGBKKBDDBEEBFBEDBDGGBTTBIBDHHBBBEFFBBBDCCDCBDCBECBNDBGCBEFFBCCBEBCNBWEBOEEYRRBKKEFFBFBDEEDBBFBBLGBXEEYLLGBBKEEFGBDEBEFFBLLELBOEE0BEEHDBRBBbEETCBZKKCBBICBCDBHCCJFBLBBELB7BDBekBBDCCGZZCYYBGGCIILBBFfBpClBlBBCBoBlBlBQOOBjBBnGCCBDBCBB6LFFBIICFFBqBqBFBBiBFFBIICFFBQQ6BFFBkCkCBhBhBBBBbFB3CBBHBB+UCB6CGBXIBZIBVLBOEEDLB-CBBLFBLFBbFB6CGBsBEBnCJBgBNNBCBNDBCCBrBBBGKBtBDBbFBMCB-BBBiCeeBMMBEBLFBPBBvBBBNTBuCnFnFBGB9BCBQCB-BEBsBBBMHBsBEB3QBBHBBnBBBHBBJGCgBBB2BQQPBBHUUBEEKmDmDNBBcOOBBBjBNBiBOBtEDB7UVBMUB14BBB-LEBuBCCBDBCBB5BGBDNBZIBI4BI-DhBBb6C6CBKB3GZBxC3C3CBoDoDBDBsB-C-C3CIBxBuzcuzcBBB4BIB9KTB5FHB+GTB9BCBLFB5BHBnCHBNFB1DKBfCBvCMMBCBiB4B4BBHBPBBLBBoDXBdJBHBBHBBHIBIII9BDB-DBBLFBl9KLBYDByBDBvzIBBrDlBBILBGEBbGGCGDrUfBrBFB0BUUFDBGoEoEBCC-FCBHBBHBBHBBECBIIIBIBGBBNbbUDDQBBPhBB8DEBEDBuBCB5COOBBBCuBBvBhEBeCByBOBdDBlBIBfEBsBEBfmBmBBCBPpBB-EBBLFBlBDBlBDBpBHB1BKBNQQIDDMQQIDDBBB1BLB4JIBXJBJXBHrBrBKkCBHBBCtBtBDCBCBBYpCpCBGBKvBBUDDBDBiBCBcEBclBB5BDBVBBzBDDBDBJEEeBBEDBLGBKGBhCfBoBDBNIB3BCBeBBcEBbGBFLBIvCBqC2BB0BMB0BGBvBHBLFBnBCBeHBDvGBgBrBrBEBBDPBHHBKgBBvBHBrBVBblBBdTBYIBvCDBlBIBlCJBCBBaGBLFB2BTTBGBoBIBhDVVBJBTwBwBB8BBICCFQQMFB8BEBLFBFJJBDDBXXIDDGLLBDDBEEBCCBEBCEBIBBICBGKBLCCBCCnBLLCBBCFFLDDBGBDcB9CGGBcBpCHBLlFB3BBBnBhBBmCKBLFBOSB7BFBLFBVbBcBBQDBY4FB9BjDB0CLBJBBCBBJDDfDDBNNBHBLlCBJBBvBBBMaBpCHB0CMBqCGBL1CBJ3CBjBNBLFBKuBuBPJBeCBhBBBXPPBnCBIDDtBCBCDDKHBLFBHDDmBDDHGBLFBtBDBL1HBaGBSqBqBBBBe0CBCOBzBMB8clDBwDGGBJBlGryCBkDMB3iBJB88DEBoS41GB7Bl2BB6RGBgBLLBCByCLLBEBfBBHJBnCJBLIIWEBUvNB7BlGB8CEBaBBarBBsCDB6BGBS-BBGKBIIB3mHoBBhBgDB0D8vIBFIIDkJkJBNBCcBEBBCNBFHBtMjoCBsDEBOCBKGBLBBJ76DB+HCB1NFBYOBSOBvBBBYIB1D7BB3HJBoBBBjGUBnC5DBVLBVLB4CIBamEB2CoCoCDBBCBBDBBFNNCIIiCFFBJJIddFGGCCBI1K1KBlJlJB-V-VBNBGQQBuiBBgBFBH0GBISSBIIDGGBDB-BgBBCvDBuBCBPBBLDBD-JBgBQB7BEBCvOBrB1GBsBDBC-FBgBXXBGBD-GBIFFDQQmGBBRoBBtCDBLDBDwYBlCrCB+BhGBFccDCCBCCLFFCCCBEBCDBCECEDDCBBCICDCCBFFIKFCLLSEBEGGSzBBDtIBtBDBlDLBQBBQQQmBJBvF3BBeMBtBDBKGBDNBH5EB6eCBSCBOCB7GFBNDBCOBNDB5BHBLFBpBHBfBBNDBDNBKmBB5KHBPBBOCBMCB6BCCBCBRBBND
1986BLGB0EoDoDBjgBBh3pBfB-oEBBv0FBBypHOBvThtCB-QhvBBs6EEBrpIm8yVBCdBhD-DBxHvw-BB---BBB---BBB",!1)),Co:()=>new Y(Q("gg4B-nGh4hc9--BD9--B",!0)),Cs:()=>new Y(Q("gg2B--B",!0)),L:()=>new Y(Q("hCZBHZBwBLLFGGBVBCeBCpOBFLBPEBICCiEEBCBBDDBCHHCCBCCCBSBCyCBCqEBJlFBClBBDHHBnBBoCaBFDBuBqBBkBBBCiDBCQQBIIBLLBBBDRRCdBe4CBMZZBfBKBBFGGBUBFKKEYYBXBIKBGXBCGBRpBB7B1BBETTIJBQPBFHBDBBDVBCGBCEEBCBERROBBCCBPBBLJJBEBFBBDVBCGBCBBCBBCBBgBDBCUUBBBRIBCCBCVBCGBCBBCEBETTQBBYMMBGBDBBDVBCGBCBBCEBEffBCCBBBQSSCFBECBCDBEBBCCCBEEBEEBBBELBX1B1BBGBCCBCWBCPBEbbBBBCBBDBBfFFBGBCCBCWBCJBCEBEffBBBCBBQBBSIBCCBCoBBDRRGCBJCBZFBGRBEXBCIBCDDBFB7BvBBCBBNGB7BBBCCCBDBCXBCCCBIBCBBKDDBDBCWWBCBhBgCgCBGBCjBBcEB0DqBBVRRBEBFDBEEEBIIBBBFMBNSSBkBBCGGDqBBCsKBCDBDGBCCCBCBDoBBCDBDgBBCDBDGBCCCBCBDOBC4BBCDBDiCBmBPBR1CBDFBErTBDQBCZBGqCBHHBIRBOSBPRBPMBCCBQzBBkBFFkC4CBIEBDhBBCGGBkCBLeByBdBDEBMrBBFZB3BWBK0BBzC+C+CBtBBSHB3BdBOBBLrBBbjBBqBCBLjBBDKBGqBBDCBqBDBCFBCBBEGGB+FBhC1IBDFBDlBBDFBDHBCGCBdBD0BBCGBCEEBBBCGBEDBDFBFMBGCBCGB1DOORMBmDFFDJBCEEBDBHGCBCBCKBDDBGEBF1B1BB8zC8zCBjHBHDBEBBNlBBCGGD3BBIRRBVBKGBCGBCGBCGBCGBCGBCGBCGBxC2O2OBrBrBBDBGBBF1CBHCBC5CBCDBGqBBC9CBSfBxBPBhQ-tGBhCs0VBkCtBBDsIBEPBLBBVuBBReBDlCByBIBDmDBDxCBVQBCCBCDBCWBezBBPxBB-BFBECCBMMBaBLWBacBIuBBdRRBDBCJBLEBCoBBYCBCHBVWBEEEBwBBCEEBDDBDBDCCZCBDKBICBNFBDFBDFBKGBCGBCqBBCNBHyDBej9KBNWBFwBBloItLBDpDBnBGBNEBGCCBIBCMBCEBCCCBCCBCCBqDBiBqLBT-BBD1BBpBLB1DEBCmEBlBZBHZBM4CBEFBDFBDFBDCBkBLBCZBCSBCBBCOBDNBjB6DBmMcBEwBBwBfBOTBCHBHlBBLdBDjBBFHBxB9EBTjBBFjBBFnBBJzBBNKBCOBCGBCBBCKBCOBCGBCBBEzBBN2JBKVBLHBZFBCpBBCIBmCFBDCCBqBBCBBEDDBVBLWBKeBiCSBCBBLVBLZBHZBnB3BBHBBhCQQBCBCCBCcBrBcBEcBkBHBCbBc1BBLVBLSBORBvDoCB4ByBBOyBBOjBBnBbBKWB7HpBBHBBRFB5BcBLJJBUBrBRBvBUBcWBN0BB6BBBDOOBrBBhBYBbjBBeDDJiBBENNBuBBPDBWCCkBRBCYBUBBgCGBCCCBCBCOBCJBIuBBnBHBDBBDVBCGBCBBCEBETTNEBfJBCDDClBBCaaCtBtBBzBBTDBVCBfvBBVBBC5F5FBtBBqBDBlBvBBV8B8BBpBBOoCoCBZBmBGB6FrBB1D-BBgBHBDDDBGBCBBCXBQCC-CHBDmBBRCCdLLBmBBIWWMtBBUTTBnCBoGgBBgBIBCkBBSyByBBcBxDGBCBBClBBWaaBEBCBBCfBPYYBqBBlISBQCCBLBChBB9DwCwCB4cBnHjGBtyCgDBQvhBBSFBa68DBGmSB61GdBj3B4RBIeBSuCBSdBTvBBRDBgBUBGSBxNsBB0G-BBhBYBDYBtBqCBGjCjCBLBhCBBCPPBNNB0mHBqBfBiDyDB+vIDBCGBCBBCiJBQeeBBBDPPBCBJrMBloCqDBGMBEIBIJBn7F0CBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDYBCYBCeBCYBCeBCYBCeBCYBCeBCYBCHB15BeBHFBmI9BBzEsBBLGBRiKiKBcBTrBBlPbBlHdBDwGwGBdBCCBCBBCGBDEBKBBhHGBCDBCBBCOBCkGB8BjCBI1lB1lBBCBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQBlqE-2pBBhB9oEBDt0FBDwpHBQtTBjtC9QBjvBq6EBGppIB",!1)),LC:()=>new Y(Q("hCZBHZB7BLLBVBCeBCiGBCDBFvGBDZBhGDBDBBECBCHHCCBCCCBSBCyCBCqEBJlFBClBBKoBB44ClBBCGGDqBBDCBhV1CBDFBjkCKBGqBBDCBhCrBBgCMBChBBmD1IBDFBDlBBDFBDHBCGCBdBD0BBCGBCEEBBBCGBEDBDFBFMBGCBCGBmIFFDJBCEEBDBHGCBCBCFBFDDBCBGEBF1B1BB8zC8zCB6DBDmDBHDBEBBNlBBCGGzoetBBTbBnEtCBCWBEDBCsCBZBBE2Z2ZBpBBGIBIvCBh6TGBNEBqgBZBHZBmlBvCBhDjBBFjBB1DKBCOBCGBCBBCKBCOBCGBCBBk2ByBBOyBB+CVBLVB74C-BBhrV-BBhBYBDYBtpZ0CBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDYBCYBCeBCYBCeBCYBCeBCYBCeBCYBCHB15BJBCTBHFB2uCjCB",!1)),Ll:()=>new Y(Q("hDZB7BqBqBBWBCHBC2BCBQCBuBCDECBBBDCCDEEBFFDEEBBBDDDCCCDCCBCCDEECDDBDDBBBHGDCOCBSCBDDCEEC4BCBFBDDDBCCFICBjCBDZBiGCCEEEBBBTccBhBBCBBECBCWCBDBCGDB0B0BBuBBCgBCK0BCDMCBgDCxBoBBo6CqBBDCB5XFBjkCIBC2D2DBqBBgCMBChBBnD0ECBHBCgDCBHBJFBLHBJHBJFBLHBJHBJNBDHBJHBJHBJEBCBBHEEBBBCBBJDBDBBJHBLCBCBBzIEEBEEcKFDBBJDBF2B2Bs1CvBBCEEBGCFCCBCCBEBGiDCBIICFFNlBBCGG0oesBCUaCoEMCBBBC+BCBGBCCCDICFCCDCCBBBCSCGGGCMCFCCDOCbEE2ZqBBGIBIvCBh6TGBNEBqhBZBumBnBBpEjBB8EKBCOBCGBCBBk4ByBB+DVB75CfBhsVfB8BYBnqZZBbGBCRBbZBbDBCCCBFBCKBbZBbZBbZBbZBbZBbZBbZBbZBbbBdYBCFBbYBCFBbYBCFBbYBCFBbYBCFBC15B15BBIBCTBHFB4vChBB",!1)),Lm:()=>new Y(Q("wVRBFLBPEBICCmEGG-OnHnHlFBBuIBBFgBgBKEEhFoFoF1mBgEgE2R72B72BsDkTkTxOFBvF+BBOjBjBBjBByVOORMBg-CBByHgGgG2OsBsBBDBGiDiDB+C+CBBB34bjnBjnBBEBvIzDzDdBB6DIBxCYYpDDBEBB2OXXqEtDtDWBBoDDBKngVngVuBBBh-BFBCpBBCIB0sBhBhB2K04D04DnrTDB9PCBpBBBnRMBhCBBCPPB9-P9-PBCBCGBCBByhM9BBqGGBud0Q0QsSAB",!1)),Lo:()=>new Y(Q("qFQQhIFFBCBxGBB7ZaBFDBuBfBCJBkBBBCiDBCZZBLLBBBDRRCdBe4CBMZZBfBWVBrBYBIKBGXBCGBRoBB8B1BBETTIJBROBFHBDBBDVBCGBCEEBCBERROBBCCBPBBLJJBEBFBBDVBCGBCBBCBBCBBgBDBCUUBBBRIBCCBCVBCGBCBBCEBETTQBBYMMBGBDBBDVBCGBCBBCEBEffBCCBBBQSSCFBECBCDBEBBCCCBEEBEEBBBELBX1B1BBGBCCBCWBCPBEbbBBBCBBDBBfFFBGBCCBCWBCJBCEBEffBBBCBBQBBSIBCCBCoBBDRRGCBJCBZFBGRBEXBCIBCDDBFB7BvBBCBBNFB8BBBCCCBDBCXBCCCBIBCBBKDDBDBYDBhBgCgCBGBCjBBcEB0DqBBVRRBEBFDBEEEBIIBBBFMBNyDyDBnKBCDBDGBCCCBCBDoBBCDBDgBBCDBDGBCCCBCBDOBC4BBCDBDiCBmBPByDrTBDQBCZBGqCBHHBIRBOSBPRBPMBCCBQzBBpBkCkCBhBBC0BBIEBDhBBCGGBkCBLeByBdBDEBMrBBFZB3BWBK0BBxFuBBSHB3BdBOBBLrBBbjBBqBCBLdByDDBCFBCBBE7hB7hBBCB4-C3BBZWBKGBCGBCGBCGBCGBCGBCGBCGBoR2B2BF1CBJCCB4CBFGGB
1986pBBC9CBSfBxBPBhQ-tGBhC0wUBC2jBBkCnBBJrIBFPBLBBjCyByBBkCBqFoDoDEGBCCBCDBCWBezBBPxBB-BFBECCBMMBaBLWBacBIuBBuBEBDIBLEBCoBBYCBCHBVPBCFBEEEBwBBCEEBDDBDBDCCZBBEKBIPPBEBDFBDFBKGBCGByEiBBej9KBNWBFwBBloItLBDpDBkCCCBIBCMBCEBCCCBCCBCCBqDBiBqLBT-BBD1BBpBLB1DEBCmEBqDJBCsBBDeBEFBDFBDFBDCBkBLBCZBCSBCBBCOBDNBjB6DBmMcBEwBBwBfBOTBCHBHlBBLdBDjBBFHBhEtCBjDnBBJzBB9CzBBN2JBKVBLHB5EFBDCCBqBBCBBEDDBVBLWBKeBiCSBCBBLVBLZBHZBnB3BBHBBhCQQBCBCCBCcBrBcBEcBkBHBCbBc1BBLVBLSBORBvDoCB4FjBBnBDBCxJxJBoBBHBBRCBCBB5BcBLJJBUBrBRBvBUBcWBN0BB6BBBDOOBrBBhBYBbjBBeDDJiBBENNBuBBPDBWCCkBRBCYBUBBgCGBCCCBCBCOBCJBIuBBnBHBDBBDVBCGBCBBCEBETTNEBfJBCDDClBBCaaCtBtBBzBBTDBVCBfvBBVBBC5F5FBtBBqBDBlBvBBV8B8BBpBBOoCoCBZBmBGB6FrBB0GHBDDDBGBCBBCXBQCC-CHBDmBBRCCdLLBmBBIWWMtBBUTTBnCBoGgBBgBIBCkBBSyByBBcBxDGBCBBClBBWaaBEBCBBCfBPYYBnBBCBBlISBQCCBLBChBB9DwCwCB4cBnHjGBtyCgDBQvhBBSFBa68DBGmSB61GdBj3B4RBIeBSuCBSdBTvBB0BUBGSB0NnBB2MqCBGwFwFB0mHBqBfBiDyDBuwIiJBQeeBBBDPPBCBJrMBloCqDBGMBEIBIJBxzI2P2PBrBBiBiKiKBcBTrBBlPaBmHdBDwGwGBdBCCBCBBCGBDEBKiHiHBFBCDBCBBCOBCkGB8pBDBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQBlqE-2pBBhB9oEBDt0FBDwpHBQtTBjtC9QBjvBq6EBGppIB",!1)),Lt:()=>new Y(Q("lOGDnB2sH2sHBGBJHBJHBNQQwBAB",!1)),Lu:()=>new Y(Q("hCZBmDWBCGBiB2BCDOCDuBCBECEBBCCCBCCBBBDDBCBBCCBEBBCBBCECBCCDCCBCCBBBCCCBEEIJDCMCDQCDDDCCBC4BCIBBCBBDCCBCBCGCiJCCEJJHCCBBBCCCBCCBPBCIBkBDDBBBEWCGDDCBBDyBBxBgBCK2BCBMCD+CCDlBBq6ClBBCGGzW1CB0kCHHBpBBDCBhK0ECKgDCKHBJFBLHBJHBJFBMGCJHBpCDBNDBNDBNEBMDBnIFFECBDCBDEEBDBHGCBCBDDBLBBG+B+B9zCvBBxBCCBBBDGCBCBCDDJCBCgDCJCCFuqeuqeCqBCUaCoEMCE8BCLECBICFCCDCCEUCBDBCEBCOCBCBCCCBQCZs5Vs5VBYBmmBnBBpEjBB9EKBCOBCGBCBBr3ByBB+EVB75CfBhsVfBhCYBoqZZBbZBbZBbCCBGDBDDBCBCHBbZBbBBCDBDHBCGBcBBCDBCEBCEEBFBcZBbZBbZBbZBbZBbZBfYBiBYBiBYBiBYBiBYBiB2pE2pEBgBB",!1)),M:()=>new Y(Q("gYvDB0IGBoIsBBCCCBCCBCCpCKBxBUBRmDmDBFBDFBDBBCDBkBffBZB8CKB7BIBKZZBCBCIBCCBCEBsBCB8BIBrBXBCgBB3BCBCRBCGBLBBeCB5BCCBFBDBBDCBKLLBbbDCB5BCCBDBFBBDCBEffBEEMCB5BCCBGBCCBCCBVBBXFBCCB5BCCBFBDBBDCBICBLBBf8B8BBDBECBCDBKpBpBBDB4BCCBFBCCBCDBIBBMBBeCB5BCCBFBCCBCDBIBBMBBQNNBCB4BBBCGBCCBCDBKLLBeeBBBnCFFBEBCCCBGBTBB+BDDBFBNHBjDDDBHBMGBqCBBcECFBByBTBCBBGKBCjBBKlDlDBSBYDBFCBCCBDGBEDBOLBCLLBCBgWCBzdDBdCBeBBfBBhCfBKuBuBBBBC2D2DBjBjB3DLBFLB8GEB6BJBCcBDxBxBBsBBDLBVEBwBQBnB
1986IBNCBfMB5BNBxBTB5ECBCUBFHHDCBnG-BBxWgBB--CCBuEhDhDBeBrRFBqDBB1udDBCJBhBBBxCBBxIEEFYYBDBF0C0CBzBzBBQBbRBOnBnBBGBaMBtBDBwBNBlBkCkCBMBNJJBuBuBBBBzBCCBBBDBBGBBCqBqBBDBGBBtHHBCBBx5TiXiXBOBRPBuejHjH2EEBn0BCBCBBGDBpBCBFmFmFB+R+RBCBiCEB+JBBuCFBnCKByBDB7DCB2BOBqBDDBLLBCBuBKBI+B+BBBBlBNBRBBtBNNBBBxBNBJDBCBB9CLBHDD+ELBWDB4BBBCGBDBBDCBKLLBDDBFBEEBkCIBCDDCDBCEBCPPBzCzCBQBYyCyCBSBsHGBDIBcBBzCQBrDMBmDOBhIOB2HFBCBBDDBCCCBuEuEBFBDGBEddBIBpBGBCDBJKKBJBvBPBnGHBoGHBCHBzCVBCNB7DFBECCBCCBFBCjCjCBDBCBBCEB8KDBKBBCxBxBBFBEEBYmnFmnFHOBpmLRBhuCEB8BGB5gBCCB1BBIDByCMMBslTslTBizEizEBsBBDWB-QEBEFBJHBDGBfDB1ECB89B2BBFxBBJPPXEBCOBxqBGBCQBDGBCBBCEBlDhFhFBFB4L+B+BBCB9PDB-HBB0HDDIBBG7O7OBFBuDGB29lYvHB",!1)),Mc:()=>new Y(Q("joC4B4BDCBJDBCBBzBBB7BCBHBBDBBLsBsB7BCBjC7B7BBBBJCCB2B2BB7B7BCHHBDDBLLnDBBCBBECBCCBLqBqBBBB+BDB+BBB7BCCBDBDBBCBBKBBdPPB7B7BBBBGCBCCBLrBrBBsCsCBBBHHBTBBrKBBgCsFsFBFFHDDBaaBLLBBBDGBWBBDFBDLLBBB5zBffiEIIBGBCBB7KDBDCBFBBCFBhHBB7BCCKCCBJJBEByExBxBGCCBDBCBB+BffFBBD9B9BDCBCEEBxBxBBGBJBBsFWW35EBB0-dBBD5C5CBzBzBBOBvEBBwBxBxBBFFBDDBBBvDBBDBBZuBuBCuDuDDBBGuHuHBCCBCCBCC0gZCCgEuBuBBBBFBB0DZZB8B8BxBCBKBBO+C+CBBBEBBCrFrFBBBgBBB7BBBCDBDBBDCBKLLB1C1CBBBIDDCDBCBBCmDmDBBBJBBErDrDBBBHCCBCBDuHuHBBBHDBDyDyDBBBJBBCuDuDCBBHoDoDCBBFmImIBBBK4H4HBEBCBBFDDCvEvEBBBJDBF1C1CeBB-BqGqGECCoGPPrDIID2G2GBDBFBBC-K-KBNNxBBBJBBCpvQpvQBBBlxD2BBpDBB0rYBBHFB",!1)),Me:()=>new Y(Q("okBBB1xF-wB-wBBCBCCBsshBCB",!1)),Mn:()=>new Y(Q("gYvDB0IEBqIsBBCCCBCCBCCpCKBxBUBRmDmDBFBDFBDBBCDBkBffBZB8CKB7BIBKZZBCBCIBCCBCEBsBCB8BIBrBXBCfB4BCCFHBFEEBFBLBBe7B7BFDBJVVBbbDBB6BFFBFFBDDBBBEffBEEMBB6BFFBDBCBBFVVBXXBEBC7B7BDCCBCBJIIBMMBff+BNNzBEE4BCCBBBGCBCDBIBBMBBe7B7BDHHGBBVBBdBB6BBBFDBJVVBeepCIIBBBC7C7CDGBNHBjDDDBHBMGBqCBBcEC4BNBCEBCBBGKBCjBBKnDnDBCBCFBCBBDBBaBBFCBRDBODDBHHQgWgWBBBzdCBeBBfBBfBBhCBBCGBJDDBJBKuBuBBBBC2D2DBjBjB3DCBFBBKHHBBB8GBBD7B7BCGBCCCDHBHJBDxBxBBMBCeBDLBVDBxBCCBDBCGGpBIBNBBhBDBDBBCCB5BCCBEECCB7BHBDBB5ECBCMBCGBFHHEBBnG-BBxWMBFEEBKB--CCBuEhDhDBeBrRDBsDBB1udFFBIBhBBBxCBBxIEEFaaBGG4EBBbRBOnBnBBGBaKBvBCBxBDDBCBDBBoBkCkCBEBDBBDBBNJJwB0B0BCCBDBBGBBCrBrBBJJvHDDFx5Tx5TiXPBRPBuejHjH2EEBn0BCBCBBGDBpBCBFmFmFB+R+RBCBiCEB+JBBuCFBnCKByBDB8D3B3BBNBqBDDBLLBBByBDBDBBI+B+BBBBlBEBCHB-BNNB1B1BBHBLDBDgDgDBBBDCCBHHD+E+EEHBWBB6BBBEmBmBBFBEEBnCFBOECPBB2CHBDCBCYY1CFBCFFBCCBvHvHBCBHBBCBBcBB2CHBDCCBrDrDCDDBEBCmDmDCDDBCBCEBkIIBCBBhIBBCFFxEDBDBBFhBhBBIBpBFBDDBJKKBEBDCBvBMBCBBnGCCBBBCqGqGBFBCFBCzCzCBUBDGBCBBCBB7DFBECCBCCBFBCpCpCBEEC8K8KBMMB1B1BBDBGCCYmnFmnFHOBpmLLBECBhuCEB8BGB5gBgCgCBCByC5lT5lTBizEizEBsBBDWBhRCBSHBDGBfDB1ECB89B2BBFxBBJPPXEBCOBxqBGBCQBDGBCBBCEBlDhFhFBFB4L+B+BBCB9PDB-HBB0HDDIBBG7O7OBFBuDGB29lYvHB",!1)),N:()=>new Y(Q("wBJB5DBBGDDBBBitBJBnEJBnGJB9MJB3DJBFFBtDJB3DJB3DJBDFBvDMB0DJBJGBoDJBpDGBISBuDJBhDJB3DJBnCTBtIJBnCJBwWTBybCBwHJBHJBXJBtJJBhEKBmFJBHJB3FJB3CJBnEJBHJB3gBEEBEBHJBnGyBBDEB3W7BBvCVB3TdBqrBqYqYaIBPCB4KDBrEJBfHBCOBhBJBoBOBh7cJB9FJBhKFB7EJBnBJBnGJBXJB3CJB3MJB34UJBuPsBBN4BBSBB2KaBlBDBeJJnEEBrGJBvdHBaGBoBIBsCEBXFBhFBBDPBDtBBhCIB1BBBfCBsCEBpDHBZHBqBGBrKFBxBJBHJB3IeB-EJBrBDBxDGBnEdBhEJB9BJBxEJBITB8HJB3KJB3DJB3LJBnDJBHTBtCLBlNSB+CJB3UJB3CcBkHJBnCJB3BJBnLJBnDUBshBuDBimPJBnpCJB3CJBnEJBCGBvQJBnIWB+KCB6nXJBnuBTBNTBtDYB2iBxBBhqCJBnNJB3PJB4HJBtWIBhEJB4Y6BBCCBCDBtCsBBCOBjeMBk3CJB",!1)),Nd:()=>new Y(Q("wBJnxBJnEJnGJ9MJ3DJ3DJ3DJ3DJ3DJ3DJ3DJ3DJ3DJhDJ3DJnCJ3IJnCJn6BJnBJtJJhEJnFJHJ3FJ3CJnEJHJnuiBJnVJnBJnGJXJ3CJ3MJ34UJnsBJnkCJHJ9YJhEJ9BJxEJ3IJ3KJ3DJ3LJnDJHTtCJnNJnDJ3UJ3CJ3HJnCJ3BJnLJ3uQJnpCJ3CJnEJ3QJ37XJ12CxBhqCJnNJ3PJ4HJ2aJ30EJ",!0)),Nl:()=>new Y(Q("u3FCBwzCiBBDDB-zDaaBHBPCBs1dJBxyW0BBtOJJnEEBrhIuDBm8SCB",!1)),No:()=>new Y(Q("yFBBGDDBBB2pCFB5LFB5DCBmEGB6GGBSIByNJB2hBTB0jBJBhP20B20BEFBHJBnGPBqB3W3WB6BBvCVB3TdBqrB1kB1kBBCBrEJBfHBCOBhBJBoBOBxrdFBymWsBBiCDBSBB2KaBlBDB1pBHBaGBoBIBsCEBXFBhFBBDPBDtBBhCIB1BBBfCBsCEBpDHBZHBqBGBrKFBhLeB-EJBrBDBxDGBnETB8LTBmqBBBvNIBobSB0aUBn8SGB-YWBqhZTBNTBtDYBvqFIBid6BBCCBCDBtCsBBCOBjeMB",!1)),P:()=>new Y(Q("hBCBCFBCDBLBBEBBbCBCccCkBkBGEELBBEEE-VJJzOFBqBBB0BCCDDDtBBBVBBCBBOCCBBBrCDBnDsBsBBMBqHCB3BOBgBmImIBLLtE5D5D6DnMnMNwLwL7CLLBpFpFBNBCmBmBBCBoCrCrCBDBFBBwDFBsFlTlTBHB4EuTuTtBBBvCCBoCBB+ECBCCBmBKB6JBB5GBBhEGBCFBhFBBLGBdCB9DDB8BEB-BBBhCHBM9Z9ZBWBJTBCMBCLBfBBPBB6TDBeBB+hBNBwCBBgBJB0MVBgCDBhBBB8XDBCBBxDwEwEBtBBCfBDLBkNCBFJBDLBRNNjD7C7CjgdBBuICBkDLL0DFB9LDB3CBBpBCBCyByBBwBwBiDMBRBB9DDB-DBBRBB6HzqUzqUBxGxGBI
1986BXiBBCNBCFFCBB2ECBCFBCDBLBBEBBbCBCccCCCBFB7MCB9UxBxB-MoXoXoGgBgBxIIBnBxDxDBFBjCGB6CDByO-J-JjBlElEBDBtBDB+FGBuDBBCDB-DDBxBBBwCDBFOOCCB5CFBsDrJrJBCCBzDzDBDBLBBCpDpD7HWBqDCBdMBtCjEjEBBB9HpIpIBBB8E9C9CBGB0CCBCEB+CJB4GgDgDBDBrBBBmUBBrCMBwFxjBxjBBDB97CBB8zOBBmEiCiCBDBJpRpRBBBoJDBoK9lT9lTovHEB07C-a-aBAB",!1)),Pc:()=>new Y(Q("-Cg-Hg-HBUU-u3BBBZCBwHAB",!1)),Pd:()=>new Y(Q("tB9qB9qB0BiyDiyDmgBqgCqgCBEBiwDDDgBBBFdd-NUUwDxszBxszBBmBmBLqFqFhzD-J-J",!1)),Pe:()=>new Y(Q("pB0B0BgB+1D+1DC-6B-6BqtC4B4BQ7T7TCff-hBMCxChBhBCGC1MUChCCCiBmhBmhBCECtBGCtNICEGCDBB-ozB6G6GeOCESSCCCrF0B0BgBGD",!1)),Pf:()=>new Y(Q("7F+6H+6HEddpuDCCFDDQEE",!1)),Pi:()=>new Y(Q("rFt7Ht7HDBBDaapuDCCFDDQEE",!1)),Po:()=>new Y(Q("hBCBCCBDECBLLBEEBcclCGGPBBI-V-VJzOzOBEBqB3B3BDDDtBBBVBBCBBOCCBBBrCDBnDsBsBBMBqHCB3BOBgBmImIBLLtE5D5D6DnMnMNwLwL7CLLBpFpFBNBCxDxDrCEBFBBwDFBsFlTlTBHBmY9D9DBBBoCBB+ECBCCBmBFBCDB6JBB5GBBhEGBCFBhFBBLGBdCB9DDB8BEB-BBBhCHBMjajaBJJBGBJIBDDBDCBEKBCCCBIB7kDDBCBBxDwEwEBFFBBBDDDBHBCBBCDDBLLBDBCJBDDBCCCBLBDCBtNCB6B+F+FjgdBBuICBkDLL0DFB9LDB3CBBpBCBCyByBBwBwBiDMBRBB9DDB-DBBRBB6HlxUlxUBFBDXXVBBDDBECBCDBICBHCCB2E2EBBBCCBDECBLLBEEBcclBDDB7M7MBBB9UxBxB-MoXoXoGgBgBxIIBnBxDxDBFBjCGB6CDB0ZlElEBDBtBDB+FGBuDBBCDB-DDBxBBBwCDBFOOCCB5CFBsDrJrJBCCBzDzDBDBLBBCpDpD7HWBqDCBdMBtCjEjEBBB9HpIpIBBB8E9C9CBGB0CCBCEB+CJB4GgDgDBDBrBBBmUBBrCMBwFxjBxjBBDB97CBB8zOBBmEiCiCBDBJpRpRBBBoJDBoK9lT9lTovHEB07C-a-aBAB",!1)),Ps:()=>new Y(Q("oBzBzBgB-1D-1DC-6B-6B-rCEEnB4B4BQ7T7TCff-hBMCxChBhBCGC1MUChCCCiBmhBmhBCECaTTCECtNICEGCDipzBipzB4GeeCMCESSCCCrFzBzBgBEEDAB",!1)),S:()=>new Y(Q("kBHHRCBgBCCcCCkBEBCBBDCCBCBDEEfgBgBrODBNNBGGBCCCBPB2DPPBxDxDsErIrIBBB3DCBDDDBvGvGLUUB4H4HIBBpEqLqLBHHB2H2H-DjEjEBGBlEwGwGqBmGmGiGCBQCCBBBDFBVECmEHBCFBCBBGDBmGBBxXJB0WuLuLlL+E+EBgBBiLJBKIBhiBCCBBBMCBOCBOCBOBBmCOOoBCBOCBUhBB-BBBCDBCBBLCCBBBGFBCECFMMBFFBDBGDBC7B7BBFFB2LBFcBD+HBXKByCtCBXnTBtBwBBDeBLyMBX+BBFfBD1LBDpEBmHFBmLBBvBZBC4CBN1GBbPBFOOBNNWBBHBB8CBB0HBBFJBhBlBBKRRBdBMdBJQQBeBLmBBQ-JBhuG-BBx0V2BB6RWBKBBoDBB+EDBLDB+RCBiHPPB+9T+9TpEgBBuLPBhCBB3BHBtBDBjDCCBBBD7E7EHRRBBBgBCCcCCiEGBCGBOBB6JIB6BQBDCBCMBEwBwBBrBB7zBBBwSmWmWBiKiKBGBnjC2kC2kCBbBr6SDBG3qU3qUk7DvHBLCBEzNBHWBQQBgDzDB9B1HBLmBBD7BBGCBXBBIdBF8BBWhCBE7F7FB1CBrbaagBaagBaagBaagBaa9B-PB4BDBzBHBCNBCBBp2BwNwNttCEE+DiOiOBvIvIBqBBFjDBNOBDOBCOBCkBBYgFB5BcBOrBBFIBIBBPFB7E4eBEQBEMBE5GBHLBFQQBKBF3BBJJBHnBBJdBDLBFBBPIBoB3KBJNBDMBEKBE4BBCFFBOBDLBFJBIyEBC7CBLAB",!1)),Sc:()=>new Y(Q("kB+D+DBCBqnB8D8DzPBBzPBBI2H2HoImSmS8sClmClmCBgBB37hBkuVkuVtD7E7E8GBBEBB3-HDB-4wBxtCxtC",!1)),Sk:()=>new Y(Q("+CCCoCHHFEEqQDBNNBGGBCCCBPB2DPPBjoBjoB15FCCBBBMCBOCBOCBOBB9kEBBkzdWBKBBoDBBxePPBniUniUBPB8bCCjF4g9B4g9BBDB",!1)),Sm:()=>new Y(Q("rBRRBBB+BCCuBFFmBgBgB-XwQwQBBB8xGOOoBCBOCBsEoBoBBDBHlClCBDBGBBFGDIgBgBBDDCgBgBBqIBhBBB7CffBXBpBFB2OKK3BHBwDxKxKBDBDeBLPBhIiEBX+BBFfBDhIBxBUBDFB9+zB5Z5ZCCBlFRRBBB+BCCkEHHBCBitDBBhrwBx+Bx+BagBgBagBgBagBgBagBgBat5Ft5FB-uC-uCBHB",!1)),So:()=>new Y(Q("mFDDFCCyerIrIBgEgEBvGvGLUUB4H4HkQ2L2LjEFBClElEwGqBqBoMCBQCCBBBDFBVECmEHBCFBCBBGDBmGBBxXJB0WzWzW+EhBBiLJBKIBksBBBCDBCBBLCCBHHBEBCECFMMBPPCBBC7B7BBKKBDBDDBCBBCBBCGBCeBDBBCCCBdBtIHBFTBDGBDwCBCdBanBBHnCBXKByCtCBX2FBCIBC1BBJuDBC3HBtBrBBhC-HBhQvBBWBBHmBBDpEBmHFBmLBBvBZBC4CBN1GBbPBFOOBNNWBBHBBxKBBFJBhBlBBKRRBdBMdBJQQBeBLmBBQ-JBhuG-BBx0V2BBibDBLBBC+R+RBBBqqUPBuLPBhCBB3BHBuBCBlPEEFBBOBB6JIB6BQBDCBCMBEwBwBBrBB7zBBBwSpgBpgBBGBnjC2kC2kCBGBFQBr6SDBG3qU3qUk7DvHBLCBEzNBHWBQPBhDzDB9B1HBLmBBD7BBGCBXBBIdBF8BBWhCBE7F7FB1CBqlB-PB4BDBzBHBCNBCBBp2B96C96CiEyWyWBqBBFjDBNOBDOBCOBCkBBYgFB5BcBOrBBFIBIBBPFB7E6HBG4WBEQBEMBE5GBHLBFQQBKBF3BBJJBHnBBJdBDLBFBB-B3KBJNBDMBEKBE4BBCFFBOBDLBFJBIyEBC7CBLAB",!1)),Z:()=>new Y(Q("gBgEgEgvFgsCgsCBJBeBBGwBwBh9DAB",!1)),Zl:()=>new Y(Q("ohIA",!0)),Zp:()=>new Y(Q("phIA",!0)),Zs:()=>new Y(Q("gBgEgEgvFgsCgsCBJBlBwBwBh9DAB",!1)),ASCII_Hex_Digit:()=>new Y(Q("wBJIFbF",!0)),Alphabetic:()=>new Y(Q("hCZBHZBwBLLFGGBVBCeBCpOBFLBPEBICC3CeeBQBCBBDDBCHHCCBCCCBSBCyCBCqEBJlFBClBBDHHBnBBoBNBCCCBCCBCCJaBFDBeKBG3BBCGBPlDBCHBFHBFCBLCBDRRBuBBOkDBZgBBKBBFGGBWBDSBUYBIKBGXBCGBIJJBoBBLLBEGBHrCBCPBCCBFOBOSBCHBDBBDVBCGBCEEBCBEHBDBBDBBCJJFBBCEBNBBLFFBBBCFBFBBDVBCGBCBBCBBCBBFEBFBBDBBFIIBCBCSSBEBMCBCIBCCBCVBCGBCBBCEBEIBCCBCBBEQQBCBWDBFCBCHBDBBDVBCGBCBBCEBEHBDBBDBBKBBFBBCEBORRBCCBEBECBCDBEBBCCCBEEBEEBBBELBFEBECBCCBEHHpBMBCCBCWBCPBEHBCCBCCBJBBCCBCBBDDBdDBCHBCCBCWBCJBCEBEHBCCBCCBJBBGCBCDBOCBNMBCCBCoBBDHBCCBCCBCGGBCBIEBXFBCCBCRBEXBCIBCDDBFBJFBCCCBGBTBBO5BBGGBH0B0BBECBDBCXBCCCBRBCCBDEBCHHPDBhBgCgCBGBCjBBFSBFPBCjBBkC2BBCDDBDBR-BBLDBDlBBCGGDqBBCsKBCDBDGBCCCBCBDoBBCDBDgBBCDBDGBCCCBCBDOBC4BBCDBDiCBmBPBR1CBDFBErTBDQBCZBGqCBEKBITBMUBNTBNMBCCBCBBNzBBDSBPFFkC4CBIqBBGlCBLeBCLBFIBYdBDEBMrBBFZB3BbBF+BBDTBzBYYBMMBBByBzBBCOBCHB0BpBBDDBLrBBCKBP2BBXCBLjBBDKBGqBBDCBqBDBCFBCBBEGGB+FBUhBBM1IBDFBDlBBDFBDHBCGCBdBD0BBCGBCEEBBBCGBEDBDFBFMBGCBCGB1DOORMBmDFFDJBCEEBDBHGCBCBCKBDDBGEBFSSBnBBuZzBB34BkHBHDBEBBNlBBCGGD3BBI
1986RRBVBKGBCGBCGBCGBCGBCGBCGBCGBCfBwB2O2OBBBaIBIEBDEBF1CBHCBC5CBCDBGqBBC9CBSfBxBPBhQ-tGBhCs0VBkCtBBDsIBEPBLBBVuBBGHBEwDBoBIBDmDBDxCBVUBCgBBZzBBNjCBCtBtBBEBECCBBBLgBBGiBBOcBEyBBCLBQRRBOBLEBC2BBKNBTWBEkCBCCCZCBDPBDDBMFBDFBDFBKGBCGBCqBBCNBH6DBWj9KBNWBFwBBloItLBDpDBnBGBNEBGLBCMBCEBCCCBCCBCCBqDBiBqLBT-BBD1BBpBLB1DEBCmEBlBZBHZBM4CBEFBDFBDFBDCBkBLBCZBCSBCBBCOBDNBjB6DBmC0BBsIcBEwBBwBfBOdBGqBBGdBDjBBFHBCEBrB9EBTjBBFjBBFnBBJzBBNKBCOBCGBCBBCKBCOBCGBCBBEzBBN2JBKVBLHBZFBCpBBCIBmCFBDCCBqBBCBBEDDBVBLWBKeBiCSBCBBLVBLZBHZBnB3BBHBBhCDBCBBGHBCCBCcBrBcBEcBkBHBCbBc1BBLVBLSBORBvDoCB4ByBBOyBBOnBBjBbBEGGBVB7HpBBCBBEBBRFBzBCBEcBLJJBUBrBRBvBUBcWBKlCBsBEBL4BBKOOBXBYyBBSDBJiBBEKKB+BBCDBKBBLCCkBRBChBBDHHBCB-BGBCCCBCBCOBCJBI4BBYDBCHBDBBDVBCGBCBBCEBEHBDBBDBBEHHGGBdJBCDDClBBCJBCDDCDBCBBECCtBhCBCCBCDBVCBfhCBDBBC5F5FB0BBDGBaFBjB+BBCEE8B1BBDoCoCBZBDNBWGB6F4BBoD-BBgBHBDDDBGBCBBCdBCBBDBBDDB+CHBDtBBDFBCCCBccBxBBDJBSnCBGTTBnCBoDHB5CgBBgBIBCsBBCGBCyByBBcBDVBCNBqCGBCBBCrBBECCBCCBBBCDDBZZBEBCBBCkBBCBBCDBCYYBqBBlIWBKQBCoBBECBwDwCwCB4cBnDuDBSjGBtyCgDBQvhBBSFBa68DBGmSB61GuBBy2B4RBIeBSuCBSdBTvBBRDBgBUBGSBxNsBB0G-BBhBYBDYBtBqCBF4BBIQBhCBBCNNBFBK1mHBqBfBiDyDB+vIDBCGBCBBCiJBQeeBBBDPPBCBJrMBloCqDBGMBEIBIJBFi7Fi7FBzCBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDYBCYBCeBCYBCeBCYBCeBCYBCeBCYBCHB15BeBHFB2GGBCQBDGBCBBCEBG9BBiBxDxDBrBBLGBRiKiKBcBTrBBlPbBlHdBDwGwGBdBCVBJBBhHGBCDBCBBCOBCkGB8BjCBEEE1lBDBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQB1TZBHZBHZB3zD-2pBBhB9oEBDt0FBDwpHBQtTBjtC9QBjvBq6EBGppIB",!1)),Dash:()=>new Y(Q("tB9qB9qB0BiyDiyDmgBqgCqgCBEB+BoBoBQnMnMlgDDDgBBBFdd-NUUwDxszBxszBBmBmBLqFqFhzD-J-J",!1)),Emoji:()=>new Y(Q("jBHHGJBwDFFu8HNN5GXX7CFBQBBwLBBNnFnFaKBFCBoGoHoHBLLK7B7BBCBCEBKGDBDDFDDCBBDIEBJJBBBGCCGLBMBBDCCBCCTDDBTTBEBCCCBEEBGGDBBFBBMBBGBBDGGBECBVVBGGBEBCDBDFFDDDBEBCDDCCCHEEHLLBQQDFFCFFBBBCMMBxBxBBBBKeP1LBBwOCBUBB0BFF7mBNN6SCCrrvDrGrGhFBBNBBPDDBIBsCZBCBBYVVDIBWBBvFhBBDvDBDBBCCBDyCBDCBCmIBC+BBMFBCXBIBBDHBNDDBCBDFFBOOBDDJBBKGGBBBNCBJCBDCCFHHEHHB0CBxBlCBGHBDDBEJBECCBEEDJBkHLBF8I8IBtBBCJBC4FBxDMBEKBE4BBCFFBOBDLBFJB",!1)),Emoji_Component:()=>new Y(Q("jBHHGJB0+H2G2Gsp3B3+8B3+8BBYB8PEBxtBDBtzhY-CB",!1)),Emoji_Modifier:()=>new Y(Q("7-8DE",!0)),Emoji_Modifier_Base:()=>new Y(Q("9wJ8G8GRDB4jzD9B9BBBBDDDBBB2DBBDKBWSBEFFBBBCCBICCZqGqGBFFWFFBvFvFBBBEEB0CRRBBBKMMgSDDJHBHKKBIBDCB5B+B+BBCCBCCSCBCMBmHCBrBIB",!1)),Emoji_Presentation:()=>new Y(Q("64IBBuGDBEDDqQBBWBBzBLBsBUUOJJBSSBGGBJJGWWIBBCFFDIIFBBdkBkBCFFBBBC+B+BBBBZPP8aBB0BFFvlxDrGrG-FDDBIBsCZBCZZVDDBDBCCBWBBvFgBBNIBClCBCVBNqBBFEBNQBEEEBlCBCCCB5FBD+BBODBCXBTbbBOO3C0CBxBlCBHEEBBBDDBEDBMBBIIBkHLBF8I8IBtBBCJBC4FBxDMBEKBE4BBCFFBOBDLBFJB",!1)),Extended_Pictographic:()=>new Y(Q("pFFFu8HNN5GXX7CFBQBBwLBBNnFnFaKBFCBoGoHoHBLLK7B7BBCBCEBKGDBDDFDDCBBDIEBJJBBBGCCGLBMBBDCCBCCTDDBTTBEBCCCBEEBGGDBBFBBMBBGBBDGGBECBVVBGGBEBCDBDFFDDDBEBCDDCCCHEEHLLBQQDFFCFFBBBCMMBxBxBBBBKeP1LBBwOCBUBB0BFF7mBNN6SCCrrvDoBoBBCBlDLBQBBQPPBmBmBBIBxDBBNBBPDDBIBU3BBcOBLVVDIBCDBKWBH7FBDvDBDBBCCBDyCBDCBCDBG9HBC+BBMFBCXBIBBDHBNDDBCBDFFBOOBDDJBBKGGBBBNCBJCBDCCFHHEHHB0CBxBlCBGHBDQBECCBEBDMB7GlBBNDB5BHBLFBpBHBfBBNDBDNBKmBBNuBBCJBC4FB5CHBPxEBhI9fB",!1)),Hex_Digit:()=>new Y(Q("wBJIFbFq1-BJIFbF",!0)),Lowercase:()=>new Y(Q("hDZBwBLLFlBlBBWBCHBC2BCBQCBuBCDECBBBDCCDEEBFFDEEBBBDDDCCCDCCBCCDEECDDBDDBBBHGDCOCBSCBDDCEEC4BCBFBDDDBCCFICBjCBDiBBIBBfEBhDsBsBCEEDDBTccBhBBCBBECBCWCBDBCGDB0B0BBuBBCgBCK0BCDMCBgDCxBoBBo6CqBBCDB5XFBjkCIBC2D2DB+FBiC0ECBHBCgDCBHBJFBLHBJHBJFBLHBJHBJNBDHBJHBJHBJEBCBBHEEBBBCBBJDBDBBJHBLCBCBB6DOORMBuDEEBEEcKFDBBJDBFiBiBBOBFsasaBYBn6BvBBCEEBGCFCCBCCBGBEiDCBIICFFNlBBCGG0oesBCUaCBBBmEMCBBBC8BCBIBCCCDICFCCDCCBBBCSCGGGCMCFCCDOCWDBCCCBBB2ZqBBCNBHvCBh6TGBNEBqhBZBumBnBBpEjBB8EKBCOBCGBCBBkODDBBBCpBBCIBmoByBB+DVB75CfBhsVfB8BYBnqZZBbGBCRBbZBbDBCCCBFBCKBbZBbZBbZBbZBbZBbZBbZBbZBbbBdYBCFBbYBCFBbYBCFBbYBCFBbYBCFBC15B15BBIBCTBHFBmI9BB1lChBB",!1)),Math:()=>new Y(Q("rBRRBBBgBeeCuBuBFmBmBgB5W5WBBBDbbBDDBBBwQCBuwGccBBBMEEOPPBCBWEBMEBiCMBFEEBFFBDBTFFDJBCDDBEBHEEBDDBCCBBBCFBENBClClCBWBCFBCBBFBBFfBCHHBPPBqIBJDBVBB7CffBZBCZZMGB+NBBNJBFFBFBBDBBEEBPCCDFBMHBGBB6BCCeDBKCBxK-BBhI-PBxBUBDFB9+zB4Z4ZBEBCjFjFRCBeCCeCCkEHHBCBitDBBhrwBwoBwoBBzCBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDjJBDxBBhwFDBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQB1BBB-uCIB",!1)),Quotation_Mark:()=>new Y(Q("iBFFkEQQ96HHBaBBowDqOqOBCBOCBixzBDB+FFF7CBB",!1)),Terminal_Punctuation:()=>new Y(Q("hBLLCMMBEE-ZJJiQ6B6BpCPPCCB1FsBsBBJBCsHsHB3B3BBEBCHBgBmImIB1nB1nBBtFtFFFB4JBB2YHBmY9D9DBBBoCBB+ECBEoBoBBCBDBB7JBBjLDBjFBBLBBCCBeCB8FEB-BBBldYYBKKBBBwlDCBzJOOFLLCBBEBBtNBB8ndBBuICBkHEB-LBB3CBBgD4E4EBBB0ECBgERRB6H6HnxUDDB6B6BBBBCDBqFLLCMMBEEiCDD7hBxBxBnkBoGoG3JBB5EFBlCFB6CDB5dEBtBDB+FGBxDDBgECBiEBBHRRB5C5CBDBtDrJrJB2D2DBBBNBBnLDBEOBqDBB6HCBmQCC8HBB4CBBFBB-MCBuBmUmUBrCrCBspBspBBDB6vRBBmEiCiCBBBLqRqRBoJoJBnwTnwTovHDB",!1)),Uppercase:()=>new Y(Q("hCZBmDWBCGBiB2BCDOCDuBCBECEBBCCCBCCBBBDDBCBBCCBEBBCBBCECBCCDCCBCCBBBCCCBEEIJDCMCDQCDDDCCBC4BCIBBCBBDCCBCBCGCiJCCEJJHCCBBBCCCBCCBPBCIBkBDDBBBEWCGDDCBBDyBBxBgBCK2BCBMCD+CCDlBBq6ClBBCGGzW1CB0kCHHBpBBDCBhK0ECKgDCKHBJFBLHBJHBJFBMGCJHBpCDBNDBNDBNEBMDBnIFFECBDCBDEEBDBHGCBCBDDBLBBGbbBOBUzZzZBYBx5BvBBxBCCB
1986BBDGCBCBCDDJCBCgDCJCCFuqeuqeCqBCUaCoEMCE8BCLECBICFCCDCCEUCBDBCEBCOCBCBCCCBQCZs5Vs5VBYBmmBnBBpEjBB9EKBCOBCGBCBBr3ByBB+EVB75CfBhsVfBhCYBoqZZBbZBbZBbCCBGDBDDBCBCHBbZBbBBCDBDHBCGBcBBCDBCEBCEEBFBcZBbZBbZBbZBbZBbZBfYBiBYBiBYBiBYBiBYBiB2pE2pEBgBBvgCZBHZBHZB",!1)),White_Space:()=>new Y(Q("JEBTlDlDbgvFgvFgsCKBeBBGwBwBh9DAB",!1))})),Ie(jo,"SCRIPTS",new bm({Adlam:()=>new Y(Q("go6DrCFJFB",!0)),Ahom:()=>new Y(Q("g4lCaDOFW",!0)),Anatolian_Hieroglyphs:()=>new Y(Q("ggxCmS",!0)),Arabic:()=>new Y(Q("gwBEBCFBCNBCCBCfBCJBMZBCrDBChBBxCvBBxHhBBGqCBCcBxy8BtPBDvEBhBPBxDEBCmEBk7DeBkCFBJIBiBFBh43BDBCaBCBBCDDCJBCDBCCCHFFCECBBBCBBCDDCICBCCDDBCGBCDBCDBCCCBIBCQBGCBCEBCQB1BBB",!1)),Armenian:()=>new Y(Q("xpBlBDxBDCks9BE",!0)),Avestan:()=>new Y(Q("g4iC1BEG",!0)),Balinese:()=>new Y(Q("g4GsCCxB",!0)),Bamum:()=>new Y(Q("g1pB3CpowB4R",!0)),Bassa_Vah:()=>new Y(Q("w26CdDF",!0)),Batak:()=>new Y(Q("g+GzBJD",!0)),Bengali:()=>new Y(Q("gsCDBCHBDBBDVBCGBCEEBCBDIBDBBDDBJFFBCCBDBDYB",!1)),Beria_Erfe:()=>new Y(Q("g17CYDY",!0)),Bhaiksuki:()=>new Y(Q("ggnCICsBCNLc",!0)),Bopomofo:()=>new Y(Q("qXB6wLqBxDf",!0)),Brahmi:()=>new Y(Q("ggkCtCFjBKA",!0)),Braille:()=>new Y(Q("ggK-H",!0)),Buginese:()=>new Y(Q("gwGbDB",!0)),Buhid:()=>new Y(Q("g6FT",!0)),Canadian_Aboriginal:()=>new Y(Q("ggF-TxRlC7tgCP",!0)),Carian:()=>new Y(Q("g1gCwB",!0)),Caucasian_Albanian:()=>new Y(Q("wphCzBMA",!0)),Chakma:()=>new Y(Q("gokC0BCR",!0)),Cham:()=>new Y(Q("gwqB2BKNDJDD",!0)),Cherokee:()=>new Y(Q("g9E1CDFz7lBvC",!0)),Chorasmian:()=>new Y(Q("w9jCb",!0)),Common:()=>new Y(Q("AgCBbFBbuBBCOBCEBYgBgBiOmBBGEBDTB1DKKHCC+THHPEEhB9E9ElQiEiEB6mB6mB2MDBjJwvBwvBBBBoCBBsGBBCumBumBOIIBCBCFBCCBDmYmYBKBD2CBCKBEKBCOBShBB-BlBBCCBDFBCaBCQBqBCBF5UBXKBW-cBhIzTBDpEBhQ9CBzMUBCCCBXBQHBFDB8CBBE7C7CB0E0EBOBhBlBBKxBxBB+BBgBwCBwB5C5CBmFBhuG-BBhoWhBBnDCBmFJB1HhFhFsMPPBzuUzuUBxGxGBIBXiBBCSBCDB0ECCBeBbFBbKBLuBuBBhChCBFBCGBLEBjICBFsBBEIBxCMB0BsBBlHaBltuBDB96D8HBEzNBHWBQQBgDzDB9B1HBLmBBD9BBEQBJBBIdBF8BB2GTBNTBN2CBKYBoE0CBCmCBCBBDDDBDDBCBCLBCCCBFBCgCBCDBDHBCGBCbBCDBCEBCEEBFBCzKBDjJBDxBByjFjCBtC8BBjWrBBFjDBNOBDOBCOBCkBBLtFB5BZBCBBOrBBFIBIBBPFB7E4eBEQBEMBE5GBHLBFQQBKBF3BBJJBHnBBJdBDLBFBBPIBoB3KBJNBDMBEKBE4BBCFFBOBDLBFJBIyEBCmDBnghYffB+CB",!1)),Coptic:()=>new Y(Q("ifNxkKzDGG",!0)),Cuneiform:()=>new Y(Q("ggoC5cnDuDCEMjG",!0)),Cypriot:()=>new Y(Q("ggiCFBDCCBqBBCBBEDD",!1)),Cypro_Minoan:()=>new Y(Q("w8rCiD",!0)),Cyrillic:()=>new Y(Q("ggBkEBDoFBx6FKBhFtCtCojEfBhie-CBv8VBBhw4B9BBiBAB",!1)),Deseret:()=>new Y(Q("gghCvC",!0)),Devanagari:()=>new Y(Q("goCwCFODZh7nBfhwcJ",!0)),Dives_Akuru:()=>new Y(Q("gomCGBDDDBGBCBBCdBCBBDLBKJB",!1)),Dogra:()=>new Y(Q("ggmC7B",!0)),Duployan:()=>new Y(Q("ggvDqDGMEIIJDD",!0)),Egyptian_Hieroglyphs:()=>new Y(Q("ggsC1iBL68D",!0)),Elbasan:()=>new Y(Q("gohCnB",!0)),Elymaic:()=>new Y(Q("g-jCW",!0)),Ethiopic:()=>new Y(Q("gwEoCBCDBDGBCCCBCBDoBBCDBDgBBCDBDGBCCCBCBDOBC4BBCDBDiCBDfBEZBnvGWBKGBCGBCGBCGBCGBCGBCGBCGBjpfFBDFBDFBKGBCGBylvCGBCD
1986BCBBCOB",!1)),Garay:()=>new Y(Q("gqjClBEcJB",!0)),Georgian:()=>new Y(Q("glElBBCGGDqBBCDBx8CqBBDCBhiElBBCGG",!1)),Glagolitic:()=>new Y(Q("ggL-Ch9sDGCQDGCBCE",!0)),Gothic:()=>new Y(Q("w5gCa",!0)),Grantha:()=>new Y(Q("g4kCDBCHBDBBDVBCGBCBBCEBDIBDBBDCBDHHGGBDGBEEB",!1)),Greek:()=>new Y(Q("wbDBCCBDDBCFFCCCBBBCCCBSBC+BBPPBnpGEBzBEBFEB1ChKhKBUBDFBDlBBDFBDHBCGCBdBD0BBCOBCNBDFBCSBDCBCIBoJ-xiB-xiB7uVuCBSgj0Bgj0BBkCB",!1)),Gujarati:()=>new Y(Q("h0CCBCIBCCBCVBCGBCBBCEBDJBCCBCCBDQQBCBDLBIGB",!1)),Gunjala_Gondi:()=>new Y(Q("grnCFCBCkBCBCFIJ",!0)),Gurmukhi:()=>new Y(Q("hwCCBCFBFBBDVBCGBCBBCBBCBBDCCBDBFBBDCBEIIBCBCIIBPB",!1)),Gurung_Khema:()=>new Y(Q("go4C5B",!0)),Han:()=>new Y(Q("g0LZBC4CBN1GBwBCCaIBPDBle-tGBhC-vUBhoWtLBDpDBpodBBNGBqgkB-2pBBhB9oEBDt0FBDwpHBQtTBjtC9QBjvBq6EBGppIB",!1)),Hangul:()=>new Y(Q("goE-HvxHBiI9CyDeiCei3dckUj9KNWFwBl9JeEFDFDFDC",!0)),Hanifi_Rohingya:()=>new Y(Q("gojCnBJJ",!0)),Hanunoo:()=>new Y(Q("g5FU",!0)),Hatran:()=>new Y(Q("gniCSCBGE",!0)),Hebrew:()=>new Y(Q("xsB2BBJaBFFBpp9BZBCEBCCCBCCBCCBIB",!1)),Hiragana:()=>new Y(Q("hiM1CBHCBi7-C+IBTeeBBBulQAB",!1)),Imperial_Aramaic:()=>new Y(Q("giiCVCI",!0)),Inherited:()=>new Y(Q("gYvDB2IBBlOKBbhXhXBCB8qEtBBDLBlPCBCMBCGBFHHEBBnG-BBtQBBjGgBB65DDBsDBBmrzBPBRNBwejHjH7iEl+uBl+uBBsBBDWBhRCBSHBDGBfDBz6rYvHB",!1)),Inscriptional_Pahlavi:()=>new Y(Q("g7iCSGH",!0)),Inscriptional_Parthian:()=>new Y(Q("g6iCVDH",!0)),Javanese:()=>new Y(Q("gsqBtCDJFB",!0)),Kaithi:()=>new Y(Q("gkkCiCLA",!0)),Kannada:()=>new Y(Q("gkDMCCCWCJCEDICCCDIBGCCDDJCC",!0)),Katakana:()=>new Y(Q("hlM5CBDCBxHPBxGuBBC3CBvgzBJBCsBBzisBDBCGBCBBCgJgJBBBzBPPBCB",!1)),Kawi:()=>new Y(Q("g4nCQCoBEc",!0)),Kayah_Li:()=>new Y(Q("goqBtBCA",!0)),Kharoshthi:()=>new Y(Q("gwiCDCBGHCCCcDCFJII",!0)),Khitan_Small_Script:()=>new Y(Q("k-7C84G84GB0OBqBAB",!1)),Khmer:()=>new Y(Q("g8F9CDJHJnPf",!0)),Khojki:()=>new Y(Q("gwkCRCuB",!0)),Khudawadi:()=>new Y(Q("w1kC6BGJ",!0)),Kirat_Rai:()=>new Y(Q("gq7C5B",!0)),Lao:()=>new Y(Q("h0DBBCCCBDBCXBCCCBVBDEBCCCBFBCJBDDB",!1)),Latin:()=>new Y(Q("hCZBHZBwBQQGWBCeBCgOBoBEB8wGlBBHwBBGDBGMBClCBiC-HByLOORMBuEBBHccSoBB42CfBj1elDBExCBVOBxZqBBCIBCDB38TGB7gBZBHZBmhCFBCpBBCIBm61BeBHFB",!1)),Lepcha:()=>new Y(Q("ggH3BEOEC",!0)),Limbu:()=>new Y(Q("goGeBCLBFLBFEEBKB",!1)),Linear_A:()=>new Y(Q("gwhC2JKVLH",!0)),Linear_B:()=>new Y(Q("gggCLCZCSCBCODNjB6D",!0)),Lisu:()=>new Y(Q("wmpBvBx1eA",!0)),Lycian:()=>new Y(Q("g0gCc",!0)),Lydian:()=>new Y(Q("gpiCZGA",!0)),Mahajani:()=>new Y(Q("wqkCmB",!0)),Makasar:()=>new Y(Q("g3nCY",!0)),Malayalam:()=>new Y(Q("goDMCCCyBCCCFFPDZ",!0)),Mandaic:()=>new Y(Q("giCbDA",!0)),Manichaean:()=>new Y(Q("g2iCmBFL",!0)),Marchen:()=>new Y(Q("wjnCfDVCN",!0)),Masaram_Gondi:()=>new Y(Q("gonCGBCBBCrBBECCBCCBHBJJB",!1)),Medefaidrin:()=>new Y(Q("gy7C6C",!0)),Meetei_Mayek:()=>new Y(Q("g3qBWqGtBDJ",!0)),Mende_Kikakui:()=>new Y(Q("gg6DkGDP",!0)),Meroitic_Cursive:()=>new Y(Q("gtiCXFTDtB",!0)),Meroitic_Hieroglyphs:()=>new Y(Q("gsiCf",!0)),Miao:()=>new Y(Q("g47CqCF4BIQ",!0)),Modi:()=>new Y(Q("gwlCkCMJ",!0)),Mongolian:()=>new Y(Q("ggGBBDCCBSBH4CBIqBB2t-BMB",!1)),Mro:()=>new Y(Q("gy6CeCJFB",!0)),Multani:()=>new Y(Q("g0kCGBCCCBCBCOBCKB",!1)),Myanmar:()=>new Y(Q("ggE-EhqmBeiDfxibT",!0)),Nabataean:()=>new Y(Q("gkiCeJI",!0)),Nag_Mundari:()=>new Y(Q("wm5DpB",!0)),Nandinagari:()=>new Y(Q("gtmCHDtBDK",!0)),New_Tai_Lue:()=>new Y(Q("gsGrBFZHKEB",!0)),Newa:()=>new Y(Q("gglC7CCE",!0)),Nko:()=>new Y(Q("g+B6BDC",!0)),Nushu:()=>new Y(Q("h-7CvsQvsQBqMB",!1)),Nyiakeng_Puachue_Hmong:()=>new Y(Q("go4DsBENDJFB",!0)),Ogham:()=>new Y(Q("g0Fc",!0)),Ol_Chiki:()=>new Y(Q("wiHvB",!0)),Ol_Onal:()=>new Y(Q("wu5DqBFA",!0)),Old_Hungarian:()=>new Y(Q("gkjCyBOyBIF",!0)),Old_Italic:()=>new Y(Q("g4gCjBKC",!0)),Old_North_Arabian:()=>new Y(Q("g0iCf",!0)),Old_Permic:()=>new Y(Q("w6gCqB",!0)),Old_Persian:()=>new Y(Q("g9gCjBFN",!0)),Old_Sogdian:()=>new Y(Q("g4jCnB",!0)),Old_South_Arabian:()=>new Y(Q("gziCf",!0)),Old_Turkic:()=>new Y(Q("ggjCoC",!0)),Old_Uyghur:()=>new Y(Q("w7jCZ",!0)),Oriya:()=>new Y(Q("h4CCCHDBDVCGCBCEDIDBDCICFBCEDR",!0)),Osage:()=>new Y(Q("wlhCjBFjB",!0)),Osmanya:()=>new Y(Q("gkhCdDJ",!0)),Pahawh_Hmong:()=>new Y(Q("g46ClCLJCGCUGS",!0)),Palmyrene:()=>new Y(Q("gjiCf",!0)),Pau_Cin_Hau:()=>new Y(Q("g2mC4B",!0)),Phags_Pa:()=>new Y(Q("giqB3B",!0)),Phoenician:()=>new Y(Q("goiCbEA",!0)),Psalter_Pahlavi:()=>new Y(Q("g8iCRIDNG",!0)),Rejang:()=>new Y(Q("wpqBjBMA",!0)),Runic:()=>new Y(Q("g1FqCEK",!0)),Samaritan:()=>new Y(Q("ggCtBDO",!0)),Saurashtra:()=>new Y(Q("gkqBlCJL",!0)),Sharada:()=>new Y(Q("gskC-ChsCH",!0)),Shavian:()=>new Y(Q("wihCvB",!0)),Siddham:()=>new Y(Q("gslC1BDlB",!0)),Sidetic:()=>new Y(Q("gqiCZ",!0)),SignWriting:()=>new Y(Q("gg2DrUQECO",!0)),Sinhala:()=>new Y(Q("hsDCBCRBEXBCIBCDDBFBEFFBEBCCCBGBHJBDCBt-gCTB",!1)),Sogdian:()=>new Y(Q("w5jCpB",!0)),Sora_Sompeng:()=>new Y(Q("wmkCYIJ",!0)),Soyombo:()=>new Y(Q("wymCyC",!0)),Sundanese:()=>new Y(Q("g8G-BhIH",!0)),Sunuwar:()=>new Y(Q("g+mChBPJ",!0)),Syloti_Nagri:()=>new Y(Q("ggqBsB",!0)),Syriac:()=>new Y(Q("g4BNC7BDCxIK",!0)),Tagalog:()=>new Y(Q("g4FVKA",!0)),Tagbanwa:()=>new Y(Q("g7FMCCCB",!0)),Tai_Le:()=>new Y(Q("wqGdDE",!0)),Tai_Tham:()=>new Y(Q("gxG+BCcDKHJHN",!0)),Tai_Viet:()=>new Y(Q("g0qBiCZE",!0)),Tai_Yo:()=>new Y(Q("g25DeCVJB",!0)),Takri:()=>new Y(Q("g0lC5BHJ",!0)),Tamil:()=>new Y(Q("i8CBBCFBECBCDBEBBCCCBEEBEEBBBELBFEBECBCDBDHHPUBm+kCxBBOAB",!1)),Tangsa:()=>new Y(Q("wz6CuCCJ",!0)),Tangut:()=>new Y(Q("g-7CgBgBB+3GBhQeBiDyDB",!1)),Telugu:()=>
1986new Y(Q("ggDMCCCWCPDICCCDIBCCCBDDDJII",!0)),Thaana:()=>new Y(Q("g8BxB",!0)),Thai:()=>new Y(Q("hwD5BGb",!0)),Tibetan:()=>new Y(Q("g4DnCCjBFmBCjBCOCGFB",!0)),Tifinagh:()=>new Y(Q("wpL3BIBPA",!0)),Tirhuta:()=>new Y(Q("gklCnCJJ",!0)),Todhri:()=>new Y(Q("guhCzB",!0)),Tolong_Siki:()=>new Y(Q("wtnCrBFJ",!0)),Toto:()=>new Y(Q("w04De",!0)),Tulu_Tigalari:()=>new Y(Q("g8kCJBCDDClBBCJBCDDCDBCJBCBBJBB",!1)),Ugaritic:()=>new Y(Q("g8gCdCA",!0)),Unknown:()=>new Y(Q("4bBBHDBICCVuMuMnBBBzBBBE4B4BBGBcDBHKBvI9B9BBmDmDBMB8BBByBBBQddBCCMEBjBEBuHJJBDDBXXICCBBBFBBKBBDBBFHBCDBDGGBaaBEEHDBDBBXIIDGDBCCGDBDBBECBCGBFCCBFBSJBEKKEXXIDDGBBLIEBCCBNBFBBNGBIEEJBBDBBXIIDGGBKKBDDBEEBFBEDBDGGBTTBIBDHHBBBEFFBBBDCCDCBDCBECBNDBGCBEFFBCCBEBCNBWEBOEEYRRBKKEFFBFBDEEDBBFBBLGBXEEYLLGBBKEEFGBDEBEFFBLLELBOEE0BEEHDBRBBbEETCBZKKCBBICBCDBHCCJFBLBBELB7BDBekBBDCCGZZCYYBGGCIILBBFfBpClBlBBCBoBlBlBQOOBjBBnGCCBDBCBB6LFFBIICFFBqBqBFBBiBFFBIICFFBQQ6BFFBkCkCBhBhBBBBbFB3CBBHBB+UCB6CGBXIBZIBVLBOEEDLB-CBBLFBLFBbFB6CGBsBEBnCJBgBNNBCBNDBCCBrBBBGKBtBDBbFBMCB-BBBiCeeBMMBEBLFBPBBvBBBNTBuCnFnFBGB9BCBQCB-BEBsBBBMHBsBEB3QBBHBBnBBBHBBJGCgBBB2BQQPBBHUUBEEKmDmDNBBcOOBBBjBNBiBOBtEDB7UVBMUB14BBB-LEBuBCCBDBCBB5BGBDNBZIBI4BI-DhBBb6C6CBKB3GZBxC3C3CBoDoDBDBsB-C-C3CIBxBuzcuzcBBB4BIB9KTB5FHB+GTB9BCBLFB5BHBnCHBNFB1DKBfCBvCMMBCBiB4B4BBHBPBBLBBoDXBdJBHBBHBBHIBIII9BDB-DBBLFBl9KLBYDByBjoIBvLBBrDlBBILBGEBbGGCGDrUfBrBFB0BUUFDBGoEoEBCC-FCBHBBHBBHBBECBIIIBIBGBBNbbUDDQBBPhBB8DEBEDBuBCB5COOBBBCuBBvBhEBeCByBOBdDBlBIBfEBsBEBfmBmBBCBPpBB-EBBLFBlBDBlBDBpBHB1BKBNQQIDDMQQIDDBBB1BLB4JIBXJBJXBHrBrBKkCBHBBCtBtBDCBCBBYpCpCBGBKvBBUDDBDBiBCBcEBclBB5BDBVBBzBDDBDBJEEeBBEDBLGBKGBhCfBoBDBNIB3BCBeBBcEBbGBFLBIvCBqC2BB0BMB0BGBvBHBLFBnBCBeHBDvGBgBrBrBEBBDPBHHBKgBBvBHBrBVBblBBdTBYIBvCDBlBIBlCJBCBBaGBLFB2BTTBGBoBIBhDVVBJBTwBwBB8BBICCFQQMFB8BEBLFBFJJBDDBXXIDDGLLBDDBEEBCCBEBCEBIBBICBGKBLCCBCCnBLLCBBCFFLDDBGBDcB9CGGBcBpCHBLlFB3BBBnBhBBmCKBLFBOSB7BFBLFBVbBcBBQDBY4FB9BjDB0CLBJBBCBBJDDfDDBNNBHBLlCBJBBvBBBMaBpCHB0CMBqCGBL1CBJ3CBjBNBLFBKuBuBPJBeCBhBBBXPPBnCBIDDtBCBCDDKHBLFBHDDmBDDHGBLFBtBDBL1HBaGBSqBqBBBBe0CBCOBzBMB8clDBwDGGBJBlGryCBkDMB3iBJB88DEBoS41GB7Bl2BB6RGBgBLLBCByCLLBEBfBBHJBnCJBLIIWEBUvNB7BlGB8CEBaBBarBBsCDB6BGBS-BBGKBIIB3mHoBBhBgDB0D8vIBFIIDkJkJBNBCcBEBBCNBFHBtMjoCBsDEBOCBKGBLBBJ76DB+HCB1NFBYOBSOBvBBBYIB1D7BB3HJBoBBBjGUBnC5DBVLBVLB4CIBamEB2CoCoCDBBCBBDBBFNNCIIiCFFBJJIddFGGCCBI1K1KBlJlJB-V-VBNBGQQBuiBBgBFBH0GBISSBIIDGGBDB-BgBBCvDBuBCBPBBLDBD-JBgBQB7BEBCvOBrB1GBsBDBC-FBgBXXBGBD-GBIFFDQQmGBBRoBBtCDBLDBDwYBlCrCB+BhGBFccDCCBCCLFFCCCBEBCDBCECEDDCBBCICDCCBFFIKFCLLSEBEGGSzBBDtIBtBDBlDLBQBBQQQmBJBvF3BBeMBtBDBKGBDNBH5EB6eCBSCBOCB7GFBNDBCOBNDB5BHBLFBpBHBfBBNDBDNBKmBB5KHBPBBOCBMCB6BCCBCBRBBND
1986BLGB0EoDoDBjgBBh3pBfB-oEBBv0FBBypHOBvThtCB-QhvBBs6EEBrpIm8yVBCdBhD-DBxHvw-FB",!1)),Vai:()=>new Y(Q("gopBrJ",!0)),Vithkuqi:()=>new Y(Q("wrhCKCOCGCBCKCOCGCB",!0)),Wancho:()=>new Y(Q("g24D5BGA",!0)),Warang_Citi:()=>new Y(Q("glmCyCNA",!0)),Yezidi:()=>new Y(Q("g0jCpBCCDB",!0)),Yi:()=>new Y(Q("ggoBskBE2B",!0)),Zanabazar_Square:()=>new Y(Q("gwmCnC",!0))})),Ie(jo,"FOLD_CATEGORIES",new bm({L:()=>new Y(Q("laA",!0)),LC:()=>new Y(Q("laA",!0)),Ll:()=>new Y(Q("hCZBmDWBCGBiBuBCEECDOCDuBCBECEBBCCCBCCBBBDDBCBBCCBEBBCBBCECBCCDCCBCCBBBCCCBEEIBBCBBCBBCOCDQCDBBCCCBBBC4BCIBBCBBDCCBCBCGC3HrBrBCEEJHHCCBCCCBCCBPBCIBkBJJCUCGDDCBBDyBBxBgBCK2BCBMCD+CCDlBBq6ClBBCGGzW1CB0kCHHBpBBDCBhK0ECKgDCKHBJFBLHBJHBJFBMGCJHBZHBJHBJHBJEBMEBMDBNEBMEBqJEEBHHxC9zC9zCBuBBxBCCBBBDGCBCBCDDJCBCgDCJCCFuqeuqeCqBCUaCoEMCE8BCLECBICFCCDCCEUCBDBCEBCOCBCBCCCBQCZs5Vs5VBYBmmBnBBpEjBB9EKBCOBCGBCBBr3ByBB+EVB75CfBhsVfBhCYBoyehBB",!1)),Lt:()=>new Y(Q("kOCCBCCBCClBCCtsHHBJHBJHBMQQwBAB",!1)),Lu:()=>new Y(Q("hDZB7BqBqBBWBCHBCuBCEECDOCDsBCDECBBBDCCDEEGDDECBDDDCCCDFFDEECDDECCGBBCBBCBBCOCBSCDBBCEECkBCEQCJDDBCCFICBEBCBBCCCBEEBCCBCBCEBDCCBDDIDDCBBEFBGLLBnFnFsBCCEEEBBBvBDBCdBCBBECBCWCBDBCGD1BvBBCgBCK0BCDMCBgDCyBlBBq6CqBBDCB5XFBjkCIBCvHvHERRzD0ECGGGC8CCBHBJFBLHBJHBJFBMGCJHBJNBzBBBNSSBPPBEEpL2B2Bs1CvBBCEEBGCHDDLiDCJCCFNNBkBBCGG0oesBCUaCoEMCE8BCLCCDICFFFCBBDSCMOCFCCDOCb9a9advCBi8UZBumBnBBpEjBB8EKBCOBCGBCBBk4ByBB+DVB75CfBhsVfB8BYBvyehBB",!1)),M:()=>new Y(Q("5cgBgBlgHAB",!1)),Mn:()=>new Y(Q("5cgBgBlgHAB",!1)),Emoji:()=>new Y(Q("8mJA",!0)),Extended_Pictographic:()=>new Y(Q("8mJA",!0)),Lowercase:()=>new Y(Q("hCZBmDWBCGBiBuBCEECDOCDuBCBECEBBCCCBCCBBBDDBCBBCCBEBBCBBCECBCCDCCBCCBBBCCCBEEIBBCBBCBBCOCDQCDBBCCCBBBC4BCIBBCBBDCCBCBCGCiJCCEJJHCCBBBCCCBCCBPBCIBkBJJCUCGDDCBBDyBBxBgBCK2BCBMCD+CCDlBBq6ClBBCGGzW1CB0kCHHBpBBDCBhK0ECKgDCKHBJFBLHBJHBJFBMGCJHBZHBJHBJHBJEBMEBMDBNEBMEBqJEEBHHuBPBUzZzZBYBx5BvBBxBCCBBBDGCBCBCDDJCBCgDCJCCFuqeuqeCqBCUaCoEMCE8BCLECBICFCCDCCEUCBDBCEBCOCBCBCCCBQCZs5Vs5VBYBmmBnBBpEjBB9EKBCOBCGBCBBr3ByBB+EVB75CfBhsVfBhCYBoyehBB",!1)),Math:()=>new Y(Q("ycGDCHHFMMDDDCHHFAB",!1)),Uppercase:()=>new Y(Q("hDZB7BqBqBBWBCHBCuBCEECDOCDsBCDECBBBDCCDEEGDDECBDDDCCCDFFDEECDDECCGBBCBBCBBCOCBSCDBBCEECkBCEQCJDDBCCFICBEBCBBCCCBEEBCCBCBCEBDCCBDDIDDCBBEFBGLLBnFnFsBCCEEEBBBvBDBCdBCBBECBCWCBDBCGD1BvBBCgBCK0BCDMCBgDCyBlBBq6CqBBDCB5XFBjkCIBCvHvHERRzD0ECGGGC8CCBHBJFBLHBJHBJFBMGCJHBJNBzBBBNSSBPPBEEpLiBiBBOBFsasaBYBn6BvBBCEEBGCHDDLiDCJCCFNNBkBBCGG0oesBCUaCoEMCE8BCLCCDICFFFCBBDSCMOCFCCDOCb9a9advCBi8UZBumBnBBpEjBB8EKBCOBCGBCBBk4ByBB+DVB75CfBhsVfB8BYBvyehBB",!1))})),Ie(jo,"FOLD_SCRIPT",new bm({Common:()=>new Y(Q("8cgBgB",!1)),Greek:()=>new Y(Q("1FwUwU",!1)),Inherited:()=>new Y(Q("5cgBgBlgHAB",!1))})),jo),Bn,Ge=(Bn=class{static is32(e,t){let r=0,s=e.length;for(;r<s;){const a=r+Math.floor((s-r)/2),c=e.getLo(a),u=e.getHi(a);if(c<=t&&t<=u){const h=e.getStride(a);return(t-c)%h===0}t<c?s=a:r=a+1}return!1}static is(e,t){if(t<=Bn.MAX_LATIN1){for(let r=0;r<e.length;r++){if(t>e.getHi(r))continue;const s=e.getLo(r);if(t<s)return!1;const a=e.getStride(r);return(t-s)%a===0}return!1}return e.length>0&&t>=e.getLo(0)&&Bn.is32(e,t)}static isUpper(e){if(e<=Bn.MAX_LATIN1){const t=String.fromCodePoint(e);return t.toUpperCase()===t&&t.toLowerCase()!==t}return Bn.is(Es.Upper,e)}static isPrint(e){return e<=Bn.MAX_LATIN1?e>=32&&e<Bn.MAX_ASCII||e>=161&&e!==173:Bn.is(Es.Print,e)}static simpleFold(e){if(Es.CASE_ORBIT.has(e))return Es.CASE_ORBIT.get(e);const t=ye.toLowerCase(e);return t!==e?t:ye.toUpperCase(e)}static equalsIgnoreCase(e,t){if(e===t)return!0;if(e<0||t<0)return!1;if(e<=Bn.MAX_ASCII&&t<=Bn.MAX_ASCII)return 65<=e&&e<=90&&(e|=32),65<=t&&t<=90&&(t|=32),e===t;for(let r=Bn.simpleFold(e);r!==e;r=Bn.simpleFold(r))if(r===t)return!0;return!1}},Ie(Bn,"MAX_RUNE",1114111),Ie(Bn,"MAX_ASCII",127),Ie(Bn,"MAX_LATIN1",255),Ie(Bn,"MAX_BMP",65535),Ie(Bn,"MIN_FOLD",65),Ie(Bn,"MAX_FOLD",125251),Ie(Bn,"MIN_HIGH_SURROGATE",55296),Ie(Bn,"MAX_HIGH_SURROGATE",56319),Ie(Bn,"MIN_LOW_SURROGATE",56320),Ie(Bn,"MAX_LOW_SURROGATE",57343),Ie(Bn,"MIN_SUPPLEMENTARY_CODE_POINT",65536),Bn);const vx=256,lD=new Uint8Array(vx);for(let n=0;n<vx;n++)lD[n]=97<=n&&n<=122||65<=n&&n<=90||48<=n&&n<=57||n===95?1:0;let HB=null,qB=null;var Dn,Ze=(Dn=class{static emptyInts(){return[]}static isByteArray(e){return Array.isArray(e)||e instanceof Uint8Array}static isalnum(e){return ye.CODES.get("0")<=e&&e<=ye.CODES.get("9")||ye.CODES.get("a")<=e&&e<=ye.CODES.get("z")||ye.CODES.get("A")<=e&&e<=ye.CODES.get("Z")}static unhex(e){return ye.CODES.get("0")<=e&&e<=ye.CODES.get("9")?e-ye.CODES.get("0"):ye.CODES.get("a")<=e&&e<=ye.CODES.get("f")?e-ye.CODES.get("a")+10:ye.CODES.get("A")<=e&&e<=ye.CODES.get("F")?e-ye.CODES.get("A")+10:-1}static escapeRune(e){let t="";if(Ge.isPrint(e))Dn.METACHARACTERS.indexOf(String.fromCodePoint(e))>=0&&(t+="\\"),t+=String.fromCodePoint(e);else switch(e){case ye.CODES.get('"'):t+='\\"';break;case ye.CODES.get("\\"):t+="\\\\";break;case ye.CODES.get("	"):t+="\\t";break;case ye.CODES.get(`
1987`):t+="\\n";break;case ye.CODES.get("\r"):t+="\\r";break;case ye.CODES.get("\b"):t+="\\b";break;case ye.CODES.get("\f"):t+="\\f";break;default:{let r=e.toString(16);e<256?(t+="\\x",r.length===1&&(t+="0"),t+=r):t+=`\\x{${r}}`;break}}return t}static stringToRunes(e){const t=String(e),r=[];let s=0;for(;s<t.length;){const a=t.codePointAt(s);
1987r.push(a),s+=a>Ge.MAX_BMP?2:1}return r}static runeToString(e){return String.fromCodePoint(e)}static isWordRune(e){return e<vx?lD[e]===1:!1}static emptyOpContext(e,t){let r=0;return e<0&&(r|=Dn.EMPTY_BEGIN_TEXT|Dn.EMPTY_BEGIN_LINE),e===10&&(r|=Dn.EMPTY_BEGIN_LINE),t<0&&(r|=Dn.EMPTY_END_TEXT|Dn.EMPTY_END_LINE),t===10&&(r|=Dn.EMPTY_END_LINE),Dn.isWordRune(e)!==Dn.isWordRune(t)?r|=Dn.EMPTY_WORD_BOUNDARY:r|=Dn.EMPTY_NO_WORD_BOUNDARY,r}static quoteMeta(e){return e.split("").map(t=>Dn.METACHARACTERS.indexOf(t)>=0?`\\${t}`:t).join("")}static charCount(e){return e>Ge.MAX_BMP?2:1}static toArray(e){const t=e.length,r=new Array(t);for(let s=0;s<t;s++)r[s]=e[s];return r}static stringToUtf8ByteArray(e){if(globalThis.TextEncoder)return HB||(HB=new TextEncoder),HB.encode(e);{let t=[],r=0;for(let s=0;s<e.length;s++){let a=e.charCodeAt(s);a<128?t[r++]=a:a<2048?(t[r++]=a>>6|192,t[r++]=a&63|128):(a&64512)===Ge.MIN_HIGH_SURROGATE&&s+1<e.length&&(e.charCodeAt(s+1)&64512)===Ge.MIN_LOW_SURROGATE?(a=Ge.MIN_SUPPLEMENTARY_CODE_POINT+((a&1023)<<10)+(e.charCodeAt(++s)&1023),t[r++]=a>>18|240,t[r++]=a>>12&63|128,t[r++]=a>>6&63|128,t[r++]=a&63|128):(t[r++]=a>>12|224,t[r++]=a>>6&63|128,t[r++]=a&63|128)}return t}}static utf8ByteArrayToString(e){if(globalThis.TextDecoder){qB||(qB=new TextDecoder("utf-8"));const t=e instanceof Uint8Array?e:new Uint8Array(e);return qB.decode(t)}else{let t=[],r=0,s=0;for(;r<e.length;){let a=e[r++];if(a<128)t[s++]=String.fromCharCode(a);else if(a>191&&a<224){let c=e[r++];t[s++]=String.fromCharCode((a&31)<<6|c&63)}else if(a>239&&a<365){let c=e[r++],u=e[r++],h=e[r++],f=((a&7)<<18|(c&63)<<12|(u&63)<<6|h&63)-Ge.MIN_SUPPLEMENTARY_CODE_POINT;t[s++]=String.fromCharCode(Ge.MIN_HIGH_SURROGATE+(f>>10)),t[s++]=String.fromCharCode(Ge.MIN_LOW_SURROGATE+(f&1023))}else{let c=e[r++],u=e[r++];t[s++]=String.fromCharCode((a&15)<<12|(c&63)<<6|u&63)}}return t.join("")}}},Ie(Dn,"METACHARACTERS","\\.+*?()|[]{}^$"),Ie(Dn,"EMPTY_BEGIN_LINE",1),Ie(Dn,"EMPTY_END_LINE",2),Ie(Dn,"EMPTY_BEGIN_TEXT",4),Ie(Dn,"EMPTY_END_TEXT",8),Ie(Dn,"EMPTY_WORD_BOUNDARY",16),Ie(Dn,"EMPTY_NO_WORD_BOUNDARY",32),Ie(Dn,"EMPTY_ALL",-1),Dn);const cD=(n=[],e=0)=>{const t=Object.create(null);for(let r=0;r<n.length;r++){const s=n[r],a=e+r;t[s]=a,t[a]=s}return Object.freeze(t)};var Jo,Bc=(Jo=class{getEncoding(){throw Error("not implemented")}asCharSequence(){throw Error("not implemented")}asBytes(){throw Error("not implemented")}length(){throw Error("not implemented")}isUTF8Encoding(){return this.getEncoding()===Jo.Encoding.UTF_8}isUTF16Encoding(){return this.getEncoding()===Jo.Encoding.UTF_16}},Ie(Jo,"Encoding",cD(["UTF_16","UTF_8"])),Jo),n_=class extends Bc{constructor(n=null){super(),this.bytes=n}getEncoding(){return Bc.Encoding.UTF_8}asCharSequence(){return Ze.utf8ByteArrayToString(this.bytes)}asBytes(){return this.bytes}length(){return this.bytes.length}},Xj=class extends Bc{constructor(n=null){super(),this.charSequence=n}getEncoding(){return Bc.Encoding.UTF_16}asCharSequence(){return this.charSequence}asBytes(){return Ze.stringToUtf8ByteArray(this.charSequence.toString())}length(){return this.charSequence.length}},tc=class{static utf16(n){return new Xj(n)}static utf8(n){return Ze.isByteArray(n)?new n_(n):new n_(Ze.stringToUtf8ByteArray(n))}},ms=class{static EOF(){return-8}constructor(){this.end=0}canCheckPrefix(){return!0}endPos(){return this.end}hasString(){return!1}hasAnyString(){return!1}prefixLength(){return 0}},Zj=class extends ms{constructor(n,e=0,t=n.length){super(),this.bytes=n,this.start=e,this.end=t}hasString(n,e){const t=n.bytes;if(t.length===0)return!0;const r=this.indexOf(this.bytes,t,this.start+e);return r!==-1&&r<=this.end-t.length}hasAnyString(n,e){return n.ac8?n.ac8.searchUTF8(this.bytes,this.start+e,this.end):!1}step(n){if(n+=this.start,n>=this.end)return ms.EOF();const e=this.bytes[n]&255;if(e<128)return e<<3|1;if(e>=194&&e<=223&&n+1<this.end){const t=this.bytes[n+1]&255;return(t&192)!==128?e<<3|1:((e&31)<<6|t&63)<<3|2}else if(e>=224&&e<=239&&n+2<this.end){const t=this.bytes[n+1]&255;if((t&192)!==128)return e<<3|1;const r=this.bytes[n+2]&255;return(r&192)!==128?e<<3|1:((e&15)<<12|(t&63)<<6|r&63)<<3|3}else if(e>=240&&e<=244&&n+3<this.end){const t=this.bytes[n+1]&255;if((t&192)!==128)return e<<3|1;const r=this.bytes[n+2]&255;if((r&192)!==128)return e<<3|1;const s=this.bytes[n+3]&255;return(s&192)!==128?e<<3|1:((e&7)<<18|(t&63)<<12|(r&63)<<6|s&63)<<3|4}else return e<<3|1}index(n,e){e+=this.start;const t=this.indexOf(this.bytes,n.prefixUTF8,e);return t<0?t:t-e}context(n){n+=this.start;let e=-1;if(n>this.start&&n<=this.end){let r=n-1;if(e=this.bytes[r--],e>=128){let s=n-4;for(s<this.start&&(s=this.start);r>=s&&(this.bytes[r]&192)===128;)r--;r<this.start&&(r=this.start),e=this.step(r-this.start)>>3}}const t=n<this.end?this.step(n-this.start)>>3:-1;return Ze.emptyOpContext(e,t)}indexOf(n,e,t=0){let r=e.length;if(r===0)return t<=this.end?t:-1;const s=e[0];let a=this.end-r;const c=typeof n.indexOf=="function";let u=t;for(;u<=a;){if(c){if(u=n.indexOf(s,u),u===-1||u>a)return-1}else{for(;u<=a&&n[u]!==s;)u++;if(u>a)return-1}let h=!0;for(let f=1;f<r;f++)if(n[u+f]!==e[f]){h=!1;break}if(h)return u;u++}return-1}prefixLength(n){return n.prefixUTF8.length}},eO=class extends ms{constructor(n,e=0,t=n.length){super(),this.charSequence=n,this.start=e,this.end=t}hasString(n,e){const t=this.charSequence.indexOf(n.str,this.start+e);return t!==-1&&t<=this.end-n.str.length}hasAnyString(n,e){return n.ac16?n.ac16.searchUTF16(this.charSequence,this.start+e,this.end):!1}step(n){if(n+=this.start,n>=this.end)return ms.EOF();const e=this.charSequence.charCodeAt(n);if(e<Ge.MIN_HIGH_SURROGATE||e>Ge.MAX_HIGH_SURROGATE||n+1>=this.end)return e<<3|1;const t=this.charSequence.charCodeAt(n+1);return t>=Ge.MIN_LOW_SURROGATE&&t<=Ge.MAX_LOW_SURROGATE?(e-Ge.MIN_HIGH_SURROGATE)*1024+(t-Ge.MIN_LOW_SURROGATE)+Ge.MIN_SUPPLEMENTARY_CODE_POINT<<3|2:e<<3|1}index(n,e){e+=this.start;const t=this.charSequence.indexOf(n.prefix,e);return t<0||t>this.end-n.prefix.length?-1:t-e}context(n){n+=this.start;const e=n>this.start&&n<=this.end?this.charSequence.charCodeAt(n-1):-1,t=n<this.end?this.charSequence.charCodeAt(n):-1;return Ze.emptyOpContext(e,t)}prefixLength(n){return n.prefix.length}},Sn=class{static fromUTF8(n,e=0,t=n.length){return new Zj(n,e,t)}static fromUTF16(n,e=0,t=n.length){return new eO(n,e,t)}}
1987,qh=class extends Error{constructor(n){super(n),this.name="RE2JSException"}},vn=class extends qh{constructor(n,e=null){let t=`error parsing regexp: ${n}`;e&&(t+=`: \`${e}\``),super(t),this.name="RE2JSSyntaxException",this.message=t,this.error=n,this.input=e}getDescription(){return this.error}getPattern(){return this.input}},tO=class extends qh{constructor(n){super(n),this.name="RE2JSCompileException"}},vs=class extends qh{constructor(n){super(n),this.name="RE2JSGroupException"}},nO=class extends qh{constructor(n){super(n),this.name="RE2JSFlagsException"}},ih=class extends qh{constructor(n){super(n),this.name="RE2JSInternalException"}},rc,r_=(rc=class{static quoteReplacement(e,t=!1){return t?e.indexOf("\\")<0&&e.indexOf("$")<0?e:e.split("").map(r=>{const s=r.codePointAt(0);return s===ye.CODES.get("\\")||s===ye.CODES.get("$")?`\\${r}`:r}).join(""):e.indexOf("$")<0?e:e.split("").map(r=>r.codePointAt(0)===ye.CODES.get("$")?"$$":r).join("")}constructor(e,t){if(e===null)throw new Error("pattern is null");this.patternInput=e;const r=this.patternInput.re2();this.patternGroupCount=r.numberOfCapturingGroups(),this.groups=[],this.namedGroups=r.namedGroups,this.numberOfInstructions=r.numberOfInstructions(),t instanceof Bc?this.resetMatcherInput(t):Ze.isByteArray(t)?this.resetMatcherInput(tc.utf8(t)):this.resetMatcherInput(tc.utf16(t))}pattern(){return this.patternInput}reset(){return this.matcherInputLength=this.matcherInput.length(),this.appendPos=0,this.hasMatch=!1,this.hasGroups=!1,this.anchorFlag=0,this}resetMatcherInput(e){if(e===null)throw new Error("input is null");return e instanceof Bc||(Ze.isByteArray(e)?e=tc.utf8(e):e=tc.utf16(e)),this.matcherInput=e,this.reset(),this}start(e=0){if(typeof e=="string"){const t=this.namedGroups[e];if(!Number.isFinite(t))throw new vs(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e]}end(e=0){if(typeof e=="string"){const t=this.namedGroups[e];if(!Number.isFinite(t))throw new vs(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e+1]}programSize(){return this.numberOfInstructions}group(e=0){if(typeof e=="string"){const s=this.namedGroups[e];if(!Number.isFinite(s))throw new vs(`group '${e}' not found`);e=s}const t=this.start(e),r=this.end(e);return t<0&&r<0?null:this.substring(t,r)}getNamedGroups(){if(!this.hasMatch)throw new vs("perhaps no match attempted");const e=Object.create(null);for(const t of Object.keys(this.namedGroups))e[t]=this.group(t);return e}groupCount(){return this.patternGroupCount}loadGroup(e){if(e<0||e>this.patternGroupCount)throw new vs(`Group index out of bounds: ${e}`);if(!this.hasMatch)throw new vs("perhaps no match attempted");if(e===0||this.hasGroups)return;const t=this.matcherInputLength,r=this.patternInput.re2().matchMachineInput(this.matcherInput,this.groups[0],t,this.anchorFlag,1+this.patternGroupCount);if(!r[0])throw new vs("inconsistency in matching group data");this.groups=r[1],this.hasGroups=!0}matches(){return this.genMatch(0,ke.ANCHOR_BOTH)}lookingAt(){return this.genMatch(0,ke.ANCHOR_START)}find(e=null){if(e!==null){if(e<0||e>this.matcherInputLength)throw new vs(`start index out of bounds: ${e}`);return this.reset(),this.genMatch(e,0)}if(e=0,this.hasMatch&&(e=this.groups[1],this.groups[0]===this.groups[1])){const t=(this.matcherInput.isUTF16Encoding()?Sn.fromUTF16(this.matcherInput.asCharSequence(),0,this.matcherInputLength):Sn.fromUTF8(this.matcherInput.asBytes(),0,this.matcherInputLength)).step(e);t<0?e++:e+=t&7}return this.genMatch(e,ke.UNANCHORED)}genMatch(e,t){const r=this.patternInput.re2().matchMachineInput(this.matcherInput,e,this.matcherInputLength,t,1);return r[0]?(this.groups=r[1],this.hasMatch=!0,this.hasGroups=this.patternGroupCount===0,this.anchorFlag=t,!0):(this.hasMatch=!1,!1)}substring(e,t){return this.matcherInput.isUTF8Encoding()?Ze.utf8ByteArrayToString(this.matcherInput.asBytes().slice(e,t)):this.matcherInput.asCharSequence().substring(e,t).toString()}inputLength(){return this.matcherInputLength}appendReplacement(e,t=!1){let r="";const s=this.start(),a=this.end();return this.appendPos<s&&(r+=this.substring(this.appendPos,s)),this.appendPos=a,r+=t?this.appendReplacementInternalJava(e):this.appendReplacementInternalJs(e),r}appendReplacementInternalJava(e){let t="",r=0;const s=e.length;let a=0;for(;a<s;){const c=e.codePointAt(a);if(c===ye.CODES.get("\\")){if(r<a&&(t+=e.substring(r,a)),a++,a>=s)throw new vs("character to be escaped is missing");r=a,a++;continue}if(c===ye.CODES.get("$")){if(r<a&&(t+=e.substring(r,a)),a+1>=s)throw new vs("Illegal group reference: group index is missing");const u=e.codePointAt(a+1);if(ye.CODES.get("0")<=u&&u<=ye.CODES.get("9")){let h=u-ye.CODES.get("0"),f=a+2;for(;f<s;f++){const y=e.codePointAt(f);if(y<ye.CODES.get("0")||y>ye.CODES.get("9")||h*10+y-ye.CODES.get("0")>this.patternGroupCount)break;h=h*10+y-ye.CODES.get("0")}if(h>this.patternGroupCount)throw new vs(`n > number of groups: ${h}`);const p=this.group(h);p!==null&&(t+=p),a=f,r=a}else if(u===ye.CODES.get("{")){let h=a+2;for(;h<s&&e.codePointAt(h)!==ye.CODES.get("}");)h++;if(h>=s)throw new vs("named capture group is missing trailing '}'");const f=e.substring(a+2,h),p=this.group(f);p!==null&&(t+=p),a=h+1,r=a}else throw new vs("Illegal group reference");continue}a++}return r<s&&(t+=e.substring(r,s)),t}appendReplacementInternalJs(e){let t="",r=0;const s=e.length;for(let a=0;a<s-1;a++)if(e.codePointAt(a)===ye.CODES.get("$")){let c=e.codePointAt(a+1);if(ye.CODES.get("$")===c){r<a&&(t+=e.substring(r,a)),t+="$",a++,r=a+1;continue}else if(ye.CODES.get("&")===c){r<a&&(t+=e.substring(r,a));const u=this.group(0);u!==null?t+=u:t+="$&",a++,r=a+1;continue}else if(ye.CODES.get("`")===c){r<a&&(t+=e.substring(r,a)),t+=this.substring(0,this.start(0)),a++,r=a+1;continue}else if(ye.CODES.get("'")===c){r<a&&(t+=e.substring(r,a)),t+=this.substring(this.end(0),this.matcherIn
1987putLength),a++,r=a+1;continue}else if(ye.CODES.get("1")<=c&&c<=ye.CODES.get("9")){let u=c-ye.CODES.get("0");for(r<a&&(t+=e.substring(r,a)),a+=2;a<s&&(c=e.codePointAt(a),!(c<ye.CODES.get("0")||c>ye.CODES.get("9")||u*10+c-ye.CODES.get("0")>this.patternGroupCount));a++)u=u*10+c-ye.CODES.get("0");if(u>this.patternGroupCount){t+=`$${u}`,r=a,a--;continue}const h=this.group(u);h!==null&&(t+=h),r=a,a--;continue}else if(c===ye.CODES.get("<")){r<a&&(t+=e.substring(r,a)),a++;let u=a+1;for(;u<e.length&&e.codePointAt(u)!==ye.CODES.get(">")&&e.codePointAt(u)!==ye.CODES.get(" ");)u++;if(u===e.length||e.codePointAt(u)!==ye.CODES.get(">")){t+=e.substring(a-1,u+1),r=u+1,a=u;continue}const h=e.substring(a+1,u);if(Object.prototype.hasOwnProperty.call(this.namedGroups,h)){const f=this.group(h);f!==null&&(t+=f)}else t+=`$<${h}>`;r=u+1,a=u;continue}}return r<s&&(t+=e.substring(r,s)),t}appendTail(){return this.substring(this.appendPos,this.matcherInputLength)}replaceAll(e,t=!1){return this.replace(e,!0,t)}replaceFirst(e,t=!1){return this.replace(e,!1,t)}replace(e,t=!0,r=!1){let s="";this.reset();const a=typeof e=="function",c=Object.keys(this.namedGroups).length>0;let u=null;if(a){if(this.groupCount()>=rc.MAX_REPLACER_ARGS)throw new vs("Too many capture groups to safely invoke replacer function");u=this.matcherInput.isUTF8Encoding()?this.matcherInput.asBytes():this.matcherInput.asCharSequence()}for(;this.find()&&(s+=a?this.appendReplacementFunc(e,c,u):this.appendReplacement(e,r),!!t););return s+=this.appendTail(),s}appendReplacementFunc(e,t,r){let s="";const a=this.start(),c=this.end();this.appendPos<a&&(s+=this.substring(this.appendPos,a)),this.appendPos=c;const u=this.buildReplacerArgs(a,t,r);return s+=String(e(...u)),s}buildReplacerArgs(e,t,r){const s=[this.group(0)],a=this.groupCount();for(let c=1;c<=a;c++){const u=this.start(c);u<0?s.push(void 0):s.push(this.substring(u,this.end(c)))}if(s.push(e),s.push(r),t){const c=this.getNamedGroups();for(const u in c)c[u]===null&&(c[u]=void 0);s.push(c)}return s}},Ie(rc,"MAX_REPLACER_ARGS",65535),rc),Gt,xe=(Gt=class{static isRuneOp(e){return Gt.RUNE<=e&&e<=Gt.RUNE_ANY_NOT_NL}static escapeRunes(e){let t='"';for(let r of e)t+=Ze.escapeRune(r);return t+='"',t}constructor(e){this.op=e,this.out=0,this.arg=0,this.runes=[],this.next=null}matchRune(e){if(this.runes.length===1){const c=this.runes[0];return(this.arg&ke.FOLD_CASE)!==0?Ge.equalsIgnoreCase(c,e):e===c}const t=this.runes.length;if(t===0)return!1;if(t===2||t===4||t===6||t===8){for(let c=0;c<t;c+=2){if(e<this.runes[c])return!1;if(e<=this.runes[c+1])return!0}return!1}let r=0,s=t>>1;for(;s>1;){const c=s>>1;r+=this.runes[r+c<<1]<=e?c:0,s-=c}r+=this.runes[r<<1]<=e?1:0;const a=r-1;return a>=0&&e<=this.runes[a<<1|1]}matchRunePos(e){if(this.runes.length===1){const c=this.runes[0];return(this.arg&ke.FOLD_CASE)!==0?Ge.equalsIgnoreCase(c,e)?0:-1:e===c?0:-1}const t=this.runes.length;if(t===0)return-1;if(t===2||t===4||t===6||t===8){for(let c=0;c<t;c+=2){if(e<this.runes[c])return-1;if(e<=this.runes[c+1])return Math.floor(c/2)}return-1}let r=0,s=t>>1;for(;s>1;){const c=s>>1;r+=this.runes[r+c<<1]<=e?c:0,s-=c}r+=this.runes[r<<1]<=e?1:0;const a=r-1;return a>=0&&e<=this.runes[a<<1|1]?a:-1}toString(){switch(this.op){case Gt.ALT:return`alt -> ${this.out}, ${this.arg}`;case Gt.ALT_MATCH:return`altmatch -> ${this.out}, ${this.arg}`;case Gt.CAPTURE:return`cap ${this.arg} -> ${this.out}`;case Gt.EMPTY_WIDTH:return`empty ${this.arg} -> ${this.out}`;case Gt.MATCH:return`match${this.arg!==0?` ${this.arg}`:""}`;case Gt.FAIL:return"fail";case Gt.NOP:return`nop -> ${this.out}`;case Gt.LB_WRITE:return`lbwrite ${this.arg} -> ${this.out}`;case Gt.LB_CHECK:return`lbcheck ${this.arg} -> ${this.out}`;case Gt.RUNE:return this.runes===null?"rune <null>":["rune ",Gt.escapeRunes(this.runes),(this.arg&ke.FOLD_CASE)!==0?"/i":""," -> ",this.out].join("");case Gt.RUNE1:return`rune1 ${Gt.escapeRunes(this.runes)} -> ${this.out}`;case Gt.RUNE_ANY:return`any -> ${this.out}`;case Gt.RUNE_ANY_NOT_NL:return`anynotnl -> ${this.out}`;default:throw new Error("unhandled case in Inst.toString")}}},Ie(Gt,"ALT",1),Ie(Gt,"ALT_MATCH",2),Ie(Gt,"CAPTURE",3),Ie(Gt,"EMPTY_WIDTH",4),Ie(Gt,"FAIL",5),Ie(Gt,"MATCH",6),Ie(Gt,"NOP",7),Ie(Gt,"RUNE",8),Ie(Gt,"RUNE1",9),Ie(Gt,"RUNE_ANY",10),Ie(Gt,"RUNE_ANY_NOT_NL",11),Ie(Gt,"LB_WRITE",12),Ie(Gt,"LB_CHECK",13),Gt),s_=class{constructor(n){this.sparse=new Int32Array(n),this.densePcs=new Int32Array(n),this.denseCaps=null,this.size=0,this.ncap=0}init(n){this.ncap=n;const e=this.densePcs.length*n;(!this.denseCaps||this.denseCaps.length<e)&&(this.denseCaps=new Int32Array(e))}contains(n){const e=this.sparse[n];return e<this.size&&this.densePcs[e]===n}isEmpty(){return this.size===0}add(n){const e=this.size++;return this.sparse[n]=e,this.densePcs[e]=n,e}clear(){this.size=0}toString(){let n="{";for(let e=0;e<this.size;e++)e!==0&&(n+=", "),n+=this.densePcs[e];return n+="}",n}},rO=class ky{static fromRE2(e){const t=new ky;return t.prog=e.prog,t.re2=e,t.q0=new s_(t.prog.numInst()),t.q1=new s_(t.prog.numInst()),t.matched=!1,t.matchcap=new Int32Array(t.prog.numCap<2?2:t.prog.numCap),t.ncap=0,t}static fromMachine(e){return ky.fromRE2(e.re2)}constructor(){this.prog=null,this.re2=null,this.q0=null,this.q1=null,this.matched=!1,this.matchcap=null,this.ncap=0,this.lbTable=null}init(e){this.ncap=e,e>this.matchcap.length?this.matchcap=new Int32Array(e).fill(-1):this.matchcap.fill(-1),this.q0.init(e),this.q1.init(e),this.prog.numLb>0&&((!this.lbTable||this.lbTable.length<this.prog.numLb+1)&&(this.lbTable=new Int32Array(this.prog.numLb+1)),this.lbTable.fill(-1))}submatches(){return this.ncap===0?Ze.emptyInts():Ze.toArray(this.matchcap.subarray(0,this.ncap))}match(e,t,r){const s=this.re2.cond;if(s===Ze.EMPTY_ALL||(r===ke.ANCHOR_START||r===ke.ANCHOR_BOTH)&&t!==0)return!1;this.matched=!1,this.matchcap.fill(-1);let a=this.prog.numLb>0?0:t,c=t,u=this.q0,h=this.q1,f=e.step(a),p=f>>3,y=f&7,b=-1,w=0;f!==ms.EOF()&&(f=e.step(a+y),b=f>>3,w=f&7);let E;for(a===0?E=Ze.emptyOpContext(-1,p):E=e.context(a);;){if(u.isEmpty()){if((s&Ze.EMPTY_BEGIN_TEXT)!==0&&a!==0||(r===ke.ANCHOR_START||r===ke.ANCHOR_BOTH)&&a!==0||this.matched)break;if(this.prog.numLb===0&&this.re2.prefix.length!==0&&b!==this.re2.prefixRune&&e.canCheckPrefix()){const I=e.index(this.re2,a);if(I<0)break;a+=I,f=e.step(a),p=f>>3,y=f&7,f=e.step(a+y),b=f>>3,w=f&7,E=e.context(a)}}if(a===0&&this.prog.numLb>0)for(let I=0;I<this.prog.lbStarts.length;I++)this.add(u,this.prog.lbStarts[I],a,this.matchcap,0,E);!this.matched&&(a===0||r===ke.UNANCHORED)&&a>=c&&(this.ncap>0&&(this.matchcap[0]=a),this.add(u,this.prog.start,a,this.matchcap,0,E));const N=a+y;if(E=e.context(N),this.step(u,h,a,N,p,E,r,a===e.endPos()),y===0||this.ncap===0&&this.matched)break;a+=y,p=b,y=w,p!==-1&&(f=e.step(a+y),b=f>>3,w=f&7);const S=u;u=h,h=S}return h.clear(),this.matched}matchSet(e,t,r){const s=this.re2.cond;if(s===Ze.EMPTY_ALL)return[];if((r===ke.ANCHOR_START||r===ke.ANCHOR_BOTH)&&t!==0)return[];let a=this.prog.numLb>0?0:t,c=t,u=this.q0,h=this.q1,f=e.step(a),p=f>>3,y=f&7,b=-1,w=0;f!==ms.EOF()&&(f=e.step(a+y),b=f>>3,w=f&7);let E=a===0?Ze.emptyOpContext(-1,p):e.context(a);const N=new Set;for(;!(u.isEmpty()&&((s&Ze.EMPTY_BEGIN_TEXT)!==0&&a!==0||(r===ke.ANCHOR_START||r===ke.ANCHOR_BOTH)&&a!==0));){if(a===0&&this.prog.numLb>0)for(let O=0;O<this.prog.lbStarts.length;O++)this.add(u,this.prog.lbStarts[O],a,this.matchcap,0,E);(a===0||r===ke.UNANCHORED)&&a>=c&&this.add(u,this.prog.start,a,this.matchcap,0,E);const S=a+y;E=e.context(S);for(let O=0;O<u.size;O++){const F=u.densePcs[O],J=this.prog.inst[F],z=O*this.ncap;let U=!1;switch(J.op){case xe.MATCH:if(r===ke.ANCHOR_BOTH&&a!==e.endPos())break;N.add(J.arg);break;case xe.RUNE:U=J.matchRune(p);break;case xe.RUNE1:U=p===J.runes[0];break;case xe.RUNE_ANY:U=!0;break;case xe.RUNE_ANY_NOT_NL:U=p!==10;break;default:continue}U&&this.add(h,J.out,S,u.denseCaps,z,E)}if(u.clear(),y===0)break;a+=y,p=b,y=w,p!==-1&&(f=e.step(a+y),b=f>>3,w=f&7);const I=u;u=h,h=I}return h.clear(),Array.from(N).sort((S,I)=>S-I)}step(e,t,r,s,a,c,u,h){const f=this.re2.longest;for(let p=0;p<e.size;p++){const y=e.densePcs[p],b=p*this.ncap;if(f&&this.matched&&this.ncap>0&&this.matchcap[0]<e.denseCaps[b])continue;const w=this.prog.inst[y];let E=!1;switch(w.op){case xe.MATCH:if(u===ke.ANCHOR_BOTH&&!h)break;if(this.ncap>0&&(!f||!this.matched||this.matchcap[1]<r)){e.denseCaps[b+1]=r;for(let N=0;N<this.ncap;N++)this.matchcap[N]=e.denseCaps[b+N]}f||(e.size=0),this.matched=!0;break;case xe.RUNE:E=w.matchRune(a);break;case xe.RUNE1:E=a===w.runes[0];break;case xe.RUNE_ANY:E=!0;break;case xe.RUNE_ANY_NOT_NL:E=a!==10;break;default:continue}E&&this.add(t,w.out,s,e.denseCaps,b,c)}e.clear()}add(e,t,r,s,a,c){for(;;){if(t===0||e.contains(t))return;const u=e.add(t),h=this.prog.inst[t];switch(h.op){case xe.FAIL:return;case xe.ALT:case xe.ALT_MATCH:this.add(e,h.out,r,s,a,c),t=h.arg;continue;case xe.EMPTY_WIDTH:if((h.arg&~c)===0){t=h.out;continue}return;case xe.NOP:t=h.out;continue;case xe.CAPTURE:if(h.arg<this.ncap){const f=s[a+h.arg];s[a+h.arg]=r,this.add(e,h.out,r,s,a,c),s[a+h.arg]=f;return}else{t=h.out;continue}case xe.LB_WRITE:this.lbTable[Math.abs(h.arg)]=r,t=h.out;continue;case xe.LB_CHECK:if(h.arg>0){if(this.lbTable[h.arg]===r){t=h.out;continue}}else if(this.lbTable[-h.arg]!==r){t=h.out;continue}return;case xe.MATCH:case xe.RUNE:case xe.RUNE1:case xe.RUNE_ANY:case xe.RUNE_ANY_NOT_NL:if(this.ncap>0){const f=u*this.ncap;for(let p=0;p<this.ncap;p++)e.denseCaps[f+p]=s[a+p]}return;default:throw new ih("unhandled")}}}};const i_=n=>{let e=-2128831035;for(let t=0;t<n.length;t++)e^=n[t],e=Math.imul(e,16777619);return e},sO=(n,e)=>{if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0};var iO=class{constructor(n,e,t=[]){this.nfaStates=n,this.isMatch=e,this.matchIDs=t,this.nextLatin1=new Array(Ge.MAX_LATIN1+1).fill(null),this.nextLatin1Anchored=new Array(Ge.MAX_LATIN1+1).fill(null),this.transKeys=[],this.transVals=[],this.lastSeen=0}},Ra,aO=(Ra=class{constructor(e,t=8388608){this.prog=e,this.stateCache=new Map,this.stateCount=0,this.startState=null,this.stateLimit=Math.max(1,Math.floor(t/Ra.STATE_MEMORY_ESTIMATE)),this.cacheClears=0,this.failed=!1,this.clock=0}computeClosure(e){const t=new Set,r=[...e];let s=!1;const a=[];for(;r.length>0;){const u=r.pop();if(t.has(u))continue;t.add(u);const h=this.prog.getInst(u);switch(h.op){case xe.MATCH:s=!0,a.includes(h.arg)||a.push(h.arg);break;case xe.ALT:case xe.ALT_MATCH:r.push(h.out),r.push(h.arg);break;case xe.NOP:case xe.CAPTURE:r.push(h.out);break;case xe.EMPTY_WIDTH:case xe.LB_WRITE:case xe.LB_CHECK:return null}}const c=Int32Array.from(t).sort();return a.sort((u,h)=>u-h),{pcs:c,isMatch:s,matchIDs:a}}getState(e){const t=this.computeClosure(e);
1987if(!t)return null;const r=t.pcs,s=i_(r);let a=this.stateCache.get(s);if(a)for(let u=0;u<a.length;u++){const h=a[u];if(sO(h.nfaStates,r))return h.lastSeen=++this.clock,h}else a=[],this.stateCache.set(s,a);if(this.failed)return null;if(this.stateCount>=this.stateLimit){if(this.cacheClears++,this.cacheClears>=Ra.MAX_CACHE_CLEARS)return this.failed=!0,this.stateCache.clear(),this.stateCount=0,this.startState=null,null;this.evictCache(),a=this.stateCache.get(s),a||(a=[],this.stateCache.set(s,a))}const c=new iO(r,t.isMatch,t.matchIDs);return c.lastSeen=++this.clock,a.push(c),this.stateCount++,c}evictCache(){const e=[];for(const c of this.stateCache.values())for(let u=0;u<c.length;u++)e.push(c[u]);e.sort((c,u)=>c.lastSeen-u.lastSeen);const t=Math.max(1,Math.floor(this.stateLimit/2)),r=e.length-t,s=e.slice(r),a=new Set(s);this.stateCache.clear(),this.stateCount=0;for(let c=0;c<s.length;c++){const u=s[c];u.nextLatin1.fill(null),u.nextLatin1Anchored.fill(null),u.transKeys.length=0,u.transVals.length=0;const h=i_(u.nfaStates);let f=this.stateCache.get(h);f||(f=[],this.stateCache.set(h,f)),f.push(u),this.stateCount++}this.startState&&!a.has(this.startState)&&(this.startState=null)}step(e,t,r){if(t<=Ge.MAX_LATIN1)if(r===ke.UNANCHORED){const c=e.nextLatin1[t];if(c!==null)return c}else{const c=e.nextLatin1Anchored[t];if(c!==null)return c}else{const c=t+(r===ke.UNANCHORED?0:Ge.MAX_RUNE+1),u=e.transKeys,h=u.length;for(let f=0;f<h;f++)if(u[f]===c)return e.transVals[f]}const s=[];for(let c=0;c<e.nfaStates.length;c++){const u=e.nfaStates[c],h=this.prog.getInst(u);xe.isRuneOp(h.op)&&h.matchRune(t)&&s.push(h.out)}r===ke.UNANCHORED&&s.push(this.prog.start);const a=this.getState(s);if(t<=Ge.MAX_LATIN1)r===ke.UNANCHORED?e.nextLatin1[t]=a:e.nextLatin1Anchored[t]=a;else{const c=t+(r===ke.UNANCHORED?0:Ge.MAX_RUNE+1);e.transKeys.push(c),e.transVals.push(a)}return a}match(e,t,r){if((r===ke.ANCHOR_START||r===ke.ANCHOR_BOTH)&&t!==0)return!1;if(!this.startState&&(this.startState=this.getState([this.prog.start]),!this.startState))return null;let s=e.endPos(),a=this.startState;if(a.isMatch)if(r===ke.ANCHOR_BOTH){if(t===s)return!0}else return!0;let c=t;for(;c<s;){const u=e.step(c),h=u>>3,f=u&7;if(f===0)break;if(a=r===ke.UNANCHORED&&h<=Ge.MAX_LATIN1&&a.nextLatin1[h]||this.step(a,h,r),a===null)return null;if(a.lastSeen=++this.clock,a.isMatch)if(r===ke.ANCHOR_BOTH){if(c+f===s)return!0}else return!0;if(a.nfaStates.length===0&&r!==ke.UNANCHORED)return!1;c+=f}return!1}matchSet(e,t,r){if((r===ke.ANCHOR_START||r===ke.ANCHOR_BOTH)&&t!==0)return[];if(!this.startState&&(this.startState=this.getState([this.prog.start]),!this.startState))return null;let s=e.endPos(),a=this.startState;const c=new Set,u=(f,p)=>{f.isMatch&&(r===ke.ANCHOR_BOTH?p===s&&f.matchIDs.forEach(y=>c.add(y)):f.matchIDs.forEach(y=>c.add(y)))};u(a,t);let h=t;for(;h<s;){const f=e.step(h),p=f>>3,y=f&7;if(y===0)break;if(a=r===ke.UNANCHORED&&p<=Ge.MAX_LATIN1&&a.nextLatin1[p]||this.step(a,p,r),a===null)return null;if(a.lastSeen=++this.clock,h+=y,u(a,h),a.nfaStates.length===0&&r!==ke.UNANCHORED)break}return Array.from(c).sort((f,p)=>f-p)}},Ie(Ra,"MAX_CACHE_CLEARS",5),Ie(Ra,"STATE_MEMORY_ESTIMATE",838),Ra);const oO=32,lO=500,zB=256,cO=256*1024;var uO=class{constructor(){this.end=0,this.cap=new Int32Array(0),this.matchcap=new Int32Array(0),this.ncap=0,this.jobPc=new Int32Array(zB),this.jobArg=new Uint8Array(zB),this.jobPos=new Int32Array(zB),this.jobLen=0,this.visited=new Uint32Array(0)}reset(n,e,t){this.end=e,this.jobLen=0,this.ncap=t;const r=n.numInst()*(e+1)+oO-1>>>5;this.visited.length<r?this.visited=new Uint32Array(r):this.visited.fill(0,0,r),this.cap.length<t?this.cap=new Int32Array(t).fill(-1):this.cap.fill(-1,0,t),this.matchcap.length<t?this.matchcap=new Int32Array(t).fill(-1):this.matchcap.fill(-1,0,t)}shouldVisit(n,e){const t=n*(this.end+1)+e,r=t>>>5,s=1<<(t&31);return(this.visited[r]&s)!==0?!1:(this.visited[r]|=s,!0)}push(n,e,t,r){if(n.prog.getInst(e).op!==xe.FAIL&&(r||this.shouldVisit(e,t))){if(this.jobLen>=this.jobPc.length){const s=this.jobPc.length*2,a=new Int32Array(s);a.set(this.jobPc),this.jobPc=a;const c=new Uint8Array(s);c.set(this.jobArg),this.jobArg=c;const u=new Int32Array(s);u.set(this.jobPos),this.jobPos=u}this.jobPc[this.jobLen]=e,this.jobArg[this.jobLen]=r?1:0,this.jobPos[this.jobLen]=t,this.jobLen++}}tryBacktrack(n,e,t,r,s){const a=n.longest;for(this.push(n,t,r,!1);this.jobLen>0;){this.jobLen--;let c=this.jobPc[this.jobLen],u=this.jobArg[this.jobLen]===1,h=this.jobPos[this.jobLen],f=!0;for(;!(!f&&!this.shouldVisit(c,h));){f=!1;const p=n.prog.getInst(c);switch(p.op){case xe.FAIL:throw new ih("unexpected InstFail");case xe.ALT:if(u){u=!1,c=p.arg;continue}
1987else{this.push(n,c,h,!0),c=p.out;continue}case xe.ALT_MATCH:{const y=n.prog.getInst(p.out);if(xe.isRuneOp(y.op)){this.push(n,p.arg,h,!1),c=p.arg,h=this.end;continue}this.push(n,p.out,this.end,!1),c=p.out;continue}case xe.RUNE:{const y=e.step(h);if(y===ms.EOF()||!p.matchRune(y>>3))break;h+=y&7,c=p.out;continue}case xe.RUNE1:{const y=e.step(h);if(y===ms.EOF()||y>>3!==p.runes[0])break;h+=y&7,c=p.out;continue}case xe.RUNE_ANY_NOT_NL:{const y=e.step(h);if(y===ms.EOF()||y>>3===10)break;h+=y&7,c=p.out;continue}case xe.RUNE_ANY:{const y=e.step(h);if(y===ms.EOF())break;h+=y&7,c=p.out;continue}case xe.CAPTURE:if(u){this.cap[p.arg]=h;break}else{p.arg<this.ncap&&(this.push(n,c,this.cap[p.arg],!0),this.cap[p.arg]=h),c=p.out;continue}case xe.EMPTY_WIDTH:{const y=e.context(h);if((p.arg&~y)!==0)break;c=p.out;continue}case xe.NOP:c=p.out;continue;case xe.MATCH:{if(s===ke.ANCHOR_BOTH&&h!==this.end)break;if(this.ncap===0)return!0;this.ncap>1&&(this.cap[1]=h);const y=this.matchcap[1];if((y===-1||a&&h>0&&h>y)&&this.matchcap.set(this.cap),!a||h===this.end)return!0;break}case xe.LB_WRITE:case xe.LB_CHECK:throw new ih("Backtracker cannot evaluate Lookbehind instructions");default:throw new ih("bad inst")}break}}return a&&this.matchcap.length>1&&this.matchcap[1]>=0}};const vm=[];var wm=class uD{static shouldBacktrack(e){return e.numInst()<=lO}static maxBitStateLen(e){return uD.shouldBacktrack(e)?Math.floor(cO/e.numInst()):0}static execute(e,t,r,s,a){const c=e.cond;if(c===Ze.EMPTY_ALL||(s===ke.ANCHOR_START||s===ke.ANCHOR_BOTH)&&r!==0||(c&Ze.EMPTY_BEGIN_TEXT)!==0&&r!==0)return null;const u=vm.length>0?vm.pop():new uO,h=t.endPos();u.reset(e.prog,h,a);let f=!1;if((c&Ze.EMPTY_BEGIN_TEXT)!==0||s===ke.ANCHOR_START||s===ke.ANCHOR_BOTH)u.ncap>0&&(u.cap[0]=r),u.tryBacktrack(e,t,e.prog.start,r,s)&&(f=!0);else{let y=-1;for(;r<=h&&y!==0;r+=y){if(e.prefix.length>0){const w=t.index(e,r);if(w<0)break;r+=w}if(u.ncap>0&&(u.cap[0]=r),u.tryBacktrack(e,t,e.prog.start,r,s)){f=!0;break}const b=t.step(r);y=b===ms.EOF()?0:b&7}}if(!f)return vm.push(u),null;const p=a===0?[]:Ze.toArray(u.matchcap.subarray(0,a));return vm.push(u),p}},a_=class{constructor(n){this.sparse=new Uint32Array(n),this.dense=new Uint32Array(n),this.size=0,this.nextIndex=0}empty(){return this.nextIndex>=this.size}next(){return this.dense[this.nextIndex++]}clear(){this.size=0,this.nextIndex=0}contains(n){return n<this.sparse.length&&this.sparse[n]<this.size&&this.dense[this.sparse[n]]===n}insert(n){this.contains(n)||this.insertNew(n)}insertNew(n){n>=this.sparse.length||(this.sparse[n]=this.size,this.dense[this.size]=n,this.size++)}};const dO=(n,e,t,r)=>{const s=n.length,a=e.length;let c=0,u=0;const h=[],f=[];let p=!0,y=-1;const b=w=>{const E=w?n:e,N=w?c:u,S=w?t:r;return y>0&&E[N]<=h[y]?!1:(h.push(E[N],E[N+1]),w?c+=2:u+=2,y+=2,f.push(S),!0)};for(;c<s||u<a;)if(u>=a?p=b(!0):c>=s||e[u]<n[c]?p=b(!1):p=b(!0),!p)return null;return{merged:h,next:f}};var hO=class{constructor(n){this.start=n.start,this.numCap=n.numCap,this.inst=new Array(n.inst.length);for(let e=0;e<n.inst.length;e++){const t=n.inst[e],r=new xe(t.op);r.out=t.out,r.arg=t.arg,r.runes=t.runes?t.runes.slice():[],r.next=null,this.inst[e]=r}}};const fO=n=>{const e=new hO(n);for(let t=0;t<e.inst.length;t++){const r=e.inst[t];if(r.op!==xe.ALT&&r.op!==xe.ALT_MATCH)continue;let s="out",a="arg",c=e.inst[r[a]];if(c.op!==xe.ALT&&c.op!==xe.ALT_MATCH&&(s="arg",a="out",c=e.inst[r[a]],c.op!==xe.ALT&&c.op!==xe.ALT_MATCH))continue;const u=e.inst[r[s]];if(u.op===xe.ALT||u.op===xe.ALT_MATCH)continue;let h="out",f="arg",p=!1;c.out===t?p=!0:c.arg===t&&(p=!0,h="arg",f="out"),p&&(c[h]=r[s]),r[s]===c[h]&&(r[a]=c[f])}return e},mO=n=>{if(n.inst.length>=1e3)return null;const e=new a_(n.inst.length),t=new a_(n.inst.length),r=new Array(n.inst.length),s=new Array(n.inst.length).fill(!1),a=c=>{let u=!0;const h=n.inst[c];if(t.contains(c))return!0;switch(t.insert(c),h.op){case xe.ALT:case xe.ALT_MATCH:{u=a(h.out)&&a(h.arg);let f=s[h.out],p=s[h.arg];if(f&&p)return!1;if(p){const E=h.out;h.out=h.arg,h.arg=E;const N=f;f=p,p=N}f&&(s[c]=!0,h.op=xe.ALT_MATCH);const y=r[h.out]||[],b=r[h.arg]||[],w=dO(y,b,h.out,h.arg);if(!w)return!1;r[c]=w.merged,h.next=new Uint32Array(w.next);break}case xe.CAPTURE:case xe.EMPTY_WIDTH:case xe.NOP:u=a(h.out),s[c]=s[h.out],r[c]=r[h.out]?r[h.out].slice():[],h.next=new Uint32Array(Math.floor(r[c].length/2)+1).fill(h.out);break;case xe.MATCH:case xe.FAIL:s[c]=h.op===xe.MATCH;break;case xe.RUNE:{if(s[c]=!1,h.next&&h.next.length>0)break;if(e.insert(h.out),!h.runes||h.runes.length===0){r[c]=[],h.next=new Uint32Array([h.out]);break}let f=[];if(h.runes.length===1&&(h.arg&ke.FOLD_CASE)!==0){const p=h.runes[0];f.push(p,p);for(let y=Ge.simpleFold(p);y!==p;y=Ge.simpleFold(y))f.push(y,y);f.sort((y,b)=>y-b)}else for(let p=0;p<h.runes.length;p++)f.push(h.runes[p]);r[c]=f,h.next=new Uint32Array(Math.floor(f.length/2)+1).fill(h.out),h.op=xe.RUNE;break}case xe.RUNE1:{if(s[c]=!1,h.next&&h.next.length>0)break;e.insert(h.out);let f=[];if((h.arg&ke.FOLD_CASE)!==0){const p=h.runes[0];f.push(p,p);for(let y=Ge.simpleFold(p);y!==p;y=Ge.simpleFold(y))f.push(y,y);f.sort((y,b)=>y-b)}else f.push(h.runes[0],h.runes[0]);r[c]=f,h.next=new Uint32Array(Math.floor(f.length/2)+1).fill(h.out),h.op=xe.RUNE;break}case xe.RUNE_ANY:if(s[c]=!1,h.next&&h.next.length>0)break;e.insert(h.out),r[c]=[0,Ge.MAX_RUNE],h.next=new Uint32Array([h.out]);break;case xe.RUNE_ANY_NOT_NL:if(s[c]=!1,h.next&&h.next.length>0)break;e.insert(h.out),r[c]=[0,9,11,Ge.MAX_RUNE],h.next=new Uint32Array(Math.floor(r[c].length/2)+1).fill(h.out);break}return u};for(e.clear(),e.insert(n.start);!e.empty();)if(t.clear(),!a(e.next()))return null;for(let c=0;c<n.inst.length;c++)r[c]&&(n.inst[c].runes=r[c]);return n},gO=(n,e)=>{for(let t=0;t<e.inst.length;t++){const r=e.inst[t];switch(r.op){case xe.ALT:case xe.ALT_MATCH:case xe.RUNE:break;case xe.CAPTURE:case xe.EMPTY_WIDTH:case xe.NOP:case xe.MATCH:case xe.FAIL:n.inst[t].next=null;break;case xe.RUNE1:case xe.RUNE_ANY:case xe.RUNE_ANY_NOT_NL:n.inst[t].next=null,n.inst[t].op=r.op,n.inst[t].runes=r.runes?r.runes.slice():[];break}}};var o_=class dD{static compile(e){if(e.start===0||e.numLb>0)return null;const t=e.inst[e.start];if(t.op!==xe.EMPTY_WIDTH||(t.arg&Ze.EMPTY_BEGIN_TEXT)===0)return null;let r=!1;for(let a=0;a<e.inst.length;a++)if(e.inst[a].op===xe.ALT||e.inst[a].op===xe.ALT_MATCH){r=!0;break}for(let a=0;a<e.inst.length;a++){const c=e.inst[a],u=e.inst[c.out].op;
1987switch(c.op){case xe.ALT:case xe.ALT_MATCH:if(u===xe.MATCH||e.inst[c.arg].op===xe.MATCH)return null;break;case xe.EMPTY_WIDTH:if(u===xe.MATCH){if((c.arg&Ze.EMPTY_END_TEXT)===Ze.EMPTY_END_TEXT)continue;return null}break;default:if(u===xe.MATCH&&r)return null;break}}let s=fO(e);return s=mO(s),s!==null&&gO(s,e),s}static next(e,t){const r=e.matchRunePos(t);return r>=0?e.next[r]:e.op===xe.ALT_MATCH?e.out:0}static execute(e,t,r,s,a){const c=e.onepass;if(!c)return null;const u=new Int32Array(a).fill(-1);let h=!1,f=t.step(r),p=f>>3,y=f&7,b=ms.EOF(),w=-1,E=0;f!==ms.EOF()&&(b=t.step(r+y),b!==ms.EOF()&&(w=b>>3,E=b&7));let N=r===0?Ze.emptyOpContext(-1,p):t.context(r),S=c.start,I;for(;;){switch(I=c.inst[S],S=I.out,I.op){case xe.MATCH:return s===ke.ANCHOR_BOTH&&r!==t.endPos()?null:(h=!0,u.length>0&&(u[0]=0,u[1]=r),a===0?[]:Ze.toArray(u));case xe.RUNE:if(!I.matchRune(p))return null;break;case xe.RUNE1:if(p!==I.runes[0])return null;break;case xe.RUNE_ANY:break;case xe.RUNE_ANY_NOT_NL:if(p===10)return null;break;case xe.ALT:case xe.ALT_MATCH:S=dD.next(I,p);continue;case xe.FAIL:return null;case xe.NOP:continue;case xe.EMPTY_WIDTH:if((I.arg&~N)!==0)return null;continue;case xe.CAPTURE:I.arg<u.length&&(u[I.arg]=r);continue;default:throw new ih("bad inst")}if(y===0)break;N=Ze.emptyOpContext(p,w),r+=y,p=w,y=E,p!==-1&&(b=t.step(r+y),b!==ms.EOF()?(w=b>>3,E=b&7):(w=-1,E=0))}return h?a===0?[]:Ze.toArray(u):null}},rt,ie=(rt=class{static isPseudoOp(e){return e>=rt.Op.LEFT_PAREN}static emptySubs(){return[]}static quoteIfHyphen(e){return e===ye.CODES.get("-")?"\\":""}static fromRegexp(e){const t=new rt(e.op);return t.flags=e.flags,t.subs=e.subs,t.runes=e.runes,t.cap=e.cap,t.min=e.min,t.max=e.max,t.name=e.name,t.namedGroups=e.namedGroups,t.lb=e.lb,t}constructor(e){this.op=e,this.flags=0,this.subs=rt.emptySubs(),this.runes=[],this.min=0,this.max=0,this.cap=0,this.name=null,this.namedGroups=Object.create(null),this.lb=0}reinit(){this.flags=0,this.subs=rt.emptySubs(),this.runes=[],this.cap=0,this.min=0,this.max=0,this.name=null,this.namedGroups=Object.create(null),this.lb=0}toString(){return this.appendTo()}appendTo(){let e="";switch(this.op){case rt.Op.NO_MATCH:e+="[^\\x00-\\x{10FFFF}]";break;case rt.Op.EMPTY_MATCH:e+="(?:)";break;case rt.Op.STAR:case rt.Op.PLUS:case rt.Op.QUEST:case rt.Op.REPEAT:{const t=this.subs[0];switch(t.op>rt.Op.CAPTURE||t.op===rt.Op.LITERAL&&t.runes.length>1?e+=`(?:${t.appendTo()})`:e+=t.appendTo(),this.op){case rt.Op.STAR:e+="*";break;case rt.Op.PLUS:e+="+";break;case rt.Op.QUEST:e+="?";break;case rt.Op.REPEAT:e+=`{${this.min}`,this.min!==this.max&&(e+=",",this.max>=0&&(e+=this.max)),e+="}";break}(this.flags&ke.NON_GREEDY)!==0&&(e+="?");break}case rt.Op.CONCAT:for(let t of this.subs)t.op===rt.Op.ALTERNATE?e+=`(?:${t.appendTo()})`:e+=t.appendTo();break;case rt.Op.ALTERNATE:{let t="";for(let r of this.subs)e+=t,t="|",e+=r.appendTo();break}case rt.Op.LITERAL:(this.flags&ke.FOLD_CASE)!==0&&(e+="(?i:");for(let t of this.runes)e+=Ze.escapeRune(t);(this.flags&ke.FOLD_CASE)!==0&&(e+=")");break;case rt.Op.ANY_CHAR_NOT_NL:e+="(?-s:.)";break;case rt.Op.ANY_CHAR:e+="(?s:.)";break;case rt.Op.PLB:e+=`(?<=${this.subs[0].appendTo()})`;break;case rt.Op.NLB:e+=`(?<!${this.subs[0].appendTo()})`;break;case rt.Op.CAPTURE:this.name===null||this.name.length===0?e+="(":e+=`(?P<${this.name}>`,this.subs[0].op!==rt.Op.EMPTY_MATCH&&(e+=this.subs[0].appendTo()),e+=")";break;case rt.Op.BEGIN_TEXT:e+="\\A";break;case rt.Op.END_TEXT:(this.flags&ke.WAS_DOLLAR)!==0?e+="(?-m:$)":e+="\\z";break;case rt.Op.BEGIN_LINE:e+="^";break;case rt.Op.END_LINE:e+="$";break;case rt.Op.WORD_BOUNDARY:e+="\\b";break;case rt.Op.NO_WORD_BOUNDARY:e+="\\B";break;case rt.Op.CHAR_CLASS:if(this.runes.length%2!==0){e+="[invalid char class]";break}if(e+="[",this.runes.length===0)e+="^\\x00-\\x{10FFFF}";else if(this.runes[0]===0&&this.runes[this.runes.length-1]===Ge.MAX_RUNE){e+="^";for(let t=1;t<this.runes.length-1;t+=2){const r=this.runes[t]+1,s=this.runes[t+1]-1;e+=rt.quoteIfHyphen(r),e+=Ze.escapeRune(r),r!==s&&(e+="-",e+=rt.quoteIfHyphen(s),e+=Ze.escapeRune(s))}}else for(let t=0;t<this.runes.length;t+=2){const r=this.runes[t],s=this.runes[t+1];e+=rt.quoteIfHyphen(r),e+=Ze.escapeRune(r),r!==s&&(e+="-",e+=rt.quoteIfHyphen(s),e+=Ze.escapeRune(s))}e+="]";break;default:e+=this.op;break}return e}maxCap(){let e=0;if(this.op===rt.Op.CAPTURE&&(e=this.cap),this.subs!==null)for(let t of this.subs){const r=t.maxCap();e<r&&(e=r)}return e}equals(e){if(!(e!==null&&e instanceof rt)||this.op!==e.op)return!1;switch(this.op){case rt.Op.END_TEXT:if((this.flags&ke.WAS_DOLLAR)!==(e.flags&ke.WAS_DOLLAR))return!1;break;case rt.Op.LITERAL:case rt.Op.CHAR_CLASS:if(this.runes===null&&e.runes===null)break;
vendor: 11,147 bytes, lines 1987-1992
1987if(this.runes===null||e.runes===null||this.runes.length!==e.runes.length)return!1;for(let t=0;t<this.runes.length;t++)if(this.runes[t]!==e.runes[t])return!1;break;case rt.Op.ALTERNATE:case rt.Op.CONCAT:if(this.subs.length!==e.subs.length)return!1;for(let t=0;t<this.subs.length;++t)if(!this.subs[t].equals(e.subs[t]))return!1;break;case rt.Op.STAR:case rt.Op.PLUS:case rt.Op.QUEST:if((this.flags&ke.NON_GREEDY)!==(e.flags&ke.NON_GREEDY)||!this.subs[0].equals(e.subs[0]))return!1;break;case rt.Op.REPEAT:if((this.flags&ke.NON_GREEDY)!==(e.flags&ke.NON_GREEDY)||this.min!==e.min||this.max!==e.max||!this.subs[0].equals(e.subs[0]))return!1;break;case rt.Op.CAPTURE:if(this.cap!==e.cap||(this.name===null?e.name!==null:this.name!==e.name)||!this.subs[0].equals(e.subs[0]))return!1;break;case rt.Op.PLB:case rt.Op.NLB:if(this.lb!==e.lb||!this.subs[0].equals(e.subs[0]))return!1;break}return!0}},Ie(rt,"Op",cD(["NO_MATCH","EMPTY_MATCH","LITERAL","CHAR_CLASS","ANY_CHAR_NOT_NL","ANY_CHAR","BEGIN_LINE","END_LINE","BEGIN_TEXT","END_TEXT","WORD_BOUNDARY","NO_WORD_BOUNDARY","CAPTURE","STAR","PLUS","QUEST","REPEAT","CONCAT","ALTERNATE","PLB","NLB","LEFT_PAREN","VERTICAL_BAR"])),rt),l_=class{constructor(n){this.next=[Object.create(null)],this.fail=[0],this.match=[!1];for(const t of n){let r=0;for(let s=0;s<t.length;s++){const a=t[s];a in this.next[r]||(this.next.push(Object.create(null)),this.fail.push(0),this.match.push(!1),this.next[r][a]=this.next.length-1),r=this.next[r][a]}this.match[r]=!0}const e=[];for(const t in this.next[0])if(Object.prototype.hasOwnProperty.call(this.next[0],t)){const r=this.next[0][t];this.fail[r]=0,e.push(r)}for(;e.length>0;){const t=e.shift();for(const r in this.next[t])if(Object.prototype.hasOwnProperty.call(this.next[t],r)){const s=this.next[t][r];let a=this.fail[t];for(;a!==0&&!(r in this.next[a]);)a=this.fail[a];r in this.next[a]?this.fail[s]=this.next[a][r]:this.fail[s]=0,this.match[s]=this.match[s]||this.match[this.fail[s]],e.push(s)}}}searchUTF16(n,e,t){let r=0;for(let s=e;s<t;s++){const a=n.charCodeAt(s);for(;r!==0&&!(a in this.next[r]);)r=this.fail[r];if(a in this.next[r]&&(r=this.next[r][a]),this.match[r])return!0}return!1}searchUTF8(n,e,t){let r=0;for(let s=e;s<t;s++){const a=n[s];for(;r!==0&&!(a in this.next[r]);)r=this.fail[r];if(a in this.next[r]&&(r=this.next[r][a]),this.match[r])return!0}return!1}},Xi,Jt=(Xi=class{constructor(e){this.type=e,this.subs=[],this.str="",this.bytes=null,this.ac16=null,this.ac8=null}eval(e,t){switch(this.type){case Xi.Type.NONE:return!0;case Xi.Type.EXACT:return e.hasString(this,t);case Xi.Type.AND:for(let r=0;r<this.subs.length;r++)if(!this.subs[r].eval(e,t))return!1;return!0;case Xi.Type.OR:if(this.ac16&&this.ac8)return e.hasAnyString(this,t);for(let r=0;r<this.subs.length;r++)if(this.subs[r].eval(e,t))return!0;return!1;default:return!0}}},Ie(Xi,"Type",{NONE:0,EXACT:1,AND:2,OR:3}),Xi),pO=class Aa{static build(e){const t=Aa.fromRegexp(e);return Aa.simplify(t)}static fromRegexp(e){if(!e)return new Jt(Jt.Type.NONE);switch(e.op){case ie.Op.PLB:case ie.Op.NLB:case ie.Op.NO_MATCH:case ie.Op.EMPTY_MATCH:case ie.Op.BEGIN_LINE:case ie.Op.END_LINE:case ie.Op.BEGIN_TEXT:case ie.Op.END_TEXT:case ie.Op.WORD_BOUNDARY:case ie.Op.NO_WORD_BOUNDARY:case ie.Op.CHAR_CLASS:case ie.Op.ANY_CHAR_NOT_NL:case ie.Op.ANY_CHAR:return new Jt(Jt.Type.NONE);case ie.Op.LITERAL:{if(e.runes.length===0||(e.flags&ke.FOLD_CASE)!==0)return new Jt(Jt.Type.NONE);const t=new Jt(Jt.Type.EXACT);let r="";for(let s=0;s<e.runes.length;s++)r+=String.fromCodePoint(e.runes[s]);return t.str=r,t.bytes=Ze.stringToUtf8ByteArray(t.str),t}case ie.Op.CAPTURE:case ie.Op.PLUS:return Aa.fromRegexp(e.subs[0]);case ie.Op.REPEAT:return e.min>=1?Aa.fromRegexp(e.subs[0]):new Jt(Jt.Type.NONE);case ie.Op.CONCAT:{const t=new Jt(Jt.Type.AND);for(const r of e.subs)t.subs.push(Aa.fromRegexp(r));return t}case ie.Op.ALTERNATE:{const t=new Jt(Jt.Type.OR);for(const r of e.subs)t.subs.push(Aa.fromRegexp(r));return t}default:return new Jt(Jt.Type.NONE)}}static simplify(e){if(e.type===Jt.Type.EXACT||e.type===Jt.Type.NONE)return e;if(e.type===Jt.Type.AND){const t=[];for(const r of e.subs){const s=Aa.simplify(r);if(s.type!==Jt.Type.NONE)if(s.type===Jt.Type.AND)for(let a=0;a<s.subs.length;a++)t.push(s.subs[a]);else t.push(s)}return t.length===0?new Jt(Jt.Type.NONE):t.length===1?t[0]:(e.subs=t,e)}if(e.type===Jt.Type.OR){const t=[];for(const c of e.subs){const u=Aa.simplify(c);if(u.type===Jt.Type.NONE)return new Jt(Jt.Type.NONE);if(u.type===Jt.Type.OR)for(let h=0;h<u.subs.length;h++)t.push(u.subs[h]);else t.push(u)}if(t.length===0)return new Jt(Jt.Type.NONE);if(t.length===1)return t[0];const r=new Set,s=[];for(const c of t)c.type===Jt.Type.EXACT?r.has(c.str)||(r.add(c.str),s.push(c)):s.push(c);e.subs=s;let a=!0;for(const c of s)if(c.type!==Jt.Type.EXACT){a=!1;break}return a&&s.length>1&&(e.ac16=new l_(s.map(c=>{const u=[];for(let h=0;h<c.str.length;h++)u.push(c.str.charCodeAt(h));return u})),e.ac8=new l_(s.map(c=>c.bytes))),e}return e}},hi=class{constructor(n=0,e=0){this.head=n,this.tail=e}},BO=class{constructor(){this.inst=[],this.start=0,this.numCap=2,this.lbStarts=[],this.numLb=0}getInst(n){return this.inst[n]}numInst(){return this.inst.length}addInst(n){this.inst.push(new xe(n))}skipNop(n){let e=this.inst[n];for(;e.op===xe.NOP||e.op===xe.CAPTURE;)e=this.inst[n],n=e.out;return e}prefix(){let n="",e=this.skipNop(this.start);if(!xe.isRuneOp(e.op)||e.runes.length!==1)return[e.op===xe.MATCH,n];for(;xe.isRuneOp(e.op)&&e.runes.length===1&&(e.arg&ke.FOLD_CASE)===0;)n+=String.fromCodePoint(e.runes[0]),e=this.skipNop(e.out);return[e.op===xe.MATCH,n]}startCond(){let n=0,e=this.start;e:for(;;){const t=this.inst[e];switch(t.op){case xe.EMPTY_WIDTH:n|=t.arg;break;case xe.FAIL:return-1;case xe.CAPTURE:case xe.NOP:break;default:break e}e=t.out}return n}patch(n,e){let t=n.head;for(;t!==0;){const r=this.inst[t>>1];(t&1)===0?(t=r.out,r.out=e):(t=r.arg,r.arg=e)}}append(n,e){if(n.head===0)return e;if(e.head===0)return n;const t=this.inst[n.tail>>1];return(n.tail&1)===0?t.out=e.head:t.arg=e.head,new hi(n.head,e.tail)}toString(){let n="";for(let e=0;e<this.inst.length;e++){const t=n.length;n+=e,e===this.start&&(n+="*"),n+="        ".substring(n.length-t),n+=this.inst[e],n+=`
1988`}return n}},Em=class{constructor(n=0,e=new hi,t=!1){this.i=n,this.out=e,this.nullable=t}},yO=class gu{static ANY_RUNE_NOT_NL(){return[0,ye.CODES.get(`
1989`)-1,ye.CODES.get(`
1990`)+1,Ge.MAX_RUNE]}static ANY_RUNE(){return[0,Ge.MAX_RUNE]}static compileRegexp(e){const t=new gu,r=t.compile(e);return t.prog.patch(r.out,t.newInst(xe.MATCH).i),t.prog.start=r.i,t.prog}static compileSet(e){const t=new gu;if(e.length===0)return t.prog.start=t.newInst(xe.FAIL).i,t.prog;let r=[];for(let a=0;a<e.length;a++){const c=t.compile(e[a]),u=t.newInst(xe.MATCH);t.prog.getInst(u.i).arg=a,t.prog.patch(c.out,u.i),r.push(c.i)}let s=r[0];for(let a=1;a<r.length;a++){const c=t.newInst(xe.ALT),u=t.prog.getInst(c.i);u.out=s,u.arg=r[a],s=c.i}return t.prog.start=s,t.prog}constructor(){this.prog=new BO,this.newInst(xe.FAIL)}newInst(e){return this.prog.addInst(e),new Em(this.prog.numInst()-1,new hi,!0)}nop(){const e=this.newInst(xe.NOP);return e.out=new hi(e.i<<1,e.i<<1),e}fail(){return new Em}cap(e){const t=this.newInst(xe.CAPTURE);return t.out=new hi(t.i<<1,t.i<<1),this.prog.getInst(t.i).arg=e,this.prog.numCap<e+1&&(this.prog.numCap=e+1),t}cat(e,t){return e.i===0||t.i===0?this.fail():(this.prog.patch(e.out,t.i),new Em(e.i,t.out,e.nullable&&t.nullable))}alt(e,t){if(e.i===0)return t;if(t.i===0)return e;const r=this.newInst(xe.ALT),s=this.prog.getInst(r.i);return s.out=e.i,s.arg=t.i,r.out=this.prog.append(e.out,t.out),r.nullable=e.nullable||t.nullable,r}loop(e,t){const r=this.newInst(xe.ALT),s=this.prog.getInst(r.i);return t?(s.arg=e.i,r.out=new hi(r.i<<1,r.i<<1)):(s.out=e.i,r.out=new hi(r.i<<1|1,r.i<<1|1)),this.prog.patch(e.out,r.i),r}quest(e,t){const r=this.newInst(xe.ALT),s=this.prog.getInst(r.i);return t?(s.arg=e.i,r.out=new hi(r.i<<1,r.i<<1)):(s.out=e.i,r.out=new hi(r.i<<1|1,r.i<<1|1)),r.out=this.prog.append(r.out,e.out),r}star(e,t){return e.nullable?this.quest(this.plus(e,t),t):this.loop(e,t)}plus(e,t){return new Em(e.i,this.loop(e,t).out,e.nullable)}empty(e){const t=this.newInst(xe.EMPTY_WIDTH);return this.prog.getInst(t.i).arg=e,t.out=new hi(t.i<<1,t.i<<1),t}rune(e,t){const r=this.newInst(xe.RUNE);r.nullable=!1;const s=this.prog.getInst(r.i);return s.runes=e,t&=ke.FOLD_CASE,(e.length!==1||Ge.simpleFold(e[0])===e[0])&&(t&=-2),s.arg=t,r.out=new hi(r.i<<1,r.i<<1),(t&ke.FOLD_CASE)===0&&e.length===1||e.length===2&&e[0]===e[1]?s.op=xe.RUNE1:e.length===2&&e[0]===0&&e[1]===Ge.MAX_RUNE?s.op=xe.RUNE_ANY:e.length===4&&e[0]===0&&e[1]===ye.CODES.get(`
1991`)-1&&e[2]===ye.CODES.get(`
1992`)+1&&e[3]===Ge.MAX_RUNE&&(s.op=xe.RUNE_ANY_NOT_NL),r}lookBehind(e,t){const r=this.newInst(xe.LB_WRITE);this.prog.getInst(r.i).arg=t;const s=this.rune(gu.ANY_RUNE(),0),a=this.star(s,!0),c=this.cat(a,e);this.prog.patch(c.out,r.i);const u=this.newInst(xe.LB_CHECK);return this.prog.getInst(u.i).arg=t,this.prog.lbStarts.push(c.i),Math.abs(t)>this.prog.numLb&&(this.prog.numLb=Math.abs(t)),u.out=new hi(u.i<<1,u.i<<1),u}compile(e){switch(e.op){case ie.Op.NO_MATCH:return this.fail();case ie.Op.EMPTY_MATCH:return this.nop();case ie.Op.LITERAL:if(e.runes.length===0)return this.nop();{let t=null;for(let r of e.runes){const s=this.rune([r],e.flags);t=t===null?s:this.cat(t,s)}return t}case ie.Op.CHAR_CLASS:return this.rune(e.runes,e.flags);case ie.Op.ANY_CHAR_NOT_NL:return this.rune(gu.ANY_RUNE_NOT_NL(),0);case ie.Op.ANY_CHAR:return this.rune(gu.ANY_RUNE(),0);case ie.Op.BEGIN_LINE:return this.empty(Ze.EMPTY_BEGIN_LINE);case ie.Op.END_LINE:return this.empty(Ze.EMPTY_END_LINE);case ie.Op.BEGIN_TEXT:return this.empty(Ze.EMPTY_BEGIN_TEXT);case ie.Op.END_TEXT:return this.empty(Ze.EMPTY_END_TEXT);case ie.Op.WORD_BOUNDARY:return this.empty(Ze.EMPTY_WORD_BOUNDARY);case ie.Op.NO_WORD_BOUNDARY:return this.empty(Ze.EMPTY_NO_WORD_BOUNDARY);case ie.Op.PLB:case ie.Op.NLB:return this.lookBehind(this.compile(e.subs[0]),e.lb);case ie.Op.CAPTURE:{const t=this.cap(e.cap<<1),r=this.compile(e.subs[0]),s=this.cap(e.cap<<1|1);return this.cat(this.cat(t,r),s)}case ie.Op.STAR:return this.star(this.compile(e.subs[0]),(e.flags&ke.NON_GREEDY)!==0);case ie.Op.PLUS:return this.plus(this.compile(e.subs[0]),(e.flags&ke.NON_GREEDY)!==0);case ie.Op.QUEST:return this.quest(this.compile(e.subs[0]),(e.flags&ke.NON_GREEDY)!==0);case ie.Op.CONCAT:if(e.subs.length===0)return this.nop();{let t=null;for(let r of e.subs){const s=this.compile(r);t=t===null?s:this.cat(t,s)}return t}case ie.Op.ALTERNATE:if(e.subs.length===0)return this.nop();{let t=null;for(let r of e.subs){const s=this.compile(r);t=t===null?s:this.alt(t,s)}return t}default:throw new tO("regexp: unhandled case in compile")}}},xO=class Gs{static simplify(e){if(e===null)return null;switch(e.op){case ie.Op.PLB:case ie.Op.NLB:case ie.Op.CAPTURE:{const t=Gs.simplify(e.subs[0]);if(t!==e.subs[0]){const r=ie.fromRegexp(e);return r.runes=[],r.subs=[t],r}return e}case ie.Op.CONCAT:case ie.Op.ALTERNATE:{const t=[];let r=!1;for(let s=0;s<e.subs.length;s++){const a=e.subs[s],c=Gs.simplify(a);
1992if(c!==a&&(r=!0),e.op===ie.Op.CONCAT){if(c.op===ie.Op.NO_MATCH)return new ie(ie.Op.NO_MATCH);if(c.op===ie.Op.EMPTY_MATCH){r=!0;continue}if(c.op===ie.Op.CONCAT){r=!0;for(let u=0;u<c.subs.length;u++)t.push(c.subs[u]);continue}}else if(e.op===ie.Op.ALTERNATE){if(c.op===ie.Op.NO_MATCH){r=!0;continue}if(c.op===ie.Op.ALTERNATE){r=!0;for(let u=0;u<c.subs.length;u++)t.push(c.subs[u]);continue}}t.push(c)}if(r){if(t.length===0)return new ie(e.op===ie.Op.CONCAT?ie.Op.EMPTY_MATCH:ie.Op.NO_MATCH);if(t.length===1)return t[0];const s=ie.fromRegexp(e);return s.runes=[],s.subs=t,s}return e}case ie.Op.CHAR_CLASS:return e.runes===null?e:e.runes.length===0?new ie(ie.Op.NO_MATCH):e.runes.length===2&&e.runes[0]===0&&e.runes[1]===Ge.MAX_RUNE?new ie(ie.Op.ANY_CHAR):e.runes.length===4&&e.runes[0]===0&&e.runes[1]===ye.CODES.get(`
1993`)-1&&e.runes[2]===ye.CODES.get(`
1994`)+1&&e.runes[3]===Ge.MAX_RUNE?new ie(ie.Op.ANY_CHAR_NOT_NL):e;case ie.Op.STAR:case ie.Op.PLUS:case ie.Op.QUEST:{const t=Gs.simplify(e.subs[0]);return Gs.simplify1(e.op,e.flags,t,e)}case ie.Op.REPEAT:{if(e.min===0&&e.max===0)return new ie(ie.Op.EMPTY_MATCH);const t=Gs.simplify(e.subs[0]);if(e.max===-1){if(e.min===0)return Gs.simplify1(ie.Op.STAR,e.flags,t,null);if(e.min===1)return Gs.simplify1(ie.Op.PLUS,e.flags,t,null);const s=new ie(ie.Op.CONCAT),a=[];for(let c=0;c<e.min-1;c++)a.push(t);return a.push(Gs.simplify1(ie.Op.PLUS,e.flags,t,null)),s.subs=a.slice(0),Gs.simplify(s)}if(e.min===1&&e.max===1)return t;let r=null;if(e.min>0){r=[];for(let s=0;s<e.min;s++)r.push(t)}if(e.max>e.min){let s=Gs.simplify1(ie.Op.QUEST,e.flags,t,null);for(let a=e.min+1;a<e.max;a++){const c=new ie(ie.Op.CONCAT);c.subs=[t,s],s=Gs.simplify1(ie.Op.QUEST,e.flags,c,null)}if(r===null)return s;r.push(s)}if(r!==null){const s=new ie(ie.Op.CONCAT);return s.subs=r.slice(0),Gs.simplify(s)}return new ie(ie.Op.NO_MATCH)}}return e}static simplify1(e,t,r,s){if(r.op===ie.Op.EMPTY_MATCH)return r;if(r.op===ie.Op.NO_MATCH)return e===ie.Op.PLUS?r:new ie(ie.Op.EMPTY_MATCH);if(e===r.op&&(t&ke.NON_GREEDY)===(r.flags&ke.NON_GREEDY))return r;if(s!==null&&s.op===e&&(s.flags&ke.NON_GREEDY)===(t&ke.NON_GREEDY)&&r===s.subs[0])return s;const a=new ie(e);return a.flags=t,a.subs=[r],a}},zt=class{constructor(n,e){this.sign=n,this.cls=e}};const c_=[48,57],u_=[9,10,12,13,32,32],d_=[48,57,65,90,95,95,97,122],h_=new Map([["\\d",new zt(1,c_)],["\\D",new zt(-1,c_)],["\\s",new zt(1,u_)],["\\S",new zt(-1,u_)],["\\w",new zt(1,d_)],["\\W",new zt(-1,d_)]]),f_=[48,57,65,90,97,122],m_=[65,90,97,122],g_=[0,127],p_=[9,9,32,32],B_=[0,31,127,127],y_=[48,57],x_=[33,126],C_=[97,122],b_=[32,126],v_=[33,47,58,64,91,96,123,126],w_=[9,13,32,32],E_=[65,90],__=[48,57,65,90,95,95,97,122],T_=[48,57,65,70,97,102],k_=new Map([["[:alnum:]",new zt(1,f_)],["[:^alnum:]",new zt(-1,f_)],["[:alpha:]",new zt(1,m_)],["[:^alpha:]",new zt(-1,m_)],["[:ascii:]",new zt(1,g_)],["[:^ascii:]",new zt(-1,g_)],["[:blank:]",new zt(1,p_)],["[:^blank:]",new zt(-1,p_)],["[:cntrl:]",new zt(1,B_)],["[:^cntrl:]",new zt(-1,B_)],["[:digit:]",new zt(1,y_)],["[:^digit:]",new zt(-1,y_)],["[:graph:]",new zt(1,x_)],["[:^graph:]",new zt(-1,x_)],["[:lower:]",new zt(1,C_)],["[:^lower:]",new zt(-1,C_)],["[:print:]",new zt(1,b_)],["[:^print:]",new zt(-1,b_)],["[:punct:]",new zt(1,v_)],["[:^punct:]",new zt(-1,v_)],["[:space:]",new zt(1,w_)],["[:^space:]",new zt(-1,w_)],["[:upper:]",new zt(1,E_)],["[:^upper:]",new zt(-1,E_)],["[:word:]",new zt(1,__)],["[:^word:]",new zt(-1,__)],["[:xdigit:]",new zt(1,T_)],["[:^xdigit:]",new zt(-1,T_)]]);var Ro=class Oo{static charClassToString(e,t){let r="[";for(let s=0;s<t;s+=2){s>0&&(r+=" ");const a=e[s],c=e[s+1];a===c?r+=`0x${a.toString(16)}`:r+=`0x${a.toString(16)}-0x${c.toString(16)}`}return r+="]",r}static cmp(e,t,r,s){const a=e[t]-r;return a!==0?a:s-e[t+1]}static qsortIntPair(e,t,r){const s=((t+r)/2|0)&-2,a=e[s],c=e[s+1];let u=t,h=r;for(;u<=h;){for(;u<r&&Oo.cmp(e,u,a,c)<0;)u+=2;for(;h>t&&Oo.cmp(e,h,a,c)>0;)h-=2;if(u<=h){if(u!==h){let f=e[u];e[u]=e[h],e[h]=f,f=e[u+1],e[u+1]=e[h+1],e[h+1]=f}u+=2,h-=2}}t<h&&Oo.qsortIntPair(e,t,h),u<r&&Oo.qsortIntPair(e,u,r)}constructor(e=Ze.emptyInts()){this.r=e,this.len=e.length}toArray(){return this.len===this.r.length?this.r:this.r.slice(0,this.len)}cleanClass(){if(this.len<4)return this;Oo.qsortIntPair(this.r,0,this.len-2);let e=2;for(let t=2;t<this.len;t+=2){const r=this.r[t],s=this.r[t+1];if(r<=this.r[e-1]+1){s>this.r[e-1]&&(this.r[e-1]=s);continue}this.r[e]=r,this.r[e+1]=s,e+=2}return this.len=e,this}appendLiteral(e,t){return(t&ke.FOLD_CASE)!==0?this.appendFoldedRange(e,e):this.appendRange(e,e)}appendRange(e,t){if(this.len>0){for(let r=2;r<=4;r+=2)if(this.len>=r){const s=this.r[this.len-r],a=this.r[this.len-r+1];if(e<=a+1&&s<=t+1)return e<s&&(this.r[this.len-r]=e),t>a&&(this.r[this.len-r+1]=t),this}}return this.r[this.len++]=e,this.r[this.len++]=t,this}appendFoldedRange(e,t){if(e<=Ge.MIN_FOLD&&t>=Ge.MAX_FOLD)return this.appendRange(e,t);if(t<Ge.MIN_FOLD||e>Ge.MAX_FOLD)return this.appendRange(e,t);e<Ge.MIN_FOLD&&(this.appendRange(e,Ge.MIN_FOLD-1),e=Ge.MIN_FOLD),t>Ge.MAX_FOLD&&(this.appendRange(Ge.MAX_FOLD+1,t),t=Ge.MAX_FOLD);for(let r=e;r<=t;r++){this.appendRange(r,r);for(let s=Ge.simpleFold(r);s!==r;s=Ge.simpleFold(s))this.appendRange(s,s)}return this}appendClass(e){for(let t=0;t<e.length;t+=2)this.appendRange(e[t],e[t+1]);return this}appendFoldedClass(e){for(let t=0;t<e.length;t+=2)this.appendFoldedRange(e[t],e[t+1]);return this}appendNegatedClass(e){let t=0;for(let r=0;r<e.length;r+=2){const s=e[r],a=e[r+1];t<=s-1&&this.appendRange(t,s-1),t=a+1}return t<=Ge.MAX_RUNE&&this.appendRange(t,Ge.MAX_RUNE),this}appendTable(e){for(let t=0;t<e.length;++t){const r=e.getLo(t),s=e.getHi(t),a=e.getStride(t);if(a===1){this.appendRange(r,s);continue}for(let c=r;c<=s;c+=a)this.appendRange(c,c)}return this}appendNegatedTable(e){let t=0;for(let r=0;r<e.length;++r){const s=e.getLo(r),a=e.getHi(r),c=e.getStride(r);if(c===1){t<=s-1&&this.appendRange(t,s-1),t=a+1;continue}for(let u=s;u<=a;u+=c)t<=u-1&&this.appendRange(t,u-1),t=u+1}return t<=Ge.MAX_RUNE&&this.appendRange(t,Ge.MAX_RUNE),this}appendTableWithSign(e,t){return t<0?this.appendNegatedTable(e):this.appendTable(e)}negateClass(){let e=0,t=0;for(let r=0;r<this.len;r+=2){const s=this.r[r],a=this.r[r+1];e<=s-1&&(this.r[t]=e,this.r[t+1]=s-1,t+=2),e=a+1}return this.len=t,e<=Ge.MAX_RUNE&&(this.r[this.len++]=e,this.r[this.len++]=Ge.MAX_RUNE),this}appendClassWithSign(e,t){return t<0?this.appendNegatedClass(e):this.appendClass(e)}appendGroup(e,t){let r=e.cls;return t&&(r=new Oo().appendFoldedClass(r).cleanClass().toArray()),this.appendClassWithSign(r,e.sign)}toString(){return Oo.charClassToString(this.r,this.len)}},CO=class{constructor(n){this.str=n,this.position=0}pos(){return this.position}rewindTo(n){this.position=n}more(){return this.position<this.str.length}peek(){return this.str.codePointAt(this.position)}skip(n){this.position+=n}skipString(n){this.position+=n.length}pop(){const n=this.str.codePointAt(this.position);return this.position+=Ze.charCount(n),n}lookingAt(n){return this.str.startsWith(n,this.position)}rest(){return this.str.substring(this.position)}from(n){return this.str.substring(n,this.position)}toString(){return this.rest()}},Re,bO=(Re=class{static unicodeTable(e){return e==="Any"?{tab:Re.ANY_TABLE,fold:Re.ANY_TABLE,sign:1}
1994:e==="Ascii"?{tab:Re.ASCII_TABLE,fold:Re.ASCII_FOLD_TABLE,sign:1}:e==="Assigned"?{tab:Es.CATEGORIES.get("Cn"),fold:Es.CATEGORIES.get("Cn"),sign:-1}:e==="Lc"?{tab:Es.CATEGORIES.get("LC"),fold:Es.FOLD_CATEGORIES.get("LC"),sign:1}:Es.CATEGORIES.has(e)?{tab:Es.CATEGORIES.get(e),fold:Es.FOLD_CATEGORIES.get(e),sign:1}:Es.SCRIPTS.has(e)?{tab:Es.SCRIPTS.get(e),fold:Es.FOLD_SCRIPT.get(e),sign:1}:null}static minFoldRune(e){if(e<Ge.MIN_FOLD||e>Ge.MAX_FOLD)return e;let t=e;const r=e;for(e=Ge.simpleFold(e);e!==r;e=Ge.simpleFold(e))t>e&&(t=e);return t}static leadingRegexp(e){if(e.op===ie.Op.EMPTY_MATCH)return null;if(e.op===ie.Op.CONCAT&&e.subs.length>0){const t=e.subs[0];return t.op===ie.Op.EMPTY_MATCH?null:t}return e}static literalRegexp(e,t){const r=new ie(ie.Op.LITERAL);return r.flags=t,r.runes=Ze.stringToRunes(e),r}static parse(e,t){return new Re(e,t).parseInternal()}static parseRepeat(e){const t=e.pos();if(!e.more()||!e.lookingAt("{"))return-1;e.skip(1);const r=Re.parseInt(e);if(r===-1||!e.more())return-1;let s;if(!e.lookingAt(","))s=r;else{if(e.skip(1),!e.more())return-1;if(e.lookingAt("}"))s=-1;else if((s=Re.parseInt(e))===-1)return-1}if(!e.more()||!e.lookingAt("}"))return-1;if(e.skip(1),r<0||r>1e3||s===-2||s>1e3||s>=0&&r>s)throw new vn(Re.ERR_INVALID_REPEAT_SIZE,e.from(t));return r<<16|s&Ge.MAX_BMP}static isValidCaptureName(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++){const r=e.codePointAt(t);if(r!==ye.CODES.get("_")&&!Ze.isalnum(r))return!1}return!0}static parseInt(e){const t=e.pos();for(;e.more()&&e.peek()>=ye.CODES.get("0")&&e.peek()<=ye.CODES.get("9");)e.skip(1);const r=e.from(t);return r.length===0||r.length>1&&r.codePointAt(0)===ye.CODES.get("0")?-1:r.length>8?-2:parseInt(r,10)}static isCharClass(e){return e.op===ie.Op.LITERAL&&e.runes.length===1||e.op===ie.Op.CHAR_CLASS||e.op===ie.Op.ANY_CHAR_NOT_NL||e.op===ie.Op.ANY_CHAR}static matchRune(e,t){switch(e.op){case ie.Op.LITERAL:return e.runes.length===1&&e.runes[0]===t;case ie.Op.CHAR_CLASS:for(let r=0;r<e.runes.length;r+=2)if(e.runes[r]<=t&&t<=e.runes[r+1])return!0;return!1;case ie.Op.ANY_CHAR_NOT_NL:return t!==ye.CODES.get(`
1995`);case ie.Op.ANY_CHAR:return!0}return!1}static mergeCharClass(e,t){switch(e.op){case ie.Op.ANY_CHAR:break;case ie.Op.ANY_CHAR_NOT_NL:Re.matchRune(t,ye.CODES.get(`
1996`))&&(e.op=ie.Op.ANY_CHAR);break;case ie.Op.CHAR_CLASS:t.op===ie.Op.LITERAL?e.runes=new Ro(e.runes).appendLiteral(t.runes[0],t.flags).toArray():e.runes=new Ro(e.runes).appendClass(t.runes).toArray();break;case ie.Op.LITERAL:if(t.runes[0]===e.runes[0]&&t.flags===e.flags)break;e.op=ie.Op.CHAR_CLASS,e.runes=new Ro().appendLiteral(e.runes[0],e.flags).appendLiteral(t.runes[0],t.flags).toArray();break}}static parseEscape(e){const t=e.pos();if(e.skip(1),!e.more())throw new vn(Re.ERR_TRAILING_BACKSLASH);let r=e.pop();e:switch(r){case ye.CODES.get("1"):case ye.CODES.get("2"):case ye.CODES.get("3"):case ye.CODES.get("4"):case ye.CODES.get("5"):case ye.CODES.get("6"):case ye.CODES.get("7"):if(!e.more(
1996)||e.peek()<ye.CODES.get("0")||e.peek()>ye.CODES.get("7"))break;case ye.CODES.get("0"):{let s=r-ye.CODES.get("0");for(let a=1;a<3&&!(!e.more()||e.peek()<ye.CODES.get("0")||e.peek()>ye.CODES.get("7"));a++)s=s*8+e.peek()-ye.CODES.get("0"),e.skip(1);return s}case ye.CODES.get("x"):{if(!e.more())break;if(r=e.pop(),r===ye.CODES.get("{")){let c=0,u=0;for(;;){if(!e.more())break e;if(r=e.pop(),r===ye.CODES.get("}"))break;const h=Ze.unhex(r);if(h<0||(u=u*16+h,u>Ge.MAX_RUNE))break e;c++}if(c===0)break e;return u}const s=Ze.unhex(r);if(!e.more())break;r=e.pop();const a=Ze.unhex(r);if(s<0||a<0)break;return s*16+a}case ye.CODES.get("a"):return ye.CODES.get("\x07");case ye.CODES.get("f"):return ye.CODES.get("\f");case ye.CODES.get("n"):return ye.CODES.get(`
1997`);case ye.CODES.get("r"):return ye.CODES.get("\r");case ye.CODES.get("t"):return ye.CODES.get("	");case ye.CODES.get("v"):return ye.CODES.get("\v");default:if(r<=Ge.MAX_ASCII&&!Ze.isalnum(r))return r;break}throw new vn(Re.ERR_INVALID_ESCAPE,e.from(t))}static parseClassChar(e,t){if(!e.more())throw new vn(Re.ERR_MISSING_BRACKET,e.from(t));return e.lookingAt("\\")?Re.parseEscape(e):e.pop()}static concatRunes(e,t){for(let r=0;r<t.length;r++)e.push(t[r]);return e}static hasCapture(e){if(e===null)return!1;if(e.op===ie.Op.CAPTURE)return!0;if(e.subs){for(let t of e.subs)if(Re.hasCapture(t))return!0}return!1}constructor(e,t=0){this.wholeRegexp=e,this.flags=t,this.numCap=0,this.namedGroups=Object.create(null),this.stack=[],this.free=null,this.numRegexp=0,this.numRunes=0,this.repeats=0,this.height=null,this.size=null,this.nlb=0}newRegexp(e){let t=this.free;return t!==null&&t.subs!==null&&t.subs.length>0?(this.free=t.subs[0],t.reinit(),t.op=e):(t=new ie(e),this.numRegexp+=1),t}reuse(e){this.height!==null&&this.height.has(e)&&this.height.delete(e),e.subs!==null&&e.subs.length>0&&(e.subs[0]=this.free),this.free=e}checkLimits(e){if(this.numRunes>Re.MAX_RUNES)throw new vn(Re.ERR_LARGE);this.checkSize(e),this.checkHeight(e)}checkSize(e){if(this.size===null){if(this.repeats===0&&(this.repeats=1),e.op===ie.Op.REPEAT){let t=e.max;t===-1&&(t=e.min),t<=0&&(t=1),t>Math.floor(Re.MAX_SIZE/this.repeats)?this.repeats=Re.MAX_SIZE:this.repeats*=t}if(this.numRegexp<Math.floor(Re.MAX_SIZE/this.repeats))return;this.size=new Map;for(let t of this.stack)this.checkSize(t)}if(this.calcSize(e,!0)>Re.MAX_SIZE)throw new vn(Re.ERR_LARGE)}calcSize(e,t=!1){if(!t&&this.size!==null&&this.size.has(e))return this.size.get(e);let r=0;switch(e.op){case ie.Op.LITERAL:r=e.runes.length;break;case ie.Op.PLB:case ie.Op.NLB:case ie.Op.CAPTURE:case ie.Op.STAR:r=2+this.calcSize(e.subs[0]);break;case ie.Op.PLUS:case ie.Op.QUEST:r=1+this.calcSize(e.subs[0]);break;case ie.Op.CONCAT:for(let s of e.subs)r=r+this.calcSize(s);break;case ie.Op.ALTERNATE:for(let s of e.subs)r=r+this.calcSize(s);e.subs.length>1&&(r=r+e.subs.length-1);break;case ie.Op.REPEAT:{let s=this.calcSize(e.subs[0]);if(e.max===-1){e.min===0?r=2+s:r=1+e.min*s;break}r=e.max*s+(e.max-e.min);break}}return r=Math.max(1,r),this.size===null&&(this.size=new Map),this.size.set(e,r),r}checkHeight(e){if(!(this.numRegexp<Re.MAX_HEIGHT)){if(this.height===null){this.height=new Map;for(let t of this.stack)this.checkHeight(t)}if(this.calcHeight(e,!0)>Re.MAX_HEIGHT)throw new vn(Re.ERR_NESTING_DEPTH)}}calcHeight(e,t=!1){if(!t&&this.height!==null&&this.height.has(e))return this.height.get(e);let r=1;for(let s of e.subs){const a=this.calcHeight(s);r<1+a&&(r=1+a)}return this.height===null&&(this.height=new Map),this.height.set(e,r),r}pop(){return this.stack.pop()}popToPseudo(){const e=this.stack.length;let t=e;for(;t>0&&!ie.isPseudoOp(this.stack[t-1].op);)t--;const r=this.stack.slice(t,e);return this.stack=this.stack.slice(0,t),r}push(e){if(this.numRunes+=e.runes.length,e.op===ie.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]===e.runes[1]){if(this.maybeConcat(e.runes[0],this.flags&-2))return null;e.op=ie.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags&-2}else if(e.op===ie.Op.CHAR_CLASS&&e.runes.length===4&&e.runes[0]===e.runes[1]&&e.runes[2]===e.runes[3]&&Ge.simpleFold(e.runes[0])===e.runes[2]&&Ge.simpleFold(e.runes[2])===e.runes[0]||e.op===ie.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]+1===e.runes[1]&&Ge.simpleFold(e.runes[0])===e.runes[1]&&Ge.simpleFold(e.runes[1])===e.runes[0]){if
vendor: 4,468 bytes, lines 1997-1999
1997(this.maybeConcat(e.runes[0],this.flags|ke.FOLD_CASE))return null;e.op=ie.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags|ke.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(e),this.checkLimits(e),e}maybeConcat(e,t){const r=this.stack.length;if(r<2)return!1;const s=this.stack[r-1],a=this.stack[r-2];return s.op!==ie.Op.LITERAL||a.op!==ie.Op.LITERAL||(s.flags&ke.FOLD_CASE)!==(a.flags&ke.FOLD_CASE)?!1:(a.runes=Re.concatRunes(a.runes,s.runes),e>=0?(s.runes=[e],s.flags=t,!0):(this.pop(),this.reuse(s),!1))}newLiteral(e,t){const r=this.newRegexp(ie.Op.LITERAL);return r.flags=t,(t&ke.FOLD_CASE)!==0&&(e=Re.minFoldRune(e)),r.runes=[e],r}literal(e){this.push(this.newLiteral(e,this.flags))}op(e){const t=this.newRegexp(e);return t.flags=this.flags,this.push(t)}repeat(e,t,r,s,a,c){let u=this.flags;if((u&ke.PERL_X)!==0&&(a.more()&&a.lookingAt("?")&&(a.skip(1),u^=ke.NON_GREEDY),c!==-1))throw new vn(Re.ERR_INVALID_REPEAT_OP,a.from(c));const h=this.stack.length;if(h===0)throw new vn(Re.ERR_MISSING_REPEAT_ARGUMENT,a.from(s));const f=this.stack[h-1];if(ie.isPseudoOp(f.op))throw new vn(Re.ERR_MISSING_REPEAT_ARGUMENT,a.from(s));const p=this.newRegexp(e);if(p.min=t,p.max=r,p.flags=u,p.subs=[f],this.stack[h-1]=p,this.checkLimits(p),e===ie.Op.REPEAT&&(t>=2||r>=2)&&!this.repeatIsValid(p,1e3))throw new vn(Re.ERR_INVALID_REPEAT_SIZE,a.from(s))}repeatIsValid(e,t){if(e.op===ie.Op.REPEAT){let r=e.max;if(r===0)return!0;if(r<0&&(r=e.min),r>t)return!1;r>0&&(t=Math.trunc(t/r))}for(let r of e.subs)if(!this.repeatIsValid(r,t))return!1;return!0}concat(){this.maybeConcat(-1,0);const e=this.popToPseudo();return e.length===0?this.push(this.newRegexp(ie.Op.EMPTY_MATCH)):this.push(this.collapse(e,ie.Op.CONCAT))}alternate(){const e=this.popToPseudo();return e.length>0&&this.cleanAlt(e[e.length-1]),e.length===0?this.push(this.newRegexp(ie.Op.NO_MATCH)):this.push(this.collapse(e,ie.Op.ALTERNATE))}cleanAlt(e){e.op===ie.Op.CHAR_CLASS&&(e.runes=new Ro(e.runes).cleanClass().toArray(),e.runes.length===2&&e.runes[0]===0&&e.runes[1]===Ge.MAX_RUNE?(e.runes=[],e.op=ie.Op.ANY_CHAR):e.runes.length===4&&e.runes[0]===0&&e.runes[1]===ye.CODES.get(`
1998`)-1&&e.runes[2]===ye.CODES.get(`
1999`)+1&&e.runes[3]===Ge.MAX_RUNE&&(e.runes=[],e.op=ie.Op.ANY_CHAR_NOT_NL))}collapse(e,t){if(e.length===1)return e[0];let r=0;for(let u of e)r+=u.op===t?u.subs.length:1;let s=new Array(r).fill(null),a=0;for(let u of e)if(u.op===t){for(let h=0;h<u.subs.length;h++)s[a++]=u.subs[h];this.reuse(u)}else s[a++]=u;let c=this.newRegexp(t);if(c.subs=s,t===ie.Op.ALTERNATE&&(c.subs=this.factor(c.subs),c.subs.length===1)){const u=c;c=c.subs[0],this.reuse(u)}return c}factor(e){if(e.length<2)return e;let t=0,r=e.length,s=0,a=null,c=0,u=0,h=0;for(let p=0;p<=r;p++){let y=null,b=0,w=0;if(p<r){let E=e[t+p];if(E.op===ie.Op.CONCAT&&E.subs.length>0&&(E=E.subs[0]),E.op===ie.Op.LITERAL&&(y=E.runes,b=E.runes.length,w=E.flags&ke.FOLD_CASE),w===u){let N=0;for(;N<c&&N<b&&a[N]===y[N];)N++;if(N>0){c=N;continue}}}if(p!==h)if(p===h+1)e[s++]=e[t+h];else{const E=this.newRegexp(ie.Op.LITERAL);E.flags=u,E.runes=a.slice(0,c);for(let I=h;I<p;I++)e[t+I]=this.removeLeadingString(e[t+I],c),this.checkLimits(e[t+I]);const N=this.collapse(e.slice(t+h,t+p),ie.Op.ALTERNATE),S=this.newRegexp(ie.Op.CONCAT);S.subs=[E,N],e[s++]=S}h=p,a=y,c=b,u=w}r=s,t=0,h=0,s=0;let f=null;for(let p=0;p<=r;p++){let y=null;if(!(p<r&&(y=Re.leadingRegexp(e[t+p]),f!==null&&f.equals(y)&&(Re.isCharClass(f)||f.op===ie.Op.REPEAT&&f.min===f.max&&Re.isCharClass(f.subs[0]))))){if(p!==h)if(p===h+1)e[s++]=e[t+h];else{const b=f;for(let N=h;N<p;N++){const S=N!==h;e[t+N]=this.removeLeadingRegexp(e[t+N],S),this.checkLimits(e[t+N])}const w=this.collapse(e.slice(t+h,t+p),ie.Op.ALTERNATE),E=this.newRegexp(ie.Op.CONCAT);E.subs=[b,w],e[s++]=E}h=p,f=y}}r=s,t=0,h=0,s=0;for(let p=0;p<=r;p++)if(!(p<r&&Re.isCharClass(e[t+p]))){if(p!==h)if(p===h+1)e[s++]=e[t+h];else{let y=h;for(let w=h+1;w<p;w++){const E=e[t+y],N=e[t+w];(E.op<N.op||E.op===N.op&&(E.runes!==null?E.runes.length:0)<(N.runes!==null?N.runes.length:0))&&(y=w)}const b=e[t+h];e[t+h]=e[t+y],e[t+y]=b;for(let w=h+1;w<p;w++)Re.mergeCharClass(e[t+h],e[t+w]),this.reuse(e[t+w]);this.cleanAlt(e[t+h]),e[s++]=e[t+h]}p<r&&(e[s++]=e[t+p]),h=p+1}r=s,t=0,h=0,s=0;for(let p=0;p<r;++p)p+1<r&&e[t+p].op===ie.Op.EMPTY_MATCH&&e[t+p+1].op===ie.Op.EMPTY_MATCH||(e[s++]=e[t+p]);return r=s,t=0,e.slice(t,r)}removeLeadingString(e,t){if(e.op===ie.Op.CONCAT&&e.subs.length>0){const r=this.removeLeadingString(e.subs[0],t);
1999if(e.subs[0]=r,r.op===ie.Op.EMPTY_MATCH)switch(this.reuse(r),e.subs.length){case 0:case 1:e.op=ie.Op.EMPTY_MATCH,e.subs=ie.emptySubs();break;case 2:{const s=e;e=e.subs[1],this.reuse(s);break}default:e.subs=e.subs.slice(1,e.subs.length);break}return e}return e.op===ie.Op.LITERAL&&(e.runes=e.runes.slice(t,e.runes.length),e.runes.length===0&&(e.op=ie.Op.EMPTY_MATCH)),e}removeLeadingRegexp(e,t){if(e.op===ie.Op.CONCAT&&e.subs.length>0){switch(t&&this.reuse(e.subs[0]),e.subs=e.subs.slice(1,e.subs.length),e.subs.length){case 0:e.op=ie.Op.EMPTY_MATCH,e.subs=ie.emptySubs();break;case 1:{const r=e;e=e.subs[0],this.reuse(r);break}}return e}return t&&this.reuse(e),this.newRegexp(ie.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&ke.LITERAL)!==0)return Re.literalRegexp(this.wholeRegexp,this.flags);let e=-1,t=-1,r=-1;const s=new CO(this.wholeRegexp);for(;s.more();){let a=-1;e:switch(s.peek()){case ye.CODES.get("("):if((this.flags&ke.LOOKBEHIND)!==0){if(s.lookingAt("(?<=")){this.parsePosLookBehind(),s.skip(4);break}if(s.lookingAt("(?<!")){this.parseNegLookBehind(),s.skip(4);break}}if((this.flags&ke.PERL_X)!==0&&s.lookingAt("(?")){this.parsePerlFlags(s);break}this.op(ie.Op.LEFT_PAREN).cap=++this.numCap,s.skip(1);break;case ye.CODES.get("|"):this.parseVerticalBar(),s.skip(1);break;case ye.CODES.get(")"):this.parseRightParen(),s.skip(1);break;case ye.CODES.get("^"):(this.flags&ke.ONE_LINE)!==0?this.op(ie.Op.BEGIN_TEXT):this.op(ie.Op.BEGIN_LINE),s.skip(1);break;case ye.CODES.get("$"):(this.flags&ke.ONE_LINE)!==0?this.op(ie.Op.END_TEXT).flags|=ke.WAS_DOLLAR:this.op(ie.Op.END_LINE),s.skip(1);break;case ye.CODES.get("."):(this.flags&ke.DOT_NL)!==0?this.op(ie.Op.ANY_CHAR):this.op(ie.Op.ANY_CHAR_NOT_NL),s.skip(1);break;case ye.CODES.get("["):this.parseClass(s);break;case ye.CODES.get("*"):case ye.CODES.get("+"):case ye.CODES.get("?"):{a=s.pos();let c=null;switch(s.pop()){case ye.CODES.get("*"):c=ie.Op.STAR;break;case ye.CODES.get("+"):c=ie.Op.PLUS;break;case ye.CODES.get("?"):c=ie.Op.QUEST;break}this.repeat(c,t,r,a,s,e);break}case ye.CODES.get("{"):{a=s.pos();const c=Re.parseRepeat(s);if(c<0){s.rewindTo(a),this.literal(s.pop());break}t=c>>16,r=(c&Ge.MAX_BMP)<<16>>16,this.repeat(ie.Op.REPEAT,t,r,a,s,e);break}case ye.CODES.get("\\"):{const c=s.pos();if(s.skip(1),(this.flags&ke.PERL_X)!==0&&s.more())switch(s.pop()){case ye.CODES.get("A"):this.op(ie.Op.BEGIN_TEXT);break e;case ye.CODES.get("b"):this.op(ie.Op.WORD_BOUNDARY);break e;case ye.CODES.get("B"):this.op(ie.Op.NO_WORD_BOUNDARY);break e;case ye.CODES.get("C"):throw new vn(Re.ERR_INVALID_ESCAPE,"\\C");case ye.CODES.get("Q"):{let f=s.rest();const p=f.indexOf("\\E");p>=0?(f=f.substring(0,p),s.skipString(f),s.skipString("\\E")):s.skipString(f);let y=0;for(;y<f.length;){const b=f.codePointAt(y);this.literal(b),y+=Ze.charCount(b)}break e}case ye.CODES.get("z"):this.op(ie.Op.END_TEXT);break e;default:s.rewindTo(c);break}else s.rewindTo(c);const u=this.newRegexp(ie.Op.CHAR_CLASS);if(u.flags=this.flags,s.lookingAt("\\p")||s.lookingAt("\\P")){const f=new Ro;if(this.parseUnicodeClass(s,f)){u.runes=f.toArray(),this.push(u);break e}}const h=new Ro;if(this.parsePerlClassEscape(s,h)){u.runes=h.toArray(),this.push(u);break e}s.rewindTo(c),this.reuse(u),this.literal(Re.parseEscape(s));break}default:this.literal(s.pop());break}e=a}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length!==1)throw new vn(Re.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(e){const t=e.pos(),r=e.rest();if(r.startsWith("(?P<")||r.startsWith("(?<")){const u=r.charAt(2)==="P"?4:3,h=r.indexOf(">");if(h<0)throw new vn(Re.ERR_INVALID_NAMED_CAPTURE,r);const f=r.substring(u,h);if(e.skipString(f),e.skip(u+1),!Re.isValidCaptureName(f))throw new vn(Re.ERR_INVALID_NAMED_CAPTURE,r.substring(0,h+1));const p=this.op(ie.Op.LEFT_PAREN);if(p.cap=++this.numCap,this.namedGroups[f])throw new vn(Re.ERR_DUPLICATE_NAMED_CAPTURE,f);this.namedGroups[f]=this.numCap,p.name=f;return}e.skip(2);let s=this.flags,a=1,c=!1;e:for(;e.more();){const u=e.pop();switch(u){case ye.CODES.get("i"):s|=ke.FOLD_CASE,c=!0;break;case ye.CODES.get("m"):s&=-17,c=!0;break;case ye.CODES.get("s"):s|=ke.DOT_NL,c=!0;break;case ye.CODES.get("U"):s|=ke.NON_GREEDY,c=!0;break;case ye.CODES.get("-"):if(a<0)break e;a=-1,s=~s,c=!1;break;case ye.CODES.get(":"):case ye.CODES.get(")"):if(a<0){if(!c)break e;s=~s}u===ye.CODES.get(":")&&this.op(ie.Op.LEFT_PAREN),this.flags=s;return;default:break e}}
1999throw new vn(Re.ERR_INVALID_PERL_OP,e.from(t))}parsePosLookBehind(){const e=this.newRegexp(ie.Op.LEFT_PAREN);return e.flags=this.flags,e.lb=++this.nlb,this.push(e)}parseNegLookBehind(){const e=this.newRegexp(ie.Op.LEFT_PAREN);return e.flags=this.flags,e.lb=-++this.nlb,this.push(e)}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(ie.Op.VERTICAL_BAR)}swapVerticalBar(){const e=this.stack.length;if(e>=3&&this.stack[e-2].op===ie.Op.VERTICAL_BAR&&Re.isCharClass(this.stack[e-1])&&Re.isCharClass(this.stack[e-3])){let t=this.stack[e-1],r=this.stack[e-3];if(t.op>r.op){const s=r;r=t,t=s,this.stack[e-3]=r}return Re.mergeCharClass(r,t),this.reuse(t),this.pop(),!0}if(e>=2){const t=this.stack[e-1],r=this.stack[e-2];if(r.op===ie.Op.VERTICAL_BAR)return e>=3&&this.cleanAlt(this.stack[e-3]),this.stack[e-2]=t,this.stack[e-1]=r,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new vn(Re.ERR_UNEXPECTED_PAREN,this.wholeRegexp);const e=this.pop(),t=this.pop();if(t.op!==ie.Op.LEFT_PAREN)throw new vn(Re.ERR_UNEXPECTED_PAREN,this.wholeRegexp);if(this.flags=t.flags,t.lb!==0){if(Re.hasCapture(e))throw new vn(Re.ERR_INVALID_CAPTURE_IN_LOOKBEHIND,this.wholeRegexp);t.lb>0?t.op=ie.Op.PLB:t.op=ie.Op.NLB,t.subs=[e],this.push(t);return}t.cap===0?this.push(e):(t.op=ie.Op.CAPTURE,t.subs=[e],this.push(t))}parsePerlClassEscape(e,t){const r=e.pos();if((this.flags&ke.PERL_X)===0||!e.more()||e.pop()!==ye.CODES.get("\\")||!e.more())return!1;e.pop();const s=e.from(r),a=h_.has(s)?h_.get(s):null;return a===null?!1:(t.appendGroup(a,(this.flags&ke.FOLD_CASE)!==0),!0)}parseNamedClass(e,t){const r=e.rest(),s=r.indexOf(":]");if(s<0)return!1;const a=r.substring(0,s+2);e.skipString(a);const c=k_.has(a)?k_.get(a):null;if(c===null)throw new vn(Re.ERR_INVALID_CHAR_RANGE,a);return t.appendGroup(c,(this.flags&ke.FOLD_CASE)!==0),!0}parseUnicodeClass(e,t){const r=e.pos();if((this.flags&ke.UNICODE_GROUPS)===0||!e.lookingAt("\\p")&&!e.lookingAt("\\P"))return!1;e.skip(1);let s=1,a=e.pop();if(a===ye.CODES.get("P")&&(s=-1),!e.more())throw e.rewindTo(r),new vn(Re.ERR_INVALID_CHAR_RANGE,e.rest());a=e.pop();let c;if(a!==ye.CODES.get("{"))c=Ze.runeToString(a);else{const p=e.rest(),y=p.indexOf("}");if(y<0)throw e.rewindTo(r),new vn(Re.ERR_INVALID_CHAR_RANGE,e.rest());c=p.substring(0,y),e.skipString(c),e.skip(1)}c.length!==0&&c.codePointAt(0)===ye.CODES.get("^")&&(s=0-s,c=c.substring(1));const u=Re.unicodeTable(c);if(u===null)throw new vn(Re.ERR_INVALID_CHAR_RANGE,e.from(r));u.sign<0&&(s=0-s);const h=u.tab,f=u.fold;if((this.flags&ke.FOLD_CASE)===0||f===null)t.appendTableWithSign(h,s);else{const p=new Ro().appendTable(h).appendTable(f).cleanClass().toArray();t.appendClassWithSign(p,s)}return!0}parseClass(e){const t=e.pos();e.skip(1);const r=this.newRegexp(ie.Op.CHAR_CLASS);r.flags=this.flags;const s=new Ro;let a=1;e.more()&&e.lookingAt("^")&&(a=-1,e.skip(1),(this.flags&ke.CLASS_NL)===0&&s.appendRange(ye.CODES.get(`
2000`),ye.CODES.get(`
2001`)));let c=!0;for(;!e.more()||e.peek()!==ye.CODES.get("]")||c;){if(e.more()&&e.lookingAt("-")&&(this.flags&ke.PERL_X)===0&&!c){const p=e.rest();if(p==="-"||!p.startsWith("-]"))throw e.rewindTo(t),new vn(Re.ERR_INVALID_CHAR_RANGE,e.rest())}c=!1;const u=e.pos();if(e.lookingAt("[:")){if(this.parseNamedClass(e,s))continue;e.rewindTo(u)}if(this.parseUnicodeClass(e,s)||this.parsePerlClassEscape(e,s))continue;e.rewindTo(u);const h=Re.parseClassChar(e,t);let f=h;if(e.more()&&e.lookingAt("-")){if(e.skip(1),e.more()&&e.lookingAt("]"))e.skip(-1);else if(f=Re.parseClassChar(e,t),f<h)throw new vn(Re.ERR_INVALID_CHAR_RANGE,e.from(u))}(this.flags&ke.FOLD_CASE)===0?s.appendRange(h,f):s.appendFoldedRange(h,f)}e.skip(1),s.cleanClass(),a<0&&s.negateClass(),r.runes=s.toArray(),this.push(r)}},Ie(Re,"ERR_INTERNAL_ERROR","regexp/syntax: internal error"),Ie(Re,"ERR_INVALID_CHAR_RANGE","invalid character class range"),Ie(Re,"ERR_INVALID_ESCAPE","invalid escape sequence"),Ie(Re,"ERR_INVALID_NAMED_CAPTURE","invalid named capture"),Ie(Re,"ERR_INVALID_PERL_OP","invalid or unsupported Perl syntax"),Ie(Re,"ERR_INVALID_REPEAT_OP","invali
2001d nested repetition operator"),Ie(Re,"ERR_INVALID_REPEAT_SIZE","invalid repeat count"),Ie(Re,"ERR_MISSING_BRACKET","missing closing ]"),Ie(Re,"ERR_MISSING_PAREN","missing closing )"),Ie(Re,"ERR_MISSING_REPEAT_ARGUMENT","missing argument to repetition operator"),Ie(Re,"ERR_TRAILING_BACKSLASH","trailing backslash at end of expression"),Ie(Re,"ERR_DUPLICATE_NAMED_CAPTURE","duplicate capture group name"),Ie(Re,"ERR_UNEXPECTED_PAREN","unexpected )"),Ie(Re,"ERR_NESTING_DEPTH","expression nests too deeply"),Ie(Re,"ERR_LARGE","expression too large"),Ie(Re,"ERR_INVALID_CAPTURE_IN_LOOKBEHIND","invalid capture in lookbehind"),Ie(Re,"MAX_HEIGHT",1e3),Ie(Re,"MAX_SIZE",3355443),Ie(Re,"MAX_RUNES",33554432),Ie(Re,"ANY_TABLE",new Y(new Uint32Array([0,Ge.MAX_RUNE,1]))),Ie(Re,"ASCII_TABLE",new Y(new Uint32Array([0,127,1]))),Ie(Re,"ASCII_FOLD_TABLE",new Y(new Uint32Array([0,127,1,383,383,1,8490,8490,1]))),Re),vO=class Wl{static initTest(e){const t=Wl.compile(e),r=new Wl(t.expr,t.prog,t.numSubexp,t.longest);return r.cond=t.cond,r.prefix=t.prefix,r.prefixUTF8=t.prefixUTF8,r.prefixComplete=t.prefixComplete,r.prefixRune=t.prefixRune,r.prefilter=t.prefilter,r}static compile(e){return Wl.compileImpl(e,ke.PERL,!1)}static compilePOSIX(e){return Wl.compileImpl(e,ke.POSIX,!0)}static compileImpl(e,t,r){let s=bO.parse(e,t);const a=s.maxCap();s=xO.simplify(s);const c=pO.build(s),u=yO.compileRegexp(s),h=new Wl(e,u,a,r);h.prefilter=c.type===Jt.Type.NONE?null:c;const[f,p]=u.prefix();return h.prefixComplete=f,h.prefix=p,h.prefixUTF8=Ze.stringToUtf8ByteArray(h.prefix),h.prefix.length>0&&(h.prefixRune=h.prefix.codePointAt(0)),h.namedGroups=s.namedGroups,h}static match(e,t){return Wl.compile(e).match(t)}constructor(e,t,r=0,s=0){this.expr=e,this.prog=t,this.numSubexp=r,this.longest=s,this.cond=t.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.machinePool=[],this.dfa=new aO(this.prog),this.onepass=o_.compile(this.prog),this.prefilter=null}matchPrefixComplete(e,t,r,s){if((r===ke.ANCHOR_START||r===ke.ANCHOR_BOTH)&&t!==0)return null;let a=-1,c=-1;const u=e.prefixLength(this);if(r===ke.UNANCHORED){const h=e.index(this,t);if(h<0)return null;a=t+h,c=a+u}else if(r===ke.ANCHOR_BOTH){if(e.endPos()!==u||e.index(this,0)!==0)return null;a=0,c=u}else if(r===ke.ANCHOR_START){if(e.index(this,0)!==0)return null;a=0,c=u}if(a<0)return null;if(s>0){const h=new Int32Array(s).fill(-1);return h[0]=a,h[1]=c,Array.from(h)}return[]}executeEngine(e,t,r,s){if(this.prefixComplete&&(s===0||this.numSubexp===0))return this.matchPrefixComplete(e,t,r,s);if(this.prefilter!==null&&r===ke.UNANCHORED&&!this.prefilter.eval(e,t))return null;if(this.onepass!==null)return o_.execute(this,e,t,r,s);if(s>0)return this.prog.numLb===0&&e.endPos()<=wm.maxBitStateLen(this.prog)?wm.execute(this,e,t,r,s):this.doExecuteNFA(e,t,r,s);if(this.prog.numLb===0){const a=this.dfa.match(e,t,r);if(a!==null)return a?[]:null;if(e.endPos()<=wm.maxBitStateLen(this.prog))return wm.execute(this,e,t,r,s)}return this.doExecuteNFA(e,t,r,s)}numberOfCapturingGroups(){return this.numSubexp}numberOfInstructions(){return this.prog.numInst()}get(){return this.machinePool.length>0?this.machinePool.pop():null}reset(){this.machinePool.length=0}put(e){this.machinePool.push(e)}toString(){return this.expr}doExecuteNFA(e,t,r,s){let a=this.get();a||(a=rO.fromRE2(this)),a.init(s);const c=a.match(e,t,r)?a.submatches():null;return this.put(a),c}match(e){return this.executeEngine(Sn.fromUTF16(e),0,ke.UNANCHORED,0)!==null}matchWithGroup(e,t,r,s,a){return e instanceof Bc||(Ze.isByteArray(e)?e=tc.utf8(e):e=tc.utf16(e)),this.matchMachineInput(e,t,r,s,a)}matchMachineInput(e,t,r,s,a){if(t>r)return[!1,null];const c=e.isUTF16Encoding()?Sn.fromUTF16(e.asCharSequence(),0,r):Sn.fromUTF8(e.asBytes(),0,r),u=this.executeEngine(c,t,s,2*a);return u===null?[!1,null]:[!0,u]}matchUTF8(e){return this.executeEngine(Sn.fromUTF8(e),0,ke.UNANCHORED,0)!==null}replaceAll(e,t){return this.replaceAllFunc(e,()=>t,2*e.length+1)}replaceFirst(e,t){return this.replaceAllFunc(e,()=>t,1)}replaceAllFunc(e,t,r){let s=0,a=0,c="";const u=Sn.fromUTF16(e);let h=0;for(;a<=e.length;){const f=this.executeEngine(u,a,ke.UNANCHORED,2);if(f===null||f.length===0)break;c+=e.substring(s,f[0]),(f[1]>s||f[0]===0)&&(c+=t(e.substring(f[0],f[1])),h++),s=f[1];const p=u.step(a)&7;if(a+p>f[1]?a+=p:a+1>f[1]?a++:a=f[1],h>
2001=r)break}return c+=e.substring(s),c}pad(e){if(e===null)return null;let t=(1+this.numSubexp)*2;if(e.length<t){let r=new Array(t).fill(-1);for(let s=0;s<e.length;s++)r[s]=e[s];e=r}return e}allMatches(e,t,r=s=>s){let s=[];const a=e.endPos();t<0&&(t=a+1);let c=0,u=0,h=-1;for(;u<t&&c<=a;){const f=this.executeEngine(e,c,ke.UNANCHORED,this.prog.numCap);if(f===null||f.length===0)break;let p=!0;if(f[1]===c){f[0]===h&&(p=!1);const y=e.step(c);y<0?c=a+1:c+=y&7}else c=f[1];h=f[1],p&&(s.push(r(this.pad(f))),u++)}return s}findUTF8(e){const t=this.executeEngine(Sn.fromUTF8(e),0,ke.UNANCHORED,2);return t===null?null:e.slice(t[0],t[1])}findUTF8Index(e){const t=this.executeEngine(Sn.fromUTF8(e),0,ke.UNANCHORED,2);return t===null?null:t.slice(0,2)}find(e){const t=this.executeEngine(Sn.fromUTF16(e),0,ke.UNANCHORED,2);return t===null?"":e.substring(t[0],t[1])}findIndex(e){return this.executeEngine(Sn.fromUTF16(e),0,ke.UNANCHORED,2)}findUTF8Submatch(e){const t=this.executeEngine(Sn.fromUTF8(e),0,ke.UNANCHORED,this.prog.numCap);if(t===null)return null;const r=new Array(1+this.numSubexp).fill(null);for(let s=0;s<r.length;s++)2*s<t.length&&t[2*s]>=0&&(r[s]=e.slice(t[2*s],t[2*s+1]));return r}findUTF8SubmatchIndex(e){return this.pad(this.executeEngine(Sn.fromUTF8(e),0,ke.UNANCHORED,this.prog.numCap))}findSubmatch(e){const t=this.executeEngine(Sn.fromUTF16(e),0,ke.UNANCHORED,this.prog.numCap);if(t===null)return null;const r=new Array(1+this.numSubexp).fill(null);for(let s=0;s<r.length;s++)2*s<t.length&&t[2*s]>=0&&(r[s]=e.substring(t[2*s],t[2*s+1]));return r}findSubmatchIndex(e){return this.pad(this.executeEngine(Sn.fromUTF16(e),0,ke.UNANCHORED,this.prog.numCap))}findAllUTF8(e,t){const r=this.allMatches(Sn.fromUTF8(e),t,s=>e.slice(s[0],s[1]));return r.length===0?null:r}findAllUTF8Index(e,t){const r=this.allMatches(Sn.fromUTF8(e),t,s=>s.slice(0,2));return r.length===0?null:r}findAll(e,t){const r=this.allMatches(Sn.fromUTF16(e),t,s=>e.substring(s[0],s[1]));return r.length===0?null:r}findAllIndex(e,t){const r=this.allMatches(Sn.fromUTF16(e),t,s=>s.slice(0,2));return r.length===0?null:r}findAllUTF8Submatch(e,t){const r=this.allMatches(Sn.fromUTF8(e),t,s=>{let a=new Array(s.length/2|0).fill(null);for(let c=0;c<a.length;c++)s[2*c]>=0&&(a[c]=e.slice(s[2*c],s[2*c+1]));return a});return r.length===0?null:r}findAllUTF8SubmatchIndex(e,t){const r=this.allMatches(Sn.fromUTF8(e),t);return r.length===0?null:r}findAllSubmatch(e,t){const r=this.allMatches(Sn.fromUTF16(e),t,s=>{let a=new Array(s.length/2|0).fill(null);for(let c=0;c<a.length;c++)s[2*c]>=0&&(a[c]=e.substring(s[2*c],s[2*c+1]));return a});return r.length===0?null:r}findAllSubmatchIndex(e,t){const r=this.allMatches(Sn.fromUTF16(e),t);return r.length===0?null:r}},wO=class pu{static isHexadecimal(e){return"0"<=e&&e<="9"||"A"<=e&&e<="F"||"a"<=e&&e<="f"}static translate(e){let t="";if(e instanceof RegExp&&(e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e=e.source),typeof e!="string")return e;let r="",s=!1,a=e.length;a===0&&(r="(?:)",s=!0);let c=!1,u=0;for(;u<a;){let f=e[u];if(f==="\\"){if(u+1<a)switch(f=e[u+1],f){case"\\":r+="\\\\",u+=2;continue;case"c":if(u+2<a){let b=e[u+2].charCodeAt(0);if(b>=65&&b<=90||b>=97&&b<=122){let w=b%32;r+="\\x",r+=(w>>4).toString(16).toUpperCase(),r+=(w&15).toString(16).toUpperCase(),u+=3,s=!0;continue}}r+="c",u+=2,s=!0;continue;case"u":if(u+2<a){if(e[u+2]==="{"){let b=u+3,w=!1,E=!1;for(;b<a;){const N=e[b];if(N==="}"){E=!0;break}if(!pu.isHexadecimal(N))break;w=!0,b++}if(E&&w){r+="\\x",u+=2,s=!0;continue}}else if(u+5<a){let b=!0;for(let w=0;w<4;w++)if(!pu.isHexadecimal(e[u+2+w])){b=!1;break}if(b){r+="\\x{"+e.substring(u+2,u+6)+"}",u+=6,s=!0;continue}}}r+="u",u+=2,s=!0;continue;case"x":{let b=!1;if(u+2<a&&e[u+2]==="{"){let w=u+3,E=!1,N=!1;for(;w<a;){const S=e[w];if(S==="}"){N=!0;break}if(!pu.isHexadecimal(S))break;E=!0,w++}N&&E&&(b=!0)}else u+3<a&&pu.isHexadecimal(e[u+2])&&pu.isHexadecimal(e[u+3])&&(b=!0);b?(r+="\\x",u+=2):(r+="x",u+=2,s=!0);continue}case"n":case"r":case"t":case"a":case"f":case"v":case"d":case"D":case"s":case"S":case"w":case"W":case"b":case"B":case"p":case"P":case"A":case"z":case"Q":case"E":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":r+="\\"+f,u+=2;continue;default:{let b=e.codePointAt(u+1);if(b>=48&&b<=57||b>=65&&b<=90||b>=97&&b<=122){let w=Ze.charCount(b);r+=e.substring(u+1,u+1+w),u+=w+1,s=!0}else{r+="\\";let w=Ze.charCount(b);r+=e.substring(u+1,u+1+w),u+=w+1}continue}}}else if(f==="/"){r+="\\/",u+=1,s=!0;continue}else if(f==="[")c=!0;else if(f==="]")c=!1;else if(!c&&f==="("&&u+2<a&&e[u+1]==="?"&&e[u+2]==="<"&&u+3<a&&!"=!>)".includes(e[u+3])){r+="(?P<",u+=3,s=!0;continue}let p=e.codePointAt(u),y=Ze.charCount(p);r+=e.substring(u,u+y),u+=y}const h=s?r:e;return t.length>0?`(?${t})${h}`:h}},gr,wx=(gr=class{static quote(e){return Ze.quoteMeta(e)}
2001static quoteReplacement(e,t=!1){return r_.quoteReplacement(e,t)}static translateRegExp(e){return wO.translate(e)}static compile(e,t=0){let r=e;if((t&gr.CASE_INSENSITIVE)!==0&&(r=`(?i)${r}`),(t&gr.DOTALL)!==0&&(r=`(?s)${r}`),(t&gr.MULTILINE)!==0&&(r=`(?m)${r}`),(t&-544)!==0)throw new nO("Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH, LOOKBEHINDS");let s=ke.PERL;(t&gr.DISABLE_UNICODE_GROUPS)!==0&&(s&=-129),(t&gr.LOOKBEHINDS)!==0&&(s|=ke.LOOKBEHIND);const a=new gr(e,t);return a.re2Input=vO.compileImpl(r,s,(t&gr.LONGEST_MATCH)!==0),a}static matches(e,t){return gr.compile(e).testExact(t)}static initTest(e,t,r){if(e==null)throw new Error("pattern is null");if(r==null)throw new Error("re2 is null");const s=new gr(e,t);return s.re2Input=r,s}constructor(e,t){this.patternInput=e,this.flagsInput=t,this.re2Input=null}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(e){return this.testExact(e)}matcher(e){return Ze.isByteArray(e)&&(e=tc.utf8(e)),new r_(this,e)}test(e){return Ze.isByteArray(e)?this.re2Input.matchUTF8(e):this.re2Input.match(e)}testExact(e){const t=Ze.isByteArray(e)?Sn.fromUTF8(e):Sn.fromUTF16(e);return this.re2Input.executeEngine(t,0,ke.ANCHOR_BOTH,0)!==null}exec(e){const t=this.matcher(e);if(!t.find())return null;const r=[t.group(0)];for(let a=1;a<=t.groupCount();a++){const c=t.group(a);r.push(c===null?void 0:c)}r.index=t.start(0),r.input=e;const s=this.namedGroups();if(Object.keys(s).length>0){const a=t.getNamedGroups();for(const c in a)a[c]===null&&(a[c]=void 0);r.groups=a}else r.groups=void 0;return r}split(e,t=0){const r=this.matcher(e),s=[];let a=0,c=0;for(;r.find();){if(c===0&&r.end()===0){c=r.end();continue}if(t>0&&s.length===t-1)break;if(c===r.start()){if(t===0){a+=1,c=r.end();continue}}else for(;a>0;)s.push(""),a-=1;s.push(r.substring(c,r.start())),c=r.end()}if(t===0&&c!==r.inputLength()){for(;a>0;)s.push(""),a-=1;s.push(r.substring(c,r.inputLength()))}return(t!==0||s.length===0&&!(c===r.inputLength()&&c>0))&&s.push(r.substring(c,r.inputLength())),s}*matchAll(e){const t=this.matcher(e);for(;t.find();){const r=[t.group(0)];for(let a=1;a<=t.groupCount();a++){const c=t.group(a);r.push(c===null?void 0:c)}r.index=t.start(0),r.input=e;const s=this.namedGroups();if(Object.keys(s).length>0){const a=t.getNamedGroups();for(const c in a)a[c]===null&&(a[c]=void 0);r.groups=a}else r.groups=void 0;yield r}}toString(){return this.patternInput}programSize(){return this.re2Input.numberOfInstructions()}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(e){return this===e?!0:e===null||this.constructor!==e.constructor?!1:this.flagsInput===e.flagsInput&&this.patternInput===e.patternInput}},Ie(gr,"CASE_INSENSITIVE",du.CASE_INSENSITIVE),Ie(gr,"DOTALL",du.DOTALL),Ie(gr,"MULTILINE",du.MULTILINE),Ie(gr,"DISABLE_UNICODE_GROUPS",du.DISABLE_UNICODE_GROUPS),Ie(gr,"LONGEST_MATCH",du.LONGEST_MATCH),Ie(gr,"LOOKBEHINDS",du.LOOKBEHINDS),gr);/**
2002 * @license
2003 * Copyright 2017 Google LLC
2004 *
2005 * Licensed under the Apache License, Version 2.0 (the "License");
2006 * you may not use this file except in compliance with the License.
2007 * You may obtain a copy of the License at
2008 *
2009 *   http://www.apache.org/licenses/LICENSE-2.0
2010 *
2011 * Unless required by applicable law or agreed to in writing, software
2012 * distributed under the License is distributed on an "AS IS" BASIS,
2013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2014 * See the License for the specific language governing permissions and
2015 * limitations under the License.
2016 */let Fu="12.18.0";function EO(n){Fu=n}/**
2017 * @license
2018 * Copyright 2020 Google LLC
2019 *
2020 * Licensed under the Apache License, Version 2.0 (the "License");
2021 * you may not use this file except in compliance with the License.
2022 * You may obtain a copy of the License at
2023 *
2024 *   http://www.apache.org/licenses/LICENSE-2.0
2025 *
2026 * Unless required by applicable law or agreed to in writing, software
2027 * distributed under the License is distributed on an "AS IS" BASIS,
2028 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2029 * See the License for the specific language governing permissions and
2030 * limitations under the License.
2031 *//**
2032 * @license
2033 * Copyright 2017 Google LLC
2034 *
2035 * Licensed under the Apache License, Version 2.0 (the "License");
2036 * you may not use this file except in compliance with the License.
2037 * You may obtain a copy of the License at
2038 *
2039 *   http://www.apache.org/licenses/LICENSE-2.0
2040 *
2041 * Unless required by applicable law or agreed to in writing, software
2042 * distributed under the License is distributed on an "AS IS" BASIS,
2043 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2044 * See the License for the specific language governing permissions and
2045 * limitations under the License.
2046 */const el=new cx("@firebase/firestore");function Bu(){return el.logLevel}function _O(n){el.setLogLevel(n)}function Ue(n,...e){if(el.logLevel<=Ut.DEBUG){const t=e.map(Ex);el.debug(`Firestore (${Fu}): ${n}`,...t)}}function za(n,...e){if(el.logLevel<=Ut.ERROR){const t=e.map(Ex);el.error(`Firestore (${Fu}): ${n}`,...t)}}function Ri(n,...e){if(el.logLevel<=Ut.WARN){const t=e.map(Ex);el.warn(`Firestore (${Fu}): ${n}`,...t)}}function Ex(n){if(typeof n=="string")return n;try{return(function(t){return JSON.stringify(t)})(n)}catch{return n}}/**
2047 * @license
2048 * Copyright 2017 Google LLC
2049 *
2050 * Licensed under the Apache License, Version 2.0 (the "License");
2051 * you may not use this file except in compliance with the License.
2052 * You may obtain a copy of the License at
2053 *
2054 *   http://www.apache.org/licenses/LICENSE-2.0
2055 *
2056 * Unless required by applicable law or agreed to in writing, software
2057 * distributed under the License is distributed on an "AS IS" BASIS,
2058 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2059 * See the License for the specific language governing permissions and
2060 * limitations under the License.
2061 */function ot(n,e,t){let r="Unexpected state";typeof e=="string"?r=e:t=e,hD(n,r,t)}function hD(n,e,t){let r=`FIRESTORE (${Fu}) INTERNAL ASSERTION FAILED: ${e} (ID: ${n.toString(16)})`;if(t!==void 0)try{r+=" CONTEXT: "+JSON.stringify(t)}catch{r+=" CONTEXT: "+t}throw za(r),new Error(r)}function Xe(n,e,t,r){let s="Unexpected state";typeof t=="string"?s=t:r=t,n||hD(e,s,r)}function xt(n,e){return n}/**
2062 * @license
2063 * Copyright 2020 Google LLC
2064 *
2065 * Licensed under the Apache License, Version 2.0 (the "License");
2066 * you may not use this file except in compliance with the License.
2067 * You may obtain a copy of the License at
2068 *
2069 *   http://www.apache.org/licenses/LICENSE-2.0
2070 *
2071 * Unless required by applicable law or agreed to in writing, software
2072 * distributed under the License is distributed on an "AS IS" BASIS,
2073 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2074 * See the License for the specific language governing permissions and
2075 * limitations under the License.
2076 */function TO(n){const e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<n;r++)t[r]=Math.floor(256*Math.random());return t}/**
2077 * @license
2078 * Copyright 2017 Google LLC
2079 *
2080 * Licensed under the Apache License, Version 2.0 (the "License");
2081 * you may not use this file except in compliance with the License.
2082 * You may obtain a copy of the License at
2083 *
2084 *   http://www.apache.org/licenses/LICENSE-2.0
2085 *
2086 * Unless required by applicable law or agreed to in writing, software
2087 * distributed under the License is distributed on an "AS IS" BASIS,
2088 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2089 * See the License for the specific language governing permissions and
2090 * limitations under the License.
2091 */class _x{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516);let r="";for(;r.length<20;){const s=TO(40);for(let a=0;a<s.length;++a)r.length<20&&s[a]<t&&(r+=e.charAt(s[a]%62))}return r}}function Lt(n,e){return n<e?-1:n>e?1:0}function Ny(n,e){const t=Math.min(n.length,e.length);for(let r=0;r<t;r++){const s=n.charAt(r),a=e.charAt(r);if(s!==a)return JB(s)===JB(a)?Lt(s,a):JB(s)?1:-1}return Lt(n.length,e.length)}const kO=55296,NO=57343;function JB(n){const e=n.charCodeAt(0);return e>=kO&&e<=NO}function Au(n,e,t){return n.length===e.length&&n.every(((r,s)=>t(r,e[s])))}/**
2092 * @license
2093 * Copyright 2017 Google LLC
2094 *
2095 * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 5,212 bytes, lines 2096-2106
2096 * you may not use this file except in compliance with the License.
2097 * You may obtain a copy of the License at
2098 *
2099 *   http://www.apache.org/licenses/LICENSE-2.0
2100 *
2101 * Unless required by applicable law or agreed to in writing, software
2102 * distributed under the License is distributed on an "AS IS" BASIS,
2103 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2104 * See the License for the specific language governing permissions and
2105 * limitations under the License.
2106 */class Fn{constructor(e,t){this.comparator=e,this.root=t||qr.EMPTY}insert(e,t){return new Fn(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,qr.BLACK,null,null))}remove(e){return new Fn(this.comparator,this.root.remove(e,this.comparator).copy(null,null,qr.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const r=this.comparator(e,t.key);if(r===0)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){const s=this.comparator(e,r.key);if(s===0)return t+r.left.size;s<0?r=r.left:(t+=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(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal(((t,r)=>(e(t,r),!1)))}toString(){const e=[];return this.inorderTraversal(((t,r)=>(e.push(`${t}:${r}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new _m(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new _m(this.root,e,this.comparator,!1)}getReverseIterator(){return new _m(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new _m(this.root,e,this.comparator,!0)}}class _m{constructor(e,t,r,s){this.isReverse=s,this.nodeStack=[];let a=1;for(;!e.isEmpty();)if(a=t?r(e.key,t):1,t&&s&&(a*=-1),a<0)e=this.isReverse?e.left:e.right;else{if(a===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class qr{constructor(e,t,r,s,a){this.key=e,this.value=t,this.color=r??qr.RED,this.left=s??qr.EMPTY,this.right=a??qr.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,s,a){return new qr(e??this.key,t??this.value,r??this.color,s??this.left,a??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}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(e,t,r){let s=this;const a=r(e,s.key);return s=a<0?s.copy(null,null,null,s.left.insert(e,t,r),null):a===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return qr.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let r,s=this;if(t(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),t(e,s.key)===0){if(s.right.isEmpty())return qr.EMPTY;r=s.right.min(),s=s.copy(r.key,r.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,qr.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,qr.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw ot(43730,{key:this.key,value:this.value});if(this.right.isRed())throw ot(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw ot(27949);return e+(this.isRed()?0:1)}}qr.EMPTY=null,qr.RED=!0,qr.BLACK=!1;
vendor: 4,243 bytes, lines 2106-2146
2106qr.EMPTY=new class{constructor(){this.size=0}get key(){throw ot(57766)}get value(){throw ot(16141)}get color(){throw ot(16727)}get left(){throw ot(29726)}get right(){throw ot(36894)}copy(e,t,r,s,a){return this}insert(e,t,r){return new qr(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/**
2107 * @license
2108 * Copyright 2017 Google LLC
2109 *
2110 * Licensed under the Apache License, Version 2.0 (the "License");
2111 * you may not use this file except in compliance with the License.
2112 * You may obtain a copy of the License at
2113 *
2114 *   http://www.apache.org/licenses/LICENSE-2.0
2115 *
2116 * Unless required by applicable law or agreed to in writing, software
2117 * distributed under the License is distributed on an "AS IS" BASIS,
2118 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2119 * See the License for the specific language governing permissions and
2120 * limitations under the License.
2121 */class yr{constructor(e){this.comparator=e,this.data=new Fn(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal(((t,r)=>(e(t),!1)))}forEachInRange(e,t){const r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){const s=r.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let r;for(r=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new N_(this.data.getIterator())}getIteratorFrom(e){return new N_(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach((r=>{t=t.add(r)})),t}isEqual(e){if(!(e instanceof yr)||this.size!==e.size)return!1;const t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){const s=t.getNext().key,a=r.getNext().key;if(this.comparator(s,a)!==0)return!1}return!0}toArray(){const e=[];return this.forEach((t=>{e.push(t)})),e}toString(){const e=[];return this.forEach((t=>e.push(t))),"SortedSet("+e.toString()+")"}copy(e){const t=new yr(this.comparator);return t.data=e,t}}class N_{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/**
2122 * @license
2123 * Copyright 2017 Google LLC
2124 *
2125 * Licensed under the Apache License, Version 2.0 (the "License");
2126 * you may not use this file except in compliance with the License.
2127 * You may obtain a copy of the License at
2128 *
2129 *   http://www.apache.org/licenses/LICENSE-2.0
2130 *
2131 * Unless required by applicable law or agreed to in writing, software
2132 * distributed under the License is distributed on an "AS IS" BASIS,
2133 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2134 * See the License for the specific language governing permissions and
2135 * limitations under the License.
2136 */const ve={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 Fe extends aa{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
2137 * @license
2138 * Copyright 2017 Google LLC
2139 *
2140 * Licensed under the Apache License, Version 2.0 (the "License");
2141 * you may not use this file except in compliance with the License.
2142 * You may obtain a copy of the License at
2143 *
2144 *   http://www.apache.org/licenses/LICENSE-2.0
2145 *
2146 * Unless required by applicable law or agreed to in writing, softw
2146are
2147 * distributed under the License is distributed on an "AS IS" BASIS,
2148 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2149 * See the License for the specific language governing permissions and
2150 * limitations under the License.
2151 */const Yi="__name__";class Ki{constructor(e,t,r){t===void 0?t=0:t>e.length&&ot(637,{offset:t,range:e.length}),r===void 0?r=e.length-t:r>e.length-t&&ot(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return Ki.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Ki?e.forEach((r=>{t.push(r)})):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}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(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const a=Ki.compareSegments(e.get(s),t.get(s));if(a!==0)return a}return Lt(e.length,t.length)}static compareSegments(e,t){const r=Ki.isNumericId(e),s=Ki.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?Ki.extractNumericId(e).compare(Ki.extractNumericId(t)):Ny(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Ko.fromString(e.substring(4,e.length-2))}}class sn extends Ki{construct(e,t,r){return new sn(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toStringWithLeadingSlash(){return`/${this.canonicalString()}`}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const r of e){if(r.indexOf("//")>=0)throw new Fe(ve.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter((s=>s.length>0)))}return new sn(t)}static emptyPath(){return new sn([])}}const SO=/^[_a-zA-Z][_a-zA-Z0-9]*$/;let Ks=class yu extends Ki{construct(e,t,r){return new yu(e,t,r)}static isValidIdentifier(e){return SO.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),yu.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===Yi}static keyField(){return new yu([Yi])}static fromServerFormat(e){const t=[];let r="",s=0;const a=()=>{if(r.length===0)throw new Fe(ve.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""};let c=!1;for(;s<e.length;){const u=e[s];if(u==="\\"){if(s+1===e.length)throw new Fe(ve.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const h=e[s+1];if(h!=="\\"&&h!=="."&&h!=="`")throw new Fe(ve.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=h,s+=2}else u==="`"?(c=!c,s++):u!=="."||c?(r+=u,s++):(a(),s++)}if(a(),c)throw new Fe(ve.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new yu(t)}static emptyPath(){return new yu([])}};/**
2152 * @license
2153 * Copyright 2020 Google LLC
2154 *
2155 * Licensed under the Apache License, Version 2.0 (the "License");
2156 * you may not use this file except in compliance with the License.
2157 * You may obtain a copy of the License at
2158 *
2159 *   http://www.apache.org/licenses/LICENSE-2.0
2160 *
2161 * Unless required by applicable law or agreed to in writing, software
2162 * distributed under the License is distributed on an "AS IS" BASIS,
2163 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2164 * See the License for the specific language governing permissions and
2165 * limitations under the License.
2166 */class zs{constructor(e){this.fields=e,e.sort(Ks.comparator)}static empty(){return new zs([])}unionWith(e){let t=new yr(Ks.comparator);for(const r of this.fields)t=t.add(r);for(const r of e)t=t.add(r);return new zs(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Au(this.fields,e.fields,((t,r)=>t.isEqual(r)))}}/**
2167 * @license
2168 * Copyright 2017 Google LLC
2169 *
2170 * Licensed under the Apache License, Version 2.0 (the "License");
2171 * you may not use this file except in compliance with the License.
2172 * You may obtain a copy of the License at
2173 *
2174 *   http://www.apache.org/licenses/LICENSE-2.0
2175 *
2176 * Unless required by applicable law or agreed to in writing, software
2177 * distributed under the License is distributed on an "AS IS" BASIS,
2178 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2179 * See the License for the specific language governing permissions and
2180 * limitations under the License.
2181 */function mg(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function hl(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function DO(n,e){const t=[];for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.push(e(n[r],r,n));return t}function fD(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}/**
2182 * @license
2183 * Copyright 2017 Google LLC
2184 *
2185 * Licensed under the Apache License, Version 2.0 (the "License");
2186 * you may not use this file except in compliance with the License.
2187 * You may obtain a copy of the License at
2188 *
2189 *   http://www.apache.org/licenses/LICENSE-2.0
2190 *
2191 * Unless required by applicable law or agreed to in writing, software
2192 * distributed under the License is distributed on an "AS IS" BASIS,
2193 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2194 * See the License for the specific language governing permissions and
2195 * limitations under the License.
2196 */class nt{constructor(e){this.path=e}static fromPath(e){return new nt(sn.fromString(e))}static fromName(e){return new nt(sn.fromString(e).popFirst(5))}static empty(){return new nt(sn.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&sn.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return sn.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new nt(new sn(e.slice()))}}/**
2197 * @license
2198 * Copyright 2017 Google LLC
2199 *
2200 * Licensed under the Apache License, Version 2.0 (the "License");
2201 * you may not use this file except in compliance with the License.
2202 * You may obtain a copy of the License at
2203 *
2204 *   http://www.apache.org/licenses/LICENSE-2.0
2205 *
2206 * Unless required by applicable law or agreed to in writing, software
2207 * distributed under the License is distributed on an "AS IS" BASIS,
2208 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2209 * See the License for the specific language governing permissions and
2210 * limitations under the License.
2211 */function mD(n,e,t){if(!t)throw new Fe(ve.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function AO(n,e,t,r){if(e===!0&&r===!0)throw new Fe(ve.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function S_(n){if(!nt.isDocumentKey(n))throw new Fe(ve.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function D_(n){if(nt.isDocumentKey(n))throw new Fe(ve.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${n} has ${n.length}.`)}function zh(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Object.getPrototypeOf(n)===null)}function tp(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=(function(r){return r.constructor?r.constructor.name:null})(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":ot(12329,{type:typeof n})}function mi(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new Fe(ve.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=tp(n);throw new Fe(ve.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}/**
2212 * @license
2213 * Copyright 2025 Google LLC
2214 *
2215 * Licensed under the Apache License, Version 2.0 (the "License");
2216 * you may not use this file except in compliance with the License.
2217 * You may obtain a copy of the License at
2218 *
2219 *   http://www.apache.org/licenses/LICENSE-2.0
2220 *
2221 * Unless required by applicable law or agreed to in writing, software
2222 * distributed under the License is distributed on an "AS IS" BASIS,
2223 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2224 * See the License for the specific language governing permissions and
2225 * limitations under the License.
2226 */function Br(n,e){const t={typeString:n};return e&&(t.value=e),t}function Jh(n,e){if(!zh(n))throw new Fe(ve.INVALID_ARGUMENT,"JSON must be an object");let t;for(const r in e)if(e[r]){const s=e[r].typeString,a="value"in e[r]?{value:e[r].value}:void 0;if(!(r in n)){t=`JSON missing required field: '${r}'`;break}const c=n[r];if(s&&typeof c!==s){t=`JSON field '${r}' must be a ${s}.`;break}if(a!==void 0&&c!==a.value){t=`Expected '${r}' field to equal '${a.value}'`;break}}if(t)throw new Fe(ve.INVALID_ARGUMENT,t);return!0}/**
2227 * @license
2228 * Copyright 2017 Google LLC
2229 *
2230 * Licensed under the Apache License, Version 2.0 (the "License");
2231 * you may not use this file except in compliance with the License.
2232 * You may obtain a copy of the License at
2233 *
2234 *   http://www.apache.org/licenses/LICENSE-2.0
2235 *
2236 * Unless required by applicable law or agreed to in writing, software
2237 * distributed under the License is distributed on an "AS IS" BASIS,
2238 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2239 * See the License for the specific language governing permissions and
2240 * limitations under the License.
2241 */const A_=-62135596800,I_=1e6;class An{static now(){return An.fromMillis(Date.now())}static fromDate(e){return An.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*I_);return new An(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new Fe(ve.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new Fe(ve.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<A_)throw new Fe(ve.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new Fe(ve.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/I_}_compareTo(e){return this.seconds===e.seconds?Lt(this.nanoseconds,e.nanoseconds):Lt(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:An._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(Jh(e,An._jsonSchema))return new An(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-A_;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}An._jsonSchemaVersion="firestore/timestamp/1.0",An._jsonSchema={type:Br("string",An._jsonSchemaVersion),seconds:Br("number"),nanoseconds:Br("number")};/**
2242 * @license
2243 * Copyright 2023 Google LLC
2244 *
2245 * Licensed under the Apache License, Version 2.0 (the "License");
2246 * you may not use this file except in compliance with the License.
2247 * You may obtain a copy of the License at
2248 *
2249 *   http://www.apache.org/licenses/LICENSE-2.0
2250 *
2251 * Unless required by applicable law or agreed to in writing, software
2252 * distributed under the License is distributed on an "AS IS" BASIS,
2253 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2254 * See the License for the specific language governing permissions and
2255 * limitations under the License.
2256 */class gD extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
2257 * @license
2258 * Copyright 2020 Google LLC
2259 *
2260 * Licensed under the Apache License, Version 2.0 (the "License");
2261 * you may not use this file except in compliance with the License.
2262 * You may obtain a copy of the License at
2263 *
2264 *   http://www.apache.org/licenses/LICENSE-2.0
2265 *
2266 * Unless required by applicable law or agreed to in writing, software
2267 * distributed under the License is distributed on an "AS IS" BASIS,
2268 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2269 * See the License for the specific language governing permissions and
2270 * limitations under the License.
2271 */class xr{constructor(e){this.binaryString=e}static fromBase64String(e){const t=(function(s){try{return atob(s)}catch(a){throw typeof DOMException<"u"&&a instanceof DOMException?new gD("Invalid base64 string: "+a):a}})(e);return new xr(t)}static fromUint8Array(e){const t=(function(s){let a="";for(let c=0;c<s.length;++c)a+=String.fromCharCode(s[c]);return a})(e);return new xr(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return(function(t){return btoa(t)})(this.binaryString)}
2271toUint8Array(){return(function(t){const r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r})(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return Lt(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}xr.EMPTY_BYTE_STRING=new xr("");const IO=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function tl(n){if(Xe(!!n,39018),typeof n=="string"){let e=0;const t=IO.exec(n);if(Xe(!!t,46558,{timestamp:n}),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}const r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:Jn(n.seconds),nanos:Jn(n.nanos)}}function Jn(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function nl(n){return typeof n=="string"?xr.fromBase64String(n):xr.fromUint8Array(n)}/**
2272 * @license
2273 * Copyright 2020 Google LLC
2274 *
2275 * Licensed under the Apache License, Version 2.0 (the "License");
2276 * you may not use this file except in compliance with the License.
2277 * You may obtain a copy of the License at
2278 *
2279 *   http://www.apache.org/licenses/LICENSE-2.0
2280 *
2281 * Unless required by applicable law or agreed to in writing, software
2282 * distributed under the License is distributed on an "AS IS" BASIS,
2283 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2284 * See the License for the specific language governing permissions and
2285 * limitations under the License.
2286 */const pD="server_timestamp",BD="__type__",yD="__previous_value__",xD="__local_write_time__";function np(n){var t,r;return((r=(((t=n==null?void 0:n.mapValue)==null?void 0:t.fields)||{})[BD])==null?void 0:r.stringValue)===pD}function $h(n){const e=n.mapValue.fields[yD];return np(e)?$h(e):e}function Iu(n){const e=tl(n.mapValue.fields[xD].timestampValue);return new An(e.seconds,e.nanos)}/**
2287 * @license
2288 * Copyright 2017 Google LLC
2289 *
2290 * Licensed under the Apache License, Version 2.0 (the "License");
2291 * you may not use this file except in compliance with the License.
2292 * You may obtain a copy of the License at
2293 *
2294 *   http://www.apache.org/licenses/LICENSE-2.0
2295 *
2296 * Unless required by applicable law or agreed to in writing, software
2297 * distributed under the License is distributed on an "AS IS" BASIS,
2298 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2299 * See the License for the specific language governing permissions and
2300 * limitations under the License.
2301 */class RO{constructor(e,t,r,s,a,c,u,h,f,p,y,b,w){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=s,this.ssl=a,this.forceLongPolling=c,this.autoDetectLongPolling=u,this.longPollingOptions=h,this.useFetchStreams=f,this.isUsingEmulator=p,this.apiKey=y,this._customHeaders=b,this.grpcFlowControlWindow=w}}const gg="(default)";class wh{constructor(e,t){this.projectId=e,this.database=t||gg}static empty(){return new wh("","")}get isDefaultDatabase(){return this.database===gg}isEqual(e){return e instanceof wh&&e.projectId===this.projectId&&e.database===this.database}}function PO(n,e){if(!Object.prototype.hasOwnProperty.apply(n.options,["projectId"]))throw new Fe(ve.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new wh(n.options.projectId,e)}/**
2302 * @license
2303 * Copyright 2017 Google LLC
2304 *
2305 * Licensed under the Apache License, Version 2.0 (the "License");
2306 * you may not use this file except in compliance with the License.
2307 * You may obtain a copy of the License at
2308 *
2309 *   http://www.apache.org/licenses/LICENSE-2.0
2310 *
2311 * Unless required by applicable law or agreed to in writing, software
2312 * distributed under the License is distributed on an "AS IS" BASIS,
2313 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2314 * See the License for the specific language governing permissions and
2315 * limitations under the License.
2316 */const Tx=-1;function rp(n){return n==null}function Eh(n){return n===0&&1/n==-1/0}function MO(n){return typeof n=="number"&&Number.isInteger(n)&&!Eh(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}function LO(n){return typeof n=="string"}/**
2317 * @license
2318 * Copyright 2020 Google LLC
2319 *
2320 * Licensed under the Apache License, Version 2.0 (the "License");
2321 * you may not use this file except in compliance with the License.
2322 * You may obtain a copy of the License at
2323 *
2324 *   http://www.apache.org/licenses/LICENSE-2.0
2325 *
2326 * Unless required by applicable law or agreed to in writing, software
2327 * distributed under the License is distributed on an "AS IS" BASIS,
2328 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2329 * See the License for the specific language governing permissions and
2330 * limitations under the License.
2331 */const CD="__type__",jO="__max__",Tm={mapValue:{}},bD="__vector__",_h="value",Ru={nullValue:"NULL_VALUE"},Ds={booleanValue:!0},Rr={booleanValue:!1};function Cr(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?np(n)?4:OO(n)?9007199254740991:pg(n)?10:11:ot(28295,{value:n})}function pi(n,e,t){if(n===e)return!0;const r=Cr(n);if(r!==Cr(e))return!1;switch(r){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return Iu(n).isEqual(Iu(e));case 3:return(function(a,c){if(typeof a.timestampValue=="string"&&typeof c.timestampValue=="string"&&a.timestampValue.length===c.timestampValue.length)return a.timestampValue===c.timestampValue;const u=tl(a.timestampValue),h=tl(c.timestampValue);return u.seconds===h.seconds&&u.nanos===h.nanos})(n,e);case 5:return n.stringValue===e.stringValue;case 6:return(function(a,c){return nl(a.bytesValue).isEqual(nl(c.bytesValue))})(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return(function(a,c){return Jn(a.geoPointValue.latitude)===Jn(c.geoPointValue.latitude)&&Jn(a.geoPointValue.longitude)===Jn(c.geoPointValue.longitude)})(n,e);case 2:return(function(a,c,u){if("integerValue"in a&&"integerValue"in c)return Jn(a.integerValue)===Jn(c.integerValue);let h,f;if("doubleValue"in a&&"doubleValue"in c)h=Jn(a.doubleValue),f=Jn(c.doubleValue);else{if(!(u!=null&&u.t))return!1;h=Jn(a.integerValue??a.doubleValue),f=Jn(c.integerValue??c.doubleValue)}return h===f?!!(u!=null&&u.i)||Eh(h)===Eh(f):!!(u===void 0||u.o)&&isNaN(h)&&isNaN(f)})(n,e,t);case 9:return Au(n.arrayValue.values||[],e.arrayValue.values||[],((s,a)=>pi(s,a,t)));case 10:case 11:return(function(a,c,u){const h=a.mapValue.fields||{},f=c.mapValue.fields||{};if(mg(h)!==mg(f))return!1;for(const p in h)if(h.hasOwnProperty(p)&&(f[p]===void 0||!pi(h[p],f[p],u)))return!1;return!0})(n,e,t);default:return ot(52216,{left:n})}}function Th(n,e){return(n.values||[]).find((t=>pi(t,e)))!==void 0}function As(n,e){if(n===e)return 0;const t=Cr(n),r=Cr(e);if(t!==r)return Lt(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return Lt(n.booleanValue,e.booleanValue);case 2:return(function(a,c){const u=Jn(a.integerValue||a.doubleValue),h=Jn(c.integerValue||c.doubleValue);return u<h?-1:u>h?1:u===h?0:isNaN(u)?isNaN(h)?0:-1:1})(n,e);case 3:return R_(n.timestampValue,e.timestampValue);case 4:return R_(Iu(n),Iu(e));case 5:return Ny(n.stringValue,e.stringValue);case 6:return(function(a,c){const u=nl(a),h=nl(c);return u.compareTo(h)})(n.bytesValue,e.bytesValue);case 7:return(function(a,c){const u=a.split("/"),h=c.split("/");for(let f=0;f<u.length&&f<h.length;f++){const p=Lt(u[f],h[f]);if(p!==0)return p}return Lt(u.length,h.length)})(n.referenceValue,e.referenceValue);case 8:return(function(a,c){const u=Lt(Jn(a.latitude),Jn(c.latitude));return u!==0?u:Lt(Jn(a.longitude),Jn(c.longitude))})(n.geoPointValue,e.geoPointValue);case 9:return P_(n.arrayValue,e.arrayValue);case 10:return(function(a,c){var b,w,E,N;const u=a.fields||{},h=c.fields||{},f=(b=u[_h])==null?void 0:b.arrayValue,p=(w=h[_h])==null?void 0:w.arrayValue,y=Lt(((E=f==null?void 0:f.values)==null?void 0:E.length)||0,((N=p==null?void 0:p.values)==null?void 0:N.length)||0);return y!==0?y:P_(f,p)})(n.mapValue,e.mapValue);case 11:return(function(a,c){if(a===Tm.mapValue&&c===Tm.mapValue)return 0;if(a===Tm.mapValue)return 1;if(c===Tm.mapValue)return-1;const u=a.fields||{},h=Object.keys(u),f=c.fields||{},p=Object.keys(f);h.sort(),p.sort();for(let y=0;y<h.length&&y<p.length;++y){const b=Ny(h[y],p[y]);if(b!==0)return b;const w=As(u[h[y]],f[p[y]]);if(w!==0)return w}return Lt(h.length,p.length)})(n.mapValue,e.mapValue);default:throw ot(23264,{u:t})}}function R_(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return Lt(n,e);const t=tl(n),r=tl(e),s=Lt(t.seconds,r.seconds);return s!==0?s:Lt(t.nanos,r.nanos)}function P_(n,e){const t=n.values||[],r=e.values||[];for(let s=0;s<t.length&&s<r.length;++s){const a=As(t[s],r[s]);if(a!==void 0&&a!==0)return a}return Lt(t.length,r.length)}function Pu(n){return Sy(n)}function Sy(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?(function(t){const r=tl(t);return`time(${r.seconds},${r.nanos})`})(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?(function(t){return nl(t).toBase64()})(n.bytesValue):"referenceValue"in n?(function(t){return nt.fromName(t).toString()})(n.referenceValue):"geoPointValue"in n?(function(t){return`geo(${t.latitude},${t.longitude})`})(n.geoPointValue):"arrayValue"in n?(function(t){let r="[",s=!0;for(const a of t.values||[])s?s=!1:r+=",",r+=Sy(a);return r+"]"})(n.arrayValue):"mapValue"in n?(function(t){const r=Object.keys(t.fields||{}).sort();let s="{",a=!0;for(const c of r)a?a=!1:s+=",",s+=`${c}:${Sy(t.fields[c])}`;return s+"}"})(n.mapValue):ot(61005,{value:n})}function Km(n){switch(Cr(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=$h(n);return e?16+Km(e):16;case 5:return 2*n.stringValue.length;case 6:return nl(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return(function(r){return(r.values||[]).reduce(((s,a)=>s+Km(a)),0)})(n.arrayValue);case 10:case 11:return(function(r){let s=0;return hl(r.fields,((a,c)=>{s+=a.length+Km(c)})),s})(n.mapValue);default:throw ot(13486,{value:n})}}function M_(n,e){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${e.path.canonicalString()}`}}function Qi(n){return!!n&&"integerValue"in n}function nc(n){return!!n&&"doubleValue"in n}function rl(n){return Qi(n)||nc(n)}function Mu(n){return!!n&&"arrayValue"in n}function Js(n){return!!n&&"nullValue"in n}function Is(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function sc(n){return!!n&&"mapValue"in n}function pg(n){var t,r;return((r=(((t=n==null?void 0:n.mapValue)==null?void 0:t.fields)||{})[CD])==null?void 0:r.stringValue)===bD}function Dy(n){var e,t;return(t=(((e=n==null?void 0:n.mapValue)==null?void 0:e.fields)||{})[_h])==null?void 0:t.arrayValue}function ah(n){if(n.geoPointValue)return{geoPointValue:{...n.geoPointValue}};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:{...n.timestampValue}};if(n.mapValue){const e={mapValue:{fields:{}}};return hl(n.mapValue.fields,((t,r)=>e.mapValue.fields[t]=ah(r))),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=ah(n.arrayValue.values[t]);return e}return{...n}}function OO(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===jO}/**
2332 * @license
2333 * Copyright 2017 Google LLC
2334 *
2335 * Licensed under the Apache License, Version 2.0 (the "License");
2336 * you may not use this file except in compliance with the License.
2337 * You may obtain a copy of the License at
2338 *
2339 *   http://www.apache.org/licenses/LICENSE-2.0
2340 *
2341 * Unless required by applicable law or agreed to in writing, software
2342 * distributed under the License is distributed on an "AS IS" BASIS,
2343 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2344 * See the License for the specific language governing permissions and
2345 * limitations under the License.
2346 */class fs{constructor(e){this.value=e}static empty(){return new fs({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(t=(t.mapValue.fields||{})[e.get(r)],!sc(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=ah(t)}setAll(e){let t=Ks.emptyPath(),r={},s=[];e.forEach(((c,u)=>{if(!t.isImmediateParentOf(u)){const h=this.getFieldsMap(t);this.applyChanges(h,r,s),r={},s=[],t=u.popLast()}c?r[u.lastSegment()]=ah(c):s.push(u.lastSegment())}));const a=this.getFieldsMap(t);this.applyChanges(a,r,s)}delete(e){const t=this.field(e.popLast());sc(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return pi(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let s=t.mapValue.fields[e.get(r)];sc(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,r){hl(t,((s,a)=>e[s]=a));for(const s of r)delete e[s]}clone(){return new fs(ah(this.value))}}function vD(n){const e=[];return hl(n.fields,((t,r)=>{const s=new Ks([t]);if(sc(r)){const a=vD(r.mapValue).fields;
2346if(a.length===0)e.push(s);else for(const c of a)e.push(s.child(c))}else e.push(s)})),new zs(e)}/**
2347 * @license
2348 * Copyright 2020 Google LLC
2349 *
2350 * Licensed under the Apache License, Version 2.0 (the "License");
2351 * you may not use this file except in compliance with the License.
2352 * You may obtain a copy of the License at
2353 *
2354 *   http://www.apache.org/licenses/LICENSE-2.0
2355 *
2356 * Unless required by applicable law or agreed to in writing, software
2357 * distributed under the License is distributed on an "AS IS" BASIS,
2358 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2359 * See the License for the specific language governing permissions and
2360 * limitations under the License.
2361 */function sp(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Eh(e)?"-0":e}}function kx(n){return{integerValue:""+n}}function Nx(n,e,t){return MO(e)?kx(e):sp(n,e)}/**
2362 * @license
2363 * Copyright 2018 Google LLC
2364 *
2365 * Licensed under the Apache License, Version 2.0 (the "License");
2366 * you may not use this file except in compliance with the License.
2367 * You may obtain a copy of the License at
2368 *
2369 *   http://www.apache.org/licenses/LICENSE-2.0
2370 *
2371 * Unless required by applicable law or agreed to in writing, software
2372 * distributed under the License is distributed on an "AS IS" BASIS,
2373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2374 * See the License for the specific language governing permissions and
2375 * limitations under the License.
2376 */class ip{constructor(){this._=void 0}}function FO(n,e,t){return n instanceof Bg?(function(s,a){const c={fields:{[BD]:{stringValue:pD},[xD]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return a&&np(a)&&(a=$h(a)),a&&(c.fields[yD]=a),{mapValue:c}})(t,e):n instanceof kh?ED(n,e):n instanceof Nh?_D(n,e):n instanceof Sh?(function(s,a){const c=wD(s,a),u=Cg(c)+Cg(s.l);return Qi(c)&&Qi(s.l)?kx(u):sp(s.serializer,u)})(n,e):n instanceof yg?(function(s,a){return L_(s,a,Math.min)})(n,e):n instanceof xg?(function(s,a){return L_(s,a,Math.max)})(n,e):void 0}function UO(n,e,t){return n instanceof kh?ED(n,e):n instanceof Nh?_D(n,e):t}function wD(n,e){return n instanceof Sh?rl(e)?e:{integerValue:0}:null}class Bg extends ip{}class kh extends ip{constructor(e){super(),this.elements=e}}function ED(n,e){const t=TD(e);for(const r of n.elements)t.some((s=>pi(s,r)))||t.push(r);return{arrayValue:{values:t}}}class Nh extends ip{constructor(e){super(),this.elements=e}}function _D(n,e){let t=TD(e);for(const r of n.elements)t=t.filter((s=>!pi(s,r)));return{arrayValue:{values:t}}}class Sx extends ip{constructor(e,t){super(),this.serializer=e,this.l=t}}class Sh extends Sx{}class yg extends Sx{}class xg extends Sx{}function L_(n,e,t){if(!rl(e))return n.l;const r=t(Cg(e),Cg(n.l));return Qi(e)&&Qi(n.l)?kx(r):sp(n.serializer,r)}function Cg(n){return Jn(n.integerValue||n.doubleValue)}function TD(n){return Mu(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function VO(n,e){return n.field.isEqual(e.field)&&(function(r,s){return r instanceof kh&&s instanceof kh||r instanceof Nh&&s instanceof Nh?Au(r.elements,s.elements,pi):r instanceof Sh&&s instanceof Sh||r instanceof yg&&s instanceof yg||r instanceof xg&&s instanceof xg?pi(r.l,s.l):r instanceof Bg&&s instanceof Bg})(n.transform,e.transform)}class GO{constructor(e,t){this.version=e,this.transformResults=t}}class Ys{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Ys}static exists(e){return new Ys(void 0,e)}static updateTime(e){return new Ys(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function Ym(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class ap{}function kD(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new op(n.key,Ys.none()):new Kh(n.key,n.data,Ys.none());{const t=n.data,r=fs.empty();let s=new yr(Ks.comparator);for(let a of e.fields)if(!s.has(a)){let c=t.field(a);c===null&&a.length>1&&(a=a.popLast(),c=t.field(a)),c===null?r.delete(a):r.set(a,c),s=s.add(a)}return new fl(n.key,r,new zs(s.toArray()),Ys.none())}}function HO(n,e,t){n instanceof Kh?(function(s,a,c){const u=s.value.clone(),h=O_(s.fieldTransforms,a,c.transformResults);u.setAll(h),a.convertToFoundDocument(c.version,u).setHasCommittedMutations()})(n,e,t):n instanceof fl?(function(s,a,c){if(!Ym(s.precondition,a))return void a.convertToUnknownDocument(c.version);const u=O_(s.fieldTransforms,a,c.transformResults),h=a.data;h.setAll(ND(s)),h.setAll(u),a.convertToFoundDocument(c.version,h).setHasCommittedMutations()})(n,e,t):(function(s,a,c){a.convertToNoDocument(c.version).setHasCommittedMutations()})(0,e,t)}function oh(n,e,t,r){return n instanceof Kh?(function(a,c,u,h){if(!Ym(a.precondition,c))return u;const f=a.value.clone(),p=F_(a.fieldTransforms,h,c);return f.setAll(p),c.convertToFoundDocument(c.version,f).setHasLocalMutations(),null})(n,e,t,r):n instanceof fl?(function(a,c,u,h){if(!Ym(a.precondition,c))return u;const f=F_(a.fieldTransforms,h,c),p=c.data;return p.setAll(ND(a)),p.setAll(f),c.convertToFoundDocument(c.version,p).setHasLocalMutations(),u===null?null:u.unionWith(a.fieldMask.fields).unionWith(a.fieldTransforms.map((y=>y.field)))})(n,e,t,r):(function(a,c,u){return Ym(a.precondition,c)?(c.convertToNoDocument(c.version).setHasLocalMutations(),null):u})(n,e,t)}function qO(n,e){let t=null;for(const r of n.fieldTransforms){const s=e.data.field(r.field),a=wD(r.transform,s||null);a!=null&&(t===null&&(t=fs.empty()),t.set(r.field,a))}return t||null}function j_(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.prec
2376ondition.isEqual(e.precondition)&&!!(function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&Au(r,s,((a,c)=>VO(a,c)))})(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class Kh extends ap{constructor(e,t,r,s=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class fl extends ap{constructor(e,t,r,s,a=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=s,this.fieldTransforms=a,this.type=1}getFieldMask(){return this.fieldMask}}function ND(n){const e=new Map;return n.fieldMask.fields.forEach((t=>{if(!t.isEmpty()){const r=n.data.field(t);e.set(t,r)}})),e}function O_(n,e,t){const r=new Map;Xe(n.length===t.length,32656,{h:t.length,T:n.length});for(let s=0;s<t.length;s++){const a=n[s],c=a.transform,u=e.data.field(a.field);r.set(a.field,UO(c,u,t[s]))}return r}function F_(n,e,t){const r=new Map;for(const s of n){const a=s.transform,c=t.data.field(s.field);r.set(s.field,FO(a,c,e))}return r}class op extends ap{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class zO extends ap{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
2377 * @license
2378 * Copyright 2022 Google LLC
2379 *
2380 * Licensed under the Apache License, Version 2.0 (the "License");
2381 * you may not use this file except in compliance with the License.
2382 * You may obtain a copy of the License at
2383 *
2384 *   http://www.apache.org/licenses/LICENSE-2.0
2385 *
2386 * Unless required by applicable law or agreed to in writing, software
2387 * distributed under the License is distributed on an "AS IS" BASIS,
2388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2389 * See the License for the specific language governing permissions and
2390 * limitations under the License.
2391 */class bg{constructor(e,t){this.position=e,this.inclusive=t}}function U_(n,e,t){let r=0;for(let s=0;s<n.position.length;s++){const a=e[s],c=n.position[s];if(a.field.isKeyField()?r=nt.comparator(nt.fromName(c.referenceValue),t.key):r=As(c,t.data.field(a.field)),a.dir==="desc"&&(r*=-1),r!==0)break}return r}function V_(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!pi(n.position[t],e.position[t]))return!1;return!0}/**
2392 * @license
2393 * Copyright 2022 Google LLC
2394 *
2395 * Licensed under the Apache License, Version 2.0 (the "License");
2396 * you may not use this file except in compliance with the License.
2397 * You may obtain a copy of the License at
2398 *
2399 *   http://www.apache.org/licenses/LICENSE-2.0
2400 *
2401 * Unless required by applicable law or agreed to in writing, software
2402 * distributed under the License is distributed on an "AS IS" BASIS,
2403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2404 * See the License for the specific language governing permissions and
2405 * limitations under the License.
2406 */class SD{}class pr extends SD{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new $O(e,t,r):t==="array-contains"?new QO(e,r):t==="in"?new WO(e,r):t==="not-in"?new XO(e,r):t==="array-contains-any"?new ZO(e,r):new pr(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new KO(e,r):new YO(e,r)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&t.nullValue===void 0&&this.matchesComparison(As(t,this.value)):t!==null&&Cr(this.value)===Cr(t)&&this.matchesComparison(As(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return ot(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class Pi extends SD{constructor(e,t){super(),this.filters=e,this.op=t,this.P=null}static create(e,t){return new Pi(e,t)}matches(e){return DD(this)?this.filters.find((t=>!t.matches(e)))===void 0:this.filters.find((t=>t.matches(e)))!==void 0}getFlattenedFilters(){return this.P!==null||(this.P=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.P}getFilters(){return Object.assign([],this.filters)}}function DD(n){return n.op==="and"}function AD(n){return JO(n)&&DD(n)}function JO(n){for(const e of n.filters)if(e instanceof Pi)return!1;return!0}function Ay(n){if(n instanceof pr)return n.field.canonicalString()+n.op.toString()+Pu(n.value);if(AD(n))return n.filters.map((e=>Ay(e))).join(",");{const e=n.filters.map((t=>Ay(t))).join(",");return`${n.op}(${e})`}}function ID(n,e){return n instanceof pr?(function(r,s){return s instanceof pr&&r.op===s.op&&r.field.isEqual(s.field)&&pi(r.value,s.value)})(n,e):n instanceof Pi?(function(r,s){return s instanceof Pi&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce(((a,c,u)=>a&&ID(c,s.filters[u])),!0):!1})(n,e):void ot(19439)}function RD(n){return n instanceof pr?(function(t){return`${t.field.canonicalString()} ${t.op} ${Pu(t.value)}`})(n):n instanceof Pi?(function(t){return t.op.toString()+" {"+t.getFilters().map(RD).join(" ,")+"}"})(n):"Filter"}class $O extends pr{constructor(e,t,r){super(e,t,r),this.key=nt.fromName(r.referenceValue)}matches(e){const t=nt.comparator(e.key,this.key);return this.matchesComparison(t)}}class KO extends pr{constructor(e,t){super(e,"in",t),this.keys=PD("in",t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}}class YO extends pr{constructor(e,t){super(e,"not-in",t),this.keys=PD("not-in",t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}}function PD(n,e){var t;return(((t=e.arrayValue)==null?void 0:t.values)||[]).map((r=>nt.fromName(r.referenceValue)))}class QO extends pr{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Mu(t)&&Th(t.arrayValue,this.value)}}class WO extends pr{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&Th(this.value.arrayValue,t)}}class XO extends pr{constructor(e,t){super(e,"not-in",t)}matches(e){if(Th(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!Th(this.value.arrayValue,t)}}class ZO extends pr{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Mu(t)||!t.arrayValue.values)&&t.arrayValue.values.some((r=>Th(this.value.arrayValue,r)))}}/**
2407 * @license
2408 * Copyright 2022 Google LLC
2409 *
2410 * Licensed under the Apache License, Version 2.0 (the "License");
2411 * you may not use this file except in compliance with the License.
2412 * You may obtain a copy of the License at
2413 *
2414 *   http://www.apache.org/licenses/LICENSE-2.0
2415 *
2416 * Unless required by applicable law or agreed to in writing, software
2417 * distributed under the License is distributed on an "AS IS" BASIS,
2418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2419 * See the License for the specific language governing permissions and
2420 * limitations under the License.
2421 */class vg{constructor(e,t="asc"){this.field=e,this.dir=t}}function e5(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}/**
2422 * @license
2423 * Copyright 2017 Google LLC
2424 *
2425 * Licensed under the Apache License, Version 2.0 (the "License");
2426 * you may not use this file except in compliance with the License.
2427 * You may obtain a copy of the License at
2428 *
2429 *   http://www.apache.org/licenses/LICENSE-2.0
2430 *
2431 * Unless required by applicable law or agreed to in writing, software
2432 * distributed under the License is distributed on an "AS IS" BASIS,
2433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2434 * See the License for the specific language governing permissions and
2435 * limitations under the License.
2436 */class pt{static fromTimestamp(e){return new pt(e)}static min(){return new pt(new An(0,0))}static max(){return new pt(new An(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/**
2437 * @license
2438 * Copyright 2017 Google LLC
2439 *
2440 * Licensed under the Apache License, Version 2.0 (the "License");
2441 * you may not use this file except in compliance with the License.
2442 * You may obtain a copy of the License at
2443 *
2444 *   http://www.apache.org/licenses/LICENSE-2.0
2445 *
2446 * Unless required by applicable law or agreed to in writing, software
2447 * distributed under the License is distributed on an "AS IS" BASIS,
2448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2449 * See the License for the specific language governing permissions and
2450 * limitations under the License.
2451 */class Xr{constructor(e,t,r,s,a,c,u){this.key=e,this.documentType=t,this.version=r,this.readTime=s,this.createTime=a,this.data=c,this.documentState=u}static newInvalidDocument(e){return new Xr(e,0,pt.min(),pt.min(),pt.min(),fs.empty(),0)}static newFoundDocument(e,t,r,s){return new Xr(e,1,t,pt.min(),r,s,0)}static newNoDocument(e,t){return new Xr(e,2,t,pt.min(),pt.min(),fs.empty(),0)}static newUnknownDocument(e,t){return new Xr(e,3,t,pt.min(),pt.min(),fs.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(pt.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=fs.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=fs.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=pt.min(),this}setReadTime(e){return this.readTime=e,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(e){return e instanceof Xr&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new Xr(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}})`}}
2451/**
2452 * @license
2453 * Copyright 2021 Google LLC
2454 *
2455 * Licensed under the Apache License, Version 2.0 (the "License");
2456 * you may not use this file except in compliance with the License.
2457 * You may obtain a copy of the License at
2458 *
2459 *   http://www.apache.org/licenses/LICENSE-2.0
2460 *
2461 * Unless required by applicable law or agreed to in writing, software
2462 * distributed under the License is distributed on an "AS IS" BASIS,
2463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2464 * See the License for the specific language governing permissions and
2465 * limitations under the License.
2466 */const Dh=-1;function t5(n,e){const t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=pt.fromTimestamp(r===1e9?new An(t+1,0):new An(t,r));return new sl(s,nt.empty(),e)}function n5(n){return new sl(n.readTime,n.key,Dh)}class sl{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new sl(pt.min(),nt.empty(),Dh)}static max(){return new sl(pt.max(),nt.empty(),Dh)}}function r5(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=nt.comparator(n.documentKey,e.documentKey),t!==0?t:Lt(n.largestBatchId,e.largestBatchId))}/**
2467 * @license
2468 * Copyright 2019 Google LLC
2469 *
2470 * Licensed under the Apache License, Version 2.0 (the "License");
2471 * you may not use this file except in compliance with the License.
2472 * You may obtain a copy of the License at
2473 *
2474 *   http://www.apache.org/licenses/LICENSE-2.0
2475 *
2476 * Unless required by applicable law or agreed to in writing, software
2477 * distributed under the License is distributed on an "AS IS" BASIS,
2478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2479 * See the License for the specific language governing permissions and
2480 * limitations under the License.
2481 */class s5{constructor(e,t=null,r=[],s=[],a=null,c=null,u=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=s,this.limit=a,this.startAt=c,this.endAt=u,this.R=null}}function G_(n,e=null,t=[],r=[],s=null,a=null,c=null){return new s5(n,e,t,r,s,a,c)}function MD(n){const e=xt(n);if(e.R===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((r=>Ay(r))).join(","),t+="|ob:",t+=e.orderBy.map((r=>(function(a){return a.field.canonicalString()+a.dir})(r))).join(","),rp(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((r=>Pu(r))).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((r=>Pu(r))).join(",")),e.R=t}return e.R}function LD(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!e5(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!ID(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!V_(n.startAt,e.startAt)&&V_(n.endAt,e.endAt)}function Zl(n){return!!n.isCorePipeline}function jD(n){return!!n.path&&nt.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}/**
2482 * @license
2483 * Copyright 2017 Google LLC
2484 *
2485 * Licensed under the Apache License, Version 2.0 (the "License");
2486 * you may not use this file except in compliance with the License.
2487 * You may obtain a copy of the License at
2488 *
2489 *   http://www.apache.org/licenses/LICENSE-2.0
2490 *
2491 * Unless required by applicable law or agreed to in writing, software
2492 * distributed under the License is distributed on an "AS IS" BASIS,
2493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2494 * See the License for the specific language governing permissions and
2495 * limitations under the License.
2496 */class Yh{constructor(e,t=null,r=[],s=[],a=null,c="F",u=null,h=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=a,this.limitType=c,this.startAt=u,this.endAt=h,this.I=null,this.A=null,this.V=null,this.startAt,this.endAt}}function i5(n,e,t,r,s,a,c,u){return new Yh(n,e,t,r,s,a,c,u)}function lp(n){return new Yh(n)}function H_(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function a5(n){return nt.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}function OD(n){return n.collectionGroup!==null}function lh(n){const e=xt(n);if(e.I===null){e.I=[];const t=new Set;for(const a of e.explicitOrderBy)e.I.push(a),t.add(a.field.canonicalString());const r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(c){let u=new yr(Ks.comparator);
2496return c.filters.forEach((h=>{h.getFlattenedFilters().forEach((f=>{f.isInequality()&&(u=u.add(f.field))}))})),u})(e).forEach((a=>{t.has(a.canonicalString())||a.isKeyField()||e.I.push(new vg(a,r))})),t.has(Ks.keyField().canonicalString())||e.I.push(new vg(Ks.keyField(),r))}return e.I}function ta(n){const e=xt(n);return e.A||(e.A=o5(e,lh(n))),e.A}function o5(n,e){if(n.limitType==="F")return G_(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map((s=>{const a=s.dir==="desc"?"asc":"desc";return new vg(s.field,a)}));const t=n.endAt?new bg(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new bg(n.startAt.position,n.startAt.inclusive):null;return G_(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function Iy(n,e){const t=n.filters.concat([e]);return new Yh(n.path,n.collectionGroup,n.explicitOrderBy.slice(),t,n.limit,n.limitType,n.startAt,n.endAt)}function wg(n,e,t){return new Yh(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function l5(n,e){return LD(ta(n),ta(e))&&n.limitType===e.limitType}function ch(n){return`Query(target=${(function(t){let r=t.path.canonicalString();return t.collectionGroup!==null&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map((s=>RD(s))).join(", ")}]`),rp(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map((s=>(function(c){return`${c.field.canonicalString()} (${c.dir})`})(s))).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map((s=>Pu(s))).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map((s=>Pu(s))).join(",")),`Target(${r})`})(ta(n))}; limitType=${n.limitType})`}function cp(n,e){return e.isFoundDocument()&&(function(r,s){const a=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(a):nt.isDocumentKey(r.path)?r.path.isEqual(a):r.path.isImmediateParentOf(a)})(n,e)&&(function(r,s){for(const a of lh(r))if(!a.field.isKeyField()&&s.data.field(a.field)===null)return!1;return!0})(n,e)&&(function(r,s){for(const a of r.filters)if(!a.matches(s))return!1;return!0})(n,e)&&(function(r,s){return!(r.startAt&&!(function(c,u,h){const f=U_(c,u,h);return c.inclusive?f<=0:f<0})(r.startAt,lh(r),s)||r.endAt&&!(function(c,u,h){const f=U_(c,u,h);return c.inclusive?f>=0:f>0})(r.endAt,lh(r),s))})(n,e)}function Dx(n){return(e,t)=>{let r=!1;for(const s of lh(n)){const a=c5(s,e,t);if(a!==0)return a;r=r||s.field.isKeyField()}return 0}}function c5(n,e,t){const r=n.field.isKeyField()?nt.comparator(e.key,t.key):(function(a,c,u){const h=c.data.field(a),f=u.data.field(a);return h!==null&&f!==null?As(h,f):ot(42886)})(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return ot(19790,{direction:n.dir})}}/**
2497 * @license
2498 * Copyright 2017 Google LLC
2499 *
2500 * Licensed under the Apache License, Version 2.0 (the "License");
2501 * you may not use this file except in compliance with the License.
2502 * You may obtain a copy of the License at
2503 *
2504 *   http://www.apache.org/licenses/LICENSE-2.0
2505 *
2506 * Unless required by applicable law or agreed to in writing, software
2507 * distributed under the License is distributed on an "AS IS" BASIS,
2508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2509 * See the License for the specific language governing permissions and
2510 * limitations under the License.
2511 */class u5{constructor(e,t){this.count=e,this.unchangedNames=t}}/**
2512 * @license
2513 * Copyright 2017 Google LLC
2514 *
2515 * Licensed under the Apache License, Version 2.0 (the "License");
2516 * you may not use this file except in compliance with the License.
2517 * You may obtain a copy of the License at
2518 *
2519 *   http://www.apache.org/licenses/LICENSE-2.0
2520 *
2521 * Unless required by applicable law or agreed to in writing, software
2522 * distributed under the License is distributed on an "AS IS" BASIS,
2523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2524 * See the License for the specific language governing permissions and
2525 * limitations under the License.
2526 */var fr,qt;function d5(n){switch(n){case ve.OK:return ot(64938);case ve.CANCELLED:case ve.UNKNOWN:case ve.DEADLINE_EXCEEDED:case ve.RESOURCE_EXHAUSTED:case ve.INTERNAL:case ve.UNAVAILABLE:case ve.UNAUTHENTICATED:return!1;case ve.INVALID_ARGUMENT:case ve.NOT_FOUND:case ve.ALREADY_EXISTS:case ve.PERMISSION_DENIED:case ve.FAILED_PRECONDITION:case ve.ABORTED:case ve.OUT_OF_RANGE:case ve.UNIMPLEMENT
2526ED:case ve.DATA_LOSS:return!0;default:return ot(15467,{code:n})}}function FD(n){if(n===void 0)return za("GRPC error has no .code"),ve.UNKNOWN;switch(n){case fr.OK:return ve.OK;case fr.CANCELLED:return ve.CANCELLED;case fr.UNKNOWN:return ve.UNKNOWN;case fr.DEADLINE_EXCEEDED:return ve.DEADLINE_EXCEEDED;case fr.RESOURCE_EXHAUSTED:return ve.RESOURCE_EXHAUSTED;case fr.INTERNAL:return ve.INTERNAL;case fr.UNAVAILABLE:return ve.UNAVAILABLE;case fr.UNAUTHENTICATED:return ve.UNAUTHENTICATED;case fr.INVALID_ARGUMENT:return ve.INVALID_ARGUMENT;case fr.NOT_FOUND:return ve.NOT_FOUND;case fr.ALREADY_EXISTS:return ve.ALREADY_EXISTS;case fr.PERMISSION_DENIED:return ve.PERMISSION_DENIED;case fr.FAILED_PRECONDITION:return ve.FAILED_PRECONDITION;case fr.ABORTED:return ve.ABORTED;case fr.OUT_OF_RANGE:return ve.OUT_OF_RANGE;case fr.UNIMPLEMENTED:return ve.UNIMPLEMENTED;case fr.DATA_LOSS:return ve.DATA_LOSS;default:return ot(39323,{code:n})}}(qt=fr||(fr={}))[qt.OK=0]="OK",qt[qt.CANCELLED=1]="CANCELLED",qt[qt.UNKNOWN=2]="UNKNOWN",qt[qt.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",qt[qt.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",qt[qt.NOT_FOUND=5]="NOT_FOUND",qt[qt.ALREADY_EXISTS=6]="ALREADY_EXISTS",qt[qt.PERMISSION_DENIED=7]="PERMISSION_DENIED",qt[qt.UNAUTHENTICATED=16]="UNAUTHENTICATED",qt[qt.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",qt[qt.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",qt[qt.ABORTED=10]="ABORTED",qt[qt.OUT_OF_RANGE=11]="OUT_OF_RANGE",qt[qt.UNIMPLEMENTED=12]="UNIMPLEMENTED",qt[qt.INTERNAL=13]="INTERNAL",qt[qt.UNAVAILABLE=14]="UNAVAILABLE",qt[qt.DATA_LOSS=15]="DATA_LOSS";/**
2527 * @license
2528 * Copyright 2017 Google LLC
2529 *
2530 * Licensed under the Apache License, Version 2.0 (the "License");
2531 * you may not use this file except in compliance with the License.
2532 * You may obtain a copy of the License at
2533 *
2534 *   http://www.apache.org/licenses/LICENSE-2.0
2535 *
2536 * Unless required by applicable law or agreed to in writing, software
2537 * distributed under the License is distributed on an "AS IS" BASIS,
2538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2539 * See the License for the specific language governing permissions and
2540 * limitations under the License.
2541 */class Ec{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r!==void 0){for(const[s,a]of r)if(this.equalsFn(s,e))return a}}has(e){return this.get(e)!==void 0}set(e,t){const r=this.mapKeyFn(e),s=this.inner[r];if(s===void 0)return this.inner[r]=[[e,t]],void this.innerSize++;for(let a=0;a<s.length;a++)if(this.equalsFn(s[a][0],e))return void(s[a]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r===void 0)return!1;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return r.length===1?delete this.inner[t]:r.splice(s,1),this.innerSize--,!0;return!1}forEach(e){hl(this.inner,((t,r)=>{for(const[s,a]of r)e(s,a)}))}isEmpty(){return fD(this.inner)}size(){return this.innerSize}}/**
2542 * @license
2543 * Copyright 2017 Google LLC
2544 *
2545 * Licensed under the Apache License, Version 2.0 (the "License");
2546 * you may not use this file except in compliance with the License.
2547 * You may obtain a copy of the License at
2548 *
2549 *   http://www.apache.org/licenses/LICENSE-2.0
2550 *
2551 * Unless required by applicable law or agreed to in writing, software
2552 * distributed under the License is distributed on an "AS IS" BASIS,
2553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2554 * See the License for the specific language governing permissions and
2555 * limitations under the License.
2556 */const h5=new Fn(nt.comparator);function Ns(){return h5}const UD=new Fn(nt.comparator);function xu(...n){let e=UD;for(const t of n)e=e.insert(t.key,t);return e}function VD(n){let e=UD;return n.forEach(((t,r)=>e=e.insert(t,r.overlayedDocument))),e}function Ho(){return uh()}function GD(){return uh()}function uh(){return new Ec((n=>n.toString()),((n,e)=>n.isEqual(e)))}const f5=new Fn(nt.comparator),m5=new yr(nt.comparator);function Dt(...n){let e=m5;for(const t of n)e=e.add(t);return e}const g5=new yr(Lt);function p5(){return g5}/**
2557 * @license
2558 * Copyright 2023 Google LLC
2559 *
2560 * Licensed under the Apache License, Version 2.0 (the "License");
2561 * you may not use this file except in compliance with the License.
2562 * You may obtain a copy of the License at
2563 *
2564 *   http://www.apache.org/licenses/LICENSE-2.0
2565 *
2566 * Unless required by applicable law or agreed to in writing, software
2567 * distributed under the License is distributed on an "AS IS" BASIS,
2568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2569 * See the License for the specific language governing permissions and
2570 * limitations under the License.
2571 */function B5(){return new TextEncoder}/**
2572 * @license
2573 * Copyright 2022 Google LLC
2574 *
2575 * Licensed under the Apache License, Version 2.0 (the "License");
2576 * you may not use this file except in compliance with the License.
2577 * You may obtain a copy of the License at
2578 *
2579 *   http://www.apache.org/licenses/LICENSE-2.0
2580 *
2581 * Unless required by applicable law or agreed to in writing, software
2582 * distributed under the License is distributed on an "AS IS" BASIS,
2583 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2584 * See the License for the specific language governing permissions and
2585 * limitations under the License.
2586 */const y5=new Ko([4294967295,4294967295],0);function q_(n){const e=B5().encode(n),t=new eD;return t.update(e),new Uint8Array(t.digest())}function z_(n){const e=new DataView(n.buffer),t=e.getUint32(0,!0),r=e.getUint32(4,!0),s=e.getUint32(8,!0),a=e.getUint32(12,!0);return[new Ko([t,r],0),new Ko([s,a],0)]}class Ax{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new Wd(`Invalid padding: ${t}`);if(r<0)throw new Wd(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new Wd(`Invalid hash count: ${r}`);if(e.length===0&&t!==0)throw new Wd(`Invalid padding when bitmap length is 0: ${t}`);this.m=8*e.length-t,this.p=Ko.fromNumber(this.m)}S(e,t,r){let s=e.add(t.multiply(Ko.fromNumber(r)));return s.compare(y5)===1&&(s=new Ko([s.getBits(0),s.getBits(1)],0)),s.modulo(this.p).toNumber()}v(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.m===0)return!1;const t=q_(e),[r,s]=z_(t);for(let a=0;a<this.hashCount;a++){const c=this.S(r,s,a);if(!this.v(c))return!1}return!0}static create(e,t,r){const s=e%8==0?0:8-e%8,a=new Uint8Array(Math.ceil(e/8)),c=new Ax(a,s,t);return r.forEach((u=>c.insert(u))),c}insert(e){if(this.m===0)return;const t=q_(e),[r,s]=z_(t);for(let a=0;a<this.hashCount;a++){const c=this.S(r,s,a);this.D(c)}}D(e){const t=Math.floor(e/8),r=e%8;this.bitmap[t]|=1<<r}}class Wd extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
2587 * @license
2588 * Copyright 2017 Google LLC
2589 *
2590 * Licensed under the Apache License, Version 2.0 (the "License");
2591 * you may not use this file except in compliance with the License.
2592 * You may obtain a copy of the License at
2593 *
2594 *   http://www.apache.org/licenses/LICENSE-2.0
2595 *
2596 * Unless required by applicable law or agreed to in writing, software
2597 * distributed under the License is distributed on an "AS IS" BASIS,
2598 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2599 * See the License for the specific language governing permissions and
2600 * limitations under the License.
2601 */class Qh{constructor(e,t,r,s,a,c){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=s,this.augmentedDocumentUpdates=a,this.resolvedLimboDocuments=c}static createSynthesizedRemoteEventForCurrentChange(e,t,r){const s=new Map;return s.set(e,Wh.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new Qh(pt.min(),s,new Fn(Lt),Ns(),Ns(),Dt())}}class Wh{constructor(e,t,r,s,a){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=s,this.removedDocuments=a}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new Wh(r,t,Dt(),Dt(),Dt())}}/**
2602 * @license
2603 * Copyright 2017 Google LLC
2604 *
2605 * Licensed under the Apache License, Version 2.0 (the "License");
2606 * you may not use this file except in compliance with the License.
2607 * You may obtain a copy of the License at
2608 *
2609 *   http://www.apache.org/licenses/LICENSE-2.0
2610 *
2611 * Unless required by applicable law or agreed to in writing, softw
2611are
2612 * distributed under the License is distributed on an "AS IS" BASIS,
2613 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2614 * See the License for the specific language governing permissions and
2615 * limitations under the License.
2616 */class Qm{constructor(e,t,r,s){this.C=e,this.removedTargetIds=t,this.key=r,this.F=s}}class HD{constructor(e,t){this.targetId=e,this.O=t}}class qD{constructor(e,t,r=xr.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}}class J_{constructor(e){this.targetId=e,this.M=0,this.N=$_(),this.L=xr.EMPTY_BYTE_STRING,this.B=!1,this.U=!0}get current(){return this.B}get resumeToken(){return this.L}get k(){return this.M!==0}get q(){return this.U}$(e){e.approximateByteSize()>0&&(this.U=!0,this.L=e)}K(){let e=Dt(),t=Dt(),r=Dt();return this.N.forEach(((s,a)=>{switch(a){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:r=r.add(s);break;default:ot(38017,{changeType:a})}})),new Wh(this.L,this.B,e,t,r)}W(){this.U=!1,this.N=$_()}G(e,t){this.U=!0,this.N=this.N.insert(e,t)}j(e){this.U=!0,this.N=this.N.remove(e)}H(){this.M+=1}J(){this.M-=1,Xe(this.M>=0,3241,{M:this.M,targetId:this.targetId})}Y(){this.U=!0,this.B=!0}}const Vd="WatchChangeAggregator";class x5{constructor(e){this.Z=e,this.X=new Map,this.ee=Ns(),this.te=km(),this.ne=Ns(),this.re=km(),this.ie=new Fn(Lt)}se(e){for(const t of e.C)e.F&&e.F.isFoundDocument()?this._e(t,e.F):this.oe(t,e.key,e.F);for(const t of e.removedTargetIds)this.oe(t,e.key,e.F)}ae(e){this.forEachTarget(e,(t=>{const r=this.X.get(t);if(r)switch(e.state){case 0:this.ue(t)&&r.$(e.resumeToken);break;case 1:r.J(),r.k||r.W(),r.$(e.resumeToken);break;case 2:r.J(),r.k||this.removeTarget(t);break;case 3:this.ue(t)&&(r.Y(),r.$(e.resumeToken));break;case 4:this.ue(t)&&(this.ce(t),r.$(e.resumeToken));break;default:ot(56790,{state:e.state})}else Ue(Vd,`handleTargetChange received targetChange for untracked target ID (${t}) with state (${e.state})`)}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.X.forEach(((r,s)=>{this.ue(s)&&t(s)}))}le(e){var t;return Zl(e)?e.getPipelineSourceType()==="documents"&&((t=e.getPipelineDocuments())==null?void 0:t.length)===1:jD(e)}Ee(e){const t=e.targetId,r=e.O.count,s=this.he(t);if(s){const a=s.target;if(this.le(a))if(r===0){const c=new nt(Zl(a)?sn.fromString(a.getPipelineDocuments()[0]):a.path);this.oe(t,c,Xr.newNoDocument(c,pt.min()))}else Xe(r===1,20013,"Single document existence filter with count: "+r);else{const c=this.Te(t);if(c!==r){const u=this.Pe(e),h=u?this.Re(u,e,c):1;if(h!==0){this.ce(t);const f=h===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.ie=this.ie.insert(t,f)}}}}}Pe(e){const t=e.O.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:a=0}=t;let c,u;try{c=nl(r).toUint8Array()}catch(h){if(h instanceof gD)return Ri("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{u=new Ax(c,s,a)}catch(h){return Ri(h instanceof Wd?"BloomFilter error: ":"Applying bloom filter failed: ",h),null}return u.m===0?null:u}Re(e,t,r){return t.O.count===r-this.Ve(e,t.targetId)?0:2}Ve(e,t){const r=this.Z.getRemoteKeysForTarget(t);let s=0;return r.forEach((a=>{const c=this.Z.Ae(),u=`projects/${c.projectId}/databases/${c.database}/documents/${a.path.canonicalString()}`;e.mightContain(u)||(this.oe(t,a,null),s++)})),s}de(e){const t=new Map;this.X.forEach(((a,c)=>{const u=this.he(c);if(u){if(a.current&&this.le(u.target)){const h=Zl(u.target)?sn.fromString(u.target.getPipelineDocuments()[0]):u.target.path,f=new nt(h);this.fe(f).has(c)||this.me(c,f)||this.oe(c,f,Xr.newNoDocument(f,e))}a.q&&(t.set(c,a.K()),a.W())}}));let r=Dt();this.re.forEach(((a,c)=>{let u=!0;
2616c.forEachWhile((h=>{const f=this.he(h);return!f||f.purpose==="TargetPurposeLimboResolution"||(u=!1,!1)})),u&&(r=r.add(a))})),this.ee.forEach(((a,c)=>c.setReadTime(e))),this.ne.forEach(((a,c)=>c.setReadTime(e)));const s=new Qh(e,t,this.ie,this.ee,this.ne,r);return this.ee=Ns(),this.te=km(),this.ne=Ns(),this.re=km(),this.ie=new Fn(Lt),s}_e(e,t){const r=this.X.get(e);if(!r||!this.ue(e))return void Ue(Vd,`addDocumentToTarget received document for unknown inactive target (${e})`);const s=this.me(e,t.key)?2:0;r.G(t.key,s),Zl(this.he(e).target)&&this.he(e).target.getPipelineFlavor()!=="exact"?this.ne=this.ne.insert(t.key,t):this.ee=this.ee.insert(t.key,t),this.te=this.te.insert(t.key,this.fe(t.key).add(e)),this.re=this.re.insert(t.key,this.pe(t.key).add(e))}oe(e,t,r){const s=this.X.get(e);s&&this.ue(e)?(this.me(e,t)?s.G(t,1):s.j(t),this.re=this.re.insert(t,this.pe(t).delete(e)),this.re=this.re.insert(t,this.pe(t).add(e)),r&&(Zl(this.he(e).target)&&this.he(e).target.getPipelineFlavor()!=="exact"?this.ne=this.ne.insert(t,r):this.ee=this.ee.insert(t,r))):Ue(Vd,`removeDocumentFromTarget received document for unknown or inactive target (${e})`)}removeTarget(e){this.X.delete(e)}Te(e){const t=this.X.get(e);if(!t)return 0;const r=t.K();return this.Z.getRemoteKeysForTarget(e).size+r.addedDocuments.size-r.removedDocuments.size}H(e){let t=this.X.get(e);t||(Ue(Vd,`recordPendingTargetRequest set up tracking for target ID ${e}`),t=new J_(e),this.X.set(e,t)),t.H()}pe(e){let t=this.re.get(e);return t||(t=new yr(Lt),this.re=this.re.insert(e,t)),t}fe(e){let t=this.te.get(e);return t||(t=new yr(Lt),this.te=this.te.insert(e,t)),t}ue(e){const t=this.he(e)!==null;return t||Ue(Vd,"Detected inactive target",e),t}he(e){const t=this.X.get(e);return t===void 0||t.k?null:this.Z.ge(e)}ce(e){this.X.set(e,new J_(e)),this.Z.getRemoteKeysForTarget(e).forEach((t=>{this.oe(e,t,null)}))}me(e,t){return this.Z.getRemoteKeysForTarget(e).has(t)}}function km(){return new Fn(nt.comparator)}function $_(){return new Fn(nt.comparator)}const C5={asc:"ASCENDING",desc:"DESCENDING"},b5={"<":"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"},v5={and:"AND",or:"OR"};class w5{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function Ry(n,e){return n.useProto3Json||rp(e)?e:{value:e}}function Eg(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function Ix(n){const e=tl(n);return new An(e.seconds,e.nanos)}function zD(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function Wm(n,e){return Eg(n,e.toTimestamp())}function na(n){return Xe(!!n,49232),pt.fromTimestamp(Ix(n))}function Rx(n,e){return Py(n,e).canonicalString()}function Py(n,e){const t=(function(s){return new sn(["projects",s.projectId,"databases",s.database])})(n).child("documents");return e===void 0?t:t.child(e)}function JD(n){const e=sn.fromString(n);return Xe(WD(e),10190,{key:e.toString()}),e}function _g(n,e){return Rx(n.databaseId,e.path)}function $B(n,e){const t=JD(e);if(t.get(1)!==n.databaseId.projectId)throw new Fe(ve.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new Fe(ve.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new nt(KD(t))}function $D(n,e){return Rx(n.databaseId,e)}function E5(n){const e=JD(n);return e.length===4?sn.emptyPath():KD(e)}function My(n){return new sn(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function KD(n){return Xe(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function K_(n,e,t){return{name:_g(n,e),fields:t.value.mapValue.fields}}function _5(n,e){let t;if("targetChange"in e){e.targetChange;const r=(function(f){return f==="NO_CHANGE"?0:f==="ADD"?1:f==="REMOVE"?2:f==="CURRENT"?3:f==="RESET"?4:ot(39313,{state:f})})(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],a=(function(f,p){return f.useProto3Json?(Xe(p===void 0||typeof p=="string",58123),xr.fromBase64String(p||"")):(Xe(p===void 0||p instanceof Buffer||p instanceof Uint8Array,16193),xr.fromUint8Array(p||new Uint8Array))})(n,e.targetChange.resumeToken),c=e.targetChange.cause,u=c&&(function(f){const p=f.code===void 0?ve.UNKNOWN:FD(f.code);return new Fe(p,f.message||"")})(c);t=new qD(r,s,a,u||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=$B(n,r.document.name),a=na(r.document.updateTime),c=r.document.createTime?na(r.document.createTime):pt.min(),u=new fs({mapValue:{fields:r.document.fields}}),h=Xr.newFoundDocument(s,a,c,u),f=r.targetIds||[],p=r.removedTargetIds||[];t=new Qm(f,p,h.key,h)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=$B(n,r.document),a=r.readTime?na(r.readTime):pt.min(),c=Xr.newNoDocument(s,a),u=r.removedTargetIds||[];t=new Qm([],u,c.key,c)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=$B(n,r.document),a=r.removedTargetIds||[];t=new Qm([],a,s,null)}else{if(!("filter"in e))return ot(11601,{ye:e});{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:a}=r,c=new u5(s,a),u=r.targetId;t=new HD(u,c)}}return t}function T5(n,e){let t;if(e instanceof Kh)t={update:K_(n,e.key,e.value)};else if(e instanceof op)t={delete:_g(n,e.key)};else if(e instanceof fl)t={update:K_(n,e.key,e.data),updateMask:L5(e.fieldMask)};else{if(!(e instanceof zO))return ot(16599,{we:e.type});t={verify:_g(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map((r=>(function(a,c){const u=c.transform;if(u instanceof Bg)return{fieldPath:c.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(u instanceof kh)return{fieldPath:c.field.canonicalString(),appendMissingElements:{values:u.elements}};if(u instanceof Nh)return{fieldPath:c.field.canonicalString(),removeAllFromArray:{values:u.elements}};if(u instanceof Sh)return{fieldPath:c.field.canonicalString(),increment:u.l};if(u instanceof yg)return{fieldPath:c.field.canonicalString(),minimum:u.l};if(u instanceof xg)return{fieldPath:c.field.canonicalString(),maximum:u.l};throw ot(20930,{transform:c.transform})})(0,r)))),e.precondition.isNone||(t.currentDocument=(function(s,a){return a.updateTime!==void 0?{updateTime:Wm(s,a.updateTime)}:a.exists!==void 0?{exists:a.exists}:ot(27497)})(n,e.precondition)),t}function k5(n,e){return n&&n.length>0?(Xe(e!==void 0,14353),n.map((t=>(function(s,a){let c=s.updateTime?na(s.updateTime):na(a);return c.isEqual(pt.min())&&(c=na(a)),new GO(c,s.transformResults||[])})(t,e)))):[]}function N5(n,e){return{documents:[$D(n,e.path)]}}function S5(n,e){const t={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=$D(n,s);const a=(function(f){if(f.length!==0)return QD(Pi.create(f,"and"))})(e.filters);a&&(t.structuredQuery.where=a);const c=(function(f){if(f.length!==0)return f.map((p=>(function(b){return{field:Cu(b.field),direction:R5(b.dir)}})(p)))})(e.orderBy);c&&(t.structuredQuery.orderBy=c);const u=Ry(n,e.limit);return u!==null&&(t.structuredQuery.limit=u),e.startAt&&(t.structuredQuery.startAt=(function(f){return{before:f.inclusive,values:f.position}})(e.startAt)),e.endAt&&(t.structuredQuery.endAt=(function(f){return{before:!f.inclusive,values:f.position}})(e.endAt)),{be:t,parent:s}}function D5(n){let e=E5(n.parent);
2616const t=n.structuredQuery,r=t.from?t.from.length:0;let s=null;if(r>0){Xe(r===1,65062);const p=t.from[0];p.allDescendants?s=p.collectionId:e=e.child(p.collectionId)}let a=[];t.where&&(a=(function(y){const b=YD(y);return b instanceof Pi&&AD(b)?b.getFilters():[b]})(t.where));let c=[];t.orderBy&&(c=(function(y){return y.map((b=>(function(E){return new vg(bu(E.field),(function(S){switch(S){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(E.direction))})(b)))})(t.orderBy));let u=null;t.limit&&(u=(function(y){let b;return b=typeof y=="object"?y.value:y,rp(b)?null:b})(t.limit));let h=null;t.startAt&&(h=(function(y){const b=!!y.before,w=y.values||[];return new bg(w,b)})(t.startAt));let f=null;return t.endAt&&(f=(function(y){const b=!y.before,w=y.values||[];return new bg(w,b)})(t.endAt)),i5(e,s,c,a,u,"F",h,f)}function A5(n,e){const t=(function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return ot(28987,{purpose:s})}})(e.purpose);return t==null?null:{"goog-listen-tags":t}}function I5(n,e){return{structuredPipeline:{pipeline:{stages:e.stages.map((t=>t._toProto(n)))}}}}function YD(n){return n.unaryFilter!==void 0?(function(t){switch(t.unaryFilter.op){case"IS_NAN":const r=bu(t.unaryFilter.field);return pr.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=bu(t.unaryFilter.field);return pr.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const a=bu(t.unaryFilter.field);return pr.create(a,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const c=bu(t.unaryFilter.field);return pr.create(c,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return ot(61313);default:return ot(60726)}})(n):n.fieldFilter!==void 0?(function(t){return pr.create(bu(t.fieldFilter.field),(function(s){switch(s){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 ot(58110);default:return ot(50506)}})(t.fieldFilter.op),t.fieldFilter.value)})(n):n.compositeFilter!==void 0?(function(t){return Pi.create(t.compositeFilter.filters.map((r=>YD(r))),(function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return ot(1026)}})(t.compositeFilter.op))})(n):ot(30097,{filter:n})}function R5(n){return C5[n]}function P5(n){return b5[n]}function M5(n){return v5[n]}function Cu(n){return{fieldPath:n.canonicalString()}}function bu(n){return Ks.fromServerFormat(n.fieldPath)}function QD(n){return n instanceof pr?(function(t){if(t.op==="=="){if(Is(t.value))return{unaryFilter:{field:Cu(t.field),op:"IS_NAN"}};if(Js(t.value))return{unaryFilter:{field:Cu(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Is(t.value))return{unaryFilter:{field:Cu(t.field),op:"IS_NOT_NAN"}};if(Js(t.value))return{unaryFilter:{field:Cu(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Cu(t.field),op:P5(t.op),value:t.value}}})(n):n instanceof Pi?(function(t){const r=t.getFilters().map((s=>QD(s)));return r.length===1?r[0]:{compositeFilter:{op:M5(t.op),filters:r}}})(n):ot(54877,{filter:n})}function L5(n){const e=[];return n.fields.forEach((t=>e.push(t.canonicalString()))),{fieldPaths:e}}function WD(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}function XD(n){return!!n&&typeof n._toProto=="function"&&n._protoValueType==="ProtoValue"}function Ah(n,e){const t={fields:{}};return e.forEach(((r,s)=>{if(typeof s!="string")throw new Error(`Cannot encode map with non-string key: ${s}`);t.fields[s]=r._toProto(n)})),{mapValue:t}}function ZD(n){return{stringValue:n}}/**
2617 * @license
2618 * Copyright 2020 Google LLC
2619 *
2620 * Licensed under the Apache License, Version 2.0 (the "License");
2621 * you may not use this file except in compliance with the License.
2622 * You may obtain a copy of the License at
2623 *
2624 *   http://www.apache.org/licenses/LICENSE-2.0
2625 *
2626 * Unless required by applicable law or agreed to in writing, softw
2626are
2627 * distributed under the License is distributed on an "AS IS" BASIS,
2628 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2629 * See the License for the specific language governing permissions and
2630 * limitations under the License.
2631 */function up(n){return new w5(n,!0)}/**
2632 * @license
2633 * Copyright 2020 Google LLC
2634 *
2635 * Licensed under the Apache License, Version 2.0 (the "License");
2636 * you may not use this file except in compliance with the License.
2637 * You may obtain a copy of the License at
2638 *
2639 *   http://www.apache.org/licenses/LICENSE-2.0
2640 *
2641 * Unless required by applicable law or agreed to in writing, software
2642 * distributed under the License is distributed on an "AS IS" BASIS,
2643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2644 * See the License for the specific language governing permissions and
2645 * limitations under the License.
2646 */class fi{constructor(e){this._byteString=e}static fromBase64String(e){try{return new fi(xr.fromBase64String(e))}catch(t){throw new Fe(ve.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new fi(xr.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:fi._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(Jh(e,fi._jsonSchema))return fi.fromBase64String(e.bytes)}}fi._jsonSchemaVersion="firestore/bytes/1.0",fi._jsonSchema={type:Br("string",fi._jsonSchemaVersion),bytes:Br("string")};/**
2647 * @license
2648 * Copyright 2020 Google LLC
2649 *
2650 * Licensed under the Apache License, Version 2.0 (the "License");
2651 * you may not use this file except in compliance with the License.
2652 * You may obtain a copy of the License at
2653 *
2654 *   http://www.apache.org/licenses/LICENSE-2.0
2655 *
2656 * Unless required by applicable law or agreed to in writing, software
2657 * distributed under the License is distributed on an "AS IS" BASIS,
2658 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2659 * See the License for the specific language governing permissions and
2660 * limitations under the License.
2661 */class dp{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new Fe(ve.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new Ks(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}function j5(){return new dp(Yi)}/**
2662 * @license
2663 * Copyright 2020 Google LLC
2664 *
2665 * Licensed under the Apache License, Version 2.0 (the "License");
2666 * you may not use this file except in compliance with the License.
2667 * You may obtain a copy of the License at
2668 *
2669 *   http://www.apache.org/licenses/LICENSE-2.0
2670 *
2671 * Unless required by applicable law or agreed to in writing, software
2672 * distributed under the License is distributed on an "AS IS" BASIS,
2673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2674 * See the License for the specific language governing permissions and
2675 * limitations under the License.
2676 */class Px{constructor(e){this._methodName=e}}/**
2677 * @license
2678 * Copyright 2017 Google LLC
2679 *
2680 * Licensed under the Apache License, Version 2.0 (the "License");
2681 * you may not use this file except in compliance with the License.
2682 * You may obtain a copy of the License at
2683 *
2684 *   http://www.apache.org/licenses/LICENSE-2.0
2685 *
2686 * Unless required by applicable law or agreed to in writing, software
2687 * distributed under the License is distributed on an "AS IS" BASIS,
2688 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2689 * See the License for the specific language governing permissions and
2690 * limitations under the License.
2691 */class ra{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new Fe(ve.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new Fe(ve.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return Lt(this._lat,e._lat)||Lt(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:ra._jsonSchemaVersion}}static fromJSON(e){if(Jh(e,ra._jsonSchema))return new ra(e.latitude,e.longitude)}}ra._jsonSchemaVersion="firestore/geoPoint/1.0",ra._jsonSchema={type:Br("string",ra._jsonSchemaVersion),latitude:Br("number"),longitude:Br("number")};/**
2692 * @license
2693 * Copyright 2017 Google LLC
2694 *
2695 * Licensed under the Apache License, Version 2.0 (the "License");
2696 * you may not use this file except in compliance with the License.
2697 * You may obtain a copy of the License at
2698 *
2699 *   http://www.apache.org/licenses/LICENSE-2.0
2700 *
2701 * Unless required by applicable law or agreed to in writing, software
2702 * distributed under the License is distributed on an "AS IS" BASIS,
2703 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2704 * See the License for the specific language governing permissions and
2705 * limitations under the License.
2706 */class Wr{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}Wr.UNAUTHENTICATED=new Wr(null),Wr.GOOGLE_CREDENTIALS=new Wr("google-credentials-uid"),Wr.FIRST_PARTY=new Wr("first-party-uid"),Wr.MOCK_USER=new Wr("mock-user");/**
2707 * @license
2708 * Copyright 2017 Google LLC
2709 *
2710 * Licensed under the Apache License, Version 2.0 (the "License");
2711 * you may not use this file except in compliance with the License.
2712 * You may obtain a copy of the License at
2713 *
2714 *   http://www.apache.org/licenses/LICENSE-2.0
2715 *
2716 * Unless required by applicable law or agreed to in writing, software
2717 * distributed under the License is distributed on an "AS IS" BASIS,
2718 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2719 * See the License for the specific language governing permissions and
2720 * limitations under the License.
2721 */class Ua{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}/**
2722 * @license
2723 * Copyright 2017 Google LLC
2724 *
2725 * Licensed under the Apache License, Version 2.0 (the "License");
2726 * you may not use this file except in compliance with the License.
2727 * You may obtain a copy of the License at
2728 *
2729 *   http://www.apache.org/licenses/LICENSE-2.0
2730 *
2731 * Unless required by applicable law or agreed to in writing, software
2732 * distributed under the License is distributed on an "AS IS" BASIS,
2733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2734 * See the License for the specific language governing permissions and
2735 * limitations under the License.
2736 */class e1{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class O5{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(Wr.UNAUTHENTICATED)))}shutdown(){}}class F5{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}}class U5{constructor(e){this.ve=e,this.currentUser=Wr.UNAUTHENTICATED,this.De=0,this.forceRefresh=!1,this.auth=null}start(e,t){Xe(this.xe===void 0,42304);let r=this.De;const s=h=>this.De!==r?(r=this.De,t(h)):Promise.resolve();let a=new Ua;this.xe=()=>{this.De++,this.currentUser=this.Ce(),a.resolve(),a=new Ua,e.enqueueRetryable((()=>s(this.currentUser)))};const c=()=>{const h=a;e.enqueueRetryable((async()=>{await h.promise,await s(this.currentUser)}))},u=h=>{Ue("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=h,this.xe&&(this.auth.addAuthTokenListener(this.xe),c())};this.ve.onInit((h=>u(h))),setTimeout((()=>{if(!this.auth){const h=this.ve.getImmediate({optional:!0});h?u(h):(Ue("FirebaseAuthCredentialsProvider","Auth not yet detected"),a.resolve(),a=new Ua)}}),0),c()}getToken(){const e=this.De,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((r=>this.De!==e?(Ue("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(Xe(typeof r.accessToken=="string",31837,{Fe:r}),new e1(r.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.xe&&this.auth.removeAuthTokenListener(this.xe),this.xe=void 0}Ce(){const e=this.auth&&this.auth.getUid();return Xe(e===null||typeof e=="string",2055,{Oe:e}),new Wr(e)}}class V5{constructor(e,t,r){this.Me=e,this.Ne=t,this.Le=r,this.type="FirstParty",this.user=Wr.FIRST_PARTY,this.Be=new Map}Ue(){return this.Le?this.Le():null}get headers(){this.Be.set("X-Goog-AuthUser",this.Me);const e=this.Ue();return e&&this.Be.set("Authorization",e),this.Ne&&this.Be.set("X-Goog-Iam-Authorization-Token",this.Ne),this.Be}}class G5{constructor(e,t,r){this.Me=e,this.Ne=t,this.Le=r}getToken(){return Promise.resolve(new V5(this.Me,this.Ne,this.Le))}start(e,t){e.enqueueRetryable((()=>t(Wr.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class Y_{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class H5{constructor(e,t){this.ke=t,this.forceRefresh=!1,this.appCheck=null,this.qe=null,this.$e=null,Ts(e)&&e.settings.appCheckToken&&(this.$e=e.settings.appCheckToken)}start(e,t){Xe(this.xe===void 0,3512);const r=a=>{a.error!=null&&Ue("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${a.error.message}`);const c=a.token!==this.qe;return this.qe=a.token,Ue("FirebaseAppCheckTokenProvider",`Received ${c?"new":"existing"} token.`),c?t(a.token):Promise.resolve()};this.xe=a=>{e.enqueueRetryable((()=>r(a)))};const s=a=>{Ue("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=a,this.xe&&this.appCheck.addTokenListener(this.xe)};this.ke.onInit((a=>s(a))),setTimeout((()=>
2736{if(!this.appCheck){const a=this.ke.getImmediate({optional:!0});a?s(a):Ue("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.$e)return Promise.resolve(new Y_(this.$e));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((t=>t?(Xe(typeof t.token=="string",44558,{tokenResult:t}),this.qe=t.token,new Y_(t.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.xe&&this.appCheck.removeTokenListener(this.xe),this.xe=void 0}}function t1(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}/**
2737 * @license
2738 * Copyright 2019 Google LLC
2739 *
2740 * Licensed under the Apache License, Version 2.0 (the "License");
2741 * you may not use this file except in compliance with the License.
2742 * You may obtain a copy of the License at
2743 *
2744 *   http://www.apache.org/licenses/LICENSE-2.0
2745 *
2746 * Unless required by applicable law or agreed to in writing, software
2747 * distributed under the License is distributed on an "AS IS" BASIS,
2748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2749 * See the License for the specific language governing permissions and
2750 * limitations under the License.
2751 */class q5{Ke(e){}shutdown(){}}/**
2752 * @license
2753 * Copyright 2019 Google LLC
2754 *
2755 * Licensed under the Apache License, Version 2.0 (the "License");
2756 * you may not use this file except in compliance with the License.
2757 * You may obtain a copy of the License at
2758 *
2759 *   http://www.apache.org/licenses/LICENSE-2.0
2760 *
2761 * Unless required by applicable law or agreed to in writing, software
2762 * distributed under the License is distributed on an "AS IS" BASIS,
2763 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2764 * See the License for the specific language governing permissions and
2765 * limitations under the License.
2766 */const Q_="ConnectivityMonitor";class W_{constructor(){this.Qe=()=>this.We(),this.Ge=()=>this.ze(),this.je=[],this.He()}Ke(e){this.je.push(e)}shutdown(){window.removeEventListener("online",this.Qe),window.removeEventListener("offline",this.Ge)}He(){window.addEventListener("online",this.Qe),window.addEventListener("offline",this.Ge)}We(){Ue(Q_,"Network connectivity changed: AVAILABLE");for(const e of this.je)e(0)}ze(){Ue(Q_,"Network connectivity changed: UNAVAILABLE");for(const e of this.je)e(1)}static Je(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
2767 * @license
2768 * Copyright 2023 Google LLC
2769 *
2770 * Licensed under the Apache License, Version 2.0 (the "License");
2771 * you may not use this file except in compliance with the License.
2772 * You may obtain a copy of the License at
2773 *
2774 *   http://www.apache.org/licenses/LICENSE-2.0
2775 *
2776 * Unless required by applicable law or agreed to in writing, software
2777 * distributed under the License is distributed on an "AS IS" BASIS,
2778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2779 * See the License for the specific language governing permissions and
2780 * limitations under the License.
2781 */let Nm=null;function Ly(){return Nm===null?Nm=(function(){return 268435456+Math.round(2147483648*Math.random())})():Nm++,"0x"+Nm.toString(16)}/**
2782 * @license
2783 * Copyright 2020 Google LLC
2784 *
2785 * Licensed under the Apache License, Version 2.0 (the "License");
2786 * you may not use this file except in compliance with the License.
2787 * You may obtain a copy of the License at
2788 *
2789 *   http://www.apache.org/licenses/LICENSE-2.0
2790 *
2791 * Unless required by applicable law or agreed to in writing, software
2792 * distributed under the License is distributed on an "AS IS" BASIS,
2793 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2794 * See the License for the specific language governing permissions and
2795 * limitations under the License.
2796 */const KB="RestConnection",z5={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class J5{get Ye(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.Ze=t+"://"+e.host,this.Xe=`projects/${r}/databases/${s}`,this.et=this.databaseId.database===gg?`project_id=${r}`:`project_id=${r}&database_id=${s}`}tt(e,t,r,s,a){const c=Ly(),u=this.nt(e,t.toUriEncodedString());Ue(KB,`Sending RPC '${e}' ${c}:`,u,r);
vendor: 8,467 bytes, lines 2796-2856
2796const h={"google-cloud-resource-prefix":this.Xe,"x-goog-request-params":this.et};this.rt(h,s,a);const{host:f}=new URL(u),p=vc(f);return this.it(e,u,h,r,p).then((y=>(Ue(KB,`Received RPC '${e}' ${c}: `,y),y)),(y=>{throw Ri(KB,`RPC '${e}' ${c} failed with error: `,y,"url: ",u,"request:",r),y}))}st(e,t,r,s,a,c){return this.tt(e,t,r,s,a)}rt(e,t,r){if(e["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+Fu})(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach(((s,a)=>e[a]=s)),r&&r.headers.forEach(((s,a)=>e[a]=s)),this.databaseInfo._customHeaders)for(const s of Object.keys(this.databaseInfo._customHeaders))e[s]=this.databaseInfo._customHeaders[s]}nt(e,t){const r=z5[e];let s=`${this.Ze}/v1/${t}:${r}`;return this.databaseInfo.apiKey&&(s=`${s}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),s}terminate(){}}/**
2797 * @license
2798 * Copyright 2017 Google LLC
2799 *
2800 * Licensed under the Apache License, Version 2.0 (the "License");
2801 * you may not use this file except in compliance with the License.
2802 * You may obtain a copy of the License at
2803 *
2804 *   http://www.apache.org/licenses/LICENSE-2.0
2805 *
2806 * Unless required by applicable law or agreed to in writing, software
2807 * distributed under the License is distributed on an "AS IS" BASIS,
2808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2809 * See the License for the specific language governing permissions and
2810 * limitations under the License.
2811 */class $5{constructor(e){this._t=e._t,this.ot=e.ot}ut(e){this.ct=e}lt(e){this.Et=e}ht(e){this.Tt=e}onMessage(e){this.Pt=e}close(){this.ot()}send(e){this._t(e)}Rt(){this.ct()}It(){this.Et()}At(e){this.Tt(e)}Vt(e){this.Pt(e)}}/**
2812 * @license
2813 * Copyright 2017 Google LLC
2814 *
2815 * Licensed under the Apache License, Version 2.0 (the "License");
2816 * you may not use this file except in compliance with the License.
2817 * You may obtain a copy of the License at
2818 *
2819 *   http://www.apache.org/licenses/LICENSE-2.0
2820 *
2821 * Unless required by applicable law or agreed to in writing, software
2822 * distributed under the License is distributed on an "AS IS" BASIS,
2823 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2824 * See the License for the specific language governing permissions and
2825 * limitations under the License.
2826 */const Qr="WebChannelConnection",Gd=(n,e,t)=>{n.listen(e,(r=>{try{t(r)}catch(s){setTimeout((()=>{throw s}),0)}}))};class ku extends J5{constructor(e){super(e),this.dt=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static ft(){if(!ku.gt){const e=sD();Gd(e,rD.STAT_EVENT,(t=>{t.stat===Ey.PROXY?Ue(Qr,"STAT_EVENT: detected buffering proxy"):t.stat===Ey.NOPROXY&&Ue(Qr,"STAT_EVENT: detected no buffering proxy")})),ku.gt=!0}}it(e,t,r,s,a){const c=Ly();return new Promise(((u,h)=>{const f=new tD;f.setWithCredentials(!0),f.listenOnce(nD.COMPLETE,(()=>{try{switch(f.getLastErrorCode()){case $m.NO_ERROR:const y=f.getResponseJson();Ue(Qr,`XHR for RPC '${e}' ${c} received:`,JSON.stringify(y)),u(y);break;case $m.TIMEOUT:Ue(Qr,`RPC '${e}' ${c} timed out`),h(new Fe(ve.DEADLINE_EXCEEDED,"Request time out"));break;case $m.HTTP_ERROR:const b=f.getStatus();if(Ue(Qr,`RPC '${e}' ${c} failed with status:`,b,"response text:",f.getResponseText()),b>0){let w=f.getResponseJson();Array.isArray(w)&&(w=w[0]);const E=w==null?void 0:w.error;if(E&&E.status&&E.message){const N=(function(I){const O=I.toLowerCase().replace(/_/g,"-");return Object.values(ve).indexOf(O)>=0?O:ve.UNKNOWN})(E.status);h(new Fe(N,E.message))}else h(new Fe(ve.UNKNOWN,"Server responded with status "+f.getStatus()))}else h(new Fe(ve.UNAVAILABLE,"Connection failed."));break;default:ot(9055,{yt:e,streamId:c,wt:f.getLastErrorCode(),bt:f.getLastError()})}}finally{Ue(Qr,`RPC '${e}' ${c} completed.`)}}));const p=JSON.stringify(s);Ue(Qr,`RPC '${e}' ${c} sending request:`,s),f.send(t,"POST",p,r,15)}))}St(e,t,r){const s=Ly(),a=[this.Ze,"/","google.firestore.v1.Firestore","/",e,"/channel"],c=this.createWebChannelTransport(),u={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&&(u.longPollingTimeout=Math.round(1e3*h)),this.useFetchStreams&&(u.useFetchStreams=!0),this.rt(u.initMessageHeaders,t,r),u.encodeInitMessageHeaders=!0;const f=a.join("");Ue(Qr,`Creating RPC '${e}' stream ${s}: ${f}`,u);const p=c.createWebChannel(f,u);this.vt(p);let y=!1,b=!1;const w=new $5({_t:E=>{b?Ue(Qr,`Not sending because RPC '${e}' stream ${s} is closed:`,E):(y||(Ue(Qr,`Opening RPC '${e}' stream ${s} transport.`),p.open(),y=!0),Ue(Qr,`RPC '${e}' stream ${s} sending:`,E),p.send(E))},ot:()=>p.close()});return Gd(p,Qd.EventType.OPEN,(()=>{b||(Ue(Qr,`RPC '${e}' stream ${s} transport opened.`),w.Rt())})),Gd(p,Qd.EventType.CLOSE,(()=>{b||(b=!0,Ue(Qr,`RPC '${e}' stream ${s} transport closed`),w.At(),this.Dt(p))})),Gd(p,Qd.EventType.ERROR,(E=>{b||(b=!0,Ri(Qr,`RPC '${e}' stream ${s} transport errored. Name:`,E.name,"Message:",E.message),w.At(new Fe(ve.UNAVAILABLE,"The operation could not be completed")))})),Gd(p,Qd.EventType.MESSAGE,(E=>{var N;if(!b){const S=E.data[0];Xe(!!S,16349);const I=S,O=(I==null?void 0:I.error)||((N=I[0])==null?void 0:N.error);if(O){Ue(Qr,`RPC '${e}' stream ${s} received error:`,O);const F=O.status;let J=(function(D){const k=fr[D];if(k!==void 0)return FD(k)})(F),z=O.message;F==="NOT_FOUND"&&z.includes("database")&&z.includes("does not exist")&&z.includes(this.databaseId.database)&&Ri(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),J===void 0&&(J=ve.INTERNAL,z="Unknown error status: "+F+" with message "+O.message),b=!0,w.At(new Fe(J,z)),p.close()}else Ue(Qr,`RPC '${e}' stream ${s} received:`,S),w.Vt(S)}})),ku.ft(),setTimeout((()=>{w.It()}),0),w}terminate(){this.dt.forEach((e=>e.close())),this.dt=[]}vt(e){this.dt.push(e)}Dt(e){this.dt=this.dt.filter((t=>t===e))}rt(e,t,r){super.rt(e,t,r),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return iD()}}/**
2827 * @license
2828 * Copyright 2020 Google LLC
2829 *
2830 * Licensed under the Apache License, Version 2.0 (the "License");
2831 * you may not use this file except in compliance with the License.
2832 * You may obtain a copy of the License at
2833 *
2834 *   http://www.apache.org/licenses/LICENSE-2.0
2835 *
2836 * Unless required by applicable law or agreed to in writing, software
2837 * distributed under the License is distributed on an "AS IS" BASIS,
2838 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2839 * See the License for the specific language governing permissions and
2840 * limitations under the License.
2841 */function K5(n){return new ku(n)}ku.gt=!1;class n1{constructor(e,t,r=1e3,s=1.5,a=6e4){this.xt=e,this.timerId=t,this.Ct=r,this.Ft=s,this.Ot=a,this.Mt=0,this.Nt=null,this.Lt=Date.now(),this.reset()}reset(){this.Mt=0}Bt(){this.Mt=this.Ot}Ut(e){this.cancel();const t=Math.floor(this.Mt+this.kt()),r=Math.max(0,Date.now()-this.Lt),s=Math.max(0,t-r);s>0&&Ue("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.Mt} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.Nt=this.xt.enqueueAfterDelay(this.timerId,s,(()=>(this.Lt=Date.now(),e()))),this.Mt*=this.Ft,this.Mt<this.Ct&&(this.Mt=this.Ct),this.Mt>this.Ot&&(this.Mt=this.Ot)}qt(){this.Nt!==null&&(this.Nt.skipDelay(),this.Nt=null)}cancel(){this.Nt!==null&&(this.Nt.cancel(),this.Nt=null)}kt(){return(Math.random()-.5)*this.Mt}}/**
2842 * @license
2843 * Copyright 2017 Google LLC
2844 *
2845 * Licensed under the Apache License, Version 2.0 (the "License");
2846 * you may not use this file except in compliance with the License.
2847 * You may obtain a copy of the License at
2848 *
2849 *   http://www.apache.org/licenses/LICENSE-2.0
2850 *
2851 * Unless required by applicable law or agreed to in writing, software
2852 * distributed under the License is distributed on an "AS IS" BASIS,
2853 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2854 * See the License for the specific language governing permissions and
2855 * limitations under the License.
2856 */const X_="PersistentStream";
2856class r1{constructor(e,t,r,s,a,c,u,h){this.xt=e,this.$t=r,this.Kt=s,this.connection=a,this.authCredentialsProvider=c,this.appCheckCredentialsProvider=u,this.listener=h,this.state=0,this.Qt=0,this.Wt=null,this.Gt=null,this.stream=null,this.zt=0,this.jt=new n1(e,t)}Ht(){return this.state===1||this.state===5||this.Jt()}Jt(){return this.state===2||this.state===3}start(){this.zt=0,this.state!==4?this.auth():this.Yt()}async stop(){this.Ht()&&await this.close(0)}Zt(){this.state=0,this.jt.reset()}Xt(){this.Jt()&&this.Wt===null&&(this.Wt=this.xt.enqueueAfterDelay(this.$t,6e4,(()=>this.en())))}tn(e){this.nn(),this.stream.send(e)}async en(){if(this.Jt())return this.close(0)}nn(){this.Wt&&(this.Wt.cancel(),this.Wt=null)}rn(){this.Gt&&(this.Gt.cancel(),this.Gt=null)}async close(e,t){this.nn(),this.rn(),this.jt.cancel(),this.Qt++,e!==4?this.jt.reset():t&&t.code===ve.RESOURCE_EXHAUSTED?(za(t.toString()),za("Using maximum backoff delay to prevent overloading the backend."),this.jt.Bt()):t&&t.code===ve.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.sn(),this.stream.close(),this.stream=null),this.state=e,await this.listener.ht(t)}sn(){}auth(){this.state=1;const e=this._n(this.Qt),t=this.Qt;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([r,s])=>{this.Qt===t&&this.an(r,s)}),(r=>{e((()=>{const s=new Fe(ve.UNKNOWN,"Fetching auth token failed: "+r.message);return this.un(s)}))}))}an(e,t){const r=this._n(this.Qt);this.stream=this.cn(e,t),this.stream.ut((()=>{r((()=>this.listener.ut()))})),this.stream.lt((()=>{r((()=>(this.state=2,this.Gt=this.xt.enqueueAfterDelay(this.Kt,1e4,(()=>(this.Jt()&&(this.state=3),Promise.resolve()))),this.listener.lt())))})),this.stream.ht((s=>{r((()=>this.un(s)))})),this.stream.onMessage((s=>{r((()=>++this.zt==1?this.En(s):this.onNext(s)))}))}Yt(){this.state=5,this.jt.Ut((async()=>{this.state=0,this.start()}))}un(e){return Ue(X_,`close with error: ${e}`),this.stream=null,this.close(4,e)}_n(e){return t=>{this.xt.enqueueAndForget((()=>this.Qt===e?t():(Ue(X_,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class Y5 extends r1{constructor(e,t,r,s,a,c){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,s,c),this.serializer=a}cn(e,t){return this.connection.St("Listen",e,t)}En(e){return this.onNext(e)}onNext(e){this.jt.reset();const t=_5(this.serializer,e),r=(function(a){if(!("targetChange"in a))return pt.min();const c=a.targetChange;return c.targetIds&&c.targetIds.length?pt.min():c.readTime?na(c.readTime):pt.min()})(e);return this.listener.hn(t,r)}Tn(e){const t={};t.database=My(this.serializer),t.addTarget=(function(a,c){let u;const h=c.target;if(u=Zl(h)?{pipelineQuery:I5(a,h)}:jD(h)?{documents:N5(a,h)}:{query:S5(a,h).be},u.targetId=c.targetId,c.resumeToken.approximateByteSize()>0){u.resumeToken=zD(a,c.resumeToken);const f=Ry(a,c.expectedCount);f!==null&&(u.expectedCount=f)}else if(c.snapshotVersion.compareTo(pt.min())>0){u.readTime=Eg(a,c.snapshotVersion.toTimestamp());const f=Ry(a,c.expectedCount);f!==null&&(u.expectedCount=f)}return u})(this.serializer,e);const r=A5(this.serializer,e);r&&(t.labels=r),this.tn(t)}Pn(e){const t={};t.database=My(this.serializer),t.removeTarget=e,this.tn(t)}}class Q5 extends r1{constructor(e,t,r,s,a,c){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,s,c),this.serializer=a}get Rn(){return this.zt>0}start(){this.lastStreamToken=void 0,super.start()}sn(){this.Rn&&this.In([])}cn(e,t){return this.connection.St("Write",e,t)}En(e){return Xe(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,Xe(!e.writeResults||e.writeResults.length===0,55816),this.listener.An()}onNext(e){Xe(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.jt.reset();const t=k5(e.writeResults,e.commitTime),r=na(e.commitTime);return this.listener.Vn(r,t)}dn(){const e={};e.database=My(this.serializer),this.tn(e)}In(e){const t={streamToken:this.lastStreamToken,writes:e.map((r=>T5(this.serializer,r)))};this.tn(t)}}/**
2857 * @license
2858 * Copyright 2017 Google LLC
2859 *
2860 * Licensed under the Apache License, Version 2.0 (the "License");
2861 * you may not use this file except in compliance with the License.
2862 * You may obtain a copy of the License at
2863 *
2864 *   http://www.apache.org/licenses/LICENSE-2.0
2865 *
2866 * Unless required by applicable law or agreed to in writing, software
2867 * distributed under the License is distributed on an "AS IS" BASIS,
2868 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2869 * See the License for the specific language governing permissions and
2870 * limitations under the License.
2871 */class W5{}class X5 extends W5{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=s,this.fn=!1}mn(){if(this.fn)throw new Fe(ve.FAILED_PRECONDITION,"The client has already been terminated.")}tt(e,t,r,s){return this.mn(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,c])=>this.connection.tt(e,Py(t,r),s,a,c))).catch((a=>{throw a.name==="FirebaseError"?(a.code===ve.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new Fe(ve.UNKNOWN,a.toString())}))}st(e,t,r,s,a){return this.mn(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([c,u])=>this.connection.st(e,Py(t,r),s,c,u,a))).catch((c=>{throw c.name==="FirebaseError"?(c.code===ve.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),c):new Fe(ve.UNKNOWN,c.toString())}))}terminate(){this.fn=!0,this.connection.terminate()}}function Z5(n,e,t,r){return new X5(n,e,t,r)}/**
2872 * @license
2873 * Copyright 2020 Google LLC
2874 *
2875 * Licensed under the Apache License, Version 2.0 (the "License");
2876 * you may not use this file except in compliance with the License.
2877 * You may obtain a copy of the License at
2878 *
2879 *   http://www.apache.org/licenses/LICENSE-2.0
2880 *
2881 * Unless required by applicable law or agreed to in writing, software
2882 * distributed under the License is distributed on an "AS IS" BASIS,
2883 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2884 * See the License for the specific language governing permissions and
2885 * limitations under the License.
2886 */const eF="ComponentProvider",Z_=new Map;function tF(n,e,t,r,s){return new RO(n,e,t,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,t1(s.experimentalLongPollingOptions),s.useFetchStreams,s.isUsingEmulator,r,s._customHeaders,s.grpcFlowControlWindow)}/**
2887 * @license
2888 * Copyright 2018 Google LLC
2889 *
2890 * Licensed under the Apache License, Version 2.0 (the "License");
2891 * you may not use this file except in compliance with the License.
2892 * You may obtain a copy of the License at
2893 *
2894 *   http://www.apache.org/licenses/LICENSE-2.0
2895 *
2896 * Unless required by applicable law or agreed to in writing, software
2897 * distributed under the License is distributed on an "AS IS" BASIS,
2898 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2899 * See the License for the specific language governing permissions and
2900 * limitations under the License.
2901 */const eT={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},s1=41943040;class _s{static withCacheSize(e){return new _s(e,_s.DEFAULT_COLLECTION_PERCENTILE,_s.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}_s.DEFAULT_COLLECTION_PERCENTILE=10,_s.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,_s.DEFAULT=new _s(s1,_s.DEFAULT_COLLECTION_PERCENTILE,_s.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),_s.DISABLED=new _s(-1,0,0);/**
2902 * @license
2903 * Copyright 2018 Google LLC
2904 *
2905 * Licensed under the Apache License, Version 2.0 (the "License");
2906 * you may not use this file except in compliance with the License.
2907 * You may obtain a copy of the License at
2908 *
2909 *   http://www.apache.org/licenses/LICENSE-2.0
2910 *
2911 * Unless required by applicable law or agreed to in writing, software
2912 * distributed under the License is distributed on an "AS IS" BASIS,
2913 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2914 * See the License for the specific language governing permissions and
2915 * limitations under the License.
2916 */class hp{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=r=>this.pn(r),this.gn=r=>t.writeSequenceNumber(r))}pn(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.gn&&this.gn(e),e}}hp.yn=-1;/**
2917 * @license
2918 * Copyright 2020 Google LLC
2919 *
2920 * Licensed under the Apache License, Version 2.0 (the "License");
2921 * you may not use this file except in compliance with the License.
2922 * You may obtain a copy of the License at
2923 *
2924 *   http://www.apache.org/licenses/LICENSE-2.0
2925 *
2926 * Unless required by applicable law or agreed to in writing, software
2927 * distributed under the License is distributed on an "AS IS" BASIS,
2928 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2929 * See the License for the specific language governing permissions and
2930 * limitations under the License.
2931 */const nF="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class rF{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}}/**
2932 * @license
2933 * Copyright 2017 Google LLC
2934 *
2935 * Licensed under the Apache License, Version 2.0 (the "License");
2936 * you may not use this file except in compliance with the License.
2937 * You may obtain a copy of the License at
2938 *
2939 *   http://www.apache.org/licenses/LICENSE-2.0
2940 *
2941 * Unless required by applicable law or agreed to in writing, software
2942 * distributed under the License is distributed on an "AS IS" BASIS,
2943 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2944 * See the License for the specific language governing permissions and
2945 * limitations under the License.
2946 */async function Uu(n){if(n.code!==ve.FAILED_PRECONDITION||n.message!==nF)throw n;Ue("LocalStore","Unexpectedly lost primary lease")}/**
2947 * @license
2948 * Copyright 2017 Google LLC
2949 *
2950 * Licensed under the Apache License, Version 2.0 (the "License");
2951 * you may not use this file except in compliance with the License.
2952 * You may obtain a copy of the License at
2953 *
2954 *   http://www.apache.org/licenses/LICENSE-2.0
2955 *
2956 * Unless required by applicable law or agreed to in writing, software
2957 * distributed under the License is distributed on an "AS IS" BASIS,
2958 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2959 * See the License for the specific language governing permissions and
2960 * limitations under the License.
2961 */class Ee{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e((t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)}),(t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)}))}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&ot(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new Ee(((r,s)=>{this.nextCallback=a=>{this.wrapSuccess(e,a).next(r,s)},this.catchCallback=a=>{this.wrapFailure(t,a).next(r,s)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(e){try{const t=e();return t instanceof Ee?t:Ee.resolve(t)}catch(t){return Ee.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction((()=>e(t))):Ee.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction((()=>e(t))):Ee.reject(t)}static resolve(e){return new Ee(((t,r)=>{t(e)}))}static reject(e){return new Ee(((t,r)=>{r(e)}))}static waitFor(e){return new Ee(((t,r)=>{let s=0,a=0,c=!1;e.forEach((u=>{++s,u.next((()=>{++a,c&&a===s&&t()}),(h=>r(h)))})),c=!0,a===s&&t()}))}static or(e){let t=Ee.resolve(!1);for(const r of e)t=t.next((s=>s?Ee.resolve(s):r()));return t}static forEach(e,t){const r=[];return e.forEach(((s,a)=>{r.push(t.call(this,s,a))})),this.waitFor(r)}static mapArray(e,t){return new Ee(((r,s)=>{const a=e.length,c=new Array(a);let u=0;for(let h=0;h<a;h++){const f=h;t(e[f]).next((p=>{c[f]=p,++u,u===a&&r(c)}),(p=>s(p)))}}))}static doWhile(e,t){return new Ee(((r,s)=>{const a=()=>{e()===!0?t().next((()=>{a()}),s):r()};a()}))}}function sF(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Vu(n){return n.name==="IndexedDbTransactionError"}/**
2962 * @license
2963 * Copyright 2020 Google LLC
2964 *
2965 * Licensed under the Apache License, Version 2.0 (the "License");
2966 * you may not use this file except in compliance with the License.
2967 * You may obtain a copy of the License at
2968 *
2969 *   http://www.apache.org/licenses/LICENSE-2.0
2970 *
2971 * Unless required by applicable law or agreed to in writing, softw
2971are
2972 * distributed under the License is distributed on an "AS IS" BASIS,
2973 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2974 * See the License for the specific language governing permissions and
2975 * limitations under the License.
2976 */const tT="LruGarbageCollector",iF=1048576;function nT([n,e],[t,r]){const s=Lt(n,t);return s===0?Lt(e,r):s}class aF{constructor(e){this.Jn=e,this.buffer=new yr(nT),this.Yn=0}Zn(){return++this.Yn}Xn(e){const t=[e,this.Zn()];if(this.buffer.size<this.Jn)this.buffer=this.buffer.add(t);else{const r=this.buffer.last();nT(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}}class oF{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.er=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.tr(6e4)}stop(){this.er&&(this.er.cancel(),this.er=null)}get started(){return this.er!==null}tr(e){Ue(tT,`Garbage collection scheduled in ${e}ms`),this.er=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this.er=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Vu(t)?Ue(tT,"Ignoring IndexedDB error during garbage collection: ",t):await Uu(t)}await this.tr(3e5)}))}}class lF{constructor(e,t){this.nr=e,this.params=t}calculateTargetCount(e,t){return this.nr.rr(e).next((r=>Math.floor(t/100*r)))}nthSequenceNumber(e,t){if(t===0)return Ee.resolve(hp.yn);const r=new aF(t);return this.nr.forEachTarget(e,(s=>r.Xn(s.sequenceNumber))).next((()=>this.nr.ir(e,(s=>r.Xn(s))))).next((()=>r.maxValue))}removeTargets(e,t,r){return this.nr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.nr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(Ue("LruGarbageCollector","Garbage collection skipped; disabled"),Ee.resolve(eT)):this.getCacheSize(e).next((r=>r<this.params.cacheSizeCollectionThreshold?(Ue("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),eT):this.sr(e,t)))}getCacheSize(e){return this.nr.getCacheSize(e)}sr(e,t){let r,s,a,c,u,h,f;const p=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((y=>(y>this.params.maximumSequenceNumbersToCollect?(Ue("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${y}`),s=this.params.maximumSequenceNumbersToCollect):s=y,c=Date.now(),this.nthSequenceNumber(e,s)))).next((y=>(r=y,u=Date.now(),this.removeTargets(e,r,t)))).next((y=>(a=y,h=Date.now(),this.removeOrphanedDocuments(e,r)))).next((y=>(f=Date.now(),Bu()<=Ut.DEBUG&&Ue("LruGarbageCollector",`LRU Garbage Collection
2977	Counted targets in ${c-p}ms
2978	Determined least recently used ${s} in `+(u-c)+`ms
2979	Removed ${a} targets in `+(h-u)+`ms
2980	Removed ${y} documents in `+(f-h)+`ms
2981Total Duration: ${f-p}ms`),Ee.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:a,documentsRemoved:y}))))}}function cF(n,e){return new lF(n,e)}/**
2982 * @license
2983 * Copyright 2020 Google LLC
2984 *
2985 * Licensed under the Apache License, Version 2.0 (the "License");
2986 * you may not use this file except in compliance with the License.
2987 * You may obtain a copy of the License at
2988 *
2989 *   http://www.apache.org/licenses/LICENSE-2.0
2990 *
2991 * Unless required by applicable law or agreed to in writing, software
2992 * distributed under the License is distributed on an "AS IS" BASIS,
2993 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2994 * See the License for the specific language governing permissions and
2995 * limitations under the License.
2996 */const i1="firestore.googleapis.com",rT=!0;class sT{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new Fe(ve.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=i1,this.ssl=rT}else this.host=e.host,this.ssl=e.ssl??rT;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e._customHeaders&&(this._customHeaders={...e._customHeaders}),e.cacheSizeBytes===void 0)this.cacheSizeBytes=s1;
2996else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<iF)throw new Fe(ve.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}if(AO("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=t1(e.experimentalLongPollingOptions??{}),(function(r){if(r.timeoutSeconds!==void 0){if(isNaN(r.timeoutSeconds))throw new Fe(ve.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (must not be NaN)`);if(r.timeoutSeconds<5)throw new Fe(ve.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (minimum allowed value is 5)`);if(r.timeoutSeconds>30)throw new Fe(ve.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (maximum allowed value is 30)`)}})(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams,e.grpcFlowControlWindow!==void 0){if(typeof e.grpcFlowControlWindow!="number"||e.grpcFlowControlWindow<=0||e.grpcFlowControlWindow>2147483647||!Number.isInteger(e.grpcFlowControlWindow))throw new Fe(ve.INVALID_ARGUMENT,"grpcFlowControlWindow must be a positive integer and cannot exceed 2147483647");this.grpcFlowControlWindow=e.grpcFlowControlWindow}}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&(function(r,s){return r.timeoutSeconds===s.timeoutSeconds})(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams&&this.grpcFlowControlWindow===e.grpcFlowControlWindow&&(function(r,s){if(r===s)return!0;if(!r||!s)return!1;const a=Object.keys(r),c=Object.keys(s);if(a.length!==c.length)return!1;for(const u of a)if(r[u]!==s[u])return!1;return!0})(this._customHeaders,e._customHeaders)}}let fp=class{constructor(e,t,r,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new sT({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new Fe(ve.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(e){if(this._settingsFrozen)throw new Fe(ve.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 sT(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=(function(r){if(!r)return new O5;switch(r.type){case"firstParty":return new G5(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new Fe(ve.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(e.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(t){const r=Z_.get(t);r&&(Ue(eF,"Removing Datastore"),Z_.delete(t),r.terminate())})(this),Promise.resolve()}};function uF(n,e,t,r={}){var f;n=mi(n,fp);const s=vc(e),a=n._getSettings(),c={...a,emulatorOptions:n._getEmulatorOptions()},u=`${e}:${t}`;s&&lx(`https://${u}`),a.host!==i1&&a.host!==u&&Ri("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const h={...a,host:u,ssl:s,emulatorOptions:r};if(!hc(h,c)&&(n._setSettings(h),r.mockUserToken)){let p,y;if(typeof r.mockUserToken=="string")p=r.mockUserToken,y=Wr.MOCK_USER;else{p=hS(r.mockUserToken,(f=n._app)==null?void 0:f.options.projectId);const b=r.mockUserToken.sub||r.mockUserToken.user_id;if(!b)throw new Fe(ve.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");y=new Wr(b)}n._authCredentials=new F5(new e1(p,y))}}/**
2997 * @license
2998 * Copyright 2020 Google LLC
2999 *
3000 * Licensed under the Apache License, Version 2.0 (the "License");
3001 * you may not use this file except in compliance with the License.
3002 * You may obtain a copy of the License at
3003 *
3004 *   http://www.apache.org/licenses/LICENSE-2.0
3005 *
3006 * Unless required by applicable law or agreed to in writing, software
3007 * distributed under the License is distributed on an "AS IS" BASIS,
3008 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3009 * See the License for the specific language governing permissions and
3010 * limitations under the License.
3011 */class ml{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new ml(this.firestore,e,this._query)}}class er{constructor(e,t,r){this.converter=t,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Yo(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new er(this.firestore,e,this._key)}toJSON(){return{type:er._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(Jh(t,er._jsonSchema))return new er(e,r||null,new nt(sn.fromString(t.referencePath)))}}er._jsonSchemaVersion="firestore/documentReference/1.0",er._jsonSchema={type:Br("string",er._jsonSchemaVersion),referencePath:Br("string")};class Yo extends ml{constructor(e,t,r){super(e,t,lp(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new er(this.firestore,null,new nt(e))}withConverter(e){return new Yo(this.firestore,e,this._path)}}function wn(n,e,...t){if(n=En(n),mD("collection","path",e),n instanceof fp){const r=sn.fromString(e,...t);return D_(r),new Yo(n,null,r)}{if(!(n instanceof er||n instanceof Yo))throw new Fe(ve.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(sn.fromString(e,...t));return D_(r),new Yo(n.firestore,null,r)}}function ft(n,e,...t){if(n=En(n),arguments.length===1&&(e=_x.newId()),mD("doc","path",e),n instanceof fp){const r=sn.fromString(e,...t);return S_(r),new er(n,null,new nt(r))}{if(!(n instanceof er||n instanceof Yo))throw new Fe(ve.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(sn.fromString(e,...t));return S_(r),new er(n.firestore,n instanceof Yo?n.converter:null,new nt(r))}}/**
3012 * @license
3013 * Copyright 2017 Google LLC
3014 *
3015 * Licensed under the Apache License, Version 2.0 (the "License");
3016 * you may not use this file except in compliance with the License.
3017 * You may obtain a copy of the License at
3018 *
3019 *   http://www.apache.org/licenses/LICENSE-2.0
3020 *
3021 * Unless required by applicable law or agreed to in writing, software
3022 * distributed under the License is distributed on an "AS IS" BASIS,
3023 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3024 * See the License for the specific language governing permissions and
3025 * limitations under the License.
3026 *//**
3027 * @license
3028 * Copyright 2024 Google LLC
3029 *
3030 * Licensed under the Apache License, Version 2.0 (the "License");
3031 * you may not use this file except in compliance with the License.
3032 * You may obtain a copy of the License at
3033 *
3034 *   http://www.apache.org/licenses/LICENSE-2.0
3035 *
3036 * Unless required by applicable law or agreed to in writing, software
3037 * distributed under the License is distributed on an "AS IS" BASIS,
3038 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3039 * See the License for the specific language governing permissions and
3040 * limitations under the License.
3041 */class Ss{constructor(e){this._values=(e||[]).map((t=>t))}toArray(){return this._values.map((e=>e))}isEqual(e){return(function(r,s){if(r.length!==s.length)return!1;for(let a=0;a<r.length;++a)if(r[a]!==s[a])return!1;return!0})(this._values,e._values)}toJSON(){return{type:Ss._jsonSchemaVersion,vectorValues:this._values}}
vendor: 5,398 bytes, lines 3041-3056
3041static fromJSON(e){if(Jh(e,Ss._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((t=>typeof t=="number")))return new Ss(e.vectorValues);throw new Fe(ve.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Ss._jsonSchemaVersion="firestore/vectorValue/1.0",Ss._jsonSchema={type:Br("string",Ss._jsonSchemaVersion),vectorValues:Br("object")};/**
3042 * @license
3043 * Copyright 2017 Google LLC
3044 *
3045 * Licensed under the Apache License, Version 2.0 (the "License");
3046 * you may not use this file except in compliance with the License.
3047 * You may obtain a copy of the License at
3048 *
3049 *   http://www.apache.org/licenses/LICENSE-2.0
3050 *
3051 * Unless required by applicable law or agreed to in writing, software
3052 * distributed under the License is distributed on an "AS IS" BASIS,
3053 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3054 * See the License for the specific language governing permissions and
3055 * limitations under the License.
3056 */const dF=/^__.*__$/;class hF{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return this.fieldMask!==null?new fl(e,this.data,this.fieldMask,t,this.fieldTransforms):new Kh(e,this.data,t,this.fieldTransforms)}}class a1{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new fl(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function o1(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw ot(40011,{dataSource:n})}}class Mx{constructor(e,t,r,s,a,c){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=s,a===void 0&&this.validatePath(),this.fieldTransforms=a||[],this.fieldMask=c||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new Mx({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){var s;const t=(s=this.path)==null?void 0:s.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePathSegment(e),r}childContextForFieldPath(e){var s;const t=(s=this.path)==null?void 0:s.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePath(),r}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return Tg(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find((t=>e.isPrefixOf(t)))!==void 0||this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))!==void 0}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(e.length===0)throw this.createError("Document fields must not be empty");if(o1(this.dataSource)&&dF.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class fF{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||up(e)}createContext(e,t,r,s=!1){return new Mx({dataSource:e,methodName:t,targetDoc:r,path:Ks.emptyPath(),arrayElement:!1,hasConverter:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function Lx(n){const e=n._freezeSettings(),t=up(n._databaseId);return new fF(n._databaseId,!!e.ignoreUndefinedProperties,t)}function l1(n,e,t,r,s,a={}){const c=n.createContext(a.merge||a.mergeFields?2:0,e,t,s);jx("Data must be an object, but it was:",c,r);const u=c1(r,c);let h,f;if(a.merge)h=new zs(c.fieldMask),f=c.fieldTransforms;else if(a.mergeFields){const p=[];for(const y of a.mergeFields){const b=yc(e,y,t);if(!c.contains(b))throw new Fe(ve.INVALID_ARGUMENT,`Field '${b}' is specified in your field mask but missing from your input data.`);h1(p,b)||p.push(b)}h=new zs(p),f=c.fieldTransforms.filter((y=>h.covers(y.field)))}else h=null,f=c.fieldTransforms;return new hF(new fs(u),h,f)}class mp extends Px{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof mp}}function mF(n,e,t,r){const s=n.createContext(1,e,t);jx("Data must be an object, but it was:",s,r);const a=[],c=fs.empty();hl(r,((h,f)=>{const p=d1(e,h,t);f=En(f);const y=s.childContextForFieldPath(p);if(f instanceof mp)a.push(p);else{const b=il(f,y);b!=null&&(a.push(p),c.set(p,b))}}));const u=new zs(a);return new a1(c,u,s.fieldTransforms)}function gF(n,e,t,r,s,a){const c=n.createContext(1,e,t),u=[yc(e,r,t)],h=[s];if(a.length%2!=0)throw new Fe(ve.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let b=0;b<a.length;b+=2)u.push(yc(e,a[b])),h.push(a[b+1]);const f=[],p=fs.empty();for(let b=u.length-1;b>=0;--b)if(!h1(f,u[b])){const w=u[b];let E=h[b];E=En(E);const N=c.childContextForFieldPath(w);if(E instanceof mp)f.push(w);else{const S=il(E,N);S!=null&&(f.push(w),p.set(w,S))}}const y=new zs(f);return new a1(p,y,c.fieldTransforms)}function pF(n,e,t,r=!1){return il(t,n.createContext(r?4:3,e))}function il(n,e,t){if(u1(n=En(n)))return jx("Unsupported field value:",e,n),c1(n,e);if(n instanceof Px)return(function(s,a){if(!o1(a.dataSource))throw a.createError(`${s._methodName}
3056() can only be used with update() and set()`);if(!a.path)throw a.createError(`${s._methodName}() is not currently supported inside arrays`);const c=s._toFieldTransform(a);c&&a.fieldTransforms.push(c)})(n,e),null;if(n===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),n instanceof Array){if(e.settings.arrayElement&&e.dataSource!==4)throw e.createError("Nested arrays are not supported");return(function(s,a){const c=[];let u=0;for(const h of s){let f=il(h,a.childContextForArray(u));f==null&&(f={nullValue:"NULL_VALUE"}),c.push(f),u++}return{arrayValue:{values:c}}})(n,e)}return(function(s,a,c){if((s=En(s))===null)return{nullValue:"NULL_VALUE"};if(typeof s=="number")return Nx(a.serializer,s);if(typeof s=="boolean")return{booleanValue:s};if(typeof s=="string")return{stringValue:s};if(s instanceof Date){const u=An.fromDate(s);return{timestampValue:Eg(a.serializer,u)}}if(s instanceof An){const u=new An(s.seconds,1e3*Math.floor(s.nanoseconds/1e3));return{timestampValue:Eg(a.serializer,u)}}if(s instanceof ra)return{geoPointValue:{latitude:s.latitude,longitude:s.longitude}};if(s instanceof fi)return{bytesValue:zD(a.serializer,s._byteString)};if(s instanceof er){const u=a.databaseId,h=s.firestore._databaseId;if(!h.isEqual(u))throw a.createError(`Document reference is for database ${h.projectId}/${h.database} but should be for database ${u.projectId}/${u.database}`);return{referenceValue:Rx(s.firestore._databaseId||a.databaseId,s._key.path)}}if(s instanceof Ss)return(function(h,f){const p=h instanceof Ss?h.toArray():h;return{mapValue:{fields:{[CD]:{stringValue:bD},[_h]:{arrayValue:{values:p.map((b=>{if(typeof b!="number")throw f.createError("VectorValues must only contain numeric values.");return sp(f.serializer,b)}))}}}}}})(s,a);if(XD(s))return s._toProto(a.serializer);throw a.createError(`Unsupported field value: ${tp(s)}`)})(n,e)}function c1(n,e){const t={};return fD(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):hl(n,((r,s)=>{const a=il(s,e.childContextForField(r));a!=null&&(t[r]=a)})),{mapValue:{fields:t}}}function u1(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof An||n instanceof ra||n instanceof fi||n instanceof er||n instanceof Px||n instanceof Ss||XD(n))}function jx(n,e,t){if(!u1(t)||!zh(t)){const r=tp(t);throw r==="an object"?e.createError(n+" a custom object"):e.createError(n+" "+r)}}function yc(n,e,t){if((e=En(e))instanceof dp)return e._internalPath;if(typeof e=="string")return d1(n,e);throw Tg("Field path arguments must be of type string or ",n,!1,void 0,t)}const BF=new RegExp("[~\\*/\\[\\]]");function d1(n,e,t){if(e.search(BF)>=0)throw Tg(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new dp(...e.split("."))._internalPath}catch{throw Tg(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function Tg(n,e,t,r,s){const a=r&&!r.isEmpty(),c=s!==void 0;let u=`Function ${e}() called with invalid data`;t&&(u+=" (via `toFirestore()`)"),u+=". ";let h="";return(a||c)&&(h+=" (found",a&&(h+=` in field ${r}`),c&&(h+=` in document ${s}`),h+=")"),new Fe(ve.INVALID_ARGUMENT,u+n+h)}function h1(n,e){return n.some((t=>t.isEqual(e)))}function f1(n){return typeof n._readUserData=="function"}/**
3057 * @license
3058 * Copyright 2025 Google LLC
3059 *
3060 * Licensed under the Apache License, Version 2.0 (the "License");
3061 * you may not use this file except in compliance with the License.
3062 * You may obtain a copy of the License at
3063 *
3064 *   http://www.apache.org/licenses/LICENSE-2.0
3065 *
3066 * Unless required by applicable law or agreed to in writing, software
3067 * distributed under the License is distributed on an "AS IS" BASIS,
3068 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3069 * See the License for the specific language governing permissions and
3070 * limitations under the License.
3071 */class ts{constructor(e){this.optionDefinitions=e}_getKnownOptions(e,t){const r=fs.empty();for(const s in this.optionDefinitions)if(this.optionDefinitions.hasOwnProperty(s)){const a=this.optionDefinitions[s];if(s in e){const c=e[s];let u;a.nestedOptions&&zh(c)?u={mapValue:{fields:new ts(a.nestedOptions).getOptionsProto(t,c)}}:c&&(u=il(c,t)??void 0),u&&r.set(Ks.fromServerFormat(a.serverName),u)}}return r}getOptionsProto(e,t,r){const s=this._getKnownOptions(t,e);if(r){const a=new Map(DO(r,((c,u)=>[Ks.fromServerFormat(u),c!==void 0?il(c,e):null])));s.setAll(a)}return s.value.mapValue.fields??{}}}/**
3072 * @license
3073 * Copyright 2024 Google LLC
3074 *
3075 * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 12,053 bytes, lines 3076-3101
3076 * you may not use this file except in compliance with the License.
3077 * You may obtain a copy of the License at
3078 *
3079 *   http://www.apache.org/licenses/LICENSE-2.0
3080 *
3081 * Unless required by applicable law or agreed to in writing, software
3082 * distributed under the License is distributed on an "AS IS" BASIS,
3083 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3084 * See the License for the specific language governing permissions and
3085 * limitations under the License.
3086 */function yF(n){return typeof n=="object"&&n!==null&&!!("nullValue"in n&&(n.nullValue===null||n.nullValue==="NULL_VALUE")||"booleanValue"in n&&(n.booleanValue===null||typeof n.booleanValue=="boolean")||"integerValue"in n&&(n.integerValue===null||typeof n.integerValue=="number"||typeof n.integerValue=="string")||"doubleValue"in n&&(n.doubleValue===null||typeof n.doubleValue=="number")||"timestampValue"in n&&(n.timestampValue===null||(function(t){return typeof t=="object"&&t!==null&&"seconds"in t&&(t.seconds===null||typeof t.seconds=="number"||typeof t.seconds=="string")&&"nanos"in t&&(t.nanos===null||typeof t.nanos=="number")})(n.timestampValue))||"stringValue"in n&&(n.stringValue===null||typeof n.stringValue=="string")||"bytesValue"in n&&(n.bytesValue===null||n.bytesValue instanceof Uint8Array)||"referenceValue"in n&&(n.referenceValue===null||typeof n.referenceValue=="string")||"geoPointValue"in n&&(n.geoPointValue===null||(function(t){return typeof t=="object"&&t!==null&&"latitude"in t&&(t.latitude===null||typeof t.latitude=="number")&&"longitude"in t&&(t.longitude===null||typeof t.longitude=="number")})(n.geoPointValue))||"arrayValue"in n&&(n.arrayValue===null||(function(t){return typeof t=="object"&&t!==null&&!(!("values"in t)||t.values!==null&&!Array.isArray(t.values))})(n.arrayValue))||"mapValue"in n&&(n.mapValue===null||(function(t){return typeof t=="object"&&t!==null&&!(!("fields"in t)||t.fields!==null&&!zh(t.fields))})(n.mapValue))||"fieldReferenceValue"in n&&(n.fieldReferenceValue===null||typeof n.fieldReferenceValue=="string")||"functionValue"in n&&(n.functionValue===null||(function(t){return typeof t=="object"&&t!==null&&!(!("name"in t)||t.name!==null&&typeof t.name!="string"||!("args"in t)||t.args!==null&&!Array.isArray(t.args))})(n.functionValue))||"pipelineValue"in n&&(n.pipelineValue===null||(function(t){return typeof t=="object"&&t!==null&&!(!("stages"in t)||t.stages!==null&&!Array.isArray(t.stages))})(n.pipelineValue)))}function xF(n){return new Ss(n)}/**
3087 * @license
3088 * Copyright 2024 Google LLC
3089 *
3090 * Licensed under the Apache License, Version 2.0 (the "License");
3091 * you may not use this file except in compliance with the License.
3092 * You may obtain a copy of the License at
3093 *
3094 *   http://www.apache.org/licenses/LICENSE-2.0
3095 *
3096 * Unless required by applicable law or agreed to in writing, software
3097 * distributed under the License is distributed on an "AS IS" BASIS,
3098 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3099 * See the License for the specific language governing permissions and
3100 * limitations under the License.
3101 */function Pe(n){let e;return n instanceof _c?n:(e=zh(n)?EF(n):n instanceof Array?_F(n):m1(n,void 0),e)}function YB(n){if(n instanceof _c)return n;if(n instanceof Ss)return Ih(n);if(Array.isArray(n))return Ih(xF(n));throw new Error("Unsupported value: "+typeof n)}function Ox(n){return LO(n)?Xm(n):Pe(n)}class _c{constructor(){this._protoValueType="ProtoValue"}add(e){return new Ce("add",[this,Pe(e)],"add")}asBoolean(){if(this instanceof al)return this;if(this instanceof Hu)return new p1(this);if(this instanceof Gu)return new wF(this);if(this instanceof Ce)return new g1(this);throw new Fe("invalid-argument",`Conversion of type ${typeof this} to BooleanExpression not supported.`)}subtract(e){return new Ce("subtract",[this,Pe(e)],"subtract")}multiply(e){return new Ce("multiply",[this,Pe(e)],"multiply")}divide(e){return new Ce("divide",[this,Pe(e)],"divide")}mod(e){return new Ce("mod",[this,Pe(e)],"mod")}equal(e){return new Ce("equal",[this,Pe(e)],"equal").asBoolean()}notEqual(e){return new Ce("not_equal",[this,Pe(e)],"notEqual").asBoolean()}lessThan(e){return new Ce("less_than",[this,Pe(e)],"lessThan").asBoolean()}lessThanOrEqual(e){return new Ce("less_than_or_equal",[this,Pe(e)],"lessThanOrEqual").asBoolean()}greaterThan(e){return new Ce("greater_than",[this,Pe(e)],"greaterThan").asBoolean()}greaterThanOrEqual(e){return new Ce("greater_than_or_equal",[this,Pe(e)],"greaterThanOrEqual").asBoolean()}arrayConcat(e,...t){const r=[e,...t].map((s=>Pe(s)));return new Ce("array_concat",[this,...r],"arrayConcat")}arrayContains(e){return new Ce("array_contains",[this,Pe(e)],"arrayContains").asBoolean()}arrayContainsAll(e){const t=Array.isArray(e)?new Xd(e.map(Pe),"arrayContainsAll"):e;return new Ce("array_contains_all",[this,t],"arrayContainsAll").asBoolean()}arrayContainsAny(e){const t=Array.isArray(e)?new Xd(e.map(Pe),"arrayContainsAny"):e;return new Ce("array_contains_any",[this,t],"arrayContainsAny").asBoolean()}arrayReverse(){return new Ce("array_reverse",[this])}arrayLength(){return new Ce("array_length",[this],"arrayLength")}equalAny(e){const t=Array.isArray(e)?new Xd(e.map(Pe),"equalAny"):e;return new Ce("equal_any",[this,t],"equalAny").asBoolean()}notEqualAny(e){const t=Array.isArray(e)?new Xd(e.map(Pe),"notEqualAny"):e;return new Ce("not_equal_any",[this,t],"notEqualAny").asBoolean()}exists(){return new Ce("exists",[this],"exists").asBoolean()}charLength(){return new Ce("char_length",[this],"charLength")}like(e){return new Ce("like",[this,Pe(e)],"like").asBoolean()}regexContains(e){return new Ce("regex_contains",[this,Pe(e)],"regexContains").asBoolean()}regexFind(e){return new Ce("regex_find",[this,Pe(e)],"regexFind")}regexFindAll(e){return new Ce("regex_find_all",[this,Pe(e)],"regexFindAll")}regexMatch(e){return new Ce("regex_match",[this,Pe(e)],"regexMatch").asBoolean()}stringContains(e){return new Ce("string_contains",[this,Pe(e)],"stringContains").asBoolean()}startsWith(e){return new Ce("starts_with",[this,Pe(e)],"startsWith").asBoolean()}endsWith(e){return new Ce("ends_with",[this,Pe(e)],"endsWith").asBoolean()}toLower(){return new Ce("to_lower",[this],"toLower")}toUpper(){return new Ce("to_upper",[this],"toUpper")}trim(e){const t=[this];return e&&t.push(Pe(e)),new Ce("trim",t,"trim")}ltrim(e){const t=[this];return e&&t.push(Pe(e)),new Ce("ltrim",t,"ltrim")}rtrim(e){const t=[this];return e&&t.push(Pe(e)),new Ce("rtrim",t,"rtrim")}type(){return new Ce("type",[this])}isType(e){return new Ce("is_type",[this,Ih(e)],"isType").asBoolean()}stringConcat(e,...t){const r=[e,...t].map(Pe);return new Ce("string_concat",[this,...r],"stringConcat")}stringIndexOf(e){return new Ce("string_index_of",[this,Pe(e)],"stringIndexOf")}stringRepeat(e){return new Ce("string_repeat",[this,Pe(e)],"stringRepeat")}stringReplaceAll(e,t){return new Ce("string_replace_all",[this,Pe(e),Pe(t)],"stringReplaceAll")}stringReplaceOne(e,t){return new Ce("string_replace_one",[this,Pe(e),Pe(t)],"stringReplaceOne")}concat(e,...t){const r=[e,...t].map(Pe);return new Ce("concat",[this,...r],"concat")}reverse(){return new Ce("reverse",[this],"reverse")}arrayFilter(e,t){return new Ce("array_filter",[this,Pe(e),t],"arrayFilter")}arrayTransform(e,t){return new Ce("array_transform",[this,Pe(e),t],"arrayTransform")}arrayTransformWithIndex(e,t,r){return new Ce("array_transform",[this,Pe(e),Pe(t),r],"arrayTransformWithIndex")}arraySlice(e,t){const r=[this,Pe(e)];return t!==void 0&&r.push(Pe(t)),new Ce("array_slice",r,"arraySlice")}arrayFirst(){return new Ce("array_first",[this],"arrayFirst")}arrayFirstN(e){return new Ce("array_first_n",[this,Pe(e)],"arrayFirstN")}arrayLast(){return new Ce("array_last",[this],"arrayLast")}arrayLastN(e){return new Ce("array_last_n",[this,Pe(e)],"arrayLastN")}arrayMaximum(){return new Ce("maximum",[this],"arrayMaximum")}arrayMaximumN(e){return new Ce("maximum_n",[this,Pe(e)],"arrayMaximumN")}arrayMinimum(){return new Ce("minimum",[this],"arrayMinimum")}arrayMinimumN(e){return new Ce("minimum_n",[this,Pe(e)],"arrayMinimumN")}arrayIndexOf(e){return new Ce("array_index_of",[this,Pe(e),Pe("first")],"arrayIndexOf")}arrayLastIndexOf(e){return new Ce("array_index_of",[this,Pe(e),Pe("last")],"arrayLastIndexOf")}arrayIndexOfAll(e){return new Ce("array_index_of_all",[this,Pe(e)],"arrayIndexOfAll")}byteLength(){return new Ce("byte_length",[this],"byteLength")}ceil(){return new Ce("ceil",[this])}floor(){return new Ce("floor",[this])}abs(){return new Ce("abs",[this])}exp(){return new Ce("exp",[this])}mapGet(e){return new Ce("map_get",[this,Ih(e)],"mapGet")}mapSet(e,t,...r){const s=[this,Pe(e),Pe(t),...r.map(Pe)];return new Ce("map_set",s,"mapSet")}mapKeys(){return new Ce("map_keys",[this],"mapKeys")}mapValues(){return new Ce("map_values",[this],"mapValues")}mapEntries(){return new Ce("map_entries",[this],"mapEntries")}getField(e){return new Ce("get_field",[this,Pe(e)],"get_field")}count(){return Hs._create("count",[this],"count")}sum(){return Hs._create("sum",[this],"sum")}average(){return Hs._create("average",[this],"average")}minimum(){return Hs._create("minimum",[this],"minimum")}maximum(){return Hs._create("maximum",[this],"maximum")}first(){return Hs._create("first",[this],"first")}last(){return Hs._create("last",[this],"last")}arrayAgg(){return Hs._create("array_agg",[this],"arrayAgg")}arrayAggDistinct(){return Hs._create("array_agg_distinct",[this],"arrayAggDistinct")}countDistinct(){return Hs._create("count_distinct",[this],"countDistinct")}logicalMaximum(e,...t){const r=[e,...t];return new Ce("maximum",[this,...r.map(Pe)],"logicalMaximum")}logicalMinimum(e,...t){const r=[e,...t];return new Ce("minimum",[this,...r.map(Pe)],"minimum")}vectorLength(){return new Ce("vector_length",[this],"vectorLength")}cosineDistance(e){return new Ce("cosine_distance",[this,YB(e)],"cosineDistance")}dotProduct(e){return new Ce("dot_product",[this,YB(e)],"dotProduct")}euclideanDistance(e){return new Ce("euclidean_distance",[this,YB(e)],"euclideanDistance")}unixMicrosToTimestamp(){return new Ce("unix_micros_to_timestamp",[this],"unixMicrosToTimestamp")}timestampToUnixMicros(){return new Ce("timestamp_to_unix_micros",[this],"timestampToUnixMicros")}unixMillisToTimestamp(){return new Ce("unix_millis_to_timestamp",[this],"unixMillisToTimestamp")}timestampToUnixMillis(){return new Ce("timestamp_to_unix_millis",[this],"timestampToUnixMillis")}unixSecondsToTimestamp(){return new Ce("unix_seconds_to_timestamp",[this],"unixSecondsToTimestamp")}timestampToUnixSeconds(){return new Ce("timestamp_to_unix_seconds",[this],"timestampToUnixSeconds")}timestampAdd(e,t){return new Ce("timestamp_add",[this,Pe(e),Pe(t)],"timestampAdd")}timestampSubtract(e,t){return new Ce("timestamp_subtract",[this,Pe(e),Pe(t)],"timestampSubtract")}timestampDiff(e,t){return new Ce("timestamp_diff",[this,Ox(e),Pe(t)],"timestampDiff")}timestampExtract(e,t){const r=[this,Pe(e)];return t&&r.push(Pe(t)),new Ce("timestamp_extract",r,"timestampExtract")}documentId(){return new Ce("document_id",[this],"documentId")}parent(){return new Ce("parent",[this],"parent")}substring(e,t){const r=Pe(e);return new Ce("substring",t===void 0?[this,r]:[this,r,Pe(t)],"substring")}arrayGet(e){return new Ce("array_get",[this,Pe(e)],"arrayGet")}isError(){return new Ce("is_error",[this],"isError").asBoolean()}ifError(e){const t=new Ce("if_error",[this,Pe(e)],"ifError");return e instanceof al?t.asBoolean():t}isAbsent(){return new Ce("is_absent",[this],"isAbsent").asBoolean()}mapRemove(e){return new Ce("map_remove",[this,Pe(e)],"mapRemove")}mapMerge(e,...t){const r=Pe(e),s=t.map(Pe);return new Ce("map_merge",[this,r,...s],"mapMerge")}pow(e){return new Ce("pow",[this,Pe(e)])}trunc(e){return e===void 0?new Ce("trunc",[this]):new Ce("trunc",[this,Pe(e)],"trunc")}round(e){return e===void 0?new Ce("round",[this]):new Ce("round",[this,Pe(e)],"round")}collectionId(){return new Ce("collection_id",[this])}length(){return new Ce("length",[this])}ln(){return new Ce("ln",[this])}sqrt(){return new Ce("sqrt",[this])}
vendor: 11,261 bytes, lines 3101-3132
3101stringReverse(){return new Ce("string_reverse",[this])}ifAbsent(e){return new Ce("if_absent",[this,Pe(e)],"ifAbsent")}ifNull(e){return new Ce("if_null",[this,Pe(e)],"ifNull")}coalesce(e,...t){return new Ce("coalesce",[this,Pe(e),...t.map(Pe)],"coalesce")}join(e){return new Ce("join",[this,Pe(e)],"join")}log10(){return new Ce("log10",[this])}arraySum(){return new Ce("sum",[this])}split(e){return new Ce("split",[this,Pe(e)])}timestampTruncate(e,t){const r=[this,Pe(e)];return t&&r.push(Pe(t)),new Ce("timestamp_trunc",r)}ascending(){return TF(this)}descending(){return kF(this)}as(e){return new bF(this,e,"as")}}class Hs{constructor(e,t){this.name=e,this.params=t,this.exprType="AggregateFunction",this._protoValueType="ProtoValue"}static _create(e,t,r){const s=new Hs(e,t);return s._methodName=r,s}as(e){return new CF(this,e,"as")}_toProto(e){return{functionValue:{name:this.name,args:this.params.map((t=>t._toProto(e)))}}}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach((t=>t._readUserData(e)))}}class CF{constructor(e,t,r){this.aggregate=e,this.alias=t,this._methodName=r}_readUserData(e){this.aggregate._readUserData(e)}}class bF{constructor(e,t,r){this.expr=e,this.alias=t,this._methodName=r,this.exprType="AliasedExpression",this.selectable=!0}_readUserData(e){this.expr._readUserData(e)}}class Xd extends _c{constructor(e,t){super(),this.ur=e,this._methodName=t,this.expressionType="ListOfExpressions"}_toProto(e){return{arrayValue:{values:this.ur.map((t=>t._toProto(e)))}}}_readUserData(e){this.ur.forEach((t=>t._readUserData(e)))}}class Gu extends _c{constructor(e,t){super(),this.fieldPath=e,this._methodName=t,this.expressionType="Field",this.selectable=!0}get _fieldPath(){return this.fieldPath}get fieldName(){return this.fieldPath.canonicalString()}get alias(){return this.fieldName}get expr(){return this}geoDistance(e){return new Ce("geo_distance",[this,Pe(e)],"geoDistance")}_toProto(e){return{fieldReferenceValue:this.fieldPath.canonicalString()}}_readUserData(e){}}function Xm(n){return vF(n,"field")}function vF(n,e){return new Gu(typeof n=="string"?Yi===n?j5()._internalPath:yc("field",n):n._internalPath,e)}class Hu extends _c{constructor(e,t){super(),this.value=e,this._methodName=t,this.expressionType="Constant"}static _fromProto(e){const t=new Hu(e,void 0);return t._protoValue=e,t}_toProto(e){return Xe(this._protoValue!==void 0,237),this._protoValue}_getValue(){return this._protoValue}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,yF(this._protoValue)||(this._protoValue=il(this.value,e))}}function Ih(n,e){return m1(n,"constant")}function m1(n,e){const t=new Hu(n,e);return typeof n=="boolean"?new p1(t):t}class Ce extends _c{constructor(e,t,r,s){super(),this.name=e,this.params=t,this.expressionType="Function",this._optionsProto=void 0,r!==void 0&&(this._methodName=r),s!==void 0&&(this._options=s)}get _optionsUtil(){return new ts({})}_toProto(e){const t={functionValue:{name:this.name,args:this.params.map((r=>r._toProto(e)))}};return this._optionsProto&&(t.functionValue.options=this._optionsProto),t}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach((t=>t._readUserData(e))),this._options&&(this._optionsProto=this._optionsUtil.getOptionsProto(e,this._options))}}class al extends _c{get _methodName(){return this._expr._methodName}countIf(){return Hs._create("count_if",[this],"countIf")}not(){return new Ce("not",[this],"not").asBoolean()}conditional(e,t){return new Ce("conditional",[this,e,t],"conditional")}ifError(e){const t=Pe(e),r=new Ce("if_error",[this,t],"ifError");return t instanceof al?r.asBoolean():r}_toProto(e){return this._expr._toProto(e)}_readUserData(e){this._expr._readUserData(e)}}class g1 extends al{constructor(e){super(),this._expr=e,this.expressionType="Function"}}class p1 extends al{constructor(e){super(),this._expr=e,this.expressionType="Constant"}_getValue(){return this._expr._getValue()}}class wF extends al{constructor(e){super(),this._expr=e,this.expressionType="Field"}}function EF(n,e){const t=[];for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const s=n[r];t.push(Ih(r)),t.push(Pe(s))}return new Ce("map",t,"map")}function _F(n){return(function(t,r){return new Ce("array",t.map((s=>Pe(s))),r)})(n,"array")}function TF(n){return new B1(Ox(n),"ascending","ascending")}function kF(n){return new B1(Ox(n),"descending","descending")}class B1{constructor(e,t,r){this.expr=e,this.direction=t,this._methodName=r,this._protoValueType="ProtoValue"}_toProto(e){return{mapValue:{fields:{direction:ZD(this.direction),expression:this.expr._toProto(e)}}}}_readUserData(e){this.expr._readUserData(e)}}/**
3102 * @license
3103 * Copyright 2024 Google LLC
3104 *
3105 * Licensed under the Apache License, Version 2.0 (the "License");
3106 * you may not use this file except in compliance with the License.
3107 * You may obtain a copy of the License at
3108 *
3109 *   http://www.apache.org/licenses/LICENSE-2.0
3110 *
3111 * Unless required by applicable law or agreed to in writing, software
3112 * distributed under the License is distributed on an "AS IS" BASIS,
3113 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3114 * See the License for the specific language governing permissions and
3115 * limitations under the License.
3116 */class Qs{constructor(e){this.optionsProto=void 0,{rawOptions:this.rawOptions,...this.knownOptions}=e}_readUserData(e){this.optionsProto=this._optionsUtil.getOptionsProto(e,this.knownOptions,this.rawOptions)}_toProto(e){return{name:this._name,options:this.optionsProto}}}class y1 extends Qs{get _name(){return"add_fields"}get _optionsUtil(){return new ts({})}constructor(e,t){super(t),this.fields=e}_toProto(e){return{...super._toProto(e),args:[Ah(e,this.fields)]}}_readUserData(e){super._readUserData(e),ol(this.fields,e)}}class x1 extends Qs{get _name(){return"aggregate"}get _optionsUtil(){return new ts({})}constructor(e,t,r){super(r),this.groups=e,this.accumulators=t}_toProto(e){return{...super._toProto(e),args:[Ah(e,this.accumulators),Ah(e,this.groups)]}}_readUserData(e){super._readUserData(e),ol(this.groups,e),ol(this.accumulators,e)}}class C1 extends Qs{get _name(){return"distinct"}get _optionsUtil(){return new ts({})}constructor(e,t){super(t),this.groups=e}_toProto(e){return{...super._toProto(e),args:[Ah(e,this.groups)]}}_readUserData(e){super._readUserData(e),ol(this.groups,e)}}class gp extends Qs{get _name(){return"collection"}get _optionsUtil(){return new ts({forceIndex:{serverName:"force_index"}})}constructor(e,t){super(t),this.Er=e.startsWith("/")?e:"/"+e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:this.Er}]}}_readUserData(e){super._readUserData(e)}}class pp extends Qs{get _name(){return"collection_group"}get _optionsUtil(){return new ts({forceIndex:{serverName:"force_index"}})}constructor(e,t){super(t),this.collectionId=e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:""},{stringValue:this.collectionId}]}}_readUserData(e){super._readUserData(e)}}class Fx extends Qs{get _name(){return"database"}get _optionsUtil(){return new ts({})}_toProto(e){return{...super._toProto(e)}}_readUserData(e){super._readUserData(e)}}class Ux extends Qs{get _name(){return"documents"}get _optionsUtil(){return new ts({})}constructor(e,t){if(super(t),!e||e.length===0)throw new Fe(ve.INVALID_ARGUMENT,"Empty document paths are not allowed in DocumentsSource");const r=e.map((a=>a.startsWith("/")?a:"/"+a)),s=new Set(r);if(s.size!==r.length)throw new Fe(ve.INVALID_ARGUMENT,"Duplicate document paths are not allowed in DocumentsSource");this.hr=r,this.Tr=s}_toProto(e){return{...super._toProto(e),args:this.hr.map((t=>({referenceValue:t})))}}_readUserData(e){super._readUserData(e)}}class Bp extends Qs{get _name(){return"where"}get _optionsUtil(){return new ts({})}constructor(e,t){super(t),this.condition=e}_toProto(e){return{...super._toProto(e),args:[this.condition._toProto(e)]}}_readUserData(e){super._readUserData(e),ol(this.condition,e)}}class xc extends Qs{get _name(){return"limit"}get _optionsUtil(){return new ts({})}constructor(e,t){Xe(!isNaN(e)&&e!==1/0&&e!==-1/0,34860),super(t),this.limit=e}_toProto(e){return{...super._toProto(e),args:[Nx(e,this.limit)]}}}class iT extends Qs{get _name(){return"offset"}get _optionsUtil(){return new ts({})}constructor(e,t){super(t),this.offset=e}_toProto(e){return{...super._toProto(e),args:[Nx(e,this.offset)]}}}class NF extends Qs{get _name(){return"select"}get _optionsUtil(){return new ts({})}constructor(e,t){super(t),this.selections=e}_toProto(e){return{...super._toProto(e),args:[Ah(e,this.selections)]}}_readUserData(e){super._readUserData(e),ol(this.selections,e)}}class ja extends Qs{get _name(){return"sort"}get _optionsUtil(){return new ts({})}constructor(e,t){super(t),this.orderings=e}_toProto(e){return{...super._toProto(e),args:this.orderings.map((t=>t._toProto(e)))}}_readUserData(e){super._readUserData(e),ol(this.orderings,e)}}class Vx extends Qs{get _name(){return"replace_with"}get _optionsUtil(){return new ts({})}constructor(e,t){super(t),this.map=e}_toProto(e){return{...super._toProto(e),args:[this.map._toProto(e),ZD(Vx.Pr)]}}_readUserData(e){super._readUserData(e),ol(this.map,e)}}Vx.Pr="full_replace";function ol(n,e){return f1(n)?n._readUserData(e):Array.isArray(n)?n.forEach((t=>t._readUserData(e))):n instanceof Map?n.forEach((t=>t._readUserData(e))):Object.values(n).forEach((t=>t._readUserData(e))),n}/**
3117 * @license
3118 * Copyright 2026 Google LLC
3119 *
3120 * Licensed under the Apache License, Version 2.0 (the "License");
3121 * you may not use this file except in compliance with the License.
3122 * You may obtain a copy of the License at
3123 *
3124 *   http://www.apache.org/licenses/LICENSE-2.0
3125 *
3126 * Unless required by applicable law or agreed to in writing, software
3127 * distributed under the License is distributed on an "AS IS" BASIS,
3128 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3129 * See the License for the specific language governing permissions and
3130 * limitations under the License.
3131 */class dh{constructor(e,t,r,s){this._db=e,this.userDataReader=t,this._userDataWriter=r,this.stages=s}Ar(e,t){const r=this.userDataReader.createContext(3,e);return f1(t)?t._readUserData(r):Array.isArray(t)?t.forEach((s=>s._readUserData(r))):t.forEach((s=>s._readUserData(r))),t}where(e){const t=this.stages.map((r=>r));return this.Ar("where",e),t.push(new Bp(e,{})),new dh(this._db,this.userDataReader,this._userDataWriter,t)}limit(e){const t=this.stages.map((r=>r));return t.push(new xc(e,{})),new dh(this._db,this.userDataReader,this._userDataWriter,t)}sort(e,...t){const r=this.stages.map((s=>s));return"orderings"in e?r.push(new ja(this.Ar("sort",e.orderings),{})):r.push(new ja(this.Ar("sort",[e,...t]),{})),new dh(this._db,this.userDataReader,this._userDataWriter,r)}Vr(e){return{pipeline:{stages:this.stages.map((t=>t._toProto(e)))}}}}// Copyright 2024 Google LLC* @license
3132class hs{constructor(e,t,r){this.serializer=e,this.stages=t,this.listenOptions=r,this.isCorePipeline=!0}getPipelineCollection(){return yp(this)}getPipelineCollectionGroup(){return Gx(this)}getPipelineCollectionId(){return SF(this)}getPipelineDocuments(){return jy(this)}getPipelineFlavor(){return(function(t){let r="exact";
3132return t.stages.forEach(((s,a)=>{s._name!==C1.name&&s._name!==x1.name||(r="keyless"),s._name===NF.name&&r==="exact"&&(r="augmented"),s._name===y1.name&&a<t.stages.length-1&&r==="exact"&&(r="augmented")})),r})(this)}getPipelineSourceType(){return Qo(this)}}function Qo(n){const e=n.stages[0];return e instanceof gp||e instanceof pp||e instanceof Fx||e instanceof Ux?e._name:"unknown"}function yp(n){if(Qo(n)==="collection")return n.stages[0].Er}function Gx(n){if(Qo(n)==="collection_group")return n.stages[0].collectionId}function SF(n){switch(Qo(n)){case"collection":return sn.fromString(yp(n)).lastSegment();case"collection_group":return Gx(n);default:return}}function jy(n){if(Qo(n)==="documents")return n.stages[0].hr}class se{constructor(e,t){this.type=e,this.value=t}static dr(){return new se("ERROR",void 0)}static mr(){return new se("UNSET",void 0)}static pr(){return new se("NULL",Ru)}static newValue(e){return Js(e)?new se("NULL",Ru):(function(r){return!!r&&"booleanValue"in r})(e)?new se("BOOLEAN",e):Qi(e)?new se("INT",e):nc(e)?new se("DOUBLE",e):(function(r){return!!r&&"timestampValue"in r&&!!r.timestampValue})(e)?new se("TIMESTAMP",e):(function(r){return!!r&&"stringValue"in r})(e)?new se("STRING",e):(function(r){return!!r&&"bytesValue"in r})(e)?new se("BYTES",e):e.referenceValue?new se("REFERENCE",e):e.geoPointValue?new se("GEO_POINT",e):Mu(e)?new se("ARRAY",e):pg(e)?new se("VECTOR",e):sc(e)?new se("MAP",e):new se("ERROR",void 0)}gr(){return this.type==="ERROR"||this.type==="UNSET"}yr(){return this.type==="NULL"}}function hh(n){if(!n.gr())return n.value}function b1(n){return n instanceof al?n._expr:n}function ut(n){if((n=b1(n))instanceof Gu)return new DF(n);if(n instanceof Hu)return new AF(n);if(n instanceof Xd)return new IF(n);if(n instanceof Ce){if(n.name==="add")return new MF(n);if(n.name==="subtract")return new LF(n);if(n.name==="multiply")return new jF(n);if(n.name==="divide")return new OF(n);if(n.name==="mod")return new FF(n);if(n.name==="and")return new UF(n);if(n.name==="equal")return new XF(n);if(n.name==="not_equal")return new ZF(n);if(n.name==="less_than")return new e3(n);if(n.name==="less_than_or_equal")return new t3(n);if(n.name==="greater_than")return new n3(n);if(n.name==="greater_than_or_equal")return new r3(n);if(n.name==="array_concat")return new s3(n);if(n.name==="array_reverse")return new i3(n);if(n.name==="array_contains")return new a3(n);if(n.name==="array_contains_all")return new o3(n);if(n.name==="array_contains_any")return new l3(n);if(n.name==="array_length")return new c3(n);if(n.name==="array_element")return new u3(n);if(n.name==="equal_any")return new v1(n);if(n.name==="not_equal_any")return new GF(n);if(n.name==="is_nan")return new HF(n);if(n.name==="is_not_nan")return new qF(n);if(n.name==="is_null")return new zF(n);if(n.name==="is_not_null")return new JF(n);if(n.name==="is_error")return new $F(n);if(n.name==="exists")return new KF(n);if(n.name==="not")return new xp(n);if(n.name==="or")return new VF(n);if(n.name==="xor")return new Hx(n);if(n.name==="conditional")return new YF(n);if(n.name==="maximum")return new QF(n);if(n.name==="minimum")return new WF(n);if(n.name==="reverse")return new d3(n);if(n.name==="replace_first")return new h3(n);if(n.name==="replace_all")return new f3(n);if(n.name==="char_length")return new m3(n);if(n.name==="byte_length")return new g3(n);if(n.name==="like")return new p3(n);if(n.name==="regex_contains")return new B3(n);if(n.name==="regex_match")return new y3(n);if(n.name==="string_contains")return new x3(n);if(n.name==="starts_with")return new C3(n);if(n.name==="ends_with")return new b3(n);if(n.name==="to_lower")return new v3(n);if(n.name==="to_upper")return new w3(n);if(n.name==="trim")return new E3(n);if(n.name==="string_concat")return new _3(n);if(n.name==="map_get")return new T3(n);if(n.name==="cosine_distance")return new k3(n);if(n.name==="dot_product")return new N3(n);if(n.name==="euclidean_distance")return new S3(n);if(n.name==="vector_length")return new D3(n);if(n.name==="unix_micros_to_timestamp")return new M3(n);if(n.name==="timestamp_to_unix_micros")return new O3(n);if(n.name==="unix_millis_to_timestamp")return new L3(n);if(n.name==="timestamp_to_unix_millis")return new F3(n);if(n.name==="unix_seconds_to_timestamp")return new j3(n);if(n.name==="timestamp_to_unix_seconds")return new U3(n);if(n.name==="timestamp_add")return new V3(n);if(n.name==="timestamp_subtract")return new G3(n)}throw new Error(`Unknown Expr : ${n}`)}class DF{constructor(e){this.expr=e}evaluate(e,t){if(this.expr.fieldName===Yi)return se.newValue({referenceValue:_g(e.serializer,t.key)});if(this.expr.fieldName==="__update_time__")return se.newValue({timestampValue:Wm(e.serializer,t.version)});if(this.expr.fieldName==="__create_time__")return se.newValue({timestampValue:Wm(e.serializer,t.createTime)});const r=t.data.field(this.expr._fieldPath);return r?np(r)?se.newValue((function(a,c){if(a.serverTimestampBehavior==="estimate")return{timestampValue:Wm(a.serializer,pt.fromTimestamp(Iu(c)))};if(a.serverTimestampBehavior==="previous"){const u=$h(c);if(u)return u}return{nullValue:"NULL_VALUE"}})(e,r)):se.newValue(r):se.mr()}}class AF{constructor(e){this.expr=e}evaluate(e,t){return se.newValue(this.expr._getValue())}}class IF{constructor(e){this.expr=e}evaluate(e,t){const r=this.expr.ur.map((s=>ut(s).evaluate(e,t)));return r.some((s=>s.gr()))?se.dr():se.newValue({arrayValue:{values:r.map((s=>s.value))}})}}function zr(n){return nc(n)?Number(n.doubleValue):Number(n.integerValue)}function sa(n){return BigInt(n.integerValue)}const RF=BigInt("0x7fffffffffffffff"),PF=-BigInt("0x8000000000000000");class Xh{constructor(e){this.expr=e}evaluate(e,t){Xe(this.expr.params.length>=2,24778);const r=ut(this.expr.params[0]).evaluate(e,t),s=ut(this.expr.params[1]).evaluate(e,t);let a=this.wr(r,s);for(const c of this.expr.params.slice(2)){const u=ut(c).evaluate(e,t);a=this.wr(a,u)}return a}wr(e,t){if(e.gr()||t.gr())return se.dr();if(e.yr()||t.yr())return se.pr();const r=e.value,s=t.value;if(!nc(r)&&!Qi(r)||!nc(s)&&!Qi(s))return se.dr();if(nc(r)||nc(s)){const a=this.br(r,s);return a?se.newValue(a):se.dr()}if(Qi(r)&&Qi(s)){const a=this.Sr(r,s);return a===void 0?se.dr():typeof a=="number"?se.newValue({doubleValue:a}):a<PF||a>RF?se.dr():se.newValue({integerValue:`${a}`})}return se.dr()}}function Ja(n,e){return Cr(n)!==Cr(e)?"TYPE_MISMATCH":Is(n)||Is(e)?"NOT_EQ":Js(n)&&Js(e)?"EQ":Js(n)||Js(e)?"NULL":Mu(n)&&Mu(e)?(function(r,s){var c,u,h;if(((c=r.values)==null?void 0:c.length)!==((u=s.values)==null?void 0:u.length))return"NOT_EQ";let a=!1;for(let f=0;f<(((h=r.values)==null?void 0:h.length)??0);f++){const p=r.values[f],y=s.values[f];switch(Ja(p,y)){case"EQ":break;case"NOT_EQ":case"TYPE_MISMATCH":return"NOT_EQ";case"NULL":a=!0;break;default:ot(44609,{vr:p,Dr:y})}}return a?"NULL":"EQ"})(n.arrayValue,e.arrayValue):pg(n)&&pg(e)||sc(n)&&sc(e)?(function(r,s){const a=r.fields||{},c=s.fields||{};if(mg(a)!==mg(c))return"NOT_EQ";let u=!1;for(const h in a)if(a.hasOwnProperty(h)){if(c[h]===void 0)return"NOT_EQ";switch(Ja(a[h],c[h])){case"NOT_EQ":case"TYPE_MISMATCH":return"NOT_EQ";case"NULL":u=!0}}return u?"NULL":"EQ"})(n.mapValue,e.mapValue):(function(r,s){return pi(r,s,{o:!1,t:!0,i:!0})})(n,e)?"EQ":"NOT_EQ"}class MF extends Xh{Sr(e,t){return sa(e)+sa(t)}br(e,t){return{doubleValue:zr(e)+zr(t)}}}class LF extends Xh{constructor(e){super(e),this.expr=e}Sr(e,t){return sa(e)-sa(t)}br(e,t){return{doubleValue:zr(e)-zr(t)}}}class jF extends Xh{constructor(e){super(e),this.expr=e}Sr(e,t){return sa(e)*sa(t)}br(e,t){return{doubleValue:zr(e)*zr(t)}}}class OF extends Xh{constructor(e){super(e),this.expr=e}Sr(e,t){const r=sa(t);if(r!==BigInt(0))return sa(e)/r}br(e,t){const r=zr(t);return r===0?{doubleValue:Eh(r)?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY}:{doubleValue:zr(e)/r}}}class FF extends Xh{constructor(e){super(e),this.expr=e}Sr(e,t){const r=sa(t);if(r!==BigInt(0))return sa(e)%r}br(e,t){const r=zr(t);if(r!==0)return{doubleValue:zr(e)%r}}}class UF{constructor(e){this.expr=e}evaluate(e,t){var a;let r=!1,s=!1;for(const c of this.expr.params){const u=ut(c).evaluate(e,t);switch(u.type){case"BOOLEAN":if(!((a=u.value)!=null&&a.booleanValue))return se.newValue(Rr);break;case"NULL":s=!0;break;default:r=!0}}
3132return r?se.dr():s?se.pr():se.newValue(Ds)}}class xp{constructor(e){this.expr=e}evaluate(e,t){var s;Xe(this.expr.params.length===1,9634);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"BOOLEAN":return se.newValue({booleanValue:!((s=r.value)!=null&&s.booleanValue)});case"NULL":return se.pr();default:return se.dr()}}}class VF{constructor(e){this.expr=e}evaluate(e,t){var a;let r=!1,s=!1;for(const c of this.expr.params){const u=ut(c).evaluate(e,t);switch(u.type){case"BOOLEAN":if((a=u.value)!=null&&a.booleanValue)return se.newValue(Ds);break;case"NULL":s=!0;break;default:r=!0}}return r?se.dr():s?se.pr():se.newValue(Rr)}}class Hx{constructor(e){this.expr=e}evaluate(e,t){var a;let r=!1,s=!1;for(const c of this.expr.params){const u=ut(c).evaluate(e,t);switch(u.type){case"BOOLEAN":r=Hx.xor(r,!!((a=u.value)!=null&&a.booleanValue));break;case"NULL":s=!0;break;default:return se.dr()}}return s?se.pr():se.newValue({booleanValue:r})}static xor(e,t){return(e||t)&&!(e&&t)}}class v1{constructor(e){this.expr=e}evaluate(e,t){var c,u;Xe(this.expr.params.length===2,55094);let r=!1;const s=ut(this.expr.params[0]).evaluate(e,t);switch(s.type){case"NULL":r=!0;break;case"ERROR":case"UNSET":return se.dr()}const a=ut(this.expr.params[1]).evaluate(e,t);switch(a.type){case"ARRAY":break;case"NULL":r=!0;break;default:return se.dr()}if(r)return se.pr();for(const h of((u=(c=a.value)==null?void 0:c.arrayValue)==null?void 0:u.values)??[])switch(Js(s.value)&&Js(h)?"EQ":Ja(s.value,h)){case"EQ":return se.newValue(Ds);case"NOT_EQ":case"TYPE_MISMATCH":break;case"NULL":r=!0;break;default:ot(44608,{value:s.value,candidate:h})}return r?se.pr():se.newValue(Rr)}}class GF{constructor(e){this.expr=e}evaluate(e,t){return new xp(new Ce("not",[new Ce("equal_any",this.expr.params)])).evaluate(e,t)}}class HF{constructor(e){this.expr=e}evaluate(e,t){Xe(this.expr.params.length===1,23322);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"INT":return se.newValue(Rr);case"DOUBLE":return se.newValue({booleanValue:isNaN(zr(r.value))});case"NULL":return se.pr();default:return se.dr()}}}class qF{constructor(e){this.expr=e}evaluate(e,t){return Xe(this.expr.params.length===1,50406),new xp(new Ce("not",[new Ce("is_nan",this.expr.params)])).evaluate(e,t)}}class zF{constructor(e){this.expr=e}evaluate(e,t){switch(Xe(this.expr.params.length===1,23123),ut(this.expr.params[0]).evaluate(e,t).type){case"NULL":return se.newValue(Ds);case"UNSET":case"ERROR":return se.dr();default:return se.newValue(Rr)}}}class JF{constructor(e){this.expr=e}evaluate(e,t){return Xe(this.expr.params.length===1,23167),new xp(new Ce("not",[new Ce("is_null",this.expr.params)])).evaluate(e,t)}}class $F{constructor(e){this.expr=e}evaluate(e,t){return Xe(this.expr.params.length===1,5228),ut(this.expr.params[0]).evaluate(e,t).type==="ERROR"?se.newValue(Ds):se.newValue(Rr)}}class KF{constructor(e){this.expr=e}evaluate(e,t){switch(Xe(this.expr.params.length===1,6877),ut(this.expr.params[0]).evaluate(e,t).type){case"ERROR":return se.dr();case"UNSET":return se.newValue(Rr);default:return se.newValue(Ds)}}}class YF{constructor(e){this.expr=e}evaluate(e,t){var s;Xe(this.expr.params.length===3,11706);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"BOOLEAN":return(s=r.value)!=null&&s.booleanValue?ut(this.expr.params[1]).evaluate(e,t):ut(this.expr.params[2]).evaluate(e,t);case"NULL":return ut(this.expr.params[2]).evaluate(e,t);default:return se.dr()}}}class QF{constructor(e){this.expr=e}evaluate(e,t){const r=this.expr.params.map((a=>ut(a).evaluate(e,t)));let s;for(const a of r)switch(a.type){case"ERROR":case"UNSET":case"NULL":continue;default:s=s===void 0||As(a.value,s.value)>0?a:s}return s===void 0?se.pr():s}}class WF{constructor(e){this.expr=e}evaluate(e,t){const r=this.expr.params.map((a=>ut(a).evaluate(e,t)));let s;for(const a of r)switch(a.type){case"ERROR":case"UNSET":case"NULL":continue;default:s=s===void 0||As(a.value,s.value)<0?a:s}return s===void 0?se.pr():s}}class qu{constructor(e){this.expr=e}evaluate(e,t){Xe(this.expr.params.length===2,31033,`${this.expr.name}() function should have exactly 2 params`);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"ERROR":case"UNSET":return se.dr()}const s=ut(this.expr.params[1]).evaluate(e,t);switch(s.type){case"ERROR":case"UNSET":return se.dr()}return this.Cr(r,s)}}class XF extends qu{constructor(e){super(e),this.expr=e}Cr(e,t){if(e.yr()&&t.yr())return se.newValue(Ds);if(e.yr()||t.yr()||Is(e.value)||Is(t.value)||Cr(e.value)!==Cr(t.value))return se.newValue(Rr);switch(Ja(e.value,t.value)){case"EQ":return se.newValue(Ds);case"NOT_EQ":return se.newValue(Rr);case"NULL":return se.pr();default:ot(44615,{left:e,right:t})}}}class ZF extends qu{constructor(e){super(e),this.expr=e}Cr(e,t){switch(Ja(e.value,t.value)){case"EQ":return se.newValue(Rr);case"NOT_EQ":case"TYPE_MISMATCH":return se.newValue(Ds);case"NULL":return se.pr();default:ot(44614,{left:e,right:t})}}}class e3 extends qu{constructor(e){super(e),this.expr=e}Cr(e,t){return Cr(e.value)!==Cr(t.value)||Is(e.value)||Is(t.value)?se.newValue(Rr):se.newValue({booleanValue:As(e.value,t.value)<0})}}class t3 extends qu{constructor(e){super(e),this.expr=e}Cr(e,t){return Cr(e.value)!==Cr(t.value)||Is(e.value)||Is(t.value)?se.newValue(Rr):Ja(e.value,t.value)==="EQ"?se.newValue(Ds):se.newValue({booleanValue:As(e.value,t.value)<0})}}class n3 extends qu{constructor(e){super(e),this.expr=e}Cr(e,t){return Cr(e.value)!==Cr(t.value)||Is(e.value)||Is(t.value)?se.newValue(Rr):se.newValue({booleanValue:As(e.value,t.value)>0})}}class r3 extends qu{constructor(e){super(e),this.expr=e}Cr(e,t){return Cr(e.value)!==Cr(t.value)||Is(e.value)||Is(t.value)?se.newValue(Rr):Ja(e.value,t.value)==="EQ"?se.newValue(Ds):se.newValue({booleanValue:As(e.value,t.value)>0})}}class s3{constructor(e){this.expr=e}evaluate(e,t){throw new Error("Unimplemented")}}class i3{constructor(e){this.expr=e}evaluate(e,t){var s;Xe(this.expr.params.length===1,216);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"NULL":return se.pr();case"ARRAY":{const a=((s=r.value.arrayValue)==null?void 0:s.values)??[];return se.newValue({arrayValue:{values:[...a].reverse()}})}default:return se.dr()}}}class a3{constructor(e){this.expr=e}evaluate(e,t){return Xe(this.expr.params.length===2,52884),new v
31321(new Ce("eq_any",[this.expr.params[1],this.expr.params[0]])).evaluate(e,t)}}class o3{constructor(e){this.expr=e}evaluate(e,t){var h,f,p,y;Xe(this.expr.params.length===2,1392);let r=!1;const s=ut(this.expr.params[0]).evaluate(e,t);switch(s.type){case"ARRAY":break;case"NULL":r=!0;break;default:return se.dr()}const a=ut(this.expr.params[1]).evaluate(e,t);switch(a.type){case"ARRAY":break;case"NULL":r=!0;break;default:return se.dr()}if(r)return se.pr();const c=((f=(h=a.value)==null?void 0:h.arrayValue)==null?void 0:f.values)??[],u=((y=(p=s.value)==null?void 0:p.arrayValue)==null?void 0:y.values)??[];for(const b of c){let w=!1;r=!1;for(const E of u){switch(Js(b)&&Js(E)?"EQ":Ja(b,E)){case"EQ":w=!0;break;case"NOT_EQ":case"TYPE_MISMATCH":break;case"NULL":r=!0;break;default:ot(44613,{value:E,search:b})}if(w)break}if(!w)return se.newValue(Rr)}return se.newValue(Ds)}}class l3{constructor(e){this.expr=e}evaluate(e,t){var h,f,p,y;Xe(this.expr.params.length===2,2680);let r=!1;const s=ut(this.expr.params[0]).evaluate(e,t);switch(s.type){case"ARRAY":break;case"NULL":r=!0;break;default:return se.dr()}const a=ut(this.expr.params[1]).evaluate(e,t);switch(a.type){case"ARRAY":break;case"NULL":r=!0;break;default:return se.dr()}if(r)return se.pr();const c=((f=(h=a.value)==null?void 0:h.arrayValue)==null?void 0:f.values)??[],u=((y=(p=s.value)==null?void 0:p.arrayValue)==null?void 0:y.values)??[];for(const b of u)for(const w of c)switch(Js(b)&&Js(w)?"EQ":Ja(b,w)){case"EQ":return se.newValue(Ds);case"NOT_EQ":case"TYPE_MISMATCH":break;case"NULL":r=!0;break;default:ot(60403,{value:b,search:w})}return r?se.pr():se.newValue(Rr)}}class c3{constructor(e){this.expr=e}evaluate(e,t){var s,a,c;Xe(this.expr.params.length===1,38605);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"NULL":return se.pr();case"ARRAY":return se.newValue({integerValue:`${((c=(a=(s=r.value)==null?void 0:s.arrayValue)==null?void 0:a.values)==null?void 0:c.length)??0}`});default:return se.dr()}}}class u3{constructor(e){this.expr=e}evaluate(e,t){throw new Error("Unimplemented")}}class d3{constructor(e){this.expr=e}evaluate(e,t){var s,a;Xe(this.expr.params.length===1,1508);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"NULL":return se.pr();case"BYTES":{const c=(s=r.value)==null?void 0:s.bytesValue;if(typeof c=="string"){const u=xr.fromBase64String(c).toUint8Array();return u.reverse(),se.newValue({bytesValue:xr.fromUint8Array(u).toBase64()})}return se.newValue({bytesValue:new Uint8Array(c).reverse()})}case"STRING":{const c=(a=r.value)==null?void 0:a.stringValue,u=new Intl.__PRIVATE_Segmenter(void 0,{granularity:"grapheme"}).segment(c),h=Array.from(u,(f=>f.segment)).reverse();return se.newValue({stringValue:h.join("")})}default:return se.dr()}}}class h3{constructor(e){this.expr=e}evaluate(e,t){throw new Error("Unimplemented")}}class f3{constructor(e){this.expr=e}evaluate(e,t){throw new Error("Unimplemented")}}class m3{constructor(e){this.expr=e}evaluate(e,t){Xe(this.expr.params.length===1,19400);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"NULL":return se.pr();case"STRING":{const s=(function(c){let u=0;for(let h=0;h<c.length;h++){const f=c.codePointAt(h);if(f===void 0)return;if(f<=65535)if(f>=55296&&f<=57343)if(f<=56319){const p=c.codePointAt(h+1);p!==void 0&&p>=56320&&p<=57343?(u+=1,h++):u+=1}else u+=1;else u+=1;else{if(!(f<=1114111))return;u+=1,h++}}return u})(r.value.stringValue);return s===void 0?se.dr():se.newValue({integerValue:s})}default:return se.dr()}}}class g3{constructor(e){this.expr=e}evaluate(e,t){var s,a;Xe(this.expr.params.length===1,8486);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"BYTES":{const c=(s=r.value)==null?void 0:s.bytesValue;return typeof c=="string"?se.newValue({integerValue:xr.fromBase64String(c).toUint8Array().length}):se.newValue({integerValue:new Uint8Array(c).length})}case"STRING":{const c=(function(h){let f=0;for(let p=0;p<h.length;p++){const y=h.codePointAt(p);if(y===void 0)return;if(y>=55296&&y<=57343){if(!(y<=56319))return;{const b=h.codePointAt(p+1);if(b===void 0||!(b>=56320&&b<=57343))return;f+=4,p++}}else if(y<=127)f+=1;else if(y<=2047)f+=2;else if(y<=65535)f+=3;else{if(!(y<=1114111))return;f+=4,p++}}return f})((a=r.value)==null?void 0:a.stringValue);return c===void 0?se.dr():se.newValue({integerValue:c})}case"NULL":return se.pr();default:return se.dr()}}}class zu{constructor(e){this.expr=e}evaluate(e,t){var c,u;Xe(this.expr.params.length===2,39773,`${this.expr.name}() function should have exactly two parameters`);let r=!1;const s=ut(this.expr.params[0]).evaluate(e,t);switch(s.type){case"STRING":break;case"NULL":r=!0;break;default:return se.dr()}const a=ut(this.expr.params[1]).evaluate(e,t);switch(a.type){case"STRING":break;case"NULL":r=!0;break;default:return se.dr()}return r?se.pr():this.Fr((c=s.value)==null?void 0:c.stringValue,(u=a.value)==null?void 0:u.stringValue)}}class p3 extends zu{Fr(e,t){try{const r=(function(c){let u="";for(let h=0;h<c.length;h++){const f=c.charAt(h);switch(f){case"_":u+=".";break;case"%":u+=".*";break;case"\\":case".":case"*":case"?":case"+":case"^":case"$":case"|":case"(":case")":case"[":case"]":case"{":case"}":u+="\\"+f;break;default:u+=f}}return"^"+u+"$"}
3132)(t),s=wx.compile(r);return se.newValue({booleanValue:s.matches(e)})}catch(r){return Ri(`Invalid LIKE pattern converted to regex: ${t}, returning error. Error: ${r}`),se.dr()}}}class B3 extends zu{Fr(e,t){try{const r=wx.compile(t);return se.newValue({booleanValue:r.test(e)})}catch{return Ri(`Invalid regex pattern found in regex_contains: ${t}, returning error`),se.dr()}}}class y3 extends zu{Fr(e,t){try{return se.newValue({booleanValue:wx.compile(t).matches(e)})}catch{return Ri(`Invalid regex pattern found in regex_match: ${t}, returning error`),se.dr()}}}class x3 extends zu{Fr(e,t){return se.newValue({booleanValue:e.includes(t)})}}class C3 extends zu{Fr(e,t){return se.newValue({booleanValue:e.startsWith(t)})}}class b3 extends zu{Fr(e,t){return se.newValue({booleanValue:e.endsWith(t)})}}class v3{constructor(e){this.expr=e}evaluate(e,t){var s,a;Xe(this.expr.params.length===1,29079);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"STRING":return se.newValue({stringValue:(a=(s=r.value)==null?void 0:s.stringValue)==null?void 0:a.toLowerCase()});case"NULL":return se.pr();default:return se.dr()}}}class w3{constructor(e){this.expr=e}evaluate(e,t){var s,a;Xe(this.expr.params.length===1,60487);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"STRING":return se.newValue({stringValue:(a=(s=r.value)==null?void 0:s.stringValue)==null?void 0:a.toUpperCase()});case"NULL":return se.pr();default:return se.dr()}}}class E3{constructor(e){this.expr=e}evaluate(e,t){var s,a;Xe(this.expr.params.length===1,28544);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"STRING":return se.newValue({stringValue:(a=(s=r.value)==null?void 0:s.stringValue)==null?void 0:a.trim()});case"NULL":return se.pr();default:return se.dr()}}}class _3{constructor(e){this.expr=e}evaluate(e,t){const r=this.expr.params.map((c=>ut(c).evaluate(e,t)));let s="",a=!1;for(const c of r)switch(c.type){case"STRING":s+=c.value.stringValue;break;case"NULL":a=!0;break;default:return se.dr()}return a?se.pr():se.newValue({stringValue:s})}}class T3{constructor(e){this.expr=e}evaluate(e,t){var c,u,h,f;Xe(this.expr.params.length===2,4483);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"UNSET":return se.mr();case"MAP":break;default:return se.dr()}const s=ut(this.expr.params[1]).evaluate(e,t);if(s.type!=="STRING")return se.dr();const a=(f=(u=(c=r.value)==null?void 0:c.mapValue)==null?void 0:u.fields)==null?void 0:f[(h=s.value)==null?void 0:h.stringValue];return a===void 0?se.mr():se.newValue(a)}}class qx{constructor(e){this.expr=e}evaluate(e,t){var f,p;Xe(this.expr.params.length===2,25231,`${this.expr.name}() function should have exactly 2 params`);let r=!1;const s=ut(this.expr.params[0]).evaluate(e,t);switch(s.type){case"VECTOR":break;case"NULL":r=!0;break;default:return se.dr()}const a=ut(this.expr.params[1]).evaluate(e,t);switch(a.type){case"VECTOR":break;case"NULL":r=!0;break;default:return se.dr()}if(r)return se.pr();const c=Dy(s.value),u=Dy(a.value);if(c===void 0||u===void 0||((f=c.values)==null?void 0:f.length)!==((p=u.values)==null?void 0:p.length))return se.dr();const h=this.Or(c,u);return h===void 0||isNaN(h)?se.dr():se.newValue({doubleValue:h})}}class k3 extends qx{Or(e,t){const r=(e==null?void 0:e.values)??[],s=(t==null?void 0:t.values)??[];if(r.length===0)return;let a=0,c=0,u=0;for(let f=0;f<r.length;f++){if(!rl(r[f])||!rl(s[f]))return;const p=zr(r[f]),y=zr(s[f]);a+=p*y,c+=p*p,u+=y*y}const h=Math.sqrt(c)*Math.sqrt(u);if(h!==0)return 1-Math.max(-1,Math.min(1,a/h))}}class N3 extends qx{Or(e,t){const r=(e==null?void 0:e.values)??[],s=(t==null?void 0:t.values)??[];if(r.length===0)return 0;let a=0;for(let c=0;c<r.length;c++){if(!rl(r[c])||!rl(s[c]))return;a+=zr(r[c])*zr(s[c])}return a}}class S3 extends qx{Or(e,t){const r=(e==null?void 0:e.values)??[],s=(t==null?void 0:t.values)??[];if(r.length===0)return 0;let a=0;for(let c=0;c<r.length;c++){if(!rl(r[c])||!rl(s[c]))return;const u=zr(r[c]),h=zr(s[c]);a+=Math.pow(u-h,2)}return Math.sqrt(a)}}class D3{constructor(e){this.expr=e}evaluate(e,t){var s;Xe(this.expr.params.length===1,39044);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"VECTOR":{const a=Dy(r.value);return se.newValue({integerValue:((s=a==null?void 0:a.values)==null?void 0:s.length)??0})}case"NULL":return se.pr();default:return se.dr()}}}const Rh=BigInt(-62135596800),Ph=BigInt(253402300799),kg=BigInt(1e3),Wo=BigInt(1e6),A3=Rh*kg,I3=Ph*kg+BigInt(999),R3=Rh*Wo,P3=Ph*Wo+BigInt(999999);function zx(n){return n>=R3&&n<=P3}function w1(n){return n>=Rh&&n<=Ph}function Mh(n,e){const t=BigInt(n);return!(t<Rh||t>Ph)&&!(e<0||e>=1e9)&&(t!==Rh||e===0)&&!(t===Ph&&e>999999999)}function E1(n,e){return e<0?{seconds:n-1,nanos:e+1e9}:{seconds:n,nanos:e}}function Jx(n){return BigInt(n.seconds)*Wo+BigInt(Math.trunc(n.nanoseconds/1e3))}class $x{constructor(e){this.expr=e}evaluate(e,t){Xe(this.expr.params.length===1,49262,`${this.expr.name}() function should have exactly one parameter`);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"INT":return this.toTimestamp(BigInt(r.value.integerValue));case"NULL":return se.pr();default:return se.dr()}}}class M3 extends $x{toTimestamp(e){if(!zx(e))return se.dr();let t=Number(e/Wo),r=Number(e%Wo*BigInt(1e3));const s=E1(t,r);return t=s.seconds,r=s.nanos,Mh(t,r)?se.newValue({timestampValue:{seconds:t,nanos:r}}):se.dr()}}class L3 extends $x{toTimestamp(e){if(!(function(c){return c>=A3&&c<=I3})(e))return se.dr();let t=Number(e/kg),r=Number(e%kg*BigInt(1e6));const s=E1(t,r);return t=s.seconds,r=s.nanos,Mh(t,r)?se.newValue({timestampValue:{seconds:t,nanos:r}}):se.dr()}}class j3 extends $x{toTimestamp(e){if(!w1(e))return se.dr();const t=Number(e);return se.newValue({timestampValue:{seconds:t,nanos:0}})}}class Kx{constructor(e){this.expr=e}evaluate(e,t){Xe(this.expr.params.length===1,1265,`${this.expr.name}() function should have exactly one parameter`);const r=ut(this.expr.params[0]).evaluate(e,t);switch(r.type){case"TIMESTAMP":break;case"NULL":return se.pr();default:return se.dr()}const s=Ix(r.value.timestampValue);return Mh(s.seconds,s.nanoseconds)?this.Mr(s):se.dr()}}class O3 extends Kx{Mr(e){const t=Jx(e);return zx(t)?se.newValue({integerValue:`${t.toString()}`}):se.dr()}}class F3 extends Kx{Mr(e){const t=Jx(e),r=t/BigInt(1e3),s=t%BigInt(1e3);return r>BigInt(0)||s===BigInt(0)?se.newValue({integerValue:r.toString()}):se.newValue({integerValue:(r-BigInt(1)).toString()})}}class U3 extends Kx{Mr(e){const t=BigInt(e.seconds);return w1(t)?se.newValue({integerValue:t.toString()}):se.dr()}}class _1{constructor(e){this.expr=e}evaluate(e,t){Xe(this.expr.params.length===3,2775,`${this.expr.name}() function should have exactly 3 parameters`);let r=!1;const s=ut(this.expr.params[0]).evaluate(e,t);switch(s.type){case"TIMESTAMP":break;case"NULL":r=!0;break;default:return se.dr()}const a=ut(this.expr.params[1]).evaluate(e,t);let c;switch(a.type){case"STRING":if(c=(function(O){switch(O){case"microsecond":return"microsecond";case"millisecond":return"millisecond";case"second":return"second";case"minute":return"minute";case"hour":return"hour";case"day":return"day";default:return}})(a.value.stringValue),c===void 0)return se.dr();break;case"NULL":r=!0;break;default:return se.dr()}const u=ut(this.expr.params[2]).evaluate(e,t);switch(u.type){case"INT":break;case"NULL":r=!0;break;default:return se.dr()}if(r)return se.pr();const h=BigInt(u.value.integerValue);let f;try{switch(c){case"microsecond":f=h;break;case"millisecond":f=h*BigInt(1e3);break;case"second":f=h*BigInt(1e6);break;case"minute":f=h*BigInt(6e7);break;case"hour":f=h*BigInt(36e8);break;case"day":f=h*BigInt(864e8);break;default:return se.dr()}if(c!=="microsecond"&&h!==BigInt(0)&&f/h!==BigInt(this.Nr(c)))return se.dr()}catch(I){return Ri(`Error during timestamp arithmetic: ${I}`),se.dr()}const p=Ix(s.value.timestampValue);if(!Mh(p.seconds,p.nanoseconds))return se.dr();const y=Jx(p),b=this.Lr(y,f);if(!zx(b))return se.dr();const w=Number(b/Wo),E=b%Wo,N=Number((E<0?E+Wo:E)*BigInt(1e3)),S=E<0?w-1:w;return Mh(S,N)?se.newValue({timestampValue:{seconds:S,nanos:N}}):se.dr()}Nr(e){switch(e){case"millisecond":return 1e3;case"second":return 1e6;case"minute":return 6e7;case"hour":return 36e8;case"day":return 864e8;default:return 1}}}
vendor: 4,642 bytes, lines 3132-3151
3132class V3 extends _1{Lr(e,t){return e+t}}class G3 extends _1{Lr(e,t){return e-t}}function Lh(n){if((n=b1(n))instanceof Gu)return`fld(${n.fieldName})`;if(n instanceof Hu)return`cst(${(function(t){return t===null?"null":typeof t=="number"?t.toString():typeof t=="string"?`"${t}"`:t instanceof er?`ref(${t.path})`:t instanceof Ss?`vec(${JSON.stringify(t)})`:JSON.stringify(t)})(n.value)})`;if(n instanceof Ce)return`fn(${n.name},[${n.params.map(Lh).join(",")}])`;if(n.expressionType==="ListOfExpressions")return`list([${n.ur.map(Lh).join(",")}])`;throw new Error(`Unrecognized expr ${JSON.stringify(n,null,2)}`)}function H3(n){if(n instanceof y1)return`${n._name}(${Sm(n.fields)})`;if(n instanceof x1){let e=`${n._name}(${Sm(n.accumulators)})`;return n.groups.size>0&&(e+=`grouping(${Sm(n.groups)})`),e}if(n instanceof C1)return`${n._name}(${Sm(n.groups)})`;if(n instanceof gp)return`${n._name}(${n.Er})`;if(n instanceof pp)return`${n._name}(${n.collectionId})`;if(n instanceof Fx)return`${n._name}()`;if(n instanceof Ux)return`${n._name}(${n.hr.sort()})`;if(n instanceof Bp)return`${n._name}(${Lh(n.condition)})`;if(n instanceof xc)return`${n._name}(${n.limit})`;if(n instanceof ja)return`${n._name}(${(function(t){return t.map((r=>`${Lh(r.expr)}${r.direction}`)).join(",")})(n.orderings)})`;throw new Error(`Unrecognized stage ${n._name}`)}function Sm(n){return`${Array.from(n.entries()).sort().map((([e,t])=>`${e}=${Lh(t)}`)).join(",")}`}function Va(n){return n.stages.map((e=>H3(e))).join("|")}function T1(n,e){return Va(n)===Va(e)}function Er(n){return n instanceof hs}function aT(n){return Er(n)?Va(n):ch(n)}function k1(n){return Er(n)?Va(n):(function(t){return`${MD(ta(t))}|lt:${t.limitType}`})(n)}function Cp(n,e){return n instanceof hs&&e instanceof hs?T1(n,e):!(n instanceof hs&&!(e instanceof hs)||!(n instanceof hs)&&e instanceof hs)&&l5(n,e)}function N1(n){return Zl(n)?Va(n):MD(n)}function S1(n,e){return n instanceof hs&&e instanceof hs?T1(n,e):!(n instanceof hs&&!(e instanceof hs)||!(n instanceof hs)&&e instanceof hs)&&LD(n,e)}function q3(n,e){const t=(function(s){let a=!1;const c=[];for(const u of s)if(u instanceof ja)if(a=!0,u.orderings.some((h=>h.expr instanceof Gu&&h.expr.fieldName===Yi)))c.push(u);else{const h=u.orderings.map((f=>f));h.push(Xm(Yi).ascending()),c.push(new ja(h,{}))}else u instanceof xc&&(a||(c.push(new ja([Xm(Yi).ascending()],{})),a=!0)),c.push(u);return a||c.push(new ja([Xm(Yi).ascending()],{})),c})(n.stages);if(n.userDataReader){const r=n.userDataReader.createContext(3,"toCorePipeline");t.forEach((s=>s._readUserData(r)))}return new hs(n.userDataReader.serializer,t,e)}/**
3133 * @license
3134 * Copyright 2017 Google LLC
3135 *
3136 * Licensed under the Apache License, Version 2.0 (the "License");
3137 * you may not use this file except in compliance with the License.
3138 * You may obtain a copy of the License at
3139 *
3140 *   http://www.apache.org/licenses/LICENSE-2.0
3141 *
3142 * Unless required by applicable law or agreed to in writing, software
3143 * distributed under the License is distributed on an "AS IS" BASIS,
3144 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3145 * See the License for the specific language governing permissions and
3146 * limitations under the License.
3147 */class z3{constructor(e,t,r,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=s}applyToRemoteDocument(e,t){const r=t.mutationResults;for(let s=0;s<this.mutations.length;s++){const a=this.mutations[s];a.key.isEqual(e.key)&&HO(a,e,r[s])}}applyToLocalView(e,t){for(const r of this.baseMutations)r.key.isEqual(e.key)&&(t=oh(r,e,t,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(e.key)&&(t=oh(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const r=GD();return this.mutations.forEach((s=>{const a=e.get(s.key),c=a.overlayedDocument;let u=this.applyToLocalView(c,a.mutatedFields);u=t.has(s.key)?null:u;const h=kD(c,u);h!==null&&r.set(s.key,h),c.isValidDocument()||c.convertToNoDocument(pt.min())})),r}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),Dt())}isEqual(e){return this.batchId===e.batchId&&Au(this.mutations,e.mutations,((t,r)=>j_(t,r)))&&Au(this.baseMutations,e.baseMutations,((t,r)=>j_(t,r)))}}class Yx{constructor(e,t,r,s){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=s}static from(e,t,r){Xe(e.mutations.length===r.length,58842,{Br:e.mutations.length,Ur:r.length});let s=(function(){return f5})();const a=e.mutations;for(let c=0;c<a.length;c++)s=s.insert(a[c].key,r[c].version);return new Yx(e,t,r,s)}}/**
3148 * @license
3149 * Copyright 2017 Google LLC
3150 *
3151 * Licensed under the Apache License, Version 2.0 (the "License");
3152 * you may not use this file except in compliance with the License.
3153 * You may obtain a copy of the License at
3154 *
3155 *   http://www.apache.org/licenses/LICENSE-2.0
3156 *
3157 * Unless required by applicable law or agreed to in writing, software
3158 * distributed under the License is distributed on an "AS IS" BASIS,
3159 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3160 * See the License for the specific language governing permissions and
3161 * limitations under the License.
3162 */const D1="�";function J3(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=oT(e)),e=$3(n.get(t),e);return oT(e)}function $3(n,e){let t=e;const r=n.length;for(let s=0;s<r;s++){const a=n.charAt(s);switch(a){case"\0":t+="��";break;case D1:t+="��";break;default:t+=a}}return t}function oT(n){return n+D1+"�"}/**
3163 * @license
3164 * Copyright 2022 Google LLC
3165 *
3166 * Licensed under the Apache License, Version 2.0 (the "License");
3167 * you may not use this file except in compliance with the License.
3168 * You may obtain a copy of the License at
3169 *
3170 *   http://www.apache.org/licenses/LICENSE-2.0
3171 *
3172 * Unless required by applicable law or agreed to in writing, software
3173 * distributed under the License is distributed on an "AS IS" BASIS,
3174 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3175 * See the License for the specific language governing permissions and
3176 * limitations under the License.
3177 */class K3{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
3178      largestBatchId: ${this.largestBatchId},
3179      mutation: ${this.mutation.toString()}
3180    }`}}/**
3181 * @license
3182 * Copyright 2017 Google LLC
3183 *
3184 * Licensed under the Apache License, Version 2.0 (the "License");
3185 * you may not use this file except in compliance with the License.
3186 * You may obtain a copy of the License at
3187 *
3188 *   http://www.apache.org/licenses/LICENSE-2.0
3189 *
3190 * Unless required by applicable law or agreed to in writing, software
3191 * distributed under the License is distributed on an "AS IS" BASIS,
3192 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3193 * See the License for the specific language governing permissions and
3194 * limitations under the License.
3195 */class Oa{constructor(e,t,r,s,a=pt.min(),c=pt.min(),u=xr.EMPTY_BYTE_STRING,h=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=a,this.lastLimboFreeSnapshotVersion=c,this.resumeToken=u,this.expectedCount=h}withSequenceNumber(e){return new Oa(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new Oa(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new Oa(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new Oa(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/**
3196 * @license
3197 * Copyright 2017 Google LLC
3198 *
3199 * Licensed under the Apache License, Version 2.0 (the "License");
3200 * you may not use this file except in compliance with the License.
3201 * You may obtain a copy of the License at
3202 *
3203 *   http://www.apache.org/licenses/LICENSE-2.0
3204 *
3205 * Unless required by applicable law or agreed to in writing, software
3206 * distributed under the License is distributed on an "AS IS" BASIS,
3207 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3208 * See the License for the specific language governing permissions and
3209 * limitations under the License.
3210 */class Y3{constructor(e){this.qr=e}}function Q3(n){const e=D5({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?wg(e,e.limit,"L"):e}/**
3211 * @license
3212 * Copyright 2019 Google LLC
3213 *
3214 * Licensed under the Apache License, Version 2.0 (the "License");
3215 * you may not use this file except in compliance with the License.
3216 * You may obtain a copy of the License at
3217 *
3218 *   http://www.apache.org/licenses/LICENSE-2.0
3219 *
3220 * Unless required by applicable law or agreed to in writing, softw
3220are
3221 * distributed under the License is distributed on an "AS IS" BASIS,
3222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3223 * See the License for the specific language governing permissions and
3224 * limitations under the License.
3225 */class W3{constructor(){this.Yi=new X3}addToCollectionParentIndex(e,t){return this.Yi.add(t),Ee.resolve()}getCollectionParents(e,t){return Ee.resolve(this.Yi.getEntries(t))}addFieldIndex(e,t){return Ee.resolve()}deleteFieldIndex(e,t){return Ee.resolve()}deleteAllFieldIndexes(e){return Ee.resolve()}createTargetIndexes(e,t){return Ee.resolve()}getDocumentsMatchingTarget(e,t){return Ee.resolve(null)}getIndexType(e,t){return Ee.resolve(0)}getFieldIndexes(e,t){return Ee.resolve([])}getNextCollectionGroupToUpdate(e){return Ee.resolve(null)}getMinOffset(e,t){return Ee.resolve(sl.min())}getMinOffsetFromCollectionGroup(e,t){return Ee.resolve(sl.min())}updateCollectionGroup(e,t,r){return Ee.resolve()}updateIndexEntries(e,t){return Ee.resolve()}}class X3{constructor(){this.index={}}add(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t]||new yr(sn.comparator),a=!s.has(r);return this.index[t]=s.add(r),a}has(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t];return s&&s.has(r)}getEntries(e){return(this.index[e]||new yr(sn.comparator)).toArray()}}/**
3226 * @license
3227 * Copyright 2017 Google LLC
3228 *
3229 * Licensed under the Apache License, Version 2.0 (the "License");
3230 * you may not use this file except in compliance with the License.
3231 * You may obtain a copy of the License at
3232 *
3233 *   http://www.apache.org/licenses/LICENSE-2.0
3234 *
3235 * Unless required by applicable law or agreed to in writing, software
3236 * distributed under the License is distributed on an "AS IS" BASIS,
3237 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3238 * See the License for the specific language governing permissions and
3239 * limitations under the License.
3240 */class ll{constructor(e){this.gs=e}next(){return this.gs+=2,this.gs}static ys(){return new ll(0)}static ws(){return new ll(-1)}}// Copyright 2024 Google LLC* @license
3241function A1(n,e){var r;let t=e;for(const s of n.stages)t=eU({serializer:n.serializer,serverTimestampBehavior:(r=n.listenOptions)==null?void 0:r.serverTimestampBehavior},s,t);return t}function bp(n,e){return A1(n,[e]).length>0}function Z3(n,e){return Er(n)?bp(n,e):cp(n,e)}function eU(n,e,t){if(e instanceof gp)return(function(s,a,c){return c.filter((u=>u.isFoundDocument()&&`/${u.key.getCollectionPath().canonicalString()}`===a.Er))})(0,e,t);if(e instanceof Bp)return(function(s,a,c){return c.filter((u=>{const h=hh(ut(a.condition).evaluate(s,u));return h!==void 0&&pi(h,Ds)}))})(n,e,t);if(e instanceof pp)return(function(s,a,c){return c.filter((u=>u.isFoundDocument()&&u.key.getCollectionPath().lastSegment()===a.collectionId))})(0,e,t);if(e instanceof Fx)return(function(s,a,c){return c.filter((u=>u.isFoundDocument()))})(0,0,t);if(e instanceof Ux)return(function(s,a,c){return c.filter((u=>u.isFoundDocument()&&a.Tr.has(u.key.path.toStringWithLeadingSlash())))})(0,e,t);if(e instanceof xc)return(function(s,a,c){return c.slice(0,a.limit)})(0,e,t);if(e instanceof ja)return(function(s,a,c){const u=a.orderings.map((h=>({Os:ut(h.expr),direction:h.direction})));return[...c].sort(((h,f)=>{for(const{Os:p,direction:y}of u){const b=hh(p.evaluate(s,h)),w=hh(p.evaluate(s,f)),E=As(b??Ru,w??Ru);if(E!==0)return y==="ascending"?E:-E}return 0}))})(n,e,t);throw new Error(`Unknown stage: ${e._name}`)}function Oy(n){const e=(function(r){for(let s=r.stages.length-1;s>=0;s--){const a=r.stages[s];if(a instanceof ja)return a.orderings}throw new Error("Pipeline must contain at least one Sort stage")})(n);return(t,r)=>{for(const s of e){const a=hh(ut(s.expr).evaluate({serializer:n.serializer},t)),c=hh(ut(s.expr).evaluate({serializer:n.serializer},r)),u=As(a||Ru,c||Ru);if(u!==0)return s.direction==="ascending"?u:-u}return 0}}function QB(n){for(let e=n.stages.length-1;e>=0;e--){const t=n.stages[e];if(t instanceof xc)return{limit:t.limit}}}/**
3242 * @license
3243 * Copyright 2017 Google LLC
3244 *
3245 * Licensed under the Apache License, Version 2.0 (the "License");
3246 * you may not use this file except in compliance with the License.
3247 * You may obtain a copy of the License at
3248 *
3249 *   http://www.apache.org/licenses/LICENSE-2.0
3250 *
3251 * Unless required by applicable law or agreed to in writing, software
3252 * distributed under the License is distributed on an "AS IS" BASIS,
3253 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3254 * See the License for the specific language governing permissions and
3255 * limitations under the License.
3256 */class tU{constructor(){this.changes=new Ec((e=>e.toString()),((e,t)=>e.isEqual(t))),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Xr.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const r=this.changes.get(t);return r!==void 0?Ee.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}/**
3257 * @license
3258 * Copyright 2017 Google LLC
3259 *
3260 * Licensed under the Apache License, Version 2.0 (the "License");
3261 * you may not use this file except in compliance with the License.
3262 * You may obtain a copy of the License at
3263 *
3264 *   http://www.apache.org/licenses/LICENSE-2.0
3265 *
3266 * Unless required by applicable law or agreed to in writing, software
3267 * distributed under the License is distributed on an "AS IS" BASIS,
3268 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3269 * See the License for the specific language governing permissions and
3270 * limitations under the License.
3271 *//**
3272 * @license
3273 * Copyright 2022 Google LLC
3274 *
3275 * Licensed under the Apache License, Version 2.0 (the "License");
3276 * you may not use this file except in compliance with the License.
3277 * You may obtain a copy of the License at
3278 *
3279 *   http://www.apache.org/licenses/LICENSE-2.0
3280 *
3281 * Unless required by applicable law or agreed to in writing, software
3282 * distributed under the License is distributed on an "AS IS" BASIS,
3283 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3284 * See the License for the specific language governing permissions and
3285 * limitations under the License.
3286 */class nU{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}/**
3287 * @license
3288 * Copyright 2017 Google LLC
3289 *
3290 * Licensed under the Apache License, Version 2.0 (the "License");
3291 * you may not use this file except in compliance with the License.
3292 * You may obtain a copy of the License at
3293 *
3294 *   http://www.apache.org/licenses/LICENSE-2.0
3295 *
3296 * Unless required by applicable law or agreed to in writing, software
3297 * distributed under the License is distributed on an "AS IS" BASIS,
3298 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3299 * See the License for the specific language governing permissions and
3300 * limitations under the License.
3301 */class rU{constructor(e,t,r,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next((s=>(r=s,this.remoteDocumentCache.getEntry(e,t)))).next((s=>(r!==null&&oh(r.mutation,s,zs.empty(),An.now()),s)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.getLocalViewOfDocuments(e,r,Dt()).next((()=>r))))}getLocalViewOfDocuments(e,t,r=Dt()){const s=Ho();return this.populateOverlays(e,s,t).next((()=>this.computeViews(e,t,s,r).next((a=>{let c=xu();return a.forEach(((u,h)=>{c=c.insert(u,h.overlayedDocument)})),c}))))}getOverlayedDocuments(e,t){const r=Ho();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,Dt())))}populateOverlays(e,t,r){const s=[];return r.forEach((a=>{t.has(a)||s.push(a)})),this.documentOverlayCache.getOverlays(e,s).next((a=>{a.forEach(((c,u)=>{t.set(c,u)}))}))}computeViews(e,t,r,s){let a=Ns();const c=uh(),u=(function(){return uh()})();return t.forEach(((h,f)=>{const p=r.get(f.key);s.has(f.key)&&(p===void 0||p.mutation instanceof fl)?a=a.insert(f.key,f):p!==void 0?(c.set(f.key,p.mutation.getFieldMask()),oh(p.mutation,f,p.mutation.getFieldMask(),An.now())):c.set(f.key,zs.empty())})),this.recalculateAndSaveOverlays(e,a).next((h=>
vendor: 4,421 bytes, lines 3301-3305
3301(h.forEach(((f,p)=>c.set(f,p))),t.forEach(((f,p)=>u.set(f,new nU(p,c.get(f)??null)))),u)))}recalculateAndSaveOverlays(e,t){const r=uh();let s=new Fn(((c,u)=>c-u)),a=Dt();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((c=>{for(const u of c)u.keys().forEach((h=>{const f=t.get(h);if(f===null)return;let p=r.get(h)||zs.empty();p=u.applyToLocalView(f,p),r.set(h,p);const y=(s.get(u.batchId)||Dt()).add(h);s=s.insert(u.batchId,y)}))})).next((()=>{const c=[],u=s.getReverseIterator();for(;u.hasNext();){const h=u.getNext(),f=h.key,p=h.value,y=GD();p.forEach((b=>{if(!a.has(b)){const w=kD(t.get(b),r.get(b));w!==null&&y.set(b,w),a=a.add(b)}})),c.push(this.documentOverlayCache.saveOverlays(e,f,y))}return Ee.waitFor(c)})).next((()=>r))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.recalculateAndSaveOverlays(e,r)))}getDocumentsMatchingQuery(e,t,r,s){return Er(t)?this.getDocumentsMatchingPipeline(e,t,r,s):a5(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):OD(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,s):this.getDocumentsMatchingCollectionQuery(e,t,r,s)}getNextDocuments(e,t,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,s).next((a=>{const c=s-a.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,s-a.size):Ee.resolve(Ho());let u=Dh,h=a;return c.next((f=>Ee.forEach(f,((p,y)=>(u<y.largestBatchId&&(u=y.largestBatchId),a.get(p)?Ee.resolve():this.remoteDocumentCache.getEntry(e,p).next((b=>{h=h.insert(p,b)}))))).next((()=>this.populateOverlays(e,f,a))).next((()=>this.computeViews(e,h,f,Dt()))).next((p=>({batchId:u,changes:VD(p)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new nt(t)).next((r=>{let s=xu();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s}))}getDocumentsMatchingCollectionGroupQuery(e,t,r,s){const a=t.collectionGroup;let c=xu();return this.indexManager.getCollectionParents(e,a).next((u=>Ee.forEach(u,(h=>{const f=(function(y,b){return new Yh(b,null,y.explicitOrderBy.slice(),y.filters.slice(),y.limit,y.limitType,y.startAt,y.endAt)})(t,h.child(a));return this.getDocumentsMatchingCollectionQuery(e,f,r,s).next((p=>{p.forEach(((y,b)=>{c=c.insert(y,b)}))}))})).next((()=>c))))}getDocumentsMatchingCollectionQuery(e,t,r,s){let a;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next((c=>(a=c,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,a,s)))).next((c=>this.retrieveMatchingLocalDocuments(a,c,(u=>cp(t,u)))))}getDocumentsMatchingPipeline(e,t,r,s){if(Qo(t)==="collection_group"){const a=Gx(t);let c=xu();return this.indexManager.getCollectionParents(e,a).next((u=>Ee.forEach(u,(h=>{const f=(function(y,b){const w=y.stages.map((E=>E instanceof pp?new gp(b.canonicalString(),{}):E));return new hs(y.serializer,w)})(t,h.child(a));return this.getDocumentsMatchingPipeline(e,f,r,s).next((p=>{p.forEach(((y,b)=>{c=c.insert(y,b)}))}))})).next((()=>c))))}{let a;return this.getOverlaysForPipeline(e,t,r.largestBatchId).next((c=>{switch(a=c,Qo(t)){case"collection":return this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,a,s);case"documents":let u=Dt();for(const h of jy(t))u=u.add(nt.fromPath(h));return this.remoteDocumentCache.getEntries(e,u);case"database":return this.remoteDocumentCache.getAllEntries(e);default:throw new Fe("invalid-argument",`Invalid pipeline source to execute offline: ${Va(t)}`)}})).next((c=>this.retrieveMatchingLocalDocuments(a,c,(u=>bp(t,u)))))}}retrieveMatchingLocalDocuments(e,t,r){e.forEach(((a,c)=>{const u=c.getKey();t.get(u)===null&&(t=t.insert(u,Xr.newInvalidDocument(u)))}));let s=xu();return t.forEach(((a,c)=>{const u=e.get(a);u!==void 0&&oh(u.mutation,c,zs.empty(),An.now()),r(c)&&(s=s.insert(a,c))})),s}getOverlaysForPipeline(e,t,r){switch(Qo(t)){case"collection":return this.documentOverlayCache.getOverlaysForCollection(e,sn.fromString(yp(t)),r);case"collection_group":throw new Fe("invalid-argument",`Unexpected collection group pipeline: ${Va(t)}`);case"documents":return this.documentOverlayCache.getOverlays(e,jy(t).map((s=>nt.fromPath(s))));case"database":return this.documentOverlayCache.getAllOverlays(e,r);default:throw new Fe("invalid-argument",`Failed to get overlays for pipeline: ${Va(t)}`)}}}/**
3302 * @license
3303 * Copyright 2020 Google LLC
3304 *
3305 * Licensed under the Apache License, Version 2.0 (the "License");
3306 * you may not use this file except in compliance with the License.
3307 * You may obtain a copy of the License at
3308 *
3309 *   http://www.apache.org/licenses/LICENSE-2.0
3310 *
3311 * Unless required by applicable law or agreed to in writing, software
3312 * distributed under the License is distributed on an "AS IS" BASIS,
3313 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3314 * See the License for the specific language governing permissions and
3315 * limitations under the License.
3316 */class sU{constructor(e){this.serializer=e,this.Ks=new Map,this.Qs=new Map}getBundleMetadata(e,t){return Ee.resolve(this.Ks.get(t))}saveBundleMetadata(e,t){return this.Ks.set(t.id,(function(s){return{id:s.id,version:s.version,createTime:na(s.createTime)}})(t)),Ee.resolve()}getNamedQuery(e,t){return Ee.resolve(this.Qs.get(t))}saveNamedQuery(e,t){return this.Qs.set(t.name,(function(s){return{name:s.name,query:Q3(s.bundledQuery),readTime:na(s.readTime)}})(t)),Ee.resolve()}}/**
3317 * @license
3318 * Copyright 2022 Google LLC
3319 *
3320 * Licensed under the Apache License, Version 2.0 (the "License");
3321 * you may not use this file except in compliance with the License.
3322 * You may obtain a copy of the License at
3323 *
3324 *   http://www.apache.org/licenses/LICENSE-2.0
3325 *
3326 * Unless required by applicable law or agreed to in writing, software
3327 * distributed under the License is distributed on an "AS IS" BASIS,
3328 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3329 * See the License for the specific language governing permissions and
3330 * limitations under the License.
3331 */class iU{constructor(){this.overlays=new Fn(nt.comparator),this.Ws=new Map}getOverlay(e,t){return Ee.resolve(this.overlays.get(t))}getOverlays(e,t){const r=Ho();return Ee.forEach(t,(s=>this.getOverlay(e,s).next((a=>{a!==null&&r.set(s,a)})))).next((()=>r))}getAllOverlays(e,t){const r=Ho();return this.overlays.forEach(((s,a)=>{a.largestBatchId>t&&r.set(s,a)})),Ee.resolve(r)}saveOverlays(e,t,r){return r.forEach(((s,a)=>{this.Yr(e,t,a)})),Ee.resolve()}removeOverlaysForBatchId(e,t,r){const s=this.Ws.get(r);return s!==void 0&&(s.forEach((a=>this.overlays=this.overlays.remove(a))),this.Ws.delete(r)),Ee.resolve()}getOverlaysForCollection(e,t,r){const s=Ho(),a=t.length+1,c=new nt(t.child("")),u=this.overlays.getIteratorFrom(c);for(;u.hasNext();){const h=u.getNext().value,f=h.getKey();if(!t.isPrefixOf(f.path))break;f.path.length===a&&h.largestBatchId>r&&s.set(h.getKey(),h)}return Ee.resolve(s)}getOverlaysForCollectionGroup(e,t,r,s){let a=new Fn(((f,p)=>f-p));const c=this.overlays.getIterator();for(;c.hasNext();){const f=c.getNext().value;if(f.getKey().getCollectionGroup()===t&&f.largestBatchId>r){let p=a.get(f.largestBatchId);p===null&&(p=Ho(),a=a.insert(f.largestBatchId,p)),p.set(f.getKey(),f)}}const u=Ho(),h=a.getIterator();for(;h.hasNext()&&(h.getNext().value.forEach(((f,p)=>u.set(f,p))),!(u.size()>=s)););return Ee.resolve(u)}Yr(e,t,r){const s=this.overlays.get(r.key);if(s!==null){const c=this.Ws.get(s.largestBatchId).delete(r.key);this.Ws.set(s.largestBatchId,c)}this.overlays=this.overlays.insert(r.key,new K3(t,r));let a=this.Ws.get(t);a===void 0&&(a=Dt(),this.Ws.set(t,a)),this.Ws.set(t,a.add(r.key))}}/**
3332 * @license
3333 * Copyright 2024 Google LLC
3334 *
3335 * Licensed under the Apache License, Version 2.0 (the "License");
3336 * you may not use this file except in compliance with the License.
3337 * You may obtain a copy of the License at
3338 *
3339 *   http://www.apache.org/licenses/LICENSE-2.0
3340 *
3341 * Unless required by applicable law or agreed to in writing, software
3342 * distributed under the License is distributed on an "AS IS" BASIS,
3343 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3344 * See the License for the specific language governing permissions and
3345 * limitations under the License.
3346 */class aU{constructor(){this.sessionToken=xr.EMPTY_BYTE_STRING}getSessionToken(e){return Ee.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,Ee.resolve()}}/**
3347 * @license
3348 * Copyright 2017 Google LLC
3349 *
3350 * Licensed under the Apache License, Version 2.0 (the "License");
3351 * you may not use this file except in compliance with the License.
3352 * You may obtain a copy of the License at
3353 *
3354 *   http://www.apache.org/licenses/LICENSE-2.0
3355 *
3356 * Unless required by applicable law or agreed to in writing, software
3357 * distributed under the License is distributed on an "AS IS" BASIS,
3358 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3359 * See the License for the specific language governing permissions and
3360 * limitations under the License.
3361 */class Qx{constructor(){this.Gs=new yr(Ir.zs),this.js=new yr(Ir.Hs)}isEmpty(){return this.Gs.isEmpty()}addReference(e,t){const r=new Ir(e,t);this.Gs=this.Gs.add(r),this.js=this.js.add(r)}Js(e,t){e.forEach((r=>this.addReference(r,t)))}removeReference(e,t){this.Ys(new Ir(e,t))}Zs(e,t){e.forEach((r=>this.removeReference(r,t)))}Xs(e){const t=new nt(new sn([])),r=new Ir(t,e),s=new Ir(t,e+1),a=[];return this.js.forEachInRange([r,s],(c=>{this.Ys(c),a.push(c.key)})),a}e_(){this.Gs.forEach((e=>this.Ys(e)))}Ys(e){this.Gs=this.Gs.delete(e),this.js=this.js.delete(e)}t_(e){const t=new nt(new sn([])),r=new Ir(t,e),s=new Ir(t,e+1);let a=Dt();return this.js.forEachInRange([r,s],(c=>{a=a.add(c.key)})),a}containsKey(e){const t=new Ir(e,0),r=this.Gs.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}}class Ir{constructor(e,t){this.key=e,this.n_=t}static zs(e,t){return nt.comparator(e.key,t.key)||Lt(e.n_,t.n_)}static Hs(e,t){return Lt(e.n_,t.n_)||nt.comparator(e.key,t.key)}}/**
3362 * @license
3363 * Copyright 2017 Google LLC
3364 *
3365 * Licensed under the Apache License, Version 2.0 (the "License");
3366 * you may not use this file except in compliance with the License.
3367 * You may obtain a copy of the License at
3368 *
3369 *   http://www.apache.org/licenses/LICENSE-2.0
3370 *
3371 * Unless required by applicable law or agreed to in writing, software
3372 * distributed under the License is distributed on an "AS IS" BASIS,
3373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3374 * See the License for the specific language governing permissions and
3375 * limitations under the License.
3376 */class oU{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Wr=1,this.r_=new yr(Ir.zs)}checkEmpty(e){return Ee.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,s){const a=this.Wr;this.Wr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const c=new z3(a,t,r,s);this.mutationQueue.push(c);for(const u of s)this.r_=this.r_.add(new Ir(u.key,a)),this.indexManager.addToCollectionParentIndex(e,u.key.path.popLast());return Ee.resolve(c)}lookupMutationBatch(e,t){return Ee.resolve(this.i_(t))}getNextMutationBatchAfterBatchId(e,t){const r=t+1,s=this.s_(r),a=s<0?0:s;return Ee.resolve(this.mutationQueue.length>a?this.mutationQueue[a]:null)}getHighestUnacknowledgedBatchId(){return Ee.resolve(this.mutationQueue.length===0?Tx:this.Wr-1)}getAllMutationBatches(e){return Ee.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const r=new Ir(t,0),s=new Ir(t,Number.POSITIVE_INFINITY),a=[];return this.r_.forEachInRange([r,s],(c=>{const u=this.i_(c.n_);a.push(u)})),Ee.resolve(a)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new yr(Lt);return t.forEach((s=>{const a=new Ir(s,0),c=new Ir(s,Number.POSITIVE_INFINITY);this.r_.forEachInRange([a,c],(u=>{r=r.add(u.n_)}))})),Ee.resolve(this.__(r))}getAllMutationBatchesAffectingQuery(e,t){const r=t.path,s=r.length+1;let a=r;nt.isDocumentKey(a)||(a=a.child(""));const c=new Ir(new nt(a),0);let u=new yr(Lt);return this.r_.forEachWhile((h=>{const f=h.key.path;return!!r.isPrefixOf(f)&&(f.length===s&&(u=u.add(h.n_)),!0)}),c),Ee.resolve(this.__(u))}__(e){const t=[];return e.forEach((r=>{const s=this.i_(r);s!==null&&t.push(s)})),t}removeMutationBatch(e,t){Xe(this.o_(t.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.r_;return Ee.forEach(t.mutations,(s=>{const a=new Ir(s.key,t.batchId);return r=r.delete(a),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)})).next((()=>{this.r_=r}))}jr(e){}containsKey(e,t){const r=new Ir(t,0),s=this.r_.firstAfterOrEqual(r);return Ee.resolve(t.isEqual(s&&s.key))}
vendor: 11,653 bytes, lines 3376-3461
3376performConsistencyCheck(e){return this.mutationQueue.length,Ee.resolve()}o_(e,t){return this.s_(e)}s_(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}i_(e){const t=this.s_(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}/**
3377 * @license
3378 * Copyright 2017 Google LLC
3379 *
3380 * Licensed under the Apache License, Version 2.0 (the "License");
3381 * you may not use this file except in compliance with the License.
3382 * You may obtain a copy of the License at
3383 *
3384 *   http://www.apache.org/licenses/LICENSE-2.0
3385 *
3386 * Unless required by applicable law or agreed to in writing, software
3387 * distributed under the License is distributed on an "AS IS" BASIS,
3388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3389 * See the License for the specific language governing permissions and
3390 * limitations under the License.
3391 */class lU{constructor(e){this.a_=e,this.docs=(function(){return new Fn(nt.comparator)})(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const r=t.key,s=this.docs.get(r),a=s?s.size:0,c=this.a_(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:c}),this.size+=c-a,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const r=this.docs.get(t);return Ee.resolve(r?r.document.mutableCopy():Xr.newInvalidDocument(t))}getEntries(e,t){let r=Ns();return t.forEach((s=>{const a=this.docs.get(s);r=r.insert(s,a?a.document.mutableCopy():Xr.newInvalidDocument(s))})),Ee.resolve(r)}getAllEntries(e){let t=Ns();return this.docs.forEach(((r,s)=>{t=t.insert(r,s.document)})),Ee.resolve(t)}getDocumentsMatchingQuery(e,t,r,s){let a,c;Er(t)?(a=sn.fromString(yp(t)),c=p=>bp(t,p)):(a=t.path,c=p=>cp(t,p));let u=Ns();const h=new nt(a.child("__id-9223372036854775808__")),f=this.docs.getIteratorFrom(h);for(;f.hasNext();){const{key:p,value:{document:y}}=f.getNext();if(!a.isPrefixOf(p.path))break;p.path.length>a.length+1||r5(n5(y),r)<=0||(s.has(y.key)||c(y))&&(u=u.insert(y.key,y.mutableCopy()))}return Ee.resolve(u)}getAllFromCollectionGroup(e,t,r,s){ot(9500)}u_(e,t){return Ee.forEach(this.docs,(r=>t(r)))}newChangeBuffer(e){return new cU(this)}getSize(e){return Ee.resolve(this.size)}}class cU extends tU{constructor(e){super(),this.qs=e}applyChanges(e){const t=[];return this.changes.forEach(((r,s)=>{s.isValidDocument()?t.push(this.qs.addEntry(e,s)):this.qs.removeEntry(r)})),Ee.waitFor(t)}getFromCache(e,t){return this.qs.getEntry(e,t)}getAllFromCache(e,t){return this.qs.getEntries(e,t)}}/**
3392 * @license
3393 * Copyright 2017 Google LLC
3394 *
3395 * Licensed under the Apache License, Version 2.0 (the "License");
3396 * you may not use this file except in compliance with the License.
3397 * You may obtain a copy of the License at
3398 *
3399 *   http://www.apache.org/licenses/LICENSE-2.0
3400 *
3401 * Unless required by applicable law or agreed to in writing, software
3402 * distributed under the License is distributed on an "AS IS" BASIS,
3403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3404 * See the License for the specific language governing permissions and
3405 * limitations under the License.
3406 */class uU{constructor(e){this.persistence=e,this.c_=new Ec((t=>N1(t)),S1),this.lastRemoteSnapshotVersion=pt.min(),this.highestTargetId=0,this.l_=0,this.E_=new Qx,this.targetCount=0,this.h_=ll.ys()}forEachTarget(e,t){return this.c_.forEach(((r,s)=>t(s))),Ee.resolve()}getLastRemoteSnapshotVersion(e){return Ee.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return Ee.resolve(this.l_)}allocateTargetId(e){return this.highestTargetId=this.h_.next(),Ee.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.l_&&(this.l_=t),Ee.resolve()}vs(e){this.c_.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.h_=new ll(t),this.highestTargetId=t),e.sequenceNumber>this.l_&&(this.l_=e.sequenceNumber)}addTargetData(e,t){return this.vs(t),this.targetCount+=1,Ee.resolve()}updateTargetData(e,t){return this.vs(t),Ee.resolve()}removeTargetData(e,t){return this.c_.delete(t.target),this.E_.Xs(t.targetId),this.targetCount-=1,Ee.resolve()}removeTargets(e,t,r){let s=0;const a=[];return this.c_.forEach(((c,u)=>{u.sequenceNumber<=t&&r.get(u.targetId)===null&&(this.c_.delete(c),a.push(this.removeMatchingKeysForTargetId(e,u.targetId)),s++)})),Ee.waitFor(a).next((()=>s))}getTargetCount(e){return Ee.resolve(this.targetCount)}getTargetData(e,t){const r=this.c_.get(t)||null;return Ee.resolve(r)}addMatchingKeys(e,t,r){return this.E_.Js(t,r),Ee.resolve()}removeMatchingKeys(e,t,r){this.E_.Zs(t,r);const s=this.persistence.referenceDelegate,a=[];return s&&t.forEach((c=>{a.push(s.markPotentiallyOrphaned(e,c))})),Ee.waitFor(a)}removeMatchingKeysForTargetId(e,t){return this.E_.Xs(t),Ee.resolve()}getMatchingKeysForTargetId(e,t){const r=this.E_.t_(t);return Ee.resolve(r)}containsKey(e,t){return Ee.resolve(this.E_.containsKey(t))}}/**
3407 * @license
3408 * Copyright 2017 Google LLC
3409 *
3410 * Licensed under the Apache License, Version 2.0 (the "License");
3411 * you may not use this file except in compliance with the License.
3412 * You may obtain a copy of the License at
3413 *
3414 *   http://www.apache.org/licenses/LICENSE-2.0
3415 *
3416 * Unless required by applicable law or agreed to in writing, software
3417 * distributed under the License is distributed on an "AS IS" BASIS,
3418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3419 * See the License for the specific language governing permissions and
3420 * limitations under the License.
3421 */class I1{constructor(e,t){this.T_={},this.overlays={},this.P_=new hp(0),this.R_=!1,this.R_=!0,this.I_=new aU,this.referenceDelegate=e(this),this.A_=new uU(this),this.indexManager=new W3,this.remoteDocumentCache=(function(s){return new lU(s)})((r=>this.referenceDelegate.V_(r))),this.serializer=new Y3(t),this.d_=new sU(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.R_=!1,Promise.resolve()}get started(){return this.R_}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new iU,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.T_[e.toKey()];return r||(r=new oU(t,this.referenceDelegate),this.T_[e.toKey()]=r),r}getGlobalsCache(){return this.I_}getTargetCache(){return this.A_}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.d_}runTransaction(e,t,r){Ue("MemoryPersistence","Starting transaction:",e);const s=new dU(this.P_.next());return this.referenceDelegate.f_(),r(s).next((a=>this.referenceDelegate.m_(s).next((()=>a)))).toPromise().then((a=>(s.raiseOnCommittedEvent(),a)))}p_(e,t){return Ee.or(Object.values(this.T_).map((r=>()=>r.containsKey(e,t))))}}class dU extends rF{constructor(e){super(),this.currentSequenceNumber=e}}class Wx{constructor(e){this.persistence=e,this.g_=new Qx,this.y_=null}static w_(e){return new Wx(e)}get b_(){if(this.y_)return this.y_;throw ot(60996)}addReference(e,t,r){return this.g_.addReference(r,t),this.b_.delete(r.toString()),Ee.resolve()}removeReference(e,t,r){return this.g_.removeReference(r,t),this.b_.add(r.toString()),Ee.resolve()}markPotentiallyOrphaned(e,t){return this.b_.add(t.toString()),Ee.resolve()}removeTarget(e,t){this.g_.Xs(t.targetId).forEach((s=>this.b_.add(s.toString())));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next((s=>{s.forEach((a=>this.b_.add(a.toString())))})).next((()=>r.removeTargetData(e,t)))}f_(){this.y_=new Set}m_(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return Ee.forEach(this.b_,(r=>{const s=nt.fromPath(r);return this.S_(e,s).next((a=>{a||t.removeEntry(s,pt.min())}))})).next((()=>(this.y_=null,t.apply(e))))}updateLimboDocument(e,t){return this.S_(e,t).next((r=>{r?this.b_.delete(t.toString()):this.b_.add(t.toString())}))}V_(e){return 0}S_(e,t){return Ee.or([()=>Ee.resolve(this.g_.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.p_(e,t)])}}class Ng{constructor(e,t){this.persistence=e,this.v_=new Ec((r=>J3(r.path)),((r,s)=>r.isEqual(s))),this.garbageCollector=cF(this,t)}static w_(e,t){return new Ng(e,t)}f_(){}m_(e){return Ee.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}rr(e){const t=this.xs(e);return this.persistence.getTargetCache().getTargetCount(e).next((r=>t.next((s=>r+s))))}xs(e){let t=0;return this.ir(e,(r=>{t++})).next((()=>t))}ir(e,t){return Ee.forEach(this.v_,((r,s)=>this.Fs(e,r,s).next((a=>a?Ee.resolve():t(s)))))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0;const s=this.persistence.getRemoteDocumentCache(),a=s.newChangeBuffer();return s.u_(e,(c=>this.Fs(e,c,t).next((u=>{u||(r++,a.removeEntry(c,pt.min()))})))).next((()=>a.apply(e))).next((()=>r))}markPotentiallyOrphaned(e,t){return this.v_.set(t,e.currentSequenceNumber),Ee.resolve()}removeTarget(e,t){const r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.v_.set(r,e.currentSequenceNumber),Ee.resolve()}removeReference(e,t,r){return this.v_.set(r,e.currentSequenceNumber),Ee.resolve()}updateLimboDocument(e,t){return this.v_.set(t,e.currentSequenceNumber),Ee.resolve()}V_(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Km(e.data.value)),t}Fs(e,t,r){return Ee.or([()=>this.persistence.p_(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const s=this.v_.get(t);return Ee.resolve(s!==void 0&&s>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}/**
3422 * @license
3423 * Copyright 2017 Google LLC
3424 *
3425 * Licensed under the Apache License, Version 2.0 (the "License");
3426 * you may not use this file except in compliance with the License.
3427 * You may obtain a copy of the License at
3428 *
3429 *   http://www.apache.org/licenses/LICENSE-2.0
3430 *
3431 * Unless required by applicable law or agreed to in writing, software
3432 * distributed under the License is distributed on an "AS IS" BASIS,
3433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3434 * See the License for the specific language governing permissions and
3435 * limitations under the License.
3436 */class Xx{constructor(e,t,r,s){this.targetId=e,this.fromCache=t,this.Ao=r,this.Vo=s}static fo(e,t){let r=Dt(),s=Dt();for(const a of t.docChanges)switch(a.type){case 0:r=r.add(a.doc.key);break;case 1:s=s.add(a.doc.key)}return new Xx(e,t.fromCache,r,s)}}/**
3437 * @license
3438 * Copyright 2017 Google LLC
3439 *
3440 * Licensed under the Apache License, Version 2.0 (the "License");
3441 * you may not use this file except in compliance with the License.
3442 * You may obtain a copy of the License at
3443 *
3444 *   http://www.apache.org/licenses/LICENSE-2.0
3445 *
3446 * Unless required by applicable law or agreed to in writing, software
3447 * distributed under the License is distributed on an "AS IS" BASIS,
3448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3449 * See the License for the specific language governing permissions and
3450 * limitations under the License.
3451 */function hU(n,e){return nt.comparator(n.key,e.key)}/**
3452 * @license
3453 * Copyright 2023 Google LLC
3454 *
3455 * Licensed under the Apache License, Version 2.0 (the "License");
3456 * you may not use this file except in compliance with the License.
3457 * You may obtain a copy of the License at
3458 *
3459 *   http://www.apache.org/licenses/LICENSE-2.0
3460 *
3461 * Unless required by applicable law or agreed to in writing, softw
3461are
3462 * distributed under the License is distributed on an "AS IS" BASIS,
3463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3464 * See the License for the specific language governing permissions and
3465 * limitations under the License.
3466 */class fU{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}/**
3467 * @license
3468 * Copyright 2019 Google LLC
3469 *
3470 * Licensed under the Apache License, Version 2.0 (the "License");
3471 * you may not use this file except in compliance with the License.
3472 * You may obtain a copy of the License at
3473 *
3474 *   http://www.apache.org/licenses/LICENSE-2.0
3475 *
3476 * Unless required by applicable law or agreed to in writing, software
3477 * distributed under the License is distributed on an "AS IS" BASIS,
3478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3479 * See the License for the specific language governing permissions and
3480 * limitations under the License.
3481 */class mU{constructor(){this.mo=!1,this.po=!1,this.yo=100,this.wo=(function(){return xM()?8:sF(es())>0?6:4})()}initialize(e,t){this.bo=e,this.indexManager=t,this.mo=!0}getDocumentsMatchingQuery(e,t,r,s){const a={result:null};return this.So(e,t).next((c=>{a.result=c})).next((()=>{if(!a.result)return this.vo(e,t,s,r).next((c=>{a.result=c}))})).next((()=>{if(a.result)return;const c=new fU;return this.Do(e,t,c).next((u=>{if(a.result=u,this.po)return this.xo(e,t,c,u.size)}))})).next((()=>a.result))}xo(e,t,r,s){return Er(t)?Ee.resolve():r.documentReadCount<this.yo?(Bu()<=Ut.DEBUG&&Ue("QueryEngine","SDK will not create cache indexes for query:",ch(t),"since it only creates cache indexes for collection contains","more than or equal to",this.yo,"documents"),Ee.resolve()):(Bu()<=Ut.DEBUG&&Ue("QueryEngine","Query:",ch(t),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.wo*s?(Bu()<=Ut.DEBUG&&Ue("QueryEngine","The SDK decides to create cache indexes for query:",ch(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,ta(t))):Ee.resolve())}So(e,t){if(Er(t))return Ee.resolve(null);let r=t;if(H_(r))return Ee.resolve(null);let s=ta(r);return this.indexManager.getIndexType(e,s).next((a=>a===0?null:(r.limit!==null&&a===1&&(r=wg(r,null,"F"),s=ta(r)),this.indexManager.getDocumentsMatchingTarget(e,s).next((c=>{const u=Dt(...c);return this.bo.getDocuments(e,u).next((h=>this.indexManager.getMinOffset(e,s).next((f=>{const p=this.Co(r,h);return this.Fo(r,p,u,f.readTime)?this.So(e,wg(r,null,"F")):this.Oo(e,p,r,f)}))))})))))}vo(e,t,r,s){return(Er(t)?(function(c){for(const u of c.stages){if(u instanceof xc||u instanceof iT)return!1;if(u instanceof Bp){if(u.condition instanceof g1&&u.condition._expr.name==="exists"&&u.condition._expr.params[0]instanceof Gu&&u.condition._expr.params[0].fieldName===Yi)continue;return!1}}return!0})(t):H_(t))||s.isEqual(pt.min())?Ee.resolve(null):this.bo.getDocuments(e,r).next((a=>{const c=this.Co(t,a);return this.Fo(t,c,r,s)?Ee.resolve(null):(Bu()<=Ut.DEBUG&&Ue("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),aT(t)),this.Oo(e,c,t,t5(s,Dh)).next((u=>u)))}))}Co(e,t){let r,s;return Er(e)?(r=new yr(hU),s=a=>bp(e,a)):(r=new yr(Dx(e)),s=a=>cp(e,a)),t.forEach(((a,c)=>{s(c)&&(r=r.add(c))})),r}Fo(e,t,r,s){if(Er(e))return(function(u){return u.stages.some((h=>h instanceof xc||h instanceof iT))})(e);if(e.limit===null)return!1;if(r.size!==t.size)return!0;const a=e.limitType==="F"?t.last():t.first();return!!a&&(a.hasPendingWrites||a.version.compareTo(s)>0)}Do(e,t,r){return Bu()<=Ut.DEBUG&&Ue("QueryEngine","Using full collection scan to execute query:",aT(t)),this.bo.getDocumentsMatchingQuery(e,t,sl.min(),r)}Oo(e,t,r,s){return this.bo.getDocumentsMatchingQuery(e,r,s).next((a=>(t.forEach((c=>{a=a.insert(c.key,c)})),a)))}}/**
3482 * @license
3483 * Copyright 2020 Google LLC
3484 *
3485 * Licensed under the Apache License, Version 2.0 (the "License");
3486 * you may not use this file except in compliance with the License.
3487 * You may obtain a copy of the License at
3488 *
3489 *   http://www.apache.org/licenses/LICENSE-2.0
3490 *
3491 * Unless required by applicable law or agreed to in writing, softw
3491are
3492 * distributed under the License is distributed on an "AS IS" BASIS,
3493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3494 * See the License for the specific language governing permissions and
3495 * limitations under the License.
3496 */const Zx="LocalStore",gU=3e8;class pU{constructor(e,t,r,s){this.persistence=e,this.Mo=t,this.serializer=s,this.No=new Fn(Lt),this.Lo=new Ec((a=>N1(a)),S1),this.Bo=new Map,this.Uo=e.getRemoteDocumentCache(),this.A_=e.getTargetCache(),this.d_=e.getBundleCache(),this.ko(r)}ko(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new rU(this.Uo,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Uo.setIndexManager(this.indexManager),this.Mo.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.No)))}}function BU(n,e,t,r){return new pU(n,e,t,r)}async function R1(n,e){const t=xt(n);return await t.persistence.runTransaction("Handle user change","readonly",(r=>{let s;return t.mutationQueue.getAllMutationBatches(r).next((a=>(s=a,t.ko(e),t.mutationQueue.getAllMutationBatches(r)))).next((a=>{const c=[],u=[];let h=Dt();for(const f of s){c.push(f.batchId);for(const p of f.mutations)h=h.add(p.key)}for(const f of a){u.push(f.batchId);for(const p of f.mutations)h=h.add(p.key)}return t.localDocuments.getDocuments(r,h).next((f=>({qo:f,removedBatchIds:c,addedBatchIds:u})))}))}))}function yU(n,e){const t=xt(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",(r=>{const s=e.batch.keys(),a=t.Uo.newChangeBuffer({trackRemovals:!0});return(function(u,h,f,p){const y=f.batch,b=y.keys();let w=Ee.resolve();return b.forEach((E=>{w=w.next((()=>p.getEntry(h,E))).next((N=>{const S=f.docVersions.get(E);Xe(S!==null,48541),N.version.compareTo(S)<0&&(y.applyToRemoteDocument(N,f),N.isValidDocument()&&(N.setReadTime(f.commitVersion),p.addEntry(N)))}))})),w.next((()=>u.mutationQueue.removeMutationBatch(h,y)))})(t,r,e,a).next((()=>a.apply(r))).next((()=>t.mutationQueue.performConsistencyCheck(r))).next((()=>t.documentOverlayCache.removeOverlaysForBatchId(r,s,e.batch.batchId))).next((()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,(function(u){let h=Dt();for(let f=0;f<u.mutationResults.length;++f)u.mutationResults[f].transformResults.length>0&&(h=h.add(u.batch.mutations[f].key));return h})(e)))).next((()=>t.localDocuments.getDocuments(r,s)))}))}function P1(n){const e=xt(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.A_.getLastRemoteSnapshotVersion(t)))}function xU(n,e){const t=xt(n),r=e.snapshotVersion;let s=t.No;return t.persistence.runTransaction("Apply remote event","readwrite-primary",(a=>{const c=t.Uo.newChangeBuffer({trackRemovals:!0});s=t.No;const u=[];
3496e.targetChanges.forEach(((p,y)=>{const b=s.get(y);if(!b)return;u.push(t.A_.removeMatchingKeys(a,p.removedDocuments,y).next((()=>t.A_.addMatchingKeys(a,p.addedDocuments,y))));let w=b.withSequenceNumber(a.currentSequenceNumber);e.targetMismatches.get(y)!==null?w=w.withResumeToken(xr.EMPTY_BYTE_STRING,pt.min()).withLastLimboFreeSnapshotVersion(pt.min()):p.resumeToken.approximateByteSize()>0&&(w=w.withResumeToken(p.resumeToken,r)),s=s.insert(y,w),(function(N,S,I){return N.resumeToken.approximateByteSize()===0||S.snapshotVersion.toMicroseconds()-N.snapshotVersion.toMicroseconds()>=gU?!0:I.addedDocuments.size+I.modifiedDocuments.size+I.removedDocuments.size>0})(b,w,p)&&u.push(t.A_.updateTargetData(a,w))}));let h=Ns(),f=Dt();if(e.documentUpdates.forEach((p=>{e.resolvedLimboDocuments.has(p)&&u.push(t.persistence.referenceDelegate.updateLimboDocument(a,p))})),u.push(CU(a,c,e.documentUpdates).next((p=>{h=p.$o,f=p.Ko}))),!r.isEqual(pt.min())){const p=t.A_.getLastRemoteSnapshotVersion(a).next((y=>t.A_.setTargetsMetadata(a,a.currentSequenceNumber,r)));u.push(p)}return Ee.waitFor(u).next((()=>c.apply(a))).next((()=>t.localDocuments.getLocalViewOfDocuments(a,h,f))).next((()=>h))})).then((a=>(t.No=s,a)))}function CU(n,e,t){let r=Dt(),s=Dt();return t.forEach((a=>r=r.add(a))),e.getEntries(n,r).next((a=>{let c=Ns();return t.forEach(((u,h)=>{const f=a.get(u);h.isFoundDocument()!==f.isFoundDocument()&&(s=s.add(u)),h.isNoDocument()&&h.version.isEqual(pt.min())?(e.removeEntry(u,h.readTime),c=c.insert(u,h)):!f.isValidDocument()||h.version.compareTo(f.version)>0||h.version.compareTo(f.version)===0&&f.hasPendingWrites?(e.addEntry(h),c=c.insert(u,h)):Ue(Zx,"Ignoring outdated watch update for ",u,". Current version:",f.version," Watch version:",h.version)})),{$o:c,Ko:s}}))}function bU(n,e){const t=xt(n);return t.persistence.runTransaction("Get next mutation batch","readonly",(r=>(e===void 0&&(e=Tx),t.mutationQueue.getNextMutationBatchAfterBatchId(r,e))))}function vU(n,e){const t=xt(n);return t.persistence.runTransaction("Allocate target","readwrite",(r=>{let s;return t.A_.getTargetData(r,e).next((a=>a?(s=a,Ee.resolve(s)):t.A_.allocateTargetId(r).next((c=>(s=new Oa(e,c,"TargetPurposeListen",r.currentSequenceNumber),t.A_.addTargetData(r,s).next((()=>s)))))))})).then((r=>{const s=t.No.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.No=t.No.insert(r.targetId,r),t.Lo.set(e,r.targetId)),r}))}async function Fy(n,e,t){const r=xt(n),s=r.No.get(e),a=t?"readwrite":"readwrite-primary";try{t||await r.persistence.runTransaction("Release target",a,(c=>r.persistence.referenceDelegate.removeTarget(c,s)))}catch(c){if(!Vu(c))throw c;Ue(Zx,`Failed to update sequence numbers for target ${e}: ${c}`)}r.No=r.No.remove(e),r.Lo.delete(s.target)}function lT(n,e,t){const r=xt(n);let s=pt.min(),a=Dt();return r.persistence.runTransaction("Execute query","readwrite",(c=>(function(h,f,p){const y=xt(h),b=y.Lo.get(p);return b!==void 0?Ee.resolve(y.No.get(b)):y.A_.getTargetData(f,p)})(r,c,Er(e)?e:ta(e)).next((u=>{if(u)return s=u.lastLimboFreeSnapshotVersion,r.A_.getMatchingKeysForTargetId(c,u.targetId).next((h=>{a=h}))})).next((()=>r.Mo.getDocumentsMatchingQuery(c,e,t?s:pt.min(),t?a:Dt()))).next((u=>(wU(r,u),{documents:u,Qo:a})))))}function wU(n,e){e.forEach(((t,r)=>{const s=r.key.getCollectionGroup(),a=n.Bo.get(s)||pt.min();r.readTime.compareTo(a)>0&&n.Bo.set(s,r.readTime)}))}/**
3497 * @license
3498 * Copyright 2020 Google LLC
3499 *
3500 * Licensed under the Apache License, Version 2.0 (the "License");
3501 * you may not use this file except in compliance with the License.
3502 * You may obtain a copy of the License at
3503 *
3504 *   http://www.apache.org/licenses/LICENSE-2.0
3505 *
3506 * Unless required by applicable law or agreed to in writing, software
3507 * distributed under the License is distributed on an "AS IS" BASIS,
3508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3509 * See the License for the specific language governing permissions and
3510 * limitations under the License.
3511 */class EU{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.Jo=0,this.Yo=null,this.Zo=!0}Xo(){this.Jo===0&&(this.ea("Unknown"),this.Yo=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.Yo=null,this.ta("Backend didn't respond within 10 seconds."),this.ea("Offline"),Promise.resolve()))))}na(e){this.state==="Online"?this.ea("Unknown"):(this.Jo++,this.Jo>=1&&(this.ra(),this.ta(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ea("Offline")))}set(e){this.ra(),this.Jo=0,e==="Online"&&(this.Zo=!1),this.ea(e)}ea(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}ta(e){const t=`Could not reach Cloud Firestore backend. ${e}
3512This 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.Zo?(za(t),this.Zo=!1):Ue("OnlineStateTracker",t)}ra(){this.Yo!==null&&(this.Yo.cancel(),this.Yo=null)}}/**
3513 * @license
3514 * Copyright 2017 Google LLC
3515 *
3516 * Licensed under the Apache License, Version 2.0 (the "License");
3517 * you may not use this file except in compliance with the License.
3518 * You may obtain a copy of the License at
3519 *
3520 *   http://www.apache.org/licenses/LICENSE-2.0
3521 *
3522 * Unless required by applicable law or agreed to in writing, software
3523 * distributed under the License is distributed on an "AS IS" BASIS,
3524 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3525 * See the License for the specific language governing permissions and
3526 * limitations under the License.
3527 */const ia="RemoteStore";class _U{constructor(e,t,r,s,a){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.ia=[],this.sa=new Map,this._a=new Map,this.oa=new Map,this.aa=new ll(1e3),this.ua=new ll(1001),this.ca=new Set,this.la=[],this.Ea=a,this.Ea.Ke((c=>{r.enqueueAndForget((async()=>{Tc(this)&&(Ue(ia,"Restarting streams for network reachability change."),await(async function(h){const f=xt(h);f.ca.add(4),await Zh(f),f.ha.set("Unknown"),f.ca.delete(4),await vp(f)})(this))}))})),this.ha=new EU(r,s)}}async function vp(n){if(Tc(n))for(const e of n.la)await e(!0)}async function Zh(n){for(const e of n.la)await e(!1)}function Uy(n,e){return n._a.get(e)||void 0}function M1(n,e){const t=xt(n),r=Uy(t,e.targetId);if(r!==void 0&&t.sa.has(r))return;const s=(function(u,h){const f=Uy(u,h);f!==void 0&&u.oa.delete(f);const p=(function(b,w){return w%2!=0?b.ua.next():b.aa.next()})(u,h);return u._a.set(h,p),u.oa.set(p,h),p})(t,e.targetId);Ue(ia,"remoteStoreListen mapping SDK target ID to remote",e.targetId,s);const a=new Oa(e.target,s,e.purpose,e.sequenceNumber,e.snapshotVersion,e.lastLimboFreeSnapshotVersion,e.resumeToken);t.sa.set(s,a),rC(t)?nC(t):Ju(t).Jt()&&tC(t,a)}function eC(n,e){const t=xt(n),r=Ju(t),s=Uy(t,e);Ue(ia,"remoteStoreUnlisten removing mapping of SDK target ID to remote",e,s),t.sa.delete(s),t._a.delete(e),t.oa.delete(s),r.Jt()&&L1(t,s),t.sa.size===0&&(r.Jt()?r.Xt():Tc(t)&&t.ha.set("Unknown"))}function tC(n,e){if(n.Ta.H(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(pt.min())>0){const t=n.oa.get(e.targetId);if(t===void 0)return void Ue(ia,"SDK target ID not found for remote ID: "+e.targetId);const r=n.remoteSyncer.getRemoteKeysForTarget(t).size;e=e.withExpectedCount(r)}Ju(n).Tn(e)}function L1(n,e){n.Ta.H(e),Ju(n).Pn(e)}function nC(n){n.Ta=new x5({getRemoteKeysForTarget:e=>{const t=n.oa.get(e);return t!==void 0?n.remoteSyncer.getRemoteKeysForTarget(t):Dt()},ge:e=>n.sa.get(e)||null,Ae:()=>n.datastore.serializer.databaseId}),Ju(n).start(),n.ha.Xo()}function rC(n){return Tc(n)&&!Ju(n).Ht()&&n.sa.size>0}function Tc(n){return xt(n).ca.size===0}function j1(n){n.Ta=void 0}async function TU(n){n.ha.set("Online")}async function kU(n){n.sa.forEach(((e,t)=>{tC(n,e)}))}async function NU(n,e){j1(n),rC(n)?(n.ha.na(e),nC(n)):n.ha.set("Unknown")}async function SU(n,e,t){if(n.ha.set("Online"),e instanceof qD&&e.state===2&&e.cause)try{await(async function(s,a){const c=a.cause;for(const u of a.targetIds){if(s.sa.has(u)){const h=s.oa.get(u);h!==void 0&&(await s.remoteSyncer.rejectListen(h,c),s._a.delete(h),s.oa.delete(u)),s.sa.delete(u)}s.Ta.removeTarget(u)}})(n,e)}catch(r){Ue(ia,"Failed to remove targets %s: %s ",e.targetIds.join(","),r),await Sg(n,r)}else if(e instanceof Qm?n.Ta.se(e):e instanceof HD?n.Ta.Ee(e):n.Ta.ae(e),!t.isEqual(pt.min()))try{const r=await P1(n.localStore);t.compareTo(r)>=0&&await(function(a,c){const u=a.Ta.de(c);
vendor: 4,249 bytes, lines 3527-3546
3527u.targetChanges.forEach(((f,p)=>{if(f.resumeToken.approximateByteSize()>0){const y=a.sa.get(p);y&&a.sa.set(p,y.withResumeToken(f.resumeToken,c))}})),u.targetMismatches.forEach(((f,p)=>{const y=a.sa.get(f);if(!y)return;a.sa.set(f,y.withResumeToken(xr.EMPTY_BYTE_STRING,y.snapshotVersion)),L1(a,f);const b=new Oa(y.target,f,p,y.sequenceNumber);tC(a,b)}));const h=(function(p,y){const b=new Map;y.targetChanges.forEach(((E,N)=>{const S=p.oa.get(N);S!==void 0&&b.set(S,E)}));let w=new Fn(Lt);return y.targetMismatches.forEach(((E,N)=>{const S=p.oa.get(E);S!==void 0&&(w=w.insert(S,N))})),new Qh(y.snapshotVersion,b,w,y.documentUpdates,y.augmentedDocumentUpdates,y.resolvedLimboDocuments)})(a,u);return a.remoteSyncer.applyRemoteEvent(h)})(n,t)}catch(r){Ue(ia,"Failed to raise snapshot:",r),await Sg(n,r)}}async function Sg(n,e,t){if(!Vu(e))throw e;n.ca.add(1),await Zh(n),n.ha.set("Offline"),t||(t=()=>P1(n.localStore)),n.asyncQueue.enqueueRetryable((async()=>{Ue(ia,"Retrying IndexedDB access"),await t(),n.ca.delete(1),await vp(n)}))}function O1(n,e){return e().catch((t=>Sg(n,t,e)))}async function wp(n){const e=xt(n),t=cl(e);let r=e.ia.length>0?e.ia[e.ia.length-1].batchId:Tx;for(;DU(e);)try{const s=await bU(e.localStore,r);if(s===null){e.ia.length===0&&t.Xt();break}r=s.batchId,AU(e,s)}catch(s){await Sg(e,s)}F1(e)&&U1(e)}function DU(n){return Tc(n)&&n.ia.length<10}function AU(n,e){n.ia.push(e);const t=cl(n);t.Jt()&&t.Rn&&t.In(e.mutations)}function F1(n){return Tc(n)&&!cl(n).Ht()&&n.ia.length>0}function U1(n){cl(n).start()}async function IU(n){cl(n).dn()}async function RU(n){const e=cl(n);for(const t of n.ia)e.In(t.mutations)}async function PU(n,e,t){const r=n.ia.shift(),s=Yx.from(r,e,t);await O1(n,(()=>n.remoteSyncer.applySuccessfulWrite(s))),await wp(n)}async function MU(n,e){e&&cl(n).Rn&&await(async function(r,s){if((function(c){return d5(c)&&c!==ve.ABORTED})(s.code)){const a=r.ia.shift();cl(r).Zt(),await O1(r,(()=>r.remoteSyncer.rejectFailedWrite(a.batchId,s))),await wp(r)}})(n,e),F1(n)&&U1(n)}async function cT(n,e){const t=xt(n);t.asyncQueue.verifyOperationInProgress(),Ue(ia,"RemoteStore received new credentials");const r=Tc(t);t.ca.add(3),await Zh(t),r&&t.ha.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.ca.delete(3),await vp(t)}async function LU(n,e){const t=xt(n);e?(t.ca.delete(2),await vp(t)):e||(t.ca.add(2),await Zh(t),t.ha.set("Unknown"))}function Ju(n){return n.Pa||(n.Pa=(function(t,r,s){const a=xt(t);return a.mn(),new Y5(r,a.connection,a.authCredentials,a.appCheckCredentials,a.serializer,s)})(n.datastore,n.asyncQueue,{ut:TU.bind(null,n),lt:kU.bind(null,n),ht:NU.bind(null,n),hn:SU.bind(null,n)}),n.la.push((async e=>{e?(n.Pa.Zt(),rC(n)?nC(n):n.ha.set("Unknown")):(await n.Pa.stop(),j1(n))}))),n.Pa}function cl(n){return n.Ra||(n.Ra=(function(t,r,s){const a=xt(t);return a.mn(),new Q5(r,a.connection,a.authCredentials,a.appCheckCredentials,a.serializer,s)})(n.datastore,n.asyncQueue,{ut:()=>Promise.resolve(),lt:IU.bind(null,n),ht:MU.bind(null,n),An:RU.bind(null,n),Vn:PU.bind(null,n)}),n.la.push((async e=>{e?(n.Ra.Zt(),await wp(n)):(await n.Ra.stop(),n.ia.length>0&&(Ue(ia,`Stopping write stream with ${n.ia.length} pending writes`),n.ia=[]))}))),n.Ra}/**
3528 * @license
3529 * Copyright 2017 Google LLC
3530 *
3531 * Licensed under the Apache License, Version 2.0 (the "License");
3532 * you may not use this file except in compliance with the License.
3533 * You may obtain a copy of the License at
3534 *
3535 *   http://www.apache.org/licenses/LICENSE-2.0
3536 *
3537 * Unless required by applicable law or agreed to in writing, software
3538 * distributed under the License is distributed on an "AS IS" BASIS,
3539 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3540 * See the License for the specific language governing permissions and
3541 * limitations under the License.
3542 */class sC{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ia(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ia(this.observer.error,e):za("Uncaught Error in snapshot listener:",e.toString()))}Aa(){this.muted=!0}Ia(e,t){setTimeout((()=>{this.muted||e(t)}),0)}}/**
3543 * @license
3544 * Copyright 2017 Google LLC
3545 *
3546 * Licensed under the Apache License, Version 2.0 (the "License");
3547 * you may not use this file except in compliance with the License.
3548 * You may obtain a copy of the License at
3549 *
3550 *   http://www.apache.org/licenses/LICENSE-2.0
3551 *
3552 * Unless required by applicable law or agreed to in writing, software
3553 * distributed under the License is distributed on an "AS IS" BASIS,
3554 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3555 * See the License for the specific language governing permissions and
3556 * limitations under the License.
3557 */class iC{constructor(e,t,r,s,a){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=s,this.removalCallback=a,this.deferred=new Ua,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((c=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,s,a){const c=Date.now()+r,u=new iC(e,t,c,s,a);return u.start(r),u}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new Fe(ve.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then((e=>this.deferred.resolve(e)))):Promise.resolve()))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function aC(n,e){if(za("AsyncQueue",`${e}: ${n}`),Vu(n))return new Fe(ve.UNAVAILABLE,`${e}: ${n}`);throw n}class uT{constructor(){this.activeTargetIds=p5()}La(e){this.activeTargetIds=this.activeTargetIds.add(e)}Ba(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Na(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class jU{constructor(){this.du=new uT,this.fu={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.du.La(e),this.fu[e]||"not-current"}updateQueryState(e,t,r){this.fu[e]=t}removeLocalQueryTarget(e){this.du.Ba(e)}isLocalQueryTarget(e){return this.du.activeTargetIds.has(e)}clearQueryState(e){delete this.fu[e]}getAllActiveQueryTargets(){return this.du.activeTargetIds}isActiveQueryTarget(e){return this.du.activeTargetIds.has(e)}start(){return this.du=new uT,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}function WB(){return typeof document<"u"?document:null}/**
3558 * @license
3559 * Copyright 2017 Google LLC
3560 *
3561 * Licensed under the Apache License, Version 2.0 (the "License");
3562 * you may not use this file except in compliance with the License.
3563 * You may obtain a copy of the License at
3564 *
3565 *   http://www.apache.org/licenses/LICENSE-2.0
3566 *
3567 * Unless required by applicable law or agreed to in writing, software
3568 * distributed under the License is distributed on an "AS IS" BASIS,
3569 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3570 * See the License for the specific language governing permissions and
3571 * limitations under the License.
3572 */class ic{static emptySet(e){return new ic(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||nt.comparator(t.key,r.key):(t,r)=>nt.comparator(t.key,r.key),this.keyedMap=xu(),this.sortedSet=new Fn(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal(((t,r)=>(e(t),!1)))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof ic)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){const s=t.getNext().key,a=r.getNext().key;if(!s.isEqual(a))return!1}return!0}toString(){const e=[];return this.forEach((t=>{e.push(t.toString())})),e.length===0?"DocumentSet ()":`DocumentSet (
3573  `+e.join(`  
3574`)+`
3575)`}copy(e,t){const r=new ic;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}/**
3576 * @license
3577 * Copyright 2017 Google LLC
3578 *
3579 * Licensed under the Apache License, Version 2.0 (the "License");
3580 * you may not use this file except in compliance with the License.
3581 * You may obtain a copy of the License at
3582 *
3583 *   http://www.apache.org/licenses/LICENSE-2.0
3584 *
3585 * Unless required by applicable law or agreed to in writing, software
3586 * distributed under the License is distributed on an "AS IS" BASIS,
3587 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3588 * See the License for the specific language governing permissions and
3589 * limitations under the License.
3590 */class dT{constructor(){this.mu=new Fn(nt.comparator)}track(e){const t=e.doc.key,r=this.mu.get(t);r?e.type!==0&&r.type===3?this.mu=this.mu.insert(t,e):e.type===3&&r.type!==1?this.mu=this.mu.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.mu=this.mu.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.mu=this.mu.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.mu=this.mu.remove(t):e.type===1&&r.type===2?this.mu=this.mu.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.mu=this.mu.insert(t,{type:2,doc:e.doc}):ot(63341,{ye:e,pu:r}):this.mu=this.mu.insert(t,e)}gu(){const e=[];return this.mu.inorderTraversal(((t,r)=>{e.push(r)})),e}}class Lu{constructor(e,t,r,s,a,c,u,h,f){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=a,this.fromCache=c,this.syncStateChanged=u,this.excludesMetadataChanges=h,this.hasCachedResults=f}static fromInitialDocuments(e,t,r,s,a){const c=[];return t.forEach((u=>{c.push({type:0,doc:u})})),new Lu(e,t,ic.emptySet(t),c,r,s,!0,!1,a)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Cp(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==r[s].type||!t[s].doc.isEqual(r[s].doc))return!1;return!0}}/**
3591 * @license
3592 * Copyright 2017 Google LLC
3593 *
3594 * Licensed under the Apache License, Version 2.0 (the "License");
3595 * you may not use this file except in compliance with the License.
3596 * You may obtain a copy of the License at
3597 *
3598 *   http://www.apache.org/licenses/LICENSE-2.0
3599 *
3600 * Unless required by applicable law or agreed to in writing, software
3601 * distributed under the License is distributed on an "AS IS" BASIS,
3602 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3603 * See the License for the specific language governing permissions and
3604 * limitations under the License.
3605 */class OU{constructor(){this.yu=void 0,this.wu=[]}bu(){return this.wu.some((e=>e.Su()))}}class FU{constructor(){this.queries=hT(),this.onlineState="Unknown",this.vu=new Set}terminate(){(function(t,r){const s=xt(t),a=s.queries;s.queries=hT(),a.forEach(((c,u)=>{for(const h of u.wu)h.onError(r)}))})(this,new Fe(ve.ABORTED,"Firestore shutting down"))}}function hT(){return new Ec((n=>k1(n)),Cp)}async function oC(n,e){const t=xt(n);let r=3;const s=e.query;let a=t.queries.get(s);a?!a.bu()&&e.Su()&&(r=2):(a=new OU,r=e.Su()?0:1);try{switch(r){case 0:a.yu=await t.onListen(s,!0);break;case 1:a.yu=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(c){const u=aC(c,`Initialization of query '${Er(e.query)?Va(e.query):ch(e.query)}' failed`);return void e.onError(u)}t.queries.set(s,a),a.wu.push(e),e.Du(t.onlineState),a.yu&&e.xu(a.yu)&&cC(t)}async function lC(n,e){const t=xt(n),r=e.query;let s=3;const a=t.queries.get(r);if(a){const c=a.wu.indexOf(e);c>=0&&(a.wu.splice(c,1),a.wu.length===0?s=e.Su()?0:1:!a.bu()&&e.Su()&&(s=2))}switch(s){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}}function UU(n,e){const t=xt(n);let r=!1;for(const s of e){const a=s.query,c=t.queries.get(a);if(c){for(const u of c.wu)u.xu(s)&&(r=!0);c.yu=s}}r&&cC(t)}function VU(n,e,t){const r=xt(n),s=r.queries.get(e);if(s)for(const a of s.wu)a.onError(t);r.queries.delete(e)}function cC(n){n.vu.forEach((e=>{e.next()}))}var Vy;(function(n){n.Default="default",n.Cache="cache"})(Vy||(Vy={}));class uC{constructor(e,t,r){this.query=e,this.Cu=t,this.Fu=!1,this.Ou=null,this.onlineState="Unknown",this.options=r||{}}xu(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new Lu(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Fu?this.Mu(e)&&(this.Cu.next(e),t=!0):this.Nu(e,this.onlineState)&&(this.Lu(e),t=!0),this.Ou=e,t}onError(e){this.Cu.error(e)}Du(e){this.onlineState=e;let t=!1;return this.Ou&&!this.Fu&&this.Nu(this.Ou,e)&&(this.Lu(this.Ou),t=!0),t}Nu(e,t){if(!e.fromCache||!this.Su())return!0;const r=t!=="Offline";
vendor: 4,544 bytes, lines 3605-3620
3605return(!this.options.waitForSyncWhenOnline||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}Mu(e){if(e.docChanges.length>0)return!0;const t=this.Ou&&this.Ou.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}Lu(e){e=Lu.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Fu=!0,this.Cu.next(e)}Su(){return this.options.source!==Vy.Cache}}/**
3606 * @license
3607 * Copyright 2017 Google LLC
3608 *
3609 * Licensed under the Apache License, Version 2.0 (the "License");
3610 * you may not use this file except in compliance with the License.
3611 * You may obtain a copy of the License at
3612 *
3613 *   http://www.apache.org/licenses/LICENSE-2.0
3614 *
3615 * Unless required by applicable law or agreed to in writing, software
3616 * distributed under the License is distributed on an "AS IS" BASIS,
3617 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3618 * See the License for the specific language governing permissions and
3619 * limitations under the License.
3620 */class V1{constructor(e){this.key=e}}class G1{constructor(e){this.key=e}}class GU{constructor(e,t){this.query=e,this.Gu=t,this.zu=null,this.hasCachedResults=!1,this.current=!1,this.ju=Dt(),this.mutatedKeys=Dt(),this.Hu=Er(e)?Oy(e):Dx(e),this.Ju=new ic(this.Hu)}get Yu(){return this.Gu}Zu(e,t){const r=t?t.Xu:new dT,s=t?t.Ju:this.Ju;let a=t?t.mutatedKeys:this.mutatedKeys,c=s,u=!1;const[h,f]=this.ec(this.query,s);e.inorderTraversal(((y,b)=>{const w=s.get(y),E=Z3(this.query,b)?b:null,N=!!w&&this.mutatedKeys.has(w.key),S=!!E&&(E.hasLocalMutations||this.mutatedKeys.has(E.key)&&E.hasCommittedMutations);let I=!1;w&&E?w.data.isEqual(E.data)?N!==S&&(r.track({type:3,doc:E}),I=!0):this.tc(w,E)||(r.track({type:2,doc:E}),I=!0,(h&&this.Hu(E,h)>0||f&&this.Hu(E,f)<0)&&(u=!0)):!w&&E?(r.track({type:0,doc:E}),I=!0):w&&!E&&(r.track({type:1,doc:w}),I=!0,(h||f)&&(u=!0)),I&&(E?(c=c.add(E),a=S?a.add(y):a.delete(y)):(c=c.delete(y),a=a.delete(y)))}));const p=this.nc(this.query);if(p)if(Er(this.query)){const y=[];c.forEach((E=>y.push(E)));const b=A1(this.query,y);let w=new ic(Oy(this.query));for(const E of b)w=w.add(E);c.forEach((E=>{w.has(E.key)||(a=a.delete(E.key),r.track({type:1,doc:E}))})),c=w}else{const y=this.rc(this.query);for(;c.size>p;){const b=y==="F"?c.last():c.first();c=c.delete(b.key),a=a.delete(b.key),r.track({type:1,doc:b})}}return{Ju:c,Xu:r,Fo:u,mutatedKeys:a}}nc(e){var t;return Er(e)?(t=QB(e))==null?void 0:t.limit:e.limit||void 0}rc(e){if(Er(e)){const t=QB(e);return t&&t.limit<0?"L":"F"}return e.limitType}ec(e,t){var r;if(Er(e)){const s=(r=QB(e))==null?void 0:r.limit;return[t.size===s?t.last():null,null]}return[e.limitType==="F"&&t.size===this.nc(this.query)?t.last():null,e.limitType==="L"&&t.size===this.nc(this.query)?t.first():null]}tc(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,s){const a=this.Ju;this.Ju=e.Ju,this.mutatedKeys=e.mutatedKeys;const c=e.Xu.gu();c.sort(((p,y)=>(function(w,E){const N=S=>{switch(S){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return ot(20277,{ye:S})}};return N(w)-N(E)})(p.type,y.type)||this.Hu(p.doc,y.doc))),this.sc(r),s=s??!1;const u=t&&!s?this._c():[],h=this.ju.size===0&&this.current&&!s?1:0,f=h!==this.zu;return this.zu=h,c.length!==0||f?{snapshot:new Lu(this.query,e.Ju,a,c,e.mutatedKeys,h===0,f,!1,!!r&&r.resumeToken.approximateByteSize()>0),oc:u}:{oc:u}}Du(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({Ju:this.Ju,Xu:new dT,mutatedKeys:this.mutatedKeys,Fo:!1},!1)):{oc:[]}}ac(e){return!this.Gu.has(e)&&!!this.Ju.has(e)&&!this.Ju.get(e).hasLocalMutations}sc(e){e&&(e.addedDocuments.forEach((t=>this.Gu=this.Gu.add(t))),e.modifiedDocuments.forEach((t=>{})),e.removedDocuments.forEach((t=>this.Gu=this.Gu.delete(t))),this.current=e.current)}_c(){if(!this.current)return[];const e=this.ju;this.ju=Dt(),this.Ju.forEach((r=>{this.ac(r.key)&&(this.ju=this.ju.add(r.key))}));const t=[];return e.forEach((r=>{this.ju.has(r)||t.push(new G1(r))})),this.ju.forEach((r=>{e.has(r)||t.push(new V1(r))})),t}uc(e){this.Gu=e.Qo,this.ju=Dt();const t=this.Zu(e.documents);return this.applyChanges(t,!0)}cc(){return Lu.fromInitialDocuments(this.query,this.Ju,this.mutatedKeys,this.zu===0,this.hasCachedResults)}}const dC="SyncEngine";class HU{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class qU{constructor(e){this.key=e,this.lc=!1}}class zU{constructor(e,t,r,s,a,c){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedCl
3620ientState=s,this.currentUser=a,this.maxConcurrentLimboResolutions=c,this.Ec={},this.hc=new Ec((u=>k1(u)),Cp),this.Tc=new Map,this.Pc=new Set,this.Rc=new Fn(nt.comparator),this.Ic=new Map,this.Ac=new Qx,this.Vc={},this.dc=new Map,this.fc=ll.ws(),this.onlineState="Unknown",this.mc=void 0}get isPrimaryClient(){return this.mc===!0}}async function JU(n,e,t=!0){const r=K1(n);let s;const a=r.hc.get(e);return a?(r.sharedClientState.addLocalQueryTarget(a.targetId),s=a.view.cc()):s=await H1(r,e,t,!0),s}async function $U(n,e){const t=K1(n);await H1(t,e,!0,!1)}async function H1(n,e,t,r){const s=await vU(n.localStore,Er(e)?e:ta(e)),a=s.targetId,c=n.sharedClientState.addLocalQueryTarget(a,t);let u;return r&&(u=await KU(n,e,a,c==="current",s.resumeToken)),n.isPrimaryClient&&t&&M1(n.remoteStore,s),u}async function KU(n,e,t,r,s){n.gc=(y,b,w)=>(async function(N,S,I,O){let F=S.view.Zu(I);F.Fo&&(F=await lT(N.localStore,S.query,!1).then((({documents:D})=>S.view.Zu(D,F))));const J=O&&O.targetChanges.get(S.targetId),z=O&&O.targetMismatches.get(S.targetId)!=null,U=S.view.applyChanges(F,N.isPrimaryClient,J,z);return mT(N,S.targetId,U.oc),U.snapshot})(n,y,b,w);const a=await lT(n.localStore,e,!0),c=new GU(e,a.Qo),u=c.Zu(a.documents),h=Wh.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),f=c.applyChanges(u,n.isPrimaryClient,h);mT(n,t,f.oc);const p=new HU(e,t,c);return n.hc.set(e,p),n.Tc.has(t)?n.Tc.get(t).push(e):n.Tc.set(t,[e]),f.snapshot}async function YU(n,e,t){const r=xt(n),s=r.hc.get(e),a=r.Tc.get(s.targetId);if(a.length>1)return r.Tc.set(s.targetId,a.filter((c=>!Cp(c,e)))),void r.hc.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedCl
3620ientState.isActiveQueryTarget(s.targetId)||await Fy(r.localStore,s.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(s.targetId),t&&eC(r.remoteStore,s.targetId),Gy(r,s.targetId)})).catch(Uu)):(Gy(r,s.targetId),await Fy(r.localStore,s.targetId,!0))}async function QU(n,e){const t=xt(n),r=t.hc.get(e),s=t.Tc.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),eC(t.remoteStore,r.targetId))}async function WU(n,e,t){const r=s6(n);try{const s=await(function(c,u){const h=xt(c),f=An.now(),p=u.reduce(((w,E)=>w.add(E.key)),Dt());let y,b;return h.persistence.runTransaction("Locally write mutations","readwrite",(w=>{let E=Ns(),N=Dt();return h.Uo.getEntries(w,p).next((S=>{E=S,E.forEach(((I,O)=>{O.isValidDocument()||(N=N.add(I))}))})).next((()=>h.localDocuments.getOverlayedDocuments(w,E))).next((S=>{y=S;const I=[];for(const O of u){const F=qO(O,y.get(O.key).overlayedDocument);F!=null&&I.push(new fl(O.key,F,vD(F.value.mapValue),Ys.exists(!0)))}return h.mutationQueue.addMutationBatch(w,f,I,u)})).next((S=>{b=S;const I=S.applyToLocalDocumentSet(y,N);return h.documentOverlayCache.saveOverlays(w,S.batchId,I)}))})).then((()=>({batchId:b.batchId,changes:VD(y)})))})(r.localStore,e);r.sharedClientState.addPendingMutation(s.batchId),(function(c,u,h){let f=c.Vc[c.currentUser.toKey()];f||(f=new Fn(Lt)),f=f.insert(u,h),c.Vc[c.currentUser.toKey()]=f})(r,s.batchId,t),await ef(r,s.changes),await wp(r.remoteStore)}catch(s){const a=aC(s,"Failed to persist write");t.reject(a)}}async function q1(n,e){const t=xt(n);try{const r=await xU(t.localStore,e);
vendor: 3,538 bytes, line 3620
3620e.targetChanges.forEach(((s,a)=>{const c=t.Ic.get(a);c&&(Xe(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?c.lc=!0:s.modifiedDocuments.size>0?Xe(c.lc,14607):s.removedDocuments.size>0&&(Xe(c.lc,42227),c.lc=!1))})),await ef(t,r,e)}catch(r){await Uu(r)}}function fT(n,e,t){const r=xt(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){const s=[];r.hc.forEach(((a,c)=>{const u=c.view.Du(e);u.snapshot&&s.push(u.snapshot)})),(function(c,u){const h=xt(c);h.onlineState=u;let f=!1;h.queries.forEach(((p,y)=>{for(const b of y.wu)b.Du(u)&&(f=!0)})),f&&cC(h)})(r.eventManager,e),s.length&&r.Ec.hn(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function XU(n,e,t){const r=xt(n);r.sharedClientState.updateQueryState(e,"rejected",t);const s=r.Ic.get(e),a=s&&s.key;if(a){let c=new Fn(nt.comparator);c=c.insert(a,Xr.newNoDocument(a,pt.min()));const u=Dt().add(a),h=new Qh(pt.min(),new Map,new Fn(Lt),c,Ns(),u);await q1(r,h),r.Rc=r.Rc.remove(a),r.Ic.delete(e),hC(r)}else await Fy(r.localStore,e,!1).then((()=>Gy(r,e,t))).catch(Uu)}async function ZU(n,e){const t=xt(n),r=e.batch.batchId;try{const s=await yU(t.localStore,e);J1(t,r,null),z1(t,r),t.sharedClientState.updateMutationState(r,"acknowledged"),await ef(t,s)}catch(s){await Uu(s)}}async function e6(n,e,t){const r=xt(n);try{const s=await(function(c,u){const h=xt(c);return h.persistence.runTransaction("Reject batch","readwrite-primary",(f=>{let p;return h.mutationQueue.lookupMutationBatch(f,u).next((y=>(Xe(y!==null,37113),p=y.keys(),h.mutationQueue.removeMutationBatch(f,y)))).next((()=>h.mutationQueue.performConsistencyCheck(f))).next((()=>h.documentOverlayCache.removeOverlaysForBatchId(f,p,u))).next((()=>h.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(f,p))).next((()=>h.localDocuments.getDocuments(f,p)))}))})(r.localStore,e);J1(r,e,t),z1(r,e),r.sharedClientState.updateMutationState(e,"rejected",t),await ef(r,s)}catch(s){await Uu(s)}}function z1(n,e){(n.dc.get(e)||[]).forEach((t=>{t.resolve()})),n.dc.delete(e)}function J1(n,e,t){const r=xt(n);let s=r.Vc[r.currentUser.toKey()];if(s){const a=s.get(e);a&&(t?a.reject(t):a.resolve(),s=s.remove(e)),r.Vc[r.currentUser.toKey()]=s}}function Gy(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const r of n.Tc.get(e))n.hc.delete(r),t&&n.Ec.yc(r,t);n.Tc.delete(e),n.isPrimaryClient&&n.Ac.Xs(e).forEach((r=>{n.Ac.containsKey(r)||$1(n,r)}))}function $1(n,e){n.Pc.delete(e.path.canonicalString());const t=n.Rc.get(e);t!==null&&(eC(n.remoteStore,t),n.Rc=n.Rc.remove(e),n.Ic.delete(t),hC(n))}function mT(n,e,t){for(const r of t)r instanceof V1?(n.Ac.addReference(r.key,e),t6(n,r)):r instanceof G1?(Ue(dC,"Document no longer in limbo: "+r.key),n.Ac.removeReference(r.key,e),n.Ac.containsKey(r.key)||$1(n,r.key)):ot(19791,{wc:r})}function t6(n,e){const t=e.key,r=t.path.canonicalString();n.Rc.get(t)||n.Pc.has(r)||(Ue(dC,"New document in limbo: "+t),n.Pc.add(r),hC(n))}function hC(n){for(;n.Pc.size>0&&n.Rc.size<n.maxConcurrentLimboResolutions;){const e=n.Pc.values().next().value;n.Pc.delete(e);const t=new nt(sn.fromString(e)),r=n.fc.next();n.Ic.set(r,new qU(t)),n.Rc=n.Rc.insert(t,r),M1(n.remoteStore,new Oa(ta(lp(t.path)),r,"TargetPurposeLimboResolution",hp.yn))}}async function ef(n,e,t){const r=xt(n),s=[],a=[],c=[];r.hc.isEmpty()||(r.hc.forEach(((u,h)=>{c.push(r.gc(h,e,t).then((f=>{var p;if((f||t)&&r.isPrimaryClient){const y=f?!f.fromCache:(p=t==null?void 0:t.targetChanges.get(h.targetId))==null?void 0:p.current;
3620r.sharedClientState.updateQueryState(h.targetId,y?"current":"not-current")}if(f){s.push(f);const y=Xx.fo(h.targetId,f);a.push(y)}})))})),await Promise.all(c),r.Ec.hn(s),await(async function(h,f){const p=xt(h);try{await p.persistence.runTransaction("notifyLocalViewChanges","readwrite",(y=>Ee.forEach(f,(b=>Ee.forEach(b.Ao,(w=>p.persistence.referenceDelegate.addReference(y,b.targetId,w))).next((()=>Ee.forEach(b.Vo,(w=>p.persistence.referenceDelegate.removeReference(y,b.targetId,w)))))))))}catch(y){if(!Vu(y))throw y;Ue(Zx,"Failed to update sequence numbers: "+y)}for(const y of f){const b=y.targetId;if(!y.fromCache){const w=p.No.get(b),E=w.snapshotVersion,N=w.withLastLimboFreeSnapshotVersion(E);p.No=p.No.insert(b,N)}}})(r.localStore,a))}async function n6(n,e){const t=xt(n);if(!t.currentUser.isEqual(e)){Ue(dC,"User change. New user:",e.toKey());const r=await R1(t.localStore,e);t.currentUser=e,(function(a,c){a.dc.forEach((u=>{u.forEach((h=>{h.reject(new Fe(ve.CANCELLED,c))}))})),a.dc.clear()})(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await ef(t,r.qo)}}function r6(n,e){const t=xt(n),r=t.Ic.get(e);if(r&&r.lc)return Dt().add(r.key);{let s=Dt();const a=t.Tc.get(e);if(!a)return s;for(const c of a??[]){const u=t.hc.get(c);s=s.unionWith(u.view.Yu)}return s}}function K1(n){const e=xt(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=q1.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=r6.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=XU.bind(null,e),e.Ec.hn=UU.bind(null,e.eventManager),e.Ec.yc=VU.bind(null,e.eventManager),e}function s6(n){const e=xt(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=ZU.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=e6.bind(null,e),e}class Dg{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=up(e.databaseInfo.databaseId),this.sharedClientState=this.Sc(e),this.persistence=this.vc(e),await this.persistence.start(),this.localStore=this.Dc(e),this.gcScheduler=this.xc(e,this.localStore),this.indexBackfillerScheduler=this.Cc(e,this.localStore)}xc(e,t){return null}Cc(e,t){return null}Dc(e){return BU(this.persistence,new mU,e.initialUser,this.serializer)}vc(e){return new I1(Wx.w_,this.serializer)}Sc(e){return new jU}async terminate(){var e,t;(e=this.gcScheduler)==null||e.stop(),(t=this.indexBackfillerScheduler)==null||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Dg.provider={build:()=>new Dg};class i6 extends Dg{constructor(e){super(),this.cacheSizeBytes=e}xc(e,t){Xe(this.persistence.referenceDelegate instanceof Ng,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new oF(r,e.asyncQueue,t)}vc(e){const t=this.cacheSizeBytes!==void 0?_s.withCacheSize(this.cacheSizeBytes):_s.DEFAULT;return new I1((r=>Ng.w_(r,t)),this.serializer)}}class Hy{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>fT(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=n6.bind(null,this.syncEngine),await LU(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return(function(){return new FU})()}createDatastore(e){const t=up(e.databaseInfo.databaseId),r=K5(e.databaseInfo);return Z5(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return(function(r,s,a,c,u){return new _U(r,s,a,c,u)})(this.localStore,this.datastore,e.asyncQueue,(t=>fT(this.syncEngine,t,0)),(function(){return W_.Je()?new W_:new q5})())}createSyncEngine(e,t){return(function(s,a,c,u,h,f,p){const y=new zU(s,a,c,u,h,f);return p&&(y.mc=!0),y})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await(async function(s){const a=xt(s);Ue(ia,"RemoteStore shutting down."),a.ca.add(5),await Zh(a),a.Ea.shutdown(),a.ha.set("Unknown")})(this.remoteStore),(e=this.datastore)==null||e.terminate(),(t=this.eventManager)==null||t.terminate()}}Hy.provider={build:()=>new Hy};/**
3621 * @license
3622 * Copyright 2017 Google LLC
3623 *
3624 * Licensed under the Apache License, Version 2.0 (the "License");
3625 * you may not use this file except in compliance with the License.
3626 * You may obtain a copy of the License at
3627 *
3628 *   http://www.apache.org/licenses/LICENSE-2.0
3629 *
3630 * Unless required by applicable law or agreed to in writing, software
3631 * distributed under the License is distributed on an "AS IS" BASIS,
3632 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3633 * See the License for the specific language governing permissions and
3634 * limitations under the License.
3635 */const ul="FirestoreClient";class a6{constructor(e,t,r,s,a){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this._databaseInfo=s,this.user=Wr.UNAUTHENTICATED,this.clientId=_x.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=a,this.authCredentials.start(r,(async c=>{Ue(ul,"Received user=",c.uid),await this.authCredentialListener(c),this.user=c})),this.appCheckCredentials.start(r,(c=>(Ue(ul,"Received new app check token=",c),this.appCheckCredentialListener(c,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(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new Ua;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const r=aC(t,"Failed to shutdown persistence");e.reject(r)}})),e.promise}}async function XB(n,e){n.asyncQueue.verifyOperationInProgress(),Ue(ul,"Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener((async s=>{r.isEqual(s)||(await R1(e.localStore,s),r=s)})),e.persistence.setDatabaseDeletedListener((()=>n.terminate())),n._offlineComponents=e}async function gT(n,e){n.asyncQueue.verifyOperationInProgress();const t=await o6(n);Ue(ul,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener((r=>cT(e.remoteStore,r))),n.setAppCheckTokenChangeListener(((r,s)=>cT(e.remoteStore,s))),n._onlineComponents=e}async function o6(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){Ue(ul,"Using user provided OfflineComponentProvider");try{await XB(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!(function(s){return s.name==="FirebaseError"?s.code===ve.FAILED_PRECONDITION||s.code===ve.UNIMPLEMENTED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11})(t))throw t;Ri("Error using user provided cache. Falling back to memory cache: "+t),await XB(n,new Dg)}}else Ue(ul,"Using default OfflineComponentProvider"),await XB(n,new i6(void 0));return n._offlineComponents}async function Y1(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(Ue(ul,"Using user provided OnlineComponentProvider"),await gT(n,n._uninitializedComponentsProvider._online)):(Ue(ul,"Using default OnlineComponentProvider"),await gT(n,new Hy))),n._onlineComponents}function l6(n){return Y1(n).then((e=>e.syncEngine))}async function Ag(n){const e=await Y1(n),t=e.eventManager;return t.onListen=JU.bind(null,e.syncEngine),t.onUnlisten=YU.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=$U.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=QU.bind(null,e.syncEngine),t}function c6(n,e,t,r){const s=new sC(r),a=new uC(e,s,t);return n.asyncQueue.enqueueAndForget((async()=>oC(await Ag(n),a))),()=>{s.Aa(),n.asyncQueue.enqueueAndForget((async()=>lC(await Ag(n),a)))}}function u6(n,e,t={}){const r=new Ua;return n.asyncQueue.enqueueAndForget((async()=>(function(a,c,u,h,f){const p=new sC({next:b=>{p.Aa(),c.enqueueAndForget((()=>lC(a,y)));const w=b.docs.has(u);!w&&b.fromCache?f.reject(new Fe(ve.UNAVAILABLE,"Failed to get document because the client is offline.")):w&&b.fromCache&&h&&h.source==="server"?f.reject(new Fe(ve.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(b)},error:b=>f.reject(b)}),y=new uC(lp(u.path),p,{includeMetadataChanges:!0,waitForSyncWhe
3635nOnline:!0});return oC(a,y)})(await Ag(n),n.asyncQueue,e,t,r))),r.promise}function d6(n,e,t={}){const r=new Ua;return n.asyncQueue.enqueueAndForget((async()=>(function(a,c,u,h,f){const p=new sC({next:b=>{p.Aa(),c.enqueueAndForget((()=>lC(a,y))),b.fromCache&&h.source==="server"?f.reject(new Fe(ve.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(b)},error:b=>f.reject(b)}),y=new uC(u instanceof dh?q3(u):u,p,{includeMetadataChanges:!0,waitForSyncWhenOnline:!0});return oC(a,y)})(await Ag(n),n.asyncQueue,e,t,r))),r.promise}function h6(n,e){const t=new Ua;return n.asyncQueue.enqueueAndForget((async()=>WU(await l6(n),e,t))),t.promise}/**
3636 * @license
3637 * Copyright 2020 Google LLC
3638 *
3639 * Licensed under the Apache License, Version 2.0 (the "License");
3640 * you may not use this file except in compliance with the License.
3641 * You may obtain a copy of the License at
3642 *
3643 *   http://www.apache.org/licenses/LICENSE-2.0
3644 *
3645 * Unless required by applicable law or agreed to in writing, software
3646 * distributed under the License is distributed on an "AS IS" BASIS,
3647 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3648 * See the License for the specific language governing permissions and
3649 * limitations under the License.
3650 */let Q1=class{constructor(e,t,r,s,a){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=s,this._converter=a}get id(){return this._key.path.lastSegment()}get ref(){return new er(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new f6(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){var e;return((e=this._document)==null?void 0:e.data.clone().value.mapValue.fields)??void 0}get(e){if(this._document){const t=this._document.data.field(yc("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}},f6=class extends Q1{data(){return super.data()}};/**
3651 * @license
3652 * Copyright 2020 Google LLC
3653 *
3654 * Licensed under the Apache License, Version 2.0 (the "License");
3655 * you may not use this file except in compliance with the License.
3656 * You may obtain a copy of the License at
3657 *
3658 *   http://www.apache.org/licenses/LICENSE-2.0
3659 *
3660 * Unless required by applicable law or agreed to in writing, software
3661 * distributed under the License is distributed on an "AS IS" BASIS,
3662 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3663 * See the License for the specific language governing permissions and
3664 * limitations under the License.
3665 */class m6{convertValue(e,t="none"){switch(Cr(e)){case 0:return null;case 1:return e.booleanValue;case 2:return Jn(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(nl(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw ot(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return hl(e,((s,a)=>{r[s]=this.convertValue(a,t)})),r}convertVectorValue(e){var r,s,a;const t=(a=(s=(r=e.fields)==null?void 0:r[_h].arrayValue)==null?void 0:s.values)==null?void 0:a.map((c=>Jn(c.doubleValue)));return new Ss(t)}convertGeoPoint(e){return new ra(Jn(e.latitude),Jn(e.longitude))}convertArray(e,t){return(e.values||[]).map((r=>this.convertValue(r,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const r=$h(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(Iu(e));default:return null}}convertTimestamp(e){const t=tl(e);return new An(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=sn.fromString(e);Xe(WD(r),9688,{name:e});const s=new wh(r.get(1),r.get(3)),a=new nt(r.popFirst(5));return s.isEqual(t)||za(`A document reference to ${a} refers to a different database (${s.projectId}/${s.database}), which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),a}}/**
3666 * @license
3667 * Copyright 2020 Google LLC
3668 *
3669 * Licensed under the Apache License, Version 2.0 (the "License");
3670 * you may not use this file except in compliance with the License.
3671 * You may obtain a copy of the License at
3672 *
3673 *   http://www.apache.org/licenses/LICENSE-2.0
3674 *
3675 * Unless required by applicable law or agreed to in writing, software
3676 * distributed under the License is distributed on an "AS IS" BASIS,
3677 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3678 * See the License for the specific language governing permissions and
3679 * limitations under the License.
3680 */function W1(n,e,t){let r;return r=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,r}/**
3681 * @license
3682 * Copyright 2020 Google LLC
3683 *
3684 * Licensed under the Apache License, Version 2.0 (the "License");
3685 * you may not use this file except in compliance with the License.
3686 * You may obtain a copy of the License at
3687 *
3688 *   http://www.apache.org/licenses/LICENSE-2.0
3689 *
3690 * Unless required by applicable law or agreed to in writing, software
3691 * distributed under the License is distributed on an "AS IS" BASIS,
3692 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3693 * See the License for the specific language governing permissions and
3694 * limitations under the License.
3695 */const pT="AsyncQueue";class BT{constructor(e=Promise.resolve()){this.qc=[],this.$c=!1,this.Kc=[],this.Qc=null,this.Wc=!1,this.Gc=!1,this.zc=[],this.jt=new n1(this,"async_queue_retry"),this.jc=()=>{const r=WB();r&&Ue(pT,"Visibility state changed to "+r.visibilityState),this.jt.qt()},this.Hc=e;const t=WB();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.jc)}get isShuttingDown(){return this.$c}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Jc(),this.Yc(e)}enterRestrictedMode(e){if(!this.$c){this.$c=!0,this.Gc=e||!1;const t=WB();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.jc)}}enqueue(e){if(this.Jc(),this.$c)return new Promise((()=>{}));const t=new Ua;return this.Yc((()=>this.$c&&this.Gc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.qc.push(e),this.Zc())))}async Zc(){if(this.qc.length!==0){try{await this.qc[0](),this.qc.shift(),this.jt.reset()}catch(e){if(!Vu(e))throw e;Ue(pT,"Operation failed with retryable error: "+e)}this.qc.length>0&&this.jt.Ut((()=>this.Zc()))}}Yc(e){const t=this.Hc.then((()=>(this.Wc=!0,e().catch((r=>{throw this.Qc=r,this.Wc=!1,za("INTERNAL UNHANDLED ERROR: ",yT(r)),r})).then((r=>(this.Wc=!1,r))))));return this.Hc=t,t}enqueueAfterDelay(e,t,r){this.Jc(),this.zc.indexOf(e)>-1&&(t=0);const s=iC.createAndSchedule(this,e,t,r,(a=>this.Xc(a)));return this.Kc.push(s),s}Jc(){this.Qc&&ot(47125,{el:yT(this.Qc)})}verifyOperationInProgress(){}async tl(){let e;do e=this.Hc,await e;while(e!==this.Hc)}nl(e){for(const t of this.Kc)if(t.timerId===e)return!0;return!1}rl(e){return this.tl().then((()=>{this.Kc.sort(((t,r)=>t.targetTimeMs-r.targetTimeMs));for(const t of this.Kc)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.tl()}))}il(e){this.zc.push(e)}Xc(e){const t=this.Kc.indexOf(e);this.Kc.splice(t,1)}}function yT(n){let e=n.message||"";return n.stack&&(e=n.stack.includes(n.message)?n.stack:n.message+`
3696`+n.stack),e}class dl extends fp{constructor(e,t,r,s){super(e,t,r,s),this.type="firestore",this._queue=new BT,this._persistenceKey=(s==null?void 0:s.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new BT(e),this._firestoreClient=void 0,await e}}}function xT(n,e){const t=typeof n=="object"?n:Wg(),r=typeof n=="string"?n:e||gg,s=Qg(t,"firestore").getImmediate({identifier:r});if(!s._initialized){const a=lS("firestore");a&&uF(s,...a)}return s}function tf(n){if(n._terminated)throw new Fe(ve.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||g6(n),n._firestoreClient}function g6(n){var r,s,a,c;const e=n._freezeSettings(),t=tF(n._databaseId,((r=n._app)==null?void 0:r.options.appId)||"",n._persistenceKey,(s=n._app)==null?void 0:s.options.apiKey,e);n._componentsProvider||(a=e.localCache)!=null&&a._offlineComponentProvider&&((c=e.localCache)!=null&&c._onlineComponentProvider)&&(n._componentsProvider={_offline:e.localCache._offlineComponentProvider,_online:e.localCache._onlineComponentProvider}),n._firestoreClient=new a6(n._authCredentials,n._appCheckCredentials,n._queue,t,n._componentsProvider&&(function(h){const f=h==null?void 0:h._online.build();return{_offline:h==null?void 0:h._offline.build(f),_online:f}})(n._componentsProvider))}/**
3697 * @license
3698 * Copyright 2024 Google LLC
3699 *
3700 * Licensed under the Apache License, Version 2.0 (the "License");
3701 * you may not use this file except in compliance with the License.
3702 * You may obtain a copy of the License at
3703 *
3704 *   http://www.apache.org/licenses/LICENSE-2.0
3705 *
3706 * Unless required by applicable law or agreed to in writing, software
3707 * distributed under the License is distributed on an "AS IS" BASIS,
3708 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3709 * See the License for the specific language governing permissions and
3710 * limitations under the License.
3711 */class fC extends m6{constructor(e){super(),this.firestore=e}convertBytes(e){return new fi(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new er(this.firestore,null,t)}}class Zd{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class ac extends Q1{constructor(e,t,r,s,a,c){super(e,t,r,s,c),this._firestore=e,this._firestoreImpl=e,this.metadata=a}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new Zm(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const r=this._document.data.field(yc("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new Fe(ve.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,t={};return t.type=ac._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?t:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t)}}ac._jsonSchemaVersion="firestore/documentSnapshot/1.0",ac._jsonSchema={type:Br("string",ac._jsonSchemaVersion),bundleSource:Br("string","DocumentSnapshot"),bundleName:Br("string"),bundle:Br("string")};class Zm extends ac{data(e={}){return super.data(e)}}class oc{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new Zd(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){const e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach((r=>{e.call(t,new Zm(this._firestore,this._userDataWriter,r.key,r,new Zd(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new Fe(ve.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=(function(s,a){if(s._snapshot.oldDocs.isEmpty()){let c=0;return s._snapshot.docChanges.map((u=>{Er(s._snapshot.query)?Oy(s._snapshot.query):Dx(s.query._query);const h=new Zm(s._firestore,s._userDataWriter,u.doc.key,u.doc,new Zd(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);return u.doc,{type:"added",doc:h,oldIndex:-1,newIndex:c++}}))}{let c=s._snapshot.oldDocs;return s._snapshot.docChanges.filter((u=>a||u.type!==3)).map((u=>{const h=new Zm(s._firestore,s._userDataWriter,u.doc.key,u.doc,new Zd(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);let f=-1,p=-1;return u.type!==0&&(f=c.indexOf(u.doc.key),c=c.delete(u.doc.key)),u.type!==1&&(c=c.add(u.doc),p=c.indexOf(u.doc.key)),{type:p6(u.type),doc:h,oldIndex:f,newIndex:p}}))}})(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new Fe(ve.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};
3711e.type=oc._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=_x.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],r=[],s=[];return this.docs.forEach((a=>{a._document!==null&&(t.push(a._document),r.push(this._userDataWriter.convertObjectMap(a._document.data.value.mapValue.fields,"previous")),s.push(a.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function p6(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return ot(61501,{type:n})}}/**
3712 * @license
3713 * Copyright 2025 Google LLC
3714 *
3715 * Licensed under the Apache License, Version 2.0 (the "License");
3716 * you may not use this file except in compliance with the License.
3717 * You may obtain a copy of the License at
3718 *
3719 *   http://www.apache.org/licenses/LICENSE-2.0
3720 *
3721 * Unless required by applicable law or agreed to in writing, software
3722 * distributed under the License is distributed on an "AS IS" BASIS,
3723 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3724 * See the License for the specific language governing permissions and
3725 * limitations under the License.
3726 */oc._jsonSchemaVersion="firestore/querySnapshot/1.0",oc._jsonSchema={type:Br("string",oc._jsonSchemaVersion),bundleSource:Br("string","QuerySnapshot"),bundleName:Br("string"),bundle:Br("string")};/**
3727 * @license
3728 * Copyright 2020 Google LLC
3729 *
3730 * Licensed under the Apache License, Version 2.0 (the "License");
3731 * you may not use this file except in compliance with the License.
3732 * You may obtain a copy of the License at
3733 *
3734 *   http://www.apache.org/licenses/LICENSE-2.0
3735 *
3736 * Unless required by applicable law or agreed to in writing, software
3737 * distributed under the License is distributed on an "AS IS" BASIS,
3738 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3739 * See the License for the specific language governing permissions and
3740 * limitations under the License.
3741 */function X1(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new Fe(ve.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class mC{}class Z1 extends mC{}function fh(n,e,...t){let r=[];e instanceof mC&&r.push(e),r=r.concat(t),(function(a){const c=a.filter((h=>h instanceof gC)).length,u=a.filter((h=>h instanceof Ep)).length;if(c>1||c>0&&u>0)throw new Fe(ve.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 s of r)n=s._apply(n);return n}class Ep extends Z1{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new Ep(e,t,r)}_apply(e){const t=this._parse(e);return tA(e._query,t),new ml(e.firestore,e.converter,Iy(e._query,t))}_parse(e){const t=Lx(e.firestore);return(function(a,c,u,h,f,p,y){let b;if(f.isKeyField()){if(p==="array-contains"||p==="array-contains-any")throw new Fe(ve.INVALID_ARGUMENT,`Invalid Query. You can't perform '${p}' queries on documentId().`);if(p==="in"||p==="not-in"){bT(y,p);const E=[];for(const N of y)E.push(CT(h,a,N));b={arrayValue:{values:E}}}else b=CT(h,a,y)}else p!=="in"&&p!=="not-in"&&p!=="array-contains-any"||bT(y,p),b=pF(u,c,y,p==="in"||p==="not-in");return pr.create(f,p,b)})(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function ZB(n,e,t){const r=e,s=yc("where",n);return Ep._create(s,r,t)}class gC extends mC{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new gC(e,t)}_parse(e){const t=this._queryConstraints.map((r=>r._parse(e))).filter((r=>r.getFilters().length>0));return t.length===1?t[0]:Pi.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return t.getFilters().length===0?e:((function(s,a){let c=s;const u=a.getFlattenedFilters();for(const h of u)tA(c,h),c=Iy(c,h)})(e._query,t),new ml(e.firestore,e.converter,Iy(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}
3741class pC extends Z1{constructor(e,t,r){super(),this.type=e,this._limit=t,this._limitType=r}static _create(e,t,r){return new pC(e,t,r)}_apply(e){return new ml(e.firestore,e.converter,wg(e._query,this._limit,this._limitType))}}function eA(n){return pC._create("limit",n,"F")}function CT(n,e,t){if(typeof(t=En(t))=="string"){if(t==="")throw new Fe(ve.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!OD(e)&&t.indexOf("/")!==-1)throw new Fe(ve.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${t}' contains a '/' character.`);const r=e.path.child(sn.fromString(t));if(!nt.isDocumentKey(r))throw new Fe(ve.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 M_(n,new nt(r))}if(t instanceof er)return M_(n,t._key);throw new Fe(ve.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${tp(t)}.`)}function bT(n,e){if(!Array.isArray(n)||n.length===0)throw new Fe(ve.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function tA(n,e){const t=(function(s,a){for(const c of s)for(const u of c.getFlattenedFilters())if(a.indexOf(u.op)>=0)return u.op;return null})(n.filters,(function(s){switch(s){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[]}})(e.op));if(t!==null)throw t===e.op?new Fe(ve.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new Fe(ve.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${t.toString()}' filters.`)}/**
3742 * @license
3743 * Copyright 2017 Google LLC
3744 *
3745 * Licensed under the Apache License, Version 2.0 (the "License");
3746 * you may not use this file except in compliance with the License.
3747 * You may obtain a copy of the License at
3748 *
3749 *   http://www.apache.org/licenses/LICENSE-2.0
3750 *
3751 * Unless required by applicable law or agreed to in writing, software
3752 * distributed under the License is distributed on an "AS IS" BASIS,
3753 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3754 * See the License for the specific language governing permissions and
3755 * limitations under the License.
3756 */function vT(n){return(function(t,r){if(typeof t!="object"||t===null)return!1;const s=t;for(const a of r)if(a in s&&typeof s[a]=="function")return!0;return!1})(n,["next","error","complete"])}/**
3757 * @license
3758 * Copyright 2020 Google LLC
3759 *
3760 * Licensed under the Apache License, Version 2.0 (the "License");
3761 * you may not use this file except in compliance with the License.
3762 * You may obtain a copy of the License at
3763 *
3764 *   http://www.apache.org/licenses/LICENSE-2.0
3765 *
3766 * Unless required by applicable law or agreed to in writing, software
3767 * distributed under the License is distributed on an "AS IS" BASIS,
3768 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3769 * See the License for the specific language governing permissions and
3770 * limitations under the License.
3771 */class B6{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=Lx(e)}set(e,t,r){this._verifyNotCommitted();const s=ey(e,this._firestore),a=W1(s.converter,t,r),c=l1(this._dataReader,"WriteBatch.set",s._key,a,s.converter!==null,r);return this._mutations.push(c.toMutation(s._key,Ys.none())),this}update(e,t,r,...s){this._verifyNotCommitted();const a=ey(e,this._firestore);let c;return c=typeof(t=En(t))=="string"||t instanceof dp?gF(this._dataReader,"WriteBatch.update",a._key,t,r,s):mF(this._dataReader,"WriteBatch.update",a._key,t),this._mutations.push(c.toMutation(a._key,Ys.exists(!0))),this}delete(e){this._verifyNotCommitted();const t=ey(e,this._firestore);return this._mutations=this._mutations.concat(new op(t._key,Ys.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new Fe(ve.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function ey(n,e){if((n=En(n)).firestore!==e)throw new Fe(ve.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return n}/**
3772 * @license
3773 * Copyright 2020 Google LLC
3774 *
3775 * Licensed under the Apache License, Version 2.0 (the "License");
3776 * you may not use this file except in compliance with the License.
3777 * You may obtain a copy of the License at
3778 *
3779 *   http://www.apache.org/licenses/LICENSE-2.0
3780 *
3781 * Unless required by applicable law or agreed to in writing, software
3782 * distributed under the License is distributed on an "AS IS" BASIS,
3783 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3784 * See the License for the specific language governing permissions and
3785 * limitations under the License.
3786 */function Dm(n){n=mi(n,er);const e=mi(n.firestore,dl),t=tf(e);return u6(t,n._key).then((r=>nA(e,n,r)))}function Hr(n){n=mi(n,ml);const e=mi(n.firestore,dl),t=tf(e),r=new fC(e);return X1(n._query),d6(t,n._query).then((s=>new oc(e,r,n,s)))}function Zn(n,e,t){n=mi(n,er);const r=mi(n.firestore,dl),s=W1(n.converter,e,t),a=Lx(r);return BC(r,[l1(a,"setDoc",n._key,s,n.converter!==null,t).toMutation(n._key,Ys.none())])}function cs(n){return BC(mi(n.firestore,dl),[new op(n._key,Ys.none())])}function Sa(n,...e){var f,p,y;n=En(n);let t={includeMetadataChanges:!1,source:"default"},r=0;typeof e[r]!="object"||vT(e[r])||(t=e[r++]);const s={includeMetadataChanges:t.includeMetadataChanges,source:t.source};if(vT(e[r])){const b=e[r];e[r]=(f=b.next)==null?void 0:f.bind(b),e[r+1]=(p=b.error)==null?void 0:p.bind(b),e[r+2]=(y=b.complete)==null?void 0:y.bind(b)}let a,c,u;if(n instanceof er)c=mi(n.firestore,dl),u=lp(n._key.path),a={next:b=>{e[r]&&e[r](nA(c,n,b))},error:e[r+1],complete:e[r+2]};else{const b=mi(n,ml);c=mi(b.firestore,dl),u=b._query;const w=new fC(c);a={next:E=>{e[r]&&e[r](new oc(c,w,b,E))},error:e[r+1],complete:e[r+2]},X1(n._query)}const h=tf(c);return c6(h,u,s,a)}function BC(n,e){const t=tf(n);return h6(t,e)}function nA(n,e,t){const r=t.docs.get(e._key),s=new fC(n);return new ac(n,s,e._key,r,new Zd(t.hasPendingWrites,t.fromCache),e.converter)}function eh(n){return n=mi(n,dl),tf(n),new B6(n,(e=>BC(n,e)))}const wT="@firebase/firestore",ET="4.17.1";(function(e,t=!0){EO(wc),mc(new Zo("firestore",((r,{instanceIdentifier:s,options:a})=>{const c=r.getProvider("app").getImmediate(),u=new dl(new U5(r.getProvider("auth-internal")),new H5(c,r.getProvider("app-check-internal")),PO(c,s),c);return a={useFetchStreams:t,...a},u._setSettings(a),u}),"PUBLIC").setMultipleInstances(!0)),Zi(wT,ET,e),Zi(wT,ET,"esm2020")})();/**
3787 * @license
3788 * Copyright 2017 Google LLC
3789 *
3790 * Licensed under the Apache License, Version 2.0 (the "License");
3791 * you may not use this file except in compliance with the License.
3792 * You may obtain a copy of the License at
3793 *
3794 *   http://www.apache.org/licenses/LICENSE-2.0
3795 *
3796 * Unless required by applicable law or agreed to in writing, software
3797 * distributed under the License is distributed on an "AS IS" BASIS,
3798 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3799 * See the License for the specific language governing permissions and
3800 * limitations under the License.
3801 */const rA="firebasestorage.googleapis.com",sA="storageBucket",y6=120*1e3,x6=600*1e3;/**
3802 * @license
3803 * Copyright 2017 Google LLC
3804 *
3805 * Licensed under the Apache License, Version 2.0 (the "License");
3806 * you may not use this file except in compliance with the License.
3807 * You may obtain a copy of the License at
3808 *
3809 *   http://www.apache.org/licenses/LICENSE-2.0
3810 *
3811 * Unless required by applicable law or agreed to in writing, software
3812 * distributed under the License is distributed on an "AS IS" BASIS,
3813 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3814 * See the License for the specific language governing permissions and
3815 * limitations under the License.
3816 */class nr extends aa{constructor(e,t,r=0){super(ty(e),`Firebase Storage: ${t} (${ty(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,nr.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return ty(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
3817${this.customData.serverResponse}`:this.message=this._baseMessage}}var tr;(function(n){n.UNKNOWN="unknown",n.OBJECT_NOT_FOUND="object-not-found",n.BUCKET_NOT_FOUND="bucket-not-found",n.PROJECT_NOT_FOUND="project-not-found",n.QUOTA_EXCEEDED="quota-exceeded",n.UNAUTHENTICATED="unauthenticated",n.UNAUTHORIZED="unauthorized",n.UNAUTHORIZED_APP="unauthorized-app",n.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",n.INVALID_CHECKSUM="invalid-checksum",n.CANCELED="canceled",n.INVALID_EVENT_NAME="invalid-event-name",n.INVALID_URL="invalid-url",n.INVALID_DEFAULT_BUCKET="invalid-default-bucket",n.NO_DEFAULT_BUCKET="no-default-bucket",n.CANNOT_SLICE_BLOB="cannot-slice-blob",n.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",n.NO_DOWNLOAD_URL="no-download-url",n.INVALID_ARGUMENT="invalid-argument",n.INVALID_ARGUMENT_COUNT="invalid-argument-count",n.APP_DELETED="app-deleted",n.INVALID_ROOT_OPERATION="invalid-root-operation",n.INVALID_FORMAT="invalid-format",n.INTERNAL_ERROR="internal-error",n.UNSUPPORTED_ENVIRONMENT="unsupported-environment"})(tr||(tr={}));function ty(n){return"storage/"+n}function yC(){const n="An unknown error occurred, please check the error payload for server response.";return new nr(tr.UNKNOWN,n)}function C6(n){return new nr(tr.OBJECT_NOT_FOUND,"Object '"+n+"' does not exist.")}function b6(n){return new nr(tr.QUOTA_EXCEEDED,"Quota for bucket '"+n+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function v6(){const n="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new nr(tr.UNAUTHENTICATED,n)}function w6(){return new nr(tr.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function E6(n){return new nr(tr.UNAUTHORIZED,"User does not have permission to access '"+n+"'.")}function _6(){return new nr(tr.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function T6(){return new nr(tr.CANCELED,"User canceled the upload/download.")}function k6(n){return new nr(tr.INVALID_URL,"Invalid URL '"+n+"'.")}function N6(n){return new nr(tr.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+n+"'.")}function S6(){return new nr(tr.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+sA+"' property when initializing the app?")}function D6(){return new nr(tr.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function A6(){return new nr(tr.NO_DOWNLOAD_URL,"The given file does not have any download URLs.")}function I6(n){return new nr(tr.UNSUPPORTED_ENVIRONMENT,`${n} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function qy(n){return new nr(tr.INVALID_ARGUMENT,n)}function iA(){return new nr(tr.APP_DELETED,"The Firebase app was deleted.")}function R6(n){return new nr(tr.INVALID_ROOT_OPERATION,"The operation '"+n+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function mh(n,e){return new nr(tr.INVALID_FORMAT,"String does not match format '"+n+"': "+e)}function Hd(n){throw new nr(tr.INTERNAL_ERROR,"Internal error: "+n)}/**
3818 * @license
3819 * Copyright 2017 Google LLC
3820 *
3821 * Licensed under the Apache License, Version 2.0 (the "License");
3822 * you may not use this file except in compliance with the License.
3823 * You may obtain a copy of the License at
3824 *
3825 *   http://www.apache.org/licenses/LICENSE-2.0
3826 *
3827 * Unless required by applicable law or agreed to in writing, software
3828 * distributed under the License is distributed on an "AS IS" BASIS,
3829 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3830 * See the License for the specific language governing permissions and
3831 * limitations under the License.
3832 */class $s{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let r;try{r=$s.makeFromUrl(e,t)}catch{return new $s(e,"")}if(r.path==="")return r;throw N6(e)}static makeFromUrl(e,t){let r=null;const s="([A-Za-z0-9.\\-_]+)";function a(J){J.path.charAt(J.path.length-1)==="/"&&(J.path_=J.path_.slice(0,-1))}const c="(/(.*))?$",u=new RegExp("^gs://"+s+c,"i"),h={bucket:1,path:3};function f(J){J.path_=decodeURIComponent(J.path)}const p="v[A-Za-z0-9_]+",y=t.replace(/[.]/g,"\\."),b="(/([^?#]*).*)?$",w=new RegExp(`^https?://${y}/${p}/b/${s}/o${b}`,"i"),E={bucket:1,path:3},N=t===rA?"(?:storage.googleapis.com|storage.cloud.google.com)":t,S="([^?#]*)",I=new RegExp(`^https?://${N}/${s}/${S}`,"i"),F=[{regex:u,indices:h,postModify:a},{regex:w,indices:E,postModify:f},{regex:I,indices:{bucket:1,path:2},postModify:f}];for(let J=0;J<F.length;J++){const z=F[J],U=z.regex.exec(e);if(U){const D=U[z.indices.bucket];let k=U[z.indices.path];k||(k=""),r=new $s(D,k),z.postModify(r);break}}if(r==null)throw k6(e);return r}}class P6{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}/**
3833 * @license
3834 * Copyright 2017 Google LLC
3835 *
3836 * Licensed under the Apache License, Version 2.0 (the "License");
3837 * you may not use this file except in compliance with the License.
3838 * You may obtain a copy of the License at
3839 *
3840 *   http://www.apache.org/licenses/LICENSE-2.0
3841 *
3842 * Unless required by applicable law or agreed to in writing, software
3843 * distributed under the License is distributed on an "AS IS" BASIS,
3844 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3845 * See the License for the specific language governing permissions and
3846 * limitations under the License.
3847 */function M6(n,e,t){let r=1,s=null,a=null,c=!1,u=0;function h(){return u===2}let f=!1;function p(...S){f||(f=!0,e.apply(null,S))}function y(S){s=setTimeout(()=>{s=null,n(w,h())},S)}function b(){a&&clearTimeout(a)}function w(S,...I){if(f){b();return}if(S){b(),p.call(null,S,...I);return}if(h()||c){b(),p.call(null,S,...I);return}r<64&&(r*=2);let F;u===1?(u=2,F=0):F=(r+Math.random())*1e3,y(F)}let E=!1;function N(S){E||(E=!0,b(),!f&&(s!==null?(S||(u=2),clearTimeout(s),y(0)):S||(u=1)))}return y(0),a=setTimeout(()=>{c=!0,N(!0)},t),N}function L6(n){n(!1)}/**
3848 * @license
3849 * Copyright 2017 Google LLC
3850 *
3851 * Licensed under the Apache License, Version 2.0 (the "License");
3852 * you may not use this file except in compliance with the License.
3853 * You may obtain a copy of the License at
3854 *
3855 *   http://www.apache.org/licenses/LICENSE-2.0
3856 *
3857 * Unless required by applicable law or agreed to in writing, software
3858 * distributed under the License is distributed on an "AS IS" BASIS,
3859 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3860 * See the License for the specific language governing permissions and
3861 * limitations under the License.
3862 */function j6(n){return n!==void 0}function O6(n){return typeof n=="object"&&!Array.isArray(n)}function xC(n){return typeof n=="string"||n instanceof String}function _T(n){return CC()&&n instanceof Blob}function CC(){return typeof Blob<"u"}function TT(n,e,t,r){if(r<e)throw qy(`Invalid value for '${n}'. Expected ${e} or greater.`);if(r>t)throw qy(`Invalid value for '${n}'. Expected ${t} or less.`)}/**
3863 * @license
3864 * Copyright 2017 Google LLC
3865 *
3866 * Licensed under the Apache License, Version 2.0 (the "License");
3867 * you may not use this file except in compliance with the License.
3868 * You may obtain a copy of the License at
3869 *
3870 *   http://www.apache.org/licenses/LICENSE-2.0
3871 *
3872 * Unless required by applicable law or agreed to in writing, software
3873 * distributed under the License is distributed on an "AS IS" BASIS,
3874 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3875 * See the License for the specific language governing permissions and
3876 * limitations under the License.
3877 */function bC(n,e,t){let r=e;return t==null&&(r=`https://${e}`),`${t}://${r}/v0${n}`}function aA(n){const e=encodeURIComponent;let t="?";for(const r in n)if(n.hasOwnProperty(r)){const s=e(r)+"="+e(n[r]);t=t+s+"&"}return t=t.slice(0,-1),t}var lc;(function(n){n[n.NO_ERROR=0]="NO_ERROR",n[n.NETWORK_ERROR=1]="NETWORK_ERROR",n[n.ABORT=2]="ABORT"})(lc||(lc={}));/**
3878 * @license
3879 * Copyright 2022 Google LLC
3880 *
3881 * Licensed under the Apache License, Version 2.0 (the "License");
3882 * you may not use this file except in compliance with the License.
3883 * You may obtain a copy of the License at
3884 *
3885 *   http://www.apache.org/licenses/LICENSE-2.0
3886 *
3887 * Unless required by applicable law or agreed to in writing, software
3888 * distributed under the License is distributed on an "AS IS" BASIS,
3889 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3890 * See the License for the specific language governing permissions and
3891 * limitations under the License.
3892 */function F6(n,e){const t=n>=500&&n<600,s=[408,429].indexOf(n)!==-1,a=e.indexOf(n)!==-1;return t||s||a}/**
3893 * @license
3894 * Copyright 2017 Google LLC
3895 *
3896 * Licensed under the Apache License, Version 2.0 (the "License");
3897 * you may not use this file except in compliance with the License.
3898 * You may obtain a copy of the License at
3899 *
3900 *   http://www.apache.org/licenses/LICENSE-2.0
3901 *
3902 * Unless required by applicable law or agreed to in writing, software
3903 * distributed under the License is distributed on an "AS IS" BASIS,
3904 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3905 * See the License for the specific language governing permissions and
3906 * limitations under the License.
3907 */class U6{constructor(e,t,r,s,a,c,u,h,f,p,y,b=!0,w=!1){this.url_=e,this.method_=t,this.headers_=r,this.body_=s,this.successCodes_=a,this.additionalRetryCodes_=c,this.callback_=u,this.errorCallback_=h,this.timeout_=f,this.progressCallback_=p,this.connectionFactory_=y,this.retry=b,this.isUsingEmulator=w,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((E,N)=>{this.resolve_=E,this.reject_=N,this.start_()})}start_(){const e=(r,s)=>{if(s){r(!1,new Am(!1,null,!0));return}const a=this.connectionFactory_();this.pendingConnection_=a;const c=u=>{const h=u.loaded,f=u.lengthComputable?u.total:-1;this.progressCallback_!==null&&this.progressCallback_(h,f)};this.progressCallback_!==null&&a.addUploadProgressListener(c),a.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&a.removeUploadProgressListener(c),this.pendingConnection_=null;const u=a.getErrorCode()===lc.NO_ERROR,h=a.getStatus();if(!u||F6(h,this.additionalRetryCodes_)&&this.retry){const p=a.getErrorCode()===lc.ABORT;r(!1,new Am(!1,null,p));return}const f=this.successCodes_.indexOf(h)!==-1;r(!0,new Am(f,a))})},t=(r,s)=>{const a=this.resolve_,c=this.reject_,u=s.connection;if(s.wasSuccessCode)try{const h=this.callback_(u,u.getResponse());j6(h)?a(h):a()}catch(h){c(h)}else if(u!==null){const h=yC();h.serverResponse=u.getErrorText(),this.errorCallback_?c(this.errorCallback_(u,h)):c(h)}else if(s.canceled){const h=this.appDelete_?iA():T6();c(h)}else{const h=_6();c(h)}};this.canceled_?t(!1,new Am(!1,null,!0)):this.backoffId_=M6(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&L6(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class Am{constructor(e,t,r){this.wasSuccessCode=e,this.connection=t,this.canceled=!!r}}function V6(n,e){e!==null&&e.length>0&&(n.Authorization="Firebase "+e)}function G6(n,e){n["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function H6(n,e){e&&(n["X-Firebase-GMPID"]=e)}function q6(n,e){e!==null&&(n["X-Firebase-AppCheck"]=e)}
3907function z6(n,e,t,r,s,a,c=!0,u=!1){const h=aA(n.urlParams),f=n.url+h,p=Object.assign({},n.headers);return H6(p,e),V6(p,t),G6(p,a),q6(p,r),new U6(f,n.method,p,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,s,c,u)}/**
3908 * @license
3909 * Copyright 2017 Google LLC
3910 *
3911 * Licensed under the Apache License, Version 2.0 (the "License");
3912 * you may not use this file except in compliance with the License.
3913 * You may obtain a copy of the License at
3914 *
3915 *   http://www.apache.org/licenses/LICENSE-2.0
3916 *
3917 * Unless required by applicable law or agreed to in writing, software
3918 * distributed under the License is distributed on an "AS IS" BASIS,
3919 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3920 * See the License for the specific language governing permissions and
3921 * limitations under the License.
3922 */function J6(){return typeof BlobBuilder<"u"?BlobBuilder:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:void 0}function $6(...n){const e=J6();if(e!==void 0){const t=new e;for(let r=0;r<n.length;r++)t.append(n[r]);return t.getBlob()}else{if(CC())return new Blob(n);throw new nr(tr.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}}function K6(n,e,t){return n.webkitSlice?n.webkitSlice(e,t):n.mozSlice?n.mozSlice(e,t):n.slice?n.slice(e,t):null}/**
3923 * @license
3924 * Copyright 2021 Google LLC
3925 *
3926 * Licensed under the Apache License, Version 2.0 (the "License");
3927 * you may not use this file except in compliance with the License.
3928 * You may obtain a copy of the License at
3929 *
3930 *   http://www.apache.org/licenses/LICENSE-2.0
3931 *
3932 * Unless required by applicable law or agreed to in writing, software
3933 * distributed under the License is distributed on an "AS IS" BASIS,
3934 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3935 * See the License for the specific language governing permissions and
3936 * limitations under the License.
3937 */function Y6(n){if(typeof atob>"u")throw I6("base-64");return atob(n)}/**
3938 * @license
3939 * Copyright 2017 Google LLC
3940 *
3941 * Licensed under the Apache License, Version 2.0 (the "License");
3942 * you may not use this file except in compliance with the License.
3943 * You may obtain a copy of the License at
3944 *
3945 *   http://www.apache.org/licenses/LICENSE-2.0
3946 *
3947 * Unless required by applicable law or agreed to in writing, software
3948 * distributed under the License is distributed on an "AS IS" BASIS,
3949 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3950 * See the License for the specific language governing permissions and
3951 * limitations under the License.
3952 */const Wi={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class ny{constructor(e,t){this.data=e,this.contentType=t||null}}function Q6(n,e){switch(n){case Wi.RAW:return new ny(oA(e));case Wi.BASE64:case Wi.BASE64URL:return new ny(lA(n,e));case Wi.DATA_URL:return new ny(X6(e),Z6(e))}throw yC()}function oA(n){const e=[];for(let t=0;t<n.length;t++){let r=n.charCodeAt(t);if(r<=127)e.push(r);else if(r<=2047)e.push(192|r>>6,128|r&63);else if((r&64512)===55296)if(!(t<n.length-1&&(n.charCodeAt(t+1)&64512)===56320))e.push(239,191,189);else{const a=r,c=n.charCodeAt(++t);r=65536|(a&1023)<<10|c&1023,e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}else(r&64512)===56320?e.push(239,191,189):e.push(224|r>>12,128|r>>6&63,128|r&63)}return new Uint8Array(e)}function W6(n){let e;try{e=decodeURIComponent(n)}catch{throw mh(Wi.DATA_URL,"Malformed data URL.")}return oA(e)}function lA(n,e){switch(n){case Wi.BASE64:{const s=e.indexOf("-")!==-1,a=e.indexOf("_")!==-1;if(s||a)throw mh(n,"Invalid character '"+(s?"-":"_")+"' found: is it base64url encoded?");break}case Wi.BASE64URL:{const s=e.indexOf("+")!==-1,a=e.indexOf("/")!==-1;if(s||a)throw mh(n,"Invalid character '"+(s?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let t;try{t=Y6(e)}catch(s){throw s.message.includes("polyfill")?s:mh(n,"Invalid character found")}const r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}class cA{constructor(e){this.base64=!1,this.contentType=null;const t=e.match(/^data:([^,]+)?,/);if(t===null)throw mh(Wi.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const r=t[1]||null;r!=null&&(this.base64=eV(r,";base64"),this.contentType=this.base64?r.substring(0,r.length-7):r),this.rest=e.substring(e.indexOf(",")+1)}}function X6(n){const e=new cA(n);return e.base64?lA(Wi.BASE64,e.rest):W6(e.rest)}function Z6(n){return new cA(n).contentType}function eV(n,e){return n.length>=e.length?n.substring(n.length-e.length)===e:!1}/**
3953 * @license
3954 * Copyright 2017 Google LLC
3955 *
3956 * Licensed under the Apache License, Version 2.0 (the "License");
3957 * you may not use this file except in compliance with the License.
3958 * You may obtain a copy of the License at
3959 *
3960 *   http://www.apache.org/licenses/LICENSE-2.0
3961 *
3962 * Unless required by applicable law or agreed to in writing, software
3963 * distributed under the License is distributed on an "AS IS" BASIS,
3964 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3965 * See the License for the specific language governing permissions and
3966 * limitations under the License.
3967 */class qo{constructor(e,t){let r=0,s="";_T(e)?(this.data_=e,r=e.size,s=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),r=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),r=e.length),this.size_=r,this.type_=s}size(){return this.size_}type(){return this.type_}slice(e,t){if(_T(this.data_)){const r=this.data_,s=K6(r,e,t);return s===null?null:new qo(s)}else{const r=new Uint8Array(this.data_.buffer,e,t-e);return new qo(r,!0)}}static getBlob(...e){if(CC()){const t=e.map(r=>r instanceof qo?r.data_:r);return new qo($6.apply(null,t))}else{const t=e.map(c=>xC(c)?Q6(Wi.RAW,c).data:c.data_);let r=0;t.forEach(c=>{r+=c.byteLength});const s=new Uint8Array(r);let a=0;return t.forEach(c=>{for(let u=0;u<c.length;u++)s[a++]=c[u]}),new qo(s,!0)}}uploadData(){return this.data_}}/**
3968 * @license
3969 * Copyright 2017 Google LLC
3970 *
3971 * Licensed under the Apache License, Version 2.0 (the "License");
3972 * you may not use this file except in compliance with the License.
3973 * You may obtain a copy of the License at
3974 *
3975 *   http://www.apache.org/licenses/LICENSE-2.0
3976 *
3977 * Unless required by applicable law or agreed to in writing, software
3978 * distributed under the License is distributed on an "AS IS" BASIS,
3979 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3980 * See the License for the specific language governing permissions and
3981 * limitations under the License.
3982 */function uA(n){let e;try{e=JSON.parse(n)}catch{return null}return O6(e)?e:null}/**
3983 * @license
3984 * Copyright 2017 Google LLC
3985 *
3986 * Licensed under the Apache License, Version 2.0 (the "License");
3987 * you may not use this file except in compliance with the License.
3988 * You may obtain a copy of the License at
3989 *
3990 *   http://www.apache.org/licenses/LICENSE-2.0
3991 *
3992 * Unless required by applicable law or agreed to in writing, software
3993 * distributed under the License is distributed on an "AS IS" BASIS,
3994 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3995 * See the License for the specific language governing permissions and
3996 * limitations under the License.
3997 */function tV(n){if(n.length===0)return null;const e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function nV(n,e){const t=e.split("/").filter(r=>r.length>0).join("/");return n.length===0?t:n+"/"+t}function dA(n){const e=n.lastIndexOf("/",n.length-2);return e===-1?n:n.slice(e+1)}/**
3998 * @license
3999 * Copyright 2017 Google LLC
4000 *
4001 * Licensed under the Apache License, Version 2.0 (the "License");
4002 * you may not use this file except in compliance with the License.
4003 * You may obtain a copy of the License at
4004 *
4005 *   http://www.apache.org/licenses/LICENSE-2.0
4006 *
4007 * Unless required by applicable law or agreed to in writing, software
4008 * distributed under the License is distributed on an "AS IS" BASIS,
4009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4010 * See the License for the specific language governing permissions and
4011 * limitations under the License.
4012 */function rV(n,e){return e}class us{constructor(e,t,r,s){this.server=e,this.local=t||e,this.writable=!!r,this.xform=s||rV}}let Im=null;function sV(n){return!xC(n)||n.length<2?n:dA(n)}function hA(){if(Im)return Im;const n=[];n.push(new us("bucket")),n.push(new us("generation")),n.push(new us("metageneration")),n.push(new us("name","fullPath",!0));function e(a,c){return sV(c)}const t=new us("name");t.xform=e,n.push(t);function r(a,c){return c!==void 0?Number(c):c}const s=new us("size");return s.xform=r,n.push(s),n.push(new us("timeCreated")),n.push(new us("updated")),n.push(new us("md5Hash",null,!0)),n.push(new us("cacheControl",null,!0)),n.push(new us("contentDisposition",null,!0)),n.push(new us("contentEncoding",null,!0)),n.push(new us("contentLanguage",null,!0)),n.push(new us("contentType",null,!0)),n.push(new us("metadata","customMetadata",!0)),Im=n,Im}function iV(n,e){function t(){const r=n.bucket,s=n.fullPath,a=new $s(r,s);return e._makeStorageReference(a)}Object.defineProperty(n,"ref",{get:t})}function aV(n,e,t){const r={};r.type="file";const s=t.length;for(let a=0;a<s;a++){const c=t[a];r[c.local]=c.xform(r,e[c.server])}return iV(r,n),r}function fA(n,e,t){const r=uA(e);return r===null?null:aV(n,r,t)}function oV(n,e,t,r){const s=uA(e);
4012if(s===null||!xC(s.downloadTokens))return null;const a=s.downloadTokens;if(a.length===0)return null;const c=encodeURIComponent;return a.split(",").map(f=>{const p=n.bucket,y=n.fullPath,b="/b/"+c(p)+"/o/"+c(y),w=bC(b,t,r),E=aA({alt:"media",token:f});return w+E})[0]}function lV(n,e){const t={},r=e.length;for(let s=0;s<r;s++){const a=e[s];a.writable&&(t[a.server]=n[a.local])}return JSON.stringify(t)}class mA{constructor(e,t,r,s){this.url=e,this.method=t,this.handler=r,this.timeout=s,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}/**
4013 * @license
4014 * Copyright 2017 Google LLC
4015 *
4016 * Licensed under the Apache License, Version 2.0 (the "License");
4017 * you may not use this file except in compliance with the License.
4018 * You may obtain a copy of the License at
4019 *
4020 *   http://www.apache.org/licenses/LICENSE-2.0
4021 *
4022 * Unless required by applicable law or agreed to in writing, software
4023 * distributed under the License is distributed on an "AS IS" BASIS,
4024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4025 * See the License for the specific language governing permissions and
4026 * limitations under the License.
4027 */function gA(n){if(!n)throw yC()}function cV(n,e){function t(r,s){const a=fA(n,s,e);return gA(a!==null),a}return t}function uV(n,e){function t(r,s){const a=fA(n,s,e);return gA(a!==null),oV(a,s,n.host,n._protocol)}return t}function pA(n){function e(t,r){let s;return t.getStatus()===401?t.getErrorText().includes("Firebase App Check token is invalid")?s=w6():s=v6():t.getStatus()===402?s=b6(n.bucket):t.getStatus()===403?s=E6(n.path):s=r,s.status=t.getStatus(),s.serverResponse=r.serverResponse,s}return e}function dV(n){const e=pA(n);function t(r,s){let a=e(r,s);return r.getStatus()===404&&(a=C6(n.path)),a.serverResponse=s.serverResponse,a}return t}function hV(n,e,t){const r=e.fullServerUrl(),s=bC(r,n.host,n._protocol),a="GET",c=n.maxOperationRetryTime,u=new mA(s,a,uV(n,t),c);return u.errorHandler=dV(e),u}function fV(n,e){return n&&n.contentType||e&&e.type()||"application/octet-stream"}function mV(n,e,t){const r=Object.assign({},t);return r.fullPath=n.path,r.size=e.size(),r.contentType||(r.contentType=fV(null,e)),r}function gV(n,e,t,r,s){const a=e.bucketOnlyServerUrl(),c={"X-Goog-Upload-Protocol":"multipart"};function u(){let F="";for(let J=0;J<2;J++)F=F+Math.random().toString().slice(2);return F}const h=u();c["Content-Type"]="multipart/related; boundary="+h;const f=mV(e,r,s),p=lV(f,t),y="--"+h+`\r
4028Content-Type: application/json; charset=utf-8\r
4029\r
4030`+p+`\r
4031--`+h+`\r
4032Content-Type: `+f.contentType+`\r
4033\r
4034`,b=`\r
4035--`+h+"--",w=qo.getBlob(y,r,b);if(w===null)throw D6();const E={name:f.fullPath},N=bC(a,n.host,n._protocol),S="POST",I=n.maxUploadRetryTime,O=new mA(N,S,cV(n,t),I);return O.urlParams=E,O.headers=c,O.body=w.uploadData(),O.errorHandler=pA(e),O}/**
4036 * @license
4037 * Copyright 2017 Google LLC
4038 *
4039 * Licensed under the Apache License, Version 2.0 (the "License");
4040 * you may not use this file except in compliance with the License.
4041 * You may obtain a copy of the License at
4042 *
4043 *   http://www.apache.org/licenses/LICENSE-2.0
4044 *
4045 * Unless required by applicable law or agreed to in writing, software
4046 * distributed under the License is distributed on an "AS IS" BASIS,
4047 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4048 * See the License for the specific language governing permissions and
4049 * limitations under the License.
4050 */class pV{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=lc.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=lc.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=lc.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,r,s,a){if(this.sent_)throw Hd("cannot .send() more than once");if(vc(e)&&r&&(this.xhr_.withCredentials=!0),this.sent_=!0,this.xhr_.open(t,e,!0),a!==void 0)for(const c in a)a.hasOwnProperty(c)&&this.xhr_.setRequestHeader(c,a[c].toString());return s!==void 0?this.xhr_.send(s):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw Hd("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw Hd("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw Hd("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw Hd("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener("progress",e)}}class BV extends pV{initXhr(){this.xhr_.responseType="text"}}function BA(){return new BV}/**
4051 * @license
4052 * Copyright 2019 Google LLC
4053 *
4054 * Licensed under the Apache License, Version 2.0 (the "License");
4055 * you may not use this file except in compliance with the License.
4056 * You may obtain a copy of the License at
4057 *
4058 *   http://www.apache.org/licenses/LICENSE-2.0
4059 *
4060 * Unless required by applicable law or agreed to in writing, software
4061 * distributed under the License is distributed on an "AS IS" BASIS,
4062 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4063 * See the License for the specific language governing permissions and
4064 * limitations under the License.
4065 */class Cc{constructor(e,t){this._service=e,t instanceof $s?this._location=t:this._location=$s.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new Cc(e,t)}get root(){const e=new $s(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return dA(this._location.path)}get storage(){return this._service}get parent(){const e=tV(this._location.path);if(e===null)return null;const t=new $s(this._location.bucket,e);return new Cc(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw R6(e)}}function yV(n,e,t){n._throwIfRoot("uploadBytes");const r=gV(n.storage,n._location,hA(),new qo(e,!0),t);return n.storage.makeRequestWithTokens(r,BA).then(s=>({metadata:s,ref:n}))}function xV(n){n._throwIfRoot("getDownloadURL");const e=hV(n.storage,n._location,hA());return n.storage.makeRequestWithTokens(e,BA).then(t=>{if(t===null)throw A6();return t})}function CV(n,e){const t=nV(n._location.path,e),r=new $s(n._location.bucket,t);return new Cc(n.storage,r)}/**
4066 * @license
4067 * Copyright 2017 Google LLC
4068 *
4069 * Licensed under the Apache License, Version 2.0 (the "License");
4070 * you may not use this file except in compliance with the License.
4071 * You may obtain a copy of the License at
4072 *
4073 *   http://www.apache.org/licenses/LICENSE-2.0
4074 *
4075 * Unless required by applicable law or agreed to in writing, software
4076 * distributed under the License is distributed on an "AS IS" BASIS,
4077 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4078 * See the License for the specific language governing permissions and
4079 * limitations under the License.
4080 */function bV(n){return/^[A-Za-z]+:\/\//.test(n)}function vV(n,e){return new Cc(n,e)}function yA(n,e){if(n instanceof vC){const t=n;if(t._bucket==null)throw S6();const r=new Cc(t,t._bucket);return e!=null?yA(r,e):r}else return e!==void 0?CV(n,e):n}function wV(n,e){if(e&&bV(e)){if(n instanceof vC)return vV(n,e);throw qy("To use ref(service, url), the first argument must be a Storage instance.")}else return yA(n,e)}function kT(n,e){const t=e==null?void 0:e[sA];return t==null?null:$s.makeFromBucketSpec(t,n)}function EV(n,e,t,r={}){n.host=`${e}:${t}`;const s=vc(e);s&&lx(`https://${n.host}/b`),n._isUsingEmulator=!0,n._protocol=s?"https":"http";const{mockUserToken:a}=r;a&&(n._overrideAuthToken=typeof a=="string"?a:hS(a,n.app.options.projectId))}class vC{constructor(e,t,r,s,a,c=!1){this.app=e,this._authProvider=t,this._appCheckProvider=r,this._url=s,this._firebaseVersion=a,this._isUsingEmulator=c,this._bucket=null,this._host=rA,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=y6,this._maxUploadRetryTime=x6,this._requests=new Set,s!=null?this._bucket=$s.makeFromBucketSpec(s,this._host):this._bucket=kT(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=$s.makeFromBucketSpec(this._url,e):this._bucket=kT(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){TT("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){TT("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){const t=await e.getToken();if(t!==null)return t.accessToken}return null}async _getAppCheckToken(){if(Ts(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=this._appCheckProvider.getImmediate({optional:!0});
4080return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new Cc(this,e)}_makeRequest(e,t,r,s,a=!0){if(this._deleted)return new P6(iA());{const c=z6(e,this._appId,r,s,t,this._firebaseVersion,a,this._isUsingEmulator);return this._requests.add(c),c.getPromise().then(()=>this._requests.delete(c),()=>this._requests.delete(c)),c}}async makeRequestWithTokens(e,t){const[r,s]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,r,s).getPromise()}}const NT="@firebase/storage",ST="0.14.5";/**
4081 * @license
4082 * Copyright 2020 Google LLC
4083 *
4084 * Licensed under the Apache License, Version 2.0 (the "License");
4085 * you may not use this file except in compliance with the License.
4086 * You may obtain a copy of the License at
4087 *
4088 *   http://www.apache.org/licenses/LICENSE-2.0
4089 *
4090 * Unless required by applicable law or agreed to in writing, software
4091 * distributed under the License is distributed on an "AS IS" BASIS,
4092 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4093 * See the License for the specific language governing permissions and
4094 * limitations under the License.
4095 */const xA="storage";function _V(n,e,t){return n=En(n),yV(n,e,t)}function TV(n){return n=En(n),xV(n)}function kV(n,e){return n=En(n),wV(n,e)}function NV(n=Wg(),e){n=En(n);const r=Qg(n,xA).getImmediate({identifier:e}),s=lS("storage");return s&&SV(r,...s),r}function SV(n,e,t,r={}){EV(n,e,t,r)}/**
4096 * @license
4097 * Copyright 2020 Google LLC
4098 *
4099 * Licensed under the Apache License, Version 2.0 (the "License");
4100 * you may not use this file except in compliance with the License.
4101 * You may obtain a copy of the License at
4102 *
4103 *   http://www.apache.org/licenses/LICENSE-2.0
4104 *
4105 * Unless required by applicable law or agreed to in writing, software
4106 * distributed under the License is distributed on an "AS IS" BASIS,
4107 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4108 * See the License for the specific language governing permissions and
4109 * limitations under the License.
4110 */function DV(n,{instanceIdentifier:e}){const t=n.getProvider("app").getImmediate(),r=n.getProvider("auth-internal"),s=n.getProvider("app-check-internal");return new vC(t,r,s,e,wc)}function AV(){mc(new Zo(xA,DV,"PUBLIC").setMultipleInstances(!0)),Zi(NT,ST,""),Zi(NT,ST,"esm2020")}AV();const IV="safaritugendequotebuilder",RV="1:946173158647:web:575b3835adcc357385dff2",PV="AIzaSyBwbYn18F2IPFfCqnYB3oO8HpO2vCz4SoU",MV="safaritugendequotebuilder.firebaseapp.com",LV="ai-studio-ugandasafariitin-884edfdc-6748-45c4-b464-4e43c6aee453",jV="safaritugendequotebuilder.firebasestorage.app",OV="946173158647",FV="",UV="946173158647-dgk199iqope2nrnqq19u9loadcn922st.apps.googleusercontent.com",VV="",Ig={projectId:IV,appI
4110d:RV,apiKey:PV,authDomain:MV,firestoreDatabaseId:LV,storageBucket:jV,messagingSenderId:OV,measurementId:FV,oAuthClientId:UV,recaptchaSiteKey:VV};_O("error");const Rg=_L().length>0?Wg():dx(Ig),Ar=ZS(Rg),GV=new Ia,Oe=Ig.firestoreDatabaseId?xT(Rg,Ig.firestoreDatabaseId):xT(Rg),HV=NV(Rg),Ti=[{id:"story-top-5-parks",title:"Top 5 Must-See National Parks in Uganda",summary:"From tracking mountain gorillas in ancient rainforests to witnessing the sheer power of the Nile, explore the premier wildlife reserves that make Uganda the Pearl of Africa.",content:`Uganda, often hailed as the "Pearl of Africa," is a land of dramatic volcanic topography, emerald rainforests, sprawling savannahs, and world-class biodiversity. Unlike many conventional safari destinations where wildlife is viewed from afar, Uganda offers intimate, ground-level encounters with some of our planet's rarest creatures.
4111
4112Here is our definitive countdown of the top 5 national parks every traveler should consider for an unforgettable safari circuit:
4113
4114### 1. Bwindi Impenetrable National Park
4115Steeped in mist and ancient flora dating back over 25,000 years, Bwindi shelters roughly half the world’s remaining mountain gorillas. Trekking beneath giant mahogany trees and thick bamboo groves to spend an hour with a habituated gorilla family is universally acknowledged as one of life’s most profound wildlife experiences.
4116- **Highlight**: Gorilla tracking across Buhoma, Ruhija, Rushaga, and Nkuringo sectors.
4117- **Top tip**: Secure permits at least 4–6 months in advance.
4118
4119### 2. Queen Elizabeth National Park
4120Spanning the Great Rift Valley floor between Lake George and Lake Edward, Queen Elizabeth offers the ultimate classic savannah safari combined with an incredible aquatic ecosystem.
4121- **Highlight**: The 2-hour boat cruise along the Kazinga Channel delivers dense concentrations of hippos, Nile crocodiles, and herds of bathing elephants.
4122- **Unique feature**: The southern Ishasha sector is famous for rare tree-climbing lions resting in colossal fig trees.
4123
4124### 3. Kibale Forest National Park
4125Celebrated globally as the "Primate Capital of the World," Kibale boasts 13 primate species, with over 1,500 chimpanzees roaming its dense evergreen canopy.
4126- **Highlight**: Chimpanzee tracking with experienced ranger-guides, or the full-day Chimpanzee Habituation Experience (CHEX).
4127- **Nearby**: Bigodi Wetland Sanctuary for guided community bird walks and rare colobus sightings.
4128
4129### 4. Murchison Falls National Park
4130Uganda's largest and oldest conservation area, bisected by the Victoria Nile. The river surges violently through an 8-meter rock gorge before tumbling 43 meters into the Devil's Cauldron.
4131- **Highlight**: Game drives on the northern savannah delta (Rothschild’s giraffes, lions, leopards) paired with a boat cruise to the base of the falls.
4132- **Adventure**: Hike up to the Top of the Falls for breathtaking viewpoints and cooling mist spray.
4133
4134### 5. Kidepo Valley National Park
4135Tucked away in the rugged Karamoja northeast bordering South Sudan and Kenya, Kidepo is widely recognized by seasoned wildlife photographers as Africa's most raw and atmospheric savannah wilderness.
4136- **Highlight**: Vast herds of buffalo numbering in the thousands, cheetahs, ostriches, and dramatic mountain backdrops with virtually no tourist crowds.`,coverImageUrl:"https://images.unsplash.com/photo-1516426122078-c23e76319801?auto=format&fit=crop&w=1200&q=80",category:"Safari Circuits",tags:["National Parks","Gorillas","Safari Planning","Murchison Falls","Kidepo"],destinationId:"bwindi",destinationName:"Bwindi Impenetrable National Park",readTime:"6 min read",authorId:"admin_sys",authorName:"Maria Namatovu",authorEmail:"[email protected]",authorAvatar:"https://images.unsplash.com/photo-1573496359142-b8d87734a5a2?auto=format&fit=crop&w=200&q=80",authorRole:"Senior Safari Expert & Conservationist",status:"published",featured:!0,likesCount:38,publishedAt:"2026-08-14T09:00:00Z",createdAt:"2026-08-14T08:30:00Z"},{id:"story-silverback-encounter",title:"Face-to-Face with the Ruhija Silverback: A Morning in the Mist",summary:"A ranger-guided ascent through Bwindi’s steep ridges led to an unforgettable hour seated just meters from a magnificent 400-pound mountain gorilla patriarch.",content:`The morning began at 7:00 AM at the Ruhija briefing post in eastern Bwindi. The valley was wrapped in thick, cool fog that smelled of wet earth and wild ginger. Our head ranger, Christopher, checked our boots, gaiters, and walking sticks, repeating the golden rule: "Keep 7 to 10 meters distance, stay calm, and if the silverback looks directly at you, crouch low and avert your gaze."
4137
4138We hired two local porters from the community association, which was the single best decision of our journey. Not only did they carry our daypacks and steady our footing along steep mud ridges, but our porter fees directly funded local family schooling and conservation initiatives.
4139
4140After two and a half hours of cutting through dense foliage, Christopher halted and pointed forward with a quiet hand gesture.
4141
4142Through a curtain of wild celery, there he was: the dominant silverback of the Mukiza family. He was colossal—broad shoulders coated 
4142in glistening silver-grey hair, chewing bamboo shoots with calm, effortless strength. Nearby, two juveniles were tumbling playfully down a moss-covered slope while a mother cradled a four-month-old infant.
4143
4144For sixty uninterrupted minutes, the forest around us seemed to stand still. When the silverback looked up and made brief, gentle eye contact, there was a profound sense of intelligence and ancient serenity that no documentary could ever replicate.
4145
4146Visiting mountain gorillas is not just wildlife watching; it is an active lifeline for their survival. Tourism revenue funds the anti-poaching patrols and community clinics that have allowed mountain gorilla populations to rebound past 1,000 individuals today.`,coverImageUrl:"https://images.unsplash.com/photo-1547970810-dc1eac37d174?auto=format&fit=crop&w=1200&q=80",category:"Gorilla Trekking",tags:["Mountain Gorillas","Bwindi","Ruhija","Wildlife Conservation","Porters"],destinationId:"bwindi",destinationName:"Bwindi Impenetrable National Park",readTime:"5 min read",authorId:"consultant_robert",authorName:"Robert Kyagulanyi",authorEmail:"[email protected]",authorAvatar:"https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?auto=format&fit=crop&w=200&q=80",authorRole:"Head Field Guide & Primate Specialist",status:"published",featured:!1,likesCount:52,publishedAt:"2026-08-22T11:15:00Z",createdAt:"2026-08-22T10:45:00Z"},{id:"story-kazinga-channel-cruise",title:"The Kazinga Channel Safari: Where Elephants and River Giants Gather",summary:"Why the 32-kilometer natural waterway connecting Lake George and Lake Edward is one of Africa’s highest-density wildlife boat safaris.",content:`If you ask seasoned East Africa travelers what surprised them most about Uganda, many will point not to the primates, but to the Kazinga Channel boat safari in Queen Elizabeth National Park.
4147
4148Boarding the open-sided vessel at Mweya jetty around 3:00 PM, the equatorial heat begins to soften into a gentle golden light. The Kazinga Channel is a 32-kilometer natural canal connecting Lake George with Lake Edward, and in the late afternoon, it serves as the central gathering place for wildlife from across the park.
4149
4150Within the first fifteen minutes of leaving shore:
4151- Hundreds of hippos wallow in enormous pods, their eyes and ears peeking above the water, grunting rhythmically.
4152- Enormous Nile crocodiles, some over 4 meters long, bask with open jaws on the muddy sandbanks.
4153- Herds of savannah elephants walk down to the water’s edge in orderly family lines, submerging their trunks to drink and splashing their backs with cool water.
4154- Flocks of African skimmers, pink-backed pelicans, and yellow-billed storks fish along the shallows.
4155
4156What makes the boat safari superior to a standard vehicle drive is the proximity and tranquility. Animals in the water have little fear of passing boats, allowing photographers to capture intimate wide-angle shots of elephants drinking just fifteen yards away without causing the slightest disturbance.`,coverImageUrl:"https://images.unsplash.com/photo-1557050543-4d5f4e07ef46?auto=format&fit=crop&w=1200&q=80",category:"Wildlife Encounters",tags:["Queen Elizabeth","Kazinga Channel","Boat Safari","Elephants","Birdwatching"],destinationId:"queen-elizabeth",destinationName:"Queen Elizabeth National Park",readTime:"4 min read",authorId:"consultant_david",authorName:"David Mukasa",authorEmail:"[email protected]",authorAvatar:"https://images.unsplash.com/photo-1500648767791-00dcc994a43e?auto=format&fit=crop&w=200&q=80",authorRole:"Birding & Safari Circuit Guide",status:"published",featured:!1,likesCount:29,publishedAt:"2026-08-28T14:30:00Z",createdAt:"2026-08-28T14:00:00Z"},{id:"story-kibale-chimp-dawn",title:"Dawn in the Primate Capital: Chimpanzee Tracking in Kibale Forest",summary:"The thrilling sound of pant-hoots echoing across the rainforest canopy at dawn, and an exhilarating morning spent tracking our closest living cousins.",content:`Kibale Forest awakens well before sunrise. Long before human trekkers arrive at the Kanyanchu Tourism Centre, the misty canopy vibrates with high-pitched whistling, leaf-rustling, and the haunting resonance of distant pant-hoots.
4157
4158Chimpanzee tracking is a completely different energy than gorilla trekking. While gorillas are terrestrial, slow-moving vegetarians who spend their days quietly grazing on herbs, chimpanzees are dynamic, vocal, and agile tree-dwellers.
4159
4160Our ranger instructed us to follow the acoustic cues. When an alpha male finds an abundant fig tree or reunites with his patrol squad, his call triggers a deafening chorus that ripples for miles through the forest. We moved quickly along winding forest trails, stepping over ironwood roots and avoiding biting safari ants.
4161
4162Suddenly, twenty meters overhead, three chimps were swinging effortlessly through the high canopy. Shortly after, a mother and her young adolescent descended to the forest floor, walking bipedally across a fallen log right beside our trail. Watching a wild chimpanzee use a stripped twig to carefully extract termites from a mound was a testament to tool usage in our 
4162closest animal relatives (sharing 98.7% of our DNA).
4163
4164If you have the stamina, we strongly recommend booking the full-day Chimpanzee Habituation Experience (CHEX), which gives you four hours on the ground with researchers as opposed to the standard one-hour trek.`,coverImageUrl:"https://images.unsplash.com/photo-1540573133985-87b6da6d54a9?auto=format&fit=crop&w=1200&q=80",category:"Wildlife Encounters",tags:["Kibale Forest","Chimpanzees","Primates","Kanyanchu","CHEX"],destinationId:"kibale",destinationName:"Kibale Forest National Park",readTime:"4 min read",authorId:"consultant_sarah",authorName:"Sarah Alupo",authorEmail:"[email protected]",authorAvatar:"https://images.unsplash.com/photo-1544005313-94ddf0286df2?auto=format&fit=crop&w=200&q=80",authorRole:"Primate Researcher & Guide",status:"published",featured:!1,likesCount:34,publishedAt:"2026-09-01T08:00:00Z",createdAt:"2026-09-01T07:30:00Z"},{id:"story-packing-guide-uganda",title:"Essential Gear & Packing for Uganda: What I Wish I Knew Before Bwindi",summary:"A field-tested packing checklist covering gardening gloves, moisture-wicking layers, US Dollar bill requirements, and must-have gear for rainforest trekking.",content:`Packing for an East African safari is usually associated with khaki shorts and wide-brimmed hats. However, Uganda’s unique mix of equatorial savannahs and high-altitude mountain rainforests requires specialized gear preparation.
4165
4166Here are the critical items most first-time travelers overlook:
4167
4168### 1. Sturdy Gardening or Puncture-Proof Gloves
4169In Bwindi and Mgahinga, there are no paved trails. Rangers will often cut through stinging nettles, thorny thistles, and wild brambles with machetes. When you grab branches or forest vines for balance on 45-degree muddy slopes, good gardening gloves protect your hands completely.
4170
4171### 2. High Gaiters & Breathable Rain Gear
4172Do not hike in heavy rubber boots—they will blister your feet on steep climbs. Instead, wear broken-in, waterproof hiking boots paired with lightweight gaiters. Tucking your safari trousers into your socks and gaiters prevents red safari ants from crawling up your legs. Always carry a lightweight, breathable waterproof shell in your daypack, even during the dry season.
4173
4174### 3. Pristine US Dollars (Series 2013 or Newer)
4175Ugandan commercial banks, hotels, and forex bureaus will strictly reject US dollar banknotes dated before 2013, as well as bills with tears, stamps, or heavy folds. Bring crisp, unblemished $50 and $100 bills for permit balances and tip funds.
4176
4177### 4. Insect Repellent with DEET or Picaridin
4178While mountain gorilla habitats sit at cooler elevations (1,800m–2,600m) where mosquito density is low, lower savannah parks like Queen Elizabeth and Murchison Falls have active evening tsetse fly and mosquito populations. Pack 30%+ DEET and wear neutral earth tones (khaki, beige, olive)—avoid dark blue and black, which attract tsetse flies.`,coverImageUrl:"https://images.unsplash.com/photo-1469854523086-cc02fe5d8800?auto=format&fit=crop&w=1200&q=80",category:"Travel Tips",tags:["Packing List","Travel Advice","Bwindi Prep","Gorilla Gear","Forex Tips"],readTime:"5 min read",authorId:"admin_sys",authorName:"Alex Thompson",authorEmail:"[email protected]",authorAvatar:"https://images.unsplash.com/photo-1534528741775-53994a69daeb?auto=format&fit=crop&w=200&q=80",authorRole:"Traveler & Expedition Writer",status:"published",featured:!1,likesCount:45,publishedAt:"2026-09-02T16:20:00Z",createdAt:"2026-09-02T15:40:00Z"}];let ry=!1,DT=!1;async function qV(){if(!(DT||ry)){ry=!0;try{if((await Hr(fh(wn(Oe,"destinations"),eA(1)))).empty){console.log("[Firebase Seeder] Initializing Firestore with Uganda Safari data...");const e=eh(Oe);for(const a of nh)e.set(ft(Oe,"destinations",a.id),a);
4178for(const a of rh)e.set(ft(Oe,"lodges",a.id),a);await e.commit();const t=eh(Oe);for(const a of Kl)t.set(ft(Oe,"flightOperators",a.id),a);for(const a of Yl)t.set(ft(Oe,"flightCosts",a.id),a);await t.commit();const r=eh(Oe);for(const a of $l)r.set(ft(Oe,"reviews",a.id),a);for(const a of xR)r.set(ft(Oe,"itineraries",a.id),a);await r.commit();const s=eh(Oe);for(const a of Ti)s.set(ft(Oe,"stories",a.id),a);await s.commit(),console.log("[Firebase Seeder] Core destinations, lodges, and flight logistics initialized.")}else await zV();DT=!0}catch(n){console.warn("[Firebase Seeder] Seeding check skipped or encountered error (using local cache fallback):",n)}finally{ry=!1}}}async function zV(){try{if((await Hr(fh(wn(Oe,"stories"),eA(1)))).empty){console.log("[Firebase Seeder] Seeding initial Safari Stories to Firestore...");const e=eh(Oe);for(const t of Ti)e.set(ft(Oe,"stories",t.id),t);await e.commit(),console.log("[Firebase Seeder] Safari Stories successfully seeded!")}}catch(n){console.warn("[Firebase Seeder] Story seeding check fallback:",n)}}const JV=new Set(["c1","c2","c3","c4","c5","c6","admin_sys"]),$V=new Set(["[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]"]),ws=(n,e)=>{if(JV.has(n)||/^c[0-9]+$/.test(n)||n==="admin_sys")return!0;if(e){const t=e.toLowerCase().trim();if($V.has(t)||t.endsWith("@example.com")||t.endsWith("@ugandasafari.com")&&!t.startsWith("burtbaguma"))return!0}return!1},tt=(n,e)=>{try{const t=window.localStorage.getItem(n);return t?JSON.parse(t):e}catch{return e}},_t=(n,e)=>{try{window.localStorage.setItem(n,JSON.stringify(e))}catch{}};typeof window<"u"&&qV().catch(()=>{});const AT=n=>({...n,stops:n.stops.map(e=>({...e,activitiesJson:JSON.stringify(e.activities||[]),activities:[]})),breakdownJson:n.breakdown?JSON.stringify(n.breakdown):null,breakdown:null}),Rm=n=>{var e;return{...n,stops:(e=n.stops)==null?void 0:e.map(t=>({...t,activities:t.activitiesJson?JSON.parse(t.activitiesJson):t.activities||[]})),breakdown:n.breakdownJson?JSON.parse(n.breakdownJson):n.breakdown||void 0}},ge={logAnalyticsEvent:(n,e)=>{try{const t=tt("analytics_logs",[]),s=[{event:n,timestamp:new Date().toISOString(),details:e,url:window.location.pathname},...t].slice(0,500);_t("analytics_logs",s)}catch{}},saveItinerary:async n=>{try{await Zn(ft(Oe,"itineraries",n.id),{...AT(n),updatedAt:new Date().toISOString()}),console.log("[Firestore] Itinerary saved:",n.id)}
4178catch(t){console.warn("[Firestore] Error saving itinerary, caching locally:",t)}const e=tt("itineraries",[]);return _t("itineraries",[n,...e.filter(t=>t.id!==n.id)]),n},updateItinerary:async n=>{try{await Zn(ft(Oe,"itineraries",n.id),{...AT(n),updatedAt:new Date().toISOString()},{merge:!0}),console.log("[Firestore] Itinerary updated:",n.id)}catch(r){console.warn("[Firestore] Error updating itinerary, updating local cache:",r)}const e=tt("itineraries",[]),t=e.findIndex(r=>r.id===n.id);return t!==-1?e[t]=n:e.push(n),_t("itineraries",e),n},deleteItinerary:async n=>{try{await cs(ft(Oe,"itineraries",n)),console.log("[Firestore] Itinerary deleted:",n)}catch(t){console.warn("[Firestore] Error deleting itinerary:",t)}const e=tt("itineraries",[]);_t("itineraries",e.filter(t=>t.id!==n))},getAllItineraries:async()=>{try{const e=(await Hr(wn(Oe,"itineraries"))).docs.map(t=>Rm(t.data()));return _t("itineraries",e),e}catch(n){console.warn("[Firestore] Falling back to cached itineraries:",n)}return tt("itineraries",[])},getItinerariesByEmail:async n=>{try{const t=fh(wn(Oe,"itineraries"),ZB("travelerEmail","==",n)),r=await Hr(t);if(!r.empty)return r.docs.map(s=>Rm(s.data()))}catch(t){console.warn("[Firestore] Query by email error, using cache:",t)}return(await ge.getAllItineraries()).filter(t=>{var r;return((r=t.travelerEmail)==null?void 0:r.toLowerCase())===n.toLowerCase()})},getItinerariesByConsultant:async n=>{try{const t=fh(wn(Oe,"itineraries"),ZB("consultantId","==",n)),r=await Hr(t);if(!r.empty)return r.docs.map(s=>Rm(s.data()))}catch(t){console.warn("[Firestore] Query by consultant error, using cache:",t)}return(await ge.getAllItineraries()).filter(t=>t.consultantId===n)},verifyItineraryForReview:async n=>{const e=await ge.getAllItineraries(),t=await ge.getAllReviews(),r=e.find(c=>c.id===n);return r?["confirmed","completed","cancelled"].includes(r.status)?t.find(c=>c.itineraryId===n)?{canReview:!1,consultantId:null,error:"A review has already been submitted for this trip."}:{canReview:!0,consultantId:r.consultantId}:{canReview:!1,consultantId:null,error:"Reviews can only be left for trips that are confirmed, completed, or cancelled."}:{canReview:!1,consultantId:null,error:"Itinerary ID not found."}},submitReview:async n=>{const e=`r-${Date.now()}`,t={...n,id:e};try{await Zn(ft(Oe,"reviews",e),{...t,createdAt:new Date().toISOString()}),console.log("[Firestore] Review submitted:",e)}catch(s){console.warn("[Firestore] Error saving review to Firestore:",s)}const r=tt("reviews",$l);return _t("reviews",[t,...r]),t},updateReview:async n=>{try{await Zn(ft(Oe,"reviews",n.id),n,{merge:!0})}catch(r){console.warn("[Firestore] Error updating review:",r)}const e=tt("reviews",$l),t=e.findIndex(r=>
4178r.id===n.id);return t!==-1&&(e[t]=n,_t("reviews",e)),n},getReviewsByConsultant:async n=>{try{const t=fh(wn(Oe,"reviews"),ZB("consultantId","==",n)),r=await Hr(t);if(!r.empty)return r.docs.map(s=>s.data())}catch(t){console.warn("[Firestore] Error fetching consultant reviews:",t)}return(await ge.getAllReviews()).filter(t=>t.consultantId===n)},getAllReviews:async()=>{try{const n=await Hr(wn(Oe,"reviews"));if(!n.empty){const e=n.docs.map(t=>t.data());return _t("reviews",e),e}}catch(n){console.warn("[Firestore] Error fetching all reviews:",n)}return tt("reviews",$l)},deleteReview:async n=>{try{await cs(ft(Oe,"reviews",n))}catch(t){console.warn("[Firestore] Error deleting review:",t)}const e=tt("reviews",$l);_t("reviews",e.filter(t=>t.id!==n))},getAllConsultants:async()=>{let n=[];try{const s=await Hr(wn(Oe,"consultants"));s.empty||(n=s.docs.map(a=>({...a.data(),id:a.id})))}catch(s){console.warn("[Firestore] Error fetching consultants:",s)}n.length===0&&(n=tt("consultants",[])),n=n.filter(s=>!ws(s.id,s.email));const e=tt("consultants",[]);for(const s of n){const a=e.find(c=>c.id===s.id||c.email&&s.email&&c.email.toLowerCase()===s.email.toLowerCase());a!=null&&a.imageUrl&&(!s.imageUrl||s.imageUrl!==a.imageUrl)&&(s.imageUrl=a.imageUrl)}const r=tt("uganda_safari_users",[]).filter(s=>s.role==="consultant"&&!ws(s.id,s.email));for(const s of r){const a=s.consultantId||s.id,c=n.find(u=>u.id===a||u.email&&s.email&&u.email.toLowerCase()===s.email.toLowerCase());if(c)s.imageUrl&&(!c.imageUrl||c.imageUrl!==s.imageUrl)&&(c.imageUrl=s.imageUrl);else{const u={id:a,name:s.name||"Safari Consultant",email:s.email||`${(s.name||"consultant").toLowerCase().replace(/\s+/g,".")}@ugandasafari.com`,phone:"+256 700 000 000",bio:`${s.name} is a certified Uganda Safari Specialist and travel planner with deep expertise in custom gorilla trekking, wildlife safaris, and primate expeditions.`,imageUrl:s.imageUrl||"https://images.unsplash.com/photo-1534528741775-53994a69daeb?auto=format&fit=crop&q=80&w=600",specialties:["Gorilla Trekking","Primate Safaris","Savannah Wildlife","Bird Watching"],isAvailable:!0,commissionRate:.15,canSetCommissionRate:!0,showCommissionRateOnProfile:!0,socials:{linkedin:"",instagram:"",facebook:""},company:{name:"Uganda Safari Specialists",website:"https://ugandasafari.com",tier:"Mid-range to High-end",utbLicensed:!0,autoMember:!0}};n.push(u)}}return _t("consultants",n),n},getConsultantById:async n=>{try{const t=await Dm(ft(Oe,"consultants",n));if(t.exists())return{...t.data(),id:t.id}}catch(t){console.warn("[Firestore] Error fetching consultant by id:",t)}return(await ge.getAllConsultants()).find(t=>t.id===n||t.email&&n&&t.email.toLowerCase()===n.toLowerCase())},addConsultant:async n=>{try{await Zn(ft(Oe,"consultants",n.id),n,{merge:!0})}catch(r){console.warn("[Firestore] Error adding consultant:",r)}const e=tt("consultants",[]),t=e.findIndex(r=>
4178r.id===n.id);return t>=0?e[t]=n:e.push(n),_t("consultants",e),n},updateConsultant:async n=>{try{await Zn(ft(Oe,"consultants",n.id),n,{merge:!0})}catch(a){console.warn("[Firestore] Error saving consultant profile:",a)}try{const a=Ar.currentUser;a&&await Zn(ft(Oe,"users",a.uid),{name:n.name,imageUrl:n.imageUrl,consultantId:n.id,updatedAt:new Date().toISOString()},{merge:!0})}catch(a){console.warn("[Firestore] Error syncing auth user record:",a)}const e=tt("consultants",[]),t=e.findIndex(a=>a.id===n.id||a.email&&n.email&&a.email.toLowerCase()===n.email.toLowerCase());t!==-1?e[t]={...e[t],...n}:e.push(n),_t("consultants",e);const r=tt("uganda_safari_users",[]),s=r.findIndex(a=>a.consultantId===n.id||a.id===n.id||Ar.currentUser&&a.id===Ar.currentUser.uid||a.email&&n.email&&a.email.toLowerCase()===n.email.toLowerCase());s!==-1&&(r[s]={...r[s],name:n.name,imageUrl:n.imageUrl,consultantId:n.id},_t("uganda_safari_users",r));try{const a=localStorage.getItem("uganda_safari_session");if(a){const c=JSON.parse(a);if(c.consultantId===n.id||c.id===n.id||Ar.currentUser&&c.id===Ar.currentUser.uid||c.email&&n.email&&c.email.toLowerCase()===n.email.toLowerCase()){const u={...c,name:n.name,imageUrl:n.imageUrl,consultantId:n.id};localStorage.setItem("uganda_safari_session",JSON.stringify(u))}}}catch{}return n},deleteConsultant:async n=>{try{await cs(ft(Oe,"consultants",n)),await cs(ft(Oe,"users",n)).catch(()=>{})}catch(r){console.warn("[Firestore] Error deleting consultant:",r)}const e=tt("consultants",[]);_t("consultants",e.filter(r=>r.id!==n));const t=tt("uganda_safari_users",[]);_t("uganda_safari_users",t.filter(r=>r.id!==n&&r.consultantId!==n))},getAllFlightOperators:async()=>{try{const n=await Hr(wn(Oe,"flightOperators"));if(!n.empty){const e=n.docs.map(t=>t.data());return _t("flightOperators",e),e}}catch(n){console.warn("[Firestore] Error fetching flight operators:",n)}return tt("flightOperators",Kl)},addFlightOperator:async n=>{try{await Zn(ft(Oe,"flightOperators",n.id),n)}catch(t){console.warn("[Firestore] Error adding flight operator:",t)}const e=tt("flightOperators",Kl);return _t("flightOperators",[...e,n]),n},updateFlightOperator:async n=>{try{await Zn(ft(Oe,"flightOperators",n.id),n,{merge:!0})}catch(r){console.warn("[Firestore] Error updating flight operator:",r)}const e=tt("flightOperators",Kl),t=e.findIndex(r=>
4178r.id===n.id);return t!==-1&&(e[t]=n,_t("flightOperators",e)),n},deleteFlightOperator:async n=>{try{await cs(ft(Oe,"flightOperators",n))}catch(t){console.warn("[Firestore] Error deleting flight operator:",t)}const e=tt("flightOperators",Kl);_t("flightOperators",e.filter(t=>t.id!==n))},getAllFlightCosts:async()=>{try{const n=await Hr(wn(Oe,"flightCosts"));if(!n.empty){const e=n.docs.map(t=>t.data());return _t("flightCosts",e),e}}catch(n){console.warn("[Firestore] Error fetching flight costs:",n)}return tt("flightCosts",Yl)},addFlightCost:async n=>{try{await Zn(ft(Oe,"flightCosts",n.id),n)}catch(t){console.warn("[Firestore] Error adding flight cost:",t)}const e=tt("flightCosts",Yl);return _t("flightCosts",[...e,n]),n},updateFlightCost:async n=>{try{await Zn(ft(Oe,"flightCosts",n.id),n,{merge:!0})}catch(r){console.warn("[Firestore] Error updating flight cost:",r)}const e=tt("flightCosts",Yl),t=e.findIndex(r=>r.id===n.id);return t!==-1&&(e[t]=n,_t("flightCosts",e)),n},deleteFlightCost:async n=>{try{await cs(ft(Oe,"flightCosts",n))}catch(t){console.warn("[Firestore] Error deleting flight cost:",t)}const e=tt("flightCosts",Yl);_t("flightCosts",e.filter(t=>t.id!==n))},getAllDestinations:async()=>{try{const n=await Hr(wn(Oe,"destinations"));if(!n.empty)return n.docs.map(t=>t.data())}catch(n){console.warn("[Firestore] Falling back to default destinations:",n)}return nh},saveDestination:async n=>{try{await Zn(ft(Oe,"destinations",n.id),n)}catch(e){console.warn("[Firestore] Error saving destination:",e)}return n},deleteDestination:async n=>{try{await cs(ft(Oe,"destinations",n))}catch(e){console.warn("[Firestore] Error deleting destination:",e)}},getAllLodges:async()=>{try{const n=await Hr(wn(Oe,"lodges"));if(!n.empty)return n.docs.map(t=>t.data())}catch(n){console.warn("[Firestore] Falling back to default lodges:",n)}return rh},saveLodge:async n=>{try{await Zn(ft(Oe,"lodges",n.id),n)}catch(e){console.warn("[Firestore] Error saving lodge:",e)}return n},deleteLodge:async n=>{try{await cs(ft(Oe,"lodges",n))}catch(e){console.warn("[Firestore] Error deleting lodge:",e)}},getUserProfile:async n=>{try{const r=await Dm(ft(Oe,"users",n));if(r.exists()){const s={...r.data(),id:r.id};return s.email&&s.email.toLowerCase()==="[email protected]"&&(s.isSuperAdmin=!0,s.role="admin"),s}}catch(r){console.warn("[Firestore] Error fetching user profile:",r)}const t=tt("uganda_safari_users",[]).find(r=>r.id===n);return t?(t.email&&t.email.toLowerCase()==="[email protected]"&&(t.isSuperAdmin=!0,t.role="admin"),t):null},saveUserProfile:async n=>{const e={...n};e.email&&e.email.toLowerCase()==="[email protected]"&&(e.isSuperAdmin=!0,e.role="admin");try{await Zn(ft(Oe,"users",e.id),{...e,updatedAt:new Date().toISOString()},{merge:!0})}catch(s){console.warn("[Firestore] Error saving user profile:",s)}const t=tt("uganda_safari_users",[]),r=t.findIndex(s=>s.id===e.id||s.email&&e.email&&s.email.toLowerCase()===e.email.toLowerCase());r>=0?t[r]={...t[r],...e}:t.push(e),_t("uganda_safari_users",t)},getAllUsers:async()=>{let n=[];try{const s=await Hr(wn(Oe,"users"));s.empty||(n=s.docs.map(a=>({...a.data(),id:a.id})))}catch(s){console.warn("[Firestore] Error fetching users list:",s)}const e=tt("uganda_safari_users",[]);for(const s of e)n.find(c=>c.id===s.id||c.email&&s.email&&c.email.toLowerCase()===s.email.toLowerCase())||n.push(s);n=n.filter(s=>!ws(s.id,s.email));const t="[email protected]",r=n.find(s=>s.email&&s.email.toLowerCase()===t.toLowerCase());return r&&(r.role="admin",r.isSuperAdmin=!0),_t("uganda_safari_users",n),n},deleteUser:async n=>{try{const s=(await Dm(ft(Oe,"users",n))).data(),a=((s==null?void 0:s.email)||"").toLowerCase().trim(),c=s==null?void 0:s.consultantId;if(await cs(ft(Oe,"users",n)),c&&await cs(ft(Oe,"consultants",c)).catch(()=>{}),await cs(ft(Oe,"consultants",n)).catch(()=>{}),a){const u=await Hr(wn(Oe,"consultants"));for(const h of u.docs)(h.data().email||"").toLowerCase().trim()===a&&await cs(ft(Oe,"consultants",h.id)).catch(()=>{})}}catch(r){console.warn("[Firestore] Error deleting user profile:",r)}const e=tt("uganda_safari_users",[]);
4178_t("uganda_safari_users",e.filter(r=>r.id!==n&&(!r.email||r.email.toLowerCase()!==n.toLowerCase())));const t=tt("consultants",[]);_t("consultants",t.filter(r=>r.id!==n&&(!r.email||r.email.toLowerCase()!==n.toLowerCase())))},purgeUnregisteredUsersAndConsultants:async()=>{const n=[];let e=0,t=0;try{const s=(await Hr(wn(Oe,"users"))).docs.map(f=>({...f.data(),id:f.id}));for(const f of s)if(ws(f.id,f.email))try{await cs(ft(Oe,"users",f.id)),e++,n.push(`Removed unregistered user: ${f.name||f.id} (${f.email||"no email"})`)}catch(p){console.warn(`[Purge] Could not delete user doc ${f.id}:`,p)}const a=await Hr(wn(Oe,"users")),c=new Set(a.docs.map(f=>f.id)),u=new Set(a.docs.map(f=>(f.data().email||"").toLowerCase().trim()).filter(Boolean)),h=await Hr(wn(Oe,"consultants"));for(const f of h.docs){const p=f.data(),y=f.id,b=(p.email||"").toLowerCase().trim(),w=ws(y,b),E=c.has(y)||b&&u.has(b);if(w||!E)try{await cs(ft(Oe,"consultants",y)),t++,n.push(`Removed unregistered consultant: ${p.name||y} (${p.email||"no email"})`)}catch(N){console.warn(`[Purge] Could not delete consultant doc ${y}:`,N)}}try{window.localStorage.removeItem("consultants"),window.localStorage.removeItem("uganda_safari_users"),window.localStorage.removeItem("uganda_safari_admin_users")}catch{}}catch(r){console.warn("[Purge] Error during purgeUnregisteredUsersAndConsultants:",r)}return{deletedUsersCount:e,deletedConsultantsCount:t,details:n}},updateUserEmail:async(n,e)=>{try{await Zn(ft(Oe,"users",n),{email:e,updatedAt:new Date().toISOString()},{merge:!0});const r=(await Dm(ft(Oe,"users",n))).data(),s=(r==null?void 0:r.consultantId)||((r==null?void 0:r.role)==="consultant"?n:null);if(s){await Zn(ft(Oe,"consultants",s),{email:e},{merge:!0});const a=tt("consultants",[]),c=a.findIndex(u=>u.id===s);c!==-1&&(a[c].email=e,_t("consultants",a))}}catch(t){console.warn("[Firestore] Error updating user email:",t)}},sendEmail:async n=>{try{const e=await fetch("/api/send-email",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,_ts:n._ts||Date.now()})}),t=await e.json();return!e.ok||!t.success?(console.warn("[Email Service] Email dispatch note:",t.warning||t.error||"Could not send email"),{success:!1,warning:t.warning||t.error}):(t.warning?console.warn("[Email Service]",t.warning):console.log("Email dispatched successfully:",t.messageId||"Delivered"),{success:!0,delivered:t.delivered})}catch(e){return console.warn("[Email Service] Network/transport warning while dispatching email:",e),{success:!1}}},subscribeToDestinations:n=>{try{return Sa(wn(Oe,"destinations"),e=>{if(e.empty)n(nh);else{const t=e.docs.map(r=>r.data());n(t)}},e=>{console.warn("[Firestore Live] Error in destinations listener:",e),n(nh)})}catch(e){return console.warn("[Firestore Live] Setup error in destinations listener:",e),()=>{}}},subscribeToLodges:n=>{try{return Sa(wn(Oe,"lodges"),e=>{if(e.empty)n(rh);else{const t=e.docs.map(r=>r.data());n(t)}},e=>{console.warn("[Firestore Live] Error in lodges listener:",e),n(rh)})}catch(e){return console.warn("[Firestore Live] Setup error in lodges listener:",e),()=>{}}},subscribeToConsultants:n=>{const e=tt("consultants",[]).filter(t=>!ws(t.id,t.email));e.length>0&&n(e);try{return Sa(wn(Oe,"consultants"),t=>{let r=[];t.empty?r=tt("consultants",[]):r=t.docs.map(u=>({...u.data(),id:u.id})),r=r.filter(u=>!ws(u.id,u.email));const s=tt("consultants",[]);for(const u of r){const h=s.find(f=>f.id===u.id||f.email&&u.email&&f.email.toLowerCase()===u.email.toLowerCase());h!=null&&h.imageUrl&&(!u.imageUrl||u.imageUrl!==h.imageUrl)&&(u.imageUrl=h.imageUrl)}const c=tt("uganda_safari_users",[]).filter(u=>u.role==="consultant"&&!ws(u.id,u.email));for(const u of c){const h=u.consultantId||u.id,f=r.find(p=>p.id===h||p.email&&u.email&&p.email.toLowerCase()===u.email.toLowerCase());f?u.imageUrl&&(!f.imageUrl||f.imageUrl!==u.imageUrl)&&(f.imageUrl=u.imageUrl):r.push({id:h,name:u.name||"Safari Consultant",email:u.email||`${(u.name||"consultant").toLowerCase().replace(/\s+/g,".")}@ugandasafari.com`,phone:"+256 700 000 000",bio:`${u.name} is a certified Uganda Safari Specialist and travel planner with deep expertise in custom gorilla trekking, wildlife safaris, and primate expeditions.`,imageUrl:u.imageUrl||"https://images.unsplash.com/photo-153452874
41781775-53994a69daeb?auto=format&fit=crop&q=80&w=600",specialties:["Gorilla Trekking","Primate Safaris","Savannah Wildlife","Bird Watching"],isAvailable:!0,commissionRate:.15,canSetCommissionRate:!0,showCommissionRateOnProfile:!0,socials:{linkedin:"",instagram:"",facebook:""},company:{name:"Uganda Safari Specialists",website:"https://ugandasafari.com",tier:"Mid-range to High-end",utbLicensed:!0,autoMember:!0}})}_t("consultants",r),n(r)},t=>{console.warn("[Firestore Live] Error in consultants listener:",t);const r=tt("consultants",[]).filter(s=>!ws(s.id,s.email));n(r)})}catch(t){console.warn("[Firestore Live] Setup error in consultants listener:",t);const r=tt("consultants",[]).filter(s=>!ws(s.id,s.email));return n(r),()=>{}}},subscribeToReviews:n=>{try{return Sa(wn(Oe,"reviews"),e=>{if(e.empty){const t=tt("reviews",$l);n(t)}else{const t=e.docs.map(r=>r.data());_t("reviews",t),n(t)}},e=>{console.warn("[Firestore Live] Error in reviews listener:",e);const t=tt("reviews",$l);n(t)})}catch(e){return console.warn("[Firestore Live] Setup error in reviews listener:",e),()=>{}}},subscribeToFlightOperators:n=>{try{return Sa(wn(Oe,"flightOperators"),e=>{if(e.empty){const t=tt("flightOperators",Kl);n(t)}else{const t=e.docs.map(r=>r.data());_t("flightOperators",t),n(t)}},e=>{console.warn("[Firestore Live] Error in flight operators listener:",e);const t=tt("flightOperators",Kl);n(t)})}catch(e){return console.warn("[Firestore Live] Setup error in flight operators listener:",e),()=>{}}},subscribeToFlightCosts:n=>{try{return Sa(wn(Oe,"flightCosts"),e=>{if(e.empty){const t=tt("flightCosts",Yl);n(t)}else{const t=e.docs.map(r=>r.data());_t("flightCosts",t),n(t)}},e=>{console.warn("[Firestore Live] Error in flight costs listener:",e);const t=tt("flightCosts",Yl);n(t)})}catch(e){return console.warn("[Firestore Live] Setup error in flight costs listener:",e),()=>{}}},subscribeToUsers:n=>{const e=tt("uganda_safari_users",[]).filter(t=>!ws(t.id,t.email));e.length>0&&n(e);try{return Sa(wn(Oe,"users"),t=>{let r=[];t.empty||t.docs.forEach(u=>{const h=u.data();r.push({...h,id:u.id})});const s=tt("uganda_safari_users",[]);for(const u of s)r.find(f=>f.id===u.id||f.email&&u.email&&f.email.toLowerCase()===u.email.toLowerCase())||r.push(u);r=r.filter(u=>!ws(u.id,u.email));const a="[email protected]",c=r.find(u=>u.email&&u.email.toLowerCase()===a.toLowerCase());c&&(c.role="admin",c.isSuperAdmin=!0),_t("uganda_safari_users",r),n(r)},t=>{console.warn("[Firestore Live] Error in users listener:",t);const r=tt("uganda_safari_users",[]).filter(s=>!ws(s.id,s.email));r.length>0&&n(r)})}catch(t){console.warn("[Firestore Live] Setup error in users listener:",t);const r=tt("uganda_safari_users",[]).filter(s=>!ws(s.id,s.email));return r.length>0&&n(r),()=>{}}},subscribeToItineraries:n=>{try{return Sa(wn(Oe,"itineraries"),e=>{const t=e.docs.map(r=>Rm(r.data()));_t("itineraries",t),n(t)},e=>{console.warn("[Firestore Live] Error in itineraries listener:",e);const t=tt("itineraries",[]);n(t)})}catch(e){console.warn("[Firestore Live] Setup error in itineraries listener:",e);const t=tt("itineraries",[]);return n(t),()=>{}}},createSupportInquiry:async n=>{const e=n.id||`INQ-${Date.now().toString(36).toUpperCase()}`,t={...n,id:e,status:n.status||"open",createdAt:n.createdAt||new Date().toISOString()};try{const s=ft(Oe,"supportInquiries",e);await Zn(s,t)}catch(s){console.warn("[Firestore] Fallback saving support inquiry to local storage:",s)}const r=tt("uganda_support_inquiries",[]);return _t("uganda_support_inquiries",[t,...r]),e},subscribeToStories:n=>{try{return Sa(wn(Oe,"stories"),e=>{if(e.empty){const t=tt("uganda_safari_stories",Ti);n(t)}else{const t=e.docs.map(r=>({...r.data(),id:r.id}));_t("uganda_safari_stories",t),n(t)}},e=>{console.warn("[Firestore Live] Error in stories listener:",e);const t=tt("uganda_safari_stories",Ti);n(t)})}catch(e){console.warn("[Firestore Live] Setup error in stories listener:",e);const t=tt("uganda_safari_stories",Ti);return n(t),()=>{}}},createStory:async(n,e)=>{const t=n.id||`story-${Date.now()}`,r=e.role==="admin"||e.email==="[email protected]",s=n.status||(r?"published":"pending"),a={id:t,title:n.title||"Untitled Safari Story",summary:n.summary||"",content:n.content||"",coverImageUrl:n.coverImageUrl||"https://images.unsplash.com/photo-1516426122078-c23e76319801?auto=format&fit=crop&w=1200&q=80",category:n.category||"Wildlife Encounters",tags:n.tags||["Safari","Uganda"],destinationId:n.destinationId,destinationName:n.destinationName,readTime:n.readTime||`${Math.max(2,Math.ceil((n.content||"").split(/\s+/).length/180))} min read`,authorId:e.id,authorName:e.name,authorEmail:e.email,authorAvatar:e.imageUrl||`https://ui-avatars.c
4178om/api/?name=${encodeURIComponent(e.name)}&background=2563eb&color=fff`,authorRole:e.role==="admin"?"Editorial Admin":e.role==="consultant"?"Safari Consultant":"Traveler & Explorer",status:s,featured:r?!!n.featured:!1,likesCount:0,publishedAt:s==="published"?new Date().toISOString():void 0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};try{const u=ft(Oe,"stories",t);await Zn(u,a)}catch(u){console.warn("[Firestore] Error creating story in firestore, updating local cache:",u)}const c=tt("uganda_safari_stories",Ti);return _t("uganda_safari_stories",[a,...c.filter(u=>u.id!==t)]),t},updateStory:async(n,e)=>{const t={...e,updatedAt:new Date().toISOString()};try{const a=ft(Oe,"stories",n);await Zn(a,t,{merge:!0})}catch(a){console.warn("[Firestore] Error updating story in firestore:",a)}const s=tt("uganda_safari_stories",Ti).map(a=>a.id===n?{...a,...t}:a);_t("uganda_safari_stories",s)},approveStory:async(n,e=!1)=>{const t={status:"published",rejectionReason:void 0,featured:e,publishedAt:new Date().toISOString(),updatedAt:new Date().toISOString()};try{const a=ft(Oe,"stories",n);await Zn(a,t,{merge:!0})}catch(a){console.warn("[Firestore] Error approving story in firestore:",a)}const s=tt("uganda_safari_stories",Ti).map(a=>a.id===n?{...a,...t}:a);_t("uganda_safari_stories",s)},rejectStory:async(n,e="Content does not meet publication guidelines")=>{const t={status:"rejected",rejectionReason:e,updatedAt:new Date().toISOString()};try{const a=ft(Oe,"stories",n);await Zn(a,t,{merge:!0})}catch(a){console.warn("[Firestore] Error rejecting story in firestore:",a)}const s=tt("uganda_safari_stories",Ti).map(a=>a.id===n?{...a,...t}:a);_t("uganda_safari_stories",s)},deleteStory:async n=>{try{const r=ft(Oe,"stories",n);await cs(r)}catch(r){console.warn("[Firestore] Error deleting story in firestore:",r)}const t=tt("uganda_safari_stories",Ti).filter(r=>r.id!==n);_t("uganda_safari_stories",t)},toggleStoryLike:async n=>{const e=`story_liked_${n}`,t=window.localStorage.getItem(e)==="true",r=t?-1:1,s=tt("uganda_safari_stories",Ti),a=s.find(h=>h.id===n),c=Math.max(0,((a==null?void 0:a.likesCount)||0)+r);t?window.localStorage.removeItem(e):window.localStorage.setItem(e,"true");try{const h=ft(Oe,"stories",n);await Zn(h,{likesCount:c},{merge:!0})}catch(h){console.warn("[Firestore] Error updating like count in firestore:",h)}const u=s.map(h=>h.id===n?{...h,likesCount:c}:h);return _t("uganda_safari_stories",u),c}},Pm=(n,e)=>{if(e)return e;const t=(n||"").toLowerCase();return t==="[email protected]"?"admin":t.includes("consultant")||t.includes("safari-expert")?"consultant":"traveler"},Mm=n=>n==="traveler"||n==="admin"?"active":"pending",mr={signInWithEmail:async(n,e)=>{var u;const t=n.trim().toLowerCase(),s=(await HE(Ar,t,e)).user;let a=await ge.getUserProfile(s.uid);const c=t==="[email protected]";if(a)c&&(a.isSuperAdmin=!0,a.role="admin",a.status="active",await ge.saveUserProfile(a));else{const h=Pm(s.email||"");a={id:s.uid,name:s.displayName||((u=s.email)==null?void 0:u.split("@")[0])||(c?"Platform Administrator":"User"),email:s.email||"",role:c?"admin":h,isSuperAdmin:c,status:c?"active":Mm(h),imageUrl:s.photoURL||void 0},await ge.saveUserProfile(a)}return a},signUpWithEmail:async(n,e,t,r="traveler",s)=>{var y;const a=n.trim().toLowerCase(),c=t.trim(),h=(await GE(Ar,a,e)).user;if(c)try{await qE(h,{displayName:c})}catch{}try{await VB(h)}catch(b){console.warn("Could not send Firebase verification email",b)}try{a&&await ge.sendEmail({to:a,subject:"Welcome to Nkuringo Safaris!",body:`Hello ${c||"Traveler"},
4179
4180Thank you for signing up with Nkuringo Safaris. We are thrilled to help you build your dream Uganda Safari itinerary.
4181
4182Best regards,
4183The Nkuringo Safaris Team`})}catch(b){console.warn("Could not send custom welcome email",b)}const f=a==="[email protected]",p={id:h.uid,name:c||((y=h.email)==null?void 0:y.split("@")[0])||(f?"Platform Administrator":"Traveler"),email:a,role:f?"admin":r,isSuperAdmin:f,status:f?"active":Mm(r),consultantId:s||void 0};return await ge.saveUserProfile(p),p},signInWithGoogle:async n=>{var a;const t=(await rj(Ar,GV)).user;let r=await ge.getUserProfile(t.uid);const s=(t.email||"").toLowerCase()==="[email protected]";if(r)s&&(r.isSuperAdmin=!0,r.role="admin",r.status="active",await ge.saveUserProfile(r));else{const c=Pm(t.email||"",n);r={id:t.uid,name:t.displayName||((a=t.email)==null?void 0:a.split("@")[0])||(s?"Platform Administrator":"Google User"),email:t.email||"",role:s?"admin":c,isSuperAdmin:s,status:s?"active":Mm(c),imageUrl:t.photoURL||void 0},await ge.saveUserProfile(r)}return r},signOut:async()=>{await zE(Ar)},sendPasswordReset:async n=>{const e=n.trim().toLowerCase();await VE(Ar,e);try{await ge.sendEmail({to:e,subject:"Nkuringo Safaris - Password Reset Link",body:`Hello,
4184
4185A password reset was requested for your account (${e}).
4186
4187Please check your inbox (and spam folder) for the password reset link sent to you, or return to the application to log in.
4188
4189Best regards,
4190The Nkuringo Safaris Support Team`})}catch(t){console.warn("Could not send custom password reset notification email",t)}},subscribeToAuth:n=>j4(Ar,async e=>{var t;if(!e){n(null);return}try{let r=await ge.getUserProfile(e.uid);const s=(e.email||"").toLowerCase()==="[email protected]";if(r)s&&(r.isSuperAdmin=!0,r.role="admin",r.status="active");else{const a=Pm(e.email||"");r={id:e.uid,name:e.displayName||((t=e.email)==null?void 0:t.split("@")[0])||(s?"Platform Administrator":"User"),email:e.email||"",role:s?"admin":a,isSuperAdmin:s,status:s?"active":Mm(a),imageUrl:e.photoURL||void 0},await ge.saveUserProfile(r)}if(!s&&(r.status==="pending"||r.status==="deactivated")){mr.signOut(),n(null);return}if(!s&&!e.emailVerified&&!e.providerData.some(a=>a.providerId==="google.com")){n(null);return}n(r)}catch{Pm(e.email||""),mr.signOut(),n(null)}}),isEmailVerified:()=>{var n,e;return!!((n=Ar.currentUser)!=null&&n.emailVerified)||!!((e=Ar.currentUser)!=null&&e.providerData.some(t=>t.providerId==="google.com"))}
4190,resendVerificationEmail:async(n,e)=>{var r;const t=n.trim().toLowerCase();if(Ar.currentUser&&((r=Ar.currentUser.email)==null?void 0:r.toLowerCase())===t)try{await VB(Ar.currentUser)}catch(s){console.warn("Could not send Firebase verification email",s)}else if(e)try{const s=await HE(Ar,t,e);await VB(s.user),await mr.signOut()}catch(s){console.warn("Sign-in during verification resend error:",s)}else try{await VE(Ar,t)}catch(s){console.warn("Password reset fallback for verification error:",s)}try{t&&await ge.sendEmail({to:t,subject:"Nkuringo Safaris - Account Verification",body:`Hello,
4191
4192We have re-sent the verification instructions for your Nkuringo Safaris account (${t}).
4193
4194Please verify your account to start planning and booking your safari itinerary.
4195
4196Best regards,
4197The Nkuringo Safaris Team`})}catch(s){console.warn("Could not send custom verification email",s)}},adminCreateUser:async n=>{const{email:e,password:t,name:r,role:s,phone:a,specialties:c,bio:u}=n;if(s==="traveler")throw new Error("Traveler accounts cannot be registered from the Admin Staff portal.");const h=(e||"").trim().toLowerCase(),f=(r||"").trim();if(!h||!h.includes("@"))throw new Error("Please enter a valid email address.");if(!t||t.length<6)throw new Error("Password must be at least 6 characters long.");const p=`adminCreateUser_${Date.now()}_${Math.random().toString(36).substring(2,7)}`,y=dx(Ig,p),b=ZS(y);let w="";try{const I=await GE(b,h,t);if(w=I.user.uid,f)try{await qE(I.user,{displayName:f})}catch{}await zE(b)}catch(I){try{await TE(y)}catch{}throw I.code==="auth/email-already-in-use"?new Error("An account with this email address already exists in Firebase Authentication. You can adjust their role directly in the Users table."):new Error(I.message||"Failed to create user credentials in Firebase Authentication.")}try{await TE(y)}catch{}const E=h==="[email protected]",N=s==="consultant"?w:void 0,S={id:w,name:f||h.split("@")[0],email:h,role:E?"admin":s,isSuperAdmin:E,status:"active",consultantId:N,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};if(await ge.saveUserProfile(S),s==="consultant"){const I={id:w,name:f,email:h,phone:(a==null?void 0:a.trim())||"+256 700 000 000",bio:(u==null?void 0:u.trim())||`${f} is a certified Uganda Safari Specialist and travel planner with deep expertise in custom gorilla trekking, wildlife safaris, and primate expeditions.`,imageUrl:"https://images.unsplash.com/photo-1534528741775-53994a69daeb?auto=format&fit=crop&q=80&w=600",specialties:c&&c.length>0?c:["Gorilla Trekking","Primate Safaris","Savannah Wildlife","Bird Watching"],isAvailable:!0,commissionRate:.15,canSetCommissionRate:!0,showCommissionRateOnProfile:!0,socials:{linkedin:"",instagram:"",facebook:""},company:{name:"Nkuringo Safaris Specialists",website:"https://ugandasafari.com",tier:"Mid-range to High-end",utbLicensed:!0,autoMember:!0}};await ge.addConsultant(I)}try{await ge.sendEmail({to:h,subject:`Welcome to Nkuringo Safaris (${s.toUpperCase()})`,body:`Hello ${f},
4198
4199Your staff account has been set up on the Nkuringo Safaris platform.
4200
4201Account Details:
4202- Name: ${f}
4203- Email: ${h}
4204- Role: ${s.toUpperCase()}
4205- Temporary Password: ${t}
4206
4207You can log in at: ${typeof window<"u"?window.location.origin:"https://ugandasafari.com"}
4208Please change your password after logging in.
4209
4210Best regards,
4211The Nkuringo Safaris Management`})}catch(I){console.warn("Could not send staff welcome email:",I)}return S}},KV=({onClose:n,onLoginSuccess:e})=>{const[t,r]=R.useState("signin"),[s,a]=R.useState(""),[c,u]=R.useState(""),[h,f]=R.useState(""),[p,y]=R.useState(""),[b,w]=R.useState("traveler"),[E,N]=R.useState(!1),[S,I]=R.useState(!1),[O,F]=R.useState(""),[J,z]=R.useState(""),[U,D]=R.useState(""),[k,_]=R.useState(!1),[M,j]=R.useState(!1),H=X=>{r(X),F(""),z(""),u(""),f(""),j(!1)},L=async X=>{const ae=(X||s).trim().toLowerCase();if(!ae){F("Please enter your email address first, then click Forgot password.");return}_(!0),F(""),z(""),D("");try{await mr.sendPasswordReset(ae),D(`A password reset link was sent to ${ae}. Please check your inbox and spam folder.`)}catch(Te){Te.code==="auth/user-not-found"?F('No active account found for this email. Click "Sign Up" to register.'):F(Te.message||"Unable to send password reset email.")}finally{_(!1)}},ee=async()=>{const X=s.trim().toLowerCase();if(!X){F("Please provide your email address to resend verification.");return}_(!0),F(""),z(""),D(""),j(!1);try{await mr.resendVerificationEmail(X,c),D(`A new verification email has been sent to ${X}. Please check your inbox and spam folder.`)}catch(ae){F(ae.message||"Unable to resend verification email.")}finally{_(!1)}},ne=async X=>{X.preventDefault();const ae=s.trim().toLowerCase();if(!ae){F("Please enter your email address.");return}_(!0),F(""),z(""),D("");try{const Te=await mr.signInWithEmail(ae,c);if(Te.status==="pending"){mr.signOut(),F("Your account is pending approval by the system admin (Bert Baguma). Please wait 2-48 hours."),z("PENDING_APPROVAL");return}if(Te.status==="deactivated"){mr.signOut(),F("Your account has been deactivated."),z("DEACTIVATED");return}if(!mr.isEmailVerified()){mr.signOut(),F("Please verify your email address before logging in."),j(!0),z("UNVERIFIED");return}e(Te)}catch(Te){console.error("[Auth Error]",Te),Te.code==="auth/invalid-credential"||Te.code==="auth/wrong-password"||Te.code==="auth/user-not-found"?(z("INVALID_CREDENTIALS"),F("Invalid email or password.")):Te.code==="auth/invalid-email"?(F("Please enter a valid email address."),z("INVALID_EMAIL")):F(Te.message||"Authentication failed. Please check your credentials.")}finally{_(!1)}},G=async X=>{X.preventDefault();const ae=s.trim().toLowerCase(),Te=p.trim();if(!ae){F("Please enter your email address.");return}if(c!==h){F("Passwords do not match. Please re-enter your password."),z("PASSWORD_MISMATCH");return}if(c.length<6){F("Password should be at least 6 characters."),z("WEAK_PASSWORD");return}_(!0),F(""),z(""),D("");try{if((await mr.signUpWithEmail(ae,c,Te,b)).status==="pending"){D("Account created! Your account requires approval from the system admin, Bert Baguma. Please wait 2-48 hours, and verify your email via the link sent."),mr.signOut();return}D("Account created! A verification link has been sent to your email. Please verify your email before signing in."),mr.signOut();return}catch(K){console.error("[Sign Up Error]",K),K.code==="auth/email-already-in-use"?(z("EMAIL_EXISTS"),F(`This email (${ae}
4211) is already registered.`)):K.code==="auth/weak-password"?(F("Password should be at least 6 characters."),z("WEAK_PASSWORD")):F(K.message||"Registration failed.")}finally{_(!1)}},W=async()=>{_(!0),F(""),z("");try{const X=await mr.signInWithGoogle(b);if(X.status==="pending"){mr.signOut(),F("Your account requires approval from the system admin (Bert Baguma). Please wait 2-48 hours.");return}if(X.status==="deactivated"){mr.signOut(),F("Your account has been deactivated.");return}e(X)}catch(X){console.error("[Google Auth Error]",X),F(X.message||"Google sign-in was cancelled or encountered an error.")}finally{_(!1)}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-xs flex justify-center items-center z-50 p-4",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-2xl p-6 sm:p-8 w-full max-w-md border border-gray-100 dark:border-gray-700",onClick:X=>X.stopPropagation(),children:[o.jsxs("div",{className:"flex justify-between items-center mb-5",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:t==="signin"?"Sign In":"Create Account"}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"Nkuringo Safaris • Cloud Firestore Secured"})]}),o.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 text-2xl p-1 leading-none cursor-pointer","aria-label":"Close",children:"×"})]}),o.jsxs("div",{className:"flex bg-gray-100 dark:bg-gray-700/60 p-1 rounded-xl mb-6",children:[o.jsx("button",{type:"button",onClick:()=>H("signin"),className:`flex-1 py-1.5 text-xs font-semibold rounded-lg transition-all cursor-pointer ${t==="signin"?"bg-white dark:bg-gray-800 text-brand-dark dark:text-white shadow-xs":"text-gray-500 dark:text-gray-400 hover:text-gray-800"}`,children:"Sign In"}),o.jsx("button",{type:"button",onClick:()=>H("signup"),className:`flex-1 py-1.5 text-xs font-semibold rounded-lg transition-all cursor-pointer ${t==="signup"?"bg-white dark:bg-gray-800 text-brand-dark dark:text-white shadow-xs":"text-gray-500 dark:text-gray-400 hover:text-gray-800"}`,children:"Sign Up"})]}),t==="signin"&&o.jsxs("form",{onSubmit:ne,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-gray-700 dark:text-gray-300 text-xs font-semibold uppercase tracking-wider mb-1.5",htmlFor:"email",children:"Email Address"}),o.jsx("input",{id:"email",type:"email",value:s,onChange:X=>a(X.target.value),className:"w-full px-3.5 py-2.5 text-sm border rounded-xl border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-emerald-500 focus:outline-none",placeholder:"[email protected]",required:!0})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex justify-between items-center mb-1.5",children:[o.jsx("label",{className:"block text-gray-700 dark:text-gray-300 text-xs font-semibold uppercase tracking-wider",htmlFor:"password",children:"Password"}),o.jsx("button",{type:"button",onClick:()=>L(),className:"text-xs text-emerald-600 dark:text-emerald-400 hover:underline cursor-pointer",children:"Forgot password?"})]}),o.jsxs("div",{className:"relative",children:[o.jsx("input",{id:"password",type:E?"text":"password",value:c,onChange:X=>u(X.target.value),className:"w-full px-3.5 py-2.5 pr-10 text-sm border rounded-xl border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-emerald-500 focus:outline-none",placeholder:"••••••••",required:!0}),o.jsx("button",{type:"button",onClick:()=>N(!E),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 cursor-pointer p-1","aria-label":E?"Hide password":"Show password",children:E?o.jsx(AB,{className:"w-4 h-4"}):o.jsx(Vm,{className:"w-4 h-4"})})]})]}),O&&o.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800/40 p-3 rounded-xl flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(uc,{className:"w-4 h-4 text-red-600 dark:text-red-400 shrink-0 mt-0.5"}),o.jsx("p",{className:"text-red-700 dark:text-red-300 text-xs leading-relaxed",children:O})]}),J==="INVALID_CREDENTIALS"&&o.jsxs("div",{className:"pt-2 border-t border-red-200/70 dark:border-red-800/40 flex flex-col gap-2",children:[o.jsx("p",{className:"text-[11px] text-gray-600 dark:text-gray-400",children:"Need help getting into your account?"}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsxs("button",{type:"button",onClick:()=>L(),className:"inline-flex items-center gap-1 px-2.5 py-1 text-xs font-semibold bg-white dark:bg-gray-800 border border-red-200 dark:border-red-800 text-emerald-700 dark:text-emerald-400 rounded-lg hover:bg-emerald-50 dark:hover:bg-emerald-950/30 transition-colors cursor-pointer",children:[o.jsx(gy,{className:"w-3 h-3"}),"Send Password Reset"]}),o.jsx("button",{type:"button",onClick:()=>H("signup"),className:"inline-flex items-center gap-1 px-2.5 py-1 text-xs font-semibold bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer",children:"Create New Account"})]})]}),M&&o.jsx("div",{className:"pt-2 border-t border-red-200/70 dark:border-red-800/40",children:o.jsxs("button",{type:"button",onClick:ee,className:"inline-flex items-center gap-1.5 text-xs text-red-700 dark:text-red-300 font-bold hover:underline cursor-pointer",children:[o.jsx($g,{className:"w-3.5 h-3.5"}
4211),"Resend Verification Email"]})})]}),U&&o.jsxs("div",{className:"bg-emerald-50 dark:bg-emerald-900/30 border border-emerald-200 dark:border-emerald-800/40 p-3 rounded-xl flex items-start gap-2",children:[o.jsx(Ga,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400 shrink-0 mt-0.5"}),o.jsx("p",{className:"text-emerald-800 dark:text-emerald-200 text-xs font-medium leading-relaxed",children:U})]}),o.jsx(He,{type:"submit",disabled:k,className:"w-full py-2.5",children:k?o.jsx(At,{}):"Sign In"}),o.jsxs("div",{className:"relative flex py-2 items-center",children:[o.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"}),o.jsx("span",{className:"flex-shrink mx-3 text-xs text-gray-400",children:"or"}),o.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"})]}),o.jsxs("button",{type:"button",onClick:W,disabled:k,className:"w-full flex items-center justify-center gap-2.5 py-2.5 px-4 border border-gray-300 dark:border-gray-600 rounded-xl text-sm font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",children:[o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",children:[o.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"}),o.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"}),o.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.06H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.94l2.85-2.22.81-.63z"}),o.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.99 3.47 2.18 7.06l3.66 2.84c.87-2.6 3.3-4.52 6.16-4.52z"})]}),"Continue with Google"]})]}),t==="signup"&&(U?o.jsxs("div",{className:"py-8 flex flex-col items-center justify-center text-center space-y-4 animate-fade-in",children:[o.jsx("div",{className:"w-16 h-16 bg-emerald-100 dark:bg-emerald-900/30 text-emerald-600 dark:text-emerald-400 rounded-full flex items-center justify-center mb-2",children:o.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),o.jsx("h3",{className:"text-xl font-bold text-gray-900 dark:text-white font-heading",children:"Registration Successful"}),o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 px-4 leading-relaxed",children:U}),o.jsx(He,{onClick:()=>H("signin"),className:"w-full mt-6 py-2.5",children:"Return to Sign In"})]}):o.jsxs("form",{onSubmit:G,className:"space-y-3.5",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-gray-700 dark:text-gray-300 text-xs font-semibold uppercase tracking-wider mb-1",htmlFor:"signup-name",children:"Full Name"}),o.jsx("input",{id:"signup-name",type:"text",value:p,onChange:X=>y(X.target.value),className:"w-full px-3.5 py-2 text-sm border rounded-xl border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-emerald-500 focus:outline-none",placeholder:"Sarah Jenkins",required:!0})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-gray-700 dark:text-gray-300 text-xs font-semibold uppercase tracking-wider mb-1",htmlFor:"signup-email",children:"Email Address"}),o.jsx("input",{id:"signup-email",type:"email",value:s,onChange:X=>a(X.target.value),className:"w-full px-3.5 py-2 text-sm border rounded-xl border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-emerald-500 focus:outline-none",placeholder:"[email protected]",required:!0})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-gray-700 dark:text-gray-300 text-xs font-semibold uppercase tracking-wider mb-1",htmlFor:"signup-password",children:"Password"}),o.jsxs("div",{className:"relative",children:[o.jsx("input",{id:"signup-password",type:E?"text":"password",value:c,onChange:X=>u(X.target.value),className:"w-full px-3.5 py-2 pr-10 text-sm border rounded-xl border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-emerald-500 focus:outline-none",placeholder:"At least 6 characters",required:!0,minLength:6}),o.jsx("button",{type:"button",onClick:()=>N(!E),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 cursor-pointer p-1","aria-label":E?"Hide password":"Show password",children:E?o.jsx(AB,{className:"w-4 h-4"}):o.jsx(Vm,{className:"w-4 h-4"})})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-gray-700 dark:text-gray-300 text-xs font-semibold uppercase tracking-wider mb-1",htmlFor:"signup-confirm-password",children:"Confirm Password"}),o.jsxs("div",{className:"relative",children:[o.jsx("input",{id:"signup-confirm-password",type:S?"text":"password",value:h,onChange:X=>f(X.target.value),className:"w-full px-3.5 py-2 pr-10 text-sm border rounded-xl border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-emerald-500 focus:outline-none",placeholder:"Repeat your password",required:!0,minLength:6}),o.jsx("button",{type:"button",onClick:()=>I(!S),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 cursor-pointer p-1","aria-label":S?"Hide password":"Show password",children:S?o.jsx(AB,{className:"w-4 h-4"}):o.jsx(Vm,{className:"w-4 h-4"})})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-gray-700 dark:text-gray-300 text-xs font-semibold uppercase tracking-wider mb-1",children:"Account Type"}),o.jsxs("select",{value:b,onChange:X=>w(X.target.value),className:"w-full px-3.5 py-2 text-sm border rounded-xl border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-emerald-500 focus:outline-none cursor-pointer",children:[o.jsx("option",{value:"traveler",children:"Traveler 
4211(Plan & Book Safaris)"}),o.jsx("option",{value:"consultant",children:"Expert (Consultant)"}),o.jsx("option",{value:"demo",children:"Demo Access"})]})]}),O&&o.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800/40 p-3 rounded-xl flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(uc,{className:"w-4 h-4 text-red-600 dark:text-red-400 shrink-0 mt-0.5"}),o.jsx("p",{className:"text-red-700 dark:text-red-300 text-xs leading-relaxed",children:O})]}),J==="EMAIL_EXISTS"&&o.jsxs("div",{className:"pt-2 border-t border-red-200/70 dark:border-red-800/40 flex flex-col gap-2",children:[o.jsx("p",{className:"text-[11px] text-gray-600 dark:text-gray-400",children:"Since this email is already registered, choose an option below:"}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsxs("button",{type:"button",onClick:()=>H("signin"),className:"inline-flex items-center gap-1 px-3 py-1.5 text-xs font-semibold bg-emerald-600 text-white rounded-lg hover:bg-emerald-700 transition-colors shadow-xs cursor-pointer",children:["Sign In with this Email",o.jsx(Bh,{className:"w-3 h-3"})]}),o.jsxs("button",{type:"button",onClick:()=>L(s),className:"inline-flex items-center gap-1 px-2.5 py-1.5 text-xs font-semibold bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-emerald-700 dark:text-emerald-400 rounded-lg hover:bg-emerald-50 dark:hover:bg-emerald-950/30 transition-colors cursor-pointer",children:[o.jsx(gy,{className:"w-3 h-3"}),"Reset Password"]})]})]})]}),U&&o.jsxs("div",{className:"bg-emerald-50 dark:bg-emerald-900/30 border border-emerald-200 dark:border-emerald-800/40 p-3 rounded-xl flex items-start gap-2",children:[o.jsx(Ga,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400 shrink-0 mt-0.5"}),o.jsx("p",{className:"text-emerald-800 dark:text-emerald-200 text-xs font-medium leading-relaxed",children:U})]}),o.jsx(He,{type:"submit",disabled:k,className:"w-full py-2.5",children:k?o.jsx(At,{}):"Create Account"}),o.jsxs("div",{className:"relative flex py-2 items-center",children:[o.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"}),o.jsx("span",{className:"flex-shrink mx-3 text-xs text-gray-400",children:"or"}),o.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"})]}),o.jsxs("button",{type:"button",onClick:W,disabled:k,className:"w-full flex items-center justify-center gap-2.5 py-2.5 px-4 border border-gray-300 dark:border-gray-600 rounded-xl text-sm font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",children:[o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",children:[o.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"}),o.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"}),o.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.06H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.94l2.85-2.22.81-.63z"}),o.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.99 3.47 2.18 7.06l3.66 2.84c.87-2.6 3.3-4.52 6.16-4.52z"})]}),"Sign Up with Google"]})]}))]})})},jn={VERIFIED_EMAIL:"safari_verified_email",VERIFIED_CODE:"safari_verified_trip_code",VERIFIED_TOKEN:"safari_trip_token",LAST_ACTIVITY:"safari_last_activity_ts",TIMEOUT_PREF:"safari_timeout_pref",EXPIRED_NOTICE:"safari_session_expired_notice"};function eg(n,e,t=30){var r;try{if(typeof document>"u")return;const s=t*24*60*60,c=typeof window<"u"&&((r=window.location)==null?void 0:r.protocol)==="https:"?"; Secure":"";document.cookie=`${encodeURIComponent(n)}=${encodeURIComponent(e)}; path=/; max-age=${s}; SameSite=Lax${c}`}catch(s){console.warn("Unable to set cookie:",s)}}function wC(n){try{if(typeof document>"u")return null;const e=encodeURIComponent(n)+"=",t=document.cookie.split(";");for(let r=0;r<t.length;r++){let s=t[r];for(;s.charAt(0)===" ";)s=s.substring(1,s.length);if(s.indexOf(e)===0)return decodeURIComponent(s.substring(e.length,s.length))}}catch(e){console.warn("Unable to read cookie:",e)}return null}function sy(n){try{if(typeof document>"u")return;document.cookie=`${encodeURIComponent(n)}=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax`}catch(e){console.warn("Unable to delete cookie:",e)}}const IT="https://ugandasafaris.com";function YV(n,e){const t={email:n.trim().toLowerCase(),code:e.trim().toUpperCase(),ts:Date.now()};try{return btoa(unescape(encodeURIComponent(JSON.stringify(t))))}catch{return btoa(JSON.stringify(t))}}function QV(n){try{const e=decodeURIComponent(escape(atob(n))),t=JSON.parse(e);if(t&&typeof t.email=="string"&&typeof t.code=="string")return{email:t.email.toLowerCase().trim(),code:t.code.toUpperCase().trim(),ts:t.ts||0}}catch{try{const e=JSON.parse(atob(n));if(e&&typeof e.email=="string"&&typeof e.code=="string")return{email:e.email.toLowerCase().trim(),code:e.code.toUpperCase().trim(),ts:e.ts||0}}catch{return null}}return null}function WV(n,e,t=IT){const r=(t||IT).replace(/\/+$/,""),s=n.trim().toLowerCase(),a=e.trim().toUpperCase(),c=YV(s,a),u=new URLSearchParams({view:"manage_trips",verify_email:s,trip_code:a,token:c});return`${r}/?${u.toString()}`}function CA(){if(typeof window>"u")return null;try{const n=new URLSearchParams(window.location.search);let e=null;window.location.hash&&window.location.hash.includes("?")&&(e=new URLSearchParams(window.location.hash.substring(window.location.hash.indexOf("?"))));const t=n.get("verify_email")||n.get("email")||(e==null?void 0:e.get("verify_email"))||(e==null?void 0:e.get("email")),r=n.get("trip_code")||n.get("code")||n.get("tripCode")||(e==null?void 0:e.get("trip_code"))||(e==null?void 0:e.get("
4211code")),s=n.get("token")||(e==null?void 0:e.get("token"));if(s&&(!t||!r)){const a=QV(s);if(a)return{email:a.email,tripCode:a.code,token:s,timestamp:a.ts}}if(t&&r)return{email:t.trim().toLowerCase(),tripCode:r.trim().toUpperCase(),token:s||void 0,timestamp:Date.now()}}catch(n){console.warn("Error reading verification parameters from URL:",n)}return null}const EC={"15m":900*1e3,"2m":120*1e3,"30s":30*1e3},XV=EC["15m"];function Pg(){try{const n=localStorage.getItem(jn.TIMEOUT_PREF)||wC(jn.TIMEOUT_PREF);if(n&&EC[n])return n}catch{}return"15m"}function ZV(n){try{localStorage.setItem(jn.TIMEOUT_PREF,n),eg(jn.TIMEOUT_PREF,n,30),gh()}catch{}}function bA(){const n=Pg();return EC[n]||XV}function gh(){try{const n=Date.now().toString();sessionStorage.setItem(jn.LAST_ACTIVITY,n)}catch{}}function vA(){try{const n=sessionStorage.getItem(jn.LAST_ACTIVITY);if(n){const e=parseInt(n,10);if(!isNaN(e)&&e>0)return e}}catch{}return Date.now()}function _C(){if(!(!!wC(jn.VERIFIED_EMAIL)||!!(typeof sessionStorage<"u"&&sessionStorage.getItem(jn.VERIFIED_EMAIL))))return!1;const e=vA(),t=bA();return Date.now()-e>t}function Lm(){const n=vA(),t=bA()-(Date.now()-n);return Math.max(0,Math.ceil(t/1e3))}function wA(n){try{sessionStorage.setItem(jn.EXPIRED_NOTICE,n)}catch{}}function eG(){try{return sessionStorage.getItem(jn.EXPIRED_NOTICE)}catch{return null}}function EA(){try{sessionStorage.removeItem(jn.EXPIRED_NOTICE)}catch{}}function Mg(n,e,t){const r=n.trim().toLowerCase();eg(jn.VERIFIED_EMAIL,r,30),e&&eg(jn.VERIFIED_CODE,e.trim().toUpperCase(),30),t&&eg(jn.VERIFIED_TOKEN,t,30);try{sessionStorage.setItem(jn.VERIFIED_EMAIL,r),e&&sessionStorage.setItem(jn.VERIFIED_CODE,e.trim().toUpperCase())}catch{}gh(),EA()}function ju(){sy(jn.VERIFIED_EMAIL),sy(jn.VERIFIED_CODE),sy(jn.VERIFIED_TOKEN);try{sessionStorage.removeItem(jn.VERIFIED_EMAIL),sessionStorage.removeItem(jn.VERIFIED_CODE),sessionStorage.removeItem("safari_verified_email"),sessionStorage.removeItem(jn.LAST_ACTIVITY)}catch{}}function _A(){if(_C()){const e=Pg();return wA(`Your session timed out after ${e==="15m"?"15 minutes":e==="2m"?"2 minutes":"30 seconds"} of inactivity to keep your itinerary and personal data secure. Please re-enter your Trip Reference Code or use your direct email link to resume.`),ju(),null}const n=wC(jn.VERIFIED_EMAIL);if(n)return n.trim().toLowerCase();try{const e=sessionStorage.getItem(jn.VERIFIED_EMAIL)||sessionStorage.getItem("safari_verified_email");if(e)return e.trim().toLowerCase()}catch{}return null}const RT=()=>`stop_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,PT=["entebbe","kampala","ziwa-rhino","lake-mburo"],Lg="uganda_safari_session",tG=()=>{try{const n=localStorage.getItem(Lg),e=n?JSON.parse(n):null;if(e)return e.role==="traveler"&&_C()?(localStorage.removeItem(Lg),ju(),null):e;const t=_A();if(t)return{id:t,name:t.split("@")[0],email:t,role:"traveler",status:"active"}}
4211catch{return null}return null},nG=()=>{try{const n=localStorage.getItem("uganda_safari_draft_itinerary");return n?JSON.parse(n):null}catch{return null}},MT=(n,e)=>({stops:e?[e]:[],transportSettings:[],startDate:"",travelerCount:2,startLocation:"entebbe",endLocation:"entebbe",consultantId:n}),rG=()=>{if(typeof window<"u")try{const n=new URLSearchParams(window.location.search),e=(n.get("view")||n.get("action")||"").toLowerCase();if(e==="manage_trips"||e==="trip_management"||e==="manage-trips"||e==="trips"||n.get("verify_email")||n.get("trip_code"))return Le.TripManagement}catch{}return Le.Home},TA={destinations:nh,lodges:rh,currentView:rG(),loggedInUser:tG(),isLoginModalOpen:!1,draftItinerary:nG(),bookingItinerary:null,bookingTravelerName:"",bookingTravelerEmail:"",bookingTravelerPhone:"",activeConsultantProfileId:null,isBookingDetailsVerified:!1},sG=(n,e)=>{switch(e.type){case"SET_PLATFORM_DATA":return{...n,destinations:e.payload.destinations,lodges:e.payload.lodges};case"SET_DESTINATIONS":return{...n,destinations:e.payload};case"SET_LODGES":return{...n,lodges:e.payload};case"UPDATE_LODGE":return{...n,lodges:n.lodges.map(s=>s.id===e.payload.id?e.payload:s)};case"NAVIGATE":{window.scrollTo(0,0);const s={...n,currentView:e.payload.view};return e.payload.clearBooking?{...s,draftItinerary:null,bookingItinerary:null,bookingTravelerName:"",bookingTravelerEmail:"",bookingTravelerPhone:"",isBookingDetailsVerified:!1}:s}case"LOGIN_SUCCESS":localStorage.setItem(Lg,JSON.stringify(e.payload));const t=e.payload.role==="traveler"?Le.TripManagement:e.payload.role==="admin"?Le.AdminHub:Le.TripDashboard;return{...n,loggedInUser:e.payload,isLoginModalOpen:!1,currentView:n.currentView===Le.TripManagement?Le.TripManagement:t};case"LOGOUT":return localStorage.removeItem(Lg),ju(),{...TA,currentView:Le.Home,loggedInUser:null};case"OPEN_LOGIN_MODAL":return{...n,isLoginModalOpen:!0};case"CLOSE_LOGIN_MODAL":return{...n,isLoginModalOpen:!1};case"START_ITINERARY":return{...n,draftItinerary:MT(null,e.payload),bookingItinerary:null,bookingTravelerName:"",bookingTravelerEmail:"",bookingTravelerPhone:"",currentView:Le.ItineraryBuilder,isBookingDetailsVerified:!1};case"START_ITINERARY_WITH_CONSULTANT":const r=n.draftItinerary?{...n.draftItinerary,consultantId:e.payload}:MT(e.payload);return{...n,draftItinerary:r,bookingItinerary:null,bookingTravelerName:"",bookingTravelerEmail:"",bookingTravelerPhone:"",currentView:Le.ItineraryBuilder,isBookingDetailsVerified:!1};case"UPDATE_DRAFT_ITINERARY":return{...n,draftItinerary:e.payload};case"DISCARD_DRAFT":return{...n,draftItinerary:null,bookingItinerary:null,bookingTravelerName:"",bookingTravelerEmail:"",bookingTravelerPhone:"",isBookingDetailsVerified:!1};case"NAVIGATE_TO_BOOKING":return{...n,bookingItinerary:e.payload,currentView:Le.Booking};case"UPDATE_BOOKING_TRAVELER_NAME":return{...n,bookingTravelerName:e.payload};case"UPDATE_BOOKING_TRAVELER_EMAIL":return{...n,bookingTravelerEmail:e.payload};case"UPDATE_BOOKING_TRAVELER_PHONE":return{...n,bookingTravelerPhone:e.payload};case"SELECT_CONSULTANT_PROFILE":return{...n,activeConsultantProfileId:e.payload,currentView:Le.ConsultantDashboard};case"SET_BOOKING_VERIFIED":return{...n,isBookingDetailsVerified:e.payload};default:return n}},kA=R.createContext(void 0),iG=({children:n})=>{const[e,t]=R.useReducer(sG,TA);R.useEffect(()=>{e.draftItinerary?localStorage.setItem("uganda_safari_draft_itinerary",JSON.stringify(e.draftItinerary)):localStorage.removeItem("uganda_safari_draft_itinerary")},[e.draftItinerary]),R.useEffect(()=>{const z=CA();if(z){Mg(z.email,z.tripCode,z.token);const U={id:z.email,name:z.email.split("@")[0],email:z.email,role:"traveler",status:"active"};t({type:"LOGIN_SUCCESS",payload:U}),t({type:"NAVIGATE",payload:{view:Le.TripManagement}})}},[]),R.useEffect(()=>{ge.logAnalyticsEvent("view_change",{view:e.currentView})},[e.currentView]),R.useEffect(()=>{let z=!0;ge.getAllDestinations().then(_=>{z&&_&&_.length>0&&t({type:"SET_DESTINATIONS",payload:_})}),ge.getAllLodges().then(_=>{z&&_&&_.length>0&&t({type:"SET_LODGES",payload:_})});const U=ge.subscribeToDestinations(_=>{z&&_&&_.length>0&&t({type:"SET_DESTINATIONS",payload:_})}),D=ge.subscribeToLodges(_=>{z&&_&&_.length>0&&t({type:"SET_LODGES",payload:_})}),k=mr.subscribeToAuth(_=>{_&&t({type:"LOGIN_SUCCESS",payload:_})});return()=>{z=!1,U(),D(),k()}},[]);const r=R.useCallback(z=>{t({type:"UPDATE_LODGE",payload:z})},[]),s=R.useCallback((z,U)=>{t({type:"NAVIGATE",payload:{view:z,...U}})},[]),a=R.useCallback(z=>t({type:"LOGIN_SUCCESS",payload:z}),[]),c=R.useCallback(()=>{mr.signOut().catch(()=>{}),t({type:"LOGOUT"})},[]),u=R.useCallback(()=>t({type:"OPEN_LOGIN_MODAL"}),[]),h=R.useCallback(()=>t({type:"CLOSE_LOGIN_MODAL"}),[]),f=R.useCallback(z=>{var _;const U=e.lodges.find(M=>M.destinationId===z&&M.isDefault),D=PT.includes(z)?1:2,k={id:RT(),destinationId:z,lodgeId:(U==null?void 0:U.id)||null,roomId:((_=U==null?void 0:U.rooms[0])==null?void 0:_.id)||null,numberOfNights:D,activities:Array(D).fill([])};t({type:"START_ITINERARY",payload:k}),ge.logAnalyticsEvent("start_itinerary",{destinationId:z})},[e.lodges]),p=R.useCallback(z=>{var D;const U=e.lodges.find(k=>k.id===z);if(U){const k=PT.includes(U.destinationId)?1:2,_={id:RT(),destinationId:U.destinationId,lodgeId:U.id,roomId:((D=U.rooms[0])==null?void 0:D.id)||null,numberOfNights:k,activities:Array(k).fill([])};t({type:"START_ITINERARY",payload:_}),ge.logAnalyticsEvent("start_itinerary_lodge",{lodgeId:z})}},[]),y=R.useCallback(z=>{t({type:"START_ITINERARY_WITH_CONSULTANT",payload:z}),ge.logAnalyticsEvent("start_itinerary_consultant",{consultantId:z})},[]),b=R.useCallback(z=>{t({type:"UPDATE_DRAFT_ITINERARY",payload:z})},[]),w=R.useCallback(()=>{t({type:"DISCARD_DRAFT"})},[]),E=R.useCallback(z=>{t({type:"NAVIGATE_TO_BOOKING",payload:z}),ge.logAnalyticsEvent("proceed_to_booking",{value:z.totalPrice})},[]),N=R.useCallback(z=>{t({type:"UPDATE_BOOKING_TRAVELER_NAME",payload:z})},[]),S=R.useCallback(z=>{t({type:"UPDATE_BOOKING_TRAVELER_EMAIL",payload:z})},[]),I=R.useCallback(z=>{t({type:"UPDATE_BOOKING_TRAVELER_PHONE",payload:z})},[]),O=R.useCallback(z=>{t({type:"SELECT_CONSULTANT_PROFILE",payload:z}),ge.logAnalyticsEvent("view_consultant",{consultantId:z})},[]),F=R.useCallback(z=>{t({type:"SET_BOOKING_VERIFIED",payload:z})},[]),J={state:e,navigateTo:s,login:a,logout:c,openLoginModal:u,startItinerary:f,startWithLodge:p,startItineraryWithConsultant:y,updateDraftItinerary:b,discardDraftItinerary:w,navigateToBooking:E,updateBookingTravelerName:N,updateBookingTravelerEmail:S,updateBookingTravelerPhone:I,selectConsultantProfile:O,setBookingVerified:F,updateLodgeInContext:r};return o.jsxs(kA.Provider,{value:J,children:[n,e.isLoginModalOpen&&o.jsx(KV,{onClose:h,onLoginSuccess:a})]})},an=()=>{const n=R.useContext(kA);if(n===void 0)throw new Error("useAppContext must be used within an AppProvider");return n};async function aG(n,e={}){const{maxWidth:t=1280,maxHeight:r=1280,quality:s=.85}=e;return new Promise((a,c)=>{const u=new FileReader;u.onerror=()=>c(new Error("Failed to read image file")),u.onload=h=>{var p;const f=new Image;f.onerror=()=>c(new Error("Failed to decode image")),f.onload=()=>{let y=f.width,b=f.height;if(y>t||b>r){const S=Math.min(t/y,r/b);y=Math.round(y*S),b=Math.round(b*S)}const w=document.createElement("canvas");w.width=y,w.height=b;const E=w.getContext("2d");if(!E){c(new Error("Could not obtain canvas 2D context"));return}E.imageSmoothingEnabled=!0,E.imageSmoothingQuality="high",E.drawImage(f,0,0,y,b);const N=w.toDataURL("image/jpeg",s);w.toBlob(S=>{S?a({blob:S,dataUrl:N}):fetch(N).then(I=>I.blob()).then(I=>a({blob:I,dataUrl:N}
4211)).catch(()=>a({blob:n,dataUrl:N}))},"image/jpeg",s)},f.src=(p=h.target)==null?void 0:p.result},u.readAsDataURL(n)})}async function NA(n,e="general",t={}){if(!n.type.startsWith("image/"))throw new Error("Selected file is not an image. Please choose a JPG, PNG, or WEBP file.");const{blob:r,dataUrl:s}=await aG(n,{...t});try{const a=n.name.replace(/[^a-zA-Z0-9.-]/g,"_"),c=Date.now(),u=`uploads/${e}/${c}_${a}`,h=kV(HV,u),f=_V(h,r,{contentType:"image/jpeg",customMetadata:{originalName:n.name,uploadedAt:new Date().toISOString()}}),p=new Promise((w,E)=>{setTimeout(()=>E(new Error("Firebase Storage upload timed out")),8e3)}),y=await Promise.race([f,p]);return await TV(y.ref)}catch(a){return console.warn("[ImageUpload] Firebase Storage upload was unavailable, using optimized local data URL fallback:",a),s}}const Qa=({id:n="image-uploader",label:e="Image",value:t="",onChange:r,folder:s="general",aspectRatio:a="wide",helperText:c,required:u=!1})=>{const[h,f]=R.useState("upload"),[p,y]=R.useState(t),[b,w]=R.useState(!1),[E,N]=R.useState(!1),[S,I]=R.useState(null),[O,F]=R.useState(!1),J=R.useRef(null);cc.useEffect(()=>{y(t||"")},[t]);const z=async L=>{if(!L.type.startsWith("image/")){I("Please select a valid image file (JPG, PNG, WEBP, etc.)");return}if(L.size>15*1024*1024){I("Image is too large. Please select a file under 15MB.");return}N(!0),I(null),F(!1);try{const ee=a==="square",ne=await NA(L,s,{maxWidth:ee?400:800,maxHeight:ee?400:800,quality:.6});r(ne),y(ne),F(!0),setTimeout(()=>F(!1),3e3)}catch(ee){console.error("Upload error:",ee),I(ee.message||"Failed to upload image. Please try again or use a URL.")}finally{N(!1)}},U=L=>{var ne;const ee=(ne=L.target.files)==null?void 0:ne[0];ee&&z(ee)},D=L=>{L.preventDefault(),L.stopPropagation(),w(!0)},k=L=>{L.preventDefault(),L.stopPropagation(),w(!1)},_=L=>{var ne;L.preventDefault(),L.stopPropagation(),w(!1);const ee=(ne=L.dataTransfer.files)==null?void 0:ne[0];ee&&z(ee)},M=L=>{const ee=L.target.value;y(ee),r(ee)},j=()=>{r(""),y(""),I(null),J.current&&(J.current.value="")},H=a==="square"?"aspect-square max-w-[200px]":a==="wide"?"aspect-video max-w-full":"max-h-48";return o.jsxs("div",{id:`${n}-container`,className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("label",{htmlFor:`${n}-input`,className:"block text-sm font-bold text-gray-700 dark:text-gray-300",children:[e," ",u&&o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsxs("div",{className:"flex bg-gray-100 dark:bg-gray-700/60 p-0.5 rounded-md border border-gray-200 dark:border-gray-600 text-xs",children:[o.jsxs("button",{id:`${n}-tab-upload`,type:"button",onClick:()=>f("upload"),className:`flex items-center gap-1.5 px-2.5 py-1 rounded transition-colors ${h==="upload"?"bg-white dark:bg-gray-800 text-blue-600 dark:text-blue-400 font-medium shadow-xs":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:[o.jsx(ig,{className:"w-3.5 h-3.5"}),"Upload File"]}),o.jsxs("button",{id:`${n}-tab-url`,type:"button",onClick:()=>f("url"),className:`flex items-center gap-1.5 px-2.5 py-1 rounded transition-colors ${h==="url"?"bg-white dark:bg-gray-800 text-blue-600 dark:text-blue-400 font-medium shadow-xs":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:[o.jsx(XN,{className:"w-3.5 h-3.5"}),"Image URL"]})]})]}),o.jsxs("div",{className:"space-y-3",children:[t?o.jsxs("div",{className:"relative group border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden bg-gray-50 dark:bg-gray-900/50",children:[o.jsx("div",{className:"mx-auto flex items-center justify-center p-2",children:o.jsx("img",{src:t,alt:"Uploaded preview",className:`w-full rounded-md object-cover shadow-xs ${H}`,onError:L=>{L.target.style.display="none"}})}),o.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-100/90 dark:bg-gray-800/90 border-t border-gray-200 dark:border-gray-700 text-xs",children:[o.jsx("span",{className:"text-gray-500 dark:text-gray-400 truncate max-w-[240px] font-mono",children:t.startsWith("data:")?"Image uploaded from device":t}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("button",{id:`${n}-replace-btn`,type:"button",onClick:()=>{var L;return(L=J.current)==null?void 0:L.click()},className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-blue-600 dar
4211k:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/40 rounded transition-colors",children:[o.jsx(RP,{className:"w-3 h-3"}),"Replace"]}),o.jsxs("button",{id:`${n}-remove-btn`,type:"button",onClick:j,className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 rounded transition-colors",children:[o.jsx(Kg,{className:"w-3 h-3"}),"Remove"]})]})]})]}):null,h==="upload"&&o.jsxs("div",{id:`${n}-dropzone`,onDragOver:D,onDragLeave:k,onDrop:_,onClick:()=>{var L;return(L=J.current)==null?void 0:L.click()},className:`border-2 border-dashed rounded-lg p-5 text-center cursor-pointer transition-all duration-200 flex flex-col items-center justify-center gap-2 ${b?"border-blue-500 bg-blue-50/50 dark:bg-blue-950/20":"border-gray-300 dark:border-gray-600 hover:border-blue-400 dark:hover:border-blue-500 bg-gray-50/50 dark:bg-gray-800/50 hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[o.jsx("input",{ref:J,id:`${n}-file-input`,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",onChange:U,className:"hidden"}),E?o.jsxs("div",{className:"flex flex-col items-center gap-2 py-3",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-blue-600 border-t-transparent"}),o.jsx("p",{className:"text-sm font-medium text-blue-600 dark:text-blue-400",children:"Processing & uploading image..."})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"p-2.5 rounded-full bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400",children:o.jsx(ig,{className:"w-6 h-6"})}),o.jsxs("div",{className:"text-center",children:[o.jsxs("p",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:[o.jsx("span",{className:"text-blue-600 dark:text-blue-400 underline",children:"Click to upload"})," or drag and drop"]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"PNG, JPG, or WEBP (auto-optimized for web)"})]})]})]}),h==="url"&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none text-gray-400",children:o.jsx(WN,{className:"w-4 h-4"})}),o.jsx("input",{id:`${n}-url-input`,type:"url",value:p,onChange:M,placeholder:"https://example.com/photo.jpg",className:"w-full pl-9 pr-3 py-2 border rounded-md border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Paste a public HTTPS link to an existing image."})]}),S&&o.jsxs("div",{className:"flex items-center gap-2 p-2.5 rounded-md bg-red-50 dark:bg-red-950/40 text-red-700 dark:text-red-300 text-xs border border-red-200 dark:border-red-800",children:[o.jsx(uc,{className:"w-4 h-4 flex-shrink-0"}),o.jsx("span",{children:S})]}),O&&o.jsxs("div",{className:"flex items-center gap-2 p-2.5 rounded-md bg-emerald-50 dark:bg-emerald-950/40 text-emerald-700 dark:text-emerald-300 text-xs border border-emerald-200 dark:border-emerald-800",children:[o.jsx(ox,{className:"w-4 h-4 flex-shrink-0"}),o.jsx("span",{children:"Image uploaded successfully!"})]}),c&&!S&&!O&&o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c})]})]})},oG=({user:n})=>{const[e,t]=R.useState(!1),[r,s]=R.useState(!1),[a,c]=R.useState(n.imageUrl||""),[u,h]=R.useState(!1),{logout:f,navigateTo:p,login:y}=an(),b=R.useRef(null);R.useEffect(()=>{const S=I=>{b.current&&!b.current.contains(I.target)&&t(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[]);const w=S=>{p(S),t(!1)},E=()=>{f(),t(!1)},N=async()=>{h(!0);try{const S={...n,imageUrl:a};if(await ge.saveUserProfile(S),n.role==="consultant"||n.consultantId){const I=n.consultantId||n.id,O=await ge.getConsultantById(I);O&&await ge.updateConsultant({...O,imageUrl:a})}y(S),s(!1)}catch(S){console.error("Failed to update avatar:",S)}finally{h(!1)}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"relative",ref:b,children:[o.jsxs("div",{id:"user-profile-menu-trigger",className:"flex items-center gap-2 cursor-pointer group",onClick:()=>t(!e),children:[o.jsx("div",{className:"relative",children:o.jsx("img",{src:n.imageUrl||"https://picsum.photos/seed/avatar/40/40",alt:n.name||"User profile",className:"w-8 h-8 rounded-full object-cover border-2 border-gray-300 dark:border-gray-600 group-hover:border-blue-500 transition-colors"})}),o.jsx("button",{id:"user-profile-menu-btn","aria-label":"Open user menu",className:"p-1 rounded-full text-gray-500 hover:text-brand-dark hover:bg-gray-100 dark:hover:bg-gray-700 dark:hover:text-white",children:o.jsx("svg",{className:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"})})})]}),e&&o.jsx("div",{id:"user-profile-dropdown",className:"absolute right-0 mt-2 w-56 bg-white dark:bg-gray-800 rounded-md shadow-lg z-20 border border-gray-200 dark:border-gray-700 overflow-hidden",children:o.jsxs("div",{className:"py-1",children:[o.jsx("div",{className:"px-4 py-2 border-b dark:border-gray-700 flex items-center justify-between",children:o.jsxs("div",{className:"overflow-hidden",children:[o.jsx("p",{className:"text-sm font-semibold text-brand-dark dark:text-white truncate",children:n.name}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 capitalize",children:n.role})]})}),o.jsxs("button",{id:"user-profile-change-photo-btn",onClick:()=>{c(n.imageUrl||""),s(!0),t(!1)},className:"w-full text-left flex items-center gap-2 px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:[o.jsx(IR,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"}),o.jsx("span",{children:"Change Photo"})]}),n.role==="admin"?o.jsxs(o.Fragment,{children:[o.jsx("button",{id:"user-profile-trip-management-btn",onClick:()=>w(Le.TripManagement),className:"w-full text-left block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:"My Trips"}),o.jsx("button",{id:"user-profile-admin-hub-btn",onClick:()=>w(Le.AdminHub),className:"w-full text-left block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:"Admin Hub (Content)"}),o.jsx("button",{id:"user-profile-reports-btn",onClick:()=>w(Le.Reports),className:"w-full text-left block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:"Platform Reports"})]}):o.jsx("button",{id:"user-profile-dashboard-btn",onClick:()=>w(n.role==="consultant"?Le.TripDashboard:Le.TripManagement),className:"w-full text-left block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:n.role==="consultant"?"Consultant Dashboard":"My Trips"}),n.role==="consultant"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{id:"user-profile-consultant-btn",onClick:()=>w(Le.EditProfile),className:"w-full text-left block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:"My Consultant Profile"}),o.jsx("button",{id:"user-profile-reviews-btn",onClick:()=>w(Le.ReviewManagement),className:"w-full text-left block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:"Manage Reviews"})]}),o.jsx("button",{id:"user-profile-logout-btn",onClick:E,className:"w-full text-left block px-4 py-2 text-sm text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50",children:"Logout"})]})})]}),r&&o.jsx("div",{id:"change-avatar-modal",className:"fixed inset-0 bg-black/60 z-50 flex items-center justify-center p-4 backdrop-blur-xs",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-md w-full p-6 border border-gray-200 dark:border-gray-700 relative animate-fadeIn",children:[o.jsx("button",{id:"change-avatar-modal-close",onClick:()=>s(!1),className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:o.jsx(bc,{className:"w-5 h-5"})}),o.jsx("h3",{className:"text-xl font-bold text-gray-900 dark:text-white mb-1",children:"Update Profile Photo"}),o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-5",children:"Upload a picture or enter a web link for your account avatar."}),o.jsx(Qa,{id:"user-avatar-upload",label:"Avatar Photo",value:a,onChange:S=>c(S),folder:"avatars",aspectRatio:"square",helperText:"Upload any square image (JPG, PNG, WEBP)."}),o.jsxs("div",{className:"flex justify-end gap-3 mt-6 pt-4 border-t dark:border-gray-700",children:[o.jsx(He,{id:"change-avatar-cancel-btn",variant:"secondary",onClick:()=>s(!1),children:"Cancel"}),o.jsx(He,{id:"change-avatar-save-btn",variant:"primary",onClick:N,disabled:u,children:u?o.jsx(At,{}):"Save Photo"})]})]})})]})},lG=()=>{const{state:n,navigateTo:e,openLoginModal:t,logout:r}=an(),{loggedInUser:s,currentView:a}=n,[c,u]=R.useState(!1),[h,f]=R.useState(()=>typeof document<"u"?document.documentElement.classList.contains("dark"):!1);R.useEffect(()=>{const S=()=>{f(document.documentElement.classList.contains("dark"))},I=new MutationObserver(S);return I.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}
4211),()=>I.disconnect()},[]);const p=()=>{const S=!h;if(f(S),S){document.documentElement.classList.add("dark");try{localStorage.setItem("theme","dark")}catch{}}else{document.documentElement.classList.remove("dark");try{localStorage.setItem("theme","light")}catch{}}},y=S=>{e(S),u(!1)},b=()=>{t(),u(!1)},w=()=>{r(),u(!1)},E="text-sm text-gray-600 dark:text-gray-300 hover:text-brand-dark dark:hover:text-white transition-colors duration-300",N="text-left text-gray-700 dark:text-gray-200 py-3 text-lg font-medium border-b border-gray-100 dark:border-gray-700 last:border-0";return o.jsxs("header",{className:"py-4 bg-white dark:bg-gray-900 sticky top-0 z-50 shadow-sm border-b border-gray-100 dark:border-gray-800",children:[o.jsxs("nav",{className:"container mx-auto px-4 flex justify-between items-center",children:[o.jsx("button",{onClick:()=>y(Le.Home),className:`text-2xl font-bold text-brand-dark dark:text-white font-heading hover:text-blue-600 dark:hover:text-blue-400 transition-colors truncate flex-shrink-0 mr-4 ${a===Le.Home?"invisible":"visible"}`,children:"Uganda Safari"}),o.jsxs("ul",{className:"hidden md:flex space-x-8 items-center",children:[o.jsx("li",{children:o.jsx("button",{onClick:()=>e(Le.ItineraryBuilder),className:E,children:"Planner"})}),o.jsx("li",{children:o.jsx("button",{onClick:()=>e(Le.ExpertsHub),className:E,children:"Experts"})}),o.jsx("li",{children:o.jsx("button",{onClick:()=>e(Le.TripManagement),className:E,children:"My Trips"})}),o.jsx("li",{children:o.jsx("button",{onClick:()=>e(Le.Stories),className:E,children:"Stories"})}),o.jsx("li",{children:o.jsx("button",{onClick:()=>e(Le.Help),className:E,children:"Help"})}),o.jsx("li",{children:o.jsx("button",{onClick:p,className:"p-2 rounded-full text-gray-500 dark:text-gray-400 hover:text-brand-dark dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500",title:h?"Switch to Light Mode":"Switch to Dark Mode","aria-label":h?"Switch to Light Mode":"Switch to Dark Mode",children:h?o.jsx(PB,{className:"w-5 h-5 text-amber-400 hover:rotate-45 transition-transform"}):o.jsx(RB,{className:"w-5 h-5 text-gray-600 hover:-rotate-12 transition-transform"})})}),o.jsx("li",{children:s?o.jsx(oG,{user:s}):o.jsx("button",{onClick:t,className:"bg-blue-600 text-white font-bold py-2 px-6 rounded-full hover:bg-blue-700 transition-transform transform hover:scale-105",children:"Login"})})]}),o.jsxs("div",{className:"md:hidden flex items-center gap-2",children:[o.jsx("button",{onClick:p,className:"p-2 rounded-lg text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",title:h?"Switch to Light Mode":"Switch to Dark Mode","aria-label":h?"Switch to Light Mode":"Switch to Dark Mode",children:h?o.jsx(PB,{className:"w-5 h-5 text-amber-400"}):o.jsx(RB,{className:"w-5 h-5"})}),o.jsx("button",{className:"p-2 text-gray-600 dark:text-gray-300 focus:outline-none rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",onClick:()=>u(!c),"aria-label":"Toggle menu",children:o.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c?o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}):o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})]})]}),c&&o.jsx("div",{className:"md:hidden absolute top-full left-0 w-full bg-white dark:bg-gray-900 border-t dark:border-gray-800 shadow-xl max-h-[90vh] overflow-y-auto",children:o.jsxs("div",{className:"flex flex-col px-6 py-4",children:[o.jsx("button",{onClick:()=>y(Le.ItineraryBuilder),className:N,children:"Planner"}),o.jsx("button",{onClick:()=>y(Le.ExpertsHub),className:N,children:"Experts"}),o.jsx("button",{onClick:()=>y(Le.TripManagement),className:N,children:"My Trips"}),o.jsx("button",{onClick:()=>y(Le.Stories),className:N,children:"Stories"}),o.jsx("button",{onClick:()=>y(Le.Help),className:N,children:"Help"}),o.jsxs("div",{className:"py-3 flex items-center justify-between border-b border-gray-100 dark:border-gray-700",children:[o.jsx("span",{className:"text-gray-700 dark:text-gray-200 text-lg font-medium",children:"Appearance"}),o.jsx("button",{onClick:p,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg bg-gray-100 dark:bg-gray-800 text-sm font-semibold text-gray-700 dark:text-gray-200",children:h?o.jsxs(o.Fragment,{children:[o.jsx(PB,{className:"w-4 h-4 text-amber-400"}),o.jsx("span",{children:"Light Mode"})]}):o.jsxs(o.Fragment,{children:[o.jsx(RB,{className:"w-4 h-4 text-gray-600"}),o.jsx("span",{children:"Dark Mode"})]})})]}),s&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100 dark:border-gray-700",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[o.jsx("img",{src:s.imageUrl||"https://picsum.photos/seed/avatar/40/40",className:"w-10 h-10 rounded-full border border-gray-200",alt:""}),o.jsxs("div",{children:[o.jsx("p",{className:"font-bold text-brand-dark dark:text-white",children:s.name}),o.jsx("p",{className:"text-xs text-gray-500 uppercase",children:s.role})]})]}),o.jsx("button",{onClick:()=>y(Le.TripManagement),className:N,children:"My Trips"}),s.role==="admin"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>y(Le.AdminHub),className:N,children:"Admin Hub (Content)"}),o.jsx("button",{onClick:()=>y(Le.Reports),className:N,children:"Platform Reports"})]}),s.role==="consultant"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>y(Le.TripDashboard),className:N,children:"Consultant Dashboard"}),o.jsx("button",{onClick:()=>y(Le.EditProfile),className:N,children:"My Profile"}),o.jsx("button",{onClick:()=>y(Le.ReviewManagement),className:N,children:"Manage Reviews"})]}),o.jsx("button",{onClick:w,className:"text-left text-red-600 py-3 text-lg font-medium mt
4211-2",children:"Logout"})]}),!s&&o.jsx("div",{className:"mt-6 pt-2",children:o.jsx("button",{onClick:b,className:"w-full bg-blue-600 text-white font-bold py-3 rounded-lg text-center shadow-md active:scale-95 transition-transform",children:"Login"})})]})})]})},cG=()=>{const{navigateTo:n}=an();return o.jsx("footer",{className:"bg-[#f8f9fa] dark:bg-[#18181b] border-t border-gray-200 dark:border-gray-800 mt-auto py-4",children:o.jsx("div",{className:"container mx-auto px-6 max-w-[1400px]",children:o.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between text-[14px] text-[#5f6368] dark:text-gray-400 gap-4",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-center md:justify-start gap-x-8 gap-y-3",children:[o.jsx("span",{className:"text-[#202124] dark:text-gray-200 font-medium text-[15px] tracking-tight",children:"Original Uganda"}),o.jsxs("div",{className:"flex items-center gap-6",children:[o.jsx("button",{onClick:()=>n(Le.TripManagement),className:"hover:text-[#202124] dark:hover:text-gray-200 transition-colors",children:"My Trips"}),o.jsx("button",{onClick:()=>n(Le.About),className:"hover:text-[#202124] dark:hover:text-gray-200 transition-colors",children:"About"}),o.jsx("button",{onClick:()=>n(Le.Privacy),className:"hover:text-[#202124] dark:hover:text-gray-200 transition-colors",children:"Privacy"}),o.jsx("button",{onClick:()=>n(Le.Terms),className:"hover:text-[#202124] dark:hover:text-gray-200 transition-colors",children:"Terms"})]})]}),o.jsx("div",{className:"flex items-center gap-6",children:o.jsxs("button",{onClick:()=>n(Le.Help),className:"hover:text-[#202124] dark:hover:text-gray-200 transition-colors flex items-center gap-1.5 font-medium",children:[o.jsx("svg",{className:"w-[18px] h-[18px] fill-current text-[#5f6368] dark:text-gray-400",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"})}),o.jsx("span",{children:"Help"})]})})]})})})},uG=n=>n.includes("Bwindi")?"Bwindi":n.includes("Queen Elizabeth")?"Queen Elizabeth":n.includes("Kibale")?"Kibale":n,ql=()=>{const{state:{draftItinerary:n,destinations:e,lodges:t},startItinerary:r,startWithLodge:s,navigateTo:a,discardDraftItinerary:c}=an(),[u,h]=R.useState(""),[f,p]=R.useState(!1),y=R.useRef(null),b=R.useMemo(()=>{const S=["bwindi","kibale","queen-elizabeth"].map(I=>e.find(O=>O.id===I)).filter(Boolean);return S.length>0?S:e.slice(0,3)},[e]);R.useEffect(()=>{const N=S=>{y.current&&!y.current.contains(S.target)&&p(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const w=R.useMemo(()=>{if(!u.trim())return e.slice(0,4).map(O=>({type:"destination",data:O}));const N=u.toLowerCase(),S=e.filter(O=>O.name.toLowerCase().includes(N)||O.shortCode&&O.shortCode.toLowerCase().includes(N)||O.hint&&O.hint.toLowerCase().includes(N)||O.keywords&&O.keywords.some(F=>F.toLowerCase().includes(N))).map(O=>({type:"destination",data:O})),I=t.filter(O=>O.name.toLowerCase().includes(N)||O.keywords&&O.keywords.some(F=>F.toLowerCase().includes(N))).map(O=>({type:"lodge",data:O}));return[...S,...I]},[u]),E=n&&n.stops.length>0;return o.jsx("div",{className:"w-full flex flex-col items-center justify-center text-center px-4 py-6 sm:py-10",children:o.jsxs("div",{className:"w-full max-w-2xl",children:[o.jsx("h1",{className:"text-4xl md:text-6xl font-extrabold text-brand-dark dark:text-white mb-4 font-heading leading-tight whitespace-nowrap",children:"Uganda Safari"}),o.jsx("p",{className:"max-w-xl mx-auto text-sm md:text-base font-light text-gray-600 dark:text-gray-300 mb-8 leading-relaxed",children:"Build your own itinerary, see your trip cost update in real time, and connect with vetted experts when you're ready to book."}),n&&n.stops&&n.stops.length>0&&o.jsxs("div",{className:"max-w-xl mx-auto mb-8 bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-800 rounded-xl p-4 flex flex-col sm:flex-row items-center justify-between text-left gap-4 shadow-sm",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-blue-900 dark:text-blue-100 font-semibold text-sm",children:"You have an itinerary in progress"}),o.jsxs("p",{className:"text-blue-700 dark:text-blue-300 text-xs mt-1",children:[n.stops.length," stop",n.stops.length>
42111?"s":""," planned",n.travelerCount?` for ${n.travelerCount} travelers`:"","."]})]}),o.jsxs("div",{className:"flex gap-2 w-full sm:w-auto shrink-0",children:[o.jsx(He,{variant:"outline",size:"sm",onClick:c,className:"w-full sm:w-auto text-blue-700 border-blue-300 hover:bg-blue-100 dark:text-blue-300 dark:border-blue-700 dark:hover:bg-blue-800",children:"Start Over"}),o.jsx(He,{variant:"primary",size:"sm",onClick:()=>a(Le.ItineraryBuilder),className:"w-full sm:w-auto whitespace-nowrap",children:"Continue"})]})]}),o.jsxs("div",{className:"relative max-w-xl mx-auto",ref:y,children:[o.jsx("svg",{className:"absolute left-4 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500 pointer-events-none",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),o.jsx("input",{type:"search",placeholder:"Where do you want to go?",className:"w-full py-3 sm:py-3.5 pl-11 pr-4 text-sm sm:text-base font-normal text-brand-dark dark:text-white placeholder-gray-400 dark:placeholder-gray-500 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-700 rounded-full shadow-xs hover:border-gray-400 dark:hover:border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500/25 focus:border-blue-500 transition-all","aria-label":"Where do you want to go?",value:u,onChange:N=>h(N.target.value),onFocus:()=>p(!0)}),f&&o.jsx("div",{className:"absolute z-10 w-full mt-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-750 rounded-xl shadow-xl overflow-hidden",children:o.jsx("ul",{className:"py-2 text-left max-h-80 overflow-y-auto",children:w.length>0?w.map(N=>o.jsxs("li",{className:"px-4 py-2.5 text-sm text-brand-dark dark:text-gray-200 hover:bg-blue-50 dark:hover:bg-gray-750 cursor-pointer flex justify-between items-center transition-colors",onClick:()=>{N.type==="destination"?r(N.data.id):s(N.data.id),p(!1),h("")},children:[o.jsx("span",{className:"font-medium",children:N.data.name}),N.type==="destination"&&N.data.hint&&o.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 px-2 py-0.5 rounded-full",children:N.data.hint}),N.type==="lodge"&&o.jsx("span",{className:"text-xs text-amber-700 dark:text-amber-300 bg-amber-50 dark:bg-amber-900/40 px-2 py-0.5 rounded-full",children:"Lodge"})]},`${N.type}-${N.data.id}`)):o.jsx("li",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400",children:"No results found."})})})]}),E&&o.jsxs("div",{className:"mt-8 p-4 bg-blue-50 dark:bg-gray-800 border border-blue-200 dark:border-gray-700 rounded-xl max-w-xl mx-auto text-center",children:[o.jsx("h2",{className:"text-sm font-semibold text-brand-dark dark:text-white",children:"You have a trip in progress."}),o.jsxs("div",{className:"mt-3 flex justify-center items-center gap-4",children:[o.jsx(He,{onClick:()=>a(Le.ItineraryBuilder),children:"Continue Planning"}),o.jsx("button",{onClick:c,className:"text-xs text-gray-500 dark:text-gray-400 hover:underline",children:"Start Over"})]})]}),o.jsxs("div",{className:"mt-8 w-full",children:[o.jsx("h2",{className:"text-xs uppercase tracking-wider text-gray-400 dark:text-gray-500 mb-3 font-medium",children:"Popular Destinations"}),o.jsx("div",{className:"flex justify-center flex-wrap gap-2.5",children:b.map(N=>o.jsx("button",{onClick:()=>r(N.id),className:"bg-white/80 dark:bg-gray-800/80 border border-gray-200 dark:border-gray-700 rounded-full py-1.5 px-4 transition-all duration-200 hover:bg-gray-50 dark:hover:bg-gray-750 hover:border-gray-300 dark:hover:border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-400",children:o.jsxs("div",{className:"flex items-baseline gap-2",children:[o.jsx("span",{className:"text-brand-dark dark:text-gray-200 text-xs sm:text-sm font-medium whitespace-nowrap",children:uG(N.name)}),N.hint&&o.jsx("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 whitespace-nowrap",children:N.hint})]})},N.id))})]})]})})},TC=n=>{const e=n.getMonth();return[2,3,4,9,10].includes(e)?"low":"high"},kC=(n,e)=>{const t=new Date(n);return t.setDate(t.getDate()+e),t},dG=({filled:n})=>o.jsx("svg",{className:`w-5 h-5 ${n?"text-yellow-500":"text-gray-300 dark:text-gray-600"}
4211`,fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.286 3.959a1 1 0 00.95.69h4.162c.969 0 1.371 1.24.588 1.81l-3.368 2.446a1 1 0 00-.364 1.118l1.287 3.959c.3.921-.755 1.688-1.54 1.118l-3.368-2.446a1 1 0 00-1.175 0l-3.368 2.446c-.784.57-1.838-.197-1.54-1.118l1.287-3.959a1 1 0 00-.364-1.118L2.06 9.386c-.783-.57-.38-1.81.588-1.81h4.162a1 1 0 00.95-.69L9.049 2.927z"})}),Wa=({rating:n,totalStars:e=5})=>o.jsx("div",{className:"flex items-center",children:Array.from({length:e},(t,r)=>o.jsx(dG,{filled:r<n},r))}),hG=n=>n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0}),zl=({title:n,travelerInfo:e,items:t})=>t.length===0?null:o.jsxs("div",{children:[o.jsxs("p",{className:"text-brand-dark dark:text-gray-100 mb-1",children:[o.jsx("span",{className:"font-bold",children:n}),e&&o.jsx("span",{className:"font-normal text-sm text-gray-500 dark:text-gray-400 ml-1",children:e})]}),o.jsx("ul",{className:"pl-2 space-y-1 text-xs text-gray-700 dark:text-gray-300",children:t.map(r=>o.jsxs("li",{className:"flex justify-between",children:[o.jsx("span",{className:"pr-2",children:r.description}),o.jsxs("span",{className:"font-medium whitespace-nowrap",children:["$",hG(r.cost)]})]},r.id))})]}),fG=({stops:n,totalPrice:e,pricePerPerson:t,isLoading:r,handleSubmit:s,travelerCount:a,startDate:c,breakdown:u,duration:h,consultant:f})=>{const{state:{destinations:p,lodges:y}}=an(),b=R.useMemo(()=>h===0?null:`${h+1} Day Custom x${a} Safari`,[h,a]),w=R.useMemo(()=>a<=0?"":`(for ${a} ${a>1?"people":"person"})`,[a]);return o.jsxs("div",{className:"lg:sticky top-8 flex flex-col gap-6 lg:max-h-[calc(100vh-4rem)]",children:[f&&o.jsxs("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-gray-700 rounded-lg flex items-center gap-4",children:[o.jsx("img",{src:f.imageUrl,alt:f.name,className:"w-16 h-16 rounded-full object-cover shadow-sm"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Your selected expert"}),o.jsx("p",{className:"font-bold text-brand-dark dark:text-white text-lg",children:f.name}),o.jsx("div",{className:"flex items-center gap-2 mt-1",children:f.reviewCount>0?o.jsxs(o.Fragment,{children:[o.jsx(Wa,{rating:f.avgRating}),o.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400 font-medium",children:["(",f.reviewCount," reviews)"]})]}):o.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"No reviews yet"})}),o.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1 font-semibold",children:[f.confirmedTrips," confirmed trip",f.confirmedTrips!==1&&"s"]})]})]}),o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-2xl p-6 flex flex-col flex-grow overflow-hidden",children:[o.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 pb-3 mb-4 flex-shrink-0",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:"Quote Summary"}),b&&o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 mt-1",children:b})]}),o.jsx("div",{className:"overflow-y-auto flex-grow pr-2",children:n.length>0?o.jsxs("div",{className:"space-y-4 text-sm",children:[o.jsx(zl,{title:"Accommodation",travelerInfo:w,items:u.accommodationItems}),o.jsx(zl,{title:"Transport",travelerInfo:w,items:u.transportItems}),o.jsx(zl,{title:"Activities",travelerInfo:w,items:u.activityItems}),o.jsx(zl,{title:"Permits",travelerInfo:w,items:u.permitCostItems}),o.jsx(zl,{title:"Permit Processing Fees",travelerInfo:w,items:u.permitFeeItems}),o.jsx(zl,{title:"Park Entry Fees",travelerInfo:w,items:u.parkFeeItems}),o.jsx(zl,{title:"Other Costs",travelerInfo:"",items:u.otherCostItems})]}):o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Add destinations to your itinerary to see a quote summary."})})]}),o.jsxs("div",{className:"bg-white dark:bg-gray-800/50 dark:backdrop-blur-sm rounded-2xl p-6 shadow-lg border dark:border-gray-700 flex-shrink-0",children:[o.jsxs("div",{className:"flex items-baseline justify-between mb-4",children:[o.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Total Price"}),o.jsxs("span",{className:"font-bold text-2xl text-brand-dark dark:text-white",children:["$",e.toLocaleStr
4211ing()]})]}),o.jsxs("div",{className:"text-right text-sm text-gray-600 dark:text-gray-300 mb-6",children:[o.jsx("span",{children:"per person"}),o.jsxs("span",{className:"ml-2 font-semibold",children:["$",t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),o.jsxs("form",{onSubmit:s,children:[o.jsx(He,{type:"submit",disabled:r||n.length===0,className:"w-full py-3 text-base",children:r?o.jsx(At,{}):f?`Book trip with ${f.name.split(" ")[0]}`:"Book this trip with an expert"}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2 text-center",children:"Lodges & Permits subject to availability."})]})]})]})},LT=({images:n,alt:e="Image",className:t=""})=>{const[r,s]=R.useState(0),a=u=>{u.stopPropagation();const f=r===0?n.length-1:r-1;s(f)},c=u=>{u.stopPropagation();const f=r===n.length-1?0:r+1;s(f)};return!n||n.length===0?o.jsx("div",{className:`w-full h-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center ${t}`,children:o.jsx("span",{className:"text-gray-400",children:"No Image"})}):n.length===1?o.jsx("img",{src:n[0],alt:e,className:`w-full h-full object-cover ${t}`}):o.jsxs("div",{className:`relative w-full h-full group overflow-hidden ${t}`,children:[o.jsx("img",{src:n[r],alt:`${e} - ${r+1}`,className:"w-full h-full object-cover transition-opacity duration-300"}),o.jsxs("div",{className:"absolute inset-0 flex items-center justify-between p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[o.jsx("button",{onClick:a,className:"p-1 rounded-full bg-black/50 text-white hover:bg-black/75 transition-colors focus:outline-none",children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),o.jsx("button",{onClick:c,className:"p-1 rounded-full bg-black/50 text-white hover:bg-black/75 transition-colors focus:outline-none",children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),o.jsx("div",{className:"absolute bottom-2 left-0 right-0 flex justify-center gap-1.5",children:n.map((u,h)=>o.jsx("div",{className:`w-2 h-2 rounded-full ring-1 ring-black/20 ${r===h?"bg-white":"bg-white/60"}`},h))})]})},On=({children:n,className:e=""})=>o.jsx("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-md overflow-hidden transition-shadow duration-300 hover:shadow-xl ${e}`,children:n}),mG=({activity:n,isSelected:e,onToggle:t,disabled:r=!1,disabledReason:s})=>o.jsxs("div",{className:`bg-white dark:bg-gray-800/50 border rounded-xl p-4 flex flex-col transition-all duration-200 ${e?"border-blue-500 ring-2 ring-blue-500/20":"border-gray-200 dark:border-gray-700"} ${r?"opacity-60 cursor-not-allowed":"cursor-pointer hover:shadow-lg hover:border-gray-300 dark:hover:border-gray-500"}`,onClick:()=>!r&&t(),role:"button","aria-pressed":e,"aria-disabled":r,title:r?s:void 0,children:[o.jsxs("div",{className:"flex justify-between items-start gap-2 mb-2",children:[o.jsx("h5",{className:"font-bold text-brand-dark dark:text-gray-100",children:n.name}),n.durationTag&&o.jsx("span",{className:"text-xs font-medium bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300 px-2 py-1 rounded-full whitespace-nowrap",children:n.durationTag})]}),o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 flex-grow mb-4",children:n.description}),o.jsxs("div",{className:"flex justify-between items-center mt-auto",children:[o.jsxs("span",{className:"text-xl font-bold text-brand-dark dark:text-white",children:["$",n.price]}),o.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),r||t()},disabled:r,className:`px-6 py-2 text-sm font-semibold rounded-lg transition-colors ${e?"bg-blue-600 text-white":"bg-blue-100 text-blue-700 hover:bg-blue-200 dark:bg-blue-900/50 dark:text-blue-200 dark:hover:bg-blue-900"}`,children:e?"Added":"Add"})]})]}),gG=n=>{if(n.imageUrls&&n.imageUrls.length>0)return n.imageUrls;if(n.imageUrl){if(!n.imageUrl.includes("picsum.photos"))return[n.imageUrl];const e=n.imageUrl.replace(/\/800\/600$/,""),t=e.substring(e.lastIndexOf("/")+1);return[`https://picsum.photos/seed/${t}/800/600`,`https://picsum.photos/seed/${t}-alt1/800/600`,`https://picsum.photos/seed/${t}-alt2/800/600`]}return["https://picsum.photos/seed/default-dest/800/600"]},pG=n=>{if(n.imageUrls&&n.imageUrls.length>0)return n.imageUrls;if(n.imageUrl){if(!n.imageUrl.includes("picsum.photos"))return[n.imageUrl];const e=n.imageUrl.replace(/\/800\/600$/,""),t=e.substring(e.lastIndexOf("/")+1);return[`https://picsum.photos/seed/${t}/800/600`,`https://picsum.photos/seed/${t}-alt1/800/600`,`https://picsum.photos/seed/${t}-alt2/800/600`]}return["https://picsum.photos/seed/default-lodge/800/600"]},BG=({stop:n,stopIndex:e,isCollapsed:t,isDragging:r,startDate:s,daysElapsed:a,startDay:c,endDay:u,onToggleCollapse:h,onStopChange:f,onActivityToggle:p,onDeleteStop:y,onDragStart:b,onDragEnter:w})=>{const{state:{destinations:E,lodges:N}}=an(),[S,I]=R.useState(0),[O,F]=R.useState(n.lodgeId),J=E.find(X=>X.id===n.destinationId),z=(J==null?void 0:J.activities)||[],U=N.filter(X=>X.destinationId===n.destinationId),D=N.find(X=>X.id===O),k=R.useMemo(()=>
4211{if(!J)return 1;const X=n.activities.flat().reduce((ae,Te)=>{const K=J.activities.find(fe=>fe.id===Te);return K!=null&&K.isFullDay?ae+1:ae},0);return X>0?X+1:1},[n.activities,J]),_=(X,ae)=>{f("lodgeId",X),f("roomId",ae)},M=X=>{let ae=0;const Te=new Date(s);for(let K=0;K<n.numberOfNights;K++){const fe=kC(Te,a+K),Se=TC(fe);if(X.pricingModel==="perNight")ae+=Se==="high"?X.highSeasonPricePerNight??0:X.lowSeasonPricePerNight??0;else{const Ae=Se==="high"?X.highSeasonPriceDouble??0:X.lowSeasonPriceDouble??0;ae+=Ae}}return n.numberOfNights>0?ae/n.numberOfNights:0},j=n.activities[S]||[],H=R.useMemo(()=>j.some(X=>{const ae=z.find(Te=>Te.id===X);return ae==null?void 0:ae.isFullDay}),[j,z]),L=["binp-gorilla-tracking","binp-gorilla-habituation"],ee="binp-long-walk",ne=R.useMemo(()=>j.some(X=>L.includes(X)),[j]),G=R.useMemo(()=>j.includes(ee),[j]),W=R.useMemo(()=>c===u?`Day ${c}`:`Day ${c}-${u}`,[c,u]);return o.jsx("div",{onPointerEnter:w,className:`mb-6 transition-opacity duration-300 rounded-2xl shadow-lg ${r?"opacity-0":"opacity-100"}`,"aria-label":`Itinerary Stop ${e+1}`,children:o.jsxs(On,{className:"!shadow-none !hover:shadow-none border border-gray-200/80 dark:border-gray-700/80",children:[o.jsxs("header",{className:"flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-800 rounded-t-lg","data-drag-handle":"true",children:[o.jsx("div",{onPointerDown:X=>b(e,X),className:"cursor-grab p-2 -ml-2 text-gray-400 dark:text-gray-500 hover:text-gray-700 dark:hover:text-gray-200 touch-none",title:"Drag to reorder",children:o.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),o.jsxs("div",{className:"flex-grow text-left px-2 cursor-pointer",onClick:h,children:[o.jsxs("h3",{className:"text-xl font-bold text-brand-dark dark:text-gray-100 font-heading",children:[W,": ",o.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:(J==null?void 0:J.name)||"No Destination Set"})]}),o.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400 -mt-1",children:[n.numberOfNights," night",n.numberOfNights!==1?"s":""]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{type:"button",onPointerDown:X=>{X.stopPropagation(),y(n.id)},className:"text-gray-500 hover:text-red-600 transition-colors p-1 rounded-full","aria-label":`Delete Stop ${e+1}`,children:o.jsx("svg",{className:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm4 0a1 1 0 012 0v6a1 1 0 11-2 0V8z",clipRule:"evenodd"})})}),o.jsx("button",{onClick:h,className:"text-gray-500 transition-transform transform p-1",style:{transform:t?"rotate(0deg)":"rotate(180deg)"},children:o.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]}),!t&&o.jsx("div",{className:"p-6 border-t border-gray-200 dark:border-gray-700 space-y-6",children:n.destinationId?o.jsxs(o.Fragment,{children:[J&&o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 p-4 rounded-lg border dark:border-gray-700 flex flex-col md:flex-row gap-4",children:[o.jsx("div",{className:"w-full md:w-1/3 flex-shrink-0",children:o.jsx(LT,{images:gG(J),alt:J.name,className:"w-full h-40 rounded-lg"})}),o.jsxs("div",{className:"flex-grow",children:[o.jsx("h4",{className:"font-bold text-lg text-brand-dark dark:text-white mb-2",children:J.name}),J.description&&o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:J.description})]})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex justify-between items-center mb-2",children:[o.jsxs("label",{htmlFor:`lodge-select-${n.id}`,className:"block text-sm font-bold text-gray-700 dark:text-gray-300",children:["Accommodation ",o.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-normal",children:"(use dropdown to change)"})]}),o.jsx("div",{className:"flex-shrink-0 w-28",children:o.jsxs("div",{className:"relative",children:[o.jsx("input",{id:`nights-${n.id}`,type:"number",min:"1",value:n.numberOfNights,onChange:X=>f("numberOfNights",X.target.value),className:"w-full p-2 pr-12 text-center border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:ring-2 focus:ring-blue-500 focus:outline-none"}),o.jsxs("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-xs text-gray-500 dark:text-gray-400",children:["night",n.numberOfNights>1&&"s"]})]})})]}),n.numberOfNights<k&&o.jsxs("div",{className:"mb-4 bg-yellow-100 border-l-4 border-yellow-500 text-yellow-800 p-3 rounded-r-lg dark:bg-yellow-900/30 dark:border-yellow-600 dark:text-yellow-200",role:"alert",children:[o.jsx("p",{className:"font-bold text-sm",children:"Recommendation"}),o.jsxs("p",{className:"text-xs",children:["A ",k,"-night stay is recommended for your selected full-day activities."]})]}),o.jsxs("select",{id:`lodge-select-${n.id}`,value:O||"",onChange:X=>F(X.target.value),className:"w-full p-3 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:ring-2 focus:ring-blue-500 focus:outline-none mb-4",disabled:!U.length,children:[o.jsx("option",{value:"",disabled:!0,children:"Browse lodges..."}),U.map(X=>o.jsx("option",{value:X.id,children:X.name},X.id))]}),D?o.jsx("div",{className:"bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",children:[o.jsx("div",{className:"lg:col-span-1",children:o.jsx(LT,{images:pG(D),alt:D.name,className:"w-full h-48 rounded-lg"})}),o.jsxs("div",{className:"lg:col-span-3 flex flex-col",children:[o.jsxs("div",{className:"pb-4 border-b border-gray-200 dark:border-gray-600",children:[o.jsx("h5",{className:"font-bold text-lg text-brand-dark dark:text-white",children:D.name}),D.features&&D.features.length>0&&o.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:D.features.map(X=>o.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-blue-800 dark:text-blue-200 bg-blue-100 dar
4211k:bg-blue-900/50 px-2 py-1 rounded-full",children:[o.jsx("svg",{className:"w-3 h-3",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),X]},X))})]}),o.jsxs("div",{className:"pt-4 flex-grow",children:[o.jsx("h6",{className:"text-sm font-bold text-gray-700 dark:text-gray-300 mb-3",children:"Available Rooms"}),o.jsx("div",{className:"space-y-3",children:D.rooms.length>0?D.rooms.map(X=>{const ae=n.lodgeId===D.id&&n.roomId===X.id,Te=M(X);let K;return X.pricingModel==="perNight"?K=o.jsxs("span",{className:"font-semibold",children:["$",Te.toLocaleString(),"/night"]}):K=o.jsxs("span",{className:"font-semibold",children:["$",Te.toLocaleString(),"/pp"]}),o.jsxs("div",{className:"flex items-center justify-between gap-4 bg-white dark:bg-gray-700/50 p-3 rounded-md border dark:border-gray-600",children:[o.jsxs("div",{children:[o.jsx("p",{className:"font-semibold text-brand-dark dark:text-gray-100",children:X.name}),o.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2",children:[o.jsxs("span",{children:["Max: ",X.maxOccupancy," people"]}),o.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),K]})]}),o.jsx("button",{onClick:()=>_(D.id,X.id),className:`px-4 py-1.5 text-sm font-semibold rounded-full transition-colors whitespace-nowrap ${ae?"bg-blue-600 text-white cursor-default":"bg-gray-200 text-gray-800 hover:bg-gray-300 dark:bg-gray-600 dark:text-gray-200 dark:hover:bg-gray-500"}`,disabled:ae,children:ae?"✓ Selected":"Select"})]},X.id)}):o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No rooms available for this lodge."})})]})]})]})}):o.jsxs("div",{className:"text-center py-8 bg-gray-50 dark:bg-gray-800/50 rounded-lg border-2 border-dashed dark:border-gray-700",children:[o.jsx("p",{className:"font-semibold text-orange-600 dark:text-orange-400",children:"No accommodation selected"}),o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:"Please select a lodge from the dropdown above."})]})]}),z.length>0&&o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-bold text-gray-700 dark:text-gray-300 mb-3",children:"Activities"}),o.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:o.jsx("nav",{className:"-mb-px flex space-x-4","aria-label":"Tabs",children:Array.from({length:n.numberOfNights}).map((X,ae)=>o.jsxs("button",{type:"button",onClick:()=>I(ae),className:`whitespace-nowrap py-3 px-1 border-b-2 font-medium text-sm focus:outline-none ${S===ae?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:border-gray-300 dark:hover:border-gray-600"}`,children:["Day ",c+ae," Activities"]},ae))})}),o.jsx("div",{className:"pt-5",children:o.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:z.map(X=>{const ae=j.includes(X.id),Te=H&&X.isFullDay&&!ae;let K=!1;(J==null?void 0:J.id)==="bwindi"&&(L.includes(X.id)?K=G:X.id===ee&&(K=ne));const Se=S===0&&X.isFullDay,Ae=Te||K||Se;let ze="";return Se?ze="Full-day activities cannot be booked on the arrival day.":Te?ze="Only one full-day activity can be selected per day.":K&&(ze="This activity cannot be combined with other strenuous treks on the same day."),o.jsx(mG,{activity:X,isSelected:ae,onToggle:()=>p(X.id,S),disabled:Ae,disabledReason:ze},X.id)})})})]})]}):o.jsx("p",{className:"text-gray-500 dark:text-gray-400 italic text-center py-4",children:"This stop has no destination. Please delete it."})})]})})},jT=()=>o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-full w-full",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})}),OT=()=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-full w-full",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 20l-5.447-2.724A1 1 0 013 16.382V12a1 1 0 011-1h16a1 1 0 011 1v4.382a1 1 0 01-.553.894L15 20M9 20h6m-3-16h.01M9 4h6"}),o.jsx("circle",{cx:"7",cy:"15",r:"2"}),o.jsx("circle",{cx:"17",cy:"15",r:"2"})]}),FT=()=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-full w-full",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20 16V8a2 2 0 00-2-2H6a2 2 0 00-4 2v8m16 0v2H4v-2m16 0h2M4 16H2m14-10V4M6 6V4m10 6h-6"}),o.jsx("circle",{cx:"7",cy:"18",r:"2"}),o.jsx("circle",{cx:"17",cy:"18",r:"2"})]}),iy=({icon:n,title:e,description:t,price:r,priceHint:s,isSelected:a,isDisabled:c,onClick:u})=>
4211o.jsxs("button",{type:"button",onClick:u,disabled:c,className:`p-4 border rounded-lg text-left w-full transition-all duration-200 flex items-center ${a?"bg-blue-50 dark:bg-gray-700/50 border-blue-500 dark:border-blue-400 ring-2 ring-blue-500/20":"bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md"} ${c?"opacity-50 cursor-not-allowed":"hover:scale-[1.02]"}`,"aria-pressed":a,children:[o.jsx("div",{className:"mr-4 text-brand-dark dark:text-gray-200 h-6 w-6",children:n}),o.jsxs("div",{className:"flex-grow",children:[o.jsx("h4",{className:"font-bold text-brand-dark dark:text-white",children:e}),o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t})]}),o.jsxs("div",{className:"text-right",children:[o.jsxs("div",{className:"font-bold text-brand-dark dark:text-white text-lg",children:["$",r]}),s&&o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s})]})]}),yG=({from:n,to:e,setting:t,onSettingChange:r,isFlyInAvailable:s,travelerCount:a,lockedVehicle:c,day:u,flyInCostPerPerson:h,availableOperators:f,allOperators:p})=>{const[y,b]=R.useState(!1),w=h*a,E=Xo.road.cruiser,N=Xo.road.van,S=t.type==="fly-in",I=t.type==="road"&&t.vehicle==="cruiser",O=t.type==="road"&&t.vehicle==="van",F=!s,J=c==="van",z=c==="cruiser",U=R.useMemo(()=>t.type!=="fly-in"||!t.operatorId?null:p.find(_=>_.id===t.operatorId),[t,p]),D=R.useMemo(()=>S?{icon:o.jsx(jT,{}),name:`Fly-in${U?` (${U.name})`:""}`,price:w,hint:a>1?`(${a} x $${h})`:"per person"}:I?{icon:o.jsx(OT,{}),name:"4x4 Safari Jeep",price:E,hint:"per day"}:O?{icon:o.jsx(FT,{}),name:"Safari Van",price:N,hint:"per day"}:{icon:null,name:"Not Selected",price:0,hint:""},[S,I,O,w,E,N,U,a,h]),k=u!==null?`Day ${u}: Travel to ${e}`:`Travel to ${e}`;return o.jsxs("div",{className:"mb-6 bg-white dark:bg-gray-800 border border-gray-200/80 dark:border-gray-700/80 rounded-xl shadow-sm",children:[o.jsxs("button",{type:"button",onClick:()=>b(!y),className:"w-full flex justify-between items-center p-4 text-left","aria-expanded":y,children:[o.jsxs("div",{children:[o.jsxs("h3",{className:"text-base font-bold text-brand-dark dark:text-gray-100",children:[k,!y&&o.jsx("span",{className:"ml-2 text-xs font-normal text-gray-500",children:"(click to change type)"})]}),!y&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400 mt-1",children:[o.jsx("div",{className:"w-5 h-5",children:D.icon}),o.jsxs("span",{children:[D.name," · "]}),o.jsxs("span",{className:"font-semibold text-brand-dark dark:text-gray-200",children:["$",D.price.toLocaleString(),D.hint&&o.jsx("span",{className:"text-xs font-normal text-gray-500 ml-1",children:D.hint})]})]})]}),o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-5 w-5 text-gray-500 dark:text-gray-400 transition-transform duration-300 ${y?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})})]}),y&&o.jsxs("div",{className:"p-4 border-t border-gray-200/80 dark:border-gray-700/80",children:[o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-3",children:[o.jsx(iy,{icon:o.jsx(jT,{}),title:"Fly-in",description:S&&U?U.name:"Fastest option",price:w.toLocaleString(),priceHint:a>1?`(${a} x $${h})`:"per person",isSelected:S,isDisabled:F,onClick:()=>r({type:"fly-in"})}),o.jsx(iy,{icon:o.jsx(OT,{}),title:"4x4 Safari Jeep",description:"Comfort & off-road",price:E.toLocaleString(),priceHint:"per day",isSelected:I,isDisabled:J,onClick:()=>r({type:"road",vehicle:"cruiser"})}),o.jsx(iy,{icon:o.jsx(FT,{}),title:"Safari Van",description:"Budget-friendly",price:N.toLocaleString(),priceHint:"per day",isSelected:O,isDisabled:z,onClick:()=>r({type:"road",vehicle:"van"})})]}),S&&f.length>1&&o.jsxs("div",{className:"mt-4 pt-4 border-t dark:border-gray-700",children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:`operator-select-${t.id}`,children:"Select Flight Operator"}),o.jsx("select",{id:`operator-select-${t.id}`,value:t.operatorId,onChange:_=>r({operatorId:_.target.value}),className:"w-full p-2 border rounded bg-white border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:f.map(_=>o.jsx("option",{value:_.id,children:_.name},_.id))})]})]})]})},xG=({value:n,onChange:e,onClose:t})=>{const r=new Date(n+"T00:00:00Z"),[s,a]=R.useState(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),1))),c=s.getUTCFullYear(),u=s.getUTCMonth(),h=["January","February","March","April","May","June","July","August","September","October","November","December"],f=["S","M","T","W","T","F","S"],p=new Date(Date.UTC(c,u,1)),y=new Date(Date.UTC(c,u+1,0)).getUTCDate(),b=p.getUTCDay(),w=Array(b).fill(null);for(let F=1;F<=y;F++)w.push(new Date(Date.UTC(c,u,F)));const E=F=>{const J=F.toISOString().split("T")[0];e(J),t()},N=F=>{a(new Date(Date.UTC(c,u+F,1)))},S=new Date,I=new Date(Date.UTC(S.getUTCFullYear(),S.getUTCMonth(),S.getUTCDate())),O=new Date(I);return O.setUTCDate(I.getUTCDate()+7),o.jsxs("div",{className:"bg-white dark:bg-gray-800 border dark:border-gray-700 rounded-lg shadow-2xl p-4",children:[o.jsxs("div",{className:"flex justify-between items-center mb-4",children:[o.jsx("button",{type:"button",onClick:()=>N(-1),className:"p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),o.jsxs("div",{className:"font-bold text-base text-brand-dark dark:text-white",children:[h[u]," ",c]}),o.jsx("button",{type:"button",onClick:()=>N(1),className:"p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),o.jsx("div",{className:"grid grid-cols-7 gap-1 text-center text-xs text-gray-500 dark:text-gray-400 mb-2",children:f.map((F,J)=>o.jsx("div",{className:"aspect-square flex items-center justify-center font-semibold",children:F},J))}),o.jsx("div",{className:"grid grid-cols-7 gap-1",children:w.map((F,J)=>{if(!F)return o.jsx("div",{className:"aspect-square"},`empty-${J}`);const z=F.getTime()===r.getTime(),U=F.getTime()===I.getTime(),D=F<O;let k="w-full h-full aspect-square rounded-full flex items-center justify-center text-sm transition-colors ";return D?k+="text-gray-300 dark:text-gray-600 cursor-not-allowed line-through":z?k+="bg-blue-600 text-white font-bold hover:bg-blue-700":U?k+="bg-blue-100 dar
4211k:bg-blue-900/50 text-blue-700 dark:text-blue-200 font-semibold hover:bg-blue-200 dark:hover:bg-blue-800/50 ring-1 ring-blue-500":k+="text-brand-dark dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",o.jsx("div",{className:"flex justify-center items-center aspect-square",children:o.jsx("button",{type:"button",className:k,onClick:()=>E(F),disabled:D,children:F.getUTCDate()})},F.toISOString())})})]})},CG=()=>o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),bG=()=>o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M15 21v-2a4 4 0 00-4-4H9a4 4 0 00-4 4v2"})}),UT=()=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}),jm=({label:n,value:e,isSelected:t,onSelect:r})=>o.jsxs("button",{type:"button",onClick:()=>r(e),className:`w-full text-left px-4 py-3 text-sm flex items-center justify-between rounded-md ${t?"bg-blue-50 dark:bg-blue-900/50 text-blue-700 dark:text-blue-200":"text-brand-dark dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[o.jsx("span",{className:"font-medium",children:n}),t&&o.jsx("svg",{className:"w-5 h-5 text-blue-600",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})]}),VT=({startDate:n,travelerCount:e,startLocation:t,endLocation:r,onStartDateChange:s,onTravelerCountChange:a,onStartLocationChange:c,onEndLocationChange:u,forceDatePickerOpen:h,isCenteredLayout:f})=>{const[p,y]=R.useState(!1),[b,w]=R.useState(!1),[E,N]=R.useState(!1),[S,I]=R.useState(!1),O=R.useRef(null),F=R.useRef(null),J=R.useRef(null),z=R.useRef(null),U=R.useRef(!1);R.useEffect(()=>{h&&!U.current&&(w(!0),U.current=!0)},[h]),R.useEffect(()=>{const j=H=>{O.current&&!O.current.contains(H.target)&&y(!1),F.current&&!F.current.contains(H.target)&&w(!1),J.current&&!J.current.contains(H.target)&&N(!1),z.current&&!z.current.contains(H.target)&&I(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const D=j=>{j<1||a(j)},k="relative w-full p-3 border border-gray-200 dark:border-gray-700 rounded-[25px] bg-white dark:bg-gray-800 transition-all shadow-sm text-left hover:border-blue-500 hover:shadow-md focus-within:ring-2 focus-within:ring-offset-2 dark:focus-within:ring-offset-gray-900 focus-within:ring-blue-500/50 focus-within:border-blue-500 flex items-center gap-3",_="text-xs font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider",M=n?new Date(n+"T00:00:00").toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric",year:"numeric"}):o.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"Select a Date"});return o.jsxs("div",{className:f?"flex flex-col md:flex-row items-stretch gap-3 bg-white/90 dark:bg-gray-800/90 backdrop-blur-sm p-4 rounded-xl shadow-2xl border border-white/20":"mb-8 flex flex-col md:flex-row items-stretch gap-3",children:[o.jsxs("div",{className:"relative flex-1",ref:F,children:[o.jsxs("button",{type:"button",onClick:()=>w(j=>!j),className:`${k} w-full ${h&&!n?"animate-pulse ring-2 ring-blue-500 border-blue-500":""}`,"aria-label":"Trip Start Date",children:[o.jsx("div",{className:"text-gray-500 dark:text-gray-400 flex-shrink-0",children:o.jsx(CG,{})}),o.jsxs("div",{children:[o.jsx("div",{className:_,children:"Trip Start Date"}),o.jsx("div",{className:"text-sm font-medium text-brand-dark dark:text-gray-200 mt-1",children:M})]})]}),b&&o.jsx("div",{className:"absolute top-full mt-2 w-full z-20",children:o.jsx(xG,{value:n||new Date().toISOString().split("T")[0],onChange:s,onClose:()=>w(!1)})})]}),o.jsxs("div",{className:"relative flex-1",ref:O,children:[o.jsxs("button",{type:"button",onClick:()=>y(j=>!j),className:`${k} w-full`,children:[o.jsx("div",{className:"text-gray-500 dark:text-gray-400 flex-shrink-0",children:o.jsx(bG,{})}),o.jsxs("div",{className:"text-left",children:[o.jsx("div",{className:_,children:"Guests"}),o.jsx("div",{className:"text-sm font-medium text-brand-dark dark:text-gray-200 mt-1",children:`${e} guest${e>1?"s":""}`})]})]}),p&&o.jsx("div",{className:"absolute top-full mt-2 left-0 w-full bg-white dark:bg-gray-800 border dark:border-gray-600 rounded-lg shadow-xl p-4 z-10",onClick:j=>j.stopPropagation(),children:o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"font-semibold text-brand-dark dark:text-white",children:"Guests"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:()=>D(e-1),disabled:e<=1,className:"w-8 h-8 rounded-full border dark:border-gray-500 disabled:opacity-50 flex items-center justify-center",children:"-"}),o.jsx("span",{className:"w-8 text-center font-medium",children:e}),o.jsx("button",{type:"button",onClick:()=>D(e+1),className:"w-8 h-8 rounded-full border dark:border-gray-500 flex items-center justify-center",children:"+"})]})]})})]}),o.jsxs("div",{className:"relative flex-1",ref:J,children:[o.jsxs("button",{type:"button",onClick:()=>N(j=>!j),className:`${k} w-full`,"aria-label":"Start Location",children:[o.jsx("div",{className:"text-gray-500 dark:text-gray-400 flex-shrink-0",children:o.jsx(UT,{})}),o.jsxs("div",{children:[o.jsx("div",{className:_,children:"Start Location"}),o.jsx("div",{className:"text-sm font-medium text-brand-dark dark:text-gray-200 mt-1 capitalize",children:t})]})]}),E&&o.jsxs("div",{className:"absolute top-full mt-2 w-full bg-white dark:bg-gray-800 border dark:border-gray-600 rounded-lg shadow-xl p-2 z-10",children:[o.jsx(jm,{label:"Entebbe",value:"entebbe",isSelected:t==="entebbe",onSelect:j=>{c(j),N(!1)}}),o.jsx(jm,{label:"Kigali",value:"kigali",isSelected:t==="kigali",onSelect:j=>{c(j),N(!1)}})]})]}),o.jsxs("div",{className:"relative flex-1",ref:z,children:[o.jsxs("button",{type:"button",onClick:()=>I(j=>!j),className:`${k} w-full`,"aria-label":"End Location",children:[o.jsx("div",{className:"text-gray-500 dark:text-gray-400 flex-shrink-0",children:o.jsx(UT,{})}),o.jsxs("div",{children:[o.jsx("div",{className:_,children:"End Location"}),o.jsx("div",{className:"text-sm font-medium text-brand-dark dark:text-gray-200 mt-1 capitalize",children:r})]})]}),S&&o.jsxs("div",{className:"absolute top-full mt-2 w-full bg-white dark:bg-gray-800 border dark:border-gray-600 rounded-lg shadow-xl p-2 z-10",children:[o.jsx(jm,{label:"Entebbe",value:"entebbe",isSelected:r==="entebbe",onSelect:j=>{u(j),I(!1)}}),o.jsx(jm,{label:"Kigali",value:"kigali",isSelected:r==="kigali",onSelect:j=>{u(j),I(!1)}})]})]})]})},vG=({onAddDestination:n,onAddLodge:e,stops:t})=>{const{state:{destinations:r,lodges:s}}
4211=an(),[a,c]=R.useState(!1),[u,h]=R.useState(""),f=R.useRef(null),p=R.useRef(null);R.useEffect(()=>{const w=E=>{f.current&&!f.current.contains(E.target)&&c(!1)};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[]);const{results:y,title:b}=R.useMemo(()=>{const w=t.length>0?t[t.length-1]:null;if(!u.trim()){if(w){const I=w.destinationId,O=r.find(U=>U.id===I),F=CR[I]||[],J=new Set(t.map(U=>U.destinationId)),z=F.filter(U=>!J.has(U)).map(U=>r.find(D=>D.id===U)).filter(U=>U!==void 0).slice(0,3).map(U=>({type:"destination",data:U}));if(z.length>0)return{results:z,title:`Next up from ${O==null?void 0:O.name}?`}}return{results:r.slice(0,4).map(I=>({type:"destination",data:I})),title:"Popular Destinations"}}const E=u.toLowerCase(),N=r.filter(I=>I.name.toLowerCase().includes(E)||I.shortCode&&I.shortCode.toLowerCase().includes(E)||I.hint&&I.hint.toLowerCase().includes(E)||I.keywords&&I.keywords.some(O=>O.toLowerCase().includes(E))).map(I=>({type:"destination",data:I})),S=s.filter(I=>I.name.toLowerCase().includes(E)||I.keywords&&I.keywords.some(O=>O.toLowerCase().includes(E))).map(I=>({type:"lodge",data:I}));return{results:[...N,...S].slice(0,10),title:"Search Results"}},[u,t]);return o.jsxs("div",{className:"relative",ref:f,children:[o.jsxs("div",{className:"relative",children:[o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-500 pointer-events-none",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})}),o.jsx("input",{ref:p,type:"search",placeholder:"Add a destination or lodge...",value:u,onChange:w=>h(w.target.value),onFocus:()=>c(!0),className:"w-full text-left py-3 pl-11 pr-4 text-gray-800 dark:text-gray-200 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-full shadow-sm hover:shadow-md transition-shadow focus:outline-none focus:ring-2 focus:ring-blue-400"})]}),a&&o.jsxs("div",{className:"absolute z-20 w-full bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-xl mt-2",children:[o.jsx("div",{className:"px-4 py-2 text-xs font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:b}),o.jsx("ul",{className:"py-1 max-h-80 overflow-y-auto",children:y.length>0?y.map(w=>o.jsxs("li",{className:"px-4 py-3 text-brand-dark dark:text-gray-200 hover:bg-blue-50 dark:hover:bg-gray-700 cursor-pointer flex justify-between items-center",onClick:()=>{w.type==="destination"?n(w.data.id):e(w.data.id),h(""),c(!1)},children:[o.jsx("span",{children:w.data.name}),w.type==="destination"&&w.data.hint&&o.jsx("span",{className:"text-sm text-gray-500 bg-gray-100 dark:bg-gray-600 dark:text-gray-300 px-2 py-0.5 rounded-full",children:w.data.hint}),w.type==="lodge"&&o.jsx("span",{className:"text-sm text-gray-500 bg-yellow-100 dark:bg-yellow-900/50 dark:text-yellow-300 px-2 py-0.5 rounded-full",children:"Lodge"})]},`${w.type}-${w.data.id}`)):o.jsx("li",{className:"px-4 py-2 text-gray-500 dark:text-gray-400",children:"No results found."})})]})]})},wG=(n,e,t,r)=>{if(n.pricingModel==="perNight"){const s=t==="high"?"highSeasonPricePerNight":"lowSeasonPricePerNight";return(e==null?void 0:e[s])??n[s]??0}if(r===1){const s=t==="high"?"highSeasonPriceSingle":"lowSeasonPriceSingle";return(e==null?void 0:e[s])??n[s]??0}else if(r>1){const s=t==="high"?"highSeasonPriceDouble":"lowSeasonPriceDouble";return((e==null?void 0:e[s])??n[s]??0)*r}return 0},EG=n=>{if(!n)return 0;if(typeof n.adminCommissionRateOverride=="number"&&n.adminCommissionRateOverride>=0)return n.adminCommissionRateOverride;if(n.canSetCommissionRate??!0){const e=n.commissionRate||0;return Math.min(e,.25)}return 0},_G=()=>{const{state:n,navigateTo:e,navigateToBooking:t,updateDraftItinerary:r}=an(),{destinations:s,lodges:a}=n,{draftItinerary:c}=n,[u,h]=R.useState(null),[f,p]=R.useState(!1),[y,b]=R.useState(!1),[w,E]=R.useState([]),[N,S]=R.useState([]),[I,O]=R.useState(!1),[F,J]=R.useState({}
4211),[z,U]=R.useState(null),[D,k]=R.useState(null),[_,M]=R.useState(null),j=R.useRef(null),H=R.useRef(null),L=R.useRef({x:0,y:0}),ee=R.useRef(null),[ne]=R.useState(`TU-${Math.random().toString(36).substr(2,6).toUpperCase()}`),[G,W]=R.useState(0),[X,ae]=R.useState(0),[Te,K]=R.useState({accommodationItems:[],activityItems:[],parkFeeItems:[],transportItems:[],permitCostItems:[],permitFeeItems:[],otherCostItems:[]}),[fe,Se]=R.useState({commissionableSubtotal:0,nonCommissionableSubtotal:0}),Ae=(c==null?void 0:c.stops.reduce((re,Ne)=>re+Ne.numberOfNights,0))||0;R.useEffect(()=>{c||e(Le.Home),ge.getAllFlightCosts().then(E),ge.getAllFlightOperators().then(S)},[c,e]),R.useEffect(()=>{if(c&&!c.startDate)p(!0),b(!1);else if(f&&(c!=null&&c.startDate)){b(!0);const re=setTimeout(()=>{p(!1),b(!1)},500);return()=>clearTimeout(re)}},[c==null?void 0:c.startDate,f]),R.useEffect(()=>{c!=null&&c.consultantId?(async()=>{const Ne=await ge.getConsultantById(c.consultantId);if(Ne){const[De,qe]=await Promise.all([ge.getReviewsByConsultant(Ne.id),ge.getItinerariesByConsultant(Ne.id)]),je=De.length,st=je>0?De.reduce((ht,Qe)=>ht+Qe.rating,0)/je:0,bt=qe.filter(ht=>ht.status==="confirmed"||ht.status==="completed").length;h({...Ne,avgRating:st,reviewCount:je,confirmedTrips:bt})}})():h(null)},[c==null?void 0:c.consultantId]),R.useEffect(()=>{if(!c)return;const re=c.stops.length>0?c.stops.length+1:0;if(c.transportSettings.length!==re){const Ne=[];for(let De=0;De<re;De++){const qe=`leg_${De}`,je=c.transportSettings.find(st=>st.id===qe);je?Ne.push(je):Ne.push({id:qe,type:"road",vehicle:"cruiser"})}r({...c,transportSettings:Ne.slice(0,re)})}},[c,r]);const ze=R.useCallback((re,Ne,De)=>{if(De){const je=w.find(st=>(st.from===re&&st.to===Ne||st.from===Ne&&st.to===re)&&st.operatorId===De);if(je)return je.cost}const qe=w.find(je=>je.from===re&&je.to===Ne||je.from===Ne&&je.to===re);return(qe==null?void 0:qe.cost)||Xo.flyIn},[w]);R.useEffect(()=>{var or,Li;if(!c||!c.startDate)return;let re=0,Ne=0,De=0;const qe=[],je=[],st=[],bt=[],ht=new Map,Qe=new Date(c.startDate),it=c.travelerCount;c.stops.forEach(_n=>{var Yn,on;const{destinationId:Kt,lodgeId:$e,roomId:un,numberOfNights:Kn,activities:rs}=_n,Hn=s.find(Nt=>Nt.id===Kt),Rt=a.find(Nt=>Nt.id===$e),Tn=Rt==null?void 0:Rt.rooms.find(Nt=>Nt.id===un),$r=(Yn=u==null?void 0:u.lodgeRates)==null?void 0:Yn.find(Nt=>Nt.lodgeId===$e),vr=(on=$r==null?void 0:$r.sellingRateOverrides)==null?void 0:on.find(Nt=>Nt.roomId===un);if(Rt&&Tn&&it>0){const Nt=Math.ceil(it/Tn.maxOccupancy);let Cn=it,jr=0;for(let Nr=0;Nr<Nt;Nr++){const Ps=Math.min(Cn,Tn.maxOccupancy);Cn-=Ps;let Sr=0;for(let Ws=0;Ws<Kn;Ws++){const ps=kC(Qe,De+Ws),Kr=TC(ps);Sr+=wG(Tn,vr,Kr,Ps)}jr+=Sr}re+=jr;const bn=Nt>1?`${Nt} x ${Tn.name}`:Tn.name;qe.push({id:`${Rt.id}-${Tn.id}-${_n.id}`,description:`${Rt.name} - ${bn} (${Kn} night${Kn>1?"s":""})`,cost:jr})}Hn&&rs.forEach(Nt=>{let Cn=!1;if(Nt.forEach(jr=>{const bn=Hn.activities.find(Nr=>Nr.id===jr);if(bn){let Nr=0,Ps=bn.name;switch(bn.unit){case"per person":Nr=bn.price*it;break;case"per guide":case"per vehicle":case"per group":Nr=bn.price;break}if(Ps=`${bn.name} (${it>1?`${it} people`:"1 person"})`,bn.includesParkEntryFee?(Ne+=Nr,st.push({id:`${bn.id}-${_n.id}-${Math.random()}`,description:Ps,cost:Nr})):(re+=Nr,je.push({id:`${bn.id}-${_n.id}-${Math.random()}`,description:Ps,cost:Nr}),Cn=!0),bn.permitProcessingFee&&bn.permitProcessingFee>0){const Sr=bn.permitProcessingFee*it;re+=Sr,bt.push({id:`permit-fee-${bn.id}-${_n.id}-${Math.random()}`,description:`${bn.name} Processing (${it>1?`${it} permits`:"1 permit"})`,cost:Sr})}}}),Cn&&Hn.parkFee>0){const jr=Hn.parkFee*it;Ne+=jr;const bn=ht.get(Hn.id)||{name:`${Hn.name} Entry`,cost:0,days:0};bn.cost+=jr,bn.days+=1,ht.set(Hn.id,bn)}}),De+=Kn});const jt=Array.from(ht.entries()).map(([_n,Kt])=>({id:_n,description:`${Kt.name} (${Kt.days} day${Kt.days>1?"s":""}, ${it} ${it>1?"people":"person"})`,cost:Kt.cost})),kr=[];let Rn=0;c.transportSettings.forEach((_n,Kt)=>{var $e,un,Kn,rs;if(_n.type==="fly-in"){const Hn=Kt===0?c.startLocation:($e=c.stops[Kt-1])==null?void 0:$e.destinationId,Rt=Kt>=c.stops.length?c.endLocation:(un=c.stops[Kt])==null?void 0:un.destinationId;if(Hn&&Rt){const $r=ze(Hn,Rt,_n.operatorId)*it;Rn+=$r;const vr=Kt===0?c.startLocation==="entebbe"?"Entebbe":"Kigali":(Kn=s.find(Cn=>Cn.id===Hn))==null?void 0:Kn.name,Yn=Kt>=c.stops.length?c.endLocation==="entebbe"?"Entebbe":"Kigali":(rs=s.find(Cn=>Cn.id===Rt))==null?void 0:rs.name,on=N.find(Cn=>Cn.id===_n.operatorId),Nt=on?` (${on.name})`:"";kr.push({id:`fly_${_n.id}`,description:`Fly-in: ${vr} to ${Yn}${Nt}`,cost:$r})}}}),Ne+=Rn;let Vn=0;const xn=Ae>0?Ae+1:0;if(xn>0){const _n=["entebbe","kigali","kampala"],Kt=c.stops.findIndex($e=>!_n.includes($e.destinationId));if(Kt===-1)Vn=0;else{let $e=-1;for(let Rt=c.stops.length-1;Rt>=0;Rt--)if(!_n.includes(c.stops[Rt].destinationId)){$e=Rt;break}let un=0;for(let Rt=0;Rt<Kt;Rt++)un+=c.stops[Rt].numberOfNights;let Kn=0;for(let Rt=$e+1;Rt<c.stops.length;Rt++)Kn+=c.stops[Rt].numberOfNights;const rs=un+Kn,Hn=Math.max(0,xn-rs);if(Hn>0){const Rt=c.transportSettings.find(Cn=>Cn.type==="road"),Tn=(Rt==null?void 0:Rt.vehicle)??"cruiser",$r=(Li=(or=u==null?void 0:u.transportRates)==null?void 0:or.road)==null?void 0:Li[Tn],vr=typeof $r=="number"?$r:Xo.road[Tn],Yn=Math.ceil(it/7);Vn=Hn*vr*Yn;const on=Tn==="cruiser"?"4x4 Safari Cruiser":"Safari Van",Nt=Yn>1?`${Yn} x `:"";kr.unshift({id:`${Tn}_hire`,description:`${Nt}${on} Hire (${Hn} days)`,cost:Vn})}}}re+=Vn;let Gn=0;const It=EG(u);It>0&&(Gn=re*It);const $n=[];Gn>0&&$n.push({id:"consultancy-fee",description:`Consultancy Fee (${Number((It*100).toPrecision(15))}%)`,cost:Gn});const Pn=re+Ne+Gn;W(Pn),ae(it>0?Pn/it:0),K({accommodationItems:qe,activityItems:je,parkFeeItems:jt,transportItems:kr,permitCostItems:st,permitFeeItems:bt,otherCostItems:$n}),Se({commissionableSubtotal:re,nonCommissionableSubtotal:Ne})},[c,u,ze,N,s,a]);const lt=R.useCallback(re=>{if(!c)return;const Ne=c.stops.filter(De=>De.id!==re);r({...c,stops:Ne})},[c,r]),dt=R.useCallback(re=>{M({x:re.clientX,y:re.clientY})},[]),Wt=R.useCallback(()=>{const re=j.current,Ne=H.current;
4211if(c&&re!==null&&Ne!==null&&re!==Ne){const De=[...c.stops],[qe]=De.splice(re,1);De.splice(Ne,0,qe),r({...c,stops:De})}U(null),k(null),M(null),j.current=null,H.current=null,document.body.style.userSelect="",document.body.style.cursor="",window.removeEventListener("pointermove",dt),window.removeEventListener("pointerup",Wt)},[c,r,dt]),Ht=R.useCallback((re,Ne)=>{const De=Ne.currentTarget.closest("[data-drag-handle]");if(De){if(Ne.preventDefault(),ee.current=De.parentElement,ee.current){const qe=ee.current.getBoundingClientRect();L.current={x:Ne.clientX-qe.left,y:Ne.clientY-qe.top};const je=ee.current.cloneNode(!0);k(je.innerHTML)}U(re),j.current=re,H.current=re,M({x:Ne.clientX,y:Ne.clientY}),document.body.style.userSelect="none",document.body.style.cursor="grabbing",window.addEventListener("pointermove",dt),window.addEventListener("pointerup",Wt)}},[dt,Wt]),Mr=R.useCallback(re=>{j.current!==null&&j.current!==re&&(H.current=re)},[]),br=(re,Ne,De)=>{if(!c)return;const qe=c.stops.map(je=>{var st,bt;if(je.id===re){const ht={...je,[Ne]:De};if(Ne==="destinationId"){ht.activities=Array(ht.numberOfNights).fill([]);const Qe=a.find(it=>it.destinationId===De&&it.isDefault);ht.lodgeId=(Qe==null?void 0:Qe.id)||null,ht.roomId=((st=Qe==null?void 0:Qe.rooms[0])==null?void 0:st.id)||null}if(Ne==="lodgeId"){const Qe=a.find(it=>it.id===De);ht.roomId=((bt=Qe==null?void 0:Qe.rooms[0])==null?void 0:bt.id)||null}if(Ne==="numberOfNights"){const Qe=Math.max(1,parseInt(De,10)||1);ht.numberOfNights=Qe;const it=ht.activities||[];Qe>it.length?ht.activities=[...it,...Array(Qe-it.length).fill([])]:ht.activities=it.slice(0,Qe)}return ht}return je});r({...c,stops:qe})},Lr=(re,Ne,De)=>{if(!c)return;const qe=c.stops.find(Qe=>Qe.id===re);if(!qe)return;const je=s.find(Qe=>Qe.id===qe.destinationId),st=je==null?void 0:je.activities.find(Qe=>Qe.id===De),bt=!(qe.activities[Ne]||[]).includes(De),ht=c.stops.map(Qe=>{if(Qe.id===re){const it=[...Qe.activities],jt=it[Ne]||[],kr=bt?[...jt,De]:jt.filter(Vn=>Vn!==De);it[Ne]=kr;let Rn={...Qe,activities:it};if(bt&&(st!=null&&st.isFullDay)){const xn=Rn.activities.flat().reduce((Gn,It)=>{const $n=je==null?void 0:je.activities.find(Pn=>Pn.id===It);return $n!=null&&$n.isFullDay?Gn+1:Gn},0)+1;if(Rn.numberOfNights<xn){const Gn=xn;Rn.numberOfNights=Gn;const It=Rn.activities||[];Gn>It.length&&(Rn.activities=[...It,...Array(Gn-It.length).fill([])])}}return Rn}return Qe});r({...c,stops:ht})},gt=(re,Ne)=>{if(!c)return;let De=c.transportSettings.map(je=>{var st,bt,ht;if(je.id===re){const Qe={...je,...Ne};if(Ne.type==="fly-in"){delete Qe.vehicle;const it=c.transportSettings.findIndex(Vn=>Vn.id===re),jt=it===0?c.startLocation:(st=c.stops[it-1])==null?void 0:st.destinationId,kr=it>=c.stops.length?c.endLocation:(bt=c.stops[it])==null?void 0:bt.destinationId,Rn=N.filter(Vn=>w.some(xn=>xn.operatorId===Vn.id&&(xn.from===jt&&xn.to===kr||xn.from===kr&&xn.to===jt)));(!Qe.operatorId||!Rn.some(Vn=>Vn.id===Qe.operatorId))&&(Qe.operatorId=(ht=Rn[0])==null?void 0:ht.id)}else Ne.type==="road"&&(delete Qe.operatorId,Qe.vehicle||(Qe.vehicle="cruiser"));return Qe}return je});const qe=De.find(je=>je.type==="road");if(qe){const je=qe.vehicle;De=De.map(st=>st.type==="road"&&st.vehicle!==je?{...st,vehicle:je}:st)}r({...c,transportSettings:De})},Ye=re=>{J(Ne=>({...Ne,[re]:!Ne[re]}))},In=(re,Ne)=>{c&&r({...c,[re]:Ne})},Jr=R.useCallback(re=>{if(!c)return;const Ne=["entebbe","kampala","ziwa-rhino","lake-mburo"],De=a.find(ht=>ht.destinationId===re&&ht.isDefault),qe=De==null?void 0:De.rooms[0],je=Ne.includes(re)?1:2,st={id:`stop_${Date.now()}`,destinationId:re,lodgeId:(De==null?void 0:De.id)||null,roomId:(qe==null?void 0:qe.id)||null,numberOfNights:je,activities:Array(je).fill([])},bt=[...c.stops,st];r({...c,stops:bt}),J(ht=>({...ht,[st.id]:!1}))},[c,r]),ar=R.useCallback(re=>{if(!c)return;const Ne=["entebbe","kampala","ziwa-rhino","lake-mburo"],De=a.find(ht=>ht.id===re);if(!De)return;const qe=De.rooms[0],je=Ne.includes(De.destinationId)?1:2,st={id:`stop_${Date.now()}`,destinationId:De.destinationId,lodgeId:De.id,roomId:(qe==null?void 0:qe.id)||null,numberOfNights:je,activities:Array(je).fill([])},bt=[...c.stops,st];r({...c,stops:bt}),J(ht=>({...ht,[st.id]:!1}))},[c,r]),Rs=re=>{if(re.preventDefault(),!!c){O(!0);try{const{commissionableSubtotal:Ne,nonCommissionableSubtotal:De}=fe,qe={id:ne,title:"Custom Uganda Safari",duration:Ae,stops:c.stops,status:"planning",startDate:c.startDate,travelerCount:c.travelerCount,startLocation:c.startLocation,endLocation:c.endLocation,totalPrice:G,commissionableSubtotal:Ne,nonCommissionableSubtotal:De,transportSettings:c.transportSettings||[],breakdown:Te};t(qe)}catch(Ne){console.error("Failed to navigate to booking:",Ne),alert("An error occurred preparing your booking. Please try again.")}finally{O(!1)}}};if(!c)return o.jsx("div",{className:"flex justify-center items-center h-full",children:o.jsx(At,{})});const{stops:Ct,startDate:St,travelerCount:Un,startLocation:Tr,endLocation:ns,transportSettings:yn}=c,kt={itineraryId:ne,startDate:St,travelerCount:Un,startLocation:Tr,endLocation:ns,onStartDateChange:re=>In("startDate",re),onTravelerCountChange:re=>In("travelerCount",re),onStartLocationChange:re=>In("startLocation",re),onEndLocationChange:re=>In("endLocation",re)};return o.jsxs("div",{children:[f&&o.jsx("div",{className:`fixed inset-0 bg-gray-900/60 backdrop-blur-sm z-40 flex flex-col items-center justify-start pt-16 p-4 transition-opacity duration-500
4212            ${y?"opacity-0":"opacity-100"}
4213          `,children:o.jsxs("div",{className:`w-full max-w-5xl transition-all duration-500 ${y?"scale-95 opacity-0":"scale-100 opacity-100"}`,children:[o.jsx("div",{className:"text-center mb-6 max-w-xl mx-auto",children:o.jsx("p",{className:"inline-block bg-white dark:bg-gray-900 text-brand-dark dark:text-gray-100 font-semibold p-4 rounded-lg shadow-lg",children:"Let's get started! Please select your trip start date to begin planning."})}),o.jsx(VT,{...kt,forceDatePickerOpen:!0,isCenteredLayout:!0})]})}),o.jsxs("div",{className:`transition-opacity duration-700 delay-200 ${f?"opacity-0":"opacity-100"}`,children:[o.jsx("div",{className:"mb-2",children:o.jsx("h1",{className:"text-4xl font-bold font-heading p-2 -ml-2 dark:text-white",children:"Build Your Uganda Adventure"})}),o.jsx(VT,{...kt,isCenteredLayout:!1}),o.jsxs("div",{className:"grid lg:grid-cols-3 gap-8",children:[o.jsxs("div",{className:"lg:col-span-2",children:[Ct.length===0&&o.jsxs("div",{className:"text-center py-16 px-6 bg-gray-50 dark:bg-gray-800/50 rounded-lg border-2 border-dashed dark:border-gray-700",children:[o.jsx("h2",{className:"text-xl font-semibold text-brand-dark dark:text-white",children:"Your itinerary is empty."}),o.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:"Use the search bar below to add your first destination or lodge."})]}),(()=>{const re=yn.findIndex(De=>De.type==="road"),Ne=re!==-1?yn[re].vehicle:null;return yn.map((De,qe)=>{var _n,Kt;const je=qe===Ct.length,st=qe===0?null:Ct[qe-1],bt=je?null:Ct[qe],ht=st?(_n=s.find($e=>$e.id===st.destinationId))==null?void 0:_n.name:Tr==="entebbe"?"Entebbe":"Kigali",Qe=bt?(Kt=s.find($e=>$e.id===bt.destinationId))==null?void 0:Kt.name:ns==="entebbe"?"Entebbe":"Kigali",it=st?st.destinationId:Tr,jt=bt?bt.destinationId:ns,kr=ze(it,jt,De.operatorId),Rn=N.filter($e=>w.some(un=>un.operatorId===$e.id&&(un.from===it&&un.to===jt||un.from===jt&&un.to===it))),Vn=Rn.length>0,xn=it===jt,It=De.type==="road"&&yn.indexOf(De)===re?null:Ne,$n=Ct.slice(0,qe).reduce(($e,un)=>$e+un.numberOfNights,0),Pn=$n+1,or=Pn,Li=or+(bt?bt.numberOfNights-1:0);return o.jsxs(cc.Fragment,{children:[!xn&&o.jsx(yG,{from:ht||"Start",to:Qe||"End",setting:De,onSettingChange:$e=>gt(De.id,$e),isFlyInAvailable:Vn,travelerCount:Un,lockedVehicle:It,day:qe===0?null:Pn,flyInCostPerPerson:kr,availableOperators:Rn,allOperators:N}),bt&&o.jsx(BG,{stop:bt,stopIndex:qe,isCollapsed:!!F[bt.id],isDragging:qe===z,startDate:St,daysElapsed:$n,startDay:or,endDay:Li,onToggleCollapse:()=>Ye(bt.id),onStopChange:($e,un)=>br(bt.id,$e,un),onActivityToggle:($e,un)=>Lr(bt.id,un,$e),onDeleteStop:lt,onDragStart:Ht,onDragEnter:()=>Mr(qe)},bt.id)]},De.id)})})(),o.jsx("div",{className:"mt-6",children:o.jsx(vG,{stops:Ct,onAddDestination:Jr,onAddLodge:ar})})]}),o.jsx("div",{className:"lg:col-span-1",children:o.jsx(fG,{stops:Ct,totalPrice:G,pricePerPerson:X,isLoading:I,handleSubmit:Rs,travelerCount:Un,startDate:St,breakdown:Te,duration:Ae,consultant:u})})]})]}),D&&_&&ee.current&&o.jsx("div",{style:{position:"fixed",top:_.y-L.current.y,left:_.x-L.current.x,width:`${ee.current.offsetWidth}px`,pointerEvents:"none",zIndex:1e3,transform:"rotate(2deg)",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.3)"},dangerouslySetInnerHTML:{__html:D}})]})},TG=()=>{const{selectConsultantProfile:n}
4213=an(),[e,t]=R.useState([]),[r,s]=R.useState(!0),[a,c]=R.useState("our-pick");R.useEffect(()=>{(async()=>{s(!0);try{const[p,y,b]=await Promise.all([ge.getAllConsultants(),ge.getAllReviews(),ge.getAllItineraries()]),w=p.map(E=>{const N=y.filter(F=>F.consultantId===E.id),S=N.length,I=S>0?N.reduce((F,J)=>F+J.rating,0)/S:0,O=b.filter(F=>F.consultantId===E.id&&(F.status==="confirmed"||F.status==="completed")).length;return{...E,avgRating:I,reviewCount:S,confirmedTrips:O}});t(w)}catch(p){console.error("Failed to fetch and process consultant data:",p)}finally{s(!1)}})()},[]);const u=R.useMemo(()=>{const f=[...e];switch(a){case"rating":f.sort((p,y)=>y.avgRating-p.avgRating||y.reviewCount-p.reviewCount);break;case"experience":f.sort((p,y)=>y.confirmedTrips-p.confirmedTrips||y.avgRating-p.avgRating);break;case"name":f.sort((p,y)=>p.name.localeCompare(y.name));break;case"our-pick":default:f.sort((p,y)=>y.avgRating-p.avgRating||y.confirmedTrips-p.confirmedTrips);break}return f},[e,a]),h=[{key:"our-pick",label:"Our Pick"},{key:"rating",label:"Highest Rating"},{key:"experience",label:"Most Trips"},{key:"name",label:"Name (A-Z)"}];return o.jsxs("div",{className:"max-w-6xl mx-auto",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("h1",{className:"text-4xl font-bold text-brand-dark dark:text-white font-heading",children:"Our Safari Experts"}),o.jsx("p",{className:"text-lg mt-2 text-gray-600 dark:text-gray-300 max-w-3xl mx-auto",children:"Meet our hand-picked team of local consultants. They bring years of experience, deep local knowledge, and a passion for crafting unforgettable Ugandan adventures."})]}),o.jsx("div",{className:"mb-10 flex justify-center",children:o.jsx("div",{className:"p-1.5 bg-gray-100 dark:bg-gray-800 rounded-lg flex flex-wrap gap-2",role:"radiogroup","aria-label":"Sort consultants",children:h.map(f=>o.jsx("button",{onClick:()=>c(f.key),role:"radio","aria-checked":a===f.key,className:`px-5 py-2 text-sm font-semibold rounded-md transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900 ${a===f.key?"bg-white dark:bg-gray-700 text-blue-600 dark:text-white shadow":"text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700/50"}`,children:f.label},f.key))})}),r?o.jsx("div",{className:"flex justify-center mt-16",children:o.jsx(At,{})}):o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8",children:u.map(f=>o.jsx(kG,{consultant:f,onSelectConsultant:n},f.id))})]})},kG=({consultant:n,onSelectConsultant:e})=>o.jsxs("button",{onClick:()=>e(n.id),className:"relative aspect-[3/4] w-full rounded-2xl overflow-hidden group shadow-lg hover:shadow-2xl transition-all duration-300 transform hover:scale-105 focus:outline-none focus:ring-4 focus:ring-blue-500 focus:ring-opacity-50","aria-label":`View profile for ${n.name}`,children:[o.jsx("img",{src:n.imageUrl,alt:n.name,className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),o.jsx("div",{className:`absolute top-4 right-4 text-xs font-bold px-3 py-1 rounded-full shadow-sm ${n.isAvailable?"bg-green-200 text-green-900 dark:bg-green-900 dark:text-green-200":"bg-gray-200 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}`,children:n.isAvailable?"Available":"Unavailable"}),o.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"}),o.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-6 text-white text-left",children:[o.jsx("h3",{className:"text-3xl font-bold font-heading",children:n.name}),o.jsx("p",{className:"text-sm opacity-90 mt-1",children:n.specialties.slice(0,3).join(", ")}),o.jsx("div",{className:"flex items-center gap-2 mt-3",children:n.reviewCount>0?o.jsxs(o.Fragment,{children:[o.jsx(Wa,{rating:n.avgRating}),o.jsx("span",{className:"font-semibold text-sm",children:n.avgRating.toFixed(1)}),o.jsxs("span",{className:"text-xs opacity-80",children:["(",n.reviewCount," reviews)"]})]}):o.jsx("span",{className:"text-sm font-semibold opacity-90",children:"(0 reviews)"})})]})]}),NG=({rating:n,onRatingChange:e,hoverRating:t,onHoverRating:r})=>
4213o.jsx("div",{className:"flex",onMouseLeave:()=>r(0),children:[1,2,3,4,5].map(s=>o.jsx("button",{type:"button",onClick:()=>e(s),onMouseEnter:()=>r(s),className:"text-3xl focus:outline-none transition-transform transform hover:scale-110 p-1","aria-label":`Rate ${s} star${s>1?"s":""}`,children:o.jsx("span",{className:s<=(t||n)?"text-yellow-400":"text-gray-300 dark:text-gray-600",children:"★"})},s))}),SG=({consultant:n,onClose:e,onReviewSubmitted:t})=>{const[r,s]=R.useState(1),[a,c]=R.useState(""),[u,h]=R.useState("idle"),[f,p]=R.useState(""),[y,b]=R.useState(""),[w,E]=R.useState(0),[N,S]=R.useState(0),[I,O]=R.useState(""),[F,J]=R.useState(!1),[z,U]=R.useState(""),D=async H=>{H.preventDefault(),h("verifying"),p("");const L=await ge.verifyItineraryForReview(a.trim());L.canReview&&L.consultantId===n.id?(h("verified"),s(2)):(h("error"),L.consultantId&&L.consultantId!==n.id?p(`This trip was not managed by ${n.name}. Please leave a review on the correct expert's profile.`):p(L.error||"Could not verify this itinerary ID."))},k=async H=>{if(H.preventDefault(),w===0){alert("Please select a star rating.");return}if(!y||!I){alert("Please fill out all fields.");return}if(z.trim().length>0){console.warn("[Security] Automated review submission detected. Simulating completion."),s(3);return}J(!0),await ge.submitReview({itineraryId:a.trim(),consultantId:n.id,travelerName:y,rating:w,comment:I}),J(!1),s(3)},_=()=>o.jsxs("form",{onSubmit:D,children:[o.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300 mb-4",children:["To leave a review for ",o.jsx("strong",{children:n.name}),", please enter your Trip ID. This helps us ensure all reviews are from real travelers."]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"itineraryId",className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",children:"Trip ID"}),o.jsx("input",{id:"itineraryId",type:"text",value:a,onChange:H=>c(H.target.value.toUpperCase()),placeholder:"e.g., TU-XYZ123",className:"w-full p-2 border rounded-lg border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 dark:text-white focus:ring-2 focus:ring-blue-500 focus:outline-none",required:!0})]}),u==="error"&&o.jsx("p",{className:"text-red-500 dark:text-red-400 text-sm mt-2",children:f}),o.jsxs("div",{className:"flex justify-end gap-4 pt-6",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(He,{type:"submit",disabled:u==="verifying",children:u==="verifying"?o.jsx(At,{}):"Verify Trip"})]})]}),M=()=>o.jsxs("form",{onSubmit:k,className:"space-y-4",children:[o.jsxs("div",{style:{position:"absolute",opacity:0,zIndex:-1,pointerEvents:"none",height:0,overflow:"hidden"},"aria-hidden":"true",children:[o.jsx("label",{htmlFor:"review_website_trap",children:"Personal Website"}),o.jsx("input",{id:"review_website_trap",type:"text",name:"review_website_trap",tabIndex:-1,autoComplete:"off",value:z,onChange:H=>U(H.target.value)})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"travelerName",className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",children:"Your Name"}),o.jsx("input",{id:"travelerName",type:"text",value:y,onChange:H=>b(H.target.value),required:!0,placeholder:"The name to display on your review",className:"w-full p-2 border rounded-lg border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 dark:text-white focus:ring-2 focus:ring-blue-500 focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",children:"Your Rating"}),o.jsx(NG,{rating:w,onRatingChange:E,hoverRating:N,onHoverRating:S})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"comment",className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",children:"Your Review"}),o.jsx("textarea",{id:"comment",value:I,onChange:H=>O(H.target.value),required:!0,rows:4,placeholder:"Share your experience...",className:"w-full p-2 border rounded-lg border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 dark:text-white focus:ring-2 focus:ring-blue-500 focus:outline-none"})]}),o.jsxs("div",{className:"flex justify-end gap-4 pt-4",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(He,{type:"submit",disabled:F,children:F?o.jsx(At,{}):"Submit Review"})]})]}),j=()=>o.jsxs("div",{className:"text-center py-4",children:[o.jsx("svg",{className:"w-16 h-16 mx-auto text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),o.jsx("h3",{className:"text-xl font-bold mt-4",children:"Thank You!"}),o.jsx("p",{className:"text-gray-600 dark:text-gray-300 mt-2",children:"Your review has been submitted successfully."}),o.jsx("div",{className:"mt-6",children:o.jsx(He,{onClick:()=>{t(),e()},children:"Close"})})]});return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-60 flex justify-center items-center z-50 p-4",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-lg m-4 transform transition-transform scale-100",onClick:H=>H.stopPropagation(),children:[o.jsxs("div",{className:"flex justify-between items-start mb-6",children:[o.jsxs("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:[r===1&&"Leave a Review",r===2&&`Reviewing ${n.name}`,r===3&&"Success"]}),o.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-700 dark:text-gray-500 dark:hover:text-gray-300 text-3xl leading-none -mt-2",children:"×"})]}),r===1&&_(),r===2&&M(),r===3&&j()]})})},DG=()=>
4213o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:o.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.225 0z"})}),AG=()=>o.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[o.jsx("path",{d:"M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.85s-.011 3.585-.069 4.85c-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07s-3.585-.012-4.85-.07c-3.252-.148-4.771-1.691-4.919-4.919-.058-1.265-.07-1.645-.07-4.85s.012-3.585.07-4.85c.148-3.225 1.664 4.771 4.919-4.919C8.415 2.175 8.796 2.163 12 2.163zm0 1.802c-3.153 0-3.518.012-4.745.068-2.678.122-3.831 1.274-3.953 3.953-.056 1.227-.068 1.592-.068 4.745s.012 3.518.068 4.745c.122 2.678 1.275 3.831 3.953 3.953 1.227.056 1.592.068 4.745.068s3.518-.012 4.745-.068c2.678-.122 3.831-1.275 3.953-3.953.056-1.227.068-1.592.068-4.745s-.012-3.518-.068-4.745c-.122-2.678-1.275-3.831-3.953-3.953-1.227-.056-1.592-.068-4.745-.068z"}),o.jsx("path",{d:"M12 6.865a5.135 5.135 0 100 10.27 5.135 5.135 0 000-10.27zm0 8.468a3.333 3.333 0 110-6.666 3.333 3.333 0 010 6.666z"}),o.jsx("path",{d:"M16.949 5.252a1.2 1.2 0 100 2.4 1.2 1.2 0 000-2.4z"})]}),IG=()=>o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:o.jsx("path",{d:"M22.675 0H1.325C.593 0 0 .593 0 1.325v21.351C0 23.407.593 24 1.325 24H12.82v-9.294H9.692v-3.622h3.128V8.413c0-3.1 1.893-4.788 4.659-4.788 1.325 0 2.463.099 2.795.143v3.24l-1.918.001c-1.504 0-1.795.715-1.795 1.763v2.313h3.587l-.467 3.622h-3.12V24h6.116c.732 0 1.325-.593 1.325-1.325V1.325C24 .593 23.407 0 22.675 0z"})}),RG=n=>{if(!n)return 0;if(typeof n.adminCommissionRateOverride=="number"&&n.adminCommissionRateOverride>=0)return n.adminCommissionRateOverride;if(n.canSetCommissionRate??!0){const e=n.commissionRate||0;return Math.min(e,.25)}return 0},PG=({review:n})=>o.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4 transition-shadow hover:shadow-md",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("p",{className:"font-bold text-brand-dark dark:text-white",children:n.travelerName}),o.jsx(Wa,{rating:n.rating})]}),o.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300 italic",children:['"',n.comment,'"']}),n.consultantReply&&o.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-200/80 dark:border-gray-700 bg-gray-50 dark:bg-gray-700/50 -m-4 p-4 rounded-b-lg",children:[o.jsx("p",{className:"text-xs font-bold text-gray-500 dark:text-gray-400",children:"Reply from consultant"}),o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 mt-1",children:n.consultantReply})]})]}),MG=({consultantId:n})=>{const{state:{loggedInUser:e},navigateTo:t,startItineraryWithConsultant:r}=an(),[s,a]=R.useState(null),[c,u]=R.useState([]),[h,f]=R.useState(0),[p,y]=R.useState(!0),[b,w]=R.useState(!1),E=R.useCallback(async()=>{if(n){y(!0);try{const[I,O,F]=await Promise.all([ge.getConsultantById(n),ge.getReviewsByConsultant(n),ge.getItinerariesByConsultant(n)]);if(I){a(I),u(O);const J=F.filter(z=>z.status==="confirmed"||z.status==="completed").length;f(J)}}catch(I){console.error("Failed to fetch consultant data:",I)}finally{y(!1)}}},[n]);R.useEffect(()=>{E()},[E]);const N=c.length>0?c.reduce((I,O)=>I+O.rating,0)/c.length:0,S=s?RG(s):0;return p?o.jsx("div",{className:"flex justify-center mt-16",children:o.jsx(At,{})}):s?o.jsxs("div",{className:"max-w-5xl mx-auto",children:[o.jsx("div",{className:"mb-6",children:o.jsxs("button",{onClick:()=>t(Le.ExpertsHub),className:"flex items-center gap-2 text-sm font-semibold text-gray-600 dark:text-gray-400 hover:text-brand-dark dark:hover:text-white transition-colors",children:[o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 19l-7-7m0 0l7-7m-7 7h18"})}),"Back to All Experts"]}
4213)}),o.jsx("div",{className:"bg-white dark:bg-brand-dark rounded-2xl shadow-xl overflow-hidden",children:o.jsxs("div",{className:"p-8 md:p-12",children:[o.jsxs("div",{className:"grid md:grid-cols-3 gap-8 items-start",children:[o.jsx("div",{className:"md:col-span-1",children:o.jsx("img",{src:s.imageUrl,alt:s.name,className:"w-full h-auto aspect-square object-cover rounded-xl shadow-md"})}),o.jsxs("div",{className:"md:col-span-2",children:[o.jsxs("div",{className:"flex justify-between items-start",children:[o.jsx("h1",{className:"text-4xl md:text-5xl font-bold text-brand-dark dark:text-white font-heading",children:s.name}),o.jsx("span",{className:`text-xs font-bold px-3 py-1 rounded-full shadow-sm whitespace-nowrap ${s.isAvailable?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-gray-200 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}`,children:s.isAvailable?"Available":"Unavailable"})]}),o.jsx("p",{className:"text-lg text-blue-600 dark:text-blue-400 font-semibold mt-2",children:s.specialties.slice(0,3).join(" • ")}),o.jsx("div",{className:"flex items-center gap-2 mt-3",children:c.length>0?o.jsxs(o.Fragment,{children:[o.jsx(Wa,{rating:N}),o.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400 font-medium",children:[N.toFixed(1)," (",c.length," reviews)"]})]}):o.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 font-medium",children:"No reviews yet"})}),s.company&&o.jsxs("div",{className:"mt-6 p-4 bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700",children:[o.jsx("p",{className:"text-xs font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Affiliated Company"}),o.jsx("a",{href:s.company.website,target:"_blank",rel:"noopener noreferrer",className:"text-lg font-bold text-blue-600 dark:text-blue-400 hover:underline",children:s.company.name}),o.jsx("p",{className:"text-sm font-medium text-brand-dark dark:text-gray-300 mt-1",children:s.company.tier}),o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-2 mt-3 text-xs text-gray-600 dark:text-gray-400",children:[s.company.utbLicensed&&o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx("svg",{className:"w-4 h-4 text-green-500",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),"UTB Licensed"]}),s.company.autoMember&&o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx("svg",{className:"w-4 h-4 text-green-500",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),"AUTO Member"]})]})]})]})]}),o.jsx("hr",{className:"my-8 md:my-12 border-t border-gray-200 dark:border-gray-700"}),o.jsxs("div",{className:"grid md:grid-cols-3 gap-8 md:gap-12",children:[o.jsxs("div",{className:"md:col-span-2 space-y-10",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-2xl font-bold font-heading text-brand-dark dark:text-white mb-3",children:["About ",s.name]}),o.jsx("p",{className:"text-brand-dark dark:text-gray-300 leading-relaxed whitespace-pre-line",children:s.bio})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex justify-between items-center mb-4",children:[o.jsx("h2",{className:"text-2xl font-bold font-heading text-brand-dark dark:text-white",children:"Reviews"}),!e&&o.jsx(He,{onClick:()=>w(!0),variant:"secondary",className:"!py-2 !px-4 text-sm",children:"Leave a Review"})]}),c.length>0?o.jsx("div",{className:"space-y-4",children:c.map(I=>o.jsx(PG,{review:I},I.id))}):o.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 py-8 px-4 bg-gray-50 dark:bg-gray-800 rounded-lg",children:o.jsx("p",{children:"This expert has no reviews yet. Be the first!"})})]})]}),o.jsxs("div",{className:"md:col-span-1 space-y-8",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-xl font-bold font-heading text-brand-dark dark:text-white mb-3",children:"Specialties"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:s.specialties.map(I=>o.jsx("span",{className:"bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-300 text-xs font-semibold px-3 py-1 rounded-full border border-blue-200 dark:border-blue-700",children:I},I))})]}),s.showCommissionRateOnProfile&&o.jsxs("div",{children:[o.jsx("h2",{className:"text-xl font-bold font-heading text-brand-dark dark:text-white mb-2",children:"Consultancy Fee"}
4213),o.jsx("p",{className:"text-5xl font-bold text-blue-600 dark:text-blue-400",children:S>0?`${Number((S*100).toPrecision(15))}%`:"Not Set"}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"Applies to commissionable items like accommodation, transport, and activities."})]}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-xl font-bold font-heading text-brand-dark dark:text-white mb-2",children:"Trips Confirmed"}),o.jsx("p",{className:"text-5xl font-bold text-blue-600 dark:text-blue-400",children:h})]}),s.socials&&o.jsxs("div",{children:[o.jsx("h2",{className:"text-xl font-bold font-heading text-brand-dark dark:text-white mb-3",children:"Connect"}),o.jsxs("div",{className:"space-y-3",children:[s.socials.linkedin&&o.jsxs("a",{href:s.socials.linkedin,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 text-gray-600 dark:text-gray-400 hover:text-blue-700 dark:hover:text-blue-500 font-medium",children:[o.jsx(DG,{})," LinkedIn"]}),s.socials.instagram&&o.jsxs("a",{href:s.socials.instagram,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 text-gray-600 dark:text-gray-400 hover:text-pink-600 dark:hover:text-pink-500 font-medium",children:[o.jsx(AG,{})," Instagram"]}),s.socials.facebook&&o.jsxs("a",{href:s.socials.facebook,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 text-gray-600 dark:text-gray-400 hover:text-blue-800 dark:hover:text-blue-500 font-medium",children:[o.jsx(IG,{})," Facebook"]})]})]})]})]}),o.jsx("div",{className:"text-center mt-12 pt-8 border-t border-gray-200 dark:border-gray-700",children:o.jsx(He,{onClick:()=>r(s.id),className:"w-full max-w-sm py-3 text-base",disabled:!s.isAvailable,children:s.isAvailable?`Plan a Trip with ${s.name}`:"Currently Unavailable"})})]})}),b&&s&&o.jsx(SG,{consultant:s,onClose:()=>w(!1),onReviewSubmitted:E})]}):o.jsx("div",{className:"text-center text-xl text-red-600",children:"Consultant not found. Please select a consultant from the Experts Hub."})},NC=({currentPage:n,totalItems:e,pageSize:t,onPageChange:r,onPageSizeChange:s,pageSizeOptions:a=[5,10,20,50],itemLabel:c="trips"})=>{const u=Math.max(1,Math.ceil(e/t)),h=e===0?0:(n-1)*t+1,f=Math.min(n*t,e),p=()=>{const y=[];if(u<=5)for(let w=1;w<=u;w++)y.push(w);else{y.push(1),n>3&&y.push("...");const w=Math.max(2,n-1),E=Math.min(u-1,n+1);for(let N=w;N<=E;N++)y.includes(N)||y.push(N);n<u-2&&y.push("..."),y.includes(u)||y.push(u)}return y};return o.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-center gap-4 py-4 px-2 border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 rounded-b-lg",children:[o.jsxs("div",{className:"flex items-center gap-3 text-xs sm:text-sm text-gray-600 dark:text-gray-400",children:[o.jsxs("span",{children:["Showing ",o.jsx("strong",{className:"font-semibold text-gray-900 dark:text-white",children:h})," to"," ",o.jsx("strong",{className:"font-semibold text-gray-900 dark:text-white",children:f})," of"," ",o.jsx("strong",{className:"font-semibold text-gray-900 dark:text-white",children:e})," ",c]}),s&&o.jsxs("div",{className:"flex items-center gap-1.5 ml-2",children:[o.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Per page:"}),o.jsx("select",{value:t,onChange:y=>s(Number(y.target.value)),className:"px-2 py-1 text-xs border rounded bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-white focus:ring-1 focus:ring-emerald-500 focus:outline-none",children:a.map(y=>o.jsx("option",{value:y,children:y},y))})]})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>r(1),disabled:n===1,"aria-label":"First page",className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed transition",children:o.jsx(FR,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>r(n-1),disabled:n===1,"aria-label":"Previous page",className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed transition",children:o.jsx(zN,{className:"w-4 h-4"})}),o.jsx("div",{className:"flex items-center gap-1 mx-1",children:p().map((y,b)=>typeof y=="number"?o.jsx("button",{onClick:()=>r(y),className:`min-w-[32px] h-8 px-2 text-xs sm:text-sm font-medium rounded-md transition ${n===y?"bg-emerald-600 text-white font-bold shadow-sm":"text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:y},b):o.jsx("span",{className:"px-1.5 text-gray-400 dark:text-gray-500",children:"..."},b))}),o.jsx("button",{onClick:()=>r(n+1),disabled:n===u||u===0,"aria-label":"Next page",className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed transition",children:o.jsx(ax,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>r(u),disabled:n===u||u===0,"aria-label":"Last page",className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed transition",children:o.jsx(VR,{className:"w-4 h-4"})})]})]})},Jl=({title:n,travelerInfo:e,items:t})=>{if(t.length===0)return null;const r=t.reduce((s,a)=>s+a.cost,0);return o.jsxs("div",{className:"mb-4",children:[o.jsxs("div",{className:"flex justify-between items-baseline border-b border-gray-200 dark:border-gray-700 pb-1 mb-2",children:[o.jsxs("h3",{className:"font-bold text-gray-800 dark:text-gray-200",children:[n," ",o.jsx("span",{className:"text-xs font-normal text-gray-500",children:e})]}),o.jsxs("span",{className:"font-bold text-brand-dark dark:text-white",children:["$",r.toLocaleStr
4213ing()]})]}),o.jsx("ul",{className:"space-y-1",children:t.map(s=>o.jsxs("li",{className:"flex justify-between text-gray-600 dark:text-gray-400 text-xs",children:[o.jsx("span",{className:"truncate pr-4",children:s.description}),o.jsxs("span",{className:"flex-shrink-0",children:["$",s.cost.toLocaleString()]})]},s.id))})]})},SA=({breakdown:n,travelerCount:e})=>{const t=R.useMemo(()=>e<=0?"":`(for ${e} ${e>1?"people":"person"})`,[e]);return n?o.jsxs("div",{className:"space-y-4 text-sm mt-4 p-4 bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700",children:[o.jsx("h3",{className:"text-lg font-bold text-brand-dark dark:text-white font-heading mb-3 border-b dark:border-gray-700 pb-2",children:"Stored Quote Summary"}),o.jsx(Jl,{title:"Accommodation",travelerInfo:t,items:n.accommodationItems||[]}),o.jsx(Jl,{title:"Transport",travelerInfo:t,items:n.transportItems||[]}),o.jsx(Jl,{title:"Activities",travelerInfo:t,items:n.activityItems||[]}),o.jsx(Jl,{title:"Permits",travelerInfo:t,items:n.permitCostItems||[]}),o.jsx(Jl,{title:"Permit Processing Fees",travelerInfo:t,items:n.permitFeeItems||[]}),o.jsx(Jl,{title:"Park Entry Fees",travelerInfo:t,items:n.parkFeeItems||[]}),o.jsx(Jl,{title:"Other Costs",travelerInfo:"",items:n.otherCostItems||[]})]}):o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 italic",children:"Detailed quote breakdown is not available for this legacy trip."})},LG=["planning","confirmed","completed","cancelled"],Po=({label:n,value:e})=>o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n}),o.jsx("p",{className:"text-sm text-brand-dark dark:text-gray-200 truncate",children:e})]}),SC=({itinerary:n,consultantName:e,onClose:t,onSave:r,isReadOnly:s=!1})=>{const{state:{destinations:a,lodges:c}}=an(),[u,h]=R.useState(n.status),[f,p]=R.useState(!1),y=b=>{b.preventDefault(),!(!r||s)&&(p(!0),setTimeout(()=>{r({...n,status:u}),p(!1)},500))};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-60 flex justify-center items-center z-50 p-4",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-3xl m-4 flex flex-col max-h-[90vh]",children:[o.jsxs("header",{className:"flex justify-between items-center p-6 border-b dark:border-gray-700 flex-shrink-0",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:n.title}),o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 font-mono",children:n.id})]}),o.jsx("button",{onClick:t,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("main",{className:"p-6 space-y-6 overflow-y-auto",children:[o.jsx("section",{className:"bg-gray-50 dark:bg-gray-900/50 p-4 rounded-lg border dark:border-gray-700",children:o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsx(Po,{label:"Traveler",value:n.travelerName}),o.jsx(Po,{label:"Email",value:o.jsx("a",{href:`mailto:${n.travelerEmail}`,className:"text-blue-600 hover:underline",children:n.travelerEmail})}),o.jsx(Po,{label:"Phone",value:n.travelerPhone||"N/A"}),o.jsx(Po,{label:"Consultant",value:e}),o.jsx(Po,{label:"Start Date",value:new Date(n.startDate).toLocaleDateString()}),o.jsx(Po,{label:"Duration",value:`${n.duration} nights / ${n.duration+1} days`}),o.jsx(Po,{label:"People",value:n.travelerCount}),o.jsx(Po,{label:"Total Price",value:`$${n.totalPrice.toLocaleString()}`})]})}),o.jsx(SA,{breakdown:n.breakdown,travelerCount:n.travelerCount}),o.jsxs("section",{children:[o.jsx("h3",{className:"text-lg font-bold text-brand-dark dark:text-white font-heading mb-3",children:"Itinerary Details"}),o.jsx("div",{className:"space-y-4",children:n.stops.map((b,w)=>{const E=a.find(I=>I.id===b.destinationId),N=c.find(I=>I.id===b.lodgeId),S=N==null?void 0:N.rooms.find(I=>I.id===b.roomId);return o.jsxs("div",{className:"border dark:border-gray-700 rounded-lg p-4 bg-white dark:bg-gray-800/50",children:[o.jsxs("h4",{className:"font-bold text-brand-dark dark:text-white",children:["Stop ",w+1,": ",(E==null?void 0:E.name)||"Unknown Destination"," (",b.numberOfNights," nights)"]}),o.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300 mb-3",children:[o.jsx("strong",{children:"Accommodation:"})," ",(N==null?void 0:N.name)||"Not specified"," - ",(S==null?void 0:S.name)||"Not specified"]}),b.activities.map((I,O)=>o.jsxs("div",{className:"pl-4 border-l-2 dark:border-gray-600 ml-1 mt-2",children:[o.jsxs("p",{className:"font-semibold text-xs text-gray-700 dark:text-gray-300",children:["Day ",w+O+1," Activities"]}),I.length>0?o.jsx("ul",{className:"list-disc list-inside text-sm text-gray-600 dark:text-gray-400",children:I.map(F=>{const J=E==null?void 0:E.activities.find(z=>z.id===F);return o.jsx("li",{children:(J==null?void 0:J.name)||"Unknown Activity"},F)})}):o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 italic",children:"No activities planned for this day."})]},O))]},b.id)})})]})]}),s?o.jsxs("footer",{className:"mt-auto p-5 border-t dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50 rounded-b-lg flex justify-between items-center flex-shrink-0",children:[o.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Trip Status: ",o.jsx("strong",{className:"capitalize text-brand-dark dark:text-white",children:n.status.replace("_"," ")})]}),o.jsx(He,{type:"button",onClick:t,children:"Close Details"})]}):o.jsx("form",{onSubmit:y,className:"mt-auto p-6 border-t dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50 rounded-b-lg flex-shrink-0",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"status",children:"Update Status"}),o.jsx("select",{id:"status",value:u,onChange:b=>h(b.target.value),className:"p-2 border rounded-lg border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 dark:text-white capitalize",children:LG.map(b=>o.jsx("option",{value:b,children:b},b))})]}),o.jsxs("div",{className:"flex gap-4",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:t,children:"Close"}),o.jsx(He,{type:"submit",disabled:f||u===n.status,children:f?o.jsx(At,{}):"Save Changes"})]})]})})]})})},DA=({isOpen:n,onClose:e,onConfirm:t,title:r,children:s,confirmText:a="Confirm"})=>n?o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-60 flex justify-center items-center z-50 transition-opacity",onClick:e,children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-md m-4 transform transition-transform scale-100",onClick:c=>c.stopPropagation(),children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading mb-4",children:r}),o.jsx("div",{className:"text-gray-600 dark:text-gray-300 mb-6",children:s}),o.jsxs("div",{className:"flex justify-end gap-4",children:[o.jsx(He,{variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(He,{variant:"danger",onClick:t,children:a})]})]})}):null;function jG({enabled:n,onTimeout:e,warningThresholdSeconds:t=60}
4213){const[r,s]=R.useState(()=>Lm()),[a,c]=R.useState(!1),[u,h]=R.useState(()=>Pg()),f=R.useRef(Date.now()),p=R.useRef(e);p.current=e;const y=R.useCallback(()=>{gh(),f.current=Date.now(),s(Lm()),c(!1)},[]),b=R.useCallback(w=>{ZV(w),h(w),gh(),f.current=Date.now(),s(Lm()),c(!1)},[]);return R.useEffect(()=>{if(!n){c(!1);return}const w=()=>{const S=Date.now();S-f.current>2e3&&(gh(),f.current=S),c(!1)},E=["mousemove","mousedown","keydown","touchstart","scroll","click"];E.forEach(S=>{window.addEventListener(S,w,{passive:!0})});const N=setInterval(()=>{if(_C()){ju();const O=Pg();wA(`Your session expired after ${O==="15m"?"15 minutes":O==="2m"?"2 minutes":"30 seconds"} of inactivity to protect your itinerary details. Please re-enter your Trip Reference Code or click your email link to resume.`),c(!1),p.current();return}const S=Lm();s(S);const I=u==="30s"?10:t;S>0&&S<=I?c(!0):c(!1)},1e3);return()=>{E.forEach(S=>{window.removeEventListener(S,w)}),clearInterval(N)}},[n,u,t]),{remainingSeconds:r,showWarning:a,resetTimer:y,activePreset:u,changePreset:b}}const GT=["planning","pending_confirmation","confirmed","completed","cancelled"],HT=n=>{switch(n){case"completed":return"bg-emerald-100 text-emerald-800 dark:bg-emerald-950/70 dark:text-emerald-300 border-emerald-300 dark:border-emerald-800";case"confirmed":return"bg-blue-100 text-blue-800 dark:bg-blue-950/70 dark:text-blue-300 border-blue-300 dark:border-blue-800";
4213case"pending_confirmation":return"bg-amber-100 text-amber-800 dark:bg-amber-950/70 dark:text-amber-300 border-amber-300 dark:border-amber-800";case"planning":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-950/70 dark:text-yellow-300 border-yellow-300 dark:border-yellow-800";case"cancelled":return"bg-red-100 text-red-800 dark:bg-red-950/70 dark:text-red-300 border-red-300 dark:border-red-800";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300 border-gray-300 dark:border-gray-600"}},OG=()=>{const{navigateTo:n,loggedInUser:e,login:t,logout:r}=an(),s=(e==null?void 0:e.role)==="admin",[a,c]=R.useState([]),[u,h]=R.useState([]),[f,p]=R.useState(!0),[y,b]=R.useState(()=>e!=null&&e.email?e.email.trim().toLowerCase():_A()),[w,E]=R.useState((e==null?void 0:e.email)||""),[N,S]=R.useState(""),[I,O]=R.useState(null),[F,J]=R.useState(!1),[z,U]=R.useState(null),[D,k]=R.useState(()=>{const re=eG();return re?(EA(),re):null});R.useEffect(()=>{e!=null&&e.email&&!y&&(b(e.email.trim().toLowerCase()),E(e.email))},[e==null?void 0:e.email,y]),R.useEffect(()=>{const re=CA();re&&re.email&&(Mg(re.email,re.tripCode,re.token),b(re.email),E(re.email),t({id:re.email,name:re.email.split("@")[0],email:re.email,role:"traveler",status:"active"}),Ye(`Signed in via secure direct link for ${re.email}. Active session secured.`),setTimeout(()=>Ye(null),6e3))},[t]);const[_,M]=R.useState(s?"admin":"traveler"),j=!!y&&(!s||_==="traveler"),{remainingSeconds:H,showWarning:L,resetTimer:ee,activePreset:ne,changePreset:G}=jG({enabled:j,onTimeout:()=>{ju(),r(),b(null),k(`For your security, your session auto-locked after ${ne==="15m"?"15 minutes":ne==="2m"?"2 minutes":"30 seconds"} of inactivity. Your personal safari itinerary and booking details remain protected. Please sign in below to continue.`)},warningThresholdSeconds:60}),[W,X]=R.useState(""),[ae,Te]=R.useState("all"),[K,fe]=R.useState("all"),[Se,Ae]=R.useState("newest"),[ze,lt]=R.useState(1),[dt,Wt]=R.useState(10),[Ht,Mr]=R.useState(null),[br,Lr]=R.useState(null),[gt,Ye]=R.useState(null);R.useEffect(()=>{p(!0);let re=!0;const Ne=ge.subscribeToItineraries(De=>{re&&(c(De||[]),p(!1))});return ge.getAllConsultants().then(De=>{re&&h(De||[])}),()=>{re=!1,Ne()}},[]);const In=R.useMemo(()=>u.reduce((re,Ne)=>(re[Ne.id]=Ne.name,re),{}),[u]),Jr=async re=>{re.preventDefault(),O(null);const Ne=w.trim().toLowerCase(),De=N.trim().toUpperCase();if(!Ne){O("Please enter the email address used during booking.");return}if(!De){O("Please enter your Trip Reference Code from your confirmation email.");return}J(!0);try{let qe=a.some(je=>{const st=je.travelerEmail&&je.travelerEmail.trim().toLowerCase()===Ne,bt=je.id&&je.id.trim().toUpperCase()===De;return st&&bt});if(qe||(qe=(await ge.getItinerariesByEmail(Ne)).some(st=>st.id&&st.id.trim().toUpperCase()===De)),qe){Mg(Ne,De),b(Ne);const je=a.find(bt=>bt.travelerEmail&&bt.travelerEmail.trim().toLowerCase()===Ne),st=(je==null?void 0:je.travelerName)||Ne.split("@")[0];
4213t({id:Ne,name:st,email:Ne,role:"traveler",status:"active"}),S(""),O(null),k(null),Ye(`Welcome, ${st}! Signed in to My Trips. Session secured.`),setTimeout(()=>Ye(null),5e3)}else O("Verification failed: No booking was found matching that email and Trip Reference Code. Please check the code in your confirmation email and try again.")}catch(qe){console.warn("Trip verification error:",qe),O("Unable to verify trip code. Please check your network connection.")}finally{J(!1)}},ar=()=>{ju(),r(),b(null),S(""),O(null),Ye("Signed out securely. Session locked and cookies removed."),setTimeout(()=>Ye(null),4e3)},Rs=re=>{navigator.clipboard.writeText(re),U(re),setTimeout(()=>U(null),2500)},Ct=R.useMemo(()=>s&&_==="admin"?a:y?a.filter(re=>re.travelerEmail&&re.travelerEmail.trim().toLowerCase()===y.toLowerCase()):[],[a,s,_,y]),St=R.useMemo(()=>Ct.filter(re=>{const Ne=W.toLowerCase().trim(),De=!Ne||re.id&&re.id.toLowerCase().includes(Ne)||re.title&&re.title.toLowerCase().includes(Ne)||re.travelerName&&re.travelerName.toLowerCase().includes(Ne)||re.travelerEmail&&re.travelerEmail.toLowerCase().includes(Ne),qe=ae==="all"||re.status===ae,je=K==="all"||re.consultantId===K;return De&&qe&&je}).sort((re,Ne)=>Se==="newest"?new Date(Ne.startDate||0).getTime()-new Date(re.startDate||0).getTime():Se==="oldest"?new Date(re.startDate||0).getTime()-new Date(Ne.startDate||0).getTime():Se==="price-desc"?(Ne.totalPrice||0)-(re.totalPrice||0):Se==="price-asc"?(re.totalPrice||0)-(Ne.totalPrice||0):Se==="duration"?(Ne.duration||0)-(re.duration||0):0),[Ct,W,ae,K,Se]);R.useEffect(()=>{lt(1)},[W,ae,K,Se,dt]);const Un=R.useMemo(()=>{const re=(ze-1)*dt;return St.slice(re,re+dt)},[St,ze,dt]),Tr=R.useMemo(()=>{const re=Ct.length,Ne=Ct.filter(je=>je.status==="confirmed"||je.status==="completed").length,De=Ct.filter(je=>je.status==="planning"||je.status==="pending_confirmation").length,qe=Ct.filter(je=>je.status==="confirmed"||je.status==="completed").reduce((je,st)=>je+(st.totalPrice||0),0);return{total:re,confirmed:Ne,planning:De,totalRevenue:qe}},[Ct]),ns=async(re,Ne)=>{if(!s)return;const De={...re,status:Ne};c(qe=>qe.map(je=>je.id===re.id?De:je));try{await ge.updateItinerary(De),Ye(`Updated status for trip ${re.id} to ${Ne.replace("_"," ")}.`)}catch(qe){console.error("Failed to update itinerary status:",qe)}setTimeout(()=>Ye(null),5e3)},yn=async()=>{if(!s||!br)return;const re=br.id;Lr(null),c(Ne=>Ne.filter(De=>De.id!==re));try{await ge.deleteItinerary(re),Ye(`Deleted trip ${re} from Firebase database.`)}catch(Ne){console.error("Failed to delete itinerary:",Ne)}setTimeout(()=>Ye(null),5e3)};if((!s||_==="traveler")&&!y)return o.jsx("div",{className:"max-w-xl mx-auto px-4 py-16",children:o.jsxs(On,{className:"p-8 sm:p-10 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-xl rounded-2xl",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("div",{className:"w-16 h-16 rounded-2xl bg-blue-50 dark:bg-blue-950/60 text-blue-600 dark:text-blue-400 flex items-center justify-center mx-auto mb-4 ring-8 ring-blue-50/50 dark:ring-blue-950/30",children:o.jsx(IB,{className:"w-8 h-8"})}),o.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-gray-900 dark:text-white font-heading tracking-tight",children:"Sign In to My Trips"}),o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 mt-2.5 leading-relaxed",children:"Access your confirmed safari bookings, daily itineraries, and confidential quotes securely. Entering your booking credentials signs you in immediately."})]}),D&&o.jsxs("div",{className:"mb-6 p-4 rounded-xl bg-amber-50 dark:bg-amber-950/40 border border-amber-300 dark:border-amber-800 text-amber-900 dark:text-amber-200 text-xs flex items-start gap-3",children:[o.jsx(IB,{className:"w-5 h-5 text-amber-600 dark:text-amber-400 shrink-0 mt-0.5"}),o.jsxs("div",{children:[o.jsx("p",{className:"font-bold text-sm text-amber-950 dark:text-amber-100 mb-1",children:"Session Auto-Locked for Security"}),o.jsx("p",{className:"leading-relaxed",children:D})]})]}),o.jsxs("div",{className:"mb-6 p-4 rounded-xl bg-blue-50 dark:bg-blue-950/40 border border-blue-200 dark:border-blue-800/60 text-xs text-blue-800 dark:text-blue-300 flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-blue-100 dar
4213k:bg-blue-900/60 text-blue-600 dark:text-blue-400 shrink-0",children:o.jsx(JN,{className:"w-4 h-4"})}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"font-bold text-blue-900 dark:text-blue-200",children:"Received a direct link in your email?"}),o.jsxs("p",{className:"leading-relaxed text-blue-800/90 dark:text-blue-300/90",children:["Clicking the ",o.jsx("strong",{children:"Direct Access Link"})," inside your booking confirmation email signs you in automatically and loads your trips without needing to type your code manually."]})]})]}),o.jsxs("form",{onSubmit:Jr,className:"space-y-5",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300 mb-2",children:"Booking Email Address"}),o.jsxs("div",{className:"relative",children:[o.jsx($g,{className:"w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none"}),o.jsx("input",{type:"email",required:!0,value:w,onChange:re=>E(re.target.value),placeholder:"e.g. [email protected]",className:"w-full pl-10 pr-4 py-2.5 text-sm border rounded-xl border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:outline-none transition-shadow"})]})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("label",{className:"block text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300",children:"Trip Reference Code"}),o.jsx("span",{className:"text-[11px] text-blue-600 dark:text-blue-400 font-medium",children:"Found in confirmation email"})]}),o.jsxs("div",{className:"relative",children:[o.jsx(gy,{className:"w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none"}),o.jsx("input",{type:"text",required:!0,value:N,onChange:re=>S(re.target.value),placeholder:"e.g. ITIN-123456",className:"w-full pl-10 pr-4 py-2.5 text-sm font-mono tracking-wider border rounded-xl border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:outline-none transition-shadow"})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2 leading-normal",children:"Signing in with your email and code unlocks all safaris and itineraries booked under your account."})]}),I&&o.jsxs("div",{className:"p-3.5 bg-red-50 dark:bg-red-950/50 border border-red-200 dark:border-red-800 rounded-xl text-xs text-red-700 dark:text-red-300 flex items-start gap-2.5 animate-fadeIn",children:[o.jsx(uc,{className:"w-4 h-4 shrink-0 mt-0.5 text-red-600 dark:text-red-400"}),o.jsx("span",{className:"leading-relaxed",children:I})]}),o.jsx(He,{type:"submit",disabled:F,className:"w-full py-3 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-xl flex items-center justify-center gap-2 shadow-sm",children:F?o.jsxs(o.Fragment,{children:[o.jsx(At,{}),o.jsx("span",{children:"Signing In..."})]}):o.jsxs(o.Fragment,{children:[o.jsx(IB,{className:"w-4 h-4"}),o.jsx("span",{children:"Sign In to My Trips"})]})})]}),o.jsxs("div",{className:"mt-6 pt-5 border-t border-gray-100 dark:border-gray-700 flex items-center justify-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[o.jsx(xh,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400 shrink-0"}),o.jsx("span",{children:"Encrypted Session with Automatic Inactivity Lock"})]}),s&&o.jsx("div",{className:"mt-4 text-center",children:o.jsx("button",{onClick:()=>M("admin"),className:"text-xs text-gray-500 hover:text-gray-800 dark:hover:text-gray-200 underline",children:"Administrator: Switch back to Platform Admin View"})}),o.jsxs("div",{className:"mt-6 pt-4 border-t border-gray-100 dark:border-gray-700 text-center text-xs text-gray-500 dark:text-gray-400 space-y-2",children:[o.jsxs("p",{children:["Haven't booked an expedition yet?"," ",o.jsx("button",{onClick:()=>n(Le.ItineraryBuilder),className:"text-blue-600 dark:text-blue-400 font-semibold hover:underline",children:"Build Your Safari Itinerary"})]}),o.jsx("p",{className:"text-[11px] text-gray-400 dark:text-gray-500",children:"Need help finding your Trip Reference Code? Check your email confirmation or contact support."})]})]})});const kt=!s||_==="traveler";return o.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 relative",children:[o.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-4 mb-8",children:[o.jsxs("div",{children:[o.jsx("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:kt?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-semibold bg-blue-100 text-blue-800 dark:bg-blue-950/60 dark:text-blue-300 border border-blue-200 dark:border-blue-800",children:[o.jsx(xh,{className:"w-3.5 h-3.5 text-blue-600 dar
4213k:text-blue-400"}),"Signed In: ",o.jsx("span",{className:"font-mono",children:y})]}),o.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium bg-amber-50 dark:bg-amber-950/40 text-amber-900 dark:text-amber-200 border border-amber-200 dark:border-amber-800",title:"Session will auto-lock if left idle to prevent unauthorized access",children:[o.jsx(Si,{className:"w-3.5 h-3.5 text-amber-600 dark:text-amber-400"}),o.jsxs("span",{children:["Auto-lock: ",o.jsxs("strong",{className:"font-mono",children:[Math.floor(H/60),":",(H%60).toString().padStart(2,"0")]})]})]}),o.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-lg text-xs bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300",children:[o.jsx(zP,{className:"w-3 h-3 text-gray-400 mr-0.5"}),o.jsx("span",{className:"text-[11px] text-gray-500 mr-1 hidden sm:inline",children:"Idle Limit:"}),o.jsx("button",{onClick:()=>G("15m"),className:`px-1.5 py-0.5 rounded text-[11px] font-semibold transition-colors ${ne==="15m"?"bg-blue-600 text-white":"hover:text-blue-600 text-gray-600 dark:text-gray-400"}`,title:"OWASP Standard (15 min) - Recommended for reading long itineraries",children:"15m (Standard)"}),o.jsx("button",{onClick:()=>G("2m"),className:`px-1.5 py-0.5 rounded text-[11px] font-semibold transition-colors ${ne==="2m"?"bg-blue-600 text-white":"hover:text-blue-600 text-gray-600 dark:text-gray-400"}`,title:"Public Computer Mode (2 min) - Recommended for shared devices",children:"2m (Public PC)"}),o.jsx("button",{onClick:()=>G("30s"),className:`px-1.5 py-0.5 rounded text-[11px] font-semibold transition-colors ${ne==="30s"?"bg-blue-600 text-white":"hover:text-blue-600 text-gray-600 dark:text-gray-400"}`,title:"Rapid Auto-Lock Test (30 sec) - For testing inactivity auto-lock",children:"30s (Test)"})]}),o.jsxs("button",{onClick:ar,className:"inline-flex items-center gap-1 text-xs text-gray-600 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 px-2.5 py-1 rounded-full border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 transition-colors shadow-xs",title:"Sign out and lock access to your trips",children:[o.jsx(BP,{className:"w-3 h-3"}),o.jsx("span",{children:"Sign Out"})]})]}):o.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-semibold bg-emerald-100 text-emerald-800 dark:bg-emerald-950/60 dark:text-emerald-300 border border-emerald-200 dark:border-emerald-800",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse"}),"Admin View • Firebase Database Sync"]})}),o.jsx("h1",{className:"text-3xl sm:text-4xl font-extrabold text-brand-dark dark:text-white font-heading tracking-tight",children:kt?"My Safari Bookings":"Trip Management"}),o.jsx("p",{className:"text-sm sm:text-base text-gray-600 dark:text-gray-300 mt-1",children:kt?"Review your confirmed itineraries, track planning progress, and access detailed quotes for your safaris.":"Browse, monitor, and update safari bookings and client itineraries stored directly in your cloud database."})]}),o.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s&&o.jsxs("div",{className:"flex rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-1 text-xs font-semibold",children:[o.jsx("button",{onClick:()=>M("admin"),className:`px-3 py-1.5 rounded-md transition-colors ${_==="admin"?"bg-emerald-600 text-white":"text-gray-600 dark:text-gray-300 hover:text-gray-900"}`,children:"All Platform Trips"}),o.jsx("button",{onClick:()=>M("traveler"),className:`px-3 py-1.5 rounded-md transition-colors ${_==="traveler"?"bg-blue-600 text-white":"text-gray-600 dark:text-gray-300 hover:text-gray-900"}`,children:"Traveler Portal"})]}),o.jsxs(He,{onClick:()=>n(Le.ItineraryBuilder),className:"flex items-center gap-2 bg-emerald-600 hover:bg-emerald-700 text-white font-semibold py-2.5 px-4 rounded-lg shadow-sm",children:[o.jsx(AP,{className:"w-4 h-4"}),o.jsx("span",{children:kt?"Plan Another Safari":"Create New Trip"})]})]})]}),gt&&o.jsxs("div",{className:"mb-6 p-4 rounded-lg bg-emerald-50 dark:bg-emerald-950/40 border border-emerald-200 dark:border-emerald-800 text-emerald-800 dark:text-emerald-200 flex items-center justify-between text-sm",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ga,{className:"w-5 h-5 text-emerald-600 dark:text-emerald-400 flex-shrink-0"}),o.jsx("span",{children:gt})]}),o.jsx("button",{onClick:()=>Ye(null),className:"text-xs font-semibold text-emerald-700 dark:text-emerald-300 hover:underline",children:"Dismiss"})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-8",children:[o.jsxs(On,{className:"p-5 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:kt?"My Bookings":"Total Cloud Trips"}),o.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white mt-1",children:Tr.total})]}),o.jsx("div",{className:"p-3 bg-blue-50 dark:bg-blue-950/50 rounded-xl text-blue-600 dar
4213k:text-blue-400",children:o.jsx(nP,{className:"w-5 h-5"})})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:kt?`Linked to ${y}`:"Stored in Firestore itineraries"})]}),o.jsxs(On,{className:"p-5 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Confirmed & Ready"}),o.jsx("p",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400 mt-1",children:Tr.confirmed})]}),o.jsx("div",{className:"p-3 bg-emerald-50 dark:bg-emerald-950/50 rounded-xl text-emerald-600 dark:text-emerald-400",children:o.jsx(Ga,{className:"w-5 h-5"})})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"Finalized expeditions"})]}),o.jsxs(On,{className:"p-5 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"In Review / Planning"}),o.jsx("p",{className:"text-2xl font-bold text-amber-600 dark:text-amber-400 mt-1",children:Tr.planning})]}),o.jsx("div",{className:"p-3 bg-amber-50 dark:bg-amber-950/50 rounded-xl text-amber-600 dark:text-amber-400",children:o.jsx(Si,{className:"w-5 h-5"})})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"Awaiting confirmation"})]}),o.jsxs(On,{className:"p-5 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:kt?"Total Value":"Booked Volume"}),o.jsxs("p",{className:"text-2xl font-bold text-brand-dark dark:text-white mt-1",children:["$",Tr.totalRevenue.toLocaleString()]})]}),o.jsx("div",{className:"p-3 bg-purple-50 dark:bg-purple-950/50 rounded-xl text-purple-600 dark:text-purple-400",children:o.jsx(sg,{className:"w-5 h-5"})})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"Total quoted safari volume"})]})]}),o.jsx(On,{className:"p-4 sm:p-5 mb-6 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm",children:o.jsxs("div",{className:"flex flex-col lg:flex-row gap-3 items-stretch lg:items-center",children:[o.jsxs("div",{className:"relative flex-grow",children:[o.jsx(yh,{className:"w-4 h-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),o.jsx("input",{type:"search",value:W,onChange:re=>X(re.target.value),placeholder:kt?"Search your trips by Reference Code, Title, or Destination...":"Search by Trip ID, Title, Traveler name or email...",className:"w-full pl-9 pr-4 py-2 text-sm border rounded-lg border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-emerald-500 focus:outline-none"})]}),o.jsx("div",{className:"w-full sm:w-auto",children:o.jsxs("select",{value:ae,onChange:re=>Te(re.target.value),className:"w-full sm:w-44 px-3 py-2 text-sm border rounded-lg border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-emerald-500 focus:outline-none",children:[o.jsxs("option",{value:"all",children:["All Statuses (",Ct.length,")"]}),GT.map(re=>o.jsx("option",{value:re,className:"capitalize",children:re.replace("_"," ")},re))]})}),!kt&&o.jsx("div",{className:"w-full sm:w-auto",children:o.jsxs("select",{value:K,onChange:re=>fe(re.target.value),className:"w-full sm:w-48 px-3 py-2 text-sm border rounded-lg border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-emerald-500 focus:outline-none",children:[o.jsx("option",{value:"all",children:"All Consultants"}),u.map(re=>o.jsx("option",{value:re.id,children:re.name},re.id))]})}),o.jsx("div",{className:"w-full sm:w-auto",children:o.jsxs("select",{value:Se,onChange:re=>Ae(re.target.value),className:"w-full sm:w-40 px-3 py-2 text-sm border rounded-lg border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-emerald-500 focus:outline-none",children:[o.jsx("option",{value:"newest",children:"Newest First"}),o.jsx("option",{value:"oldest",children:"Oldest First"}),o.jsx("option",{value:"price-desc",children:"Price: High to Low"}),o.jsx("option",{value:"price-asc",children:"Price: Low to High"}),o.jsx("option",{value:"duration",children:"Duration: Longest"})]})}),(W||ae!=="all"||K!=="all")&&o.jsx("button",{onClick:()=>{X(""),Te("all"),fe("all")},className:"text-xs font-semibold text-gray-500 hover:text-emerald-600 dark:hover:text-emerald-400 underline whitespace-nowrap self-center",children:"Clear filters"})]})}),o.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden",children:f?o.jsxs("div",{className:"py-20 text-center",children:[o.jsx(At,{}),o.jsx("p",{className:"mt-3 text-sm text-gray-500 dark:text-gray-400",children:"Retrieving bookings from Firebase database..."})]}):St.length>0?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"overflow-x-auto",children:o.jsxs("table",{className:"w-full text-sm text-left",children:[o.jsx("thead",{className:"text-xs text-gray-600 dark:text-gray-300 uppercase bg-gray-50 dark:bg-gray-750/70 border-b border-gray-200 dark:border-gray-700",children:o.jsxs("tr",{children:[o.jsx("th",{scope:"col",className:"px-6 py-3.5 font-semibold",children:"Trip Details & Code"}),!kt&&o.jsx("th",{scope:"col",className:"px-6 py-3.5 font-semibold",children:"Traveler"}),o.jsx("th",{scope:"col",className:"px-6 py-3.5 font-semibold",children:"Safari Specialist"}),o.jsx("th",{scope:"col",className:"px-6 py-3.5 font-semibold",children:"Start Date"}),o.jsx("th",{scope:"col",className:"px-6 py-3.5 font-semibold",children:"Total Price"}),o.jsx("th",{scope:"col",className:"px-6 py-3.5 font-semibold",children:"Status"}),o.jsx("th",{scope:"col",className:"px-6 py-3.5 text-right font-semibold",children:"Actions"})]})}),o.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:Un.map(re=>{const Ne=In[re.consultantId]||"Direct Safari Specialist";return o.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-750/50 transition-colors",children:[o.jsx("td",{className:"px-6 py-4",children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"font-bold text-gray-900 dark:text-white text-base",children:re.title||"Custom Uganda Safari"}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[o.jsxs("span",{className:"font-mono text-xs font-semibold text-blue-700 dark:text-blue-400 bg-blue-50 dark:bg-blue-950/50 px-2 py-0.5 rounded border border-blue-200 dark:border-blue-800/80 inline-flex items-center gap-1",children:[o.jsx("span",{children:re.id}),o.jsx("button",{type:"button",onClick:()=>Rs(re.id),className:"text-gray-400 hover:text-blue-600 transition-colors ml-0.5",title:"Copy Trip Reference Code",children:z===re.id?o.jsx(Jg,{className:"w-3 h-3 text-emerald-600"}):o.jsx($N,{className:"w-3 h-3"})})]}),o.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:re.duration?`${re.duration+1} days / ${re.duration} nights`:"Custom duration"}),o.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:["• ",re.travelerCount," ",re.travelerCount===1?"traveler":"travelers"]})]}),re.startLocation&&re.endLocation&&o.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400 mt-0.5 flex items-center gap-1",children:[o.jsx(jh,{className:"w-3 h-3 text-gray-400 shrink-0"}),re.startLocation," → ",re.endLocation]})]})}),!kt&&o.jsx("td",{className:"px-6 py-4",children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:re.travelerName||"Anonymous Traveler"}),o.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:re.travelerEmail||"No email provided"})]})}),o.jsx("td",{className:"px-6 py-4",children:o.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-gray-800 dark:text-gray-200 bg-gray-100 dark:bg-gray-700 px-2.5 py-1 rounded-md",children:[o.jsx(rS,{className:"w-3 h-3 text-gray-500 dark:text-gray-400"}),Ne]})}),o.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-gray-800 dark:text-gray-200 font-medium",children:re.startDate?new Date(re.startDate).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):o.jsx("span",{className:"text-gray-400 dark:text-gray-500 italic",children:"Unscheduled"})}),o.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[o.jsxs("span",{className:"font-bold text-gray-900 dark:text-white text-base",children:["$",(re.totalPrice||0).toLocaleStr
4213ing()]}),o.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 block",children:"USD"})]}),o.jsx("td",{className:"px-6 py-4",children:!kt&&s?o.jsx("select",{value:re.status,onChange:De=>ns(re,De.target.value),className:`text-xs font-bold rounded-full px-3 py-1.5 border capitalize focus:outline-none focus:ring-2 focus:ring-emerald-500 ${HT(re.status)}`,children:GT.map(De=>o.jsx("option",{value:De,children:De.replace("_"," ")},De))}):o.jsx("span",{className:`text-xs font-bold rounded-full px-3 py-1 border capitalize inline-block ${HT(re.status)}`,children:re.status.replace("_"," ")})}),o.jsx("td",{className:"px-6 py-4 text-right whitespace-nowrap",children:o.jsxs("div",{className:"flex items-center justify-end gap-2",children:[o.jsxs("button",{onClick:()=>Mr(re),className:"inline-flex items-center gap-1.5 text-xs font-semibold px-3 py-1.5 rounded-lg bg-blue-50 dark:bg-blue-950/60 text-blue-600 dark:text-blue-300 hover:bg-blue-100 dark:hover:bg-blue-900 transition-colors",title:"View Full Itinerary, Lodges & Stored Quote",children:[o.jsx(Vm,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"View Details & Quote"})]}),!kt&&s&&o.jsxs("button",{onClick:()=>Lr(re),className:"inline-flex items-center gap-1 text-xs font-semibold px-2.5 py-1.5 rounded-md text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-950/50 transition-colors",title:"Delete from Firebase Database",children:[o.jsx(Kg,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"Delete"})]})]})})]},re.id)})})]})}),o.jsx(NC,{currentPage:ze,totalItems:St.length,pageSize:dt,onPageChange:lt,onPageSizeChange:Wt,itemLabel:"trips"})]}):o.jsxs("div",{className:"py-20 text-center px-4",children:[o.jsx("div",{className:"w-16 h-16 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center mx-auto mb-4 text-gray-400",children:o.jsx(sg,{className:"w-8 h-8"})}),o.jsx("h3",{className:"text-xl font-bold text-gray-900 dark:text-white font-heading",children:kt?"No Safaris Found Under This Account":"No Trips Found in Database"}),o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-md mx-auto mt-2",children:kt?`No bookings match your search under ${y}. If you used a different email when submitting your trip, exit and verify with that email address.`:"No trips matched your search or filter criteria. Try clearing filters to see all database entries."}),o.jsxs("div",{className:"mt-6 flex justify-center gap-3",children:[(W||ae!=="all"||K!=="all")&&o.jsx(He,{variant:"secondary",onClick:()=>{X(""),Te("all"),fe("all")},children:"Clear Filters"}),kt?o.jsx(He,{onClick:ar,variant:"secondary",children:"Look Up Another Email"}):null,o.jsx(He,{onClick:()=>n(Le.ItineraryBuilder),className:"bg-emerald-600 hover:bg-emerald-700 text-white",children:"Create New Safari Itinerary"})]})]})}),Ht&&o.jsx(SC,{itinerary:Ht,consultantName:In[Ht.consultantId]||"Specialist",isReadOnly:kt,onClose:()=>Mr(null),onSave:async re=>{s&&(Mr(null),c(Ne=>Ne.map(De=>De.id===re.id?re:De)),await ge.updateItinerary(re),Ye(`Saved updates for trip ${re.id}.`),setTimeout(()=>Ye(null),5e3))}}),br&&s&&o.jsx(DA,{isOpen:!0,onClose:()=>Lr(null),onConfirm:yn,title:"Delete Trip from Database?",confirmText:"Yes, Delete Permanently",children:o.jsxs("div",{className:"space-y-3",children:[o.jsxs("p",{children:["Are you sure you want to permanently delete trip"," ",o.jsx("strong",{className:"font-mono text-gray-900 dark:text-white",children:br.id})," (",o.jsx("em",{children:br.title}),")?"]}),o.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 font-semibold",children:"This action will remove the itinerary record from the Firebase Firestore database immediately."})]})}),L&&kt&&o.jsxs("div",{role:"alert",className:"fixed bottom-6 right-6 z-50 max-w-sm sm:max-w-md bg-amber-600 text-white p-4 rounded-2xl shadow-2xl border border-amber-500 flex items-center justify-between gap-4 animate-bounce-subtle",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx(Si,{className:"w-6 h-6 shrink-0 animate-pulse text-amber-100"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm font-bold truncate",children:"Session Auto-Lock Warning"}),o.jsxs("p",{className:"text-xs text-amber-100",children:["Inactivity detected. Locking in ",o.jsxs("span",{className:"font-mono font-bold text-white",children:[H,"s"]})," to keep your data secure."]})]})]}),o.jsx("button",{onClick:ee,className:"shrink-0 px-3.5 py-2 bg-white text-amber-950 font-bold text-xs rounded-xl shadow hover:bg-amber-50 transition-colors focus:ring-2 focus:ring-amber-300",children:"Stay Logged In"})]})]})},FG=["Wildlife Encounters","Gorilla Trekking","Travel Tips","Culture & Community","Photography","Safari Circuits","Lodge Experiences"],AA=({isOpen:n,onClose:e,onSubmit:t,currentUser:r,initialStory:s})=>{var G;const{state:{destinations:a,lodges:c}}=an(),u=r.role==="admin"||r.email==="[email protected]",[h,f]=R.useState((s==null?void 0:s.title)||""),[p,y]=R.use
4213State((s==null?void 0:s.summary)||""),[b,w]=R.useState((s==null?void 0:s.content)||""),[E,N]=R.useState((s==null?void 0:s.category)||"Wildlife Encounters"),[S,I]=R.useState((s==null?void 0:s.destinationId)||""),[O,F]=R.useState((s==null?void 0:s.coverImageUrl)||"https://images.unsplash.com/photo-1516426122078-c23e76319801?auto=format&fit=crop&w=1200&q=80"),[J,z]=R.useState(((G=s==null?void 0:s.tags)==null?void 0:G.join(", "))||"Uganda, Safari, Wildlife"),[U,D]=R.useState((s==null?void 0:s.status)||(u?"published":"pending")),[k,_]=R.useState((s==null?void 0:s.featured)||!1),[M,j]=R.useState(!1),[H,L]=R.useState(null),ee=R.useMemo(()=>{const W=b.trim().split(/\s+/).filter(Boolean).length;return`${Math.max(1,Math.ceil(W/180))} min read`},[b]);if(!n)return null;const ne=async W=>{if(W.preventDefault(),!h.trim()){L("Please enter a descriptive story title.");return}if(!p.trim()){L("Please provide a brief story summary / teaser.");return}if(!b.trim()){L("Please write your story content.");return}L(null),j(!0);try{const X=a.find(K=>K.id===S),ae=J.split(",").map(K=>K.trim()).filter(Boolean),Te={title:h.trim(),summary:p.trim(),content:b.trim(),category:E,destinationId:S||void 0,destinationName:X?X.name:void 0,coverImageUrl:O.trim(),tags:ae.length>0?ae:["Safari","Uganda"],readTime:ee,status:u?U:U==="draft"?"draft":"pending",featured:u?k:!1};await t(Te),e()}catch(X){L((X==null?void 0:X.message)||"Failed to submit story. Please try again.")}finally{j(!1)}};return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm overflow-y-auto",children:o.jsxs("div",{className:"relative w-full max-w-3xl my-8 bg-white dark:bg-gray-850 rounded-2xl shadow-2xl border border-gray-200 dark:border-gray-750 overflow-hidden text-left animate-in fade-in zoom-in-95 duration-200",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"px-6 py-5 bg-gradient-to-r from-blue-700 to-indigo-800 text-white flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2 bg-white/10 rounded-xl backdrop-blur-sm",children:o.jsx(KN,{className:"w-6 h-6 text-yellow-300"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-xl font-bold font-heading",children:s?"Edit Safari Story":"Share Your Safari Story"}),o.jsx("p",{className:"text-xs text-blue-100 mt-0.5",children:u?"Admin Editorial Publisher — Publish directly or review traveler submissions":"Author your Uganda expedition journal for review by our editorial team"})]})]}),o.jsx("button",{onClick:e,className:"p-1.5 text-white/80 hover:text-white rounded-lg hover:bg-white/10 transition-colors","aria-label":"Close modal",children:o.jsx(bc,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:ne,className:"p-6 space-y-6 max-h-[75vh] overflow-y-auto",children:[!u&&o.jsxs("div",{className:"p-4 rounded-xl bg-blue-50 dark:bg-blue-950/40 border border-blue-200 dark:border-blue-900 text-blue-800 dark:text-blue-300 text-xs leading-relaxed flex items-start gap-3",children:[o.jsx(dc,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0"}),o.jsxs("div",{children:[o.jsx("span",{className:"font-bold",children:"Editorial Review Workflow:"})," As a registered traveler or guide, when you submit your story, it will be placed in the"," ",o.jsx("span",{className:"font-semibold underline",children:"Editorial Review Queue"}),". An administrator will review and approve it for public publishing."]})]}),H&&o.jsxs("div",{className:"p-3 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-800 rounded-lg text-red-700 dark:text-red-300 text-sm flex items-center gap-2",children:[o.jsx(uc,{className:"w-4 h-4 flex-shrink-0"}),o.jsx("span",{children:H})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm font-bold text-gray-800 dark:text-gray-200 mb-1.5",children:["Story Title ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"text",required:!0,value:h,onChange:W=>f(W.target.value),placeholder:"e.g. Eye to Eye with the Mukiza Silverback in Eastern Bwindi",className:"w-full px-4 py-2.5 rounded-xl border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-brand-dark dark:text-white text-base focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-all"})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm font-semibold text-gray-800 dark:text-gray-200 mb-1.5 flex items-center gap-1.5",children:[o.jsx(tS,{className:"w-3.5 h-3.5 text-blue-500"}),"Category ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("select",{value:E,onChange:W=>N(W.target.value),className:"w-full px-3.5 py-2.5 rounded-xl border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-brand-dark dark:text-white text-sm focus:ring-2 focus:ring-blue-500 outline-none",children:FG.map(W=>o.jsx("option",{value:W,children:W},W))})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm font-semibold text-gray-800 dark:text-gray-200 mb-1.5 flex items-center gap-1.5",children:[o.jsx(jh,{className:"w-3.5 h-3.5 text-emerald-500"}),"Featured Park / Destination (Optional)"]}),o.jsxs("select",{value:S,onChange:W=>I(W.target.value),className:"w-full px-3.5 py-2.5 rounded-xl border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-brand-dark dark:text-white text-sm focus:ring-2 focus:ring-blue-500 outline-none",children:[o.jsx("option",{value:"",children:"General Uganda Safari (No single park)"}),a.map(W=>o.jsxs("option",{value:W.id,children:[W.name," (",W.shortCode||"Park",")"]},W.id))]})]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm font-semibold text-gray-800 dark:text-gray-200 mb-1.5",children:["Short Summary / Teaser ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("textarea",{required:!0,rows:2,value:p,onChange:W=>y(W.target.value),placeholder:"A brief 1-2 sentence hook summarizing the adventure or advice...",className:"w-full px-4 py-2.5 rounded-xl border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-brand-dark dark:text-white text-sm focus:ring-2 focus:ring-blue-500 outline-none"})]}),o.jsx("div",{children:o.jsx(Qa,{id:"story-cover-image",label:"Cover Image",value:O,onChange:W=>
4213F(W),folder:"stories",aspectRatio:"wide",helperText:"Upload a vibrant landscape photo or paste an image URL. Recommended ratio 16:9.",required:!0})}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[o.jsxs("label",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:["Story Narrative & Details ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[o.jsx(Si,{className:"w-3.5 h-3.5 text-blue-500"}),o.jsxs("span",{children:["Estimated reading time: ",o.jsx("strong",{children:ee})]})]})]}),o.jsx("textarea",{required:!0,rows:9,value:b,onChange:W=>w(W.target.value),placeholder:"Write your safari experience here... Separate paragraphs with double newlines. You can include section headings using '### Heading', bullet points using '- item', or practical advice for fellow travelers.",className:"w-full px-4 py-3 rounded-xl border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-brand-dark dark:text-white text-sm leading-relaxed font-sans focus:ring-2 focus:ring-blue-500 outline-none"}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Supports markdown headers (###), bulleted lists (-), bold text (**bold**), and natural paragraph spacing."})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-semibold text-gray-800 dark:text-gray-200 mb-1.5",children:"Tags (comma-separated)"}),o.jsx("input",{type:"text",value:J,onChange:W=>z(W.target.value),placeholder:"e.g. Mountain Gorillas, Bwindi, Photography, Packing Tips",className:"w-full px-4 py-2 rounded-xl border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-brand-dark dark:text-white text-sm focus:ring-2 focus:ring-blue-500 outline-none"})]}),u&&o.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 space-y-3",children:[o.jsx("h4",{className:"text-xs font-bold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:"Administrator Publishing Controls"}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 items-center",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-semibold text-gray-700 dark:text-gray-300 mb-1",children:"Publication Status"}),o.jsxs("select",{value:U,onChange:W=>D(W.target.value),className:"w-full px-3 py-1.5 rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-750 text-brand-dark dark:text-white text-sm focus:ring-2 focus:ring-blue-500 outline-none",children:[o.jsx("option",{value:"published",children:"Published (Visible to all)"}),o.jsx("option",{value:"pending",children:"Pending Review"}),o.jsx("option",{value:"draft",children:"Draft"}),o.jsx("option",{value:"rejected",children:"Rejected"})]})]}),o.jsx("div",{className:"flex items-center pt-4",children:o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm font-medium text-gray-700 dark:text-gray-300",children:[o.jsx("input",{type:"checkbox",checked:k,onChange:W=>_(W.target.checked),className:"w-4 h-4 text-blue-600 rounded focus:ring-blue-500"}),o.jsx("span",{children:"Feature on top hero spotlight"})]})})]})]}),o.jsx("div",{className:"flex items-center justify-between pt-2 text-xs text-gray-500 dark:text-gray-400 border-t border-gray-100 dark:border-gray-800",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("img",{src:r.imageUrl||`https://ui-avatars.com/api/?name=${encodeURIComponent(r.name)}&background=2563eb&color=fff`,alt:r.name,className:"w-6 h-6 rounded-full object-cover"}),o.jsxs("span",{children:["Publishing as: ",o.jsx("strong",{className:"text-gray-700 dark:text-gray-300",children:r.name})," (",r.role,")"]})]})}),o.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-gray-200 dark:border-gray-800",children:[o.jsx("button",{type:"button",onClick:e,disabled:M,className:"px-5 py-2.5 rounded-xl text-sm font-medium text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",children:"Cancel"}),o.jsx(He,{type:"submit",disabled:M,className:"flex items-center gap-2",children:M?o.jsx("span",{children:"Submitting..."}):o.jsxs(o.Fragment,{children:[o.jsx(ZN,{className:"w-4 h-4"}),o.jsx("span",{children:u&&U==="published"?"Publish Story Now":"Submit for Review"})]})})]})]})]})})},IA=({story:n,isOpen:e,onClose:t,currentUser:r,onLike:s,onApprove:a,onReject:c,onDelete:u,onEdit:h})=>{var _;const{startItinerary:f}
4213=an(),[p,y]=R.useState(!1),[b,w]=R.useState(!1),[E,N]=R.useState(""),[S,I]=R.useState(!1);if(!e||!n)return null;const O=(r==null?void 0:r.role)==="admin"||(r==null?void 0:r.email)==="[email protected]",F=(r==null?void 0:r.id)===n.authorId,J=()=>{var M;(M=navigator.clipboard)==null||M.writeText(window.location.href),y(!0),setTimeout(()=>y(!1),2500)},z=async()=>{if(a){I(!0);try{await a(n.id,n.featured)}finally{I(!1)}}},U=async()=>{if(c){I(!0);try{await c(n.id,E||"Content does not meet publication guidelines"),w(!1)}finally{I(!1)}}},D=async()=>{if(u&&window.confirm("Are you sure you want to permanently delete this story?")){I(!0);try{await u(n.id),t()}finally{I(!1)}}},k=M=>{const j=M.split(`
4214`),H=[];let L=[];const ee=ne=>{L.length>0&&(H.push(o.jsx("ul",{className:"list-disc list-inside space-y-2 my-4 text-gray-700 dark:text-gray-300 pl-2",children:L.map((G,W)=>o.jsx("li",{className:"leading-relaxed",children:G},W))},ne)),L=[])};return j.forEach((ne,G)=>{const W=ne.trim();if(W.startsWith("- ")||W.startsWith("* ")){L.push(W.substring(2));return}ee(`list-${G}`),W.startsWith("### ")?H.push(o.jsx("h3",{className:"text-2xl font-bold font-heading text-brand-dark dark:text-white mt-8 mb-3",children:W.replace("### ","")},G)):W.startsWith("## ")?H.push(o.jsx("h2",{className:"text-3xl font-bold font-heading text-brand-dark dark:text-white mt-10 mb-4 pb-2 border-b border-gray-200 dark:border-gray-800",children:W.replace("## ","")},G)):W.length>0&&H.push(o.jsx("p",{className:"text-base md:text-lg leading-relaxed text-gray-700 dark:text-gray-300 my-4",children:W},G))}),ee("list-end"),H};return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-6 bg-black/70 backdrop-blur-md overflow-y-auto",children:o.jsxs("div",{className:"relative w-full max-w-4xl bg-white dark:bg-gray-850 rounded-2xl shadow-2xl border border-gray-200 dark:border-gray-750 overflow-hidden text-left my-8 animate-in fade-in zoom-in-95 duration-200",role:"dialog","aria-modal":"true",children:[o.jsx("button",{onClick:t,className:"absolute top-4 right-4 z-20 p-2.5 bg-black/60 hover:bg-black/80 text-white rounded-full backdrop-blur-md shadow-lg transition-transform hover:scale-105","aria-label":"Close story",children:o.jsx(bc,{className:"w-5 h-5"})}),o.jsxs("div",{className:"relative w-full aspect-[21/9] sm:aspect-[16/7] overflow-hidden bg-gray-950",children:[o.jsx("img",{src:n.coverImageUrl,alt:n.title,className:"w-full h-full object-cover"}),o.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/30 to-transparent"}),o.jsxs("div",{className:"absolute bottom-6 left-6 right-6 flex flex-wrap items-center justify-between gap-3 text-white",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("span",{className:"px-3 py-1 text-xs font-bold uppercase tracking-wider rounded-full bg-blue-600 text-white shadow-sm",children:n.category}),n.featured&&o.jsxs("span",{className:"px-3 py-1 text-xs font-bold uppercase tracking-wider rounded-full bg-amber-500 text-brand-dark shadow-sm flex items-center gap-1",children:[o.jsx(dc,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"Featured"})]}),n.status!=="published"&&o.jsxs("span",{className:`px-3 py-1 text-xs font-bold uppercase tracking-wider rounded-full shadow-sm ${n.status==="pending"?"bg-yellow-500 text-gray-950":n.status==="rejected"?"bg-red-500 text-white":"bg-gray-500 text-white"}`,children:["Status: ",n.status]})]}),o.jsxs("div",{className:"flex items-center gap-4 text-xs font-medium text-white/90",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(Si,{className:"w-4 h-4 text-blue-300"}),o.jsx("span",{children:n.readTime})]}),n.publishedAt&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(DR,{className:"w-4 h-4 text-blue-300"}),o.jsx("span",{children:new Date(n.publishedAt).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})})]})]})]})]}),(O||F)&&o.jsxs("div",{className:"px-6 py-3 bg-gray-100 dark:bg-gray-900/90 border-b border-gray-200 dark:border-gray-750 flex flex-wrap items-center justify-between gap-3 text-xs",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xh,{className:"w-4 h-4 text-blue-600 dar
4214k:text-blue-400"}),o.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-300",children:O?"Admin Moderation Controls":"Author Management"}),o.jsx("span",{className:`px-2 py-0.5 rounded font-bold uppercase text-[10px] ${n.status==="published"?"bg-green-100 text-green-800 dark:bg-green-900/50 dark:text-green-300":n.status==="pending"?"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-300":"bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-300"}`,children:n.status})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[O&&n.status!=="published"&&o.jsxs("button",{disabled:S,onClick:z,className:"px-3 py-1.5 bg-green-600 hover:bg-green-700 text-white rounded-lg font-semibold flex items-center gap-1.5 transition-colors",children:[o.jsx(Ga,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"Approve & Publish"})]}),O&&n.status==="pending"&&!b&&o.jsxs("button",{disabled:S,onClick:()=>w(!0),className:"px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white rounded-lg font-semibold flex items-center gap-1.5 transition-colors",children:[o.jsx(nS,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"Reject / Request Changes"})]}),h&&(O||F)&&o.jsxs("button",{disabled:S,onClick:()=>{t(),h(n)},className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-semibold flex items-center gap-1.5 transition-colors",children:[o.jsx(_P,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"Edit"})]}),u&&(O||F)&&o.jsx("button",{disabled:S,onClick:D,className:"p-1.5 text-gray-500 hover:text-red-600 dark:hover:text-red-400 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",title:"Delete Story",children:o.jsx(Kg,{className:"w-4 h-4"})})]})]}),b&&o.jsxs("div",{className:"p-4 bg-red-50 dark:bg-red-950/40 border-b border-red-200 dark:border-red-800 text-xs",children:[o.jsx("p",{className:"font-bold text-red-800 dark:text-red-300 mb-2",children:"Provide feedback or reason for rejecting this story:"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"text",value:E,onChange:M=>N(M.target.value),placeholder:"e.g. Please add more details regarding road conditions and permit guidelines...",className:"flex-grow px-3 py-1.5 rounded-lg border border-red-300 dark:border-red-700 bg-white dark:bg-gray-800 text-sm"}),o.jsx("button",{onClick:U,disabled:S,className:"px-4 py-1.5 bg-red-600 hover:bg-red-700 text-white font-bold rounded-lg",children:"Confirm Rejection"}),o.jsx("button",{onClick:()=>w(!1),className:"px-3 py-1.5 bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-lg",children:"Cancel"})]})]}),o.jsxs("div",{className:"p-6 md:p-10 max-h-[68vh] overflow-y-auto",children:[o.jsxs("div",{className:"mb-8",children:[o.jsx("h1",{className:"text-3xl md:text-5xl font-extrabold font-heading text-brand-dark dark:text-white leading-tight mb-4",children:n.title}),o.jsx("p",{className:"text-lg md:text-xl text-gray-600 dark:text-gray-300 leading-relaxed font-sans",children:n.summary}),o.jsxs("div",{className:"mt-6 pt-6 border-t border-gray-100 dark:border-gray-800 flex flex-wrap items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("img",{src:n.authorAvatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(n.authorName)}&background=2563eb&color=fff`,alt:n.authorName,className:"w-12 h-12 rounded-full object-cover border-2 border-blue-500/30"}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-base font-bold text-brand-dark dark:text-white",children:n.authorName}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:n.authorRole||"Uganda Safari Contributor"})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("button",{onClick:()=>s(n.id),className:"px-4 py-2 rounded-full bg-red-50 dark:bg-red-950/30 text-red-600 dark:text-red-400 hover:bg-red-100 dark:hover:bg-red-900/50 text-sm font-semibold flex items-center gap-2 transition-colors border border-red-200/50 dark:border-red-900/40","aria-label":"Like story",children:[o.jsx(QN,{className:"w-4 h-4 fill-current"}),o.jsx("span",{children:n.likesCount||0})]}),o.jsx("button",{onClick:J,className:"px-4 py-2 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 text-sm font-semibold flex items-center gap-2 transition-colors","aria-label":"Share story",children:p?o.jsxs(o.Fragment,{children:[o.jsx(Jg,{className:"w-4 h-4 text-green-500"}),o.jsx("span",{children:"Copied!"})]}):o.jsxs(o.Fragment,{children:[o.jsx(FP,{className:"w-4 h-4"}),o.jsx("span",{children:"Share"})]})})]})]})]}),o.jsx("article",{className:"prose dark:prose-invert max-w-none text-brand-dark dark:text-gray-200",children:k(n.content)}),n.destinationId&&o.jsxs("div",{className:"mt-12 p-6 rounded-2xl bg-gradient-to-br from-blue-50 to-indigo-50 dark:from-gray-800 dark:to-gray-850 border border-blue-100 dar
4214k:border-gray-700 flex flex-col sm:flex-row items-center justify-between gap-6 shadow-sm",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-blue-700 dark:text-blue-400 mb-1",children:[o.jsx(jh,{className:"w-4 h-4"}),o.jsx("span",{children:"Featured Safari Destination"})]}),o.jsxs("h4",{className:"text-xl font-bold text-brand-dark dark:text-white font-heading",children:["Inspired to visit ",n.destinationName||"this park","?"]}),o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 mt-1 max-w-xl",children:"Add this national park directly to your custom safari plan, estimate lodging costs, and connect with local gorilla trekking experts."})]}),o.jsxs(He,{onClick:()=>{t(),f(n.destinationId)},className:"whitespace-nowrap flex items-center gap-2 shadow-md hover:scale-105 transition-transform",children:[o.jsx(sg,{className:"w-4 h-4"}),o.jsxs("span",{children:["Plan Safari to ",((_=n.destinationName)==null?void 0:_.split(" ")[0])||"Park"]})]})]}),n.tags&&n.tags.length>0&&o.jsxs("div",{className:"mt-8 pt-6 border-t border-gray-100 dark:border-gray-800 flex flex-wrap items-center gap-2",children:[o.jsxs("span",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mr-2 flex items-center gap-1",children:[o.jsx(tS,{className:"w-3.5 h-3.5"}),"Tags:"]}),n.tags.map(M=>o.jsxs("span",{className:"px-3 py-1 rounded-full text-xs font-medium bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",children:["#",M]},M))]})]})]})})},Da=({columns:n,data:e,actions:t,title:r,onAddItem:s,addItemLabel:a="+ Add New",headerContent:c,pagination:u=!1})=>{const h=typeof u=="object"&&u.pageSize?u.pageSize:10,f=typeof u=="object"&&u.showPageSizeOptions!==!1,[p,y]=R.useState(1),[b,w]=R.useState(h),E=Math.ceil(e.length/b)||1;R.useEffect(()=>{p>E&&y(1)},[E,p]);const N=R.useMemo(()=>{if(!u)return e;const O=(p-1)*b;return e.slice(O,O+b)},[e,u,p,b]),S=(p-1)*b,I=Math.min(S+b,e.length);return o.jsxs("div",{className:"bg-white dark:bg-gray-850 p-6 rounded-xl shadow-md border border-gray-200 dark:border-gray-750",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-4",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:r}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3 w-full sm:w-auto justify-start sm:justify-end",children:[c,s&&o.jsx(He,{onClick:s,className:"text-sm !py-2 !px-4 whitespace-nowrap shadow-sm",children:a})]})]}),o.jsx("div",{className:"overflow-x-auto",children:o.jsxs("table",{className:"w-full text-sm text-left text-gray-500 dark:text-gray-400",children:[o.jsx("thead",{className:"text-xs text-gray-700 dark:text-gray-300 uppercase bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-750",children:o.jsxs("tr",{children:[n.map((O,F)=>o.jsx("th",{scope:"col",className:"px-6 py-3",children:O.header},F)),t&&t.length>0&&o.jsx("th",{scope:"col",className:"px-6 py-3 text-right",children:"Actions"})]})}),o.jsxs("tbody",{children:[N.map(O=>o.jsxs("tr",{className:"bg-white dark:bg-gray-850 border-b border-gray-100 dark:border-gray-750 hover:bg-gray-50 dark:hover:bg-gray-800/60 transition-colors",children:[n.map((F,J)=>o.jsx("td",{className:"px-6 py-4 text-gray-700 dark:text-gray-300",children:typeof F.accessor=="function"?F.accessor(O):O[F.accessor]},J)),t&&t.length>0&&o.jsx("td",{className:"px-6 py-4 space-x-4 whitespace-nowrap text-right",children:t.map((F,J)=>o.jsx("button",{onClick:()=>F.onClick(O),className:`font-medium text-blue-600 dark:text-blue-400 hover:underline ${F.className||""}`,children:F.label},J))})]},O.id)),e.length===0&&o.jsx("tr",{children:o.jsx("td",{colSpan:n.length+(t?1:0),className:"text-center py-10 text-gray-500 dark:text-gray-400",children:"No data available."})})]})]})}),u&&e.length>0&&o.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 pt-4 mt-2 border-t border-gray-100 dark:border-gray-800 text-xs text-gray-600 dark:text-gray-400",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("span",{children:["Showing ",o.jsx("strong",{className:"text-gray-900 dark:text-white",children:S+1})," to ",o.jsx("strong",{className:"text-gray-900 dark:text-white",children:I})," of ",o.jsx("strong",{className:"text-gray-900 dark:text-white",children:e.length})," entries"]}),f&&o.jsxs("div",{className:"flex items-center gap-1.5 ml-2 pl-3 border-l border-gray-200 dark:border-gray-700",children:[o.jsx("span",{children:"Per page:"}),o.jsxs("select",{value:b,onChange:O=>{w(Number(O.target.value)),y(1)},className:"px-2 py-1 border border-gray-300 dark:border-gray-700 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-xs focus:ring-1 focus:ring-emerald-500",children:[o.jsx("option",{value:5,children:"5"}),o.jsx("option",{value:10,children:"10"}),o.jsx("option",{value:15,children:"15"}),o.jsx("option",{value:25,children:"25"}),o.jsx("option",{value:50,children:"50"})]})]})]}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("button",{onClick:()=>y(O=>Math.max(1,O-1)),disabled:p===1,className:"p-1.5 rounded-lg border border-gray-300 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-gray-700 dark:text-gray-300",title:"Previous Page",children:o.jsx(zN,{className:"w-4 h-4"})}),o.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:E},(O,F)=>F+1).filter(O=>O===1||O===E||Math.abs(O-p)<=1).map((O,F,J)=>{const z=J[F-1],U=z&&O-z>1;return o.jsxs(cc.Fragment,{children:[U&&o.jsx("span",{className:"px-1 text-gray-400",children:"..."}),o.jsx("button",{onClick:()=>y(O),className:`min-w-7 h-7 px-2 text-xs font-semibold rounded-lg transition-colors ${p===O?"bg-emerald-600 text-white shadow-sm":"border border-gray-300 dark:border-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:O})]},O)})}),o.jsx("button",{onClick:()=>y(O=>Math.min(E,O+1)),disabled:p===E,className:"p-1.5 rounded-lg border border-gray-300 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-gray-700 dark:text-gray-300",title:"Next Page",children:o.jsx(ax,{className:"w-4 h-4"})})]})]})]})},RA=({id:n,label:e,values:t=[],onChange:r,maxImages:s=4,folder:a="uploads",aspectRatio:c="auto",helperText:u,required:h=!1})=>{const[f,p]=R.useState("upload"),[y,b]=R.useState(""),[w,E]=R.use
4214State(!1),[N,S]=R.useState(null),[I,O]=R.useState(!1),[F,J]=R.useState(!1),z=R.useRef(null),U=t.length<s,D=ne=>{ne.preventDefault(),U&&J(!0)},k=ne=>{ne.preventDefault(),J(!1)},_=async ne=>{ne.preventDefault(),J(!1),U&&ne.dataTransfer.files&&ne.dataTransfer.files.length>0&&await j(ne.dataTransfer.files)},M=async ne=>{ne.target.files&&ne.target.files.length>0&&await j(ne.target.files)},j=async ne=>{S(null),O(!1);const G=Array.from(ne).slice(0,s-t.length);if(G.length!==0){E(!0);try{const W=[];for(const X of G){if(X.size>5*1024*1024)throw new Error(`File ${X.name} is too large (max 5MB)`);if(!X.type.startsWith("image/"))throw new Error(`File ${X.name} is not an image`);const ae=await NA(X,a);W.push(ae)}r([...t,...W]),O(!0),setTimeout(()=>O(!1),3e3),z.current&&(z.current.value="")}catch(W){console.error("Upload failed:",W),S(W.message||"Failed to upload image(s).")}finally{E(!1)}}},H=()=>{y.trim()&&(r([...t,y.trim()]),b(""))},L=ne=>{const G=[...t];G.splice(ne,1),r(G)},ee=c==="square"?"aspect-square max-w-[200px]":c==="wide"?"aspect-video max-w-full":"max-h-48";return o.jsxs("div",{id:`${n}-container`,className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300",children:[e," (",t.length,"/",s,") ",h&&o.jsx("span",{className:"text-red-500",children:"*"})]}),U&&o.jsxs("div",{className:"flex bg-gray-100 dark:bg-gray-700/60 p-0.5 rounded-md border border-gray-200 dark:border-gray-600 text-xs",children:[o.jsxs("button",{type:"button",onClick:()=>p("upload"),className:`flex items-center gap-1.5 px-2.5 py-1 rounded transition-colors ${f==="upload"?"bg-white dark:bg-gray-800 text-blue-600 dark:text-blue-400 font-medium shadow-xs":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:[o.jsx(ig,{className:"w-3.5 h-3.5"}),"Upload"]}),o.jsxs("button",{type:"button",onClick:()=>p("url"),className:`flex items-center gap-1.5 px-2.5 py-1 rounded transition-colors ${f==="url"?"bg-white dark:bg-gray-800 text-blue-600 dark:text-blue-400 font-medium shadow-xs":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:[o.jsx(XN,{className:"w-3.5 h-3.5"}),"URL"]})]})]}),o.jsxs("div",{className:"space-y-3",children:[t.length>0&&o.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:t.map((ne,G)=>o.jsxs("div",{className:"relative group border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden bg-gray-50 dark:bg-gray-900/50",children:[o.jsx("div",{className:"mx-auto flex items-center justify-center p-2",children:o.jsx("img",{src:ne,alt:`Preview ${G+1}`,className:`w-full rounded-md object-cover shadow-xs ${ee}`})}),o.jsx("button",{type:"button",onClick:()=>L(G),className:"absolute top-1 right-1 p-1.5 bg-white/90 dark:bg-gray-800/90 hover:bg-red-50 dark:hover:bg-red-900/50 text-red-600 rounded-md opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(Kg,{className:"w-4 h-4"})})]},G))}),U&&o.jsxs(o.Fragment,{children:[f==="upload"&&o.jsxs("div",{onDragOver:D,onDragLeave:k,onDrop:_,onClick:()=>{var ne;return(ne=z.current)==null?void 0:ne.click()},className:`border-2 border-dashed rounded-lg p-5 text-center cursor-pointer transition-all duration-200 flex flex-col items-center justify-center gap-2 ${F?"border-blue-500 bg-blue-50/50 dark:bg-blue-950/20":"border-gray-300 dark:border-gray-600 hover:border-blue-400 dark:hover:border-blue-500 bg-gray-50/50 dark:bg-gray-800/50 hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[o.jsx("input",{ref:z,type:"file",multiple:!0,accept:"image/png,image/jpeg,image/webp,image/gif",onChange:M,className:"hidden"}),w?o.jsxs("div",{className:"flex flex-col items-center gap-2 py-3",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-blue-600 border-t-transparent"}),o.jsx("p",{className:"text-sm font-medium text-blue-600 dark:text-blue-400",children:"Processing..."})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"p-2.5 rounded-full bg-blue-50 dark:bg-blue-900/30 text-blue-600 dar
4214k:text-blue-400",children:o.jsx(ig,{className:"w-6 h-6"})}),o.jsx("div",{className:"text-center",children:o.jsxs("p",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:[o.jsx("span",{className:"text-blue-600 dark:text-blue-400 underline",children:"Click to upload"})," or drag and drop"]})})]})]}),f==="url"&&o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none text-gray-400",children:o.jsx(WN,{className:"w-4 h-4"})}),o.jsx("input",{type:"url",value:y,onChange:ne=>b(ne.target.value),placeholder:"https://example.com/photo.jpg",className:"w-full pl-9 pr-3 py-2 border rounded-md border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),o.jsx("button",{type:"button",onClick:H,disabled:!y.trim(),className:"px-4 py-2 bg-blue-600 text-white rounded-md text-sm font-medium hover:bg-blue-700 disabled:opacity-50",children:"Add"})]})]}),N&&o.jsxs("div",{className:"flex items-center gap-2 p-2.5 rounded-md bg-red-50 dark:bg-red-950/40 text-red-700 dark:text-red-300 text-xs border border-red-200 dark:border-red-800",children:[o.jsx(uc,{className:"w-4 h-4 flex-shrink-0"}),o.jsx("span",{children:N})]}),I&&o.jsxs("div",{className:"flex items-center gap-2 p-2.5 rounded-md bg-emerald-50 dark:bg-emerald-950/40 text-emerald-700 dark:text-emerald-300 text-xs border border-emerald-200 dark:border-emerald-800",children:[o.jsx(ox,{className:"w-4 h-4 flex-shrink-0"}),o.jsx("span",{children:"Image uploaded successfully!"})]}),u&&!N&&!I&&o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:u})]})]})},UG=({destination:n,onClose:e,onSave:t})=>{const[r,s]=R.useState(n),[a,c]=R.useState(!1);if(R.useEffect(()=>{s(n)},[n]),!r)return null;const u=f=>{const{name:p,value:y,type:b}=f.target,w=b==="number";s(r?{...r,[p]:w?parseFloat(y)||0:y}:null)},h=f=>{f.preventDefault(),r&&(c(!0),setTimeout(()=>{t(r),c(!1),e()},500))};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-2xl m-4 max-h-[90vh] overflow-y-auto",children:[o.jsxs("div",{className:"flex justify-between items-center mb-6",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:"Edit Destination"}),o.jsx("button",{onClick:e,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("form",{onSubmit:h,className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsxs("div",{className:"md:col-span-2",children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"name",children:"Name"}),o.jsx("input",{id:"name",name:"name",type:"text",value:r.name,onChange:u,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"shortCode",children:"Short Code"}),o.jsx("input",{id:"shortCode",name:"shortCode",type:"text",value:r.shortCode||"",onChange:u,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"description",children:"Description"}),o.jsx("textarea",{id:"description",name:"description",value:r.description,onChange:u,rows:3,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"hint",children:"Hint"}),o.jsx("input",{id:"hint",name:"hint",type:"text",value:r.hint||"",onChange:u,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsx("div",{children:o.jsx(RA,{id:"edit-destination-image",label:"Destination Images",values:r.imageUrls||(r.imageUrl?[r.imageUrl]:[]),onChange:f=>s(p=>p?{...p,imageUrl:f[0]||"",imageUrls:f}:null),folder:"destinations",aspectRatio:"wide",maxImages:4,helperText:"Upload up to 4 high-resolution landscape photos of this destination."})}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"parkFee",children:"Park Fee ($)"}),o.jsx("input",{id:"parkFee",name:"parkFee",type:"number",value:r.parkFee,onChange:u,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"flyInAirstrip",name:"flyInAirstrip",type:"checkbox",checked:r.flyInAirstrip||!1,onChange:f=>s(r?{...r,flyInAirstrip:f.target.checked}:null),className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"flyInAirstrip",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"Has Fly-in Airstrip"})]}),o.jsxs("div",{className:"flex justify-end gap-4 pt-4",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(He,{type:"submit",disabled:a,children:a?o.jsx(At,{}):"Save Changes"})]})]})]})})},VG=({activity:n,onClose:e,onSave:t})=>
4214{const[r,s]=R.useState(n),[a,c]=R.useState(!1);if(R.useEffect(()=>{s(n)},[n]),!r)return null;const u=f=>{const{name:p,value:y,type:b}=f.target;let w=y;b==="number"?w=parseFloat(y)||0:b==="checkbox"&&(w=f.target.checked),s(E=>E?{...E,[p]:w}:null)},h=f=>{f.preventDefault(),r&&(c(!0),setTimeout(()=>{t(r),c(!1),e()},500))};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-2xl m-4 max-h-[90vh] overflow-y-auto",children:[o.jsxs("div",{className:"flex justify-between items-center mb-6",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:"Edit Activity"}),o.jsx("button",{onClick:e,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("form",{onSubmit:h,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"name",children:"Name"}),o.jsx("input",{id:"name",name:"name",type:"text",value:r.name,onChange:u,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"description",children:"Description"}),o.jsx("textarea",{id:"description",name:"description",value:r.description,onChange:u,rows:3,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsx("div",{children:o.jsx(Qa,{id:"edit-activity-image",label:"Activity Image",value:r.imageUrl||"",onChange:f=>s(p=>p?{...p,imageUrl:f}:null),folder:"activities",aspectRatio:"wide",helperText:"Upload a photo showcasing this safari activity."})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"price",children:"Price ($)"}),o.jsx("input",{id:"price",name:"price",type:"number",value:r.price,onChange:u,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"unit",children:"Unit"}),o.jsxs("select",{id:"unit",name:"unit",value:r.unit,onChange:u,className:"w-full p-2 border rounded border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:[o.jsx("option",{value:"per person",children:"Per Person"}),o.jsx("option",{value:"per guide",children:"Per Guide"}),o.jsx("option",{value:"per vehicle",children:"Per Vehicle"}),o.jsx("option",{value:"per group",children:"Per Group"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"permitProcessingFee",children:"Permit Fee ($)"}),o.jsx("input",{id:"permitProcessingFee",name:"permitProcessingFee",type:"number",value:r.permitProcessingFee||0,onChange:u,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 pt-2",children:[o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"includesParkEntryFee",name:"includesParkEntryFee",type:"checkbox",checked:r.includesParkEntryFee,onChange:u,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"includesParkEntryFee",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"Includes Park Fee"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"requiresVehicle",name:"requiresVehicle",type:"checkbox",checked:r.requiresVehicle||!1,onChange:u,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"requiresVehicle",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"Requires Vehicle"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"isFullDay",name:"isFullDay",type:"checkbox",checked:r.isFullDay||!1,onChange:u,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"isFullDay",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"Is Full Day Activity"})]})]}),o.jsxs("div",{className:"flex justify-end gap-4 pt-6",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(He,{type:"submit",disabled:a,children:a?o.jsx(At,{}):"Save Changes"})]})]})]})})},GG=({room:n,onChange:e,onDelete:t})=>o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 p-4 rounded-lg border border-gray-200 dark:border-gray-600 space-y-3",children:[o.jsxs("div",{className:"flex justify-between items-start",children:[o.jsx("input",{type:"text",value:n.name,onChange:r=>e(n.id,"name",r.target.value),className:"w-full p-2 border rounded border-gray-300 dark:border-gray-500 dark:bg-gray-600 dark:text-white text-sm font-semibold"}),o.jsx("button",{type:"button",onClick:()=>t(n.id),className:"ml-4 text-red-500 hover:text-red-700 dark:hover:text-red-400 flex-shrink-0",children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm4 0a1 1 0 012 0v6a1 1 0 11-2 0V8z",clipRule:"evenodd"})})})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-bold text-gray-600 dark:text-gray-400 mb-1",children:"Max Occupancy"}),o.jsx("input",{type:"number",value:n.maxOccupancy,onChange:r=>e(n.id,"maxOccupancy",r.target.value),className:"w-full p-2 border rounded border-gray-300 dark:border-gray-500 dark:bg-gray-600 dark:text-white text-sm"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-bold text-gray-600 dark:text-gray-400 mb-1",children:"Pricing Model"}),o.jsxs("select",{value:n.pricingModel,onChange:r=>e(n.id,"pricingModel",r.target.value),className:"w-full p-2 border rounded border-gray-300 dark:border-gray-500 dark:bg-gray-600 dark:text-white text-sm bg-white",children:[o.jsx("option",{value:"perPerson",children:"Per Person"}),o.jsx("option",{value:"perNight",children:"Per Night"})]})]})]}),n.pricingModel==="perPerson"?o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-bold text-gray-600 dark:text-gray-400 mb-1",children:"Low (Single)"}),o.jsx("input",{type:"number",value:n.lowSeasonPriceSingle||0,onChange:r=>e(n.id,"lowSeasonPriceSingle",r.target.value),className:"w-full p-2 border rounded border-gray-300 dark:border-gray-500 dark:bg-gray-600 dark:text-white text-sm"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-bold text-gray-600 dark:text-gray-400 mb-1",children:"Low (Double/pp)"}),o.jsx("input",{type:"number",value:n.lowSeasonPriceDouble||0,onChange:r=>e(n.id,"lowSeasonPriceDouble",r.target.value),className:"w-full p-2 border rounded border-gray-300 dark:border-gray-500 dark:bg-gray-600 dark:text-white text-sm"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-bold text-gray-600 dark:text-gray-400 mb-1",children:"High (Single)"}),o.jsx("input",{type:"number",value:n.highSeasonPriceSingle||0,onChange:r=>e(n.id,"highSeasonPriceSingle",r.target.value),className:"w-full p-2 border rounded border-gray-300 dark:border-gray-500 dark:bg-gray-600 dark:text-white text-sm"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-bold text-gray-600 dark:text-gray-400 mb-1",children:"High (Double/pp)"}),o.jsx("input",{type:"number",value:n.highSeasonPriceDouble||0,onChange:r=>e(n.id,"highSeasonPriceDouble",r.target.value),className:"w-full p-2 border rounded border-gray-300 dark:border-gray-500 dark:bg-gray-600 dark:text-white text-sm"})]})]}):o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-bold text-gray-600 dark:text-gray-400 mb-1",children:"Low Season (Per Night)"}),o.jsx("input",{type:"number",value:n.lowSeasonPricePerNight||0,onChange:r=>e(n.id,"lowSeasonPricePerNight",r.target.value),className:"w-full p-2 border rounded border-gray-300 dark:border-gray-500 dark:bg-gray-600 dark:text-white text-sm"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-bold text-gray-600 dark:text-gray-400 mb-1",children:"High Season (Per Night)"}),o.jsx("input",{type:"number",value:n.highSeasonPricePerNight||0,onChange:r=>e(n.id,"highSeasonPricePerNight",r.target.value),className:"w-full p-2 border rounded border-gray-300 dark:border-gray-500 dark:bg-gray-600 dark:text-white text-sm"})]})]})]}),HG=({lodge:n,destinations:e,onClose:t,onSave:r})=>{const[s,a]=R.useState(n),[c,u]=R.useState(!1),[h,f]=R.useState("");
4214if(R.useEffect(()=>{var S;a(n),n&&f(((S=n.features)==null?void 0:S.join(", "))||"")},[n]),!s)return null;const p=S=>{const{name:I,value:O,type:F}=S.target,J=F==="checkbox";a(z=>z?{...z,[I]:J?S.target.checked:O}:null)},y=S=>{const I=S.target.value;f(I),a(O=>O?{...O,features:I.split(",").map(F=>F.trim()).filter(Boolean)}:null)},b=(S,I,O)=>{a(F=>{if(!F)return null;const J=F.rooms.map(z=>{if(z.id===S){const U=typeof z[I]=="number"||I.toLowerCase().includes("price")||I==="maxOccupancy";return{...z,[I]:U?parseFloat(O)||0:O}}return z});return{...F,rooms:J}})},w=()=>{a(S=>{if(!S)return null;const I={id:`room_${Date.now()}`,name:"New Room",maxOccupancy:2,pricingModel:"perPerson",lowSeasonPriceSingle:100,lowSeasonPriceDouble:80,highSeasonPriceSingle:150,highSeasonPriceDouble:120};return{...S,rooms:[...S.rooms,I]}})},E=S=>{a(I=>I?{...I,rooms:I.rooms.filter(O=>O.id!==S)}:null)},N=S=>{S.preventDefault(),s&&(u(!0),setTimeout(()=>{r(s),u(!1),t()},500))};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-3xl m-4 max-h-[90vh] flex flex-col",children:[o.jsxs("div",{className:"flex justify-between items-center mb-6 flex-shrink-0",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:"Edit Lodge"}),o.jsx("button",{onClick:t,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("form",{onSubmit:N,className:"space-y-6 flex-grow overflow-y-auto pr-2",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"name",children:"Lodge Name"}),o.jsx("input",{id:"name",name:"name",type:"text",value:s.name,onChange:p,required:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"destinationId",children:"Destination"}),o.jsx("select",{id:"destinationId",name:"destinationId",value:s.destinationId,onChange:p,required:!0,className:"w-full p-2 border rounded border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:e.map(S=>o.jsx("option",{value:S.id,children:S.name},S.id))})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"isDefault",name:"isDefault",type:"checkbox",checked:s.isDefault,onCh
4214ange:p,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"isDefault",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"Set as default lodge for this destination"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"features",children:"Features (comma-separated)"}),o.jsx("input",{id:"features",name:"features",type:"text",value:h,onChange:y,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsx("div",{children:o.jsx(Qa,{id:"edit-lodge-image",label:"Lodge Image",value:s.imageUrl||"",onChange:S=>a(I=>I?{...I,imageUrl:S}:null),folder:"lodges",aspectRatio:"wide",helperText:"Upload a photo of the lodge or accommodations."})})]}),o.jsxs("div",{className:"pt-4 border-t dark:border-gray-700",children:[o.jsx("h3",{className:"text-lg font-bold text-brand-dark dark:text-white font-heading mb-4",children:"Manage Rooms"}),o.jsxs("div",{className:"space-y-3",children:[s.rooms.map(S=>o.jsx(GG,{room:S,onChange:b,onDelete:E},S.id)),s.rooms.length===0&&o.jsx("p",{className:"text-sm text-center text-gray-500 dark:text-gray-400 py-4",children:"This lodge has no rooms yet."})]}),o.jsx(He,{type:"button",variant:"secondary",onClick:w,className:"w-full mt-4 text-sm !py-2",children:"+ Add New Room"})]}),o.jsxs("div",{className:"flex justify-end gap-4 pt-4 flex-shrink-0",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),o.jsx(He,{type:"submit",disabled:c,children:c?o.jsx(At,{}):"Save Changes"})]})]})]})})},hu=({label:n,rackRate:e,value:t,onChange:r,profit:s,unit:a,disabled:c})=>o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/60 p-2.5 rounded border border-gray-200 dark:border-gray-600",children:[o.jsx("label",{className:"block text-xs font-semibold text-gray-700 dark:text-gray-300",children:n}),o.jsxs("div",{className:"flex items-baseline justify-between mt-0.5",children:[o.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Rack: ",o.jsxs("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:["$",e??"N/A"]})]}),o.jsx("span",{className:"text-[10px] text-emerald-600 dark:text-emerald-400 font-mono",children:"DB"})]}),o.jsx("input",{type:"number",placeholder:e!==void 0?`${e}`:"Your Price",value:t??"",onChange:r,disabled:c,className:"w-full p-1.5 mt-1 border rounded border-gray-300 dark:border-gray-500 dark:bg-gray-800 dark:text-white text-xs disabled:opacity-60"}),o.jsxs("p",{className:`mt-1 text-xs font-semibold ${s.startsWith("-")?"text-red-500":"text-emerald-600 dark:text-emerald-400"}`,children:["Profit: ",s," ",o.jsx("span",{className:"text-[10px] font-normal text-gray-500 dark:text-gray-400",children:a})]})]}),PA=({lodgeRate:n,allLodgeRates:e,lodges:t,onUpdate:r,onDelete:s,disabled:a=!1})=>{const c=R.useMemo(()=>t.find(b=>b.id===n.lodgeId),[t,n.lodgeId]),u=b=>{r({...n,lodgeId:b.target.value,sellingRateOverrides:[]})},h=b=>{const w=parseFloat(b.target.value)/100;r({...n,commission:isNaN(w)?0:w})},f=(b,w,E)=>{const N=parseFloat(E),S=[...n.sellingRateOverrides||[]];let I=S.find(O=>O.roomId===b);if(I){I={...I,[w]:isNaN(N)?void 0:N};const O=S.findIndex(F=>F.roomId===b);S[O]=I}else S.push({roomId:b,[w]:isNaN(N)?void 0:N});r({...n,sellingRateOverrides:S})},p=R.useMemo(()=>t.filter(b=>!e.some(w=>w.lodgeId===b.id)||b.id===n.lodgeId),[t,e,n.lodgeId]),y=(b,w)=>{if(b===void 0)return"-";const E=w??b,N=b*(n.commission||0),S=b-E,I=N-S;return`${I>=0?"$":"-$"}${Math.abs(I).toFixed(2)}`};return o.jsxs("div",{className:"bg-white dark:bg-gray-800 p-4 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-3 items-end",children:[o.jsxs("div",{className:"md:col-span-6",children:[o.jsx("label",{className:"block text-xs font-bold text-gray-700 dark:text-gray-300 mb-1",children:"Lodge (Live Database)"}),o.jsxs("select",{value:n.lodgeId,onChange:u,disabled:a,className:"w-full p-2 border rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white text-sm bg-white focus:ring-2 focus:ring-brand-gold focus:border-transparent",children:[o.jsx("option",{value:"",children:"Select a Lodge from Database..."}),p.map(b=>o.jsxs("option",{value:b.id,children:[b.name," (",b.rooms.length," rooms configured)"]},b.id))]})]}),o.jsxs("div",{className:"md:col-span-4",children:[o.jsxs("div",{className:"flex justify-between items-center mb-1",children:[o.jsx("label",{className:"block text-xs font-bold text-gray-700 dark:text-gray-300",children:"Negotiated Commission (%)"}),o.jsxs("span",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:[((n.commission||0)*100).toFixed(1),"% rate"]})]}),o.jsxs("div",{className:"relative",children:[o.jsx("input",{type:"number",step:"0.5",min:"0",max:"100",value:Number(((n.commission||0)*100).toPrecision(15)),onChange:h,disabled:a,placeholder:"e.g. 20",className:"w-full p-2 pr-8 border rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white text-sm focus:ring-2 focus:ring-brand-gold"}),o.jsx("span",{className:"absolute right-3 top-2.5 text-xs text-gray-400 font-bold",children:"%"})]})]}),o.jsx("div",{className:"md:col-span-2 flex justify-end",children:o.jsxs("button",{type:"button",onClick:s,disabled:a,className:"h-10 px-3 flex items-center gap-1 text-xs text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 border border-red-200 dark:border-red-900/50 rounded-lg hover:bg-red-50 dark:hover:bg-red-950/20 transition-colors disabled:opacity-50",title:"Remove negotiated lodge rate",children:[o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm4 0a1 1 0 012 0v6a1 1 0 11-2 0V8z",clipRule:"evenodd"})}),"Remove"]})})]}),c&&c.rooms.length>0&&o.jsxs("div",{className:"pt-3 border-t border-gray-200 dark:border-gray-700 space-y-3",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{children:[o.jsxs("h5",{className:"text-xs font-bold text-gray-800 dark:text-gray-200 uppercase tracking-wider",children:["Room Rates & Overrides (",c.rooms.length," room",c.rooms.length>
42141?"s":"",")"]}),o.jsx("p",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:"Rack rates are synced directly from the database (managed in Admin Hub). Enter your custom selling price to adjust margin or leave empty to sell at standard rack rate."})]}),o.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-semibold bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300 border border-blue-200 dark:border-blue-800",children:"Synced with Admin Hub Database"})]}),o.jsx("div",{className:"space-y-3",children:c.rooms.map(b=>{var E;const w=(E=n.sellingRateOverrides)==null?void 0:E.find(N=>N.roomId===b.id);return o.jsxs("div",{className:"p-3 bg-gray-50/70 dark:bg-gray-750 rounded-lg border border-gray-200 dark:border-gray-700",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"font-bold text-xs text-gray-900 dark:text-white",children:b.name}),o.jsxs("span",{className:"text-[10px] text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-800 px-2 py-0.5 rounded border dark:border-gray-600",children:["Pricing: ",b.pricingModel==="perPerson"?"Per Person / Night":"Per Room / Night"," (Max ",b.maxOccupancy,")"]})]}),b.pricingModel==="perPerson"?o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[o.jsx(hu,{label:"Low Season (Single)",rackRate:b.lowSeasonPriceSingle,value:w==null?void 0:w.lowSeasonPriceSingle,onChange:N=>f(b.id,"lowSeasonPriceSingle",N.target.value),profit:y(b.lowSeasonPriceSingle,w==null?void 0:w.lowSeasonPriceSingle),unit:"/person",disabled:a}),o.jsx(hu,{label:"Low Season (Double/pp)",rackRate:b.lowSeasonPriceDouble,value:w==null?void 0:w.lowSeasonPriceDouble,onChange:N=>f(b.id,"lowSeasonPriceDouble",N.target.value),profit:y(b.lowSeasonPriceDouble,w==null?void 0:w.lowSeasonPriceDouble),unit:"/person",disabled:a}),o.jsx(hu,{label:"High Season (Single)",rackRate:b.highSeasonPriceSingle,value:w==null?void 0:w.highSeasonPriceSingle,onChange:N=>f(b.id,"highSeasonPriceSingle",N.target.value),profit:y(b.highSeasonPriceSingle,w==null?void 0:w.highSeasonPriceSingle),unit:"/person",disabled:a}),o.jsx(hu,{label:"High Season (Double/pp)",rackRate:b.highSeasonPriceDouble,value:w==null?void 0:w.highSeasonPriceDouble,onChange:N=>f(b.id,"highSeasonPriceDouble",N.target.value),profit:y(b.highSeasonPriceDouble,w==null?void 0:w.highSeasonPriceDouble),unit:"/person",disabled:a})]}):o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[o.jsx(hu,{label:"Low Season (Per Night)",rackRate:b.lowSeasonPricePerNight,value:w==null?void 0:w.lowSeasonPricePerNight,onChange:N=>f(b.id,"lowSeasonPricePerNight",N.target.value),profit:y(b.lowSeasonPricePerNight,w==null?void 0:w.lowSeasonPricePerNight),unit:"/night",disabled:a}),o.jsx(hu,{label:"High Season (Per Night)",rackRate:b.highSeasonPricePerNight,value:w==null?void 0:w.highSeasonPricePerNight,onChange:N=>f(b.id,"highSeasonPricePerNight",N.target.value),profit:y(b.highSeasonPricePerNight,w==null?void 0:w.highSeasonPricePerNight),unit:"/night",disabled:a})]})]},b.id)})})]}),c&&c.rooms.length===0&&o.jsx("div",{className:"p-3 bg-amber-50 dark:bg-amber-950/20 border border-amber-200 dark:border-amber-900/30 rounded-lg text-xs text-amber-800 dark:text-amber-300",children:"This lodge currently has no rooms defined in the database. Rooms can be added by an administrator in Admin Hub → Manage Lodges."})]})},qG=({consultant:n,lodges:e=[],onClose:t,onSave:r})=>{var S,I,O,F,J,z;const[s,a]=R.useState(n),[c,u]=R.useState(!1),[h,f]=R.useState("");if(R.useEffect(()=>{a(n),n&&f(n.specialties.join(", "))},[n]),!s)return null;const p=()=>{const U={lodgeId:"",commission:.15,sellingRateOverrides:[]};a(D=>D?{...D,lodgeRates:[...D.lodgeRates||[],U]}:null)},y=(U,D)=>{a(k=>{if(!k)return null;const _=[...k.lodgeRates||[]];return _[U]=D,{...k,lodgeRates:_}})},b=U=>{a(D=>D?{...D,lodgeRates:(D.lodgeRates||[]).filter((k,_)=>_!==U)}:null)},w=U=>{const{name:D,value:k,type:_}=U.target,M=_==="checkbox",j=M?U.target.checked:!1;if(D.startsWith("company.")){const H=D.split(".")[1];a(L=>
4214L?{...L,company:{...L.company||{},[H]:M?j:k}}:null)}else if(D==="commissionRate"){const H=parseFloat(k)/100;a(L=>L?{...L,commissionRate:isNaN(H)?0:H}:null)}else if(D==="adminCommissionRateOverride"){const H=parseFloat(k)/100;a(L=>L?{...L,adminCommissionRateOverride:k===""||isNaN(H)?void 0:H}:null)}else a(H=>H?{...H,[D]:M?j:k}:null)},E=U=>{const D=U.target.value;f(D),a(k=>k?{...k,specialties:D.split(",").map(_=>_.trim()).filter(Boolean)}:null)},N=U=>{U.preventDefault(),s&&(u(!0),setTimeout(()=>{r(s),u(!1),t()},500))};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-2xl m-4 max-h-[90vh] overflow-y-auto",children:[o.jsxs("div",{className:"flex justify-between items-center mb-6",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:"Edit Consultant"}),o.jsx("button",{onClick:t,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("form",{onSubmit:N,className:"space-y-6",children:[o.jsxs("fieldset",{className:"space-y-4 p-4 border dark:border-gray-600 rounded-lg",children:[o.jsx("legend",{className:"text-lg font-semibold px-2 dark:text-white",children:"Consultant Info"}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"name",children:"Name"}),o.jsx("input",{id:"name",name:"name",type:"text",value:s.name,onChange:w,required:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"email",children:"Email Address"}),o.jsx("input",{id:"email",name:"email",type:"email",value:s.email||"",onChange:w,required:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"phone",children:"Phone Number"}),o.jsx("input",{id:"phone",name:"phone",type:"tel",value:s.phone||"",onChange:w,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"bio",children:"Bio"}),o.jsx("textarea",{id:"bio",name:"bio",value:s.bio,onChange:w,rows:3,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsx("div",{children:o.jsx(Qa,{id:"edit-consultant-image",label:"Profile Image",value:s.imageUrl,onChange:U=>a(D=>D?{...D,imageUrl:U}:null),folder:"consultants",aspectRatio:"square",helperText:"Upload a consultant profile image or photo."})}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"specialties",children:"Specialties (comma-separated)"}),o.jsx("input",{id:"specialties",name:"specialties",type:"text",value:h,onChange:E,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"isAvailable",name:"isAvailable",type:"checkbox",checked:s.isAvailable,onChange:w,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"isAvailable",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"Available for new trips"})]})]}),o.jsxs("fieldset",{className:"space-y-4 p-4 border dark:border-gray-600 rounded-lg",children:[o.jsx("legend",{className:"text-lg font-semibold px-2 dark:text-white",children:"Fee Structure"}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"commissionRate",children:"Consultant-set Fee (%)"}),o.jsx("input",{id:"commissionRate",name:"commissionRate",type:"number",step:"0.1",value:Number(((s.commissionRate||0)*100).toPrecision(15)),disabled:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-800 cursor-not-allowed"})]}),o.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-gray-50 dark:bg-gray-700/50 border dark:border-gray-600",children:[o.jsx("input",{id:"canSetCommissionRate",name:"canSetCommissionRate",type:"checkbox",checked:s.canSetCommissionRate??!0,onChange:w,className:"h-5 w-5 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"canSetCommissionRate",className:"text-sm text-gray-900 dark:text-gray-200",children:"Allow consultant to set their own fee (max 25%)"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"adminCommissionRateOverride",children:"Admin Override Fee (%)"}),o.jsx("input",{id:"adminCommissionRateOverride",name:"adminCommissionRateOverride",type:"number",step:"0.1",placeholder:"Empty = no override",value:s.adminCommissionRateOverride!==void 0?Number((s.adminCommissionRateOverride*100).toPrecision(15)):"",onCh
4214ange:w,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"If set, this fee will be used regardless of other settings."})]})]}),o.jsxs("fieldset",{className:"space-y-4 p-4 border dark:border-gray-600 rounded-lg",children:[o.jsxs("div",{className:"flex justify-between items-center px-2",children:[o.jsxs("legend",{className:"text-lg font-semibold dark:text-white",children:["Negotiated Lodge Rates & Commissions (",((S=s.lodgeRates)==null?void 0:S.length)||0,")"]}),o.jsx("button",{type:"button",onClick:p,className:"text-xs bg-brand-gold text-brand-dark px-3 py-1.5 rounded-md font-semibold hover:bg-yellow-400 transition-colors shadow-sm",children:"+ Add Lodge Rate"})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 px-2",children:"Manage this consultant's negotiated commission and room selling rate overrides on database lodges. These settings dynamically reflect in Itinerary Builder and Booking totals."}),o.jsxs("div",{className:"space-y-3",children:[(s.lodgeRates||[]).map((U,D)=>o.jsx(PA,{lodgeRate:U,allLodgeRates:s.lodgeRates||[],lodges:e,onUpdate:k=>y(D,k),onDelete:()=>b(D)},D)),(!s.lodgeRates||s.lodgeRates.length===0)&&o.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700/40 rounded-lg text-center text-xs text-gray-500 dark:text-gray-400 border border-dashed border-gray-300 dark:border-gray-600",children:"No negotiated lodge rates configured for this consultant yet."})]})]}),o.jsxs("fieldset",{className:"space-y-4 p-4 border dark:border-gray-600 rounded-lg",children:[o.jsx("legend",{className:"text-lg font-semibold px-2 dark:text-white",children:"Company Affiliation"}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"company.name",children:"Company Name"}),o.jsx("input",{id:"company.name",name:"company.name",type:"text",value:((I=s.company)==null?void 0:I.name)||"",onChange:w,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"company.website",children:"Company Website"}),o.jsx("input",{id:"company.website",name:"company.website",type:"url",placeholder:"https://example.com",value:((O=s.company)==null?void 0:O.website)||"",onChange:w,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"company.tier",children:"Company Tier"}),o.jsxs("select",{id:"company.tier",name:"company.tier",value:((F=s.company)==null?void 0:F.tier)||"Mid-range",onChange:w,className:"w-full p-2 border rounded border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:[o.jsx("option",{value:"Budget",children:"Budget"}),o.jsx("option",{value:"Mid-range",children:"Mid-range"}),o.jsx("option",{value:"High-end",children:"High-end"}),o.jsx("option",{value:"Mid-range to High-end",children:"Mid-range to High-end"})]})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"company.utbLicensed",name:"company.utbLicensed",type:"checkbox",checked:((J=s.company)==null?void 0:J.utbLicensed)||!1,onChange:w,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"company.utbLicensed",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"UTB Licensed"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"company.autoMember",name:"company.autoMember",type:"checkbox",checked:((z=s.company)==null?void 0:z.autoMember)||!1,onChange:w,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"company.autoMember",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"AUTO Member"})]})]}),o.jsxs("div",{className:"flex justify-end gap-4 pt-4",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}
4214),o.jsx(He,{type:"submit",disabled:c,children:c?o.jsx(At,{}):"Save Changes"})]})]})]})})},zG=({review:n,onClose:e,onSave:t})=>{const[r,s]=R.useState(n),[a,c]=R.useState(!1);if(R.useEffect(()=>{s(n)},[n]),!r)return null;const u=f=>{const{name:p,value:y}=f.target;s(b=>b?{...b,[p]:y}:null)},h=f=>{f.preventDefault(),r&&(c(!0),setTimeout(()=>{t(r),c(!1),e()},500))};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-lg m-4",children:[o.jsxs("div",{className:"flex justify-between items-center mb-6",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:"Edit Review"}),o.jsx("button",{onClick:e,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("form",{onSubmit:h,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("p",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",children:"Traveler Name"}),o.jsx("p",{className:"w-full p-2 bg-gray-100 dark:bg-gray-700 dark:text-white rounded border border-gray-300 dark:border-gray-600",children:r.travelerName})]}),o.jsxs("div",{children:[o.jsx("p",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",children:"Rating"}),o.jsx(Wa,{rating:r.rating})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"comment",children:"Comment"}),o.jsx("textarea",{id:"comment",name:"comment",value:r.comment,onChange:u,rows:4,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"consultantReply",children:"Consultant Reply"}),o.jsx("textarea",{id:"consultantReply",name:"consultantReply",value:r.consultantReply||"",onChange:u,rows:3,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{className:"flex justify-end gap-4 pt-4",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(He,{type:"submit",disabled:a,children:a?o.jsx(At,{}):"Save Changes"})]})]})]})})},JG={name:"",shortCode:"",description:"",hint:"",imageUrl:"https://picsum.photos/seed/newdest/800/600",parkFee:0,flyInAirstrip:!1},$G=({onClose:n,onSave:e})=>{const[t,r]=R.useState(JG),[s,a]=R.useState(!1),c=h=>{const{name:f,value:p,type:y}=h.target,b=y==="number";r(w=>({...w,[f]:b?parseFloat(p)||0:p}))},u=h=>{h.preventDefault(),t.name&&(a(!0),setTimeout(()=>{e(t),a(!1),n()},500))};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-2xl m-4 max-h-[90vh] overflow-y-auto",children:[o.jsxs("div",{className:"flex justify-between items-center mb-6",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:"Add New Destination"}),o.jsx("button",{onClick:n,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("form",{onSubmit:u,className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsxs("div",{className:"md:col-span-2",children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"name",children:"Name"}),o.jsx("input",{id:"name",name:"name",type:"text",value:t.name,onChange:c,required:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"shortCode",children:"Short Code"}),o.jsx("input",{id:"shortCode",name:"shortCode",type:"text",value:t.shortCode,onChange:c,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"description",children:"Description"}),o.jsx("textarea",{id:"description",name:"description",value:t.description,onChange:c,rows:3,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsx("div",{children:o.jsx(RA,{id:"add-destination-image",label:"Destination Images",values:t.imageUrls||(t.imageUrl?[t.imageUrl]:[]),onChange:h=>r(f=>({...f,imageUrl:h[0]||"",imageUrls:h})),folder:"destinations",aspectRatio:"wide",maxImages:4,helperText:"Upload up to 4 high-resolution landscape photos of this destination."})}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"parkFee",children:"Park Fee ($)"}),o.jsx("input",{id:"parkFee",name:"parkFee",type:"number",value:t.parkFee,onChange:c,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"flyInAirstrip",name:"flyInAirstrip",type:"checkbox",checked:t.flyInAirstrip||!1,onChange:h=>r(f=>({...f,flyInAirstrip:h.target.checked})),className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"flyInAirstrip",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"Has Fly-in Airstrip"})]}),o.jsxs("div",{className:"flex justify-end gap-4 pt-4",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:n,children:"Cancel"}),o.jsx(He,{type:"submit",disabled:s,children:s?o.jsx(At,{}):"Add Destination"})]})]})]})})},KG=({destinations:n,onClose:e,onSave:t})=>{var b;
4214const[r,s]=R.useState({name:"",destinationId:((b=n[0])==null?void 0:b.id)||"",isDefault:!1,imageUrl:"",features:[]}),[a,c]=R.useState(""),[u,h]=R.useState(!1),f=w=>{const{name:E,value:N,type:S}=w.target,I=S==="checkbox";s(O=>({...O,[E]:I?w.target.checked:N}))},p=w=>{const E=w.target.value;c(E),s(N=>({...N,features:E.split(",").map(S=>S.trim()).filter(Boolean)}))},y=w=>{w.preventDefault(),!(!r.name||!r.destinationId)&&(h(!0),setTimeout(()=>{const{...E}=r;t(E),h(!1),e()},500))};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-lg m-4",children:[o.jsxs("div",{className:"flex justify-between items-center mb-6",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:"Add New Lodge"}),o.jsx("button",{onClick:e,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("form",{onSubmit:y,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"name",children:"Lodge Name"}),o.jsx("input",{id:"name",name:"name",type:"text",value:r.name,onChange:f,required:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"destinationId",children:"Destination"}),o.jsx("select",{id:"destinationId",name:"destinationId",value:r.destinationId,onChange:f,required:!0,className:"w-full p-2 border rounded border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:n.map(w=>o.jsx("option",{value:w.id,children:w.name},w.id))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"features",children:"Features (comma-separated)"}),o.jsx("input",{id:"features",name:"features",type:"text",value:a,onChange:p,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsx("div",{children:o.jsx(Qa,{id:"add-lodge-image",label:"Lodge Image",value:r.imageUrl,onChange:w=>s(E=>({...E,imageUrl:w})),folder:"lodges",aspectRatio:"wide",helperText:"Upload a photo of the lodge or accommodations."})}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"isDefault",name:"isDefault",type:"checkbox",checked:r.isDefault,onCh
4214ange:f,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"isDefault",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"Set as default lodge for this destination"})]}),o.jsxs("div",{className:"flex justify-end gap-4 pt-4",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(He,{type:"submit",disabled:u,children:u?o.jsx(At,{}):"Add Lodge"})]})]})]})})},YG={name:"",description:"",price:0,unit:"per person",includesParkEntryFee:!1,requiresVehicle:!1,isFullDay:!1,permitProcessingFee:0,imageUrl:""},QG=({destinations:n,onClose:e,onSave:t})=>{var y;const[r,s]=R.useState(YG),[a,c]=R.useState(((y=n[0])==null?void 0:y.id)||""),[u,h]=R.useState(!1),f=b=>{const{name:w,value:E,type:N}=b.target;let S=E;N==="number"?S=parseFloat(E)||0:N==="checkbox"&&(S=b.target.checked),s(I=>({...I,[w]:S}))},p=b=>{b.preventDefault(),!(!r.name||!a)&&(h(!0),setTimeout(()=>{t(r,a),h(!1),e()},500))};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-2xl m-4 max-h-[90vh] overflow-y-auto",children:[o.jsxs("div",{className:"flex justify-between items-center mb-6",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:"Add New Activity"}),o.jsx("button",{onClick:e,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("form",{onSubmit:p,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"destinationId",children:"Destination"}),o.jsx("select",{id:"destinationId",name:"destinationId",value:a,onChange:b=>c(b.target.value),required:!0,className:"w-full p-2 border rounded border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:n.map(b=>o.jsx("option",{value:b.id,children:b.name},b.id))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"name",children:"Activity Name"}),o.jsx("input",{id:"name",name:"name",type:"text",value:r.name,onChange:f,required:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"description",children:"Description"}),o.jsx("textarea",{id:"description",name:"description",value:r.description,onChange:f,rows:3,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsx("div",{children:o.jsx(Qa,{id:"add-activity-image",label:"Activity Image",value:r.imageUrl||"",onChange:b=>s(w=>({...w,imageUrl:b})),folder:"activities",aspectRatio:"wide",helperText:"Upload a photo showcasing this safari activity."})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"price",children:"Price ($)"}),o.jsx("input",{id:"price",name:"price",type:"number",value:r.price,onChange:f,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"unit",children:"Unit"}),o.jsxs("select",{id:"unit",name:"unit",value:r.unit,onChange:f,className:"w-full p-2 border rounded border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:[o.jsx("option",{value:"per person",children:"Per Person"}),o.jsx("option",{value:"per guide",children:"Per Guide"}),o.jsx("option",{value:"per vehicle",children:"Per Vehicle"}),o.jsx("option",{value:"per group",children:"Per Group"})]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-2",children:[o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"includesParkEntryFee",name:"includesParkEntryFee",type:"checkbox",checked:r.includesParkEntryFee,onChange:f,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"includesParkEntryFee",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"Includes Park Entry Fee"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"requiresVehicle",name:"requiresVehicle",type:"checkbox",checked:r.requiresVehicle,onChange:f,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"requiresVehicle",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"Requires Vehicle"})]})]}),o.jsxs("div",{className:"flex justify-end gap-4 pt-4",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(He,{type:"submit",disabled:u,children:u?o.jsx(At,{}):"Add Activity"})]})]})]})})}
4214,WG={name:"",email:"",phone:"",bio:"",imageUrl:"https://picsum.photos/seed/newconsultant/400/400",specialties:[],commissionRate:.15,isAvailable:!0,company:{name:"",website:"",tier:"Mid-range",utbLicensed:!1,autoMember:!1}},XG=({onClose:n,onSave:e})=>{var y,b,w,E,N;const[t,r]=R.useState(WG),[s,a]=R.useState(!1),[c,u]=R.useState(""),h=S=>{const{name:I,value:O,type:F}=S.target,J=F==="checkbox",z=J?S.target.checked:!1;if(I.startsWith("company.")){const U=I.split(".")[1];r(D=>({...D,company:{...D.company||{},[U]:J?z:O}}))}else if(I==="commissionRate"){const U=parseFloat(O)/100;r(D=>({...D,commissionRate:isNaN(U)?0:U}))}else r(U=>({...U,[I]:J?z:O}))},f=S=>{u(S.target.value),r(I=>({...I,specialties:S.target.value.split(",").map(O=>O.trim()).filter(Boolean)}))},p=S=>{S.preventDefault(),t.name&&(a(!0),setTimeout(()=>{e(t),a(!1),n()},500))};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-2xl m-4 max-h-[90vh] overflow-y-auto",children:[o.jsxs("div",{className:"flex justify-between items-center mb-6",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:"Add New Consultant"}),o.jsx("button",{onClick:n,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("form",{onSubmit:p,className:"space-y-6",children:[o.jsxs("fieldset",{className:"space-y-4 p-4 border dark:border-gray-600 rounded-lg",children:[o.jsx("legend",{className:"text-lg font-semibold px-2 dark:text-white",children:"Consultant Info"}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"name",children:"Name"}),o.jsx("input",{id:"name",name:"name",type:"text",value:t.name,onChange:h,required:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"email",children:"Email Address"}),o.jsx("input",{id:"email",name:"email",type:"email",value:t.email||"",onChange:h,required:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"phone",children:"Phone Number"}),o.jsx("input",{id:"phone",name:"phone",type:"tel",value:t.phone||"",onChange:h,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"bio",children:"Bio"}),o.jsx("textarea",{id:"bio",name:"bio",value:t.bio,onChange:h,rows:3,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsx("div",{children:o.jsx(Qa,{id:"add-consultant-image",label:"Profile Image",value:t.imageUrl,onChange:S=>r(I=>({...I,imageUrl:S})),folder:"consultants",aspectRatio:"square",helperText:"Upload a consultant profile photo or enter an image URL."})}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"specialties",children:"Specialties (comma-separated)"}),o.jsx("input",{id:"specialties",name:"specialties",type:"text",value:c,onChange:f,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"commissionRate",children:"Commission Rate (%)"}),o.jsx("input",{id:"commissionRate",name:"commissionRate",type:"number",step:"0.1",value:Number(((t.commissionRate||0)*100).toPrecision(15)),onChange:h,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"isAvailable",name:"isAvailable",type:"checkbox",checked:t.isAvailable,onChange:h,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"isAvailable",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"Available for new trips"})]})]}),o.jsxs("fieldset",{className:"space-y-4 p-4 border dark:border-gray-600 rounded-lg",children:[o.jsx("legend",{className:"text-lg font-semibold px-2 dark:text-white",children:"Company Affiliation"}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"company.name",children:"Company Name"}),o.jsx("input",{id:"company.name",name:"company.name",type:"text",value:(y=t.company)==null?void 0:y.name,onChange:h,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"company.website",children:"Company Website"}),o.jsx("input",{id:"company.website",name:"company.website",type:"url",placeholder:"https://example.com",value:(b=t.company)==null?void 0:b.website,onChange:h,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"company.tier",children:"Company Tier"}),o.jsxs("select",{id:"company.tier",name:"company.tier",value:(w=t.company)==null?void 0:w.tier,onCh
4214ange:h,className:"w-full p-2 border rounded border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:[o.jsx("option",{value:"Budget",children:"Budget"}),o.jsx("option",{value:"Mid-range",children:"Mid-range"}),o.jsx("option",{value:"High-end",children:"High-end"}),o.jsx("option",{value:"Mid-range to High-end",children:"Mid-range to High-end"})]})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"company.utbLicensed",name:"company.utbLicensed",type:"checkbox",checked:(E=t.company)==null?void 0:E.utbLicensed,onChange:h,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"company.utbLicensed",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"UTB Licensed"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{id:"company.autoMember",name:"company.autoMember",type:"checkbox",checked:(N=t.company)==null?void 0:N.autoMember,onChange:h,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),o.jsx("label",{htmlFor:"company.autoMember",className:"ml-2 block text-sm text-gray-900 dark:text-gray-200",children:"AUTO Member"})]})]}),o.jsxs("div",{className:"flex justify-end gap-4 pt-4",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:n,children:"Cancel"}),o.jsx(He,{type:"submit",disabled:s,children:s?o.jsx(At,{}):"Add Consultant"})]})]})]})})},ZG=({onClose:n,onUserCreated:e})=>{const[t,r]=R.useState(""),[s,a]=R.useState(""),[c,u]=R.useState(""),[h,f]=R.useState(!1),[p,y]=R.useState("consultant"),[b,w]=R.useState("+256 "),[E,N]=R.useState("Gorilla Trekking, Savannah Wildlife, Bird Watching"),[S,I]=R.useState(""),[O,F]=R.useState(!1),[J,z]=R.useState(null),U=()=>{const k="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%";let _="";for(let M=0;M<10;M++)_+=k.charAt(Math.floor(Math.random()*k.length));u(_),f(!0)},D=async k=>{k.preventDefault(),z(null);const _=t.trim(),M=s.trim().toLowerCase();if(!_){z("Please enter the user full name.");return}if(!M||!M.includes("@")){z("Please enter a valid email address.");return}if(!c||c.length<6){z("Password must be at least 6 characters.");return}if(p==="traveler"){z("Traveler accounts cannot be created from this portal.");return}F(!0);try{const j=await mr.adminCreateUser({name:_,email:M,password:c,role:p,phone:p==="consultant"?b.trim():void 0,specialties:p==="consultant"?E.split(",").map(H=>H.trim()).filter(Boolean):void 0,bio:p==="consultant"?S.trim():void 0});e(j),n()}catch(j){console.error("Error creating user:",j),z(j.message||"An error occurred while creating the user.")}finally{F(!1)}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 z-50 flex justify-center items-center p-4 backdrop-blur-sm",children:o.jsxs("div",{className:"bg-white dark:bg-gray-850 rounded-2xl max-w-xl w-full max-h-[92vh] flex flex-col shadow-2xl border border-gray-200 dark:border-gray-750 overflow-hidden",children:[o.jsxs("div",{className:"p-6 border-b border-gray-100 dark:border-gray-750 flex justify-between items-start",children:[o.jsxs("div",{children:[o.jsx("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-semibold bg-emerald-100 dark:bg-emerald-950/60 text-emerald-800 dark:text-emerald-300 border border-emerald-300 dark:border-emerald-800 mb-2",children:"Super Admin Tool"}),o.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white font-heading",children:"Register New Staff User"}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Create an authenticated back-office or specialist account. Traveler users are excluded and register via the public portal."})]}),o.jsx("button",{onClick:n,disabled:O,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 text-xl font-bold p-1 rounded-lg transition-colors",children:"×"})]}),o.jsxs("form",{onSubmit:D,className:"flex-1 overflow-y-auto p-6 space-y-4",children:[J&&o.jsxs("div",{className:"p-3.5 bg-red-50 dark:bg-red-950/40 border border-red-300 dark:border-red-800 text-red-700 dark:text-red-300 rounded-xl text-xs font-medium flex items-start gap-2",children:[o.jsx("span",{className:"font-bold text-sm leading-none",children:"!"}),o.jsx("span",{children:J})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300 mb-1",children:["Full Name ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"text",required:!0,value:t,onChange:k=>r(k.target.value),placeholder:"e.g. Grace Tumuhimbise",className:"w-full px-3.5 py-2 text-sm border rounded-xl bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-emerald-500 focus:outline-none"})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300 mb-1",children:["Work Email Address ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"email",required:!0,value:s,onChange:k=>a(k.target.value),placeholder:"e.g. [email protected]",className:"w-full px-3.5 py-2 text-sm border rounded-xl bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-emerald-500 focus:outline-none"})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex justify-between items-center mb-1",children:[o.jsxs("label",{className:"block text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300",children:["Initial Password ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("button",{type:"button",onClick:U,className:"text-xs font-semibold text-emerald-600 hover:text-emerald-700 dark:text-emerald-400 dark:hover:text-emerald-300 underline",children:"Generate Password"})]}),o.jsxs("div",{className:"relative",children:[o.jsx("input",{type:h?"text":"password",required:!0,minLength:6,value:c,onChange:k=>u(k.target.value),placeholder:"At least 6 characters",className:"w-full px-3.5 py-2 text-sm border rounded-xl bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-white pr-20 focus:ring-2 focus:ring-emerald-500 focus:outline-none font-mono"}),o.jsx("button",{type:"button",onClick:()=>f(!h),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 font-medium px-2 py-1",children:h?"Hide":"Show"})]}),o.jsx("p",{className:"text-[11px] text-gray-500 dark:text-gray-400 mt-1",children:"The user can update this password after logging in or use the password reset link."})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300 mb-1",children:["Internal Role ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsxs("select",{value:p,onChange:k=>y(k.target.value),className:"w-full px-3.5 py-2.5 text-sm border rounded-xl bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-emerald-500 focus:outline-none",children:[o.jsx("option",{value:"consultant",children:"Safari Consultant (Trip planner, lead respondent & profile in Experts Hub)"}),o.jsx("option",{value:"admin",children:"Administrator (Full back-office, catalog and hub management)"}),o.jsx("option",{value:"demo",children:"Demo / Read-Only QA"})]}
4214),o.jsxs("p",{className:"text-[11px] text-amber-600 dark:text-amber-400 mt-1 flex items-center gap-1",children:[o.jsx("span",{children:"ⓘ"})," Traveler accounts are intentionally excluded from back-office signup."]})]}),p==="consultant"&&o.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800/60 rounded-xl border border-gray-200 dark:border-gray-700 space-y-3",children:[o.jsx("div",{className:"text-xs font-bold text-gray-900 dark:text-white",children:"Consultant Profile Details"}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-[11px] font-semibold text-gray-600 dark:text-gray-400 mb-1",children:"Contact Phone Number"}),o.jsx("input",{type:"text",value:b,onChange:k=>w(k.target.value),placeholder:"+256 700 000 000",className:"w-full px-3 py-1.5 text-xs border rounded-lg bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-emerald-500 focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-[11px] font-semibold text-gray-600 dark:text-gray-400 mb-1",children:"Specialties (Comma Separated)"}),o.jsx("input",{type:"text",value:E,onChange:k=>N(k.target.value),placeholder:"Gorilla Trekking, Bird Watching, Primate Expeditions",className:"w-full px-3 py-1.5 text-xs border rounded-lg bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-emerald-500 focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-[11px] font-semibold text-gray-600 dark:text-gray-400 mb-1",children:"Short Bio (Optional)"}),o.jsx("textarea",{rows:2,value:S,onChange:k=>I(k.target.value),placeholder:"Certified specialist with expertise in custom Uganda gorilla and wildlife itineraries...",className:"w-full px-3 py-1.5 text-xs border rounded-lg bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-emerald-500 focus:outline-none resize-none"})]})]}),o.jsxs("div",{className:"pt-3 border-t border-gray-100 dark:border-gray-750 flex items-center justify-end gap-3",children:[o.jsx("button",{type:"button",onClick:n,disabled:O,className:"px-4 py-2 text-sm font-semibold text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-xl transition-colors",children:"Cancel"}),o.jsxs(He,{type:"submit",disabled:O,className:"!py-2 !px-5 text-sm font-semibold flex items-center gap-2",children:[O&&o.jsx(At,{className:"w-4 h-4 text-white"}),O?"Creating Account...":"Create Staff Account"]})]})]})]})})},eH=({operator:n,onClose:e,onSave:t})=>{const[r,s]=R.useState(""),[a,c]=R.useState(!1),u=n!==null;R.useEffect(()=>{s((n==null?void 0:n.name)||"")},[n]);const h=f=>{if(f.preventDefault(),!r)return;c(!0);const p={id:(n==null?void 0:n.id)||`new_${Date.now()}`,name:r};setTimeout(()=>{t(p),c(!1),e()},500)};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-md m-4",children:[o.jsxs("div",{className:"flex justify-between items-center mb-6",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:u?"Edit Flight Operator":"Add Flight Operator"}),o.jsx("button",{onClick:e,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("form",{onSubmit:h,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"name",children:"Operator Name"}),o.jsx("input",{id:"name",name:"name",type:"text",value:r,onChange:f=>s(f.target.value),required:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{className:"flex justify-end gap-4 pt-4",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(He,{type:"submit",disabled:a,children:a?o.jsx(At,{}):u?"Save Changes":"Add Operator"})]})]})]})})},tH=({cost:n,operators:e,destinations:t,onClose:r,onSave:s})=>{var b,w,E;
4214const[a,c]=R.useState({from:(n==null?void 0:n.from)||((b=t[0])==null?void 0:b.id)||"",to:(n==null?void 0:n.to)||((w=t[1])==null?void 0:w.id)||"",operatorId:(n==null?void 0:n.operatorId)||((E=e[0])==null?void 0:E.id)||"",cost:(n==null?void 0:n.cost)||0}),[u,h]=R.useState(!1),f=n!==null,p=N=>{const{name:S,value:I,type:O}=N.target;c(F=>({...F,[S]:O==="number"?parseFloat(I)||0:I}))},y=N=>{if(N.preventDefault(),!a.from||!a.to||!a.operatorId||a.from===a.to){alert("Please ensure 'From' and 'To' are different and all fields are selected.");return}h(!0);const S={id:(n==null?void 0:n.id)||`new_${Date.now()}`,...a};setTimeout(()=>{s(S),h(!1),r()},500)};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 w-full max-w-lg m-4",children:[o.jsxs("div",{className:"flex justify-between items-center mb-6",children:[o.jsx("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:f?"Edit Flight Cost":"Add Flight Cost"}),o.jsx("button",{onClick:r,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("form",{onSubmit:y,className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"from",children:"From"}),o.jsx("select",{id:"from",name:"from",value:a.from,onChange:p,required:!0,className:"w-full p-2 border rounded bg-white border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:t.filter(N=>N.flyInAirstrip).map(N=>o.jsx("option",{value:N.id,children:N.name},N.id))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"to",children:"To"}),o.jsx("select",{id:"to",name:"to",value:a.to,onChange:p,required:!0,className:"w-full p-2 border rounded bg-white border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:t.filter(N=>N.flyInAirstrip).map(N=>o.jsx("option",{value:N.id,children:N.name},N.id))})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"operatorId",children:"Operator"}),o.jsx("select",{id:"operatorId",name:"operatorId",value:a.operatorId,onChange:p,required:!0,className:"w-full p-2 border rounded bg-white border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:e.map(N=>o.jsx("option",{value:N.id,children:N.name},N.id))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"cost",children:"Cost (per person, one-way)"}),o.jsx("input",{id:"cost",name:"cost",type:"number",value:a.cost,onChange:p,required:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{className:"flex justify-end gap-4 pt-4",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),o.jsx(He,{type:"submit",disabled:u,children:u?o.jsx(At,{}):f?"Save Changes":"Add Cost"})]})]})]})})},fu=n=>`${n}_${Date.now()}`,Mo=({tab:n,label:e,activeTab:t,setActiveTab:r})=>
4214o.jsx("button",{onClick:()=>r(n),className:`px-4 py-2 text-sm font-medium rounded-md transition-colors ${t===n?"bg-blue-600 text-white":"text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e}),nH=()=>{const{state:{destinations:n,lodges:e,loggedInUser:t},navigateTo:r,updateLodgeInContext:s}=an(),a=((t==null?void 0:t.email)||"").toLowerCase()==="[email protected]"||!!(t!=null&&t.isSuperAdmin),[c,u]=R.useState("destinations"),[h,f]=R.useState(n),[p,y]=R.useState(e);R.useEffect(()=>{f(n)},[n]),R.useEffect(()=>{y(e)},[e]);const[b,w]=R.useState([]),[E,N]=R.useState([]),[S,I]=R.useState([]),[O,F]=R.useState([]),[J,z]=R.useState([]),[U,D]=R.useState([]),[k,_]=R.useState(null),[M,j]=R.useState(!1),[H,L]=R.useState(null),[ee,ne]=R.useState(null),[G,W]=R.useState(""),[X,ae]=R.useState(null),[Te,K]=R.useState("date");R.useEffect(()=>{const $=ge.subscribeToDestinations(tn=>{tn&&tn.length>0&&f(tn)}),de=ge.subscribeToLodges(tn=>{tn&&tn.length>0&&y(tn)}),Be=ge.subscribeToConsultants(tn=>{w(tn)}),et=ge.subscribeToReviews(tn=>{N([...tn].sort((no,Sc)=>Sc.id.localeCompare(no.id,void 0,{numeric:!0})))}),vt=ge.subscribeToFlightOperators(tn=>{I(tn)}),Zt=ge.subscribeToFlightCosts(tn=>{F(tn)}),en=ge.subscribeToUsers(tn=>{z(tn)});ge.getAllUsers().then(tn=>{tn&&tn.length>0&&z(tn)});const ua=ge.subscribeToStories(tn=>{D(tn)});return()=>{$(),de(),Be(),et(),vt(),Zt(),en(),ua()}},[]);const fe=R.useMemo(()=>b.reduce(($,de)=>($[de.id]=de.name,$),{}),[b]),Se=R.useMemo(()=>{const $={};for(const Be of E)$[Be.consultantId]||($[Be.consultantId]={total:0,count:0}),$[Be.consultantId].total+=Be.rating,$[Be.consultantId].count+=1;const de={};for(const Be in $)de[Be]=$[Be].total/$[Be].count;return de},[E]),[Ae,ze]=R.useState(null),[lt,dt]=R.useState(!1),[Wt,Ht]=R.useState(null),[Mr,br]=R.useState(!1),[Lr,gt]=R.useState(null),[Ye,In]=R.useState(!1),[Jr,ar]=R.useState(null),[Rs,Ct]=R.useState(!1),[St,Un]=R.useState(null),[Tr,ns]=R.useState(!1),[yn,kt]=R.useState(!1),[re,Ne]=R.useState(null),[De,qe]=R.useState(!1),[je,st]=R.useState(null),[bt,ht]=R.useState(!1),[Qe,it]=R.useState(!1),[jt,kr]=R.useState(!1),[Rn,Vn]=R.useState(!1),[xn,Gn]=R.useState(!1),[It,$n]=R.useState("all"),[Pn,or]=R.useState(""),Li=R.useMemo(()=>{const $={all:J.length,admin:0,consultant:0,traveler:0,demo:0};return J.forEach(de=>{de.role&&$[de.role]!==void 0&&$[de.role]++}),$},[J]),_n=R.useMemo(()=>J.filter($=>{if(It!=="all"&&$.role!==It)return!1;if(Pn.trim()){const de=Pn.trim().toLowerCase(),Be=($.name||"").toLowerCase().includes(de),et=($.email||"").toLowerCase().includes(de);if(!Be&&!et)return!1}return!0}),[J,It,Pn]),Kt=$=>{z(de=>[$,...de.filter(Be=>Be.id!==$.id)]),$.role==="consultant"&&ge.getAllConsultants().then(de=>{w(de)}),ae(`Successfully signed up staff member ${$.name} (${$.email}) with role ${$.role.toUpperCase()}. An onboarding notification has been dispatched.`),setTimeout(()=>ae(null),8e3)},[$e,un]=R.useState(null),[Kn,rs]=R.useState(!1);R.useEffect(()=>{a&&ge.purgeUnregisteredUsersAndConsultants().then($=>{($.deletedUsersCount>0||$.deletedConsultantsCount>0)&&(ge.getAllUsers().then(z),ge.getAllConsultants().then(w))}).catch(()=>{})},[a]);const Hn=async()=>{rs(!0);try{const $=await ge.purgeUnregisteredUsersAndConsultants(),de=await ge.getAllUsers(),Be=await ge.getAllConsultants();z(de),w(Be),$.deletedUsersCount>0||$.deletedConsultantsCount>0?ae(`Cleanup completed: Removed ${$.deletedUsersCount} unregistered user account(s) and ${$.deletedConsultantsCount} mock consultant(s) from Firebase.`):ae("All platform users and consultants are strictly verified and registered in Firebase.")}catch($){ae(`Notice: ${$.message||"Error occurred during cleanup"}`)}finally{rs(!1),setTimeout(()=>ae(null),8e3)}},Rt=$=>{ze($),dt(!0)},Tn=$=>{ge.saveDestination($).then(()=>{f(de=>de.map(Be=>Be.id===$.id?$:Be))})},$r=$=>{Ht($),br(!0)},vr=$=>{Wt&&f(de=>de.map(Be=>Be.id===Wt.destinationId?{...Be,activities:Be.activities.map(et=>et.id===$.id?$:et)}:Be))},Yn=$=>{gt($),In(!0)},on=$=>{ge.saveLodge($).then(()=>{y(de=>de.map(Be=>Be.id===$.id?$:Be)),s($)})},Nt=$=>{ar($),Ct(!0)},Cn=$=>{ge.updateConsultant($).then(de=>{w(Be=>Be.map(et=>et.id===de.id?de:et)),z(Be=>Be.map(et=>et.id===de.id||et.consultantId===de.id?{...et,name:de.name,email:de.email||et.email,imageUrl:de.imageUrl||et.imageUrl}:et)),ae(`Updated profile and email for ${de.name}`),setTimeout(()=>ae(null),6e3)})},jr=$=>{Un($),ns(!0)},bn=$=>{ge.updateReview($).then(de=>{N(Be=>Be.map(et=>et.id===de.id?de:et))})},Nr=$=>{Ne($),kt(!0)},Ps=$=>{($.id.startsWith("new_")?ge.addFlightOperator({...$,id:fu("op")}):ge.updateFlightOperator($)).then(()=>ge.getAllFlightOperators().then(I))},Sr=$=>{st($),qe(!0)},Ws=$=>{($.id.startsWith("new_")?ge.addFlightCost({...$,id:fu("fc")}):ge.updateFlightCost($)).then(()=>ge.getAllFlightCosts().then(F))},ps=$=>{const de={...$,id:fu("dest"),activities:[]};ge.saveDestination(de).then(()=>{f(Be=>[...Be,de])})},Kr=$=>{const de={...$,id:fu("lodge"),rooms:[]};ge.saveLodge(de).then(()=>{y(Be=>[...Be,de])})},ss=($,de)=>{const Be={...$,id:fu("act")};f(et=>et.map(vt=>vt.id===de?{...vt,activities:[...vt.activities,Be]}:vt))},Xs=$=>{const de={...$,id:fu("cons")};ge.addConsultant(de).then(Be=>{w(et=>[...et,Be]),ae(`New consultant ${Be.name} added to the consultants catalog.`),setTimeout(()=>ae(null),6e3)})},qn=($,de)=>{un({...$,type:de})},pl=()=>
4214{if($e){switch($e.type){case"destinations":ge.deleteDestination($e.id).then(()=>{f($=>$.filter(de=>de.id!==$e.id))});break;case"lodges":ge.deleteLodge($e.id).then(()=>{y($=>$.filter(de=>de.id!==$e.id))});break;case"consultants":ge.deleteConsultant($e.id).then(()=>{w($=>$.filter(de=>de.id!==$e.id)),z($=>$.filter(de=>de.id!==$e.id&&de.consultantId!==$e.id)),ae(`Consultant ${$e.name} deleted.`),setTimeout(()=>ae(null),5e3)});break;case"users":ge.deleteUser($e.id).then(()=>{z($=>$.filter(de=>de.id!==$e.id)),w($=>$.filter(de=>{var Be,et;return de.id!==$e.id&&((Be=de.email)==null?void 0:Be.toLowerCase())!==((et=$e.name)==null?void 0:et.toLowerCase())})),ae(`Successfully removed user ${$e.name} from Firebase.`),setTimeout(()=>ae(null),5e3)});break;case"activities":f($=>$.map(de=>({...de,activities:de.activities.filter(Be=>Be.id!==$e.id)})));break;case"reviews":ge.deleteReview($e.id).then(()=>{N($=>$.filter(de=>de.id!==$e.id))});break;case"flightOperators":ge.deleteFlightOperator($e.id).then(()=>{I($=>$.filter(de=>de.id!==$e.id))});break;case"flightCosts":ge.deleteFlightCost($e.id).then(()=>{F($=>$.filter(de=>de.id!==$e.id))});break;case"stories":ge.deleteStory($e.id).then(()=>{D($=>$.filter(de=>de.id!==$e.id))});break}un(null)}},Bl=async($,de)=>{const Be=J.find(vt=>vt.id===$);if(!Be)return;const et={...Be,status:de};await ge.saveUserProfile(et),z(vt=>vt.map(Zt=>Zt.id===$?et:Zt))},Zs=async($,de)=>{const Be=J.find(Zt=>Zt.id===$);if(!Be)return;const et=Be.consultantId||Be.id,vt={...Be,role:de,consultantId:de==="consultant"?et:Be.consultantId};if(de==="consultant"){if(!b.find(en=>en.id===et||en.email&&Be.email&&en.email.toLowerCase()===Be.email.toLowerCase())){const en={id:et,name:Be.name||"Safari Consultant",email:Be.email||`${(Be.name||"consultant").toLowerCase().replace(/\s+/g,".")}@ugandasafari.com`,phone:"+256 700 000 000",bio:`${Be.name} is a certified Uganda Safari Specialist and travel planner with deep expertise in custom gorilla trekking, wildlife safaris, and primate expeditions.`,imageUrl:Be.imageUrl||"https://images.unsplash.com/photo-1534528741775-53994a69daeb?auto=format&fit=crop&q=80&w=600",specialties:["Gorilla Trekking","Primate Safaris","Savannah Wildlife","Bird Watching"],isAvailable:!0,commissionRate:.15,canSetCommissionRate:!0,showCommissionRateOnProfile:!0,socials:{linkedin:"",instagram:"",facebook:""},company:{name:"Uganda Safari Specialists",website:"https://ugandasafari.com",tier:"Mid-range to High-end",utbLicensed:!0,autoMember:!0}};await ge.addConsultant(en),w(ua=>[...ua.filter(tn=>tn.id!==et),en])}ae(`Assigned Consultant role to ${Be.name}. They now appear in the Consultants tab.`)}else ae(`Updated role for ${Be.name} to ${de}.`);await ge.saveUserProfile(vt),z(Zt=>Zt.map(en=>en.id===$?vt:en)),setTimeout(()=>ae(null),6e3)},ei=async $=>{if($.preventDefault(),!ee||!G.trim())return;const de=G.trim();await ge.updateUserEmail(ee.id,de),z(et=>et.map(vt=>vt.id===ee.id?{...vt,email:de}:vt));const Be=ee.consultantId||(ee.role==="consultant"?ee.id:null);Be&&w(et=>et.map(vt=>vt.id===Be?{...vt,email:de}:vt)),ae(`Updated email address for ${ee.name} to ${de}`),setTimeout(()=>ae(null),6e3),ne(null)},yl=[{header:"Name",accessor:$=>o.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:$.name})},{header:"Email",accessor:$=>o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:$.email||"N/A"}),o.jsx("button",{onClick:()=>{ne($),W($.email||"")},title:"Edit User Email",className:"text-xs text-emerald-600 hover:text-emerald-700 dark:text-emerald-400 dark:hover:text-emerald-300 font-semibold px-1.5 py-0.5 rounded hover:bg-emerald-50 dark:hover:bg-emerald-950/40",children:"Edit"})]})},{header:"Account Type",accessor:$=>{const de=$.isSuperAdmin||$.email&&$.email.toLowerCase()==="[email protected]";return o.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-md ${de?"bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-300 border border-amber-300 dark:border-amber-700":$.consultantId||$.role==="consultant"?"bg-blue-50 text-blue-800 dark:bg-blue-950/50 dark:text-blue-300":"text-gray-600 dark:text-gray-300"}`,children:de?"★ Super Administrator":$.consultantId||$.role==="consultant"?"Linked Safari Expert"
4214:"Direct Traveler"})}},{header:"Role",accessor:$=>{const de={admin:"bg-red-100 text-red-800 dark:bg-red-950 dark:text-red-300",consultant:"bg-blue-100 text-blue-800 dark:bg-blue-950 dark:text-blue-300",traveler:"bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-300",demo:"bg-purple-100 text-purple-800 dark:bg-purple-950 dark:text-purple-300"};return o.jsx("span",{className:`px-2.5 py-1 text-xs font-semibold rounded-full capitalize ${de[$.role]||"bg-gray-100"}`,children:$.role})}},{header:"Assign Role",accessor:$=>$.isSuperAdmin||$.email&&$.email.toLowerCase()==="[email protected]"?o.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:"Permanent Super Admin"}):o.jsxs("select",{value:$.role,onChange:Be=>Zs($.id,Be.target.value),className:"text-xs border rounded-lg px-2.5 py-1.5 bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 focus:ring-2 focus:ring-emerald-500 focus:outline-none",children:[o.jsx("option",{value:"traveler",children:"Traveler"}),o.jsx("option",{value:"consultant",children:"Consultant"}),o.jsx("option",{value:"admin",children:"Admin"}),o.jsx("option",{value:"demo",children:"Demo"})]})},{header:"Status",accessor:$=>{const de={active:"bg-green-100 text-green-800 dark:bg-green-950 dark:text-green-300",pending:"bg-amber-100 text-amber-800 dark:bg-amber-950 dark:text-amber-300",deactivated:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300"},Be=$.status||"active";return o.jsx("span",{className:`px-2.5 py-1 text-xs font-semibold rounded-full capitalize ${de[Be]||"bg-gray-100"}`,children:Be})}},{header:"Assign Status",accessor:$=>o.jsxs("select",{value:$.status||"active",onChange:de=>Bl($.id,de.target.value),className:"text-xs border rounded-lg px-2.5 py-1.5 bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 focus:ring-2 focus:ring-emerald-500 focus:outline-none",children:[o.jsx("option",{value:"active",children:"Active (Approved)"}),o.jsx("option",{value:"pending",children:"Pending"}),o.jsx("option",{value:"deactivated",children:"Deactivated"})]})},{header:"Authentication & Password",accessor:$=>o.jsx("button",{onClick:async()=>{if($.email){try{await mr.sendPasswordReset($.email),ae(`Success: Password reset email sent to ${$.email}`)}catch(de){de.code==="auth/user-not-found"?ae(`Notice: ${$.email} has not activated their Firebase Auth login yet. They can activate it anytime by clicking "Sign Up" in the login window.`):ae(`Notice: ${de.message||"Unable to send reset email"}`)}setTimeout(()=>ae(null),8e3)}},className:"text-xs font-semibold text-emerald-600 hover:text-emerald-700 dark:text-emerald-400 hover:underline",children:"Send Reset Email →"})}],xl=[{label:"Delete",onClick:$=>{if($.isSuperAdmin||$.email&&$.email.toLowerCase()==="[email protected]"){ae("Action restricted: Cannot delete the permanent Super Administrator account."),setTimeout(()=>ae(null),5e3);return}qn({id:$.id,name:`${$.name} (${$.email||"no email"})`},"users")},className:"!text-red-600 hover:!text-red-800"}],Cl=[{header:"Name",accessor:"name"},{header:"Short Code",accessor:"shortCode"},{header:"Park Fee",accessor:$=>`$${$.parkFee}`},{header:"Activities",accessor:$=>$.activities.length}],Nc=[{header:"Name",accessor:"name"},{header:"Destination",accessor:$=>{var de;return((de=h.find(Be=>Be.id===$.destinationId))==null?void 0:de.name)||"N/A"}},{header:"Rooms & Rack Rates",accessor:$=>{const de=$.rooms.length;if(de===0)return o.jsx("span",{className:"text-gray-400 text-xs",children:"No rooms"});const Be=[];$.rooms.forEach(en=>{en.lowSeasonPriceSingle&&Be.push(en.lowSeasonPriceSingle),en.lowSeasonPriceDouble&&Be.push(en.lowSeasonPriceDouble),en.lowSeasonPricePerNight&&Be.push(en.lowSeasonPricePerNight),en.highSeasonPriceSingle&&Be.push(en.highSeasonPriceSingle),en.highSeasonPriceDouble&&Be.push(en.highSeasonPriceDouble),en.highSeasonPricePerNight&&Be.push(en.highSeasonPricePerNight)});const et=Be.length?Math.min(...Be):null,vt=Be.length?Math.max(...Be):null,Zt=et!==null&&vt!==null?et===vt?`$${et}`:`$${et} - $${vt}`:"Unpriced";return o.jsxs("div",{children:[o.jsxs("div",{className:"font-semibold text-xs text-gray-800 dark:text-gray-200",children:[de," room",de>1?"s":""]}),o.jsx("div",{className:"text-[11px] text-emerald-600 dark:text-emerald-400 font-medium",children:Zt})]})}},{header:"Consultant Overrides",accessor:$=>{const de=b.filter(Be=>{var et;return(et=Be.lodgeRates)==null?void 0:et.some(vt=>vt.lodgeId===$.id)});return de.length===0?o.jsx("span",{className:"text-gray-400 text-xs italic",children:"Standard (Rack only)"}):o.jsx("div",{className:"flex flex-wrap gap-1",children:de.map(Be=>{var Zt;const et=(Zt=Be.lodgeRates)==null?void 0:Zt.find(en=>en.lodgeId===$.id),vt=et?((et.commission||0)*100).toFixed(0):"0";return o.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[11px] font-semibold bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300 border border-emerald-200 dark:border-emerald-800",title:`${Be.name}: ${vt}% commission`,children:[Be.name,": ",vt,"%"]},Be.id)})})}}],eo=[{header:"Consultant",accessor:$=>o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("img",{src:$.imageUrl||"https://images.unsplash.com/photo-153452874
42141775-53994a69daeb?auto=format&fit=crop&q=80&w=600",alt:$.name,className:"w-10 h-10 rounded-full object-cover border border-amber-200 dark:border-gray-700 shrink-0 shadow-sm"}),o.jsxs("div",{children:[o.jsx("div",{className:"font-semibold text-gray-900 dark:text-white leading-tight",children:$.name}),o.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:$.email})]})]})},{header:"Negotiated Lodges & Commissions",accessor:$=>!$.lodgeRates||$.lodgeRates.length===0?o.jsx("span",{className:"text-gray-400 text-xs italic",children:"Standard rack rates"}):o.jsx("div",{className:"flex flex-wrap gap-1 max-w-xs",children:$.lodgeRates.map(de=>{const Be=p.find(Zt=>Zt.id===de.lodgeId),et=(Be==null?void 0:Be.name)||de.lodgeId,vt=((de.commission||0)*100).toFixed(0);return o.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[11px] font-medium bg-amber-50 text-amber-900 dark:bg-amber-950/40 dark:text-amber-300 border border-amber-200 dark:border-amber-800",title:`${et}: ${vt}% commission`,children:[et,": ",vt,"%"]},de.lodgeId)})})},{header:"Platform Fee",accessor:$=>$.adminCommissionRateOverride!==void 0?o.jsxs("span",{className:"text-xs font-semibold text-purple-600 dark:text-purple-400",children:["Admin: ",($.adminCommissionRateOverride*100).toFixed(1),"%"]}):o.jsxs("span",{className:"text-xs text-gray-700 dark:text-gray-300",children:[(($.commissionRate||0)*100).toFixed(1),"%"]})},{header:"Avg. Rating",accessor:$=>Se[$.id]?Se[$.id].toFixed(2):"N/A"},{header:"Specialties",accessor:$=>($.specialties||[]).join(", ")}],is=[{header:"Activity Name",accessor:"name"},{header:"Destination",accessor:"destinationName"},{header:"Price",accessor:$=>`$${$.price}`}],Qn=[{header:"Traveler",accessor:"travelerName"},{header:"Comment",accessor:$=>o.jsx("span",{className:"line-clamp-2",children:$.comment})},{header:"Rating",accessor:"rating"},{header:"Consultant",accessor:"consultantName"}],lr=[{header:"Name",accessor:"name"}],ji=[{header:"From",accessor:"fromName"},{header:"To",accessor:"toName"},{header:"Operator",accessor:"operatorName"},{header:"Cost",accessor:$=>`$${$.cost}`}],bl=R.useMemo(()=>h.flatMap($=>$.activities.map(de=>({...de,destinationId:$.id,destinationName:$.name}))),[h]),Xt=R.useMemo(()=>E.map($=>({...$,consultantName:fe[$.consultantId]||"N/A"})).sort(($,de)=>{if(Te==="consultant"){const Be=$.consultantName.localeCompare(de.consultantName);return Be!==0?Be:de.id.localeCompare($.id,void 0,{numeric:!0})}return de.id.localeCompare($.id,void 0,{numeric:!0})}),[E,fe,Te]),la=R.useMemo(()=>{const $=new Map(h.map(Be=>[Be.id,Be.name])),de=new Map(S.map(Be=>[Be.id,Be.name]));return O.map(Be=>({...Be,fromName:$.get(Be.from)||Be.from,toName:$.get(Be.to)||Be.to,operatorName:de.get(Be.operatorId)||"N/A"}))},[O,S,h]),as=R.useMemo(()=>U.filter($=>$.status==="pending").length,[U]),ca=[{header:"Title",accessor:$=>o.jsxs("div",{className:"max-w-xs",children:[o.jsx("button",{onClick:()=>_($),className:"font-bold text-left text-blue-600 dark:text-blue-400 hover:underline line-clamp-1",children:$.title}),o.jsx("p",{className:"text-xs text-gray-500 line-clamp-1",children:$.summary})]})},{header:"Author",accessor:$=>o.jsx("span",{className:"text-xs font-semibold",children:$.authorName})},{header:"Category",accessor:$=>o.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-semibold bg-blue-50 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300",children:$.category})},{header:"Status",accessor:$=>o.jsx("span",{className:`px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider ${$.status==="published"?"bg-green-100 text-green-800 dark:bg-green-900/50 dark:text-green-300":$.status==="pending"?"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-300":$.status==="rejected"?"bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-300":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}`,children:$.status})},{header:"Featured",accessor:$=>o.jsx("button",{onClick:async()=>{await ge.updateStory($.id,{featured:!$.featured})},className:`px-2 py-0.5 rounded text-xs font-bold transition-colors ${$.featured?"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-300 hover:bg-amber-200":"text-gray-400 hover:text-gray-600 bg-gray-100 dark:bg-gray-800"}`,title:"Toggle Featured on homepage",children:$.featured?"★ Featured":"☆ Standard"})},{header:"Moderation",accessor:$=>o.jsxs("div",{className:"flex items-center gap-1.5",children:[$.status!=="published"&&o.jsx("button",{onClick:async()=>{await ge.approveStory($.id)},className:"px-2.5 py-1 bg-green-600 hover:bg-green-700 text-white rounded text-xs font-bold transition-colors",children:"Approve"}),$.status==="pending"&&o.jsx("button",{onClick:async()=>{const de=window.prompt("Enter rejection feedback for the author:");de!==null&&await ge.rejectStory($.id,de||void 0)},className:"px-2.5 py-1 bg-red-600 hover:bg-red-700 text-white rounded text-xs font-bold transition-colors",children:"Reject"}),o.jsx("button",{onClick:()=>_($),className:"px-2 py-1 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 text-gray-700 dark:text-gray-300 rounded text-xs font-medium",children:"Read"})]})}],zn=($,de)=>[{label:"Edit",onClick:de},{label:"Delete",onClick:Be=>qn({id:Be.id,name:Be.name||Be.title||Be.travelerName||"this item"},$),className:"!text-red-600 hover:!text-red-800"}],to=()=>{const $=o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium",children:"Sort by:"}),o.jsx("button",{onClick:()=>K("date"),className:`px-3 py-1 rounded-md transition-colors ${Te==="date"?"bg-blue-600 text-white font-semibold":"text-gray-600 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600"}`,children:"Date"}),o.jsx("button",{onClick:()=>K("consultant"),className:`px-3 py-1 rounded-md transition-colors ${Te==="consultant"?"bg-blue-600 text-white font-semibold":"text-gray-600 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600"}`,children:"Consultant"})]});
4214switch(c){case"destinations":return o.jsx(Da,{title:"Manage Destinations",columns:Cl,data:h,actions:zn("destinations",Rt),onAddItem:()=>ht(!0)});case"lodges":return o.jsx(Da,{title:"Manage Lodges",columns:Nc,data:p,actions:zn("lodges",Yn),onAddItem:()=>it(!0)});case"consultants":return o.jsx(Da,{title:"Manage Consultants",columns:eo,data:b,actions:zn("consultants",Nt),onAddItem:()=>Vn(!0)});case"activities":return o.jsx(Da,{title:"Manage Activities",columns:is,data:bl,actions:zn("activities",$r),onAddItem:()=>kr(!0)});case"reviews":return o.jsx(Da,{title:"Manage Reviews",columns:Qn,data:Xt,actions:zn("reviews",jr),headerContent:$});case"flights":return o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsx("div",{className:"lg:col-span-1",children:o.jsx(Da,{title:"Flight Operators",columns:lr,data:S,actions:zn("flightOperators",Nr),onAddItem:()=>{Ne(null),kt(!0)}})}),o.jsx("div",{className:"lg:col-span-2",children:o.jsx(Da,{title:"Flight Leg Costs",columns:ji,data:la,actions:zn("flightCosts",Sr),onAddItem:()=>{st(null),qe(!0)}})})]});case"users":return a?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-4 rounded-xl text-sm text-blue-800 dark:text-blue-300 flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2 bg-blue-100 dark:bg-blue-900 rounded-lg text-blue-700 dark:text-blue-300 shrink-0",children:o.jsx(HP,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("strong",{children:"Super Admin User Access Control:"})," Manage real authenticated platform users. Super admins can sign up staff accounts (excluding traveler accounts which register publicly), filter users by role, and adjust privileges in real-time."]})]}),o.jsx("span",{className:"px-3 py-1 bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 rounded-full text-xs font-semibold self-start sm:self-auto whitespace-nowrap",children:"Super Admin Only"})]}),X&&o.jsxs("div",{className:"p-3 bg-amber-50 dark:bg-amber-950/40 border border-amber-300 dark:border-amber-700 text-amber-900 dark:text-amber-200 rounded-xl text-xs font-medium flex items-center justify-between",children:[o.jsx("span",{children:X}),o.jsx("button",{onClick:()=>ae(null),className:"text-amber-700 hover:text-amber-900 font-bold ml-2 text-sm leading-none",children:"×"})]}),o.jsxs("div",{className:"bg-white dark:bg-gray-850 p-4 rounded-xl border border-gray-200 dark:border-gray-750 shadow-sm flex flex-col md:flex-row items-stretch md:items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsxs("span",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 flex items-center gap-1 mr-1",children:[o.jsx(YN,{className:"w-3.5 h-3.5"})," Role Filter:"]}),["all","admin","consultant","traveler","demo"].map(de=>{const Be=It===de,et={all:"All Users",admin:"Admins",consultant:"Consultants",traveler:"Travelers",demo:"Demo"};return o.jsxs("button",{onClick:()=>$n(de),className:`px-3 py-1.5 rounded-lg text-xs font-semibold transition-all flex items-center gap-1.5 ${Be?"bg-emerald-600 text-white shadow-sm ring-2 ring-emerald-500/30":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:[o.jsx("span",{children:et[de]}),o.jsx("span",{className:`px-1.5 py-0.2 rounded-full text-[10px] ${Be?"bg-emerald-700 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:Li[de]||0})]},de)})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("button",{onClick:Hn,disabled:Kn,title:"Remove any mock, test, or unregistered accounts from Firebase and local cache",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold text-rose-700 dark:text-rose-300 bg-rose-50 dark:bg-rose-950/40 hover:bg-rose-100 dark:hover:bg-rose-900/50 border border-rose-200 dark:border-rose-800 transition-colors disabled:opacity-50 whitespace-nowrap shadow-xs",children:[o.jsx(nM,{className:`w-3.5 h-3.5 ${Kn?"animate-spin":""}`}),Kn?"Cleaning Up...":"Clean Up Unregistered"]}),o.jsxs("div",{className:"relative min-w-[200px] max-w-xs",children:[o.jsx(yh,{className:"w-4 h-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none"}),o.jsx("input",{type:"text",placeholder:"Search by name or email...",value:Pn,onChange:de=>or(de.target.value),className:"w-full pl-9 pr-8 py-1.5 text-xs rounded-lg border border-gray-300 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-emerald-500"}),Pn&&o.jsx("button",{onClick:()=>or(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:o.jsx(bc,{className:"w-3.5 h-3.5"})})]})]})]}),o.jsx(Da,{title:"Platform Users & Access",columns:yl,data:_n,actions:xl,onAddItem:()=>Gn(!0),addItemLabel:"+ Sign Up Staff User",pagination:{pageSize:10,showPageSizeOptions:!0}})]}):o.jsxs("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-300 dark:border-amber-800 p-8 rounded-2xl text-center space-y-3",children:[o.jsx("div",{className:"w-12 h-12 bg-amber-100 dar
4214k:bg-amber-900/50 rounded-full flex items-center justify-center mx-auto text-amber-700 dark:text-amber-300 font-bold text-xl",children:"🔒"}),o.jsx("h3",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Super Administrator Access Required"}),o.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300 max-w-md mx-auto",children:["Only the designated Super Administrator (",o.jsx("span",{className:"font-semibold text-emerald-600 dark:text-emerald-400",children:"[email protected]"}),") has authorization to view, manage, and assign user credentials and access levels."]})]});case"stories":return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-4 rounded-xl text-sm text-blue-800 dark:text-blue-300 flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"Safari Stories Editorial Queue:"})," Review traveler and guide submissions, approve stories for publication, feature stories on the landing page, or edit content."]}),as>0&&o.jsxs("span",{className:"px-3 py-1 rounded-full bg-amber-500 text-gray-950 font-bold text-xs whitespace-nowrap self-start sm:self-auto",children:[as," Pending Review"]})]}),o.jsx(Da,{title:"Stories & Expedition Journals",columns:ca,data:U,actions:zn("stories",de=>{L(de),j(!0)}),onAddItem:()=>{L(null),j(!0)}})]});default:return null}};return o.jsxs("div",{className:"max-w-7xl mx-auto space-y-6",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("h1",{className:"text-4xl font-bold text-brand-dark dark:text-white font-heading",children:"Admin Hub"}),o.jsx("p",{className:"text-lg mt-2 text-gray-600 dark:text-gray-300",children:"Manage your platform's core data."}),o.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-semibold bg-emerald-50 dark:bg-emerald-950/40 text-emerald-700 dark:text-emerald-300 border border-emerald-200 dark:border-emerald-800 shadow-sm mt-3",children:[o.jsxs("span",{className:"relative flex h-2 w-2",children:[o.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),o.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]}),"Live Database Sync"]})]}),o.jsxs("div",{className:"flex justify-center flex-wrap gap-4 p-2 bg-gray-100 dark:bg-gray-900 rounded-lg",children:[o.jsx(Mo,{tab:"destinations",label:"Destinations",activeTab:c,setActiveTab:u}),o.jsx(Mo,{tab:"lodges",label:"Lodges",activeTab:c,setActiveTab:u}),o.jsx(Mo,{tab:"activities",label:"Activities",activeTab:c,setActiveTab:u}),o.jsx(Mo,{tab:"consultants",label:"Consultants",activeTab:c,setActiveTab:u}),o.jsx(Mo,{tab:"reviews",label:"Reviews",activeTab:c,setActiveTab:u}),o.jsx(Mo,{tab:"flights",label:"Flights",activeTab:c,setActiveTab:u}),a&&o.jsx(Mo,{tab:"users",label:"Users & Access",activeTab:c,setActiveTab:u}),o.jsx(Mo,{tab:"stories",label:as>0?`Stories (${as})`:"Stories",activeTab:c,setActiveTab:u}),o.jsx("button",{onClick:()=>r(Le.TripManagement),className:"px-4 py-2 text-sm font-semibold rounded-md transition-all text-white bg-emerald-600 hover:bg-emerald-700 shadow-sm flex items-center gap-1.5",title:"Go to Trip Management",children:o.jsx("span",{children:"Trip Management →"})})]}),o.jsx("div",{children:to()}),lt&&o.jsx(UG,{destination:Ae,onClose:()=>dt(!1),onSave:Tn}),Mr&&o.jsx(VG,{activity:Wt,onClose:()=>br(!1),onSave:vr}),Ye&&o.jsx(HG,{lodge:Lr,destinations:h,onClose:()=>In(!1),onSave:on}),Rs&&o.jsx(qG,{consultant:Jr,lodges:p,onClose:()=>Ct(!1),onSave:Cn}),Tr&&o.jsx(zG,{review:St,onClose:()=>ns(!1),onSave:bn}),yn&&o.jsx(eH,{operator:re,onClose:()=>kt(!1),onSave:Ps}),De&&o.jsx(tH,{cost:je,operators:S,destinations:h,onClose:()=>qe(!1),onSave:Ws}),bt&&o.jsx($G,{onClose:()=>ht(!1),onSave:ps}),Qe&&o.jsx(KG,{destinations:h,onClose:()=>it(!1),onSave:Kr}),jt&&o.jsx(QG,{destinations:h,onClose:()=>kr(!1),onSave:ss}),Rn&&o.jsx(XG,{onClose:()=>Vn(!1),onSave:Xs}),xn&&o.jsx(ZG,{onClose:()=>Gn(!1),onUserCreated:Kt}),ee&&o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50 p-4",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-xl max-w-md w-full p-6 space-y-4",children:[o.jsxs("div",{className:"flex justify-between items-center pb-2 border-b dark:border-gray-700",children:[o.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Edit User Email"}),o.jsx("button",{onClick:()=>ne(null),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 text-xl font-bold",children:"×"})]}),o.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Updating the email for ",o.jsx("strong",{children:ee.name}
4214)," (",ee.role,"). If this user is a safari consultant, their public and internal consultant profile will be kept in sync automatically."]}),o.jsxs("form",{onSubmit:ei,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-semibold uppercase text-gray-700 dark:text-gray-300 mb-1",htmlFor:"user-new-email",children:"Email Address"}),o.jsx("input",{id:"user-new-email",type:"email",value:G,onChange:$=>W($.target.value),required:!0,className:"w-full p-2.5 border rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white text-sm focus:ring-2 focus:ring-emerald-500 focus:outline-none",placeholder:"[email protected]"})]}),o.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[o.jsx(He,{type:"button",variant:"secondary",onClick:()=>ne(null),children:"Cancel"}),o.jsx(He,{type:"submit",variant:"primary",children:"Save Email"})]})]})]})}),M&&t&&o.jsx(AA,{isOpen:M,onClose:()=>{j(!1),L(null)},onSubmit:async $=>{H?await ge.updateStory(H.id,$):await ge.createStory($,t),j(!1),L(null)},currentUser:t,initialStory:H}),k&&o.jsx(IA,{story:k,isOpen:!!k,onClose:()=>_(null),currentUser:t,onLike:async $=>{await ge.toggleStoryLike($)},onApprove:async $=>{await ge.approveStory($),_(de=>de?{...de,status:"published"}:null)},onReject:async($,de)=>{await ge.rejectStory($,de),_(Be=>Be?{...Be,status:"rejected",rejectionReason:de}:null)},onDelete:async $=>{await ge.deleteStory($),_(null)},onEdit:$=>{_(null),L($),j(!0)}}),o.jsxs(DA,{isOpen:!!$e,onClose:()=>un(null),onConfirm:pl,title:"Confirm Deletion",confirmText:"Delete",children:["Are you sure you want to delete ",o.jsx("strong",{children:$e==null?void 0:$e.name}),"? This action cannot be undone."]})]})},rH=(n,e,t,r)=>{if(n.pricingModel==="perNight"){const s=t==="high"?"highSeasonPricePerNight":"lowSeasonPricePerNight";return(e==null?void 0:e[s])??n[s]??0}if(r===1){const s=t==="high"?"highSeasonPriceSingle":"lowSeasonPriceSingle";return(e==null?void 0:e[s])??n[s]??0}else if(r>1){const s=t==="high"?"highSeasonPriceDouble":"lowSeasonPriceDouble";return((e==null?void 0:e[s])??n[s]??0)*r}return 0},sH=n=>{if(!n)return 0;if(typeof n.adminCommissionRateOverride=="number"&&n.adminCommissionRateOverride>=0)return n.adminCommissionRateOverride;if(n.canSetCommissionRate??!0){const e=n.commissionRate||0;return Math.min(e,.25)}return 0},qT=(n,e,t,r,s,a)=>{var F,J;if(!n)return{totalPrice:0,pricePerPerson:0,commissionableSubtotal:0,nonCommissionableSubtotal:0,consultancyFee:0};const c=(z,U,D)=>{if(D){const _=t.find(M=>(M.from===z&&M.to===U||M.from===U&&M.to===z)&&M.operatorId===D);if(_)return _.cost}const k=t.find(_=>_.from===z&&_.to===U||_.from===U&&_.to===z);return(k==null?void 0:k.cost)||Xo.flyIn};let u=0,h=0,f=0;const p=new Date(n.startDate),y=n.travelerCount;n.stops.forEach(z=>{var G,W;const{destinationId:U,lodgeId:D,roomId:k,numberOfNights:_,activities:M}=z,j=s.find(X=>X.id===U),H=a.find(X=>X.id===D),L=H==null?void 0:H.rooms.find(X=>X.id===k),ee=(G=e==null?void 0:e.lodgeRates)==null?void 0:G.find(X=>X.lodgeId===D),ne=(W=ee==null?void 0:ee.sellingRateOverrides)==null?void 0:W.find(X=>X.roomId===k);if(H&&L&&y>0){const X=Math.ceil(y/L.maxOccupancy);let ae=y;for(let Te=0;Te<X;Te++){const K=Math.min(ae,L.maxOccupancy);ae-=K;for(let fe=0;fe<_;fe++){const Se=kC(p,f+fe),Ae=TC(Se);u+=rH(L,ne,Ae,K)}}}if(j){const X=new Map;M.forEach((ae,Te)=>{let K=!1;ae.forEach(fe=>{const Se=j.activities.find(Ae=>Ae.id===fe);if(Se){let Ae=0;switch(Se.unit){case"per person":Ae=Se.price*y;break;default:Ae=Se.price;break}Se.includesParkEntryFee?h+=Ae:(u+=Ae,K=!0),Se.permitProcessingFee&&(u+=Se.permitProcessingFee*y)}}),K&&j.parkFee>0&&!X.has(Te)&&(h+=j.parkFee*y,X.set(Te,!0))})}f+=_});let b=0;const w=n.transportSettings||[];w.forEach((z,U)=>{var D,k;if(z.type==="fly-in"){const _=U===0?n.startLocation:(D=n.stops[U-1])==null?void 0:D.destinationId,M=U>=n.stops.length?n.endLocation:(k=n.stops[U])==null?void 0:k.destinationId;_&&M&&(b+=c(_,M,z.operatorId)*y)}}),h+=b;let E=0;const N=n.duration>0?n.duration+1:0;if(N>0){const z=["entebbe","kigali","kampala"],U=n.stops.findIndex(D=>!z.includes(D.destinationId));if(U!==-1){let D=n.stops.length-1;for(let j=n.stops.length-1;j>=0;j--)if(!z.includes(n.stops[j].destinationId)){D=j;break}const k=n.stops.slice(0,U).reduce((j,H)=>j+H.numberOfNights,0),_=n.stops.slice(D+1).reduce((j,H)=>j+H.numberOfNights,0),M=Math.max(0,N-(k+_));if(M>0){const j=w.find(G=>G.type==="road"),H=(j==null?void 0:j.vehicle)??"cruiser",L=(J=(F=e==null?void 0:e.transportRates)==null?void 0:F.road)==null?void 0:J[H],ee=typeof L=="number"?L:Xo.road[H],ne=Math.ceil(y/7);E=M*ee*ne}}}u+=E;const S=sH(e),I=u*S,O=u+h+I;return{totalPrice:O,pricePerPerson:y>0?O/y:0,commissionableSubtotal:u,nonCommissionableSubtotal:h,consultancyFee:I}},iH=({consultant:n,isSelected:e,onSelect:t,onLearnMore:r})=>
4214o.jsxs("div",{className:`p-4 border rounded-lg transition-all duration-200 ${e?"bg-white dark:bg-gray-800 border-blue-500 dark:border-blue-400 ring-2 ring-blue-200 dark:ring-blue-500/50":"bg-gray-50 dark:bg-gray-700/50 border-gray-200 dark:border-gray-700"}`,children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("img",{src:n.imageUrl,alt:n.name,className:"w-16 h-16 rounded-full object-cover"}),o.jsxs("div",{className:"flex-grow",children:[o.jsx("h3",{className:"font-bold text-lg text-brand-dark dark:text-white",children:n.name}),o.jsx("div",{className:"flex items-center gap-2",children:n.reviewCount>0?o.jsxs(o.Fragment,{children:[o.jsx(Wa,{rating:n.avgRating}),o.jsxs("span",{className:"text-xs",children:["(",n.reviewCount,")"]})]}):o.jsx("span",{className:"text-xs text-gray-500",children:"(0 reviews)"})})]})]}),o.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-2 truncate",children:n.specialties.join(" • ")}),o.jsxs("div",{className:"mt-4 flex gap-2",children:[o.jsx(He,{onClick:t,className:"w-full !py-1.5 text-sm",variant:e?"primary":"secondary",children:e?"✓ Selected":"Select"}),o.jsx("button",{type:"button",onClick:r,className:"w-full text-center text-sm font-semibold text-blue-600 dark:text-blue-400 hover:underline focus:outline-none focus:ring-2 focus:ring-blue-300 rounded-md",children:"Learn More"})]})]}),aH=({consultant:n})=>o.jsx("div",{className:"p-4 border dark:border-gray-700 rounded-lg bg-white dark:bg-gray-700 ring-2 ring-blue-500 dark:ring-blue-400",children:o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("img",{src:n.imageUrl,alt:n.name,className:"w-20 h-20 rounded-full object-cover"}),o.jsxs("div",{className:"flex-grow",children:[o.jsx("h3",{className:"font-bold text-xl text-brand-dark dark:text-white",children:n.name}),o.jsx("div",{className:"flex items-center gap-2 mt-1",children:n.reviewCount>0?o.jsxs(o.Fragment,{children:[o.jsx(Wa,{rating:n.avgRating}),o.jsxs("span",{className:"text-xs",children:["(",n.reviewCount,")"]})]}):o.jsx("span",{className:"text-xs text-gray-500",children:"(0 reviews)"})}),o.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-2",children:n.specialties.join(" • ")})]})]})}),oH=({itinerary:n,travelerName:e,travelerEmail:t,travelerPhone:r,preSelectedConsultantId:s})=>{var Lr;const{state:{destinations:a,lodges:c}}=an(),{state:{isBookingDetailsVerified:u},navigateTo:h,selectConsultantProfile:f,updateBookingTravelerName:p,updateBookingTravelerEmail:y,updateBookingTravelerPhone:b,setBookingVerified:w}=an(),[E,N]=R.useState([]),[S,I]=R.useState(s),[O,F]=R.useState(!1),[J,z]=R.useState(!0),[U,D]=R.useState(!1),[k,_]=R.useState([]),[M,j]=R.useState([]),[H,L]=R.useState(!1),[ee,ne]=R.useState(""),[G,W]=R.useState("idle"),[X,ae]=R.useState(""),Te=cc.useRef(Date.now()),K=gt=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(gt);R.useEffect(()=>{z(!0),(async()=>{try{const[Ye,In,Jr,ar,Rs]=await Promise.all([ge.getAllConsultants(),ge.getAllReviews(),ge.getAllItineraries(),ge.getAllFlightCosts(),ge.getAllFlightOperators()]);_(ar),j(Rs);const Ct=Ye.map(St=>{const Un=In.filter(kt=>kt.consultantId===St.id),Tr=Un.length,ns=Tr>0?Un.reduce((kt,re)=>kt+re.rating,0)/Tr:0,yn=Jr.filter(kt=>kt.consultantId===St.id&&kt.status==="confirmed").length;return{...St,avgRating:ns,reviewCount:Tr,confirmedTrips:yn}});Ct.sort((St,Un)=>Un.avgRating!==St.avgRating?Un.avgRating-St.avgRating:Un.confirmedTrips-St.confirmedTrips),N(Ct)}catch(Ye){console.error("Failed to fetch booking page data:",Ye)}finally{z(!1)}})()},[]),R.useEffect(()=>{if(!t){W("idle"),w(!1),ne("");return}const gt=K(t);if(W(gt?"valid":"invalid"),w(!1),gt&&e){L(!0),ne("");const Ye=setTimeout(()=>{w(!0),L(!1)},500);return()=>clearTimeout(Ye)}else L(!1),ne(gt?"":"Please enter a valid email address.")},[t,e,w]);const fe=R.useMemo(()=>E.find(gt=>gt.id===S)||null,[S,E]),{rackRateTotal:Se,finalPriceTotal:Ae,discount:ze,consultancyFee:lt,perPersonPrice:dt}=R.useMemo(()=>{if(J)return{rackRateTotal:n.totalPrice,finalPriceTotal:n.totalPrice,discount:0,consultancyFee:0,perPersonPrice:0};const gt=qT(n,null,k,M,a,c),Ye=qT(n,fe,k,M,a,c),In=gt.totalPrice-(Ye.totalPrice-Ye.consultancyFee);return{rackRateTotal:gt.totalPrice,finalPriceTotal:Ye.totalPrice,discount:In>0?In:0,consultancyFee:Ye.consultancyFee,perPersonPrice:Ye.pricePerPerson}},[n,fe,k,M,J]),Wt=Math.abs(ze)>.01,Ht=R.useCallback(gt=>{p(gt.target.value)},[p]),Mr=R.useCallback(gt=>{y(gt.target.value)},[y]),br=async gt=>{if(gt.preventDefault(),!S||!e||!t||!u){alert("Please select a consultant and fill in your name and email.");return}if(X.trim().length>0||Date.now()-Te.current<1200){console.warn("[Security] Automated booking submission detected. Simulating booking confirmation."),D(!0);return}F(!0);const Ye={...n,title:`${e} x${n.travelerCount} Safari`,consultantId:S,travelerName:e,travelerEmail:t,travelerPhone:r,status:"pending_confirmation",totalPrice:Ae};try{if((await ge.getAllItineraries()).some(ar=>ar.id===n.id)?await ge.updateItinerary(Ye):await ge.saveItinerary(Ye),fe&&fe.email)try{await ge.sendEmail({to:fe.email,subject:`New Trip Pending Confirmation: ${Ye.id}`,_hp:X,_ts:Te.current,body:`
4215                    Hello ${fe.name.split(" ")[0]},
4216
4217                    A new trip is awaiting your confirmation.
4218
4219                    Trip ID: ${Ye.id}
4220                    Traveler: ${Ye.travelerName}
4221                    Total Price: $${Ye.totalPrice.toLocaleString()}
4222
4223                    Please log in to your dashboard to review the details and confirm the booking.
4224
4225                    Thank you,
4226                    The Uganda Safari Platform
4227                `});const ar=WV(Ye.travelerEmail,Ye.id);await ge.sendEmail({to:Ye.travelerEmail,subject:"Your Uganda Safari Booking Request & Direct Access Link (Pending Confirmation)",_hp:X,_ts:Te.current,body:`Hello ${Ye.travelerName},
4228
4229Thank you for your booking request! Your customized Uganda safari itinerary has been submitted to your selected expert, ${fe.name}.
4230
4231==================================================
4232DIRECT ACCESS LINK (AUTO-VERIFY & MANAGE YOUR SAFARI):
4233${ar}
4234==================================================
4235Clicking this direct link instantly verifies your email, sets your secure verification cookie, and opens your safari management dashboard without needing manual sign-in.
4236
4237YOUR CONFIDENTIAL TRIP REFERENCE CODE:
4238${Ye.id}
4239
4240BOOKING EMAIL:
4241${Ye.travelerEmail}
4242
4243LIVE PORTAL:
4244https://ugandasafaris.com
4245
4246HOW TO ACCESS YOUR SAFARI ONLINE:
4247Option 1 (Fastest): Click your direct access link above from this email. It automatically sets your email verification cookie on your device so your trips remain accessible.
4248Option 2 (Manual Login): Visit https://ugandasafaris.com, select "My Trips" from the menu or footer, and enter your booking email (${Ye.travelerEmail}) with your confidential Trip Reference Code (${Ye.id}).
4249
4250TRIP SUMMARY:
4251- Safari Duration: ${Ye.duration} Nights
4252- Starting Date: ${new Date(Ye.startDate).toLocaleDateString()}
4253- Travelers: ${Ye.travelerCount}
4254- Estimated Total: $${Ye.totalPrice.toLocaleString()}
4255
4256Your expert will review availability for your dates and contact you directly to confirm your booking. Please keep this email safe, as your Trip Reference Code and direct link are required to access your booking online.
4257
4258Sincerely,
4259The Uganda Safari Platform Team
4260https://ugandasafaris.com`}),Mg(Ye.travelerEmail,Ye.id)}catch(ar){console.warn("Notification email dispatch note:",ar)}D(!0)}catch(In){console.error("Failed to save final itinerary:",In),alert("There was an error confirming your booking. Please try again.")}finally{F(!1)}};if(U){const gt=t||n.travelerEmail||"your email";return o.jsxs("div",{className:"max-w-2xl mx-auto py-16 px-4 text-center animate-fadeIn",children:[o.jsx("div",{className:"w-16 h-16 bg-emerald-100 dark:bg-emerald-950/60 text-emerald-600 dark:text-emerald-400 rounded-full flex items-center justify-center mx-auto mb-6 shadow-xs",children:o.jsx(Ga,{className:"w-9 h-9"})}),o.jsx("h2",{className:"text-3xl font-bold font-heading text-brand-dark dark:text-white",children:"Booking Request Received!"}),o.jsxs("p",{className:"text-gray-600 dark:text-gray-300 mt-3 text-base leading-relaxed",children:["Your safari itinerary has been dispatched to your expert,"," ",o.jsx("strong",{className:"text-brand-dark dark:text-white",children:(fe==null?void 0:fe.name)||"our safari team"}),"."]}),o.jsx("div",{className:"my-8 p-6 bg-blue-50 dark:bg-blue-950/40 border border-blue-200 dark:border-blue-800/60 rounded-2xl text-left shadow-xs",children:o.jsxs("div",{className:"flex items-start gap-3.5",children:[o.jsx("div",{className:"p-2.5 rounded-xl bg-blue-100 dark:bg-blue-900/60 text-blue-600 dark:text-blue-300 shrink-0",children:o.jsx($g,{className:"w-5 h-5"})}),o.jsxs("div",{className:"space-y-2.5",children:[o.jsx("h4",{className:"text-sm font-bold text-blue-900 dark:text-blue-200",children:"Direct Access Link & Trip Reference Code Sent to Your Email"}),o.jsxs("p",{className:"text-xs text-blue-800/90 dark:text-blue-300/90 leading-relaxed",children:["For traveler security and data privacy, your confidential ",o.jsx("strong",{children:"Trip Reference Code"})," is not displayed on this screen. We have dispatched it together with an auto-verification link to:"]}),o.jsx("div",{className:"inline-block px-3 py-1.5 bg-white dark:bg-gray-800 rounded-lg border border-blue-200 dark:border-blue-800 text-xs font-mono font-bold text-blue-700 dark:text-blue-300 shadow-2xs",children:gt}),o.jsxs("div",{className:"flex items-center gap-2 pt-1 text-xs text-emerald-700 dark:text-emerald-300 font-medium",children:[o.jsx(JN,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400 shrink-0"}),o.jsx("span",{children:"Your email verification cookie has been initialized on this browser for seamless access."})]}),o.jsxs("p",{className:"text-xs text-blue-700/90 dark:text-blue-400/90",children:["Opening the direct link from your email on any device will automatically configure your verification cookie and open your safari dashboard at ",o.jsx("strong",{children:"ugandasafaris.com"}),"."]})]})]})}),o.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-3",children:[o.jsxs(He,{onClick:()=>h(Le.TripManagement,{clearBooking:!0}),className:"w-full sm:w-auto px-6 py-2.5 flex items-center justify-center gap-2",children:[o.jsx("span",{children:"My Trips"}),o.jsx(Bh,{className:"w-4 h-4"})]}),o.jsx(He,{onClick:()=>h(Le.Home,{clearBooking:!0}),variant:"secondary",className:"w-full sm:w-auto px-6 py-2.5",children:"Return to Home"})]})]})}return o.jsxs("div",{className:"max-w-5xl mx-auto",children:[o.jsxs("div",{className:"text-center mb-10",children:[o.jsx("h1",{className:"text-4xl font-bold text-brand-dark dark:text-white font-heading",children:"Confirm Your Booking"}),o.jsx("p",{className:"text-lg mt-2 text-gray-600 dark:text-gray-300",children:"You're almost there! Just a few final steps to secure your adventure."})]}),o.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:o.jsxs("div",{className:"grid md:grid-cols-2",children:[o.jsx("div",{className:"p-8 border-r border-gray-200 dark:border-gray-700",children:s?o.jsxs(o.Fragment,{children:[o.jsx("h2",{className:"text-xl font-bold font-heading text-brand-dark dark:text-white mb-1",children:"1. Your Safari Expert"}),o.jsxs("p",{className:"text-gray-600 dark:text-gray-300 mb-6 text-sm",children:["Your trip will be managed by ",(Lr=E.find(gt=>gt.id===s))==null?void 0:Lr.name,"."]}),J||!fe?o.jsx(At,{}):o.jsx(aH,{consultant:fe})]}):o.jsxs(o.Fragment,{children:[o.jsx("h2",{className:"text-xl font-bold font-heading text-brand-dark dark:text-white mb-1",children:"1. Choose Your Safari Expert"}),o.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 text-sm",children:"Select an expert to manage your booking."}),o.jsx("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto pr-3 -mr-3",children:J?o.jsx(At,{}):E.filter(gt=>gt.isAvailable).map(gt=>o.jsx(iH,{consultant:gt,isSelected:S===gt.id,onSelect:()=>I(gt.id),onLearnMore:()=>f(gt.id)},gt.id))})]})}),o.jsxs("div",{className:"p-8 relative flex flex-col",children:[!S&&!s&&o.jsx("div",{className:"absolute inset-0 bg-gray-50/80 dark:bg-gray-900/80 flex items-center justify-center z-10 backdrop-blur-sm","aria-hidden":"true",children:o.jsxs("div",{className:"text-center text-gray-600 dark:text-gray-400 font-semibold p-4",children:[o.jsx("svg",{className:"w-12 h-12 mx-auto mb-2 text-gray-400 dark:text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M11 15l-3-3m0 0l3-3m-3 3h8M3 12a9 9 0 1118 0 9 9 0 01-18 0z"})}),o.jsx("p",{children:"Select an expert to proceed"})]})}),o.jsx("form",{onSubmit:br,className:"flex flex-col flex-grow",children:o.jsxs("fieldset",{disabled:!S||H,className:"flex flex-col flex-grow",children:[o.jsxs("div",{style:{position:"absolute",opacity:0,zIndex:-1,pointerEvents:"none",height:0,overflow:"hidden"},"aria-hidden":"true",children:[o.jsx("label",{htmlFor:"traveler_company_url",children:"Company Website URL"}),o.jsx("input",{id:"traveler_company_url",type:"text",name:"traveler_company_url",tabIndex:-1,autoComplete:"off",value:X,onChange:gt=>ae(gt.target.value)})]}),o.jsx("h2",{className:"text-xl font-bold font-heading text-brand-dark dark:text-white mb-1",children:"2. Enter Your Details"}),o.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-2 text-sm",children:"Let us know who to send the confirmation to."}),o.jsxs("div",{className:"space-y-4 flex-grow",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"travelerName",children:"Full Name"}
4260),o.jsx("input",{id:"travelerName",type:"text",value:e,onChange:Ht,required:!0,className:"w-full p-2 border rounded-lg border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-700"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"travelerEmail",children:"Email Address"}),o.jsx("input",{id:"travelerEmail",type:"email",value:t,onChange:Mr,required:!0,className:`w-full p-2 border rounded-lg bg-white dark:bg-gray-700 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-700 transition-colors focus:outline-none focus:ring-2 ${G==="valid"?"border-green-500 dark:border-green-500 ring-green-200 dark:ring-green-800/50":G==="invalid"?"border-red-500 dark:border-red-500 ring-red-200 dark:ring-red-800/50":"border-gray-300 dark:border-gray-600 focus:ring-blue-500"}`}),ee&&o.jsx("p",{className:"text-red-500 text-xs mt-1",children:ee})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"travelerPhone",children:"Phone Number (Optional)"}),o.jsx("input",{id:"travelerPhone",type:"tel",value:r,onChange:gt=>b(gt.target.value),className:"w-full p-2 border rounded-lg border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-700"})]})]}),o.jsxs("div",{className:"pt-4 mt-6 border-t dark:border-gray-700",children:[H&&o.jsx("div",{className:"text-center p-4",children:o.jsx(At,{})}),u?o.jsxs("div",{className:"animate-fade-in",children:[Wt&&o.jsxs("div",{className:"space-y-2 mb-4 text-sm text-right",children:[o.jsxs("div",{className:"flex justify-between items-baseline",children:[o.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Quote Rack Rate"}),o.jsxs("span",{className:"font-medium text-gray-500 dark:text-gray-400 line-through",children:["$",Se.toLocaleString(void 0,{minimumFractionDigits:2})]})]}),lt>0&&o.jsxs("div",{className:"flex justify-between items-baseline",children:[o.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Consultancy Fee"}),o.jsxs("span",{className:"font-medium text-gray-800 dark:text-gray-300",children:["+$",lt.toLocaleString(void 0,{minimumFractionDigits:2})]})]}),ze>.01&&o.jsxs("div",{className:"flex justify-between items-baseline",children:[o.jsx("span",{className:"font-semibold text-green-600 dark:text-green-400",children:fe?`${fe.name.split(" ")[0]}'s Special Discount`:"Expert Discount"}),o.jsxs("span",{className:"font-semibold text-green-600 dark:text-green-400",children:["-$",ze.toLocaleString(void 0,{minimumFractionDigits:2})]})]})]}),o.jsxs("div",{className:"flex justify-between items-baseline mb-4",children:[o.jsxs("div",{className:"text-left",children:[o.jsxs("p",{className:"text-lg font-semibold text-brand-dark dark:text-white",children:["$",dt.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"per person"})]}),o.jsxs("div",{className:"text-right",children:[o.jsxs("p",{className:"text-2xl font-bold text-brand-dark dark:text-white",children:["$",Ae.toLocaleString(void 0,{minimumFractionDigits:2})]}),o.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:["Total for ",n.travelerCount," traveler",n.travelerCount>1?"s":""]})]})]}),o.jsx(He,{type:"submit",disabled:O||!S||!e||!t,className:"w-full py-3 text-base",children:O?o.jsx(At,{}):"Confirm & Send to Expert"})]}):o.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 py-4",children:[o.jsxs("div",{className:"text-right mb-4",children:[o.jsxs("p",{className:"text-2xl font-bold text-brand-dark dark:text-white",children:["$",Se.toLocaleString(void 0,{minimumFractionDigits:2})]}),o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Total Rack Rate"})]}),o.jsx("p",{className:"text-sm bg-blue-50 dark:bg-blue-900/40 p-3 rounded-lg border border-blue-200 dark:border-blue-800",children:S?"Enter your name and a valid email to verify details and see if you qual
4260ify for special expert rates.":"Select an expert to proceed."})]})]})]})})]})]})})]})},lH=({itinerary:n,travelerName:e})=>{const[t,r]=R.useState(!1),[s,a]=R.useState(!1),{navigateTo:c}=an();if(s)return null;const u=e?`Ready, ${e.split(" ")[0]}?`:"Ready to book?";return o.jsxs("div",{className:"fixed bottom-6 right-6 z-40",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[o.jsxs("button",{onClick:()=>c(Le.Booking),className:"flex items-center gap-3 px-5 py-3 bg-gray-700 text-white rounded-lg shadow-lg hover:bg-gray-800 transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500","aria-label":"Complete your booking",children:[o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{d:"M10.894 2.553a1 1 0 00-1.788 0l-7 14a1 1 0 001.169 1.409l5-1.429A1 1 0 009 15.571V11a1 1 0 112 0v4.571a1 1 0 00.725.962l5 1.428a1 1 0 001.17-1.408l-7-14z"})}),o.jsx("span",{className:"font-semibold text-sm",children:"Complete Your Booking"})]}),o.jsx("div",{className:`absolute bottom-full right-0 mb-2 w-80 bg-white dark:bg-gray-800 rounded-lg shadow-2xl border border-gray-200 dark:border-gray-700 transition-all duration-300 origin-bottom-right ${t?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"}`,children:o.jsxs("div",{className:"p-4",children:[o.jsxs("div",{className:"flex justify-between items-start",children:[o.jsxs("div",{children:[o.jsx("p",{className:"font-bold text-brand-dark dark:text-white",children:n.title}),o.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[n.duration+1," days / ",n.duration," ",n.duration===1?"night":"nights"," for ",n.travelerCount," ",n.travelerCount>1?"people":"person"]})]}),o.jsxs("button",{onClick:()=>a(!0),className:"text-gray-400 hover:text-gray-700 p-1 -mt-1 -mr-1",children:[o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})}),o.jsx("span",{className:"sr-only",children:"Dismiss"})]})]}),o.jsx("p",{className:"text-lg font-semibold text-blue-700 dark:text-blue-400 mt-3",children:u})]})})]})},Zr=({icon:n,title:e,value:t,description:r,previousValue:s})=>{const c=(()=>{if(s===void 0)return null;const u=typeof t=="string"?parseFloat(t.replace(/[^0-9.-]+/g,"")):t,h=typeof s=="string"?parseFloat(s.replace(/[^0-9.-]+/g,"")):s;if(h===0&&u>0)return{percentage:100,isIncrease:!0,text:"vs $0"};if(h===0)return null;const f=(u-h)/h*100,p=f>=0;return{percentage:Math.abs(f),isIncrease:p,text:`${p?"+":""}${f.toFixed(1)}%`}})();return o.jsxs("div",{className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md border border-gray-200 dark:border-gray-700 flex flex-col justify-between",children:[o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsx("div",{className:"flex-shrink-0 bg-blue-100 dark:bg-blue-900/50 text-blue-600 dark:text-blue-300 p-3 rounded-lg",children:n}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e}),o.jsx("p",{className:"text-3xl font-bold text-brand-dark dark:text-white mt-1",children:t}),r&&o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:r})]})]}),c&&o.jsxs("div",{className:`mt-3 flex items-center text-sm font-semibold ${c.isIncrease?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[c.isIncrease?o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M5.293 9.707a1 1 0 010-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 01-1.414 1.414L11 7.414V15a1 1 0 11-2 0V7.414L6.707 9.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}):o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M14.707 10.293a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 111.414-1.414L9 12.586V5a1 1 0 012 0v7.586l2.293-2.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),o.jsx("span",{children:c.text}),o.jsx("span",{className:"text-xs font-normal text-gray-500 dark:text-gray-400 ml-1",children:"vs previous period"})]})]})};var qd={exports:{}},ay={},oy,zT;function cH(){if(zT)return oy;zT=1;function n(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.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 oy=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);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 s=this;return this._timer=setTimeout(function(){s._attempts++,s._operationTimeoutCb&&(s._timeout=setTimeout(function(){s._operationTimeoutCb(s._attempts)},s._operationTimeout),s._options.unref&&s._timeout.unref()),s._fn(s._attempts)},r),this._options.unref&&this._timer.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},n.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,r=0,s=0;s<this._errors.length;s++){var a=this._errors[s],c=a.message,u=(e[c]||0)+1;e[c]=u,u>=r&&(t=a,r=u)}return t},oy}var JT;
4260function uH(){return JT||(JT=1,(function(n){var e=cH();n.operation=function(t){var r=n.timeouts(t);return new e(r,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})},n.timeouts=function(t){if(t instanceof Array)return[].concat(t);var r={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var s in t)r[s]=t[s];if(r.minTimeout>r.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var a=[],c=0;c<r.retries;c++)a.push(this.createTimeout(c,r));return t&&t.forever&&!a.length&&a.push(this.createTimeout(c,r)),a.sort(function(u,h){return u-h}),a},n.createTimeout=function(t,r){var s=r.randomize?Math.random()+1:1,a=Math.round(s*Math.max(r.minTimeout,1)*Math.pow(r.factor,t));return a=Math.min(a,r.maxTimeout),a},n.wrap=function(t,r,s){if(r instanceof Array&&(s=r,r=null),!s){s=[];for(var a in t)typeof t[a]=="function"&&s.push(a)}for(var c=0;c<s.length;c++){var u=s[c],h=t[u];t[u]=(function(p){var y=n.operation(r),b=Array.prototype.slice.call(arguments,1),w=b.pop();b.push(function(E){y.retry(E)||(E&&(arguments[0]=y.mainError()),w.apply(this,arguments))}),y.attempt(function(){p.apply(t,b)})}).bind(t,h),t[u].options=r}}})(ay)),ay}var ly,$T;function dH(){return $T||($T=1,ly=uH()),ly}var KT;function hH(){if(KT)return qd.exports;
4260KT=1;const n=dH(),e=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class t extends Error{constructor(u){super(),u instanceof Error?(this.originalError=u,{message:u}=u):(this.originalError=new Error(u),this.originalError.stack=this.stack),this.name="AbortError",this.message=u}}const r=(c,u,h)=>{const f=h.retries-(u-1);return c.attemptNumber=u,c.retriesLeft=f,c},s=c=>e.includes(c),a=(c,u)=>new Promise((h,f)=>{u={onFailedAttempt:()=>{},retries:10,...u};const p=n.operation(u);p.attempt(async y=>{try{h(await c(y))}catch(b){if(!(b instanceof Error)){f(new TypeError(`Non-error was thrown: "${b}". You should only throw errors.`));return}if(b instanceof t)p.stop(),f(b.originalError);else if(b instanceof TypeError&&!s(b.message))p.stop(),f(b);else{r(b,y,u);try{await u.onFailedAttempt(b)}catch(w){f(w);return}p.retry(b)||f(p.mainError())}}})});return qd.exports=a,qd.exports.default=a,qd.exports.AbortError=t,qd.exports}var MA=hH();const fH=HN(MA);var mH={};/**
4261 * @license
4262 * Copyright 2025 Google LLC
4263 * SPDX-License-Identifier: Apache-2.0
4264 */let gH,pH;function BH(){return{geminiUrl:gH,vertexUrl:pH}}function yH(n,e,t,r){var s,a;if(!(n!=null&&n.baseUrl)){const c=BH();return e?(s=c.vertexUrl)!==null&&s!==void 0?s:t:(a=c.geminiUrl)!==null&&a!==void 0?a:r}return n.baseUrl}/**
4265 * @license
4266 * Copyright 2025 Google LLC
4267 * SPDX-License-Identifier: Apache-2.0
4268 */class Xa{}function Ve(n,e){const t=/\{([^}]+)\}/g;return n.replace(t,(r,s)=>{if(Object.prototype.hasOwnProperty.call(e,s)){const a=e[s];return a!=null?String(a):""}else throw new Error(`Key '${s}' not found in valueMap.`)})}function B(n,e,t){for(let a=0;a<e.length-1;a++){const c=e[a];if(c.endsWith("[]")){const u=c.slice(0,-2);if(!(u in n))if(Array.isArray(t))n[u]=Array.from({length:t.length},()=>({}));else throw new Error(`Value must be a list given an array path ${c}`);if(Array.isArray(n[u])){const h=n[u];if(Array.isArray(t))for(let f=0;f<h.length;f++){const p=h[f];B(p,e.slice(a+1),t[f])}else for(const f of h)B(f,e.slice(a+1),t)}return}else if(c.endsWith("[0]")){const u=c.slice(0,-3);u in n||(n[u]=[{}]);const h=n[u];B(h[0],e.slice(a+1),t);return}(!n[c]||typeof n[c]!="object")&&(n[c]={}),n=n[c]}const r=e[e.length-1],s=n[r];if(s!==void 0){if(!t||typeof t=="object"&&Object.keys(t).length===0||t===s)return;if(typeof s=="object"&&typeof t=="object"&&s!==null&&t!==null)Object.assign(s,t);else throw new Error(`Cannot set value for an existing key. Key: ${r}`)}else r==="_self"&&typeof t=="object"&&t!==null&&!Array.isArray(t)?Object.assign(n,t):n[r]=t}function g(n,e,t=void 0){try{if(e.length===1&&e[0]==="_self")return n;for(let r=0;r<e.length;r++){if(typeof n!="object"||n===null)return t;const s=e[r];if(s.endsWith("[]")){const a=s.slice(0,-2);if(a in n){const c=n[a];return Array.isArray(c)?c.map(u=>g(u,e.slice(r+1),t)):t}else return t}else n=n[s]}return n}catch(r){if(r instanceof TypeError)return t;throw r}}function xH(n,e){for(const[t,r]of Object.entries(e)){const s=t.split("."),a=r.split("."),c=new Set;let u=-1;for(let h=0;h<s.length;h++)if(s[h]==="*"){u=h;break}if(u!==-1&&a.length>u)for(let h=u;h<a.length;h++){const f=a[h];f!=="*"&&!f.endsWith("[]")&&!f.endsWith("[0]")&&c.add(f)}zy(n,s,a,0,c)}}function zy(n,e,t,r,s){if(r>=e.length||typeof n!="object"||n===null)return;const a=e[r];if(a.endsWith("[]")){const c=a.slice(0,-2),u=n;if(c in u&&Array.isArray(u[c]))for(const h of u[c])zy(h,e,t,r+1,s)}else if(a==="*"){if(typeof n=="object"&&n!==null&&!Array.isArray(n)){const c=n,u=Object.keys(c).filter(f=>!f.startsWith("_")&&!s.has(f)),h={};for(const f of u)h[f]=c[f];for(const[f,p]of Object.entries(h)){const y=[];for(const b of t.slice(r))b==="*"?y.push(f):y.push(b);B(c,y,p)}for(const f of u)delete c[f]}}else{const c=n;a in c&&zy(c[a],e,t,r+1,s)}}/**
4269 * @license
4270 * Copyright 2025 Google LLC
4271 * SPDX-License-Identifier: Apache-2.0
4272 */function DC(n){if(typeof n!="string")throw new Error("fromImageBytes must be a string");return n}/**
4273 * @license
4274 * Copyright 2025 Google LLC
4275 * SPDX-License-Identifier: Apache-2.0
4276 */function CH(n){const e={},t=g(n,["operationName"]);t!=null&&B(e,["operationName"],t);const r=g(n,["resourceName"]);return r!=null&&B(e,["_url","resourceName"],r),e}function bH(n){const e={},t=g(n,["name"]);t!=null&&B(e,["name"],t);const r=g(n,["metadata"]);r!=null&&B(e,["metadata"],r);const s=g(n,["done"]);s!=null&&B(e,["done"],s);const a=g(n,["error"]);a!=null&&B(e,["error"],a);const c=g(n,["response","generateVideoResponse"]);return c!=null&&B(e,["response"],wH(c)),e}function vH(n){const e={},t=g(n,["name"]);t!=null&&B(e,["name"],t);const r=g(n,["metadata"]);r!=null&&B(e,["metadata"],r);const s=g(n,["done"]);s!=null&&B(e,["done"],s);const a=g(n,["error"]);a!=null&&B(e,["error"],a);const c=g(n,["response"]);return c!=null&&B(e,["response"],EH(c)),e}function wH(n){const e={},t=g(n,["generatedSamples"]);if(t!=null){let a=t;Array.isArray(a)&&(a=a.map(c=>_H(c))),B(e,["generatedVideos"],a)}const r=g(n,["raiMediaFilteredCount"]);r!=null&&B(e,["raiMediaFilteredCount"],r);const s=g(n,["raiMediaFilteredReasons"]);return s!=null&&B(e,["raiMediaFilteredReasons"],s),e}function EH(n){const e={},t=g(n,["videos"]);if(t!=null){let a=t;Array.isArray(a)&&(a=a.map(c=>TH(c))),B(e,["generatedVideos"],a)}const r=g(n,["raiMediaFilteredCount"]);r!=null&&B(e,["raiMediaFilteredCount"],r);const s=g(n,["raiMediaFilteredReasons"]);return s!=null&&B(e,["raiMediaFilteredReasons"],s),e}function _H(n){const e={},t=g(n,["video"]);return t!=null&&B(e,["video"],IH(t)),e}function TH(n){const e={},t=g(n,["_self"]);return t!=null&&B(e,["video"],RH(t)),e}function kH(n){const e={},t=g(n,["operationName"]);return t!=null&&B(e,["_url","operationName"],t),e}function NH(n){const e={},t=g(n,["operationName"]);return t!=null&&B(e,["_url","operationName"],t),e}function SH(n){const e={},t=g(n,["name"]);t!=null&&B(e,["name"],t);const r=g(n,["metadata"]);r!=null&&B(e,["metadata"],r);const s=g(n,["done"]);s!=null&&B(e,["done"],s);const a=g(n,["error"]);a!=null&&B(e,["error"],a);const c=g(n,["response"]);return c!=null&&B(e,["response"],DH(c)),e}function DH(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["parent"]);r!=null&&B(e,["parent"],r);const s=g(n,["documentName"]);return s!=null&&B(e,["documentName"],s),e}function LA(n){const e={},t=g(n,["name"]);t!=null&&B(e,["name"],t);const r=g(n,["metadata"]);r!=null&&B(e,["metadata"],r);const s=g(n,["done"]);s!=null&&B(e,["done"],s);const a=g(n,["error"]);a!=null&&B(e,["error"],a);const c=g(n,["response"]);return c!=null&&B(e,["response"],AH(c)),e}function AH(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["parent"]);r!=null&&B(e,["parent"],r);const s=g(n,["documentName"]);return s!=null&&B(e,["documentName"],s),e}function IH(n){const e={},t=g(n,["uri"]);t!=null&&B(e,["uri"],t);const r=g(n,["encodedVideo"]);r!=null&&B(e,["videoBytes"],DC(r));const s=g(n,["encoding"]);return s!=null&&B(e,["mimeType"],s),e}function RH(n){const e={},t=g(n,["gcsUri"]);t!=null&&B(e,["uri"],t);const r=g(n,["bytesBase64Encoded"]);r!=null&&B(e,["videoBytes"],DC(r));const s=g(n,["mimeType"]);return s!=null&&B(e,["mimeType"],s),e}/**
4277 * @license
4278 * Copyright 2025 Google LLC
4279 * SPDX-License-Identifier: Apache-2.0
4280 */var YT;(function(n){n.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",n.PYTHON="PYTHON"})(YT||(YT={}));var QT;(function(n){n.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",n.OUTCOME_OK="OUTCOME_OK",n.OUTCOME_FAILED="OUTCOME_FAILED",n.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(QT||(QT={}));var WT;(function(n){n.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",n.SILENT="SILENT",n.WHEN_IDLE="WHEN_IDLE",n.INTERRUPT="INTERRUPT"})(WT||(WT={}));var qs;(function(n){n.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",n.STRING="STRING",n.NUMBER="NUMBER",n.INTEGER="INTEGER",n.BOOLEAN="BOOLEAN",n.ARRAY="ARRAY",n.OBJECT="OBJECT",n.NULL="NULL"}
4280)(qs||(qs={}));var XT;(function(n){n.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",n.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(XT||(XT={}));var ZT;(function(n){n.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",n.NO_AUTH="NO_AUTH",n.API_KEY_AUTH="API_KEY_AUTH",n.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",n.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",n.OAUTH="OAUTH",n.OIDC_AUTH="OIDC_AUTH"})(ZT||(ZT={}));var ek;(function(n){n.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",n.HTTP_IN_QUERY="HTTP_IN_QUERY",n.HTTP_IN_HEADER="HTTP_IN_HEADER",n.HTTP_IN_PATH="HTTP_IN_PATH",n.HTTP_IN_BODY="HTTP_IN_BODY",n.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(ek||(ek={}));var tk;(function(n){n.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",n.SIMPLE_SEARCH="SIMPLE_SEARCH",n.ELASTIC_SEARCH="ELASTIC_SEARCH"})(tk||(tk={}));var nk;(function(n){n.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",n.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",n.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",n.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(nk||(nk={}));var rk;(function(n){n.UNSPECIFIED="UNSPECIFIED",n.BLOCKING="BLOCKING",n.NON_BLOCKING="NON_BLOCKING"})(rk||(rk={}));var sk;(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.MODE_DYNAMIC="MODE_DYNAMIC"})(sk||(sk={}));var ik;(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.AUTO="AUTO",n.ANY="ANY",n.NONE="NONE",
4280n.VALIDATED="VALIDATED"})(ik||(ik={}));var ak;(function(n){n.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",n.MINIMAL="MINIMAL",n.LOW="LOW",n.MEDIUM="MEDIUM",n.HIGH="HIGH"})(ak||(ak={}));var ok;(function(n){n.DONT_ALLOW="DONT_ALLOW",n.ALLOW_ADULT="ALLOW_ADULT",n.ALLOW_ALL="ALLOW_ALL"})(ok||(ok={}));var lk;(function(n){n.PROMINENT_PEOPLE_UNSPECIFIED="PROMINENT_PEOPLE_UNSPECIFIED",n.ALLOW_PROMINENT_PEOPLE="ALLOW_PROMINENT_PEOPLE",n.BLOCK_PROMINENT_PEOPLE="BLOCK_PROMINENT_PEOPLE"})(lk||(lk={}));var ck;(function(n){n.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",n.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",n.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",n.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",n.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",n.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",n.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",n.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",n.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",n.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",n.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(ck||(ck={}));var uk;(function(n){n.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",n.SEVERITY="SEVERITY",n.PROBABILITY="PROBABILITY"})(uk||(uk={}));var dk;(function(n){n.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",n.BLOCK_NONE="BLOCK_NONE",n.OFF="OFF"})(dk||(dk={}));var hk;(function(n){n.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",n.STOP="STOP",n.MAX_TOKENS="MAX_TOKENS",n.SAFETY="SAFETY",n.RECITATION="RECITATION",n.LANGUAGE="LANGUAGE",n.OTHER="OTHER",n.BLOCKLIST="BLOCKLIST",n.PROHIBITED_CONTENT="PROHIBITED_CONTENT",n.SPII="SPII",n.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",n.IMAGE_SAFETY="IMAGE_SAFETY",n.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",n.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",n.NO_IMAGE="NO_IMAGE",n.IMAGE_RECITATION="IMAGE_RECITATION",n.IMAGE_OTHER="IMAGE_OTHER"})(hk||(hk={}));var fk;(function(n){n.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",n.NEGLIGIBLE="NEGLIGIBLE",n.LOW="LOW",n.MEDIUM="MEDIUM",n.HIGH="HIGH"})(fk||(fk={}));var mk;(function(n){n.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",n.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",n.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",n.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",n.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(mk||(mk={}));var gk;(function(n){n.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",n.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",n.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",n.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",n.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(gk||(gk={}));var pk;(function(n){n.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",n.SAFETY="SAFETY",n.OTHER="OTHER",n.BLOCKLIST="BLOCKLIST",n.PROHIBITED_CONTENT="PROHIBITED_CONTENT",n.IMAGE_SAFETY="IMAGE_SAFETY",n.MODEL_ARMOR="MODEL_ARMOR",n.JAILBREAK="JAILBREAK"})(pk||(pk={}));var Bk;(function(n){n.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",n.ON_DEMAND="ON_DEMAND",n.ON_DEMAND_PRIORITY="ON_DEMAND_PRIORITY",n.ON_DEMAND_FLEX="ON_DEMAND_FLEX",n.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Bk||(Bk={}));var jg;(function(n){n.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",n.TEXT="TEXT",n.IMAGE="IMAGE",n.AUDIO="AUDIO",n.VIDEO="VIDEO"})(jg||(jg={}));var yk;(function(n){n.MODEL_STAGE_UNSPECIFIED="MODEL_STAGE_UNSPECIFIED",n.UNSTABLE_EXPERIMENTAL="UNSTABLE_EXPERIMENTAL",n.EXPERIMENTAL="EXPERIMENTAL",n.PREVIEW="PREVIEW",n.STABLE="STABLE",n.LEGACY="LEGACY",n.DEPRECATED="DEPRECATED",n.RETIRED="RETIRED"})(yk||(yk={}));var xk;(function(n){n.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",n.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",n.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",n.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(xk||(xk={}));var Ck;(function(n){n.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",n.TUNING_MODE_FULL="TUNING_MODE_FULL",n.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(Ck||(Ck={}));var bk;(function(n){n.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",n.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",n.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",n.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",n.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",n.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",n.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(bk||(bk={}));var Jy;(function(n){n.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",n.JOB_STATE_QUEUED="JOB_STATE_QUEUED",n.JOB_STATE_PENDING="JOB_STATE_PENDING",n.JOB_STATE_RUNNING="JOB_STATE_RUNNING",n.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",n.JOB_STATE_FAILED="JOB_STATE_FAILED",n.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",n.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",n.JOB_STATE_PAUSED="JOB_STATE_PAUSED",n.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",n.JOB_STATE_UPDATING="JOB_STATE_UPDATING",n.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"}
4280)(Jy||(Jy={}));var vk;(function(n){n.TUNING_JOB_STATE_UNSPECIFIED="TUNING_JOB_STATE_UNSPECIFIED",n.TUNING_JOB_STATE_WAITING_FOR_QUOTA="TUNING_JOB_STATE_WAITING_FOR_QUOTA",n.TUNING_JOB_STATE_PROCESSING_DATASET="TUNING_JOB_STATE_PROCESSING_DATASET",n.TUNING_JOB_STATE_WAITING_FOR_CAPACITY="TUNING_JOB_STATE_WAITING_FOR_CAPACITY",n.TUNING_JOB_STATE_TUNING="TUNING_JOB_STATE_TUNING",n.TUNING_JOB_STATE_POST_PROCESSING="TUNING_JOB_STATE_POST_PROCESSING"})(vk||(vk={}));var wk;(function(n){n.AGGREGATION_METRIC_UNSPECIFIED="AGGREGATION_METRIC_UNSPECIFIED",n.AVERAGE="AVERAGE",n.MODE="MODE",n.STANDARD_DEVIATION="STANDARD_DEVIATION",n.VARIANCE="VARIANCE",n.MINIMUM="MINIMUM",n.MAXIMUM="MAXIMUM",n.MEDIAN="MEDIAN",n.PERCENTILE_P90="PERCENTILE_P90",n.PERCENTILE_P95="PERCENTILE_P95",n.PERCENTILE_P99="PERCENTILE_P99"})(wk||(wk={}));var Ek;(function(n){n.PAIRWISE_CHOICE_UNSPECIFIED="PAIRWISE_CHOICE_UNSPECIFIED",n.BASELINE="BASELINE",n.CANDIDATE="CANDIDATE",n.TIE="TIE"})(Ek||(Ek={}));var _k;(function(n){n.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",n.TUNING_TASK_I2V="TUNING_TASK_I2V",n.TUNING_TASK_T2V="TUNING_TASK_T2V",n.TUNING_TASK_R2V="TUNING_TASK_R2V"})(_k||(_k={}));var Tk;(function(n){n.STATE_UNSPECIFIED="STATE_UNSPECIFIED",n.STATE_PENDING="STATE_PENDING",n.STATE_ACTIVE="STATE_ACTIVE",n.STATE_FAILED="STATE_FAILED"})(Tk||(Tk={}));var kk;(function(n){n.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",n.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",n.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",n.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",n.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH"})(kk||(kk={}));var Nk;(function(n){n.TOOL_TYPE_UNSPECIFIED="TOOL_TYPE_UNSPECIFIED",n.GOOGLE_SEARCH_WEB="GOOGLE_SEARCH_WEB",n.GOOGLE_SEARCH_IMAGE="GOOGLE_SEARCH_IMAGE",n.URL_CONTEXT="URL_CONTEXT",n.GOOGLE_MAPS="GOOGLE_MAPS",n.FILE_SEARCH="FILE_SEARCH"})(Nk||(Nk={}));var $y;(function(n){n.COLLECTION="COLLECTION"})($y||($y={}));var Sk;(function(n){n.UNSPECIFIED="unspecified",n.FLEX="flex",n.STANDARD="standard",n.PRIORITY="priority"})(Sk||(Sk={}));var Dk;(function(n){n.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",n.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",n.BALANCED="BALANCED",n.PRIORITIZE_COST="PRIORITIZE_COST"})(Dk||(Dk={}));var Og;(function(n){n.PREDICT="PREDICT",n.EMBED_CONTENT="EMBED_CONTENT"})(Og||(Og={}));var Ak;(function(n){n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",n.BLOCK_NONE="BLOCK_NONE"})(Ak||(Ak={}));var Ik;(function(n){n.auto="auto",n.en="en",n.ja="ja",n.ko="ko",n.hi="hi",n.zh="zh",n.pt="pt",n.es="es"})(Ik||(Ik={}));var Rk;(function(n){n.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",n.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",n.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",n.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",n.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(Rk||(Rk={}));var Pk;(function(n){n.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",n.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",n.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",n.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(Pk||(Pk={}));var Mk;(function(n){n.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",n.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",n.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",n.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(Mk||(Mk={}));var Lk;(function(n){n.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",n.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",n.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",n.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",n.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",n.EDIT_MODE_STYLE="EDIT_MODE_STYLE",n.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",n.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(Lk||(Lk={}));var jk;(function(n){n.FOREGROUND="FOREGROUND",n.BACKGROUND="BACKGROUND",n.PROMPT="PROMPT",n.SEMANTIC="SEMANTIC",n.INTERACTIVE="INTERACTIVE"})(jk||(jk={}));var Ok;(function(n){n.ASSET="ASSET",n.STYLE="STYLE"})(Ok||(Ok={}));var Fk;(function(n){n.INSERT="INSERT",n.REMOVE="REMOVE",n.REMOVE_STATIC="REMOVE_STATIC",
4280n.OUTPAINT="OUTPAINT"})(Fk||(Fk={}));var Uk;(function(n){n.OPTIMIZED="OPTIMIZED",n.LOSSLESS="LOSSLESS"})(Uk||(Uk={}));var Vk;(function(n){n.CROP="CROP",n.PAD="PAD"})(Vk||(Vk={}));var Gk;(function(n){n.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",n.PREFERENCE_TUNING="PREFERENCE_TUNING",n.DISTILLATION="DISTILLATION"})(Gk||(Gk={}));var Hk;(function(n){n.STATE_UNSPECIFIED="STATE_UNSPECIFIED",n.PROCESSING="PROCESSING",n.ACTIVE="ACTIVE",n.FAILED="FAILED"})(Hk||(Hk={}));var qk;(function(n){n.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",n.UPLOADED="UPLOADED",n.GENERATED="GENERATED",n.REGISTERED="REGISTERED"})(qk||(qk={}));var zk;(function(n){n.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",n.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",n.RESPONSE_REJECTED="RESPONSE_REJECTED",n.NEED_MORE_INPUT="NEED_MORE_INPUT",n.PROHIBITED_INPUT_CONTENT="PROHIBITED_INPUT_CONTENT",n.IMAGE_PROHIBITED_INPUT_CONTENT="IMAGE_PROHIBITED_INPUT_CONTENT",n.INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED="INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED",n.INPUT_IMAGE_CELEBRITY="INPUT_IMAGE_CELEBRITY",n.INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED="INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED",n.INPUT_TEXT_NCII_PROHIBITED="INPUT_TEXT_NCII_PROHIBITED",n.INPUT_OTHER="INPUT_OTHER",n.INPUT_IP_PROHIBITED="INPUT_IP_PROHIBITED",n.BLOCKLIST="BLOCKLIST",n.UNSAFE_PROMPT_FOR_IMAGE_GENERATION="UNSAFE_PROMPT_FOR_IMAGE_GENERATION",n.GENERATED_IMAGE_SAFETY="GENERATED_IMAGE_SAFETY",n.GENERATED_CONTENT_SAFETY="GENERATED_CONTENT_SAFETY",n.GENERATED_AUDIO_SAFETY="GENERATED_AUDIO_SAFETY",n.GENERATED_VIDEO_SAFETY="GENERATED_VIDEO_SAFETY",n.GENERATED_CONTENT_PROHIBITED="GENERATED_CONTENT_PROHIBITED",n.GENERATED_CONTENT_BLOCKLIST="GENERATED_CONTENT_BLOCKLIST",n.GENERATED_IMAGE_PROHIBITED="GENERATED_IMAGE_PROHIBITED",n.GENERATED_IMAGE_CELEBRITY="GENERATED_IMAGE_CELEBRITY",n.GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER="GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER",n.GENERATED_IMAGE_IDENTIFIABLE_PEOPLE="GENERATED_IMAGE_IDENTIFIABLE_PEOPLE",n.GENERATED_IMAGE_MINORS="GENERATED_IMAGE_MINORS",n.OUTPUT_IMAGE_IP_PROHIBITED="OUTPUT_IMAGE_IP_PROHIBITED",n.GENERATED_OTHER="GENERATED_OTHER",n.MAX_REGENERATION_REACHED="MAX_REGENERATION_REACHED"})(zk||(zk={}));var Jk;(function(n){n.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",n.TEXT="TEXT",n.IMAGE="IMAGE",n.VIDEO="VIDEO",n.AUDIO="AUDIO",n.DOCUMENT="DOCUMENT"})(Jk||(Jk={}));var $k;(function(n){n.VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",n.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",n.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS"})($k||($k={}));var Kk;(function(n){n.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",n.ACTIVITY_START="ACTIVITY_START",n.ACTIVITY_END="ACTIVITY_END"})(Kk||(Kk={}));var Yk;(function(n){n.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",n.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",n.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(Yk||(Yk={}));var Qk;(function(n){n.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",n.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",n.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(Qk||(Qk={}));var Wk;(function(n){n.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",n.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",n.NO_INTERRUPTION="NO_INTERRUPTION"})(Wk||(Wk={}));var Xk;(function(n){n.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",n.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",n.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT",n.TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO="TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO"})(Xk||(Xk={}));var Zk;(function(n){n.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",n.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",n.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",n.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",n.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",n.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",n.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",n.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",n.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",n.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",n.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",n.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",n.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(Zk||(Zk={}));var eN;(function(n){n.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",n.QUALITY="QUALITY",n.DIVERSITY="DIVERSITY",n.VOCALIZATION="VOCALIZATION"})(eN||(eN={}));var vu;(function(n){n.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",n.PLAY="PLAY",n.PAUSE="PAUSE",n.STOP="STOP",n.RESET_CONTEXT="RESET_CONTEXT"})(vu||(vu={}));class Fg{constructor(e){const t={};for(const r of e.headers.entries())t[r[0]]=r[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}}class zd{get text(){var e,t,r,s,a,c,u,h;if(((s=(r=(t=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||t===void 0?void 0:t.content)===null||r===void 0?void 0:r.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let f="",p=!1;const y=[];for(const b of(h=(u=(c=(a=this.candidates)===null||a===void 0?void 0:a[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)!==null&&h!==void 0?h:[]){for(const[w,E]of Object.entries(b))w!=="text"&&w!=="thought"&&w!=="thoughtSignature"&&(E!==null||E!==void 0)&&y.push(w);if(typeof b.text=="string"){if(typeof b.thought=="boolean"&&b.thought)continue;p=!0,f+=b.text}}return y.length>0&&console.warn(`there are non-text parts ${y} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),p?f:void 0}get data(){var e,t,r,s,a,c,u,h;if(((s=(r=(t=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||t===void 0?void 0:t.content)===null||r===void 0?void 0:r.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let f="";const p=[];for(const y of(h=(u=(c=(a=this.candidates)===null||a===void 0?void 0:a[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)!==null&&h!==void 0?h:[]){for(const[b,w]of Object.entries(y))b!=="inlineData"&&(w!==null||w!==void 0)&&p.push(b);
4280y.inlineData&&typeof y.inlineData.data=="string"&&(f+=atob(y.inlineData.data))}return p.length>0&&console.warn(`there are non-data parts ${p} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),f.length>0?btoa(f):void 0}get functionCalls(){var e,t,r,s,a,c,u,h;if(((s=(r=(t=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||t===void 0?void 0:t.content)===null||r===void 0?void 0:r.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const f=(h=(u=(c=(a=this.candidates)===null||a===void 0?void 0:a[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)===null||h===void 0?void 0:h.filter(p=>p.functionCall).map(p=>p.functionCall).filter(p=>p!==void 0);if((f==null?void 0:f.length)!==0)return f}get executableCode(){var e,t,r,s,a,c,u,h,f;if(((s=(r=(t=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||t===void 0?void 0:t.content)===null||r===void 0?void 0:r.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const p=(h=(u=(c=(a=this.candidates)===null||a===void 0?void 0:a[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)===null||h===void 0?void 0:h.filter(y=>y.executableCode).map(y=>y.executableCode).filter(y=>y!==void 0);if((p==null?void 0:p.length)!==0)return(f=p==null?void 0:p[0])===null||f===void 0?void 0:f.code}get codeExecutionResult(){var e,t,r,s,a,c,u,h,f;if(((s=(r=(t=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||t===void 0?void 0:t.content)===null||r===void 0?void 0:r.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const p=(h=(u=(c=(a=this.candidates)===null||a===void 0?void 0:a[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)===null||h===void 0?void 0:h.filter(y=>y.codeExecutionResult).map(y=>y.codeExecutionResult).filter(y=>y!==void 0);if((p==null?void 0:p.length)!==0)return(f=p==null?void 0:p[0])===null||f===void 0?void 0:f.output}}class tN{}class nN{}class PH{}class MH{}class LH{}class jH{}class rN{}class sN{}class iN{}class OH{}class Ug{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const r=new Ug;let s;const a=e;return t?s=vH(a):s=bH(a),Object.assign(r,s),r}}class FH{}class aN{}class oN{}class lN{}class UH{}class VH{}class GH{}class AC{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const r=new AC,a=SH(e);return Object.assign(r,a),r}}class HH{}class qH{}class zH{}class JH{}class cN{}class $H{get text(){var e,t,r;let s="",a=!1;const c=[];for(const u of(r=(t=(e=this.serverContent)===null||e===void 0?void 0:e.modelTurn)===null||t===void 0?void 0:t.parts)!==null&&r!==void 0?r:[]){for(const[h,f]of Object.entries(u))h!=="text"&&h!=="thought"&&f!==null&&c.push(h);if(typeof u.text=="string"){if(typeof u.thought=="boolean"&&u.thought)continue;a=!0,s+=u.text}}return c.length>0&&console.warn(`there are non-text parts ${c} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),a?s:void 0}get data(){var e,t,r;let s="";const a=[];for(const c of(r=(t=(e=this.serverContent)===null||e===void 0?void 0:e.modelTurn)===null||t===void 0?void 0:t.parts)!==null&&r!==void 0?r:[]){for(const[u,h]of Object.entries(c))u!=="inlineData"&&h!==null&&a.push(u);c.inlineData&&typeof c.inlineData.data=="string"&&(s+=atob(c.inlineData.data))}return a.length>0&&console.warn(`there are non-data parts ${a} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),s.length>0?btoa(s):void 0}}class KH{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class IC{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const r=new IC,a=LA(e);return Object.assign(r,a),r}}/**
4281 * @license
4282 * Copyright 2025 Google LLC
4283 * SPDX-License-Identifier: Apache-2.0
4284 */function $t(n,e){if(!e||typeof e!="string")throw new Error("model is required and must be a string");if(e.includes("..")||e.includes("?")||e.includes("&"))throw new Error("invalid model parameter");if(n.isVertexAI()){if(e.startsWith("publishers/")||e.startsWith("projects/")||e.startsWith("models/"))return e;if(e.indexOf("/")>=0){const t=e.split("/",2);return`publishers/${t[0]}/models/${t[1]}`}else return`publishers/google/models/${e}`}else return e.startsWith("models/")||e.startsWith("tunedModels/")?e:`models/${e}`}function jA(n,e){const t=$t(n,e);return t?t.startsWith("publishers/")&&n.isVertexAI()?`projects/${n.getProject()}/locations/${n.getLocation()}/${t}`:t.startsWith("models/")&&n.isVertexAI()?`projects/${n.getProject()}/locations/${n.getLocation()}/publishers/google/${t}`:t:""}function OA(n){return Array.isArray(n)?n.map(e=>Vg(e)):[Vg(n)]}function Vg(n){if(typeof n=="object"&&n!==null)return n;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof n}`)}function FA(n){const e=Vg(n);if(e.mimeType&&e.mimeType.startsWith("image/"))return e;throw new Error(`Unsupported mime type: ${e.mimeType}`)}function UA(n){const e=Vg(n);if(e.mimeType&&e.mimeType.startsWith("audio/"))return e;throw new Error(`Unsupported mime type: ${e.mimeType}`)}function uN(n){if(n==null)throw new Error("PartUnion is required");if(typeof n=="object")return n;if(typeof n=="string")return{text:n};throw new Error(`Unsupported part type: ${typeof n}`)}function VA(n){if(n==null||Array.isArray(n)&&n.length===0)throw new Error("PartListUnion is required");return Array.isArray(n)?n.map(e=>uN(e)):[uN(n)]}function Ky(n){return n!=null&&typeof n=="object"&&"parts"in n&&Array.isArray(n.parts)}function dN(n){return n!=null&&typeof n=="object"&&"functionCall"in n}function hN(n){return n!=null&&typeof n=="object"&&"functionResponse"in n}function Pr(n){if(n==null)throw new Error("ContentUnion is required");return Ky(n)?n:{role:"user",parts:VA(n)}}function RC(n,e){if(!e)return[];if(n.isVertexAI()&&Array.isArray(e))return e.flatMap(t=>{const r=Pr(t);return r.parts&&r.parts.length>0&&r.parts[0].text!==void 0?[r.parts[0].text]:[]});if(n.isVertexAI()){const t=Pr(e);return t.parts&&t.parts.length>0&&t.parts[0].text!==void 0?[t.parts[0].text]:[]}return Array.isArray(e)?e.map(t=>Pr(t)):[Pr(e)]}function ks(n){if(n==null||Array.isArray(n)&&n.length===0)throw new Error("contents are required");if(!Array.isArray(n)){if(dN(n)||hN(n))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[Pr(n)]}const e=[],t=[],r=Ky(n[0]);for(const s of n){const a=Ky(s);if(a!=r)throw new Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them");if(a)e.push(s);else{if(dN(s)||hN(s))throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");t.push(s)}}return r||e.push({role:"user",parts:VA(t)}),e}function YH(n,e){n.includes("null")&&(e.nullable=!0);const t=n.filter(r=>r!=="null");if(t.length===1)e.type=Object.values(qs).includes(t[0].toUpperCase())?t[0].toUpperCase():qs.TYPE_UNSPECIFIED;else{e.anyOf=[];for(const r of t)e.anyOf.push({type:Object.values(qs).includes(r.toUpperCase())?r.toUpperCase():qs.TYPE_UNSPECIFIED})}}function Nu(n){const e={},t=["items"],r=["anyOf"],s=["properties"];
4284if(n.type&&n.anyOf)throw new Error("type and anyOf cannot be both populated.");const a=n.anyOf;a!=null&&a.length==2&&(a[0].type==="null"?(e.nullable=!0,n=a[1]):a[1].type==="null"&&(e.nullable=!0,n=a[0])),n.type instanceof Array&&YH(n.type,e);for(const[c,u]of Object.entries(n))if(u!=null)if(c=="type"){if(u==="null")throw new Error("type: null can not be the only possible type for the field.");if(u instanceof Array)continue;e.type=Object.values(qs).includes(u.toUpperCase())?u.toUpperCase():qs.TYPE_UNSPECIFIED}else if(t.includes(c))e[c]=Nu(u);else if(r.includes(c)){const h=[];for(const f of u){if(f.type=="null"){e.nullable=!0;continue}h.push(Nu(f))}e[c]=h}else if(s.includes(c)){const h={};for(const[f,p]of Object.entries(u))h[f]=Nu(p);e[c]=h}else{if(c==="additionalProperties")continue;e[c]=u}return e}function PC(n){return Nu(n)}function MC(n){if(typeof n=="object")return n;if(typeof n=="string")return{voiceConfig:{prebuiltVoiceConfig:{voiceName:n}}};throw new Error(`Unsupported speechConfig type: ${typeof n}`)}function LC(n){if("multiSpeakerVoiceConfig"in n)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return n}function $u(n){if(n.functionDeclarations)for(const e of n.functionDeclarations)e.parameters&&(Object.keys(e.parameters).includes("$schema")?e.parametersJsonSchema||(e.parametersJsonSchema=e.parameters,delete e.parameters):e.parameters=Nu(e.parameters)),e.response&&(Object.keys(e.response).includes("$schema")?e.responseJsonSchema||(e.responseJsonSchema=e.response,delete e.response):e.response=Nu(e.response));return n}function Ku(n){if(n==null)throw new Error("tools is required");if(!Array.isArray(n))throw new Error("tools is required and must be an array of Tools");const e=[];for(const t of n)e.push(t);return e}function QH(n,e,t,r=1){const s=!e.startsWith(`${t}/`)&&e.split("/").length===r;return n.isVertexAI()?e.startsWith("projects/")?e:e.startsWith("locations/")?`projects/${n.getProject()}/${e}`:e.startsWith(`${t}/`)?`projects/${n.getProject()}/locations/${n.getLocation()}/${e}`:s?`projects/${n.getProject()}/locations/${n.getLocation()}/${t}/${e}`:e:s?`${t}/${e}`:e}function Za(n,e){if(typeof e!="string")throw new Error("name must be a string");return QH(n,e,"cachedContents")}function GA(n){switch(n){case"STATE_UNSPECIFIED":return"JOB_STATE_UNSPECIFIED";case"CREATING":return"JOB_STATE_RUNNING";case"ACTIVE":return"JOB_STATE_SUCCEEDED";case"FAILED":return"JOB_STATE_FAILED";default:return n}}function gl(n){return DC(n)}function WH(n){return n!=null&&typeof n=="object"&&"name"in n}function XH(n){return n!=null&&typeof n=="object"&&"video"in n}function ZH(n){return n!=null&&typeof n=="object"&&"uri"in n}function HA(n){var e;let t;if(WH(n)&&(t=n.name),!(ZH(n)&&(t=n.uri,t===void 0))&&!(XH(n)&&(t=(e=n.video)===null||e===void 0?void 0:e.uri,t===void 0))){if(typeof n=="string"&&(t=n),t===void 0)throw new Error("Could not extract file name from the provided input.");if(t.startsWith("https://")){const s=t.split("files/")[1].match(/[a-z0-9]+/);if(s===null)throw new Error(`Could not extract file name from URI ${t}`);t=s[0]}else t.startsWith("files/")&&(t=t.split("files/")[1]);return t}}function qA(n,e){let t;return n.isVertexAI()?t=e?"publishers/google/models":"models":t=e?"models":"tunedModels",t}function zA(n){for(const e of["models","tunedModels","publisherModels"])if(e8(n,e))return n[e];return[]}function e8(n,e){return n!==null&&typeof n=="object"&&e in n}function t8(n,e={}){const t=n,r={name:t.name,description:t.description,parametersJsonSchema:t.inputSchema};return t.outputSchema&&(r.responseJsonSchema=t.outputSchema),e.behavior&&(r.behavior=e.behavior),{functionDeclarations:[r]}}function n8(n,e={}){const t=[],r=new Set;for(const s of n){const a=s.name;if(r.has(a))throw new Error(`Duplicate function name ${a} found in MCP tools. Please ensure function names are unique.`);r.add(a);const c=t8(s,e);c.functionDeclarations&&t.push(...c.functionDeclarations)}return{functionDeclarations:t}}function JA(n,e){let t;if(typeof e=="string")if(n.isVertexAI())if(e.startsWith("gs://"))t={format:"jsonl",gcsUri:[e]};else if(e.startsWith("bq://"))t={format:"bigquery",bigqueryUri:e};else if(/^projects\/[^/]+\/locations\/[^/]+\/datasets\/[^/]+$/.test(e))t={format:"vertex-dataset",vertexDatasetN
4284ame:e};else throw new Error(`Unsupported string source for Vertex AI: ${e}`);else if(e.startsWith("files/"))t={fileName:e};else throw new Error(`Unsupported string source for Gemini API: ${e}`);else if(Array.isArray(e)){if(n.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");t={inlinedRequests:e}}else t=e;const r=[t.gcsUri,t.bigqueryUri,t.vertexDatasetName].filter(Boolean).length,s=[t.inlinedRequests,t.fileName].filter(Boolean).length;if(n.isVertexAI()){if(s>0||r!==1)throw new Error("Exactly one of `gcsUri`, `bigqueryUri`, or `vertexDatasetName` must be set for Vertex AI.")}else if(r>0||s!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return t}function r8(n){if(typeof n!="string")return n;const e=n;if(e.startsWith("gs://"))return{format:"jsonl",gcsUri:e};if(e.startsWith("bq://"))return{format:"bigquery",bigqueryUri:e};throw new Error(`Unsupported destination: ${e}`)}function $A(n){if(typeof n!="object"||n===null)return{};const e=n,t=e.inlinedResponses;if(typeof t!="object"||t===null)return n;const s=t.inlinedResponses;if(!Array.isArray(s)||s.length===0)return n;let a=!1;for(const c of s){if(typeof c!="object"||c===null)continue;const h=c.response;if(typeof h!="object"||h===null)continue;if(h.embedding!==void 0){a=!0;break}}return a&&(e.inlinedEmbedContentResponses=e.inlinedResponses,delete e.inlinedResponses),n}function Yu(n,e){const t=e;if(!n.isVertexAI()){if(/batches\/[^/]+$/.test(t))return t.split("/").pop();throw new Error(`Invalid batch job name: ${t}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(t))return t.split("/").pop();if(/^\d+$/.test(t))return t;throw new Error(`Invalid batch job name: ${t}.`)}function KA(n){const e=n;return e==="BATCH_STATE_UNSPECIFIED"?"JOB_STATE_UNSPECIFIED":e==="BATCH_STATE_PENDING"?"JOB_STATE_PENDING":e==="BATCH_STATE_RUNNING"?"JOB_STATE_RUNNING":e==="BATCH_STATE_SUCCEEDED"?"JOB_STATE_SUCCEEDED":e==="BATCH_STATE_FAILED"?"JOB_STATE_FAILED":e==="BATCH_STATE_CANCELLED"?"JOB_STATE_CANCELLED":e==="BATCH_STATE_EXPIRED"?"JOB_STATE_EXPIRED":e}function s8(n){return n.includes("gemini")&&n!=="gemini-embedding-001"||n.includes("maas")}/**
4285 * @license
4286 * Copyright 2025 Google LLC
4287 * SPDX-License-Identifier: Apache-2.0
4288 */function i8(n){const e={},t=g(n,["apiKey"]);if(t!=null&&B(e,["apiKey"],t),g(n,["apiKeyConfig"])!==void 0)throw new Error("apiKeyConfig parameter is not supported in Gemini API.");if(g(n,["authType"])!==void 0)throw new Error("authType parameter is not supported in Gemini API.");if(g(n,["googleServiceAccountConfig"])!==void 0)throw new Error("googleServiceAccountConfig parameter is not supported in Gemini API.");if(g(n,["httpBasicAuthConfig"])!==void 0)throw new Error("httpBasicAuthConfig parameter is not supported in Gemini API.");if(g(n,["oauthConfig"])!==void 0)throw new Error("oauthConfig parameter is not supported in Gemini API.");if(g(n,["oidcConfig"])!==void 0)throw new Error("oidcConfig parameter is not supported in Gemini API.");return e}function a8(n){const e={},t=g(n,["responsesFile"]);t!=null&&B(e,["fileName"],t);const r=g(n,["inlinedResponses","inlinedResponses"]);if(r!=null){let a=r;Array.isArray(a)&&(a=a.map(c=>U8(c))),B(e,["inlinedResponses"],a)}const s=g(n,["inlinedEmbedContentResponses","inlinedResponses"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>c)),B(e,["inlinedEmbedContentResponses"],a)}return e}function o8(n){const e={},t=g(n,["predictionsFormat"]);t!=null&&B(e,["format"],t);const r=g(n,["gcsDestination","outputUriPrefix"]);r!=null&&B(e,["gcsUri"],r);const s=g(n,["bigqueryDestination","outputUri"]);s!=null&&B(e,["bigqueryUri"],s);const a=g(n,["vertexMultimodalDatasetDestination"]);return a!=null&&B(e,["vertexDataset"],W8(a)),e}function l8(n){const e={},t=g(n,["format"]);t!=null&&B(e,["predictionsFormat"],t);const r=g(n,["gcsUri"]);r!=null&&B(e,["gcsDestination","outputUriPrefix"],r);const s=g(n,["bigqueryUri"]);if(s!=null&&B(e,["bigqueryDestination","outputUri"],s),g(n,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(g(n,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(g(n,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");const a=g(n,["vertexDataset"]);return a!=null&&B(e,["vertexMultimodalDatasetDestination"],X8(a)),e}function tg(n){const e={},t=g(n,["name"]);t!=null&&B(e,["name"],t);const r=g(n,["metadata","displayName"]);r!=null&&B(e,["displayName"],r);
4288const s=g(n,["metadata","state"]);s!=null&&B(e,["state"],KA(s));const a=g(n,["metadata","createTime"]);a!=null&&B(e,["createTime"],a);const c=g(n,["metadata","endTime"]);c!=null&&B(e,["endTime"],c);const u=g(n,["metadata","updateTime"]);u!=null&&B(e,["updateTime"],u);const h=g(n,["metadata","model"]);h!=null&&B(e,["model"],h);const f=g(n,["metadata","output"]);return f!=null&&B(e,["dest"],a8($A(f))),e}function Yy(n){const e={},t=g(n,["name"]);t!=null&&B(e,["name"],t);const r=g(n,["displayName"]);r!=null&&B(e,["displayName"],r);const s=g(n,["state"]);s!=null&&B(e,["state"],KA(s));const a=g(n,["error"]);a!=null&&B(e,["error"],a);const c=g(n,["createTime"]);c!=null&&B(e,["createTime"],c);const u=g(n,["startTime"]);u!=null&&B(e,["startTime"],u);const h=g(n,["endTime"]);h!=null&&B(e,["endTime"],h);const f=g(n,["updateTime"]);f!=null&&B(e,["updateTime"],f);const p=g(n,["model"]);p!=null&&B(e,["model"],p);const y=g(n,["inputConfig"]);y!=null&&B(e,["src"],c8(y));const b=g(n,["outputConfig"]);b!=null&&B(e,["dest"],o8($A(b)));const w=g(n,["completionStats"]);w!=null&&B(e,["completionStats"],w);const E=g(n,["outputInfo"]);return E!=null&&B(e,["outputInfo"],E),e}function c8(n){const e={},t=g(n,["instancesFormat"]);t!=null&&B(e,["format"],t);const r=g(n,["gcsSource","uris"]);r!=null&&B(e,["gcsUri"],r);const s=g(n,["bigquerySource","inputUri"]);s!=null&&B(e,["bigqueryUri"],s);const a=g(n,["vertexMultimodalDatasetSource","datasetName"]);return a!=null&&B(e,["vertexDatasetName"],a),e}function u8(n,e){const t={};if(g(e,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(g(e,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(g(e,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const r=g(e,["fileName"]);r!=null&&B(t,["fileName"],r);const s=g(e,["inlinedRequests"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>F8(n,c))),B(t,["requests","requests"],a)}if(g(e,["vertexDatasetName"])!==void 0)throw new Error("vertexDatasetName parameter is not supported in Gemini API.");return t}function d8(n){const e={},t=g(n,["format"]);t!=null&&B(e,["instancesFormat"],t);const r=g(n,["gcsUri"]);r!=null&&B(e,["gcsSource","uris"],r);const s=g(n,["bigqueryUri"]);if(s!=null&&B(e,["bigquerySource","inputUri"],s),g(n,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(g(n,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");const a=g(n,["vertexDatasetName"]);return a!=null&&B(e,["vertexMultimodalDatasetSource","datasetName"],a),e}function h8(n){const e={},t=g(n,["data"]);if(t!=null&&B(e,["data"],t),g(n,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=g(n,["mimeType"]);return r!=null&&B(e,["mimeType"],r),e}function f8(n,e){const t={},r=g(e,["name"]);return r!=null&&B(t,["_url","name"],Yu(n,r)),t}function m8(n,e){const t={},r=g(e,["name"]);return r!=null&&B(t,["_url","name"],Yu(n,r)),t}function g8(n){const e={},t=g(n,["content"]);t!=null&&B(e,["content"],t);const r=g(n,["citationMetadata"]);r!=null&&B(e,["citationMetadata"],p8(r));const s=g(n,["tokenCount"]);s!=null&&B(e,["tokenCount"],s);const a=g(n,["finishReason"]);a!=null&&B(e,["finishReason"],a);const c=g(n,["groundingMetadata"]);c!=null&&B(e,["groundingMetadata"],c);const u=g(n,["avgLogprobs"]);u!=null&&B(e,["avgLogprobs"],u);const h=g(n,["index"]);h!=null&&B(e,["index"],h);const f=g(n,["logprobsResult"]);f!=null&&B(e,["logprobsResult"],f);const p=g(n,["safetyRatings"]);if(p!=null){let b=p;Array.isArray(b)&&(b=b.map(w=>w)),B(e,["safetyRatings"],b)}const y=g(n,["urlContextMetadata"]);return y!=null&&B(e,["urlContextMetadata"],y),e}function p8(n){const e={},t=g(n,["citationSources"]);if(t!=null){let r=t;Array.isArray(r)&&(r=r.map(s=>s)),B(e,["citations"],r)}return e}function YA(n){const e={},t=g(n,["parts"]);if(t!=null){let s=t;Array.isArray(s)&&(s=s.map(a=>$8(a))),B(e,["parts"],s)}const r=g(n,["role"]);return r!=null&&B(e,["role"],r),e}function B8(n,e){const t={},r=g(n,["displayName"]);if(e!==void 0&&r!=null&&B(e,["batch","displayName"],r),g(n,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");const s=g(n,["webhookConfig"]);return e!==void 0&&s!=null&&B(e,["batch","webhookConfig"],s),t}function y8(n,e){const t={},r=g(n,["displayName"]);e!==void 0&&r!=null&&B(e,["displayName"],r);const s=g(n,["dest"]);if(e!==void 0&&s!=null&&B(e,["outputConfig"],l8(r8(s))),g(n,["webhookConfig"])!==void 0)throw new Error("webhookConfig parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return t}function fN(n,e){const t={},r=g(e,["model"]);r!=null&&B(t,["_url","model"],$t(n,r));const s=g(e,["src"]);s!=null&&B(t,["batch","inputConfig"],u8(n,JA(n,s)));const a=g(e,["config"]);return a!=null&&B8(a,t),t}function x8(n,e){const t={},r=g(e,["model"]);r!=null&&B(t,["model"],$t(n,r));const s=g(e,["src"]);s!=null&&B(t,["inputConfig"],d8(JA(n,s)));const a=g(e,["config"]);return a!=null&&y8(a,t),t}function C8(n,e){const t={},r=g(n,["displayName"]);return e!==void 0&&r!=null&&B(e,["batch","displayName"],r),t}function b8(n,e){const t={},r=g(e,["model"]);r!=null&&B(t,["_url","model"],$t(n,r));const s=g(e,["src"]);s!=null&&B(t,["batch","inputConfig"],N8(n,s));const a=g(e,["config"]);return a!=null&&C8(a,t),t}function v8(n,e){const t={},r=g(e,["name"]);return r!=null&&B(t,["_url","name"],Yu(n,r)),t}function w8(n,e){const t={},r=g(e,["name"]);return r!=null&&B(t,["_url","name"],Yu(n,r)),t}function E8(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["name"]);r!=null&&B(e,["name"],r);const s=g(n,["done"]);s!=null&&B(e,["done"],s);const a=g(n,["error"]);return a!=null&&B(e,["error"],a),e}function _8(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["name"]);r!=null&&B(e,["name"],r);const s=g(n,["done"]);s!=null&&B(e,["done"],s);const a=g(n,["error"]);return a!=null&&B(e,["error"],a),e}function T8(n,e){const t={},r=g(e,["contents"]);if(r!=null){let a=RC(n,r);Array.isArray(a)&&(a=a.map(c=>c)),B(t,["requests[]","request","content"],a)}const s=g(e,["config"]);return s!=null&&(B(t,["_self"],k8(s,t)),xH(t,{"requests[].*":"requests[].request.*"})),t}function k8(n,e){const t={},r=g(n,["taskType"]);e!==void 0&&r!=null&&B(e,["requests[]","taskType"],r);
4288const s=g(n,["title"]);e!==void 0&&s!=null&&B(e,["requests[]","title"],s);const a=g(n,["outputDimensionality"]);if(e!==void 0&&a!=null&&B(e,["requests[]","outputDimensionality"],a),g(n,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(g(n,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");if(g(n,["documentOcr"])!==void 0)throw new Error("documentOcr parameter is not supported in Gemini API.");if(g(n,["audioTrackExtraction"])!==void 0)throw new Error("audioTrackExtraction parameter is not supported in Gemini API.");return t}function N8(n,e){const t={},r=g(e,["fileName"]);r!=null&&B(t,["file_name"],r);const s=g(e,["inlinedRequests"]);return s!=null&&B(t,["requests"],T8(n,s)),t}function S8(n){const e={};if(g(n,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const t=g(n,["fileUri"]);t!=null&&B(e,["fileUri"],t);const r=g(n,["mimeType"]);return r!=null&&B(e,["mimeType"],r),e}function D8(n){const e={},t=g(n,["id"]);t!=null&&B(e,["id"],t);const r=g(n,["args"]);r!=null&&B(e,["args"],r);const s=g(n,["name"]);if(s!=null&&B(e,["name"],s),g(n,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(g(n,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function A8(n){const e={},t=g(n,["allowedFunctionNames"]);t!=null&&B(e,["allowedFunctionNames"],t);const r=g(n,["mode"]);if(r!=null&&B(e,["mode"],r),g(n,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return e}function I8(n,e,t){const r={},s=g(e,["systemInstruction"]);t!==void 0&&s!=null&&B(t,["systemInstruction"],YA(Pr(s)));const a=g(e,["temperature"]);a!=null&&B(r,["temperature"],a);const c=g(e,["topP"]);c!=null&&B(r,["topP"],c);const u=g(e,["topK"]);u!=null&&B(r,["topK"],u);const h=g(e,["candidateCount"]);h!=null&&B(r,["candidateCount"],h);const f=g(e,["maxOutputTokens"]);f!=null&&B(r,["maxOutputTokens"],f);const p=g(e,["stopSequences"]);p!=null&&B(r,["stopSequences"],p);const y=g(e,["responseLogprobs"]);y!=null&&B(r,["responseLogprobs"],y);const b=g(e,["logprobs"]);b!=null&&B(r,["logprobs"],b);const w=g(e,["presencePenalty"]);w!=null&&B(r,["presencePenalty"],w);const E=g(e,["frequencyPenalty"]);E!=null&&B(r,["frequencyPenalty"],E);const N=g(e,["seed"]);N!=null&&B(r,["seed"],N);const S=g(e,["responseMimeType"]);S!=null&&B(r,["responseMimeType"],S);const I=g(e,["responseSchema"]);I!=null&&B(r,["responseSchema"],PC(I));const O=g(e,["responseJsonSchema"]);if(O!=null&&B(r,["responseJsonSchema"],O),g(e,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(g(e,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const F=g(e,["safetySettings"]);if(t!==void 0&&F!=null){let ee=F;Array.isArray(ee)&&(ee=ee.map(ne=>K8(ne))),B(t,["safetySettings"],ee)}const J=g(e,["tools"]);if(t!==void 0&&J!=null){let ee=Ku(J);Array.isArray(ee)&&(ee=ee.map(ne=>Q8($u(ne)))),B(t,["tools"],ee)}const z=g(e,["toolConfig"]);if(t!==void 0&&z!=null&&B(t,["toolConfig"],Y8(z)),g(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const U=g(e,["cachedContent"]);t!==void 0&&U!=null&&B(t,["cachedContent"],Za(n,U));const D=g(e,["responseModalities"]);D!=null&&B(r,["responseModalities"],D);const k=g(e,["mediaResolution"]);k!=null&&B(r,["mediaResolution"],k);const _=g(e,["speechConfig"]);if(_!=null&&B(r,["speechConfig"],MC(_)),g(e,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const M=g(e,["thinkingConfig"]);M!=null&&B(r,["thinkingConfig"],M);const j=g(e,["imageConfig"]);j!=null&&B(r,["imageConfig"],O8(j));const H=g(e,["enableEnhancedCivicAnswers"]);if(H!=null&&B(r,["enableEnhancedCivicAnswers"],H),g(e,["modelArmorConfig"])!==void 0)throw new Error("modelArmorConfig parameter is not supported in Gemini API.");const L=g(e,["serviceTier"]);return t!==void 0&&L!=null&&B(t,["serviceTier"],L),r}function R8(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["candidates"]);if(r!=null){let f=r;Array.isArray(f)&&(f=f.map(p=>g8(p))),B(e,["candidates"],f)}const s=g(n,["modelVersion"]);s!=null&&B(e,["modelVersion"],s);const a=g(n,["promptFeedback"]);a!=null&&B(e,["promptFeedback"],a);const c=g(n,["responseId"]);c!=null&&B(e,["responseId"],c);const u=g(n,["usageMetadata"]);u!=null&&B(e,["usageMetadata"],u);const h=g(n,["modelStatus"]);return h!=null&&B(e,["modelStatus"],h),e}function P8(n,e){const t={},r=g(e,["name"]);return r!=null&&B(t,["_url","name"],Yu(n,r)),t}function M8(n,e){const t={},r=g(e,["name"]);return r!=null&&B(t,["_url","name"],Yu(n,r)),t}function L8(n){const e={},t=g(n,["authConfig"]);t!=null&&B(e,["authConfig"],i8(t));const r=g(n,["enableWidget"]);return r!=null&&B(e,["enableWidget"],r),e}function j8(n){const e={},t=g(n,["searchTypes"]);if(t!=null&&B(e,["searchTypes"],t),g(n,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");if(g(n,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");const r=g(n,["timeRangeFilter"]);return r!=null&&B(e,["timeRangeFilter"],r),e}function O8(n){const e={}
4288,t=g(n,["aspectRatio"]);t!=null&&B(e,["aspectRatio"],t);const r=g(n,["imageSize"]);if(r!=null&&B(e,["imageSize"],r),g(n,["personGeneration"])!==void 0)throw new Error("personGeneration parameter is not supported in Gemini API.");if(g(n,["prominentPeople"])!==void 0)throw new Error("prominentPeople parameter is not supported in Gemini API.");if(g(n,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(g(n,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");if(g(n,["imageOutputOptions"])!==void 0)throw new Error("imageOutputOptions parameter is not supported in Gemini API.");return e}function F8(n,e){const t={},r=g(e,["model"]);r!=null&&B(t,["request","model"],$t(n,r));const s=g(e,["contents"]);if(s!=null){let u=ks(s);Array.isArray(u)&&(u=u.map(h=>YA(h))),B(t,["request","contents"],u)}const a=g(e,["metadata"]);a!=null&&B(t,["metadata"],a);const c=g(e,["config"]);return c!=null&&B(t,["request","generationConfig"],I8(n,c,g(t,["request"],{}))),t}function U8(n){const e={},t=g(n,["response"]);t!=null&&B(e,["response"],R8(t));const r=g(n,["metadata"]);r!=null&&B(e,["metadata"],r);const s=g(n,["error"]);return s!=null&&B(e,["error"],s),e}function V8(n,e){const t={},r=g(n,["pageSize"]);e!==void 0&&r!=null&&B(e,["_query","pageSize"],r);const s=g(n,["pageToken"]);if(e!==void 0&&s!=null&&B(e,["_query","pageToken"],s),g(n,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return t}function G8(n,e){const t={},r=g(n,["pageSize"]);e!==void 0&&r!=null&&B(e,["_query","pageSize"],r);const s=g(n,["pageToken"]);e!==void 0&&s!=null&&B(e,["_query","pageToken"],s);const a=g(n,["filter"]);return e!==void 0&&a!=null&&B(e,["_query","filter"],a),t}function H8(n){const e={},t=g(n,["config"]);return t!=null&&V8(t,e),e}function q8(n){const e={},t=g(n,["config"]);return t!=null&&G8(t,e),e}function z8(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["nextPageToken"]);r!=null&&B(e,["nextPageToken"],r);const s=g(n,["operations"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>tg(c))),B(e,["batchJobs"],a)}return e}function J8(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["nextPageToken"]);r!=null&&B(e,["nextPageToken"],r);const s=g(n,["batchPredictionJobs"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>Yy(c))),B(e,["batchJobs"],a)}return e}function $8(n){const e={},t=g(n,["mediaResolution"]);t!=null&&B(e,["mediaResolution"],t);const r=g(n,["codeExecutionResult"]);r!=null&&B(e,["codeExecutionResult"],r);const s=g(n,["executableCode"]);s!=null&&B(e,["executableCode"],s);const a=g(n,["fileData"]);a!=null&&B(e,["fileData"],S8(a));const c=g(n,["functionCall"]);c!=null&&B(e,["functionCall"],D8(c));const u=g(n,["functionResponse"]);u!=null&&B(e,["functionResponse"],u);const h=g(n,["inlineData"]);h!=null&&B(e,["inlineData"],h8(h));const f=g(n,["text"]);f!=null&&B(e,["text"],f);const p=g(n,["thought"]);p!=null&&B(e,["thought"],p);const y=g(n,["thoughtSignature"]);y!=null&&B(e,["thoughtSignature"],y);const b=g(n,["videoMetadata"]);b!=null&&B(e,["videoMetadata"],b);const w=g(n,["toolCall"]);w!=null&&B(e,["toolCall"],w);const E=g(n,["toolResponse"]);E!=null&&B(e,["toolResponse"],E);const N=g(n,["partMetadata"]);return N!=null&&B(e,["partMetadata"],N),e}function K8(n){const e={},t=g(n,["category"]);if(t!=null&&B(e,["category"],t),g(n,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const r=g(n,["threshold"]);return r!=null&&B(e,["threshold"],r),e}function Y8(n){const e={},t=g(n,["retrievalConfig"]);t!=null&&B(e,["retrievalConfig"],t);const r=g(n,["functionCallingConfig"]);r!=null&&B(e,["functionCallingConfig"],A8(r));const s=g(n,["includeServerSideToolInvocations"]);return s!=null&&B(e,["includeServerSideToolInvocations"],s),e}function Q8(n){const e={};if(g(n,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const t=g(n,["computerUse"]);t!=null&&B(e,["computerUse"],t);const r=g(n,["fileSearch"]);r!=null&&B(e,["fileSearch"],r);const s=g(n,["googleSearch"]);s!=null&&B(e,["googleSearch"],j8(s));const a=g(n,["googleMaps"]);a!=null&&B(e,["googleMaps"],L8(a));const c=g(n,["codeExecution"]);if(c!=null&&B(e,["codeExecution"],c),g(n,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=g(n,["functionDeclarations"]);if(u!=null){let y=u;Array.isArray(y)&&(y=y.map(b=>b)),B(e,["functionDeclarations"],y)}const h=g(n,["googleSearchRetrieval"]);if(h!=null&&B(e,["googleSearchRetrieval"],h),g(n,["parallelAiSearch"])!==void 0)throw new Error("parallelAiSearch parameter is not supported in Gemini API.");const f=g(n,["urlContext"]);
4288f!=null&&B(e,["urlContext"],f);const p=g(n,["mcpServers"]);if(p!=null){let y=p;Array.isArray(y)&&(y=y.map(b=>b)),B(e,["mcpServers"],y)}return e}function W8(n){const e={},t=g(n,["bigqueryDestination","outputUri"]);t!=null&&B(e,["bigqueryDestination"],t);const r=g(n,["displayName"]);return r!=null&&B(e,["displayName"],r),e}function X8(n){const e={},t=g(n,["bigqueryDestination"]);t!=null&&B(e,["bigqueryDestination","outputUri"],t);const r=g(n,["displayName"]);return r!=null&&B(e,["displayName"],r),e}/**
4289 * @license
4290 * Copyright 2025 Google LLC
4291 * SPDX-License-Identifier: Apache-2.0
4292 */var $a;(function(n){n.PAGED_ITEM_BATCH_JOBS="batchJobs",n.PAGED_ITEM_MODELS="models",n.PAGED_ITEM_TUNING_JOBS="tuningJobs",n.PAGED_ITEM_FILES="files",n.PAGED_ITEM_CACHED_CONTENTS="cachedContents",n.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",n.PAGED_ITEM_DOCUMENTS="documents"})($a||($a={}));class kc{constructor(e,t,r,s){this.pageInternal=[],this.paramsInternal={},this.requestInternal=t,this.init(e,r,s)}init(e,t,r){var s,a;this.nameInternal=e,this.pageInternal=t[this.nameInternal]||[],this.sdkHttpResponseInternal=t==null?void 0:t.sdkHttpResponse,this.idxInternal=0;let c={config:{}};!r||Object.keys(r).length===0?c={config:{}}:typeof r=="object"?c=Object.assign({},r):c=r,c.config&&(c.config.pageToken=t.nextPageToken),this.paramsInternal=c,this.pageInternalSize=(a=(s=c.config)===null||s===void 0?void 0:s.pageSize)!==null&&a!==void 0?a:this.pageInternal.length}initNextPage(e){this.init(this.nameInternal,e,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(e){return this.pageInternal[e]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const e=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:e,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){var e;return((e=this.params.config)===null||e===void 0?void 0:e.pageToken)!==void 0}}/**
4293 * @license
4294 * Copyright 2025 Google LLC
4295 * SPDX-License-Identifier: Apache-2.0
4296 */class Z8 extends Xa{constructor(e){super(),this.apiClient=e,this.list=async(t={})=>new kc($a.PAGED_ITEM_BATCH_JOBS,r=>this.listInternal(r),await this.listInternal(t),t),this.create=async t=>(this.apiClient.isVertexAI()&&(t.config=this.formatDestination(t.src,t.config)),this.createInternal(t)),this.createEmbeddings=async t=>{if(console.warn("batches.createEmbeddings() is experimental and may change without notice."),this.apiClient.isVertexAI())throw new Error("Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(t)}}createInlinedGenerateContentRequest(e){const t=fN(this.apiClient,e),r=t._url,s=Ve("{model}:batchGenerateContent",r),u=t.batch.inputConfig.requests,h=u.requests,f=[];for(const p of h){const y=Object.assign({},p);if(y.systemInstruction){const b=y.systemInstruction;delete y.systemInstruction;const w=y.request;w.systemInstruction=b,y.request=w}f.push(y)}return u.requests=f,delete t.config,delete t._url,delete t._query,{path:s,body:t}}getGcsUri(e){if(typeof e=="string")return e.startsWith("gs://")?e:void 0;if(!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0)return e.gcsUri[0]}getBigqueryUri(e){if(typeof e=="string")return e.startsWith("bq://")?e:void 0;if(!Array.isArray(e))return e.bigqueryUri}formatDestination(e,t){const r=t?Object.assign({},t):{},s=Date.now().toString();if(r.displayName||(r.displayName=`genaiBatchJob_${s}`),r.dest===void 0){const a=this.getGcsUri(e),c=this.getBigqueryUri(e);if(a)a.endsWith(".jsonl")?r.dest=`${a.slice(0,-6)}/dest`:r.dest=`${a}_dest_${s}`;else if(c)r.dest=`${c}_dest_${s}`;else throw new Error("Unsupported source for Gemini Enterprise Agent Platform (previously known as Vertex AI): No GCS or BigQuery URI found.")}return r}async createInternal(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=x8(this.apiClient,e);return u=Ve("batchPredictionJobs",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json()),c.then(p=>Yy(p))}else{const f=fN(this.apiClient,e);return u=Ve("{model}:batchGenerateContent",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json()),c.then(p=>tg(p))}}async createEmbeddingsInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=b8(this.apiClient,e);return a=Ve("{model}:asyncBatchEmbedContent",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>tg(h))}}async get(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=M8(this.apiClient,e);return u=Ve("batchPredictionJobs/{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json()),c.then(p=>Yy(p))}else{const f=P8(this.apiClient,e);return u=Ve("batches/{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json()),c.then(p=>tg(p))}}async cancel(e){var t,r,s,a;let c="",u={};if(this.apiClient.isVertexAI()){const h=m8(this.apiClient,e);c=Ve("batchPredictionJobs/{name}:cancel",h._url),u=h._query,delete h._url,delete h._query,await this.apiClient.request({path:c,queryParams:u,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal})}else{const h=f8(this.apiClient,e);c=Ve("batches/{name}:cancel",h._url),u=h._query,delete h._url,delete h._query,await this.apiClient.request({path:c,queryParams:u,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal})}}async listInternal(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=q8(e);return u=Ve("batchPredictionJobs",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=J8(p),b=new cN;return Object.assign(b,y),b})}else{const f=H8(e);return u=Ve("batches",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=z8(p),b=new cN;return Object.assign(b,y),b})}}async delete(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=w8(this.apiClient,e);return u=Ve("batchPredictionJobs/{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>_8(p))}else{const f=v8(this.apiClient,e);return u=Ve("batches/{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>E8(p))}}}/**
4297 * @license
4298 * Copyright 2025 Google LLC
4299 * SPDX-License-Identifier: Apache-2.0
4300 */function e9(n){const e={},t=g(n,["apiKey"]);if(t!=null&&B(e,["apiKey"],t),g(n,["apiKeyConfig"])!==void 0)throw new Error("apiKeyConfig parameter is not supported in Gemini API.");if(g(n,["authType"])!==void 0)throw new Error("authType parameter is not supported in Gemini API.");if(g(n,["googleServiceAccountConfig"])!==void 0)throw new Error("googleServiceAccountConfig parameter is not supported in Gemini API.");if(g(n,["httpBasicAuthConfig"])!==void 0)throw new Error("httpBasicAuthConfig parameter is not supported in Gemini API.");if(g(n,["oauthConfig"])!==void 0)throw new Error("oauthConfig parameter is not supported in Gemini API.");if(g(n,["oidcConfig"])!==void 0)throw new Error("oidcConfig parameter is not supported in Gemini API.");return e}function t9(n){const e={},t=g(n,["data"]);if(t!=null&&B(e,["data"],t),g(n,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=g(n,["mimeType"]);return r!=null&&B(e,["mimeType"],r),e}function mN(n){const e={},t=g(n,["parts"]);if(t!=null){let s=t;Array.isArray(s)&&(s=s.map(a=>E9(a))),B(e,["parts"],s)}const r=g(n,["role"]);return r!=null&&B(e,["role"],r),e}function gN(n){const e={},t=g(n,["parts"]);if(t!=null){let s=t;Array.isArray(s)&&(s=s.map(a=>_9(a))),B(e,["parts"],s)}const r=g(n,["role"]);return r!=null&&B(e,["role"],r),e}function n9(n,e){const t={},r=g(n,["ttl"]);e!==void 0&&r!=null&&B(e,["ttl"],r);const s=g(n,["expireTime"]);e!==void 0&&s!=null&&B(e,["expireTime"],s);const a=g(n,["displayName"]);e!==void 0&&a!=null&&B(e,["displayName"],a);const c=g(n,["contents"]);if(e!==void 0&&c!=null){let p=ks(c);Array.isArray(p)&&(p=p.map(y=>mN(y))),B(e,["contents"],p)}const u=g(n,["systemInstruction"]);e!==void 0&&u!=null&&B(e,["systemInstruction"],mN(Pr(u)));const h=g(n,["tools"]);if(e!==void 0&&h!=null){let p=h;Array.isArray(p)&&(p=p.map(y=>N9(y))),B(e,["tools"],p)}const f=g(n,["toolConfig"]);if(e!==void 0&&f!=null&&B(e,["toolConfig"],T9(f)),g(n,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return t}function r9(n,e){const t={},r=g(n,["ttl"]);e!==void 0&&r!=null&&B(e,["ttl"],r);const s=g(n,["expireTime"]);e!==void 0&&s!=null&&B(e,["expireTime"],s);const a=g(n,["displayName"]);e!==void 0&&a!=null&&B(e,["displayName"],a);const c=g(n,["contents"]);if(e!==void 0&&c!=null){let y=ks(c);Array.isArray(y)&&(y=y.map(b=>gN(b))),B(e,["contents"],y)}const u=g(n,["systemInstruction"]);e!==void 0&&u!=null&&B(e,["systemInstruction"],gN(Pr(u)));const h=g(n,["tools"]);if(e!==void 0&&h!=null){let y=h;Array.isArray(y)&&(y=y.map(b=>S9(b))),B(e,["tools"],y)}const f=g(n,["toolConfig"]);e!==void 0&&f!=null&&B(e,["toolConfig"],k9(f));const p=g(n,["kmsKeyName"]);return e!==void 0&&p!=null&&B(e,["encryption_spec","kmsKeyName"],p),t}function s9(n,e){const t={},r=g(e,["model"]);r!=null&&B(t,["model"],jA(n,r));const s=g(e,["config"]);return s!=null&&n9(s,t),t}function i9(n,e){const t={},r=g(e,["model"]);r!=null&&B(t,["model"],jA(n,r));const s=g(e,["config"]);return s!=null&&r9(s,t),t}function a9(n,e){const t={},r=g(e,["name"]);return r!=null&&B(t,["_url","name"],Za(n,r)),t}function o9(n,e){const t={},r=g(e,["name"]);return r!=null&&B(t,["_url","name"],Za(n,r)),t}function l9(n){const e={},t=g(n,["sdkHttpResponse"]);return t!=null&&B(e,["sdkHttpResponse"],t),e}function c9(n){const e={},t=g(n,["sdkHttpResponse"]);return t!=null&&B(e,["sdkHttpResponse"],t),e}function u9(n){const e={};
4300if(g(n,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const t=g(n,["fileUri"]);t!=null&&B(e,["fileUri"],t);const r=g(n,["mimeType"]);return r!=null&&B(e,["mimeType"],r),e}function d9(n){const e={},t=g(n,["id"]);t!=null&&B(e,["id"],t);const r=g(n,["args"]);r!=null&&B(e,["args"],r);const s=g(n,["name"]);if(s!=null&&B(e,["name"],s),g(n,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(g(n,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function h9(n){const e={},t=g(n,["allowedFunctionNames"]);t!=null&&B(e,["allowedFunctionNames"],t);const r=g(n,["mode"]);if(r!=null&&B(e,["mode"],r),g(n,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return e}function f9(n){const e={},t=g(n,["description"]);t!=null&&B(e,["description"],t);const r=g(n,["name"]);r!=null&&B(e,["name"],r);const s=g(n,["parameters"]);s!=null&&B(e,["parameters"],s);const a=g(n,["parametersJsonSchema"]);a!=null&&B(e,["parametersJsonSchema"],a);const c=g(n,["response"]);c!=null&&B(e,["response"],c);const u=g(n,["responseJsonSchema"]);if(u!=null&&B(e,["responseJsonSchema"],u),g(n,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return e}function m9(n,e){const t={},r=g(e,["name"]);return r!=null&&B(t,["_url","name"],Za(n,r)),t}function g9(n,e){const t={},r=g(e,["name"]);return r!=null&&B(t,["_url","name"],Za(n,r)),t}function p9(n){const e={},t=g(n,["authConfig"]);t!=null&&B(e,["authConfig"],e9(t));const r=g(n,["enableWidget"]);return r!=null&&B(e,["enableWidget"],r),e}function B9(n){const e={},t=g(n,["searchTypes"]);if(t!=null&&B(e,["searchTypes"],t),g(n,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");if(g(n,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");const r=g(n,["timeRangeFilter"]);return r!=null&&B(e,["timeRangeFilter"],r),e}function y9(n,e){const t={},r=g(n,["pageSize"]);e!==void 0&&r!=null&&B(e,["_query","pageSize"],r);const s=g(n,["pageToken"]);return e!==void 0&&s!=null&&B(e,["_query","pageToken"],s),t}function x9(n,e){const t={},r=g(n,["pageSize"]);e!==void 0&&r!=null&&B(e,["_query","pageSize"],r);const s=g(n,["pageToken"]);return e!==void 0&&s!=null&&B(e,["_query","pageToken"],s),t}function C9(n){const e={},t=g(n,["config"]);return t!=null&&y9(t,e),e}function b9(n){const e={},t=g(n,["config"]);return t!=null&&x9(t,e),e}function v9(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["nextPageToken"]);r!=null&&B(e,["nextPageToken"],r);const s=g(n,["cachedContents"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>c)),B(e,["cachedContents"],a)}return e}function w9(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["nextPageToken"]);r!=null&&B(e,["nextPageToken"],r);const s=g(n,["cachedContents"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>c)),B(e,["cachedContents"],a)}return e}function E9(n){const e={},t=g(n,["mediaResolution"]);t!=null&&B(e,["mediaResolution"],t);const r=g(n,["codeExecutionResult"]);r!=null&&B(e,["codeExecutionResult"],r);const s=g(n,["executableCode"]);s!=null&&B(e,["executableCode"],s);const a=g(n,["fileData"]);a!=null&&B(e,["fileData"],u9(a));const c=g(n,["functionCall"]);c!=null&&B(e,["functionCall"],d9(c));const u=g(n,["functionResponse"]);u!=null&&B(e,["functionResponse"],u);const h=g(n,["inlineData"]);h!=null&&B(e,["inlineData"],t9(h));const f=g(n,["text"]);f!=null&&B(e,["text"],f);const p=g(n,["thought"]);p!=null&&B(e,["thought"],p);const y=g(n,["thoughtSignature"]);y!=null&&B(e,["thoughtSignature"],y);const b=g(n,["videoMetadata"]);b!=null&&B(e,["videoMetadata"],b);const w=g(n,["toolCall"]);w!=null&&B(e,["toolCall"],w);const E=g(n,["toolResponse"]);E!=null&&B(e,["toolResponse"],E);const N=g(n,["partMetadata"]);return N!=null&&B(e,["partMetadata"],N),e}function _9(n){const e={},t=g(n,["mediaResolution"]);t!=null&&B(e,["mediaResolution"],t);const r=g(n,["codeExecutionResult"]);r!=null&&B(e,["codeExecutionResult"],r);const s=g(n,["executableCode"]);s!=null&&B(e,["executableCode"],s);const a=g(n,["fileData"]);a!=null&&B(e,["fileData"],a);const c=g(n,["functionCall"]);c!=null&&B(e,["functionCall"],c);const u=g(n,["functionResponse"]);u!=null&&B(e,["functionResponse"],u);const h=g(n,["inlineData"]);h!=null&&B(e,["inlineData"],h);const f=g(n,["text"]);f!=null&&B(e,["text"],f);const p=g(n,["thought"]);p!=null&&B(e,["thought"],p);const y=g(n,["thoughtSignature"]);y!=null&&B(e,["thoughtSignature"],y);const b=g(n,["videoMetadata"]);if(b!=null&&B(e,["videoMetadata"],b),g(n,["toolCall"])!==void 0)throw new Error("toolCall parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(g(n,["toolResponse"])!==void 0)throw new Error("toolResponse parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(g(n,["partMetadata"])!==void 0)throw new Error("partMetadata parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return e}function T9(n){const e={},t=g(n,["retrievalConfig"]);t!=null&&B(e,["retrievalConfig"],t);const r=g(n,["functionCallingConfig"]);r!=null&&B(e,["functionCallingConfig"],h9(r));const s=g(n,["includeServerSideToolInvocations"]);return s!=null&&B(e,["includeServerSideToolInvocations"],s),e}function k9(n){const e={},t=g(n,["retrievalConfig"]);t!=null&&B(e,["retrievalConfig"],t);const r=g(n,["functionCallingConfig"]);if(r!=null&&B(e,["functionCallingConfig"],r),g(n,["includeServerSideToolInvocations"])!==void 0)throw new Error("includeServerSideToolInvocations parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return e}function N9(n){const e={};
4300if(g(n,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const t=g(n,["computerUse"]);t!=null&&B(e,["computerUse"],t);const r=g(n,["fileSearch"]);r!=null&&B(e,["fileSearch"],r);const s=g(n,["googleSearch"]);s!=null&&B(e,["googleSearch"],B9(s));const a=g(n,["googleMaps"]);a!=null&&B(e,["googleMaps"],p9(a));const c=g(n,["codeExecution"]);if(c!=null&&B(e,["codeExecution"],c),g(n,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=g(n,["functionDeclarations"]);if(u!=null){let y=u;Array.isArray(y)&&(y=y.map(b=>b)),B(e,["functionDeclarations"],y)}const h=g(n,["googleSearchRetrieval"]);if(h!=null&&B(e,["googleSearchRetrieval"],h),g(n,["parallelAiSearch"])!==void 0)throw new Error("parallelAiSearch parameter is not supported in Gemini API.");const f=g(n,["urlContext"]);f!=null&&B(e,["urlContext"],f);const p=g(n,["mcpServers"]);if(p!=null){let y=p;Array.isArray(y)&&(y=y.map(b=>b)),B(e,["mcpServers"],y)}return e}function S9(n){const e={},t=g(n,["retrieval"]);t!=null&&B(e,["retrieval"],t);const r=g(n,["computerUse"]);if(r!=null&&B(e,["computerUse"],r),g(n,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");const s=g(n,["googleSearch"]);s!=null&&B(e,["googleSearch"],s);const a=g(n,["googleMaps"]);a!=null&&B(e,["googleMaps"],a);const c=g(n,["codeExecution"]);c!=null&&B(e,["codeExecution"],c);const u=g(n,["enterpriseWebSearch"]);u!=null&&B(e,["enterpriseWebSearch"],u);const h=g(n,["functionDeclarations"]);if(h!=null){let b=h;Array.isArray(b)&&(b=b.map(w=>f9(w))),B(e,["functionDeclarations"],b)}const f=g(n,["googleSearchRetrieval"]);f!=null&&B(e,["googleSearchRetrieval"],f);const p=g(n,["parallelAiSearch"]);p!=null&&B(e,["parallelAiSearch"],p);const y=g(n,["urlContext"]);if(y!=null&&B(e,["urlContext"],y),g(n,["mcpServers"])!==void 0)throw new Error("mcpServers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return e}function D9(n,e){const t={},r=g(n,["ttl"]);e!==void 0&&r!=null&&B(e,["ttl"],r);const s=g(n,["expireTime"]);return e!==void 0&&s!=null&&B(e,["expireTime"],s),t}function A9(n,e){const t={},r=g(n,["ttl"]);e!==void 0&&r!=null&&B(e,["ttl"],r);const s=g(n,["expireTime"]);return e!==void 0&&s!=null&&B(e,["expireTime"],s),t}function I9(n,e){const t={},r=g(e,["name"]);r!=null&&B(t,["_url","name"],Za(n,r));const s=g(e,["config"]);return s!=null&&D9(s,t),t}function R9(n,e){const t={},r=g(e,["name"]);r!=null&&B(t,["_url","name"],Za(n,r));const s=g(e,["config"]);return s!=null&&A9(s,t),t}/**
4301 * @license
4302 * Copyright 2025 Google LLC
4303 * SPDX-License-Identifier: Apache-2.0
4304 */class P9 extends Xa{constructor(e){super(),this.apiClient=e,this.list=async(t={})=>new kc($a.PAGED_ITEM_CACHED_CONTENTS,r=>this.listInternal(r),await this.listInternal(t),t)}async create(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=i9(this.apiClient,e);return u=Ve("cachedContents",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json()),c.then(p=>p)}else{const f=s9(this.apiClient,e);return u=Ve("cachedContents",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json()),c.then(p=>p)}}async get(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=g9(this.apiClient,e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json()),c.then(p=>p)}else{const f=m9(this.apiClient,e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json()),c.then(p=>p)}}async delete(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=o9(this.apiClient,e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=c9(p),b=new oN;return Object.assign(b,y),b})}else{const f=a9(this.apiClient,e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=l9(p),b=new oN;return Object.assign(b,y),b})}}async update(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=R9(this.apiClient,e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"PATCH",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json()),c.then(p=>p)}else{const f=I9(this.apiClient,e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"PATCH",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json()),c.then(p=>p)}}async listInternal(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=b9(e);return u=Ve("cachedContents",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=w9(p),b=new lN;return Object.assign(b,y),b})}else{const f=C9(e);return u=Ve("cachedContents",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=v9(p),b=new lN;return Object.assign(b,y),b})}}}function zo(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function pN(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function yt(n){return this instanceof yt?(this.v=n,this):new yt(n)}function Ai(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,a=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",c),s[Symbol.asyncIterator]=function(){return this},s;function c(w){return function(E){return Promise.resolve(E).then(w,y)}}function u(w,E){r[w]&&(s[w]=function(N){return new Promise(function(S,I){a.push([w,N,S,I])>1||h(w,N)})},E&&(s[w]=E(s[w])))}function h(w,E){try{f(r[w](E))}catch(N){b(a[0][3],N)}}function f(w){w.value instanceof yt?Promise.resolve(w.value.v).then(p,y):b(a[0][2],w)}function p(w){h("next",w)}function y(w){h("throw",w)}function b(w,E){w(E),a.shift(),a.length&&h(a[0][0],a[0][1])}}function Ii(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof pN=="function"?pN(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(a){t[a]=n[a]&&function(c){return new Promise(function(u,h){c=n[a](c),s(u,h,c.done,c.value)})}}function s(a,c,u,h){Promise.resolve(h).then(function(f){a({value:f,done:u})},c)}}/**
4305 * @license
4306 * Copyright 2025 Google LLC
4307 * SPDX-License-Identifier: Apache-2.0
4308 */function M9(n){var e;if(n.candidates==null||n.candidates.length===0)return!1;const t=(e=n.candidates[0])===null||e===void 0?void 0:e.content;return t===void 0?!1:QA(t)}function QA(n){if(n.parts===void 0||n.parts.length===0)return!1;for(const e of n.parts)if(e===void 0||Object.keys(e).length===0)return!1;return!0}function L9(n){if(n.length!==0){for(const e of n)if(e.role!=="user"&&e.role!=="model")throw new Error(`Role must be user or model, but got ${e.role}.`)}}function BN(n){if(n===void 0||n.length===0)return[];const e=[],t=n.length;let r=0;for(;r<t;)if(n[r].role==="user")e.push(n[r]),r++;else{const s=[];let a=!0;for(;r<t&&n[r].role==="model";)s.push(n[r]),a&&!QA(n[r])&&(a=!1),r++;a?e.push(...s):e.pop()}return e}class j9{constructor(e,t){this.modelsModule=e,this.apiClient=t}create(e){return new O9(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}}class O9{constructor(e,t,r,s={},a=[]){this.apiClient=e,this.modelsModule=t,this.model=r,this.config=s,this.history=a,this.sendPromise=Promise.resolve(),L9(a)}async sendMessage(e){var t;await this.sendPromise;const r=Pr(e.message),s=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(r),config:(t=e.config)!==null&&t!==void 0?t:this.config});return this.sendPromise=(async()=>{var a,c,u;const h=await s,f=(c=(a=h.candidates)===null||a===void 0?void 0:a[0])===null||c===void 0?void 0:c.content,p=h.automaticFunctionCallingHistory,y=this.getHistory(!0).length;let b=[];p!=null&&(b=(u=p.slice(y))!==null&&u!==void 0?u:[]);const w=f?[f]:[];this.recordHistory(r,w,b)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),s}async sendMessageStream(e){var t;await this.sendPromise;const r=Pr(e.message),s=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(r),config:(t=e.config)!==null&&t!==void 0?t:this.config});this.sendPromise=s.then(()=>{}).catch(()=>{});const a=await s;return this.processStreamResponse(a,r)}getHistory(e=!1){const t=e?BN(this.history):this.history;return structuredClone(t)}processStreamResponse(e,t){return Ai(this,arguments,function*(){var s,a,c,u,h,f;const p=[];try{for(var y=!0,b=Ii(e),w;w=yield yt(b.next()),s=w.done,!s;y=!0){u=w.value,y=!1;const E=u;if(M9(E)){const N=(f=(h=E.candidates)===null||h===void 0?void 0:h[0])===null||f===void 0?void 0:f.content;N!==void 0&&p.push(N)}yield yield yt(E)}}catch(E){a={error:E}}finally{try{!y&&!s&&(c=b.return)&&(yield yt(c.call(b)))}finally{if(a)throw a.error}}this.recordHistory(t,p)})}recordHistory(e,t,r){let s=[];t.length>0&&t.every(a=>a.role!==void 0)?s=t:s.push({role:"model",parts:[]}),r&&r.length>0?this.history.push(...BN(r)):this.history.push(e),this.history.push(...s)}}/**
4309 * @license
4310 * Copyright 2025 Google LLC
4311 * SPDX-License-Identifier: Apache-2.0
4312 */class _p extends Error{constructor(e){super(e.message),this.name="ApiError",this.status=e.status,Object.setPrototypeOf(this,_p.prototype)}}/**
4313 * @license
4314 * Copyright 2025 Google LLC
4315 * SPDX-License-Identifier: Apache-2.0
4316 */function F9(n){const e={},t=g(n,["file"]);return t!=null&&B(e,["file"],t),e}function U9(n){const e={},t=g(n,["sdkHttpResponse"]);return t!=null&&B(e,["sdkHttpResponse"],t),e}function V9(n){const e={},t=g(n,["name"]);return t!=null&&B(e,["_url","file"],HA(t)),e}function G9(n){const e={},t=g(n,["sdkHttpResponse"]);return t!=null&&B(e,["sdkHttpResponse"],t),e}function H9(n){const e={},t=g(n,["name"]);return t!=null&&B(e,["_url","file"],HA(t)),e}function q9(n){const e={},t=g(n,["uris"]);return t!=null&&B(e,["uris"],t),e}function z9(n,e){const t={},r=g(n,["pageSize"]);e!==void 0&&r!=null&&B(e,["_query","pageSize"],r);const s=g(n,["pageToken"]);return e!==void 0&&s!=null&&B(e,["_query","pageToken"],s),t}function J9(n){const e={},t=g(n,["config"]);return t!=null&&z9(t,e),e}function $9(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["nextPageToken"]);r!=null&&B(e,["nextPageToken"],r);const s=g(n,["files"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>c)),B(e,["files"],a)}return e}function K9(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["files"]);if(r!=null){let s=r;Array.isArray(s)&&(s=s.map(a=>a)),B(e,["files"],s)}return e}/**
4317 * @license
4318 * Copyright 2025 Google LLC
4319 * SPDX-License-Identifier: Apache-2.0
4320 */class Y9 extends Xa{constructor(e){super(),this.apiClient=e,this.list=async(t={})=>new kc($a.PAGED_ITEM_FILES,r=>this.listInternal(r),await this.listInternal(t),t)}async upload(e){if(this.apiClient.isVertexAI())throw new Error("Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(e.file,e.config).then(t=>t)}async download(e){await this.apiClient.downloadFile(e)}async registerFiles(e){throw new Error("registerFiles is only supported in Node.js environments.")}async _registerFiles(e){return this.registerFilesInternal(e)}async listInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=J9(e);return a=Ve("files",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(f=>{const p=f;return p.sdkHttpResponse={headers:h.headers},p})),s.then(h=>{const f=$9(h),p=new HH;return Object.assign(p,f),p})}}async createInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=F9(e);return a=Ve("upload/v1beta/files",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>{const f=U9(h),p=new qH;return Object.assign(p,f),p})}}async get(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=H9(e);return a=Ve("files/{file}",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>h)}}async delete(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=V9(e);return a=Ve("files/{file}",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(f=>{const p=f;return p.sdkHttpResponse={headers:h.headers},p})),s.then(h=>{const f=G9(h),p=new zH;return Object.assign(p,f),p})}}async registerFilesInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=q9(e);return a=Ve("files:register",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>{const f=K9(h),p=new JH;return Object.assign(p,f),p})}}}/**
4321 * @license
4322 * Copyright 2025 Google LLC
4323 * SPDX-License-Identifier: Apache-2.0
4324 */function yN(n){const e={};
4324if(g(n,["languageCodes"])!==void 0)throw new Error("languageCodes parameter is not supported in Gemini API.");return e}function Q9(n){const e={},t=g(n,["apiKey"]);if(t!=null&&B(e,["apiKey"],t),g(n,["apiKeyConfig"])!==void 0)throw new Error("apiKeyConfig parameter is not supported in Gemini API.");if(g(n,["authType"])!==void 0)throw new Error("authType parameter is not supported in Gemini API.");if(g(n,["googleServiceAccountConfig"])!==void 0)throw new Error("googleServiceAccountConfig parameter is not supported in Gemini API.");if(g(n,["httpBasicAuthConfig"])!==void 0)throw new Error("httpBasicAuthConfig parameter is not supported in Gemini API.");if(g(n,["oauthConfig"])!==void 0)throw new Error("oauthConfig parameter is not supported in Gemini API.");if(g(n,["oidcConfig"])!==void 0)throw new Error("oidcConfig parameter is not supported in Gemini API.");return e}function ng(n){const e={},t=g(n,["data"]);if(t!=null&&B(e,["data"],t),g(n,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=g(n,["mimeType"]);return r!=null&&B(e,["mimeType"],r),e}function W9(n){const e={},t=g(n,["parts"]);if(t!=null){let s=t;Array.isArray(s)&&(s=s.map(a=>m7(a))),B(e,["parts"],s)}const r=g(n,["role"]);return r!=null&&B(e,["role"],r),e}function X9(n){const e={},t=g(n,["parts"]);if(t!=null){let s=t;Array.isArray(s)&&(s=s.map(a=>g7(a))),B(e,["parts"],s)}const r=g(n,["role"]);return r!=null&&B(e,["role"],r),e}function Z9(n){const e={};if(g(n,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const t=g(n,["fileUri"]);t!=null&&B(e,["fileUri"],t);const r=g(n,["mimeType"]);return r!=null&&B(e,["mimeType"],r),e}function e7(n){const e={},t=g(n,["id"]);t!=null&&B(e,["id"],t);const r=g(n,["args"]);r!=null&&B(e,["args"],r);const s=g(n,["name"]);if(s!=null&&B(e,["name"],s),g(n,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(g(n,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function t7(n){const e={},t=g(n,["description"]);t!=null&&B(e,["description"],t);const r=g(n,["name"]);r!=null&&B(e,["name"],r);const s=g(n,["parameters"]);s!=null&&B(e,["parameters"],s);const a=g(n,["parametersJsonSchema"]);a!=null&&B(e,["parametersJsonSchema"],a);const c=g(n,["response"]);c!=null&&B(e,["response"],c);const u=g(n,["responseJsonSchema"]);if(u!=null&&B(e,["responseJsonSchema"],u),g(n,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return e}function n7(n){const e={},t=g(n,["modelSelectionConfig"]);t!=null&&B(e,["modelConfig"],t);const r=g(n,["responseJsonSchema"]);r!=null&&B(e,["responseJsonSchema"],r);const s=g(n,["audioTimestamp"]);s!=null&&B(e,["audioTimestamp"],s);const a=g(n,["candidateCount"]);a!=null&&B(e,["candidateCount"],a);const c=g(n,["enableAffectiveDialog"]);c!=null&&B(e,["enableAffectiveDialog"],c);const u=g(n,["frequencyPenalty"]);u!=null&&B(e,["frequencyPenalty"],u);const h=g(n,["logprobs"]);h!=null&&B(e,["logprobs"],h);const f=g(n,["maxOutputTokens"]);f!=null&&B(e,["maxOutputTokens"],f);const p=g(n,["mediaResolution"]);p!=null&&B(e,["mediaResolution"],p);const y=g(n,["presencePenalty"]);y!=null&&B(e,["presencePenalty"],y);const b=g(n,["responseLogprobs"]);b!=null&&B(e,["responseLogprobs"],b);const w=g(n,["responseMimeType"]);w!=null&&B(e,["responseMimeType"],w);const E=g(n,["responseModalities"]);E!=null&&B(e,["responseModalities"],E);const N=g(n,["responseSchema"]);N!=null&&B(e,["responseSchema"],N);const S=g(n,["routingConfig"]);S!=null&&B(e,["routingConfig"],S);const I=g(n,["seed"]);I!=null&&B(e,["seed"],I);const O=g(n,["speechConfig"]);O!=null&&B(e,["speechConfig"],O);const F=g(n,["stopSequences"]);F!=null&&B(e,["stopSequences"],F);const J=g(n,["temperature"]);J!=null&&B(e,["temperature"],J);const z=g(n,["thinkingConfig"]);z!=null&&B(e,["thinkingConfig"],z);const U=g(n,["topK"]);U!=null&&B(e,["topK"],U);const D=g(n,["topP"]);if(D!=null&&B(e,["topP"],D),g(n,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return e}function r7(n){const e={},t=g(n,["authConfig"]);t!=null&&B(e,["authConfig"],Q9(t));const r=g(n,["enableWidget"]);return r!=null&&B(e,["enableWidget"],r),e}function s7(n){const e={},t=g(n,["searchTypes"]);if(t!=null&&B(e,["searchTypes"],t),g(n,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");if(g(n,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");const r=g(n,["timeRangeFilter"]);return r!=null&&B(e,["timeRangeFilter"],r),e}function i7(n,e){const t={},r=g(n,["generationConfig"]);e!==void 0&&r!=null&&B(e,["setup","generationConfig"],r);const s=g(n,["responseModalities"]);e!==void 0&&s!=null&&B(e,["setup","generationConfig","responseModalities"],s);const a=g(n,["temperature"]);e!==void 0&&a!=null&&B(e,["setup","generationConfig","temperature"],a);const c=g(n,["topP"]);e!==void 0&&c!=null&&B(e,["setup","generationConfig","topP"],c);const u=g(n,["topK"]);e!==void 0&&u!=null&&B(e,["setup","generationConfig","topK"],u);const h=g(n,["maxOutputTokens"]);e!==void 0&&h!=null&&B(e,["setup","generationConfig","maxOutputTokens"],h);const f=g(n,["mediaResolution"]);e!==void 0&&f!=null&&B(e,["setup","generationConfig","mediaResolution"],f);const p=g(n,["seed"]);e!==void 0&&p!=null&&B(e,["setup","generationConfig","seed"],p);const y=g(n,["speechConfig"]);e!==void 0&&y!=null&&B(e,["setup","generationConfig","speechConfig"],LC(y));const b=g(n,["thinkingConfig"]);e!==void 0&&b!=null&&B(e,["setup","generationConfig","thinkingConfig"],b);const w=g(n,["enableAffectiveDialog"]);e!==void 0&&w!=null&&B(e,["setup","generationConfig","enableAffectiveDialog"],w);const E=g(n,["systemInstruction"]);e!==void 0&&E!=null&&B(e,["setup","systemInstruction"],W9(Pr(E)));const N=g(n,["tools"]);if(e!==void 0&&N!=null){let k=Ku(N);Array.isArray(k)&&(k=k.map(_=>
4324y7($u(_)))),B(e,["setup","tools"],k)}const S=g(n,["sessionResumption"]);e!==void 0&&S!=null&&B(e,["setup","sessionResumption"],B7(S));const I=g(n,["inputAudioTranscription"]);e!==void 0&&I!=null&&B(e,["setup","inputAudioTranscription"],yN(I));const O=g(n,["outputAudioTranscription"]);e!==void 0&&O!=null&&B(e,["setup","outputAudioTranscription"],yN(O));const F=g(n,["realtimeInputConfig"]);e!==void 0&&F!=null&&B(e,["setup","realtimeInputConfig"],F);const J=g(n,["contextWindowCompression"]);e!==void 0&&J!=null&&B(e,["setup","contextWindowCompression"],J);const z=g(n,["proactivity"]);if(e!==void 0&&z!=null&&B(e,["setup","proactivity"],z),g(n,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");const U=g(n,["avatarConfig"]);e!==void 0&&U!=null&&B(e,["setup","avatarConfig"],U);const D=g(n,["safetySettings"]);if(e!==void 0&&D!=null){let k=D;Array.isArray(k)&&(k=k.map(_=>p7(_))),B(e,["setup","safetySettings"],k)}return t}function a7(n,e){const t={},r=g(n,["generationConfig"]);e!==void 0&&r!=null&&B(e,["setup","generationConfig"],n7(r));const s=g(n,["responseModalities"]);e!==void 0&&s!=null&&B(e,["setup","generationConfig","responseModalities"],s);const a=g(n,["temperature"]);e!==void 0&&a!=null&&B(e,["setup","generationConfig","temperature"],a);const c=g(n,["topP"]);e!==void 0&&c!=null&&B(e,["setup","generationConfig","topP"],c);const u=g(n,["topK"]);e!==void 0&&u!=null&&B(e,["setup","generationConfig","topK"],u);const h=g(n,["maxOutputTokens"]);e!==void 0&&h!=null&&B(e,["setup","generationConfig","maxOutputTokens"],h);const f=g(n,["mediaResolution"]);e!==void 0&&f!=null&&B(e,["setup","generationConfig","mediaResolution"],f);const p=g(n,["seed"]);e!==void 0&&p!=null&&B(e,["setup","generationConfig","seed"],p);const y=g(n,["speechConfig"]);e!==void 0&&y!=null&&B(e,["setup","generationConfig","speechConfig"],LC(y));const b=g(n,["thinkingConfig"]);e!==void 0&&b!=null&&B(e,["setup","generationConfig","thinkingConfig"],b);const w=g(n,["enableAffectiveDialog"]);e!==void 0&&w!=null&&B(e,["setup","generationConfig","enableAffectiveDialog"],w);const E=g(n,["systemInstruction"]);e!==void 0&&E!=null&&B(e,["setup","systemInstruction"],X9(Pr(E)));const N=g(n,["tools"]);if(e!==void 0&&N!=null){let _=Ku(N);Array.isArray(_)&&(_=_.map(M=>x7($u(M)))),B(e,["setup","tools"],_)}const S=g(n,["sessionResumption"]);e!==void 0&&S!=null&&B(e,["setup","sessionResumption"],S);const I=g(n,["inputAudioTranscription"]);e!==void 0&&I!=null&&B(e,["setup","inputAudioTranscription"],I);const O=g(n,["outputAudioTranscription"]);e!==void 0&&O!=null&&B(e,["setup","outputAudioTranscription"],O);const F=g(n,["realtimeInputConfig"]);e!==void 0&&F!=null&&B(e,["setup","realtimeInputConfig"],F);const J=g(n,["contextWindowCompression"]);e!==void 0&&J!=null&&B(e,["setup","contextWindowCompression"],J);const z=g(n,["proactivity"]);e!==void 0&&z!=null&&B(e,["setup","proactivity"],z);const U=g(n,["explicitVadSignal"]);e!==void 0&&U!=null&&B(e,["setup","explicitVadSignal"],U);const D=g(n,["avatarConfig"]);e!==void 0&&D!=null&&B(e,["setup","avatarConfig"],D);const k=g(n,["safetySettings"]);if(e!==void 0&&k!=null){let _=k;Array.isArray(_)&&(_=_.map(M=>M)),B(e,["setup","safetySettings"],_)}return t}function o7(n,e){const t={},r=g(e,["model"]);r!=null&&B(t,["setup","model"],$t(n,r));const s=g(e,["config"]);return s!=null&&B(t,["config"],i7(s,t)),t}function l7(n,e){const t={},r=g(e,["model"]);r!=null&&B(t,["setup","model"],$t(n,r));const s=g(e,["config"]);return s!=null&&B(t,["config"],a7(s,t)),t}function c7(n){const e={},t=g(n,["musicGenerationConfig"]);return t!=null&&B(e,["musicGenerationConfig"],t),e}function u7(n){const e={},t=g(n,["weightedPrompts"]);if(t!=null){let r=t;Array.isArray(r)&&(r=r.map(s=>s)),B(e,["weightedPrompts"],r)}return e}function d7(n){const e={},t=g(n,["media"]);if(t!=null){let f=OA(t);Array.isArray(f)&&(f=f.map(p=>ng(p))),B(e,["mediaChunks"],f)}const r=g(n,["audio"]);r!=null&&B(e,["audio"],ng(UA(r)));const s=g(n,["audioStreamEnd"]);s!=null&&B(e,["audioStreamEnd"],s);const a=g(n,["video"]);a!=null&&B(e,["video"],ng(FA(a)));const c=g(n,["text"]);c!=null&&B(e,["text"],c);const u=g(n,["activityStart"]);u!=null&&B(e,["activityStart"],u);const h=g(n,["activityEnd"]);return h!=null&&B(e,["activityEnd"],h),e}function h7(n){const e={},t=g(n,["media"]);if(t!=null){let f=OA(t);Array.isArray(f)&&(f=f.map(p=>p)),B(e,["mediaChunks"],f)}const r=g(n,["audio"]);r!=null&&B(e,["audio"],UA(r));const s=g(n,["audioStreamEnd"]);s!=null&&B(e,["audioStreamEnd"],s);const a=g(n,["video"]);a!=null&&B(e,["video"],FA(a));const c=g(n,["text"]);c!=null&&B(e,["text"],c);const u=g(n,["activityStart"]);u!=null&&B(e,["activityStart"],u);const h=g(n,["activityEnd"]);return h!=null&&B(e,["activityEnd"],h),e}function f7(n){const e={},t=g(n,["setupComplete"]);t!=null&&B(e,["setupComplete"],t);const r=g(n,["serverContent"]);r!=null&&B(e,["serverContent"],r);const s=g(n,["toolCall"]);s!=null&&B(e,["toolCall"],s);const a=g(n,["toolCallCancellation"]);a!=null&&B(e,["toolCallCancellation"],a);const c=g(n,["usageMetadata"]);c!=null&&B(e,["usageMetadata"],C7(c));const u=g(n,["goAway"]);u!=null&&B(e,["goAway"],u);const h=g(n,["sessionResumptionUpdate"]);h!=null&&B(e,["sessionResumptionUpdate"],h);const f=g(n,["voiceActivityDetectionSignal"]);f!=null&&B(e,["voiceActivityDetectionSignal"],f);const p=g(n,["voiceActivity"]);return p!=null&&B(e,["voiceActivity"],b7(p)),e}function m7(n){const e={},t=g(n,["mediaResolution"]);t!=null&&B(e,["mediaResolution"],t);const r=g(n,["codeExecutionResult"]);r!=null&&B(e,["codeExecutionResult"],r);const s=g(n,["executableCode"]);s!=null&&B(e,["executableCode"],s);const a=g(n,["fileData"]);a!=null&&B(e,["fileData"],Z9(a));const c=g(n,["functionCall"]);c!=null&&B(e,["functionCall"],e7(c));const u=g(n,["functionResponse"]);u!=null&&B(e,["functionResponse"],u);const h=g(n,["inlineData"]);h!=null&&B(e,["inlineData"],ng(h));const f=g(n,["text"]);f!=null&&B(e,["text"],f);const p=g(n,["thought"]);p!=null&&B(e,["thought"],p);const y=g(n,["thoughtSignature"]);y!=null&&B(e,["thoughtSignature"],y);const b=g(n,["videoMetadata"]);b!=null&&B(e,["videoMetadata"],b);const w=g(n,["toolCall"]);w!=null&&B(e,["toolCall"],w);const E=g(n,["toolResponse"]);E!=null&&B(e,["toolResponse"],E);const N=g(n,["partMetadata"]);return N!=null&&B(e,["partMetadata"],N),e}function g7(n){const e={},t=g(n,["mediaResolution"]);t!=null&&B(e,["mediaResolution"],t);const r=g(n,["codeExecutionResult"]);r!=null&&B(e,["codeExecutionResult"],r);const s=g(n,["executableCode"]);s!=null&&B(e,["executableCode"],s);const a=g(n,["fileData"]);a!=null&&B(e,["fileData"],a);const c=g(n,["functionCall"]);c!=null&&B(e,["functionCall"],c);const u=g(n,["functionResponse"]);u!=null&&B(e,["functionResponse"],u);const h=g(n,["inlineData"]);h!=null&&B(e,["inlineData"],h);const f=g(n,["text"]);f!=null&&B(e,["text"],f);const p=g(n,["thought"]);p!=null&&B(e,["thought"],p);const y=g(n,["thoughtSignature"]);y!=null&&B(e,["thoughtSignature"],y);const b=g(n,["videoMetadata"]);if(b!=null&&B(e,["videoMetadata"],b),g(n,["toolCall"])!==void 0)throw new Error("toolCall parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(g(n,["toolResponse"])!==void 0)throw new Error("toolResponse parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(g(n,["partMetadata"])!==void 0)throw new Error("partMetadata parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return e}function p7(n){const e={},t=g(n,["category"]);if(t!=null&&B(e,["category"],t),g(n,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const r=g(n,["threshold"]);return r!=null&&B(e,["threshold"],r),e}function B7(n){const e={},t=g(n,["handle"]);if(t!=null&&B(e,["handle"],t),g(n,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return e}function y7(n){const e={};
4324if(g(n,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const t=g(n,["computerUse"]);t!=null&&B(e,["computerUse"],t);const r=g(n,["fileSearch"]);r!=null&&B(e,["fileSearch"],r);const s=g(n,["googleSearch"]);s!=null&&B(e,["googleSearch"],s7(s));const a=g(n,["googleMaps"]);a!=null&&B(e,["googleMaps"],r7(a));const c=g(n,["codeExecution"]);if(c!=null&&B(e,["codeExecution"],c),g(n,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=g(n,["functionDeclarations"]);if(u!=null){let y=u;Array.isArray(y)&&(y=y.map(b=>b)),B(e,["functionDeclarations"],y)}const h=g(n,["googleSearchRetrieval"]);if(h!=null&&B(e,["googleSearchRetrieval"],h),g(n,["parallelAiSearch"])!==void 0)throw new Error("parallelAiSearch parameter is not supported in Gemini API.");const f=g(n,["urlContext"]);f!=null&&B(e,["urlContext"],f);const p=g(n,["mcpServers"]);if(p!=null){let y=p;Array.isArray(y)&&(y=y.map(b=>b)),B(e,["mcpServers"],y)}return e}function x7(n){const e={},t=g(n,["retrieval"]);t!=null&&B(e,["retrieval"],t);const r=g(n,["computerUse"]);if(r!=null&&B(e,["computerUse"],r),g(n,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");const s=g(n,["googleSearch"]);s!=null&&B(e,["googleSearch"],s);const a=g(n,["googleMaps"]);a!=null&&B(e,["googleMaps"],a);const c=g(n,["codeExecution"]);c!=null&&B(e,["codeExecution"],c);const u=g(n,["enterpriseWebSearch"]);u!=null&&B(e,["enterpriseWebSearch"],u);const h=g(n,["functionDeclarations"]);if(h!=null){let b=h;Array.isArray(b)&&(b=b.map(w=>t7(w))),B(e,["functionDeclarations"],b)}const f=g(n,["googleSearchRetrieval"]);f!=null&&B(e,["googleSearchRetrieval"],f);const p=g(n,["parallelAiSearch"]);p!=null&&B(e,["parallelAiSearch"],p);const y=g(n,["urlContext"]);if(y!=null&&B(e,["urlContext"],y),g(n,["mcpServers"])!==void 0)throw new Error("mcpServers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return e}function C7(n){const e={},t=g(n,["promptTokenCount"]);t!=null&&B(e,["promptTokenCount"],t);const r=g(n,["cachedContentTokenCount"]);r!=null&&B(e,["cachedContentTokenCount"],r);const s=g(n,["candidatesTokenCount"]);s!=null&&B(e,["responseTokenCount"],s);const a=g(n,["toolUsePromptTokenCount"]);a!=null&&B(e,["toolUsePromptTokenCount"],a);const c=g(n,["thoughtsTokenCount"]);c!=null&&B(e,["thoughtsTokenCount"],c);const u=g(n,["totalTokenCount"]);u!=null&&B(e,["totalTokenCount"],u);const h=g(n,["promptTokensDetails"]);if(h!=null){let w=h;Array.isArray(w)&&(w=w.map(E=>E)),B(e,["promptTokensDetails"],w)}const f=g(n,["cacheTokensDetails"]);if(f!=null){let w=f;Array.isArray(w)&&(w=w.map(E=>E)),B(e,["cacheTokensDetails"],w)}
4324const p=g(n,["candidatesTokensDetails"]);if(p!=null){let w=p;Array.isArray(w)&&(w=w.map(E=>E)),B(e,["responseTokensDetails"],w)}const y=g(n,["toolUsePromptTokensDetails"]);if(y!=null){let w=y;Array.isArray(w)&&(w=w.map(E=>E)),B(e,["toolUsePromptTokensDetails"],w)}const b=g(n,["trafficType"]);return b!=null&&B(e,["trafficType"],b),e}function b7(n){const e={},t=g(n,["type"]);return t!=null&&B(e,["voiceActivityType"],t),e}/**
4325 * @license
4326 * Copyright 2025 Google LLC
4327 * SPDX-License-Identifier: Apache-2.0
4328 */function v7(n,e){const t={},r=g(n,["apiKey"]);if(r!=null&&B(t,["apiKey"],r),g(n,["apiKeyConfig"])!==void 0)throw new Error("apiKeyConfig parameter is not supported in Gemini API.");if(g(n,["authType"])!==void 0)throw new Error("authType parameter is not supported in Gemini API.");if(g(n,["googleServiceAccountConfig"])!==void 0)throw new Error("googleServiceAccountConfig parameter is not supported in Gemini API.");if(g(n,["httpBasicAuthConfig"])!==void 0)throw new Error("httpBasicAuthConfig parameter is not supported in Gemini API.");if(g(n,["oauthConfig"])!==void 0)throw new Error("oauthConfig parameter is not supported in Gemini API.");if(g(n,["oidcConfig"])!==void 0)throw new Error("oidcConfig parameter is not supported in Gemini API.");return t}function w7(n,e){const t={},r=g(n,["data"]);if(r!=null&&B(t,["data"],r),g(n,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=g(n,["mimeType"]);return s!=null&&B(t,["mimeType"],s),t}function E7(n,e){const t={},r=g(n,["content"]);r!=null&&B(t,["content"],r);const s=g(n,["citationMetadata"]);s!=null&&B(t,["citationMetadata"],_7(s));const a=g(n,["tokenCount"]);a!=null&&B(t,["tokenCount"],a);const c=g(n,["finishReason"]);c!=null&&B(t,["finishReason"],c);const u=g(n,["groundingMetadata"]);u!=null&&B(t,["groundingMetadata"],u);const h=g(n,["avgLogprobs"]);h!=null&&B(t,["avgLogprobs"],h);const f=g(n,["index"]);f!=null&&B(t,["index"],f);const p=g(n,["logprobsResult"]);p!=null&&B(t,["logprobsResult"],p);const y=g(n,["safetyRatings"]);if(y!=null){let w=y;Array.isArray(w)&&(w=w.map(E=>E)),B(t,["safetyRatings"],w)}const b=g(n,["urlContextMetadata"]);return b!=null&&B(t,["urlContextMetadata"],b),t}function _7(n,e){const t={},r=g(n,["citationSources"]);if(r!=null){let s=r;Array.isArray(s)&&(s=s.map(a=>a)),B(t,["citations"],s)}return t}function T7(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["contents"]);if(a!=null){let c=ks(a);Array.isArray(c)&&(c=c.map(u=>Qu(u))),B(r,["contents"],c)}return r}function k7(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["tokensInfo"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>c)),B(t,["tokensInfo"],a)}return t}function N7(n,e){const t={},r=g(n,["values"]);r!=null&&B(t,["values"],r);const s=g(n,["statistics"]);return s!=null&&B(t,["statistics"],S7(s)),t}function S7(n,e){const t={},r=g(n,["truncated"]);r!=null&&B(t,["truncated"],r);const s=g(n,["token_count"]);return s!=null&&B(t,["tokenCount"],s),t}function nf(n,e){const t={},r=g(n,["parts"]);if(r!=null){let a=r;Array.isArray(a)&&(a=a.map(c=>Oq(c))),B(t,["parts"],a)}const s=g(n,["role"]);return s!=null&&B(t,["role"],s),t}function Qu(n,e){const t={},r=g(n,["parts"]);if(r!=null){let a=r;Array.isArray(a)&&(a=a.map(c=>Fq(c))),B(t,["parts"],a)}const s=g(n,["role"]);return s!=null&&B(t,["role"],s),t}function D7(n,e){const t={},r=g(n,["controlType"]);r!=null&&B(t,["controlType"],r);const s=g(n,["enableControlImageComputation"]);return s!=null&&B(t,["computeControl"],s),t}function A7(n,e){const t={};if(g(n,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(g(n,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(g(n,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return t}function I7(n,e,t){const r={},s=g(n,["systemInstruction"]);e!==void 0&&s!=null&&B(e,["systemInstruction"],Qu(Pr(s)));const a=g(n,["tools"]);if(e!==void 0&&a!=null){let u=a;Array.isArray(u)&&(u=u.map(h=>eI(h))),B(e,["tools"],u)}const c=g(n,["generationConfig"]);return e!==void 0&&c!=null&&B(e,["generationConfig"],wq(c)),r}function R7(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["contents"]);if(a!=null){let u=ks(a);Array.isArray(u)&&(u=u.map(h=>nf(h))),B(r,["contents"],u)}const c=g(e,["config"]);return c!=null&&A7(c),r}function P7(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["contents"]);if(a!=null){let u=ks(a);Array.isArray(u)&&(u=u.map(h=>Qu(h))),B(r,["contents"],u)}const c=g(e,["config"]);return c!=null&&I7(c,r),r}function M7(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["totalTokens"]);s!=null&&B(t,["totalTokens"],s);const a=g(n,["cachedContentTokenCount"]);return a!=null&&B(t,["cachedContentTokenCount"],a),t}function L7(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["totalTokens"]);return s!=null&&B(t,["totalTokens"],s),t}function j7(n,e,t){const r={},s=g(e,["model"]);return s!=null&&B(r,["_url","name"],$t(n,s)),r}function O7(n,e,t){const r={},s=g(e,["model"]);return s!=null&&B(r,["_url","name"],$t(n,s)),r}function F7(n,e){const t={},r=g(n,["sdkHttpResponse"]);return r!=null&&B(t,["sdkHttpResponse"],r),t}function U7(n,e){const t={},r=g(n,["sdkHttpResponse"]);return r!=null&&B(t,["sdkHttpResponse"],r),t}function V7(n,e,t){const r={},s=g(n,["outputGcsUri"]);e!==void 0&&s!=null&&B(e,["parameters","storageUri"],s);const a=g(n,["negativePrompt"]);e!==void 0&&a!=null&&B(e,["parameters","negativePrompt"],a);const c=g(n,["numberOfImages"]);
4328e!==void 0&&c!=null&&B(e,["parameters","sampleCount"],c);const u=g(n,["aspectRatio"]);e!==void 0&&u!=null&&B(e,["parameters","aspectRatio"],u);const h=g(n,["guidanceScale"]);e!==void 0&&h!=null&&B(e,["parameters","guidanceScale"],h);const f=g(n,["seed"]);e!==void 0&&f!=null&&B(e,["parameters","seed"],f);const p=g(n,["safetyFilterLevel"]);e!==void 0&&p!=null&&B(e,["parameters","safetySetting"],p);const y=g(n,["personGeneration"]);e!==void 0&&y!=null&&B(e,["parameters","personGeneration"],y);const b=g(n,["includeSafetyAttributes"]);e!==void 0&&b!=null&&B(e,["parameters","includeSafetyAttributes"],b);const w=g(n,["includeRaiReason"]);e!==void 0&&w!=null&&B(e,["parameters","includeRaiReason"],w);const E=g(n,["language"]);e!==void 0&&E!=null&&B(e,["parameters","language"],E);const N=g(n,["outputMimeType"]);e!==void 0&&N!=null&&B(e,["parameters","outputOptions","mimeType"],N);const S=g(n,["outputCompressionQuality"]);e!==void 0&&S!=null&&B(e,["parameters","outputOptions","compressionQuality"],S);const I=g(n,["addWatermark"]);e!==void 0&&I!=null&&B(e,["parameters","addWatermark"],I);const O=g(n,["labels"]);e!==void 0&&O!=null&&B(e,["labels"],O);const F=g(n,["editMode"]);e!==void 0&&F!=null&&B(e,["parameters","editMode"],F);const J=g(n,["baseSteps"]);return e!==void 0&&J!=null&&B(e,["parameters","editConfig","baseSteps"],J),r}function G7(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["prompt"]);a!=null&&B(r,["instances[0]","prompt"],a);const c=g(e,["referenceImages"]);if(c!=null){let h=c;Array.isArray(h)&&(h=h.map(f=>zq(f))),B(r,["instances[0]","referenceImages"],h)}const u=g(e,["config"]);return u!=null&&V7(u,r),r}function H7(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["predictions"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>Tp(c))),B(t,["generatedImages"],a)}return t}function q7(n,e,t){const r={},s=g(n,["taskType"]);e!==void 0&&s!=null&&B(e,["requests[]","taskType"],s);const a=g(n,["title"]);e!==void 0&&a!=null&&B(e,["requests[]","title"],a);const c=g(n,["outputDimensionality"]);if(e!==void 0&&c!=null&&B(e,["requests[]","outputDimensionality"],c),g(n,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(g(n,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");if(g(n,["documentOcr"])!==void 0)throw new Error("documentOcr parameter is not supported in Gemini API.");if(g(n,["audioTrackExtraction"])!==void 0)throw new Error("audioTrackExtraction parameter is not supported in Gemini API.");return r}function z7(n,e,t){const r={};let s=g(t,["embeddingApiType"]);if(s===void 0&&(s="PREDICT"),s==="PREDICT"){const y=g(n,["taskType"]);e!==void 0&&y!=null&&B(e,["instances[]","task_type"],y)}else if(s==="EMBED_CONTENT"){const y=g(n,["taskType"]);e!==void 0&&y!=null&&B(e,["embedContentConfig","taskType"],y)}let a=g(t,["embeddingApiType"]);if(a===void 0&&(a="PREDICT"),a==="PREDICT"){const y=g(n,["title"]);e!==void 0&&y!=null&&B(e,["instances[]","title"],y)}else if(a==="EMBED_CONTENT"){const y=g(n,["title"]);e!==void 0&&y!=null&&B(e,["embedContentConfig","title"],y)}let c=g(t,["embeddingApiType"]);if(c===void 0&&(c="PREDICT"),c==="PREDICT"){const y=g(n,["outputDimensionality"]);e!==void 0&&y!=null&&B(e,["parameters","outputDimensionality"],y)}else if(c==="EMBED_CONTENT"){const y=g(n,["outputDimensionality"]);e!==void 0&&y!=null&&B(e,["embedContentConfig","outputDimensionality"],y)}let u=g(t,["embeddingApiType"]);if(u===void 0&&(u="PREDICT"),u==="PREDICT"){const y=g(n,["mimeType"]);e!==void 0&&y!=null&&B(e,["instances[]","mimeType"],y)}let h=g(t,["embeddingApiType"]);if(h===void 0&&(h="PREDICT"),h==="PREDICT"){const y=g(n,["autoTruncate"]);e!==void 0&&y!=null&&B(e,["parameters","autoTruncate"],y)}else if(h==="EMBED_CONTENT"){const y=g(n,["autoTruncate"]);e!==void 0&&y!=null&&B(e,["embedContentConfig","autoTruncate"],y)}let f=g(t,["embeddingApiType"]);if(f===void 0&&(f="PREDICT"),f==="EMBED_CONTENT"){const y=g(n,["documentOcr"]);e!==void 0&&y!=null&&B(e,["embedContentConfig","documentOcr"],y)}let p=g(t,["embeddingApiType"]);if(p===void 0&&(p="PREDICT"),p==="EMBED_CONTENT"){const y=g(n,["audioTrackExtraction"]);e!==void 0&&y!=null&&B(e,["embedContentConfig","audioTrackExtraction"],y)}return r}function J7(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["contents"]);if(a!=null){let f=RC(n,a);Array.isArray(f)&&(f=f.map(p=>p)),B(r,["requests[]","content"],f)}const c=g(e,["content"]);c!=null&&nf(Pr(c));const u=g(e,["config"]);u!=null&&q7(u,r);const h=g(e,["model"]);return h!==void 0&&B(r,["requests[]","model"],$t(n,h)),r}function $7(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));let a=g(t,["embeddingApiType"]);if(a===void 0&&(a="PREDICT"),a==="PREDICT"){const h=g(e,["contents"]);if(h!=null){let f=RC(n,h);Array.isArray(f)&&(f=f.map(p=>p)),B(r,["instances[]","content"],f)}}let c=g(t,["embeddingApiType"]);if(c===void 0&&(c="PREDICT"),c==="EMBED_CONTENT"){const h=g(e,["content"]);h!=null&&B(r,["content"],Qu(Pr(h)))}const u=g(e,["config"]);return u!=null&&z7(u,r,t),r}function K7(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["embeddings"]);if(s!=null){let c=s;Array.isArray(c)&&(c=c.map(u=>u)),B(t,["embeddings"],c)}const a=g(n,["metadata"]);return a!=null&&B(t,["metadata"],a),t}function Y7(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["predictions[]","embeddings"]);if(s!=null){let c=s;Array.isArray(c)&&(c=c.map(u=>N7(u))),B(t,["embeddings"],c)}const a=g(n,["metadata"]);if(a!=null&&B(t,["metadata"],a),e&&g(e,["embeddingApiType"])==="EMBED_CONTENT"){const c=g(n,["embedding"]),u=g(n,["usageMetadata"]),h=g(n,["truncated"]);if(c){const f={};u&&u.promptTokenCount&&(f.tokenCount=u.promptTokenCount),h&&(f.truncated=h),c.statistics=f,B(t,["embeddings"],[c])}}return t}function Q7(n,e){const t={},r=g(n,["endpoint"]);r!=null&&B(t,["name"],r);const s=g(n,["deployedModelId"]);return s!=null&&B(t,["deployedModelId"],s),t}function W7(n,e){const t={};
4328if(g(n,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=g(n,["fileUri"]);r!=null&&B(t,["fileUri"],r);const s=g(n,["mimeType"]);return s!=null&&B(t,["mimeType"],s),t}function X7(n,e){const t={},r=g(n,["id"]);r!=null&&B(t,["id"],r);const s=g(n,["args"]);s!=null&&B(t,["args"],s);const a=g(n,["name"]);if(a!=null&&B(t,["name"],a),g(n,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(g(n,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function Z7(n,e){const t={},r=g(n,["allowedFunctionNames"]);r!=null&&B(t,["allowedFunctionNames"],r);const s=g(n,["mode"]);if(s!=null&&B(t,["mode"],s),g(n,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function eq(n,e){const t={},r=g(n,["description"]);r!=null&&B(t,["description"],r);const s=g(n,["name"]);s!=null&&B(t,["name"],s);const a=g(n,["parameters"]);a!=null&&B(t,["parameters"],a);const c=g(n,["parametersJsonSchema"]);c!=null&&B(t,["parametersJsonSchema"],c);const u=g(n,["response"]);u!=null&&B(t,["response"],u);const h=g(n,["responseJsonSchema"]);if(h!=null&&B(t,["responseJsonSchema"],h),g(n,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return t}function tq(n,e,t,r){const s={},a=g(e,["systemInstruction"]);t!==void 0&&a!=null&&B(t,["systemInstruction"],nf(Pr(a)));const c=g(e,["temperature"]);c!=null&&B(s,["temperature"],c);const u=g(e,["topP"]);u!=null&&B(s,["topP"],u);const h=g(e,["topK"]);h!=null&&B(s,["topK"],h);const f=g(e,["candidateCount"]);f!=null&&B(s,["candidateCount"],f);const p=g(e,["maxOutputTokens"]);p!=null&&B(s,["maxOutputTokens"],p);const y=g(e,["stopSequences"]);y!=null&&B(s,["stopSequences"],y);const b=g(e,["responseLogprobs"]);b!=null&&B(s,["responseLogprobs"],b);const w=g(e,["logprobs"]);w!=null&&B(s,["logprobs"],w);const E=g(e,["presencePenalty"]);E!=null&&B(s,["presencePenalty"],E);const N=g(e,["frequencyPenalty"]);N!=null&&B(s,["frequencyPenalty"],N);const S=g(e,["seed"]);S!=null&&B(s,["seed"],S);const I=g(e,["responseMimeType"]);I!=null&&B(s,["responseMimeType"],I);const O=g(e,["responseSchema"]);O!=null&&B(s,["responseSchema"],PC(O));const F=g(e,["responseJsonSchema"]);if(F!=null&&B(s,["responseJsonSchema"],F),g(e,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(g(e,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const J=g(e,["safetySettings"]);if(t!==void 0&&J!=null){let ne=J;Array.isArray(ne)&&(ne=ne.map(G=>Jq(G))),B(t,["safetySettings"],ne)}const z=g(e,["tools"]);if(t!==void 0&&z!=null){let ne=Ku(z);Array.isArray(ne)&&(ne=ne.map(G=>ez($u(G)))),B(t,["tools"],ne)}const U=g(e,["toolConfig"]);if(t!==void 0&&U!=null&&B(t,["toolConfig"],Xq(U)),g(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const D=g(e,["cachedContent"]);t!==void 0&&D!=null&&B(t,["cachedContent"],Za(n,D));const k=g(e,["responseModalities"]);k!=null&&B(s,["responseModalities"],k);const _=g(e,["mediaResolution"]);_!=null&&B(s,["mediaResolution"],_);const M=g(e,["speechConfig"]);if(M!=null&&B(s,["speechConfig"],MC(M)),g(e,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const j=g(e,["thinkingConfig"]);j!=null&&B(s,["thinkingConfig"],j);const H=g(e,["imageConfig"]);H!=null&&B(s,["imageConfig"],Nq(H));const L=g(e,["enableEnhancedCivicAnswers"]);if(L!=null&&B(s,["enableEnhancedCivicAnswers"],L),g(e,["modelArmorConfig"])!==void 0)throw new Error("modelArmorConfig parameter is not supported in Gemini API.");const ee=g(e,["serviceTier"]);return t!==void 0&&ee!=null&&B(t,["serviceTier"],ee),s}function nq(n,e,t,r){const s={},a=g(e,["systemInstruction"]);t!==void 0&&a!=null&&B(t,["systemInstruction"],Qu(Pr(a)));const c=g(e,["temperature"]);
4328c!=null&&B(s,["temperature"],c);const u=g(e,["topP"]);u!=null&&B(s,["topP"],u);const h=g(e,["topK"]);h!=null&&B(s,["topK"],h);const f=g(e,["candidateCount"]);f!=null&&B(s,["candidateCount"],f);const p=g(e,["maxOutputTokens"]);p!=null&&B(s,["maxOutputTokens"],p);const y=g(e,["stopSequences"]);y!=null&&B(s,["stopSequences"],y);const b=g(e,["responseLogprobs"]);b!=null&&B(s,["responseLogprobs"],b);const w=g(e,["logprobs"]);w!=null&&B(s,["logprobs"],w);const E=g(e,["presencePenalty"]);E!=null&&B(s,["presencePenalty"],E);const N=g(e,["frequencyPenalty"]);N!=null&&B(s,["frequencyPenalty"],N);const S=g(e,["seed"]);S!=null&&B(s,["seed"],S);const I=g(e,["responseMimeType"]);I!=null&&B(s,["responseMimeType"],I);const O=g(e,["responseSchema"]);O!=null&&B(s,["responseSchema"],PC(O));const F=g(e,["responseJsonSchema"]);F!=null&&B(s,["responseJsonSchema"],F);const J=g(e,["routingConfig"]);J!=null&&B(s,["routingConfig"],J);const z=g(e,["modelSelectionConfig"]);z!=null&&B(s,["modelConfig"],z);const U=g(e,["safetySettings"]);if(t!==void 0&&U!=null){let ae=U;Array.isArray(ae)&&(ae=ae.map(Te=>Te)),B(t,["safetySettings"],ae)}const D=g(e,["tools"]);if(t!==void 0&&D!=null){let ae=Ku(D);Array.isArray(ae)&&(ae=ae.map(Te=>eI($u(Te)))),B(t,["tools"],ae)}const k=g(e,["toolConfig"]);t!==void 0&&k!=null&&B(t,["toolConfig"],Zq(k));const _=g(e,["labels"]);t!==void 0&&_!=null&&B(t,["labels"],_);const M=g(e,["cachedContent"]);t!==void 0&&M!=null&&B(t,["cachedContent"],Za(n,M));const j=g(e,["responseModalities"]);j!=null&&B(s,["responseModalities"],j);const H=g(e,["mediaResolution"]);H!=null&&B(s,["mediaResolution"],H);const L=g(e,["speechConfig"]);L!=null&&B(s,["speechConfig"],MC(L));const ee=g(e,["audioTimestamp"]);ee!=null&&B(s,["audioTimestamp"],ee);const ne=g(e,["thinkingConfig"]);ne!=null&&B(s,["thinkingConfig"],ne);const G=g(e,["imageConfig"]);if(G!=null&&B(s,["imageConfig"],Sq(G)),g(e,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");const W=g(e,["modelArmorConfig"]);t!==void 0&&W!=null&&B(t,["modelArmorConfig"],W);const X=g(e,["serviceTier"]);return t!==void 0&&X!=null&&B(t,["serviceTier"],X),s}function xN(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["contents"]);if(a!=null){let u=ks(a);Array.isArray(u)&&(u=u.map(h=>nf(h))),B(r,["contents"],u)}const c=g(e,["config"]);return c!=null&&B(r,["generationConfig"],tq(n,c,r)),r}function CN(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["contents"]);if(a!=null){let u=ks(a);Array.isArray(u)&&(u=u.map(h=>Qu(h))),B(r,["contents"],u)}const c=g(e,["config"]);return c!=null&&B(r,["generationConfig"],nq(n,c,r)),r}function bN(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["candidates"]);if(s!=null){let p=s;Array.isArray(p)&&(p=p.map(y=>E7(y))),B(t,["candidates"],p)}const a=g(n,["modelVersion"]);a!=null&&B(t,["modelVersion"],a);const c=g(n,["promptFeedback"]);c!=null&&B(t,["promptFeedback"],c);const u=g(n,["responseId"]);u!=null&&B(t,["responseId"],u);const h=g(n,["usageMetadata"]);h!=null&&B(t,["usageMetadata"],h);const f=g(n,["modelStatus"]);return f!=null&&B(t,["modelStatus"],f),t}function vN(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["candidates"]);if(s!=null){let p=s;Array.isArray(p)&&(p=p.map(y=>y)),B(t,["candidates"],p)}const a=g(n,["createTime"]);a!=null&&B(t,["createTime"],a);const c=g(n,["modelVersion"]);c!=null&&B(t,["modelVersion"],c);const u=g(n,["promptFeedback"]);u!=null&&B(t,["promptFeedback"],u);const h=g(n,["responseId"]);h!=null&&B(t,["responseId"],h);const f=g(n,["usageMetadata"]);return f!=null&&B(t,["usageMetadata"],f),t}function rq(n,e,t){const r={};if(g(n,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(g(n,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const s=g(n,["numberOfImages"]);
4328e!==void 0&&s!=null&&B(e,["parameters","sampleCount"],s);const a=g(n,["aspectRatio"]);e!==void 0&&a!=null&&B(e,["parameters","aspectRatio"],a);const c=g(n,["guidanceScale"]);if(e!==void 0&&c!=null&&B(e,["parameters","guidanceScale"],c),g(n,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const u=g(n,["safetyFilterLevel"]);e!==void 0&&u!=null&&B(e,["parameters","safetySetting"],u);const h=g(n,["personGeneration"]);e!==void 0&&h!=null&&B(e,["parameters","personGeneration"],h);const f=g(n,["includeSafetyAttributes"]);e!==void 0&&f!=null&&B(e,["parameters","includeSafetyAttributes"],f);const p=g(n,["includeRaiReason"]);e!==void 0&&p!=null&&B(e,["parameters","includeRaiReason"],p);const y=g(n,["language"]);e!==void 0&&y!=null&&B(e,["parameters","language"],y);const b=g(n,["outputMimeType"]);e!==void 0&&b!=null&&B(e,["parameters","outputOptions","mimeType"],b);const w=g(n,["outputCompressionQuality"]);if(e!==void 0&&w!=null&&B(e,["parameters","outputOptions","compressionQuality"],w),g(n,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(g(n,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const E=g(n,["imageSize"]);if(e!==void 0&&E!=null&&B(e,["parameters","sampleImageSize"],E),g(n,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return r}function sq(n,e,t){const r={},s=g(n,["outputGcsUri"]);e!==void 0&&s!=null&&B(e,["parameters","storageUri"],s);const a=g(n,["negativePrompt"]);e!==void 0&&a!=null&&B(e,["parameters","negativePrompt"],a);const c=g(n,["numberOfImages"]);e!==void 0&&c!=null&&B(e,["parameters","sampleCount"],c);const u=g(n,["aspectRatio"]);e!==void 0&&u!=null&&B(e,["parameters","aspectRatio"],u);const h=g(n,["guidanceScale"]);e!==void 0&&h!=null&&B(e,["parameters","guidanceScale"],h);const f=g(n,["seed"]);e!==void 0&&f!=null&&B(e,["parameters","seed"],f);const p=g(n,["safetyFilterLevel"]);e!==void 0&&p!=null&&B(e,["parameters","safetySetting"],p);const y=g(n,["personGeneration"]);e!==void 0&&y!=null&&B(e,["parameters","personGeneration"],y);const b=g(n,["includeSafetyAttributes"]);e!==void 0&&b!=null&&B(e,["parameters","includeSafetyAttributes"],b);const w=g(n,["includeRaiReason"]);e!==void 0&&w!=null&&B(e,["parameters","includeRaiReason"],w);const E=g(n,["language"]);e!==void 0&&E!=null&&B(e,["parameters","language"],E);const N=g(n,["outputMimeType"]);e!==void 0&&N!=null&&B(e,["parameters","outputOptions","mimeType"],N);const S=g(n,["outputCompressionQuality"]);e!==void 0&&S!=null&&B(e,["parameters","outputOptions","compressionQuality"],S);const I=g(n,["addWatermark"]);e!==void 0&&I!=null&&B(e,["parameters","addWatermark"],I);const O=g(n,["labels"]);e!==void 0&&O!=null&&B(e,["labels"],O);const F=g(n,["imageSize"]);e!==void 0&&F!=null&&B(e,["parameters","sampleImageSize"],F);const J=g(n,["enhancePrompt"]);return e!==void 0&&J!=null&&B(e,["parameters","enhancePrompt"],J),r}function iq(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["prompt"]);a!=null&&B(r,["instances[0]","prompt"],a);const c=g(e,["config"]);return c!=null&&rq(c,r),r}function aq(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["prompt"]);a!=null&&B(r,["instances[0]","prompt"],a);const c=g(e,["config"]);return c!=null&&sq(c,r),r}function oq(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["predictions"]);if(s!=null){let c=s;Array.isArray(c)&&(c=c.map(u=>xq(u))),B(t,["generatedImages"],c)}const a=g(n,["positivePromptSafetyAttributes"]);return a!=null&&B(t,["positivePromptSafetyAttributes"],XA(a)),t}function lq(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["predictions"]);if(s!=null){let c=s;Array.isArray(c)&&(c=c.map(u=>Tp(u))),B(t,["generatedImages"],c)}const a=g(n,["positivePromptSafetyAttributes"]);return a!=null&&B(t,["positivePromptSafetyAttributes"],ZA(a)),t}function cq(n,e,t){const r={},s=g(n,["numberOfVideos"]);
4328if(e!==void 0&&s!=null&&B(e,["parameters","sampleCount"],s),g(n,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(g(n,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const a=g(n,["durationSeconds"]);if(e!==void 0&&a!=null&&B(e,["parameters","durationSeconds"],a),g(n,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const c=g(n,["aspectRatio"]);e!==void 0&&c!=null&&B(e,["parameters","aspectRatio"],c);const u=g(n,["resolution"]);e!==void 0&&u!=null&&B(e,["parameters","resolution"],u);const h=g(n,["personGeneration"]);if(e!==void 0&&h!=null&&B(e,["parameters","personGeneration"],h),g(n,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const f=g(n,["negativePrompt"]);e!==void 0&&f!=null&&B(e,["parameters","negativePrompt"],f);const p=g(n,["enhancePrompt"]);if(e!==void 0&&p!=null&&B(e,["parameters","enhancePrompt"],p),g(n,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const y=g(n,["lastFrame"]);e!==void 0&&y!=null&&B(e,["instances[0]","lastFrame"],kp(y));const b=g(n,["referenceImages"]);if(e!==void 0&&b!=null){let E=b;Array.isArray(E)&&(E=E.map(N=>fz(N))),B(e,["instances[0]","referenceImages"],E)}if(g(n,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(g(n,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");if(g(n,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const w=g(n,["webhookConfig"]);if(e!==void 0&&w!=null&&B(e,["webhookConfig"],w),g(n,["resizeMode"])!==void 0)throw new Error("resizeMode parameter is not supported in Gemini API.");return r}function uq(n,e,t){const r={},s=g(n,["numberOfVideos"]);e!==void 0&&s!=null&&B(e,["parameters","sampleCount"],s);const a=g(n,["outputGcsUri"]);e!==void 0&&a!=null&&B(e,["parameters","storageUri"],a);const c=g(n,["fps"]);e!==void 0&&c!=null&&B(e,["parameters","fps"],c);const u=g(n,["durationSeconds"]);e!==void 0&&u!=null&&B(e,["parameters","durationSeconds"],u);const h=g(n,["seed"]);e!==void 0&&h!=null&&B(e,["parameters","seed"],h);const f=g(n,["aspectRatio"]);e!==void 0&&f!=null&&B(e,["parameters","aspectRatio"],f);const p=g(n,["resolution"]);e!==void 0&&p!=null&&B(e,["parameters","resolution"],p);const y=g(n,["personGeneration"]);e!==void 0&&y!=null&&B(e,["parameters","personGeneration"],y);const b=g(n,["pubsubTopic"]);e!==void 0&&b!=null&&B(e,["parameters","pubsubTopic"],b);const w=g(n,["negativePrompt"]);e!==void 0&&w!=null&&B(e,["parameters","negativePrompt"],w);const E=g(n,["enhancePrompt"]);e!==void 0&&E!=null&&B(e,["parameters","enhancePrompt"],E);const N=g(n,["generateAudio"]);e!==void 0&&N!=null&&B(e,["parameters","generateAudio"],N);const S=g(n,["lastFrame"]);e!==void 0&&S!=null&&B(e,["instances[0]","lastFrame"],Mi(S));const I=g(n,["referenceImages"]);if(e!==void 0&&I!=null){let U=I;Array.isArray(U)&&(U=U.map(D=>mz(D))),B(e,["instances[0]","referenceImages"],U)}const O=g(n,["mask"]);e!==void 0&&O!=null&&B(e,["instances[0]","mask"],hz(O));const F=g(n,["compressionQuality"]);e!==void 0&&F!=null&&B(e,["parameters","compressionQuality"],F);const J=g(n,["labels"]);if(e!==void 0&&J!=null&&B(e,["labels"],J),g(n,["webhookConfig"])!==void 0)throw new Error("webhookConfig parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");const z=g(n,["resizeMode"]);return e!==void 0&&z!=null&&B(e,["parameters","resizeMode"],z),r}function dq(n,e){const t={},r=g(n,["name"]);r!=null&&B(t,["name"],r);const s=g(n,["metadata"]);s!=null&&B(t,["metadata"],s);const a=g(n,["done"]);a!=null&&B(t,["done"],a);const c=g(n,["error"]);c!=null&&B(t,["error"],c);const u=g(n,["response","generateVideoResponse"]);return u!=null&&B(t,["response"],gq(u)),t}function hq(n,e){const t={},r=g(n,["name"]);r!=null&&B(t,["name"],r);const s=g(n,["metadata"]);s!=null&&B(t,["metadata"],s);const a=g(n,["done"]);a!=null&&B(t,["done"],a);const c=g(n,["error"]);c!=null&&B(t,["error"],c);const u=g(n,["response"]);return u!=null&&B(t,["response"],pq(u)),t}function fq(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["prompt"]);a!=null&&B(r,["instances[0]","prompt"],a);const c=g(e,["image"]);c!=null&&B(r,["instances[0]","image"],kp(c));const u=g(e,["video"]);u!=null&&B(r,["instances[0]","video"],tI(u));const h=g(e,["source"]);h!=null&&Bq(h,r);const f=g(e,["config"]);return f!=null&&cq(f,r),r}function mq(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["prompt"]);a!=null&&B(r,["instances[0]","prompt"],a);const c=g(e,["image"]);c!=null&&B(r,["instances[0]","image"],Mi(c));const u=g(e,["video"]);u!=null&&B(r,["instances[0]","video"],nI(u));const h=g(e,["source"]);h!=null&&yq(h,r);const f=g(e,["config"]);return f!=null&&uq(f,r),r}function gq(n,e){const t={},r=g(n,["generatedSamples"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(u=>bq(u))),B(t,["generatedVideos"],c)}const s=g(n,["raiMediaFilteredCount"]);s!=null&&B(t,["raiMediaFilteredCount"],s);const a=g(n,["raiMediaFilteredReasons"]);return a!=null&&B(t,["raiMediaFilteredReasons"],a),t}function pq(n,e){const t={},r=g(n,["videos"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(u=>vq(u))),B(t,["generatedVideos"],c)}const s=g(n,["raiMediaFilteredCount"]);s!=null&&B(t,["raiMediaFilteredCount"],s);const a=g(n,["raiMediaFilteredReasons"]);return a!=null&&B(t,["raiMediaFilteredReasons"],a),t}function Bq(n,e,t){const r={},s=g(n,["prompt"]);e!==void 0&&s!=null&&B(e,["instances[0]","prompt"],s);const a=g(n,["image"]);e!==void 0&&a!=null&&B(e,["instances[0]","image"],kp(a));const c=g(n,["video"]);return e!==void 0&&c!=null&&B(e,["instances[0]","video"],tI(c)),r}function yq(n,e,t){const r={},s=g(n,["prompt"]);e!==void 0&&s!=null&&B(e,["instances[0]","prompt"],s);const a=g(n,["image"]);e!==void 0&&a!=null&&B(e,["instances[0]","image"],Mi(a));const c=g(n,["video"]);return e!==void 0&&c!=null&&B(e,["instances[0]","video"],nI(c)),r}function xq(n,e){const t={},r=g(n,["_self"]);r!=null&&B(t,["image"],Dq(r));const s=g(n,["raiFilteredReason"]);s!=null&&B(t,["raiFilteredReason"],s);const a=g(n,["_self"]);return a!=null&&B(t,["safetyAttributes"],XA(a)),t}function Tp(n,e){const t={},r=g(n,["_self"]);r!=null&&B(t,["image"],WA(r));const s=g(n,["raiFilteredReason"]);s!=null&&B(t,["raiFilteredReason"],s);const a=g(n,["_self"]);a!=null&&B(t,["safetyAttributes"],ZA(a));const c=g(n,["prompt"]);return c!=null&&B(t,["enhancedPrompt"],c),t}function Cq(n,e){const t={},r=g(n,["_self"]);r!=null&&B(t,["mask"],WA(r));const s=g(n,["labels"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>c)),B(t,["labels"],a)}return t}function bq(n,e){const t={},r=g(n,["video"]);return r!=null&&B(t,["video"],uz(r)),t}function vq(n,e){const t={},r=g(n,["_self"]);return r!=null&&B(t,["video"],dz(r)),t}function wq(n,e){const t={},r=g(n,["modelSelectionConfig"]);r!=null&&B(t,["modelConfig"],r);const s=g(n,["responseJsonSchema"]);s!=null&&B(t,["responseJsonSchema"],s);const a=g(n,["audioTimestamp"]);a!=null&&B(t,["audioTimestamp"],a);const c=g(n,["candidateCount"]);c!=null&&B(t,["candidateCount"],c);const u=g(n,["enableAffectiveDialog"]);u!=null&&B(t,["enableAffectiveDialog"],u);const h=g(n,["frequencyPenalty"]);h!=null&&B(t,["frequencyPenalty"],h);const f=g(n,["logprobs"]);f!=null&&B(t,["logprobs"],f);const p=g(n,["maxOutputTokens"]);p!=null&&B(t,["maxOutputTokens"],p);const y=g(n,["mediaResolution"]);y!=null&&B(t,["mediaResolution"],y);const b=g(n,["presencePenalty"]);b!=null&&B(t,["presencePenalty"],b);const w=g(n,["responseLogprobs"]);w!=null&&B(t,["responseLogprobs"],w);const E=g(n,["responseMimeType"]);E!=null&&B(t,["responseMimeType"],E);const N=g(n,["responseModalities"]);N!=null&&B(t,["responseModalities"],N);const S=g(n,["responseSchema"]);S!=null&&B(t,["responseSchema"],S);
4328const I=g(n,["routingConfig"]);I!=null&&B(t,["routingConfig"],I);const O=g(n,["seed"]);O!=null&&B(t,["seed"],O);const F=g(n,["speechConfig"]);F!=null&&B(t,["speechConfig"],F);const J=g(n,["stopSequences"]);J!=null&&B(t,["stopSequences"],J);const z=g(n,["temperature"]);z!=null&&B(t,["temperature"],z);const U=g(n,["thinkingConfig"]);U!=null&&B(t,["thinkingConfig"],U);const D=g(n,["topK"]);D!=null&&B(t,["topK"],D);const k=g(n,["topP"]);if(k!=null&&B(t,["topP"],k),g(n,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return t}function Eq(n,e,t){const r={},s=g(e,["model"]);return s!=null&&B(r,["_url","name"],$t(n,s)),r}function _q(n,e,t){const r={},s=g(e,["model"]);return s!=null&&B(r,["_url","name"],$t(n,s)),r}function Tq(n,e){const t={},r=g(n,["authConfig"]);r!=null&&B(t,["authConfig"],v7(r));const s=g(n,["enableWidget"]);return s!=null&&B(t,["enableWidget"],s),t}function kq(n,e){const t={},r=g(n,["searchTypes"]);if(r!=null&&B(t,["searchTypes"],r),g(n,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");if(g(n,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");const s=g(n,["timeRangeFilter"]);return s!=null&&B(t,["timeRangeFilter"],s),t}function Nq(n,e){const t={},r=g(n,["aspectRatio"]);r!=null&&B(t,["aspectRatio"],r);const s=g(n,["imageSize"]);if(s!=null&&B(t,["imageSize"],s),g(n,["personGeneration"])!==void 0)throw new Error("personGeneration parameter is not supported in Gemini API.");if(g(n,["prominentPeople"])!==void 0)throw new Error("prominentPeople parameter is not supported in Gemini API.");if(g(n,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(g(n,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");if(g(n,["imageOutputOptions"])!==void 0)throw new Error("imageOutputOptions parameter is not supported in Gemini API.");return t}function Sq(n,e){const t={},r=g(n,["aspectRatio"]);r!=null&&B(t,["aspectRatio"],r);const s=g(n,["imageSize"]);s!=null&&B(t,["imageSize"],s);const a=g(n,["personGeneration"]);a!=null&&B(t,["personGeneration"],a);const c=g(n,["prominentPeople"]);c!=null&&B(t,["prominentPeople"],c);const u=g(n,["outputMimeType"]);u!=null&&B(t,["imageOutputOptions","mimeType"],u);const h=g(n,["outputCompressionQuality"]);h!=null&&B(t,["imageOutputOptions","compressionQuality"],h);const f=g(n,["imageOutputOptions"]);return f!=null&&B(t,["imageOutputOptions"],f),t}function Dq(n,e){const t={},r=g(n,["bytesBase64Encoded"]);r!=null&&B(t,["imageBytes"],gl(r));const s=g(n,["mimeType"]);return s!=null&&B(t,["mimeType"],s),t}function WA(n,e){const t={},r=g(n,["gcsUri"]);r!=null&&B(t,["gcsUri"],r);const s=g(n,["bytesBase64Encoded"]);s!=null&&B(t,["imageBytes"],gl(s));const a=g(n,["mimeType"]);return a!=null&&B(t,["mimeType"],a),t}function kp(n,e){const t={};if(g(n,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const r=g(n,["imageBytes"]);r!=null&&B(t,["bytesBase64Encoded"],gl(r));const s=g(n,["mimeType"]);return s!=null&&B(t,["mimeType"],s),t}function Mi(n,e){const t={},r=g(n,["gcsUri"]);r!=null&&B(t,["gcsUri"],r);const s=g(n,["imageBytes"]);s!=null&&B(t,["bytesBase64Encoded"],gl(s));const a=g(n,["mimeType"]);return a!=null&&B(t,["mimeType"],a),t}function Aq(n,e,t,r){const s={},a=g(e,["pageSize"]);t!==void 0&&a!=null&&B(t,["_query","pageSize"],a);const c=g(e,["pageToken"]);t!==void 0&&c!=null&&B(t,["_query","pageToken"],c);const u=g(e,["filter"]);t!==void 0&&u!=null&&B(t,["_query","filter"],u);const h=g(e,["queryBase"]);return t!==void 0&&h!=null&&B(t,["_url","models_url"],qA(n,h)),s}function Iq(n,e,t,r){const s={},a=g(e,["pageSize"]);t!==void 0&&a!=null&&B(t,["_query","pageSize"],a);const c=g(e,["pageToken"]);t!==void 0&&c!=null&&B(t,["_query","pageToken"],c);const u=g(e,["filter"]);t!==void 0&&u!=null&&B(t,["_query","filter"],u);const h=g(e,["queryBase"]);return t!==void 0&&h!=null&&B(t,["_url","models_url"],qA(n,h)),s}function Rq(n,e,t){const r={},s=g(e,["config"]);return s!=null&&Aq(n,s,r),r}function Pq(n,e,t){const r={},s=g(e,["config"]);return s!=null&&Iq(n,s,r),r}function Mq(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["nextPageToken"]);s!=null&&B(t,["nextPageToken"],s);const a=g(n,["_self"]);if(a!=null){let c=zA(a);Array.isArray(c)&&(c=c.map(u=>Qy(u))),B(t,["models"],c)}return t}function Lq(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["nextPageToken"]);s!=null&&B(t,["nextPageToken"],s);const a=g(n,["_self"]);if(a!=null){let c=zA(a);Array.isArray(c)&&(c=c.map(u=>Wy(u))),B(t,["models"],c)}return t}function jq(n,e){const t={},r=g(n,["maskMode"]);r!=null&&B(t,["maskMode"],r);const s=g(n,["segmentationClasses"]);s!=null&&B(t,["maskClasses"],s);const a=g(n,["maskDilation"]);return a!=null&&B(t,["dilation"],a),t}function Qy(n,e){const t={},r=g(n,["name"]);r!=null&&B(t,["name"],r);const s=g(n,["displayName"]);s!=null&&B(t,["displayName"],s);const a=g(n,["description"]);a!=null&&B(t,["description"],a);
4328const c=g(n,["version"]);c!=null&&B(t,["version"],c);const u=g(n,["_self"]);u!=null&&B(t,["tunedModelInfo"],tz(u));const h=g(n,["inputTokenLimit"]);h!=null&&B(t,["inputTokenLimit"],h);const f=g(n,["outputTokenLimit"]);f!=null&&B(t,["outputTokenLimit"],f);const p=g(n,["supportedGenerationMethods"]);p!=null&&B(t,["supportedActions"],p);const y=g(n,["temperature"]);y!=null&&B(t,["temperature"],y);const b=g(n,["maxTemperature"]);b!=null&&B(t,["maxTemperature"],b);const w=g(n,["topP"]);w!=null&&B(t,["topP"],w);const E=g(n,["topK"]);E!=null&&B(t,["topK"],E);const N=g(n,["thinking"]);return N!=null&&B(t,["thinking"],N),t}function Wy(n,e){const t={},r=g(n,["name"]);r!=null&&B(t,["name"],r);const s=g(n,["displayName"]);s!=null&&B(t,["displayName"],s);const a=g(n,["description"]);a!=null&&B(t,["description"],a);const c=g(n,["versionId"]);c!=null&&B(t,["version"],c);const u=g(n,["deployedModels"]);if(u!=null){let b=u;Array.isArray(b)&&(b=b.map(w=>Q7(w))),B(t,["endpoints"],b)}const h=g(n,["labels"]);h!=null&&B(t,["labels"],h);const f=g(n,["_self"]);f!=null&&B(t,["tunedModelInfo"],nz(f));const p=g(n,["defaultCheckpointId"]);p!=null&&B(t,["defaultCheckpointId"],p);const y=g(n,["checkpoints"]);if(y!=null){let b=y;Array.isArray(b)&&(b=b.map(w=>w)),B(t,["checkpoints"],b)}return t}function Oq(n,e){const t={},r=g(n,["mediaResolution"]);r!=null&&B(t,["mediaResolution"],r);const s=g(n,["codeExecutionResult"]);s!=null&&B(t,["codeExecutionResult"],s);const a=g(n,["executableCode"]);a!=null&&B(t,["executableCode"],a);const c=g(n,["fileData"]);c!=null&&B(t,["fileData"],W7(c));const u=g(n,["functionCall"]);u!=null&&B(t,["functionCall"],X7(u));const h=g(n,["functionResponse"]);h!=null&&B(t,["functionResponse"],h);const f=g(n,["inlineData"]);f!=null&&B(t,["inlineData"],w7(f));const p=g(n,["text"]);p!=null&&B(t,["text"],p);const y=g(n,["thought"]);y!=null&&B(t,["thought"],y);const b=g(n,["thoughtSignature"]);b!=null&&B(t,["thoughtSignature"],b);const w=g(n,["videoMetadata"]);w!=null&&B(t,["videoMetadata"],w);const E=g(n,["toolCall"]);E!=null&&B(t,["toolCall"],E);const N=g(n,["toolResponse"]);N!=null&&B(t,["toolResponse"],N);const S=g(n,["partMetadata"]);return S!=null&&B(t,["partMetadata"],S),t}function Fq(n,e){const t={},r=g(n,["mediaResolution"]);r!=null&&B(t,["mediaResolution"],r);const s=g(n,["codeExecutionResult"]);s!=null&&B(t,["codeExecutionResult"],s);const a=g(n,["executableCode"]);a!=null&&B(t,["executableCode"],a);const c=g(n,["fileData"]);c!=null&&B(t,["fileData"],c);const u=g(n,["functionCall"]);u!=null&&B(t,["functionCall"],u);const h=g(n,["functionResponse"]);h!=null&&B(t,["functionResponse"],h);const f=g(n,["inlineData"]);f!=null&&B(t,["inlineData"],f);const p=g(n,["text"]);p!=null&&B(t,["text"],p);const y=g(n,["thought"]);y!=null&&B(t,["thought"],y);const b=g(n,["thoughtSignature"]);b!=null&&B(t,["thoughtSignature"],b);const w=g(n,["videoMetadata"]);if(w!=null&&B(t,["videoMetadata"],w),g(n,["toolCall"])!==void 0)throw new Error("toolCall parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(g(n,["toolResponse"])!==void 0)throw new Error("toolResponse parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(g(n,["partMetadata"])!==void 0)throw new Error("partMetadata parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return t}function Uq(n,e){const t={},r=g(n,["productImage"]);return r!=null&&B(t,["image"],Mi(r)),t}function Vq(n,e,t){const r={},s=g(n,["numberOfImages"]);e!==void 0&&s!=null&&B(e,["parameters","sampleCount"],s);const a=g(n,["baseSteps"]);e!==void 0&&a!=null&&B(e,["parameters","baseSteps"],a);const c=g(n,["outputGcsUri"]);e!==void 0&&c!=null&&B(e,["parameters","storageUri"],c);const u=g(n,["seed"]);e!==void 0&&u!=null&&B(e,["parameters","seed"],u);const h=g(n,["safetyFilterLevel"]);e!==void 0&&h!=null&&B(e,["parameters","safetySetting"],h);const f=g(n,["personGeneration"]);e!==void 0&&f!=null&&B(e,["parameters","personGeneration"],f);const p=g(n,["addWatermark"]);e!==void 0&&p!=null&&B(e,["parameters","addWatermark"],p);const y=g(n,["outputMimeType"]);e!==void 0&&y!=null&&B(e,["parameters","outputOptions","mimeType"],y);const b=g(n,["outputCompressionQuality"]);e!==void 0&&b!=null&&B(e,["parameters","outputOptions","compressionQuality"],b);const w=g(n,["enhancePrompt"]);e!==void 0&&w!=null&&B(e,["parameters","enhancePrompt"],w);const E=g(n,["labels"]);return e!==void 0&&E!=null&&B(e,["labels"],E),r}function Gq(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["source"]);a!=null&&qq(a,r);const c=g(e,["config"]);return c!=null&&Vq(c,r),r}function Hq(n,e){const t={},r=g(n,["predictions"]);if(r!=null){let s=r;Array.isArray(s)&&(s=s.map(a=>Tp(a))),B(t,["generatedImages"],s)}return t}function qq(n,e,t){const r={},s=g(n,["prompt"]);e!==void 0&&s!=null&&B(e,["instances[0]","prompt"],s);const a=g(n,["personImage"]);e!==void 0&&a!=null&&B(e,["instances[0]","personImage","image"],Mi(a));const c=g(n,["productImages"]);if(e!==void 0&&c!=null){let u=c;Array.isArray(u)&&(u=u.map(h=>Uq(h))),B(e,["instances[0]","productImages"],u)}return r}function zq(n,e){const t={},r=g(n,["referenceImage"]);r!=null&&B(t,["referenceImage"],Mi(r));const s=g(n,["referenceId"]);s!=null&&B(t,["referenceId"],s);const a=g(n,["referenceType"]);a!=null&&B(t,["referenceType"],a);const c=g(n,["maskImageConfig"]);c!=null&&B(t,["maskImageConfig"],jq(c));const u=g(n,["controlImageConfig"]);u!=null&&B(t,["controlImageConfig"],D7(u));const h=g(n,["styleImageConfig"]);h!=null&&B(t,["styleImageConfig"],h);const f=g(n,["subjectImageConfig"]);return f!=null&&B(t,["subjectImageConfig"],f),t}function XA(n,e){const t={},r=g(n,["safetyAttributes","categories"]);r!=null&&B(t,["categories"],r);const s=g(n,["safetyAttributes","scores"]);s!=null&&B(t,["scores"],s);const a=g(n,["contentType"]);return a!=null&&B(t,["contentType"],a),t}function ZA(n,e){const t={},r=g(n,["safetyAttributes","categories"]);r!=null&&B(t,["categories"],r);const s=g(n,["safetyAttributes","scores"]);s!=null&&B(t,["scores"],s);const a=g(n,["contentType"]);return a!=null&&B(t,["contentType"],a),t}function Jq(n,e){const t={},r=g(n,["category"]);if(r!=null&&B(t,["category"],r),g(n,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const s=g(n,["threshold"]);return s!=null&&B(t,["threshold"],s),t}function $q(n,e){const t={},r=g(n,["image"]);return r!=null&&B(t,["image"],Mi(r)),t}function Kq(n,e,t){const r={},s=g(n,["mode"]);e!==void 0&&s!=null&&B(e,["parameters","mode"],s);const a=g(n,["maxPredictions"]);e!==void 0&&a!=null&&B(e,["parameters","maxPredictions"],a);const c=g(n,["confidenceThreshold"]);e!==void 0&&c!=null&&B(e,["parameters","confidenceThreshold"],c);const u=g(n,["maskDilation"]);e!==void 0&&u!=null&&B(e,["parameters","maskDilation"],u);const h=g(n,["binaryColorThreshold"]);e!==void 0&&h!=null&&B(e,["parameters","binaryColorThreshold"],h);const f=g(n,["labels"]);return e!==void 0&&f!=null&&B(e,["labels"],f),r}function Yq(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["source"]);a!=null&&Wq(a,r);const c=g(e,["config"]);return c!=null&&Kq(c,r),r}function Qq(n,e){const t={},r=g(n,["predictions"]);if(r!=null){let s=r;Array.isArray(s)&&(s=s.map(a=>Cq(a))),B(t,["generatedMasks"],s)}return t}function Wq(n,e,t){const r={},s=g(n,["prompt"]);e!==void 0&&s!=null&&B(e,["instances[0]","prompt"],s);const a=g(n,["image"]);e!==void 0&&a!=null&&B(e,["instances[0]","image"],Mi(a));const c=g(n,["scribbleImage"]);return e!==void 0&&c!=null&&B(e,["instances[0]","scribble"],$q(c)),r}function Xq(n,e){const t={},r=g(n,["retrievalConfig"]);r!=null&&B(t,["retrievalConfig"],r);const s=g(n,["functionCallingConfig"]);s!=null&&B(t,["functionCallingConfig"],Z7(s));const a=g(n,["includeServerSideToolInvocations"]);return a!=null&&B(t,["includeServerSideToolInvocations"],a),t}function Zq(n,e){const t={},r=g(n,["retrievalConfig"]);r!=null&&B(t,["retrievalConfig"],r);const s=g(n,["functionCallingConfig"]);if(s!=null&&B(t,["functionCallingConfig"],s),g(n,["includeServerSideToolInvocations"])!==void 0)throw new Error("includeServerSideToolInvocations parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return t}function ez(n,e){const t={};
4328if(g(n,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const r=g(n,["computerUse"]);r!=null&&B(t,["computerUse"],r);const s=g(n,["fileSearch"]);s!=null&&B(t,["fileSearch"],s);const a=g(n,["googleSearch"]);a!=null&&B(t,["googleSearch"],kq(a));const c=g(n,["googleMaps"]);c!=null&&B(t,["googleMaps"],Tq(c));const u=g(n,["codeExecution"]);if(u!=null&&B(t,["codeExecution"],u),g(n,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const h=g(n,["functionDeclarations"]);if(h!=null){let b=h;Array.isArray(b)&&(b=b.map(w=>w)),B(t,["functionDeclarations"],b)}const f=g(n,["googleSearchRetrieval"]);if(f!=null&&B(t,["googleSearchRetrieval"],f),g(n,["parallelAiSearch"])!==void 0)throw new Error("parallelAiSearch parameter is not supported in Gemini API.");const p=g(n,["urlContext"]);p!=null&&B(t,["urlContext"],p);const y=g(n,["mcpServers"]);if(y!=null){let b=y;Array.isArray(b)&&(b=b.map(w=>w)),B(t,["mcpServers"],b)}return t}function eI(n,e){const t={},r=g(n,["retrieval"]);r!=null&&B(t,["retrieval"],r);const s=g(n,["computerUse"]);if(s!=null&&B(t,["computerUse"],s),g(n,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");const a=g(n,["googleSearch"]);a!=null&&B(t,["googleSearch"],a);const c=g(n,["googleMaps"]);c!=null&&B(t,["googleMaps"],c);const u=g(n,["codeExecution"]);u!=null&&B(t,["codeExecution"],u);const h=g(n,["enterpriseWebSearch"]);h!=null&&B(t,["enterpriseWebSearch"],h);const f=g(n,["functionDeclarations"]);if(f!=null){let w=f;Array.isArray(w)&&(w=w.map(E=>eq(E))),B(t,["functionDeclarations"],w)}const p=g(n,["googleSearchRetrieval"]);p!=null&&B(t,["googleSearchRetrieval"],p);const y=g(n,["parallelAiSearch"]);y!=null&&B(t,["parallelAiSearch"],y);const b=g(n,["urlContext"]);if(b!=null&&B(t,["urlContext"],b),g(n,["mcpServers"])!==void 0)throw new Error("mcpServers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return t}function tz(n,e){const t={},r=g(n,["baseModel"]);r!=null&&B(t,["baseModel"],r);const s=g(n,["createTime"]);s!=null&&B(t,["createTime"],s);const a=g(n,["updateTime"]);return a!=null&&B(t,["updateTime"],a),t}function nz(n,e){const t={},r=g(n,["labels","google-vertex-llm-tuning-base-model-id"]);r!=null&&B(t,["baseModel"],r);const s=g(n,["createTime"]);s!=null&&B(t,["createTime"],s);const a=g(n,["updateTime"]);return a!=null&&B(t,["updateTime"],a),t}function rz(n,e,t){const r={},s=g(n,["displayName"]);e!==void 0&&s!=null&&B(e,["displayName"],s);const a=g(n,["description"]);e!==void 0&&a!=null&&B(e,["description"],a);const c=g(n,["defaultCheckpointId"]);return e!==void 0&&c!=null&&B(e,["defaultCheckpointId"],c),r}function sz(n,e,t){const r={},s=g(n,["displayName"]);e!==void 0&&s!=null&&B(e,["displayName"],s);const a=g(n,["description"]);e!==void 0&&a!=null&&B(e,["description"],a);const c=g(n,["defaultCheckpointId"]);return e!==void 0&&c!=null&&B(e,["defaultCheckpointId"],c),r}function iz(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","name"],$t(n,s));const a=g(e,["config"]);return a!=null&&rz(a,r),r}function az(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["config"]);return a!=null&&sz(a,r),r}function oz(n,e,t){const r={},s=g(n,["outputGcsUri"]);e!==void 0&&s!=null&&B(e,["parameters","storageUri"],s);const a=g(n,["safetyFilterLevel"]);e!==void 0&&a!=null&&B(e,["parameters","safetySetting"],a);const c=g(n,["personGeneration"]);e!==void 0&&c!=null&&B(e,["parameters","personGeneration"],c);const u=g(n,["includeRaiReason"]);e!==void 0&&u!=null&&B(e,["parameters","includeRaiReason"],u);const h=g(n,["outputMimeType"]);e!==void 0&&h!=null&&B(e,["parameters","outputOptions","mimeType"],h);const f=g(n,["outputCompressionQuality"]);e!==void 0&&f!=null&&B(e,["parameters","outputOptions","compressionQuality"],f);const p=g(n,["enhanceInputImage"]);e!==void 0&&p!=null&&B(e,["parameters","upscaleConfig","enhanceInputImage"],p);const y=g(n,["imagePreservationFactor"]);e!==void 0&&y!=null&&B(e,["parameters","upscaleConfig","imagePreservationFactor"],y);const b=g(n,["labels"]);e!==void 0&&b!=null&&B(e,["labels"],b);const w=g(n,["numberOfImages"]);
4328e!==void 0&&w!=null&&B(e,["parameters","sampleCount"],w);const E=g(n,["mode"]);return e!==void 0&&E!=null&&B(e,["parameters","mode"],E),r}function lz(n,e,t){const r={},s=g(e,["model"]);s!=null&&B(r,["_url","model"],$t(n,s));const a=g(e,["image"]);a!=null&&B(r,["instances[0]","image"],Mi(a));const c=g(e,["upscaleFactor"]);c!=null&&B(r,["parameters","upscaleConfig","upscaleFactor"],c);const u=g(e,["config"]);return u!=null&&oz(u,r),r}function cz(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["predictions"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>Tp(c))),B(t,["generatedImages"],a)}return t}function uz(n,e){const t={},r=g(n,["uri"]);r!=null&&B(t,["uri"],r);const s=g(n,["encodedVideo"]);s!=null&&B(t,["videoBytes"],gl(s));const a=g(n,["encoding"]);return a!=null&&B(t,["mimeType"],a),t}function dz(n,e){const t={},r=g(n,["gcsUri"]);r!=null&&B(t,["uri"],r);const s=g(n,["bytesBase64Encoded"]);s!=null&&B(t,["videoBytes"],gl(s));const a=g(n,["mimeType"]);return a!=null&&B(t,["mimeType"],a),t}function hz(n,e){const t={},r=g(n,["image"]);r!=null&&B(t,["_self"],Mi(r));const s=g(n,["maskMode"]);return s!=null&&B(t,["maskMode"],s),t}function fz(n,e){const t={},r=g(n,["image"]);r!=null&&B(t,["image"],kp(r));const s=g(n,["referenceType"]);return s!=null&&B(t,["referenceType"],s),t}function mz(n,e){const t={},r=g(n,["image"]);r!=null&&B(t,["image"],Mi(r));const s=g(n,["referenceType"]);return s!=null&&B(t,["referenceType"],s),t}function tI(n,e){const t={},r=g(n,["uri"]);r!=null&&B(t,["uri"],r);const s=g(n,["videoBytes"]);s!=null&&B(t,["encodedVideo"],gl(s));const a=g(n,["mimeType"]);return a!=null&&B(t,["encoding"],a),t}function nI(n,e){const t={},r=g(n,["uri"]);r!=null&&B(t,["gcsUri"],r);const s=g(n,["videoBytes"]);s!=null&&B(t,["bytesBase64Encoded"],gl(s));const a=g(n,["mimeType"]);return a!=null&&B(t,["mimeType"],a),t}/**
4329 * @license
4330 * Copyright 2025 Google LLC
4331 * SPDX-License-Identifier: Apache-2.0
4332 */function gz(n,e,t){const r={},s=g(e,["displayName"]);t!==void 0&&s!=null&&B(t,["displayName"],s);const a=g(e,["embeddingModel"]);return t!==void 0&&a!=null&&B(t,["embeddingModel"],$t(n,a)),r}function pz(n,e){const t={},r=g(e,["config"]);return r!=null&&gz(n,r,t),t}function Bz(n,e){const t={},r=g(n,["force"]);return e!==void 0&&r!=null&&B(e,["_query","force"],r),t}function yz(n){const e={},t=g(n,["name"]);t!=null&&B(e,["_url","name"],t);const r=g(n,["config"]);return r!=null&&Bz(r,e),e}function xz(n){const e={},t=g(n,["name"]);return t!=null&&B(e,["_url","name"],t),e}function Cz(n,e){const t={},r=g(n,["customMetadata"]);if(e!==void 0&&r!=null){let a=r;Array.isArray(a)&&(a=a.map(c=>c)),B(e,["customMetadata"],a)}const s=g(n,["chunkingConfig"]);return e!==void 0&&s!=null&&B(e,["chunkingConfig"],s),t}function bz(n){const e={},t=g(n,["name"]);t!=null&&B(e,["name"],t);const r=g(n,["metadata"]);r!=null&&B(e,["metadata"],r);const s=g(n,["done"]);s!=null&&B(e,["done"],s);const a=g(n,["error"]);a!=null&&B(e,["error"],a);const c=g(n,["response"]);return c!=null&&B(e,["response"],wz(c)),e}function vz(n){const e={},t=g(n,["fileSearchStoreName"]);t!=null&&B(e,["_url","file_search_store_name"],t);const r=g(n,["fileName"]);r!=null&&B(e,["fileName"],r);const s=g(n,["config"]);return s!=null&&Cz(s,e),e}function wz(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["parent"]);r!=null&&B(e,["parent"],r);const s=g(n,["documentName"]);return s!=null&&B(e,["documentName"],s),e}function Ez(n,e){const t={},r=g(n,["pageSize"]);e!==void 0&&r!=null&&B(e,["_query","pageSize"],r);const s=g(n,["pageToken"]);return e!==void 0&&s!=null&&B(e,["_query","pageToken"],s),t}function _z(n){const e={},t=g(n,["config"]);return t!=null&&Ez(t,e),e}function Tz(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["nextPageToken"]);r!=null&&B(e,["nextPageToken"],r);const s=g(n,["fileSearchStores"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>c)),B(e,["fileSearchStores"],a)}return e}function rI(n,e){const t={},r=g(n,["mimeType"]);e!==void 0&&r!=null&&B(e,["mimeType"],r);const s=g(n,["displayName"]);e!==void 0&&s!=null&&B(e,["displayName"],s);const a=g(n,["customMetadata"]);if(e!==void 0&&a!=null){let u=a;Array.isArray(u)&&(u=u.map(h=>h)),B(e,["customMetadata"],u)}const c=g(n,["chunkingConfig"]);return e!==void 0&&c!=null&&B(e,["chunkingConfig"],c),t}function kz(n){const e={},t=g(n,["fileSearchStoreName"]);t!=null&&B(e,["_url","file_search_store_name"],t);const r=g(n,["config"]);return r!=null&&rI(r,e),e}function Nz(n){const e={},t=g(n,["sdkHttpResponse"]);return t!=null&&B(e,["sdkHttpResponse"],t),e}/**
4333 * @license
4334 * Copyright 2025 Google LLC
4335 * SPDX-License-Identifier: Apache-2.0
4336 */const Sz="Content-Type",Dz="X-Server-Timeout",Az="User-Agent",Xy="x-goog-api-client",Iz="1.52.0",Rz=`google-genai-sdk/${Iz}`,Pz="v1beta1",Mz="v1beta",Lz=new Set(["us","eu"]),jz=5,Oz=[408,429,500,502,503,504];class Fz{constructor(e){var t,r,s;this.clientOptions=Object.assign({},e),this.customBaseUrl=(t=e.httpOptions)===null||t===void 0?void 0:t.baseUrl,this.clientOptions.vertexai&&(this.clientOptions.project&&this.clientOptions.location?this.clientOptions.apiKey=void 0:this.clientOptions.apiKey&&(this.clientOptions.project=void 0,this.clientOptions.location=void 0));const a={};if(this.clientOptions.vertexai){if(!this.clientOptions.location&&!this.clientOptions.apiKey&&!this.customBaseUrl&&(this.clientOptions.location="global"),!(this.clientOptions.project&&this.clientOptions.location||this.clientOptions.apiKey)&&!this.customBaseUrl)throw new Error("Authentication is not set up. Please provide either a project and location, or an API key, or a custom base URL.");const u=e.project&&e.location||!!e.apiKey;this.customBaseUrl&&!u?(a.baseUrl=this.customBaseUrl,this.clientOptions.project=void 0,this.clientOptions.location=void 0):this.clientOptions.apiKey||this.clientOptions.location==="global"?a.baseUrl="https://aiplatform.googleapis.com/":this.clientOptions.project&&this.clientOptions.location&&Lz.has(this.clientOptions.location)?a.baseUrl=`https://aiplatform.${this.clientOptions.location}.rep.googleapis.com/`:this.clientOptions.project&&this.clientOptions.location&&(a.baseUrl=`https://${this.clientOptions.location}-aiplatform.googleapis.com/`),a.apiVersion=(r=this.clientOptions.apiVersion)!==null&&r!==void 0?r:Pz}else this.clientOptions.apiKey||console.warn("API key should be set when using the Gemini API."),a.apiVersion=(s=this.clientOptions.apiVersion)!==null&&s!==void 0?s:Mz,a.baseUrl="https://generativelanguage.googleapis.com/";a.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=a,e.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(a,e.httpOptions))}isVertexAI(){var e;return(e=this.clientOptions.vertexai)!==null&&e!==void 0?e:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getCustomBaseUrl(){return this.customBaseUrl}async getAuthHeaders(){const e=new Headers;return await this.clientOptions.auth.addAuthHeaders(e),e}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw new Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw new Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw new Error("Headers are not set.")}getRequestUrlInternal(e){if(!e||e.baseUrl===void 0||e.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const r=[e.baseUrl.endsWith("/")?e.baseUrl.slice(0,-1):e.baseUrl];return e.apiVersion&&e.apiVersion!==""&&r.push(e.apiVersion),r.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const e=this.getBaseUrl(),t=new URL(e);return t.protocol=t.protocol=="http:"?"ws":"wss",t.toString()}setBaseUrl(e){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=e;else throw new Error("HTTP options are not correctly set.")}constructUrl(e,t,r){const s=[this.getRequestUrlInternal(t)];return r&&s.push(this.getBaseResourcePath()),e!==""&&s.push(e),new URL(`${s.join("/")}`)}shouldPrependVertexProjectPath(e,t){return!(t.baseUrl&&t.baseUrlResourceScope===$y.COLLECTION||this.clientOptions.apiKey||!this.clientOptions.vertexai||e.path.startsWith("projects/")||e.httpMethod==="GET"&&e.path.startsWith("publishers/google/models"))}async request(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));const r=this.shouldPrependVertexProjectPath(e,t),s=this.constructUrl(e.path,t,r);if(e.queryParams)for(const[c,u]of Object.entries(e.queryParams))s.searchParams.append(c,String(u));let a={};if(e.httpMethod==="GET"){if(e.body&&e.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else a.body=e.body;return a=await this.includeExtraHttpOptionsToRequestInit(a,t,s.toString(),e.abortSignal),this.unaryApiCall(s,a,e.httpMethod)}patchHttpOptions(e,t){const r=JSON.parse(JSON.stringify(e));for(const[s,a]of Object.entries(t))typeof a=="object"?r[s]=Object.assign(Object.assign({},r[s]),a):a!==void 0&&(r[s]=a);return r}async requestStream(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));const r=this.shouldPrependVertexProjectPath(e,t),s=this.constructUrl(e.path,t,r);(!s.searchParams.has("alt")||s.searchParams.get("alt")!=="sse")&&s.searchParams.set("alt","sse");let a={};return a.body=e.body,a=await this.includeExtraHttpOptionsToRequestInit(a,t,s.toString(),e.abortSignal),this.streamApiCall(s,a,e.httpMethod)}async includeExtraHttpOptionsToRequestInit(e,t,r,s){if(t&&t.timeout||s){const a=new AbortController,c=a.signal;
4336if(t.timeout&&(t==null?void 0:t.timeout)>0){const u=setTimeout(()=>a.abort(),t.timeout);u&&typeof u.unref=="function"&&u.unref()}s&&s.addEventListener("abort",()=>{a.abort()}),e.signal=c}return t&&t.extraBody!==null&&Uz(e,t.extraBody),e.headers=await this.getHeadersInternal(t,r),e}async unaryApiCall(e,t,r){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:r})).then(async s=>(await wN(s),new Fg(s))).catch(s=>{throw s instanceof Error?s:new Error(JSON.stringify(s))})}async streamApiCall(e,t,r){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:r})).then(async s=>(await wN(s),this.processStreamResponse(s))).catch(s=>{throw s instanceof Error?s:new Error(JSON.stringify(s))})}processStreamResponse(e){return Ai(this,arguments,function*(){var r;const s=(r=e==null?void 0:e.body)===null||r===void 0?void 0:r.getReader(),a=new TextDecoder("utf-8");if(!s)throw new Error("Response body is empty");try{let c="";const u="data:",h=[`
4337
4338`,"\r\r",`\r
4339\r
4340`];for(;;){const{done:f,value:p}=yield yt(s.read());if(f){if(c.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const y=a.decode(p,{stream:!0});try{const E=JSON.parse(y);if("error"in E){const N=JSON.parse(JSON.stringify(E.error)),S=N.status,I=N.code,O=`got status: ${S}. ${JSON.stringify(E)}`;if(I>=400&&I<600)throw new _p({message:O,status:I})}}catch(E){if(E.name==="ApiError")throw E}c+=y;let b=-1,w=0;for(;;){b=-1,w=0;for(const S of h){const I=c.indexOf(S);I!==-1&&(b===-1||I<b)&&(b=I,w=S.length)}if(b===-1)break;const E=c.substring(0,b);c=c.substring(b+w);const N=E.trim();if(N.startsWith(u)){const S=N.substring(u.length).trim();try{const I=new Response(S,{headers:e==null?void 0:e.headers,status:e==null?void 0:e.status,statusText:e==null?void 0:e.statusText});yield yield yt(new Fg(I))}catch(I){throw new Error(`exception parsing stream chunk ${S}. ${I}`)}}}}}finally{s.releaseLock()}})}async apiCall(e,t){var r;if(!this.clientOptions.httpOptions||!this.clientOptions.httpOptions.retryOptions)return fetch(e,t);const s=this.clientOptions.httpOptions.retryOptions;return fH(async()=>{const c=await fetch(e,t);if(c.ok)return c;throw Oz.includes(c.status)?new Error(`Retryable HTTP Error: ${c.statusText}`):new MA.AbortError(`Non-retryable exception ${c.statusText} sending request`)},{retries:((r=s.attempts)!==null&&r!==void 0?r:jz)-1})}getDefaultHeaders(){const e={},t=Rz+" "+this.clientOptions.userAgentExtra;return e[Az]=t,e[Xy]=t,e[Sz]="application/json",e}async getHeadersInternal(e,t){const r=new Headers;if(e&&e.headers){for(const[s,a]of Object.entries(e.headers))r.append(s,a);e.timeout&&e.timeout>0&&r.append(Dz,String(Math.ceil(e.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(r,t),r}getFileName(e){var t;let r="";return typeof e=="string"&&(r=e.replace(/[/\\]+$/,""),r=(t=r.split(/[/\\]/).pop())!==null&&t!==void 0?t:""),r}async uploadFile(e,t){var r;const s={};t!=null&&(s.mimeType=t.mimeType,s.name=t.name,s.displayName=t.displayName),s.name&&!s.name.startsWith("files/")&&(s.name=`files/${s.name}`);const a=this.clientOptions.uploader,c=await a.stat(e);s.sizeBytes=String(c.size);const u=(r=t==null?void 0:t.mimeType)!==null&&r!==void 0?r:c.type;if(u===void 0||u==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");s.mimeType=u;const h={file:s},f=this.getFileName(e),p=Ve("upload/v1beta/files",h._url),y=await this.fetchUploadUrl(p,s.sizeBytes,s.mimeType,f,h,t==null?void 0:t.httpOptions);return a.upload(e,y,this)}async uploadFileToFileSearchStore(e,t,r){var s;const a=this.clientOptions.uploader,c=await a.stat(t),u=String(c.size),h=(s=r==null?void 0:r.mimeType)!==null&&s!==void 0?s:c.type;if(h===void 0||h==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");const f=`upload/v1beta/${e}:uploadToFileSearchStore`,p=this.getFileName(t),y={};r!=null&&rI(r,y);const b=await this.fetchUploadUrl(f,u,h,p,y,r==null?void 0:r.httpOptions);return a.uploadToFileSearchStore(t,b,this)}async downloadFile(e){await this.clientOptions.downloader.download(e,this)}async fetchUploadUrl(e,t,r,s,a,c){var u;let h={};c?h=c:h={apiVersion:"",headers:Object.assign({"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${t}`,"X-Goog-Upload-Header-Content-Type":`${r}`},s?{"X-Goog-Upload-File-Name":s}:{})};const f=await this.request({path:e,body:JSON.stringify(a),httpMethod:"POST",httpOptions:h});if(!f||!(f!=null&&f.headers))throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const p=(u=f==null?void 0:f.headers)===null||u===void 0?void 0:u["x-goog-upload-url"];if(p===void 0)throw new Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return p}}async function wN(n){var e;if(n===void 0)throw new Error("response is undefined");if(!n.ok){const t=n.status;let r;!((e=n.headers.get("content-type"))===null||e===void 0)&&e.includes("application/json")?r=await n.json():r={error:{message:await n.text(),code:n.status,status:n.statusText}};const s=JSON.stringify(r);throw t>=400&&t<600?new _p({message:s,status:t}):new Error(s)}}function Uz(n,e){if(!e||Object.keys(e).length===0)return;if(n.body instanceof Blob){console.warn("includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.");return}let t={};
4340if(typeof n.body=="string"&&n.body.length>0)try{const a=JSON.parse(n.body);if(typeof a=="object"&&a!==null&&!Array.isArray(a))t=a;else{console.warn("includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.");return}}catch{console.warn("includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.");return}function r(a,c){const u=Object.assign({},a);for(const h in c)if(Object.prototype.hasOwnProperty.call(c,h)){const f=c[h],p=u[h];f&&typeof f=="object"&&!Array.isArray(f)&&p&&typeof p=="object"&&!Array.isArray(p)?u[h]=r(p,f):(p&&f&&typeof p!=typeof f&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${h}". Original type: ${typeof p}, New type: ${typeof f}. Overwriting.`),u[h]=f)}return u}const s=r(t,e);n.body=JSON.stringify(s)}/**
4341 * @license
4342 * Copyright 2025 Google LLC
4343 * SPDX-License-Identifier: Apache-2.0
4344 */const Vz="mcp_used/unknown";let Gz=!1;function sI(n){for(const e of n)if(Hz(e)||typeof e=="object"&&"inputSchema"in e)return!0;return Gz}function iI(n){var e;const t=(e=n[Xy])!==null&&e!==void 0?e:"";n[Xy]=(t+` ${Vz}`).trimStart()}function Hz(n){return n!==null&&typeof n=="object"&&n instanceof jC}function qz(n){return Ai(this,arguments,function*(t,r=100){let s,a=0;for(;a<r;){const c=yield yt(t.listTools({cursor:s}));for(const u of c.tools)yield yield yt(u),a++;if(!c.nextCursor)break;s=c.nextCursor}})}class jC{constructor(e=[],t){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=t}static create(e,t){return new jC(e,t)}async initialize(){var e,t,r,s;if(this.mcpTools.length>0)return;const a={},c=[];for(const p of this.mcpClients)try{for(var u=!0,h=(t=void 0,Ii(qz(p))),f;f=await h.next(),e=f.done,!e;u=!0){s=f.value,u=!1;const y=s;c.push(y);const b=y.name;if(a[b])throw new Error(`Duplicate function name ${b} found in MCP tools. Please ensure function names are unique.`);a[b]=p}}catch(y){t={error:y}}finally{try{!u&&!e&&(r=h.return)&&await r.call(h)}finally{if(t)throw t.error}}this.mcpTools=c,this.functionNameToMcpClient=a}async tool(){return await this.initialize(),n8(this.mcpTools,this.config)}async callTool(e){await this.initialize();const t=[];for(const r of e)if(r.name in this.functionNameToMcpClient){const s=this.functionNameToMcpClient[r.name];let a;this.config.timeout&&(a={timeout:this.config.timeout});const c=await s.callTool({name:r.name,arguments:r.args},void 0,a);t.push({functionResponse:{name:r.name,response:c.isError?{error:c}:c}})}return t}}/**
4345 * @license
4346 * Copyright 2025 Google LLC
4347 * SPDX-License-Identifier: Apache-2.0
4348 */async function zz(n,e,t){const r=new KH;let s;t.data instanceof Blob?s=JSON.parse(await t.data.text()):s=JSON.parse(t.data),Object.assign(r,s),e(r)}class Jz{constructor(e,t,r){this.apiClient=e,this.auth=t,this.webSocketFactory=r}async connect(e){var t,r;if(this.apiClient.isVertexAI())throw new Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");const s=this.apiClient.getWebsocketBaseUrl(),a=this.apiClient.getApiVersion(),c=Yz(this.apiClient.getDefaultHeaders()),u=this.apiClient.getApiKey(),h=`${s}/ws/google.ai.generativelanguage.${a}.GenerativeService.BidiGenerateMusic?key=${u}`;let f=()=>{};const p=new Promise(F=>{f=F}),y=e.callbacks,b=function(){f({})},w=this.apiClient,E={onopen:b,onmessage:F=>{zz(w,y.onmessage,F)},onerror:(t=y==null?void 0:y.onerror)!==null&&t!==void 0?t:function(F){},onclose:(r=y==null?void 0:y.onclose)!==null&&r!==void 0?r:function(F){}},N=this.webSocketFactory.create(h,Kz(c),E);N.connect(),await p;const O={setup:{model:$t(this.apiClient,e.model)}};return N.send(JSON.stringify(O)),new $z(N,this.apiClient)}}class $z{constructor(e,t){this.conn=e,this.apiClient=t}async setWeightedPrompts(e){if(!e.weightedPrompts||Object.keys(e.weightedPrompts).length===0)throw new Error("Weighted prompts must be set and contain at least one entry.");const t=u7(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){e.musicGenerationConfig||(e.musicGenerationConfig={});const t=c7(e);this.conn.send(JSON.stringify(t))}sendPlaybackControl(e){const t={playbackControl:e};this.conn.send(JSON.stringify(t))}play(){this.sendPlaybackControl(vu.PLAY)}pause(){this.sendPlaybackControl(vu.PAUSE)}stop(){this.sendPlaybackControl(vu.STOP)}resetContext(){this.sendPlaybackControl(vu.RESET_CONTEXT)}
4348close(){this.conn.close()}}function Kz(n){const e={};return n.forEach((t,r)=>{e[r]=t}),e}function Yz(n){const e=new Headers;for(const[t,r]of Object.entries(n))e.append(t,r);return e}/**
4349 * @license
4350 * Copyright 2025 Google LLC
4351 * SPDX-License-Identifier: Apache-2.0
4352 */const Qz="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function Wz(n,e,t){const r=new $H;let s;t.data instanceof Blob?s=await t.data.text():t.data instanceof ArrayBuffer?s=new TextDecoder().decode(t.data):s=t.data;const a=JSON.parse(s);if(n.isVertexAI()){const c=f7(a);Object.assign(r,c)}else Object.assign(r,a);e(r)}class Xz{constructor(e,t,r){this.apiClient=e,this.auth=t,this.webSocketFactory=r,this.music=new Jz(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){var t,r,s,a,c,u;if(e.config&&e.config.httpOptions)throw new Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");const h=this.apiClient.getWebsocketBaseUrl(),f=this.apiClient.getApiVersion();let p;const y=this.apiClient.getHeaders();e.config&&e.config.tools&&sI(e.config.tools)&&iI(y);const b=nJ(y);if(this.apiClient.isVertexAI()){const _=this.apiClient.getProject(),M=this.apiClient.getLocation(),j=this.apiClient.getApiKey(),H=!!_&&!!M||!!j;this.apiClient.getCustomBaseUrl()&&!H?p=h:(p=`${h}/ws/google.cloud.aiplatform.${f}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(b,p))}else{const _=this.apiClient.getApiKey();let M="BidiGenerateContent",j="key";_!=null&&_.startsWith("auth_tokens/")&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),f!=="v1alpha"&&console.warn("Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection."),M="BidiGenerateContentConstrained",j="access_token"),p=`${h}/ws/google.ai.generativelanguage.${f}.GenerativeService.${M}?${j}=${_}`}let w=()=>{};const E=new Promise(_=>{w=_}),N=e.callbacks,S=function(){var _;(_=N==null?void 0:N.onopen)===null||_===void 0||_.call(N),w({})},I=this.apiClient,O={onopen:S,onmessage:_=>{Wz(I,N.onmessage,_)},onerror:(t=N==null?void 0:N.onerror)!==null&&t!==void 0?t:function(_){},onclose:(r=N==null?void 0:N.onclose)!==null&&r!==void 0?r:function(_){}},F=this.webSocketFactory.create(p,tJ(b),O);F.connect(),await E;let J=$t(this.apiClient,e.model);if(this.apiClient.isVertexAI()&&J.startsWith("publishers/")){const _=this.apiClient.getProject(),M=this.apiClient.getLocation();_&&M&&(J=`projects/${_}/locations/${M}/`+J)}let z={};this.apiClient.isVertexAI()&&((s=e.config)===null||s===void 0?void 0:s.responseModalities)===void 0&&(e.config===void 0?e.config={responseModalities:[jg.AUDIO]}:e.config.responseModalities=[jg.AUDIO]),!((a=e.config)===null||a===void 0)&&a.generationConfig&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");const U=(u=(c=e.config)===null||c===void 0?void 0:c.tools)!==null&&u!==void 0?u:[],D=[];for(const _ of U)if(this.isCallableTool(_)){const M=_;D.push(await M.tool())}else D.push(_);D.length>0&&(e.config.tools=D);const k={model:J,config:e.config,callbacks:e.callbacks};return this.apiClient.isVertexAI()?z=l7(this.apiClient,k):z=o7(this.apiClient,k),delete z.config,F.send(JSON.stringify(z)),new eJ(F,this.apiClient)}isCallableTool(e){return"callTool"in e&&typeof e.callTool=="function"}}const Zz={turnComplete:!0};class eJ{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(t.turns!==null&&t.turns!==void 0){let r=[];try{r=ks(t.turns),e.isVertexAI()||(r=r.map(s=>nf(s)))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof t.turns}'`)}return{clientContent:{turns:r,turnComplete:t.turnComplete}}}return{clientContent:{turnComplete:t.turnComplete}}}tLiveClienttToolResponse(e,t){let r=[];if(t.functionResponses==null)throw new Error("functionResponses is required.");
4352if(Array.isArray(t.functionResponses)?r=t.functionResponses:r=[t.functionResponses],r.length===0)throw new Error("functionResponses is required.");for(const a of r){if(typeof a!="object"||a===null||!("name"in a)||!("response"in a))throw new Error(`Could not parse function response, type '${typeof a}'.`);if(!e.isVertexAI()&&!("id"in a))throw new Error(Qz)}return{toolResponse:{functionResponses:r}}}sendClientContent(e){e=Object.assign(Object.assign({},Zz),e);const t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};this.apiClient.isVertexAI()?t={realtimeInput:h7(e)}:t={realtimeInput:d7(e)},this.conn.send(JSON.stringify(t))}sendToolResponse(e){if(e.functionResponses==null)throw new Error("Tool response parameters are required.");const t=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(t))}close(){this.conn.close()}}function tJ(n){const e={};return n.forEach((t,r)=>{e[r]=t}),e}function nJ(n){const e=new Headers;for(const[t,r]of Object.entries(n))e.append(t,r);return e}/**
4353 * @license
4354 * Copyright 2025 Google LLC
4355 * SPDX-License-Identifier: Apache-2.0
4356 */const EN=10;function _N(n){var e,t,r;if(!((e=n==null?void 0:n.automaticFunctionCalling)===null||e===void 0)&&e.disable)return!0;let s=!1;for(const c of(t=n==null?void 0:n.tools)!==null&&t!==void 0?t:[])if(Su(c)){s=!0;break}if(!s)return!0;const a=(r=n==null?void 0:n.automaticFunctionCalling)===null||r===void 0?void 0:r.maximumRemoteCalls;return a&&(a<0||!Number.isInteger(a))||a==0?(console.warn("Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:",a),!0):!1}function Su(n){return"callTool"in n&&typeof n.callTool=="function"}function rJ(n){var e,t,r;return(r=(t=(e=n.config)===null||e===void 0?void 0:e.tools)===null||t===void 0?void 0:t.some(s=>Su(s)))!==null&&r!==void 0?r:!1}function TN(n){var e;const t=[];return!((e=n==null?void 0:n.config)===null||e===void 0)&&e.tools&&n.config.tools.forEach((r,s)=>{if(Su(r))return;const a=r;a.functionDeclarations&&a.functionDeclarations.length>0&&t.push(s)}),t}function kN(n){var e;return!(!((e=n==null?void 0:n.automaticFunctionCalling)===null||e===void 0)&&e.ignoreCallHistory)}/**
4357 * @license
4358 * Copyright 2025 Google LLC
4359 * SPDX-License-Identifier: Apache-2.0
4360 */class sJ extends Xa{constructor(e){super(),this.apiClient=e,this.embedContent=async t=>{if(!this.apiClient.isVertexAI())return t.model.includes("gemini-embedding-2")&&(t.contents=ks(t.contents)),await this.embedContentInternal(t);if(t.model.includes("gemini")&&t.model!=="gemini-embedding-001"||t.model.includes("maas")){const s=ks(t.contents);if(s.length>1)throw new Error("The embedContent API for this model only supports one content at a time.");const a=Object.assign(Object.assign({},t),{content:s[0],embeddingApiType:Og.EMBED_CONTENT});return await this.embedContentInternal(a)}else{const s=Object.assign(Object.assign({},t),{embeddingApiType:Og.PREDICT});return await this.embedContentInternal(s)}},this.generateContent=async t=>{var r,s,a,c,u;const h=await this.processParamsMaybeAddMcpUsage(t);if(this.maybeMoveToResponseJsonSchem(t),!rJ(t)||_N(t.config))return await this.generateContentInternal(h);const f=TN(t);if(f.length>0){const N=f.map(S=>`tools[${S}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${N}.`)}let p,y;const b=ks(h.contents),w=(a=(s=(r=h.config)===null||r===void 0?void 0:r.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls)!==null&&a!==void 0?a:EN;let E=0;for(;E<w&&(p=await this.generateContentInternal(h),!(!p.functionCalls||p.functionCalls.length===0));){const N=p.candidates[0].content,S=[];for(const I of(u=(c=t.config)===null||c===void 0?void 0:c.tools)!==null&&u!==void 0?u:[])if(Su(I)){const F=await I.callTool(p.functionCalls);S.push(...F)}E++,y={role:"user",parts:S},h.contents=ks(h.contents),h.contents.push(N),h.contents.push(y),kN(h.config)&&(b.push(N),b.push(y))}return kN(h.config)&&(p.automaticFunctionCallingHistory=b),p},this.generateContentStream=async t=>{var r,s,a,c,u;if(this.maybeMoveToResponseJsonSchem(t),_N(t.config)){const y=await this.processParamsMaybeAddMcpUsage(t);return await this.generateContentStreamInternal(y)}const h=TN(t);if(h.length>0){const y=h.map(b=>`tools[${b}]`).join(", ");throw new Error(`Incompatible tools found at ${y}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const f=(a=(s=(r=t==null?void 0:t.config)===null||r===void 0?void 0:r.toolConfig)===null||s===void 0?void 0:s.functionCallingConfig)===null||a===void 0?void 0:a.streamFunctionCallArguments,p=(u=(c=t==null?void 0:t.config)===null||c===void 0?void 0:c.automaticFunctionCalling)===null||u===void 0?void 0:u.disable;if(f&&!p)throw new Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.");return await this.processAfcStream(t)},this.generateImages=async t=>await this.generateImagesInternal(t).then(r=>{var s;let a;const c=[];if(r!=null&&r.generatedImages)for(const h of r.generatedImages)h&&(h!=null&&h.safetyAttributes)&&((s=h==null?void 0:h.safetyAttributes)===null||s===void 0?void 0:s.contentType)==="Positive Prompt"?a=h==null?void 0:h.safetyAttributes:c.push(h);let u;return a?u={generatedImages:c,positivePromptSafetyAttributes:a,sdkHttpResponse:r.sdk
4360HttpResponse}:u={generatedImages:c,sdkHttpResponse:r.sdkHttpResponse},u}),this.list=async t=>{var r;const c={config:Object.assign(Object.assign({},{queryBase:!0}),t==null?void 0:t.config)};if(this.apiClient.isVertexAI()&&!c.config.queryBase){if(!((r=c.config)===null||r===void 0)&&r.filter)throw new Error("Filtering tuned models list for Gemini Enterprise Agent Platform (previously known as Vertex AI) is not currently supported");c.config.filter="labels.tune-type:*"}return new kc($a.PAGED_ITEM_MODELS,u=>this.listInternal(u),await this.listInternal(c),c)},this.editImage=async t=>{const r={model:t.model,prompt:t.prompt,referenceImages:[],config:t.config};return t.referenceImages&&t.referenceImages&&(r.referenceImages=t.referenceImages.map(s=>s.toReferenceImageAPI())),await this.editImageInternal(r)},this.upscaleImage=async t=>{let r={numberOfImages:1,mode:"upscale"};t.config&&(r=Object.assign(Object.assign({},r),t.config));const s={model:t.model,image:t.image,upscaleFactor:t.upscaleFactor,config:r};return await this.upscaleImageInternal(s)},this.generateVideos=async t=>{var r,s,a,c,u,h;if((t.prompt||t.image||t.video)&&t.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||(!((r=t.video)===null||r===void 0)&&r.uri&&(!((s=t.video)===null||s===void 0)&&s.videoBytes)?t.video={uri:t.video.uri,mimeType:t.video.mimeType}:!((c=(a=t.source)===null||a===void 0?void 0:a.video)===null||c===void 0)&&c.uri&&(!((h=(u=t.source)===null||u===void 0?void 0:u.video)===null||h===void 0)&&h.videoBytes)&&(t.source.video={uri:t.source.video.uri,mimeType:t.source.video.mimeType})),await this.generateVideosInternal(t)}}maybeMoveToResponseJsonSchem(e){e.config&&e.config.responseSchema&&(e.config.responseJsonSchema||Object.keys(e.config.responseSchema).includes("$schema")&&(e.config.responseJsonSchema=e.config.responseSchema,delete e.config.responseSchema))}async processParamsMaybeAddMcpUsage(e){var t,r,s;const a=(t=e.config)===null||t===void 0?void 0:t.tools;if(!a)return e;const c=await Promise.all(a.map(async h=>Su(h)?await h.tool():h)),u={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:c})};if(u.config.tools=c,e.config&&e.config.tools&&sI(e.config.tools)){const h=(s=(r=e.config.httpOptions)===null||r===void 0?void 0:r.headers)!==null&&s!==void 0?s:{};let f=Object.assign({},h);Object.keys(f).length===0&&(f=this.apiClient.getDefaultHeaders()),iI(f),u.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:f})}return u}async initAfcToolsMap(e){var t,r,s;const a=new Map;for(const c of(r=(t=e.config)===null||t===void 0?void 0:t.tools)!==null&&r!==void 0?r:[])if(Su(c)){const u=c,h=await u.tool();for(const f of(s=h.functionDeclarations)!==null&&s!==void 0?s:[]){if(!f.name)throw new Error("Function declaration name is required.");if(a.has(f.name))throw new Error(`Duplicate tool declaration name: ${f.name}`);a.set(f.name,u)}}return a}async processAfcStream(e){var t,r,s;const a=(s=(r=(t=e.config)===null||t===void 0?void 0:t.automaticFunctionCalling)===null||r===void 0?void 0:r.maximumRemoteCalls)!==null&&s!==void 0?s:EN;let c=!1,u=0;const h=await this.initAfcToolsMap(e);return(function(f,p,y){return Ai(this,arguments,function*(){for(var b,w,E,N,S,I;u<a;){c&&(u++,c=!1);const z=yield yt(f.processParamsMaybeAddMcpUsage(y)),U=yield yt(f.generateContentStreamInternal(z)),D=[],k=[];try{for(var O=!0,F=(w=void 0,Ii(U)),J;J=yield yt(F.next()),b=J.done,!b;O=!0){N=J.value,O=!1;const _=N;if(yield yield yt(_),_.candidates&&(!((S=_.candidates[0])===null||S===void 0)&&S.content)){k.push(_.candidates[0].content);for(const M of(I=_.candidates[0].content.parts)!==null&&I!==void 0?I:[])if(u<a&&M.functionCall){if(!M.functionCall.name)throw new Error("Function call name was not returned by the model.");if(p.has(M.functionCall.name)){const j=yield yt(p.get(M.functionCall.name).callTool([M.functionCall]));D.push(...j)}else throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${p.keys()}, mising tool: ${M.functionCall.name}`)}}}}catch(_){w={error:_}}finally{try{!O&&!b&&(E=F.return)&&(yield yt(E.call(F)))}finally{if(w)throw w.error}}if(D.length>0){c=!0;const _=new zd;_.candidates=[{content:{role:"user",parts:D}}],yield yield yt(_);const M=[];M.push(...k),M.push({role:"user",parts:D});const j=ks(y.contents).concat(M);y.contents=j}else break}})})(this,h,e)}async generateContentInternal(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=CN(this.apiClient,e);return u=Ve("{model}:generateContent",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=vN(p),b=new zd;return Object.assign(b,y),b})}else{const f=xN(this.apiClient,e);return u=Ve("{model}:generateContent",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=bN(p),b=new zd;return Object.assign(b,y),b})}}async generateContentStreamInternal(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=CN(this.apiClient,e);return u=Ve("{model}:streamGenerateContent?alt=sse",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.requestStream({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}),c.then(function(y){return Ai(this,arguments,function*(){var b,w,E,N;try{for(var S=!0,I=Ii(y),O;O=yield yt(I.next()),b=O.done,!b;S=!0){N=O.value,S=!1;const F=N,J=vN(yield yt(F.json()),e);J.sdkHttpResponse={headers:F.headers};const z=new zd;Object.assign(z,J),yield yield yt(z)}}catch(F){w={error:F}}finally{try{!S&&!b&&(E=I.return)&&(yield yt(E.call(I)))}finally{if(w)throw w.error}}})})}else{const f=xN(this.apiClient,e);return u=Ve("{model}:streamGenerateContent?alt=sse",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.requestStream({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}),c.then(function(y){return Ai(this,arguments,function*(){var b,w,E,N;try{for(var S=!0,I=Ii(y),O;O=yield yt(I.next()),b=O.done,!b;S=!0){N=O.value,S=!1;const F=N,J=bN(yield yt(F.json()),e);J.sdkHttpResponse={headers:F.headers};const z=new zd;Object.assign(z,J),yield yield yt(z)}}catch(F){w={error:F}}finally{try{!S&&!b&&(E=I.return)&&(yield yt(E.call(I)))}finally{if(w)throw w.error}}})})}}async embedContentInternal(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=$7(this.apiClient,e,e),p=s8(e.model)?"{model}:embedContent":"{model}:predict";return u=Ve(p,f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(y=>y.json().then(b=>{const w=b;return w.sdkHttpResponse={headers:y.headers},w})),c.then(y=>{const b=Y7(y,e),w=new tN;return Object.assign(w,b),w})}else{const f=J7(this.apiClient,e);return u=Ve("{model}:batchEmbedContents",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=K7(p),b=new tN;return Object.assign(b,y),b})}}async generateImagesInternal(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=aq(this.apiClient,e);return u=Ve("{model}:predict",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=lq(p),b=new nN;return Object.assign(b,y),b})}else{const f=iq(this.apiClient,e);return u=Ve("{model}:predict",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=oq(p),b=new nN;return Object.assign(b,y),b})}}async editImageInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI()){const u=G7(this.apiClient,e);return a=Ve("{model}:predict",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(f=>{const p=f;return p.sdkHttpResponse={headers:h.headers},p})),s.then(h=>{const f=H7(h),p=new PH;return Object.assign(p,f),p})}else throw new Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async upscaleImageInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI()){const u=lz(this.apiClient,e);return a=Ve("{model}:predict",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(f=>{const p=f;return p.sdkHttpResponse={headers:h.headers},p})),s.then(h=>{const f=cz(h),p=new MH;return Object.assign(p,f),p})}else throw new Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async recontextImage(e){var t,r;let s,a="",c={};
4360if(this.apiClient.isVertexAI()){const u=Gq(this.apiClient,e);return a=Ve("{model}:predict",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>{const f=Hq(h),p=new LH;return Object.assign(p,f),p})}else throw new Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async segmentImage(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI()){const u=Yq(this.apiClient,e);return a=Ve("{model}:predict",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>{const f=Qq(h),p=new jH;return Object.assign(p,f),p})}else throw new Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async get(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=_q(this.apiClient,e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json()),c.then(p=>Wy(p))}else{const f=Eq(this.apiClient,e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json()),c.then(p=>Qy(p))}}async listInternal(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=Pq(this.apiClient,e);return u=Ve("{models_url}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=Lq(p),b=new rN;return Object.assign(b,y),b})}else{const f=Rq(this.apiClient,e);return u=Ve("{models_url}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=Mq(p),b=new rN;return Object.assign(b,y),b})}}async update(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=az(this.apiClient,e);return u=Ve("{model}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"PATCH",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json()),c.then(p=>Wy(p))}else{const f=iz(this.apiClient,e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"PATCH",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json()),c.then(p=>Qy(p))}}async delete(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=O7(this.apiClient,e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=U7(p),b=new sN;return Object.assign(b,y),b})}else{const f=j7(this.apiClient,e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=F7(p),b=new sN;return Object.assign(b,y),b})}}async countTokens(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=P7(this.apiClient,e);return u=Ve("{model}:countTokens",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=L7(p),b=new iN;return Object.assign(b,y),b})}else{const f=R7(this.apiClient,e);return u=Ve("{model}:countTokens",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=M7(p),b=new iN;return Object.assign(b,y),b})}}async computeTokens(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI()){const u=T7(this.apiClient,e);return a=Ve("{model}:computeTokens",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(f=>{const p=f;return p.sdkHttpResponse={headers:h.headers},p})),s.then(h=>
4360{const f=k7(h),p=new OH;return Object.assign(p,f),p})}else throw new Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async generateVideosInternal(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=mq(this.apiClient,e);return u=Ve("{model}:predictLongRunning",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json()),c.then(p=>{const y=hq(p),b=new Ug;return Object.assign(b,y),b})}else{const f=fq(this.apiClient,e);return u=Ve("{model}:predictLongRunning",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json()),c.then(p=>{const y=dq(p),b=new Ug;return Object.assign(b,y),b})}}}/**
4361 * @license
4362 * Copyright 2025 Google LLC
4363 * SPDX-License-Identifier: Apache-2.0
4364 */class iJ extends Xa{constructor(e){super(),this.apiClient=e}async getVideosOperation(e){const t=e.operation,r=e.config;if(t.name===void 0||t.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const s=t.name.split("/operations/")[0];let a;r&&"httpOptions"in r&&(a=r.httpOptions);const c=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:s,config:{httpOptions:a}});return t._fromAPIResponse({apiResponse:c,_isVertexAI:!0})}else{const s=await this.getVideosOperationInternal({operationName:t.name,config:r});return t._fromAPIResponse({apiResponse:s,_isVertexAI:!1})}}async get(e){const t=e.operation,r=e.config;if(t.name===void 0||t.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const s=t.name.split("/operations/")[0];let a;r&&"httpOptions"in r&&(a=r.httpOptions);const c=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:s,config:{httpOptions:a}});return t._fromAPIResponse({apiResponse:c,_isVertexAI:!0})}else{const s=await this.getVideosOperationInternal({operationName:t.name,config:r});return t._fromAPIResponse({apiResponse:s,_isVertexAI:!1})}}async getVideosOperationInternal(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=NH(e);return u=Ve("{operationName}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json()),c}else{const f=kH(e);return u=Ve("{operationName}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json()),c}}async fetchPredictVideosOperationInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI()){const u=CH(e);return a=Ve("{resourceName}:fetchPredictOperation",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s}else throw new Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}}/**
4365 * @license
4366 * Copyright 2025 Google LLC
4367 * SPDX-License-Identifier: Apache-2.0
4368 */function NN(n){const e={};if(g(n,["languageCodes"])!==void 0)throw new Error("languageCodes parameter is not supported in Gemini API.");return e}function aJ(n){const e={},t=g(n,["apiKey"]);if(t!=null&&B(e,["apiKey"],t),g(n,["apiKeyConfig"])!==void 0)throw new Error("apiKeyConfig parameter is not supported in Gemini API.");if(g(n,["authType"])!==void 0)throw new Error("authType parameter is not supported in Gemini API.");if(g(n,["googleServiceAccountConfig"])!==void 0)throw new Error("googleServiceAccountConfig parameter is not supported in Gemini API.");if(g(n,["httpBasicAuthConfig"])!==void 0)throw new Error("httpBasicAuthConfig parameter is not supported in Gemini API.");if(g(n,["oauthConfig"])!==void 0)throw new Error("oauthConfig parameter is not supported in Gemini API.");if(g(n,["oidcConfig"])!==void 0)throw new Error("oidcConfig parameter is not supported in Gemini API.");return e}function oJ(n){const e={},t=g(n,["data"]);if(t!=null&&B(e,["data"],t),g(n,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=g(n,["mimeType"]);return r!=null&&B(e,["mimeType"],r),e}function lJ(n){const e={},t=g(n,["parts"]);if(t!=null){let s=t;Array.isArray(s)&&(s=s.map(a=>BJ(a))),B(e,["parts"],s)}const r=g(n,["role"]);return r!=null&&B(e,["role"],r),e}function cJ(n,e,t){const r={},s=g(e,["expireTime"]);t!==void 0&&s!=null&&B(t,["expireTime"],s);
4368const a=g(e,["newSessionExpireTime"]);t!==void 0&&a!=null&&B(t,["newSessionExpireTime"],a);const c=g(e,["uses"]);t!==void 0&&c!=null&&B(t,["uses"],c);const u=g(e,["liveConnectConstraints"]);t!==void 0&&u!=null&&B(t,["bidiGenerateContentSetup"],pJ(n,u));const h=g(e,["lockAdditionalFields"]);return t!==void 0&&h!=null&&B(t,["fieldMask"],h),r}function uJ(n,e){const t={},r=g(e,["config"]);return r!=null&&B(t,["config"],cJ(n,r,t)),t}function dJ(n){const e={};if(g(n,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const t=g(n,["fileUri"]);t!=null&&B(e,["fileUri"],t);const r=g(n,["mimeType"]);return r!=null&&B(e,["mimeType"],r),e}function hJ(n){const e={},t=g(n,["id"]);t!=null&&B(e,["id"],t);const r=g(n,["args"]);r!=null&&B(e,["args"],r);const s=g(n,["name"]);if(s!=null&&B(e,["name"],s),g(n,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(g(n,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function fJ(n){const e={},t=g(n,["authConfig"]);t!=null&&B(e,["authConfig"],aJ(t));const r=g(n,["enableWidget"]);return r!=null&&B(e,["enableWidget"],r),e}function mJ(n){const e={},t=g(n,["searchTypes"]);if(t!=null&&B(e,["searchTypes"],t),g(n,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");if(g(n,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");const r=g(n,["timeRangeFilter"]);return r!=null&&B(e,["timeRangeFilter"],r),e}function gJ(n,e){const t={},r=g(n,["generationConfig"]);e!==void 0&&r!=null&&B(e,["setup","generationConfig"],r);const s=g(n,["responseModalities"]);e!==void 0&&s!=null&&B(e,["setup","generationConfig","responseModalities"],s);const a=g(n,["temperature"]);e!==void 0&&a!=null&&B(e,["setup","generationConfig","temperature"],a);const c=g(n,["topP"]);e!==void 0&&c!=null&&B(e,["setup","generationConfig","topP"],c);const u=g(n,["topK"]);e!==void 0&&u!=null&&B(e,["setup","generationConfig","topK"],u);const h=g(n,["maxOutputTokens"]);e!==void 0&&h!=null&&B(e,["setup","generationConfig","maxOutputTokens"],h);const f=g(n,["mediaResolution"]);e!==void 0&&f!=null&&B(e,["setup","generationConfig","mediaResolution"],f);const p=g(n,["seed"]);e!==void 0&&p!=null&&B(e,["setup","generationConfig","seed"],p);const y=g(n,["speechConfig"]);e!==void 0&&y!=null&&B(e,["setup","generationConfig","speechConfig"],LC(y));const b=g(n,["thinkingConfig"]);e!==void 0&&b!=null&&B(e,["setup","generationConfig","thinkingConfig"],b);const w=g(n,["enableAffectiveDialog"]);e!==void 0&&w!=null&&B(e,["setup","generationConfig","enableAffectiveDialog"],w);const E=g(n,["systemInstruction"]);e!==void 0&&E!=null&&B(e,["setup","systemInstruction"],lJ(Pr(E)));const N=g(n,["tools"]);if(e!==void 0&&N!=null){let k=Ku(N);Array.isArray(k)&&(k=k.map(_=>CJ($u(_)))),B(e,["setup","tools"],k)}const S=g(n,["sessionResumption"]);e!==void 0&&S!=null&&B(e,["setup","sessionResumption"],xJ(S));const I=g(n,["inputAudioTranscription"]);e!==void 0&&I!=null&&B(e,["setup","inputAudioTranscription"],NN(I));const O=g(n,["outputAudioTranscription"]);e!==void 0&&O!=null&&B(e,["setup","outputAudioTranscription"],NN(O));const F=g(n,["realtimeInputConfig"]);e!==void 0&&F!=null&&B(e,["setup","realtimeInputConfig"],F);const J=g(n,["contextWindowCompression"]);e!==void 0&&J!=null&&B(e,["setup","contextWindowCompression"],J);const z=g(n,["proactivity"]);if(e!==void 0&&z!=null&&B(e,["setup","proactivity"],z),g(n,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");const U=g(n,["avatarConfig"]);e!==void 0&&U!=null&&B(e,["setup","avatarConfig"],U);const D=g(n,["safetySettings"]);if(e!==void 0&&D!=null){let k=D;Array.isArray(k)&&(k=k.map(_=>yJ(_))),B(e,["setup","safetySettings"],k)}return t}function pJ(n,e){const t={},r=g(e,["model"]);r!=null&&B(t,["setup","model"],$t(n,r));const s=g(e,["config"]);return s!=null&&B(t,["config"],gJ(s,t)),t}function BJ(n){const e={},t=g(n,["mediaResolution"]);t!=null&&B(e,["mediaResolution"],t);const r=g(n,["codeExecutionResult"]);r!=null&&B(e,["codeExecutionResult"],r);const s=g(n,["executableCode"]);s!=null&&B(e,["executableCode"],s);const a=g(n,["fileData"]);a!=null&&B(e,["fileData"],dJ(a));const c=g(n,["functionCall"]);c!=null&&B(e,["functionCall"],hJ(c));const u=g(n,["functionResponse"]);u!=null&&B(e,["functionResponse"],u);const h=g(n,["inlineData"]);h!=null&&B(e,["inlineData"],oJ(h));const f=g(n,["text"]);f!=null&&B(e,["text"],f);const p=g(n,["thought"]);p!=null&&B(e,["thought"],p);const y=g(n,["thoughtSignature"]);y!=null&&B(e,["thoughtSignature"],y);const b=g(n,["videoMetadata"]);b!=null&&B(e,["videoMetadata"],b);const w=g(n,["toolCall"]);w!=null&&B(e,["toolCall"],w);const E=g(n,["toolResponse"]);E!=null&&B(e,["toolResponse"],E);const N=g(n,["partMetadata"]);return N!=null&&B(e,["partMetadata"],N),e}function yJ(n){const e={},t=g(n,["category"]);if(t!=null&&B(e,["category"],t),g(n,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const r=g(n,["threshold"]);return r!=null&&B(e,["threshold"],r),e}function xJ(n){const e={},t=g(n,["handle"]);if(t!=null&&B(e,["handle"],t),g(n,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return e}function CJ(n){const e={};
4368if(g(n,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const t=g(n,["computerUse"]);t!=null&&B(e,["computerUse"],t);const r=g(n,["fileSearch"]);r!=null&&B(e,["fileSearch"],r);const s=g(n,["googleSearch"]);s!=null&&B(e,["googleSearch"],mJ(s));const a=g(n,["googleMaps"]);a!=null&&B(e,["googleMaps"],fJ(a));const c=g(n,["codeExecution"]);if(c!=null&&B(e,["codeExecution"],c),g(n,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=g(n,["functionDeclarations"]);if(u!=null){let y=u;Array.isArray(y)&&(y=y.map(b=>b)),B(e,["functionDeclarations"],y)}const h=g(n,["googleSearchRetrieval"]);if(h!=null&&B(e,["googleSearchRetrieval"],h),g(n,["parallelAiSearch"])!==void 0)throw new Error("parallelAiSearch parameter is not supported in Gemini API.");const f=g(n,["urlContext"]);f!=null&&B(e,["urlContext"],f);const p=g(n,["mcpServers"]);if(p!=null){let y=p;Array.isArray(y)&&(y=y.map(b=>b)),B(e,["mcpServers"],y)}return e}/**
4369 * @license
4370 * Copyright 2025 Google LLC
4371 * SPDX-License-Identifier: Apache-2.0
4372 */function bJ(n){const e=[];for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){const r=n[t];if(typeof r=="object"&&r!=null&&Object.keys(r).length>0){const s=Object.keys(r).map(a=>`${t}.${a}`);e.push(...s)}else e.push(t)}return e.join(",")}function vJ(n,e){let t=null;const r=n.bidiGenerateContentSetup;if(typeof r=="object"&&r!==null&&"setup"in r){const a=r.setup;typeof a=="object"&&a!==null?(n.bidiGenerateContentSetup=a,t=a):delete n.bidiGenerateContentSetup}else r!==void 0&&delete n.bidiGenerateContentSetup;const s=n.fieldMask;if(t){const a=bJ(t);if(Array.isArray(e==null?void 0:e.lockAdditionalFields)&&(e==null?void 0:e.lockAdditionalFields.length)===0)a?n.fieldMask=a:delete n.fieldMask;else if(e!=null&&e.lockAdditionalFields&&e.lockAdditionalFields.length>0&&s!==null&&Array.isArray(s)&&s.length>0){const c=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let u=[];s.length>0&&(u=s.map(f=>c.includes(f)?`generationConfig.${f}`:f));const h=[];a&&h.push(a),u.length>0&&h.push(...u),h.length>0?n.fieldMask=h.join(","):delete n.fieldMask}else delete n.fieldMask}else s!==null&&Array.isArray(s)&&s.length>0?n.fieldMask=s.join(","):delete n.fieldMask;return n}class wJ extends Xa{constructor(e){super(),this.apiClient=e}async create(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const u=uJ(this.apiClient,e);a=Ve("auth_tokens",u._url),c=u._query,delete u.config,delete u._url,delete u._query;const h=vJ(u,e.config);return s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(f=>f.json()),s.then(f=>f)}}}/**
4373 * @license
4374 * Copyright 2025 Google LLC
4375 * SPDX-License-Identifier: Apache-2.0
4376 */function EJ(n,e){const t={},r=g(n,["force"]);return e!==void 0&&r!=null&&B(e,["_query","force"],r),t}function _J(n){const e={},t=g(n,["name"]);t!=null&&B(e,["_url","name"],t);const r=g(n,["config"]);return r!=null&&EJ(r,e),e}function TJ(n){const e={},t=g(n,["name"]);return t!=null&&B(e,["_url","name"],t),e}function kJ(n,e){const t={},r=g(n,["pageSize"]);e!==void 0&&r!=null&&B(e,["_query","pageSize"],r);const s=g(n,["pageToken"]);return e!==void 0&&s!=null&&B(e,["_query","pageToken"],s),t}function NJ(n){const e={},t=g(n,["parent"]);t!=null&&B(e,["_url","parent"],t);const r=g(n,["config"]);return r!=null&&kJ(r,e),e}function SJ(n){const e={},t=g(n,["sdkHttpResponse"]);t!=null&&B(e,["sdkHttpResponse"],t);const r=g(n,["nextPageToken"]);r!=null&&B(e,["nextPageToken"],r);const s=g(n,["documents"]);if(s!=null){let a=s;Array.isArray(a)&&(a=a.map(c=>c)),B(e,["documents"],a)}return e}/**
4377 * @license
4378 * Copyright 2025 Google LLC
4379 * SPDX-License-Identifier: Apache-2.0
4380 */class DJ extends Xa{constructor(e){super(),this.apiClient=e,this.list=async t=>
4380new kc($a.PAGED_ITEM_DOCUMENTS,r=>this.listInternal({parent:t.parent,config:r.config}),await this.listInternal(t),t)}async get(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=TJ(e);return a=Ve("{name}",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>h)}}async delete(e){var t,r;let s="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const c=_J(e);s=Ve("{name}",c._url),a=c._query,delete c._url,delete c._query,await this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal})}}async listInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=NJ(e);return a=Ve("{parent}/documents",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>{const f=SJ(h),p=new UH;return Object.assign(p,f),p})}}}/**
4381 * @license
4382 * Copyright 2025 Google LLC
4383 * SPDX-License-Identifier: Apache-2.0
4384 */class AJ extends Xa{constructor(e,t=new DJ(e)){super(),this.apiClient=e,this.documents=t,this.list=async(r={})=>new kc($a.PAGED_ITEM_FILE_SEARCH_STORES,s=>this.listInternal(s),await this.listInternal(r),r)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI())throw new Error("Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async downloadMedia(e,t){if(this.apiClient.isVertexAI())throw new Error("This method is only supported in the Gemini Developer client.");const r=new URL(e,"http://dummy.com");let s=r.pathname;if(s.startsWith("/")&&(s=s.slice(1)),!s.includes("/media/"))throw new Error(`Invalid uri format: ${e}. Expected to contain /media/`);const a={};r.searchParams.forEach((h,f)=>{a[f]=h}),a.alt="media";const c=Object.assign({},t==null?void 0:t.httpOptions),u=await this.apiClient.request({path:s,httpMethod:"GET",queryParams:a,httpOptions:c});if(u instanceof Fg){const h=await u.responseInternal.arrayBuffer();return new Uint8Array(h)}else throw new Error("Unexpected response type from downloadMedia")}async create(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=pz(this.apiClient,e);return a=Ve("fileSearchStores",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>h)}}async get(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=xz(e);return a=Ve("{name}",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>h)}}async delete(e){var t,r;let s="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const c=yz(e);s=Ve("{name}",c._url),a=c._query,delete c._url,delete c._query,await this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal})}}async listInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=_z(e);return a=Ve("fileSearchStores",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>{const f=Tz(h),p=new VH;return Object.assign(p,f),p})}}async uploadToFileSearchStoreInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=kz(e);return a=Ve("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>{const f=Nz(h),p=new GH;return Object.assign(p,f),p})}}async importFile(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=vz(e);return a=Ve("{file_search_store_name}:importFile",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),s.then(h=>{const f=bz(h),p=new AC;return Object.assign(p,f),p})}}}/**
4385 * @license
4386 * Copyright 2025 Google LLC
4387 * SPDX-License-Identifier: Apache-2.0
4388 */let aI=function(){const{crypto:n}=globalThis;if(n!=null&&n.randomUUID)return aI=n.randomUUID.bind(n),n.randomUUID();const e=new Uint8Array(1),t=n?()=>n.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^t()&15>>+r/4).toString(16))};const IJ=()=>aI();/**
4389 * @license
4390 * Copyright 2025 Google LLC
4391 * SPDX-License-Identifier: Apache-2.0
4392 */function Zy(n){return typeof n=="object"&&n!==null&&("name"in n&&n.name==="AbortError"||"message"in n&&String(n.message).includes("FetchRequestCanceledException"))}const ex=n=>{if(n instanceof Error)return n;if(typeof n=="object"&&n!==null){try{if(Object.prototype.toString.call(n)==="[object Error]"){const e=new Error(n.message,n.cause?{cause:n.cause}:{});return n.stack&&(e.stack=n.stack),n.cause&&!e.cause&&(e.cause=n.cause),n.name&&(e.name=n.name),e}}catch{}try{return new Error(JSON.stringify(n))}catch{}}return new Error(n)};/**
4393 * @license
4394 * Copyright 2025 Google LLC
4395 * SPDX-License-Identifier: Apache-2.0
4396 */class Bi extends Error{}class gs extends Bi{constructor(e,t,r,s){super(`${gs.makeMessage(e,t,r)}`),this.status=e,this.headers=s,this.error=t}static makeMessage(e,t,r){const s=t!=null&&t.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):r;return e&&s?`${e} ${s}`:e?`${e} status code (no body)`:s||"(no status code or body)"}static generate(e,t,r,s){if(!e||!s)return new Np({message:r,cause:ex(t)});const a=t;return e===400?new lI(e,a,r,s):e===401?new cI(e,a,r,s):e===403?new uI(e,a,r,s):e===404?new dI(e,a,r,s):e===409?new hI(e,a,r,s):e===422?new fI(e,a,r,s):e===429?new mI(e,a,r,s):e>=500?new gI(e,a,r,s):new gs(e,a,r,s)}}class tx extends gs{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class Np extends gs{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class oI extends Np{constructor({message:e}={}){super({message:e??"Request timed out."})}}class lI extends gs{}class cI extends gs{}class uI extends gs{}class dI extends gs{}class hI extends gs{}class fI extends gs{}class mI extends gs{}class gI extends gs{}/**
4397 * @license
4398 * Copyright 2025 Google LLC
4399 * SPDX-License-Identifier: Apache-2.0
4400 */const RJ=/^[a-z][a-z0-9+.-]*:/i,PJ=n=>RJ.test(n);let nx=n=>(nx=Array.isArray,nx(n));const MJ=nx;let LJ=MJ;const SN=LJ;function DN(n){if(!n)return!0;for(const e in n)return!1;return!0}function jJ(n,e){return Object.prototype.hasOwnProperty.call(n,e)}const OJ=(n,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new Bi(`${n} must be an integer`);if(e<0)throw new Bi(`${n} must be a positive integer`);return e},FJ=n=>{try{return JSON.parse(n)}catch{return}};/**
4401 * @license
4402 * Copyright 2025 Google LLC
4403 * SPDX-License-Identifier: Apache-2.0
4404 */const UJ=n=>new Promise(e=>setTimeout(e,n));/**
4405 * @license
4406 * Copyright 2025 Google LLC
4407 * SPDX-License-Identifier: Apache-2.0
4408 */function VJ(){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 pI(...n){const e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...n)}function GJ(n){let e=Symbol.asyncIterator in n?n[Symbol.asyncIterator]():n[Symbol.iterator]();return pI({start(){},async pull(t){const{done:r,value:s}=await e.next();r?t.close():t.enqueue(s)},async cancel(){var t;await((t=e.return)===null||t===void 0?void 0:t.call(e))}})}function BI(n){if(n[Symbol.asyncIterator])return n;const e=n.getReader();return{async next(){try{const t=await e.read();return t!=null&&t.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){const t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function HJ(n){var e,t;if(n===null||typeof n!="object")return;if(n[Symbol.asyncIterator]){await((t=(e=n[Symbol.asyncIterator]()).return)===null||t===void 0?void 0:t.call(e));return}const r=n.getReader(),s=r.cancel();r.releaseLock(),await s}/**
4409 * @license
4410 * Copyright 2025 Google LLC
4411 * SPDX-License-Identifier: Apache-2.0
4412 */const qJ=({headers:n,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});/**
4413 * @license
4414 * Copyright 2025 Google LLC
4415 * SPDX-License-Identifier: Apache-2.0
4416 */function zJ(n){return Object.entries(n).filter(([e,t])=>typeof t<"u").map(([e,t])=>{if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new Bi(`Cannot stringify type ${typeof t}; 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("&")}/**
4417 * @license
4418 * Copyright 2025 Google LLC
4419 * SPDX-License-Identifier: Apache-2.0
4420 */const JJ="0.0.1";/**
4421 * @license
4422 * Copyright 2025 Google LLC
4423 * SPDX-License-Identifier: Apache-2.0
4424 */const yI=()=>{var n;if(typeof File>"u"){const{process:e}=globalThis,t=typeof((n=e==null?void 0:e.versions)===null||n===void 0?void 0:n.node)=="string"&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function cy(n,e,t){return yI(),new File(n,e??"unknown_file",t)}function $J(n){return(typeof n=="object"&&n!==null&&("name"in n&&n.name&&String(n.name)||"url"in n&&n.url&&String(n.url)||"filename"in n&&n.filename&&String(n.filename)||"path"in n&&n.path&&String(n.path))||"").split(/[\\/]/).pop()||void 0}const KJ=n=>n!=null&&typeof n=="object"&&typeof n[Symbol.asyncIterator]=="function";/**
4425 * @license
4426 * Copyright 2025 Google LLC
4427 * SPDX-License-Identifier: Apache-2.0
4428 */const xI=n=>n!=null&&typeof n=="object"&&typeof n.size=="number"&&typeof n.type=="string"&&typeof n.text=="function"&&typeof n.slice=="function"&&typeof n.arrayBuffer=="function",YJ=n=>n!=null&&typeof n=="object"&&typeof n.name=="string"&&typeof n.lastModified=="number"&&xI(n),QJ=n=>n!=null&&typeof n=="object"&&typeof n.url=="string"&&typeof n.blob=="function";async function WJ(n,e,t){if(yI(),n=await n,YJ(n))return n instanceof File?n:cy([await n.arrayBuffer()],n.name);if(QJ(n)){const s=await n.blob();return e||(e=new URL(n.url).pathname.split(/[\\/]/).pop()),cy(await rx(s),e,t)}const r=await rx(n);if(e||(e=$J(n)),!(t!=null&&t.type)){const s=r.find(a=>typeof a=="object"&&"type"in a&&a.type);typeof s=="string"&&(t=Object.assign(Object.assign({},t),{type:s}))}return cy(r,e,t)}async function rx(n){var e,t,r,s,a;let c=[];if(typeof n=="string"||ArrayBuffer.isView(n)||n instanceof ArrayBuffer)c.push(n);else if(xI(n))c.push(n instanceof Blob?n:await n.arrayBuffer());else if(KJ(n))try{for(var u=!0,h=Ii(n),f;
4428f=await h.next(),e=f.done,!e;u=!0){s=f.value,u=!1;const p=s;c.push(...await rx(p))}}catch(p){t={error:p}}finally{try{!u&&!e&&(r=h.return)&&await r.call(h)}finally{if(t)throw t.error}}else{const p=(a=n==null?void 0:n.constructor)===null||a===void 0?void 0:a.name;throw new Error(`Unexpected data type: ${typeof n}${p?`; constructor: ${p}`:""}${XJ(n)}`)}return c}function XJ(n){return typeof n!="object"||n===null?"":`; props: [${Object.getOwnPropertyNames(n).map(t=>`"${t}"`).join(", ")}]`}/**
4429 * @license
4430 * Copyright 2025 Google LLC
4431 * SPDX-License-Identifier: Apache-2.0
4432 */class OC{constructor(e){this._client=e}}OC._key=[];/**
4433 * @license
4434 * Copyright 2025 Google LLC
4435 * SPDX-License-Identifier: Apache-2.0
4436 */function CI(n){return n.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const AN=Object.freeze(Object.create(null)),ZJ=(n=CI)=>(function(t,...r){if(t.length===1)return t[0];let s=!1;const a=[],c=t.reduce((p,y,b)=>{var w,E,N;/[?#]/.test(y)&&(s=!0);const S=r[b];let I=(s?encodeURIComponent:n)(""+S);return b!==r.length&&(S==null||typeof S=="object"&&S.toString===((N=Object.getPrototypeOf((E=Object.getPrototypeOf((w=S.hasOwnProperty)!==null&&w!==void 0?w:AN))!==null&&E!==void 0?E:AN))===null||N===void 0?void 0:N.toString))&&(I=S+"",a.push({start:p.length+y.length,length:I.length,error:`Value of type ${Object.prototype.toString.call(S).slice(8,-1)} is not a valid path parameter`})),p+y+(b===r.length?"":I)},""),u=c.split(/[?#]/,1)[0],h=/(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let f;for(;(f=h.exec(u))!==null;){const p=f[0].startsWith("/"),y=p?1:0,b=p?f[0].slice(1):f[0];a.push({start:f.index+y,length:b.length,error:`Value "${b}" can't be safely passed as a path parameter`})}if(a.sort((p,y)=>p.start-y.start),a.length>0){let p=0;const y=a.reduce((b,w)=>{const E=" ".repeat(w.start-p),N="^".repeat(w.length);return p=w.start+w.length,b+E+N},"");throw new Bi(`Path parameters result in path with invalid segments:
4437${a.map(b=>b.error).join(`
4438`)}
4439${c}
4440${y}`)}return c}),ki=ZJ(CI);/**
4441 * @license
4442 * Copyright 2025 Google LLC
4443 * SPDX-License-Identifier: Apache-2.0
4444 */class bI extends OC{create(e,t){var r;const{api_version:s=this._client.apiVersion}=e,a=zo(e,["api_version"]);if("model"in a&&"agent_config"in a)throw new Bi("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if("agent"in a&&"generation_config"in a)throw new Bi("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(ki`/${s}/interactions`,Object.assign(Object.assign({body:a},t),{stream:(r=e.stream)!==null&&r!==void 0?r:!1}))}delete(e,t={},r){const{api_version:s=this._client.apiVersion}=t??{};return this._client.delete(ki`/${s}/interactions/${e}`,r)}cancel(e,t={},r){const{api_version:s=this._client.apiVersion}=t??{};return this._client.post(ki`/${s}/interactions/${e}/cancel`,r)}get(e,t={},r){var s;const a=t??{},{api_version:c=this._client.apiVersion}=a,u=zo(a,["api_version"]);return this._client.get(ki`/${c}/interactions/${e}`,Object.assign(Object.assign({query:u},r),{stream:(s=t==null?void 0:t.stream)!==null&&s!==void 0?s:!1}))}}bI._key=Object.freeze(["interactions"]);class vI extends bI{}/**
4445 * @license
4446 * Copyright 2025 Google LLC
4447 * SPDX-License-Identifier: Apache-2.0
4448 */class wI extends OC{create(e,t){const{api_version:r=this._client.apiVersion}=e,s=zo(e,["api_version"]);return this._client.post(ki`/${r}/webhooks`,Object.assign({body:s},t))}update(e,t={},r){const s=t??{},{api_version:a=this._client.apiVersion,update_mask:c}=s,u=zo(s,["api_version","update_mask"]);return this._client.patch(ki`/${a}/webhooks/${e}`,Object.assign({query:{update_mask:c},body:u},r))}list(e={},t){const r=e??{},{api_version:s=this._client.apiVersion}=r,a=zo(r,["api_version"]);return this._client.get(ki`/${s}/webhooks`,Object.assign({query:a},t))}delete(e,t={},r){const{api_version:s=this._client.apiVersion}=t??{};return this._client.delete(ki`/${s}/webhooks/${e}`,r)}get(e,t={},r){const{api_version:s=this._client.apiVersion}=t??{};return this._client.get(ki`/${s}/webhooks/${e}`,r)}ping(e,t=void 0,r){const{api_version:s=this._client.apiVersion,body:a}=t??{};return this._client.post(ki`/${s}/webhooks/${e}:ping`,Object.assign({body:a},r))}rotateSigningSecret(e,t={},r){const s=t??{},{api_version:a=this._client.apiVersion}=s,c=zo(s,["api_version"]);return this._client.post(ki`/${a}/webhooks/${e}:rotateSigningSecret`,Object.assign({body:c},r))}}wI._key=Object.freeze(["webhooks"]);class EI extends wI{}/**
4449 * @license
4450 * Copyright 2025 Google LLC
4451 * SPDX-License-Identifier: Apache-2.0
4452 */function e$(n){let e=0;for(const s of n)e+=s.length;const t=new Uint8Array(e);let r=0;for(const s of n)t.set(s,r),r+=s.length;return t}let Om;function FC(n){let e;return(Om??(e=new globalThis.TextEncoder,Om=e.encode.bind(e)))(n)}let Fm;function IN(n){let e;return(Fm??(e=new globalThis.TextDecoder,Fm=e.decode.bind(e)))(n)}/**
4453 * @license
4454 * Copyright 2025 Google LLC
4455 * SPDX-License-Identifier: Apache-2.0
4456 */class Sp{constructor(){this.buffer=new Uint8Array,this.carriageReturnIndex=null,this.searchIndex=0}decode(e){var t;if(e==null)return[];const r=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?FC(e):e;this.buffer=e$([this.buffer,r]);const s=[];let a;for(;(a=t$(this.buffer,(t=this.carriageReturnIndex)!==null&&t!==void 0?t: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)){s.push(IN(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null,this.searchIndex=0;continue}const c=this.carriageReturnIndex!==null?a.preceding-1:a.preceding,u=IN(this.buffer.subarray(0,c));s.push(u),this.buffer=this.buffer.subarray(a.index),this.carriageReturnIndex=null,this.searchIndex=0}return this.searchIndex=Math.max(0,this.buffer.length-1),s}flush(){return this.buffer.length?this.decode(`
4457`):[]}}Sp.NEWLINE_CHARS=new Set([`
4458`,"\r"]);Sp.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function t$(n,e){const s=e??0,a=n.indexOf(10,s),c=n.indexOf(13,s);if(a===-1&&c===-1)return null;let u;
4458return a!==-1&&c!==-1?u=Math.min(a,c):u=a!==-1?a:c,n[u]===10?{preceding:u,index:u+1,carriage:!1}:{preceding:u,index:u+1,carriage:!0}}/**
4459 * @license
4460 * Copyright 2025 Google LLC
4461 * SPDX-License-Identifier: Apache-2.0
4462 */const Gg={off:0,error:200,warn:300,info:400,debug:500},RN=(n,e,t)=>{if(n){if(jJ(Gg,n))return n;ds(t).warn(`${e} was set to ${JSON.stringify(n)}, expected one of ${JSON.stringify(Object.keys(Gg))}`)}};function th(){}function Um(n,e,t){return!e||Gg[n]>Gg[t]?th:e[n].bind(e)}const n$={error:th,warn:th,info:th,debug:th};let PN=new WeakMap;function ds(n){var e;const t=n.logger,r=(e=n.logLevel)!==null&&e!==void 0?e:"off";if(!t)return n$;const s=PN.get(t);if(s&&s[0]===r)return s[1];const a={error:Um("error",t,r),warn:Um("warn",t,r),info:Um("info",t,r),debug:Um("debug",t,r)};return PN.set(t,[r,a]),a}const Xl=n=>(n.options&&(n.options=Object.assign({},n.options),delete n.options.headers),n.headers&&(n.headers=Object.fromEntries((n.headers instanceof Headers?[...n.headers]:Object.entries(n.headers)).map(([e,t])=>[e,e.toLowerCase()==="x-goog-api-key"||e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":t]))),"retryOfRequestLogID"in n&&(n.retryOfRequestLogID&&(n.retryOf=n.retryOfRequestLogID),delete n.retryOfRequestLogID),n);/**
4463 * @license
4464 * Copyright 2025 Google LLC
4465 * SPDX-License-Identifier: Apache-2.0
4466 */class wu{constructor(e,t,r){this.iterator=e,this.controller=t,this.client=r}static fromSSEResponse(e,t,r){let s=!1;const a=r?ds(r):console;function c(){return Ai(this,arguments,function*(){var h,f,p,y;if(s)throw new Bi("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let b=!1;try{try{for(var w=!0,E=Ii(r$(e,t)),N;N=yield yt(E.next()),h=N.done,!h;w=!0){y=N.value,w=!1;const S=y;if(!b)if(S.data.startsWith("[DONE]")){b=!0;continue}else try{yield yield yt(JSON.parse(S.data))}catch(I){throw a.error("Could not parse message into JSON:",S.data),a.error("From chunk:",S.raw),I}}}catch(S){f={error:S}}finally{try{!w&&!h&&(p=E.return)&&(yield yt(p.call(E)))}finally{if(f)throw f.error}}b=!0}catch(S){if(Zy(S))return yield yt(void 0);throw S}finally{b||t.abort()}})}return new wu(c,t,r)}static fromReadableStream(e,t,r){let s=!1;function a(){return Ai(this,arguments,function*(){var h,f,p,y;const b=new Sp,w=BI(e);try{for(var E=!0,N=Ii(w),S;S=yield yt(N.next()),h=S.done,!h;E=!0){y=S.value,E=!1;const I=y;for(const O of b.decode(I))yield yield yt(O)}}catch(I){f={error:I}}finally{try{!E&&!h&&(p=N.return)&&(yield yt(p.call(N)))}finally{if(f)throw f.error}}for(const I of b.flush())yield yield yt(I)})}function c(){return Ai(this,arguments,function*(){var h,f,p,y;if(s)throw new Bi("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let b=!1;try{try{for(var w=!0,E=Ii(a()),N;N=yield yt(E.next()),h=N.done,!h;w=!0){y=N.value,w=!1;const S=y;b||S&&(yield yield yt(JSON.parse(S)))}}catch(S){f={error:S}}finally{try{!w&&!h&&(p=E.return)&&(yield yt(p.call(E)))}finally{if(f)throw f.error}}b=!0}catch(S){if(Zy(S))return yield yt(void 0);throw S}finally{b||t.abort()}})}return new wu(c,t,r)}[Symbol.asyncIterator](){return this.iterator()}tee(){const e=[],t=[],r=this.iterator(),s=a=>({next:()=>{if(a.length===0){const c=r.next();e.push(c),t.push(c)}return a.shift()}});return[new wu(()=>s(e),this.controller,this.client),new wu(()=>s(t),this.controller,this.client)]}toReadableStream(){const e=this;let t;return pI({async start(){t=e[Symbol.asyncIterator]()},async pull(r){try{const{value:s,done:a}=await t.next();if(a)return r.close();const c=FC(JSON.stringify(s)+`
4467`);r.enqueue(c)}catch(s){r.error(s)}},async cancel(){var r;await((r=t.return)===null||r===void 0?void 0:r.call(t))}})}}function r$(n,e){return Ai(this,arguments,function*(){var r,s,a,c;if(!n.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new Bi("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 Bi("Attempted to iterate over a response with no body");const u=new i$,h=new Sp,f=BI(n.body);try{for(var p=!0,y=Ii(s$(f)),b;b=yield yt(y.next()),r=b.done,!r;p=!0){c=b.value,p=!1;const w=c;for(const E of h.decode(w)){const N=u.decode(E);
4467N&&(yield yield yt(N))}}}catch(w){s={error:w}}finally{try{!p&&!r&&(a=y.return)&&(yield yt(a.call(y)))}finally{if(s)throw s.error}}for(const w of h.flush()){const E=u.decode(w);E&&(yield yield yt(E))}})}function s$(n){return Ai(this,arguments,function*(){var t,r,s,a;try{for(var c=!0,u=Ii(n),h;h=yield yt(u.next()),t=h.done,!t;c=!0){a=h.value,c=!1;const f=a;if(f==null)continue;const p=f instanceof ArrayBuffer?new Uint8Array(f):typeof f=="string"?FC(f):f;yield yield yt(p)}}catch(f){r={error:f}}finally{try{!c&&!t&&(s=u.return)&&(yield yt(s.call(u)))}finally{if(r)throw r.error}}})}class i${constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const a={event:this.event,data:this.data.join(`
4468`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],a}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,r,s]=a$(e,":");return s.startsWith(" ")&&(s=s.substring(1)),t==="event"?this.event=s:t==="data"&&this.data.push(s),null}}function a$(n,e){const t=n.indexOf(e);return t!==-1?[n.substring(0,t),e,n.substring(t+e.length)]:[n,"",""]}/**
4469 * @license
4470 * Copyright 2025 Google LLC
4471 * SPDX-License-Identifier: Apache-2.0
4472 */async function o$(n,e){const{response:t,requestLogID:r,retryOfRequestLogID:s,startTime:a}=e,c=await(async()=>{var u;if(e.options.stream)return ds(n).debug("response",t.status,t.url,t.headers,t.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(t,e.controller,n):wu.fromSSEResponse(t,e.controller,n);if(t.status===204)return null;if(e.options.__binaryResponse)return t;const h=t.headers.get("content-type"),f=(u=h==null?void 0:h.split(";")[0])===null||u===void 0?void 0:u.trim();return(f==null?void 0:f.includes("application/json"))||(f==null?void 0:f.endsWith("+json"))?t.headers.get("content-length")==="0"?void 0:await t.json():await t.text()})();return ds(n).debug(`[${r}] response parsed`,Xl({retryOfRequestLogID:s,url:t.url,status:t.status,body:c,durationMs:Date.now()-a})),c}/**
4473 * @license
4474 * Copyright 2025 Google LLC
4475 * SPDX-License-Identifier: Apache-2.0
4476 */class UC extends Promise{constructor(e,t,r=o$){super(s=>{s(null)}),this.responsePromise=t,this.parseResponse=r,this.client=e}_thenUnwrap(e){return new UC(this.client,this.responsePromise,async(t,r)=>e(await this.parseResponse(t,r),r))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(this.client,e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}/**
4477 * @license
4478 * Copyright 2025 Google LLC
4479 * SPDX-License-Identifier: Apache-2.0
4480 */const _I=Symbol("brand.privateNullableHeaders");function*l$(n){if(!n)return;if(_I in n){const{values:r,nulls:s}=n;yield*r.entries();for(const a of s)yield[a,null];return}let e=!1,t;n instanceof Headers?t=n.entries():SN(n)?t=n:(e=!0,t=Object.entries(n??{}));for(let r of t){const s=r[0];if(typeof s!="string")throw new TypeError("expected header name to be a string");const a=SN(r[1])?r[1]:[r[1]];let c=!1;for(const u of a)u!==void 0&&(e&&!c&&(c=!0,yield[s,null]),yield[s,u])}}const Jd=n=>{const e=new Headers,t=new Set;for(const r of n){const s=new Set;for(const[a,c]of l$(r)){const u=a.toLowerCase();s.has(u)||(e.delete(a),s.add(u)),c===null?(e.delete(a),t.add(u)):(e.append(a,c),t.delete(u))}}return{[_I]:!0,values:e,nulls:t}};/**
4481 * @license
4482 * Copyright 2025 Google LLC
4483 * SPDX-License-Identifier: Apache-2.0
4484 */const uy=n=>{var e,t,r,s,a;if(typeof globalThis.process<"u")return((t=(e=mH)===null||e===void 0?void 0:e[n])===null||t===void 0?void 0:t.trim())||void 0;if(typeof globalThis.Deno<"u")return((a=(s=(r=globalThis.Deno.env)===null||r===void 0?void 0:r.get)===null||s===void 0?void 0:s.call(r,n))===null||a===void 0?void 0:a.trim())||void 0};/**
4485 * @license
4486 * Copyright 2025 Google LLC
4487 * SPDX-License-Identifier: Apache-2.0
4488 */var TI;class Dp{constructor(e){var t,r,s,a,c,u,h,{baseURL:f=uy("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:p=(t=uy("GEMINI_API_KEY"))!==null&&t!==void 0?t:null,apiVersion:y="v1beta"}=e,b=zo(e,["baseURL","apiKey","apiVersion"]);const w=Object.assign(Object.assign({apiKey:p,apiVersion:y},b),{baseURL:f||"https://generativelanguage.googleapis.com"});this.baseURL=w.baseURL,this.timeout=(r=w.timeout)!==null&&r!==void 0?r:Dp.DEFAULT_TIMEOUT,this.logger=(s=w.logger)!==null&&s!==void 0?s:console;const E="warn";this.logLevel=E,this.logLevel=(c=(a=RN(w.logLevel,"ClientOptions.logLevel",this))!==null&&a!==void 0?a:RN(uy("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&c!==void 0?c:E,this.fetchOptions=w.fetchOptions,this.maxRetries=(u=w.maxRetries)!==null&&u!==void 0?u:2,this.fetch=(h=w.fetch)!==null&&h!==void 0?h:VJ(),this.encoder=qJ,this._options=w,this.apiKey=p,this.apiVersion=y,this.clientAdapter=w.clientAdapter}withOptions(e){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}),e))}
4488baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.has("authorization")||e.has("x-goog-api-key"))&&!(this.apiKey&&e.get("x-goog-api-key"))&&!t.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(e){const t=Jd([e.headers]);if(!(t.values.has("authorization")||t.values.has("x-goog-api-key"))){if(this.apiKey)return Jd([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter&&this.clientAdapter.isVertexAI())return Jd([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(e){return zJ(e)}getUserAgent(){return`${this.constructor.name}/JS ${JJ}`}defaultIdempotencyKey(){return`stainless-node-retry-${IJ()}`}makeStatusError(e,t,r,s){return gs.generate(e,t,r,s)}buildURL(e,t,r){const s=!this.baseURLOverridden()&&r||this.baseURL,a=PJ(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),c=this.defaultQuery(),u=Object.fromEntries(a.searchParams);return(!DN(c)||!DN(u))&&(t=Object.assign(Object.assign(Object.assign({},u),c),t)),typeof t=="object"&&t&&!Array.isArray(t)&&(a.search=this.stringifyQuery(t)),a.toString()}async prepareOptions(e){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!e.path.startsWith(`/${this.apiVersion}/projects/`)){const t=e.path.slice(this.apiVersion.length+1);e.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${t}`}}async prepareRequest(e,{url:t,options:r}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,r){return this.request(Promise.resolve(r).then(s=>Object.assign({method:e,path:t},s)))}request(e,t=null){return new UC(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,r){var s,a,c;const u=await e,h=(s=u.maxRetries)!==null&&s!==void 0?s:this.maxRetries;t==null&&(t=h),await this.prepareOptions(u);const{req:f,url:p,timeout:y}=await this.buildRequest(u,{retryCount:h-t});await this.prepareRequest(f,{url:p,options:u});const b="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),w=r===void 0?"":`, retryOf: ${r}`,E=Date.now();if(ds(this).debug(`[${b}] sending request`,Xl({retryOfRequestLogID:r,method:u.method,url:p,options:u,headers:f.headers})),!((a=u.signal)===null||a===void 0)&&a.aborted)throw new tx;const N=new AbortController,S=await this.fetchWithTimeout(p,f,y,N).catch(ex),I=Date.now();if(S instanceof globalThis.Error){const F=`retrying, ${t} attempts remaining`;if(!((c=u.signal)===null||c===void 0)&&c.aborted)throw new tx;const J=Zy(S)||/timed? ?out/i.test(String(S)+("cause"in S?String(S.cause):""));if(t)return ds(this).info(`[${b}] connection ${J?"timed out":"failed"} - ${F}`),ds(this).debug(`[${b}] connection ${J?"timed out":"failed"} (${F})`,Xl({retryOfRequestLogID:r,url:p,durationMs:I-E,message:S.message})),this.retryRequest(u,t,r??b);throw ds(this).info(`[${b}] connection ${J?"timed out":"failed"} - error; no more retries left`),ds(this).debug(`[${b}] connection ${J?"timed out":"failed"} (error; no more retries left)`,Xl({retryOfRequestLogID:r,url:p,durationMs:I-E,message:S.message})),J?new oI:new Np({cause:S})}const O=`[${b}${w}] ${f.method} ${p} ${S.ok?"succeeded":"failed"} with status ${S.status} in ${I-E}ms`;if(!S.ok){const F=await this.shouldRetry(S);if(t&&F){const _=`retrying, ${t} attempts remaining`;return await HJ(S.body),ds(this).info(`${O} - ${_}`),ds(this).debug(`[${b}] response error (${_})`,Xl({retryOfRequestLogID:r,url:S.url,status:S.status,headers:S.headers,durationMs:I-E})),this.retryRequest(u,t,r??b,S.headers)}const J=F?"error; no more retries left":"error; not retryable";ds(this).info(`${O} - ${J}`);const z=await S.text().catch(_=>ex(_).message),U=FJ(z),D=U?void 0:z;throw ds(this).debug(`[${b}] response error (${J})`,Xl({retryOfRequestLogID:r,url:S.url,status:S.status,headers:S.headers,message:D,durationMs:Date.now()-E})),this.makeStatusError(S.status,U,D,S.headers)}return ds(this).info(O),ds(this).debug(`[${b}] response start`,Xl({retryOfRequestLogID:r,url:S.url,status:S.status,headers:S.headers,durationMs:I-E})),{response:S,options:u,controller:N,requestLogID:b,retryOfRequestLogID:r,startTime:E}}async fetchWithTimeout(e,t,r,s){const a=t||{},{signal:c,method:u}=a,h=zo(a,["signal","method"]),f=this._makeAbort(s);c&&c.addEventListener("abort",f,{once:!0});const p=setTimeout(f,r),y=globalThis.ReadableStream&&h.body instanceof globalThis.ReadableStream||typeof h.body=="object"&&h.body!==null&&Symbol.asyncIterator in h.body,b=Object.assign(Object.assign(Object.assign({signal:s.signal},y?{duplex:"half"}:{}),{method:"GET"}),h);u&&(b.method=u.toUpperCase());try{return await this.fetch.call(void 0,e,b)}finally{clearTimeout(p)}}async shouldRetry(e){const t=e.headers.get("x-should-retry");return t==="true"?!0:t==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,r,s){var a;let c;const u=s==null?void 0:s.get("retry-after-ms");if(u){const f=parseFloat(u);Number.isNaN(f)||(c=f)}const h=s==null?void 0:s.get("retry-after");if(h&&!c){const f=parseFloat(h);Number.isNaN(f)?c=Date.parse(h)-Date.now():c=f*1e3}if(c===void 0){const f=(a=e.maxRetries)!==null&&a!==void 0?a:this.maxRetries;c=this.calculateDefaultRetryTimeoutMillis(t,f)}
4488return await UJ(c),this.makeRequest(e,t-1,r)}calculateDefaultRetryTimeoutMillis(e,t){const a=t-e,c=Math.min(.5*Math.pow(2,a),8),u=1-Math.random()*.25;return c*u*1e3}async buildRequest(e,{retryCount:t=0}={}){var r,s,a;const c=Object.assign({},e),{method:u,path:h,query:f,defaultBaseURL:p}=c,y=this.buildURL(h,f,p);"timeout"in c&&OJ("timeout",c.timeout),c.timeout=(r=c.timeout)!==null&&r!==void 0?r:this.timeout;const{bodyHeaders:b,body:w}=this.buildBody({options:c}),E=await this.buildHeaders({options:e,method:u,bodyHeaders:b,retryCount:t});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:u,headers:E},c.signal&&{signal:c.signal}),globalThis.ReadableStream&&w instanceof globalThis.ReadableStream&&{duplex:"half"}),w&&{body:w}),(s=this.fetchOptions)!==null&&s!==void 0?s:{}),(a=c.fetchOptions)!==null&&a!==void 0?a:{}),url:y,timeout:c.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:r,retryCount:s}){let a={};this.idempotencyHeader&&t!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),a[this.idempotencyHeader]=e.idempotencyKey);const c=await this.authHeaders(e);let u=Jd([a,{Accept:"application/json","User-Agent":this.getUserAgent()},this._options.defaultHeaders,r,e.headers,c]);return this.validateHeaders(u),u.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}
4488){if(!e)return{bodyHeaders:void 0,body:void 0};const r=Jd([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&r.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:GJ(e)}:typeof e=="object"&&r.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:this.encoder({body:e,headers:r})}}Dp.DEFAULT_TIMEOUT=6e4;class _r extends Dp{constructor(){super(...arguments),this.interactions=new vI(this),this.webhooks=new EI(this)}}TI=_r;_r.GeminiNextGenAPIClient=TI;_r.GeminiNextGenAPIClientError=Bi;_r.APIError=gs;_r.APIConnectionError=Np;_r.APIConnectionTimeoutError=oI;_r.APIUserAbortError=tx;_r.NotFoundError=dI;_r.ConflictError=hI;_r.RateLimitError=mI;_r.BadRequestError=lI;_r.AuthenticationError=cI;_r.InternalServerError=gI;_r.PermissionDeniedError=uI;_r.UnprocessableEntityError=fI;_r.toFile=WJ;_r.Interactions=vI;_r.Webhooks=EI;/**
4489 * @license
4490 * Copyright 2025 Google LLC
4491 * SPDX-License-Identifier: Apache-2.0
4492 */function c$(n,e){const t={},r=g(n,["name"]);return r!=null&&B(t,["_url","name"],r),t}function u$(n,e){const t={},r=g(n,["name"]);return r!=null&&B(t,["_url","name"],r),t}function d$(n,e){const t={},r=g(n,["sdkHttpResponse"]);return r!=null&&B(t,["sdkHttpResponse"],r),t}function h$(n,e){const t={},r=g(n,["sdkHttpResponse"]);return r!=null&&B(t,["sdkHttpResponse"],r),t}function f$(n,e,t){const r={};if(g(n,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const s=g(n,["tunedModelDisplayName"]);if(e!==void 0&&s!=null&&B(e,["displayName"],s),g(n,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const a=g(n,["epochCount"]);e!==void 0&&a!=null&&B(e,["tuningTask","hyperparameters","epochCount"],a);const c=g(n,["learningRateMultiplier"]);if(c!=null&&B(r,["tuningTask","hyperparameters","learningRateMultiplier"],c),g(n,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(g(n,["preTunedModelCheckpointId"])!==void 0)throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(g(n,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");if(g(n,["tuningMode"])!==void 0)throw new Error("tuningMode parameter is not supported in Gemini API.");if(g(n,["customBaseModel"])!==void 0)throw new Error("customBaseModel parameter is not supported in Gemini API.");const u=g(n,["batchSize"]);e!==void 0&&u!=null&&B(e,["tuningTask","hyperparameters","batchSize"],u);const h=g(n,["learningRate"]);if(e!==void 0&&h!=null&&B(e,["tuningTask","hyperparameters","learningRate"],h),g(n,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");if(g(n,["beta"])!==void 0)throw new Error("beta parameter is not supported in Gemini API.");if(g(n,["baseTeacherModel"])!==void 0)throw new Error("baseTeacherModel parameter is not supported in Gemini API.");if(g(n,["tunedTeacherModelSource"])!==void 0)throw new Error("tunedTeacherModelSource parameter is not supported in Gemini API.");if(g(n,["sftLossWeightMultiplier"])!==void 0)throw new Error("sftLossWeightMultiplier parameter is not supported in Gemini API.");if(g(n,["outputUri"])!==void 0)throw new Error("outputUri parameter is not supported in Gemini API.");if(g(n,["encryptionSpec"])!==void 0)throw new Error("encryptionSpec parameter is not supported in Gemini API.");return r}function m$(n,e,t){const r={};let s=g(t,["config","method"]);if(s===void 0&&(s="SUPERVISED_FINE_TUNING"),s==="SUPERVISED_FINE_TUNING"){const U=g(n,["validationDataset"]);e!==void 0&&U!=null&&B(e,["supervisedTuningSpec"],dy(U))}else if(s==="PREFERENCE_TUNING"){const U=g(n,["validationDataset"]);e!==void 0&&U!=null&&B(e,["preferenceOptimizationSpec"],dy(U))}else if(s==="DISTILLATION"){const U=g(n,["validationDataset"]);e!==void 0&&U!=null&&B(e,["distillationSpec"],dy(U))}const a=g(n,["tunedModelDisplayName"]);e!==void 0&&a!=null&&B(e,["tunedModelDisplayName"],a);const c=g(n,["description"]);e!==void 0&&c!=null&&B(e,["description"],c);let u=g(t,["config","method"]);if(u===void 0&&(u="SUPERVISED_FINE_TUNING"),u==="SUPERVISED_FINE_TUNING"){const U=g(n,["epochCount"]);e!==void 0&&U!=null&&B(e,["supervisedTuningSpec","hyperParameters","epochCount"],U)}else if(u==="PREFERENCE_TUNING"){const U=g(n,["epochCount"]);e!==void 0&&U!=null&&B(e,["preferenceOptimizationSpec","hyperParameters","epochCount"],U)}else if(u==="DISTILLATION"){const U=g(n,["epochCount"]);e!==void 0&&U!=null&&B(e,["distillationSpec","hyperParameters","epochCount"],U)}let h=g(t,["config","method"]);if(h===void 0&&(h="SUPERVISED_FINE_TUNING"),h==="SUPERVISED_FINE_TUNING"){const U=g(n,["learningRateMultiplier"]);e!==void 0&&U!=null&&B(e,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],U)}else if(h==="PREFERENCE_TUNING"){const U=g(n,["learningRateMultiplier"]);e!==void 0&&U!=null&&B(e,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],U)}else if(h==="DISTILLATION"){const U=g(n,["learningRateMultiplier"]);e!==void 0&&U!=null&&B(e,["distillationSpec","hyperParameters","learningRateMultiplier"],U)}let f=g(t,["config","method"]);if(f===void 0&&(f="SUPERVISED_FINE_TUNING"),f==="SUPERVISED_FINE_TUNING"){const U=g(n,["exportLastCheckpointOnly"]);e!==void 0&&U!=null&&B(e,["supervisedTuningSpec","exportLastCheckpointOnly"],U)}else if(f==="PREFERENCE_TUNING"){const U=g(n,["exportLastCheckpointOnly"]);e!==void 0&&U!=null&&B(e,["preferenceOptimizationSpec","exportLastCheckpointOnly"],U)}else if(f==="DISTILLATION"){const U=g(n,["exportLastCheckpointOnly"]);e!==void 0&&U!=null&&B(e,["distillationSpec","exportLastCheckpointOnly"],U)}let p=g(t,["config","method"]);if(p===void 0&&(p="SUPERVISED_FINE_TUNING"),p==="SUPERVISED_FINE_TUNING"){const U=g(n,["adapterSize"]);e!==void 0&&U!=null&&B(e,["supervisedTuningSpec","hyperParameters","adapterSize"],U)}else if(p==="PREFERENCE_TUNING"){const U=g(n,["adapterSize"]);e!==void 0&&U!=null&&B(e,["preferenceOptimizationSpec","hyperParameters","adapterSize"],U)}else if(p==="DISTILLATION"){const U=g(n,["adapterSize"]);e!==void 0&&U!=null&&B(e,["distillationSpec","hyperParameters","adapterSize"],U)}let y=g(t,["config","method"]);if(y===void 0&&(y="SUPERVISED_FINE_TUNING"),y==="SUPERVISED_FINE_TUNING"){const U=g(n,["tuningMode"]);e!==void 0&&U!=null&&B(e,["supervisedTuningSpec","tuningMode"],U)}else if(y==="DISTILLATION"){const U=g(n,["tuningMode"]);e!==void 0&&U!=null&&B(e,["distillationSpec","tuningMode"],U)}const b=g(n,["customBaseModel"]);e!==void 0&&b!=null&&B(e,["customBaseModel"],b);let w=g(t,["config","method"]);if(w===void 0&&(w="SUPERVISED_FINE_TUNING"),w==="SUPERVISED_FINE_TUNING"){const U=g(n,["batchSize"]);e!==void 0&&U!=null&&B(e,["supervisedTuningSpec","hyperParameters","batchSize"],U)}else if(w==="DISTILLATION"){const U=g(n,["batchSize"]);e!==void 0&&U!=null&&B(e,["distillationSpec","hyperParameters","batchSize"],U)}let E=g(t,["config","method"]);if(E===void 0&&(E="SUPERVISED_FINE_TUNING"),E==="SUPERVISED_FINE_TUNING"){const U=g(n,["learningRate"]);e!==void 0&&U!=null&&B(e,["supervisedTuningSpec","hyperParameters","learningRate"],U)}else if(E==="DISTILLATION"){const U=g(n,["learningRate"]);e!==void 0&&U!=null&&B(e,["distillationSpec","hyperParameters","learningRate"],U)}const N=g(n,["labels"]);e!==void 0&&N!=null&&B(e,["labels"],N);const S=g(n,["beta"]);e!==void 0&&S!=null&&B(e,["preferenceOptimizationSpec","hyperParameters","beta"],S);const I=g(n,["baseTeacherModel"]);e!==void 0&&I!=null&&B(e,["distillationSpec","baseTeacherModel"],I);const O=g(n,["tunedTeacherModelSource"]);e!==void 0&&O!=null&&B(e,["distillationSpec","tunedTeacherModelSource"],O);const F=g(n,["sftLossWeightMultiplier"]);e!==void 0&&F!=null&&B(e,["distillationSpec","hyperParameters","sftLossWeightMultiplier"],F);const J=g(n,["outputUri"]);e!==void 0&&J!=null&&B(e,["outputUri"],J);const z=g(n,["encryptionSpec"]);return e!==void 0&&z!=null&&B(e,["encryptionSpec"],z),r}function g$(n,e){const t={},r=g(n,["baseModel"]);r!=null&&B(t,["baseModel"],r);const s=g(n,["preTunedModel"]);s!=null&&B(t,["preTunedModel"],s);const a=g(n,["trainingDataset"]);a!=null&&w$(a);const c=g(n,["config"]);return c!=null&&f$(c,t),t}function p$(n,e){const t={},r=g(n,["baseModel"]);r!=null&&B(t,["baseModel"],r);const s=g(n,["preTunedModel"]);s!=null&&B(t,["preTunedModel"],s);const a=g(n,["trainingDataset"]);a!=null&&E$(a,t,e);const c=g(n,["config"]);return c!=null&&m$(c,t,e),t}function B$(n,e){const t={},r=g(n,["name"]);return r!=null&&B(t,["_url","name"],r),t}function y$(n,e){const t={},r=g(n,["name"]);return r!=null&&B(t,["_url","name"],r),t}function x$(n,e,t){const r={},s=g(n,["pageSize"]);e!==void 0&&s!=null&&B(e,["_query","pageSize"],s);const a=g(n,["pageToken"]);e!==void 0&&a!=null&&B(e,["_query","pageToken"],a);const c=g(n,["filter"]);return e!==void 0&&c!=null&&B(e,["_query","filter"],c),r}function C$(n,e){const t={},r=g(n,["config"]);return r!=null&&x$(r,t),t}function b$(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["nextPageToken"]);s!=null&&B(t,["nextPageToken"],s);const a=g(n,["tuningJobs"]);if(a!=null){let c=a;Array.isArray(c)&&(c=c.map(u=>sx(u))),B(t,["tuningJobs"],c)}return t}function v$(n,e){const t={},r=g(n,["name"]);r!=null&&B(t,["model"],r);const s=g(n,["name"]);return s!=null&&B(t,["endpoint"],s),t}function w$(n,e){const t={};
4492if(g(n,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(g(n,["vertexDatasetResource"])!==void 0)throw new Error("vertexDatasetResource parameter is not supported in Gemini API.");const r=g(n,["examples"]);if(r!=null){let s=r;Array.isArray(s)&&(s=s.map(a=>a)),B(t,["examples","examples"],s)}return t}function E$(n,e,t){const r={};let s=g(t,["config","method"]);if(s===void 0&&(s="SUPERVISED_FINE_TUNING"),s==="SUPERVISED_FINE_TUNING"){const c=g(n,["gcsUri"]);e!==void 0&&c!=null&&B(e,["supervisedTuningSpec","trainingDatasetUri"],c)}else if(s==="PREFERENCE_TUNING"){const c=g(n,["gcsUri"]);e!==void 0&&c!=null&&B(e,["preferenceOptimizationSpec","trainingDatasetUri"],c)}else if(s==="DISTILLATION"){const c=g(n,["gcsUri"]);e!==void 0&&c!=null&&B(e,["distillationSpec","promptDatasetUri"],c)}let a=g(t,["config","method"]);if(a===void 0&&(a="SUPERVISED_FINE_TUNING"),a==="SUPERVISED_FINE_TUNING"){const c=g(n,["vertexDatasetResource"]);e!==void 0&&c!=null&&B(e,["supervisedTuningSpec","trainingDatasetUri"],c)}else if(a==="PREFERENCE_TUNING"){const c=g(n,["vertexDatasetResource"]);e!==void 0&&c!=null&&B(e,["preferenceOptimizationSpec","trainingDatasetUri"],c)}else if(a==="DISTILLATION"){const c=g(n,["vertexDatasetResource"]);e!==void 0&&c!=null&&B(e,["distillationSpec","promptDatasetUri"],c)}if(g(n,["examples"])!==void 0)throw new Error("examples parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return r}function _$(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["name"]);s!=null&&B(t,["name"],s);const a=g(n,["state"]);a!=null&&B(t,["state"],GA(a));const c=g(n,["createTime"]);c!=null&&B(t,["createTime"],c);const u=g(n,["tuningTask","startTime"]);u!=null&&B(t,["startTime"],u);const h=g(n,["tuningTask","completeTime"]);h!=null&&B(t,["endTime"],h);const f=g(n,["updateTime"]);f!=null&&B(t,["updateTime"],f);const p=g(n,["description"]);p!=null&&B(t,["description"],p);const y=g(n,["baseModel"]);y!=null&&B(t,["baseModel"],y);const b=g(n,["_self"]);return b!=null&&B(t,["tunedModel"],v$(b)),t}function sx(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["name"]);s!=null&&B(t,["name"],s);const a=g(n,["state"]);a!=null&&B(t,["state"],GA(a));const c=g(n,["createTime"]);c!=null&&B(t,["createTime"],c);const u=g(n,["startTime"]);u!=null&&B(t,["startTime"],u);const h=g(n,["endTime"]);h!=null&&B(t,["endTime"],h);const f=g(n,["updateTime"]);f!=null&&B(t,["updateTime"],f);const p=g(n,["error"]);p!=null&&B(t,["error"],p);const y=g(n,["description"]);y!=null&&B(t,["description"],y);const b=g(n,["baseModel"]);b!=null&&B(t,["baseModel"],b);const w=g(n,["tunedModel"]);w!=null&&B(t,["tunedModel"],w);const E=g(n,["preTunedModel"]);E!=null&&B(t,["preTunedModel"],E);const N=g(n,["supervisedTuningSpec"]);N!=null&&B(t,["supervisedTuningSpec"],N);const S=g(n,["preferenceOptimizationSpec"]);S!=null&&B(t,["preferenceOptimizationSpec"],S);const I=g(n,["distillationSpec"]);I!=null&&B(t,["distillationSpec"],I);const O=g(n,["tuningDataStats"]);O!=null&&B(t,["tuningDataStats"],O);const F=g(n,["encryptionSpec"]);F!=null&&B(t,["encryptionSpec"],F);const J=g(n,["partnerModelTuningSpec"]);J!=null&&B(t,["partnerModelTuningSpec"],J);const z=g(n,["customBaseModel"]);z!=null&&B(t,["customBaseModel"],z);const U=g(n,["evaluateDatasetRuns"]);if(U!=null){let X=U;Array.isArray(X)&&(X=X.map(ae=>ae)),B(t,["evaluateDatasetRuns"],X)}const D=g(n,["experiment"]);D!=null&&B(t,["experiment"],D);const k=g(n,["fullFineTuningSpec"]);k!=null&&B(t,["fullFineTuningSpec"],k);const _=g(n,["labels"]);_!=null&&B(t,["labels"],_);const M=g(n,["outputUri"]);M!=null&&B(t,["outputUri"],M);const j=g(n,["pipelineJob"]);j!=null&&B(t,["pipelineJob"],j);const H=g(n,["serviceAccount"]);H!=null&&B(t,["serviceAccount"],H);const L=g(n,["tunedModelDisplayName"]);L!=null&&B(t,["tunedModelDisplayName"],L);const ee=g(n,["tuningJobState"]);ee!=null&&B(t,["tuningJobState"],ee);const ne=g(n,["veoTuningSpec"]);ne!=null&&B(t,["veoTuningSpec"],ne);const G=g(n,["distillationSamplingSpec"]);G!=null&&B(t,["distillationSamplingSpec"],G);const W=g(n,["tuningJobMetadata"]);return W!=null&&B(t,["tuningJobMetadata"],W),t}function T$(n,e){const t={},r=g(n,["sdkHttpResponse"]);r!=null&&B(t,["sdkHttpResponse"],r);const s=g(n,["name"]);s!=null&&B(t,["name"],s);const a=g(n,["metadata"]);a!=null&&B(t,["metadata"],a);const c=g(n,["done"]);c!=null&&B(t,["done"],c);const u=g(n,["error"]);return u!=null&&B(t,["error"],u),t}function dy(n,e){const t={},r=g(n,["gcsUri"]);r!=null&&B(t,["validationDatasetUri"],r);const s=g(n,["vertexDatasetResource"]);return s!=null&&B(t,["validationDatasetUri"],s),t}/**
4493 * @license
4494 * Copyright 2025 Google LLC
4495 * SPDX-License-Identifier: Apache-2.0
4496 */class k$ extends Xa{constructor(e){super(),this.apiClient=e,this.list=async(t={})=>new kc($a.PAGED_ITEM_TUNING_JOBS,r=>this.listInternal(r),await this.listInternal(t),t),this.get=async t=>await this.getInternal(t),this.tune=async t=>{var r;if(this.apiClient.isVertexAI())if(t.baseModel.startsWith("projects/")){const s={tunedModelName:t.baseModel};!((r=t.config)===null||r===void 0)&&r.preTunedModelCheckpointId&&(s.checkpointId=t.config.preTunedModelCheckpointId);const a=Object.assign(Object.assign({},t),{preTunedModel:s});return a.baseModel=void 0,await this.tuneInternal(a)}else{const s=Object.assign({},t);return await this.tuneInternal(s)}else{const s=Object.assign({},t),a=await this.tuneMldevInternal(s);let c="";return a.metadata!==void 0&&a.metadata.tunedModel!==void 0?c=a.metadata.tunedModel:a.name!==void 0&&a.name.includes("/operations/")&&(c=a.name.split("/operations/")[0]),{name:c,state:Jy.JOB_STATE_QUEUED}}}}async getInternal(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=y$(e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>sx(p))}else{const f=B$(e);return u=Ve("{name}",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>_$(p))}}async listInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI()){const u=C$(e);return a=Ve("tuningJobs",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(f=>{const p=f;return p.sdkHttpResponse={headers:h.headers},p})),s.then(h=>{const f=b$(h),p=new FH;return Object.assign(p,f),p})}else throw new Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async cancel(e){var t,r,s,a;let c,u="",h={};if(this.apiClient.isVertexAI()){const f=u$(e);return u=Ve("{name}:cancel",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=h$(p),b=new aN;return Object.assign(b,y),b})}else{const f=c$(e);return u=Ve("{name}:cancel",f._url),h=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:h,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(a=e.config)===null||a===void 0?void 0:a.abortSignal}).then(p=>p.json().then(y=>{const b=y;return b.sdkHttpResponse={headers:p.headers},b})),c.then(p=>{const y=d$(p),b=new aN;return Object.assign(b,y),b})}}async tuneInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI()){const u=p$(e,e);return a=Ve("tuningJobs",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(f=>{const p=f;return p.sdkHttpResponse={headers:h.headers},p})),s.then(h=>sx(h))}else throw new Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async tuneMldevInternal(e){var t,r;let s,a="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=g$(e);return a=Ve("tunedModels",u._url),c=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(f=>{const p=f;return p.sdkHttpResponse={headers:h.headers},p})),s.then(h=>T$(h))}}}/**
4497 * @license
4498 * Copyright 2025 Google LLC
4499 * SPDX-License-Identifier: Apache-2.0
4500 */class N${async download(e,t){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an <a> tag.")}}const S$=1024*1024*8,D$=3,A$=1e3,I$=2,Hg="x-goog-upload-status";async function R$(n,e,t,r){var s;const a=await kI(n,e,t,r),c=await(a==null?void 0:a.json());if(((s=a==null?void 0:a.headers)===null||s===void 0?void 0:s[Hg])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return c.file}async function P$(n,e,t,r){var s;const a=await kI(n,e,t,r),c=await(a==null?void 0:a.json());if(((s=a==null?void 0:a.headers)===null||s===void 0?void 0:s[Hg])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");const u=LA(c),h=new IC;return Object.assign(h,u),h}async function kI(n,e,t,r){var s,a,c;let u=e;const h=(r==null?void 0:r.baseUrl)||((s=t.clientOptions.httpOptions)===null||s===void 0?void 0:s.baseUrl);if(h){const w=new URL(h),E=new URL(e);E.protocol=w.protocol,E.host=w.host,E.port=w.port,u=E.toString()}let f=0,p=0,y=new Fg(new Response),b="upload";for(f=n.size;p<f;){const w=Math.min(S$,f-p),E=n.slice(p,p+w);p+w>=f&&(b+=", finalize");let N=0,S=A$;for(;N<D$;){const I=Object.assign(Object.assign({},(r==null?void 0:r.headers)||{}),{"X-Goog-Upload-Command":b,"X-Goog-Upload-Offset":String(p),"Content-Length":String(w)});if(y=await t.request({path:"",body:E,httpMethod:"POST",httpOptions:Object.assign(Object.assign({},r),{apiVersion:"",baseUrl:u,headers:I})}),!((a=y==null?void 0:y.headers)===null||a===void 0)&&a[Hg])break;N++,await L$(S),S=S*I$}if(p+=w,((c=y==null?void 0:y.headers)===null||c===void 0?void 0:c[Hg])!=="active")break;if(f<=p)throw new Error("All content has been uploaded, but the upload status is not finalized.")}return y}async function M$(n){return{size:n.size,type:n.type}}function L$(n){return new Promise(e=>setTimeout(e,n))}class j${async upload(e,t,r,s){if(typeof e=="string")throw new Error("File path is not supported in browser uploader.");return await R$(e,t,r,s)}async uploadToFileSearchStore(e,t,r,s){if(typeof e=="string")throw new Error("File path is not supported in browser uploader.");return await P$(e,t,r,s)}async stat(e){if(typeof e=="string")throw new Error("File path is not supported in browser uploader.");return await M$(e)}}/**
4501 * @license
4502 * Copyright 2025 Google LLC
4503 * SPDX-License-Identifier: Apache-2.0
4504 */class O${create(e,t,r){return new F$(e,t,r)}}class F${constructor(e,t,r){this.url=e,this.headers=t,this.callbacks=r}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose
4504=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(e){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(e)}close(){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.close()}}/**
4505 * @license
4506 * Copyright 2025 Google LLC
4507 * SPDX-License-Identifier: Apache-2.0
4508 */const MN="x-goog-api-key";class U${constructor(e){this.apiKey=e}async addAuthHeaders(e,t){if(e.get(MN)===null){if(this.apiKey.startsWith("auth_tokens/"))throw new Error("Ephemeral tokens are only supported by the live API.");if(!this.apiKey)throw new Error("API key is missing. Please provide a valid API key.");e.append(MN,this.apiKey)}}}/**
4509 * @license
4510 * Copyright 2025 Google LLC
4511 * SPDX-License-Identifier: Apache-2.0
4512 */const V$="gl-node/";class hy{getNextGenClient(){var e;const t=this.httpOptions;if(this._nextGenClient===void 0){const r=this.httpOptions;this._nextGenClient=new _r({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:r==null?void 0:r.timeout,maxRetries:(e=r==null?void 0:r.retryOptions)===null||e===void 0?void 0:e.attempts})}return t!=null&&t.extraBody&&console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored."),this._nextGenClient}get interactions(){return this._interactions!==void 0?this._interactions:(console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions."),this._interactions=this.getNextGenClient().interactions,this._interactions)}get webhooks(){return this._webhooks!==void 0?this._webhooks:(this._webhooks=this.getNextGenClient().webhooks,this._webhooks)}constructor(e){var t;if(e.apiKey==null)throw new Error("An API Key must be set when running in a browser");if(e.project||e.location)throw new Error("Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.");this.vertexai=(t=e.vertexai)!==null&&t!==void 0?t:!1,this.apiKey=e.apiKey;const r=yH(e.httpOptions,e.vertexai,void 0,void 0);r&&(e.httpOptions?e.httpOptions.baseUrl=r:e.httpOptions={baseUrl:r}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;const s=new U$(this.apiKey);this.apiClient=new Fz({auth:s,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:V$+"web",uploader:new j$,downloader:new N$}),this.models=new sJ(this.apiClient),this.live=new Xz(this.apiClient,s,new O$),this.batches=new Z8(this.apiClient),this.chats=new j9(this.models,this.apiClient),this.caches=new P9(this.apiClient),this.files=new Y9(this.apiClient),this.operations=new iJ(this.apiClient),this.authTokens=new wJ(this.apiClient),this.tunings=new k$(this.apiClient),this.fileSearchStores=new AJ(this.apiClient)}}const G$=()=>{if(typeof window<"u"&&window.process&&window.process.env)return window.process.env.API_KEY},mu=G$(),NI={getItinerarySuggestions:async(n,e)=>{try{if(!mu)throw new Error("API Key not found");const s=(await new hy({apiKey:mu}).models.generateContent({model:"gemini-3-flash-preview",contents:`Generate a ${e}-day itinerary for a trip to ${n}, Uganda. For each day, provide a brief, engaging note (max 30 words) suggesting what to do. Focus on the key experiences.`,config:{responseMimeType:"application/json",responseSchema:{type:qs.OBJECT,properties:{itinerary:{type:qs.ARRAY,description:"The list of daily suggestions for the itinerary.",items:{type:qs.OBJECT,properties:{day:{type:qs.INTEGER,description:"The day number of the itinerary."},notes:{type:qs.STRING,description:"A brief, engaging note for the day's activities."}}}}}}}})).text||"{}";return JSON.parse(s).itinerary||[]}catch(t){return console.error("Error fetching AI itinerary suggestions:",t),Array.from({length:e},(r,s)=>({day:s+1,notes:`Plan your adventure at ${n}.`}))}},getAdminReportSummary:async(n,e,t)=>{try{if(!mu)return"API Key missing. Unable to generate summary.";const r=new hy({apiKey:mu});let s=`
4513        You are an expert data analyst for a safari tour platform. 
4514        Based on the following key metrics for the period "${t}", provide a concise, insightful summary (2-3 sentences) of the platform's performance. 
4515        Highlight the most important trend or takeaway for an administrator. The tone should be professional and informative.
4516
4517        Current Period Metrics:
4518        - Total Confirmed Bookings Value (GBV): $${n.totalBookings}
4519        - Total Platform Revenue: $${n.platformRevenue}
4520        - Itineraries in Planning: ${n.planningCount}
4521        - Confirmed Itineraries: ${n.confirmedCount}
4522        - Top Performing Consultant: ${n.topConsultantName}
4523        - Top Destination: ${n.topDestinationName}
4524      `;return e&&(s+=`
4525          
4526Previous Period Metrics:
4527          - Total Confirmed Bookings Value (GBV): $${e.totalBookings}
4528          - Total Platform Revenue: $${e.platformRevenue}
4529          - Itineraries in Planning: ${e.planningCount}
4530          - Confirmed Itineraries: ${e.confirmedCount}
4531
4532          Crucially, compare the current period to the previous period in your summary. Point out the most significant change (positive or negative) and offer a brief insight into what it might mean.
4533        `),s+=`
4534Generate the summary now.`,(await r.models.generateContent({model:"gemini-3-flash-preview",contents:s})).text||"Summary unavailable."}catch(r){return console.error("Error generating admin report summary:",r),"Reviewing metrics manually is recommended at this time."}},getConsultantReportSummary:async(n,e,t)=>{try{if(!mu)return"API Key missing. Unable to generate summary.";const r=new hy({apiKey:mu}),s=`
4535        You are an expert business coach for a safari tour consultant named ${n}. 
4536        Based on the following key metrics for the period "${t}", provide a concise, insightful, and encouraging summary (2-3 sentences) of their performance. 
4537        Highlight a key strength and suggest one area of focus. The tone should be professional, supportive, and data-driven.
4538
4539        Current Performance Metrics:
4540        - Trips in Planning: ${e.planningCount}
4541        - Trips Pending Confirmation: ${e.pendingCount}
4542        - Trips Confirmed/Completed: ${e.confirmedCount}
4543        - Total Estimated Earnings: $${e.totalEarnings.toFixed(2)}
4544        - Average Traveler Rating: ${e.avgRating.toFixed(2)} (from ${e.reviewCount} reviews)
4545
4546        Analyze these numbers and generate the summary now.
4547      `;return(await r.models.generateContent({model:"gemini-3-flash-preview",contents:s})).text||"Keep up the great work!"}catch(r){return console.error("Error generating consultant report summary:",r),"Your performance statistics are ready for review below!"}}},ph=({data:n,title:e})=>{const t=cc.useMemo(()=>n.length===0?0:Math.max(...n.map(s=>s.value)),[n]),r=cc.useMemo(()=>[...n].sort((s,a)=>a.value-s.value),[n]);return o.jsxs("div",{className:"bg-white dark:bg-gray-800 p-4 rounded-lg shadow-md border border-gray-200 dark:border-gray-700 h-full",children:[o.jsx("h4",{className:"text-sm font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-4",children:e}),o.jsx("div",{className:"space-y-3",children:r.length>0?r.map(s=>o.jsxs("div",{className:"grid grid-cols-3 gap-2 items-center text-xs",children:[o.jsx("span",{className:"truncate text-gray-600 dark:text-gray-300 col-span-1",children:s.label}),o.jsxs("div",{className:"col-span-2 flex items-center gap-2",children:[o.jsx("div",{className:"w-full bg-gray-200 dark:bg-gray-700 rounded-full h-4",children:o.jsx("div",{className:"bg-blue-500 h-4 rounded-full",style:{width:`${t>0?s.value/t*100:0}%`}})}),o.jsx("span",{className:"font-semibold text-brand-dark dark:text-gray-200 w-12 text-right",children:s.value.toLocaleString(void 0,{notation:"compact"})})]})]},s.label)):o.jsx("div",{className:"flex items-center justify-center h-32",children:o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center",children:"No data available for this period."})})})]})},qg=["planning","pending_confirmation","confirmed","completed","cancelled"],zg=n=>{switch(n){case"completed":return"bg-green-100 text-green-800 border-green-200 focus:ring-green-500 dark:bg-green-900/50 dark:text-green-300 dark:border-green-700";case"confirmed":return"bg-blue-100 text-blue-800 border-blue-200 focus:ring-blue-500 dark:bg-blue-900/50 dark:text-blue-300 dark:border-blue-700";
4547case"pending_confirmation":return"bg-orange-100 text-orange-800 border-orange-200 focus:ring-orange-500 dark:bg-orange-900/50 dark:text-orange-300 dark:border-orange-700";case"planning":return"bg-yellow-100 text-yellow-800 border-yellow-200 focus:ring-yellow-500 dark:bg-yellow-900/50 dark:text-yellow-300 dark:border-yellow-700";case"cancelled":return"bg-red-100 text-red-800 border-red-200 focus:ring-red-500 dark:bg-red-900/50 dark:text-red-300 dark:border-red-700";default:return"bg-gray-100 text-gray-800 border-gray-200 focus:ring-gray-500 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-600"}},LN=n=>n?typeof n.adminCommissionRateOverride=="number"&&n.adminCommissionRateOverride>=0?n.adminCommissionRateOverride:n.canSetCommissionRate??!0?Math.min(n.commissionRate||0,.25):0:0,jN=(n,e)=>{const t=new Date(n);return t.setDate(t.getDate()-e),t},ON=n=>n.toISOString().split("T")[0],FN=({label:n,isActive:e,onClick:t})=>o.jsx("button",{onClick:t,className:`${e?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:border-gray-600"} whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm`,"aria-current":e?"page":void 0,children:n}),H$=({itineraries:n,onUpdateItinerary:e,onViewItinerary:t})=>{const[r,s]=R.useState(""),[a,c]=R.useState("all"),[u,h]=R.useState(1),[f,p]=R.useState(10),y=R.useMemo(()=>n.filter(E=>{const N=r.toLowerCase(),S=!r||E.id.toLowerCase().includes(N)||E.title.toLowerCase().includes(N)||E.travelerName.toLowerCase().includes(N),I=a==="all"||E.status===a;return S&&I}),[n,r,a]);R.useEffect(()=>{h(1)},[r,a,f]);const b=R.useMemo(()=>{const E=(u-1)*f;return y.slice(E,E+f)},[y,u,f]),w=(E,N)=>{e({...E,status:N})};return o.jsxs("div",{children:[o.jsxs("div",{className:"mb-6 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg border dark:border-gray-700 flex flex-col md:flex-row gap-4 items-center",children:[o.jsxs("div",{className:"relative flex-grow w-full md:w-auto",children:[o.jsx("input",{type:"search",placeholder:"Search by ID, title, or traveler...",value:r,onChange:E=>s(E.target.value),className:"w-full p-2 pl-10 border rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"}),o.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})]}),o.jsxs("select",{value:a,onChange:E=>c(E.target.value),className:"w-full md:w-48 p-2 border rounded-lg border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 dark:text-white",children:[o.jsx("option",{value:"all",children:"All Statuses"}),qg.map(E=>o.jsx("option",{value:E,className:"capitalize",children:E.replace("_"," ")},E))]})]}),o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md overflow-x-auto",children:[o.jsxs("table",{className:"w-full text-sm text-left text-gray-500 dark:text-gray-400",children:[o.jsx("thead",{className:"text-xs text-gray-700 dark:text-gray-400 uppercase bg-gray-50 dark:bg-gray-700",children:o.jsxs("tr",{children:[o.jsx("th",{className:"px-6 py-3",children:"Start Date"}),o.jsx("th",{className:"px-6 py-3",children:"Trip Details"}),o.jsx("th",{className:"px-6 py-3",children:"Traveler"}),o.jsx("th",{className:"px-6 py-3",children:"Price"}),o.jsx("th",{className:"px-6 py-3",children:"Status"}),o.jsx("th",{className:"px-6 py-3 text-right",children:"Actions"})]})}),o.jsxs("tbody",{children:[b.map(E=>o.jsxs("tr",{className:"bg-white dark:bg-gray-800 border-b dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600",children:[o.jsx("td",{className:"px-6 py-4 font-medium text-gray-900 dark:text-white",children:new Date(E.startDate).toLocaleDateString()}),o.jsxs("td",{className:"px-6 py-4",children:[o.jsx("div",{className:"font-semibold text-brand-dark dark:text-white",children:E.title}),o.jsx("div",{className:"font-mono text-xs text-gray-500 dark:text-gray-400",children:E.id})]}),o.jsx("td",{className:"px-6 py-4",children:E.travelerName}),o.jsxs("td",{className:"px-6 py-4",children:["$",E.totalPrice.toLocaleStr
4547ing()]}),o.jsx("td",{className:"px-6 py-4",children:o.jsxs("div",{className:"relative",children:[o.jsx("select",{value:E.status,onChange:N=>w(E,N.target.value),className:`w-full pl-3 pr-8 py-1 text-xs font-bold rounded-full capitalize border appearance-none transition-colors duration-200 focus:outline-none focus:ring-2 ${zg(E.status)}`,children:qg.map(N=>o.jsx("option",{value:N,children:N.replace("_"," ")},N))}),o.jsx("svg",{className:"w-4 h-4 absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-gray-600 dark:text-gray-400",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})})]})}),o.jsx("td",{className:"px-6 py-4 text-right",children:o.jsx("button",{onClick:()=>t(E),className:"font-medium text-blue-600 dark:text-blue-400 hover:underline",children:"View Trip"})})]},E.id)),y.length===0&&o.jsx("tr",{children:o.jsx("td",{colSpan:6,className:"text-center py-10 text-gray-500 dark:text-gray-400",children:"No trips match the current filters."})})]})]}),y.length>0&&o.jsx(NC,{currentPage:u,totalItems:y.length,pageSize:f,onPageChange:h,onPageSizeChange:p,itemLabel:"trips"})]})]})},q$=({user:n})=>{const[e,t]=R.useState([]),[r,s]=R.useState([]),[a,c]=R.useState(null),[u,h]=R.useState(!0),[f,p]=R.useState(""),[y,b]=R.useState(!0),[w,E]=R.useState("dashboard"),[N,S]=R.useState(null),[I,O]=R.useState("30d"),[F,J]=R.useState({start:jN(new Date,29),end:new Date}),z=R.useCallback(async()=>{h(!0);try{const[ee,ne,G]=await Promise.all([ge.getConsultantById(n.id),ge.getItinerariesByConsultant(n.id),ge.getReviewsByConsultant(n.id)]);c(ee||null),t(ne.sort((W,X)=>
4547new Date(X.startDate).getTime()-new Date(W.startDate).getTime())),s(G.sort((W,X)=>X.id.localeCompare(W.id,void 0,{numeric:!0})))}catch(ee){console.error("Failed to load consultant dashboard data:",ee)}finally{h(!1)}},[n.id]);R.useEffect(()=>{z()},[z]);const U=R.useCallback(ee=>{if(O(ee),ee==="custom")return;if(ee==="all"){if(e.length===0){const W=new Date;J({start:W,end:W})}else{const W=e.map(X=>new Date(X.startDate)).sort((X,ae)=>X.getTime()-ae.getTime());J({start:W[0]||new Date,end:new Date})}return}const ne=new Date;let G=0;switch(ee){case"7d":G=6;break;case"3m":G=89;break;case"1y":G=364;break;case"30d":default:G=29;break}J({start:jN(ne,G),end:ne})},[e]),D=(ee,ne)=>{const G=new Date(ne);O("custom"),J(W=>({...W,[ee]:G}))},{filteredItineraries:k,filteredReviews:_}=R.useMemo(()=>{if(I==="all"||u)return{filteredItineraries:e,filteredReviews:r};const ee=new Date(F.start);ee.setHours(0,0,0,0);const ne=new Date(F.end);ne.setHours(23,59,59,999);const G=e.filter(ae=>{const Te=new Date(ae.startDate);return Te>=ee&&Te<=ne}),W=new Set(G.map(ae=>ae.id)),X=r.filter(ae=>W.has(ae.itineraryId));return{filteredItineraries:G,filteredReviews:X}},[e,r,F,I,u]),M=R.useMemo(()=>{const ee=k.reduce((ae,Te)=>(ae[Te.status]=(ae[Te.status]||0)+1,ae),{}),ne=k.filter(ae=>ae.status==="confirmed"||ae.status==="completed"),G=LN(a),W=ne.reduce((ae,Te)=>{const fe=Te.totalPrice*.8*G;return ae.total+=fe,ae},{total:0}),X=_.length>0?{avgRating:_.reduce((ae,Te)=>ae+Te.rating,0)/_.length,reviewCount:_.length}:{avgRating:0,reviewCount:0};return{planningCount:ee.planning||0,pendingCount:ee.pending_confirmation||0,confirmedCount:(ee.confirmed||0)+(ee.completed||0),totalEarnings:W.total,...X}},[k,_,a]);R.useEffect(()=>{if(!u&&a){b(!0);let ee="All Time";I!=="all"&&(ee=`${F.start.toLocaleDateString()} - ${F.end.toLocaleDateString()}`),NI.getConsultantReportSummary(a.name,M,ee).then(p).finally(()=>b(!1))}},[M,u,a,F,I]);const j=R.useMemo(()=>{if(!a)return[];const ee=LN(a),G=k.filter(W=>W.status==="confirmed"||W.status==="completed").reduce((W,X)=>{const ae=new Date(X.startDate).toLocaleString("default",{month:"short",year:"numeric"}),K=X.totalPrice*.8*ee;return W[ae]=(W[ae]||0)+K,W},{});return Object.entries(G).map(([W,X])=>({label:W,value:X}))},[k,a]),H=async ee=>{const ne=[...e];t(G=>G.map(W=>W.id===ee.id?ee:W)),(N==null?void 0:N.id)===ee.id&&S(null);try{await ge.updateItinerary(ee)}catch(G){console.error("Failed to update itinerary:",G),t(ne)}},L=({preset:ee,label:ne})=>o.jsx("button",{onClick:()=>U(ee),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${I===ee?"bg-blue-600 text-white font-semibold":"text-gray-600 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600"}`,children:ne});return u?o.jsx("div",{className:"flex justify-center mt-16",children:o.jsx(At,{})}):o.jsxs("div",{className:"space-y-6",children:[o.jsxs("h1",{className:"text-4xl font-bold text-brand-dark dark:text-white font-heading",children:[n.name.split(" ")[0],"'s Dashboard"]}),o.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:o.jsxs("nav",{className:"-mb-px flex space-x-8","aria-label":"Tabs",children:[o.jsx(FN,{label:"Dashboard",isActive:w==="dashboard",onClick:()=>E("dashboard")}),o.jsx(FN,{label:"My Trips",isActive:w==="trips",onClick:()=>E("trips")})]})}),w==="dashboard"&&o.jsxs("div",{className:"space-y-6 animate-fade-in",children:[o.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800/50 rounded-lg border dark:border-gray-700 flex flex-wrap items-center gap-4 text-sm",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx(L,{preset:"7d",label:"7 Days"}),o.jsx(L,{preset:"30d",label:"30 Days"}),o.jsx(L,{preset:"3m",label:"3 Months"}),o.jsx(L,{preset:"1y",label:"1 Year"}),o.jsx(L,{preset:"all",label:"All Time"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"date",value:ON(F.start),onChange:ee=>D("start",ee.target.value),className:"p-1.5 border rounded-md border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:[color-scheme:dark]"}),o.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"to"}),o.jsx("input",{type:"date",value:ON(F.end),onChange:ee=>D("end",ee.target.value),className:"p-1.5 border rounded-md border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:[color-scheme:dark]"})]})]}),o.jsxs(On,{className:"!p-6 bg-blue-50 dark:bg-gray-800 border-blue-200 dark:border-blue-900",children:[o.jsxs("h3",{className:"text-lg font-bold text-brand-dark dark:text-white font-heading flex items-center gap-2",children:[o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-blue-500",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M11.3 1.046A1 1 0 0112 2v5h4a1 1 0 01.82 1.573l-7 10A1 1 0 018 18v-5H4a1 1 0 01-.82-1.573l7-10a1 1 0 011.12-.38z",clipRule:"evenodd"})}),"Performance Summary"]}),y?o.jsxs("div",{className:"flex items-center gap-2 mt-2 text-sm text-gray-500 dark:text-gray-400",children:[o.jsx(At,{}),o.jsx("span",{children:"Generating insights..."})]}):o.jsx("p",{className:"mt-2 text-brand-dark dark:text-gray-300 leading-relaxed",children:f})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),title:"Planning",value:M.planningCount}),o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),title:"Confirmed",value:M.confirmedCount}),o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v.01"})}
4547),title:"Total Earnings",value:`$${M.totalEarnings.toLocaleString(void 0,{maximumFractionDigits:0})}`}),o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.783-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})}),title:"Avg. Rating",value:M.reviewCount>0?M.avgRating.toFixed(2):"N/A",description:M.reviewCount>0?`from ${M.reviewCount} reviews`:"No reviews yet"})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsx("div",{className:"lg:col-span-2",children:o.jsx(ph,{title:"Monthly Earnings",data:j})}),o.jsxs(On,{className:"!p-6",children:[o.jsx("h3",{className:"text-lg font-bold font-heading mb-4 text-brand-dark dark:text-white",children:"Recent Reviews"}),o.jsxs("div",{className:"space-y-4",children:[_.slice(0,3).map(ee=>o.jsxs("div",{className:"border-b border-gray-100 dark:border-gray-700 pb-3 last:border-b-0",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("p",{className:"font-semibold text-sm text-brand-dark dark:text-white",children:ee.travelerName}),o.jsx(Wa,{rating:ee.rating})]}),o.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 italic mt-1",children:['"',ee.comment,'"']})]},ee.id)),_.length===0&&o.jsx("p",{className:"text-sm text-center text-gray-500 dark:text-gray-400 py-4",children:"No reviews yet for this period."})]})]})]})]}),w==="trips"&&o.jsx("div",{className:"animate-fade-in",children:o.jsx(H$,{itineraries:e,onUpdateItinerary:H,onViewItinerary:S})}),N&&o.jsx(SC,{itinerary:N,onClose:()=>S(null),onSave:H,consultantName:n.name})]})},z$=()=>{const{navigateTo:n}=an(),[e,t]=R.useState([]),[r,s]=R.useState({}),[a,c]=R.useState(!0),[u,h]=R.useState(""),[f,p]=R.useState("all"),[y,b]=R.useState("all"),[w,E]=R.useState(null),[N,S]=R.useState([]),[I,O]=R.useState(1),[F,J]=R.useState(10);R.useEffect(()=>{c(!0);let _=!0;const M=ge.subscribeToItineraries(j=>{_&&(t((j||[]).sort((H,L)=>new Date(L.startDate||0).getTime()-new Date(H.startDate||0).getTime())),c(!1))});return ge.getAllConsultants().then(j=>{if(_){S(j||[]);const H=(j||[]).reduce((L,ee)=>(L[ee.id]=ee.name,L),{});s(H)}}),()=>{_=!1,M()}},[]);const z=R.useMemo(()=>e.filter(_=>{const M=u.toLowerCase().trim(),j=!M||_.id&&_.id.toLowerCase().includes(M)||_.title&&_.title.toLowerCase().includes(M)||_.travelerName&&_.travelerName.toLowerCase().includes(M)||_.travelerEmail&&_.travelerEmail.toLowerCase().includes(M),H=f==="all"||_.status===f,L=y==="all"||_.consultantId===y;return j&&H&&L}),[e,u,f,y]);R.useEffect(()=>{O(1)},[u,f,y,F]);const U=R.useMemo(()=>{const _=(I-1)*F;return z.slice(_,_+F)},[z,I,F]),D=async _=>{const M=[...e];t(j=>j.map(H=>H.id===_.id?_:H)),(w==null?void 0:w.id)===_.id&&E(null);try{await ge.updateItinerary(_)}catch(j){console.error("Failed to update itinerary:",j),t(M)}},k=(_,M)=>{D({..._,status:M})};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-6",children:[o.jsxs("div",{children:[o.jsx("div",{className:"flex items-center gap-2 mb-1",children:o.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-semibold bg-emerald-100 text-emerald-800 dark:bg-emerald-950/60 dark:text-emerald-300 border border-emerald-200 dark:border-emerald-800",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse"}),"Live Firebase Database"]})}),o.jsx("h1",{className:"text-3xl sm:text-4xl font-bold text-brand-dark dark:text-white font-heading",children:"Trip Management"}),o.jsxs("p",{className:"text-sm sm:text-base mt-1 text-gray-600 dark:text-gray-300",children:["Viewing all trips stored directly in the Firebase database (",e.length," total)."]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(He,{variant:"secondary",onClick:()=>n(Le.TripManagement),children:"Dedicated Trips View"}),o.jsx(He,{onClick:()=>n(Le.AdminHub),children:"Manage Content"})]})]}),o.jsxs("div",{className:"mb-6 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg border dark:border-gray-700 flex flex-col md:flex-row gap-4 items-center",children:[o.jsxs("div",{className:"relative flex-grow w-full md:w-auto",children:[o.jsx("input",{type:"search",placeholder:"Search by ID, title, or traveler...",value:u,onChange:_=>h(_.target.value),className:"w-full p-2 pl-10 border rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"}),o.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})]}),o.jsxs("select",{value:f,onChange:_=>p(_.target.value),className:"w-full md:w-48 p-2 border rounded-lg border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 dark:text-white",children:[o.jsx("option",{value:"all",children:"All Statuses"}),qg.map(_=>o.jsx("option",{value:_,className:"capitalize",children:_.replace("_"," ")},_))]}),o.jsxs("select",{value:y,onChange:_=>b(_.target.value),className:"w-full md:w-48 p-2 border rounded-lg border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 dark:text-white",children:[o.jsx("option",{value:"all",children:"All Consultants"}),N.map(_=>o.jsx("option",{value:_.id,children:_.name},_.id))]})]}),o.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md overflow-x-auto",children:a?o.jsxs("div",{className:"py-20 text-center",children:[o.jsx(At,{}),o.jsx("p",{className:"text-xs text-gray-400 mt-2",children:"Loading from Firestore..."})]}):o.jsxs(o.Fragment,{children:[o.jsxs("table",{className:"w-full text-sm text-left text-gray-500 dark:text-gray-400",children:[o.jsx("thead",{className:"text-xs text-gray-700 dark:text-gray-400 uppercase bg-gray-50 dark:bg-gray-700",children:o.jsxs("tr",{children:[o.jsx("th",{className:"px-6 py-3",children:"Start Date"}),o.jsx("th",{className:"px-6 py-3",children:"Trip Details"}),o.jsx("th",{className:"px-6 py-3",children:"Traveler"}),o.jsx("th",{className:"px-6 py-3",children:"Consultant"}),o.jsx("th",{className:"px-6 py-3",children:"Price"}),o.jsx("th",{className:"px-6 py-3",children:"Status"}),o.jsx("th",{className:"px-6 py-3 text-right",children:"Actions"})]})}),o.jsxs("tbody",{children:[U.map(_=>o.jsxs("tr",{className:"bg-white dark:bg-gray-800 border-b dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600",children:[o.jsx("td",{className:"px-6 py-4 font-medium text-gray-900 dark:text-white",children:new Date(_.startDate).toLocaleDateString()}),o.jsxs("td",{className:"px-6 py-4",children:[o.jsx("div",{className:"font-semibold text-brand-dark dark:text-white",children:_.title}),o.jsx("div",{className:"font-mono text-xs text-gray-500 dark:text-gray-400",children:_.id})]}),o.jsx("td",{className:"px-6 py-4",children:_.travelerName}),o.jsx("td",{className:"px-6 py-4",children:r[_.consultantId]||"N/A"}),o.jsxs("td",{className:"px-6 py-4",children:["$",_.totalPrice.toLocaleStr
4547ing()]}),o.jsx("td",{className:"px-6 py-4",children:o.jsxs("div",{className:"relative",children:[o.jsx("select",{value:_.status,onChange:M=>k(_,M.target.value),className:`w-full pl-3 pr-8 py-1 text-xs font-bold rounded-full capitalize border appearance-none transition-colors duration-200 focus:outline-none focus:ring-2 ${zg(_.status)}`,children:qg.map(M=>o.jsx("option",{value:M,children:M.replace("_"," ")},M))}),o.jsx("svg",{className:"w-4 h-4 absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-gray-600 dark:text-gray-400",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})})]})}),o.jsx("td",{className:"px-6 py-4 text-right",children:o.jsx("button",{onClick:()=>E(_),className:"font-medium text-blue-600 dark:text-blue-400 hover:underline",children:"View Trip"})})]},_.id)),z.length===0&&o.jsx("tr",{children:o.jsx("td",{colSpan:7,className:"text-center py-10 text-gray-500 dark:text-gray-400",children:"No trips match the current filters."})})]})]}),z.length>0&&o.jsx(NC,{currentPage:I,totalItems:z.length,pageSize:F,onPageChange:O,onPageSizeChange:J,itemLabel:"trips"})]})}),w&&o.jsx(SC,{itinerary:w,onClose:()=>E(null),onSave:D,consultantName:r[w.consultantId]})]})},J$=({user:n})=>{var S;const[e,t]=R.useState([]),[r,s]=R.useState([]),[a,c]=R.useState([]),[u,h]=R.useState([]),[f,p]=R.useState(!0),[y,b]=R.useState(null),[w,E]=R.useState(new Set);R.useEffect(()=>{(async()=>{p(!0);try{if(!n.email)return;const[O,F,J,z]=await Promise.all([ge.getItinerariesByEmail(n.email),ge.getAllDestinations(),ge.getAllLodges(),ge.getAllConsultants()]);h(z),t(O.sort((U,D)=>new Date(D.startDate).getTime()-new Date(U.startDate).getTime())),s(F),c(J)}catch(O){console.error("Failed to load traveler dashboard data:",O)}finally{p(!1)}})()},[n.email]);const N=I=>{E(O=>new Set(O).add(I.id)),b(I)};return f?o.jsx("div",{className:"flex justify-center mt-16",children:o.jsx(At,{})}):y&&w.has(y.id)?o.jsxs("div",{className:"space-y-6 animate-fade-in",children:[o.jsx("button",{onClick:()=>b(null),className:"text-sm font-semibold text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white flex items-center gap-1",children:"← Back to My Trips"}),o.jsxs(On,{className:"!p-6 md:!p-8 border-t-4 border-t-emerald-500",children:[o.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-4 mb-8",children:[o.jsxs("div",{children:[o.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-semibold mb-1",children:["Booked with: ",o.jsx("span",{className:"text-brand-dark dark:text-white",children:((S=u.find(I=>I.id===y.consultantId))==null?void 0:S.name)||"Unknown Expert"})]}),o.jsx("h2",{className:"text-3xl font-bold text-brand-dark dark:text-white font-heading",children:y.title}),o.jsxs("p",{className:"text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2 text-sm flex-wrap",children:[o.jsx("span",{children:new Date(y.startDate).toLocaleDateString()}),o.jsx("span",{children:"•"}),o.jsxs("span",{children:[y.duration," Nights"]}),o.jsx("span",{children:"•"}),o.jsxs("span",{children:[y.travelerCount," Travelers"]}),o.jsx("span",{children:"•"}),o.jsxs("span",{className:"capitalize text-emerald-600 dark:text-emerald-400 font-medium",children:["Route: ",y.startLocation," to ",y.endLocation]})]})]}),o.jsxs("div",{className:"text-left md:text-right",children:[o.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-semibold mb-1",children:"Status"}),o.jsx("span",{className:`px-3 py-1 text-xs font-bold rounded-full capitalize border ${zg(y.status)}`,children:y.status.replace("_"," ")})]})]}),o.jsx("div",{className:"mt-8 mb-8",children:o.jsx(SA,{breakdown:y.breakdown,travelerCount:y.travelerCount})}),o.jsxs("div",{className:"space-y-4",children:[o.jsx("h3",{className:"text-xl font-bold text-brand-dark dark:text-white font-heading border-b border-gray-100 dark:border-gray-700 pb-2",children:"Trip Itinerary"}),y.stops.map((I,O)=>{const F=r.find(_=>_.id===I.destinationId),J=a.find(_=>_.id===I.lodgeId),z=J==null?void 0:J.rooms.find(_=>_.id===I.roomId),U=new Date(y.startDate);let D=0;for(let _=0;_<O;_++)D+=y.stops[_].numberOfNights;U.setDate(U.getDate()+D);const k=new Date(U);return k.setDate(k.getDate()+I.numberOfNights),o.jsxs("div",{className:"flex gap-4 p-4 rounded-xl bg-gray-50 dark:bg-gray-800/50 border border-gray-100 dark:border-gray-700",children:[o.jsx("div",{className:"flex-shrink-0 w-16 h-16 rounded-lg overflow-hidden bg-gray-200 dark:bg-gray-700",children:F!=null&&F.imageUrl?o.jsx("img",{src:F.imageUrl,alt:F==null?void 0:F.name,className:"w-full h-full object-cover"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-400",children:o.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})})}),o.jsxs("div",{className:"flex-grow",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start gap-2 mb-2",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-bold text-lg text-brand-dark dark:text-white",children:(F==null?void 0:F.name)||"Unknown Location"}),J&&o.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-300 mt-1 flex items-center gap-1.5",children:[o.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})}),o.jsx("span",{className:"font-medium",children:J.name}),z&&o.jsxs("span",{className:"text-gray-400 dark:text-gray-500",children:["(",z.name,")"]})]})]}),o.jsxs("div",{className:"sm:text-right text-sm",children:[o.jsxs("div",{className:"font-medium text-gray-900 dark:text-white",children:[U.toLocaleDateString()," - ",k.toLocaleDateString()]}),o.jsxs("div",{className:"text-gray-500",children:[I.numberOfNights," Nights"]})]})]}),I.activities&&I.activities.some(_=>_.length>0)&&o.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-700/50",children:[o.jsx("div",{className:"text-xs uppercase tracking-wider text-gray-500 font-semibold mb-2",children:"Activities"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:I.activities.flatMap(_=>_).map((_,M)=>{const j=F==null?void 0:F.activities.find(H=>H.id===_);return j?o.jsx("span",{className:"px-2.5 py-1 bg-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md text-xs font-medium text-gray-700 dark:text-gray-300 shadow-sm",children:j.name},`${_}-${M}`):null})})]})]})]},I.id)})]}),o.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100 dark:border-gray-700",children:o.jsxs("div",{className:"bg-emerald-50 dark:bg-emerald-900/20 rounded-xl p-6 flex flex-col md:flex-row justify-between items-center gap-4 border border-emerald-100 dark:border-emerald-800",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"text-lg font-bold text-gray-900 dark:text-white font-heading",children:"Total Price Quote"}),o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:"Includes all selected lodges, activities, and transport."})]}),o.jsxs("div",{className:"text-right",children:[o.jsxs("span",{className:"text-3xl font-bold text-emerald-600 dark:text-emerald-400",children:["$",y.totalPrice.toLocaleStr
4547ing()]}),o.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 text-center md:text-right",children:"USD"})]})]})})]})]}):o.jsxs("div",{className:"space-y-6 animate-fade-in",children:[o.jsx("div",{className:"flex justify-between items-end",children:o.jsxs("div",{children:[o.jsx("h1",{className:"text-4xl font-bold text-brand-dark dark:text-white font-heading",children:"My Trips"}),o.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-1 text-sm",children:"Manage and view your planned and past safaris."})]})}),e.length===0?o.jsxs(On,{className:"text-center py-16",children:[o.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center mx-auto mb-4",children:o.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),o.jsx("h3",{className:"text-xl font-bold text-gray-900 dark:text-white font-heading mb-2",children:"No trips found"}),o.jsx("p",{className:"text-gray-500 dark:text-gray-400 max-w-md mx-auto mb-6",children:"You haven't booked any trips yet. Head over to the Trip Planner to start building your dream Ugandan safari."})]}):o.jsx(On,{className:"!p-0 overflow-hidden",children:o.jsx("div",{className:"overflow-x-auto",children:o.jsxs("table",{className:"w-full text-sm text-left",children:[o.jsx("thead",{className:"text-xs text-gray-500 dark:text-gray-400 uppercase bg-gray-50 dark:bg-gray-800/50 border-b border-gray-100 dark:border-gray-700",children:o.jsxs("tr",{children:[o.jsx("th",{scope:"col",className:"px-6 py-4 font-semibold",children:"Trip ID"}),o.jsx("th",{scope:"col",className:"px-6 py-4 font-semibold",children:"Title"}),o.jsx("th",{scope:"col",className:"px-6 py-4 font-semibold",children:"Dates"}),o.jsx("th",{scope:"col",className:"px-6 py-4 font-semibold",children:"Travelers"}),o.jsx("th",{scope:"col",className:"px-6 py-4 font-semibold",children:"Status"}),o.jsx("th",{scope:"col",className:"px-6 py-4 font-semibold text-right",children:"Total Price"}),o.jsx("th",{scope:"col",className:"px-6 py-4"})]})}),o.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700/50",children:e.map(I=>o.jsxs("tr",{className:"bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-750 transition-colors",children:[o.jsx("td",{className:"px-6 py-4 font-mono text-xs text-gray-500 dark:text-gray-400",children:I.id.substring(0,8).toUpperCase()}),o.jsx("td",{className:"px-6 py-4 font-medium text-gray-900 dark:text-white",children:I.title}),o.jsxs("td",{className:"px-6 py-4 text-gray-600 dark:text-gray-300",children:[new Date(I.startDate).toLocaleDateString()," (",I.duration," Nights)"]}),o.jsx("td",{className:"px-6 py-4 text-gray-600 dark:text-gray-300",children:I.travelerCount}),o.jsx("td",{className:"px-6 py-4",children:o.jsx("span",{className:`px-2.5 py-1 text-[10px] uppercase font-bold rounded-full border ${zg(I.status)}`,children:I.status.replace("_"," ")})}),o.jsxs("td",{className:"px-6 py-4 text-right font-medium text-gray-900 dark:text-white",children:["$",I.totalPrice.toLocaleString()]}),o.jsx("td",{className:"px-6 py-4 text-right",children:o.jsx("button",{onClick:()=>N(I),className:"text-emerald-600 dark:text-emerald-400 hover:text-emerald-700 font-medium text-sm",children:"View Details"})})]},I.id))})]})})})]})},$$=({user:n})=>o.jsx("div",{className:"max-w-7xl mx-auto w-full",children:n.role==="admin"?o.jsx(z$,{}):n.role==="traveler"?o.jsx(J$,{user:n}):o.jsx(q$,{user:n})}),K$=({user:n})=>{var M,j,H,L;const{login:e,state:{lodges:t}}=an(),[r,s]=R.useState(null),[a,c]=R.useState(t),[u,h]=R.useState(!0),[f,p]=R.useState(!1),[y,b]=R.useState(""),[w,E]=R.useState(""),N=R.useRef("");R.useEffect(()=>{let ee=!0;ge.getAllLodges().then(G=>{ee&&G&&G.length>0&&c(G)});const ne=ge.subscribeToLodges(G=>{ee&&G&&G.length>0&&c(G)});return()=>{ee=!1,ne()}},[]),R.useEffect(()=>{let ee=!0;return(async()=>{h(!0);const G=n.consultantId||n.id;let W=await ge.getConsultantById(G);!W&&n.email&&(W=(await ge.getAllConsultants()).find(ae=>ae.email&&ae.email.toLowerCase()===n.email.toLowerCase())),ee&&W&&(s(W),b((W.specialties||[]).join(", ")),N.current=W.email||""),ee&&h(!1)})(),()=>{ee=!1}},[n.id,n.consultantId,n.email]);const S=ee=>{const{name:ne,value:G}=ee.target;s(W=>W?{...W,[ne]:G}:null)},I=ee=>{const ne=ee.target.value;b(ne),s(G=>G?{...G,specialties:ne.split(",").map(W=>
4547W.trim()).filter(Boolean)}:null)},O=(ee,ne)=>{const G=parseFloat(ne);s(W=>{var X;return W?{...W,transportRates:{...W.transportRates,road:{...(X=W.transportRates)==null?void 0:X.road,[ee]:isNaN(G)?void 0:G}}}:null})},F=()=>{const ee={lodgeId:"",commission:.15,sellingRateOverrides:[]};s(ne=>ne?{...ne,lodgeRates:[...ne.lodgeRates||[],ee]}:null)},J=(ee,ne)=>{s(G=>{if(!G||!G.lodgeRates)return G;const W=[...G.lodgeRates];return W[ee]=ne,{...G,lodgeRates:W}})},z=ee=>{s(ne=>!ne||!ne.lodgeRates?ne:{...ne,lodgeRates:ne.lodgeRates.filter((G,W)=>W!==ee)})},U=async ee=>{if(ee.preventDefault(),!!r){p(!0),E("");try{const ne={...r,email:N.current||r.email},G=await ge.updateConsultant(ne);s(G),e({...n,name:G.name||n.name,imageUrl:G.imageUrl||n.imageUrl,consultantId:G.id||n.consultantId}),E("Profile updated successfully!"),setTimeout(()=>E(""),4e3)}catch(ne){console.error("Failed to update profile:",ne),alert("An error occurred. Please try again.")}finally{p(!1)}}},D=(r==null?void 0:r.canSetCommissionRate)??!0,k=Number((((r==null?void 0:r.commissionRate)||0)*100).toPrecision(15)),_=D&&k>25;return u?o.jsx("div",{className:"flex justify-center mt-16",children:o.jsx(At,{})}):r?o.jsxs("div",{className:"max-w-4xl mx-auto",children:[o.jsxs("div",{className:"text-center mb-10",children:[o.jsx("h1",{className:"text-4xl font-bold text-brand-dark dark:text-white font-heading",children:"Edit Your Profile"}),o.jsx("p",{className:"text-lg mt-2 text-gray-600 dark:text-gray-300",children:"Keep your information up-to-date for travelers."})]}),o.jsxs("form",{onSubmit:U,className:"space-y-6",children:[o.jsxs(On,{className:"!p-6",children:[o.jsx("h3",{className:"text-xl font-bold font-heading mb-4 text-brand-dark dark:text-white",children:"Your Details"}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[o.jsx("div",{className:"md:col-span-1",children:o.jsx(Qa,{id:"consultant-profile-image",label:"Profile Picture",value:r.imageUrl,onChange:ee=>s(ne=>ne?{...ne,imageUrl:ee}:null),folder:"consultants",aspectRatio:"square",helperText:"Upload a professional headshot for your traveler profile."})}),o.jsxs("div",{className:"md:col-span-2 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"name",children:"Full Name"}),o.jsx("input",{id:"name",name:"name",type:"text",value:r.name,disabled:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-700 cursor-not-allowed"})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-1",children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300",htmlFor:"email",children:"Contact Email"}),o.jsx("span",{className:"text-[10px] font-semibold tracking-wide uppercase px-2 py-0.5 rounded bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300 border border-gray-300 dark:border-gray-600",children:"Admin Managed"})]}),o.jsx("input",{id:"email",name:"email",type:"email",value:r.email||"",disabled:!0,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-700/60 text-gray-500 dark:text-gray-400 cursor-not-allowed"}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Consultant emails are managed by the platform administrator for security."})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"phone",children:"Phone Number"}),o.jsx("input",{id:"phone",name:"phone",type:"tel",value:r.phone||"",onChange:S,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"bio",children:"Biography"}),o.jsx("textarea",{id:"bio",name:"bio",value:r.bio,onChange:S,rows:5,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"specialties",children:"Specialties (comma-separated)"}),o.jsx("input",{id:"specialties",name:"specialties",type:"text",value:y,onChange:I,className:"w-full p-2 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]})]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsxs(On,{className:"!p-6",children:[o.jsx("h3",{className:"text-xl font-bold font-heading mb-4 text-brand-dark dark:text-white",children:"Availability"}),o.jsxs("div",{className:"flex items-center p-3 rounded-lg bg-gray-50 dark:bg-gray-700/50 border dark:border-gray-600",children:[o.jsx("input",{id:"isAvailable",name:"isAvailable",type:"checkbox",checked:r.isAvailable,onChange:ee=>s(ne=>ne?{...ne,isAvailable:ee.target.checked}:null),className:"h-5 w-5 rounded text-blue-600 focus:ring-blue-500 border-gray-300 dark:border-gray-500"}),o.jsx("label",{htmlFor:"isAvailable",className:"ml-3 text-sm font-medium text-brand-dark dark:text-gray-200",children:r.isAvailable?"Available for new trips":"Unavailable for new trips"})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"When unavailable, you won't be shown to new travelers."})]}),o.jsxs(On,{className:"!p-6",children:[o.jsx("h3",{className:"text-xl font-bold font-heading mb-4 text-brand-dark dark:text-white",children:"Consultancy Fee"}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",htmlFor:"commissionRate",children:"Fee Percentage (%)"}),o.jsx("input",{id:"commissionRate",name:"commissionRate",type:"number",step:"0.1",max:D?"25":void 0,value:k,disabled:!D,onChange:ee=>{const ne=parseFloat(ee.target.value)/100;s(G=>G?{...G,commissionRate:isNaN(ne)?void 0:ne}:null)},className:`w-full p-2 border rounded ${_?"border-red-500":"border-gray-300 dark:border-gray-600"} dark:bg-gray-700 dark:text-white ${D?"":"bg-gray-100 dark:bg-gray-800 cursor-not-allowed"}`}),D?_?o.jsx("p",{className:"text-xs text-red-500 dark:text-red-400 mt-2",children:"The maximum consultancy fee is 25%."}):o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"This is the service fee you charge on commissionable items like accommodation, transport, and activities. Max 25%."}):o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"Your consultancy fee is managed by the platform administrator."})]}),o.jsxs("div",{className:"flex items-center gap-3 mt-4 p-3 rounded-lg bg-gray-50 dark:bg-gray-700/50 border dark:border-gray-600",children:[o.jsx("input",{id:"showCommissionRateOnProfile",name:"showCommissionRateOnProfile",type:"checkbox",checked:r.showCommissionRateOnProfile??!1,onChange:ee=>s(ne=>ne?{...ne,showCommissionRateOnProfile:ee.target.checked}:null),className:"h-5 w-5 rounded text-blue-600 focus:ring-blue-500 border-gray-300 dark:border-gray-500"}),o.jsx("label",{htmlFor:"showCommissionRateOnProfile",className:"text-sm font-medium text-brand-dark dark:text-gray-200",children:"Display my fee on my public profile"})]})]})]}),o.jsxs(On,{className:"!p-6",children:[o.jsx("h3",{className:"text-xl font-bold font-heading mb-4 text-brand-dark dark:text-white",children:"Custom Transport Rates"}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",children:"4x4 Safari Cruiser"}),o.jsxs("div",{className:"relative",children:[o.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500",children:"$"}),o.jsx("input",{type:"number",value:((j=(M=r.transportRates)==null?void 0:M.road)==null?void 0:j.cruiser)??"",onChange:ee=>O("cruiser",ee.target.value),placeholder:`Default: ${Xo.road.cruiser}`,className:"w-full p-2 pl-6 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-1",children:"Safari Van"}),o.jsxs("div",{className:"relative",children:[o.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500",children:"$"}),o.jsx("input",{type:"number",value:((L=(H=r.transportRates)==null?void 0:H.road)==null?void 0:L.van)??"",onChange:ee=>O("van",ee.target.value),placeholder:`Default: ${Xo.road.van}`,className:"w-full p-2 pl-6 border rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]})]})]})]}),o.jsxs(On,{className:"!p-6",children:[o.jsxs("div",{className:"flex justify-between items-center mb-4",children:[o.jsx("h3",{className:"text-xl font-bold font-heading text-brand-dark dark:text-white",children:"Negotiated Lodge Rates"}),o.jsx(He,{type:"button",variant:"secondary",onClick:F,className:"!py-2 !px-4 text-sm",children:"+ Add Lodge Rate"})]}),o.jsxs("div",{className:"space-y-4",children:[(r.lodgeRates||[]).map((ee,ne)=>o.jsx(PA,{lodgeRate:ee,allLodgeRates:r.lodgeRates||[],lodges:a,onUpdate:G=>J(ne,G),onDelete:()=>z(ne)},ne)),(r.lodgeRates||[]).length===0&&o.jsx("p",{className:"text-sm text-center text-gray-500 dark:text-gray-400 py-4",children:"You haven't added any custom lodge rates yet."})]})]}),o.jsxs("div",{className:"mt-8 text-right flex items-center justify-end gap-4",children:[w&&o.jsx("p",{className:"text-green-600 dark:text-green-400 font-semibold",children:w}),o.jsx(He,{type:"submit",disabled:f||_,children:f?o.jsx(At,{}):"Save Changes"})]})]})]}):o.jsx("div",{className:"text-center text-xl text-red-600",children:"Could not load consultant profile."})},Y$=({review:n,onSaveReply:e})=>{const[t,r]=R.useState(!1),[s,a]=R.useState(n.consultantReply||""),c=()=>{e(n.id,s),r(!1)};return o.jsx(On,{className:"!p-6",children:o.jsxs("div",{className:"flex gap-4",children:[o.jsxs("div",{className:"flex-shrink-0 text-center w-24",children:[o.jsx("p",{className:"font-bold text-brand-dark",children:n.travelerName}),o.jsx("div",{className:"flex justify-center mt-1",children:o.jsx(Wa,{rating:n.rating})})]}),o.jsxs("div",{className:"flex-grow border-l pl-4",children:[o.jsxs("p",{className:"italic text-brand-dark",children:['"',n.comment,'"']}),o.jsxs("p",{className:"text-xs text-gray-500 mt-2 font-mono",children:["From Trip: ",n.itineraryId]}),o.jsx("div",{className:"mt-4 pt-4 border-t",children:t?o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-bold text-gray-700 mb-2",children:"Your Reply"}),o.jsx("textarea",{value:s,onChange:u=>a(u.target.value),rows:3,className:"w-full p-2 border rounded border-gray-300 text-sm",placeholder:"Write your response..."}),o.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[o.jsx(He,{onClick:()=>r(!1),variant:"secondary",className:"!py-1 !px-3 text-sm",children:"Cancel"}),o.jsx(He,{onClick:c,className:"!py-1 !px-3 text-sm",children:"Save Reply"})]})]}):n.consultantReply?o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-bold text-gray-700 mb-1",children:"Your Reply"}),o.jsx("p",{className:"text-sm text-gray-800 bg-blue-50 p-3 rounded-md",children:n.consultantReply}),o.jsx("button",{onClick:()=>r(!0),className:"text-sm text-blue-600 hover:underline mt-2",children:"Edit Reply"})]}):o.jsx(He,{onClick:()=>r(!0),variant:"secondary",className:"!py-1 !px-3 text-sm",children:"Write a Reply"})})]})]})})},Q$=({user:n})=>
4547{const[e,t]=R.useState([]),[r,s]=R.useState(!0);R.useEffect(()=>{ge.getReviewsByConsultant(n.id).then(c=>{t(c),s(!1)})},[n.id]);const a=async(c,u)=>{const h=[...e],f=e.find(y=>y.id===c);if(!f)return;const p={...f,consultantReply:u};t(y=>y.map(b=>b.id===c?p:b));try{await ge.updateReview(p)}catch(y){console.error("Failed to save reply:",y),alert("Could not save reply. Reverting changes."),t(h)}};return r?o.jsx("div",{className:"flex justify-center mt-16",children:o.jsx(At,{})}):o.jsxs("div",{className:"max-w-4xl mx-auto",children:[o.jsxs("div",{className:"text-center mb-10",children:[o.jsx("h1",{className:"text-4xl font-bold text-brand-dark font-heading",children:"Manage Your Reviews"}),o.jsx("p",{className:"text-lg mt-2 text-gray-600",children:"Engage with your travelers by responding to their feedback."})]}),o.jsx("div",{className:"space-y-6",children:e.length>0?e.map(c=>o.jsx(Y$,{review:c,onSaveReply:a},c.id)):o.jsxs("div",{className:"text-center py-12",children:[o.jsx("p",{className:"text-xl text-brand-dark",children:"You don't have any reviews yet."}),o.jsx("p",{className:"text-gray-600 mt-2",children:"Completed trips will appear here for you to manage."})]})})]})},W$=[{id:"all",label:"All Resources",iconName:"Compass"},{id:"planning",label:"Safari Planning",iconName:"MapPin"},{id:"permits",label:"Gorilla & Chimp Permits",iconName:"ShieldCheck"},{id:"lodges",label:"Lodges & Transport",iconName:"Luggage"},{id:"experts",label:"Consultants & Booking",iconName:"UserCheck"},{id:"travel_essentials",label:"Visas, Health & Packing",iconName:"HeartPulse"}],UN=[{id:"building-itinerary-guide",title:"Building Your Custom Uganda Safari Itinerary",category:"planning",categoryLabel:"Safari Planning",readTime:"4 min read",summary:"A step-by-step master guide to creating, customizing, and pricing your dream Uganda wildlife circuit.",keywords:["itinerary","builder","planner","calculator","destinations","parks","cost breakdown"],content:{overview:"Our interactive Safari Planner allows travelers to design multi-destination Ugandan circuits with real-time park entry calculations, lodge assignments, activity permits, and private 4x4 transportation.",sections:[{heading:"Step 1: Define Duration & Starting Hub",body:["Most international visitors land at Entebbe International Airport (EBB). For a classic Uganda safari, we recommend at least 7 to 10 days to cover gorilla trekking, wildlife savannahs, and chimpanzee tracking without exhausting transit days.","Select your desired trip length and specify whether your safari departs from Entebbe, Kampala, or Kigali (for quick southwest Bwindi access)."],tip:"Allow at least 2 nights per major national park. Driving between parks takes 4–7 hours on scenic countryside roads."},{heading:"Step 2: Add Destinations & Experiences",body:["Browse our verified destination catalog. Add national parks such as Bwindi Impenetrable (Mountain Gorillas), Queen Elizabeth (Tree-climbing lions & Kazinga Channel boat cruise), Kibale (Chimpanzee tracking), and Murchison Falls (The world’s most powerful waterfall).","For each stop, tailor the number of nights, select your preferred lodge accommodation (Luxury, Mid-range, or Budget), and add seasonal activities."],bulletPoints:["Bwindi: 2-3 nights recommended for gorilla trekking and Batwa cultural encounters.","Queen Elizabeth: 2-3 nights for savannah game drives, lion tracking, and afternoon boat cruises.","Kibale Forest: 2 nights for chimpanzee trekking in the primate capital.","Murchison Falls: 3 nights for Nile river cruises, top-of-falls hikes, and big four wildlife."]},{heading:"Step 3: Review Transparent Pricing & Vehicle Logistics",body:["The itinerary builder calculates your subtotal dynamically based on official UWA park conservation fees, selected lodge rates per person sharing, guide fees, and custom 4x4 safari cruiser hire.","Once you are happy with the draft, submit it for booking or assign it directly to an accredited local Ugandan consultant."],tip:"Private 4x4 Safari Land Cruisers include a licensed English-speaking professional driver-guide, unlimited game drive mileage, and park entry vehicle fees."}],actionPrompt:{text:"Ready to build your dream Uganda adventure?",targetView:"itinerary-builder",buttonText:"Open Itinerary Planner"}}},{id:"gorilla-permits-complete-guide",title:"Gorilla Trekking Permits: 2026 Rules & Sector Allocation",category:"permits",categoryLabel:"Gorilla & Chimp Permits",readTime:"5 min read",summary:"Official Uganda Wildlife Authority (UWA) permit pricing, Bwindi sectors, fitness rules, and booking timelines.",keywords:["gorilla","permit","bwindi","mgahinga","trekking","cost","age limit","uwa"],content:{overview:"Mountain gorilla trekking in Uganda is one of the world’s most profound wildlife encounters. With fewer than 1,060 mountain gorillas remaining on Earth, permits are strictly regulated by the Uganda Wildlife Authority (UWA) to safeguard primate conservation.",sections:[{heading:"Official 2026 UWA Permit Tariffs",body:["Permit rates are fixed annually by UWA and include park entry on trek day, armed wildlife rangers, and 1 full hour with the habituated gorilla family.",`• Foreign Non-Residents (FNR): USD $800 per permit
4548• Foreign Residents (with East African work/residency permit): USD $700 per permit
4549• East African Community (EAC) Citizens: UGX 300,000 per permit
4550• Gorilla Habituation Experience (Rushaga sector, 4 hours with researchers): USD $1,500`],warning:"Only 8 tourists are permitted to visit a single gorilla family per day. Because permits regularly sell out 3–6 months in advance for peak dry seasons (June–August & Dec–Feb), advance reservation is vital."},{heading:"Understanding Bwindi Sectors & Lodging Alignment",body:["Bwindi Impenetrable National Park spans 321 square kilometers with rugged mountainous terrain. It is partitioned into four distinct trekking sectors:",`1. Buhoma (North): The oldest sector with luxury lodges and relatively gentler hiking trails.
45512. Ruhija (East): High-elevation misty ridge, excellent for birding and moderate treks.
45523. Rushaga (South): Highest concentration of gorilla families and the sole host of the 4-hour Habituation Experience.
45534. Nkuringo (Southwest): Dramatic views of the Virunga volcanoes with steeper, physically demanding trails.`],tip:"CRITICAL: Your lodge booking MUST correspond to the exact trekking sector printed on your UWA permit. Traveling between sectors can take 2 to 3 hours over mountain passes in the dark before the mandatory 7:30 AM morning briefing."},{heading:"Age Restrictions, Health Protocols & Porters",body:[`• Minimum Age: Strictly 15 years old. Passports are inspected at the ranger station prior to departure.
4554• Illness Rule: Gorillas share 98.4% of human DNA and are susceptible to human respiratory viruses. If you have a cough, flu, or cold, rangers will refuse entry to protect the troop (a refund or reschedule is handled per UWA terms).
4555• Porters: Always hire a local porter at the trailhead (USD $15–$20). Not only will they carry your backpack and lend a helping hand on slippery mud slopes, but porter hire directly funds community livelihoods around the park boundary.`]}],actionPrompt:{text:"Need help securing gorilla permits for specific dates?",targetView:"experts",buttonText:"Connect with a Safari Expert"}}},{id:"chimpanzee-tracking-kibale-guide",title:"Chimpanzee Tracking & Habituation in Kibale Forest",category:"permits",categoryLabel:"Gorilla & Chimp Permits",readTime:"3 min read",summary:"Everything you need to know about trekking our closest living relatives in the Primate Capital of the World.",keywords:["chimpanzee","kibale","chimp permit","kyambura","budongo","primate capital"],content:{overview:"Kibale National Park protects the greatest density and diversity of primates in Africa, sheltering over 1,500 chimpanzees alongside 12 other monkey and primate species.",sections:[{heading:"Standard Chimp Trek vs. Habituation Experience",body:["Kibale offers two distinct permits issued by UWA:","• Standard Chimpanzee Trek (USD $250 FNR): Conducted in two daily sessions (8:00 AM and 2:00 PM). Treks average 2 to 3 hours with 1 hour of direct observation.","• Chimpanzee Habituation Experience (CHEX - USD $300 FNR): Accompany researchers and rangers before dawn as chimps de-nest, follow their foraging troop through the canopy, and observe behavior until they construct new nests at dusk."],tip:"Morning treks generally offer higher activity levels as chimps vocalize, groom, and forage actively in the fig trees."},{heading:"Alternative Chimpanzee Tracking Locations",body:["While Kibale offers the highest sighting success rate (>95%), travelers can also encounter chimpanzees at:",`• Kyambura Gorge ("Valley of Apes" in Queen Elizabeth National Park): A sunken underground tropical forest surrounded by savannah.
4556• Budongo Forest (near Murchison Falls): Excellent mahogany forest canopy tracking.
4557• Kalinzu Central Forest Reserve: Affordable alternative located just outside Queen Elizabeth.`]}]}},{id:"safari-seasons-weather-guide",title:"Best Time to Visit Uganda: Seasons, Wildlife & Weather",category:"planning",categoryLabel:"Safari Planning",readTime:"4 min read",summary:"A seasonal breakdown of dry vs. green months, bird migrations, photography lighting, and gorilla trail conditions.",keywords:["seasons","weather","dry season","rainy season","best time","climate","months"],content:{overview:"Straddling the Equator and elevated on the East African plateau (averaging 1,100m elevation), Uganda enjoys pleasant tropical weather year-round with temperatures ranging between 22°C to 29°C (72°F–84°F).",sections:[{heading:"Peak Dry Seasons (June to August & December to February)",body:["The premier window for savannah wildlife viewing and gorilla trekking.",`• Forest trails in Bwindi and Kibale are drier and less slippery underfoot.
4558• Wildlife congregates around waterholes and riverbanks in Queen Elizabeth, Murchison Falls, and Kidepo Valley, making animals easy to spot.
4559• Low malaria transmission risk due to fewer pools of standing water.
4560• Advance booking (4–6 months ahead) is strongly advised for both lodges and permits.`]},{heading:"Green / Wet Seasons (March to May & September to November)",body:['Known as the "Emerald Season", this period transforms the landscapes into lush, vivid green paradises.',`• Ideal for photography enthusiasts seeking dramatic cloudscapes, golden light, and rich vegetation contrast.
4561• Outstanding birdwatching as thousands of Palearctic and intra-African migratory species arrive in Queen Elizabeth and Murchison Falls.
4562• Many luxury safari lodges offer attractive promotional discounts.
4563• Rain usually falls in short, intense afternoon downpours rather than persistent all-day drizzle.`],tip:"Gorilla trekking proceeds 365 days a year rain or shine. In green season, simply ensure sturdy waterproof gaiters and high-traction boots!"}]}},{id:"visa-entry-health-requirements",title:"Uganda Entry Requirements: eVisa, Health & Vaccinations",category:"travel_essentials",categoryLabel:"Visas, Health & Packing",readTime:"4 min read",summary:"Crucial entry rules: mandatory online eVisa application, yellow fever card validation, and malaria prophylaxis.",keywords:["visa","evisa","yellow fever","health","vaccines","malaria","entry requirements","immigration"],content:{overview:"Preparing your travel documentation and healthcare precautions ensures effortless arrival at Entebbe International Airport.",sections:[{heading:"Mandatory Online eVisa (No Visa on Arrival)",body:["Uganda immigration ceased issuing visas on arrival at Entebbe Airport. All foreign nationals requiring a visa must apply online prior to boarding your flight.",`• Official Portal: Only apply through the official government portal: https://visas.immigration.go.ug
4564• Standard Tourist Visa: USD $50 (single entry, valid up to 90 days).
4565• East African Tourist Visa: USD $100 (multiple entry between Uganda, Rwanda, and Kenya for 90 days, provided your journey begins in the country that issued the visa).`],warning:"Beware of third-party scam websites charging extortionate surcharges. Only use the official .go.ug government portal."},{heading:"Yellow Fever Certificate (Mandatory Requirement)",body:["An International Certificate of Vaccination against Yellow Fever is mandatory for all travelers aged 1 year and older entering Uganda.","Health quarantine officers will inspect your physical Yellow Card at Entebbe Airport before border control. Ensure your vaccination was administered at least 10 days before arrival."]},{heading:"Malaria Prevention & Safari Health",body:["Uganda is a malaria-endemic country. Consult your travel clinic or physician 4–6 weeks prior to departure for prophylactic medication (commonly Atovaquone/Proguanil / Malarone or Doxycycline).","Bring insect repellent containing 30–50% DEET or Picaridin for twilight hours. Safari lodges furnish mosquito netting over beds and spray rooms during turndown service."]}]}},{id:"currency-payments-tipping-guide",title:"Money, Currency, Tipping & Payment Etiquette",category:"travel_essentials",categoryLabel:"Visas, Health & Packing",readTime:"4 min read",summary:"The strict 2013+ US Dollar rule, currency exchange, tipping standards for guides and porters, and credit card usage.",keywords:["currency","usd","cash","tipping","credit card","ugx","shilling","atms","dollar bills"],content:{overview:"Understanding East African currency conventions saves travelers unexpected hassles when paying for souvenirs, drinks, and tips.",sections:[{heading:"The US Dollar Rule: Series 2013 or Newer Only",body:["Due to strict counterfeit prevention protocols across East African commercial banks and foreign exchange bureaus, US Dollar banknotes MUST be printed in 2013 or later.","Notes must be in crisp condition without tears, pen marks, excessive creases, or pinholes. Bills from series 2006 or older will be refused everywhere in Uganda."],warning:"Inspect all USD banknotes from your bank before departing your home country. Denominations of $50 and $100 receive significantly higher exchange rates than small bills ($1, $5, $10, $20)."},{heading:"Local Currency (Ugandan Shilling / UGX)",body:["The local currency is the Ugandan Shilling (UGX). While safaris, park fees, and major lodge stays are priced in USD, having UGX is essential for roadside craft markets, local snacks, tipping porters, and minor village purchases.","ATMs are widely available in Entebbe and Kampala (Barclays/Absa, Stanbic, Standard Chartered accept Visa and Mastercard). In remote bush areas, ATMs are non-existent."]},{heading:"Recommended Tipping Guidelines (Per Group)",body:["Tipping is customary and profoundly appreciated across the Ugandan hospital
4565ity sector:",`• Private Safari Driver-Guide: USD $10 – $20 per day from the group.
4566• Lead Gorilla Ranger / Guide: USD $15 – $20 per trek from the group.
4567• Gorilla Trackers & Scouts: USD $10 – $15 shared among tracking team.
4568• Trailhead Porters: USD $15 – $20 per porter (hiring fee) plus optional $5 tip.
4569• Lodge Staff Tip Box: USD $5 – $10 per day distributed among behind-the-scenes staff.`]}]}},{id:"safari-vehicles-and-transit-guide",title:"Safari Vehicles: 4x4 Land Cruisers vs. Safari Minivans",category:"lodges",categoryLabel:"Lodges & Transport",readTime:"3 min read",summary:"Comparing pop-up roof 4x4 Land Cruisers, customized minivans, and domestic bush flights across Uganda.",keywords:["vehicle","4x4","land cruiser","minivan","transport","domestic flights","aerolink","transit"],content:{overview:"Uganda’s diverse terrain spans tarmac highways, murram gravel roads, and rugged forest trails. Selecting the right vehicle ensures comfort and safety.",sections:[{heading:"Custom 4x4 Safari Land Cruiser (Top Choice)",body:["The iconic East African safari vehicle. Fitted with heavy-duty suspension, high ground clearance, pop-up roof hatch for unobstructed 360° photography, onboard fridge/coolbox, and charging ports for cameras and smartphones.","Indispensable for navigating muddy slopes in Bwindi Impenetrable and the sandy tracks of Ishasha (Queen Elizabeth) and Kidepo Valley."]},{heading:"Domestic Bush Flights (Aerolink & Bar Aviation)",body:["If you wish to bypass 8-to-10 hour overland drives between Entebbe and the southwest, daily scheduled Cessna Caravan flights operate between Entebbe (EBB) and airstrips at Kihihi (for Bwindi North), Kisoro (for Bwindi South), Kasese (Queen Elizabeth), and Pakuba (Murchison Falls).","Flight times average only 60 to 75 minutes. Luggage allowance on domestic bush flights is typically 15kg (33 lbs) per person in soft duffel bags."],tip:"Soft-sided duffel bags without rigid frames are required on domestic light aircraft so luggage can fit into aircraft pods."}]}},{id:"booking-through-consultants-explained",title:"How Our Verified Local Safari Experts Work For You",category:"experts",categoryLabel:"Consultants & Booking",readTime:"3 min read",summary:"The benefits of booking through accredited local Ugandan operators and our platform protections.",keywords:["consultants","experts","booking","security","uto","trust","local guides"],content:{overview:"Our platform pairs travelers directly with licensed, vetted Ugandan safari consultants who live and breathe East African wildlife.",sections:[{heading:"Direct Field Expertise & Tailored Proposals",body:["Rather than dealing with an anonymous overseas call center, you correspond with local experts based in Kampala and Entebbe. They monitor real-time road conditions, lodge availability, and UWA permit registries.","You can share your customized itinerary draft directly from our planner to request expert review, route optimizations, or custom quotation."]},{heading:"UWA Permit Acquisition & Operational Support",body:["Securing gorilla and chimpanzee permits requires navigating Uganda Wildlife Authority reservation counters in Kampala. Your assigned consultant purchases and holds original printed biometric permit cards on your behalf.","On arrival at Entebbe Airport, your dedicated driver-guide welcomes you at the arrivals gate with your welcome packet and itinerary briefing."]}],actionPrompt:{text:"Browse our community of top-rated local Ugandan safari specialists.",targetView:"experts",buttonText:"Meet Our Experts"}}}],X$=[{id:"faq-1",category:"permits",question:"How far in advance should I book my gorilla trekking permit?",answer:"We strongly recommend booking at least 3 to 6 months in advance for peak dry seasons (June to August and December to February). Because UWA strictly caps visitors to 8 persons per habituated gorilla troop per day, permits for accessible sectors like Buhoma sell out quickly.",highlight:"3 to 6 months ahead recommended for peak season."},{id:"faq-2",category:"permits",question:"What is the minimum age for gorilla and chimpanzee trekking in Uganda?",answer:"The minimum age for gorilla trekking in Bwindi and Mgahinga is strictly 15 years old. The minimum age for chimpanzee tracking in Kibale Forest is 12 years old (or 15 years for the full Habituation Experience). Passports are verified at the ranger briefing station.",highlight:"Strictly 15 years for gorillas; 12+ for chimpanzees."},{id:"faq-3",category:"planning",question:"How many days do I need for a classic Uganda safari?",answer:"A comprehensive safari comb
4569ining mountain gorillas, chimpanzees, and savannah game drives requires 7 to 10 days. If you also wish to include Murchison Falls in the northwest or remote Kidepo Valley in the northeast, plan for 12 to 14 days to minimize exhausting driving hours.",highlight:"7–10 days covers gorillas, chimps, and savannah wildlife."},{id:"faq-4",category:"travel_essentials",question:"Can I get a visa upon arrival at Entebbe Airport?",answer:"No. Uganda ceased issuing visas on arrival. All foreign visitors requiring an entry visa must apply online in advance via the official government portal (visas.immigration.go.ug) and receive an electronic approval letter before traveling.",highlight:"No visa on arrival. Must apply online before flying."},{id:"faq-5",category:"travel_essentials",question:"Is a Yellow Fever vaccination card strictly required?",answer:"Yes. An official International Certificate of Vaccination against Yellow Fever is mandatory for all travelers entering Uganda. It must have been administered at least 10 days prior to your arrival date. Quarantine officers inspect the card at Entebbe before immigration.",highlight:"Mandatory for all arrivals aged 1 year and older."},{id:"faq-6",category:"travel_essentials",question:"Why do US Dollar banknotes need to be printed in 2013 or newer?",answer:"East African banks and foreign exchange bureaus enforce strict anti-counterfeiting policies and will reject any US Dollar bill issued prior to 2013, as well as any notes with tears, pen marks, or heavy folds. Always request fresh, crisp bills from your home bank.",highlight:"USD bills must be series 2013 or newer, clean and un-torn."},{id:"faq-7",category:"planning",question:"How physically demanding is gorilla trekking?",answer:'Treks can vary between 1 hour to 6+ hours of hiking through dense, untamed rainforest, steep volcanic slopes, tangled roots, and damp mud. A reasonable level of fitness is recommended. You can hire a local porter ($15–$20) to carry your gear and assist on challenging terrain, and "sedan chair" stretcher teams are available for travelers with mobility limitations.',highlight:"Hikes range from 1 to 6+ hours; porters and assistance available."},{id:"faq-8",category:"lodges",question:'What does "Full Board" include at safari lodges?',answer:"In Uganda, Full Board (FB) at safari lodges covers all three meals: breakfast, lunch (or a packed 
4569safari bush lunch during game drives), and a multi-course dinner. Luxury lodges frequently include house wines, local beers, and laundry, while budget and mid-range properties charge separately for alcoholic beverages.",highlight:"Breakfast, lunch, and dinner included in Full Board."},{id:"faq-9",category:"experts",question:"How does booking through a consultant work on this platform?",answer:'You can build an itinerary draft yourself, calculate costs, and click "Book with Consultant" or browse our Experts Hub to select a verified specialist. The consultant reviews your dates, secures UWA permits, confirms lodge rooms, and coordinates your private 4x4 safari cruiser and guide.',highlight:"Direct expert assistance with official UWA permits and logistics."},{id:"faq-10",category:"travel_essentials",question:"What clothes should I pack specifically for gorilla trekking?",answer:"Pack neutral-toned clothing (khaki, tan, olive green; avoid dark blue and black which attract tsetse flies). Bring sturdy, waterproof hiking boots, long moisture-wicking trousers tucked into socks, long-sleeve shirts for thorny brush, a waterproof rain jacket or poncho, and gardening gloves to grip stinging vegetation safely.",highlight:"Neutral colors, waterproof boots, long trousers, and gardening gloves."},{id:"faq-11",category:"lodges",question:"Are domestic flights available between parks?",answer:"Yes! Scheduled bush flights operated by Aerolink Uganda and Bar Aviation fly daily between Entebbe (EBB) and airstrips near the parks: Kihihi and Kisoro (Bwindi), Kasese and Mweya (Queen Elizabeth), Pakuba and Bugungu (Murchison Falls), and Kidepo. Flight times average 60 to 75 minutes.",highlight:"Daily flights reduce 8–10 hour drives to 70 minutes."}],Z$=[{name:"Uganda Wildlife Authority (UWA) Headquarters",role:"National Parks & Permit Reservations",phone:"+256 414 355000",email:"[email protected]",hours:"Mon - Fri: 8:00 AM - 5:00 PM EAT",description:"Central agency overseeing gorilla, chimp, and national park bookings.",badge:"Official Authority"},{name:"Uganda Tourism Board (UTB)",role:"Traveler Assistance & Tour Operator Verification",phone:"+256 414 342196",email:"[email protected]",hours:"Mon - Fri: 8:30 AM - 5:00 PM EAT",description:"National tourism promotion and visitor inquiry liaison.",badge:"Tourism Board"},{name:"Uganda Tourist Police Force (UTP)",role:"24/7 Dedicated Visitor Safety & Emergency Response",phone:"+256 800 199 699",hours:"24 Hours / 7 Days a week",description:"Specialized police division deployed along major national park tourist circuits.",badge:"24/7 Emergency"},{name:"AMREF Flying Doctors (Air Ambulance Evacuation)",role:"Emergency Bush Medical Evacuation",phone:"+254 20 699 2299",email:"[email protected]",hours:"24/7 Flight Operations",description:"Leading aero-medical evacuation service across East African national park airstrips.",badge:"Medical Flight"},{name:"Entebbe International Airport Information",role:"Flight Logistics & Airport Assistance",phone:"+256 414 353000",hours:"24 Hours / 7 Days a week",description:"Arrivals, customs inquiries, lost luggage, and ground transport desks.",badge:"Airport Info"}],$d=[{id:"pack-1",category:"Travel Documents & Health",item:"Passport valid for at least 6 months with 2+ blank pages",importance:"essential",tip:"Keep physical copies and digital backups in cloud storage."},{id:"pack-2",category:"Travel Documents & Health",item:"Yellow Fever Vaccination Certificate (Yellow Card)",importance:"essential",tip:"Inspected upon arrival at Entebbe Airport before immigration."},{id:"pack-3",category:"Travel Documents & Health",item:"Printed Uganda eVisa approval letter",importance:"essential",tip:"Ensure barcoded approval PDF is printed clearly."},{id:"pack-4",category:"Travel Documents & Health",item:"Malaria Prophylaxis (Malarone / Doxycycl
4569ine)",importance:"essential",tip:"Start regimen prior to arrival as prescribed by your travel physician."},{id:"pack-5",category:"Gorilla & Primate Trekking",item:"Sturdy waterproof hiking boots with ankle support",importance:"essential",tip:"Break boots in before the trip to prevent painful blisters on steep trails."},{id:"pack-6",category:"Gorilla & Primate Trekking",item:"Heavy-duty gardening or puncture-resistant gloves",importance:"essential",tip:"Invaluable for steadying yourself on thorny vegetation and stinging nettles."},{id:"pack-7",category:"Gorilla & Primate Trekking",item:"Waterproof gaiters or tall hiking socks",importance:"recommended",tip:"Tuck pants into socks to deter safari ants when stationary near gorillas."},{id:"pack-8",category:"Gorilla & Primate Trekking",item:"Breathable lightweight rain jacket or poncho",importance:"essential",tip:"Rainstorms in tropical rainforests can occur suddenly at any hour."},{id:"pack-9",category:"Safari & Wildlife Drives",item:"Binoculars (8x42 or 10x42 magnification)",importance:"essential",tip:"Crucial for tree-climbing lions, distant leopards, and rare bird species."},{id:"pack-10",category:"Safari & Wildlife Drives",item:"Neutral clothing (Khaki, beige, olive - avoid dark blue and black)",importance:"recommended",tip:"Dark blue and black attract tsetse flies; bright white alerts wildlife."},{id:"pack-11",category:"Safari & Wildlife Drives",item:"Wide-brim sun hat and UV sunglasses",importance:"essential",tip:"Protects from intense equatorial sun during open pop-up roof drives."},{id:"pack-12",category:"Electronics & Gear",item:"High-capacity power bank (15,000–20,000 mAh)",importance:"recommended",tip:"Many eco-lodges turn off generator power late at night."},{id:"pack-13",category:"Electronics & Gear",item:"UK-style 3-pin plug adapter (Type G)",importance:"essential",tip:"Standard wall socket throughout Uganda."},{id:"pack-14",category:"Cash & Valuables",item:"Crisp USD cash notes (Series 2013 or newer only)",importance:"essential",tip:"Higher denominations ($50, $100) receive optimal exchange rates."},{id:"pack-15",category:"Cash & Valuables",item:"Waterproof dry bag for camera & electronics",importance:"recommended",tip:"Shields gear during boat cruises and sudden forest downpours."}],eK=({article:n,onClose:e,onSelectRelatedArticle:t,allArticles:r})=>{const{navigateTo:s}=an();if(!n)return null;const a=r.filter(u=>u.id!==n.id&&(u.category===n.category||u.keywords.some(h=>n.keywords.includes(h)))).slice(0,3),c=()=>{var u,h;((u=n.content.actionPrompt)==null?void 0:u.targetView)==="itinerary-builder"?(s(Le.ItineraryBuilder),e()):((h=n.content.actionPrompt)==null?void 0:h.targetView)==="experts"&&(s(Le.ExpertsHub),e())};return o.jsx("div",{id:"article-reader-modal",className:"fixed inset-0 z-50 overflow-y-auto bg-black/60 backdrop-blur-xs flex items-center justify-center p-3 sm:p-6",children:o.jsxs("div",{className:"bg-white dark:bg-gray-850 rounded-2xl shadow-2xl max-w-3xl w-full max-h-[90vh] flex flex-col border border-gray-200 dark:border-gray-750 overflow-hidden animate-fadeIn",children:[o.jsxs("div",{className:"p-6 border-b border-gray-200 dark:border-gray-750 flex items-start justify-between bg-gray-50/80 dark:bg-gray-900/90",children:[o.jsxs("div",{className:"space-y-2 pr-4",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"px-2.5 py-0.5 rounded-full text-xs font-semibold bg-blue-100 text-blue-800 dark:bg-blue-900/60 dark:text-blue-300",children:n.categoryLabel}),o.jsxs("span",{className:"flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400",children:[o.jsx(Si,{className:"w-3.5 h-3.5"}),n.readTime]})]}),o.jsx("h2",{className:"text-xl sm:text-2xl font-black font-heading text-brand-dark dark:text-white leading-snug",children:n.title})]}),o.jsx("button",{onClick:e,"aria-label":"Close article",className:"p-2 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:o.jsx(bc,{className:"w-6 h-6"})})]}),o.jsxs("div",{className:"p-6 sm:p-8 overflow-y-auto space-y-6 text-gray-700 dark:text-gray-200",children:[o.jsx("div",{className:"p-4 rounded-xl bg-blue-50/70 dark:bg-blue-950/40 border border-blue-100 dar
4569k:border-blue-900/60 text-blue-950 dark:text-blue-200 text-base leading-relaxed",children:n.content.overview}),o.jsx("div",{className:"space-y-8",children:n.content.sections.map((u,h)=>o.jsxs("div",{className:"space-y-3",children:[o.jsxs("h3",{className:"text-lg font-bold font-heading text-brand-dark dark:text-white flex items-center gap-2",children:[o.jsx("span",{className:"w-6 h-6 rounded-full bg-blue-600 text-white text-xs flex items-center justify-center font-bold",children:h+1}),u.heading]}),u.body.map((f,p)=>o.jsx("p",{className:"text-sm sm:text-base leading-relaxed whitespace-pre-line text-gray-600 dark:text-gray-300",children:f},p)),u.bulletPoints&&o.jsx("ul",{className:"space-y-2 mt-2 ml-2",children:u.bulletPoints.map((f,p)=>o.jsxs("li",{className:"flex items-start gap-2 text-sm text-gray-700 dark:text-gray-300",children:[o.jsx(ox,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400 mt-0.5 flex-shrink-0"}),o.jsx("span",{children:f})]},p))}),u.tip&&o.jsxs("div",{className:"flex items-start gap-3 p-3.5 rounded-lg bg-emerald-50 dark:bg-emerald-950/40 border border-emerald-200 dark:border-emerald-800 text-emerald-900 dark:text-emerald-200 text-xs sm:text-sm",children:[o.jsx(fP,{className:"w-5 h-5 text-emerald-600 dark:text-emerald-400 flex-shrink-0 mt-0.5"}),o.jsxs("div",{children:[o.jsx("strong",{className:"font-semibold block",children:"Pro-Tip for Travelers:"}),o.jsx("span",{children:u.tip})]})]}),u.warning&&o.jsxs("div",{className:"flex items-start gap-3 p-3.5 rounded-lg bg-amber-50 dark:bg-amber-950/40 border border-amber-200 dark:border-amber-800 text-amber-900 dark:text-amber-200 text-xs sm:text-sm",children:[o.jsx(nS,{className:"w-5 h-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5"}),o.jsxs("div",{children:[o.jsx("strong",{className:"font-semibold block",children:"Official Notice / Caution:"}),o.jsx("span",{children:u.warning})]})]})]},h))}),n.content.actionPrompt&&o.jsxs("div",{className:"p-5 rounded-xl bg-gradient-to-r from-blue-600 to-indigo-700 text-white flex flex-col sm:flex-row items-center justify-between gap-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-bold text-base",children:"Plan with Confidence"}),o.jsx("p",{className:"text-sm text-blue-100",children:n.content.actionPrompt.text})]}),o.jsxs("button",{onClick:c,className:"px-5 py-2.5 rounded-full bg-white text-blue-700 hover:bg-blue-50 font-bold text-sm shadow-md transition-transform transform hover:scale-105 whitespace-nowrap flex items-center gap-1.5",children:[o.jsx("span",{children:n.content.actionPrompt.buttonText}),o.jsx(Bh,{className:"w-4 h-4"})]})]}),a.length>0&&o.jsxs("div",{className:"pt-6 border-t border-gray-200 dark:border-gray-700",children:[o.jsxs("h4",{className:"text-sm font-bold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-3 flex items-center gap-1.5",children:[o.jsx(rg,{className:"w-4 h-4"}),"Related Safari Guides"]}),o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:a.map(u=>o.jsxs("button",{onClick:()=>t(u),className:"p-3 text-left rounded-lg border border-gray-200 dark:border-gray-700 hover:border-blue-400 dark:hover:border-blue-500 hover:bg-blue-50/50 dark:hover:bg-blue-950/20 transition-all group",children:[o.jsx("span",{className:"text-xs font-semibold text-blue-600 dark:text-blue-400 block truncate",children:u.categoryLabel}),o.jsx("p",{className:"text-xs font-bold text-brand-dark dark:text-white line-clamp-2 mt-1 group-hover:text-blue-600 dark:group-hover:text-blue-400 transition-colors",children:u.title})]},u.id))})]})]}),o.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-800/90 border-t border-gray-200 dark:border-gray-700 flex justify-end",children:o.jsx("button",{onClick:e,className:"px-5 py-2 rounded-lg text-sm font-medium bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-800 dark:text-white transition-colors",children:"Close Guide"})})]})})},tK=({isOpen:n,onClose:e,initialCategory:t="General Inquiry"})=>{const{state:r}=an(),{loggedInUser:s}=r,[a,c]=R.useState({name:(s==null?void 0:s.name)||"",email:(s==null?void 0:s.email)||"",category:t,subject:"",message:"",tripReference:""}),[u,h]=R.useState(!1),[f,p]=R.useState(null),[y,b]=R.useState(null),[w,E]=R.use
4569State(!1),[N,S]=R.useState(""),I=cc.useRef(Date.now());if(!n)return null;const O=U=>{const{name:D,value:k}=U.target;c(_=>({..._,[D]:k})),p(null)},F=async U=>{if(U.preventDefault(),!a.name.trim()||!a.email.trim()||!a.message.trim()){p("Please fill in your name, email, and message.");return}if(N.trim().length>0||Date.now()-I.current<900){console.warn("[Security] Automated inquiry submission detected. Simulating ticket dispatch."),b("TKT-"+Math.random().toString(36).substring(2,8).toUpperCase());return}h(!0),p(null);try{const D=await ge.createSupportInquiry({name:a.name.trim(),email:a.email.trim(),category:a.category,subject:a.subject.trim()||`${a.category} Question`,message:a.message.trim(),tripReference:a.tripReference.trim()||void 0,status:"open"});b(D)}catch(D){console.error("Support inquiry error:",D),p(D.message||"Failed to submit inquiry. Please try again or email support.")}finally{h(!1)}},J=()=>{var U;y&&((U=navigator.clipboard)==null||U.writeText(y),E(!0),setTimeout(()=>E(!1),2500))},z=()=>{b(null),c({name:(s==null?void 0:s.name)||"",email:(s==null?void 0:s.email)||"",category:"General Inquiry",subject:"",message:"",tripReference:""}),e()};return o.jsx("div",{id:"support-inquiry-modal",className:"fixed inset-0 z-50 overflow-y-auto bg-black/60 backdrop-blur-xs flex items-center justify-center p-3 sm:p-6",children:o.jsxs("div",{className:"bg-white dark:bg-gray-850 rounded-2xl shadow-2xl max-w-lg w-full overflow-hidden border border-gray-200 dark:border-gray-750 animate-fadeIn",children:[o.jsxs("div",{className:"p-6 border-b border-gray-200 dark:border-gray-750 flex items-center justify-between bg-gray-50 dark:bg-gray-900/90",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx("div",{className:"p-2 rounded-lg bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-400",children:o.jsx(Gm,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-bold text-brand-dark dark:text-white",children:"Contact Safari Support"}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Direct inquiry to our Uganda Wildlife & Logistics team"})]})]}),o.jsx("button",{onClick:z,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",children:o.jsx(bc,{className:"w-5 h-5"})})]}),y?o.jsxs("div",{className:"p-8 text-center space-y-5",children:[o.jsx("div",{className:"w-16 h-16 bg-emerald-100 dark:bg-emerald-950/60 text-emerald-600 dark:text-emerald-400 rounded-full flex items-center justify-center mx-auto",children:o.jsx(Ga,{className:"w-10 h-10"})}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Inquiry Received!"}),o.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:["Thank you, ",a.name,". Our Kampala dispatch and safari planning team will review your inquiry and email you within 24 hours."]})]}),o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 p-4 rounded-xl border border-gray-200 dark:border-gray-600 flex items-center justify-between",children:[o.jsxs("div",{className:"text-left",children:[o.jsx("span",{className:"text-[10px] uppercase font-bold text-gray-400 dark:text-gray-400 block",children:"Support Ticket Reference"}),o.jsx("span",{className:"font-mono text-base font-bold text-blue-600 dark:text-blue-400",children:y})]}),o.jsxs("button",{onClick:J,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 transition-colors",children:[w?o.jsx(Jg,{className:"w-3.5 h-3.5 text-emerald-500"}):o.jsx($N,{className:"w-3.5 h-3.5"}),w?"Copied":"Copy"]})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"A copy of your inquiry has been logged for traveler tracking."}),o.jsx("button",{onClick:z,className:"w-full py-2.5 px-4 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-bold text-sm shadow-md transition-all",children:"Done"})]}):o.jsxs("form",{onSubmit:F,className:"p-6 space-y-4",children:[o.jsxs("div",{style:{position:"absolute",opacity:0,zIndex:-1,pointerEvents:"none",height:0,overflow:"hidden"},"aria-hidden":"true",children:[o.jsx("label",{htmlFor:"company_website_url",children:"Company Website"}),o.jsx("input",{id:"company_website_url",type:"text",name:"company_website_url",tabIndex:-1,autoComplete:"off",value:N,onChange:U=>S(U.target.value)})]}),f&&o.jsxs("div",{className:"p-3 bg-red-50 dark:bg-red-950/40 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-300 rounded-lg text-xs flex items-center gap-2",children:[o.jsx(uc,{className:"w-4 h-4 flex-shrink-0"}),o.jsx("span",{children:f})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-bold text-gray-700 dark:text-gray-300 mb-1",children:["Your Full Name ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"text",name:"name",value:a.name,onChange:O,required:!0,placeholder:"e.g. Sarah Jenkins",className:"w-full px-3.5 py-2.5 text-sm border rounded-lg border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-brand-dark dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-bold text-gray-700 dark:text-gray-300 mb-1",children:["Email Address ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"email",name:"email",value:a.email,onChange:O,required:!0,placeholder:"[email protected]",className:"w-full px-3.5 py-2.5 text-sm border rounded-lg border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-brand-dark dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-bold text-gray-700 dark:text-gray-300 mb-1",children:"Topic / Category"}),o.jsxs("select",{name:"category",value:a.category,onChange:O,className:"w-full px-3.5 py-2.5 text-sm border rounded-lg border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-brand-dark dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",children:[o.jsx("option",{value:"Itinerary Planning Advice",children:"Itinerary Planning Advice"}),o.jsx("option",{value:"Gorilla & Chimp Permits",children:"Gorilla & Chimp Permits"}),o.jsx("option",{value:"Lodge & Transport Logistics",children:"Lodge & Transport Logistics"}),o.jsx("option",{value:"Booking & Payment Question",children:"Booking & Payment Question"}),o.jsx("option",{value:"Consultant Verification",children:"Consultant Verification"}),o.jsx("option",{value:"General Inquiry",children:"General Inquiry"})]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-bold text-gray-700 dark:text-gray-300 mb-1",children:["Trip Reference # ",o.jsx("span",{className:"text-gray-400 font-normal",children:"(optional)"})]}),o.jsx("input",{type:"text",name:"tripReference",value:a.tripReference,onChange:O,placeholder:"e.g. ITIN-1234",className:"w-full px-3.5 py-2.5 text-sm border rounded-lg border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-brand-dark dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-bold text-gray-700 dark:text-gray-300 mb-1",children:"Subject"}),o.jsx("input",{type:"text",name:"subject",value:a.subject,onChange:O,placeholder:"Brief summary of what you need help with",className:"w-full px-3.5 py-2.5 text-sm border rounded-lg border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-brand-dark dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-bold text-gray-700 dark:text-gray-300 mb-1",children:["Message / Details ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("textarea",{name:"message",value:a.message,onChange:O,required:!0,rows:4,placeholder:"Please describe your dates, target destinations, permit inquiries, or any specific requirements...",className:"w-full px-3.5 py-2.5 text-sm border rounded-lg border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-brand-dark dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),o.jsxs("div",{className:"flex items-center justify-between pt-2",children:[o.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Typical response time: < 24 hrs"}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{type:"button",onClick:z,className:"px-4 py-2 text-xs font-medium text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",children:"Cancel"}),o.jsx("button",{type:"submit",disabled:u,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg bg-blue-600 hover:bg-blue-700 disabled:opacity-60 text-white font-bold text-xs shadow-md transition-all",children:u?o.jsxs(o.Fragment,{children:[o.jsx(At,{}),o.jsx("span",{children:"Sending..."})]}):o.jsxs(o.Fragment,{children:[o.jsx(ZN,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"Send Inquiry"})]})})]})]})]})]})})}
4569,VN="uganda_safari_packing_checked",nK=()=>{const[n,e]=R.useState(()=>{try{const E=localStorage.getItem(VN);return E?JSON.parse(E):{}}catch{return{}}}),[t,r]=R.useState("All"),[s,a]=R.useState(!1);R.useEffect(()=>{try{localStorage.setItem(VN,JSON.stringify(n))}catch{}},[n]);const c=E=>{e(N=>({...N,[E]:!N[E]}))},u=()=>{window.confirm("Reset your packing checklist progress?")&&e({})},h=()=>{const E={};$d.forEach(N=>{E[N.id]=!0}),e(E)},f=["All",...Array.from(new Set($d.map(E=>E.category)))],p=$d.filter(E=>{const N=t==="All"||E.category===t,S=!s||E.importance==="essential";return N&&S}),y=$d.length,b=$d.filter(E=>n[E.id]).length,w=Math.round(b/y*100);return o.jsxs("div",{id:"safari-checklist-container",className:"bg-white dark:bg-gray-850 rounded-xl shadow-md border border-gray-200 dark:border-gray-750 overflow-hidden",children:[o.jsxs("div",{className:"p-6 bg-gradient-to-r from-emerald-800 to-teal-900 text-white",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(eS,{className:"w-6 h-6 text-emerald-300"}),o.jsx("h3",{className:"text-xl font-bold font-heading",children:"Interactive Safari Readiness & Packing List"})]}),o.jsx("p",{className:"text-sm text-emerald-100 mt-1",children:"Check off essentials as you prepare for your Uganda expedition. Your progress is saved automatically."})]}),o.jsxs("div",{className:"bg-white/10 backdrop-blur-xs px-4 py-2.5 rounded-lg border border-white/20 text-center sm:text-right min-w-[140px]",children:[o.jsx("span",{className:"text-xs uppercase tracking-wider text-emerald-200 font-semibold block",children:"Readiness"}),o.jsxs("span",{className:"text-2xl font-black text-white",children:[w,"%"]}),o.jsxs("span",{className:"text-xs text-emerald-100 block",children:[b," of ",y," items"]})]})]}),o.jsx("div",{className:"w-full bg-black/20 h-2.5 rounded-full mt-4 overflow-hidden",children:o.jsx("div",{className:"bg-emerald-400 h-full transition-all duration-500 ease-out rounded-full",style:{width:`${w}%`}})})]}),o.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-900/80 border-b border-gray-200 dark:border-gray-750 flex flex-wrap items-center justify-between gap-3",children:[o.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-1 max-w-full",children:f.map(E=>o.jsx("button",{onClick:()=>r(E),className:`px-3 py-1 rounded-full text-xs font-medium whitespace-nowrap transition-colors ${t===E?"bg-emerald-600 text-white shadow-xs":"bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 border border-gray-200 dark:border-gray-700"}`,children:E},E))}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("button",{onClick:()=>a(!s),className:`flex items-center gap-1 px-3 py-1 rounded-lg text-xs font-medium border transition-colors ${s?"bg-amber-100 text-amber-800 border-amber-300 dark:bg-amber-900/40 dark:text-amber-300 dark:border-amber-700":"bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700"}`,children:[o.jsx(YN,{className:"w-3 h-3"}),o.jsx("span",{children:"Essentials Only"})]}),o.jsx("button",{onClick:h,className:"px-2.5 py-1 text-xs font-medium text-emerald-700 dark:text-emerald-300 hover:bg-emerald-50 dark:hover:bg-emerald-950/40 rounded transition-colors",children:"Check All"}),o.jsxs("button",{onClick:u,className:"flex items-center gap-1 px-2.5 py-1 text-xs font-medium text-gray-500 hover:text-red-600 dark:hover:text-red-400 rounded transition-colors",title:"Reset checklist",children:[o.jsx(MP,{className:"w-3 h-3"}),"Reset"]})]})]}),o.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-750 max-h-[440px] overflow-y-auto p-2",children:[p.map(E=>{const N=!!n[E.id];return o.jsxs("div",{onClick:()=>c(E.id),className:`p-3 rounded-lg flex items-start gap-3 cursor-pointer transition-colors ${N?"bg-emerald-50/60 dark:bg-emerald-950/30 text-gray-500 dark:text-gray-400":"hover:bg-gray-50 dark:hover:bg-gray-800 text-gray-800 dark:text-gray-200"}`,children:[o.jsx("button",{type:"button",className:"mt-0.5 flex-shrink-0 text-emerald-600 dark:text-emerald-400 focus:outline-none","aria-label":N?`Uncheck ${E.item}`:`Check ${E.item}`,children:N?o.jsx(Ga,{className:"w-5 h-5 text-emerald-600 dark:text-emerald-400 fill-emerald-100 dark:fill-emerald-950"}):o.jsx(QR,{className:"w-5 h-5 text-gray-300 dark:text-gray-600 hover:text-emerald-500"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:`text-sm font-medium ${N?"line-through opacity-75":""}`,children:E.item}),E.importance==="essential"&&o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300 border border-red-200 dark:border-red-800",children:"Essential"}),o.jsx("span",{className:"text-[11px] text-gray-400 dark:text-gray-500",children:E.category})]}),o.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 italic",children:["💡 ",E.tip]})]})]},E.id)}),p.length===0&&o.jsx("div",{className:"p-8 text-center text-gray-500 dark:text-gray-400 text-sm",children:"No checklist items match your selected filter."})]}),b===y&&y>0&&o.jsxs("div",{className:"p-3 bg-emerald-600 text-white text-center text-xs font-bold flex items-center justify-center gap-2",children:[o.jsx(dc,{className:"w-4 h-4"}),o.jsx("span",{children:"Congratulations! You are 100% safari-ready for Uganda!"})]})]})},rK=()=>o.jsxs("div",{id:"emergency-directory-container",className:"bg-white dark:bg-gray-850 rounded-xl shadow-md border border-gray-200 dark:border-gray-750 overflow-hidden",children:[o.jsxs("div",{className:"p-6 bg-gradient-to-r from-slate-900 to-blue-950 text-white flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xh,{className:"w-6 h-6 text-blue-400"}),o.jsx("h3",{className:"text-xl font-bold font-heading",children:"Official Directory & Field Assistance"})]}),o.jsx("p",{className:"text-sm text-blue-200 mt-1",children:"Official government bodies, wildlife authorities, and 24/7 emergency response in Uganda."})]}),o.jsx("span",{className:"hidden sm:inline-block px-3 py-1 rounded-full text-xs font-semibold bg-blue-800/80 text-blue-200 border border-blue-600/50",children:"Verified Field Contacts"})]}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-6 divide-y md:divide-y-0 md:divide-x divide-gray-100 dark:divide-gray-750",children:Z$.map((n,e)=>o.jsxs("div",{className:`p-4 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-800/60 transition-colors ${e%2!==0?"md:pl-6":""}`,children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-bold text-sm text-brand-dark dark:text-white",children:n.name}
4569),o.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 font-medium mt-0.5",children:n.role})]}),n.badge&&o.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider bg-blue-100 dark:bg-blue-900/50 text-blue-800 dark:text-blue-300",children:n.badge})]}),o.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-2",children:n.description}),o.jsxs("div",{className:"mt-3.5 space-y-1.5 text-xs",children:[o.jsxs("div",{className:"flex items-center gap-2 text-gray-700 dark:text-gray-300",children:[o.jsx(SP,{className:"w-3.5 h-3.5 text-emerald-600 dark:text-emerald-400 flex-shrink-0"}),o.jsx("a",{href:`tel:${n.phone.replace(/\s+/g,"")}`,className:"font-mono font-semibold hover:underline text-emerald-700 dark:text-emerald-400",children:n.phone})]}),n.email&&o.jsxs("div",{className:"flex items-center gap-2 text-gray-700 dark:text-gray-300",children:[o.jsx($g,{className:"w-3.5 h-3.5 text-blue-600 dark:text-blue-400 flex-shrink-0"}),o.jsx("a",{href:`mailto:${n.email}`,className:"hover:underline text-blue-600 dark:text-blue-400 truncate",children:n.email})]}),o.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400 text-[11px]",children:[o.jsx(Si,{className:"w-3.5 h-3.5 flex-shrink-0"}),o.jsx("span",{children:n.hours})]})]})]},e))})]}),sK=()=>{const{navigateTo:n}=an(),[e,t]=R.useState(""),[r,s]=R.useState("all"),[a,c]=R.useState("guides"),[u,h]=R.useState(null),[f,p]=R.useState(!1),[y,b]=R.useState("General Inquiry"),[w,E]=R.useState("faq-1"),[N,S]=R.useState(""),I=k=>{switch(k){case"planning":return o.jsx(jh,{className:"w-4 h-4"});case"permits":return o.jsx(xh,{className:"w-4 h-4"});case"lodges":return o.jsx(xP,{className:"w-4 h-4"});case"experts":return o.jsx(eM,{className:"w-4 h-4"});case"travel_essentials":return o.jsx(lP,{className:"w-4 h-4"});default:return o.jsx(sg,{className:"w-4 h-4"})}},O=R.useMemo(()=>{const k=e.toLowerCase().trim();return UN.filter(_=>{if(!(r==="all"||_.category===r))return!1;if(!k)return!0;const j=_.title.toLowerCase().includes(k),H=_.summary.toLowerCase().includes(k),L=_.keywords.some(ne=>ne.toLowerCase().includes(k)),ee=_.content.sections.some(ne=>ne.heading.toLowerCase().includes(k)||ne.body.some(G=>G.toLowerCase().includes(k)));return j||H||L||ee})},[e,r]),F=R.useMemo(()=>{const k=e.toLowerCase().trim();return X$.filter(_=>r==="all"||_.category===r?k?_.question.toLowerCase().includes(k)||_.answer.toLowerCase().includes(k):!0:!1)},[e,r]),J=k=>{E(_=>_===k?null:k)},z=k=>{t(k),s("all")},U=k=>{b(k),p(!0)},D=k=>{k.preventDefault(),N.trim()&&n(Le.TripDashboard)};return o.jsxs("div",{className:"max-w-6xl mx-auto w-full space-y-10 pb-16",children:[o.jsxs("section",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-brand-dark via-slate-900 to-blue-950 text-white p-8 sm:p-12 shadow-xl border border-slate-800",children:[o.jsxs("div",{className:"relative z-10 max-w-3xl mx-auto text-center space-y-6",children:[o.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-semibold bg-white/10 text-emerald-300 border border-white/15 backdrop-blur-xs",children:[o.jsx(dc,{className:"w-3.5 h-3.5 text-emerald-400"}),o.jsx("span",{children:"Uganda Safari Knowledge Base & Support"})]}),o.jsx("h1",{className:"text-3xl sm:text-5xl font-black font-heading tracking-tight text-white leading-tight",children:"How can we assist your Uganda journey?"}),o.jsx("p",{className:"text-sm sm:text-base text-gray-300 max-w-2xl mx-auto leading-relaxed",children:"Search official guides on mountain gorilla permits, optimal safari routing, national park tariffs, packing checklists, and working with local safari experts."}),o.jsxs("div",{className:"relative max-w-2xl mx-auto mt-6",children:[o.jsxs("div",{className:"relative flex items-center",children:[o.jsx(yh,{className:"w-5 h-5 text-gray-400 absolute left-4 pointer-events-none"}),o.jsx("input",{type:"text",value:e,onChange:k=>t(k.target.value),placeholder:"Search guides, gorilla permits, yellow fever, best seasons, vehicles...",className:"w-full pl-12 pr-10 py-3.5 bg-white dark:bg-gray-800 text-gray-900 dark:text-white rounded-xl shadow-lg text-sm sm:text-base placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 border border-gray-200 dark:border-gray-700"}),e&&o.jsx("button",{onClick:()=>t(""),className:"absolute right-3.5 p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Clear search",children:o.jsx(bc,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3 flex-wrap text-xs text-gray-300",children:[o.jsx("span",{className:"text-gray-400 font-medium",children:"Popular:"}),["Gorilla Permit $800","Yellow Fever","USD Series 2013+","Best Time to Visit","4x4 Land Cruiser","Packing List"].map(k=>o.jsx("button",{onClick:()=>z(k),className:"px-2.5 py-1 rounded-full bg-white/10 hover:bg-white/20 text-gray-200 hover:text-white transition-colors border border-white/10",children:k},k))]})]})]}),o.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mt-10 pt-8 border-t border-white/10 text-center",children:[o.jsxs("div",{className:"p-2",children:[o.jsx("span",{className:"block text-lg sm:text-xl font-bold text-white",children:"100% UWA"}),o.jsx("span",{className:"text-xs text-gray-400",children:"Official 2026 Tariffs"})]}),o.jsxs("div",{className:"p-2",children:[o.jsx("span",{className:"block text-lg sm:text-xl font-bold text-emerald-400",children:"Verified"}),o.jsx("span",{className:"text-xs text-gray-400",children:"Accredited Consultants"})]}),o.jsxs("div",{className:"p-2",children:[o.jsx("span",{className:"block text-lg sm:text-xl font-bold text-blue-400",children:"24/7 Hotline"}),o.jsx("span",{className:"text-xs text-gray-400",children:"Tourist Police & AMREF"})]}),o.jsxs("div",{className:"p-2",children:[o.jsx("span",{className:"block text-lg sm:text-xl font-bold text-amber-400",children:"Direct Quotes"}),o.jsx("span",{className:"text-xs text-gray-400",children:"Zero Middleman Markup"})]})]})]}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 border-b border-gray-200 dark:border-gray-700 pb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto pb-1 max-w-full",children:[o.jsxs("button",{onClick:()=>c("guides"),className:`flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-bold transition-colors whitespace-nowrap ${a==="guides"?"bg-blue-600 text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:[o.jsx(rg,{className:"w-4 h-4"}),o.jsxs("span",{children:["Safari Guides (",O.length,")"]})]}),o.jsxs("button",{onClick:()=>c("faqs"),className:`flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-bold transition-colors whitespace-nowrap ${a==="faqs"?"bg-blue-600 text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:[o.jsx(KR,{className:"w-4 h-4"}),o.jsxs("span",{children:["FAQs (",F.length,")"]})]}),o.jsxs("button",{onClick:()=>c("checklist"),className:`flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-bold transition-colors whitespace-nowrap ${a==="checklist"?"bg-emerald-600 text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:[o.jsx(eS,{className:"w-4 h-4"}),o.jsx("span",{children:"Packing & Readiness Checklist"})]}),o.jsxs("button",{onClick:()=>c("directory"),className:`flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-bold transition-colors whitespace-nowrap ${a==="directory"?"bg-blue-600 text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:[o.jsx(kP,{className:"w-4 h-4"}),o.jsx("span",{children:"Field Directory & Emergency"})]})]}),o.jsxs("button",{onClick:()=>U("General Inquiry"),className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg text-xs sm:text-sm font-bold bg-gray-100 dark:bg-gray-800 hover:bg-blue-50 dark:hover:bg-blue-950/40 text-blue-600 dar
4569k:text-blue-400 border border-gray-200 dark:border-gray-700 transition-colors",children:[o.jsx(Gm,{className:"w-4 h-4"}),o.jsx("span",{children:"Ask Support a Question"})]})]}),(a==="guides"||a==="faqs")&&o.jsx("div",{className:"flex items-center gap-2 overflow-x-auto pb-2",children:W$.map(k=>o.jsxs("button",{onClick:()=>s(k.id),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold whitespace-nowrap transition-all ${r===k.id?"bg-blue-600 text-white shadow-xs scale-105":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 border border-transparent dark:border-gray-700"}`,children:[I(k.id),o.jsx("span",{children:k.label})]},k.id))}),a==="guides"&&o.jsx("div",{className:"space-y-6",children:O.length===0?o.jsxs("div",{className:"text-center py-16 px-4 bg-gray-50 dark:bg-gray-800/40 rounded-xl border border-gray-200 dark:border-gray-700",children:[o.jsx(yh,{className:"w-10 h-10 text-gray-400 mx-auto mb-3"}),o.jsx("h3",{className:"text-lg font-bold text-gray-700 dark:text-gray-300",children:"No matching guides found"}),o.jsxs("p",{className:"text-sm text-gray-500 mt-1 max-w-md mx-auto",children:[`We couldn't find guides matching "`,e,'". Try a different term or submit a question to our team.']}),o.jsxs("div",{className:"flex justify-center gap-3 mt-4",children:[o.jsx("button",{onClick:()=>t(""),className:"px-4 py-2 text-xs font-medium bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-white rounded-lg",children:"Clear Search"}),o.jsx("button",{onClick:()=>U(e||"General Inquiry"),className:"px-4 py-2 text-xs font-medium bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:"Ask Our Team Directly"})]})]}):o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:O.map(k=>o.jsxs(On,{className:"!p-6 flex flex-col justify-between hover:shadow-xl transition-all duration-300 border border-gray-200 dark:border-gray-700 group cursor-pointer",children:[o.jsxs("div",{onClick:()=>h(k),className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"px-2.5 py-0.5 rounded-full text-xs font-semibold bg-blue-50 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300",children:k.categoryLabel}),o.jsxs("span",{className:"flex items-center gap-1 text-xs text-gray-400",children:[o.jsx(Si,{className:"w-3.5 h-3.5"}),k.readTime]})]}),o.jsx("h3",{className:"font-bold text-lg text-brand-dark dark:text-white group-hover:text-blue-600 dark:group-hover:text-blue-400 transition-colors leading-snug",children:k.title}),o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 line-clamp-3",children:k.summary})]}),o.jsxs("div",{className:"pt-4 mt-4 border-t border-gray-100 dark:border-gray-700 flex items-center justify-between",children:[o.jsxs("button",{onClick:()=>h(k),className:"text-xs font-bold text-blue-600 dark:text-blue-400 hover:text-blue-700 flex items-center gap-1",children:[o.jsx("span",{children:"Read Full Guide"}),o.jsx(Bh,{className:"w-3.5 h-3.5 transition-transform group-hover:translate-x-1"})]}),o.jsxs("span",{className:"text-[11px] text-gray-400 font-medium",children:[k.content.sections.length," sections"]})]})]},k.id))})}),a==="faqs"&&o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between pb-2",children:[o.jsx("h2",{className:"text-xl font-bold font-heading text-brand-dark dark:text-white",children:"Frequently Asked Questions"}),o.jsxs("span",{className:"text-xs text-gray-500",children:["Showing ",F.length," answered questions"]})]}),F.length===0?o.jsxs("div",{className:"text-center py-12 px-4 bg-gray-50 dark:bg-gray-800/40 rounded-xl",children:[o.jsx("p",{className:"text-gray-500",children:"No questions found matching your search."}),o.jsx("button",{onClick:()=>U("FAQ Question"),className:"mt-3 text-xs font-bold text-blue-600 hover:underline",children:"Submit your question to our help desk →"})]}):o.jsx("div",{className:"space-y-3",children:F.map(k=>{const _=w===k.id;return o.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-xl bg-white dark:bg-gray-800 overflow-hidden transition-shadow duration-200 hover:shadow-xs",children:[o.jsxs("button",{onClick:()=>J(k.id),className:"w-full text-left p-4 sm:p-5 flex items-start justify-between gap-4 focus:outline-none","aria-expanded":_,children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-blue-600 dar
4569k:text-blue-400",children:k.category}),o.jsx("h3",{className:"font-bold text-base sm:text-lg text-brand-dark dark:text-white",children:k.question})]}),o.jsx("div",{className:"mt-1 p-1 rounded-full text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 flex-shrink-0",children:_?o.jsx(MR,{className:"w-5 h-5 transition-transform"}):o.jsx(ax,{className:"w-5 h-5 transition-transform"})})]}),_&&o.jsxs("div",{className:"px-5 pb-5 pt-1 border-t border-gray-100 dark:border-gray-700/60 text-gray-600 dark:text-gray-300 text-sm leading-relaxed space-y-3 animate-fadeIn",children:[o.jsx("p",{children:k.answer}),k.highlight&&o.jsxs("div",{className:"p-3 bg-blue-50 dark:bg-blue-950/40 rounded-lg text-blue-900 dark:text-blue-200 text-xs font-medium border border-blue-100 dark:border-blue-900/50 flex items-center gap-2",children:[o.jsx(dc,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 flex-shrink-0"}),o.jsxs("span",{children:[o.jsx("strong",{children:"Key takeaway:"})," ",k.highlight]})]})]})]},k.id)})})]}),a==="checklist"&&o.jsx("div",{className:"space-y-4",children:o.jsx(nK,{})}),a==="directory"&&o.jsx("div",{className:"space-y-4",children:o.jsx(rK,{})}),o.jsxs("section",{className:"bg-gradient-to-r from-gray-50 to-blue-50 dark:from-gray-800 dark:to-gray-800/80 p-6 sm:p-8 rounded-2xl border border-gray-200 dark:border-gray-700 flex flex-col md:flex-row items-center justify-between gap-6",children:[o.jsxs("div",{className:"space-y-1 text-center md:text-left",children:[o.jsxs("div",{className:"inline-flex items-center gap-1.5 text-xs font-bold text-blue-700 dark:text-blue-300 uppercase tracking-wider",children:[o.jsx(Si,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"Already have a reservation?"})]}),o.jsx("h3",{className:"text-xl font-bold font-heading text-brand-dark dark:text-white",children:"Check Your Trip Status & Documents"}),o.jsx("p",{className:"text-xs sm:text-sm text-gray-600 dark:text-gray-300 max-w-xl",children:"Access your confirmed dates, assigned driver-guide details, UWA permit cards, and invoice breakdown in your traveler dashboard."})]}),o.jsxs("form",{onSubmit:D,className:"flex items-center gap-2 w-full md:w-auto",children:[o.jsx("input",{type:"text",value:N,onChange:k=>S(k.target.value),placeholder:"Enter Itinerary ID or Email",className:"px-3.5 py-2.5 text-sm bg-white dark:bg-gray-700 text-brand-dark dark:text-white border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:outline-none flex-1 md:w-64"}),o.jsx("button",{type:"submit",className:"px-4 py-2.5 bg-blue-600 hover:bg-blue-700 text-white font-bold text-xs sm:text-sm rounded-lg shadow-sm whitespace-nowrap transition-colors",children:"Check Status"})]})]}),o.jsxs("section",{className:"text-center bg-white dark:bg-gray-800 p-8 sm:p-12 rounded-2xl border border-gray-200 dark:border-gray-700 shadow-sm space-y-4",children:[o.jsx("div",{className:"w-12 h-12 rounded-full bg-blue-100 dark:bg-blue-900/50 text-blue-600 dark:text-blue-400 flex items-center justify-center mx-auto",children:o.jsx(Gm,{className:"w-6 h-6"})}),o.jsx("h2",{className:"text-2xl sm:text-3xl font-bold font-heading text-brand-dark dark:text-white",children:"Still have a specific safari question?"}),o.jsx("p",{className:"text-sm sm:text-base text-gray-600 dark:text-gray-300 max-w-xl mx-auto",children:"Our team of Kampala-based wildlife experts and logistical coordinators are here to help you craft an unforgettable journey across Uganda."}),o.jsxs("div",{className:"flex items-center justify-center gap-4 pt-2 flex-wrap",children:[o.jsxs("button",{onClick:()=>U("Custom Safari Planning"),className:"bg-blue-600 text-white font-bold py-3 px-8 rounded-full hover:bg-blue-700 transition-transform transform hover:scale-105 shadow-md flex items-center gap-2 text-sm",children:[o.jsx(Gm,{className:"w-4 h-4"}),o.jsx("span",{children:"Contact Safari Support"})]}),o.jsx("button",{onClick:()=>n(Le.ItineraryBuilder),className:"bg-gray-100 dark:bg-gray-700 text-brand-dark dark:text-white font-bold py-3 px-8 rounded-full hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors text-sm",children:"Open Itinerary Planner"}),o.jsxs("button",{onClick:()=>
4569n(Le.ExpertsHub),className:"text-blue-600 dark:text-blue-400 font-bold py-3 px-4 hover:underline text-sm flex items-center gap-1",children:[o.jsx("span",{children:"Browse Local Experts"}),o.jsx(Bh,{className:"w-4 h-4"})]})]})]}),o.jsx(eK,{article:u,onClose:()=>h(null),onSelectRelatedArticle:k=>h(k),allArticles:UN}),o.jsx(tK,{isOpen:f,onClose:()=>p(!1),initialCategory:y})]})},iK=({itineraries:n,previousItineraries:e,consultants:t,dateRange:r,enableCompare:s,activePreset:a})=>{const{state:{destinations:c,lodges:u}}=an(),[h,f]=R.useState(""),[p,y]=R.useState(!0),b=R.useCallback(N=>{const S=N.filter(_=>_.status==="confirmed"),I=S.reduce((_,M)=>_+M.totalPrice,0),O=S.reduce((_,M)=>{const j=t.find(ee=>ee.id===M.consultantId),H=(j==null?void 0:j.commissionRate)||0,L=M.totalPrice*.8;return _+L*H},0),F=N.reduce((_,M)=>(_[M.status]=(_[M.status]||0)+1,_),{}),z=t.map(_=>{const j=S.filter(H=>H.consultantId===_.id).reduce((H,L)=>H+L.totalPrice,0);return{name:_.name,totalValue:j}}).sort((_,M)=>M.totalValue-_.totalValue)[0]||{name:"N/A"},U=N.flatMap(_=>_.stops).reduce((_,M)=>(_[M.destinationId]=(_[M.destinationId]||0)+1,_),{}),D=Object.keys(U).sort((_,M)=>U[M]-U[_])[0],k=c.find(_=>_.id===D)||{name:"N/A"};return{totalBookings:I,platformRevenue:O,planningCount:F.planning||0,pendingCount:F.pending_confirmation||0,totalUsers:new Set(N.map(_=>_.travelerEmail)).size,topConsultant:z,topDestination:k,confirmedCount:F.confirmed||0}},[t]),{currentPeriodMetrics:w,previousPeriodMetrics:E}=R.useMemo(()=>({currentPeriodMetrics:b(n),previousPeriodMetrics:b(e)}),[n,e,b]);return R.useEffect(()=>{if(t.length>0){y(!0);const N=I=>({totalBookings:I.totalBookings.toFixed(0),platformRevenue:I.platformRevenue.toFixed(0),planningCount:I.planningCount,confirmedCount:I.confirmedCount,topConsultantName:I.topConsultant.name,topDestinationName:I.topDestination.name}),S=a==="all"?`All Time (since ${r.start.toLocaleDateString()})`:`${r.start.toLocaleDateString()} - ${r.end.toLocaleDateString()}`;NI.getAdminReportSummary(N(w),s?N(E):null,S).then(I=>f(I)).finally(()=>y(!1))}},[w,E,t,s,r,a]),o.jsxs("div",{className:"space-y-6",children:[o.jsxs(On,{className:"!p-6 bg-blue-50 dark:bg-gray-800 border-blue-200 dark:border-blue-900",children:[o.jsxs("h3",{className:"text-lg font-bold text-brand-dark dark:text-white font-heading flex items-center gap-2",children:[o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-blue-500",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M11.3 1.046A1 1 0 0112 2v5h4a1 1 0 01.82 1.573l-7 10A1 1 0 018 18v-5H4a1 1 0 01-.82-1.573l7-10a1 1 0 011.12-.38z",clipRule:"evenodd"})}),"AI-Powered Summary"]}),p?o.jsxs("div",{className:"flex items-center gap-2 mt-2 text-sm text-gray-500 dark:text-gray-400",children:[o.jsx(At,{}),o.jsx("span",{children:"Generating insights..."})]}):o.jsx("p",{className:"mt-2 text-brand-dark dark:text-gray-300 leading-relaxed",children:h})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v.01"})}),title:"Total Booking Value",value:`$${w.totalBookings.toLocaleString(void 0,{maximumFractionDigits:0})}`,previousValue:s?E.totalBookings:void 0,description:"From confirmed trips (GBV)"}),o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 9V7a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2m2 4h10a2 2 0 002-2v-6a2 2 0 00-2-2H9a2 2 0 00-2 2v6a2 2 0 002 2zm7-5a2 2 0 11-4 0 2 2 0 014 0z"})}),title:"Platform Revenue",value:`$${w.platformRevenue.toLocaleString(void 0,{maximumFractionDigits:0})}`,previousValue:s?E.platformRevenue:void 0,description:"Estimated commission earned"}),o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"})}),title:"Active Itineraries",value:w.planningCount+w.pendingCount,previousValue:s?E.planningCount+E.pendingCount:void 0,description:`${w.planningCount} Planning, ${w.pendingCount} Pending`}),o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M15 21v-2a4 4 0 00-4-4H9a4 4 0 00-4 4v2"})}),title:"Total Users",value:w.totalUsers,previousValue:s?E.totalUsers:void 0,description:"Unique traveler emails"})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs(On,{className:"!p-6",children:[o.jsx("h3",{className:"font-bold text-brand-dark dark:text-white",children:"Itinerary Funnel"}),o.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Chart coming soon for ",r.start.toLocaleDateString()," - ",r.end.toLocaleDateString()]})]}),o.jsxs(On,{className:"!p-6",children:[o.jsx("h3",{className:"font-bold text-brand-dark dark:text-white",children:"Bookings Over Time"}),o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Time comparison graph coming soon..."})]})]})]})},fy=n=>n>=1e3?`$${(n/1e3).toFixed(1)}k`:`$${n.toFixed(0)}`,SI=({data:n,compareData:e=[],title:t,className:r=""})=>{const[s,a]=R.useState(null),c={top:20,right:20,bottom:40,left:50},u=500,h=300,{points:f,comparePoints:p,yTicks:y,xTicks:b,maxY:w}=R.useMemo(()=>{const S=[...n.map(L=>L.value),...e.map(L=>L.value)],O=(S.length>0?Math.max(...S):100)*1.1,F=[...n.map(L=>L.day),...e.map(L=>L.day)],J=F.length>0?Math.max(...F):1,z=L=>c.left+(L-1)/(J-1)*(u-c.left-c.right),U=L=>h-c.bottom-L/O*(h-c.top-c.bottom),D=n.map(L=>`${z(L.day)},${U(L.value)}`).join(" "),k=e.map(L=>`${z(L.day)},${U(L.value)}`).join(" "),_=5,M=Array.from({length:_+1},(L,ee)=>{const ne=O/_*ee;return{value:ne,y:U(ne)}}),j=Math.min(J,7),H=Array.from({length:j},(L,ee)=>{const ne=Math.ceil(1+ee/(j-1)*(J-1));return{day:ne,x:z(ne)}});return{points:D,comparePoints:k,yTicks:M,xTicks:H,maxY:O}},[n,e,u,h,c]),E=S=>{const I=S.currentTarget.getBoundingClientRect(),O=S.clientX-I.left,F=Math.round(1+(O-c.left)/(u-c.left-c.right)*(n.length-1));if(F>=1&&F<=n.length){const J=n[F-1],z=e.find(k=>k.day===F),U=k=>c.left+(k-1)/(n.length-1)*(u-c.left-c.right),D=k=>h-c.bottom-k/w*(h-c.top-c.bottom);a({x:U(J.day),y:D(J.value),day:J.day,value:J.value,compareValue:z==null?void 0:z.value})}else a(null)},N=()=>{a(null)};return o.jsxs("div",{className:`bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md border border-gray-200 dark:border-gray-700 ${r}`,children:[o.jsx("h3",{className:"text-sm font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2",children:t}),o.jsxs("div",{className:"relative",children:[o.jsxs("svg",{viewBox:`0 0 ${u} ${h}`,onMouseMove:E,onMouseLeave:N,children:[y.map(S=>o.jsxs("g",{children:[o.jsx("line",{x1:c.left,y1:S.y,x2:u-c.right,y2:S.y,stroke:"var(--grid-color, #E5E7EB)",className:"dark:stroke-gray-700",strokeDasharray:"2,2"}),o.jsx("text",{x:c.left-8,y:S.y+3,textAnchor:"end",fontSize:"10",fill:"var(--text-color, #6B7280)",className:"dark:fill-gray-400",children:fy(S.value)})]},S.value)),b.map(S=>o.jsx("g",{children:o.jsxs("text",{x:S.x,y:h-c.bottom+15,textAnchor:"middle",fontSize:"10",fill:"var(--text-color, #6B7280)",className:"dark:fill-gray-400",children:["Day ",S.day]})},S.day)),o.jsx("line",{x1:c.left,y1:c.top,x2:c.left,y2:h-c.bottom,stroke:"var(--axis-color, #D1D5DB)",className:"dark:stroke-gray-600"}),o.jsx("line",{x1:c.left,y1:h-c.bottom,x2:u-c.right,y2:h-c.bottom,stroke:"var(--axis-color, #D1D5DB)",className:"dark:stroke-gray-600"}),e.length>0&&o.jsx("polyline",{fill:"none",stroke:"var(--compare-line-color, #9CA3AF)",className:"dark:stroke-gray-500",strokeWidth:"2",strokeDasharray:"4,4",points:p}),o.jsx("polyline",{fill:"none",stroke:"var(--line-color, #3B82F6)",className:"dark:stroke-blue-400",strokeWidth:"2",points:f}),s&&o.jsxs("g",{children:[o.jsx("line",{x1:s.x,y1:c.top,x2:s.x,y2:h-c.bottom,stroke:"var(--tooltip-line-color, #9CA3AF)",className:"dark:stroke-gray-500",strokeWidth:"1"}),o.jsx("circle",{cx:s.x,cy:s.y,r:"4",fill:"var(--line-color, #3B82F6)",className:"dark:fill-blue-400",stroke:"white",strokeWidth:"2"}),o.jsx("foreignObject",{x:s.x>u/2?s.x-130:s.x+10,y:c.top,width:"120",height:"80",children:o.jsxs("div",{className:"bg-brand-dark text-white p-2 rounded-md shadow-lg text-xs font-sans",children:[o.jsxs("div",{className:"font-bold mb-1",children:["Day ",s.day]}),o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-blue-300",children:"Current:"}),o.jsx("span",{children:fy(s.value)})]}),s.compareValue!==void 0&&o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-gray-400",children:"Previous:"}),o.jsx("span",{children:fy(s.compareValue)})]})]})})]})]}),o.jsxs("div",{className:"flex justify-center items-center gap-6 mt-2 text-xs text-gray-600 dark:text-gray-400",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-3 h-3 bg-blue-500 dark:bg-blue-400 rounded-sm"}),o.jsx("span",{children:"Current Period"})]}),e.length>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-3 h-0.5 border-t-2 border-dashed border-gray-400 dark:border-gray-500"}
4569),o.jsx("span",{children:"Previous Period"})]})]})]})]})},aK=({itineraries:n,previousItineraries:e,consultants:t,reviews:r,dateRange:s,compareDateRange:a,enableCompare:c,activePreset:u})=>{var U;const{state:{destinations:h,lodges:f}}=an(),[p,y]=R.useState(null),[b,w]=R.useState({key:"totalRevenue",direction:"descending"}),E=R.useMemo(()=>t.map(D=>{const k=n.filter(ae=>ae.consultantId===D.id),_=k.filter(ae=>ae.status==="confirmed"),M=r.filter(ae=>ae.consultantId===D.id),j=_.reduce((ae,Te)=>ae+Te.totalPrice,0),H=_.reduce((ae,Te)=>{const K=Te.totalPrice*.8;return ae+K*(D.commissionRate||0)},0),L=k.length,ee=L>0?_.length/L*100:0,ne=M.length>0?M.reduce((ae,Te)=>ae+Te.rating,0)/M.length:0,G=_.length>0?j/_.length:0,W=_.reduce((ae,Te)=>ae+Te.duration,0),X=_.length>0?W/_.length:0;return{id:D.id,name:D.name,imageUrl:D.imageUrl,totalItineraries:L,confirmedItineraries:_.length,conversionRate:ee,totalRevenue:j,avgRating:ne,reviewCount:M.length,commissionPaid:H,avgBookingValue:G,avgTripDuration:X}}),[n,t,r]),N=R.useMemo(()=>{let D=[...E];return b.key&&D.sort((k,_)=>k[b.key]<_[b.key]?b.direction==="ascending"?-1:1:k[b.key]>_[b.key]?b.direction==="ascending"?1:-1:0),D},[E,b]);R.useEffect(()=>{!p&&N.length>0&&y(N[0].id)},[N,p]);const S=R.useMemo(()=>{if(!p||u==="all")return null;const D=[...n,...e],k=(j,H)=>{const L=new Date(new Date(j).setHours(0,0,0,0)),ee=new Date(new Date(H).setHours(23,59,59,999)),ne=D.filter(ae=>{const Te=new Date(ae.startDate);return ae.consultantId===p&&ae.status==="confirmed"&&Te>=L&&Te<=ee}).sort((ae,Te)=>new Date(ae.startDate).getTime()-new Date(Te.startDate).getTime()),G=Math.round((ee.getTime()-L.getTime())/(1e3*3600*24))+1,W=Array(G).fill(0);ne.forEach(ae=>{const Te=new Date(new Date(ae.startDate).setHours(0,0,0,0)),K=Math.round((Te.getTime()-L.getTime())/(1e3*3600*24));K>=0&&K<G&&(W[K]+=ae.totalPrice)});let X=0;return W.map((ae,Te)=>(X+=ae,{day:Te+1,value:X}))},_=k(s.start,s.end),M=c?k(a.start,a.end):[];return{currentData:_,previousData:M}},[p,n,e,s,a,c,u]),I=R.useMemo(()=>{var L;if(!p)return null;const D=E.find(ee=>ee.id===p);if(!D)return null;const k=n.filter(ee=>ee.consultantId===p&&ee.status==="confirmed"),_=k.flatMap(ee=>ee.stops).reduce((ee,ne)=>(ee[ne.destinationId]=(ee[ne.destinationId]||0)+1,ee),{}),M=Object.keys(_).sort((ee,ne)=>_[ne]-_[ee])[0],j=((L=h.find(ee=>ee.id===M))==null?void 0:L.name)||"N/A",H=k.length>0?Math.max(...k.map(ee=>ee.totalPrice)):0;return{avgBookingValue:D.avgBookingValue,topDestination:j,highestBookingValue:H}},[p,E,n]),O=D=>{let k="ascending";b.key===D&&b.direction==="ascending"?k="descending":b.key===D&&b.direction==="descending"&&(k="ascending"),w({key:D,direction:k})},F=({sortKey:D,label:k,className:_=""})=>o.jsx("th",{scope:"col",className:`px-4 py-3 ${_}`,children:o.jsxs("button",{onClick:()=>O(D),className:"flex items-center gap-1 group",children:[k,o.jsxs("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity",children:[b.key===D&&b.direction==="descending"&&"↓",b.key===D&&b.direction==="ascending"&&"↑",b.key!==D&&"↕"]})]})}),J=({label:D,value:k})=>o.jsxs("div",{className:"flex justify-between items-baseline py-2 border-b border-gray-100 dark:border-gray-700",children:[o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:D}),o.jsx("p",{className:"font-bold text-brand-dark dark:text-gray-200",children:k})]}),z=((U=t.find(D=>D.id===p))==null?void 0:U.name)||"";return o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsx("div",{className:"lg:col-span-2",children:o.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-700 overflow-x-auto",children:o.jsxs("table",{className:"w-full text-sm text-left text-gray-500 dark:text-gray-400",children:[o.jsx("thead",{className:"text-xs text-gray-700 dark:text-gray-400 uppercase bg-gray-50 dark:bg-gray-700",children:o.jsxs("tr",{children:[o.jsx(F,{sortKey:"name",label:"Consultant"}),o.jsx(F,{sortKey:"totalRevenue",label:"Revenue",className:"text-right"}),o.jsx(F,{sortKey:"avgBookingValue",label:"Avg. Value",className:"text-right"}),o.jsx(F,{sortKey:"avgTripDuration",label:"Avg. Duration",className:"text-right"}
4569),o.jsx(F,{sortKey:"conversionRate",label:"Conv. Rate",className:"text-right"}),o.jsx(F,{sortKey:"avgRating",label:"Rating",className:"text-right"})]})}),o.jsx("tbody",{children:N.map(D=>o.jsxs("tr",{onClick:()=>y(D.id),className:`border-b dark:border-gray-700 cursor-pointer transition-colors ${p===D.id?"bg-blue-50 dark:bg-gray-700/50":"bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-600"}`,children:[o.jsx("td",{className:"px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("img",{src:D.imageUrl,alt:D.name,className:"w-8 h-8 rounded-full object-cover"}),o.jsx("span",{className:"font-semibold text-brand-dark dark:text-white whitespace-nowrap",children:D.name})]})}),o.jsxs("td",{className:"px-4 py-3 text-right font-medium text-gray-800 dark:text-gray-200",children:["$",D.totalRevenue.toLocaleString(void 0,{maximumFractionDigits:0})]}),o.jsxs("td",{className:"px-4 py-3 text-right",children:["$",D.avgBookingValue.toLocaleString(void 0,{maximumFractionDigits:0})]}),o.jsxs("td",{className:"px-4 py-3 text-right",children:[D.avgTripDuration.toFixed(1)," nights"]}),o.jsxs("td",{className:"px-4 py-3 text-right",children:[D.conversionRate.toFixed(1),"%"]}),o.jsx("td",{className:"px-4 py-3 text-right",children:D.reviewCount>0?`${D.avgRating.toFixed(2)} (${D.reviewCount})`:"N/A"})]},D.id))})]})})}),o.jsxs("div",{className:"lg:col-span-1 space-y-6",children:[S?o.jsx(SI,{title:`Revenue Growth for ${z}`,data:S.currentData,compareData:c?S.previousData:[]}):o.jsx(On,{className:"!p-6 min-h-[300px] flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("h3",{className:"text-sm font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-4",children:"Revenue Growth"}),o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:u==="all"?"Growth chart is not available for 'All Time'.":"Select a consultant to view their growth."})]})}),I&&o.jsxs(On,{className:"!p-6",children:[o.jsxs("h3",{className:"text-sm font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2",children:["Highlights for ",z]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(J,{label:"Avg. Booking Value",value:`$${I.avgBookingValue.toLocaleString(void 0,{maximumFractionDigits:0})}`}
4569),o.jsx(J,{label:"Top Destination",value:I.topDestination}),o.jsx(J,{label:"Highest Value Trip",value:`$${I.highestBookingValue.toLocaleString(void 0,{maximumFractionDigits:0})}`})]})]})]})]})},oK=({destinationData:n,allItineraries:e,allConsultants:t,dateRange:r,onClose:s})=>{const{state:{destinations:a,lodges:c}}=an(),u=R.useMemo(()=>{var U;const h=e.filter(D=>{const k=new Date(D.startDate),_=k>=r.start&&k<=r.end,M=D.stops.some(j=>j.destinationId===n.id);return D.status==="confirmed"&&_&&M}),f=h.reduce((D,k)=>D+k.travelerCount,0);let p=0;h.forEach(D=>{const k=D.stops.reduce((j,H)=>j+H.numberOfNights,0);if(k===0)return;const _=D.totalPrice/k,M=D.stops.filter(j=>j.destinationId===n.id).reduce((j,H)=>j+H.numberOfNights,0);p+=_*M});const y=f>0?p/f:0,b=h.reduce((D,k)=>{const _=k.consultantId;return D[_]=(D[_]||0)+1,D},{}),w=Object.keys(b).sort((D,k)=>b[k]-b[D])[0],E=((U=t.find(D=>D.id===w))==null?void 0:U.name)||"N/A",N={};h.forEach(D=>{const k=D.stops.reduce((L,ee)=>L+ee.numberOfNights,0);if(k===0)return;const _=D.totalPrice/k,M=D.stops.filter(L=>L.destinationId===n.id).reduce((L,ee)=>L+ee.numberOfNights,0),j=_*M,H=new Date(D.startDate).toLocaleString("default",{month:"short",year:"numeric"});N[H]=(N[H]||0)+j});const S=Object.entries(N).map(([D,k])=>({label:D,value:k})),I={};h.forEach(D=>{D.stops.forEach(k=>{k.destinationId===n.id&&k.lodgeId&&(I[k.lodgeId]=(I[k.lodgeId]||0)+k.numberOfNights)})});const O=Object.entries(I).map(([D,k])=>{var _;return{label:((_=c.find(M=>M.id===D))==null?void 0:_.name)||"Unknown Lodge",value:k}}).sort((D,k)=>k.value-D.value).slice(0,5),F=a.find(D=>D.id===n.id),J={};h.forEach(D=>{D.stops.forEach(k=>{k.destinationId===n.id&&k.activities.flat().forEach(_=>{J[_]=(J[_]||0)+D.travelerCount})})});const z=Object.entries(J).map(([D,k])=>{var _;return{label:((_=F==null?void 0:F.activities.find(M=>M.id===D))==null?void 0:_.name)||"Unknown",value:k}}).sort((D,k)=>k.value-D.value).slice(0,5);return{totalVisitors:f,totalRevenue:p,avgSpendPerVisitor:y,topConsultantName:E,monthlyRevenueForBarChart:S,lodgePopularityData:O,activityPopularityData:z}},[n.id,e,t,r]);return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-60 flex justify-center items-center z-50 p-4",onClick:s,children:o.jsxs("div",{className:"bg-gray-100 dark:bg-gray-900 rounded-lg shadow-xl w-full max-w-5xl m-4 flex flex-col max-h-[90vh]",onClick:h=>h.stopPropagation(),children:[o.jsxs("header",{className:"flex justify-between items-center p-6 border-b dark:border-gray-700 flex-shrink-0 bg-white dark:bg-gray-800 rounded-t-lg",children:[o.jsxs("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:[n.name," Insights"]}),o.jsx("button",{onClick:s,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("main",{className:"p-6 space-y-6 overflow-y-auto",children:[o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v.01"})}),title:"Total Revenue",value:`$${u.totalRevenue.toLocaleString(void 0,{maximumFractionDigits:0})}`}),o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M15 21v-2a4 4 0 00-4-4H9a4 4 0 00-4 4v2"})}),title:"Total Visitors",value:u.totalVisitors.toLocaleString()}),o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 9V7a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2m2 4h10a2 2 0 002-2v-6a2 2 0 00-2-2H9a2 2 0 00-2 2v6a2 2 0 002 2zm7-5a2 2 0 11-4 0 2 2 
45690 014 0z"})}),title:"Avg Spend / Visitor",value:`$${u.avgSpendPerVisitor.toLocaleString(void 0,{maximumFractionDigits:0})}`}),o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.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"})}),title:"Top Consultant",value:u.topConsultantName})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsx(ph,{title:"Monthly Revenue",data:u.monthlyRevenueForBarChart}),o.jsx(ph,{title:"Lodge Popularity (by Nights Booked)",data:u.lodgePopularityData}),o.jsx("div",{className:"lg:col-span-2",children:o.jsx(ph,{title:"Activity Popularity (by # of people)",data:u.activityPopularityData})})]})]})]})})},lK=({itineraries:n,consultants:e,dateRange:t})=>{const{state:{destinations:r,lodges:s}}=an(),[a,c]=R.useState({key:"totalRevenue",direction:"descending"}),[u,h]=R.useState(null),f=R.useMemo(()=>{const w=n.filter(N=>N.status==="confirmed"),E={};return w.forEach(N=>{const S=N.stops.reduce((O,F)=>O+F.numberOfNights,0);if(S===0)return;const I=N.totalPrice/S;N.stops.forEach(O=>{E[O.destinationId]||(E[O.destinationId]={totalVisitors:0,totalNights:0,totalRevenue:0,lodgeBookings:{}}),E[O.destinationId].totalVisitors+=N.travelerCount,E[O.destinationId].totalNights+=O.numberOfNights,E[O.destinationId].totalRevenue+=I*O.numberOfNights,O.lodgeId&&(E[O.destinationId].lodgeBookings[O.lodgeId]=(E[O.destinationId].lodgeBookings[O.lodgeId]||0)+1)})}),r.map(N=>{var F;const S=E[N.id];if(!S)return{id:N.id,name:N.name,imageUrl:N.imageUrl,totalVisitors:0,totalNights:0,totalRevenue:0,avgSpendPerNight:0,mostPopularLodge:"N/A"};const I=Object.keys(S.lodgeBookings).sort((J,z)=>S.lodgeBookings[z]-S.lodgeBookings[J])[0],O=((F=s.find(J=>J.id===I))==null?void 0:F.name)||"N/A";return{id:N.id,name:N.name,imageUrl:N.imageUrl,totalVisitors:S.totalVisitors,totalNights:S.totalNights,totalRevenue:S.totalRevenue,avgSpendPerNight:S.totalNights>0?S.totalRevenue/S.totalNights:0,mostPopularLodge:O}})},[n]),p=R.useMemo(()=>{let w=[...f];return a.key&&w.sort((E,N)=>E[a.key]<N[a.key]?a.direction==="ascending"?-1:1:E[a.key]>N[a.key]?a.direction==="ascending"?1:-1:0),w},[f,a]),y=w=>{let E="ascending";a.key===w&&a.direction==="ascending"?E="descending":a.key===w&&a.direction==="descending"&&(E="ascending"),c({key:w,direction:E})},b=({sortKey:w,label:E,className:N=""})=>o.jsx("th",{scope:"col",className:`px-4 py-3 ${N}`,children:o.jsxs("button",{onClick:()=>y(w),className:"flex items-center gap-1 group",children:[E,o.jsxs("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity",children:[a.key===w&&a.direction==="descending"&&"↓",a.key===w&&a.direction==="ascending"&&"↑",a.key!==w&&"↕"]})]})});return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-700 overflow-x-auto",children:o.jsxs("table",{className:"w-full text-sm text-left text-gray-500 dark:text-gray-400",children:[o.jsx("thead",{className:"text-xs text-gray-700 dark:text-gray-400 uppercase bg-gray-50 dark:bg-gray-700",children:o.jsxs("tr",{children:[o.jsx(b,{sortKey:"name",label:"Destination"}),o.jsx(b,{sortKey:"totalRevenue",label:"Total Revenue",className:"text-right"}),o.jsx(b,{sortKey:"totalVisitors",label:"Total Visitors",className:"text-right"}),o.jsx(b,{sortKey:"totalNights",label:"Total Nights",className:"text-right"}),o.jsx(b,{sortKey:"avgSpendPerNight",label:"Avg. Spend/Night",className:"text-right"}),o.jsx("th",{scope:"col",className:"px-4 py-3",children:"Most Popular Lodge"})]})}),o.jsx("tbody",{children:p.map(w=>o.jsxs("tr",{onClick:()=>h(w),className:"border-b dark:border-gray-700 bg-white dark:bg-gray-800 hover:bg-blue-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors",children:[o.jsx("td",{className:"px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("img",{src:w.imageUrl,alt:w.name,className:"w-10 h-10 rounded-md object-cover"}),o.jsx("span",{className:"font-semibold text-brand-dark dark:text-white whitespace-nowrap",children:w.name})]})}),o.jsxs("td",{className:"px-4 py-3 text-right font-medium text-gray-800 dark:text-gray-200",children:["$",w.totalRevenue.toLocaleStr
4569ing(void 0,{maximumFractionDigits:0})]}),o.jsx("td",{className:"px-4 py-3 text-right",children:w.totalVisitors.toLocaleString()}),o.jsx("td",{className:"px-4 py-3 text-right",children:w.totalNights.toLocaleString()}),o.jsxs("td",{className:"px-4 py-3 text-right",children:["$",w.avgSpendPerNight.toLocaleString(void 0,{maximumFractionDigits:0})]}),o.jsx("td",{className:"px-4 py-3",children:w.mostPopularLodge})]},w.id))})]})}),u&&o.jsx(oK,{destinationData:u,allItineraries:n,allConsultants:e,dateRange:t,onClose:()=>h(null)})]})},cK=({lodgeData:n,allItineraries:e,previousPeriodItineraries:t,allConsultants:r,dateRange:s,compareDateRange:a,enableCompare:c,activePreset:u,onClose:h})=>{const{state:{destinations:f,lodges:p}}=an(),y=R.useMemo(()=>p.find(E=>E.id===n.id),[n.id]),b=R.useMemo(()=>{const E=e.filter(U=>{const D=new Date(U.startDate)>=s.start&&new Date(U.startDate)<=s.end,k=U.stops.some(_=>_.lodgeId===n.id);return U.status==="confirmed"&&D&&k});let N=0,S=0;const I=new Set,O={};E.forEach(U=>{const D=U.duration;if(D===0)return;const k=U.totalPrice/D;U.stops.forEach(_=>{_.lodgeId===n.id&&(I.add(U.id),N+=_.numberOfNights,S+=k*_.numberOfNights,_.roomId&&(O[_.roomId]=(O[_.roomId]||0)+_.numberOfNights))})});const F=I.size,J=N>0?S/N:0,z=Object.entries(O).map(([U,D])=>{var k;return{label:((k=y==null?void 0:y.rooms.find(_=>_.id===U))==null?void 0:k.name)||"Unknown Room",value:D}}).sort((U,D)=>D.value-U.value);return{totalRevenue:S,totalNights:N,totalBookings:F,avgSpendPerNight:J,roomPerformanceData:z}},[n.id,e,s,y]),w=R.useMemo(()=>{if(u==="all")return null;const E=[...e,...t],N=(O,F)=>{const J=new Date(new Date(O).setHours(0,0,0,0)),z=new Date(new Date(F).setHours(23,59,59,999)),U=E.filter(M=>{const j=new Date(M.startDate);return M.stops.some(L=>L.lodgeId===n.id)&&M.status==="confirmed"&&j>=J&&j<=z}).sort((M,j)=>new Date(M.startDate).getTime()-new Date(j.startDate).getTime()),D=Math.round((z.getTime()-J.getTime())/(1e3*3600*24))+1,k=Array(D).fill(0);U.forEach(M=>{const j=new Date(new Date(M.startDate).setHours(0,0,0,0)),H=Math.round((j.getTime()-J.getTime())/(1e3*3600*24));if(H>=0&&H<D){const L=M.duration>0?M.duration:1,ee=M.totalPrice/L,ne=M.stops.filter(G=>G.lodgeId===n.id).reduce((G,W)=>G+W.numberOfNights,0);k[H]+=ee*ne}});let _=0;return k.map((M,j)=>(_+=M,{day:j+1,value:_}))},S=N(s.start,s.end),I=c?N(a.start,a.end):[];return{currentData:S,previousData:I}},[n.id,e,t,s,a,c,u]);return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-60 flex justify-center items-center z-50 p-4",onClick:h,children:o.jsxs("div",{className:"bg-gray-100 dark:bg-gray-900 rounded-lg shadow-xl w-full max-w-5xl m-4 flex flex-col max-h-[90vh]",onClick:E=>E.stopPropagation(),children:[o.jsxs("header",{className:"flex justify-between items-center p-6 border-b dark:border-gray-700 flex-shrink-0 bg-white dark:bg-gray-800 rounded-t-lg",children:[o.jsxs("h2",{className:"text-2xl font-bold text-brand-dark dark:text-white font-heading",children:[n.name," - Performance Details"]}),o.jsx("button",{onClick:h,className:"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 text-3xl leading-none",children:"×"})]}),o.jsxs("main",{className:"p-6 space-y-6 overflow-y-auto",children:[o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v.01"})}),title:"Total Revenue",value:`$${b.totalRevenue.toLocaleString(void 0,{maximumFractionDigits:0})}`}),o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})}
4569),title:"Total Nights Booked",value:b.totalNights.toLocaleString()}),o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),title:"Total Bookings",value:b.totalBookings.toLocaleString()}),o.jsx(Zr,{icon:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 9V7a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2m2 4h10a2 2 0 002-2v-6a2 2 0 00-2-2H9a2 2 0 00-2 2v6a2 2 0 002 2zm7-5a2 2 0 11-4 0 2 2 0 014 0z"})}),title:"Avg Spend / Night",value:`$${b.avgSpendPerNight.toLocaleString(void 0,{maximumFractionDigits:0})}`})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-5 gap-6",children:[o.jsx("div",{className:"lg:col-span-3",children:w?o.jsx(SI,{title:"Cumulative Revenue Growth",data:w.currentData,compareData:c?w.previousData:[]}):o.jsx("div",{className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md border border-gray-200 dark:border-gray-700 h-full flex items-center justify-center",children:o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Growth chart not available for 'All Time'."})})}),o.jsx("div",{className:"lg:col-span-2",children:o.jsx(ph,{title:"Room Performance (Nights Booked)",data:b.roomPerformanceData})})]})]})]})})},uK=({itineraries:n,previousItineraries:e,consultants:t,dateRange:r,compareDateRange:s,enableCompare:a,activePreset:c})=>{const{state:{destinations:u,lodges:h}}=an(),[f,p]=R.useState({key:"totalRevenue",direction:"descending"}),[y,b]=R.useState(null),w=R.useMemo(()=>{const I=n.filter(F=>F.status==="confirmed"),O={};return I.forEach(F=>{const J=F.duration;if(J===0)return;const z=F.totalPrice/J;F.stops.forEach(U=>{if(!U.lodgeId)return;O[U.lodgeId]||(O[U.lodgeId]={totalNights:0,totalRevenue:0,roomBookings:{},itineraryIds:new Set});const D=O[U.lodgeId];D.totalNights+=U.numberOfNights,D.totalRevenue+=z*U.numberOfNights,D.itineraryIds.add(F.id),U.roomId&&(D.roomBookings[U.roomId]=(D.roomBookings[U.roomId]||0)+1)})}),h.map(F=>{var D,k,_;const J=O[F.id];if(!J)return{id:F.id,name:F.name,destinationName:((D=u.find(M=>M.id===F.destinationId))==null?void 0:D.name)||"N/A",totalNights:0,totalBookings:0,totalRevenue:0,avgSpendPerNight:0,mostPopularRoom:"N/A"};const z=Object.keys(J.roomBookings).sort((M,j)=>J.roomBookings[j]-J.roomBookings[M])[0],U=((k=F.rooms.find(M=>M.id===z))==null?void 0:k.name)||"N/A";return{id:F.id,name:F.name,destinationName:((_=u.find(M=>M.id===F.destinationId))==null?void 0:_.name)||"N/A",totalNights:J.totalNights,totalBookings:J.itineraryIds.size,totalRevenue:J.totalRevenue,avgSpendPerNight:J.totalNights>0?J.totalRevenue/J.totalNights:0,mostPopularRoom:U}})},[n]),E=R.useMemo(()=>{let I=[...w];return f.key&&I.sort((O,F)=>O[f.key]<F[f.key]?f.direction==="ascending"?-1:1:O[f.key]>F[f.key]?f.direction==="ascending"?1:-1:0),I},[w,f]),N=I=>{let O="ascending";f.key===I&&f.direction==="ascending"?O="descending":f.key===I&&f.direction==="descending"&&(O="ascending"),p({key:I,direction:O})},S=({sortKey:I,label:O,className:F=""})=>o.jsx("th",{scope:"col",className:`px-4 py-3 ${F}`,children:o.jsxs("button",{onClick:()=>N(I),className:"flex items-center gap-1 group",children:[O,o.jsxs("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity",children:[f.key===I&&f.direction==="descending"&&"↓",f.key===I&&f.direction==="ascending"&&"↑",f.key!==I&&"↕"]})]})});return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-700 overflow-x-auto",children:o.jsxs("table",{className:"w-full text-sm text-left text-gray-500 dark:text-gray-400",children:[o.jsx("thead",{className:"text-xs text-gray-700 dark:text-gray-400 uppercase bg-gray-50 dark:bg-gray-700",children:o.jsxs("tr",{children:[o.jsx(S,{sortKey:"name",label:"Lodge"}),o.jsx("th",{scope:"col",className:"px-4 py-3",children:"Destination"}),o.jsx(S,{sortKey:"totalRevenue",label:"Total Revenue",className:"text-right"}),o.jsx(S,{sortKey:"totalNights",label:"Nights Booked",className:"text-right"}),o.jsx(S,{sortKey:"totalBookings",label:"Total Bookings",className:"text-right"}),o.jsx(S,{sortKey:"avgSpendPerNight",label:"Avg. Spend/Night",className:"text-right"}),o.jsx("th",{scope:"col",className:"px-4 py-3",children:"Most Popular Room"})]})}),o.jsx("tbody",{children:E.map(I=>o.jsxs("tr",{onClick:()=>b(I),className:"border-b dark:border-gray-700 bg-white dark:bg-gray-800 hover:bg-blue-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors",children:[o.jsx("td",{className:"px-4 py-3 font-semibold text-brand-dark dark:text-white whitespace-nowrap",children:I.name}),o.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:I.destinationName}),o.jsxs("td",{className:"px-4 py-3 text-right font-medium text-gray-800 dark:text-gray-200",children:["$",I.totalRevenue.toLocaleStr
4569ing(void 0,{maximumFractionDigits:0})]}),o.jsx("td",{className:"px-4 py-3 text-right",children:I.totalNights.toLocaleString()}),o.jsx("td",{className:"px-4 py-3 text-right",children:I.totalBookings.toLocaleString()}),o.jsxs("td",{className:"px-4 py-3 text-right",children:["$",I.avgSpendPerNight.toLocaleString(void 0,{maximumFractionDigits:0})]}),o.jsx("td",{className:"px-4 py-3",children:I.mostPopularRoom})]},I.id))})]})}),y&&o.jsx(cK,{lodgeData:y,allItineraries:n,previousPeriodItineraries:e,allConsultants:t,dateRange:r,compareDateRange:s,enableCompare:a,activePreset:c,onClose:()=>b(null)})]})},Lo=(n,e)=>{const t=new Date(n);return t.setDate(t.getDate()-e),t},GN=n=>n.toISOString().split("T")[0],dK=()=>{const[n,e]=R.useState("overview"),[t,r]=R.useState([]),[s,a]=R.useState([]),[c,u]=R.useState([]),[h,f]=R.useState(!0),[p,y]=R.useState("30d"),[b,w]=R.useState(!0),[E,N]=R.useState({start:Lo(new Date,29),end:new Date}),[S,I]=R.useState({start:Lo(new Date,59),end:Lo(new Date,30)});R.useEffect(()=>{(async()=>{f(!0);try{const[M,j,H]=await Promise.all([ge.getAllItineraries(),ge.getAllConsultants(),ge.getAllReviews()]);r(M),a(j),u(H)}catch(M){console.error("Failed to fetch report data:",M)}finally{f(!1)}})()},[]);const O=R.useCallback(_=>{if(y(_),_==="custom")return;if(_==="all"){if(t.length===0){const ne=new Date;N({start:ne,end:ne})}else{const ne=t.map(G=>new Date(G.startDate)).sort((G,W)=>G.getTime()-W.getTime());N({start:ne[0],end:new Date})}return}const M=new Date;let j=0;switch(_){case"7d":j=6;break;case"4m":j=120;break;case"30d":default:j=29;break}const H=Lo(M,j);N({start:H,end:M});const L=Lo(H,j+1),ee=Lo(H,1);I({start:L,end:ee})},[t]),F=(_,M)=>{const j=new Date(M);y("custom"),N(H=>{const L={...H,[_]:j},ee=(L.end.getTime()-L.start.getTime())/(1e3*3600*24);return I({start:Lo(L.start,ee+1),end:Lo(L.start,1)}),L})},J=R.useMemo(()=>t.filter(_=>{const M=new Date(_.startDate);return M>=E.start&&M<=E.end}),[t,E]),z=R.useMemo(()=>t.filter(_=>{const M=new Date(_.startDate);return M>=S.start&&M<=S.end}),[t,S]),U=({tab:_,label:M})=>o.jsx("button",{onClick:()=>e(_),className:`px-4 py-2 text-sm font-semibold rounded-md transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900 ${n===_?"bg-white dark:bg-gray-700 text-blue-600 dark:text-white shadow":"text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700/50"}`,children:M}),D=({preset:_,label:M})=>o.jsx("button",{onClick:()=>O(_),className:`px-3 py-1.5 text-sm rounded-md transition-colors ${p===_?"bg-blue-600 text-white font-semibold":"text-gray-600 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600"}`,children:M}),k=()=>{const _={itineraries:J,previousItineraries:z,consultants:s,reviews:c,dateRange:E,compareDateRange:S,enableCompare:b&&p!=="all",activePreset:p};switch(n){case"overview":return o.jsx(iK,{..._});case"consultants":return o.jsx(aK,{..._});case"destinations":return o.jsx(lK,{..._});case"lodges":return o.jsx(uK,{..._});default:return null}};return o.jsxs("div",{className:"max-w-7xl mx-auto w-full space-y-8",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-4xl font-bold text-brand-dark dark:text-white font-heading",children:"Platform Reports"}),o.jsx("p",{className:"text-lg mt-1 text-gray-600 dark:text-gray-300",children:"Data-driven insights to help you understand and grow the platform."})]}),o.jsxs("div",{className:"p-1.5 bg-gray-100 dark:bg-gray-900 rounded-lg flex flex-wrap gap-2 self-start",role:"tablist","aria-label":"Reports",children:[o.jsx(U,{tab:"overview",label:"Platform Overview"}),o.jsx(U,{tab:"consultants",label:"Consultant Performance"}),o.jsx(U,{tab:"destinations",label:"Destination Insights"}),o.jsx(U,{tab:"lodges",label:"Lodge Insights"})]}),o.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800/50 rounded-lg border dark:border-gray-700 flex flex-wrap items-center gap-4 text-sm",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(D,{preset:"7d",label:"Last 7 Days"}),o.jsx(D,{preset:"30d",label:"Last 30 Days"}
4569),o.jsx(D,{preset:"4m",label:"Last 4 Months"}),o.jsx(D,{preset:"all",label:"All Time"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"date",value:GN(E.start),onChange:_=>F("start",_.target.value),className:"p-1.5 border rounded-md border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:[color-scheme:dark]"}),o.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"to"}),o.jsx("input",{type:"date",value:GN(E.end),onChange:_=>F("end",_.target.value),className:"p-1.5 border rounded-md border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:[color-scheme:dark]"})]}),o.jsxs("div",{className:"flex items-center gap-2 pl-4 border-l dark:border-gray-600",children:[o.jsx("input",{type:"checkbox",id:"compare-toggle",checked:b,onChange:_=>w(_.target.checked),disabled:p==="all",className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 disabled:opacity-50"}),o.jsx("label",{htmlFor:"compare-toggle",className:"font-medium text-gray-700 dark:text-gray-300",children:"Compare to previous period"})]})]}),o.jsx("div",{children:h?o.jsx("div",{className:"py-20 flex justify-center",children:o.jsx(At,{})}):k()})]})},hK=["All","Wildlife Encounters","Gorilla Trekking","Travel Tips","Safari Circuits","Culture & Community","Photography","Lodge Experiences"],fK=()=>{const{state:{loggedInUser:n},openLoginModal:e,navigateTo:t,startItinerary:r}=an(),s=(n==null?void 0:n.role)==="admin"||(n==null?void 0:n.email)==="[email protected]",[a,c]=R.useState([]),[u,h]=R.useState("All"),[f,p]=R.useState(""),[y,b]=R.useState("published"),[w,E]=R.useState(!1),[N,S]=R.useState(null),[I,O]=R.useState(null),[F,J]=R.useState(null);R.useEffect(()=>{const G=ge.subscribeToStories(W=>{c(W)});return()=>G()},[]);const z=G=>{J(G),setTimeout(()=>J(null),3500)},U=R.useMemo(()=>a.filter(G=>G.status==="pending").length,[a]),D=R.useMemo(()=>n?a.filter(G=>G.authorId===n.id).length:0,[a,n]),k=R.useMemo(()=>{let G=[];if(y==="published"?G=a.filter(W=>W.status==="published"):y==="my-stories"?G=a.filter(W=>W.authorId===(n==null?void 0:n.id)):y==="review-queue"&&(G=a.filter(W=>W.status==="pending"||s&&W.status==="rejected")),u!=="All"&&(G=G.filter(W=>W.category===u)),f.trim()){const W=f.toLowerCase();G=G.filter(X=>X.title.toLowerCase().includes(W)||X.summary.toLowerCase().includes(W)||X.content.toLowerCase().includes(W)||X.authorName.toLowerCase().includes(W)||X.destinationName&&X.destinationName.toLowerCase().includes(W)||X.tags&&X.tags.some(ae=>ae.toLowerCase().includes(W)))}return G.sort((W,X)=>{if(W.featured&&!X.featured)return-1;if(!W.featured&&X.featured)return 1;const ae=new Date(W.publishedAt||W.createdAt).getTime();return new Date(X.publishedAt||X.createdAt).getTime()-ae})},[a,y,u,f,n,s]),_=R.useMemo(()=>y!=="published"||u!=="All"||f.trim()?null:k.find(G=>G.featured)||k[0]||null,[k,y,u,f]),M=R.useMemo(()=>_&&y==="published"&&u==="All"&&!f.trim()?k.filter(G=>G.id!==_.id):k,[k,_,y,u,f]),j=async G=>{n&&(N?(await ge.updateStory(N.id,G),z("Story updated successfully."),S(null)):(await ge.createStory(G,n),s&&G.status==="published"?z("Story published directly to the Safari Stories feed!"):(z("✨ Story submitted for editorial review! An admin will review it shortly."),b("my-stories"))))},H=async(G,W=!1)=>{await ge.approveStory(G,W),z("Story approved and published successfully."),(I==null?void 0:I.id)===G&&O(X=>X?{...X,status:"published",rejectionReason:void 0}:null)},L=async(G,W)=>{await ge.rejectStory(G,W),z("Story marked as rejected with feedback."),(I==null?void 0:I.id)===G&&O(X=>X?{...X,status:"rejected",rejectionReason:W}:null)},ee=async G=>{await ge.deleteStory(G),z("Story removed."),(I==null?void 0:I.id)===G&&O(null)},ne=async G=>{const W=await ge.toggleStoryLike(G);(I==null?void 0:I.id)===G&&O(X=>X?{...X,likesCount:W}:null)};return o.jsxs("div",{className:"w-full max-w-7xl mx-auto px-4 py-4 sm:py-8",children:[F&&o.jsxs("div",{className:"fixed bottom-6 right-6 z-50 px-5 py-3 rounded-xl bg-gray-900 text-white shadow-2xl border border-gray-700 text-sm flex items-center gap-3 animate-in fade-in slide-in-from-bottom-4 duration-200",children:[o.jsx(Ga,{className:"w-5 h-5 text-emerald-400 flex-shrink-0"}),o.jsx("span",{children:F})]}),o.jsxs("div",{className:"flex flex-col md:flex-row md:items-end justify-between gap-6 pb-8 border-b border-gray-200 dark:border-gray-800",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-blue-600 dar
4569k:text-blue-400 mb-2",children:[o.jsx(KN,{className:"w-4 h-4"}),o.jsx("span",{children:"Uganda Safari Journals & Insights"})]}),o.jsx("h1",{className:"text-4xl md:text-5xl font-extrabold font-heading text-brand-dark dark:text-white tracking-tight",children:"Safari Stories"}),o.jsx("p",{className:"mt-2 text-base md:text-lg text-gray-600 dark:text-gray-300 max-w-2xl",children:"Real field journals, gorilla trekking logs, wildlife photography, and expert itinerary advice written by travelers and certified Ugandan guides."})]}),o.jsx("div",{className:"flex items-center gap-3 flex-shrink-0",children:o.jsxs(He,{onClick:()=>{n?(S(null),E(!0)):e()},className:"flex items-center gap-2 py-3 px-6 shadow-md hover:shadow-lg hover:scale-105 transition-all text-sm font-bold",children:[o.jsx(JR,{className:"w-4 h-4"}),o.jsx("span",{children:"Share Your Story"})]})})]}),o.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex items-center gap-2 p-1 bg-gray-100 dark:bg-gray-800/70 rounded-xl",children:[o.jsxs("button",{onClick:()=>b("published"),className:`px-4 py-2 rounded-lg text-sm font-semibold transition-all flex items-center gap-2 ${y==="published"?"bg-white dark:bg-gray-700 text-brand-dark dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-brand-dark dark:hover:text-white"}`,children:[o.jsx(rg,{className:"w-4 h-4"}),o.jsx("span",{children:"All Published"})]}),n&&o.jsxs("button",{onClick:()=>b("my-stories"),className:`px-4 py-2 rounded-lg text-sm font-semibold transition-all flex items-center gap-2 ${y==="my-stories"?"bg-white dark:bg-gray-700 text-brand-dark dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-brand-dark dark:hover:text-white"}`,children:[o.jsx(rS,{className:"w-4 h-4"}),o.jsx("span",{children:"My Stories"}),D>0&&o.jsx("span",{className:"px-2 py-0.5 text-xs rounded-full bg-blue-100 dark:bg-blue-900/60 text-blue-700 dark:text-blue-300 font-bold",children:D})]}),s&&o.jsxs("button",{onClick:()=>b("review-queue"),className:`px-4 py-2 rounded-lg text-sm font-semibold transition-all flex items-center gap-2 ${y==="review-queue"?"bg-white dark:bg-gray-700 text-brand-dark dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-brand-dark dark:hover:text-white"}`,children:[o.jsx(yE,{className:"w-4 h-4 text-amber-500"}),o.jsx("span",{children:"Admin Review Queue"}),U>0&&o.jsxs("span",{className:"px-2 py-0.5 text-xs rounded-full bg-amber-500 text-gray-950 font-bold animate-pulse",children:[U," Pending"]})]})]}),o.jsxs("div",{className:"relative w-full sm:w-72",children:[o.jsx(yh,{className:"w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2"}),o.jsx("input",{type:"search",value:f,onChange:G=>p(G.target.value),placeholder:"Search stories, parks, topics...",className:"w-full pl-10 pr-4 py-2 text-sm bg-white dark:bg-gray-800 text-brand-dark dark:text-white rounded-xl border border-gray-200 dark:border-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all"})]})]}),o.jsx("div",{className:"mt-4 flex items-center gap-2 overflow-x-auto pb-2 scrollbar-thin",children:hK.map(G=>o.jsx("button",{onClick:()=>h(G),className:`px-4 py-1.5 rounded-full text-xs font-semibold whitespace-nowrap transition-all ${u===G?"bg-blue-600 text-white shadow-sm scale-105":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:G},G))}),y==="review-queue"&&o.jsxs("div",{className:"mt-6 p-4 rounded-xl bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 text-amber-900 dark:text-amber-300 text-xs flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(yE,{className:"w-5 h-5 text-amber-600 dark:text-amber-400 flex-shrink-0"}),o.jsxs("div",{children:[o.jsx("p",{className:"font-bold text-sm",children:"Editorial Moderation Desk"}),o.jsx("p",{className:"mt-0.5 text-amber-800 dark:text-amber-400",children:'Registered users and guides submit stories here for safety, quality, and accuracy checks. Click "Approve & Publish" to immediately make them public.'})]})]}),o.jsxs("span",{className:"px-3 py-1 bg-amber-200 dark:bg-amber-900/60 rounded-full font-bold text-xs",children:[U," Awaiting Review"]})]}),y==="my-stories"&&o.jsxs("div",{className:"mt-6 p-4 rounded-xl bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-900 text-blue-900 dark:text-blue-300 text-xs flex items-center justify-between gap-4",children:[o.jsxs("div",{children:[o.jsx("p",{className:"font-bold text-sm",children:"Your Author Dashboard"}),o.jsx("p",{className:"mt-0.5 text-blue-800 dark:text-blue-400",children:'Track the status of your safari stories. Stories with status "Pending" are actively being reviewed by our editorial team.'})]}),o.jsx("button",{onClick:()=>{S(null),E(!0)},className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-semibold whitespace-nowrap",children:"Write Another Story"})]}),_&&o.jsx("div",{className:"mt-8 relative rounded-3xl overflow-hidden shadow-xl border border-gray-200 dark:border-gray-800 group bg-gray-900 text-white",children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 min-h-[380px]",children:[o.jsxs("div",{className:"lg:col-span-7 relative h-64 lg:h-auto overflow-hidden",children:[o.jsx("img",{src:_.coverImageUrl,alt:_.title,className:"w-full h-full object-cover object-center group-hover:scale-105 transition-transform duration-700"}),o.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-gray-900 via-trans
4569parent to-transparent lg:bg-gradient-to-r lg:from-transparent lg:to-gray-900"}),o.jsx("div",{className:"absolute top-4 left-4",children:o.jsxs("span",{className:"px-3.5 py-1.5 rounded-full text-xs font-bold uppercase tracking-wider bg-amber-500 text-gray-950 shadow-md flex items-center gap-1.5",children:[o.jsx(dc,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"Featured Expedition"})]})})]}),o.jsxs("div",{className:"lg:col-span-5 p-6 sm:p-8 md:p-10 flex flex-col justify-between bg-gray-900",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-3 text-xs text-blue-400 font-semibold mb-3",children:[o.jsx("span",{className:"px-2.5 py-0.5 rounded-md bg-blue-950/60 border border-blue-800/60 text-blue-300 uppercase tracking-wider",children:_.category}),o.jsx("span",{children:"•"}),o.jsxs("span",{className:"flex items-center gap-1 text-gray-400",children:[o.jsx(Si,{className:"w-3.5 h-3.5"}),_.readTime]})]}),o.jsx("h2",{onClick:()=>O(_),className:"text-2xl sm:text-3xl font-bold font-heading text-white leading-tight cursor-pointer hover:text-blue-400 transition-colors",children:_.title}),o.jsx("p",{className:"mt-3 text-sm sm:text-base text-gray-300 leading-relaxed line-clamp-3",children:_.summary})]}),o.jsxs("div",{className:"pt-6 mt-6 border-t border-gray-800 flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("img",{src:_.authorAvatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(_.authorName)}&background=2563eb&color=fff`,alt:_.authorName,className:"w-10 h-10 rounded-full object-cover border border-gray-700"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-bold text-white",children:_.authorName}),o.jsx("p",{className:"text-xs text-gray-400",children:_.authorRole||"Author"})]})]}),o.jsx("button",{onClick:()=>O(_),className:"px-4 py-2 rounded-xl bg-blue-600 hover:bg-blue-700 text-white text-xs font-bold transition-transform hover:scale-105",children:"Read Story"})]})]})]})}),o.jsxs("div",{className:"mt-10",children:[o.jsx("div",{className:"flex items-center justify-between mb-6",children:o.jsxs("h3",{className:"text-xl font-bold font-heading text-brand-dark dark:text-white",children:[y==="published"?u==="All"?"Latest Stories & Guides":`${u} Stories`:y==="my-stories"?"Your Submitted Stories":"Stories Requiring Review",o.jsxs("span",{className:"ml-2 text-sm font-normal text-gray-500",children:["(",k.length,")"]})]})}),k.length===0?o.jsxs("div",{className:"text-center py-16 px-4 bg-gray-50 dark:bg-gray-850 rounded-2xl border border-gray-200 dark:border-gray-800",children:[o.jsx(rg,{className:"w-12 h-12 text-gray-400 mx-auto mb-3"}),o.jsx("h4",{className:"text-lg font-bold text-brand-dark dark:text-white",children:"No stories found"}),o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-md mx-auto mt-1 mb-6",children:f?`No stories matched your search "${f}". Try different keywords or categories.`:y==="my-stories"?"You haven't authored any stories yet. Share your experience with mountain gorillas or savanna wildlife!":y==="review-queue"?"All traveler submissions have been reviewed and published. Great job!":"No published stories found in this category yet."}),y==="my-stories"&&o.jsx(He,{onClick:()=>{S(null),E(!0)},children:"Author Your First Story"})]}):o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 sm:gap-8",children:M.map(G=>o.jsxs("article",{className:"flex flex-col bg-white dark:bg-gray-850 rounded-2xl overflow-hidden shadow-sm hover:shadow-xl border border-gray-200 dark:border-gray-800 transition-all duration-300 group",children:[o.jsxs("div",{className:"relative aspect-[16/10] overflow-hidden bg-gray-100 dark:bg-gray-900 cursor-pointer",onClick:()=>O(G),children:[o.jsx("img",{src:G.coverImageUrl,alt:G.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",loading:"lazy"}),o.jsxs("div",{className:"absolute top-3 left-3 flex flex-wrap gap-1.5",children:[o.jsx("span",{className:"px-2.5 py-1 rounded-md text-[11px] font-bold uppercase tracking-wider bg-black/60 backdrop-blur-md text-white",children:G.category}),G.featured&&o.jsxs("span",{className:"px-2 py-1 rounded-md text-[10px] font-bold uppercase tracking-wider bg-amber-500 text-gray-950 flex items-center gap-1",children:[o.jsx(dc,{className:"w-3 h-3"}),o.jsx("span",{children:"Featured"})]})]}),G.status!=="published"&&o.jsx("div",{className:"absolute top-3 right-3",children:o.jsx("span",{className:`px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider shadow-sm ${G.status==="pending"?"bg-amber-500 text-gray-950":G.status==="rejected"?"bg-red-500 text-white":"bg-gray-600 text-white"}`,children:G.status})}),G.destinationName&&o.jsxs("div",{className:"absolute bottom-3 left-3 flex items-center gap-1 text-xs text-white/90 bg-black/50 backdrop-blur-sm px-2 py-0.5 rounded-full",children:[o.jsx(jh,{className:"w-3 h-3 text-emerald-400"}),o.jsx("span",{className:"truncate max-w-[180px]",children:G.destinationName})]})]}),o.jsxs("div",{className:"p-5 sm:p-6 flex flex-col flex-grow justify-between",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400 mb-2",children:[o.jsx(Si,{className:"w-3.5 h-3.5 text-blue-500"}),o.jsx("span",{children:G.readTime}),o.jsx("span",{children:"•"}),o.jsx("span",{children:new Date(G.publishedAt||G.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})})]}),o.jsx("h4",{onClick:()=>O(G),className:"text-lg font-bold font-heading text-brand-dark dark:text-white leading-snug line-clamp-2 cursor-pointer group-hover:text-blue-600 dar
4569k:group-hover:text-blue-400 transition-colors",children:G.title}),o.jsx("p",{className:"mt-2 text-xs sm:text-sm text-gray-600 dark:text-gray-300 line-clamp-3 leading-relaxed",children:G.summary}),G.status==="rejected"&&G.rejectionReason&&o.jsxs("div",{className:"mt-3 p-2.5 rounded-lg bg-red-50 dark:bg-red-950/40 border border-red-200 dark:border-red-900 text-[11px] text-red-700 dark:text-red-300",children:[o.jsx("strong",{children:"Editorial feedback:"})," ",G.rejectionReason]})]}),o.jsxs("div",{className:"mt-6 pt-4 border-t border-gray-100 dark:border-gray-800 flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx("img",{src:G.authorAvatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(G.authorName)}&background=2563eb&color=fff`,alt:G.authorName,className:"w-7 h-7 rounded-full object-cover border border-gray-200 dark:border-gray-700"}),o.jsx("div",{className:"text-left",children:o.jsx("p",{className:"text-xs font-semibold text-brand-dark dark:text-gray-200 truncate max-w-[110px]",children:G.authorName})})]}),o.jsx("div",{className:"flex items-center gap-2",children:s&&G.status==="pending"?o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs("button",{onClick:()=>H(G.id),className:"px-2.5 py-1 bg-green-600 hover:bg-green-700 text-white text-xs font-bold rounded-lg transition-colors flex items-center gap-1",title:"Approve & Publish",children:[o.jsx(Jg,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"Approve"})]}),o.jsx("button",{onClick:()=>O(G),className:"px-2.5 py-1 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 text-xs font-semibold rounded-lg",children:"Review"})]}):o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("button",{onClick:()=>ne(G.id),className:"flex items-center gap-1 text-xs text-gray-500 hover:text-red-500 transition-colors","aria-label":"Like story",children:[o.jsx(QN,{className:"w-3.5 h-3.5 fill-current"}),o.jsx("span",{children:G.likesCount||0})]}),o.jsx("button",{onClick:()=>O(G),className:"text-xs font-bold text-blue-600 dark:text-blue-400 hover:underline",children:"Read →"})]})})]})]})]},G.id))})]}),o.jsxs("div",{className:"mt-16 p-8 rounded-3xl bg-gradient-to-r from-blue-700 via-indigo-700 to-blue-900 text-white flex flex-col md:flex-row items-center justify-between gap-6 shadow-xl",children:[o.jsxs("div",{className:"max-w-2xl text-center md:text-left",children:[o.jsx("h3",{className:"text-2xl sm:text-3xl font-bold font-heading",children:"Ready to live your own Uganda safari story?"}),o.jsx("p",{className:"text-sm sm:text-base text-blue-100 mt-2",children:"Build your custom circuit, pick luxury eco-lodges, calculate official gorilla permits, and connect with certified Ugandan guides."})]}),o.jsx(He,{onClick:()=>t(Le.ItineraryBuilder),className:"bg-white text-blue-800 hover:bg-blue-50 font-bold px-8 py-3.5 rounded-full shadow-lg whitespace-nowrap text-base hover:scale-105 transition-all",children:"Open Safari Planner"})]}),w&&n&&o.jsx(AA,{isOpen:w,onClose:()=>{E(!1),S(null)},onSubmit:j,currentUser:n,initialStory:N}),I&&o.jsx(IA,{story:I,isOpen:!!I,onClose:()=>O(null),currentUser:n,onLike:ne,onApprove:H,onReject:L,onDelete:ee,onEdit:G=>{O(null),S(G),E(!0)}})]})},mK=()=>o.jsxs("div",{className:"container mx-auto px-4 py-16 max-w-4xl animate-fade-in",children:[o.jsx("h1",{className:"text-4xl md:text-5xl font-bold text-gray-900 dark:text-white mb-8 font-heading",children:"About Nkuringo Safaris"}),o.jsxs("div",{className:"prose prose-lg dark:prose-invert max-w-none text-gray-600 dark:text-gray-300",children:[o.jsx("p",{className:"text-xl leading-relaxed mb-6",children:"Nkuringo Safaris is a premium, woman-led hospitality brand rooted in Uganda. We specialize in crafting authentic, life-changing wilderness experiences that connect travelers deeply with nature and local communities."}),o.jsx("p",{className:"mb-4",children:"For over two decades, we have been pioneers in sustainable tourism, operating award-winning eco-lodges and curating bespoke safaris across East Africa's most breathtaking landscapes. Our deep local knowledge and commitment to conservation ensure every journey with us leaves a positive footprint."}),o.jsx("p",{className:"mb-4",children:"Our team of local experts brings unrivaled passion and expertise, ensuring your adventure is thoughtfully tailored, culturally rich, and seamlessly executed."})]})]}),gK=()=>o.jsxs("div",{className:"container mx-auto px-4 py-16 max-w-4xl animate-fade-in",children:[o.jsx("h1",{className:"text-4xl font-bold text-gray-900 dark:text-white mb-8 font-heading",children:"Privacy Policy"}),o.jsxs("div",{className:"prose prose-lg dark:prose-invert max-w-none text-gray-600 dark:text-gray-300",children:[o.jsxs("p",{className:"mb-4",children:["Last updated: ",new Date().toLocaleDateString()]}),o.jsx("h2",{className:"text-2xl font-semibold text-gray-800 dark:text-gray-200 mt-8 mb-4",children:"1. Information We Collect"}),o.jsx("p",{className:"mb-4",children:"We collect information you provide directly to us, such as when you create an account, book a safari, subscribe to our newsletter, or contact our support team."}),o.jsx("h2",{className:"text-2xl font-semibold text-gray-800 dark:text-gray-200 mt-8 mb-4",children:"2. How We Use Information"}),o.jsx("p",{className:"mb-4",children:"We use the information we collect to provide, maintain, and improve our services, process your bookings, send you technical notices and support messages, and communicate with you about products, services, and events."}),o.jsx("h2",{className:"text-2xl font-semibold text-gray-800 dark:text-gray-200 mt-8 mb-4",children:"3. Data Security"}),o.jsx("p",{className:"mb-4",children:"We take reasonable measures to help protect information about you from loss, theft, misuse, unauthorized access, disclosure, alteration, and destruction."})]})]}),pK=()=>o.jsxs("div",{className:"container mx-auto px-4 py-16 max-w-4xl animate-fade-in",children:[o.jsx("h1",{className:"text-4xl font-bold text-gray-900 dark:text-white mb-8 font-heading",children:"Terms of Service"}),o.jsxs("div",{className:"prose prose-lg dark:prose-invert max-w-none text-gray-600 dark:text-gray-300",children:[o.jsxs("p",{className:"mb-4",children:["Last updated: ",new Date().toLocaleDateString()]}),o.jsx("h2",{className:"text-2xl font-semibold text-gray-800 dark:text-gray-200 mt-8 mb-4",children:"1. Acceptance of Terms"}),o.jsx("p",{className:"mb-4",children:"By accessing or using our services, you agree to be bound by these Terms. If you do not agree to all of these Terms, do not use our services."}),o.jsx("h2",{className:"text-2xl font-semibold text-gray-800 dark:text-gray-200 mt-8 mb-4",children:"2. Booking and Payments"}),o.jsx("p",{className:"mb-4",children:"All bookings are subject to availability. A deposit may be required to secure your reservation. Final payment terms will be specified in your itinerary proposal."}),o.jsx("h2",{className:"text-2xl font-semibold text-gray-800 dark:text-gray-200 mt-8 mb-4",children:"3. Cancellations"}),o.jsx("p",{className:"mb-4",children:"Cancellation policies vary depending on the specific safari package and lodges booked. Please review the cancellation terms provided with your specific booking confirmation."})]})]}),BK=()=>{const{state:n}=an(),{currentView:e,loggedInUser:t,bookingItinerary:r,draftItinerary:s,activeConsultantProfileId:a,bookingTravelerName:c,bookingTravelerEmail:u,bookingTravelerPhone:h}=n,f=()=>{switch(e){case Le.ItineraryBuilder:return o.jsx(_G,{});case Le.ExpertsHub:return o.jsx(TG,{});case Le.ConsultantDashboard:return o.jsx(MG,{consultantId:a});case Le.TripManagement:return o.jsx(OG,{});case Le.AdminHub:return(t==null?void 0:t.role)==="admin"?o.jsx(nH,{}):o.jsx(ql,{});case Le.Reports:return(t==null?void 0:t.role)==="admin"?o.jsx(dK,{}):o.jsx(ql,{});case Le.TripDashboard:return t?o.jsx($$,{user:t}):o.jsx(ql,{});case Le.EditProfile:return(t==null?void 0:t.role)==="consultant"?o.jsx(K$,{user:t}):o.jsx(ql,{});case Le.ReviewManagement:return(t==null?void 0:t.role)==="consultant"?o.jsx(Q$,{user:t}):o.jsx(ql,{});case Le.Help:return o.jsx(sK,{});case Le.Stories:case Le.Blog:return o.jsx(fK,{});case Le.About:return o.jsx(mK,{});case Le.Privacy:return o.jsx(gK,{});case Le.Terms:return o.jsx(pK,{});case Le.Booking:return r?o.jsx(oH,{itinerary:r,travelerName:c,travelerEmail:u,travelerPhone:h,preSelectedConsultantId:s==null?void 0:s.consultantId}):o.jsx(ql,{});case Le.Home:default:return o.jsx(ql,{})}};return o.jsxs("div",{className:"bg-white dark:bg-gray-900 min-h-screen flex flex-col font-sans text-brand-dark dark:text-gray-200",children:[o.jsx(lG,{}),o.jsx("main",{className:`flex-grow ${e===Le.Home?"flex":"container mx-auto px-4 py-8"}`,children:f()}),o.jsx(cG,{}),r&&e!==Le.Booking&&o.jsx(lH,{itinerary:r,travelerName:c}
4569)]})},DI=document.getElementById("root");if(!DI)throw new Error("Could not find root element to mount to");const yK=yR.createRoot(DI);yK.render(o.jsx(R.StrictMode,{children:o.jsx(iG,{children:o.jsx(BK,{})})}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.