vendor: 6,009 bytes, line 1
1(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))o(d);new MutationObserver(d=>{for(const u of d)if(u.type==="childList")for(const x of u.addedNodes)x.tagName==="LINK"&&x.rel==="modulepreload"&&o(x)}).observe(document,{childList:!0,subtree:!0});function i(d){const u={};return d.integrity&&(u.integrity=d.integrity),d.referrerPolicy&&(u.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?u.credentials="include":d.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(d){if(d.ep)return;d.ep=!0;const u=i(d);fetch(d.href,u)}})();var ou={exports:{}},Tl={};var dg;function Ab(){if(dg)return Tl;dg=1;var s=Symbol.for("react.transitional.element"),l=Symbol.for("react.fragment");function i(o,d,u){var x=null;if(u!==void 0&&(x=""+u),d.key!==void 0&&(x=""+d.key),"key"in d){u={};for(var y in d)y!=="key"&&(u[y]=d[y])}else u=d;return d=u.ref,{$$typeof:s,type:o,key:x,ref:d!==void 0?d:null,props:u}}return Tl.Fragment=l,Tl.jsx=i,Tl.jsxs=i,Tl}var ug;function Eb(){return ug||(ug=1,ou.exports=Ab()),ou.exports}var e=Eb(),cu={exports:{}},et={};var mg;function Tb(){if(mg)return et;mg=1;var s=Symbol.for("react.transitional.element"),l=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),x=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),k=Symbol.iterator;function w(H){return H===null||typeof H!="object"?null:(H=k&&H[k]||H["@@iterator"],typeof H=="function"?H:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,T={};function S(H,Z,$){this.props=H,this.context=Z,this.refs=T,this.updater=$||N}S.prototype.isReactComponent={},S.prototype.setState=function(H,Z){if(typeof H!="object"&&typeof H!="function"&&H!=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,H,Z,"setState")},S.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function _(){}_.prototype=S.prototype;function z(H,Z,$){this.props=H,this.context=Z,this.refs=T,this.updater=$||N}var A=z.prototype=new _;A.constructor=z,j(A,S.prototype),A.isPureReactComponent=!0;var L=Array.isArray;function F(){}var D={H:null,A:null,T:null,S:null},te=Object.prototype.hasOwnProperty;function pe(H,Z,$){var O=$.ref;return{$$typeof:s,type:H,key:Z,ref:O!==void 0?O:null,props:$}}function he(H,Z){return pe(H.type,Z,H.props)}function X(H){return typeof H=="object"&&H!==null&&H.$$typeof===s}function I(H){var Z={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function($){return Z[$]})}var q=/\/+/g;function be(H,Z){return typeof H=="object"&&H!==null&&H.key!=null?I(""+H.key):Z.toString(36)}function ne(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(F,F):(H.status="pending",H.then(function(Z){H.status==="pending"&&(H.status="fulfilled",H.value=Z)},function(Z){H.status==="pending"&&(H.status="rejected",H.reason=Z)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function M(H,Z,$,O,P){var V=typeof H;(V==="undefined"||V==="boolean")&&(H=null);var ye=!1;if(H===null)ye=!0;else switch(V){case"bigint":case"string":case"number":ye=!0;break;case"object":switch(H.$$typeof){case s:case l:ye=!0;break;case b:return ye=H._init,M(ye(H._payload),Z,$,O,P)}}if(ye)return P=P(H),ye=O===""?"."+be(H,0):O,L(P)?($="",ye!=null&&($=ye.replace(q,"$&/")+"/"),M(P,Z,$,"",function(nt){return nt})):P!=null&&(X(P)&&(P=he(P,$+(P.key==null||H&&H.key===P.key?"":(""+P.key).replace(q,"$&/")+"/")+ye)),Z.push(P)),1;ye=0;var ge=O===""?".":O+":";if(L(H))for(var qe=0;qe<H.length;qe++)O=H[qe],V=ge+be(O,qe),ye+=M(O,Z,$,V,P);else if(qe=w(H),typeof qe=="function")for(H=qe.call(H),qe=0;!(O=H.next()).done;)O=O.value,V=ge+be(O,qe++),ye+=M(O,Z,$,V,P);else if(V==="object"){if(typeof H.then=="function")return M(ne(H),Z,$,O,P);throw Z=String(H),Error("Objects are not valid as a React child (found: "+(Z==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":Z)+"). If you meant to render a collection of children, use an array instead.")}return ye}function Y(H,Z,$){if(H==null)return H;var O=[],P=0;return M(H,O,"","",function(V){return Z.call($,V,P++)}),O}function oe(H){if(H._status===-1){var Z=H._result;Z=Z(),Z.then(function($){(H._status===0||H._status===-1)&&(H._status=1,H._result=$)},function($){(H._status===0||H._status===-1)&&(H._status=2,H._result=$)}),H._status===-1&&(H._status=0,H._result=Z)}if(H._status===1)return H._result.default;throw H._result}var Ce=typeof reportError=="function"?reportError:function(H){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof H=="object"&&H!==null&&typeof H.message=="string"?String(H.message):String(H),error:H});if(!window.dispatchEvent(Z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",H);return}console.error(H)},Ae={map:Y,forEach:function(H,Z,$){Y(H,function(){Z.apply(this,arguments)},$)},count:function(H){var Z=0;return Y(H,function(){Z++}),Z},toArray:function(H){return Y(H,function(Z){return Z})||[]},only:function(H){if(!X(H))throw Error("React.Children.only expected to receive a single React element child.");return H}};return et.Activity=f,et.Children=Ae,et.Component=S,et.Fragment=i,et.Profiler=d,et.PureComponent=z,et.StrictMode=o,et.Suspense=p,et.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=D,et.__COMPILER_RUNTIME={__proto__:null,c:function(H){return D.H.useMemoCache(H)}}
vendor: 14,662 bytes, lines 1-3
1,et.cache=function(H){return function(){return H.apply(null,arguments)}},et.cacheSignal=function(){return null},et.cloneElement=function(H,Z,$){if(H==null)throw Error("The argument must be a React element, but you passed "+H+".");var O=j({},H.props),P=H.key;if(Z!=null)for(V in Z.key!==void 0&&(P=""+Z.key),Z)!te.call(Z,V)||V==="key"||V==="__self"||V==="__source"||V==="ref"&&Z.ref===void 0||(O[V]=Z[V]);var V=arguments.length-2;if(V===1)O.children=$;else if(1<V){for(var ye=Array(V),ge=0;ge<V;ge++)ye[ge]=arguments[ge+2];O.children=ye}return pe(H.type,P,O)},et.createContext=function(H){return H={$$typeof:x,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null},H.Provider=H,H.Consumer={$$typeof:u,_context:H},H},et.createElement=function(H,Z,$){var O,P={},V=null;if(Z!=null)for(O in Z.key!==void 0&&(V=""+Z.key),Z)te.call(Z,O)&&O!=="key"&&O!=="__self"&&O!=="__source"&&(P[O]=Z[O]);var ye=arguments.length-2;if(ye===1)P.children=$;else if(1<ye){for(var ge=Array(ye),qe=0;qe<ye;qe++)ge[qe]=arguments[qe+2];P.children=ge}if(H&&H.defaultProps)for(O in ye=H.defaultProps,ye)P[O]===void 0&&(P[O]=ye[O]);return pe(H,V,P)},et.createRef=function(){return{current:null}},et.forwardRef=function(H){return{$$typeof:y,render:H}},et.isValidElement=X,et.lazy=function(H){return{$$typeof:b,_payload:{_status:-1,_result:H},_init:oe}},et.memo=function(H,Z){return{$$typeof:g,type:H,compare:Z===void 0?null:Z}},et.startTransition=function(H){var Z=D.T,$={};D.T=$;try{var O=H(),P=D.S;P!==null&&P($,O),typeof O=="object"&&O!==null&&typeof O.then=="function"&&O.then(F,Ce)}catch(V){Ce(V)}finally{Z!==null&&$.types!==null&&(Z.types=$.types),D.T=Z}},et.unstable_useCacheRefresh=function(){return D.H.useCacheRefresh()},et.use=function(H){return D.H.use(H)},et.useActionState=function(H,Z,$){return D.H.useActionState(H,Z,$)},et.useCallback=function(H,Z){return D.H.useCallback(H,Z)},et.useContext=function(H){return D.H.useContext(H)},et.useDebugValue=function(){},et.useDeferredValue=function(H,Z){return D.H.useDeferredValue(H,Z)},et.useEffect=function(H,Z){return D.H.useEffect(H,Z)},et.useEffectEvent=function(H){return D.H.useEffectEvent(H)},et.useId=function(){return D.H.useId()},et.useImperativeHandle=function(H,Z,$){return D.H.useImperativeHandle(H,Z,$)},et.useInsertionEffect=function(H,Z){return D.H.useInsertionEffect(H,Z)},et.useLayoutEffect=function(H,Z){return D.H.useLayoutEffect(H,Z)},et.useMemo=function(H,Z){return D.H.useMemo(H,Z)},et.useOptimistic=function(H,Z){return D.H.useOptimistic(H,Z)},et.useReducer=function(H,Z,$){return D.H.useReducer(H,Z,$)},et.useRef=function(H){return D.H.useRef(H)},et.useState=function(H){return D.H.useState(H)},et.useSyncExternalStore=function(H,Z,$){return D.H.useSyncExternalStore(H,Z,$)},et.useTransition=function(){return D.H.useTransition()},et.version="19.2.4",et}var hg;function Zu(){return hg||(hg=1,cu.exports=Tb()),cu.exports}var h=Zu(),du={exports:{}},Rl={},uu={exports:{}},mu={};var xg;function Rb(){return xg||(xg=1,(function(s){function l(M,Y){var oe=M.length;M.push(Y);e:for(;0<oe;){var Ce=oe-1>>>1,Ae=M[Ce];if(0<d(Ae,Y))M[Ce]=Y,M[oe]=Ae,oe=Ce;else break e}}function i(M){return M.length===0?null:M[0]}function o(M){if(M.length===0)return null;var Y=M[0],oe=M.pop();if(oe!==Y){M[0]=oe;e:for(var Ce=0,Ae=M.length,H=Ae>>>1;Ce<H;){var Z=2*(Ce+1)-1,$=M[Z],O=Z+1,P=M[O];if(0>d($,oe))O<Ae&&0>d(P,$)?(M[Ce]=P,M[O]=oe,Ce=O):(M[Ce]=$,M[Z]=oe,Ce=Z);else if(O<Ae&&0>d(P,oe))M[Ce]=P,M[O]=oe,Ce=O;else break e}}return Y}function d(M,Y){var oe=M.sortIndex-Y.sortIndex;return oe!==0?oe:M.id-Y.id}if(s.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;s.unstable_now=function(){return u.now()}}else{var x=Date,y=x.now();s.unstable_now=function(){return x.now()-y}}var p=[],g=[],b=1,f=null,k=3,w=!1,N=!1,j=!1,T=!1,S=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,z=typeof setImmediate<"u"?setImmediate:null;function A(M){for(var Y=i(g);Y!==null;){if(Y.callback===null)o(g);else if(Y.startTime<=M)o(g),Y.sortIndex=Y.expirationTime,l(p,Y);else break;Y=i(g)}}function L(M){if(j=!1,A(M),!N)if(i(p)!==null)N=!0,F||(F=!0,I());else{var Y=i(g);Y!==null&&ne(L,Y.startTime-M)}}var F=!1,D=-1,te=5,pe=-1;function he(){return T?!0:!(s.unstable_now()-pe<te)}function X(){if(T=!1,F){var M=s.unstable_now();pe=M;var Y=!0;try{e:{N=!1,j&&(j=!1,_(D),D=-1),w=!0;var oe=k;try{t:{for(A(M),f=i(p);f!==null&&!(f.expirationTime>M&&he());){var Ce=f.callback;if(typeof Ce=="function"){f.callback=null,k=f.priorityLevel;var Ae=Ce(f.expirationTime<=M);if(M=s.unstable_now(),typeof Ae=="function"){f.callback=Ae,A(M),Y=!0;break t}f===i(p)&&o(p),A(M)}else o(p);f=i(p)}if(f!==null)Y=!0;else{var H=i(g);H!==null&&ne(L,H.startTime-M),Y=!1}}break e}finally{f=null,k=oe,w=!1}Y=void 0}}finally{Y?I():F=!1}}}var I;if(typeof z=="function")I=function(){z(X)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,be=q.port2;q.port1.onmessage=X,I=function(){be.postMessage(null)}}else I=function(){S(X,0)};function ne(M,Y){D=S(function(){M(s.unstable_now())},Y)}s.unstable_IdlePriority=5,s.unstable_ImmediatePriority=1,s.unstable_LowPriority=4,s.unstable_NormalPriority=3,s.unstable_Profiling=null,s.unstable_UserBlockingPriority=2,s.unstable_cancelCallback=function(M){M.callback=null},s.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):te=0<M?Math.floor(1e3/M):5},s.unstable_getCurrentPriorityLevel=function(){return k},s.unstable_next=function(M){switch(k){case 1:case 2:case 3:var Y=3;break;default:Y=k}var oe=k;k=Y;try{return M()}finally{k=oe}},s.unstable_requestPaint=function(){T=!0},s.unstable_runWithPriority=function(M,Y){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var oe=k;k=M;try{return Y()}finally{k=oe}},s.unstable_scheduleCallback=function(M,Y,oe){var Ce=s.unstable_now();switch(typeof oe=="object"&&oe!==null?(oe=oe.delay,oe=typeof oe=="number"&&0<oe?Ce+oe:Ce):oe=Ce,M){case 1:var Ae=-1;break;case 2:Ae=250;break;case 5:Ae=1073741823;break;case 4:Ae=1e4;break;default:Ae=5e3}return Ae=oe+Ae,M={id:b++,callback:Y,priorityLevel:M,startTime:oe,expirationTime:Ae,sortIndex:-1},oe>Ce?(M.sortIndex=oe,l(g,M),i(p)===null&&M===i(g)&&(j?(_(D),D=-1):j=!0,ne(L,oe-Ce))):(M.sortIndex=Ae,l(p,M),N||w||(N=!0,F||(F=!0,I()))),M},s.unstable_shouldYield=he,s.unstable_wrapCallback=function(M){var Y=k;return function(){var oe=k;k=Y;try{return M.apply(this,arguments)}finally{k=oe}}}})(mu)),mu}var gg;function zb(){return gg||(gg=1,uu.exports=Rb()),uu.exports}var hu={exports:{}},ea={};var fg;function Lb(){if(fg)return ea;fg=1;var s=Zu();function l(p){var g="https://react.dev/errors/"+p;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)g+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+p+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var o={d:{f:i,r:function(){throw Error(l(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},d=Symbol.for("react.portal");function u(p,g,b){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:d,key:f==null?null:""+f,children:p,containerInfo:g,implementation:b}}var x=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function y(p,g){if(p==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return ea.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,ea.createPortal=function(p,g){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(l(299));return u(p,g,null,b)},ea.flushSync=function(p){var g=x.T,b=o.p;try{if(x.T=null,o.p=2,p)return p()}finally{x.T=g,o.p=b,o.d.f()}},ea.preconnect=function(p,g){typeof p=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,o.d.C(p,g))},ea.prefetchDNS=function(p){typeof p=="string"&&o.d.D(p)},ea.preinit=function(p,g){if(typeof p=="string"&&g&&typeof g.as=="string"){var b=g.as,f=y(b,g.crossOrigin),k=typeof g.integrity=="string"?g.integrity:void 0,w=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;b==="style"?o.d.S(p,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:f,integrity:k,fetchPriority:w}):b==="script"&&o.d.X(p,{crossOrigin:f,integrity:k,fetchPriority:w,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},ea.preinitModule=function(p,g){if(typeof p=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var b=y(g.as,g.crossOrigin);o.d.M(p,{crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&o.d.M(p)},ea.preload=function(p,g){if(typeof p=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var b=g.as,f=y(b,g.crossOrigin);o.d.L(p,b,{crossOrigin:f,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},ea.preloadModule=function(p,g){if(typeof p=="string")if(g){var b=y(g.as,g.crossOrigin);o.d.m(p,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else o.d.m(p)},ea.requestFormReset=function(p){o.d.r(p)},ea.unstable_batchedUpdates=function(p,g){return p(g)},ea.useFormState=function(p,g,b){return x.H.useFormState(p,g,b)},ea.useFormStatus=function(){return x.H.useHostTransitionStatus()},ea.version="19.2.4",ea}var pg;function Mb(){if(pg)return hu.exports;pg=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(l){console.error(l)}}return s(),hu.exports=Lb(),hu.exports}var yg;function Ob(){if(yg)return Rl;yg=1;var s=zb(),l=Zu(),i=Mb();function o(t){var a="https://react.dev/errors/"+t;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)a+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+t+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function d(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function u(t){var a=t,n=t;if(t.alternate)for(;a.return;)a=a.return;else{t=a;do a=t,(a.flags&4098)!==0&&(n=a.return),t=a.return;while(t)}return a.tag===3?n:null}function x(t){if(t.tag===13){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function y(t){if(t.tag===31){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function p(t){if(u(t)!==t)throw Error(o(188))}function g(t){var a=t.alternate;if(!a){if(a=u(t),a===null)throw Error(o(188));return a!==t?null:t}for(var n=t,r=a;;){var c=n.return;if(c===null)break;var m=c.alternate;if(m===null){if(r=c.return,r!==null){n=r;continue}break}if(c.child===m.child){for(m=c.child;m;){if(m===n)return p(c),t;if(m===r)return p(c),a;m=m.sibling}throw Error(o(188))}if(n.return!==r.return)n=c,r=m;else{for(var v=!1,E=c.child;E;){if(E===n){v=!0,n=c,r=m;break}if(E===r){v=!0,r=c,n=m;break}E=E.sibling}if(!v){for(E=m.child;E;){if(E===n){v=!0,n=m,r=c;break}if(E===r){v=!0,r=m,n=c;break}E=E.sibling}if(!v)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?t:a}function b(t){var a=t.tag;if(a===5||a===26||a===27||a===6)return t;for(t=t.child;t!==null;){if(a=b(t),a!==null)return a;t=t.sibling}return null}var f=Object.assign,k=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),z=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),te=Symbol.for("react.lazy"),pe=Symbol.for("react.activity"),he=Symbol.for("react.memo_cache_sentinel"),X=Symbol.iterator;function I(t){return t===null||typeof t!="object"?null:(t=X&&t[X]||t["@@iterator"],typeof t=="function"?t:null)}var q=Symbol.for("react.client.reference");function be(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===q?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case j:return"Fragment";case S:return"Profiler";case T:return"StrictMode";case L:return"Suspense";case F:return"SuspenseList";case pe:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case N:return"Portal";case z:return t.displayName||"Context";case _:return(t._context.displayName||"Context")+".Consumer";case A:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case D:return a=t.displayName||null,a!==null?a:be(t.type)||"Memo";case te:a=t._payload,t=t._init;try{return be(t(a))}catch{}}return null}var ne=Array.isArray,M=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe={pending:!1,data:null,method:null,action:null},Ce=[],Ae=-1;function H(t){return{current:t}}function Z(t){0>Ae||(t.current=Ce[Ae],Ce[Ae]=null,Ae--)}function $(t,a){Ae++,Ce[Ae]=t.current,t.current=a}var O=H(null),P=H(null),V=H(null),ye=H(null);function ge(t,a){switch($(V,a),$(P,t),$(O,null),a.nodeType){case 9:case 11:t=(t=a.documentElement)&&(t=t.namespaceURI)?Lx(t):0;break;default:if(t=a.tagName,a=a.namespaceURI)a=Lx(a),t=Mx(a,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}Z(O),$(O,t)}function qe(){Z(O),Z(P),Z(V)}function nt(t){t.memoizedState!==null&&$(ye,t);var a=O.current,n=Mx(a,t.type);a!==n&&($(P,t),$(O,n))}function R(t){P.current===t&&(Z(O),Z(P)),ye.current===t&&(Z(ye),Sl._currentValue=oe)}var we,ie;function Ee(t){if(we===void 0)try{throw Error()}catch(n){var a=n.stack.trim().match(/\n( *(at )?)/);we=a&&a[1]||"",ie=-1<n.stack.indexOf(` 2 at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return` 3`+we+t+ie}var Je=!1;
vendor: 7,047 bytes, lines 3-8
3function me(t,a){if(!t||Je)return"";Je=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(a){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(re){var ae=re}Reflect.construct(t,[],fe)}else{try{fe.call()}catch(re){ae=re}t.call(fe.prototype)}}else{try{throw Error()}catch(re){ae=re}(fe=t())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(re){if(re&&ae&&typeof re.stack=="string")return[re.stack,ae.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var m=r.DetermineComponentFrameRoot(),v=m[0],E=m[1];if(v&&E){var B=v.split(` 4`),ee=E.split(` 5`);for(c=r=0;r<B.length&&!B[r].includes("DetermineComponentFrameRoot");)r++;for(;c<ee.length&&!ee[c].includes("DetermineComponentFrameRoot");)c++;if(r===B.length||c===ee.length)for(r=B.length-1,c=ee.length-1;1<=r&&0<=c&&B[r]!==ee[c];)c--;for(;1<=r&&0<=c;r--,c--)if(B[r]!==ee[c]){if(r!==1||c!==1)do if(r--,c--,0>c||B[r]!==ee[c]){var ue=` 6`+B[r].replace(" at new "," at ");return t.displayName&&ue.includes("<anonymous>")&&(ue=ue.replace("<anonymous>",t.displayName)),ue}while(1<=r&&0<=c);break}}}finally{Je=!1,Error.prepareStackTrace=n}return(n=t?t.displayName||t.name:"")?Ee(n):""}function ke(t,a){switch(t.tag){case 26:case 27:case 5:return Ee(t.type);case 16:return Ee("Lazy");case 13:return t.child!==a&&a!==null?Ee("Suspense Fallback"):Ee("Suspense");case 19:return Ee("SuspenseList");case 0:case 15:return me(t.type,!1);case 11:return me(t.type.render,!1);case 1:return me(t.type,!0);case 31:return Ee("Activity");default:return""}}function ze(t){try{var a="",n=null;do a+=ke(t,n),n=t,t=t.return;while(t);return a}catch(r){return` 7Error generating stack: `+r.message+` 8`+r.stack}}var C=Object.prototype.hasOwnProperty,ve=s.unstable_scheduleCallback,Oe=s.unstable_cancelCallback,dt=s.unstable_shouldYield,Q=s.unstable_requestPaint,He=s.unstable_now,It=s.unstable_getCurrentPriorityLevel,Ls=s.unstable_ImmediatePriority,Ms=s.unstable_UserBlockingPriority,un=s.unstable_NormalPriority,qr=s.unstable_LowPriority,Zl=s.unstable_IdlePriority,Xo=s.log,Un=s.unstable_setDisableYieldValue,Os=null,Jt=null;function es(t){if(typeof Xo=="function"&&Un(t),Jt&&typeof Jt.setStrictMode=="function")try{Jt.setStrictMode(Os,t)}catch{}}var aa=Math.clz32?Math.clz32:Kl,Wo=Math.log,Br=Math.LN2;function Kl(t){return t>>>=0,t===0?32:31-(Wo(t)/Br|0)|0}var mn=256,hn=262144,K=4194304;function Re(t){var a=t&42;if(a!==0)return a;switch(t&-t){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 t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Ue(t,a,n){var r=t.pendingLanes;if(r===0)return 0;var c=0,m=t.suspendedLanes,v=t.pingedLanes;t=t.warmLanes;var E=r&134217727;return E!==0?(r=E&~m,r!==0?c=Re(r):(v&=E,v!==0?c=Re(v):n||(n=E&~t,n!==0&&(c=Re(n))))):(E=r&~m,E!==0?c=Re(E):v!==0?c=Re(v):n||(n=r&~t,n!==0&&(c=Re(n)))),c===0?0:a!==0&&a!==c&&(a&m)===0&&(m=c&-c,n=a&-a,m>=n||m===32&&(n&4194048)!==0)?a:c}function Ge(t,a){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&a)===0}function Sa(t,a){switch(t){case 1:case 2:case 4:case 8:case 64:return a+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 a+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 sa(){var t=K;return K<<=1,(K&62914560)===0&&(K=4194304),t}function cs(t){for(var a=[],n=0;31>n;n++)a.push(t);return a}function Pe(t,a){t.pendingLanes|=a,a!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Dt(t,a,n,r,c,m){var v=t.pendingLanes;t.pendingLanes=n,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=n,t.entangledLanes&=n,t.errorRecoveryDisabledLanes&=n,t.shellSuspendCounter=0;var E=t.entanglements,B=t.expirationTimes,ee=t.hiddenUpdates;for(n=v&~n;0<n;){var ue=31-aa(n),fe=1<<ue;E[ue]=0,B[ue]=-1;var ae=ee[ue];if(ae!==null)for(ee[ue]=null,ue=0;ue<ae.length;ue++){var re=ae[ue];re!==null&&(re.lane&=-536870913)}n&=~fe}r!==0&&Jl(t,r,0),m!==0&&c===0&&t.tag!==0&&(t.suspendedLanes|=m&~(v&~a))}function Jl(t,a,n){t.pendingLanes|=a,t.suspendedLanes&=~a;var r=31-aa(a);t.entangledLanes|=a,t.entanglements[r]=t.entanglements[r]|1073741824|n&261930}function fm(t,a){var n=t.entangledLanes|=a;for(t=t.entanglements;n;){var r=31-aa(n),c=1<<r;c&a|t[r]&a&&(t[r]|=a),n&=~c}}function pm(t,a){var n=a&-a;return n=(n&42)!==0?1:Zo(n),(n&(t.suspendedLanes|a))!==0?0:n}function Zo(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=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:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function Ko(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function ym(){var t=Y.p;return t!==0?t:(t=window.event,t===void 0?32:sg(t.type))}function bm(t,a){var n=Y.p;try{return Y.p=t,a()}finally{Y.p=n}}var $s=Math.random().toString(36).slice(2),Qt="__reactFiber$"+$s,ra="__reactProps$"+$s,Fn="__reactContainer$"+$s,Jo="__reactEvents$"+$s,pp="__reactListeners$"+$s,yp="__reactHandles$"+$s,vm="__reactResources$"+$s,Ur="__reactMarker$"+$s;function ec(t){delete t[Qt],delete t[ra],delete t[Jo],delete t[pp],delete t[yp]}function In(t){var a=t[Qt];if(a)return a;for(var n=t.parentNode;n;){if(a=n[Fn]||n[Qt]){if(n=a.alternate,a.child!==null||n!==null&&n.child!==null)for(t=Ux(t);t!==null;){if(n=t[Qt])return n;t=Ux(t)}return a}t=n,n=t.parentNode}return null}function Vn(t){if(t=t[Qt]||t[Fn]){var a=t.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return t}return null}function Fr(t){var a=t.tag;if(a===5||a===26||a===27||a===6)return t.stateNode;throw Error(o(33))}function Gn(t){var a=t[vm];return a||(a=t[vm]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function Yt(t){t[Ur]=!0}var jm=new Set,wm={};function xn(t,a){Yn(t,a),Yn(t+"Capture",a)}function Yn(t,a){for(wm[t]=a,t=0;t<a.length;t++)jm.add(a[t])}var bp=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u
vendor: 6,763 bytes, line 8
8037D\\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]*$"),km={},Nm={};function vp(t){return C.call(Nm,t)?!0:C.call(km,t)?!1:bp.test(t)?Nm[t]=!0:(km[t]=!0,!1)}function ei(t,a,n){if(vp(a))if(n===null)t.removeAttribute(a);else{switch(typeof n){case"undefined":case"function":case"symbol":t.removeAttribute(a);return;case"boolean":var r=a.toLowerCase().slice(0,5);if(r!=="data-"&&r!=="aria-"){t.removeAttribute(a);return}}t.setAttribute(a,""+n)}}function ti(t,a,n){if(n===null)t.removeAttribute(a);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(a);return}t.setAttribute(a,""+n)}}function ds(t,a,n,r){if(r===null)t.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(n);return}t.setAttributeNS(a,n,""+r)}}function Ca(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function _m(t){var a=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function jp(t,a,n){var r=Object.getOwnPropertyDescriptor(t.constructor.prototype,a);if(!t.hasOwnProperty(a)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var c=r.get,m=r.set;return Object.defineProperty(t,a,{configurable:!0,get:function(){return c.call(this)},set:function(v){n=""+v,m.call(this,v)}}),Object.defineProperty(t,a,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(v){n=""+v},stopTracking:function(){t._valueTracker=null,delete t[a]}}}}function tc(t){if(!t._valueTracker){var a=_m(t)?"checked":"value";t._valueTracker=jp(t,a,""+t[a])}}function Sm(t){if(!t)return!1;var a=t._valueTracker;if(!a)return!0;var n=a.getValue(),r="";return t&&(r=_m(t)?t.checked?"true":"false":t.value),t=r,t!==n?(a.setValue(t),!0):!1}function ai(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var wp=/[\n"\\]/g;function Aa(t){return t.replace(wp,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function ac(t,a,n,r,c,m,v,E){t.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?t.type=v:t.removeAttribute("type"),a!=null?v==="number"?(a===0&&t.value===""||t.value!=a)&&(t.value=""+Ca(a)):t.value!==""+Ca(a)&&(t.value=""+Ca(a)):v!=="submit"&&v!=="reset"||t.removeAttribute("value"),a!=null?sc(t,v,Ca(a)):n!=null?sc(t,v,Ca(n)):r!=null&&t.removeAttribute("value"),c==null&&m!=null&&(t.defaultChecked=!!m),c!=null&&(t.checked=c&&typeof c!="function"&&typeof c!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?t.name=""+Ca(E):t.removeAttribute("name")}function Cm(t,a,n,r,c,m,v,E){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(t.type=m),a!=null||n!=null){if(!(m!=="submit"&&m!=="reset"||a!=null)){tc(t);return}n=n!=null?""+Ca(n):"",a=a!=null?""+Ca(a):n,E||a===t.value||(t.value=a),t.defaultValue=a}r=r??c,r=typeof r!="function"&&typeof r!="symbol"&&!!r,t.checked=E?t.checked:!!r,t.defaultChecked=!!r,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(t.name=v),tc(t)}function sc(t,a,n){a==="number"&&ai(t.ownerDocument)===t||t.defaultValue===""+n||(t.defaultValue=""+n)}function Pn(t,a,n,r){if(t=t.options,a){a={};for(var c=0;c<n.length;c++)a["$"+n[c]]=!0;for(n=0;n<t.length;n++)c=a.hasOwnProperty("$"+t[n].value),t[n].selected!==c&&(t[n].selected=c),c&&r&&(t[n].defaultSelected=!0)}else{for(n=""+Ca(n),a=null,c=0;c<t.length;c++){if(t[c].value===n){t[c].selected=!0,r&&(t[c].defaultSelected=!0);return}a!==null||t[c].disabled||(a=t[c])}a!==null&&(a.selected=!0)}}function Am(t,a,n){if(a!=null&&(a=""+Ca(a),a!==t.value&&(t.value=a),n==null)){t.defaultValue!==a&&(t.defaultValue=a);return}t.defaultValue=n!=null?""+Ca(n):""}function Em(t,a,n,r){if(a==null){if(r!=null){if(n!=null)throw Error(o(92));if(ne(r)){if(1<r.length)throw Error(o(93));r=r[0]}n=r}n==null&&(n=""),a=n}n=Ca(a),t.defaultValue=n,r=t.textContent,r===n&&r!==""&&r!==null&&(t.value=r),tc(t)}function Qn(t,a){if(a){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=a;return}}t.textContent=a}var kp=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 Tm(t,a,n){var r=a.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?r?t.setProperty(a,""):a==="float"?t.cssFloat="":t[a]="":r?t.setProperty(a,n):typeof n!="number"||n===0||kp.has(a)?a==="float"?t.cssFloat=n:t[a]=(""+n).trim():t[a]=n+"px"}function Rm(t,a,n){if(a!=null&&typeof a!="object")throw Error(o(62));if(t=t.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||a!=null&&a.hasOwnProperty(r)||(r.indexOf("--")===0?t.setProperty(r,""):r==="float"?t.cssFloat="":t[r]="");for(var c in a)r=a[c],a.hasOwnProperty(c)&&n[c]!==r&&Tm(t,c,r)}else for(var m in a)a.hasOwnProperty(m)&&Tm(t,m,a[m])}function nc(t){if(t.indexOf("-")===-1)return!1;switch(t){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 Np=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"],["colorRen
8dering","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-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"]]),_p=/^[\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 si(t){return _p.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function us(){}var rc=null;function lc(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Xn=null,Wn=null;function zm(t){var a=Vn(t);if(a&&(t=a.stateNode)){var n=t[ra]||null;e:switch(t=a.stateNode,a.type){case"input":if(ac(t,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),a=n.name,n.type==="radio"&&a!=null){for(n=t;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+Aa(""+a)+'"][type="radio"]'),a=0;a<n.length;a++){var r=n[a];if(r!==t&&r.form===t.form){var c=r[ra]||null;if(!c)throw Error(o(90));ac(r,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(a=0;a<n.length;a++)r=n[a],r.form===t.form&&Sm(r)}break e;case"textarea":Am(t,n.value,n.defaultValue);break e;case"select":a=n.value,a!=null&&Pn(t,!!n.multiple,a,!1)}}}var ic=!1;function Lm(t,a,n){if(ic)return t(a,n);ic=!0;try{var r=t(a);return r}finally{if(ic=!1,(Xn!==null||Wn!==null)&&(Vi(),Xn&&(a=Xn,t=Wn,Wn=Xn=null,zm(a),t)))for(a=0;a<t.length;a++)zm(t[a])}}function Ir(t,a){var n=t.stateNode;if(n===null)return null;var r=n[ra]||null;if(r===null)return null;n=r[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(t=t.type,r=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!r;break e;default:t=!1}if(t)return null;if(n&&typeof n!="function")throw Error(o(231,a,typeof n));return n}var ms=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),oc=!1;if(ms)try{var Vr={};Object.defineProperty(Vr,"passive",{get:function(){oc=!0}}),window.addEventListener("test",Vr,Vr),window.removeEventListener("test",Vr,Vr)}catch{oc=!1}var Ds=null,cc=null,ni=null;function Mm(){if(ni)return ni;var t,a=cc,n=a.length,r,c="value"in Ds?Ds.value:Ds.textContent,m=c.length;for(t=0;t<n&&a[t]===c[t];t++);var v=n-t;for(r=1;r<=v&&a[n-r]===c[m-r];r++);return ni=c.slice(t,1<r?1-r:void 0)}function ri(t){var a=t.keyCode;
vendor: 5,472 bytes, line 8
8return"charCode"in t?(t=t.charCode,t===0&&a===13&&(t=13)):t=a,t===10&&(t=13),32<=t||t===13?t:0}function li(){return!0}function Om(){return!1}function la(t){function a(n,r,c,m,v){this._reactName=n,this._targetInst=c,this.type=r,this.nativeEvent=m,this.target=v,this.currentTarget=null;for(var E in t)t.hasOwnProperty(E)&&(n=t[E],this[E]=n?n(m):m[E]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?li:Om,this.isPropagationStopped=Om,this}return f(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=li)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=li)},persist:function(){},isPersistent:li}),a}var gn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ii=la(gn),Gr=f({},gn,{view:0,detail:0}),Sp=la(Gr),dc,uc,Yr,oi=f({},Gr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:hc,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Yr&&(Yr&&t.type==="mousemove"?(dc=t.screenX-Yr.screenX,uc=t.screenY-Yr.screenY):uc=dc=0,Yr=t),dc)},movementY:function(t){return"movementY"in t?t.movementY:uc}}),$m=la(oi),Cp=f({},oi,{dataTransfer:0}),Ap=la(Cp),Ep=f({},Gr,{relatedTarget:0}),mc=la(Ep),Tp=f({},gn,{animationName:0,elapsedTime:0,pseudoElement:0}),Rp=la(Tp),zp=f({},gn,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Lp=la(zp),Mp=f({},gn,{data:0}),Dm=la(Mp),Op={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},$p={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"},Dp={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Hp(t){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(t):(t=Dp[t])?!!a[t]:!1}function hc(){return Hp}var qp=f({},Gr,{key:function(t){if(t.key){var a=Op[t.key]||t.key;if(a!=="Unidentified")return a}return t.type==="keypress"?(t=ri(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?$p[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:hc,charCode:function(t){return t.type==="keypress"?ri(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?ri(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),Bp=la(qp),Up=f({},oi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Hm=la(Up),Fp=f({},Gr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:hc}),Ip=la(Fp),Vp=f({},gn,{propertyName:0,elapsedTime:0,pseudoElement:0}),Gp=la(Vp),Yp=f({},oi,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Pp=la(Yp),Qp=f({},gn,{newState:0,oldState:0}),Xp=la(Qp),Wp=[9,13,27,32],xc=ms&&"CompositionEvent"in window,Pr=null;ms&&"documentMode"in document&&(Pr=document.documentMode);var Zp=ms&&"TextEvent"in window&&!Pr,qm=ms&&(!xc||Pr&&8<Pr&&11>=Pr),Bm=" ",Um=!1;function Fm(t,a){switch(t){case"keyup":return Wp.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Im(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Zn=!1;function Kp(t,a){switch(t){case"compositionend":return Im(a);case"keypress":return a.which!==32?null:(Um=!0,Bm);case"textInput":return t=a.data,t===Bm&&Um?null:t;default:return null}}function Jp(t,a){if(Zn)return t==="compositionend"||!xc&&Fm(t,a)?(t=Mm(),ni=cc=Ds=null,Zn=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return qm&&a.locale!=="ko"?null:a.data;default:return null}}var ey={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 Vm(t){var a=t&&t.nodeName&&t.nodeName.toLowerCase();return a==="input"?!!ey[t.type]:a==="textarea"}function Gm(t,a,n,r){Xn?Wn?Wn.push(r):Wn=[r]:Xn=r,a=Zi(a,"onChange"),0<a.length&&(n=new ii("onChange","change",null,n,r),t.push({event:n,listeners:a}))}var Qr=null,Xr=null;function ty(t){Cx(t,0)}function ci(t){var a=Fr(t);if(Sm(a))return t}
vendor: 4,924 bytes, line 8
8function Ym(t,a){if(t==="change")return a}var Pm=!1;if(ms){var gc;if(ms){var fc="oninput"in document;if(!fc){var Qm=document.createElement("div");Qm.setAttribute("oninput","return;"),fc=typeof Qm.oninput=="function"}gc=fc}else gc=!1;Pm=gc&&(!document.documentMode||9<document.documentMode)}function Xm(){Qr&&(Qr.detachEvent("onpropertychange",Wm),Xr=Qr=null)}function Wm(t){if(t.propertyName==="value"&&ci(Xr)){var a=[];Gm(a,Xr,t,lc(t)),Lm(ty,a)}}function ay(t,a,n){t==="focusin"?(Xm(),Qr=a,Xr=n,Qr.attachEvent("onpropertychange",Wm)):t==="focusout"&&Xm()}function sy(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return ci(Xr)}function ny(t,a){if(t==="click")return ci(a)}function ry(t,a){if(t==="input"||t==="change")return ci(a)}function ly(t,a){return t===a&&(t!==0||1/t===1/a)||t!==t&&a!==a}var ga=typeof Object.is=="function"?Object.is:ly;function Wr(t,a){if(ga(t,a))return!0;if(typeof t!="object"||t===null||typeof a!="object"||a===null)return!1;var n=Object.keys(t),r=Object.keys(a);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var c=n[r];if(!C.call(a,c)||!ga(t[c],a[c]))return!1}return!0}function Zm(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Km(t,a){var n=Zm(t);t=0;for(var r;n;){if(n.nodeType===3){if(r=t+n.textContent.length,t<=a&&r>=a)return{node:n,offset:a-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Zm(n)}}function Jm(t,a){return t&&a?t===a?!0:t&&t.nodeType===3?!1:a&&a.nodeType===3?Jm(t,a.parentNode):"contains"in t?t.contains(a):t.compareDocumentPosition?!!(t.compareDocumentPosition(a)&16):!1:!1}function eh(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var a=ai(t.document);a instanceof t.HTMLIFrameElement;){try{var n=typeof a.contentWindow.location.href=="string"}catch{n=!1}if(n)t=a.contentWindow;else break;a=ai(t.document)}return a}function pc(t){var a=t&&t.nodeName&&t.nodeName.toLowerCase();return a&&(a==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||a==="textarea"||t.contentEditable==="true")}var iy=ms&&"documentMode"in document&&11>=document.documentMode,Kn=null,yc=null,Zr=null,bc=!1;function th(t,a,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;bc||Kn==null||Kn!==ai(r)||(r=Kn,"selectionStart"in r&&pc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Zr&&Wr(Zr,r)||(Zr=r,r=Zi(yc,"onSelect"),0<r.length&&(a=new ii("onSelect","select",null,a,n),t.push({event:a,listeners:r}),a.target=Kn)))}function fn(t,a){var n={};return n[t.toLowerCase()]=a.toLowerCase(),n["Webkit"+t]="webkit"+a,n["Moz"+t]="moz"+a,n}var Jn={animationend:fn("Animation","AnimationEnd"),animationiteration:fn("Animation","AnimationIteration"),animationstart:fn("Animation","AnimationStart"),transitionrun:fn("Transition","TransitionRun"),transitionstart:fn("Transition","TransitionStart"),transitioncancel:fn("Transition","TransitionCancel"),transitionend:fn("Transition","TransitionEnd")},vc={},ah={};ms&&(ah=document.createElement("div").style,"AnimationEvent"in window||(delete Jn.animationend.animation,delete Jn.animationiteration.animation,delete Jn.animationstart.animation),"TransitionEvent"in window||delete Jn.transitionend.transition);function pn(t){if(vc[t])return vc[t];if(!Jn[t])return t;var a=Jn[t],n;for(n in a)if(a.hasOwnProperty(n)&&n in ah)return vc[t]=a[n];return t}var sh=pn("animationend"),nh=pn("animationiteration"),rh=pn("animationstart"),oy=pn("transitionrun"),cy=pn("transitionstart"),dy=pn("transitioncancel"),lh=pn("transitionend"),ih=new Map,jc="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(" ");jc.push("scrollEnd");function Pa(t,a){ih.set(t,a),xn(a,[t])}var di=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var a=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(a))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)}
vendor: 13,907 bytes, line 8
8,Ea=[],er=0,wc=0;function ui(){for(var t=er,a=wc=er=0;a<t;){var n=Ea[a];Ea[a++]=null;var r=Ea[a];Ea[a++]=null;var c=Ea[a];Ea[a++]=null;var m=Ea[a];if(Ea[a++]=null,r!==null&&c!==null){var v=r.pending;v===null?c.next=c:(c.next=v.next,v.next=c),r.pending=c}m!==0&&oh(n,c,m)}}function mi(t,a,n,r){Ea[er++]=t,Ea[er++]=a,Ea[er++]=n,Ea[er++]=r,wc|=r,t.lanes|=r,t=t.alternate,t!==null&&(t.lanes|=r)}function kc(t,a,n,r){return mi(t,a,n,r),hi(t)}function yn(t,a){return mi(t,null,null,a),hi(t)}function oh(t,a,n){t.lanes|=n;var r=t.alternate;r!==null&&(r.lanes|=n);for(var c=!1,m=t.return;m!==null;)m.childLanes|=n,r=m.alternate,r!==null&&(r.childLanes|=n),m.tag===22&&(t=m.stateNode,t===null||t._visibility&1||(c=!0)),t=m,m=m.return;return t.tag===3?(m=t.stateNode,c&&a!==null&&(c=31-aa(n),t=m.hiddenUpdates,r=t[c],r===null?t[c]=[a]:r.push(a),a.lane=n|536870912),m):null}function hi(t){if(50<bl)throw bl=0,zd=null,Error(o(185));for(var a=t.return;a!==null;)t=a,a=t.return;return t.tag===3?t.stateNode:null}var tr={};function uy(t,a,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fa(t,a,n,r){return new uy(t,a,n,r)}function Nc(t){return t=t.prototype,!(!t||!t.isReactComponent)}function hs(t,a){var n=t.alternate;return n===null?(n=fa(t.tag,a,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=a,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&65011712,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,a=t.dependencies,n.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n.refCleanup=t.refCleanup,n}function ch(t,a){t.flags&=65011714;var n=t.alternate;return n===null?(t.childLanes=0,t.lanes=a,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,t.type=n.type,a=n.dependencies,t.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),t}function xi(t,a,n,r,c,m){var v=0;if(r=t,typeof t=="function")Nc(t)&&(v=1);else if(typeof t=="string")v=fb(t,n,O.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case pe:return t=fa(31,n,a,c),t.elementType=pe,t.lanes=m,t;case j:return bn(n.children,c,m,a);case T:v=8,c|=24;break;case S:return t=fa(12,n,a,c|2),t.elementType=S,t.lanes=m,t;case L:return t=fa(13,n,a,c),t.elementType=L,t.lanes=m,t;case F:return t=fa(19,n,a,c),t.elementType=F,t.lanes=m,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case z:v=10;break e;case _:v=9;break e;case A:v=11;break e;case D:v=14;break e;case te:v=16,r=null;break e}v=29,n=Error(o(130,t===null?"null":typeof t,"")),r=null}return a=fa(v,n,a,c),a.elementType=t,a.type=r,a.lanes=m,a}function bn(t,a,n,r){return t=fa(7,t,r,a),t.lanes=n,t}function _c(t,a,n){return t=fa(6,t,null,a),t.lanes=n,t}function dh(t){var a=fa(18,null,null,0);return a.stateNode=t,a}function Sc(t,a,n){return a=fa(4,t.children!==null?t.children:[],t.key,a),a.lanes=n,a.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},a}var uh=new WeakMap;function Ta(t,a){if(typeof t=="object"&&t!==null){var n=uh.get(t);return n!==void 0?n:(a={value:t,source:a,stack:ze(a)},uh.set(t,a),a)}return{value:t,source:a,stack:ze(a)}}var ar=[],sr=0,gi=null,Kr=0,Ra=[],za=0,Hs=null,ts=1,as="";function xs(t,a){ar[sr++]=Kr,ar[sr++]=gi,gi=t,Kr=a}function mh(t,a,n){Ra[za++]=ts,Ra[za++]=as,Ra[za++]=Hs,Hs=t;var r=ts;t=as;var c=32-aa(r)-1;r&=~(1<<c),n+=1;var m=32-aa(a)+c;if(30<m){var v=c-c%5;m=(r&(1<<v)-1).toString(32),r>>=v,c-=v,ts=1<<32-aa(a)+c|n<<c|r,as=m+t}else ts=1<<m|n<<c|r,as=t}function Cc(t){t.return!==null&&(xs(t,1),mh(t,1,0))}function Ac(t){for(;t===gi;)gi=ar[--sr],ar[sr]=null,Kr=ar[--sr],ar[sr]=null;for(;t===Hs;)Hs=Ra[--za],Ra[za]=null,as=Ra[--za],Ra[za]=null,ts=Ra[--za],Ra[za]=null}function hh(t,a){Ra[za++]=ts,Ra[za++]=as,Ra[za++]=Hs,ts=a.id,as=a.overflow,Hs=t}var Xt=null,wt=null,ct=!1,qs=null,La=!1,Ec=Error(o(519));function Bs(t){var a=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Jr(Ta(a,t)),Ec}function xh(t){var a=t.stateNode,n=t.type,r=t.memoizedProps;switch(a[Qt]=t,a[ra]=r,n){case"dialog":lt("cancel",a),lt("close",a);break;case"iframe":case"object":case"embed":lt("load",a);break;case"video":case"audio":for(n=0;n<jl.length;n++)lt(jl[n],a);break;case"source":lt("error",a);break;case"img":case"image":case"link":lt("error",a),lt("load",a);break;case"details":lt("toggle",a);break;case"input":lt("invalid",a),Cm(a,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case"select":lt("invalid",a);break;case"textarea":lt("invalid",a),Em(a,r.value,r.defaultValue,r.children)}n=r.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||a.textContent===""+n||r.suppressHydrationWarning===!0||Rx(a.textContent,n)?(r.popover!=null&&(lt("beforetoggle",a),lt("toggle",a)),r.onScroll!=null&<("scroll",a),r.onScrollEnd!=null&<("scrollend",a),r.onClick!=null&&(a.onclick=us),a=!0):a=!1,a||Bs(t,!0)}function gh(t){for(Xt=t.return;Xt;)switch(Xt.tag){case 5:case 31:case 13:La=!1;return;case 27:case 3:La=!0;return;default:Xt=Xt.return}}function nr(t){if(t!==Xt)return!1;if(!ct)return gh(t),ct=!0,!1;var a=t.tag,n;if((n=a!==3&&a!==27)&&((n=a===5)&&(n=t.type,n=!(n!=="form"&&n!=="button")||Pd(t.type,t.memoizedProps)),n=!n),n&&wt&&Bs(t),gh(t),a===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(o(317));wt=Bx(t)}else if(a===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(o(317));wt=Bx(t)}else a===27?(a=wt,en(t.type)?(t=Kd,Kd=null,wt=t):wt=a):wt=Xt?Oa(t.stateNode.nextSibling):null;return!0}function vn(){wt=Xt=null,ct=!1}function Tc(){var t=qs;return t!==null&&(da===null?da=t:da.push.apply(da,t),qs=null),t}function Jr(t){qs===null?qs=[t]:qs.push(t)}var Rc=H(null),jn=null,gs=null;function Us(t,a,n){$(Rc,a._currentValue),a._currentValue=n}function fs(t){t._currentValue=Rc.current,Z(Rc)}function zc(t,a,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&a)!==a?(t.childLanes|=a,r!==null&&(r.childLanes|=a)):r!==null&&(r.childLanes&a)!==a&&(r.childLanes|=a),t===n)break;t=t.return}}function Lc(t,a,n,r){var c=t.child;for(c!==null&&(c.return=t);c!==null;){var m=c.dependencies;if(m!==null){var v=c.child;m=m.firstContext;e:for(;m!==null;){var E=m;m=c;for(var B=0;B<a.length;B++)if(E.context===a[B]){m.lanes|=n,E=m.alternate,E!==null&&(E.lanes|=n),zc(m.return,n,t),r||(v=null);break e}m=E.next}}else if(c.tag===18){if(v=c.return,v===null)throw Error(o(341));v.lanes|=n,m=v.alternate,m!==null&&(m.lanes|=n),zc(v,n,t),v=null}else v=c.child;if(v!==null)v.return=c;else for(v=c;v!==null;){if(v===t){v=null;break}if(c=v.sibling,c!==null){c.return=v.return,v=c;break}v=v.return}c=v}}function rr(t,a,n,r){t=null;for(var c=a,m=!1;c!==null;){if(!m){if((c.flags&524288)!==0)m=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var v=c.alternate;if(v===null)throw Error(o(387));if(v=v.memoizedProps,v!==null){var E=c.type;ga(c.pendingProps.value,v.value)||(t!==null?t.push(E):t=[E])}}else if(c===ye.current){if(v=c.alternate,v===null)throw Error(o(387));v.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(t!==null?t.push(Sl):t=[Sl])}c=c.return}t!==null&&Lc(a,t,n,r),a.flags|=262144}function fi(t){for(t=t.firstContext;t!==null;){if(!ga(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function wn(t){jn=t,gs=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Wt(t){return fh(jn,t)}function pi(t,a){return jn===null&&wn(t),fh(t,a)}function fh(t,a){var n=a._currentValue;if(a={context:a,memoizedValue:n,next:null},gs===null){if(t===null)throw Error(o(308));gs=a,t.dependencies={lanes:0,firstContext:a},t.flags|=524288}else gs=gs.next=a;return n}var my=typeof AbortController<"u"?AbortController:function(){var t=[],a=this.signal={aborted:!1,addEventListener:function(n,r){t.push(r)}};this.abort=function(){a.aborted=!0,t.forEach(function(n){return n()})}},hy=s.unstable_scheduleCallback,xy=s.unstable_NormalPriority,Ht={$$typeof:z,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Mc(){return{controller:new my,data:new Map,refCount:0}}function el(t){t.refCount--,t.refCount===0&&hy(xy,function(){t.controller.abort()})}var tl=null,Oc=0,lr=0,ir=null;function gy(t,a){if(tl===null){var n=tl=[];Oc=0,lr=Hd(),ir={status:"pending",value:void 0,then:function(r){n.push(r)}}}return Oc++,a.then(ph,ph),a}function ph(){if(--Oc===0&&tl!==null){ir!==null&&(ir.status="fulfilled");var t=tl;tl=null,lr=0,ir=null;for(var a=0;a<t.length;a++)(0,t[a])()}}function fy(t,a){var n=[],r={status:"pending",value:null,reason:null,then:function(c){n.push(c)}};return t.then(function(){r.status="fulfilled",r.value=a;for(var c=0;c<n.length;c++)(0,n[c])(a)},function(c){for(r.status="rejected",r.reason=c,c=0;c<n.length;c++)(0,n[c])(void 0)}),r}var yh=M.S;M.S=function(t,a){tx=He(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&gy(t,a),yh!==null&&yh(t,a)};var kn=H(null);function $c(){var t=kn.current;return t!==null?t:jt.pooledCache}function yi(t,a){a===null?$(kn,kn.current):$(kn,a.pool)}function bh(){var t=$c();return t===null?null:{parent:Ht._currentValue,pool:t}}var or=Error(o(460)),Dc=Error(o(474)),bi=Error(o(542)),vi={then:function(){}};function vh(t){return t=t.status,t==="fulfilled"||t==="rejected"}function jh(t,a,n){switch(n=t[n],n===void 0?t.push(a):n!==a&&(a.then(us,us),a=n),a.status){case"fulfilled":return a.value;case"rejected":throw t=a.reason,kh(t),t;default:if(typeof a.status=="string")a.then(us,us);else{if(t=jt,t!==null&&100<t.shellSuspendCounter)throw Error(o(482));t=a,t.status="pending",t.then(function(r){if(a.status==="pending"){var c=a;c.status="fulfilled",c.value=r}},function(r){if(a.status==="pending"){var c=a;c.status="rejected",c.reason=r}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw t=a.reason,kh(t),t}throw _n=a,or}}function Nn(t){try{var a=t._init;return a(t._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(_n=n,or):n}}var _n=null;function wh(){if(_n===null)throw Error(o(459));var t=_n;return _n=null,t}function kh(t){if(t===or||t===bi)throw Error(o(483))}var cr=null,al=0;function ji(t){var a=al;return al+=1,cr===null&&(cr=[]),jh(cr,t,a)}function sl(t,a){a=a.props.ref,t.ref=a!==void 0?a:null}function wi(t,a){throw a.$$typeof===k?Error(o(525)):(t=Object.prototype.toString.call(a),Error(o(31,t==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":t)))}function Nh(t){function a(W,G){if(t){var J=W.deletions;J===null?(W.deletions=[G],W.flags|=16):J.push(G)}}function n(W,G){if(!t)return null;for(;G!==null;)a(W,G),G=G.sibling;return null}function r(W){for(var G=new Map;W!==null;)W.key!==null?G.set(W.key,W):G.set(W.index,W),W=W.sibling;return G}function c(W,G){return W=hs(W,G),W.index=0,W.sibling=null,W}function m(W,G,J){return W.index=J,t?(J=W.alternate,J!==null?(J=J.index,J<G?(W.flags|=67108866,G):J):(W.flags|=67108866,G)):(W.flags|=1048576,G)}function v(W){return t&&W.alternate===null&&(W.flags|=67108866),W}function E(W,G,J,xe){return G===null||G.tag!==6?(G=_c(J,W.mode,xe),G.return=W,G):(G=c(G,J),G.return=W,G)}function B(W,G,J,xe){var Ve=J.type;return Ve===j?ue(W,G,J.props.children,xe,J.key):G!==null&&(G.elementType===Ve||typeof Ve=="object"&&Ve!==null&&Ve.$$typeof===te&&Nn(Ve)===G.type)?(G=c(G,J.props),sl(G,J),G.return=W,G):(G=xi(J.type,J.key,J.props,null,W.mode,xe),sl(G,J),G.return=W,G)}function ee(W,G,J,xe){return G===null||G.tag!==4||G.stateNode.containerInfo!==J.containerInfo||G.stateNode.implementation!==J.implementation?(G=Sc(J,W.mode,xe),G.return=W,G):(G=c(G,J.children||[]),G.return=W,G)}function ue(W,G,J,xe,Ve){return G===null||G.tag!==7?(G=bn(J,W.mode,xe,Ve),G.return=W,G):(G=c(G,J),G.return=W,G)}function fe(W,G,J){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=_c(""+G,W.mode,J),G.return=W,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case w:return J=xi(G.type,G.key,G.props,null,W.mode,J),sl(J,G),J.return=W,J;case N:return G=Sc(G,W.mode,J),G.return=W,G;case te:return G=Nn(G),fe(W,G,J)}if(ne(G)||I(G))return G=bn(G,W.mode,J,null),G.return=W,G;if(typeof G.then=="function")return fe(W,ji(G),J);if(G.$$typeof===z)return fe(W,pi(W,G),J);wi(W,G)}return null}function ae(W,G,J,xe){var Ve=G!==null?G.key:null;if(typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint")return Ve!==null?null:E(W,G,""+J,xe);if(typeof J=="object"&&J!==null){switch(J.$$typeof){case w:return J.key===Ve?B(W,G,J,xe):null;case N:return J.key===Ve?ee(W,G,J,xe):null;case te:return J=Nn(J),ae(W,G,J,xe)}if(ne(J)||I(J))return Ve!==null?null:ue(W,G,J,xe,null);if(typeof J.then=="function")return ae(W,G,ji(J),xe);if(J.$$typeof===z)return ae(W,G,pi(W,J),xe);wi(W,J)}return null}function re(W,G,J,xe,Ve){if(typeof xe=="string"&&xe!==""||typeof xe=="number"||typeof xe=="bigint")return W=W.get(J)||null,E(G,W,""+xe,Ve);if(typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case w:return W=W.get(xe.key===null?J:xe.key)||null,B(G,W,xe,Ve);case N:return W=W.get(xe.key===null?J:xe.key)||null,ee(G,W,xe,Ve);case te:return xe=Nn(xe),re(W,G,J,xe,Ve)}if(ne(xe)||I(xe))return W=W.get(J)||null,ue(G,W,xe,Ve,null);if(typeof xe.then=="function")return re(W,G,J,ji(xe),Ve);
vendor: 6,062 bytes, line 8
8if(xe.$$typeof===z)return re(W,G,J,pi(G,xe),Ve);wi(G,xe)}return null}function De(W,G,J,xe){for(var Ve=null,ut=null,Be=G,st=G=0,ot=null;Be!==null&&st<J.length;st++){Be.index>st?(ot=Be,Be=null):ot=Be.sibling;var mt=ae(W,Be,J[st],xe);if(mt===null){Be===null&&(Be=ot);break}t&&Be&&mt.alternate===null&&a(W,Be),G=m(mt,G,st),ut===null?Ve=mt:ut.sibling=mt,ut=mt,Be=ot}if(st===J.length)return n(W,Be),ct&&xs(W,st),Ve;if(Be===null){for(;st<J.length;st++)Be=fe(W,J[st],xe),Be!==null&&(G=m(Be,G,st),ut===null?Ve=Be:ut.sibling=Be,ut=Be);return ct&&xs(W,st),Ve}for(Be=r(Be);st<J.length;st++)ot=re(Be,W,st,J[st],xe),ot!==null&&(t&&ot.alternate!==null&&Be.delete(ot.key===null?st:ot.key),G=m(ot,G,st),ut===null?Ve=ot:ut.sibling=ot,ut=ot);return t&&Be.forEach(function(rn){return a(W,rn)}),ct&&xs(W,st),Ve}function Ye(W,G,J,xe){if(J==null)throw Error(o(151));for(var Ve=null,ut=null,Be=G,st=G=0,ot=null,mt=J.next();Be!==null&&!mt.done;st++,mt=J.next()){Be.index>st?(ot=Be,Be=null):ot=Be.sibling;var rn=ae(W,Be,mt.value,xe);if(rn===null){Be===null&&(Be=ot);break}t&&Be&&rn.alternate===null&&a(W,Be),G=m(rn,G,st),ut===null?Ve=rn:ut.sibling=rn,ut=rn,Be=ot}if(mt.done)return n(W,Be),ct&&xs(W,st),Ve;if(Be===null){for(;!mt.done;st++,mt=J.next())mt=fe(W,mt.value,xe),mt!==null&&(G=m(mt,G,st),ut===null?Ve=mt:ut.sibling=mt,ut=mt);return ct&&xs(W,st),Ve}for(Be=r(Be);!mt.done;st++,mt=J.next())mt=re(Be,W,st,mt.value,xe),mt!==null&&(t&&mt.alternate!==null&&Be.delete(mt.key===null?st:mt.key),G=m(mt,G,st),ut===null?Ve=mt:ut.sibling=mt,ut=mt);return t&&Be.forEach(function(Cb){return a(W,Cb)}),ct&&xs(W,st),Ve}function vt(W,G,J,xe){if(typeof J=="object"&&J!==null&&J.type===j&&J.key===null&&(J=J.props.children),typeof J=="object"&&J!==null){switch(J.$$typeof){case w:e:{for(var Ve=J.key;G!==null;){if(G.key===Ve){if(Ve=J.type,Ve===j){if(G.tag===7){n(W,G.sibling),xe=c(G,J.props.children),xe.return=W,W=xe;break e}}else if(G.elementType===Ve||typeof Ve=="object"&&Ve!==null&&Ve.$$typeof===te&&Nn(Ve)===G.type){n(W,G.sibling),xe=c(G,J.props),sl(xe,J),xe.return=W,W=xe;break e}n(W,G);break}else a(W,G);G=G.sibling}J.type===j?(xe=bn(J.props.children,W.mode,xe,J.key),xe.return=W,W=xe):(xe=xi(J.type,J.key,J.props,null,W.mode,xe),sl(xe,J),xe.return=W,W=xe)}return v(W);case N:e:{for(Ve=J.key;G!==null;){if(G.key===Ve)if(G.tag===4&&G.stateNode.containerInfo===J.containerInfo&&G.stateNode.implementation===J.implementation){n(W,G.sibling),xe=c(G,J.children||[]),xe.return=W,W=xe;break e}else{n(W,G);break}else a(W,G);G=G.sibling}xe=Sc(J,W.mode,xe),xe.return=W,W=xe}return v(W);case te:return J=Nn(J),vt(W,G,J,xe)}if(ne(J))return De(W,G,J,xe);if(I(J)){if(Ve=I(J),typeof Ve!="function")throw Error(o(150));return J=Ve.call(J),Ye(W,G,J,xe)}if(typeof J.then=="function")return vt(W,G,ji(J),xe);if(J.$$typeof===z)return vt(W,G,pi(W,J),xe);wi(W,J)}return typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint"?(J=""+J,G!==null&&G.tag===6?(n(W,G.sibling),xe=c(G,J),xe.return=W,W=xe):(n(W,G),xe=_c(J,W.mode,xe),xe.return=W,W=xe),v(W)):n(W,G)}return function(W,G,J,xe){try{al=0;var Ve=vt(W,G,J,xe);return cr=null,Ve}catch(Be){if(Be===or||Be===bi)throw Be;var ut=fa(29,Be,null,W.mode);return ut.lanes=xe,ut.return=W,ut}}}var Sn=Nh(!0),_h=Nh(!1),Fs=!1;function Hc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function qc(t,a){t=t.updateQueue,a.updateQueue===t&&(a.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Is(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Vs(t,a,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,(xt&2)!==0){var c=r.pending;return c===null?a.next=a:(a.next=c.next,c.next=a),r.pending=a,a=hi(t),oh(t,null,n),a}return mi(t,r,a,n),hi(t)}function nl(t,a,n){if(a=a.updateQueue,a!==null&&(a=a.shared,(n&4194048)!==0)){var r=a.lanes;r&=t.pendingLanes,n|=r,a.lanes=n,fm(t,n)}}function Bc(t,a){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var c=null,m=null;if(n=n.firstBaseUpdate,n!==null){do{var v={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};m===null?c=m=v:m=m.next=v,n=n.next}while(n!==null);m===null?c=m=a:m=m.next=a}else c=m=a;n={baseState:r.baseState,firstBaseUpdate:c,lastBaseUpdate:m,shared:r.shared,callbacks:r.callbacks},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=a:t.next=a,n.lastBaseUpdate=a}var Uc=!1;function rl(){if(Uc){var t=ir;if(t!==null)throw t}}function ll(t,a,n,r){Uc=!1;var c=t.updateQueue;Fs=!1;var m=c.firstBaseUpdate,v=c.lastBaseUpdate,E=c.shared.pending;if(E!==null){c.shared.pending=null;var B=E,ee=B.next;B.next=null,v===null?m=ee:v.next=ee,v=B;var ue=t.alternate;ue!==null&&(ue=ue.updateQueue,E=ue.lastBaseUpdate,E!==v&&(E===null?ue.firstBaseUpdate=ee:E.next=ee,ue.lastBaseUpdate=B))}if(m!==null){var fe=c.baseState;v=0,ue=ee=B=null,E=m;do{var ae=E.lane&-536870913,re=ae!==E.lane;if(re?(it&ae)===ae:(r&ae)===ae){ae!==0&&ae===lr&&(Uc=!0),ue!==null&&(ue=ue.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var De=t,Ye=E;ae=a;var vt=n;switch(Ye.tag){case 1:if(De=Ye.payload,typeof De=="function"){fe=De.call(vt,fe,ae);break e}fe=De;break e;case 3:De.flags=De.flags&-65537|128;case 0:if(De=Ye.payload,ae=typeof De=="function"?De.call(vt,fe,ae):De,ae==null)break e;fe=f({},fe,ae);break e;case 2:Fs=!0}}ae=E.callback,ae!==null&&(t.flags|=64,re&&(t.flags|=8192),re=c.callbacks,re===null?c.callbacks=[ae]:re.push(ae))}else re={lane:ae,tag:E.tag,payload:E.payload,callback:E.callback,next:null},ue===null?(ee=ue=re,B=fe):ue=ue.next=re,v|=ae;if(E=E.next,E===null){if(E=c.shared.pending,E===null)break;re=E,E=re.next,re.next=null,c.lastBaseUpdate=re,c.shared.pending=null}}while(!0);ue===null&&(B=fe),c.baseState=B,c.firstBaseUpdate=ee,c.lastBaseUpdate=ue,m===null&&(c.shared.lanes=0),Xs|=v,t.lanes=v,t.memoizedState=fe}}function Sh(t,a){if(typeof t!="function")throw Error(o(191,t));t.call(a)}function Ch(t,a){var n=t.callbacks;
vendor: 5,015 bytes, line 8
8if(n!==null)for(t.callbacks=null,t=0;t<n.length;t++)Sh(n[t],a)}var dr=H(null),ki=H(0);function Ah(t,a){t=_s,$(ki,t),$(dr,a),_s=t|a.baseLanes}function Fc(){$(ki,_s),$(dr,dr.current)}function Ic(){_s=ki.current,Z(dr),Z(ki)}var pa=H(null),Ma=null;function Gs(t){var a=t.alternate;$(Lt,Lt.current&1),$(pa,t),Ma===null&&(a===null||dr.current!==null||a.memoizedState!==null)&&(Ma=t)}function Vc(t){$(Lt,Lt.current),$(pa,t),Ma===null&&(Ma=t)}function Eh(t){t.tag===22?($(Lt,Lt.current),$(pa,t),Ma===null&&(Ma=t)):Ys()}function Ys(){$(Lt,Lt.current),$(pa,pa.current)}function ya(t){Z(pa),Ma===t&&(Ma=null),Z(Lt)}var Lt=H(0);function Ni(t){for(var a=t;a!==null;){if(a.tag===13){var n=a.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||Wd(n)||Zd(n)))return a}else if(a.tag===19&&(a.memoizedProps.revealOrder==="forwards"||a.memoizedProps.revealOrder==="backwards"||a.memoizedProps.revealOrder==="unstable_legacy-backwards"||a.memoizedProps.revealOrder==="together")){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var ps=0,at=null,yt=null,qt=null,_i=!1,ur=!1,Cn=!1,Si=0,il=0,mr=null,py=0;function Tt(){throw Error(o(321))}function Gc(t,a){if(a===null)return!1;for(var n=0;n<a.length&&n<t.length;n++)if(!ga(t[n],a[n]))return!1;return!0}function Yc(t,a,n,r,c,m){return ps=m,at=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,M.H=t===null||t.memoizedState===null?m0:id,Cn=!1,m=n(r,c),Cn=!1,ur&&(m=Rh(a,n,r,c)),Th(t),m}function Th(t){M.H=dl;var a=yt!==null&&yt.next!==null;if(ps=0,qt=yt=at=null,_i=!1,il=0,mr=null,a)throw Error(o(300));t===null||Bt||(t=t.dependencies,t!==null&&fi(t)&&(Bt=!0))}function Rh(t,a,n,r){at=t;var c=0;do{if(ur&&(mr=null),il=0,ur=!1,25<=c)throw Error(o(301));if(c+=1,qt=yt=null,t.updateQueue!=null){var m=t.updateQueue;m.lastEffect=null,m.events=null,m.stores=null,m.memoCache!=null&&(m.memoCache.index=0)}M.H=h0,m=a(n,r)}while(ur);return m}function yy(){var t=M.H,a=t.useState()[0];return a=typeof a.then=="function"?ol(a):a,t=t.useState()[0],(yt!==null?yt.memoizedState:null)!==t&&(at.flags|=1024),a}function Pc(){var t=Si!==0;return Si=0,t}function Qc(t,a,n){a.updateQueue=t.updateQueue,a.flags&=-2053,t.lanes&=~n}function Xc(t){if(_i){for(t=t.memoizedState;t!==null;){var a=t.queue;a!==null&&(a.pending=null),t=t.next}_i=!1}ps=0,qt=yt=at=null,ur=!1,il=Si=0,mr=null}function na(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return qt===null?at.memoizedState=qt=t:qt=qt.next=t,qt}function Mt(){if(yt===null){var t=at.alternate;t=t!==null?t.memoizedState:null}else t=yt.next;var a=qt===null?at.memoizedState:qt.next;if(a!==null)qt=a,yt=t;else{if(t===null)throw at.alternate===null?Error(o(467)):Error(o(310));yt=t,t={memoizedState:yt.memoizedState,baseState:yt.baseState,baseQueue:yt.baseQueue,queue:yt.queue,next:null},qt===null?at.memoizedState=qt=t:qt=qt.next=t}return qt}function Ci(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ol(t){var a=il;return il+=1,mr===null&&(mr=[]),t=jh(mr,t,a),a=at,(qt===null?a.memoizedState:qt.next)===null&&(a=a.alternate,M.H=a===null||a.memoizedState===null?m0:id),t}function Ai(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return ol(t);if(t.$$typeof===z)return Wt(t)}throw Error(o(438,String(t)))}function Wc(t){var a=null,n=at.updateQueue;if(n!==null&&(a=n.memoCache),a==null){var r=at.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(a={data:r.data.map(function(c){return c.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),n===null&&(n=Ci(),at.updateQueue=n),n.memoCache=a,n=a.data[a.index],n===void 0)for(n=a.data[a.index]=Array(t),r=0;r<t;r++)n[r]=he;return a.index++,n}function ys(t,a){return typeof a=="function"?a(t):a}function Ei(t){var a=Mt();return Zc(a,yt,t)}function Zc(t,a,n){var r=t.queue;if(r===null)throw Error(o(311));r.lastRenderedReducer=n;var c=t.baseQueue,m=r.pending;if(m!==null){if(c!==null){var v=c.next;c.next=m.next,m.next=v}a.baseQueue=c=m,r.pending=null}if(m=t.baseState,c===null)t.memoizedState=m;else{a=c.next;var E=v=null,B=null,ee=a,ue=!1;do{var fe=ee.lane&-536870913;if(fe!==ee.lane?(it&fe)===fe:(ps&fe)===fe){var ae=ee.revertLane;if(ae===0)B!==null&&(B=B.next={lane:0,revertLane:0,gesture:null,action:ee.action,hasEagerState:ee.hasEagerState,eagerState:ee.eagerState,next:null}),fe===lr&&(ue=!0);else if((ps&ae)===ae){ee=ee.next,ae===lr&&(ue=!0);continue}else fe={lane:0,revertLane:ee.revertLane,gesture:null,action:ee.action,hasEagerState:ee.hasEagerState,eagerState:ee.eagerState,next:null},B===null?(E=B=fe,v=m):B=B.next=fe,at.lanes|=ae,Xs|=ae;fe=ee.action,Cn&&n(m,fe),m=ee.hasEagerState?ee.eagerState:n(m,fe)}else ae={lane:fe,revertLane:ee.revertLane,gesture:ee.gesture,action:ee.action,hasEagerState:ee.hasEagerState,eagerState:ee.eagerState,next:null},B===null?(E=B=ae,v=m):B=B.next=ae,at.lanes|=fe,Xs|=fe;ee=ee.next}
vendor: 4,448 bytes, line 8
8while(ee!==null&&ee!==a);if(B===null?v=m:B.next=E,!ga(m,t.memoizedState)&&(Bt=!0,ue&&(n=ir,n!==null)))throw n;t.memoizedState=m,t.baseState=v,t.baseQueue=B,r.lastRenderedState=m}return c===null&&(r.lanes=0),[t.memoizedState,r.dispatch]}function Kc(t){var a=Mt(),n=a.queue;if(n===null)throw Error(o(311));n.lastRenderedReducer=t;var r=n.dispatch,c=n.pending,m=a.memoizedState;if(c!==null){n.pending=null;var v=c=c.next;do m=t(m,v.action),v=v.next;while(v!==c);ga(m,a.memoizedState)||(Bt=!0),a.memoizedState=m,a.baseQueue===null&&(a.baseState=m),n.lastRenderedState=m}return[m,r]}function zh(t,a,n){var r=at,c=Mt(),m=ct;if(m){if(n===void 0)throw Error(o(407));n=n()}else n=a();var v=!ga((yt||c).memoizedState,n);if(v&&(c.memoizedState=n,Bt=!0),c=c.queue,td(Oh.bind(null,r,c,t),[t]),c.getSnapshot!==a||v||qt!==null&&qt.memoizedState.tag&1){if(r.flags|=2048,hr(9,{destroy:void 0},Mh.bind(null,r,c,n,a),null),jt===null)throw Error(o(349));m||(ps&127)!==0||Lh(r,a,n)}return n}function Lh(t,a,n){t.flags|=16384,t={getSnapshot:a,value:n},a=at.updateQueue,a===null?(a=Ci(),at.updateQueue=a,a.stores=[t]):(n=a.stores,n===null?a.stores=[t]:n.push(t))}function Mh(t,a,n,r){a.value=n,a.getSnapshot=r,$h(a)&&Dh(t)}function Oh(t,a,n){return n(function(){$h(a)&&Dh(t)})}function $h(t){var a=t.getSnapshot;t=t.value;try{var n=a();return!ga(t,n)}catch{return!0}}function Dh(t){var a=yn(t,2);a!==null&&ua(a,t,2)}function Jc(t){var a=na();if(typeof t=="function"){var n=t;if(t=n(),Cn){es(!0);try{n()}finally{es(!1)}}}return a.memoizedState=a.baseState=t,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ys,lastRenderedState:t},a}function Hh(t,a,n,r){return t.baseState=n,Zc(t,yt,typeof r=="function"?r:ys)}function by(t,a,n,r,c){if(zi(t))throw Error(o(485));if(t=a.action,t!==null){var m={payload:c,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(v){m.listeners.push(v)}};M.T!==null?n(!0):m.isTransition=!1,r(m),n=a.pending,n===null?(m.next=a.pending=m,qh(a,m)):(m.next=n.next,a.pending=n.next=m)}}function qh(t,a){var n=a.action,r=a.payload,c=t.state;if(a.isTransition){var m=M.T,v={};M.T=v;try{var E=n(c,r),B=M.S;B!==null&&B(v,E),Bh(t,a,E)}catch(ee){ed(t,a,ee)}finally{m!==null&&v.types!==null&&(m.types=v.types),M.T=m}}else try{m=n(c,r),Bh(t,a,m)}catch(ee){ed(t,a,ee)}}function Bh(t,a,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(r){Uh(t,a,r)},function(r){return ed(t,a,r)}):Uh(t,a,n)}function Uh(t,a,n){a.status="fulfilled",a.value=n,Fh(a),t.state=n,a=t.pending,a!==null&&(n=a.next,n===a?t.pending=null:(n=n.next,a.next=n,qh(t,n)))}function ed(t,a,n){var r=t.pending;if(t.pending=null,r!==null){r=r.next;do a.status="rejected",a.reason=n,Fh(a),a=a.next;while(a!==r)}t.action=null}function Fh(t){t=t.listeners;for(var a=0;a<t.length;a++)(0,t[a])()}function Ih(t,a){return a}function Vh(t,a){if(ct){var n=jt.formState;if(n!==null){e:{var r=at;if(ct){if(wt){t:{for(var c=wt,m=La;c.nodeType!==8;){if(!m){c=null;break t}if(c=Oa(c.nextSibling),c===null){c=null;break t}}m=c.data,c=m==="F!"||m==="F"?c:null}if(c){wt=Oa(c.nextSibling),r=c.data==="F!";break e}}Bs(r)}r=!1}r&&(a=n[0])}}return n=na(),n.memoizedState=n.baseState=a,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ih,lastRenderedState:a},n.queue=r,n=c0.bind(null,at,r),r.dispatch=n,r=Jc(!1),m=ld.bind(null,at,!1,r.queue),r=na(),c={state:a,dispatch:null,action:t,pending:null},r.queue=c,n=by.bind(null,at,c,m,n),c.dispatch=n,r.memoizedState=t,[a,n,!1]}function Gh(t){var a=Mt();return Yh(a,yt,t)}function Yh(t,a,n){if(a=Zc(t,a,Ih)[0],t=Ei(ys)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var r=ol(a)}catch(v){throw v===or?bi:v}else r=a;a=Mt();var c=a.queue,m=c.dispatch;return n!==a.memoizedState&&(at.flags|=2048,hr(9,{destroy:void 0},vy.bind(null,c,n),null)),[r,m,t]}function vy(t,a){t.action=a}function Ph(t){var a=Mt(),n=yt;if(n!==null)return Yh(a,n,t);Mt(),a=a.memoizedState,n=Mt();var r=n.queue.dispatch;return n.memoizedState=t,[a,r,!1]}function hr(t,a,n,r){return t={tag:t,create:n,deps:r,inst:a,next:null},a=at.updateQueue,a===null&&(a=Ci(),at.updateQueue=a),n=a.lastEffect,n===null?a.lastEffect=t.next=t:(r=n.next,n.next=t,t.next=r,a.lastEffect=t),t}function Qh(){return Mt().memoizedState}function Ti(t,a,n,r){var c=na();at.flags|=t,c.memoizedState=hr(1|a,{destroy:void 0},n,r===void 0?null:r)}function Ri(t,a,n,r){var c=Mt();r=r===void 0?null:r;var m=c.memoizedState.inst;
vendor: 4,894 bytes, line 8
8yt!==null&&r!==null&&Gc(r,yt.memoizedState.deps)?c.memoizedState=hr(a,m,n,r):(at.flags|=t,c.memoizedState=hr(1|a,m,n,r))}function Xh(t,a){Ti(8390656,8,t,a)}function td(t,a){Ri(2048,8,t,a)}function jy(t){at.flags|=4;var a=at.updateQueue;if(a===null)a=Ci(),at.updateQueue=a,a.events=[t];else{var n=a.events;n===null?a.events=[t]:n.push(t)}}function Wh(t){var a=Mt().memoizedState;return jy({ref:a,nextImpl:t}),function(){if((xt&2)!==0)throw Error(o(440));return a.impl.apply(void 0,arguments)}}function Zh(t,a){return Ri(4,2,t,a)}function Kh(t,a){return Ri(4,4,t,a)}function Jh(t,a){if(typeof a=="function"){t=t();var n=a(t);return function(){typeof n=="function"?n():a(null)}}if(a!=null)return t=t(),a.current=t,function(){a.current=null}}function e0(t,a,n){n=n!=null?n.concat([t]):null,Ri(4,4,Jh.bind(null,a,t),n)}function ad(){}function t0(t,a){var n=Mt();a=a===void 0?null:a;var r=n.memoizedState;return a!==null&&Gc(a,r[1])?r[0]:(n.memoizedState=[t,a],t)}function a0(t,a){var n=Mt();a=a===void 0?null:a;var r=n.memoizedState;if(a!==null&&Gc(a,r[1]))return r[0];if(r=t(),Cn){es(!0);try{t()}finally{es(!1)}}return n.memoizedState=[r,a],r}function sd(t,a,n){return n===void 0||(ps&1073741824)!==0&&(it&261930)===0?t.memoizedState=a:(t.memoizedState=n,t=sx(),at.lanes|=t,Xs|=t,n)}function s0(t,a,n,r){return ga(n,a)?n:dr.current!==null?(t=sd(t,n,r),ga(t,a)||(Bt=!0),t):(ps&42)===0||(ps&1073741824)!==0&&(it&261930)===0?(Bt=!0,t.memoizedState=n):(t=sx(),at.lanes|=t,Xs|=t,a)}function n0(t,a,n,r,c){var m=Y.p;Y.p=m!==0&&8>m?m:8;var v=M.T,E={};M.T=E,ld(t,!1,a,n);try{var B=c(),ee=M.S;if(ee!==null&&ee(E,B),B!==null&&typeof B=="object"&&typeof B.then=="function"){var ue=fy(B,r);cl(t,a,ue,ja(t))}else cl(t,a,r,ja(t))}catch(fe){cl(t,a,{then:function(){},status:"rejected",reason:fe},ja())}finally{Y.p=m,v!==null&&E.types!==null&&(v.types=E.types),M.T=v}}function wy(){}function nd(t,a,n,r){if(t.tag!==5)throw Error(o(476));var c=r0(t).queue;n0(t,c,a,oe,n===null?wy:function(){return l0(t),n(r)})}function r0(t){var a=t.memoizedState;if(a!==null)return a;a={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ys,lastRenderedState:oe},next:null};var n={};return a.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ys,lastRenderedState:n},next:null},t.memoizedState=a,t=t.alternate,t!==null&&(t.memoizedState=a),a}function l0(t){var a=r0(t);a.next===null&&(a=t.alternate.memoizedState),cl(t,a.next.queue,{},ja())}function rd(){return Wt(Sl)}function i0(){return Mt().memoizedState}function o0(){return Mt().memoizedState}function ky(t){for(var a=t.return;a!==null;){switch(a.tag){case 24:case 3:var n=ja();t=Is(n);var r=Vs(a,t,n);r!==null&&(ua(r,a,n),nl(r,a,n)),a={cache:Mc()},t.payload=a;return}a=a.return}}function Ny(t,a,n){var r=ja();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},zi(t)?d0(a,n):(n=kc(t,a,n,r),n!==null&&(ua(n,t,r),u0(n,a,r)))}function c0(t,a,n){var r=ja();cl(t,a,n,r)}function cl(t,a,n,r){var c={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(zi(t))d0(a,c);else{var m=t.alternate;if(t.lanes===0&&(m===null||m.lanes===0)&&(m=a.lastRenderedReducer,m!==null))try{var v=a.lastRenderedState,E=m(v,n);if(c.hasEagerState=!0,c.eagerState=E,ga(E,v))return mi(t,a,c,0),jt===null&&ui(),!1}catch{}if(n=kc(t,a,c,r),n!==null)return ua(n,t,r),u0(n,a,r),!0}return!1}function ld(t,a,n,r){if(r={lane:2,revertLane:Hd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},zi(t)){if(a)throw Error(o(479))}else a=kc(t,n,r,2),a!==null&&ua(a,t,2)}function zi(t){var a=t.alternate;return t===at||a!==null&&a===at}function d0(t,a){ur=_i=!0;var n=t.pending;n===null?a.next=a:(a.next=n.next,n.next=a),t.pending=a}function u0(t,a,n){if((n&4194048)!==0){var r=a.lanes;r&=t.pendingLanes,n|=r,a.lanes=n,fm(t,n)}}var dl={readContext:Wt,use:Ai,useCallback:Tt,useContext:Tt,useEffect:Tt,useImperativeHandle:Tt,useLayoutEffect:Tt,useInsertionEffect:Tt,useMemo:Tt,useReducer:Tt,useRef:Tt,useState:Tt,useDebugValue:Tt,useDeferredValue:Tt,useTransition:Tt,useSyncExternalStore:Tt,useId:Tt,useHostTransitionStatus:Tt,useFormState:Tt,useActionState:Tt,useOptimistic:Tt,useMemoCache:Tt,useCacheRefresh:Tt};dl.useEffectEvent=Tt;var m0={readContext:Wt,use:Ai,useCallback:function(t,a){return na().memoizedState=[t,a===void 0?null:a],t},useContext:Wt,useEffect:Xh,useImperativeHandle:function(t,a,n){n=n!=null?n.concat([t]):null,Ti(4194308,4,Jh.bind(null,a,t),n)},useLayoutEffect:function(t,a){return Ti(4194308,4,t,a)},useInsertionEffect:function(t,a){Ti(4,2,t,a)},useMemo:function(t,a){var n=na();a=a===void 0?null:a;var r=t();if(Cn){es(!0);try{t()}finally{es(!1)}}return n.memoizedState=[r,a],r},useReducer:function(t,a,n){var r=na();if(n!==void 0){var c=n(a);if(Cn){es(!0);try{n(a)}finally{es(!1)}}}else c=a;
vendor: 5,056 bytes, line 8
8return r.memoizedState=r.baseState=c,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:c},r.queue=t,t=t.dispatch=Ny.bind(null,at,t),[r.memoizedState,t]},useRef:function(t){var a=na();return t={current:t},a.memoizedState=t},useState:function(t){t=Jc(t);var a=t.queue,n=c0.bind(null,at,a);return a.dispatch=n,[t.memoizedState,n]},useDebugValue:ad,useDeferredValue:function(t,a){var n=na();return sd(n,t,a)},useTransition:function(){var t=Jc(!1);return t=n0.bind(null,at,t.queue,!0,!1),na().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,a,n){var r=at,c=na();if(ct){if(n===void 0)throw Error(o(407));n=n()}else{if(n=a(),jt===null)throw Error(o(349));(it&127)!==0||Lh(r,a,n)}c.memoizedState=n;var m={value:n,getSnapshot:a};return c.queue=m,Xh(Oh.bind(null,r,m,t),[t]),r.flags|=2048,hr(9,{destroy:void 0},Mh.bind(null,r,m,n,a),null),n},useId:function(){var t=na(),a=jt.identifierPrefix;if(ct){var n=as,r=ts;n=(r&~(1<<32-aa(r)-1)).toString(32)+n,a="_"+a+"R_"+n,n=Si++,0<n&&(a+="H"+n.toString(32)),a+="_"}else n=py++,a="_"+a+"r_"+n.toString(32)+"_";return t.memoizedState=a},useHostTransitionStatus:rd,useFormState:Vh,useActionState:Vh,useOptimistic:function(t){var a=na();a.memoizedState=a.baseState=t;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=n,a=ld.bind(null,at,!0,n),n.dispatch=a,[t,a]},useMemoCache:Wc,useCacheRefresh:function(){return na().memoizedState=ky.bind(null,at)},useEffectEvent:function(t){var a=na(),n={impl:t};return a.memoizedState=n,function(){if((xt&2)!==0)throw Error(o(440));return n.impl.apply(void 0,arguments)}}},id={readContext:Wt,use:Ai,useCallback:t0,useContext:Wt,useEffect:td,useImperativeHandle:e0,useInsertionEffect:Zh,useLayoutEffect:Kh,useMemo:a0,useReducer:Ei,useRef:Qh,useState:function(){return Ei(ys)},useDebugValue:ad,useDeferredValue:function(t,a){var n=Mt();return s0(n,yt.memoizedState,t,a)},useTransition:function(){var t=Ei(ys)[0],a=Mt().memoizedState;return[typeof t=="boolean"?t:ol(t),a]},useSyncExternalStore:zh,useId:i0,useHostTransitionStatus:rd,useFormState:Gh,useActionState:Gh,useOptimistic:function(t,a){var n=Mt();return Hh(n,yt,t,a)},useMemoCache:Wc,useCacheRefresh:o0};id.useEffectEvent=Wh;var h0={readContext:Wt,use:Ai,useCallback:t0,useContext:Wt,useEffect:td,useImperativeHandle:e0,useInsertionEffect:Zh,useLayoutEffect:Kh,useMemo:a0,useReducer:Kc,useRef:Qh,useState:function(){return Kc(ys)},useDebugValue:ad,useDeferredValue:function(t,a){var n=Mt();return yt===null?sd(n,t,a):s0(n,yt.memoizedState,t,a)},useTransition:function(){var t=Kc(ys)[0],a=Mt().memoizedState;return[typeof t=="boolean"?t:ol(t),a]},useSyncExternalStore:zh,useId:i0,useHostTransitionStatus:rd,useFormState:Ph,useActionState:Ph,useOptimistic:function(t,a){var n=Mt();return yt!==null?Hh(n,yt,t,a):(n.baseState=t,[t,n.queue.dispatch])},useMemoCache:Wc,useCacheRefresh:o0};h0.useEffectEvent=Wh;function od(t,a,n,r){a=t.memoizedState,n=n(r,a),n=n==null?a:f({},a,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}var cd={enqueueSetState:function(t,a,n){t=t._reactInternals;var r=ja(),c=Is(r);c.payload=a,n!=null&&(c.callback=n),a=Vs(t,c,r),a!==null&&(ua(a,t,r),nl(a,t,r))},enqueueReplaceState:function(t,a,n){t=t._reactInternals;var r=ja(),c=Is(r);c.tag=1,c.payload=a,n!=null&&(c.callback=n),a=Vs(t,c,r),a!==null&&(ua(a,t,r),nl(a,t,r))},enqueueForceUpdate:function(t,a){t=t._reactInternals;var n=ja(),r=Is(n);r.tag=2,a!=null&&(r.callback=a),a=Vs(t,r,n),a!==null&&(ua(a,t,n),nl(a,t,n))}};function x0(t,a,n,r,c,m,v){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(r,m,v):a.prototype&&a.prototype.isPureReactComponent?!Wr(n,r)||!Wr(c,m):!0}function g0(t,a,n,r){t=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(n,r),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(n,r),a.state!==t&&cd.enqueueReplaceState(a,a.state,null)}function An(t,a){var n=a;if("ref"in a){n={};for(var r in a)r!=="ref"&&(n[r]=a[r])}if(t=t.defaultProps){n===a&&(n=f({},n));for(var c in t)n[c]===void 0&&(n[c]=t[c])}return n}function f0(t){di(t)}function p0(t){console.error(t)}function y0(t){di(t)}function Li(t,a){try{var n=t.onUncaughtError;n(a.value,{componentStack:a.stack})}catch(r){setTimeout(function(){throw r})}}function b0(t,a,n){try{var r=t.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function dd(t,a,n){return n=Is(n),n.tag=3,n.payload={element:null},n.callback=function(){Li(t,a)},n}function v0(t){return t=Is(t),t.tag=3,t}function j0(t,a,n,r){var c=n.type.getDerivedStateFromError;if(typeof c=="function"){var m=r.value;t.payload=function(){return c(m)},t.callback=function(){b0(a,n,r)}}var v=n.stateNode;v!==null&&typeof v.componentDidCatch=="function"&&(t.callback=function(){b0(a,n,r),typeof c!="function"&&(Ws===null?Ws=new Set([this]):Ws.add(this));var E=r.stack;this.componentDidCatch(r.value,{componentStack:E!==null?E:""})})}
vendor: 11,793 bytes, line 8
8function _y(t,a,n,r,c){if(n.flags|=32768,r!==null&&typeof r=="object"&&typeof r.then=="function"){if(a=n.alternate,a!==null&&rr(a,n,c,!0),n=pa.current,n!==null){switch(n.tag){case 31:case 13:return Ma===null?Gi():n.alternate===null&&Rt===0&&(Rt=3),n.flags&=-257,n.flags|=65536,n.lanes=c,r===vi?n.flags|=16384:(a=n.updateQueue,a===null?n.updateQueue=new Set([r]):a.add(r),Od(t,r,c)),!1;case 22:return n.flags|=65536,r===vi?n.flags|=16384:(a=n.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=a):(n=a.retryQueue,n===null?a.retryQueue=new Set([r]):n.add(r)),Od(t,r,c)),!1}throw Error(o(435,n.tag))}return Od(t,r,c),Gi(),!1}if(ct)return a=pa.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=c,r!==Ec&&(t=Error(o(422),{cause:r}),Jr(Ta(t,n)))):(r!==Ec&&(a=Error(o(423),{cause:r}),Jr(Ta(a,n))),t=t.current.alternate,t.flags|=65536,c&=-c,t.lanes|=c,r=Ta(r,n),c=dd(t.stateNode,r,c),Bc(t,c),Rt!==4&&(Rt=2)),!1;var m=Error(o(520),{cause:r});if(m=Ta(m,n),yl===null?yl=[m]:yl.push(m),Rt!==4&&(Rt=2),a===null)return!0;r=Ta(r,n),n=a;do{switch(n.tag){case 3:return n.flags|=65536,t=c&-c,n.lanes|=t,t=dd(n.stateNode,r,t),Bc(n,t),!1;case 1:if(a=n.type,m=n.stateNode,(n.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||m!==null&&typeof m.componentDidCatch=="function"&&(Ws===null||!Ws.has(m))))return n.flags|=65536,c&=-c,n.lanes|=c,c=v0(c),j0(c,t,n,r),Bc(n,c),!1}n=n.return}while(n!==null);return!1}var ud=Error(o(461)),Bt=!1;function Zt(t,a,n,r){a.child=t===null?_h(a,null,n,r):Sn(a,t.child,n,r)}function w0(t,a,n,r,c){n=n.render;var m=a.ref;if("ref"in r){var v={};for(var E in r)E!=="ref"&&(v[E]=r[E])}else v=r;return wn(a),r=Yc(t,a,n,v,m,c),E=Pc(),t!==null&&!Bt?(Qc(t,a,c),bs(t,a,c)):(ct&&E&&Cc(a),a.flags|=1,Zt(t,a,r,c),a.child)}function k0(t,a,n,r,c){if(t===null){var m=n.type;return typeof m=="function"&&!Nc(m)&&m.defaultProps===void 0&&n.compare===null?(a.tag=15,a.type=m,N0(t,a,m,r,c)):(t=xi(n.type,null,r,a,a.mode,c),t.ref=a.ref,t.return=a,a.child=t)}if(m=t.child,!bd(t,c)){var v=m.memoizedProps;if(n=n.compare,n=n!==null?n:Wr,n(v,r)&&t.ref===a.ref)return bs(t,a,c)}return a.flags|=1,t=hs(m,r),t.ref=a.ref,t.return=a,a.child=t}function N0(t,a,n,r,c){if(t!==null){var m=t.memoizedProps;if(Wr(m,r)&&t.ref===a.ref)if(Bt=!1,a.pendingProps=r=m,bd(t,c))(t.flags&131072)!==0&&(Bt=!0);else return a.lanes=t.lanes,bs(t,a,c)}return md(t,a,n,r,c)}function _0(t,a,n,r){var c=r.children,m=t!==null?t.memoizedState:null;if(t===null&&a.stateNode===null&&(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode==="hidden"){if((a.flags&128)!==0){if(m=m!==null?m.baseLanes|n:n,t!==null){for(r=a.child=t.child,c=0;r!==null;)c=c|r.lanes|r.childLanes,r=r.sibling;r=c&~m}else r=0,a.child=null;return S0(t,a,m,n,r)}if((n&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},t!==null&&yi(a,m!==null?m.cachePool:null),m!==null?Ah(a,m):Fc(),Eh(a);else return r=a.lanes=536870912,S0(t,a,m!==null?m.baseLanes|n:n,n,r)}else m!==null?(yi(a,m.cachePool),Ah(a,m),Ys(),a.memoizedState=null):(t!==null&&yi(a,null),Fc(),Ys());return Zt(t,a,c,n),a.child}function ul(t,a){return t!==null&&t.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function S0(t,a,n,r,c){var m=$c();return m=m===null?null:{parent:Ht._currentValue,pool:m},a.memoizedState={baseLanes:n,cachePool:m},t!==null&&yi(a,null),Fc(),Eh(a),t!==null&&rr(t,a,r,!0),a.childLanes=c,null}function Mi(t,a){return a=$i({mode:a.mode,children:a.children},t.mode),a.ref=t.ref,t.child=a,a.return=t,a}function C0(t,a,n){return Sn(a,t.child,null,n),t=Mi(a,a.pendingProps),t.flags|=2,ya(a),a.memoizedState=null,t}function Sy(t,a,n){var r=a.pendingProps,c=(a.flags&128)!==0;if(a.flags&=-129,t===null){if(ct){if(r.mode==="hidden")return t=Mi(a,r),a.lanes=536870912,ul(null,t);if(Vc(a),(t=wt)?(t=qx(t,La),t=t!==null&&t.data==="&"?t:null,t!==null&&(a.memoizedState={dehydrated:t,treeContext:Hs!==null?{id:ts,overflow:as}:null,retryLane:536870912,hydrationErrors:null},n=dh(t),n.return=a,a.child=n,Xt=a,wt=null)):t=null,t===null)throw Bs(a);return a.lanes=536870912,null}return Mi(a,r)}var m=t.memoizedState;if(m!==null){var v=m.dehydrated;if(Vc(a),c)if(a.flags&256)a.flags&=-257,a=C0(t,a,n);else if(a.memoizedState!==null)a.child=t.child,a.flags|=128,a=null;else throw Error(o(558));else if(Bt||rr(t,a,n,!1),c=(n&t.childLanes)!==0,Bt||c){if(r=jt,r!==null&&(v=pm(r,n),v!==0&&v!==m.retryLane))throw m.retryLane=v,yn(t,v),ua(r,t,v),ud;Gi(),a=C0(t,a,n)}else t=m.treeContext,wt=Oa(v.nextSibling),Xt=a,ct=!0,qs=null,La=!1,t!==null&&hh(a,t),a=Mi(a,r),a.flags|=4096;return a}return t=hs(t.child,{mode:r.mode,children:r.children}),t.ref=a.ref,a.child=t,t.return=a,t}function Oi(t,a){var n=a.ref;if(n===null)t!==null&&t.ref!==null&&(a.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(o(284));(t===null||t.ref!==n)&&(a.flags|=4194816)}}function md(t,a,n,r,c){return wn(a),n=Yc(t,a,n,r,void 0,c),r=Pc(),t!==null&&!Bt?(Qc(t,a,c),bs(t,a,c)):(ct&&r&&Cc(a),a.flags|=1,Zt(t,a,n,c),a.child)}function A0(t,a,n,r,c,m){return wn(a),a.updateQueue=null,n=Rh(a,r,n,c),Th(t),r=Pc(),t!==null&&!Bt?(Qc(t,a,m),bs(t,a,m)):(ct&&r&&Cc(a),a.flags|=1,Zt(t,a,n,m),a.child)}function E0(t,a,n,r,c){if(wn(a),a.stateNode===null){var m=tr,v=n.contextType;typeof v=="object"&&v!==null&&(m=Wt(v)),m=new n(r,m),a.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,m.updater=cd,a.stateNode=m,m._reactInternals=a,m=a.stateNode,m.props=r,m.state=a.memoizedState,m.refs={},Hc(a),v=n.contextType,m.context=typeof v=="object"&&v!==null?Wt(v):tr,m.state=a.memoizedState,v=n.getDerivedStateFromProps,typeof v=="function"&&(od(a,n,v,r),m.state=a.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(v=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),v!==m.state&&cd.enqueueReplaceState(m,m.state,null),ll(a,r,m,c),rl(),m.state=a.memoizedState),typeof m.componentDidMount=="function"&&(a.flags|=4194308),r=!0}else if(t===null){m=a.stateNode;var E=a.memoizedProps,B=An(n,E);m.props=B;var ee=m.context,ue=n.contextType;v=tr,typeof ue=="object"&&ue!==null&&(v=Wt(ue));var fe=n.getDerivedStateFromProps;ue=typeof fe=="function"||typeof m.getSnapshotBeforeUpdate=="function",E=a.pendingProps!==E,ue||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(E||ee!==v)&&g0(a,m,r,v),Fs=!1;var ae=a.memoizedState;m.state=ae,ll(a,r,m,c),rl(),ee=a.memoizedState,E||ae!==ee||Fs?(typeof fe=="function"&&(od(a,n,fe,r),ee=a.memoizedState),(B=Fs||x0(a,n,B,r,ae,ee,v))?(ue||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount()),typeof m.componentDidMount=="function"&&(a.flags|=4194308)):(typeof m.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=r,a.memoizedState=ee),m.props=r,m.state=ee,m.context=v,r=B):(typeof m.componentDidMount=="function"&&(a.flags|=4194308),r=!1)}else{m=a.stateNode,qc(t,a),v=a.memoizedProps,ue=An(n,v),m.props=ue,fe=a.pendingProps,ae=m.context,ee=n.contextType,B=tr,typeof ee=="object"&&ee!==null&&(B=Wt(ee)),E=n.getDerivedStateFromProps,(ee=typeof E=="function"||typeof m.getSnapshotBeforeUpdate=="function")||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(v!==fe||ae!==B)&&g0(a,m,r,B),Fs=!1,ae=a.memoizedState,m.state=ae,ll(a,r,m,c),rl();var re=a.memoizedState;v!==fe||ae!==re||Fs||t!==null&&t.dependencies!==null&&fi(t.dependencies)?(typeof E=="function"&&(od(a,n,E,r),re=a.memoizedState),(ue=Fs||x0(a,n,ue,r,ae,re,B)||t!==null&&t.dependencies!==null&&fi(t.dependencies))?(ee||typeof m.UNSAFE_componentWillUpdate!="function"&&typeof m.componentWillUpdate!="function"||(typeof m.componentWillUpdate=="function"&&m.componentWillUpdate(r,re,B),typeof m.UNSAFE_componentWillUpdate=="function"&&m.UNSAFE_componentWillUpdate(r,re,B)),typeof m.componentDidUpdate=="function"&&(a.flags|=4),typeof m.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof m.componentDidUpdate!="function"||v===t.memoizedProps&&ae===t.memoizedState||(a.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||v===t.memoizedProps&&ae===t.memoizedState||(a.flags|=1024),a.memoizedProps=r,a.memoizedState=re),m.props=r,m.state=re,m.context=B,r=ue):(typeof m.componentDidUpdate!="function"||v===t.memoizedProps&&ae===t.memoizedState||(a.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||v===t.memoizedProps&&ae===t.memoizedState||(a.flags|=1024),r=!1)}return m=r,Oi(t,a),r=(a.flags&128)!==0,m||r?(m=a.stateNode,n=r&&typeof n.getDerivedStateFromError!="function"?null:m.render(),a.flags|=1,t!==null&&r?(a.child=Sn(a,t.child,null,c),a.child=Sn(a,null,n,c)):Zt(t,a,n,c),a.memoizedState=m.state,t=a.child):t=bs(t,a,c),t}function T0(t,a,n,r){return vn(),a.flags|=256,Zt(t,a,n,r),a.child}var hd={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function xd(t){return{baseLanes:t,cachePool:bh()}}function gd(t,a,n){return t=t!==null?t.childLanes&~n:0,a&&(t|=va),t}function R0(t,a,n){var r=a.pendingProps,c=!1,m=(a.flags&128)!==0,v;if((v=m)||(v=t!==null&&t.memoizedState===null?!1:(Lt.current&2)!==0),v&&(c=!0,a.flags&=-129),v=(a.flags&32)!==0,a.flags&=-33,t===null){if(ct){if(c?Gs(a):Ys(),(t=wt)?(t=qx(t,La),t=t!==null&&t.data!=="&"?t:null,t!==null&&(a.memoizedState={dehydrated:t,treeContext:Hs!==null?{id:ts,overflow:as}:null,retryLane:536870912,hydrationErrors:null},n=dh(t),n.return=a,a.child=n,Xt=a,wt=null)):t=null,t===null)throw Bs(a);return Zd(t)?a.lanes=32:a.lanes=536870912,null}var E=r.children;return r=r.fallback,c?(Ys(),c=a.mode,E=$i({mode:"hidden",children:E},c),r=bn(r,c,n,null),E.return=a,r.return=a,E.sibling=r,a.child=E,r=a.child,r.memoizedState=xd(n),r.childLanes=gd(t,v,n),a.memoizedState=hd,ul(null,r)):(Gs(a),fd(a,E))}var B=t.memoizedState;if(B!==null&&(E=B.dehydrated,E!==null)){if(m)a.flags&256?(Gs(a),a.flags&=-257,a=pd(t,a,n)):a.memoizedState!==null?(Ys(),a.child=t.child,a.flags|=128,a=null):(Ys(),E=r.fallback,c=a.mode,r=$i({mode:"visible",children:r.children},c),E=bn(E,c,n,null),E.flags|=2,r.return=a,E.return=a,r.sibling=E,a.child=r,Sn(a,t.child,null,n),r=a.child,r.memoizedState=xd(n),r.childLanes=gd(t,v,n),a.memoizedState=hd,a=ul(null,r));else if(Gs(a),Zd(E)){if(v=E.nextSibling&&E.nextSibling.dataset,v)var ee=v.dgst;v=ee,r=Error(o(419)),r.stack="",r.digest=v,Jr({value:r,source:null,stack:null}),a=pd(t,a,n)}else if(Bt||rr(t,a,n,!1),v=(n&t.childLanes)!==0,Bt||v){if(v=jt,v!==null&&(r=pm(v,n),r!==0&&r!==B.retryLane))throw B.retryLane=r,yn(t,r),ua(v,t,r),ud;Wd(E)||Gi(),a=pd(t,a,n)}else Wd(E)?(a.flags|=192,a.child=t.child,a=null):(t=B.treeContext,wt=Oa(E.nextSibling),Xt=a,ct=!0,qs=null,La=!1,t!==null&&hh(a,t),a=fd(a,r.children),a.flags|=4096);return a}return c?(Ys(),E=r.fallback,c=a.mode,B=t.child,ee=B.sibling,r=hs(B,{mode:"hidden",children:r.children}),r.subtreeFlags=B.subtreeFlags&65011712,ee!==null?E=hs(ee,E):(E=bn(E,c,n,null),E.flags|=2),E.return=a,r.return=a,r.sibling=E,a.child=r,ul(null,r),r=a.child,E=t.child.memoizedState,E===null?E=xd(n):(c=E.cachePool,c!==null?(B=Ht._currentValue,c=c.parent!==B?{parent:B,pool:B}:c):c=bh(),E={baseLanes:E.baseLanes|n,cachePool:c}),r.memoizedState=E,r.childLanes=gd(t,v,n),a.memoizedState=hd,ul(t.child,r)):(Gs(a),n=t.child,t=n.sibling,n=hs(n,{mode:"visible",children:r.children}),n.return=a,n.sibling=null,t!==null&&(v=a.deletions,v===null?(a.deleti
vendor: 5,256 bytes, line 8
8ons=[t],a.flags|=16):v.push(t)),a.child=n,a.memoizedState=null,n)}function fd(t,a){return a=$i({mode:"visible",children:a},t.mode),a.return=t,t.child=a}function $i(t,a){return t=fa(22,t,null,a),t.lanes=0,t}function pd(t,a,n){return Sn(a,t.child,null,n),t=fd(a,a.pendingProps.children),t.flags|=2,a.memoizedState=null,t}function z0(t,a,n){t.lanes|=a;var r=t.alternate;r!==null&&(r.lanes|=a),zc(t.return,a,n)}function yd(t,a,n,r,c,m){var v=t.memoizedState;v===null?t.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:c,treeForkCount:m}:(v.isBackwards=a,v.rendering=null,v.renderingStartTime=0,v.last=r,v.tail=n,v.tailMode=c,v.treeForkCount=m)}function L0(t,a,n){var r=a.pendingProps,c=r.revealOrder,m=r.tail;r=r.children;var v=Lt.current,E=(v&2)!==0;if(E?(v=v&1|2,a.flags|=128):v&=1,$(Lt,v),Zt(t,a,r,n),r=ct?Kr:0,!E&&t!==null&&(t.flags&128)!==0)e:for(t=a.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&z0(t,n,a);else if(t.tag===19)z0(t,n,a);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===a)break e;for(;t.sibling===null;){if(t.return===null||t.return===a)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(c){case"forwards":for(n=a.child,c=null;n!==null;)t=n.alternate,t!==null&&Ni(t)===null&&(c=n),n=n.sibling;n=c,n===null?(c=a.child,a.child=null):(c=n.sibling,n.sibling=null),yd(a,!1,c,n,m,r);break;case"backwards":case"unstable_legacy-backwards":for(n=null,c=a.child,a.child=null;c!==null;){if(t=c.alternate,t!==null&&Ni(t)===null){a.child=c;break}t=c.sibling,c.sibling=n,n=c,c=t}yd(a,!0,n,null,m,r);break;case"together":yd(a,!1,null,null,void 0,r);break;default:a.memoizedState=null}return a.child}function bs(t,a,n){if(t!==null&&(a.dependencies=t.dependencies),Xs|=a.lanes,(n&a.childLanes)===0)if(t!==null){if(rr(t,a,n,!1),(n&a.childLanes)===0)return null}else return null;if(t!==null&&a.child!==t.child)throw Error(o(153));if(a.child!==null){for(t=a.child,n=hs(t,t.pendingProps),a.child=n,n.return=a;t.sibling!==null;)t=t.sibling,n=n.sibling=hs(t,t.pendingProps),n.return=a;n.sibling=null}return a.child}function bd(t,a){return(t.lanes&a)!==0?!0:(t=t.dependencies,!!(t!==null&&fi(t)))}function Cy(t,a,n){switch(a.tag){case 3:ge(a,a.stateNode.containerInfo),Us(a,Ht,t.memoizedState.cache),vn();break;case 27:case 5:nt(a);break;case 4:ge(a,a.stateNode.containerInfo);break;case 10:Us(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,Vc(a),null;break;case 13:var r=a.memoizedState;if(r!==null)return r.dehydrated!==null?(Gs(a),a.flags|=128,null):(n&a.child.childLanes)!==0?R0(t,a,n):(Gs(a),t=bs(t,a,n),t!==null?t.sibling:null);Gs(a);break;case 19:var c=(t.flags&128)!==0;if(r=(n&a.childLanes)!==0,r||(rr(t,a,n,!1),r=(n&a.childLanes)!==0),c){if(r)return L0(t,a,n);a.flags|=128}if(c=a.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),$(Lt,Lt.current),r)break;return null;case 22:return a.lanes=0,_0(t,a,n,a.pendingProps);case 24:Us(a,Ht,t.memoizedState.cache)}return bs(t,a,n)}function M0(t,a,n){if(t!==null)if(t.memoizedProps!==a.pendingProps)Bt=!0;else{if(!bd(t,n)&&(a.flags&128)===0)return Bt=!1,Cy(t,a,n);Bt=(t.flags&131072)!==0}else Bt=!1,ct&&(a.flags&1048576)!==0&&mh(a,Kr,a.index);switch(a.lanes=0,a.tag){case 16:e:{var r=a.pendingProps;if(t=Nn(a.elementType),a.type=t,typeof t=="function")Nc(t)?(r=An(t,r),a.tag=1,a=E0(null,a,t,r,n)):(a.tag=0,a=md(null,a,t,r,n));else{if(t!=null){var c=t.$$typeof;if(c===A){a.tag=11,a=w0(null,a,t,r,n);break e}else if(c===D){a.tag=14,a=k0(null,a,t,r,n);break e}}throw a=be(t)||t,Error(o(306,a,""))}}return a;case 0:return md(t,a,a.type,a.pendingProps,n);case 1:return r=a.type,c=An(r,a.pendingProps),E0(t,a,r,c,n);case 3:e:{if(ge(a,a.stateNode.containerInfo),t===null)throw Error(o(387));r=a.pendingProps;var m=a.memoizedState;c=m.element,qc(t,a),ll(a,r,null,n);var v=a.memoizedState;if(r=v.cache,Us(a,Ht,r),r!==m.cache&&Lc(a,[Ht],n,!0),rl(),r=v.element,m.isDehydrated)if(m={element:r,isDehydrated:!1,cache:v.cache},a.updateQueue.baseState=m,a.memoizedState=m,a.flags&256){a=T0(t,a,r,n);break e}else if(r!==c){c=Ta(Error(o(424)),a),Jr(c),a=T0(t,a,r,n);break e}else for(t=a.stateNode.containerInfo,t.nodeType===9?t=t.body:t=t.nodeName==="HTML"?t.ownerDocument.body:t,wt=Oa(t.firstChild),Xt=a,ct=!0,qs=null,La=!0,n=_h(a,null,r,n),a.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(vn(),r===c){a=bs(t,a,n);break e}Zt(t,a,r,n)}a=a.child}return a;case 26:return Oi(t,a),t===null?(n=Gx(a.type,null,a.pendingProps,null))?a.memoizedState=n:ct||(n=a.type,t=a.pendingProps,r=Ki(V.current).createElement(n),r[Qt]=a,r[ra]=t,Kt(r,n,t),Yt(r),a.stateNode=r):a.memoizedState=Gx(a.type,t.memoizedProps,a.pendingProps,t.memoizedState),null;case 27:return nt(a),t===null&&ct&&(r=a.stateNode=Fx(a.type,a.pendingProps,V.current),Xt=a,La=!0,c=wt,en(a.type)?(Kd=c,wt=Oa(r.firstChild)):wt=c),Zt(t,a,a.pendingProps.children,n),Oi(t,a),t===null&&(a.flags|=4194304),a.child;case 5:return t===null&&ct&&((c=r=wt)&&(r=sb(r,a.type,a.pendingProps,La),r!==null?(a.stateNode=r,Xt=a,wt=Oa(r.firstChild),La=!1,c=!0):c=!1),c||Bs(a)),nt(a),c=a.type,m=a.pendingProps,v=t!==null?t.memoizedProps:null,r=m.children,Pd(c,m)?r=null:v!==null&&Pd(c,v)&&(a.flags|=32),a.memoizedState!==null&&(c=Yc(t,a,yy,null,
vendor: 1,317 bytes, line 8
8null,n),Sl._currentValue=c),Oi(t,a),Zt(t,a,r,n),a.child;case 6:return t===null&&ct&&((t=n=wt)&&(n=nb(n,a.pendingProps,La),n!==null?(a.stateNode=n,Xt=a,wt=null,t=!0):t=!1),t||Bs(a)),null;case 13:return R0(t,a,n);case 4:return ge(a,a.stateNode.containerInfo),r=a.pendingProps,t===null?a.child=Sn(a,null,r,n):Zt(t,a,r,n),a.child;case 11:return w0(t,a,a.type,a.pendingProps,n);case 7:return Zt(t,a,a.pendingProps,n),a.child;case 8:return Zt(t,a,a.pendingProps.children,n),a.child;case 12:return Zt(t,a,a.pendingProps.children,n),a.child;case 10:return r=a.pendingProps,Us(a,a.type,r.value),Zt(t,a,r.children,n),a.child;case 9:return c=a.type._context,r=a.pendingProps.children,wn(a),c=Wt(c),r=r(c),a.flags|=1,Zt(t,a,r,n),a.child;case 14:return k0(t,a,a.type,a.pendingProps,n);case 15:return N0(t,a,a.type,a.pendingProps,n);case 19:return L0(t,a,n);case 31:return Sy(t,a,n);case 22:return _0(t,a,n,a.pendingProps);case 24:return wn(a),r=Wt(Ht),t===null?(c=$c(),c===null&&(c=jt,m=Mc(),c.pooledCache=m,m.refCount++,m!==null&&(c.pooledCacheLanes|=n),c=m),a.memoizedState={parent:r,cache:c},Hc(a),Us(a,Ht,c)):((t.lanes&n)!==0&&(qc(t,a),ll(a,null,null,n),rl()),c=t.memoizedState,m=a.memoizedState,c.parent!==r?(c={parent:r,cache:r},a.memoizedState=c,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=c),Us(a,Ht,r)):(r=m.cac
vendor: 5,067 bytes, line 8
8he,Us(a,Ht,r),r!==c.cache&&Lc(a,[Ht],n,!0))),Zt(t,a,a.pendingProps.children,n),a.child;case 29:throw a.pendingProps}throw Error(o(156,a.tag))}function vs(t){t.flags|=4}function vd(t,a,n,r,c){if((a=(t.mode&32)!==0)&&(a=!1),a){if(t.flags|=16777216,(c&335544128)===c)if(t.stateNode.complete)t.flags|=8192;else if(ix())t.flags|=8192;else throw _n=vi,Dc}else t.flags&=-16777217}function O0(t,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!Wx(a))if(ix())t.flags|=8192;else throw _n=vi,Dc}function Di(t,a){a!==null&&(t.flags|=4),t.flags&16384&&(a=t.tag!==22?sa():536870912,t.lanes|=a,pr|=a)}function ml(t,a){if(!ct)switch(t.tailMode){case"hidden":a=t.tail;for(var n=null;a!==null;)a.alternate!==null&&(n=a),a=a.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?a||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function kt(t){var a=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(a)for(var c=t.child;c!==null;)n|=c.lanes|c.childLanes,r|=c.subtreeFlags&65011712,r|=c.flags&65011712,c.return=t,c=c.sibling;else for(c=t.child;c!==null;)n|=c.lanes|c.childLanes,r|=c.subtreeFlags,r|=c.flags,c.return=t,c=c.sibling;return t.subtreeFlags|=r,t.childLanes=n,a}function Ay(t,a,n){var r=a.pendingProps;switch(Ac(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return kt(a),null;case 1:return kt(a),null;case 3:return n=a.stateNode,r=null,t!==null&&(r=t.memoizedState.cache),a.memoizedState.cache!==r&&(a.flags|=2048),fs(Ht),qe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(t===null||t.child===null)&&(nr(a)?vs(a):t===null||t.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Tc())),kt(a),null;case 26:var c=a.type,m=a.memoizedState;return t===null?(vs(a),m!==null?(kt(a),O0(a,m)):(kt(a),vd(a,c,null,r,n))):m?m!==t.memoizedState?(vs(a),kt(a),O0(a,m)):(kt(a),a.flags&=-16777217):(t=t.memoizedProps,t!==r&&vs(a),kt(a),vd(a,c,t,r,n)),null;case 27:if(R(a),n=V.current,c=a.type,t!==null&&a.stateNode!=null)t.memoizedProps!==r&&vs(a);else{if(!r){if(a.stateNode===null)throw Error(o(166));return kt(a),null}t=O.current,nr(a)?xh(a):(t=Fx(c,r,n),a.stateNode=t,vs(a))}return kt(a),null;case 5:if(R(a),c=a.type,t!==null&&a.stateNode!=null)t.memoizedProps!==r&&vs(a);else{if(!r){if(a.stateNode===null)throw Error(o(166));return kt(a),null}if(m=O.current,nr(a))xh(a);else{var v=Ki(V.current);switch(m){case 1:m=v.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:m=v.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":m=v.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":m=v.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":m=v.createElement("div"),m.innerHTML="<script><\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof r.is=="string"?v.createElement("select",{is:r.is}):v.createElement("select"),r.multiple?m.multiple=!0:r.size&&(m.size=r.size);break;default:m=typeof r.is=="string"?v.createElement(c,{is:r.is}):v.createElement(c)}}m[Qt]=a,m[ra]=r;e:for(v=a.child;v!==null;){if(v.tag===5||v.tag===6)m.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===a)break e;for(;v.sibling===null;){if(v.return===null||v.return===a)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}a.stateNode=m;e:switch(Kt(m,c,r),c){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&vs(a)}}return kt(a),vd(a,a.type,t===null?null:t.memoizedProps,a.pendingProps,n),null;case 6:if(t&&a.stateNode!=null)t.memoizedProps!==r&&vs(a);else{if(typeof r!="string"&&a.stateNode===null)throw Error(o(166));if(t=V.current,nr(a)){if(t=a.stateNode,n=a.memoizedProps,r=null,c=Xt,c!==null)switch(c.tag){case 27:case 5:r=c.memoizedProps}t[Qt]=a,t=!!(t.nodeValue===n||r!==null&&r.suppressHydrationWarning===!0||Rx(t.nodeValue,n)),t||Bs(a,!0)}else t=Ki(t).createTextNode(r),t[Qt]=a,a.stateNode=t}return kt(a),null;case 31:if(n=a.memoizedState,t===null||t.memoizedState!==null){if(r=nr(a),n!==null){if(t===null){if(!r)throw Error(o(318));if(t=a.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(o(557));t[Qt]=a}else vn(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;kt(a),t=!1}else n=Tc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=n),t=!0;if(!t)return a.flags&256?(ya(a),a):(ya(a),null);if((a.flags&128)!==0)throw Error(o(558))}return kt(a),null;case 13:if(r=a.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(c=nr(a),r!==null&&r.dehydrated!==null){if(t===null){if(!c)throw Error(o(318));if(c=a.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(o(317));c[Qt]=a}else vn(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;kt(a),c=!1}else c=Tc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=c),c=!0;if(!c)return a.flags&256?(ya(a),a):(ya(a),null)}
vendor: 23,828 bytes, line 8
8return ya(a),(a.flags&128)!==0?(a.lanes=n,a):(n=r!==null,t=t!==null&&t.memoizedState!==null,n&&(r=a.child,c=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(c=r.alternate.memoizedState.cachePool.pool),m=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(m=r.memoizedState.cachePool.pool),m!==c&&(r.flags|=2048)),n!==t&&n&&(a.child.flags|=8192),Di(a,a.updateQueue),kt(a),null);case 4:return qe(),t===null&&Fd(a.stateNode.containerInfo),kt(a),null;case 10:return fs(a.type),kt(a),null;case 19:if(Z(Lt),r=a.memoizedState,r===null)return kt(a),null;if(c=(a.flags&128)!==0,m=r.rendering,m===null)if(c)ml(r,!1);else{if(Rt!==0||t!==null&&(t.flags&128)!==0)for(t=a.child;t!==null;){if(m=Ni(t),m!==null){for(a.flags|=128,ml(r,!1),t=m.updateQueue,a.updateQueue=t,Di(a,t),a.subtreeFlags=0,t=n,n=a.child;n!==null;)ch(n,t),n=n.sibling;return $(Lt,Lt.current&1|2),ct&&xs(a,r.treeForkCount),a.child}t=t.sibling}r.tail!==null&&He()>Fi&&(a.flags|=128,c=!0,ml(r,!1),a.lanes=4194304)}else{if(!c)if(t=Ni(m),t!==null){if(a.flags|=128,c=!0,t=t.updateQueue,a.updateQueue=t,Di(a,t),ml(r,!0),r.tail===null&&r.tailMode==="hidden"&&!m.alternate&&!ct)return kt(a),null}else 2*He()-r.renderingStartTime>Fi&&n!==536870912&&(a.flags|=128,c=!0,ml(r,!1),a.lanes=4194304);r.isBackwards?(m.sibling=a.child,a.child=m):(t=r.last,t!==null?t.sibling=m:a.child=m,r.last=m)}return r.tail!==null?(t=r.tail,r.rendering=t,r.tail=t.sibling,r.renderingStartTime=He(),t.sibling=null,n=Lt.current,$(Lt,c?n&1|2:n&1),ct&&xs(a,r.treeForkCount),t):(kt(a),null);case 22:case 23:return ya(a),Ic(),r=a.memoizedState!==null,t!==null?t.memoizedState!==null!==r&&(a.flags|=8192):r&&(a.flags|=8192),r?(n&536870912)!==0&&(a.flags&128)===0&&(kt(a),a.subtreeFlags&6&&(a.flags|=8192)):kt(a),n=a.updateQueue,n!==null&&Di(a,n.retryQueue),n=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(n=t.memoizedState.cachePool.pool),r=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(r=a.memoizedState.cachePool.pool),r!==n&&(a.flags|=2048),t!==null&&Z(kn),null;case 24:return n=null,t!==null&&(n=t.memoizedState.cache),a.memoizedState.cache!==n&&(a.flags|=2048),fs(Ht),kt(a),null;case 25:return null;case 30:return null}throw Error(o(156,a.tag))}function Ey(t,a){switch(Ac(a),a.tag){case 1:return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 3:return fs(Ht),qe(),t=a.flags,(t&65536)!==0&&(t&128)===0?(a.flags=t&-65537|128,a):null;case 26:case 27:case 5:return R(a),null;case 31:if(a.memoizedState!==null){if(ya(a),a.alternate===null)throw Error(o(340));vn()}return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 13:if(ya(a),t=a.memoizedState,t!==null&&t.dehydrated!==null){if(a.alternate===null)throw Error(o(340));vn()}return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 19:return Z(Lt),null;case 4:return qe(),null;case 10:return fs(a.type),null;case 22:case 23:return ya(a),Ic(),t!==null&&Z(kn),t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 24:return fs(Ht),null;case 25:return null;default:return null}}function $0(t,a){switch(Ac(a),a.tag){case 3:fs(Ht),qe();break;case 26:case 27:case 5:R(a);break;case 4:qe();break;case 31:a.memoizedState!==null&&ya(a);break;case 13:ya(a);break;case 19:Z(Lt);break;case 10:fs(a.type);break;case 22:case 23:ya(a),Ic(),t!==null&&Z(kn);break;case 24:fs(Ht)}}function hl(t,a){try{var n=a.updateQueue,r=n!==null?n.lastEffect:null;if(r!==null){var c=r.next;n=c;do{if((n.tag&t)===t){r=void 0;var m=n.create,v=n.inst;r=m(),v.destroy=r}n=n.next}while(n!==c)}}catch(E){pt(a,a.return,E)}}function Ps(t,a,n){try{var r=a.updateQueue,c=r!==null?r.lastEffect:null;if(c!==null){var m=c.next;r=m;do{if((r.tag&t)===t){var v=r.inst,E=v.destroy;if(E!==void 0){v.destroy=void 0,c=a;var B=n,ee=E;try{ee()}catch(ue){pt(c,B,ue)}}}r=r.next}while(r!==m)}}catch(ue){pt(a,a.return,ue)}}function D0(t){var a=t.updateQueue;if(a!==null){var n=t.stateNode;try{Ch(a,n)}catch(r){pt(t,t.return,r)}}}function H0(t,a,n){n.props=An(t.type,t.memoizedProps),n.state=t.memoizedState;try{n.componentWillUnmount()}catch(r){pt(t,a,r)}}function xl(t,a){try{var n=t.ref;if(n!==null){switch(t.tag){case 26:case 27:case 5:var r=t.stateNode;break;case 30:r=t.stateNode;break;default:r=t.stateNode}typeof n=="function"?t.refCleanup=n(r):n.current=r}}catch(c){pt(t,a,c)}}function ss(t,a){var n=t.ref,r=t.refCleanup;if(n!==null)if(typeof r=="function")try{r()}catch(c){pt(t,a,c)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(c){pt(t,a,c)}else n.current=null}function q0(t){var a=t.type,n=t.memoizedProps,r=t.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":n.autoFocus&&r.focus();break e;case"img":n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(c){pt(t,t.return,c)}}function jd(t,a,n){try{var r=t.stateNode;Zy(r,t.type,n,a),r[ra]=a}catch(c){pt(t,t.return,c)}}function B0(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&en(t.type)||t.tag===4}function wd(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||B0(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&en(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function kd(t,a,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,a?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(t,a):(a=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,a.appendChild(t),n=n._reactRootContainer,n!=null||a.onclick!==null||(a.onclick=us));else if(r!==4&&(r===27&&en(t.type)&&(n=t.stateNode,a=null),t=t.child,t!==null))for(kd(t,a,n),t=t.sibling;t!==null;)kd(t,a,n),t=t.sibling}function Hi(t,a,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,a?n.insertBefore(t,a):n.appendChild(t);else if(r!==4&&(r===27&&en(t.type)&&(n=t.stateNode),t=t.child,t!==null))for(Hi(t,a,n),t=t.sibling;t!==null;)Hi(t,a,n),t=t.sibling}function U0(t){var a=t.stateNode,n=t.memoizedProps;try{for(var r=t.type,c=a.attributes;c.length;)a.removeAttributeNode(c[0]);Kt(a,r,n),a[Qt]=t,a[ra]=n}catch(m){pt(t,t.return,m)}}var js=!1,Ut=!1,Nd=!1,F0=typeof WeakSet=="function"?WeakSet:Set,Pt=null;function Ty(t,a){if(t=t.containerInfo,Gd=ro,t=eh(t),pc(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var c=r.anchorOffset,m=r.focusNode;r=r.focusOffset;try{n.nodeType,m.nodeType}catch{n=null;break e}var v=0,E=-1,B=-1,ee=0,ue=0,fe=t,ae=null;t:for(;;){for(var re;fe!==n||c!==0&&fe.nodeType!==3||(E=v+c),fe!==m||r!==0&&fe.nodeType!==3||(B=v+r),fe.nodeType===3&&(v+=fe.nodeValue.length),(re=fe.firstChild)!==null;)ae=fe,fe=re;for(;;){if(fe===t)break t;if(ae===n&&++ee===c&&(E=v),ae===m&&++ue===r&&(B=v),(re=fe.nextSibling)!==null)break;fe=ae,ae=fe.parentNode}fe=re}n=E===-1||B===-1?null:{start:E,end:B}}else n=null}n=n||{start:0,end:0}}else n=null;for(Yd={focusedElem:t,selectionRange:n},ro=!1,Pt=a;Pt!==null;)if(a=Pt,t=a.child,(a.subtreeFlags&1028)!==0&&t!==null)t.return=a,Pt=t;else for(;Pt!==null;){switch(a=Pt,m=a.alternate,t=a.flags,a.tag){case 0:if((t&4)!==0&&(t=a.updateQueue,t=t!==null?t.events:null,t!==null))for(n=0;n<t.length;n++)c=t[n],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&m!==null){t=void 0,n=a,c=m.memoizedProps,m=m.memoizedState,r=n.stateNode;try{var De=An(n.type,c);t=r.getSnapshotBeforeUpdate(De,m),r.__reactInternalSnapshotBeforeUpdate=t}catch(Ye){pt(n,n.return,Ye)}}break;case 3:if((t&1024)!==0){if(t=a.stateNode.containerInfo,n=t.nodeType,n===9)Xd(t);else if(n===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":Xd(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(o(163))}if(t=a.sibling,t!==null){t.return=a.return,Pt=t;break}Pt=a.return}}function I0(t,a,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ks(t,n),r&4&&hl(5,n);break;case 1:if(ks(t,n),r&4)if(t=n.stateNode,a===null)try{t.componentDidMount()}catch(v){pt(n,n.return,v)}else{var c=An(n.type,a.memoizedProps);a=a.memoizedState;try{t.componentDidUpdate(c,a,t.__reactInternalSnapshotBeforeUpdate)}catch(v){pt(n,n.return,v)}}r&64&&D0(n),r&512&&xl(n,n.return);break;case 3:if(ks(t,n),r&64&&(t=n.updateQueue,t!==null)){if(a=null,n.child!==null)switch(n.child.tag){case 27:case 5:a=n.child.stateNode;break;case 1:a=n.child.stateNode}try{Ch(t,a)}catch(v){pt(n,n.return,v)}}break;case 27:a===null&&r&4&&U0(n);case 26:case 5:ks(t,n),a===null&&r&4&&q0(n),r&512&&xl(n,n.return);break;case 12:ks(t,n);break;case 31:ks(t,n),r&4&&Y0(t,n);break;case 13:ks(t,n),r&4&&P0(t,n),r&64&&(t=n.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(n=qy.bind(null,n),rb(t,n))));break;case 22:if(r=n.memoizedState!==null||js,!r){a=a!==null&&a.memoizedState!==null||Ut,c=js;var m=Ut;js=r,(Ut=a)&&!m?Ns(t,n,(n.subtreeFlags&8772)!==0):ks(t,n),js=c,Ut=m}break;case 30:break;default:ks(t,n)}}function V0(t){var a=t.alternate;a!==null&&(t.alternate=null,V0(a)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(a=t.stateNode,a!==null&&ec(a)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var _t=null,ia=!1;function ws(t,a,n){for(n=n.child;n!==null;)G0(t,a,n),n=n.sibling}function G0(t,a,n){if(Jt&&typeof Jt.onCommitFiberUnmount=="function")try{Jt.onCommitFiberUnmount(Os,n)}catch{}switch(n.tag){case 26:Ut||ss(n,a),ws(t,a,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Ut||ss(n,a);var r=_t,c=ia;en(n.type)&&(_t=n.stateNode,ia=!1),ws(t,a,n),kl(n.stateNode),_t=r,ia=c;break;case 5:Ut||ss(n,a);case 6:if(r=_t,c=ia,_t=null,ws(t,a,n),_t=r,ia=c,_t!==null)if(ia)try{(_t.nodeType===9?_t.body:_t.nodeName==="HTML"?_t.ownerDocument.body:_t).removeChild(n.stateNode)}catch(m){pt(n,a,m)}else try{_t.removeChild(n.stateNode)}catch(m){pt(n,a,m)}break;case 18:_t!==null&&(ia?(t=_t,Dx(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,n.stateNode),_r(t)):Dx(_t,n.stateNode));break;case 4:r=_t,c=ia,_t=n.stateNode.containerInfo,ia=!0,ws(t,a,n),_t=r,ia=c;break;case 0:case 11:case 14:case 15:Ps(2,n,a),Ut||Ps(4,n,a),ws(t,a,n);break;case 1:Ut||(ss(n,a),r=n.stateNode,typeof r.componentWillUnmount=="function"&&H0(n,a,r)),ws(t,a,n);break;case 21:ws(t,a,n);break;case 22:Ut=(r=Ut)||n.memoizedState!==null,ws(t,a,n),Ut=r;break;default:ws(t,a,n)}}function Y0(t,a){if(a.memoizedState===null&&(t=a.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{_r(t)}catch(n){pt(a,a.return,n)}}}function P0(t,a){if(a.memoizedState===null&&(t=a.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{_r(t)}catch(n){pt(a,a.return,n)}}function Ry(t){switch(t.tag){case 31:case 13:case 19:var a=t.stateNode;return a===null&&(a=t.stateNode=new F0),a;case 22:return t=t.stateNode,a=t._retryCache,a===null&&(a=t._retryCache=new F0),a;default:throw Error(o(435,t.tag))}}function qi(t,a){var n=Ry(t);a.forEach(function(r){if(!n.has(r)){n.add(r);var c=By.bind(null,t,r);r.then(c,c)}})}function oa(t,a){var n=a.deletions;if(n!==null)for(var r=0;r<n.length;r++){var c=n[r],m=t,v=a,E=v;e:for(;E!==null;){switch(E.tag){case 27:if(en(E.type)){_t=E.stateNode,ia=!1;break e}break;case 5:_t=E.stateNode,ia=!1;break e;case 3:case 4:_t=E.stateNode.containerInfo,ia=!0;break e}E=E.return}if(_t===null)throw Error(o(160));G0(m,v,c),_t=null,ia=!1,m=c.alternate,m!==null&&(m.return=null),c.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)Q0(a,t),a=a.sibling}var Qa=null;function Q0(t,a){var n=t.alternate,r=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:oa(a,t),ca(t),r&4&&(Ps(3,t,t.return),hl(3,t),Ps(5,t,t.return));break;case 1:oa(a,t),ca(t),r&512&&(Ut||n===null||ss(n,n.return)),r&64&&js&&(t=t.updateQueue,t!==null&&(r=t.callbacks,r!==null&&(n=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var c=Qa;if(oa(a,t),ca(t),r&512&&(Ut||n===null||ss(n,n.return)),r&4){var m=n!==null?n.memoizedState:null;if(r=t.memoizedState,n===null)if(r===null)if(t.stateNode===null){e:{r=t.type,n=t.memoizedProps,c=c.ownerDocument||c;t:switch(r){case"title":m=c.getElementsByTagName("title")[0],(!m||m[Ur]||m[Qt]||m.namespaceURI==="http://www.w3.org/2000/svg"||m.hasAttribute("itemprop"))&&(m=c.createElement(r),c.head.insertBefore(m,c.querySelector("head > title"))),Kt(m,r,n),m[Qt]=t,Yt(m),r=m;break e;case"link":var v=Qx("link","href",c).get(r+(n.href||""));if(v){for(var E=0;E<v.length;E++)if(m=v[E],m.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&m.getAttribute("rel")===(n.rel==null?null:n.rel)&&m.getAttribute("title")===(n.title==null?null:n.title)&&m.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){v.splice(E,1);break t}}m=c.createElement(r),Kt(m,r,n),c.head.appendChild(m);break;case"meta":if(v=Qx("meta","content",c).get(r+(n.content||""))){for(E=0;E<v.length;E++)if(m=v[E],m.getAttribute("content")===(n.content==null?null:""+n.content)&&m.getAttribute("name")===(n.name==null?null:n.name)&&m.getAttribute("property")===(n.property==null?null:n.property)&&m.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&m.getAttribute("charset")===(n.charSet==null?null:n.charSet)){v.splice(E,1);break t}}m=c.createElement(r),Kt(m,r,n),c.head.appendChild(m);break;default:throw Error(o(468,r))}m[Qt]=t,Yt(m),r=m}t.stateNode=r}else Xx(c,t.type,t.stateNode);else t.stateNode=Px(c,r,t.memoizedProps);else m!==r?(m===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):m.count--,r===null?Xx(c,t.type,t.stateNode):Px(c,r,t.memoizedProps)):r===null&&t.stateNode!==null&&jd(t,t.memoizedProps,n.memoizedProps)}break;case 27:oa(a,t),ca(t),r&512&&(Ut||n===null||ss(n,n.return)),n!==null&&r&4&&jd(t,t.memoizedProps,n.memoizedProps);break;case 5:if(oa(a,t),ca(t),r&512&&(Ut||n===null||ss(n,n.return)),t.flags&32){c=t.stateNode;try{Qn(c,"")}catch(De){pt(t,t.return,De)}}r&4&&t.stateNode!=null&&(c=t.memoizedProps,jd(t,c,n!==null?n.memoizedProps:c)),r&1024&&(Nd=!0);break;case 6:if(oa(a,t),ca(t),r&4){if(t.stateNode===null)throw Error(o(162));r=t.memoizedProps,n=t.stateNode;try{n.nodeValue=r}catch(De){pt(t,t.return,De)}}break;case 3:if(to=null,c=Qa,Qa=Ji(a.containerInfo),oa(a,t),Qa=c,ca(t),r&4&&n!==null&&n.memoizedState.isDehydrated)try{_r(a.containerInfo)}catch(De){pt(t,t.return,De)}Nd&&(Nd=!1,X0(t));break;case 4:r=Qa,Qa=Ji(t.stateNode.containerInfo),oa(a,t),ca(t),Qa=r;break;case 12:oa(a,t),ca(t);break;case 31:oa(a,t),ca(t),r&4&&(r=t.updateQueue,r!==null&&(t.updateQueue=null,qi(t,r)));break;case 13:oa(a,t),ca(t),t.child.flags&8192&&t.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Ui=He()),r&4&&(r=t.updateQueue,r!==null&&(t.updateQueue=null,qi(t,r)));break;case 22:c=t.memoizedState!==null;var B=n!==null&&n.memoizedState!==null,ee=js,ue=Ut;if(js=ee||c,Ut=ue||B,oa(a,t),Ut=ue,js=ee,ca(t),r&8192)e:for(a=t.stateNode,a._visibility=c?a._visibility&-2:a._visibility|1,c&&(n===null||B||js||Ut||En(t)),n=null,a=t;;){if(a.tag===5||a.tag===26){if(n===null){B=n=a;try{if(m=B.stateNode,c)v=m.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none";else{E=B.stateNode;var fe=B.memoizedProps.style,ae=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;E.style.display=ae==null||typeof ae=="boolean"?"":(""+ae).trim()}}catch(De){pt(B,B.return,De)}}}else if(a.tag===6){if(n===null){B=a;try{B.stateNode.nodeValue=c?"":B.memoizedProps}catch(De){pt(B,B.return,De)}}}else if(a.tag===18){if(n===null){B=a;try{var re=B.stateNode;c?Hx(re,!0):Hx(B.stateNode,!1)}catch(De){pt(B,B.return,De)}}}else if((a.tag!==22&&a.tag!==23||a.memoizedState===null||a===t)&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===t)break e;for(;a.sibling===null;){if(a.return===null||a.return===t)break e;n===a&&(n=null),a=a.return}n===a&&(n=null),a.sibling.return=a.return,a=a.sibling}r&4&&(r=t.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,qi(t,n))));break;case 19:oa(a,t),ca(t),r&4&&(r=t.updateQueue,r!==null&&(t.updateQueue=null,qi(t,r)));break;case 30:break;case 21:break;default:oa(a,t),ca(t)}}function ca(t){var a=t.flags;if(a&2){try{for(var n,r=t.return;r!==null;){if(B0(r)){n=r;break}r=r.return}if(n==null)throw Error(o(160));switch(n.tag){case 27:var c=n.stateNode,m=wd(t);Hi(t,m,c);break;case 5:var v=n.stateNode;n.flags&32&&(Qn(v,""),n.flags&=-33);var E=wd(t);Hi(t,E,v);break;case 3:case 4:var B=n.stateNode.containerInfo,ee=wd(t);kd(t,ee,B);break;default:throw Error(o(161))}}catch(ue){pt(t,t.return,ue)}t.flags&=-3}a&4096&&(t.flags&=-4097)}function X0(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var a=t;X0(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),t=t.sibling}}function ks(t,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)I0(t,a.alternate,a),a=a.sibling}function En(t){for(t=t.child;t!==null;){var a=t;switch(a.tag){case 0:case 11:case 14:case 15:Ps(4,a,a.return),En(a);break;case 1:ss(a,a.return);var n=a.stateNode;typeof n.componentWillUnmount=="function"&&H0(a,a.return,n),En(a);break;case 27:kl(a.stateNode);case 26:case 5:ss(a,a.return),En(a);break;case 22:a.memoizedState===null&&En(a);break;case 30:En(a);break;default:En(a)}t=t.sibling}}function Ns(t,a,n){for(n=n&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var r=a.alternate,c=t,m=a,v=m.flags;switch(m.tag){case 0:case 11:case 15:Ns(c,m,n),hl(4,m);break;case 1:if(Ns(c,m,n),r=m,c=r.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(ee){pt(r,r.return,ee)}if(r=m,c=r.updateQueue,c!==null){var E=r.stateNode;try{var B=c.shared.hiddenCallbacks;if(B!==null)for(c.shared.hiddenCallbacks=null,c=0;c<B.length;c++)Sh(B[c],E)}catch(ee){pt(r,r.return,ee)}}n&&v&64&&D0(m),xl(m,m.return);break;case 27:U0(m);case 26:case 5:Ns(c,m,n),n&&r===null&&v&4&&q0(m),xl(m,m.return);break;case 12:Ns(c,m,n);break;case 31:Ns(c,m,n),n&&v&4&&Y0(c,m);break;case 13:Ns(c,m,n),n&&v&4&&P0(c,m);break;case 22:m.memoizedState===null&&Ns(c,m,n),xl(m,m.return);break;case 30:break;default:Ns(c,m,n)}a=a.sibling}}function _d(t,a){var n=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(n=t.memoizedState.cachePool.pool),t=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(t=a.memoizedState.cachePool.pool),t!==n&&(t!=null&&t.refCount++,n!=null&&el(n))}function Sd(t,a){t=null,a.alternate!==null&&(t=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==t&&(a.refCount++,t!=null&&el(t))}function Xa(t,a,n,r){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)W0(t,a,n,r),a=a.sibling}function W0(t,a,n,r){var c=a.flags;switch(a.tag){case 0:case 11:case 15:Xa(t,a,n,r),c&2048&&hl(9,a);break;case 1:Xa(t,a,n,r);break;case 3:Xa(t,a,n,r),c&2048&&(t=null,a.alternate!==null&&(t=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==t&&(a.refCount++,t!=null&&el(t)));break;case 12:if(c&2048){Xa(t,a,n,r),t=a.stateNode;try{var m=a.memoizedProps,v=m.id,E=m.onPostCommit;typeof E=="function"&&E(v,a.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(B){pt(a,a.return,B)}}else Xa(t,a,n,r);break;case 31:Xa(t,a,n,r);break;case 13:Xa(t,a,n,r);break;case 23:break;case 22:m=a.stateNode,v=a.alternate,a.memoizedState!==null?m._visibility&2?Xa(t,a,n,r):gl(t,a):m._visibility&2?Xa(t,a,n,r):(m._visibility|=2,xr(t,a,n,r,(a.subtreeFlags&10256)!==0||!1)),c&2048&&_d(v,a);break;case 24:Xa(t,a,n,r),c&2048&&Sd(a.alternate,a);break;default:Xa(t,a,n,r)}}function xr(t,a,n,r,c){for(c=c&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var m=t,v=a,E=n,B=r,ee=v.flags;switch(v.tag){case 0:case 11:case 15:xr(m,v,E,B,c),hl(8,v);break;case 23:break;case 22:var ue=v.stateNode;v.memoizedState!==null?ue._visibility&2?xr(m,v,E,B,c):gl(m,v):(ue._visibility|=2,xr(m,v,E,B,c)),c&&ee&2048&&_d(v.alternate,v);break;case 24:xr(m,v,E,B,c),c&&ee&2048&&Sd(v.alternate,v);break;default:xr(m,v,E,B,c)}a=a.sibling}}function gl(t,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var n=t,r=a,c=r.flags;switch(r.tag){case 22:gl(n,r),c&2048&&_d(r.alternate,r);break;case 24:gl(n,r),c&2048&&Sd(r.alternate,r);break;default:gl(n,r)}a=a.sibling}}var fl=8192;function gr(t,a,n){if(t.subtreeFlags&fl)for(t=t.child;t!==null;)Z0(t,a,n),t=t.sibling}function Z0(t,a,n){switch(t.tag){case 26:gr(t,a,n),t.flags&fl&&t.memoizedState!==null&&pb(n,Qa,t.memoizedState,t.memoizedProps);break;case 5:gr(t,a,n);break;case 3:case 4:var r=Qa;Qa=Ji(t.stateNode.containerInfo),gr(t,a,n),Qa=r;break;case 22:t.memoizedState===null&&(r=t.alternate,r!==null&&r.memoizedState!==null?(r=fl,fl=16777216,gr(t,a,n),fl=r):gr(t,a,n));break;default:gr(t,a,n)}}function K0(t){var a=t.alternate;if(a!==null&&(t=a.child,t!==null)){a.child=null;do a=t.sibling,t.sibling=null,t=a;while(t!==null)}}function pl(t){var a=t.deletions;if((t.flags&16)!==0){if(a!==null)for(var n=0;n<a.length;n++){var r=a[n];Pt=r,ex(r,t)}K0(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)J0(t),t=t.sibling}function J0(t){switch(t.tag){case 0:case 11:case 15:pl(t),t.flags&2048&&Ps(9,t,t.return);break;case 3:pl(t);break;case 12:pl(t);break;case 22:var a=t.stateNode;t.memoizedState!==null&&a._visibility&2&&(t.return===null||t.return.tag!==13)?(a._visibility&=-3,Bi(t)):pl(t);break;default:pl(t)}}function Bi(t){var a=t.deletions;if((t.flags&16)!==0){if(a!==null)for(var n=0;n<a.length;n++){var r=a[n];Pt=r,ex(r,t)}K0(t)}for(t=t.child;t!==null;){switch(a=t,a.tag){case 0:case 11:case 15:Ps(8,a,a.return),Bi(a);break;case 22:n=a.stateNode,n._visibility&2&&(n._visibility&=-3,Bi(a));break;default:Bi(a)}t=t.sibling}}function ex(t,a){for(;Pt!==null;){var n=Pt;switch(n.tag){case 0:case 11:case 15:Ps(8,n,a);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:el(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Pt=r;else e:for(n=t;Pt!==null;){r=Pt;var c=r.sibling,m=r.return;if(V0(r),r===n){Pt=null;break e}if(c!==null){c.return=m,Pt=c;break e}Pt=m}}}var zy={getCacheForType:function(t){var a=Wt(Ht),n=a.data.get(t);return n===void 0&&(n=t(),a.data.set(t,n)),n},cacheSignal:function(){return Wt(Ht).controller.signal}},Ly=typeof WeakMap=="function"?WeakMap:Map,xt=0,jt=null,rt=null,it=0,ft=0,ba=null,Qs=!1,fr=!1,Cd=!1,_s=0,Rt=0,Xs=0,Tn=0,Ad=0,va=0,pr=0,yl=null,da=null,Ed=!1,Ui=0,tx=0,Fi=1/0,Ii=null,Ws=null,Vt=0,Zs=null,yr=null,Ss=0,Td=0,Rd=null,ax=null,bl=0,zd=null;function ja(){return(xt&2)!==0&&it!==0?it&-it:M.T!==null?Hd():ym()}function sx(){if(va===0)if((it&536870912)===0||ct){var t=hn;hn<<=1,(hn&3932160)===0&&(hn=262144),va=t}else va=536870912;return t=pa.current,t!==null&&(t.flags|=32),va}function ua(t,a,n){(t===jt&&(ft===2||ft===9)||t.cancelPendingCommit!==null)&&(br(t,0),Ks(t,it,va,!1)),Pe(t,n),((xt&2)===0||t!==jt)&&(t===jt&&((xt&2)===0&&(Tn|=n),Rt===4&&Ks(t,it,va,!1)),ns(t))}function nx(t,a,n){if((xt&6)!==0)throw Error(o(327));var r=!n&&(a&127)===0&&(a&t.expiredLanes)===0||Ge(t,a),c=r?$y(t,a):Md(t,a,!0),m=r;do{if(c===0){fr&&!r&&Ks(t,a,0,!1);break}else{if(n=t.current.alternate,m&&!My(n)){c=Md(t,a,!1),m=!1;continue}if(c===2){if(m=a,t.errorRecoveryDisabledLanes&m)var v=0;else v=t.pendingLanes&-536870913,v=v!==0?v:v&536870912?536870912:0;if(v!==0){a=v;e:{var E=t;c=yl;var B=E.current.memoizedState.isDehydrated;if(B&&(br(E,v).flags|=256),v=Md(E,v,!1),v!==2){if(Cd&&!B){E.errorRecoveryDisabledLanes|=m,Tn|=m,c=4;break e}m=da,da=c,m!==null&&(da===null?da=m:da.push.apply(da,m))}c=v}if(m=!1,c!==2)continue}}if(c===1){br(t,0),Ks(t,a,0,!0);break}e:{switch(r=t,m=c,m){case 0:case 1:throw Error(o(345));case 4:if((a&4194048)!==a)break;case 6:Ks(r,a,va,!Qs);break e;case 2:da=null;break;case 3:case 5:break;default:throw Error(o(329))}
vendor: 15,582 bytes, line 8
8if((a&62914560)===a&&(c=Ui+300-He(),10<c)){if(Ks(r,a,va,!Qs),Ue(r,0,!0)!==0)break e;Ss=a,r.timeoutHandle=Ox(rx.bind(null,r,n,da,Ii,Ed,a,va,Tn,pr,Qs,m,"Throttled",-0,0),c);break e}rx(r,n,da,Ii,Ed,a,va,Tn,pr,Qs,m,null,-0,0)}}break}while(!0);ns(t)}function rx(t,a,n,r,c,m,v,E,B,ee,ue,fe,ae,re){if(t.timeoutHandle=-1,fe=a.subtreeFlags,fe&8192||(fe&16785408)===16785408){fe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:us},Z0(a,m,fe);var De=(m&62914560)===m?Ui-He():(m&4194048)===m?tx-He():0;if(De=yb(fe,De),De!==null){Ss=m,t.cancelPendingCommit=De(hx.bind(null,t,a,m,n,r,c,v,E,B,ue,fe,null,ae,re)),Ks(t,m,v,!ee);return}}hx(t,a,m,n,r,c,v,E,B)}function My(t){for(var a=t;;){var n=a.tag;if((n===0||n===11||n===15)&&a.flags&16384&&(n=a.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var c=n[r],m=c.getSnapshot;c=c.value;try{if(!ga(m(),c))return!1}catch{return!1}}if(n=a.child,a.subtreeFlags&16384&&n!==null)n.return=a,a=n;else{if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Ks(t,a,n,r){a&=~Ad,a&=~Tn,t.suspendedLanes|=a,t.pingedLanes&=~a,r&&(t.warmLanes|=a),r=t.expirationTimes;for(var c=a;0<c;){var m=31-aa(c),v=1<<m;r[m]=-1,c&=~v}n!==0&&Jl(t,n,a)}function Vi(){return(xt&6)===0?(vl(0),!1):!0}function Ld(){if(rt!==null){if(ft===0)var t=rt.return;else t=rt,gs=jn=null,Xc(t),cr=null,al=0,t=rt;for(;t!==null;)$0(t.alternate,t),t=t.return;rt=null}}function br(t,a){var n=t.timeoutHandle;n!==-1&&(t.timeoutHandle=-1,eb(n)),n=t.cancelPendingCommit,n!==null&&(t.cancelPendingCommit=null,n()),Ss=0,Ld(),jt=t,rt=n=hs(t.current,null),it=a,ft=0,ba=null,Qs=!1,fr=Ge(t,a),Cd=!1,pr=va=Ad=Tn=Xs=Rt=0,da=yl=null,Ed=!1,(a&8)!==0&&(a|=a&32);var r=t.entangledLanes;if(r!==0)for(t=t.entanglements,r&=a;0<r;){var c=31-aa(r),m=1<<c;a|=t[c],r&=~m}return _s=a,ui(),n}function lx(t,a){at=null,M.H=dl,a===or||a===bi?(a=wh(),ft=3):a===Dc?(a=wh(),ft=4):ft=a===ud?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,ba=a,rt===null&&(Rt=1,Li(t,Ta(a,t.current)))}function ix(){var t=pa.current;return t===null?!0:(it&4194048)===it?Ma===null:(it&62914560)===it||(it&536870912)!==0?t===Ma:!1}function ox(){var t=M.H;return M.H=dl,t===null?dl:t}function cx(){var t=M.A;return M.A=zy,t}function Gi(){Rt=4,Qs||(it&4194048)!==it&&pa.current!==null||(fr=!0),(Xs&134217727)===0&&(Tn&134217727)===0||jt===null||Ks(jt,it,va,!1)}function Md(t,a,n){var r=xt;xt|=2;var c=ox(),m=cx();(jt!==t||it!==a)&&(Ii=null,br(t,a)),a=!1;var v=Rt;e:do try{if(ft!==0&&rt!==null){var E=rt,B=ba;switch(ft){case 8:Ld(),v=6;break e;case 3:case 2:case 9:case 6:pa.current===null&&(a=!0);var ee=ft;if(ft=0,ba=null,vr(t,E,B,ee),n&&fr){v=0;break e}break;default:ee=ft,ft=0,ba=null,vr(t,E,B,ee)}}Oy(),v=Rt;break}catch(ue){lx(t,ue)}while(!0);return a&&t.shellSuspendCounter++,gs=jn=null,xt=r,M.H=c,M.A=m,rt===null&&(jt=null,it=0,ui()),v}function Oy(){for(;rt!==null;)dx(rt)}function $y(t,a){var n=xt;xt|=2;var r=ox(),c=cx();jt!==t||it!==a?(Ii=null,Fi=He()+500,br(t,a)):fr=Ge(t,a);e:do try{if(ft!==0&&rt!==null){a=rt;var m=ba;t:switch(ft){case 1:ft=0,ba=null,vr(t,a,m,1);break;case 2:case 9:if(vh(m)){ft=0,ba=null,ux(a);break}a=function(){ft!==2&&ft!==9||jt!==t||(ft=7),ns(t)},m.then(a,a);break e;case 3:ft=7;break e;case 4:ft=5;break e;case 7:vh(m)?(ft=0,ba=null,ux(a)):(ft=0,ba=null,vr(t,a,m,7));break;case 5:var v=null;switch(rt.tag){case 26:v=rt.memoizedState;case 5:case 27:var E=rt;if(v?Wx(v):E.stateNode.complete){ft=0,ba=null;var B=E.sibling;if(B!==null)rt=B;else{var ee=E.return;ee!==null?(rt=ee,Yi(ee)):rt=null}break t}}ft=0,ba=null,vr(t,a,m,5);break;case 6:ft=0,ba=null,vr(t,a,m,6);break;case 8:Ld(),Rt=6;break e;default:throw Error(o(462))}}Dy();break}catch(ue){lx(t,ue)}while(!0);return gs=jn=null,M.H=r,M.A=c,xt=n,rt!==null?0:(jt=null,it=0,ui(),Rt)}function Dy(){for(;rt!==null&&!dt();)dx(rt)}function dx(t){var a=M0(t.alternate,t,_s);t.memoizedProps=t.pendingProps,a===null?Yi(t):rt=a}function ux(t){var a=t,n=a.alternate;switch(a.tag){case 15:case 0:a=A0(n,a,a.pendingProps,a.type,void 0,it);break;case 11:a=A0(n,a,a.pendingProps,a.type.render,a.ref,it);break;case 5:Xc(a);default:$0(n,a),a=rt=ch(a,_s),a=M0(n,a,_s)}t.memoizedProps=t.pendingProps,a===null?Yi(t):rt=a}function vr(t,a,n,r){gs=jn=null,Xc(a),cr=null,al=0;var c=a.return;try{if(_y(t,c,a,n,it)){Rt=1,Li(t,Ta(n,t.current)),rt=null;return}}catch(m){if(c!==null)throw rt=c,m;Rt=1,Li(t,Ta(n,t.current)),rt=null;return}a.flags&32768?(ct||r===1?t=!0:fr||(it&536870912)!==0?t=!1:(Qs=t=!0,(r===2||r===9||r===3||r===6)&&(r=pa.current,r!==null&&r.tag===13&&(r.flags|=16384))),mx(a,t)):Yi(a)}function Yi(t){var a=t;do{if((a.flags&32768)!==0){mx(a,Qs);return}t=a.return;var n=Ay(a.alternate,a,_s);if(n!==null){rt=n;return}if(a=a.sibling,a!==null){rt=a;return}rt=a=t}while(a!==null);Rt===0&&(Rt=5)}function mx(t,a){do{var n=Ey(t.alternate,t);if(n!==null){n.flags&=32767,rt=n;return}if(n=t.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!a&&(t=t.sibling,t!==null)){rt=t;return}rt=t=n}while(t!==null);Rt=6,rt=null}function hx(t,a,n,r,c,m,v,E,B){t.cancelPendingCommit=null;do Pi();while(Vt!==0);if((xt&6)!==0)throw Error(o(327));if(a!==null){if(a===t.current)throw Error(o(177));if(m=a.lanes|a.childLanes,m|=wc,Dt(t,n,m,v,E,B),t===jt&&(rt=jt=null,it=0),yr=a,Zs=t,Ss=n,Td=m,Rd=c,ax=r,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,Uy(un,function(){return yx(),null})):(t.callbackNode=null,t.callbackPriority=0),r=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||r){r=M.T,M.T=null,c=Y.p,Y.p=2,v=xt,xt|=4;try{Ty(t,a,n)}finally{xt=v,Y.p=c,M.T=r}}Vt=1,xx(),gx(),fx()}}function xx(){if(Vt===1){Vt=0;var t=Zs,a=yr,n=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||n){n=M.T,M.T=null;var r=Y.p;Y.p=2;var c=xt;xt|=4;try{Q0(a,t);var m=Yd,v=eh(t.containerInfo),E=m.focusedElem,B=m.selectionRange;if(v!==E&&E&&E.ownerDocument&&Jm(E.ownerDocument.documentElement,E)){if(B!==null&&pc(E)){var ee=B.start,ue=B.end;if(ue===void 0&&(ue=ee),"selectionStart"in E)E.selectionStart=ee,E.selectionEnd=Math.min(ue,E.value.length);else{var fe=E.ownerDocument||document,ae=fe&&fe.defaultView||window;if(ae.getSelection){var re=ae.getSelection(),De=E.textContent.length,Ye=Math.min(B.start,De),vt=B.end===void 0?Ye:Math.min(B.end,De);!re.extend&&Ye>vt&&(v=vt,vt=Ye,Ye=v);var W=Km(E,Ye),G=Km(E,vt);if(W&&G&&(re.rangeCount!==1||re.anchorNode!==W.node||re.anchorOffset!==W.offset||re.focusNode!==G.node||re.focusOffset!==G.offset)){var J=fe.createRange();J.setStart(W.node,W.offset),re.removeAllRanges(),Ye>vt?(re.addRange(J),re.extend(G.node,G.offset)):(J.setEnd(G.node,G.offset),re.addRange(J))}}}}for(fe=[],re=E;re=re.parentNode;)re.nodeType===1&&fe.push({element:re,left:re.scrollLeft,top:re.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;E<fe.length;E++){var xe=fe[E];xe.element.scrollLeft=xe.left,xe.element.scrollTop=xe.top}}ro=!!Gd,Yd=Gd=null}finally{xt=c,Y.p=r,M.T=n}}t.current=a,Vt=2}}function gx(){if(Vt===2){Vt=0;var t=Zs,a=yr,n=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||n){n=M.T,M.T=null;var r=Y.p;Y.p=2;var c=xt;xt|=4;try{I0(t,a.alternate,a)}finally{xt=c,Y.p=r,M.T=n}}Vt=3}}function fx(){if(Vt===4||Vt===3){Vt=0,Q();var t=Zs,a=yr,n=Ss,r=ax;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?Vt=5:(Vt=0,yr=Zs=null,px(t,t.pendingLanes));var c=t.pendingLanes;if(c===0&&(Ws=null),Ko(n),a=a.stateNode,Jt&&typeof Jt.onCommitFiberRoot=="function")try{Jt.onCommitFiberRoot(Os,a,void 0,(a.current.flags&128)===128)}catch{}if(r!==null){a=M.T,c=Y.p,Y.p=2,M.T=null;try{for(var m=t.onRecoverableError,v=0;v<r.length;v++){var E=r[v];m(E.value,{componentStack:E.stack})}}finally{M.T=a,Y.p=c}}(Ss&3)!==0&&Pi(),ns(t),c=t.pendingLanes,(n&261930)!==0&&(c&42)!==0?t===zd?bl++:(bl=0,zd=t):bl=0,vl(0)}}function px(t,a){(t.pooledCacheLanes&=a)===0&&(a=t.pooledCache,a!=null&&(t.pooledCache=null,el(a)))}function Pi(){return xx(),gx(),fx(),yx()}function yx(){if(Vt!==5)return!1;var t=Zs,a=Td;Td=0;var n=Ko(Ss),r=M.T,c=Y.p;try{Y.p=32>n?32:n,M.T=null,n=Rd,Rd=null;var m=Zs,v=Ss;if(Vt=0,yr=Zs=null,Ss=0,(xt&6)!==0)throw Error(o(331));var E=xt;if(xt|=4,J0(m.current),W0(m,m.current,v,n),xt=E,vl(0,!1),Jt&&typeof Jt.onPostCommitFiberRoot=="function")try{Jt.onPostCommitFiberRoot(Os,m)}catch{}return!0}finally{Y.p=c,M.T=r,px(t,a)}}function bx(t,a,n){a=Ta(n,a),a=dd(t.stateNode,a,2),t=Vs(t,a,2),t!==null&&(Pe(t,2),ns(t))}function pt(t,a,n){if(t.tag===3)bx(t,t,n);else for(;a!==null;){if(a.tag===3){bx(a,t,n);break}else if(a.tag===1){var r=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Ws===null||!Ws.has(r))){t=Ta(n,t),n=v0(2),r=Vs(a,n,2),r!==null&&(j0(n,r,a,t),Pe(r,2),ns(r));break}}a=a.return}}function Od(t,a,n){var r=t.pingCache;if(r===null){r=t.pingCache=new Ly;var c=new Set;r.set(a,c)}else c=r.get(a),c===void 0&&(c=new Set,r.set(a,c));c.has(n)||(Cd=!0,c.add(n),t=Hy.bind(null,t,a,n),a.then(t,t))}function Hy(t,a,n){var r=t.pingCache;r!==null&&r.delete(a),t.pingedLanes|=t.suspendedLanes&n,t.warmLanes&=~n,jt===t&&(it&n)===n&&(Rt===4||Rt===3&&(it&62914560)===it&&300>He()-Ui?(xt&2)===0&&br(t,0):Ad|=n,pr===it&&(pr=0)),ns(t)}function vx(t,a){a===0&&(a=sa()),t=yn(t,a),t!==null&&(Pe(t,a),ns(t))}function qy(t){var a=t.memoizedState,n=0;a!==null&&(n=a.retryLane),vx(t,n)}function By(t,a){var n=0;switch(t.tag){case 31:case 13:var r=t.stateNode,c=t.memoizedState;c!==null&&(n=c.retryLane);break;case 19:r=t.stateNode;break;case 22:r=t.stateNode._retryCache;break;default:throw Error(o(314))}r!==null&&r.delete(a),vx(t,n)}function Uy(t,a){return ve(t,a)}var Qi=null,jr=null,$d=!1,Xi=!1,Dd=!1,Js=0;function ns(t){t!==jr&&t.next===null&&(jr===null?Qi=jr=t:jr=jr.next=t),Xi=!0,$d||($d=!0,Iy())}function vl(t,a){if(!Dd&&Xi){Dd=!0;do for(var n=!1,r=Qi;r!==null;){if(t!==0){var c=r.pendingLanes;if(c===0)var m=0;else{var v=r.suspendedLanes,E=r.pingedLanes;m=(1<<31-aa(42|t)+1)-1,m&=c&~(v&~E),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(n=!0,Nx(r,m))}else m=it,m=Ue(r,r===jt?m:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),(m&3)===0||Ge(r,m)||(n=!0,Nx(r,m));r=r.next}while(n);Dd=!1}}function Fy(){jx()}function jx(){Xi=$d=!1;var t=0;Js!==0&&Jy()&&(t=Js);for(var a=He(),n=null,r=Qi;r!==null;){var c=r.next,m=wx(r,a);m===0?(r.next=null,n===null?Qi=c:n.next=c,c===null&&(jr=n)):(n=r,(t!==0||(m&3)!==0)&&(Xi=!0)),r=c}Vt!==0&&Vt!==5||vl(t),Js!==0&&(Js=0)}function wx(t,a){for(var n=t.suspendedLanes,r=t.pingedLanes,c=t.expirationTimes,m=t.pendingLanes&-62914561;0<m;){var v=31-aa(m),E=1<<v,B=c[v];B===-1?((E&n)===0||(E&r)!==0)&&(c[v]=Sa(E,a)):B<=a&&(t.expiredLanes|=E),m&=~E}if(a=jt,n=it,n=Ue(t,t===a?n:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),r=t.callbackNode,n===0||t===a&&(ft===2||ft===9)||t.cancelPendingCommit!==null)return r!==null&&r!==null&&Oe(r),t.callbackNode=null,t.callbackPriority=0;if((n&3)===0||Ge(t,n)){if(a=n&-n,a===t.callbackPriority)return a;switch(r!==null&&Oe(r),Ko(n)){case 2:case 8:n=Ms;break;case 32:n=un;break;case 268435456:n=Zl;break;default:n=un}return r=kx.bind(null,t),n=ve(n,r),t.callbackPriority=a,t.callbackNode=n,a}return r!==null&&r!==null&&Oe(r),t.callbackPriority=2,t.callbackNode=null,2}function kx(t,a){if(Vt!==0&&Vt!==5)return t.callbackNode=null,t.callbackPriority=0,null;var n=t.callbackNode;if(Pi()&&t.callbackNode!==n)return null;var r=it;return r=Ue(t,t===jt?r:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),r===0?null:(nx(t,r,a),wx(t,He()),t.callbackNode!=null&&t.callbackNode===n?kx.bind(null,t):null)}function Nx(t,a){if(Pi())return null;nx(t,a,!0)}function Iy(){tb(function(){(xt&6)!==0?ve(Ls,Fy):jx()})}function Hd(){if(Js===0){var t=lr;t===0&&(t=mn,mn<<=1,(mn&261888)===0&&(mn=256)),Js=t}return Js}function _x(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:si(""+t)}function Sx(t,a){var n=a.ownerDocument.createElement("input");return n.name=a.name,n.value=a.value,t.id&&n.setAttribute("form",t.id),a.parentNode.insertBefore(n,a),t=new FormData(t),n.parentNode.removeChild(n),t}function Vy(t,a,n,r,c){if(a==="submit"&&n&&n.stateNode===c){var m=_x((c[ra]||null).action),v=r.submitter;v&&(a=(a=v[ra]||null)?_x(a.formAction):v.getAttribute("formAction"),a!==null&&(m=a,v=null));var E=new ii("action","action",null,r,c);t.push({event:E,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Js!==0){var B=v?Sx(c,v):new FormData(c);nd(n,{pending:!0,data:B,method:c.method,action:m},null,B)}}else typeof m=="function"&&(E.preventDefault(),B=v?Sx(c,v):new FormData(c),nd(n,{pending:!0,data:B,method:c.method,action:m},m,B))},currentTarget:c}]})}}for(var qd=0;qd<jc.length;qd++){var Bd=jc[qd],Gy=Bd.toLowerCase(),Yy=Bd[0].toUpperCase()+Bd.slice(1);Pa(Gy,"on"+Yy)}Pa(sh,"onAnimationEnd"),Pa(nh,"onAnimationIteration"),Pa(rh,"onAnimationStart"),Pa("dblclick","onDoubleClick"),Pa("focusin","onFocus"),Pa("focusout","onBlur"),Pa(oy,"onTransitionRun"),Pa(cy,"onTransitionStart"),Pa(dy,"onTransitionCancel"),Pa(lh,"onTransitionEnd"),Yn("onMouseEnter",["mouseout","mouseover"]),Yn("onMouseLeave",["mouseout","mouseover"]),Yn("onPointerEnter",["pointerout","pointerover"]),Yn("onPointerLeave",["pointerout","pointerover"]),xn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),xn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),xn("onBeforeInput",["compositionend","keypress","textInput","paste"]),xn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),xn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),xn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var jl="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(" "),Py=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(jl));function Cx(t,a){a=(a&4)!==0;for(var n=0;n<t.length;n++){var r=t[n],c=r.event;r=r.listeners;e:{var m=void 0;if(a)for(var v=r.length-1;0<=v;v--){var E=r[v],B=E.instance,ee=E.currentTarget;if(E=E.listener,B!==m&&c.isPropagationStopped())break e;m=E,c.currentTarget=ee;try{m(c)}catch(ue){di(ue)}c.currentTarget=null,m=B}else for(v=0;v<r.length;v++){if(E=r[v],B=E.instance,ee=E.currentTarget,E=E.listener,B!==m&&c.isPropagationStopped())break e;m=E,c.currentTarget=ee;try{m(c)}catch(ue){di(ue)}c.currentTarget=null,m=B}}}}function lt(t,a){var n=a[Jo];n===void 0&&(n=a[Jo]=new Set);var r=t+"__bubble";n.has(r)||(Ax(a,t,2,!1),n.add(r))}function Ud(t,a,n){var r=0;a&&(r|=4),Ax(n,t,r,a)}var Wi="_reactListening"+Math.random().toString(36).slice(2);function Fd(t){if(!t[Wi]){t[Wi]=!0,jm.forEach(function(n){n!=="selectionchange"&&(Py.has(n)||Ud(n,!1,t),Ud(n,!0,t))});var a=t.nodeType===9?t:t.ownerDocument;a===null||a[Wi]||(a[Wi]=!0,Ud("selectionchange",!1,a))}}function Ax(t,a,n,r){switch(sg(a)){case 2:var c=jb;break;case 8:c=wb;break;default:c=su}n=c.bind(null,a,n,t),c=void 0,!oc||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(c=!0),r?c!==void 0?t.addEventListener(a,n,{capture:!0,passive:c}):t.addEventListener(a,n,!0):c!==void 0?t.addEventListener(a,n,{passive:c}):t.addEventListener(a,n,!1)}function Id(t,a,n,r,c){var m=r;if((a&1)===0&&(a&2)===0&&r!==null)e:for(;;){if(r===null)return;var v=r.tag;if(v===3||v===4){var E=r.stateNode.containerInfo;
vendor: 1,432 bytes, line 8
8if(E===c)break;if(v===4)for(v=r.return;v!==null;){var B=v.tag;if((B===3||B===4)&&v.stateNode.containerInfo===c)return;v=v.return}for(;E!==null;){if(v=In(E),v===null)return;if(B=v.tag,B===5||B===6||B===26||B===27){r=m=v;continue e}E=E.parentNode}}r=r.return}Lm(function(){var ee=m,ue=lc(n),fe=[];e:{var ae=ih.get(t);if(ae!==void 0){var re=ii,De=t;switch(t){case"keypress":if(ri(n)===0)break e;case"keydown":case"keyup":re=Bp;break;case"focusin":De="focus",re=mc;break;case"focusout":De="blur",re=mc;break;case"beforeblur":case"afterblur":re=mc;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":re=$m;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":re=Ap;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":re=Ip;break;case sh:case nh:case rh:re=Rp;break;case lh:re=Gp;break;case"scroll":case"scrollend":re=Sp;break;case"wheel":re=Pp;break;case"copy":case"cut":case"paste":re=Lp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":re=Hm;break;case"toggle":case"beforetoggle":re=Xp}var Ye=(a&4)!==0,vt=!Ye&&(t==="scroll"||t==="scrollend"),W=Ye?ae!==null?ae+"Capture":null:ae;Ye=[];for(var G=ee,J;G!==null;){var xe=G;
vendor: 6,554 bytes, lines 8-9
8if(J=xe.stateNode,xe=xe.tag,xe!==5&&xe!==26&&xe!==27||J===null||W===null||(xe=Ir(G,W),xe!=null&&Ye.push(wl(G,xe,J))),vt)break;G=G.return}0<Ye.length&&(ae=new re(ae,De,null,n,ue),fe.push({event:ae,listeners:Ye}))}}if((a&7)===0){e:{if(ae=t==="mouseover"||t==="pointerover",re=t==="mouseout"||t==="pointerout",ae&&n!==rc&&(De=n.relatedTarget||n.fromElement)&&(In(De)||De[Fn]))break e;if((re||ae)&&(ae=ue.window===ue?ue:(ae=ue.ownerDocument)?ae.defaultView||ae.parentWindow:window,re?(De=n.relatedTarget||n.toElement,re=ee,De=De?In(De):null,De!==null&&(vt=u(De),Ye=De.tag,De!==vt||Ye!==5&&Ye!==27&&Ye!==6)&&(De=null)):(re=null,De=ee),re!==De)){if(Ye=$m,xe="onMouseLeave",W="onMouseEnter",G="mouse",(t==="pointerout"||t==="pointerover")&&(Ye=Hm,xe="onPointerLeave",W="onPointerEnter",G="pointer"),vt=re==null?ae:Fr(re),J=De==null?ae:Fr(De),ae=new Ye(xe,G+"leave",re,n,ue),ae.target=vt,ae.relatedTarget=J,xe=null,In(ue)===ee&&(Ye=new Ye(W,G+"enter",De,n,ue),Ye.target=J,Ye.relatedTarget=vt,xe=Ye),vt=xe,re&&De)t:{for(Ye=Qy,W=re,G=De,J=0,xe=W;xe;xe=Ye(xe))J++;xe=0;for(var Ve=G;Ve;Ve=Ye(Ve))xe++;for(;0<J-xe;)W=Ye(W),J--;for(;0<xe-J;)G=Ye(G),xe--;for(;J--;){if(W===G||G!==null&&W===G.alternate){Ye=W;break t}W=Ye(W),G=Ye(G)}Ye=null}else Ye=null;re!==null&&Ex(fe,ae,re,Ye,!1),De!==null&&vt!==null&&Ex(fe,vt,De,Ye,!0)}}e:{if(ae=ee?Fr(ee):window,re=ae.nodeName&&ae.nodeName.toLowerCase(),re==="select"||re==="input"&&ae.type==="file")var ut=Ym;else if(Vm(ae))if(Pm)ut=ry;else{ut=sy;var Be=ay}else re=ae.nodeName,!re||re.toLowerCase()!=="input"||ae.type!=="checkbox"&&ae.type!=="radio"?ee&&nc(ee.elementType)&&(ut=Ym):ut=ny;if(ut&&(ut=ut(t,ee))){Gm(fe,ut,n,ue);break e}Be&&Be(t,ae,ee),t==="focusout"&&ee&&ae.type==="number"&&ee.memoizedProps.value!=null&&sc(ae,"number",ae.value)}switch(Be=ee?Fr(ee):window,t){case"focusin":(Vm(Be)||Be.contentEditable==="true")&&(Kn=Be,yc=ee,Zr=null);break;case"focusout":Zr=yc=Kn=null;break;case"mousedown":bc=!0;break;case"contextmenu":case"mouseup":case"dragend":bc=!1,th(fe,n,ue);break;case"selectionchange":if(iy)break;case"keydown":case"keyup":th(fe,n,ue)}var st;if(xc)e:{switch(t){case"compositionstart":var ot="onCompositionStart";break e;case"compositionend":ot="onCompositionEnd";break e;case"compositionupdate":ot="onCompositionUpdate";break e}ot=void 0}else Zn?Fm(t,n)&&(ot="onCompositionEnd"):t==="keydown"&&n.keyCode===229&&(ot="onCompositionStart");ot&&(qm&&n.locale!=="ko"&&(Zn||ot!=="onCompositionStart"?ot==="onCompositionEnd"&&Zn&&(st=Mm()):(Ds=ue,cc="value"in Ds?Ds.value:Ds.textContent,Zn=!0)),Be=Zi(ee,ot),0<Be.length&&(ot=new Dm(ot,t,null,n,ue),fe.push({event:ot,listeners:Be}),st?ot.data=st:(st=Im(n),st!==null&&(ot.data=st)))),(st=Zp?Kp(t,n):Jp(t,n))&&(ot=Zi(ee,"onBeforeInput"),0<ot.length&&(Be=new Dm("onBeforeInput","beforeinput",null,n,ue),fe.push({event:Be,listeners:ot}),Be.data=st)),Vy(fe,t,ee,n,ue)}Cx(fe,a)})}function wl(t,a,n){return{instance:t,listener:a,currentTarget:n}}function Zi(t,a){for(var n=a+"Capture",r=[];t!==null;){var c=t,m=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||m===null||(c=Ir(t,n),c!=null&&r.unshift(wl(t,c,m)),c=Ir(t,a),c!=null&&r.push(wl(t,c,m))),t.tag===3)return r;t=t.return}return[]}function Qy(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function Ex(t,a,n,r,c){for(var m=a._reactName,v=[];n!==null&&n!==r;){var E=n,B=E.alternate,ee=E.stateNode;if(E=E.tag,B!==null&&B===r)break;E!==5&&E!==26&&E!==27||ee===null||(B=ee,c?(ee=Ir(n,m),ee!=null&&v.unshift(wl(n,ee,B))):c||(ee=Ir(n,m),ee!=null&&v.push(wl(n,ee,B)))),n=n.return}v.length!==0&&t.push({event:a,listeners:v})}var Xy=/\r\n?/g,Wy=/\u0000|\uFFFD/g;function Tx(t){return(typeof t=="string"?t:""+t).replace(Xy,` 9`).replace(Wy,"")}function Rx(t,a){return a=Tx(a),Tx(t)===a}function bt(t,a,n,r,c,m){switch(n){case"children":typeof r=="string"?a==="body"||a==="textarea"&&r===""||Qn(t,r):(typeof r=="number"||typeof r=="bigint")&&a!=="body"&&Qn(t,""+r);break;case"className":ti(t,"class",r);break;case"tabIndex":ti(t,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":ti(t,n,r);break;case"style":Rm(t,r,m);break;case"data":if(a!=="object"){ti(t,"data",r);break}case"src":case"href":if(r===""&&(a!=="a"||n!=="href")){t.removeAttribute(n);break}if(r==null||typeof r=="function"||typeof r=="symbol"||typeof r=="boolean"){t.removeAttribute(n);break}r=si(""+r),t.setAttribute(n,r);break;case"action":case"formAction":if(typeof r=="function"){t.setAttribute(n,"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 m=="function"&&(n==="formAction"?(a!=="input"&&bt(t,a,"name",c.name,c,null),bt(t,a,"formEncType",c.formEncType,c,null),bt(t,a,"formMethod",c.formMethod,c,null),bt(t,a,"formTarget",c.formTarget,c,null)):(bt(t,a,"encType",c.encType,c,null),bt(t,a,"method",c.method,c,null),bt(t,a,"target",c.target,c,null)));if(r==null||typeof r=="symbol"||typeof r=="boolean"){t.removeAttribute(n);break}r=si(""+r),t.setAttribute(n,r);break;case"onClick":r!=null&&(t.onclick=us);break;case"onScroll":r!=null&<("scroll",t);break;case"onScrollEnd":r!=null&<("scrollend",t);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(o(61));if(n=r.__html,n!=null){if(c.children!=null)throw Error(o(60));t.innerHTML=n}}break;case"multiple":t.multiple=r&&typeof r!="function"&&typeof r!="symbol";break;case"muted":t.muted=r&&typeof r!="function"&&typeof r!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(r==null||typeof r=="function"||typeof r=="boolean"||typeof r=="symbol"){t.removeAttribute("xlink:href");break}n=si(""+r),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":r!=null&&typeof r!="function"&&typeof r!="symbol"?t.setAttribute(n,""+r):t.removeAttribute(n);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"playsInl
9ine":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":r&&typeof r!="function"&&typeof r!="symbol"?t.setAttribute(n,""):t.removeAttribute(n);break;case"capture":case"download":r===!0?t.setAttribute(n,""):r!==!1&&r!=null&&typeof r!="function"&&typeof r!="symbol"?t.setAttribute(n,r):t.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":r!=null&&typeof r!="function"&&typeof r!="symbol"&&!isNaN(r)&&1<=r?t.setAttribute(n,r):t.removeAttribute(n);break;case"rowSpan":case"start":r==null||typeof r=="function"||typeof r=="symbol"||isNaN(r)?t.removeAttribute(n):t.setAttribute(n,r);break;case"popover":lt("beforetoggle",t),lt("toggle",t),ei(t,"popover",r);break;case"xlinkActuate":ds(t,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":ds(t,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":ds(t,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":ds(t,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":ds(t,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":ds(t,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":ds(t,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":ds(t,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":ds(t,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":ei(t,"is",r);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=Np.get(n)||n,ei(t,n,r))}}function Vd(t,a,n,r,c,m){switch(n){case"style":Rm(t,r,m);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(o(61));if(n=r.__html,n!=null){if(c.children!=null)throw Error(o(60));t.innerHTML=n}}break;case"children":typeof r=="string"?Qn(t,r):(typeof r=="number"||typeof r=="bigint")&&Qn(t,""+r);break;case"onScroll":r!=null&<("scroll",t);break;case"onScrollEnd":r!=null&<("scrollend",t);break;case"onClick":r!=null&&(t.onclick=us);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!wm.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(c=n.endsWith("Capture"),a=n.slice(2,c?n.length-7:void 0),m=t[ra]||null,m=m!=null?m[n]:null,typeof m=="function"&&t.removeEventListener(a,m,c),typeof r=="function")){typeof m!="function"&&m!==null&&(n in t?t[n]=null:t.hasAttribute(n)&&t.removeAttribute(n)),t.addEventListener(a,r,c);break e}n in t?t[n]=r:r===!0?t.setAttribute(n,""):ei(t,n,r)}}}function Kt(t,a,n){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":lt("error",t),lt("load",t);var r=!1,c=!1,m;for(m in n)if(n.hasOwnProperty(m)){var v=n[m];if(v!=null)switch(m){case"src":r=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,a));default:bt(t,a,m,v,n,null)}}c&&bt(t,a,"srcSet",n.srcSet,n,null),r&&bt(t,a,"src",n.src,n,null);return;case"input":lt("invalid",t);var E=m=v=c=null,B=null,ee=null;for(r in n)if(n.hasOwnProperty(r)){var ue=n[r];if(ue!=null)switch(r){case"name":c=ue;break;case"type":v=ue;break;case"checked":B=ue;break;case"defaultChecked":ee=ue;break;case"value":m=ue;break;case"defaultValue":E=ue;break;case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(o(137,a));break;default:bt(t,a,r,ue,n,null)}}Cm(t,m,E,B,ee,v,c,!1);return;case"select":lt("invalid",t),r=v=m=null;for(c in n)if(n.hasOwnProperty(c)&&(E=n[c],E!=null))switch(c){case"value":m=E;break;case"defaultValue":v=E;break;case"multiple":r=E;default:bt(t,a,c,E,n,null)}a=m,n=v,t.multiple=!!r,a!=null?Pn(t,!!r,a,!1):n!=null&&Pn(t,!!r,n,!0);return;case"textarea":lt("invalid",t),m=c=r=null;for(v in n)if(n.hasOwnProperty(v)&&(E=n[v],E!=null))switch(v){case"value":r=E;break;case"defaultValue":c=E;break;case"children":m=E;break;case"dangerouslySetInnerHTML":if(E!=null)throw Error(o(91));break;default:bt(t,a,v,E,n,null)}Em(t,r,c,m);return;case"option":for(B in n)n.hasOwnProperty(B)&&(r=n[B],r!=null)&&(B==="selected"?t.selected=r&&typeof r!="function"&&typeof r!="symbol":bt(t,a,B,r,n,null));return;case"dialog":lt("beforetoggle",t),lt("toggle",t),lt("cancel",t),lt("close",t);break;case"iframe":case"object":lt("load",t);break;case"video":case"audio":for(r=0;r<jl.length;r++)lt(jl[r],t);break;case"image":lt("error",t),lt("load",t);break;case"details":lt("toggle",t);break;case"embed":case"source":case"link":lt("error",t),lt("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ee in n)if(n.hasOwnProperty(ee)&&(r=n[ee],r!=null))switch(ee){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,a));default:bt(t,a,ee,r,n,null)}return;default:if(nc(a)){for(ue in n)n.hasOwnProperty(ue)&&(r=n[ue],r!==void 0&&Vd(t,a,ue,r,n,void 0));return}}for(E in n)n.hasOwnProperty(E)&&(r=n[E],r!=null&&bt(t,a,E,r,n,null))}function Zy(t,a,n,r){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,m=null,v=null,E=null,B=null,ee=null,ue=null;for(re in n){var fe=n[re];if(n.hasOwnProperty(re)&&fe!=null)switch(re){case"checked":break;case"value":break;case"defaultValue":B=fe;default:r.hasOwnProperty(re)||bt(t,a,re,null,r,fe)}}for(var ae in r){var re=r[ae];if(fe=n[ae],r.hasOwnProperty(ae)&&(re!=null||fe!=null))switch(ae){case"type":m=re;break;case"name":c=re;break;case"checked":ee=re;break;case"defaultChecked":ue=re;break;case"value":v=re;break;case"defaultValue":E=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(o(137,a));break;default:re!==fe&&bt(t,a,ae,re,r,fe)}}ac(t,v,E,B,ee,ue,m,c);return;case"select":re=v=E=ae=null;for(m in n)if(B=n[m],n.hasOwnProperty(m)&&B!=null)switch(m){case"value":break;case"multiple":re=B;default:r.hasOwnProperty(m)||bt(t,a,m,null,r,B)}for(c in r)if(m=r[c],B=n[c],r.hasOwnProperty(c)&&(m!=null||B!=null))switch(c){case"value":ae=m;break;case"defaultValue":E=m;break;case"multiple":v=m;default:m!==B&&bt(t,a,c,m,r,B)}a=E,n=v,r=re,ae!=null?Pn(t,!!n,ae,!1):!!r!=!!n&&(a!=null?Pn(t,!!n,a,!0):Pn(t,!!n,n?[]:"",!1));return;case"textarea":re=ae=null;for(E in n)if(c=n[E],n.hasOwnProperty(E)&&c!=null&&!r.hasOwnProperty(E))switch(E){case"value":break;case"children":break;default:bt(t,a,E,null,r,c)}for(v in r)if(c=r[v],m=n[v],r.hasOwnProperty(v)&&(c!=null||m!=null))switch(v){case"value":ae=c;break;case"defaultValue":re=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==m&&bt(t,a,v,c,r,m)}Am(t,ae,re);return;case"option":for(var De in n)ae=n[De],n.hasOwnProperty(De)&&ae!=null&&!r.hasOwnProperty(De)&&(De==="selected"?t.selected=!1:bt(t,a,De,null,r,ae));for(B in r)ae=r[B],re=n[B],r.hasOwnProperty(B)&&ae!==re&&(ae!=null||re!=null)&&(B==="selected"?t.selected=ae&&typeof ae!="function"&&typeof ae!="symbol":bt(t,a,B,ae,r,re));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 Ye in n)ae=n[Ye],n.hasOwnProperty(Ye)&&ae!=null&&!r.hasOwnProperty(Ye)&&bt(t,a,Ye,null,r,ae);for(ee in r)if(ae=r[ee],re=n[ee],r.hasOwnProperty(ee)&&ae!==re&&(ae!=null||re!=null))switch(ee){case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(o(137,a));break;default:bt(t,a,ee,ae,r,re)}return;default:if(nc(a)){for(var vt in n)ae=n[vt],n.hasOwnProperty(vt)&&ae!==void 0&&!r.hasOwnProperty(vt)&&Vd(t,a,vt,void 0,r,ae);for(ue in r)ae=r[ue],re=n[ue],!r.hasOwnProperty(ue)||ae===re||ae===void 0&&re===void 0||Vd(t,a,ue,ae,r,re);return}}for(var W in n)ae=n[W],n.hasOwnProperty(W)&&ae!=null&&!r.hasOwnProperty(W)&&bt(t,a,W,null,r,ae);for(fe in r)ae=r[fe],re=n[fe],!r.hasOwnProperty(fe)||ae===re||ae==null&&re==null||bt(t,a,fe,ae,r,re)}function zx(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Ky(){if(typeof performance.getEntriesByType=="function"){for(var t=0,a=0,n=performance.getEntriesByType("resource"),r=0;r<n.length;r++){var c=n[r],m=c.transferSize,v=c.initiatorType,E=c.duration;if(m&&E&&zx(v)){for(v=0,E=c.responseEnd,r+=1;r<n.length;r++){var B=n[r],ee=B.startTime;if(ee>E)break;var ue=B.transferSize,fe=B.initiatorType;ue&&zx(fe)&&(B=B.responseEnd,v+=ue*(B<E?1:(E-ee)/(B-ee)))}if(--r,a+=8*(m+v)/(c.duration/1e3),t++,10<t)break}}if(0<t)return a/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var Gd=null,Yd=null;function Ki(t){return t.nodeType===9?t:t.ownerDocument}function Lx(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Mx(t,a){if(t===0)switch(a){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&a==="foreignObject"?0:t}function Pd(t,a){return t==="textarea"||t==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.children=="bigint"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var Qd=null;function Jy(){var t=window.event;return t&&t.type==="popstate"?t===Qd?!1:(Qd=t,!0):(Qd=null,!1)}var Ox=typeof setTimeout=="function"?setTimeout:void 0,eb=typeof clearTimeout=="function"?clearTimeout:void 0,$x=typeof Promise=="function"?Promise:void 0,tb=typeof queueMicrotask=="function"?queueMicrotask:typeof $x<"u"?function(t){return $x.resolve(null).then(t).cat
vendor: 11,374 bytes, line 9
9ch(ab)}:Ox;function ab(t){setTimeout(function(){throw t})}function en(t){return t==="head"}function Dx(t,a){var n=a,r=0;do{var c=n.nextSibling;if(t.removeChild(n),c&&c.nodeType===8)if(n=c.data,n==="/$"||n==="/&"){if(r===0){t.removeChild(c),_r(a);return}r--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")r++;else if(n==="html")kl(t.ownerDocument.documentElement);else if(n==="head"){n=t.ownerDocument.head,kl(n);for(var m=n.firstChild;m;){var v=m.nextSibling,E=m.nodeName;m[Ur]||E==="SCRIPT"||E==="STYLE"||E==="LINK"&&m.rel.toLowerCase()==="stylesheet"||n.removeChild(m),m=v}}else n==="body"&&kl(t.ownerDocument.body);n=c}while(n);_r(a)}function Hx(t,a){var n=t;t=0;do{var r=n.nextSibling;if(n.nodeType===1?a?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",n.getAttribute("style")===""&&n.removeAttribute("style")):n.nodeType===3&&(a?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),r&&r.nodeType===8)if(n=r.data,n==="/$"){if(t===0)break;t--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||t++;n=r}while(n)}function Xd(t){var a=t.firstChild;for(a&&a.nodeType===10&&(a=a.nextSibling);a;){var n=a;switch(a=a.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":Xd(n),ec(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}t.removeChild(n)}}function sb(t,a,n,r){for(;t.nodeType===1;){var c=n;if(t.nodeName.toLowerCase()!==a.toLowerCase()){if(!r&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(r){if(!t[Ur])switch(a){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(m=t.getAttribute("rel"),m==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(m!==c.rel||t.getAttribute("href")!==(c.href==null||c.href===""?null:c.href)||t.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin)||t.getAttribute("title")!==(c.title==null?null:c.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(m=t.getAttribute("src"),(m!==(c.src==null?null:c.src)||t.getAttribute("type")!==(c.type==null?null:c.type)||t.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&m&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(a==="input"&&t.type==="hidden"){var m=c.name==null?null:""+c.name;if(c.type==="hidden"&&t.getAttribute("name")===m)return t}else return t;if(t=Oa(t.nextSibling),t===null)break}return null}function nb(t,a,n){if(a==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!n||(t=Oa(t.nextSibling),t===null))return null;return t}function qx(t,a){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!a||(t=Oa(t.nextSibling),t===null))return null;return t}function Wd(t){return t.data==="$?"||t.data==="$~"}function Zd(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function rb(t,a){var n=t.ownerDocument;if(t.data==="$~")t._reactRetry=a;else if(t.data!=="$?"||n.readyState!=="loading")a();else{var r=function(){a(),n.removeEventListener("DOMContentLoaded",r)};n.addEventListener("DOMContentLoaded",r),t._reactRetry=r}}function Oa(t){for(;t!=null;t=t.nextSibling){var a=t.nodeType;if(a===1||a===3)break;if(a===8){if(a=t.data,a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"||a==="F!"||a==="F")break;if(a==="/$"||a==="/&")return null}}return t}var Kd=null;function Bx(t){t=t.nextSibling;for(var a=0;t;){if(t.nodeType===8){var n=t.data;if(n==="/$"||n==="/&"){if(a===0)return Oa(t.nextSibling);a--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||a++}t=t.nextSibling}return null}function Ux(t){t=t.previousSibling;for(var a=0;t;){if(t.nodeType===8){var n=t.data;if(n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"){if(a===0)return t;a--}else n!=="/$"&&n!=="/&"||a++}t=t.previousSibling}return null}function Fx(t,a,n){switch(a=Ki(n),t){case"html":if(t=a.documentElement,!t)throw Error(o(452));return t;case"head":if(t=a.head,!t)throw Error(o(453));return t;case"body":if(t=a.body,!t)throw Error(o(454));return t;default:throw Error(o(451))}}function kl(t){for(var a=t.attributes;a.length;)t.removeAttributeNode(a[0]);ec(t)}var $a=new Map,Ix=new Set;function Ji(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var Cs=Y.d;Y.d={f:lb,r:ib,D:ob,C:cb,L:db,m:ub,X:hb,S:mb,M:xb};function lb(){var t=Cs.f(),a=Vi();return t||a}function ib(t){var a=Vn(t);a!==null&&a.tag===5&&a.type==="form"?l0(a):Cs.r(t)}var wr=typeof document>"u"?null:document;function Vx(t,a,n){var r=wr;if(r&&typeof a=="string"&&a){var c=Aa(a);c='link[rel="'+t+'"][href="'+c+'"]',typeof n=="string"&&(c+='[crossorigin="'+n+'"]'),Ix.has(c)||(Ix.add(c),t={rel:t,crossOrigin:n,href:a},r.querySelector(c)===null&&(a=r.createElement("link"),Kt(a,"link",t),Yt(a),r.head.appendChild(a)))}}function ob(t){Cs.D(t),Vx("dns-prefetch",t,null)}function cb(t,a){Cs.C(t,a),Vx("preconnect",t,a)}function db(t,a,n){Cs.L(t,a,n);var r=wr;if(r&&t&&a){var c='link[rel="preload"][as="'+Aa(a)+'"]';a==="image"&&n&&n.imageSrcSet?(c+='[imagesrcset="'+Aa(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(c+='[imagesizes="'+Aa(n.imageSizes)+'"]')):c+='[href="'+Aa(t)+'"]';var m=c;switch(a){case"style":m=kr(t);break;case"script":m=Nr(t)}$a.has(m)||(t=f({rel:"preload",href:a==="image"&&n&&n.imageSrcSet?void 0:t,as:a},n),$a.set(m,t),r.querySelector(c)!==null||a==="style"&&r.querySelector(Nl(m))||a==="script"&&r.querySelector(_l(m))||(a=r.createElement("link"),Kt(a,"link",t),Yt(a),r.head.appendChild(a)))}}function ub(t,a){Cs.m(t,a);var n=wr;if(n&&t){var r=a&&typeof a.as=="string"?a.as:"script",c='link[rel="modulepreload"][as="'+Aa(r)+'"][href="'+Aa(t)+'"]',m=c;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Nr(t)}if(!$a.has(m)&&(t=f({rel:"modulepreload",href:t},a),$a.set(m,t),n.querySelector(c)===null)){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(_l(m)))return}r=n.createElement("link"),Kt(r,"link",t),Yt(r),n.head.appendChild(r)}}}function mb(t,a,n){Cs.S(t,a,n);var r=wr;if(r&&t){var c=Gn(r).hoistableStyles,m=kr(t);a=a||"default";var v=c.get(m);if(!v){var E={loading:0,preload:null};if(v=r.querySelector(Nl(m)))E.loading=5;else{t=f({rel:"stylesheet",href:t,"data-precedence":a},n),(n=$a.get(m))&&Jd(t,n);var B=v=r.createElement("link");Yt(B),Kt(B,"link",t),B._p=new Promise(function(ee,ue){B.onload=ee,B.onerror=ue}),B.addEventListener("load",function(){E.loading|=1}),B.addEventListener("error",function(){E.loading|=2}),E.loading|=4,eo(v,a,r)}v={type:"stylesheet",instance:v,count:1,state:E},c.set(m,v)}}}function hb(t,a){Cs.X(t,a);var n=wr;if(n&&t){var r=Gn(n).hoistableScripts,c=Nr(t),m=r.get(c);m||(m=n.querySelector(_l(c)),m||(t=f({src:t,async:!0},a),(a=$a.get(c))&&eu(t,a),m=n.createElement("script"),Yt(m),Kt(m,"link",t),n.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},r.set(c,m))}}function xb(t,a){Cs.M(t,a);var n=wr;if(n&&t){var r=Gn(n).hoistableScripts,c=Nr(t),m=r.get(c);m||(m=n.querySelector(_l(c)),m||(t=f({src:t,async:!0,type:"module"},a),(a=$a.get(c))&&eu(t,a),m=n.createElement("script"),Yt(m),Kt(m,"link",t),n.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},r.set(c,m))}}function Gx(t,a,n,r){var c=(c=V.current)?Ji(c):null;if(!c)throw Error(o(446));switch(t){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(a=kr(n.href),n=Gn(c).hoistableStyles,r=n.get(a),r||(r={type:"style",instance:null,count:0,state:null},n.set(a,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){t=kr(n.href);var m=Gn(c).hoistableStyles,v=m.get(t);if(v||(c=c.ownerDocument||c,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(t,v),(m=c.querySelector(Nl(t)))&&!m._p&&(v.instance=m,v.state.loading=5),$a.has(t)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},$a.set(t,n),m||gb(c,t,n,v.state))),a&&r===null)throw Error(o(528,""));return v}if(a&&r!==null)throw Error(o(529,""));return null;case"script":return a=n.async,n=n.src,typeof n=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=Nr(n),n=Gn(c).hoistableScripts,r=n.get(a),r||(r={type:"script",instance:null,count:0,state:null},n.set(a,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,t))}}function kr(t){return'href="'+Aa(t)+'"'}function Nl(t){return'link[rel="stylesheet"]['+t+"]"}function Yx(t){return f({},t,{"data-precedence":t.precedence,precedence:null})}function gb(t,a,n,r){t.querySelector('link[rel="preload"][as="style"]['+a+"]")?r.loading=1:(a=t.createElement("link"),r.preload=a,a.addEventListener("load",function(){return r.loading|=1}),a.addEventListener("error",function(){return r.loading|=2}),Kt(a,"link",n),Yt(a),t.head.appendChild(a))}function Nr(t){return'[src="'+Aa(t)+'"]'}function _l(t){return"script[async]"+t}function Px(t,a,n){if(a.count++,a.instance===null)switch(a.type){case"style":var r=t.querySelector('style[data-href~="'+Aa(n.href)+'"]');if(r)return a.instance=r,Yt(r),r;var c=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(t.ownerDocument||t).createElement("style"),Yt(r),Kt(r,"style",c),eo(r,n.precedence,t),a.instance=r;case"stylesheet":c=kr(n.href);var m=t.querySelector(Nl(c));if(m)return a.state.loading|=4,a.instance=m,Yt(m),m;r=Yx(n),(c=$a.get(c))&&Jd(r,c),m=(t.ownerDocument||t).createElement("link"),Yt(m);var v=m;return v._p=new Promise(function(E,B){v.onload=E,v.onerror=B}),Kt(m,"link",r),a.state.loading|=4,eo(m,n.precedence,t),a.instance=m;case"script":return m=Nr(n.src),(c=t.querySelector(_l(m)))?(a.instance=c,Yt(c),c):(r=n,(c=$a.get(m))&&(r=f({},n),eu(r,c)),t=t.ownerDocument||t,c=t.createElement("script"),Yt(c),Kt(c,"link",r),t.head.appendChild(c),a.instance=c);case"void":return null;default:throw Error(o(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(r=a.instance,a.state.loading|=4,eo(r,n.precedence,t));return a.instance}function eo(t,a,n){for(var r=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=r.length?r[r.length-1]:null,m=c,v=0;v<r.length;v++){var E=r[v];if(E.dataset.precedence===a)m=E;else if(m!==c)break}m?m.parentNode.insertBefore(t,m.nextSibling):(a=n.nodeType===9?n.head:n,a.insertBefore(t,a.firstChild))}function Jd(t,a){t.crossOrigin==null&&(t.crossOrigin=a.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=a.referrerPolicy),t.title==null&&(t.title=a.title)}function eu(t,a){t.crossOrigin==null&&(t.crossOrigin=a.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=a.referrerPolicy),t.integrity==null&&(t.integrity=a.integrity)}var to=null;function Qx(t,a,n){if(to===null){var r=new Map,c=to=new Map;c.set(n,r)}else c=to,r=c.get(n),r||(r=new Map,c.set(n,r));if(r.has(t))return r;for(r.set(t,null),n=n.getElementsByTagName(t),c=0;c<n.length;c++){var m=n[c];if(!(m[Ur]||m[Qt]||t==="link"&&m.getAttribute("rel")==="stylesheet")&&m.namespaceURI!=="http://www.w3.org/2000/svg"){var v=m.getAttribute(a)||"";v=t+v;var E=r.get(v);
vendor: 5,941 bytes, line 9
9E?E.push(m):r.set(v,[m])}}return r}function Xx(t,a,n){t=t.ownerDocument||t,t.head.insertBefore(n,a==="title"?t.querySelector("head > title"):null)}function fb(t,a,n){if(n===1||a.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;return a.rel==="stylesheet"?(t=a.disabled,typeof a.precedence=="string"&&t==null):!0;case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function Wx(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function pb(t,a,n,r){if(n.type==="stylesheet"&&(typeof r.media!="string"||matchMedia(r.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var c=kr(r.href),m=a.querySelector(Nl(c));if(m){a=m._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(t.count++,t=ao.bind(t),a.then(t,t)),n.state.loading|=4,n.instance=m,Yt(m);return}m=a.ownerDocument||a,r=Yx(r),(c=$a.get(c))&&Jd(r,c),m=m.createElement("link"),Yt(m);var v=m;v._p=new Promise(function(E,B){v.onload=E,v.onerror=B}),Kt(m,"link",r),n.instance=m}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(n,a),(a=n.state.preload)&&(n.state.loading&3)===0&&(t.count++,n=ao.bind(t),a.addEventListener("load",n),a.addEventListener("error",n))}}var tu=0;function yb(t,a){return t.stylesheets&&t.count===0&&no(t,t.stylesheets),0<t.count||0<t.imgCount?function(n){var r=setTimeout(function(){if(t.stylesheets&&no(t,t.stylesheets),t.unsuspend){var m=t.unsuspend;t.unsuspend=null,m()}},6e4+a);0<t.imgBytes&&tu===0&&(tu=62500*Ky());var c=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&no(t,t.stylesheets),t.unsuspend)){var m=t.unsuspend;t.unsuspend=null,m()}},(t.imgBytes>tu?50:800)+a);return t.unsuspend=n,function(){t.unsuspend=null,clearTimeout(r),clearTimeout(c)}}:null}function ao(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)no(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var so=null;function no(t,a){t.stylesheets=null,t.unsuspend!==null&&(t.count++,so=new Map,a.forEach(bb,t),so=null,ao.call(t))}function bb(t,a){if(!(a.state.loading&4)){var n=so.get(t);if(n)var r=n.get(null);else{n=new Map,so.set(t,n);for(var c=t.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m<c.length;m++){var v=c[m];(v.nodeName==="LINK"||v.getAttribute("media")!=="not all")&&(n.set(v.dataset.precedence,v),r=v)}r&&n.set(null,r)}c=a.instance,v=c.getAttribute("data-precedence"),m=n.get(v)||r,m===r&&n.set(null,c),n.set(v,c),this.count++,r=ao.bind(this),c.addEventListener("load",r),c.addEventListener("error",r),m?m.parentNode.insertBefore(c,m.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(c,t.firstChild)),a.state.loading|=4}}var Sl={$$typeof:z,Provider:null,Consumer:null,_currentValue:oe,_currentValue2:oe,_threadCount:0};function vb(t,a,n,r,c,m,v,E,B){this.tag=1,this.containerInfo=t,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=cs(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=cs(0),this.hiddenUpdates=cs(null),this.identifierPrefix=r,this.onUncaughtError=c,this.onCaughtError=m,this.onRecoverableError=v,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=B,this.incompleteTransitions=new Map}function Zx(t,a,n,r,c,m,v,E,B,ee,ue,fe){return t=new vb(t,a,n,v,B,ee,ue,fe,E),a=1,m===!0&&(a|=24),m=fa(3,null,null,a),t.current=m,m.stateNode=t,a=Mc(),a.refCount++,t.pooledCache=a,a.refCount++,m.memoizedState={element:r,isDehydrated:n,cache:a},Hc(m),t}function Kx(t){return t?(t=tr,t):tr}function Jx(t,a,n,r,c,m){c=Kx(c),r.context===null?r.context=c:r.pendingContext=c,r=Is(a),r.payload={element:n},m=m===void 0?null:m,m!==null&&(r.callback=m),n=Vs(t,r,a),n!==null&&(ua(n,t,a),nl(n,t,a))}function eg(t,a){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var n=t.retryLane;t.retryLane=n!==0&&n<a?n:a}}function au(t,a){eg(t,a),(t=t.alternate)&&eg(t,a)}function tg(t){if(t.tag===13||t.tag===31){var a=yn(t,67108864);a!==null&&ua(a,t,67108864),au(t,67108864)}}function ag(t){if(t.tag===13||t.tag===31){var a=ja();a=Zo(a);var n=yn(t,a);n!==null&&ua(n,t,a),au(t,a)}}var ro=!0;function jb(t,a,n,r){var c=M.T;M.T=null;var m=Y.p;try{Y.p=2,su(t,a,n,r)}finally{Y.p=m,M.T=c}}function wb(t,a,n,r){var c=M.T;M.T=null;var m=Y.p;try{Y.p=8,su(t,a,n,r)}finally{Y.p=m,M.T=c}}function su(t,a,n,r){if(ro){var c=nu(r);if(c===null)Id(t,a,r,lo,n),ng(t,r);else if(Nb(c,t,a,n,r))r.stopPropagation();else if(ng(t,r),a&4&&-1<kb.indexOf(t)){for(;c!==null;){var m=Vn(c);if(m!==null)switch(m.tag){case 3:if(m=m.stateNode,m.current.memoizedState.isDehydrated){var v=Re(m.pendingLanes);if(v!==0){var E=m;for(E.pendingLanes|=2,E.entangledLanes|=2;v;){var B=1<<31-aa(v);E.entanglements[1]|=B,v&=~B}ns(m),(xt&6)===0&&(Fi=He()+500,vl(0))}}break;case 31:case 13:E=yn(m,2),E!==null&&ua(E,m,2),Vi(),au(m,2)}if(m=nu(r),m===null&&Id(t,a,r,lo,n),m===c)break;c=m}c!==null&&r.stopPropagation()}else Id(t,a,r,null,n)}}function nu(t){return t=lc(t),ru(t)}var lo=null;function ru(t){if(lo=null,t=In(t),t!==null){var a=u(t);if(a===null)t=null;else{var n=a.tag;if(n===13){if(t=x(a),t!==null)return t;t=null}else if(n===31){if(t=y(a),t!==null)return t;t=null}else if(n===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;t=null}else a!==t&&(t=null)}}return lo=t,null}function sg(t){switch(t){case"beforetoggle":case"cancel":case"click":case"close"
vendor: 4,141 bytes, line 9
9: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(It()){case Ls:return 2;case Ms:return 8;case un:case qr:return 32;case Zl:return 268435456;default:return 32}default:return 32}}var lu=!1,tn=null,an=null,sn=null,Cl=new Map,Al=new Map,nn=[],kb="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 ng(t,a){switch(t){case"focusin":case"focusout":tn=null;break;case"dragenter":case"dragleave":an=null;break;case"mouseover":case"mouseout":sn=null;break;case"pointerover":case"pointerout":Cl.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Al.delete(a.pointerId)}}function El(t,a,n,r,c,m){return t===null||t.nativeEvent!==m?(t={blockedOn:a,domEventName:n,eventSystemFlags:r,nativeEvent:m,targetContainers:[c]},a!==null&&(a=Vn(a),a!==null&&tg(a)),t):(t.eventSystemFlags|=r,a=t.targetContainers,c!==null&&a.indexOf(c)===-1&&a.push(c),t)}function Nb(t,a,n,r,c){switch(a){case"focusin":return tn=El(tn,t,a,n,r,c),!0;case"dragenter":return an=El(an,t,a,n,r,c),!0;case"mouseover":return sn=El(sn,t,a,n,r,c),!0;case"pointerover":var m=c.pointerId;return Cl.set(m,El(Cl.get(m)||null,t,a,n,r,c)),!0;case"gotpointercapture":return m=c.pointerId,Al.set(m,El(Al.get(m)||null,t,a,n,r,c)),!0}return!1}function rg(t){var a=In(t.target);if(a!==null){var n=u(a);if(n!==null){if(a=n.tag,a===13){if(a=x(n),a!==null){t.blockedOn=a,bm(t.priority,function(){ag(n)});return}}else if(a===31){if(a=y(n),a!==null){t.blockedOn=a,bm(t.priority,function(){ag(n)});return}}else if(a===3&&n.stateNode.current.memoizedState.isDehydrated){t.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}t.blockedOn=null}function io(t){if(t.blockedOn!==null)return!1;for(var a=t.targetContainers;0<a.length;){var n=nu(t.nativeEvent);if(n===null){n=t.nativeEvent;var r=new n.constructor(n.type,n);rc=r,n.target.dispatchEvent(r),rc=null}else return a=Vn(n),a!==null&&tg(a),t.blockedOn=n,!1;a.shift()}return!0}function lg(t,a,n){io(t)&&n.delete(a)}function _b(){lu=!1,tn!==null&&io(tn)&&(tn=null),an!==null&&io(an)&&(an=null),sn!==null&&io(sn)&&(sn=null),Cl.forEach(lg),Al.forEach(lg)}function oo(t,a){t.blockedOn===a&&(t.blockedOn=null,lu||(lu=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,_b)))}var co=null;function ig(t){co!==t&&(co=t,s.unstable_scheduleCallback(s.unstable_NormalPriority,function(){co===t&&(co=null);for(var a=0;a<t.length;a+=3){var n=t[a],r=t[a+1],c=t[a+2];if(typeof r!="function"){if(ru(r||n)===null)continue;break}var m=Vn(n);m!==null&&(t.splice(a,3),a-=3,nd(m,{pending:!0,data:c,method:n.method,action:r},r,c))}}))}function _r(t){function a(B){return oo(B,t)}tn!==null&&oo(tn,t),an!==null&&oo(an,t),sn!==null&&oo(sn,t),Cl.forEach(a),Al.forEach(a);for(var n=0;n<nn.length;n++){var r=nn[n];r.blockedOn===t&&(r.blockedOn=null)}for(;0<nn.length&&(n=nn[0],n.blockedOn===null);)rg(n),n.blockedOn===null&&nn.shift();if(n=(t.ownerDocument||t).$$reactFormReplay,n!=null)for(r=0;r<n.length;
9r+=3){var c=n[r],m=n[r+1],v=c[ra]||null;if(typeof m=="function")v||ig(n);else if(v){var E=null;if(m&&m.hasAttribute("formAction")){if(c=m,v=m[ra]||null)E=v.formAction;else if(ru(c)!==null)continue}else E=v.action;typeof E=="function"?n[r+1]=E:(n.splice(r,3),r-=3),ig(n)}}}function og(){function t(m){m.canIntercept&&m.info==="react-transition"&&m.intercept({handler:function(){return new Promise(function(v){return c=v})},focusReset:"manual",scroll:"manual"})}function a(){c!==null&&(c(),c=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var m=navigation.currentEntry;m&&m.url!=null&&navigation.navigate(m.url,{state:m.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var r=!1,c=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(n,100),function(){r=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),c!==null&&(c(),c=null)}}}function iu(t){this._internalRoot=t}uo.prototype.render=iu.prototype.render=function(t){var a=this._internalRoot;if(a===null)throw Error(o(409));var n=a.current,r=ja();Jx(n,r,t,a,null,null)},uo.prototype.unmount=iu.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var a=t.containerInfo;Jx(t.current,2,null,t,null,null),Vi(),a[Fn]=null}};function uo(t){this._internalRoot=t}uo.prototype.unstable_scheduleHydration=function(t){if(t){var a=ym();t={blockedOn:null,target:t,priority:a};for(var n=0;n<nn.length&&a!==0&&a<nn[n].priority;n++);nn.splice(n,0,t),n===0&&rg(t)}};var cg=l.version;if(cg!=="19.2.4")throw Error(o(527,cg,"19.2.4"));Y.findDOMNode=function(t){var a=t._reactInternals;if(a===void 0)throw typeof t.render=="function"?Error(o(188)):(t=Object.keys(t).join(","),Error(o(268,t)));return t=g(a),t=t!==null?b(t):null,t=t===null?null:t.stateNode,t};var Sb={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:M,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var mo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!mo.isDisabled&&mo.supportsFiber)try{Os=mo.inject(Sb),Jt=mo}catch{}}return Rl.createRoot=function(t,a){if(!d(t))throw Error(o(299));var n=!1,r="",c=f0,m=p0,v=y0;return a!=null&&(a.unstable_strictMode===!0&&(n=!0),a.identifierPrefix!==void 0&&(r=a.identifierPrefix),a.onUncaughtError!==void 0&&(c=a.onUncaughtError),a.onCaughtError!==void 0&&(m=a.onCaughtError),a.onRecoverableError!==void 0&&(v=a.onRecoverableError)),a=Zx(t,1,!1,null,null,n,r,null,c,m,v,og),t[Fn]=a.current,Fd(t),new iu(a)},Rl.hydrateRoot=function(t,a,n){if(!d(t))throw Error(o(299));var r=!1,c="",m=f0,v=p0,E=y0,B=null;return n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(c=n.identifierPrefix),n.onUncaughtError!==void 0&&(m=n.onUncaughtError),n.onCaughtError!==void 0&&(v=n.onCaughtError),n.onRecoverableError!==void 0&&(E=n.onRecoverableError),n.formState!==void 0&&(B=n.formState)),a=Zx(t,1,!0,a,n??null,r,c,B,m,v,E,og),a.context=Kx(null),n=a.current,r=ja(),r=Zo(r),c=Is(r),c.callback=null,Vs(n,c,r),n=r,a.current.lanes=n,Pe(a,n),ns(a),t[Fn]=a.current,Fd(t),new uo(a)},Rl.version="19.2.4",Rl}var bg;function $b(){if(bg)return du.exports;bg=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(l){console.error(l)}}return s(),du.exports=Ob(),du.exports}var Db=$b();const xf="https://api.fantize.com/api";function gf(){return localStorage.getItem("fantize_token")}function ff(s){localStorage.setItem("fantize_token",s)}function vg(){localStorage.removeItem("fantize_token")}async function ce(s,l={}){const i=gf(),o={"Content-Type":"application/json",...l.headers||{}};i&&(o.Authorization=`Bearer ${i}`);const d=Date.now(),u=l.method||"GET";console.log(`ð¡ [API] ${u} ${s}`);try{const x=await fetch(`${xf}${s}`,{...l,headers:o}),y=await x.json(),p=Date.now()-d;if(!x.ok){const g=y.error||`Request failed (${x.status})`,b=y;console.error(`â [API] ${u} ${s} failed:`,g,"status:",x.status,"duration:",p+"ms"),typeof window<"u"&&window.fantizeAnalytics&&window.fantizeAnalytics.trackApiRequest(s,u,!1,p,g);const f=new Error(g);throw f.status=x.status,f.payload=b,f}return console.log(`â
[API] ${u} ${s} success, duration:`,p+"ms"),typeof window<"u"&&window.fantizeAnalytics&&window.fantizeAnalytics.trackApiRequest(s,u,!0,p),y}catch(x){const y=Date.now()-d;throw x instanceof Error&&!x.message.includes("Request failed")&&(console.error(`â [API] ${u} ${s} network error:`,x.message,"duration:",y+"ms"),typeof window<"u"&&window.fantizeAnalytics&&window.fantizeAnalytics.trackApiRequest(s,u,!1,y,x.message)),x}}async function Ku(s,l){const i=gf(),o={};i&&(o.Authorization=`Bearer ${i}`);const d=Date.now();console.log(`ð¤ [API] POST ${s} (upload)`);try{const u=await fetch(`${xf}${s}`,{method:"POST",headers:o,body:l}),x=await u.json(),y=Date.now()-d;if(!u.ok){const p=x.error||`Upload failed (${u.status})`;throw console.error(`â [API] POST ${s} (upload) failed:`,p,"status:",u.status,"duration:",y+"ms"),typeof window<"u"&&window.fantizeAnalytics&&window.fantizeAnalytics.trackApiRequest(s,"POST",!1,y,p),new Error(p)}return console.log(`â
[API] POST ${s} (upload) success, duration:`,y+"ms"),typeof window<"u"&&window.fantizeAnalytics&&window.fantizeAnalytics.trackApiRequest(s,"POST",!0,y),x}catch(u){const x=Date.now()-d;throw u instanceof Error&&!u.message.includes("Upload failed")&&(console.error(`â [API] POST ${s} (upload) network error:`,u.message,"duration:",x+"ms"),typeof window<"u"&&window.fantizeAnalytics&&window.fantizeAnalytics.trackApiRequest(s,"POST",!1,x,u.message)),u}}const Da={login:(s,l)=>ce("/auth/login",{method:"POST",body:JSON.stringify({email:s,password:l})}),register:(s,l,i,o)=>ce("/auth/register",{method:"POST",body:JSON.stringify({name:s,email:l,password:i,company_name:o})}),me:()=>ce("/auth/me"),listUsers:()=>ce("/users"),inviteUser:s=>ce("/users",{method:"POST",body:JSON.stringify(s)}),updateUser:(s,l)=>ce(`/users/${s}`,{method:"PUT",body:JSON.stringify(l)}),resendInvite:s=>ce(`/users/${s}/resend-invite`,{method:"POST"}),deleteUser:s=>ce(`/users/${s}`,{method:"DELETE"}),inviteInfo:s=>ce(`/users/invite/${s}`),acceptInvite:(s,l)=>ce("/users/accept-invite",{method:"POST",body:JSON.stringify({token:s,password:l})}),updateUiState:s=>ce("/account/ui-state",{method:"PATCH",body:JSON.stringify(s)})},pf={get:()=>ce("/dashboard")},Ba={list:s=>{const l=new URLSearchParams;return s?.limit&&l.set("limit",String(s.limit)),s?.offset&&l.set("offset",String(s.offset)),s?.search&&l.set("search",s.search),s?.list_id&&l.set("list_id",s.list_id),ce(`/contacts?${l}`)},create:s=>ce("/contacts",{method:"POST",body:JSON.stringify(s)}),import:s=>{const l=new FormData;return l.append("file",s),Ku("/contacts/import",l)},delete:s=>ce(`/contacts/${s}`,{method:"DELETE"})},Hb={list:s=>{const l=new URLSearchParams;return s?.contact_id&&l.set("contact_id",s.contact_id),s?.fan_level&&l.set("fan_level",s.fan_level),ce(`/fan-profiles?${l}`)},advocates:()=>ce("/fan-profiles/advocates"),create:s=>ce("/fan-profiles",{method:"POST",body:JSON.stringify(s)}),update:(s,l)=>ce(`/fan-profiles/${s}`,{method:"PUT",body:JSON.stringify(l)})},yf={list:s=>{const l=new URLSearchParams;return s?.limit&&l.set("limit",String(s.limit)),s?.offset&&l.set("offset",String(s.offset)),ce(`/orders?${l}`)},create:s=>ce("/orders",{method:"POST",body:JSON.stringify(s)})},bf={list:s=>{const l=s?`?status=${s}`:"";return ce(`/conversations${l}`)},create:s=>ce("/conversations",{method:"POST",body:JSON.stringify(s)}),update:(s,l)=>ce(`/conversations/${s}`,{method:"PUT",body:JSON.stringify(l)})},Du={get:()=>ce("/brand-config"),update:s=>ce("/brand-config",{method:"PUT",body:JSON.stringify(s)}),uploadLogo:s=>
9{const l=new FormData;return l.append("file",s),Ku("/brand-config/logo",l)}},Hu={list:()=>ce("/brand-media"),upload:s=>{const l=new FormData;return l.append("file",s),Ku("/brand-media",l)},remove:s=>ce(`/brand-media/${s}`,{method:"DELETE"})},xa={list:()=>ce("/campaigns"),get:s=>ce(`/campaigns/${s}`),create:s=>ce("/campaigns",{method:"POST",body:JSON.stringify(s)}),update:(s,l)=>ce(`/campaigns/${s}`,{method:"PUT",body:JSON.stringify(l)}),send:s=>ce(`/campaigns/${s}/send`,{method:"POST"}),stats:s=>ce(`/campaigns/${s}/stats`),sends:(s,l)=>{const i=new URLSearchParams;return l?.limit&&i.set("limit",String(l.limit)),l?.offset&&i.set("offset",String(l.offset)),ce(`/campaigns/${s}/sends?${i}`)},generateCopy:s=>ce("/campaigns/generate-copy",{method:"POST",body:JSON.stringify(s)})},vf={list:()=>ce("/templates"),create:s=>ce("/templates",{method:"POST",body:JSON.stringify(s)})},os={list:()=>ce("/target-profiles"),create:s=>ce("/target-profiles",{method:"POST",body:JSON.stringify(s)}),update:(s,l)=>ce(`/target-profiles/${s}`,{method:"PUT",body:JSON.stringify(l)}),delete:s=>ce(`/target-profiles/${s}`,{method:"DELETE"})},Eo={list:()=>ce("/research-jobs"),get:s=>ce(`/research-jobs/${s}`),create:s=>ce("/research-jobs",{method:"POST",body:JSON.stringify(s)}),providers:()=>ce("/research-providers")},xu={save:(s,l)=>ce(`/provider-credentials/${s}`,{method:"PUT",body:JSON.stringify(l)}),test:s=>ce(`/provider-credentials/${s}/test`,{method:"POST"}),delete:s=>ce(`/provider-credentials/${s}`,{method:"DELETE"})},gu={list:s=>{const l=new URLSearchParams;return s?.job_id&&l.set("job_id",s.job_id),s?.profile_id&&l.set("profile_id",s.profile_id),s?.status&&l.set("status",s.status),ce(`/research-matches?${l}`)},promote:s=>ce(`/research-matches/${s}/promote`,{method:"POST"}),reject:s=>ce(`/research-matches/${s}/reject`,{method:"POST"})},Za={list:()=>ce("/lists"),create:s=>ce("/lists",{method:"POST",body:JSON.stringify({name:s})}),delete:s=>ce(`/lists/${s}`,{method:"DELETE"}),addContacts:(s,l)=>ce(`/lists/${s}/contacts`,{method:"POST",body:JSON.stringify({contact_ids:l})})};function Na(s){const l=new URLSearchParams;if(s)for(const[o,d]of Object.entries(s))d!=null&&d!==""&&l.set(o,String(d));const i=l.toString();return i?`?${i}`:""}const Qe=(s,l)=>ce(s,{method:"POST",body:l?JSON.stringify(l):void 0}),ls=(s,l)=>ce(s,{method:"PUT",body:l?JSON.stringify(l):void 0}),Ts=s=>ce(s,{method:"DELETE"}),Me={presets:()=>ce("/leads/presets"),createPreset:s=>Qe("/leads/presets",s),editPreset:(s,l)=>ls(`/leads/presets/${s}`,l),removePreset:s=>Ts(`/leads/presets/${s}`),duplicatePreset:(s,l)=>Qe(`/leads/presets/${s}/duplicate`,l?{name:l}:{}),fromPreset:(s,l)=>Qe("/leads/searches/from-preset",{preset_key:s,overrides:l}),createSearch:s=>Qe("/leads/searches",s),updateSearch:(s,l)=>ls(`/leads/searches/${s}`,l),deleteSearch:s=>Ts(`/leads/searches/${s}`),preview:s=>ce(`/leads/searches/${s}/preview`),run:(s,l)=>Qe(`/leads/searches/${s}/run`,l||{}),runs:()=>ce("/leads/runs"),getRun:s=>ce(`/leads/runs/${s}`),results:(s,l)=>ce(`/leads/runs/${s}/results${Na(l)}`),qualifyPreview:s=>ce(`/leads/runs/${s}/qualify-preview`),qualify:(s,l)=>Qe(`/leads/runs/${s}/qualify`,l||{}),internalCheckPreview:s=>ce(`/leads/runs/${s}/internal-check-preview`),enrichPreview:s=>ce(`/leads/runs/${s}/enrich-preview`),enrich:(s,l)=>Qe(`/leads/runs/${s}/enrich`,l||{}),pauseEnrich:s=>Qe(`/leads/runs/${s}/enrich/pause`),compare:(s,l)=>ce(`/leads/runs/${s}/compare/${l}`),suggestions:s=>ce(`/leads/runs/${s}/suggestions`),applySuggestion:(s,l,i)=>Qe(`/leads/searches/${s}/apply-suggestion`,{criteria_delta:l,name:i}),findMore:s=>Qe("/leads/find-more-like-this",{lead_ids:s}),saveLead:s=>Qe(`/leads/${s}/save`),excludeLead:s=>Qe(`/leads/${s}/exclude`),noteLead:(s,l)=>Qe(`/leads/${s}/note`,{note:l}),addToList:(s,l)=>Qe(`/leads/${s}/add-to-list`,l),addToCampaign:(s,l)=>Qe(`/leads/${s}/add-to-campaign`,{campaign_id:l}),lists:()=>ce("/leads/lists"),exclusions:()=>ce("/leads/exclusions"),addExclusion:(s,l,i)=>Qe("/leads/exclusions",{type:s,value:l,reason:i}),deleteExclusion:s=>Ts(`/leads/exclusions/${s}`),schedules:()=>ce("/leads/schedules"),createSchedule:s=>Qe("/leads/schedules",s),updateSchedule:(s,l)=>ls(`/leads/schedules/${s}`,l),deleteSchedule:s=>Ts(`/leads/schedules/${s}`),runScheduleNow:s=>Qe(`/leads/schedules/${s}/run-now`),automation:()=>ce("/leads/automation"),setAutomation:(s,l)=>Qe(`/leads/searches/${s}/automation`,l),profileMatches:s=>ce(`/leads/profile-matches${Na({dedupe_key:s})}`),exportLeads:s=>Qe("/leads/export",s),approvals:()=>ce("/leads/approvals"),approve:s=>
9Qe(`/leads/approvals/${s}/approve`),reject:s=>Qe(`/leads/approvals/${s}/reject`),analytics:s=>ce(`/leads/analytics${s?`?days=${s}`:""}`),adminProviders:()=>ce("/leads/admin/providers"),saveCredentials:(s,l)=>ls(`/leads/admin/credentials/${s}`,{fields:l}),deleteCredentials:s=>Ts(`/leads/admin/credentials/${s}`),testCredentials:s=>Qe(`/leads/admin/credentials/${s}/test`),usageLimits:()=>ce("/leads/admin/usage-limits"),setUsageLimit:(s,l)=>ls(`/leads/admin/usage-limits/${s}`,l),usage:()=>ce("/leads/admin/usage"),adminPresets:()=>ce("/leads/admin/presets"),updatePreset:(s,l)=>ls(`/leads/admin/presets/${s}`,l)},Te="/leads/engagement",je={dashboard:s=>ce(`${Te}/dashboard${Na(s)}`),lifecycle:s=>ce(`${Te}/lifecycle${Na(s)}`),events:s=>ce(`${Te}/events${Na(s)}`),contact:s=>ce(`${Te}/contacts/${s}`),setStatus:(s,l,i)=>Qe(`${Te}/contacts/${s}/status`,{internal_status:l,reason:i}),progress:(s,l,i)=>Qe(`${Te}/contacts/${s}/progress`,{action:l,reason:i}),manualEvent:s=>Qe(`${Te}/events/manual`,s),importEvents:s=>Qe(`${Te}/events/import`,s),inbound:s=>ce(`${Te}/inbound${Na(s)}`),inboundItem:s=>ce(`${Te}/inbound/${s}`),resolveInbound:(s,l)=>Qe(`${Te}/inbound/${s}/resolve`,l),routeInbound:(s,l)=>Qe(`${Te}/inbound/${s}/route`,l),inboundAccuracy:()=>ce(`${Te}/inbound-accuracy`),reviews:s=>ce(`${Te}/reviews${Na({status:s})}`),reviewAction:(s,l)=>Qe(`${Te}/reviews/${s}/action`,l),reviewInstantlySafety:(s,l)=>ce(`${Te}/reviews/${s}/instantly-safety${l?`?classification=${encodeURIComponent(l)}`:""}`),v2LaunchState:()=>ce(`${Te}/v2/launch-state`),v2ReviewAction:(s,l)=>Qe(`${Te}/v2/reviews/${s}/action`,l),syncErrors:()=>ce(`${Te}/sync-errors`),retrySync:s=>Qe(`${Te}/sync-errors/${s}/retry`),retryAllSync:()=>Qe(`${Te}/sync-errors/retry-all`),syncJobRouting:s=>ce(`${Te}/sync-errors/${s}/routing`),dncUnresolved:()=>ce(`${Te}/dnc/unresolved`),dncCount:()=>ce(`${Te}/dnc/count`),dncRecheck:s=>ce(`${Te}/dnc/recheck?email=${encodeURIComponent(s)}`),dncRetry:s=>Qe(`${Te}/dnc/retry`,{email:s,confirm:!0}),settings:()=>ce(`${Te}/settings`),saveSettings:s=>ls(`${Te}/settings`,s),webhookInfo:()=>ce(`${Te}/webhook-info`),rotateWebhook:()=>Qe(`${Te}/webhook-info/rotate`),ownerRules:()=>ce(`${Te}/owner-rules`),addOwnerRule:s=>Qe(`${Te}/owner-rules`,s),deleteOwnerRule:s=>Ts(`${Te}/owner-rules/${s}`),hubspotOwners:()=>ce(`${Te}/hubspot-owners`),routingOptions:()=>ce(`${Te}/routing-options`),resolveRouting:(s,l)=>Qe(`${Te}/reviews/${s}/resolve-routing`,l),audit:s=>ce(`${Te}/audit${Na(s)}`),team:()=>ce(`${Te}/team`),addTeamMember:s=>Qe(`${Te}/team`,s),attention:()=>ce(`${Te}/attention`),automationReadiness:()=>ce(`${Te}/automation/readiness`),listVerification:s=>ce(`${Te}/list-verification/${encodeURIComponent(s)}`),updateTeamMember:(s,l)=>ls(`${Te}/team/${s}`,l),deleteTeamMember:s=>Ts(`${Te}/team/${s}`),assignRules:()=>ce(`${Te}/assignment/rules`),addAssignRule:s=>Qe(`${Te}/assignment/rules`,s),updateAssignRule:(s,l)=>ls(`${Te}/assignment/rules/${s}`,l),deleteAssignRule:s=>Ts(`${Te}/assignment/rules/${s}`),reorderAssignRules:s=>Qe(`${Te}/assignment/rules/reorder`,{order:s}),previewAssign:s=>Qe(`${Te}/assignment/preview`,s),assignReadiness:()=>ce(`${Te}/assignment/readiness`),assignMeta:()=>ce(`${Te}/assignment/meta`),lifecyclePreview:s=>Qe(`${Te}/lifecycle/preview`,s),goLiveReadiness:()=>ce(`${Te}/go-live-readiness`),mapping:()=>ce(`${Te}/mapping`),testLog:()=>ce(`${Te}/test-log`),testNotification:s=>Qe(`${Te}/notifications/test`,s?{notify_config:s}:{}),notificationLog:()=>ce(`${Te}/notifications/log`),hubspotPreflight:()=>ce(`${Te}/hubspot-preflight`),instantlyCampaigns:()=>ce(`${Te}/instantly-campaigns`),campaignOwners:()=>ce(`${Te}/campaign-owners`),addCampaignOwner:s=>Qe(`${Te}/campaign-owners`,s),updateCampaignOwner:(s,l)=>ls(`${Te}/campaign-owners/${s}`,l),deleteCampaignOwner:s=>Ts(`${Te}/campaign-owners/${s}`),importCampaignOwners:s=>Qe(`${Te}/campaign-owners/import`,{csv:s}),validateOwner:s=>ce(`${Te}/validate-owner${Na({owner_id:s})}`),instantlySenders:s=>ce(`${Te}/instantly/senders${Na({campaign_id:s})}`),instantlyCampaignLeads:(s,l)=>ce(`${Te}/instantly/campaign-leads${Na({campaign_id:s,max:l})}`),importInstantlyCampaign:s=>Qe(`${Te}/instantly/import-campaign`,s),syncPreview:(s,l)=>ce(`${Te}/contacts/${s}/sync-preview${Na({intent:l})}`),controlledTest:()=>ce(`${Te}/controlled-test`),callConfig:()=>ce(`${Te}/call-config`),logCall:s=>Qe(`${Te}/calls`,s),approveCalling:s=>Qe(`${Te}/contacts/${s}/approve-calling`),cleanupQueue:s=>ce(`${Te}/cleanup-queue${Na({filter:s})}`),cleanupAction:(s,l,i)=>Qe(`${Te}/cleanup/${s}/action`,{action:l,reason:i})},Rn={list:()=>ce("/outreach"),create:s=>ce("/outreach",{method:"POST",body:JSON.stringify(s)}),update:(s,l)=>ce(`/outreach/${s}`,{method:"PUT",body:JSON.stringify(l)}),remove:s=>ce(`/outreach/${s}`,{method:"DELETE"}),bulkImport:s=>ce("/outreach/bulk",{method:"POST",body:JSON.stringify({companies:s})})},fu={list:()=>ce("/social/accounts"),connect:s=>ce(`/social/connect/${s}`),disconnect:s=>ce(`/social/accounts/${s}`,{method:"DELETE"})},jf=h.createContext(null);function qb({children:s}){const[l,i]=h.useState(null),[o,d]=h.useState(!0);h.useEffect(()=>{if(!localStorage.getItem("fantize_token")){d(!1);return}Da.me().then(i).catch(()=>vg()).finally(()=>d(!1))},[]);const u=(f,k)=>{const w=f;if(w&&w.waitlisted)return{kind:"waitlisted",message:w.message,position:w.position,email:w.email};if(!w||typeof w.token!="string"||!w.token||!w.account)throw new Error(w?.message||`Couldn't ${k} â the server returned a response this app doesn't support. Please try again or c
9ontact support.`);return ff(w.token),i(w.account),{kind:"ok"}},x=async(f,k)=>u(await Da.login(f,k),"sign in"),y=async(f,k,w,N)=>u(await Da.register(f,k,w,N),"sign up"),p=()=>{vg(),i(null)},g=async f=>{i(k=>k&&{...k,ui_state:{...k.ui_state,...f}});try{await Da.updateUiState(f)}catch{}},b=l?l.is_admin??(l.role?l.role==="admin":!0):!1;return e.jsx(jf.Provider,{value:{account:l,isAdmin:b,loading:o,login:x,register:y,logout:p,updateUiState:g},children:s})}function zt(){const s=h.useContext(jf);if(!s)throw new Error("useAuth must be used within AuthProvider");return s}const wf=h.createContext({theme:"system",resolvedTheme:"light",setTheme:()=>{}});function Bb({children:s}){const[l,i]=h.useState(()=>localStorage.getItem("fantize-theme")||"system"),[o,d]=h.useState("light");h.useEffect(()=>{const x=window.matchMedia("(prefers-color-scheme: dark)");function y(b){return b==="system"?x.matches?"dark":"light":b}function p(){const b=y(l);d(b);const f=document.documentElement;f.classList.toggle("dark",b==="dark"),f.setAttribute("data-theme",b),f.style.colorScheme=b}p();const g=()=>{l==="system"&&p()};return x.addEventListener("change",g),()=>x.removeEventListener("change",g)},[l]);function u(x){localStorage.setItem("fantize-theme",x),i(x)}return e.jsx(wf.Provider,{value:{theme:l,resolvedTheme:o,setTheme:u},children:s})}function Ub(){return h.useContext(wf)}const ho="fantize.marketingPreview",kf=h.createContext(null),Fb=s=>s?s.is_admin??(s.role?s.role==="admin":!0):!1;function Ib({children:s}){const{account:l}=zt(),i=Fb(l),[o,d]=h.useState(()=>{try{return sessionStorage.getItem(ho)==="1"}catch{return!1}}),u=o&&i;h.useEffect(()=>{if(o&&l&&!i){try{sessionStorage.removeItem(ho)}catch{}d(!1)}},[o,l,i]);const x=h.useCallback(()=>{if(i){try{sessionStorage.setItem(ho,"1")}catch{}d(!0)}},[i]),y=h.useCallback(()=>{try{sessionStorage.removeItem(ho)}catch{}d(!1)},[]),p=h.useMemo(()=>({active:u,asMarketing:u,readOnly:u,canPreview:i,enter:x,exit:y}),[u,i,x,y]);return e.jsx(kf.Provider,{value:p,children:s})}function Ja(){return h.useContext(kf)||{active:!1,asMarketing:!1,readOnly:!1,canPreview:!1,enter:()=>{},exit:()=>{}}}var jg="popstate";function Vb(s={}){function l(o,d){let{pathname:u,search:x,hash:y}=o.location;return qu("",{pathname:u,search:x,hash:y},d.state&&d.state.usr||null,d.state&&d.state.key||"default")}function i(o,d){return typeof d=="string"?d:Vl(d)}return Yb(l,i,null,s)}function At(s,l){if(s===!1||s===null||typeof s>"u")throw new Error(l)}function Fa(s,l){if(!s){typeof console<"u"&&console.warn(l);try{throw new Error(l)}catch{}}}function Gb(){return Math.random().toString(36).substring(2,10)}function wg(s,l){return{usr:s.state,key:s.key,idx:l}}function qu(s,l,i=null,o){return{pathname:typeof s=="string"?s:s.pathname,search:"",hash:"",...typeof l=="string"?Lr(l):l,state:i,key:l&&l.key||o||Gb()}}function Vl({pathname:s="/",search:l="",hash:i=""}){return l&&l!=="?"&&(s+=l.charAt(0)==="?"?l:"?"+l),i&&i!=="#"&&(s+=i.charAt(0)==="#"?i:"#"+i),s}function Lr(s){let l={};if(s){let i=s.indexOf("#");i>=0&&(l.hash=s.substring(i),s=s.substring(0,i));let o=s.indexOf("?");o>=0&&(l.search=s.substring(o),s=s.substring(0,o)),s&&(l.pathname=s)}return l}function Yb(s,l,i,o={}){let{window:d=document.defaultView,v5Compat:u=!1}=o,x=d.history,y="POP",p=null,g=b();g==null&&(g=0,x.replaceState({...x.state,idx:g},""));function b(){return(x.state||{idx:null}).idx}function f(){y="POP";let T=b(),S=T==null?null:T-g;g=T,p&&p({action:y,location:j.location,delta:S})}function k(T,S){y="PUSH";let _=qu(j.location,T,S);g=b()+1;let z=wg(_,g),A=j.createHref(_);try{x.pushState(z,"",A)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;d.location.assign(A)}u&&p&&p({action:y,location:j.location,delta:1})}function w(T,S){y="REPLACE";let _=qu(j.location,T,S);g=b();let z=wg(_,g),A=j.createHref(_);x.replaceState(z,"",A),u&&p&&p({action:y,location:j.location,delta:0})}function N(T){return Pb(T)}let j={get action(){return y},get location(){return s(d,x)},listen(T){if(p)throw new Error("A history only accepts one active listener");return d.addEventListener(jg,f),p=T,()=>{d.removeEventListener(jg,f),p=null}},createHref(T){return l(d,T)},createURL:N,encodeLocation(T){let S=N(T);return{pathname:S.pathname,search:S.search,hash:S.hash}},push:k,replace:w,go(T){return x.go(T)}};return j}function Pb(s,l=!1){let i="http://localhost";
9typeof window<"u"&&(i=window.location.origin!=="null"?window.location.origin:window.location.href),At(i,"No window.location.(origin|href) available to create URL");let o=typeof s=="string"?s:Vl(s);return o=o.replace(/ $/,"%20"),!l&&o.startsWith("//")&&(o=i+o),new URL(o,i)}function Nf(s,l,i="/"){return Qb(s,l,i,!1)}function Qb(s,l,i,o){let d=typeof l=="string"?Lr(l):l,u=zs(d.pathname||"/",i);if(u==null)return null;let x=_f(s);Xb(x);let y=null;for(let p=0;y==null&&p<x.length;++p){let g=lv(u);y=nv(x[p],g,o)}return y}function _f(s,l=[],i=[],o="",d=!1){let u=(x,y,p=d,g)=>{let b={relativePath:g===void 0?x.path||"":g,caseSensitive:x.caseSensitive===!0,childrenIndex:y,route:x};if(b.relativePath.startsWith("/")){if(!b.relativePath.startsWith(o)&&p)return;At(b.relativePath.startsWith(o),`Absolute route path "${b.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),b.relativePath=b.relativePath.slice(o.length)}let f=Rs([o,b.relativePath]),k=i.concat(b);x.children&&x.children.length>0&&(At(x.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),_f(x.children,l,k,f,p)),!(x.path==null&&!x.index)&&l.push({path:f,score:av(f,x.index),routesMeta:k})};return s.forEach((x,y)=>{if(x.path===""||!x.path?.includes("?"))u(x,y);else for(let p of Sf(x.path))u(x,y,!0,p)}),l}function Sf(s){let l=s.split("/");if(l.length===0)return[];let[i,...o]=l,d=i.endsWith("?"),u=i.replace(/\?$/,"");if(o.length===0)return d?[u,""]:[u];let x=Sf(o.join("/")),y=[];return y.push(...x.map(p=>p===""?u:[u,p].join("/"))),d&&y.push(...x),y.map(p=>s.startsWith("/")&&p===""?"/":p)}function Xb(s){s.sort((l,i)=>l.score!==i.score?i.score-l.score:sv(l.routesMeta.map(o=>o.childrenIndex),i.routesMeta.map(o=>o.childrenIndex)))}var Wb=/^:[\w-]+$/,Zb=3,Kb=2,Jb=1,ev=10,tv=-2,kg=s=>s==="*";function av(s,l){let i=s.split("/"),o=i.length;return i.some(kg)&&(o+=tv),l&&(o+=Kb),i.filter(d=>!kg(d)).reduce((d,u)=>d+(Wb.test(u)?Zb:u===""?Jb:ev),o)}function sv(s,l){return s.length===l.length&&s.slice(0,-1).every((o,d)=>o===l[d])?s[s.length-1]-l[l.length-1]:0}function nv(s,l,i=!1){let{routesMeta:o}=s,d={},u="/",x=[];for(let y=0;y<o.length;++y){let p=o[y],g=y===o.length-1,b=u==="/"?l:l.slice(u.length)||"/",f=Mo({path:p.relativePath,caseSensitive:p.caseSensitive,end:g},b),k=p.route;if(!f&&g&&i&&!o[o.length-1].route.index&&(f=Mo({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},b)),!f)return null;
9Object.assign(d,f.params),x.push({params:d,pathname:Rs([u,f.pathname]),pathnameBase:dv(Rs([u,f.pathnameBase])),route:k}),f.pathnameBase!=="/"&&(u=Rs([u,f.pathnameBase]))}return x}function Mo(s,l){typeof s=="string"&&(s={path:s,caseSensitive:!1,end:!0});let[i,o]=rv(s.path,s.caseSensitive,s.end),d=l.match(i);if(!d)return null;let u=d[0],x=u.replace(/(.)\/+$/,"$1"),y=d.slice(1);return{params:o.reduce((g,{paramName:b,isOptional:f},k)=>{if(b==="*"){let N=y[k]||"";x=u.slice(0,u.length-N.length).replace(/(.)\/+$/,"$1")}const w=y[k];return f&&!w?g[b]=void 0:g[b]=(w||"").replace(/%2F/g,"/"),g},{}),pathname:u,pathnameBase:x,pattern:s}}function rv(s,l=!1,i=!0){Fa(s==="*"||!s.endsWith("*")||s.endsWith("/*"),`Route path "${s}" will be treated as if it were "${s.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${s.replace(/\*$/,"/*")}".`);let o=[],d="^"+s.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(x,y,p)=>(o.push({paramName:y,isOptional:p!=null}),p?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return s.endsWith("*")?(o.push({paramName:"*"}),d+=s==="*"||s==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?d+="\\/*$":s!==""&&s!=="/"&&(d+="(?:(?=\\/|$))"),[new RegExp(d,l?void 0:"i"),o]}function lv(s){try{return s.split("/").map(l=>decodeURIComponent(l).replace(/\//g,"%2F")).join("/")}catch(l){return Fa(!1,`The URL path "${s}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${l}).`),s}}function zs(s,l){if(l==="/")return s;if(!s.toLowerCase().startsWith(l.toLowerCase()))return null;let i=l.endsWith("/")?l.length-1:l.length,o=s.charAt(i);return o&&o!=="/"?null:s.slice(i)||"/"}var iv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function ov(s,l="/"){let{pathname:i,search:o="",hash:d=""}=typeof s=="string"?Lr(s):s,u;return i?(i=i.replace(/\/\/+/g,"/"),i.startsWith("/")?u=Ng(i.substring(1),"/"):u=Ng(i,l)):u=l,{pathname:u,search:uv(o),hash:mv(d)}}function Ng(s,l){let i=l.replace(/\/+$/,"").split("/");return s.split("/").forEach(d=>{d===".."?i.length>1&&i.pop():d!=="."&&i.push(d)}),i.length>1?i.join("/"):"/"}function pu(s,l,i,o){return`Cannot include a '${s}' character in a manually specified \`to.${l}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${i}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function cv(s){return s.filter((l,i)=>i===0||l.route.path&&l.route.path.length>0)}function Ju(s){let l=cv(s);return l.map((i,o)=>o===l.length-1?i.pathname:i.pathnameBase)}function em(s,l,i,o=!1){let d;typeof s=="string"?d=Lr(s):(d={...s},At(!d.pathname||!d.pathname.includes("?"),pu("?","pathname","search",d)),At(!d.pathname||!d.pathname.includes("#"),pu("#","pathname","hash",d)),At(!d.search||!d.search.includes("#"),pu("#","search","hash",d)));let u=s===""||d.pathname==="",x=u?"/":d.pathname,y;if(x==null)y=i;else{let f=l.length-1;if(!o&&x.startsWith("..")){let k=x.split("/");for(;k[0]==="..";)k.shift(),f-=1;d.pathname=k.join("/")}y=f>=0?l[f]:"/"}let p=ov(d,y),g=x&&x!=="/"&&x.endsWith("/"),b=(u||x===".")&&i.endsWith("/");return!p.pathname.endsWith("/")&&(g||b)&&(p.pathname+="/"),p}var Rs=s=>s.join("/").replace(/\/\/+/g,"/"),dv=s=>s.replace(/\/+$/,"").replace(/^\/*/,"/"),uv=s=>!s||s==="?"?"":s.startsWith("?")?s:"?"+s,mv=s=>!s||s==="#"?"":s.startsWith("#")?s:"#"+s,hv=class{constructor(s,l,i,o=!1){this.status=s,this.statusText=l||"",this.internal=o,i instanceof Error?(this.data=i.toString(),this.error=i):this.data=i}};function xv(s){return s!=null&&typeof s.status=="number"&&typeof s.statusText=="string"&&typeof s.internal=="boolean"&&"data"in s}function gv(s){return s.map(l=>l.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Cf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Af(s,l){let i=s;if(typeof i!="string"||!iv.test(i))return{absoluteURL:void 0,isExternal:!1,to:i};let o=i,d=!1;if(Cf)try{let u=new URL(window.location.href),x=i.startsWith("//")?new URL(u.protocol+i):new URL(i),y=zs(x.pathname,l);x.origin===u.origin&&y!=null?i=y+x.search+x.hash:d=!0}catch{Fa(!1,`<Link to="${i}">
9 contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:d,to:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Ef=["POST","PUT","PATCH","DELETE"];new Set(Ef);var fv=["GET",...Ef];new Set(fv);var Mr=h.createContext(null);Mr.displayName="DataRouter";var Fo=h.createContext(null);Fo.displayName="DataRouterState";var pv=h.createContext(!1),Tf=h.createContext({isTransitioning:!1});Tf.displayName="ViewTransition";var yv=h.createContext(new Map);yv.displayName="Fetchers";var bv=h.createContext(null);bv.displayName="Await";var _a=h.createContext(null);_a.displayName="Navigation";var Or=h.createContext(null);Or.displayName="Location";var Va=h.createContext({outlet:null,matches:[],isDataRoute:!1});Va.displayName="Route";var tm=h.createContext(null);tm.displayName="RouteError";var Rf="REACT_ROUTER_ERROR",vv="REDIRECT",jv="ROUTE_ERROR_RESPONSE";function wv(s){if(s.startsWith(`${Rf}:${vv}:{`))try{let l=JSON.parse(s.slice(28));if(typeof l=="object"&&l&&typeof l.status=="number"&&typeof l.statusText=="string"&&typeof l.location=="string"&&typeof l.reloadDocument=="boolean"&&typeof l.replace=="boolean")return l}catch{}}function kv(s){if(s.startsWith(`${Rf}:${jv}:{`))try{let l=JSON.parse(s.slice(40));if(typeof l=="object"&&l&&typeof l.status=="number"&&typeof l.statusText=="string")return new hv(l.status,l.statusText,l.data)}catch{}}function Nv(s,{relative:l}={}){At(Dn(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:o}=h.useContext(_a),{hash:d,pathname:u,search:x}=Yl(s,{relative:l}),y=u;return i!=="/"&&(y=u==="/"?i:Rs([i,u])),o.createHref({pathname:y,search:x,hash:d})}function Dn(){return h.useContext(Or)!=null}function Ga(){return At(Dn(),"useLocation() may be used only in the context of a <Router> component."),h.useContext(Or).location}function _v(){return h.useContext(Or).navigationType}var zf="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Lf(s){h.useContext(_a).static||h.useLayoutEffect(s)}function Ya(){let{isDataRoute:s}=h.useContext(Va);return s?Bv():Sv()}function Sv(){At(Dn(),"useNavigate() may be used only in the context of a <Router> component.");let s=h.useContext(Mr),{basename:l,navigator:i}=h.useContext(_a),{matches:o}=h.useContext(Va),{pathname:d}=Ga(),u=JSON.stringify(Ju(o)),x=h.useRef(!1);return Lf(()=>{x.current=!0}),h.useCallback((p,g={})=>{if(Fa(x.current,zf),!x.current)return;if(typeof p=="number"){i.go(p);return}let b=em(p,JSON.parse(u),d,g.relative==="path");s==null&&l!=="/"&&(b.pathname=b.pathname==="/"?l:Rs([l,b.pathname])),(g.replace?i.replace:i.push)(b,g.state,g)},[l,i,u,d,s])}var Cv=h.createContext(null);function Av(s){let l=h.useContext(Va).outlet;return h.useMemo(()=>l&&h.createElement(Cv.Provider,{value:s},l),[l,s])}function am(){let{matches:s}=h.useContext(Va),l=s[s.length-1];return l?l.params:{}}function Yl(s,{relative:l}={}){let{matches:i}=h.useContext(Va),{pathname:o}=Ga(),d=JSON.stringify(Ju(i));return h.useMemo(()=>em(s,JSON.parse(d),o,l==="path"),[s,d,o,l])}function Ev(s,l){return Mf(s,l)}function Mf(s,l,i,o,d){At(Dn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:u}=h.useContext(_a),{matches:x}=h.useContext(Va),y=x[x.length-1],p=y?y.params:{},g=y?y.pathname:"/",b=y?y.pathnameBase:"/",f=y&&y.route;{let _=f&&f.path||"";$f(g,!f||_.endsWith("*")||_.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${_}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. 10 11Please change the parent <Route path="${_}"> to <Route path="${_==="/"?"*":`${_}/*`}">.`)}let k=Ga(),w;if(l){let _=typeof l=="string"?Lr(l):l;At(b==="/"||_.pathname?.startsWith(b),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${b}" but pathname "${_.pathname}" was given in the \`location\` prop.`),w=_}else w=k;let N=w.pathname||"/",j=N;if(b!=="/"){let _=b.replace(/^\//,"").split("/");j="/"+N.replace(/^\//,"").split("/").slice(_.length).join("/")}let T=Nf(s,{pathname:j});Fa(f||T!=null,`No routes matched location "${w.pathname}${w.search}${w.hash}" `),Fa(T==null||T[T.length-1].route.element!==void 0||T[T.length-1].route.Component!==void 0||T[T.length-1].route.lazy!==void 0,`Matched leaf route at location "${w.pathname}${w.search}${w.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=Mv(T&&T.map(_=>Object.assign({},_,{params:Object.assign({},p,_.params),pathname:Rs([b,u.encodeLocation?u.encodeLocation(_.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathname]),pathnameBase:_.pathnameBase==="/"?b:Rs([b,u.encodeLocation?u.encodeLocation(_.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathnameBase])})),x,i,o,d);return l&&S?h.createElement(Or.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...w},navigationType:"POP"}},S):S}function Tv(){let s=qv(),l=xv(s)?`${s.status} ${s.statusText}`:s instanceof Error?s.message:JSON.stringify(s),i=s instanceof Error?s.stack:null,o="rgba(200,200,200, 0.5)",d={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},x=null;return console.error("Error handled by React Router default ErrorBoundary:",s),x=h.createElement(h.Fragment,null,h.createElement("p",null,"ð¿ Hey developer ð"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:u},"ErrorBoundary")," or"," ",h.createElement("code",{style:u},"errorElement")," prop on your route.")),h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application
11Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},l),i?h.createElement("pre",{style:d},i):null,x)}var Rv=h.createElement(Tv,null),Of=class extends h.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,l){return l.location!==s.location||l.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:l.error,location:l.location,revalidation:s.revalidation||l.revalidation}}componentDidCatch(s,l){this.props.onError?this.props.onError(s,l):console.error("React Router caught the following error during render",s)}render(){let s=this.state.error;if(this.context&&typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){const i=kv(s.digest);i&&(s=i)}let l=s!==void 0?h.createElement(Va.Provider,{value:this.props.routeContext},h.createElement(tm.Provider,{value:s,children:this.props.component})):this.props.children;return this.context?h.createElement(zv,{error:s},l):l}};Of.contextType=pv;var yu=new WeakMap;function zv({children:s,error:l}){let{basename:i}=h.useContext(_a);if(typeof l=="object"&&l&&"digest"in l&&typeof l.digest=="string"){let o=wv(l.digest);if(o){let d=yu.get(l);if(d)throw d;let u=Af(o.location,i);if(Cf&&!yu.get(l))if(u.isExternal||o.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const x=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:o.replace}));throw yu.set(l,x),x}return h.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return s}function Lv({routeContext:s,match:l,children:i}){let o=h.useContext(Mr);return o&&o.static&&o.staticContext&&(l.route.errorElement||l.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=l.route.id),h.createElement(Va.Provider,{value:s},i)}function Mv(s,l=[],i=null,o=null,d=null){if(s==null){if(!i)return null;if(i.errors)s=i.matches;else if(l.length===0&&!i.initialized&&i.matches.length>0)s=i.matches;else return null}let u=s,x=i?.errors;if(x!=null){let b=u.findIndex(f=>f.route.id&&x?.[f.route.id]!==void 0);At(b>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(x).join(",")}`),u=u.slice(0,Math.min(u.length,b+1))}let y=!1,p=-1;if(i)for(let b=0;b<u.length;b++){let f=u[b];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(p=b),f.route.id){let{loaderData:k,errors:w}=i,N=f.route.loader&&!k.hasOwnProperty(f.route.id)&&(!w||w[f.route.id]===void 0);if(f.route.lazy||N){y=!0,p>=0?u=u.slice(0,p+1):u=[u[0]];break}}}let g=i&&o?(b,f)=>{o(b,{location:i.location,params:i.matches?.[0]?.params??{},unstable_pattern:gv(i.matches),errorInfo:f})}:void 0;return u.reduceRight((b,f,k)=>{let w,N=!1,j=null,T=null;i&&(w=x&&f.route.id?x[f.route.id]:void 0,j=f.route.errorElement||Rv,y&&(p<0&&k===0?($f("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),N=!0,T=null):p===k&&(N=!0,T=f.route.hydrateFallbackElement||null)));let S=l.concat(u.slice(0,k+1)),_=()=>{let z;return w?z=j:N?z=T:f.route.Component?z=h.createElement(f.route.Component,null):f.route.element?z=f.route.element:z=b,h.createElement(Lv,{match:f,routeContext:{outlet:b,matches:S,isDataRoute:i!=null},children:z})};return i&&(f.route.ErrorBoundary||f.route.errorElement||k===0)?h.createElement(Of,{location:i.location,revalidation:i.revalidation,component:j,error:w,children:_(),routeContext:{outlet:null,matches:S,isDataRoute:!0},onError:g}):_()},null)}function sm(s){return`${s} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ov(s){let l=h.useContext(Mr);return At(l,sm(s)),l}function $v(s){let l=h.useContext(Fo);return At(l,sm(s)),l}function Dv(s){let l=h.useContext(Va);return At(l,sm(s)),l}function nm(s){let l=Dv(s),i=l.matches[l.matches.length-1];return At(i.route.id,`${s} can only be used on routes that contain a unique "id"`),i.route.id}function Hv(){return nm("useRouteId")}function qv(){let s=h.useContext(tm),l=$v("useRouteError"),i=nm("useRouteError");return s!==void 0?s:l.errors?.[i]}function Bv(){let{router:s}=Ov("useNavigate"),l=nm("useNavigate"),i=h.useRef(!1);return Lf(()=>{i.current=!0}),h.useCallback(async(d,u={})=>{Fa(i.current,zf),i.current&&(typeof d=="number"?await s.navigate(d):await s.navigate(d,{fromRouteId:l,...u}))},[s,l])}var _g={};function $f(s,l,i){!l&&!_g[s]&&(_g[s]=!0,Fa(!1,i))}h.memo(Uv);function Uv({routes:s,future:l,state:i,onError:o}){return Mf(s,void 0,i,o,l)}function is({to:s,replace:l,state:i,relative:o}){At(Dn(),"<Navigate> may be used only in the context of a <Router> component.");let{static:d}=h.useContext(_a);Fa(!d,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:u}=h.useContext(Va),{pathname:x}=Ga(),y=Ya(),p=em(s,Ju(u),x,o==="path"),g=JSON.stringify(p);return h.useEffect(()=>{y(JSON.parse(g),{replace:l,state:i,relative:o})},[y,g,o,l,i]),null}function Df(s){return Av(s.context)}function Le(s){At(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Fv({basename:s="/",children:l=null,location:i,navigationType:o="POP",navigator:d,static:u=!1,unstable_useTransitions:x}){At(!Dn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let y=s.replace(/^\/*/,"/"),p=h.useMemo(()=>({basename:y,navigator:d,static:u,unstable_useTransitions:x,future:{}}),[y,d,u,x]);typeof i=="string"&&(i=Lr(i));let{pathname:g="/",search:b="",hash:f="",state:k=null,key:w="default"}=i,N=h.useMemo(()=>{let j=zs(g,y);
11return j==null?null:{location:{pathname:j,search:b,hash:f,state:k,key:w},navigationType:o}},[y,g,b,f,k,w,o]);return Fa(N!=null,`<Router basename="${y}"> is not able to match the URL "${g}${b}${f}" because it does not start with the basename, so the <Router> won't render anything.`),N==null?null:h.createElement(_a.Provider,{value:p},h.createElement(Or.Provider,{children:l,value:N}))}function Iv({children:s,location:l}){return Ev(Bu(s),l)}function Bu(s,l=[]){let i=[];return h.Children.forEach(s,(o,d)=>{if(!h.isValidElement(o))return;let u=[...l,d];if(o.type===h.Fragment){i.push.apply(i,Bu(o.props.children,u));return}At(o.type===Le,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),At(!o.props.index||!o.props.children,"An index route cannot have child routes.");let x={id:o.props.id||u.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(x.children=Bu(o.props.children,u)),i.push(x)}),i}var To="get",Ro="application/x-www-form-urlencoded";function Io(s){return typeof HTMLElement<"u"&&s instanceof HTMLElement}function Vv(s){return Io(s)&&s.tagName.toLowerCase()==="button"}function Gv(s){return Io(s)&&s.tagName.toLowerCase()==="form"}function Yv(s){return Io(s)&&s.tagName.toLowerCase()==="input"}function Pv(s){return!!(s.metaKey||s.altKey||s.ctrlKey||s.shiftKey)}function Qv(s,l){return s.button===0&&(!l||l==="_self")&&!Pv(s)}function Uu(s=""){return new URLSearchParams(typeof s=="string"||Array.isArray(s)||s instanceof URLSearchParams?s:Object.keys(s).reduce((l,i)=>{let o=s[i];return l.concat(Array.isArray(o)?o.map(d=>[i,d]):[[i,o]])},[]))}function Xv(s,l){let i=Uu(s);return l&&l.forEach((o,d)=>{i.has(d)||l.getAll(d).forEach(u=>{i.append(d,u)})}),i}var xo=null;function Wv(){if(xo===null)try{new FormData(document.createElement("form"),0),xo=!1}catch{xo=!0}return xo}var Zv=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function bu(s){return s!=null&&!Zv.has(s)?(Fa(!1,`"${s}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ro}"`),null):s}function Kv(s,l){let i,o,d,u,x;if(Gv(s)){let y=s.getAttribute("action");o=y?zs(y,l):null,i=s.getAttribute("method")||To,d=bu(s.getAttribute("enctype"))||Ro,u=new FormData(s)}else if(Vv(s)||Yv(s)&&(s.type==="submit"||s.type==="image")){let y=s.form;if(y==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=s.getAttribute("formaction")||y.getAttribute("action");if(o=p?zs(p,l):null,i=s.getAttribute("formmethod")||y.getAttribute("method")||To,d=bu(s.getAttribute("formenctype"))||bu(y.getAttribute("enctype"))||Ro,u=new FormData(y,s),!Wv()){let{name:g,type:b,value:f}=s;if(b==="image"){let k=g?`${g}.`:"";u.append(`${k}x`,"0"),u.append(`${k}y`,"0")}else g&&u.append(g,f)}}else{if(Io(s))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=To,o=null,d=Ro,x=s}return u&&d==="text/plain"&&(x=u,u=void 0),{action:o,method:i.toLowerCase(),encType:d,formData:u,body:x}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function rm(s,l){if(s===!1||s===null||typeof s>"u")throw new Error(l)}function Jv(s,l,i,o){let d=typeof s=="string"?new URL(s,typeof window>"u"?"server://singlefetch/":window.location.origin):s;return i?d.pathname.endsWith("/")?d.pathname=`${d.pathname}_.${o}`:d.pathname=`${d.pathname}.${o}`:d.pathname==="/"?d.pathname=`_root.${o}`:l&&zs(d.pathname,l)==="/"?d.pathname=`${l.replace(/\/$/,"")}/_root.${o}`:d.pathname=`${d.pathname.replace(/\/$/,"")}.${o}`,d}async function ej(s,l){if(s.id in l)return l[s.id];try{let i=await import(s.module);return l[s.id]=i,i}catch(i){return console.error(`Error loading route module \`${s.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.
11isSpaMode,window.location.reload(),new Promise(()=>{})}}function tj(s){return s==null?!1:s.href==null?s.rel==="preload"&&typeof s.imageSrcSet=="string"&&typeof s.imageSizes=="string":typeof s.rel=="string"&&typeof s.href=="string"}async function aj(s,l,i){let o=await Promise.all(s.map(async d=>{let u=l.routes[d.route.id];if(u){let x=await ej(u,i);return x.links?x.links():[]}return[]}));return lj(o.flat(1).filter(tj).filter(d=>d.rel==="stylesheet"||d.rel==="preload").map(d=>d.rel==="stylesheet"?{...d,rel:"prefetch",as:"style"}:{...d,rel:"prefetch"}))}function Sg(s,l,i,o,d,u){let x=(p,g)=>i[g]?p.route.id!==i[g].route.id:!0,y=(p,g)=>i[g].pathname!==p.pathname||i[g].route.path?.endsWith("*")&&i[g].params["*"]!==p.params["*"];return u==="assets"?l.filter((p,g)=>x(p,g)||y(p,g)):u==="data"?l.filter((p,g)=>{let b=o.routes[p.route.id];if(!b||!b.hasLoader)return!1;if(x(p,g)||y(p,g))return!0;if(p.route.shouldRevalidate){let f=p.route.shouldRevalidate({currentUrl:new URL(d.pathname+d.search+d.hash,window.origin),currentParams:i[0]?.params||{},nextUrl:new URL(s,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function sj(s,l,{includeHydrateFallback:i}={}){return nj(s.map(o=>{let d=l.routes[o.route.id];if(!d)return[];let u=[d.module];return d.clientActionModule&&(u=u.concat(d.clientActionModule)),d.clientLoaderModule&&(u=u.concat(d.clientLoaderModule)),i&&d.hydrateFallbackModule&&(u=u.concat(d.hydrateFallbackModule)),d.imports&&(u=u.concat(d.imports)),u}).flat(1))}function nj(s){return[...new Set(s)]}function rj(s){let l={},i=Object.keys(s).sort();for(let o of i)l[o]=s[o];return l}function lj(s,l){let i=new Set;return new Set(l),s.reduce((o,d)=>{let u=JSON.stringify(rj(d));return i.has(u)||(i.add(u),o.push({key:u,link:d})),o},[])}function Hf(){let s=h.useContext(Mr);return rm(s,"You must render this element inside a <DataRouterContext.Provider> element"),s}function ij(){let s=h.useContext(Fo);return rm(s,"You must render this element inside a <DataRouterStateContext.Provider> element"),s}var lm=h.createContext(void 0);lm.displayName="FrameworkContext";function qf(){let s=h.useContext(lm);return rm(s,"You must render this element inside a <HydratedRouter> element"),s}function oj(s,l){let i=h.useContext(lm),[o,d]=h.useState(!1),[u,x]=h.useState(!1),{onFocus:y,onBlur:p,onMouseEnter:g,onMouseLeave:b,onTouchStart:f}=l,k=h.useRef(null);h.useEffect(()=>{if(s==="render"&&x(!0),s==="viewport"){let j=S=>{S.forEach(_=>{x(_.isIntersecting)})},T=new IntersectionObserver(j,{threshold:.5});return k.current&&T.observe(k.current),()=>{T.disconnect()}}},[s]),h.useEffect(()=>{if(o){let j=setTimeout(()=>{x(!0)},100);return()=>{clearTimeout(j)}}},[o]);let w=()=>{d(!0)},N=()=>{d(!1),x(!1)};return i?s!=="intent"?[u,k,{}]:[u,k,{onFocus:zl(y,w),onBlur:zl(p,N),onMouseEnter:zl(g,w),onMouseLeave:zl(b,N),onTouchStart:zl(f,w)}]:[!1,k,{}]}function zl(s,l){return i=>{s&&s(i),i.defaultPrevented||l(i)}}function cj({page:s,...l}){let{router:i}=Hf(),o=h.useMemo(()=>Nf(i.routes,s,i.basename),[i.routes,s,i.basename]);return o?h.createElement(uj,{page:s,matches:o,...l}):null}function dj(s){let{manifest:l,routeModules:i}=qf(),[o,d]=h.useState([]);return h.useEffect(()=>{let u=!1;return aj(s,l,i).then(x=>{u||d(x)}),()=>{u=!0}},[s,l,i]),o}function uj({page:s,matches:l,...i}){let o=Ga(),{future:d,manifest:u,routeModules:x}=qf(),{basename:y}=Hf(),{loaderData:p,matches:g}=ij(),b=h.useMemo(()=>Sg(s,l,g,u,o,"data"),[s,l,g,u,o]),f=h.useMemo(()=>Sg(s,l,g,u,o,"assets"),[s,l,g,u,o]),k=h.useMemo(()=>{if(s===o.pathname+o.search+o.hash)return[];let j=new Set,T=!1;if(l.forEach(_=>{let z=u.routes[_.route.id];!z||!z.hasLoader||(!b.some(A=>A.route.id===_.route.id)&&_.route.id in p&&x[_.route.id]?.shouldRevalidate||z.hasClientLoader?T=!0:j.add(_.route.id))}),j.size===0)return[];let S=Jv(s,y,d.unstable_trailingSlashAwareDataRequests,"data");return T&&j.size>0&&S.searchParams.set("_routes",l.filter(_=>j.has(_.route.id)).map(_=>_.route.id).join(",")),[S.pathname+S.search]},[y,d.unstable_trailingSlashAwareDataRequests,p,o,u,b,l,s,x]),w=h.useMemo(()=>sj(f,u),[f,u]),N=dj(f);return h.createElement(h.Fragment,null,k.map(j=>h.createElement("link",{key:j,rel:"prefetch",as:"fetch",href:j,...i})),w.map(j=>h.createElement("link",{key:j,rel:"modulepreload",href:j,...i})),N.map(({key:j,link:T})=>h.createElement("link",{key:j,nonce:i.nonce,...T,crossOrigin:T.crossOrigin??i.crossOrigin})))}function mj(...s){return l=>
11{s.forEach(i=>{typeof i=="function"?i(l):i!=null&&(i.current=l)})}}var hj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{hj&&(window.__reactRouterVersion="7.13.0")}catch{}function xj({basename:s,children:l,unstable_useTransitions:i,window:o}){let d=h.useRef();d.current==null&&(d.current=Vb({window:o,v5Compat:!0}));let u=d.current,[x,y]=h.useState({action:u.action,location:u.location}),p=h.useCallback(g=>{i===!1?y(g):h.startTransition(()=>y(g))},[i]);return h.useLayoutEffect(()=>u.listen(p),[u,p]),h.createElement(Fv,{basename:s,children:l,location:x.location,navigationType:x.action,navigator:u,unstable_useTransitions:i})}var Bf=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Se=h.forwardRef(function({onClick:l,discover:i="render",prefetch:o="none",relative:d,reloadDocument:u,replace:x,state:y,target:p,to:g,preventScrollReset:b,viewTransition:f,unstable_defaultShouldRevalidate:k,...w},N){let{basename:j,unstable_useTransitions:T}=h.useContext(_a),S=typeof g=="string"&&Bf.test(g),_=Af(g,j);g=_.to;let z=Nv(g,{relative:d}),[A,L,F]=oj(o,w),D=pj(g,{replace:x,state:y,target:p,preventScrollReset:b,relative:d,viewTransition:f,unstable_defaultShouldRevalidate:k,unstable_useTransitions:T});function te(he){l&&l(he),he.defaultPrevented||D(he)}let pe=h.createElement("a",{...w,...F,href:_.absoluteURL||z,onClick:_.isExternal||u?l:te,ref:mj(N,L),target:p,"data-discover":!S&&i==="render"?"true":void 0});return A&&!S?h.createElement(h.Fragment,null,pe,h.createElement(cj,{page:z})):pe});Se.displayName="Link";var Er=h.forwardRef(function({"aria-current":l="page",caseSensitive:i=!1,className:o="",end:d=!1,style:u,to:x,viewTransition:y,children:p,...g},b){let f=Yl(x,{relative:g.relative}),k=Ga(),w=h.useContext(Fo),{navigator:N,basename:j}=h.useContext(_a),T=w!=null&&wj(f)&&y===!0,S=N.encodeLocation?N.encodeLocation(f).pathname:f.pathname,_=k.pathname,z=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;i||(_=_.toLowerCase(),z=z?z.toLowerCase():null,S=S.toLowerCase()),z&&j&&(z=zs(z,j)||z);const A=S!=="/"&&S.endsWith("/")?S.length-1:S.length;let L=_===S||!d&&_.startsWith(S)&&_.charAt(A)==="/",F=z!=null&&(z===S||!d&&z.startsWith(S)&&z.charAt(S.length)==="/"),D={isActive:L,isPending:F,isTransitioning:T},te=L?l:void 0,pe;typeof o=="function"?pe=o(D):pe=[o,L?"active":null,F?"pending":null,T?"transitioning":null].filter(Boolean).join(" ");let he=typeof u=="function"?u(D):u;return h.createElement(Se,{...g,"aria-current":te,className:pe,ref:b,style:he,to:x,viewTransition:y},typeof p=="function"?p(D):p)});Er.displayName="NavLink";var gj=h.forwardRef(({discover:s="render",fetcherKey:l,navigate:i,reloadDocument:o,replace:d,state:u,method:x=To,action:y,onSubmit:p,relative:g,preventScrollReset:b,viewTransition:f,unstable_defaultShouldRevalidate:k,...w},N)=>{let{unstable_useTransitions:j}=h.useContext(_a),T=vj(),S=jj(y,{relative:g}),_=x.toLowerCase()==="get"?"get":"post",z=typeof y=="string"&&Bf.test(y),A=L=>{if(p&&p(L),L.defaultPrevented)return;L.preventDefault();let F=L.nativeEvent.submitter,D=F?.getAttribute("formmethod")||x,te=()=>T(F||L.currentTarget,{fetcherKey:l,method:D,navigate:i,replace:d,state:u,relative:g,preventScrollReset:b,viewTransition:f,unstable_defaultShouldRevalidate:k});j&&i!==!1?h.startTransition(()=>te()):te()};return h.createElement("form",{ref:N,method:_,action:S,onSubmit:o?p:A,...w,"data-discover":!z&&s==="render"?"true":void 0})});gj.displayName="Form";function fj(s){return`${s} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Uf(s){let l=h.useContext(Mr);return At(l,fj(s)),l}function pj(s,{target:l,replace:i,state:o,preventScrollReset:d,relative:u,viewTransition:x,unstable_defaultShouldRevalidate:y,unstable_useTransitions:p}={}){let g=Ya(),b=Ga(),f=Yl(s,{relative:u});return h.useCallback(k=>{if(Qv(k,l)){k.preventDefault();let w=i!==void 0?i:Vl(b)===Vl(f),N=()=>g(s,{replace:w,state:o,preventScrollReset:d,relative:u,viewTransition:x,unstable_defaultShouldRevalidate:y});p?h.startTransition(()=>N()):N()}},[b,g,f,i,o,l,s,d,u,x,y,p])}function $r(s){Fa(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let l=h.useRef(Uu(s)),i=h.useRef(!1),o=Ga(),d=h.useMemo(()=>Xv(o.search,i.current?null:l.current),[o.search]),u=Ya(),x=h.useCallback((y,p)=>{const g=Uu(typeof y=="function"?y(new URLSearchParams(d)):y);i.current=!0,u("?"+g,p)},[u,d]);return[d,x]}var yj=0,bj=()=>`__${String(++yj)}__`;function vj(){let{router:s}=Uf("useSubmit"),{basename:l}=h.useContext(_a),i=Hv(),o=s.fetch,d=s.navigate;return h.useCallback(async(u,x={})=>{let{action:y,method:p,encType:g,formData:b,body:f}=Kv(u,l);if(x.navigate===!1){let k=x.fetcherKey||bj();await o(k,i,x.action||y,{unstable_defaultShouldRevalidate:x.unstable_defaultShouldRevalidate,preventScrollReset:x.preventScrollReset,formData:b,body:f,formMethod:x.method||p,formEncType:x.encType||g,flushSync:x.flushSync})}else await d(x.action||y,{unstable_defaultShouldRevalidate:x.unstable_defaultShouldRevalidate,preventScrollReset:x.preventScrollReset,formData:b,body:f,formMethod:x.method||p,formEncType:x.encType||g,replace:x.replace,state:x.state,fromRouteId:i,flushSync:x.flushSync,viewTransition:x.viewTransition})},[o,d,l,i])}function jj(s,{relative:l}={}){let{basename:i}=h.useContext(_a),o=h.useContext(Va);At(o,"useFormAction must be used inside a RouteContext");let[d]=o.matches.slice(-1),u={...Yl(s||".",{relative:l})},x=Ga();if(s==null){u.search=x.search;let y=new URLSearchParams(u.search),p=y.getAll("index");if(p.some(b=>b==="")){y.delete("index"),p.filter(f=>f).forEach(f=>y.append("index",f));let b=y.toString();u.search=b?`?${b}`:""}}return(!s||s===".")&&d.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(u.pathname=u.pathname==="/"?i:Rs([i,u.pathname])),Vl(u)}function wj(s,{relative:l}={}){let i=h.useContext(Tf);At(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Uf("useViewTransitionState"),d=Yl(s,{relative:l});if(!i.isTransitioning)return!1;let u=zs(i.currentLocation.pathname,o)||i.currentLocation.pathname,x=zs(i.nextLocation.pathname,o)||i.nextLocation.pathname;return Mo(d.pathname,x)!=null||Mo(d.pathname,u)!=null}function cn({size:s="lg"}){return e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{style:{width:`${s==="lg"?"225":"150"}px`},children:e.jsx("img",{src:"/assets/logo-1d1f1115.png",alt:"Fantize",className:"w-full"})}),e.jsx("h5",{className:"font-bold text-[2rem] hidden",children:"Fantize"})]})}function go({isActive:s}){return["px-3 lg:px-5 py-2 rounded-md text-sm lg:text-base whitespace-nowrap transition-colors",s?"bg-primary-50 dark:bg-primary-950/40 text-primary-700 dark:text-primary-300 font-semibold":"text-slate-700 dark:text-gray-300 font-medium hover:text-primary-600 dark:hover:text-primary-400 hover:bg-slate-50 dark:hover:bg-gray-800"].join(" ")}function kj(){const{account:s}=zt();return e.jsxs(e.Fragment,{children:[e.jsx("header",{className:"sticky top-0 z-50 bg-white/95 dar
11k:bg-gray-950/90 backdrop-blur supports-[backdrop-filter]:bg-white/80 dark:supports-[backdrop-filter]:bg-gray-950/75 shadow-sm dark:shadow-none border-b border-slate-100 dark:border-gray-800",children:e.jsx("div",{className:"container mx-auto p-4 lg:p-5 lg:px-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Se,{to:"/",className:"flex-shrink-0",children:e.jsx(cn,{size:"lg"})}),e.jsx("nav",{className:"ml-auto",children:e.jsxs("div",{className:"flex items-center space-x-1 sm:space-x-3",children:[e.jsx(Er,{to:"/",end:!0,className:l=>`hidden sm:inline-block ${go(l)}`,children:"Home"}),e.jsx(Er,{to:"/pricing",className:l=>`hidden sm:inline-block ${go(l)}`,children:"Pricing"}),e.jsx(Er,{to:"/contact",className:l=>`hidden sm:inline-block ${go(l)}`,children:"Contact"}),s?e.jsx(Se,{to:"/dashboard",className:"bg-primary-500 hover:bg-primary-700 text-white px-4 lg:px-5 py-2 rounded-md text-sm lg:text-base whitespace-nowrap",children:"Dashboard"}):e.jsxs(e.Fragment,{children:[e.jsx(Er,{to:"/login",className:go,children:"Login"}),e.jsx(Se,{to:"/register",className:"bg-primary-500 hover:bg-primary-700 text-white px-4 lg:px-5 py-2 rounded-md text-sm lg:text-base whitespace-nowrap font-semibold",children:"Sign Up"})]})]})})]})})}),e.jsx("main",{children:e.jsx(Df,{})}),e.jsx("footer",{className:"p-5 lg:px-0 bg-black text-white",children:e.jsx("div",{className:"container mx-auto",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center space-y-4 md:space-y-0",children:[e.jsxs("div",{children:["© ",new Date().getFullYear()," All Rights Reserved fantize.com"]}),e.jsxs("div",{className:"flex items-center space-x-6 text-sm",children:[e.jsx("a",{href:"/privacy",className:"hover:text-primary-300 transition-colors",children:"Privacy Policy"}),e.jsx("a",{href:"/terms",className:"hover:text-primary-300 transition-colors",children:"Terms of Service"}),e.jsx("a",{href:"/security",className:"hover:text-primary-300 transition-colors",children:"Security"})]}),e.jsxs("div",{className:"flex items-center space-x-3 text-xs text-gray-400",children:[e.jsxs("span",{className:"flex items-center space-x-1",children:[e.jsx("svg",{className:"w-3 h-3 text-green-500",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 1a4.5 4.5 0 00-4.5 4.5V9H5a2 2 0 00-2 2v6a2 2 0 002 2h10a2 2 0 002-2v-6a2 2 0 00-2-2h-.5V5.5A4.5 4.5 0 0010 1zm3 8V5.5a3 3 0 10-6 0V9h6z",clipRule:"evenodd"})}),e.jsx("span",{children:"SSL"})]}),e.jsxs("span",{className:"flex items-center space-x-1",children:[e.jsx("svg",{className:"w-3 h-3 text-purple-500",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M10 2a5 5 0 00-5 5v2a2 2 0 00-2 2v5a2 2 0 002 2h10a2 2 0 002-2v-5a2 2 0 00-2-2H7V7a3 3 0 015.905-.75 1 1 0 001.937-.5A5.002 5.002 0 0010 2z"})}),e.jsx("span",{children:"Encrypted"})]})]})]})})})]})}const Ff=h.createContext(null);function Nj(){return h.useContext(Ff)}function dn({items:s,active:l,onChange:i,label:o,className:d=""}){const u=h.useId(),x=p=>["inline-flex items-center gap-1.5 px-4 min-h-11 rounded-full text-sm whitespace-nowrap transition-colors duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400",p?"bg-primary-100 text-primary-700 font-medium dark:bg-primary-900/50 dark:text-primary-300":"text-gray-600 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-700/60 dark:hover:text-gray-200"].join(" "),y=(p,g)=>p==null?null:e.jsx("span",{className:`text-xs rounded-full px-1.5 py-0.5 font-normal ${g?"bg-primary-200 text-primary-700 dark:bg-primary-800 dark:text-primary-200":"bg-gray-200 text-gray-500 dark:bg-gray-700 dark:text-gray-400"}`,children:p});return e.jsxs("div",{className:d,children:[e.jsxs("label",{className:"sm:hidden block",children:[e.jsx("span",{className:"sr-only",children:o}),e.jsx("select",{value:l,onChange:p=>{const g=s.find(b=>b.key===p.target.value);g?.to?window.location.assign(g.to):i?.(p.target.value)},className:"w-full min-h-11 rounded-xl border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700/80 text-gray-900 dark:text-gray-100 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500",children:s.map(p=>e.jsxs("option",{value:p.key,disabled:p.disabled,children:[p.label,p.count!=null?` (${p.count})`:""]},p.key))})]}),e.jsx("nav",{"aria-label":o,className:"hidden sm:flex flex-wrap items-center gap-1",id:u,children:s.map(p=>{const g=p.key===l;
11return p.to?e.jsxs(Er,{to:p.to,"aria-current":g?"page":void 0,className:x(g),children:[p.label,y(p.count,g)]},p.key):e.jsxs("button",{type:"button",onClick:()=>i?.(p.key),"aria-current":g?"page":void 0,disabled:p.disabled,className:x(g),children:[p.label,y(p.count,g)]},p.key)})})]})}function Hn({search:s,children:l,summary:i,onClear:o,clearLabel:d="Clear filters",className:u=""}){return e.jsxs("div",{className:`rounded-2xl bg-white dark:bg-gray-800/80 ring-1 ring-gray-200 dark:ring-gray-700/60 shadow-sm p-3 sm:p-4 ${u}`,children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-end",children:[s&&e.jsxs("label",{className:"flex-1 min-w-[12rem]",children:[e.jsx("span",{className:"sr-only",children:s.label||"Search"}),e.jsx("input",{type:"search",value:s.value,onChange:x=>s.onChange(x.target.value),placeholder:s.placeholder||"Search",className:"w-full min-h-11 rounded-xl border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700/80 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent"})]}),l,o&&e.jsx("button",{type:"button",onClick:o,className:"min-h-11 rounded-xl px-3 text-sm font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:d})]}),i&&e.jsx("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400","aria-live":"polite",children:i})]})}function ha({label:s,value:l,onChange:i,options:o,className:d=""}){return e.jsxs("label",{className:`flex flex-col gap-1 ${d}`,children:[e.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:s}),e.jsx("select",{value:l,onChange:u=>i(u.target.value),className:"min-h-11 rounded-xl border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700/80 text-gray-900 dark:text-gray-100 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent",children:o.map(u=>e.jsx("option",{value:u.value,children:u.label},u.value))})]})}function Vo({items:s,label:l="More actions",align:i="right"}){const[o,d]=h.useState(!1),u=h.useRef(null),x=h.useRef(null),y=h.useId();h.useEffect(()=>{if(!o)return;const b=w=>{u.current&&!u.current.contains(w.target)&&d(!1)},f=w=>{if(w.key==="Escape"&&(d(!1),x.current?.focus()),w.key==="ArrowDown"||w.key==="ArrowUp"){const N=Array.from(u.current?.querySelectorAll("[role=menuitem]:not(:disabled)")||[]);if(!N.length)return;const j=N.indexOf(document.activeElement),T=w.key==="ArrowDown"?(j+1)%N.length:(j-1+N.length)%N.length;N[T].focus(),w.preventDefault()}};return document.addEventListener("mousedown",b),document.addEventListener("keydown",f),u.current?.querySelector("[role=menuitem]:not(:disabled)")?.focus(),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[o]);const p=s.filter(b=>!b.danger),g=s.filter(b=>b.danger);return e.jsxs("div",{className:"relative",ref:u,children:[e.jsx("button",{ref:x,type:"button","aria-haspopup":"menu","aria-expanded":o,"aria-controls":y,"aria-label":l,title:l,onClick:()=>d(b=>!b),className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-xl text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z"})})}),o&&e.jsxs("div",{id:y,role:"menu","aria-label":l,className:`absolute z-30 mt-1 w-52 rounded-xl bg-white dark:bg-gray-800 shadow-lg ring-1 ring-gray-200 dark:ring-gray-700 py-1 ${i==="right"?"right-0":"left-0"}`,children:[p.map(b=>e.jsx("button",{role:"menuitem",type:"button",disabled:b.disabled,title:b.title,onClick:()=>{d(!1),b.onClick()},className:"block w-full min-h-11 px-4 text-left text-sm text-gray-700 hover:bg-gray-50 disabled:opacity-50 dark:text-gray-200 dark:hover:bg-gray-700 focus:outline-none focus-visible:bg-gray-100 dark:focus-visible:bg-gray-700",children:b.label},b.label)),p.length>0&&g.length>0&&e.jsx("div",{role:"separator",className:"my-1 border-t border-gray-100 dark:border-gray-700"}),g.map(b=>e.jsx("button",{role:"menuitem",type:"button",disabled:b.disabled,title:b.title,onClick:()=>{d(!1),b.onClick()},className:"block w-full min-h-11 px-4 text-left text-sm text-rose-600 hover:bg-rose-50 disabled:opacity-50 dark:text-rose-300 dark:hover:bg-rose-900/30 focus:outline-none focus-visible:bg-rose-50 dark:focus-visible:bg-rose-900/30",children:b.label},b.label))]})]})}function Pl({open:s,title:l,children:i,confirmLabel:o="Confirm",cancelLabel:d="Cancel",danger:u,busy:x,onConfirm:y,onCancel:p}){const g=h.useRef(null),b=h.useId();return h.useEffect(()=>{if(!s)return;g.current?.focus();const f=k=>{k.key==="Escape"&&p()};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[s,p]),s?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:p,"aria-hidden":"true"}),e.jsxs("div",{role:"alertdialog","aria-modal":"true","aria-labelledby":b+"-t","aria-describedby":b+"-d",className:"relative z-10 w-full max-w-md rounded-2xl bg-white dark:bg-gray-800 p-6 shadow-2xl",children:[e.jsx("h2",{id:b+"-t",className:"font-display text-lg font-semibold text-gray-900 dark:text-gray-100",children:l}),e.jsx("div",{id:b+"-d",className:"mt-2 text-sm text-gray-600 dark:text-gray-300 space-y-2",children:i}),e.jsxs("div",{className:"mt-5 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx("button",{ref:g,type:"button",onClick:p,disabled:x,className:"min-h-11 rounded-xl bg-gray-100 px-4 text-sm font-medium text-gray-700 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-200 dark:hover:bg-gray-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:d}),e.jsx("button",{type:"button",onClick:y,disabled:x,className:`min-h-11 rounded-xl px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:opacity-50 ${u?"bg-rose-600 hover:bg-rose-700 focus-visible:ring-rose-500":"bg-primary-600 hover:bg-primary-700 focus-visible:ring-primary-500"}`,children:x?"Workingâ¦":o})]})]})]}):null}function If({dirty:s,saving:l,onSave:i,onDiscard:o,error:d,success:u,summary:x}){return!s&&!u&&!d?null:e.jsx("div",{role:"region","aria-label":"Unsaved changes","aria-live":"polite",className:"sticky bottom-20 lg:bottom-4 z-30 mt-6",children:e.jsxs("div",{className:`mx-auto flex max-w-3xl flex-col gap-3 rounded-2xl px-4 py-3 shadow-lg ring-1 sm:flex-row sm:items-center ${d?"bg-rose-50 ring-rose-200 dark:bg-rose-950/60 dark:ring-rose-800":!s&&u?"bg-emerald-50 ring-emerald-200 dark:bg-emerald-950/60 dark:ring-emerald-800":"bg-slate-900 text-white ring-slate-700 dark:bg-slate-800"}`,children:[e.jsx("div",{className:"min-w-0 flex-1 text-sm",children:d?e.jsx("span",{className:"font-medium text-rose-800 dark:text-rose-200",children:d}):!s&&u?e.jsx("span",{className:"font-medium text-emerald-800 dark:text-emerald-200",children:u}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"Unsaved changes"}),x&&e.jsx("span",{className:"ml-2 text-white/75",children:x})]})}),s&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:o,disabled:l,className:`min-h-11 rounded-xl px-3 text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-white ${d?"text-rose-800 hover:bg-rose-100 dar
11k:text-rose-200":"text-white/90 hover:bg-white/10"}`,children:"Discard"}),e.jsx("button",{type:"button",onClick:i,disabled:l,className:"min-h-11 rounded-xl bg-primary-500 px-4 text-sm font-semibold text-white hover:bg-primary-600 disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-white",children:l?"Savingâ¦":"Save changes"})]})]})})}function Sr({id:s,title:l,description:i,children:o,action:d,advanced:u}){const[x,y]=h.useState(!u);return e.jsxs("section",{id:s,"aria-labelledby":s+"-h",className:"scroll-mt-24 rounded-2xl bg-white dark:bg-gray-800/80 ring-1 ring-gray-200 dark:ring-gray-700/60 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 px-5 pt-5 pb-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{id:s+"-h",className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:l}),i&&e.jsx("p",{className:"mt-0.5 text-sm text-gray-500 dark:text-gray-400",children:i})]}),u?e.jsx("button",{type:"button","aria-expanded":x,"aria-controls":s+"-body",onClick:()=>y(p=>!p),className:"min-h-11 flex-none rounded-xl px-3 text-sm font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:x?"Hide advanced":"Show advanced"}):d]}),x&&e.jsx("div",{id:s+"-body",className:"px-5 pb-5 space-y-4",children:o})]})}function $t({label:s,checked:l,onChange:i,help:o,disabled:d}){return e.jsxs("label",{className:`flex items-start gap-3 min-h-11 py-1 ${d?"opacity-60":"cursor-pointer"}`,children:[e.jsx("span",{className:"flex h-11 w-11 -ml-2.5 flex-none items-center justify-center",children:e.jsx("input",{type:"checkbox",checked:!!l,disabled:d,onChange:u=>i(u.target.checked),className:"h-5 w-5 rounded border-gray-300 text-primary-600 focus:ring-primary-500 dark:border-gray-600 dark:bg-gray-700"})}),e.jsxs("span",{className:"pt-2.5",children:[e.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:s}),o&&e.jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 mt-0.5 leading-relaxed",children:o})]})]})}function Oo({columns:s,rows:l,rowKey:i,card:o,caption:d,rowClassName:u,empty:x}){return!l.length&&x?e.jsx(e.Fragment,{children:x}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block overflow-x-auto rounded-xl ring-1 ring-gray-100 dark:ring-gray-700/60",children:e.jsxs("table",{className:"w-full text-sm",children:[d&&e.jsx("caption",{className:"sr-only",children:d}),e.jsx("thead",{children:e.jsx("tr",{children:s.map(y=>e.jsx("th",{scope:"col",className:`bg-gray-50 dark:bg-gray-900/60 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider px-4 py-3 ${y.align==="right"?"text-right":"text-left"} ${y.hideBelowMd?"hidden lg:table-cell":""} ${y.className||""}`,children:y.header},y.key))})}),e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700/50",children:l.map(y=>e.jsx("tr",{className:`text-gray-900 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700/40 ${u?.(y)||""}`,children:s.map(p=>e.jsx("td",{className:`px-4 py-3 align-top ${p.align==="right"?"text-right":""} ${p.hideBelowMd?"hidden lg:table-cell":""} ${p.className||""}`,children:p.render(y)},p.key))},i(y)))})]})}),e.jsx("ul",{className:"md:hidden space-y-3","aria-label":d,children:l.map(y=>e.jsx("li",{className:`rounded-2xl bg-white dark:bg-gray-800/80 ring-1 ring-gray-200 dark:ring-gray-700/60 p-4 ${u?.(y)||""}`,children:o?o(y):e.jsx("dl",{className:"space-y-2",children:s.map(p=>e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("dt",{className:"text-[11px] font-semibold uppercase tracking-wider text-gray-400",children:p.header}),e.jsx("dd",{className:"text-sm text-gray-900 dark:text-gray-100",children:p.render(y)})]},p.key))})},i(y)))})]})}function Rr({message:s,onRetry:l,retryLabel:i="Try again"}){return e.jsx("div",{role:"alert",className:"rounded-2xl bg-rose-50 text-rose-800 ring-1 ring-inset ring-rose-200 px-4 py-3 text-sm dark:bg-rose-900/30 dark:text-rose-200 dark:ring-rose-700/50",children:e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("span",{children:s}),l&&e.jsx("button",{type:"button",onClick:l,className:"min-h-11 self-start rounded-xl bg-white px-3 text-sm font-medium text-rose-800 ring-1 ring-rose-300 hover:bg-rose-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-rose-500 dark:bg-slate-800 dark:text-rose-200 dark:ring-rose-500/50",children:i})]})})}function qn({message:s,tone:l="green"}){if(!s)return null;const i={green:"bg-emerald-50 text-emerald-800 ring-emerald-200 dark:bg-emerald-900/30 dark:text-emerald-200 dark:ring-emerald-700/50",blue:"bg-sky-50 text-sky-800 ring-sky-200 dark:bg-sky-900/30 dark:text-sky-200 dark:ring-sky-700/50",amber:"bg-amber-50 text-amber-900 ring-amber-200 dark:bg-amber-900/30 dark:text-amber-200 dark:ring-amber-700/50",red:"bg-rose-50 text-rose-800 ring-rose-200 dark:bg-rose-900/30 dark:text-rose-200 dark:ring-rose-700/50"}[l];return e.jsx("div",{role:"status","aria-live":"polite",className:`mb-4 rounded-2xl px-4 py-3 text-sm r
11ing-1 ring-inset ${i}`,children:s})}function Es({to:s,children:l}){return e.jsxs(Se,{to:s,className:"inline-flex min-h-11 items-center gap-1 text-sm font-medium text-primary-600 hover:underline dark:text-primary-400 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 rounded-lg",children:[l,e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]})}const ht={home:"M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25",search:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 15.803a7.5 7.5 0 0010.607 10.607z",templates:"M3.75 6A2.25 2.25 0 016 3.75h2.25A2.25 2.25 0 0110.5 6v2.25a2.25 2.25 0 01-2.25 2.25H6A2.25 2.25 0 013.75 8.25V6zM3.75 15.75A2.25 2.25 0 016 13.5h2.25a2.25 2.25 0 012.25 2.25V18a2.25 2.25 0 01-2.25 2.25H6A2.25 2.25 0 013.75 18v-2.25zM13.5 6a2.25 2.25 0 012.25-2.25H18A2.25 2.25 0 0120.25 6v2.25A2.25 2.25 0 0118 10.5h-2.25a2.25 2.25 0 01-2.25-2.25V6zM13.5 15.75a2.25 2.25 0 012.25-2.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-2.25a2.25 2.25 0 01-2.25-2.25v-2.25z",results:"M3.75 3v11.25A2.25 2.25 0 006 16.5h2.25M3.75 3h-1.5m1.5 0h16.5m0 0h1.5m-1.5 0v11.25A2.25 2.25 0 0118 16.5h-2.25m-7.5 0h7.5m-7.5 0l-1 3m8.5-3l1 3m0 0l.5 1.5m-.5-1.5h-9.5m0 0l-.5 1.5m.75-9l3-3 2.148 2.148A12.061 12.061 0 0116.5 7.605",calendar:"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5",exclude:"M18.364 5.636L5.636 18.364m12.728 0L5.636 5.636M21 12a9 9 0 11-18 0 9 9 0 0118 0z",reply:"M2.25 12.76c0 1.6 1.123 2.994 2.707 3.227 1.068.157 2.148.279 3.238.364.466.037.893.281 1.153.671L12 21l2.652-3.978c.26-.39.687-.634 1.153-.67 1.09-.086 2.17-.208 3.238-.365 1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.
11123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z",bell:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0",lifecycle:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99",broom:"M19.5 12c0-1.232-.046-2.453-.138-3.662a4.006 4.006 0 00-3.7-3.7 48.678 48.678 0 00-7.324 0 4.006 4.006 0 00-3.7 3.7c-.017.22-.032.441-.046.662M19.5 12l3-3m-3 3l-3-3m-12 3c0 1.232.046 2.453.138 3.662a4.006 4.006 0 003.7 3.7 48.656 48.656 0 007.324 0 4.006 4.006 0 003.7-3.7c.017-.22.032-.441.046-.662M4.5 12l3 3m-3-3l-3 3",campaign:"M19.114 5.636a9 9 0 010 12.728M16.463 8.288a5.25 5.25 0 010 7.424M6.75 8.25l4.72-4.72a.75.75 0 011.28.53v15.88a.75.75 0 01-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.01 9.01 0 012.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25H6.75z",route:"M7.5 21L3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5",bolt:"M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z",contacts:"M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z",list:"M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zM3.75 12h.007v.008H3.75V12zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm-.375 5.25h.007v.008H3.75v-.008zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z",pipeline:"M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 01-.659 1.591l-5.432 5.432a2.25 2.25 0 00-.659 1.591v2.927a2.25 2.25 0 01-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 00-.659-1.591L3.659 7.409A2.25 2.25 0 013 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32
110 0112 3z",chat:"M20.25 8.511c.884.284 1.5 1.128 1.5 2.097v4.286c0 1.136-.847 2.1-1.98 2.193-.34.027-.68.052-1.02.072v3.091l-3-3c-1.354 0-2.694-.055-4.02-.163a2.115 2.115 0 01-.825-.242m9.345-8.334a2.126 2.126 0 00-.476-.095 48.64 48.64 0 00-8.048 0c-1.131.094-1.976 1.057-1.976 2.192v4.286c0 .837.46 1.58 1.155 1.951m9.345-8.334V6.637c0-1.621-1.152-3.026-2.76-3.235A48.455 48.455 0 0011.25 3c-2.115 0-4.198.137-6.24.402-1.608.209-2.76 1.614-2.76 3.235v6.226c0 1.621 1.152 3.026 2.76 3.235.577.075 1.157.14 1.74.194V21l4.155-4.155",orders:"M2.25 3h1.386c.51 0 .955.343 1.087.835l.383 1.437M7.5 14.25a3 3 0 00-3 3h15.75m-12.75-3h11.218c1.121-2.3 2.1-4.684 2.924-7.138a60.114 60.114 0 00-16.536-1.84M7.5 14.25L5.106 5.272M6 20.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm12.75 0a.75.75 0 11-1.5 0 .75.75 0 011.5 0z",gauge:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z",cog:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281zM15 12a3 3 0 11-6 0 3 3 0 016 0z",users:"M18 18.72a9.094 9.094 0 003.741-.479 3 3 0 00-4.682-2.72m.94 3.198l.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0112 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 016 18.719m12 0a5.971 5.971 0 00-.941-3.197m0 0A5.995 5.995 0 0012 12.75a5.995 5.995 0 00-5.058 2.772m0 0a3 3 0 00-4.681 2.72 8.986 8.986 0 003.74.477m.94-3.197a5.971 5.971 0 00-.94 3.197M15 6.75a3 3 0 11-6 0 3 3 0 016 0zm6 3a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0zm-13.5 0a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z",link:"M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244",analytics:"M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z",brand:"M9.53 16.122a3 3 0 00-5.78 1.128 2.25 2.25 0 01-2.4 2.245 4.5 4.5 0 008.4-2.245c0-.399-.078-.78-.22-1.128zm0 0a15.998 15.998 0 003.388-1.62m-5.043-.025a15.994 15.994 0 011.622-3.395m3.42 3.42a15.995 15.995 0 004.764-4.648l3.876-5.814a1.151 1.151 0 00-1.597-1.597L14.146 6.32a15.996 15.996 0 00-4.649 4.763m3.42 3.42a6.776 6.776 0 00-3.42-3.42",help:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z",flask:"M9.75 3.104v5.714a2.25 2.25 0 01-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 014.5 0m0 0v5.714c0 .597.237 1.17.659 1.591L19.8 15.3M14.25 3.104c.251.023.501.05.75.082M19.8 15.3l-1.57.393A9.065 9.065 0 0112 15a9.065 9.065 0 00-6.23-.693L5 14.5m14.8.8l1.402 1.402c1.232 1.232.65 3.318-1.067 3.611A48.309 48.309 0 0112 21c-2.773 0-5.491-.235-8.135-.687-1.718-.293-2.3-2.379-1.067-3.61L5 14.5",user:"M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z",block:"M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"},im=[{key:"overview",entries:[{key:"overview",label:"Overview",path:"/dashboard",icon:ht.home,exact:!0,adminOnly:!0,description:"Whether Fantize is operating normally, what needs attention, and what to do next."}]},{key:"prospecting",label:"Prospecting",adminOnly:!0,entries:[{key:"searches",label:"Searches",path:"/dashboard/prospecting/searches",icon:ht.search,adminOnly:!0,description:"Saved lead searches: review the criteria, run, duplicate or schedule them."},{key:"templates",label:"Templates",path:"/dashboard/prospecting/templates",icon:ht.templates,adminOnly:!0,description:"Ready-made starting points for a new search."},{key:"template-library",label:"Template Library",path:"/dashboard/prospecting/templates/library",parent:"templates",adminOnly:!0,description:"Create, edit and organise the search templates this workspace uses."},{key:"results",label:"Results",path:"/dashboard/prospecting/results",icon:ht.results,adminOnly:!0,description:"Every search that has run, and the leads each one found."},{key:"result",label:"Search results",path:"/dashboard/prospecting/results/:id",parent:"results",adminOnly:!0,hidden:!0},{key:"schedules",label:"Prospecting Schedules",path:"/dashboard/prospecting/schedules",icon:ht.calendar,adminOnly:!0,description:"Searches that re-run on a cadence and surface new matches for review."},{key:"exclusions",label:"Exclusions",path:"/dashboard/prospecting/exclusions",icon:ht.exclude,adminOnly:!0,description:"Domains, emails, companies and profiles kept out of every search."}]},{key:"lead-ops",label:"Lead Operations",entries:[{key:"review",label:"Reply Review",path:"/dashboard/leads/review",icon:ht.reply,description:"Replies from outbound campaigns that are waiting for a decision, and the record of past decisions."},{key:"inbound",label:"Inbound Review",path:"/dashboard/leads/inbound",icon:ht.chat,adminOnly:!0,description:"Mail that arrived at a shared mailbox, what Fantize thinks each one is, and what is still waiting for a person."},{key:"inbound-item",label:"Inbound conversation",path:"/dashboard/leads/inbound/:id",parent:"inbound",adminOnly:!0,hidden:!0},{key:"activity",label:"Activity & Issues",path:"/dashboard/leads/activity",icon:ht.bell,de
11scription:"What is waiting for a person, what has been processed, and what could not complete."},{key:"lifecycle",label:"Lead Lifecycle",path:"/dashboard/leads/lifecycle",icon:ht.lifecycle,adminOnly:!0,description:"Where every engaged lead currently lives: outbound only, waiting for review, handed to HubSpot, or closed."},{key:"cleanup",label:"Cleanup Review",path:"/dashboard/leads/cleanup",icon:ht.broom,adminOnly:!0,description:"HubSpot contacts synced for calling that never qualified and are past the cleanup window."},{key:"dnc",label:"Do Not Contact",path:"/dashboard/leads/do-not-contact",icon:ht.block,adminOnly:!0,description:"Addresses on the do-not-contact list whose provider block still needs confirming."},{key:"review-legacy",label:"Reply Review (legacy)",path:"/dashboard/leads/review-legacy",parent:"review",adminOnly:!0,hidden:!0}]},{key:"campaigns",label:"Campaigns & Outreach",adminOnly:!0,entries:[{key:"campaigns",label:"Campaigns",path:"/dashboard/campaigns",icon:ht.campaign,adminOnly:!0,description:"Email, SMS and social campaigns created and sent from Fantize."},{key:"first-campaign",label:"First campaign setup",path:"/dashboard/campaigns/first-campaign",parent:"campaigns",adminOnly:!0,hidden:!0},{key:"campaign-routing",label:"Campaign Routing",path:"/dashboard/campaigns/routing",icon:ht.route,adminOnly:!0,description:"Which salesperson each outbound campaign hands off to, and the state of every campaign."},{key:"outreach",label:"Outreach Tracker",path:"/dashboard/outreach",icon:ht.bolt,adminOnly:!0,description:"Manual outreach you are tracking by hand, alongside past prospect research."}]},{key:"crm",label:"Contacts & CRM",adminOnly:!0,entries:[{key:"contacts",label:"Contacts",path:"/dashboard/contacts",icon:ht.contacts,adminOnly:!0,description:"Every contact in this workspace."},{key:"lists",label:"Lists & Segments",path:"/dashboard/lists",icon:ht.list,adminOnly:!0,description:"Groups of contacts for campaigns and outreach."},{key:"pipeline",label:"Fan Pipeline",path:"/dashboard/pipeline",icon:ht.pipeline,adminOnly:!0,description:"Engagement level of each contact, from prospect to superfan."},{key:"conversations",label:"Conversations",path:"/dashboard/conversations",icon:ht.chat,adminOnly:!0,description:"Fan conversations started by campaigns."},{key:"orders",label:"Orders",path:"/dashboard/orders",icon:ht.orders,adminOnly:!0,description:"Revenue and order history from campaigns."}]},{key:"automation",label:"Automation & Integrations",adminOnly:!0,entries:[{key:"readiness",label:"Operational Readiness",path:"/dashboard/automation/readiness",icon:ht.gauge,adminOnly:!0,description:"Technical prerequisites, provider connectivity, the current processing mode and campaign exceptions, stated separately."},{key:"automation-settings",label:"Automation Settings",path:"/dashboard/automation/settings",icon:ht.cog,adminOnly:!0,description:"How replies qualify, what Fantize writes to HubSpot, and the safety protections around handoffs."},{key:"lead-assignment",label:"Lead Assignment",path:"/dashboard/automation/lead-assignment",icon:ht.users,adminOnly:!0,description:"Who may receive new leads, the default owner, and conditional assignment rules."},{key:"lifecycle-hubspot",label:"Lifecycle & HubSpot",path:"/dashboard/automation/lifecycle-hubspot",icon:ht.lifecycle,adminOnly:!0,description:"How lifecycle stages, lead statuses and fields map into HubSpot."},{key:"notifications",label:"Notifications",path:"/dashboard/automation/notifications",icon:ht.bell,adminOnly:!0,description:"Who is told when a lead qualifies, through which channel, and whether each channel can deliver."},{key:"test-mode",label:"Test Mode",path:"/dashboard/automation/test-mode",icon:ht.flask,adminOnly:!0,description:"Dry-run a reply scenario and see the outcome before anything is live."},{key:"integrations",label:"Integrations",path:"/dashboard/integrations",icon:ht.link,adminOnly:!0,description:"HubSpot, Instantly, data providers, social accounts, exports and usage."}]},{key:"analytics",label:"Analytics",adminOnly:!0,entries:[{key:"analytics",label:"Analytics",path:"/dashboard/analytics",icon:ht.analytics,adminOnly:!0,description:"Reporting across leads, campaigns, contacts and API cost."}]},{key:"admin",label:"Administration",adminOnly:!0,entries:[{key:"users",label:"Team & Roles",path:"/dashboard/users",icon:ht.users,adminOnly:!0,description:"Invite people into this workspace and set what each role can change."},{key:"brand",label:"Brand Settings",path:"/dashboard/brand",icon:ht.brand,adminOnly:!0,description:"How your brand appears in campaigns and social-proof messages."}]},{key:"support",entries:[{key:"help",label:"Help",path:"/dashboard/help",icon:ht.help,description:"How reply review works and what each decision does."},{key:"preferences",label:"Account & Preferences",path:"/dashboard/preferences",icon:ht.user,hidden:!0,description:"Your profile, appearance and account."}]}],Vf=im.flatMap(s=>s.entries),$o=Object.fromEntries(Vf.map(s=>[s.key,s]));function Gf(s){return im.filter(l=>s||!l.adminOnly).map(l=>({...l,entries:l.entries.filter(i=>!i.parent&&!i.hidden&&(s||!i.adminOnly))}
11)).filter(l=>l.entries.length>0)}function _j(s){return(s?["overview","review","searches","campaigns"]:["review","activity","help"]).map(i=>$o[i])}function Cg(s,l){return s.includes(":")?new RegExp("^"+s.replace(/:[^/]+/g,"[^/]+")+"$").test(l):l===s}function om(s){const l=Vf.filter(i=>Cg(i.path,s)||i.also&&i.also.some(o=>Cg(o,s))?!0:!i.exact&&!i.path.includes(":")&&s.startsWith(i.path+"/"));return l.length?l.sort((i,o)=>o.path.length-i.path.length)[0]:null}function Do(s,l){const i=om(l);if(!i)return!1;if(i.key===s.key)return!0;let o=i.parent?$o[i.parent]:void 0;for(;o;){if(o.key===s.key)return!0;o=o.parent?$o[o.parent]:void 0}return!1}function Sj(s){return im.find(l=>l.entries.some(i=>i.key===s.key))}function Cj(s,l,i){const o=om(s);if(!o)return i?[{label:i}]:[];const d=[];let u=o;for(;u;)d.unshift(u),u=u.parent?$o[u.parent]:void 0;const x=[],y=Sj(d[0]);return y?.label&&l&&x.push({label:y.label}),d.forEach((p,g)=>{const b=g===d.length-1;x.push(b&&!i?{label:p.label}:{label:p.label,to:p.path.includes(":")?void 0:p.path})}),i&&x.push({label:i}),x}function Aj(s,l){const i=om(s);return`${l||i?.label||"Fantize"} | Fantize`}const Ej=[{from:"/dashboard/leads",to:s=>{const l=s.get("tab");return`/dashboard/prospecting/${{templates:"templates",searches:"searches",runs:"results",schedules:"schedules",exclusions:"exclusions"}[l||""]||"searches"}`}},{from:"/dashboard/leads/library",to:()=>"/dashboard/prospecting/templates/library"},{from:"/dashboard/leads/schedules",to:()=>"/dashboard/prospecting/schedules"},{from:"/dashboard/leads/campaign-mapping",to:()=>"/dashboard/campaigns/routing"},{from:"/dashboard/leads/assignment",to:()=>"/dashboard/automation/lead-assignment"},{from:"/dashboard/leads/mapping",to:()=>"/dashboard/automation/lifecycle-hubspot"},{from:"/dashboard/leads/notifications",to:()=>"/dashboard/automation/notifications"},{from:"/dashboard/leads/test",to:()=>"/dashboard/automation/test-mode"},{from:"/dashboard/leads/go-live",to:()=>"/dashboard/automation/readiness"},{from:"/dashboard/leads/settings",to:()=>"/dashboard/automation/settings"},{from:"/dashboard/leads/engagement-settings",to:()=>"/dashboard/automation/settings"},{from:"/dashboard/leads/sync-errors",to:()=>"/dashboard/leads/activity?tab=issues"},{from:"/dashboard/onboarding",to:()=>"/dashboard/campaigns/first-campaign"}],Tj="/dashboard/leads/review",Rj={year:"numeric",month:"short",day:"numeric"},zj={month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},Lj={hour:"2-digit",minute:"2-digit"};function Dr(s){if(s==null||s==="")return null;if(s instanceof Date)return isNaN(s.getTime())?null:s;if(typeof s=="number"){const o=new Date(s);return isNaN(o.getTime())?null:o}const l=String(s).trim();if(!l)return null;let i;if(/^\d{4}-\d{2}-\d{2}$/.test(l)){const[o,d,u]=l.split("-").map(Number);i=new Date(o,d-1,u)}else!(/[zZ]$/.test(l)||/[+-]\d{2}:?\d{2}$/.test(l))&&/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}/.test(l)?i=new Date(l.replace(" ","T")+"Z"):i=new Date(l);return isNaN(i.getTime())?null:i}function Ke(s,l=Rj,i="â"){const o=Dr(s);return o?o.toLocaleDateString(void 0,l):i}function Ia(s,l=zj,i="â"){const o=Dr(s);return o?o.toLocaleString(void 0,l):i}function Yf(s,l=Lj,i="â"){const o=Dr(s);return o?o.toLocaleTimeString(void 0,l):i}function Gt(s){const l=Dr(s);return l?l.getTime():0}function Pf(s){const l=Dr(s);return l?Date.now()-l.getTime():Number.POSITIVE_INFINITY}class Mj{events=[];storageKey="fantize_analytics_events";constructor(){this.loadEvents()}loadEvents(){try{const l=localStorage.getItem(this.storageKey);l&&(this.events=JSON.parse(l))}catch(l){console.error("[Analytics] Failed to load events:",l)}}saveEvents(){try{const l=this.events.slice(-1e3);localStorage.setItem(this.storageKey,JSON.stringify(l))}catch(l){console.error("[Analytics] Failed to save events:",l)}}track(l,i){const o={event:l,timestamp:new Date().toISOString(),userId:this.getUserId(),properties:i};this.events.push(o),this.saveEvents(),console.log(`[Analytics] ${l}`,i||{}),this.sendToBackend(o)}async sendToBackend(l){}trackError(l,i,o){const d=i instanceof Error?i.message:i,u=i instanceof Error?i.stack:void 0,x={event:"error",timestamp:new Date().toISOString(),userId:this.getUserId(),properties:{context:l,errorMessage:d,errorStack:u,...o},error:d};this.events.push(x),this.saveEvents(),console.error(`[Analytics Error] ${l}:`,d,o||{})}trackApiRequest(l,i,o,d,u){this.track("api_request",{endpoint:l,method:i,success:o,duration:d,error:u})}getEvents(){return[...this.events]}getEventsByType(l){return this.events.filter(i=>i.event===l)}getFunnelStats(){const l=["wizard_started","wizard_step_1_completed","wizard_step_2_started","wizard_step_2_completed","wizard_step_3_started","campaign_sent","wizard_completed"],i={};return l.forEach(o=>{i[o]=this.getEventsByType(o).length}),i}getErrorSummary(){const l=this.events.filter(o=>o.event==="error"),i={};return l.forEach(o=>{const d=o.properties?.context||"unknown";i[d]=(i[d]||0)+1}),{totalErrors:l.length,errorsByContext:i,recentErrors:l.slice(-10)}}exportData(){const l={events:this.events,funnelStats:this.getFunnelStats(),errorSummary:this.getErrorSummary(),exportedAt:new Date().toISOString()},i=new Blob([JSON.stringify(l,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),d=document.createElement("a");d.href=o,d.download=`fantize-analytics-${Date.now()}.json`,d.click(),URL.revokeObjectURL(o)}clear(){this.events=[],localStorage.removeItem(this.storageKey),console.log("[Analytics] All events cleared")}getUserId(){try{const l=localStorage.getItem("fantize_token");return l?btoa(l).slice(0,16):void 0}catch{return}}}const Ie=new Mj;typeof window<"u"&&(window.fantizeAnalytics=Ie);
11function Oj(){const[s,l]=h.useState(!1),[i,o]=h.useState({}),[d,u]=h.useState({totalErrors:0,errorsByContext:{},recentErrors:[]}),[x,y]=h.useState({total:0,success:0,failed:0});h.useEffect(()=>{window.showAnalyticsDebugger=()=>l(!0),window.hideAnalyticsDebugger=()=>l(!1);const b=setInterval(()=>{s&&p()},2e3);return()=>clearInterval(b)},[s]);const p=()=>{const b=Ie.getFunnelStats(),f=Ie.getErrorSummary(),k=Ie.getEventsByType("api_request"),w=k.filter(j=>j.properties?.success===!0).length,N=k.filter(j=>j.properties?.success===!1).length;o(b),u(f),y({total:k.length,success:w,failed:N})};if(h.useEffect(()=>{s&&p()},[s]),!s)return null;const g=(b,f)=>{const k=i[b]||0,w=i[f]||0;return k===0?0:Math.round(w/k*100)};return e.jsxs("div",{className:"fixed bottom-4 right-4 w-96 bg-white border-2 border-gray-800 rounded-lg shadow-2xl z-50 max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"bg-gray-800 text-white px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 bg-green-400 rounded-full animate-pulse"}),e.jsx("h3",{className:"font-bold text-sm",children:"Analytics Debugger"})]}),e.jsx("button",{onClick:()=>l(!1),className:"text-white hover:text-red-400 transition-colors",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"w-5 h-5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-xs uppercase text-gray-500 mb-2",children:"Activation Funnel"}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsx(zn,{label:"Wizard Started",count:i.wizard_started||0,percentage:100}),e.jsx(zn,{label:"Step 1 Completed",count:i.wizard_step_1_completed||0,percentage:g("wizard_started","wizard_step_1_completed")}),e.jsx(zn,{label:"Step 2 Started",count:i.wizard_step_2_started||0,percentage:g("wizard_started","wizard_step_2_started")}),e.jsx(zn,{label:"Step 2 Completed",count:i.wizard_step_2_completed||0,percentage:g("wizard_started","wizard_step_2_completed")}),e.jsx(zn,{label:"Step 3 Started",count:i.wizard_step_3_started||0,percentage:g("wizard_started","wizard_step_3_started")}),e.jsx(zn,{label:"Campaign Sent",count:i.campaign_sent||0,percentage:g("wizard_started","campaign_sent"),isLast:!0}),e.jsx(zn,{label:"Wizard Completed",count:i.wizard_completed||0,percentage:g("wizard_started","wizard_completed"),isLast:!0})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-xs uppercase text-gray-500 mb-2",children:"API Requests"}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[e.jsxs("div",{className:"bg-gray-100 rounded p-2",children:[e.jsx("div",{className:"text-gray-500",children:"Total"}),e.jsx("div",{className:"text-lg font-bold",children:x.total})]}),e.jsxs("div",{className:"bg-green-50 rounded p-2",children:[e.jsx("div",{className:"text-green-600",children:"Success"}),e.jsx("div",{className:"text-lg font-bold text-green-600",children:x.success})]}),e.jsxs("div",{className:"bg-red-50 rounded p-2",children:[e.jsx("div",{className:"text-red-600",children:"Failed"}),e.jsx("div",{className:"text-lg font-bold text-red-600",children:x.failed})]})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-bold text-xs uppercase text-gray-500 mb-2",children:["Errors (",d.totalErrors,")"]}),d.totalErrors>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-1 mb-2",children:Object.entries(d.errorsByContext).map(([b,f])=>e.jsxs("div",{className:"flex items-center justify-between text-xs bg-red-50 rounded px-2 py-1",children:[e.jsx("span",{className:"font-mono text-red-700",children:b}),e.jsx("span",{className:"font-bold text-red-600",children:f})]},b))}),e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Recent:"}),e.jsx("div",{className:"space-y-1 max-h-40 overflow-y-auto",children:d.recentErrors.map((b,f)=>e.jsxs("div",{className:"bg-red-50 border-l-2 border-red-400 rounded px-2 py-1 text-xs",children:[e.jsx("div",{className:"font-mono text-red-700 font-semibold",children:b.properties?.context}),e.jsx("div",{className:"text-red-600 truncate",children:b.properties?.errorMessage}),e.jsx("div",{className:"text-gray-400 text-[10px]",children:Yf(b.timestamp)})]},f))})]}):e.jsx("div",{className:"text-xs text-green-600 bg-green-50 rounded px-2 py-1",children:"No errors logged"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("button",{onClick:()=>p(),className:"w-full bg-gradient-to-b from-primary-500 to-primary-600 hover:from-primary-600 hover:to-primary-700 text-white px-3 py-2 rounded-lg text-xs font-medium shadow-sm",children:"Refresh Stats"}),e.jsx("button",{onClick:()=>Ie.exportData(),className:"w-full bg-green-500 hover:bg-green-600 text-white px-3 py-2 rounded text-xs font-medium",children:"Export Data"}),e.jsx("button",{onClick:()=>{confirm("Are you sure you want to clear all analytics data?")&&(Ie.clear(),p())},className:"w-full bg-red-500 hover:bg-red-600 text-white px-3 py-2 rounded text-xs font-medium",children:"Clear Data"})]})]}),e.jsxs("div",{className:"bg-gray-50 px-4 py-2 text-[10px] text-gray-500 border-t",children:["Console: ",e.jsx("code",{className:"bg-gray-200 px-1 rounded",children:"window.fantizeAnalytics"})]})]})}function zn({label:s,count:l,percentage:i,isLast:o}){const d=()=>i>=80?"bg-green-500":i>=50?"bg-yellow-500":"bg-red-500";return e.jsxs("div",{className:o?"border-t pt-2 mt-2":"",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-gray-700",children:s}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold",children:l}),e.jsxs("span",{className:`text-xs font-bold ${i>=50?"text-green-600":"text-red-600"}`,children:[i,"%"]})]})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-1.5",children:e.jsx("div",{className:`h-1.5 rounded-full transition-all ${d()}`,style:{width:`${Math.min(i,100)}%`}})})]})}function Wa({d:s,className:l="w-5 h-5"}){return s?e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:l,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:s})}):e.jsx("span",{className:l,"aria-hidden":"true"})}const ma="focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400";function Qf({entry:s,active:l,onNavigate:i,collapsed:o,compact:d}){return o?e.jsx(Se,{to:s.path,onClick:i,title:s.label,"aria-label":s.label,"aria-current":l?"page":void 0,className:`flex items-center justify-center w-11 h-11 mx-auto rounded-xl mb-0.5 transition-colors ${ma} ${l?"bg-primary-100 text-primary-700 dark:bg-primary-900/50 dark:text-primary-300":"text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-200"}`,children:e.jsx(Wa,{d:s.icon})}):e.jsxs(Se,{to:s.path,onClick:i,"aria-current":l?"page":void 0,className:`flex items-center gap-3 px-3 min-h-11 rounded-xl text-sm transition-colors ${ma} ${d?"py-1.5":"py-2"} ${l?"font-semibold bg-primary-50 text-primary-700 dark:bg-primary-900/40 dark:text-primary-200 border-l-2 border-primary-500 dark:border-primary-400 pl-[10px]":"font-medium text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"}`,children:[e.jsx(Wa,{d:s.icon,className:"w-5 h-5 flex-none"}),e.jsx("span",{className:"flex-1 truncate",children:s.label})]})}function Ag({pathname:s,account:l,isAdmin:i,onNavigate:o,collapsed:d=!1,onToggle:u}){const x=Ja(),y=Gf(i),[p,g]=h.useState(()=>{try{return JSON.parse(sessionStorage.getItem("fantize-nav-groups")||"{}")}catch{return{}}});function b(k){g(w=>{const N={...w,[k]:w[k]===!1};try{sessionStorage.setItem("fantize-nav-groups",JSON.stringify(N))}catch{}return N})}const f=k=>k.entries.some(w=>Do(w,s));return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:`relative flex border-b border-gray-100 dark:border-gray-800 flex-shrink-0 min-h-[65px] ${d?"flex-col items-center justify-center gap-1.5 p-2":"items-center justify-center px-4 py-3"}`,children:[e.jsx(Se,{to:"/",onClick:o,"aria-label":"Fantize home",className:`flex min-h-11 items-center justify-center rounded-lg ${ma} ${d?"":"-translate-x-[15px]"}`,children:e.jsx(cn,{size:"sm"})}),u&&e.jsx("button",{type:"button",onClick:u,"aria-label":d?"Expand sidebar":"Collapse sidebar","aria-expanded":!d,title:d?"Expand sidebar":"Collapse sidebar",className:`flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-lg text-gray-400 dark:text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors ${ma} ${d?"":"absolute right-1 top-1/2 -translate-y-1/2"}`,children:e.jsx(Wa,{d:d?"M8.25 4.5l7.5 7.5-7.5 7.5":"M15.75 19.5L8.25 12l7.5-7.5",className:"w-4 h-4"})})]}),e.jsx("nav",{"aria-label":"Main",className:"flex-1 overflow-y-auto py-3 px-2",children:y.map(k=>{const w=!!k.label&&i,N=!w||p[k.key]!==!1||f(k);return e.jsxs("div",{className:"mb-1",children:[w&&!d&&e.jsxs("button",{type:"button",onClick:()=>b(k.key),"aria-expanded":N,className:`w-full min-h-11 group/hdr flex items-center justify-between text-[11px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-500 px-3 pt-3 pb-1 hover:text-gray-700 dark:hover:text-gray-300 transition-colors rounded-lg ${ma}`,children:[e.jsx("span",{children:k.label}),e.jsx(Wa,{d:"M19.5 8.25l-7.5 7.5-7.5-7.5",className:`w-3.5 h-3.5 text-gray-300 dark:text-gray-600 group-hover/hdr:text-gray-500 transition-transform motion-reduce:transition-none ${N?"":"-rotate-90"}`})]}),w&&d&&e.jsx("div",{className:"border-t border-gray-100 dark:border-gray-800 mx-2 mt-3 mb-1.5",role:"separator"}),(d||N)&&k.entries.map(j=>e.jsx(Qf,{entry:j,active:Do(j,s),onNavigate:o,collapsed:d,compact:w},j.key))]},k.key)})}),e.jsx("div",{className:`flex-shrink-0 border-t border-gray-100 dark:border-gray-800 ${d?"p-2":"p-3 space-y-1"}`,children:d?e.jsx(Se,{to:"/dashboard/preferences",onClick:o,title:l?.name??"Account & Preferences","aria-label":"Account & Preferences","aria-current":s.startsWith("/dashboard/preferences")?"page":void 0,className:`mx-auto flex h-11 w-11 items-center justify-center rounded-xl bg-gradient-to-br from-primary-500 to-violet-600 text-sm font-bold text-white shadow-sm hover:opacity-90 ${ma}`,children:(l?.name?.[0]??"?").toUpperCase()}):e.jsxs(e.Fragment,{children:[e.jsxs(Se,{to:"/dashboard/preferences",onClick:o,"aria-label":"Account & Preferences","aria-current":s.startsWith("/dashboard/preferences")?"page":void 0,className:`flex items-center gap-3 w-full px-2 py-2 min-h-11 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors group ${ma}`,children:[e.jsx("div",{className:"flex-shrink-0 w-9 h-9 rounded-xl bg-gradient-to-br from-primary-500 to-violet-600 flex items-center justify-center text-sm font-bold text-white shadow-sm","aria-hidden":"true",children:(l?.name?.[0]??"?").toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 truncate group-hover:text-primary-700 dark:group-hover:text-primary-300",children:l?.name}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 truncate",children:l?.email})]}),e.jsx(Wa,{d:"M8.25 4.5l7.5 7.5-7.5 7.5",className:"w-4 h-4 text-gray-300 dark:text-gray-600 group-hover:text-primary-500 flex-shrink-0"})]}),x.canPreview&&!x.active&&e.jsx("button",{type:"button",onClick:x.enter,className:`w-full min-h-11 rounded-xl px-3 text-left text-xs font-medium text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200 ${ma}`,children:"View as Marketing (preview)"})]})})]})}function $j(){const{account:s,isAdmin:l}=zt(),i=Ja(),o=i.asMarketing?!1:l,d=Ga(),[u,x]=h.useState(!1),[y,p]=h.useState(!1),[g,b]=h.useState(()=>{try{return localStorage.getItem("fantize-sidebar-collapsed")==="true"}catch{return!1}}),f=()=>{b(j=>{const T=!j;try{localStorage.setItem("fantize-sidebar-collapsed",String(T))}catch{}return T})};h.useEffect(()=>{x(!1),p(!1)},[d.pathname,d.search]),h.useEffect(()=>{if(!u&&!y)return;const j=T=>{T.key==="Escape"&&(x(!1),p(!1))};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[u,y]);const k=_j(o),w=new Set(k.map(j=>j.key)),N=Gf(o).map(j=>({...j,entries:j.entries.filter(T=>!w.has(T.key))}
11)).filter(j=>j.entries.length>0);return e.jsx(Ff.Provider,{value:{isAdmin:o},children:e.jsxs("div",{className:"min-h-screen bg-slate-50 dark:bg-[#0d0b14] flex",children:[e.jsx("a",{href:"#main",className:"sr-only focus:not-sr-only focus:fixed focus:left-4 focus:top-4 focus:z-[60] focus:rounded-xl focus:bg-white focus:px-4 focus:py-3 focus:text-sm focus:font-medium focus:text-primary-700 focus:shadow-lg focus:ring-2 focus:ring-primary-500",children:"Skip to content"}),e.jsx("aside",{"aria-label":"Sidebar",className:`hidden lg:flex lg:flex-col lg:fixed lg:inset-y-0 lg:left-0 ${g?"lg:w-16":"lg:w-[264px]"} bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-800 z-30 transition-all duration-300 motion-reduce:transition-none`,children:e.jsx(Ag,{pathname:d.pathname,account:s,isAdmin:o,collapsed:g,onToggle:f})}),u&&e.jsxs("div",{className:"lg:hidden fixed inset-0 z-50 flex",role:"dialog","aria-modal":"true","aria-label":"Navigation menu",children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:()=>x(!1),"aria-hidden":"true"}),e.jsxs("div",{className:"relative flex flex-col w-[288px] max-w-[85vw] bg-white dark:bg-gray-900 h-full shadow-2xl",children:[e.jsx("button",{type:"button",onClick:()=>x(!1),"aria-label":"Close menu",className:`absolute top-2 right-2 z-10 flex h-11 w-11 items-center justify-center rounded-lg text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800 ${ma}`,children:e.jsx(Wa,{d:"M6 18L18 6M6 6l12 12",className:"w-5 h-5"})}),e.jsx(Ag,{pathname:d.pathname,account:s,isAdmin:o,onNavigate:()=>x(!1)})]})]}),e.jsxs("header",{className:"lg:hidden fixed top-0 left-0 right-0 z-40 h-14 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800 flex items-center justify-between px-3",children:[e.jsx(Se,{to:"/","aria-label":"Fantize home",className:`flex min-h-11 items-center gap-2 min-w-0 rounded-lg px-1 ${ma}`,children:e.jsx(cn,{size:"sm"})}),e.jsx("button",{type:"button",onClick:()=>x(!0),"aria-label":"Open menu","aria-expanded":u,className:`flex h-11 w-11 items-center justify-center rounded-xl text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 ${ma}`,children:e.jsx(Wa,{d:"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5",className:"w-6 h-6"})})]}),e.jsxs("main",{id:"main",tabIndex:-1,className:`flex-1 ${g?"lg:ml-16":"lg:ml-[264px]"} min-w-0 overflow-x-clip transition-all duration-300 motion-reduce:transition-none focus:outline-none`,children:[e.jsx("div",{className:"h-14 lg:hidden","aria-hidden":"true"}),e.jsx("div",{className:"px-4 py-5 sm:px-6 sm:py-6 lg:px-8 lg:py-8 pb-24 lg:pb-10 min-h-screen",children:e.jsx("div",{className:"mx-auto w-full max-w-6xl",children:e.jsx(Df,{})})})]}),e.jsxs("nav",{"aria-label":"Primary",className:"lg:hidden fixed bottom-0 left-0 right-0 z-40 h-16 bg-white dark:bg-gray-900 border-t border-gray-200 dark:border-gray-800 flex items-stretch",children:[k.map(j=>{const T=Do(j,d.pathname);return e.jsxs(Se,{to:j.path,"aria-current":T?"page":void 0,className:`flex-1 flex flex-col items-center justify-center gap-0.5 min-w-11 px-1 text-[10px] font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500 ${T?"text-primary-600 dark:text-primary-400":"text-gray-500 dark:text-gray-500"}`,children:[e.jsx(Wa,{d:j.icon,className:"w-5 h-5"}),e.jsx("span",{className:"truncate max-w-full",children:j.label})]},j.key)}),e.jsxs("button",{type:"button",onClick:()=>p(!0),"aria-expanded":y,"aria-haspopup":"dialog",className:`flex-1 flex flex-col items-center justify-center gap-0.5 min-w-11 text-[10px] font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500 ${y?"text-primary-600 dark:text-primary-400":"text-gray-500 dark:text-gray-500"}`,children:[e.jsx(Wa,{d:"M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z",className:"w-5 h-5"}),"More"]})]}),y&&e.jsxs("div",{className:"lg:hidden fixed inset-0 z-50 flex flex-col justify-end",role:"dialog","aria-modal":"true","aria-label":"More navigation",children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:()=>p(!1),"aria-hidden":"true"}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-900 rounded-t-2xl shadow-2xl max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 pt-3 pb-2 border-b border-gray-100 dark:border-gray-800 flex-shrink-0",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"More"}),e.jsx("button",{type:"button",onClick:()=>p(!1),"aria-label":"Close",className:`flex h-11 w-11 items-center justify-center rounded-lg text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 ${ma}`,children:e.jsx(Wa,{d:"M6 18L18 6M6 6l12 12",className:"w-5 h-5"})})]}),e.jsx("nav",{"aria-label":"More",className:"overflow-y-auto flex-1 px-3 py-2",children:N.map(j=>e.jsxs("div",{className:"mb-2",children:[j.label&&o&&e.jsx("div",{className:"px-3 pt-2 pb-1 text-[11px] font-semibold uppercase tracking-wider text-gray-500",children:j.label}),j.entries.map(T=>e.jsx(Qf,{entry:T,active:Do(T,d.pathname),onNavigate:()=>p(!1)},T.key))]},j.key))}),e.jsxs("div",{className:"flex-shrink-0 border-t border-gray-100 dark:border-gray-800 px-4 py-3",children:[e.jsxs(Se,{to:"/dashboard/preferences",onClick:()=>p(!1),"aria-label":"Account & Preferences",className:`flex items-center gap-3 w-full px-2 py-2 min-h-11 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800 ${ma}`,children:[e.jsx("div",{className:"flex-shrink-0 w-9 h-9 rounded-xl bg-gradient-to-br from-primary-500 to-violet-600 flex items-center justify-center text-sm font-bold text-white shadow-sm","aria-hidden":"true",children:(s?.name?.[0]??"?").toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 truncate",children:s?.name}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 truncate",children:s?.email})]}),e.jsx(Wa,{d:"M8.25 4.5l7.5 7.5-7.5 7.5",className:"w-4 h-4 text-gray-300 dark:text-gray-600 flex-shrink-0"})]}),i.canPreview&&!i.active&&e.jsx("button",{type:"button",onClick:()=>{p(!1),i.enter()},className:`mt-1 w-full min-h-11 rounded-xl px-3 text-left text-xs font-medium text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800 ${ma}`,children:"View as Marketing (preview)"})]})]})]}),i.active&&e.jsxs("div",{role:"status","aria-live":"polite",className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 rounded-full bg-slate-900/95 px-4 py-2 text-sm text-white shadow-lg ring-1 ring-white/10 backdrop-blur max-lg:bottom-20 max-sm:left-4 max-sm:right-4 max-sm:justify-between",children:[e.jsx("span",{className:"font-medium",children:"Marketing Preview"}),e.jsx("span",{className:"hidden text-white/70 sm:inline",children:"read-only"}),e.jsx("button",{type:"button",onClick:i.exit,className:"min-h-11 min-w-11 rounded-full bg-white/15 px-3 text-sm font-medium hover:bg-white/25 focus:outline-none focus-visible:ring-2 focus-visible:ring-white",children:"Exit preview"})]}),e.jsx(Oj,{})]})})}function Dj({children:s}){const{account:l,loading:i}=zt();return i?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"loader w-10 h-10 border-4 border-gray-200 rounded-full"})}):l?e.jsx(e.Fragment,{children:s}):e.jsx(is,{to:"/login",replace:!0})}function vu({className:s="w-5 h-5"}){return e.jsx("svg",{className:s,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M16.704 5.29a1 1 0 010 1.42l-7.5 7.5a1 1 0 01-1.42 0l-3.5-3.5a1 1 0 111.42-1.42l2.79 2.79 6.79-6.79a1 1 0 011.42 0z",clipRule:"evenodd"})})}function Hj({d:s,className:l="w-5 h-5"}){const i=Array.isArray(s)?s:[s];return e.jsx("svg",{className:l,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.6,stroke:"currentColor","aria-hidden":"true",children:i.map((o,d)=>e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:o},d))})}const Ll="inline-flex items-center justify-center gap-2 bg-primary-600 hover:bg-primary-700 text-white font-semibold text-base px-6 py-3 rounded-lg shadow-sm hover:shadow transition-colors duration-200",Eg="inline-flex items-center justify-center gap-2 bg-white dark:bg-gray-800 text-slate-700 dark:text-gray-200 font-semibold text-base px-6 py-3 rounded-lg ring-1 ring-slate-300 dark:ring-gray-600 hover:bg-slate-50 dark:hover:bg-gray-700 transition-colors duration-200",ju="p-6 sm:p-7",qj="p-8 sm:p-10";function wu({children:s,alt:l=!1,id:i}){return e.jsx("section",{id:i,className:`border-t border-slate-200 dark:border-gray-800 ${l?"bg-slate-50 dark:bg-gray-900/40":"bg-white dark:bg-gray-950"} ${i?"scroll-mt-20":""}`,children:e.jsx("div",{className:"max-w-6xl mx-auto px-5 lg:px-8 py-16 lg:py-24",children:s})})}function ku({title:s,sub:l}){return e.jsxs("div",{className:"text-center max-w-2xl mx-auto mb-12",children:[e.jsx("h2",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-slate-900 dark:text-gray-100",children:s}
11),l&&e.jsx("p",{className:"mt-4 text-lg text-slate-600 dark:text-gray-400 leading-relaxed",children:l})]})}function Bj(){return h.useEffect(()=>{document.title="Fantize: Turn customers into your best marketers"},[]),e.jsxs("div",{className:"bg-white dark:bg-gray-950",children:[e.jsxs("section",{className:"relative overflow-hidden bg-white dark:bg-slate-900 bg-cover bg-center",style:{backgroundImage:"url(/img/intro-bg.png)"},children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/75 via-white/35 to-white/65 dark:from-slate-950/85 dark:via-slate-900/75 dark:to-slate-950/90"}),e.jsxs("div",{className:"relative max-w-5xl mx-auto px-5 lg:px-8 pt-12 lg:pt-16 pb-20 text-center",children:[e.jsx("span",{className:"inline-flex items-center gap-2 rounded-full bg-primary-50 text-primary-700 ring-1 ring-primary-200 dark:bg-white/10 dark:text-primary-100 dark:ring-white/20 backdrop-blur px-3.5 py-1.5 text-sm font-medium",children:"For D2C brands, e-commerce & consumer businesses"}),e.jsxs("h1",{className:"mt-6 text-4xl sm:text-5xl lg:text-6xl font-semibold tracking-tight leading-[1.1] text-slate-900 dark:text-white",children:["Turn your customers into",e.jsx("br",{className:"hidden sm:block"})," your ",e.jsx("span",{className:"text-primary-600 dark:text-primary-300",children:"best marketers"})]}),e.jsx("p",{className:"mt-5 text-lg sm:text-xl text-slate-600 dark:text-slate-200 max-w-2xl mx-auto leading-relaxed",children:"Use real customer names and authentic social proof in your campaigns, not generic ads that sound like everyone else."}),e.jsxs("div",{className:"mt-8 flex flex-col sm:flex-row items-center justify-center gap-3",children:[e.jsxs(Se,{to:"/register",className:`${Ll} w-full sm:w-auto`,children:["Start your first campaign",e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M3 10a1 1 0 011-1h9.586l-3.293-3.293a1 1 0 111.414-1.414l5 5a1 1 0 010 1.414l-5 5a1 1 0 01-1.414-1.414L13.586 11H4a1 1 0 01-1-1z",clipRule:"evenodd"})})]}),e.jsx(Se,{to:"/contact",className:"inline-flex items-center justify-center gap-2 bg-white hover:bg-slate-50 text-slate-700 ring-1 ring-slate-300 dark:bg-white/10 dark:hover:bg-white/20 dark:text-white dark:ring-white/30 font-semibold px-6 py-3 rounded-lg backdrop-blur transition-colors duration-200 w-full sm:w-auto text-base",children:"Schedule a demo"})]}),e.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2 text-sm text-slate-600 dark:text-slate-300",children:[e.jsx(vu,{className:"w-4 h-4 text-primary-600 dark:text-primary-300"}),"No credit card required · Built for brands that grow with their customers"]}),e.jsxs("div",{className:"mt-12 lg:mt-16 max-w-2xl mx-auto bg-white dark:bg-gray-900 rounded-2xl ring-1 ring-slate-200 dark:ring-white/10 shadow-2xl p-6 lg:p-8 text-left",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-primary-600 dark:text-primary-400",children:"Illustrative example"}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-slate-400 dark:text-gray-500",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500"})," Powered by Fantize"]})]}),e.jsxs("p",{className:"mt-3 text-xl lg:text-2xl font-medium text-slate-800 dark:text-gray-100 leading-snug",children:["âTwo of your friends just tried ",e.jsx("span",{className:"text-primary-600 dark:text-primary-400",children:"[Your Brand]"}),", see why they're sharing it.â"]})]})]})]}),e.jsxs(wu,{children:[e.jsx(ku,{title:"Generic ads vs. social proof",sub:"Traditional marketing tells people what to buy. Social proof shows them who's already buying, and loving it."}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"rounded-2xl ring-1 ring-slate-200 dark:ring-gray-700 bg-white dark:bg-gray-900 overflow-hidden",children:[e.jsx("div",{className:"px-6 lg:px-8 py-4 border-b border-slate-200 dark:border-gray-700",children:e.jsx("h3",{className:"text-base font-semibold text-slate-500 dark:text-gray-400",children:"Generic ad: the old way"})}),e.jsxs("div",{className:"p-6 lg:p-8",children:[e.jsxs("div",{className:"rounded-xl bg-slate-50 dark:bg-gray-800/60 ring-1 ring-slate-200 dark:ring-gray-700 p-6 text-center",children:[e.jsx("p",{className:"text-slate-600 dar
11k:text-gray-400",children:"âTry our amazing product today! Limited time offer. Shop now and save 20%!â"}),e.jsx("span",{className:"mt-4 inline-block bg-slate-600 dark:bg-gray-600 text-white px-5 py-2.5 rounded-lg text-sm font-semibold",children:"Shop now"})]}),e.jsx("ul",{className:"mt-6 space-y-2.5 text-sm text-slate-600 dark:text-gray-400",children:["Low trust: sounds like everyone else","No social validation or credibility","Treats people as anonymous traffic"].map(s=>e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx("svg",{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-slate-400",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM7 9a1 1 0 000 2h6a1 1 0 100-2H7z",clipRule:"evenodd"})}),s]},s))})]})]}),e.jsxs("div",{className:"rounded-2xl ring-1 ring-primary-200 dark:ring-primary-800 bg-white dark:bg-gray-900 overflow-hidden shadow-lg shadow-primary-900/5",children:[e.jsx("div",{className:"px-6 lg:px-8 py-4 bg-primary-600",children:e.jsx("h3",{className:"text-base font-semibold text-white",children:"Social-proof message: the Fantize way"})}),e.jsxs("div",{className:"p-6 lg:p-8",children:[e.jsxs("div",{className:"rounded-xl bg-primary-50/70 dark:bg-primary-900/20 ring-1 ring-primary-200 dark:ring-primary-800 p-6 text-center",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-primary-600 dark:text-primary-400",children:"Illustrative example"}),e.jsx("p",{className:"mt-2 text-slate-800 dark:text-gray-100 font-medium",children:"âTwo friends in your area just ordered from [Your Brand]. Join them and get 20% off your first purchase.â"}),e.jsx("span",{className:"mt-4 inline-block bg-primary-600 text-white px-5 py-2.5 rounded-lg text-sm font-semibold",children:"See what your friends love"})]}),e.jsx("ul",{className:"mt-6 space-y-2.5 text-sm text-slate-700 dark:text-gray-300",children:["Real names build instant trust","Social validation drives interest","Every message is personal, not generic"].map(s=>e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(vu,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-primary-600 dark:text-primary-400"}),e.jsx("span",{className:"font-medium",children:s})]},s))})]})]})]}),e.jsxs("div",{className:"text-center mt-12",children:[e.jsx(Se,{to:"/register",className:`${Ll}`,children:"Start your first campaign"}),e.jsx("p",{className:"mt-4 text-sm text-slate-500 dark:text-gray-500",children:"Set up in 5 minutes · No credit card required · 14-day free trial"})]})]}),e.jsxs(wu,{id:"pricing",alt:!0,children:[e.jsx(ku,{title:"Simple, transparent pricing",sub:"Choose the plan that fits your brand. Every plan includes the core fan-engagement tools and analytics dashboard."}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 max-w-5xl mx-auto items-stretch",children:[{name:"Starter",price:"$499",unit:"/month",features:["Up to 10,000 fan interactions","Basic analytics dashboard","Email support","2 campaign templates"],cta:"Start 14-day free trial",to:"/register",popular:!1},{name:"Professional",price:"$1,299",unit:"/month",features:["Up to 50,000 fan interactions","Advanced analytics & insights","Priority support","Unlimited campaign templates","Dedicated account manager"],cta:"Start 14-day free trial",to:"/register",popular:!0},{name:"Enterprise",price:"Custom",unit:"",features:["Unlimited fan interactions","Custom analytics & reporting","24/7 premium support","White-label solutions","API access & integrations"],cta:"Contact sales",to:"/contact",popular:!1}].map(s=>e.jsxs("div",{className:`relative flex flex-col rounded-2xl p-8 bg-white dark:bg-gray-900 transition-shadow hover:shadow-lg ${s.popular?"ring-2 ring-primary-500 shadow-lg shadow-primary-900/5":"ring-1 ring-slate-200 dark:ring-gray-700"}`,children:[s.popular&&e.jsx("span",{className:"absolute -top-3 left-1/2 -translate-x-1/2 bg-primary-600 text-white px-3 py-1 rounded-full text-xs font-semibold",children:"Most popular"}),e.jsx("h3",{className:"text-lg font-semibold text-slate-900 dark:text-gray-100 text-center",children:s.name}),e.jsxs("div",{className:"text-center mt-3 mb-6",children:[e.jsx("span",{className:"text-4xl font-semibold tracking-tight text-slate-900 dark:text-gray-100",children:s.price}),e.jsx("span",{className:"text-slate-500 dark:text-gray-400",children:s.unit})]}),e.jsx("ul",{className:"space-y-3 mb-8 flex-1",children:s.features.map(l
11=>e.jsxs("li",{className:"flex items-start gap-2.5 text-sm text-slate-600 dark:text-gray-300",children:[e.jsx(vu,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-primary-600 dark:text-primary-400"}),l]},l))}),e.jsx(Se,{to:s.to,className:s.popular?`${Ll} w-full`:`${Eg} w-full`,children:s.cta})]},s.name))})]}),e.jsxs("section",{className:"fanapart-bg relative overflow-hidden border-t border-slate-200 dark:border-slate-800 bg-slate-100 dark:bg-slate-950 bg-cover bg-center",children:[e.jsx("div",{className:"absolute inset-0 dark:bg-gradient-to-b dark:from-slate-950/50 dark:via-slate-950/25 dark:to-slate-950/55"}),e.jsxs("div",{className:"relative max-w-6xl mx-auto px-5 lg:px-8 py-16 lg:py-24",children:[e.jsx("div",{className:"text-center max-w-2xl mx-auto mb-12",children:e.jsx("h2",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-slate-900 dark:text-white",children:"What sets Fantize apart"})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6 max-w-5xl mx-auto",children:[{t:"Fan-centric strategies",d:"We put your fans at the heart of every campaign, understanding their passions to create messages that resonate and inspire action.",icon:"M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z"},{t:"Integrated fan analytics",d:"Understand your fans through engagement and interaction tracking, then refine and tailor strategies for maximum impact.",icon:"M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z"},{t:"Tailored to every brand",d:"No two brands are alike, and neither are their fans. We craft unique, fan-driven campaigns that reflect your brand.",icon:["M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09z","M18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456z"]},{t:"Sustainable growth",d:"Tap the organic growth of fan-based marketing to lower advertising spend and footprint: an efficient, durable approach.",icon:"M2.25 18L9 11.25l4.306 4.306a11.95 11.95 0 015.814-5.519l2.74-1.22m0 0l-5.94-2.28m5.94 2.28l-2.28 5.941"}].map(s=>e.jsxs("div",{className:`rounded-2xl ring-1 ring-slate-200 bg-white/80 shadow-sm shadow-slate-300/40 dark:ring-white/10 dark:bg-white/5 dark:shadow-lg dark:shadow-slate-950/30 backdrop-blur-sm ${ju}`,children:[e.jsx("div",{className:"w-11 h-11 rounded-xl bg-primary-100 text-primary-600 ring-1 ring-primary-200 dark:bg-primary-500/20 dark:text-primary-200 dark:ring-primary-400/30 flex items-center justify-center mb-4 mx-auto",children:e.jsx(Hj,{d:s.icon,className:"w-5 h-5"})}),e.jsx("h3",{className:"text-base font-semibold text-slate-900 dark:text-white",children:s.t}),e.jsx("p",{className:"mt-2 text-sm text-slate-600 dark:text-slate-300 leading-relaxed",children:s.d})]},s.t))})]})]}),e.jsxs("section",{className:"ourstory-bg relative overflow-hidden border-t border-slate-200 dark:border-slate-800 bg-slate-100 dark:bg-slate-950 bg-cover bg-center",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/75 via-white/60 to-white/75 dark:from-slate-950/75 dark:via-slate-950/60 dark:to-slate-950/75"}),e.jsxs("div",{className:"relative max-w-3xl mx-auto px-5 lg:px-8 py-16 lg:py-24 space-y-12",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-slate-900 dark:text-white text-center",children:"Our story"}),e.jsx("p",{className:"mt-5 text-lg text-slate-700 dark:text-slate-200 leading-relaxed text-center",children:"In a rapidly evolving marketing landscape, Fantize was born from a simple observation: brands hold a vast, often untapped reservoir of energy and passion: their fans. Instead of looking outward for expensive endorsements, why not look within the community of loyalists who already love and advocate for your brand? Fantize bridges that gap, turning enthusiastic fans into powerful brand ambassadors."})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-6",children:[e.jsxs("div",{className:`rounded-2xl ring-1 ring-slate-200 bg-white/80 shadow-sm shadow-slate-300/40 dark:ring-white/10 dark:bg-white/5 dark:shadow-lg dark:shadow-slate-950/30 backdrop-blur-sm ${ju}`,children:[e.jsx("h3",{className:"text-base font-semibold text-slate-900 dark:text-white",children:"Our vision"}
11),e.jsx("p",{className:"mt-2 text-slate-600 dark:text-slate-300 leading-relaxed",children:"To redefine advertising by prioritizing authenticity, connection, and fan-driven campaigns that resonate on a global scale."})]}),e.jsxs("div",{className:`rounded-2xl ring-1 ring-slate-200 bg-white/80 shadow-sm shadow-slate-300/40 dark:ring-white/10 dark:bg-white/5 dark:shadow-lg dark:shadow-slate-950/30 backdrop-blur-sm ${ju}`,children:[e.jsx("h3",{className:"text-base font-semibold text-slate-900 dark:text-white",children:"Our mission"}),e.jsx("p",{className:"mt-2 text-slate-600 dark:text-slate-300 leading-relaxed",children:"Harness genuine fan enthusiasm and turn it into compelling, impactful campaigns that increase visibility and foster deeper connections."})]})]})]})]}),e.jsxs(wu,{children:[e.jsx(ku,{title:"Be our first featured case study",sub:"Fantize is new, and we're looking for early-stage partners to build alongside. Join us and help shape how fan-powered marketing works."}),e.jsxs("div",{className:`max-w-2xl mx-auto rounded-2xl bg-slate-50 dark:bg-gray-900 ring-1 ring-slate-200 dark:ring-gray-700 ${qj} text-center`,children:[e.jsx("p",{className:"text-slate-600 dark:text-gray-400 leading-relaxed",children:"If you're a D2C brand, e-commerce company, or consumer business with a loyal customer base, we want to work with you. Early partners get hands-on onboarding, direct access to our team, and a chance to shape the product."}),e.jsx(Se,{to:"/contact",className:`${Ll} mt-6`,children:"Talk to our team"})]})]}),e.jsxs("section",{className:"cta-fan-bg relative overflow-hidden border-t border-slate-200 dark:border-slate-800 bg-slate-100 dark:bg-slate-950 bg-cover bg-center",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/80 via-white/60 to-white/80 dark:from-slate-950/80 dark:via-slate-950/70 dark:to-slate-950/80"}),e.jsx("div",{className:"relative max-w-6xl mx-auto px-5 lg:px-8 py-16 lg:py-24",children:e.jsxs("div",{className:"text-center max-w-2xl mx-auto",children:[e.jsx("h2",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-slate-900 dark:text-white",children:"Ready to transform your marketing?"}),e.jsx("p",{className:"mt-4 text-lg text-slate-700 dark:text-slate-200/90 leading-relaxed",children:"Harness the power of your most loyal customers. Start your free trial today, or schedule a personalized demo."}),e.jsxs("div",{className:"mt-8 flex flex-col sm:flex-row items-center justify-center gap-3",children:[e.jsx(Se,{to:"/register",className:`${Ll} w-full sm:w-auto`,children:"Start 14-day free trial"}),e.jsxs(Se,{to:"/contact",className:`${Eg} w-full sm:w-auto`,children:[e.jsx(Uj,{className:"w-4 h-4"}),"Schedule a demo"]})]})]})})]})]})}function Uj({className:s}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",className:s,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 6.75c0 8.284 6.716 15 15 15h2.25a2.25 2.25 0 002.25-2.25v-1.372c0-.516-.351-.966-.852-1.091l-4.423-1.106c-.44-.11-.902.055-1.173.417l-.97 1.293c-.282.376-.769.542-1.21.38a12.035 12.035 0 01-7.143-7.143c-.162-.441.004-.928.38-1.21l1.293-.97c.363-.271.527-.734.417-1.173L6.963 3.102a1.125 1.125 0 00-1.091-.852H4.5A2.25 2.25 0 002.25 4.5v2.25z"})})}function Fj({className:s}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.6,stroke:"currentColor",className:s,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 6.75c0 8.284 6.716 15 15 15h2.25a2.25 2.25 0 002.25-2.25v-1.372c0-.516-.351-.966-.852-1.091l-4.423-1.106c-.44-.11-.902.055-1.173.417l-.97 1.293c-.282.376-.769.542-1.21.38a12.035 12.035 0 01-7.143-7.143c-.162-.441.004-.928.38-1.21l1.293-.97c.363-.271.527-.734.417-1.173L6.963 3.102a1.125 1.125 0 00-1.091-.852H4.5A2.25 2.25 0 002.25 4.5v2.25z"})})}function Ij({className:s}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.6,stroke:"currentColor",className:s,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})})}function Vj({className:s}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.6,stroke:"currentColor",className:s,"aria-hidden":"true",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10.5a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1115 0z"})]})}function Gj({className:s}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"
11currentColor",className:s,"aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm13.36-1.814a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z",clipRule:"evenodd"})})}const fo="w-full rounded-lg border border-slate-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3.5 py-2.5 text-slate-900 dark:text-gray-100 placeholder-slate-400 dark:placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-500 transition",po="block text-sm font-medium text-slate-700 dark:text-gray-200 mb-1.5";function Yj(){const[s,l]=h.useState({fullName:"",email:"",phone:"",message:""}),[i,o]=h.useState(!1),[d,u]=h.useState(!1),[x,y]=h.useState("");h.useEffect(()=>{document.title="Contact Us | Fantize"},[]);const p=f=>{l({...s,[f.target.name]:f.target.value})},g=async f=>{f.preventDefault(),u(!0),y("");try{(await(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s.fullName,email:s.email,phone:s.phone,message:s.message})})).json())?.success?o(!0):y("Something went wrong sending your message. Please try again.")}catch{y("Could not send your message right now. Please try again in a moment.")}finally{u(!1)}},b=[{icon:Fj,label:"Phone",value:"+1 (781) 925-1700",href:"tel:+17819251700"},{icon:Ij,label:"Email",value:"[email protected]",href:"mailto:[email protected]"}];return e.jsx("div",{className:"bg-white dark:bg-gray-950",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-5 lg:px-8 pt-10 lg:pt-12 pb-16 lg:pb-24",children:[e.jsxs("div",{className:"text-center max-w-2xl mx-auto",children:[e.jsx("span",{className:"inline-flex items-center rounded-full bg-primary-50 dark:bg-primary-900/30 text-primary-700 dark:text-primary-300 ring-1 ring-primary-200 dark:ring-primary-800 px-3.5 py-1.5 text-sm font-medium",children:"Contact"}),e.jsx("h1",{className:"mt-6 text-4xl sm:text-5xl font-semibold tracking-tight text-slate-900 dark:text-white",children:"Let's get in touch"}),e.jsx("p",{className:"mt-4 text-lg text-slate-600 dark:text-gray-400 leading-relaxed",children:"Tell us about your brand and what you're trying to grow. We'll get back to you quickly, and let's start something great together."})]}),e.jsxs("div",{className:"mt-14 grid lg:grid-cols-5 gap-6 lg:gap-8 items-start",children:[e.jsx("aside",{className:"lg:col-span-2 space-y-4",children:e.jsxs("div",{className:"rounded-2xl ring-1 ring-slate-200 dark:ring-gray-700 bg-white dark:bg-gray-900 p-6 sm:p-7",children:[e.jsx("h2",{className:"text-base font-semibold text-slate-900 dark:text-gray-100",children:"Reach us directly"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-gray-400",children:"Prefer to talk now? Use the details below."}),e.jsxs("div",{className:"mt-5 space-y-5",children:[b.map(({icon:f,label:k,value:w,href:N})=>e.jsxs("a",{href:N,className:"group flex items-start gap-4",children:[e.jsx("span",{className:"flex-shrink-0 w-11 h-11 rounded-xl bg-primary-50 dark:bg-primary-900/30 text-primary-600 dark:text-primary-400 ring-1 ring-primary-100 dark:ring-primary-800 flex items-center justify-center",children:e.jsx(f,{className:"w-5 h-5"})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-semibold text-slate-900 dark:text-gray-100",children:k}),e.jsx("span",{className:"block text-primary-600 dark:text-primary-400 group-hover:underline break-words",children:w})]})]},k)),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("span",{className:"flex-shrink-0 w-11 h-11 rounded-xl bg-primary-50 dark:bg-primary-900/30 text-primary-600 dark:text-primary-400 ring-1 ring-primary-100 dark:ring-primary-800 flex items-center justify-center",children:e.jsx(Vj,{className:"w-5 h-5"})}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-semibold text-slate-900 dark:text-gray-100",children:"Office"}),e.jsxs("address",{className:"not-italic text-slate-600 dark:text-gray-300 leading-relaxed",children:["State Street Financial Center",e.jsx("br",{}),"One Lincoln Street",e.jsx("br",{}),"Boston, MA 02111"]})]})]})]})]})}),e.jsx("div",{className:"lg:col-span-3",children:e.jsx("div",{className:"rounded-2xl ring-1 ring-slate-200 dark:ring-gray-700 bg-white dark:bg-gray-900 shadow-sm p-6 sm:p-8",children:i?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Gj,{className:"w-16 h-16 text-emerald-500 mx-auto mb-4"}),e.jsx("h2",{className:"text-2xl font-semibold text-slate-900 dark:text-white mb-2",children:"Thank y
11ou!"}),e.jsx("p",{className:"text-slate-600 dark:text-gray-300",children:"We've received your message and our team will be in touch soon."})]}):e.jsxs("form",{onSubmit:g,className:"space-y-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-slate-900 dark:text-gray-100",children:"Send us a message"}),x&&e.jsx("div",{className:"rounded-lg bg-rose-50 dark:bg-rose-950/40 ring-1 ring-rose-200 dark:ring-rose-900 text-rose-700 dark:text-rose-300 px-4 py-2.5 text-sm",children:x}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:po,htmlFor:"fullName",children:"Full name"}),e.jsx("input",{id:"fullName",type:"text",name:"fullName",value:s.fullName,onChange:p,autoFocus:!0,required:!0,className:fo,placeholder:"Full name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:po,htmlFor:"email",children:"Email"}),e.jsx("input",{id:"email",type:"email",name:"email",value:s.email,onChange:p,required:!0,className:fo,placeholder:"[email protected]"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:po,htmlFor:"phone",children:["Phone ",e.jsx("span",{className:"font-normal text-slate-400",children:"(optional)"})]}),e.jsx("input",{id:"phone",type:"tel",name:"phone",value:s.phone,onChange:p,className:fo,placeholder:"+1 (555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx("label",{className:po,htmlFor:"message",children:"Message"}),e.jsx("textarea",{id:"message",name:"message",value:s.message,onChange:p,required:!0,rows:5,className:fo,placeholder:"Tell us a bit about your brand and goalsâ¦"})]}),e.jsx("button",{type:"submit",disabled:d,className:"w-full inline-flex items-center justify-center bg-primary-600 hover:bg-primary-700 text-white font-semibold px-6 py-3 rounded-lg shadow-sm transition-colors disabled:opacity-60",children:d?"Sendingâ¦":"Send message"}),e.jsx("p",{className:"text-center text-xs text-slate-400 dark:text-gray-500",children:"We'll only use your details to respond to your enquiry."})]})})})]})]})})}function Ot({className:s}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:s,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function Pj(){return h.useEffect(()=>{document.title="Pricing | Fantize"},[]),e.jsx("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-950",children:e.jsxs("div",{className:"container mx-auto px-5 lg:px-0 pt-10 lg:pt-12 pb-16 lg:pb-24",children:[e.jsxs("div",{className:"text-center max-w-2xl mx-auto mb-12",children:[e.jsx("span",{className:"inline-flex items-center rounded-full bg-primary-50 dark:bg-primary-900/30 text-primary-700 dark:text-primary-300 ring-1 ring-primary-200 dark:ring-primary-800 px-3.5 py-1.5 text-sm font-medium",children:"Pricing"}),e.jsx("h1",{className:"mt-6 text-4xl sm:text-5xl font-semibold tracking-tight text-slate-900 dark:text-white",children:"Simple, transparent pricing"}),e.jsx("p",{className:"mt-4 text-lg text-gray-600 dark:text-gray-400",children:"Choose the plan that fits your brand's needs. All plans include our core fan engagement tools and analytics dashboard."}),e.jsxs("div",{className:"mt-6 inline-flex items-center gap-2 bg-primary-50 dark:bg-primary-900/30 text-primary-700 dark:text-primary-300 ring-1 ring-primary-200 dark:ring-primary-800 px-4 py-2 rounded-full",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"w-5 h-5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"font-semibold",children:"14-day free trial ⢠No credit card required"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 max-w-6xl mx-auto",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 border-2 border-gray-200 dark:border-gray-700 rounded-2xl p-8 hover:shadow-2xl transition-all",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h3",{className:"text-2xl font-bold mb-2 text-slate-900 dark:text-white",children:"Starter"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm mb-4",children:"Perfect for small businesses getting started"}),e.jsxs("div",{className:"mb-6",children:[e.jsx("span",{className:"text-5xl font-bold text-primary-500",children:"$20"}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"/month"})]})]}),e.jsxs("ul",{className:"space-y-4 mb-8",children:[e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:e.jsx("strong",{children:"1,000 contacts"})})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:e.jsx("strong",{children:"10,000 emails/month"})})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Basic analytics dashboard"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Email support"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"2 campaign templates"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Fan engagement tools"})]})]}),e.jsx(Se,{to:"/register",className:"block text-center bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600 text-primary-600 dark:text-primary-300 font-semibold py-3 rounded-lg transition-colors",children:"Start 14-Day Free Trial"})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 border-2 border-primary-500 rounded-2xl p-8 hover:shadow-2xl transition-all relative",children:[e.jsx("div",{className:"absolute -top-4 left-1/2 transform -translate-x-1/2 bg-primary-500 text-white px-4 py-1 rounded-full text-sm font-semibold",children:"Most Popular"}),e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h3",{className:"text-2xl font-bold mb-2 text-slate-900 dark:text-white",children:"Growth"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm mb-4",children:"For growing brands scaling their reach"}),e.jsxs("div",{className:"mb-6",children:[e.jsx("span",{className:"text-5xl font-bold text-primary-500",children:"$99"}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"/month"})]})]}),e.jsxs("ul",{className:"space-y-4 mb-8",children:[e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:e.jsx("strong",{children:"10,000 contacts"})})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:e.jsx("strong",{children:"100,000 emails/month"})})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Advanced analytics & insights"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Priority email & chat support"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Unlimited campaign templates"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"A/B testing"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Custom branding"})]})]}),e.jsx(Se,{to:"/register",className:"block text-center bg-primary-500 hover:bg-primary-700 text-white font-semibold py-3 rounded-lg transition-colors",children:"Start 14-Day Free Trial"})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 border-2 border-gray-200 dark:border-gray-700 rounded-2xl p-8 hover:shadow-2xl transition-all",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h3",{className:"text-2xl font-bold mb-2 text-slate-900 dark:text-white",children:"Enterprise"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm mb-4",children:"For large organizations with custom needs"}),e.jsxs("div",{className:"mb-6",children:[e.jsx("span",{className:"text-5xl font-bold text-primary-500",children:"$499"}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"/month"})]})]}),e.jsxs("ul",{className:"space-y-4 mb-8",children:[e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:e.jsx("strong",{children:"Unlimited contacts"})})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:e.jsx("strong",{children:"Unlimited emails"})})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Custom analytics & reporting"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"24/7 premium support"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Dedicated account manager"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"White-label solutions"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"API access & integrations"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 text-primary-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Custom onboarding & training"})]})]}),e.jsx(Se,{to:"/contact",className:"block text-center bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600 text-primary-600 dark:text-primary-300 font-semibold py-3 rounded-lg transition-colors",children:"Contact Sales"})]})]}),e.jsx("div",{className:"mt-16 max-w-4xl mx-auto bg-gradient-to-r from-primary-600 via-primary-600 to-violet-600 rounded-2xl p-8 text-white shadow-lg shadow-primary-900/25",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-2xl font-bold mb-3",children:"Try Fantize Risk-Free for 14 Days"}),e.jsx("p",{className:"text-lg text-white/90 mb-6",children:"No credit card required. Cancel anytime. Experience the full power of fan-driven marketing with unlimited access to all features during your trial."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsx(Se,{to:"/register",className:"bg-white text-primary-600 hover:bg-primary-50 font-semibold px-8 py-3 rounded-lg transition-colors shadow-md",children:"Start Your Free Trial"}),e.jsx(Se,{to:"/contact",className:"bg-transparent border-2 border-white text-white hover:bg-white/10 font-semibold px-8 py-3 rounded-lg transition-colors",children:"Schedule a Demo"})]})]})}),e.jsxs("div",{className:"mt-20 max-w-3xl mx-auto",children:[e.jsx("h2",{className:"text-3xl font-bold tracking-tight text-center mb-10 text-slate-900 dark:text-white",children:"Frequently Asked Questions"}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl p-6 shadow-sm ring-1 ring-gray-200 dark:ring-gray-700",children:[e.jsx("h4",{className:"font-semibold text-lg mb-2 text-slate-900 dark:text-gray-100",children:"Can I change plans later?"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Yes! You can upgrade or downgrade your plan at any time. Changes take effect immediately, and we'll prorate any differences."})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl p-6 shadow-sm ring-1 ring-gray-200 dark:ring-gray-700",children:[e.jsx("h4",{className:"font-semibold text-lg mb-2 text-slate-900 dark:text-gray-100",children:"What happens after my trial ends?"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"After your 14-day trial, you'll be prompted to choose a plan. If you don't select one, your account will be paused until you upgrade. Your data is always safe and accessible."})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl p-6 shadow-sm ring-1 ring-gray-200 dark:ring-gray-700",children:[e.jsx("h4",{className:"font-semibold text-lg mb-2 text-slate-900 dark:text-gray-100",children:"Do you offer annual billing?"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Yes! Contact our sales team for annual pricing options, which include significant discounts compared to monthly billing."})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl p-6 shadow-sm ring-1 ring-gray-200 dark:ring-gray-700",children:[e.jsx("h4",{className:"font-semibold text-lg mb-2 text-slate-900 dark:text-gray-100",children:"What payment methods do you accept?"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"We accept all major credit cards (Visa, Mastercard, American Express) and offer invoicing for Enterprise customers."})]})]})]})]})})}
11function Qj(){const[s,l]=h.useState(""),[i,o]=h.useState(""),[d,u]=h.useState(""),[x,y]=h.useState(!1),[p,g]=h.useState(null),{login:b,account:f}=zt(),k=Ya();h.useEffect(()=>{document.title="Login | Fantize",Ie.track("page_view",{page:"login",path:"/login"})},[]),h.useEffect(()=>{f&&k("/dashboard")},[f,k]);const w=async N=>{N.preventDefault(),u(""),y(!0),Ie.track("login_attempt",{email:s});try{const j=await b(s,i);if(j.kind==="waitlisted"){Ie.track("login_waitlisted",{email:s}),g({message:j.message,email:j.email});return}Ie.track("login_success",{email:s}),k("/dashboard")}catch(j){Ie.trackError("login",j,{email:s}),u(j.message)}finally{y(!1)}};return p?e.jsx("div",{className:"min-h-screen bg-gray-50 dark:bg-[#0d0b14] flex flex-col justify-center py-12 px-4",children:e.jsxs("div",{className:"mx-auto w-full max-w-md",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx(Se,{to:"/",children:e.jsx(cn,{size:"sm"})})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow dark:shadow-gray-950 rounded-2xl p-8 ring-1 ring-gray-200 dark:ring-gray-700 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary-100 dark:bg-primary-900/40 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-primary-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100 mb-2",children:"You're on the waitlist"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:p.message}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-6",children:["We'll email ",e.jsx("span",{className:"font-medium",children:p.email})," as soon as your account is approved."]}),e.jsx("button",{onClick:()=>g(null),className:"text-primary-500 hover:text-primary-700 text-sm font-semibold",children:"â Try a different account"})]})]})}):e.jsx("div",{className:"min-h-screen bg-gray-50 dark:bg-[#0d0b14] flex flex-col justify-center py-12 px-4",children:e.jsxs("div",{className:"mx-auto w-full max-w-md",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx(Se,{to:"/",children:e.jsx(cn,{size:"sm"})})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow dark:shadow-gray-950 rounded-2xl p-8 ring-1 ring-gray-200 dark:ring-gray-700",children:[e.jsx("h2",{className:"text-2xl font-bold text-center mb-6 text-gray-900 dark:text-gray-100",children:"Sign in to your account"}),d&&e.jsx("div",{className:"bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded mb-4",children:d}),e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"login-email",className:"block text-sm font-bold text-gray-700 dark:text-gray-200 mb-1",children:"Email"}),e.jsx("input",{id:"login-email",type:"email",value:s,onChange:N=>l(N.target.value),required:!0,autoFocus:!0,className:"shadow appearance-none border rounded w-full p-3 text-gray-700 dark:text-gray-100 bg-white dark:bg-gray-700 dark:border-gray-600 focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"login-password",className:"block text-sm font-bold text-gray-700 dark:text-gray-200 mb-1",children:"Password"}),e.jsx("input",{id:"login-password",type:"password",value:i,onChange:N=>o(N.target.value),required:!0,className:"shadow appearance-none border rounded w-full p-3 text-gray-700 dark:text-gray-100 bg-white dark:bg-gray-700 dark:border-gray-600 focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),e.jsx("button",{type:"submit",disabled:x,className:"bg-primary-500 hover:bg-primary-700 text-white font-bold w-full py-3 px-4 rounded-md focus:outline-none",children:x?"Signing in...":"Sign In"})]}),e.jsxs("p",{className:"mt-6 text-center text-sm text-gray-600",children:["Don't have an account?"," ",e.jsx(Se,{to:"/register",className:"text-primary-500 hover:text-primary-700 font-semibold",children:"Sign up"})]})]})]})})}function Tg(s,l,i){const o={timestamp:new Date().toISOString()};l&&(l.id&&(o.userId=l.id),l.email&&(o.userEmail=l.email)),i&&Object.keys(i).length>0&&(o.metadata=i),console.log(`[FUNNEL] ${s}`,{timestamp:o.timestamp,...o.userId&&{userId:o.userId},...o.userEmail&&{userEmail:o.userEmail},...o.metadata&&{metadata:o.metadata}})}
11function Xj(){const[s,l]=h.useState(""),[i,o]=h.useState(""),[d,u]=h.useState(""),[x,y]=h.useState(""),[p,g]=h.useState(""),[b,f]=h.useState(!1),[k,w]=h.useState(null),{register:N,account:j}=zt(),T=Ya();h.useEffect(()=>{document.title="Sign Up | Fantize",Ie.track("page_view",{page:"register",path:"/register"}),console.log("ð [RegisterPage] Page viewed"),Tg("registration_started")},[]),h.useEffect(()=>{j&&T("/dashboard")},[j,T]);const S=async _=>{_.preventDefault(),g(""),f(!0),console.log("ð [RegisterPage] Registration attempt started"),Ie.track("registration_attempt",{email:i,name:s,hasCompanyName:!!x});try{const z=await N(s,i,d,x||void 0);if(z.kind==="waitlisted"){console.log("â³ [RegisterPage] User waitlisted:",z.message),Ie.track("registration_waitlisted",{email:i,name:s}),w({message:z.message,position:z.position,email:z.email});return}console.log("â
[RegisterPage] Registration successful"),Ie.track("registration_success",{email:i,name:s,hasCompanyName:!!x}),Tg("registration_completed",{email:i,name:s},{hasCompanyName:!!x}),T("/dashboard")}catch(z){console.error("â [RegisterPage] Registration failed:",z.message),Ie.trackError("registration",z,{email:i,name:s}),g(z.message)}finally{f(!1)}};return k?e.jsx("div",{className:"min-h-screen bg-gray-50 dark:bg-[#0d0b14] flex flex-col justify-center py-12 px-4",children:e.jsxs("div",{className:"mx-auto w-full max-w-md",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx(Se,{to:"/",children:e.jsx(cn,{size:"sm"})})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow dark:shadow-gray-950 rounded-2xl p-8 ring-1 ring-gray-200 dark:ring-gray-700 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary-100 dark:bg-primary-900/40 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-primary-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100 mb-2",children:"You're on the waitlist!"}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:["We've saved your spot for ",e.jsx("span",{className:"font-semibold text-gray-800 dark:text-gray-200",children:k.email}),"."]}),k.position&&e.jsx("div",{className:"bg-primary-50 dark:bg-primary-900/30 border border-primary-200 dark:border-primary-700 rounded-xl p-3 mb-4",children:e.jsxs("p",{className:"text-sm font-semibold text-primary-700 dark:text-primary-300",children:["You are #",k.position," in line"]})}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-6",children:["We'll email you at ",e.jsx("span",{className:"font-medium",children:k.email})," as soon as your account is approved. No action needed on your part."]}),e.jsx(Se,{to:"/",className:"text-primary-500 hover:text-primary-700 text-sm font-semibold",children:"â Back to Fantize"})]})]})}):e.jsx("div",{className:"min-h-screen bg-gray-50 dark:bg-[#0d0b14] flex flex-col justify-center py-12 px-4",children:e.jsxs("div",{className:"mx-auto w-full max-w-md",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx(Se,{to:"/",children:e.jsx(cn,{size:"sm"})})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow dark:shadow-gray-950 rounded-2xl p-8 ring-1 ring-gray-200 dark:ring-gray-700",children:[e.jsx("h2",{className:"text-2xl font-bold text-center mb-6 text-gray-900 dark:text-gray-100",children:"Create your account"}),e.jsxs("div",{className:"bg-primary-50 dark:bg-primary-900/30 border border-primary-200 dark:border-primary-700 rounded-xl p-4 mb-6",children:[e.jsxs("p",{className:"text-sm text-center text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:"font-semibold",children:"Join 500+ brands"})," transforming their marketing with Fantize"]}),e.jsx("p",{className:"text-xs text-center text-gray-600 dark:text-gray-400 mt-2",children:"â 14-day free trial ⢠No credit card required ⢠Cancel anytime"})]}),p&&e.jsx("div",{className:"bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded mb-4",children:p}),e.jsxs("form",{onSubmit:S,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"register-full-name",className:"block text-sm font-bold text-gray-700 dark:text-gray-200 mb-1",children:"Full Name"}),e.jsx("input",{id:"register-full-name",type:"text",value:s,onChange:_=>l(_.target.value),required:!0,autoFocus:!0,className:"shadow appearance-none border rounded w-full p-3 text-gray-700 dark:text-gray-100 bg-white dark:bg-gray-700 dark:border-gray-600 focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"register-email",className:"block text-sm font-bold text-gray-700 dark:text-gray-200 mb-1",children:"Email"}),e.jsx("input",{id:"register-email",type:"email",value:i,onChange:_=>o(_.target.value),required:!0,className:"shadow appearance-none border rounded w-full p-3 text-gray-700 dark:text-gray-100 bg-white dark:bg-gray-700 dark:border-gray-600 focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"register-password",className:"block text-sm font-bold text-gray-700 dark:text-gray-200 mb-1",children:"Password"}),e.jsx("input",{id:"register-password",type:"password",value:d,onChange:_=>u(_.target.value),required:!0,minLength:6,className:"shadow appearance-none border rounded w-full p-3 text-gray-700 dark:text-gray-100 bg-white dark:bg-gray-700 dark:border-gray-600 focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"register-company-name",className:"block text-sm font-bold text-gray-700 dark:text-gray-200 mb-1",children:["Company Name ",e.jsx("span",{className:"font-normal text-gray-400",children:"(optional)"})]}),e.jsx("input",{id:"register-company-name",type:"text",value:x,onChange:_=>y(_.target.value),className:"shadow appearance-none border rounded w-full p-3 text-gray-700 dark:text-gray-100 bg-white dark:bg-gray-700 dark:border-gray-600 focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),e.jsx("button",{type:"submit",disabled:b,className:"bg-primary-500 hover:bg-primary-700 text-white font-bold w-full py-3 px-4 roun
11ded-md focus:outline-none",children:b?"Creating account...":"Sign Up"})]}),e.jsxs("p",{className:"mt-6 text-center text-sm text-gray-600",children:["Already have an account?"," ",e.jsx(Se,{to:"/login",className:"text-primary-500 hover:text-primary-700 font-semibold",children:"Sign in"})]}),e.jsxs("div",{className:"mt-6 flex items-center justify-center space-x-4 text-xs text-gray-500",children:[e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("svg",{className:"w-4 h-4 text-green-600",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 1a4.5 4.5 0 00-4.5 4.5V9H5a2 2 0 00-2 2v6a2 2 0 002 2h10a2 2 0 002-2v-6a2 2 0 00-2-2h-.5V5.5A4.5 4.5 0 0010 1zm3 8V5.5a3 3 0 10-6 0V9h6z",clipRule:"evenodd"})}),e.jsx("span",{className:"font-semibold",children:"SSL Secured"})]}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("svg",{className:"w-4 h-4 text-purple-600",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M10 2a5 5 0 00-5 5v2a2 2 0 00-2 2v5a2 2 0 002 2h10a2 2 0 002-2v-5a2 2 0 00-2-2H7V7a3 3 0 015.905-.75 1 1 0 001.937-.5A5.002 5.002 0 0010 2z"})}),e.jsx("span",{className:"font-semibold",children:"Data Encrypted"})]})]})]})]})})}const Xf={ready:{label:"Ready",tone:"green",glyph:"â",sr:"Ready"},healthy:{label:"Healthy",tone:"green",glyph:"â",sr:"Healthy"},monitoring:{label:"Monitoring",tone:"blue",glyph:"â",sr:"Monitoring"},connected:{label:"Connected",tone:"green",glyph:"â",sr:"Connected"},verified:{label:"Verified",tone:"green",glyph:"â",sr:"Verified"},"needs-review":{label:"Needs review",tone:"amber",glyph:"!",sr:"Needs review"},"action-required":{label:"Action required",tone:"red",glyph:"!",sr:"Action required"},paused:{label:"Paused",tone:"amber",glyph:"ââ",sr:"Paused"},disabled:{label:"Off",tone:"gray",glyph:"â",sr:"Off"},unavailable:{label:"Unavailable",tone:"gray",glyph:"?",sr:"Unavailable"},"not-configured":{label:"Not configured",tone:"gray",glyph:"â",sr:"Not configured"},info:{label:"",tone:"blue",glyph:"i",sr:""}},Wj={green:"bg-emerald-50 text-emerald-800 ring-emerald-600/25 dark:bg-emerald-500/10 dark:text-emerald-200 dark:ring-emerald-400/30",blue:"bg-sky-50 text-sky-800 ring-sky-600/25 dark:bg-sky-500/10 dark:text-sky-200 dark:ring-sky-400/30",amber:"bg-amber-50 text-amber-900 ring-amber-600/30 dark:bg-amber-500/10 dark:text-amber-200 dark:ring-amber-400/30",red:"bg-rose-50 text-rose-800 ring-rose-600/25 dark:bg-rose-500/10 dark:text-rose-200 dark:ring-rose-400/30",gray:"bg-slate-100 text-slate-700 ring-slate-500/25 dark:bg-slate-500/10 dark:text-slate-200 dark:ring-slate-400/30"};function We({kind:s,label:l,title:i,size:o="sm",className:d=""}){const u=Xf[s];return e.jsxs("span",{title:i,className:["inline-flex items-start gap-1.5 max-w-full rounded-full font-medium ring-1 ring-inset leading-snug",o==="md"?"px-3 py-1 text-sm":"px-2.5 py-0.5 text-xs",Wj[u.tone],d].join(" "),children:[e.jsx("span",{"aria-hidden":"true",className:"text-[0.85em] leading-none mt-[0.2em] flex-none",children:u.glyph}),u.sr&&e.jsxs("span",{className:"sr-only",children:[u.sr,": "]}),e.jsx("span",{children:l??u.label})]})}function zr({items:s,columns:l=1,dense:i=!1}){const o=l===3?"sm:grid-cols-2 lg:grid-cols-3":l===2?"sm:grid-cols-2":"";return e.jsx("dl",{className:`grid grid-cols-1 ${o} gap-x-6 ${i?"gap-y-2":"gap-y-3"}`,children:s.map(d=>e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx(We,{kind:d.kind,label:Xf[d.kind].label||void 0,className:"mt-0.5 flex-none"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400",children:d.label}),e.jsx("dd",{className:"text-sm text-gray-900 dark:text-gray-100",children:d.value}),d.detail&&e.jsx("dd",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:d.detail}),d.to&&e.jsx("dd",{className:"mt-1",children:e.jsx(Se,{to:d.to,className:"inline-flex min-h-11 items-center text-sm font-medium text-primary-600 hover:underline dark:text-primary-400 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 rounded-lg",children:d.toLabel||"Open"})})]})]},d.key))})}function Wf({title:s,body:l,to:i,cta:o,tone:d="blue",secondary:u}){const x={blue:"border-l-primary-500",amber:"border-l-amber-500",green:"border-l-emerald-500",gray:"border-l-gray-400"}[d];return e.jsxs("section",{"aria-label":"Next recommended action",className:`rounded-2xl bg-white dark:bg-gray-800/80 ring-1 ring-gray-200 dark:ring-gray-700/60 shadow-sm p-5 border-l-4 ${x}`,children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:"Next recommended action"}),e.jsx("h2",{className:"mt-1 text-base font-semibold text-gray-900 dark:text-gray-100",children:s}),l&&e.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-300 leading-relaxed",children:l}),(i||u)&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[i&&e.jsx(Se,{to:i,className:"inline-flex min-h-11 items-center rounded-xl bg-gradient-to-b from-primary-500 to-primary-600 px-4 text-sm font-medium text-white shadow-sm hover:from-primary-600 hover:to-primary-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2",children:o||"Open"}),u&&e.jsx(Se,{to:u.to,className:"inline-flex min-h-11 items-center text-sm font-medium text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-white focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 rounded-lg px-1",children:u.label})]})]})}const Ho={green:"bg-emerald-50 text-emerald-700 ring-emerald-200 dark:bg-emerald-900/30 dark:text-emerald-300 dark:ring-emerald-700/50",blue:"bg-sky-50 text-sky-700 ring-sky-200 dark:bg-sky-900/30 dark:text-sky-300 dark:ring-sky-700/50",amber:"bg-amber-50 text-amber-700 ring-amber-200 dark:bg-amber-900/30 dark:text-amber-300 dark:ring-amber-700/50",gray:"bg-gray-50 text-gray-600 ring-gray-200 dark:bg-gray-700/50 dark:text-gray-300 dark:ring-gray-600",red:"bg-rose-50 text-rose-700 ring-rose-200 dark:bg-rose-900/30 dark:text-rose-300 dark:ring-rose-700/50"},de="w-full min-h-11 rounded-xl border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700/80 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 dark:placeholder:text-gray-500 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 dark:focus:ring-primary-400 focus:border-transparent transition-colors",Hr="bg-gray-50 dark:bg-gray-900/60 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider px-4 py-3 text-left",Ql="hover:bg-gray-50 dark:hover:bg-gray-700/40 transition-colors text-sm text-gray-900 dark:text-gray-200";function _e({children:s,className:l="",onClick:i}){return e.jsx("div",{onClick:i,className:["bg-white dark:bg-gray-800/80 rounded-2xl shadow-sm dark:shadow-gray-950/50","ring-1 ring-gray-200 dark:ring-gray-700/60 p-5",i?"cursor-pointer hover:shadow-md hover:ring-gray-300 dark:hover:ring-gray-600 dark:hover:shadow-gray-900 transition-shadow":"",l].filter(
11Boolean).join(" "),children:s})}function Xe({title:s,subtitle:l,action:i,secondary:o,status:d,crumbTail:u,documentTitle:x,noBreadcrumbs:y,eyebrow:p}){const b=Dn()?Ga().pathname:"",f=Nj(),k=y||!b?[]:Cj(b,!!f?.isAdmin,u);return h.useEffect(()=>{document.title=x?`${x} | Fantize`:b?Aj(b,u||void 0):`${s} | Fantize`},[b,x,u,s]),e.jsxs("header",{className:"mb-6",children:[k.length>1&&e.jsx(s1,{items:k}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[p&&e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-gray-400 dark:text-gray-500 mb-1",children:p}),e.jsx("h1",{className:"font-display text-2xl font-semibold text-gray-900 dark:text-gray-100 leading-tight",children:s}),l&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1 max-w-3xl leading-relaxed",children:l})]}),(i||o)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:flex-none sm:justify-end",children:[o,i]})]}),d&&e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:d})]})}function Fe({children:s,action:l,variant:i="default"}){return e.jsxs("div",{className:["flex items-center justify-between mb-3",i==="accented"?"border-b pb-3 mb-4 border-gray-100 dark:border-gray-700":""].filter(Boolean).join(" "),children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:s}),l]})}function Go(){return e.jsx("hr",{className:"border-t border-gray-100 dark:border-gray-700/60 my-6"})}function Ml({className:s=""}){return e.jsx("div",{className:`h-px bg-gradient-to-r from-transparent via-primary-200 dark:via-primary-800/60 to-transparent my-6 ${s}`})}function Zf({children:s,className:l=""}){return e.jsx("span",{className:`bg-gradient-to-r from-primary-600 to-violet-600 dark:from-primary-400 dark:to-violet-400 bg-clip-text text-transparent ${l}`,children:s})}function se({tone:s="gray",children:l}){return e.jsx("span",{className:`inline-flex items-center whitespace-nowrap rounded-full px-2.5 py-0.5 text-xs font-medium ring-1 ring-inset ${Ho[s]||Ho.gray}`,children:l})}function Ct({label:s,value:l,tone:i="gray",sub:o}){if(i==="featured")return e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary-600 to-violet-600 dark:from-primary-700 dark:to-violet-700 shadow-md shadow-primary-900/20 p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent pointer-events-none"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"text-2xl font-semibold text-white",children:l}),e.jsx("div",{className:"text-xs text-primary-200 mt-1",children:s}),o&&e.jsx("div",{className:"text-xs text-primary-300/70 mt-0.5",children:o})]})]});const d=i==="green"?"text-emerald-600 dark:text-emerald-400":i==="blue"?"text-sky-600 dark:text-sky-400":i==="amber"?"text-amber-600 dark:text-amber-400":i==="red"?"text-rose-600 dar
11k:text-rose-400":"text-gray-900 dark:text-gray-100",u=i==="green"?"dark:border-l-emerald-500":i==="blue"?"dark:border-l-sky-500":i==="amber"?"dark:border-l-amber-500":i==="red"?"dark:border-l-rose-500":"dark:border-l-gray-600";return e.jsxs("div",{className:["bg-white dark:bg-gray-800/80 rounded-2xl shadow-sm ring-1 ring-gray-200 dark:ring-gray-700/60 p-4","dark:border-l-2",u].join(" "),children:[e.jsx("div",{className:`text-2xl font-semibold ${d}`,children:l}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:s}),o&&e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-0.5",children:o})]})}function U({children:s,onClick:l,variant:i="primary",size:o="md",disabled:d,type:u="button",className:x="",title:y}){const p="inline-flex items-center justify-center gap-2 font-medium rounded-xl transition-colors duration-150 disabled:opacity-50 disabled:cursor-not-allowed",g={sm:"text-sm px-3 py-1.5 min-h-11",md:"text-sm px-4 py-2 min-h-11",lg:"text-base px-6 py-3 min-h-12"},b={primary:"bg-gradient-to-b from-primary-500 to-primary-600 text-white hover:from-primary-600 hover:to-primary-700 shadow-sm shadow-primary-900/20 dark:shadow-primary-950/40 dark:from-primary-500 dark:to-primary-600 dark:hover:from-primary-600 dark:hover:to-primary-700",success:"bg-gradient-to-b from-emerald-400 to-emerald-500 text-white hover:from-emerald-500 hover:to-emerald-600 shadow-sm shadow-emerald-900/20",danger:"bg-rose-500 text-white hover:bg-rose-600",soft:"bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-200 dark:hover:bg-gray-600",ghost:"text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700/60"};return e.jsx("button",{type:u,onClick:l,disabled:d,title:y,className:[p,g[o],b[i],x].filter(Boolean).join(" "),children:s})}const Rg={purple:{border:"border-l-primary-500",hover:"hover:bg-gradient-to-br hover:from-primary-50 hover:to-violet-50/60 dark:hover:from-primary-950/40 dark:hover:to-violet-950/20",iconBg:"bg-gradient-to-br from-primary-100 to-primary-50",iconBgDark:"dark:from-primary-900/60 dark:to-primary-800/30",iconColor:"text-primary-600 dark:text-primary-400"},green:{border:"border-l-emerald-500",hover:"hover:bg-gradient-to-br hover:from-emerald-50 hover:to-teal-50/60 dark:hover:from-emerald-950/30 dark:hover:to-teal-950/10",iconBg:"bg-gradient-to-br from-emerald-100 to-emerald-50",iconBgDark:"dark:from-emerald-900/50 dark:to-emerald-800/20",iconColor:"text-emerald-600 dark:text-emerald-400"},blue:{border:"border-l-sky-500",hover:"hover:bg-gradient-to-br hover:from-sky-50 hover:to-indigo-50/60 dark:hover:from-sky-950/30 dark:hover:to-indigo-950/10",iconBg:"bg-gradient-to-br from-sky-100 to-sky-50",iconBgDark:"dark:from-sky-900/50 dark:to-sky-800/20",iconColor:"text-sky-600 dark:text-sky-400"},amber:{border:"border-l-amber-500",hover:"hover:bg-gradient-to-br hover:from-amber-50 hover:to-orange-50/60 dark:hover:from-amber-950/30 dark:hover:to-orange-950/10",iconBg:"bg-gradient-to-br from-amber-100 to-amber-50",iconBgDark:"dark:from-amber-900/50 dark:to-amber-800/20",iconColor:"text-amber-600 dark:text-amber-400"}};function Ha({icon:s,title:l,description:i,onClick:o,href:d,tone:u="purple"}){const x=Rg[u]??Rg.purple,y=e.jsxs("div",{className:["h-full bg-white dark:bg-gray-800/80 rounded-2xl shadow-sm","ring-1 ring-gray-200 dark:ring-gray-700/60 p-5","border-l-4 transition-all duration-150","cursor-pointer hover:shadow-md hover:ring-gray-300 dark:hover:ring-gray-600 dark:hover:shadow-gray-950/60","flex items-center gap-4",x.border,x.hover].join(" "),children:[e.jsx("div",{className:`flex-shrink-0 w-14 h-14 rounded-xl flex items-center justify-center ${x.iconBg} ${x.iconBgDark} ${x.iconColor}`,children:s}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 leading-snug",children:l}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1 leading-snug",children:i})]})]});return d?e.jsx(Se,{to:d,className:"block h-full no-underline",children:y}):e.jsx("div",{onClick:o,className:"h-full",children:y})}function Ne({tone:s="blue",children:l}){return e.jsx("div",{className:`rounded-2xl px-4 py-3 text-sm r
11ing-1 ring-inset ${Ho[s]||Ho.blue}`,children:l})}function Ze({title:s,hint:l,doing:i,action:o,next:d,icon:u,tone:x="neutral"}){return e.jsxs("div",{className:`text-center py-10 px-4 rounded-2xl border-2 border-dashed ${x==="positive"?"border-emerald-200 bg-emerald-50/40 dark:border-emerald-800/60 dark:bg-emerald-950/20":"border-gray-200 dark:border-gray-700 bg-white/50 dark:bg-gray-800/30"}`,children:[u&&e.jsx("div",{className:"flex justify-center mb-3 text-gray-300 dark:text-gray-600",children:u}),e.jsx("p",{className:"text-gray-700 dark:text-gray-200 font-medium",children:s}),l&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1 max-w-md mx-auto",children:l}),i&&e.jsxs("p",{className:"mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-sky-800 dark:text-sky-200",children:[e.jsx("span",{"aria-hidden":"true",children:"â"}),i]}),(o||d)&&e.jsxs("div",{className:"mt-4 flex flex-col items-center gap-2 sm:flex-row sm:justify-center",children:[o,d&&e.jsx(Se,{to:d.to,className:"inline-flex min-h-11 items-center text-sm font-medium text-primary-600 hover:underline dark:text-primary-400 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 rounded-lg px-2",children:d.label})]})]})}function tt({label:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-8",children:[e.jsxs("svg",{className:"animate-spin w-10 h-10 text-primary-500 dark:text-primary-400",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),s&&e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:s})]})}function Xl({tabs:s,active:l,onChange:i}){return e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto pb-1",children:s.map(o=>{const d=o.key===l;return e.jsxs("button",{type:"button",onClick:()=>i(o.key),className:["inline-flex items-center gap-1.5 px-4 py-1.5 min-h-11 rounded-full text-sm whitespace-nowrap transition-colors duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400",d?"bg-primary-100 text-primary-700 font-medium dark:bg-primary-900/50 dark:text-primary-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700/60 dark:hover:text-gray-200 font-normal"].join(" "),children:[o.label,o.count!=null&&e.jsx("span",{className:`text-xs rounded-full px-1.5 py-0.5 font-normal ${d?"bg-primary-200 text-primary-700 dark:bg-primary-800 dark:text-primary-200":"bg-gray-200 text-gray-500 dark:bg-gray-700 dark:text-gray-400"}`,children:o.count})]},o.key)})})}function Bn({status:s}){const i={active:"green",done:"green",completed:"green",strong:"green",paused:"amber",pending:"amber",running:"amber",viable:"amber",error:"red",failed:"red"}[s.toLowerCase()]??"gray";return e.jsx(se,{tone:i,children:s})}const Zj=new Set(["input","select","textarea"]);function le({label:s,error:l,help:i,required:o,children:d,id:u}){const x=h.useId(),y=u||`ff-${x.replace(/[^a-zA-Z0-9_-]/g,"")}`,p=`${y}-label`,g=`${y}-help`,b=`${y}-error`,f=l?b:i?g:void 0,k=h.useRef(null),[w,N]=h.useState(null),[j,T]=h.useState(!0),S=h.Children.count(d)===1?h.Children.toArray(d)[0]:null,_=!!S&&h.isValidElement(S)&&typeof S.type=="string"&&Zj.has(S.type);let z=d;if(_){const te=S,pe=[te.props["aria-describedby"],f].filter(Boolean).join(" ")||void 0;z=h.cloneElement(te,{id:te.props.id||y,"aria-describedby":pe,"aria-invalid":l?!0:te.props["aria-invalid"],"aria-required":o?!0:te.props["aria-required"]})}const A=_?S.props.id||y:null;h.useEffect(()=>{if(_||!k.current)return;const te=Array.from(k.current.querySelectorAll("input:not([type=hidden]),select,textarea")),pe=te.find(he=>!(he.labels&&he.labels.length)&&!he.getAttribute("aria-label")&&!he.getAttribute("aria-labelledby"))||te.find(he=>he.id===y);if(!pe){T(!1),N(null);return}pe.id||(pe.id=y),f&&!pe.getAttribute("aria-describedby")&&pe.setAttribute("aria-describedby",f),l?pe.setAttribute("aria-invalid","true"):pe.getAttribute("aria-invalid")==="true"&&pe.removeAttribute("aria-invalid"),o&&!pe.getAttribute("aria-required")&&pe.setAttribute("aria-required","true"),T(!0),N(pe.id)});const L="text-xs font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",F=e.jsxs(e.Fragment,{children:[s,o&&e.jsx("span",{className:"text-rose-500 ml-0.5","aria-hidden":"true",children:"*"}),o&&e.jsx("span",{className:"sr-only",children:" (required)"})]}),D=_||j&&!!w;return e.jsxs("div",{className:"flex flex-col",ref:k,role:D?void 0:"group","aria-labelledby":D?void 0:p,"aria-describedby":D?void 0:f,children:[D?e.jsx("label",{id:p,htmlFor:A||w||y,className:L,children:F}):e.jsx("span",{id:p,className:L,children:F}),z,i&&!l&&e.jsx("p",{id:g,className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:i}),l&&e.jsx("p",{id:b,role:"alert",className:"text-xs text-rose-600 dar
11k:text-rose-400 mt-1",children:l})]})}function Et({open:s,onClose:l,title:i,children:o,footer:d,widthClass:u="max-w-lg"}){return s?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 dark:bg-black/70 backdrop-blur-sm",onClick:l,"aria-hidden":"true"}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":i,className:`relative z-10 flex flex-col w-full ${u} max-h-[90vh] bg-white dark:bg-gray-800 rounded-2xl shadow-2xl dark:shadow-gray-950`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-shrink-0 px-6 pt-6 pb-4",children:[i&&e.jsx("h2",{className:"font-display text-xl font-semibold text-gray-900 dark:text-gray-100 leading-tight",children:i}),e.jsx("button",{type:"button",onClick:l,"aria-label":"Close",className:"ml-auto -mr-2 -mt-2 flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-lg text-gray-400 dark:text-gray-400 hover:text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 pb-6",children:o}),d&&e.jsx("div",{className:"flex-shrink-0 border-t border-gray-100 dark:border-gray-700 px-6 py-4",children:d})]})]}):null}function Kj(s){return s==null?"â":s>=1e9?"$"+(s/1e9).toFixed(1)+"B":s>=1e6?"$"+(s/1e6).toFixed(1)+"M":s>=1e3?"$"+Math.round(s/1e3)+"K":"$"+s}function Jj(s){return s>=.7?"green":s>=.4?"amber":"gray"}function e1(s){return s>=.7?"Strong match":s>=.4?"Worth a review":"Low fit"}function t1(s){return s==="valid"?"green":s==="risky"?"amber":"gray"}function a1(s){return s==="valid"?"Verified":s==="risky"?"Risky":s==="invalid"?"Unverifiable":"Unverified"}function s1({items:s}){return e.jsx("nav",{"aria-label":"Breadcrumb",className:"mb-3 text-sm",children:e.jsx("ol",{className:"flex items-center gap-1.5 flex-wrap",children:s.map((l,i)=>{const o=i===s.length-1;return e.jsxs("li",{className:"flex items-center gap-1.5",children:[i>0&&e.jsx("span",{"aria-hidden":"true",className:"text-gray-300 dark:text-gray-700 select-none",children:"/"}),l.to&&!o?e.jsx(Se,{to:l.to,className:"inline-flex min-h-11 -my-2 items-center rounded px-1 -mx-1 text-gray-500 hover:text-primary-600 dark:text-gray-400 dark:hover:text-primary-400 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:l.label}):e.jsx("span",{"aria-current":o?"page":void 0,className:o?"text-gray-700 dark:text-gray-200 font-medium":"text-gray-500 dark:text-gray-400",children:l.label})]},"crumb-"+i)})})})}const n1={search:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 15.803a7.5 7.5 0 0010.607 10.607z",contacts:"M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z",campaign:"M19.114 5.636a9 9 0 010 12.728M16.463 8.288a5.25 5.25 0 010 7.424M6.75 8.25l4.72-4.72a.75.75 0 011.28.53v15.88a.75.75 0 01-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.01 9.01 0 012.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25H6.75z",list:"M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zM3.75 12h.007v.008H3.75V12zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm-.375 5.25h.007v.008H3.75v-.008zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z",analytics:"M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z",integrations:"M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244",calendar:"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5",orders:"M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 002.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 00-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75 2.25 2.25 0 00-.1-.664m-5.8 0A2.251 2.251 0 0113.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25zM6.75 12h.008v.008H6.75V12zm0 3h.008v.008H6.75V15zm0 3h.008v.008H6.75V18z",conversations:"M20.25 8.511c.884.284 1.5 1.128 1.5 2.097v4.286c0 1.136-.847 2.1-1.98 2.193-.34.027-.68.052-1.02.072v3.091l-3-3c-1.354 0-2.694-.055-4.02-.163a2.115 2.115 0 01-.825-.242m9.345-8.334a2.126 2.126 0 00-.476-.095 48.64 48.64 0 00-8.048 0c-1.131.094-1.976 1.057-1.976 2.192v4.286c0 .837.46 1.58 1.155 1.951m9.345-8.334V6.637c0-1.621-1.152-3.026-2.76-3.235A48.455 48.455 0 0011.25 3c-2.115 0-4.198.137-6.24.402-1.608.209-2.76 1.614-2.76 3.235v6.226c0 1.621 1.152 3.026 2.76 3.235.577.075 1.157.14 1.74.194V21l4.155-4.155",templates:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z",pipeline:"M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 01-.659 1.591l-5.432 5.432a2.25 2.25 0 00-.659 1.591v2.927a2.25 2.25 0 01-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 00-.659-1.591L3.659 7.409A2.25 2.25 0 013 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32
110 0112 3z",folder:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776",refresh:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99",clock:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z",currency:"M12 6v12m-3-2.818l.879.659c1.171.879 3.07.879 4.242 0 1.172-.879 1.172-2.303 0-3.182C13.536 12.219 12.768 12 12 12c-.725 0-1.45-.22-2.003-.659-1.106-.879-1.106-2.303 0-3.182s2.9-.879 4.006 0l.415.33M21 12a9 9 0 11-18 0 9 9 0 0118 0z",sparkle:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z",bookmark:"M17.593 3.322c1.1.128 1.907 1.077 1.907 2.185V21L12 17.25 4.5 21V5.507c0-1.108.806-2.057 1.907-2.185a48.507 48.507 0 0111.186 0z",outreach:"M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z"};function $e({name:s,className:l="w-6 h-6"}){const i=n1[s];if(!i)return null;const o=Array.isArray(i)?i:[i];return e.jsx("svg",{className:l,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:o.map((d,u)=>e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d},u))})}function Kf(s){return Ke(s,{month:"short",day:"numeric"})}function zg(s){return s==="email"?"blue":s==="social"?"green":s==="sms"?"amber":"gray"}const cm={blue:"bg-sky-50 dark:bg-sky-950/40 text-sky-600 dark:text-sky-400",green:"bg-emerald-50 dark:bg-emerald-950/40 text-emerald-600 dark:text-emerald-400",amber:"bg-amber-50 dark:bg-amber-950/40 text-amber-600 dark:text-amber-400",gray:"bg-gray-100 dark:bg-gray-700/50 text-gray-500 dark:text-gray-400"};function dm(){return e.jsx("svg",{className:"shrink-0 w-4 h-4 text-gray-300 dark:text-gray-600 opacity-0 -translate-x-1 group-hover:opacity-100 group-hover:translate-x-0 transition-all motion-reduce:transition-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})}function Lg({tone:s,icon:l,children:i,action:o}){return e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h2",{className:"flex items-center gap-2.5 text-lg font-semibold text-gray-900 dark:text-gray-100",children:[e.jsx("span",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${cm[s]}`,"aria-hidden":"true",children:l}),i]}),o]})}function qa(){return e.jsx("div",{className:"bg-gray-100 dark:bg-gray-700 animate-pulse motion-reduce:animate-none rounded-xl h-14"})}function r1({steps:s,onDismiss:l}){const i=s.filter(d=>d.done).length,o=Math.round(i/s.length*100);return e.jsxs(_e,{className:"mb-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Getting started"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"A few steps to get the most out of Fantize."})]}),e.jsx("button",{type:"button",onClick:l,className:"min-h-11 rounded-lg px-2 text-xs text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 shrink-0 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:"Dismiss"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-3 mb-4",children:[e.jsx("div",{className:"flex-1 h-2 rounded-full bg-gray-100 dark:bg-gray-700 overflow-hidden",role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,"aria-label":"Getting started progress",children:e.jsx("div",{className:"h-2 rounded-full bg-primary-500 transition-all duration-500 motion-reduce:transition-none",style:{width:`${o}%`}})}),e.jsxs("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 whitespace-nowrap",children:[i," of ",s.length," done"]})]}),e.jsx("ol",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:s.map((d,u)=>e.jsxs("li",{className:"flex items-center gap-3 py-3",children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center text-xs font-semibold shrink-0 ${d.done?"bg-emerald-500 text-white":"bg-gray-100 dark:bg-gray-700 text-gray-500"}`,"aria-hidden":"true",children:d.done?"â":u+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-sm font-medium ${d.done?"text-gray-400 dark:text-gray-500 line-through":"text-gray-900 dark:text-gray-100"}`,children:d.label}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:d.description})]}),d.done?e.jsx(se,{tone:"green",children:"Done"}):e.jsx(Se,{to:d.to,className:"shrink-0",children:e.jsx(U,{size:"sm",variant:"soft",children:d.cta}
11)})]},d.label))})]})}function l1({campaigns:s,loading:l}){const i=s.slice(0,5);return l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(qa,{}),e.jsx(qa,{}),e.jsx(qa,{})]}):i.length===0?e.jsx(Ze,{title:"No campaigns yet",hint:"Campaigns you create and send from Fantize appear here.",icon:e.jsx($e,{name:"campaign",className:"w-8 h-8"}),action:e.jsx(Se,{to:"/dashboard/campaigns",children:e.jsx(U,{variant:"primary",size:"sm",children:"Create a campaign"})})}):e.jsxs("div",{className:"flex flex-col gap-1",children:[i.map(o=>e.jsxs(Se,{to:"/dashboard/campaigns",className:"group flex items-center gap-3 px-3 py-2 min-h-11 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-700/40 transition-colors no-underline focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:[e.jsx("div",{className:`shrink-0 w-9 h-9 rounded-lg flex items-center justify-center ${cm[zg(o.type)]}`,"aria-hidden":"true",children:e.jsx($e,{name:"campaign",className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate group-hover:text-primary-600 dark:group-hover:text-primary-400",children:o.name}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-0.5",children:Kf(o.created_at)})]}),e.jsx(se,{tone:zg(o.type),children:o.type}),e.jsx(dm,{})]},o.id)),e.jsx(Se,{to:"/dashboard/campaigns",className:"mt-1 flex items-center justify-center gap-1 rounded-xl min-h-11 text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400 hover:bg-gray-50 dark:hover:bg-gray-700/40 no-underline focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:"All campaigns"})]})}function i1({runs:s,loading:l}){const i=Ya(),o=[...s].sort((d,u)=>Gt(u.created_at)-Gt(d.created_at)).slice(0,5);return l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(qa,{}),e.jsx(qa,{}),e.jsx(qa,{})]}):o.length===0?e.jsx(Ze,{title:"No searches yet",hint:"Prospecting searches and the leads they find appear here.",icon:e.jsx($e,{name:"search",className:"w-8 h-8"}),action:e.jsx(U,{variant:"primary",size:"sm",onClick:()=>i("/dashboard/prospecting/searches"),children:"Start a search"})}):e.jsxs("div",{className:"flex flex-col gap-1",children:[o.map(d=>{const u=d.status==="running"?"amber":d.status==="done"&&(d.strong_matches??0)>0?"green":"blue";return e.jsxs(Se,{to:`/dashboard/prospecting/results/${d.id}`,className:"group flex items-center gap-3 px-3 py-2 min-h-11 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-700/40 transition-colors no-underline focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:[e.jsx("div",{className:`shrink-0 w-9 h-9 rounded-lg flex items-center justify-center ${cm[u]}`,"aria-hidden":"true",children:e.jsx($e,{name:"search",className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate group-hover:text-primary-600 dark:group-hover:text-primary-400",children:d.label||"Search"}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-0.5",children:Kf(d.created_at)})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d.status==="running"&&e.jsx(We,{kind:"monitoring",label:"Running"}),d.status==="done"&&(d.strong_matches??0)>0&&e.jsxs(se,{tone:"green",children:[d.strong_matches," strong"]}),d.status==="done"&&(d.viable_count??0)>0&&e.jsxs(se,{tone:"amber",children:[d.viable_count," viable"]}),d.status!=="running"&&e.jsx(Bn,{status:d.status})]}),e.jsx(dm,{})]},d.id)}),e.jsx(Se,{to:"/dashboard/prospecting/results",className:"mt-1 flex items-center justify-center gap-1 rounded-xl min-h-11 text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400 hover:bg-gray-50 dark:hover:bg-gray-700/40 no-underline focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:"All results"})]})}function Nu({to:s,icon:l,label:i,value:o,sub:d,accent:u}){const x={blue:"bg-sky-50 dark:bg-sky-950/40 text-sky-600 dark:text-sky-400",amber:"bg-amber-50 dark:bg-amber-950/40 text-amber-600 dar
11k:text-amber-400",violet:"bg-primary-50 dark:bg-primary-950/40 text-primary-600 dark:text-primary-400"}[u];return e.jsxs(Se,{to:s,className:"group relative flex items-center gap-4 p-5 min-h-11 no-underline transition-colors hover:bg-gray-50/80 dark:hover:bg-gray-700/30 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500",children:[e.jsx("div",{className:`shrink-0 w-11 h-11 rounded-xl flex items-center justify-center ${x}`,"aria-hidden":"true",children:l}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-[1.6rem] leading-none font-semibold tracking-tight tabular-nums text-gray-900 dark:text-gray-100",children:o}),e.jsx("div",{className:"mt-1 text-sm font-medium text-gray-700 dark:text-gray-300",children:i}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:d})]}),e.jsx(dm,{})]})}function o1(){const{account:s}=zt(),[l,i]=h.useState(null),[o,d]=h.useState([]),[u,x]=h.useState([]),[y,p]=h.useState([]),[g,b]=h.useState(!1),[f,k]=h.useState(!1),[w,N]=h.useState(!0),[j,T]=h.useState(!0),[S,_]=h.useState(!0),[z,A]=h.useState(""),[L,F]=h.useState(null),D=s?`fantize_onboarding_dismissed_${s.id}`:"";h.useEffect(()=>{D&&k(localStorage.getItem(D)==="1")},[D]);function te(){D&&localStorage.setItem(D,"1"),k(!0)}h.useEffect(()=>{pf.get().then(ye=>i(ye)).catch(ye=>A(ye.message)).finally(()=>N(!1)),Du.get().then(ye=>b(!!ye.configured)).catch(()=>b(!1)),Me.runs().then(ye=>d(ye.runs)).catch(()=>d([])).finally(()=>T(!1)),xa.list().then(ye=>x(ye.campaigns)).catch(()=>x([])).finally(()=>_(!1)),Za.list().then(ye=>p(ye.lists)).catch(()=>p([])),je.attention().then(F).catch(()=>F("error"))},[]);const pe=s?.name?.split(" ")[0]??"there",X=(s?.created_at?Pf(s.created_at)<1440*60*1e3:!1)?"Welcome":"Welcome back",I=o.reduce((ye,ge)=>ye+(ge.viable_count??0),0),q=o.filter(ye=>ye.status==="done"&&(ye.strong_matches??0)>0),be=u.filter(ye=>ye.type==="draft"||ye.status==="draft"),ne=u.filter(ye=>ye.status==="sent"||ye.status==="sending"||ye.status==="active").length,M=[{label:"Set up your brand",description:"Add your name, logo, and colors so campaigns look like you.",done:g,to:"/dashboard/brand",cta:"Set up"},{label:"Import your contacts",description:"Bring in the people you want to reach.",done:(l?.stats.contacts??0)>0,to:"/dashboard/contacts",cta:"Import"},{label:"Run your first lead search",description:"Find new prospects that match your ideal customer.",done:o.length>0,to:"/dashboard/prospecting/searches",cta:"Search"}],Y=M.every(ye=>ye.done),oe=!!l&&!Y&&!f,Ce=L&&L!=="error"?L:null,Ae=Ce?.protection||{},H=Ce?.counts||{},Z=Number(H.pending_reviews)||0,$=Number(H.overdue_reviews)||0,O=Array.isArray(Ce?.items)?Ce.items.length:0,P=Ce?[{key:"hs",label:"HubSpot",kind:Ae.hubspot_connected?"connected":"not-configured",value:Ae.hubspot_connected?"Connected":"Not connected"},{key:"in",label:"Instantly",kind:Ae.instantly_connected?"connected":"not-configured",value:Ae.instantly_connected?"Connected â monitoring for replies":"Not connected"},{key:"rev",label:"Manual review",kind:Ae.actions_enabled?"ready":"disabled",value:Ae.actions_enabled?"Live":"Switched off on the server"},{key:"auto",label:"Automatic HubSpot sync",kind:Ae.auto_sync_enabled?"ready":"disabled",value:Ae.auto_sync_enabled?"On":"Off â human review required"},{key:"not",label:"Notifications",kind:Ae.external_notifications?"ready":"info",value:Ae.external_notifications?"External channels on":"In-app only"},{key:"wait",label:"Waiting for a person",kind:O===0?"healthy":$>0?"action-required":"needs-review",value:O===0?"Nothing":`${O} item${O===1?"":"s"}`,to:"/dashboard/leads/activity",toLabel:"Activity & Issues"}]:[],V=L==="error"?{title:"Check Activity & Issues",body:"The operating status could not be loaded, so nothing below can be assumed. Activity & Issues loads it independently.",to:"/dashboard/leads/activity",cta:"Open Activity & Issues",tone:"amber"}:Ce?$>0?{title:`${$} repl${$===1?"y has":"ies have"} waited past the review window`,body:"Oldest first. Each one is a person who answered a campaign and is waiting on a decision.",to:"/dashboard/leads/review",cta:"Open Reply Review",tone:"amber"}:Z>0?{title:`${Z} repl${Z===1?"y is":"ies are"} waiting for a decision`,body:"Nothing reaches a salesperson or HubSpot until someone decides.",to:"/dashboard/leads/review",cta:"Open Reply Review",tone:"blue"}:O>0?{title:`${O} item${O===1?"":"s"} need${O===1?"s":""} attention`,body:"Campaign routing, a provider hold or a handoff that did not complete. None of them stops the rest of the workflow.",to:"/dashboard/leads/activity",cta:"Open Activity & Issues",tone:"amber"}:!Ae.hubspot_connected||!Ae.instantly_connected?{title:"Connect the missing provider",body:"Replies cannot be read or handed off until both HubSpot and Instantly are connected.",to:"/dashboard/integrations?tab=crm-sync",cta:"Open Integrations",tone:"amber"}:q.length>0?{title:`${q.length} search result${q.length===1?"":"s"} ready to review`,body:"Strong matches are waiting to be reviewed, enriched and saved.",to:"/dashboard/prospecting/results",cta:"Open Results",tone:"green"}:be.length>0?{title:`${be.length} campaign draft${be.length===1?"":"s"} awaiting review`,body:"Drafts are not sent until you send them.",to:"/dashboard/campaigns",cta:"Open Campaigns",tone:"blue"}:{title:"Nothing needs you right now",body:"Fantize is monitoring for replies. Decisions stay manual until automatic sync is enabled under Operational Readiness.",to:"/dashboard/leads/activity",cta:"See what Fantize is doing",tone:"green"}:null;return z?e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(Xe,{title:"Overview"}),e.jsx("div",{className:"rounded-2xl bg-rose-50 text-rose-700 ring-1 ring-rose-200 px-5 py-4 text-sm font-medium",role:"alert",children:z})]}):e.jsxs("div",{className:"max-w-5xl mx-auto pb-8",children:[e.jsx(Xe,{title:`${X}, ${pe}`,documentTitle:"Overview",subtitle:"Whether Fantize is operating normally, what needs attention, and what to do next.",status:Ce?e.jsxs(e.Fragment,{children:[e.jsx(We,{kind:O===0?"healthy":$>0?"action-required":"needs-review",label:O===0?"Operating normally":`${O} item${O===1?" needs":"s need"} attention`,size:"md"}),e.jsx(We,{kind:Ae.auto_sync_enabled?"ready":"info",label:Ae.auto_sync_enabled?"Automatic sync on":"Every reply waits for a person"}),e.jsxs("span",{className:"text-xs text-gray-500",children:["Checked ",Ke(Ce.generated_at)]})]}):L==="error"?e.jsx(We,{kind:"unavailable",label:"Operating status unavailable"}):e.jsx(We,{kind:"unavailable",label:"Checking operating statusâ¦"})}),oe&&e.jsx(r1,{steps:M,onDismiss:te}
11),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-5 gap-6 mb-6",children:[e.jsx("div",{className:"lg:col-span-3",children:e.jsxs(_e,{className:"h-full",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-3",children:"Operating status"}),Ce?e.jsx(zr,{items:P,columns:2,dense:!0}):L==="error"?e.jsxs("p",{className:"text-sm text-gray-500",children:["Could not be loaded. ",e.jsx(Se,{to:"/dashboard/leads/activity",className:"underline",children:"Open Activity & Issues"})," to try again."]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(qa,{}),e.jsx(qa,{})]})]})}),e.jsx("div",{className:"lg:col-span-2",children:V?e.jsx(Wf,{title:V.title,body:V.body,to:V.to,cta:V.cta,tone:V.tone}):e.jsx(qa,{})})]}),e.jsx("div",{className:"mb-6 rounded-2xl bg-white dark:bg-gray-800/80 ring-1 ring-gray-200 dark:ring-gray-700/60 shadow-sm overflow-hidden",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 divide-y sm:divide-y-0 sm:divide-x divide-gray-100 dark:divide-gray-700/60",children:w?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-5",children:e.jsx(qa,{})}),e.jsx("div",{className:"p-5",children:e.jsx(qa,{})}),e.jsx("div",{className:"p-5",children:e.jsx(qa,{})})]}):l?e.jsxs(e.Fragment,{children:[e.jsx(Nu,{to:"/dashboard/prospecting/results",accent:"blue",icon:e.jsx($e,{name:"search",className:"w-5 h-5"}),label:"Viable leads found",value:I.toLocaleString(),sub:q.length>0?`${q.length} result${q.length===1?"":"s"} ready to review`:o.length>0?`From ${o.length} search${o.length!==1?"es":""}`:"No searches yet"}),e.jsx(Nu,{to:"/dashboard/campaigns",accent:"amber",icon:e.jsx($e,{name:"campaign",className:"w-5 h-5"}),label:"Campaigns",value:l.stats.campaigns.toLocaleString(),sub:be.length>0?`${be.length} draft${be.length!==1?"s":""} in progress`:ne>0?`${ne} live`:l.stats.campaigns>0?"None in progress":"No campaigns yet"}),e.jsx(Nu,{to:"/dashboard/lists",accent:"violet",icon:e.jsx($e,{name:"list",className:"w-5 h-5"}),label:"Lists",value:y.length.toLocaleString(),sub:l.stats.contacts>0?`${l.stats.contacts.toLocaleString()} contact${l.stats.contacts!==1?"s":""} total`:"No contacts yet"})]}):null})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(_e,{children:[e.jsx(Lg,{tone:"amber",icon:e.jsx($e,{name:"campaign",className:"w-4 h-4"}),children:"Recent campaigns"}),e.jsx(l1,{campaigns:u,loading:S})]}),e.jsxs(_e,{children:[e.jsx(Lg,{tone:"blue",icon:e.jsx($e,{name:"search",className:"w-4 h-4"}),children:"Recent searches"}),e.jsx(i1,{runs:o,loading:j})]})]})]})}function Jf({onClose:s,onStartImport:l}){const[i,o]=h.useState(1),d=()=>{const p=`email,first_name,last_name,company,phone 12[email protected],Contact,One,Acme Corp,555-0101 13[email protected],Contact,Two,Tech Innovations,555-0102 14[email protected],Contact,Three,StartupXYZ,555-0103 15[email protected],Contact,Four,Enterprise Solutions,555-0104 16[email protected],Contact,Five,Creative Agency,555-0105`,g=new Blob([p],{type:"text/csv"}),b=window.URL.createObjectURL(g),f=document.createElement("a");f.href=b,f.download="sample-contacts.csv",document.body.appendChild(f),f.click(),document.body.removeChild(f),window.URL.revokeObjectURL(b)},u=()=>{s(),l?.()},x=[{title:"Prepare Your CSV File",icon:"ð",content:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-700",children:"Start with a spreadsheet containing your contacts. You can use Excel, Google Sheets, or any spreadsheet software."}),e.jsx("div",{className:"bg-blue-50 border-l-4 border-blue-400 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-semibold text-blue-900 mb-1",children:"Required Column: email"}),e.jsxs("p",{className:"text-blue-800",children:["Your CSV must have an ",e.jsx("code",{className:"bg-white dark:bg-gray-700 dark:text-gray-200 px-1 rounded",children:"email"})," column. All other columns are optional."]})]})]})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"Supported Columns:"}),e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-green-600 font-bold",children:"â"}),e.jsxs("div",{children:[e.jsx("code",{className:"bg-gray-100 px-2 py-0.5 rounded text-xs font-mono",children:"email"}),e.jsx("span",{className:"text-red-600 ml-1",children:"*"}),e.jsx("span",{className:"text-gray-600 ml-2",children:"Contact's email address (required)"})]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-green-600 font-bold",children:"â"}),e.jsxs("div",{children:[e.jsx("code",{className:"bg-gray-100 px-2 py-0.5 rounded text-xs font-mono",children:"first_name"}),e.jsx("span",{className:"text-gray-600 ml-2",children:"Contact's first name"})]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-green-600 font-bold",children:"â"}),e.jsxs("div",{children:[e.jsx("code",{className:"bg-gray-100 px-2 py-0.5 rounded text-xs font-mono",children:"last_name"}),e.jsx("span",{className:"text-gray-600 ml-2",children:"Contact's last name"})]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-green-600 font-bold",children:"â"}),e.jsxs("div",{children:[e.jsx("code",{className:"bg-gray-100 px-2 py-0.5 rounded text-xs font-mono",children:"company"}),e.jsx("span",{className:"text-gray-600 ml-2",children:"Company or organization name"})]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-green-600 font-bold",children:"â"}),e.jsxs("div",{children:[e.jsx("code",{className:"bg-gray-100 px-2 py-0.5 rounded text-xs font-mono",children:"phone"}),e.jsx("span",{className:"text-gray-600 ml-2",children:"Phone number (any format)"})]})]})]})]}),e.jsx("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-3 text-sm",children:e.jsxs("p",{className:"text-yellow-900",children:[e.jsx("span",{className:"font-semibold",children:"Note:"})," Extra columns in your CSV will be ignored. Only the columns listed above will be imported."]})})]})},{title:"Format Your CSV Correctly",icon:"â ",content:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-700",children:"Ensure your CSV follows the correct format for successful importing."}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"Example CSV Format:"}),e.jsx("div",{className:"bg-gray-900 text-gray-100 p-4 rounded-lg overflow-x-auto",children:e.jsx("pre",{className:"text-xs font-mono",children:`email,first_name,last_name,company,phone 17[email protected],Contact,One,Acme Corp,555-0101 18[email protected],Contact,Two,Tech Innovations,555-0102 19[email protected],Contact,Three,StartupXYZ,555-0103`})}),e.jsxs("button",{onClick:d,className:"mt-3 inline-flex items-center gap-2 text-sm font-medium text-primary-600 hover:text-primary-700",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"})}),"Download Sample CSV"]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-3",children:"Formatting Rules:"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-green-100 rounded-full flex items-center justify-center text-green-600 font-bold text-sm",children:"1"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-gray-100",children:"First row must be headers"}),e.jsxs("p",{className:"text-gray-600",children:["Column names should be lowercase and match exactly: ",e.jsx("code",{className:"bg-gray-100 px-1 rounded text-xs",children:"email"}),", ",e.jsx("code",{className:"bg-gray-100 px-1 rounded text-xs",children:"first_name"}),", etc."]})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-green-100 rounded-full flex items-center justify-center text-green-600 font-bold text-sm",children:"2"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Use commas to separate values"}),e.jsx("p",{className:"text-gray-600",children:'CSV stands for "Comma-Separated Values" - each field should be separated by a comma'})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-green-100 rounded-full flex items-center justify-center text-green-600 font-bold text-sm",children:"3"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-gray-100",children:"One contact per row"}),e.jsx("p",{className:"text-gray-600",children:"Each row after the header represents one contact"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-green-100 rounded-full flex items-center justify-center text-green-600 font-bold text-sm",children:"4"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Empty fields are allowed"}),e.jsxs("p",{className:"text-gray-600",children:["If you don't have data for a field, leave it empty: ",e.jsx("code",{className:"bg-gray-100 px-1 rounded text-xs",children:"[email protected],Contact,,CompanyX,"})]})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-green-100 rounded-full flex items-center justify-center text-green-600 font-bold text-sm",children:"5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Save as CSV format"}),e.jsx("p",{className:"text-gray-600",children:'In Excel or Google Sheets, use "File â Save As â CSV" or "File â Download â CSV"'})]})]})]})]})]})},{title:"Upload Your CSV File",icon:"ð¤",content:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-700",children:"Once your CSV is ready, you can upload it to import your contacts."}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-3",children:"Two Ways to Import:"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"border-2 border-gray-200 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 bg-primary-100 rounded-lg flex items-center justify-center",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5 text-primary-600",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Method 1: Upload CSV File"}),e.jsx("p",{className:"text-sm text-gray-600 mb-2",children:'Click the "Import CSV" button and select your CSV file from your computer.'}),e.jsx("div",{className:"text-xs text-gray-500 bg-gray-50 p-2 rounded",children:"Best for larger contact lists and when you have the CSV file saved locally."})]})]})}),e.jsx("div",{className:"border-2 border-gray-200 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 bg-purple-100 rounded-lg flex items-center justify-center",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5 text-purple-600",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 002.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 00-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75 2.25 2.25 0 00-.1-.664m-5.8 0A2.251 2.251 0 0113.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25zM6.75 12h.008v.008H6.75V12zm0 3h.008v.008H6.75V15zm0 3h.008v.008H6.75V18z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Method 2: Paste CSV Data"}),e.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Copy your CSV data from Excel or Google Sheets and paste it directly into the text area."}),e.jsx("div",{className:"text-xs text-gray-500 bg-gray-50 p-2 rounded",children:"Qu
19ick and convenient for smaller lists or when copying directly from spreadsheet software."})]})]})})]})]}),e.jsx("div",{className:"bg-green-50 border-l-4 border-green-400 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5 text-green-600 flex-shrink-0 mt-0.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-semibold text-green-900 mb-1",children:"What happens during import:"}),e.jsxs("ul",{className:"text-green-800 space-y-1",children:[e.jsx("li",{children:"⢠Duplicate emails will be automatically skipped"}),e.jsx("li",{children:"⢠Invalid email addresses will be skipped"}),e.jsx("li",{children:"⢠You'll see a summary showing how many contacts were imported and skipped"}),e.jsx("li",{children:"⢠Successfully imported contacts appear in your Contacts list immediately"})]})]})]})})]})},{title:"Troubleshooting Tips",icon:"ð§",content:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-700",children:"Common issues and how to fix them:"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"border-l-4 border-red-400 bg-red-50 p-4",children:[e.jsx("h5",{className:"font-semibold text-red-900 mb-2",children:'â "Invalid CSV format"'}),e.jsx("p",{className:"text-sm text-red-800 mb-2",children:"This error means your file isn't properly formatted as a CSV."}),e.jsxs("div",{className:"text-xs text-red-700 dark:text-red-300 bg-white dark:bg-gray-700 p-2 rounded",children:[e.jsx("strong",{children:"Solution:"}),' Make sure you saved the file as CSV (not Excel .xlsx). In Excel, use "File â Save As â CSV". In Google Sheets, use "File â Download â Comma-separated values (.csv)".']})]}),e.jsxs("div",{className:"border-l-4 border-yellow-400 bg-yellow-50 p-4",children:[e.jsx("h5",{className:"font-semibold text-yellow-900 mb-2",children:'â ï¸ "Missing required column: email"'}),e.jsx("p",{className:"text-sm text-yellow-800 mb-2",children:"The email column is missing or incorrectly named."}),e.jsxs("div",{className:"text-xs text-yellow-700 dark:text-yellow-300 bg-white dark:bg-gray-700 p-2 rounded",children:[e.jsx("strong",{children:"Solution:"})," Make sure your first row has a column named exactly ",e.jsx("code",{className:"bg-gray-100 px-1 rounded",children:"email"}),' (lowercase, no spaces). Check for typos like "Email" or "e-mail".']})]}),e.jsxs("div",{className:"border-l-4 border-orange-400 bg-orange-50 p-4",children:[e.jsx("h5",{className:"font-semibold text-orange-900 mb-2",children:'â ï¸ "All contacts were skipped"'}),e.jsx("p",{className:"text-sm text-orange-800 mb-2",children:"No contacts were imported - they were all duplicates or invalid."}),e.jsxs("div",{className:"text-xs text-orange-700 dark:text-orange-300 bg-white dark:bg-gray-700 p-2 rounded",children:[e.jsx("strong",{children:"Solution:"})," Check if these contacts already exist in your system. Also verify that all email addresses are valid (e.g., have @ symbol and domain)."]})]}),e.jsxs("div",{className:"border-l-4 border-blue-400 bg-blue-50 p-4",children:[e.jsx("h5",{className:"font-semibold text-blue-900 mb-2",children:'â¹ï¸ "Some contacts were skipped"'}),e.jsx("p",{className:"text-sm text-blue-800 mb-2",children:"This is normal - duplicates and invalid emails are skipped."}),e.jsxs("div",{className:"text-xs text-blue-700 dark:text-blue-300 bg-white dark:bg-gray-700 p-2 rounded",children:[e.jsx("strong",{children:"Note:"})," The system prevents duplicate contacts automatically. This is not an error - your valid, unique contacts were imported successfully."]})]})]}),e.jsxs("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-4",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"Still having trouble?"}),e.jsxs("div",{className:"text-sm text-gray-700 space-y-2",children:[e.jsx("p",{children:"Try these steps:"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-2",children:[e.jsx("li",{children:"Download our sample CSV file and verify it imports successfully"}),e.jsx("li",{children:"Copy your data into the sample CSV template"}),e.jsx("li",{children:"Make sure there are no extra commas or special characters in your data"}),e.jsx("li",{children:"Verify each email address is valid"}),e.jsx("li",{children:"Try importing a small batch first (5-10 contacts) to test"})]})]})]})]})}],y=x[i-1];return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-2xl max-w-3xl w-full max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:"How to Import Contacts"}),e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:"Step-by-step guide to importing your contacts via CSV"})]}),e.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600 transition-colors","aria-label":"Close",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"w-6 h-6",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"px-6 py-4 bg-gray-50 border-b border-gray-200",children:e.jsx("div",{className:"flex items-center justify-between mb-2",children:x.map((p,g)=>e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsxs("button",{onClick:()=>o(g+1),className:`flex flex-col items-center flex-1 transition-all ${i===g+1?"scale-110":""}`,children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center text-lg font-bold mb-1 transition-all ${i>g+1?"bg-green-500 text-white":i===g+1?"bg-primary-500 text-white ring-4 ring-primary-100":"bg-gray-200 text-gray-400"}`,children:i>g+1?"â":p.icon}),e.jsx("span",{className:`text-xs font-medium text-center hidden sm:block ${i===g+1?"text-primary-600":"text-gray-500"}`,children:p.title})]}),g<x.length-1&&e.jsx("div",{className:`h-1 flex-1 mx-1 rounded transition-all ${i>g+1?"bg-green-500":"bg-gray-200"}`})]},g))})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6",children:e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"text-4xl",children:y.icon}),e.jsx("h3",{className:"text-xl font-bold text-gray-900 dark:text-gray-100",children:y.title})]}
19),y.content]})}),e.jsx("div",{className:"border-t border-gray-200 px-6 py-4 bg-gray-50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-sm text-gray-600",children:["Step ",i," of ",x.length]}),e.jsxs("div",{className:"flex gap-3",children:[i>1&&e.jsx("button",{onClick:()=>o(i-1),className:"px-4 py-2 border border-gray-300 rounded-lg font-medium hover:bg-gray-100 transition-colors",children:"â Previous"}),i<x.length?e.jsx("button",{onClick:()=>o(i+1),className:"px-4 py-2 bg-primary-500 hover:bg-primary-600 text-white rounded-lg font-medium transition-colors",children:"Next â"}):e.jsxs("button",{onClick:u,className:"px-6 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg font-bold transition-colors flex items-center gap-2",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"w-5 h-5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Ready to Import"]})]})]})})]})})}function c1(s){const l=String(s??"");return/^[=+\-@\t\r]/.test(l)?`'${l}`:l}function Ua(s,l){const i=l.map(x=>x.map(y=>{const p=c1(y);return/[",\n\r]/.test(p)?`"${p.replace(/"/g,'""')}"`:p}).join(",")).join(`\r 20`),o=new Blob(["\uFEFF"+i],{type:"text/csv;charset=utf-8;"}),d=URL.createObjectURL(o),u=document.createElement("a");u.href=d,u.download=s.endsWith(".csv")?s:`${s}.csv`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(d)}function ep(s){return s.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"export"}function Fl(s){const l=["Email","First Name","Last Name","Company","Phone","Status","Origin","From Search","Why Matched","Matched","Added"],i=s.map(o=>[o.email,o.first_name??"",o.last_name??"",o.company??"",o.phone??"",o.status??"",o.origin?.source??o.source??"",o.origin?.search_name??"",o.origin?.why_matched??"",o.origin?.matched_at?Ia(o.origin.matched_at):"",Ke(o.created_at)]);return[l,...i]}const _u=de,d1={"lead-gen":"Lead search",manual:"Added manually",import:"Imported",founder_network:"Founder network",fantize:"Sign-up",fantize_company_registration:"Company sign-up"};function tp(s){return s?d1[s]||s.replace(/[-_]/g," ").replace(/\b\w/g,l=>l.toUpperCase()):"Unknown"}const Mg=s=>[s.first_name,s.last_name].filter(Boolean).join(" "),yo=s=>s.origin?.source||s.source||"unknown";function Ol({field:s,label:l,sortField:i,sortDir:o,onSort:d}){const u=i===s;return e.jsx("th",{scope:"col","aria-sort":u?o==="asc"?"ascending":"descending":"none",className:"text-left px-2 py-1 font-medium text-gray-500 dark:text-gray-400",children:e.jsxs("button",{type:"button",onClick:()=>d(s),"aria-label":`Sort by ${l}${u?o==="asc"?", ascending":", descending":""}`,className:`inline-flex min-h-11 items-center gap-1 rounded-lg px-2 hover:text-gray-700 dark:hover:text-gray-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 ${u?"text-gray-700 dark:text-gray-200":""}`,children:[l,e.jsx("span",{className:"text-[10px] leading-none","aria-hidden":"true",children:u?o==="asc"?"â²":"â¼":"â"})]})})}function Og({contact:s,lists:l,onAddToList:i,onAddToNewList:o,onDelete:d}){const[u,x]=h.useState(!1);return e.jsxs("div",{className:"relative inline-block text-left",children:[e.jsx("button",{onClick:()=>x(y=>!y),"aria-label":"Contact actions",className:"px-2 py-1 rounded-lg text-gray-400 hover:text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700 text-lg leading-none min-h-11 min-w-11 justify-center",children:"â¯"}),u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>x(!1)}),e.jsxs("div",{className:"absolute right-0 z-20 mt-1 w-56 rounded-xl bg-white dark:bg-gray-800 shadow-lg ring-1 ring-gray-100 dark:ring-gray-700 py-1 max-h-80 overflow-y-auto",children:[s.origin?.run_id&&e.jsx(Se,{to:`/dashboard/prospecting/results/${s.origin.run_id}`,onClick:()=>x(!1),className:"block px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",children:"View origin search â"}),e.jsx("div",{className:"px-4 pt-2 pb-1 text-[11px] font-medium uppercase tracking-wide text-gray-400",children:"Add to list"}),l.length===0&&e.jsx("div",{className:"px-4 py-1.5 text-xs text-gray-400",children:"No lists yet"}),l.map(y=>e.jsx("button",{onClick:()=>{x(!1),i(s.id,y.id,y.name)},className:"block w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700 truncate",children:y.name},y.id)),e.jsx("button",{onClick:()=>{x(!1),o(s.id)},className:"block w-full text-left px-4 py-2 text-sm text-primary-600 hover:bg-gray-50 dark:hover:bg-gray-700",children:"ï¼ New listâ¦"}),e.jsx("div",{className:"my-1 border-t border-gray-100 dark:border-gray-700"}),e.jsx("button",{onClick:()=>{x(!1),d(s.id)},className:"block w-full text-left px-4 py-2 text-sm text-rose-600 hover:bg-rose-50 dark:hover:bg-rose-900/20",children:"Delete contact"})]})]})]})}function $g({origin:s,source:l}){const i=s?.source||l,o=tp(i),d=i==="lead-gen";return e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx(se,{tone:d?"blue":"gray",children:o}),d&&s?.run_id?e.jsx(Se,{to:`/dashboard/prospecting/results/${s.run_id}`,className:"text-xs text-primary-600 hover:underline truncate max-w-[14rem]",title:s.why_matched||s.search_name||"View originating search",children:s.search_name?`from â${s.search_name}â`:"View search â"}):d&&s?.search_name?e.jsxs("span",{className:"text-xs text-gray-400 truncate max-w-[14rem]",children:["from â",s.search_name,"â"]}):null]})}
20function u1(){const[s,l]=h.useState([]),[i,o]=h.useState(""),[d,u]=h.useState(!0),[x,y]=h.useState(""),[p,g]=h.useState(!1),[b,f]=h.useState(!1),[k,w]=h.useState(null),[N,j]=h.useState(!1),[T,S]=h.useState([]),[_,z]=h.useState(""),[A,L]=h.useState("date"),[F,D]=h.useState("desc"),[te,pe]=h.useState("all"),he=h.useRef(null);function X(O){A===O?D(P=>P==="asc"?"desc":"asc"):(L(O),D(O==="date"?"desc":"asc"))}const I=O=>{z(O),setTimeout(()=>z(""),2500)};async function q(){try{const{lists:O}=await Za.list();S(O)}catch{}}async function be(O,P,V){try{await Za.addContacts(P,[O]),I(`Added to â${V}â.`),q()}catch(ye){y(ye.message)}}async function ne(O){const P=window.prompt("New list name");if(!(!P||!P.trim()))try{const V=await Za.create(P.trim());await Za.addContacts(V.id,[O]),I(`Created â${V.name}â and added the contact.`),q()}catch(V){y(V.message)}}const M=async()=>{j(!0),y("");try{const{contacts:O}=await Ba.list({limit:5e3,search:i||void 0});if(O.length===0){y("No contacts to export.");return}const P=new Date().toISOString().slice(0,10);Ua(`fantize-contacts-${P}.csv`,Fl(O)),Ie.track("contacts_exported",{count:O.length,search:!!i})}catch(O){y(O.message)}finally{j(!1)}},Y=O=>{u(!0),Ba.list({limit:2e3,search:O}).then(P=>{l(P.contacts),Ie.track("contacts_loaded",{count:P.contacts.length,search:!!O})}).catch(P=>y(P.message)).finally(()=>u(!1))};h.useEffect(()=>{Ie.track("page_view",{page:"contacts",path:"/dashboard/contacts"}),console.log("ð¥ [ContactsPage] Page viewed"),Y(),q()},[]);const oe=O=>{O.preventDefault(),Y(i)},Ce=async O=>{const P=O.target.files?.[0];if(P){console.log("ð [ContactsPage] Starting contact import:",P.name),Ie.track("contact_import_started",{fileName:P.name,fileSize:P.size,source:"contacts_page"});try{const V=await Ba.import(P);console.log("â
[ContactsPage] Contact import success:",V),Ie.track("contact_import_success",{imported:V.imported,skipped:V.skipped,source:"contacts_page"}),w(V),Y(i)}catch(V){console.error("â [ContactsPage] Contact import failed:",V.message),Ie.trackError("contact_import",V,{fileName:P.name,source:"contacts_page"}),y(V.message)}he.current&&(he.current.value="")}},Ae=async O=>{if(window.confirm("Delete this contact? This cannot be undone."))try{await Ba.delete(O),l(s.filter(P=>P.id!==O))}catch(P){y(P.message)}},H=i.trim().length>0,Z=Array.from(new Set(s.map(yo))).sort(),$=s.filter(O=>te==="all"||yo(O)===te).sort((O,P)=>{let V=0;switch(A){case"date":V=Gt(O.created_at)-Gt(P.created_at);break;case"company":V=(O.company||"").localeCompare(P.company||"",void 0,{sensitivity:"base"});break;case"name":V=Mg(O).localeCompare(Mg(P),void 0,{sensitivity:"base"});break;case"email":V=(O.email||"").localeCompare(P.email||"",void 0,{sensitivity:"base"});break;case"origin":V=yo(O).localeCompare(yo(P));break}return F==="asc"?V:-V});return e.jsxs("div",{className:"max-w-5xl mx-auto",children:[b&&e.jsx(Jf,{onClose:()=>f(!1),onStartImport:()=>he.current?.click()}),e.jsx("input",{ref:he,type:"file",accept:".csv",onChange:Ce,className:"hidden"}),e.jsx(Xe,{title:"Contacts",subtitle:`${s.length} contact${s.length!==1?"s":""} in this workspace.`,action:e.jsxs(e.Fragment,{children:[e.jsx(U,{variant:"soft",size:"sm",onClick:()=>f(!0),children:"Import CSV"}),e.jsx(U,{variant:"soft",size:"sm",onClick:M,disabled:N||s.length===0,children:N?"Exportingâ¦":"Export CSV"}),e.jsx(U,{variant:"primary",size:"sm",onClick:()=>g(!0),children:"Add Contact"})]})}),x&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"red",children:x})}),k&&e.jsx("div",{className:"mb-4",children:e.jsxs(Ne,{tone:"blue",children:["Imported ",k.imported," contact",k.imported!==1?"s":""," (",k.skipped," skipped)."," ",e.jsx("button",{onClick:()=>w(null),className:"underline font-medium ml-1",children:"Dismiss"})]})}),e.jsxs("form",{onSubmit:oe,className:"mb-6",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:i,onChange:O=>o(O.target.value),placeholder:"Search by name, email, or company...","aria-label":"Search contacts by name, email or company",className:_u+" flex-1"}),e.jsx(U,{type:"submit",variant:"soft",children:"Search"})]}),H&&!d&&e.jsxs("p",{className:"text-xs text-gray-400 mt-2",children:["Showing ",s.length," result",s.length!==1?"s":""]})]}),!d&&s.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-6",children:[e.jsxs("select",{value:te,onChange:O=>pe(O.target.value),className:_u+" sm:max-w-[14rem] w-auto","aria-label":"Filter by origin",children:[e.jsx("option",{value:"all",children:"All origins"}),Z.map(O=>e.jsx("option",{value:O,children:tp(O)},O))]}),e.jsxs("select",{value:A,onChange:O=>L(O.target.value),className:_u+" sm:max-w-[12rem] w-auto","aria-label":"Sort by",children:[e.jsx("option",{value:"date",children:"Sort: Date"}),e.jsx("option",{value:"company",children:"Sort: Company"}),e.jsx("option",{value:"name",children:"Sort: Name"}),e.jsx("option",{value:"email",children:"Sort: Email"}),e.jsx("option",{value:"origin",children:"Sort: Origin"})]}),e.jsx(U,{variant:"soft",size:"sm",onClick:()=>D(O=>
20O==="asc"?"desc":"asc"),children:F==="asc"?"â Ascending":"â Descending"}),te!=="all"&&e.jsxs("span",{className:"text-xs text-gray-400",children:[$.length," of ",s.length]})]}),e.jsx(Et,{open:p,onClose:()=>g(!1),title:"Add Contact",children:e.jsx(m1,{onDone:()=>{g(!1),Y(i)},onCancel:()=>g(!1)})}),d?e.jsx(tt,{label:"Loading contactsâ¦"}):s.length===0?e.jsx(Ze,{title:H?"No contacts match your search.":"No contacts yet.",hint:H?"Try a different search term.":"Add contacts manually or import a CSV â or find your first leads below.",action:H?void 0:e.jsx("div",{className:"max-w-sm mx-auto mt-2",children:e.jsx(Ha,{icon:e.jsx($e,{name:"search",className:"w-8 h-8"}),title:"Start with Lead Generation",description:"Find qualified prospects and add them to your CRM automatically.",href:"/dashboard/prospecting/searches",tone:"blue"})})}):$.length===0?e.jsx(Ze,{title:"No contacts match these filters",hint:"Try a different origin or clear the filter.",icon:e.jsx($e,{name:"search",className:"w-8 h-8"}),action:e.jsx(U,{variant:"soft",size:"sm",onClick:()=>pe("all"),children:"Clear filter"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col gap-3 sm:hidden",children:$.map(O=>e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-xs text-gray-400",children:Ke(O.created_at)}),e.jsx("p",{className:"font-semibold text-gray-900 dark:text-gray-100 truncate",children:O.company||[O.first_name,O.last_name].filter(Boolean).join(" ")||O.email}),e.jsxs("p",{className:"text-sm text-gray-500 mt-0.5 truncate",children:[[O.first_name,O.last_name].filter(Boolean).join(" ")||"â"," · ",O.email]}),e.jsx("div",{className:"mt-1.5",children:e.jsx($g,{origin:O.origin,source:O.source})})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx(Og,{contact:O,lists:T,onAddToList:be,onAddToNewList:ne,onDelete:Ae})})]})},O.id))}),e.jsx("div",{className:"hidden sm:block bg-white dark:bg-gray-800/80 rounded-2xl shadow-sm ring-1 ring-gray-100 dark:ring-gray-700 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:Hr,children:e.jsxs("tr",{children:[e.jsx(Ol,{field:"date",label:"Date",sortField:A,sortDir:F,onSort:X}),e.jsx(Ol,{field:"company",label:"Company",sortField:A,sortDir:F,onSort:X}),e.jsx(Ol,{field:"name",label:"Name",sortField:A,sortDir:F,onSort:X}),e.jsx(Ol,{field:"email",label:"Email",sortField:A,sortDir:F,onSort:X}),e.jsx(Ol,{field:"origin",label:"Origin",sortField:A,sortDir:F,onSort:X}),e.jsx("th",{className:"text-right px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:$.map(O=>e.jsxs("tr",{className:Ql,children:[e.jsx("td",{className:"px-4 py-3 text-gray-400 dark:text-gray-500 whitespace-nowrap",children:Ke(O.created_at)}),e.jsx("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:O.company||"â"}),e.jsx("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:[O.first_name,O.last_name].filter(Boolean).join(" ")||"â"}),e.jsx("td",{className:"px-4 py-3 font-medium text-gray-900 dark:text-gray-100",children:O.email}),e.jsx("td",{className:"px-4 py-3",children:e.jsx($g,{origin:O.origin,source:O.source})}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx(Og,{contact:O,lists:T,onAddToList:be,onAddToNewList:ne,onDelete:Ae})})]},O.id))})]})})]}),_&&e.jsx("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-50 rounded-full bg-gray-900 text-white text-sm px-4 py-2 shadow-lg",children:_})]})}function m1({onDone:s,onCancel:l}){const[i,o]=h.useState({email:"",first_name:"",last_name:"",company:"",phone:""}),[d,u]=h.useState(""),[x,y]=h.useState(!1),p=async b=>{b.preventDefault(),y(!0),u("");try{await Ba.create(i),s()}catch(f){u(f.message)}finally{y(!1)}},g=de;return e.jsxs("form",{onSubmit:p,className:"space-y-4",children:[d&&e.jsx(Ne,{tone:"red",children:d}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(le,{label:"Email",required:!0,children:e.jsx("input",{type:"email",required:!0,value:i.email,onChange:b=>o({...i,email:b.target.value}),className:g,placeholder:"[email protected]"})}),e.jsx(le,{label:"First Name",children:e.jsx("input",{type:"text",value:i.first_name,onChange:b=>o({...i,first_name:b.target.value}),className:g,placeholder:"First name"})}),e.jsx(le,{label:"Last Name",children:e.jsx("input",{type:"text",value:i.last_name,onChange:b=>o({...i,last_name:b.target.value}),className:g,placeholder:"Last name"})}),e.jsx(le,{label:"Company",children:e.jsx("input",{type:"text",value:i.company,onChange:b=>o({...i,company:b.target.value}),className:g,placeholder:"Acme Inc."})}),e.jsx(le,{label:"Phone",children:e.jsx("input",{type:"tel",value:i.phone,onChange:b=>o({...i,phone:b.target.value}),className:g,placeholder:"+1 555 000 0000"})})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(U,{type:"submit",variant:"primary",disabled:x,children:x?"Savingâ¦":"Save Contact"}),e.jsx(U,{type:"button",variant:"soft",onClick:l,children:"Cancel"})]})]})}const h1=[{id:"welcome",name:"Welcome Email",description:"Warm welcome for new subscribers",icon:"conversations",subject:"Welcome to our community!",content:`Hi {{first_name}}, 21 22Welcome to our community! We're thrilled to have you on board. 23 24Here's what you can expect from us: 25⢠Regular updates about our products and services 26⢠Exclusive offers and early access to new features 27⢠Tips and insights to help you get the most value 28 29If you have any questions, just reply to this email. We're here to help! 30 31Best regards, 32The Team`,previewText:"Friendly welcome message that introduces your brand and sets expectations for future communications."},{id:"product-launch",name:"Product Launch",description:"Announce exciting new products",icon:"campaign",subject:"Introducing [Product Name] - You're going to love this!",content:`Hi {{first_name}}, 33 34Big news! We're excited to announce the launch of our newest product: [Product Name]. 35 36What makes it special: 37⢠[Key benefit #1] 38⢠[Key benefit #2] 39⢠[Key benefit #3] 40 41As a valued member of our community, you get early access! Use code LAUNCH20 for 20% off your first order. 42 43ð [Check it out now] 44 45Don't miss out - this offer expires in 48 hours! 46 47Cheers, 48The Team`,previewText:"Generate excitement and drive early adoption with exclusive offers for your audience."},{id:"customer-survey",name:"Customer Survey",description:"Gather valuable feedback",icon:"analytics",subject:"We'd love your feedback (2 minutes)",content:`Hi {{first_name}}, 49 50Your opinion matters to us! We're always looking to improve, and we'd love to hear what you think. 51 52Would you take 2 minutes to share your experience with us? 53 54ð [Take the survey] 55 56As a thank you, we'll enter you into a draw to win [incentive/prize]. 57
58Your feedback helps us serve you better. Thank you for being part of our community! 59 60Best, 61The Team`,previewText:"Collect actionable insights to improve your products and customer experience."}];function Fu(s){return s==="sent"?"green":s==="draft"?"gray":s==="scheduled"?"blue":s==="sending"?"amber":"gray"}function Dg(s){return s==="sms"?"conversations":s==="social_proof"?"sparkle":s==="darkcall"?"pipeline":"campaign"}function Hg(s){return s==="sms"?"SMS":s==="social_proof"?"Social Proof":s==="darkcall"?"DarkCall":s==="email"?"Email":s}const qg={blue:{grad:"from-sky-500 to-blue-600",text:"text-sky-600 dark:text-sky-400",glow:"bg-sky-400/25 dark:bg-sky-500/20"},amber:{grad:"from-amber-500 to-orange-600",text:"text-amber-600 dark:text-amber-400",glow:"bg-amber-400/25 dark:bg-amber-500/20"},green:{grad:"from-emerald-500 to-teal-600",text:"text-emerald-600 dark:text-emerald-400",glow:"bg-emerald-400/25 dark:bg-emerald-500/20"},violet:{grad:"from-violet-500 to-purple-600",text:"text-violet-600 dark:text-violet-400",glow:"bg-violet-400/25 dark:bg-violet-500/20"}},Bg=["blue","amber","green"];function Ug({icon:s,title:l,description:i,preview:o,badge:d,tone:u="blue",onClick:x}){const y=qg[u]||qg.blue;return e.jsxs("button",{onClick:x,className:"group relative flex h-full flex-col overflow-hidden text-left rounded-2xl p-5 bg-white dark:bg-gray-800/80 ring-1 ring-gray-200 dark:ring-gray-700/60 shadow-sm transition-all duration-150 hover:shadow-md hover:-translate-y-0.5 hover:ring-gray-300 dark:hover:ring-gray-600",children:[e.jsx("span",{className:`pointer-events-none absolute -top-10 -right-10 w-28 h-28 rounded-full blur-2xl opacity-0 group-hover:opacity-100 transition-opacity duration-300 ${y.glow}`}),d&&e.jsx("span",{className:"absolute top-3 right-3 z-10 inline-flex items-center rounded-full bg-gray-100 dark:bg-gray-700/70 text-gray-600 dark:text-gray-300 ring-1 ring-inset ring-gray-200 dark:ring-gray-600 px-2 py-0.5 text-[10px] font-semibold",children:d}),e.jsxs("div",{className:"relative flex flex-col flex-1",children:[e.jsx("div",{className:`w-12 h-12 rounded-xl bg-gradient-to-br ${y.grad} text-white shadow-sm flex items-center justify-center mb-3 transition-transform group-hover:scale-105`,children:e.jsx($e,{name:s,className:"w-6 h-6"})}),e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-gray-100",children:l}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5 line-clamp-1",children:i}),e.jsxs("div",{className:"mt-3 w-full flex-1 rounded-xl bg-gray-50 dark:bg-gray-900/50 ring-1 ring-gray-100 dark:ring-gray-700/50 p-3 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("p",{className:"font-medium text-gray-700 dark:text-gray-200 mb-1",children:"Preview"}),e.jsx("p",{className:"line-clamp-2",children:o})]}),e.jsxs("div",{className:`mt-3 inline-flex items-center gap-1 text-sm font-semibold ${y.text}`,children:["Use this template",e.jsx("svg",{className:"w-4 h-4 group-hover:translate-x-0.5 transition-transform",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3"})})]})]})]})}function Fg({icon:s,title:l,description:i,onClick:o}){return e.jsxs("button",{onClick:o,className:"group flex h-full flex-col items-center justify-center text-center rounded-2xl p-5 bg-gray-50/60 dark:bg-gray-900/30 ring-1 ring-dashed ring-gray-300 dark:ring-gray-600 hover:ring-gray-400 dark:hover:ring-gray-500 hover:bg-white dark:hover:bg-gray-800/60 transition",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl bg-gradient-to-br from-gray-100 to-gray-50 dark:from-gray-700/60 dark:to-gray-800/30 text-gray-500 dark:text-gray-400 group-hover:text-primary-600 dark:group-hover:text-primary-400 flex items-center justify-center mb-3 transition",children:e.jsx($e,{name:s,className:"w-7 h-7"})}),e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-1 group-hover:text-primary-600 dark:group-hover:text-primary-400 transition",children:l}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:i})]})}const x1=10080*60*1e3;function g1(){const{account:s,updateUiState:l}
61=zt(),[i,o]=$r(),d=_v(),[u,x]=h.useState([]),[y,p]=h.useState([]),[g,b]=h.useState(!0),[f,k]=h.useState(""),[w,N]=h.useState(!1),[j,T]=h.useState(null),[S,_]=h.useState(null),[z,A]=h.useState(!1),[L,F]=h.useState(!1),[D,te]=h.useState(null),[pe,he]=h.useState([]),[X,I]=h.useState(!1),[q,be]=h.useState("all"),ne=h.useRef(!1),M=s?`fantize_campaign_welcome_dismissed_${s.id}`:"",Y=()=>!!M&&localStorage.getItem(M)==="1",oe=s?.created_at?Pf(s.created_at)<x1:!1,Ce=!!s?.ui_state?.campaign_welcome_seen,Ae=()=>{M&&localStorage.setItem(M,"1"),Ce||l({campaign_welcome_seen:!0}).catch(()=>{})},H=()=>{Ae(),A(!1),F(!1)},Z=()=>(b(!0),Promise.all([xa.list(),Za.list(),vf.list().catch(()=>({templates:[]}))]).then(([ge,qe,nt])=>{x(ge.campaigns),p(qe.lists),he(nt.templates)}).catch(ge=>k(ge.message)).finally(()=>b(!1)));h.useEffect(()=>{Ie.track("page_view",{page:"campaigns",path:"/dashboard/campaigns"}),console.log("ð§ [CampaignsPage] Page viewed"),Z()},[]),h.useEffect(()=>{if(g||!s||ne.current||(ne.current=!0,w||j))return;if(i.get("showTemplates")==="true"){A(!0),F(!1),i.delete("showTemplates"),o(i,{replace:!0});return}d==="PUSH"&&oe&&u.length===0&&!Ce&&!Y()&&(A(!0),F(!0),Ae())},[g,s,u]);const $=async ge=>{console.log("ð [CampaignsPage] Sending campaign:",ge),Ie.track("campaign_send_started",{campaignId:ge,source:"campaigns_page"});const qe=Date.now();try{const nt=await xa.send(ge),R=Date.now()-qe;console.log("â
[CampaignsPage] Campaign sent:",nt,R+"ms"),Ie.track("campaign_sent",{campaignId:ge,queuedCount:nt.queued,duration:R,source:"campaigns_page"}),_(ge),Z()}catch(nt){const R=Date.now()-qe,we=nt.message;console.error("â [CampaignsPage] Campaign send failed:",we,R+"ms"),Ie.trackError("campaign_send",nt,{campaignId:ge,duration:R,source:"campaigns_page"}),k(we)}},O=ge=>{Ae(),te(ge),T(null),A(!1),F(!1),N(!0)},P={draft:u.filter(ge=>ge.status==="draft").length,scheduled:u.filter(ge=>ge.status==="scheduled").length,sent:u.filter(ge=>ge.status==="sent").length},V=[{key:"all",label:"All",count:u.length},{key:"draft",label:"Drafts",count:P.draft},{key:"scheduled",label:"Scheduled",count:P.scheduled},{key:"sent",label:"Sent",count:P.sent}],ye=q==="all"?u:u.filter(ge=>ge.status===q);return S?e.jsx(f1,{campaignId:S,onBack:()=>{_(null),Z()},onSend:$}):e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(Xe,{title:"Campaigns",subtitle:"Email, SMS and social campaigns created and sent from Fantize. Outbound (Instantly) campaigns and who they hand off to are under Campaign Routing.",action:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{variant:"soft",size:"sm",onClick:()=>{A(!0),F(!1),N(!1),T(null)},children:"Browse message templates"}),e.jsx(U,{variant:"primary",size:"sm",onClick:()=>{N(!0),T(null),te(null),A(!1)},children:"New Campaign"})]})}),f&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"red",children:f})}),z&&!w&&!j&&e.jsx("div",{className:"mb-8",children:e.jsxs("div",{className:"relative bg-white dark:bg-gray-800/80 rounded-2xl shadow-sm ring-1 ring-gray-200 dark:ring-gray-700/60 overflow-hidden",children:[e.jsx("div",{className:"h-1 bg-gradient-to-r from-primary-500 via-violet-500 to-primary-500"}),e.jsxs("div",{className:"p-6 sm:p-7",children:[e.jsx("button",{onClick:H,className:"absolute top-3 right-3 w-11 h-11 rounded-lg flex items-center justify-center text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700/60 transition focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500","aria-label":"Close templates",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),e.jsxs("div",{className:"flex items-start gap-4 mb-6 pr-10",children:[e.jsx("div",{className:"hidden sm:flex flex-shrink-0 w-12 h-12 rounded-xl bg-gradient-to-br from-primary-100 to-violet-100 dark:from-primary-900/60 dark:to-violet-900/30 text-primary-600 dark:text-primary-300 items-center justify-center",children:e.jsx($e,{name:"sparkle",className:"w-6 h-6"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-primary-500 dark:text-primary-400",children:L?"Get started":"Templates"}),e.jsx("h2",{className:"font-display text-xl sm:text-2xl font-semibold text-gray-900 dark:text-gray-100 mt-1",children:L?e.jsxs(e.Fragment,{children:["Let's create your ",e.jsx(Zf,{children:"first campaign"})]}):"Quick-start templates"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:L?"Pick a ready-made template to launch in seconds, or start from a blank canvas. You can customize everything before anything is sent.":"Choose a template to create your campaign in seconds."})]})]}),L&&e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-6",children:[{n:1,label:"Pick a template",desc:"Start from proven copy"},{n:2,label:"Make it yours",desc:"Edit text and audience"},{n:3,label:"Send",desc:"Reach your contacts"}].map(ge=>e.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl bg-gray-50 dark:bg-gray-900/40 ring-1 ring-gray-100 dark:ring-gray-700/50 px-3 py-2.5",children:[e.jsx("span",{className:"flex-shrink-0 w-6 h-6 rounded-full bg-primary-500 text-white text-xs font-semibold flex items-center justify-center",children:ge.n}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-gray-900 dark:text-gray-100 leading-tight truncate",children:ge.label}),e.jsx("p",{className:"text-[11px] text-gray-500 dark:text-gray-400 leading-tight truncate hidden sm:block",children:ge.desc})]})]},ge.n))}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[h1.map((ge,qe)=>e.jsx(Ug,{icon:ge.icon,title:ge.name,description:ge.description,preview:ge.previewText,tone:Bg[qe%Bg.length],onClick:()=>O({name:ge.name,subject:ge.subject,content:ge.content,description:ge.description})},ge.id)),pe.map(ge=>e.jsx(Ug,{icon:"templates",title:ge.name,description:ge.subject,badge:"Saved",tone:"violet",preview:ge.content.length>120?ge.content.substring(0,120)+"â¦":ge.content,onClick:()=>O({name:ge.name,subject:ge.subject,content:ge.content})},ge.id)),e.jsx(Fg,{icon:"campaign",title:"Start from scratch",description:"Build a campaign from a blank canvas",onClick:()=>{Ae(),A(!1),F(!1),N(!0),T(null),te(null)}}),e.jsx(Fg,{icon:"templates",title:"Create template",description:"Save reusable copy for later",onClick:()=>I(!0)})]})]})]})}),e.jsx(y1,{open:X,onClose:()=>I(!1),onCreated:()=>{I(!1),Z()}}),w||j?e.jsx(p1,{campaign:j,lists:y,prefill:D,onDone:()=>{N(!1),T(null),te(null),Z()},onCancel:()=>{N(!1),T(null),te(null)}}
61):g?e.jsx(tt,{label:"Loading campaignsâ¦"}):u.length===0?!z&&e.jsx(Ze,{title:"No campaigns yet",hint:"Start from a ready-made template, build from scratch, or find leads to target first.",icon:e.jsx($e,{name:"campaign",className:"w-8 h-8"}),action:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 max-w-xl mx-auto mt-2",children:[e.jsx(Ha,{icon:e.jsx($e,{name:"templates",className:"w-7 h-7"}),title:"Browse Templates",description:"Start in seconds from a proven template.",onClick:()=>{A(!0),F(!1)},tone:"purple"}),e.jsx(Ha,{icon:e.jsx($e,{name:"search",className:"w-7 h-7"}),title:"Find Leads First",description:"Build a targeted list before you send.",href:"/dashboard/prospecting/searches",tone:"green"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-6",children:[e.jsx(Ct,{label:"Total Campaigns",value:u.length,tone:"featured"}),e.jsx(Ct,{label:"Drafts",value:P.draft,tone:"amber"}),e.jsx(Ct,{label:"Scheduled",value:P.scheduled,tone:"blue"}),e.jsx(Ct,{label:"Sent",value:P.sent,tone:"green"})]}),e.jsx("div",{className:"mb-5",children:e.jsx(Xl,{tabs:V,active:q,onChange:be})}),ye.length===0?e.jsx(Ze,{title:`No ${q==="all"?"":q+" "}campaigns`,hint:"Try a different filter or create a new campaign.",icon:e.jsx($e,{name:"campaign",className:"w-8 h-8"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col gap-3 lg:hidden",children:ye.map(ge=>e.jsx(_e,{onClick:()=>_(ge.id),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-xl bg-gradient-to-br from-primary-100 to-primary-50 dark:from-primary-900/60 dark:to-primary-800/30 text-primary-600 dark:text-primary-400 flex items-center justify-center",children:e.jsx($e,{name:Dg(ge.type),className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-semibold text-gray-900 dark:text-gray-100 truncate",children:ge.name}),e.jsxs("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-0.5",children:[Hg(ge.type)," · ",Ke(ge.created_at)]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1.5 flex-shrink-0",children:[e.jsx(se,{tone:Fu(ge.status),children:ge.status}),e.jsxs("div",{className:"flex gap-2",onClick:qe=>qe.stopPropagation(),children:[e.jsx("button",{onClick:()=>T(ge),className:"text-xs text-primary-600 hover:text-primary-800",children:"Edit"}),ge.status==="draft"&&e.jsx("button",{onClick:()=>$(ge.id),className:"text-xs text-emerald-600 hover:text-emerald-800 font-medium",children:"Send"})]})]})]})},ge.id))}),e.jsx("div",{className:"hidden lg:block bg-white dark:bg-gray-800/80 dark:ring-gray-700/60 rounded-2xl shadow-sm ring-1 ring-gray-100 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:Hr,children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Campaign"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"List"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Created"}),e.jsx("th",{className:"px-4 py-3"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:ye.map(ge=>e.jsxs("tr",{className:Ql+" cursor-pointer",onClick:()=>_(ge.id),children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-9 h-9 rounded-lg bg-gradient-to-br from-primary-100 to-primary-50 dark:from-primary-900/60 dark:to-primary-800/30 text-primary-600 dark:text-primary-400 flex items-center justify-center",children:e.jsx($e,{name:Dg(ge.type),className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:ge.name})]})}),e.jsx("td",{className:"px-4 py-3 text-gray-500 dark:text-gray-400",children:Hg(ge.type)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(se,{tone:Fu(ge.status),children:ge.status})}),e.jsx("td",{className:"px-4 py-3 text-gray-500 dark:text-gray-400",children:ge.list_name||"â"}),e.jsx("td",{className:"px-4 py-3 text-gray-400 dark:text-gray-500",children:Ke(ge.created_at)}),e.jsxs("td",{className:"px-4 py-3 text-right space-x-3",onClick:qe=>
61qe.stopPropagation(),children:[e.jsx("button",{onClick:()=>T(ge),className:"text-primary-500 hover:text-primary-700 text-xs",children:"Edit"}),ge.status==="draft"&&e.jsx("button",{onClick:()=>$(ge.id),className:"text-emerald-600 hover:text-emerald-800 text-xs font-medium",children:"Send"})]})]},ge.id))})]})})]})]})]})}function f1({campaignId:s,onBack:l,onSend:i}){const[o,d]=h.useState(null),[u,x]=h.useState(null),[y,p]=h.useState([]),[g,b]=h.useState(!0),[f,k]=h.useState(""),w=()=>{Promise.all([xa.get(s),xa.stats(s),xa.sends(s,{limit:100})]).then(([T,S,_])=>{d(T),x(S),p(_.sends)}).catch(T=>k(T.message)).finally(()=>b(!1))};if(h.useEffect(()=>{w();const T=setInterval(()=>{o?.status==="sending"&&w()},5e3);return()=>clearInterval(T)},[s,o?.status]),g)return e.jsx(tt,{label:"Loading campaignâ¦"});if(!o)return e.jsx(Ne,{tone:"red",children:"Campaign not found."});const N=u&&u.total>0?Math.round(u.sent/u.total*100):0,j=u&&u.total>0?Math.round(u.failed/u.total*100):0;return e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsxs("button",{onClick:l,className:"text-sm text-primary-500 hover:text-primary-700 mb-4 inline-flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})}),"Back to Campaigns"]}),e.jsxs("div",{className:"flex items-start justify-between mb-6 gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl font-semibold text-gray-900 dark:text-gray-100",children:o.name}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2",children:[e.jsx("span",{children:o.type}),e.jsx(se,{tone:Fu(o.status),children:o.status}),o.sent_at&&e.jsxs("span",{children:["· Sent ",Ia(o.sent_at)]})]})]}),o.status==="draft"&&e.jsx(U,{variant:"success",onClick:()=>i(o.id),children:"Send Campaign"})]}),f&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"red",children:f})}),u&&u.total>0&&e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4 mb-6",children:[{label:"Total",value:u.total,tone:"gray"},{label:"Sent",value:u.sent,tone:"green"},{label:"Failed",value:u.failed,tone:"red"},{label:"Queued",value:u.queued+u.sending,tone:"blue"},{label:"Progress",value:`${N}%`,tone:"gray"}].map(T=>e.jsxs("div",{className:"bg-white dark:bg-gray-800/80 dark:ring-gray-700/60 rounded-2xl shadow-sm ring-1 ring-gray-100 p-4",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 uppercase mb-1",children:T.label}),e.jsx("p",{className:`text-2xl font-bold ${T.tone==="green"?"text-emerald-600":T.tone==="red"?"text-rose-600":T.tone==="blue"?"text-sky-600":"text-gray-900 dark:text-gray-100"}`,children:T.value})]},T.label))}),u&&u.total>0&&e.jsxs("div",{className:"bg-white dark:bg-gray-800/80 dark:ring-gray-700/60 rounded-2xl shadow-sm ring-1 ring-gray-100 p-4 mb-6",children:[e.jsxs("div",{className:"flex justify-between text-xs text-gray-500 dark:text-gray-400 mb-2",children:[e.jsx("span",{children:"Delivery Progress"}),e.jsxs("span",{children:[u.sent+u.failed," / ",u.total]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-gray-700 rounded-full h-3 overflow-hidden",children:e.jsxs("div",{className:"h-3 flex",children:[e.jsx("div",{className:"bg-emerald-500 transition-all",style:{width:`${N}%`}}),e.jsx("div",{className:"bg-rose-400 transition-all",style:{width:`${j}%`}})]})}),o.status==="sending"&&e.jsx("p",{className:"text-xs text-sky-600 mt-2 animate-pulse",children:"Sending in progressâ¦"})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800/80 dark:ring-gray-700/60 rounded-2xl shadow-sm ring-1 ring-gray-100 p-4 mb-6",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"Content Preview"}),o.subject&&e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-200 mb-1",children:[e.jsx("strong",{children:"Subject:"})," ",o.subject]}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300 border-t dark:border-gray-700 pt-2 mt-2 max-h-40 overflow-y-auto",dangerouslySetInnerHTML:{__html:o.content||"<em>No content</em>"}})]}),y.length>0&&e.jsxs("div",{className:"bg-white dark:bg-gray-800/80 dark:ring-gray-700/60 rounded-2xl shadow-sm ring-1 ring-gray-100 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-100 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50",children:e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Delivery Log"})}),e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:Hr,children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium text-gray-500 dark:text-gray-400",children:"Recipient"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-gray-500 dark:text-gray-400",children:"Channel"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-gray-500 dark:text-gray-400",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-gray-500 dark:text-gray-400",children:"Sent At"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-gray-500 dark:text-gray-400",children:"Error"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:y.map(T=>e.jsxs("tr",{children:[e.jsxs("td",{className:"px-4 py-2 text-gray-900 dark:text-gray-100",children:[T.first_name," ",T.last_name,e.jsx("span",{className:"text-gray-400 dark:text-gray-500 ml-1 text-xs",children:T.email||T.phone})]}),e.jsx("td",{className:"px-4 py-2 text-gray-500 dark:text-gray-400",children:T.channel}),e.jsx("td",{className:"px-4 py-2",children:e.jsx(se,{tone:T.status==="sent"?"green":T.status==="failed"?"red":T.status==="sending"?"blue":"gray",children:T.status})}),e.jsx("td",{className:"px-4 py-2 text-gray-400 dark:text-gray-500",children:T.sent_at?Ia(T.sent_at):"â"}),e.jsx("td",{className:"px-4 py-2 text-rose-500 text-xs",children:T.error||""})]},T.id))})]})]})]})}function p1({campaign:s,lists:l,prefill:i,onDone:o,onCancel:d}){const u=()=>s?{name:s.name,type:s.type,subject:s.subject||"",content:s.content||"",target_list_id:s.target_list_id||""}:i?{name:i.name,type:"email",subject:i.subject,content:i.content,target_list_id:""}:{name:"",type:"email",subject:"",content:"",target_list_id:""},[x,y]=h.useState(u()),[p,g]=h.useState(""),[b,f]=h.useState(!1),[k,w]=h.useState(!1),[N,j]=h.useState({goal:"",target_audience:""}),[T,S]=h.useState(!1),_=de,z=async L=>{L.preventDefault(),f(!0),g("");try{s?await xa.update(s.id,{name:x.name,type:x.type,subject:x.subject,content:x.content,target_list_id:x.target_list_id||void 0}):await xa.create({name:x.name,type:x.type,subject:x.subject,content:x.content,target_list_id:x.target_list_id||void 0}),o()}catch(F){g(F.message)}finally{f(!1)}},A=async()=>
61{if(!N.goal||!N.target_audience){g("Please provide both campaign goal and target audience.");return}S(!0),g("");try{const L=await xa.generateCopy({goal:N.goal,target_audience:N.target_audience,campaign_type:x.type});y({...x,subject:L.subject,content:L.body}),w(!1),j({goal:"",target_audience:""})}catch(L){g(L.message)}finally{S(!1)}};return e.jsxs("div",{className:"bg-white dark:bg-gray-800/80 dark:ring-gray-700/60 rounded-2xl shadow-sm ring-1 ring-gray-100 p-6 mb-6",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("h3",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:s?"Edit Campaign":i?i.name:"New Campaign"}),i?.description&&e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:[i.description," â Customize below and send when ready."]})]}),p&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"red",children:p})}),e.jsxs("form",{onSubmit:z,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{htmlFor:"campaign-campaign-name",className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:["Campaign Name ",e.jsx("span",{className:"text-rose-500",children:"*"})]}),e.jsx("input",{id:"campaign-campaign-name",type:"text",required:!0,value:x.name,onChange:L=>y({...x,name:L.target.value}),className:_,placeholder:"My Campaign"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{htmlFor:"campaign-type",className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:"Type"}),e.jsxs("select",{id:"campaign-type",value:x.type,onChange:L=>y({...x,type:L.target.value}),className:_,children:[e.jsx("option",{value:"email",children:"Email"}),e.jsx("option",{value:"sms",children:"SMS"}),e.jsx("option",{value:"social_proof",children:"Social Proof"}),e.jsx("option",{value:"darkcall",children:"DarkCall (Multi-Channel)"})]})]})]}),l.length>0&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{htmlFor:"campaign-target-list",className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:"Target List"}),e.jsxs("select",{id:"campaign-target-list",value:x.target_list_id,onChange:L=>y({...x,target_list_id:L.target.value}),className:_,children:[e.jsx("option",{value:"",children:"All contacts"}),l.map(L=>e.jsx("option",{value:L.id,children:L.name},L.id))]})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{htmlFor:"campaign-subject",className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:"Subject"}),e.jsxs("button",{type:"button",onClick:()=>w(!k),className:"text-xs text-primary-500 hover:text-primary-700 font-medium flex items-center gap-1",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09z"})}),k?"Hide AI Assistant":"Generate with AI"]})]}),e.jsx("input",{id:"campaign-subject",type:"text",value:x.subject,onChange:L=>y({...x,subject:L.target.value}),className:_,placeholder:"Your email subject lineâ¦"})]}),k&&e.jsxs("div",{className:"bg-gradient-to-r from-primary-50 to-violet-50 dark:from-primary-950/40 dark:to-violet-950/20 ring-2 ring-primary-200 dark:ring-primary-800/50 rounded-2xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx($e,{name:"sparkle",className:"w-5 h-5 text-primary-600 dark:text-primary-400"}),e.jsx("h4",{className:"font-semibold text-sm text-primary-700 dark:text-primary-300",children:"AI Copy Generator"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{htmlFor:"campaign-campaign-goal",className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:["Campaign Goal ",e.jsx("span",{className:"text-rose-500",children:"*"})]}),e.jsx("input",{id:"campaign-campaign-goal",type:"text",value:N.goal,onCh
61ange:L=>j({...N,goal:L.target.value}),placeholder:"e.g., Promote new product launch, announce sale",className:_})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{htmlFor:"campaign-target-audience",className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:["Target Audience ",e.jsx("span",{className:"text-rose-500",children:"*"})]}),e.jsx("input",{id:"campaign-target-audience",type:"text",value:N.target_audience,onChange:L=>j({...N,target_audience:L.target.value}),placeholder:"e.g., Young professionals, existing customers, music fans",className:_})]}),e.jsx(U,{type:"button",variant:"primary",disabled:T,onClick:A,className:"w-full",children:T?"Generatingâ¦":"Generate Copy"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{htmlFor:"campaign-content",className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:"Content"}),i&&e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:["Tip: use ","{{first_name}}"," to personalise"]})]}),e.jsx("textarea",{id:"campaign-content",value:x.content,onChange:L=>y({...x,content:L.target.value}),rows:8,className:_+" font-mono"})]}),i&&e.jsxs("div",{className:"bg-emerald-50 dark:bg-emerald-950/30 ring-1 ring-emerald-200 dark:ring-emerald-800/50 rounded-2xl p-4 flex items-start gap-3",children:[e.jsx("svg",{className:"w-5 h-5 text-emerald-600 flex-shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-semibold text-emerald-700 dark:text-emerald-300 mb-0.5",children:"Ready to send!"}),e.jsx("p",{className:"text-emerald-700 dark:text-emerald-300 text-xs",children:"Your campaign is pre-filled with proven copy. Customise it or click Create to save as draft and review before sending."})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(U,{type:"submit",variant:"primary",disabled:b,children:b?"Savingâ¦":s?"Update Campaign":"Create Campaign"}),e.jsx(U,{type:"button",variant:"soft",onClick:d,children:"Cancel"})]})]})]})}function y1({open:s,onClose:l,onCreated:i}){const[o,d]=h.useState({name:"",subject:"",content:""}),[u,x]=h.useState(""),[y,p]=h.useState(!1),g=()=>{d({name:"",subject:"",content:""}),x("")},b=()=>{g(),l()},f=o.name.trim()!==""&&o.subject.trim()!==""&&o.content.trim()!=="",k=async()=>{if(f){p(!0),x("");try{await vf.create({name:o.name,subject:o.subject,content:o.content}),g(),i()}catch(w){x(w.message)}finally{p(!1)}}};return e.jsxs(Et,{open:s,onClose:b,title:"Create Template",footer:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(U,{type:"button",variant:"soft",onClick:b,children:"Cancel"}),e.jsx(U,{type:"button",variant:"primary",disabled:!f||y,onClick:k,children:y?"Savingâ¦":"Create"})]}),children:[u&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"red",children:u})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(le,{label:"Template Name",required:!0,children:e.jsx("input",{type:"text",value:o.name,onChange:w=>d({...o,name:w.target.value}),className:de,placeholder:"My Template"})}),e.jsx(le,{label:"Subject",required:!0,children:e.jsx("input",{type:"text",value:o.subject,onChange:w=>d({...o,subject:w.target.value}),className:de,placeholder:"Email subject lineâ¦"})}),e.jsx(le,{label:"Content",required:!0,children:e.jsx("textarea",{value:o.content,onChange:w=>d({...o,content:w.target.value}),rows:8,className:de+" font-mono",placeholder:"HTML or plain textâ¦"})})]})]})}const b1=["prospect","user","advocate","superfan"],v1={prospect:"bg-gray-200 dark:bg-gray-600 text-gray-700 dark:text-gray-200",user:"bg-sky-400 text-white",advocate:"bg-emerald-500 text-white",superfan:"bg-primary-500 text-white"},j1={prospect:"gray",user:"blue",advocate:"green",superfan:"green"},w1={prospect:"gray",user:"blue",advocate:"green",superfan:"green"};
61function k1(){const[s,l]=h.useState([]),[i,o]=h.useState(!0),[d,u]=h.useState("");if(h.useEffect(()=>{Hb.list().then(y=>l(y.fan_profiles)).catch(y=>u(y.message)).finally(()=>o(!1))},[]),i)return e.jsx(tt,{label:"Loading pipelineâ¦"});const x=b1.map(y=>({level:y,count:s.filter(p=>p.fan_level===y).length,profiles:s.filter(p=>p.fan_level===y)}));return e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(Xe,{title:"Fan Pipeline",subtitle:"Track fan engagement levels from prospect to superfan."}),d&&e.jsx(Ne,{tone:"red",children:d}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:x.map(y=>e.jsx(Ct,{label:y.level.charAt(0).toUpperCase()+y.level.slice(1),value:y.count,tone:j1[y.level]},y.level))}),e.jsxs(_e,{className:"mb-6",children:[e.jsx(Fe,{children:"Conversion Funnel"}),e.jsx("div",{className:"space-y-3 mt-2",children:x.map(y=>{const p=Math.max(...x.map(b=>b.count),1),g=Math.max(y.count/p*100,10);return e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-24 text-right text-sm font-medium text-gray-600 dark:text-gray-300 capitalize",children:y.level}),e.jsx("div",{className:"flex-1",children:e.jsx("div",{className:`h-10 rounded-md flex items-center px-3 text-sm font-bold transition-all ${v1[y.level]}`,style:{width:`${g}%`},children:y.count})})]},y.level)})})]}),x.map(y=>y.profiles.length>0?e.jsxs(_e,{className:"mb-4",children:[e.jsx(Fe,{children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(se,{tone:w1[y.level],children:y.level.charAt(0).toUpperCase()+y.level.slice(1)}),e.jsxs("span",{className:"text-gray-400 text-sm font-normal",children:["(",y.count,")"]})]})}),e.jsx("div",{className:"space-y-0 divide-y divide-gray-100 dark:divide-gray-700",children:y.profiles.map(p=>e.jsxs("div",{className:"flex items-center justify-between py-2.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:[p.first_name,p.last_name].filter(Boolean).join(" ")||p.email}),(p.first_name||p.last_name)&&e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 ml-2",children:p.email})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[p.product_or_service&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:p.product_or_service}),p.referral_count>0&&e.jsxs(se,{tone:"green",children:[p.referral_count," referral",p.referral_count!==1?"s":""]}),p.review_rating&&e.jsxs("span",{className:"text-xs text-amber-500",children:["â
".repeat(p.review_rating),"â".repeat(5-p.review_rating)]})]})]},p.id))})]},y.level):null),s.length===0&&e.jsx(Ze,{title:"No fan profiles yet",hint:"Fan profiles are created automatically when contacts interact with your campaigns.",icon:e.jsx($e,{name:"contacts",className:"w-8 h-8"})})]})}function N1(){const[s,l]=h.useState([]),[i,o]=h.useState(0),[d,u]=h.useState(0),[x,y]=h.useState(!0),[p,g]=h.useState("");h.useEffect(()=>{yf.list({limit:100}).then(f=>{l(f.orders),o(f.revenue),u(f.total)}).catch(f=>g(f.message)).finally(()=>y(!1))},[]);const b=d>0?i/d:0;return e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(Xe,{title:"Orders",subtitle:"Revenue and order history from your campaigns."}),p&&e.jsx(Ne,{tone:"red",children:p}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-6",children:[e.jsx(Ct,{label:"Total Orders",value:d,tone:"gray"}),e.jsx(Ct,{label:"Revenue",value:`$${i.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`,tone:"green"}),e.jsx(Ct,{label:"Avg Order Value",value:`$${b.toFixed(2)}`,tone:"blue"})]}),x?e.jsx(tt,{label:"Loading ordersâ¦"}):s.length===0?e.jsx(Ze,{title:"No orders yet",hint:"Orders are recorded when contacts make purchases through your campaigns.",icon:e.jsx($e,{name:"orders",className:"w-8 h-8"})}):e.jsx(_e,{className:"overflow-hidden p-0",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:Hr,children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Contact"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Product"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Amount"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Campaign"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Date"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:s.map(f=>e.jsxs("tr",{className:Ql+" text-sm",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[f.first_name,f.last_name].filter(
61Boolean).join(" ")||f.email}),(f.first_name||f.last_name)&&e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:f.email})]}),e.jsx("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:f.product_or_service||"â"}),e.jsxs("td",{className:"px-4 py-3 font-medium text-gray-900 dark:text-gray-100",children:["$",(f.amount||0).toFixed(2)]}),e.jsx("td",{className:"px-4 py-3 text-gray-500 dark:text-gray-400",children:f.campaign_name||"â"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(Bn,{status:f.status})}),e.jsx("td",{className:"px-4 py-3 text-gray-400 dark:text-gray-500 text-xs",children:Ke(f.created_at)})]},f.id))})]})})]})}const _1={post_purchase:"Post-Purchase",fan_cultivation:"Fan Cultivation",social_proof_outreach:"Social Proof",feedback_request:"Feedback Request"},S1={post_purchase:"blue",fan_cultivation:"green",social_proof_outreach:"blue",feedback_request:"amber"},C1={active:"bg-emerald-500",paused:"bg-amber-400"},A1=[{key:"active",label:"Active"},{key:"paused",label:"Paused"},{key:"completed",label:"Completed"}];function E1(){const[s,l]=h.useState([]),[i,o]=h.useState("active"),[d,u]=h.useState(!0),[x,y]=h.useState(""),p=g=>{u(!0),bf.list(g).then(b=>l(b.conversations)).catch(b=>y(b.message)).finally(()=>u(!1))};return h.useEffect(()=>{p(i)},[i]),e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(Xe,{title:"Conversations",subtitle:"Fan engagement conversations from your campaigns."}),x&&e.jsx(Ne,{tone:"red",children:x}),e.jsx("div",{className:"mb-5",children:e.jsx(Xl,{tabs:A1,active:i,onChange:g=>o(g)})}),d?e.jsx(tt,{label:"Loading conversationsâ¦"}):s.length===0?e.jsx(Ze,{title:`No ${i} conversations`,hint:"Conversations start automatically after campaign interactions and purchases.",icon:e.jsx($e,{name:"conversations",className:"w-8 h-8"})}):e.jsx("div",{className:"space-y-3",children:s.map(g=>e.jsxs(_e,{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:`flex-shrink-0 w-3 h-3 rounded-full ${C1[g.status]??"bg-gray-300"}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-gray-900 dark:text-gray-100 truncate",children:[g.first_name,g.last_name].filter(Boolean).join(" ")||g.email}),e.jsx("p",{className:"text-xs text-gray-400 truncate",children:g.email})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0 text-sm",children:[g.purpose&&e.jsx(se,{tone:S1[g.purpose]??"gray",children:_1[g.purpose]??g.purpose}),g.channel&&e.jsx("span",{className:"text-gray-500 capitalize text-xs",children:g.channel}),e.jsxs(se,{tone:"gray",children:[g.message_count," msg",g.message_count!==1?"s":""]}),e.jsx("span",{className:"text-gray-400 text-xs",children:g.last_message_at?Ke(g.last_message_at):"No messages"})]})]},g.id))})]})}const Ln=de;function T1(s){return s?s<1024?`${s} B`:s<1024*1024?`${Math.round(s/1024)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`:""}function R1({onUploaded:s,onError:l}){const i=h.useRef(null),[o,d]=h.useState(!1),[u,x]=h.useState(!1);async function y(p){if(!(!p||p.length===0)){x(!0);for(const g of Array.from(p)){if(!g.type.startsWith("image/")){l(`"${g.name}" is not an image.`);continue}if(g.size>5*1024*1024){l(`"${g.name}" exceeds the 5MB limit.`);continue}try{const{item:b}=await Hu.upload(g);s(b)}catch(b){l(b.message||`Failed to upload "${g.name}".`)}}x(!1),i.current&&(i.current.value="")}}return e.jsxs("div",{onDragOver:p=>{p.preventDefault(),d(!0)},onDragLeave:()=>d(!1),onDrop:p=>{p.preventDefault(),d(!1),y(p.dataTransfer.files)},onClick:()=>i.current?.click(),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),i.current?.click())},role:"button",tabIndex:0,"aria-label":"Upload brand media",className:["relative flex flex-col items-center justify-center text-center gap-2 rounded-2xl border-2 border-dashed p-8 cursor-pointer transition-colors",o?"border-primary-400 bg-primary-50/70 dark:border-primary-500 dark:bg-primary-950/30":"border-gray-300 dark:border-gray-600 hover:border-primary-300 dark:hover:border-primary-700 hover:bg-gray-50 dark:hover:bg-gray-700/30"].join(" "),children:[u?e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-600 dark:text-gray-300",children:[e.jsxs("svg",{className:"animate-spin w-4 h-4 text-primary-500",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),"Uploadingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-11 h-11 rounded-xl bg-primary-50 dark:bg-primary-950/40 text-primary-600 dark:text-primary-400 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})})}),e.jsx("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:"Drag & drop images here, or click to browse"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"PNG, SVG, JPG, WebP, GIF, or AVIF, up to 5MB each. You can add several at once."})]}),e.jsx("input",{ref:i,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:p=>y(p.target.files)})]})}function z1({m:s,isLogo:l,onSetLogo:i,onCopy:o,onDelete:d}
61){const[u,x]=h.useState(!1);return e.jsxs("div",{className:"group relative flex flex-col rounded-xl ring-1 ring-gray-200 dark:ring-gray-700 bg-white dark:bg-gray-800/60 overflow-hidden",children:[e.jsx("div",{className:"aspect-[4/3] flex items-center justify-center p-3 bg-gray-50 dark:bg-gray-900/40",children:u?e.jsxs("div",{className:"flex flex-col items-center gap-1 text-gray-300 dark:text-gray-600",children:[e.jsx("svg",{className:"w-7 h-7",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909M3 3l18 18M21 16.5V6a1.5 1.5 0 00-1.5-1.5H6"})}),e.jsx("span",{className:"text-[10px]",children:"Preview unavailable"})]}):e.jsx("img",{src:s.url,alt:s.original_name||"Brand media",className:"max-w-full max-h-full object-contain",loading:"lazy",onError:()=>x(!0)})}),l&&e.jsx("span",{className:"absolute top-2 left-2 rounded-full bg-primary-600 text-white text-[10px] font-semibold px-2 py-0.5 shadow-sm",children:"Logo"}),e.jsxs("div",{className:"p-2.5 border-t border-gray-100 dark:border-gray-700/60",children:[e.jsx("div",{className:"text-xs font-medium text-gray-700 dark:text-gray-200 truncate",title:s.original_name||s.filename,children:s.original_name||s.filename}),s.size?e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 mt-0.5",children:T1(s.size)}):null,e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:i,className:["flex-1 rounded-lg text-xs font-medium px-2 py-1.5 transition-colors",l?"bg-primary-50 dark:bg-primary-950/50 text-primary-700 dark:text-primary-300 ring-1 ring-primary-200 dark:ring-primary-800":"bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-600"].join(" "),children:l?"Logo â":"Use as logo"}),e.jsx("button",{type:"button",onClick:o,title:"Copy image link","aria-label":"Copy image link",className:"shrink-0 w-8 h-8 rounded-lg flex items-center justify-center text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75"})})}),e.jsx("button",{type:"button",onClick:d,title:"Delete","aria-label":"Delete media",className:"shrink-0 w-8 h-8 rounded-lg flex items-center justify-center text-gray-400 hover:text-rose-600 dar
61k:hover:text-rose-400 hover:bg-rose-50 dark:hover:bg-rose-950/40 transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})})})]})]})]})}function L1(){const[s,l]=h.useState({brand_name:"",brand_logo_url:"",brand_color:"#622487",sender_name:"",sender_email:"",tone:"friendly",free_offer_text:""}),[i,o]=h.useState(!0),[d,u]=h.useState(!1),[x,y]=h.useState(!1),[p,g]=h.useState(""),[b,f]=h.useState([]),[k,w]=h.useState("");h.useEffect(()=>{Du.get().then(S=>{if("configured"in S&&!S.configured)return;const _=S;l({brand_name:_.brand_name||"",brand_logo_url:_.brand_logo_url||"",brand_color:_.brand_color||"#622487",sender_name:_.sender_name||"",sender_email:_.sender_email||"",tone:_.tone||"friendly",free_offer_text:_.free_offer_text||""})}).catch(S=>g(S.message)).finally(()=>o(!1)),Hu.list().then(S=>f(S.media)).catch(()=>{})},[]),h.useEffect(()=>{if(!k)return;const S=setTimeout(()=>w(""),2500);return()=>clearTimeout(S)},[k]);async function N(S){try{await navigator.clipboard.writeText(S),w("Image link copied to clipboard.")}catch{w("Could not copy â select and copy the URL manually.")}}async function j(S){if(window.confirm("Remove this media from your library? This cannot be undone."))try{await Hu.remove(S.id),f(_=>_.filter(z=>z.id!==S.id)),l(_=>_.brand_logo_url===S.url?{..._,brand_logo_url:""}:_)}catch(_){g(_.message||"Could not delete media.")}}const T=async S=>{S.preventDefault(),u(!0),g(""),y(!1);try{await Du.update(s),y(!0)}catch(_){g(_.message)}finally{u(!1)}};return h.useEffect(()=>{if(!x)return;const S=setTimeout(()=>y(!1),3e3);return()=>clearTimeout(S)},[x]),i?e.jsx(tt,{label:"Loading brand settingsâ¦"}):e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(Xe,{title:"Brand Settings",subtitle:"How your brand appears in campaigns and social-proof messages."}),x&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"green",children:"Brand settings saved successfully."})}),p&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"red",children:p})}),k&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"blue",children:k})}),e.jsx(_e,{children:e.jsxs("form",{onSubmit:T,className:"space-y-5",children:[e.jsx(le,{label:"Brand Name",required:!0,children:e.jsx("input",{type:"text",required:!0,value:s.brand_name,onChange:S=>l({...s,brand_name:S.target.value}),className:Ln,placeholder:"e.g., Reper, Fantize, Your Company"})}),e.jsxs(le,{label:"Brand Logo",help:"Shown in your campaigns and social-proof messages. Choose any image from your media library below, or paste a URL.",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"shrink-0 w-16 h-16 rounded-xl bg-gray-50 dark:bg-gray-700/50 ring-1 ring-gray-200 dark:ring-gray-600 flex items-center justify-center overflow-hidden",children:s.brand_logo_url?e.jsx("img",{src:s.brand_logo_url,alt:"Selected brand logo",className:"w-full h-full object-contain"}):e.jsx("svg",{className:"w-7 h-7 text-gray-300 dark:text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"})})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:s.brand_logo_url?"Logo selected":"No logo selected"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:s.brand_logo_url?"Pick a different image in the media library below, or clear it.":"Upload to your media library below, then choose âUse as logoâ."})]}),s.brand_logo_url&&e.jsx("button",{type:"button",onClick:()=>l({...s,brand_logo_url:""}),className:"shrink-0 text-xs font-medium text-gray-400 hover:text-rose-600 dar
61k:hover:text-rose-400 transition-colors",children:"Clear"})]}),e.jsxs("details",{className:"mt-2 group",children:[e.jsx("summary",{className:"text-xs text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer select-none list-none",children:"Or paste an image URL"}),e.jsx("input",{type:"url",value:s.brand_logo_url,onChange:S=>l({...s,brand_logo_url:S.target.value}),className:`${Ln} mt-2`,placeholder:"https://..."})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(le,{label:"Brand Color",children:e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("input",{type:"color",value:s.brand_color,onChange:S=>l({...s,brand_color:S.target.value}),"aria-label":"Brand color",style:{width:44,height:44},className:"rounded-xl border border-gray-200 dark:border-gray-600 cursor-pointer p-1 bg-white dark:bg-gray-700"}),e.jsx("input",{type:"text",value:s.brand_color,onChange:S=>l({...s,brand_color:S.target.value}),className:Ln,placeholder:"#622487"})]})}),e.jsx(le,{label:"Tone",help:"Voice used in campaign copy and social proof messages.",children:e.jsxs("select",{value:s.tone,onChange:S=>l({...s,tone:S.target.value}),className:Ln,children:[e.jsx("option",{value:"friendly",children:"Friendly"}),e.jsx("option",{value:"professional",children:"Professional"}),e.jsx("option",{value:"casual",children:"Casual"})]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(le,{label:"Sender Name",children:e.jsx("input",{type:"text",value:s.sender_name,onChange:S=>l({...s,sender_name:S.target.value}),className:Ln,placeholder:"e.g., The Reper Team"})}),e.jsx(le,{label:"Sender Email",children:e.jsx("input",{type:"email",value:s.sender_email,onChange:S=>l({...s,sender_email:S.target.value}),className:Ln,placeholder:"e.g., [email protected]"})})]}),e.jsx(le,{label:"Default Free Offer Text",help:"Used in social proof messages as the call-to-action.",children:e.jsx("textarea",{value:s.free_offer_text,onChange:S=>l({...s,free_offer_text:S.target.value}),rows:3,className:Ln,placeholder:"e.g., Try it free for 30 days â no credit card required."})}),e.jsx("div",{className:"pt-1",children:e.jsx(U,{type:"submit",disabled:d,variant:"primary",children:d?"Savingâ¦":"Save Brand Settings"})})]})}),e.jsxs(_e,{className:"mt-6",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Brand media library"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:"Upload logos, hero images, background graphics, product shots, or any brand asset. Uploading just adds it here, nothing changes automatically. Choose an asset to use as your logo, or copy its link to use anywhere else (campaign content, hero images, backgrounds)."})]}),e.jsx(R1,{onUploaded:S=>f(_=>[S,..._]),onError:S=>g(S)}),e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700 dark:text-gray-200",children:["Your media",e.jsx("span",{className:"inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-gray-100 dark:bg-gray-700 text-xs font-medium text-gray-500 dark:text-gray-400",children:b.length})]}),b.length>0&&e.jsx("span",{className:"hidden sm:block text-xs text-gray-400 dark:text-gray-500",children:"Use as logo, copy link, or delete"})]}),b.length>0?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-4",children:b.map(S=>e.jsx(z1,{m:S,isLogo:s.brand_logo_url===S.url,onSetLogo:()=>{l(_=>({..._,brand_logo_url:S.url})),w("Selected as logo. Click âSave Brand Settingsâ to apply.")},onCopy:()=>N(S.url),onDelete:()=>j(S)},S.id))}):e.jsxs("div",{className:"rounded-2xl border-2 border-dashed border-gray-200 dark:border-gray-700 bg-gray-50/60 dark:bg-gray-900/30 py-10 px-4 text-center",children:[e.jsx("div",{className:"mx-auto w-12 h-12 rounded-xl bg-gray-100 dark:bg-gray-700/50 text-gray-400 dark:text-gray-500 flex items-center justify-center mb-3",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"})})}),e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:"No media yet"}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1 max-w-sm mx-auto",children:"Uploaded assets appear here, ready to use as your logo, a hero image, a background graphic, or anywhere else across Fantize."})]})]})]})]})}const M1=[{value:"silent",label:"Silent (born â¤1945)"},{value:"boomer",label:"Boomer (1946â1964)"},{value:"genx",label:"Gen X (1965â1980)"},{value:"millennial",label:"Millennial (1981â1996)"},{value:"genz",label:"Gen Z (1997+)"}],O1=["active_community","email_list","podcast","instagram_following","membership_model","wine_club","local_following","long_tenure","seeking_capital","word_of_mouth","author_events","festival_presence"],$1=["Food & Beverage","Retail","Beauty & Cosmetics","Health & Wellness","Manufacturing","Outdoor Retail","Software","Services","Automotive"],D1=["completed","running","pending","failed"];function Iu(s){return s==null?"â":s>=1e6?`$${(s/1e6).toFixed(1)}M`:s>=1e3?`$${Math.round(s/1e3)}K`:`$${s}`}function Gl(s){return!s||s.revenue_min==null&&s.revenue_max==null?"â":`${Iu(s.revenue_min)} â ${Iu(s.revenue_max)}`}const H1=s=>Ke(s,{year:"numeric",month:"short",day:"numeric"}),Vu=s=>Ia(s,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});function q1(s){const l=new Date;return l.setDate(l.getDate()-s),l.toISOString().slice(0,10)}const Ig={text:"",projectId:"all",status:"all",provider:"all",dateFrom:"",dateTo:"",minResults:""};
61function B1(){const[s,l]=h.useState([]),[i,o]=h.useState([]),[d,u]=h.useState(!0),[x,y]=h.useState(""),[p,g]=h.useState("history"),[b,f]=h.useState(Ig),[k,w]=h.useState("date"),[N,j]=h.useState("desc"),[T,S]=h.useState(!1),[_,z]=h.useState(null),[A,L]=h.useState({}),[F,D]=h.useState(!1),[te,pe]=h.useState(""),[he,X]=h.useState(null),[I,q]=h.useState(!1),[be,ne]=h.useState(null);h.useEffect(()=>{M()},[]);async function M(){u(!0);try{const[{profiles:me},{jobs:ke}]=await Promise.all([os.list(),Eo.list().catch(()=>({jobs:[]}))]);l(me),o(ke),me.length&&!te&&pe(me[0].id)}catch(me){y(me.message||"Failed to load prospect research.")}finally{u(!1)}}const Y=h.useMemo(()=>{const me={};for(const ke of s)me[ke.id]=ke;return me},[s]),oe=h.useMemo(()=>Array.from(new Set(i.map(me=>me.provider).filter(Boolean))),[i]),Ce=h.useMemo(()=>i.map(me=>({...me,project:Y[me.profile_id]||null,projectName:Y[me.profile_id]?.name||"Unknown project"})),[i,Y]),Ae=h.useMemo(()=>{const me=b.text.trim().toLowerCase(),ke=b.minResults?Number(b.minResults):null,ze=b.dateFrom?new Date(b.dateFrom+"T00:00:00").getTime():null,C=b.dateTo?new Date(b.dateTo+"T23:59:59").getTime():null;return Ce.filter(ve=>{if(me&&!(ve.projectName.toLowerCase().includes(me)||(ve.project?.description||"").toLowerCase().includes(me))||b.projectId!=="all"&&ve.profile_id!==b.projectId||b.status!=="all"&&ve.status!==b.status||b.provider!=="all"&&ve.provider!==b.provider||ke!=null&&(ve.total_found??0)<ke)return!1;const Oe=Gt(ve.created_at);return!(ze!=null&&Oe<ze||C!=null&&Oe>C)})},[Ce,b]),H=h.useMemo(()=>{const me=N==="asc"?1:-1;return[...Ae].sort((ke,ze)=>{let C=0;switch(k){case"date":C=Gt(ke.created_at)-Gt(ze.created_at);break;case"project":C=ke.projectName.localeCompare(ze.projectName,void 0,{sensitivity:"base"});break;case"results":C=(ke.total_found??0)-(ze.total_found??0);break;case"status":C=ke.status.localeCompare(ze.status);break;case"provider":C=(ke.provider||"").localeCompare(ze.provider||"");break}return C*me})},[Ae,k,N]),Z=h.useMemo(()=>{const me=new Map;for(const ke of H){const ze=me.get(ke.profile_id)||[];ze.push(ke),me.set(ke.profile_id,ze)}return Array.from(me.entries()).map(([ke,ze])=>({profile_id:ke,project:Y[ke]||null,projectName:ze[0].projectName,runs:ze,prospects:ze.reduce((C,ve)=>C+(ve.total_found??0),0)}))},[H,Y]),$=h.useMemo(()=>{const me=i.reduce((ze,C)=>ze+(C.total_found??0),0),ke=i.filter(ze=>ze.status==="completed").length;return{projects:s.length,searches:i.length,prospects:me,avg:i.length?Math.round(me/i.length):0,completed:ke}},[i,s]),O=b.text!==""||b.projectId!=="all"||b.status!=="all"||b.provider!=="all"||b.dateFrom!==""||b.dateTo!==""||b.minResults!=="";function P(me,ke){f(ze=>({...ze,[me]:ke}))}function V(){f(Ig)}function ye(me){k===me?j(ke=>ke==="asc"?"desc":"asc"):(w(me),j(me==="project"?"asc":"desc"))}function ge(me,ke){w(me),j(ke)}async function qe(me){if(_===me){z(null);return}if(z(me),!A[me]){D(!0);try{const{matches:ke}=await gu.list({job_id:me});L(ze=>({...ze,[me]:ke}))}catch(ke){y(ke.message)}finally{D(!1)}}}async function nt(me){if(me){y("");try{const{id:ke}=await Eo.create({profile_id:me,max_results:25}),ze=async()=>{const C=await Eo.get(ke);X(C),C.status==="running"||C.status==="pending"?setTimeout(ze,1200):(X(null),await M(),g("history"),f(ve=>({...ve,projectId:me})),z(ke),await qe(ke))};ze()}catch(ke){y(ke.message)}}}async function R(me){try{if(be?.id){const ke=await os.update(be.id,me);l(ze=>ze.map(C=>C.id===ke.id?ke:C))}else{const ke=await os.create(me);l(ze=>[ke,...ze]),pe(ke.id)}q(!1),ne(null)}catch(ke){y(ke.message)}}async function we(me){if(confirm("Delete this targeting project? Past search runs and results are kept."))try{await os.delete(me),l(ke=>ke.filter(ze=>ze.id!==me)),te===me&&pe(s.find(ke=>ke.id!==me)?.id||"")}catch(ke){y(ke.message)}}async function ie(me,ke){try{await gu.promote(ke),L(ze=>({...ze,[me]:(ze[me]||[]).map(C=>C.id===ke?{...C,status:"promoted"}:C)}))}catch(ze){y(ze.message)}}async function Ee(me,ke){try{await gu.reject(ke),L(ze=>({...ze,[me]:(ze[me]||[]).map(C=>C.id===ke?{...C,status:"rejected"}:C)}))}catch(ze){y(ze.message)}}function Je(){const me=C=>
61C&&C.length?C.join("; "):"",ke=C=>!C||C.employee_min==null&&C.employee_max==null?"":`${C.employee_min??0} - ${C.employee_max??"+"}`,ze=[["Started","Completed","Project","Provider","Status","Results Found","Requested","Revenue Target","Employee Range","Industries","Geographies","Signals","Keywords","Error"],...H.map(C=>[Vu(C.created_at),C.completed_at?Vu(C.completed_at):"",C.projectName,C.provider||"",C.status,C.total_found??0,C.max_results??"",Gl(C.project)==="â"?"":Gl(C.project),ke(C.project),me(C.project?.industries),me(C.project?.geo),me(C.project?.signals),me(C.project?.keywords),C.error??""])];Ua(`search-history-${new Date().toISOString().slice(0,10)}`,ze)}return d?e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-sm ring-1 ring-gray-200 dark:ring-gray-700 p-6 mb-6",children:e.jsx(tt,{label:"Loading prospect researchâ¦"})}):e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-sm ring-1 ring-gray-200 dark:ring-gray-700 p-5 sm:p-6 mb-6",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-start lg:justify-between gap-4 mb-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Prospect Research"}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Review every search you've run here. Set up, edit, schedule, and manage searches in"," ",e.jsx(Se,{to:"/dashboard/prospecting/searches",className:"text-primary-600 hover:underline font-medium",children:"Searches"}),"."]})]}),s.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("select",{value:te,onChange:me=>pe(me.target.value),className:`${de} max-w-[12rem]`,"aria-label":"Project to research",children:s.map(me=>e.jsx("option",{value:me.id,children:me.name},me.id))}),e.jsx(U,{size:"sm",onClick:()=>nt(te),disabled:!!he||!te,children:he?"Researchingâ¦":"Run Research"}),e.jsx(U,{size:"sm",variant:"soft",onClick:()=>{ne(null),q(!0)},children:"+ New Project"})]})]}),x&&e.jsx("div",{className:"mb-4",children:e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-300 px-3 py-2 rounded-lg text-sm",children:x})}),he&&e.jsxs("div",{className:"mb-4 text-sm text-amber-700 dark:text-amber-300 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg px-3 py-2",children:["Researching â",Y[he.profile_id]?.name||"project","â⦠status: ",he.status]}),s.length===0?e.jsx(Ze,{title:"No targeting projects yet",hint:"Create a project that describes the companies you want Fantize to find, then run a search.",action:e.jsx(U,{onClick:()=>{ne(null),q(!0)},children:"Create your first project"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-5",children:[e.jsx(bo,{label:"Projects",value:$.projects}),e.jsx(bo,{label:"Searches run",value:$.searches}),e.jsx(bo,{label:"Prospects found",value:$.prospects.toLocaleString(),tone:"primary"}),e.jsx(bo,{label:"Avg / search",value:$.avg})]}),e.jsx("div",{className:"inline-flex rounded-xl bg-gray-100 dark:bg-gray-900/60 p-1 mb-5",children:["history","projects"].map(me=>e.jsx("button",{onClick:()=>g(me),className:`px-4 py-1.5 rounded-lg text-sm font-medium transition-colors ${p===me?"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"}`,children:me==="history"?"Search History":"Projects"},me))}),p==="history"?e.jsx(U1,{filters:b,setFilter:P,clearFilters:V,filtersActive:O,profiles:s,providers:oe,sortField:k,sortDir:N,toggleSort:ye,setSort:ge,groupByProject:T,setGroupByProject:S,sorted:H,grouped:Z,totalRuns:Ce.length,expandedJobId:_,matchesByJob:A,loadingMatches:F,onToggleExpand:qe,onPromote:ie,onReject:Ee,onExport:Je}):e.jsx(I1,{profiles:s,jobs:i,onRun:nt,running:!!he,onEdit:me=>{ne(me),q(!0)},onDelete:we,onViewHistory:me=>{g("history"),f(ke=>({...ke,projectId:me}))}})]}),I&&e.jsx(V1,{initial:be,onSave:R,onCancel:()=>{q(!1),ne(null)}})]})}function bo({label:s,value:l,tone:i}){return e.jsxs("div",{className:"rounded-xl bg-gray-50 dark:bg-gray-900/40 ring-1 ring-gray-100 dark:ring-gray-700/60 px-4 py-3",children:[e.jsx("div",{className:`text-xl font-bold ${i==="primary"?"text-primary-600 dark:text-primary-400":"text-gray-900 dark:text-gray-100"}`,children:l}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:s})]})}function U1(s){const{filters:l,setFilter:i,clearFilters:o,filtersActive:d,profiles:u,providers:x,sortField:y,sortDir:p,toggleSort:g,setSort:b,groupByProject:f,setGroupByProject:k,sorted:w,grouped:N,totalRuns:j,expandedJobId:T,matchesByJob:S,loadingMatches:_,onToggleExpand:z,onPromote:A,onReject:L,onExport:F}=s,D=`${de} text-sm`,[te,pe]=h.useState(d),he=[l.projectId!=="all",l.status!=="all",l.provider!=="all",!!l.dateFrom,!!l.dateTo,!!l.minResults].filter(
61Boolean).length,X="text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500 mb-1.5";return e.jsxs("div",{children:[e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-gray-700 bg-gray-50/60 dark:bg-gray-900/30 p-3 mb-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2.5",children:[e.jsx("input",{value:l.text,onChange:I=>i("text",I.target.value),placeholder:"Search by project nameâ¦",className:`${D} flex-1`}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("select",{value:`${y}:${p}`,onChange:I=>{const[q,be]=I.target.value.split(":");b(q,be)},className:D,"aria-label":"Sort",children:[e.jsx("option",{value:"date:desc",children:"Newest first"}),e.jsx("option",{value:"date:asc",children:"Oldest first"}),e.jsx("option",{value:"project:asc",children:"Project AâZ"}),e.jsx("option",{value:"project:desc",children:"Project ZâA"}),e.jsx("option",{value:"results:desc",children:"Most results"}),e.jsx("option",{value:"results:asc",children:"Fewest results"}),e.jsx("option",{value:"status:asc",children:"Status"})]}),e.jsxs("button",{onClick:()=>pe(I=>!I),className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 text-sm font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 whitespace-nowrap",children:[e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M2 4.75A.75.75 0 012.75 4h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 4.75zM4 10a.75.75 0 01.75-.75h10.5a.75.75 0 010 1.5H4.75A.75.75 0 014 10zm3 5.25a.75.75 0 01.75-.75h4.5a.75.75 0 010 1.5h-4.5a.75.75 0 01-.75-.75z",clipRule:"evenodd"})}),"Filters",he>0&&e.jsx("span",{className:"ml-0.5 inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1 rounded-full bg-primary-600 text-white text-[11px]",children:he})]})]})]}),te&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-700 grid grid-cols-1 lg:grid-cols-2 gap-x-6 gap-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:X,children:"Refine"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2.5",children:[e.jsxs("select",{value:l.projectId,onChange:I=>i("projectId",I.target.value),className:D,"aria-label":"Filter by project",children:[e.jsx("option",{value:"all",children:"All projects"}),u.map(I=>e.jsx("option",{value:I.id,children:I.name},I.id))]}),e.jsxs("select",{value:l.status,onChange:I=>i("status",I.target.value),className:D,"aria-label":"Filter by status",children:[e.jsx("option",{value:"all",children:"Any status"}),D1.map(I=>e.jsx("option",{value:I,children:I[0].toUpperCase()+I.slice(1)},I))]}),e.jsxs("select",{value:l.provider,onChange:I=>i("provider",I.target.value),className:D,"aria-label":"Filter by type",children:[e.jsx("option",{value:"all",children:"Any type"}),x.map(I=>e.jsx("option",{value:I,children:I},I))]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:X,children:"Date & results"}),e.jsxs("div",{className:"flex flex-wrap items-end gap-2.5",children:[e.jsxs("label",{className:"text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{className:"block mb-1",children:"From"}),e.jsx("input",{type:"date",value:l.dateFrom,onChange:I=>i("dateFrom",I.target.value),className:D})]}),e.jsxs("label",{className:"text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{className:"block mb-1",children:"To"}),e.jsx("input",{type:"date",value:l.dateTo,onChange:I=>i("dateTo",I.target.value),className:D})]}),e.jsx("div",{className:"flex items-center gap-1 pb-0.5",children:[{l:"7d",d:7},{l:"30d",d:30},{l:"90d",d:90}].map(I=>e.jsx("button",{onClick:()=>{i("dateFrom",q1(I.d)),i("dateTo","")},className:"px-2.5 py-1.5 text-xs rounded-lg border border-gray-200 dark:border-gray-600 text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:I.l},I.l))}),e.jsxs("label",{className:"text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{className:"block mb-1",children:"Min results"}),e.jsx("input",{type:"number",min:0,value:l.minResults,onChange:I=>i("minResults",I.target.value),placeholder:"0",className:`${D} w-20`})]})]}),e.jsxs("label",{className:"flex items-center gap-2 min-h-11 text-sm text-gray-600 dark:text-gray-300 mt-3",children:[e.jsx("span",{className:"flex h-11 w-11 -ml-2.5 flex-none items-center justify-center",children:e.jsx("input",{type:"checkbox",checked:f,onChange:I=>k(I.target.checked),className:"rounded border-gray-300 dark:border-gray-600"})}),"Group by project"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2.5 pt-2.5 border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Showing ",e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:w.length})," of ",j," searches"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[d&&e.jsx("button",{onClick:o,className:"text-xs font-medium text-primary-600 dark:text-primary-400 hover:underline",children:"Clear filters"}),e.jsx("button",{onClick:F,disabled:w.length===0,className:"text-xs font-medium text-gray-600 dark:text-gray-300 hover:underline disabled:opacity-40",children:"Export CSV"})]})]})]}
61),w.length===0?e.jsx(Ze,{title:j===0?"No searches run yet":"No searches match these filters",hint:j===0?"Pick a project above and click Run Research to start.":"Try widening the date range or clearing filters."}):f?e.jsx("div",{className:"space-y-4",children:N.map(I=>e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 bg-gray-50 dark:bg-gray-900/40 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 truncate",children:I.projectName}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Revenue target ",Gl(I.project)]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 text-xs",children:[e.jsxs(se,{tone:"gray",children:[I.runs.length," ",I.runs.length===1?"search":"searches"]}),e.jsxs(se,{tone:"blue",children:[I.prospects.toLocaleString()," prospects"]})]})]}),e.jsx(Vg,{runs:I.runs,sortField:y,sortDir:p,toggleSort:g,showProject:!1,expandedJobId:T,matchesByJob:S,loadingMatches:_,onToggleExpand:z,onPromote:A,onReject:L})]},I.profile_id))}):e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsx(Vg,{runs:w,sortField:y,sortDir:p,toggleSort:g,showProject:!0,expandedJobId:T,matchesByJob:S,loadingMatches:_,onToggleExpand:z,onPromote:A,onReject:L})})]})}function Vg(s){const{runs:l,sortField:i,sortDir:o,toggleSort:d,showProject:u,expandedJobId:x,matchesByJob:y,loadingMatches:p,onToggleExpand:g,onPromote:b,onReject:f}=s,k=u?6:5;return e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50 text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsx($l,{label:"Date",field:"date",sortField:i,sortDir:o,onSort:d}),u&&e.jsx($l,{label:"Project",field:"project",sortField:i,sortDir:o,onSort:d}),e.jsx($l,{label:"Type",field:"provider",sortField:i,sortDir:o,onSort:d}),e.jsx($l,{label:"Status",field:"status",sortField:i,sortDir:o,onSort:d}),e.jsx($l,{label:"Results",field:"results",sortField:i,sortDir:o,onSort:d,align:"right"}),e.jsx("th",{className:"px-4 py-2.5"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:l.map(w=>{const N=x===w.id;return e.jsxs(h.Fragment,{children:[e.jsxs("tr",{onClick:()=>g(w.id),className:"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/40 text-gray-900 dark:text-gray-200",children:[e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:Vu(w.created_at)}),u&&e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 truncate max-w-[14rem]",children:w.projectName}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:Gl(w.project)})]}),e.jsx("td",{className:"px-4 py-3 text-gray-500 dark:text-gray-400",children:w.provider||"â"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(Bn,{status:w.status})}),e.jsx("td",{className:"px-4 py-3 text-right font-medium tabular-nums",children:(w.total_found??0).toLocaleString()}),e.jsx("td",{className:"px-4 py-3 text-right whitespace-nowrap",children:e.jsx("span",{className:"text-xs text-primary-600 dark:text-primary-400",children:N?"Hide":"View"})})]}),N&&e.jsx("tr",{children:e.jsx("td",{colSpan:k,className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/40 border-t border-gray-100 dark:border-gray-700",children:p&&!y[w.id]?e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 py-3 text-center",children:"Loading prospectsâ¦"}):e.jsx(F1,{matches:y[w.id]||[],onPromote:j=>b(w.id,j),onReject:j=>f(w.id,j)})})},w.id+"-detail")]},w.id)})})]})}function $l({label:s,field:l,sortField:i,sortDir:o,onSort:d,align:u}){const x=i===l;return e.jsx("th",{className:`px-4 py-2.5 font-medium ${u==="right"?"text-right":"text-left"}`,children:e.jsxs("button",{onClick:()=>d(l),className:`inline-flex items-center gap-1 hover:text-gray-700 dark:hover:text-gray-200 ${x?"text-gray-700 dark:text-gray-200":""}`,children:[s,e.jsx("span",{className:"text-[10px]",children:x?o==="asc"?"â²":"â¼":"â"})]})})}function F1({matches:s,onPromote:l,onReject:i}){return s.length===0?e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 py-3 text-center",children:"This search returned no prospects."}):e.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50 text-xs uppercase text-gray-500 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-3 py-2",children:"Score"}),e.jsx("th",{className:"text-left px-3 py-2",children:"Company"}),e.jsx("th",{className:"text-left px-3 py-2",children:"Revenue / Size"}),e.jsx("th",{className:"text-left px-3 py-2",children:"Owner"}),e.jsx("th",{className:"text-left px-3 py-2",children:"Contact"}),e.jsx("th",{className:"px-3 py-2"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:s.map(o=>e.jsxs("tr",{className:o.status!=="new"?"opacity-50":"hover:bg-gray-50 dark:hover:bg-gray-700/40",children:[e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:`inline-block px-2 py-1 rounded text-xs font-bold ${o.match_score>=.8?"bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300":o.match_score>=.6?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/40 dark:text-yellow-300":"bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-300"}`,children:(o.match_score*100).toFixed(0)})}),e.jsxs("td",{className:"px-3 py-3",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:o.company_name}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[o.industry,o.location?` · ${o.location}`:"",o.founded_year?` · est. ${o.founded_year}`:""]})]}),e.jsxs("td",{className:"px-3 py-3 text-xs text-gray-600 dark:text-gray-300",children:[Iu(o.revenue_estimate),o.employee_estimate?e.jsxs("div",{className:"text-gray-400 dark:text-gray-500",children:[o.employee_estimate," empl."]}):null]}),e.jsxs("td",{className:"px-3 py-3 text-xs text-gray-600 dark:text-gray-300",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:o.owner_name||"â"}),e.jsx("div",{className:"text-gray-400 dark:text-gray-500",children:o.owner_role})]}),e.jsxs("td",{className:"px-3 py-3 text-xs",children:[o.contact_email&&e.jsx("div",{children:e.jsx("a",{href:`mailto:${o.contact_email}`,className:"text-primary-600 dark:text-primary-400 hover:underline",children:o.contact_email})}),o.contact_phone&&e.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:o.contact_phone})]}),e.jsx("td",{className:"px-3 py-3 text-right whitespace-nowrap",children:o.status==="new"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>l(o.id),className:"text-xs text-green-700 dark:text-green-400 hover:underline mr-3",children:"Add to pipeline"}),e.jsx("button",{onClick:()=>i(o.id),className:"text-xs text-gray-400 dark:text-gray-500 hover:text-red-600 dark:hover:text-red-400",children:"Reject"})]}):e.jsx("span",{className:`text-xs ${o.status==="promoted"?"text-green-600 dark:text-green-400":"text-gray-400 dark:text-gray-500"}`,children:o.status})})]},o.id))})]})})}function I1({profiles:s,jobs:l,onRun:i,running:o,onEdit:d,onDelete:u,onViewHistory:x}){const y=h.useMemo(()=>{const b={};for(const f of l){const k=b[f.profile_id]||{runs:0,prospects:0};k.runs+=1,k.prospects+=f.total_found??0,(!k.last||new Date(f.created_at)>new Date(k.last))&&(k.last=f.created_at),b[f.profile_id]=k}return b},[l]),p=b=>`inline-flex items-center justify-center w-8 h-8 rounded-lg transition-colors disabled:opacity-50 ${b==="primary"?"bg-primary-600 text-white hover:bg-primary-700":b==="danger"?"text-rose-500 hover:bg-rose-50 dark:hover:bg-rose-900/20":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700"}`,g=b=>e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.7,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:b})});return e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:s.map(b=>{const f=y[b.id]||{runs:0,prospects:0},k=b.industries||[];return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800/60 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 truncate",children:b.name}),b.description&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 line-clamp-2 mt-0.5",children:b.description})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{title:"Run research","aria-label":"Run research",onClick:()=>
61i(b.id),disabled:o,className:p("primary"),children:g("M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.348a1.125 1.125 0 010 1.971l-11.54 6.347a1.125 1.125 0 01-1.667-.985V5.653z")}),e.jsx("button",{title:"View history","aria-label":"View history",onClick:()=>x(b.id),className:p("ghost"),children:g("M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z")}),e.jsx("button",{title:"Edit project","aria-label":"Edit project",onClick:()=>d(b),className:p("ghost"),children:g("M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931z")}),e.jsx("button",{title:"Delete project","aria-label":"Delete project",onClick:()=>u(b.id),className:p("danger"),children:g("M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-3",children:[e.jsx(se,{tone:"gray",children:Gl(b)}),k.slice(0,3).map(w=>e.jsx(se,{tone:"blue",children:w},w)),k.length>3&&e.jsxs(se,{tone:"gray",children:["+",k.length-3]}),k.length===0&&e.jsx("span",{className:"text-xs text-gray-400",children:"Any industry"})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-3 pt-3 border-t border-gray-100 dark:border-gray-700/60 text-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200 tabular-nums",children:f.runs})," searches"]}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200 tabular-nums",children:f.prospects.toLocaleString()})," prospects"]}),e.jsx("span",{className:"ml-auto whitespace-nowrap",children:f.last?`Last ${H1(f.last)}`:"Never run"})]})]},b.id)})})}function V1({initial:s,onSave:l,onCancel:i}){const[o,d]=h.useState(s?.name||""),[u,x]=h.useState(s?.description||""),[y,p]=h.useState(s?.revenue_min?.toString()||""),[g,b]=h.useState(s?.revenue_max?.toString()||""),[f,k]=h.useState(s?.employee_min?.toString()||""),[w,N]=h.useState(s?.employee_max?.toString()||""),[j,T]=h.useState(s?.industries||[]),[S,_]=h.useState(s?.owner_generations||[]),[z,A]=h.useState(s?.owner_age_min?.toString()||""),[L,F]=h.useState(s?.owner_age_max?.toString()||""),[D,te]=h.useState(s?.signals||[]),[pe,he]=h.useState((s?.keywords||[]).join(", ")),[X,I]=h.useState(s?.pitch_angle||"");function q(M,Y,oe){Y(M.includes(oe)?M.filter(Ce=>Ce!==oe):[...M,oe])}function be(){o.trim()&&l({name:o.trim(),description:u.trim()||void 0,revenue_min:y?Number(y):null,revenue_max:g?Number(g):null,employee_min:f?Number(f):null,employee_max:w?Number(w):null,industries:j,owner_generations:S,owner_age_min:z?Number(z):null,owner_age_max:L?Number(L):null,signals:D,keywords:pe.split(",").map(M=>M.trim()).filter(Boolean),pitch_angle:X.trim()||void 0})}const ne=M=>`px-3 py-1 rounded-full text-xs border transition-colors ${M?"bg-primary-500 text-white border-primary-500":"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:border-gray-400 dark:hover:border-gray-500"}`;return e.jsx(Et,{open:!0,onClose:i,title:s?"Edit Target Project":"New Target Project",footer:e.jsxs(e.Fragment,{children:[e.jsx(U,{variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(U,{onClick:be,disabled:!o.trim(),children:s?"Save changes":"Create project"})]}),children:e.jsxs("div",{className:"space-y-5",children:[e.jsx(wa,{label:"Project name *",children:e.jsx("input",{value:o,onChange:M=>d(M.target.value),className:de,placeholder:"e.g. Boomer-owned community businesses"})}),e.jsx(wa,{label:"What are you looking for?",children:e.jsx("textarea",{value:u,onChange:M=>x(M.target.value),rows:2,className:de,placeholder:"Plain-English description. Helps you remember this project."})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(wa,{label:"Revenue min ($)",children:e.jsx("input",{type:"number",value:y,onChange:M=>p(M.target.value),className:de,placeholder:"500000"})}),e.jsx(wa,{label:"Revenue max ($)",children:e.jsx("input",{type:"number",value:g,onChange:M=>b(M.target.value),className:de,placeholder:"2000000"})}),e.jsx(wa,{label:"Employees min",children:e.jsx("input",{type:"number",value:f,onChange:M=>k(M.target.value),className:de})}),e.jsx(wa,{label:"Employees max",children:e.jsx("input",{type:"number",value:w,onChange:M=>N(M.target.value),className:de})})]}),e.jsxs(wa,{label:"Industries",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:$1.map(M=>e.jsx("button",{type:"button",onClick:()=>q(j,T,M),className:ne(j.includes(M)),children:M},M))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Pick none to match any industry."})]}),e.jsx(wa,{label:"Owner generation",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:M1.map(M=>e.jsx("button",{type:"button",onClick:()=>
61q(S,_,M.value),className:ne(S.includes(M.value)),children:M.label},M.value))})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(wa,{label:"Owner age min",children:e.jsx("input",{type:"number",value:z,onChange:M=>A(M.target.value),className:de,placeholder:"58"})}),e.jsx(wa,{label:"Owner age max",children:e.jsx("input",{type:"number",value:L,onChange:M=>F(M.target.value),className:de,placeholder:"78"})})]}),e.jsxs(wa,{label:"Intent / community signals",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:O1.map(M=>e.jsx("button",{type:"button",onClick:()=>q(D,te,M),className:ne(D.includes(M)),children:M.replace(/_/g," ")},M))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"More signals = tighter targeting."})]}),e.jsx(wa,{label:"Custom keywords (comma-separated)",children:e.jsx("input",{value:pe,onChange:M=>he(M.target.value),className:de,placeholder:"succession, legacy, community round, local brand"})}),e.jsx(wa,{label:"Pitch angle",children:e.jsx("textarea",{value:X,onChange:M=>I(M.target.value),rows:3,className:de,placeholder:"One-sentence pitch. Used when generating campaign copy for matches."})})]})})}function wa({label:s,children:l}){return e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-sm font-medium mb-1 text-gray-700 dark:text-gray-200",children:s}),l]})}function G1(s){return s==="researching"?"blue":s==="pitched"||s==="follow-up"?"amber":s==="signed"?"green":"gray"}const Ka={researching:"Researching",pitched:"Pitched","follow-up":"Follow-up",signed:"Signed"},ta=de;function Y1(){const{account:s}=zt(),[l,i]=h.useState([]),[o,d]=h.useState(!0),[u,x]=h.useState(!1),[y,p]=h.useState("all");h.useEffect(()=>{},[]),h.useEffect(()=>{s&&g()},[s]);async function g(){d(!0);try{const{companies:z}=await Rn.list();if(z.length===0){const A=`fantize_target_companies_${s.id}`,L=localStorage.getItem(A)||localStorage.getItem("fantize_target_companies");if(L){const F=JSON.parse(L);if(F.length>0){await Rn.bulkImport(F);const{companies:D}=await Rn.list();i(D)}else i([])}else i([]);localStorage.removeItem("fantize_target_companies"),localStorage.removeItem(`fantize_target_companies_${s.id}`)}else i(z)}catch{i([])}finally{d(!1)}}const b=async z=>{const A=new Date().toISOString();try{const{company:L}=await Rn.create({...z,id:Date.now().toString(),addedDate:A});i(F=>[L,...F]),x(!1)}catch{}},f=async(z,A)=>{i(L=>L.map(F=>F.id===z?{...F,status:A}:F));try{await Rn.update(z,{status:A})}catch{}},k=async z=>{if(confirm("Are you sure you want to delete this company?")){i(A=>A.filter(L=>L.id!==z));try{await Rn.remove(z)}catch{}}},w=async z=>{i(A=>A.map(L=>L.id===z.id?z:L));try{await Rn.update(z.id,z)}catch{}},N=y==="all"?l:l.filter(z=>z.status===y),j=l.filter(z=>z.status==="signed").length,T=j/5*100,_=["all","researching","pitched","follow-up","signed"].map(z=>({key:z,label:z==="all"?"All":Ka[z],count:z==="all"?l.length:l.filter(A=>A.status===z).length}));return e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(Xe,{title:"Outreach Tracker",subtitle:"Manual outreach you are tracking by hand, alongside past prospect research.",secondary:e.jsx(Se,{to:"/dashboard/prospecting/searches",children:e.jsx(U,{variant:"soft",size:"sm",children:"Find targets in Prospecting"})})}),e.jsx(B1,{}),e.jsx(Go,{}),e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"Manual outreach tracker"}),e.jsx(U,{variant:"primary",size:"sm",onClick:()=>x(!0),children:"Add Company"})]}),o?e.jsx(tt,{label:"Loading your trackerâ¦"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800/80 rounded-2xl shadow-sm ring-1 ring-gray-100 dark:ring-gray-700 p-5 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"Goal: Sign 5 B2C Companies"}),e.jsxs("span",{className:"text-xl font-bold text-primary-600",children:[j,"/5"]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-gray-700 rounded-full h-3 mb-2",children:e.jsx("div",{className:"bg-primary-500 h-3 rounded-full transition-all duration-500",style:{width:`${Math.min(T,100)}%`}})}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:j>=5?"Goal achieved! Fantastic work!":`${5-j} more ${5-j===1?"company":"companies"} to go.`})]}),e.jsx("div",{className:"mb-6",children:e.jsx(Xl,{tabs:_,active:y,onChange:z=>p(z)})}),e.jsx(Et,{open:u,onClose:()=>x(!1),title:"Add Target Company",children:e.jsx(X1,{onAdd:b,onCancel:()=>x(!1)})}),N.length===0?e.jsx(Ze,{title:y!=="all"?`No companies with status "${Ka[y]}".`:"No companies tracked yet.",hint:y==="all"?"Find prospects via Lead Gen or add a company manually.":"Try selecting a different filter.",action:y==="all"?e.jsx(Se,{to:"/dashboard/prospecting/searches",children:e.jsx(U,{variant:"primary",size:"sm",children:"Find Prospects via Lead Gen"})}):void 0}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col gap-3 sm:hidden",children:N.map(z=>e.jsx(P1,{company:z,onUpdateStatus:f,onDelete:k,onEdit:w},z.id))}),e.jsx("div",{className:"hidden sm:block bg-white dark:bg-gray-800/80 rounded-2xl shadow-sm ring-1 ring-gray-100 dark:ring-gray-700 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:Hr,children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Company"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Industry"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Key Contact"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Next Action"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Notes"}),e.jsx("th",{className:"px-4 py-3"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:N.map(z=>e.jsx(Q1,{company:z,onUpdateStatus:f,onDelete:k,onEdit:w},z.id))})]})})]})]})]})}function P1({company:s,onUpdateStatus:l,onDelete:i,onEdit:o}
61){const[d,u]=h.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(_e,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold text-gray-900 dark:text-gray-100 truncate",children:s.companyName}),e.jsx("p",{className:"text-xs text-gray-500",children:s.industry})]}),e.jsx(se,{tone:G1(s.status),children:Ka[s.status]})]}),e.jsxs("div",{className:"text-sm text-gray-600 mb-2",children:[e.jsx("span",{className:"font-medium",children:s.keyContact}),s.contactRole&&e.jsxs("span",{className:"text-gray-400",children:[" · ",s.contactRole]}),s.contactEmail&&e.jsx("div",{children:e.jsx("a",{href:`mailto:${s.contactEmail}`,className:"text-xs text-primary-600 hover:underline",children:s.contactEmail})})]}),s.nextAction&&e.jsxs("div",{className:"text-xs text-gray-500 mb-2",children:[e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:"Next: "}),s.nextAction]}),s.notes&&e.jsx("p",{className:"text-xs text-gray-400 line-clamp-2 mb-2",children:s.notes}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-gray-100 dark:border-gray-700",children:[e.jsx("select",{value:s.status,onChange:x=>l(s.id,x.target.value),className:"text-xs border border-gray-200 dark:border-gray-600 rounded-lg px-2 py-1 focus:outline-none focus:ring-1 focus:ring-primary-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",children:Object.keys(Ka).map(x=>e.jsx("option",{value:x,children:Ka[x]},x))}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>u(!0),className:"text-xs text-primary-600 hover:text-primary-800",children:"Edit"}),e.jsx("button",{onClick:()=>i(s.id),className:"text-xs text-rose-500 hover:text-rose-700",children:"Delete"})]})]})]}),e.jsx(Et,{open:d,onClose:()=>u(!1),title:"Edit Company",children:e.jsx(ap,{company:s,onSave:x=>{o(x),u(!1)},onCancel:()=>u(!1)})})]})}function Q1({company:s,onUpdateStatus:l,onDelete:i,onEdit:o}){const[d,u]=h.useState(!1),[x,y]=h.useState(!1);return d?e.jsx("tr",{className:"bg-gray-50 dark:bg-gray-900/40",children:e.jsx("td",{colSpan:7,className:"px-4 py-4",children:e.jsx(ap,{company:s,onSave:p=>{o(p),u(!1)},onCancel:()=>u(!1)})})}):e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:Ql,children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:s.companyName}),e.jsxs("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:["Added ",Ke(s.addedDate)]})]}),e.jsx("td",{className:"px-4 py-3 text-gray-500 dark:text-gray-400",children:s.industry}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:s.keyContact}),s.contactRole&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.contactRole}),s.contactEmail&&e.jsx("a",{href:`mailto:${s.contactEmail}`,className:"text-xs text-primary-600 hover:underline",children:s.contactEmail})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("select",{value:s.status,onChange:p=>l(s.id,p.target.value),className:"text-xs border border-gray-200 dark:border-gray-600 rounded-lg px-2 py-1 focus:outline-none focus:ring-1 focus:ring-primary-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",children:Object.keys(Ka).map(p=>e.jsx("option",{value:p,children:Ka[p]},p))})}),e.jsx("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:e.jsx("div",{className:"max-w-xs font-medium",children:s.nextAction||"â"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"max-w-xs",children:s.notes?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-gray-500 dark:text-gray-400 text-xs line-clamp-2",children:s.notes}),e.jsx("button",{onClick:()=>y(!x),className:"text-xs text-primary-600 hover:underline mt-1",children:x?"Show less":"Show more"})]}):e.jsx("span",{className:"text-gray-400",children:"â"})})}),e.jsxs("td",{className:"px-4 py-3 text-right whitespace-nowrap",children:[e.jsx("button",{onClick:()=>u(!0),className:"text-primary-600 hover:text-primary-800 text-xs mr-3",children:"Edit"}),e.jsx("button",{onClick:()=>i(s.id),className:"text-rose-500 hover:text-rose-700 text-xs",children:"Delete"})]})]}),x&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/40 border-t border-gray-100 dark:border-gray-700",children:e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium text-gray-700 dark:text-gray-200 mb-1",children:"Full Notes:"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300 whitespace-pre-wrap",children:s.notes}),e.jsxs("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-2",children:["Last updated: ",Ia(s.lastUpdated)]})]})})})]})}function X1({onAdd:s,onCancel:l}){const[i,o]=h.useState({companyName:"",industry:"",keyContact:"",contactEmail:"",contactRole:"",status:"researching",notes:"",nextAction:""}),d=u=>{u.preventDefault(),s(i)};return e.jsxs("form",{onSubmit:d,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(le,{label:"Company name",required:!0,children:e.jsx("input",{type:"text",placeholder:"Acme Manufacturing",required:!0,value:i.companyName,onChange:u=>o({...i,companyName:u.target.value}),className:ta})}),e.jsx(le,{label:"Industry",required:!0,children:e.jsx("input",{type:"text",placeholder:"e.g., Beauty, Fashion, Food",required:!0,value:i.industry,onChange:u=>o({...i,industry:u.target.value}),className:ta})}),e.jsx(le,{label:"Key contact name",required:!0,children:e.jsx("input",{type:"text",placeholder:"Jane Doe",required:!0,value:i.keyContact,onChange:u=>o({...i,keyContact:u.target.value}),className:ta})}),e.jsx(le,{label:"Contact email",children:e.jsx("input",{type:"email",placeholder:"[email protected]",value:i.contactEmail,onChange:u=>o({...i,contactEmail:u.target.value}),className:ta})}),e.jsx(le,{label:"Contact role",children:e.jsx("input",{type:"text",placeholder:"e.g., CMO",value:i.contactRole,onChange:u=>o({...i,contactRole:u.target.value}),className:ta})}),e.jsx(le,{label:"Status",children:e.jsx("select",{value:i.status,onChange:u=>o({...i,status:u.target.value}),className:ta,children:Object.keys(Ka).map(u=>e.jsx("option",{value:u,children:Ka[u]},u))})})]}),e.jsx(le,{label:"Next action",required:!0,children:e.jsx("input",{type:"text",placeholder:"e.g., Send pitch deck by Friday",required:!0,value:i.nextAction,onChange:u=>o({...i,nextAction:u.target.value}),className:ta})}),e.jsx(le,{label:"Notes",children:e.jsx("textarea",{placeholder:"Research, conversation history, pain points",value:i.notes,onChange:u=>o({...i,notes:u.target.value}),rows:3,className:ta})}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(U,{type:"submit",variant:"primary",children:"Add Company"}),e.jsx(U,{type:"button",variant:"soft",onClick:l,children:"Cancel"})]})]})}function ap({company:s,onSave:l,onCancel:i}){const[o,d]=h.useState(s),u=x=>{x.preventDefault(),l(o)};return e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(le,{label:"Company name",required:!0,children:e.jsx("input",{type:"text",placeholder:"Acme Manufacturing",required:!0,value:o.companyName,onChange:x=>d({...o,companyName:x.target.value}),className:ta})}),e.jsx(le,{label:"Industry",required:!0,children:e.jsx("input",{type:"text",placeholder:"e.g., Beauty, Fashion, Food",required:!0,value:o.industry,onChange:x=>d({...o,industry:x.target.value}),className:ta})}),e.jsx(le,{label:"Key contact name",required:!0,children:e.jsx("input",{type:"text",placeholder:"Jane Doe",required:!0,value:o.keyContact,onChange:x=>d({...o,keyContact:x.target.value}),className:ta})}),e.jsx(le,{label:"Contact email",children:e.jsx("input",{type:"email",placeholder:"[email protected]",value:o.contactEmail||"",onChange:x=>d({...o,contactEmail:x.target.value}),className:ta})}),e.jsx(le,{label:"Contact role",children:e.jsx("input",{type:"text",placeholder:"e.g., CMO",value:o.contactRole||"",onChange:x=>d({...o,contactRole:x.target.value}),className:ta})}),e.jsx(le,{label:"Status",children:e.jsx("select",{value:o.status,onChange:x=>d({...o,status:x.target.value}),className:ta,children:Object.keys(Ka).map(x=>e.jsx("option",{value:x,children:Ka[x]},x))})})]}),e.jsx(le,{label:"Next action",required:!0,children:e.jsx("input",{type:"text",placeholder:"e.g., Send pitch deck by Friday",required:!0,value:o.nextAction,onChange:x=>d({...o,nextAction:x.target.value}),className:ta})}),e.jsx(le,{label:"Notes",children:e.jsx("textarea",{placeholder:"Research, conversation history, pain points",value:o.notes,onChange:x=>d({...o,notes:x.target.value}),rows:3,className:ta})}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(U,{type:"submit",variant:"primary",children:"Save Changes"}),e.jsx(U,{type:"button",variant:"soft",onClick:i,children:"Cancel"})]})]})}const Yo=de,Tr={blue:"bg-sky-50 dark:bg-sky-950/40 text-sky-600 dark:text-sky-400",green:"bg-emerald-50 dark:bg-emerald-950/40 text-emerald-600 dark:text-emerald-400",amber:"bg-amber-50 dark:bg-amber-950/40 text-amber-600 dar
61k:text-amber-400",violet:"bg-primary-50 dark:bg-primary-950/40 text-primary-600 dark:text-primary-400",gray:"bg-gray-100 dark:bg-gray-700/50 text-gray-400 dark:text-gray-500"};function W1({open:s}){return e.jsx("svg",{className:`shrink-0 w-5 h-5 text-gray-400 dark:text-gray-500 transition-transform duration-200 ${s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function um({icon:s,iconClass:l,active:i,title:o,meta:d,badge:u,open:x,onToggle:y,children:p}){const g=l??(i?"bg-emerald-50 dark:bg-emerald-950/40 text-emerald-600 dark:text-emerald-400":"bg-gray-100 dark:bg-gray-700/50 text-gray-400 dark:text-gray-500");return e.jsxs("div",{className:`rounded-2xl bg-white dark:bg-gray-800/80 ring-1 shadow-sm overflow-hidden transition-shadow hover:shadow-md ${i?"ring-emerald-200 dark:ring-emerald-800/60":"ring-gray-200 dark:ring-gray-700/60"}`,children:[e.jsxs("button",{type:"button",onClick:y,"aria-expanded":x,className:"w-full flex items-center gap-3.5 p-4 text-left",children:[e.jsx("div",{className:`shrink-0 w-10 h-10 rounded-xl flex items-center justify-center ${g}`,children:s}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-gray-900 dark:text-gray-100",children:o}),u]}),d&&e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-0.5 truncate",children:d})]}),e.jsx(W1,{open:x})]}),x&&e.jsx("div",{className:"px-4 pb-4 pt-4 border-t border-gray-100 dark:border-gray-700/60",children:p})]})}const sp={stub:{label:"Demo (stub)",description:"Hardcoded sample data for exploring the UI. Automatically used when no real providers are configured.",fieldLabels:{},signupUrl:"",cost:"Free â not real data"},prospeo:{label:"Prospeo",description:"Lead sourcing and enrichment. Finds prospect data and enriches approved leads with verified emails, company info, and contact details. Used only when enrichment is needed, after dedup and existing-data checks.",fieldLabels:{prospeo_api_key:"Prospeo API key",prospeo_base_url:"API base URL (optional)",prospeo_limit:"Per-domain result limit (optional)"},fieldHelp:{prospeo_api_key:"From your Prospeo dashboard, API section. Final key and plan details are still pending; editable here anytime."},signupUrl:"https://prospeo.io",cost:"Paid (credits)"},"web-search":{label:"Web Search + LLM Extraction",description:"Runs Brave Search queries from your profile, then uses a local LLM to pull company and owner details from result pages. Broad coverage, weaker precision on revenue numbers.",fieldLabels:{brave_api_key:"Brave Search API key"},fieldHelp:{brave_api_key:"Create one at api.search.brave.com/app/keys. Free tier: 2,000 queries/month."},signupUrl:"https://api.search.brave.com/app/keys",cost:"Free tier available · $3/1000 queries beyond"},"opencorporates-places":{label:"OpenCorporates + Google Places",description:"Google Places finds businesses by industry + location; OpenCorporates adds legal entity and officer data (proxy for owner age).",fieldLabels:{google_places_api_key:"Google Places API key",opencorporates_api_token:"OpenCorporates API token (optional)"},fieldHelp:{google_places_api_key:"Console: console.cloud.google.com â APIs â Places API (New). First 10K requests/month free.",opencorporates_api_token:"Optional â raises rate limit from 50 to 1000 req/day."},signupUrl:"https://console.cloud.google.com/",cost:"~$0-$30/month for typical campaign volume"},pdl:{label:"People Data Labs",description:"Highest-quality firmographic + person data. Revenue bands, employee counts, founder names/ages. Best for precision revenue targeting.",fieldLabels:{pdl_api_key:"PDL API key"},fieldHelp:{pdl_api_key:"Sign up at peopledatalabs.com. Pay per company/person match."},signupUrl:"https://www.peopledatalabs.com/",cost:"$0.05-$0.10 per matched company + person"},phantombuster:{label:"PhantomBuster (LinkedIn Sales Navigator)",description:"Scrapes LinkedIn Sales Navigator for companies matching your criteria. Slow (1-5 min per run) but rich data.",fieldLabels:{phantombuster_api_key:"PhantomBuster API key",phantombuster_agent_id:"Agent (Phantom) ID",linkedin_
61session_cookie:"LinkedIn li_at session cookie"},fieldHelp:{phantombuster_agent_id:'ID of a configured "LinkedIn Sales Navigator Search Export" Phantom.',linkedin_session_cookie:"Your LinkedIn session cookie - logged-in browser, DevTools > Application > Cookies > li_at."},signupUrl:"https://phantombuster.com/",cost:"$69-$200/month + LinkedIn Sales Navigator subscription"},apollo:{label:"Apollo.io",description:"Strong all-around B2B data: company search by industry, employees, revenue band, plus owner/founder emails. Best practical fit for most use cases.",fieldLabels:{apollo_api_key:"Apollo API key"},fieldHelp:{apollo_api_key:"Settings > Integrations > API in your Apollo dashboard."},signupUrl:"https://app.apollo.io/#/settings/integrations/api",cost:"Free tier: 50 credits/mo. Paid plans from $59/user/mo."},hunter:{label:"Hunter.io",description:"Email finder. Best paired with another discovery provider - point Hunter at a list of domains to fill in owner email addresses.",fieldLabels:{hunter_api_key:"Hunter API key"},fieldHelp:{hunter_api_key:"API key from your Hunter.io dashboard > API."},signupUrl:"https://hunter.io/api-keys",cost:"Free: 50 searches/mo. Paid from $49/mo."},clearbit:{label:"Clearbit (HubSpot Breeze)",description:"Firmographic enrichment - revenue, employees, industry, location. Discovery API requires paid HubSpot plan.",fieldLabels:{clearbit_api_key:"Clearbit API key"},fieldHelp:{clearbit_api_key:"Now part of HubSpot. Find your key under HubSpot > Integrations > Breeze Intelligence."},signupUrl:"https://clearbit.com/",cost:"Paid (HubSpot plan + Breeze add-on)"},crunchbase:{label:"Crunchbase",description:"Best for tech startups, VC-backed companies, funding history. Less coverage of small mom-and-pop businesses.",fieldLabels:{crunchbase_api_key:"Crunchbase API key"},fieldHelp:{crunchbase_api_key:"Requires a Crunchbase Enterprise API plan."},signupUrl:"https://data.crunchbase.com/docs",cost:"Enterprise API plan starts at $29K/yr"},yelp:{label:"Yelp Fusion",description:"Local business discovery with built-in community signals (rating + review count = active local following).",fieldLabels:{yelp_api_key:"Yelp Fusion API key"},fieldHelp:{yelp_api_key:"Create at yelp.com/developers/v3/manage_app."},signupUrl:"https://www.yelp.com/developers/v3/manage_app",cost:"Free up to 5,000 calls/day"},serpapi:{label:"SerpAPI (Google Search)",description:"Same web-search + LLM extraction pipeline as Brave, but uses Google search results. Better for niche queries that lean on Google index.",fieldLabels:{serpapi_api_key:"SerpAPI key"},fieldHelp:{serpapi_api_key:"Find at serpapi.com/dashboard."},signupUrl:"https://serpapi.com/",cost:"Free: 100 searches/mo. Paid from $50/mo."},apify:{label:"Apify",description:"Marketplace of pre-built scrapers (Yellow Pages, Google Maps, LinkedIn, Crunchbase, etc). Pick an actor ID; Fantize launches it with your search terms and pulls back the dataset.",fieldLabels:{apify_api_key:"Apify API token",apify_actor_id:"Actor ID"},fieldHelp:{apify_actor_id:'e.g. "compass~google-maps-scraper" or "drobnikj~linkedin-companies-scraper". Browse at apify.com/store.'},signupUrl:"https://console.apify.com/account#/integrations",cost:"Pay-per-use. Most actors $0.50-$5 per 1,000 results."},zoominfo:{label:"ZoomInfo",description:"Enterprise B2B database. Highest data quality and biggest coverage but requires an enterprise contract. Built for sales teams at SaaS companies.",fieldLabels:{zoominfo_username:"API username",zoominfo_password:"API password",zoominfo_client_id:"Client ID"},fieldHelp:{zoominfo_username:"Provided by your ZoomInfo CSM after API access is enabled on your contract."},signupUrl:"https://www.zoominfo.com/sales/contact-sales",cost:"Enterprise contract, typically $15K+/year minimum"},cognism:{label:"Cognism",description:"Enterprise B2B database, strong in EU + GDPR-compliant data. Alternative to ZoomInfo for European prospects.",fieldLabels:{cognism_api_key:"Cognism API key"},fieldHelp:{cognism_api_key:"Requires a paid Cognism plan with the API add-on enabled."},signupUrl:"https://www.cognism.com/",cost:"Enterprise plan + API add-on"},lusha:{label:"Lusha",description:"Contact and company enrichment. Like Hunter, best as an enrichment layer - point at known domains to fill in firmographic data.",fieldLabels:{lusha_api_key:"Lusha API key"},fieldHelp:{lusha_api_key:"Find under Account > API in your Lusha dashboard."},signupUrl:"https://www.lusha.com/api/",cost:"Free: 5 credits/mo. Paid from $39/mo."}},np=[{key:"providers",label:"Data Providers"},{key:"crm-sync",label:"CRM & Sync"},{key:"social",label:"Social Platforms"},{key:"export",label:"Export"},{key:"usage",label:"Usage & Cost"}],Z1=np.map(s=>s.key),Il=s=>sp[s]?.label??s,Gg={integrations:"crm-sync"};
61function K1(){const[s,l]=h.useState([]),[i,o]=h.useState(!0),[d,u]=h.useState(""),[x,y]=$r(),p=x.get("tab")||"",[g,b]=h.useState(Z1.includes(Gg[p]||p)?Gg[p]||p:"providers");function f(w){b(w),y(w==="providers"?{}:{tab:w},{replace:!0})}h.useEffect(()=>{k()},[]);async function k(){o(!0);try{const{providers:w}=await Eo.providers();l(w)}catch(w){u(w.message)}finally{o(!1)}}return e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(Xe,{title:"Integrations",subtitle:"Every connection Fantize uses â HubSpot and Instantly, data providers, social accounts, exports and usage."}),e.jsx(dn,{label:"Integration sections",items:np,active:g,onChange:f,className:"mb-6"}),d&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"red",children:d})}),g==="providers"&&e.jsx(e.Fragment,{children:i?e.jsx(tt,{label:"Loading providersâ¦"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3",children:s.filter(w=>w.name!=="stub").slice().sort((w,N)=>Number(N.configured)-Number(w.configured)||Il(w.name).localeCompare(Il(N.name),void 0,{sensitivity:"base"})).map(w=>e.jsx(n2,{provider:w,onChange:k},w.name))}),e.jsx("div",{className:"mt-6",children:e.jsxs(Ne,{tone:"blue",children:[e.jsx("span",{className:"font-semibold",children:"Using more than one provider â "}),"By default, the research runner uses every configured provider and merges + dedupes their results. Higher-precision providers (PDL, PhantomBuster) score higher when their data includes revenue and owner age. If none are configured, Fantize falls back to the demo stub."]})})]})}),g==="crm-sync"&&e.jsx(J1,{}),g==="export"&&e.jsx(r2,{}),g==="social"&&e.jsx(o2,{}),g==="usage"&&e.jsx(s2,{})]})}function J1(){const[s,l]=h.useState([]),[i,o]=h.useState(!0),[d,u]=h.useState(""),[x,y]=h.useState(""),p=h.useCallback(async()=>{try{const{providers:b}=await Me.adminProviders();l(b.filter(f=>f.kind==="integration"))}catch(b){u(b.message)}finally{o(!1)}},[]);h.useEffect(()=>{p()},[p]);function g(b){y(b),setTimeout(()=>y(""),3e3)}return i?e.jsx(tt,{label:"Loading CRM integrationsâ¦"}):e.jsxs("div",{className:"space-y-4",children:[d&&e.jsx(Ne,{tone:"red",children:d}),e.jsx(Ne,{tone:"blue",children:"Connect your CRM or email platform and approved leads sync out automatically after review. Keys are stored encrypted, masked after saving, and never shown in logs or exports."}),s.length===0?e.jsx(_e,{children:e.jsx("p",{className:"text-sm text-gray-500",children:"No CRM integrations available yet."})}):e.jsx("div",{className:"space-y-3",children:s.slice().sort((b,f)=>Number(f.configured)-Number(b.configured)).map(b=>e.jsx(e2,{p:b,onSaved:f=>{g(f),p()}},b.name))}),x&&e.jsx("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 bg-gray-900 text-white text-sm px-4 py-2 rounded-xl z-50 shadow-lg",children:x})]})}function e2({p:s,onSaved:l}){const[i,o]=h.useState(s.configured),[d,u]=h.useState({}),[x,y]=h.useState(null),[p,g]=h.useState(!1),b=Object.values(d).some(j=>j.trim()!=="");async function f(){g(!0);try{await Me.saveCredentials(s.name,d),u({}),l(`${s.label||s.name} credentials saved.`)}finally{g(!1)}}async function k(){g(!0);try{y(await Me.testCredentials(s.name))}finally{g(!1)}}async function w(){confirm(`Remove ${s.label||s.name} credentials?`)&&(await Me.deleteCredentials(s.name),l(`${s.label||s.name} credentials removed.`))}const N=s.configured&&s.masked_fields?Object.entries(s.masked_fields).map(([j,T])=>`${j}: ${T}`).join(" · "):void 0;return e.jsxs(um,{active:s.configured,open:i,onToggle:()=>o(j=>!j),icon:e.jsx($e,{name:"integrations",className:"w-5 h-5"}),title:s.label||s.name,meta:i?void 0:s.configured?"Connected":void 0,badge:s.configured?e.jsx(se,{tone:"green",children:"Connected"}):e.jsx(se,{tone:"gray",children:"Not set"}),children:[N&&e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mb-3",children:N}),e.jsx("div",{className:"grid sm:grid-cols-2 gap-3 mb-3",children:s.fields.map(j=>e.jsx(le,{label:j.label,children:e.jsx("input",{type:j.secret?"password":"text",placeholder:j.label,className:Yo,value:d[j.key]||"",onChange:T=>u({...d,[j.key]:T.target.value}),autoComplete:j.secret?"new-password":"off"})},j.key))}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(U,{size:"sm",onClick:f,disabled:p||!b,children:"Save"}),e.jsx(U,{size:"sm",variant:"soft",onClick:k,disabled:p,children:"Test connection"}),s.configured&&e.jsx(U,{size:"sm",variant:"ghost",onClick:w,disabled:p,className:"text-rose-600 hover:bg-rose-50",children:"Remove"}),x&&e.jsx(se,{tone:x.ok?"green":"amber",children:x.message})]})]})}const Gu=s=>
61"$"+(s||0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2});function Su({tone:s,icon:l,value:i,label:o,valueClass:d}){return e.jsxs("div",{className:"flex items-center gap-3.5 rounded-2xl bg-white dark:bg-gray-800/80 ring-1 ring-gray-200 dark:ring-gray-700/60 shadow-sm p-4",children:[e.jsx("div",{className:`shrink-0 w-11 h-11 rounded-xl flex items-center justify-center ${Tr[s]}`,children:l}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:`text-2xl font-semibold leading-none tracking-tight tabular-nums ${d??"text-gray-900 dark:text-gray-100"}`,children:i}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1.5",children:o})]})]})}function t2({label:s,valueLabel:l,pct:i,barClass:o}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-200 font-medium truncate",children:s}),e.jsx("span",{className:"text-gray-500 dark:text-gray-400 tabular-nums shrink-0 ml-2",children:l})]}),e.jsx("div",{className:"h-2 rounded-full bg-gray-100 dark:bg-gray-700/60 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${o}`,style:{width:`${Math.max(i,2)}%`}})})]})}function a2({provider:s,label:l,spend:i,cap:o,recordCap:d,onSave:u}){const[x,y]=h.useState(o!=null?String(o):""),[p,g]=h.useState(!1),[b,f]=h.useState(!1),k=x.trim()===""?null:Number(x),w=k!=null&&(!isFinite(k)||k<0),N=(o??null)!==(k??null),j=o&&o>0?Math.min(i/o*100,100):0,T=j>=100?"bg-rose-500":j>=80?"bg-amber-500":"bg-emerald-500";async function S(){if(!w){g(!0);try{await u(s,k,d),f(!0),setTimeout(()=>f(!1),1500)}finally{g(!1)}}}return e.jsxs("div",{className:"px-3 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1.5",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200 truncate",children:l}),e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500 tabular-nums shrink-0",children:[Gu(i)," spent"]})]}),o!=null&&o>0&&e.jsx("div",{className:"h-1.5 rounded-full bg-gray-100 dark:bg-gray-700/60 overflow-hidden mb-2",children:e.jsx("div",{className:`h-full rounded-full ${T}`,style:{width:`${Math.max(j,2)}%`}})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-[10rem]",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm",children:"$"}),e.jsx("input",{type:"number",min:"0",step:"1",inputMode:"decimal",value:x,onChange:_=>y(_.target.value),onKeyDown:_=>{_.key==="Enter"&&S()},placeholder:"No cap",className:`${Yo} pl-7 py-1.5 text-sm`,"aria-label":`Monthly cost cap for ${l}`})]}),e.jsx(U,{size:"sm",variant:N?"primary":"soft",onClick:S,disabled:p||w||!N,children:p?"Savingâ¦":"Save"}),b&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-emerald-600 dark:text-emerald-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Saved"]})]})]})}function s2(){const[s,l]=h.useState([]),[i,o]=h.useState([]),[d,u]=h.useState(!0),[x,y]=h.useState("");h.useEffect(()=>{Promise.all([Me.usage().then(A=>A.month||[]).catch(()=>[]),Me.usageLimits().then(A=>A.limits||[]).catch(()=>[])]).then(([A,L])=>{l(A),o(L)}).catch(A=>y(A.message)).finally(()=>u(!1))},[]);async function p(A,L,F){await Me.setUsageLimit(A,{monthly_cost_cap:L,monthly_record_cap:F}),o(D=>[...D.filter(pe=>pe.provider!==A),{provider:A,monthly_cost_cap:L,monthly_record_cap:F}])}if(d)return e.jsx(tt,{label:"Loading usage & costâ¦"});const g=s.reduce((A,L)=>A+(L.records||0),0),b=s.reduce((A,L)=>A+(L.cached||0),0),f=s.reduce((A,L)=>A+(L.cost||0),0),k=g+b>0?Math.round(b/(g+b)*100):0,w=s.filter(A=>(A.cost||0)>0).sort((A,L)=>(L.cost||0)-(A.cost||0)),N=Math.max(...w.map(A=>A.cost||0),1e-4),j=s.filter(A=>(A.records||0)+(A.cached||0)>0).sort((A,L)=>(L.records||0)+(L.cached||0)-((A.records||0)+(A.cached||0))),T=A=>s.find(L=>
61L.provider===A)?.cost||0,S=A=>i.find(L=>L.provider===A),z=Array.from(new Set([...s.filter(A=>(A.cost||0)>0).map(A=>A.provider),...i.filter(A=>A.monthly_cost_cap||A.monthly_record_cap).map(A=>A.provider)])).map(A=>({provider:A,label:Il(A),spend:T(A),limit:S(A)})).sort((A,L)=>{const F=(A.limit?.monthly_cost_cap?2:0)+(A.spend>0?1:0);return(L.limit?.monthly_cost_cap?2:0)+(L.spend>0?1:0)-F||A.label.localeCompare(L.label)});return e.jsxs("div",{className:"space-y-5",children:[x&&e.jsx(Ne,{tone:"red",children:x}),e.jsx(Ne,{tone:"blue",children:"Estimated API spend and consumption this month, by provider. Costs are tracked automatically for every connected provider that charges per record or token. Results served from cache are free, so a high cache rate means the cost optimizer is doing its job."}),s.length===0?e.jsx(_e,{children:e.jsxs("div",{className:"py-6 text-center",children:[e.jsx("div",{className:"mx-auto w-11 h-11 rounded-xl bg-emerald-50 dark:bg-emerald-950/40 text-emerald-600 dark:text-emerald-400 flex items-center justify-center mb-3",children:e.jsx($e,{name:"currency",className:"w-5 h-5"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:"No billable usage yet this month"}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:"When a connected provider charges per record or token, the spend and a breakdown will appear here."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsx(Su,{tone:"violet",icon:e.jsx($e,{name:"currency",className:"w-5 h-5"}),value:Gu(f),label:"Estimated cost this month"}),e.jsx(Su,{tone:"amber",icon:e.jsx($e,{name:"integrations",className:"w-5 h-5"}),value:g.toLocaleString(),label:"API records billed"}),e.jsx(Su,{tone:"green",icon:e.jsx($e,{name:"sparkle",className:"w-5 h-5"}),value:b.toLocaleString(),label:`Served from cache · ${k}% free`,valueClass:"text-emerald-600 dark:text-emerald-400"})]}),e.jsxs(_e,{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-4",children:[e.jsx("span",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${Tr.violet}`,children:e.jsx($e,{name:"currency",className:"w-4 h-4"})}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Cost by provider"})]}),w.length===0?e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:"No billable charges yet this month. Cached and free-tier providers don't add cost."}):e.jsx("div",{className:"space-y-3",children:w.map(A=>e.jsx(t2,{label:Il(A.provider),valueLabel:Gu(A.cost),pct:A.cost/N*100,barClass:"bg-gradient-to-r from-primary-500 to-violet-500"},A.provider))})]}),e.jsxs(_e,{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-4",children:[e.jsx("span",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${Tr.amber}`,children:e.jsx($e,{name:"integrations",className:"w-4 h-4"})}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Records: billed vs cached"})]}),e.jsxs("div",{className:"flex items-center gap-4 mb-3 text-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-sm bg-amber-500"})," Billed (API)"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-sm bg-emerald-500"})," Cached (free)"]})]}),e.jsx("div",{className:"space-y-3",children:j.map(A=>{const L=(A.records||0)+(A.cached||0),F=L?A.records/L*100:0,D=L?A.cached/L*100:0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-200 font-medium truncate",children:Il(A.provider)}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 tabular-nums shrink-0 ml-2",children:[(A.records||0).toLocaleString()," billed · ",(A.cached||0).toLocaleString()," cached"]})]}),e.jsxs("div",{className:"flex h-2 rounded-full overflow-hidden bg-gray-100 dark:bg-gray-700/60",children:[e.jsx("div",{className:"h-full bg-amber-500",style:{width:`${F}%`}}),e.jsx("div",{className:"h-full bg-emerald-500",style:{width:`${D}%`}})]})]},A.provider)})})]})]}),e.jsxs(_e,{children:[e.jsx("div",{className:"flex items-center justify-between gap-3 mb-1",children:e.jsxs("h2",{className:"flex items-center gap-2.5 text-lg font-semibold text-gray-900 dark:text-gray-100",children:[e.jsx("span",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${Tr.blue}`,children:e.jsx($e,{name:"analytics",className:"w-4 h-4"})}),"Monthly cost caps"]})}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-3",children:"Providers that are active and incurring costs this month. Set a monthly spend limit per provider; when this month's estimated cost reaches the cap, the bar turns red so you can throttle or pause it. Leave blank for no cap."}),z.length===0?e.jsxs("div",{className:"py-6 text-center",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:"No providers are charging yet this month"}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:"Once a connected provider starts incurring costs, it appears here so you can set a monthly cap."})]}):e.jsx("div",{className:"max-h-96 overflow-y-auto rounded-xl ring-1 ring-gray-100 dark:ring-gray-700/60 divide-y divide-gray-100 dark:divide-gray-700/60",children:z.map(A=>e.jsx(a2,{provider:A.provider,label:A.label,spend:A.spend,cap:A.limit?.monthly_cost_cap??null,recordCap:A.limit?.monthly_record_cap??null,onSave:p},A.provider))})]})]})}function Yg(s){return/key|token|secret|cookie|password/i.test(s)}function n2({provider:s,onChange:l}){const i=sp[s.name]||{label:s.name,description:"",fieldLabels:{},signupUrl:"",cost:""},[o,d]=h.useState(!s.configured),[u,x]=h.useState({}),[y,p]=h.useState(!1),[g,b]=h.useState(!1),[f,k]=h.useState(null),[w,N]=h.useState(""),[j,T]=h.useState(s.configured),S=[...s.requiredFields,...s.optionalFields],_=Object.values(u).some(F=>F.trim().length>0);async function z(){p(!0),N("");try{const F=Object.fromEntries(Object.entries(u).filter(([,D])=>D));if(Object.keys(F).length===0){N("Enter at least one field");return}await xu.save(s.name,F),x({}),d(!1),l()}catch(F){N(F.message)}finally{p(!1)}}async function A(){b(!0),k(null);try{const F=await xu.test(s.name);k(F)}catch(F){k({ok:!1,error:F.message})}finally{b(!1)}}async function L(){if(confirm(`Remove ${i.label} credentials?`))try{await xu.delete(s.name),l()}catch(F){N(F.message)}}return e.jsxs(um,{active:s.configured,open:j,onToggle:()=>T(F=>!F),icon:e.jsx($e,{name:"integrations",className:"w-5 h-5"}),title:i.label,meta:j?void 0:s.configured?`Connected${i.cost?` · ${i.cost}`:""}`:i.cost||void 0,badge:s.configured?e.jsx(se,{tone:"green",children:"Connected"}):e.jsx(se,{tone:"gray",children:"Not configured"}),children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:i.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 flex-wrap",children:[i.cost&&e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:i.cost}),i.signupUrl&&e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>window.open(i.signupUrl,"_blank","noopener noreferrer"),children:"Get credentials â"}),s.updated_at&&e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:["Saved ",Ke(s.updated_at)]})]}),s.configured&&!o&&e.jsxs(e.Fragment,{children:[s.masked_fields&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 mt-4 p-3 bg-gray-50 dark:bg-gray-900/40 rounded-xl text-xs",children:Object.entries(s.masked_fields).map(([F,D])=>e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[i.fieldLabels[F]||F,": "]}),e.jsx("span",{className:"font-mono text-gray-700 dark:text-gray-200",children:D})]},F))}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mt-4",children:[e.jsx(U,{variant:"soft",size:"sm",onClick:A,disabled:g,children:g?"Testingâ¦":"Test Connection"}),e.jsx(U,{variant:"soft",size:"sm",onClick:()=>d(!0),children:"Edit"}),e.jsx(U,{variant:"ghost",size:"sm",onClick:L,className:"text-rose-600 hover:bg-rose-50",children:"Remove"})]})]}),!s.configured&&!o&&e.jsx("div",{className:"mt-4",children:e.jsx(U,{variant:"primary",size:"sm",onClick:()=>d(!0),children:"Connect"})}),f&&e.jsx("div",{className:"mt-3",children:e.jsx(Ne,{tone:f.ok?"green":"red",children:f.ok?`Connection verified â ${f.message||"credentials are working."}`:`Test failed â ${f.error||"check your credentials and try again."}`})}),o&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx(Fe,{children:s.configured?"Update Credentials":"Enter Credentials"}),S.map(F=>{const D=s.requiredFields.includes(F);return e.jsx(le,{label:i.fieldLabels[F]||F,help:i.fieldHelp?.[F],required:D,children:e.jsx("input",{type:Yg(F)?"password":"text",autoComplete:"new-password",value:u[F]||"",onChange:te=>x({...u,[F]:te.target.value}),placeholder:s.masked_fields?.[F]?`Saved: ${s.masked_fields[F]}`:Yg(F)?"Paste key here":"",className:Yo+" font-mono"})},F)}),w&&e.jsx(Ne,{tone:"red",children:w}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(U,{variant:"primary",size:"sm",onClick:z,disabled:y||!_,children:y?"Savingâ¦":"Save"}),e.jsx(U,{variant:"soft",size:"sm",onClick:A,disabled:g,children:g?"Testingâ¦":"Test Connection"}),e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{d(!1),x({}),N("")},children:"Cancel"})]})]})]})}function Pg({icon:s,tone:l,title:i,subtitle:o,action:d}){return e.jsxs("div",{className:"flex items-center gap-3.5 p-4 rounded-2xl bg-white dark:bg-gray-800/80 ring-1 ring-gray-200 dark:ring-gray-700/60 shadow-sm",children:[e.jsx("div",{className:`shrink-0 w-10 h-10 rounded-xl flex items-center justify-center ${Tr[l]}`,children:s}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-semibold text-gray-900 dark:text-gray-100",children:i}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5",children:o})]}),e.jsx("div",{className:"shrink-0",children:d})]})}
61function r2(){const[s,l]=h.useState([]),[i,o]=h.useState([]),[d,u]=h.useState(!0),[x,y]=h.useState(null),[p,g]=h.useState(""),[b,f]=h.useState(""),[k,w]=h.useState(new Set);h.useEffect(()=>{Promise.all([Ba.list({limit:5e3}),Za.list()]).then(([F,D])=>{l(F.contacts),o(D.lists)}).catch(F=>g(F.message)).finally(()=>u(!1))},[]);async function N(){y("all");try{const{contacts:F}=await Ba.list({limit:5e3});Ua(`fantize-contacts-${new Date().toISOString().slice(0,10)}.csv`,Fl(F))}catch(F){g(F.message)}finally{y(null)}}async function j(F){y(F.id);try{const{contacts:D}=await Ba.list({list_id:F.id,limit:5e3});Ua(`fantize-list-${ep(F.name)}.csv`,Fl(D))}catch(D){g(D.message)}finally{y(null)}}async function T(){if(k.size!==0){y("selected");try{const F=i.filter(he=>k.has(he.id)),D=new Map,te=[];for(const he of F){const{contacts:X}=await Ba.list({list_id:he.id,limit:5e3});for(const I of X){const q=(I.email||"").trim().toLowerCase();q?D.has(q)||D.set(q,I):te.push(I)}}const pe=[...D.values(),...te];if(pe.length===0){g("The selected lists have no contacts to export.");return}Ua(`fantize-lists-${k.size}-selected-${new Date().toISOString().slice(0,10)}.csv`,Fl(pe))}catch(F){g(F.message)}finally{y(null)}}}if(d)return e.jsx(tt,{label:"Loading export optionsâ¦"});const S=i.filter(F=>F.name.toLowerCase().includes(b.trim().toLowerCase())),_=S.map(F=>F.id),z=_.length>0&&_.every(F=>k.has(F));function A(F){w(D=>{const te=new Set(D);return te.has(F)?te.delete(F):te.add(F),te})}function L(){w(F=>{const D=new Set(F);return z?_.forEach(te=>D.delete(te)):_.forEach(te=>D.add(te)),D})}return e.jsxs("div",{className:"space-y-5",children:[p&&e.jsx(Ne,{tone:"red",children:p}),e.jsx(Ne,{tone:"blue",children:"Export your contacts and lists as CSV â email, name, company, phone, status, origin, and date added. Import directly into HubSpot, Salesforce, Mailchimp, or any CRM."}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Pg,{tone:"blue",icon:e.jsx($e,{name:"contacts",className:"w-5 h-5"}),title:"All contacts",subtitle:`${s.length.toLocaleString()} contact${s.length!==1?"s":""} · full CSV`,action:e.jsx(U,{variant:"primary",size:"sm",disabled:x==="all"||s.length===0,onClick:N,children:x==="all"?"Exportingâ¦":"Download CSV"})}),e.jsx(Pg,{tone:"amber",icon:e.jsx($e,{name:"search",className:"w-5 h-5"}),title:"Lead search results",subtitle:"Match scores, enrichment, and verification â exported per search run.",action:e.jsx("a",{href:"/dashboard/prospecting/searches",className:"no-underline",children:e.jsx(U,{variant:"soft",size:"sm",children:"Go to Lead Generation â"})})})]}),e.jsxs(_e,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsxs("h2",{className:"flex items-center gap-2.5 text-lg font-semibold text-gray-900 dark:text-gray-100",children:[e.jsx("span",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${Tr.violet}`,children:e.jsx($e,{name:"list",className:"w-4 h-4"})}),"Export by list"]}),e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:[i.length," list",i.length!==1?"s":""]})]}),i.length===0?e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 py-2",children:"No lists yet. Create a list to export its contacts here."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 mb-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-4.35-4.35M17 11a6 6 0 11-12 0 6 6 0 0112 0z"})}),e.jsx("input",{type:"text",value:b,onChange:F=>f(F.target.value),placeholder:"Search listsâ¦",className:`${Yo} pl-9`})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(U,{variant:"soft",size:"sm",onClick:L,disabled:_.length===0,children:z?"Clear all":"Select all"}),e.jsx(U,{variant:"primary",size:"sm",onClick:T,disabled:k.size===0||x==="selected",children:x==="selected"?"Exportingâ¦":`Download selected${k.size?` (${k.size})`:""}`})]})]}),S.length===0?e.jsxs("p",{className:"text-sm text-gray-400 dark:text-gray-500 py-4 text-center",children:["No lists match â",b,"â."]}):e.jsx("div",{className:"max-h-96 overflow-y-auto rounded-xl ring-1 ring-gray-100 dark:ring-gray-700/60 divide-y divide-gray-100 dark:divide-gray-700/60",children:S.map(F=>{const D=k.has(F.id);return e.jsxs("div",{className:`group flex items-center gap-3 px-3 py-2.5 transition-colors ${D?"bg-primary-50/50 dark:bg-primary-950/20":"hover:bg-gray-50 dark:hover:bg-gray-700/30"}`,children:[e.jsx("label",{className:"flex h-11 w-11 -my-2.5 -ml-2.5 shrink-0 items-center justify-center rounded-lg cursor-pointer focus-within:ring-2 focus-within:ring-primary-500",children:e.jsx("input",{type:"checkbox",checked:D,onChange:()=>A(F.id),className:"shrink-0 w-4 h-4 rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500 cursor-pointer","aria-label":`Select ${F.name}`})}),e.jsx("div",{className:"shrink-0 w-8 h-8 rounded-lg bg-gray-100 dark:bg-gray-700/50 text-gray-400 dark:text-gray-500 flex items-center justify-center",children:e.jsx($e,{name:"list",className:"w-4 h-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:F.name}),e.jsxs("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:[(F.contact_count??0).toLocaleStr
61ing()," contact",F.contact_count!==1?"s":""]})]}),e.jsx("button",{type:"button",onClick:()=>j(F),disabled:x===F.id,className:"shrink-0 text-xs font-medium text-primary-600 dark:text-primary-400 hover:text-primary-800 dark:hover:text-primary-300 disabled:opacity-50 px-2 py-1 rounded-lg hover:bg-primary-50 dark:hover:bg-primary-950/30 transition-colors",children:x===F.id?"Exportingâ¦":"CSV"})]},F.id)})}),k.size>0&&e.jsxs("p",{className:"mt-2 text-xs text-gray-400 dark:text-gray-500",children:[k.size," list",k.size!==1?"s":""," selected â combined export de-duplicates contacts by email."]})]})]})]})}const l2=[{key:"linkedin",label:"LinkedIn",color:"#0A66C2",description:"Connect your LinkedIn account to publish updates and articles to your professional network.",path:"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.222 0h.003z"},{key:"instagram",label:"Instagram",color:"#E4405F",description:"Connect your Instagram Business account to publish photos and stories.",path:"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.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"},{key:"facebook",label:"Facebook",color:"#1877F2",description:"Connect your Facebook Page to publish posts and updates to your audience.",path:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"},{key:"google",label:"Google",color:"#4285F4",description:"Connect your Google Business Profile to publish updates directly to Google Search.",path:"M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"},{key:"x",label:"X (Twitter)",color:"#0F172A",description:"Connect your X account to post updates and engage with your audience.",path:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"}];function i2({path:s,color:l}){return e.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",style:{color:l},"aria-hidden":"true",children:e.jsx("path",{d:s})})}function o2(){const[s,l]=h.useState([]),[i,o]=h.useState(!0),[d,u]=h.useState(null),[x,y]=h.useState(null),[p,g]=h.useState(""),b=h.useCallback(async()=>{o(!0);try{const{accounts:N}=await fu.list();l(N)}catch(N){g(N.message)}finally{o(!1)}},[]);h.useEffect(()=>{b()},[b]);async function f(N){u(N),g("");try{const{url:j}=await fu.connect(N);window.open(j,`oauth-${N}`,"width=600,height=700,noopener")}catch(j){g(j.message||`Failed to start ${N} connection.`)}finally{u(null)}}async function k(N){if(window.confirm(`Disconnect ${N.display_name||N.handle} from ${N.platform}?`)){y(N.id);try{await fu.disconnect(N.id),l(j=>j.filter(T=>T.id!==N.id))}catch(j){g(j.message)}finally{y(null)}}}if(i)return e.jsx(tt,{label:"Loading connected accountsâ¦"});const w=l2.map(N=>({platform:N,connected:s.filter(j=>j.platform===N.key)}
61)).sort((N,j)=>+(j.connected.length>0)-+(N.connected.length>0));return e.jsxs("div",{className:"space-y-4",children:[p&&e.jsx(Ne,{tone:"red",children:p}),e.jsx("div",{className:"flex items-center justify-between gap-3",children:e.jsx(Ne,{tone:"blue",children:"Connect social accounts to publish campaign content from Fantize. After connecting, use campaigns to schedule and send posts. OAuth credentials must be set under Data Providers first."})}),e.jsx("div",{className:"flex justify-end -mt-1",children:e.jsx(U,{variant:"soft",size:"sm",onClick:b,children:"Refresh"})}),e.jsx("div",{className:"space-y-3",children:w.map(({platform:N,connected:j})=>e.jsx(c2,{platform:N,connected:j,connecting:d===N.key,disconnecting:x,onConnect:()=>f(N.key),onDisconnect:k},N.key))}),e.jsx(Ne,{tone:"amber",children:"After clicking Connect, complete the OAuth flow in the new tab. Return here and click Refresh to see your connected account. If the Connect button returns an error, OAuth credentials for that platform need to be added first â contact your admin."})]})}function c2({platform:s,connected:l,connecting:i,disconnecting:o,onConnect:d,onDisconnect:u}){const x=l.length>0,[y,p]=h.useState(x);return e.jsxs(um,{active:x,open:y,onToggle:()=>p(g=>!g),icon:e.jsx(i2,{path:s.path,color:s.color}),iconClass:"bg-gray-50 dark:bg-gray-700/50",title:s.label,meta:y?void 0:x?l.map(g=>`@${g.handle}`).join(", "):void 0,badge:x?e.jsx(se,{tone:"green",children:"Connected"}):e.jsx(se,{tone:"gray",children:"Not connected"}),children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s.description}),l.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:l.map(g=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl bg-gray-50 dark:bg-gray-900/40 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:g.display_name||g.handle}),e.jsxs("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:["@",g.handle," · connected ",Ke(g.connected_at)]})]}),e.jsx(U,{variant:"ghost",size:"sm",disabled:o===g.id,onClick:()=>u(g),className:"text-rose-600 hover:bg-rose-50 shrink-0",children:o===g.id?"Disconnectingâ¦":"Disconnect"})]},g.id))}),e.jsx("div",{className:"mt-4",children:e.jsx(U,{variant:x?"soft":"primary",size:"sm",disabled:i,onClick:d,children:i?"Openingâ¦":x?"Connect another account":"Connect"})})]})}function vo(s,l,i=""){if(!(!l||l<=0||s==null))return`${Math.round(s/l*100)}% ${i}`.trim()}function rp({headline:s}){const[l,i]=h.useState(null),o=s!==void 0?s:l;return h.useEffect(()=>{if(s!==void 0)return;let u=!0;return Me.analytics().then(x=>{u&&x?.headline&&i(x.headline)}).catch(()=>{}),()=>{u=!1}},[s]),!(!!o&&Object.values(o).some(u=>(u??0)>0))||!o?null:e.jsxs("section",{"aria-label":"Lead generation metrics at a glance",className:"mb-6 rounded-2xl bg-gray-50/70 dark:bg-gray-800/40 ring-1 ring-gray-100 dark:ring-gray-700/50 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:"At a glance"}),e.jsx(Se,{to:"/dashboard/analytics?tab=leads",className:"text-xs font-medium text-primary-600 hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300",children:"View analytics â"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3",children:[e.jsx(Ct,{label:"Searches run",value:o.searches_run??0}),e.jsx(Ct,{label:"Leads found",value:o.leads_found??0}),e.jsx(Ct,{label:"Viable leads",value:o.viable_leads??0,tone:"blue",sub:vo(o.viable_leads,o.leads_found,"of found")}),e.jsx(Ct,{label:"Strong matches",value:o.strong_matches??0,tone:"featured",sub:vo(o.strong_matches,o.viable_leads,"of viable")}),e.jsx(Ct,{label:"Verified",value:o.verified_contacts??0,tone:"green",sub:vo(o.verified_contacts,o.viable_leads,"of viable")}),e.jsx(Ct,{label:"Saved to CRM",value:o.saved_leads??0,sub:vo(o.saved_leads,o.viable_leads,"of viable")})]})]})}const d2=["boomer","young_boomer","gen_x","millennial","gen_z"],jo=s=>s.split(",").map(l=>
61l.trim()).filter(Boolean),wo=s=>s&&s.length?s.join(", "):"",Cr=s=>s==null?"":String(s);function qo(s){return{name:s?.name??"",description:s?.description??"",revenue_min:Cr(s?.revenue_min),revenue_max:Cr(s?.revenue_max),employee_min:Cr(s?.employee_min),employee_max:Cr(s?.employee_max),owner_age_min:Cr(s?.owner_age_min),owner_age_max:Cr(s?.owner_age_max),owner_generations:s?.owner_generations??[],industries:wo(s?.industries),geo:wo(s?.geo),signals:wo(s?.signals),keywords:wo(s?.keywords),pitch_angle:s?.pitch_angle??""}}function mm(s){const l=i=>i.trim()===""?null:Number(i);return{name:s.name.trim(),description:s.description.trim()||void 0,revenue_min:l(s.revenue_min),revenue_max:l(s.revenue_max),employee_min:l(s.employee_min),employee_max:l(s.employee_max),owner_age_min:l(s.owner_age_min),owner_age_max:l(s.owner_age_max),owner_generations:s.owner_generations,industries:jo(s.industries),geo:jo(s.geo),signals:jo(s.signals),keywords:jo(s.keywords),pitch_angle:s.pitch_angle.trim()||void 0}}function u2(s){const l=[];if(s.industries?.length&&l.push(s.industries.slice(0,3).join(", ")),s.geo?.length&&l.push(s.geo.slice(0,2).join(", ")),s.revenue_min||s.revenue_max){const i=o=>o==null?"":o>=1e6?`$${(o/1e6).toFixed(0)}M`:`$${Math.round(o/1e3)}K`;l.push(`${i(s.revenue_min)||"â"}â${i(s.revenue_max)||"â"}`)}return s.owner_generations?.length&&l.push(s.owner_generations.map(i=>i.replace("_"," ")).join("/")),s.signals?.length&&l.push(`${s.signals.length} signal${s.signals.length===1?"":"s"}`),l.join(" · ")||"Any company (no filters yet)"}const m2=s=>`px-3 py-1 rounded-full text-xs font-medium ring-1 transition ${s?"bg-primary-50 ring-primary-300 text-primary-700 dark:bg-primary-900/40 dark:ring-primary-700 dark:text-primary-300":"bg-white ring-gray-200 text-gray-600 hover:bg-gray-50 dark:bg-gray-800 dark:ring-gray-600 dark:text-gray-400 dark:hover:bg-gray-700"}`;function h2({form:s,setForm:l}){const i=(d,u)=>l({...s,[d]:u}),o=d=>l({...s,owner_generations:s.owner_generations.includes(d)?s.owner_generations.filter(u=>u!==d):[...s.owner_generations,d]});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(le,{label:"Search name",required:!0,children:e.jsx("input",{className:de,value:s.name,onChange:d=>i("name",d.target.value),placeholder:"e.g. Northeast manufacturers, $5â25M"})}),e.jsx(le,{label:"What are you looking for?",help:"Plain-English note to remember this search.",children:e.jsx("textarea",{className:de,rows:2,value:s.description,onChange:d=>i("description",d.target.value),placeholder:"Owner-operated manufacturers ready for growth capital."})}),e.jsx(Go,{}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(le,{label:"Revenue min ($)",children:e.jsx("input",{type:"number",className:de,value:s.revenue_min,onChange:d=>i("revenue_min",d.target.value),placeholder:"1000000"})}),e.jsx(le,{label:"Revenue max ($)",children:e.jsx("input",{type:"number",className:de,value:s.revenue_max,onChange:d=>i("revenue_max",d.target.value),placeholder:"25000000"})}),e.jsx(le,{label:"Employees min",children:e.jsx("input",{type:"number",className:de,value:s.employee_min,onChange:d=>i("employee_min",d.target.value),placeholder:"10"})}),e.jsx(le,{label:"Employees max",children:e.jsx("input",{type:"number",className:de,value:s.employee_max,onChange:d=>i("employee_max",d.target.value),placeholder:"250"})}),e.jsx(le,{label:"Owner age min",children:e.jsx("input",{type:"number",className:de,value:s.owner_age_min,onChange:d=>i("owner_age_min",d.target.value),placeholder:"50"})}),e.jsx(le,{label:"Owner age max",children:e.jsx("input",{type:"number",className:de,value:s.owner_age_max,onChange:d=>i("owner_age_max",d.target.value),placeholder:"72"})})]}),e.jsx(le,{label:"Owner generation",children:e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:d2.map(d=>e.jsx("button",{type:"button",onClick:()=>o(d),className:m2(s.owner_generations.includes(d)),children:d.replace("_"," ")},d))})}),e.jsx(le,{label:"Industries",help:"Comma-separated, e.g. Manufacturing, Distribution",children:e.jsx("input",{className:de,value:s.industries,onChange:d=>i("industries",d.target.value),placeholder:"Manufacturing, Distribution"})}
61),e.jsx(le,{label:"Geography",help:"Comma-separated regions, e.g. Boston MA, Northeast",children:e.jsx("input",{className:de,value:s.geo,onChange:d=>i("geo",d.target.value),placeholder:"Boston MA, Northeast"})}),e.jsx(le,{label:"Signals",help:"Comma-separated, e.g. founder_owned, profitable",children:e.jsx("input",{className:de,value:s.signals,onChange:d=>i("signals",d.target.value),placeholder:"founder_owned, profitable"})}),e.jsx(le,{label:"Keywords",help:"Comma-separated hints for matching.",children:e.jsx("input",{className:de,value:s.keywords,onChange:d=>i("keywords",d.target.value),placeholder:"founder, succession, recurring revenue"})}),e.jsx(le,{label:"Pitch angle",help:"Used when generating outreach copy for matches.",children:e.jsx("input",{className:de,value:s.pitch_angle,onChange:d=>i("pitch_angle",d.target.value),placeholder:"Growth capital for a proven, cash-flowing business."})})]})}function x2({open:s,search:l,onClose:i,onSaved:o,onRun:d,onSchedule:u,onDuplicate:x}){const[y,p]=h.useState(()=>qo(l)),[g,b]=h.useState(l),[f,k]=h.useState(!1),[w,N]=h.useState(""),[j,T]=h.useState(null),[S,_]=h.useState(!1);h.useEffect(()=>{s&&(p(qo(l)),b(l),N(""),T(null))},[s,l]);const z=!!g;async function A(){if(!y.name.trim())return N("Give your search a name."),null;N(""),k(!0);try{const D=mm(y),te=g?await os.update(g.id,D):await os.create(D);return b(te),o(te),te}catch(D){return N(D.message??"Could not save this search."),null}finally{k(!1)}}async function L(){const D=await A();D&&d&&d(D.id)}async function F(){const D=await A();if(D){_(!0);try{T(await Me.preview(D.id))}catch(te){N(te.message??"Preview unavailable.")}finally{_(!1)}}}return e.jsx(Et,{open:s,onClose:i,widthClass:"max-w-2xl",title:z?"Search settings":"New search",footer:e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[z&&x&&e.jsx(U,{variant:"ghost",size:"sm",disabled:f,onClick:()=>x(g),children:"Duplicate"}),z&&u&&e.jsx(U,{variant:"ghost",size:"sm",disabled:f,onClick:()=>u(g),children:"Schedule"}),e.jsx("div",{className:"flex-1"}),e.jsx(U,{variant:"soft",size:"sm",disabled:f,onClick:i,children:"Cancel"}),e.jsx(U,{variant:"ghost",size:"sm",disabled:f,onClick:A,children:f?"Savingâ¦":"Save"}),e.jsx(U,{variant:"primary",size:"sm",disabled:f,onClick:L,children:"Save & Run"})]}),children:e.jsxs("div",{className:"space-y-5",children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 -mt-1",children:z?"Review, edit, preview, then run or schedule.":"Set your criteria, preview matches for free, then run."}),w&&e.jsx(Ne,{tone:"red",children:w}),e.jsx(h2,{form:y,setForm:p}),e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-gray-700 p-4 bg-gray-50/60 dark:bg-gray-800/40",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Preview (no API cost)"}),e.jsx(U,{variant:"soft",size:"sm",disabled:S||f,onClick:F,children:S?"Previewingâ¦":"Preview matches"})]}),j?e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-300 space-y-2",children:[j.summary&&e.jsx("p",{children:j.summary}),Array.isArray(j.signals)&&j.signals.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:j.signals.map(D=>e.jsx(se,{tone:"blue",children:String(D).replace(/_/g," ")},D))}),Array.isArray(j.providers_to_run)&&j.providers_to_run.length>0&&e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Will query: ",j.providers_to_run.join(", ")]}),j.pitch_angle&&e.jsxs("p",{className:"text-xs italic text-gray-500 dark:text-gray-400",children:["â",j.pitch_angle,"â"]})]}):e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"See a plain-English summary of who this search will find before spending any API budget. Saves your edits first."})]})]})})}const g2={searches:{title:"Searches",subtitle:"Your saved lead searches. Review the criteria, then run, duplicate or schedule them."},templates:{title:"Templates",subtitle:"Ready-made starting points. Start a search from one, then adjust the criteria before you run it."},results:{title:"Results",subtitle:"Every search that has run. Open one to review, enrich and save the leads it found."},schedules:{title:"Search Automation",subtitle:"The saved searches that run by themselves, the criteria each one uses, and what its last run produced. New matches are surfaced for review; nothing is exported or contacted automatically."},exclusions:{title:"Exclusions",subtitle:"Domains, emails, companies or profiles kept out of every search in this workspace."}},rs={searches:"/dashboard/prospecting/searches",templates:"/dashboard/prospecting/templates",results:"/dashboard/prospecting/results",schedules:"/dashboard/prospecting/schedules",exclusions:"/dashboard/prospecting/exclusions"};function Dl({section:s}
61){const l=Ya(),[i,o]=h.useState([]),[d,u]=h.useState([]),[x,y]=h.useState([]),[p,g]=h.useState([]),[b,f]=h.useState([]),[k,w]=h.useState(!0),[N,j]=h.useState(""),[T,S]=h.useState(null),[_,z]=h.useState(!1),[A,L]=h.useState(null),[F,D]=h.useState(null),[te,pe]=h.useState(null),[he,X]=h.useState(null);h.useEffect(()=>{I()},[]);async function I(){w(!0);try{const[P,V,ye,ge,qe]=await Promise.all([os.list(),Me.runs().catch(()=>({runs:[]})),Me.schedules().catch(()=>({schedules:[]})),Me.presets().catch(()=>({presets:[],saved_searches:[],message:""})),Me.exclusions().catch(()=>({exclusions:[]}))]);o(P.profiles),u(V.runs),y(ye.schedules),g(ge.presets),f(qe.exclusions||[])}catch(P){j(P.message??"Failed to load your searches.")}finally{w(!1)}}const q=P=>d.filter(V=>V.profile_id===P).sort((V,ye)=>Gt(ye.created_at)-Gt(V.created_at))[0]||null,be=P=>x.find(V=>V.profile_id===P)||null;function ne(){L(null),z(!0)}function M(P){L(P),z(!0)}async function Y(P){S(P),j("");try{const V=await Me.run(P);l(`/dashboard/prospecting/results/${V.run_id}`)}catch(V){j(V.message??"Could not start the search."),S(null)}}async function oe(P){S(P.id);try{const V=mm(qo(P)),ye=await os.create({...V,name:`${P.name} (copy)`});await I(),L(ye),z(!0)}catch(V){j(V.message??"Could not duplicate the search.")}finally{S(null)}}async function Ce(P){S(P.id);try{await os.delete(P.id),o(V=>V.filter(ye=>ye.id!==P.id)),X(null)}catch(V){j(V.message??"Could not delete the search.")}finally{S(null)}}async function Ae(P){S(P.preset_key);try{const{search:V}=await Me.fromPreset(P.preset_key);await I();const ye=(await os.list()).profiles.find(ge=>ge.id===V?.id)||null;L(ye),z(!0)}catch(V){j(V.message??"Could not start a search from this template.")}finally{S(null)}}const H=[{key:"searches",label:"Searches",to:rs.searches,count:i.length},{key:"templates",label:"Templates",to:rs.templates,count:p.length},{key:"results",label:"Results",to:rs.results,count:d.length},{key:"schedules",label:"Schedules",to:rs.schedules,count:x.length},{key:"exclusions",label:"Exclusions",to:rs.exclusions,count:b.length}],Z=g2[s],$=s==="searches"||s==="templates"?e.jsx(U,{variant:"primary",onClick:ne,children:"New search"}):s==="schedules"?e.jsx(U,{variant:"primary",disabled:i.length===0,onClick:()=>D(i[0]??null),title:i.length===0?"Create a search first, then schedule it.":void 0,children:"New schedule"}):void 0,O=s==="templates"?e.jsx(Se,{to:"/dashboard/prospecting/templates/library",children:e.jsx(U,{variant:"soft",children:"Manage template library"})}):void 0;return e.jsxs("div",{className:"max-w-5xl mx-auto pb-12",children:[e.jsx(Xe,{title:Z.title,subtitle:Z.subtitle,action:$,secondary:O}),e.jsx(dn,{label:"Prospecting sections",items:H,active:s,className:"mb-5"}),(s==="searches"||s==="templates")&&e.jsx(rp,{}),N&&e.jsx("div",{className:"my-4",children:e.jsx(Ne,{tone:"red",children:N})}),(s==="searches"||s==="templates")&&!k&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-3",children:"Start a search"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsx(Ha,{icon:e.jsx($e,{name:"sparkle",className:"w-7 h-7"}),title:"Start from scratch",description:"Set your own criteria, preview matches for free, then run.",onClick:ne,tone:"blue"}),e.jsx(Ha,{icon:e.jsx($e,{name:"templates",className:"w-7 h-7"}),title:"Use a template",description:p.length?`${p.length} ready-made starting point${p.length===1?"":"s"}.`:"Launch fast from a ready-made starting point.",href:rs.templates,tone:"purple"}),e.jsx(Ha,{icon:e.jsx($e,{name:"search",className:"w-7 h-7"}),title:"Re-run a saved search",description:i.length?`${i.length} saved search${i.length===1?"":"es"} ready to run again.`:"Your saved searches show up here once you create them.",href:rs.searches,tone:"green"})]})]}),k?e.jsx(tt,{label:"Loading your searchesâ¦"}):s==="searches"?i.length===0?e.jsx(Ze,{title:"No saved searches yet",hint:"A search is a set of criteria you can run again, schedule and turn into a template.",icon:e.jsx($e,{name:"search",className:"w-8 h-8"}),action:e.jsx(U,{variant:"primary",size:"sm",onClick:ne,children:"New search"}),next:{to:rs.templates,label:"Browse templates"}}):e.jsx("div",{className:"flex flex-col gap-3",children:i.map(P=>e.jsx(f2,{search:P,lastRun:q(P.id),schedule:be(P.id),busy:T===P.id,onReview:()=>M(P),onRun:()=>Y(P.id),onDuplicate:()=>
61oe(P),onSaveTemplate:()=>pe(P),onSchedule:()=>D(P),onDelete:()=>X(P)},P.id))}):s==="templates"?e.jsx(p2,{presets:p,busyKey:T,onStart:Ae}):s==="results"?e.jsx(y2,{runs:d,profiles:i}):s==="exclusions"?e.jsx(k2,{exclusions:b,onChanged:I,onError:j}):e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(v2,{onError:j}),e.jsx(b2,{schedules:x,profiles:i,onChanged:I,onError:j,onEdit:P=>{const V=i.find(ye=>ye.id===P.profile_id);V&&D(V)}})]}),e.jsx(x2,{open:_,search:A,onClose:()=>z(!1),onSaved:P=>{L(P),o(V=>{const ye=V.findIndex(qe=>qe.id===P.id);if(ye===-1)return[P,...V];const ge=[...V];return ge[ye]=P,ge})},onRun:P=>{z(!1),Y(P)},onSchedule:P=>{z(!1),D(P)},onDuplicate:P=>{z(!1),oe(P)}}),F&&e.jsx(j2,{search:F,existing:be(F.id),profiles:i,onClose:()=>D(null),onSaved:()=>{D(null),I()},onError:j}),te&&e.jsx(w2,{search:te,onClose:()=>pe(null),onSaved:()=>{pe(null),I()},onError:j}),e.jsx(Pl,{open:!!he,title:he?`Delete â${he.name}â?`:"Delete search?",confirmLabel:"Delete search",danger:!0,busy:!!he&&T===he.id,onCancel:()=>X(null),onConfirm:()=>he&&Ce(he),children:e.jsx("p",{children:"The saved criteria are removed. Past runs and the leads they found are kept and stay listed under Results."})})]})}function f2({search:s,lastRun:l,schedule:i,busy:o,onReview:d,onRun:u,onDuplicate:x,onSaveTemplate:y,onSchedule:p,onDelete:g}){return e.jsx(_e,{children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:d,className:"min-h-11 font-semibold text-gray-900 dark:text-gray-100 hover:text-primary-600 truncate text-left rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:s.name}),i&&e.jsx(se,{tone:i.status==="active"?"green":"gray",children:i.status==="active"?`Scheduled · ${i.cadence}`:"Schedule paused"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:u2(s)}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:l?e.jsxs(Se,{to:`/dashboard/prospecting/results/${l.id}`,className:"hover:underline rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:["Last run ",Ia(l.created_at)," · ",l.strong_matches??0," strong · ",l.viable_count??0," viable"]}):e.jsx("span",{children:"Never run yet"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 shrink-0",children:[e.jsx(U,{variant:"primary",size:"sm",disabled:o,onClick:u,children:o?"Startingâ¦":"Run"}),e.jsx(U,{variant:"soft",size:"sm",onClick:d,children:"Review & edit"}),e.jsx(Vo,{label:`More actions for ${s.name}`,items:[{label:"Schedule",onClick:p},{label:"Duplicate",onClick:x},{label:"Save as template",onClick:y},{label:"Delete",onClick:g,danger:!0}]})]})]})})}function p2({presets:s,busyKey:l,onStart:i}){const[o,d]=h.useState(""),[u,x]=h.useState("all"),[y,p]=h.useState("all"),g=h.useMemo(()=>{const f=new Set;for(const k of s)for(const w of k.criteria?.industries||[])typeof w=="string"&&w&&f.add(w);return Array.from(f).sort()},[s]),b=s.filter(f=>!(u==="system"&&!f.is_system||u==="mine"&&f.is_system||y!=="all"&&!(f.criteria?.industries||[]).includes(y)||o.trim()&&!`${f.name} ${f.description||""} ${f.audience_note||""}`.toLowerCase().includes(o.trim().toLowerCase())));return s.length===0?e.jsx(Ze,{title:"No templates yet",hint:"Templates are reusable starting points for searches. Create one in the template library, or save any search as a template.",icon:e.jsx($e,{name:"templates",className:"w-8 h-8"}),action:e.jsx(Se,{to:"/dashboard/prospecting/templates/library",children:e.jsx(U,{variant:"primary",size:"sm",children:"Create a template"})})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Hn,{search:{value:o,onChange:d,placeholder:"Search templates",label:"Search templates"},summary:`${b.length} of ${s.length} template${s.length===1?"":"s"}`,onClear:o||u!=="all"||y!=="all"?()=>{d(""),x("all"),p("all")}:void 0,children:[e.jsx(ha,{label:"Source",value:u,onChange:f=>x(f),options:[{value:"all",label:"All templates"},{value:"system",label:"Built-in"},{value:"mine",label:"Created here"}]}),g.length>0&&e.jsx(ha,{label:"Industry",value:y,onChange:p,options:[{value:"all",label:"Any industry"},...g.map(f=>({value:f,label:f}))]})]}),b.length===0?e.jsx(Ze,{title:"No templates match these filters",hint:"Clear the filters to
61see every template."}):e.jsx("ul",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:b.map(f=>e.jsx("li",{children:e.jsxs(_e,{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-gray-100 leading-snug",children:f.name}),e.jsx("span",{className:"flex-shrink-0",children:f.is_system?e.jsx(se,{tone:"gray",children:"Built-in"}):e.jsx(se,{tone:"blue",children:"Yours"})})]}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1 flex-1",children:f.audience_note||f.description}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[e.jsx(U,{variant:"soft",size:"sm",disabled:l===f.preset_key,onClick:()=>i(f),children:l===f.preset_key?"Startingâ¦":"Use this template"}),!f.is_system&&e.jsx(Es,{to:"/dashboard/prospecting/templates/library",children:"Edit in library"})]})]})},f.preset_key))})]})}function y2({runs:s,profiles:l}){const[i,o]=h.useState(""),[d,u]=h.useState("all");if(s.length===0)return e.jsx(Ze,{title:"No results yet",hint:"Run a search and the leads it finds appear here.",icon:e.jsx($e,{name:"search",className:"w-8 h-8"}),next:{to:rs.searches,label:"Go to Searches"}});const x=g=>l.find(b=>b.id===g)?.name||"Search",y=Array.from(new Set(s.map(g=>g.status))).sort(),p=[...s].filter(g=>d==="all"||g.status===d).filter(g=>!i.trim()||(g.label||x(g.profile_id)).toLowerCase().includes(i.trim().toLowerCase())).sort((g,b)=>Gt(b.created_at)-Gt(g.created_at));return e.jsxs("div",{className:"space-y-4",children:[s.length>5&&e.jsx(Hn,{search:{value:i,onChange:o,placeholder:"Search results by name",label:"Search results"},summary:`${p.length} of ${s.length} runs`,onClear:i||d!=="all"?()=>{o(""),u("all")}:void 0,children:e.jsx(ha,{label:"Status",value:d,onChange:u,options:[{value:"all",label:"Any status"},...y.map(g=>({value:g,label:g}))]})}),e.jsx("ul",{className:"flex flex-col gap-2",children:p.map(g=>e.jsx("li",{children:e.jsxs(Se,{to:`/dashboard/prospecting/results/${g.id}`,className:"flex items-center justify-between gap-3 px-4 py-3 min-h-11 rounded-xl bg-white dark:bg-gray-800/70 ring-1 ring-gray-200 dark:ring-gray-700 hover:ring-primary-300 transition no-underline focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:g.label||x(g.profile_id)}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:Ia(g.created_at)})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[g.strong_matches??0," strong · ",g.viable_count??0," viable"]}),e.jsx(Bn,{status:g.status})]})]})},g.id))})]})}function b2({schedules:s,profiles:l,onChanged:i,onError:o,onEdit:d}){const u=N=>l.find(j=>j.id===N)?.name||"Search",[x,y]=h.useState(null),[p,g]=h.useState(null),[b,f]=h.useState("all");async function k(N,j){y(j);try{await N(),i()}catch(T){o(T.message??"Action failed.")}finally{y(null)}}const w=s.filter(N=>b==="all"||(b==="active"?N.status==="active":N.status!=="active"));return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ne,{tone:"blue",children:"Scheduled searches are review-first. New matches are surfaced for you to look at; nothing is exported, emailed or added to a campaign without your approval."}),s.length===0?e.jsx(Ze,{title:"No prospecting schedules",hint:l.length?"Schedule a saved search to refresh it weekly or monthly and be told when new matches appear.":"Create a search first, then schedule it.",icon:e.jsx($e,{name:"calendar",className:"w-8 h-8"}),next:l.length?void 0:{to:rs.searches,label:"Go to Searches"}}):e.jsxs(e.Fragment,{children:[s.length>3&&e.jsx(Hn,{summary:`${w.length} of ${s.length} schedules`,children:e.jsx(ha,{label:"State",value:b,onChange:N=>f(N),options:[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}]})}),w.map(N=>e.jsx(_e,{children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-gray-900 dark:text-gray-100 truncate",children:N.label||u(N.profile_id)}),e.jsx(se,{tone:N.status==="active"?"green":"gray",children:N.status==="active"?"Active":"Paused"})]}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:[e.jsx("span",{className:"capitalize",children:N.cadence}),N.next_run_at?` · next ${Ke(N.next_run_at)}`:"",N.last_run_at?` · last ${Ke(N.last_run_at)}`:"",N.notify_on_new?" · emails you on new matches":""]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 shrink-0",children:[N.last_run_id&&e.jsx(Se,{to:`/dashboard/prospecting/results/${N.last_run_id}`,children:e.jsx(U,{variant:"soft",size:"sm",children:"Latest results"})}),e.jsx(U,{variant:"ghost",size:"sm",disabled:x===N.id,onClick:()=>k(()=>Me.updateSchedule(N.id,{status:N.status==="active"?"paused":"active"}),N.id),children:N.status==="active"?"Pause":"Resume"}),e.jsx(Vo,{label:`More actions for ${N.label||u(N.profile_id)}`,items:[{label:"Run now",onClick:()=>k(()=>Me.runScheduleNow(N.id),N.id),disabled:x===N.id},{label:"Edit schedule",onClick:()=>d(N)},{label:"Delete schedule",onClick:()=>g(N),danger:!0}]})]})]})},N.id))]}),e.jsx(Pl,{open:!!p,title:"Delete this schedule?",confirmLabel:"Delete schedule",danger:!0,busy:!!p&&x===p.id,onCancel:()=>g(null),onConfirm:()=>{if(p){const N=p;k(()=>Me.deleteSchedule(N.id),N.id).then(()=>g(null))}},children:e.jsx("p",{children:"The search itself and its past results are kept. Only the automatic refresh stops."})})]})}function v2({onError:s}){const[l,i]=h.useState(null),[o,d]=h.useState(!0),[u,x]=h.useState(null);async function y(){try{i(await Me.automation())}catch(f){s(f.message??"Could not load search automation.")}finally{d(!1)}}h.useEffect(()=>{y()},[]);async function p(f){x(f.profile_id);try{await Me.setAutomation(f.profile_id,{active:!f.runs_automatically,cadence:f.cadence}),await y()}catch(k){s(k.message??"Could not change automation.")}finally{x(null)}}async function g(f){x(f);try{await Me.setAutomation(f,{active:!0,cadence:"weekly"}),await y()}catch(k){s(k.message??"Could not turn automation on.")}finally{x(null)}}if(o)return e.jsx(_e,{children:e.jsx(tt,{})});if(!l)return null;const b=l.automated.filter(f=>f.runs_automatically);return e.jsxs("div",{className:"flex flex-col gap-3",children:[l.discovery_note&&e.jsxs(Ne,{tone:"amber",children:[l.discovery_note," Add a discovery provider on the Integrations page before treating any result here as a real lead."]}),l.sample_only.length>0&&e.jsxs(Ne,{tone:"amber",children:[l.sample_only.length===1?"One automated search returned sample data: ":`${l.sample_only.length} automated searches returned sample data: `,l.sample_only.map(f=>f.name).join(", "),". These are demo rows, not real leads."]}),l.failures.length>0&&e.jsxs(Ne,{tone:"amber",children:[l.failures.length===1?"One automated search failed on its last run: ":`${l.failures.length} automated searches failed on their last run: `,l.failures.map(f=>f.name).join(", "),". The error is shown on the search below."]}),e.jsxs(_e,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-gray-900 dark:text-gray-100",children:"Active automated searches"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:l.message})]}),e.jsxs(se,{tone:b.length?"green":"gray",children:[b.length," running automatically"]})]}),l.automated.length===0?e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-3",children:"No saved search runs automatically yet. Turn one on below and it will run on its own criteria, on its own schedule."}):e.jsx("div",{className:"mt-3 flex flex-col divide-y divide-gray-200 dark:divide-gray-700",children:l.automated.map(f=>e.jsxs("div",{className:"py-3 flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:f.name}),e.jsx(se,{tone:f.runs_automatically?"green":"gray",children:f.runs_automatically?"Automatic":"Paused"}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 capitalize",children:f.cadence}),f.last_status==="failed"&&e.jsx(se,{tone:"red",children:"Last run failed"}),(f.last_status==="sample_only"||f.data_source==="sample")&&e.jsx(se,{tone:"amber",children:"Sample data, not real leads"}),e.jsx("span",{className:"grow"}),e.jsx(U,{variant:"ghost",size:"sm",disabled:u===f.profile_id,onClick:()=>p(f),children:f.runs_automatically?"Turn off":"Turn on"}),f.last_run_id&&e.jsx(Se,{to:`/dashboard/prospecting/results/${f.last_run_id}`,children:e.jsx(U,{variant:"soft",size:"sm",children:"Latest results"})})]}),e.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:["Searches for: ",f.criteria_summary]}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[f.last_run_at?`Last run ${Ia(f.last_run_at)}`:"Not run yet",f.next_run_at?` · next ${Ke(f.next_run_at)}`:"",f.totals.runs?` · ${f.totals.runs} runs`:"",f.totals.failed_runs?` · ${f.totals.failed_runs} failed`:""]}),f.totals.runs>0&&e.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:["Last run: ",f.last.results," results · ",f.last.new_leads," new · ",f.last.duplicates," duplicates · ",f.last.qualified," qualified · ",f.last.needs_review," needs review · ",f.last.rejected," rejected"]}),f.last_error&&e.jsxs("div",{className:"text-xs text-red-600 dark:text-red-400",children:["Error: ",f.last_error]})]},f.schedule_id))}),l.not_automated.length>0&&e.jsxs("div",{className:"mt-4 border-t border-gray-200 dark:border-gray-700 pt-3",children:[e.jsx("div",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200 mb-2",children:"Saved searches not automated yet"}),e.jsx("div",{className:"flex flex-col gap-2",children:l.not_automated.map(f=>e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm text-gray-900 dark:text-gray-100",children:f.name}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:f.criteria_summary}),e.jsx("span",{className:"grow"}),e.jsx(U,{variant:"ghost",size:"sm",disabled:u===f.profile_id,onClick:()=>g(f.profile_id),children:"Run automatically"})]},f.profile_id))})]})]}),l.multi_profile_leads.length>0&&e.jsxs(_e,{children:[e.jsx("div",{className:"font-semibold text-gray-900 dark:text-gray-100",children:"Leads found by more than one search"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"One lead, every search that found it. This is why the lead was found; it is not its qualification status."}),e.jsx("div",{className:"mt-3 flex flex-col divide-y divide-gray-200 dark:divide-gray-700",children:l.multi_profile_leads.map(f=>e.jsxs("div",{className:"py-2",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:f.company_name||f.dedupe_key}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[f.matched_profiles.map(k=>e.jsx(se,{tone:"blue",children:k.profile_name||"Search"},k.profile_id)),f.qual_status&&e.jsx(se,{tone:"gray",children:f.qual_status})]})]},f.dedupe_key))})]})]})}function j2({search:s,existing:l,profiles:i,onClose:o,onSaved:d,onError:u}){const[x,y]=h.useState(s.id),[p,g]=h.useState(l?.cadence||"weekly"),[b,f]=h.useState(l?.custom_date||""),[k,w]=h.useState(l?!!l.notify_on_new:!0),[N,j]=h.useState(l?.label||""),[T,S]=h.useState(!1);async function _(){S(!0);try{const z={profile_id:x,cadence:p,custom_date:p==="custom"?b:void 0,notify_on_new:k,label:N.trim()||void 0};l?await Me.updateSchedule(l.id,z):await Me.createSchedule(z),d()}catch(z){u(z.message??"Could not save the schedule."),S(!1)}}return e.jsx(Et,{open:!0,onClose:o,title:l?"Edit schedule":"Schedule this search",footer
61:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(U,{variant:"soft",onClick:o,disabled:T,children:"Cancel"}),e.jsx(U,{variant:"primary",onClick:_,disabled:T,children:T?"Savingâ¦":l?"Save":"Create schedule"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(le,{label:"Search",children:e.jsx("select",{className:de,value:x,onChange:z=>y(z.target.value),disabled:!!l,children:i.map(z=>e.jsx("option",{value:z.id,children:z.name},z.id))})}),e.jsx(le,{label:"Label",help:"Optional name for this schedule.",children:e.jsx("input",{className:de,value:N,onChange:z=>j(z.target.value),placeholder:"Weekly refresh"})}),e.jsx(le,{label:"Cadence",children:e.jsxs("select",{className:de,value:p,onChange:z=>g(z.target.value),children:[e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"}),e.jsx("option",{value:"custom",children:"One-time on a date"})]})}),p==="custom"&&e.jsx(le,{label:"Run date",children:e.jsx("input",{type:"date",className:de,value:b,onChange:z=>f(z.target.value)})}),e.jsxs("label",{className:"flex items-center gap-2 min-h-11 text-sm text-gray-600 dark:text-gray-300 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:k,onChange:z=>w(z.target.checked),className:"h-5 w-5 rounded border-gray-300 text-primary-600 focus:ring-primary-500"}),"Email me when new matches appear"]})]})})}function w2({search:s,onClose:l,onSaved:i,onError:o}){const[d,u]=h.useState(`${s.name} template`),[x,y]=h.useState(s.description||""),[p,g]=h.useState(!1);async function b(){if(d.trim()){g(!0);try{const f=mm(qo(s));await Me.createPreset({name:d.trim(),audience_note:x.trim()||void 0,criteria:{revenue_min:f.revenue_min,revenue_max:f.revenue_max,employee_min:f.employee_min,employee_max:f.employee_max,owner_age_min:f.owner_age_min,owner_age_max:f.owner_age_max,owner_generations:f.owner_generations,industries:f.industries,geo:f.geo,signals:f.signals,keywords:f.keywords,pitch_angle:f.pitch_angle}}),i()}catch(f){o(f.message??"Could not save as template."),g(!1)}}}return e.jsx(Et,{open:!0,onClose:l,title:"Save as template",footer:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(U,{variant:"soft",onClick:l,disabled:p,children:"Cancel"}),e.jsx(U,{variant:"primary",onClick:b,disabled:p||!d.trim(),children:p?"Savingâ¦":"Save template"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Turn this search's criteria into a reusable template you can start future searches from."}),e.jsx(le,{label:"Template name",required:!0,children:e.jsx("input",{className:de,value:d,onChange:f=>u(f.target.value)})}),e.jsx(le,{label:"Audience note",help:"One-line summary shown on the template card.",children:e.jsx("input",{className:de,value:x,onChange:f=>y(f.target.value)})})]})})}function k2({exclusions:s,onChanged:l,onError:i}){const[o,d]=h.useState("domain"),[u,x]=h.useState(""),[y,p]=h.useState(""),[g,b]=h.useState(!1),[f,k]=h.useState(null),[w,N]=h.useState("");async function j(){if(u.trim()){b(!0);try{await Me.addExclusion(o,u.trim(),y.trim()||void 0),x(""),p(""),l()}catch(_){i(_.message??"Could not add exclusion.")}finally{b(!1)}}}async function T(_){b(!0);try{await Me.deleteExclusion(_),l(),k(null)}catch(z){i(z.message??"Could not remove exclusion.")}finally{b(!1)}}const S=s.filter(_=>!w.trim()||`${_.type} ${_.value} ${_.reason||""}`.toLowerCase().includes(w.trim().toLowerCase()));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(_e,{children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Block from all searches"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-3",children:"Anything you block here is filtered out of every search's results, across the whole workspace."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("label",{className:"sm:max-w-[10rem] w-full",children:[e.jsx("span",{className:"sr-only",children:"Type"}),e.jsxs("select",{className:de,value:o,onChange:_=>d(_.target.value),children:[e.jsx("option",{value:"domain",children:"Domain"}),e.jsx("option",{value:"email",children:"Email"}),e.jsx("option",{value:"company",children:"Company"}),e.jsx("option",{value:"linkedin",children:"LinkedIn"})]})]}),e.jsxs("label",{className:"w-full",children:[e.jsx("span",{className:"sr-only",children:"Value to block"}),e.jsx("input",{className:de,value:u,onChange:_=>x(_.target.value),placeholder:o==="domain"?"competitor.com":o==="email"?"[email protected]":o==="company"?"Acme Inc":"linkedin.com/company/acme"})]}),e.jsxs("label",{className:"w-full",children:[e.jsx("span",{className:"sr-only",children:"Reason"}),e.jsx("input",{className:de,value:y,onChange:_=>p(_.target.value),placeholder:"Reason (optional)"})]}),e.jsx(U,{variant:"primary",size:"sm",disabled:g||!u.trim(),onClick:j,children:"Block"})]})]}),s.length===0?e.jsx(Ze,{title:"No exclusions",hint:"Block a domain, email, company or LinkedIn URL to keep it out of every search.",doing:"Every search currently runs without a blocklist.",icon:e.jsx($e,{name:"search",className:"w-8 h-8"})}):e.jsxs(e.Fragment,{children:[s.length>8&&e.jsx(Hn,{search:{value:w,onChange:N,placeholder:"Search exclusions",label:"Search exclusions"},summary:`${S.length} of ${s.length}`}),e.jsx("ul",{className:"flex flex-col gap-2",children:S.map(_=>e.jsxs("li",{className:"flex items-center justify-between gap-3 px-4 py-2 rounded-xl bg-white dark:bg-gray-800/70 ring-1 ring-gray-200 dark:ring-gray-700",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{tone:"gray",children:_.type}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:_.value})]}),e.jsxs("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-0.5",children:[_.reason?`${_.reason} · `:"",_.created_at?`added ${Ke(_.created_at)}`:""]})]}),e.jsx(U,{variant:"ghost",size:"sm",disabled:g,onClick:()=>k(_),children:"Remove"})]},_.id))})]}),e.jsx(Pl,{open:!!f,title:f?`Stop blocking ${f.value}?`:"Remove exclusion?",confirmLabel:"Remove exclusion",danger:!0,busy:g,onCancel:()=>k(null),onConfirm:()=>f&&T(f.id),children:e.jsxs("p",{children:["Future searches may include this ",f?.type||"entry"," again. Existing results are not changed."]})})]})}const Nt=de,lp=["boomer","young_boomer","gen_x","millennial"],N2=["Reg CF","Reg D","Reg A","Broker-Dealer"],_2=s=>Ia(s,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});function S2(){const s=Ya(),[l,i]=h.useState(!0),[o,d]=h.useState([]),[u,x]=h.useState([]),[y,p]=h.useState([]),[g,b]=h.useState(null),[f,k]=h.useState(null),[w,N]=h.useState("presets"),[j,T]=h.useState(!1),[S,_]=h.useState(""),[z,A]=h.useState(""),[L,F]=h.useState("all"),[D,te]=h.useState(""),[pe,he]=h.useState(""),[X,I]=h.useState("az"),[q,be]=h.useState(null),[ne,M]=h.useState(!1),[Y,oe]=h.useState(null),[Ce,Ae]=h.useState(null);h.useEffect(()=>{H()},[]);async function H(){i(!0);try{const[C,ve,Oe]=await Promise.all([Me.presets(),Me.runs(),Me.analytics().catch(()=>null)]);d(C.presets),x(C.saved_searches),p(ve.runs),Oe?.headline&&b(Oe.headline)}catch(C){_(C.message??"Failed to load lead workspace.")}finally{i(!1)}}async function Z(C){k(C),_("");try{const{search:ve}=await Me.fromPreset(C),{run_id:Oe}=await Me.run(ve.id);s(`/dashboard/prospecting/results/${Oe}`)}catch(ve){_(ve.message??"Search failed to start."),k(null)}}async function $(C){k(C.id),_("");try{const{run_id:ve}=await Me.run(C.id);s(`/dashboard/prospecting/results/${ve}`)}catch(ve){_(ve.message??"Search failed to start."),k(null)}}async function O(C){T(!1);try{const{run_id:ve}=await Me.run(C);s(`/dashboard/prospecting/results/${ve}`)}catch(ve){_(ve.message??"Could not start the search run.")}}async function P(){try{const C=await Me.presets();d(C.presets),x(C.saved_searches)}catch(C){_(C.message??"Failed to refresh presets.")}}function V(){be(null),M(!0)}function ye(C){be(C),M(!0)}async function ge(C){Ae(C.preset_key),_("");try{await Me.duplicatePreset(C.preset_key),await P()}catch(ve){_(ve.message??"Could not duplicate the preset.")}finally{Ae(null)}}async function qe(C){Ae(C.preset_key),_("");try{await Me.removePreset(C.preset_key),oe(null),await P()}catch(ve){_(ve.message??"Could not delete the preset.")}finally{Ae(null)}}async function nt(C,ve){ve&&ve.is_mine?await Me.editPreset(ve.preset_key,C):await Me.createPreset(C),M(!1),await P()}if(l)return e.jsx(tt,{label:"Loading your lead workspaceâ¦"});const R=y.length>0,we=o.filter(C=>C.is_mine).length,ie=Array.from(new Set(o.flatMap(C=>C.criteria?.reg_fit??[]))).sort((C,ve)=>C.localeCompare(ve)),Ee=Array.from(new Set(o.flatMap(C=>C.criteria?.industries??[]))).sort((C,ve)=>C.localeCompare(ve)),Je=z.trim().toLowerCase(),me=o.filter(C=>L==="mine"?C.is_mine:L==="system"?C.is_system:!0).filter(C=>!D||(C.criteria?.reg_fit??[]).includes(D)).filter(C=>!pe||(C.criteria?.industries??[]).includes(pe)).filter(C=>Je?[C.name,C.audience_note,C.description,...C.criteria?.keywords??[],...C.criteria?.signals??[],...C.criteria?.reg_fit??[],...C.criteria?.industries??[]].filter(
61Boolean).join(" ").toLowerCase().includes(Je):!0).sort((C,ve)=>{if(X==="updated")return Gt(ve.updated_at)-Gt(C.updated_at);const Oe=C.name.localeCompare(ve.name,void 0,{sensitivity:"base"});return X==="za"?-Oe:Oe}),ke=!!Je||L!=="all"||!!D||!!pe;function ze(){A(""),F("all"),te(""),he("")}return e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(Xe,{title:"Template Library",subtitle:"Create, edit, duplicate and organise the search templates this workspace starts from. Run, edit and schedule searches under Searches.",action:e.jsx(U,{variant:"primary",size:"sm",onClick:()=>T(!0),children:"Start new search"}),secondary:e.jsx(Se,{to:"/dashboard/prospecting/templates",children:e.jsx(U,{variant:"soft",size:"sm",children:"Back to Templates"})})}),e.jsx(rp,{headline:g}),S&&e.jsx("div",{className:"mb-5",children:e.jsx(Ne,{tone:"red",children:S})}),R?e.jsxs("section",{className:"mb-6",children:[e.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500 mb-3",children:"Quick actions"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsx(Ha,{icon:e.jsx($e,{name:"search",className:"w-7 h-7"}),title:"New Search",description:"Custom criteria or choose a preset.",onClick:()=>T(!0),tone:"purple"}),e.jsx(Ha,{icon:e.jsx($e,{name:"calendar",className:"w-7 h-7"}),title:"Schedule Auto-Refresh",description:"Refresh a search weekly or monthly.",href:"/dashboard/prospecting/schedules",tone:"green"}),e.jsx(Ha,{icon:e.jsx($e,{name:"analytics",className:"w-7 h-7"}),title:"View Analytics",description:"Track lead quality and cost over time.",href:"/dashboard/analytics?tab=leads",tone:"blue"})]})]}):e.jsxs("section",{className:"mb-6",children:[e.jsx(Fe,{children:e.jsx(Zf,{children:"Get started in one click"})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(Ha,{icon:e.jsx($e,{name:"search",className:"w-7 h-7"}),title:"Start New Search",description:"Run a targeted search with a preset or custom criteria.",onClick:()=>T(!0),tone:"purple"}),e.jsx(Ha,{icon:e.jsx($e,{name:"bookmark",className:"w-7 h-7"}),title:"Use Saved Preset",description:"One click to run a proven search template you've already saved.",onClick:()=>N("presets"),tone:"blue"}),e.jsx(Ha,{icon:e.jsx($e,{name:"calendar",className:"w-7 h-7"}),title:"Schedule Auto-Refresh",description:"Set a saved search to run weekly or monthly automatically.",href:"/dashboard/prospecting/schedules",tone:"green"})]})]}),e.jsx(Go,{}),w==="presets"&&e.jsxs("div",{children:[o.length>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center gap-2 mb-4",children:[e.jsxs("div",{className:"relative flex-1 min-w-[12rem]",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none",children:e.jsx($e,{name:"search",className:"w-4 h-4"})}),e.jsx("input",{value:z,onChange:C=>A(C.target.value),placeholder:"Search presetsâ¦","aria-label":"Search presets",className:`${Nt} pl-9 h-9 text-sm`})]}),e.jsxs("select",{value:L,onChange:C=>F(C.target.value),"aria-label":"Filter by owner",className:`${Nt} h-9 text-sm sm:w-44`,children:[e.jsxs("option",{value:"all",children:["All presets (",o.length,")"]}),e.jsxs("option",{value:"mine",children:["My presets (",we,")"]}),e.jsxs("option",{value:"system",children:["System (",o.length-we,")"]})]}),Ee.length>0&&e.jsxs("select",{value:pe,onChange:C=>he(C.target.value),"aria-label":"Filter by industry",className:`${Nt} h-9 text-sm sm:w-44`,children:[e.jsx("option",{value:"",children:"Any industry"}),Ee.map(C=>e.jsx("option",{value:C,children:C},C))]}),ie.length>0&&e.jsxs("select",{value:D,onChange:C=>te(C.target.value),"aria-label":"Filter by regulatory fit",className:`${Nt} h-9 text-sm sm:w-40`,children:[e.jsx("option",{value:"",children:"Any reg fit"}),ie.map(C=>e.jsx("option",{value:C,children:C},C))]}),e.jsxs("select",{value:X,onChange:C=>I(C.target.value),"aria-label":"Sort presets",className:`${Nt} h-9 text-sm sm:w-40`,children:[e.jsx("option",{value:"az",children:"Name (AâZ)"}),e.jsx("option",{value:"za",children:"Name (ZâA)"}),e.jsx("option",{value:"updated",children:"Recently updated"})]}),e.jsx(U,{size:"sm",variant:"primary",onClick:V,className:"shrink-0",children:"+ New Preset"})]}),o.length===0?e.jsx(Ze,{icon:e.jsx($e,{name:"bookmark",className:"w-7 h-7"}),title:"No presets yet",hint:"Create a reusable search preset to run targeted lead searches in one click.",action:e.jsx(U,{onClick:V,children:"+ New Preset"})}):me.length===0?e.jsx(Ze,{icon:e.jsx($e,{name:"search",className:"w-7 h-7"}),title:"No presets match your filters",hint:"Try a different search term or clear the filters.",action:e.jsx(U,{variant:"soft",onClick:ze,children:"Clear filters"})}):e.jsxs(e.Fragment,{children:[ke&&e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsxs("p",{className:"text-xs text-gray-400",children:["Showing ",me.length," of ",o.length," presets"]}
61),e.jsx("button",{type:"button",onClick:ze,className:"text-xs text-gray-400 hover:text-primary-600 dark:hover:text-primary-400 underline-offset-2 hover:underline transition-colors",children:"Clear filters"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:me.map(C=>{const ve=C.criteria?.reg_fit??[],Oe=Ce===C.preset_key;return e.jsxs(_e,{className:"flex flex-col hover:shadow-md hover:ring-gray-300 dark:hover:ring-gray-600 transition-shadow",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-gray-100",children:C.name}),e.jsx(se,{tone:C.is_mine?"green":"gray",children:C.is_mine?"Custom":"System"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:C.audience_note||C.description}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-3",children:[ve.slice(0,5).map(dt=>e.jsx(se,{tone:"blue",children:dt},dt)),ve.length>5&&e.jsxs(se,{tone:"gray",children:["+",ve.length-5," more"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-3 text-xs",children:[C.is_mine&&e.jsx("button",{type:"button",onClick:()=>ye(C),className:"text-gray-500 hover:text-primary-600 dark:text-gray-400 dark:hover:text-primary-400 transition-colors",children:"Edit"}),e.jsx("button",{type:"button",disabled:Oe,onClick:()=>ge(C),className:"inline-flex min-h-11 items-center rounded-lg px-2 -mx-2 text-gray-500 hover:text-primary-600 dark:text-gray-400 dark:hover:text-primary-400 transition-colors disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:"Duplicate"}),C.is_mine&&e.jsx("button",{type:"button",disabled:Oe,onClick:()=>oe(C),className:"text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors disabled:opacity-50",children:"Delete"})]}),e.jsxs("div",{className:"flex items-center justify-between mt-3 pt-3 border-t border-gray-100 dark:border-gray-700",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-emerald-600 font-medium",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500","aria-hidden":!0}),"Ready to run"]}),e.jsx(U,{size:"sm",disabled:f===C.preset_key,onClick:()=>Z(C.preset_key),children:f===C.preset_key?"Startingâ¦":"Run Search"})]})]},C.preset_key)})})]})]}),w==="saved"&&e.jsx("div",{children:u.length===0?e.jsx(Ze,{icon:e.jsx($e,{name:"bookmark",className:"w-7 h-7"}),title:"No saved searches yet",hint:"Run a preset to save one, or build a custom search below.",action:e.jsx(U,{onClick:()=>T(!0),children:"New Custom Search"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2 mb-5",children:u.map(C=>e.jsxs(_e,{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 truncate",children:C.name}),C.preset_key&&e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["from preset: ",C.preset_key]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[C.last_run_id&&e.jsx(Se,{to:`/dashboard/prospecting/results/${C.last_run_id}`,children:e.jsx(U,{size:"sm",variant:"ghost",children:"Last Results"})}),e.jsx(U,{size:"sm",variant:"soft",disabled:f===C.id,onClick:()=>$(C),children:f===C.id?"â¦":"Run"})]})]},C.id))}),e.jsx(U,{variant:"soft",onClick:()=>T(!0),children:"+ New Custom Search"})]})}),w==="recent"&&e.jsx("div",{children:y.length===0?e.jsx(Ze,{icon:e.jsx($e,{name:"clock",className:"w-8 h-8"}),title:"No searches run yet",hint:"Run a preset or start a custom search to see results here."}):e.jsx("div",{className:"space-y-2",children:[...y].sort((C,ve)=>Gt(ve.created_at)-Gt(C.created_at)).map(C=>e.jsxs(_e,{onClick:()=>s(`/dashboard/prospecting/results/${C.id}`),className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 truncate",children:C.label||"Search"}),e.jsx("div",{className:"text-xs text-gray-400 mt-0.5",children:_2(C.created_at)})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:C.status==="running"?e.jsxs("span",{className:"flex items-center gap-1.5 text-amber-600 text-xs font-medium",children:[e.jsxs("svg",{className:"animate-spin w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),"Running"]}):e.jsxs(e.Fragment,{children:[e.jsxs(se,{tone:"green",children:[C.strong_matches??0," strong"]}),e.jsxs(se,{tone:"blue",children:[C.viable_count??0," viable"]})]})})]},C.id))})}),e.jsx(C2,{open:j,onClose:()=>T(!1),onCreated:O}),e.jsx(A2,{open:ne,preset:q,onClose:()=>M(!1),onSave:nt}),e.jsx(Et,{open:!!Y,onClose:()=>oe(null),title:"Delete preset?",footer:e.jsxs(e.Fragment,{children:[e.jsx(U,{variant:"ghost",onClick:()=>oe(null),children:"Cancel"}),e.jsx(U,{variant:"danger",disabled:!!Ce,onClick:()=>Y&&qe(Y),children:Ce?"Deletingâ¦":"Delete preset"})]}),children:e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:["This permanently removes ",e.jsx("span",{className:"font-semibold",children:Y?.name}),". Saved searches and past runs created from it are unaffected."]})})]})}function C2({open:s,onClose:l,onCreated:i}){const[o,d]=h.useState({name:"Custom search",revenue_min:"1000000",revenue_max:"25000000",industries:"",geo:"",owner_generations:[],signals:""}),[u,x]=h.useState(!1),[y,p]=h.useState("");function g(w,N){d(j=>({...j,[w]:N}))}function b(w){d(N=>
61({...N,owner_generations:N.owner_generations.includes(w)?N.owner_generations.filter(j=>j!==w):[...N.owner_generations,w]}))}function f(w){return w.split(",").map(N=>N.trim()).filter(Boolean)}async function k(){if(!o.name.trim()){p("Search name is required.");return}p(""),x(!0);try{const{search:w}=await Me.createSearch({name:o.name.trim(),revenue_min:o.revenue_min?Number(o.revenue_min):null,revenue_max:o.revenue_max?Number(o.revenue_max):null,industries:f(o.industries),geo:f(o.geo),owner_generations:o.owner_generations,signals:f(o.signals)});i(w.id)}catch(w){p(w.message??"Failed to create search."),x(!1)}}return e.jsx(Et,{open:s,onClose:l,title:"Start a Custom Search",footer:e.jsxs(e.Fragment,{children:[e.jsx(U,{variant:"ghost",onClick:l,disabled:u,children:"Cancel"}),e.jsx(U,{onClick:k,disabled:u,children:u?"Startingâ¦":"Preview & Run"})]}),children:e.jsxs("div",{className:"space-y-4",children:[y&&e.jsx(Ne,{tone:"red",children:y}),e.jsx(le,{label:"Search Name",required:!0,children:e.jsx("input",{className:Nt,value:o.name,onChange:w=>g("name",w.target.value),placeholder:"My custom search"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(le,{label:"Revenue Min ($)",children:e.jsx("input",{type:"number",className:Nt,value:o.revenue_min,onChange:w=>g("revenue_min",w.target.value),placeholder:"1000000"})}),e.jsx(le,{label:"Revenue Max ($)",children:e.jsx("input",{type:"number",className:Nt,value:o.revenue_max,onChange:w=>g("revenue_max",w.target.value),placeholder:"25000000"})})]}),e.jsx(le,{label:"Industries",help:"Comma-separated, e.g. Manufacturing, Distribution",children:e.jsx("input",{className:Nt,value:o.industries,onChange:w=>g("industries",w.target.value),placeholder:"Manufacturing, Distribution"})}),e.jsx(le,{label:"Geography",help:"Comma-separated regions, e.g. Boston MA, Northeast",children:e.jsx("input",{className:Nt,value:o.geo,onChange:w=>g("geo",w.target.value),placeholder:"Boston MA, Northeast"})}),e.jsx(le,{label:"Owner Generation",children:e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:lp.map(w=>{const N=o.owner_generations.includes(w);return e.jsx("button",{type:"button",onClick:()=>b(w),className:`px-3 py-1 rounded-full text-xs font-medium ring-1 transition ${N?"bg-primary-50 ring-primary-300 text-primary-700 dark:bg-primary-900/40 dark:ring-primary-700 dark:text-primary-300":"bg-white ring-gray-200 text-gray-600 hover:bg-gray-50 dark:bg-gray-800 dark:ring-gray-600 dark:text-gray-400 dark:hover:bg-gray-700"}`,children:w.replace("_"," ")},w)})})}),e.jsx(le,{label:"Signals",help:"Comma-separated, e.g. founder_owned, profitable",children:e.jsx("input",{className:Nt,value:o.signals,onChange:w=>g("signals",w.target.value),placeholder:"founder_owned, profitable"})})]})})}function ko(s){return s.split(",").map(l=>l.trim()).filter(Boolean)}function No(s){return Array.isArray(s)?s.join(", "):""}function Qg(s){const l=s?.criteria??{},i=o=>o==null?"":String(o);return{name:s?.is_mine?s.name:s?`${s.name} (Copy)`:"",audience_note:s?.audience_note??"",description:s?.description??"",revenue_min:i(l.revenue_min),revenue_max:i(l.revenue_max),employee_min:i(l.employee_min),employee_max:i(l.employee_max),owner_age_min:i(l.owner_age_min),owner_age_max:i(l.owner_age_max),owner_generations:Array.isArray(l.owner_generations)?l.owner_generations:[],industries:No(l.industries),geo:No(l.geo),signals:No(l.signals),keywords:No(l.keywords),pitch_angle:l.pitch_angle??"",reg_fit:Array.isArray(l.reg_fit)?l.reg_fit:[],require_verified_contact:!!l.require_verified_contact}}function A2({open:s,preset:l,onClose:i,onSave:o}){const[d,u]=h.useState(()=>Qg(l)),[x,y]=h.useState(!1),[p,g]=h.useState("");h.useEffect(()=>{s&&(u(Qg(l)),g(""))},[s,l]);const b=!!l?.is_mine,f=b?"Edit Preset":l?"Duplicate as New Preset":"New Preset";function k(S,_){u(z=>({...z,[S]:_}))}function w(S,_){u(z=>({...z,[S]:z[S].includes(_)?z[S].filter(A=>A!==_):[...z[S],_]}))}const N=S=>S.trim()===""?null:Number(S);async function j(){if(!d.name.trim()){g("A preset name is required.");return}g(""),y(!0);try{const S={revenue_min:N(d.revenue_min),revenue_max:N(d.revenue_max),employee_min:N(d.employee_min),employee_max:N(d.employee_max),owner_age_min:N(d.owner_age_min),owner_age_max:N(d.owner_age_max),owner_generations:d.owner_generations,industries:ko(d.industries),geo:ko(d.geo),signals:ko(d.signals),keywords:ko(d.keywords),pitch_angle:d.pitch_angle.trim()||null,reg_fit:d.reg_fit};d.require_verified_contact&&(S.require_verified_contact=!0),await o({name:d.name.trim(),audience_note:d.audience_note.trim()||void 0,description:d.description.trim()||void 0,criteria:S},l)}catch(S){g(S.message??"Failed to save preset."),y(!1)}}const T=S=>`px-3 py-1 rounded-full text-xs font-medium ring-1 transition ${S?"bg-primary-50 ring-primary-300 text-primary-700 dark:bg-primary-900/40 dark:ring-primary-700 dark:text-primary-300":"bg-white ring-gray-200 text-gray-600 hover:bg-gray-50 dark:bg-gray-800 dark:ring-gray-600 dark:text-gray-400 dark:hover:bg-gray-700"}`;
61return e.jsx(Et,{open:s,onClose:i,title:f,footer:e.jsxs(e.Fragment,{children:[e.jsx(U,{variant:"ghost",onClick:i,disabled:x,children:"Cancel"}),e.jsx(U,{onClick:j,disabled:x,children:x?"Savingâ¦":b?"Save Changes":"Create Preset"})]}),children:e.jsxs("div",{className:"space-y-4",children:[p&&e.jsx(Ne,{tone:"red",children:p}),e.jsx(le,{label:"Preset Name",required:!0,children:e.jsx("input",{className:Nt,value:d.name,onChange:S=>k("name",S.target.value),placeholder:"e.g. Northeast Manufacturers, $5â25M"})}),e.jsx(le,{label:"Audience Note",help:"One-line summary shown on the preset card.",children:e.jsx("input",{className:Nt,value:d.audience_note,onChange:S=>k("audience_note",S.target.value),placeholder:"Owner-operated manufacturers ready for growth capital."})}),e.jsx(le,{label:"Description",help:"Optional longer description.",children:e.jsx("textarea",{className:Nt,rows:2,value:d.description,onChange:S=>k("description",S.target.value),placeholder:"What this preset targets and why."})}),e.jsx(Go,{}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(le,{label:"Revenue Min ($)",children:e.jsx("input",{type:"number",className:Nt,value:d.revenue_min,onChange:S=>k("revenue_min",S.target.value),placeholder:"1000000"})}),e.jsx(le,{label:"Revenue Max ($)",children:e.jsx("input",{type:"number",className:Nt,value:d.revenue_max,onChange:S=>k("revenue_max",S.target.value),placeholder:"25000000"})}),e.jsx(le,{label:"Employees Min",children:e.jsx("input",{type:"number",className:Nt,value:d.employee_min,onChange:S=>k("employee_min",S.target.value),placeholder:"10"})}),e.jsx(le,{label:"Employees Max",children:e.jsx("input",{type:"number",className:Nt,value:d.employee_max,onChange:S=>k("employee_max",S.target.value),placeholder:"250"})}),e.jsx(le,{label:"Owner Age Min",children:e.jsx("input",{type:"number",className:Nt,value:d.owner_age_min,onChange:S=>k("owner_age_min",S.target.value),placeholder:"50"})}),e.jsx(le,{label:"Owner Age Max",children:e.jsx("input",{type:"number",className:Nt,value:d.owner_age_max,onChange:S=>k("owner_age_max",S.target.value),placeholder:"72"})})]}),e.jsx(le,{label:"Owner Generation",children:e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:lp.map(S=>e.jsx("button",{type:"button",onClick:()=>w("owner_generations",S),className:T(d.owner_generations.includes(S)),children:S.replace("_"," ")},S))})}),e.jsx(le,{label:"Industries",help:"Comma-separated, e.g. Manufacturing, Distribution",children:e.jsx("input",{className:Nt,value:d.industries,onChange:S=>k("industries",S.target.value),placeholder:"Manufacturing, Distribution"})}),e.jsx(le,{label:"Geography",help:"Comma-separated regions, e.g. Boston MA, Northeast",children:e.jsx("input",{className:Nt,value:d.geo,onChange:S=>k("geo",S.target.value),placeholder:"Boston MA, Northeast"})}),e.jsx(le,{label:"Signals",help:"Comma-separated, e.g. founder_owned, profitable",children:e.jsx("input",{className:Nt,value:d.signals,onChange:S=>k("signals",S.target.value),placeholder:"founder_owned, profitable"})}),e.jsx(le,{label:"Keywords",help:"Comma-separated, e.g. founder, succession, recurring revenue",children:e.jsx("input",{className:Nt,value:d.keywords,onChange:S=>k("keywords",S.target.value),placeholder:"founder, succession, recurring revenue"})}),e.jsx(le,{label:"Pitch Angle",help:"The angle used when reaching out to matches.",children:e.jsx("input",{className:Nt,value:d.pitch_angle,onChange:S=>k("pitch_angle",S.target.value),placeholder:"Growth capital for a proven, cash-flowing business."})}),e.jsx(le,{label:"Regulatory Fit",children:e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:N2.map(S=>e.jsx("button",{type:"button",onClick:()=>w("reg_fit",S),className:T(d.reg_fit.includes(S)),children:S},S))})}),e.jsxs("label",{className:"flex items-center gap-2 min-h-11 text-sm text-gray-600 dark:text-gray-300 cursor-pointer",children:[e.jsx("span",{className:"flex h-11 w-11 -ml-2.5 flex-none items-center justify-center",children:e.jsx("input",{type:"checkbox",checked:d.require_verified_contact,onChange:S=>k("require_verified_contact",S.target.checked),className:"rounded border-gray-300 text-primary-600 focus:ring-primary-500"})}),"Only include matches with a verified contact"]})]})})}const _o="Local AI qualification",Cu="Local AI unavailable",E2="Provisional result - review required";function So(s){return typeof s=="number"&&isFinite(s)?s:0}function T2(s,l=!1){const i=s?.local_model_available===!1,o=s==null?"Checking the local modelâ¦":i?`${Cu}. Running qualification now gives a provisional result that a person must review before anything advances.`:s.local_model_available===!0?"Local AI available. Results are final when it completes.":"Local model status unknown.",d=i?`${Cu}. Running a provisional check; every result will require review. Refreshingâ¦`:`${_o} started. Refreshingâ¦`,u={availability:o,startMessage:d,provisionalIfRun:i};if(s==null)return{...u,key:"loading",title:"Qualification",chip:{label:"Loading",tone:"gray"},summary:"Loadingâ¦",detail:null,button:l?"Qualifyingâ¦":"Run qualification"};
61const x=So(s.viable),y=So(s.qualified),p=So(s.unscored),g=So(s.provisional),f=x-p>0,k=l?"Qualifyingâ¦":i?f?"Re-run provisional check":"Run provisional check":f?`Re-run ${_o.toLowerCase()}`:`Run ${_o.toLowerCase()}`;return x===0?{...u,key:"empty",title:"Qualification",chip:{label:"Nothing to qualify",tone:"gray"},summary:"No viable leads to qualify.",detail:null,button:k}:g>0||s.run_status==="needs_review"?{...u,key:"provisional",title:"Qualification",chip:{label:E2,tone:"amber"},summary:`${x} viable · ${g} provisional · ${y} qualified by local AI`,detail:"Local AI was unavailable when this run was qualified, so these leads carry a provisional heuristic assessment. A person must review each one before it can be enriched or handed off. No data was sent to a hosted AI service.",button:k}:p===x?{...u,key:"pending",title:"Qualification",chip:i?{label:Cu,tone:"gray"}:{label:"Awaiting qualification",tone:"blue"},summary:`${x} viable · awaiting qualification`,detail:null,button:k}:{...u,key:"local-complete",title:_o,chip:{label:"Local AI completed",tone:"green"},summary:`${x} viable · ${y} qualified by local AI${p?` · ${p} not yet reviewed`:""}`,detail:null,button:k}}const R2={qualified:{label:"Qualified by local AI",tone:"green"},needs_review:{label:"Needs review",tone:"amber"},reject:{label:"Rejected by local AI",tone:"gray"},already_known:{label:"Already known",tone:"gray"},needs_info:{label:"Needs more info",tone:"amber"}};function z2(s){return!s||!s.qual_status?null:s.qual_mode==="provisional_heuristic"?{label:"Provisional · review required",tone:"amber"}:R2[s.qual_status]||null}function L2(s){const l=["Company","Owner","Role","Email","Phone","LinkedIn","Website","Industry","Location","Revenue Est.","Employees Est.","Confidence","Match Score","Verification","Source","Status","Signals Matched","Why Matched","Notes","Last Verified"],i=s.map(o=>[o.company_name,o.owner_name??"",o.owner_role??"",o.contact_email??"",o.contact_phone??"",o.contact_linkedin??"",o.website??"",o.industry??"",o.location??"",o.revenue_estimate??"",o.employee_estimate??"",typeof o.confidence=="number"?Math.round(o.confidence*100)+"%":"",o.match_score??"",o.verification_status??"",o.provider??"",o.status??"",(o.signals_matched??[]).join("; "),o.why_matched??"",o.notes??"",o.last_verified_at?Ke(o.last_verified_at):""]);return[l,...i]}function M2({open:s,onClose:l,leads:i,selectedCount:o,runId:d,integrations:u,onToast:x}){const[y,p]=h.useState(null),g=o>0?`${o} selected lead${o!==1?"s":""}`:`all ${i.length} lead${i.length!==1?"s":""}`;function b(){if(i.length===0){x("No leads to export.");return}Ua(`fantize-leads-${new Date().toISOString().slice(0,10)}.csv`,L2(i)),x(`Exported ${i.length} lead${i.length!==1?"s":""} to CSV.`)}async function f(k,w){if(i.length===0){x("No leads to export.");return}p(k);try{const N=i.map(S=>S.id),j=await Me.exportLeads({destination:k,lead_ids:N,run_id:d}),T=await Me.approve(j.approval_id);x(T?.message||`Sent ${N.length} leads to ${w}.`),l()}catch(N){x(N.message||`Failed to sync to ${w}.`)}finally{p(null)}}return e.jsxs(Et,{open:s,onClose:l,title:"Export Leads",children:[e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-4",children:["Exporting ",e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:g}),".",o===0&&" Select specific leads first to narrow this down."]}),e.jsxs("div",{className:"rounded-2xl ring-1 ring-gray-200 dark:ring-gray-700 p-4 flex items-center justify-between gap-4 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-xl bg-gradient-to-br from-primary-100 to-primary-50 dark:from-primary-900/60 dark:to-primary-800/30 text-primary-600 dark:text-primary-400 flex items-center justify-center",children:e.jsx($e,{name:"list",className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:"CSV Download"}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:"All fields · opens in Excel, Google Sheets, any CRM importer"})]})]}),e.jsx(U,{variant:"primary",size:"sm",onClick:b,children:"Download"})]}),e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500 mt-5 mb-2 px-1",children:"Send to your tools"}),e.jsxs("div",{className:"space-y-2",children:[u.map(k=>{const w=k.label||k.name;return e.jsxs("div",{className:"rounded-2xl ring-1 ring-gray-200 dark:ring-gray-700 p-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-xl bg-gray-100 dark:bg-gray-700/60 text-gray-500 dark:text-gray-400 flex items-center justify-center",children:e.jsx($e,{name:"integrations",className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 capitalize",children:w}),e.jsx("div",{className:"mt-0.5",children:k.configured?e.jsx(se,{tone:"green",children:"Connected"}):e.jsx(se,{tone:"gray",children:"Not connected"})})]})]}),k.configured?e.jsx(U,{variant:"soft",size:"sm",disabled:y===k.name,onClick:()=>f(k.name,w),children:y===k.name?"Sendingâ¦":`Export to ${w}`}):e.jsx(Se,{to:"/dashboard/integrations?tab=crm-sync",children:e.jsx(U,{variant:"ghost",size:"sm",children:"Connect"})})]},k.name)}),u.length===0&&e.jsxs("div",{className:"rounded-2xl ring-1 ring-dashed ring-gray-300 dark:ring-gray-600 p-4 text-center",children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-3",children:"No integrations available yet."}),e.jsx(Se,{to:"/dashboard/integrations?tab=crm-sync",children:e.jsx(U,{variant:"soft",size:"sm",children:"Manage Integrations"})})]})]}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-4",children:"Connect a tool under Lead Generation â Admin â Integrations by adding its API key. Synced exports are recorded in your Analytics."})]})}function O2({message:s}){return s?e.jsx("div",{className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-50 pointer-events-none",children:e.jsx("div",{className:"bg-gray-900 text-white text-sm px-5 py-2.5 rounded-xl shadow-lg",children:s})}):null}function $2(s){const l=Jj(s.confidence);return e.jsx(se,{tone:l,children:e1(s.confidence)})}function D2(s){const l=t1(s.verification_status);return e.jsx(se,{tone:l,children:a1(s.verification_status)})}function H2({leadId:s,availableLists:l,onDone:i}){const[o,d]=h.useState(""),[u,x]=h.useState(!1);async function y(p,g){x(!0);try{await Me.addToList(s,{list_id:p,list_name:g}),i("Added to list.")}catch(b){i(b.message||"Failed to add to list.")}finally{x(!1)}}return e.jsxs("div",{className:"absolute right-0 top-8 z-30 w-56 bg-white dark:bg-gray-800 rounded-xl shadow-lg ring-1 ring-gray-200 dark:ring-gray-700 p-2 space-y-1",children:[l.length===0&&e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 px-2 py-1",children:"No lists yet."}),l.map(p=>e.jsxs("button",{disabled:u,onClick:()=>y(p.id),className:"w-full text-left text-sm px-3 py-1.5 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 disabled:opacity-50",children:[p.name,p.contact_count!==void 0&&e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500 ml-1",children:["(",p.contact_count,")"]})]}
61,p.id)),e.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700 pt-2 px-1 flex gap-1.5",children:[e.jsx("input",{className:"flex-1 rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 px-2 py-1 text-xs focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent",placeholder:"New list nameâ¦",value:o,onChange:p=>d(p.target.value),onKeyDown:p=>{p.key==="Enter"&&o.trim()&&y(void 0,o.trim())}}),e.jsx(U,{size:"sm",disabled:!o.trim()||u,onClick:()=>y(void 0,o.trim()),children:"Add"})]})]})}function q2({leadId:s,availableCampaigns:l,onDone:i}){const[o,d]=h.useState(!1);async function u(x){d(!0);try{await Me.addToCampaign(s,x),i("Added to campaign.")}catch(y){i(y.message||"Failed to add to campaign.")}finally{d(!1)}}return e.jsxs("div",{className:"absolute right-0 top-8 z-30 w-56 bg-white dark:bg-gray-800 rounded-xl shadow-lg ring-1 ring-gray-200 dark:ring-gray-700 p-2 space-y-1",children:[l.length===0&&e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 px-2 py-1",children:"No campaigns yet."}),l.map(x=>e.jsxs("button",{disabled:o,onClick:()=>u(x.id),className:"w-full text-left text-sm px-3 py-1.5 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 disabled:opacity-50",children:[x.name,e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 ml-1",children:x.type})]},x.id))]})}function B2({lead:s,selected:l,onToggle:i,onSave:o,onExclude:d,onToast:u,availableLists:x,availableCampaigns:y}){const[p,g]=h.useState(!1),[b,f]=h.useState(null),k=h.useRef(null);h.useEffect(()=>{if(!b)return;function j(T){k.current&&!k.current.contains(T.target)&&f(null)}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[b]);const w=s.contact_id?"saved":s.status||"new",N=z2(s);return e.jsx(_e,{className:`!p-4 ${l?"ring-2 ring-primary-300":""}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("label",{className:"flex h-11 w-11 -my-2.5 -ml-2.5 shrink-0 items-center justify-center rounded-lg cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700/60 focus-within:ring-2 focus-within:ring-primary-500",children:e.jsx("input",{type:"checkbox",checked:l,onChange:i,"aria-label":`Select ${s.company_name}`,className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary-500 focus:ring-primary-500 cursor-pointer"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold text-gray-900 dark:text-gray-100 truncate",children:s.company_name}),e.jsx("div",{className:"text-sm text-gray-500 truncate",children:[s.owner_name,s.owner_role,s.location].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink min-w-0 flex-wrap justify-end",children:[$2(s),N&&e.jsx(se,{tone:N.tone,children:N.label}),D2(s),e.jsx(Bn,{status:w})]})]}),s.why_matched&&e.jsxs("p",{className:"text-xs text-gray-500 mt-1.5 italic",children:["Why matched: ",s.why_matched]}),s.qual_reason&&e.jsxs("p",{className:"text-xs mt-1 "+(s.qual_mode==="provisional_heuristic"?"text-amber-700 dark:text-amber-300":"text-gray-500"),children:["Qualification: ",s.qual_reason]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 text-xs text-gray-500",children:[s.contact_email&&e.jsx("span",{className:"truncate max-w-[200px]",children:s.contact_email}),s.industry&&e.jsx("span",{children:s.industry}),s.revenue_estimate!=null&&e.jsxs("span",{children:["Rev ",Kj(s.revenue_estimate)]}),s.employee_estimate!=null&&e.jsxs("span",{children:[s.employee_estimate.toLocaleString()," emp"]}),e.jsx(se,{tone:"gray",children:s.provider}),s.contact_id&&e.jsx(se,{tone:"green",children:"Saved"})]}),p&&e.jsxs("div",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300 space-y-1.5 border-t border-gray-100 dark:border-gray-700 pt-3",children:[s.website&&e.jsxs("div",{children:["Website:"," ",e.jsx("a",{className:"text-sky-600 hover:underline",href:s.website.startsWith("http")?s.website:`https://${s.website}`,target:"_blank",rel:"noreferrer",children:s.website})]}),s.contact_phone&&e.jsxs("div",{children:["Phone: ",s.contact_phone]}),s.contact_linkedin&&e.jsxs("div",{children:["LinkedIn:"," ",e.jsx("a",{className:"text-sky-600 hover:underline",href:s.contact_linkedin,target:"_blank",rel:"noreferrer",children:s.contact_linkedin})]}),s.signals_matched&&s.signals_matched.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:s.signals_matched.map(j=>e.jsx(se,{tone:"blue",children:j},j))}),s.last_verified_at&&e.jsxs("div",{className:"text-xs text-gray-400",children:["Last verified: ",Ke(s.last_verified_at)]}),s.notes&&e.jsxs("div",{className:"bg-amber-50 rounded-lg px-3 py-2 text-xs text-amber-700 ring-1 ring-amber-100",children:["Note: ",s.notes]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-3",children:[e.jsx(U,{size:"sm",variant:"soft",onClick:o,disabled:!!s.contact_id,children:s.contact_id?"Saved":"Save"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>g(j=>!j),children:p?"Hide":"Details"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:d,disabled:s.status==="excluded",children:"Exclude"}),e.jsxs("div",{className:"relative",ref:b==="list"?k:void 0,children:[e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>f(b==="list"?null:"list"),children:"Add to List â¾"}),b==="list"&&e.jsx(H2,{leadId:s.id,availableLists:x,onDone:j=>{f(null),u(j)}})]}),e.jsxs("div",{className:"relative",ref:b==="campaign"?k:void 0,children:[e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>f(b==="campaign"?null:"campaign"),children:"Add to Campaign â¾"}),b==="campaign"&&e.jsx(q2,{leadId:s.id,availableCampaigns:y,onDone:j=>{f(null),u(j)}})]})]})]})]})})}function U2({open:s,onClose:l,leadIds:i,availableLists:o,onDone:d}
61){const[u,x]=h.useState(""),[y,p]=h.useState(!1);async function g(b,f){p(!0);try{await Promise.all(i.map(k=>Me.addToList(k,{list_id:b,list_name:f}))),d(`${i.length} lead${i.length>1?"s":""} added to list.`)}catch(k){d(k.message||"Failed to add to list.")}finally{p(!1),l()}}return e.jsx(Et,{open:s,onClose:l,title:`Add ${i.length} lead${i.length>1?"s":""} to list`,footer:e.jsx(U,{variant:"ghost",onClick:l,children:"Cancel"}),children:e.jsxs("div",{className:"space-y-2",children:[o.length===0&&e.jsx("p",{className:"text-sm text-gray-400",children:"No lists yet â create one below."}),o.map(b=>e.jsxs("button",{disabled:y,onClick:()=>g(b.id),className:"w-full text-left text-sm px-3 py-2 rounded-xl ring-1 ring-gray-200 dark:ring-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 disabled:opacity-50 transition",children:[b.name,b.contact_count!==void 0&&e.jsxs("span",{className:"text-xs text-gray-400 ml-1",children:["· ",b.contact_count," contacts"]})]},b.id)),e.jsx("div",{className:"border-t border-gray-100 dark:border-gray-700 pt-3",children:e.jsx(le,{label:"Create new list",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:de,placeholder:"List nameâ¦",value:u,onChange:b=>x(b.target.value),onKeyDown:b=>{b.key==="Enter"&&u.trim()&&g(void 0,u.trim())}}),e.jsx(U,{disabled:!u.trim()||y,onClick:()=>g(void 0,u.trim()),children:"Create"})]})})})]})})}function F2({open:s,onClose:l,preview:i,onConfirm:o,busy:d}){return e.jsx(Et,{open:s,onClose:l,title:"Enrich Leads",footer:e.jsxs(e.Fragment,{children:[e.jsx(U,{variant:"ghost",onClick:l,disabled:d,children:"Cancel"}),e.jsx(U,{onClick:o,disabled:d,children:d?"Startingâ¦":"Confirm Enrichment"})]}),children:i?e.jsxs("div",{className:"space-y-4",children:[i.message&&e.jsx("p",{className:"text-sm text-gray-700",children:i.message}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.to_enrich!==void 0&&e.jsxs("div",{className:"rounded-xl bg-gray-50 dark:bg-gray-900/40 ring-1 ring-gray-200 dark:ring-gray-700 p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-gray-100",children:i.to_enrich}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"Leads to enrich"})]}),i.cost&&e.jsxs("div",{className:"rounded-xl bg-gray-50 dark:bg-gray-900/40 ring-1 ring-gray-200 dark:ring-gray-700 p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-semibold text-primary-600",children:i.cost}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"Estimated cost"})]})]}),e.jsx(Ne,{tone:"blue",children:"Enrichment runs in the background and fills in verified contact details for viable leads."})]}):e.jsx(tt,{label:"Loading estimateâ¦"})})}function I2(){const{id:s=""}=am(),l=Ya(),[i,o]=h.useState(null),[d,u]=h.useState(null),[x,y]=h.useState([]),[p,g]=h.useState([]),[b,f]=h.useState(null),[k,w]=h.useState("all"),[N,j]=h.useState(new Set),[T,S]=h.useState(""),[_,z]=h.useState(""),[A,L]=h.useState(!1),[F,D]=h.useState(!1),[te,pe]=h.useState(!1),[he,X]=h.useState(!1),[I,q]=h.useState([]),be=h.useRef(null),ne=h.useRef(!0);function M(C){S(C),setTimeout(()=>S(""),3e3)}const Y=h.useCallback(async()=>{try{const C=await Me.results(s);return ne.current&&u(C),C}catch(C){ne.current&&z(C.message||"Failed to load results.")}},[s]),oe=h.useCallback(async()=>{const[C,ve]=await Promise.allSettled([Za.list(),xa.list()]);C.status==="fulfilled"&&y(C.value.lists),ve.status==="fulfilled"&&g(ve.value.campaigns),Me.enrichPreview(s).then(f).catch(()=>{}),Me.adminProviders().then(Oe=>q(Oe.providers.filter(dt=>dt.kind==="integration"))).catch(()=>{})},[s]);function Ce(){be.current&&(clearInterval(be.current),be.current=null)}function Ae(){Ce(),be.current=setInterval(async()=>{if(ne.current)try{const C=await Me.getRun(s);o(C),C.status!=="running"&&(Ce(),await Y(),await oe())}catch{}},3e3)}h.useEffect(()=>{ne.current=!0;async function C(){try{const ve=await Me.getRun(s);if(!ne.current)return;o(ve),ve.status==="running"?Ae():(await Y(),await oe())}catch(ve){ne.current&&z(ve.message||"Failed to load run.")}}return C(),()=>{ne.current=!1,Ce()}},[s]),h.useEffect(()=>{document.title=i?.label?`${i.label} â Fantize`:"Search Results â Fantize"},[i?.label]);const H=d?.leads??[],Z=H.filter(C=>k==="strong"?C.confidence>=.7:k==="viable"?C.confidence>=.4&&C.confidence<.7:!0),$=H.filter(C=>C.confidence>=.7).length,O=H.filter(C=>C.confidence>=.4&&C.confidence<.7).length;function P(C){j(ve=>{const Oe=new Set(ve);return Oe.has(C)?Oe.delete(C):Oe.add(C),Oe})}function V(){N.size===Z.length?j(new Set):j(new Set(Z.map(C=>C.id)))}async function ye(C){try{await Me.saveLead(C.id),u(ve=>ve&&{...ve,leads:ve.leads.map(Oe=>Oe.id===C.id?{...Oe,status:"saved",contact_id:C.id}:Oe)}),M("Saved â")}catch(ve){M(ve.message||"Failed to save lead.")}}async function ge(C){try{await Me.excludeLead(C.id),u(ve=>ve&&{...ve,leads:ve.leads.map(Oe=>Oe.id===C.id?{...Oe,status:"excluded"}:Oe)}
61),M("Excluded.")}catch(ve){M(ve.message||"Failed to exclude lead.")}}async function qe(){const C=[...N];let ve=0;for(const Oe of C)try{await Me.saveLead(Oe),ve++}catch{}u(Oe=>Oe&&{...Oe,leads:Oe.leads.map(dt=>C.includes(dt.id)?{...dt,status:"saved",contact_id:dt.id}:dt)}),j(new Set),M(`${ve} lead${ve>1?"s":""} saved â`)}async function nt(){const C=[...N];for(const ve of C)try{await Me.excludeLead(ve)}catch{}u(ve=>ve&&{...ve,leads:ve.leads.map(Oe=>C.includes(Oe.id)?{...Oe,status:"excluded"}:Oe)}),j(new Set),M(`${C.length} lead${C.length>1?"s":""} excluded.`)}async function R(){const C=[...N];if(C.length)try{const Oe=(await Me.findMore(C))?.search?.id;if(Oe){const dt=await Me.run(Oe);l(`/dashboard/prospecting/results/${dt.run_id}`)}else M("Created a new search from these leads â find it in Searches.")}catch(ve){M(ve.message||"Could not build a search from these leads.")}}async function we(){if(L(!0),!b)try{const C=await Me.enrichPreview(s);f(C)}catch{}}async function ie(){D(!0);try{await Me.enrich(s),L(!1),M("Enrichment startedâ¦"),await Y()}catch(C){M(C.message||"Enrichment failed.")}finally{D(!1)}}const Ee=i?.status==="running";if(!i&&!_)return e.jsx(tt,{label:"Loading resultsâ¦"});if(_&&!d)return e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(Ne,{tone:"red",children:_}),e.jsx("div",{className:"mt-4",children:e.jsx(U,{variant:"ghost",onClick:()=>l("/dashboard/prospecting/results"),children:"Back to Results"})})]});const me=d?.summary,ke=i,ze=[{key:"strong",label:"Strong",count:$},{key:"viable",label:"Viable",count:O},{key:"all",label:"All",count:H.length}];return e.jsxs("div",{className:"max-w-5xl mx-auto pb-28",children:[e.jsx(Xe,{title:ke.label||"Search results",crumbTail:ke.label||"Search results",subtitle:"Review, enrich and save the leads this search found.",action:Ee?void 0:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{variant:"soft",onClick:()=>X(!0),disabled:H.length===0,children:"Export"}),e.jsx(U,{onClick:we,children:"Enrich Leads"})]})}),_&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"red",children:_})}),Ee&&e.jsx("div",{className:"mb-6",children:e.jsx(Ne,{tone:"amber",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-400 animate-pulse"}),e.jsx("span",{className:"font-medium",children:"Runningâ¦"}),e.jsx("span",{className:"text-amber-600 text-xs",children:"Results will appear automatically when complete."})]})})}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-6",children:[e.jsx(Ct,{label:"Total Found",value:me?.total_leads??ke.raw_found??0}),e.jsx(Ct,{label:"Strong Matches",value:me?.strong_matches??ke.strong_matches??0,tone:"green"}),e.jsx(Ct,{label:"Viable",value:me?.viable??ke.viable_count??0,tone:"blue"}),e.jsxs("div",{className:"bg-white dark:bg-gray-800/80 rounded-2xl shadow-sm ring-1 ring-gray-100 dark:ring-gray-700 p-4 flex flex-col justify-between",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Status"}),e.jsx(Bn,{status:ke.status})]})]}),!Ee&&H.length>0&&e.jsx(V2,{runId:s,onEnrich:we,onReload:Y,flash:M}),!Ee&&e.jsx(G2,{runId:s,profileId:ke.profile_id,runCreatedAt:ke.created_at,nav:l,flash:M}),!Ee&&H.length>0&&e.jsx(Xl,{tabs:ze,active:k,onChange:C=>{w(C),j(new Set)}}),Ee?e.jsx(tt,{label:"Searching for matchesâ¦"}):Z.length===0?e.jsx(Ze,{title:"No leads found",hint:k==="all"?"Try adjusting your search criteria to find more results.":'Switch to the "All" tab to see every result, or refine your search.',icon:e.jsx($e,{name:"search",className:"w-8 h-8"}),action:e.jsx(U,{onClick:()=>l("/dashboard/prospecting/searches"),children:"Refine Search"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3 px-1",children:[e.jsx("label",{className:"flex h-11 w-11 -my-2.5 -ml-2.5 shrink-0 items-center justify-center rounded-lg cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700/60 focus-within:ring-2 focus-within:ring-primary-500",children:e.jsx("input",{type:"checkbox",checked:N.size>0&&N.size===Z.length,ref:C=>{C&&(C.indeterminate=N.size>0&&N.size<Z.length)},onChange:V,"aria-label":`Select all ${Z.length}
61 leads shown`,className:"h-4 w-4 rounded border-gray-300 text-primary-500 focus:ring-primary-500 cursor-pointer"})}),e.jsx("span",{className:"text-xs text-gray-400",children:N.size>0?`${N.size} of ${Z.length} selected`:`${Z.length} lead${Z.length!==1?"s":""}`})]}),e.jsx("div",{className:"space-y-3",children:Z.map(C=>e.jsx(B2,{lead:C,selected:N.has(C.id),onToggle:()=>P(C.id),onSave:()=>ye(C),onExclude:()=>ge(C),onToast:M,availableLists:x,availableCampaigns:p},C.id))})]}),N.size>0&&e.jsx("div",{className:"fixed bottom-0 left-0 right-0 sm:left-64 z-40 bg-white dark:bg-gray-800/80 border-t border-gray-200 dark:border-gray-700 px-4 py-3",children:e.jsxs("div",{className:"max-w-5xl mx-auto flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:[N.size," lead",N.size>1?"s":""," selected"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(U,{size:"sm",variant:"soft",onClick:qe,children:"Save All"}),e.jsx(U,{size:"sm",variant:"soft",onClick:()=>pe(!0),children:"Add to List"}),e.jsx(U,{size:"sm",variant:"soft",onClick:R,children:"Find more like these"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:nt,children:"Exclude All"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>j(new Set),children:"Clear"})]})]})}),e.jsx(F2,{open:A,onClose:()=>L(!1),preview:b,onConfirm:ie,busy:F}),e.jsx(U2,{open:te,onClose:()=>pe(!1),leadIds:[...N],availableLists:x,onDone:C=>{pe(!1),j(new Set),M(C)}}),e.jsx(M2,{open:he,onClose:()=>X(!1),leads:N.size>0?Z.filter(C=>N.has(C.id)):Z,selectedCount:N.size,runId:s,integrations:I,onToast:M}),e.jsx(O2,{message:T})]})}function V2({runId:s,onEnrich:l,onReload:i,flash:o}){const[d,u]=h.useState(null),[x,y]=h.useState(null),[p,g]=h.useState(null),[b,f]=h.useState(!1);async function k(){Me.qualifyPreview(s).then(u).catch(()=>{}),Me.internalCheckPreview(s).then(y).catch(()=>{}),Me.enrichPreview(s).then(g).catch(()=>{})}h.useEffect(()=>{k()},[s]);const w=T2(d,b);async function N(){f(!0);try{await Me.qualify(s),o(w.startMessage),setTimeout(()=>{k(),i(),f(!1)},4e3)}catch(T){o(T.message||"Could not start qualification."),f(!1)}}const j="flex-1 min-w-[180px] rounded-xl border border-gray-200 dark:border-gray-700 p-3";return e.jsxs("div",{className:"mb-6 rounded-2xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800/70 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Cost & pipeline"}),e.jsx("span",{className:"text-xs text-gray-400",children:"Local stages run first; only unfilled contact gaps cost records."})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("div",{className:j,"data-qualification-state":w.key,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:["1 · ",w.title]}),e.jsx(se,{tone:w.chip.tone,children:w.chip.label})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:w.summary}),w.detail&&e.jsx("p",{className:"text-[11px] text-amber-700 dark:text-amber-300 mt-1",role:"status",children:w.detail}),e.jsx("p",{className:"text-[11px] text-gray-400 mt-1",children:w.availability}),e.jsx("div",{className:"mt-2",children:e.jsx(U,{variant:"soft",size:"sm",disabled:b||!d,onClick:N,children:w.button})})]}),e.jsxs("div",{className:j,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:"2 · HubSpot reuse"}),e.jsx(se,{tone:"green",children:"free"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:x?`${x.internal_hits??0} matched · ${(x.reused_email??0)+(x.reused_phone??0)} contacts reused`:"Checked during enrich."}),x&&x.need_apollo_email!=null&&e.jsxs("p",{className:"text-[11px] text-gray-400 mt-1",children:["Still need Apollo: ",x.need_apollo_email," email · ",x.need_apollo_phone," phone"]})]}),e.jsxs("div",{className:j,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:"3 · Enrich (Apollo)"}),e.jsx(se,{tone:"amber",children:"paid"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:p?`${p.to_enrich??0} to enrich · ~${p.est_records??0} records`:"Loadingâ¦"}),e.jsx("div",{className:"mt-2",children:e.jsx(U,{variant:"primary",size:"sm",onClick:l,children:"Review & enrich"})})]})]})]})}function G2({runId:s,profileId:l,runCreatedAt:i,nav:o,flash:d}
61){const[u,x]=h.useState(null),[y,p]=h.useState(null),[g,b]=h.useState(null),[f,k]=h.useState(!1),[w,N]=h.useState("");h.useEffect(()=>{let _=!0;return Me.suggestions(s).then(z=>{_&&x(z)}).catch(()=>{}),()=>{_=!1}},[s]);async function j(_){p(_.id);try{const A=(await Me.applySuggestion(l,_.criteria_delta,_.title))?.search?.id;if(A){const L=await Me.run(A);o(`/dashboard/prospecting/results/${L.run_id}`)}else d("Refined search created â find it in Searches.")}catch(z){d(z.message||"Could not apply this suggestion.")}finally{p(null)}}async function T(){k(!0),N("");try{const{runs:_}=await Me.runs(),z=_.filter(L=>L.profile_id===l&&L.id!==s&&Gt(L.created_at)<Gt(i)).sort((L,F)=>Gt(F.created_at)-Gt(L.created_at))[0];if(!z){N("No earlier run of this search to compare against yet.");return}const A=await Me.compare(s,z.id);b(A),N(`vs. run from ${Ia(z.created_at)}`)}catch(_){N(_.message||"Comparison unavailable.")}finally{k(!1)}}const S=u?.cards??[];return S.length===0&&!g&&!w&&!f?e.jsx("div",{className:"mb-6",children:e.jsx(U,{variant:"soft",size:"sm",onClick:T,disabled:f,children:"Compare to previous run"})}):e.jsxs("div",{className:"mb-6 rounded-2xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800/70 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:u?.headline||"Refine this search"}),e.jsx(U,{variant:"soft",size:"sm",onClick:T,disabled:f,children:f?"Comparingâ¦":"Compare to previous run"})]}),(g?.counts||w)&&e.jsx("div",{className:"mb-3 text-sm text-gray-600 dark:text-gray-300",children:g?.counts?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(se,{tone:"green",children:[g.counts.new??0," new"]}),e.jsxs(se,{tone:"gray",children:[g.counts.seen??0," seen before"]}),e.jsxs(se,{tone:"amber",children:[g.counts.removed??0," gone"]}),w&&e.jsx("span",{className:"text-xs text-gray-400",children:w})]}):e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:w})}),S.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:S.map(_=>e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-gray-700 p-3",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:_.title}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:_.why}),_.estimated_effect&&e.jsx("div",{className:"text-xs text-primary-600 mt-1",children:_.estimated_effect}),e.jsx("div",{className:"mt-2",children:e.jsx(U,{variant:"soft",size:"sm",disabled:y===_.id,onClick:()=>j(_),children:y===_.id?"Applyingâ¦":"Apply & run"})})]},_.id))})]})}const Y2=[{key:"leads_sourced",label:"Leads sourced",group:"outbound"},{key:"sent_to_outbound",label:"Sent to outbound",group:"outbound"},{key:"emails_delivered",label:"Emails delivered",tone:"blue",group:"outbound"},{key:"replies_received",label:"Replies received",tone:"blue",group:"engagement"},{key:"positive_replies",label:"Positive replies",tone:"green",group:"engagement"},{key:"meeting_link_clicks",label:"Meeting-link clicks",tone:"green",group:"engagement"},{key:"meetings_booked",label:"Meetings booked",tone:"green",group:"engagement"},{key:"mqls_created",label:"MQLs created",tone:"green",group:"handoff"},{key:"sals_created",label:"SALs created",tone:"green",group:"handoff"},{key:"review_queue",label:"Waiting in Reply Review",tone:"amber",group:"exceptions"},{key:"sync_errors",label:"Handoffs not completed",tone:"red",group:"exceptions"},{key:"suppressed",label:"Suppressed",tone:"red",group:"exceptions"}],P2={outbound:"Outbound",engagement:"Engagement",handoff:"Handed to HubSpot",exceptions:"Exceptions"},Au=[{key:"outbound_only",label:"Outbound system only",hint:"Cold leads still in Instantly. Nothing has qualified them."},{key:"ready_for_review",label:"Waiting for review",hint:"A reply or event qualified them; a person decides in Reply Review."},{key:"synced",label:"Handed to HubSpot",hint:"Created or updated in HubSpot."},{key:"disqualified_suppressed",label:"Closed",hint:"Disqualified or suppressed; no further outreach."}],Q2=[{action:"meeting_completed",label:"Meeting completed"},{action:"second_meeting",label:"Second meeting scheduled"},{action:"proposal_sent",label:"Proposal / letter sent"},{action:"open_opportunity",label:"Open opportunity"},{action:"disqualified",label:"Disqualified"}],Eu=25;function Xg(s){return s==null?"Not available":typeof s=="number"?s.toLocaleStr
61ing():String(s)}function X2(){const{isAdmin:s}=zt(),i=Ja().asMarketing?!1:s,[o,d]=h.useState({}),[u,x]=h.useState({}),[y,p]=h.useState({}),[g,b]=h.useState(!0),[f,k]=h.useState(""),[w,N]=h.useState("30"),[j,T]=h.useState("outbound_only"),[S,_]=h.useState(null),[z,A]=h.useState(""),[L,F]=h.useState("email_only"),[D,te]=h.useState(""),[pe,he]=h.useState("all"),[X,I]=h.useState("all"),[q,be]=h.useState("recent"),[ne,M]=h.useState(1);h.useEffect(()=>{je.callConfig().then(ie=>F(ie.outreach_mode||"email_only")).catch(()=>{})},[]);async function Y(){b(!0),k("");try{const[ie,Ee]=await Promise.all([je.dashboard({days:w}),je.lifecycle({days:w})]);d(ie.cards||{}),x({est_ai_cost:ie.cards?.est_ai_cost,ai_classify_calls:ie.cards?.ai_classify_calls,est_total_cost_month:ie.cards?.est_total_cost_month}),p(Ee.buckets||{})}catch(ie){k(ie.message||"Could not load the lifecycle.")}b(!1)}h.useEffect(()=>{Y()},[w]),h.useEffect(()=>{M(1)},[j,D,pe,X,q]);function oe(ie){A(ie),setTimeout(()=>A(""),3e3)}async function Ce(ie){const Ee=await je.contact(ie);_(Ee)}async function Ae(ie){try{await je.approveCalling(ie),oe("Syncing to HubSpot as âLeadâ for calling."),_(null),Y()}catch(Ee){oe(Ee.message)}}async function H(ie,Ee){await je.progress(ie,Ee),oe("HubSpot updated."),_(null),Y()}async function Z(ie,Ee){await je.setStatus(ie,Ee),oe("Status updated."),_(null),Y()}const $=y[j]?.leads||[],O=h.useMemo(()=>Array.from(new Set($.map(ie=>ie.campaign_name).filter(Boolean))).sort(),[$]),P=h.useMemo(()=>Array.from(new Set($.map(ie=>ie.last_classification).filter(Boolean))).sort(),[$]),V=h.useMemo(()=>{let ie=$.filter(Ee=>!(pe!=="all"&&Ee.campaign_name!==pe||X!=="all"&&Ee.last_classification!==X||D.trim()&&!`${Ee.first_name||""} ${Ee.last_name||""} ${Ee.email||""} ${Ee.company||""}`.toLowerCase().includes(D.trim().toLowerCase())));return ie=ie.slice().sort((Ee,Je)=>
61{if(q==="name")return`${Ee.last_name||""}${Ee.first_name||""}${Ee.email||""}`.localeCompare(`${Je.last_name||""}${Je.first_name||""}${Je.email||""}`);const me=new Date(Ee.last_event_at||0).getTime(),ke=new Date(Je.last_event_at||0).getTime();return q==="recent"?ke-me:me-ke}),ie},[$,pe,X,D,q]),ye=Math.max(1,Math.ceil(V.length/Eu)),ge=V.slice((ne-1)*Eu,ne*Eu),qe=w==="3650"?"all time":`the last ${w} days`,nt=o.emails_delivered,R=o.replies_received,we=typeof nt=="number"&&nt===0&&typeof R=="number"&&R>0;return e.jsxs("div",{className:"max-w-6xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Lead Lifecycle",subtitle:"Where every engaged lead currently lives. Cold leads stay in the outbound system; only engaged leads are handed to HubSpot.",secondary:e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-300",children:[e.jsx("span",{children:"Range"}),e.jsxs("select",{value:w,onChange:ie=>N(ie.target.value),className:de+" w-auto","aria-label":"Metrics time range",children:[e.jsx("option",{value:"7",children:"Last 7 days"}),e.jsx("option",{value:"30",children:"Last 30 days"}),e.jsx("option",{value:"90",children:"Last 90 days"}),e.jsx("option",{value:"3650",children:"All time"})]})]})}),e.jsx(qn,{message:z}),f&&e.jsx("div",{className:"mb-4",children:e.jsx(Rr,{message:f,onRetry:Y})}),g?e.jsx(tt,{label:"Loading lifecycleâ¦"}):e.jsxs(e.Fragment,{children:[e.jsxs("section",{"aria-labelledby":"funnel-h",className:"mb-8",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2 mb-3",children:[e.jsxs("h2",{id:"funnel-h",className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:["Funnel for ",qe]}),e.jsx("span",{className:"text-xs text-gray-500",children:"Counted from the outbound event feed (webhooks, polling and imports). Metrics the feed does not carry are shown as âNot availableâ."})]}),we&&e.jsx("div",{className:"mb-3",children:e.jsx(Ne,{tone:"amber",children:"Replies were received while no deliveries were recorded in this range. That usually means the outbound platform reports replies but not deliveries for this period, not that replies arrived without emails. Delivery counts are only as complete as the feed."})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:["outbound","engagement","handoff","exceptions"].map(ie=>e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2",children:P2[ie]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:Y2.filter(Ee=>Ee.group===ie).map(Ee=>e.jsx(Ct,{label:Ee.label,value:Xg(o[Ee.key]),tone:o[Ee.key]==null?"gray":Ee.tone},Ee.key))})]},ie))}),e.jsxs("details",{className:"mt-3",children:[e.jsxs("summary",{className:"min-h-11 flex items-center cursor-pointer text-sm text-gray-600 dark:text-gray-300",children:["Cost estimates for ",qe]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 mt-2",children:[e.jsx(Ct,{label:"Est. AI classification cost",value:u.est_ai_cost==null?"Not available":`$${u.est_ai_cost.toFixed(4)}`,sub:u.ai_classify_calls==null?void 0:`${u.ai_classify_calls} AI calls`}),e.jsx(Ct,{label:"Est. total API cost (monthly)",value:u.est_total_cost_month==null?"Not available":`$${u.est_total_cost_month.toFixed(2)}`}),e.jsx(Ct,{label:"Handed to HubSpot (current)",value:Xg(y.synced?.count),tone:"green"})]})]})]}),e.jsxs("section",{"aria-labelledby":"board-h",children:[e.jsx("h2",{id:"board-h",className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Where leads live now"}),e.jsxs("p",{className:"text-sm text-gray-500 mb-3",children:["Current state, not limited to the range above. ",Au.find(ie=>ie.key===j)?.hint]}),e.jsx(dn,{label:"Lifecycle state",active:j,onChange:T,className:"mb-4",items:Au.map(ie=>({key:ie.key,label:ie.label,count:y[ie.key]?.count??0}))}),$.length===0?e.jsx(Ze,{title:`No leads are ${Au.find(ie=>ie.key===j)?.label.toLowerCase()}`,hint:"Leads move between these states as outbound activity, replies and decisions come in.",doing:"Monitoring the outbound event feed"}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs(Hn,{search:{value:D,onChange:te,placeholder:"Search name, email or company",label:"Search leads"},summary:`${V.length} of ${$.length} lead${$.length===1?"":"s"}${ye>1?` · page ${ne} of ${ye}`:""}`,onClear:D||pe!=="all"||X!=="all"?()=>{te(""),he("all"),I("all")}:void 0,children:[O.length>
611&&e.jsx(ha,{label:"Campaign",value:pe,onChange:he,options:[{value:"all",label:"All campaigns"},...O.map(ie=>({value:ie,label:ie}))]}),P.length>1&&e.jsx(ha,{label:"Last classification",value:X,onChange:I,options:[{value:"all",label:"Any"},...P.map(ie=>({value:ie,label:String(ie).replace(/_/g," ")}))]}),e.jsx(ha,{label:"Sort",value:q,onChange:ie=>be(ie),options:[{value:"recent",label:"Most recent activity"},{value:"oldest",label:"Oldest activity"},{value:"name",label:"Name AâZ"}]})]}),V.length===0?e.jsx(Ze,{title:"No leads match these filters",hint:"Clear the filters to see every lead in this state."}):e.jsx("ul",{className:"space-y-2",children:ge.map(ie=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>Ce(ie.id),className:"w-full text-left rounded-2xl bg-white dark:bg-gray-800/80 ring-1 ring-gray-200 dark:ring-gray-700/60 shadow-sm p-3 flex items-center justify-between gap-3 hover:ring-primary-300 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-medium text-gray-900 dark:text-gray-100 truncate",children:[[ie.first_name,ie.last_name].filter(Boolean).join(" ")||ie.email,ie.company&&e.jsxs("span",{className:"text-gray-400 font-normal",children:[" · ",ie.company]})]}),e.jsxs("div",{className:"text-xs text-gray-500 truncate",children:[ie.email," ",ie.campaign_name&&`· ${ie.campaign_name}`," ",ie.last_event_at&&`· ${Ke(ie.last_event_at)}`]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 flex-wrap justify-end",children:[ie.last_classification&&e.jsx(se,{tone:"gray",children:String(ie.last_classification).replace(/_/g," ")}),ie.hubspot_sync_mode==="lead"&&e.jsx(se,{tone:"blue",children:"HubSpot Lead"}),e.jsx(se,{tone:ip(ie.internal_status),children:hm(ie.internal_status)}),ie.hubspot_contact_id&&ie.hubspot_sync_mode!=="lead"&&e.jsx(se,{tone:"green",children:"In HubSpot"})]})]})},ie.id))}),ye>1&&e.jsxs("nav",{"aria-label":"Pagination",className:"flex items-center justify-between gap-3 pt-2",children:[e.jsx(U,{size:"sm",variant:"soft",disabled:ne<=1,onClick:()=>M(ie=>ie-1),children:"Previous"}),e.jsxs("span",{className:"text-sm text-gray-500",children:["Page ",ne," of ",ye]}),e.jsx(U,{size:"sm",variant:"soft",disabled:ne>=ye,onClick:()=>M(ie=>ie+1),children:"Next"})]})]})]})]}),e.jsx(Et,{open:!!S,onClose:()=>_(null),title:S?J2(S.contact):"",widthClass:"max-w-2xl",children:S&&e.jsx(W2,{data:S,mode:L,onProgress:i?H:void 0,onStatus:i?Z:void 0,onApproveCalling:i?Ae:void 0})})]})}function W2({data:s,mode:l,onProgress:i,onStatus:o,onApproveCalling:d}){const u=s.contact,x=/@no-email\.fantize\.local$/.test(u.email||"")?null:u.email,y={email_reply:"Email reply",meeting_booked:"Meeting booked",phone_call:"Phone call",manual:"Manual approval"},p=l!=="email_only"&&!u.hubspot_contact_id&&u.hubspot_sync_mode!=="lead"&&u.hubspot_sync_mode!=="qualified";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide mb-1.5",children:"Where this lead lives"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:K2(u).map((g,b)=>e.jsx(We,{kind:g.kind,label:g.label},b))})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(se,{tone:ip(u.internal_status),children:hm(u.internal_status)}),u.hubspot_lifecycle_stage&&e.jsx(se,{tone:"green",children:u.hubspot_lifecycle_stage}),u.hubspot_lead_status&&e.jsx(se,{tone:"blue",children:u.hubspot_lead_status}),u.qualification_source&&e.jsxs(se,{tone:"gray",children:["via ",y[u.qualification_source]||u.qualification_source]}),u.sync_status&&u.sync_status!=="none"&&e.jsxs(se,{tone:u.sync_status==="failed"?"red":"green",children:["sync: ",u.sync_status]}),u.call_task_status&&(()=>{const g=Z2[u.call_task_status]||{label:u.call_task_status,tone:"gray"};return e.jsx(se,{tone:g.tone,children:g.label})})()]}),p&&d&&e.jsx(Ne,{tone:"blue",children:e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{children:["Sync this lead to HubSpot as lifecycle stage ",e.jsx("b",{children:"âLeadâ"})," so reps can call it there. It is not created as an MQL."]}),e.jsx(U,{size:"sm",onClick:()=>d(u.id),children:"Approve for calling"})]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 text-sm",children:[e.jsx(ln,{label:"Email",value:x||(u.phone?"(none â phone only)":void 0)}),e.jsx(ln,{label:"Phone",value:u.phone}),e.jsx(ln,{label:"Company",value:u.company}),e.jsx(ln,{label:"Campaign",value:u.instantly_campaign||u.campaign_name}),e.jsx(ln,{label:"Source",value:u.lead_source}),e.jsx(ln,{label:"Owner",value:u.owner_id}),u.call_outcome&&e.jsx(ln,{label:"Last call outcome",value:`${u.call_outcome}${u.call_rep?` · ${u.call_rep}`:""}`}),u.mql_reason&&e.jsx(ln,{label:"Qualification reason",value:u.mql_reason})]}),u.last_reply_text&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide mb-1",children:"Last reply"}),e.jsx("div",{className:"text-sm bg-gray-50 dark:bg-gray-700/40 rounded-xl p-3 whitespace-pre-wrap",children:u.last_reply_text}),u.last_reply_summary&&e.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:["Summary: ",u.last_reply_summary]})]}),o&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Fantize status (nothing is sent)"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.internal_status!=="synced"&&u.sync_status!=="synced"&&e.jsx(U,{size:"sm",variant:"soft",onClick:()=>o(u.id,"ready_for_outreach"),children:"Mark ready for outreach"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>o(u.id,"disqualified"),children:"Disqualify"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>o(u.id,"suppressed"),children:"Suppress"})]})]}),i&&(u.hubspot_contact_id||u.internal_status==="synced")&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Sales progression (updates HubSpot)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Q2.filter(g=>g.action!=="disqualified").map(g=>e.jsx(U,{size:"sm",variant:"soft",onClick:()=>i(u.id,g.action),children:g.label},g.action))}),e.jsx("div",{className:"mt-2 border-t border-gray-100 dark:border-gray-700/60 pt-2",children:e.jsx(U,{size:"sm",variant:"danger",onClick:()=>{window.confirm("Mark this lead disqualified in HubSpot? This updates the HubSpot record.")&&i(u.id,"disqualified")},children:"Disqualified (updates HubSpot)"})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:"Recent activity"}),e.jsxs("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:[(s.events||[]).slice(0,20).map(g=>e.jsxs("div",{className:"text-xs flex items-center justify-between gap-2 border-b border-gray-100 dark:border-gray-700/50 py-1",children:[e.jsx("span",{className:"font-medium",children:g.event_type}),e.jsx("span",{className:"text-gray-500 truncate",children:g.decision}),e.jsx("span",{className:"text-gray-400 flex-shrink-0",children:Ke(g.created_at)})]},g.id)),(s.events||[]).length===0&&e.jsx("div",{className:"text-xs text-gray-400",children:"No events recorded."})]})]})]})}function ln({label:s,value:l}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-400 uppercase tracking-wide",children:s}),e.jsx("div",{className:"text-gray-800 dark:text-gray-200 truncate",children:l||"â"})]})}
61const Z2={created:{label:"HubSpot Call Task Created",tone:"green"},duplicate:{label:"Duplicate Open Task Found",tone:"amber"},missing_owner:{label:"Missing Owner / Needs Review",tone:"red"},failed:{label:"Task Creation Failed",tone:"red"}};function K2(s){const l=[],i=s.hubspot_sync_mode==="qualified"||["synced"].includes(s.internal_status)||/marketingqualified|salesqualified|opportunity|customer/i.test(s.hubspot_lifecycle_stage||"");return s.hubspot_contact_id?s.hubspot_sync_mode==="lead"&&!i&&l.push({label:"HubSpot Lead (calling)",kind:"connected"}):l.push({label:"Fantize only",kind:"info"}),i&&l.push({label:s.mql_at||/marketingqualified/i.test(s.hubspot_lifecycle_stage||"")?"HubSpot MQL":"HubSpot Qualified",kind:"ready"}),s.sequence_suppressed?l.push({label:`Suppressed from sequence${s.sequence_suppress_method?` (${String(s.sequence_suppress_method).replace("_"," ")})`:""}`,kind:"paused"}):(s.instantly_campaign||s.campaign_name)&&!i&&l.push({label:"Active email sequence",kind:"info"}),(s.internal_status==="cleanup_review"||s.cleanup_eligible_at&&!i&&new Date(s.cleanup_eligible_at)<=new Date)&&l.push({label:"Cleanup review",kind:"needs-review"}),l.length||l.push({label:hm(s.internal_status),kind:"info"}),l}function J2(s){return[s.first_name,s.last_name].filter(Boolean).join(" ")||s.email}function hm(s){return(s||"").replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase())}function ip(s){return["synced","qualified_for_sync"].includes(s)?"green":["qualified_for_review","replied"].includes(s)?"amber":["disqualified","suppressed","bounced"].includes(s)?"red":["delivered","contacted","sent_to_outbound"].includes(s)?"blue":"gray"}const e5=new Set(["approve_sync","mark_mql","mark_sal","mark_meeting_scheduled","edit_before_sync"]),Wg={review:"needs a human decision",mark_negative:"looks negative",ignore:"no action needed",suppress:"stop contacting"},op=[{key:"positive_interest",label:"Interested"},{key:"meeting_intent",label:"Wants to talk"},{key:"meeting_scheduled",label:"Meeting booked"},{key:"referral_wrong_contact",label:"Wrong person / referred us on"},{key:"neutral_ambiguous",label:"Unclear"},{key:"not_interested",label:"Not interested"},{key:"out_of_office",label:"Out of office"},{key:"unsubscribe",label:"Asked to be removed"},{key:"bounce_invalid",label:"Bounced / bad address"},{key:"spam_junk",label:"Spam / junk"}],Co=Object.fromEntries(op.map(s=>[s.key,s.label]));function t5(){const[s,l]=h.useState([]),{isAdmin:i}=zt(),[o,d]=h.useState(!0),[u,x]=h.useState("pending"),[y,p]=h.useState(""),[g,b]=h.useState([]),[f,k]=h.useState(0),[w,N]=h.useState(null),[j,T]=h.useState([]),[S,_]=h.useState(null),[z,A]=h.useState("");async function L(){d(!0);const we=(await je.reviews(u)).reviews||[];l(we),d(!1),u==="pending"&&D(we)}h.useEffect(()=>{L()},[u]);const F=3;async function D(R,we){const ie=++$.current,Ee=new Set(R.map(C=>C.id)),Je=new Map(R.map(C=>[C.id,(we&&we[C.id])??X(C)])),me=R.map(C=>C.id).filter(C=>H.current.get(C)!==Je.get(C));if(!me.length)return;me.forEach(C=>H.current.set(C,Je.get(C)||"")),M(C=>{const ve={...C};return me.forEach(Oe=>{ve[Oe]="loading"}),ve});let ke=0;const ze=async()=>{for(;ke<me.length;){const C=me[ke++];if(ie!==$.current||!Ee.has(C)){H.current.delete(C);continue}const ve=(Z.current.get(C)||0)+1;Z.current.set(C,ve);try{const Oe=await je.reviewInstantlySafety(C,Je.get(C));if(ie!==$.current||Z.current.get(C)!==ve)return;if(!Oe||!Oe.routing){M(dt=>({...dt,[C]:"error"})),oe(dt=>({...dt,[C]:"The safety check returned an incomplete result."}));continue}be(dt=>({...dt,[C]:Oe})),M(dt=>({...dt,[C]:"ok"}))}catch(Oe){if(ie!==$.current||Z.current.get(C)!==ve)return;be(dt=>{const Q={...dt};return delete Q[C],Q}),P(dt=>({...dt,[C]:!1})),M(dt=>({...dt,[C]:"error"})),oe(dt=>({...dt,[C]:Oe?.message||"The safety check could not be completed."})),H.current.delete(C)}}};await Promise.all(Array.from({length:Math.min(F,me.length)},ze))}h.useEffect(()=>{je.team().then(R=>T((R.team||[]).filter(we=>we.active))).catch(()=>{})},[]),h.useEffect(()=>{je.settings().then(R=>_(R.settings.notify_config)).catch(()=>{})},[]),h.useEffect(()=>{je.dncCount().then(R=>k(R.count||0)).catch(()=>{})},[]);function te(R){p(R),setTimeout(()=>p(""),3e3)}const[pe,he]=h.useState({}),X=R=>pe[R.id]??(R.model_classification||R.classification||"");function I(R,we){he(ie=>({...ie,[R.id]:we})),P(ie=>({...ie,[R.id]:!1})),M(ie=>({...ie,[R.id]:"loading"})),D([{...R,__cat:we}],{[R.id]:we})}const[q,be]=h.useState({}),[ne,M]=h.useState({}),[Y,oe]=h.useState({}),[Ce,Ae]=h.useState({}),H=h.useRef(new Map),Z=h.useRef(new Map),$=h.useRef(0),[O,P]=h.useState({});async function V(R,we){if(Ce[R])return;const ie=we??H.current.get(R)??"";Ae(Ee=>({...Ee,[R]:!0}));try{const Ee=await je.reviewInstantlySafety(R,ie),Je=q[R]&&q[R].enrollment_snapshot_hash;be(me=>({...me,[R]:Ee})),M(me=>({...me,[R]:Ee&&Ee.routing?"ok":"error"})),(!Ee||!Ee.routing)&&oe(me=>({...me,[R]:"The safety check returned an incomplete result."})),H.current.set(R,ie),(!Je||Je!==(Ee&&Ee.enrollment_snapshot_hash))&&P(me=>({...me,[R]:!1})),te(Ee.safe?"Instantly re-checked: this lead is safe to approve.":"Instantly re-checked: still not safe to approve.")}catch(Ee){be(Je=>{const me={...Je};return delete me[R],me}),M(Je=>({...Je,[R]:"error"})),oe(Je=>({...Je,[R]:Ee?.message||"Unknown error"})),P(Je=>({...Je,[R]:!1})),H.current.delete(R),te("Could not complete the Instantly safety check.")}Ae(Ee=>({...Ee,[R]:!1}))}const ye=R=>{if(ne[R]!=="ok")return!0;const ie=q[R];return!ie||ie.approval_possible!==!0||ie.verified===!1||ie.action&&ie.action.outcome==="safety_unknown"||!ie.routing||ie.routing.safe!==!0||!ie.routing_snapshot_hash||Array.isArray(ie.enrollments)&&ie.enrollments.some(Ee=>Ee.subsequence_status===1||Ee.subsequences_known===!1)||ie.safe===!1&&!ie.requires_confirmation?!0:ie.requires_confirmation?!O[R]||!ie.enrollment_snapshot_hash:!1},ge=R=>{const we=ne[R];return we==="loading"||we===void 0?"Checking routing and Instantly safety...":we==="error"?"Safety check unavailable":""},qe=R=>{const we=q[R];if(!we)return{};const ie={};return we.enrollment_snapshot_hash&&(ie.confirm_workspace_scope=!!O[R],ie.enrollment_snapshot_hash=we.enrollment_snapshot_hash),we.routing_snapshot_hash&&(ie.routing_snapshot_hash=we.routing_snapshot_hash),ie};async function nt(R,we,ie={}){if(!(we==="suppress"&&!window.confirm(`Add this address to the do-not-contact list? 62 63⢠Adds the exact email address to Instantlyâs workspace block list 64⢠Adds it to Fantizeâs do-not-contact list 65⢠Affects every campaign using that exact address 66⢠Does not delete engagement history 67⢠An active or unknown Instantly subsequence may still need an administrator to verify it 68 69If you only mean "they said no", use "Not interested â stop follow-ups" instead.`))&&!z){A(R+we);try{const Ee=await je.reviewAction(R,{action:we,...ie}),Je=s.find(ke=>ke.id===R)||{}
69,me=[Je.first_name,Je.last_name].filter(Boolean).join(" ")||Je.email||"this lead";he(ke=>{const ze={...ke};return delete ze[R],ze}),be(ke=>{const ze={...ke};return delete ze[R],ze}),e5.has(we)?b(ke=>[...ke,{key:`${R}-${Date.now()}`,text:`Approved and queued for HubSpot sync â ${me}.`,detail:Ee&&Ee.sync_job?"You can follow it in Sync Errors if it does not complete.":void 0}]):te(s5(we)),await L()}catch(Ee){Ee?.status===409&&Ee?.payload?.held?(be(Je=>({...Je,[R]:Ee.payload})),P(Je=>({...Je,[R]:!1})),te("Not approved â this lead may still receive Instantly emails.")):te(Ee.message||"Action failed")}A("")}}return e.jsxs("div",{className:"max-w-5xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Reply Review (legacy)",subtitle:"The former queue, kept as a rollback destination for administrators. Day-to-day review happens in Reply Review."}),y&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"green",children:y})}),i&&f>0&&e.jsx("div",{className:"mb-4",children:e.jsxs(Ne,{tone:"amber",children:[f," do-not-contact ",f===1?"request needs":"requests need"," attention: the Instantly block could not be confirmed, so an active campaign could still reach ",f===1?"that address":"those addresses","."," ",e.jsx(Se,{to:"/dashboard/leads/do-not-contact",className:"underline font-medium",children:"Review them"})]})}),g.length>0&&e.jsx("div",{className:"mb-4 space-y-2",role:"status","aria-live":"polite",children:g.map(R=>e.jsxs("div",{className:"rounded-xl border border-emerald-300 dark:border-emerald-800 bg-emerald-50 dark:bg-emerald-900/20 p-3 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"text-sm text-emerald-900 dark:text-emerald-200",children:[e.jsx("div",{className:"font-medium",children:R.text}),R.detail&&e.jsx("div",{className:"text-xs text-emerald-900/80 dark:text-emerald-200/80",children:R.detail})]}),e.jsx("button",{className:"text-xs text-emerald-900/70 dark:text-emerald-200/70 hover:underline flex-shrink-0",onClick:()=>b(we=>we.filter(ie=>ie.key!==R.key)),children:"Dismiss"})]},R.key))}),e.jsx(Xl,{tabs:[{key:"pending",label:"Pending"},{key:"resolved",label:"Resolved"}],active:u,onChange:x}),e.jsx("div",{className:"mt-4 space-y-3",children:o?e.jsx(tt,{label:"Loading review queueâ¦"}):s.length===0?e.jsx(Ze,{title:"Nothing to review",hint:"Replies that need judgment will land here. High-confidence positives auto-sync; clear negatives are suppressed automatically."}):s.map(R=>e.jsxs(_e,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[[R.first_name,R.last_name].filter(Boolean).join(" ")||R.email,R.company&&e.jsxs("span",{className:"text-gray-400 font-normal",children:[" · ",R.company]})]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[R.email," ",R.campaign_name&&`· ${R.campaign_name}`," ",R.lead_source&&`· ${R.lead_source}`," · ",Ke(R.occurred_at||R.created_at)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[R.event_type==="phone_call"?e.jsxs(se,{tone:"blue",children:["ð ",R.call_outcome||"call"]}):R.classification&&e.jsx(se,{tone:"amber",children:R.classification}),R.event_type!=="phone_call"&&R.confidence!=null&&e.jsxs(se,{tone:"gray",children:["conf ",R.confidence]}),e.jsx(se,{tone:"gray",children:R.event_type==="phone_call"?"phone":R.classification_method||"rule"}),R.hubspot_contact_id&&e.jsx(se,{tone:"green",children:"In HubSpot"})]})]}),e.jsx("div",{className:"text-xs text-gray-500",children:R.reason}),e.jsxs("div",{className:"rounded-xl bg-gray-50 dark:bg-gray-700/30 p-2.5 text-xs space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-gray-400",children:"Proposed:"})," ",R.proposed_stage_label?e.jsxs(se,{tone:"green",children:[R.proposed_stage_label," · ",R.proposed_lead_status]}):e.jsx("span",{className:"text-gray-400",children:"pending your decision"})]}),ne[R.id]==="ok"&&q[R.id]&&q[R.id].routing?e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-gray-400",children:"Owner:"})," ",q[R.id].routing.current_owner_id?e.jsx(se,{tone:q[R.id].routing.safe?"green":"amber",children:q[R.id].routing.current_owner_id}):e.jsx(se,{tone:"red",children:"no confirmed owner"})]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-gray-400",children:"Mapping:"})," ",q[R.id].routing.mapping_active===!0?e.jsx(se,{tone:"green",children:"active"}):q[R.id].routing.mapping_active===!1?e.jsx(se,{tone:"red",children:"inactive"}):e.jsx(se,{tone:"red",children:"none"})]}),q[R.id].routing.fallback===!0&&e.jsx(se,{tone:"amber",children:"fallback rout
69ing"}),q[R.id].routing.safe?e.jsx(se,{tone:"green",children:"Routing confirmed"}):e.jsx(se,{tone:"red",children:q[R.id].routing.reason})]}):e.jsx(e.Fragment,{children:e.jsxs("span",{children:[e.jsx("span",{className:"text-gray-400",children:"Owner:"})," ",e.jsx(se,{tone:"gray",children:ne[R.id]==="error"?"unconfirmed":"checking..."})]})}),R.assigned_owner_name&&e.jsxs("span",{className:"text-gray-400",children:["At ingestion: ",R.assigned_owner_name]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-gray-500",children:[(R.instantly_campaign||R.campaign_name)&&e.jsxs("span",{children:[e.jsx("span",{className:"text-gray-400",children:"Campaign:"})," ",R.instantly_campaign||R.campaign_name]}),R.qualification_reason&&e.jsxs("span",{children:[e.jsx("span",{className:"text-gray-400",children:"Reason:"})," ",R.qualification_reason]}),R.event_type==="phone_call"&&e.jsxs("span",{children:[e.jsx("span",{className:"text-gray-400",children:"Call:"})," ",R.call_outcome,R.call_rep?` · ${R.call_rep}`:"",R.phone?` · ${R.phone}`:""]}),R.qualification_source&&e.jsxs("span",{children:[e.jsx("span",{className:"text-gray-400",children:"Source:"})," ",e.jsx(se,{tone:"gray",children:{email_reply:"Email",meeting_booked:"Meeting",phone_call:"Phone",manual:"Manual"}[R.qualification_source]||R.qualification_source})]}),R.assigned_owner_reason&&e.jsxs("span",{children:[e.jsx("span",{className:"text-gray-400",children:"Routing:"})," ",R.assigned_owner_reason]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-gray-400",children:"Notify:"})," ",S&&S.methods?.length?S.methods.map(we=>we.replace("_"," ")).join(", "):"not set"]})]}),(R.sync_warnings||[]).length>0&&e.jsxs("div",{className:"text-amber-700 dark:text-amber-400",children:["â ",R.sync_warnings.join(" · ")]})]}),R.reply_text&&e.jsx("div",{className:"text-sm bg-gray-50 dark:bg-gray-700/40 rounded-xl p-3 whitespace-pre-wrap",children:R.reply_text}),R.reply_summary&&e.jsxs("div",{className:"text-xs text-gray-500",children:["AI summary: ",R.reply_summary]}),Wg[R.recommended_action]&&e.jsxs("div",{className:"text-xs text-gray-400",children:["Suggested handling: ",Wg[R.recommended_action],e.jsx("span",{className:"ml-1 text-gray-400",children:"(your decision below is what applies)"})]}),u==="pending"&&e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-gray-700 p-3 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-400",children:"Suggested:"}),R.model_classification?e.jsx(se,{tone:"gray",children:Co[R.model_classification]||R.model_classification}):e.jsx("span",{className:"text-gray-400",children:"none â the classifier could not read this reply"}),R.model_confidence!=null&&e.jsxs("span",{className:"text-gray-400",children:["confidence ",R.model_confidence]}),R.suggestion_method&&e.jsxs("span",{className:"text-gray-400",children:["by ",R.suggestion_method==="rule"?"a fixed rule":"AI",R.suggestion_method==="ai"&&R.model_name?` (${R.model_name})`:""]})]}),e.jsxs("label",{className:"block text-xs text-gray-500",children:["Your category â this is what gets recorded",e.jsxs("select",{className:"mt-1 block w-full min-h-11 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-2 py-1.5 text-sm",value:X(R),onChange:we=>I(R,we.target.value),children:[e.jsx("option",{value:"",children:"Choose a categoryâ¦"}),op.map(we=>e.jsxs("option",{value:we.key,children:[we.label,R.model_classification===we.key?" â suggested":""]},we.key))]})]}),X(R)&&R.model_classification&&X(R)!==R.model_classification&&e.jsx("div",{className:"text-xs text-amber-700 dark:text-amber-400",children:"You are changing the suggestion. Both versions are kept."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{size:"sm",variant:"soft",disabled:!!z,title:"Records this reply as not usable for measuring the classifier, and closes the item.",onClick:()=>nt(R.id,"ignore",{reject_classification:!0}),children:"Canât categorize this"}),e.jsx("span",{className:"text-xs text-gray-400",children:X(R)?`Will be recorded as â${Co[X(R)]||X(R)}â`:"Pick a category before approving"})]})]}),u==="pending"&&q[R.id]&&e.jsxs("div",{className:"rounded-xl border p-3 space-y-2 text-sm "+((q[R.id].action||{}).outcome==="already_stopped"&&q[R.id].approval_possible!==!1?"border-green-300 bg-green-50 dark:border-green-800 dark:bg-green-900/20":"border-amber-300 bg-amber-50 dark:border-amber-800 dark:bg-amber-900/20"),children:[(()=>{const we=q[R.id].action||{},ie=q[R.id].approval_possible===!1?"routing_blocked":we.outcome;return ie==="routing_blocked"?e.jsx("div",{className:"font-medium text-amber-900 dark:text-amber-200",children:q[R.id].headline}):ie==="already_stopped"&&we.reason==="not_enrolled"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-medium text-green-800 dark:text-green-300",children:"No Instantly campaign enrollment was found."}),e.jsx("div",{className:"text-green-900/80 dark:text-green-200/80",children:"The completed safety check found no campaign enrollment for this email address. No Instantly update is expected."})]}):ie==="already_stopped"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-medium text-green-800 dark:text-green-300",children:"Instantly follow-ups are already stopped for the main campaign sequence."}),e.jsx("div",{className:"text-green-900/80 dark:text-green-200/80",children:we.intended_status!=null?`Every listed enrollment already has the intended status (${we.intended_status}). No Instantly update is expected.`:"Every listed enrollment already carries a non-default status. No Instantly update is expected."})]}):ie==="status_update_required"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"font-medium text-amber-900 dark:text-amber-200",children:["Approval will update this email addressâs Instantly status",we.intended_status!=null?` to ${we.intended_status}`:""," across all listed enrollments and stop automated follow-ups for the main campaign sequence."]}),e.jsx("div",{className:"text-amber-900/85 dark:text-amber-200/85",children:"Nothing is deleted, blockl
69isted or removed at the provider."})]}):ie==="manual_stop_required"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-medium text-amber-900 dark:text-amber-200",children:"Fantize cannot safely stop this lead through the Instantly API."}),e.jsxs("ul",{className:"list-disc ml-5 text-amber-900/85 dark:text-amber-200/85 space-y-0.5",children:[e.jsx("li",{children:"Stop the lead manually in Instantly, then check again."}),e.jsxs("li",{children:["This lead was ",e.jsx("strong",{children:"not"})," synced to HubSpot."]}),e.jsx("li",{children:"Nothing was deleted, blocklisted or changed in Instantly."})]}),we.detail&&e.jsx("div",{className:"text-xs text-amber-900/70 dark:text-amber-200/70",children:we.detail})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-medium text-amber-900 dark:text-amber-200",children:"Fantize could not verify the leadâs Instantly state."}),e.jsx("div",{className:"text-amber-900/85 dark:text-amber-200/85",children:"Approval remains blocked until the check succeeds."})]})})(),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1 text-xs text-gray-700 dark:text-gray-300",children:[q[R.id].campaign_name&&e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Campaign:"})," ",q[R.id].campaign_name]}),q[R.id].campaign_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Campaign ID:"})," ",e.jsx("code",{children:q[R.id].campaign_id})]}),q[R.id].lead_email&&e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Lead:"})," ",q[R.id].lead_email]}),q[R.id].instantly_lead_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Instantly lead ID:"})," ",e.jsx("code",{children:q[R.id].instantly_lead_id})]}),q[R.id].remaining_steps!=null&&e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Steps remaining:"})," ",q[R.id].remaining_steps,q[R.id].total_steps!=null?` of ${q[R.id].total_steps}`:""]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Provider check:"})," ",q[R.id].verified===!1?e.jsx("span",{className:"text-amber-700 dark:text-amber-400",children:"could not be completed"}):e.jsx("span",{className:"text-emerald-700 dark:text-emerald-400",children:"completed"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Instantly main sequence:"})," ",q[R.id].verified===!1?"unknown":q[R.id].basis==="not_enrolled"?"no campaign enrollment found":q[R.id].basis==="stopped_by_interest_status"?"stopped by existing interest status":q[R.id].basis==="sequence_complete"?"complete â no steps remain":q[R.id].basis==="stopped_by_reply"?"stopped by a verified reply":q[R.id].basis==="flagged_manual"?"not stopped â needs a manual stop":String(q[R.id].basis||"unknown")]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Subsequence:"})," ",q[R.id].verified===!1?"unknown":q[R.id].action&&q[R.id].action.subsequence_blocking?"active or unverifiable":"none active"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Routing:"})," ",q[R.id].routing?q[R.id].routing.safe?"confirmed":"not configured":"unknown"]}),q[R.id].checked_at&&e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Checked:"})," ",Ke(q[R.id].checked_at)]})]}),q[R.id].detail&&e.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("span",{className:"text-gray-500",children:"Instantly detail:"})," ",q[R.id].detail]}),q[R.id].routing&&q[R.id].routing.safe===!1&&e.jsxs("div",{className:"rounded-lg border border-red-300 dark:border-red-800 bg-white/60 dark:bg-gray-900/30 p-3 space-y-1 text-xs",children:[e.jsx("div",{className:"font-medium text-red-800 dark:text-red-300",children:"Not synced â this lead has no confirmed owner to route to."}),e.jsx("div",{className:"text-red-900/85 dark:text-red-200/85",children:q[R.id].routing.routing_message}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-0.5 text-gray-700 dark:text-gray-300 pt-1",children:[q[R.id].routing.campaign_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Campaign:"})," ",e.jsx("code",{children:q[R.id].routing.campaign_id})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Mapping:"})," ",q[R.id].routing.mapping_active===!0?"active":q[R.id].routing.mapping_active===!1?"inactive":"none"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Routing source:"})," ",q[R.id].routing.routing_source||"none"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Current owner:"})," ",q[R.id].routing.current_owner_id||"none",q[R.id].routing.owner_active===!1&&e.jsx("span",{className:"text-red-700 dark:text-red-400",children:" · inactive"})]}),q[R.id].routing.routing_changed&&e.jsxs("div",{className:"sm:col-span-2 text-amber-800 dark:text-amber-300",children:["Owner
69changed since this reply arrived: was ",q[R.id].routing.ingested_owner_id||"none",", now ",q[R.id].routing.current_owner_id||"none",". Re-check to confirm the current routing."]})]}),e.jsx("div",{className:"text-gray-500 pt-1",children:"Nothing was sent to HubSpot. Fix the mapping or owner, then re-check."})]}),q[R.id].enrollment_count>1?e.jsxs("div",{className:"rounded-lg border border-amber-400 dark:border-amber-700 bg-white/60 dark:bg-gray-900/30 p-3 space-y-2",children:[e.jsxs("div",{className:"font-medium text-amber-900 dark:text-amber-200",children:["This email address is enrolled in ",q[R.id].enrollment_count," Instantly campaigns. Instantly applies interest status to the address, so any change reaches all of them."]}),q[R.id].enrollments_are_last_known&&e.jsxs("div",{className:"text-xs text-amber-800 dark:text-amber-300",children:["Last known information, not confirmed just now â the provider check could not be completed",q[R.id].enrollments_last_verified_at?` (read at ${Ke(q[R.id].enrollments_last_verified_at)})`:"","."]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"text-xs w-full",children:[e.jsx("thead",{className:"text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left pr-3 py-1",children:"Campaign"}),e.jsx("th",{className:"text-left pr-3",children:"State"}),e.jsx("th",{className:"text-left pr-3",children:"Mapping"}),e.jsx("th",{className:"text-right pr-3",children:"Steps left"}),e.jsx("th",{className:"text-left pr-3",children:"Current status"})]})}),e.jsx("tbody",{children:q[R.id].enrollments.map(we=>e.jsxs("tr",{className:"border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("td",{className:"pr-3 py-1",children:[we.campaign_name||"Unnamed",we.is_source_campaign&&e.jsx(se,{tone:"blue",children:"this review"}),e.jsx("div",{className:"text-gray-400",children:e.jsx("code",{children:we.campaign_id})})]}),e.jsx("td",{className:"pr-3",children:we.campaign_state}),e.jsx("td",{className:"pr-3",children:we.mapping_state==="active"?e.jsxs("span",{className:"text-emerald-700 dark:text-emerald-400",children:["active",we.mapping_owner_id?` · owner ${we.mapping_owner_id}`:""]}):we.mapping_state==="inactive"?e.jsx("span",{className:"text-amber-700 dark:text-amber-400",children:"inactive"}):e.jsx("span",{className:"text-gray-400",children:"no Fantize mapping"})}),e.jsx("td",{className:"pr-3 text-right tabular-nums",children:we.remaining_steps??"?"}),e.jsxs("td",{className:"pr-3",children:[we.interest_status==null?"none":we.interest_status,we.subsequence_status===1&&e.jsx("span",{className:"ml-1 text-amber-700 dark:text-amber-400",children:"· active subsequence"})]})]},we.lead_id))})]})}),q[R.id].subsequence_note&&e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:q[R.id].subsequence_note}),e.jsx("div",{className:"text-xs text-gray-500",children:"Other campaigns are listed because Instantly applies interest status to the email address, not to one enrollment. They do not need a Fantize mapping for this reviewâs HubSpot handoff."}),e.jsx("div",{className:"text-xs text-gray-500",children:q[R.id].attribution_note}),q[R.id].requires_confirmation&&q[R.id].confirmation_label&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-2 min-h-11 text-xs text-gray-800 dark:text-gray-200 cursor-pointer",children:[e.jsx("span",{className:"flex h-11 w-11 -ml-2.5 flex-none items-center justify-center",children:e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500",checked:!!O[R.id],onChange:we=>P(ie=>({...ie,[R.id]:we.target.checked}))})}),e.jsx("span",{children:q[R.id].confirmation_label})]}),!O[R.id]&&e.jsx("div",{className:"text-xs text-amber-700 dark:text-amber-400",children:"Approval stays blocked until this is confirmed."})]})]}):q[R.id].subsequence_note?e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:q[R.id].subsequence_note}):null,e.jsx(U,{size:"sm",variant:"soft",disabled:!!Ce[R.id],title:"Re-reads the lead and campaign in Instantly. This only reads â it never changes anything at the provider and never approves the lead.",onClick:()=>V(R.id,X(R)),children:Ce[R.id]?"Checking Instantlyâ¦":"Check Instantly Again"})]}),u==="pending"&&ne[R.id]!=="ok"&&e.jsx("div",{className:`rounded-lg border p-2.5 text-xs ${ne[R.id]==="error"?"border-red-300 dark:border-red-800 bg-red-50/60 dark:bg-red-950/20":"border-gray-200 dark:border-gray-700 bg-gray-50/70 dark:bg-gray-800/40"}`,children:ne[R.id]==="error"?e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"font-medium text-red-800 dark:text-red-300",children:"Safety check unavailable"}),e.jsx("div",{className:"text-red-900/85 dark:text-red-200/85",children:"Routing and Instantly safety could not be confirmed, so approv
69ing is disabled. Use âCheck Instantly Againâ to retry; if it keeps failing, an administrator should check the Instantly and HubSpot connections before anyone approves this lead."}),Y[R.id]&&e.jsxs("div",{className:"text-gray-500",children:["Detail: ",Y[R.id]]})]}):e.jsx("div",{className:"text-gray-600 dark:text-gray-300",children:ge(R.id)})}),u==="pending"?e.jsxs("div",{className:"flex flex-wrap gap-2 pt-1",children:[e.jsx(U,{size:"sm",variant:"success",disabled:!!z||!X(R)||ye(R.id),title:"Marks this a qualified lead (MQL) and sends it to HubSpot for follow-up.",onClick:()=>nt(R.id,"approve_sync",{final_classification:X(R),...qe(R.id)}),children:"Approve as qualified lead"}),e.jsx(U,{size:"sm",variant:"soft",disabled:!!z||!X(R)||ye(R.id),title:"Records that a meeting is booked and hands the lead to sales (SAL) in HubSpot.",onClick:()=>nt(R.id,"mark_meeting_scheduled",{final_classification:X(R),...qe(R.id)}),children:"Meeting booked â hand to sales"}),e.jsx(U,{size:"sm",variant:"soft",disabled:!!z||ye(R.id),title:"Change the name, company or stage before anything is sent to HubSpot.",onClick:()=>N(R),children:"Edit before sync"}),e.jsx(U,{size:"sm",variant:"ghost",disabled:!!z||!X(R),title:"Stops automated Instantly follow-ups for this address and records the reply. Nothing is sent to HubSpot.",onClick:()=>nt(R.id,"mark_not_interested",{final_classification:X(R),...qe(R.id)}),children:"Not interested â stop follow-ups"}),e.jsx(U,{size:"sm",variant:"ghost",disabled:!!z||!X(R),title:"Adds the address to Fantizeâs do-not-contact list and Instantlyâs workspace block list. Use for unsubscribes and complaints.",onClick:()=>nt(R.id,"suppress",{final_classification:X(R),...qe(R.id)}),children:"Never contact again"}),e.jsx(U,{size:"sm",variant:"ghost",disabled:!!z||!X(R),title:"Record this review and allow automated outreach to continue. Nothing is sent to HubSpot.",onClick:()=>nt(R.id,"keep_in_outreach",{final_classification:X(R),...qe(R.id)}),children:"Keep in outreach"}),i&&j.length>0&&e.jsxs("select",{className:de+" w-auto text-sm",defaultValue:"",onChange:we=>{we.target.value&&nt(R.id,"assign_owner",{member_id:we.target.value})},children:[e.jsx("option",{value:"",children:"Reassign ownerâ¦"}),j.map(we=>e.jsx("option",{value:we.id,children:we.name},we.id))]})]}):e.jsxs("div",{className:"text-xs text-gray-500 space-y-0.5",children:[e.jsxs("div",{children:["Resolved: ",e.jsx("span",{className:"font-medium",children:R.resolution})," ",R.resolved_by&&`by ${R.resolved_by}`," ",R.resolved_at&&`· ${Ke(R.resolved_at)}`]}),(R.model_classification||R.final_classification)&&e.jsxs("div",{children:["Suggested ",e.jsx("span",{className:"font-medium",children:Co[R.model_classification]||R.model_classification||"none"}),R.model_confidence!=null&&` (${R.model_confidence})`," · ","recorded ",e.jsx("span",{className:"font-medium",children:R.final_classification?Co[R.final_classification]||R.final_classification:"not categorized"}),R.model_agreement&&e.jsx(se,{tone:R.model_agreement==="accepted"?"green":R.model_agreement==="corrected"?"amber":"gray",children:R.model_agreement})]})]})]},R.id))}),e.jsx(a5,{review:w,onClose:()=>N(null),onSubmit:async(R,we)=>{await nt(w.id,"edit_before_sync",{intent:R,edits:we,final_classification:X(w),...qe(w.id)}),N(null)}})]})}function a5({review:s,onClose:l,onSubmit:i}){const[o,d]=h.useState({}),[u,x]=h.useState("mql");return h.useEffect(()=>{s&&(d({first_name:s.first_name||"",last_name:s.last_name||"",company:s.company||""}),x("mql"))},[s]),s?e.jsx(Et,{open:!!s,onClose:l,title:"Edit before sync",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(U,{variant:"ghost",onClick:l,children:"Cancel"}),e.jsx(U,{variant:"success",onClick:()=>i(u,o),children:"Sync to HubSpot"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(le,{label:"First name",children:e.jsx("input",{className:de,value:o.first_name||"",onChange:y=>d({...o,first_name:y.target.value})})}),e.jsx(le,{label:"Last name",children:e.jsx("input",{className:de,value:o.last_name||"",onChange:y=>d({...o,last_name:y.target.value})})}),e.jsx(le,{label:"Company",children:e.jsx("input",{className:de,value:o.company||"",onChange:y=>
69d({...o,company:y.target.value})})}),e.jsx(le,{label:"Sync as",children:e.jsxs("select",{className:de,value:u,onChange:y=>x(y.target.value),children:[e.jsx("option",{value:"mql",children:"MQL â Engaged with Outreach"}),e.jsx("option",{value:"sal",children:"SAL â Meeting Scheduled"})]})})]})}):null}function s5(s){return{approve_sync:"Approved as a qualified lead â sending to HubSpot.",mark_mql:"Approved as a qualified lead â sent to HubSpot.",mark_sal:"Handed to sales â sent to HubSpot.",mark_meeting_scheduled:"Meeting booked â handed to sales in HubSpot.",edit_before_sync:"Sent to HubSpot with your edits.",mark_not_interested:"Marked not interested. They stay on the list.",mark_disqualified:"Disqualified. They will not be queued for calling.",suppress:"Added to the do-not-contact list. No campaign can email them again.",assign_owner:"Owner assigned.",ignore:"Kept in outreach.",keep_in_outreach:"Kept in outreach (Instantly)."}[s]||"Done."}const n5={new_issuer_lead:"New issuer lead",existing_issuer_question:"Existing client",investor_support:"Investor support",general_inquiry:"General inquiry",spam_or_noise:"Spam or noise",needs_review:"Needs review"},r5={new_issuer_lead:"green",existing_issuer_question:"blue",investor_support:"blue",general_inquiry:"gray",spam_or_noise:"gray",needs_review:"amber"},Zg={new:"Not yet classified",classified:"Classified",needs_review:"Waiting for a person",routed:"Routed",closed:"Closed"};function l5(s){const l=s.last_message_at||s.first_message_at||s.created_at,i=Dr(l);if(!i)return"â";const o=i.toDateString()===new Date().toDateString(),d=Yf(l,{hour:"2-digit",minute:"2-digit"});return o?`Today ${d}`:`${Ke(l,{day:"numeric",month:"short"})} ${d}`}function i5({value:s,method:l}){if(s==null)return e.jsx("span",{className:"text-gray-400",children:"â"});const i=Math.round(s*100),o=i>=85?"bg-emerald-500":i>=70?"bg-blue-500":"bg-amber-500";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-1.5 w-12 rounded-full bg-gray-200 dark:bg-gray-700","aria-hidden":"true",children:e.jsx("div",{className:`h-1.5 rounded-full ${o}`,style:{width:`${Math.max(i,3)}%`}})}),e.jsxs("span",{className:"tabular-nums text-xs text-gray-600 dark:text-gray-300",title:l?`Decided by ${l}`:void 0,children:[i,"%"]})]})}function o5({item:s}){const l=!!(s.research_match_id||s.contact_id||s.lifecycle_id),i=!!s.internal_found;return!l&&!i?s.internal_checked_at?e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"New to both"}):e.jsx("span",{className:"text-xs text-gray-400",children:"Not checked yet"}):e.jsxs("div",{className:"space-y-1",children:[l&&e.jsxs("div",{children:[e.jsx(se,{tone:"blue",children:"In Fantize"}),s.research_match_id&&e.jsx("div",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:"Already a lead"}),!s.research_match_id&&(s.contact_id||s.lifecycle_id)&&e.jsx("div",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:"Already a contact"})]}),i&&e.jsxs("div",{children:[e.jsx(se,{tone:"green",children:"In HubSpot"}),e.jsxs("div",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:[s.hubspot_lifecycle||"no lifecycle set",s.hubspot_owner?` · ${s.hubspot_owner}`:""]}),s.hubspot_matched_on&&e.jsxs("div",{className:"text-xs text-gray-400",children:["matched on ",s.hubspot_matched_on.replace(/_/g," ")]})]})]})}function c5({item:s}){const l=s.company_name||(s.from_domain&&!s.from_domain.includes("gmail")?s.from_domain:null);return e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-medium text-gray-900 dark:text-gray-100",children:s.from_name||s.from_email||"Unknown sender"}),e.jsxs("div",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:[s.from_name&&s.from_email?s.from_email:null,s.from_name&&s.from_email&&l?" · ":null,l]})]})}function d5(){const[s,l]=h.useState(null),[i,o]=h.useState(null),[d,u]=h.useState(!0),[x,y]=h.useState("needs_review"),[p,g]=h.useState(""),[b,f]=h.useState("");h.useEffect(()=>{let j=!1;return u(!0),je.inbound({status:x||void 0,route:p||void 0,limit:200}).then(T=>{j||(l(T),o(null))}).catch(T=>{j||o(T?.message||"Could not load inbound mail.")}).finally(()=>{j||u(!1)}),()=>{j=!0}},[x,p]);const k=h.useMemo(()=>{const j=s?.items||[],T=b.trim().toLowerCase();return T?j.filter(S=>[S.from_email,S.from_name,S.company_name,S.from_domain,S.subject].some(_=>(_||"").toLowerCase().includes(T))):j},[s,b]),w=s?.counts||{},N=w.needs_review||0;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Xe,{title:"Inbound Review",subtitle:"Mail that arrived at a shared mailbox, with what Fantize thinks each one is. Nothing here has been replied to.",status:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[N>0&&e.jsxs(se,{tone:"amber",children:[N," waiting for a person"]}),w.routed?e.jsxs(se,{tone:"green",children:[w.routed," routed"]}):null,w.new?e.jsxs(se,{tone:"gray",children:[w.new," not yet classified"]}):null]})}),i&&e.jsxs(Ne,{tone:"red",children:["Could not load inbound mail. ",i]}),e.jsxs(_e,{children:[e.jsxs(Hn,{search:{value:b,onChange:f,placeholder:"Sender, company or subject"},summary:d?void 0:`${k.length} of ${s?.items.length??0} shown`,onClear:()=>{f(""),y(""),g("")},children:[e.jsx(ha,{label:"Status",value:x,onChange:y,options:[{value:"",label:"Any status"},...Object.keys(Zg).map(j=>({value:j,label:Zg[j]}))]}),e.jsx(ha,{label:"Desk",value:p,onChange:g,options:[{value:"",label:"Any desk"},...(s?.destinations||[]).map(j=>({value:j,label:j.replace(/_/g," ")}))]})]}),d?e.jsx(tt,{label:"Reading the mailbox record"}):k.length===0?e.jsx(Ze,{title:x==="needs_review"?"Nothing is waiting for a person":"No inbound mail here",hint:(s?.items.length??0)===0&&!b?"Mail appears here once intake is connected to a mailbox. Nothing is sent from this page.":"Try a different status or desk, or clear the filters."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:Hr,children:[e.jsx("th",{className:"px-3 py-2 text-left",children:"Sender"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Company"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Subject"}),e.jsx("th",{className:"px-3 py-2 text-left whitespace-nowrap",children:"Received"}),e.jsx("th",{className:"px-3 py-2 text-left whitespace-nowrap",children:"Already known"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Classification"}),e.jsx("th",{className:"px-3 py-2 text-left whitespace-nowrap",children:"Confidence"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Reason"})]})}),e.jsx("tbody",{children:k.map(j=>{const T=j.final_classification||j.classification;return e.jsxs("tr",{className:Ql,children:[e.jsx("td",{className:"px-3 py-2 max-w-[14rem]",children:e.jsx(c5,{item:j})}),e.jsxs("td",{className:"px-3 py-2 max-w-[12rem]",children:[e.jsx("div",{className:"truncate text-gray-800 dark:text-gray-200",children:j.company_name||"â"}
69),j.company_source&&e.jsxs("div",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:["from ",j.company_source.replace(/_/g," ")]})]}),e.jsxs("td",{className:"px-3 py-2 max-w-[20rem]",children:[e.jsx(Se,{to:`/dashboard/leads/inbound/${j.id}`,className:"block truncate font-medium text-blue-700 hover:underline dark:text-blue-400",children:j.subject||"(no subject)"}),j.message_count>1&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[j.message_count," messages"]})]}),e.jsx("td",{className:"px-3 py-2 whitespace-nowrap text-gray-600 dark:text-gray-300",children:l5(j)}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(o5,{item:j})}),e.jsxs("td",{className:"px-3 py-2",children:[T?e.jsx(se,{tone:r5[T]||"gray",children:n5[T]||T}):e.jsx("span",{className:"text-gray-400",children:"Not yet classified"}),j.final_classification&&e.jsx("div",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:"Decided by a person"})]}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(i5,{value:j.confidence,method:j.classification_method})}),e.jsxs("td",{className:"px-3 py-2 max-w-[22rem]",children:[e.jsx("div",{className:"truncate text-gray-700 dark:text-gray-300",title:j.classification_reason||void 0,children:j.classification_reason||e.jsx("span",{className:"text-gray-400",children:"No reason recorded"})}),!j.final_classification&&j.blocked_by?.length>0&&e.jsxs("div",{className:"mt-0.5 truncate text-xs text-amber-700 dark:text-amber-400",title:j.blocked_by.join("; "),children:["Held: ",j.blocked_by[0]]}),j.route_reason&&j.auto_routed===1&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-500 dark:text-gray-400",title:j.route_reason,children:j.route_reason})]})]},j.id)})})]})})]})]})}const Ar={new_issuer_lead:"New issuer lead",existing_issuer_question:"Existing client",investor_support:"Investor support",general_inquiry:"General inquiry",spam_or_noise:"Spam or noise",needs_review:"Needs review"},u5={new_issuer_lead:"green",existing_issuer_question:"blue",investor_support:"blue",general_inquiry:"gray",spam_or_noise:"gray",needs_review:"amber"},m5={create_or_attach_lead:"Create or attach a lead",answer_client:"Answer the client",answer_investor:"Answer the investor",triage:"Triage",file_only:"File it, no reply needed",review:"Decide what this is"}
69,h5={ingested:"Arrived",classified:"Classified",reclassified:"Reclassified",routed:"Routed",held_for_review:"Held for review",reviewed:"Reviewed by a person"},Mn=s=>s?s.replace(/_/g," "):"â",x5=["sales_pipeline","issuer_support","investor_support","general_inbox","archive","review_queue"],g5=[{value:"new_issuer_lead",label:"Mark as lead",help:"A company that might raise on Netcapital."},{value:"existing_issuer_question",label:"Existing client issue",help:"A question from a company we already work with."},{value:"investor_support",label:"Investor support",help:"An investor asking about an investment, a payment or an account."},{value:"general_inquiry",label:"General inquiry",help:"A real message that is none of the above."},{value:"spam_or_noise",label:"Dismiss as spam",help:"Nobody needs to answer this. It stays on the record."}];function f5(){const{id:s=""}=am(),l=Ya(),[i,o]=h.useState(null),[d,u]=h.useState(null),[x,y]=h.useState(null),[p,g]=h.useState(!0),[b,f]=h.useState(!1),[k,w]=h.useState(""),[N,j]=h.useState(""),[T,S]=h.useState(""),_=h.useCallback(()=>{g(!0),je.inboundItem(s).then(X=>{o(X),u(null)}).catch(X=>u(X?.message||"Could not load this conversation.")).finally(()=>g(!1))},[s]);h.useEffect(_,[_]);async function z(){f(!0),u(null);try{const X=await je.routeInbound(s,{route:N||void 0,owner:T.trim()||void 0,reason:k.trim()||void 0});y(X?.message||"Routed."),j(""),S(""),w(""),_()}catch(X){u(X?.message||"Could not route that item.")}finally{f(!1)}}async function A(X){f(!0),u(null);try{const I=await je.resolveInbound(s,{classification:X,reason:k.trim()||void 0});y(I?.message||"Recorded."),w(""),_()}catch(I){u(I?.message||"Could not record that decision.")}finally{f(!1)}}if(p&&!i)return e.jsx(tt,{label:"Reading the conversation"});if(d&&!i)return e.jsxs(Ne,{tone:"red",children:["Could not load this conversation. ",d]});if(!i)return null;const{item:L,messages:F,history:D}=i,te=L.final_classification||L.classification,pe=L.final_classification||L.proposed_classification||L.classification,he=L.status==="needs_review"||L.status==="new";return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Xe,{title:L.subject||"(no subject)",crumbTail:L.from_name||L.from_email||void 0,subtitle:e.jsxs(e.Fragment,{children:["From ",e.jsx("strong",{children:L.from_name||L.from_email}),L.from_name&&L.from_email?` (${L.from_email})`:"",L.company_name?` at ${L.company_name}`:"",L.mailbox?`, to ${L.mailbox}`:""]}),status:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[te&&e.jsx(se,{tone:u5[te]||"gray",children:Ar[te]||te}),he&&e.jsx(se,{tone:"amber",children:"Waiting for a person"}),L.status==="routed"&&e.jsx(se,{tone:"green",children:"Routed"}),L.internal_found?e.jsx(se,{tone:"green",children:"In HubSpot"}):null]}),secondary:e.jsx(U,{variant:"soft",onClick:()=>l("/dashboard/leads/inbound"),children:"Back to the queue"})}),x&&e.jsx(Ne,{tone:"green",children:x}),d&&e.jsx(Ne,{tone:"red",children:d}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"What Fantize recommends"}),e.jsxs("dl",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Classification"}),e.jsxs("dd",{className:"mt-1 text-gray-900 dark:text-gray-100",children:[pe?Ar[pe]||pe:"Not yet classified",L.confidence!=null&&e.jsxs("span",{className:"ml-2 tabular-nums text-sm text-gray-500 dark:text-gray-400",children:[Math.round(L.confidence*100),"% sure"]})]})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Route"}),e.jsx("dd",{className:"mt-1 text-gray-900 dark:text-gray-100",children:Mn(L.route)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Action"}),e.jsx("dd",{className:"mt-1 text-gray-900 dark:text-gray-100",children:L.assigned_action?m5[L.assigned_action]||Mn(L.assigned_action):"â"})]})]}),L.classification_reason&&e.jsxs("p",{className:"mt-4 text-sm text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Why: "}),L.classification_reason]}),L.blocked_by?.length>0&&e.jsxs("p",{className:"mt-2 text-sm text-amber-700 dark:text-amber-400",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Held because: "}),L.blocked_by.join("; ")]}),L.assigned_owner&&e.jsxs("p",{className:"mt-2 text-sm text-gray-600 dark:text-gray-400",children:["Held by ",L.assigned_owner,L.owner_source?` (${Mn(L.owner_source)})`:"","."]}),e.jsxs("div",{className:"mt-5 border-t border-gray-200 pt-4 dark:border-gray-700",children:[e.jsx("label",{htmlFor:"inbound-reason",className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"Note (optional)"}),e.jsx("input",{id:"inbound-reason",value:k,onChange:X=>w(X.target.value),placeholder:"Why you decided this, for whoever reads it next",className:"mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm dark:border-gray-600 dark:bg-gray-800"}),e.jsx("div",{className:"mt-3 flex flex-wrap items-end gap-3",children:e.jsx(U,{onClick:()=>pe&&A(pe),disabled:b||!pe,title:pe?`Confirm this is ${Ar[pe]||pe}`:"Nothing has been classified yet",children:b?"Recordingâ¦":`Approve: ${pe?Ar[pe]||pe:"â"}`})}),e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:"Or say what it really is"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:g5.filter(X=>X.value!==pe).map(X=>e.jsx(U,{variant:X.value==="spam_or_noise"?"ghost":"soft",disabled:b,title:X.help,onClick:()=>
69A(X.value),children:X.label},X.value))})]}),e.jsx("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:"Approving records agreement with the classifier; changing records a correction. Neither sends a reply."}),e.jsxs("div",{className:"mt-5 border-t border-gray-200 pt-4 dark:border-gray-700",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsx(ha,{label:"Send to desk",value:N,onChange:j,options:[{value:"",label:"Leave where it is"},...x5.map(X=>({value:X,label:Mn(X)}))]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"inbound-owner",className:"block text-xs font-medium text-gray-600 dark:text-gray-400",children:"Assign to"}),e.jsx("input",{id:"inbound-owner",value:T,onChange:X=>S(X.target.value),placeholder:L.assigned_owner||"Nobody yet",className:"mt-1 rounded-lg border border-gray-300 px-3 py-2 text-sm dark:border-gray-600 dark:bg-gray-800"})]}),e.jsx(U,{variant:"soft",disabled:b||!N&&!T.trim(),onClick:z,children:b?"Recordingâ¦":"Route"})]}),e.jsx("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:"Routing by hand does not change what the message was classified as, and the desk and the person are recorded as two decisions because they are two."})]})]})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:`Conversation (${F.length} ${F.length===1?"message":"messages"})`}),e.jsx("ol",{className:"space-y-4",children:F.map(X=>e.jsxs("li",{className:"rounded-xl border border-gray-200 p-4 dark:border-gray-700",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[e.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:[X.from_name||X.from_email||"Unknown sender",X.direction==="out"&&e.jsx("span",{className:"ml-2 text-xs font-normal text-gray-500",children:"sent by us"})]}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Ia(X.received_at||X.sent_at)})]}),X.subject&&X.subject!==L.subject&&e.jsxs("div",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:["Subject: ",X.subject]}),e.jsx("p",{className:"mt-2 whitespace-pre-wrap text-sm text-gray-800 dark:text-gray-200",children:X.body_text||X.snippet||e.jsx("span",{className:"text-gray-400",children:"No body was stored."})}),(X.provider_labels?.length>0||X.attachments?.length>0)&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[X.provider_labels?.map(I=>e.jsx(se,{tone:"gray",children:I},I)),X.attachments?.map((I,q)=>e.jsx(se,{tone:"blue",children:I.filename||"attachment"},`${I.filename}-${q}`))]})]},X.id))})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"History"}),e.jsx("ol",{className:"space-y-3",children:D.map(X=>e.jsxs("li",{className:"flex gap-3 text-sm",children:[e.jsx("div",{className:"w-40 shrink-0 text-xs text-gray-500 dark:text-gray-400",children:Ia(X.at)}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-gray-900 dark:text-gray-100",children:[h5[X.action]||Mn(X.action),X.from_value&&X.to_value&&X.from_value!==X.to_value&&e.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[" ","from ",Ar[X.from_value]||Mn(X.from_value)," to ",Ar[X.to_value]||Mn(X.to_value)]}),e.jsxs("span",{className:"ml-2 text-xs text-gray-500 dark:text-gray-400",children:["by ",X.actor]})]}),X.reason&&e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:X.reason})]})]},X.id))})]})]})}function On({id:s,title:l,children:i}){return e.jsxs("section",{id:s,"aria-labelledby":s+"-h",className:"scroll-mt-24 border-t border-slate-200 pt-5 dark:border-slate-800",children:[e.jsx("h2",{id:s+"-h",className:"text-base font-semibold text-slate-900 dark:text-slate-100",children:l}),e.jsx("div",{className:"mt-2 space-y-2 text-[15px] leading-relaxed text-slate-700 dark:text-slate-300",children:i})]})}function $n({name:s,children:l}){return e.jsxs("div",{className:"flex flex-col gap-0.5 sm:flex-row sm:gap-3",children:[e.jsx("dt",{className:"shrink-0 font-medium text-slate-900 sm:w-56 dark:text-slate-100",children:s}),e.jsx("dd",{className:"text-slate-700 dark:text-slate-300",children:l})]})}function As({label:s,where:l,closes:i,confirms:o,children:d}){return e.jsxs("div",{className:"rounded-xl border border-slate-200 p-3.5 dar
69k:border-slate-800",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[e.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:s}),e.jsx("span",{className:"rounded-full bg-slate-100 px-2 py-0.5 text-[11px] font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300",children:l}),o&&e.jsx("span",{className:"rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-800 ring-1 ring-inset ring-amber-200 dark:bg-amber-400/10 dark:text-amber-200 dark:ring-amber-400/30",children:"asks you to confirm"}),e.jsx("span",{className:"text-[11px] text-slate-500 dark:text-slate-400",children:i?"closes the review":"leaves the review open"})]}),e.jsx("p",{className:"mt-1.5 text-[15px] leading-relaxed text-slate-700 dark:text-slate-300",children:d})]})}const Kg=[{key:"around",label:"Finding your way around"},{key:"arrive",label:"How replies arrive"},{key:"checks",label:"What Fantize checks"},{key:"decisions",label:"What each decision does"},{key:"holds",label:"Holds and greyed-out actions"},{key:"stop",label:"When to stop and ask"}];function p5(){const{isAdmin:s}=zt(),i=Ja().asMarketing?!1:s,[o,d]=h.useState("around"),u=y=>{d(y),document.getElementById(y)?.scrollIntoView({behavior:"smooth",block:"start"})},x=i?[...Kg,{key:"prospecting",label:"Prospecting qualification"}]:Kg;return e.jsxs("div",{className:"mx-auto max-w-3xl pb-16",children:[e.jsx(Xe,{title:"Help",subtitle:"How reply review works, what Fantize does on its own, and what needs a person."}),e.jsx(dn,{label:"Help sections",items:x,active:o,onChange:u,className:"mb-6"}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-[15px] leading-relaxed text-slate-700 dark:text-slate-300",children:"Fantize watches the replies your outbound campaigns receive, works out what each one means, checks that it is safe to act on, and puts it in front of you. You make the decision. Nothing reaches a salesperson or HubSpot without one."}),e.jsx(On,{id:"around",title:"Finding your way around",children:e.jsxs("dl",{className:"space-y-3",children:[e.jsxs($n,{name:"Reply Review",children:["Your work. ",e.jsx("strong",{className:"font-medium text-slate-900 dark:text-slate-100",children:"Pending"})," lists replies nobody has decided on yet; ",e.jsx("strong",{className:"font-medium text-slate-900 dark:text-slate-100",children:"Resolved"})," is the record of what was decided and by whom. Search by sender, or filter by salesperson, classification and readiness."]}),e.jsxs($n,{name:"Activity & Issues",children:["Whether Fantize is operating normally. ",e.jsx("em",{children:"Needs Attention"})," lists everything waiting for a person; ",e.jsx("em",{children:"Processing Issues"})," lists HubSpot handoffs that did not complete. Overall health (HubSpot, Instantly, manual review, automatic sync, notifications) is shown separately from individual issues."]}),e.jsx($n,{name:"Account & Preferences",children:"Your profile, appearance and sign-out, from the account chip at the bottom of the menu."}),i&&e.jsxs($n,{name:"Administrator areas",children:["Prospecting (searches, templates, results, schedules, exclusions), Lead Operations (lifecycle, cleanup, do-not-contact), Campaigns & Outreach (campaigns, campaign routing, outreach tracker), Contacts & CRM, Automation & Integrations (operational readiness, automation settings, lead assignment, lifecycle & HubSpot, notifications, test mode, integrations), Analytics and Administration. Marketing users see none of these; choose ",e.jsx("em",{children:"View as Marketing (preview)"})," under your account chip to see exactly what they see."]})]})}),e.jsx(On,{id:"arrive",title:"How replies arrive",children:e.jsx("p",{children:"Someone replies to a campaign email in Instantly. Fantize records the reply, reads it, and opens a review. Replies normally appear within a few minutes. While nothing is pending, Reply Review says so and Fantize keeps monitoring; there is nothing to do."})}),e.jsxs(On,{id:"checks",title:"What Fantize checks before you decide",children:[e.jsxs("dl",{className:"space-y-3",children:[e.jsx($n,{name:"Classification",children:"What Fantize thinks the reply means, with how confident it is. It is a suggestion. You confirm or change it as part of every decision."}),e.jsx($n,{name:"Instantly safety",children:"Whether more campaign emails are still scheduled to this person, and whether Fantize can stop them. If Fantize could not complete this check, it says so rather than guessing."}
69),e.jsx($n,{name:"Owner routing",children:"Which salesperson this campaign hands off to, from Campaign Routing. Fantize confirms the owner is still active in HubSpot at the moment you decide, not when the reply arrived. The confirmation names the owner the handoff goes to now. If the campaign was routed to someone else when the reply arrived, the review says so; history keeps the original name, and only the approved salespeople for new leads can be chosen."})]}),e.jsx("p",{children:"The queue suggests a recommended action for most replies, marked with a star. It is a starting point, not an instruction."})]}),e.jsxs(On,{id:"decisions",title:"What each decision does",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(As,{label:"Qualified lead",where:"HubSpot",closes:!0,confirms:!0,children:"Creates or updates this lead in HubSpot straight away, using the confirmed owner routing. This is the handoff to sales and cannot be undone inside Fantize."}),e.jsx(As,{label:"Meeting booked",where:"HubSpot",closes:!0,confirms:!0,children:"Creates or updates the lead in HubSpot straight away, sets the stage to Sales Qualified Lead with status âMeeting Scheduledâ, adds a note, and may create a follow-up call task. It cannot be undone inside Fantize."}),e.jsx(As,{label:"Not interested",where:"Instantly",closes:!0,confirms:!0,children:"Records the outcome and closes the review. It stops automated follow-ups only when follow-ups are still running and the checked provider state supports stopping them â if they have already stopped, nothing further is stopped. No HubSpot handoff is created."}),e.jsx(As,{label:"Close as wrong contact / referred",where:"Instantly",closes:!0,confirms:!0,children:"Records that outcome and closes the review. It stops follow-ups only when that is still required and the checked provider state supports it. It does not save the person they referred you to â copy those details out of the reply first, because nothing about them is recorded anywhere."}),e.jsx(As,{label:"Never contact again",where:"Instantly",closes:!0,confirms:!0,children:"Adds the address to Fantize's do-not-contact list immediately, across your whole workspace rather than this campaign alone, and attempts to add it to the Instantly block list. The Instantly half is attempted, not guaranteed â confirmation may still be pending when the review closes, and the review says so when it is."}),i&&e.jsx(As,{label:"Set the owner",where:"HubSpot",closes:!1,confirms:!0,children:"Changes who owns this lead and updates the owner in HubSpot when the contact already exists there. It deliberately leaves the review open so you can still decide what happens to the reply. Administrator only."}),e.jsx(As,{label:"Keep in outreach",where:"Fantize only",closes:!0,confirms:!1,children:"Closes the review and records that outreach should continue. It does not start or restart an Instantly campaign â it records the disposition and leaves the current Instantly state exactly as it is. Nothing is sent anywhere."}),e.jsx(As,{label:"Set aside",where:"Fantize only",closes:!0,confirms:!1,children:"Closes the review without recording a sales outcome. It leaves the current Instantly state unchanged and creates no HubSpot handoff. Nothing is sent anywhere."}),i&&e.jsx(As,{label:"Mark disqualified in Fantize",where:"Fantize only",closes:!0,confirms:!1,children:"Marks the lead disqualified in Fantize and closes the review. Nothing is sent anywhere. Administrator only."})]}),e.jsx("p",{className:"pt-1",children:"Anything that reaches HubSpot or Instantly asks you to confirm first, and the confirmation spells out exactly what will change. Treat every decision as final: closing a review is not something you can undo yourself."}),e.jsx("h3",{className:"pt-2 text-sm font-semibold text-slate-900 dark:text-slate-100",children:"How a decision is carried out"}),e.jsxs("ol",{className:"list-decimal space-y-1 pl-5",children:[e.jsx("li",{children:"You confirm or correct the classification, then choose the outcome."}),e.jsx("li",{children:"Follow-ups have normally already stopped: every campaign is required to stop sending the moment someone replies, which is why this reply reached you."}),e.jsx("li",{children:"Fantize re-checks the current Instantly and routing state as you submit â not the state from when the page loaded."}),e.jsx("li",{children:"Fantize creates the HubSpot handoff and retries it automatically if the first attempt fails. It will not be created twice."}),e.jsx("li",{children:"If a campaign has no active salesperson, you can set one yourself and carry on."})]}),e.jsx("h3",{className:"pt-2 text-sm font-semibold text-slate-900 dark:text-slate-100",children:"If someone else decides first"}),e.jsx("p",{children:"Two people can open the same reply. Only the first decision counts; the second person is told the review was already resolved and their queue refreshes. Nothing is recorded twice and nobody quietly overwrites anyone."})]}),e.jsxs(On,{id:"holds",title:"Holds and greyed-out actions",children:[e.jsx("h3",{className:"text-sm font-semibold text-slate-900 dark:text-slate-100",children:"Leads that already exist in HubSpot from an import"}),e.jsx("p",{children:"Some people your campaigns reach already have a HubSpot record that was created by a bulk import before Fantize tracking began. Fantize checks for this before every handoff and treats those records carefully rather than writing over them."}),e.jsxs("ul",{className:"list-disc space-y-1 pl-5",children:[e.jsx("li",{children:"If everything lines up â the reply belongs to a campaign this workspace runs, a person approved the handoff, and the record's existing salesperson matches the campaign's routing â the handoff completes with a limited, reviewed update. The record's owner and origin are never changed. A record already at the target stage gets its notes and reply history added with
69no other change."}),e.jsx("li",{children:"If anything does not line up â a different owner, an ambiguous match, or the record came from somewhere Fantize must not touch â the handoff is refused and a review explains exactly why, so a person decides."}),e.jsxs("li",{children:["If the pre-handoff safety check itself cannot finish (for example the provider could not be reached), the handoff ",e.jsx("strong",{className:"font-medium",children:"waits"})," instead of proceeding. It is retried automatically and appears under Processing Issues until it completes or an administrator retries it. Nothing partial is written."]})]}),e.jsx("h3",{className:"pt-2 text-sm font-semibold text-slate-900 dark:text-slate-100",children:"When the action you want is greyed out"}),e.jsxs("div",{className:"rounded-xl border-l-4 border-amber-400 bg-amber-50 p-4 dark:border-amber-500 dark:bg-amber-950/30",children:[e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:"A greyed-out action can still be the right decision."}),e.jsx("p",{className:"mt-2 text-amber-900/90 dark:text-amber-100/90",children:"It means a provider requirement has not cleared yet â not that your reading of the reply is wrong. Most of the time you can clear it yourself: if the campaign has no salesperson, choose one and the action comes back. If a check could not reach Instantly, run it again."}),e.jsx("p",{className:"mt-2 text-amber-900/90 dark:text-amber-100/90",children:"Technical support is needed only when the integration genuinely cannot operate â credentials have expired, a provider stays unreachable after Fantize has retried, or the provider contradicts a guarantee the account requires. Your decision and the attempt history are kept either way; nothing is lost and nothing partial is sent."}),e.jsx("p",{className:"mt-2 font-medium text-amber-900 dark:text-amber-200",children:"Never pick a different business outcome to get past a provider requirement â that records a sale nobody made, on the lead the check was protecting."})]}),e.jsx("h3",{className:"pt-2 text-sm font-semibold text-slate-900 dark:text-slate-100",children:"Why a handoff might be refused as a duplicate"}),e.jsx("p",{children:"Fantize sends one HubSpot handoff per reply, permanently, even if the same reply produces more than one review. If you approve something it has already handed over, it declines and tells you so."}),e.jsx("p",{children:"You may also see a reply refused because it is word-for-word identical to one already sent for this person. That is usually an automatic out-of-office or âIâve left the companyâ message firing again. Fantize cannot tell that apart from a genuinely new message with the same wording, so it stops and asks an administrator to look. If you believe it is a real new reply, say so â do not work around it."})]}),e.jsxs(On,{id:"stop",title:"When to stop and ask an administrator",children:[e.jsx("p",{children:"Stop and ask when:"}),e.jsxs("ul",{className:"list-disc space-y-1 pl-5",children:[e.jsx("li",{children:"Routing or the Instantly check is unavailable, and you are unsure whether a decision is safe."}),e.jsx("li",{children:"A reply is refused as a duplicate or a repeat and you think that is wrong."}),e.jsx("li",{children:"The reply mentions legal, billing or complaint matters."}),e.jsx("li",{children:"You are about to hand a lead to sales and something about it does not look right."})]}),e.jsx("p",{children:"Never proceed with a HubSpot handoff while routing or Instantly safety is uncertain. Leaving a review pending costs nothing; an unwanted handoff cannot be undone from here."}),e.jsx("p",{children:e.jsx(Se,{to:"/dashboard/leads/activity",className:"inline-flex min-h-11 items-center font-medium text-primary-600 hover:underline dark:text-primary-400 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 rounded-lg",children:"Check what is waiting in Activity & Issues"})})]}),i&&e.jsxs(On,{id:"prospecting",title:"Prospecting qualification",children:[e.jsx("p",{children:"After a search finds leads, Fantize qualifies the viable ones with an approved local model that runs on its own equipment. Lead and company details are not sent to a hosted AI service for this step, and it incurs no AI charge."}),e.jsxs("p",{children:["If the local model is unavailable, qualification still completes, but every result is ",e.jsx("strong",{className:"font-medium text-slate-900 dark:text-slate-100",children:"provisional"}),": a fixed rule-of-thumb check marks each lead as needing review. The run detail shows",e.
69jsx("em",{children:" Provisional result - review required"}),", nothing counts as qualified, and no lead is enriched, exported or handed off until a person confirms it. Re-run qualification once the local model is available to replace provisional results with final ones. The AI model provider setting under Automation Settings applies to reply classification and does not change this behaviour."]})]})]})]})}const y5={email_replied:"amber",meeting_booked:"green",meeting_link_clicked:"green",email_delivered:"blue",email_sent:"blue",email_bounced:"red",unsubscribed:"red",negative_reply:"red",out_of_office:"gray",hubspot_sync_success:"green",hubspot_sync_failed:"red"};function b5({embedded:s=!1}={}){const[l,i]=h.useState([]),[o,d]=h.useState([]),[u,x]=h.useState(!0),[y,p]=h.useState({days:"30"}),[g,b]=h.useState(""),[f,k]=h.useState(!1),[w,N]=h.useState(null),{isAdmin:j}=zt();async function T(){x(!0);const _=await je.events(y);i(_.events||[]),d(_.event_types||[]),x(!1)}h.useEffect(()=>{T()},[y]);function S(_){b(_),setTimeout(()=>b(""),3500)}return e.jsxs("div",{className:s?"":"max-w-5xl mx-auto pb-12",children:[s?e.jsxs("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Recent activity"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Every outbound event Fantize has processed â replies, deliveries, bounces, bookings and handoffs â normalized and deduplicated. Administrator diagnostics."})]}),j&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(U,{variant:"soft",size:"sm",onClick:async()=>{N(await je.webhookInfo())},children:"Webhook & sync schedule"}),e.jsx(U,{size:"sm",onClick:()=>k(!0),children:"Import events"})]})]}):e.jsx(Xe,{title:"Recent Activity",subtitle:"Every outbound event, normalized and deduplicated â from webhooks, polling, calendar tools or import.",action:j?e.jsx(U,{onClick:()=>k(!0),children:"Import events"}):void 0,secondary:j?e.jsx(U,{variant:"soft",onClick:async()=>{N(await je.webhookInfo())},children:"Webhook & sync schedule"}):void 0}),g&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"green",children:g})}),e.jsxs("div",{className:"flex flex-wrap gap-3 mb-4",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-gray-500",children:"Event type"}),e.jsxs("select",{className:de+" w-auto",value:y.event_type||"",onChange:_=>p({...y,event_type:_.target.value||void 0}),children:[e.jsx("option",{value:"",children:"All event types"}),o.map(_=>e.jsx("option",{value:_,children:_},_))]})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-gray-500",children:"Range"}),e.jsxs("select",{className:de+" w-auto",value:y.days||"30",onChange:_=>p({...y,days:_.target.value}),children:[e.jsx("option",{value:"7",children:"7 days"}),e.jsx("option",{value:"30",children:"30 days"}),e.jsx("option",{value:"90",children:"90 days"}),e.jsx("option",{value:"3650",children:"All time"})]})]})]}),u?e.jsx(tt,{label:"Loading activityâ¦"}):l.length===0?e.jsx(Ze,{title:"No activity in this range",hint:"Events arrive from the outbound platform's webhook, the 15-minute sync schedule, calendar tools or a CSV import.",doing:"Polling the outbound platform every 15 minutes",action:j?e.jsx(U,{onClick:()=>k(!0),children:"Import events"}):void 0}):e.jsx("div",{className:"space-y-2",children:l.map(_=>e.jsxs(_e,{className:"!p-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:[[_.first_name,_.last_name].filter(Boolean).join(" ")||_.lead_email,_.company&&e.jsxs("span",{className:"text-gray-400 font-normal",children:[" · ",_.company]})]}),e.jsxs("div",{className:"text-xs text-gray-500 truncate",children:[_.campaign_name||"â"," · ",_.source_system," ",_.decision&&`· ${_.decision}`]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[_.classification&&e.jsxs(se,{tone:"gray",children:[_.classification,_.confidence!=null?` ${_.confidence}`:""]}),e.jsx(se,{tone:y5[_.event_type]||"gray",children:_.event_type}),e.jsx("span",{className:"text-xs text-gray-400 w-20 text-right",children:Ke(_.occurred_at||_.created_at)})]})]},_.id))}),e.jsx(v5,{open:f,onClose:()=>k(!1),onDone:_=>{S(_),k(!1),T()}}),e.jsx(Et,{open:!!w,onClose:()=>N(null),title:"Webhook & sync schedule",widthClass:"max-w-xl",children:w&&e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("p",{className:"text-gray-600 dark:text-gray-300",children:["Point your outbound or calendar platform at this URL. Replace ",e.jsx("code",{children:"{provider}"})," with ",e.jsx("code",{children:"instantly"}),", ",e.jsx("code",{children:"calendly"}),", or ",e.jsx("code",{children:"webhook"}),"."]}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-700/40 rounded-xl p-3 font-mono text-xs break-all",children:w.url_template}),w.secret_masked?.configured&&!w.revealed&&e.jsxs("p",{className:"text-gray-600 dark:text-gray-300",children:["A secret is set, ending ",e.jsx("span",{className:"font-mono",children:w.secret_masked.last4}),". The full value appears only when you generate a new one."]}),w.revealed&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-gray-50 dark:bg-gray-700/40 rounded-xl p-3 font-mono text-xs break-all",children:w.revealed}),e.jsx(Ne,{tone:"amber",children:"Copy this now. It will not be shown again â if you lose it, generate another."})]}),e.jsx(Ne,{tone:"blue",children:"If webhooks are not available, the sync schedule (polling every 15 minutes) and CSV/API import keep the workflow running â there is no webhook dependency."}),e.jsx(U,{variant:"soft",size:"sm",onClick:async()=>{const _=await je.rotateWebhook(),z=await je.webhookInfo();N({...z,revealed:_.url})},children:"Generate a new secret"})]})})]})}function v5({open:s,onClose:l,onDone:i}){const[o,d]=h.useState("manual"),[u,x]=h.useState({email:"",event_type:"email_replied",campaign_name:"",reply_text:""}),[y,p]=h.useState(""),[g,b]=h.useState(!1),[f,k]=h.useState("");async function w(){b(!0),k("");try{if(o==="manual"){const N=await je.manualEvent(u);i(N.duplicate?"Duplicate â already recorded.":`Recorded: ${N.decision||"event"}`)}else{const N=await je.importEvents({csv:y,source_system:"csv"});i(N.message||`Imported ${N.ingested}.`)}}catch(N){k(N.message||"Import failed")}b(!1)}return e.jsx(Et,{open:s,onClose:l,title:"Import activity",footer
69:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(U,{variant:"ghost",onClick:l,children:"Cancel"}),e.jsx(U,{onClick:w,disabled:g,children:g?"Importingâ¦":"Import"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(U,{size:"sm",variant:o==="manual"?"primary":"soft",onClick:()=>d("manual"),children:"Single event"}),e.jsx(U,{size:"sm",variant:o==="csv"?"primary":"soft",onClick:()=>d("csv"),children:"CSV paste"})]}),f&&e.jsx(Ne,{tone:"red",children:f}),o==="manual"?e.jsxs(e.Fragment,{children:[e.jsx(le,{label:"Email",required:!0,children:e.jsx("input",{className:de,value:u.email,onChange:N=>x({...u,email:N.target.value})})}),e.jsx(le,{label:"Event type",children:e.jsx("select",{className:de,value:u.event_type,onChange:N=>x({...u,event_type:N.target.value}),children:["email_sent","email_delivered","email_bounced","email_replied","meeting_link_clicked","meeting_booked","unsubscribed"].map(N=>e.jsx("option",{value:N,children:N},N))})}),e.jsx(le,{label:"Campaign name",children:e.jsx("input",{className:de,value:u.campaign_name,onChange:N=>x({...u,campaign_name:N.target.value})})}),u.event_type==="email_replied"&&e.jsx(le,{label:"Reply text",children:e.jsx("textarea",{className:de,rows:3,value:u.reply_text,onChange:N=>x({...u,reply_text:N.target.value})})})]}):e.jsx(le,{label:"CSV (header row required)",help:"Columns: email, event_type, campaign_name, occurred_at, reply_text, source_event_id",children:e.jsx("textarea",{className:de+" font-mono text-xs",rows:8,placeholder:`email,event_type,campaign_name,reply_text 70[email protected],email_replied,Q3,"Happy to chat next week"`,value:y,onChange:N=>p(N.target.value)})})]})})}function j5({embedded:s=!1}={}){const{isAdmin:l}=zt(),[i,o]=h.useState([]),[d,u]=h.useState(5),[x,y]=h.useState({}),[p,g]=h.useState(!0),[b,f]=h.useState(""),[k,w]=h.useState("");async function N(){g(!0);const z=await je.syncErrors(),A=z.errors||[];o(A),u(z.max_attempts||5);const L={};await Promise.all(A.map(async F=>{try{L[F.id]=await je.syncJobRouting(F.id)}catch{}})),y(L),g(!1)}h.useEffect(()=>{N()},[]);function j(z){f(z),setTimeout(()=>f(""),3500)}const T=z=>l&&x[z]?.retry_allowed===!0;async function S(z){if(T(z)){w(z);try{const A=await je.retrySync(z);j(A.ok?"Synced successfully.":`Still failing: ${A.error||"unknown"}`),await N()}catch(A){j(A?.payload?.error||A?.payload?.message||A.message),await N()}w("")}}async function _(){if(l){w("all");try{const z=await je.retryAllSync(),A=z.skipped?`, ${z.skipped} skipped as unsafe`:"";j(`${z.eligible} eligible: ${z.retried} retried, ${z.failed} still failing${A}.`),await N()}catch(z){j(z?.payload?.error||z.message)}w("")}}return e.jsxs("div",{className:s?"":"max-w-4xl mx-auto pb-12",children:[s?e.jsxs("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Handoffs that did not complete"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Retained and retried automatically. A retry updates the existing HubSpot contact and never creates a second."})]}),l&&i.length>0&&e.jsx(U,{variant:"soft",size:"sm",onClick:_,disabled:k==="all",children:k==="all"?"Retryingâ¦":"Retry all safe handoffs"})]}):e.jsx(Xe,{title:"Processing Issues",subtitle:"HubSpot handoffs that did not complete. They are retained and retried; a retry updates the existing contact and never creates a second.",action:l&&i.length>0?e.jsx(U,{variant:"soft",onClick:_,disabled:k==="all",children:k==="all"?"Retryingâ¦":"Retry all safe handoffs"}):void 0}),b&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"blue",children:b})}),!l&&i.length>0&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"amber",children:"These syncs need an administrator. You can see every failure and its explanation here, but retrying sends the lead to HubSpot, so an admin has to review the routing and run it."})}),p?e.jsx(tt,{label:"Loading sync errorsâ¦"}):i.length===0?e.jsx(Ze,{tone:"positive",title:"No handoffs are stuck",hint:"Every qualified lead that should be in HubSpot is in HubSpot.",doing:"Retrying any transient failure automatically"}):e.jsx("div",{className:"space-y-3",children:i.map(z=>
70{const A=x[z.id],L=z.blocked_reason||A?.routing?.reason,F=!!A&&A.retry_allowed!==!0;return e.jsxs(_e,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-medium text-gray-900 dark:text-gray-100 truncate",children:[[z.first_name,z.last_name].filter(Boolean).join(" ")||z.email,z.company&&e.jsxs("span",{className:"text-gray-400 font-normal",children:[" · ",z.company]})]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[z.email," · ",Ke(z.updated_at)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(se,{tone:"blue",children:(z.intent||"").toUpperCase()}),z.status==="blocked"?e.jsx(We,{kind:"paused",label:"Held â routing must be confirmed"}):z.attempts>=d?e.jsx(We,{kind:"action-required",label:`Retries exhausted (${z.attempts}/${d})`}):e.jsx(We,{kind:"needs-review",label:`Retrying (${z.attempts}/${d})`})]})]}),e.jsx(Ne,{tone:"red",children:z.last_error||"Sync failed"}),z.reason&&e.jsxs("div",{className:"text-xs text-gray-500",children:["Reason: ",z.reason]}),A&&e.jsxs("div",{className:`rounded-lg border p-3 text-xs space-y-1 ${F?"border-amber-200 bg-amber-50/70 dark:border-amber-900/50 dark:bg-amber-950/30":"border-gray-100 bg-gray-50/70 dark:border-gray-700/60 dark:bg-gray-800/40"}`,children:[e.jsx("div",{className:"font-medium text-gray-700 dark:text-gray-200",children:F?"Routing is not currently safe to send":"Routing checked and current"}),A.routing?.message&&e.jsx("div",{className:"text-gray-600 dark:text-gray-300",children:A.routing.message}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-gray-500",children:[e.jsxs("div",{children:["Approved owner: ",e.jsx("code",{children:A.approved_owner_id||"none recorded"})]}),e.jsxs("div",{children:["Current mapped owner: ",e.jsx("code",{children:A.current_owner_id||"none"})]})]}),A.owner_changed&&e.jsxs("div",{className:"text-amber-800 dark:text-amber-300 font-medium",children:["The owner changed after this sync was approved (",A.approved_owner_id," â ",A.current_owner_id,"). Fantize will not reassign the lead on its own â an administrator must decide, and re-approve if the new owner is correct."]}),L&&e.jsxs("div",{className:"text-gray-400",children:["Reason code: ",e.jsx("code",{children:L})]})]}),l&&e.jsxs("div",{className:"flex justify-end items-center gap-3",children:[!T(z.id)&&e.jsx("span",{className:"text-xs text-gray-400",children:A?"Retry is unavailable while routing is unsafe":"Routing could not be confirmed"}),e.jsx(U,{size:"sm",onClick:()=>S(z.id),disabled:k===z.id||!T(z.id),children:k===z.id?"Retryingâ¦":"Retry now"})]})]},z.id)})})]})}const w5={overdue_review:"Reply waiting too long",unmapped_campaign:"Campaign has no salesperson",inactive_mapping:"Campaign routing switched off",unapproved_owner:"Campaign routes to a non-salesperson",sync_problem:"HubSpot handoff needs a person",readiness:"Campaign safety setting",provider_campaign:"Campaign paused by provider",sender:"Sending mailbox",dnc:"Do-not-contact protection",fallback_reviewer:"Fallback reviewer"},Jg=new Set(["unmapped_campaign","inactive_mapping","unapproved_owner","readiness","provider_campaign","sender"]),k5=[{test:s=>s.startsWith("/dashboard/leads/review"),label:"Open in Reply Review"},{test:s=>s.startsWith("/dashboard/leads/campaign-mapping")||s.startsWith("/dashboard/campaigns/routing"),label:"Open Campaign Routing"},{test:s=>s.startsWith("/dashboard/leads/activity"),label:"Open Processing Issues"},{test:s=>s.startsWith("/dashboard/leads/do-not-contact"),label:"Open Do Not Contact"},{test:s=>s.startsWith("/dashboard/leads/assignment")||s.startsWith("/dashboard/automation/lead-assignment"),label:"Open Lead Assignment"}];function N5(s){return s?k5.find(l=>l.test(s))?.label||"Open":null}function _5(s){return s.startsWith("/dashboard/leads/review")||s.startsWith("/dashboard/leads/activity")||s.startsWith("/dashboard/help")}function S5(){const{isAdmin:s}=zt(),i=Ja().asMarketing?!1:s,[o,d]=h.useState(null),[u,x]=h.useState(""),[y,p]=h.useState(!0);async function g(){p(!0),x("");try{d(await je.attention())}catch(_){x(_.message||"Could not load the attention list.")}p(!1)}if(h.useEffect(()=>{g()},[]),y&&!o)return e.jsx(tt,{label:"Checking what is waitingâ¦"});if(u)return e.jsx(Rr,{message:u,onRetry:g});if(!o)return null;const b=o.items||[],f=o.counts||{},k=o.protection||{},w=o.fallback_reviewer||{},N=b.filter(_=>!Jg.has(_.kind)),j=b.filter(_=>Jg.has(_.kind)),T=[{key:"hubspot",label:"HubSpot",kind:k.hubspot_connected?"connected":"not-configured",value:k.hubspot_connected?"Connected":"Not connected â handoffs cannot reach HubSpot"},{key:"instantly",label:"Instantly",kind:k.instantly_connected?"connected":"not-configured",value:k.instantly_connected?"Connected â replies are being read":"Not connected â replies are not being read"},{key:"review",label:"Manual review",kind:k.actions_enabled?"ready":"disabled",value:k.actions_enabled?"Live â decisions in Reply Review act immediately":"Switched off on the server â decisions are declined"},{key:"sync",label:"Automatic HubSpot sync",kind:k.auto_sync_enabled?"ready":"disabled",value:k.auto_sync_enabled?"On â qualifying replies sync without a person":"Off â every qualifying reply waits for a person"},{key:"notify",label:"Notifications",kind:k.external_notifications?"ready":"info",value:k.external_notifications?"External channels on":"In-app only"},{key:"fallback",label:"Fallback reviewer",kind:w.name?w.active?"ready":"action-required":"not-configured",value:w.name?`${w.name}${w.active?"":" (inactive)"} · ${w.lead_eligible?"also a salesperson":"reviewer only, never a routing target"}`:"None set â unmatched leads would wait for nobody"}
70],S=[{label:"Pending replies",n:Number(f.pending_reviews)||0,to:"/dashboard/leads/review",kind:"needs-review"},{label:"Overdue replies",n:Number(f.overdue_reviews)||0,to:"/dashboard/leads/review",kind:"action-required"},{label:"Campaigns without a salesperson",n:Number(f.unmapped_active_campaigns)||0,to:i?"/dashboard/campaigns/routing":void 0,kind:"action-required"},{label:"Campaigns routed to a non-salesperson",n:Number(f.mappings_to_unapproved_owner)||0,to:i?"/dashboard/campaigns/routing":void 0,kind:"action-required"},{label:"Handoffs needing a person",n:Number(f.sync_problems)||0,to:"/dashboard/leads/activity?tab=issues",kind:"action-required"},{label:"Campaigns failing a safety check",n:Number(f.campaigns_failing_readiness)||0,to:i?"/dashboard/automation/readiness":void 0,kind:"needs-review"}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{"aria-labelledby":"attn-items",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsx("h2",{id:"attn-items",className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Waiting for a person"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:g,children:"Refresh"})]}),b.length===0?e.jsx(Ze,{tone:"positive",title:"Nothing is waiting for a person",hint:"Every live campaign has an approved salesperson, no reply is past its review window, and no handoff is parked.",doing:"Monitoring replies and handoffs",next:{to:"/dashboard/leads/review",label:"Open Reply Review"}}):e.jsxs("div",{className:"space-y-4",children:[N.length>0&&e.jsx(ef,{title:"Replies and handoffs",items:N,isAdmin:i}),j.length>0&&e.jsx(ef,{title:"Campaign-specific",items:j,isAdmin:i,note:"These affect one campaign each. The rest of the workflow keeps operating."})]})]}),e.jsxs("section",{"aria-labelledby":"attn-counts",children:[e.jsx("h2",{id:"attn-counts",className:"sr-only",children:"Counts"}),e.jsx("ul",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-6",children:S.map(_=>{const z=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`text-2xl font-semibold tabular-nums ${_.n>0?"text-gray-900 dark:text-white":"text-gray-400 dark:text-gray-500"}`,children:_.n}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 leading-snug",children:_.label}),_.n>0&&e.jsx("div",{className:"mt-1",children:e.jsx(We,{kind:_.kind})})]});return e.jsx("li",{children:_.to&&_.n>0?e.jsx(Se,{to:_.to,className:"block h-full rounded-2xl bg-white dark:bg-gray-800/80 ring-1 ring-gray-200 dark:ring-gray-700/60 shadow-sm p-4 text-center hover:ring-primary-300 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:z}):e.jsx("div",{className:"h-full rounded-2xl bg-white dark:bg-gray-800/80 ring-1 ring-gray-200 dark:ring-gray-700/60 shadow-sm p-4 text-center",children:z})},_.label)})})]}),e.jsxs(_e,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Overall health"}),e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Checked ",Ke(o.generated_at)," · review window ",o.review_sla_hours,"h"]})]}),e.jsx(zr,{items:T,columns:2,dense:!0}),e.jsx("p",{className:"mt-3 text-xs text-gray-500 dark:text-gray-400",children:"Nothing on this page changes these facts. Administrators change them under Automation & Integrations."})]}),Array.isArray(o.pending_reviews)&&o.pending_reviews.length>0&&e.jsxs(_e,{children:[e.jsx("h2",{className:"mb-2 text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Pending replies, oldest first"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full text-sm",children:[e.jsx("caption",{className:"sr-only",children:"Pending replies"}),e.jsx("thead",{className:"text-left text-xs text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"py-1 pr-3",children:"Waiting"}),e.jsx("th",{scope:"col",className:"py-1 pr-3",children:"Lead"}),e.jsx("th",{scope:"col",className:"py-1 pr-3",children:"Campaign"}),e.jsx("th",{scope:"col",className:"py-1 pr-3",children:"Suggested"}),e.jsx("th",{scope:"col",className:"py-1",children:e.jsx("span",{className:"sr-only",children:"Open"})})]})}),e.jsx("tbody",{children:o.pending_reviews.map(_=>e.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-700/60",children:[e.jsx("td",{className:"py-1.5 pr-3 whitespace-nowrap",children:e.jsx(se,{tone:_.overdue?"red":"gray",children:_.waiting_hours==null?"Not measured":_.waiting_hours>=48?`${Math.round(_.waiting_hours/24)}
70d`:`${_.waiting_hours}h`})}),e.jsxs("td",{className:"py-1.5 pr-3",children:[_.lead||"â",_.company?e.jsxs("span",{className:"text-gray-400",children:[" · ",_.company]}):null]}),e.jsx("td",{className:"py-1.5 pr-3 text-gray-500",children:_.campaign||"â"}),e.jsx("td",{className:"py-1.5 pr-3 text-gray-500",children:_.classification?`${String(_.classification).replace(/_/g," ")}${typeof _.confidence=="number"?` (${_.confidence}%)`:""}`:"unclassified"}),e.jsx("td",{className:"py-1.5",children:e.jsx(Se,{to:`/dashboard/leads/review?review=${_.id}`,className:"inline-flex min-h-11 items-center text-primary-600 hover:underline dark:text-primary-400 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 rounded-lg px-1",children:"Review"})})]},_.id))})]})})]})]})}function ef({title:s,items:l,isAdmin:i,note:o}){return e.jsxs(_e,{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200 mb-1",children:s}),o&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:o}),e.jsx("ul",{className:"divide-y divide-gray-100 dark:divide-gray-700/60",children:l.map((d,u)=>e.jsxs("li",{className:"flex flex-col gap-1 py-3 sm:flex-row sm:items-start sm:gap-4",children:[e.jsxs("div",{className:"flex-none sm:w-52 flex flex-col gap-1",children:[e.jsx(We,{kind:d.severity==="high"?"action-required":"needs-review",label:d.severity==="high"?"Action required":"Needs review"}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:w5[d.kind]||d.kind})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:d.title}),d.detail&&e.jsx("div",{className:"mt-0.5 text-sm text-gray-600 dark:text-gray-300",children:d.detail}),d.campaign&&e.jsxs("div",{className:"mt-0.5 text-xs text-gray-400",children:["Campaign: ",d.campaign]})]}),d.where&&(i||_5(d.where))&&e.jsx("div",{className:"flex-none",children:e.jsx(Se,{to:d.where,className:"inline-flex min-h-11 items-center text-sm font-medium text-primary-600 hover:underline dark:text-primary-400 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 rounded-lg px-1",children:N5(d.where)})})]},`${d.kind}:${d.id}:${u}`))})]})}const tf=[{key:"attention",label:"Needs Attention"},{key:"issues",label:"Processing Issues"},{key:"activity",label:"Recent Activity"}];function C5(){const{isAdmin:s}=zt(),i=Ja().asMarketing?!1:s,o=i?tf:tf.filter(b=>b.key!=="activity"),[d,u]=$r(),x=d.get("tab"),[y,p]=h.useState(x==="issues"?"issues":x==="activity"&&i?"activity":"attention"),g=b=>{p(b);const f=new URLSearchParams(d);b==="attention"?f.delete("tab"):f.set("tab",b),u(f,{replace:!0})};return e.jsxs("div",{className:"pb-12",children:[e.jsx(Xe,{title:"Activity & Issues",subtitle:"What is waiting for a person, what has been processed, and any handoff that c
70ould not complete."}),e.jsx(dn,{label:"Activity & Issues sections",items:o,active:y,onChange:g,className:"mb-5"}),e.jsx("div",{children:y==="attention"?e.jsx(S5,{}):y==="activity"?e.jsx(b5,{embedded:!0}):e.jsx(j5,{embedded:!0})})]})}function af(s){if(s&&s.classification)return"none";const l=String(s&&s.classification_error||"");return l==="ai_classification_indeterminate"?"indeterminate":"service_unavailable"}function A5(s){return af(s)==="none"?[]:[af(s)==="indeterminate"?"This reply could not be categorized automatically.":"Classification was unavailable when this reply arrived.","No suggested decision is available. Review the reply and choose the appropriate outcome."]}const E5={positive_interest:"Positive interest",meeting_intent:"Wants to meet",meeting_scheduled:"Meeting scheduled",referral_wrong_contact:"Referred us elsewhere",neutral_ambiguous:"Unclear",not_interested:"Not interested",out_of_office:"Out of office",unsubscribe:"Asked to unsubscribe",bounce_invalid:"Bad address",spam_junk:"Spam"},Tu={positive_interest:"green",meeting_intent:"green",meeting_scheduled:"green",referral_wrong_contact:"amber",neutral_ambiguous:"gray",not_interested:"red",out_of_office:"gray",unsubscribe:"red",bounce_invalid:"red",spam_junk:"red"};function Bl(s){return s?E5[s]||s.replace(/_/g," "):"Not classified"}function Ru(s){const l=[s.first_name,s.last_name].filter(Boolean).join(" ").trim();return l?{primary:l,secondary:s.email||null,hasName:!0}:{primary:s.email||"Unknown sender",secondary:null,hasName:!1}}function Ul(s){if(!s)return{text:"",trimmed:!1};const l=String(s).replace(/\r/g,"").split(` 71`),i=[];for(const u of l){const x=u.trim();if(/^>/.test(x)||/^On .+wrote:$/i.test(x)||/^-{2,}\s*$/.test(x)||/^_{2,}\s*$/.test(x)||/^(from|sent|to|subject|cc|date):/i.test(x)&&i.length||/^(unsubscribe|this email and any files|confidentiality notice|disclaimer)/i.test(x))break;i.push(u)}let o=i.join(` 72`).trim();o=o.replace(/https?:\/\/\S{40,}/g,"[link]"),o=o.replace(/\n{3,}/g,` 73 74`);const d=o.length<String(s).trim().length;return{text:o,trimmed:d}}function T5(s){const{text:l}=Ul(s.reply_text);if(!l)return{email:null,ambiguous:!1};const i=String(s.email||"").toLowerCase(),o=l.match(/[\w.+-]+@[\w-]+\.[a-z]{2,}/gi)||[],d=new Set,u=[];for(const x of o){const y=x.toLowerCase().replace(/[.,;:)\]]+$/,"");d.has(y)||(d.add(y),y!==i&&(/^(no-?reply|do-?not-?reply|mailer-daemon|postmaster|bounce|notifications?)@/.test(y)||/@(sentry|mailgun|sendgrid|amazonses|mailchimp)\./.test(y)||u.push(y)))}return u.length===1?{email:u[0],ambiguous:!1}:{email:null,ambiguous:u.length>1}}function Po(s,l){return l?"loading":!s||s.verified===!1||s.outcome==="check_inconclusive"||s.basis==="assessment_error"?"unavailable":s.needs_manual_action===!0?"unsafe":"ok"}function Yu(s){const l=s&&typeof s.remaining_steps=="number"?s.remaining_steps:null;return s&&s.reason==="provider_stop_unsupported"?{headline:"More emails are still scheduled to this address",detail:l?`Instantly still has ${l} step${l===1?"":"s"} queued for this lead, and it cannot stop a single lead through its API.`:"Instantly still has steps queued for this lead, and it cannot stop a single lead through its API.",steps:l}:{headline:"Instantly checks did not clear",detail:"The check completed and reported that this address is not safe to hand on yet.",steps:l}}function xm(s){const l=s&&s.outreach;if(l&&l.current_state)switch(l.current_state){case"stopped_by_reply":return"stopped";case"stopped_verified":return"stopped";case"not_enrolled":return"not_enrolled";case"active":return"manual_required";default:return"unverified"}return!s||s.verified===!1?"unverified":s.enrollment_count===0?"not_enrolled":s.stop_on_reply&&s.replied?"stopped":s.needs_manual_action===!0?"manual_required":"active"}function Bo(s){const l=s&&s.outreach;return l&&l.current_label||null}function sf(s){const l=s&&s.outreach;return l&&l.historical_note||null}function R5(s,l=!1){if(l)return"Checking Instantlyâ¦";switch(xm(s)){case"stopped":return Bo(s)||"Follow-ups are already stopped";case"not_enrolled":return"This address is not enrolled in an Instantly campaign";case"active":return"Outreach remains active";case"manual_required":return Bo(s)||"Instantly reports follow-ups are still active, which contradicts this campaign's protection";default:return"Instantly status could not be verified"}}
74function Pu(s,l){const i=l&&l.routing;let o,d;i?(o=i.safe&&i.current_owner_id?String(i.current_owner_id):null,d=i.safe&&i.current_owner_name||null):(o=s.salesperson_owner_id?String(s.salesperson_owner_id):null,d=s.salesperson_owner_id&&s.salesperson_label||null);const u=i&&i.arrival_owner_id||s.arrival_owner_id||null,x=i&&i.arrival_owner_name||s.arrival_owner_name||null,y=!!(i&&i.arrival_recorded_at||s.arrival_recorded_at);return{current_id:o,current_name:d,arrival_id:u?String(u):null,arrival_name:x,changed:y&&String(u||"")!==String(o||"")}}function nf(s,l,i){const o=[],d=l&&l.routing;l?d&&d.held?o.push({key:"routing",state:"blocked",label:"HubSpot handoff unavailable until this campaign has an owner",detail:"An administrator maps the campaign to an active owner."}):d&&d.safe?o.push({key:"routing",state:"ok",label:"Routing confirmed"}):o.push({key:"routing",state:"unknown",label:"Routing state unavailable"}):o.push({key:"routing",state:i?"neutral":"unknown",label:i?"Checking routingâ¦":"Routing check not loaded"});const u=Pu(s,l);return u.current_name?o.push({key:"owner",state:"ok",label:`Handoff owner: ${u.current_name}`,detail:u.changed?u.arrival_name?`Routed to ${u.arrival_name} when this reply arrived. The campaign now hands off to ${u.current_name}.`:`This campaign had no owner when this reply arrived. It now hands off to ${u.current_name}.`:void 0}):s.assigned_owner_name||s.assigned_owner_email?o.push({key:"owner",state:"ok",label:`Owner confirmed â ${s.assigned_owner_name||s.assigned_owner_email}`}):o.push({key:"owner",state:"blocked",label:"No HubSpot owner currently resolves for this campaign",detail:"Configure or activate a campaign owner mapping before using a HubSpot handoff action."}),l?Po(l,!1)==="unsafe"?o.push({key:"instantly",state:"blocked",label:Yu(l).headline,detail:Yu(l).detail}):l.verified?l.enrollment_count===0?o.push({key:"instantly",state:"ok",label:"No campaign enrollment found",detail:"This address is not in an Instantly campaign, so there are no follow-ups to stop."}):l.stop_on_reply&&l.replied?o.push({key:"instantly",state:"ok",label:"Follow-ups already stopped",detail:l.basis_label||void 0}):o.push({key:"instantly",state:"attention",label:"Instantly check completed",detail:l.basis_label||void 0}):o.push({key:"instantly",state:"unknown",label:"Instantly check incomplete â not verified"}):o.push({key:"instantly",state:i?"neutral":"unknown",label:i?"Checking Instantlyâ¦":"Instantly check not loaded"}),l&&l.requires_confirmation&&o.push({key:"confirm",state:"attention",label:"Additional confirmation required",detail:l.confirmation_label||void 0}),o}function z5(s,l,i){const o=i?i.queuesHubSpot:!1;return l&&l.routing&&l.routing.held&&o?{title:"Routing is not configured for this campaign",body:l.headline||"This campaign is not mapped to an active owner, so an approved lead would have nowhere to go.",who:"An administrator can set this up under Campaigns."}:l&&l.error?{title:"The Instantly check could not be completed",body:"The provider did not answer, so we cannot confirm what would happen to this address. The result below is unverified.",who:"Try again shortly, or ask an administrator to check the Instantly connection."}:l&&l.approval_possible===!1&&o&&!(l.routing&&l.routing.held)?{title:"This reply cannot be approved yet",body:l.headline||"One or more checks have not cleared.",who:"Review the checklist above."}:!s.ready_for_sync&&!l?{title:"Not ready to approve",body:s.reason||"This reply needs judgment before it can be handed to HubSpot.",who:"Choose an outcome below."}:null}const Qu=[{key:"approve_sync",label:"Qualified lead",group:"sales",result:"Immediately creates or updates this lead in HubSpot using the verified owner routing, records the approval and closes this review.",queuesHubSpot:!0,requiresProviderStop:!1,leavesQueue:!0},{key:"mark_meeting_scheduled",label:"Meeting booked",group:"sales",result:"Immediately creates or updates the lead in HubSpot, sets the stage to Sales Qualified Lead with status âMeeting Scheduledâ, adds a note and may create a follow-up call task. This closes the review.",queuesHubSpot:!0,requiresProvi
74derStop:!1,leavesQueue:!0},{key:"mark_not_interested",label:"Not interested",group:"outreach",result:"Record as not interested, stop follow-ups and close the review.",queuesHubSpot:!1,requiresProviderStop:!0,leavesQueue:!0},{key:"keep_in_outreach",label:"Keep in outreach",group:"outreach",result:"Close this review and explicitly record that outreach should continue. No HubSpot handoff is created.",queuesHubSpot:!1,requiresProviderStop:!1,leavesQueue:!0},{key:"mark_wrong_contact",label:"Close as wrong contact / referred",group:"correct",result:"Stop follow-ups to this address and close the review as wrong contact / referred.",queuesHubSpot:!1,requiresProviderStop:!0,leavesQueue:!0},{key:"ignore",label:"Set aside",group:"correct",result:"Close this review without recording a sales outcome. This does not change the current Instantly status or create a HubSpot handoff.",queuesHubSpot:!1,requiresProviderStop:!1,leavesQueue:!0},{key:"suppress",label:"Never contact again",group:"protect",destructive:!0,result:"Add this address to do-not-contact protection, locally and in the Instantly workspace block list",queuesHubSpot:!1,requiresProviderStop:!1,leavesQueue:!0},{key:"assign_owner",label:"Set the owner",group:"escalate",adminOnly:!0,result:"Assign an owner so the lead can be approved. The review stays pending.",queuesHubSpot:!1,requiresProviderStop:!1,leavesQueue:!1},{key:"mark_disqualified",label:"Mark disqualified in Fantize",group:"escalate",adminOnly:!0,destructive:!0,result:"Closes the review and updates Fantize only. It does not remove or update the lead in HubSpot.",queuesHubSpot:!1,requiresProviderStop:!1,leavesQueue:!0}];function rf(s,l){const i=xm(l);return s.key==="mark_wrong_contact"?i==="manual_required"?"An administrator must stop or remove this lead in Instantly before this review can be closed.":i==="stopped"||i==="not_enrolled"?"Close this review as wrong contact / referred. Follow-ups are already stopped.":"Stop follow-ups to this address and close the review as wrong contact / referred.":s.key==="mark_not_interested"?i==="manual_required"?"An administrator must stop or remove this lead in Instantly before this review can be closed.":i==="stopped"||i==="not_enrolled"?"Record as not interested and close the review. Follow-ups are already stopped.":"Record as not interested, stop follow-ups and close the review.":s.key==="suppress"?i==="stopped"||i==="not_enrolled"?"Adds this address to Fantize's do-not-contact list and the Instantly workspace block list, so campaigns in this workspace stop sending to it.":"Adds local do-not-contact protection immediately and attempts to verify Instantly block-list protection. Provider confirmation may remain pending.":s.key==="ignore"?"Close this review without recording a sales outcome. This does not change the current Instantly status or create a HubSpot handoff.":s.result}const cp={positive_interest:"approve_sync",meeting_intent:"approve_sync",meeting_scheduled:"mark_meeting_scheduled",referral_wrong_contact:"mark_wrong_contact",not_interested:"mark_not_interested",neutral_ambiguous:"keep_in_outreach",out_of_office:"ignore",spam_junk:"ignore",unsubscribe:"suppress",bounce_invalid:"suppress"};function L5(s){return s.queuesHubSpot||s.requiresProviderStop}function zu(s,l,i=!1){return L5(s)?Po(l,i)!=="ok"?!0:s.queuesHubSpot?!!(l&&(l.routing&&l.routing.held||l.approval_possible===!1)):!1:!1}function lf(s,l,i=!1){switch(Po(l,i)){case"loading":return"Waiting for the Instantly check to complete.";case"unavailable":return"Try the Instantly check again before using this action.";case"unsafe":return"An administrator must stop or remove this lead in Instantly first.";default:return s.queuesHubSpot?"Routing required â an administrator maps this campaign to an owner":""}}function M5(s,l,i){const o=cp[s.classification];return o&&Xu(i).find(d=>d.key===o)||null}function Xu(s){return s==="admin"?Qu:Qu.filter(l=>!l.adminOnly)}function Lu(s,l=Date.now(),i=o=>o){if(!s)return"";const o=new Date(s).getTime();if(Number.isNaN(o))return"";const d=Math.floor((l-o)/6e4);if(d<1)return"just now";if(d<60)return`${d}m ago`;const u=Math.floor(d/60);if(u<24)return`${u}h ago`;const x=Math.floor(u/24);return x<30?`${x}d ago`:i(s)}function Mu(s,l){if(s.status&&s.status!=="pending")return{label:"Resolved",tone:"gray"};const i=l?xm(l):null;if(i==="manual_required")return{label:"Needs Instantly action",tone:"red"};if(i==="unverified")return{label:"Check unavailable",tone:"amber"};const o=s.classification?Qu.find(d=>d.key===cp[s.classification]):void 0;
74return o&&o.queuesHubSpot&&l&&l.routing&&l.routing.held?{label:"Needs routing",tone:"blue"}:o&&o.queuesHubSpot&&!l?{label:"Needs routing check",tone:"blue"}:{label:"Ready for decision",tone:"green"}}function of(s,l){if(l)return null;const i="Do not choose a different business outcome to work around a provider requirement.",o=s&&s.outreach;return o&&o.actionable&&(!s||!s.routing||!s.routing.held)?null:s&&s.routing&&s.routing.held?{kind:"routing",heading:"This campaign needs a salesperson before a HubSpot handoff",body:`Your decision may be correct. A HubSpot handoff cannot be created yet because no active owner resolves for this campaign. Choose the salesperson who should own replies from it, then come back and select the outcome you intended. ${i}`,adminAction:"You can resolve this yourself - choose an active salesperson below.",selfService:!0}:!o||o.current_state==="unknown"?{kind:"unavailable",heading:"Fantize could not check Instantly",body:`Fantize could not verify the current Instantly state for this address, so it stopped rather than guessing. Your decision is not lost. Try the check again; if it keeps failing, this is a technical fault with the integration rather than anything for you to fix. ${i}`,adminAction:"If retrying does not clear it, technical support is required.",selfService:!1}:o.current_state==="active"?{kind:"instantly",heading:"Instantly reports this sequence is still running",body:`Every campaign in this account is required to stop sending when someone replies, so an active sequence here contradicts that guarantee. Fantize will not create a HubSpot handoff while this is true. This is a technical fault to investigate, not a decision for you to work around. ${i}`,adminAction:"Technical support is required: the campaign protection and the provider state disagree.",selfService:!1}:null}const gm={approve_sync:{confirm:!0,system:"HubSpot",closesReview:!0,stopsFollowUps:!1,createsHandoff:!0,undoable:!1,what:"Creates or updates this lead in HubSpot straight away, using the verified owner routing."},mark_meeting_scheduled:{confirm:!0,system:"HubSpot",closesReview:!0,stopsFollowUps:!1,createsHandoff:!0,undoable:!1,what:"Creates or updates the lead in HubSpot straight away, sets the stage to Sales Qualified Lead with status âMeeting Scheduledâ, adds a note, and may create a follow-up call task."},edit_before_sync:{confirm:!0,system:"HubSpot",closesReview:!0,stopsFollowUps:!1,createsHandoff:!0,undoable:!1,what:"Applies your edits and then creates or updates the lead in HubSpot straight away."},mark_not_interested:{confirm:!0,system:"Instantly",closesReview:!0,stopsFollowUps:!0,createsHandoff:!1,undoable:!1,what:"Stops automated follow-ups to this address in Instantly."},mark_wrong_contact:{confirm:!0,system:"Instantly",closesReview:!0,stopsFollowUps:!0,createsHandoff:!1,undoable:!1,what:"Stops automated follow-ups to this address in Instantly."},suppress:{confirm:!0,system:"Instantly",closesReview:!0,stopsFollowUps:!0,createsHandoff:!1,undoable:!1,what:"Adds this address to the do-not-contact list and to the Instantly block list."},keep_in_outreach:{confirm:!1,system:"Fantize only",closesReview:!0,stopsFollowUps:!1,createsHandoff:!1,undoable:!0,what:"Records that outreach should continue and closes the review."},ignore:{confirm:!1,system:"Fantize only",closesReview:!0,stopsFollowUps:!1,createsHandoff:!1,undoable:!0,what:"Closes the review without recording a sales outcome."},mark_disqualified:{confirm:!1,system:"Fantize only",closesReview:!0,stopsFollowUps:!1,createsHandoff:!1,undoable:!0,what:"Marks the lead disqualified in Fantize and closes the review."},assign_owner:{confirm:!0,system:"HubSpot",closesReview:!1,stopsFollowUps:!1,createsHandoff:!1,undoable:!0,what:"Changes who owns this lead, and updates the owner in HubSpot when the contact already exists there."}};function O5(s,l){const i=gm[s];if(!i)return[];const o=[i.what,i.system==="Fantize only"?"This changes Fantize only. Nothing is sent to HubSpot or Instantly.":`This changes ${i.system}.`,i.closesReview?"The review will close.":"The review will stay open.",i.stopsFollowUps?"Follow-up emails will stop.":"Follow-up emails are unaffected.",i.createsHandoff?"A HubSpot handoff will be created.":"No HubSpot handoff will be created."];return i.createsHandoff&&l&&l.current_name&&(o.push(`The HubSpot handoff owner is ${l.current_name}${l.current_id?` (HubSpot owner ${l.current_id})`:""}.`),l.changed&&o.push(l.arrival_name?`This reply was routed to ${l.arrival_name} when it arrived. The handoff uses the current campaign owner.`:"This campaign had no owner when the reply arrived. The handoff uses the current campaign owner.")),o.push(i.undoable?"An administrator can reverse this inside Fantize.":"This cannot be undone inside Fantize."),o}function $5(s,l,i,o){const d={action:s.key,final_classification:o};i?.routing_snapshot_hash&&(d.routing_snapshot_hash=i.routing_snapshot_hash);const u=i?.enrollment_snapshot_hash??i?.snapshot_hash;return u&&(d.enrollment_snapshot_hash=u,(i?.enrollment_count??0)>1&&(d.confirm_workspace_scope=!0)),s.key==="assign_owner"&&(d.confirm_reassignment=!0),d}function D5(s){const[l,i]=h.useState(null),o=h.useRef(new Set);return{submit:h.useCallback(async(u,x,y,p)=>{if(!x?.id)return{kind:"invalid",message:"No review selected."};if(!p)return{kind:"invalid",message:"Choose the category that describes this reply before deciding."};if(o.current.has(x.id))return{kind:"refused",message:"That decision is already being submitted.",retryable:!1};o.current.add(x.id),i(x.id);try{const g=await je.v2ReviewAction(x.id,$5(u,x,y,p));return s?.(x.id),{kind:"success",resolved:!!g?.resolved,syncJob:g?.sync_job??null,message:g?.sync_job?"Recorded. The HubSpot handoff has been sent.":"Recorded."}}catch(g){const b=g?.status,f=g?.payload??{},k=f?.outcome;return b===403&&k==="launch_gate_closed"?{kind:"gated",message:f.error||"This interface is not live yet. Nothing was changed."}:b===409&&k==="already_resolved"?(s?.(x.id),{kind:"conflict",review:f.review,message:"Another person resolved this review first. Nothing further was recorded. The queue has been refreshed."}):b===409&&k==="duplicate_provider_work"?(s?.(x.id),{kind:"duplicate",message:f.error||"A HubSpot handoff is already queued for this lead, so nothing further was created."}):b===409?(s?.(x.id),{kind:"refused",reason:f.reason||k,retryable:!0,message:f.error||f.warning||"A safety check has to be confirmed before this decision can be recorded. The review has been refreshed."}):b===400?{kind:"invalid",message:f.error||"That decision could not be recorded as submitted."}:b===403?{kind:"refused",message:f.error||"You do not have permission for that action.",retryable:!1}:b?{kind:"refused",message:f.error||`That decision could not be recorded (error ${b}).`,retryable:!0}:{kind:"network",retryable:!0,message:"Could not reach Fantize. Nothing was changed. Check your connection and try again."}}finally{o.current.delete(x.id),i(null)}},[s]),pending:l,isPending:u=>o.current.has(u)}}const H5=["positive_interest","meeting_intent","meeting_scheduled","referral_wrong_contact","neutral_ambiguous","not_interested","out_of_office","unsubscribe","bounce_invalid","spam_junk"],q5={approve_sync:"positive_interest",mark_meeting_scheduled:"meeting_scheduled",mark_not_interested:"not_interested",mark_wrong_contact:"referral_wrong_contact",suppress:"unsubscribe",keep_in_outreach:"neutral_ambiguous",ignore:"neutral_ambiguous",mark_disqualified:"not_interested",assign_owner:"positive_interest"};function dp(s,l){return l||q5[s.key]||""}function B5({action:s,suggested:l,submitting:i,gateClosed:o,handoffOwner:d,onCancel:u,onConfirm:x}){const y=gm[s.key],p=O5(s.key,d),[g,b]=h.useState(()=>dp(s,l)),f=h.useRef(null),k=h.useRef(null),w=`confirm-title-${s.key}`,N=`confirm-desc-${s.key}`;h.useEffect(()=>{k.current?.focus();const S=_=>{if(_.key==="Escape"){_.preventDefault(),u();return}if(_.key!=="Tab")return;const z=f.current?.querySelectorAll("button:not([disabled]), select:not([disabled]), [href], input
74:not([disabled])");if(!z||!z.length)return;const A=z[0],L=z[z.length-1];_.shiftKey&&document.activeElement===A?(_.preventDefault(),L.focus()):!_.shiftKey&&document.activeElement===L&&(_.preventDefault(),A.focus())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[u]);const j=y&&!y.undoable,T=y&&y.system!=="Fantize only";return e.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center overflow-y-auto bg-slate-900/50 p-0 backdrop-blur-sm sm:items-center sm:p-4",onMouseDown:S=>{S.target===S.currentTarget&&u()},children:e.jsxs("div",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":w,"aria-describedby":N,className:"w-full max-w-lg rounded-t-2xl bg-white shadow-xl ring-1 ring-slate-900/10 dark:bg-slate-900 dark:ring-white/10 sm:rounded-2xl",children:[e.jsxs("div",{className:"border-b border-slate-200 px-5 py-4 dark:border-slate-700",children:[e.jsx("h2",{id:w,className:"text-base font-semibold text-slate-900 dark:text-white",children:s.label}),e.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:T?`Confirm before Fantize changes ${y.system}.`:"Confirm this decision."})]}),e.jsxs("div",{id:N,className:"px-5 py-4",children:[e.jsx("ul",{className:"space-y-2",children:p.map((S,_)=>e.jsxs("li",{className:"flex gap-2.5 text-sm text-slate-700 dark:text-slate-200",children:[e.jsx("span",{"aria-hidden":"true",className:"mt-[7px] h-1.5 w-1.5 flex-none rounded-full bg-slate-400 dark:bg-slate-500"}),e.jsx("span",{children:S})]},_))}),s.key==="mark_wrong_contact"&&e.jsx("p",{className:"mt-4 rounded-lg bg-amber-50 px-3 py-2 text-sm text-amber-900 ring-1 ring-inset ring-amber-200 dark:bg-amber-400/10 dark:text-amber-200 dark:ring-amber-400/30",children:"The referred person is not saved. Copy their details from the reply first."}),j&&e.jsx("p",{className:"mt-4 rounded-lg bg-amber-50 px-3 py-2 text-sm text-amber-900 ring-1 ring-inset ring-amber-200 dark:bg-amber-400/10 dark:text-amber-200 dark:ring-amber-400/30",children:"Read this once more before confirming. Fantize cannot take it back."}),e.jsxs("div",{className:"mt-4 border-t border-slate-200 pt-4 dark:border-slate-700",children:[e.jsx("label",{htmlFor:`confirm-cat-${s.key}`,className:"block text-sm font-medium text-slate-900 dark:text-white",children:"Category recorded for this reply"}),e.jsx("p",{className:"mt-0.5 text-xs text-slate-500 dark:text-slate-400",children:l?"Fantize suggested this. Change it if the reply says something else.":"Fantize could not categorise this reply, so choose the category yourself."}),e.jsxs("select",{id:`confirm-cat-${s.key}`,value:g,onChange:S=>b(S.target.value),className:"mt-2 min-h-11 w-full rounded-lg border-slate-300 bg-white px-3 text-sm text-slate-900 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:border-slate-600 dark:bg-slate-800 dark:text-white",children:[!g&&e.jsx("option",{value:"",children:"Choose a categoryâ¦"}),H5.map(S=>e.jsxs("option",{value:S,children:[Bl(S),S===l?" â suggested":""]},S))]})]}),o&&e.jsx("p",{className:"mt-4 rounded-lg bg-slate-100 px-3 py-2 text-sm text-slate-600 ring-1 ring-inset ring-slate-200 dark:bg-slate-800 dark:text-slate-300 dark:ring-slate-700",children:"These actions are switched off on the server. Confirming will send the decision and Fantize will refuse it, so nothing will change anywhere."})]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 border-t border-slate-200 px-5 py-4 dark:border-slate-700 sm:flex-row sm:justify-end",children:[e.jsx("button",{type:"button",onClick:u,disabled:i,className:"min-h-11 rounded-lg bg-white px-4 text-sm font-medium text-slate-700 ring-1 ring-inset ring-slate-300 hover:bg-slate-50 disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 dark:bg-slate-800 dark:text-slate-200 dark:ring-slate-600",children:"Cancel"}),e.jsx("button",{ref:k,type:"button",onClick:()=>x(g),disabled:i||!g,className:`min-h-11 rounded-lg px-4 text-sm font-semibold text-white shadow-sm disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-slate-900 ${s.destructive?"bg-rose-600 hover:bg-rose-700 focus-visible:ring-rose-500":s.group==="sales"?"bg-emerald-600 hover:bg-emerald-700 focus-visible:ring-emerald-500":"bg-indigo-600 hover:bg-indigo-700 focus-visible:ring-indigo-500"}`,children:i?"Submittingâ¦":g?`Confirm ${s.label.toLowerCase()}`:"Choose a category"})]})]})})}function U5({reviewId:s,campaignName:l,onResolved:i}
74){const o=Ja(),[d,u]=h.useState(null),[x,y]=h.useState(""),[p,g]=h.useState("choose"),[b,f]=h.useState(null),[k,w]=h.useState(!1),[N,j]=h.useState(null),T=h.useRef(null),S=h.useCallback(()=>je.routingOptions().then(A=>u((A?.owners||[]).map(L=>({id:String(L.id),name:L.name})))).catch(()=>u([])),[]);h.useEffect(()=>{let A=!0;return S().then(()=>{A||u(null)}),()=>{A=!1}},[S]),h.useEffect(()=>{y(""),g("choose"),f(null),j(null)},[s]),h.useEffect(()=>{p==="confirm"&&T.current?.focus()},[p]);const _=d?.find(A=>A.id===x)||null,z=h.useCallback(async()=>{if(_){if(f(null),o.readOnly){j({owner_id:_.id,owner_name:_.name}),g("done");return}w(!0);try{const A=await je.resolveRouting(s,{owner_id:_.id,confirm:!0}),L={owner_id:String(A.owner_id),owner_name:A.owner_name||_.name};j(L),g("done"),i(L)}catch(A){const L=A?.payload?.outcome;L==="owner_inactive"||L==="owner_not_found"?(f("That salesperson is no longer available. Choose another active salesperson."),y(""),g("choose"),S()):L==="launch_gate_closed"?(f("Routing updates are temporarily unavailable until launch. Nothing was changed."),g("choose")):(f(A?.payload?.error||A?.message||"The routing update did not complete. Nothing was changed."),g("choose"))}finally{w(!1)}}},[_,o.readOnly,s,i,S]);return p==="done"&&N?e.jsxs("div",{role:"status",className:"mb-3 rounded-xl border-l-4 border-emerald-400 bg-emerald-50 p-4 dark:border-emerald-500 dark:bg-emerald-950/30",children:[e.jsx("p",{className:"text-sm font-medium text-emerald-900 dark:text-emerald-200",children:o.readOnly?`Marketing Preview is read-only, so nothing was changed. Outside preview this would assign ${N.owner_name} to this campaign.`:"Campaign routing updated. HubSpot handoff actions are now available."}),!o.readOnly&&e.jsxs("p",{className:"mt-1 text-sm text-emerald-900/90 dark:text-emerald-100/90",children:[N.owner_name," will receive qualified leads from this campaign. Review the reply and choose the outcome you intended â nothing has been decided for you."]})]}):e.jsxs("div",{role:"region","aria-label":"Assign a salesperson to this campaign",className:"mb-3 rounded-xl border-l-4 border-blue-400 bg-blue-50 p-4 dark:border-blue-500 dark:bg-blue-950/30",children:[e.jsx("p",{className:"text-sm font-semibold text-blue-900 dark:text-blue-200",children:"No active salesperson is assigned to this campaign"}),e.jsx("p",{className:"mt-1 text-sm text-blue-900/90 dark:text-blue-100/90",children:"Choose the salesperson who should receive qualified leads from this campaign. This assigns the sales handoff for the campaign â it is not administrator access, and it changes nothing else."}),b&&e.jsx("div",{className:"mt-2",children:e.jsx(Ne,{tone:"amber",children:b})}),p==="choose"&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx("label",{htmlFor:"routing-owner",className:"sr-only",children:"Salesperson for this campaign"}),e.jsxs("select",{id:"routing-owner",value:x,onChange:A=>y(A.target.value),className:"min-h-11 min-w-0 flex-1 rounded-lg border border-blue-300 bg-white px-3 text-sm text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 dark:border-blue-500/50 dark:bg-slate-800 dark:text-slate-100 sm:w-64 sm:flex-none",children:[e.jsx("option",{value:"",children:d===null?"Loading salespeopleâ¦":"Choose a salespersonâ¦"}),(d||[]).map(A=>e.jsx("option",{value:A.id,children:A.name},A.id))]}),e.jsx(U,{size:"sm",disabled:!x,onClick:()=>g("confirm"),className:"min-h-11 min-w-11",children:"Continue"})]}),p==="confirm"&&_&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("p",{ref:T,tabIndex:-1,className:"text-sm text-blue-900 outline-none dark:text-blue-100",children:["You are assigning ",e.jsx("span",{className:"font-semibold",children:_.name})," to"," ",e.jsx("span",{className:"font-semibold",children:l||"this campaign"}),". This will be used for this review and future replies from the campaign."]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(U,{size:"sm",onClick:z,disabled:k,className:"min-h-11 min-w-11",children:k?"Assigningâ¦":"Assign salesperson"}),e.jsx(U,{size:"sm",variant:"soft",onClick:()=>g("choose"),disabled:k,className:"min-h-11 min-w-11",children:"Back"})]})]})]})}const zo={ok:{glyph:"â",className:"bg-emerald-50 text-emerald-700 ring-emerald-600/20 dark:bg-emerald-500/10 dark:text-emerald-300 dark:ring-emerald-400/20",sr:"Confirmed"},blocked:{glyph:"â",className:"bg-rose-50 text-rose-700 ring-rose-600/20 dark:bg-rose-500/10 dark:text-rose-300 dark:ring-rose-400/20",sr:"Blocked"},attention:{glyph:"!",className:"bg-amber-50 text-amber-800 ring-amber-600/20 dark:bg-amber-500/10 dark:text-amber-300 dark:ring-amber-400/20",sr:"Needs attention"},unknown:{glyph:"?",className:"bg-slate-100 text-slate-600 ring-slate-500/20 dark:bg-slate-500/10 dark:text-slate-300 dark:ring-slate-400/20",sr:"Unavailable"},neutral:{glyph:"â¦",className:"bg-slate-100 text-slate-500 ring-slate-500/20 dark:bg-slate-500/10 dark:text-slate-400 dark:ring-slate-400/20",sr:"Checking"}};function F5({title:s,count:l,children:i,defaultOpen:o=!1}
74){const[d,u]=h.useState(o);return e.jsxs("div",{className:"border-t border-slate-200 dark:border-slate-700/70",children:[e.jsxs("button",{type:"button",onClick:()=>u(x=>!x),"aria-expanded":d,className:"w-full min-h-[44px] flex items-center justify-between gap-3 py-3 text-left text-sm font-medium text-slate-700 dark:text-slate-200 hover:text-slate-900 dark:hover:text-white focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-slate-900 rounded",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[s,typeof l=="number"&&e.jsx("span",{className:"text-xs font-normal text-slate-400 dark:text-slate-500",children:l})]}),e.jsx("span",{"aria-hidden":"true",className:`inline-flex w-4 flex-none justify-center text-slate-400 transition-transform motion-reduce:transition-none ${d?"rotate-90":""}`,children:"âº"})]}),d&&e.jsx("div",{className:"pb-4 text-sm text-slate-600 dark:text-slate-300",children:i})]})}function I5({item:s}){const l=zo[s.state];return e.jsxs("li",{className:"flex items-start gap-3 py-2",children:[e.jsx("span",{className:`mt-0.5 flex h-5 w-5 flex-none items-center justify-center rounded-full text-[11px] font-bold ring-1 ring-inset ${l.className}`,"aria-hidden":"true",children:l.glyph}),e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"sr-only",children:[l.sr,": "]}),e.jsx("span",{className:"text-sm text-slate-800 dark:text-slate-100",children:s.label}),s.detail&&e.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-slate-500 dark:text-slate-400 break-words",children:s.detail})]})]})}function cf({action:s,blocked:l,blockedReason:i,resultText:o,onSelect:d,state:u,prominent:x}){const y="w-full rounded-xl px-4 text-left ring-1 ring-inset transition-colors motion-reduce:transition-none focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-slate-900",p=x?"min-h-[68px] py-3":"min-h-[60px] py-2.5",g=s.group==="sales",b=l?"bg-slate-100 text-slate-400 ring-slate-200 cursor-not-allowed dark:bg-slate-800/40 dark:text-slate-500 dark:ring-slate-700":s.destructive?x?"bg-rose-50 text-rose-800 ring-rose-300 hover:bg-rose-100 dark:bg-rose-500/10 dark:text-rose-200 dark:ring-rose-400/40":"bg-white text-rose-700 ring-rose-300 hover:bg-rose-50 dark:bg-slate-800 dark:text-rose-300 dark:ring-rose-500/40":x?g?"bg-emerald-600 text-white ring-emerald-600 hover:bg-emerald-700 shadow-sm":"bg-indigo-600 text-white ring-indigo-600 hover:bg-indigo-700 shadow-sm":g?"bg-white text-emerald-800 ring-emerald-300 hover:bg-emerald-50 dark:bg-slate-800 dark:text-emerald-300 dark:ring-emerald-500/40":"bg-white text-slate-800 ring-slate-300 hover:bg-slate-50 dark:bg-slate-800 dark:text-slate-100 dark:ring-slate-600";return e.jsx("button",{type:"button",disabled:l,"aria-disabled":l,onClick:()=>d(s.key),className:`${y} ${p} ${b}`,children:e.jsxs("span",{className:"flex items-start justify-between gap-2",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:`block font-semibold ${x?"text-[15px]":"text-sm"}`,children:[x&&e.jsx("span",{className:"mr-1.5","aria-hidden":"true",children:"â
"}),s.label]}),e.jsx("span",{className:`mt-0.5 block text-xs leading-snug ${x&&!s.destructive?"text-white/85":l?"":"text-slate-500 dark:text-slate-400"}`,children:l?i:o})]}),(u||l)&&e.jsx("span",{className:"flex-none whitespace-nowrap rounded-full bg-black/10 px-2 py-0.5 text-[11px] font-medium dark:bg-white/10",children:u||(i&&/Waiting/.test(i)?"Checkingâ¦":"Unavailable")})]})})}function V5(s){return s.key==="routing"||s.key==="owner"?s.state==="ok"?s.key==="routing"?"Routing confirmed":s.label.startsWith("Handoff owner:")?s.label:"HubSpot owner set":s.state==="blocked"?"No HubSpot owner resolves":"Routing check unavailable":s.key==="instantly"?s.state==="unknown"?"Instantly check unavailable":/no campaign enrollment/i.test(s.label)?"Not enrolled in Instantly":/stopped/i.test(s.label)?"Follow-ups stopped":"Follow-ups still scheduled":s.label}function G5(){const{isAdmin:s}=zt(),l=Ja(),i=l.asMarketing?!1:s,[o,d]=h.useState("pending"),u=i?"admin":"reviewer",[x,y]=h.useState(null),[p,g]=h.useState(null),[b,f]=h.useState(!0),[k,w]=h.useState(null),[N,j]=h.useState(""),[T,S]=h.useState("all"),[_,z]=h.useState("all"),[A,L]=h.useState("all"),F=h.useRef(null),[D,te]=h.useState("newest"),[pe,he]=h.useState(!1),[X,I]=h.useState({}),[q,be]=h.useState(!1),[ne,M]=h.useState(null),[Y,oe]=h.useState(null),[Ce,Ae]=h.useState(null),[H,Z]=h.useState(null),[$,O]=h.useState(""),[P,V]=h.useState(null),ye=(K,Re)=>{try{navigator.clipboard?.writeText(K)}catch{}V(Re),setTimeout(()=>V(null),2e3)},ge=h.useRef(null),qe=h.useRef(null),nt=h.useRef(null),[R,we]=h.useState("none"),ie="fantize.replyScrollCue.dismissed",[Ee,Je]=h.useState(()=>{try{return localStorage.getItem(ie)==="1"}catch{return!1}}),me=h.useCallback(()=>{Je(!0);try{localStorage.setItem(ie,"1")}catch{}},[]);h.useEffect(()=>{let K=!0;return je.v2LaunchState().then(Re=>{K&&oe(!!Re?.actions_enabled)}).catch(()=>{K&&oe(null)}),()=>{K=!1}},[]);const ke=h.useCallback(async K=>{f(!0),g(null);try{const Re=await je.reviews(K);y(Re.reviews||[]);try{const Ue=new URLSearchParams(window.location.search).get("review");Ue&&(Re.reviews||[]).some(Ge=>Ge.id===Ue)&&(Oe(!1),w(Ue))}catch{}}catch(Re){y(null),g(Re?.message||"The review queue could not be loaded.")}finally{f(!1)}},[]);h.useEffect(()=>{qe.current=k},[k]),h.useEffect(()=>{b&&O("")},[b]),h.useEffect(()=>{w(null),Oe(!1),ke(o)},[o,ke]);const ze=h.useMemo(()=>{const K=x||[],Re=N.trim().toLowerCase();let Ue=K.filter(Ge=>
74!(Re&&!(String(Ge.email||"").toLowerCase().includes(Re)||String(Ru(Ge).primary).toLowerCase().includes(Re))||_!=="all"&&Ge.classification!==_||A!=="all"&&(Ge.salesperson_key||"unassigned")!==A||T==="ready"&&!Ge.ready_for_sync||T==="blocked"&&Ge.ready_for_sync||T==="attention"&&!(Ge.assigned_conflict||!Ge.classification||typeof Ge.confidence=="number"&&Ge.confidence<70)));return Ue=Ue.slice().sort((Ge,Sa)=>{const sa=new Date(Ge.occurred_at||Ge.created_at||0).getTime(),cs=new Date(Sa.occurred_at||Sa.created_at||0).getTime();return D==="newest"?cs-sa:sa-cs}),Ue},[x,N,_,A,T,D]),C=h.useMemo(()=>k&&(x||[]).find(K=>K.id===k)||null,[k,x]);h.useEffect(()=>{if(!C)return;if(X[C.id]!==void 0){M(null);return}let K=!1;return be(!0),M(null),je.reviewInstantlySafety(C.id,C.classification||void 0).then(Re=>{K||I(Ue=>({...Ue,[C.id]:Re}))}).catch(Re=>{K||(M(Re?.message||"The Instantly check could not be loaded."),I(Ue=>({...Ue,[C.id]:null})))}).finally(()=>{K||be(!1)}),()=>{K=!0}},[C,X]);const[ve,Oe]=h.useState(!1),dt=h.useRef(null);h.useEffect(()=>{if(b||!x||ve&&!k)return;const K=ze.map(Ge=>Ge.id),Re=dt.current!==A;if(dt.current=A,!Re&&k&&K.includes(k))return;const Ue=K[0]||null;Ue!==k&&(w(Ue),nt.current&&(nt.current.scrollTop=0),ge.current&&(ge.current.scrollTop=0),Z(null),Ae(null),O(Ue?`Showing ${ze[0]?.email||"the first reply"}, ${ze.length} ${ze.length===1?"reply":"replies"} in this view.`:"No replies match this view."))},[ze,x,b,k,A,ve]);const Q=5,[He,It]=h.useState({}),[Ls,Ms]=h.useState(null);h.useEffect(()=>{let K=!0;return je.syncErrors().then(Re=>{if(!K)return;const Ue={};for(const Ge of Re?.errors||[]){if(!Ge?.lifecycle_id)continue;const sa=Number(Ge.attempts||0)>=Q;Ue[Ge.lifecycle_id]=sa?"Fantize could not complete the HubSpot handoff after retrying. Technical support is required. Your decision and the attempt history have been preserved.":"The HubSpot handoff did not complete on the first attempt. Fantize will retry automatically. The review remains protected, and the handoff will not be created twice."}It(Ue)}).catch(()=>{}),()=>{K=!1}},[o]);const[un,qr]=h.useState(null),Zl=h.useCallback(async()=>{const K=x?.find(Ge=>Ge.id===k);if(!K)return;const Re=of(X[K.id]??null,q),Ue=[`Review: ${K.id}`,`Reply from: ${K.email||"unknown"}`,`Campaign: ${K.campaign_name||"unknown"}`,`Blocked because: ${Re?Re.heading.replace(/^Your decision may be correct - /,""):"a required check has not cleared"}`,`Administrator action: ${Re?Re.adminAction:"Re-run the safety and routing checks for this review."}`].join(` 75`);try{await navigator.clipboard.writeText(Ue),qr("ok")}catch{qr("fail")}},[x,k,X,q]);h.useEffect(()=>{qr(null),Ms(null)},[k]),h.useEffect(()=>{Z(null),Ae(null),V(null)},[k,o]),h.useEffect(()=>{const K=()=>{const Re=nt.current;if(!Re)return;if(!(Re.scrollHeight>Re.clientHeight+2))return we("none");const Ge=Re.scrollTop+Re.clientHeight>=Re.scrollHeight-4;we(Ge?"end":"more")};return K(),window.addEventListener("resize",K),()=>window.removeEventListener("resize",K)},[k,o,x]),h.useEffect(()=>{if(Ee||R!=="more")return;const K=setTimeout(me,2e3);return()=>clearTimeout(K)},[Ee,R,k,me]);const Xo=h.useCallback((K,Re)=>{q||(be(!0),M(null),je.reviewInstantlySafety(K,Re||void 0).then(Ue=>I(Ge=>qe.current===K?{...Ge,[K]:Ue}:Ge)).catch(Ue=>{qe.current===K&&(M(Ue?.message||"The Instantly check could not be loaded."),I(Ge=>({...Ge,[K]:null})))}).finally(()=>{qe.current===K&&be(!1)}))},[q]);h.useEffect(()=>{!k||!ge.current||(ge.current.focus({preventScroll:!0}),window.scrollTo({top:0,behavior:"auto"}))},[k]);const Un=h.useMemo(()=>{const K=(x||[]).filter(Ue=>o==="pending"?Ue.status==="pending":Ue.status!=="pending").filter(Ue=>A==="all"||(Ue.salesperson_key||"unassigned")===A),Re={all:K.length,ready:0,blocked:0,attention:0};for(const Ue of K){const Ge=Mu(Ue,X[Ue.id]??void 0).label;Ge==="Ready for decision"?Re.ready++:Ge==="Needs routing"||Ge==="Needs routing check"?Re.blocked++:Re.attention++}return Re},[x,o,A,X]),Os=h.useMemo(()=>{const K=new Map;for(const Ue of x||[]){const Ge=Ue.salesperson_key||"unassigned",Sa=Ue.salesperson_label||"Unassigned /
75needs routing";Ge===A&&(F.current=Sa);const sa=K.get(Ge);sa?sa.count+=1:K.set(Ge,{key:Ge,label:Sa,count:1})}const Re=Array.from(K.values()).sort((Ue,Ge)=>(Ue.key==="unassigned"?1:0)-(Ge.key==="unassigned"?1:0)||Ue.label.localeCompare(Ge.label));return A!=="all"&&!Re.some(Ue=>Ue.key===A)&&Re.unshift({key:A,label:F.current||"Selected salesperson",count:0}),Re},[x,A]),Jt=(_!=="all"?1:0)+(A!=="all"?1:0)+(T!=="all"?1:0),es="The referred person is not saved. Copy their details from the reply first.",aa=h.useCallback(K=>{ke(o),qe.current===K&&I(Re=>{const Ue={...Re};return delete Ue[K],Ue})},[ke,o]),{submit:Wo,pending:Br}=D5(aa),Kl=h.useMemo(()=>Xu("admin"),[]),mn=h.useCallback(K=>{const Re=Kl.find(Ue=>Ue.key===K);if(Re){if(Z(null),gm[K]?.confirm){Ae(Re);return}hn(Re,dp(Re,C?.classification))}},[Kl,C]);async function hn(K,Re){if(!C)return;if(l.readOnly){Ae(null),Z({kind:"refused",retryable:!1,actionKey:K.key,message:"Marketing Preview is read-only. Exit preview to make a decision."});return}const Ue=await Wo(K,C,X[C.id],Re);qe.current===C.id&&(Ae(null),Z({...Ue,actionKey:K.key}))}return e.jsxs("div",{className:"w-full pb-16",children:[e.jsx("div",{"aria-live":"polite",className:"sr-only",children:$}),e.jsxs("div",{className:k?"hidden lg:block":"",children:[e.jsx(Xe,{title:"Reply Review",subtitle:"Replies from your outbound campaigns. Pending replies are waiting for a person to decide; Resolved is the record of what was decided and by whom.",status:Y===!1?e.jsx(We,{kind:"disabled",label:"Manual decisions: switched off on the server"}):Y?e.jsx(We,{kind:"ready",label:"Manual decisions: live â approvals write to HubSpot and Instantly"}):e.jsx(We,{kind:"unavailable",label:"Checking whether manual decisions are live"})}),Y===!1&&e.jsx("div",{className:"-mt-2 mb-4",children:e.jsx(Ne,{tone:"blue",children:"Decisions are temporarily switched off while the launch is completed. You can read every reply and check its routing and safety now; pressing a decision will be declined until they are switched on, and nothing reaches HubSpot or Instantly in the meantime."})}),Y&&(x||[]).length>0&&e.jsx("div",{className:"-mt-2 mb-4",children:e.jsx(Ne,{tone:"amber",children:"Decisions here are live. Approving a reply writes to HubSpot and stopping outreach writes to Instantly, immediately."})}),Y===null&&e.jsx("div",{className:"-mt-2 mb-4",children:e.jsx(Ne,{tone:"blue",children:"Checking with the server whether decisions are switched on. Until that answer arrives, treat every control as though it will act."})})]}),e.jsxs("div",{className:`${k?"hidden lg:flex":"flex"} mb-4 flex-wrap items-center gap-2`,children:[e.jsx("div",{role:"tablist","aria-label":"Queue status",className:"inline-flex rounded-xl bg-slate-100 p-1 dark:bg-slate-800",children:["pending","resolved"].map(K=>e.jsxs("button",{role:"tab","aria-selected":o===K,onClick:()=>d(K),className:`min-h-[44px] rounded-lg px-3.5 text-sm font-medium capitalize transition-colors motion-reduce:transition-none focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 ${o===K?"bg-white text-slate-900 shadow-sm dark:bg-slate-700 dark:text-white":"text-slate-600 dark:text-slate-300"}`,children:[K,o===K&&x&&e.jsx("span",{className:"ml-1.5 text-xs text-slate-400",children:ze.length})]},K))}),e.jsxs("label",{className:"order-last w-full min-w-0 sm:order-none sm:w-auto sm:flex-1 sm:max-w-xs",children:[e.jsx("span",{className:"sr-only",children:"Search by sender or email"}),e.jsx("input",{type:"search",value:N,onChange:K=>j(K.target.value),placeholder:"Search sender or email",className:de+" min-h-[44px]"})]}),e.jsxs("label",{className:"hidden min-w-0 sm:block sm:w-52",children:[e.jsx("span",{className:"sr-only",children:"Filter by salesperson"}),e.jsxs("select",{value:A,onChange:K=>L(K.target.value),className:de+" min-h-[44px]",children:[e.jsx("option",{value:"all",children:"All salespeople"}),Os.map(K=>e.jsxs("option",{value:K.key,children:[K.key==="unassigned"?K.label:`All campaigns for ${K.label}`," (",K.count,")"]},K.key))]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs(U,{variant:"soft",onClick:()=>he(K=>!K),className:"min-h-[44px]",children:["Filters",Jt>0?` (${Jt})`:""]}),pe&&e.jsx("div",{className:"absolute right-0 z-20 mt-2 w-72 rounded-2xl border border-slate-200 bg-white p-4 shadow-lg dark:border-slate-700 dark:bg-slate-800",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-xs font-medium text-slate-500 dark:text-slate-400",children:"Readiness"}),e.jsxs("select",{value:T,onChange:K=>S(K.target.value),className:de+" min-h-[44px]",children:[e.jsxs("option",{value:"all",children:["All (",Un.all,")"]}),e.jsxs("option",{value:"ready",children:["Ready for decision (",Un.ready,")"]}),e.jsxs("option",{value:"blocked",children:["Needs routing (",Un.blocked,")"]}),e.jsxs("option",{value:"attention",children:["Needs attention (",Un.attention,")"]})]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-xs font-medium text-slate-500 dark:text-slate-400",children:"Classification"}
75),e.jsxs("select",{value:_,onChange:K=>z(K.target.value),className:de+" min-h-[44px]",children:[e.jsx("option",{value:"all",children:"All"}),Object.keys(Tu).map(K=>e.jsx("option",{value:K,children:Bl(K)},K))]})]}),e.jsxs("label",{className:"block sm:hidden",children:[e.jsx("span",{className:"mb-1 block text-xs font-medium text-slate-500 dark:text-slate-400",children:"Campaign"}),e.jsxs("select",{value:A,onChange:K=>L(K.target.value),className:de+" min-h-[44px]","aria-label":"Filter by salesperson",children:[e.jsx("option",{value:"all",children:"All"}),Os.map(K=>e.jsxs("option",{value:K.key,children:[K.key==="unassigned"?K.label:`All campaigns for ${K.label}`," (",K.count,")"]},K.key))]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-xs font-medium text-slate-500 dark:text-slate-400",children:"Sort"}),e.jsxs("select",{value:D,onChange:K=>te(K.target.value),className:de+" min-h-[44px]",children:[e.jsx("option",{value:"newest",children:"Newest first"}),e.jsx("option",{value:"oldest",children:"Oldest first"})]})]}),e.jsx(U,{variant:"ghost",onClick:()=>{z("all"),L("all"),S("all")},className:"min-h-[44px]",children:"Clear filters"})]})})]})]}),e.jsxs("div",{className:"lg:grid lg:grid-cols-[minmax(320px,380px)_minmax(0,1fr)] lg:gap-6 lg:items-start",children:[e.jsxs("section",{"aria-label":"Replies awaiting review",className:`${k?"hidden lg:block":"block"} min-w-0 lg:sticky lg:top-4 lg:max-h-[calc(100vh-7rem)] lg:overflow-y-auto rounded-2xl border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-800/60`,children:[b&&e.jsx("ul",{className:"divide-y divide-slate-100 dark:divide-slate-700/60","aria-hidden":"true",children:[0,1,2,3].map(K=>e.jsxs("li",{className:"p-4",children:[e.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-slate-200 motion-reduce:animate-none dark:bg-slate-700"}),e.jsx("div",{className:"mt-2 h-3 w-full animate-pulse rounded bg-slate-100 motion-reduce:animate-none dark:bg-slate-700/60"}),e.jsx("div",{className:"mt-1.5 h-3 w-4/5 animate-pulse rounded bg-slate-100 motion-reduce:animate-none dark:bg-slate-700/60"})]},K))}),!b&&p&&e.jsxs("div",{className:"p-4",children:[e.jsxs(Ne,{tone:"red",children:[p," This is a loading problem, not an empty queue."]}),e.jsx("div",{className:"mt-3",children:e.jsx(U,{size:"sm",variant:"soft",onClick:()=>ke(o),children:"Try again"})})]}),!b&&!p&&ze.length===0&&e.jsx("div",{className:"p-6",children:(x||[]).length===0?e.jsx(Ze,{tone:"positive",title:o==="pending"?"No replies need a decision":"No resolved replies yet",hint:o==="pending"?"When someone replies to a campaign, Fantize reads it, runs the safety checks and opens a review here. Nothing is waiting on you.":"Decisions you and your colleagues make on Pending replies are recorded here.",doing:"Monitoring for replies",next:{to:"/dashboard/leads/activity",label:"Check system health in Activity & Issues"}}):e.jsx(Ze,{title:"No replies match these filters",hint:`${(x||[]).length} ${(x||[]).length===1?"reply is":"replies are"} hidden by the active filters.`,action:e.jsx(U,{size:"sm",variant:"soft",onClick:()=>{z("all"),L("all"),S("all"),j("")},children:"Clear filters"})})}),!b&&!p&&ze.length>0&&e.jsx("ul",{className:"divide-y divide-slate-100 dark:divide-slate-700/60",children:ze.map(K=>{const Re=Ru(K),Ue=Mu(K,X[K.id]??void 0),Ge=Ul(K.reply_text),Sa=K.id===k;return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>{Oe(!1),w(K.id)},"aria-current":Sa?"true":void 0,className:`w-full px-4 py-3.5 text-left transition-colors motion-reduce:transition-none focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-500 ${Sa?"bg-indigo-50 dark:bg-indigo-500/10 border-l-[3px] border-indigo-600 pl-[13px] dark:border-indigo-400":"border-l-[3px] border-transparent pl-[13px] hover:bg-slate-50 dark:hover:bg-slate-700/40"}`,children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-slate-900 dark:text-white",children:Re.primary}),e.jsx("span",{className:"flex-none text-xs text-slate-400",children:Lu(K.occurred_at||K.created_at,Date.now(),Ke)})]}),Re.secondary&&e.jsx("div",{className:"truncate text-xs text-slate-500 dark:text-slate-400",children:Re.secondary}),Ge.text&&e.jsx("p",{className:"mt-1.5 line-clamp-2 text-sm leading-snug text-slate-600 dar
75k:text-slate-300",children:Ge.text}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[e.jsx(se,{tone:Tu[K.classification]||"gray",children:Bl(K.classification)}),e.jsx(se,{tone:Ue.tone,children:Ue.label}),K.overdue&&typeof K.waiting_hours=="number"&&e.jsx(se,{tone:"red",children:`Waiting ${Math.round(K.waiting_hours/24)}d`}),typeof K.confidence=="number"&&e.jsxs("span",{className:"text-xs text-slate-400",children:[K.confidence,"% confident"]})]}),(K.campaign_name||K.instantly_campaign)&&e.jsx("div",{className:"mt-1 truncate text-xs text-slate-400 dark:text-slate-500",children:K.campaign_name||K.instantly_campaign})]})},K.id)})})]}),e.jsxs("section",{"aria-label":"Selected reply",className:`${k?"block":"hidden lg:block"} mt-4 lg:mt-0 min-w-0`,children:[!C&&e.jsx("div",{className:"hidden rounded-2xl border border-dashed border-slate-300 p-10 text-center lg:block dark:border-slate-700",children:e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:"Choose a reply from the queue to review it."})}),C&&(()=>{const K=X[C.id]??null,Re=M5(C,K,u),Ue=q?null:z5(C,K,Re),Ge=Xu(u).filter(Pe=>
75Pe.key!==(Re&&Re.key)),sa=[Re,...Ge].filter(Boolean).some(Pe=>zu(Pe,K,q))?of(K,q):null,cs=Mu(C,K);return e.jsxs("div",{ref:ge,tabIndex:-1,className:"rounded-2xl border border-slate-200 bg-white focus:outline-none dark:border-slate-700 dark:bg-slate-800/60",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-slate-200 px-4 py-3 dark:border-slate-700 sm:px-5",children:[e.jsxs("button",{type:"button",onClick:()=>{Oe(!0),w(null)},className:"-ml-1 inline-flex min-h-[44px] min-w-[44px] items-center gap-1 rounded-lg px-2 text-sm font-medium text-indigo-600 hover:bg-indigo-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 lg:hidden dark:text-indigo-400 dark:hover:bg-indigo-500/10",children:[e.jsx("span",{"aria-hidden":"true",children:"â¹"})," Queue"]}),e.jsx("h2",{className:"min-w-0 flex-1 break-all text-base font-semibold text-slate-900 dark:text-white sm:text-lg",children:Ru(C).primary}),e.jsx(se,{tone:cs.tone,children:cs.label}),e.jsxs("p",{className:"w-full truncate text-xs text-slate-500 dark:text-slate-400",children:[C.campaign_name||C.instantly_campaign||"No campaign recorded"," · ",Lu(C.occurred_at||C.created_at,Date.now(),Ke)," · ",C.status==="pending"?"Awaiting a decision":`Resolved${C.final_classification?` â ${Bl(C.final_classification)}`:""}`]})]}),e.jsxs("div",{className:"px-4 pt-4 sm:px-5",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{ref:nt,role:"region","aria-label":"Reply message",tabIndex:0,onScroll:Pe=>{const Dt=Pe.currentTarget;if(Dt.scrollTop>0&&me(),Dt.scrollHeight<=Dt.clientHeight+2)return we("none");const Jl=Dt.scrollTop+Dt.clientHeight>=Dt.scrollHeight-4;we(Jl?"end":"more")},className:`preview-reply max-h-[min(34vh,220px)] overflow-y-auto overscroll-contain rounded-xl bg-slate-50 px-4 py-3 text-[15px] leading-relaxed text-slate-800 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 sm:max-h-[240px] lg:max-h-[264px] dark:bg-slate-900/40 dark:text-slate-100 ${R!=="none"?"preview-reply--scrolls":""}`,children:e.jsx("p",{className:"whitespace-pre-wrap [overflow-wrap:anywhere]",children:Ul(C.reply_text).text||"No message text was captured for this reply."})}),R==="more"&&!Ee&&e.jsxs(e.Fragment,{children:[e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 h-10 rounded-b-xl bg-gradient-to-t from-slate-50 via-slate-50/80 to-transparent dark:from-slate-900/60 dark:via-slate-900/40"}),e.jsx("span",{"aria-hidden":"true",className:"preview-cue pointer-events-none absolute bottom-1.5 left-1/2 -translate-x-1/2 rounded-full bg-slate-700/85 px-2.5 py-0.5 text-[11px] font-medium text-white shadow-sm",children:"Scroll to read more"})]})]}),Ul(C.reply_text).trimmed&&e.jsx("p",{className:"mt-1.5 text-xs text-slate-400",children:"Quoted history and signature hidden. The untouched message is under Details."})]}),e.jsxs("p",{className:"px-4 pb-2 text-xs text-slate-500 sm:px-5 dark:text-slate-400",children:["Instantly: ",R5(K,q)]}),C.classification?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 px-4 pb-3 text-sm sm:px-5",children:[e.jsx("span",{className:"text-slate-400",children:"Fantize suggests"}),e.jsx(se,{tone:Tu[C.classification]||"gray",children:Bl(C.classification)}),e.jsxs("span",{className:"text-xs text-slate-400",children:[typeof C.confidence=="number"?`${C.confidence}% confident`:"confidence not recorded"," · you decide"]})]}):e.jsx("div",{className:"mx-4 mb-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 sm:mx-5 dark:border-amber-900/60 dark:bg-amber-950/30",children:A5(C).map((Pe,Dt)=>e.jsx("p",{className:Dt===0?"text-sm font-medium text-amber-900 dark:text-amber-200":"mt-0.5 text-xs text-amber-800 dark:text-amber-300",children:Pe},Dt))}),(()=>{const Pe=Po(K,q);if(Pe==="ok"||Pe==="loading")return null;if(Pe==="unsafe"){const Dt=Yu(K);return e.jsx("div",{className:"px-4 pb-3 sm:px-5",children:e.jsxs("div",{className:"rounded-xl bg-rose-50 px-4 py-3 text-sm ring-1 ring-inset ring-rose-600/20 dark:bg-rose-500/10 dark:ring-rose-400/20",children:[e.jsx("p",{className:"font-semibold text-rose-900 dark:text-rose-200",children:Dt.headline}),e.jsx("p",{className:"mt-0.5 text-rose-900/80 dark:text-rose-200/80",children:Dt.detail}),e.jsx("p",{className:"mt-1.5 text-rose-900/80 dark:text-rose-200/80",children:"Leave this review pending and notify an administrator. An administrator stops or removes the lead in Instantly, then re-checks it here."})]})})}return e.jsx("div",{className:"px-4 pb-3 sm:px-5",children:e.jsxs("div",{className:"rounded-xl bg-amber-50 px-4 py-3 text-sm r
75ing-1 ring-inset ring-amber-600/20 dark:bg-amber-500/10 dark:ring-amber-400/20",children:[e.jsx("p",{className:"font-semibold text-amber-900 dark:text-amber-200",children:"Instantly status could not be verified"}),e.jsx("p",{className:"mt-0.5 text-amber-900/80 dark:text-amber-200/80",children:"Fantize could not finish reading this lead's status, so we cannot say what would happen to it."}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",disabled:q,onClick:()=>Xo(C.id,C.classification),className:"min-h-[44px] rounded-lg bg-amber-600 px-3.5 text-sm font-semibold text-white hover:bg-amber-700 disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-amber-500",children:q?"Checkingâ¦":"Try check again"}),e.jsx("span",{className:"text-xs text-amber-900/70 dark:text-amber-200/70",children:K&&K.checked_at?`Last checked ${Lu(K.checked_at,Date.now(),Ke)}`:"Not yet checked"})]}),e.jsx("p",{className:"mt-1.5 text-xs text-amber-900/70 dark:text-amber-200/70",children:"If it stays unavailable, leave this review pending and notify an administrator."})]})})})(),Ue&&e.jsx("div",{className:"px-4 pb-3 sm:px-5",children:e.jsxs("div",{className:"rounded-xl bg-amber-50 px-4 py-3 text-sm ring-1 ring-inset ring-amber-600/20 dark:bg-amber-500/10 dark:ring-amber-400/20",children:[e.jsx("p",{className:"font-semibold text-amber-900 dark:text-amber-200",children:Ue.title}),e.jsx("p",{className:"mt-0.5 text-amber-900/80 dark:text-amber-200/80",children:"An administrator sets this up. Other outcomes below still work; the review stays pending."})]})}),C.classification==="referral_wrong_contact"&&(()=>{const Pe=T5(C);return e.jsx("div",{className:"px-4 pb-3 sm:px-5",children:e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white px-4 py-3 dark:border-slate-700 dark:bg-slate-800/60",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Possible referral"}),Pe.email?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:"Possible referred contact"}),e.jsx("p",{className:"break-all font-mono text-sm text-slate-900 dark:text-white",children:Pe.email}),e.jsx("p",{className:"mt-1 text-xs text-amber-700 dark:text-amber-300",children:"Verify this information in the reply before using it."})]}):e.jsx("p",{className:"mt-1 text-sm text-slate-600 dark:text-slate-300",children:"Fantize does not save referred contact details. Review and copy them from the reply before closing."}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[Pe.email&&e.jsx("button",{type:"button",onClick:()=>ye(Pe.email,"address"),className:"min-h-[44px] rounded-lg border border-slate-300 px-3 text-sm font-medium text-slate-700 hover:bg-slate-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 dark:border-slate-600 dark:text-slate-200",children:P==="address"?"Copied":"Copy address"}),e.jsx("button",{type:"button",onClick:()=>ye(Ul(C.reply_text).text,"reply"),className:"min-h-[44px] rounded-lg border border-slate-300 px-3 text-sm font-medium text-slate-700 hover:bg-slate-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 dark:border-slate-600 dark:text-slate-200",children:P==="reply"?"Copied":"Copy relevant reply text"})]})]})})})(),e.jsxs("div",{className:"border-y-2 border-slate-100 bg-slate-50/60 px-4 py-4 dark:border-slate-700/60 dark:bg-slate-900/20 sm:px-5",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h3",{className:"text-base font-semibold text-slate-900 dark:text-white",children:"What should happen next?"}),e.jsx("span",{role:"note",className:`rounded-full px-2.5 py-1 text-[11px] font-medium ring-1 ring-inset ${Y===!1?"bg-white text-slate-600 ring-slate-300 dark:bg-slate-800 dark:text-slate-300 dark:ring-slate-600":"bg-white text-indigo-700 ring-indigo-200 dark:bg-slate-800 dark:text-indigo-300 dark:ring-indigo-400/40"}`,children:Y===!1?"Manual decisions are switched off on the server":Y?"Manual decisions are live":"Checking whether manual decisions are liveâ¦"})]}),(K&&K.routing&&K.routing.held||Ls===C.id)&&e.jsx(U5,{reviewId:C.id,campaignName:C.campaign_name,onResolved:()=>{Ms(C.id),I(Pe=>{const Dt={...Pe};return delete Dt[C.id],Dt}),ke(o)}}),sa&&e.jsxs("div",{role:"region","aria-label":"What to do about this blocked action",className:"mb-3 rounded-xl border-l-4 border-amber-400 bg-amber-50 p-4 dark:border-amber-500 dark:bg-amber-950/30",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200",children:sa.heading}),e.jsx("p",{className:"mt-1 text-sm leading-relaxed text-amber-900/90 dark:text-amber-100/90",children:sa.body}),e.jsxs("p",{className:"mt-2 text-sm text-amber-900/90 dark:text-amber-100/90",children:[e.jsx("span",{className:"font-medium",children:"What an administrator needs to do: "}),sa.adminAction]}),e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:Zl,className:"inline-flex min-h-11 min-w-11 items-center rounded-lg bg-white px-3 text-sm font-medium text-amber-900 ring-1 ring-amber-300 hover:bg-amber-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-amber-600 dar
75k:bg-slate-800 dark:text-amber-200 dark:ring-amber-500/50",children:"Copy issue details"}),e.jsx("span",{"aria-live":"polite",className:"text-sm text-amber-900/80 dark:text-amber-100/80",children:un==="ok"?"Copied. Paste this to an administrator.":un==="fail"?"Could not copy â select the details above instead.":""})]})]}),Bo(K)&&e.jsx("p",{className:"mb-3 text-sm text-slate-600 dark:text-slate-300",children:Bo(K)}),sf(K)&&e.jsx("p",{className:"mb-3 border-l-2 border-slate-300 pl-3 text-xs text-slate-500 dark:border-slate-600 dark:text-slate-400",children:sf(K)}),C.lifecycle_id&&He[C.lifecycle_id]&&e.jsx("div",{className:"mb-3",children:e.jsx(Ne,{tone:"amber",children:He[C.lifecycle_id]})}),H&&e.jsxs("div",{className:"mb-3",children:[e.jsx(Ne,{tone:H.kind==="success"?"green":H.kind==="gated"?"blue":(H.kind==="network","amber"),children:H.message}),H.actionKey==="mark_wrong_contact"&&H.kind==="success"&&e.jsx("p",{className:"mt-1 px-1 text-xs text-amber-700 dark:text-amber-300",children:es})]}),Re&&e.jsx("div",{className:"mb-3",children:e.jsx(cf,{action:Re,blocked:zu(Re,K,q),blockedReason:lf(Re,K,q),resultText:rf(Re,K),prominent:!0,state:Br===C.id?"Submittingâ¦":void 0,onSelect:mn})}),e.jsx("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",children:Ge.map(Pe=>e.jsx(cf,{action:Pe,blocked:zu(Pe,K,q),blockedReason:lf(Pe,K,q),resultText:rf(Pe,K),state:Br===C.id?"Submittingâ¦":void 0,onSelect:mn},Pe.key))}),u==="reviewer"&&e.jsx("p",{className:"mt-3 text-xs text-slate-500 dark:text-slate-400",children:"Setting an owner and disqualifying a contact are done by an administrator."})]}),e.jsx("div",{className:"flex flex-wrap gap-2 px-4 py-3 sm:px-5",children:nf(C,K,q).slice(0,3).map(Pe=>e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium ring-1 ring-inset ${zo[Pe.state].className}`,children:[e.jsx("span",{"aria-hidden":"true",children:zo[Pe.state].glyph}),e.jsxs("span",{className:"sr-only",children:[zo[Pe.state].sr,": "]}),V5(Pe)]},Pe.key))}),e.jsx("div",{className:"px-4 pb-2 sm:px-5",children:e.jsx(F5,{title:"Details",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Readiness"}),e.jsx("ul",{className:"divide-y divide-slate-100 dark:divide-slate-700/60",children:nf(C,K,q).map(Pe=>e.jsx(I5,{item:Pe},Pe.key))}),ne&&e.jsxs("p",{className:"mt-1 text-xs text-slate-500",children:[ne," The reply above is still shown."]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Full message"}),e.jsx("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-slate-50 p-3 font-sans text-sm text-slate-700 dark:bg-slate-900/40 dark:text-slate-200",children:C.reply_text||"No message text was captured."})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Routing and ownership"}),(()=>{const Pe=Pu(C,K);return e.jsxs("dl",{className:"space-y-1 text-sm","data-testid":"routing-ownership",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-40 flex-none text-slate-400",children:"Handoff owner now"}),e.jsx("dd",{className:"min-w-0 break-words",children:Pe.current_name||"No active owner resolves for this campaign"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-40 flex-none text-slate-400",children:"Routed at arrival"}),e.jsxs("dd",{className:"min-w-0 break-words",children:[C.arrival_recorded_at?Pe.arrival_name||"Unmapped when this reply arrived":"Not recorded",Pe.changed&&e.jsx("span",{className:"ml-2 rounded bg-amber-50 px-1.5 py-0.5 text-xs text-amber-900 ring-1 ring-inset ring-amber-200 dark:bg-amber-400/10 dark:text-amber-200 dark:ring-amber-400/30",children:"Owner changed since arrival"})]})]})]})})(),e.jsx("p",{className:"mt-1 break-words text-sm text-slate-500",children:C.assignment_note||""})]}),(C.reply_summary||C.ai_reason)&&e.jsxs("div",{children:[e.jsx("h4",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Why Fantize read it that way"}),e.jsx("p",{className:"text-sm",children:C.reply_summary||C.ai_reason})]}),u==="admin"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("h4",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Instantly check"}),K?e.jsx("dl",{className:"space-y-1 text-sm",children:["outcome","basis_label","enrollment_count","remaining_steps","verified","stop_on_reply"].map(Pe=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-40 flex-none text-slate-400",children:Pe.replace(/_/g," ")}),e.jsx("dd",{className:"min-w-0 break-words",children:String(K[Pe])})]},Pe))}):e.jsx("p",{className:"text-sm",children:"No check loaded."})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Technical identifiers"}),e.jsx("dl",{className:"space-y-1 font-mono text-xs",children:[["review",C.id],["event",C.event_id],["lifecycle",C.lifecycle_id],["campaign",C.campaign_id],["model",C.model_name],["rout
75ing hash",K?.routing_snapshot_hash],["enrollment hash",K?.enrollment_snapshot_hash]].map(([Pe,Dt])=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-32 flex-none text-slate-400",children:Pe}),e.jsx("dd",{className:"min-w-0 break-all",children:Dt?String(Dt):"â"})]},String(Pe)))})]})]})]})},C.id)})]})})()]})]}),Ce&&C&&e.jsx(B5,{action:Ce,suggested:C.classification,submitting:Br===C.id,gateClosed:Y===!1,handoffOwner:Pu(C,X[C.id]??null),onCancel:()=>Ae(null),onConfirm:K=>{hn(Ce,K)}})]})}function Y5(){const{isAdmin:s}=zt(),[l,i]=h.useState([]),[o,d]=h.useState(!0),[u,x]=h.useState(""),[y,p]=h.useState(""),[g,b]=h.useState({});function f(j){p(j),setTimeout(()=>p(""),6e3)}async function k(){d(!0);try{const j=await je.dncUnresolved();i(j.items||[])}catch(j){f(j?.payload?.error||j.message)}d(!1)}h.useEffect(()=>{s&&k()},[s]);async function w(j){x(j+":check");try{const T=await je.dncRecheck(j);b(S=>({...S,[j]:T})),f(`Checked ${j}: Instantly block ${T.instantly_block}, subsequence ${T.subsequence_state}.`)}catch(T){f(T?.payload?.error||T.message)}x("")}async function N(j){if(window.confirm(`Retry Instantly protection for ${j}? 76 77⢠Creates or verifies an Instantly block-list entry for this exact address 78⢠Never removes the Fantize do-not-contact entry 79⢠Never removes an existing Instantly block`)){x(j+":retry");try{const T=await je.dncRetry(j);f(T.copy||"Retry complete."),await k()}catch(T){f(T?.payload?.error||T.message)}x("")}}return s?e.jsxs("div",{className:"max-w-4xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Do Not Contact",subtitle:"Addresses on the do-not-contact list whose Instantly block could not be confirmed. Until it is, an active campaign could still reach them. Every address here is already protected from future Fantize sourcing.",status:!o&&e.jsx(We,{kind:l.length?"action-required":"healthy",label:l.length?`${l.length} address${l.length===1?"":"es"} need confirmation`:"Every do-not-contact request has a confirmed provider block"}),secondary:e.jsx(U,{size:"sm",variant:"soft",onClick:k,disabled:o,children:"Refresh"})}),e.jsx(qn,{message:y,tone:"blue"}),o?e.jsx(tt,{label:"Loading do-not-contact protectionâ¦"}):l.length===0?e.jsx(Ze,{tone:"positive",title:"Nothing needs attention",hint:"Every do-not-contact request has a confirmed Instantly block.",doing:"Re-checking unconfirmed blocks automatically"}):e.jsx("div",{className:"space-y-3",children:l.map(j=>e.jsxs(_e,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 break-all",children:j.email}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Requested ",Ke(j.created_at)," · ",j.source_action==="automated_rule"?"automatic unsubscribe reply":"reviewer action"]})]}),e.jsx(We,{kind:"action-required",label:"Block unconfirmed"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1 text-xs text-gray-700 dark:text-gray-300",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Fantize do-not-contact:"})," ",e.jsx("span",{className:"text-emerald-700 dark:text-emerald-400",children:"confirmed"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Instantly block:"})," ",e.jsx("span",{className:j.instantly_block==="confirmed"?"text-emerald-700 dark:text-emerald-400":"text-amber-700 dark:text-amber-400",children:j.instantly_block})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Subsequence:"})," ",j.subsequence_state||"unknown"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Attempts:"})," ",j.attempts??0]}),j.provider_entry_id&&e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("span",{className:"text-gray-500",children:"Instantly entry:"})," ",e.jsx("code",{children:j.provider_entry_id})]}),j.provider_detail&&e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("span",{className:"text-gray-500",children:"Reason:"})," ",j.provider_detail]})]}),e.jsx(Ne,{tone:"amber",children:j.instructions}),g[j.email]&&e.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-400 border-t border-gray-100 dark:border-gray-700/60 pt-2",children:["Last check: Instantly block ",e.jsx("strong",{children:g[j.email].instantly_block}),", subsequence ",e.jsx("strong",{children:g[j.email].subsequence_state}),". This check changed nothing."]}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(U,{size:"sm",variant:"soft",disabled:u===j.email+":check",title:"Re-reads Instantly. This only reads â it changes nothing.",onClick:()=>w(j.email),children:u===j.email+":check"?"Checkingâ¦":"Check again"}),e.jsx(U,{size:"sm",disabled:u===j.email+":retry",title:"Creates or verifies the Instantly block-list entry. Never removes anything.",onClick:()=>N(j.email),children:u===j.email+":retry"?"Retryingâ¦":"Retry Instantly block"})]})]},j.email))})]}):e.jsxs("div",{className:"max-w-4xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Do Not Contact",subt
79itle:"Addresses Fantize will never contact again."}),e.jsx(Ne,{tone:"amber",children:"This section is Admin-only. Ask your workspace admin to review do-not-contact protection."})]})}function P5({to:s,children:l}){const{isAdmin:i}=zt();return(Ja().asMarketing?!1:i)?e.jsx(e.Fragment,{children:l}):e.jsx(is,{to:s,replace:!0})}const Q5=[{key:"mode",label:"Processing mode"},{key:"thresholds",label:"Qualification & review"},{key:"crm",label:"CRM writing"},{key:"ai",label:"AI & cost"},{key:"protection",label:"Safety protections"},{key:"advanced",label:"Advanced"}];function X5(){const[s,l]=h.useState(null),[i,o]=h.useState(null),[d,u]=h.useState({}),[x,y]=h.useState(null),[p,g]=h.useState(null),[b,f]=h.useState(null),[k,w]=h.useState(null),[N,j]=h.useState(!0),[T,S]=h.useState(!1),[_,z]=h.useState(null),[A,L]=h.useState(null),[F,D]=h.useState(null),[te,pe]=h.useState("mode"),[he,X]=h.useState(!1);async function I(){j(!0);const[$,O,P,V]=await Promise.all([je.settings(),je.webhookInfo(),je.goLiveReadiness(),je.callConfig().catch(()=>null)]);l($.settings),o($.settings),u($.property_names_default||{}),y(O),f(P),w(V),j(!1)}h.useEffect(()=>{I()},[]);function q($,O){L(null),o({...i,[$]:O})}function be($,O){q("call_outcome_map",{...i.call_outcome_map||{},[$]:O})}const ne=h.useMemo(()=>!!i&&!!s&&JSON.stringify(i)!==JSON.stringify(s),[i,s]),M=h.useMemo(()=>!i||!s?[]:Object.keys({...i,...s}).filter($=>JSON.stringify(i[$])!==JSON.stringify(s[$])),[i,s]);function Y($,O){const P={inbound_guard_fail_closed:"When protection checks cannot be completed, handoffs will wait and be retried instead of proceeding. Enable fail-closed protection?",inbound_import_exception:"Verified campaign-enrolled imported contacts will accept a limited, reviewed update during handoff. This narrows a protection. Allow constrained updates?",auto_decisions_enabled:'Decision automation will stop automated outreach for clear "not interested" replies (with every safety check, and a review whenever anything is uncertain) and will send low-confidence positive replies to review instead of leaving them unread. Enable decision automation?'};O&&!window.confirm(P[$]||"Enable this protection-affecting setting?")||(O&&X(!0),q($,O))}async function oe(){if(F){z("Fix the property map JSON before saving.");return}S(!0),z(null),L(null);const $={...i,stage_map:void 0,...he?{confirm_protection_change:!0}:{}};try{await je.saveSettings($),L("Settings saved."),X(!1),await I(),setTimeout(()=>L(null),4e3)}catch(O){z(O.message||"Could not save."),o({...i,auto_sync_enabled:s?.auto_sync_enabled??!1})}finally{S(!1)}}function Ce(){o(s),z(null),D(null),X(!1)}const Ae=$=>{pe($),document.getElementById($)?.scrollIntoView({behavior:"smooth",block:"start"})};if(N||!i)return e.jsxs("div",{className:"max-w-3xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Automation Settings"}),e.jsx(tt,{label:"Loading settingsâ¦"})]});const H=b&&!b.ready&&!i.auto_sync_enabled,Z=Number(i.review_min_confidence)>Number(i.min_confidence_auto);return e.jsxs("div",{className:"max-w-3xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Automation Settings",subtitle:"How replies qualify, what Fantize writes to HubSpot, and the safety protections around every handoff. Changes apply only when you save.",status:e.jsxs(e.Fragment,{children:[e.jsx(We,{kind:s?.auto_sync_enabled?"ready":"disabled",label:s?.auto_sync_enabled?"Automatic HubSpot sync: on":"Automatic HubSpot sync: off â every qualifying reply waits for a person"}),e.jsx(We,{kind:s?.auto_decisions_enabled?"ready":"disabled",label:s?.auto_decisions_enabled?"Decision automation: on":"Decision automation: off"}),e.jsx(We,{kind:s?.inbound_guard_fail_closed?"ready":"needs-review",label:s?.inbound_guard_fail_closed?"Fail-closed protection: on":"Fail-closed protection: off"})]})}),e.jsx(dn,{label:"Settings sections",items:Q5,active:te,onChange:Ae,className:"mb-5"}),b&&e.jsxs("div",{className:"mb-5 rounded-2xl bg-white dark:bg-gray-800/80 ring-1 ring-gray-200 dark:ring-gray-700/60 shadow-sm p-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Technical prerequisites"}),e.jsxs("div",{className:"text-sm text-gray-500",children:[b.items.filter($=>$.done).length," of ",b.items.length," complete · ",b.ready?"automatic sync may be enabled":"automatic sync stays locked until every prerequisite is complete","."]})]}),e.jsx(Es,{to:"/dashboard/automation/readiness",children:"Operational Readiness"})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs(Sr,{id:"mode",title:"Processing mode",description:"Which path leads take, and whether phone-call outcomes can qualify them.",children:[e.jsx(le,{label:"Workflow type",help:"Email-only keeps cold leads out of HubSpot until they qualify. Call-enabled syncs approved leads to HubSpot as lifecycle stage âLeadâ (only) so reps can call them there.",children:e.jsxs("select",{className:de,value:i.outreach_mode||"email_only",onChange:$=>q("outreach_mode",$.target.value),children:[e.jsx("option",{value:"email_only",children:"Email-only â cold leads stay out of HubSpot until qual
79ified"}),e.jsx("option",{value:"call_enabled",children:"Call-enabled â sync approved leads to HubSpot as âLeadâ for calling"}),e.jsx("option",{value:"both",children:"Both â choose per lead or campaign"})]})}),i.outreach_mode!=="email_only"&&e.jsxs(Ne,{tone:"blue",children:["Call-enabled leads are synced to HubSpot as lifecycle stage ",e.jsx("b",{children:"âLeadâ"})," only â never as Marketing Lead or MQL. They advance to MQL/SAL only on a real qualifying call outcome."]}),e.jsx($t,{label:"Enable call-based MQL qualification",checked:i.call_mql_enabled,onChange:$=>q("call_mql_enabled",$),help:"Let phone-call outcomes (from Instantly, a dialer, or logged manually) qualify a lead. âInterestedâ â MQL, âMeeting Bookedâ â SAL, per the mapping below."}),i.call_mql_enabled&&k&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-gray-500 mb-1",children:"Call outcome â action"}),e.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-700/40",children:k.outcomes.map($=>e.jsxs("label",{className:"flex flex-col gap-1 py-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-200",children:$.label}),e.jsxs("select",{className:de+" sm:w-64",value:(i.call_outcome_map||{})[$.key]||$.action,onChange:O=>be($.key,O.target.value),children:[e.jsx("option",{value:"mql",children:"Create/update as MQL"}),e.jsx("option",{value:"sal",children:"Create/update as SAL (qualified)"}),e.jsx("option",{value:"review",children:"Send to manual review"}),e.jsx("option",{value:"disqualify_if_exists",children:"Disqualify only if contact exists"}),e.jsx("option",{value:"keep",children:"Keep in outreach (no sync)"}),e.jsx("option",{value:"ignore",children:"Record only (no sync)"})]})]},$.key))})]}),e.jsx($t,{label:"Suppress qualified leads from Instantly sequences",checked:i.sequence_suppression_enabled,onChange:$=>q("sequence_suppression_enabled",$),help:"When a lead qualifies (MQL/SAL), pause or remove them from active Instantly cold sequences so outreach does not continue. Flags for manual removal if the API cannot do it."}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[e.jsx(le,{label:"Cleanup window for non-responsive HubSpot Leads",help:"Call-enabled Leads that never qualify become eligible for Cleanup Review after this period.",children:e.jsxs("select",{className:de,value:i.cleanup_period_days||14,onChange:$=>q("cleanup_period_days",parseInt($.target.value,10)),children:[e.jsx("option",{value:14,children:"2 weeks"}),e.jsx("option",{value:30,children:"30 days (monthly)"}),e.jsx("option",{value:60,children:"60 days"})]})}),e.jsx($t,{label:"Allow auto-delete after cleanup window",checked:i.cleanup_auto_delete,onChange:$=>q("cleanup_auto_delete",$),help:"Off (recommended): cleanup always requires a person; nothing is deleted automatically."})]}),e.jsx(Es,{to:"/dashboard/leads/cleanup",children:"Open Cleanup Review"}),i.outreach_mode!=="email_only"&&e.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700/60 pt-3 space-y-3",children:[e.jsx($t,{label:"Create a HubSpot call task when a lead is synced for calling",checked:i.call_task_enabled,onChange:$=>q("call_task_enabled",$),help:"When a lead syncs to HubSpot as âLeadâ, create a Call task assigned to the contact owner, with campaign/source and prep notes. If no owner can be found, the lead is flagged for review instead of an unassigned task."}),i.call_task_enabled&&e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[e.jsx(le,{label:"Task due date",children:e.jsxs("select",{className:de,value:i.call_task_due||"next_business_day",onChange:$=>q("call_task_due",$.target.value),children:[e.jsx("option",{value:"same_day",children:"Same day"}),e.jsx("option",{value:"next_business_day",children:"Next business day"})]})}),e.jsx(le,{label:"Priority",children:e.jsxs("select",{className:de,value:i.call_task_priority||"MEDIUM",onChange:$=>q("call_task_priority",$.target.value),children:[e.jsx("option",{value:"LOW",children:"Low"}),e.jsx("option",{value:"MEDIUM",children:"Normal"}),e.jsx("option",{value:"HIGH",children:"High"})]})}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(le,{label:"Task title",help:"Campaign name is appended automatically.",children:e.jsx("input",{className:de,value:i.call_task_title||"",onChange:$=>q("call_task_title",$.target.value),placeholder:"Call lead from Fantize campaign"})})})]})]})]}),e.jsxs(Sr,{id:"thresholds",title:"Qualification & review thresholds",description:"When a reply qualifies on its own, and when it waits for a person.",children:[e.jsx($t,{label:"Enable automatic sync to HubSpot",checked:i.auto_sync_enabled,onChange:$=>q("auto_sync_enabled",$),disabled:!!H,help:H?"Locked until every technical prerequisite under Operational Readiness is complete. Until then, every qualifying lead waits in Reply Review.":"On: a qualifying reply above the auto-sync confidence syncs to HubSpot without a person. Off: every qualifying reply waits in Reply Review for a decision."}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(le,{label:"Minimum confidence to sync automatically",help:"90â100 recommended. Only applies when automatic sync is on.",error:Z?"Must be at or above the review threshold.":void 0,children:e.jsx("input",{type:"number",min:0,max:100,className:de,value:i.min_confidence_auto,onChange:$=>q("min_confidence_auto",+$.target.value)})}),e.jsx(le,{label:"Minimum confidence to open a review",help:"Below this, the reply is recorded and nothing else happens.",children:e.jsx("input",{type:"number",min:0,max:100,className:de,value:i.review_min_confidence,onChange:$=>q("review_min_confidence",+$.target.value)})})]}),e.jsx($t,{label:"A meeting-link click alone qualifies as MQL",checked:i.meeting_click_qualifies_mql,onChange:$=>q("meeting_click_qualifies_mql",$)}),e.jsx(le,{label:"When a meeting is booked, set the HubSpot lifecycle stage to",children:e.jsxs("select",{className:de,value:i.meeting_booked_stage,onChange:$=>q("meeting_booked_stage",$.target.value),children:[e.jsx("option",{value:"sal",children:"SAL / Meeting Scheduled (recommended)"}),e.jsx("option",{value:"mql",children:"MQL / Engaged with Outreach"})]})}),e.jsx($t,{label:"Ambiguous replies require a person",checked:i.ambiguous_requires_review,onChange:$=>q("ambiguous_requires_review",$),help:"Off: an ambiguous reply above the auto-sync threshold could sync without review."}),e.jsx($t,{label:"Referral / wrong-contact replies require a person",checked:i.referral_requires_review,onChange:$=>q("referral_requires_review",$)})]}),e.jsxs(Sr,{id:"crm",title:"CRM writing behaviour",description:"What Fantize is allowed to change on a HubSpot contact.",children:[e.jsx($t,{label:"Update existing HubSpot contacts",checked:i.update_existing_contacts,onChange:$=>q("update_existing_contacts",$),help:"Off = create-only; a contact that already exists is left untouched. Handoffs to imported contacts are governed by the safety protections below regardless."}),e.jsx($t,{label:"Log positive replies as HubSpot email engagements",checked:i.log_email_engagement,onChange:$=>q("log_email_engagement",$),help:"On (default): when a positive reply syncs, Fantize also logs it as an inbou
79nd email on the contact's HubSpot timeline, not just a note. Best-effort â never blocks the sync."}),e.jsx($t,{label:"Write custom HubSpot properties",checked:i.send_custom_properties,onChange:$=>q("send_custom_properties",$),help:"Off (default): rich data (classification, reason, reply, campaign) is written as a contact note so a sync never fails on a missing property. On: also write the mapped custom properties (Advanced) â create them in HubSpot first."}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Standard properties (lifecycle stage, lead status, name, company, email, phone) always sync. The outbound campaign is written to the ",e.jsx("code",{children:"instantly_campaign"})," property and the note."]}),e.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700/60 pt-3 space-y-1",children:[e.jsx($t,{label:"I have confirmed the HubSpot lifecycle/status mapping",checked:i.hubspot_mapping_confirmed,onChange:$=>q("hubspot_mapping_confirmed",$),help:"The lead-status options Fantize writes exist in HubSpot. Reviewed under Lifecycle & HubSpot."}),e.jsx($t,{label:"I have confirmed the required HubSpot fields are available",checked:i.hubspot_fields_confirmed,onChange:$=>q("hubspot_fields_confirmed",$)}),e.jsx(Es,{to:"/dashboard/automation/lifecycle-hubspot",children:"Review the mapping under Lifecycle & HubSpot"})]})]}),e.jsxs(Sr,{id:"ai",title:"AI & cost control",description:"Which model reads human replies, and a spending cap. This selection applies to reply classification only.",children:[e.jsx(le,{label:"AI model provider (reply classification)",help:"Local is free (on-box model); hosted is the paid tier; auto tries local first. This setting does not presently govern Prospecting qualification, which uses the approved local model only and gives a provisional, review-required result when that model is unavailable.",children:e.jsxs("select",{className:de,value:i.ai_provider,onChange:$=>q("ai_provider",$.target.value),children:[e.jsx("option",{value:"auto",children:"Auto (free local first, hosted fallback)"}),e.jsx("option",{value:"local",children:"Local only (free)"}),e.jsx("option",{value:"paid",children:"Hosted tier"})]})}),e.jsx(le,{label:"Monthly AI cost cap (USD, optional)",help:"Leave empty for no cap.",children:e.jsx("input",{type:"number",min:0,step:"0.01",className:de,value:i.ai_monthly_cost_cap??"",onChange:$=>q("ai_monthly_cost_cap",$.target.value===""?null:+$.target.value)})}),e.jsx(Ne,{tone:"blue",children:"Rules classify clear replies (bounces, unsubscribes, out-of-office, confirmed bookings) with no AI cost. AI only runs on genuine human replies, and identical replies are cached."})]}),e.jsxs(Sr,{id:"protection",title:"Safety protections",description:"How handoffs behave when a lead may already exist outside this workspace, and whether Fantize may decide clear replies on its own. Changing these asks for confirmation and every change is recorded with who made it and when.",children:[e.jsx($t,{label:"Fail closed when protection checks cannot be completed",checked:i.inbound_guard_fail_closed,onChange:$=>Y("inbound_guard_fail_closed",$),help:"On: if the pre-handoff safety check cannot finish, the handoff waits and is retried instead of proceeding. Off: the handoff proceeds under the remaining safeguards."}),e.jsx($t,{label:"Allow constrained updates to verified campaign-enrolled imported contacts",checked:i.inbound_import_exception,onChange:$=>Y("inbound_import_exception",$),help:"On: a contact this workspace deliberately contacted, that already exists from an earlier import, can receive a limited approved update after every check passes. Requires fail-closed protection to be on. Off: such handoffs are held for a person."}),e.jsx($t,{label:"Enable decision automation for clear replies",checked:i.auto_decisions_enabled,onChange:$=>Y("auto_decisions_enabled",$),help:"On: a rule-certain ânot interestedâ reply also stops automated outreach (fully checked; anything uncertain goes to review instead), and a low-confidence positive reply opens a review so a person reads it. Off: those replies are recorded and outreach state is left as-is. Automatic HubSpot sync is governed separately above."}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Decision automation and automatic HubSpot sync are different things: the first decides clear negative replies; the second hands qualifying positive replies to HubSpot without a person. Both are shown on ",e.jsx(Se,{to:"/dashboard/automation/readiness",className:"underline",children:"Operational Readiness"}),"."]})]}),e.jsxs(Sr,{id:"advanced",title:"Advanced configuration",description:"Property mapping JSON and the inbound webhook. Only needed when connecting or changing an integration.",advanced:!0,children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100 mb-1",children:"Custom property map"}),e.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["Used only when âWrite custom HubSpot propertiesâ is on. Logical field â your HubSpot internal property name. Set a value to ",e.jsx("code",{children:"null"})," to skip that field."]}),e.jsx(le,{label:"Property name map (JSON)",error:F||void 0,children:e.jsx("textarea",{className:de+" font-mono text-xs",rows:10,defaultValue:JSON.stringify(i.property_names||d,null,2),onBlur:$=>{try{q("hubspot_property_map",JSON.parse($.target.value)),D(null)}
79catch{D("This is not valid JSON. Fix it before saving.")}}})})]}),e.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700/60 pt-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100 mb-1",children:"Inbound webhook & sync schedule"}),x&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Point your outbound or calendar platform at this URL. If webhooks are unavailable, the sync schedule (polling every 15 minutes) and CSV import keep the workflow running."}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-700/40 rounded-xl p-3 font-mono text-xs break-all",children:x.url_template}),x.secret_masked?.configured&&!p&&e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:["A secret is set, ending ",e.jsx("span",{className:"font-mono",children:x.secret_masked.last4}),". The full value is shown only when you generate a new one."]}),p&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-gray-50 dark:bg-gray-700/40 rounded-xl p-3 font-mono text-xs break-all",children:p}),e.jsx(Ne,{tone:"amber",children:"Copy this now. It will not be shown again â if you lose it, generate another."})]}),e.jsx(U,{size:"sm",variant:"soft",onClick:async()=>{if(!window.confirm("Generate a new webhook secret? The previous one stops working immediately and any platform using it must be updated."))return;const $=await je.rotateWebhook();g($.url),y(await je.webhookInfo())},children:"Generate a new secret"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Generating a secret takes effect immediately and is not part of the Save above."})]})]}),e.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700/60 pt-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100 mb-1",children:"Related configuration"}),e.jsxs("ul",{className:"text-sm space-y-1",children:[e.jsx("li",{children:e.jsx(Es,{to:"/dashboard/automation/lead-assignment",children:"Lead Assignment â who may receive new leads, defaults and rules"})}),e.jsx("li",{children:e.jsx(Es,{to:"/dashboard/campaigns/routing",children:"Campaign Routing â which salesperson each campaign hands off to"})}),e.jsx("li",{children:e.jsx(Es,{to:"/dashboard/automation/notifications",children:"Notifications â channels and timing"})}),e.jsx("li",{children:e.jsx(Es,{to:"/dashboard/integrations",children:"Integrations â HubSpot and Instantly credentials"})})]})]})]})]}),e.jsx(If,{dirty:ne,saving:T,onSave:oe,onDiscard:Ce,error:_,success:A,summary:M.length?`${M.length} setting${M.length===1?"":"s"} changed`:void 0}),Z&&ne&&e.jsx("p",{className:"mt-2 text-xs text-rose-600",children:"The auto-sync threshold must be at or above the review threshold."}),!ne&&!A&&e.jsxs("p",{className:"mt-6 text-xs text-gray-400 flex items-center gap-2",children:[e.jsx(se,{tone:"gray",children:"No unsaved changes"})," Edits appear in a bar at the bottom of the screen with Save and Discard."]})]})}function W5(){const[s,l]=h.useState([]),[i,o]=h.useState([]),[d,u]=h.useState({attributes:[],operators:[],scopes:[],conflict_modes:[],presets:[],campaigns:[]}),[x,y]=h.useState([]),[p,g]=h.useState(null),[b,f]=h.useState(null),[k,w]=h.useState(!0),[N,j]=h.useState(""),[T,S]=h.useState(null),[_,z]=h.useState(null);function A(I){j(I),setTimeout(()=>j(""),3e3)}async function L(){const[I,q,be,ne,M,Y]=await Promise.all([je.team(),je.assignRules(),je.assignMeta(),je.hubspotOwners().catch(()=>({owners:[]})),je.settings(),je.assignReadiness()]);l(I.team||[]),o(q.rules||[]),u(be),y(ne.owners||[]),g(M.settings),f(Y),w(!1)}h.useEffect(()=>{L()},[]);async function F(I){await je.saveSettings(I);const[q,be]=await Promise.all([je.settings(),je.assignReadiness()]);g(q.settings),f(be),A("Saved.")}async function D(I,q){const be=i.slice(),ne=I+q;ne<0||ne>=be.length||([be[I],be[ne]]=[be[ne],be[I]],o(be),await je.reorderAssignRules(be.map(M=>M.id)),L())}async function te(I){await je.updateAssignRule(I.id,{enabled:!I.enabled}),L()}async function pe(I){await je.deleteAssignRule(I),L(),A("Rule deleted.")}async function he(I){try{await je.deleteTeamMember(I.id),A("Member removed."),L()}catch(q){A(q.message)}}if(k||!p)return e.jsxs("div",{className:"max-w-5xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Lead Assignment"}),e.jsx(tt,{label:"Loading assignment setupâ¦"})]});const X=I=>x.find(q=>String(q.id)===String(I))?.name||I;return e.jsxs("div",{className:"max-w-5xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Lead Assignment",subtitle:"Who may receive new leads, the default owner when nothing else applies, and conditional rules that pick a person from search criteria. Which s
79alesperson a campaign hands off to is set under Campaign Routing."}),N&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"green",children:N})}),b&&e.jsxs(_e,{className:"mb-5",children:[e.jsx(Fe,{action:e.jsx(se,{tone:b.ready?"green":"amber",children:b.ready?"Assignment prerequisites complete":"Assignment setup incomplete"}),children:"Assignment prerequisites"}),e.jsx("div",{className:"grid sm:grid-cols-2 gap-x-6 gap-y-1",children:b.items.map(I=>e.jsxs("div",{className:"flex items-start gap-2 text-sm py-0.5",children:[e.jsx("span",{className:I.done?"text-emerald-600":"text-gray-400","aria-hidden":"true",children:I.done?"â":"â"}),e.jsx("span",{className:"sr-only",children:I.done?"Done:":"To do:"}),e.jsxs("span",{className:I.done?"text-gray-700 dark:text-gray-200":"text-gray-500",children:[I.label,I.note?e.jsxs("span",{className:"text-gray-400",children:[" â ",I.note]}):null]})]},I.key))})]}),e.jsxs(_e,{className:"mb-5 space-y-3",children:[e.jsx(Fe,{children:"Defaults"}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[e.jsx(le,{label:"Default owner (required fallback)",help:"Used when no rule matches. Leads clearly show when the default was used.",children:e.jsxs("select",{className:de,value:p.default_team_member_id||"",onChange:I=>F({default_team_member_id:I.target.value||null}),children:[e.jsx("option",{value:"",children:"â none yet â"}),s.filter(I=>I.active).map(I=>e.jsx("option",{value:I.id,children:I.name},I.id))]})}),e.jsx(le,{label:"When more than one rule matches",help:"Priority = use the top-ranked rule. Review = send the lead to the Review Queue to confirm.",children:e.jsxs("select",{className:de,value:p.routing_conflict_mode||"priority",onChange:I=>F({routing_conflict_mode:I.target.value}),children:[e.jsx("option",{value:"priority",children:"Use highest-priority rule"}),e.jsx("option",{value:"review",children:"Send to Review Queue"})]})})]})]}),e.jsxs(_e,{className:"mb-5",children:[e.jsx(Fe,{action:e.jsx(U,{size:"sm",onClick:()=>S({name:"",email:"",hubspot_owner_id:""}),children:"Add team member"}),children:"Team members and who may receive new leads"}),s.length===0?e.jsx(Ze,{title:"No team members yet",hint:"Add the people leads should be assigned to, then map each to their HubSpot owner record."}):e.jsx("div",{className:"space-y-1",children:s.map(I=>e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm border-b border-gray-100 dark:border-gray-700/50 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"font-medium",children:I.name})," ",e.jsxs("span",{className:"text-gray-400",children:["· ",I.email]}),!I.active&&e.jsx(se,{tone:"gray",children:"inactive"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[I.active&&Number(I.lead_eligible)===1?e.jsx(se,{tone:"blue",children:"receives new leads"}):e.jsx(se,{tone:"gray",children:"reviewer only"}),I.hubspot_owner_id?e.jsxs(se,{tone:"green",children:["HubSpot: ",X(I.hubspot_owner_id)]}):e.jsx(se,{tone:"amber",children:"not mapped to HubSpot"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>S(I),children:"Edit"}),e.jsx(U,{size:"sm",variant:"ghost",title:"Remove this team member",onClick:()=>{window.confirm(`Remove ${I.name} from the team? History keeps their name; they can no longer be a routing target.`)&&he(I)},children:"Remove"})]})]},I.id))}),x.length===0&&e.jsxs(Ne,{tone:"amber",children:[e.jsx("b",{children:"HubSpot owners aren't loading."})," Connect HubSpot in Integrations so you can map team members to owner records."]})]}),e.jsxs(_e,{className:"mb-5",children:[e.jsxs(Fe,{action:e.jsx(U,{size:"sm",disabled:!s.length,onClick:()=>z(K5()),children:"Add rule"}),children:["Conditional assignment rules ",e.jsx("span",{className:"text-sm font-normal text-gray-400",children:"(top = highest priority)"})]}),i.length===0?e.jsx(Ze,{title:"No routing rules yet",hint:"Add rules like âIndustry is Manufacturing â Carolâ or âCampaign Q3 â Bob.â Leads with no matching rule go to the default owner."}):e.jsx("div",{className:"space-y-2",children:i.map((I,q)=>e.jsx("div",{className:`rounded-xl border p-3 ${I.enabled?"border-gray-200 dark:border-gray-700":"border-dashed border-gray-200 dark:border-gray-700 opacity-60"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[I.name||J5(I,d)," ",e.jsxs("span",{className:"text-gray-400 font-normal",children:["â ",I.member_name||"unknown"]}),!I.member_hubspot&&e.jsx(se,{tone:"amber",children:"owner not mapped"})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-0.5",children:[e.jsx(se,{tone:"blue",children:up(I)})," ",(I.conditions||[]).map((be,ne)=>e.jsx("span",{className:"mr-1",children:mp(be,d)},ne)),(!I.conditions||!I.conditions.length)&&e.jsx("span",{className:"text-gray-400",children:"applies to all leads in scope"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(()=>{const be=Z5(I,!!b?.items?.find(ne=>ne.key==="routing_tested")?.done);return e.jsx(se,{tone:be.tone,children:be.label})})(),e.jsx("button",{type:"button","aria-label":"Move rule up",title:"Move up",className:"flex h-11 w-11 items-center justify-center rounded-lg text-gray-500 hover:text-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",onClick:()=>D(q,-1),children:"â²"}),e.jsx("button",{type:"button","aria-label":"Move rule down",title:"Move down",className:"flex h-11 w-11 items-center justify-center rounded-lg text-gray-500 hover:text-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",onClick:()=>D(q,1),children:"â¼"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>te(I),children:I.enabled?"Disable":"Enable"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>z({...I,conditions:I.conditions&&I.conditions.length?I.conditions:[{attr:"industry",op:"contains",value:""}]}),children:"Edit"}),e.jsx(U,{size:"sm",variant:"ghost",title:"Delete this rule",onClick:()=>{window.confirm("Delete this assignment rule? Leads it matched will fall to the next rule or the default owner.")&&pe(I.id)},children:"Delete"})]})]})},I.id))})]}),e.jsx(aw,{onTested:()=>je.assignReadiness().then(f)}),T&&e.jsx(ew,{member:T,owners:x,onClose:()=>S(null),onSaved:()=>{S(null),L()}}),_&&e.jsx(tw,{rule:_,team:s,meta:d,onClose:()=>z(null),onSaved:()=>{z(null),L()}})]})}function Z5(s,l){return s.enabled?s.member_hubspot?l?{tone:"green",label:"Verified"}:{tone:"blue",label:"Needs testing"}:{tone:"amber",label:"Needs owner mapping"}:{tone:"gray",label:"Inactive"}}function K5(){return{name:"",team_member_id:"",scope:"global",scope_value:"",conditions:[{attr:"industry",op:"contains",value:""}],priority:void 0}}function up(s){return s.scope==="global"?"All searches":s.scope==="campaign"?`Campaign: ${s.scope_value||"any"}`:s.scope==="preset"?`Preset: ${s.scope_value||"any"}`:"Manual searches"}function mp(s,l){const i=l.attributes?.find(d=>d.key===s.attr)?.label||s.attr,o=l.operators?.find(d=>d.key===s.op)?.label||s.op;return`${i} ${o} â${s.value}â`}function J5(s,l){return s.conditions?.length?mp(s.conditions[0],l)+(s.conditions.length>1?` +${s.conditions.length-1}`:""):up(s)}function ew({member:s,owners:l,onClose:i,onSaved:o}
79){const[d,u]=h.useState({name:s.name||"",email:s.email||"",hubspot_owner_id:s.hubspot_owner_id||"",active:s.active===void 0?1:s.active,lead_eligible:Number(s.lead_eligible)===1}),[x,y]=h.useState("");async function p(){y("");try{s.id?await je.updateTeamMember(s.id,d):await je.addTeamMember(d),o()}catch(g){y(g.message)}}return e.jsx(Et,{open:!0,onClose:i,title:s.id?"Edit team member":"Add team member",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(U,{variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(U,{onClick:p,children:"Save"})]}),children:e.jsxs("div",{className:"space-y-3",children:[x&&e.jsx(Ne,{tone:"red",children:x}),e.jsx(le,{label:"Name",required:!0,children:e.jsx("input",{className:de,value:d.name,onChange:g=>u({...d,name:g.target.value})})}),e.jsx(le,{label:"Email",required:!0,children:e.jsx("input",{className:de,value:d.email,onChange:g=>u({...d,email:g.target.value})})}),e.jsx(le,{label:"Maps to HubSpot owner",help:"Required before this person's leads can sync to HubSpot.",children:l.length?e.jsxs("select",{className:de,value:d.hubspot_owner_id||"",onChange:g=>u({...d,hubspot_owner_id:g.target.value}),children:[e.jsx("option",{value:"",children:"â not mapped yet â"}),l.map(g=>e.jsxs("option",{value:g.id,children:[g.name,g.email?` (${g.email})`:""]},g.id))]}):e.jsx("input",{className:de,placeholder:"HubSpot owner ID",value:d.hubspot_owner_id||"",onChange:g=>u({...d,hubspot_owner_id:g.target.value})})}),s.id&&e.jsxs("label",{className:"flex items-center gap-2 min-h-11 text-sm",children:[e.jsx("span",{className:"flex h-11 w-11 -ml-2.5 flex-none items-center justify-center",children:e.jsx("input",{type:"checkbox",checked:!!d.active,onChange:g=>u({...d,active:g.target.checked?1:0})})})," Active team member"]}),e.jsx(le,{label:"Receives new leads",help:"Off = reviewer only (can be the fallback reviewer, is never offered as a campaign owner and never becomes a HubSpot contact owner through Fantize). On = approved salesperson; needs a HubSpot owner mapping.",children:e.jsxs("label",{className:"flex items-center gap-2 min-h-11 text-sm",children:[e.jsx("span",{className:"flex h-11 w-11 -ml-2.5 flex-none items-center justify-center",children:e.jsx("input",{type:"checkbox",checked:!!d.lead_eligible,onChange:g=>u({...d,lead_eligible:g.target.checked})})})," Approved to receive new leads"]})})]})})}function tw({rule:s,team:l,meta:i,onClose:o,onSaved:d}){const[u,x]=h.useState({...s}),[y,p]=h.useState("");function g(w,N){const j=u.conditions.slice();j[w]={...j[w],...N},x({...u,conditions:j})}function b(){x({...u,conditions:[...u.conditions,{attr:"geography",op:"contains",value:""}]})}function f(w){x({...u,conditions:u.conditions.filter((N,j)=>j!==w)})}async function k(){p("");const w={...u,conditions:u.conditions.filter(N=>N.attr&&N.value!=="")};try{s.id?await je.updateAssignRule(s.id,w):await je.addAssignRule(w),d()}catch(N){p(N.message)}}return e.jsx(Et,{open:!0,onClose:o,title:s.id?"Edit rule":"Add routing rule",widthClass:"max-w-xl",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(U,{variant:"ghost",onClick:o,children:"Cancel"}),e.jsx(U,{onClick:k,children:"Save rule"})]}),children:e.jsxs("div",{className:"space-y-3",children:[y&&e.jsx(Ne,{tone:"red",children:y}),e.jsx(le,{label:"Rule name (optional)",help:"Shown as the assignment reason, e.g. âWest region reps.â",children:e.jsx("input",{className:de,value:u.name||"",onChange:w=>x({...u,name:w.target.value})})}),e.jsx(le,{label:"Assign to",required:!0,children:e.jsxs("select",{className:de,value:u.team_member_id||"",onChange:w=>x({...u,team_member_id:w.target.value}),children:[e.jsx("option",{value:"",children:"â choose a team member â"}),l.filter(w=>w.active).map(w=>e.jsx("option",{value:w.id,children:w.name},w.id))]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(le,{label:"Applies to",children:e.jsxs("select",{className:de,value:u.scope,onChange:w=>x({...u,scope:w.target.value}),children:[e.jsx("option",{value:"global",children:"All searches"}),e.jsx("option",{value:"campaign",children:"A specific campaign"}),e.jsx("option",{value:"preset",children:"A specific preset search"}),e.jsx("option",{value:"manual",children:"Manual searches only"})]})}),(u.scope==="campaign"||u.scope==="preset")&&e.jsx(le,{label:u.scope==="campaign"?"Campaign":"Preset",children:u.scope==="campaign"?e.jsxs("select",{className:de,value:u.scope_value||"",onChange:w=>x({...u,scope_value:w.target.value}),children:[e.jsx("option",{value:"",children:"â any â"}),(i.campaigns||[]).map(w=>e.jsx("option",{value:w.name,children:w.name},w.id))]}):e.jsxs("select",{className:de,value:u.scope_value||"",onChange:w=>x({...u,scope_value:w.target.value}),children:[e.jsx("option",{value:"",children:"â any â"}),(i.presets||[]).map(w=>e.jsx("option",{value:w.preset_key,children:w.name},w.preset_key))]})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-xs font-medium text-gray-600 uppercase tracking-wide mb-1",children:["Conditions ",e.jsx("span",{className:"text-gray-400 normal-case",children:"(all must match)"})]}),e.jsx("div",{className:"space-y-2",children:u.conditions.map((w,N)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("select",{className:de+" flex-1",value:w.attr,onCh
79ange:j=>g(N,{attr:j.target.value}),children:(i.attributes||[]).map(j=>e.jsx("option",{value:j.key,children:j.label},j.key))}),e.jsx("select",{className:de+" w-32",value:w.op,onChange:j=>g(N,{op:j.target.value}),children:(i.operators||[]).map(j=>e.jsx("option",{value:j.key,children:j.label},j.key))}),e.jsx("input",{className:de+" flex-1",value:w.value,placeholder:"value",onChange:j=>g(N,{value:j.target.value})}),e.jsx("button",{type:"button","aria-label":"Remove condition",className:"flex h-11 w-11 flex-none items-center justify-center rounded-lg text-gray-400 hover:text-rose-600 hover:bg-rose-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",onClick:()=>f(N),children:"â"})]},N))}),e.jsx(U,{size:"sm",variant:"ghost",onClick:b,children:"+ Add condition"}),u.scope==="global"&&!u.conditions.length&&e.jsx(Ne,{tone:"amber",children:"A rule for âall searchesâ needs at least one condition, or it would match every lead."})]})]})})}function aw({onTested:s}){const[l,i]=h.useState([{geography:"",industry:"",company_size:"",campaign:"",preset:""}]),[o,d]=h.useState(null),[u,x]=h.useState(!1);function y(g,b){const f=l.slice();f[g]={...f[g],...b},i(f)}async function p(){x(!0);try{const g=await je.previewAssign({samples:l.filter(b=>Object.values(b).some(f=>f))});d(g.results),s()}finally{x(!1)}}return e.jsxs(_e,{children:[e.jsx(Fe,{action:e.jsx(U,{size:"sm",variant:"soft",onClick:()=>i([...l,{geography:"",industry:"",company_size:"",campaign:"",preset:""}]),children:"Add sample lead"}),children:"Preview who gets assigned"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Enter a few sample leads and see exactly who they would be assigned to. Read-only: nothing syncs to HubSpot."}),e.jsx("div",{className:"space-y-2",children:l.map((g,b)=>e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-2",children:[e.jsx("input",{className:de,"aria-label":"Geography or state",placeholder:"Geography/State",value:g.geography,onChange:f=>y(b,{geography:f.target.value})}),e.jsx("input",{className:de,"aria-label":"Industry",placeholder:"Industry",value:g.industry,onChange:f=>y(b,{industry:f.target.value})}),e.jsx("input",{className:de,"aria-label":"Company size in employees",placeholder:"Size (employees)",value:g.company_size,onChange:f=>y(b,{company_size:f.target.value})}),e.jsx("input",{className:de,"aria-label":"Campaign",placeholder:"Campaign",value:g.campaign,onChange:f=>y(b,{campaign:f.target.value})}),e.jsx("input",{className:de,"aria-label":"Preset key",placeholder:"Preset key",value:g.preset,onChange:f=>y(b,{preset:f.target.value})})]},b))}),e.jsx("div",{className:"mt-3",children:e.jsx(U,{onClick:p,disabled:u,children:u?"Checkingâ¦":"Preview assignments"})}),o&&e.jsxs("div",{className:"mt-4 space-y-1",children:[o.map((g,b)=>e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm border-b border-gray-100 dark:border-gray-700/50 py-1.5",children:[e.jsx("span",{className:"text-gray-500 truncate",children:sw(g.input)}),e.jsxs("span",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:"font-medium",children:g.owner||"â no owner â"}),e.jsx(se,{tone:g.fallback?"gray":g.conflict?"amber":"green",children:g.reason}),g.warning&&e.jsx(se,{tone:"red",children:"!"})]})]},b)),o.some(g=>g.warning)&&e.jsx(Ne,{tone:"amber",children:"Some sample leads have warnings (no owner, or owner not mapped to HubSpot). Fix these before going live."})]})]})}function sw(s){return Object.entries(s).filter(([,l])=>l).map(([l,i])=>`${l}: ${i}`).join(", ")||"(empty)"}const Wu={connected:{kind:"connected",label:"Connected",meaning:"Set up and reachable; not yet exercised by a real sync."},verified:{kind:"verified",label:"Verified",meaning:"Tested with a real sync."},needs_setup:{kind:"action-required",label:"Needs setup",meaning:"Something must be created or confirmed in HubSpot before this can be used."},missing:{kind:"action-required",label:"Missing field",meaning:"The HubSpot property does not exist."},not_tested:{kind:"unavailable",label:"Not tested",meaning:"Never exercised; nothing is known to be wrong."},note_only:{kind:"info",label:"Saved to note",meaning:"Written into the contact note rather than a dedicated property, so a sync never fails on it."}};function Ou({status:s}){const l=Wu[s]||Wu.not_tested;return e.jsx(We,{kind:l.kind,label:l.label})}
79function nw(){const[s,l]=h.useState(null),[i,o]=h.useState(!0),[d,u]=h.useState(""),[x,y]=h.useState("");async function p(){o(!0),u("");try{l(await je.mapping())}catch(_){u(_.message||"Could not load the mapping.")}o(!1)}h.useEffect(()=>{p()},[]);function g(_){y(_),setTimeout(()=>y(""),3e3)}async function b(_,z){await je.saveSettings({[_]:z}),g("Saved."),p()}if(i||!s&&!d)return e.jsxs("div",{className:"max-w-4xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Lifecycle & HubSpot"}),e.jsx(tt,{label:"Loading mappingâ¦"})]});if(d&&!s)return e.jsxs("div",{className:"max-w-4xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Lifecycle & HubSpot"}),e.jsx(Rr,{message:d,onRetry:p})]});const f=s.stages||[],k=s.fields||[],w=k.filter(_=>_.required&&(_.status==="missing"||_.status==="needs_setup")),N=k.filter(_=>_.status==="note_only"),j=[{key:"hs",label:"HubSpot",kind:s.hubspot_connected?"connected":"not-configured",value:s.hubspot_connected?"Connected":"Not connected â nothing can sync",to:s.hubspot_connected?void 0:"/dashboard/integrations?tab=crm-sync",toLabel:"Connect HubSpot"},{key:"stay",label:"Which leads stay in the outbound system",kind:"info",value:"Every cold lead. A lead is created in HubSpot only once it qualifies (a positive reply, a booked meeting, or an approved call outcome)."},{key:"enter",label:"What makes a lead enter HubSpot",kind:"info",value:"A decision in Reply Review, or automatic sync when it is enabled and the reply is above the confidence threshold."},{key:"stages",label:"Lifecycle stages",kind:f.some(_=>_.status==="needs_setup"||_.status==="missing")?"action-required":s.mapping_confirmed?"ready":"needs-review",value:`${f.length} stage mappings${s.mapping_confirmed?", confirmed":", not yet confirmed"}`},{key:"fields",label:"Required fields",kind:w.length?"action-required":s.fields_confirmed?"ready":"needs-review",value:w.length?`${w.length} required field${w.length===1?"":"s"} need setup`:`All required fields available${s.fields_confirmed?", confirmed":", not yet confirmed"}`},{key:"note",label:"Fields written to the contact note",kind:"info",value:N.length?`${N.length} field${N.length===1?"":"s"} (custom properties are off)`:"None â custom properties are written directly"}],T=[{key:"system",header:"System",render:_=>e.jsx(se,{tone:_.system==="HubSpot"?"green":"blue",children:_.system})},{key:"stage",header:"Stage",render:_=>e.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:_.stage})},{key:"fz",header:"Fantize status",render:_=>_.fantize_status},{key:"hs",header:"HubSpot stage",hideBelowMd:!0,render:_=>e.jsx("span",{className:"font-mono text-xs text-gray-500",children:_.hubspot})},{key:"ls",header:"Lead status",render:_=>_.lead_status},{key:"st",header:"Status",render:_=>e.jsx(Ou,{status:_.status})}],S=[{key:"label",header:"Field",render:_=>e.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:_.label})},{key:"prop",header:"HubSpot property",hideBelowMd:!0,render:_=>e.jsx("span",{className:"font-mono text-xs text-gray-500",children:_.hubspot_property||"â"})},{key:"req",header:"Required",render:_=>_.required?e.jsx(se,{tone:"gray",children:"Required"}):e.jsx("span",{className:"text-gray-400 text-xs",children:"optional"})},{key:"st",header:"Status",render:_=>e.jsx(Ou,{status:_.status})}];return e.jsxs("div",{className:"max-w-4xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Lifecycle & HubSpot",subtitle:"How leads move from the outbound system into HubSpot: which stay out, what brings one in, how stages and statuses are assigned, and which fields are ready to receive them.",status:e.jsxs(e.Fragment,{children:[e.jsx(We,{kind:s.hubspot_connected?"connected":"not-configured",label:s.hubspot_connected?"HubSpot connected":"HubSpot not connected"}),w.length>0&&e.jsx(We,{kind:"action-required",label:`${w.length} required field${w.length===1?"":"s"} need setup`})]})}),e.jsx(qn,{message:x}),!s.hubspot_connected&&e.jsx("div",{className:"mb-5",children:e.jsx(Ne,{tone:"amber",children:e.jsxs("p",{children:["HubSpot is not connected yet. ",e.jsx(Se,{to:"/dashboard/integrations?tab=crm-sync",className:"underline font-medium",children:"Connect HubSpot"})," so qualified leads can sync."]})})}),e.jsxs(_e,{className:"mb-5",children:[e.jsx(Fe,{children:"Summary"}),e.jsx(zr,{items:j,columns:2})]}),e.jsxs(_e,{className:"mb-5",children:[e.jsx(Fe,{children:"Lifecycle stages"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Cold leads stay in the outbound system. They only move into HubSpot once they qualify, at the stage and lead status shown here."}),e.jsx(Oo,{caption:"Lifecycle stage mapping",columns:T,rows:f,rowKey:_=>`${_.system}:${_.stage}`}),e.jsx("div",{className:"mt-3",children:e.jsx($t,{checked:!!s.mapping_confirmed,onChange:_=>b("hubspot_mapping_confirmed",_),label:"I have confirmed these lead-status values exist in HubSpot",help:e.jsxs(e.Fragment,{children:["HubSpot â Settings â Properties â Lead Status. Values Fantize writes: ",f.map(_=>
79_.lead_status).filter(Boolean).filter((_,z,A)=>A.indexOf(_)===z).join(", ")||"see table","."]})})})]}),e.jsxs(_e,{className:"mb-5",children:[e.jsx(Fe,{children:"HubSpot fields"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Standard fields always sync. Custom fields sync to a dedicated property only when mapped and âWrite custom HubSpot propertiesâ is on; otherwise the data is written to the contact note so a sync never fails."}),e.jsx(Oo,{caption:"HubSpot field mapping",columns:S,rows:k,rowKey:_=>_.key}),e.jsx("div",{className:"mt-3",children:e.jsx($t,{checked:!!s.fields_confirmed,onChange:_=>b("hubspot_fields_confirmed",_),label:"I have confirmed the required HubSpot fields are available"})}),!s.send_custom_properties&&e.jsx(Ne,{tone:"blue",children:e.jsxs("p",{children:["Custom fields are currently written to the contact note. To use dedicated HubSpot properties, turn on âWrite custom HubSpot propertiesâ under ",e.jsx(Se,{to:"/dashboard/automation/settings#crm",className:"underline",children:"Automation Settings â CRM writing"})," after creating them in HubSpot."]})})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"What the statuses mean"}),e.jsx("dl",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-2 text-sm",children:Object.entries(Wu).map(([_,z])=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("dt",{className:"flex-none",children:e.jsx(Ou,{status:_})}),e.jsx("dd",{className:"text-gray-600 dark:text-gray-300",children:z.meaning})]},_))}),e.jsxs("p",{className:"mt-3 text-xs text-gray-500",children:["âConnectedâ is an actual connection. âVerifiedâ means a real sync exercised this value. Run the HubSpot preflight under ",e.jsx(Es,{to:"/dashboard/automation/readiness",children:"Operational Readiness"})," to verify live."]})]})]})}const df={active:1},rw=`Campaign,Display Name,Owner,HubSpot Owner ID,Internal Owner,Territory,Lead Group,Fallback Owner,Active 80Example Outbound Campaign,Example,[email protected],,Example Rep,Region,Group,,yes 81Second Example Campaign,Second,,000000,Another Rep,Region,Group,,yes`,lw={0:{label:"Draft",kind:"info"},1:{label:"Active â sending",kind:"healthy"},2:{label:"Paused by provider",kind:"paused"},3:{label:"Completed",kind:"info"},4:{label:"Running subsequences",kind:"healthy"},"-99":{label:"Bounce-protected â sending stopped",kind:"action-required"},"-1":{label:"Account suspended",kind:"action-required"},"-2":{label:"Accounts unhealthy",kind:"action-required"},active:{label:"Active â sending",kind:"healthy"},paused:{label:"Paused by provider",kind:"paused"},completed:{label:"Completed",kind:"info"},bounce_protect:{label:"Bounce-protected â sending stopped",kind:"action-required"}};function uf(s){if(s==null||s==="")return{label:"Not reported",kind:"unavailable"};const l=String(s).toLowerCase();return lw[l]||{label:String(s).replace(/_/g," "),kind:"info"}}function iw(){const{isAdmin:s}=zt(),i=Ja().asMarketing?!1:s,[o,d]=h.useState([]),[u,x]=h.useState([]),[y,p]=h.useState([]),[g,b]=h.useState([]),[f,k]=h.useState(null),[w,N]=h.useState(null),[j,T]=h.useState(!0),[S,_]=h.useState(""),[z,A]=h.useState(""),[L,F]=h.useState(null),[D,te]=h.useState(!1),[pe,he]=h.useState(""),[X,I]=h.useState(null),[q,be]=h.useState(null),[ne,M]=h.useState(""),[Y,oe]=h.useState("all"),[Ce,Ae]=h.useState("all"),[H,Z]=h.useState("all"),[$,O]=h.useState("all");function P(Q){_(Q),setTimeout(()=>_(""),3500)}async function V(){const[Q,He,It,Ls]=await Promise.all([je.campaignOwners(),je.team(),je.hubspotOwners().catch(()=>({owners:[]})),je.settings()]);d(Q.mappings||[]),x(He.team||[]),p(It.owners||[]),N(Ls.settings),T(!1),je.instantlyCampaigns().then(Ms=>{b(Ms.campaigns||[]),k(!!Ms.connected)}).catch(()=>k(null))}h.useEffect(()=>{V()},[]);const ye="Campaign routing is Admin-only. Ask your workspace admin to change it.";async function ge(){if(A(""),!i){A(ye);return}const Q={...L};if(!Q.instantly_campaign||!String(Q.instantly_campaign).trim()){A("Choose or enter the outbound campaign.");return}if(!Q.team_member_id&&!Q.hubspot_owner_id&&!Q.fallback_owner_id){A("Assign a salesperson (team member or HubSpot owner), or set a fallback owner.");return}try{L?.id?await je.updateCampaignOwner(L.id,Q):await je.addCampaignOwner(Q),F(null),P("C
81ampaign routing saved."),V()}catch(He){A(He.message||"Could not save.")}}async function qe(Q){if(!i){P(ye);return}try{await je.deleteCampaignOwner(Q.id),be(null),P("Routing removed."),V()}catch(He){P(He.message)}}async function nt(Q){if(!i){P(ye);return}try{await je.updateCampaignOwner(Q.id,{active:!Q.active}),V()}catch(He){P(He.message)}}async function R(Q,He="Saved."){await je.saveSettings(Q);const It=await je.settings();N(It.settings),P(He)}async function we(){if(A(""),I(null),!i){A(ye);return}try{const Q=await je.importCampaignOwners(pe);I(Q),P(Q.message),V()}catch(Q){A(Q.message||"Import failed.")}}const ie=Q=>y.find(He=>String(He.id)===String(Q))?.name||(Q?`Owner ${Q}`:"â");function Ee(Q){if(Q.team_member_id){const He=u.find(Ls=>Ls.id===Q.team_member_id),It=!!(He&&He.hubspot_owner_id);return{text:He?He.name:"Unknown member",mapped:It,fallback:!1}}return Q.hubspot_owner_id?{text:Q.owner_name||ie(Q.hubspot_owner_id),mapped:!0,fallback:!1}:Q.fallback_owner_id?{text:Q.owner_name||ie(Q.fallback_owner_id),mapped:!0,fallback:!0}:{text:"No one",mapped:!1,fallback:!1}}const Je=Q=>{const He=g.find(It=>Q.instantly_campaign_id&&It.id===Q.instantly_campaign_id||(It.name||"").toLowerCase()===(Q.instantly_campaign||"").toLowerCase());return He?uf(He.status):f===!1?{label:"Instantly not connected",kind:"not-configured"}:f===null?{label:"Not reported",kind:"unavailable"}:{label:"Not found in Instantly",kind:"unavailable"}},me=Q=>{const He=Ee(Q);return Q.active?He.mapped?He.fallback?{label:"Per-campaign fallback owner",kind:"needs-review"}:{label:"Routes to a salesperson",kind:"ready"}:{label:"No HubSpot owner â handoff would fail",kind:"action-required"}:{label:"Routing switched off",kind:"disabled"}},ke=h.useMemo(()=>{const Q=new Map;for(const He of o){const It=Ee(He);Q.set(It.text,It.text)}return Array.from(Q.keys()).sort()},[o,u,y]),ze=o.filter(Q=>!(ne.trim()&&!`${Q.display_name||""} ${Q.instantly_campaign} ${Q.territory||""} ${Q.lead_group||""}`.toLowerCase().includes(ne.trim().toLowerCase())||Y!=="all"&&Ee(Q).text!==Y||$!=="all"&&(Q.classification||"production")!==$||Ce!=="all"&&Je(Q).kind!==Ce||H!=="all"&&me(Q).kind!==H)),C={production:o.filter(Q=>(Q.classification||"production")==="production").length,unmapped:o.filter(Q=>Q.active&&!Ee(Q).mapped).length,held:o.filter(Q=>["paused","action-required"].includes(Je(Q).kind)).length};if(j||!w)return e.jsxs("div",{className:"max-w-6xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Campaign Routing"}),e.jsx(tt,{label:"Loading campaign routingâ¦"})]});const ve=w.routing_fallback_mode||"manual_routing",Oe=u.find(Q=>Q.id===w.fallback_reviewer_member_id),dt=[{key:"campaign",header:"Outbound campaign",render:Q=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:Q.display_name||Q.instantly_campaign}),Q.display_name&&Q.display_name.trim().toLowerCase()!==(Q.instantly_campaign||"").trim().toLowerCase()&&e.jsx("div",{className:"text-xs text-gray-400",children:Q.instantly_campaign}),(Q.territory||Q.lead_group)&&e.jsx("div",{className:"text-xs text-gray-400 lg:hidden",children:[Q.territory,Q.lead_group].filter(Boolean).join(" · ")})]})},{key:"owner",header:"Hands off to",render:Q=>{const He=Ee(Q);return e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-800 dark:text-gray-200",children:He.text}),He.fallback&&e.jsx("span",{className:"text-xs text-gray-400",children:" (fallback owner)"}),Q.internal_owner_name&&e.jsxs("div",{className:"text-xs text-gray-400",children:["Internal: ",Q.internal_owner_name]})]})}},{key:"class",header:"Classification",hideBelowMd:!0,render:Q=>{const He=Q.classification||"production";return e.jsx(se,{tone:He==="production"?"blue":"gray",children:He==="production"?"Production":He==="test"?"Test":"Archived"})}},{key:"provider",header:"Provider state",render:Q=>{const He=Je(Q);return e.jsx(We,{kind:He.kind,label:He.label})}},{key:"mapping",header:"Routing state",render:Q=>{const He=me(Q);return e.jsx(We,{kind:He.kind,label:He.label})}},{key:"region",header:"Territory · Group",hideBelowMd:!0,className:"text-gray-500",render:Q=>
81[Q.territory,Q.lead_group].filter(Boolean).join(" · ")||"â"},{key:"actions",header:e.jsx("span",{className:"sr-only",children:"Actions"}),align:"right",render:Q=>i?e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(U,{size:"sm",variant:"soft",onClick:()=>{A(""),F({...Q})},children:"Edit"}),e.jsx(Vo,{label:`More actions for ${Q.display_name||Q.instantly_campaign}`,items:[{label:Q.active?"Switch routing off":"Switch routing on",onClick:()=>nt(Q)},{label:"Delete routing",onClick:()=>be(Q),danger:!0}]})]}):e.jsx("span",{className:"text-xs text-gray-400",children:"Admin-only"})}];return e.jsxs("div",{className:"max-w-6xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Campaign Routing",subtitle:"Which salesperson each outbound (Instantly) campaign hands off to, and the current state of every campaign. This is the primary routing rule; unmatched campaigns follow the fallback behaviour below.",action:i?e.jsx(U,{onClick:()=>{A(""),F({...df})},children:"Add routing"}):void 0,secondary:i?e.jsx(U,{variant:"soft",onClick:()=>{te(!0),I(null),he("")},children:"Import CSV"}):void 0,status:e.jsxs(e.Fragment,{children:[e.jsx(We,{kind:"info",label:`${C.production} production campaign${C.production===1?"":"s"}`}),C.unmapped>0?e.jsx(We,{kind:"action-required",label:`${C.unmapped} without a HubSpot owner`}):e.jsx(We,{kind:"ready",label:"Every active campaign resolves to an owner"}),C.held>0&&e.jsx(We,{kind:"paused",label:`${C.held} held or paused by the provider`}),f===!1&&e.jsx(We,{kind:"not-configured",label:"Instantly not connected â provider state unavailable"})]})}),e.jsx(qn,{message:S}),e.jsxs(_e,{className:"mb-5",children:[e.jsx(Fe,{children:"Fallback routing for unmatched campaigns"}),e.jsxs("p",{className:"text-sm text-gray-500 mb-3",children:["What happens when a reply's campaign matches none of the routing rows below.",!i&&" Managed by your workspace admin."]}),i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[e.jsx(le,{label:"Fallback behaviour",help:"Recommended: a person decides. The default-owner option assigns silently and is kept only for workspaces that relied on it.",children:e.jsxs("select",{className:de,value:ve,onChange:Q=>R({routing_fallback_mode:Q.target.value},"Fallback behaviour saved."),children:[e.jsx("option",{value:"manual_routing",children:"Send to a reviewer and flag âNeeds Manual Routingâ (recommended)"}),e.jsx("option",{value:"default_owner",children:"Assign silently to a default owner (not recommended)"})]})}),ve==="manual_routing"?e.jsxs(le,{label:"Fallback reviewer",help:"Unmatched leads wait for this person to choose a salesperson. The reviewer decides where a lead goes; the lead is never handed to the reviewer's own HubSpot owner.",children:[e.jsxs("select",{className:de,value:w.fallback_reviewer_member_id||"",onChange:Q=>R({fallback_reviewer_member_id:Q.target.value||null},"Fallback reviewer saved."),children:[e.jsx("option",{value:"",children:"â Choose a reviewer â"}),u.map(Q=>e.jsxs("option",{value:Q.id,children:[Q.name,Number(Q.active)===1?"":" (inactive)",Number(Q.lead_eligible)===1?" (also a salesperson)":" (reviewer)"]},Q.id))]}),Oe&&Number(Oe.active)!==1&&e.jsx("div",{className:"mt-1 text-xs text-red-600",children:"This reviewer is inactive, so unmatched leads are waiting for nobody. Choose a current operator."})]}):e.jsx(le,{label:"Default owner",children:e.jsxs("select",{className:de,value:w.default_team_member_id||"",onChange:Q=>R({default_team_member_id:Q.target.value||null},"Default owner saved."),children:[e.jsx("option",{value:"",children:"â No default owner â"}),u.map(Q=>e.jsxs("option",{value:Q.id,children:[Q.name,Q.hubspot_owner_id?"":" (not mapped to HubSpot)"]},Q.id))]})})]}),ve==="manual_routing"&&e.jsxs("details",{className:"mt-3 rounded-xl border border-gray-100 dark:border-gray-700/60 p-3",children:[e.jsx("summary",{className:"min-h-11 flex items-center cursor-pointer text-sm font-medium text-gray-700 dark:text-gray-200",children:"Advanced fallback options"}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3 mt-3",children:[e.jsx(le,{label:"Fallback reviewer HubSpot owner ID",help:"Optional â used only when the reviewer is not a team member.",children:e.jsx("input",{className:de,value:w.fallback_reviewer_owner_id||"",onChange:Q=>N({...w,fallback_reviewer_owner_id:Q.target.value}),onBlur:Q=>R({fallback_reviewer_owner_id:Q.target.value||null},"Saved."),placeholder:"HubSpot owner ID"})}),e.jsx(le,{label:"Fallback Slack webhook (optional)",help:"A dedicated Slack channel for manual-routing alerts. Defaults to your notification Slack webhook.",children:e.jsx("input",{className:de,value:w.fallback_slack_webhook_url||"",onChange:Q=>N({...w,fallback_slack_webhook_url:Q.target.value}),onBlur:Q=>R({fallback_slack_webhook_url:Q.target.value||null},"Saved."),placeholder:"https://hooks.slack.com/services/â¦"})})]})]}),ve==="manual_routing"&&e.jsx("div",{className:"mt-3",children:Oe?e.jsx(We,{kind:Oe.hubspot_owner_id?"ready":"needs-review",label:Oe.hubspot_owner_id?"Fallback reviewer ready":"Fallback reviewer not mapped to HubSpot"}):w.fallback_reviewer_owner_id?e.jsx(We,{kind:"ready",label:`Using HubSpot owner ${w.fallback_reviewer_owner_id}`}):e.jsx(We,{kind:"action-required",label:"No fallback reviewer set â unmatched leads would be flagged unassigned"})})]}):e.jsx(Ne,{tone:"gray",children:ve==="manual_routing"?`Unmatched leads are sent to the fallback reviewer${Oe?` (${Oe.name})`:""}, flagged âNeeds Manual Routingâ, and a person chooses the salesperson.`:"Unmatched leads are assigned to the default owner without a person choosing."})]}),!i&&e.jsx("div",{className:"mb-3",children:e.jsx(Ne,{tone:"amber",children:"Campaign routing is Admin-only. You can see which campaigns are routed where, but changes are made by your workspace admin."})}),o.length===0?e.jsx(Ze,{title:"No campaign routing yet",hint:"Add your first outbound campaign and the salesperson it hands off to, or import a spreadsheet.",doing:"Replies from unrouted campaigns follow the fallback behaviour above.",action:i?e.jsx(U,{size:"sm",onClick:()=>{A(""),F({...df})},children:"Add routing"}):void 0}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Hn,{search:{value:ne,onChange:M,placeholder:"Search campaigns, territory or group",label:"Search campaigns"},summary:`${ze.length} of ${o.length} campaign${o.length===1?"":"s"}`,onClear:ne||Y!=="all"||Ce!=="all"||H!=="all"||$!=="all"?()=>{M(""),oe("all"),Ae("all"),Z("all"),O("all")}:void 0,children:[e.jsx(ha,{label:"Hands off to",value:Y,onChange:oe,options:[{value:"all",label:"Anyone"},...ke.map(Q=>({value:Q,label:Q}))]}),e.jsx(ha,{label:"Classification",value:$,onChange:O,options:[{value:"all",label:"All"},{value:"production",label:"Production"},{value:"test",label:"Test"},{value:"archived",label:"Archived"}]}),e.jsx(ha,{label:"Provider state",value:Ce,onChange:Ae,options:[{value:"all",label:"Any"},{value:"healthy",label:"Active"},{value:"paused",label:"Paused"},{value:"action-required",label:"Held / needs action"},{value:"info",label:"Draft or completed"},{value:"unavailable",label:"Not reported"}]}),e.jsx(ha,{label:"Routing state",value:H,onChange:Z,options:[{value:"all",label:"Any"},{value:"ready",label:"Routes to a salesperson"},{value:"needs-review",label:"Fallback owner"},{value:"action-required",label:"No HubSpot owner"},{value:"disabled",label:"Switched off"}]})]}),e.jsx(Oo,{caption:"Campaign routing",columns:dt,rows:ze,rowKey:
81Q=>Q.id,rowClassName:Q=>Q.active?"":"opacity-70",empty:e.jsx(Ze,{title:"No campaigns match these filters",hint:"Clear the filters to see every campaign."})}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Classification is configuration, never inferred from a campaign's name or its salesperson. Provider state is what Instantly reports now and is changed in Instantly, not here. Routing state says whether a handoff from this campaign would resolve to a HubSpot owner."})]}),e.jsx(Et,{open:!!L,onClose:()=>F(null),title:L?.id?"Edit campaign routing":"Add campaign routing",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(U,{variant:"soft",onClick:()=>F(null),children:"Cancel"}),e.jsx(U,{onClick:ge,children:"Save routing"})]}),children:L&&e.jsxs("div",{className:"space-y-4",children:[z&&e.jsx(Ne,{tone:"red",children:z}),e.jsxs(le,{label:"Outbound campaign",required:!0,help:f?"Pick from your connected Instantly campaigns, or type a name.":"Connect Instantly under Integrations to pick from a list. You can type the name for now.",children:[g.length>0?e.jsxs("select",{className:de,value:g.some(Q=>Q.name===L.instantly_campaign)?L.instantly_campaign:"__custom",onChange:Q=>{if(Q.target.value==="__custom"){F({...L,instantly_campaign:"",instantly_campaign_id:null});return}const He=g.find(It=>It.name===Q.target.value);F({...L,instantly_campaign:He.name,instantly_campaign_id:He.id,display_name:L.display_name||He.name})},children:[e.jsx("option",{value:"__custom",children:"â Type a custom name â"}),g.map(Q=>e.jsxs("option",{value:Q.name,children:[Q.name,Q.status!==void 0?` (${uf(Q.status).label})`:""]},Q.id||Q.name))]}):null,e.jsx("input",{className:de+(g.length>0?" mt-2":""),placeholder:"Campaign name (match key)",value:L.instantly_campaign||"",onChange:Q=>F({...L,instantly_campaign:Q.target.value})})]}),e.jsx(le,{label:"Display name",help:"Friendly name shown in Fantize (optional).",children:e.jsx("input",{className:de,value:L.display_name||"",onChange:Q=>F({...L,display_name:Q.target.value})})}),e.jsx(le,{label:"Hands off to (team member)",help:"Preferred â team members are mapped to a HubSpot owner under Lead Assignment, so the routing is validated.",children:e.jsxs("select",{className:de,value:L.team_member_id||"",onChange:Q=>F({...L,team_member_id:Q.target.value||null}),children:[e.jsx("option",{value:"",children:"â None (use a HubSpot owner directly) â"}),u.map(Q=>e.jsxs("option",{value:Q.id,children:[Q.name,Q.hubspot_owner_id?"":" (not mapped)"]},Q.id))]})}),e.jsx(le,{label:"â¦or a HubSpot contact owner directly",help:"Use when the owner is not a Fantize team member.",children:e.jsxs("select",{className:de,value:L.hubspot_owner_id||"",onChange:Q=>{const He=y.find(It=>String(It.id)===Q.target.value);F({...L,hubspot_owner_id:Q.target.value||null,owner_name:He?He.name:L.owner_name})},children:[e.jsx("option",{value:"",children:"â None â"}),y.map(Q=>e.jsxs("option",{value:Q.id,children:[Q.name,Q.email?` (${Q.email})`:""]},Q.id))]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(le,{label:"Internal owner name",children:e.jsx("input",{className:de,value:L.internal_owner_name||"",onChange:Q=>F({...L,internal_owner_name:Q.target.value})})}),e.jsx(le,{label:"Territory / region",children:e.jsx("input",{className:de,value:L.territory||"",onChange:Q=>F({...L,territory:Q.target.value})})}),e.jsx(le,{label:"Lead group",children:e.jsx("input",{className:de,value:L.lead_group||"",onChange:Q=>F({...L,lead_group:Q.target.value})})}),e.jsx(le,{label:"Per-campaign fallback owner",help:"If this campaign's owner cannot be found in HubSpot.",children:e.jsxs("select",{className:de,value:L.fallback_owner_id||"",onChange:Q=>F({...L,fallback_owner_id:Q.target.value||null}),children:[e.jsx("option",{value:"",children:"â None (use the workspace fallback) â"}),y.map(Q=>e.jsx("option",{value:Q.id,children:Q.name},Q.id))]})})]}),e.jsxs("label",{className:"flex items-center gap-2 min-h-11 text-sm text-gray-700 dark:text-gray-200",children:[e.jsx("input",{type:"checkbox",className:"h-5 w-5 rounded border-gray-300 text-primary-600 focus:ring-primary-500",checked:!!L.active,onChange:Q=>F({...L,active:Q.target.checked?1:0})}),"Routing on (replies to this campaign hand off to the person above)"]}),e.jsxs(le,{label:"Operational classification",children:[e.jsxs("select",{className:de,value:L.classification||"production",onChange:Q=>F({...L,classification:Q.target.value}),children:[e.jsx("option",{value:"production",children:"Production â routes leads, counts toward readiness and reporting"}),e.jsx("option",{value:"test",children:"Test â visible history only; excluded from production routing, readiness, reporting and activation"}),e.jsx("option",{value:"archived",children:"Archived â kept for history; excluded from everything operational"})]}),e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:"Classification is configuration â never inferred from a campaign's name or its assigned salesperson. Changes are recorded in the audit history."})]})]})}),e.jsx(Et,{open:D,onClose:()=>te(!1),title:"Import campaign routing",widthClass:"max-w-2xl",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(U,{variant:"soft",onClick:()=>te(!1),children:"Close"}),e.jsx(U,{onClick:we,disabled:!pe.trim(),children:"Import"})]}),children:e.jsxs("div",{className:"space-y-3",children:[z&&e.jsx(Ne,{tone:"red",children:z}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Paste CSV from your spreadsheet. Recognized columns: ",e.jsx("span",{className:"font-mono text-xs",children:"Campaign, Display Name, Owner, HubSpot Owner ID, Internal Owner, Territory, Lead Group, Fallback Owner, Active"}),". Rows are matched to existing team members by name or email; otherwise give a HubSpot Owner ID."]}),e.jsx("button",{type:"button",className:"min-h-11 text-sm text-primary-600 hover:underline rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",onClick:()=>he(rw),children:"Load example template"}),e.jsxs("label",{children:[e.jsx("span",{className:"sr-only",children:"CSV"}),e.jsx("textarea",{className:de+" font-mono text-xs h-48",placeholder:"Campaign,Owner,...",value:pe,onCh
81ange:Q=>he(Q.target.value)})]}),X&&e.jsxs(Ne,{tone:X.imported?"green":"amber",children:[e.jsx("div",{children:X.message}),X.warnings?.length>0&&e.jsx("ul",{className:"list-disc ml-5 mt-1 text-xs",children:X.warnings.map((Q,He)=>e.jsx("li",{children:Q},He))})]})]})}),e.jsx(Pl,{open:!!q,title:q?`Delete routing for â${q.display_name||q.instantly_campaign}â?`:"Delete routing?",confirmLabel:"Delete routing",danger:!0,onCancel:()=>be(null),onConfirm:()=>q&&qe(q),children:e.jsxs("p",{children:["Replies to this campaign will follow the fallback behaviour instead of handing off to ",q?Ee(q).text:"this person",". The campaign itself in Instantly is not changed. If you only want to stop routing for a while, switch routing off instead."]})}),i&&e.jsxs("p",{className:"mt-4 text-xs text-gray-500 dark:text-gray-400",children:["Who may receive new leads is set under ",e.jsx(Se,{to:"/dashboard/automation/lead-assignment",className:"underline",children:"Lead Assignment"}),". Campaign readiness and list-quality holds are summarised under ",e.jsx(Se,{to:"/dashboard/automation/readiness",className:"underline",children:"Operational Readiness"}),"."]})]})}const ow=[{key:"all",label:"All eligible"},{key:"no_answer",label:"No answer"},{key:"voicemail",label:"Voicemail only"},{key:"bad_number",label:"Bad number"},{key:"not_interested",label:"Not interested"},{key:"no_activity",label:"No call activity"}],Hl={disqualify:{label:"Disqualify",consequence:"Marks the lead disqualified in Fantize. The record is kept; nothing is sent to HubSpot."},suppress:{label:"Suppress",consequence:"Stops further outreach in Fantize. The record is kept."},archive:{label:"Archive",consequence:"Hides the lead from active lists. The record is kept."},flag_removal:{label:"Flag for HubSpot removal",consequence:"Marks the record so an administrator removes it in HubSpot by hand. Fantize does not delete anything.",danger:!0}};function cw(){const[s,l]=h.useState(null),[i,o]=h.useState("all"),[d,u]=h.useState(!0),[x,y]=h.useState(""),[p,g]=h.useState(""),[b,f]=h.useState(null),[k,w]=h.useState(!1);function N(A){g(A),setTimeout(()=>g(""),3500)}async function j(A=i){u(!0),y("");try{l(await je.cleanupQueue(A))}catch(L){y(L.message||"Could not load the cleanup list.")}finally{u(!1)}}h.useEffect(()=>{j("all")},[]);function T(A){o(A),j(A)}async function S(){if(b){w(!0);try{await je.cleanupAction(b.lead.id,b.action),N(`Lead ${Hl[b.action]?.label.toLowerCase()||b.action.replace("_"," ")}.`),f(null),j()}catch(A){N(A.message)}finally{w(!1)}}}const _=s?.leads||[],z=[{key:"lead",header:"Lead",render:A=>e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-800 dark:text-gray-100",children:[A.first_name,A.last_name].filter(Boolean).join(" ")||A.email||A.phone||"â"}),e.jsxs("div",{className:"text-xs text-gray-400",children:[A.company||"",A.email?` · ${A.email}`:"",A.phone?` · ${A.phone}`:""]})]})},{key:"campaign",header:"Campaign",className:"text-gray-500",render:A=>A.instantly_campaign||"â"},{key:"call",header:"Last call",render:A=>A.call_outcome?e.jsx(se,{tone:"gray",children:A.call_outcome}):e.jsx("span",{className:"text-gray-400 text-xs",children:"no activity"})},{key:"since",header:"Eligible since",hideBelowMd:!0,className:"text-gray-500 text-xs",render:A=>A.cleanup_eligible_at?Ke(A.cleanup_eligible_at):"â"},{key:"actions",header:e.jsx("span",{className:"sr-only",children:"Actions"}),align:"right",render:A=>e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(U,{size:"sm",variant:"soft",onClick:()=>f({lead:A,action:"disqualify"}),children:"Disqualify"}),e.jsx(Vo,{label:`More actions for ${A.email||A.phone||"lead"}`,items:[{label:"Suppress",onClick:()=>f({lead:A,action:"suppress"})},{label:"Archive",onClick:()=>f({lead:A,action:"archive"})},{label:"Flag for HubSpot removal",onClick:()=>f({lead:A,action:"flag_removal"}),danger:!0}]})]})}];return e.jsxs("div",{className:"max-w-5xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Cleanup Review",subtitle:"HubSpot contacts synced as âLeadâ for calling that never qualified and are past the cleanup window. Every action here is a reviewed decision; nothing is deleted automatically.",status:s?e.jsxs(e.Fragment,{children:[e.jsx(We,{kind:"info",label:`Cleanup window: ${s.cleanup_period_days} days`}),e.jsx(We,{kind:s.auto_delete?"needs-review":"ready",label:s.auto_delete?"Auto-delete after window: on":"Auto-delete: off â review required"})]}):void 0}),e.jsx(qn,{message:p}),x&&e.jsx("div",{className:"mb-4",children:e.jsx(Rr,{message:x,onRetry:()=>j()})}),e.jsx(dn,{label:"Cleanup filter",items:ow,active:i,onChange:T,className:"mb-5"}),d?e.jsx(tt,{label:"Loading cleanup listâ¦"}):_.length===0?e.jsx(Ze,{tone:"positive",title:"Nothing to clean up",hint:"Call-enabled HubSpot Leads that never qualify appear here once the cleanup window passes.",doing:"Watching the cleanup window"}):e.jsxs(_e,{children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-3",children:[_.length," lead",_.length===1?"":"s"," eligible for cleanup"]}),e.jsx(Oo,{caption:"Leads eligible for cleanup",columns:z,rows:_,rowKey:A=>A.id}),e.jsx("p",{className:"text-xs text-gray-500 mt-3",children:"Actions preserve full audit history. Disqualify, Suppress and Archive keep the record
81in Fantize; Flag marks it for manual removal in HubSpot."})]}),e.jsx(Pl,{open:!!b,title:b?`${Hl[b.action]?.label}: ${[b.lead.first_name,b.lead.last_name].filter(Boolean).join(" ")||b.lead.email||"this lead"}?`:"",confirmLabel:b?Hl[b.action]?.label:"Confirm",danger:!!b&&!!Hl[b.action]?.danger,busy:k,onCancel:()=>f(null),onConfirm:S,children:e.jsx("p",{children:b?Hl[b.action]?.consequence:""})})]})}const dw={admin:"Admin",marketing:"Marketing"};function uw(){const{isAdmin:s,account:l}=zt(),[i,o]=h.useState([]),[d,u]=h.useState(""),[x,y]=h.useState(!0),[p,g]=h.useState(""),[b,f]=h.useState(""),[k,w]=h.useState(null),[N,j]=h.useState(null);function T(D){g(D),setTimeout(()=>g(""),4e3)}async function S(){try{const D=await Da.listUsers();o(D.users||[]),u(D.workspace_owner||"")}catch(D){f(D.message)}finally{y(!1)}}h.useEffect(()=>{S()},[]);async function _(){if(f(""),!k?.name||!k?.email){f("Name and email are required.");return}try{const D=await Da.inviteUser(k);w(null),j({email:D.email,link:D.invite_link}),T(D.message),S()}catch(D){f(D.message)}}async function z(D,te){await Da.updateUser(D.id,{role:te}),T(`${D.name} is now ${dw[te]}.`),S()}async function A(D){await Da.updateUser(D.id,{active:!D.active}),T(`${D.name} ${D.active?"deactivated":"reactivated"}.`),S()}async function L(D){const te=await Da.resendInvite(D.id);j({email:D.email,link:te.invite_link}),T("New invite link generated.")}async function F(D){await Da.deleteUser(D.id),T(`${D.name} removed.`),S()}return s?x?e.jsxs("div",{className:"max-w-4xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Team & Roles"}),e.jsx(tt,{label:"Loading teamâ¦"})]}):e.jsxs("div",{className:"max-w-4xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Team & Roles",subtitle:"Invite people into this shared workspace and set what each role can see and change.",action:e.jsx(U,{onClick:()=>{f(""),w({name:"",email:"",role:"marketing"})},children:"Invite member"})}),p&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"green",children:p})}),b&&e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{tone:"red",children:b})}),N&&e.jsxs(_e,{className:"mb-5 border-l-4 border-l-emerald-500",children:[e.jsxs(Fe,{children:["Invite link for ",N.email]}),e.jsx("p",{className:"text-sm text-gray-500 mb-2",children:"Send this one-time link so they can set their password and join. It expires in 7 days."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{readOnly:!0,className:de+" font-mono text-xs",value:N.link,onFocus:D=>D.target.select()}),e.jsx(U,{size:"sm",variant:"soft",onClick:()=>{navigator.clipboard?.writeText(N.link),T("Copied.")},children:"Copy"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>j(null),children:"Done"})]})]}),e.jsxs(_e,{className:"mb-5",children:[e.jsx(Fe,{children:"Workspace members"}),e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2.5 border-b border-gray-100 dark:border-gray-700/50",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-medium text-gray-800 dark:text-gray-100",children:[l?.name," ",e.jsx("span",{className:"text-gray-400 font-normal",children:"(you)"})]}),e.jsx("div",{className:"text-xs text-gray-400",children:d||l?.email})]}),e.jsx(se,{tone:"green",children:"Admin · Owner"})]}),i.length===0?e.jsx("div",{className:"pt-3",children:e.jsx(Ze,{title:"No team members yet",hint:"Invite your Marketing team so they can work the shared pipeline."})}):e.jsx("div",{className:"divide-y divide-gray-50 dark:divide-gray-700/40",children:i.map(D=>e.jsxs("div",{className:`flex items-center justify-between gap-3 py-2.5 ${D.active?"":"opacity-50"}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-gray-800 dark:text-gray-100 truncate",children:D.name}),e.jsxs("div",{className:"text-xs text-gray-400 truncate",children:[D.email," · ",D.accepted?D.last_login?`last login ${Ke(D.last_login)}`:"joined":"invite pending"]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!D.accepted&&e.jsx(se,{tone:"amber",children:"Pending"}),e.jsxs("select",{"aria-label":`Role for ${D.name}`,className:de+" text-sm w-36",value:D.role,onChange:te=>z(D,te.target.value),children:[e.jsx("option",{value:"marketing",children:"Marketing"}),e.jsx("option",{value:"admin",children:"Admin"})]}),!D.accepted&&e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>L(D),children:"Resend"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>A(D),children:D.active?"Deactivate":"Reactivate"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>{window.confirm(`Remove ${D.name} from this workspace? They lose access immediately.`)&&F(D)},children:"Remove"})]})]},D.id))})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"What each role can do"}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(se,{tone:"green",children:"Admin"}),e.jsxs("ul",{className:"list-disc ml-5 mt-2 text-gray-600 dark:text-gray-300 space-y-1",children:[e.jsx("li",{children:"Everything Marketing can do"}),e.jsx("li",{children:"Overview, Prospecting, Lead Lifecycle, Cleanup Review, Do Not Contact"}),e.jsx("li",{children:"Campaigns, Campaign Routing, Outreach Tracker, Contacts & CRM"}),e.jsx("li",{children:"Automation & Integrations: Operational Readiness, Automation Settings, Lead Assignment, Lifecycle & HubSpot, Notifications, Test Mode, Integrations"}),e.jsx("li",{children:"Analytics, Team & Roles, Brand Settings"})]})]}),e.jsxs("div",{children:[e.jsx(se,{tone:"blue",children:"Marketing"}),e.jsxs("ul",{className:"list-disc ml-5 mt-2 text-gray-600 dark:text-gray-300 space-y-1",children:[e.jsx("li",{children:"Reply Review â decide replies; approved decisions hand off to HubSpot"}),e.jsx("li",{children:"Activity & Issues â what is waiting and what did not complete (read-only)"}),e.jsx("li",{children:"Help, and their own Account & Preferences"}),e.jsx("li",{children:"Shared workspace â sees the whole teamâs replies"}),e.jsx("li",{children:"Cannot open any administrator page; direct links redirect to Reply Review"})]})]})]})]}),e.jsx(Et,{open:!!k,onClose:()=>w(null),title:"Invite a team member",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(U,{variant:"soft",onClick:()=>w(null),children:"Cancel"}),e.jsx(U,{onClick:_,children:"Create invite"})]}),children:k&&e.jsxs("div",{className:"space-y-4",children:[b&&e.jsx(Ne,{tone:"red",children:b}),e.jsx(le,{label:"Full name",required:!0,children:e.jsx("input",{className:de,value:k.name,onChange:D=>w({...k,name:D.target.value}),placeholder:"Jane Doe"})}),e.jsx(le,{label:"Work email",required:!0,children:e.jsx("input",{className:de,value:k.email,onChange:D=>w({...k,email:D.target.value}),placeholder:"[email protected]"})}),e.jsx(le,{label:"Role",help:"Marketing shares the workspace but canât change Admin-only settings.",children:e.jsxs("select",{className:de,value:k.role,onChange:D=>w({...k,role:D.target.value}),children:[e.jsx("option",{value:"marketing",children:"Marketing"}),e.jsx("option",{value:"admin",children:"Admin"})]})}),e.jsx("p",{className:"text-xs text-gray-400",children:"Theyâll get a one-time link to set their own password â no password is set or stored for them here."})]})})]}):e.jsxs("div",{className:"max-w-3xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Team & Roles"}),e.jsx(Ne,{tone:"amber",children:"This section is Admin-only. Ask your workspace admin to manage team members and roles."})]})}function mw(){const[s]=$r(),l=s.get("token")||"",[i,o]=h.useState(null),[d,u]=h.useState(!0),[x,y]=h.useState(""),[p,g]=h.useState(""),[b,f]=h.useState(""),[k,w]=h.useState(!1);h.useEffect(()=>{document.title="Set your password | Fantize"},[]),h.useEffect(()=>{if(!l){f("This link is missing its invite token."),u(!1);return}Da.inviteInfo(l).then(o).catch(j=>
81f(j.message||"This invite link is invalid or expired.")).finally(()=>u(!1))},[l]);async function N(){if(f(""),x.length<8){f("Choose a password of at least 8 characters.");return}if(x!==p){f("The two passwords donât match.");return}w(!0);try{const j=await Da.acceptInvite(l,x);ff(j.token),window.location.href="/dashboard"}catch(j){f(j.message||"Could not set your password."),w(!1)}}return e.jsx("div",{className:"min-h-screen flex items-center justify-center px-4 bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900 dark:text-gray-100",children:"Fantize"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Set your password to join the team"})]}),e.jsx(_e,{children:d?e.jsx(tt,{label:"Checking your inviteâ¦"}):i?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500",children:"Welcome"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:i.name}),e.jsxs("div",{className:"text-xs text-gray-400",children:[i.email," · ",i.role==="admin"?"Admin":"Marketing"]})]}),b&&e.jsx(Ne,{tone:"red",children:b}),e.jsx(le,{label:"Create a password",required:!0,children:e.jsx("input",{type:"password",className:de,value:x,onChange:j=>y(j.target.value),placeholder:"At least 8 characters",autoComplete:"new-password"})}),e.jsx(le,{label:"Confirm password",required:!0,children:e.jsx("input",{type:"password",className:de,value:p,onChange:j=>g(j.target.value),onKeyDown:j=>j.key==="Enter"&&N(),autoComplete:"new-password"})}),e.jsx(U,{onClick:N,disabled:k,className:"w-full",children:k?"Setting upâ¦":"Set password & continue"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ne,{tone:"red",children:b||"This invite link is invalid or has expired."}),e.jsx("p",{className:"text-sm text-gray-500",children:"Ask your workspace admin to resend your invite."}),e.jsx(Se,{to:"/login",className:"text-sm text-primary-600 hover:underline",children:"Back to sign in"})]})})]})})}const hw=[{v:"fantize_only",l:"In Fantize only",hint:"Shows in Reply Review and Activity & Issues. Always on in practice."},{v:"slack",l:"Slack",hint:"Post to a Slack channel via an incoming webhook"},{v:"email",l:"Email",hint:"Email an address or distribution list"},{v:"hubspot_task",l:"HubSpot task",hint:"Create a task on the HubSpot contact for its owner"}],xw=[{v:"instant",l:"As it happens"},{v:"daily_digest",l:"Daily digest (1pm)"},{v:"after_approval",l:"After a person approves"},{v:"after_mql",l:"After MQL"},{v:"after_sal",l:"After SAL / meeting"},{v:"after_sync",l:"After the HubSpot handoff"}],gw={methods:["fantize_only"],timing:["after_mql"],recipient:"",slack_webhook_url:"",active_during_testing:!0};function fw(){const[s,l]=h.useState(null),[i,o]=h.useState(null),[d,u]=h.useState(!1),[x,y]=h.useState(!1),[p,g]=h.useState([]),[b,f]=h.useState(!0),[k,w]=h.useState(!1),[N,j]=h.useState(null),[T,S]=h.useState(null),[_,z]=h.useState(!1),[A,L]=h.useState(""),[F,D]=h.useState(null),[te,pe]=h.useState(null);async function he(){const[$,O]=await Promise.all([je.settings(),je.notificationLog()]),P=$.settings.notify_config||gw;l(P),o(P),u(!!$.settings.notify_confirmed),y(!!$.settings.notify_confirmed),g(O.log||[]),f(!1),je.automationReadiness().then(V=>{D(V.channels||null),pe(V.automation?.external_notifications??null)}).catch(()=>D(null))}h.useEffect(()=>{he()},[]);function X($){L($),setTimeout(()=>L(""),4e3)}const I=h.useMemo(()=>!!i&&(JSON.stringify(i)!==JSON.stringify(s)||x!==d),[i,s,x,d]),q=i&&i.methods.includes("email"),be=i&&i.methods.includes("slack"),ne=i&&i.methods.length>0&&i.timing.length>0&&(!q||!!i.recipient)&&(!be||!!i.slack_webhook_url)&&x,M=i&&i.methods.some($=>$!=="fantize_only"),Y=[];i&&i.methods.length===0&&Y.push("Choose at least one channel."),i&&i.timing.length===0&&Y.push("Choose when to notify."),q&&!i.recipient&&Y.push("Add an email recipient."),be&&!i.slack_webhook_url&&Y.push("Add the Slack webhook URL."),i&&!x&&Y.push("Confirm the preference (required for activation).");function oe($,O){S(null);const P=i[$];o({...i,[$]:P.includes(O)?P.filter(V=>V!==O):[...P,O]})}async function Ce(){w(!0),j(null);try{await je.saveSettings({notify_config:i,notify_confirmed:x,notify_channel:i.methods[0]}),S("Notification settings saved."),await he(),setTimeout(()=>S(null),4e3)}catch($){j($.message||"Could not save.")}finally{w(!1)}}function Ae(){o(s),y(d),j(null)}async function H(){if(window.confirm("Send a test notification now through the external
81channels selected above? This saves the current settings first.")){z(!0);try{await je.saveSettings({notify_config:i,notify_confirmed:x,notify_channel:i.methods[0]});const $=await je.testNotification(i);X($.message||"Test sent."),he()}catch($){X($.message)}finally{z(!1)}}}if(b||!i)return e.jsxs("div",{className:"max-w-3xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Notifications"}),e.jsx(tt,{label:"Loadingâ¦"})]});const Z=F?Object.entries(F).map(([$,O])=>({key:$,label:$.replace(/_/g," ").replace(/^\w/,P=>P.toUpperCase()),kind:O.ready?"ready":"not-configured",value:O.ready?"Could deliver now":"Cannot deliver yet",detail:O.ready?O.detail:O.blocker})):[];return e.jsxs("div",{className:"max-w-3xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Notifications",subtitle:"Who is told when a lead qualifies, through which channel and when â and whether each channel could deliver today.",status:e.jsxs(e.Fragment,{children:[e.jsx(We,{kind:te===null?"unavailable":te?"ready":"info",label:te===null?"Delivery mode unknown":te?"External channels: on":"In-app only â external channels are switched off on the server"}),e.jsx(We,{kind:ne?"ready":"needs-review",label:ne?"Configuration complete":`${Y.length} item${Y.length===1?"":"s"} to complete`})]}),action:M?e.jsx(U,{variant:"soft",onClick:H,disabled:_,children:_?"Sendingâ¦":"Send test"}):void 0}),e.jsx(qn,{message:A}),e.jsxs(_e,{className:"mb-5",children:[e.jsx(Fe,{children:"Channel readiness"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Whether each channel could deliver right now, and the exact blocker when it could not. Read-only; nothing is sent from this card."}),F?e.jsx(zr,{items:Z,columns:2,dense:!0}):e.jsx("p",{className:"text-sm text-gray-500",children:"Channel readiness could not be read."}),te===!1&&e.jsx("p",{className:"mt-3 text-xs text-gray-500",children:"External delivery is switched off by a server setting. Until an administrator turns it on, only in-app notifications appear, whatever is selected below."})]}),e.jsxs(_e,{className:"mb-5",children:[e.jsx(Fe,{action:e.jsx(se,{tone:ne?"green":"amber",children:ne?"Complete":"Incomplete"}),children:"How to notify"}),e.jsx("div",{className:"grid sm:grid-cols-2 gap-2",children:hw.map($=>e.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 min-h-11 cursor-pointer text-sm ${i.methods.includes($.v)?"border-primary-300 bg-primary-50/40 dark:bg-primary-900/20 dark:border-primary-700":"border-gray-200 dark:border-gray-700"}`,children:[e.jsx("input",{type:"checkbox",className:"mt-0.5 h-5 w-5 rounded border-gray-300 text-primary-600 focus:ring-primary-500",checked:i.methods.includes($.v),onChange:()=>oe("methods",$.v)}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:$.l}),e.jsx("span",{className:"block text-xs text-gray-500",children:$.hint})]})]},$.v))}),be&&e.jsx("div",{className:"mt-3",children:e.jsx(le,{label:"Slack incoming-webhook URL",help:"In Slack: Apps â Incoming Webhooks â add to a channel, then paste the URL here.",error:i.slack_webhook_url?void 0:"Required for Slack delivery.",children:e.jsx("input",{className:de,value:i.slack_webhook_url,onChange:$=>{S(null),o({...i,slack_webhook_url:$.target.value})},placeholder:"https://hooks.slack.com/services/â¦"})})}),q&&e.jsx("div",{className:"mt-3",children:e.jsx(le,{label:"Email recipient",help:"Where qualified-lead alerts are emailed.",error:i.recipient?void 0:"Required for email delivery.",children:e.jsx("input",{className:de,type:"email",value:i.recipient,onChange:$=>{S(null),o({...i,recipient:$.target.value})},placeholder:"[email protected]"})})}),i.methods.includes("hubspot_task")&&e.jsx("div",{className:"mt-3",children:e.jsx(Ne,{tone:"blue",children:"HubSpot tasks are created on the contact and assigned to its owner once the lead is in HubSpot."})})]}),e.jsxs(_e,{className:"mb-5",children:[e.jsx(Fe,{children:"When to notify"}),e.jsx("div",{className:"grid sm:grid-cols-2 gap-x-4",children:xw.map($=>e.jsx($t,{label:$.l,checked:i.timing.includes($.v),onChange:()=>oe("timing",$.v)},$.v))})]}),e.jsxs(_e,{className:"space-y-2 mb-5",children:[e.jsx(Fe,{children:"During testing"}),e.jsx($t,{label:"Send external alerts during testing (before activation)",checked:i.active_during_testing,onChange:$=>{S(null),o({...i,active_during_testing:$})},help:"Off keeps Slack, email and HubSpot quiet while you test; in-app alerts still appear. They begin once automation is activated."}),e.jsx("div",{className:"border-t border-gray-100 dark:border-gray-700/60 pt-2",children:e.jsx($t,{label:"I have confirmed the notification preference",checked:x,onChange:$=>{S(null),y($)},help:"Required before automation can be activated under Operational Readiness."})}),ne?e.jsxs(Ne,{tone:"green",children:["Notifications are configured.",q?` Emails go to ${i.recipient}.`:"",be?" Slack webhook set.":""," Use âSend testâ to verify delivery."]}):e.jsx(Ne,{tone:"amber",children:e.jsx("ul",{className:"list-disc ml-5",children:Y.map($=>e.jsx("li",{children:$},$))})})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"Delivery log"}),p.length===0?e.jsx(Ze,{title:"No notifications sent yet",hint:"Send a test, or wait for a lead to qualify.",doing:"Nothing to deliver"}):e.jsx("ul",{className:"space-y-1",children:p.map($=>e.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm border-b border-gray-100 dark:border-gray-700/40 py-1.5",children:[e.jsxs("span",{className:"min-w-0 truncate",children:[e.jsx(se,{tone:"gray",children:$.method.replace("_"," ")})," ",e.jsxs("span",{className:"text-gray-500",children:[$.trigger,$.recipient?` â ${$.recipient}`:""]}),$.detail&&$.status!=="sent"&&e.jsxs("span",{className:"text-gray-400",children:[" · ",$.detail]})]}),e.jsxs("span",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(We,{kind:$.status==="sent"?"ready":$.status==="skipped"?"disabled":"action-required",label:$.status==="sent"?"Sent":$.status==="skipped"?"Skipped":"Failed"}),e.jsx("span",{className:"text-xs text-gray-400",children:Ke($.created_at)})]})]},$.id))})]}),e.jsx(If,{dirty:I,saving:k,onSave:Ce,onDiscard:Ae,error:N,success:T})]})}const Ao={hubspot_mapping_confirmed:{to:"/dashboard/automation/lifecycle-hubspot",label:"Open Lifecycle & HubSpot"},hubspot_fields_confirmed:{to:"/dashboard/automation/lifecycle-hubspot",label:"Open Lifecycle & HubSpot"},instantly_campaign_mapped:{to:"/dashboard/campaigns/routing",label:"Open Campaign Routing"},owner_routing_configured:{to:"/dashboard/automation/lead-assignment",label:"Open Lead Assignment"},default_owner_set:{to:"/dashboard/automation/lead-assignment",label:"Open Lead Assignment"},routing_tested:{to:"/dashboard/automation/test-mode",label:"Open Test Mode"},notify_confirmed:{to:"/dashboard/automation/notifications",label:"Open Notifications"},review_tested:{to:"/dashboard/leads/review",label:"Open Reply Review"},samples_tested:{to:"/dashboard/automation/test-mode",label:"Open Test Mode"},sync_verified:{to:"/dashboard/leads/review",label:"Open Reply Review"}},pw={pass:"ready",fail:"action-required",warn:"needs-review"},yw={active:{label:"Active â sending",kind:"healthy"},paused:{label:"Paused by provider",kind:"paused"},completed:{label:"Completed",kind:"info"},bounce_protect:{label:"Bounce-protected â sending stopped",kind:"action-required"},draft:{label:"Draft",kind:"info"}};
81function bw(){const[s,l]=h.useState(null),[i,o]=h.useState(!1),[d,u]=h.useState(!0),[x,y]=h.useState(""),[p,g]=h.useState(""),[b,f]=h.useState(""),[k,w]=h.useState(null),[N,j]=h.useState(!1),[T,S]=h.useState(null),[_,z]=h.useState(!1),[A,L]=h.useState(null);async function F(){u(!0),y("");try{const[O,P]=await Promise.all([je.goLiveReadiness(),je.settings()]);l(O),o(!!P.settings.auto_sync_enabled),L(new Date().toISOString())}catch(O){y(O.message||"Could not load readiness.")}u(!1),je.automationReadiness().then(O=>{S(O),z(!1)}).catch(()=>{S(null),z(!0)})}h.useEffect(()=>{F()},[]);function D(O){g(O),setTimeout(()=>g(""),3500)}async function te(){j(!0),f("");try{w(await je.hubspotPreflight())}catch(O){f(O.message||"Preflight failed.")}finally{j(!1)}}async function pe(O){f("");const P=O?"Turn on automatic HubSpot sync? Qualifying replies above the auto-sync confidence will be handed to HubSpot without a person deciding. You can turn it off again here.":"Turn off automatic HubSpot sync? Every qualifying reply will wait in Reply Review for a person.";if(window.confirm(P))try{await je.saveSettings({auto_sync_enabled:O}),o(O),D(O?"Automatic sync turned on.":"Automatic sync turned off."),F()}catch(V){f(V.message||"Could not change automatic sync."),o(!1)}}if(d&&!s)return e.jsxs("div",{className:"max-w-3xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Operational Readiness"}),e.jsx(tt,{label:"Checking readinessâ¦"})]});if(x&&!s)return e.jsxs("div",{className:"max-w-3xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Operational Readiness"}),e.jsx(Rr,{message:x,onRetry:F})]});const he=s.items||[],X=he.filter(O=>O.done).length,I=he.filter(O=>!O.done),q=I.length===0,be=T?.automation||{},ne=T?.providers||{},M=Array.isArray(T?.campaigns)?T.campaigns:[],Y=M.filter(O=>O.state!=="active"&&O.state!=="completed"||O.verification&&!O.verification.ready),Ce=Object.entries(T?.channels||{}).filter(([,O])=>O.ready).map(([O])=>O.replace(/_/g," ")),Ae=Ce.some(O=>O!=="in app"&&O!=="fantize only"),H=T?[{key:"hubspot",label:"HubSpot",kind:ne.hubspot_connected?"connected":"not-configured",value:ne.hubspot_connected?"Connected":"Not connected â handoffs cannot reach HubSpot",to:ne.hubspot_connected?void 0:"/dashboard/integrations?tab=crm-sync",toLabel:"Connect in Integrations"},{key:"instantly",label:"Instantly",kind:ne.instantly_connected?"connected":"not-configured",value:ne.instantly_connected?"Connected â monitoring for replies":"Not connected â replies are not being read",to:ne.instantly_connected?void 0:"/dashboard/integrations?tab=crm-sync",toLabel:"Connect in Integrations"}]:[],Z=T?[{key:"review",label:"Human review",kind:"needs-review",value:be.auto_sync_enabled?"Required only below the auto-sync confidence":"Required for every qualifying reply",detail:"Decisions are made in Reply Review."},{key:"sync",label:"Automatic HubSpot sync",kind:be.auto_sync_enabled?"ready":"disabled",value:be.auto_sync_enabled?"On â qualifying replies sync without a person":"Off â nothing reaches HubSpot without a person"},{key:"decisions",label:"Decision automation",kind:be.auto_decisions_enabled?"ready":"disabled",value:be.auto_decisions_enabled?"On â clear ânot interestedâ replies stop outreach automatically":"Off â every reply is recorded and left for a person"},{key:"failclosed",label:"Fail-closed protection",kind:be.inbound_guard_fail_closed?"ready":"needs-review",value:be.inbound_guard_fail_closed?"On â a handoff whose checks cannot finish waits":"Off â a handoff proceeds under the remaining safeguards"},{key:"import",label:"Imported-contact handling",kind:be.inbound_import_exception?"ready":"disabled",value:be.inbound_import_exception?"On â verified enrolled imports get a limited, reviewed update":"Off â such handoffs are held for a person"},{key:"notify",label:"Notifications",kind:Ae?"ready":"info",value:Ae?`External channels ready: ${Ce.join(", ")}`:"In-app only",to:"/dashboard/automation/notifications",toLabel:"Notification settings"}]:[],$=(()=>{if(!T&&_)return{title:"Re-check the live activation summary",body:"The live summary of providers and campaigns could not be loaded, so campaign exceptions are unknown. Reload to try again.",to:void 0,cta:void 0,tone:"amber"};if(T&&!ne.hubspot_connected)return{title:"Connect HubSpot",body:"Handoffs cannot reach HubSpot until it is connected under Integrations.",to:"/dashboard/integrations?tab=crm-sync",cta:"Open Integrations",tone:"amber"};if(T&&!ne.instantly_connected)return{title:"Connect Instantly",body:"Replies are not being read until Instantly is connected under Integrations.",to:"/dashboard/integrations?tab=crm-sync",cta:"Open Integrations",tone:"amber"};if(!q){const O=I[0],P=Ao[O.key];return{title:`Complete: ${O.label}`,body:`${I.length} technical prerequisite${I.length===1?"":"s"} remain before automatic sync can be enabled. Manual review keeps working meanwhile.`,to:P?.to,cta:P?.label,tone:"blue"}}return Y.length?{title:`${Y.length} campaign${Y.length===1?"":"s"} need${Y.length===1?"s":""} a decision before it can send`,body:"Technical prerequisites are complete. These
81campaigns are held by the provider or need list verification; the rest of the workflow keeps operating.",to:"/dashboard/campaigns/routing",cta:"Open Campaign Routing",tone:"amber"}:T&&Array.isArray(T.remaining_before_activation)&&T.remaining_before_activation.length?{title:"Remaining before activation",body:T.remaining_before_activation.join(" · "),to:void 0,cta:void 0,tone:"blue"}:i?{title:"Operating normally",body:"Automatic sync is on and no campaign is held. Check Activity & Issues for anything waiting on a person.",to:"/dashboard/leads/activity",cta:"Open Activity & Issues",tone:"green"}:{title:"Nothing is blocking. Automatic sync stays off until you enable it.",body:"Every prerequisite is complete. Enabling automatic sync is an explicit administrator decision made below; until then every qualifying reply waits in Reply Review.",to:"/dashboard/leads/review",cta:"Open Reply Review",tone:"green"}})();return e.jsxs("div",{className:"max-w-3xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Operational Readiness",subtitle:"How the workflow is operating right now, as separate facts. Technical prerequisites can be complete while automatic processing stays off or a campaign is held.",status:e.jsxs(e.Fragment,{children:[e.jsx(We,{kind:q?"ready":"needs-review",label:q?"Technical prerequisites: complete":`Technical prerequisites: ${I.length} remaining`}),T&&e.jsx(We,{kind:be.auto_sync_enabled?"ready":"disabled",label:be.auto_sync_enabled?"Automatic sync: on":"Automatic sync: off â human review required"}),T&&Y.length>0&&e.jsx(We,{kind:"paused",label:`${Y.length} campaign${Y.length===1?"":"s"} held`}),A&&e.jsxs("span",{className:"text-xs text-gray-500",children:["Checked ",Ke(A)]})]}),secondary:e.jsx(U,{variant:"soft",onClick:F,disabled:d,children:d?"Refreshingâ¦":"Refresh"})}),e.jsx(qn,{message:p}),e.jsxs("div",{className:"space-y-5",children:[e.jsx(Wf,{title:$.title,body:$.body,to:$.to,cta:$.cta,tone:$.tone}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"Provider connectivity"}),!T&&!_&&e.jsx(tt,{label:"Checking providersâ¦"}),_&&e.jsx(Rr,{message:"The live provider check could not be completed.",onRetry:F}),T&&e.jsx(zr,{items:H,columns:2})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"Processing mode"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"What Fantize does on its own, and what waits for a person. These are configured under Automation Settings; nothing here changes them except the automatic-sync switch at the bottom of this page."}),!T&&!_&&e.jsx(tt,{label:"Reading automation stateâ¦"}),T&&e.jsx(zr,{items:Z,columns:2})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"Campaign exceptions"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Production campaigns that are held, paused or awaiting list verification. A held campaign never makes the whole workflow unavailable; replies to it are still reviewed."}),!T&&!_&&e.jsx(tt,{label:"Inspecting campaignsâ¦"}),T&&M.length===0&&e.jsx("p",{className:"text-sm text-gray-500",children:"No production campaigns are mapped yet."}),T&&M.length>0&&Y.length===0&&e.jsx(We,{kind:"healthy",label:`All ${M.length} production campaign${M.length===1?"":"s"} sending normally`,size:"md"}),T&&Y.length>0&&e.jsx("ul",{className:"divide-y divide-gray-100 dark:divide-gray-700/50",children:Y.map(O=>{const P=yw[String(O.state)]||{label:String(O.state).replace(/_/g," "),kind:"info"};return e.jsxs("li",{className:"py-2.5 flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between sm:gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:O.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Hands off to ",O.owner_name||O.owner_id||"no one"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(We,{kind:P.kind,label:P.label}),O.verification&&e.jsx(We,{kind:O.verification.ready?"verified":"action-required",label:O.verification.ready?"List verification satisfied":O.verification.run_id?`List verification: ${O.verification.reasons.length} item(s) open`:"Action required: verify the list before this campaign can resume"})]})]},O.id)})}),T&&Array.isArray(T.test_campaigns)&&T.test_campaigns.length>0&&e.jsxs("div",{className:"mt-3 text-xs text-gray-500",children:[T.test_campaigns.length," test campaign",T.test_campaigns.length===1?"":"s"," kept for history only â excluded from production routing, readiness and activation."]}),e.jsx("div",{className:"mt-3",children:e.jsx(Se,{to:"/dashboard/campaigns/routing",className:"inline-flex min-h-11 items-center text-sm font-medium text-primary-600 hover:underline dark:text-primary-400 rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:"Every campaign, with its provider and routing state"})})]}),e.jsxs(_e,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1",children:[e.jsx(Fe,{children:"Technical prerequisites"}),e.jsxs(se,{tone:q?"green":"amber",children:[X," of ",he.length]})]}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"What must be in place before automatic sync may be enabled. Manual review does not depend on these."}),e.jsx("ul",{className:"divide-y divide-gray-100 dark:divide-gray-700/50",children:he.map(O=>e.jsxs("li",{className:"flex items-start justify-between gap-3 py-2.5",children:[e.jsxs("div",{className:"flex items-start gap-2.5 min-w-0",children:[e.jsx(We,{kind:O.done?"ready":"needs-review",label:O.done?"Done":"To do",className:"mt-0.5 flex-none"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:`text-sm ${O.done?"text-gray-700 dark:text-gray-200":"text-gray-900 dark:text-gray-100 font-medium"}`,children:O.label}),!O.done&&O.note&&e.jsx("div",{className:"text-xs text-amber-700 dark:text-amber-400",children:O.note})]})]}),!O.done&&Ao[O.key]&&e.jsx(Se,{to:Ao[O.key].to,className:"flex-shrink-0",children:e.jsx(U,{size:"sm",variant:"soft",children:Ao[O.key].label})})]}
81,O.key))})]}),e.jsxs(_e,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1",children:[e.jsx(Fe,{children:"HubSpot preflight"}),e.jsx(U,{size:"sm",variant:"soft",onClick:te,disabled:N,children:N?"Checkingâ¦":k?"Re-run":"Run HubSpot preflight"})]}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Reads HubSpot directly to confirm the lifecycle stages, lead-status values, a Disqualified status, the campaign property, contact owners, engagement logging and API scopes this workflow needs. Read-only."}),!k&&!N&&e.jsx("p",{className:"text-sm text-gray-500",children:"Not run in this session. âVerifiedâ below means a live check passed, not that a setting exists."}),N&&e.jsx(tt,{label:"Querying HubSpotâ¦"}),b&&e.jsx("div",{className:"mb-3",children:e.jsx(Ne,{tone:"red",children:b})}),k&&e.jsxs(e.Fragment,{children:[!k.connected&&e.jsx(Ne,{tone:"red",children:"HubSpot is not connected. Add your private-app token under Integrations, then re-run."}),k.connected&&e.jsx("div",{className:"mb-3",children:e.jsx(We,{kind:k.ready?"verified":"needs-review",label:k.ready?"HubSpot verified for a controlled test":"HubSpot needs setup before testing",size:"md"})}),e.jsx("ul",{className:"divide-y divide-gray-100 dark:divide-gray-700/50",children:(k.items||[]).map(O=>e.jsx("li",{className:"py-2.5",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-100",children:O.label}),e.jsx("div",{className:"text-xs text-gray-500",children:O.detail}),O.missing&&O.missing.length>0&&e.jsxs("div",{className:"text-xs text-red-600 dark:text-red-400 mt-0.5",children:["Missing: ",O.missing.join(", ")]}),O.status!=="pass"&&O.fix&&e.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-300 mt-1 bg-gray-50 dark:bg-gray-800/60 rounded px-2 py-1",children:["How to fix: ",O.fix]})]}),e.jsx(We,{kind:pw[O.status]||"info",label:O.status==="pass"?"Verified":O.status==="fail"?"Failed":"Warning"})]})},O.key))})]})]}),e.jsxs(_e,{className:"space-y-3",children:[e.jsx(Fe,{children:"Automatic HubSpot sync"}),e.jsx("p",{className:"text-sm text-gray-500",children:"An explicit administrator decision. It stays exactly where you leave it and is never turned on by readiness alone."}),!q&&!i&&e.jsx(Ne,{tone:"amber",children:"Locked until every technical prerequisite above is complete. Until then, qualifying leads wait safely in Reply Review â nothing syncs by accident."}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Automatically sync qualified leads to HubSpot"}),e.jsx("div",{className:"text-sm text-gray-500",children:i?"On â qualified leads sync automatically.":"Off â every qualifying lead waits in Reply Review for a person."})]}),e.jsx(U,{variant:i?"soft":"primary",disabled:!q&&!i,onClick:()=>pe(!i),children:i?"Turn off automatic sync":"Enable automatic sync"})]})]})]})]})}const ql=[{v:"positive_reply",l:"Positive reply",event_type:"email_replied",reply:"Sounds interesting, can you send more information?"},{v:"meeting_intent",l:"Asks to schedule",event_type:"email_replied",reply:"Happy to chat next week â can you send a few times?"},{v:"meeting_scheduled",l:"Meeting scheduled",event_type:"meeting_booked",reply:""},{v:"meeting_click",l:"Meeting-link clicked",event_type:"meeting_link_clicked",reply:""},{v:"contacted",l:"Email delivered (Contacted)",event_type:"email_delivered",reply:""},{v:"not_contacted",l:"Not contacted",event_type:"not_contacted",reply:""},{v:"unsubscribe",l:"Unsubscribe reply",event_type:"email_replied",reply:"Please remove me, unsubscribe."},{v:"disqualified",l:"Disqualified (manual)",event_type:"disqualified",reply:""}],vw={instant:"instantly",daily_digest:"daily digest",after_approval:"after approval",after_mql:"after MQL",after_sal:"after SAL",after_sync:"after sync"};function jw(){const[s,l]=h.useState("positive_reply"),[i,o]=h.useState(""),[d,u]=h.useState(""),[x,y]=h.useState(ql[0].reply
81),[p,g]=h.useState(null),[b,f]=h.useState(null),[k,w]=h.useState([]),[N,j]=h.useState(!1),[T,S]=h.useState(!0),[_,z]=h.useState(null),[A,L]=h.useState(null),[F,D]=h.useState(""),[te,pe]=h.useState(""),[he,X]=h.useState(!1),[I,q]=h.useState(""),[be,ne]=h.useState(null);async function M(){const V=await je.testLog();w(V.log||[])}async function Y(){try{z(await je.controlledTest())}catch{}}h.useEffect(()=>{(async()=>{const V=await je.settings();g(V.settings.notify_config),L(V.settings),V.settings.test_campaign&&(D(V.settings.test_campaign),o(V.settings.test_campaign)),V.settings.test_owner_id&&pe(V.settings.test_owner_id),await Promise.all([M(),Y()]),S(!1)})()},[]);function oe(V){q(V),setTimeout(()=>q(""),4e3)}async function Ce(){X(!0);try{await je.saveSettings({test_campaign:F,test_owner_id:te}),oe("Test campaign and owner saved."),await Y()}finally{X(!1)}}async function Ae(){X(!0);try{const V=(await je.campaignOwners()).mappings.find(ye=>(ye.instantly_campaign||"").toLowerCase()===F.toLowerCase());V?await je.updateCampaignOwner(V.id,{hubspot_owner_id:te,active:1}):await je.addCampaignOwner({instantly_campaign:F,display_name:F,hubspot_owner_id:te,active:1}),oe(`Mapped â${F}â â HubSpot owner ${te}.`),await Y()}catch(V){oe(V.message)}finally{X(!1)}}async function H(){ne(null);try{ne(await je.validateOwner(te))}catch(V){ne({valid:!1,message:V.message})}}async function Z(){X(!0);try{const V=await je.importInstantlyCampaign({campaign_name:F});oe(V.message||"Imported."),await Y()}catch(V){oe(V.message)}finally{X(!1)}}function $(V){l(V);const ye=ql.find(ge=>ge.v===V);y(ye.reply)}async function O(){j(!0);try{const V=ql.find(ge=>ge.v===s),ye=await je.lifecyclePreview({event_type:V.event_type,reply_text:x,campaign:i,industry:d,use_ai:!0});f(ye),await M()}finally{j(!1)}}if(T)return e.jsxs("div",{className:"max-w-3xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Test Mode"}),e.jsx(tt,{label:"Loadingâ¦"})]});const P=p&&p.methods?.length?`${p.methods.map(V=>V.replace("_"," ")).join(", ")} · ${(p.timing||[]).map(V=>vw[V]||V).join(", ")||"no timing set"}`:"not configured";return e.jsxs("div",{className:"max-w-3xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Test Mode",subtitle:"Dry-run a reply scenario and see the outcome â owner, status, notification and HubSpot fields â before anything is live. Nothing here writes to HubSpot or Instantly except the explicit import and mapping buttons in the controlled-test card, which say so."}),e.jsxs(_e,{className:"mb-5 border-l-4 border-l-primary-500",children:[e.jsx(Fe,{action:_&&e.jsx(se,{tone:_.ready?"green":"amber",children:_.ready?"Ready for controlled test":"Setup incomplete"}),children:"Controlled Test Mode"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Run the first controlled test with the existing leads already uploaded to your Instantly test campaign/list â no new Prospeo search. Map the campaign to a HubSpot owner, import the leads, preview each sync, and approve before anything writes to HubSpot."}),I&&e.jsx("div",{className:"mb-3",children:e.jsx(Ne,{tone:"green",children:I})}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3 mb-3",children:[e.jsx(le,{label:"Test campaign / list",help:"The Instantly campaign or list already holding your test leads. Saved as workspace configuration; nothing is assumed.",children:e.jsx("input",{className:de,value:F,onChange:V=>D(V.target.value),placeholder:"Name of the test campaign"})}),e.jsx(le,{label:"HubSpot contact owner ID",help:"All qualified leads from this campaign map to this owner.",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:de,value:te,onChange:V=>{pe(V.target.value),ne(null)},placeholder:"HubSpot owner ID"}),e.jsx(U,{size:"sm",variant:"soft",onClick:H,children:"Validate"})]})})]}),be&&e.jsx("div",{className:"mb-3",children:e.jsx(Ne,{tone:be.valid?"green":"red",children:be.message})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx(U,{size:"sm",onClick:Ce,disabled:he,children:"Save test config"}),e.jsx(U,{size:"sm",variant:"soft",onClick:Ae,disabled:he||!F||!te,title:"Writes a campaign routing row for the test campaign",children:"Map campaign â owner (writes routing)"}),e.jsx(U,{size:"sm",variant:"soft",onClick:Z,disabled:he||!F,title:"Reads leads from Instantly and creates Fantize records",children:he?"Workingâ¦":"Import existing leads from Instantly"}),A&&!A.instantly_connected&&e.jsx("span",{className:"text-xs text-amber-600 self-center",children:"Connect Instantly to auto-read leads, or paste them on the review screen."})]}),_&&e.jsxs("div",{className:"rounded-xl bg-gray-50 dark:bg-gray-800/60 p-3",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-400 mb-2",children:"Test checklist"}),e.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-700/50",children:_.checklist.map(V=>e.jsxs("div",{className:"flex items-start gap-2.5 py-1.5 text-sm",children:[e.jsx("span",{className:`mt-0.5 flex-shrink-0 ${V.done?"text-emerald-600":"text-gray-300 dark:text-gray-600"}`,children:V.done?"â":"â"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:V.done?"text-gray-600 dark:text-gray-300":"text-gray-800 dark:text-gray-100",children:V.label}),V.note&&e.jsx("span",{className:"text-xs text-amber-600 ml-2",children:V.note})]})]},V.key))}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-3 text-sm",children:[e.jsx(Se,{to:"/dashboard/campaigns/routing",className:"inline-flex min-h-11 items-center text-primary-600 hover:underline rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:"Campaign Routing"}),e.jsx(Se,{to:"/dashboard/leads/review",className:"inline-flex min-h-11 items-center text-primary-600 hover:underline rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:"Reply Review"}),e.jsx(Se,{to:"/dashboard/leads/lifecycle",className:"inline-flex min-h-11 items-center text-primary-600 hover:underline rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:"Lead Lifecycle"}),e.jsx(Se,{to:"/dashboard/automation/readiness",className:"inline-flex min-h-11 items-center text-primary-600 hover:underline rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:"Operational Readiness (HubSpot preflight)"})]})]})]}),e.jsxs(_e,{className:"mb-5",children:[e.jsx(Fe,{children:"Run a scenario"}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-3",children:[e.jsx(le,{label:"Scenario",children:e.jsx("select",{className:de,value:s,onChange:V=>$(V.target.value),children:ql.map(V=>e.jsx("option",{value:V.v,children:V.l},V.v))})}),e.jsx(le,{label:"Outbound campaign",children:e.jsx("input",{className:de,value:i,onChange:V=>o(V.target.value),placeholder:"Campaign name"})}),e.jsx(le,{label:"Industry (for routing)",children:e.jsx("input",{className:de,value:d,onChange:V=>u(V.target.value),placeholder:"e.g. Manufacturing"})})]}),ql.find(V=>V.v===s)?.event_type==="email_replied"&&e.jsx(le,{label:"Reply text",children:e.jsx("textarea",{className:de,rows:2,value:x,onChange:V=>y(V.target.value)})}),e.jsx("div",{className:"mt-2",children:e.jsx(U,{onClick:O,disabled:N,children:N?"Runningâ¦":"Run test"})})]}),b&&e.jsxs(_e,{className:"mb-5",children:[e.jsx(Fe,{action:e.jsx(se,{tone:b.outcome.would_sync?b.warnings.length?"red":"green":"gray",children:b.outcome.would_sync?b.warnings.length?"Would fail":"Would sync":"Stays in Fantize"}),children:"Result"}),e.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-100 mb-3",children:b.outcome.decision}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-x-6 gap-y-2 text-sm",children:[e.jsx(on,{label:"Fantize status",value:b.outcome.internal_status}),e.jsx(on,{label:"Proposed owner",value:b.proposed_owner?`${b.proposed_owner}${b.owner_mapped===!1?" (not mapped)":""}`:"â",tone:b.owner_mapped===!1?"red":void 0}),e.jsx(on,{label:"HubSpot lifecycle",value:b.outcome.proposed_lifecycle_stage||"â"}),e.jsx(on,{label:"HubSpot lead status",value:b.outcome.proposed_lead_status||"â"}),e.jsx(on,{label:"Routing reason",value:b.owner_reason||"â"}),e.jsx(on,{label:"Goes to Review?",value:b.outcome.goes_to_review?"Yes":"No"}),e.jsx(on,{label:"Notification",value:b.outcome.would_sync||b.outcome.goes_to_review?P:"none (no qualification)"}),b.classification&&e.jsx(on,{label:"AI classified",value:`${b.classification.classification} (${b.classification.confidence}, ${b.classification.method})`})]}),b.warnings.length>0&&e.jsxs(Ne,{tone:"amber",children:[e.jsx("b",{children:"Before this could sync:"}),e.jsx("ul",{className:"list-disc ml-5 mt-1",children:b.warnings.map((V,ye)=>e.jsx("li",{children:V},ye))})]})]}),e.jsxs(_e,{children:[e.jsx(Fe,{action:e.jsx(Se,{to:"/dashboard/automation/lead-assignment",className:"inline-flex min-h-11 items-center text-sm text-primary-600 hover:underline rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:"Test assignment with sample leads"}),children:"Test history"}),k.length===0?e.jsx(Ze,{title:"No tests run yet",hint:"Run a scenario above to start building your test history."}):e.jsx("div",{className:"space-y-1",children:k.map(V=>e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm border-b border-gray-50 dark:border-gray-700/40 py-1.5",children:[e.jsxs("span",{className:"min-w-0 truncate",children:[e.jsx(se,{tone:"gray",children:V.kind})," ",e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:V.summary||V.scenario})]}),e.jsxs("span",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(se,{tone:V.passed?"green":"amber",children:V.passed?"Pass":"Review"}),e.jsx("span",{className:"text-xs text-gray-400",children:Ke(V.created_at)})]})]},V.id))})]})]})}function on({label:s,value:l,tone:i}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-400",children:s}
81),e.jsx("div",{className:`${i==="red"?"text-rose-600 dark:text-rose-400 font-medium":"text-gray-800 dark:text-gray-200"}`,children:l})]})}function ww(){const s=Ya(),[l,i]=h.useState(1),[o,d]=h.useState(""),[u,x]=h.useState(!1),[y,p]=h.useState(null),[g,b]=h.useState(null),f=h.useRef(null),k=h.useRef(Date.now());h.useEffect(()=>{k.current=Date.now(),Ie.track("wizard_started",{timestamp:new Date().toISOString()}),Ie.track("step_viewed",{step:1,stepName:"import_contacts"}),console.log("ð¯ [FirstCampaignWizard] Wizard started")},[]),h.useEffect(()=>{l===1?Ie.track("step_viewed",{step:1,stepName:"import_contacts"}):l===2?Ie.track("step_viewed",{step:2,stepName:"create_campaign"}):l===3&&Ie.track("step_viewed",{step:3,stepName:"review_send"})},[l]),h.useEffect(()=>()=>{l<3&&(Ie.track("wizard_abandoned",{abandonedAtStep:l,contactsImported:y?.imported||0,campaignCreated:!!g}),console.log("â ï¸ [FirstCampaignWizard] Wizard abandoned at step",l))},[l,y,g]);const[w,N]=h.useState(""),[j,T]=h.useState(!1),[S,_]=h.useState({name:"Welcome Campaign",type:"social_proof",subject:"Join our growing community!",content:`Hi {{first_name}}, 82 83We're excited to have you join our community of happy customers! 84 85ð You're in great company - join thousands of satisfied customers who trust us. 86 87Here's what makes us special: 88⢠Proven track record with real results 89⢠Join a community that's growing every day 90⢠Trusted by industry leaders and everyday users alike 91 92As a welcome gift, here's an exclusive offer just for you: [Your special offer] 93 94Ready to get started? Click below to explore: 95ð [Get Started Now] 96 97Welcome aboard! 98 99The Team`}),[z,A]=h.useState(!1),[L,F]=h.useState({goal:"",target_audience:""}),[D,te]=h.useState(!1),pe=async ne=>{const M=ne.target.files?.[0];if(!M)return;console.log("ð [FirstCampaignWizard] Starting file import:",M.name,"size:",M.size),Ie.track("wizard_step_1_file_upload_started",{fileName:M.name,fileSize:M.size}),T(!0),d("");const Y=Date.now();try{const oe=await Ba.import(M),Ce=Date.now()-Y;console.log("â [FirstCampaignWizard] File import successful:",oe,"duration:",Ce+"ms"),Ie.track("wizard_step_1_file_upload_success",{imported:oe.imported,skipped:oe.skipped,duration:Ce}),p(oe),oe.imported>0&&(Ie.track("wizard_step_1_completed",{method:"file",contactCount:oe.imported}),Ie.track("step_completed",{step:1,stepName:"import_contacts",method:"file",contactCount:oe.imported}),console.log("ð [FirstCampaignWizard] Step 1 completed - advancing to step 2"),setTimeout(()=>i(2),1500))}catch(oe){const Ce=Date.now()-Y,Ae=oe.message;console.error("â [FirstCampaignWizard] File import failed:",Ae,"duration:",Ce+"ms"),Ie.trackError("wizard_step_1_file_upload",oe,{fileName:M.name,duration:Ce}),d(Ae)}finally{T(!1),f.current&&(f.current.value="")}},he=async()=>{if(!w.trim()){d("Please paste CSV data");return}console.log("ð [FirstCampaignWizard] Starting paste import, text length:",w.length),Ie.track("wizard_step_1_paste_upload_started",{textLength:w.length}),T(!0),d("");const ne=Date.now();try{const M=new Blob([w],{type:"text/csv"}),Y=new File([M],"contacts.csv",{type:"text/csv"}),oe=await Ba.import(Y),Ce=Date.now()-ne;console.log("â [FirstCampaignWizard] Paste import successful:",oe,"duration:",Ce+"ms"),Ie.track("wizard_step_1_paste_upload_success",{imported:oe.imported,skipped:oe.skipped,duration:Ce}),p(oe),oe.imported>0&&(Ie.track("wizard_step_1_completed",{method:"paste",contactCount:oe.imported}),Ie.track("step_completed",{step:1,stepName:"import_contacts",method:"paste",contactCount:oe.imported}),console.log("ð [FirstCampaignWizard] Step 1 completed - advancing to step 2"),setTimeout(()=>i(2),1500))}catch(M){const Y=Date.now()-ne,oe=M.message;console.error("â [FirstCampaignWizard] Paste import failed:",oe,"duration:",Y+"ms"),Ie.trackError("wizard_step_1_paste_upload",M,{textLength:w.length,duration:Y}),d(oe)}finally{T(!1)}},X=async()=>{if(!L.goal||!L.target_audience){d("Please provide both campaign goal and target audience");return}console.log("ð¤ [FirstCampaignWizard] Starting AI generation:",{goal:L.goal,audience:L.target_audience}),Ie.track("wizard_step_2_ai_generation_started",{goal:L.goal,targetAudience:L.target_audience,campaignType:S.type}),A(!0),d("");const ne=Date.now();try{const M=await xa.generateCopy({goal:L.goal,target_audience:L.target_audience,campaign_type:S.type}),Y=Date.now()-ne;console.log("â [FirstCampaignWizard] AI generation successful, duration:",Y+"ms"),Ie.track("wizard_step_2_ai_generation_success",{duration:Y,subjectLength:M.subject.length,bodyLength:M.body.length}),_({...S,subject:M.subject,content:M.body})}catch(M){const Y=Date.now()-ne,oe=M.message;console.error("â [FirstCampaignWizard] AI generation failed:",oe,"duration:",Y+"ms"),Ie.trackError("wizard_step_2_ai_generation",M,{duration:Y}),d(oe)}finally{A(!1)}},I=async()=>{console.log("ð [FirstCampaignWizard] Creating campaign:",{name:S.name,type:S.type,hasSubject:!!S.subject,contentLength:S.content.length}),Ie.track("wizard_step_2_create_campaign_started",{campaignName:S.name,campaignType:S.type,hasSubject:!!S.subject,contentLength:S.content.length}),d("");const ne=Date.now();try{const M=await xa.create({name:S.name,type:S.type,subject:S.subject,content:S.content}),Y=Date.now()-ne;console.log("â [FirstCampaignWizard] Campaign created successfully:",M.id,"duration:",Y+"ms"),Ie.track("wizard_step_2_completed",{campaignId:M.id,duration:Y}),Ie.track("step_completed",{step:2,stepName:"create_campaign",campaignId:M.id,campaignType:S.type,duration:Y}),Ie.track("wizard_step_3_started",{campaignId:M.id}),b(M.id),i(3)}catch(M){const Y=Date.now()-ne,oe=M.message;console.error("â [FirstCampaignWizard] Campaign creation failed:",oe,"duration:",Y+"ms"),Ie.trackError("wizard_step_2_create_campaign",M,{duration:Y}),d(oe)}},q=async()=>
99{if(!g)return;console.log("ð [FirstCampaignWizard] Sending campaign:",g),Ie.track("campaign_send_started",{campaignId:g,contactCount:y?.imported||0,source:"wizard"}),te(!0),d("");const ne=Date.now();try{const M=await xa.send(g),Y=Date.now()-ne;console.log("â [FirstCampaignWizard] Campaign sent successfully:",M,"duration:",Y+"ms"),Ie.track("campaign_sent",{campaignId:g,queuedCount:M.queued,duration:Y,source:"wizard"}),Ie.track("step_completed",{step:3,stepName:"review_send",campaignId:g,queuedCount:M.queued,duration:Y}),Ie.track("wizard_completed",{campaignId:g,contactsImported:y?.imported||0,campaignType:S.type,totalDuration:Date.now()-k.current}),setTimeout(()=>{console.log("ð [FirstCampaignWizard] Redirecting to dashboard"),s("/dashboard")},1e3)}catch(M){const Y=Date.now()-ne,oe=M.message;console.error("â [FirstCampaignWizard] Campaign send failed:",oe,"duration:",Y+"ms"),Ie.trackError("campaign_send",M,{campaignId:g,duration:Y,source:"wizard"}),d(oe),te(!1)}},be=ne=>{console.log(`âï¸ [FirstCampaignWizard] Skipping from step ${l} to step ${ne}`),Ie.track("wizard_step_skipped",{fromStep:l,toStep:ne}),Ie.track("wizard_step_2_started",{viaSkip:!0}),i(ne)};return e.jsxs("div",{className:"max-w-4xl mx-auto",children:[u&&e.jsx(Jf,{onClose:()=>x(!1),onStartImport:()=>f.current?.click()}),e.jsx(Xe,{title:"First campaign setup",subtitle:"Three steps: import contacts, create the campaign, review and send. Nothing is sent until the last step."}),e.jsx("div",{className:"mb-8",children:e.jsx("div",{className:"flex items-center justify-between",children:[{num:1,label:"Import Contacts",icon:"ð¥"},{num:2,label:"Create Campaign",icon:"âï¸"},{num:3,label:"Review & Send",icon:"ð"}].map((ne,M)=>e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsxs("div",{className:"flex flex-col items-center flex-1",children:[e.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center text-lg font-bold mb-2 transition-all ${l>ne.num?"bg-green-500 text-white":l===ne.num?"bg-primary-500 text-white ring-4 ring-primary-100":"bg-gray-200 text-gray-400"}`,children:l>ne.num?"â":ne.icon}),e.jsx("span",{className:`text-sm font-medium ${l===ne.num?"text-primary-600":"text-gray-500"}`,children:ne.label})]}),M<2&&e.jsx("div",{className:`h-1 flex-1 mx-2 rounded ${l>ne.num?"bg-green-500":"bg-gray-200"}`})]},ne.num))})}),o&&e.jsx("div",{className:"bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded mb-6",children:o}),y&&e.jsxs("div",{className:"bg-green-50 border border-green-200 text-green-700 px-4 py-3 rounded mb-6 flex items-start gap-3",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5 flex-shrink-0 mt-0.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold",children:["Success! Imported ",y.imported," contacts"]}),y.skipped>0&&e.jsxs("p",{className:"text-sm",children:["(",y.skipped," skipped - already exist or invalid)"]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg p-8",children:[l===1&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Step 1: Import Your Contacts"}),e.jsx("button",{onClick:()=>be(2),type:"button",className:"inline-flex min-h-11 items-center rounded-lg px-2 text-primary-600 hover:text-primary-800 text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:"Skip this step"})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"border-2 border-dashed border-gray-300 rounded-lg p-6 hover:border-primary-400 transition-colors",children:e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-12 h-12 mx-auto text-gray-400 mb-3",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Upload CSV File"}),e.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Upload a CSV file with columns: email, first_name, last_name, company, phone"}),e.jsxs("label",{className:"inline-flex items-center gap-2 bg-primary-500 hover:bg-primary-600 text-white px-6 py-3 rounded-lg font-semibold cursor-pointer transition-colors",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),j?"Importing...":"Choose CSV File",e.jsx("input",{ref:f,type:"file",accept:".csv",onChange:pe,disabled:j,className:"hidden"})]})]})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-gray-300"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"px-2 bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400",children:"OR"})})]}),e.jsxs("div",{className:"border-2 border-gray-300 rounded-lg p-6",children:[e.jsx("h3",{id:"wizard-csv-heading",className:"text-lg font-semibold mb-2",children:"Paste CSV Data"}),e.jsx("p",{id:"wizard-csv-help",className:"text-sm text-gray-600 mb-4",children:"Copy and paste your CSV data directly below"}),e.jsx("textarea",{"aria-labelledby":"wizard-csv-heading","aria-describedby":"wizard-csv-help",value:w,onChange:ne=>N(ne.target.value),placeholder:`email,first_name,last_name,company,phone 100[email protected],Contact,One,Acme Inc,555-1234
101[email protected],Contact,Two,Tech Co,555-5678`,rows:6,className:"w-full border rounded-lg px-4 py-3 font-mono text-sm focus:outline-none focus:ring-2 focus:ring-primary-500",disabled:j}),e.jsx("button",{onClick:he,disabled:j||!w.trim(),className:"mt-4 bg-primary-500 hover:bg-primary-600 text-white px-6 py-3 rounded-lg font-semibold disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:j?"Importing...":"Import Contacts"})]}),e.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})}),e.jsxs("div",{className:"text-sm text-blue-900",children:[e.jsx("p",{className:"font-semibold mb-1",children:"CSV Format Example:"}),e.jsx("code",{className:"text-xs bg-white dark:bg-gray-700 dark:text-gray-200 px-2 py-1 rounded",children:"email,first_name,last_name,company,phone"}),e.jsx("p",{className:"mt-2 text-blue-800",children:"Don't worry if you skip this step - you can always add contacts later!"})]})]})})]})]}),l===2&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Step 2: Create Your Campaign"}),e.jsx("p",{className:"text-gray-600 mb-6",children:"We've pre-filled a proven social proof template for you. Customize it or use AI to generate fresh copy!"}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"wizard-campaign-name",className:"block text-sm font-medium text-gray-700 mb-2",children:"Campaign Name"}),e.jsx("input",{id:"wizard-campaign-name",type:"text",value:S.name,onChange:ne=>_({...S,name:ne.target.value}),className:"w-full border rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"wizard-campaign-type",className:"block text-sm font-medium text-gray-700 mb-2",children:"Campaign Type"}),e.jsxs("select",{id:"wizard-campaign-type",value:S.type,onChange:ne=>_({...S,type:ne.target.value}),className:"w-full border rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-primary-500",children:[e.jsx("option",{value:"social_proof",children:"Social Proof - Leverage community trust"}),e.jsx("option",{value:"email",children:"Email - Standard message"}),e.jsx("option",{value:"sms",children:"SMS - Text message"}),e.jsx("option",{value:"darkcall",children:"DarkCall - Multi-channel"})]})]}),e.jsxs("div",{className:"bg-gradient-to-r from-primary-50 to-violet-50 dark:from-primary-950/40 dark:to-violet-950/20 border-2 border-primary-200 dark:border-primary-800 rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-6 h-6 text-purple-600",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z"})}),e.jsx("h3",{className:"text-lg font-bold text-purple-900",children:"AI Copy Generator (Optional)"})]}),e.jsx("p",{className:"text-sm text-purple-800 mb-4",children:"Let AI create personalized campaign copy for you"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"wizard-what-s-your-campaign-goal",className:"block text-xs font-medium text-gray-700 mb-1",children:"What's your campaign goal?"}),e.jsx("input",{id:"wizard-what-s-your-campaign-goal",type:"text",value:L.goal,onCh
101ange:ne=>F({...L,goal:ne.target.value}),placeholder:"e.g., Welcome new subscribers, promote a product, build trust",className:"w-full border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-purple-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"wizard-who-s-your-target-audience",className:"block text-xs font-medium text-gray-700 mb-1",children:"Who's your target audience?"}),e.jsx("input",{id:"wizard-who-s-your-target-audience",type:"text",value:L.target_audience,onChange:ne=>F({...L,target_audience:ne.target.value}),placeholder:"e.g., Small business owners, music fans, tech enthusiasts",className:"w-full border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-purple-500"})]}),e.jsx("button",{onClick:X,disabled:z,className:"w-full bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg font-semibold disabled:opacity-50 transition-colors",children:z?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsxs("svg",{className:"animate-spin h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Generating..."]}):"⨠Generate with AI"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"wizard-subject-line",className:"block text-sm font-medium text-gray-700 mb-2",children:"Subject Line"}),e.jsx("input",{id:"wizard-subject-line",type:"text",value:S.subject,onChange:ne=>_({...S,subject:ne.target.value}),className:"w-full border rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-primary-500",placeholder:"Enter your email subject line"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"wizard-message-content",className:"block text-sm font-medium text-gray-700 mb-2",children:"Message Content"}),e.jsx("textarea",{id:"wizard-message-content",value:S.content,onChange:ne=>_({...S,content:ne.target.value}),rows:12,className:"w-full border rounded-lg px-4 py-3 font-mono text-sm focus:outline-none focus:ring-2 focus:ring-primary-500",placeholder:"Enter your campaign message..."}),e.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["ð¡ Tip: Use ","{{first_name}}"," and ","{{last_name}}"," to personalize your message"]})]}),S.type==="social_proof"&&e.jsx("div",{className:"bg-green-50 border border-green-200 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5 text-green-600 flex-shrink-0 mt-0.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{className:"text-sm text-green-900",children:[e.jsx("p",{className:"font-semibold mb-1",children:"Social Proof Campaign Selected!"}),e.jsx("p",{className:"text-green-800",children:"This template leverages social proof to build trust and credibility. It highlights community, testimonials, and social validation to increase engagement."})]})]})}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>i(1),className:"px-6 py-3 border border-gray-300 rounded-lg font-semibold hover:bg-gray-50 transition-colors",children:"â Back"}),e.jsx("button",{onClick:I,className:"flex-1 bg-primary-500 hover:bg-primary-600 text-white px-6 py-3 rounded-lg font-semibold transition-colors",children:"Continue to Review â"})]})]})]}),l===3&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Step 3: Review & Send"}),e.jsx("p",{className:"text-gray-600 mb-6",children:"Review your campaign details and send when ready!"}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"border-2 border-gray-200 rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-gray-50 px-4 py-3 border-b border-gray-200",children:e.jsx("h3",{className:"font-bold text-sm",children:"Campaign Preview"})}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase",children:"Campaign Name"}),e.jsx("p",{className:"text-lg font-semibold",children:S.name})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase",children:"Type"}
101),e.jsx("p",{className:"capitalize",children:S.type.replace("_"," ")})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase",children:"Subject"}),e.jsx("p",{className:"font-medium",children:S.subject})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase",children:"Message"}),e.jsx("div",{className:"mt-2 bg-gray-50 rounded-lg p-4 border border-gray-200 max-h-64 overflow-y-auto",children:e.jsx("pre",{className:"text-sm whitespace-pre-wrap font-sans",children:S.content})})]})]})]}),e.jsx("div",{className:"bg-gradient-to-r from-green-50 to-emerald-50 border-2 border-green-200 rounded-lg p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-12 h-12 bg-green-500 rounded-full flex items-center justify-center text-2xl",children:"ð"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold text-green-900 mb-2",children:"You're All Set!"}),e.jsx("p",{className:"text-green-800 mb-3",children:"Your campaign is ready to send. Click the button below to send it to all your contacts."}),e.jsxs("ul",{className:"text-sm text-green-700 space-y-1",children:[e.jsx("li",{children:"â Campaign created and saved as draft"}),e.jsxs("li",{children:["â ",y?`${y.imported} contacts`:"Contacts"," ready to receive"]}),e.jsx("li",{children:"â Personalization tags will be replaced automatically"})]})]})]})}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>i(2),className:"px-6 py-3 border border-gray-300 rounded-lg font-semibold hover:bg-gray-50 transition-colors",disabled:D,children:"â Edit Campaign"}),e.jsx("button",{onClick:q,disabled:D,className:"flex-1 bg-green-600 hover:bg-green-700 text-white px-6 py-3 rounded-lg font-bold text-lg disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:D?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"w-6 h-6",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5"})}),"Send Campaign Now ð"]})})]}),e.jsx("div",{className:"text-center pt-2",children:e.jsx("button",{onClick:()=>s("/dashboard"),className:"text-sm text-gray-500 hover:text-gray-700 underline",disabled:D,children:"Skip for now and go to dashboard"})})]})]})]})]})}const kw=de;function Nw({message:s,onDone:l}){return h.useEffect(()=>{const i=setTimeout(l,2e3);return()=>clearTimeout(i)},[l]),e.jsx("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-5 py-2.5 bg-gray-900 text-white text-sm rounded-full shadow-xl animate-fade-in",children:s})}function _w(){const[s,l]=h.useState([]),[i,o]=h.useState(!0),[d,u]=h.useState(!1),[x,y]=h.useState(""),[p,g]=h.useState(!1),[b,f]=h.useState(""),[k,w]=h.useState(null);h.useEffect(()=>{},[]);const N=()=>{o(!0),Za.list().then(D=>l(D.lists)).catch(()=>l([])).finally(()=>o(!1))};h.useEffect(()=>{N()},[]);const j=s.reduce((D,te)=>D+(te.contact_count??0),0),T=s.length>0?Math.round(j/s.length):0,S=async D=>{if(D.preventDefault(),!!x.trim()){g(!0),f("");try{await Za.create(x.trim()),u(!1),y(""),w("List created"),N()}catch(te){f(te.message)}finally{g(!1)}}},_=async D=>{if(window.confirm(`Delete "${D.name}"? This cannot be undone.`))try{await Za.delete(D.id),w("List deleted"),N()}catch(te){w(`Error: ${te.message}`)}},z=()=>{if(s.length===0){w("No lists to export");return}const D=[["List Name","Description","Contacts","Created"],...s.map(te=>[te.name,te.description??"",te.contact_count??0,Ke(te.created_at)])];Ua(`fantize-lists-${new Date().toISOString().slice(0,10)}.csv`,D),w("Lists exported")},[A,L]=h.useState(null),F=async D=>{L(D.id);try{const{contacts:te}=await Ba.list({list_id:D.id,limit:5e3});if(te.length===0){w(`"${D.name}" has no contacts`);return}Ua(`fantize-list-${ep(D.name)}.csv`,Fl(te)),w(`Exported ${te.length} contact${te.length!==1?"s":""}`)}catch(te){w(`Error: ${te.message}`)}finally{L(null)}};return e.jsxs("div",{className:"max-w-5xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Lists & Segments",subtitle:"Organize contacts into targeted groups for campaigns and outreach.",action:e.jsxs(e.Fragment,{children:[e.jsx(U,{variant:"soft",size:"sm",onClick:z,disabled:s.length===0,children:"Export CSV"}),e.jsx(U,{variant:"primary",size:"sm",onClick:()=>{u(!0),f(""),y("")},children:"New List"})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-6",children:[e.jsx(Ct,{label:"Total Lists",value:s.length,tone:"gray"}
101),e.jsx(Ct,{label:"Total Contacts Across Lists",value:j.toLocaleString(),tone:"blue"}),e.jsx(Ct,{label:"Avg List Size",value:T.toLocaleString(),tone:"gray"})]}),i?e.jsx(tt,{label:"Loading listsâ¦"}):s.length===0?e.jsx(Ze,{title:"No lists yet",hint:"Create a list to organize contacts for targeted campaigns.",icon:e.jsx($e,{name:"list",className:"w-8 h-8"}),action:e.jsx(U,{variant:"primary",onClick:()=>{u(!0),f(""),y("")},children:"Create Your First List"})}):e.jsxs(e.Fragment,{children:[e.jsx(Fe,{children:"All Lists"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(D=>e.jsxs(_e,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[e.jsx("p",{className:"font-semibold text-gray-900 dark:text-gray-100 leading-snug",children:D.name}),e.jsxs(se,{tone:"blue",children:[(D.contact_count??0).toLocaleString()," contacts"]})]}),e.jsxs("p",{className:"text-xs text-gray-400 mb-4",children:["Created ",Ke(D.created_at,{month:"short",day:"numeric",year:"numeric"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Se,{to:"/dashboard/prospecting/searches",children:e.jsx(U,{variant:"ghost",size:"sm",children:"Add from Lead Gen"})}),e.jsx(U,{variant:"soft",size:"sm",disabled:A===D.id||(D.contact_count??0)===0,onClick:()=>F(D),children:A===D.id?"Exportingâ¦":"Export"}),e.jsx(U,{variant:"danger",size:"sm",onClick:()=>_(D),children:"Delete"})]})]},D.id))})]}),e.jsx(Et,{open:d,onClose:()=>{u(!1),y(""),f("")},title:"Create New List",footer:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(U,{variant:"ghost",onClick:()=>{u(!1),y(""),f("")},children:"Cancel"}),e.jsx(U,{variant:"primary",disabled:p||!x.trim(),onClick:S,type:"button",children:p?"Creatingâ¦":"Create"})]}),children:e.jsxs("form",{onSubmit:S,className:"space-y-4",children:[e.jsx(le,{label:"List Name",required:!0,error:b,children:e.jsx("input",{autoFocus:!0,t
101ype:"text",value:x,onChange:D=>y(D.target.value),placeholder:"e.g. Hot Leads Q2, Newsletter Subscribers",className:kw})}),e.jsx("button",{type:"submit",className:"sr-only","aria-hidden":"true"})]})}),k&&e.jsx(Nw,{message:k,onDone:()=>w(null)})]})}const Ft={primary:"#6366F1",violet:"#8B5CF6",emerald:"#10B981",sky:"#0EA5E9",amber:"#F59E0B",rose:"#F43F5E"},Uo={primary:"bg-gradient-to-r from-primary-500 to-primary-400",violet:"bg-gradient-to-r from-violet-500 to-violet-400",emerald:"bg-gradient-to-r from-emerald-500 to-emerald-400",sky:"bg-gradient-to-r from-sky-500 to-sky-400",amber:"bg-gradient-to-r from-amber-500 to-amber-400",rose:"bg-gradient-to-r from-rose-500 to-rose-400"},hp=[{key:"7",label:"7d"},{key:"30",label:"30d"},{key:"90",label:"90d"},{key:"all",label:"All"}],Sw={boomer:"Boomer",young_boomer:"Young Boomer",genx:"Gen X",gen_x:"Gen X",millennial:"Millennial",gen_z:"Gen Z",genz:"Gen Z"},Cw=s=>Sw[s]||s.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase()),Aw=s=>s.replace(/-/g," ").replace(/\b\w/g,l=>l.toUpperCase());function Ew(s){return s==="sent"?"green":s==="draft"?"gray":s==="scheduled"?"blue":s==="sending"?"amber":"gray"}function Tw(s,l=750){const[i,o]=h.useState(0),d=h.useRef(0);return h.useEffect(()=>{const u=d.current,x=performance.now();let y=0;const p=g=>{const b=Math.min(1,(g-x)/l),f=1-Math.pow(1-b,3),k=u+(s-u)*f;o(k),b<1?y=requestAnimationFrame(p):d.current=s};return y=requestAnimationFrame(p),()=>cancelAnimationFrame(y)},[s,l]),i}function Wl(){const[s,l]=h.useState(!1);return h.useEffect(()=>{const i=requestAnimationFrame(()=>l(!0));return()=>cancelAnimationFrame(i)},[]),s}function mf({trend:s}){if(!s)return null;const{delta_pct:l,cur:i,prev:o}=s;if(l===null)return i>0&&o===0?e.jsx("span",{className:"inline-flex items-center gap-0.5 text-[11px] font-medium text-emerald-600 dark:text-emerald-400",children:"New"}):null;if(l===0)return e.jsx("span",{className:"text-[11px] font-medium text-gray-400 dark:text-gray-500",children:"â"});const d=l>0;return e.jsxs("span",{className:`inline-flex items-center gap-0.5 text-[11px] font-semibold ${d?"text-emerald-600 dark:text-emerald-400":"text-rose-500 dark:text-rose-400"}`,title:`${i.toLocaleString()} this period vs ${o.toLocaleString()} previous`,children:[e.jsx("span",{className:"text-[9px]",children:d?"â²":"â¼"}),Math.abs(l),"%"]})}function St({label:s,value:l,trend:i,tone:o="gray",suffix:d="",featured:u=!1}){const x=Tw(l),y=Math.round(x).toLocaleString()+d,p=o==="green"?"text-emerald-600 dark:text-emerald-400":o==="blue"?"text-sky-600 dark:text-sky-400":o==="amber"?"text-amber-600 dark:text-amber-400":o==="violet"?"text-violet-600 dark:text-violet-400":"text-gray-900 dark:text-gray-100";return u?e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary-600 to-violet-600 dark:from-primary-700 dark:to-violet-700 shadow-md shadow-primary-900/20 p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent pointer-events-none"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex items-baseline justify-between",children:e.jsx("div",{className:"text-2xl font-semibold text-white tabular-nums",children:y})}),e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[e.jsx("div",{className:"text-xs text-primary-200",children:s}),e.jsx(mf,{trend:i})]})]})]}):e.jsxs("div",{className:"bg-white dark:bg-gray-800/80 rounded-2xl shadow-sm ring-1 ring-gray-200 dark:ring-gray-700/60 p-4 transition-shadow hover:shadow-md",children:[e.jsx("div",{className:`text-2xl font-semibold tabular-nums ${p}`,children:y}),e.jsxs("div",{className:"flex items-center justify-between mt-1 gap-2",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:s}),e.jsx(mf,{trend:i})]})]})}function xp({stages:s}){const l=Wl(),i=Math.max(1,...s.map(o=>o.value));return e.jsx("div",{className:"space-y-3",children:s.map((o,d)=>{const u=o.value/i*100,x=d>0?s[d-1].value:null,y=x&&x>0?Math.round(o.value/x*100):null;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs mb-1",children:[e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:o.label}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 tabular-nums",children:[o.value.toLocaleStr
101ing(),y!==null&&e.jsxs("span",{className:"ml-1.5 text-gray-400 dark:text-gray-500",children:[y,"% â"]})]})]}),e.jsx("div",{className:"h-8 rounded-lg bg-gray-100 dark:bg-gray-700/50 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-lg ${Uo[o.tone]||Uo.primary} transition-all duration-700 ease-out`,style:{width:l?`${Math.max(u,2)}%`:"0%",transitionDelay:`${d*80}ms`}})})]},o.label)})})}function Qo({segments:s,size:l=160,thickness:i=22}){const o=Wl(),d=s.reduce((p,g)=>p+g.value,0),u=(l-i)/2,x=2*Math.PI*u;let y=0;return d===0?e.jsx("div",{className:"flex items-center justify-center text-sm text-gray-400 dark:text-gray-500",style:{height:l},children:"No data yet"}):e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsxs("svg",{width:l,height:l,viewBox:`0 0 ${l} ${l}`,className:"-rotate-90 flex-shrink-0",children:[e.jsx("circle",{cx:l/2,cy:l/2,r:u,fill:"none",strokeWidth:i,className:"stroke-gray-100 dark:stroke-gray-700/60"}),s.map((p,g)=>{if(p.value===0)return null;const b=p.value/d*x,f=`${o?b:0} ${x}`,k=e.jsx("circle",{cx:l/2,cy:l/2,r:u,fill:"none",strokeWidth:i,stroke:p.color,strokeDasharray:f,strokeDashoffset:-y,strokeLinecap:"butt",style:{transition:"stroke-dasharray 800ms ease-out",transitionDelay:`${g*90}ms`}},g);return y+=b,k})]}),e.jsx("div",{className:"flex flex-col gap-2 min-w-0",children:s.map(p=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:p.color}}),e.jsx("span",{className:"text-gray-600 dark:text-gray-300 truncate",children:p.label}),e.jsxs("span",{className:"text-gray-900 dark:text-gray-100 font-medium tabular-nums ml-auto",children:[p.value.toLocaleString(),e.jsxs("span",{className:"text-gray-400 dark:text-gray-500 ml-1",children:[Math.round(p.value/d*100),"%"]})]})]},p.label))})]})}function Lo({items:s,tone:l="primary",emptyHint:i="No data yet."}){const o=Wl();if(!s.length)return e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:i});const d=Math.max(1,...s.map(u=>u.value));return e.jsx("div",{className:"space-y-2.5",children:s.map((u,x)=>{const y=u.value/d*100;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs mb-1",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-300 truncate mr-2",children:u.label}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 tabular-nums flex-shrink-0",children:[u.meta?e.jsx("span",{className:"text-gray-400 dark:text-gray-500 mr-1.5",children:u.meta}):null,u.value.toLocaleString()]})]}),e.jsx("div",{className:"h-2.5 rounded-full bg-gray-100 dark:bg-gray-700/50 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${Uo[l]||Uo.primary} transition-all duration-700 ease-out`,style:{width:o?`${Math.max(y,3)}%`:"0%",transitionDelay:`${x*60}ms`}})})]},u.label)})})}function $u({pct:s,label:l,sub:i,color:o}){const d=Wl(),u=96,x=9,y=(u-x)/2,p=2*Math.PI*y,g=Math.min(100,Math.max(0,s))/100*p;return e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsxs("div",{className:"relative",style:{width:u,height:u},children:[e.jsxs("svg",{width:u,height:u,viewBox:`0 0 ${u} ${u}`,className:"-rotate-90",children:[e.jsx("circle",{cx:u/2,cy:u/2,r:y,fill:"none",strokeWidth:x,className:"stroke-gray-100 dark:stroke-gray-700/60"}),e.jsx("circle",{cx:u/2,cy:u/2,r:y,fill:"none",strokeWidth:x,stroke:o,strokeLinecap:"round",strokeDasharray:`${d?g:0} ${p}`,style:{transition:"stroke-dasharray 900ms ease-out"}})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("span",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 tabular-nums",children:[s,"%"]})})]}),e.jsx("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-300 mt-2",children:l}),i&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500",children:i})]})}function gp({rows:s}){const l=Wl(),[i,o]=h.useState(null),d=Math.max(1,...s.map(u=>u.leads));return s.length===0?e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:"No data yet."}):e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex items-end gap-1 h-52",children:s.map((u,x)=>{const y=u.leads/d*100,p=u.viable/d*100,g=u.verified/d*100,b=i===x;return e.jsx("div",{className:"relative flex-1 flex flex-col items-center justify-end h-full",onMouseEnter:()=>o(x),onMouseLeave:()=>o(null),children:e.jsxs("div",{className:"relative w-full flex justify-center",style:{height:"100%"},children:[e.jsx("div",{className:`absolute bottom-0 w-full rounded-t bg-gradient-to-t from-primary-500/80 to-primary-400/70 dark:from-primary-500/70 dark:to-primary-400/60 transition-all duration-700 ease-out ${b?"opacity-100":"opacity-90"}`,style:{height:l?`${y}%`:"0%",minHeight:u.leads>0?"3px":"0",transitionDelay:`${x*25}ms`}}),e.jsx("div",{className:"absolute bottom-0 w-[55%] rounded-t bg-gradient-to-t from-emerald-500 to-emerald-400 transition-all duration-700 ease-out",style:{height:l?`${p}%`:"0%",minHeight:u.viable>0?"3px":"0",transitionDelay:`${x*25+120}ms`}}),u.verified>0&&e.jsx("div",{className:"absolute bottom-0 w-[28%] rounded-t bg-sky-500 transition-all duration-700 ease-out",style:{height:l?`${g}%`:"0%",minHeight:"3px",transitionDelay:`${x*25+200}ms`}})]})},u.day)})}),e.jsx("div",{className:"flex gap-1 mt-1",children:s.map((u,x)=>{const y=Math.ceil(s.length/7),p=x===0||x===s.length-1||x%y===0;return e.jsx("div",{className:"flex-1 text-center",children:p&&e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 leading-none",children:Ke(u.day,{month:"short",day:"numeric"})})},u.day)})}),i!==null&&e.jsxs("div",{className:"pointer-events-none absolute -top-2 left-1/2 -translate-x-1/2 -translate-y-full z-10 rounded-lg bg-gray-900 text-white text-xs px-3 py-2 shadow-lg whitespace-nowrap",children:[e.jsx("div",{className:"font-medium mb-0.5",children:Ke(s[i].day,{month:"short",day:"numeric",year:"numeric"})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm bg-primary-400"})," ",s[i].leads," leads"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm bg-emerald-400"})," ",s[i].viable," viable"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm bg-sky-4
10100"})," ",s[i].verified," verified"]})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-3 text-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-sm bg-primary-400"})," Leads"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-sm bg-emerald-400"})," Viable"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-sm bg-sky-400"})," Verified"]})]})]})}function Rw({value:s,onChange:l,loading:i}){return e.jsxs("div",{className:"inline-flex items-center rounded-full bg-gray-100 dark:bg-gray-800 p-0.5 ring-1 ring-gray-200 dark:ring-gray-700",children:[i&&e.jsx("span",{className:"ml-1 mr-0.5 w-3 h-3 rounded-full border-2 border-primary-400 border-t-transparent animate-spin","aria-label":"Loading"}),hp.map(o=>{const d=s===o.key;return e.jsx("button",{type:"button",onClick:()=>l(o.key),className:["px-3 min-h-11 min-w-11 rounded-full text-xs font-medium transition-colors duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",d?"bg-white dark:bg-gray-700 text-primary-700 dark:text-primary-300 shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"].join(" "),children:o.label},o.key)})]})}function zw({data:s,analytics:l,campaigns:i,rangeKey:o}){const d=l?.headline||{},u=l?.trends||{},x=l?.cost||{},y=l?.dimensions||{},p=l?.daily_funnel||[],g=(x.records_saved_by_cache||0)+(x.duplicates_removed||0)+(x.leads_filtered_before_enrichment||0),b=[{label:"Leads Found",value:d.leads_found??0,tone:"primary"},{label:"Viable Leads",value:d.viable_leads??0,tone:"violet"},{label:"Strong Matches",value:d.strong_matches??0,tone:"sky"},{label:"Verified Contacts",value:d.verified_contacts??0,tone:"emerald"},{label:"Saved to CRM",value:d.saved_leads??0,tone:"emerald"}],f=b.some(j=>j.value>0),k={};i.forEach(j=>{k[j.type]=(k[j.type]||0)+1});const w=[{label:"Email",value:k.email||0,color:Ft.sky},{label:"Social Proof",value:k.social_proof||0,color:Ft.emerald},{label:"SMS",value:k.sms||0,color:Ft.amber},{label:"DarkCall",value:k.darkcall||0,color:Ft.violet}].filter(j=>j.value>0),N=(y.by_industry||[]).map(j=>({label:j.label,value:j.n}));return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsx(St,{label:"Leads Found",value:d.leads_found??0,trend:u.leads_found,featured:!0}),e.jsx(St,{label:"Strong Matches",value:d.strong_matches??0,tone:"green"}),e.jsx(St,{label:"Verified Contacts",value:d.verified_contacts??0,trend:u.verified_contacts,tone:"green"}),e.jsx(St,{label:"Saved to CRM",value:d.saved_leads??0,trend:u.saved_leads,tone:"blue"}),e.jsx(St,{label:"Total Contacts",value:s.stats.contacts}),e.jsx(St,{label:"Active Campaigns",value:s.stats.campaigns}),e.jsx(St,{label:"Total Orders",value:s.stats.orders}),e.jsx(St,{label:"Conversations",value:s.stats.active_conversations,tone:"amber"})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs(_e,{children:[e.jsx(Fe,{children:"Lead acquisition funnel"}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mb-4 -mt-2",children:"Conversion from discovery through to CRM"}),f?e.jsx(xp,{stages:b}):e.jsx(Ze,{title:"No lead data yet",hint:"Run a search to populate the funnel.",icon:e.jsx($e,{name:"search",className:"w-8 h-8"})})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"Campaign mix"}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mb-4 -mt-2",children:"Breakdown by campaign channel"}),e.jsx(Qo,{segments:w})]})]}),e.jsxs(_e,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(Fe,{children:"Lead pipeline over time"}),e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:l?.window?.label})]}
101),e.jsx(gp,{rows:p})]}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[e.jsxs(_e,{className:"lg:col-span-2",children:[e.jsx(Fe,{children:"Top industries"}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mb-4 -mt-2",children:"Where your matched companies cluster"}),e.jsx(Lo,{items:N,tone:"violet",emptyHint:"Run a search to see industry mix."})]}),e.jsxs(_e,{className:"flex flex-col items-center justify-center text-center bg-gradient-to-br from-emerald-50 to-teal-50/40 dark:from-emerald-950/30 dark:to-teal-950/10 ring-emerald-200 dark:ring-emerald-800/40",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-emerald-100 dark:bg-emerald-900/40 flex items-center justify-center text-emerald-600 dark:text-emerald-400 mb-3",children:e.jsx($e,{name:"currency",className:"w-6 h-6"})}),e.jsx("p",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-400 uppercase tracking-wide mb-1",children:"API Credits Saved"}),e.jsx("p",{className:"text-4xl font-semibold text-emerald-600 dark:text-emerald-400 tabular-nums",children:g.toLocaleString()}),e.jsx("p",{className:"text-xs text-emerald-700/70 dark:text-emerald-400/70 mt-2",children:"records filtered before billing"})]})]})]},o)}function Lw({analytics:s,rangeKey:l}){if(!s)return e.jsx(Ze,{title:"Start running lead searches to see analytics here.",hint:"Head to Lead Generation to run your first search.",icon:e.jsx($e,{name:"search",className:"w-8 h-8"}),action:e.jsx(Se,{to:"/dashboard/prospecting/searches",children:e.jsx(U,{variant:"primary",children:"Go to Lead Generation"})})});const i=s.headline||{},o=s.trends||{},d=s.rates||{},u=s.dimensions||{},x=s.contactability||{},y=s.daily_funnel||[],p=[{label:"Leads Found",value:i.leads_found??0,tone:"primary"},{label:"Viable Leads",value:i.viable_leads??0,tone:"violet"},{label:"Strong Matches",value:i.strong_matches??0,tone:"sky"},{label:"Verified Contacts",value:i.verified_contacts??0,tone:"emerald"},{label:"Saved to CRM",value:i.saved_leads??0,tone:"emerald"},{label:"Exported",value:i.exported_leads??0,tone:"amber"}],g=p.some(N=>N.value>0),b=(u.by_generation||[]).map((N,j)=>({label:Cw(N.label),value:N.n,color:[Ft.primary,Ft.emerald,Ft.amber,Ft.sky,Ft.rose][j%5]})),f=(u.by_employee_band||[]).slice().sort((N,j)=>j.n-N.n).map(N=>({label:`${N.label} employees`,value:N.n})),k=(u.by_industry||[]).map(N=>({label:N.label,value:N.n})),w=(u.by_location||[]).map(N=>({label:N.label,value:N.n}));return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx(Fe,{children:"Search & lead volume"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsx(St,{label:"Searches Run",value:i.searches_run??0,trend:o.searches_run}),e.jsx(St,{label:"Leads Found",value:i.leads_found??0,trend:o.leads_found}),e.jsx(St,{label:"Viable Leads",value:i.viable_leads??0,trend:o.viable_leads,tone:"blue"}),e.jsx(St,{label:"Strong Matches",value:i.strong_matches??0,tone:"green"})]})]}),e.jsxs("div",{children:[e.jsx(Fe,{children:"Pipeline efficiency"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsx(St,{label:"Viable Rate",value:d.viable_rate??0,suffix:"%",tone:"green"}),e.jsx(St,{label:"Duplicates Filtered",value:d.dedup_rate??0,suffix:"%",tone:"amber"}),e.jsx(St,{label:"Verified Rate",value:d.verified_rate??0,suffix:"%",tone:"green"}),e.jsx(St,{label:"Enrichment Success",value:d.enrichment_success_pct??0,suffix:"%",tone:"blue"})]})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs(_e,{children:[e.jsx(Fe,{children:"Conversion funnel"}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mb-4 -mt-2",children:"Stage-to-stage conversion across the workflow"}),g?e.jsx(xp,{stages:p}):e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:"No data yet."})]}),e.jsxs(_e,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(Fe,{children:"Pipeline over time"}),e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:s?.window?.label})]}),e.jsx(gp,{rows:y})]})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"Contactability"}),e.jsxs("p",{className:"text-xs text-gray-400 dark:text-gray-500 mb-4 -mt-2",children:["How reachable your matched leads are (",(x.total??0).toLocaleStr
101ing()," leads)"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 max-w-md mx-auto",children:[e.jsx($u,{pct:x.email_pct??0,label:"Email",sub:`${(x.email??0).toLocaleString()} leads`,color:Ft.emerald}),e.jsx($u,{pct:x.phone_pct??0,label:"Phone",sub:`${(x.phone??0).toLocaleString()} leads`,color:Ft.sky}),e.jsx($u,{pct:x.linkedin_pct??0,label:"LinkedIn",sub:`${(x.linkedin??0).toLocaleString()} leads`,color:Ft.violet})]})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs(_e,{children:[e.jsx(Fe,{children:"By industry"}),e.jsx(Lo,{items:k,tone:"violet",emptyHint:"No industry data yet."})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"By owner generation"}),b.length?e.jsx(Qo,{segments:b}):e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:"No generation data yet."})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"By company size"}),e.jsx(Lo,{items:f,tone:"sky",emptyHint:"No size data yet."})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"By location"}),e.jsx(Lo,{items:w,tone:"amber",emptyHint:"No location data yet."})]})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs(_e,{children:[e.jsx(Fe,{children:"Best-performing presets"}),(s.best_presets||[]).length===0?e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:"No preset runs yet."}):e.jsx("div",{className:"space-y-2",children:s.best_presets.map(N=>e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-200 truncate mr-2",children:Aw(N.preset_key)}),e.jsxs("span",{className:"flex gap-1.5 flex-shrink-0",children:[e.jsxs(se,{tone:"green",children:[N.strong," strong"]}),e.jsxs(se,{tone:"blue",children:[N.viable," viable"]}),e.jsxs(se,{tone:"gray",children:[N.runs," runs"]})]})]},N.preset_key))})]}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"Source performance"}),(s.source_performance||[]).length===0?e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:"No data yet."}):e.jsx("div",{className:"space-y-2",children:s.source_performance.map(N=>e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-200 truncate mr-2 capitalize",children:N.source}),e.jsxs("span",{className:"flex gap-1.5 flex-shrink-0",children:[e.jsxs(se,{tone:"gray",children:[N.leads," leads"]}),e.jsxs(se,{tone:"green",children:[N.verified," verified"]})]})]},N.source))})]})]})]},l)}function Mw({campaigns:s}){const l={};s.forEach(o=>{l[o.type]=(l[o.type]||0)+1});const i=[{label:"Email",value:l.email||0,color:Ft.sky},{label:"Social Proof",value:l.social_proof||0,color:Ft.emerald},{label:"SMS",value:l.sms||0,color:Ft.amber},{label:"DarkCall",value:l.darkcall||0,color:Ft.violet}].filter(o=>o.value>0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsx(St,{label:"Total Campaigns",value:s.length,featured:!0}),e.jsx(St,{label:"Email",value:l.email??0,tone:"blue"}),e.jsx(St,{label:"Social",value:l.social_proof??0,tone:"green"}),e.jsx(St,{label:"SMS",value:l.sms??0,tone:"amber"})]}),s.length>0&&e.jsxs(_e,{children:[e.jsx(Fe,{children:"Channel breakdown"}),e.jsx(Qo,{segments:i})]}),e.jsxs(Ne,{tone:"blue",children:["Connect email and social platforms in"," ",e.jsx(Se,{to:"/dashboard/integrations",className:"underline font-medium",children:"Integrations"})," ","to see delivery and open rate data for each campaign."]}),s.length===0?e.jsx(Ze,{title:"No campaigns yet",hint:"Create your first campaign to start tracking performance.",icon:e.jsx($e,{name:"campaign",className:"w-8 h-8"}),action:e.jsx(Se,{to:"/dashboard/campaigns",children:e.jsx(U,{variant:"primary",children:"Go to Campaigns"})})}):e.jsx("div",{className:"bg-white dark:bg-gray-800/80 rounded-2xl shadow-sm ring-1 ring-gray-100 dark:ring-gray-700 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/60 border-b border-gray-100 dark:border-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Name"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Created"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Status"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:s.map(o=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/40",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-gray-900 dark:text-gray-100",children:o.name}),e.jsx("td",{className:"px-4 py-3 text-gray-500 dark:text-gray-400 capitalize",children:o.type}),e.jsx("td",{className:"px-4 py-3 text-gray-400 dark:text-gray-500",children:Ke(o.created_at,{month:"short",day:"numeric",year:"numeric"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(se,{tone:Ew(o.status),children:o.status})})]},o.id))})]})})]})}function Ow({analytics:s,rangeKey:l}){if(!s)return e.jsx(Ze,{title:"Start running lead searches to see analytics here.",hint:"API usage data appears after your first search run.",icon:e.jsx($e,{name:"currency",className:"w-8 h-8"}),action:e.jsx(Se,{to:"/dashboard/prospecting/searches",children:e.jsx(U,{variant:"primary",children:"Go to Lead Generation"})})});const i=s.cost||{},o=i.api_records_used||0,d=(i.records_saved_by_cache||0)+(i.duplicates_removed||0)+(i.leads_filtered_before_enrichment||0),u=[{label:"From cache",value:i.records_saved_by_cache||0,color:Ft.emerald},{label:"Duplicates removed",value:i.duplicates_removed||0,color:Ft.sky},{label:"Filtered pre-enrich",value:i.leads_filtered_before_enrichment||0,color:Ft.violet}
101,{label:"Billed (API)",value:o,color:Ft.amber}].filter(x=>x.value>0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsx(St,{label:"API Records Used",value:o,tone:"amber"}),e.jsx(St,{label:"Records Saved by Cache",value:i.records_saved_by_cache??0,tone:"green"}),e.jsx(St,{label:"Duplicates Removed",value:i.duplicates_removed??0,tone:"green"}),e.jsx(St,{label:"Filtered Before Enrichment",value:i.leads_filtered_before_enrichment??0,tone:"green"})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs(_e,{children:[e.jsx(Fe,{children:"Records: billed vs. saved"}),e.jsx(Qo,{segments:u})]}),e.jsxs(_e,{className:"flex flex-col items-center justify-center text-center bg-gradient-to-br from-emerald-50 to-teal-50/40 dark:from-emerald-950/30 dark:to-teal-950/10 ring-emerald-200 dark:ring-emerald-800/40",children:[e.jsx("p",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-400 uppercase tracking-wide mb-1",children:"Total credits saved"}),e.jsx("p",{className:"text-5xl font-semibold text-emerald-600 dark:text-emerald-400 tabular-nums",children:d.toLocaleString()}),e.jsx("p",{className:"text-sm text-emerald-700/70 dark:text-emerald-400/70 mt-2",children:"records not billed to paid API endpoints"})]})]}),e.jsx(Ne,{tone:"green",children:"Fantize filters and caches aggressively before hitting paid API endpoints, saving you money. Duplicates, cache hits, and pre-enrichment filters never reach billable quota."})]},l)}const fp=[{key:"overview",label:"Overview"},{key:"leads",label:"Lead Workflow"},{key:"campaigns",label:"Campaigns"},{key:"costs",label:"API & Costs"}],hf=new Set(fp.map(s=>s.key)),$w=new Set(hp.map(s=>s.key));function Dw(){const[s,l]=$r(),i=s.get("tab"),o=s.get("range"),[d,u]=h.useState(i&&hf.has(i)?i:"overview"),[x,y]=h.useState(o&&$w.has(o)?o:"all"),[p,g]=h.useState(null),[b,f]=h.useState(null),[k,w]=h.useState([]),[N,j]=h.useState(!0),[T,S]=h.useState(!1);h.useEffect(()=>{},[]),h.useEffect(()=>{const he=s.get("tab");he&&hf.has(he)&&he!==d&&u(he)},[s]);function _(he){u(he);const X=new URLSearchParams(s);he==="overview"?X.delete("tab"):X.set("tab",he),l(X,{replace:!0})}function z(he){y(he);const X=new URLSearchParams(s);he==="all"?X.delete("range"):X.set("range",he),l(X,{replace:!0})}h.useEffect(()=>{Promise.all([pf.get(),xa.list().catch(()=>({campaigns:[]}))]).then(([he,X])=>{g(he),w(X.campaigns)}).catch(()=>{}).finally(()=>j(!1))},[]),h.useEffect(()=>{S(!0);const he=x==="all"?void 0:x;Me.analytics(he).then(X=>f(X)).catch(()=>f(null)).finally(()=>S(!1))},[x]);const A=`${x}`;if(N)return e.jsx(tt,{label:"Loading analyticsâ¦"});if(!p)return e.jsxs("div",{className:"max-w-5xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Analytics",subtitle:"Cross-app performance overview."}),e.jsx(Ze,{title:"Could not load dashboard data.",hint:"Check your connection and try refreshing.",icon:e.jsx($e,{name:"analytics",className:"w-8 h-8"})})]});const L=()=>new Date().toISOString().slice(0,10);function F(){const he=b?.headline||{},X=b?.cost||{};if(d==="overview"){const I=[["Metric","Value"],["Window",b?.window?.label||"All time"],["Total Contacts",p.stats.contacts],["Total Campaigns",p.stats.campaigns],["Total Orders",p.stats.orders],["Active Conversations",p.stats.active_conversations],["Leads Found",he.leads_found??0],["Strong Matches",he.strong_matches??0],["Verified Contacts",he.verified_contacts??0],["Saved to CRM",he.saved_leads??0]];Ua(`fantize-analytics-overview-${L()}.csv`,I)}else if(d==="leads"){const I=b?.dimensions||{},q=[["Metric","Value"],["Window",b?.window?.label||"All time"],["Searches Run",he.searches_run??0],["Leads Found",he.leads_found??0],["Viable Leads",he.viable_leads??0],["Strong Matches",he.strong_matches??0],["Verified Contacts",he.verified_contacts??0],["Verified Rate (%)",he.verified_pct??0],["Saved to CRM",he.saved_leads??0],["Exported",he.exported_leads??0],[],["Industry","Leads"],...(I.by_industry||[]).map(be=>[be.label,be.n]),[],["Day","Leads","Viable","Verified"],...(b?.daily_funnel||[]).map(be=>[be.day,be.leads,be.viable,be.verified])];Ua(`fantize-analytics-leads-${L()}.csv`,q)}else if(d==="campaigns"){const I=[["Name","Type","Status","List","List Size","Subject","Sent","Created"],...k.map(q=>[q.name,q.type,q.status,q.list_name||"",q.list_size??"",q.subject||"",q.sent_at?Ke(q.sent_at):"",Ke(q.created_at)])];Ua(`fantize-analytics-campaigns-${L()}.csv`,I)}else{const I=X.api_records_used||0,q=[["Metric","Value"],["Window",b?.window?.label||"All time"],["API Records Used (billed)",I],["Records Saved by Cache",X.records_saved_by_cache??0],["Duplicates Removed",X.duplicates_removed??0],["Filtered Before Enrichment",X.leads_filtered_before_enrichment??0],["Total Credits Saved",(X.records_saved_by_cache||0)+(X.duplicates_removed||0)+(X.leads_filtered_before_enrichment||0)]];Ua(`fantize-analytics-costs-${L()}.csv`,q)}}const D=d==="campaigns"?k.length>0:d==="overview"?!0:!!b,te=d!=="campaigns",pe=e.jsxs("div",{className:"flex items-center gap-2",children:[te&&e.jsx(Rw,{value:x,onChange:z,loading:T}),e.jsx(U,{variant:"soft",size:"sm",onClick:F,disabled:!D,children:"Export CSV"})]});return e.jsxs("div",{className:"max-w-5xl mx-auto pb-12",children:[e.jsx(Xe,{title:"Analytics",subtitle:"Reporting across leads, campaigns, contacts and API cost.",secondary:pe}),e.jsx(dn,{label:"Analytics sections",items:fp,active:d,onChange:_,className:"mb-6"}),d==="overview"&&e.jsx(zw,{data:p,analytics:b,campaigns:k,rangeKey:A}),d==="leads"&&e.jsx(Lw,{analytics:b,rangeKey:A}
101),d==="campaigns"&&e.jsx(Mw,{campaigns:k}),d==="costs"&&e.jsx(Ow,{analytics:b,rangeKey:A})]})}function Hw(){const{theme:s,setTheme:l}=Ub(),i=[{value:"system",label:"System",icon:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0H3"})})},{value:"light",label:"Light",icon:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 3v2.25m6.364.386l-1.591 1.591M21 12h-2.25m-.386 6.364l-1.591-1.591M12 18.75V21m-4.773-4.227l-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z"})})},{value:"dark",label:"Dark",icon:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.752 15.002A9.718 9.718 0 0118 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 003 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 009.002-5.998z"})})}];return e.jsx("div",{className:"flex items-center gap-0.5 p-1 bg-gray-100 dark:bg-gray-800 rounded-xl ring-1 ring-gray-200 dark:ring-gray-700",children:i.map(o=>e.jsx("button",{onClick:()=>l(o.value),title:o.label,"aria-label":"Set theme: "+o.label,"aria-pressed":s===o.value,className:`flex items-center justify-center w-11 h-11 rounded-lg text-xs transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 ${s===o.value?"bg-gradient-to-b from-white to-gray-50 dark:from-primary-900/60 dark:to-primary-950/80 text-primary-600 dark:text-primary-400 shadow-sm ring-1 ring-primary-200 dark:ring-primary-800/60":"text-gray-400 dark:text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-white/60 dark:hover:bg-gray-700/60"}`,children:o.icon},o.value))})}function qw(){const{account:s,logout:l,isAdmin:i}=zt(),o=Ja(),d=Ya(),[u,x]=h.useState([]),[y,p]=h.useState(0),[g,b]=h.useState(0),[f,k]=h.useState([]),[w,N]=h.useState(!0),[j,T]=h.useState(!0);h.useEffect(()=>{if(!i){N(!1),T(!1);return}yf.list({limit:5}).then(A=>{x(A.orders),p(A.revenue),b(A.total)}).catch(()=>{}).finally(()=>N(!1)),bf.list("active").then(A=>k(A.conversations)).catch(()=>{}).finally(()=>T(!1))},[i]);const S=()=>{l(),d("/")},_=(s?.name?.[0]??"?").toUpperCase(),z=s?.created_at?Ke(s.created_at,{month:"long",year:"numeric"}):null;return e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(Xe,{title:"Account & Preferences",subtitle:"Your profile, appearance and account."}),e.jsxs(_e,{className:"mb-6",children:[e.jsx(Fe,{children:"Profile"}),e.jsxs("div",{className:"flex items-center gap-5 mt-3",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-gradient-to-br from-primary-500 to-violet-600 flex items-center justify-center text-2xl font-bold text-white shadow-lg shadow-primary-900/20 flex-shrink-0",children:_}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 truncate",children:s?.name}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate",children:s?.email}),z&&e.jsxs("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:["Member since ",z]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx(se,{tone:i?"green":"blue",children:i?"Administrator":"Marketing"}),s?.plan&&e.jsx(se,{tone:"gray",children:s.plan})]})]}),o.canPreview&&e.jsxs("div",{className:"mt-4 border-t border-gray-100 dark:border-gray-700/60 pt-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Marketing preview"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"See exactly what a Marketing user sees. Read-only; your own role is unchanged."})]}),o.active?e.jsx(U,{variant:"soft",size:"sm",onClick:o.exit,children:"Exit preview"}):e.jsx(U,{variant:"soft",size:"sm",onClick:o.enter,children:"View as Marketing (preview)"})]})]}),e.jsx(Ml,{className:"my-6"}),e.jsxs(_e,{className:"mb-6",children:[e.jsx(Fe,{children:"Appearance"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-4",children:"Choose your preferred color theme. System follows your device setting."}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Hw,{}),e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Preference saved automatically"})]})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx(Ml,{className:"my-6"}),e.jsxs(_e,{className:"mb-6",children:[e.jsx(Fe,{action:e.jsx(Se,{to:"/dashboard/orders",children:e.jsx(U,{variant:"ghost",size:"sm",children:"View all orders â"})}),children:"Orders"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-4",children:"Revenue and order history from your campaigns."}),w?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(A=>e.jsx("div",{className:"h-12 bg-gray-100 dark:bg-gray-700 animate-pulse rounded-xl"},A))}):u.length===0?e.jsx("div",{className:"text-center py-6 rounded-xl bg-gray-50 dark:bg-gray-800/50",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No orders yet. Orders are recorded when contacts make purchases through your campaigns."})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs("div",{className:"rounded-xl bg-gray-50 dark:bg-gray-800/50 p-3 text-center",children:[e.jsx("div",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:g}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Total Orders"})]}),e.jsxs("div",{className:"rounded-xl bg-emerald-50 dark:bg-emerald-950/30 p-3 text-center",children:[e.jsxs("div",{className:"text-xl font-semibold text-emerald-700 dark:text-emerald-300",children:["$",y.toLocaleStr
101ing(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),e.jsx("div",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Revenue"})]}),e.jsxs("div",{className:"rounded-xl bg-sky-50 dark:bg-sky-950/30 p-3 text-center",children:[e.jsx("div",{className:"text-xl font-semibold text-sky-700 dark:text-sky-300",children:g>0?`$${(y/g).toFixed(2)}`:"â"}),e.jsx("div",{className:"text-xs text-sky-600 dark:text-sky-400",children:"Avg Order"})]})]}),e.jsx("div",{className:"space-y-2",children:u.slice(0,3).map(A=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 rounded-xl bg-gray-50 dark:bg-gray-800/50 text-sm",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 truncate",children:[A.first_name,A.last_name].filter(Boolean).join(" ")||A.email}),A.product_or_service&&e.jsxs("span",{className:"text-gray-400 dark:text-gray-500 ml-2 text-xs",children:["· ",A.product_or_service]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:["$",(A.amount||0).toFixed(2)]}),e.jsx(Bn,{status:A.status})]})]},A.id))})]})]}),e.jsx(Ml,{className:"my-6"}),e.jsxs(_e,{className:"mb-6",children:[e.jsx(Fe,{action:e.jsx(Se,{to:"/dashboard/conversations",children:e.jsx(U,{variant:"ghost",size:"sm",children:"View all â"})}),children:"Conversations"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-4",children:"Active fan engagement conversations from your campaigns."}),j?e.jsx("div",{className:"space-y-2",children:[1,2].map(A=>e.jsx("div",{className:"h-12 bg-gray-100 dark:bg-gray-700 animate-pulse rounded-xl"},A))}):f.length===0?e.jsx("div",{className:"text-center py-6 rounded-xl bg-gray-50 dark:bg-gray-800/50",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No active conversations. Conversations start automatically after campaign interactions."})}):e.jsxs("div",{className:"space-y-2",children:[f.slice(0,4).map(A=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-xl bg-gray-50 dark:bg-gray-800/50 text-sm",children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${A.status==="active"?"bg-emerald-500":A.status==="paused"?"bg-amber-400":"bg-gray-300"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 truncate",children:[A.first_name,A.last_name].filter(Boolean).join(" ")||A.email}),A.channel&&e.jsxs("span",{className:"text-gray-400 dark:text-gray-500 ml-2 text-xs capitalize",children:["· ",A.channel]})]}),e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:[A.message_count," msg",A.message_count!==1?"s":""]})]},A.id)),f.length>4&&e.jsxs("p",{className:"text-xs text-center text-gray-400 dark:text-gray-500 pt-1",children:["+",f.length-4," more active conversations"]})]})]})]}),e.jsx(Ml,{className:"my-6"}),e.jsxs(_e,{className:"mb-6",children:[e.jsx(Fe,{children:"Plan & Billing"}),e.jsxs("div",{className:"flex items-center justify-between gap-4 mt-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:s?.plan?`${s.plan} Plan`:"Free Trial"}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5",children:s?.plan?"Manage your subscription and billing details.":"14-day trial · No credit card required"})]}),e.jsx(Se,{to:"/pricing",children:e.jsx(U,{variant:"primary",size:"sm",children:"Upgrade Plan"})})]})]}),e.jsx(Ml,{className:"my-6"}),e.jsxs(_e,{children:[e.jsx(Fe,{children:"Account"}),e.jsxs("div",{className:"flex items-center justify-between gap-4 mt-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Sign Out"}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5",children:"Sign out of your Fantize account on this device."})]}),e.jsx(U,{variant:"danger",size:"sm",onClick:S,children:"Sign Out"})]})]})]})}function Bw(){return h.useEffect(()=>{document.title="Page not found | Fantize"},[]),e.jsxs("div",{className:"min-h-screen bg-slate-50 dark:bg-[#0C0E1A]",children:[e.jsx("header",{className:"border-b border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900",children:e.jsx("div",{className:"mx-auto max-w-4xl px-4 py-3",children:e.jsx(Se,{to:"/","aria-label":"Fantize home",className:"inline-flex min-h-11 items-center rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:e.jsx(cn,{size:"lg"})})})}),e.jsxs("main",{id:"main",className:"mx-auto max-w-4xl px-4 py-16",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-gray-500",children:"Page not found"}),e.jsx("h1",{className:"mt-2 font-display text-3xl font-semibold text-gray-900 dark:text-gray-100",children:"That page does not exist"}),e.jsx("p",{className:"mt-2 max-w-prose text-sm text-gray-600 dark:text-gray-300",children:"The address may have changed. Pages that moved in the current version of Fantize redirect automatically, so this address was never part of the application."}),e.jsxs("div",{className:"mt-6 flex flex-wrap gap-3",children:[e.jsx(Se,{to:"/dashboard",className:"inline-flex min-h-11 items-center rounded-xl bg-gradient-to-b from-primary-500 to-primary-600 px-5 text-sm font-medium text-white shadow-sm hover:from-primary-600 hover:to-primary-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2",children:"Go to Fantize"}),e.jsx(Se,{to:"/dashboard/help",className:"inline-flex min-h-11 items-center rounded-xl bg-white px-5 text-sm font-medium text-gray-700 ring-1 ring-gray-200 hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-200 dark:ring-gray-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500",children:"Help"})]})]})]})}const Uw=()=>e.jsx("div",{className:"max-w-4xl mx-auto py-12 px-4",children:e.jsxs("div",{className:"prose dark:prose-invert max-w-none",children:[e.jsx("h1",{className:"text-4xl font-bold mb-4",children:"Privacy Policy"}),e.jsx("p",{className:"text-gray-500 mb-8",children:"Last updated: March 15, 2026"}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"Introduction"}),e.jsx("p",{className:"mb-4",children:"At Fantize, we take your privacy seriously. This Privacy Policy explains how we
101collect, use, disclose, and safeguard your information when you use our services. If you do not agree with the terms of this privacy policy, please do not access the services."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"1. Information We Collect"}),e.jsx("h3",{className:"text-xl font-semibold mb-3",children:"Personal Information"}),e.jsx("p",{className:"mb-4",children:"We may collect personal information that you voluntarily provide to us when you:"}),e.jsxs("ul",{className:"list-disc pl-6 mb-4 space-y-2",children:[e.jsx("li",{children:"Register for an account"}),e.jsx("li",{children:"Use our services"}),e.jsx("li",{children:"Contact us for support"})]}),e.jsx("p",{className:"mb-4",children:"This information may include name, email address, and other contact information."}),e.jsx("h3",{className:"text-xl font-semibold mb-3",children:"Automatically Collected Information"}),e.jsx("p",{className:"mb-4",children:"When you use our services, we may automatically collect log and usage data, device information, and cookies."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"2. How We Use Your Information"}),e.jsx("p",{className:"mb-4",children:"We may use the information we collect to:"}),e.jsxs("ul",{className:"list-disc pl-6 mb-4 space-y-2",children:[e.jsx("li",{children:"Provide, operate, and maintain our services"}),e.jsx("li",{children:"Process your transactions and manage your account"}),e.jsx("li",{children:"Send you technical notices, updates, and support messages"}),e.jsx("li",{children:"Monitor and analyze trends and usage"}),e.jsx("li",{children:"Detect, prevent, and address technical issues"}),e.jsx("li",{children:"Comply with legal obligations"})]})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"3. How We Share Your Information"}),e.jsx("p",{className:"mb-4",children:"Fantize may not sell your personal information. By using our services, you acknowledge and consent to the sharing of your data as necessary for Fantize to fulfill its functions. This includes sharing with legal counsel, regulatory authorities, service providers, and third parties as required."}),e.jsx("p",{className:"mb-4",children:"Fantize may not require all recipients of data to enter into separate confidentiality agreements where the nature of the engagement or legal obligation may not require it."})]}),e.jsxs("section",{id:"data-security",className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"4. Data Security"}),e.jsx("p",{className:"mb-4",children:"Fantize may employ commercially reasonable security measures at its discretion to protect information against unauthorized access, alteration, disclosure, or destruction. No method of transmission over the Internet or electronic storage is 100% secure. Fantize may not guarantee absolute security and assumes no liability for unauthorized access resulting from circumstances beyond its reasonable control."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"5. Data Retention"}),e.jsx("p",{className:"mb-4",children:"Fantize may retain your personal information for as long as necessary to fulfill the purposes outlined in this Privacy Policy, or as required or permitted by law."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"6. Your Privacy Rights"}),e.jsx("p",{className:"mb-4",children:"Depending on your location, you may have rights regarding your personal information including access, correction, deletion, portability, and opt-out of marketing communications."}),e.jsx("p",{className:"mb-4",children:"To exercise these rights, contact us at [email protected]. Fantize may respond to such requests at its discretion and in accordance with applicable law."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"7.
101Cookies"}),e.jsx("p",{className:"mb-4",children:"Fantize may use cookies and similar tracking technologies. You can instruct your browser to refuse all cookies, but some portions of our services may not function properly without them."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"8. Children's Privacy"}),e.jsx("p",{className:"mb-4",children:"Our services are not intended for individuals under the age of 18. We do not knowingly collect personal information from children under 18."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"9. Changes to This Privacy Policy"}),e.jsx("p",{className:"mb-4",children:"Fantize may update this Privacy Policy at any time at its sole discretion. Changes are effective immediately upon posting. Continued use of the services after changes constitutes acceptance."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"10. Contact Us"}),e.jsx("p",{className:"mb-4",children:"If you have any questions about this Privacy Policy, please contact us:"}),e.jsxs("ul",{className:"list-none space-y-1",children:[e.jsx("li",{children:"Email: [email protected]"}),e.jsx("li",{children:"Address: 1 Lincoln Street, Boston, MA 02111"}),e.jsx("li",{children:"Phone: 1-650-276-3200"}),e.jsx("li",{children:"Legal Counsel: CodeLaw LLC"})]})]})]})}),Fw=()=>e.jsx("div",{className:"max-w-4xl mx-auto py-12 px-4",children:e.jsxs("div",{className:"prose dark:prose-invert max-w-none",children:[e.jsx("h1",{className:"text-4xl font-bold mb-4",children:"Terms of Service"}),e.jsx("p",{className:"text-gray-500 mb-8",children:"Last updated: March 15, 2026"}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"1. Agreement to Terms"}),e.jsx("p",{className:"mb-4",children:"By accessing or using Fantize's services, you agree to be bound by these Terms of Service and all applicable laws and regulations. If you do not agree with any of these terms, you are prohibited from using or accessing our services."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"2. Nature of Services"}),e.jsx("p",{className:"mb-4",children:"Fantize is an AI-powered marketing and audience platform. Fantize operates pursuant to contractual rights and provides technology, infrastructure, and administrative mechanisms to its users."}),e.jsx("p",{className:"mb-4",children:"Fantize may not provide investment, legal, tax, or professional advice. Fantize may not guarantee the accuracy, completeness, or timeliness of any information provided through the services. Where outcomes affect third-party systems or data, those outcomes arise from user actions, contractual rights, or third-party processes â not from Fantize exercising control over those systems."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"3. Use License"}),e.jsx("p",{className:"mb-4",children:"Fantize may grant you a personal, non-exclusive, non-transferable, limited license to access and use the services, subject to the terms of this agreement."}),e.jsx("p",{className:"mb-4",children:"You may not:"}),e.jsxs("ul",{className:"list-disc pl-6 mb-4 space-y-2",children:[e.jsx("li",{children:"Modify or copy the materials or services"}),e.jsx("li",{children:"Use the materials for any commercial purpose without authorization"}),e.jsx("li",{children:"Attempt to decompile or reverse engineer any software contained in our services"}),e.jsx("li",{children:"Remove any copyright or proprietary notations from the materials"})]})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"4. Account Registration"}),e.jsx("p",{className:"mb-4",children:"To access certain features of our services, you must register for an account. You agree to provide accurate, current, and complete information and to maintain the accuracy of such information."}),e.jsx("p",{className:"mb-4",children:"You are responsible for safeguarding your password and for all activities that occur under your account."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"5. User Data and Privacy"}),e.jsx("p",{className:"mb-4",children:"Your use of our services is also governed by our Privacy Policy. You retain all rights to your personal data. By using Fantize's services, you grant Fantize a non-exclusive, worldwide license to use data generated through your use of the platform for the purposes of providing, improving, and protecting our services, and for compliance with legal and regulatory obligations."}),e.jsx("p",{className:"mb-4",children:"Fantize may share data with service providers, legal counsel, regulatory authorities, and third parties as necessary to fulfill its functions. Fantize may not guarantee that all third parties receiving data will be bound by confidentiality agreements."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"6. Payment Terms"}),e.jsx("p",{className:"mb-4",children:"If you subscribe to a paid plan, you agree to pay all fees associated with your subscription. All fees are non-refundable except as required by law."}),e.jsx("p",{className:"mb-4",children:"Fantize may change pricing at any time at its sole discretion. Continued use of the services after a pricing change constitutes acceptance of the new pricing."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"7. Prohibited Uses"}),e.jsx("p",{className:"mb-4",children:"You may use our services only for lawful purposes and in accordance with these Terms. You agree not to use our services:"}),e.jsxs("ul",{className:"list-disc pl-6 mb-4 space-y-2",children:[e.jsx("li",{children:"In any way that violates any applicable federal, state, local, or international law or regulation"}),e.jsx("li",{children:"To transmit any advertising or promotional material without prior written consent"}),e.jsx("li",{children:"To impersonate or attempt to impersonate Fantize, an employee, or any other person or entity"}),e.jsx("li",{children:"To engage in any conduct that restricts or inhibits anyone's use or enjoyment of the services"})]})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"8. Assumption of Risk"}),e.jsx("p",{className:"mb-4",children:"Technology platforms carry inherent risks including but not limited to: service interruptions, data loss, security vulnerabilities, regulatory uncertainty, and third-party service failures. You acknowledge that you understand these risks and assume full responsibility for your use of the services."}),e.jsx("p",{className:"mb-4",children:"Fantize may not guarantee the availability, security, or uninterrupted operation of the services."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"9. Disclaimer of Warranties"}),e.jsx("p",{className:"mb-4",children:'The services are provided on an "AS IS" and "AS AVAILABLE" basis. Fantize makes no representations or warranties of any kind, express or implied, as to the operation of the services or the information, content, materials, or products included in the services.'})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"10. Limitation of Liability"}),e.jsx("p",{className:"mb-4",children:"In no event shall Fantize, its directors, employees, partners, agents, suppliers, or affiliates be liable for any indirect, incidental, special, consequential, or punitive damages, including without limitation, loss of profits, data, use, goodwill, or other intangible losses, resulting from your access to or use of or inability to access or use the services."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"11. Indemnification"}),e.jsx("p",{className:"mb-4",children:"You agree to defend, indemnify, and hold harmless Fantize and its employees, contractors, agents, officers, and directors, from and against any and all claims, damages, obligations, losses, liabilities, costs or debt, and expenses arising from your use of the services or your violation of these Terms."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"12. Termination"}),e.jsx("p",{className:"mb-4",children:"Fantize may terminate or suspend your account and access to the services at any time, at its sole discretion, for any reason, without prior notice or liability."}),e.jsx("p",{className:"mb-4",children:"You may discontinue use of the services at any time. Fantize may, at its sole discretion, retain or delete account data in accordance with its operational and legal requirements."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"13. Governing Law"}),e.jsx("p",{className:"mb-4",children:"These Terms shall be governed and construed in accordance with the laws of the Commonwealth of Massachusetts, United States, without regard to its conflict of law provisions."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"14. Changes to Terms"}),e.jsx("p",{className:"mb-4",children:"Fantize reserves the right to modify or replace these Terms at any time at its sole discretion. Changes are effective immediately upon posting. Continued use of the services after changes constitutes acceptance. Nothing in these Terms shall be construed as creating any obligation, liability, or encumbrance on Fantize beyond what is required by applicable law."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-4",children:"15. Contact Information"}),e.jsx("p",{className:"mb-4",children:"If you have any questions about these Terms, please contact us:"}),e.jsxs("ul",{className:"list-none space-y-1",children:[e.jsx("li",{children:"Email: [email protected]"}),e.jsx("li",{children:"Address: 1 Lincoln Street, Boston, MA 02111"}),e.jsx("li",{children:"Phone: 1-650-276-3200"}),e.jsx("li",{children:"Legal Counsel: CodeLaw LLC"})]})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-8",children:"Feature descriptions reflect Fantize's current or planned capabilities and are subject to change. Fantize makes no guarantees regarding the availability, timing, or functionality of any described features."})]})});function Iw(){const[s]=$r(),l=s.get("tab"),i=l==="integrations"?"crm-sync":l==="usage"?"usage":"";return e.jsx(is,{to:`/dashboard/integrations${i?`?tab=${i}`:""}`,replace:!0})}function ka(){const s=Ga(),l=Ej.find(o=>o.from===s.pathname),i=l?l.to(new URLSearchParams(s.search)):"/dashboard";return e.jsx(is,{to:i,replace:!0})}function Vw(){const{id:s}=am();return e.jsx(is,{to:`/dashboard/prospecting/results/${s}`,replace:!0})}function gt({children:s}){return e.jsx(P5,{to:Tj,children:s})}function Gw(){return e.jsx(xj,{children:e.jsxs(Iv,{children:[e.jsxs(Le,{path:"/",element:e.jsx(kj,{}),children:[e.jsx(Le,{index:!0,element:e.jsx(Bj,{})}),e.jsx(Le,{path:"contact",element:e.jsx(Yj,{})}),e.jsx(Le,{path:"pricing",element:e.jsx(Pj,{})}),e.jsx(Le,{path:"privacy",element:e.jsx(Uw,{})}),e.jsx(Le,{path:"terms",element:e.jsx(Fw,{})})]}),e.jsx(Le,{path:"/login",element:e.jsx(Qj,{})}),e.jsx(Le,{path:"/register",element:e.jsx(Xj,{})}),e.jsx(Le,{path:"/set-password",element:e.jsx(mw,{})}),e.jsxs(Le,{path:"/dashboard",element:e.jsx(Dj,{children:e.jsx($j,{})}),children:[e.jsx(Le,{index:!0,element:e.jsx(gt,{children:e.jsx(o1,{})})}),e.jsx(Le,{path:"prospecting",element:e.jsx(is,{to:"/dashboard/prospecting/searches",replace:!0})}),e.jsx(Le,{path:"prospecting/searches",element:e.jsx(gt,{children:e.jsx(Dl,{section:"searches"})})}),e.jsx(Le,{path:"prospecting/templates",element:e.jsx(gt,{children:e.jsx(Dl,{section:"templates"})})}),e.jsx(Le,{path:"prospecting/templates/library",element:e.jsx(gt,{children:e.jsx(S2,{})})}),e.jsx(Le,{path:"prospecting/results",element:e.jsx(gt,{children:e.jsx(Dl,{section:"results"})})}),e.jsx(Le,{path:"prospecting/results/:id",element:e.jsx(gt,{children:e.jsx(I2,{})})}),e.jsx(Le,{path:"prospecting/schedules",element:e.jsx(gt,{children:e.jsx(Dl,{section:"schedules"})})}),e.jsx(Le,{path:"prospecting/exclusions",element:e.jsx(gt,{children:e.jsx(Dl,{section:"exclusions"})})}),e.jsx(Le,{path:"leads/review",element:e.jsx(G5,{})}),e.jsx(Le,{path:"leads/inbound",element:e.jsx(d5,{})}),e.jsx(Le,{path:"leads/inbound/:id",element:e.jsx(f5,{})}),e.jsx(Le,{path:"leads/review-legacy",element:e.jsx(gt,{children:e.jsx(t5,{})})}),e.jsx(Le,{path:"review-queue-v2-preview",element:e.jsx(is,{to:"/dashboard/leads/review",replace:!0})}),e.jsx(Le,{path:"leads/activity",element:e.jsx(C5,{})}),e.jsx(Le,{path:"leads/lifecycle",element:e.jsx(gt,{children:e.jsx(X2,{})})}),e.jsx(Le,{path:"leads/cleanup",element:e.jsx(gt,{children:e.jsx(cw,{})})}),e.jsx(Le,{path:"leads/do-not-contact",element:e.jsx(gt,{children:e.jsx(Y5,{})})}),e.jsx(Le,{path:"campaigns",element:e.jsx(gt,{children:e.jsx(g1,{})})}),e.jsx(Le,{path:"campaigns/first-campaign",element:e.jsx(gt,{children:e.jsx(ww,{})})}),e.jsx(Le,{path:"campaigns/routing",element:e.jsx(gt,{children:e.jsx(iw,{})})}),e.jsx(Le,{path:"templates",element:e.jsx(is,{to:"/dashboard/campaigns?showTemplates=true",replace:!0})}),e.jsx(Le,{path:"outreach",element:e.jsx(gt,{children:e.jsx(Y1,{})})}),e.jsx(Le,{path:"contacts",element:e.jsx(gt,{children:e.jsx(u1,{})})}),e.jsx(Le,{path:"lists",element:e.jsx(gt,{children:e.jsx(_w,{})})}),e.jsx(Le,{path:"pipeline",element:e.jsx(gt,{children:e.jsx(k1,{})})}),e.jsx(Le,{path:"conversations",element:e.jsx(gt,{children:e.jsx(E1,{})})}),e.jsx(Le,{path:"orders",element:e.jsx(gt,{children:e.jsx(N1,{})})}),e.jsx(Le,{path:"automation",element:e.jsx(is,{to:"/dashboard/automation/readiness",replace:!0})}),e.jsx(Le,{path:"automation/readiness",element:e.jsx(gt,{children:e.jsx(bw,{})})}),e.jsx(Le,{path:"automation/settings",element:e.jsx(gt,{children:e.jsx(X5,{})})}),e.jsx(Le,{path:"automation/lead-assignment",element:e.jsx(gt,{children:e.jsx(W5,{})})}),e.jsx(Le,{path:"automation/lifecycle-hubspot",element:e.jsx(gt,{children:e.jsx(nw,{})})}),e.jsx(Le,{path:"automation/notifications",element:e.jsx(gt,{children:e.jsx(fw,{})})}),e.jsx(Le,{path:"automation/test-mode",element:e.jsx(gt,{children:e.jsx(jw,{})})}),e.jsx(Le,{path:"integrations",element:e.jsx(gt,{children:e.jsx(K1,{})})}),e.jsx(Le,{path:"analytics",element:e.jsx(gt,{children:e.jsx(Dw,{})})}),e.jsx(Le,{path:"users",element:e.jsx(gt,{children:e.jsx(uw,{})})}),e.jsx(Le,{path:"brand",element:e.jsx(gt,{children:e.jsx(L1,{})})}),e.jsx(Le,{path:"help",element:e.jsx(p5,{})}),e.jsx(Le,{path:"preferences",element:e.jsx(qw,{})}),e.jsx(Le,{path:"leads",element:e.jsx(ka,{})}),e.jsx(Le,{path:"leads/library",element:e.jsx(ka,{})}),e.jsx(Le,{path:"leads/runs/:id",element:e.jsx(Vw,{})}),e.jsx(Le,{path:"leads/schedules",element:e.jsx(ka,{})}),e.jsx(Le,{path:"leads/campaign-mapping",element:e.jsx(ka,{})}),e.jsx(Le,{path:"leads/assignment",element:e.jsx(ka,{})}),e.jsx(Le,{path:"leads/mapping",element:e.jsx(ka,{})}),e.jsx(Le,{path:"leads/notifications",element:e.jsx(ka,{})}),e.jsx(Le,{path:"leads/test",element:e.jsx(ka,{})}),e.jsx(Le,{path:"leads/go-live",element:e.jsx(ka,{})}),e.jsx(Le,{path:"leads/settings",element:e.jsx(ka,{})}),e.jsx(Le,{path:"leads/engagement-settings",element:e.jsx(ka,{})}),e.jsx(Le,{path:"leads/sync-errors",element:e.jsx(ka,{})}),e.jsx(Le,{path:"onboarding",element:e.jsx(ka,{})}),e.jsx(Le,{path:"leads/analytics",element:e.jsx(is,{to:"/dashboard/analytics?tab=leads",replace:!0})}),e.jsx(Le,{path:"leads/admin",element:e.jsx(Iw,{})})]}),e.jsx(Le,{path:"*",element:e.jsx(Bw,{})})]})})}Db.createRoot(document.getElementById("root")).render(e.jsx(h.StrictMode,{children:e.jsx(Bb,{children:e.jsx(qb,{children:e.jsx(Ib,{children:e.jsx(Gw,{})})})})}));
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.