PageSourceSearch

https://outliner.com/assets/index-Cr9cGxwF.js

js outliner.com collected 2026-10-04 23:42:24 UTC 1,168,404 bytes, 211 lines download raw bytes

vendor: 5,306 bytes, line 1
1function QP(t,s){for(var n=0;n<s.length;n++){const a=s[n];if(typeof a!="string"&&!Array.isArray(a)){for(const o in a)if(o!=="default"&&!(o in t)){const l=Object.getOwnPropertyDescriptor(a,o);l&&Object.defineProperty(t,o,l.get?l:{enumerable:!0,get:()=>a[o]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&a(d)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function a(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function vb(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Wf={exports:{}},ic={},Qf={exports:{}},Ut={};var Cj;function GP(){if(Cj)return Ut;Cj=1;var t=Symbol.for("react.element"),s=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),x=Symbol.iterator;function v(U){return U===null||typeof U!="object"?null:(U=x&&U[x]||U["@@iterator"],typeof U=="function"?U:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,j={};function b(U,Q,we){this.props=U,this.context=Q,this.refs=j,this.updater=we||w}b.prototype.isReactComponent={},b.prototype.setState=function(U,Q){if(typeof U!="object"&&typeof U!="function"&&U!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,U,Q,"setState")},b.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function k(){}k.prototype=b.prototype;function N(U,Q,we){this.props=U,this.context=Q,this.refs=j,this.updater=we||w}var T=N.prototype=new k;T.constructor=N,C(T,b.prototype),T.isPureReactComponent=!0;var P=Array.isArray,I=Object.prototype.hasOwnProperty,O={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function F(U,Q,we){var _e,Ie={},Te=null,ue=null;if(Q!=null)for(_e in Q.ref!==void 0&&(ue=Q.ref),Q.key!==void 0&&(Te=""+Q.key),Q)I.call(Q,_e)&&!R.hasOwnProperty(_e)&&(Ie[_e]=Q[_e]);var Re=arguments.length-2;if(Re===1)Ie.children=we;else if(1<Re){for(var $e=Array(Re),le=0;le<Re;le++)$e[le]=arguments[le+2];Ie.children=$e}if(U&&U.defaultProps)for(_e in Re=U.defaultProps,Re)Ie[_e]===void 0&&(Ie[_e]=Re[_e]);return{$$typeof:t,type:U,key:Te,ref:ue,props:Ie,_owner:O.current}}function M(U,Q){return{$$typeof:t,type:U.type,key:Q,ref:U.ref,props:U.props,_owner:U._owner}}function z(U){return typeof U=="object"&&U!==null&&U.$$typeof===t}function H(U){var Q={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(we){return Q[we]})}var V=/\/+/g;function B(U,Q){return typeof U=="object"&&U!==null&&U.key!=null?H(""+U.key):Q.toString(36)}function Y(U,Q,we,_e,Ie){var Te=typeof U;(Te==="undefined"||Te==="boolean")&&(U=null);var ue=!1;if(U===null)ue=!0;else switch(Te){case"string":case"number":ue=!0;break;case"object":switch(U.$$typeof){case t:case s:ue=!0}}if(ue)return ue=U,Ie=Ie(ue),U=_e===""?"."+B(ue,0):_e,P(Ie)?(we="",U!=null&&(we=U.replace(V,"$&/")+"/"),Y(Ie,Q,we,"",function(le){return le})):Ie!=null&&(z(Ie)&&(Ie=M(Ie,we+(!Ie.key||ue&&ue.key===Ie.key?"":(""+Ie.key).replace(V,"$&/")+"/")+U)),Q.push(Ie)),1;if(ue=0,_e=_e===""?".":_e+":",P(U))for(var Re=0;Re<U.length;Re++){Te=U[Re];var $e=_e+B(Te,Re);ue+=Y(Te,Q,we,$e,Ie)}else if($e=v(U),typeof $e=="function")for(U=$e.call(U),Re=0;!(Te=U.next()).done;)Te=Te.value,$e=_e+B(Te,Re++),ue+=Y(Te,Q,we,$e,Ie);else if(Te==="object")throw Q=String(U),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.");return ue}function L(U,Q,we){if(U==null)return U;var _e=[],Ie=0;return Y(U,_e,"","",function(Te){return Q.call(we,Te,Ie++)}),_e}function K(U){if(U._status===-1){var Q=U._result;Q=Q(),Q.then(function(we){(U._status===0||U._status===-1)&&(U._status=1,U._result=we)},function(we){(U._status===0||U._status===-1)&&(U._status=2,U._result=we)}),U._status===-1&&(U._status=0,U._result=Q)}if(U._status===1)return U._result.default;throw U._result}var _={current:null},$={transition:null},A={ReactCurrentDispatcher:_,ReactCurrentBatchConfig:$,ReactCurrentOwner:O};function W(){throw Error("act(...) is not supported in production builds of React.")}return Ut.Children={map:L,forEach:function(U,Q,we){L(U,function(){Q.apply(this,arguments)},we)},count:function(U){var Q=0;return L(U,function(){Q++}),Q},toArray:function(U){return L(U,function(Q){return Q})||[]}
vendor: 8,695 bytes, line 1
1,only:function(U){if(!z(U))throw Error("React.Children.only expected to receive a single React element child.");return U}},Ut.Component=b,Ut.Fragment=n,Ut.Profiler=o,Ut.PureComponent=N,Ut.StrictMode=a,Ut.Suspense=h,Ut.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=A,Ut.act=W,Ut.cloneElement=function(U,Q,we){if(U==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+U+".");var _e=C({},U.props),Ie=U.key,Te=U.ref,ue=U._owner;if(Q!=null){if(Q.ref!==void 0&&(Te=Q.ref,ue=O.current),Q.key!==void 0&&(Ie=""+Q.key),U.type&&U.type.defaultProps)var Re=U.type.defaultProps;for($e in Q)I.call(Q,$e)&&!R.hasOwnProperty($e)&&(_e[$e]=Q[$e]===void 0&&Re!==void 0?Re[$e]:Q[$e])}var $e=arguments.length-2;if($e===1)_e.children=we;else if(1<$e){Re=Array($e);for(var le=0;le<$e;le++)Re[le]=arguments[le+2];_e.children=Re}return{$$typeof:t,type:U.type,key:Ie,ref:Te,props:_e,_owner:ue}},Ut.createContext=function(U){return U={$$typeof:d,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},U.Provider={$$typeof:l,_context:U},U.Consumer=U},Ut.createElement=F,Ut.createFactory=function(U){var Q=F.bind(null,U);return Q.type=U,Q},Ut.createRef=function(){return{current:null}},Ut.forwardRef=function(U){return{$$typeof:u,render:U}},Ut.isValidElement=z,Ut.lazy=function(U){return{$$typeof:g,_payload:{_status:-1,_result:U},_init:K}},Ut.memo=function(U,Q){return{$$typeof:f,type:U,compare:Q===void 0?null:Q}},Ut.startTransition=function(U){var Q=$.transition;$.transition={};try{U()}finally{$.transition=Q}},Ut.unstable_act=W,Ut.useCallback=function(U,Q){return _.current.useCallback(U,Q)},Ut.useContext=function(U){return _.current.useContext(U)},Ut.useDebugValue=function(){},Ut.useDeferredValue=function(U){return _.current.useDeferredValue(U)},Ut.useEffect=function(U,Q){return _.current.useEffect(U,Q)},Ut.useId=function(){return _.current.useId()},Ut.useImperativeHandle=function(U,Q,we){return _.current.useImperativeHandle(U,Q,we)},Ut.useInsertionEffect=function(U,Q){return _.current.useInsertionEffect(U,Q)},Ut.useLayoutEffect=function(U,Q){return _.current.useLayoutEffect(U,Q)},Ut.useMemo=function(U,Q){return _.current.useMemo(U,Q)},Ut.useReducer=function(U,Q,we){return _.current.useReducer(U,Q,we)},Ut.useRef=function(U){return _.current.useRef(U)},Ut.useState=function(U){return _.current.useState(U)},Ut.useSyncExternalStore=function(U,Q,we){return _.current.useSyncExternalStore(U,Q,we)},Ut.useTransition=function(){return _.current.useTransition()},Ut.version="18.3.1",Ut}var kj;function Sm(){return kj||(kj=1,Qf.exports=GP()),Qf.exports}var Pj;function YP(){if(Pj)return ic;Pj=1;var t=Sm(),s=Symbol.for("react.element"),n=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function d(u,h,f){var g,x={},v=null,w=null;f!==void 0&&(v=""+f),h.key!==void 0&&(v=""+h.key),h.ref!==void 0&&(w=h.ref);for(g in h)a.call(h,g)&&!l.hasOwnProperty(g)&&(x[g]=h[g]);if(u&&u.defaultProps)for(g in h=u.defaultProps,h)x[g]===void 0&&(x[g]=h[g]);return{$$typeof:s,type:u,key:v,ref:w,props:x,_owner:o.current}}return ic.Fragment=n,ic.jsx=d,ic.jsxs=d,ic}var Tj;function ZP(){return Tj||(Tj=1,Wf.exports=YP()),Wf.exports}var e=ZP(),ju={},Gf={exports:{}},Wn={},Yf={exports:{}},Zf={};var Ej;function XP(){return Ej||(Ej=1,(function(t){function s($,A){var W=$.length;$.push(A);e:for(;0<W;){var U=W-1>>>1,Q=$[U];if(0<o(Q,A))$[U]=A,$[W]=Q,W=U;else break e}}function n($){return $.length===0?null:$[0]}function a($){if($.length===0)return null;var A=$[0],W=$.pop();if(W!==A){$[0]=W;e:for(var U=0,Q=$.length,we=Q>>>1;U<we;){var _e=2*(U+1)-1,Ie=$[_e],Te=_e+1,ue=$[Te];if(0>o(Ie,W))Te<Q&&0>o(ue,Ie)?($[U]=ue,$[Te]=W,U=Te):($[U]=Ie,$[_e]=W,U=_e);else if(Te<Q&&0>o(ue,W))$[U]=ue,$[Te]=W,U=Te;else break e}}return A}function o($,A){var W=$.sortIndex-A.sortIndex;return W!==0?W:$.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;t.unstable_now=function(){return l.now()}}else{var d=Date,u=d.now();t.unstable_now=function(){return d.now()-u}}var h=[],f=[],g=1,x=null,v=3,w=!1,C=!1,j=!1,b=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T($){for(var A=n(f);A!==null;){if(A.callback===null)a(f);else if(A.startTime<=$)a(f),A.sortIndex=A.expirationTime,s(h,A);else break;A=n(f)}}function P($){if(j=!1,T($),!C)if(n(h)!==null)C=!0,K(I);else{var A=n(f);A!==null&&_(P,A.startTime-$)}}function I($,A){C=!1,j&&(j=!1,k(F),F=-1),w=!0;var W=v;try{for(T(A),x=n(h);x!==null&&(!(x.expirationTime>A)||$&&!H());){var U=x.callback;if(typeof U=="function"){x.callback=null,v=x.priorityLevel;var Q=U(x.expirationTime<=A);A=t.unstable_now(),typeof Q=="function"?x.callback=Q:x===n(h)&&a(h),T(A)}else a(h);x=n(h)}if(x!==null)var we=!0;else{var _e=n(f);_e!==null&&_(P,_e.startTime-A),we=!1}return we}finally{x=null,v=W,w=!1}}var O=!1,R=null,F=-1,M=5,z=-1;function H(){return!(t.unstable_now()-z<M)}function V(){if(R!==null){var $=t.unstable_now();z=$;var A=!0;try{A=R(!0,$)}finally{A?B():(O=!1,R=null)}}else O=!1}var B;if(typeof N=="function")B=function(){N(V)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,L=Y.port2;Y.port1.onmessage=V,B=function(){L.postMessage(null)}}else B=function(){b(V,0)};function K($){R=$,O||(O=!0,B())}function _($,A){F=b(function(){$(t.unstable_now())},A)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function($){$.callback=null},t.unstable_continueExecution=function(){C||w||(C=!0,K(I))},t.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<$?Math.floor(1e3/$):5},t.unstable_getCurrentPriorityLevel=function(){return v},t.unstable_getFirstCallbackNode=function(){return n(h)},t.unstable_next=function($){switch(v){case 1:case 2:case 3:var A=3;break;default:A=v}var W=v;v=A;try{return $()}finally{v=W}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function($,A){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var W=v;v=$;try{return A()}finally{v=W}},t.unstable_scheduleCallback=function($,A,W){var U=t.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?U+W:U):W=U,$){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=W+Q,$={id:g++,callback:A,priorityLevel:$,startTime:W,expirationTime:Q,sortIndex:-1},W>U?($.sortIndex=W,s(f,$),n(h)===null&&$===n(f)&&(j?(k(F),F=-1):j=!0,_(P,W-U))):($.sortIndex=Q,s(h,$),C||w||(C=!0,K(I))),$},t.unstable_shouldYield=H,t.unstable_wrapCallback=function($){var A=v;return function(){var W=v;v=A;try{return $.apply(this,arguments)}finally{v=W}}}})(Zf)),Zf}var _j;function JP(){return _j||(_j=1,Yf.exports=XP()),Yf.exports}var Rj;function eT(){if(Rj)return Wn;Rj=1;var t=Sm(),s=JP();function n(r){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+r,c=1;c<arguments.length;c++)i+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+r+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var a=new Set,o={};function l(r,i){d(r,i),d(r+"Capture",i)}function d(r,i){for(o[r]=i,r=0;r<i.length;r++)a.add(i[r])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,g={},x={};function v(r){return h.call(x,r)?!0:h.call(g,r)?!1:f.test(r)?x[r]=!0:(g[r]=!0,!1)}function w(r,i,c,p){if(c!==null&&c.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return p?!1:c!==null?!c.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function C(r,i,c,p){if(i===null||typeof i>"u"||w(r,i,c,p))return!0;
vendor: 47,318 bytes, lines 1-6
1if(p)return!1;if(c!==null)switch(c.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function j(r,i,c,p,y,S,E){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=p,this.attributeNamespace=y,this.mustUseProperty=c,this.propertyName=r,this.type=i,this.sanitizeURL=S,this.removeEmptyString=E}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){b[r]=new j(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var i=r[0];b[i]=new j(i,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){b[r]=new j(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){b[r]=new j(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){b[r]=new j(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){b[r]=new j(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){b[r]=new j(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){b[r]=new j(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){b[r]=new j(r,5,!1,r.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function N(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var i=r.replace(k,N);b[i]=new j(i,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var i=r.replace(k,N);b[i]=new j(i,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var i=r.replace(k,N);b[i]=new j(i,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){b[r]=new j(r,1,!1,r.toLowerCase(),null,!1,!1)}),b.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){b[r]=new j(r,1,!1,r.toLowerCase(),null,!0,!0)});function T(r,i,c,p){var y=b.hasOwnProperty(i)?b[i]:null;(y!==null?y.type!==0:p||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(C(i,c,y,p)&&(c=null),p||y===null?v(i)&&(c===null?r.removeAttribute(i):r.setAttribute(i,""+c)):y.mustUseProperty?r[y.propertyName]=c===null?y.type===3?!1:"":c:(i=y.attributeName,p=y.attributeNamespace,c===null?r.removeAttribute(i):(y=y.type,c=y===3||y===4&&c===!0?"":""+c,p?r.setAttributeNS(p,i,c):r.setAttribute(i,c))))}var P=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,I=Symbol.for("react.element"),O=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),z=Symbol.for("react.provider"),H=Symbol.for("react.context"),V=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),_=Symbol.for("react.offscreen"),$=Symbol.iterator;function A(r){return r===null||typeof r!="object"?null:(r=$&&r[$]||r["@@iterator"],typeof r=="function"?r:null)}var W=Object.assign,U;function Q(r){if(U===void 0)try{throw Error()}catch(c){var i=c.stack.trim().match(/\n( *(at )?)/);U=i&&i[1]||""}return`
2`+U+r}var we=!1;function _e(r,i){if(!r||we)return"";we=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(ie){var p=ie}Reflect.construct(r,[],i)}else{try{i.call()}catch(ie){p=ie}r.call(i.prototype)}else{try{throw Error()}catch(ie){p=ie}r()}}catch(ie){if(ie&&p&&typeof ie.stack=="string"){for(var y=ie.stack.split(`
3`),S=p.stack.split(`
4`),E=y.length-1,q=S.length-1;1<=E&&0<=q&&y[E]!==S[q];)q--;for(;1<=E&&0<=q;E--,q--)if(y[E]!==S[q]){if(E!==1||q!==1)do if(E--,q--,0>q||y[E]!==S[q]){var G=`
5`+y[E].replace(" at new "," at ");return r.displayName&&G.includes("<anonymous>")&&(G=G.replace("<anonymous>",r.displayName)),G}while(1<=E&&0<=q);break}}}finally{we=!1,Error.prepareStackTrace=c}return(r=r?r.displayName||r.name:"")?Q(r):""}function Ie(r){switch(r.tag){case 5:return Q(r.type);case 16:return Q("Lazy");case 13:return Q("Suspense");case 19:return Q("SuspenseList");case 0:case 2:case 15:return r=_e(r.type,!1),r;case 11:return r=_e(r.type.render,!1),r;case 1:return r=_e(r.type,!0),r;default:return""}}function Te(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case R:return"Fragment";case O:return"Portal";case M:return"Profiler";case F:return"StrictMode";case B:return"Suspense";case Y:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case H:return(r.displayName||"Context")+".Consumer";case z:return(r._context.displayName||"Context")+".Provider";case V:var i=r.render;return r=r.displayName,r||(r=i.displayName||i.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case L:return i=r.displayName||null,i!==null?i:Te(r.type)||"Memo";case K:i=r._payload,r=r._init;try{return Te(r(i))}catch{}}return null}function ue(r){var i=r.type;switch(r.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=i.render,r=r.displayName||r.name||"",i.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Te(i);case 8:return i===F?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function Re(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function $e(r){var i=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function le(r){var i=$e(r)?"checked":"value",c=Object.getOwnPropertyDescriptor(r.constructor.prototype,i),p=""+r[i];if(!r.hasOwnProperty(i)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var y=c.get,S=c.set;return Object.defineProperty(r,i,{configurable:!0,get:function(){return y.call(this)},set:function(E){p=""+E,S.call(this,E)}}),Object.defineProperty(r,i,{enumerable:c.enumerable}),{getValue:function(){return p},setValue:function(E){p=""+E},stopTracking:function(){r._valueTracker=null,delete r[i]}}}}function Me(r){r._valueTracker||(r._valueTracker=le(r))}function He(r){if(!r)return!1;var i=r._valueTracker;if(!i)return!0;var c=i.getValue(),p="";return r&&(p=$e(r)?r.checked?"true":"false":r.value),r=p,r!==c?(i.setValue(r),!0):!1}function ft(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function Ct(r,i){var c=i.checked;return W({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:c??r._wrapperState.initialChecked})}function zt(r,i){var c=i.defaultValue==null?"":i.defaultValue,p=i.checked!=null?i.checked:i.defaultChecked;c=Re(i.value!=null?i.value:c),r._wrapperState={initialChecked:p,initialValue:c,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function Wt(r,i){i=i.checked,i!=null&&T(r,"checked",i,!1)}function Le(r,i){Wt(r,i);var c=Re(i.value),p=i.type;if(c!=null)p==="number"?(c===0&&r.value===""||r.value!=c)&&(r.value=""+c):r.value!==""+c&&(r.value=""+c);else if(p==="submit"||p==="reset"){r.removeAttribute("value");return}i.hasOwnProperty("value")?Xt(r,i.type,c):i.hasOwnProperty("defaultValue")&&Xt(r,i.type,Re(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(r.defaultChecked=!!i.defaultChecked)}function Nt(r,i,c){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var p=i.type;if(!(p!=="submit"&&p!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+r._wrapperState.initialValue,c||i===r.value||(r.value=i),r.defaultValue=i}c=r.name,c!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,c!==""&&(r.name=c)}function Xt(r,i,c){(i!=="number"||ft(r.ownerDocument)!==r)&&(c==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+c&&(r.defaultValue=""+c))}var qt=Array.isArray;function us(r,i,c,p){if(r=r.options,i){i={};for(var y=0;y<c.length;y++)i["$"+c[y]]=!0;for(c=0;c<r.length;c++)y=i.hasOwnProperty("$"+r[c].value),r[c].selected!==y&&(r[c].selected=y),y&&p&&(r[c].defaultSelected=!0)}else{for(c=""+Re(c),i=null,y=0;y<r.length;y++){if(r[y].value===c){r[y].selected=!0,p&&(r[y].defaultSelected=!0);return}i!==null||r[y].disabled||(i=r[y])}i!==null&&(i.selected=!0)}}function qs(r,i){if(i.dangerouslySetInnerHTML!=null)throw Error(n(91));return W({},i,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function Ks(r,i){var c=i.value;if(c==null){if(c=i.children,i=i.defaultValue,c!=null){if(i!=null)throw Error(n(92));if(qt(c)){if(1<c.length)throw Error(n(93));c=c[0]}i=c}i==null&&(i=""),c=i}r._wrapperState={initialValue:Re(c)}}function xn(r,i){var c=Re(i.value),p=Re(i.defaultValue);c!=null&&(c=""+c,c!==r.value&&(r.value=c),i.defaultValue==null&&r.defaultValue!==c&&(r.defaultValue=c)),p!=null&&(r.defaultValue=""+p)}function vn(r){var i=r.textContent;i===r._wrapperState.initialValue&&i!==""&&i!==null&&(r.value=i)}function Ls(r){switch(r){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function $t(r,i){return r==null||r==="http://www.w3.org/1999/xhtml"?Ls(i):r==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var ze,Xe=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,c,p,y){MSApp.execUnsafeLocalFunction(function(){return r(i,c,p,y)})}:r})(function(r,i){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=i;else{for(ze=ze||document.createElement("div"),ze.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=ze.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;i.firstChild;)r.appendChild(i.firstChild)}});function ne(r,i){if(i){var c=r.firstChild;if(c&&c===r.lastChild&&c.nodeType===3){c.nodeValue=i;return}}r.textContent=i}var pe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ut=["Webkit","ms","Moz","O"];Object.keys(pe).forEach(function(r){ut.forEach(function(i){i=i+r.charAt(0).toUpperCase()+r.substring(1),pe[i]=pe[r]})});function mt(r,i,c){return i==null||typeof i=="boolean"||i===""?"":c||typeof i!="number"||i===0||pe.hasOwnProperty(r)&&pe[r]?(""+i).trim():i+"px"}function ms(r,i){r=r.style;for(var c in i)if(i.hasOwnProperty(c)){var p=c.indexOf("--")===0,y=mt(c,i[c],p);c==="float"&&(c="cssFloat"),p?r.setProperty(c,y):r[c]=y}}var Kt=W({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function kt(r,i){if(i){if(Kt[r]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(n(137,r));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(n(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(n(61))}if(i.style!=null&&typeof i.style!="object")throw Error(n(62))}}function xs(r,i){if(r.indexOf("-")===-1)return typeof i.is=="string";switch(r){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 hs=null;function Jn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var _n=null,en=null,Ft=null;function Jt(r){if(r=Kl(r)){if(typeof _n!="function")throw Error(n(280));var i=r.stateNode;i&&(i=Od(i),_n(r.stateNode,r.type,i))}}function vs(r){en?Ft?Ft.push(r):Ft=[r]:en=r}function Fs(){if(en){var r=en,i=Ft;if(Ft=en=null,Jt(r),i)for(r=0;r<i.length;r++)Jt(i[r])}}function Cs(r,i){return r(i)}function Hs(){}var Is=!1;function Rn(r,i,c){if(Is)return r(i,c);Is=!0;try{return Cs(r,i,c)}finally{Is=!1,(en!==null||Ft!==null)&&(Hs(),Fs())}}function as(r,i){var c=r.stateNode;if(c===null)return null;var p=Od(c);if(p===null)return null;c=p[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(p=!p.disabled)||(r=r.type,p=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!p;break e;default:r=!1}if(r)return null;if(c&&typeof c!="function")throw Error(n(231,i,typeof c));return c}var tn=!1;if(u)try{var $s={};Object.defineProperty($s,"passive",{get:function(){tn=!0}}),window.addEventListener("test",$s,$s),window.removeEventListener("test",$s,$s)}catch{tn=!1}function un(r,i,c,p,y,S,E,q,G){var ie=Array.prototype.slice.call(arguments,3);try{i.apply(c,ie)}catch(ve){this.onError(ve)}}var yn=!1,zn=null,Gs=!1,er=null,se={onError:function(r){yn=!0,zn=r}};function Ue(r,i,c,p,y,S,E,q,G){yn=!1,zn=null,un.apply(se,arguments)}function Be(r,i,c,p,y,S,E,q,G){if(Ue.apply(this,arguments),yn){if(yn){var ie=zn;yn=!1,zn=null}else throw Error(n(198));Gs||(Gs=!0,er=ie)}}function De(r){var i=r,c=r;if(r.alternate)for(;i.return;)i=i.return;else{r=i;do i=r,(i.flags&4098)!==0&&(c=i.return),r=i.return;while(r)}return i.tag===3?c:null}function st(r){if(r.tag===13){var i=r.memoizedState;if(i===null&&(r=r.alternate,r!==null&&(i=r.memoizedState)),i!==null)return i.dehydrated}return null}function ks(r){if(De(r)!==r)throw Error(n(188))}function Gr(r){var i=r.alternate;if(!i){if(i=De(r),i===null)throw Error(n(188));return i!==r?null:r}for(var c=r,p=i;;){var y=c.return;if(y===null)break;var S=y.alternate;if(S===null){if(p=y.return,p!==null){c=p;continue}break}if(y.child===S.child){for(S=y.child;S;){if(S===c)return ks(y),r;if(S===p)return ks(y),i;S=S.sibling}throw Error(n(188))}if(c.return!==p.return)c=y,p=S;else{for(var E=!1,q=y.child;q;){if(q===c){E=!0,c=y,p=S;break}if(q===p){E=!0,p=y,c=S;break}q=q.sibling}if(!E){for(q=S.child;q;){if(q===c){E=!0,c=S,p=y;break}if(q===p){E=!0,p=S,c=y;break}q=q.sibling}if(!E)throw Error(n(189))}}if(c.alternate!==p)throw Error(n(190))}if(c.tag!==3)throw Error(n(188));return c.stateNode.current===c?r:i}function fa(r){return r=Gr(r),r!==null?J(r):null}function J(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var i=J(r);if(i!==null)return i;r=r.sibling}return null}var he=s.unstable_scheduleCallback,Qe=s.unstable_cancelCallback,_t=s.unstable_shouldYield,Ge=s.unstable_requestPaint,es=s.unstable_now,Yr=s.unstable_getCurrentPriorityLevel,mn=s.unstable_ImmediatePriority,Si=s.unstable_UserBlockingPriority,Fa=s.unstable_NormalPriority,Zr=s.unstable_LowPriority,tv=s.unstable_IdlePriority,gd=null,Xr=null;function c2(r){if(Xr&&typeof Xr.onCommitFiberRoot=="function")try{Xr.onCommitFiberRoot(gd,r,void 0,(r.current.flags&128)===128)}catch{}}var kr=Math.clz32?Math.clz32:m2,d2=Math.log,u2=Math.LN2;function m2(r){return r>>>=0,r===0?32:31-(d2(r)/u2|0)|0}var xd=64,vd=4194304;function Pl(r){switch(r&-r){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: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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function yd(r,i){var c=r.pendingLanes;if(c===0)return 0;var p=0,y=r.suspendedLanes,S=r.pingedLanes,E=c&268435455;if(E!==0){var q=E&~y;q!==0?p=Pl(q):(S&=E,S!==0&&(p=Pl(S)))}else E=c&~y,E!==0?p=Pl(E):S!==0&&(p=Pl(S));if(p===0)return 0;if(i!==0&&i!==p&&(i&y)===0&&(y=p&-p,S=i&-i,y>=S||y===16&&(S&4194240)!==0))return i;if((p&4)!==0&&(p|=c&16),i=r.entangledLanes,i!==0)for(r=r.entanglements,i&=p;0<i;)c=31-kr(i),y=1<<c,p|=r[c],i&=~y;return p}function h2(r,i){switch(r){case 1:case 2:case 4:return i+250;case 8:case 16:case 32:case 64: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 i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function f2(r,i){for(var c=r.suspendedLanes,p=r.pingedLanes,y=r.expirationTimes,S=r.pendingLanes;0<S;){var E=31-kr(S),q=1<<E,G=y[E];G===-1?((q&c)===0||(q&p)!==0)&&(y[E]=h2(q,i)):G<=i&&(r.expiredLanes|=q),S&=~q}}function hh(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function sv(){var r=xd;return xd<<=1,(xd&4194240)===0&&(xd=64),r}function fh(r){for(var i=[],c=0;31>c;c++)i.push(r);return i}function Tl(r,i,c){r.pendingLanes|=i,i!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,i=31-kr(i),r[i]=c}function p2(r,i){var c=r.pendingLanes&~i;r.pendingLanes=i,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=i,r.mutableReadLanes&=i,r.entangledLanes&=i,i=r.entanglements;var p=r.eventTimes;for(r=r.expirationTimes;0<c;){var y=31-kr(c),S=1<<y;i[y]=0,p[y]=-1,r[y]=-1,c&=~S}}function ph(r,i){var c=r.entangledLanes|=i;for(r=r.entanglements;c;){var p=31-kr(c),y=1<<p;y&i|r[p]&i&&(r[p]|=i),c&=~y}}var ns=0;function nv(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var rv,gh,av,iv,ov,xh=!1,jd=[],$a=null,Ua=null,za=null,El=new Map,_l=new Map,Ba=[],g2="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 submit".split(" ");function lv(r,i){switch(r){case"focusin":case"focusout":$a=null;break;case"dragenter":case"dragleave":Ua=null;break;case"mouseover":case"mouseout":za=null;break;case"pointerover":case"pointerout":El.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":_l.delete(i.pointerId)}}function Rl(r,i,c,p,y,S){return r===null||r.nativeEvent!==S?(r={blockedOn:i,domEventName:c,eventSystemFlags:p,nativeEvent:S,targetContainers:[y]},i!==null&&(i=Kl(i),i!==null&&gh(i)),r):(r.eventSystemFlags|=p,i=r.targetContainers,y!==null&&i.indexOf(y)===-1&&i.push(y),r)}function x2(r,i,c,p,y){switch(i){case"focusin":return $a=Rl($a,r,i,c,p,y),!0;case"dragenter":return Ua=Rl(Ua,r,i,c,p,y),!0;case"mouseover":return za=Rl(za,r,i,c,p,y),!0;case"pointerover":var S=y.pointerId;return El.set(S,Rl(El.get(S)||null,r,i,c,p,y)),!0;case"gotpointercapture":return S=y.pointerId,_l.set(S,Rl(_l.get(S)||null,r,i,c,p,y)),!0}return!1}function cv(r){var i=Ci(r.target);if(i!==null){var c=De(i);if(c!==null){if(i=c.tag,i===13){if(i=st(c),i!==null){r.blockedOn=i,ov(r.priority,function(){av(c)});return}}else if(i===3&&c.stateNode.current.memoizedState.isDehydrated){r.blockedOn=c.tag===3?c.stateNode.containerInfo:null;return}}}r.blockedOn=null}function wd(r){if(r.blockedOn!==null)return!1;for(var i=r.targetContainers;0<i.length;){var c=yh(r.domEventName,r.eventSystemFlags,i[0],r.nativeEvent);if(c===null){c=r.nativeEvent;var p=new c.constructor(c.type,c);hs=p,c.target.dispatchEvent(p),hs=null}else return i=Kl(c),i!==null&&gh(i),r.blockedOn=c,!1;i.shift()}return!0}function dv(r,i,c){wd(r)&&c.delete(i)}function v2(){xh=!1,$a!==null&&wd($a)&&($a=null),Ua!==null&&wd(Ua)&&(Ua=null),za!==null&&wd(za)&&(za=null),El.forEach(dv),_l.forEach(dv)}function Al(r,i){r.blockedOn===i&&(r.blockedOn=null,xh||(xh=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,v2)))}function Il(r){function i(y){return Al(y,r)}if(0<jd.length){Al(jd[0],r);for(var c=1;c<jd.length;c++){var p=jd[c];p.blockedOn===r&&(p.blockedOn=null)}}for($a!==null&&Al($a,r),Ua!==null&&Al(Ua,r),za!==null&&Al(za,r),El.forEach(i),_l.forEach(i),c=0;c<Ba.length;c++)p=Ba[c],p.blockedOn===r&&(p.blockedOn=null);for(;0<Ba.length&&(c=Ba[0],c.blockedOn===null);)cv(c),c.blockedOn===null&&Ba.shift()}var oo=P.ReactCurrentBatchConfig,bd=!0;function y2(r,i,c,p){var y=ns,S=oo.transition;oo.transition=null;try{ns=1,vh(r,i,c,p)}finally{ns=y,oo.transition=S}}function j2(r,i,c,p){var y=ns,S=oo.transition;oo.transition=null;try{ns=4,vh(r,i,c,p)}finally{ns=y,oo.transition=S}}function vh(r,i,c,p){if(bd){var y=yh(r,i,c,p);if(y===null)Mh(r,i,p,Nd,c),lv(r,p);else if(x2(y,r,i,c,p))p.stopPropagation();else if(lv(r,p),i&4&&-1<g2.indexOf(r)){for(;y!==null;){var S=Kl(y);if(S!==null&&rv(S),S=yh(r,i,c,p),S===null&&Mh(r,i,p,Nd,c),S===y)break;y=S}y!==null&&p.stopPropagation()}else Mh(r,i,p,null,c)}}var Nd=null;function yh(r,i,c,p){if(Nd=null,r=Jn(p),r=Ci(r),r!==null)if(i=De(r),i===null)r=null;else if(c=i.tag,c===13){if(r=st(i),r!==null)return r;r=null}else if(c===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;r=null}else i!==r&&(r=null);return Nd=r,null}function uv(r){switch(r){case"cancel":case"click":case"close":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"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 1;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"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Yr()){case mn:return 1;case Si:return 4;case Fa:case Zr:return 16;case tv:return 536870912;default:return 16}default:return 16}}var Va=null,jh=null,Sd=null;function mv(){if(Sd)return Sd;var r,i=jh,c=i.length,p,y="value"in Va?Va.value:Va.textContent,S=y.length;for(r=0;r<c&&i[r]===y[r];r++);var E=c-r;for(p=1;p<=E&&i[c-p]===y[S-p];p++);return Sd=y.slice(r,1<p?1-p:void 0)}function Cd(r){var i=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&i===13&&(r=13)):r=i,r===10&&(r=13),32<=r||r===13?r:0}function kd(){return!0}function hv(){return!1}function tr(r){function i(c,p,y,S,E){this._reactName=c,this._targetInst=y,this.type=p,this.nativeEvent=S,this.target=E,this.currentTarget=null;for(var q in r)r.hasOwnProperty(q)&&(c=r[q],this[q]=c?c(S):S[q]);return this.isDefaultPrevented=(S.defaultPrevented!=null?S.defaultPrevented:S.returnValue===!1)?kd:hv,this.isPropagationStopped=hv,this}return W(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var c=this.nativeEvent;c&&(c.preventDefault?c.preventDefault():typeof c.returnValue!="unknown"&&(c.returnValue=!1),this.isDefaultPrevented=kd)},stopPropagation:function(){var c=this.nativeEvent;c&&(c.stopPropagation?c.stopPropagation():typeof c.cancelBubble!="unknown"&&(c.cancelBubble=!0),this.isPropagationStopped=kd)},persist:function(){},isPersistent:kd}),i}var lo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},wh=tr(lo),Dl=W({},lo,{view:0,detail:0}),w2=tr(Dl),bh,Nh,Ol,Pd=W({},Dl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ch,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==Ol&&(Ol&&r.type==="mousemove"?(bh=r.screenX-Ol.screenX,Nh=r.screenY-Ol.screenY):Nh=bh=0,Ol=r),bh)},movementY:function(r){return"movementY"in r?r.movementY:Nh}}),fv=tr(Pd),b2=W({},Pd,{dataTransfer:0}),N2=tr(b2),S2=W({},Dl,{relatedTarget:0}),Sh=tr(S2),C2=W({},lo,{animationName:0,elapsedTime:0,pseudoElement:0}),k2=tr(C2),P2=W({},lo,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),T2=tr(P2),E2=W({},lo,{data:0}),pv=tr(E2),_2={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},R2={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"},A2={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function I2(r){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(r):(r=A2[r])?!!i[r]:!1}function Ch(){return I2}var D2=W({},Dl,{key:function(r){if(r.key){var i=_2[r.key]||r.key;if(i!=="Unidentified")return i}return r.type==="keypress"?(r=Cd(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?R2[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ch,charCode:function(r){return r.type==="keypress"?Cd(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Cd(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),O2=tr(D2),M2=W({},Pd,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),gv=tr(M2),L2=W({},Dl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ch}),F2=tr(L2),$2=W({},lo,{propertyName:0,elapsedTime:0,pseudoElement:0}),U2=tr($2),z2=W({},Pd,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),B2=tr(z2),V2=[9,13,27,32],kh=u&&"CompositionEvent"in window,Ml=null;u&&"documentMode"in document&&(Ml=document.documentMode);var q2=u&&"TextEvent"in window&&!Ml,xv=u&&(!kh||Ml&&8<Ml&&11>=Ml),vv=" ",yv=!1;function jv(r,i){switch(r){case"keyup":return V2.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wv(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var co=!1;function K2(r,i){switch(r){case"compositionend":return wv(i);case"keypress":return i.which!==32?null:(yv=!0,vv);case"textInput":return r=i.data,r===vv&&yv?null:r;default:return null}}function H2(r,i){if(co)return r==="compositionend"||!kh&&jv(r,i)?(r=mv(),Sd=jh=Va=null,co=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return xv&&i.locale!=="ko"?null:i.data;default:return null}}var W2={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 bv(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i==="input"?!!W2[r.type]:i==="textarea"}function Nv(r,i,c,p){vs(p),i=Ad(i,"onChange"),0<i.length&&(c=new wh("onChange","change",null,c,p),r.push({event:c,listeners:i}))}var Ll=null,Fl=null;function Q2(r){zv(r,0)}function Td(r){var i=po(r);if(He(i))return r}function G2(r,i){if(r==="change")return i}var Sv=!1;if(u){var Ph;if(u){var Th="oninput"in document;if(!Th){var Cv=document.createElement("div");Cv.setAttribute("oninput","return;"),Th=typeof Cv.oninput=="function"}Ph=Th}else Ph=!1;Sv=Ph&&(!document.documentMode||9<document.documentMode)}function kv(){Ll&&(Ll.detachEvent("onpropertychange",Pv),Fl=Ll=null)}function Pv(r){if(r.propertyName==="value"&&Td(Fl)){var i=[];Nv(i,Fl,r,Jn(r)),Rn(Q2,i)}}function Y2(r,i,c){r==="focusin"?(kv(),Ll=i,Fl=c,Ll.attachEvent("onpropertychange",Pv)):r==="focusout"&&kv()}function Z2(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Td(Fl)}function X2(r,i){if(r==="click")return Td(i)}function J2(r,i){if(r==="input"||r==="change")return Td(i)}function eP(r,i){return r===i&&(r!==0||1/r===1/i)||r!==r&&i!==i}var Pr=typeof Object.is=="function"?Object.is:eP;function $l(r,i){if(Pr(r,i))return!0;if(typeof r!="object"||r===null||typeof i!="object"||i===null)return!1;var c=Object.keys(r),p=Object.keys(i);if(c.length!==p.length)return!1;for(p=0;p<c.length;p++){var y=c[p];if(!h.call(i,y)||!Pr(r[y],i[y]))return!1}return!0}function Tv(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Ev(r,i){var c=Tv(r);r=0;for(var p;c;){if(c.nodeType===3){if(p=r+c.textContent.length,r<=i&&p>=i)return{node:c,offset:i-r};r=p}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=Tv(c)}}function _v(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?_v(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function Rv(){for(var r=window,i=ft();i instanceof r.HTMLIFrameElement;){try{var c=typeof i.contentWindow.location.href=="string"}catch{c=!1}if(c)r=i.contentWindow;else break;i=ft(r.document)}return i}function Eh(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i&&(i==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||i==="textarea"||r.contentEditable==="true")}function tP(r){var i=Rv(),c=r.focusedElem,p=r.selectionRange;if(i!==c&&c&&c.ownerDocument&&_v(c.ownerDocument.documentElement,c)){if(p!==null&&Eh(c)){if(i=p.start,r=p.end,r===void 0&&(r=i),"selectionStart"in c)c.selectionStart=i,c.selectionEnd=Math.min(r,c.value.length);else if(r=(i=c.ownerDocument||document)&&i.defaultView||window,r.getSelection){r=r.getSelection();var y=c.textContent.length,S=Math.min(p.start,y);p=p.end===void 0?S:Math.min(p.end,y),!r.extend&&S>p&&(y=p,p=S,S=y),y=Ev(c,S);var E=Ev(c,p);y&&E&&(r.rangeCount!==1||r.anchorNode!==y.node||r.anchorOffset!==y.offset||r.focusNode!==E.node||r.focusOffset!==E.offset)&&(i=i.createRange(),i.setStart(y.node,y.offset),r.removeAllRanges(),S>p?(r.addRange(i),r.extend(E.node,E.offset)):(i.setEnd(E.node,E.offset),r.addRange(i)))}}for(i=[],r=c;r=r.parentNode;)r.nodeType===1&&i.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof c.focus=="function"&&c.focus(),c=0;c<i.length;c++)r=i[c],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var sP=u&&"documentMode"in document&&11>=document.documentMode,uo=null,_h=null,Ul=null,Rh=!1;function Av(r,i,c){var p=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;Rh||uo==null||uo!==ft(p)||(p=uo,"selectionStart"in p&&Eh(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),Ul&&$l(Ul,p)||(Ul=p,p=Ad(_h,"onSelect"),0<p.length&&(i=new wh("onSelect","select",null,i,c),r.push({event:i,listeners:p}),i.target=uo)))}function Ed(r,i){var c={};return c[r.toLowerCase()]=i.toLowerCase(),c["Webkit"+r]="webkit"+i,c["Moz"+r]="moz"+i,c}var mo={animationend:Ed("Animation","AnimationEnd"),animationiteration:Ed("Animation","AnimationIteration"),animationstart:Ed("Animation","AnimationStart"),transitionend:Ed("Transition","TransitionEnd")},Ah={},Iv={};u&&(Iv=document.createElement("div").style,"AnimationEvent"in window||(delete mo.animationend.animation,delete mo.animationiteration.animation,delete mo.animationstart.animation),"TransitionEvent"in window||delete mo.transitionend.transition);function _d(r){if(Ah[r])return Ah[r];if(!mo[r])return r;var i=mo[r],c;for(c in i)if(i.hasOwnProperty(c)&&c in Iv)return Ah[r]=i[c];return r}var Dv=_d("animationend"),Ov=_d("animationiteration"),Mv=_d("animationstart"),Lv=_d("transitionend"),Fv=new Map,$v="abort auxClick 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(" ");function qa(r,i){Fv.set(r,i),l(i,[r])}for(var Ih=0;Ih<$v.length;Ih++){var Dh=$v[Ih],nP=Dh.toLowerCase(),rP=Dh[0].toUpperCase()+Dh.slice(1);qa(nP,"on"+rP)}qa(Dv,"onAnimationEnd"),qa(Ov,"onAnimationIteration"),qa(Mv,"onAnimationStart"),qa("dblclick","onDoubleClick"),qa("focusin","onFocus"),qa("focusout","onBlur"),qa(Lv,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zl="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(" "),aP=new Set("cancel close invalid load scroll toggle".split(" ").concat(zl));function Uv(r,i,c){var p=r.type||"unknown-event";r.currentTarget=c,Be(p,i,void 0,r),r.currentTarget=null}function zv(r,i){i=(i&4)!==0;for(var c=0;c<r.length;c++){var p=r[c],y=p.event;p=p.listeners;e:{var S=void 0;if(i)for(var E=p.length-1;0<=E;E--){var q=p[E],G=q.instance,ie=q.currentTarget;if(q=q.listener,G!==S&&y.isPropagationStopped())break e;Uv(y,q,ie),S=G}else for(E=0;E<p.length;E++){if(q=p[E],G=q.instance,ie=q.currentTarget,q=q.listener,G!==S&&y.isPropagationStopped())break e;Uv(y,q,ie),S=G}}}if(Gs)throw r=er,Gs=!1,er=null,r}function ys(r,i){var c=i[Bh];c===void 0&&(c=i[Bh]=new Set);var p=r+"__bubble";c.has(p)||(Bv(i,r,2,!1),c.add(p))}function Oh(r,i,c){var p=0;i&&(p|=4),Bv(c,r,p,i)}var Rd="_reactListening"+Math.random().toString(36).slice(2);function Bl(r){if(!r[Rd]){r[Rd]=!0,a.forEach(function(c){c!=="selectionchange"&&(aP.has(c)||Oh(c,!1,r),Oh(c,!0,r))});var i=r.nodeType===9?r:r.ownerDocument;i===null||i[Rd]||(i[Rd]=!0,Oh("selectionchange",!1,i))}}function Bv(r,i,c,p){switch(uv(i)){case 1:var y=y2;break;case 4:y=j2;break;default:y=vh}c=y.bind(null,i,c,r),y=void 0,!tn||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(y=!0),p?y!==void 0?r.addEventListener(i,c,{capture:!0,passive:y}):r.addEventListener(i,c,!0):y!==void 0?r.addEventListener(i,c,{passive:y}):r.addEventListener(i,c,!1)}function Mh(r,i,c,p,y){var S=p;if((i&1)===0&&(i&2)===0&&p!==null)e:for(;;){if(p===null)return;var E=p.tag;if(E===3||E===4){var q=p.stateNode.containerInfo;if(q===y||q.nodeType===8&&q.parentNode===y)break;if(E===4)for(E=p.return;E!==null;){var G=E.tag;if((G===3||G===4)&&(G=E.stateNode.containerInfo,G===y||G.nodeType===8&&G.parentNode===y))return;E=E.return}for(;q!==null;){if(E=Ci(q),E===null)return;if(G=E.tag,G===5||G===6){p=S=E;continue e}q=q.parentNode}}p=p.return}Rn(function(){var ie=S,ve=Jn(c),Se=[];e:{var ge=Fv.get(r);if(ge!==void 0){var Ke=wh,Je=r;switch(r){case"keypress":if(Cd(c)===0)break e;case"keydown":case"keyup":Ke=O2;break;case"focusin":Je="focus",Ke=Sh;break;case"focusout":Je="blur",Ke=Sh;break;case"beforeblur":case"afterblur":Ke=Sh;break;case"click":if(c.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ke=fv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ke=N2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ke=F2;break;case Dv:case Ov:case Mv:Ke=k2;break;case Lv:Ke=U2;break;case"scroll":Ke=w2;break;case"wheel":Ke=B2;break;case"copy":case"cut":case"paste":Ke=T2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ke=gv}var et=(i&4)!==0,Us=!et&&r==="scroll",re=et?ge!==null?ge+"Capture":null:ge;et=[];for(var X=ie,ae;X!==null;){ae=X;var Ee=ae.stateNode;if(ae.tag===5&&Ee!==null&&(ae=Ee,re!==null&&(Ee=as(X,re),Ee!=null&&et.push(Vl(X,Ee,ae)))),Us)break;X=X.return}0<et.length&&(ge=new Ke(ge,Je,null,c,ve),Se.push({event:ge,listeners:et}))}}if((i&7)===0){e:{if(ge=r==="mouseover"||r==="pointerover",Ke=r==="mouseout"||r==="pointerout",ge&&c!==hs&&(Je=c.relatedTarget||c.fromElement)&&(Ci(Je)||Je[pa]))break e;if((Ke||ge)&&(ge=ve.window===ve?ve:(ge=ve.ownerDocument)?ge.defaultView||ge.parentWindow:window,Ke?(Je=c.relatedTarget||c.toElement,Ke=ie,Je=Je?Ci(Je):null,Je!==null&&(Us=De(Je),Je!==Us||Je.tag!==5&&Je.tag!==6)&&(Je=null)):(Ke=null,Je=ie),Ke!==Je)){if(et=fv,Ee="onMouseLeave",re="onMouseEnter",X="mouse",(r==="pointerout"||r==="pointerover")&&(et=gv,Ee="onPointerLeave",re="onPointerEnter",X="pointer"),Us=Ke==null?ge:po(Ke),ae=Je==null?ge:po(Je),ge=new et(Ee,X+"leave",Ke,c,ve),ge.target=Us,ge.relatedTarget=ae,Ee=null,Ci(ve)===ie&&(et=new et(re,X+"enter",Je,c,ve),et.target=ae,et.relatedTarget=Us,Ee=et),Us=Ee,Ke&&Je)t:{for(et=Ke,re=Je,X=0,ae=et;ae;ae=ho(ae))X++;for(ae=0,Ee=re;Ee;Ee=ho(Ee))ae++;for(;0<X-ae;)et=ho(et),X--;for(;0<ae-X;)re=ho(re),ae--;for(;X--;){if(et===re||re!==null&&et===re.alternate)break t;et=ho(et),re=ho(re)}et=null}else et=null;Ke!==null&&Vv(Se,ge,Ke,et,!1),Je!==null&&Us!==null&&Vv(Se,Us,Je,et,!0)}}e:{if(ge=ie?po(ie):window,Ke=ge.nodeName&&ge.nodeName.toLowerCase(),Ke==="select"||Ke==="input"&&ge.type==="file")var nt=G2;else if(bv(ge))if(Sv)nt=J2;else{nt=Z2;var pt=Y2}else(Ke=ge.nodeName)&&Ke.toLowerCase()==="input"&&(ge.type==="checkbox"||ge.type==="radio")&&(nt=X2);if(nt&&(nt=nt(r,ie))){Nv(Se,nt,c,ve);break e}pt&&pt(r,ge,ie),r==="focusout"&&(pt=ge._wrapperState)&&pt.controlled&&ge.type==="number"&&Xt(ge,"number",ge.value)}switch(pt=ie?po(ie):window,r){case"focusin":(bv(pt)||pt.contentEditable==="true")&&(uo=pt,_h=ie,Ul=null);break;case"focusout":Ul=_h=uo=null;break;case"mousedown":Rh=!0;break;case"contextmenu":case"mouseup":case"dragend":Rh=!1,Av(Se,c,ve);break;case"selectionchange":if(sP)break;case"keydown":case"keyup":Av(Se,c,ve)}var gt;if(kh)e:{switch(r){case"compositionstart":var yt="onCompositionStart";break e;case"compositionend":yt="onCompositionEnd";break e;case"compositionupdate":yt="onCompositionUpdate";break e}yt=void 0}else co?jv(r,c)&&(yt="onCompositionEnd"):r==="keydown"&&c.keyCode===229&&(yt="onCompositionStart");yt&&(xv&&c.locale!=="ko"&&(co||yt!=="onCompositionStart"?yt==="onCompositionEnd"&&co&&(gt=mv()):(Va=ve,jh="value"in Va?Va.value:Va.textContent,co=!0)),pt=Ad(ie,yt),0<pt.length&&(yt=new pv(yt,r,null,c,ve),Se.push({event:yt,listeners:pt}),gt?yt.data=gt:(gt=wv(c),gt!==null&&(yt.data=gt)))),(gt=q2?K2(r,c):H2(r,c))&&(ie=Ad(ie,"onBeforeInput"),0<ie.length&&(ve=new pv("onBeforeInput","beforeinput",null,c,ve),Se.push({event:ve,listeners:ie}),ve.data=gt))}zv(Se,i)})}function Vl(r,i,c){return{instance:r,listener:i,currentTarget:c}}function Ad(r,i){for(var c=i+"Capture",p=[];r!==null;){var y=r,S=y.stateNode;y.tag===5&&S!==null&&(y=S,S=as(r,c),S!=null&&p.unshift(Vl(r,S,y)),S=as(r,i),S!=null&&p.push(Vl(r,S,y))),r=r.return}return p}function ho(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function Vv(r,i,c,p,y){for(var S=i._reactName,E=[];c!==null&&c!==p;){var q=c,G=q.alternate,ie=q.stateNode;if(G!==null&&G===p)break;q.tag===5&&ie!==null&&(q=ie,y?(G=as(c,S),G!=null&&E.unshift(Vl(c,G,q))):y||(G=as(c,S),G!=null&&E.push(Vl(c,G,q)))),c=c.return}E.length!==0&&r.push({event:i,listeners:E})}var iP=/\r\n?/g,oP=/\u0000|\uFFFD/g;function qv(r){return(typeof r=="string"?r:""+r).replace(iP,`
6`).replace(oP,"")}function Id(r,i,c){if(i=qv(i),qv(r)!==i&&c)throw Error(n(425))}function Dd(){}var Lh=null,Fh=null;function $h(r,i){return r==="textarea"||r==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Uh=typeof setTimeout=="function"?setTimeout:void 0,lP=typeof clearTimeout=="function"?clearTimeout:void 0,Kv=typeof Promise=="function"?Promise:void 0,cP=typeof queueMicrotask=="function"?queueMicrotask:typeof Kv<"u"?function(r){return Kv.resolve(null).then(r).catch(dP)}:Uh;function dP(r){setTimeout(function(){throw r})}function zh(r,i){var c=i,p=0;do{var y=c.nextSibling;if(r.removeChild(c),y&&y.nodeType===8)if(c=y.data,c==="/$"){if(p===0){r.removeChild(y),Il(i);return}p--}else c!=="$"&&c!=="$?"&&c!=="$!"||p++;c=y}while(c);Il(i)}function Ka(r){for(;r!=null;r=r.nextSibling){var i=r.nodeType;if(i===1||i===3)break;if(i===8){if(i=r.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return r}function Hv(r){r=r.previousSibling;for(var i=0;r;){if(r.nodeType===8){var c=r.data;if(c==="$"||c==="$!"||c==="$?"){if(i===0)return r;i--}else c==="/$"&&i++}r=r.previousSibling}return null}var fo=Math.random().toString(36).slice(2),Jr="__reactFiber$"+fo,ql="__reactProps$"+fo,pa="__reactContainer$"+fo,Bh="__reactEvents$"+fo,uP="__reactListeners$"+fo,mP="__reactHandles$"+fo;function Ci(r){var i=r[Jr];if(i)return i;for(var c=r.parentNode;c;){if(i=c[pa]||c[Jr]){if(c=i.alternate,i.child!==null||c!==null&&c.child!==null)for(r=Hv(r);r!==null;){if(c=r[Jr])return c;r=Hv(r)}return i}r=c,c=r.parentNode}return null}function Kl(r){return r=r[Jr]||r[pa],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function po(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function Od(r){return r[ql]||null}var Vh=[],go=-1;function Ha(r){return{current:r}}function js(r){0>go||(r.current=Vh[go],Vh[go]=null,go--)}function fs(r,i){go++,Vh[go]=r.current,r.current=i}var Wa={},jn=Ha(Wa),Bn=Ha(!1),ki=Wa;function xo(r,i){var c=r.type.contextTypes;if(!c)return Wa;var p=r.stateNode;if(p&&p.__reactInternalMemoizedUnmaskedChildContext===i)return p.__reactInternalMemoizedMaskedChildContext;var y={},S;for(S in c)y[S]=i[S];return p&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=i,r.__reactInternalMemoizedMaskedChildContext=y),y}function Vn(r){return r=r.childContextTypes,r!=null}function Md(){js(Bn),js(jn)}function Wv(r,i,c){if(jn.current!==Wa)throw Error(n(168));fs(jn,i),fs(Bn,c)}function Qv(r,i,c){var p=r.stateNode;if(i=i.childContextTypes,typeof p.getChildContext!="function")return c;p=p.getChildContext();for(var y in p)if(!(y in i))throw Error(n(108,ue(r)||"Unknown",y));return W({},c,p)}function Ld(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Wa,ki=jn.current,fs(jn,r),fs(Bn,Bn.current),!0}function Gv(r,i,c){var p=r.stateNode;if(!p)throw Error(n(169));c?(r=Qv(r,i,ki),p.__reactInternalMemoizedMergedChildContext=r,js(Bn),js(jn),fs(jn,r)):js(Bn),fs(Bn,c)}var ga=null,Fd=!1,qh=!1;function Yv(r){ga===null?ga=[r]:ga.push(r)}function hP(r){Fd=!0,Yv(r)}function Qa(){if(!qh&&ga!==null){qh=!0;var r=0,i=ns;try{var c=ga;for(ns=1;r<c.length;r++){var p=c[r];do p=p(!0);while(p!==null)}ga=null,Fd=!1}catch(y){throw ga!==null&&(ga=ga.slice(r+1)),he(mn,Qa),y}finally{ns=i,qh=!1}}return null}var vo=[],yo=0,$d=null,Ud=0,ur=[],mr=0,Pi=null,xa=1,va="";function Ti(r,i){vo[yo++]=Ud,vo[yo++]=$d,$d=r,Ud=i}function Zv(r,i,c){ur[mr++]=xa,ur[mr++]=va,ur[mr++]=Pi,Pi=r;var p=xa;r=va;var y=32-kr(p)-1;p&=~(1<<y),c+=1;var S=32-kr(i)+y;if(30<S){var E=y-y%5;S=(p&(1<<E)-1).toString(32),p>>=E,y-=E,xa=1<<32-kr(i)+y|c<<y|p,va=S+r}else xa=1<<S|c<<y|p,va=r}function Kh(r){r.return!==null&&(Ti(r,1),Zv(r,1,0))}function Hh(r){for(;r===$d;)$d=vo[--yo],vo[yo]=null,Ud=vo[--yo],vo[yo]=null;for(;r===Pi;)Pi=ur[--mr],ur[mr]=null,va=ur[--mr],ur[mr]=null,xa=ur[--mr],ur[mr]=null}var sr=null,nr=null,Ns=!1,Tr=null;function Xv(r,i){var c=gr(5,null,null,0);c.elementType="DELETED",c.stateNode=i,c.return=r,i=r.deletions,i===null?(r.deletions=[c],r.flags|=16):i.push(c)}
vendor: 2,361 bytes, line 6
6function Jv(r,i){switch(r.tag){case 5:var c=r.type;return i=i.nodeType!==1||c.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(r.stateNode=i,sr=r,nr=Ka(i.firstChild),!0):!1;case 6:return i=r.pendingProps===""||i.nodeType!==3?null:i,i!==null?(r.stateNode=i,sr=r,nr=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(c=Pi!==null?{id:xa,overflow:va}:null,r.memoizedState={dehydrated:i,treeContext:c,retryLane:1073741824},c=gr(18,null,null,0),c.stateNode=i,c.return=r,r.child=c,sr=r,nr=null,!0):!1;default:return!1}}function Wh(r){return(r.mode&1)!==0&&(r.flags&128)===0}function Qh(r){if(Ns){var i=nr;if(i){var c=i;if(!Jv(r,i)){if(Wh(r))throw Error(n(418));i=Ka(c.nextSibling);var p=sr;i&&Jv(r,i)?Xv(p,c):(r.flags=r.flags&-4097|2,Ns=!1,sr=r)}}else{if(Wh(r))throw Error(n(418));r.flags=r.flags&-4097|2,Ns=!1,sr=r}}}function ey(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;sr=r}function zd(r){if(r!==sr)return!1;if(!Ns)return ey(r),Ns=!0,!1;var i;if((i=r.tag!==3)&&!(i=r.tag!==5)&&(i=r.type,i=i!=="head"&&i!=="body"&&!$h(r.type,r.memoizedProps)),i&&(i=nr)){if(Wh(r))throw ty(),Error(n(418));for(;i;)Xv(r,i),i=Ka(i.nextSibling)}if(ey(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));e:{for(r=r.nextSibling,i=0;r;){if(r.nodeType===8){var c=r.data;if(c==="/$"){if(i===0){nr=Ka(r.nextSibling);break e}i--}else c!=="$"&&c!=="$!"&&c!=="$?"||i++}r=r.nextSibling}nr=null}}else nr=sr?Ka(r.stateNode.nextSibling):null;return!0}function ty(){for(var r=nr;r;)r=Ka(r.nextSibling)}function jo(){nr=sr=null,Ns=!1}function Gh(r){Tr===null?Tr=[r]:Tr.push(r)}var fP=P.ReactCurrentBatchConfig;function Hl(r,i,c){if(r=c.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(c._owner){if(c=c._owner,c){if(c.tag!==1)throw Error(n(309));var p=c.stateNode}if(!p)throw Error(n(147,r));var y=p,S=""+r;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===S?i.ref:(i=function(E){var q=y.refs;E===null?delete q[S]:q[S]=E},i._stringRef=S,i)}if(typeof r!="string")throw Error(n(284));if(!c._owner)throw Error(n(290,r))}return r}function Bd(r,i){throw r=Object.prototype.toString.call(i),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":r))}function sy(r){var i=r._init;return i(r._payload)}function ny(r){function i(re,X){if(r){var ae=re.deletions;
vendor: 10,069 bytes, line 6
6ae===null?(re.deletions=[X],re.flags|=16):ae.push(X)}}function c(re,X){if(!r)return null;for(;X!==null;)i(re,X),X=X.sibling;return null}function p(re,X){for(re=new Map;X!==null;)X.key!==null?re.set(X.key,X):re.set(X.index,X),X=X.sibling;return re}function y(re,X){return re=si(re,X),re.index=0,re.sibling=null,re}function S(re,X,ae){return re.index=ae,r?(ae=re.alternate,ae!==null?(ae=ae.index,ae<X?(re.flags|=2,X):ae):(re.flags|=2,X)):(re.flags|=1048576,X)}function E(re){return r&&re.alternate===null&&(re.flags|=2),re}function q(re,X,ae,Ee){return X===null||X.tag!==6?(X=zf(ae,re.mode,Ee),X.return=re,X):(X=y(X,ae),X.return=re,X)}function G(re,X,ae,Ee){var nt=ae.type;return nt===R?ve(re,X,ae.props.children,Ee,ae.key):X!==null&&(X.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===K&&sy(nt)===X.type)?(Ee=y(X,ae.props),Ee.ref=Hl(re,X,ae),Ee.return=re,Ee):(Ee=mu(ae.type,ae.key,ae.props,null,re.mode,Ee),Ee.ref=Hl(re,X,ae),Ee.return=re,Ee)}function ie(re,X,ae,Ee){return X===null||X.tag!==4||X.stateNode.containerInfo!==ae.containerInfo||X.stateNode.implementation!==ae.implementation?(X=Bf(ae,re.mode,Ee),X.return=re,X):(X=y(X,ae.children||[]),X.return=re,X)}function ve(re,X,ae,Ee,nt){return X===null||X.tag!==7?(X=Mi(ae,re.mode,Ee,nt),X.return=re,X):(X=y(X,ae),X.return=re,X)}function Se(re,X,ae){if(typeof X=="string"&&X!==""||typeof X=="number")return X=zf(""+X,re.mode,ae),X.return=re,X;if(typeof X=="object"&&X!==null){switch(X.$$typeof){case I:return ae=mu(X.type,X.key,X.props,null,re.mode,ae),ae.ref=Hl(re,null,X),ae.return=re,ae;case O:return X=Bf(X,re.mode,ae),X.return=re,X;case K:var Ee=X._init;return Se(re,Ee(X._payload),ae)}if(qt(X)||A(X))return X=Mi(X,re.mode,ae,null),X.return=re,X;Bd(re,X)}return null}function ge(re,X,ae,Ee){var nt=X!==null?X.key:null;if(typeof ae=="string"&&ae!==""||typeof ae=="number")return nt!==null?null:q(re,X,""+ae,Ee);if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case I:return ae.key===nt?G(re,X,ae,Ee):null;case O:return ae.key===nt?ie(re,X,ae,Ee):null;case K:return nt=ae._init,ge(re,X,nt(ae._payload),Ee)}if(qt(ae)||A(ae))return nt!==null?null:ve(re,X,ae,Ee,null);Bd(re,ae)}return null}function Ke(re,X,ae,Ee,nt){if(typeof Ee=="string"&&Ee!==""||typeof Ee=="number")return re=re.get(ae)||null,q(X,re,""+Ee,nt);if(typeof Ee=="object"&&Ee!==null){switch(Ee.$$typeof){case I:return re=re.get(Ee.key===null?ae:Ee.key)||null,G(X,re,Ee,nt);case O:return re=re.get(Ee.key===null?ae:Ee.key)||null,ie(X,re,Ee,nt);case K:var pt=Ee._init;return Ke(re,X,ae,pt(Ee._payload),nt)}if(qt(Ee)||A(Ee))return re=re.get(ae)||null,ve(X,re,Ee,nt,null);Bd(X,Ee)}return null}function Je(re,X,ae,Ee){for(var nt=null,pt=null,gt=X,yt=X=0,rn=null;gt!==null&&yt<ae.length;yt++){gt.index>yt?(rn=gt,gt=null):rn=gt.sibling;var Zt=ge(re,gt,ae[yt],Ee);if(Zt===null){gt===null&&(gt=rn);break}r&&gt&&Zt.alternate===null&&i(re,gt),X=S(Zt,X,yt),pt===null?nt=Zt:pt.sibling=Zt,pt=Zt,gt=rn}if(yt===ae.length)return c(re,gt),Ns&&Ti(re,yt),nt;if(gt===null){for(;yt<ae.length;yt++)gt=Se(re,ae[yt],Ee),gt!==null&&(X=S(gt,X,yt),pt===null?nt=gt:pt.sibling=gt,pt=gt);return Ns&&Ti(re,yt),nt}for(gt=p(re,gt);yt<ae.length;yt++)rn=Ke(gt,re,yt,ae[yt],Ee),rn!==null&&(r&&rn.alternate!==null&&gt.delete(rn.key===null?yt:rn.key),X=S(rn,X,yt),pt===null?nt=rn:pt.sibling=rn,pt=rn);return r&&gt.forEach(function(ni){return i(re,ni)}),Ns&&Ti(re,yt),nt}function et(re,X,ae,Ee){var nt=A(ae);if(typeof nt!="function")throw Error(n(150));if(ae=nt.call(ae),ae==null)throw Error(n(151));for(var pt=nt=null,gt=X,yt=X=0,rn=null,Zt=ae.next();gt!==null&&!Zt.done;yt++,Zt=ae.next()){gt.index>yt?(rn=gt,gt=null):rn=gt.sibling;var ni=ge(re,gt,Zt.value,Ee);if(ni===null){gt===null&&(gt=rn);break}r&&gt&&ni.alternate===null&&i(re,gt),X=S(ni,X,yt),pt===null?nt=ni:pt.sibling=ni,pt=ni,gt=rn}if(Zt.done)return c(re,gt),Ns&&Ti(re,yt),nt;if(gt===null){for(;!Zt.done;yt++,Zt=ae.next())Zt=Se(re,Zt.value,Ee),Zt!==null&&(X=S(Zt,X,yt),pt===null?nt=Zt:pt.sibling=Zt,pt=Zt);return Ns&&Ti(re,yt),nt}for(gt=p(re,gt);!Zt.done;yt++,Zt=ae.next())Zt=Ke(gt,re,yt,Zt.value,Ee),Zt!==null&&(r&&Zt.alternate!==null&&gt.delete(Zt.key===null?yt:Zt.key),X=S(Zt,X,yt),pt===null?nt=Zt:pt.sibling=Zt,pt=Zt);return r&&gt.forEach(function(WP){return i(re,WP)}),Ns&&Ti(re,yt),nt}function Us(re,X,ae,Ee){if(typeof ae=="object"&&ae!==null&&ae.type===R&&ae.key===null&&(ae=ae.props.children),typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case I:e:{for(var nt=ae.key,pt=X;pt!==null;){if(pt.key===nt){if(nt=ae.type,nt===R){if(pt.tag===7){c(re,pt.sibling),X=y(pt,ae.props.children),X.return=re,re=X;break e}}else if(pt.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===K&&sy(nt)===pt.type){c(re,pt.sibling),X=y(pt,ae.props),X.ref=Hl(re,pt,ae),X.return=re,re=X;break e}c(re,pt);break}else i(re,pt);pt=pt.sibling}ae.type===R?(X=Mi(ae.props.children,re.mode,Ee,ae.key),X.return=re,re=X):(Ee=mu(ae.type,ae.key,ae.props,null,re.mode,Ee),Ee.ref=Hl(re,X,ae),Ee.return=re,re=Ee)}return E(re);case O:e:{for(pt=ae.key;X!==null;){if(X.key===pt)if(X.tag===4&&X.stateNode.containerInfo===ae.containerInfo&&X.stateNode.implementation===ae.implementation){c(re,X.sibling),X=y(X,ae.children||[]),X.return=re,re=X;break e}else{c(re,X);break}else i(re,X);X=X.sibling}X=Bf(ae,re.mode,Ee),X.return=re,re=X}return E(re);case K:return pt=ae._init,Us(re,X,pt(ae._payload),Ee)}if(qt(ae))return Je(re,X,ae,Ee);if(A(ae))return et(re,X,ae,Ee);Bd(re,ae)}return typeof ae=="string"&&ae!==""||typeof ae=="number"?(ae=""+ae,X!==null&&X.tag===6?(c(re,X.sibling),X=y(X,ae),X.return=re,re=X):(c(re,X),X=zf(ae,re.mode,Ee),X.return=re,re=X),E(re)):c(re,X)}return Us}var wo=ny(!0),ry=ny(!1),Vd=Ha(null),qd=null,bo=null,Yh=null;function Zh(){Yh=bo=qd=null}function Xh(r){var i=Vd.current;js(Vd),r._currentValue=i}function Jh(r,i,c){for(;r!==null;){var p=r.alternate;if((r.childLanes&i)!==i?(r.childLanes|=i,p!==null&&(p.childLanes|=i)):p!==null&&(p.childLanes&i)!==i&&(p.childLanes|=i),r===c)break;r=r.return}}function No(r,i){qd=r,Yh=bo=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&i)!==0&&(qn=!0),r.firstContext=null)}function hr(r){var i=r._currentValue;if(Yh!==r)if(r={context:r,memoizedValue:i,next:null},bo===null){if(qd===null)throw Error(n(308));bo=r,qd.dependencies={lanes:0,firstContext:r}}else bo=bo.next=r;return i}var Ei=null;function ef(r){Ei===null?Ei=[r]:Ei.push(r)}function ay(r,i,c,p){var y=i.interleaved;return y===null?(c.next=c,ef(i)):(c.next=y.next,y.next=c),i.interleaved=c,ya(r,p)}function ya(r,i){r.lanes|=i;var c=r.alternate;for(c!==null&&(c.lanes|=i),c=r,r=r.return;r!==null;)r.childLanes|=i,c=r.alternate,c!==null&&(c.childLanes|=i),c=r,r=r.return;return c.tag===3?c.stateNode:null}var Ga=!1;function tf(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function iy(r,i){r=r.updateQueue,i.updateQueue===r&&(i.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function ja(r,i){return{eventTime:r,lane:i,tag:0,payload:null,callback:null,next:null}}function Ya(r,i,c){var p=r.updateQueue;if(p===null)return null;if(p=p.shared,(Qt&2)!==0){var y=p.pending;return y===null?i.next=i:(i.next=y.next,y.next=i),p.pending=i,ya(r,c)}return y=p.interleaved,y===null?(i.next=i,ef(p)):(i.next=y.next,y.next=i),p.interleaved=i,ya(r,c)}function Kd(r,i,c){if(i=i.updateQueue,i!==null&&(i=i.shared,(c&4194240)!==0)){var p=i.lanes;p&=r.pendingLanes,c|=p,i.lanes=c,ph(r,c)}}function oy(r,i){var c=r.updateQueue,p=r.alternate;if(p!==null&&(p=p.updateQueue,c===p)){var y=null,S=null;if(c=c.firstBaseUpdate,c!==null){do{var E={eventTime:c.eventTime,lane:c.lane,tag:c.tag,payload:c.payload,callback:c.callback,next:null};S===null?y=S=E:S=S.next=E,c=c.next}while(c!==null);S===null?y=S=i:S=S.next=i}else y=S=i;c={baseState:p.baseState,firstBaseUpdate:y,lastBaseUpdate:S,shared:p.shared,effects:p.effects},r.updateQueue=c;return}r=c.lastBaseUpdate,r===null?c.firstBaseUpdate=i:r.next=i,c.lastBaseUpdate=i}function Hd(r,i,c,p){var y=r.updateQueue;Ga=!1;var S=y.firstBaseUpdate,E=y.lastBaseUpdate,q=y.shared.pending;if(q!==null){y.shared.pending=null;var G=q,ie=G.next;G.next=null,E===null?S=ie:E.next=ie,E=G;var ve=r.alternate;ve!==null&&(ve=ve.updateQueue,q=ve.lastBaseUpdate,q!==E&&(q===null?ve.firstBaseUpdate=ie:q.next=ie,ve.lastBaseUpdate=G))}if(S!==null){var Se=y.baseState;E=0,ve=ie=G=null,q=S;do{var ge=q.lane,Ke=q.eventTime;if((p&ge)===ge){ve!==null&&(ve=ve.next={eventTime:Ke,lane:0,tag:q.tag,payload:q.payload,callback:q.callback,next:null});e:{var Je=r,et=q;switch(ge=i,Ke=c,et.tag){case 1:if(Je=et.payload,typeof Je=="function"){Se=Je.call(Ke,Se,ge);break e}Se=Je;break e;case 3:Je.flags=Je.flags&-65537|128;case 0:if(Je=et.payload,ge=typeof Je=="function"?Je.call(Ke,Se,ge):Je,ge==null)break e;Se=W({},Se,ge);break e;case 2:Ga=!0}}q.callback!==null&&q.lane!==0&&(r.flags|=64,ge=y.effects,ge===null?y.effects=[q]:ge.push(q))}else Ke={eventTime:Ke,lane:ge,tag:q.tag,payload:q.payload,callback:q.callback,next:null},ve===null?(ie=ve=Ke,G=Se):ve=ve.next=Ke,E|=ge;if(q=q.next,q===null){if(q=y.shared.pending,q===null)break;ge=q,q=ge.next,ge.next=null,y.lastBaseUpdate=ge,y.shared.pending=null}}while(!0);if(ve===null&&(G=Se),y.baseState=G,y.firstBaseUpdate=ie,y.lastBaseUpdate=ve,i=y.shared.interleaved,i!==null){y=i;do E|=y.lane,y=y.next;while(y!==i)}else S===null&&(y.shared.lanes=0);Ai|=E,r.lanes=E,r.memoizedState=Se}}function ly(r,i,c){if(r=i.effects,i.effects=null,r!==null)for(i=0;i<r.length;i++){var p=r[i],y=p.callback;if(y!==null){if(p.callback=null,p=c,typeof y!="function")throw Error(n(191,y));y.call(p)}}}var Wl={},ea=Ha(Wl),Ql=Ha(Wl),Gl=Ha(Wl);function _i(r){if(r===Wl)throw Error(n(174));return r}function sf(r,i){switch(fs(Gl,i),fs(Ql,r),fs(ea,Wl),r=i.nodeType,r){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:$t(null,"");break;default:r=r===8?i.parentNode:i,i=r.namespaceURI||null,r=r.tagName,i=$t(i,r)}js(ea),fs(ea,i)}function So(){js(ea),js(Ql),js(Gl)}function cy(r){_i(Gl.current);
vendor: 4,284 bytes, line 6
6var i=_i(ea.current),c=$t(i,r.type);i!==c&&(fs(Ql,r),fs(ea,c))}function nf(r){Ql.current===r&&(js(ea),js(Ql))}var Ps=Ha(0);function Wd(r){for(var i=r;i!==null;){if(i.tag===13){var c=i.memoizedState;if(c!==null&&(c=c.dehydrated,c===null||c.data==="$?"||c.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var rf=[];function af(){for(var r=0;r<rf.length;r++)rf[r]._workInProgressVersionPrimary=null;rf.length=0}var Qd=P.ReactCurrentDispatcher,of=P.ReactCurrentBatchConfig,Ri=0,Ts=null,Ys=null,sn=null,Gd=!1,Yl=!1,Zl=0,pP=0;function wn(){throw Error(n(321))}function lf(r,i){if(i===null)return!1;for(var c=0;c<i.length&&c<r.length;c++)if(!Pr(r[c],i[c]))return!1;return!0}function cf(r,i,c,p,y,S){if(Ri=S,Ts=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,Qd.current=r===null||r.memoizedState===null?yP:jP,r=c(p,y),Yl){S=0;do{if(Yl=!1,Zl=0,25<=S)throw Error(n(301));S+=1,sn=Ys=null,i.updateQueue=null,Qd.current=wP,r=c(p,y)}while(Yl)}if(Qd.current=Xd,i=Ys!==null&&Ys.next!==null,Ri=0,sn=Ys=Ts=null,Gd=!1,i)throw Error(n(300));return r}function df(){var r=Zl!==0;return Zl=0,r}function ta(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return sn===null?Ts.memoizedState=sn=r:sn=sn.next=r,sn}function fr(){if(Ys===null){var r=Ts.alternate;r=r!==null?r.memoizedState:null}else r=Ys.next;var i=sn===null?Ts.memoizedState:sn.next;if(i!==null)sn=i,Ys=r;else{if(r===null)throw Error(n(310));Ys=r,r={memoizedState:Ys.memoizedState,baseState:Ys.baseState,baseQueue:Ys.baseQueue,queue:Ys.queue,next:null},sn===null?Ts.memoizedState=sn=r:sn=sn.next=r}return sn}function Xl(r,i){return typeof i=="function"?i(r):i}function uf(r){var i=fr(),c=i.queue;if(c===null)throw Error(n(311));c.lastRenderedReducer=r;var p=Ys,y=p.baseQueue,S=c.pending;if(S!==null){if(y!==null){var E=y.next;y.next=S.next,S.next=E}p.baseQueue=y=S,c.pending=null}if(y!==null){S=y.next,p=p.baseState;var q=E=null,G=null,ie=S;do{var ve=ie.lane;if((Ri&ve)===ve)G!==null&&(G=G.next={lane:0,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null}),p=ie.hasEagerState?ie.eagerState:r(p,ie.action);else{var Se={lane:ve,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null};G===null?(q=G=Se,E=p):G=G.next=Se,Ts.lanes|=ve,Ai|=ve}ie=ie.next}while(ie!==null&&ie!==S);G===null?E=p:G.next=q,Pr(p,i.memoizedState)||(qn=!0),i.memoizedState=p,i.baseState=E,i.baseQueue=G,c.lastRenderedState=p}if(r=c.interleaved,r!==null){y=r;do S=y.lane,Ts.lanes|=S,Ai|=S,y=y.next;while(y!==r)}else y===null&&(c.lanes=0);return[i.memoizedState,c.dispatch]}function mf(r){var i=fr(),c=i.queue;if(c===null)throw Error(n(311));c.lastRenderedReducer=r;var p=c.dispatch,y=c.pending,S=i.memoizedState;if(y!==null){c.pending=null;var E=y=y.next;do S=r(S,E.action),E=E.next;while(E!==y);Pr(S,i.memoizedState)||(qn=!0),i.memoizedState=S,i.baseQueue===null&&(i.baseState=S),c.lastRenderedState=S}return[S,p]}function dy(){}function uy(r,i){var c=Ts,p=fr(),y=i(),S=!Pr(p.memoizedState,y);if(S&&(p.memoizedState=y,qn=!0),p=p.queue,hf(fy.bind(null,c,p,r),[r]),p.getSnapshot!==i||S||sn!==null&&sn.memoizedState.tag&1){if(c.flags|=2048,Jl(9,hy.bind(null,c,p,y,i),void 0,null),nn===null)throw Error(n(349));(Ri&30)!==0||my(c,i,y)}return y}function my(r,i,c){r.flags|=16384,r={getSnapshot:i,value:c},i=Ts.updateQueue,i===null?(i={lastEffect:null,stores:null},Ts.updateQueue=i,i.stores=[r]):(c=i.stores,c===null?i.stores=[r]:c.push(r))}function hy(r,i,c,p){i.value=c,i.getSnapshot=p,py(i)&&gy(r)}function fy(r,i,c){return c(function(){py(i)&&gy(r)})}function py(r){var i=r.getSnapshot;r=r.value;try{var c=i();return!Pr(r,c)}catch{return!0}}function gy(r){var i=ya(r,1);i!==null&&Ar(i,r,1,-1)}function xy(r){var i=ta();return typeof r=="function"&&(r=r()),i.memoizedState=i.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Xl,lastRenderedState:r},i.queue=r,r=r.dispatch=vP.bind(null,Ts,r),[i.memoizedState,r]}function Jl(r,i,c,p){return r={tag:r,create:i,destroy:c,deps:p,next:null}
vendor: 10,882 bytes, lines 6-8
6,i=Ts.updateQueue,i===null?(i={lastEffect:null,stores:null},Ts.updateQueue=i,i.lastEffect=r.next=r):(c=i.lastEffect,c===null?i.lastEffect=r.next=r:(p=c.next,c.next=r,r.next=p,i.lastEffect=r)),r}function vy(){return fr().memoizedState}function Yd(r,i,c,p){var y=ta();Ts.flags|=r,y.memoizedState=Jl(1|i,c,void 0,p===void 0?null:p)}function Zd(r,i,c,p){var y=fr();p=p===void 0?null:p;var S=void 0;if(Ys!==null){var E=Ys.memoizedState;if(S=E.destroy,p!==null&&lf(p,E.deps)){y.memoizedState=Jl(i,c,S,p);return}}Ts.flags|=r,y.memoizedState=Jl(1|i,c,S,p)}function yy(r,i){return Yd(8390656,8,r,i)}function hf(r,i){return Zd(2048,8,r,i)}function jy(r,i){return Zd(4,2,r,i)}function wy(r,i){return Zd(4,4,r,i)}function by(r,i){if(typeof i=="function")return r=r(),i(r),function(){i(null)};if(i!=null)return r=r(),i.current=r,function(){i.current=null}}function Ny(r,i,c){return c=c!=null?c.concat([r]):null,Zd(4,4,by.bind(null,i,r),c)}function ff(){}function Sy(r,i){var c=fr();i=i===void 0?null:i;var p=c.memoizedState;return p!==null&&i!==null&&lf(i,p[1])?p[0]:(c.memoizedState=[r,i],r)}function Cy(r,i){var c=fr();i=i===void 0?null:i;var p=c.memoizedState;return p!==null&&i!==null&&lf(i,p[1])?p[0]:(r=r(),c.memoizedState=[r,i],r)}function ky(r,i,c){return(Ri&21)===0?(r.baseState&&(r.baseState=!1,qn=!0),r.memoizedState=c):(Pr(c,i)||(c=sv(),Ts.lanes|=c,Ai|=c,r.baseState=!0),i)}function gP(r,i){var c=ns;ns=c!==0&&4>c?c:4,r(!0);var p=of.transition;of.transition={};try{r(!1),i()}finally{ns=c,of.transition=p}}function Py(){return fr().memoizedState}function xP(r,i,c){var p=ei(r);if(c={lane:p,action:c,hasEagerState:!1,eagerState:null,next:null},Ty(r))Ey(i,c);else if(c=ay(r,i,c,p),c!==null){var y=In();Ar(c,r,p,y),_y(c,i,p)}}function vP(r,i,c){var p=ei(r),y={lane:p,action:c,hasEagerState:!1,eagerState:null,next:null};if(Ty(r))Ey(i,y);else{var S=r.alternate;if(r.lanes===0&&(S===null||S.lanes===0)&&(S=i.lastRenderedReducer,S!==null))try{var E=i.lastRenderedState,q=S(E,c);if(y.hasEagerState=!0,y.eagerState=q,Pr(q,E)){var G=i.interleaved;G===null?(y.next=y,ef(i)):(y.next=G.next,G.next=y),i.interleaved=y;return}}catch{}c=ay(r,i,y,p),c!==null&&(y=In(),Ar(c,r,p,y),_y(c,i,p))}}function Ty(r){var i=r.alternate;return r===Ts||i!==null&&i===Ts}function Ey(r,i){Yl=Gd=!0;var c=r.pending;c===null?i.next=i:(i.next=c.next,c.next=i),r.pending=i}function _y(r,i,c){if((c&4194240)!==0){var p=i.lanes;p&=r.pendingLanes,c|=p,i.lanes=c,ph(r,c)}}var Xd={readContext:hr,useCallback:wn,useContext:wn,useEffect:wn,useImperativeHandle:wn,useInsertionEffect:wn,useLayoutEffect:wn,useMemo:wn,useReducer:wn,useRef:wn,useState:wn,useDebugValue:wn,useDeferredValue:wn,useTransition:wn,useMutableSource:wn,useSyncExternalStore:wn,useId:wn,unstable_isNewReconciler:!1},yP={readContext:hr,useCallback:function(r,i){return ta().memoizedState=[r,i===void 0?null:i],r},useContext:hr,useEffect:yy,useImperativeHandle:function(r,i,c){return c=c!=null?c.concat([r]):null,Yd(4194308,4,by.bind(null,i,r),c)},useLayoutEffect:function(r,i){return Yd(4194308,4,r,i)},useInsertionEffect:function(r,i){return Yd(4,2,r,i)},useMemo:function(r,i){var c=ta();return i=i===void 0?null:i,r=r(),c.memoizedState=[r,i],r},useReducer:function(r,i,c){var p=ta();return i=c!==void 0?c(i):i,p.memoizedState=p.baseState=i,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:i},p.queue=r,r=r.dispatch=xP.bind(null,Ts,r),[p.memoizedState,r]},useRef:function(r){var i=ta();return r={current:r},i.memoizedState=r},useState:xy,useDebugValue:ff,useDeferredValue:function(r){return ta().memoizedState=r},useTransition:function(){var r=xy(!1),i=r[0];return r=gP.bind(null,r[1]),ta().memoizedState=r,[i,r]},useMutableSource:function(){},useSyncExternalStore:function(r,i,c){var p=Ts,y=ta();if(Ns){if(c===void 0)throw Error(n(407));c=c()}else{if(c=i(),nn===null)throw Error(n(349));(Ri&30)!==0||my(p,i,c)}y.memoizedState=c;var S={value:c,getSnapshot:i};return y.queue=S,yy(fy.bind(null,p,S,r),[r]),p.flags|=2048,Jl(9,hy.bind(null,p,S,c,i),void 0,null),c},useId:function(){var r=ta(),i=nn.identifierPrefix;if(Ns){var c=va,p=xa;c=(p&~(1<<32-kr(p)-1)).toString(32)+c,i=":"+i+"R"+c,c=Zl++,0<c&&(i+="H"+c.toString(32)),i+=":"}else c=pP++,i=":"+i+"r"+c.toString(32)+":";return r.memoizedState=i},unstable_isNewReconciler:!1},jP={readContext:hr,useCallback:Sy,useContext:hr,useEffect:hf,useImperativeHandle:Ny,useInsertionEffect:jy,useLayoutEffect:wy,useMemo:Cy,useReducer:uf,useRef:vy,useState:function(){return uf(Xl)},useDebugValue:ff,useDeferredValue:function(r){var i=fr();return ky(i,Ys.memoizedState,r)},useTransition:function(){var r=uf(Xl)[0],i=fr().memoizedState;return[r,i]},useMutableSource:dy,useSyncExternalStore:uy,useId:Py,unstable_isNewReconciler:!1},wP={readContext:hr,useCallback:Sy,useContext:hr,useEffect:hf,useImperativeHandle:Ny,useInsertionEffect:jy,useLayoutEffect:wy,useMemo:Cy,useReducer:mf,useRef:vy,useState:function(){return mf(Xl)},useDebugValue:ff,useDeferredValue:function(r){var i=fr();return Ys===null?i.memoizedState=r:ky(i,Ys.memoizedState,r)},useTransition:function(){var r=mf(Xl)[0],i=fr().memoizedState;return[r,i]},useMutableSource:dy,useSyncExternalStore:uy,useId:Py,unstable_isNewReconciler:!1};function Er(r,i){if(r&&r.defaultProps){i=W({},i),r=r.defaultProps;for(var c in r)i[c]===void 0&&(i[c]=r[c]);return i}return i}function pf(r,i,c,p){i=r.memoizedState,c=c(p,i),c=c==null?i:W({},i,c),r.memoizedState=c,r.lanes===0&&(r.updateQueue.baseState=c)}var Jd={isMounted:function(r){return(r=r._reactInternals)?De(r)===r:!1},enqueueSetState:function(r,i,c){r=r._reactInternals;var p=In(),y=ei(r),S=ja(p,y);S.payload=i,c!=null&&(S.callback=c),i=Ya(r,S,y),i!==null&&(Ar(i,r,y,p),Kd(i,r,y))},enqueueReplaceState:function(r,i,c){r=r._reactInternals;var p=In(),y=ei(r),S=ja(p,y);S.tag=1,S.payload=i,c!=null&&(S.callback=c),i=Ya(r,S,y),i!==null&&(Ar(i,r,y,p),Kd(i,r,y))},enqueueForceUpdate:function(r,i){r=r._reactInternals;var c=In(),p=ei(r),y=ja(c,p);y.tag=2,i!=null&&(y.callback=i),i=Ya(r,y,p),i!==null&&(Ar(i,r,p,c),Kd(i,r,p))}};function Ry(r,i,c,p,y,S,E){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(p,S,E):i.prototype&&i.prototype.isPureReactComponent?!$l(c,p)||!$l(y,S):!0}function Ay(r,i,c){var p=!1,y=Wa,S=i.contextType;return typeof S=="object"&&S!==null?S=hr(S):(y=Vn(i)?ki:jn.current,p=i.contextTypes,S=(p=p!=null)?xo(r,y):Wa),i=new i(c,S),r.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=Jd,r.stateNode=i,i._reactInternals=r,p&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=y,r.__reactInternalMemoizedMaskedChildContext=S),i}function Iy(r,i,c,p){r=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(c,p),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(c,p),i.state!==r&&Jd.enqueueReplaceState(i,i.state,null)}function gf(r,i,c,p){var y=r.stateNode;y.props=c,y.state=r.memoizedState,y.refs={},tf(r);var S=i.contextType;typeof S=="object"&&S!==null?y.context=hr(S):(S=Vn(i)?ki:jn.current,y.context=xo(r,S)),y.state=r.memoizedState,S=i.getDerivedStateFromProps,typeof S=="function"&&(pf(r,i,S,c),y.state=r.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(i=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),i!==y.state&&Jd.enqueueReplaceState(y,y.state,null),Hd(r,c,y,p),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308)}function Co(r,i){try{var c="",p=i;do c+=Ie(p),p=p.return;while(p);var y=c}catch(S){y=`
7Error generating stack: `+S.message+`
8`+S.stack}return{value:r,source:i,stack:y,digest:null}}function xf(r,i,c){return{value:r,source:null,stack:c??null,digest:i??null}}function vf(r,i){try{console.error(i.value)}catch(c){setTimeout(function(){throw c})}}var bP=typeof WeakMap=="function"?WeakMap:Map;function Dy(r,i,c){c=ja(-1,c),c.tag=3,c.payload={element:null};var p=i.value;return c.callback=function(){iu||(iu=!0,If=p),vf(r,i)},c}function Oy(r,i,c){c=ja(-1,c),c.tag=3;var p=r.type.getDerivedStateFromError;if(typeof p=="function"){var y=i.value;c.payload=function(){return p(y)},c.callback=function(){vf(r,i)}}var S=r.stateNode;return S!==null&&typeof S.componentDidCatch=="function"&&(c.callback=function(){vf(r,i),typeof p!="function"&&(Xa===null?Xa=new Set([this]):Xa.add(this));var E=i.stack;this.componentDidCatch(i.value,{componentStack:E!==null?E:""})}),c}function My(r,i,c){var p=r.pingCache;if(p===null){p=r.pingCache=new bP;var y=new Set;p.set(i,y)}else y=p.get(i),y===void 0&&(y=new Set,p.set(i,y));y.has(c)||(y.add(c),r=MP.bind(null,r,i,c),i.then(r,r))}function Ly(r){do{var i;if((i=r.tag===13)&&(i=r.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return r;r=r.return}while(r!==null);return null}function Fy(r,i,c,p,y){return(r.mode&1)===0?(r===i?r.flags|=65536:(r.flags|=128,c.flags|=131072,c.flags&=-52805,c.tag===1&&(c.alternate===null?c.tag=17:(i=ja(-1,1),i.tag=2,Ya(c,i,1))),c.lanes|=1),r):(r.flags|=65536,r.lanes=y,r)}var NP=P.ReactCurrentOwner,qn=!1;function An(r,i,c,p){i.child=r===null?ry(i,null,c,p):wo(i,r.child,c,p)}function $y(r,i,c,p,y){c=c.render;var S=i.ref;return No(i,y),p=cf(r,i,c,p,S,y),c=df(),r!==null&&!qn?(i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~y,wa(r,i,y)):(Ns&&c&&Kh(i),i.flags|=1,An(r,i,p,y),i.child)}function Uy(r,i,c,p,y){if(r===null){var S=c.type;return typeof S=="function"&&!Uf(S)&&S.defaultProps===void 0&&c.compare===null&&c.defaultProps===void 0?(i.tag=15,i.type=S,zy(r,i,S,p,y)):(r=mu(c.type,null,p,i,i.mode,y),r.ref=i.ref,r.return=i,i.child=r)}if(S=r.child,(r.lanes&y)===0){var E=S.memoizedProps;if(c=c.compare,c=c!==null?c:$l,c(E,p)&&r.ref===i.ref)return wa(r,i,y)}return i.flags|=1,r=si(S,p),r.ref=i.ref,r.return=i,i.child=r}function zy(r,i,c,p,y){if(r!==null){var S=r.memoizedProps;if($l(S,p)&&r.ref===i.ref)if(qn=!1,i.pendingProps=p=S,(r.lanes&y)!==0)(r.flags&131072)!==0&&(qn=!0);else return i.lanes=r.lanes,wa(r,i,y)}return yf(r,i,c,p,y)}function By(r,i,c){var p=i.pendingProps,y=p.children,S=r!==null?r.memoizedState:null;if(p.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},fs(Po,rr),rr|=c;else{if((c&1073741824)===0)return r=S!==null?S.baseLanes|c:c,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:r,cachePool:null,transitions:null},i.updateQueue=null,fs(Po,rr),rr|=r,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},p=S!==null?S.baseLanes:c,fs(Po,rr),rr|=p}else S!==null?(p=S.baseLanes|c,i.memoizedState=null):p=c,fs(Po,rr),rr|=p;return An(r,i,y,c),i.child}function Vy(r,i){var c=i.ref;(r===null&&c!==null||r!==null&&r.ref!==c)&&(i.flags|=512,i.flags|=2097152)}
vendor: 4,310 bytes, line 8
8function yf(r,i,c,p,y){var S=Vn(c)?ki:jn.current;return S=xo(i,S),No(i,y),c=cf(r,i,c,p,S,y),p=df(),r!==null&&!qn?(i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~y,wa(r,i,y)):(Ns&&p&&Kh(i),i.flags|=1,An(r,i,c,y),i.child)}function qy(r,i,c,p,y){if(Vn(c)){var S=!0;Ld(i)}else S=!1;if(No(i,y),i.stateNode===null)tu(r,i),Ay(i,c,p),gf(i,c,p,y),p=!0;else if(r===null){var E=i.stateNode,q=i.memoizedProps;E.props=q;var G=E.context,ie=c.contextType;typeof ie=="object"&&ie!==null?ie=hr(ie):(ie=Vn(c)?ki:jn.current,ie=xo(i,ie));var ve=c.getDerivedStateFromProps,Se=typeof ve=="function"||typeof E.getSnapshotBeforeUpdate=="function";Se||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(q!==p||G!==ie)&&Iy(i,E,p,ie),Ga=!1;var ge=i.memoizedState;E.state=ge,Hd(i,p,E,y),G=i.memoizedState,q!==p||ge!==G||Bn.current||Ga?(typeof ve=="function"&&(pf(i,c,ve,p),G=i.memoizedState),(q=Ga||Ry(i,c,q,p,ge,G,ie))?(Se||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount()),typeof E.componentDidMount=="function"&&(i.flags|=4194308)):(typeof E.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=p,i.memoizedState=G),E.props=p,E.state=G,E.context=ie,p=q):(typeof E.componentDidMount=="function"&&(i.flags|=4194308),p=!1)}else{E=i.stateNode,iy(r,i),q=i.memoizedProps,ie=i.type===i.elementType?q:Er(i.type,q),E.props=ie,Se=i.pendingProps,ge=E.context,G=c.contextType,typeof G=="object"&&G!==null?G=hr(G):(G=Vn(c)?ki:jn.current,G=xo(i,G));var Ke=c.getDerivedStateFromProps;(ve=typeof Ke=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(q!==Se||ge!==G)&&Iy(i,E,p,G),Ga=!1,ge=i.memoizedState,E.state=ge,Hd(i,p,E,y);var Je=i.memoizedState;q!==Se||ge!==Je||Bn.current||Ga?(typeof Ke=="function"&&(pf(i,c,Ke,p),Je=i.memoizedState),(ie=Ga||Ry(i,c,ie,p,ge,Je,G)||!1)?(ve||typeof E.UNSAFE_componentWillUpdate!="function"&&typeof E.componentWillUpdate!="function"||(typeof E.componentWillUpdate=="function"&&E.componentWillUpdate(p,Je,G),typeof E.UNSAFE_componentWillUpdate=="function"&&E.UNSAFE_componentWillUpdate(p,Je,G)),typeof E.componentDidUpdate=="function"&&(i.flags|=4),typeof E.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof E.componentDidUpdate!="function"||q===r.memoizedProps&&ge===r.memoizedState||(i.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||q===r.memoizedProps&&ge===r.memoizedState||(i.flags|=1024),i.memoizedProps=p,i.memoizedState=Je),E.props=p,E.state=Je,E.context=G,p=ie):(typeof E.componentDidUpdate!="function"||q===r.memoizedProps&&ge===r.memoizedState||(i.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||q===r.memoizedProps&&ge===r.memoizedState||(i.flags|=1024),p=!1)}return jf(r,i,c,p,S,y)}function jf(r,i,c,p,y,S){Vy(r,i);var E=(i.flags&128)!==0;if(!p&&!E)return y&&Gv(i,c,!1),wa(r,i,S);p=i.stateNode,NP.current=i;var q=E&&typeof c.getDerivedStateFromError!="function"?null:p.render();return i.flags|=1,r!==null&&E?(i.child=wo(i,r.child,null,S),i.child=wo(i,null,q,S)):An(r,i,q,S),i.memoizedState=p.state,y&&Gv(i,c,!0),i.child}function Ky(r){var i=r.stateNode;i.pendingContext?Wv(r,i.pendingContext,i.pendingContext!==i.context):i.context&&Wv(r,i.context,!1),sf(r,i.containerInfo)}function Hy(r,i,c,p,y){return jo(),Gh(y),i.flags|=256,An(r,i,c,p),i.child}var wf={dehydrated:null,treeContext:null,retryLane:0};function bf(r){return{baseLanes:r,cachePool:null,transitions:null}}function Wy(r,i,c){var p=i.pendingProps,y=Ps.current,S=!1,E=(i.flags&128)!==0,q;if((q=E)||(q=r!==null&&r.memoizedState===null?!1:(y&2)!==0),q?(S=!0,i.flags&=-129):(r===null||r.memoizedState!==null)&&(y|=1),fs(Ps,y&1),r===null)return Qh(i),r=i.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((i.mode&1)===0?i.lanes=1:r.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(E=p.children,r=p.fallback,S?(p=i.mode,S=i.child,E={mode:"hidden",children:E},(p&1)===0&&S!==null?(S.childLanes=0,S.pendingProps=E):S=hu(E,p,0,null),r=Mi(r,p,c,null),S.return=i,r.return=i,S.sibling=r,i.child=S,i.child.memoizedState=bf(c),i.memoizedState=wf,r):Nf(i,E));
vendor: 6,987 bytes, line 8
8if(y=r.memoizedState,y!==null&&(q=y.dehydrated,q!==null))return SP(r,i,E,p,q,y,c);if(S){S=p.fallback,E=i.mode,y=r.child,q=y.sibling;var G={mode:"hidden",children:p.children};return(E&1)===0&&i.child!==y?(p=i.child,p.childLanes=0,p.pendingProps=G,i.deletions=null):(p=si(y,G),p.subtreeFlags=y.subtreeFlags&14680064),q!==null?S=si(q,S):(S=Mi(S,E,c,null),S.flags|=2),S.return=i,p.return=i,p.sibling=S,i.child=p,p=S,S=i.child,E=r.child.memoizedState,E=E===null?bf(c):{baseLanes:E.baseLanes|c,cachePool:null,transitions:E.transitions},S.memoizedState=E,S.childLanes=r.childLanes&~c,i.memoizedState=wf,p}return S=r.child,r=S.sibling,p=si(S,{mode:"visible",children:p.children}),(i.mode&1)===0&&(p.lanes=c),p.return=i,p.sibling=null,r!==null&&(c=i.deletions,c===null?(i.deletions=[r],i.flags|=16):c.push(r)),i.child=p,i.memoizedState=null,p}function Nf(r,i){return i=hu({mode:"visible",children:i},r.mode,0,null),i.return=r,r.child=i}function eu(r,i,c,p){return p!==null&&Gh(p),wo(i,r.child,null,c),r=Nf(i,i.pendingProps.children),r.flags|=2,i.memoizedState=null,r}function SP(r,i,c,p,y,S,E){if(c)return i.flags&256?(i.flags&=-257,p=xf(Error(n(422))),eu(r,i,E,p)):i.memoizedState!==null?(i.child=r.child,i.flags|=128,null):(S=p.fallback,y=i.mode,p=hu({mode:"visible",children:p.children},y,0,null),S=Mi(S,y,E,null),S.flags|=2,p.return=i,S.return=i,p.sibling=S,i.child=p,(i.mode&1)!==0&&wo(i,r.child,null,E),i.child.memoizedState=bf(E),i.memoizedState=wf,S);if((i.mode&1)===0)return eu(r,i,E,null);if(y.data==="$!"){if(p=y.nextSibling&&y.nextSibling.dataset,p)var q=p.dgst;return p=q,S=Error(n(419)),p=xf(S,p,void 0),eu(r,i,E,p)}if(q=(E&r.childLanes)!==0,qn||q){if(p=nn,p!==null){switch(E&-E){case 4:y=2;break;case 16:y=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:y=32;break;case 536870912:y=268435456;break;default:y=0}y=(y&(p.suspendedLanes|E))!==0?0:y,y!==0&&y!==S.retryLane&&(S.retryLane=y,ya(r,y),Ar(p,r,y,-1))}return $f(),p=xf(Error(n(421))),eu(r,i,E,p)}return y.data==="$?"?(i.flags|=128,i.child=r.child,i=LP.bind(null,r),y._reactRetry=i,null):(r=S.treeContext,nr=Ka(y.nextSibling),sr=i,Ns=!0,Tr=null,r!==null&&(ur[mr++]=xa,ur[mr++]=va,ur[mr++]=Pi,xa=r.id,va=r.overflow,Pi=i),i=Nf(i,p.children),i.flags|=4096,i)}function Qy(r,i,c){r.lanes|=i;var p=r.alternate;p!==null&&(p.lanes|=i),Jh(r.return,i,c)}function Sf(r,i,c,p,y){var S=r.memoizedState;S===null?r.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:p,tail:c,tailMode:y}:(S.isBackwards=i,S.rendering=null,S.renderingStartTime=0,S.last=p,S.tail=c,S.tailMode=y)}function Gy(r,i,c){var p=i.pendingProps,y=p.revealOrder,S=p.tail;if(An(r,i,p.children,c),p=Ps.current,(p&2)!==0)p=p&1|2,i.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=i.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Qy(r,c,i);else if(r.tag===19)Qy(r,c,i);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}p&=1}if(fs(Ps,p),(i.mode&1)===0)i.memoizedState=null;else switch(y){case"forwards":for(c=i.child,y=null;c!==null;)r=c.alternate,r!==null&&Wd(r)===null&&(y=c),c=c.sibling;c=y,c===null?(y=i.child,i.child=null):(y=c.sibling,c.sibling=null),Sf(i,!1,y,c,S);break;case"backwards":for(c=null,y=i.child,i.child=null;y!==null;){if(r=y.alternate,r!==null&&Wd(r)===null){i.child=y;break}r=y.sibling,y.sibling=c,c=y,y=r}Sf(i,!0,c,null,S);break;case"together":Sf(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function tu(r,i){(i.mode&1)===0&&r!==null&&(r.alternate=null,i.alternate=null,i.flags|=2)}function wa(r,i,c){if(r!==null&&(i.dependencies=r.dependencies),Ai|=i.lanes,(c&i.childLanes)===0)return null;if(r!==null&&i.child!==r.child)throw Error(n(153));if(i.child!==null){for(r=i.child,c=si(r,r.pendingProps),i.child=c,c.return=i;r.sibling!==null;)r=r.sibling,c=c.sibling=si(r,r.pendingProps),c.return=i;c.sibling=null}return i.child}function CP(r,i,c){switch(i.tag){case 3:Ky(i),jo();break;case 5:cy(i);break;case 1:Vn(i.type)&&Ld(i);break;case 4:sf(i,i.stateNode.containerInfo);break;case 10:var p=i.type._context,y=i.memoizedProps.value;fs(Vd,p._currentValue),p._currentValue=y;break;case 13:if(p=i.memoizedState,p!==null)return p.dehydrated!==null?(fs(Ps,Ps.current&1),i.flags|=128,null):(c&i.child.childLanes)!==0?Wy(r,i,c):(fs(Ps,Ps.current&1),r=wa(r,i,c),r!==null?r.sibling:null);fs(Ps,Ps.current&1);break;case 19:if(p=(c&i.childLanes)!==0,(r.flags&128)!==0){if(p)return Gy(r,i,c);i.flags|=128}if(y=i.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),fs(Ps,Ps.current),p)break;return null;case 22:case 23:return i.lanes=0,By(r,i,c)}return wa(r,i,c)}var Yy,Cf,Zy,Xy;Yy=function(r,i){for(var c=i.child;c!==null;){if(c.tag===5||c.tag===6)r.appendChild(c.stateNode);else if(c.tag!==4&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===i)break;for(;c.sibling===null;){if(c.return===null||c.return===i)return;c=c.return}c.sibling.return=c.return,c=c.sibling}},Cf=function(){},Zy=function(r,i,c,p){var y=r.memoizedProps;if(y!==p){r=i.stateNode,_i(ea.current);var S=null;switch(c){case"input":y=Ct(r,y),p=Ct(r,p),S=[];break;case"select":y=W({},y,{value:void 0}),p=W({},p,{value:void 0}),S=[];break;case"textarea":y=qs(r,y),p=qs(r,p),S=[];break;default:typeof y.onClick!="function"&&typeof p.onClick=="function"&&(r.onclick=Dd)}kt(c,p);var E;c=null;for(ie in y)if(!p.hasOwnProperty(ie)&&y.hasOwnProperty(ie)&&y[ie]!=null)if(ie==="style"){var q=y[ie];for(E in q)q.hasOwnProperty(E)&&(c||(c={}),c[E]="")}else ie!=="dangerouslySetInnerHTML"&&ie!=="children"&&ie!=="suppressContentEditableWarning"&&ie!=="suppressHydrationWarning"&&ie!=="autoFocus"&&(o.hasOwnProperty(ie)?S||(S=[]):(S=S||[]).push(ie,null));for(ie in p){var G=p[ie];if(q=y?.[ie],p.hasOwnProperty(ie)&&G!==q&&(G!=null||q!=null))if(ie==="style")if(q){for(E in q)!q.hasOwnProperty(E)||G&&G.hasOwnProperty(E)||(c||(c={}),c[E]="");for(E in G)G.hasOwnProperty(E)&&q[E]!==G[E]&&(c||(c={}),c[E]=G[E])}else c||(S||(S=[]),S.push(ie,c)),c=G;else ie==="dangerouslySetInnerHTML"?(G=G?G.__html:void 0,q=q?q.__html:void 0,G!=null&&q!==G&&(S=S||[]).push(ie,G)):ie==="children"?typeof G!="string"&&typeof G!="number"||(S=S||[]).push(ie,""+G):ie!=="suppressContentEditableWarning"&&ie!=="suppressHydrationWarning"&&(o.hasOwnProperty(ie)?(G!=null&&ie==="onScroll"&&ys("scroll",r),S||q===G||(S=[])):(S=S||[]).push(ie,G))}c&&(S=S||[]).push("style",c);var ie=S;(i.updateQueue=ie)&&(i.flags|=4)}},Xy=function(r,i,c,p){c!==p&&(i.flags|=4)};function ec(r,i){if(!Ns)switch(r.tailMode){case"hidden":i=r.tail;for(var c=null;i!==null;)i.alternate!==null&&(c=i),i=i.sibling;c===null?r.tail=null:c.sibling=null;break;case"collapsed":c=r.tail;for(var p=null;c!==null;)c.alternate!==null&&(p=c),c=c.sibling;
vendor: 8,769 bytes, line 8
8p===null?i||r.tail===null?r.tail=null:r.tail.sibling=null:p.sibling=null}}function bn(r){var i=r.alternate!==null&&r.alternate.child===r.child,c=0,p=0;if(i)for(var y=r.child;y!==null;)c|=y.lanes|y.childLanes,p|=y.subtreeFlags&14680064,p|=y.flags&14680064,y.return=r,y=y.sibling;else for(y=r.child;y!==null;)c|=y.lanes|y.childLanes,p|=y.subtreeFlags,p|=y.flags,y.return=r,y=y.sibling;return r.subtreeFlags|=p,r.childLanes=c,i}function kP(r,i,c){var p=i.pendingProps;switch(Hh(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bn(i),null;case 1:return Vn(i.type)&&Md(),bn(i),null;case 3:return p=i.stateNode,So(),js(Bn),js(jn),af(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(r===null||r.child===null)&&(zd(i)?i.flags|=4:r===null||r.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Tr!==null&&(Mf(Tr),Tr=null))),Cf(r,i),bn(i),null;case 5:nf(i);var y=_i(Gl.current);if(c=i.type,r!==null&&i.stateNode!=null)Zy(r,i,c,p,y),r.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!p){if(i.stateNode===null)throw Error(n(166));return bn(i),null}if(r=_i(ea.current),zd(i)){p=i.stateNode,c=i.type;var S=i.memoizedProps;switch(p[Jr]=i,p[ql]=S,r=(i.mode&1)!==0,c){case"dialog":ys("cancel",p),ys("close",p);break;case"iframe":case"object":case"embed":ys("load",p);break;case"video":case"audio":for(y=0;y<zl.length;y++)ys(zl[y],p);break;case"source":ys("error",p);break;case"img":case"image":case"link":ys("error",p),ys("load",p);break;case"details":ys("toggle",p);break;case"input":zt(p,S),ys("invalid",p);break;case"select":p._wrapperState={wasMultiple:!!S.multiple},ys("invalid",p);break;case"textarea":Ks(p,S),ys("invalid",p)}kt(c,S),y=null;for(var E in S)if(S.hasOwnProperty(E)){var q=S[E];E==="children"?typeof q=="string"?p.textContent!==q&&(S.suppressHydrationWarning!==!0&&Id(p.textContent,q,r),y=["children",q]):typeof q=="number"&&p.textContent!==""+q&&(S.suppressHydrationWarning!==!0&&Id(p.textContent,q,r),y=["children",""+q]):o.hasOwnProperty(E)&&q!=null&&E==="onScroll"&&ys("scroll",p)}switch(c){case"input":Me(p),Nt(p,S,!0);break;case"textarea":Me(p),vn(p);break;case"select":case"option":break;default:typeof S.onClick=="function"&&(p.onclick=Dd)}p=y,i.updateQueue=p,p!==null&&(i.flags|=4)}else{E=y.nodeType===9?y:y.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=Ls(c)),r==="http://www.w3.org/1999/xhtml"?c==="script"?(r=E.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof p.is=="string"?r=E.createElement(c,{is:p.is}):(r=E.createElement(c),c==="select"&&(E=r,p.multiple?E.multiple=!0:p.size&&(E.size=p.size))):r=E.createElementNS(r,c),r[Jr]=i,r[ql]=p,Yy(r,i,!1,!1),i.stateNode=r;e:{switch(E=xs(c,p),c){case"dialog":ys("cancel",r),ys("close",r),y=p;break;case"iframe":case"object":case"embed":ys("load",r),y=p;break;case"video":case"audio":for(y=0;y<zl.length;y++)ys(zl[y],r);y=p;break;case"source":ys("error",r),y=p;break;case"img":case"image":case"link":ys("error",r),ys("load",r),y=p;break;case"details":ys("toggle",r),y=p;break;case"input":zt(r,p),y=Ct(r,p),ys("invalid",r);break;case"option":y=p;break;case"select":r._wrapperState={wasMultiple:!!p.multiple},y=W({},p,{value:void 0}),ys("invalid",r);break;case"textarea":Ks(r,p),y=qs(r,p),ys("invalid",r);break;default:y=p}kt(c,y),q=y;for(S in q)if(q.hasOwnProperty(S)){var G=q[S];S==="style"?ms(r,G):S==="dangerouslySetInnerHTML"?(G=G?G.__html:void 0,G!=null&&Xe(r,G)):S==="children"?typeof G=="string"?(c!=="textarea"||G!=="")&&ne(r,G):typeof G=="number"&&ne(r,""+G):S!=="suppressContentEditableWarning"&&S!=="suppressHydrationWarning"&&S!=="autoFocus"&&(o.hasOwnProperty(S)?G!=null&&S==="onScroll"&&ys("scroll",r):G!=null&&T(r,S,G,E))}switch(c){case"input":Me(r),Nt(r,p,!1);break;case"textarea":Me(r),vn(r);break;case"option":p.value!=null&&r.setAttribute("value",""+Re(p.value));break;case"select":r.multiple=!!p.multiple,S=p.value,S!=null?us(r,!!p.multiple,S,!1):p.defaultValue!=null&&us(r,!!p.multiple,p.defaultValue,!0);break;default:typeof y.onClick=="function"&&(r.onclick=Dd)}switch(c){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break e;case"img":p=!0;break e;default:p=!1}}p&&(i.flags|=4)}i.ref!==null&&(i.flags|=512,i.flags|=2097152)}return bn(i),null;case 6:if(r&&i.stateNode!=null)Xy(r,i,r.memoizedProps,p);else{if(typeof p!="string"&&i.stateNode===null)throw Error(n(166));if(c=_i(Gl.current),_i(ea.current),zd(i)){if(p=i.stateNode,c=i.memoizedProps,p[Jr]=i,(S=p.nodeValue!==c)&&(r=sr,r!==null))switch(r.tag){case 3:Id(p.nodeValue,c,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&Id(p.nodeValue,c,(r.mode&1)!==0)}S&&(i.flags|=4)}else p=(c.nodeType===9?c:c.ownerDocument).createTextNode(p),p[Jr]=i,i.stateNode=p}return bn(i),null;case 13:if(js(Ps),p=i.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(Ns&&nr!==null&&(i.mode&1)!==0&&(i.flags&128)===0)ty(),jo(),i.flags|=98560,S=!1;else if(S=zd(i),p!==null&&p.dehydrated!==null){if(r===null){if(!S)throw Error(n(318));if(S=i.memoizedState,S=S!==null?S.dehydrated:null,!S)throw Error(n(317));S[Jr]=i}else jo(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;bn(i),S=!1}else Tr!==null&&(Mf(Tr),Tr=null),S=!0;if(!S)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=c,i):(p=p!==null,p!==(r!==null&&r.memoizedState!==null)&&p&&(i.child.flags|=8192,(i.mode&1)!==0&&(r===null||(Ps.current&1)!==0?Zs===0&&(Zs=3):$f())),i.updateQueue!==null&&(i.flags|=4),bn(i),null);case 4:return So(),Cf(r,i),r===null&&Bl(i.stateNode.containerInfo),bn(i),null;case 10:return Xh(i.type._context),bn(i),null;case 17:return Vn(i.type)&&Md(),bn(i),null;case 19:if(js(Ps),S=i.memoizedState,S===null)return bn(i),null;if(p=(i.flags&128)!==0,E=S.rendering,E===null)if(p)ec(S,!1);else{if(Zs!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(E=Wd(r),E!==null){for(i.flags|=128,ec(S,!1),p=E.updateQueue,p!==null&&(i.updateQueue=p,i.flags|=4),i.subtreeFlags=0,p=c,c=i.child;c!==null;)S=c,r=p,S.flags&=14680066,E=S.alternate,E===null?(S.childLanes=0,S.lanes=r,S.child=null,S.subtreeFlags=0,S.memoizedProps=null,S.memoizedState=null,S.updateQueue=null,S.dependencies=null,S.stateNode=null):(S.childLanes=E.childLanes,S.lanes=E.lanes,S.child=E.child,S.subtreeFlags=0,S.deletions=null,S.memoizedProps=E.memoizedProps,S.memoizedState=E.memoizedState,S.updateQueue=E.updateQueue,S.type=E.type,r=E.dependencies,S.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),c=c.sibling;return fs(Ps,Ps.current&1|2),i.child}r=r.sibling}S.tail!==null&&es()>To&&(i.flags|=128,p=!0,ec(S,!1),i.lanes=4194304)}else{if(!p)if(r=Wd(E),r!==null){if(i.flags|=128,p=!0,c=r.updateQueue,c!==null&&(i.updateQueue=c,i.flags|=4),ec(S,!0),S.tail===null&&S.tailMode==="hidden"&&!E.alternate&&!Ns)return bn(i),null}else 2*es()-S.renderingStartTime>To&&c!==1073741824&&(i.flags|=128,p=!0,ec(S,!1),i.lanes=4194304);S.isBackwards?(E.sibling=i.child,i.child=E):(c=S.last,c!==null?c.sibling=E:i.child=E,S.last=E)}return S.tail!==null?(i=S.tail,S.rendering=i,S.tail=i.sibling,S.renderingStartTime=es(),i.sibling=null,c=Ps.current,fs(Ps,p?c&1|2:c&1),i):(bn(i),null);case 22:case 23:return Ff(),p=i.memoizedState!==null,r!==null&&r.memoizedState!==null!==p&&(i.flags|=8192),p&&(i.mode&1)!==0?(rr&1073741824)!==0&&(bn(i),i.subtreeFlags&6&&(i.flags|=8192)):bn(i),null;case 24:return null;case 25:return null}throw Error(n(156,i.tag))}function PP(r,i){switch(Hh(i),i.tag){case 1:return Vn(i.type)&&Md(),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return So(),js(Bn),js(jn),af(),r=i.flags,(r&65536)!==0&&(r&128)===0?(i.flags=r&-65537|128,i):null;case 5:return nf(i),null;case 13:if(js(Ps),r=i.memoizedState,r!==null&&r.dehydrated!==null){if(i.alternate===null)throw Error(n(340));jo()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return js(Ps),null;case 4:return So(),null;case 10:return Xh(i.type._context),null;case 22:case 23:return Ff(),null;case 24:return null;default:return null}}var su=!1,Nn=!1,TP=typeof WeakSet=="function"?WeakSet:Set,Ye=null;function ko(r,i){var c=r.ref;if(c!==null)if(typeof c=="function")try{c(null)}catch(p){Ds(r,i,p)}else c.current=null}function kf(r,i,c){try{c()}catch(p){Ds(r,i,p)}}var Jy=!1;function EP(r,i){if(Lh=bd,r=Rv(),Eh(r)){if("selectionStart"in r)var c={start:r.selectionStart,end:r.selectionEnd};else e:{c=(c=r.ownerDocument)&&c.defaultView||window;var p=c.getSelection&&c.getSelection();if(p&&p.rangeCount!==0){c=p.anchorNode;var y=p.anchorOffset,S=p.focusNode;p=p.focusOffset;try{c.nodeType,S.nodeType}catch{c=null;break e}var E=0,q=-1,G=-1,ie=0,ve=0,Se=r,ge=null;t:for(;;){for(var Ke;Se!==c||y!==0&&Se.nodeType!==3||(q=E+y),Se!==S||p!==0&&Se.nodeType!==3||(G=E+p),Se.nodeType===3&&(E+=Se.n
vendor: 4,120 bytes, line 8
8odeValue.length),(Ke=Se.firstChild)!==null;)ge=Se,Se=Ke;for(;;){if(Se===r)break t;if(ge===c&&++ie===y&&(q=E),ge===S&&++ve===p&&(G=E),(Ke=Se.nextSibling)!==null)break;Se=ge,ge=Se.parentNode}Se=Ke}c=q===-1||G===-1?null:{start:q,end:G}}else c=null}c=c||{start:0,end:0}}else c=null;for(Fh={focusedElem:r,selectionRange:c},bd=!1,Ye=i;Ye!==null;)if(i=Ye,r=i.child,(i.subtreeFlags&1028)!==0&&r!==null)r.return=i,Ye=r;else for(;Ye!==null;){i=Ye;try{var Je=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(Je!==null){var et=Je.memoizedProps,Us=Je.memoizedState,re=i.stateNode,X=re.getSnapshotBeforeUpdate(i.elementType===i.type?et:Er(i.type,et),Us);re.__reactInternalSnapshotBeforeUpdate=X}break;case 3:var ae=i.stateNode.containerInfo;ae.nodeType===1?ae.textContent="":ae.nodeType===9&&ae.documentElement&&ae.removeChild(ae.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ee){Ds(i,i.return,Ee)}if(r=i.sibling,r!==null){r.return=i.return,Ye=r;break}Ye=i.return}return Je=Jy,Jy=!1,Je}function tc(r,i,c){var p=i.updateQueue;if(p=p!==null?p.lastEffect:null,p!==null){var y=p=p.next;do{if((y.tag&r)===r){var S=y.destroy;y.destroy=void 0,S!==void 0&&kf(i,c,S)}y=y.next}while(y!==p)}}function nu(r,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var c=i=i.next;do{if((c.tag&r)===r){var p=c.create;c.destroy=p()}c=c.next}while(c!==i)}}function Pf(r){var i=r.ref;if(i!==null){var c=r.stateNode;r.tag,r=c,typeof i=="function"?i(r):i.current=r}}function ej(r){var i=r.alternate;i!==null&&(r.alternate=null,ej(i)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(i=r.stateNode,i!==null&&(delete i[Jr],delete i[ql],delete i[Bh],delete i[uP],delete i[mP])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function tj(r){return r.tag===5||r.tag===3||r.tag===4}function sj(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||tj(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Tf(r,i,c){var p=r.tag;if(p===5||p===6)r=r.stateNode,i?c.nodeType===8?c.parentNode.insertBefore(r,i):c.insertBefore(r,i):(c.nodeType===8?(i=c.parentNode,i.insertBefore(r,c)):(i=c,i.appendChild(r)),c=c._reactRootContainer,c!=null||i.onclick!==null||(i.onclick=Dd));else if(p!==4&&(r=r.child,r!==null))for(Tf(r,i,c),r=r.sibling;r!==null;)Tf(r,i,c),r=r.sibling}function Ef(r,i,c){var p=r.tag;if(p===5||p===6)r=r.stateNode,i?c.insertBefore(r,i):c.appendChild(r);else if(p!==4&&(r=r.child,r!==null))for(Ef(r,i,c),r=r.sibling;r!==null;)Ef(r,i,c),r=r.sibling}var hn=null,_r=!1;function Za(r,i,c){for(c=c.child;c!==null;)nj(r,i,c),c=c.sibling}function nj(r,i,c){if(Xr&&typeof Xr.onCommitFiberUnmount=="function")try{Xr.onCommitFiberUnmount(gd,c)}catch{}switch(c.tag){case 5:Nn||ko(c,i);case 6:var p=hn,y=_r;hn=null,Za(r,i,c),hn=p,_r=y,hn!==null&&(_r?(r=hn,c=c.stateNode,r.nodeType===8?r.parentNode.removeChild(c):r.removeChild(c)):hn.removeChild(c.stateNode));break;case 18:hn!==null&&(_r?(r=hn,c=c.stateNode,r.nodeType===8?zh(r.parentNode,c):r.nodeType===1&&zh(r,c),Il(r)):zh(hn,c.stateNode));break;case 4:p=hn,y=_r,hn=c.stateNode.containerInfo,_r=!0,Za(r,i,c),hn=p,_r=y;break;case 0:case 11:case 14:case 15:if(!Nn&&(p=c.updateQueue,p!==null&&(p=p.lastEffect,p!==null))){y=p=p.next;do{var S=y,E=S.destroy;S=S.tag,E!==void 0&&((S&2)!==0||(S&4)!==0)&&kf(c,i,E),y=y.next}while(y!==p)}Za(r,i,c);break;case 1:if(!Nn&&(ko(c,i),p=c.stateNode,typeof p.componentWillUnmount=="function"))try{p.props=c.memoizedProps,p.state=c.memoizedState,p.componentWillUnmount()}catch(q){Ds(c,i,q)}Za(r,i,c);break;case 21:Za(r,i,c);break;case 22:c.mode&1?(Nn=(p=Nn)||c.memoizedState!==null,Za(r,i,c),Nn=p):Za(r,i,c);break;default:Za(r,i,c)}}function rj(r){var i=r.updateQueue;if(i!==null){r.updateQueue=null;var c=r.stateNode;c===null&&(c=r.stateNode=new TP),i.forEach(function(p){var y=FP.bind(null,r,p);
vendor: 12,747 bytes, line 8
8c.has(p)||(c.add(p),p.then(y,y))})}}function Rr(r,i){var c=i.deletions;if(c!==null)for(var p=0;p<c.length;p++){var y=c[p];try{var S=r,E=i,q=E;e:for(;q!==null;){switch(q.tag){case 5:hn=q.stateNode,_r=!1;break e;case 3:hn=q.stateNode.containerInfo,_r=!0;break e;case 4:hn=q.stateNode.containerInfo,_r=!0;break e}q=q.return}if(hn===null)throw Error(n(160));nj(S,E,y),hn=null,_r=!1;var G=y.alternate;G!==null&&(G.return=null),y.return=null}catch(ie){Ds(y,i,ie)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)aj(i,r),i=i.sibling}function aj(r,i){var c=r.alternate,p=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(Rr(i,r),sa(r),p&4){try{tc(3,r,r.return),nu(3,r)}catch(et){Ds(r,r.return,et)}try{tc(5,r,r.return)}catch(et){Ds(r,r.return,et)}}break;case 1:Rr(i,r),sa(r),p&512&&c!==null&&ko(c,c.return);break;case 5:if(Rr(i,r),sa(r),p&512&&c!==null&&ko(c,c.return),r.flags&32){var y=r.stateNode;try{ne(y,"")}catch(et){Ds(r,r.return,et)}}if(p&4&&(y=r.stateNode,y!=null)){var S=r.memoizedProps,E=c!==null?c.memoizedProps:S,q=r.type,G=r.updateQueue;if(r.updateQueue=null,G!==null)try{q==="input"&&S.type==="radio"&&S.name!=null&&Wt(y,S),xs(q,E);var ie=xs(q,S);for(E=0;E<G.length;E+=2){var ve=G[E],Se=G[E+1];ve==="style"?ms(y,Se):ve==="dangerouslySetInnerHTML"?Xe(y,Se):ve==="children"?ne(y,Se):T(y,ve,Se,ie)}switch(q){case"input":Le(y,S);break;case"textarea":xn(y,S);break;case"select":var ge=y._wrapperState.wasMultiple;y._wrapperState.wasMultiple=!!S.multiple;var Ke=S.value;Ke!=null?us(y,!!S.multiple,Ke,!1):ge!==!!S.multiple&&(S.defaultValue!=null?us(y,!!S.multiple,S.defaultValue,!0):us(y,!!S.multiple,S.multiple?[]:"",!1))}y[ql]=S}catch(et){Ds(r,r.return,et)}}break;case 6:if(Rr(i,r),sa(r),p&4){if(r.stateNode===null)throw Error(n(162));y=r.stateNode,S=r.memoizedProps;try{y.nodeValue=S}catch(et){Ds(r,r.return,et)}}break;case 3:if(Rr(i,r),sa(r),p&4&&c!==null&&c.memoizedState.isDehydrated)try{Il(i.containerInfo)}catch(et){Ds(r,r.return,et)}break;case 4:Rr(i,r),sa(r);break;case 13:Rr(i,r),sa(r),y=r.child,y.flags&8192&&(S=y.memoizedState!==null,y.stateNode.isHidden=S,!S||y.alternate!==null&&y.alternate.memoizedState!==null||(Af=es())),p&4&&rj(r);break;case 22:if(ve=c!==null&&c.memoizedState!==null,r.mode&1?(Nn=(ie=Nn)||ve,Rr(i,r),Nn=ie):Rr(i,r),sa(r),p&8192){if(ie=r.memoizedState!==null,(r.stateNode.isHidden=ie)&&!ve&&(r.mode&1)!==0)for(Ye=r,ve=r.child;ve!==null;){for(Se=Ye=ve;Ye!==null;){switch(ge=Ye,Ke=ge.child,ge.tag){case 0:case 11:case 14:case 15:tc(4,ge,ge.return);break;case 1:ko(ge,ge.return);var Je=ge.stateNode;if(typeof Je.componentWillUnmount=="function"){p=ge,c=ge.return;try{i=p,Je.props=i.memoizedProps,Je.state=i.memoizedState,Je.componentWillUnmount()}catch(et){Ds(p,c,et)}}break;case 5:ko(ge,ge.return);break;case 22:if(ge.memoizedState!==null){lj(Se);continue}}Ke!==null?(Ke.return=ge,Ye=Ke):lj(Se)}ve=ve.sibling}e:for(ve=null,Se=r;;){if(Se.tag===5){if(ve===null){ve=Se;try{y=Se.stateNode,ie?(S=y.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none"):(q=Se.stateNode,G=Se.memoizedProps.style,E=G!=null&&G.hasOwnProperty("display")?G.display:null,q.style.display=mt("display",E))}catch(et){Ds(r,r.return,et)}}}else if(Se.tag===6){if(ve===null)try{Se.stateNode.nodeValue=ie?"":Se.memoizedProps}catch(et){Ds(r,r.return,et)}}else if((Se.tag!==22&&Se.tag!==23||Se.memoizedState===null||Se===r)&&Se.child!==null){Se.child.return=Se,Se=Se.child;continue}if(Se===r)break e;for(;Se.sibling===null;){if(Se.return===null||Se.return===r)break e;ve===Se&&(ve=null),Se=Se.return}ve===Se&&(ve=null),Se.sibling.return=Se.return,Se=Se.sibling}}break;case 19:Rr(i,r),sa(r),p&4&&rj(r);break;case 21:break;default:Rr(i,r),sa(r)}}function sa(r){var i=r.flags;if(i&2){try{e:{for(var c=r.return;c!==null;){if(tj(c)){var p=c;break e}c=c.return}throw Error(n(160))}switch(p.tag){case 5:var y=p.stateNode;p.flags&32&&(ne(y,""),p.flags&=-33);var S=sj(r);Ef(r,S,y);break;case 3:case 4:var E=p.stateNode.containerInfo,q=sj(r);Tf(r,q,E);break;default:throw Error(n(161))}}catch(G){Ds(r,r.return,G)}r.flags&=-3}i&4096&&(r.flags&=-4097)}function _P(r,i,c){Ye=r,ij(r)}function ij(r,i,c){for(var p=(r.mode&1)!==0;Ye!==null;){var y=Ye,S=y.child;if(y.tag===22&&p){var E=y.memoizedState!==null||su;if(!E){var q=y.alternate,G=q!==null&&q.memoizedState!==null||Nn;q=su;var ie=Nn;if(su=E,(Nn=G)&&!ie)for(Ye=y;Ye!==null;)E=Ye,G=E.child,E.tag===22&&E.memoizedState!==null?cj(y):G!==null?(G.return=E,Ye=G):cj(y);for(;S!==null;)Ye=S,ij(S),S=S.sibling;Ye=y,su=q,Nn=ie}oj(r)}else(y.subtreeFlags&8772)!==0&&S!==null?(S.return=y,Ye=S):oj(r)}}function oj(r){for(;Ye!==null;){var i=Ye;if((i.flags&8772)!==0){var c=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:Nn||nu(5,i);break;case 1:var p=i.stateNode;if(i.flags&4&&!Nn)if(c===null)p.componentDidMount();else{var y=i.elementType===i.type?c.memoizedProps:Er(i.type,c.memoizedProps);p.componentDidUpdate(y,c.memoizedState,p.__reactInternalSnapshotBeforeUpdate)}var S=i.updateQueue;S!==null&&ly(i,S,p);break;case 3:var E=i.updateQueue;if(E!==null){if(c=null,i.child!==null)switch(i.child.tag){case 5:c=i.child.stateNode;break;case 1:c=i.child.stateNode}ly(i,E,c)}break;case 5:var q=i.stateNode;if(c===null&&i.flags&4){c=q;var G=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":G.autoFocus&&c.focus();break;case"img":G.src&&(c.src=G.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var ie=i.alternate;if(ie!==null){var ve=ie.memoizedState;if(ve!==null){var Se=ve.dehydrated;Se!==null&&Il(Se)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Nn||i.flags&512&&Pf(i)}catch(ge){Ds(i,i.return,ge)}}if(i===r){Ye=null;break}if(c=i.sibling,c!==null){c.return=i.return,Ye=c;break}Ye=i.return}}function lj(r){for(;Ye!==null;){var i=Ye;if(i===r){Ye=null;break}var c=i.sibling;if(c!==null){c.return=i.return,Ye=c;break}Ye=i.return}}function cj(r){for(;Ye!==null;){var i=Ye;try{switch(i.tag){case 0:case 11:case 15:var c=i.return;try{nu(4,i)}catch(G){Ds(i,c,G)}break;case 1:var p=i.stateNode;if(typeof p.componentDidMount=="function"){var y=i.return;try{p.componentDidMount()}catch(G){Ds(i,y,G)}}var S=i.return;try{Pf(i)}catch(G){Ds(i,S,G)}break;case 5:var E=i.return;try{Pf(i)}catch(G){Ds(i,E,G)}}}catch(G){Ds(i,i.return,G)}if(i===r){Ye=null;break}var q=i.sibling;if(q!==null){q.return=i.return,Ye=q;break}Ye=i.return}}var RP=Math.ceil,ru=P.ReactCurrentDispatcher,_f=P.ReactCurrentOwner,pr=P.ReactCurrentBatchConfig,Qt=0,nn=null,Ws=null,fn=0,rr=0,Po=Ha(0),Zs=0,sc=null,Ai=0,au=0,Rf=0,nc=null,Kn=null,Af=0,To=1/0,ba=null,iu=!1,If=null,Xa=null,ou=!1,Ja=null,lu=0,rc=0,Df=null,cu=-1,du=0;function In(){return(Qt&6)!==0?es():cu!==-1?cu:cu=es()}function ei(r){return(r.mode&1)===0?1:(Qt&2)!==0&&fn!==0?fn&-fn:fP.transition!==null?(du===0&&(du=sv()),du):(r=ns,r!==0||(r=window.event,r=r===void 0?16:uv(r.type)),r)}function Ar(r,i,c,p){if(50<rc)throw rc=0,Df=null,Error(n(185));Tl(r,c,p),((Qt&2)===0||r!==nn)&&(r===nn&&((Qt&2)===0&&(au|=c),Zs===4&&ti(r,fn)),Hn(r,p),c===1&&Qt===0&&(i.mode&1)===0&&(To=es()+500,Fd&&Qa()))}function Hn(r,i){var c=r.callbackNode;f2(r,i);var p=yd(r,r===nn?fn:0);if(p===0)c!==null&&Qe(c),r.callbackNode=null,r.callbackPriority=0;else if(i=p&-p,r.callbackPriority!==i){if(c!=null&&Qe(c),i===1)r.tag===0?hP(uj.bind(null,r)):Yv(uj.bind(null,r)),cP(function(){(Qt&6)===0&&Qa()}),c=null;else{switch(nv(p)){case 1:c=mn;break;case 4:c=Si;break;case 16:c=Fa;break;case 536870912:c=tv;break;default:c=Fa}c=yj(c,dj.bind(null,r))}r.callbackPriority=i,r.callbackNode=c}}function dj(r,i){if(cu=-1,du=0,(Qt&6)!==0)throw Error(n(327));var c=r.callbackNode;if(Eo()&&r.callbackNode!==c)return null;var p=yd(r,r===nn?fn:0);if(p===0)return null;if((p&30)!==0||(p&r.expiredLanes)!==0||i)i=uu(r,p);else{i=p;var y=Qt;Qt|=2;var S=hj();(nn!==r||fn!==i)&&(ba=null,To=es()+500,Di(r,i));do try{DP();break}catch(q){mj(r,q)}while(!0);Zh(),ru.current=S,Qt=y,Ws!==null?i=0:(nn=null,fn=0,i=Zs)}if(i!==0){if(i===2&&(y=hh(r),y!==0&&(p=y,i=Of(r,y))),i===1)throw c=sc,Di(r,0),ti(r,p),Hn(r,es()),c;if(i===6)ti(r,p);else{if(y=r.current.alternate,(p&30)===0&&!AP(y)&&(i=uu(r,p),i===2&&(S=hh(r),S!==0&&(p=S,i=Of(r,S))),i===1))throw c=sc,Di(r,0),ti(r,p),Hn(r,es()),c;switch(r.finishedWork=y,r.finishedLanes=p,i){case 0:case 1:throw Error(n(345));case 2:Oi(r,Kn,ba);break;case 3:if(ti(r,p),(p&130023424)===p&&(i=Af+500-es(),10<i)){if(yd(r,0)!==0)break;if(y=r.suspendedLanes,(y&p)!==p){In(),r.pingedLanes|=r.suspendedLanes&y;break}r.timeoutHandle=Uh(Oi.bind(null,r,Kn,ba),i);break}Oi(r,Kn,ba);break;case 4:if(ti(r,p),(p&4194240)===p)break;for(i=r.eventTimes,y=-1;0<p;){var E=31-kr(p);S=1<<E,E=i[E],E>y&&(y=E),p&=~S}if(p=y,p=es()-p,p=(120>p?120:480>p?480:1080>p?1080:1920>p?1920:3e3>p?3e3:4320>p?4320:1960*RP(p/1960))-p,10<p){r.timeoutHandle=Uh(Oi.bind(null,r,Kn,ba),p);break}Oi(r,Kn,ba);break;case 5:Oi(r,Kn,ba);break;default:throw Error(n(329))}}}return Hn(r,es()),r.callbackNode===c?dj.bind(null,r):null}function Of(r,i){var c=nc;return r.current.memoizedState.isDehydrated&&(Di(r,i).flags|=256),r=uu(r,i),r!==2&&(i=Kn,Kn=c,i!==null&&Mf(i)),r}function Mf(r){Kn===null?Kn=r:Kn.push.apply(Kn,r)}function AP(r){for(var i=r;;){if(i.flags&16384){var c=i.updateQueue;if(c!==null&&(c=c.stores,c!==null))for(var p=0;p<c.length;p++){var y=c[p],S=y.getSnapshot;y=y.value;try{if(!Pr(S(),y))return!1}catch{return!1}}}if(c=i.child,i.subtreeFlags&16384&&c!==null)c.return=i,i=c;else{if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function ti(r,i){for(i&=~Rf,i&=~au,r.suspendedLanes|=i,r.pingedLanes&=~i,r=r.expirationTimes;0<i;){var c=31-kr(i),p=1<<c;r[c]=-1,i&=~p}}function uj(r){if((Qt&6)!==0)throw Error(n(327));Eo();var i=yd(r,0);if((i&1)===0)return Hn(r,es()),null;var c=uu(r,i);if(r.tag!==0&&c===2){var p=hh(r);p!==0&&(i=p,c=Of(r,p))}if(c===1)throw c=sc,Di(r,0),ti(r,i),Hn(r,es()),c;if(c===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=i,Oi(r,Kn,ba),Hn(r,es()),null}function Lf(r,i){var c=Qt;Qt|=1;try{return r(i)}finally{Qt=c,Qt===0&&(To=es()+500,Fd&&Qa())}}function Ii(r){Ja!==null&&Ja.tag===0&&(Qt&6)===0&&Eo();var i=Qt;Qt|=1;var c=pr.transition,p=ns;try{if(pr.transition=null,ns=1,r)return r()}finally{ns=p,pr.transition=c,Qt=i,(Qt&6)===0&&Qa()}}function Ff(){rr=Po.current,js(Po)}function Di(r,i){r.finishedWork=null,r.finishedLanes=0;var c=r.timeoutHandle;if(c!==-1&&(r.timeoutHandle=-1,lP(c)),Ws!==null)for(c=Ws.return;c!==null;){var p=c;switch(Hh(p),p.tag){case 1:p=p.type.childContextTypes,p!=null&&Md();break;case 3:So(),js(Bn),js(jn),af();break;case 5:nf(p);break;case 4:So();break;case 13:js(Ps);break;case 19:js(Ps);break;case 10:Xh(p.type._context);break;case 22:case 23:Ff()}c=c.return}if(nn=r,Ws=r=si(r.current,null),fn=rr=i,Zs=0,sc=null,Rf=au=Ai=0,Kn=nc=null,Ei!==null){for(i=0;i<Ei.length;i++)if(c=Ei[i],p=c.interleaved,p!==null){c.interleaved=null;var y=p.next,S=c.pending;if(S!==null){var E=S.next;S.next=y,p.next=E}c.pending=p}Ei=null}return r}function mj(r,i){do{var c=Ws;try{if(Zh(),Qd.current=Xd,Gd){for(var p=Ts.memoizedState;p!==null;){var y=p.queue;y!==null&&(y.pending=null),p=p.next}Gd=!1}if(Ri=0,sn=Ys=Ts=null,Yl=!1,Zl=0,_f.current=null,c===null||c.return===null){Zs=1,sc=i,Ws=null;break}e:{var S=r,E=c.return,q=c,G=i;if(i=fn,q.flags|=32768,G!==null&&typeof G=="object"&&typeof G.then=="function"){var ie=G,ve=q,Se=ve.tag;if((ve.mode&1)===0&&(Se===0||Se===11||Se===15)){var ge=ve.alternate;ge?(ve.updateQueue=ge.updateQueue,ve.memoizedState=ge.memoizedState,ve.lanes=ge.lanes):(ve.updateQueue=null,ve.memoizedState=null)}var Ke=Ly(E);if(Ke!==null){Ke.flags&=-257,Fy(Ke,E,q,S,i),Ke.mode&1&&My(S,ie,i),i=Ke,G=ie;var Je=i.updateQueue;if(Je===null){var et=new Set;et.add(G),i.updateQueue=et}else Je.add(G);break e}else{if((i&1)===0){My(S,ie,i),$f();break e}G=Error(n(426))}}else if(Ns&&q.mode&1){var Us=Ly(E);if(Us!==null){(Us.flags&65536)===0&&(Us.flags|=256),Fy(Us,E,q,S,i),Gh(Co(G,q));break e}}S=G=Co(G,q),Zs!==4&&(Zs=2),nc===null?nc=[S]:nc.push(S),S=E;do{switch(S.tag){case 3:S.flags|=65536,i&=-i,S.lanes|=i;var re=Dy(S,G,i);oy(S,re);break e;case 1:q=G;var X=S.type,ae=S.stateNode;if((S.flags&128)===0&&(typeof X.getDerivedStateFromError=="function"||ae!==null&&typeof ae.componentDidCatch=="function"&&(Xa===null||!Xa.has(ae)))){S.flags|=65536,i&=-i,S.lanes|=i;var Ee=Oy(S,q,i);oy(S,Ee);break e}}S=S.return}while(S!==null)}pj(c)}catch(nt){i=nt,Ws===c&&c!==null&&(Ws=c=c.return);continue}break}while(!0)}function hj(){var r=ru.current;return ru.current=Xd,r===null?Xd:r}function $f(){(Zs===0||Zs===3||Zs===2)&&(Zs=4),nn===null||(Ai&268435455)===0&&(au&268435455)===0||ti(nn,fn)}function uu(r,i){var c=Qt;Qt|=2;
vendor: 5,545 bytes, line 8
8var p=hj();(nn!==r||fn!==i)&&(ba=null,Di(r,i));do try{IP();break}catch(y){mj(r,y)}while(!0);if(Zh(),Qt=c,ru.current=p,Ws!==null)throw Error(n(261));return nn=null,fn=0,Zs}function IP(){for(;Ws!==null;)fj(Ws)}function DP(){for(;Ws!==null&&!_t();)fj(Ws)}function fj(r){var i=vj(r.alternate,r,rr);r.memoizedProps=r.pendingProps,i===null?pj(r):Ws=i,_f.current=null}function pj(r){var i=r;do{var c=i.alternate;if(r=i.return,(i.flags&32768)===0){if(c=kP(c,i,rr),c!==null){Ws=c;return}}else{if(c=PP(c,i),c!==null){c.flags&=32767,Ws=c;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{Zs=6,Ws=null;return}}if(i=i.sibling,i!==null){Ws=i;return}Ws=i=r}while(i!==null);Zs===0&&(Zs=5)}function Oi(r,i,c){var p=ns,y=pr.transition;try{pr.transition=null,ns=1,OP(r,i,c,p)}finally{pr.transition=y,ns=p}return null}function OP(r,i,c,p){do Eo();while(Ja!==null);if((Qt&6)!==0)throw Error(n(327));c=r.finishedWork;var y=r.finishedLanes;if(c===null)return null;if(r.finishedWork=null,r.finishedLanes=0,c===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var S=c.lanes|c.childLanes;if(p2(r,S),r===nn&&(Ws=nn=null,fn=0),(c.subtreeFlags&2064)===0&&(c.flags&2064)===0||ou||(ou=!0,yj(Fa,function(){return Eo(),null})),S=(c.flags&15990)!==0,(c.subtreeFlags&15990)!==0||S){S=pr.transition,pr.transition=null;var E=ns;ns=1;var q=Qt;Qt|=4,_f.current=null,EP(r,c),aj(c,r),tP(Fh),bd=!!Lh,Fh=Lh=null,r.current=c,_P(c),Ge(),Qt=q,ns=E,pr.transition=S}else r.current=c;if(ou&&(ou=!1,Ja=r,lu=y),S=r.pendingLanes,S===0&&(Xa=null),c2(c.stateNode),Hn(r,es()),i!==null)for(p=r.onRecoverableError,c=0;c<i.length;c++)y=i[c],p(y.value,{componentStack:y.stack,digest:y.digest});if(iu)throw iu=!1,r=If,If=null,r;return(lu&1)!==0&&r.tag!==0&&Eo(),S=r.pendingLanes,(S&1)!==0?r===Df?rc++:(rc=0,Df=r):rc=0,Qa(),null}function Eo(){if(Ja!==null){var r=nv(lu),i=pr.transition,c=ns;try{if(pr.transition=null,ns=16>r?16:r,Ja===null)var p=!1;else{if(r=Ja,Ja=null,lu=0,(Qt&6)!==0)throw Error(n(331));var y=Qt;for(Qt|=4,Ye=r.current;Ye!==null;){var S=Ye,E=S.child;if((Ye.flags&16)!==0){var q=S.deletions;if(q!==null){for(var G=0;G<q.length;G++){var ie=q[G];for(Ye=ie;Ye!==null;){var ve=Ye;switch(ve.tag){case 0:case 11:case 15:tc(8,ve,S)}var Se=ve.child;if(Se!==null)Se.return=ve,Ye=Se;else for(;Ye!==null;){ve=Ye;var ge=ve.sibling,Ke=ve.return;if(ej(ve),ve===ie){Ye=null;break}if(ge!==null){ge.return=Ke,Ye=ge;break}Ye=Ke}}}var Je=S.alternate;if(Je!==null){var et=Je.child;if(et!==null){Je.child=null;do{var Us=et.sibling;et.sibling=null,et=Us}while(et!==null)}}Ye=S}}if((S.subtreeFlags&2064)!==0&&E!==null)E.return=S,Ye=E;else e:for(;Ye!==null;){if(S=Ye,(S.flags&2048)!==0)switch(S.tag){case 0:case 11:case 15:tc(9,S,S.return)}var re=S.sibling;if(re!==null){re.return=S.return,Ye=re;break e}Ye=S.return}}var X=r.current;for(Ye=X;Ye!==null;){E=Ye;var ae=E.child;if((E.subtreeFlags&2064)!==0&&ae!==null)ae.return=E,Ye=ae;else e:for(E=X;Ye!==null;){if(q=Ye,(q.flags&2048)!==0)try{switch(q.tag){case 0:case 11:case 15:nu(9,q)}}catch(nt){Ds(q,q.return,nt)}if(q===E){Ye=null;break e}var Ee=q.sibling;if(Ee!==null){Ee.return=q.return,Ye=Ee;break e}Ye=q.return}}if(Qt=y,Qa(),Xr&&typeof Xr.onPostCommitFiberRoot=="function")try{Xr.onPostCommitFiberRoot(gd,r)}catch{}p=!0}return p}finally{ns=c,pr.transition=i}}return!1}function gj(r,i,c){i=Co(c,i),i=Dy(r,i,1),r=Ya(r,i,1),i=In(),r!==null&&(Tl(r,1,i),Hn(r,i))}function Ds(r,i,c){if(r.tag===3)gj(r,r,c);else for(;i!==null;){if(i.tag===3){gj(i,r,c);break}else if(i.tag===1){var p=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(Xa===null||!Xa.has(p))){r=Co(c,r),r=Oy(i,r,1),i=Ya(i,r,1),r=In(),i!==null&&(Tl(i,1,r),Hn(i,r));break}}i=i.return}}function MP(r,i,c){var p=r.pingCache;p!==null&&p.delete(i),i=In(),r.pingedLanes|=r.suspendedLanes&c,nn===r&&(fn&c)===c&&(Zs===4||Zs===3&&(fn&130023424)===fn&&500>es()-Af?Di(r,0):Rf|=c),Hn(r,i)}function xj(r,i){i===0&&((r.mode&1)===0?i=1:(i=vd,vd<<=1,(vd&130023424)===0&&(vd=4194304)));var c=In();r=ya(r,i),r!==null&&(Tl(r,i,c),Hn(r,c))}function LP(r){var i=r.memoizedState,c=0;i!==null&&(c=i.retryLane),xj(r,c)}function FP(r,i){var c=0;switch(r.tag){case 13:var p=r.stateNode,y=r.memoizedState;y!==null&&(c=y.retryLane);break;case 19:p=r.stateNode;break;default:throw Error(n(314))}p!==null&&p.delete(i),xj(r,c)}var vj;vj=function(r,i,c){if(r!==null)if(r.memoizedProps!==i.pendingProps||Bn.current)qn=!0;else{if((r.lanes&c)===0&&(i.flags&128)===0)return qn=!1,CP(r,i,c);qn=(r.flags&131072)!==0}else qn=!1,Ns&&(i.flags&1048576)!==0&&Zv(i,Ud,i.index);switch(i.lanes=0,i.tag){case 2:var p=i.type;tu(r,i),r=i.pendingProps;var y=xo(i,jn.current);No(i,c),y=cf(null,i,p,r,y,c);var S=df();return i.flags|=1,typeof y=="object"&&y!==null&&typeof y.render=="function"&&y.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,Vn(p)?(S=!0,Ld(i)):S=!1,i.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,tf(i),y.updater=Jd,i.stateNode=y,y._reactInternals=i,gf(i,p,r,c),i=jf(null,i,p,!0,S,c)):(i.tag=0,Ns&&S&&Kh(i),An(null,i,y,c),i=i.child),i;case 16:p=i.elementType;e:{switch(tu(r,i),r=i.pendingProps,y=p._init,p=y(p._payload),i.type=p,y=i.tag=UP(p),r=Er(p,r),y){case 0:i=yf(null,i,p,r,c);break e;case 1:i=qy(null,i,p,r,c);break e;case 11:i=$y(null,i,p,r,c);break e;case 14:i=Uy(null,i,p,Er(p.type,r),c);break e}throw Error(n(306,p,""))}return i;case 0:return p=i.type,y=i.pendingProps,y=i.elementType===p?y:Er(p,y),yf(r,i,p,y,c);case 1:return p=i.type,y=i.pendingProps,y=i.elementType===p?y:Er(p,y),qy(r,
vendor: 3,605 bytes, line 8
8i,p,y,c);case 3:e:{if(Ky(i),r===null)throw Error(n(387));p=i.pendingProps,S=i.memoizedState,y=S.element,iy(r,i),Hd(i,p,null,c);var E=i.memoizedState;if(p=E.element,S.isDehydrated)if(S={element:p,isDehydrated:!1,cache:E.cache,pendingSuspenseBoundaries:E.pendingSuspenseBoundaries,transitions:E.transitions},i.updateQueue.baseState=S,i.memoizedState=S,i.flags&256){y=Co(Error(n(423)),i),i=Hy(r,i,p,c,y);break e}else if(p!==y){y=Co(Error(n(424)),i),i=Hy(r,i,p,c,y);break e}else for(nr=Ka(i.stateNode.containerInfo.firstChild),sr=i,Ns=!0,Tr=null,c=ry(i,null,p,c),i.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{if(jo(),p===y){i=wa(r,i,c);break e}An(r,i,p,c)}i=i.child}return i;case 5:return cy(i),r===null&&Qh(i),p=i.type,y=i.pendingProps,S=r!==null?r.memoizedProps:null,E=y.children,$h(p,y)?E=null:S!==null&&$h(p,S)&&(i.flags|=32),Vy(r,i),An(r,i,E,c),i.child;case 6:return r===null&&Qh(i),null;case 13:return Wy(r,i,c);case 4:return sf(i,i.stateNode.containerInfo),p=i.pendingProps,r===null?i.child=wo(i,null,p,c):An(r,i,p,c),i.child;case 11:return p=i.type,y=i.pendingProps,y=i.elementType===p?y:Er(p,y),$y(r,i,p,y,c);case 7:return An(r,i,i.pendingProps,c),i.child;case 8:return An(r,i,i.pendingProps.children,c),i.child;case 12:return An(r,i,i.pendingProps.children,c),i.child;case 10:e:{if(p=i.type._context,y=i.pendingProps,S=i.memoizedProps,E=y.value,fs(Vd,p._currentValue),p._currentValue=E,S!==null)if(Pr(S.value,E)){if(S.children===y.children&&!Bn.current){i=wa(r,i,c);break e}}else for(S=i.child,S!==null&&(S.return=i);S!==null;){var q=S.dependencies;if(q!==null){E=S.child;for(var G=q.firstContext;G!==null;){if(G.context===p){if(S.tag===1){G=ja(-1,c&-c),G.tag=2;var ie=S.updateQueue;if(ie!==null){ie=ie.shared;var ve=ie.pending;ve===null?G.next=G:(G.next=ve.next,ve.next=G),ie.pending=G}}S.lanes|=c,G=S.alternate,G!==null&&(G.lanes|=c),Jh(S.return,c,i),q.lanes|=c;break}G=G.next}}else if(S.tag===10)E=S.type===i.type?null:S.child;else if(S.tag===18){if(E=S.return,E===null)throw Error(n(341));E.lanes|=c,q=E.alternate,q!==null&&(q.lanes|=c),Jh(E,c,i),E=S.sibling}else E=S.child;if(E!==null)E.return=S;else for(E=S;E!==null;){if(E===i){E=null;break}if(S=E.sibling,S!==null){S.return=E.return,E=S;break}E=E.return}S=E}An(r,i,y.children,c),i=i.child}return i;case 9:return y=i.type,p=i.pendingProps.children,No(i,c),y=hr(y),p=p(y),i.flags|=1,An(r,i,p,c),i.child;case 14:return p=i.type,y=Er(p,i.pendingProps),y=Er(p.type,y),Uy(r,i,p,y,c);case 15:return zy(r,i,i.type,i.pendingProps,c);case 17:return p=i.type,y=i.pendingProps,y=i.elementType===p?y:Er(p,y),tu(r,i),i.tag=1,Vn(p)?(r=!0,Ld(i)):r=!1,No(i,c),Ay(i,p,y),gf(i,p,y,c),jf(null,i,p,!0,r,c);case 19:return Gy(r,i,c);case 22:return By(r,i,c)}throw Error(n(156,i.tag))};function yj(r,i){return he(r,i)}function $P(r,i,c,p){this.tag=r,this.key=c,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=p,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function gr(r,i,c,p){return new $P(r,i,c,p)}function Uf(r){return r=r.prototype,!(!r||!r.isReactComponent)}function UP(r){if(typeof r=="function")return Uf(r)?1:0;if(r!=null){if(r=r.$$typeof,r===V)return 11;if(r===L)return 14}return 2}function si(r,i){var c=r.alternate;return c===null?(c=gr(r.tag,i,r.key,r.mode),c.elementType=r.elementType,c.type=r.type,c.stateNode=r.stateNode,c.alternate=r,r.alternate=c):(c.pendingProps=i,c.type=r.type,c.flags=0,c.subtreeFlags=0,c.deleti
vendor: 5,963 bytes, line 8
8ons=null),c.flags=r.flags&14680064,c.childLanes=r.childLanes,c.lanes=r.lanes,c.child=r.child,c.memoizedProps=r.memoizedProps,c.memoizedState=r.memoizedState,c.updateQueue=r.updateQueue,i=r.dependencies,c.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},c.sibling=r.sibling,c.index=r.index,c.ref=r.ref,c}function mu(r,i,c,p,y,S){var E=2;if(p=r,typeof r=="function")Uf(r)&&(E=1);else if(typeof r=="string")E=5;else e:switch(r){case R:return Mi(c.children,y,S,i);case F:E=8,y|=8;break;case M:return r=gr(12,c,i,y|2),r.elementType=M,r.lanes=S,r;case B:return r=gr(13,c,i,y),r.elementType=B,r.lanes=S,r;case Y:return r=gr(19,c,i,y),r.elementType=Y,r.lanes=S,r;case _:return hu(c,y,S,i);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case z:E=10;break e;case H:E=9;break e;case V:E=11;break e;case L:E=14;break e;case K:E=16,p=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return i=gr(E,c,i,y),i.elementType=r,i.type=p,i.lanes=S,i}function Mi(r,i,c,p){return r=gr(7,r,p,i),r.lanes=c,r}function hu(r,i,c,p){return r=gr(22,r,p,i),r.elementType=_,r.lanes=c,r.stateNode={isHidden:!1},r}function zf(r,i,c){return r=gr(6,r,null,i),r.lanes=c,r}function Bf(r,i,c){return i=gr(4,r.children!==null?r.children:[],r.key,i),i.lanes=c,i.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},i}function zP(r,i,c,p,y){this.tag=i,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=fh(0),this.expirationTimes=fh(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fh(0),this.identifierPrefix=p,this.onRecoverableError=y,this.mutableSourceEagerHydrationData=null}function Vf(r,i,c,p,y,S,E,q,G){return r=new zP(r,i,c,q,G),i===1?(i=1,S===!0&&(i|=8)):i=0,S=gr(3,null,null,i),r.current=S,S.stateNode=r,S.memoizedState={element:p,isDehydrated:c,cache:null,transitions:null,pendingSuspenseBoundaries:null},tf(S),r}function BP(r,i,c){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:p==null?null:""+p,children:r,containerInfo:i,implementation:c}}function jj(r){if(!r)return Wa;r=r._reactInternals;e:{if(De(r)!==r||r.tag!==1)throw Error(n(170));var i=r;do{switch(i.tag){case 3:i=i.stateNode.context;break e;case 1:if(Vn(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break e}}i=i.return}while(i!==null);throw Error(n(171))}if(r.tag===1){var c=r.type;if(Vn(c))return Qv(r,c,i)}return i}function wj(r,i,c,p,y,S,E,q,G){return r=Vf(c,p,!0,r,y,S,E,q,G),r.context=jj(null),c=r.current,p=In(),y=ei(c),S=ja(p,y),S.callback=i??null,Ya(c,S,y),r.current.lanes=y,Tl(r,y,p),Hn(r,p),r}function fu(r,i,c,p){var y=i.current,S=In(),E=ei(y);return c=jj(c),i.context===null?i.context=c:i.pendingContext=c,i=ja(S,E),i.payload={element:r},p=p===void 0?null:p,p!==null&&(i.callback=p),r=Ya(y,i,E),r!==null&&(Ar(r,y,E,S),Kd(r,y,E)),E}function pu(r){return r=r.current,r.child?(r.child.tag===5,r.child.stateNode):null}function bj(r,i){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var c=r.retryLane;r.retryLane=c!==0&&c<i?c:i}}function qf(r,i){bj(r,i),(r=r.alternate)&&bj(r,i)}function VP(){return null}var Nj=typeof reportError=="function"?reportError:function(r){console.error(r)};function Kf(r){this._internalRoot=r}gu.prototype.render=Kf.prototype.render=function(r){var i=this._internalRoot;if(i===null)throw Error(n(409));fu(r,i,null,null)},gu.prototype.unmount=Kf.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var i=r.containerInfo;Ii(function(){fu(null,r,null,null)}),i[pa]=null}};function gu(r){this._internalRoot=r}gu.prototype.unstable_scheduleHydration=function(r){if(r){var i=iv();r={blockedOn:null,target:r,priority:i};for(var c=0;c<Ba.length&&i!==0&&i<Ba[c].priority;c++);Ba.splice(c,0,r),c===0&&cv(r)}};function Hf(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function xu(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function Sj(){}function qP(r,i,c,p,y){if(y){if(typeof p=="function"){var S=p;p=function(){var ie=pu(E);S.call(ie)}}var E=wj(i,p,r,0,null,!1,!1,"",Sj);return r._reactRootContainer=E,r[pa]=E.current,Bl(r.nodeType===8?r.parentNode:r),Ii(),E}for(;y=r.lastChild;)r.removeChild(y);if(typeof p=="function"){var q=p;p=function(){var ie=pu(G);q.call(ie)}}var G=Vf(r,0,!1,null,null,!1,!1,"",Sj);return r._reactRootContainer=G,r[pa]=G.current,Bl(r.nodeType===8?r.parentNode:r),Ii(function(){fu(i,G,c,p)}),G}function vu(r,i,c,p,y){var S=c._reactRootContainer;if(S){var E=S;if(typeof y=="function"){var q=y;y=function(){var G=pu(E);q.call(G)}}fu(i,E,r,y)}else E=qP(c,i,r,y,p);return pu(E)}rv=function(r){switch(r.tag){case 3:var i=r.stateNode;if(i.current.memoizedState.isDehydrated){var c=Pl(i.pendingLanes);c!==0&&(ph(i,c|1),Hn(i,es()),(Qt&6)===0&&(To=es()+500,Qa()))}break;case 13:Ii(function(){var p=ya(r,1);if(p!==null){var y=In();Ar(p,r,1,y)}}),qf(r,1)}},gh=function(r){if(r.tag===13){var i=ya(r,134217728);if(i!==null){var c=In();Ar(i,r,134217728,c)}qf(r,134217728)}},av=function(r){if(r.tag===13){var i=ei(r),c=ya(r,i);if(c!==null){var p=In();Ar(c,r,i,p)}qf(r,i)}},iv=function(){return ns},ov=function(r,i){var c=ns;try{return ns=r,i()}finally{ns=c}},_n=function(r,i,c){switch(i){case"input":if(Le(r,c),i=c.name,c.type==="radio"&&i!=null){for(c=r;c.parentNode;)c=c.parentNode;for(c=c.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<c.length;i++){var p=c[i];if(p!==r&&p.form===r.form){var y=Od(p);if(!y)throw Error(n(90));He(p),Le(p,y)}}}break;case"textarea":xn(r,c);break;case"select":i=c.value,i!=null&&us(r,!!c.multiple,i,!1)}},Cs=Lf,Hs=Ii;var KP={usingClientEntryPoint:!1,Events:[Kl,po,Od,vs,Fs,Lf]}
8,ac={findFiberByHostInstance:Ci,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},HP={bundleType:ac.bundleType,version:ac.version,rendererPackageName:ac.rendererPackageName,rendererConfig:ac.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:P.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=fa(r),r===null?null:r.stateNode},findFiberByHostInstance:ac.findFiberByHostInstance||VP,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var yu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yu.isDisabled&&yu.supportsFiber)try{gd=yu.inject(HP),Xr=yu}catch{}}return Wn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=KP,Wn.createPortal=function(r,i){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Hf(i))throw Error(n(200));return BP(r,i,null,c)},Wn.createRoot=function(r,i){if(!Hf(r))throw Error(n(299));var c=!1,p="",y=Nj;return i!=null&&(i.unstable_strictMode===!0&&(c=!0),i.identifierPrefix!==void 0&&(p=i.identifierPrefix),i.onRecoverableError!==void 0&&(y=i.onRecoverableError)),i=Vf(r,1,!1,null,null,c,!1,p,y),r[pa]=i.current,Bl(r.nodeType===8?r.parentNode:r),new Kf(i)},Wn.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var i=r._reactInternals;if(i===void 0)throw typeof r.render=="function"?Error(n(188)):(r=Object.keys(r).join(","),Error(n(268,r)));return r=fa(i),r=r===null?null:r.stateNode,r},Wn.flushSync=function(r){return Ii(r)},Wn.hydrate=function(r,i,c){if(!xu(i))throw Error(n(200));return vu(null,r,i,!0,c)},Wn.hydrateRoot=function(r,i,c){if(!Hf(r))throw Error(n(405));var p=c!=null&&c.hydratedSources||null,y=!1,S="",E=Nj;if(c!=null&&(c.unstable_strictMode===!0&&(y=!0),c.identifierPrefix!==void 0&&(S=c.identifierPrefix),c.onRecoverableError!==void 0&&(E=c.onRecoverableError)),i=wj(i,null,r,1,c??null,y,!1,S,E),r[pa]=i.current,Bl(r),p)for(r=0;r<p.length;r++)c=p[r],y=c._getVersion,y=y(c._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[c,y]:i.mutableSourceEagerHydrationData.push(c,y);return new gu(i)},Wn.render=function(r,i,c){if(!xu(i))throw Error(n(200));return vu(null,r,i,!1,c)},Wn.unmountComponentAtNode=function(r){if(!xu(r))throw Error(n(40));return r._reactRootContainer?(Ii(function(){vu(null,null,r,!1,function(){r._reactRootContainer=null,r[pa]=null})}),!0):!1},Wn.unstable_batchedUpdates=Lf,Wn.unstable_renderSubtreeIntoContainer=function(r,i,c,p){if(!xu(c))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return vu(r,i,c,!1,p)},Wn.version="18.3.1-next-f1338f8080-20240426",Wn}var Aj;function yb(){if(Aj)return Gf.exports;Aj=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(s){console.error(s)}}return t(),Gf.exports=eT(),Gf.exports}var Ij;function tT(){if(Ij)return ju;Ij=1;var t=yb();return ju.createRoot=t.createRoot,ju.hydrateRoot=t.hydrateRoot,ju}var sT=tT();function nT(t,s){if(t instanceof RegExp)return{keys:!1,pattern:t};var n,a,o,l,d=[],u="",h=t.split("/");for(h[0]||h.shift();o=h.shift();)n=o[0],n==="*"?(d.push(n),u+=o[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(a=o.indexOf("?",1),l=o.indexOf(".",1),d.push(o.substring(1,~a?a:~l?l:o.length)),u+=~a&&!~l?"(?:/([^/]+?))?":"/([^/]+?)",~l&&(u+=(~a?"?":"")+"\\"+o.substring(l))):u+="/"+o;return{keys:d,pattern:new RegExp("^"+u+(s?"(?=$|/)":"/?$"),"i")}}var m=Sm();const Os=vb(m),jb=QP({__proto__:null,default:Os},[m]);var Xf={exports:{}},Jf={};var Dj;function rT(){if(Dj)return Jf;Dj=1;var t=Sm();function s(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}var n=typeof Object.is=="function"?Object.is:s,a=t.useState,o=t.useEffect,l=t.useLayoutEffect,d=t.useDebugValue;function u(x,v){var w=v(),C=a({inst:{value:w,getSnapshot:v}}),j=C[0].inst,b=C[1];return l(function(){j.value=w,j.getSnapshot=v,h(j)&&b({inst:j})},[x,w,v]),o(function(){return h(j)&&b({inst:j}),x(function(){h(j)&&b({inst:j})})},[x]),d(w),w}function h(x){var v=x.getSnapshot;x=x.value;try{var w=v();return!n(x,w)}catch{return!0}}function f(x,v){return v()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:u;return Jf.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:g,Jf}var Oj;function aT(){return Oj||(Oj=1,Xf.exports=rT()),Xf.exports}var iT=aT();const oT=jb.useInsertionEffect,lT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",cT=lT?m.useLayoutEffect:m.useEffect,dT=oT||cT,wb=t=>{const s=m.useRef([t,(...n)=>s[0](...n)]).current;return dT(()=>{s[0]=t}),s[1]},uT="popstate",xg="pushState",vg="replaceState",mT="hashchange",Mj=[uT,xg,vg,mT],hT=t=>{for(const s of Mj)addEventListener(s,t);return()=>{for(const s of Mj)removeEventListener(s,t)}},bb=(t,s)=>
8iT.useSyncExternalStore(hT,t,s),fT=()=>location.search,pT=({ssrSearch:t=""}={})=>bb(fT,()=>t),Lj=()=>location.pathname,gT=({ssrPath:t}={})=>bb(Lj,t?()=>t:Lj),xT=(t,{replace:s=!1,state:n=null}={})=>history[s?vg:xg](n,"",t),vT=(t={})=>[gT(t),xT],Fj=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[Fj]>"u"){for(const t of[xg,vg]){const s=history[t];history[t]=function(){const n=s.apply(this,arguments),a=new Event(t);return a.arguments=arguments,dispatchEvent(a),n}}Object.defineProperty(window,Fj,{value:!0})}const yT=(t,s)=>s.toLowerCase().indexOf(t.toLowerCase())?"~"+s:s.slice(t.length)||"/",Nb=(t="")=>t==="/"?"":t,jT=(t,s)=>t[0]==="~"?t.slice(1):Nb(s)+t,wT=(t="",s)=>yT(Pp(Nb(t)),Pp(s)),bT=t=>t[0]==="?"?t.slice(1):t,Pp=t=>{try{return decodeURI(t)}catch{return t}},NT=t=>Pp(bT(t)),Sb={hook:vT,searchHook:pT,parser:nT,base:"",ssrPath:void 0,ssrSearch:void 0,hrefs:t=>t},Cb=m.createContext(Sb),so=()=>m.useContext(Cb),kb={},Pb=m.createContext(kb),ST=()=>m.useContext(Pb),Cm=t=>{const[s,n]=t.hook(t);return[wT(t.base,s),wb((a,o)=>n(jT(a,t.base),o))]},Kr=()=>Cm(so()),km=()=>{const t=so();return NT(t.searchHook(t))},yg=(t,s,n,a)=>{const{pattern:o,keys:l}=s instanceof RegExp?{keys:!1,pattern:s}:t(s||"*",a),d=o.exec(n)||[],[u,...h]=d;return u!==void 0?[!0,(()=>{const f=l!==!1?Object.fromEntries(l.map((x,v)=>[x,h[v]])):d.groups;let g={...h};return f&&Object.assign(g,f),g})(),...a?[u]:[]]:[!1,null]},ar=t=>yg(so().parser,t,Kr()[0]),CT=({children:t,...s})=>{const n=so(),a=s.hook?Sb:n;let o=a;const[l,d]=s.ssrPath?.split("?")??[];d&&(s.ssrSearch=d,s.ssrPath=l),s.hrefs=s.hrefs??s.hook?.hrefs;let u=m.useRef({}),h=u.current,f=h;for(let g in a){const x=g==="base"?a[g]+(s[g]||""):s[g]||a[g];h===f&&x!==f[g]&&(u.current=f={...f}),f[g]=x,x!==a[g]&&(o=f)}return m.createElement(Cb.Provider,{value:o,children:t})},$j=({children:t,component:s},n)=>s?m.createElement(s,{params:n}):typeof t=="function"?t(n):t,kT=t=>{let s=m.useRef(kb),n=s.current;for(const a in t)t[a]!==n[a]&&(n=t);return Object.keys(t).length===0&&(n=t),s.current=n},ps=({path:t,nest:s,match:n,...a})=>{const o=so(),[l]=Cm(o),[d,u,h]=n??yg(o.parser,t,l,s),f=kT({...ST(),...u});if(!d)return null;const g=h?m.createElement(CT,{base:h},$j(a,f)):$j(a,f);return m.createElement(Pb.Provider,{value:f,children:g})},ht=m.forwardRef((t,s)=>{const n=so(),[a,o]=Cm(n),{to:l="",href:d=l,onClick:u,asChild:h,children:f,className:g,replace:x,state:v,...w}=t,C=wb(b=>{b.ctrlKey||b.metaKey||b.altKey||b.shiftKey||b.button!==0||(u?.(b),b.defaultPrevented||(b.preventDefault(),o(d,t)))}),j=n.hrefs(d[0]==="~"?d.slice(1):n.base+d,n);return h&&m.isValidElement(f)?m.cloneElement(f,{onClick:C,href:j}):m.createElement("a",{...w,onClick:C,href:j,className:g?.call?g(a===d):g,children:f,ref:s})}),Tb=t=>Array.isArray(t)?t.flatMap(s=>Tb(s&&s.type===m.Fragment?s.props.children:s)):[t],PT=({children:t,location:s})=>{const n=so(),[a]=Cm(n);for(const o of Tb(t)){let l=0;if(m.isValidElement(o)&&(l=yg(n.parser,o.props.path,s||a,o.props.nest))[0])return m.cloneElement(o,{match:l})}return null};var dl=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ui=typeof window>"u"||"Deno"in globalThis;function xr(){}function TT(t,s){return typeof t=="function"?t(s):t}function Tp(t){return typeof t=="number"&&t>=0&&t!==1/0}function Eb(t,s){return Math.max(t+(s||0)-Date.now(),0)}function Vo(t,s){return typeof t=="function"?t(s):t}function Or(t,s){return typeof t=="function"?t(s):t}function Uj(t,s){const{type:n="all",exact:a,fetchStatus:o,predicate:l,queryKey:d,stale:u}=t;if(d){if(a){if(s.queryHash!==jg(d,s.options))return!1}else if(!Sc(s.queryKey,d))return!1}if(n!=="all"){const h=s.isActive();if(n==="active"&&!h||n==="inactive"&&h)return!1}return!(typeof u=="boolean"&&s.isStale()!==u||o&&o!==s.state.fetchStatus||l&&!l(s))}function zj(t,s){const{exact:n,status:a,predicate:o,mutationKey:l}=t;if(l){if(!s.options.mutationKey)return!1;if(n){if(zi(s.options.mutationKey)!==zi(l))return!1}else if(!Sc(s.options.mutationKey,l))return!1}return!(a&&s.state.status!==a||o&&!o(s))}function jg(t,s){return(s?.queryKeyHashFn||zi)(t)}function zi(t){return JSON.stringify(t,(s,n)=>Ep(n)?Object.keys(n).sort().reduce((a,o)=>(a[o]=n[o],a),{}):n)}function Sc(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?!Object.keys(s).some(n=>
vendor: 29,067 bytes, line 8
8!Sc(t[n],s[n])):!1}function _b(t,s){if(t===s)return t;const n=Bj(t)&&Bj(s);if(n||Ep(t)&&Ep(s)){const a=n?t:Object.keys(t),o=a.length,l=n?s:Object.keys(s),d=l.length,u=n?[]:{};let h=0;for(let f=0;f<d;f++){const g=n?f:l[f];(!n&&a.includes(g)||n)&&t[g]===void 0&&s[g]===void 0?(u[g]=void 0,h++):(u[g]=_b(t[g],s[g]),u[g]===t[g]&&t[g]!==void 0&&h++)}return o===d&&h===o?t:u}return s}function Uu(t,s){if(!s||Object.keys(t).length!==Object.keys(s).length)return!1;for(const n in t)if(t[n]!==s[n])return!1;return!0}function Bj(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Ep(t){if(!Vj(t))return!1;const s=t.constructor;if(s===void 0)return!0;const n=s.prototype;return!(!Vj(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Vj(t){return Object.prototype.toString.call(t)==="[object Object]"}function ET(t){return new Promise(s=>{setTimeout(s,t)})}function _p(t,s,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,s):n.structuralSharing!==!1?_b(t,s):s}function _T(t,s,n=0){const a=[...t,s];return n&&a.length>n?a.slice(1):a}function RT(t,s,n=0){const a=[s,...t];return n&&a.length>n?a.slice(0,-1):a}var wg=Symbol();function Rb(t,s){return!t.queryFn&&s?.initialPromise?()=>s.initialPromise:!t.queryFn||t.queryFn===wg?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}var AT=class extends dl{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Ui&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(s=>{s(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},bg=new AT,IT=class extends dl{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Ui&&window.addEventListener){const s=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},zu=new IT;function Rp(){let t,s;const n=new Promise((o,l)=>{t=o,s=l});n.status="pending",n.catch(()=>{});function a(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{a({status:"fulfilled",value:o}),t(o)},n.reject=o=>{a({status:"rejected",reason:o}),s(o)},n}function DT(t){return Math.min(1e3*2**t,3e4)}function Ab(t){return(t??"online")==="online"?zu.isOnline():!0}var Ib=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function ep(t){return t instanceof Ib}function Db(t){let s=!1,n=0,a=!1,o;const l=Rp(),d=j=>{a||(v(new Ib(j)),t.abort?.())},u=()=>{s=!0},h=()=>{s=!1},f=()=>bg.isFocused()&&(t.networkMode==="always"||zu.isOnline())&&t.canRun(),g=()=>Ab(t.networkMode)&&t.canRun(),x=j=>{a||(a=!0,t.onSuccess?.(j),o?.(),l.resolve(j))},v=j=>{a||(a=!0,t.onError?.(j),o?.(),l.reject(j))},w=()=>new Promise(j=>{o=b=>{(a||f())&&j(b)},t.onPause?.()}).then(()=>{o=void 0,a||t.onContinue?.()}),C=()=>{if(a)return;let j;const b=n===0?t.initialPromise:void 0;try{j=b??t.fn()}catch(k){j=Promise.reject(k)}Promise.resolve(j).then(x).catch(k=>{if(a)return;const N=t.retry??(Ui?0:3),T=t.retryDelay??DT,P=typeof T=="function"?T(n,k):T,I=N===!0||typeof N=="number"&&n<N||typeof N=="function"&&N(n,k);if(s||!I){v(k);return}n++,t.onFail?.(n,k),ET(P).then(()=>f()?void 0:w()).then(()=>{s?v(k):C()})})};return{promise:l,cancel:d,continue:()=>(o?.(),l),cancelRetry:u,continueRetry:h,canStart:g,start:()=>(g()?C():w().then(C),l)}}function OT(){let t=[],s=0,n=u=>{u()},a=u=>{u()},o=u=>setTimeout(u,0);const l=u=>{s?t.push(u):o(()=>{n(u)})},d=()=>{const u=t;t=[],u.length&&o(()=>{a(()=>{u.forEach(h=>{n(h)})})})};return{batch:u=>{let h;s++;try{h=u()}finally{s--,s||d()}return h},batchCalls:u=>(...h)=>{l(()=>{u(...h)})},schedule:l,setNotifyFunction:u=>{n=u},setBatchNotifyFunction:u=>{a=u},setScheduler:u=>{o=u}}}var Js=OT(),Ob=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Tp(this.gcTime)&&(this.#e=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Ui?1/0:300*1e3))}clearGcTimeout(){this.#e&&(clearTimeout(this.#e),this.#e=void 0)}},MT=class extends Ob{#e;#t;#n;#s;#i;#a;constructor(t){super(),this.#a=!1,this.#i=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#n=t.cache,this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=LT(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#s?.promise}setOptions(t){this.options={...this.#i,...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,s){const n=_p(this.state.data,t,this.options);return this.#r({data:n,type:"success",dataUpdatedAt:s?.updatedAt,manual:s?.manual}),n}setState(t,s){this.#r({type:"setState",state:t,setStateOptions:s})}cancel(t){const s=this.#s?.promise;return this.#s?.cancel(t),s?s.then(xr).catch(xr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Or(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===wg||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(t=0){return this.state.isInvalidated||this.state.data===void 0||!Eb(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(s=>s.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#s?.continue()}onOnline(){this.observers.find(s=>s.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#s?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(s=>s!==t),this.observers.length||(this.#s&&(this.#a?this.#s.cancel({revert:!0}):this.#s.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#r({type:"invalidate"})}fetch(t,s){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&s?.cancelRefetch)this.cancel({silent:!0});else if(this.#s)return this.#s.continueRetry(),this.#s.promise}if(t&&this.setOptions(t),!this.options.queryFn){const u=this.observers.find(h=>h.options.queryFn);u&&this.setOptions(u.options)}const n=new AbortController,a=u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:()=>(this.#a=!0,n.signal)})},o=()=>{const u=Rb(this.options,s),h={queryKey:this.queryKey,meta:this.meta};return a(h),this.#a=!1,this.options.persister?this.options.persister(u,h,this):u(h)},l={fetchOptions:s,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:o};a(l),this.options.behavior?.onFetch(l,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==l.fetchOptions?.meta)&&this.#r({type:"fetch",meta:l.fetchOptions?.meta});const d=u=>{ep(u)&&u.silent||this.#r({type:"error",error:u}),ep(u)||(this.#n.config.onError?.(u,this),this.#n.config.onSettled?.(this.state.data,u,this)),this.scheduleGc()};return this.#s=Db({initialPromise:s?.initialPromise,fn:l.fetchFn,abort:n.abort.bind(n),onSuccess:u=>{if(u===void 0){d(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(u)}catch(h){d(h);return}this.#n.config.onSuccess?.(u,this),this.#n.config.onSettled?.(u,this.state.error,this),this.scheduleGc()},onError:d,onFail:(u,h)=>{this.#r({type:"failed",failureCount:u,error:h})},onPause:()=>{this.#r({type:"pause"})},onContinue:()=>{this.#r({type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}),this.#s.start()}#r(t){const s=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Mb(n.data,this.options),fetchMeta:t.meta??null};case"success":return{...n,data:t.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const a=t.error;return ep(a)&&a.revert&&this.#t?{...this.#t,fetchStatus:"idle"}:{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=s(this.state),Js.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function Mb(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ab(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function LT(t){const s=typeof t.initialData=="function"?t.initialData():t.initialData,n=s!==void 0,a=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:s,dataUpdateCount:0,dataUpdatedAt:n?a??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var FT=class extends dl{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,s,n){const a=s.queryKey,o=s.queryHash??jg(a,s);let l=this.get(o);return l||(l=new MT({cache:this,queryKey:a,queryHash:o,options:t.defaultQueryOptions(s),state:n,defaultOptions:t.getQueryDefaults(a)}),this.add(l)),l}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=this.#e.get(t.queryHash);s&&(t.destroy(),s===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Js.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const s={exact:!0,...t};return this.getAll().find(n=>Uj(s,n))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(n=>Uj(t,n)):s}notify(t){Js.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){Js.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Js.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},$T=class extends Ob{#e;#t;#n;constructor(t){super(),this.mutationId=t.mutationId,this.#t=t.mutationCache,this.#e=[],this.state=t.state||Lb(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(s=>s!==t),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#t.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(t){this.#n=Db({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(a,o)=>{this.#s({type:"failed",failureCount:a,error:o})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});const s=this.state.status==="pending",n=!this.#n.canStart();try{if(!s){this.#s({type:"pending",variables:t,isPaused:n}),await this.#t.config.onMutate?.(t,this);const o=await this.options.onMutate?.(t);o!==this.state.context&&this.#s({type:"pending",context:o,variables:t,isPaused:n})}const a=await this.#n.start();return await this.#t.config.onSuccess?.(a,t,this.state.context,this),await this.options.onSuccess?.(a,t,this.state.context),await this.#t.config.onSettled?.(a,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(a,null,t,this.state.context),this.#s({type:"success",data:a}),a}catch(a){try{throw await this.#t.config.onError?.(a,t,this.state.context,this),await this.options.onError?.(a,t,this.state.context),await this.#t.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,a,t,this.state.context),a}finally{this.#s({type:"error",error:a})}}finally{this.#t.runNext(this)}}#s(t){const s=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=s(this.state),Js.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#t.notify({mutation:this,type:"updated",action:t})})}};function Lb(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var UT=class extends dl{constructor(t={}){super(),this.config=t,this.#e=new Map,this.#t=Date.now()}#e;#t;build(t,s,n){const a=new $T({mutationCache:this,mutationId:++this.#t,options:t.defaultMutationOptions(s),state:n});return this.add(a),a}add(t){const s=wu(t),n=this.#e.get(s)??[];n.push(t),this.#e.set(s,n),this.notify({type:"added",mutation:t})}remove(t){const s=wu(t);if(this.#e.has(s)){const n=this.#e.get(s)?.filter(a=>a!==t);n&&(n.length===0?this.#e.delete(s):this.#e.set(s,n))}this.notify({type:"removed",mutation:t})}canRun(t){const s=this.#e.get(wu(t))?.find(n=>n.state.status==="pending");return!s||s===t}runNext(t){return this.#e.get(wu(t))?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve()}clear(){Js.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}getAll(){return[...this.#e.values()].flat()}find(t){const s={exact:!0,...t};return this.getAll().find(n=>zj(s,n))}findAll(t={}){return this.getAll().filter(s=>zj(t,s))}notify(t){Js.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){const t=this.getAll().filter(s=>s.state.isPaused);return Js.batch(()=>Promise.all(t.map(s=>s.continue().catch(xr))))}};function wu(t){return t.options.scope?.id??String(t.mutationId)}function qj(t){return{onFetch:(s,n)=>{const a=s.options,o=s.fetchOptions?.meta?.fetchMore?.direction,l=s.state.data?.pages||[],d=s.state.data?.pageParams||[];let u={pages:[],pageParams:[]},h=0;const f=async()=>{let g=!1;const x=C=>{Object.defineProperty(C,"signal",{enumerable:!0,get:()=>(s.signal.aborted?g=!0:s.signal.addEventListener("abort",()=>{g=!0}),s.signal)})},v=Rb(s.options,s.fetchOptions),w=async(C,j,b)=>{if(g)return Promise.reject();if(j==null&&C.pages.length)return Promise.resolve(C);const k={queryKey:s.queryKey,pageParam:j,direction:b?"backward":"forward",meta:s.options.meta};x(k);const N=await v(k),{maxPages:T}=s.options,P=b?RT:_T;return{pages:P(C.pages,N,T),pageParams:P(C.pageParams,j,T)}};if(o&&l.length){const C=o==="backward",j=C?zT:Kj,b={pages:l,pageParams:d},k=j(a,b);u=await w(b,k,C)}else{const C=t??l.length;do{const j=h===0?d[0]??a.initialPageParam:Kj(a,u);if(h>0&&j==null)break;u=await w(u,j),h++}while(h<C)}return u};s.options.persister?s.fetchFn=()=>s.options.persister?.(f,{queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},n):s.fetchFn=f}}}function Kj(t,{pages:s,pageParams:n}){const a=s.length-1;return s.length>0?t.getNextPageParam(s[a],s,n[a],n):void 0}function zT(t,{pages:s,pageParams:n}){return s.length>0?t.getPreviousPageParam?.(s[0],s,n[0],n):void 0}var BT=class{#e;#t;#n;#s;#i;#a;#r;#o;constructor(t={}){this.#e=t.queryCache||new FT,this.#t=t.mutationCache||new UT,this.#n=t.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#r=bg.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#o=zu.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#r?.(),this.#r=void 0,this.#o?.(),this.#o=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const s=this.defaultQueryOptions({queryKey:t});return this.#e.get(s.queryHash)?.state.data}ensureQueryData(t){const s=this.getQueryData(t.queryKey);if(s===void 0)return this.fetchQuery(t);{const n=this.defaultQueryOptions(t),a=this.#e.build(this,n);return t.revalidateIfStale&&a.isStaleByTime(Vo(n.staleTime,a))&&this.prefetchQuery(n),Promise.resolve(s)}}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:s,state:n})=>{const a=n.data;return[s,a]})}setQueryData(t,s,n){const a=this.defaultQueryOptions({queryKey:t}),l=this.#e.get(a.queryHash)?.state.data,d=TT(s,l);if(d!==void 0)return this.#e.build(this,a).setData(d,{...n,manual:!0})}setQueriesData(t,s,n){return Js.batch(()=>this.#e.findAll(t).map(({queryKey:a})=>[a,this.setQueryData(a,s,n)]))}getQueryState(t){const s=this.defaultQueryOptions({queryKey:t});return this.#e.get(s.queryHash)?.state}removeQueries(t){const s=this.#e;Js.batch(()=>{s.findAll(t).forEach(n=>{s.remove(n)})})}resetQueries(t,s){const n=this.#e,a={type:"active",...t};return Js.batch(()=>(n.findAll(t).forEach(o=>{o.reset()}),this.refetchQueries(a,s)))}cancelQueries(t={},s={}){const n={revert:!0,...s},a=Js.batch(()=>this.#e.findAll(t).map(o=>o.cancel(n)));return Promise.all(a).then(xr).catch(xr)}invalidateQueries(t={},s={}){return Js.batch(()=>{if(this.#e.findAll(t).forEach(a=>{a.invalidate()}),t.refetchType==="none")return Promise.resolve();const n={...t,type:t.refetchType??t.type??"active"};return this.refetchQueries(n,s)})}refetchQueries(t={},s){const n={...s,cancelRefetch:s?.cancelRefetch??!0},a=Js.batch(()=>this.#e.findAll(t).filter(o=>!o.isDisabled()).map(o=>{let l=o.fetch(void 0,n);return n.throwOnError||(l=l.catch(xr)),o.state.fetchStatus==="paused"?Promise.resolve():l}));return Promise.all(a).then(xr)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const n=this.#e.build(this,s);return n.isStaleByTime(Vo(s.staleTime,n))?n.fetch(s):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(xr).catch(xr)}fetchInfiniteQuery(t){return t.behavior=qj(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(xr).catch(xr)}ensureInfiniteQueryData(t){return t.behavior=qj(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return zu.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,s){this.#s.set(zi(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...this.#s.values()];let n={};return s.forEach(a=>{Sc(t,a.queryKey)&&(n={...n,...a.defaultOptions})}),n}setMutationDefaults(t,s){this.#i.set(zi(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...this.#i.values()];let n={};return s.forEach(a=>{Sc(t,a.mutationKey)&&(n={...n,...a.defaultOptions})}),n}defaultQueryOptions(t){if(t._defaulted)return t;const s={...this.#n.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=jg(s.queryKey,s)),s.refetchOnReconnect===void 0&&(s.refetchOnReconnect=s.networkMode!=="always"),s.throwOnError===void 0&&(s.throwOnError=!!s.suspense),!s.networkMode&&s.persister&&(s.networkMode="offlineFirst"),s.enabled!==!0&&s.queryFn===wg&&(s.enabled=!1),s}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},VT=class extends dl{constructor(t,s){super(),this.options=s,this.#e=t,this.#o=null,this.#r=Rp(),this.options.experimental_prefetchInRender||this.#r.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(s)}#e;#t=void 0;#n=void 0;#s=void 0;#i;#a;#r;#o;#p;#m;#h;#c;#d;#l;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Hj(this.#t,this.options)?this.#u():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ap(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ap(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#j(),this.#w(),this.#t.removeObserver(this)}setOptions(t,s){const n=this.options,a=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Or(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#b(),this.#t.setOptions(this.options),n._defaulted&&!Uu(this.options,n)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const o=this.hasListeners();o&&Wj(this.#t,a,this.options,n)&&this.#u(),this.updateResult(s),o&&(this.#t!==a||Or(this.options.enabled,this.#t)!==Or(n.enabled,this.#t)||Vo(this.options.staleTime,this.#t)!==Vo(n.staleTime,this.#t))&&this.#g();const l=this.#x();o&&(this.#t!==a||Or(this.options.enabled,this.#t)!==Or(n.enabled,this.#t)||l!==this.#l)&&this.#v(l)}getOptimisticResult(t){const s=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(s,t);return KT(this,n)&&(this.#s=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#s}trackResult(t,s){const n={};return Object.keys(t).forEach(a=>{Object.defineProperty(n,a,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(a),s?.(a),t[a])})}),n}trackProp(t){this.#f.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,s);return n.fetch().then(()=>this.createResult(n,s))}fetch(t){return this.#u({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#u(t){this.#b();let s=this.#t.fetch(this.options,t);return t?.throwOnError||(s=s.catch(xr)),s}#g(){this.#j();const t=Vo(this.options.staleTime,this.#t);if(Ui||this.#s.isStale||!Tp(t))return;const n=Eb(this.#s.dataUpdatedAt,t)+1;this.#c=setTimeout(()=>{this.#s.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#w(),this.#l=t,!(Ui||Or(this.options.enabled,this.#t)===!1||!Tp(this.#l)||this.#l===0)&&(this.#d=setInterval(()=>{(this.options.refetchIntervalInBackground||bg.isFocused())&&this.#u()},this.#l))}#y(){this.#g(),this.#v(this.#x())}#j(){this.#c&&(clearTimeout(this.#c),this.#c=void 0)}#w(){this.#d&&(clearInterval(this.#d),this.#d=void 0)}createResult(t,s){const n=this.#t,a=this.options,o=this.#s,l=this.#i,d=this.#a,h=t!==n?t.state:this.#n,{state:f}=t;let g={...f},x=!1,v;if(s._optimisticResults){const R=this.hasListeners(),F=!R&&Hj(t,s),M=R&&Wj(t,n,s,a);(F||M)&&(g={...g,...Mb(f.data,t.options)}),s._optimisticResults==="isRestoring"&&(g.fetchStatus="idle")}let{error:w,errorUpdatedAt:C,status:j}=g;if(s.select&&g.data!==void 0)if(o&&g.data===l?.data&&s.select===this.#p)v=this.#m;else try{this.#p=s.select,v=s.select(g.data),v=_p(o?.data,v,s),this.#m=v,this.#o=null}catch(R){this.#o=R}else v=g.data;if(s.placeholderData!==void 0&&v===void 0&&j==="pending"){let R;if(o?.isPlaceholderData&&s.placeholderData===d?.placeholderData)R=o.data;else if(R=typeof s.placeholderData=="function"?s.placeholderData(this.#h?.state.data,this.#h):s.placeholderData,s.select&&R!==void 0)try{R=s.select(R),this.#o=null}catch(F){this.#o=F}R!==void 0&&(j="success",v=_p(o?.data,R,s),x=!0)}this.#o&&(w=this.#o,v=this.#m,C=Date.now(),j="error");const b=g.fetchStatus==="fetching",k=j==="pending",N=j==="error",T=k&&b,P=v!==void 0,O={status:j,fetchStatus:g.fetchStatus,isPending:k,isSuccess:j==="success",isError:N,isInitialLoading:T,isLoading:T,data:v,dataUpdatedAt:g.dataUpdatedAt,error:w,errorUpdatedAt:C,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>h.dataUpdateCount||g.errorUpdateCount>h.errorUpdateCount,isFetching:b,isRefetching:b&&!k,isLoadingError:N&&!P,isPaused:g.fetchStatus==="paused",isPlaceholderData:x,isRefetchError:N&&P,isStale:Ng(t,s),refetch:this.refetch,promise:this.#r};if(this.options.experimental_prefetchInRender){const R=z=>{O.status==="error"?z.reject(O.error):O.data!==void 0&&z.resolve(O.data)},F=()=>{const z=this.#r=O.promise=Rp();R(z)},M=this.#r;switch(M.status){case"pending":t.queryHash===n.queryHash&&R(M);break;case"fulfilled":(O.status==="error"||O.data!==M.value)&&F();break;case"rejected":(O.status!=="error"||O.error!==M.reason)&&F();break}}return O}updateResult(t){const s=this.#s,n=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#h=this.#t),Uu(n,s))return;this.#s=n;const a={},o=()=>{if(!s)return!0;const{notifyOnChangeProps:l}=this.options,d=typeof l=="function"?l():l;if(d==="all"||!d&&!this.#f.size)return!0;const u=new Set(d??this.#f);return this.options.throwOnError&&u.add("error"),Object.keys(this.#s).some(h=>{const f=h;return this.#s[f]!==s[f]&&u.has(f)})};t?.listeners!==!1&&o()&&(a.listeners=!0),this.#N({...a,...t})}#b(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const s=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(s?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#N(t){Js.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function qT(t,s){return Or(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function Hj(t,s){return qT(t,s)||t.state.data!==void 0&&Ap(t,s,s.refetchOnMount)}function Ap(t,s,n){if(Or(s.enabled,t)!==!1){const a=typeof n=="function"?n(t):n;return a==="always"||a!==!1&&Ng(t,s)}return!1}function Wj(t,s,n,a){return(t!==s||Or(a.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&Ng(t,n)}function Ng(t,s){return Or(s.enabled,t)!==!1&&t.isStaleByTime(Vo(s.staleTime,t))}function KT(t,s){return!Uu(t.getCurrentResult(),s)}var HT=class extends dl{#e;#t=void 0;#n;#s;constructor(s,n){super(),this.#e=s,this.setOptions(n),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(s){const n=this.options;this.options=this.#e.defaultMutationOptions(s),Uu(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&zi(n.mutationKey)!==zi(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(s){this.#i(),this.#a(s)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(s,n){return this.#s=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(s)}#i(){const s=this.#n?.state??Lb();this.#t={...s,isPending:s.status==="pending",isSuccess:s.status==="success",isError:s.status==="error",isIdle:s.status==="idle",mutate:this.mutate,reset:this.reset}}#a(s){Js.batch(()=>
8{if(this.#s&&this.hasListeners()){const n=this.#t.variables,a=this.#t.context;s?.type==="success"?(this.#s.onSuccess?.(s.data,n,a),this.#s.onSettled?.(s.data,null,n,a)):s?.type==="error"&&(this.#s.onError?.(s.error,n,a),this.#s.onSettled?.(void 0,s.error,n,a))}this.listeners.forEach(n=>{n(this.#t)})})}},Fb=m.createContext(void 0),Sg=t=>{const s=m.useContext(Fb);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},WT=({client:t,children:s})=>(m.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(Fb.Provider,{value:t,children:s})),$b=m.createContext(!1),QT=()=>m.useContext($b);$b.Provider;function GT(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var YT=m.createContext(GT()),ZT=()=>m.useContext(YT);function Ub(t,s){return typeof t=="function"?t(...s):!!t}function Ip(){}var XT=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},JT=t=>{m.useEffect(()=>{t.clearReset()},[t])},e4=({result:t,errorResetBoundary:s,throwOnError:n,query:a})=>t.isError&&!s.isReset()&&!t.isFetching&&a&&Ub(n,[t.error,a]),t4=t=>{t.suspense&&(t.staleTime===void 0&&(t.staleTime=1e3),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3)))},s4=(t,s)=>t.isLoading&&t.isFetching&&!s,n4=(t,s)=>t?.suspense&&s.isPending,Qj=(t,s,n)=>s.fetchOptimistic(t).catch(()=>{n.clearReset()});function r4(t,s,n){const a=Sg(),o=QT(),l=ZT(),d=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(d),d._optimisticResults=o?"isRestoring":"optimistic",t4(d),XT(d,l),JT(l);const u=!a.getQueryCache().get(d.queryHash),[h]=m.useState(()=>new s(a,d)),f=h.getOptimisticResult(d);if(m.useSyncExternalStore(m.useCallback(g=>{const x=o?Ip:h.subscribe(Js.batchCalls(g));return h.updateResult(),x},[h,o]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),m.useEffect(()=>{h.setOptions(d,{listeners:!1})},[d,h]),n4(d,f))throw Qj(d,h,l);if(e4({result:f,errorResetBoundary:l,throwOnError:d.throwOnError,query:a.getQueryCache().get(d.queryHash)}))throw f.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(d,f),d.experimental_prefetchInRender&&!Ui&&s4(f,o)&&(u?Qj(d,h,l):a.getQueryCache().get(d.queryHash)?.promise)?.catch(Ip).finally(()=>{h.updateResult()}),d.notifyOnChangeProps?f:h.trackResult(f)}function je(t,s){return r4(t,VT)}function ye(t,s){const n=Sg(),[a]=m.useState(()=>new HT(n,t));m.useEffect(()=>{a.setOptions(t)},[a,t]);const o=m.useSyncExternalStore(m.useCallback(d=>a.subscribe(Js.batchCalls(d)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),l=m.useCallback((d,u)=>
8{a.mutate(d,u).catch(Ip)},[a]);if(o.error&&Ub(a.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:l,mutateAsync:o.mutate}}const Bu="outliner-portal-auth-token";function zb(){try{const t=localStorage.getItem(Bu);if(t)return{Authorization:`Bearer ${t}`}}catch{}return{}}function ri(t){t?localStorage.setItem(Bu,t):localStorage.removeItem(Bu)}function Gn(){return localStorage.getItem(Bu)}async function Bb(t){if(!t.ok){const s=await t.text()||t.statusText;throw new Error(`${t.status}: ${s}`)}}async function ce(t,s,n){const a={...zb(),...n?{"Content-Type":"application/json"}:{}},o=await fetch(s,{method:t,headers:a,body:n?JSON.stringify(n):void 0,credentials:"include"});return await Bb(o),o}const a4=({on401:t})=>async({queryKey:s})=>{const n=await fetch(s.join("/"),{credentials:"include",headers:zb()});return await Bb(n),await n.json()},de=new BT({defaultOptions:{queries:{queryFn:a4({on401:"throw"}),refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:3e4,retry:!1},mutations:{retry:!1}}}),i4=1,o4=1e6;let tp=0;function l4(){return tp=(tp+1)%Number.MAX_SAFE_INTEGER,tp.toString()}const sp=new Map,Gj=t=>{if(sp.has(t))return;const s=setTimeout(()=>{sp.delete(t),vc({type:"REMOVE_TOAST",toastId:t})},o4);sp.set(t,s)},c4=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,i4)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(n=>n.id===s.toast.id?{...n,...s.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=s;return n?Gj(n):t.toasts.forEach(a=>{Gj(a.id)}),{...t,toasts:t.toasts.map(a=>a.id===n||n===void 0?{...a,open:!1}:a)}}case"REMOVE_TOAST":return s.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(n=>n.id!==s.toastId)}}},Iu=[];let Du={toasts:[]};function vc(t){Du=c4(Du,t),Iu.forEach(s=>{s(Du)})}function d4({...t}){const s=l4(),n=o=>vc({type:"UPDATE_TOAST",toast:{...o,id:s}}),a=()=>vc({type:"DISMISS_TOAST",toastId:s});return vc({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:o=>{o||a()}}}),{id:s,dismiss:a,update:n}}function dt(){const[t,s]=m.useState(Du);return m.useEffect(()=>(Iu.push(s),()=>{const n=Iu.indexOf(s);n>-1&&Iu.splice(n,1)}),[t]),{...t,toast:d4,dismiss:n=>vc({type:"DISMISS_TOAST",toastId:n})}}var Mr=yb();const u4=vb(Mr);function Ae(t,s,{checkForDefaultPrevented:n=!0}={}){return function(o){if(t?.(o),n===!1||!o.defaultPrevented)return s?.(o)}}function Yj(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function Pm(...t){return s=>{let n=!1;const a=t.map(o=>{const l=Yj(o,s);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let o=0;o<a.length;o++){const l=a[o];typeof l=="function"?l():Yj(t[o],null)}}}}function At(...t){return m.useCallback(Pm(...t),t)}function m4(t,s){const n=m.createContext(s),a=l=>{const{children:d,...u}=l,h=m.useMemo(()=>u,Object.values(u));return e.jsx(n.Provider,{value:h,children:d})};a.displayName=t+"Provider";function o(l){const d=m.useContext(n);if(d)return d;if(s!==void 0)return s;throw new Error(`\`${l}\` must be used within \`${t}\``)}return[a,o]}function En(t,s=[]){let n=[];function a(l,d){const u=m.createContext(d),h=n.length;n=[...n,d];const f=x=>{const{scope:v,children:w,...C}=x,j=v?.[t]?.[h]||u,b=m.useMemo(()=>C,Object.values(C));return e.jsx(j.Provider,{value:b,children:w})};f.displayName=l+"Provider";function g(x,v){const w=v?.[t]?.[h]||u,C=m.useContext(w);if(C)return C;if(d!==void 0)return d;throw new Error(`\`${x}\` must be used within \`${l}\``)}return[f,g]}const o=()=>{const l=n.map(d=>m.createContext(d));return function(u){const h=u?.[t]||l;return m.useMemo(()=>({[`__scope${t}`]:{...u,[t]:h}}),[u,h])}};return o.scopeName=t,[a,h4(o,...s)]}function h4(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const a=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(l){const d=a.reduce((u,{useScope:h,scopeName:f})=>{const x=h(l)[`__scope${f}`];return{...u,...x}},{});return m.useMemo(()=>({[`__scope${s.scopeName}`]:d}),[d])}};return n.scopeName=s.scopeName,n}function Bi(t){const s=f4(t),n=m.forwardRef((a,o)=>{const{children:l,...d}=a,u=m.Children.toArray(l),h=u.find(p4);if(h){const f=h.props.children,g=u.map(x=>x===h?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:x);return e.jsx(s,{...d,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,g):null})}return e.jsx(s,{...d,ref:o,children:l})});return n.displayName=`${t}.Slot`,n}var Cg=Bi("Slot");function f4(t){const s=m.forwardRef((n,a)=>{const{children:o,...l}=n;if(m.isValidElement(o)){const d=x4(o),u=g4(l,o.props);return o.type!==m.Fragment&&(u.ref=a?Pm(a,d):d),m.cloneElement(o,u)}return m.Children.count(o)>1?m.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var Vb=Symbol("radix.slottable");function qb(t){const s=({children:n})=>e.jsx(e.Fragment,{children:n});return s.displayName=`${t}.Slottable`,s.__radixId=Vb,s}function p4(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Vb}function g4(t,s){const n={...s};for(const a in s){const o=t[a],l=s[a];/^on[A-Z]/.test(a)?o&&l?n[a]=(...u)=>{l(...u),o(...u)}:o&&(n[a]=o):a==="style"?n[a]={...o,...l}
vendor: 6,638 bytes, line 8
8:a==="className"&&(n[a]=[o,l].filter(Boolean).join(" "))}return{...t,...n}}function x4(t){let s=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function Tm(t){const s=t+"CollectionProvider",[n,a]=En(s),[o,l]=n(s,{collectionRef:{current:null},itemMap:new Map}),d=j=>{const{scope:b,children:k}=j,N=Os.useRef(null),T=Os.useRef(new Map).current;return e.jsx(o,{scope:b,itemMap:T,collectionRef:N,children:k})};d.displayName=s;const u=t+"CollectionSlot",h=Bi(u),f=Os.forwardRef((j,b)=>{const{scope:k,children:N}=j,T=l(u,k),P=At(b,T.collectionRef);return e.jsx(h,{ref:P,children:N})});f.displayName=u;const g=t+"CollectionItemSlot",x="data-radix-collection-item",v=Bi(g),w=Os.forwardRef((j,b)=>{const{scope:k,children:N,...T}=j,P=Os.useRef(null),I=At(b,P),O=l(g,k);return Os.useEffect(()=>(O.itemMap.set(P,{ref:P,...T}),()=>{O.itemMap.delete(P)})),e.jsx(v,{[x]:"",ref:I,children:N})});w.displayName=g;function C(j){const b=l(t+"CollectionConsumer",j);return Os.useCallback(()=>{const N=b.collectionRef.current;if(!N)return[];const T=Array.from(N.querySelectorAll(`[${x}]`));return Array.from(b.itemMap.values()).sort((O,R)=>T.indexOf(O.ref.current)-T.indexOf(R.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:d,Slot:f,ItemSlot:w},C,a]}var v4=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],at=v4.reduce((t,s)=>{const n=Bi(`Primitive.${s}`),a=m.forwardRef((o,l)=>{const{asChild:d,...u}=o,h=d?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(h,{...u,ref:l})});return a.displayName=`Primitive.${s}`,{...t,[s]:a}},{});function kg(t,s){t&&Mr.flushSync(()=>t.dispatchEvent(s))}function Rs(t){const s=m.useRef(t);return m.useEffect(()=>{s.current=t}),m.useMemo(()=>(...n)=>s.current?.(...n),[])}function y4(t,s=globalThis?.document){const n=Rs(t);m.useEffect(()=>{const a=o=>{o.key==="Escape"&&n(o)};return s.addEventListener("keydown",a,{capture:!0}),()=>s.removeEventListener("keydown",a,{capture:!0})},[n,s])}var j4="DismissableLayer",Dp="dismissableLayer.update",w4="dismissableLayer.pointerDownOutside",b4="dismissableLayer.focusOutside",Zj,Kb=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ul=m.forwardRef((t,s)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:l,onInteractOutside:d,onDismiss:u,...h}=t,f=m.useContext(Kb),[g,x]=m.useState(null),v=g?.ownerDocument??globalThis?.document,[,w]=m.useState({}),C=At(s,R=>x(R)),j=Array.from(f.layers),[b]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),k=j.indexOf(b),N=g?j.indexOf(g):-1,T=f.layersWithOutsidePointerEventsDisabled.size>0,P=N>=k,I=S4(R=>{const F=R.target,M=[...f.branches].some(z=>z.contains(F));!P||M||(o?.(R),d?.(R),R.defaultPrevented||u?.())},v),O=C4(R=>{const F=R.target;[...f.branches].some(z=>z.contains(F))||(l?.(R),d?.(R),R.defaultPrevented||u?.())},v);return y4(R=>{N===f.layers.size-1&&(a?.(R),!R.defaultPrevented&&u&&(R.preventDefault(),u()))},v),m.useEffect(()=>{if(g)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Zj=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(g)),f.layers.add(g),Xj(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=Zj)}},[g,v,n,f]),m.useEffect(()=>()=>{g&&(f.layers.delete(g),f.layersWithOutsidePointerEventsDisabled.delete(g),Xj())},[g,f]),m.useEffect(()=>{const R=()=>w({});return document.addEventListener(Dp,R),()=>document.removeEventListener(Dp,R)},[]),e.jsx(at.div,{...h,ref:C,style:{pointerEvents:T?P?"auto":"none":void 0,...t.style},onFocusCapture:Ae(t.onFocusCapture,O.onFocusCapture),onBlurCapture:Ae(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:Ae(t.onPointerDownCapture,I.onPointerDownCapture)})});ul.displayName=j4;var N4="DismissableLayerBranch",Hb=m.forwardRef((t,s)=>{const n=m.useContext(Kb),a=m.useRef(null),o=At(s,a);return m.useEffect(()=>{const l=a.current;if(l)return n.branches.add(l),()=>{n.branches.delete(l)}},[n.branches]),e.jsx(at.div,{...t,ref:o})});Hb.displayName=N4;function S4(t,s=globalThis?.document){const n=Rs(t),a=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const l=u=>{if(u.target&&!a.current){let h=function(){Wb(w4,n,f,{discrete:!0})};const f={originalEvent:u};u.pointerType==="touch"?(s.removeEventListener("click",o.current),o.current=h,s.addEventListener("click",o.current,{once:!0})):h()}else s.removeEventListener("click",o.current);a.current=!1},d=window.setTimeout(()=>{s.addEventListener("pointerdown",l)},0);return()=>{window.clearTimeout(d),s.removeEventListener("pointerdown",l),s.removeEventListener("click",o.current)}},[s,n]),{onPointerDownCapture:()=>a.current=!0}}function C4(t,s=globalThis?.document){const n=Rs(t),a=m.useRef(!1);return m.useEffect(()=>{const o=l=>{l.target&&!a.current&&Wb(b4,n,{originalEvent:l},{discrete:!1})};return s.addEventListener("focusin",o),()=>s.removeEventListener("focusin",o)},[s,n]),{onFocusCapture:()=>a.current=!0,onBlurCapture:()=>a.current=!1}}function Xj(){const t=new CustomEvent(Dp);document.dispatchEvent(t)}function Wb(t,s,n,{discrete:a}){const o=n.originalEvent.target,l=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});s&&o.addEventListener(t,s,{once:!0}),a?kg(o,l):o.dispatchEvent(l)}var k4=ul,P4=Hb,cn=globalThis?.document?m.useLayoutEffect:()=>{},T4="Portal",Zc=m.forwardRef((t,s)=>{const{container:n,...a}=t,[o,l]=m.useState(!1);cn(()=>l(!0),[]);const d=n||o&&globalThis?.document?.body;return d?u4.createPortal(e.jsx(at.div,{...a,ref:s}),d):null});Zc.displayName=T4;function E4(t,s){return m.useReducer((n,a)=>s[n][a]??n,t)}var gn=t=>{const{present:s,children:n}=t,a=_4(s),o=typeof n=="function"?n({present:a.isPresent}):m.Children.only(n),l=At(a.ref,R4(o));return typeof n=="function"||a.isPresent?m.cloneElement(o,{ref:l}):null};gn.displayName="Presence";function _4(t){const[s,n]=m.useState(),a=m.useRef({}),o=m.useRef(t),l=m.useRef("none"),d=t?"mounted":"unmounted",[u,h]=E4(d,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const f=bu(a.current);l.current=u==="mounted"?f:"none"},[u]),cn(()=>{const f=a.current,g=o.current;if(g!==t){const v=l.current,w=bu(f);t?h("MOUNT"):w==="none"||f?.display==="none"?h("UNMOUNT"):h(g&&v!==w?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,h]),cn(()=>
8{if(s){let f;const g=s.ownerDocument.defaultView??window,x=w=>{const j=bu(a.current).includes(w.animationName);if(w.target===s&&j&&(h("ANIMATION_END"),!o.current)){const b=s.style.animationFillMode;s.style.animationFillMode="forwards",f=g.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=b)})}},v=w=>{w.target===s&&(l.current=bu(a.current))};return s.addEventListener("animationstart",v),s.addEventListener("animationcancel",x),s.addEventListener("animationend",x),()=>{g.clearTimeout(f),s.removeEventListener("animationstart",v),s.removeEventListener("animationcancel",x),s.removeEventListener("animationend",x)}}else h("ANIMATION_END")},[s,h]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:m.useCallback(f=>{f&&(a.current=getComputedStyle(f)),n(f)},[])}}function bu(t){return t?.animationName||"none"}function R4(t){let s=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function Ur({prop:t,defaultProp:s,onChange:n=()=>{}}){const[a,o]=A4({defaultProp:s,onChange:n}),l=t!==void 0,d=l?t:a,u=Rs(n),h=m.useCallback(f=>{if(l){const x=typeof f=="function"?f(t):f;x!==t&&u(x)}else o(f)},[l,t,o,u]);return[d,h]}function A4({defaultProp:t,onChange:s}){const n=m.useState(t),[a]=n,o=m.useRef(a),l=Rs(s);return m.useEffect(()=>{o.current!==a&&(l(a),o.current=a)},[a,o,l]),n}var I4="VisuallyHidden",Xc=m.forwardRef((t,s)=>e.jsx(at.span,{...t,ref:s,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...t.style}}));Xc.displayName=I4;var D4=Xc,Pg="ToastProvider",[Tg,O4,M4]=Tm("Toast"),[Qb]=En("Toast",[M4]),[L4,Em]=Qb(Pg),Gb=t=>{const{__scopeToast:s,label:n="Notification",duration:a=5e3,swipeDirection:o="right",swipeThreshold:l=50,children:d}=t,[u,h]=m.useState(null),[f,g]=m.useState(0),x=m.useRef(!1),v=m.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Pg}\`. Expected non-empty \`string\`.`),e.jsx(Tg.Provider,{scope:s,children:e.jsx(L4,{scope:s,label:n,duration:a,swipeDirection:o,swipeThreshold:l,toastCount:f,viewport:u,onViewportChange:h,onToastAdd:m.useCallback(()=>g(w=>w+1),[]),onToastRemove:m.useCallback(()=>g(w=>w-1),[]),isFocusedToastEscapeKeyDownRef:x,isClosePausedRef:v,children:d})})};Gb.displayName=Pg;var Yb="ToastViewport",F4=["F8"],Op="toast.viewportPause",Mp="toast.viewportResume",Zb=m.forwardRef((t,s)=>{const{__scopeToast:n,hotkey:a=F4,label:o="Notifications ({hotkey})",...l}=t,d=Em(Yb,n),u=O4(n),h=m.useRef(null),f=m.useRef(null),g=m.useRef(null),x=m.useRef(null),v=At(s,x,d.onViewportChange),w=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),C=d.toastCount>0;m.useEffect(()=>{const b=k=>{a.length!==0&&a.every(T=>k[T]||k.code===T)&&x.current?.focus()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)}
8,[a]),m.useEffect(()=>{const b=h.current,k=x.current;if(C&&b&&k){const N=()=>{if(!d.isClosePausedRef.current){const O=new CustomEvent(Op);k.dispatchEvent(O),d.isClosePausedRef.current=!0}},T=()=>{if(d.isClosePausedRef.current){const O=new CustomEvent(Mp);k.dispatchEvent(O),d.isClosePausedRef.current=!1}},P=O=>{!b.contains(O.relatedTarget)&&T()},I=()=>{b.contains(document.activeElement)||T()};return b.addEventListener("focusin",N),b.addEventListener("focusout",P),b.addEventListener("pointermove",N),b.addEventListener("pointerleave",I),window.addEventListener("blur",N),window.addEventListener("focus",T),()=>{b.removeEventListener("focusin",N),b.removeEventListener("focusout",P),b.removeEventListener("pointermove",N),b.removeEventListener("pointerleave",I),window.removeEventListener("blur",N),window.removeEventListener("focus",T)}}},[C,d.isClosePausedRef]);const j=m.useCallback(({tabbingDirection:b})=>{const N=u().map(T=>{const P=T.ref.current,I=[P,...Z4(P)];return b==="forwards"?I:I.reverse()});return(b==="forwards"?N.reverse():N).flat()},[u]);return m.useEffect(()=>{const b=x.current;if(b){const k=N=>{const T=N.altKey||N.ctrlKey||N.metaKey;if(N.key==="Tab"&&!T){const I=document.activeElement,O=N.shiftKey;if(N.target===b&&O){f.current?.focus();return}const M=j({tabbingDirection:O?"backwards":"forwards"}),z=M.findIndex(H=>H===I);np(M.slice(z+1))?N.preventDefault():O?f.current?.focus():g.current?.focus()}};return b.addEventListener("keydown",k),()=>b.removeEventListener("keydown",k)}},[u,j]),e.jsxs(P4,{ref:h,role:"region","aria-label":o.replace("{hotkey}",w),tabIndex:-1,style:{pointerEvents:C?void 0:"none"},children:[C&&e.jsx(Lp,{ref:f,onFocusFromOutsideViewport:()=>{const b=j({tabbingDirection:"forwards"});np(b)}}),e.jsx(Tg.Slot,{scope:n,children:e.jsx(at.ol,{tabIndex:-1,...l,ref:v})}),C&&e.jsx(Lp,{ref:g,onFocusFromOutsideViewport:()=>{const b=j({tabbingDirection:"backwards"});np(b)}})]})});Zb.displayName=Yb;var Xb="ToastFocusProxy",Lp=m.forwardRef((t,s)=>{const{__scopeToast:n,onFocusFromOutsideViewport:a,...o}=t,l=Em(Xb,n);return e.jsx(Xc,{"aria-hidden":!0,tabIndex:0,...o,ref:s,style:{position:"fixed"},onFocus:d=>{const u=d.relatedTarget;!l.viewport?.contains(u)&&a()}})});Lp.displayName=Xb;var _m="Toast",$4="toast.swipeStart",U4="toast.swipeMove",z4="toast.swipeCancel",B4="toast.swipeEnd",Jb=m.forwardRef((t,s)=>{const{forceMount:n,open:a,defaultOpen:o,onOpenChange:l,...d}=t,[u=!0,h]=Ur({prop:a,defaultProp:o,onChange:l});return e.jsx(gn,{present:n||u,children:e.jsx(K4,{open:u,...d,ref:s,onClose:()=>h(!1),onPause:Rs(t.onPause),onResume:Rs(t.onResume),onSwipeStart:Ae(t.onSwipeStart,f=>{f.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Ae(t.onSwipeMove,f=>{const{x:g,y:x}=f.detail.delta;f.currentTarget.setAttribute("data-swipe","move"),f.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${g}px`),f.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${x}px`)}),onSwipeCancel:Ae(t.onSwipeCancel,f=>{f.currentTarget.setAttribute("data-swipe","cancel"),f.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),f.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),f.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),f.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Ae(t.onSwipeEnd,f=>{const{x:g,y:x}=f.detail.delta;f.currentTarget.setAttribute("data-swipe","end"),f.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),f.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),f.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${g}px`),f.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${x}px`),h(!1)})})})});Jb.displayName=_m;var[V4,q4]=Qb(_m,{onClose(){}}),K4=m.forwardRef((t,s)=>{const{__scopeToast:n,type:a="foreground",duration:o,open:l,onClose:d,onEscapeKeyDown:u,onPause:h,onResume:f,onSwipeStart:g,onSwipeMove:x,onSwipeCancel:v,onSwipeEnd:w,...C}=t,j=Em(_m,n),[b,k]=m.useState(null),N=At(s,Y=>k(Y)),T=m.useRef(null),P=m.useRef(null),I=o||j.duration,O=m.useRef(0),R=m.useRef(I),F=m.useRef(0),{onToastAdd:M,onToastRemove:z}=j,H=Rs(()=>{b?.contains(document.activeElement)&&j.viewport?.focus(),d()}),V=m.useCallback(Y=>
8{!Y||Y===1/0||(window.clearTimeout(F.current),O.current=new Date().getTime(),F.current=window.setTimeout(H,Y))},[H]);m.useEffect(()=>{const Y=j.viewport;if(Y){const L=()=>{V(R.current),f?.()},K=()=>{const _=new Date().getTime()-O.current;R.current=R.current-_,window.clearTimeout(F.current),h?.()};return Y.addEventListener(Op,K),Y.addEventListener(Mp,L),()=>{Y.removeEventListener(Op,K),Y.removeEventListener(Mp,L)}}},[j.viewport,I,h,f,V]),m.useEffect(()=>{l&&!j.isClosePausedRef.current&&V(I)},[l,I,j.isClosePausedRef,V]),m.useEffect(()=>(M(),()=>z()),[M,z]);const B=m.useMemo(()=>b?iN(b):null,[b]);return j.viewport?e.jsxs(e.Fragment,{children:[B&&e.jsx(H4,{__scopeToast:n,role:"status","aria-live":a==="foreground"?"assertive":"polite","aria-atomic":!0,children:B}),e.jsx(V4,{scope:n,onClose:H,children:Mr.createPortal(e.jsx(Tg.ItemSlot,{scope:n,children:e.jsx(k4,{asChild:!0,onEscapeKeyDown:Ae(u,()=>{j.isFocusedToastEscapeKeyDownRef.current||H(),j.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(at.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":l?"open":"closed","data-swipe-direction":j.swipeDirection,...C,ref:N,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Ae(t.onKeyDown,Y=>{Y.key==="Escape"&&(u?.(Y.nativeEvent),Y.nativeEvent.defaultPrevented||(j.isFocusedToastEscapeKeyDownRef.current=!0,H()))}),onPointerDown:Ae(t.onPointerDown,Y=>{Y.button===0&&(T.current={x:Y.clientX,y:Y.clientY})}),onPointerMove:Ae(t.onPointerMove,Y=>{if(!T.current)return;const L=Y.clientX-T.current.x,K=Y.clientY-T.current.y,_=!!P.current,$=["left","right"].includes(j.swipeDirection),A=["left","up"].includes(j.swipeDirection)?Math.min:Math.max,W=$?A(0,L):0,U=$?0:A(0,K),Q=Y.pointerType==="touch"?10:2,we={x:W,y:U},_e={originalEvent:Y,delta:we};_?(P.current=we,Nu(U4,x,_e,{discrete:!1})):Jj(we,j.swipeDirection,Q)?(P.current=we,Nu($4,g,_e,{discrete:!1}),Y.target.setPointerCapture(Y.pointerId)):(Math.abs(L)>Q||Math.abs(K)>Q)&&(T.current=null)}),onPointerUp:Ae(t.onPointerUp,Y=>{const L=P.current,K=Y.target;if(K.hasPointerCapture(Y.pointerId)&&K.releasePointerCapture(Y.pointerId),P.current=null,T.current=null,L){const _=Y.currentTarget,$={originalEvent:Y,delta:L};Jj(L,j.swipeDirection,j.swipeThreshold)?Nu(B4,w,$,{discrete:!0}):Nu(z4,v,$,{discrete:!0}),_.addEventListener("click",A=>A.preventDefault(),{once:!0})}})})})}),j.viewport)})]}):null}),H4=t=>{const{__scopeToast:s,children:n,...a}=t,o=Em(_m,s),[l,d]=m.useState(!1),[u,h]=m.useState(!1);return G4(()=>d(!0)),m.useEffect(()=>{const f=window.setTimeout(()=>h(!0),1e3);return()=>window.clearTimeout(f)},[]),u?null:e.jsx(Zc,{asChild:!0,children:e.jsx(Xc,{...a,children:l&&e.jsxs(e.Fragment,{children:[o.label," ",n]})})})},W4="ToastTitle",eN=m.forwardRef((t,s)=>{const{__scopeToast:n,...a}=t;return e.jsx(at.div,{...a,ref:s})});eN.displayName=W4;var Q4="ToastDescription",tN=m.forwardRef((t,s)=>{const{__scopeToast:n,...a}=t;return e.jsx(at.div,{...a,ref:s})});tN.displayName=Q4;var sN="ToastAction",nN=m.forwardRef((t,s)=>{const{altText:n,...a}=t;return n.trim()?e.jsx(aN,{altText:n,asChild:!0,children:e.jsx(Eg,{...a,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${sN}\`. Expected non-empty \`string\`.`),null)});nN.displayName=sN;var rN="ToastClose",Eg=m.forwardRef((t,s)=>{const{__scopeToast:n,...a}=t,o=q4(rN,n);return e.jsx(aN,{asChild:!0,children:e.jsx(at.button,{type:"button",...a,ref:s,onClick:Ae(t.onClick,o.onClose)})})});Eg.displayName=rN;var aN=m.forwardRef((t,s)=>{const{__scopeToast:n,altText:a,...o}=t;return e.jsx(at.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":a||void 0,...o,ref:s})});function iN(t){const s=[];return Array.from(t.childNodes).forEach(a=>{if(a.nodeType===a.TEXT_NODE&&a.textContent&&s.push(a.textContent),Y4(a)){const o=a.ariaHidden||a.hidden||a.style.display==="none",l=a.dataset.radixToastAnnounceExclude==="";if(!o)if(l){const d=a.dataset.radixToastAnnounceAlt;d&&s.push(d)}else s.push(...iN(a))}}),s}function Nu(t,s,n,{discrete:a}){const o=n.originalEvent.currentTarget,l=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});s&&o.addEventListener(t,s,{once:!0}),a?kg(o,l):o.dispatchEvent(l)}var Jj=(t,s,n=0)=>{const a=Math.abs(t.x),o=Math.abs(t.y),l=a>o;return s==="left"||s==="right"?l&&a>n:!l&&o>n};function G4(t=()=>{}){const s=Rs(t);cn(()=>{let n=0,a=0;return n=window.requestAnimationFrame(()=>a=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(a)}},[s])}function Y4(t){return t.nodeType===t.ELEMENT_NODE}function Z4(t){const s=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const o=a.tagName==="INPUT"&&a.type==="hidden";return a.disabled||a.hidden||o?NodeFilter.FILTER_SKIP:a.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)s.push(n.currentNode);return s}function np(t){const s=document.activeElement;return t.some(n=>n===s?!0:(n.focus(),document.activeElement!==s))}var X4=Gb,oN=Zb,lN=Jb,cN=eN,dN=tN,uN=nN,mN=Eg;function hN(t){var s,n,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(s=0;s<o;
8s++)t[s]&&(n=hN(t[s]))&&(a&&(a+=" "),a+=n)}else for(n in t)t[n]&&(a&&(a+=" "),a+=n);return a}function fN(){for(var t,s,n=0,a="",o=arguments.length;n<o;n++)(t=arguments[n])&&(s=hN(t))&&(a&&(a+=" "),a+=s);return a}const ew=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,tw=fN,ml=(t,s)=>n=>{var a;if(s?.variants==null)return tw(t,n?.class,n?.className);const{variants:o,defaultVariants:l}=s,d=Object.keys(o).map(f=>{const g=n?.[f],x=l?.[f];if(g===null)return null;const v=ew(g)||ew(x);return o[f][v]}),u=n&&Object.entries(n).reduce((f,g)=>{let[x,v]=g;return v===void 0||(f[x]=v),f},{}),h=s==null||(a=s.compoundVariants)===null||a===void 0?void 0:a.reduce((f,g)=>{let{class:x,className:v,...w}=g;return Object.entries(w).every(C=>{let[j,b]=C;return Array.isArray(b)?b.includes({...l,...u}[j]):{...l,...u}[j]===b})?[...f,x,v]:f},[]);return tw(t,d,h,n?.class,n?.className)};const J4=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),pN=(...t)=>t.filter((s,n,a)=>!!s&&a.indexOf(s)===n).join(" ");var eE={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const tE=m.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:o="",children:l,iconNode:d,...u},h)=>m.createElement("svg",{ref:h,...eE,width:s,height:s,stroke:t,strokeWidth:a?Number(n)*24/Number(s):n,className:pN("lucide",o),...u},[...d.map(([f,g])=>m.createElement(f,g)),...Array.isArray(l)?l:[l]]));const Pe=(t,s)=>{const n=m.forwardRef(({className:a,...o},l)=>m.createElement(tE,{ref:l,iconNode:s,className:pN(`lucide-${J4(t)}`,a),...o}));return n.displayName=`${t}`,n};const qo=Pe("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const Rm=Pe("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);const kn=Pe("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const _g=Pe("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const sE=Pe("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);const nE=Pe("BellRing",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}]]);const rE=Pe("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);const cs=Pe("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);const Qn=Pe("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);const rp=Pe("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);const Am=Pe("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);const yr=Pe("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const On=Pe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const gN=Pe("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const Bt=Pe("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Im=Pe("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const hl=Pe("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const Sr=Pe("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);const xN=Pe("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const sw=Pe("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fp=Pe("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const Vu=Pe("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Vi=Pe("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);const aE=Pe("Cookie",[["path",{d:"M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5",key:"laymnq"}],["path",{d:"M8.5 8.5v.01",key:"ue8clq"}],["path",{d:"M16 15.5v.01",key:"14dtrp"}],["path",{d:"M12 12v.01",key:"u5ubse"}],["path",{d:"M11 17v.01",key:"1hyl5a"}],["path",{d:"M7 14v.01",key:"uct60s"}]]);
8const vN=Pe("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const di=Pe("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);const Fi=Pe("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);const Yn=Pe("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Sn=Pe("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const Pt=Pe("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const iE=Pe("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);const Fr=Pe("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const Cc=Pe("FolderTree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]);const oE=Pe("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const $n=Pe("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const Dm=Pe("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);const yc=Pe("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const yN=Pe("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);const qi=Pe("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const ln=Pe("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);const lE=Pe("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);const Pa=Pe("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);const cE=Pe("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);const dE=Pe("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const jN=Pe("ListPlus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);const Ve=Pe("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);
8const Pn=Pe("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const qu=Pe("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);const Om=Pe("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);const Ta=Pe("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);const Jo=Pe("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);const wN=Pe("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);const uE=Pe("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);const no=Pe("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);const bN=Pe("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);const ka=Pe("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);const kc=Pe("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);const Rg=Pe("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);const NN=Pe("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);const mE=Pe("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);const hE=Pe("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);const $p=Pe("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);const fE=Pe("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);const fl=Pe("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);const Ku=Pe("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ds=Pe("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const jc=Pe("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const Ki=Pe("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Mm=Pe("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);const el=Pe("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);const Jc=Pe("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const Ag=Pe("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
8y:"oel41y"}]]);const pE=Pe("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);const gs=Pe("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);const Ia=Pe("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);const Pc=Pe("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const SN=Pe("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);const Lm=Pe("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);const Hu=Pe("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);const Tc=Pe("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);const ts=Pe("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const gE=Pe("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);const pl=Pe("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Ou=Pe("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);const xE=Pe("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);const Hr=Pe("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const Hi=Pe("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);const Bs=Pe("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);const lr=Pe("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);const Ig=Pe("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Zn=Pe("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}
vendor: 6,081 bytes, line 8
8],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);const Wu=Pe("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),Dg="-",vE=t=>{const s=jE(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:d=>{const u=d.split(Dg);return u[0]===""&&u.length!==1&&u.shift(),CN(u,s)||yE(d)},getConflictingClassGroupIds:(d,u)=>{const h=n[d]||[];return u&&a[d]?[...h,...a[d]]:h}}},CN=(t,s)=>{if(t.length===0)return s.classGroupId;const n=t[0],a=s.nextPart.get(n),o=a?CN(t.slice(1),a):void 0;if(o)return o;if(s.validators.length===0)return;const l=t.join(Dg);return s.validators.find(({validator:d})=>d(l))?.classGroupId},nw=/^\[(.+)\]$/,yE=t=>{if(nw.test(t)){const s=nw.exec(t)[1],n=s?.substring(0,s.indexOf(":"));if(n)return"arbitrary.."+n}},jE=t=>{const{theme:s,prefix:n}=t,a={nextPart:new Map,validators:[]};return bE(Object.entries(t.classGroups),n).forEach(([l,d])=>{Up(d,a,l,s)}),a},Up=(t,s,n,a)=>{t.forEach(o=>{if(typeof o=="string"){const l=o===""?s:rw(s,o);l.classGroupId=n;return}if(typeof o=="function"){if(wE(o)){Up(o(a),s,n,a);return}s.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([l,d])=>{Up(d,rw(s,l),n,a)})})},rw=(t,s)=>{let n=t;return s.split(Dg).forEach(a=>{n.nextPart.has(a)||n.nextPart.set(a,{nextPart:new Map,validators:[]}),n=n.nextPart.get(a)}),n},wE=t=>t.isThemeGetter,bE=(t,s)=>s?t.map(([n,a])=>{const o=a.map(l=>typeof l=="string"?s+l:typeof l=="object"?Object.fromEntries(Object.entries(l).map(([d,u])=>[s+d,u])):l);return[n,o]}):t,NE=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,n=new Map,a=new Map;const o=(l,d)=>{n.set(l,d),s++,s>t&&(s=0,a=n,n=new Map)};return{get(l){let d=n.get(l);if(d!==void 0)return d;if((d=a.get(l))!==void 0)return o(l,d),d},set(l,d){n.has(l)?n.set(l,d):o(l,d)}}},kN="!",SE=t=>{const{separator:s,experimentalParseClassName:n}=t,a=s.length===1,o=s[0],l=s.length,d=u=>{const h=[];let f=0,g=0,x;for(let b=0;b<u.length;b++){let k=u[b];if(f===0){if(k===o&&(a||u.slice(b,b+l)===s)){h.push(u.slice(g,b)),g=b+l;continue}if(k==="/"){x=b;continue}}k==="["?f++:k==="]"&&f--}const v=h.length===0?u:u.substring(g),w=v.startsWith(kN),C=w?v.substring(1):v,j=x&&x>g?x-g:void 0;return{modifiers:h,hasImportantModifier:w,baseClassName:C,maybePostfixModifierPosition:j}};return n?u=>n({className:u,parseClassName:d}):d},CE=t=>{if(t.length<=1)return t;const s=[];let n=[];return t.forEach(a=>{a[0]==="["?(s.push(...n.sort(),a),n=[]):n.push(a)}),s.push(...n.sort()),s},kE=t=>({cache:NE(t.cacheSize),parseClassName:SE(t),...vE(t)}),PE=/\s+/,TE=(t,s)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:o}=s,l=[],d=t.trim().split(PE);let u="";for(let h=d.length-1;h>=0;h-=1){const f=d[h],{modifiers:g,hasImportantModifier:x,baseClassName:v,maybePostfixModifierPosition:w}=n(f);let C=!!w,j=a(C?v.substring(0,w):v);if(!j){if(!C){u=f+(u.length>0?" "+u:u);continue}if(j=a(v),!j){u=f+(u.length>0?" "+u:u);continue}C=!1}const b=CE(g).join(":"),k=x?b+kN:b,N=k+j;if(l.includes(N))continue;l.push(N);const T=o(j,C);for(let P=0;P<T.length;++P){const I=T[P];l.push(k+I)}u=f+(u.length>0?" "+u:u)}return u};function EE(){let t=0,s,n,a="";for(;t<arguments.length;)(s=arguments[t++])&&(n=PN(s))&&(a&&(a+=" "),a+=n);return a}const PN=t=>{if(typeof t=="string")return t;let s,n="";for(let a=0;a<t.length;a++)t[a]&&(s=PN(t[a]))&&(n&&(n+=" "),n+=s);return n};function _E(t,...s){let n,a,o,l=d;function d(h){const f=s.reduce((g,x)=>x(g),t());return n=kE(f),a=n.cache.get,o=n.cache.set,l=u,u(h)}function u(h){const f=a(h);if(f)return f;const g=TE(h,n);return o(h,g),g}return function(){return l(EE.apply(null,arguments))}}const ws=t=>{const s=n=>n[t]||[];return s.isThemeGetter=!0,s},TN=/^\[(?:([a-z-]+):)?(.+)\]$/i,RE=/^\d+\/\d+$/,AE=new Set(["px","full","screen"]),IE=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,DE=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,OE=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,ME=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,LE=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Na=t=>Ko(t)||AE.has(t)||RE.test(t),ai=t=>gl(t,"length",KE),Ko=t=>!!t&&!Number.isNaN(Number(t)),ap=t=>gl(t,"number",Ko),oc=t=>!!t&&Number.isInteger(Number(t)),FE=t=>t.endsWith("%")&&Ko(t.slice(0,-1)),It=t=>TN.test(t),ii=t=>IE.test(t),$E=new Set(["length","size","percentage"]),UE=t=>gl(t,$E,EN),zE=t=>gl(t,"position",EN),BE=new Set(["image","url"]),VE=t=>gl(t,BE,WE),qE=t=>gl(t,"",HE),lc=()=>!0,gl=(t,s,n)=>{const a=TN.exec(t);return a?a[1]?typeof s=="string"?a[1]===s:s.has(a[1]):n(a[2]):!1},KE=t=>DE.test(t)&&!OE.test(t),EN=()=>!1,HE=t=>ME.test(t),WE=t=>LE.test(t),QE=()=>{const t=ws("colors"),s=ws("spacing"),n=ws("blur"),a=ws("brightness"),o=ws("borderColor"),l=ws("borderRadius"),d=ws("borderSpacing"),u=ws("borderWidth"),h=ws("contrast"),f=ws("grayscale"),g=ws("hueRotate"),x=ws("invert"),v=ws("gap"),w=ws("gradientColorStops"),C=ws("gradientColorStopPositions"),j=ws("inset"),b=ws("margin"),k=ws("opacity"),N=ws("padding"),T=ws("saturate"),P=ws("scale"),I=ws("sepia"),O=ws("skew"),R=ws("space"),F=ws("translate"),M=()=>["auto","contain","none"],z=()=>["auto","hidden","clip","visible","scroll"],H=()=>["auto",It,s],V=()=>[It,s],B=()=>["",Na,ai],Y=()=>["auto",Ko,It],L=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],K=()=>["solid","dashed","dotted","double","none"],_=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],$=()=>["start","end","center","between","around","evenly","stretch"],A=()=>["","0",It],W=()=>["auto","avoid","all","avoid-page","page","left","right","column"],U=()=>[Ko,It];return{cacheSize:500,separator:":",theme:{colors:[lc],spacing:[Na,ai],blur:["none","",ii,It],brightness:U(),borderColor:[t],borderRadius:["n
8one","","full",ii,It],borderSpacing:V(),borderWidth:B(),contrast:U(),grayscale:A(),hueRotate:U(),invert:A(),gap:V(),gradientColorStops:[t],gradientColorStopPositions:[FE,ai],inset:H(),margin:H(),opacity:U(),padding:V(),saturate:U(),scale:U(),sepia:A(),skew:U(),space:V(),translate:V()},classGroups:{aspect:[{aspect:["auto","square","video",It]}],container:["container"],columns:[{columns:[ii]}],"break-after":[{"break-after":W()}],"break-before":[{"break-before":W()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...L(),It]}],overflow:[{overflow:z()}],"overflow-x":[{"overflow-x":z()}],"overflow-y":[{"overflow-y":z()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[j]}],"inset-x":[{"inset-x":[j]}],"inset-y":[{"inset-y":[j]}],start:[{start:[j]}],end:[{end:[j]}],top:[{top:[j]}],right:[{right:[j]}],bottom:[{bottom:[j]}],left:[{left:[j]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",oc,It]}],basis:[{basis:H()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",It]}],grow:[{grow:A()}],shrink:[{shrink:A()}],order:[{order:["first","last","none",oc,It]}],"grid-cols":[{"grid-cols":[lc]}],"col-start-end":[{col:["auto",{span:["full",oc,It]},It]}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":[lc]}],"row-start-end":[{row:["auto",{span:[oc,It]},It]}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",It]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",It]}],gap:[{gap:[v]}],"gap-x":[{"gap-x":[v]}],"gap-y":[{"gap-y":[v]}],"justify-content":[{justify:["normal",...$()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...$(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...$(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[N]}],px:[{px:[N]}],py:[{py:[N]}],ps:[{ps:[N]}],pe:[{pe:[N]}],pt:[{pt:[N]}],pr:[{pr:[N]}],pb:[{pb:[N]}],pl:[{pl:[N]}],m:[{m:[b]}],mx:[{mx:[b]}],my:[{my:[b]}],ms:[{ms:[b]}],me:[{me:[b]}],mt:[{mt:[b]}],mr:[{mr:[b]}],mb:[{mb:[b]}],ml:[{ml:[b]}],"space-x":[{"space-x":[R]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[R]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",It,s]}],"min-w":[{"min-w":[It,s,"min","max","fit"]}],"max-w":[{"max-w":[It,s,"none","full","min","max","fit","prose",{screen:[ii]},ii]}],h:[{h:[It,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[It,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[It,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[It,s,"auto","min","max","fit"]}],"font-size":[{text:["base",ii,ai]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ap]}],"font-family":[{font:[lc]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",It]}],"line-clamp":[{"line-clamp":["none",Ko,ap]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Na,It]}],"list-image":[{"list-image":["none",It]}],"list-style-type":[{list:["none","disc","decimal",It]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...K(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Na,ai]}],"underline-offset":[{"underline-offset":["auto",Na,It]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:V()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",It]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",It]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...L(),zE]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",UE]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},VE]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[C]}
vendor: 5,180 bytes, line 8
8],"gradient-via-pos":[{via:[C]}],"gradient-to-pos":[{to:[C]}],"gradient-from":[{from:[w]}],"gradient-via":[{via:[w]}],"gradient-to":[{to:[w]}],rounded:[{rounded:[l]}],"rounded-s":[{"rounded-s":[l]}],"rounded-e":[{"rounded-e":[l]}],"rounded-t":[{"rounded-t":[l]}],"rounded-r":[{"rounded-r":[l]}],"rounded-b":[{"rounded-b":[l]}],"rounded-l":[{"rounded-l":[l]}],"rounded-ss":[{"rounded-ss":[l]}],"rounded-se":[{"rounded-se":[l]}],"rounded-ee":[{"rounded-ee":[l]}],"rounded-es":[{"rounded-es":[l]}],"rounded-tl":[{"rounded-tl":[l]}],"rounded-tr":[{"rounded-tr":[l]}],"rounded-br":[{"rounded-br":[l]}],"rounded-bl":[{"rounded-bl":[l]}],"border-w":[{border:[u]}],"border-w-x":[{"border-x":[u]}],"border-w-y":[{"border-y":[u]}],"border-w-s":[{"border-s":[u]}],"border-w-e":[{"border-e":[u]}],"border-w-t":[{"border-t":[u]}],"border-w-r":[{"border-r":[u]}],"border-w-b":[{"border-b":[u]}],"border-w-l":[{"border-l":[u]}],"border-opacity":[{"border-opacity":[k]}],"border-style":[{border:[...K(),"hidden"]}],"divide-x":[{"divide-x":[u]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[u]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:K()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...K()]}],"outline-offset":[{"outline-offset":[Na,It]}],"outline-w":[{outline:[Na,ai]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:B()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[Na,ai]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",ii,qE]}],"shadow-color":[{shadow:[lc]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[..._(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":_()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[a]}],contrast:[{contrast:[h]}],"drop-shadow":[{"drop-shadow":["","none",ii,It]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[g]}],invert:[{invert:[x]}],saturate:[{saturate:[T]}],sepia:[{sepia:[I]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[a]}],"backdrop-contrast":[{"backdrop-contrast":[h]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[g]}],"backdrop-invert":[{"backdrop-invert":[x]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[T]}],"backdrop-sepia":[{"backdrop-sepia":[I]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[d]}],"border-spacing-x":[{"border-spacing-x":[d]}],"border-spacing-y":[{"border-spacing-y":[d]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",It]}],duration:[{duration:U()}],ease:[{ease:["linear","in","out","in-out",It]}],delay:[{delay:U()}],animate:[{animate:["none","spin","ping","pulse","bounce",It]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[P]}],"scale-x":[{"scale-x":[P]}],"scale-y":[{"scale-y":[P]}],rotate:[{rotate:[oc,It]}],"translate-x":[{"translate-x":[F]}],"translate-y":[{"translate-y":[F]}],"skew-x":[{"skew-x":[O]}],"skew-y":[{"skew-y":[O]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",It]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",It]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":V()}],"scroll-mx":[{"scroll-mx":V()}],"scroll-my":[{"scroll-my":V()}],"scroll-ms":[{"scroll-ms":V()}],"scroll-me":[{"scroll-me":V()}],"scroll-mt":[{"scroll-mt":V()}],"scroll-mr":[{"scroll-mr":V()}],"scroll-mb":[{"scroll-mb":V()}],"scroll-ml":[{"scroll-ml":V()}],"scroll-p":[{"scroll-p":V()}],"scroll-px":[{"scroll-px":V()}],"scroll-py":[{"scroll-py":V()}],"scroll-ps":[{"scroll-ps":V()}],"scroll-pe":[{"scroll-pe":V()}],"scroll-pt":[{"scroll-pt":V()}],"scroll-pr":[{"scroll-pr":V()}],"scroll-pb":[{"scroll-pb":V()}],"scroll-pl":[{"scroll-pl":V()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}
8],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",It]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Na,ai,ap]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},GE=_E(QE);function Oe(...t){return GE(fN(t))}const YE=X4,_N=m.forwardRef(({className:t,...s},n)=>e.jsx(oN,{ref:n,className:Oe("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...s}));_N.displayName=oN.displayName;const ZE=ml("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),RN=m.forwardRef(({className:t,variant:s,...n},a)=>e.jsx(lN,{ref:a,className:Oe(ZE({variant:s}),t),...n}));RN.displayName=lN.displayName;const XE=m.forwardRef(({className:t,...s},n)=>e.jsx(uN,{ref:n,className:Oe("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",t),...s}));XE.displayName=uN.displayName;const AN=m.forwardRef(({className:t,...s},n)=>e.jsx(mN,{ref:n,className:Oe("absolute right-2 top-2 rounded-md p-1 text-foreground
8/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...s,children:e.jsx(Zn,{className:"h-4 w-4"})}));AN.displayName=mN.displayName;const IN=m.forwardRef(({className:t,...s},n)=>e.jsx(cN,{ref:n,className:Oe("text-sm font-semibold",t),...s}));IN.displayName=cN.displayName;const DN=m.forwardRef(({className:t,...s},n)=>e.jsx(dN,{ref:n,className:Oe("text-sm opacity-90",t),...s}));DN.displayName=dN.displayName;function JE(){const{toasts:t}=dt();return e.jsxs(YE,{children:[t.map(function({id:s,title:n,description:a,action:o,...l}){return e.jsxs(RN,{...l,children:[e.jsxs("div",{className:"grid gap-1",children:[n&&e.jsx(IN,{children:n}),a&&e.jsx(DN,{children:a})]}),o,e.jsx(AN,{})]},s)}),e.jsx(_N,{})]})}var e_=jb[" useId ".trim().toString()]||(()=>{}),t_=0;function jr(t){const[s,n]=m.useState(e_());return cn(()=>{n(a=>a??String(t_++))},[t]),s?`radix-${s}`:""}const s_=["top","right","bottom","left"],mi=Math.min,ir=Math.max,Qu=Math.round,Su=Math.floor,aa=t=>({x:t,y:t}
vendor: 4,132 bytes, line 8
8),n_={left:"right",right:"left",bottom:"top",top:"bottom"},r_={start:"end",end:"start"};function zp(t,s,n){return ir(t,mi(s,n))}function Ea(t,s){return typeof t=="function"?t(s):t}function _a(t){return t.split("-")[0]}function xl(t){return t.split("-")[1]}function Og(t){return t==="x"?"y":"x"}function Mg(t){return t==="y"?"height":"width"}function hi(t){return["top","bottom"].includes(_a(t))?"y":"x"}function Lg(t){return Og(hi(t))}function a_(t,s,n){n===void 0&&(n=!1);const a=xl(t),o=Lg(t),l=Mg(o);let d=o==="x"?a===(n?"end":"start")?"right":"left":a==="start"?"bottom":"top";return s.reference[l]>s.floating[l]&&(d=Gu(d)),[d,Gu(d)]}function i_(t){const s=Gu(t);return[Bp(t),s,Bp(s)]}function Bp(t){return t.replace(/start|end/g,s=>r_[s])}function o_(t,s,n){const a=["left","right"],o=["right","left"],l=["top","bottom"],d=["bottom","top"];switch(t){case"top":case"bottom":return n?s?o:a:s?a:o;case"left":case"right":return s?l:d;default:return[]}}function l_(t,s,n,a){const o=xl(t);let l=o_(_a(t),n==="start",a);return o&&(l=l.map(d=>d+"-"+o),s&&(l=l.concat(l.map(Bp)))),l}function Gu(t){return t.replace(/left|right|bottom|top/g,s=>n_[s])}function c_(t){return{top:0,right:0,bottom:0,left:0,...t}}function ON(t){return typeof t!="number"?c_(t):{top:t,right:t,bottom:t,left:t}}function Yu(t){const{x:s,y:n,width:a,height:o}=t;return{width:a,height:o,top:n,left:s,right:s+a,bottom:n+o,x:s,y:n}}function aw(t,s,n){let{reference:a,floating:o}=t;const l=hi(s),d=Lg(s),u=Mg(d),h=_a(s),f=l==="y",g=a.x+a.width/2-o.width/2,x=a.y+a.height/2-o.height/2,v=a[u]/2-o[u]/2;let w;switch(h){case"top":w={x:g,y:a.y-o.height};break;case"bottom":w={x:g,y:a.y+a.height};break;case"right":w={x:a.x+a.width,y:x};break;case"left":w={x:a.x-o.width,y:x};break;default:w={x:a.x,y:a.y}}switch(xl(s)){case"start":w[d]-=v*(n&&f?-1:1);break;case"end":w[d]+=v*(n&&f?-1:1);break}return w}const d_=async(t,s,n)=>{const{placement:a="bottom",strategy:o="absolute",middleware:l=[],platform:d}=n,u=l.filter(Boolean),h=await(d.isRTL==null?void 0:d.isRTL(s));let f=await d.getElementRects({reference:t,floating:s,strategy:o}),{x:g,y:x}=aw(f,a,h),v=a,w={},C=0;for(let j=0;j<u.length;j++){const{name:b,fn:k}=u[j],{x:N,y:T,data:P,reset:I}=await k({x:g,y:x,initialPlacement:a,placement:v,strategy:o,middlewareData:w,rects:f,platform:d,elements:{reference:t,floating:s}});g=N??g,x=T??x,w={...w,[b]:{...w[b],...P}},I&&C<=50&&(C++,typeof I=="object"&&(I.placement&&(v=I.placement),I.rects&&(f=I.rects===!0?await d.getElementRects({reference:t,floating:s,strategy:o}):I.rects),{x:g,y:x}=aw(f,v,h)),j=-1)}return{x:g,y:x,placement:v,strategy:o,middlewareData:w}};async function Ec(t,s){var n;s===void 0&&(s={});const{x:a,y:o,platform:l,rects:d,elements:u,strategy:h}=t,{boundary:f="clippingAncestors",rootBoundary:g="viewport",elementContext:x="floating",altBoundary:v=!1,padding:w=0}=Ea(s,t),C=ON(w),b=u[v?x==="floating"?"reference":"floating":x],k=Yu(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(b)))==null||n?b:b.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(u.floating)),boundary:f,rootBoundary:g,strategy:h})),N=x==="floating"?{x:a,y:o,width:d.floating.width,height:d.floating.height}:d.reference,T=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u.floating)),P=await(l.isElement==null?void 0:l.isElement(T))?await(l.getScale==null?void 0:l.getScale(T))||{x:1,y:1}:{x:1,y:1},I=Yu(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:N,offsetParent:T,strategy:h}):N);return{top:(k.top-I.top+C.top)/P.y,bottom:(I.bottom-k.bottom+C.bottom)/P.y,left:(k.left-I.left+C.left)/P.x,right:(I.right-k.right+C.right)/P.x}}const u_=t=>({name:"arrow",options:t,async fn(s){const{x:n,y:a,placement:o,rects:l,platform:d,elements:u,middlewareData:h}=s,{element:f,padding:g=0}=Ea(t,s)||{};if(f==null)return{};const x=ON(g),v={x:n,y:a},w=Lg(o),C=Mg(w),j=await d.getDimensions(f),b=w==="y",k=b?"top":"left",N=b?"bottom":"right",T=b?"clientHeight":"clientWidth",P=l.reference[C]+l.reference[w]-v[w]-l.floating[C],I=v[w]-l.reference[w],O
vendor: 7,442 bytes, line 8
8=await(d.getOffsetParent==null?void 0:d.getOffsetParent(f));let R=O?O[T]:0;(!R||!await(d.isElement==null?void 0:d.isElement(O)))&&(R=u.floating[T]||l.floating[C]);const F=P/2-I/2,M=R/2-j[C]/2-1,z=mi(x[k],M),H=mi(x[N],M),V=z,B=R-j[C]-H,Y=R/2-j[C]/2+F,L=zp(V,Y,B),K=!h.arrow&&xl(o)!=null&&Y!==L&&l.reference[C]/2-(Y<V?z:H)-j[C]/2<0,_=K?Y<V?Y-V:Y-B:0;return{[w]:v[w]+_,data:{[w]:L,centerOffset:Y-L-_,...K&&{alignmentOffset:_}},reset:K}}}),m_=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(s){var n,a;const{placement:o,middlewareData:l,rects:d,initialPlacement:u,platform:h,elements:f}=s,{mainAxis:g=!0,crossAxis:x=!0,fallbackPlacements:v,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:j=!0,...b}=Ea(t,s);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const k=_a(o),N=hi(u),T=_a(u)===u,P=await(h.isRTL==null?void 0:h.isRTL(f.floating)),I=v||(T||!j?[Gu(u)]:i_(u)),O=C!=="none";!v&&O&&I.push(...l_(u,j,C,P));const R=[u,...I],F=await Ec(s,b),M=[];let z=((a=l.flip)==null?void 0:a.overflows)||[];if(g&&M.push(F[k]),x){const Y=a_(o,d,P);M.push(F[Y[0]],F[Y[1]])}if(z=[...z,{placement:o,overflows:M}],!M.every(Y=>Y<=0)){var H,V;const Y=(((H=l.flip)==null?void 0:H.index)||0)+1,L=R[Y];if(L)return{data:{index:Y,overflows:z},reset:{placement:L}};let K=(V=z.filter(_=>_.overflows[0]<=0).sort((_,$)=>_.overflows[1]-$.overflows[1])[0])==null?void 0:V.placement;if(!K)switch(w){case"bestFit":{var B;const _=(B=z.filter($=>{if(O){const A=hi($.placement);return A===N||A==="y"}return!0}).map($=>[$.placement,$.overflows.filter(A=>A>0).reduce((A,W)=>A+W,0)]).sort(($,A)=>$[1]-A[1])[0])==null?void 0:B[0];_&&(K=_);break}case"initialPlacement":K=u;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function iw(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function ow(t){return s_.some(s=>t[s]>=0)}const h_=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:n}=s,{strategy:a="referenceHidden",...o}=Ea(t,s);switch(a){case"referenceHidden":{const l=await Ec(s,{...o,elementContext:"reference"}),d=iw(l,n.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:ow(d)}}}case"escaped":{const l=await Ec(s,{...o,altBoundary:!0}),d=iw(l,n.floating);return{data:{escapedOffsets:d,escaped:ow(d)}}}default:return{}}}}};async function f_(t,s){const{placement:n,platform:a,elements:o}=t,l=await(a.isRTL==null?void 0:a.isRTL(o.floating)),d=_a(n),u=xl(n),h=hi(n)==="y",f=["left","top"].includes(d)?-1:1,g=l&&h?-1:1,x=Ea(s,t);let{mainAxis:v,crossAxis:w,alignmentAxis:C}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return u&&typeof C=="number"&&(w=u==="end"?C*-1:C),h?{x:w*g,y:v*f}:{x:v*f,y:w*g}}const p_=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var n,a;const{x:o,y:l,placement:d,middlewareData:u}=s,h=await f_(s,t);return d===((n=u.offset)==null?void 0:n.placement)&&(a=u.arrow)!=null&&a.alignmentOffset?{}:{x:o+h.x,y:l+h.y,data:{...h,placement:d}}}}},g_=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:n,y:a,placement:o}=s,{mainAxis:l=!0,crossAxis:d=!1,limiter:u={fn:b=>{let{x:k,y:N}=b;return{x:k,y:N}}},...h}=Ea(t,s),f={x:n,y:a},g=await Ec(s,h),x=hi(_a(o)),v=Og(x);let w=f[v],C=f[x];if(l){const b=v==="y"?"top":"left",k=v==="y"?"bottom":"right",N=w+g[b],T=w-g[k];w=zp(N,w,T)}if(d){const b=x==="y"?"top":"left",k=x==="y"?"bottom":"right",N=C+g[b],T=C-g[k];C=zp(N,C,T)}const j=u.fn({...s,[v]:w,[x]:C});return{...j,data:{x:j.x-n,y:j.y-a,enabled:{[v]:l,[x]:d}}}}}},x_=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:n,y:a,placement:o,rects:l,middlewareData:d}=s,{offset:u=0,mainAxis:h=!0,crossAxis:f=!0}=Ea(t,s),g={x:n,y:a},x=hi(o),v=Og(x);let w=g[v],C=g[x];const j=Ea(u,s),b=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(h){const T=v==="y"?"height":"width",P=l.reference[v]-l.floating[T]+b.mainAxis,I=l.reference[v]+l.reference[T]-b.mainAxis;w<P?w=P:w>I&&(w=I)}if(f){var k,N;const T=v==="y"?"width":"height",P=["top","left"].includes(_a(o)),I=l.reference[x]-l.floating[T]+(P&&((k=d.offset)==null?void 0:k[x])||0)+(P?0:b.crossAxis),O=l.reference[x]+l.reference[T]+(P?0:((N=d.offset)==null?void 0:N[x])||0)-(P?b.crossAxis:0);C<I?C=I:C>O&&(C=O)}return{[v]:w,[x]:C}}}},v_=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var n,a;const{placement:o,rects:l,platform:d,elements:u}=s,{apply:h=()=>{},...f}=Ea(t,s),g=await Ec(s,f),x=_a(o),v=xl(o),w=hi(o)==="y",{width:C,height:j}=l.floating;let b,k;x==="top"||x==="bottom"?(b=x,k=v===(await(d.isRTL==null?void 0:d.isRTL(u.floating))?"start":"end")?"left":"right"):(k=x,b=v==="end"?"top":"bottom");const N=j-g.top-g.bottom,T=C-g.left-g.right,P=mi(j-g[b],N),I=mi(C-g[k],T),O=!s.middlewareData.shift;let R=P,F=I;if((n=s.middlewareData.shift)!=null&&n.enabled.x&&(F=T),(a=s.middlewareData.shift)!=null&&a.enabled.y&&(R=N),O&&!v){const z=ir(g.left,0),H=ir(g.right,0),V=ir(g.top,0),B=ir(g.bottom,0);w?F=C-2*(z!==0||H!==0?z+H:ir(g.left,g.right)):R=j-2*(V!==0||B!==0?V+B:ir(g.top,g.bottom))}await h({...s,availableWidth:F,availableHeight:R});const M=await d.getDimensions(u.floating);return C!==M.width||j!==M.height?{reset:{rects:!0}}:{}}}};function Fm(){return typeof window<"u"}function vl(t){return MN(t)?(t.nodeName||"").toLowerCase():"#document"}function cr(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function ua(t){var s;return(s=(MN(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function MN(t){return Fm()?t instanceof Node||t instanceof cr(t).Node:!1}function zr(t){return Fm()?t instanceof Element||t instanceof cr(t).Element:!1}function oa(t){return Fm()?t instanceof HTMLElement||t instanceof cr(t).HTMLElement:!1}function lw(t){return!Fm()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof cr(t).ShadowRoot}function ed(t){const{overflow:s,overflowX:n,overflowY:a,display:o}=Br(t);return/auto|scroll|overlay|hidden|clip/.test(s+a+n)&&!["inline","contents"].includes(o)}function y_(t){return["table","td","th"].includes(vl(t))}function $m(t){return[":popover-open",":modal"].some(s=>{try{return t.matches(s)}catch{return!1}})}function Fg(t){const s=$g(),n=zr(t)?Br(t):t;return["transform","translate","scale","rotate","perspective"].some(a=>n[a]?n[a]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!s&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!s&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(a=>(n.willChange||"").includes(a))||["paint","layout","strict","content"].some(a=>(n.contain||"").includes(a))}function j_(t){let s=fi(t);for(;oa(s)&&!tl(s);){if(Fg(s))return s;if($m(s))return null;s=fi(s)}return null}function $g(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function tl(t){return["html","body","#document"].includes(vl(t))}function Br(t){return cr(t).getComputedStyle(t)}function Um(t){return zr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function fi(t){if(vl(t)==="html")return t;const s=t.assignedSlot||t.parentNode||lw(t)&&t.host||ua(t);return lw(s)?s.host:s}function LN(t){const s=fi(t);return tl(s)?t.ownerDocument?t.ownerDocument.body:t.body:oa(s)&&ed(s)?s:LN(s)}
vendor: 4,453 bytes, line 8
8function _c(t,s,n){var a;s===void 0&&(s=[]),n===void 0&&(n=!0);const o=LN(t),l=o===((a=t.ownerDocument)==null?void 0:a.body),d=cr(o);if(l){const u=Vp(d);return s.concat(d,d.visualViewport||[],ed(o)?o:[],u&&n?_c(u):[])}return s.concat(o,_c(o,[],n))}function Vp(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function FN(t){const s=Br(t);let n=parseFloat(s.width)||0,a=parseFloat(s.height)||0;const o=oa(t),l=o?t.offsetWidth:n,d=o?t.offsetHeight:a,u=Qu(n)!==l||Qu(a)!==d;return u&&(n=l,a=d),{width:n,height:a,$:u}}function Ug(t){return zr(t)?t:t.contextElement}function Ho(t){const s=Ug(t);if(!oa(s))return aa(1);const n=s.getBoundingClientRect(),{width:a,height:o,$:l}=FN(s);let d=(l?Qu(n.width):n.width)/a,u=(l?Qu(n.height):n.height)/o;return(!d||!Number.isFinite(d))&&(d=1),(!u||!Number.isFinite(u))&&(u=1),{x:d,y:u}}const w_=aa(0);function $N(t){const s=cr(t);return!$g()||!s.visualViewport?w_:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function b_(t,s,n){return s===void 0&&(s=!1),!n||s&&n!==cr(t)?!1:s}function Wi(t,s,n,a){s===void 0&&(s=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),l=Ug(t);let d=aa(1);s&&(a?zr(a)&&(d=Ho(a)):d=Ho(t));const u=b_(l,n,a)?$N(l):aa(0);let h=(o.left+u.x)/d.x,f=(o.top+u.y)/d.y,g=o.width/d.x,x=o.height/d.y;if(l){const v=cr(l),w=a&&zr(a)?cr(a):a;let C=v,j=Vp(C);for(;j&&a&&w!==C;){const b=Ho(j),k=j.getBoundingClientRect(),N=Br(j),T=k.left+(j.clientLeft+parseFloat(N.paddingLeft))*b.x,P=k.top+(j.clientTop+parseFloat(N.paddingTop))*b.y;h*=b.x,f*=b.y,g*=b.x,x*=b.y,h+=T,f+=P,C=cr(j),j=Vp(C)}}return Yu({width:g,height:x,x:h,y:f})}function zg(t,s){const n=Um(t).scrollLeft;return s?s.left+n:Wi(ua(t)).left+n}function UN(t,s,n){n===void 0&&(n=!1);const a=t.getBoundingClientRect(),o=a.left+s.scrollLeft-(n?0:zg(t,a)),l=a.top+s.scrollTop;return{x:o,y:l}}function N_(t){let{elements:s,rect:n,offsetParent:a,strategy:o}=t;const l=o==="fixed",d=ua(a),u=s?$m(s.floating):!1;if(a===d||u&&l)return n;let h={scrollLeft:0,scrollTop:0},f=aa(1);const g=aa(0),x=oa(a);if((x||!x&&!l)&&((vl(a)!=="body"||ed(d))&&(h=Um(a)),oa(a))){const w=Wi(a);f=Ho(a),g.x=w.x+a.clientLeft,g.y=w.y+a.clientTop}const v=d&&!x&&!l?UN(d,h,!0):aa(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-h.scrollLeft*f.x+g.x+v.x,y:n.y*f.y-h.scrollTop*f.y+g.y+v.y}}function S_(t){return Array.from(t.getClientRects())}function C_(t){const s=ua(t),n=Um(t),a=t.ownerDocument.body,o=ir(s.scrollWidth,s.clientWidth,a.scrollWidth,a.clientWidth),l=ir(s.scrollHeight,s.clientHeight,a.scrollHeight,a.clientHeight);let d=-n.scrollLeft+zg(t);const u=-n.scrollTop;return Br(a).direction==="rtl"&&(d+=ir(s.clientWidth,a.clientWidth)-o),{width:o,height:l,x:d,y:u}}function k_(t,s){const n=cr(t),a=ua(t),o=n.visualViewport;let l=a.clientWidth,d=a.clientHeight,u=0,h=0;if(o){l=o.width,d=o.height;const f=$g();(!f||f&&s==="fixed")&&(u=o.offsetLeft,h=o.offsetTop)}return{width:l,height:d,x:u,y:h}}function P_(t,s){const n=Wi(t,!0,s==="fixed"),a=n.top+t.clientTop,o=n.left+t.clientLeft,l=oa(t)?Ho(t):aa(1),d=t.clientWidth*l.x,u=t.clientHeight*l.y,h=o*l.x,f=a*l.y;return{width:d,height:u,x:h,y:f}}function cw(t,s,n){let a;if(s==="viewport")a=k_(t,n);else if(s==="document")a=C_(ua(t));else if(zr(s))a=P_(s,n);else{const o=$N(t);a={x:s.x-o.x,y:s.y-o.y,width:s.width,height:s.height}}return Yu(a)}function zN(t,s){const n=fi(t);return n===s||!zr(n)||tl(n)?!1:Br(n).position==="fixed"||zN(n,s)}function T_(t,s){const n=s.get(t);if(n)return n;let a=_c(t,[],!1).filter(u=>zr(u)&&vl(u)!=="body"),o=null;const l=Br(t).position==="fixed";let d=l?fi(t):t;for(;zr(d)&&!tl(d);){const u=Br(d),h=Fg(d);!h&&u.position==="fixed"&&(o=null),(l?!h&&!o:!h&&u.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||ed(d)&&!h&&zN(t,d))?a=a.filter(g=>g!==d):o=u,d=fi(d)}return s.set(t,a),a}function E_(t){let{element:s,boundary:n,rootBoundary:a,strategy:o}=t;const d=[...n==="clippingAncestors"?$m(s)?[]:T_(s,this._c):[].concat(n),a],u=d[0],h=d.reduce((f,g)=>{const x=cw(s,g,o);return f.top=ir(x.top,f.top),f.right=mi(x.right,f.right),f.bottom=mi(x.bottom,f.bottom),f.left=ir(x.left,f.left),f},cw(s,u,o));return{width:h.right-h.left,height:h.bottom-h.top,x:h.left,y:h.top}}function __(t){const{width:s,height:n}=FN(t);return{width:s,height:n}}function R_(t,s,n){const a=oa(s),o=ua(s),l=n==="fixed",d=Wi(t,!0,l,s);let u={scrollLeft:0,scrollTop:0};const h=aa(0);if(a||!a&&!l)if((vl(s)!=="body"||ed(o))&&(u=Um(s)),a){const v=Wi(s,!0,l,
vendor: 4,337 bytes, line 8
8s);h.x=v.x+s.clientLeft,h.y=v.y+s.clientTop}else o&&(h.x=zg(o));const f=o&&!a&&!l?UN(o,u):aa(0),g=d.left+u.scrollLeft-h.x-f.x,x=d.top+u.scrollTop-h.y-f.y;return{x:g,y:x,width:d.width,height:d.height}}function ip(t){return Br(t).position==="static"}function dw(t,s){if(!oa(t)||Br(t).position==="fixed")return null;if(s)return s(t);let n=t.offsetParent;return ua(t)===n&&(n=n.ownerDocument.body),n}function BN(t,s){const n=cr(t);if($m(t))return n;if(!oa(t)){let o=fi(t);for(;o&&!tl(o);){if(zr(o)&&!ip(o))return o;o=fi(o)}return n}let a=dw(t,s);for(;a&&y_(a)&&ip(a);)a=dw(a,s);return a&&tl(a)&&ip(a)&&!Fg(a)?n:a||j_(t)||n}const A_=async function(t){const s=this.getOffsetParent||BN,n=this.getDimensions,a=await n(t.floating);return{reference:R_(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}};function I_(t){return Br(t).direction==="rtl"}const D_={convertOffsetParentRelativeRectToViewportRelativeRect:N_,getDocumentElement:ua,getClippingRect:E_,getOffsetParent:BN,getElementRects:A_,getClientRects:S_,getDimensions:__,getScale:Ho,isElement:zr,isRTL:I_};function VN(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function O_(t,s){let n=null,a;const o=ua(t);function l(){var u;clearTimeout(a),(u=n)==null||u.disconnect(),n=null}function d(u,h){u===void 0&&(u=!1),h===void 0&&(h=1),l();const f=t.getBoundingClientRect(),{left:g,top:x,width:v,height:w}=f;if(u||s(),!v||!w)return;const C=Su(x),j=Su(o.clientWidth-(g+v)),b=Su(o.clientHeight-(x+w)),k=Su(g),T={rootMargin:-C+"px "+-j+"px "+-b+"px "+-k+"px",threshold:ir(0,mi(1,h))||1};let P=!0;function I(O){const R=O[0].intersectionRatio;if(R!==h){if(!P)return d();R?d(!1,R):a=setTimeout(()=>{d(!1,1e-7)},1e3)}R===1&&!VN(f,t.getBoundingClientRect())&&d(),P=!1}try{n=new IntersectionObserver(I,{...T,root:o.ownerDocument})}catch{n=new IntersectionObserver(I,T)}n.observe(t)}return d(!0),l}function M_(t,s,n,a){a===void 0&&(a={});const{ancestorScroll:o=!0,ancestorResize:l=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:h=!1}=a,f=Ug(t),g=o||l?[...f?_c(f):[],..._c(s)]:[];g.forEach(k=>{o&&k.addEventListener("scroll",n,{passive:!0}),l&&k.addEventListener("resize",n)});const x=f&&u?O_(f,n):null;let v=-1,w=null;d&&(w=new ResizeObserver(k=>{let[N]=k;N&&N.target===f&&w&&(w.unobserve(s),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var T;(T=w)==null||T.observe(s)})),n()}),f&&!h&&w.observe(f),w.observe(s));let C,j=h?Wi(t):null;h&&b();function b(){const k=Wi(t);j&&!VN(j,k)&&n(),j=k,C=requestAnimationFrame(b)}return n(),()=>{var k;g.forEach(N=>{o&&N.removeEventListener("scroll",n),l&&N.removeEventListener("resize",n)}),x?.(),(k=w)==null||k.disconnect(),w=null,h&&cancelAnimationFrame(C)}}const L_=p_,F_=g_,$_=m_,U_=v_,z_=h_,uw=u_,B_=x_,V_=(t,s,n)=>{const a=new Map,o={platform:D_,...n},l={...o.platform,_c:a};return d_(t,s,{...o,platform:l})};var Mu=typeof document<"u"?m.useLayoutEffect:m.useEffect;function Zu(t,s){if(t===s)return!0;if(typeof t!=typeof s)return!1;if(typeof t=="function"&&t.toString()===s.toString())return!0;let n,a,o;if(t&&s&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==s.length)return!1;for(a=n;a--!==0;)if(!Zu(t[a],s[a]))return!1;return!0}if(o=Object.keys(t),n=o.length,n!==Object.keys(s).length)return!1;for(a=n;a--!==0;)if(!{}.hasOwnProperty.call(s,o[a]))return!1;for(a=n;a--!==0;){const l=o[a];if(!(l==="_owner"&&t.$$typeof)&&!Zu(t[l],s[l]))return!1}return!0}return t!==t&&s!==s}function qN(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function mw(t,s){const n=qN(t);return Math.round(s*n)/n}function op(t){const s=m.useRef(t);return Mu(()=>{s.current=t}),s}function q_(t){t===void 0&&(t={});const{placement:s="bottom",strategy:n="absolute",middleware:a=[],platform:o,elements:{reference:l,floating:d}={},transform:u=!0,whileElementsMounted:h,open:f}=t,[g,x]=m.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[v,w]=m.useState(a);Zu(v,a)||w(a);const[C,j]=m.useState(null),[b,k]=m.useState(null),N=m.useCallback($=>{$!==O.current&&(O.current=$,j($))},[]),T=m.useCallback($=>{$!==R.current&&(R.current=$,k($))},[]),P=l||C,I=d||b,O=m.useRef(null),R=m.useRef(null),F=m.useRef(g),M=h!=null,z=op(h),H=op(o),V=op(f),B=m.useCallback(()=>
vendor: 5,012 bytes, line 8
8{if(!O.current||!R.current)return;const $={placement:s,strategy:n,middleware:v};H.current&&($.platform=H.current),V_(O.current,R.current,$).then(A=>{const W={...A,isPositioned:V.current!==!1};Y.current&&!Zu(F.current,W)&&(F.current=W,Mr.flushSync(()=>{x(W)}))})},[v,s,n,H,V]);Mu(()=>{f===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,x($=>({...$,isPositioned:!1})))},[f]);const Y=m.useRef(!1);Mu(()=>(Y.current=!0,()=>{Y.current=!1}),[]),Mu(()=>{if(P&&(O.current=P),I&&(R.current=I),P&&I){if(z.current)return z.current(P,I,B);B()}},[P,I,B,z,M]);const L=m.useMemo(()=>({reference:O,floating:R,setReference:N,setFloating:T}),[N,T]),K=m.useMemo(()=>({reference:P,floating:I}),[P,I]),_=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!K.floating)return $;const A=mw(K.floating,g.x),W=mw(K.floating,g.y);return u?{...$,transform:"translate("+A+"px, "+W+"px)",...qN(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:W}},[n,u,K.floating,g.x,g.y]);return m.useMemo(()=>({...g,update:B,refs:L,elements:K,floatingStyles:_}),[g,B,L,K,_])}const K_=t=>{function s(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:a,padding:o}=typeof t=="function"?t(n):t;return a&&s(a)?a.current!=null?uw({element:a.current,padding:o}).fn(n):{}:a?uw({element:a,padding:o}).fn(n):{}}}},H_=(t,s)=>({...L_(t),options:[t,s]}),W_=(t,s)=>({...F_(t),options:[t,s]}),Q_=(t,s)=>({...B_(t),options:[t,s]}),G_=(t,s)=>({...$_(t),options:[t,s]}),Y_=(t,s)=>({...U_(t),options:[t,s]}),Z_=(t,s)=>({...z_(t),options:[t,s]}),X_=(t,s)=>({...K_(t),options:[t,s]});var J_="Arrow",KN=m.forwardRef((t,s)=>{const{children:n,width:a=10,height:o=5,...l}=t;return e.jsx(at.svg,{...l,ref:s,width:a,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:e.jsx("polygon",{points:"0,0 30,0 15,10"})})});KN.displayName=J_;var eR=KN;function Bg(t){const[s,n]=m.useState(void 0);return cn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const a=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const l=o[0];let d,u;if("borderBoxSize"in l){const h=l.borderBoxSize,f=Array.isArray(h)?h[0]:h;d=f.inlineSize,u=f.blockSize}else d=t.offsetWidth,u=t.offsetHeight;n({width:d,height:u})});return a.observe(t,{box:"border-box"}),()=>a.unobserve(t)}else n(void 0)},[t]),s}var Vg="Popper",[HN,yl]=En(Vg),[tR,WN]=HN(Vg),QN=t=>{const{__scopePopper:s,children:n}=t,[a,o]=m.useState(null);return e.jsx(tR,{scope:s,anchor:a,onAnchorChange:o,children:n})};QN.displayName=Vg;var GN="PopperAnchor",YN=m.forwardRef((t,s)=>{const{__scopePopper:n,virtualRef:a,...o}=t,l=WN(GN,n),d=m.useRef(null),u=At(s,d);return m.useEffect(()=>{l.onAnchorChange(a?.current||d.current)}),a?null:e.jsx(at.div,{...o,ref:u})});YN.displayName=GN;var qg="PopperContent",[sR,nR]=HN(qg),ZN=m.forwardRef((t,s)=>{const{__scopePopper:n,side:a="bottom",sideOffset:o=0,align:l="center",alignOffset:d=0,arrowPadding:u=0,avoidCollisions:h=!0,collisionBoundary:f=[],collisionPadding:g=0,sticky:x="partial",hideWhenDetached:v=!1,updatePositionStrategy:w="optimized",onPlaced:C,...j}=t,b=WN(qg,n),[k,N]=m.useState(null),T=At(s,ue=>N(ue)),[P,I]=m.useState(null),O=Bg(P),R=O?.width??0,F=O?.height??0,M=a+(l!=="center"?"-"+l:""),z=typeof g=="number"?g:{top:0,right:0,bottom:0,left:0,...g},H=Array.isArray(f)?f:[f],V=H.length>0,B={padding:z,boundary:H.filter(aR),altBoundary:V},{refs:Y,floatingStyles:L,placement:K,isPositioned:_,middlewareData:$}=q_({strategy:"fixed",placement:M,whileElementsMounted:(...ue)=>M_(...ue,{animationFrame:w==="always"}),elements:{reference:b.anchor},middleware:[H_({mainAxis:o+F,alignmentAxis:d}),h&&W_({mainAxis:!0,crossAxis:!1,limiter:x==="partial"?Q_():void 0,...B}),h&&G_({...B}),Y_({...B,apply:({elements:ue,rects:Re,availableWidth:$e,availableHeight:le})=>{const{width:Me,height:He}=Re.reference,ft=ue.floating.style;ft.setProperty("--radix-popper-available-width",`${$e}px`),ft.setProperty("--radix-popper-available-height",`${le}px`),ft.setProperty("--radix-popper-anchor-width",`${Me}px`),ft.setProperty("--radix-popper-anchor-height",`${He}px`)}}),P&&X_({element:P,padding:u}),iR({arrowWidth:R,arrowHeight:F}),v&&Z_({strategy:"referenceHidden",...B})]}),[A,W]=e0(K),U=Rs(C);cn(()=>{_&&U?.()},[_,U]);const Q=$.arrow?.x,we=$.arrow?.y,_e=$.arrow?.centerOffset!==0,[Ie,Te]=m.useState();return cn(()=>{k&&Te(window.getComputedStyle(k).zIndex)},[k]),e.jsx("div",{ref:Y.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:_?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ie,"--radix-popper-transform-origin":[$.transformOrigin?.x,$.transformOrigin?.y].join(" "),...$.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(sR,{scope:n,placedSide:A,onArrowChange:I,arrowX:Q,arrowY:we,shouldHideArrow:_e,children:e.jsx(at.div,{"data-side":A,"data-align":W,...j,ref:T,style:{...j.style,animation:_?void 0:"none"}})})})});ZN.displayName=qg;var XN="PopperArrow",rR={top:"bottom",right:"left",bottom:"top",left:"r
8ight"},JN=m.forwardRef(function(s,n){const{__scopePopper:a,...o}=s,l=nR(XN,a),d=rR[l.placedSide];return e.jsx("span",{ref:l.onArrowChange,style:{position:"absolute",left:l.arrowX,top:l.arrowY,[d]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[l.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[l.placedSide],visibility:l.shouldHideArrow?"hidden":void 0},children:e.jsx(eR,{...o,ref:n,style:{...o.style,display:"block"}})})});JN.displayName=XN;function aR(t){return t!==null}var iR=t=>({name:"transformOrigin",options:t,fn(s){const{placement:n,rects:a,middlewareData:o}=s,d=o.arrow?.centerOffset!==0,u=d?0:t.arrowWidth,h=d?0:t.arrowHeight,[f,g]=e0(n),x={start:"0%",center:"50%",end:"100%"}[g],v=(o.arrow?.x??0)+u/2,w=(o.arrow?.y??0)+h/2;let C="",j="";return f==="bottom"?(C=d?x:`${v}px`,j=`${-h}px`):f==="top"?(C=d?x:`${v}px`,j=`${a.floating.height+h}px`):f==="right"?(C=`${-h}px`,j=d?x:`${w}px`):f==="left"&&(C=`${a.floating.width+h}px`,j=d?x:`${w}px`),{data:{x:C,y:j}}}});function e0(t){const[s,n="center"]=t.split("-");return[s,n]}var Kg=QN,Hg=YN,Wg=ZN,Qg=JN,[zm]=En("Tooltip",[yl]),Bm=yl(),t0="TooltipProvider",oR=700,qp="tooltip.open",[lR,Gg]=zm(t0),s0=t=>{const{__scopeTooltip:s,delayDuration:n=oR,skipDelayDuration:a=300,disableHoverableContent:o=!1,children:l}=t,d=m.useRef(!0),u=m.useRef(!1),h=m.useRef(0);return m.useEffect(()=>{const f=h.current;return()=>window.clearTimeout(f)},[]),e.jsx(lR,{scope:s,isOpenDelayedRef:d,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(h.current),d.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>d.current=!0,a)},[a]),isPointerInTransitRef:u,onPointerInTransitChange:m.useCallback(f=>{u.current=f},[]),disableHoverableContent:o,children:l})};s0.displayName=t0;var Vm="Tooltip",[cR,qm]=zm(Vm),n0=t=>{const{__scopeTooltip:s,children:n,open:a,defaultOpen:o=!1,onOpenChange:l,disableHoverableContent:d,delayDuration:u}=t,h=Gg(Vm,t.__scopeTooltip),f=Bm(s),[g,x]=m.useState(null),v=jr(),w=m.useRef(0),C=d??h.disableHoverableContent,j=u??h.delayDuration,b=m.useRef(!1),[k=!1,N]=Ur({prop:a,defaultProp:o,onChange:R=>{R?(h.onOpen(),document.dispatchEvent(new CustomEvent(qp))):h.onClose(),l?.(R)}}),T=m.useMemo(()=>k?b.current?"delayed-open":"instant-open":"closed",[k]),P=m.useCallback(()=>{window.clearTimeout(w.current),w.current=0,b.current=!1,N(!0)},[N]),I=m.useCallback(()=>{window.clearTimeout(w.current),w.current=0,N(!1)},[N]),O=m.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{b.current=!0,N(!0),w.current=0},j)},[j,N]);return m.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]),e.jsx(Kg,{...f,children:e.jsx(cR,{scope:s,contentId:v,open:k,stateAttribute:T,trigger:g,onTriggerChange:x,onTriggerEnter:m.useCallback(()=>{h.isOpenDelayedRef.current?O():P()},[h.isOpenDelayedRef,O,P]),onTriggerLeave:m.useCallback(()=>{C?I():(window.clearTimeout(w.current),w.current=0)},[I,C]),onOpen:P,onClose:I,disableHoverableContent:C,children:n})})};n0.displayName=Vm;var Kp="TooltipTrigger",r0=m.forwardRef((t,s)=>{const{__scopeTooltip:n,...a}=t,o=qm(Kp,n),l=Gg(Kp,n),d=Bm(n),u=m.useRef(null),h=At(s,u,o.onTriggerChange),f=m.useRef(!1),g=m.useRef(!1),x=m.useCallback(()=>f.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",x),[x]),e.jsx(Hg,{asChild:!0,...d,children:e.jsx(at.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...a,ref:h,onPointerMove:Ae(t.onPointerMove,v=>{v.pointerType!=="touch"&&!g.current&&!l.isPointerInTransitRef.current&&(o.onTriggerEnter(),g.current=!0)}),onPointerLeave:Ae(t.onPointerLeave,()=>{o.onTriggerLeave(),g.current=!1}),onPointerDown:Ae(t.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",x,{once:!0})}),onFocus:Ae(t.onFocus,()=>{f.current||o.onOpen()}),onBlur:Ae(t.onBlur,o.onClose),onClick:Ae(t.onClick,o.onClose)})})});r0.displayName=Kp;var dR="TooltipPortal",[hB,uR]=zm(dR,{forceMount:void 0}),sl="TooltipContent",a0=m.forwardRef((t,s)=>{const n=uR(sl,t.__scopeTooltip),{forceMount:a=n.forceMount,side:o="top",...l}=t,d=qm(sl,t.__scopeTooltip);return e.jsx(gn,{present:a||d.open,children:d.disableHoverableContent?e.jsx(i0,{side:o,...l,ref:s}):e.jsx(mR,{side:o,...l,ref:s})})}),mR=m.forwardRef((t,s)=>{const n=qm(sl,t.__scopeTooltip),a=Gg(sl,t.__scopeTooltip),o=m.useRef(null),l=At(s,o),[d,u]=m.useState(null),{trigger:h,onClose:f}=n,g=o.current,{onPointerInTransitChange:x}=a,v=m.useCallback(()=>{u(null),x(!1)},[x]),w=m.useCallback((C,j)=>{const b=C.currentTarget,k={x:C.clientX,y:C.clientY},N=xR(k,b.getBoundingClientRect()),T=vR(k,N),P=yR(j.getBoundingClientRect()),I=wR([...T,...P]);u(I),x(!0)},[x]);return m.useEffect(()=>()=>v(),[v]),m.useEffect(()=>{if(h&&g){const C=b=>w(b,g),j=b=>w(b,h);return h.addEventListener("pointerleave",C),g.addEventListener("pointerleave",j),()=>{h.removeEventListener("pointerleave",C),g.removeEventListener("pointerleave",j)}}},[h,g,w,v]),m.useEffect(()=>{if(d){const C=j=>{const b=j.target,k={x:j.clientX,y:j.clientY},N=h?.contains(b)||g?.contains(b),T=!jR(k,d);N?v():T&&(v(),f())};return document.addEventListener("pointermove",C),()=>document.removeEventListener("pointermove",C)}},[h,g,d,f,v]),e.jsx(i0,{...t,ref:l})}),[hR,fR]=zm(Vm,{isInside:!1}),pR=qb("TooltipContent"),i0=m.forwardRef((t,s)=>{const{__scopeTooltip:n,children:a,"aria-label":o,onEscapeKeyDown:l,onPointerDownOutside:d,...u}=t,h=qm(sl,n),f=Bm(n),{onClose:g}=h;return m.useEffect(()=>(document.addEventListener(qp,g),()=>document.removeEventListener(qp,g)),[g]),m.useEffect(()=>{if(h.trigger){const x=v=>{v.target?.contains(h.trigger)&&g()};return window.addEventListener("scroll",x,{capture:!0}),()=>window.removeEventListener("scroll",x,{capture:!0})}},[h.trigger,g]),e.jsx(ul,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:x=>x.preventDefault(),onDismiss:g,children:e.jsxs(Wg,{"data-state":h.stateAttribute,...f,...u,ref:s,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(pR,{children:a}),e.jsx(hR,{scope:n,isInside:!0,children:e.jsx(D4,{id:h.contentId,role:"tooltip",children:o||a})})]})})});a0.displayName=sl;var o0="TooltipArrow",gR=m.forwardRef((t,s)=>{const{__scopeTooltip:n,...a}=t,o=Bm(n);return fR(o0,n).isInside?null:e.jsx(Qg,{...o,...a,ref:s})});gR.displayName=o0;function xR(t,s){const n=Math.abs(s.top-t.y),a=Math.abs(s.bottom-t.y),o=Math.abs(s.right-t.x),l=Math.abs(s.left-t.x);switch(Math.min(n,a,o,l)){case l:return"left";case o:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function vR(t,s,n=5){const a=[];switch(s){case"top":a.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":a.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":a.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":a.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return a}
8function yR(t){const{top:s,right:n,bottom:a,left:o}=t;return[{x:o,y:s},{x:n,y:s},{x:n,y:a},{x:o,y:a}]}function jR(t,s){const{x:n,y:a}=t;let o=!1;for(let l=0,d=s.length-1;l<s.length;d=l++){const u=s[l].x,h=s[l].y,f=s[d].x,g=s[d].y;h>a!=g>a&&n<(f-u)*(a-h)/(g-h)+u&&(o=!o)}return o}function wR(t){const s=t.slice();return s.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),bR(s)}function bR(t){if(t.length<=1)return t.slice();const s=[];for(let a=0;a<t.length;a++){const o=t[a];for(;s.length>=2;){const l=s[s.length-1],d=s[s.length-2];if((l.x-d.x)*(o.y-d.y)>=(l.y-d.y)*(o.x-d.x))s.pop();else break}s.push(o)}s.pop();const n=[];for(let a=t.length-1;a>=0;a--){const o=t[a];for(;n.length>=2;){const l=n[n.length-1],d=n[n.length-2];if((l.x-d.x)*(o.y-d.y)>=(l.y-d.y)*(o.x-d.x))n.pop();else break}n.push(o)}return n.pop(),s.length===1&&n.length===1&&s[0].x===n[0].x&&s[0].y===n[0].y?s:s.concat(n)}var NR=s0,SR=n0,CR=r0,l0=a0;const c0=NR,d0=SR,u0=CR,Yg=m.forwardRef(({className:t,sideOffset:s=4,...n},a)=>e.jsx(l0,{ref:a,sideOffset:s,className:Oe("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...n}));Yg.displayName=l0.displayName;const kR={theme:"system",setTheme:()=>null},m0=m.createContext(kR);function PR({children:t,defaultTheme:s="system",storageKey:n="outliner-ui-theme",...a}){const[o,l]=m.useState(()=>localStorage.getItem(n)||s);m.useEffect(()=>{const u=window.document.documentElement;if(u.classList.remove("light","dark"),o==="system"){const h=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";u.classList.add(h);return}u.classList.add(o)},[o]);const d={theme:o,setTheme:u=>{localStorage.setItem(n,u),l(u)}};return e.jsx(m0.Provider,{...a,value:d,children:t})}const h0=()=>{const t=m.useContext(m0);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t},f0=m.createContext(void 0),cc="outliner-auth-user";function TR({children:t}){const[s,n]=m.useState(null),[a,o]=m.useState(!0);m.useEffect(()=>{const u=localStorage.getItem(cc);if(u)try{n(JSON.parse(u))}catch{localStorage.removeItem(cc)}o(!1)},[]);const l=u=>{n(u),u?localStorage.setItem(cc,JSON.stringify(u)):localStorage.removeItem(cc)},d=()=>{n(null),localStorage.removeItem(cc)};return e.jsx(f0.Provider,{value:{user:s,setUser:l,logout:d,isLoading:a},children:t})}function Da(){const t=m.useContext(f0);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const p0=m.createContext(void 0),na="outliner-portal-user";function ER({children:t}){const[s,n]=m.useState(null),[a,o]=m.useState(!0),l=m.useRef(!1);m.useEffect(()=>{const h=localStorage.getItem(na);if(h)try{const f=JSON.parse(h);n(f),l.current||(l.current=!0,fetch("/api/portal/auth/refresh",{method:"POST",credentials:"include"}).then(async g=>{if(g.ok){const x=await g.json();x.user&&x.authToken&&(n(x.user),localStorage.setItem(na,JSON.stringify(x.user)),ri(x.authToken),console.log("[Portal Auth] Token refreshed via session"))}else if(g.status===401){console.log("[Portal Auth] Session expired, checking bearer token...");const x=Gn();x?fetch("/api/portal/auth/validate-token",{method:"POST",headers:{Authorization:`Bearer ${x}`,"Content-Type":"application/json"}}).then(async v=>{if(v.ok){const w=await v.json();w.valid&&w.user?(console.log("[Portal Auth] Bearer token still valid"),n(w.user),localStorage.setItem(na,JSON.stringify(w.user)),w.authToken&&ri(w.authToken)):(console.log("[Portal Auth] Bearer token invalid, logging out"),localStorage.removeItem(na),ri(null),n(null))}else console.log("[Portal Auth] Token validation failed, logging out"),localStorage.removeItem(na),ri(null),n(null)}).catch(v=>{console.error("[Portal Auth] Token validation error:",v)}):(console.log("[Portal Auth] No bearer token found, logging out"),localStorage.removeItem(na),ri(null),n(null))}}).catch(g=>{console.error("[Portal Auth] Refresh failed:",g)}))}catch{localStorage.removeItem(na)}o(!1)},[]);const d=(h,f)=>{n(h),h?(localStorage.setItem(na,JSON.stringify(h)),f&&ri(f)):(localStorage.removeItem(na),ri(null))},u=()=>{n(null),localStorage.removeItem(na),ri(null)};return e.jsx(p0.Provider,{value:{user:s,setUser:d,logout:u,isLoading:a},children:t})}function Oa(){const t=m.useContext(p0);if(t===void 0)throw new Error("usePortalAuth must be used within a PortalAuthProvider");return t}const ee=m.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:Oe("shadcn-card rounded-xl border bg-card border-card-border text-card-foreground shadow-sm",t),...s}));
vendor: 12,335 bytes, lines 8-23
8ee.displayName="Card";const qe=m.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:Oe("flex flex-col space-y-1.5 p-6",t),...s}));qe.displayName="CardHeader";const tt=m.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:Oe("text-2xl font-semibold leading-none tracking-tight",t),...s}));tt.displayName="CardTitle";const Tt=m.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:Oe("text-sm text-muted-foreground",t),...s}));Tt.displayName="CardDescription";const te=m.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:Oe("p-6 pt-0",t),...s}));te.displayName="CardContent";const _R=m.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:Oe("flex items-center p-6 pt-0",t),...s}));_R.displayName="CardFooter";function RR(){return e.jsx("div",{className:"min-h-screen w-full flex items-center justify-center bg-gray-50",children:e.jsx(ee,{className:"w-full max-w-md mx-4",children:e.jsxs(te,{className:"pt-6",children:[e.jsxs("div",{className:"flex mb-4 gap-2",children:[e.jsx(hl,{className:"h-8 w-8 text-red-500"}),e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"404 Page Not Found"})]}),e.jsx("p",{className:"mt-4 text-sm text-gray-600",children:"Did you forget to add the page to the router?"})]})})})}const Zg=ml("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover-elevate active-elevate-2",{variants:{variant:{default:"bg-primary text-primary-foreground border border-primary-border",destructive:"bg-destructive text-destructive-foreground border border-destructive-border",outline:" border [border-color:var(--button-outline)]  shadow-xs active:shadow-none ",secondary:"border bg-secondary text-secondary-foreground border border-secondary-border ",ghost:"border border-transparent"},size:{default:"min-h-9 px-4 py-2",sm:"min-h-8 rounded-md px-3 text-xs",lg:"min-h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),D=m.forwardRef(({className:t,variant:s,size:n,asChild:a=!1,...o},l)=>{const d=a?Cg:"button";return e.jsx(d,{className:Oe(Zg({variant:s,size:n,className:t})),ref:l,...o})});D.displayName="Button";const AR=ml("whitespace-nowrap inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 hover-elevate ",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow-xs",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow-xs",outline:" border [border-color:var(--badge-outline)] shadow-xs"}},defaultVariants:{variant:"default"}}),Ce=m.forwardRef(({className:t,variant:s,...n},a)=>e.jsx("div",{ref:a,className:Oe(AR({variant:s}),t),...n}));Ce.displayName="Badge";var lp="focusScope.autoFocusOnMount",cp="focusScope.autoFocusOnUnmount",hw={bubbles:!1,cancelable:!0},IR="FocusScope",Km=m.forwardRef((t,s)=>{const{loop:n=!1,trapped:a=!1,onMountAutoFocus:o,onUnmountAutoFocus:l,...d}=t,[u,h]=m.useState(null),f=Rs(o),g=Rs(l),x=m.useRef(null),v=At(s,j=>h(j)),w=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(a){let j=function(T){if(w.paused||!u)return;const P=T.target;u.contains(P)?x.current=P:li(x.current,{select:!0})},b=function(T){if(w.paused||!u)return;const P=T.relatedTarget;P!==null&&(u.contains(P)||li(x.current,{select:!0}))},k=function(T){if(document.activeElement===document.body)for(const I of T)I.removedNodes.length>0&&li(u)};document.addEventListener("focusin",j),document.addEventListener("focusout",b);const N=new MutationObserver(k);return u&&N.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",b),N.disconnect()}}},[a,u,w.paused]),m.useEffect(()=>{if(u){pw.add(w);const j=document.activeElement;if(!u.contains(j)){const k=new CustomEvent(lp,hw);u.addEventListener(lp,f),u.dispatchEvent(k),k.defaultPrevented||(DR($R(g0(u)),{select:!0}),document.activeElement===j&&li(u))}return()=>{u.removeEventListener(lp,f),setTimeout(()=>{const k=new CustomEvent(cp,hw);u.addEventListener(cp,g),u.dispatchEvent(k),k.defaultPrevented||li(j??document.body,{select:!0}),u.removeEventListener(cp,g),pw.remove(w)},0)}}},[u,f,g,w]);const C=m.useCallback(j=>{if(!n&&!a||w.paused)return;const b=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,k=document.activeElement;if(b&&k){const N=j.currentTarget,[T,P]=OR(N);T&&P?!j.shiftKey&&k===P?(j.preventDefault(),n&&li(T,{select:!0})):j.shiftKey&&k===T&&(j.preventDefault(),n&&li(P,{select:!0})):k===N&&j.preventDefault()}},[n,a,w.paused]);return e.jsx(at.div,{tabIndex:-1,...d,ref:v,onKeyDown:C})});Km.displayName=IR;function DR(t,{select:s=!1}={}){const n=document.activeElement;for(const a of t)if(li(a,{select:s}),document.activeElement!==n)return}function OR(t){const s=g0(t),n=fw(s,t),a=fw(s.reverse(),t);return[n,a]}function g0(t){const s=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const o=a.tagName==="INPUT"&&a.type==="hidden";return a.disabled||a.hidden||o?NodeFilter.FILTER_SKIP:a.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)s.push(n.currentNode);return s}function fw(t,s){for(const n of t)if(!MR(n,{upTo:s}))return n}function MR(t,{upTo:s}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(s!==void 0&&t===s)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function LR(t){return t instanceof HTMLInputElement&&"select"in t}function li(t,{select:s=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&LR(t)&&s&&t.select()}}var pw=FR();function FR(){let t=[];return{add(s){const n=t[0];s!==n&&n?.pause(),t=gw(t,s),t.unshift(s)},remove(s){t=gw(t,s),t[0]?.resume()}}}function gw(t,s){const n=[...t],a=n.indexOf(s);return a!==-1&&n.splice(a,1),n}function $R(t){return t.filter(s=>s.tagName!=="A")}var dp=0;function Xg(){m.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??xw()),document.body.insertAdjacentElement("beforeend",t[1]??xw()),dp++,()=>{dp===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),dp--}},[])}function xw(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var ra=function(){return ra=Object.assign||function(s){for(var n,a=1,o=arguments.length;a<o;a++){n=arguments[a];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(s[l]=n[l])}return s},ra.apply(this,arguments)};function x0(t,s){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&s.indexOf(a)<0&&(n[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,a=Object.getOwnPropertySymbols(t);o<a.length;o++)s.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(t,a[o])&&(n[a[o]]=t[a[o]]);return n}function UR(t,s,n){if(n||arguments.length===2)for(var a=0,o=s.length,l;a<o;a++)(l||!(a in s))&&(l||(l=Array.prototype.slice.call(s,0,a)),l[a]=s[a]);return t.concat(l||Array.prototype.slice.call(s))}var Lu="right-scroll-bar-position",Fu="width-before-scroll-bar",zR="with-scroll-bars-hidden",BR="--removed-body-scroll-bar-size";function up(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function VR(t,s){var n=m.useState(function(){return{value:t,callback:s,facade:{get current(){return n.value},set current(a){var o=n.value;o!==a&&(n.value=a,n.callback(a,o))}}}})[0];return n.callback=s,n.facade}var qR=typeof window<"u"?m.useLayoutEffect:m.useEffect,vw=new WeakMap;function KR(t,s){var n=VR(null,function(a){return t.forEach(function(o){return up(o,a)})});return qR(function(){var a=vw.get(n);if(a){var o=new Set(a),l=new Set(t),d=n.current;o.forEach(function(u){l.has(u)||up(u,null)}),l.forEach(function(u){o.has(u)||up(u,d)})}vw.set(n,t)},[t]),n}function HR(t){return t}function WR(t,s){s===void 0&&(s=HR);var n=[],a=!1,o={read:function(){if(a)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(l){var d=s(l,a);return n.push(d),function(){n=n.filter(function(u){return u!==d})}},assignSyncMedium:function(l){for(a=!0;n.length;){var d=n;n=[],d.forEach(l)}n={push:function(u){return l(u)},filter:function(){return n}}},assignMedium:function(l){a=!0;var d=[];if(n.length){var u=n;n=[],u.forEach(l),d=n}var h=function(){var g=d;d=[],g.forEach(l)},f=function(){return Promise.resolve().then(h)};f(),n={push:function(g){d.push(g),f()},filter:function(g){return d=d.filter(g),n}}}};return o}function QR(t){t===void 0&&(t={});var s=WR(null);return s.options=ra({async:!0,ssr:!1},t),s}var v0=function(t){var s=t.sideCar,n=x0(t,["sideCar"]);if(!s)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var a=s.read();if(!a)throw new Error("Sidecar medium not found");return m.createElement(a,ra({},n))};v0.isSideCarExport=!0;function GR(t,s){return t.useMedium(s),v0}var y0=QR(),mp=function(){},Hm=m.forwardRef(function(t,s){var n=m.useRef(null),a=m.useState({onScrollCapture:mp,onWheelCapture:mp,onTouchMoveCapture:mp}),o=a[0],l=a[1],d=t.forwardProps,u=t.children,h=t.className,f=t.removeScrollBar,g=t.enabled,x=t.shards,v=t.sideCar,w=t.noIsolation,C=t.inert,j=t.allowPinchZoom,b=t.as,k=b===void 0?"div":b,N=t.gapMode,T=x0(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=v,I=KR([n,s]),O=ra(ra({},T),o);return m.createElement(m.Fragment,null,g&&m.createElement(P,{sideCar:y0,removeScrollBar:f,shards:x,noIsolation:w,inert:C,setCallbacks:l,allowPinchZoom:!!j,lockRef:n,gapMode:N}),d?m.cloneElement(m.Children.only(u),ra(ra({},O),{ref:I})):m.createElement(k,ra({},O,{className:h,ref:I}),u))});Hm.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Hm.classNames={fullWidth:Fu,zeroRight:Lu};var YR=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ZR(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=YR();return s&&t.setAttribute("nonce",s),t}function XR(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function JR(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var eA=function(){var t=0,s=null;return{add:function(n){t==0&&(s=ZR())&&(XR(s,n),JR(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},tA=function(){var t=eA();return function(s,n){m.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&n])}},j0=function(){var t=tA(),s=function(n){var a=n.styles,o=n.dynamic;return t(a,o),null};return s},sA={left:0,top:0,right:0,gap:0},hp=function(t){return parseInt(t||"",10)||0},nA=function(t){var s=window.getComputedStyle(document.body),n=s[t==="padding"?"paddingLeft":"marginLeft"],a=s[t==="padding"?"paddingTop":"marginTop"],o=s[t==="padding"?"paddingRight":"marginRight"];return[hp(n),hp(a),hp(o)]},rA=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return sA;var s=nA(t),n=document.documentElement.clientWidth,a=window.innerWidth;return{left:s[0],top:s[1],right:s[2],gap:Math.max(0,a-n+s[2]-s[0])}},aA=j0(),Wo="data-scroll-locked",iA=function(t,s,n,a){var o=t.left,l=t.top,d=t.right,u=t.gap;return n===void 0&&(n="margin"),`
9  .`.concat(zR,` {
10   overflow: hidden `).concat(a,`;
11   padding-right: `).concat(u,"px ").concat(a,`;
12  }
13  body[`).concat(Wo,`] {
14    overflow: hidden `).concat(a,`;
15    overscroll-behavior: contain;
16    `).concat([s&&"position: relative ".concat(a,";"),n==="margin"&&`
17    padding-left: `.concat(o,`px;
18    padding-top: `).concat(l,`px;
19    padding-right: `).concat(d,`px;
20    margin-left:0;
21    margin-top:0;
22    margin-right: `).concat(u,"px ").concat(a,`;
23    `),n==="padding"&&"padding-right: ".concat(u,"px ").concat(a,";
23")].filter(Boolean).join(""),`
24  }
25  
26  .`).concat(Lu,` {
27    right: `).concat(u,"px ").concat(a,`;
28  }
29  
30  .`).concat(Fu,` {
31    margin-right: `).concat(u,"px ").concat(a,`;
32  }
33  
34  .`).concat(Lu," .").concat(Lu,` {
35    right: 0 `).concat(a,`;
36  }
37  
38  .`).concat(Fu," .").concat(Fu,` {
39    margin-right: 0 `).concat(a,`;
40  }
41  
42  body[`).concat(Wo,`] {
43    `).concat(BR,": ").concat(u,`px;
44  }
45`)},yw=function(){var t=parseInt(document.body.getAttribute(Wo)||"0",10);return isFinite(t)?t:0},oA=function(){m.useEffect(function(){return document.body.setAttribute(Wo,(yw()+1).toString()),function(){var t=yw()-1;t<=0?document.body.removeAttribute(Wo):document.body.setAttribute(Wo,t.toString())}},[])},lA=function(t){var s=t.noRelative,n=t.noImportant,a=t.gapMode,o=a===void 0?"margin":a;oA();var l=m.useMemo(function(){return rA(o)},[o]);return m.createElement(aA,{styles:iA(l,!s,o,n?"":"!important")})},Hp=!1;if(typeof window<"u")try{var Cu=Object.defineProperty({},"passive",{get:function(){return Hp=!0,!0}});window.addEventListener("test",Cu,Cu),window.removeEventListener("test",Cu,Cu)}catch{Hp=!1}var _o=Hp?{passive:!1}:!1,cA=function(t){return t.tagName==="TEXTAREA"},w0=function(t,s){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[s]!=="hidden"&&!(n.overflowY===n.overflowX&&!cA(t)&&n[s]==="visible")},dA=function(t){return w0(t,"overflowY")},uA=function(t){return w0(t,"overflowX")},jw=function(t,s){var n=s.ownerDocument,a=s;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var o=b0(t,a);if(o){var l=N0(t,a),d=l[1],u=l[2];if(d>u)return!0}a=a.parentNode}while(a&&a!==n.body);return!1},mA=function(t){var s=t.scrollTop,n=t.scrollHeight,a=t.clientHeight;return[s,n,a]},hA=function(t){var s=t.scrollLeft,n=t.scrollWidth,a=t.clientWidth;return[s,n,a]},b0=function(t,s){return t==="v"?dA(s):uA(s)},N0=function(t,s){return t==="v"?mA(s):hA(s)},fA=function(t,s){return t==="h"&&s==="rtl"?-1:1},pA=function(t,s,n,a,o){var l=fA(t,window.getComputedStyle(s).direction),d=l*a,u=n.target,h=s.contains(u),f=!1,g=d>0,x=0,v=0;do{var w=N0(t,u),C=w[0],j=w[1],b=w[2],k=j-b-l*C;(C||k)&&b0(t,u)&&(x+=k,v+=C),u instanceof ShadowRoot?u=u.host:u=u.parentNode}while(!h&&u!==document.body||h&&(s.contains(u)||s===u));return(g&&Math.abs(x)<1||!g&&Math.abs(v)<1)&&(f=!0),f},ku=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},ww=function(t){return[t.deltaX,t.deltaY]},bw=function(t){return t&&"current"in t?t.current:t},gA=function(t,s){return t[0]===s[0]&&t[1]===s[1]},xA=function(t){return`
46  .block-interactivity-`.concat(t,` {pointer-events: none;}
47  .allow-interactivity-`).concat(t,` {pointer-events: all;}
48`)},vA=0,Ro=[];function yA(t){var s=m.useRef([]),n=m.useRef([0,0]),a=m.useRef(),o=m.useState(vA++)[0],l=m.useState(j0)[0],d=m.useRef(t);m.useEffect(function(){d.current=t},[t]),m.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var j=UR([t.lockRef.current],(t.shards||[]).map(bw),!0).filter(Boolean);return j.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),j.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var u=m.useCallback(function(j,b){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!d.current.allowPinchZoom;var k=ku(j),N=n.current,T="deltaX"in j?j.deltaX:N[0]-k[0],P="deltaY"in j?j.deltaY:N[1]-k[1],I,O=j.target,R=Math.abs(T)>Math.abs(P)?"h":"v";if("touches"in j&&R==="h"&&O.type==="range")return!1;var F=jw(R,O);if(!F)return!0;if(F?I=R:(I=R==="v"?"h":"v",F=jw(R,O)),!F)return!1;if(!a.current&&"changedTouches"in j&&(T||P)&&(a.current=I),!I)return!0;var M=a.current||I;return pA(M,b,j,M==="h"?T:P)},[]),h=m.useCallback(function(j){var b=j;if(!(!Ro.length||Ro[Ro.length-1]!==l)){var k="deltaY"in b?ww(b):ku(b),N=s.current.filter(function(I){return I.name===b.type&&(I.target===b.target||b.target===I.shadowParent)&&gA(I.delta,k)})[0];if(N&&N.should){b.cancelable&&b.preventDefault();return}
vendor: 9,153 bytes, lines 48-52
48if(!N){var T=(d.current.shards||[]).map(bw).filter(Boolean).filter(function(I){return I.contains(b.target)}),P=T.length>0?u(b,T[0]):!d.current.noIsolation;P&&b.cancelable&&b.preventDefault()}}},[]),f=m.useCallback(function(j,b,k,N){var T={name:j,delta:b,target:k,should:N,shadowParent:jA(k)};s.current.push(T),setTimeout(function(){s.current=s.current.filter(function(P){return P!==T})},1)},[]),g=m.useCallback(function(j){n.current=ku(j),a.current=void 0},[]),x=m.useCallback(function(j){f(j.type,ww(j),j.target,u(j,t.lockRef.current))},[]),v=m.useCallback(function(j){f(j.type,ku(j),j.target,u(j,t.lockRef.current))},[]);m.useEffect(function(){return Ro.push(l),t.setCallbacks({onScrollCapture:x,onWheelCapture:x,onTouchMoveCapture:v}),document.addEventListener("wheel",h,_o),document.addEventListener("touchmove",h,_o),document.addEventListener("touchstart",g,_o),function(){Ro=Ro.filter(function(j){return j!==l}),document.removeEventListener("wheel",h,_o),document.removeEventListener("touchmove",h,_o),document.removeEventListener("touchstart",g,_o)}},[]);var w=t.removeScrollBar,C=t.inert;return m.createElement(m.Fragment,null,C?m.createElement(l,{styles:xA(o)}):null,w?m.createElement(lA,{gapMode:t.gapMode}):null)}function jA(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const wA=GR(y0,yA);var Wm=m.forwardRef(function(t,s){return m.createElement(Hm,ra({},t,{ref:s,sideCar:wA}))});Wm.classNames=Hm.classNames;var bA=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},Ao=new WeakMap,Pu=new WeakMap,Tu={},fp=0,S0=function(t){return t&&(t.host||S0(t.parentNode))},NA=function(t,s){return s.map(function(n){if(t.contains(n))return n;var a=S0(n);return a&&t.contains(a)?a:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},SA=function(t,s,n,a){var o=NA(s,Array.isArray(t)?t:[t]);Tu[n]||(Tu[n]=new WeakMap);var l=Tu[n],d=[],u=new Set,h=new Set(o),f=function(x){!x||u.has(x)||(u.add(x),f(x.parentNode))};o.forEach(f);var g=function(x){!x||h.has(x)||Array.prototype.forEach.call(x.children,function(v){if(u.has(v))g(v);else try{var w=v.getAttribute(a),C=w!==null&&w!=="false",j=(Ao.get(v)||0)+1,b=(l.get(v)||0)+1;Ao.set(v,j),l.set(v,b),d.push(v),j===1&&C&&Pu.set(v,!0),b===1&&v.setAttribute(n,"true"),C||v.setAttribute(a,"true")}catch(k){console.error("aria-hidden: cannot operate on ",v,k)}})};return g(s),u.clear(),fp++,function(){d.forEach(function(x){var v=Ao.get(x)-1,w=l.get(x)-1;Ao.set(x,v),l.set(x,w),v||(Pu.has(x)||x.removeAttribute(a),Pu.delete(x)),w||x.removeAttribute(n)}),fp--,fp||(Ao=new WeakMap,Ao=new WeakMap,Pu=new WeakMap,Tu={})}},Jg=function(t,s,n){n===void 0&&(n="data-aria-hidden");var a=Array.from(Array.isArray(t)?t:[t]),o=bA(t);return o?(a.push.apply(a,Array.from(o.querySelectorAll("[aria-live]"))),SA(a,o,n,"aria-hidden")):function(){return null}},ex="Dialog",[C0,k0]=En(ex),[CA,Wr]=C0(ex),P0=t=>{const{__scopeDialog:s,children:n,open:a,defaultOpen:o,onOpenChange:l,modal:d=!0}=t,u=m.useRef(null),h=m.useRef(null),[f=!1,g]=Ur({prop:a,defaultProp:o,onChange:l});return e.jsx(CA,{scope:s,triggerRef:u,contentRef:h,contentId:jr(),titleId:jr(),descriptionId:jr(),open:f,onOpenChange:g,onOpenToggle:m.useCallback(()=>g(x=>!x),[g]),modal:d,children:n})};P0.displayName=ex;var T0="DialogTrigger",E0=m.forwardRef((t,s)=>{const{__scopeDialog:n,...a}=t,o=Wr(T0,n),l=At(s,o.triggerRef);return e.jsx(at.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":nx(o.open),...a,ref:l,onClick:Ae(t.onClick,o.onOpenToggle)})});E0.displayName=T0;var tx="DialogPortal",[kA,_0]=C0(tx,{forceMount:void 0}),R0=t=>{const{__scopeDialog:s,forceMount:n,children:a,container:o}=t,l=Wr(tx,s);return e.jsx(kA,{scope:s,forceMount:n,children:m.Children.map(a,d=>e.jsx(gn,{present:n||l.open,children:e.jsx(Zc,{asChild:!0,container:o,children:d})}))})};R0.displayName=tx;var Xu="DialogOverlay",A0=m.forwardRef((t,s)=>{const n=_0(Xu,t.__scopeDialog),{forceMount:a=n.forceMount,...o}=t,l=Wr(Xu,t.__scopeDialog);return l.modal?e.jsx(gn,{present:a||l.open,children:e.jsx(TA,{...o,ref:s})}):null});A0.displayName=Xu;var PA=Bi("DialogOverlay.RemoveScroll"),TA=m.forwardRef((t,s)=>{const{__scopeDialog:n,...a}=t,o=Wr(Xu,n);return e.jsx(Wm,{as:PA,allowPinchZoom:!0,shards:[o.contentRef],children:e.jsx(at.div,{"data-state":nx(o.open),...a,ref:s,style:{pointerEvents:"auto",...a.style}})})}),Qi="DialogContent",I0=m.forwardRef((t,s)=>{const n=_0(Qi,t.__scopeDialog),{forceMount:a=n.forceMount,...o}=t,l=Wr(Qi,t.__scopeDialog);return e.jsx(gn,{present:a||l.open,children:l.modal?e.jsx(EA,{...o,ref:s}):e.jsx(_A,{...o,ref:s})})});I0.displayName=Qi;var EA=m.forwardRef((t,s)=>{const n=Wr(Qi,t.__scopeDialog),a=m.useRef(null),o=At(s,n.contentRef,a);return m.useEffect(()=>{const l=a.current;if(l)return Jg(l)},[]),e.jsx(D0,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ae(t.onCloseAutoFocus,l=>{l.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ae(t.onPointerDownOutside,l=>{const d=l.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0;(d.button===2||u)&&l.preventDefault()}),onFocusOutside:Ae(t.onFocusOutside,l=>l.preventDefault())})}),_A=m.forwardRef((t,s)=>{const n=Wr(Qi,t.__scopeDialog),a=m.useRef(!1),o=m.useRef(!1);return e.jsx(D0,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{t.onCloseAutoFocus?.(l),l.defaultPrevented||(a.current||n.triggerRef.current?.focus(),l.preventDefault()),a.current=!1,o.current=!1},onInteractOutside:l=>{t.onInteractOutside?.(l),l.defaultPrevented||(a.current=!0,l.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const d=l.target;n.triggerRef.current?.contains(d)&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&o.current&&l.preventDefault()}})}),D0=m.forwardRef((t,s)=>{const{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,...d}=t,u=Wr(Qi,n),h=m.useRef(null),f=At(s,h);return Xg(),e.jsxs(e.Fragment,{children:[e.jsx(Km,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:o,onUnmountAutoFocus:l,children:e.jsx(ul,{role:"dialog",id:u.contentId,"aria-describedby":u.descriptionId,"aria-labelledby":u.titleId,"data-state":nx(u.open),...d,ref:f,onDismiss:()=>u.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(AA,{titleId:u.titleId}),e.jsx(DA,{contentRef:h,descriptionId:u.descriptionId})]})]})}),sx="DialogTitle",O0=m.forwardRef((t,s)=>{const{__scopeDialog:n,...a}=t,o=Wr(sx,n);return e.jsx(at.h2,{id:o.titleId,...a,ref:s})});O0.displayName=sx;var M0="DialogDescription",L0=m.forwardRef((t,s)=>{const{__scopeDialog:n,...a}=t,o=Wr(M0,n);return e.jsx(at.p,{id:o.descriptionId,...a,ref:s})});L0.displayName=M0;var F0="DialogClose",$0=m.forwardRef((t,s)=>{const{__scopeDialog:n,...a}=t,o=Wr(F0,n);return e.jsx(at.button,{type:"button",...a,ref:s,onClick:Ae(t.onClick,()=>o.onOpenChange(!1))})});$0.displayName=F0;function nx(t){return t?"open":"closed"}var U0="DialogTitleWarning",[RA,z0]=m4(U0,{contentName:Qi,titleName:sx,docsSlug:"dialog"}),AA=({titleId:t})=>{const s=z0(U0),n=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users.
49
50If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component.
51
52For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return m.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},IA="DialogDescriptionWarning",DA=({contentRef:t,descriptionId:s})=>{const a=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${z0(IA).contentName}}.`;return m.useEffect(()=>{const o=t.current?.getAttribute("aria-describedby");s&&o&&(document.getElementById(s)||console.warn(a))},[a,t,s]),null},rx=P0,ax=E0,ix=R0,td=A0,sd=I0,nd=O0,rd=L0,Qm=$0;const B0=rx,OA=ax,MA=ix,V0=m.forwardRef(({className:t,...s},n)=>e.jsx(td,{className:Oe("fixed inset-0 z-50 bg-black/80  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:n}));V0.displayName=td.displayName;const LA=ml("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4  border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ox=m.forwardRef(({side:t="right",className:s,children:n,...a},o)=>e.jsxs(MA,{children:[e.jsx(V0,{}),e.jsxs(sd,{ref:o,className:Oe(LA({side:t}),s),...a,children:[n,e.jsxs(Qm,{className:"absolute right-4 top-4 roun
52ded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[e.jsx(Zn,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ox.displayName=sd.displayName;const lx=({className:t,...s})=>e.jsx("div",{className:Oe("flex flex-col space-y-2 text-center sm:text-left",t),...s});lx.displayName="SheetHeader";const cx=m.forwardRef(({className:t,...s},n)=>e.jsx(nd,{ref:n,className:Oe("text-lg font-semibold text-foreground",t),...s}));cx.displayName=nd.displayName;const q0=m.forwardRef(({className:t,...s},n)=>e.jsx(rd,{ref:n,className:Oe("text-sm text-muted-foreground",t),...s}));q0.displayName=rd.displayName;const St=rx,bs=ax,FA=ix,K0=m.forwardRef(({className:t,...s},n)=>e.jsx(td,{ref:n,className:Oe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));K0.displayName=td.displayName;const jt=m.forwardRef(({className:t,children:s,...n},a)=>e.jsxs(FA,{children:[e.jsx(K0,{}),e.jsxs(sd,{ref:a,className:Oe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[s,e.jsxs(Qm,{className:"absolute right-4 top-4 roun
52ded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(Zn,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));jt.displayName=sd.displayName;const wt=({className:t,...s})=>e.jsx("div",{className:Oe("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});wt.displayName="DialogHeader";const Vs=({className:t,...s})=>e.jsx("div",{className:Oe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Vs.displayName="DialogFooter";const bt=m.forwardRef(({className:t,...s},n)=>e.jsx(nd,{ref:n,className:Oe("text-lg font-semibold leading-none tracking-tight",t),...s}));bt.displayName=nd.displayName;const Gt=m.forwardRef(({className:t,...s},n)=>e.jsx(rd,{ref:n,className:Oe("text-sm text-muted-foreground",t),...s}));Gt.displayName=rd.displayName;const fe=m.forwardRef(({className:t,type:s,...n},a)=>e.jsx("input",{type:s,className:Oe("flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:a,...n}));fe.displayName="Input";const ss=m.forwardRef(({className:t,...s},n)=>e.jsx("textarea",{className:Oe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...s}));ss.displayName="Textarea";var $A="Label",H0=m.forwardRef((t,s)=>e.jsx(at.label,{...t,ref:s,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(t.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));H0.displayName=$A;var W0=H0;const UA=ml("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Z=m.forwardRef(({className:t,...s},n)=>e.jsx(W0,{ref:n,className:Oe(UA(),t),...s}));Z.displayName=W0.displayName;const zA="/assets/outliner_black_and_white_grainy_stars_and_data_points_flow_550_1767902965046-CMDGQ48S.png",BA="/assets/marshall-haas-tB8hEEt_.png",VA="/assets/benjamin-surman-DCPcZI3B.png",qA="/assets/image_4_1768335951357-Dwdqw5mL.png";function KA(){const[t,s]=m.useState(()=>{const h=sessionStorage.getItem("dismissed_announcements");return h?new Set(JSON.parse(h)):new Set}),n=m.useRef(null),{data:a=[],isLoading:o}=je({queryKey:["/api/public/announcements"]}),d=m.useMemo(()=>a.filter(h=>!t.has(h.id)),[a,t])[0];m.useEffect(()=>{d?.embedCode&&n.current&&(n.current.innerHTML=d.embedCode,n.current.querySelectorAll("script").forEach(f=>{const g=document.createElement("script");Array.from(f.attributes).forEach(x=>{g.setAttribute(x.name,x.value)}),g.textContent=f.textContent,f.parentNode?.replaceChild(g,f)}))},[d?.embedCode,d?.id]);const u=()=>{if(!d)return;const h=new Set(t).add(d.id);s(h),sessionStorage.setItem("dismissed_announcements",JSON.stringify(Array.from(h)))};return o||!d?null:e.jsx(St,{open:!!d,onOpenChange:()=>u(),children:e.jsxs(jt,{className:"max-w-2xl max-h-[90vh] overflow-hidden flex flex-col","data-testid":"dialog-homepage-announcement",children:[e.jsx(wt,{className:"flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(bt,{"data-testid":"text-announcement-title",children:d.title}),e.jsx(D,{variant:"ghost",size:"icon",onClick:u,"data-testid":"button-announcement-dismiss",children:e.jsx(Zn,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"flex-1 overflow-auto space-y-4",children:[d.message&&e.jsx("div",{className:"text-muted-foreground whitespace-pre-wrap","data-testid":"text-announcement-message",children:d.message}),d.embedCode&&e.jsx("div",{ref:n,className:"w-full min-h-[400px] rounded-lg overflow-hidden","data-testid":"container-announcement-embed"})]}),e.jsxs("div",{className:"flex-shrink-0 pt-4 border-t space-y-2",children:[d.buttonText&&d.buttonUrl&&e.jsx(D,{asChild:!0,className:"w-full","data-testid":"button-announcement-cta",children:e.jsx("a",{href:d.buttonUrl,target:"_blank",rel:"noopener noreferrer",children:d.buttonText})}),e.jsx(D,{onClick:u,variant:d.buttonText&&d.buttonUrl?"outline":"default",className:"w-full","data-testid":"button-announcement-got-it",children:d.buttonText&&d.buttonUrl?"Close"
52:"Got it"})]})]})})}const HA="/assets/AI_Assistant_Outliner_SOP_1769741681875-DuEdRdFm.gif",WA="/assets/SOP_Generation_Using_Screen_Recording_Outliner_SOP_1769741681875-MZnPOjYs.gif",QA="/assets/steps_1777475707525-Dpxj5Qi2.gif",GA="/assets/hierarchie_1777475841025-BriR_6Ij.gif",YA="/assets/hierarchie_1777475841025-BriR_6Ij.gif",ZA="/assets/version_1777476041705-D4J9x0JD.gif";function XA(){const{theme:t,setTheme:s}=h0(),n=m.useRef(null),[a,o]=m.useState(!1),[l,d]=m.useState(!1),[u,h]=m.useState({firstName:"",lastName:"",email:"",question:""}),[f,g]=m.useState(!1),{toast:x}=dt();m.useEffect(()=>(n.current=t,s("dark"),()=>{n.current&&n.current!=="dark"&&s(n.current)}),[]);const v=async w=>{if(w.preventDefault(),!u.firstName||!u.lastName||!u.email||!u.question){x({title:"Missing fields",description:"Please fill in all fields.",variant:"destructive"});return}g(!0);try{if(!(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)})).ok)throw new Error("Failed to send message");x({title:"Message sent",description:"Thank you for reaching out. We'll get back to you soon!"}),d(!1),h({firstName:"",lastName:"",email:"",question:""})}catch{x({title:"Error",description:"Failed to send your message. Please try again.",variant:"destructive"})}finally{g(!1)}};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"sticky top-0 z-50 w-full border-b border-border/50 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:e.jsxs("div",{className:"container mx-auto flex h-16 items-center justify-between gap-4 px-4 md:px-6",children:[e.jsx("span",{className:"font-serif font-medium tracking-tight cursor-pointer text-[46px]","data-testid":"link-logo",onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),children:"outliner"}),e.jsxs("nav",{className:"hidden md:flex items-center gap-6 font-mono uppercase tracking-wider",children:[e.jsx("a",{href:"#problem",className:"text-sm text-muted-foreground hover:text-foreground transition-colors","data-testid":"link-problem",children:"Problem"}),e.jsx("a",{href:"#story",className:"text-sm text-muted-foreground hover:text-foreground transition-colors","data-testid":"link-story",children:"Our Story"}),e.jsx("a",{href:"#solution",className:"text-sm text-muted-foreground hover:text-foreground transition-colors","data-testid":"link-solution",children:"Solution"}),e.jsx("a",{href:"#features",className:"text-sm text-muted-foreground hover:text-foreground transition-colors","data-testid":"link-features",children:"Features"}),e.jsx("a",{href:"#pricing",className:"text-sm text-muted-foreground hover:text-foreground transition-colors","data-testid":"link-pricing",children:"Pricing"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ht,{href:"/get-started?mode=login",className:"hidden md:block text-sm font-mono uppercase tracking-wider text-muted-foreground hover:text-foreground transition-colors","data-testid":"link-login",children:"Log In"}),e.jsxs(B0,{open:a,onOpenChange:o,children:[e.jsx(OA,{asChild:!0,className:"md:hidden",children:e.jsx(D,{variant:"ghost",size:"icon","data-testid":"button-mobile-menu",children:e.jsx(uE,{className:"h-5 w-5"})})}),e.jsxs(ox,{side:"right",className:"w-[280px]",children:[e.jsx(lx,{children:e.jsx(cx,{className:"font-serif text-xl",children:"Menu"})}),e.jsxs("nav",{className:"flex flex-col gap-4 mt-6 font-mono uppercase tracking-wider",children:[e.jsx("a",{href:"#problem",className:"text-sm text-muted-foreground hover:text-foreground transition-colors py-2",onClick:()=>o(!1),"data-testid":"mobile-link-problem",children:"Problem"}),e.jsx("a",{href:"#story",className:"text-sm text-muted-foreground hover:text-foreground transition-colors py-2",onClick:()=>o(!1),"data-testid":"mobile-link-story",children:"Our Story"}),e.jsx("a",{href:"#solution",className:"text-sm text-muted-foreground hover:text-foreground transition-colors py-2",onClick:()=>o(!1),"data-testid":"mobile-link-solution",children:"Solution"}),e.jsx("a",{href:"#features",className:"text-sm text-muted-foreground hover:text-foreground transition-colors py-2",onClick:()=>o(!1),"data-testid":"mobile-link-features",children:"Features"}),e.jsx("a",{href:"#pricing",className:"text-sm text-muted-foreground hover:text-foreground transition-colors py-2",onClick:()=>o(!1),"data-testid":"mobile-link-pricing",children:"Pricing"}),e.jsx("div",{className:"border-t border-border my-2"}),e.jsx(ht,{href:"/get-started?mode=login",className:"text-sm text-muted-foreground hover:text-foreground transition-colors py-2",onClick:()=>o(!1),"data-testid":"mobile-link-login",children:"Log In"})]})]})]})]})]})}),e.jsxs("section",{className:"relative overflow-hidden",style:{backgroundColor:"#100D0F",backgroundImage:`url(${zA})`,backgroundSize:"60%",backgroundPosition:"right center",backgroundRepeat:"no-repeat"},children:[e.jsx("div",{className:"absolute inset-0",style:{background:`
53              linear-gradient(to right, #100D0F 0%, #100D0F 30%, rgba(16,13,15,0.9) 45%, rgba(16,13,15,0.5) 65%, transparent 100%),
54              linear-gradient(to top, #100D0F 0%, rgba(16,13,15,0.8) 15%, rgba(16,13,15,0.3) 35%, transparent 60%),
55              radial-gradient(ellipse 80% 60% at 85% 50%, transparent 0%, rgba(16,13,15,0.4) 50%, #100D0F 100%)
56            `}}),e.jsx("div",{className:"container relative mx-auto px-4 md:px-6 py-24 md:py-36 pt-[80px] pb-[80px]",children:e.jsxs("div",{className:"max-w-2xl space-y-8",children:[e.jsxs("h1",{className:"font-serif text-4xl md:text-5xl lg:text-6xl xl:text-[72px] font-normal tracking-tight text-white",children:["Document It Once.",e.jsx("br",{}),e.jsx("span",{className:"text-white",children:"Never Explain It Again."})]}),e.jsx("p",{className:"md:text-xl max-w-xl text-[18px] text-[#fffff9]",children:"Document any process in minutes, not hours. Hit record and Outliner writes it for you. Step by step, ready to hand off. Stop being the bottleneck and start scaling what you know."})]})})]}),e.jsx("section",{id:"problem",className:"py-20 md:py-28 pt-[60px] pb-[60px] bg-[#100D0F]",children:e.jsxs("div",{className:"container mx-auto px-4 md:px-6",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsx(Ce,{className:"mb-4 py-2 text-sm font-mono uppercase tracking-wider rounded-none border-l border-l-[#B24884]",
56style:{backgroundColor:"#312D30",color:"#EEEEE3"},children:"The Problem"}),e.jsx("h2",{className:"font-serif text-[42px] font-normal tracking-tight mb-6",children:"Does this sound familiar?"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"You've built a successful business, but scaling feels impossible because everything lives in people's heads."})]}),e.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-4 gap-6",children:[{icon:Vi,title:"Knowledge Walks Out the Door",description:"When employees leave, critical processes go with them. Onboarding new hires takes months."},{icon:Lm,title:"Inconsistent Execution",description:"Different team members do the same task differently. Quality varies wildly."},{icon:Bs,title:"You're the Bottleneck",description:"Every question comes to you. You can't step away without things falling apart."},{icon:gE,title:"Scaling Feels Impossible",description:"Growth is crippled by lack of documented processes. New hires struggle to ramp up."}].map((w,C)=>e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-6 space-y-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(w.icon,{className:"w-5 h-5 text-primary"})}),e.jsx("h3",{className:"font-medium text-lg",children:w.title}),e.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:w.description})]})},C))})]})}),e.jsxs("section",{id:"story",className:"relative py-20 md:py-28 pt-[60px] pb-[60px]",style:{backgroundImage:`url(${qA})`,backgroundSize:"cover",backgroundPosition:"center"},children:[e.jsx("div",{className:"absolute inset-0",style:{backgroundColor:"rgba(16,13,15,0.6)"}}),e.jsxs("div",{className:"container relative mx-auto px-4 md:px-6",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mt-[45px] mb-[45px]",children:[e.jsx(Ce,{className:"mb-4 py-2 text-sm font-mono uppercase tracking-wider rounded-none border-l border-l-[#B24884]",style:{backgroundColor:"#312D30",color:"#EEEEE3"},children:"Our Story"}),e.jsx("h2",{className:"font-serif text-[42px] font-normal tracking-tight mb-6",children:"It doesn't have to be that way."}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"What if everything just worked like a well oiled machine?"})]}),e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-8 md:p-12 space-y-8 pt-[45px] pb-[45px] pl-[45px] pr-[45px]",children:[e.jsx("div",{className:"space-y-1",children:e.jsx(Ce,{className:"text-sm py-2 font-mono uppercase tracking-wider rounded-none border-l border-l-[#B24884]",style:{backgroundColor:"#312D30",color:"#EEEEE3"},children:"Letter from Marshall"})}),e.jsxs("div",{className:"space-y-6 text-muted-foreground leading-relaxed",children:[e.jsx("p",{children:"I'm Marshall Haas, co-founder of Outliner."}),e.jsx("p",{children:"Before this, I was the founder & CEO of Somewhere.com (formerly Shepherd). I bootstrapped that business to a $52M exit in 2024—from founding to sale in just four years."}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"font-medium text-foreground",children:"Some stats that might surprise you:"}),e.jsxs("ul",{className:"space-y-2 list-disc list-inside",children:[e.jsx("li",{children:"I only worked 778 hours in total on the business over those four years, thanks to delegation and automation."}),e.jsx("li",{children:"Our team was 150+ people"}),e.jsx("li",{children:"We distributed 8-figures in profits to owners before the acquisition."}),e.jsx("li",{children:"And I did all of this while still being a family man—my son was born in year one, my daughter in year three."})]})]}),e.jsx("p",{children:"These results weren't by accident. Ben Surman was my COO  and the mastermind behind our systems. Our success came from well optimized systems that were written and delegated to a great team. Everyone knew exactly what to do. "}),e.jsx("p",{className:"font-medium text-foreground",children:"You built your company. Now document the systems that free you from it."})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-8 pt-8 border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("img",{src:BA,alt:"Marshall Haas",className:"w-20 h-20 rounded-full object-cover border-2 border-border","data-testid":"img-marshall"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-lg",children:"Marshall Haas"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Co-founder"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("img",{src:VA,alt:"Ben Surman",className:"w-20 h-20 rounded-full object-cover border-2 border-border","data-testid":"img-benjamin"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-lg",children:"Ben Surman"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Co-founder"})]})]})]})]})})})]})]}),e.jsx("section",{id:"solution",className:"py-20 md:py-28 pt-[60px] pb-[60px] bg-[#100D0F]",children:e.jsxs("div",{className:"container mx-auto px-4 md:px-6",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsx(Ce,{className:"mb-4 py-2 text-sm font-mono uppercase tracking-wider rounded-none border-l border-l-[#B24884]",
56style:{backgroundColor:"#312D30",color:"#EEEEE3"},children:"The Solution"}),e.jsx("h2",{className:"font-serif text-[42px] font-normal tracking-tight mb-6",children:"Operations documented and systematized."}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Transform messy operations into a well-oiled machine."})]}),e.jsx("div",{className:"grid lg:grid-cols-3 gap-8",children:[{icon:gs,badge:"AI-Powered",title:"Smart Documentation",description:"Our AI drafts procedures from your rough notes, screen recordings, and interviews. You review and refine.",features:["Auto-generate from recordings","Consistent formatting","Version control"]},{icon:cs,badge:"Knowledge Base",title:"Hosted For You",description:"Your procedures live in a searchable, branded knowledge base your team will actually use.",features:["Custom branding","Full-text search","Mobile-friendly"]}].map((w,C)=>e.jsx(ee,{className:"border-border/50 overflow-hidden",children:e.jsxs(te,{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(w.icon,{className:"w-5 h-5 text-primary"})}),e.jsx(Ce,{className:"text-sm py-2 font-mono uppercase tracking-wider rounded-none border-l border-l-[#B24884]",style:{backgroundColor:"#312D30",color:"#EEEEE3"},children:w.badge})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"font-medium text-xl",children:w.title}),e.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:w.description})]}),e.jsx("ul",{className:"space-y-2",children:w.features.map((j,b)=>e.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Sr,{className:"w-4 h-4 text-primary flex-shrink-0"}),e.jsx("span",{children:j})]},b))})]})},C))})]})}),e.jsx("section",{id:"features",className:"py-20 md:py-28 bg-[#100D0F]",children:e.jsxs("div",{className:"container mx-auto px-4 md:px-6",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsx(Ce,{className:"mb-4 py-2 text-sm font-mono uppercase tracking-wider rounded-none border-l border-l-[#B24884]",style:{backgroundColor:"#312D30",color:"#EEEEE3"},children:"Features"}),e.jsx("h2",{className:"font-serif text-[42px] font-normal tracking-tight mb-6",children:"Everything to document & scale your operations."})]}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-6",children:[{icon:Pt,title:"Step-by-Step Procedures",description:"Break down complex processes into clear, actionable steps with images and videos.",media:{type:"gif",src:QA}},{icon:lr,title:"Screen Recording",description:"Capture procedures with built-in screen recording that auto-generates documentation.",media:{type:"gif",src:WA}},{icon:Pa,title:"Process Hierarchies",description:"Organize procedures into categories and link related processes together.",media:{type:"gif",src:GA}},{icon:Mm,title:"Powerful Search",description:"Find any procedure instantly with full-text search across your entire knowledge base.",media:{type:"gif",src:YA}},{icon:Ag,title:"Version Control",description:"Track changes, restore previous versions, and see who updated what and when.",media:{type:"gif",src:ZA}},{icon:Wu,title:"AI Assistant",description:"Get help writing, improving, and organizing your procedures with AI.",media:{type:"gif",src:HA}}].map((w,C)=>e.jsxs(ee,{className:"border-border/50 overflow-hidden","data-testid":`card-feature-${C}`,children:[e.jsx("div",{className:"w-full aspect-video bg-black/30 overflow-hidden",children:e.jsx("img",{src:w.media.src,alt:w.title,loading:"lazy",className:"w-full h-full object-cover","data-testid":`img-feature-${C}`})}),e.jsxs(te,{className:"p-6 space-y-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(w.icon,{className:"w-5 h-5 text-primary"})}),e.jsx("h3",{className:"font-medium",children:w.title}),e.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:w.description})]})]},C))})]})}),e.jsx("section",{id:"pricing",className:"py-20 md:py-28",children:e.jsxs("div",{className:"container mx-auto px-4 md:px-6",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsx(Ce,{className:"mb-4 py-2 text-sm font-mono uppercase tracking-wider rounded-none border-l border-l-[#B24884]",
56style:{backgroundColor:"#312D30",color:"#EEEEE3"},children:"Pricing"}),e.jsx("h2",{className:"font-serif text-[42px] font-normal tracking-tight mb-6",children:"Pricing"})]}),e.jsx("div",{className:"max-w-2xl mx-auto",children:e.jsx(ee,{className:"border-border/50","data-testid":"card-pricing-closed",children:e.jsxs(te,{className:"p-10 space-y-4 text-center",children:[e.jsx("h3",{className:"font-serif text-2xl md:text-3xl font-normal tracking-tight",children:"No longer accepting new registrations"}),e.jsx("p",{className:"text-muted-foreground text-base leading-relaxed",children:"Outliner is winding down and we are no longer onboarding new customers. Existing customers can continue to log in and access their knowledge bases."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Questions?"," ",e.jsx("button",{onClick:()=>d(!0),className:"text-primary hover:underline","data-testid":"link-pricing-contact",children:"Contact us"}),"."]})]})})})]})}),e.jsx("footer",{className:"py-12 border-t border-border",children:e.jsx("div",{className:"container mx-auto px-4 md:px-6",children:e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[e.jsxs("nav",{className:"flex flex-wrap items-center justify-center gap-x-6 gap-y-2 text-sm text-muted-foreground font-mono uppercase tracking-wider",children:[e.jsx("a",{href:"#problem",className:"hover:text-foreground transition-colors","data-testid":"link-footer-problem",children:"Problem"}),e.jsx("a",{href:"#story",className:"hover:text-foreground transition-colors","data-testid":"link-footer-story",children:"Our Story"}),e.jsx("a",{href:"#solution",className:"hover:text-foreground transition-colors","data-testid":"link-footer-solution",children:"Solution"}),e.jsx(ht,{href:"/terms",className:"hover:text-foreground transition-colors","data-testid":"link-footer-terms",children:"Terms"}),e.jsx(ht,{href:"/privacy",className:"hover:text-foreground transition-colors","data-testid":"link-footer-privacy",children:"Privacy"}),e.jsx("button",{onClick:()=>d(!0),className:"hover:text-foreground transition-colors","data-testid":"link-footer-contact",children:"CONTACT"})]}),e.jsx("div",{className:"text-sm text-muted-foreground font-mono uppercase tracking-wider text-center",children:e.jsxs("span",{children:["outliner 2025 - ",new Date().getFullYear()," All Rights Reserved"]})})]})})}),e.jsx(KA,{}),e.jsx(St,{open:l,onOpenChange:d,children:e.jsxs(jt,{className:"sm:max-w-[425px]","data-testid":"dialog-contact",children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Contact Us"}),e.jsx(Gt,{children:"Have a question? We'd love to hear from you. Send us a message and we'll respond as soon as possible."})]}),e.jsxs("form",{onSubmit:v,className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"firstName",children:"First Name"}),e.jsx(fe,{id:"firstName",placeholder:"John",value:u.firstName,onChange:w=>h(C=>({...C,firstName:w.target.value})),"data-testid":"input-contact-firstname"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"lastName",children:"Last Name"}),e.jsx(fe,{id:"lastName",placeholder:"Doe",value:u.lastName,onChange:w=>h(C=>({...C,lastName:w.target.value})),"data-testid":"input-contact-lastname"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"contactEmail",children:"Email Address"}),e.jsx(fe,{id:"contactEmail",type:"email",placeholder:"[email protected]",value:u.email,onChange:w=>h(C=>({...C,email:w.target.value})),"data-testid":"input-contact-email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"question",children:"Your Question"}),e.jsx(ss,{id:"question",placeholder:"How can we help you?",rows:4,value:u.question,onChange:w=>h(C=>({...C,question:w.target.value})),"data-testid":"input-contact-question"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx(D,{type:"button",variant:"outline",onClick:()=>d(!1),"data-testid":"button-contact-cancel",children:"Cancel"}),e.jsx(D,{type:"submit",disabled:f,style:{backgroundColor:"#B24884",color:"#FFFFF9"}
vendor: 10,254 bytes, line 56
56,"data-testid":"button-contact-submit",children:f?"Sending...":"Send Message"})]})]})]})})]})}function be({className:t,...s}){return e.jsx("div",{className:Oe("animate-pulse rounded-md bg-muted",t),...s})}var JA=m.createContext(void 0);function ad(t){const s=m.useContext(JA);return t||s||"ltr"}function Wp(t,[s,n]){return Math.min(n,Math.max(s,t))}function eI(t,s){return m.useReducer((n,a)=>s[n][a]??n,t)}var dx="ScrollArea",[Q0]=En(dx),[tI,Cr]=Q0(dx),G0=m.forwardRef((t,s)=>{const{__scopeScrollArea:n,type:a="hover",dir:o,scrollHideDelay:l=600,...d}=t,[u,h]=m.useState(null),[f,g]=m.useState(null),[x,v]=m.useState(null),[w,C]=m.useState(null),[j,b]=m.useState(null),[k,N]=m.useState(0),[T,P]=m.useState(0),[I,O]=m.useState(!1),[R,F]=m.useState(!1),M=At(s,H=>h(H)),z=ad(o);return e.jsx(tI,{scope:n,type:a,dir:z,scrollHideDelay:l,scrollArea:u,viewport:f,onViewportChange:g,content:x,onContentChange:v,scrollbarX:w,onScrollbarXChange:C,scrollbarXEnabled:I,onScrollbarXEnabledChange:O,scrollbarY:j,onScrollbarYChange:b,scrollbarYEnabled:R,onScrollbarYEnabledChange:F,onCornerWidthChange:N,onCornerHeightChange:P,children:e.jsx(at.div,{dir:z,...d,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":k+"px","--radix-scroll-area-corner-height":T+"px",...t.style}})})});G0.displayName=dx;var Y0="ScrollAreaViewport",Z0=m.forwardRef((t,s)=>{const{__scopeScrollArea:n,children:a,nonce:o,...l}=t,d=Cr(Y0,n),u=m.useRef(null),h=At(s,u,d.onViewportChange);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),e.jsx(at.div,{"data-radix-scroll-area-viewport":"",...l,ref:h,style:{overflowX:d.scrollbarXEnabled?"scroll":"hidden",overflowY:d.scrollbarYEnabled?"scroll":"hidden",...t.style},children:e.jsx("div",{ref:d.onContentChange,style:{minWidth:"100%",display:"table"},children:a})})]})});Z0.displayName=Y0;var ma="ScrollAreaScrollbar",ux=m.forwardRef((t,s)=>{const{forceMount:n,...a}=t,o=Cr(ma,t.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:d}=o,u=t.orientation==="horizontal";return m.useEffect(()=>(u?l(!0):d(!0),()=>{u?l(!1):d(!1)}),[u,l,d]),o.type==="hover"?e.jsx(sI,{...a,ref:s,forceMount:n}):o.type==="scroll"?e.jsx(nI,{...a,ref:s,forceMount:n}):o.type==="auto"?e.jsx(X0,{...a,ref:s,forceMount:n}):o.type==="always"?e.jsx(mx,{...a,ref:s}):null});ux.displayName=ma;var sI=m.forwardRef((t,s)=>{const{forceMount:n,...a}=t,o=Cr(ma,t.__scopeScrollArea),[l,d]=m.useState(!1);return m.useEffect(()=>{const u=o.scrollArea;let h=0;if(u){const f=()=>{window.clearTimeout(h),d(!0)},g=()=>{h=window.setTimeout(()=>d(!1),o.scrollHideDelay)};return u.addEventListener("pointerenter",f),u.addEventListener("pointerleave",g),()=>{window.clearTimeout(h),u.removeEventListener("pointerenter",f),u.removeEventListener("pointerleave",g)}}},[o.scrollArea,o.scrollHideDelay]),e.jsx(gn,{present:n||l,children:e.jsx(X0,{"data-state":l?"visible":"hidden",...a,ref:s})})}),nI=m.forwardRef((t,s)=>{const{forceMount:n,...a}=t,o=Cr(ma,t.__scopeScrollArea),l=t.orientation==="horizontal",d=Ym(()=>h("SCROLL_END"),100),[u,h]=eI("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(u==="idle"){const f=window.setTimeout(()=>h("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(f)}},[u,o.scrollHideDelay,h]),m.useEffect(()=>{const f=o.viewport,g=l?"scrollLeft":"scrollTop";if(f){let x=f[g];const v=()=>{const w=f[g];x!==w&&(h("SCROLL"),d()),x=w};return f.addEventListener("scroll",v),()=>f.removeEventListener("scroll",v)}},[o.viewport,l,h,d]),e.jsx(gn,{present:n||u!=="hidden",children:e.jsx(mx,{"data-state":u==="hidden"?"hidden":"visible",...a,ref:s,onPointerEnter:Ae(t.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:Ae(t.onPointerLeave,()=>h("POINTER_LEAVE"))})})}),X0=m.forwardRef((t,s)=>{const n=Cr(ma,t.__scopeScrollArea),{forceMount:a,...o}=t,[l,d]=m.useState(!1),u=t.orientation==="horizontal",h=Ym(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,g=n.viewport.offsetHeight<n.viewport.scrollHeight;d(u?f:g)}},10);return nl(n.viewport,h),nl(n.content,h),e.jsx(gn,{present:a||l,children:e.jsx(mx,{"data-state":l?"visible":"hidden",...o,ref:s})})}),mx=m.forwardRef((t,s)=>{const{orientation:n="vertical",...a}=t,o=Cr(ma,t.__scopeScrollArea),l=m.useRef(null),d=m.useRef(0),[u,h]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=nS(u.viewport,u.content),g={...a,sizes:u,onSizesChange:h,hasThumb:f>0&&f<1,onThumbChange:v=>l.current=v,onThumbPointerUp:()=>d.current=0,onThumbPointerDown:v=>d.current=v};function x(v,w){return cI(v,d.current,u,w)}return n==="horizontal"?e.jsx(rI,{...g,ref:s,onThumbPositionChange:()=>{if(o.viewport&&l.current){const v=o.viewport.scrollLeft,w=Nw(v,u,o.dir);l.current.style.transform=`translate3d(${w}px, 0, 0)`}},onWheelScroll:v=>{o.viewport&&(o.viewport.scrollLeft=v)},onDragScroll:v=>{o.viewport&&(o.viewport.scrollLeft=x(v,o.dir))}}):n==="vertical"?e.jsx(aI,{...g,ref:s,onThumbPositionChange:()=>{if(o.viewport&&l.current){const v=o.viewport.scrollTop,w=Nw(v,u);l.current.style.transform=`translate3d(0, ${w}px, 0)`}},onWheelScroll:v=>{o.viewport&&(o.viewport.scrollTop=v)},onDragScroll:v=>{o.viewport&&(o.viewport.scrollTop=x(v))}}):null}),rI=m.forwardRef((t,s)=>{const{sizes:n,onSizesChange:a,...o}=t,l=Cr(ma,t.__scopeScrollArea),[d,u]=m.useState(),h=m.useRef(null),f=At(s,h,l.onScrollbarXChange);return m.useEffect(()=>{h.current&&u(getComputedStyle(h.current))},[h]),e.jsx(eS,{"data-orientation":"horizontal",...o,ref:f,sizes:n,style:{bottom:0,left:l.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:l.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Gm(n)+"px",...t.style},onThumbPointerDown:g=>t.onThumbPointerDown(g.x),onDragScroll:g=>t.onDragScroll(g.x),onWheelScroll:(g,x)=>{if(l.viewport){const v=l.viewport.scrollLeft+g.deltaX;t.onWheelScroll(v),aS(v,x)&&g.preventDefault()}},onResize:()=>{h.current&&l.viewport&&d&&a({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:h.current.clientWidth,paddingStart:em(d.paddingLeft),paddingEnd:em(d.paddingRight)}})}})}),aI=m.forwardRef((t,s)=>{const{sizes:n,onSizesChange:a,...o}=t,l=Cr(ma,t.__scopeScrollArea),[d,u]=m.useState(),h=m.useRef(null),f=At(s,h,l.onScrollbarYChange);return m.useEffect(()=>{h.current&&u(getComputedStyle(h.current))},[h]),e.jsx(eS,{"data-orientation":"vertical",...o,ref:f,sizes:n,style:{top:0,right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Gm(n)+"px",...t.style},onThumbPointerDown:g=>t.onThumbPointerDown(g.y),onDragScroll:g=>t.onDragScroll(g.y),onWheelScroll:(g,x)=>{if(l.viewport){const v=l.viewport.scrollTop+g.deltaY;t.onWheelScroll(v),aS(v,x)&&g.preventDefault()}},onResize:()=>{h.current&&l.viewport&&d&&a({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:h.current.clientHeight,paddingStart:em(d.paddingTop),paddingEnd:em(d.paddingBottom)}})}})}),[iI,J0]=Q0(ma),eS=m.forwardRef((t,s)=>{const{__scopeScrollArea:n,sizes:a,hasThumb:o,onThumbChange:l,onThumbPointerUp:d,onThumbPointerDown:u,onThumbPositionChange:h,onDragScroll:f,onWheelScroll:g,onResize:x,...v}=t,w=Cr(ma,n),[C,j]=m.useState(null),b=At(s,M=>j(M)),k=m.useRef(null),N=m.useRef(""),T=w.viewport,P=a.content-a.viewport,I=Rs(g),O=Rs(h),R=Ym(x,10);function F(M){if(k.current){const z=M.clientX-k.current.left,H=M.clientY-k.current.top;f({x:z,y:H})}}return m.useEffect(()=>{const M=z=>{const H=z.target;C?.contains(H)&&I(z,P)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[T,C,P,I]),m.useEffect(O,[a,O]),nl(C,R),nl(w.content,R),e.jsx(iI,{scope:n,scrollbar:C,hasThumb:o,onThumbChange:Rs(l),onThumbPointerUp:Rs(d),onThumbPositionChange:O,onThumbPointerDown:Rs(u),children:e.jsx(at.div,{...v,ref:b,style:{position:"absolute",...v.style},onPointerDown:Ae(t.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),k.current=C.getBoundingClientRect(),N.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",w.viewport&&(w.viewport.style.scrollBehavior="auto"),F(M))}),onPointerMove:Ae(t.onPointerMove,F),onPointerUp:Ae(t.onPointerUp,M=>{const z=M.target;z.hasPointerCapture(M.pointerId)&&z.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=N.current,w.viewport&&(w.viewport.style.scrollBehavior=""),k.current=null})})})}),Ju="ScrollAreaThumb",tS=m.forwardRef((t,s)=>{const{forceMount:n,...a}=t,o=J0(Ju,t.__scopeScrollArea);return e.jsx(gn,{present:n||o.hasThumb,children:e.jsx(oI,{ref:s,...a})})}),oI=m.forwardRef((t,s)=>{const{__scopeScrollArea:n,style:a,...o}=t,l=Cr(Ju,n),d=J0(Ju,n),{onThumbPositionChange:u}=d,h=At(s,x=>d.onThumbChange(x)),f=m.useRef(void 0),g=Ym(()=>{f.current&&(f.current(),f.current=void 0)},100);return m.useEffect(()=>{const x=l.viewport;if(x){const v=()=>{if(g(),!f.current){const w=dI(x,u);f.current=w,u()}};return u(),x.addEventListener("scroll",v),()=>x.removeEventListener("scroll",v)}},[l.viewport,g,u]),e.jsx(at.div,{"data-state":d.hasThumb?"visible":"hidden",...o,ref:h,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...a},onPointerDownCapture:Ae(t.onPointerDownCapture,x=>{const w=x.target.getBoundingClientRect(),C=x.clientX-w.left,j=x.clientY-w.top;d.onThumbPointerDown({x:C,y:j})}),onPointerUp:Ae(t.onPointerUp,d.onThumbPointerUp)})});tS.displayName=Ju;var hx="ScrollAreaCorner",sS=m.forwardRef((t,s)=>{const n=Cr(hx,t.__scopeScrollArea),a=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&a?e.jsx(lI,{...t,ref:s}):null});sS.displayName=hx;var lI=m.forwardRef((t,s)=>{const{__scopeScrollArea:n,...a}=t,o=Cr(hx,n),[l,d]=m.useState(0),[u,h]=m.useState(0),f=!!(l&&u);return nl(o.scrollbarX,()=>{const g=o.scrollbarX?.offsetHeight||0;
56o.onCornerHeightChange(g),h(g)}),nl(o.scrollbarY,()=>{const g=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(g),d(g)}),f?e.jsx(at.div,{...a,ref:s,style:{width:l,height:u,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function em(t){return t?parseInt(t,10):0}function nS(t,s){const n=t/s;return isNaN(n)?0:n}function Gm(t){const s=nS(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=(t.scrollbar.size-n)*s;return Math.max(a,18)}function cI(t,s,n,a="ltr"){const o=Gm(n),l=o/2,d=s||l,u=o-d,h=n.scrollbar.paddingStart+d,f=n.scrollbar.size-n.scrollbar.paddingEnd-u,g=n.content-n.viewport,x=a==="ltr"?[0,g]:[g*-1,0];return rS([h,f],x)(t)}function Nw(t,s,n="ltr"){const a=Gm(s),o=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,l=s.scrollbar.size-o,d=s.content-s.viewport,u=l-a,h=n==="ltr"?[0,d]:[d*-1,0],f=Wp(t,h);return rS([0,d],[0,u])(f)}function rS(t,s){return n=>{if(t[0]===t[1]||s[0]===s[1])return s[0];const a=(s[1]-s[0])/(t[1]-t[0]);return s[0]+a*(n-t[0])}}function aS(t,s){return t>0&&t<s}var dI=(t,s=()=>{})=>{let n={left:t.scrollLeft,top:t.scrollTop},a=0;return(function o(){const l={left:t.scrollLeft,top:t.scrollTop},d=n.left!==l.left,u=n.top!==l.top;(d||u)&&s(),n=l,a=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(a)};function Ym(t,s){const n=Rs(t),a=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(a.current),[]),m.useCallback(()=>{window.clearTimeout(a.current),a.current=window.setTimeout(n,s)},[n,s])}function nl(t,s){const n=Rs(s);cn(()=>{let a=0;if(t){const o=new ResizeObserver(()=>{cancelAnimationFrame(a),a=window.requestAnimationFrame(n)});return o.observe(t),()=>{window.cancelAnimationFrame(a),o.unobserve(t)}}},[t,n])}var iS=G0,uI=Z0,mI=sS;const jl=m.forwardRef(({className:t,children:s,...n},a)=>e.jsxs(iS,{ref:a,className:Oe("relative overflow-hidden",t),...n,children:[e.jsx(uI,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(oS,{}),e.jsx(mI,{})]}));jl.displayName=iS.displayName;const oS=m.forwardRef(({className:t,orientation:s="vertical",...n},a)=>e.jsx(ux,{ref:a,orientation:s,className:Oe("flex touch-none select-none transition-colors",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...n,children:e.jsx(tS,{className:"relative flex-1 rounded-full bg-border"})}));oS.displayName=ux.displayName;function Ra(){const{theme:t,setTheme:s}=h0();return e.jsxs(D,{variant:"ghost",size:"icon",onClick:()=>s(t==="light"?"dark":"light"),"data-testid":"button-theme-toggle",children:[e.jsx(SN,{className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(NN,{className:"absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}function rl({src:t,className:s="","data-testid":n}){return e.jsx("video",{src:t,controls:!0,playsInline:!0,preload:"metadata",className:s,"data-testid":n,children:"Your browser does not support the video tag."})}const Sw="analytics_session_id";function hI(){let t=sessionStorage.getItem(Sw);return t||(t=crypto.randomUUID(),sessionStorage.setItem(Sw,t)),t}function fI(t){const s=m.useRef(new Set);m.useEffect(()=>{!t||s.current.has(t)||(s.current.add(t),ce("POST","/api/portal/analytics/view",{procedureId:t,sessionId:hI()}).catch(()=>{}))},[t])}var fx="Collapsible",[pI]=En(fx),[gI,px]=pI(fx),lS=m.forwardRef((t,s)=>{const{__scopeCollapsible:n,open:a,defaultOpen:o,disabled:l,onOpenChange:d,...u}=t,[h=!1,f]=Ur({prop:a,defaultProp:o,onChange:d});return e.jsx(gI,{scope:n,disabled:l,contentId:jr(),open:h,onOpenToggle:m.useCallback(()=>f(g=>!g),[f]),children:e.jsx(at.div,{"data-state":xx(h),"data-disabled":l?"":void 0,...u,ref:s})})});lS.displayName=fx;var cS="CollapsibleTrigger",dS=m.forwardRef((t,s)=>{const{__scopeCollapsible:n,...a}=t,o=px(cS,n);return e.jsx(at.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":xx(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...a,ref:s,onClick:Ae(t.onClick,o.onOpenToggle)})});dS.displayName=cS;var gx="CollapsibleContent",uS=m.forwardRef((t,s)=>{const{forceMount:n,...a}=t,o=px(gx,t.__scopeCollapsible);return e.jsx(gn,{present:n||o.open,children:({present:l})=>e.jsx(xI,{...a,ref:s,present:l})})});uS.displayName=gx;var xI=m.forwardRef((t,s)=>{const{__scopeCollapsible:n,present:a,children:o,...l}
56=t,d=px(gx,n),[u,h]=m.useState(a),f=m.useRef(null),g=At(s,f),x=m.useRef(0),v=x.current,w=m.useRef(0),C=w.current,j=d.open||u,b=m.useRef(j),k=m.useRef(void 0);return m.useEffect(()=>{const N=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(N)},[]),cn(()=>{const N=f.current;if(N){k.current=k.current||{transitionDuration:N.style.transitionDuration,animationName:N.style.animationName},N.style.transitionDuration="0s",N.style.animationName="none";const T=N.getBoundingClientRect();x.current=T.height,w.current=T.width,b.current||(N.style.transitionDuration=k.current.transitionDuration,N.style.animationName=k.current.animationName),h(a)}},[d.open,a]),e.jsx(at.div,{"data-state":xx(d.open),"data-disabled":d.disabled?"":void 0,id:d.contentId,hidden:!j,...l,ref:g,style:{"--radix-collapsible-content-height":v?`${v}px`:void 0,"--radix-collapsible-content-width":C?`${C}px`:void 0,...t.style},children:j&&o})});function xx(t){return t?"open":"closed"}var vI=lS;const Cn=vI,Mn=dS,Ln=uS;function yI({procedureId:t,compact:s=!1}){const[n,a]=m.useState(null),[o,l]=m.useState(!1),[d,u]=m.useState(""),{toast:h}=dt(),f=Sg(),g=ye({mutationFn:async({feedbackType:v,comment:w})=>(await ce("POST","/api/portal/analytics/feedback",{procedureId:t,feedbackType:v,comment:w})).json(),onSuccess:(v,w)=>{a(w.feedbackType),l(!1),u(""),f.invalidateQueries({queryKey:["/api/portal/analytics/content-views"]})},onError:v=>{v.message?.includes("409")||v.message?.includes("already submitted")?(h({title:"You've already provided feedback for this content",variant:"default"}),a("helpful")):h({title:"Failed to submit feedback",variant:"destructive"})}}),x=v=>{if(v==="not_helpful"&&!o){l(!0);return}g.mutate({feedbackType:v,comment:d||void 0})};return n?e.jsxs("div",{className:`flex items-center gap-2 text-muted-foreground ${s?"text-sm":""}`,"data-testid":"feedback-submitted",children:[e.jsx(yr,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{children:"Thanks for your feedback!"})]}):s?e.jsxs("div",{className:"flex items-center gap-3","data-testid":"feedback-widget-compact",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Was this helpful?"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(D,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>x("helpful"),disabled:g.isPending,"data-testid":"button-helpful",children:e.jsx(Tc,{className:"h-4 w-4"})}),e.jsx(D,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>x("not_helpful"),disabled:g.isPending,"data-testid":"button-not-helpful",children:e.jsx(Hu,{className:"h-4 w-4"})})]}),o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ss,{value:d,onChange:v=>u(v.target.value),placeholder:"How can we improve?",className:"h-8 min-h-8 text-sm resize-none","data-testid":"input-feedback-comment"}),e.jsx(D,{size:"sm",onClick:()=>g.mutate({feedbackType:"not_helpful",comment:d}),disabled:g.isPending,"data-testid":"button-submit-feedback",children:"Send"})]})]}):e.jsx(ee,{className:"mt-6","data-testid":"feedback-widget",children:e.jsx(te,{className:"py-8 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("p",{className:"text-center font-medium",children:"Was this helpful?"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(D,{variant:"outline",onClick:()=>x("helpful"),disabled:g.isPending,className:"gap-2","data-testid":"button-helpful",children:[e.jsx(Tc,{className:"h-4 w-4"}),"Yes"]}),e.jsx(Cn,{open:o,onOpenChange:l,children:e.jsx(Mn,{asChild:!0,children:e.jsxs(D,{variant:"outline",disabled:g.isPending,className:"gap-2","data-testid":"button-not-helpful",children:[e.jsx(Hu,{className:"h-4 w-4"}),"No"]})})})]}),e.jsx(Cn,{open:o,onOpenChange:l,children:e.jsxs(Ln,{className:"w-full space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(no,{className:"h-4 w-4 mt-3 text-muted-foreground shrink-0"}),e.jsx(ss,{value:d,onChange:v=>u(v.target.value),placeholder:"Tell us how we can improve this content...",className:"resize-none",rows:3,"data-testid":"input-feedback-comment"})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(D,{onClick:()=>g.mutate({feedbackType:"not_helpful",comment:d}),disabled:g.isPending,"data-testid":"button-submit-feedback",children:"Submit Feedback"})})]})})]})})})}const jI=["Playfair Display","Merriweather","Lora","Crimson Text","Libre Baskerville","Cormorant Garamond","EB Garamond","Source Serif Pro"];function wI(t,s){m.useEffect(()=>{const n=[t,s].filter(h=>!!h),a=Array.from(new Set(n));if(a.length===0)return;const o=a.map(h=>`family=${encodeURIComponent(h)}:wght@400;500;600;700`).join("&"),l="google-fonts-kb",d=`https://fonts.googleapis.com/css2?${o}&display=swap`;let u=document.getElementById(l);return u?u.href=d:(u=document.createElement("link"),u.id=l,u.rel="stylesheet",u.href=d,document.head.appendChild(u)),()=>{}},[t,s])}function Cw(t){return t&&jI.includes(t)?"serif":"sans-serif"}function Io(){const[t,s]=ar("/kb/:slug/:categoryId/:procedureId"),[n,a]=ar("/kb/:slug/:categoryId"),[o,l]=ar("/kb/:slug"),[d,u]=ar("/:companySlug/:kbSlug/:categorySlug/:procedureSlug"),[h,f]=ar("/:companySlug/:kbSlug/:categorySlug"),[g,x]=ar("/:companySlug/:kbSlug"),v=d||h||g;let w,C,j,b;d?(w=u?.companySlug,C=u?.kbSlug,j=u?.categorySlug,b=u?.procedureSlug):h?(w=f?.companySlug,C=f?.kbSlug,j=f?.categorySlug):g?(w=x?.companySlug,C=x?.kbSlug):t?(C=s?.slug,j=s?.categoryId,b=s?.procedureId):n?(C=a?.slug,j=a?.categoryId):o&&(C=l?.slug);const k=v?void 0:C,[,N]=Kr(),[T,P]=m.useState(""),{toast:I}
56=dt(),{user:O,logout:R}=Oa(),{data:F,isLoading:M}=je({queryKey:[`/api/company/${w}/kb/${C}`],enabled:v&&!!w&&!!C}),{data:z,isLoading:H}=je({queryKey:["/api/knowledge-bases/by-slug",k],enabled:!v&&!!k}),V=v?F:z,B=v?M:H,Y=w||V?.client?.slug,{data:L}=je({queryKey:["/api/public/analytics-settings",Y],queryFn:async()=>{if(!Y)return{monitorUserFeedback:!1};const Le=await fetch(`/api/public/analytics-settings/${Y}`);return Le.ok?Le.json():{monitorUserFeedback:!1}},enabled:!!Y,staleTime:1e3*60*5});wI(V?.clientBranding?.headingFont||null,V?.clientBranding?.bodyFont||null);const K=V?.clientBranding?.headingFont,_=V?.clientBranding?.bodyFont,$=V?.clientBranding?.primaryColor,A=V?.clientBranding?.preferredTheme,W=K?{fontFamily:`"${K}", ${Cw(K)}`}:{},U=_?{fontFamily:`"${_}", ${Cw(_)}`}:{};m.useEffect(()=>{if(!A||A==="system")return;const Le=window.document.documentElement,Nt=`outliner-kc-theme-${w||k}`;localStorage.getItem(Nt)||(Le.classList.remove("light","dark"),Le.classList.add(A))},[A,w,k]);const Q={headingFontStyle:W,bodyFontStyle:U,primaryColor:$||void 0},we=$?{color:$}:{},_e=j==="uncategorized",Ie=j&&!_e?V?.categories?.find(Le=>Le.id===j||Le.slug===j):null,Te=Ie?.id,ue=b?_e?V?.uncategorizedProcedures?.find(Le=>Le.id===b||Le.slug===b)?.id||b:Ie?.procedures?.find(Le=>Le.id===b||Le.slug===b)?.id||b:void 0,{data:Re,isLoading:$e}=je({queryKey:["/api/procedures",ue],enabled:!!ue}),le=()=>v&&w&&C?`/${w}/${C}`:`/kb/${k}`,Me=(Le,Nt)=>{const Xt=V?.categories?.find(us=>us.id===Nt),qt=Xt?.procedures?.find(us=>us.id===Le);v&&Xt?.slug&&qt?.slug?N(`${le()}/${Xt.slug}/${qt.slug}`):N(`${le()}/${Nt}/${Le}`)},He=Le=>{const Nt=V?.categories?.find(Xt=>Xt.id===Le);v&&Nt?.slug?N(`${le()}/${Nt.slug}`):N(`${le()}/${Le}`)},ft=()=>{N(le())},Ct=()=>{navigator.clipboard.writeText(window.location.href),I({title:"Link copied",description:"The URL has been copied to your clipboard."})},zt=()=>{const Le=le(),Nt=[{label:V?.name||"Knowledge Base",href:Le}];if(Ie){const Xt=v&&Ie.slug?Ie.slug:Te;Nt.push({label:Ie.name,href:ue?`${Le}/${Xt}`:void 0})}return Re&&Nt.push({label:Re.title}),Nt},Wt=V?.categories?.filter(Le=>{if(!T)return!0;const Nt=T.toLowerCase();return Le.name.toLowerCase().includes(Nt)||Le.procedures?.some(Xt=>Xt.title.toLowerCase().includes(Nt)||Xt.description?.toLowerCase().includes(Nt))});return B?e.jsx(kI,{}):V?e.jsxs("div",{className:"min-h-screen bg-background flex",style:U,children:[e.jsxs("aside",{className:"w-72 lg:w-80 bg-sidebar text-sidebar-foreground border-r border-sidebar-border flex-shrink-0 hidden md:flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-sidebar-border space-y-3",children:[e.jsx(ht,{href:le(),children:e.jsx("div",{className:"flex items-center gap-2 cursor-pointer","data-testid":"link-kb-logo",children:V.clientBranding?.logo?e.jsx("img",{src:V.clientBranding.logo,alt:V.clientBranding.name,className:"max-h-[50px] max-w-[160px] object-contain","data-testid":"img-kb-logo"}):e.jsx("span",{className:"text-lg",style:W,children:V.clientBranding?.name||V.name||"Knowledge Base"})})}),v&&w&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-sidebar-foreground/70",children:[e.jsx(ht,{href:`/${w}`,children:e.jsx("span",{className:"hover:text-sidebar-foreground cursor-pointer","data-testid":"link-company-home",children:V.clientBranding?.name||w})}),e.jsx(Bt,{className:"h-3 w-3"}),e.jsx(ht,{href:le(),children:e.jsx("span",{className:"hover:text-sidebar-foreground cursor-pointer","data-testid":"link-kb-home",children:V.name})})]})]}),e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(Mm,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-sidebar-foreground/50"}),e.jsx(fe,{placeholder:"Search procedures...",value:T,onChange:Le=>P(Le.target.value),className:"pl-9 bg-sidebar-accent border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50","data-testid":"input-kb-search"})]})}),e.jsx(jl,{className:"flex-1 px-2",children:e.jsxs("nav",{className:"space-y-1 pb-4",children:[(V?.uncategorizedProcedures?.length||0)>0&&e.jsx("div",{className:"space-y-0.5 mb-2",children:V?.uncategorizedProcedures?.filter(Le=>!T||Le.title.toLowerCase().includes(T.toLowerCase())||Le.description?.toLowerCase().includes(T.toLowerCase())).map(Le=>{const Nt=v&&Le.slug?Le.slug:Le.id;return e.jsx(ht,{href:`${le()}/uncategorized/${Nt}`,children:e.jsxs("button",{className:`w-full flex items-start px-3 py-2 text-sm rounded-md transition-colors ${ue===Le.id&&_e?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground
56/70 hover:text-sidebar-foreground hover:bg-sidebar-accent/50"}`,"data-testid":`button-procedure-uncategorized-${Le.id}`,children:[Le.contentType==="overview"?e.jsx(cs,{className:"h-4 w-4 flex-shrink-0 mr-1 mt-0.5",style:we}):e.jsx(Pt,{className:"h-4 w-4 flex-shrink-0 mr-1 mt-0.5",style:we}),e.jsx("span",{className:"text-left flex-1 min-w-0",children:Le.title})]})},Le.id)})}),Wt?.map(Le=>e.jsx(bI,{category:Le,selectedProcedureId:ue,selectedCategoryId:Te,onSelectProcedure:Nt=>Me(Nt,Le.id),onSelectCategory:()=>He(Le.id),searchQuery:T,baseUrl:le(),isNewUrlPattern:v,branding:Q},Le.id))]})}),e.jsxs("div",{className:"p-4 border-t border-sidebar-border space-y-3",children:[O?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hr,{className:"h-4 w-4 text-sidebar-foreground/60"}),e.jsx("span",{className:"text-xs text-sidebar-foreground truncate max-w-[120px]",title:O.email,children:O.email})]}),e.jsxs(D,{variant:"ghost",size:"sm",onClick:()=>{R(),window.location.reload()},className:"text-xs h-7 px-2","data-testid":"button-kb-logout",children:[e.jsx(Om,{className:"h-3 w-3 mr-1"}),"Logout"]})]}):e.jsx(ht,{href:`/portal/login?slug=${k}`,children:e.jsxs(D,{variant:"outline",size:"sm",className:"w-full text-xs","data-testid":"button-kb-login",children:[e.jsx(qu,{className:"h-3 w-3 mr-2"}),"Login for more content"]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-sidebar-foreground/60",children:"Powered by Outliner"}),e.jsx(Ra,{})]})]})]}),e.jsxs("main",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("header",{className:"md:hidden p-4 border-b border-border space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ht,{href:le(),children:V.clientBranding?.logo?e.jsx("img",{src:V.clientBranding.logo,alt:V.clientBranding.name,className:"max-h-[40px] max-w-[140px] object-contain","data-testid":"img-kb-logo-mobile"}):e.jsx("span",{className:"text-lg",style:W,"data-testid":"link-kb-logo-mobile",children:V.clientBranding?.name||V.name||"Knowledge Base"})}),e.jsx(Ra,{})]}),v&&w&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ht,{href:`/${w}`,children:e.jsx("span",{className:"hover:text-foreground cursor-pointer","data-testid":"link-company-home-mobile",children:V.clientBranding?.name||w})}),e.jsx(Bt,{className:"h-3 w-3"}),e.jsx(ht,{href:le(),children:e.jsx("span",{className:"hover:text-foreground cursor-pointer","data-testid":"link-kb-home-mobile",children:V.name})})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[(Te||ue)&&e.jsxs("div",{className:"px-6 pt-4 flex items-center gap-2 flex-wrap",children:[zt().map((Le,Nt,Xt)=>e.jsxs("div",{className:"flex items-center gap-2",children:[Le.href?e.jsx(ht,{href:Le.href,children:e.jsxs("span",{className:"text-sm text-muted-foreground hover:text-foreground cursor-pointer flex items-center gap-1","data-testid":`breadcrumb-${Nt}`,children:[Nt===0&&e.jsx(yN,{className:"h-3 w-3",style:we}),Le.label]})}):e.jsx("span",{className:"text-sm font-medium","data-testid":`breadcrumb-${Nt}`,children:Le.label}),Nt<Xt.length-1&&e.jsx(Bt,{className:"h-3 w-3",style:we})]},Nt)),e.jsxs(D,{variant:"ghost",size:"sm",onClick:Ct,className:"ml-auto text-muted-foreground","data-testid":"button-copy-link",children:[e.jsx(vN,{className:"h-4 w-4 mr-1"}),"Copy Link"]})]}),ue?e.jsx(CI,{procedure:Re,isLoading:$e,onBack:()=>Te?He(Te):ft(),categoryName:_e?void 0:Ie?.name,branding:Q,showFeedbackWidget:L?.monitorUserFeedback??!1}):Te&&Ie?e.jsx(SI,{category:Ie,onSelectProcedure:Le=>Me(Le,Te),onBack:ft,baseUrl:le(),isNewUrlPattern:v,branding:Q}):e.jsx(NI,{knowledgeBase:V,categories:Wt||[],uncategorizedProcedures:V?.uncategorizedProcedures||[],onSelectCategory:He,onSelectProcedure:Me,baseUrl:le(),isNewUrlPattern:v,branding:Q})]})]})]}):e.jsx(PI,{slug:k})}function bI({category:t,selectedProcedureId:s,selectedCategoryId:n,onSelectProcedure:a,onSelectCategory:o,searchQuery:l,baseUrl:d,isNewUrlPattern:u,branding:h}){const f=n===t.id,[g,x]=m.useState(!0),v=h.primaryColor?{color:h.primaryColor}:{},w=t.procedures?.filter(b=>{if(!l)return!0;const k=l.toLowerCase();return b.title.toLowerCase().includes(k)||b.description?.toLowerCase().includes(k)});if(!w?.length&&l)return null;const C=()=>u&&t.slug?t.slug:t.id,j=b=>u&&b.slug?b.slug:b.id;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("button",{onClick:o,className:`w-full flex items-start px-3 py-2 text-sm font-medium rounded-md transition-colors ${f&&!s?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground
56/80 hover:text-sidebar-foreground hover:bg-sidebar-accent"}`,"data-testid":`button-category-${t.id}`,children:[e.jsx(Bt,{className:`h-4 w-4 flex-shrink-0 transition-transform mt-0.5 ${g?"rotate-90":""}`,style:v,onClick:b=>{b.stopPropagation(),x(!g)}}),e.jsx(Fr,{className:"h-4 w-4 flex-shrink-0 ml-0.5 mr-1 mt-0.5",style:v}),e.jsx("span",{className:"text-left flex-1 min-w-0",children:t.name}),e.jsx(Ce,{variant:"secondary",className:"flex-shrink-0 text-xs no-default-hover-elevate ml-1 mt-0.5",children:w?.length||0})]}),g&&e.jsx("div",{className:"ml-6 space-y-0.5",children:w?.map(b=>e.jsx(ht,{href:`${d}/${C()}/${j(b)}`,children:e.jsxs("button",{className:`w-full flex items-start px-3 py-2 text-sm rounded-md transition-colors ${s===b.id?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/70 hover:text-sidebar-foreground hover:bg-sidebar-accent/50"}`,"data-testid":`button-procedure-${b.id}`,children:[b.contentType==="overview"?e.jsx(cs,{className:"h-4 w-4 flex-shrink-0 mr-1 mt-0.5",style:v}):e.jsx(Pt,{className:"h-4 w-4 flex-shrink-0 mr-1 mt-0.5",style:v}),e.jsx("span",{className:"text-left flex-1 min-w-0",children:b.title})]})},b.id))})]})}function NI({knowledgeBase:t,categories:s,uncategorizedProcedures:n=[],onSelectCategory:a,onSelectProcedure:o,baseUrl:l,isNewUrlPattern:d,branding:u}){const h=s.reduce((g,x)=>g+(x.procedures?.length||0),0)+n.length,f=u.primaryColor?{color:u.primaryColor}:{};return e.jsx("div",{className:"p-6 md:p-8 lg:p-12 max-w-5xl mx-auto",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(cs,{className:"h-4 w-4",style:f}),e.jsx("span",{children:"Knowledge Base"})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-normal tracking-tight",style:u.headingFontStyle,children:t.name}),t.description&&e.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl",style:u.bodyFontStyle,children:t.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pa,{className:"h-4 w-4",style:f}),s.length," categories"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pt,{className:"h-4 w-4",style:f}),h," procedures"]})]})]}),n.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-medium",style:u.headingFontStyle,children:"Quick Access"}),e.jsx("div",{className:"space-y-3",children:n.map(g=>{const x=d&&g.slug?g.slug:g.id;return e.jsx(ht,{href:`${l}/uncategorized/${x}`,className:"block",children:e.jsx(ee,{className:"border-border/50 hover-elevate cursor-pointer","data-testid":`card-procedure-uncategorized-${g.id}`,children:e.jsxs(te,{className:"p-4 flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded-md",style:{backgroundColor:u.primaryColor?`${u.primaryColor}15`:"hsl(var(--primary) / 0.1)"},children:g.contentType==="overview"?e.jsx(cs,{className:"h-5 w-5",style:f}):e.jsx(Pt,{className:"h-5 w-5",style:f})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",style:u.headingFontStyle,children:g.title}),g.description&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:g.description})]}),e.jsx(Bt,{className:"h-5 w-5 text-muted-foreground"})]})})},g.id)})})]}),s.length>0&&e.jsxs("div",{className:"space-y-4",children:[n.length>0&&e.jsx("h2",{className:"text-lg font-medium",style:u.headingFontStyle,children:"Categories"}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(g=>{const x=d&&g.slug?g.slug:g.id;return e.jsx(ht,{href:`${l}/${x}`,children:e.jsxs(ee,{className:"border-border/50 hover-elevate cursor-pointer h-full","data-testid":`card-category-${g.id}`,children:[e.jsx(qe,{className:"pb-2",children:e.jsxs(tt,{className:"flex items-center gap-2 text-base",style:u.headingFontStyle,children:[e.jsx(Fr,{className:"h-4 w-4",style:f}),g.name]})}),e.jsxs(te,{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[g.procedures?.length||0," procedures"]}),e.jsxs("div",{className:"space-y-1",children:[g.procedures?.slice(0,3).map(v
56=>e.jsxs("div",{className:"w-full text-left text-sm text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(Bt,{className:"h-3 w-3",style:f}),v.title]},v.id)),(g.procedures?.length||0)>3&&e.jsxs("p",{className:"text-xs text-muted-foreground pl-4",children:["+",(g.procedures?.length||0)-3," more"]})]})]})]})},g.id)})})]}),s.length===0&&n.length===0&&e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-12 text-center",children:[e.jsx(cs,{className:"h-12 w-12 mx-auto mb-4",style:f}),e.jsx("h3",{className:"font-medium text-lg mb-2",style:u.headingFontStyle,children:"No procedures yet"}),e.jsx("p",{className:"text-muted-foreground",children:"This knowledge base is empty. Check back later for documented procedures."})]})})]})})}function SI({category:t,onSelectProcedure:s,onBack:n,baseUrl:a,isNewUrlPattern:o,branding:l}){const d=l.primaryColor?{color:l.primaryColor}:{},u=()=>o&&t.slug?t.slug:t.id,h=f=>o&&f.slug?f.slug:f.id;return e.jsx("div",{className:"p-6 md:p-8 lg:p-12 max-w-5xl mx-auto",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(Fr,{className:"h-4 w-4",style:d}),e.jsx("span",{children:"Category"})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-normal tracking-tight",style:l.headingFontStyle,children:t.name}),e.jsx("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pt,{className:"h-4 w-4",style:d}),t.procedures?.length||0," procedures"]})})]}),e.jsx("div",{className:"space-y-4",children:t.procedures?.map(f=>e.jsx(ht,{href:`${a}/${u()}/${h(f)}`,className:"block",children:e.jsx(ee,{className:"border-border/50 hover-elevate cursor-pointer","data-testid":`card-procedure-${f.id}`,children:e.jsxs(te,{className:"p-4 flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded-md",style:{backgroundColor:l.primaryColor?`${l.primaryColor}15`:"hsl(var(--primary) / 0.1)"},children:e.jsx(Pt,{className:"h-5 w-5",style:d})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",style:l.headingFontStyle,children:f.title}),f.description&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:f.description})]}),e.jsx(Bt,{className:"h-5 w-5 flex-shrink-0",style:d})]})})},f.id))}),(!t.procedures||t.procedures.length===0)&&e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-12 text-center",children:[e.jsx(Pt,{className:"h-12 w-12 mx-auto mb-4",style:d}),e.jsx("h3",{className:"font-medium text-lg mb-2",style:l.headingFontStyle,children:"No procedures yet"}),e.jsx("p",{className:"text-muted-foreground",children:"This category is empty. Check back later for documented procedures."})]})})]})})}function CI({procedure:t,isLoading:s,onBack:n,categoryName:a,branding:o,showFeedbackWidget:l=!0}){if(fI(t?.id||null),s)return e.jsxs("div",{className:"p-6 md:p-8 lg:p-12 max-w-3xl mx-auto space-y-6",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx(be,{className:"h-4 w-full"}),e.jsx(be,{className:"h-4 w-3/4"}),e.jsx("div",{className:"space-y-4 pt-8",children:[1,2,3].map(f=>e.jsxs("div",{className:"flex gap-4",children:[e.jsx(be,{className:"h-8 w-8 rounded-full flex-shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(be,{className:"h-4 w-full"}),e.jsx(be,{className:"h-4 w-3/4"})]})]},f))})]});if(!t)return e.jsxs("div",{className:"p-6 md:p-8 lg:p-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground",children:"Procedure not found"}),e.jsxs(D,{variant:"ghost",onClick:n,className:"mt-4",children:[e.jsx(kn,{className:"h-4 w-4 mr-2"}),"Go back"]})]});const d=o.primaryColor?{color:o.primaryColor}:{},u=o.primaryColor?{backgroundColor:o.primaryColor,color:"#fff"}:{},h=o.primaryColor?{backgroundColor:o.primaryColor}:{};return e.jsx("div",{className:"p-6 md:p-8 lg:p-12 max-w-3xl mx-auto",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Ce,{variant:t.status==="published"?"default":"secondary",style:t.status==="published"?h:{},children:t.status}),t.owner&&e.jsxs(Ce,{variant:"outline",className:"gap-1",children:[e.jsx(Hr,{className:"h-3 w-3",style:d}),t.owner]})]}),e.jsx("h1",{className:"text-2xl md:text-3xl font-normal tracking-tight",style:o.headingFontStyle,children:t.title}),t.description&&e.jsx("p",{className:"text-muted-foreground leading-relaxed",style:o.bodyFontStyle,children:t.description})]}),t.videoUrl&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h2",{className:"font-medium text-lg flex items-center gap-2",style:o.headingFontStyle,children:[e.jsx(lr,{className:"h-5 w-5",style:d}),"Watch Procedure"]}),e.jsx("div",{className:"rounded-lg border border-border overflow-hidden bg-muted",children:e.jsx(rl,{src:t.videoUrl,className:"w-full aspect-video","data-testid":"video-procedure-main"})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"font-medium text-lg flex items-center gap-2",style:o.headingFontStyle,children:t.contentType==="overview"?e.jsxs(e.Fragment,{children:[e.jsx(ln,{className:"h-5 w-5",style:d}),"Key Points (",t.steps?.length||0,")"]}):e.jsxs(e.Fragment,{children:[e.jsx(Pa,{className:"h-5 w-5",style:d}),"Steps (",t.steps?.length||0,")"]})}
56),e.jsx("div",{className:"space-y-4",children:t.steps?.sort((f,g)=>f.order-g.order).map((f,g)=>e.jsxs("div",{className:"flex gap-4","data-testid":`step-${f.id}`,children:[e.jsx("div",{className:"flex-shrink-0",children:t.contentType==="overview"?e.jsx("div",{className:"w-8 h-8 flex items-center justify-center",children:e.jsx(Vu,{className:"h-3 w-3 fill-current",style:d})}):e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary text-primary-foreground flex items-center justify-center text-sm font-medium",style:u,children:g+1})}),e.jsxs("div",{className:"flex-1 space-y-3 pt-1",children:[e.jsx("h3",{className:"font-medium",style:o.headingFontStyle,children:f.title}),f.content&&e.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:f.content}),f.imageUrl&&e.jsx("div",{className:"rounded-lg border border-border overflow-hidden",children:e.jsx("img",{src:f.imageUrl,alt:f.title,className:"w-full max-h-96 object-contain bg-muted","data-testid":`img-step-media-${f.id}`})}),f.videoUrl&&e.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[f.videoType==="video"&&e.jsx(rl,{src:f.videoUrl,className:"w-full aspect-video","data-testid":`video-step-media-${f.id}`}),f.videoType?.startsWith("embed-")&&e.jsx("div",{className:"aspect-video",children:e.jsx("iframe",{src:f.videoUrl,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:f.title,"data-testid":`iframe-step-media-${f.id}`})})]})]})]},f.id))}),(!t.steps||t.steps.length===0)&&e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-8 text-center",children:[e.jsx(Sr,{className:"h-8 w-8 mx-auto mb-3",style:d}),e.jsx("p",{className:"text-muted-foreground",children:t.contentType==="overview"?"No key points have been added to this overview yet.":"No steps have been added to this procedure yet."})]})})]}),l&&e.jsx(yI,{procedureId:t.id})]})})}function kI(){return e.jsxs("div",{className:"min-h-screen bg-background flex",children:[e.jsxs("aside",{className:"w-72 lg:w-80 bg-sidebar border-r border-sidebar-border hidden md:flex flex-col",children:[e.jsx("div",{className:"p-4 border-b border-sidebar-border",children:e.jsx(be,{className:"h-6 w-24"})}),e.jsx("div",{className:"p-4",children:e.jsx(be,{className:"h-10 w-full"})}),e.jsx("div",{className:"flex-1 p-4 space-y-4",children:[1,2,3].map(t=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"h-8 w-full"}),e.jsx(be,{className:"h-6 w-3/4 ml-6"}),e.jsx(be,{className:"h-6 w-2/3 ml-6"})]},t))})]}),e.jsx("main",{className:"flex-1 p-8",children:e.jsxs("div",{className:"max-w-5xl mx-auto space-y-8",children:[e.jsx(be,{className:"h-10 w-64"}),e.jsx(be,{className:"h-4 w-full max-w-xl"}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(t=>e.jsx(be,{className:"h-40"},t))})]})})]})}function PI({slug:t}){return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(ee,{className:"max-w-md w-full",children:e.jsxs(te,{className:"p-8 text-center space-y-4",children:[e.jsx(cs,{className:"h-12 w-12 text-muted-foreground/50 mx-auto"}),e.jsx("h1",{className:"font-serif text-2xl",children:"Knowledge Base Not Found"}),e.jsxs("p",{className:"text-muted-foreground",children:['The knowledge base "',t,`" doesn't exist or you don't have access to it.`]}),e.jsx(ht,{href:"/",children:e.jsxs(D,{"data-testid":"button-kb-not-found-home",children:[e.jsx(kn,{className:"h-4 w-4 mr-2"}),"Go to Homepage"]})})]})})})}const TI=["Playfair Display","Merriweather","Lora","Crimson Text","Libre Baskerville","Cormorant Garamond","EB Garamond","Source Serif Pro"];function kw(t){return t&&TI.includes(t)?"serif":"sans-serif"}function EI(t,s){m.useEffect(()=>{const n=[t,s].filter(h=>!!h),a=Array.from(new Set(n));if(a.length===0)return;const o=a.map(h=>`family=${encodeURIComponent(h)}:wght@400;500;600;700`).join("&"),l="google-fonts-kb",d=`https://fonts.googleapis.com/css2?${o}&display=swap`;let u=document.getElementById(l);u?u.href=d:(u=document.createElement("link"),u.id=l,u.rel="stylesheet",u.href=d,document.head.appendChild(u))},[t,s])}function _I(){const[,t]=ar("/:companySlug"),s=t?.companySlug,{user:n}=Da(),{user:a}=Oa(),o=a?.id||n?.id||"anonymous",{data:l,isLoading:d,error:u}=je({queryKey:["company-knowledge-bases",s,o],queryFn:async()=>{const P={},I=localStorage.getItem("outliner-portal-auth-token");I&&(P.Authorization=`Bearer ${I}`);const O=await fetch(`/api/company/${s}/knowledge-bases`,{credentials:"include",headers:P});if(!O.ok)throw new Error("Failed to fetch");return O.json()},enabled:!!s,staleTime:0}),h=l?.knowledgeBases||[],f=l?.companyExists??!1,g=l?.companyName,w=(l?.isAuthenticated??!1)||!!n,C=l?.branding||h?.[0]?.clientBranding,j=C?.headingFont,b
56=C?.bodyFont,k=C?.preferredTheme,N=j?{fontFamily:`"${j}", ${kw(j)}`}:{},T=b?{fontFamily:`"${b}", ${kw(b)}`}:{};return EI(j||null,b||null),m.useEffect(()=>{if(!k||k==="system")return;const P=window.document.documentElement,I=`outliner-kc-theme-${s}`;localStorage.getItem(I)||(P.classList.remove("light","dark"),P.classList.add(k))},[k,s]),d?e.jsx("div",{className:"min-h-screen bg-background p-8",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(be,{className:"h-12 w-64"}),e.jsx(be,{className:"h-6 w-96"}),e.jsx("div",{className:"grid sm:grid-cols-2 gap-4 mt-8",children:[1,2,3].map(P=>e.jsx(be,{className:"h-32"},P))})]})}):u||!f?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(cs,{className:"h-16 w-16 mx-auto mb-4 text-muted-foreground"}),e.jsx("h1",{className:"text-2xl font-semibold mb-2",children:"Company Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:"The company you're looking for doesn't exist or may have moved."}),e.jsx(ht,{href:"/",children:e.jsx("span",{className:"text-primary hover:underline mt-4 inline-block cursor-pointer","data-testid":"link-home",children:"Go to Homepage"})})]})}):e.jsxs("div",{className:"min-h-screen bg-background",style:T,children:[e.jsx("header",{className:"border-b border-border",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-4 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-3",children:C?.logo?e.jsx("img",{src:C.logo,alt:C.name,className:"max-h-[50px] max-w-[160px] object-contain","data-testid":"img-company-logo"}):e.jsx("span",{className:"text-xl",style:N,"data-testid":"text-company-name",children:C?.name||g})}),e.jsx(Ra,{})]})}),e.jsx("main",{className:"max-w-4xl mx-auto px-6 py-12",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-3xl",style:N,children:"Knowledge Bases"}),e.jsx("p",{className:"text-muted-foreground",style:T,children:h.length>0?"Select a knowledge base to explore our documentation and procedures.":w?"No knowledge bases are available yet.":"Log in to access our knowledge bases."})]}),h.length===0&&!w&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Pn,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Team members can access knowledge bases by logging in."}),e.jsx(ht,{href:`/portal/login?redirect=/${s}`,children:e.jsxs(D,{"data-testid":"button-login-prompt",children:[e.jsx(qu,{className:"h-4 w-4 mr-2"}),"Team Login"]})})]}),h.length===0&&w&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(cs,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"No knowledge bases have been created yet."})]}),h.length>0&&e.jsx("div",{className:"grid sm:grid-cols-2 gap-4",children:h.map(P=>e.jsx(ht,{href:P.slug?`/${s}/${P.slug}`:`/kb/${s}`,children:e.jsxs(ee,{className:"hover-elevate cursor-pointer h-full","data-testid":`card-kb-${P.id}`,children:[e.jsx(qe,{className:"pb-2",children:e.jsxs(tt,{className:"flex items-center gap-2 text-lg",style:N,children:[e.jsx(cs,{className:"h-5 w-5 text-primary"}),P.name]})}),e.jsxs(te,{className:"space-y-3",children:[P.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:P.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:P.visibility==="public"?e.jsxs(e.Fragment,{children:[e.jsx($n,{className:"h-3 w-3"}),e.jsx("span",{children:"Public"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Pn,{className:"h-3 w-3"}),e.jsx("span",{children:"Requires login"})]})}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"})]})]})]})},P.id))})]})}),e.jsx("footer",{className:"border-t border-border",children:e.jsx("div",{className:"max-w-4xl mx-auto px-6 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Powered by Outliner"}),a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Hr,{className:"h-3 w-3"}),a.name||a.email]}),e.jsxs(D,{variant:"ghost",size:"sm",onClick:async()=>{try{await fetch("/api/portal/auth/logout",{method:"POST",credentials:"include"})}catch{}localStorage.removeItem("outliner-portal-user"),window.location.reload()},"data-testid":"button-portal-logout",children:[e.jsx(Om,{className:"h-3 w-3 mr-1"}),"Sign Out"]})]}):e.jsx(ht,{href:`/portal/login?redirect=/${s}`,children:e.jsxs(D,{variant:"ghost",size:"sm","data-testid":"button-team-login",children:[e.jsx(qu,{className:"h-3 w-3 mr-1"}),"Team Login"]})})]})})})]})}const pp=768;function RI(){const[t,s]=m.useState(void 0);return m.useEffect(()=>{const n=window.matchMedia(`(max-width: ${pp-1}px)`),a=()=>{s(window.innerWidth<pp)};return n.addEventListener("change",a),s(window.innerWidth<pp),()=>n.removeEventListener("change",a)},[]),!!t}var AI="Separator",Pw="horizontal",II=["horizontal","vertical"],mS=m.forwardRef((t,s)=>{const{decorative:n,orientation:a=Pw,...o}=t,l=DI(a)?a:Pw,u=n?{role:"none"}:{"aria-orientation":l==="vertical"?l:void 0,role:"separator"};return e.jsx(at.div,{"data-orientation":l,...u,...o,ref:s})});mS.displayName=AI;function DI(t){return II.includes(t)}var hS=mS;const OI=m.forwardRef(({className:t,orientation:s="horizontal",decorative:n=!0,...a},o)=>e.jsx(hS,{ref:o,decorative:n,orientation:s,className:Oe("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...a}));OI.displayName=hS.displayName;const MI="sidebar_state",LI=3600*24*7,FI="16rem",$I="18rem",UI="3rem",zI="b",fS=m.createContext(null);function vx(){const t=m.useContext(fS);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function pS({defaultOpen:t=!0,open:s,onOpenChange:n,className:a,style:o,children:l,...d}){const u=RI(),[h,f]=m.useState(!1),[g,x]=m.useState(t),v=s??g,w=m.useCallback(k=>{const N=typeof k=="function"?k(v):k;n?n(N):x(N),document.cookie=`${MI}=${N}; path=/; max-age=${LI}`},[n,v]),C=m.useCallback(()=>u?f(k=>!k):w(k=>!k),[u,w,f]);m.useEffect(()=>{const k=N=>
vendor: 4,130 bytes, line 56
56{N.key===zI&&(N.metaKey||N.ctrlKey)&&(N.preventDefault(),C())};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[C]);const j=v?"expanded":"collapsed",b=m.useMemo(()=>({state:j,open:v,setOpen:w,isMobile:u,openMobile:h,setOpenMobile:f,toggleSidebar:C}),[j,v,w,u,h,f,C]);return e.jsx(fS.Provider,{value:b,children:e.jsx(c0,{delayDuration:0,children:e.jsx("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":FI,"--sidebar-width-icon":UI,...o},className:Oe("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",a),...d,children:l})})})}function gS({side:t="left",variant:s="sidebar",collapsible:n="offcanvas",className:a,children:o,...l}){const{isMobile:d,state:u,openMobile:h,setOpenMobile:f}=vx();return n==="none"?e.jsx("div",{"data-slot":"sidebar",className:Oe("bg-sidebar text-sidebar-foreground flex h-full w-[var(--sidebar-width)] flex-col",a),...l,children:o}):d?e.jsx(B0,{open:h,onOpenChange:f,...l,children:e.jsxs(ox,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden",style:{"--sidebar-width":$I},side:t,children:[e.jsxs(lx,{className:"sr-only",children:[e.jsx(cx,{children:"Sidebar"}),e.jsx(q0,{children:"Displays the mobile sidebar."})]}),e.jsx("div",{className:"flex h-full w-full flex-col",children:o})]})}):e.jsxs("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":u,"data-collapsible":u==="collapsed"?n:"","data-variant":s,"data-side":t,"data-slot":"sidebar",children:[e.jsx("div",{"data-slot":"sidebar-gap",className:Oe("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",s==="floating"||s==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+var(--spacing-4))]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]")}),e.jsx("div",{"data-slot":"sidebar-container",className:Oe("fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear md:flex",t==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",s==="floating"||s==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+var(--spacing-4)+2px)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] group-data-[side=left]:border-r group-data-[side=right]:border-l",a),...l,children:e.jsx("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm",children:o})})]})}function xS({className:t,onClick:s,...n}){const{toggleSidebar:a}=vx();return e.jsxs(D,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:Oe("h-7 w-7",t),onClick:o=>{s?.(o),a()},...n,children:[e.jsx(hE,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function vS({className:t,...s}){return e.jsx("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:Oe("flex flex-col gap-2 p-2",t),...s})}function yS({className:t,...s}){return e.jsx("div",{"data-slot":"sidebar-footer","data-sidebar":"footer",className:Oe("flex flex-col gap-2 p-2",t),...s})}function jS({className:t,...s}){return e.jsx("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:Oe("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...s})}function Mo({className:t,...s}){return e.jsx("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:Oe("relative flex w-full min-w-0 flex-col p-2",t),...s})}function hc({className:t,asChild:s=!1,...n}){const a=s?Cg:"div";return e.jsx(a,{"data-slot":"sidebar-group-label","data-sidebar":"group-label",className:Oe("text-sidebar-foreground
56/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:h-4 [&>svg]:w-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),...n})}function Lo({className:t,...s}){return e.jsx("div",{"data-slot":"sidebar-group-content","data-sidebar":"group-content",className:Oe("w-full text-sm",t),...s})}function Fo({className:t,...s}){return e.jsx("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:Oe("flex w-full min-w-0 flex-col gap-1",t),...s})}function $o({className:t,...s}){return e.jsx("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:Oe("group/menu-item relative",t),...s})}const BI=ml("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:w-8! group-data-[collapsible=icon]:h-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function Uo({asChild:t=!1,isActive:s=!1,variant:n="default",size:a="default",tooltip:o,className:l,...d}){const u=t?Cg:"button",{isMobile:h,state:f}=vx(),g=e.jsx(u,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":a,"data-active":s,className:Oe(BI({variant:n,size:a}),l),...d});return o?(typeof o=="string"&&(o={children:o}),e.jsxs(d0,{children:[e.jsx(u0,{asChild:!0,children:g}),e.jsx(Yg,{side:"right",align:"center",hidden:f!=="collapsed"||h,...o})]})):g}var gp="rovingFocusGroup.onEntryFocus",VI={bubbles:!1,cancelable:!0},Zm="RovingFocusGroup",[Qp,wS,qI]=Tm(Zm),[KI,Xm]=En(Zm,[qI]),[HI,WI]=KI(Zm),bS=m.forwardRef((t,s)=>e.jsx(Qp.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Qp.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(QI,{...t,ref:s})})}));bS.displayName=Zm;var QI=m.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:n,orientation:a,loop:o=!1,dir:l,currentTabStopId:d,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:h,onEntryFocus:f,preventScrollOnEntryFocus:g=!1,...x}=t,v=m.useRef(null),w=At(s,v),C=ad(l),[j=null,b]=Ur({prop:d,defaultProp:u,onChange:h}),[k,N]=m.useState(!1),T=Rs(f),P=wS(n),I=m.useRef(!1),[O,R]=m.useState(0);return m.useEffect(()=>{const F=v.current;if(F)return F.addEventListener(gp,T),()=>F.removeEventListener(gp,T)},[T]),e.jsx(HI,{scope:n,orientation:a,dir:C,loop:o,currentTabStopId:j,onItemFocus:m.useCallback(F=>b(F),[b]),onItemShiftTab:m.useCallback(()=>N(!0),[]),onFocusableItemAdd:m.useCallback(()=>R(F=>F+1),[]),onFocusableItemRemove:m.useCallback(()=>R(F=>F-1),[]),children:e.jsx(at.div,{tabIndex:k||O===0?-1:0,"data-orientation":a,...x,ref:w,style:{outline:"none",...t.style},onMouseDown:Ae(t.onMouseDown,()=>{I.current=!0}),onFocus:Ae(t.onFocus,F=>{const M=!I.current;if(F.target===F.currentTarget&&M&&!k){const z=new CustomEvent(gp,VI);if(F.currentTarget.dispatchEvent(z),!z.defaultPrevented){const H=P().filter(K=>K.focusable),V=H.find(K=>K.active),B=H.find(K=>K.id===j),L=[V,B,...H].filter(Boolean).map(K=>K.ref.current);CS(L,g)}}I.current=!1}),onBlur:Ae(t.onBlur,()=>N(!1))})})}),NS="RovingFocusGroupItem",SS=m.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:n,focusable:a=!0,active:o=!1,tabStopId:l,...d}=t,u=jr(),h=l||u,f=WI(NS,n),g=f.currentTabStopId===h,x=wS(n),{onFocusableItemAdd:v,onFocusableItemRemove:w}=f;return m.useEffect(()=>{if(a)return v(),()=>w()},[a,v,w]),e.jsx(Qp.ItemSlot,{scope:n,id:h,focusable:a,active:o,children:e.jsx(at.span,{tabIndex:g?0:-1,"data-orientation":f.orientation,...d,ref:s,onMouseDown:Ae(t.onMouseDown,C=>{a?f.onItemFocus(h):C.preventDefault()}),onFocus:Ae(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:Ae(t.onKeyDown,C=>
vendor: 14,788 bytes, line 56
56{if(C.key==="Tab"&&C.shiftKey){f.onItemShiftTab();return}if(C.target!==C.currentTarget)return;const j=ZI(C,f.orientation,f.dir);if(j!==void 0){if(C.metaKey||C.ctrlKey||C.altKey||C.shiftKey)return;C.preventDefault();let k=x().filter(N=>N.focusable).map(N=>N.ref.current);if(j==="last")k.reverse();else if(j==="prev"||j==="next"){j==="prev"&&k.reverse();const N=k.indexOf(C.currentTarget);k=f.loop?XI(k,N+1):k.slice(N+1)}setTimeout(()=>CS(k))}})})})});SS.displayName=NS;var GI={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function YI(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function ZI(t,s,n){const a=YI(t.key,n);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return GI[a]}function CS(t,s=!1){const n=document.activeElement;for(const a of t)if(a===n||(a.focus({preventScroll:s}),document.activeElement!==n))return}function XI(t,s){return t.map((n,a)=>t[(s+a)%t.length])}var kS=bS,PS=SS,Gp=["Enter"," "],JI=["ArrowDown","PageUp","Home"],TS=["ArrowUp","PageDown","End"],eD=[...JI,...TS],tD={ltr:[...Gp,"ArrowRight"],rtl:[...Gp,"ArrowLeft"]},sD={ltr:["ArrowLeft"],rtl:["ArrowRight"]},id="Menu",[Rc,nD,rD]=Tm(id),[ro,ES]=En(id,[rD,yl,Xm]),Jm=yl(),_S=Xm(),[aD,ao]=ro(id),[iD,od]=ro(id),RS=t=>{const{__scopeMenu:s,open:n=!1,children:a,dir:o,onOpenChange:l,modal:d=!0}=t,u=Jm(s),[h,f]=m.useState(null),g=m.useRef(!1),x=Rs(l),v=ad(o);return m.useEffect(()=>{const w=()=>{g.current=!0,document.addEventListener("pointerdown",C,{capture:!0,once:!0}),document.addEventListener("pointermove",C,{capture:!0,once:!0})},C=()=>g.current=!1;return document.addEventListener("keydown",w,{capture:!0}),()=>{document.removeEventListener("keydown",w,{capture:!0}),document.removeEventListener("pointerdown",C,{capture:!0}),document.removeEventListener("pointermove",C,{capture:!0})}},[]),e.jsx(Kg,{...u,children:e.jsx(aD,{scope:s,open:n,onOpenChange:x,content:h,onContentChange:f,children:e.jsx(iD,{scope:s,onClose:m.useCallback(()=>x(!1),[x]),isUsingKeyboardRef:g,dir:v,modal:d,children:a})})})};RS.displayName=id;var oD="MenuAnchor",yx=m.forwardRef((t,s)=>{const{__scopeMenu:n,...a}=t,o=Jm(n);return e.jsx(Hg,{...o,...a,ref:s})});yx.displayName=oD;var jx="MenuPortal",[lD,AS]=ro(jx,{forceMount:void 0}),IS=t=>{const{__scopeMenu:s,forceMount:n,children:a,container:o}=t,l=ao(jx,s);return e.jsx(lD,{scope:s,forceMount:n,children:e.jsx(gn,{present:n||l.open,children:e.jsx(Zc,{asChild:!0,container:o,children:a})})})};IS.displayName=jx;var wr="MenuContent",[cD,wx]=ro(wr),DS=m.forwardRef((t,s)=>{const n=AS(wr,t.__scopeMenu),{forceMount:a=n.forceMount,...o}=t,l=ao(wr,t.__scopeMenu),d=od(wr,t.__scopeMenu);return e.jsx(Rc.Provider,{scope:t.__scopeMenu,children:e.jsx(gn,{present:a||l.open,children:e.jsx(Rc.Slot,{scope:t.__scopeMenu,children:d.modal?e.jsx(dD,{...o,ref:s}):e.jsx(uD,{...o,ref:s})})})})}),dD=m.forwardRef((t,s)=>{const n=ao(wr,t.__scopeMenu),a=m.useRef(null),o=At(s,a);return m.useEffect(()=>{const l=a.current;if(l)return Jg(l)},[]),e.jsx(bx,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ae(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),uD=m.forwardRef((t,s)=>{const n=ao(wr,t.__scopeMenu);return e.jsx(bx,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),mD=Bi("MenuContent.ScrollLock"),bx=m.forwardRef((t,s)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:o,onOpenAutoFocus:l,onCloseAutoFocus:d,disableOutsidePointerEvents:u,onEntryFocus:h,onEscapeKeyDown:f,onPointerDownOutside:g,onFocusOutside:x,onInteractOutside:v,onDismiss:w,disableOutsideScroll:C,...j}=t,b=ao(wr,n),k=od(wr,n),N=Jm(n),T=_S(n),P=nD(n),[I,O]=m.useState(null),R=m.useRef(null),F=At(s,R,b.onContentChange),M=m.useRef(0),z=m.useRef(""),H=m.useRef(0),V=m.useRef(null),B=m.useRef("right"),Y=m.useRef(0),L=C?Wm:m.Fragment,K=C?{as:mD,allowPinchZoom:!0}:void 0,_=A=>{const W=z.current+A,U=P().filter(ue=>!ue.disabled),Q=document.activeElement,we=U.find(ue=>ue.ref.current===Q)?.textValue,_e=U.map(ue=>ue.textValue),Ie=SD(_e,W,we),Te=U.find(ue=>ue.textValue===Ie)?.ref.current;(function ue(Re){z.current=Re,window.clearTimeout(M.current),Re!==""&&(M.current=window.setTimeout(()=>ue(""),1e3))})(W),Te&&setTimeout(()=>Te.focus())};m.useEffect(()=>()=>window.clearTimeout(M.current),[]),Xg();const $=m.useCallback(A=>B.current===V.current?.side&&kD(A,V.current?.area),[]);return e.jsx(cD,{scope:n,searchRef:z,onItemEnter:m.useCallback(A=>{$(A)&&A.preventDefault()},[$]),onItemLeave:m.useCallback(A=>{$(A)||(R.current?.focus(),O(null))},[$]),onTriggerLeave:m.useCallback(A=>{$(A)&&A.preventDefault()},[$]),pointerGraceTimerRef:H,onPointerGraceIntentChange:m.useCallback(A=>{V.current=A},[]),children:e.jsx(L,{...K,children:e.jsx(Km,{asChild:!0,trapped:o,onMountAutoFocus:Ae(l,A=>{A.preventDefault(),R.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:d,children:e.jsx(ul,{asChild:!0,disableOutsidePointerEvents:u,onEscapeKeyDown:f,onPointerDownOutside:g,onFocusOutside:x,onInteractOutside:v,onDismiss:w,children:e.jsx(kS,{asChild:!0,...T,dir:k.dir,orientation:"vertical",loop:a,currentTabStopId:I,onCurrentTabStopIdChange:O,onEntryFocus:Ae(h,A=>{k.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(Wg,{role:"menu","aria-orientation":"vertical","data-state":YS(b.open),"data-radix-menu-content":"",dir:k.dir,...N,...j,ref:F,style:{outline:"none",...j.style},onKeyDown:Ae(j.onKeyDown,A=>{const U=A.target.closest("[data-radix-menu-content]")===A.currentTarget,Q=A.ctrlKey||A.altKey||A.metaKey,we=A.key.length===1;U&&(A.key==="Tab"&&A.preventDefault(),!Q&&we&&_(A.key));const _e=R.current;if(A.target!==_e||!eD.includes(A.key))return;A.preventDefault();const Te=P().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);TS.includes(A.key)&&Te.reverse(),bD(Te)}),onBlur:Ae(t.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(M.current),z.current="")}),onPointerMove:Ae(t.onPointerMove,Ac(A=>{const W=A.target,U=Y.current!==A.clientX;if(A.currentTarget.contains(W)&&U){const Q=A.clientX>Y.current?"right":"left";B.current=Q,Y.current=A.clientX}}))})})})})})})});DS.displayName=wr;var hD="MenuGroup",Nx=m.forwardRef((t,s)=>{const{__scopeMenu:n,...a}=t;return e.jsx(at.div,{role:"group",...a,ref:s})});Nx.displayName=hD;var fD="MenuLabel",OS=m.forwardRef((t,s)=>{const{__scopeMenu:n,...a}=t;return e.jsx(at.div,{...a,ref:s})});OS.displayName=fD;var tm="MenuItem",Tw="menu.itemSelect",eh=m.forwardRef((t,s)=>{const{disabled:n=!1,onSelect:a,...o}=t,l=m.useRef(null),d=od(tm,t.__scopeMenu),u=wx(tm,t.__scopeMenu),h=At(s,l),f=m.useRef(!1),g=()=>{const x=l.current;if(!n&&x){const v=new CustomEvent(Tw,{bubbles:!0,cancelable:!0});x.addEventListener(Tw,w=>a?.(w),{once:!0}),kg(x,v),v.defaultPrevented?f.current=!1:d.onClose()}};return e.jsx(MS,{...o,ref:h,disabled:n,onClick:Ae(t.onClick,g),onPointerDown:x=>{t.onPointerDown?.(x),f.current=!0},onPointerUp:Ae(t.onPointerUp,x=>{f.current||x.currentTarget?.click()}),onKeyDown:Ae(t.onKeyDown,x=>{const v=u.searchRef.current!=="";n||v&&x.key===" "||Gp.includes(x.key)&&(x.currentTarget.click(),x.preventDefault())})})});eh.displayName=tm;var MS=m.forwardRef((t,s)=>{const{__scopeMenu:n,disabled:a=!1,textValue:o,...l}=t,d=wx(tm,n),u=_S(n),h=m.useRef(null),f=At(s,h),[g,x]=m.useState(!1),[v,w]=m.useState("");return m.useEffect(()=>{const C=h.current;C&&w((C.textContent??"").trim())},[l.children]),e.jsx(Rc.ItemSlot,{scope:n,disabled:a,textValue:o??v,children:e.jsx(PS,{asChild:!0,...u,focusable:!a,children:e.jsx(at.div,{role:"menuitem","data-highlighted":g?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...l,ref:f,onPointerMove:Ae(t.onPointerMove,Ac(C=>{a?d.onItemLeave(C):(d.onItemEnter(C),C.defaultPrevented||C.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ae(t.onPointerLeave,Ac(C=>d.onItemLeave(C))),onFocus:Ae(t.onFocus,()=>x(!0)),onBlur:Ae(t.onBlur,()=>x(!1))})})})}),pD="MenuCheckboxItem",LS=m.forwardRef((t,s)=>{const{checked:n=!1,onCheckedChange:a,...o}=t;return e.jsx(BS,{scope:t.__scopeMenu,checked:n,children:e.jsx(eh,{role:"menuitemcheckbox","aria-checked":sm(n)?"mixed":n,...o,ref:s,"data-state":Cx(n),onSelect:Ae(o.onSelect,()=>a?.(sm(n)?!0:!n),{checkForDefaultPrevented:!1})})})});LS.displayName=pD;var FS="MenuRadioGroup",[gD,xD]=ro(FS,{value:void 0,onValueChange:()=>{}}),$S=m.forwardRef((t,s)=>{const{value:n,onValueChange:a,...o}=t,l=Rs(a);return e.jsx(gD,{scope:t.__scopeMenu,value:n,onValueChange:l,children:e.jsx(Nx,{...o,ref:s})})});$S.displayName=FS;var US="MenuRadioItem",zS=m.forwardRef((t,s)=>{const{value:n,...a}=t,o=xD(US,t.__scopeMenu),l=n===o.value;return e.jsx(BS,{scope:t.__scopeMenu,checked:l,children:e.jsx(eh,{role:"menuitemradio","aria-checked":l,...a,ref:s,"data-state":Cx(l),onSelect:Ae(a.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});zS.displayName=US;var Sx="MenuItemIndicator",[BS,vD]=ro(Sx,{checked:!1}),VS=m.forwardRef((t,s)=>{const{__scopeMenu:n,forceMount:a,...o}=t,l=vD(Sx,n);return e.jsx(gn,{present:a||sm(l.checked)||l.checked===!0,children:e.jsx(at.span,{...o,ref:s,"data-state":Cx(l.checked)})})});VS.displayName=Sx;var yD="MenuSeparator",qS=m.forwardRef((t,s)=>{const{__scopeMenu:n,...a}=t;return e.jsx(at.div,{role:"separator","aria-orientation":"horizontal",...a,ref:s})});qS.displayName=yD;var jD="MenuArrow",KS=m.forwardRef((t,s)=>{const{__scopeMenu:n,...a}=t,o=Jm(n);return e.jsx(Qg,{...o,...a,ref:s})});KS.displayName=jD;var wD="MenuSub",[fB,HS]=ro(wD),fc="MenuSubTrigger",WS=m.forwardRef((t,s)=>{const n=ao(fc,t.__scopeMenu),a=od(fc,t.__scopeMenu),o=HS(fc,t.__scopeMenu),l=wx(fc,t.__scopeMenu),d=m.useRef(null),{pointerGraceTimerRef:u,onPointerGraceIntentChange:h}=l,f={__scopeMenu:t.__scopeMenu},g=m.useCallback(()=>{d.current&&window.clearTimeout(d.current),d.current=null},[]);return m.useEffect(()=>g,[g]),m.useEffect(()=>{const x=u.current;return()=>{window.clearTimeout(x),h(null)}},[u,h]),e.jsx(yx,{asChild:!0,...f,children:e.jsx(MS,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":YS(n.open),...t,ref:Pm(s,o.onTriggerChange),onClick:x=>{t.onClick?.(x),!(t.disabled||x.defaultPrevented)&&(x.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ae(t.onPointerMove,Ac(x=>{l.onItemEnter(x),!x.defaultPrevented&&!t.disabled&&!n.open&&!d.current&&(l.onPointerGraceIntentChange(null),d.current=window.setTimeout(()=>{n.onOpenChange(!0),g()},100))})),onPointerLeave:Ae(t.onPointerLeave,Ac(x=>{g();const v=n.content?.getBoundingClientRect();if(v){const w=n.content?.dataset.side,C=w==="right",j=C?-5:5,b=v[C?"left":"right"],k=v[C?"right":"left"];l.onPointerGraceIntentChange({area:[{x:x.clientX+j,y:x.clientY},{x:b,y:v.top},{x:k,y:v.top},{x:k,y:v.bottom},{x:b,y:v.bottom}],side:w}),window.clearTimeout(u.current),u.current=window.setTimeout(()=>l.onPointerGraceIntentChange(null),300)}else{if(l.onTriggerLeave(x),x.defaultPrevented)return;l.onPointerGraceIntentChange(null)}})),onKeyDown:Ae(t.onKeyDown,x=>{const v=l.searchRef.current!=="";t.disabled||v&&x.key===" "||tD[a.dir].includes(x.key)&&(n.onOpenChange(!0),n.content?.focus(),x.preventDefault())})})})});WS.displayName=fc;var QS="MenuSubContent",GS=m.forwardRef((t,s)=>{const n=AS(wr,t.__scopeMenu),{forceMount:a=n.forceMount,...o}=t,l=ao(wr,t.__scopeMenu),d=od(wr,t.__scopeMenu),u=HS(QS,t.__scopeMenu),h=m.useRef(null),f=At(s,h);return e.jsx(Rc.Provider,{scope:t.__scopeMenu,children:e.jsx(gn,{present:a||l.open,children:e.jsx(Rc.Slot,{scope:t.__scopeMenu,children:e.jsx(bx,{id:u.contentId,"aria-labelledby":u.triggerId,...o,ref:f,align:"start",side:d.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:g=>{d.isUsingKeyboardRef.current&&h.current?.focus(),g.preventDefault()},onCloseAutoFocus:g=>g.preventDefault(),onFocusOutside:Ae(t.onFocusOutside,g=>{g.target!==u.trigger&&l.onOpenChange(!1)}),onEscapeKeyDown:Ae(t.onEscapeKeyDown,g=>{d.onClose(),g.preventDefault()}),onKeyDown:Ae(t.onKeyDown,g=>{const x=g.currentTarget.contains(g.target),v=sD[d.dir].includes(g.key);x&&v&&(l.onOpenChange(!1),u.trigger?.focus(),g.preventDefault())})})})})})});GS.displayName=QS;function YS(t){return t?"open":"closed"}function sm(t){return t==="indeterminate"}function Cx(t){return sm(t)?"indeterminate":t?"checked":"unchecked"}function bD(t){const s=document.activeElement;for(const n of t)if(n===s||(n.focus(),document.activeElement!==s))return}function ND(t,s){return t.map((n,a)=>t[(s+a)%t.length])}function SD(t,s,n){const o=s.length>1&&Array.from(s).every(f=>f===s[0])?s[0]:s,l=n?t.indexOf(n):-1;let d=ND(t,Math.max(l,0));o.length===1&&(d=d.filter(f=>f!==n));const h=d.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return h!==n?h:void 0}function CD(t,s){const{x:n,y:a}=t;let o=!1;for(let l=0,d=s.length-1;l<s.length;d=l++){const u=s[l].x,h=s[l].y,f=s[d].x,g=s[d].y;h>a!=g>a&&n<(f-u)*(a-h)/(g-h)+u&&(o=!o)}return o}function kD(t,s){if(!s)return!1;const n={x:t.clientX,y:t.clientY};return CD(n,s)}function Ac(t){return s=>s.pointerType==="mouse"?t(s):void 0}var PD=RS,TD=yx,ED=IS,_D=DS,RD=Nx,AD=OS,ID=eh,DD=LS,OD=$S,MD=zS,LD=VS,FD=qS,$D=KS,UD=WS,zD=GS,kx="DropdownMenu",[BD]=En(kx,[ES]),Un=ES(),[VD,ZS]=BD(kx),XS=t=>{const{__scopeDropdownMenu:s,children:n,dir:a,open:o,defaultOpen:l,onOpenChange:d,modal:u=!0}=t,h=Un(s),f=m.useRef(null),[g=!1,x]=Ur({prop:o,defaultProp:l,onChange:d});return e.jsx(VD,{scope:s,triggerId:jr(),triggerRef:f,contentId:jr(),open:g,onOpenChange:x,onOpenToggle:m.useCallback(()=>x(v=>!v),[x]),modal:u,children:e.jsx(PD,{...h,open:g,onOpenChange:x,dir:a,modal:u,children:n})})};XS.displayName=kx;var JS="DropdownMenuTrigger",eC=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...o}=t,l=ZS(JS,n),d=Un(n);return e.jsx(TD,{asChild:!0,...d,children:e.jsx(at.button,{type:"button",id:l.triggerId,"aria-haspopup":"menu","aria-expanded":l.open,"aria-controls":l.open?l.contentId:void 0,"data-state":l.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...o,ref:Pm(s,l.triggerRef),onPointerDown:Ae(t.onPointerDown,u=>{!a&&u.button===0&&u.ctrlKey===!1&&(l.onOpenToggle(),l.open||u.preventDefault())}),onKeyDown:Ae(t.onKeyDown,u=>{a||(["Enter"," "].includes(u.key)&&l.onOpenToggle(),u.key==="ArrowDown"&&l.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})});eC.displayName=JS;var qD="DropdownMenuPortal",tC=t=>{const{__scopeDropdownMenu:s,...n}=t,a=Un(s);return e.jsx(ED,{...a,...n})};tC.displayName=qD;var sC="DropdownMenuContent",nC=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...a}
56=t,o=ZS(sC,n),l=Un(n),d=m.useRef(!1);return e.jsx(_D,{id:o.contentId,"aria-labelledby":o.triggerId,...l,...a,ref:s,onCloseAutoFocus:Ae(t.onCloseAutoFocus,u=>{d.current||o.triggerRef.current?.focus(),d.current=!1,u.preventDefault()}),onInteractOutside:Ae(t.onInteractOutside,u=>{const h=u.detail.originalEvent,f=h.button===0&&h.ctrlKey===!0,g=h.button===2||f;(!o.modal||g)&&(d.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});nC.displayName=sC;var KD="DropdownMenuGroup",HD=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...a}=t,o=Un(n);return e.jsx(RD,{...o,...a,ref:s})});HD.displayName=KD;var WD="DropdownMenuLabel",rC=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...a}=t,o=Un(n);return e.jsx(AD,{...o,...a,ref:s})});rC.displayName=WD;var QD="DropdownMenuItem",aC=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...a}=t,o=Un(n);return e.jsx(ID,{...o,...a,ref:s})});aC.displayName=QD;var GD="DropdownMenuCheckboxItem",iC=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...a}=t,o=Un(n);return e.jsx(DD,{...o,...a,ref:s})});iC.displayName=GD;var YD="DropdownMenuRadioGroup",ZD=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...a}=t,o=Un(n);return e.jsx(OD,{...o,...a,ref:s})});ZD.displayName=YD;var XD="DropdownMenuRadioItem",oC=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...a}=t,o=Un(n);return e.jsx(MD,{...o,...a,ref:s})});oC.displayName=XD;var JD="DropdownMenuItemIndicator",lC=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...a}=t,o=Un(n);return e.jsx(LD,{...o,...a,ref:s})});lC.displayName=JD;var eO="DropdownMenuSeparator",cC=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...a}=t,o=Un(n);return e.jsx(FD,{...o,...a,ref:s})});cC.displayName=eO;var tO="DropdownMenuArrow",sO=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...a}=t,o=Un(n);return e.jsx($D,{...o,...a,ref:s})});sO.displayName=tO;var nO="DropdownMenuSubTrigger",dC=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...a}=t,o=Un(n);return e.jsx(UD,{...o,...a,ref:s})});dC.displayName=nO;var rO="DropdownMenuSubContent",uC=m.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...a}=t,o=Un(n);return e.jsx(zD,{...o,...a,ref:s,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});uC.displayName=rO;var aO=XS,iO=eC,oO=tC,mC=nC,hC=rC,fC=aC,pC=iC,gC=oC,xC=lC,vC=cC,yC=dC,jC=uC;const Gi=aO,Yi=iO,lO=m.forwardRef(({className:t,inset:s,children:n,...a},o)=>e.jsxs(yC,{ref:o,className:Oe("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...a,children:[n,e.jsx(Bt,{className:"ml-auto"})]}));lO.displayName=yC.displayName;const cO=m.forwardRef(({className:t,...s},n)=>e.jsx(jC,{ref:n,className:Oe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...s}));cO.displayName=jC.displayName;const pi=m.forwardRef(({className:t,sideOffset:s=4,...n},a)=>e.jsx(oO,{children:e.jsx(mC,{ref:a,sideOffset:s,className:Oe("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
56de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...n})}));pi.displayName=mC.displayName;const on=m.forwardRef(({className:t,inset:s,...n},a)=>e.jsx(fC,{ref:a,className:Oe("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...n}));on.displayName=fC.displayName;const dO=m.forwardRef(({className:t,children:s,checked:n,...a},o)=>e.jsxs(pC,{ref:o,className:Oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:n,...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(xC,{children:e.jsx(yr,{className:"h-4 w-4"})})}),s]}));dO.displayName=pC.displayName;const uO=m.forwardRef(({className:t,children:s,...n},a)=>e.jsxs(gC,{ref:a,className:Oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(xC,{children:e.jsx(Vu,{className:"h-2 w-2 fill-current"})})}),s]}));uO.displayName=gC.displayName;const mO=m.forwardRef(({className:t,inset:s,...n},a)=>e.jsx(hC,{ref:a,className:Oe("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...n}));mO.displayName=hC.displayName;const Px=m.forwardRef(({className:t,...s},n)=>e.jsx(vC,{ref:n,className:Oe("-mx-1 my-1 h-px bg-muted",t),...s}));Px.displayName=vC.displayName;const Tx={super_admin:"Super Admin",admin:"Admin",support:"Support",billing:"Billing"};function hO({currentView:t,onViewChange:s,onLogout:n}){const a=[{id:"dashboard",label:"Dashboard",icon:cE}],o=[{id:"clients",label:"Clients",icon:Bs},{id:"procedures",label:"All Procedures",icon:Pt},{id:"overviews",label:"All Overviews",icon:ln}],l=[{id:"email-templates",label:"Email Templates",icon:Ta},{id:"automations",label:"Automations",icon:Wu},{id:"newsletters",label:"Newsletters",icon:wN},{id:"announcements",label:"Announcements",icon:no}],d=[{id:"analytics",label:"Analytics",icon:Am},{id:"platform-users",label:"Platform Users",icon:Ag},{id:"canceled-accounts",label:"Canceled Accounts",icon:sE},{id:"notification-preferences",label:"Notifications",icon:rE}],u=[{id:"segments",label:"Segments",icon:Lm},{id:"site-settings",label:"Site Settings",icon:Jc}],{user:h}=Da();return e.jsxs(gS,{children:[e.jsx(vS,{className:"p-4 border-b border-sidebar-border",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ht,{href:"/admin",children:e.jsx("span",{className:"font-serif text-2xl cursor-pointer","data-testid":"link-admin-logo",children:"outliner"})}),e.jsx(Ce,{variant:"secondary",className:"text-xs",children:"Admin"})]})}),e.jsxs(jS,{children:[e.jsx(Mo,{children:e.jsx(Lo,{children:e.jsx(Fo,{children:a.map(f=>e.jsx($o,{children:e.jsxs(Uo,{onClick:()=>s(f.id),isActive:t===f.id,"data-testid":`button-admin-nav-${f.id}`,children:[e.jsx(f.icon,{className:"h-4 w-4"}),e.jsx("span",{children:f.label})]})},f.id))})})}),e.jsx(Cn,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(Mo,{children:[e.jsx(Mn,{asChild:!0,children:e.jsxs(hc,{className:"cursor-pointer flex items-center justify-between",children:["CRM",e.jsx(On,{className:"h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-180"})]})}),e.jsx(Ln,{children:e.jsx(Lo,{children:e.jsx(Fo,{children:o.map(f=>e.jsx($o,{children:e.jsxs(Uo,{onClick:()=>s(f.id),isActive:t===f.id,"data-testid":`button-admin-nav-${f.id}`,children:[e.jsx(f.icon,{className:"h-4 w-4"}),e.jsx("span",{children:f.label})]})},f.id))})})})]})}),e.jsx(Cn,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(Mo,{children:[e.jsx(Mn,{asChild:!0,children:e.jsxs(hc,{className:"cursor-pointer flex items-center justify-between",children:["Communications",e.
56jsx(On,{className:"h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-180"})]})}),e.jsx(Ln,{children:e.jsx(Lo,{children:e.jsx(Fo,{children:l.map(f=>e.jsx($o,{children:e.jsxs(Uo,{onClick:()=>s(f.id),isActive:t===f.id,"data-testid":`button-admin-nav-${f.id}`,children:[e.jsx(f.icon,{className:"h-4 w-4"}),e.jsx("span",{children:f.label})]})},f.id))})})})]})}),e.jsx(Cn,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(Mo,{children:[e.jsx(Mn,{asChild:!0,children:e.jsxs(hc,{className:"cursor-pointer flex items-center justify-between",children:["Platform",e.jsx(On,{className:"h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-180"})]})}),e.jsx(Ln,{children:e.jsx(Lo,{children:e.jsx(Fo,{children:d.map(f=>e.jsx($o,{children:e.jsxs(Uo,{onClick:()=>s(f.id),isActive:t===f.id,"data-testid":`button-admin-nav-${f.id}`,children:[e.jsx(f.icon,{className:"h-4 w-4"}),e.jsx("span",{children:f.label})]})},f.id))})})})]})}),e.jsx(Cn,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(Mo,{children:[e.jsx(Mn,{asChild:!0,children:e.jsxs(hc,{className:"cursor-pointer flex items-center justify-between",children:["Tools",e.jsx(On,{className:"h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-180"})]})}),e.jsx(Ln,{children:e.jsx(Lo,{children:e.jsx(Fo,{children:u.map(f=>e.jsx($o,{children:e.jsxs(Uo,{onClick:()=>s(f.id),isActive:t===f.id,"data-testid":`button-admin-nav-${f.id}`,children:[e.jsx(f.icon,{className:"h-4 w-4"}),e.jsx("span",{children:f.label})]})},f.id))})})})]})})]}),e.jsx(yS,{className:"p-3 border-t border-sidebar-border",children:e.jsxs(Gi,{children:[e.jsx(Yi,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-3 w-full p-2 rounded-md hover-elevate text-left","data-testid":"button-admin-user-menu",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center text-sm font-semibold",children:h?.firstName?.charAt(0).toUpperCase()||"A"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:h?`${h.firstName} ${h.lastName}`:"Admin"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:Tx[h?.role]||h?.role||"Admin"})]}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"})]})}),e.jsxs(pi,{align:"end",className:"w-56",children:[e.jsxs(on,{onClick:()=>s("my-profile"),"data-testid":"button-go-to-my-profile",children:[e.jsx(Hr,{className:"h-4 w-4 mr-2"}),"My Profile"]}),e.jsx(Px,{}),e.jsxs(on,{onClick:n,"data-testid":"button-admin-logout",children:[e.jsx(Om,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})})]})}function fO({view:t}){const s={dashboard:"Dashboard",clients:"Clients",procedures:"Procedures",overviews:"Overviews",editor:"Editor","email-templates":"Email Templates",automations:"Automations",segments:"Segments",newsletters:"Newsletters",announcements:"Announcements","announcements-create":"Create Announcement","announcements-edit":"Edit Announcement","platform-users":"Platform Users","my-profile":"My Profile","notification-preferences":"Notifications","site-settings":"Site Settings",analytics:"Analytics"};return e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Admin"}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:s[t]})]})}function Yp(){const{toast:t}=dt(),[s,n]=m.useState(!1),[a,o]=m.useState(""),[l,d]=m.useState(""),u=ye({mutationFn:async h=>ce("POST","/api/clients",h),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/clients"]}),t({title:"Client created successfully"}),n(!1),o(""),d("")},onError:()=>{t({title:"Failed to create client",variant:"destructive"})}});return e.jsxs(St,{open:s,onOpenChange:n,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{size:"sm","data-testid":"button-create-client",children:[e.jsx(ds,{className:"h-4 w-4 mr-1"}),"Add Client"]})}),e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Create New Client"}),e.jsx(Gt,{children:"Add a new client organization to manage their procedures."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"client-name",children:"Client Name"}),e.jsx(fe,{id:"client-name",value:a,onChange:h=>{o(h.target.value),d(h.target.value.toLowerCase().replace(/\s+/g,"-"))},placeholder:"Acme Corporation","data-testid":"input-new-client-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"client-slug",children:"URL Slug"}
56),e.jsx(fe,{id:"client-slug",value:l,onChange:h=>d(h.target.value),placeholder:"acme-corp","data-testid":"input-new-client-slug"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Knowledge base will be accessible at /kb/",l||"slug"]})]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(D,{onClick:()=>u.mutate({name:a,slug:l,status:"active"}),disabled:!a||!l||u.isPending,"data-testid":"button-confirm-create-client",children:"Create Client"})]})]})]})}function pO({onSelectClient:t}){const{data:s,isLoading:n}=je({queryKey:["/api/clients"]}),{data:a,isLoading:o}=je({queryKey:["/api/procedures"]}),l=[{label:"Total Clients",value:s?.length||0,icon:Bs},{label:"Total Procedures",value:a?.length||0,icon:Pt},{label:"Published",value:a?.filter(d=>d.status==="published").length||0,icon:Sr},{label:"Drafts",value:a?.filter(d=>d.status==="draft").length||0,icon:Ia}];return e.jsxs("div",{className:"space-y-8 max-w-6xl",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-serif text-2xl md:text-3xl font-normal tracking-tight",children:"Dashboard"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage your clients and their procedures"})]}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-4",children:l.map((d,u)=>e.jsx(ee,{className:"border-border/50",children:e.jsx(te,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:d.label}),e.jsx("div",{className:"text-2xl font-semibold mt-1",children:n||o?e.jsx(be,{className:"h-8 w-12"}):d.value})]}),e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(d.icon,{className:"h-5 w-5 text-primary"})})]})})},u))}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-medium text-lg",children:"Recent Clients"}),e.jsx(Yp,{})]}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:n?[1,2,3].map(d=>e.jsx(be,{className:"h-32"},d)):s?.length===0?e.jsx(ee,{className:"border-border/50 col-span-full",children:e.jsxs(te,{className:"p-8 text-center",children:[e.jsx(Bs,{className:"h-10 w-10 text-muted-foreground/50 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No clients yet. Create your first client to get started."})]})}):s?.slice(0,6).map(d=>e.jsx(ee,{className:"border-border/50 hover-elevate cursor-pointer",onClick:()=>t(d.slug),"data-testid":`card-client-${d.id}`,children:e.jsx(te,{className:"p-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"font-medium",children:d.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["/",d.slug]})]}),e.jsx(Ce,{variant:d.status==="active"?"default":"secondary",children:d.status})]})})},d.id))})]})]})}function gO(){for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return m.useMemo(()=>a=>{s.forEach(o=>o(a))},s)}const th=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function wl(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function Ex(t){return"nodeType"in t}function Xn(t){var s,n;return t?wl(t)?t:Ex(t)&&(s=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?s:window:window}function _x(t){const{Document:s}=Xn(t);return t instanceof s}function ld(t){return wl(t)?!1:t instanceof Xn(t).HTMLElement}function wC(t){return t instanceof Xn(t).SVGElement}function bl(t){return t?wl(t)?t.document:Ex(t)?_x(t)?t:ld(t)||wC(t)?t.ownerDocument:document:document:document}const la=th?m.useLayoutEffect:m.useEffect;function Rx(t){const s=m.useRef(t);return la(()=>{s.current=t}),m.useCallback(function(){for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];return s.current==null?void 0:s.current(...a)},[])}function xO(){const t=m.useRef(null),s=m.useCallback((a,o)=>{t.current=setInterval(a,o)},[]),n=m.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,n]}function Ic(t,s){s===void 0&&(s=[t]);const n=m.useRef(t);return la(()=>{n.current!==t&&(n.current=t)},s),n}function cd(t,s){const n=m.useRef();return m.useMemo(()=>{const a=t(n.current);return n.current=a,a},[...s])}function nm(t){const s=Rx(t),n=m.useRef(null),a=m.useCallback(o=>{o!==n.current&&s?.(o,n.current),n.current=o},[]);return[n,a]}function Zp(t){const s=m.useRef();return m.useEffect(()=>{s.current=t},[t]),s.current}let xp={};function dd(t,s){return m.useMemo(()=>
56{if(s)return s;const n=xp[t]==null?0:xp[t]+1;return xp[t]=n,t+"-"+n},[t,s])}function bC(t){return function(s){for(var n=arguments.length,a=new Array(n>1?n-1:0),o=1;o<n;o++)a[o-1]=arguments[o];return a.reduce((l,d)=>{const u=Object.entries(d);for(const[h,f]of u){const g=l[h];g!=null&&(l[h]=g+t*f)}return l},{...s})}}const Qo=bC(1),Dc=bC(-1);function vO(t){return"clientX"in t&&"clientY"in t}function Ax(t){if(!t)return!1;const{KeyboardEvent:s}=Xn(t.target);return s&&t instanceof s}function yO(t){if(!t)return!1;const{TouchEvent:s}=Xn(t.target);return s&&t instanceof s}function Xp(t){if(yO(t)){if(t.touches&&t.touches.length){const{clientX:s,clientY:n}=t.touches[0];return{x:s,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:s,clientY:n}=t.changedTouches[0];return{x:s,y:n}}}return vO(t)?{x:t.clientX,y:t.clientY}:null}const gi=Object.freeze({Translate:{toString(t){if(!t)return;const{x:s,y:n}=t;return"translate3d("+(s?Math.round(s):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:s,scaleY:n}=t;return"scaleX("+s+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[gi.Translate.toString(t),gi.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:n,easing:a}=t;return s+" "+n+"ms "+a}}}),Ew="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function jO(t){return t.matches(Ew)?t:t.querySelector(Ew)}const wO={display:"none"};function bO(t){let{id:s,value:n}=t;return Os.createElement("div",{id:s,style:wO},n)}function NO(t){let{id:s,announcement:n,ariaLiveType:a="assertive"}=t;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Os.createElement("div",{id:s,style:o,role:"status","aria-live":a,"aria-atomic":!0},n)}function SO(){const[t,s]=m.useState("");return{announce:m.useCallback(a=>{a!=null&&s(a)},[]),announcement:t}}const NC=m.createContext(null);function CO(t){const s=m.useContext(NC);m.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(t)},[t,s])}function kO(){const[t]=m.useState(()=>new Set),s=m.useCallback(a=>(t.add(a),()=>t.delete(a)),[t]);return[m.useCallback(a=>{let{type:o,event:l}=a;t.forEach(d=>{var u;return(u=d[o])==null?void 0:u.call(d,l)})},[t]),s]}const PO={draggable:`
57    To pick up a draggable item, press the space bar.
58    While dragging, use the arrow keys to move the item.
59    Press space again to drop the item in its new position, or press escape to cancel.
60  `},TO={onDragStart(t){let{active:s}=t;return"Picked up draggable item "+s.id+"."},onDragOver(t){let{active:s,over:n}=t;return n?"Draggable item "+s.id+" was moved over droppable area "+n.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(t){let{active:s,over:n}=t;return n?"Draggable item "+s.id+" was dropped over droppable area "+n.id:"Draggable item "+s.id+" was dropped."},onDragCancel(t){let{active:s}=t;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function EO(t){let{announcements:s=TO,container:n,hiddenTextDescribedById:a,screenReaderInstructions:o=PO}=t;const{announce:l,announcement:d}=SO(),u=dd("DndLiveRegion"),[h,f]=m.useState(!1);if(m.useEffect(()=>{f(!0)},[]),CO(m.useMemo(()=>({onDragStart(x){let{active:v}=x;l(s.onDragStart({active:v}))},onDragMove(x){let{active:v,over:w}=x;s.onDragMove&&l(s.onDragMove({active:v,over:w}))},onDragOver(x){let{active:v,over:w}=x;l(s.onDragOver({active:v,over:w}))},onDragEnd(x){let{active:v,over:w}=x;l(s.onDragEnd({active:v,over:w}))},onDragCancel(x){let{active:v,over:w}=x;l(s.onDragCancel({active:v,over:w}))}}),[l,s])),!h)return null;const g=Os.createElement(Os.Fragment,null,Os.createElement(bO,{id:a,value:o.draggable}),Os.createElement(NO,{id:u,announcement:d}));return n?Mr.createPortal(g,n):g}var Xs;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Xs||(Xs={}));function rm(){}function al(t,s){return m.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function Ix(){for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return m.useMemo(()=>[...s].filter(a=>a!=null),[...s])}const Vr=Object.freeze({x:0,y:0});function SC(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function CC(t,s){let{data:{value:n}}=t,{data:{value:a}}=s;return n-a}function _O(t,s){let{data:{value:n}}=t,{data:{value:a}}=s;return a-n}function _w(t){let{left:s,top:n,height:a,width:o}=t;return[{x:s,y:n},{x:s+o,y:n},{x:s,y:n+a},{x:s+o,y:n+a}]}function kC(t,s){if(!t||t.length===0)return null;const[n]=t;return n[s]}function Rw(t,s,n){return s===void 0&&(s=t.left),n===void 0&&(n=t.to
60p),{x:s+t.width*.5,y:n+t.height*.5}}const am=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:a}=t;const o=Rw(s,s.left,s.top),l=[];for(const d of a){const{id:u}=d,h=n.get(u);if(h){const f=SC(Rw(h),o);l.push({id:u,data:{droppableContainer:d,value:f}})}}return l.sort(CC)},RO=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:a}=t;const o=_w(s),l=[];for(const d of a){const{id:u}=d,h=n.get(u);if(h){const f=_w(h),g=o.reduce((v,w,C)=>v+SC(f[C],w),0),x=Number((g/4).toFixed(4));l.push({id:u,data:{droppableContainer:d,value:x}})}}return l.sort(CC)};function AO(t,s){const n=Math.max(s.top,t.top),a=Math.max(s.left,t.left),o=Math.min(s.left+s.width,t.left+t.width),l=Math.min(s.top+s.height,t.top+t.height),d=o-a,u=l-n;if(a<o&&n<l){const h=s.width*s.height,f=t.width*t.height,g=d*u,x=g/(h+f-g);return Number(x.toFixed(4))}return 0}const IO=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:a}=t;const o=[];for(const l of a){const{id:d}=l,u=n.get(d);if(u){const h=AO(u,s);h>0&&o.push({id:d,data:{droppableContainer:l,value:h}})}}return o.sort(_O)};function DO(t,s,n){return{...t,scaleX:s&&n?s.width/n.width:1,scaleY:s&&n?s.height/n.height:1}}function PC(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:Vr}function OO(t){return function(n){for(var a=arguments.length,o=new Array(a>1?a-1:0),l=1;l<a;l++)o[l-1]=arguments[l];return o.reduce((d,u)=>({...d,top:d.top+t*u.y,bottom:d.bottom+t*u.y,left:d.left+t*u.x,right:d.right+t*u.x}),{...n})}}const MO=OO(1);function LO(t){if(t.startsWith("matrix3d(")){const s=t.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(t.startsWith("matrix(")){const s=t.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function FO(t,s,n){const a=LO(s);if(!a)return t;const{scaleX:o,scaleY:l,x:d,y:u}=a,h=t.left-d-(1-o)*parseFloat(n),f=t.top-u-(1-l)*parseFloat(n.slice(n.indexOf(" ")+1)),g=o?t.width/o:t.width,x=l?t.height/l:t.height;return{width:g,height:x,top:f,right:h+g,bottom:f+x,left:h}}const $O={ignoreTransform:!1};function Nl(t,s){s===void 0&&(s=$O);let n=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:f,transformOrigin:g}=Xn(t).getComputedStyle(t);f&&(n=FO(n,f,g))}const{top:a,left:o,width:l,height:d,bottom:u,right:h}=n;return{top:a,left:o,width:l,height:d,bottom:u,right:h}}function Aw(t){return Nl(t,{ignoreTransform:!0})}function UO(t){const s=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:s,bottom:n,width:s,height:n}}function zO(t,s){return s===void 0&&(s=Xn(t).getComputedStyle(t)),s.position==="fixed"}function BO(t,s){s===void 0&&(s=Xn(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const l=s[o];return typeof l=="string"?n.test(l):!1})}function sh(t,s){const n=[];function a(o){if(s!=null&&n.length>=s||!o)return n;if(_x(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!ld(o)||wC(o)||n.includes(o))return n;const l=Xn(t).getComputedStyle(o);return o!==t&&BO(o,l)&&n.push(o),zO(o,l)?n:a(o.parentNode)}return t?a(t):n}function TC(t){const[s]=sh(t,1);return s??null}function vp(t){return!th||!t?null:wl(t)?t:Ex(t)?_x(t)||t===bl(t).scrollingElement?window:ld(t)?t:null:null}function EC(t){return wl(t)?t.scrollX:t.scrollLeft}function _C(t){return wl(t)?t.scrollY:t.scrollTop}function Jp(t){return{x:EC(t),y:_C(t)}}var an;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(an||(an={}));function RC(t){return!th||!t?!1:t===document.scrollingElement}function AC(t){const s={x:0,y:0},n=RC(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},a={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},o=t.scrollTop<=s.y,l=t.scrollLeft<=s.x,d=t.scrollTop>=a.y,u=t.scrollLeft>=a.x;return{isTop:o,isLeft:l,isBottom:d,isRight:u,maxScroll:a,minScroll:s}}const VO={x:.2,y:.2};function qO(t,s,n,a,o){let{top:l,left:d,right:u,bottom:h}=n;a===void 0&&(a=10),o===void 0&&(o=VO);const{isTop:f,isBottom:g,isLeft:x,isRight:v}=AC(t),w={x:0,y:0},C={x:0,y:0},j={height:s.height*o.y,width:s.width*o.x};return!f&&l<=s.top+j.height?(w.y=an.Backward,C.y=a*Math.abs((s.top+j.height-l)/j.height)):!g&&h>=s.bottom-j.height&&(w.y=an.Forward,C.y=a*Math.abs((s.bottom-j.height-h)/j.height)),!v&&u>=s.right-j.width?(w.x=an.Forward,C.x=a*Math.abs((s.right-j.width-u)/j.width)):!x&&d<=s.left+j.width&&(w.x=an.Backward,C.x=a*Math.abs((s.left+j.width-d)/j.width)),{direction:w,speed:C}}function KO(t){if(t===document.scrollingElement){const{innerWidth:l,innerHe
60ight:d}=window;return{top:0,left:0,right:l,bottom:d,width:l,height:d}}const{top:s,left:n,right:a,bottom:o}=t.getBoundingClientRect();return{top:s,left:n,right:a,bottom:o,width:t.clientWidth,height:t.clientHeight}}function IC(t){return t.reduce((s,n)=>Qo(s,Jp(n)),Vr)}function HO(t){return t.reduce((s,n)=>s+EC(n),0)}function WO(t){return t.reduce((s,n)=>s+_C(n),0)}function QO(t,s){if(s===void 0&&(s=Nl),!t)return;const{top:n,left:a,bottom:o,right:l}=s(t);TC(t)&&(o<=0||l<=0||n>=window.innerHeight||a>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const GO=[["x",["left","right"],HO],["y",["top","bottom"],WO]];class Dx{constructor(s,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const a=sh(n),o=IC(a);this.rect={...s},this.width=s.width,this.height=s.height;for(const[l,d,u]of GO)for(const h of d)Object.defineProperty(this,h,{get:()=>{const f=u(a),g=o[l]-f;return this.rect[h]+g},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class wc{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var a;return(a=this.target)==null?void 0:a.removeEventListener(...n)})},this.target=s}add(s,n,a){var o;(o=this.target)==null||o.addEventListener(s,n,a),this.listeners.push([s,n,a])}}function YO(t){const{EventTarget:s}=Xn(t);return t instanceof s?t:bl(t)}function yp(t,s){const n=Math.abs(t.x),a=Math.abs(t.y);return typeof s=="number"?Math.sqrt(n**2+a**2)>s:"x"in s&&"y"in s?n>s.x&&a>s.y:"x"in s?n>s.x:"y"in s?a>s.y:!1}var vr;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(vr||(vr={}));function Iw(t){t.preventDefault()}function ZO(t){t.stopPropagation()}var Vt;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Vt||(Vt={}));const DC={start:[Vt.Space,Vt.Enter],cancel:[Vt.Esc],end:[Vt.Space,Vt.Enter,Vt.Tab]},XO=(t,s)=>{let{currentCoordinates:n}=s;switch(t.code){case Vt.Right:return{...n,x:n.x+25};case Vt.Left:return{...n,x:n.x-25};case Vt.Down:return{...n,y:n.y+25};case Vt.Up:return{...n,y:n.y-25}}};class ud{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:n}}=s;this.props=s,this.listeners=new wc(bl(n)),this.windowListeners=new wc(Xn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(vr.Resize,this.handleCancel),this.windowListeners.add(vr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(vr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:n}=this.props,a=s.node.current;a&&QO(a),n(Vr)}handleKeyDown(s){if(Ax(s)){const{active:n,context:a,options:o}=this.props,{keyboardCodes:l=DC,coordinateGetter:d=XO,scrollBehavior:u="smooth"}=o,{code:h}=s;if(l.end.includes(h)){this.handleEnd(s);return}if(l.cancel.includes(h)){this.handleCancel(s);return}const{collisionRect:f}=a.current,g=f?{x:f.left,y:f.top}:Vr;this.referenceCoordinates||(this.referenceCoordinates=g);const x=d(s,{active:n,context:a.current,currentCoordinates:g});if(x){const v=Dc(x,g),w={x:0,y:0},{scrollableAncestors:C}=a.current;for(const j of C){const b=s.code,{isTop:k,isRight:N,isLeft:T,isBottom:P,maxScroll:I,minScroll:O}=AC(j),R=KO(j),F={x:Math.min(b===Vt.Right?R.right-R.width/2:R.right,Math.max(b===Vt.Right?R.left:R.left+R.width/2,x.x)),y:Math.min(b===Vt.Down?R.bottom-R.height/2:R.bottom,Math.max(b===Vt.Down?R.top:R.top+R.height/2,x.y))},M=b===Vt.Right&&!N||b===Vt.Left&&!T,z=b===Vt.Down&&!P||b===Vt.Up&&!k;if(M&&F.x!==x.x){const H=j.scrollLeft+v.x,V=b===Vt.Right&&H<=I.x||b===Vt.Left&&H>=O.x;if(V&&!v.y){j.scrollTo({left:H,behavior:u});return}V?w.x=j.scrollLeft-H:w.x=b===Vt.Right?j.scrollLeft-I.x:j.scrollLeft-O.x,w.x&&j.scrollBy({left:-w.x,behavior:u});break}else if(z&&F.y!==x.y){const H=j.scrollTop+v.y,V=b===Vt.Down&&H<=I.y||b===Vt.Up&&H>=O.y;if(V&&!v.x){j.scrollTo({top:H,behavior:u});return}V?w.y=j.scrollTop-H:w.y=b===Vt.Down?j.scrollTop-I.y:j.scrollTop-O.y,w.y&&j.scrollBy({top:-w.y,behavior:u});break}}
60this.handleMove(s,Qo(Dc(x,this.referenceCoordinates),w))}}}handleMove(s,n){const{onMove:a}=this.props;s.preventDefault(),a(n)}handleEnd(s){const{onEnd:n}=this.props;s.preventDefault(),this.detach(),n()}handleCancel(s){const{onCancel:n}=this.props;s.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}ud.activators=[{eventName:"onKeyDown",handler:(t,s,n)=>{let{keyboardCodes:a=DC,onActivation:o}=s,{active:l}=n;const{code:d}=t.nativeEvent;if(a.start.includes(d)){const u=l.activatorNode.current;return u&&t.target!==u?!1:(t.preventDefault(),o?.({event:t.nativeEvent}),!0)}return!1}}];function Dw(t){return!!(t&&"distance"in t)}function Ow(t){return!!(t&&"delay"in t)}class Ox{constructor(s,n,a){var o;a===void 0&&(a=YO(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=n;const{event:l}=s,{target:d}=l;this.props=s,this.events=n,this.document=bl(d),this.documentListeners=new wc(this.document),this.listeners=new wc(a),this.windowListeners=new wc(Xn(d)),this.initialCoordinates=(o=Xp(l))!=null?o:Vr,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:n,bypassActivationConstraint:a}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(vr.Resize,this.handleCancel),this.windowListeners.add(vr.DragStart,Iw),this.windowListeners.add(vr.VisibilityChange,this.handleCancel),this.windowListeners.add(vr.ContextMenu,Iw),this.documentListeners.add(vr.Keydown,this.handleKeydown),n){if(a!=null&&a({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ow(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Dw(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,n){const{active:a,onPending:o}=this.props;o(a,s,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:s}=this,{onStart:n}=this.props;s&&(this.activated=!0,this.documentListeners.add(vr.Click,ZO,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(vr.SelectionChange,this.removeTextSelection),n(s))}handleMove(s){var n;const{activated:a,initialCoordinates:o,props:l}=this,{onMove:d,options:{activationConstraint:u}}=l;if(!o)return;const h=(n=Xp(s))!=null?n:Vr,f=Dc(o,h);if(!a&&u){if(Dw(u)){if(u.tolerance!=null&&yp(f,u.tolerance))return this.handleCancel();if(yp(f,u.distance))return this.handleStart()}if(Ow(u)&&yp(f,u.tolerance))return this.handleCancel();this.handlePending(u,f);return}
60s.cancelable&&s.preventDefault(),d(h)}handleEnd(){const{onAbort:s,onEnd:n}=this.props;this.detach(),this.activated||s(this.props.active),n()}handleCancel(){const{onAbort:s,onCancel:n}=this.props;this.detach(),this.activated||s(this.props.active),n()}handleKeydown(s){s.code===Vt.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const JO={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class md extends Ox{constructor(s){const{event:n}=s,a=bl(n.target);super(s,JO,a)}}md.activators=[{eventName:"onPointerDown",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:a}=s;return!n.isPrimary||n.button!==0?!1:(a?.({event:n}),!0)}}];const eM={move:{name:"mousemove"},end:{name:"mouseup"}};var eg;(function(t){t[t.RightClick=2]="RightClick"})(eg||(eg={}));class tM extends Ox{constructor(s){super(s,eM,bl(s.event.target))}}tM.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:a}=s;return n.button===eg.RightClick?!1:(a?.({event:n}),!0)}}];const jp={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class sM extends Ox{constructor(s){super(s,jp)}static setup(){return window.addEventListener(jp.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(jp.move.name,s)};function s(){}}}sM.activators=[{eventName:"onTouchStart",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:a}=s;const{touches:o}=n;return o.length>1?!1:(a?.({event:n}),!0)}}];var bc;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(bc||(bc={}));var im;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(im||(im={}));function nM(t){let{acceleration:s,activator:n=bc.Pointer,canScroll:a,draggingRect:o,enabled:l,interval:d=5,order:u=im.TreeOrder,pointerCoordinates:h,scrollableAncestors:f,scrollableAncestorRects:g,delta:x,threshold:v}=t;const w=aM({delta:x,disabled:!l}),[C,j]=xO(),b=m.useRef({x:0,y:0}),k=m.useRef({x:0,y:0}),N=m.useMemo(()=>{switch(n){case bc.Pointer:return h?{top:h.y,bottom:h.y,left:h.x,right:h.x}:null;case bc.DraggableRect:return o}},[n,o,h]),T=m.useRef(null),P=m.useCallback(()=>{const O=T.current;if(!O)return;const R=b.current.x*k.current.x,F=b.current.y*k.current.y;O.scrollBy(R,F)},[]),I=m.useMemo(()=>u===im.TreeOrder?[...f].reverse():f,[u,f]);m.useEffect(()=>{if(!l||!f.length||!N){j();return}for(const O of I){if(a?.(O)===!1)continue;const R=f.indexOf(O),F=g[R];if(!F)continue;const{direction:M,speed:z}=qO(O,F,N,s,v);for(const H of["x","y"])w[H][M[H]]||(z[H]=0,M[H]=0);if(z.x>0||z.y>0){j(),T.current=O,C(P,d),b.current=z,k.current=M;return}}b.current={x:0,y:0},k.current={x:0,y:0},j()},[s,P,a,j,l,d,JSON.stringify(N),JSON.stringify(w),C,f,I,g,JSON.stringify(v)])}const rM={x:{[an.Backward]:!1,[an.Forward]:!1},y:{[an.Backward]:!1,[an.Forward]:!1}};function aM(t){let{delta:s,disabled:n}=t;const a=Zp(s);return cd(o=>{if(n||!a||!o)return rM;const l={x:Math.sign(s.x-a.x),y:Math.sign(s.y-a.y)};return{x:{[an.Backward]:o.x[an.Backward]||l.x===-1,[an.Forward]:o.x[an.Forward]||l.x===1},y:{[an.Backward]:o.y[an.Backward]||l.y===-1,[an.Forward]:o.y[an.Forward]||l.y===1}}},[n,s,a])}function iM(t,s){const n=s!=null?t.get(s):void 0,a=n?n.node.current:null;return cd(o=>{var l;return s==null?null:(l=a??o)!=null?l:null},[a,s])}function oM(t,s){return m.useMemo(()=>t.reduce((n,a)=>{const{sensor:o}=a,l=o.activators.map(d=>({eventName:d.eventName,handler:s(d.handler,a)}));return[...n,...l]},[]),[t,s])}var Oc;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Oc||(Oc={}));var tg;(function(t){t.Optimized="optimized"})(tg||(tg={}));const Mw=new Map;function lM(t,s){let{dragging:n,dependencies:a,config:o}=s;const[l,d]=m.useState(null),{frequency:u,measure:h,strategy:f}=o,g=m.useRef(t),x=b(),v=Ic(x),w=m.useCallback(function(k){k===void 0&&(k=[]),!v.current&&d(N=>N===null?k:N.concat(k.filter(T=>!N.includes(T))))},[v]),C=m.useRef(null),j=cd(k=>{if(x&&!n)return Mw;if(!k||k===Mw||g.current!==t||l!=null){const N=new Map;for(let T of t){if(!T)continue;if(l&&l.length>0&&!l.includes(T.id)&&T.rect.current){N.set(T.id,T.rect.current);continue}const P=T.node.current,I=P?new Dx(h(P),P):null;T.rect.current=I,I&&N.set(T.id,I)}return N}return k},[t,l,n,x,h]);return m.useEffect(()=>{g.current=t},[t]),m.useEffect(()=>{x||w()},[n,x]),m.useEffect(()=>{l&&l.length>0&&d(null)},[JSON.stringify(l)]),m.useEffect(()=>{x||typeof u!="number"||C.current!==null||(C.current=setTimeout(()=>{w(),C.current=null},u))},[u,x,w,...a]),{droppableRects:j,measureDroppableContainers:w,measuringScheduled:l!=null};function b(){switch(f){case Oc.Always:return!1;case Oc.BeforeDragging:return n;default:return!n}}}function OC(t,s){return cd(n=>t?n||(typeof s=="function"?s(t):t):null,[s,t])}function cM(t,s){return OC(t,s)}function dM(t){let{callback:s,disabled:n}=t;const a=Rx(s),o=m.useMemo(()=>
60{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:l}=window;return new l(a)},[a,n]);return m.useEffect(()=>()=>o?.disconnect(),[o]),o}function nh(t){let{callback:s,disabled:n}=t;const a=Rx(s),o=m.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:l}=window;return new l(a)},[n]);return m.useEffect(()=>()=>o?.disconnect(),[o]),o}function uM(t){return new Dx(Nl(t),t)}function Lw(t,s,n){s===void 0&&(s=uM);const[a,o]=m.useState(null);function l(){o(h=>{if(!t)return null;if(t.isConnected===!1){var f;return(f=h??n)!=null?f:null}const g=s(t);return JSON.stringify(h)===JSON.stringify(g)?h:g})}const d=dM({callback(h){if(t)for(const f of h){const{type:g,target:x}=f;if(g==="childList"&&x instanceof HTMLElement&&x.contains(t)){l();break}}}}),u=nh({callback:l});return la(()=>{l(),t?(u?.observe(t),d?.observe(document.body,{childList:!0,subtree:!0})):(u?.disconnect(),d?.disconnect())},[t]),a}function mM(t){const s=OC(t);return PC(t,s)}const Fw=[];function hM(t){const s=m.useRef(t),n=cd(a=>t?a&&a!==Fw&&t&&s.current&&t.parentNode===s.current.parentNode?a:sh(t):Fw,[t]);return m.useEffect(()=>{s.current=t},[t]),n}function fM(t){const[s,n]=m.useState(null),a=m.useRef(t),o=m.useCallback(l=>{const d=vp(l.target);d&&n(u=>u?(u.set(d,Jp(d)),new Map(u)):null)},[]);return m.useEffect(()=>{const l=a.current;if(t!==l){d(l);const u=t.map(h=>{const f=vp(h);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,Jp(f)]):null}).filter(h=>h!=null);n(u.length?new Map(u):null),a.current=t}return()=>{d(t),d(l)};function d(u){u.forEach(h=>{const f=vp(h);f?.removeEventListener("scroll",o)})}},[o,t]),m.useMemo(()=>t.length?s?Array.from(s.values()).reduce((l,d)=>Qo(l,d),Vr):IC(t):Vr,[t,s])}function $w(t,s){s===void 0&&(s=[]);const n=m.useRef(null);return m.useEffect(()=>{n.current=null},s),m.useEffect(()=>{const a=t!==Vr;a&&!n.current&&(n.current=t),!a&&n.current&&(n.current=null)},[t]),n.current?Dc(t,n.current):Vr}function pM(t){m.useEffect(()=>{if(!th)return;const s=t.map(n=>{let{sensor:a}=n;return a.setup==null?void 0:a.setup()});return()=>{for(const n of s)n?.()}},t.map(s=>{let{sensor:n}=s;return n}))}function gM(t,s){return m.useMemo(()=>t.reduce((n,a)=>{let{eventName:o,handler:l}=a;return n[o]=d=>{l(d,s)},n},{}),[t,s])}function MC(t){return m.useMemo(()=>t?UO(t):null,[t])}const Uw=[];function xM(t,s){s===void 0&&(s=Nl);const[n]=t,a=MC(n?Xn(n):null),[o,l]=m.useState(Uw);function d(){l(()=>t.length?t.map(h=>RC(h)?a:new Dx(s(h),h)):Uw)}const u=nh({callback:d});return la(()=>{u?.disconnect(),d(),t.forEach(h=>u?.observe(h))},[t]),o}function vM(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return ld(s)?s:t}function yM(t){let{measure:s}=t;const[n,a]=m.useState(null),o=m.useCallback(f=>{for(const{target:g}of f)if(ld(g)){a(x=>{const v=s(g);return x?{...x,width:v.width,height:v.height}:v});break}},[s]),l=nh({callback:o}),d=m.useCallback(f=>{const g=vM(f);l?.disconnect(),g&&l?.observe(g),a(g?s(g):null)},[s,l]),[u,h]=nm(d);return m.useMemo(()=>({nodeRef:u,rect:n,setRef:h}),[n,u,h])}const jM=[{sensor:md,options:{}},{sensor:ud,options:{}}],wM={current:{}},$u={draggable:{measure:Aw},droppable:{measure:Aw,strategy:Oc.WhileDragging,frequency:tg.Optimized},dragOverlay:{measure:Nl}};class Nc extends Map{get(s){var n;return s!=null&&(n=super.get(s))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:n}=s;return!n})}getNodeFor(s){var n,a;return(n=(a=this.get(s))==null?void 0:a.node.current)!=null?n:void 0}}const bM={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Nc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:rm},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:$u,measureDroppableContainers:rm,windowRect:null,measuringScheduled:!1},NM={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:rm,draggableNodes:new Map,over:null,measureDroppableContainers:rm},rh=m.createContext(NM),LC=m.createContext(bM);function SM(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Nc}}}function CM(t,s){switch(s.type){case Xs.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case Xs.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:s.coordinates.x-t.draggable.initialCoordinates.x,y:s.coordinates.y-t.draggable.initialCoordinates.y}}};case Xs.DragEnd:case Xs.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Xs.RegisterDroppable:{const{element:n}=s,{id:a}
60=n,o=new Nc(t.droppable.containers);return o.set(a,n),{...t,droppable:{...t.droppable,containers:o}}}case Xs.SetDroppableDisabled:{const{id:n,key:a,disabled:o}=s,l=t.droppable.containers.get(n);if(!l||a!==l.key)return t;const d=new Nc(t.droppable.containers);return d.set(n,{...l,disabled:o}),{...t,droppable:{...t.droppable,containers:d}}}case Xs.UnregisterDroppable:{const{id:n,key:a}=s,o=t.droppable.containers.get(n);if(!o||a!==o.key)return t;const l=new Nc(t.droppable.containers);return l.delete(n),{...t,droppable:{...t.droppable,containers:l}}}default:return t}}function kM(t){let{disabled:s}=t;const{active:n,activatorEvent:a,draggableNodes:o}=m.useContext(rh),l=Zp(a),d=Zp(n?.id);return m.useEffect(()=>{if(!s&&!a&&l&&d!=null){if(!Ax(l)||document.activeElement===l.target)return;const u=o.get(d);if(!u)return;const{activatorNode:h,node:f}=u;if(!h.current&&!f.current)return;requestAnimationFrame(()=>{for(const g of[h.current,f.current]){if(!g)continue;const x=jO(g);if(x){x.focus();break}}})}},[a,s,o,d,l]),null}function PM(t,s){let{transform:n,...a}=s;return t!=null&&t.length?t.reduce((o,l)=>l({transform:o,...a}),n):n}function TM(t){return m.useMemo(()=>({draggable:{...$u.draggable,...t?.draggable},droppable:{...$u.droppable,...t?.droppable},dragOverlay:{...$u.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function EM(t){let{activeNode:s,measure:n,initialRect:a,config:o=!0}=t;const l=m.useRef(!1),{x:d,y:u}=typeof o=="boolean"?{x:o,y:o}:o;la(()=>{if(!d&&!u||!s){l.current=!1;return}if(l.current||!a)return;const f=s?.node.current;if(!f||f.isConnected===!1)return;const g=n(f),x=PC(g,a);if(d||(x.x=0),u||(x.y=0),l.current=!0,Math.abs(x.x)>0||Math.abs(x.y)>0){const v=TC(f);v&&v.scrollBy({top:x.y,left:x.x})}},[s,d,u,a,n])}const FC=m.createContext({...Vr,scaleX:1,scaleY:1});var ci;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(ci||(ci={}));const om=m.memo(function(s){var n,a,o,l;let{id:d,accessibility:u,autoScroll:h=!0,children:f,sensors:g=jM,collisionDetection:x=IO,measuring:v,modifiers:w,...C}=s;const j=m.useReducer(CM,void 0,SM),[b,k]=j,[N,T]=kO(),[P,I]=m.useState(ci.Uninitialized),O=P===ci.Initialized,{draggable:{active:R,nodes:F,translate:M},droppable:{containers:z}}=b,H=R!=null?F.get(R):null,V=m.useRef({initial:null,translated:null}),B=m.useMemo(()=>{var Ft;return R!=null?{id:R,data:(Ft=H?.data)!=null?Ft:wM,rect:V}:null},[R,H]),Y=m.useRef(null),[L,K]=m.useState(null),[_,$]=m.useState(null),A=Ic(C,Object.values(C)),W=dd("DndDescribedBy",d),U=m.useMemo(()=>z.getEnabled(),[z]),Q=TM(v),{droppableRects:we,measureDroppableContainers:_e,measuringScheduled:Ie}=lM(U,{dragging:O,dependencies:[M.x,M.y],config:Q.droppable}),Te=iM(F,R),ue=m.useMemo(()=>_?Xp(_):null,[_]),Re=en(),$e=cM(Te,Q.draggable.measure);EM({activeNode:R!=null?F.get(R):null,config:Re.layoutShiftCompensation,initialRect:$e,measure:Q.draggable.measure});const le=Lw(Te,Q.draggable.measure,$e),Me=Lw(Te?Te.parentElement:null),He=m.useRef({activatorEvent:null,active:null,activeNode:Te,collisionRect:null,collisions:null,droppableRects:we,draggableNodes:F,draggingNode:null,draggingNodeRect:null,droppableContainers:z,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ft=z.getNodeFor((n=He.current.over)==null?void 0:n.id),Ct=yM({measure:Q.dragOverlay.measure}),zt=(a=Ct.nodeRef.current)!=null?a:Te,Wt=O?(o=Ct.rect)!=null?o:le:null,Le=!!(Ct.nodeRef.current&&Ct.rect),Nt=mM(Le?null:le),Xt=MC(zt?Xn(zt):null),qt=hM(O?ft??Te:null),us=xM(qt),qs=PM(w,{transform:{x:M.x-Nt.x,y:M.y-Nt.y,scaleX:1,scaleY:1},activatorEvent:_,active:B,activeNodeRect:le,containerNodeRect:Me,draggingNodeRect:Wt,over:He.current.over,overlayNodeRect:Ct.rect,scrollableAncestors:qt,scrollableAncestorRects:us,windowRect:Xt}),Ks=ue?Qo(ue,M):null,xn=fM(qt),vn=$w(xn),Ls=$w(xn,[le]),$t=Qo(qs,vn),ze=Wt?MO(Wt,qs):null,Xe=B&&ze?x({active:B,collisionRect:ze,droppableRects:we,droppableContainers:U,pointerCoordinates:Ks}):null,ne=kC(Xe,"id"),[pe,ut]=m.useState(null),mt=Le?qs:Qo(qs,Ls),ms=DO(mt,(l=pe?.rect)!=null?l:null,le),Kt=m.useRef(null),kt=m.useCallback((Ft,Jt)=>{let{sensor:vs,options:Fs}=Jt;if(Y.current==null)return;const Cs=F.get(Y.current);if(!Cs)return;const Hs=Ft.nativeEvent,Is=new vs({active:Y.current,activeNode:Cs,event:Hs,options:Fs,context:He,onAbort(as){if(!F.get(as))return;const{onDragAbort:$s}=A.current,un={id:as};$s?.(un),N({type:"onDragAbort",event:un})},onPending(as,tn,$s,un){if(!F.get(as))return;const{onDragPending:zn}=A.current,Gs={id:as,constraint:tn,initialCoordinates:$s,offset:un};zn?.(Gs),N({type:"onDragPending",event:Gs})},onStart(as){const tn=Y.current;if(tn==null)return;const $s=F.get(tn);if(!$s)return;const{onDragStart:un}=A.current,yn={activatorEvent:Hs,active:{id:tn,data:$s.data,rect:V}};Mr.unstable_batchedUpdates(()=>{un?.(yn),I(ci.Initializing),k({type:Xs.DragStart,initialCoordinates:as,active:tn}),N({type:"onDragStart",event:yn}),K(Kt.current),$(Hs)})},onMove(as){k({type:Xs.DragMove,coordinates:as})},onEnd:Rn(Xs.DragEnd),onCancel:Rn(Xs.DragCancel)});Kt.current=Is;function Rn(as){return async function(){const{active:$s,collisions:un,over:yn,scrollAdjustedTranslate:zn}=He.current;let Gs=null;if($s&&zn){const{cancelDrop:er}=A.current;Gs={activatorEvent:Hs,active:$s,collisions:un,delta:zn,over:yn},as===Xs.DragEnd&&typeof er=="function"&&await Promise.resolve(er(Gs))&&(as=Xs.DragCancel)}Y.current=null,Mr.unstable_batchedUpdates(()=>{k({type:as}),I(ci.Uninitialized),ut(null),K(null),$(null),Kt.current=null;const er=as===Xs.DragEnd?"onDragEnd":"onDragCancel";if(Gs){const se=A.current[er];se?.(Gs),N({type:er,event:Gs})}})}}},[F]),xs=m.useCallback((Ft,Jt)=>(vs,Fs)=>{const Cs=vs.nativeEvent,Hs=F.get(Fs);if(Y.current!==null||!Hs||Cs.dndKit||Cs.defaultPrevented)return;const Is={active:Hs};Ft(vs,Jt.options,Is)===!0&&(Cs.dndKit={capturedBy:Jt.sensor},Y.current=Fs,kt(vs,Jt))},[F,kt]),hs=oM(g,xs);pM(g),la(()=>{le&&P===ci.Initializing&&I(ci.Initialized)},[le,P]),m.useEffect(()=>{const{onDragMove:Ft}=A.current,{active:Jt,activatorEvent:vs,collisions:Fs,over:Cs}=He.current;if(!Jt||!vs)return;const Hs={active:Jt,activatorEvent:vs,collisions:Fs,delta:{x:$t.x,y:$t.y},over:Cs};Mr.unstable_batchedUpdates(()=>{Ft?.(Hs),N({type:"onDragMove",event:Hs})})},[$t.x,$t.y]),m.useEffect(()=>{const{active:Ft,activatorEvent:Jt,collisions:vs,droppableContainers:Fs,scrollAdjustedTranslate:Cs}=He.current;if(!Ft||Y.current==null||!Jt||!Cs)return;const{onDragOver:Hs}=A.current,Is=Fs.get(ne),Rn=Is&&Is.rect.current?{id:Is.id,rect:Is.rect.current,data:Is.data,disabled:Is.disabled}:null,as={active:Ft,activatorEvent:Jt,collisions:vs,delta:{x:Cs.x,y:Cs.y},over:Rn};Mr.unstable_batchedUpdates(()=>{ut(Rn),Hs?.(as),N({type:"onDragOver",event:as})})},[ne]),la(()=>{He.current={activatorEvent:_,active:B,activeNode:Te,collisionRect:ze,collisions:Xe,droppableRects:we,draggableNodes:F,draggingNode:zt,draggingNodeRect:Wt,droppableContainers:z,over:pe,scrollableAncestors:qt,scrollAdjustedTranslate:$t},V.current={initial:Wt,translated:ze}},[B,Te,Xe,ze,F,zt,Wt,we,z,pe,qt,$t]),nM({...Re,delta:M,draggingRect:ze,pointerCoordinates:Ks,scrollableAncestors:qt,scrollableAncestorRects:us});const Jn=m.useMemo(()=>({active:B,activeNode:Te,activeNodeRect:le,activatorEvent:_,collisions:Xe,containerNodeRect:Me,dragOverlay:Ct,draggableNodes:F,droppableContainers:z,droppableRects:we,over:pe,measureDroppableContainers:_e,scrollableAncestors:qt,scrollableAncestorRects:us,measuringConfiguration:Q,measuringScheduled:Ie,windowRect:Xt}),[B,Te,le,_,Xe,Me,Ct,F,z,we,pe,_e,qt,us,Q,Ie,Xt]),_n=m.useMemo(()=>({activatorEvent:_,activators:hs,active:B,activeNodeRect:le,ariaDescribedById:{draggable:W},dispatch:k,draggableNodes:F,over:pe,measureDroppableContainers:_e}),[_,hs,B,le,k,W,F,pe,_e]);return Os.createElement(NC.Provider,{value:T},Os.createElement(rh.Provider,{value:_n},Os.createElement(LC.Provider,{value:Jn},Os.createElement(FC.Provider,{value:ms},f)),Os.createElement(kM,{disabled:u?.restoreFocus===!1})),Os.createElement(EO,{...u,hiddenTextDescribedById:W}));function en(){const Ft=L?.autoScrollEnabled===!1,Jt=typeof h=="object"?h.enabled===!1:h===!1,vs=O&&!Ft&&!Jt;return typeof h=="object"?{...h,enabled:vs}:{enabled:vs}}}),_M=m.createContext(null),zw="button",RM="Draggable";function AM(t){let{id:s,data:n,disabled:a=!1,attributes:o}=t;const l=dd(RM),{activators:d,activatorEvent:u,active:h,activeNodeRect:f,ariaDescribedById:g,draggableNodes:x,over:v}=m.useContext(rh),{role:w=zw,roleDescription:C="draggable",tabIndex:j=0}=o??{},b=h?.id===s,k=m.useContext(b?FC:_M),[N,T]=nm(),[P,I]=nm(),O=gM(d,s),R=Ic(n);la(()=>(x.set(s,{id:s,key:l,node:N,activatorNode:P,data:R}),()=>{const M=x.get(s);M&&M.key===l&&x.delete(s)}),[x,s]);const F=m.useMemo(()=>({role:w,tabIndex:j,"aria-disabled":a,"aria-pressed":b&&w===zw?!0:void 0,"aria-roledescription":C,"aria-describedby":g.draggable}),[a,w,j,b,C,g.draggable]);return{active:h,activatorEvent:u,activeNodeRect:f,attributes:F,isDragging:b,listeners:a?void 0:O,node:N,over:v,setNodeRef:T,setActivatorNodeRef:I,transform:k}}function IM(){return m.useContext(LC)}const DM="Droppable",OM={timeout:25};function MM(t){let{data:s,disabled:n=!1,id:a,resizeObserverConfig:o}=t;const l=dd(DM),{active:d,dispatch:u,over:h,measureDroppableContainers:f}=m.useContext(rh),g=m.useRef({disabled:n}),x=m.useRef(!1),v=m.useRef(null),w=m.useRef(null),{disabled:C,updateMeasurementsFor:j,timeout:b}={...OM,...o},k=Ic(j??a),N=m.useCallback(()=>
60{if(!x.current){x.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{f(Array.isArray(k.current)?k.current:[k.current]),w.current=null},b)},[b]),T=nh({callback:N,disabled:C||!d}),P=m.useCallback((F,M)=>{T&&(M&&(T.unobserve(M),x.current=!1),F&&T.observe(F))},[T]),[I,O]=nm(P),R=Ic(s);return m.useEffect(()=>{!T||!I.current||(T.disconnect(),x.current=!1,T.observe(I.current))},[I,T]),m.useEffect(()=>(u({type:Xs.RegisterDroppable,element:{id:a,key:l,disabled:n,node:I,rect:v,data:R}}),()=>u({type:Xs.UnregisterDroppable,key:l,id:a})),[a]),m.useEffect(()=>{n!==g.current.disabled&&(u({type:Xs.SetDroppableDisabled,id:a,key:l,disabled:n}),g.current.disabled=n)},[a,l,n,u]),{active:d,rect:v,isOver:h?.id===a,node:I,over:h,setNodeRef:O}}function il(t,s,n){const a=t.slice();return a.splice(n<0?a.length+n:n,0,a.splice(s,1)[0]),a}function LM(t,s){return t.reduce((n,a,o)=>{const l=s.get(a);return l&&(n[o]=l),n},Array(t.length))}function Eu(t){return t!==null&&t>=0}function FM(t,s){if(t===s)return!0;if(t.length!==s.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==s[n])return!1;return!0}function $M(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const $C=t=>{let{rects:s,activeIndex:n,overIndex:a,index:o}=t;const l=il(s,a,n),d=s[o],u=l[o];return!u||!d?null:{x:u.left-d.left,y:u.top-d.top,scaleX:u.width/d.width,scaleY:u.height/d.height}},_u={scaleX:1,scaleY:1},lm=t=>{var s;let{activeIndex:n,activeNodeRect:a,index:o,rects:l,overIndex:d}=t;const u=(s=l[n])!=null?s:a;if(!u)return null;if(o===n){const f=l[d];return f?{x:0,y:n<d?f.top+f.height-(u.top+u.height):f.top-u.top,..._u}:null}const h=UM(l,o,n);return o>n&&o<=d?{x:0,y:-u.height-h,..._u}:o<n&&o>=d?{x:0,y:u.height+h,..._u}:{x:0,y:0,..._u}};function UM(t,s,n){const a=t[s],o=t[s-1],l=t[s+1];return a?n<s?o?a.top-(o.top+o.height):l?l.top-(a.top+a.height):0:l?l.top-(a.top+a.height):o?a.top-(o.top+o.height):0:0}const UC="Sortable",zC=Os.createContext({activeIndex:-1,containerId:UC,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:$C,disabled:{draggable:!1,droppable:!1}});function cm(t){let{children:s,id:n,items:a,strategy:o=$C,disabled:l=!1}=t;const{active:d,dragOverlay:u,droppableRects:h,over:f,measureDroppableContainers:g}=IM(),x=dd(UC,n),v=u.rect!==null,w=m.useMemo(()=>a.map(O=>typeof O=="object"&&"id"in O?O.id:O),[a]),C=d!=null,j=d?w.indexOf(d.id):-1,b=f?w.indexOf(f.id):-1,k=m.useRef(w),N=!FM(w,k.current),T=b!==-1&&j===-1||N,P=$M(l);la(()=>{N&&C&&g(w)},[N,w,C,g]),m.useEffect(()=>{k.current=w},[w]);const I=m.useMemo(()=>({activeIndex:j,containerId:x,disabled:P,disableTransforms:T,items:w,overIndex:b,useDragOverlay:v,sortedRects:LM(w,h),strategy:o}),[j,x,P.draggable,P.droppable,T,w,b,h,v,o]);return Os.createElement(zC.Provider,{value:I},s)}const zM=t=>{let{id:s,items:n,activeIndex:a,overIndex:o}=t;return il(n,a,o).indexOf(s)},BM=t=>{let{containerId:s,isSorting:n,wasDragging:a,index:o,items:l,newIndex:d,previousItems:u,previousContainerId:h,transition:f}=t;return!f||!a||u!==l&&o===d?!1:n?!0:d!==o&&s===h},VM={duration:200,easing:"ease"},BC="transform",qM=gi.Transition.toString({property:BC,duration:0,easing:"linear"}),KM={roleDescription:"sortable"};function HM(t){let{disabled:s,index:n,node:a,rect:o}=t;const[l,d]=m.useState(null),u=m.useRef(n);return la(()=>{if(!s&&n!==u.current&&a.current){const h=o.current;if(h){const f=Nl(a.current,{ignoreTransform:!0}),g={x:h.left-f.left,y:h.top-f.top,scaleX:h.width/f.width,scaleY:h.height/f.height};(g.x||g.y)&&d(g)}}n!==u.current&&(u.current=n)},[s,n,a,o]),m.useEffect(()=>{l&&d(null)},[l]),l}function ah(t){let{animateLayoutChanges:s=BM,attributes:n,disabled:a,data:o,getNewIndex:l=zM,id:d,strategy:u,resizeObserverConfig:h,transition:f=VM}=t;const{items:g,containerId:x,activeIndex:v,disabled:w,disableTransforms:C,sortedRects:j,overIndex:b,useDragOverlay:k,strategy:N}=m.useContext(zC),T=WM(a,w),P=g.indexOf(d),I=m.useMemo(()=>({sortable:{containerId:x,index:P,items:g},...o}),[x,o,P,g]),O=m.useMemo(()=>g.slice(g.indexOf(d)),[g,d]),{rect:R,node:F,isOver:M,setNodeRef:z}=MM({id:d,data:I,disabled:T.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...h}}),{active:H,activatorEvent:V,activeNodeRect:B,attributes:Y,setNodeRef:L,listeners:K,isDragging:_,over:$,setActivatorNodeRef:A,transform:W}=AM({id:d,data:I,attributes:{...KM,...n},disabled:T.draggable}),U=gO(z,L),Q=!!H,we=Q&&!C&&Eu(v)&&Eu(b),_e=!k&&_,Ie=_e&&we?W:null,ue=we?Ie??(u??N)({rects:j,activeNodeRect:B,activeIndex:v,overIndex:b,index:P}
60):null,Re=Eu(v)&&Eu(b)?l({id:d,items:g,activeIndex:v,overIndex:b}):P,$e=H?.id,le=m.useRef({activeId:$e,items:g,newIndex:Re,containerId:x}),Me=g!==le.current.items,He=s({active:H,containerId:x,isDragging:_,isSorting:Q,id:d,index:P,items:g,newIndex:le.current.newIndex,previousItems:le.current.items,previousContainerId:le.current.containerId,transition:f,wasDragging:le.current.activeId!=null}),ft=HM({disabled:!He,index:P,node:F,rect:R});return m.useEffect(()=>{Q&&le.current.newIndex!==Re&&(le.current.newIndex=Re),x!==le.current.containerId&&(le.current.containerId=x),g!==le.current.items&&(le.current.items=g)},[Q,Re,x,g]),m.useEffect(()=>{if($e===le.current.activeId)return;if($e!=null&&le.current.activeId==null){le.current.activeId=$e;return}const zt=setTimeout(()=>{le.current.activeId=$e},50);return()=>clearTimeout(zt)},[$e]),{active:H,activeIndex:v,attributes:Y,data:I,rect:R,index:P,newIndex:Re,items:g,isOver:M,isSorting:Q,isDragging:_,listeners:K,node:F,overIndex:b,over:$,setNodeRef:U,setActivatorNodeRef:A,setDroppableNodeRef:z,setDraggableNodeRef:L,transform:ft??ue,transition:Ct()};function Ct(){if(ft||Me&&le.current.newIndex===P)return qM;if(!(_e&&!Ax(V)||!f)&&(Q||He))return gi.Transition.toString({...f,property:BC})}}function WM(t,s){var n,a;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t?.draggable)!=null?n:s.draggable,droppable:(a=t?.droppable)!=null?a:s.droppable}}function dm(t){if(!t)return!1;const s=t.data.current;return!!(s&&"sortable"in s&&typeof s.sortable=="object"&&"containerId"in s.sortable&&"items"in s.sortable&&"index"in s.sortable)}const QM=[Vt.Down,Vt.Right,Vt.Up,Vt.Left],Mx=(t,s)=>{let{context:{active:n,collisionRect:a,droppableRects:o,droppableContainers:l,over:d,scrollableAncestors:u}}=s;if(QM.includes(t.code)){if(t.preventDefault(),!n||!a)return;const h=[];l.getEnabled().forEach(x=>{if(!x||x!=null&&x.disabled)return;const v=o.get(x.id);if(v)switch(t.code){case Vt.Down:a.top<v.top&&h.push(x);break;case Vt.Up:a.top>v.top&&h.push(x);break;case Vt.Left:a.left>v.left&&h.push(x);break;case Vt.Right:a.left<v.left&&h.push(x);break}});const f=RO({collisionRect:a,droppableRects:o,droppableContainers:h});let g=kC(f,"id");if(g===d?.id&&f.length>1&&(g=f[1].id),g!=null){const x=l.get(n.id),v=l.get(g),w=v?o.get(v.id):null,C=v?.node.current;if(C&&w&&x&&v){const b=sh(C).some((O,R)=>u[R]!==O),k=VC(x,v),N=GM(x,v),T=b||!k?{x:0,y:0}:{x:N?a.width-w.width:0,y:N?a.height-w.height:0},P={x:w.left,y:w.top};return T.x&&T.y?P:Dc(P,T)}}}};function VC(t,s){return!dm(t)||!dm(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function GM(t,s){return!dm(t)||!dm(s)||!VC(t,s)?!1:t.data.current.sortable.index<s.data.current.sortable.index}var Lx="Tabs",[YM]=En(Lx,[Xm]),qC=Xm(),[ZM,Fx]=YM(Lx),KC=m.forwardRef((t,s)=>{const{__scopeTabs:n,value:a,onValueChange:o,defaultValue:l,orientation:d="horizontal",dir:u,activationMode:h="automatic",...f}=t,g=ad(u),[x,v]=Ur({prop:a,onChange:o,defaultProp:l});return e.jsx(ZM,{scope:n,baseId:jr(),value:x,onValueChange:v,orientation:d,dir:g,activationMode:h,children:e.jsx(at.div,{dir:g,"data-orientation":d,...f,ref:s})})});KC.displayName=Lx;var HC="TabsList",WC=m.forwardRef((t,s)=>{const{__scopeTabs:n,loop:a=!0,...o}=t,l=Fx(HC,n),d=qC(n);return e.jsx(kS,{asChild:!0,...d,orientation:l.orientation,dir:l.dir,loop:a,children:e.jsx(at.div,{role:"tablist","aria-orientation":l.orientation,...o,ref:s})})});WC.displayName=HC;var QC="TabsTrigger",GC=m.forwardRef((t,s)=>{const{__scopeTabs:n,value:a,disabled:o=!1,...l}=t,d=Fx(QC,n),u=qC(n),h=XC(d.baseId,a),f=JC(d.baseId,a),g=a===d.value;return e.jsx(PS,{asChild:!0,...u,focusable:!o,active:g,children:e.jsx(at.button,{type:"button",role:"tab","aria-selected":g,"aria-controls":f,"data-state":g?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:h,...l,ref:s,onMouseDown:Ae(t.onMouseDown,x=>{!o&&x.button===0&&x.ctrlKey===!1?d.onValueChange(a):x.preventDefault()}),onKeyDown:Ae(t.onKeyDown,x=>{[" ","Enter"].includes(x.key)&&d.onValueChange(a)}),onFocus:Ae(t.onFocus,()=>{const x=d.activationMode!=="manual";!g&&!o&&x&&d.onValueChange(a)})})})});GC.displayName=QC;var YC="TabsContent",ZC=m.forwardRef((t,s)=>{const{__scopeTabs:n,value:a,forceMount:o,children:l,...d}=t,u=Fx(YC,n),h=XC(u.baseId,a),f=JC(u.baseId,a),g=a===u.value,x=m.useRef(g);return m.useEffect(()=>{const v=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(v)},[]),e.jsx(gn,{present:o||g,children:({present:v})=>e.jsx(at.div,{"data-state":g?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":h,hidden:!v,id:f,tabIndex:0,...d,ref:s,style:{...t.style,animationDuration:x.current?"0s":void 0},children:v&&l})})});ZC.displayName=YC;function XC(t,s){return`${t}-trigger-${s}`}function JC(t,s){return`${t}-content-${s}`}var XM=KC,e1=WC,t1=GC,s1=ZC;const Ma=XM,ha=m.forwardRef(({className:t,...s},n)=>e.jsx(e1,{ref:n,className:Oe("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));ha.displayName=e1.displayName;const ls=m.forwardRef(({className:t,...s},n)=>e.jsx(t1,{ref:n,className:Oe("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...s}));ls.displayName=t1.displayName;const Ss=m.forwardRef(({className:t,...s},n)=>e.jsx(s1,{ref:n,className:Oe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));Ss.displayName=s1.displayName;function $x(t){const s=m.useRef({value:t,previous:t});return m.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var JM=[" ","Enter","ArrowUp","ArrowDown"],e3=[" ","Enter"],hd="Select",[ih,oh,t3]=Tm(hd),[Sl]=En(hd,[t3,yl]),lh=yl(),[s3,wi]=Sl(hd),[n3,r3]=Sl(hd),n1=t=>{const{__scopeSelect:s,children:n,open:a,defaultOpen:o,onOpenChange:l,value:d,defaultValue:u,onValueChange:h,dir:f,name:g,autoComplete:x,disabled:v,required:w,form:C}=t,j=lh(s),[b,k]=m.useState(null),[N,T]=m.useState(null),[P,I]=m.useState(!1),O=ad(f),[R=!1,F]=Ur({prop:a,defaultProp:o,onChange:l}),[M,z]=Ur({prop:d,defaultProp:u,onChange:h}),H=m.useRef(null),V=b?C||!!b.closest("form"):!0,[B,Y]=m.useState(new Set),L=Array.from(B).map(K=>K.props.value).join(";");return e.jsx(Kg,{...j,children:e.jsxs(s3,{required:w,scope:s,trigger:b,onTriggerChange:k,valueNode:N,onValueNodeChange:T,valueNodeHasChildren:P,onValueNodeHasChildrenChange:I,contentId:jr(),value:M,onValueChange:z,open:R,onOpenChange:F,dir:O,triggerPointerDownPosRef:H,disabled:v,children:[e.jsx(ih.Provider,{scope:s,children:e.jsx(n3,{scope:t.__scopeSelect,onNativeOptionAdd:m.useCallback(K=>{Y(_=>new Set(_).add(K))},[]),onNativeOptionRemove:m.useCallback(K=>{Y(_=>{const $=new Set(_);return $.delete(K),$})},[]),children:n})}),V?e.jsxs(T1,{"aria-hidden":!0,required:w,tabIndex:-1,name:g,autoComplete:x,value:M,onChange:K=>z(K.target.value),disabled:v,form:C,children:[M===void 0?e.jsx("option",{value:""}):null,Array.from(B)]},L):null]})})};n1.displayName=hd;var r1="SelectTrigger",a1=m.forwardRef((t,s)=>{const{__scopeSelect:n,disabled:a=!1,...o}=t,l=lh(n),d=wi(r1,n),u=d.disabled||a,h=At(s,d.onTriggerChange),f=oh(n),g=m.useRef("touch"),[x,v,w]=E1(j=>{const b=f().filter(T=>!T.disabled),k=b.find(T=>T.value===d.value),N=_1(b,j,k);N!==void 0&&d.onValueChange(N.value)}
vendor: 16,191 bytes, line 60
60),C=j=>{u||(d.onOpenChange(!0),w()),j&&(d.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return e.jsx(Hg,{asChild:!0,...l,children:e.jsx(at.button,{type:"button",role:"combobox","aria-controls":d.contentId,"aria-expanded":d.open,"aria-required":d.required,"aria-autocomplete":"none",dir:d.dir,"data-state":d.open?"open":"closed",disabled:u,"data-disabled":u?"":void 0,"data-placeholder":P1(d.value)?"":void 0,...o,ref:h,onClick:Ae(o.onClick,j=>{j.currentTarget.focus(),g.current!=="mouse"&&C(j)}),onPointerDown:Ae(o.onPointerDown,j=>{g.current=j.pointerType;const b=j.target;b.hasPointerCapture(j.pointerId)&&b.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(C(j),j.preventDefault())}),onKeyDown:Ae(o.onKeyDown,j=>{const b=x.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&v(j.key),!(b&&j.key===" ")&&JM.includes(j.key)&&(C(),j.preventDefault())})})})});a1.displayName=r1;var i1="SelectValue",o1=m.forwardRef((t,s)=>{const{__scopeSelect:n,className:a,style:o,children:l,placeholder:d="",...u}=t,h=wi(i1,n),{onValueNodeHasChildrenChange:f}=h,g=l!==void 0,x=At(s,h.onValueNodeChange);return cn(()=>{f(g)},[f,g]),e.jsx(at.span,{...u,ref:x,style:{pointerEvents:"none"},children:P1(h.value)?e.jsx(e.Fragment,{children:d}):l})});o1.displayName=i1;var a3="SelectIcon",l1=m.forwardRef((t,s)=>{const{__scopeSelect:n,children:a,...o}=t;return e.jsx(at.span,{"aria-hidden":!0,...o,ref:s,children:a||"▼"})});l1.displayName=a3;var i3="SelectPortal",c1=t=>e.jsx(Zc,{asChild:!0,...t});c1.displayName=i3;var Zi="SelectContent",d1=m.forwardRef((t,s)=>{const n=wi(Zi,t.__scopeSelect),[a,o]=m.useState();if(cn(()=>{o(new DocumentFragment)},[]),!n.open){const l=a;return l?Mr.createPortal(e.jsx(u1,{scope:t.__scopeSelect,children:e.jsx(ih.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),l):null}return e.jsx(m1,{...t,ref:s})});d1.displayName=Zi;var Ir=10,[u1,bi]=Sl(Zi),o3="SelectContentImpl",l3=Bi("SelectContent.RemoveScroll"),m1=m.forwardRef((t,s)=>{const{__scopeSelect:n,position:a="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:l,onPointerDownOutside:d,side:u,sideOffset:h,align:f,alignOffset:g,arrowPadding:x,collisionBoundary:v,collisionPadding:w,sticky:C,hideWhenDetached:j,avoidCollisions:b,...k}=t,N=wi(Zi,n),[T,P]=m.useState(null),[I,O]=m.useState(null),R=At(s,ue=>P(ue)),[F,M]=m.useState(null),[z,H]=m.useState(null),V=oh(n),[B,Y]=m.useState(!1),L=m.useRef(!1);m.useEffect(()=>{if(T)return Jg(T)},[T]),Xg();const K=m.useCallback(ue=>{const[Re,...$e]=V().map(He=>He.ref.current),[le]=$e.slice(-1),Me=document.activeElement;for(const He of ue)if(He===Me||(He?.scrollIntoView({block:"nearest"}),He===Re&&I&&(I.scrollTop=0),He===le&&I&&(I.scrollTop=I.scrollHeight),He?.focus(),document.activeElement!==Me))return},[V,I]),_=m.useCallback(()=>K([F,T]),[K,F,T]);m.useEffect(()=>{B&&_()},[B,_]);const{onOpenChange:$,triggerPointerDownPosRef:A}=N;m.useEffect(()=>{if(T){let ue={x:0,y:0};const Re=le=>{ue={x:Math.abs(Math.round(le.pageX)-(A.current?.x??0)),y:Math.abs(Math.round(le.pageY)-(A.current?.y??0))}},$e=le=>{ue.x<=10&&ue.y<=10?le.preventDefault():T.contains(le.target)||$(!1),document.removeEventListener("pointermove",Re),A.current=null};return A.current!==null&&(document.addEventListener("pointermove",Re),document.addEventListener("pointerup",$e,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Re),document.removeEventListener("pointerup",$e,{capture:!0})}}},[T,$,A]),m.useEffect(()=>{const ue=()=>$(!1);return window.addEventListener("blur",ue),window.addEventListener("resize",ue),()=>{window.removeEventListener("blur",ue),window.removeEventListener("resize",ue)}},[$]);const[W,U]=E1(ue=>{const Re=V().filter(Me=>!Me.disabled),$e=Re.find(Me=>Me.ref.current===document.activeElement),le=_1(Re,ue,$e);le&&setTimeout(()=>le.ref.current.focus())}),Q=m.useCallback((ue,Re,$e)=>{const le=!L.current&&!$e;(N.value!==void 0&&N.value===Re||le)&&(M(ue),le&&(L.current=!0))},[N.value]),we=m.useCallback(()=>T?.focus(),[T]),_e=m.useCallback((ue,Re,$e)=>{const le=!L.current&&!$e;(N.value!==void 0&&N.value===Re||le)&&H(ue)},[N.value]),Ie=a==="popper"?sg:h1,Te=Ie===sg?{side:u,sideOffset:h,align:f,alignOffset:g,arrowPadding:x,collisionBoundary:v,collisionPadding:w,sticky:C,hideWhenDetached:j,avoidCollisions:b}:{};return e.jsx(u1,{scope:n,content:T,viewport:I,onViewportChange:O,itemRefCallback:Q,selectedItem:F,onItemLeave:we,itemTextRefCallback:_e,focusSelectedItem:_,selectedItemText:z,position:a,isPositioned:B,searchRef:W,children:e.jsx(Wm,{as:l3,allowPinchZoom:!0,children:e.jsx(Km,{asChild:!0,trapped:N.open,onMountAutoFocus:ue=>{ue.preventDefault()},onUnmountAutoFocus:Ae(o,ue=>{N.trigger?.focus({preventScroll:!0}),ue.preventDefault()}),children:e.jsx(ul,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:ue=>ue.preventDefault(),onDismiss:()=>N.onOpenChange(!1),children:e.jsx(Ie,{role:"listbox",id:N.contentId,"data-state":N.open?"open":"closed",dir:N.dir,onContextMenu:ue=>ue.preventDefault(),...k,...Te,onPlaced:()=>Y(!0),ref:R,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:Ae(k.onKeyDown,ue=>{const Re=ue.ctrlKey||ue.altKey||ue.metaKey;if(ue.key==="Tab"&&ue.preventDefault(),!Re&&ue.key.length===1&&U(ue.key),["ArrowUp","ArrowDown","Home","End"].includes(ue.key)){let le=V().filter(Me=>!Me.disabled).map(Me=>Me.ref.current);if(["ArrowUp","End"].includes(ue.key)&&(le=le.slice().reverse()),["ArrowUp","ArrowDown"].includes(ue.key)){const Me=ue.target,He=le.indexOf(Me);le=le.slice(He+1)}setTimeout(()=>K(le)),ue.preventDefault()}})})})})})})});m1.displayName=o3;var c3="SelectItemAlignedPosition",h1=m.forwardRef((t,s)=>{const{__scopeSelect:n,onPlaced:a,...o}=t,l=wi(Zi,n),d=bi(Zi,n),[u,h]=m.useState(null),[f,g]=m.useState(null),x=At(s,R=>g(R)),v=oh(n),w=m.useRef(!1),C=m.useRef(!0),{viewport:j,selectedItem:b,selectedItemText:k,focusSelectedItem:N}=d,T=m.useCallback(()=>{if(l.trigger&&l.valueNode&&u&&f&&j&&b&&k){const R=l.trigger.getBoundingClientRect(),F=f.getBoundingClientRect(),M=l.valueNode.getBoundingClientRect(),z=k.getBoundingClientRect();if(l.dir!=="rtl"){const Me=z.left-F.left,He=M.left-Me,ft=R.left-He,Ct=R.width+ft,zt=Math.max(Ct,F.width),Wt=window.innerWidth-Ir,Le=Wp(He,[Ir,Math.max(Ir,Wt-zt)]);u.style.minWidth=Ct+"px",u.style.left=Le+"px"}else{const Me=F.right-z.right,He=window.innerWidth-M.right-Me,ft=window.innerWidth-R.right-He,Ct=R.width+ft,zt=Math.max(Ct,F.width),Wt=window.innerWidth-Ir,Le=Wp(He,[Ir,Math.max(Ir,Wt-zt)]);u.style.minWidth=Ct+"px",u.style.right=Le+"px"}const H=v(),V=window.innerHeight-Ir*2,B=j.scrollHeight,Y=window.getComputedStyle(f),L=parseInt(Y.borderTopWidth,10),K=parseInt(Y.paddingTop,10),_=parseInt(Y.borderBottomWidth,10),$=parseInt(Y.paddingBottom,10),A=L+K+B+$+_,W=Math.min(b.offsetHeight*5,A),U=window.getComputedStyle(j),Q=parseInt(U.paddingTop,10),we=parseInt(U.paddingBottom,10),_e=R.top+R.height/2-Ir,Ie=V-_e,Te=b.offsetHeight/2,ue=b.offsetTop+Te,Re=L+K+ue,$e=A-Re;if(Re<=_e){const Me=H.length>0&&b===H[H.length-1].ref.current;u.style.bottom="0px";const He=f.clientHeight-j.offsetTop-j.offsetHeight,ft=Math.max(Ie,Te+(Me?we:0)+He+_),Ct=Re+ft;u.style.height=Ct+"px"}else{const Me=H.length>0&&b===H[0].ref.current;u.style.top="0px";const ft=Math.max(_e,L+j.offsetTop+(Me?Q:0)+Te)+$e;u.style.height=ft+"px",j.scrollTop=Re-_e+j.offsetTop}u.style.margin=`${Ir}px 0`,u.style.minHeight=W+"px",u.style.maxHeight=V+"px",a?.(),requestAnimationFrame(()=>w.current=!0)}},[v,l.trigger,l.valueNode,u,f,j,b,k,l.dir,a]);cn(()=>T(),[T]);const[P,I]=m.useState();cn(()=>{f&&I(window.getComputedStyle(f).zIndex)},[f]);const O=m.useCallback(R=>{R&&C.current===!0&&(T(),N?.(),C.current=!1)},[T,N]);return e.jsx(u3,{scope:n,contentWrapper:u,shouldExpandOnScrollRef:w,onScrollButtonChange:O,children:e.jsx("div",{ref:h,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P},children:e.jsx(at.div,{...o,ref:x,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});h1.displayName=c3;var d3="SelectPopperPosition",sg=m.forwardRef((t,s)=>{const{__scopeSelect:n,align:a="start",collisionPadding:o=Ir,...l}=t,d=lh(n);return e.jsx(Wg,{...d,...l,ref:s,align:a,collisionPadding:o,style:{boxSizing:"border-box",...l.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});sg.displayName=d3;var[u3,Ux]=Sl(Zi,{}),ng="SelectViewport",f1=m.forwardRef((t,s)=>{const{__scopeSelect:n,nonce:a,...o}=t,l=bi(ng,n),d=Ux(ng,n),u=At(s,l.onViewportChange),h=m.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),e.jsx(ih.Slot,{scope:n,children:e.jsx(at.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:u,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ae(o.onScroll,f=>{const g=f.currentTarget,{contentWrapper:x,shouldExpandOnScrollRef:v}=d;if(v?.current&&x){const w=Math.abs(h.current-g.scrollTop);if(w>0){const C=window.innerHeight-Ir*2,j=parseFloat(x.style.minHeight),b=parseFloat(x.style.height),k=Math.max(j,b);if(k<C){const N=k+w,T=Math.min(C,N),P=N-T;x.style.height=T+"px",x.style.bottom==="0px"&&(g.scrollTop=P>0?P:0,x.style.justifyContent="flex-end")}}}h.current=g.scrollTop})})})]})});f1.displayName=ng;var p1="SelectGroup",[m3,h3]=Sl(p1),f3=m.forwardRef((t,s)=>{const{__scopeSelect:n,...a}=t,o=jr();return e.jsx(m3,{scope:n,id:o,children:e.jsx(at.div,{role:"group","aria-labelledby":o,...a,ref:s})})});f3.displayName=p1;var g1="SelectLabel",x1=m.forwardRef((t,s)=>{const{__scopeSelect:n,...a}=t,o=h3(g1,n);return e.jsx(at.div,{id:o.id,...a,ref:s})});x1.displayName=g1;var um="SelectItem",[p3,v1]=Sl(um),y1=m.forwardRef((t,s)=>{const{__scopeSelect:n,value:a,disabled:o=!1,textValue:l,...d}=t,u=wi(um,n),h=bi(um,n),f=u.value===a,[g,x]=m.useState(l??""),[v,w]=m.useState(!1),C=At(s,N=>h.itemRefCallback?.(N,a,o)),j=jr(),b=m.useRef("touch"),k=()=>{o||(u.onValueChange(a),u.onOpenChange(!1))};if(a==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(p3,{scope:n,value:a,disabled:o,textId:j,isSelected:f,onItemTextChange:m.useCallback(N=>{x(T=>T||(N?.textContent??"").trim())},[]),children:e.jsx(ih.ItemSlot,{scope:n,value:a,disabled:o,textValue:g,children:e.jsx(at.div,{role:"option","aria-labelledby":j,"data-highlighted":v?"":void 0,"aria-selected":f&&v,"data-state":f?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...d,ref:C,onFocus:Ae(d.onFocus,()=>w(!0)),onBlur:Ae(d.onBlur,()=>w(!1)),onClick:Ae(d.onClick,()=>{b.current!=="mouse"&&k()}),onPointerUp:Ae(d.onPointerUp,()=>{b.current==="mouse"&&k()}),onPointerDown:Ae(d.onPointerDown,N=>{b.current=N.pointerType}),onPointerMove:Ae(d.onPointerMove,N=>{b.current=N.pointerType,o?h.onItemLeave?.():b.current==="mouse"&&N.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ae(d.onPointerLeave,N=>{N.currentTarget===document.activeElement&&h.onItemLeave?.()}),onKeyDown:Ae(d.onKeyDown,N=>{h.searchRef?.current!==""&&N.key===" "||(e3.includes(N.key)&&k(),N.key===" "&&N.preventDefault())})})})})});y1.displayName=um;var pc="SelectItemText",j1=m.forwardRef((t,s)=>{const{__scopeSelect:n,className:a,style:o,...l}=t,d=wi(pc,n),u=bi(pc,n),h=v1(pc,n),f=r3(pc,n),[g,x]=m.useState(null),v=At(s,k=>x(k),h.onItemTextChange,k=>u.itemTextRefCallback?.(k,h.value,h.disabled)),w=g?.textContent,C=m.useMemo(()=>e.jsx("option",{value:h.value,disabled:h.disabled,children:w},h.value),[h.disabled,h.value,w]),{onNativeOptionAdd:j,onNativeOptionRemove:b}=f;return cn(()=>(j(C),()=>b(C)),[j,b,C]),e.jsxs(e.Fragment,{children:[e.jsx(at.span,{id:h.textId,...l,ref:v}),h.isSelected&&d.valueNode&&!d.valueNodeHasChildren?Mr.createPortal(l.children,d.valueNode):null]})});j1.displayName=pc;var w1="SelectItemIndicator",b1=m.forwardRef((t,s)=>{const{__scopeSelect:n,...a}=t;return v1(w1,n).isSelected?e.jsx(at.span,{"aria-hidden":!0,...a,ref:s}):null});b1.displayName=w1;var rg="SelectScrollUpButton",N1=m.forwardRef((t,s)=>{const n=bi(rg,t.__scopeSelect),a=Ux(rg,t.__scopeSelect),[o,l]=m.useState(!1),d=At(s,a.onScrollButtonChange);return cn(()=>{if(n.viewport&&n.isPositioned){let u=function(){const f=h.scrollTop>0;l(f)};const h=n.viewport;return u(),h.addEventListener("scroll",u),()=>h.removeEventListener("scroll",u)}},[n.viewport,n.isPositioned]),o?e.jsx(C1,{...t,ref:d,onAutoScroll:()=>{const{viewport:u,selectedItem:h}=n;u&&h&&(u.scrollTop=u.scrollTop-h.offsetHeight)}}):null});N1.displayName=rg;var ag="SelectScrollDownButton",S1=m.forwardRef((t,s)=>{const n=bi(ag,t.__scopeSelect),a=Ux(ag,t.__scopeSelect),[o,l]=m.useState(!1),d=At(s,a.onScrollButtonChange);return cn(()=>{if(n.viewport&&n.isPositioned){let u=function(){const f=h.scrollHeight-h.clientHeight,g=Math.ceil(h.scrollTop)<f;l(g)};const h=n.viewport;return u(),h.addEventListener("scroll",u),()=>h.removeEventListener("scroll",u)}},[n.viewport,n.isPositioned]),o?e.jsx(C1,{...t,ref:d,onAutoScroll:()=>{const{viewport:u,selectedItem:h}=n;u&&h&&(u.scrollTop=u.scrollTop+h.offsetHeight)}}):null});S1.displayName=ag;var C1=m.forwardRef((t,s)=>{const{__scopeSelect:n,onAutoScroll:a,...o}=t,l=bi("SelectScrollButton",n),d=m.useRef(null),u=oh(n),h=m.useCallback(()=>{d.current!==null&&(window.clearInterval(d.current),d.current=null)},[]);return m.useEffect(()=>()=>h(),[h]),cn(()=>{u().find(g=>g.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[u]),e.jsx(at.div,{"aria-hidden":!0,...o,ref:s,style:{flexShrink:0,...o.style},onPointerDown:Ae(o.onPointerDown,()=>{d.current===null&&(d.current=window.setInterval(a,50))}),onPointerMove:Ae(o.onPointerMove,()=>{l.onItemLeave?.(),d.current===null&&(d.current=window.setInterval(a,50))}),onPointerLeave:Ae(o.onPointerLeave,()=>{h()})})}),g3="SelectSeparator",k1=m.forwardRef((t,s)=>{const{__scopeSelect:n,...a}=t;return e.jsx(at.div,{"aria-hidden":!0,...a,ref:s})});k1.displayName=g3;var ig="SelectArrow",x3=m.forwardRef((t,s)=>{const{__scopeSelect:n,...a}=t,o=lh(n),l=wi(ig,n),d=bi(ig,n);return l.open&&d.position==="popper"?e.jsx(Qg,{...o,...a,ref:s}):null});x3.displayName=ig;function P1(t){return t===""||t===void 0}var T1=m.forwardRef((t,s)=>{const{value:n,...a}=t,o=m.useRef(null),l=At(s,o),d=$x(n);return m.useEffect(()=>{const u=o.current,h=window.HTMLSelectElement.prototype,g=Object.getOwnPropertyDescriptor(h,"value").set;if(d!==n&&g){const x=new Event("change",{bubbles:!0});g.call(u,n),u.dispatchEvent(x)}},[d,n]),e.jsx(Xc,{asChild:!0,children:e.jsx("select",{...a,ref:l,defaultValue:n})})});T1.displayName="BubbleSelect";function E1(t){const s=Rs(t),n=m.useRef(""),a=m.useRef(0),o=m.useCallback(d=>{const u=n.current+d;s(u),(function h(f){n.current=f,window.clearTimeout(a.current),f!==""&&(a.current=window.setTimeout(()=>h(""),1e3))})(u)},[s]),l=m.useCallback(()=>{n.current="",window.clearTimeout(a.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(a.current),[]),[n,o,l]}function _1(t,s,n){const o=s.length>1&&Array.from(s).every(f=>f===s[0])?s[0]:s,l=n?t.indexOf(n):-1;let d=v3(t,Math.max(l,0));o.length===1&&(d=d.filter(f=>f!==n));const h=d.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return h!==n?h:void 0}function v3(t,s){return t.map((n,a)=>t[(s+a)%t.length])}var y3=n1,R1=a1,j3=o1,w3=l1,b3=c1,A1=d1,N3=f1,I1=x1,D1=y1,S3=j1,C3=b1,O1=N1,M1=S1,L1=k1;const lt=y3,ct=j3,it=m.forwardRef(({className:t,children:s,...n},a)=>e.jsxs(R1,{ref:a,className:Oe("flex h-9 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm r
60ing-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...n,children:[s,e.jsx(w3,{asChild:!0,children:e.jsx(On,{className:"h-4 w-4 opacity-50"})})]}));it.displayName=R1.displayName;const F1=m.forwardRef(({className:t,...s},n)=>e.jsx(O1,{ref:n,className:Oe("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Im,{className:"h-4 w-4"})}));F1.displayName=O1.displayName;const $1=m.forwardRef(({className:t,...s},n)=>e.jsx(M1,{ref:n,className:Oe("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(On,{className:"h-4 w-4"})}));$1.displayName=M1.displayName;const ot=m.forwardRef(({className:t,children:s,position:n="popper",...a},o)=>e.jsx(b3,{children:e.jsxs(A1,{ref:o,className:Oe("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...a,children:[e.jsx(F1,{}),e.jsx(N3,{className:Oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx($1,{})]})}));ot.displayName=A1.displayName;const k3=m.forwardRef(({className:t,...s},n)=>e.jsx(I1,{ref:n,className:Oe("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));k3.displayName=I1.displayName;const me=m.forwardRef(({className:t,children:s,...n},a)=>e.jsxs(D1,{ref:a,className:Oe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(C3,{children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsx(S3,{children:s})]}));me.displayName=D1.displayName;const P3=m.forwardRef(({className:t,...s},n)=>e.jsx(L1,{ref:n,className:Oe("-mx-1 my-1 h-px bg-muted",t),...s}));P3.displayName=L1.displayName;const xe=Symbol.for("drizzle:entityKind");function pn(t,s){if(!t||typeof t!="object")return!1;if(t instanceof s)return!0;if(!Object.prototype.hasOwnProperty.call(s,xe))throw new Error(`Class "${s.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(t).constructor;if(n)for(;n;){if(xe in n&&n[xe]===s[xe])return!0;n=Object.getPrototypeOf(n)}return!1}class Mc{constructor(s,n){this.table=s,this.config=n,this.name=n.name,this.keyAsName=n.keyAsName,this.notNull=n.notNull,this.default=n.default,this.defaultFn=n.defaultFn,this.onUpdateFn=n.onUpdateFn,this.hasDefault=n.hasDefault,this.primary=n.primaryKey,this.isUnique=n.isUnique,this.uniqueName=n.uniqueName,this.uniqueType=n.uniqueType,this.dataType=n.dataType,this.columnType=n.columnType,this.generated=n.generated,this.generatedIdentity=n.generatedIdentity}static[xe]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(s){return s}mapToDriverValue(s){return s}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class T3{static[xe]="ColumnBuilder";config;constructor(s,n,a){this.config={name:s,keyAsName:s==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:n,columnType:a,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(s){return this.config.default=s,this.config.hasDefault=!0,this}$defaultFn(s){return this.config.defaultFn=s,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(s){return this.config.onUpdateFn=s,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(s){this.config.name===""&&(this.config.name=s)}}const Go=Symbol.for("drizzle:Name");class E3{static[xe]="PgForeignKeyBuilder";reference;
60_onUpdate="no action";_onDelete="no action";constructor(s,n){this.reference=()=>{const{name:a,columns:o,foreignColumns:l}=s();return{name:a,columns:o,foreignTable:l[0].table,foreignColumns:l}},n&&(this._onUpdate=n.onUpdate,this._onDelete=n.onDelete)}onUpdate(s){return this._onUpdate=s===void 0?"no action":s,this}onDelete(s){return this._onDelete=s===void 0?"no action":s,this}build(s){return new _3(s,this)}}class _3{constructor(s,n){this.table=s,this.reference=n.reference,this.onUpdate=n._onUpdate,this.onDelete=n._onDelete}static[xe]="PgForeignKey";reference;onUpdate;onDelete;getName(){const{name:s,columns:n,foreignColumns:a}=this.reference(),o=n.map(u=>u.name),l=a.map(u=>u.name),d=[this.table[Go],...o,a[0].table[Go],...l];return s??`${d.join("_")}_fk`}}function R3(t,...s){return t(...s)}function A3(t,s){return`${t[Go]}_${s.join("_")}_unique`}function Bw(t,s,n){for(let a=s;a<t.length;a++){const o=t[a];if(o==="\\"){a++;continue}if(o==='"')return[t.slice(s,a).replace(/\\/g,""),a+1];if(!n&&(o===","||o==="}"))return[t.slice(s,a).replace(/\\/g,""),a]}return[t.slice(s).replace(/\\/g,""),t.length]}function U1(t,s=0){const n=[];let a=s,o=!1;for(;a<t.length;){const l=t[a];if(l===","){(o||a===s)&&n.push(""),o=!0,a++;continue}if(o=!1,l==="\\"){a+=2;continue}if(l==='"'){const[h,f]=Bw(t,a+1,!0);n.push(h),a=f;continue}if(l==="}")return[n,a+1];if(l==="{"){const[h,f]=U1(t,a+1);n.push(h),a=f;continue}const[d,u]=Bw(t,a,!1);n.push(d),a=u}return[n,a]}function I3(t){const[s]=U1(t,1);return s}function z1(t){return`{${t.map(s=>Array.isArray(s)?z1(s):typeof s=="string"?`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${s}`).join(",")}}`}class Yt extends T3{foreignKeyConfigs=[];static[xe]="PgColumnBuilder";array(s){return new O3(this.config.name,this,s)}references(s,n={}){return this.foreignKeyConfigs.push({ref:s,actions:n}),this}unique(s,n){return this.config.isUnique=!0,this.config.uniqueName=s,this.config.uniqueType=n?.nulls,this}generatedAlwaysAs(s){return this.config.generated={as:s,type:"always",mode:"stored"},this}buildForeignKeys(s,n){return this.foreignKeyConfigs.map(({ref:a,actions:o})=>R3((l,d)=>{const u=new E3(()=>{const h=l();return{columns:[s],foreignColumns:[h]}});return d.onUpdate&&u.onUpdate(d.onUpdate),d.onDelete&&u.onDelete(d.onDelete),u.build(n)},a,o))}buildExtraConfigColumn(s){return new D3(s,this.config)}}class Dt extends Mc{constructor(s,n){n.uniqueName||(n.uniqueName=A3(s,[n.name])),super(s,n),this.table=s}static[xe]="PgColumn"}class D3 extends Dt{static[xe]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(s){return this.indexConfig.opClass=s,this}}class O3 extends Yt{static[xe]="PgArrayBuilder";constructor(s,n,a){super(s,"array","PgArray"),this.config.baseBuilder=n,this.config.size=a}build(s){const n=this.config.baseBuilder.build(s);return new zx(s,this.config,n)}}class zx extends Dt{constructor(s,n,a,o){super(s,n),this.baseColumn=a,this.range=o,this.size=n.size}size;static[xe]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size=="number"?this.size:""}]`}mapFromDriverValue(s){return typeof s=="string"&&(s=I3(s)),s.map(n=>this.baseColumn.mapFromDriverValue(n))}mapToDriverValue(s,n=!1){const a=s.map(o=>o===null?null:pn(this.baseColumn,zx)?this.baseColumn.mapToDriverValue(o,!0):this.baseColumn.mapToDriverValue(o));return n?a:z1(a)}}const Vw=Symbol.for("drizzle:isPgEnum");function M3(t){return!!t&&typeof t=="function"&&Vw in t&&t[Vw]===!0}class B1{static[xe]="Subquery";constructor(s,n,a,o=!1){this._={brand:"Subquery",sql:s,selectedFields:n,alias:a,isWith:o}}}const L3={startActiveSpan(t,s){return s()}},Yo=Symbol.for("drizzle:ViewBaseConfig"),wp=Symbol.for("drizzle:Schema"),qw=Symbol.for("drizzle:Columns"),Kw=Symbol.for("drizzle:ExtraConfigColumns"),bp=Symbol.for("drizzle:OriginalName"),Np=Symbol.for("drizzle:BaseName"),mm=Symbol.for("drizzle:IsAlias"),Hw=Symbol.for("drizzle:ExtraConfigBuilder"),V1=Symbol.for("drizzle:IsDrizzleTable");class or{static[xe]="Table";static Symbol={Name:Go,Schema:wp,OriginalName:bp,Columns:qw,ExtraConfigColumns:Kw,BaseName:Np,IsAlias:mm,ExtraConfigBuilder:Hw};[Go];[bp];[wp];[qw];[Kw];[Np];[mm]=!1;[V1]=!0;[Hw]=void 0;constructor(s,n,a){this[Go]=this[bp]=s,this[wp]=n,this[Np]=a}}function q1(t){return typeof t=="object"&&t!==null&&V1 in t}function F3(t){return t!=null&&typeof t.getSQL=="function"}function $3(t){const s={sql:"",params:[]};for(const n of t)s.sql+=n.sql,s.params.push(...n.params),n.typings?.length&&(s.typings||(s.typings=[]),s.typings.push(...n.typings));return s}class Dr{static[xe]="StringChunk";value;constructor(s){this.value=Array.isArray(s)?s:[s]}getSQL(){return new Ms([this])}}class Ms{constructor(s){this.queryChunks=s}static[xe]="SQL";decoder=K1;shouldInlineParams=!1;
60append(s){return this.queryChunks.push(...s.queryChunks),this}toQuery(s){return L3.startActiveSpan("drizzle.buildSQL",n=>{const a=this.buildQueryFromSourceParams(this.queryChunks,s);return n?.setAttributes({"drizzle.query.text":a.sql,"drizzle.query.params":JSON.stringify(a.params)}),a})}buildQueryFromSourceParams(s,n){const a=Object.assign({},n,{inlineParams:n.inlineParams||this.shouldInlineParams,paramStartIndex:n.paramStartIndex||{value:0}}),{casing:o,escapeName:l,escapeParam:d,prepareTyping:u,inlineParams:h,paramStartIndex:f}=a;return $3(s.map(g=>{if(pn(g,Dr))return{sql:g.value.join(""),params:[]};if(pn(g,og))return{sql:l(g.value),params:[]};if(g===void 0)return{sql:"",params:[]};if(Array.isArray(g)){const x=[new Dr("(")];for(const[v,w]of g.entries())x.push(w),v<g.length-1&&x.push(new Dr(", "));return x.push(new Dr(")")),this.buildQueryFromSourceParams(x,a)}if(pn(g,Ms))return this.buildQueryFromSourceParams(g.queryChunks,{...a,inlineParams:h||g.shouldInlineParams});if(pn(g,or)){const x=g[or.Symbol.Schema],v=g[or.Symbol.Name];return{sql:x===void 0||g[mm]?l(v):l(x)+"."+l(v),params:[]}}if(pn(g,Mc)){const x=o.getColumnCasing(g);if(n.invokeSource==="indexes")return{sql:l(x),params:[]};const v=g.table[or.Symbol.Schema];return{sql:g.table[mm]||v===void 0?l(g.table[or.Symbol.Name])+"."+l(x):l(v)+"."+l(g.table[or.Symbol.Name])+"."+l(x),params:[]}}if(pn(g,U3)){const x=g[Yo].schema,v=g[Yo].name;return{sql:x===void 0||g[Yo].isAlias?l(v):l(x)+"."+l(v),params:[]}}if(pn(g,W1)){if(pn(g.value,lg))return{sql:d(f.value++,g),params:[g],typings:["none"]};const x=g.value===null?null:g.encoder.mapToDriverValue(g.value);if(pn(x,Ms))return this.buildQueryFromSourceParams([x],a);if(h)return{sql:this.mapInlineParam(x,a),params:[]};let v=["none"];return u&&(v=[u(g.encoder)]),{sql:d(f.value++,x),params:[x],typings:v}}return pn(g,lg)?{sql:d(f.value++,g),params:[g],typings:["none"]}:pn(g,Ms.Aliased)&&g.fieldAlias!==void 0?{sql:l(g.fieldAlias),params:[]}:pn(g,B1)?g._.isWith?{sql:l(g._.alias),params:[]}:this.buildQueryFromSourceParams([new Dr("("),g._.sql,new Dr(") "),new og(g._.alias)],a):M3(g)?g.schema?{sql:l(g.schema)+"."+l(g.enumName),params:[]}:{sql:l(g.enumName),params:[]}:F3(g)?g.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([g.getSQL()],a):this.buildQueryFromSourceParams([new Dr("("),g.getSQL(),new Dr(")")],a):h?{sql:this.mapInlineParam(g,a),params:[]}:{sql:d(f.value++,g),params:[g],typings:["none"]}}))}mapInlineParam(s,{escapeString:n}){if(s===null)return"null";if(typeof s=="number"||typeof s=="boolean")return s.toString();if(typeof s=="string")return n(s);if(typeof s=="object"){const a=s.toString();return n(a==="[object Object]"?JSON.stringify(s):a)}throw new Error("Unexpected param value: "+s)}getSQL(){return this}as(s){return s===void 0?this:new Ms.Aliased(this,s)}mapWith(s){return this.decoder=typeof s=="function"?{mapFromDriverValue:s}:s,this}inlineParams(){return this.shouldInlineParams=!0,this}if(s){return s?this:void 0}}class og{constructor(s){this.value=s}static[xe]="Name";brand;getSQL(){return new Ms([this])}}const K1={mapFromDriverValue:t=>t},H1={mapToDriverValue:t=>t};({...K1,...H1});class W1{constructor(s,n=H1){this.value=s,this.encoder=n}static[xe]="Param";brand;getSQL(){return new Ms([this])}}function Et(t,...s){const n=[];(s.length>0||t.length>0&&t[0]!=="")&&n.push(new Dr(t[0]));for(const[a,o]of s.entries())n.push(o,new Dr(t[a+1]));return new Ms(n)}(t=>{function s(){return new Ms([])}t.empty=s;function n(h){return new Ms(h)}t.fromList=n;function a(h){return new Ms([new Dr(h)])}t.raw=a;function o(h,f){const g=[];for(const[x,v]of h.entries())x>0&&f!==void 0&&g.push(f),g.push(v);return new Ms(g)}t.join=o;function l(h){return new og(h)}t.identifier=l;function d(h){return new lg(h)}t.placeholder=d;function u(h,f){return new W1(h,f)}t.param=u})(Et||(Et={}));(t=>{class s{constructor(a,o){this.sql=a,this.fieldAlias=o}static[xe]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new s(this.sql,this.fieldAlias)}}t.Aliased=s})(Ms||(Ms={}));class lg{constructor(s){this.name=s}static[xe]="Placeholder";getSQL(){return new Ms([this])}}const Q1=Symbol.for("drizzle:IsDrizzleView");class U3{static[xe]="View";[Yo];[Q1]=!0;constructor({name:s,schema:n,selectedFields:a,query:o}){this[Yo]={name:s,originalName:s,schema:n,selectedFields:a,query:o,isExisting:!o,isAlias:!1}}getSQL(){return new Ms([this])}}function z3(t){return typeof t=="object"&&t!==null&&Q1 in t}Mc.prototype.getSQL=function(){return new Ms([this])};or.prototype.getSQL=function(){return new Ms([this])};B1.prototype.getSQL=function(){return new Ms([this])};function B3(t){return t[or.Symbol.Columns]}function V3(t){return t[Yo].selectedFields}function dn(t,s){return{name:typeof t=="string"&&t.length>0?t:"",config:typeof t=="object"?t:s}}class ch extends Yt{static[xe]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(s){if(s){const{name:n,...a}=s;this.config.generatedIdentity={type:"always",sequenceName:n,sequenceOptions:a}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(s){if(s){const{name:n,...a}=s;this.config.generatedIdentity={type:"byDefault",sequenceName:n,sequenceOptions:a}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class q3 extends ch{static[xe]="PgBigInt53Builder";constructor(s){super(s,"number","PgBigInt53")}build(s){return new K3(s,this.config)}}class K3 extends Dt{static[xe]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(s){return typeof s=="number"?s:Number(s)}}class H3 extends ch{static[xe]="PgBigInt64Builder";constructor(s){super(s,"bigint","PgBigInt64")}build(s){return new W3(s,this.config)}}class W3 extends Dt{static[xe]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(s){return BigInt(s)}}function Q3(t,s){const{name:n,config:a}=dn(t,s);return a.mode==="number"?new q3(n):new H3(n)}
60class G3 extends Yt{static[xe]="PgBigSerial53Builder";constructor(s){super(s,"number","PgBigSerial53"),this.config.hasDefault=!0,this.config.notNull=!0}build(s){return new Y3(s,this.config)}}class Y3 extends Dt{static[xe]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(s){return typeof s=="number"?s:Number(s)}}class Z3 extends Yt{static[xe]="PgBigSerial64Builder";constructor(s){super(s,"bigint","PgBigSerial64"),this.config.hasDefault=!0}build(s){return new X3(s,this.config)}}class X3 extends Dt{static[xe]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(s){return BigInt(s)}}function J3(t,s){const{name:n,config:a}=dn(t,s);return a.mode==="number"?new G3(n):new Z3(n)}class eL extends Yt{static[xe]="PgBooleanBuilder";constructor(s){super(s,"boolean","PgBoolean")}build(s){return new tL(s,this.config)}}class tL extends Dt{static[xe]="PgBoolean";getSQLType(){return"boolean"}}function Qs(t){return new eL(t??"")}class sL extends Yt{static[xe]="PgCharBuilder";constructor(s,n){super(s,"string","PgChar"),this.config.length=n.length,this.config.enumValues=n.enum}build(s){return new nL(s,this.config)}}class nL extends Dt{static[xe]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function rL(t,s={}){const{name:n,config:a}=dn(t,s);return new sL(n,a)}class aL extends Yt{static[xe]="PgCidrBuilder";constructor(s){super(s,"string","PgCidr")}build(s){return new iL(s,this.config)}}class iL extends Dt{static[xe]="PgCidr";getSQLType(){return"cidr"}}function oL(t){return new aL(t??"")}class lL extends Yt{static[xe]="PgCustomColumnBuilder";constructor(s,n,a){super(s,"custom","PgCustomColumn"),this.config.fieldConfig=n,this.config.customTypeParams=a}build(s){return new cL(s,this.config)}}class cL extends Dt{static[xe]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(s,n){super(s,n),this.sqlName=n.customTypeParams.dataType(n.fieldConfig),this.mapTo=n.customTypeParams.toDriver,this.mapFrom=n.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(s){return typeof this.mapFrom=="function"?this.mapFrom(s):s}mapToDriverValue(s){return typeof this.mapTo=="function"?this.mapTo(s):s}}function dL(t){return(s,n)=>{const{name:a,config:o}=dn(s,n);return new lL(a,o,t)}}class fd extends Yt{static[xe]="PgDateColumnBaseBuilder";defaultNow(){return this.default(Et`now()`)}}class uL extends fd{static[xe]="PgDateBuilder";constructor(s){super(s,"date","PgDate")}build(s){return new mL(s,this.config)}}class mL extends Dt{static[xe]="PgDate";getSQLType(){return"date"}mapFromDriverValue(s){return new Date(s)}mapToDriverValue(s){return s.toISOString()}}class hL extends fd{static[xe]="PgDateStringBuilder";constructor(s){super(s,"string","PgDateString")}build(s){return new fL(s,this.config)}}class fL extends Dt{static[xe]="PgDateString";
60getSQLType(){return"date"}}function pL(t,s){const{name:n,config:a}=dn(t,s);return a?.mode==="date"?new uL(n):new hL(n)}class gL extends Yt{static[xe]="PgDoublePrecisionBuilder";constructor(s){super(s,"number","PgDoublePrecision")}build(s){return new xL(s,this.config)}}class xL extends Dt{static[xe]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(s){return typeof s=="string"?Number.parseFloat(s):s}}function vL(t){return new gL(t??"")}class yL extends Yt{static[xe]="PgInetBuilder";constructor(s){super(s,"string","PgInet")}build(s){return new jL(s,this.config)}}class jL extends Dt{static[xe]="PgInet";getSQLType(){return"inet"}}function wL(t){return new yL(t??"")}class bL extends ch{static[xe]="PgIntegerBuilder";constructor(s){super(s,"number","PgInteger")}build(s){return new NL(s,this.config)}}class NL extends Dt{static[xe]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(s){return typeof s=="string"?Number.parseInt(s):s}}function os(t){return new bL(t??"")}class SL extends Yt{static[xe]="PgIntervalBuilder";constructor(s,n){super(s,"string","PgInterval"),this.config.intervalConfig=n}build(s){return new CL(s,this.config)}}class CL extends Dt{static[xe]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){const s=this.fields?` ${this.fields}`:"",n=this.precision?`(${this.precision})`:"";return`interval${s}${n}`}}function kL(t,s={}){const{name:n,config:a}=dn(t,s);return new SL(n,a)}class PL extends Yt{static[xe]="PgJsonBuilder";constructor(s){super(s,"json","PgJson")}build(s){return new TL(s,this.config)}}class TL extends Dt{static[xe]="PgJson";constructor(s,n){super(s,n)}getSQLType(){return"json"}mapToDriverValue(s){return JSON.stringify(s)}mapFromDriverValue(s){if(typeof s=="string")try{return JSON.parse(s)}catch{return s}return s}}function EL(t){return new PL(t??"")}class _L extends Yt{static[xe]="PgJsonbBuilder";constructor(s){super(s,"json","PgJsonb")}build(s){return new RL(s,this.config)}}class RL extends Dt{static[xe]="PgJsonb";constructor(s,n){super(s,n)}getSQLType(){return"jsonb"}mapToDriverValue(s){return JSON.stringify(s)}mapFromDriverValue(s){if(typeof s=="string")try{return JSON.parse(s)}catch{return s}return s}}function br(t){return new _L(t??"")}class AL extends Yt{static[xe]="PgLineBuilder";constructor(s){super(s,"array","PgLine")}build(s){return new IL(s,this.config)}}class IL extends Dt{static[xe]="PgLine";getSQLType(){return"line"}mapFromDriverValue(s){const[n,a,o]=s.slice(1,-1).split(",");return[Number.parseFloat(n),Number.parseFloat(a),Number.parseFloat(o)]}mapToDriverValue(s){return`{${s[0]},${s[1]},${s[2]}}`}}class DL extends Yt{static[xe]="PgLineABCBuilder";constructor(s){super(s,"json","PgLineABC")}build(s){return new OL(s,this.config)}}class OL extends Dt{static[xe]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(s){const[n,a,o]=s.slice(1,-1).split(",");return{a:Number.parseFloat(n),b:Number.parseFloat(a),c:Number.parseFloat(o)}}mapToDriverValue(s){return`{${s.a},${s.b},${s.c}}`}}function ML(t,s){const{name:n,config:a}=dn(t,s);return!a?.mode||a.mode==="tuple"?new AL(n):new DL(n)}class LL extends Yt{static[xe]="PgMacaddrBuilder";constructor(s){super(s,"string","PgMacaddr")}build(s){return new FL(s,this.config)}}class FL extends Dt{static[xe]="PgMacaddr";getSQLType(){return"macaddr"}}function $L(t){return new LL(t??"")}class UL extends Yt{static[xe]="PgMacaddr8Builder";constructor(s){super(s,"string","PgMacaddr8")}build(s){return new zL(s,this.config)}}class zL extends Dt{static[xe]="PgMacaddr8";getSQLType(){return"macaddr8"}}function BL(t){return new UL(t??"")}class VL extends Yt{static[xe]="PgNumericBuilder";constructor(s,n,a){super(s,"string","PgNumeric"),this.config.precision=n,this.config.scale=a}build(s){return new qL(s,this.config)}}class qL extends Dt{static[xe]="PgNumeric";precision;scale;constructor(s,n){super(s,n),this.precision=n.precision,this.scale=n.scale}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}}function KL(t,s){const{name:n,config:a}=dn(t,s);return new VL(n,a?.precision,a?.scale)}class HL extends Yt{static[xe]="PgPointTupleBuilder";constructor(s){super(s,"array","PgPointTuple")}build(s){return new WL(s,this.config)}}class WL extends Dt{static[xe]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(s){if(typeof s=="string"){const[n,a]=s.slice(1,-1).split(",");return[Number.parseFloat(n),Number.parseFloat(a)]}return[s.x,s.y]}mapToDriverValue(s){return`(${s[0]},${s[1]})`}}class QL extends Yt{static[xe]="PgPointObjectBuilder";constructor(s){super(s,"json","PgPointObject")}build(s){return new GL(s,this.config)}}class GL extends Dt{static[xe]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(s){if(typeof s=="string"){const[n,a]=s.slice(1,-1).split(",");return{x:Number.parseFloat(n),y:Number.parseFloat(a)}}return s}mapToDriverValue(s){return`(${s.x},${s.y})`}}function YL(t,s){const{name:n,config:a}=dn(t,s);return!a?.mode||a.mode==="tuple"?new HL(n):new QL(n)}function ZL(t){const s=[];for(let n=0;n<t.length;n+=2)s.push(Number.parseInt(t.slice(n,n+2),16));return new Uint8Array(s)}function Ww(t,s){const n=new ArrayBuffer(8),a=new DataView(n);for(let o=0;o<8;o++)a.setUint8(o,t[s+o]);return a.getFloat64(0,!0)}function G1(t){const s=ZL(t);let n=0;const a=s[n];n+=1;const o=new DataView(s.buffer),l=o.getUint32(n,a===1);if(n+=4,l&536870912&&(o.getUint32(n,a===1),n+=4),(l&65535)===1){const d=Ww(s,n);n+=8;const u=Ww(s,n);return n+=8,[d,u]}throw new Error("Unsupported geometry type")}class XL extends Yt{static[xe]="PgGeometryBuilder";constructor(s){super(s,"array","PgGeometry")}build(s){return new JL(s,this.config)}}class JL extends Dt{static[xe]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue(s){return G1(s)}mapToDriverValue(s){return`point(${s[0]} ${s[1]})`}}class eF extends Yt{static[xe]="PgGeometryObjectBuilder";constructor(s){super(s,"json","PgGeometryObject")}build(s){return new tF(s,this.config)}}class tF extends Dt{static[xe]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue(s){const n=G1(s);return{x:n[0],y:n[1]}}mapToDriverValue(s){return`point(${s.x} ${s.y})`}}function sF(t,s){const{name:n,config:a}=dn(t,s);return!a?.mode||a.mode==="tuple"?new XL(n):new eF(n)}class nF extends Yt{static[xe]="PgRealBuilder";constructor(s,n){super(s,"number","PgReal"),this.config.length=n}build(s){return new rF(s,this.config)}}class rF extends Dt{static[xe]="PgReal";constructor(s,n){super(s,n)}getSQLType(){return"real"}mapFromDriverValue=s=>typeof s=="string"?Number.parseFloat(s):s}function aF(t){return new nF(t??"")}class iF extends Yt{static[xe]="PgSerialBuilder";constructor(s){super(s,"number","PgSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(s){return new oF(s,this.config)}}class oF extends Dt{static[xe]="PgSerial";
60getSQLType(){return"serial"}}function lF(t){return new iF(t??"")}class cF extends ch{static[xe]="PgSmallIntBuilder";constructor(s){super(s,"number","PgSmallInt")}build(s){return new dF(s,this.config)}}class dF extends Dt{static[xe]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=s=>typeof s=="string"?Number(s):s}function uF(t){return new cF(t??"")}class mF extends Yt{static[xe]="PgSmallSerialBuilder";constructor(s){super(s,"number","PgSmallSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(s){return new hF(s,this.config)}}class hF extends Dt{static[xe]="PgSmallSerial";getSQLType(){return"smallserial"}}function fF(t){return new mF(t??"")}class pF extends Yt{static[xe]="PgTextBuilder";constructor(s,n){super(s,"string","PgText"),this.config.enumValues=n.enum}build(s){return new gF(s,this.config)}}class gF extends Dt{static[xe]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function oe(t,s={}){const{name:n,config:a}=dn(t,s);return new pF(n,a)}class xF extends fd{constructor(s,n,a){super(s,"string","PgTime"),this.withTimezone=n,this.precision=a,this.config.withTimezone=n,this.config.precision=a}static[xe]="PgTimeBuilder";build(s){return new vF(s,this.config)}}class vF extends Dt{static[xe]="PgTime";withTimezone;precision;constructor(s,n){super(s,n),this.withTimezone=n.withTimezone,this.precision=n.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function yF(t,s={}){const{name:n,config:a}=dn(t,s);return new xF(n,a.withTimezone??!1,a.precision)}class jF extends fd{static[xe]="PgTimestampBuilder";constructor(s,n,a){super(s,"date","PgTimestamp"),this.config.withTimezone=n,this.config.precision=a}build(s){return new wF(s,this.config)}}class wF extends Dt{static[xe]="PgTimestamp";withTimezone;precision;constructor(s,n){super(s,n),this.withTimezone=n.withTimezone,this.precision=n.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=s=>new Date(this.withTimezone?s:s+"+0000");mapToDriverValue=s=>s.toISOString()}class bF extends fd{static[xe]="PgTimestampStringBuilder";constructor(s,n,a){super(s,"string","PgTimestampString"),this.config.withTimezone=n,this.config.precision=a}build(s){return new NF(s,this.config)}}class NF extends Dt{static[xe]="PgTimestampString";withTimezone;precision;constructor(s,n){super(s,n),this.withTimezone=n.withTimezone,this.precision=n.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function Ze(t,s={}){const{name:n,config:a}=dn(t,s);return a?.mode==="string"?new bF(n,a.withTimezone??!1,a.precision):new jF(n,a?.withTimezone??!1,a?.precision)}class SF extends Yt{static[xe]="PgUUIDBuilder";constructor(s){super(s,"string","PgUUID")}defaultRandom(){return this.default(Et`gen_random_uuid()`)}build(s){return new CF(s,this.config)}}class CF extends Dt{static[xe]="PgUUID";getSQLType(){return"uuid"}}function kF(t){return new SF(t??"")}class PF extends Yt{static[xe]="PgVarcharBuilder";constructor(s,n){super(s,"string","PgVarchar"),this.config.length=n.length,this.config.enumValues=n.enum}build(s){return new TF(s,this.config)}}class TF extends Dt{static[xe]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function Ne(t,s={}){const{name:n,config:a}=dn(t,s);return new PF(n,a)}class EF extends Yt{static[xe]="PgBinaryVectorBuilder";constructor(s,n){super(s,"string","PgBinaryVector"),this.config.dimensions=n.dimensions}build(s){return new _F(s,this.config)}}class _F extends Dt{static[xe]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function RF(t,s){const{name:n,config:a}=dn(t,s);return new EF(n,a)}class AF extends Yt{static[xe]="PgHalfVectorBuilder";constructor(s,n){super(s,"array","PgHalfVector"),this.config.dimensions=n.dimensions}build(s){return new IF(s,this.config)}}class IF extends Dt{static[xe]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(s){return JSON.stringify(s)}mapFromDriverValue(s){return s.slice(1,-1).split(",").map(n=>Number.parseFloat(n))}}function DF(t,s){const{name:n,config:a}=dn(t,s);return new AF(n,a)}class OF extends Yt{static[xe]="PgSparseVectorBuilder";constructor(s,n){super(s,"string","PgSparseVector"),this.config.dimensions=n.dimensions}build(s){return new MF(s,this.config)}}class MF extends Dt{static[xe]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}
60function LF(t,s){const{name:n,config:a}=dn(t,s);return new OF(n,a)}class FF extends Yt{static[xe]="PgVectorBuilder";constructor(s,n){super(s,"array","PgVector"),this.config.dimensions=n.dimensions}build(s){return new $F(s,this.config)}}class $F extends Dt{static[xe]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(s){return JSON.stringify(s)}mapFromDriverValue(s){return s.slice(1,-1).split(",").map(n=>Number.parseFloat(n))}}function UF(t,s){const{name:n,config:a}=dn(t,s);return new FF(n,a)}function zF(){return{bigint:Q3,bigserial:J3,boolean:Qs,char:rL,cidr:oL,customType:dL,date:pL,doublePrecision:vL,inet:wL,integer:os,interval:kL,json:EL,jsonb:br,line:ML,macaddr:$L,macaddr8:BL,numeric:KL,point:YL,geometry:sF,real:aF,serial:lF,smallint:uF,smallserial:fF,text:oe,time:yF,timestamp:Ze,uuid:kF,varchar:Ne,bit:RF,halfvec:DF,sparsevec:LF,vector:UF}}const cg=Symbol.for("drizzle:PgInlineForeignKeys"),Qw=Symbol.for("drizzle:EnableRLS");class Gw extends or{static[xe]="PgTable";static Symbol=Object.assign({},or.Symbol,{InlineForeignKeys:cg,EnableRLS:Qw});[cg]=[];[Qw]=!1;[or.Symbol.ExtraConfigBuilder]=void 0}function BF(t,s,n,a,o=t){const l=new Gw(t,a,o),d=typeof s=="function"?s(zF()):s,u=Object.fromEntries(Object.entries(d).map(([g,x])=>{const v=x;v.setName(g);const w=v.build(l);return l[cg].push(...v.buildForeignKeys(w,l)),[g,w]})),h=Object.fromEntries(Object.entries(d).map(([g,x])=>{const v=x;v.setName(g);const w=v.buildExtraConfigColumn(l);return[g,w]})),f=Object.assign(l,u);return f[or.Symbol.Columns]=u,f[or.Symbol.ExtraConfigColumns]=h,Object.assign(f,{enableRLS:()=>(f[Gw.Symbol.EnableRLS]=!0,f)})}const Mt=(t,s,n)=>BF(t,s,n,void 0);var Ht;(function(t){t.assertEqual=o=>o;function s(o){}t.assertIs=s;function n(o){throw new Error}t.assertNever=n,t.arrayToEnum=o=>{const l={};for(const d of o)l[d]=d;return l},t.getValidEnumValues=o=>{const l=t.objectKeys(o).filter(u=>typeof o[o[u]]!="number"),d={};for(const u of l)d[u]=o[u];return t.objectValues(d)},t.objectValues=o=>t.objectKeys(o).map(function(l){return o[l]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const l=[];for(const d in o)Object.prototype.hasOwnProperty.call(o,d)&&l.push(d);return l},t.find=(o,l)=>{for(const d of o)if(l(d))return d},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&isFinite(o)&&Math.floor(o)===o;function a(o,l=" | "){return o.map(d=>typeof d=="string"?`'${d}'`:d).join(l)}t.joinValues=a,t.jsonStringifyReplacer=(o,l)=>typeof l=="bigint"?l.toString():l})(Ht||(Ht={}));var dg;(function(t){t.mergeShapes=(s,n)=>({...s,...n})})(dg||(dg={}));const We=Ht.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ca=t=>{switch(typeof t){case"undefined":return We.undefined;case"string":return We.string;case"number":return isNaN(t)?We.nan:We.number;case"boolean":return We.boolean;case"function":return We.function;case"bigint":return We.bigint;case"symbol":return We.symbol;case"object":return Array.isArray(t)?We.array:t===null?We.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?We.promise:typeof Map<"u"&&t instanceof Map?We.map:typeof Set<"u"&&t instanceof Set?We.set:typeof Date<"u"&&t instanceof Date?We.date:We.object;default:return We.unknown}}
vendor: 52,817 bytes, line 60
60,ke=Ht.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),VF=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class dr extends Error{get errors(){return this.issues}constructor(s){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=s}format(s){const n=s||function(l){return l.message},a={_errors:[]},o=l=>{for(const d of l.issues)if(d.code==="invalid_union")d.unionErrors.map(o);else if(d.code==="invalid_return_type")o(d.returnTypeError);else if(d.code==="invalid_arguments")o(d.argumentsError);else if(d.path.length===0)a._errors.push(n(d));else{let u=a,h=0;for(;h<d.path.length;){const f=d.path[h];h===d.path.length-1?(u[f]=u[f]||{_errors:[]},u[f]._errors.push(n(d))):u[f]=u[f]||{_errors:[]},u=u[f],h++}}};return o(this),a}static assert(s){if(!(s instanceof dr))throw new Error(`Not a ZodError: ${s}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ht.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(s=n=>n.message){const n={},a=[];for(const o of this.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(s(o))):a.push(s(o));return{formErrors:a,fieldErrors:n}}get formErrors(){return this.flatten()}}dr.create=t=>new dr(t);const ol=(t,s)=>{let n;switch(t.code){case ke.invalid_type:t.received===We.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case ke.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Ht.jsonStringifyReplacer)}`;break;case ke.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ht.joinValues(t.keys,", ")}`;break;case ke.invalid_union:n="Invalid input";break;case ke.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ht.joinValues(t.options)}`;break;case ke.invalid_enum_value:n=`Invalid enum value. Expected ${Ht.joinValues(t.options)}, received '${t.received}'`;break;case ke.invalid_arguments:n="Invalid function arguments";break;case ke.invalid_return_type:n="Invalid function return type";break;case ke.invalid_date:n="Invalid date";break;case ke.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Ht.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case ke.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case ke.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case ke.custom:n="Invalid input";break;case ke.invalid_intersection_types:n="Intersection results could not be merged";break;case ke.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case ke.not_finite:n="Number must be finite";break;default:n=s.defaultError,Ht.assertNever(t)}return{message:n}};let Y1=ol;function qF(t){Y1=t}function hm(){return Y1}const fm=t=>{const{data:s,path:n,errorMaps:a,issueData:o}=t,l=[...n,...o.path||[]],d={...o,path:l};if(o.message!==void 0)return{...o,path:l,message:o.message};let u="";const h=a.filter(f=>!!f).slice().reverse();for(const f of h)u=f(d,{data:s,defaultError:u}).message;return{...o,path:l,message:u}},KF=[];function Fe(t,s){const n=hm(),a=fm({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ol?void 0:ol].filter(o=>!!o)});t.common.issues.push(a)}class Tn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(s,n){const a=[];for(const o of n){if(o.status==="aborted")return vt;o.status==="dirty"&&s.dirty(),a.push(o.value)}return{status:s.value,value:a}}static async mergeObjectAsync(s,n){const a=[];for(const o of n){const l=await o.key,d=await o.value;a.push({key:l,value:d})}return Tn.mergeObjectSync(s,a)}static mergeObjectSync(s,n){const a={};for(const o of n){const{key:l,value:d}=o;if(l.status==="aborted"||d.status==="aborted")return vt;l.status==="dirty"&&s.dirty(),d.status==="dirty"&&s.dirty(),l.value!=="__proto__"&&(typeof d.value<"u"||o.alwaysSet)&&(a[l.value]=d.value)}return{status:s.value,value:a}}}const vt=Object.freeze({status:"aborted"}),Bo=t=>({status:"dirty",value:t}),Fn=t=>({status:"valid",value:t}),ug=t=>t.status==="aborted",mg=t=>t.status==="dirty",Xi=t=>t.status==="valid",Lc=t=>typeof Promise<"u"&&t instanceof Promise;function pm(t,s,n,a){if(typeof s=="function"?t!==s||!0:!s.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return s.get(t)}function Z1(t,s,n,a,o){if(typeof s=="function"?t!==s||!0:!s.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s.set(t,n),n}var rt;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s?.message})(rt||(rt={}));var gc,xc;class ca{constructor(s,n,a,o){this._cachedPath=[],this.parent=s,this.data=n,this._path=a,this._key=o}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Yw=(t,s)=>{if(Xi(s))return{success:!0,data:s.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new dr(t.common.issues);return this._error=n,this._error}}};function Rt(t){if(!t)return{};const{errorMap:s,invalid_type_error:n,required_error:a,description:o}=t;if(s&&(n||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return s?{errorMap:s,description:o}:{errorMap:(d,u)=>{var h,f;const{message:g}=t;return d.code==="invalid_enum_value"?{message:g??u.defaultError}:typeof u.data>"u"?{message:(h=g??a)!==null&&h!==void 0?h:u.defaultError}:d.code!=="invalid_type"?{message:u.defaultError}:{message:(f=g??n)!==null&&f!==void 0?f:u.defaultError}},description:o}}class Ot{get description(){return this._def.description}_getType(s){return Ca(s.data)}_getOrReturnCtx(s,n){return n||{common:s.parent.common,data:s.data,parsedType:Ca(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new Tn,ctx:{common:s.parent.common,data:s.data,parsedType:Ca(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const n=this._parse(s);if(Lc(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(s){const n=this._parse(s);return Promise.resolve(n)}parse(s,n){const a=this.safeParse(s,n);if(a.success)return a.data;throw a.error}safeParse(s,n){var a;const o={common:{issues:[],async:(a=n?.async)!==null&&a!==void 0?a:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:Ca(s)},l=this._parseSync({data:s,path:o.path,parent:o});return Yw(o,l)}"~validate"(s){var n,a;const o={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:Ca(s)};if(!this["~standard"].async)try{const l=this._parseSync({data:s,path:[],parent:o});return Xi(l)?{value:l.value}:{issues:o.common.issues}}catch(l){!((a=(n=l?.message)===null||n===void 0?void 0:n.toLowerCase())===null||a===void 0)&&a.includes("encountered")&&(this["~standard"].async=!0),o.common={issues:[],async:!0}}return this._parseAsync({data:s,path:[],parent:o}).then(l=>Xi(l)?{value:l.value}:{issues:o.common.issues})}async parseAsync(s,n){const a=await this.safeParseAsync(s,n);if(a.success)return a.data;throw a.error}async safeParseAsync(s,n){const a={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:Ca(s)},o=this._parse({data:s,path:a.path,parent:a}),l=await(Lc(o)?o:Promise.resolve(o));return Yw(a,l)}refine(s,n){const a=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,l)=>{const d=s(o),u=()=>l.addIssue({code:ke.custom,...a(o)});return typeof Promise<"u"&&d instanceof Promise?d.then(h=>h?!0:(u(),!1)):d?!0:(u(),!1)})}refinement(s,n){return this._refinement((a,o)=>s(a)?!0:(o.addIssue(typeof n=="function"?n(a,o):n),!1))}_refinement(s){return new qr({schema:this,typeName:xt.ZodEffects,effect:{type:"refinement",refinement:s}})}superRefine(s){return this._refinement(s)}constructor(s){this.spa=this.safeParseAsync,this._def=s,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return ia.create(this,this._def)}nullable(){return ji.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $r.create(this)}promise(){return cl.create(this,this._def)}or(s){return zc.create([this,s],this._def)}and(s){return Bc.create(this,s,this._def)}transform(s){return new qr({...Rt(this._def),schema:this,typeName:xt.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const n=typeof s=="function"?s:()=>s;return new Wc({...Rt(this._def),innerType:this,defaultValue:n,typeName:xt.ZodDefault})}brand(){return new Bx({typeName:xt.ZodBranded,type:this,...Rt(this._def)})}catch(s){const n=typeof s=="function"?s:()=>s;return new Qc({...Rt(this._def),innerType:this,catchValue:n,typeName:xt.ZodCatch})}describe(s){const n=this.constructor;return new n({...this._def,description:s})}pipe(s){return pd.create(this,s)}readonly(){return Gc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const HF=/^c[^\s-]{8,}$/i,WF=/^[0-9a-z]+$/,QF=/^[0-9A-HJKMNP-TV-Z]{26}$/i,GF=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,YF=/^[a-z0-9_-]{21}$/i,ZF=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,XF=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,JF=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,e5="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Sp;const t5=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,s5=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,n5=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,r5=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,a5=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,i5=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,X1="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",o5=new RegExp(`^${X1}$`);function J1(t){let s="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?s=`${s}\\.\\d{${t.precision}}`:t.precision==null&&(s=`${s}(\\.\\d+)?`),s}function l5(t){return new RegExp(`^${J1(t)}$`)}function ek(t){let s=`${X1}T${J1(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),s=`${s}(${n.join("|")})`,new RegExp(`^${s}$`)}function c5(t,s){return!!((s==="v4"||!s)&&t5.test(t)||(s==="v6"||!s)&&n5.test(t))}function d5(t,s){if(!ZF.test(t))return!1;try{const[n]=t.split("."),a=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(a));return!(typeof o!="object"||o===null||!o.typ||!o.alg||s&&o.alg!==s)}catch{return!1}}function u5(t,s){return!!((s==="v4"||!s)&&s5.test(t)||(s==="v6"||!s)&&r5.test(t))}class Lr extends Ot{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==We.string){const l=this._getOrReturnCtx(s);return Fe(l,{code:ke.invalid_type,expected:We.string,received:l.parsedType}),vt}const a=new Tn;let o;for(const l of this._def.checks)if(l.kind==="min")s.data.length<l.value&&(o=this._getOrReturnCtx(s,o),Fe(o,{code:ke.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),a.dirty());else if(l.kind==="max")s.data.length>l.value&&(o=this._getOrReturnCtx(s,o),Fe(o,{code:ke.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),a.dirty());else if(l.kind==="length"){const d=s.data.length>l.value,u=s.data.length<l.value;(d||u)&&(o=this._getOrReturnCtx(s,o),d?Fe(o,{code:ke.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}):u&&Fe(o,{code:ke.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}),a.dirty())}else if(l.kind==="email")JF.test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"email",code:ke.invalid_string,message:l.message}),a.dirty());else if(l.kind==="emoji")Sp||(Sp=new RegExp(e5,"u")),Sp.test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"emoji",code:ke.invalid_string,message:l.message}),a.dirty());else if(l.kind==="uuid")GF.test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"uuid",code:ke.invalid_string,message:l.message}),a.dirty());else if(l.kind==="nanoid")YF.test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"nanoid",code:ke.invalid_string,message:l.message}),a.dirty());else if(l.kind==="cuid")HF.test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"cuid",code:ke.invalid_string,message:l.message}),a.dirty());else if(l.kind==="cuid2")WF.test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"cuid2",code:ke.invalid_string,message:l.message}),a.dirty());else if(l.kind==="ulid")QF.test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"ulid",code:ke.invalid_string,message:l.message}),a.dirty());else if(l.kind==="url")try{new URL(s.data)}catch{o=this._getOrReturnCtx(s,o),Fe(o,{validation:"url",code:ke.invalid_string,message:l.message}),a.dirty()}else l.kind==="regex"?(l.regex.lastIndex=0,l.regex.test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"regex",code:ke.invalid_string,message:l.message}),a.dirty())):l.kind==="trim"?s.data=s.data.trim():l.kind==="includes"?s.data.includes(l.value,l.position)||(o=this._getOrReturnCtx(s,o),Fe(o,{code:ke.invalid_string,validation:{includes:l.value,position:l.position},message:l.message}),a.dirty()):l.kind==="toLowerCase"?s.data=s.data.toLowerCase():l.kind==="toUpperCase"?s.data=s.data.toUpperCase():l.kind==="startsWith"?s.data.startsWith(l.value)||(o=this._getOrReturnCtx(s,o),Fe(o,{code:ke.invalid_string,validation:{startsWith:l.value},message:l.message}),a.dirty()):l.kind==="endsWith"?s.data.endsWith(l.value)||(o=this._getOrReturnCtx(s,o),Fe(o,{code:ke.invalid_string,validation:{endsWith:l.value},message:l.message}),a.dirty()):l.kind==="datetime"?ek(l).test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{code:ke.invalid_string,validation:"datetime",message:l.message}),a.dirty()):l.kind==="date"?o5.test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{code:ke.invalid_string,validation:"date",message:l.message}),a.dirty()):l.kind==="time"?l5(l).test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{code:ke.invalid_string,validation:"time",message:l.message}),a.dirty()):l.kind==="duration"?XF.test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"duration",code:ke.invalid_string,message:l.message}),a.dirty()):l.kind==="ip"?c5(s.data,l.version)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"ip",code:ke.invalid_string,message:l.message}),a.dirty()):l.kind==="jwt"?d5(s.data,l.alg)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"jwt",code:ke.invalid_string,message:l.message}),a.dirty()):l.kind==="cidr"?u5(s.data,l.version)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"cidr",code:ke.invalid_string,message:l.message}),a.dirty()):l.kind==="base64"?a5.test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"base64",code:ke.invalid_string,message:l.message}),a.dirty()):l.kind==="base64url"?i5.test(s.data)||(o=this._getOrReturnCtx(s,o),Fe(o,{validation:"base64url",code:ke.invalid_string,message:l.message}),a.dirty()):Ht.assertNever(l);return{status:a.value,value:s.data}}_regex(s,n,a){return this.refinement(o=>s.test(o),{validation:n,code:ke.invalid_string,...rt.errToObj(a)})}_addCheck(s){return new Lr({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...rt.errToObj(s)})}url(s){return this._addCheck({kind:"url",...rt.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...rt.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...rt.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...rt.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...rt.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...rt.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...rt.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...rt.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...rt.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...rt.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...rt.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...rt.errToObj(s)})}datetime(s){var n,a;return typeof s=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:s}):this._addCheck({kind:"datetime",precision:typeof s?.precision>"u"?null:s?.precision,offset:(n=s?.offset)!==null&&n!==void 0?n:!1,local:(a=s?.local)!==null&&a!==void 0?a:!1,...rt.errToObj(s?.message)})}date(s){return this._addCheck({kind:"date",message:s})}time(s){return typeof s=="string"?this._addCheck({kind:"time",precision:null,message:s}):this._addCheck({kind:"time",precision:typeof s?.precision>"u"?null:s?.precision,...rt.errToObj(s?.message)})}duration(s){return this._addCheck({kind:"duration",...rt.errToObj(s)})}regex(s,n){return this._addCheck({kind:"regex",regex:s,...rt.errToObj(n)})}includes(s,n){return this._addCheck({kind:"includes",value:s,position:n?.position,...rt.errToObj(n?.message)})}startsWith(s,n){return this._addCheck({kind:"startsWith",value:s,...rt.errToObj(n)})}endsWith(s,n){return this._addCheck({kind:"endsWith",value:s,...rt.errToObj(n)})}min(s,n){return this._addCheck({kind:"min",value:s,...rt.errToObj(n)})}max(s,n){return this._addCheck({kind:"max",value:s,...rt.errToObj(n)})}length(s,n){return this._addCheck({kind:"length",value:s,...rt.errToObj(n)})}nonempty(s){return this.min(1,rt.errToObj(s))}trim(){return new Lr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Lr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Lr({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(s=>s.kind==="datetime")}get isDate(){return!!this._def.checks.find(s=>s.kind==="date")}get isTime(){return!!this._def.checks.find(s=>s.kind==="time")}get isDuration(){return!!this._def.checks.find(s=>s.kind==="duration")}get isEmail(){return!!this._def.checks.find(s=>s.kind==="email")}get isURL(){return!!this._def.checks.find(s=>s.kind==="url")}get isEmoji(){return!!this._def.checks.find(s=>s.kind==="emoji")}get isUUID(){return!!this._def.checks.find(s=>s.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(s=>s.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(s=>s.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(s=>s.kind==="cuid2")}get isULID(){return!!this._def.checks.find(s=>s.kind==="ulid")}get isIP(){return!!this._def.checks.find(s=>s.kind==="ip")}get isCIDR(){return!!this._def.checks.find(s=>s.kind==="cidr")}get isBase64(){return!!this._def.checks.find(s=>s.kind==="base64")}get isBase64url(){return!!this._def.checks.find(s=>s.kind==="base64url")}get minLength(){let s=null;for(const n of this._def.checks)n.kind==="min"&&(s===null||n.value>s)&&(s=n.value);return s}get maxLength(){let s=null;for(const n of this._def.checks)n.kind==="max"&&(s===null||n.value<s)&&(s=n.value);return s}}Lr.create=t=>{var s;return new Lr({checks:[],typeName:xt.ZodString,coerce:(s=t?.coerce)!==null&&s!==void 0?s:!1,...Rt(t)})};function m5(t,s){const n=(t.toString().split(".")[1]||"").length,a=(s.toString().split(".")[1]||"").length,o=n>a?n:a,l=parseInt(t.toFixed(o).replace(".","")),d=parseInt(s.toFixed(o).replace(".",""));return l%d/Math.pow(10,o)}class xi extends Ot{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(s){if(this._def.coerce&&(s.data=Number(s.data)),this._getType(s)!==We.number){const l=this._getOrReturnCtx(s);return Fe(l,{code:ke.invalid_type,expected:We.number,received:l.parsedType}),vt}let a;const o=new Tn;for(const l of this._def.checks)l.kind==="int"?Ht.isInteger(s.data)||(a=this._getOrReturnCtx(s,a),Fe(a,{code:ke.invalid_type,expected:"integer",received:"float",message:l.message}),o.dirty()):l.kind==="min"?(l.inclusive?s.data<l.value:s.data<=l.value)&&(a=this._getOrReturnCtx(s,a),Fe(a,{code:ke.too_small,minimum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),o.dirty()):l.kind==="max"?(l.inclusive?s.data>l.value:s.data>=l.value)&&(a=this._getOrReturnCtx(s,a),Fe(a,{code:ke.too_big,maximum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),o.dirty()):l.kind==="multipleOf"?m5(s.data,l.value)!==0&&(a=this._getOrReturnCtx(s,a),Fe(a,{code:ke.not_multiple_of,multipleOf:l.value,message:l.message}),o.dirty()):l.kind==="finite"?Number.isFinite(s.data)||(a=this._getOrReturnCtx(s,a),Fe(a,{code:ke.not_finite,message:l.message}),o.dirty()):Ht.assertNever(l);return{status:o.value,value:s.data}}gte(s,n){return this.setLimit("min",s,!0,rt.toString(n))}gt(s,n){return this.setLimit("min",s,!1,rt.toString(n))}lte(s,n){return this.setLimit("max",s,!0,rt.toString(n))}lt(s,n){return this.setLimit("max",s,!1,rt.toString(n))}setLimit(s,n,a,o){return new xi({...this._def,checks:[...this._def.checks,{kind:s,value:n,inclusive:a,message:rt.toString(o)}]})}_addCheck(s){return new xi({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:rt.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:rt.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:rt.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:rt.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:rt.toString(s)})}multipleOf(s,n){return this._addCheck({kind:"multipleOf",value:s,message:rt.toString(n)})}finite(s){return this._addCheck({kind:"finite",message:rt.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:rt.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:rt.toString(s)})}get minValue(){let s=null;for(const n of this._def.checks)n.kind==="min"&&(s===null||n.value>s)&&(s=n.value);return s}get maxValue(){let s=null;for(const n of this._def.checks)n.kind==="max"&&(s===null||n.value<s)&&(s=n.value);return s}get isInt(){return!!this._def.checks.find(s=>s.kind==="int"||s.kind==="multipleOf"&&Ht.isInteger(s.value))}get isFinite(){let s=null,n=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(n===null||a.value>n)&&(n=a.value):a.kind==="max"&&(s===null||a.value<s)&&(s=a.value)}return Number.isFinite(n)&&Number.isFinite(s)}}xi.create=t=>new xi({checks:[],typeName:xt.ZodNumber,coerce:t?.coerce||!1,...Rt(t)});class vi extends Ot{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(s){if(this._def.coerce)try{s.data=BigInt(s.data)}catch{return this._getInvalidInput(s)}if(this._getType(s)!==We.bigint)return this._getInvalidInput(s);let a;const o=new Tn;for(const l of this._def.checks)l.kind==="min"?(l.inclusive?s.data<l.value:s.data<=l.value)&&(a=this._getOrReturnCtx(s,a),Fe(a,{code:ke.too_small,type:"bigint",minimum:l.value,inclusive:l.inclusive,message:l.message}),o.dirty()):l.kind==="max"?(l.inclusive?s.data>l.value:s.data>=l.value)&&(a=this._getOrReturnCtx(s,a),Fe(a,{code:ke.too_big,type:"bigint",maximum:l.value,inclusive:l.inclusive,message:l.message}),o.dirty()):l.kind==="multipleOf"?s.data%l.value!==BigInt(0)&&(a=this._getOrReturnCtx(s,a),Fe(a,{code:ke.not_multiple_of,multipleOf:l.value,message:l.message}),o.dirty()):Ht.assertNever(l);return{status:o.value,value:s.data}}_getInvalidInput(s){const n=this._getOrReturnCtx(s);return Fe(n,{code:ke.invalid_type,expected:We.bigint,received:n.parsedType}),vt}gte(s,n){return this.setLimit("min",s,!0,rt.toString(n))}gt(s,n){return this.setLimit("min",s,!1,rt.toString(n))}lte(s,n){return this.setLimit("max",s,!0,rt.toString(n))}lt(s,n){return this.setLimit("max",s,!1,rt.toString(n))}setLimit(s,n,a,o){return new vi({...this._def,checks:[...this._def.checks,{kind:s,value:n,inclusive:a,message:rt.toString(o)}]})}_addCheck(s){return new vi({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:rt.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:rt.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:rt.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:rt.toString(s)})}multipleOf(s,n){return this._addCheck({kind:"multipleOf",value:s,message:rt.toString(n)})}get minValue(){let s=null;for(const n of this._def.checks)n.kind==="min"&&(s===null||n.value>s)&&(s=n.value);return s}get maxValue(){let s=null;for(const n of this._def.checks)n.kind==="max"&&(s===null||n.value<s)&&(s=n.value);return s}}vi.create=t=>{var s;return new vi({checks:[],typeName:xt.ZodBigInt,coerce:(s=t?.coerce)!==null&&s!==void 0?s:!1,...Rt(t)})};class Fc extends Ot{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==We.boolean){const a=this._getOrReturnCtx(s);return Fe(a,{code:ke.invalid_type,expected:We.boolean,received:a.parsedType}),vt}return Fn(s.data)}}Fc.create=t=>new Fc({typeName:xt.ZodBoolean,coerce:t?.coerce||!1,...Rt(t)});class Ji extends Ot{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==We.date){const l=this._getOrReturnCtx(s);return Fe(l,{code:ke.invalid_type,expected:We.date,received:l.parsedType}),vt}if(isNaN(s.data.getTime())){const l=this._getOrReturnCtx(s);return Fe(l,{code:ke.invalid_date}),vt}const a=new Tn;let o;for(const l of this._def.checks)l.kind==="min"?s.data.getTime()<l.value&&(o=this._getOrReturnCtx(s,o),Fe(o,{code:ke.too_small,message:l.message,inclusive:!0,exact:!1,minimum:l.value,type:"date"}),a.dirty()):l.kind==="max"?s.data.getTime()>l.value&&(o=this._getOrReturnCtx(s,o),Fe(o,{code:ke.too_big,message:l.message,inclusive:!0,exact:!1,maximum:l.value,type:"date"}),a.dirty()):Ht.assertNever(l);return{status:a.value,value:new Date(s.data.getTime())}}_addCheck(s){return new Ji({...this._def,checks:[...this._def.checks,s]})}min(s,n){return this._addCheck({kind:"min",value:s.getTime(),message:rt.toString(n)})}max(s,n){return this._addCheck({kind:"max",value:s.getTime(),message:rt.toString(n)})}get minDate(){let s=null;for(const n of this._def.checks)n.kind==="min"&&(s===null||n.value>s)&&(s=n.value);return s!=null?new Date(s):null}get maxDate(){let s=null;for(const n of this._def.checks)n.kind==="max"&&(s===null||n.value<s)&&(s=n.value);return s!=null?new Date(s):null}}Ji.create=t=>new Ji({checks:[],coerce:t?.coerce||!1,typeName:xt.ZodDate,...Rt(t)});class gm extends Ot{_parse(s){if(this._getType(s)!==We.symbol){const a=this._getOrReturnCtx(s);return Fe(a,{code:ke.invalid_type,expected:We.symbol,received:a.parsedType}),vt}return Fn(s.data)}}gm.create=t=>new gm({typeName:xt.ZodSymbol,...Rt(t)});class $c extends Ot{_parse(s){if(this._getType(s)!==We.undefined){const a=this._getOrReturnCtx(s);return Fe(a,{code:ke.invalid_type,expected:We.undefined,received:a.parsedType}),vt}return Fn(s.data)}}$c.create=t=>new $c({typeName:xt.ZodUndefined,...Rt(t)});class Uc extends Ot{_parse(s){if(this._getType(s)!==We.null){const a=this._getOrReturnCtx(s);return Fe(a,{code:ke.invalid_type,expected:We.null,received:a.parsedType}),vt}return Fn(s.data)}}Uc.create=t=>new Uc({typeName:xt.ZodNull,...Rt(t)});class ll extends Ot{constructor(){super(...arguments),this._any=!0}_parse(s){return Fn(s.data)}}ll.create=t=>new ll({typeName:xt.ZodAny,...Rt(t)});class $i extends Ot{constructor(){super(...arguments),this._unknown=!0}_parse(s){return Fn(s.data)}}$i.create=t=>new $i({typeName:xt.ZodUnknown,...Rt(t)});class Aa extends Ot{_parse(s){const n=this._getOrReturnCtx(s);return Fe(n,{code:ke.invalid_type,expected:We.never,received:n.parsedType}),vt}}Aa.create=t=>new Aa({typeName:xt.ZodNever,...Rt(t)});class xm extends Ot{_parse(s){if(this._getType(s)!==We.undefined){const a=this._getOrReturnCtx(s);return Fe(a,{code:ke.invalid_type,expected:We.void,received:a.parsedType}),vt}return Fn(s.data)}}xm.create=t=>new xm({typeName:xt.ZodVoid,...Rt(t)});class $r extends Ot{_parse(s){const{ctx:n,status:a}=this._processInputParams(s),o=this._def;if(n.parsedType!==We.array)return Fe(n,{code:ke.invalid_type,expected:We.array,received:n.parsedType}),vt;if(o.exactLength!==null){const d=n.data.length>o.exactLength.value,u=n.data.length<o.exactLength.value;(d||u)&&(Fe(n,{code:d?ke.too_big:ke.too_small,minimum:u?o.exactLength.value:void 0,maximum:d?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),a.dirty())}if(o.minLength!==null&&n.data.length<o.minLength.value&&(Fe(n,{code:ke.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),a.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(Fe(n,{code:ke.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),a.dirty()),n.common.async)return Promise.all([...n.data].map((d,u)=>o.type._parseAsync(new ca(n,d,n.path,u)))).then(d=>Tn.mergeArray(a,d));const l=[...n.data].map((d,u)=>o.type._parseSync(new ca(n,d,n.path,u)));return Tn.mergeArray(a,l)}get element(){return this._def.type}min(s,n){return new $r({...this._def,minLength:{value:s,message:rt.toString(n)}})}max(s,n){return new $r({...this._def,maxLength:{value:s,message:rt.toString(n)}})}length(s,n){return new $r({...this._def,exactLength:{value:s,message:rt.toString(n)}})}nonempty(s){return this.min(1,s)}}$r.create=(t,s)=>new $r({type:t,minLength:null,maxLength:null,exactLength:null,typeName:xt.ZodArray,...Rt(s)});function zo(t){if(t instanceof _s){const s={};for(const n in t.shape){const a=t.shape[n];s[n]=ia.create(zo(a))}return new _s({...t._def,shape:()=>s})}else return t instanceof $r?new $r({...t._def,type:zo(t.element)}):t instanceof ia?ia.create(zo(t.unwrap())):t instanceof ji?ji.create(zo(t.unwrap())):t instanceof da?da.create(t.items.map(s=>zo(s))):t}class _s extends Ot{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const s=this._def.shape(),n=Ht.objectKeys(s);return this._cached={shape:s,keys:n}}_parse(s){if(this._getType(s)!==We.object){const f=this._getOrReturnCtx(s);return Fe(f,{code:ke.invalid_type,expected:We.object,received:f.parsedType}),vt}const{status:a,ctx:o}=this._processInputParams(s),{shape:l,keys:d}=this._getCached(),u=[];if(!(this._def.catchall instanceof Aa&&this._def.unknownKeys==="strip"))for(const f in o.data)d.includes(f)||u.push(f);const h=[];for(const f of d){const g=l[f],x=o.data[f];h.push({key:{status:"valid",value:f},value:g._parse(new ca(o,x,o.path,f)),alwaysSet:f in o.data})}if(this._def.catchall instanceof Aa){const f=this._def.unknownKeys;if(f==="passthrough")for(const g of u)h.push({key:{status:"valid",value:g},value:{status:"valid",value:o.data[g]}});else if(f==="strict")u.length>0&&(Fe(o,{code:ke.unrecognized_keys,keys:u}),a.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const f=this._def.catchall;for(const g of u){const x=o.data[g];h.push({key:{status:"valid",value:g},value:f._parse(new ca(o,x,o.path,g)),alwaysSet:g in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const f=[];for(const g of h){const x=await g.key,v=await g.value;f.push({key:x,value:v,alwaysSet:g.alwaysSet})}return f}).then(f=>Tn.mergeObjectSync(a,f)):Tn.mergeObjectSync(a,h)}get shape(){return this._def.shape()}strict(s){return rt.errToObj,new _s({...this._def,unknownKeys:"strict",...s!==void 0?{errorMap:(n,a)=>{var o,l,d,u;const h=(d=(l=(o=this._def).errorMap)===null||l===void 0?void 0:l.call(o,n,a).message)!==null&&d!==void 0?d:a.defaultError;return n.code==="unrecognized_keys"?{message:(u=rt.errToObj(s).message)!==null&&u!==void 0?u:h}:{message:h}}}:{}})}strip(){return new _s({...this._def,unknownKeys:"strip"})}passthrough(){return new _s({...this._def,unknownKeys:"passthrough"})}extend(s){return new _s({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new _s({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:xt.ZodObject})}setKey(s,n){return this.augment({[s]:n})}catchall(s){return new _s({...this._def,catchall:s})}pick(s){const n={};return Ht.objectKeys(s).forEach(a=>{s[a]&&this.shape[a]&&(n[a]=this.shape[a])}),new _s({...this._def,shape:()=>n})}omit(s){const n={};return Ht.objectKeys(this.shape).forEach(a=>{s[a]||(n[a]=this.shape[a])}),new _s({...this._def,shape:()=>n})}deepPartial(){return zo(this)}partial(s){const n={};return Ht.objectKeys(this.shape).forEach(a=>{const o=this.shape[a];s&&!s[a]?n[a]=o:n[a]=o.optional()}),new _s({...this._def,shape:()=>n})}required(s){const n={};return Ht.objectKeys(this.shape).forEach(a=>{if(s&&!s[a])n[a]=this.shape[a];else{let l=this.shape[a];for(;l instanceof ia;)l=l._def.innerType;n[a]=l}}),new _s({...this._def,shape:()=>n})}keyof(){return tk(Ht.objectKeys(this.shape))}}_s.create=(t,s)=>new _s({shape:()=>t,unknownKeys:"strip",catchall:Aa.create(),typeName:xt.ZodObject,...Rt(s)});_s.strictCreate=(t,s)=>new _s({shape:()=>t,unknownKeys:"strict",catchall:Aa.create(),typeName:xt.ZodObject,...Rt(s)});_s.lazycreate=(t,s)=>new _s({shape:t,unknownKeys:"strip",catchall:Aa.create(),typeName:xt.ZodObject,...Rt(s)});class zc extends Ot{_parse(s){const{ctx:n}=this._processInputParams(s),a=this._def.options;function o(l){for(const u of l)if(u.result.status==="valid")return u.result;for(const u of l)if(u.result.status==="dirty")return n.common.issues.push(...u.ctx.common.issues),u.result;const d=l.map(u=>new dr(u.ctx.common.issues));return Fe(n,{code:ke.invalid_union,unionErrors:d}),vt}if(n.common.async)return Promise.all(a.map(async l=>{const d={...n,common:{...n.common,issues:[]},parent:null};return{result:await l._parseAsync({data:n.data,path:n.path,parent:d}),ctx:d}})).then(o);{let l;const d=[];for(const h of a){const f={...n,common:{...n.common,issues:[]},parent:null},g=h._parseSync({data:n.data,path:n.path,parent:f});if(g.status==="valid")return g;g.status==="dirty"&&!l&&(l={result:g,ctx:f}),f.common.issues.length&&d.push(f.common.issues)}if(l)return n.common.issues.push(...l.ctx.common.issues),l.result;const u=d.map(h=>new dr(h));return Fe(n,{code:ke.invalid_union,unionErrors:u}),vt}}get options(){return this._def.options}}zc.create=(t,s)=>new zc({options:t,typeName:xt.ZodUnion,...Rt(s)});const Sa=t=>t instanceof qc?Sa(t.schema):t instanceof qr?Sa(t.innerType()):t instanceof Kc?[t.value]:t instanceof yi?t.options:t instanceof Hc?Ht.objectValues(t.enum):t instanceof Wc?Sa(t._def.innerType):t instanceof $c?[void 0]:t instanceof Uc?[null]:t instanceof ia?[void 0,...Sa(t.unwrap())]:t instanceof ji?[null,...Sa(t.unwrap())]:t instanceof Bx||t instanceof Gc?Sa(t.unwrap()):t instanceof Qc?Sa(t._def.innerType):[];class dh extends Ot{_parse(s){const{ctx:n}=this._processInputParams(s);if(n.parsedType!==We.object)return Fe(n,{code:ke.invalid_type,expected:We.object,received:n.parsedType}),vt;const a=this.discriminator,o=n.data[a],l=this.optionsMap.get(o);return l?n.common.async?l._parseAsync({data:n.data,path:n.path,parent:n}):l._parseSync({data:n.data,path:n.path,parent:n}):(Fe(n,{code:ke.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),vt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(s,n,a){const o=new Map;for(const l of n){const d=Sa(l.shape[s]);if(!d.length)throw new Error(`A discriminator value for key \`${s}\` could not be extracted from all schema options`);for(const u of d){if(o.has(u))throw new Error(`Discriminator property ${String(s)} has duplicate value ${String(u)}`);o.set(u,l)}}return new dh({typeName:xt.ZodDiscriminatedUnion,discriminator:s,options:n,optionsMap:o,...Rt(a)})}}function hg(t,s){const n=Ca(t),a=Ca(s);if(t===s)return{valid:!0,data:t};if(n===We.object&&a===We.object){const o=Ht.objectKeys(s),l=Ht.objectKeys(t).filter(u=>o.indexOf(u)!==-1),d={...t,...s};for(const u of l){const h=hg(t[u],s[u]);if(!h.valid)return{valid:!1};d[u]=h.data}return{valid:!0,data:d}}else if(n===We.array&&a===We.array){if(t.length!==s.length)return{valid:!1};const o=[];for(let l=0;l<t.length;l++){const d=t[l],u=s[l],h=hg(d,u);if(!h.valid)return{valid:!1};o.push(h.data)}return{valid:!0,data:o}}else return n===We.date&&a===We.date&&+t==+s?{valid:!0,data:t}:{valid:!1}}class Bc extends Ot{_parse(s){const{status:n,ctx:a}=this._processInputParams(s),o=(l,d)=>{if(ug(l)||ug(d))return vt;const u=hg(l.value,d.value);return u.valid?((mg(l)||mg(d))&&n.dirty(),{status:n.value,value:u.data}):(Fe(a,{code:ke.invalid_intersection_types}),vt)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([l,d])=>o(l,d)):o(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}Bc.create=(t,s,n)=>new Bc({left:t,right:s,typeName:xt.ZodIntersection,...Rt(n)});class da extends Ot{_parse(s){const{status:n,ctx:a}=this._processInputParams(s);if(a.parsedType!==We.array)return Fe(a,{code:ke.invalid_type,expected:We.array,received:a.parsedType}),vt;if(a.data.length<this._def.items.length)return Fe(a,{code:ke.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),vt;!this._def.rest&&a.data.length>this._def.items.length&&(Fe(a,{code:ke.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const l=[...a.data].map((d,u)=>{const h=this._def.items[u]||this._def.rest;return h?h._parse(new ca(a,d,a.path,u)):null}).filter(d=>!!d);return a.common.async?Promise.all(l).then(d=>Tn.mergeArray(n,d)):Tn.mergeArray(n,l)}get items(){return this._def.items}rest(s){return new da({...this._def,rest:s})}}da.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new da({items:t,typeName:xt.ZodTuple,rest:null,...Rt(s)})};class Vc extends Ot{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(s){const{status:n,ctx:a}=this._processInputParams(s);if(a.parsedType!==We.object)return Fe(a,{code:ke.invalid_type,expected:We.object,received:a.parsedType}),vt;const o=[],l=this._def.keyType,d=this._def.valueType;for(const u in a.data)o.push({key:l._parse(new ca(a,u,a.path,u)),value:d._parse(new ca(a,a.data[u],a.path,u)),alwaysSet:u in a.data});return a.common.async?Tn.mergeObjectAsync(n,o):Tn.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(s,n,a){return n instanceof Ot?new Vc({keyType:s,valueType:n,typeName:xt.ZodRecord,...Rt(a)}):new Vc({keyType:Lr.create(),valueType:s,typeName:xt.ZodRecord,...Rt(n)})}}class vm extends Ot{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(s){const{status:n,ctx:a}=this._processInputParams(s);if(a.parsedType!==We.map)return Fe(a,{code:ke.invalid_type,expected:We.map,received:a.parsedType}),vt;const o=this._def.keyType,l=this._def.valueType,d=[...a.data.entries()].map(([u,h],f)=>({key:o._parse(new ca(a,u,a.path,[f,"key"])),value:l._parse(new ca(a,h,a.path,[f,"value"]))}));if(a.common.async){const u=new Map;return Promise.resolve().then(async()=>{for(const h of d){const f=await h.key,g=await h.value;if(f.status==="aborted"||g.status==="aborted")return vt;(f.status==="dirty"||g.status==="dirty")&&n.dirty(),u.set(f.value,g.value)}return{status:n.value,value:u}})}else{const u=new Map;for(const h of d){const f=h.key,g=h.value;if(f.status==="aborted"||g.status==="aborted")return vt;(f.status==="dirty"||g.status==="dirty")&&n.dirty(),u.set(f.value,g.value)}return{status:n.value,value:u}}}}vm.create=(t,s,n)=>new vm({valueType:s,keyType:t,typeName:xt.ZodMap,...Rt(n)});class eo extends Ot{_parse(s){const{status:n,ctx:a}=this._processInputParams(s);if(a.parsedType!==We.set)return Fe(a,{code:ke.invalid_type,expected:We.set,received:a.parsedType}),vt;const o=this._def;o.minSize!==null&&a.data.size<o.minSize.value&&(Fe(a,{code:ke.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&a.data.size>o.maxSize.value&&(Fe(a,{code:ke.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),n.dirty());const l=this._def.valueType;function d(h){const f=new Set;for(const g of h){if(g.status==="aborted")return vt;g.status==="dirty"&&n.dirty(),f.add(g.value)}return{status:n.value,value:f}}const u=[...a.data.values()].map((h,f)=>l._parse(new ca(a,h,a.path,f)));return a.common.async?Promise.all(u).then(h=>d(h)):d(u)}min(s,n){return new eo({...this._def,minSize:{value:s,message:rt.toString(n)}})}max(s,n){return new eo({...this._def,maxSize:{value:s,message:rt.toString(n)}})}size(s,n){return this.min(s,n).max(s,n)}nonempty(s){return this.min(1,s)}}eo.create=(t,s)=>new eo({valueType:t,minSize:null,maxSize:null,typeName:xt.ZodSet,...Rt(s)});class Zo extends Ot{constructor(){super(...arguments),this.validate=this.implement}_parse(s){const{ctx:n}=this._processInputParams(s);if(n.parsedType!==We.function)return Fe(n,{code:ke.invalid_type,expected:We.function,received:n.parsedType}),vt;function a(u,h){return fm({data:u,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,hm(),ol].filter(f=>!!f),issueData:{code:ke.invalid_arguments,argumentsError:h}})}function o(u,h){return fm({data:u,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,hm(),ol].filter(f=>!!f),issueData:{code:ke.invalid_return_type,returnTypeError:h}})}const l={errorMap:n.common.contextualErrorMap},d=n.data;if(this._def.returns instanceof cl){const u=this;return Fn(async function(...h){const f=new dr([]),g=await u._def.args.parseAsync(h,l).catch(w=>{throw f.addIssue(a(h,w)),f}),x=await Reflect.apply(d,this,g);return await u._def.returns._def.type.parseAsync(x,l).catch(w=>{throw f.addIssue(o(x,w)),f})})}else{const u=this;return Fn(function(...h){const f=u._def.args.safeParse(h,l);if(!f.success)throw new dr([a(h,f.error)]);const g=Reflect.apply(d,this,f.data),x=u._def.returns.safeParse(g,l);if(!x.success)throw new dr([o(g,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...s){return new Zo({...this._def,args:da.create(s).rest($i.create())})}returns(s){return new Zo({...this._def,returns:s})}implement(s){return this.parse(s)}strictImplement(s){return this.parse(s)}static create(s,n,a){return new Zo({args:s||da.create([]).rest($i.create()),returns:n||$i.create(),typeName:xt.ZodFunction,...Rt(a)})}}class qc extends Ot{get schema(){return this._def.getter()}_parse(s){const{ctx:n}=this._processInputParams(s);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}qc.create=(t,s)=>new qc({getter:t,typeName:xt.ZodLazy,...Rt(s)});class Kc extends Ot{_parse(s){if(s.data!==this._def.value){const n=this._getOrReturnCtx(s);return Fe(n,{received:n.data,code:ke.invalid_literal,expected:this._def.value}),vt}return{status:"valid",value:s.data}}get value(){return this._def.value}}Kc.create=(t,s)=>new Kc({value:t,typeName:xt.ZodLiteral,...Rt(s)});function tk(t,s){return new yi({values:t,typeName:xt.ZodEnum,...Rt(s)})}class yi extends Ot{constructor(){super(...arguments),gc.set(this,void 0)}_parse(s){if(typeof s.data!="string"){const n=this._getOrReturnCtx(s),a=this._def.values;return Fe(n,{expected:Ht.joinValues(a),received:n.parsedType,code:ke.invalid_type}),vt}if(pm(this,gc)||Z1(this,gc,new Set(this._def.values)),!pm(this,gc).has(s.data)){const n=this._getOrReturnCtx(s),a=this._def.values;return Fe(n,{received:n.data,code:ke.invalid_enum_value,options:a}),vt}return Fn(s.data)}get options(){return this._def.values}get enum(){const s={};for(const n of this._def.values)s[n]=n;return s}get Values(){const s={};for(const n of this._def.values)s[n]=n;return s}get Enum(){const s={};for(const n of this._def.values)s[n]=n;return s}extract(s,n=this._def){return yi.create(s,{...this._def,...n})}exclude(s,n=this._def){return yi.create(this.options.filter(a=>!s.includes(a)),{...this._def,...n})}}gc=new WeakMap;yi.create=tk;class Hc extends Ot{constructor(){super(...arguments),xc.set(this,void 0)}_parse(s){const n=Ht.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(s);if(a.parsedType!==We.string&&a.parsedType!==We.number){const o=Ht.objectValues(n);return Fe(a,{expected:Ht.joinValues(o),received:a.parsedType,code:ke.invalid_type}),vt}if(pm(this,xc)||Z1(this,xc,new Set(Ht.getValidEnumValues(this._def.values))),!pm(this,xc).has(s.data)){const o=Ht.objectValues(n);return Fe(a,{received:a.data,code:ke.invalid_enum_value,options:o}),vt}return Fn(s.data)}get enum(){return this._def.values}}xc=new WeakMap;Hc.create=(t,s)=>new Hc({values:t,typeName:xt.ZodNativeEnum,...Rt(s)});class cl extends Ot{unwrap(){return this._def.type}_parse(s){const{ctx:n}=this._processInputParams(s);if(n.parsedType!==We.promise&&n.common.async===!1)return Fe(n,{code:ke.invalid_type,expected:We.promise,received:n.parsedType}),vt;const a=n.parsedType===We.promise?n.data:Promise.resolve(n.data);return Fn(a.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}}cl.create=(t,s)=>new cl({type:t,typeName:xt.ZodPromise,...Rt(s)});class qr extends Ot{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===xt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(s){const{status:n,ctx:a}=this._processInputParams(s),o=this._def.effect||null,l={addIssue:d=>{Fe(a,d),d.fatal?n.abort():n.dirty()},get path(){return a.path}};if(l.addIssue=l.addIssue.bind(l),o.type==="preprocess"){const d=o.transform(a.data,l);if(a.common.async)return Promise.resolve(d).then(async u=>{if(n.value==="aborted")return vt;const h=await this._def.schema._parseAsync({data:u,path:a.path,parent:a});return h.status==="aborted"?vt:h.status==="dirty"||n.value==="dirty"?Bo(h.value):h});{if(n.value==="aborted")return vt;const u=this._def.schema._parseSync({data:d,path:a.path,parent:a});return u.status==="aborted"?vt:u.status==="dirty"||n.value==="dirty"?Bo(u.value):u}}if(o.type==="refinement"){const d=u=>{const h=o.refinement(u,l);if(a.common.async)return Promise.resolve(h);if(h instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u};if(a.common.async===!1){const u=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return u.status==="aborted"?vt:(u.status==="dirty"&&n.dirty(),d(u.value),{status:n.value,value:u.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(u=>u.status==="aborted"?vt:(u.status==="dirty"&&n.dirty(),d(u.value).then(()=>({status:n.value,value:u.value}))))}if(o.type==="transform")if(a.common.async===!1){const d=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Xi(d))return d;const u=o.transform(d.value,l);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:u}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(d=>Xi(d)?Promise.resolve(o.transform(d.value,l)).then(u=>({status:n.value,value:u})):d);Ht.assertNever(o)}}qr.create=(t,s,n)=>new qr({schema:t,typeName:xt.ZodEffects,effect:s,...Rt(n)});qr.createWithPreprocess=(t,s,n)=>new qr({schema:s,effect:{type:"preprocess",transform:t},typeName:xt.ZodEffects,...Rt(n)});class ia extends Ot{_parse(s){return this._getType(s)===We.undefined?Fn(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}ia.create=(t,s)=>new ia({innerType:t,typeName:xt.ZodOptional,...Rt(s)});
vendor: 4,367 bytes, line 60
60class ji extends Ot{_parse(s){return this._getType(s)===We.null?Fn(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}ji.create=(t,s)=>new ji({innerType:t,typeName:xt.ZodNullable,...Rt(s)});class Wc extends Ot{_parse(s){const{ctx:n}=this._processInputParams(s);let a=n.data;return n.parsedType===We.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Wc.create=(t,s)=>new Wc({innerType:t,typeName:xt.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...Rt(s)});class Qc extends Ot{_parse(s){const{ctx:n}=this._processInputParams(s),a={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return Lc(o)?o.then(l=>({status:"valid",value:l.status==="valid"?l.value:this._def.catchValue({get error(){return new dr(a.common.issues)},input:a.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new dr(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}Qc.create=(t,s)=>new Qc({innerType:t,typeName:xt.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...Rt(s)});class ym extends Ot{_parse(s){if(this._getType(s)!==We.nan){const a=this._getOrReturnCtx(s);return Fe(a,{code:ke.invalid_type,expected:We.nan,received:a.parsedType}),vt}return{status:"valid",value:s.data}}}ym.create=t=>new ym({typeName:xt.ZodNaN,...Rt(t)});const h5=Symbol("zod_brand");class Bx extends Ot{_parse(s){const{ctx:n}=this._processInputParams(s),a=n.data;return this._def.type._parse({data:a,path:n.path,parent:n})}unwrap(){return this._def.type}}class pd extends Ot{_parse(s){const{status:n,ctx:a}=this._processInputParams(s);if(a.common.async)return(async()=>{const l=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return l.status==="aborted"?vt:l.status==="dirty"?(n.dirty(),Bo(l.value)):this._def.out._parseAsync({data:l.value,path:a.path,parent:a})})();{const o=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return o.status==="aborted"?vt:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:a.path,parent:a})}}static create(s,n){return new pd({in:s,out:n,typeName:xt.ZodPipeline})}}class Gc extends Ot{_parse(s){const n=this._def.innerType._parse(s),a=o=>(Xi(o)&&(o.value=Object.freeze(o.value)),o);return Lc(n)?n.then(o=>a(o)):a(n)}unwrap(){return this._def.innerType}}Gc.create=(t,s)=>new Gc({innerType:t,typeName:xt.ZodReadonly,...Rt(s)});function Zw(t,s){const n=typeof t=="function"?t(s):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function sk(t,s={},n){return t?ll.create().superRefine((a,o)=>{var l,d;const u=t(a);if(u instanceof Promise)return u.then(h=>{var f,g;if(!h){const x=Zw(s,a),v=(g=(f=x.fatal)!==null&&f!==void 0?f:n)!==null&&g!==void 0?g:!0;o.addIssue({code:"custom",...x,fatal:v})}});if(!u){const h=Zw(s,a),f=(d=(l=h.fatal)!==null&&l!==void 0?l:n)!==null&&d!==void 0?d:!0;o.addIssue({code:"custom",...h,fatal:f})}}):ll.create()}const f5={object:_s.lazycreate};var xt;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(xt||(xt={}));const p5=(t,s={message:`Input not instance of ${t.name}`})=>sk(n=>n instanceof t,s),nk=Lr.create,rk=xi.create,g5=ym.create,x5=vi.create,ak=Fc.create,v5=Ji.create,y5=gm.create,j5=$c.create,w5=Uc.create,b5=ll.create,N5=$i.create,S5=Aa.create,C5=xm.create,k5=$r.create,P5=_s.create,T5=_s.str
60ictCreate,E5=zc.create,_5=dh.create,R5=Bc.create,A5=da.create,I5=Vc.create,D5=vm.create,O5=eo.create,M5=Zo.create,L5=qc.create,F5=Kc.create,$5=yi.create,U5=Hc.create,z5=cl.create,Xw=qr.create,B5=ia.create,V5=ji.create,q5=qr.createWithPreprocess,K5=pd.create,H5=()=>nk().optional(),W5=()=>rk().optional(),Q5=()=>ak().optional(),G5={string:(t=>Lr.create({...t,coerce:!0})),number:(t=>xi.create({...t,coerce:!0})),boolean:(t=>Fc.create({...t,coerce:!0})),bigint:(t=>vi.create({...t,coerce:!0})),date:(t=>Ji.create({...t,coerce:!0}))},Y5=vt;var is=Object.freeze({__proto__:null,defaultErrorMap:ol,setErrorMap:qF,getErrorMap:hm,makeIssue:fm,EMPTY_PATH:KF,addIssueToContext:Fe,ParseStatus:Tn,INVALID:vt,DIRTY:Bo,OK:Fn,isAborted:ug,isDirty:mg,isValid:Xi,isAsync:Lc,get util(){return Ht},get objectUtil(){return dg},ZodParsedType:We,getParsedType:Ca,ZodType:Ot,datetimeRegex:ek,ZodString:Lr,ZodNumber:xi,ZodBigInt:vi,ZodBoolean:Fc,ZodDate:Ji,ZodSymbol:gm,ZodUndefined:$c,ZodNull:Uc,ZodAny:ll,ZodUnknown:$i,ZodNever:Aa,ZodVoid:xm,ZodArray:$r,ZodObject:_s,ZodUnion:zc,ZodDiscriminatedUnion:dh,ZodIntersection:Bc,ZodTuple:da,ZodRecord:Vc,ZodMap:vm,ZodSet:eo,ZodFunction:Zo,ZodLazy:qc,ZodLiteral:Kc,ZodEnum:yi,ZodNativeEnum:Hc,ZodPromise:cl,ZodEffects:qr,ZodTransformer:qr,ZodOptional:ia,ZodNullable:ji,ZodDefault:Wc,ZodCatch:Qc,ZodNaN:ym,BRAND:h5,ZodBranded:Bx,ZodPipeline:pd,ZodReadonly:Gc,custom:sk,Schema:Ot,ZodSchema:Ot,late:f5,get ZodFirstPartyTypeKind(){return xt},coerce:G5,any:b5,array:k5,bigint:x5,boolean:ak,date:v5,discriminatedUnion:_5,effect:Xw,enum:$5,function:M5,instanceof:p5,intersection:R5,lazy:L5,literal:F5,map:D5,nan:g5,nativeEnum:U5,never:S5,null:w5,nullable:V5,number:rk,object:P5,oboolean:Q5,onumber:W5,optional:B5,ostring:H5,pipeline:K5,preprocess:q5,promise:z5,record:I5,set:O5,strictObject:T5,string:nk,symbol:y5,transformer:Xw,tuple:A5,undefined:j5,union:E5,unknown:N5,void:C5,NEVER:Y5,ZodIssueCode:ke,quotelessJson:VF,ZodError:dr});const Es={INT8_MIN:-128,INT8_MAX:127,INT8_UNSIGNED_MAX:255,INT16_MIN:-32768,INT16_MAX:32767,INT16_UNSIGNED_MAX:65535,INT24_MIN:-8388608,INT24_MAX:8388607,INT24_UNSIGNED_MAX:16777215,INT32_MIN:-2147483648,INT32_MAX:2147483647,INT32_UNSIGNED_MAX:4294967295,INT48_MIN:-0x800000000000,INT48_MAX:0x7fffffffffff,INT48_UNSIGNED_MAX:0xffffffffffff,INT64_MIN:-9223372036854775808n,INT64_MAX:9223372036854775807n,INT64_UNSIGNED_MAX:18446744073709551615n};function zs(t,s){return s.includes(t.columnType)}function Z5(t){return"enumValues"in t&&Array.isArray(t.enumValues)&&t.enumValues.length>0}const X5=is.union([is.string(),is.number(),is.boolean(),is.null()]),J5=is.union([X5,is.record(is.any()),is.array(is.any())]),e$=is.custom(t=>t instanceof Buffer);function ik(t,s){const n=s?.zodInstance??is,a=s?.coerce??{};let o;return Z5(t)&&(o=t.enumValues.length?n.enum(t.enumValues):n.string()),o||(zs(t,["PgGeometry","PgPointTuple"])?o=n.tuple([n.number(),n.number()]):zs(t,["PgGeometryObject","PgPointObject"])?o=n.object({x:n.number(),y:n.number()}):zs(t,["PgHalfVector","PgVector"])?(o=n.array(n.number()),o=t.dimensions?o.length(t.dimensions):o):zs(t,["PgLine"])?o=n.tuple([n.number(),n.number(),n.number()]):zs(t,["PgLineABC"])?o=n.object({a:n.number(),b:n.number(),c:n.number()}):zs(t,["PgArray"])?(o=n.array(ik(t.baseColumn,n)),o=t.size?o.length(t.size):o):t.dataType==="array"?o=n.array(n.any()):t.dataType==="number"?o=t$(t,n,a):t.dataType==="bigint"?o=s$(t,n,a):t.dataType==="boolean"?o=a===!0||a.boolean?n.coerce.boolean():n.boolean():t.dataType==="date"?o=a===!0||a.date?n.coerce.date():n.date():t.dataType==="string"?o=n$(t,n,a):t.dataType==="json"?o=J5:t.dataType==="custom"?o=n.any():t.dataType==="buffer"&&(o=e$)),o||(o=n.any()),o}function t$(t,s,n){let a=t.getSQLType().includes("unsigned"),o,l,d=!1;zs(t,["MySqlTinyInt","SingleStoreTinyInt"])?(o=a?0:Es.INT8_MIN,l=a?Es.INT8_UNSIGNED_MAX:Es.INT8_MAX,d=!0):zs(t,["PgSmallInt","PgSmallSerial","MySqlSmallInt","SingleStoreSmallInt"])?(o=a?0:Es.INT16_MIN,l=a?Es.INT16_UNSIGNED_MAX:Es.INT16_MAX,d=!0):zs(t,["PgReal","MySqlFloat","MySqlMediumInt","SingleStoreMediumInt","SingleStoreFloat"])?(o=a?0:Es.INT24_MIN,l=a?Es.INT24_UNSIGNED_MAX:Es.INT24_MAX,d=zs(t,["MySqlMediumInt","SingleStoreMediumInt"])):zs(t,["PgInteger","PgSerial","MySqlInt","SingleStoreInt"])?(o=a?0:Es.INT32_MIN,l=a?Es.INT32_UNSIGNED_MAX:Es.INT32_MAX,d=!0):zs(t,["PgDoublePrecision","MySqlReal","MySqlDouble","SingleStoreReal","SingleStoreDouble","SQLiteReal"])?(o=a?0:Es.INT48_MIN,l=a?Es.INT48_UNSIGNED_MAX:Es.INT48_MAX):zs(t,["PgBigInt53","PgBigSeri
60al53","MySqlBigInt53","MySqlSerial","SingleStoreBigInt53","SingleStoreSerial","SQLiteInteger"])?(a=a||zs(t,["MySqlSerial","SingleStoreSerial"]),o=a?0:Number.MIN_SAFE_INTEGER,l=Number.MAX_SAFE_INTEGER,d=!0):zs(t,["MySqlYear","SingleStoreYear"])?(o=1901,l=2155,d=!0):(o=Number.MIN_SAFE_INTEGER,l=Number.MAX_SAFE_INTEGER);let u=n===!0||n?.number?s.coerce.number():s.number();return u=u.min(o).max(l),d?u.int():u}function s$(t,s,n){const a=t.getSQLType().includes("unsigned"),o=a?0n:Es.INT64_MIN,l=a?Es.INT64_UNSIGNED_MAX:Es.INT64_MAX;return(n===!0||n?.bigint?s.coerce.bigint():s.bigint()).min(o).max(l)}function n$(t,s,n){if(zs(t,["PgUUID"]))return s.string().uuid();let a,o,l=!1;zs(t,["PgVarchar","SQLiteText"])?a=t.length:zs(t,["MySqlVarChar","SingleStoreVarChar"])?a=t.length??Es.INT16_UNSIGNED_MAX:zs(t,["MySqlText","SingleStoreText"])&&(t.textType==="longtext"?a=Es.INT32_UNSIGNED_MAX:t.textType==="mediumtext"?a=Es.INT24_UNSIGNED_MAX:t.textType==="text"?a=Es.INT16_UNSIGNED_MAX:a=Es.INT8_UNSIGNED_MAX),zs(t,["PgChar","MySqlChar","SingleStoreChar"])&&(a=t.length,l=!0),zs(t,["PgBinaryVector"])&&(o=/^[01]+$/,a=t.dimensions);let d=n===!0||n?.string?s.coerce.string():s.string();return d=o?d.regex(o):d,a&&l?d.length(a):a?d.max(a):d}function ok(t){return q1(t)?B3(t):V3(t)}function lk(t,s,n,a){const o={};for(const[l,d]of Object.entries(t)){if(!pn(d,Mc)&&!pn(d,Ms)&&!pn(d,Ms.Aliased)&&typeof d=="object"){const x=q1(d)||z3(d)?ok(d):d;o[l]=lk(x,s[l]??{},n,a);continue}const u=s[l];if(u!==void 0&&typeof u!="function"){o[l]=u;continue}const h=pn(d,Mc)?d:void 0,f=h?ik(h,a):is.any(),g=typeof u=="function"?u(f):f;n.never(h)||(o[l]=g,h&&(n.nullable(h)&&(o[l]=o[l].nullable()),n.optional(h)&&(o[l]=o[l].optional())))}return is.object(o)}const r$={never:t=>t?.generated?.type==="always"||t?.generatedIdentity?.type==="always",optional:t=>!t.notNull||t.notNull&&t.hasDefault,nullable:t=>!t.notNull},Lt=(t,s)=>{const n=ok(t);return lk(n,{},r$)},a$=Mt("users",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),username:oe("username").notNull().unique(),email:oe("email").notNull().unique(),password:oe("password").notNull(),firstName:oe("first_name").notNull(),lastName:oe("last_name").notNull(),role:oe("role").notNull().default("admin"),createdAt:Ze("created_at").defaultNow()});Lt(a$).pick({username:!0,email:!0,password:!0,firstName:!0,lastName:!0,role:!0});const i$=Mt("password_reset_tokens",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),userId:Ne("user_id").notNull(),token:oe("token").notNull().unique(),newPasswordH
60ash:oe("new_password_hash"),type:oe("type").notNull().default("self"),initiatedBy:Ne("initiated_by"),expiresAt:Ze("expires_at").notNull(),usedAt:Ze("used_at"),createdAt:Ze("created_at").defaultNow()});Lt(i$).omit({id:!0,usedAt:!0,createdAt:!0});const o$=Mt("clients",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),name:oe("name").notNull(),slug:oe("slug").notNull().unique(),logo:oe("logo"),primaryColor:oe("primary_color").default("#B24884"),headingFont:oe("heading_font").default("Playfair Display"),bodyFont:oe("body_font").default("Inter"),preferredTheme:oe("preferred_theme").default("system"),status:oe("status").notNull().default("active"),createdAt:Ze("created_at").defaultNow()});Lt(o$).omit({id:!0,createdAt:!0});const ck=["public","org","teams"],l$=Mt("knowledge_bases",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id").notNull(),name:oe("name").notNull(),slug:oe("slug"),description:oe("description"),isPublic:Qs("is_public").default(!1),visibility:oe("visibility").notNull().default("org"),order:os("order").default(0),archivedAt:Ze("archived_at"),createdAt:Ze("created_at").defaultNow(),updatedAt:Ze("updated_at").defaultNow()});Lt(l$).omit({id:!0,archivedAt:!0}).extend({slug:is.string().nullable().optional()});const c$=Mt("categories",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),knowledgeBaseId:Ne("knowledge_base_id").notNull(),name:oe("name").notNull(),slug:oe("slug"),icon:oe("icon"),order:os("order").default(0),isPublic:Qs("is_public").default(!0),visibility:oe("visibility"),archivedAt:Ze("archived_at"),createdAt:Ze("created_at").defaultNow(),updatedAt:Ze("updated_at").defaultNow()});Lt(c$).omit({id:!0,archivedAt:!0});const d$=["procedure","overview"],u$=Mt("procedures",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id"),categoryId:Ne("category_id"),knowledgeBaseId:Ne("knowledge_base_id"),contentType:oe("content_type").notNull().default("procedure"),title:oe("title").notNull(),slug:oe("slug"),description:oe("description"),status:oe("status").notNull().default("draft"),version:os("version").default(1),owner:oe("owner"),order:os("order").default(0),isPublic:Qs("is_public").default(!0),visibility:oe("visibility"),videoUrl:oe("video_url"),transcript:oe("transcript"),archivedAt:Ze("archived_at"),createdAt:Ze("created_at").defaultNow(),updatedAt:Ze("updated_at").defaultNow()});Lt(u$).omit({id:!0,archivedAt:!0}).extend({clientId:is.string().nullable().optional(),categoryId:is.string().nullable().optional(),knowledgeBaseId:is.string().nullable().optional(),contentType:is.enum(d$).optional().default("procedure"),status:is.string().optional().default("draft"),version:is.number().optional().default(1),order:is.number().optional().default(0),isPublic:is.boolean().optional().default(!0),slug:is.string().nullable().optional(),description:is.string().nullable().optional(),owner:is.string().nullable().optional(),videoUrl:is.string().nullable().optional(),transcript:is.string().nullable().optional()});const m$=Mt("steps",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),procedureId:Ne("procedure_id").notNull(),order:os("order").notNull(),title:oe("title").notNull(),content:oe("content"),type:oe("type").notNull().default("action"),imageUrl:oe("image_url"),videoUrl:oe("video_url"),videoType:oe("video_type")});Lt(m$).omit({id:!0});const h$=Mt("procedure_notes",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),procedureId:Ne("procedure_id").notNull(),author:oe("author").notNull(),content:oe("content").notNull(),source:oe("source").notNull().default("admin"),createdAt:Ze("created_at").defaultNow()});Lt(h$).omit({id:!0,createdAt:!0});const f$=Mt("procedure_versions",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),procedureId:Ne("procedure_id").notNull(),version:os("version").notNull(),title:oe("title").notNull(),description:oe("description"),status:oe("status").notNull(),steps:br("steps"),changedBy:oe("changed_by"),changeSummary:oe("change_summary"),source:oe("source").default("manual"),createdAt:Ze("created_at").defaultNow()});Lt(f$).omit({id:!0,createdAt:!0});const p$=Mt("client_users",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id").notNull(),email:oe("email").notNull(),name:oe("name").notNull(),firstName:oe("first_name").notNull().default(""),lastName:oe("last_name").notNull().default(""),role:oe("role").notNull().default("viewer"),status:oe("status").notNull().default("active"),onboardingCompleted:Qs("onboarding_completed").notNull().default(!1),onboardingDismissed:Qs("onboarding_dism
60issed").notNull().default(!1),onboardingStep:os("onboarding_step").notNull().default(0),createdAt:Ze("created_at").defaultNow(),lastActiveAt:Ze("last_active_at")});Lt(p$).omit({id:!0,createdAt:!0,lastActiveAt:!0});const g$=Mt("teams",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id").notNull(),name:oe("name").notNull(),description:oe("description"),createdAt:Ze("created_at").defaultNow()});Lt(g$).omit({id:!0,createdAt:!0});const x$=Mt("team_members",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),teamId:Ne("team_id").notNull(),clientUserId:Ne("client_user_id").notNull(),role:oe("role").notNull().default("member"),addedAt:Ze("added_at").defaultNow()});Lt(x$).omit({id:!0,addedAt:!0});const v$=Mt("kb_team_access",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),knowledgeBaseId:Ne("knowledge_base_id").notNull(),teamId:Ne("team_id").notNull(),createdAt:Ze("created_at").defaultNow()});Lt(v$).omit({id:!0,createdAt:!0});const y$=Mt("category_team_access",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),categoryId:Ne("category_id").notNull(),teamId:Ne("team_id").notNull(),createdAt:Ze("created_at").defaultNow()});Lt(y$).omit({id:!0,createdAt:!0});const j$=Mt("procedure_team_access",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),procedureId:Ne("procedure_id").notNull(),teamId:Ne("team_id").notNull(),createdAt:Ze("created_at").defaultNow()});Lt(j$).omit({id:!0,createdAt:!0});const w$=Mt("client_urls",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id").notNull(),url:oe("url").notNull(),type:oe("type").notNull().default("internal"),knowledgeBaseId:Ne("knowledge_base_id"),isActive:Qs("is_active").default(!0)});Lt(w$).omit({id:!0});const b$=Mt("email_templates",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),name:oe("name").notNull(),slug:oe("slug").notNull().unique(),subject:oe("subject").notNull(),htmlContent:oe("html_content").notNull(),textContent:oe("text_content"),description:oe("description"),isActive:Qs("is_active").default(!0)});Lt(b$).omit({id:!0});const N$=Mt("automation_rules",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),name:oe("name").notNull(),description:oe("description"),status:oe("status").notNull().default("draft"),triggerType:oe("trigger_type").notNull(),triggerEvent:oe("trigger_event"),triggerConfig:br("trigger_config"),templateId:Ne("template_id").notNull(),delayMinutes:os("delay_minutes").default(0),audienceFilters:br("audience_filters"),isRecurring:Qs("is_recurring").default(!1),recurringIntervalMinutes:os("recurring_interval_minutes"),createdAt:Ze("created_at").defaultNow(),updatedAt:Ze("updated_at").defaultNow()});Lt(N$).omit({id:!0,createdAt:!0,updatedAt:!0});const S$=Mt("automation_enrollments",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),ruleId:Ne("rule_id").notNull(),entityType:oe("entity_type").notNull(),entityId:Ne("entity_id").notNull(),email:oe("email").notNull(),status:oe("status").notNull().default("queued"),scheduledAt:Ze("scheduled_at").notNull(),sentAt:Ze("sent_at"),context:br("context"),errorMessage:oe("error_message"),createdAt:Ze("created_at").defaultNow()});Lt(S$).omit({id:!0,sentAt:!0,errorMessage:!0,createdAt:!0});const C$=Mt("automation_events",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),eventType:oe("event_type").notNull(),entityType:oe("entity_type").notNull(),entityId:Ne("entity_id").notNull(),payload:br("payload"),processedAt:Ze("processed_at"),createdAt:Ze("created_at").defaultNow()});Lt(C$).omit({id:!0,processedAt:!0,createdAt:!0});const k$=Mt("automation_logs",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),enrollmentId:Ne("enrollment_id").notNull(),action:oe("action").notNull(),details:oe("details"),createdAt:Ze("created_at").defaultNow()});Lt(k$).omit({id:!0,createdAt:!0});const P$=Mt("segments",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),name:oe("name").notNull(),description:oe("description"),filters:br("filters").notNull(),memberCount:os("member_count").default(0),isActive:Qs("is_active").default(!0),createdAt:Ze("created_at").defaultNow(),updatedAt:Ze("updated_at").defaultNow()});Lt(P$).omit({id:!0,memberCount:!0,createdAt:!0,updatedAt:!0});const T$=Mt("newsletter_campaigns",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),name:oe("name").notNull(),subject:oe("subject").notNull(),templateId:Ne("template_id").notNull(),status:oe("status").notNull().default("draft"),audienceType:oe("audience_type").notNull().default("all"),segmentId:Ne("segment_id"),scheduledAt:Ze("scheduled_at"),sentAt:Ze("sent_at"),totalRecipients:os("total_recipients").default(0),sentCount:os("sent_count").default(0),failedCount:os("failed_count").default(0),createdAt:Ze("created_at").defaultNow(),updatedAt:Ze("updated_at").defaultNow()});Lt(T$).omit({id:!0,sentAt:!0,totalRecipients:!0,sentCount:!0,failedCount:!0,createdAt:!0,updatedAt:!0});const E$=Mt("newsletter_recipients",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),campaignId:Ne("campaign_id").notNull(),clientId:Ne("client_id").notNull(),email:oe("email").notNull(),status:oe("status").notNull().default("pending"),sentAt:Ze("sent_at"),errorMessage:oe("error_message"),createdAt:Ze("created_at").defaultNow()});Lt(E$).omit({id:!0,sentAt:!0,errorMessage:!0,createdAt:!0});const Jw=[{value:"name",label:"Company Name",type:"text"},{value:"slug",label:"URL Slug",type:"text"},{value:"status",label:"Status",type:"select",options:["active","inactive","pending"]},{value:"primaryColor",label:"Brand Color",type:"text"},{value:"plan",label:"Subscription Plan",type:"select",options:["hosting","diy","done_with_you"]}],eb=[{value:"equals",label:"Equals"},{value:"not_equals",label:"Not Equals"},{value:"contains",label:"Contains"},{value:"greater_than",label:"Greater Than"},{value:"less_than",label:"Less Than"},{value:"is_empty",label:"Is Empty"},{value:"is_not_empty",label:"Is Not Empty"}],_$=Mt("email_logs",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id"),contactId:Ne("contact_id"),recipientEmail:oe("recipient_email").notNull(),recipientName:oe("recipient_name"),type:oe("type").notNull().default("manual"),subject:oe("subject").notNull(),templateId:Ne("template_id"),status:oe("status").notNull().default("sent"),messageId:oe("message_id"),errorMessage:oe("error_message"),metadata:br("metadata"),sentAt:Ze("sent_at").defaultNow()});Lt(_$).omit({id:!0,sentAt:!0});const R$=Mt("contact_procedures",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),contactId:Ne("contact_id").notNull(),procedureId:Ne("procedure_id").notNull(),accessLevel:oe("access_level").notNull().default("view"),assignedAt:Ze("assigned_at").defaultNow(),assignedBy:oe("assigned_by")});Lt(R$).omit({id:!0,assignedAt:!0});const A$=Mt("ai_usage_logs",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id"),service:oe("service").notNull(),operationType:oe("operation_type").notNull(),inputTokens:os("input_tokens"),outputTokens:os("output_tokens"),audioDurationSeconds:os("audio_duration_seconds"),estimatedCostCents:os("estimated_cost_cents").notNull(),metadata:br("metadata"),createdAt:Ze("created_at").defaultNow()});Lt(A$).omit({id:!0,createdAt:!0});const I$=Mt("portal_login_tokens",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientUserId:Ne("client_user_id").notNull(),email:oe("email").notNull(),token:oe("token").notNull().unique(),code:oe("code").notNull(),expiresAt:Ze("expires_at").notNull(),usedAt:Ze("used_at"),createdAt:Ze("created_at").defaultNow()});Lt(I$).omit({id:!0,usedAt:!0,createdAt:!0});const D$=Mt("subscriptions",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id").notNull().unique(),stripeCustomerId:oe("stripe_customer_id").notNull(),stripeSubscriptionId:oe("stripe_subscription_id"),stripePriceId:oe("stripe_price_id"),plan:oe("plan").notNull(),status:oe("status").notNull().default("pending"),currentPeriodStart:Ze("
60current_period_start"),currentPeriodEnd:Ze("current_period_end"),cancelAtPeriodEnd:Qs("cancel_at_period_end").default(!1),createdAt:Ze("created_at").defaultNow(),updatedAt:Ze("updated_at").defaultNow()});Lt(D$).omit({id:!0,createdAt:!0,updatedAt:!0});const Dn={hosting:{name:"Hosting",price:29,tagline:"Host and share your knowledge base",description:"Full platform access without AI features",features:["Unlimited procedures & team members","Custom branded portal","Knowledge base hosting","Content management","Analytics & reporting","Email support"],aiEnabled:!1},diy:{name:"Creator",price:100,tagline:"Perfect for teams who want control",description:"Everything in Hosting plus AI-powered tools",features:["Everything in Hosting, plus:","AI-powered writing assistant","AI procedure generation","AI step improvement","Voice transcription & SOP generation","Screen recording analysis"],aiEnabled:!0},done_with_you:{name:"Done-For-You",price:5e3,tagline:"We build and maintain your knowledge base for you",description:"Full managed service with all AI features included",features:["Everything in Creator, plus:","Dedicated project manager","We extract knowledge from your team","Professional SOP creation & revisions","Priority support & onboarding"],aiEnabled:!0}},O$=Mt("admin_notification_preferences",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),userId:Ne("user_id").notNull(),eventType:oe("event_type").notNull(),emailEnabled:Qs("email_enabled").default(!1),inAppEnabled:Qs("in_app_enabled").default(!0),createdAt:Ze("created_at").defaultNow(),updatedAt:Ze("updated_at").defaultNow()});Lt(O$).omit({id:!0,createdAt:!0,updatedAt:!0});const M$=Mt("admin_notifications",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),userId:Ne("user_id").notNull(),eventType:oe("event_type").notNull(),title:oe("title").notNull(),message:oe("message").notNull(),metadata:br("metadata"),isRead:Qs("is_read").default(!1),createdAt:Ze("created_at").defaultNow()});Lt(M$).omit({id:!0,createdAt:!0});const L$=Mt("site_settings",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),key:oe("key").notNull().unique(),siteTitle:oe("site_title"),siteDescription:oe("site_description"),ogImageUrl:oe("og_image_url"),twitterCardType:oe("twitter_card_type"),twitterSite:oe("twitter_site"),twitterTitle:oe("twitter_title"),twitterDescription:oe("twitter_description"),twitterImage:oe("twitter_image"),updatedAt:Ze("updated_at").defaultNow(),updatedBy:Ne("updated_by")});Lt(L$).omit({id:!0,updatedAt:!0});const dk=["first_login","always","once"],uk=["admin","manager","editor","viewer","any"],mk=["diy","done_with_you","any"],F$=Mt("portal_popups",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),name:oe("name").notNull(),title:oe("title").notNull(),message:oe("message"),embedCode:oe("embed_code"),buttonText:oe("button_text"),buttonUrl:oe("button_url"),triggerType:oe("trigger_type").notNull().default("once"),planFilter:oe("plan_filter").notNull().default("any"),roleFilter:oe("role_filter").notNull().default("any"),displayLocation:oe("display_location").notNull().default("portal"),isActive:Qs("is_active").default(!0),priority:os("priority").default(0),createdAt:Ze("created_at").defaultNow(),updatedAt:Ze("updated_at").defaultNow()});Lt(F$).omit({id:!0,createdAt:!0,updatedAt:!0});const $$=Mt("popup_dismissals",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),popupId:Ne("popup_id").notNull(),clientUserId:Ne("client_user_id").notNull(),dismissedAt:Ze("dismissed_at").defaultNow()});Lt($$).omit({id:!0,dismissedAt:!0});const U$=Mt("export_audit_logs",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id").notNull(),requestedBy:Ne("requested_by").notNull(),requestedByEmail:oe("requested_by_email").notNull(),exportType:oe("export_type").notNull(),exportFormat:oe("export_format").notNull().default("json"),filters:br("filters"),status:oe("status").notNull().default("completed"),recordCount:os("record_count"),fileSizeBytes:os("file_size_bytes"),ipAddress:oe("ip_address"),userAgent:oe("user_agent"),createdAt:Ze("created_at").defaultNow()});Lt(U$).omit({id:!0,createdAt:!0});const z$=Mt("content_views",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id").notNull(),procedureId:Ne("procedure_id").notNull(),clientUserId:Ne("client_user_id"),sessionId:oe("session_id"),viewedAt:Ze("viewed_at").defaultNow()});Lt(z$).omit({id:!0,viewedAt:!0});const B$=Mt("user_feedback",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id").notNull(),procedureId:Ne("procedure_id").notNull(),clientUserId:Ne("client_user_id"),feedbackType:oe("feedback_type").notNull(),comment:oe("comment"),createdAt:Ze("created_at").defaultNow()});Lt(B$).omit({id:!0,createdAt:!0});const V$=Mt("analytics_settings",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id").notNull().unique(),kbAgingThresholdDays:os("kb_aging_threshold_days").default(180),categoryAgingThresholdDays:os("category_aging_threshold_days").default(90),contentAgingThresholdDays:os("content_aging_threshold_days").default(90),lowViewThreshold:os("low_view_threshold").default(0),highViewThreshold:os("high_view_threshold").default(100),lowHelpfulRatioThreshold:os("low_helpful_ratio_threshold").default(50),monitorKbAging:Qs("monitor_kb_aging").default(!1),monitorCategoryAging:Qs("monitor_category_aging").default(!1),monitorContentAging:Qs("monitor_content_aging").default(!1),monitorContentViews:Qs("monitor_content_views").default(!1),monitorUserFeedback:Qs("monitor_user_feedback").default(!1),createdAt:Ze("created_at").defaultNow(),updatedAt:Ze("updated_at").defaultNow()});Lt(V$).omit({id:!0,createdAt:!0,updatedAt:!0});const q$=Mt("platform_events",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),eventType:oe("event_type").notNull(),userId:Ne("user_id"),clientId:Ne("client_id"),clientUserId:Ne("client_user_id"),pagePath:oe("page_path"),metadata:br("metadata"),ipAddress:oe("ip_address"),userAgent:oe("user_agent"),createdAt:Ze("created_at").defaultNow()});Lt(q$).omit({id:!0,createdAt:!0});const K$=Mt("analytics_export_logs",{id:Ne("id").primaryKey().default(Et`gen_random_uuid()`),clientId:Ne("client_id"),requestedBy:Ne("requested_by").notNull(),requestedByEmail
vendor: 4,817 bytes, line 60
60:oe("requested_by_email").notNull(),exportType:oe("export_type").notNull(),dateRangeStart:Ze("date_range_start"),dateRangeEnd:Ze("date_range_end"),recordCount:os("record_count"),createdAt:Ze("created_at").defaultNow()});Lt(K$).omit({id:!0,createdAt:!0});function Qr(t){const s=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&s==="[object Date]"?new t.constructor(+t):typeof t=="number"||s==="[object Number]"||typeof t=="string"||s==="[object String]"?new Date(t):new Date(NaN)}function to(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}const hk=6048e5,H$=864e5;let W$={};function uh(){return W$}function Yc(t,s){const n=uh(),a=s?.weekStartsOn??s?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,o=Qr(t),l=o.getDay(),d=(l<a?7:0)+l-a;return o.setDate(o.getDate()-d),o.setHours(0,0,0,0),o}function jm(t){return Yc(t,{weekStartsOn:1})}function fk(t){const s=Qr(t),n=s.getFullYear(),a=to(t,0);a.setFullYear(n+1,0,4),a.setHours(0,0,0,0);const o=jm(a),l=to(t,0);l.setFullYear(n,0,4),l.setHours(0,0,0,0);const d=jm(l);return s.getTime()>=o.getTime()?n+1:s.getTime()>=d.getTime()?n:n-1}function tb(t){const s=Qr(t);return s.setHours(0,0,0,0),s}function sb(t){const s=Qr(t),n=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return n.setUTCFullYear(s.getFullYear()),+t-+n}function Q$(t,s){const n=tb(t),a=tb(s),o=+n-sb(n),l=+a-sb(a);return Math.round((o-l)/H$)}function G$(t){const s=fk(t),n=to(t,0);return n.setFullYear(s,0,4),n.setHours(0,0,0,0),jm(n)}function Y$(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Z$(t){if(!Y$(t)&&typeof t!="number")return!1;const s=Qr(t);return!isNaN(Number(s))}function X$(t){const s=Qr(t),n=to(t,0);return n.setFullYear(s.getFullYear(),0,1),n.setHours(0,0,0,0),n}const J$={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},e6=(t,s,n)=>{let a;const o=J$[t];return typeof o=="string"?a=o:s===1?a=o.one:a=o.other.replace("{{count}}",s.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a};function Cp(t){return(s={})=>{const n=s.width?String(s.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const t6={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},s6={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},n6={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},r6={date:Cp({formats:t6,defaultWidth:"full"}),time:Cp({formats:s6,defaultWidth:"full"}),dateTime:Cp({formats:n6,defaultWidth:"full"})},a6={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},i6=(t,s,n,a)=>a6[t];function dc(t){return(s,n)=>{const a=n?.context?String(n.context):"standalone";let o;if(a==="formatting"&&t.formattingValues){const d=t.defaultFormattingWidth||t.defaultWidth,u=n?.width?String(n.width):d;o=t.formattingValues[u]||t.formattingValues[d]}else{const d=t.defaultWidth,u=n?.width?String(n.width):t.defaultWidth;o=t.values[u]||t.values[d]}const l=t.argumentCallback?t.argumentCallback(s):s;return o[l]}}const o6={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},l6={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},c6={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},d6={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Frid
60ay","Saturday"]},u6={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},m6={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},h6=(t,s)=>{const n=Number(t),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},f6={ordinalNumber:h6,era:dc({values:o6,defaultWidth:"wide"}),quarter:dc({values:l6,defaultWidth:"wide",argumentCallback:t=>t-1}),month:dc({values:c6,defaultWidth:"wide"}),day:dc({values:d6,defaultWidth:"wide"}),dayPeriod:dc({values:u6,defaultWidth:"wide",formattingValues:m6,defaultFormattingWidth:"wide"})};function uc(t){return(s,n={})=>{const a=n.width,o=a&&t.matchPatterns[a]||t.matchPatterns[t.defaultMatchWidth],l=s.match(o);if(!l)return null;const d=l[0],u=a&&t.parsePatterns[a]||t.parsePatterns[t.defaultParseWidth],h=Array.isArray(u)?g6(u,x=>x.test(d)):p6(u,x=>x.test(d));let f;f=t.valueCallback?t.valueCallback(h):h,f=n.valueCallback?n.valueCallback(f):f;const g=s.slice(d.length);return{value:f,rest:g}}}function p6(t,s){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&s(t[n]))return n}function g6(t,s){for(let n=0;n<t.length;n++)if(s(t[n]))return n}function x6(t){return(s,n={})=>{const a=s.match(t.matchPattern);if(!a)return null;const o=a[0],l=s.match(t.parsePattern);if(!l)return null;let d=t.valueCallback?t.valueCallback(l[0]):l[0];d=n.valueCallback?n.valueCallback(d):d;const u=s.slice(o.length);return{value:d,rest:u}}}const v6=/^(\d+)(th|st|nd|rd)?/i,y6=/\d+/i,j6={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},w6={any:[/^b/i,/^(a|c)/i]},b6={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},N6={any:[/1/i,/2/i,/3/i,/4/i]},S6={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},C6={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},k6={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},P6={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},T6={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},E6={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},_6={ordinalNumber:x6({matchPattern:v6,parsePattern:y6,valueCallback:t=>parseInt(t,10)}),era:uc({matchPatterns:j6,defaultMatchWidth:"wide",parsePatterns:w6,defaultParseWidth:"any"}),quarter:uc({matchPatterns:b6,defaultMatchWidth:"wide",parsePatterns:N6,defaultParseWidth:"any",valueCallback:t=>t+1}),month:uc({matchPatterns:S6,defaultMatchWidth:"wide",parsePatterns:C6,defaultParseWidth:"any"}),day:uc({matchPatterns:k6,defaultMatchWidth:"wide",parsePatterns:P6,defaultParseWidth:"any"}),dayPeriod:uc({matchPatterns:T6,defaultMatchWidth:"any",parsePatterns:E6,defaultParseWidth:"any"})},R6={code:"en-US",formatDistance:e6,formatLong:r6,formatRelative:i6,localize:f6,match:_6,options:{weekStartsOn:0,firstWeekContainsDate:1}};function A6(t){const s=Qr(t);return Q$(s,X$(s))+1}function I6(t){const s=Qr(t),n=+jm(s)-+G$(s);return Math.round(n/hk)+1}function pk(t,s){const n=Qr(t),a=n.getFullYear(),o=uh(),l=s?.firstWeekContainsDate??s?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,d=to(t,0);d.setFullYear(a+1,0,l),d.setHours(0,0,0,0);const u=Yc(d,s),h=to(t,0);h.setFullYear(a,0,l),h.setHours(0,0,0,0);const f=Yc(h,s);return n.getTime()>=u.getTime()?a+1:n.getTime()>=f.getTime()?a:a-1}function D6(t,s){const n=uh(),a=s?.firstWeekContainsDate??s?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,o=pk(t,s),l=to(t,0);return l.setFullYear(o,0,a),l.setHours(0,0,0,0),Yc(l,s)}function O6(t,s){const n=Qr(t),a=+Yc(n,s)-+D6(n,s);return Math.round(a/hk)+1}function rs(t,s){const n=t<0?"-":"",a=Math.abs(t).toString().padStart(s,"0");return n+a}const oi={y(t,s){const n=t.getFullYear(),a=n>0?n:1-n;return rs(s==="yy"?a%100:a,s.length)},M(t,s){const n=t.getMonth();return s==="M"?String(n+1):rs(n+1,2)},d(t,s){return rs(t.getDate(),s.length)},a(t,s){const n=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(t,s){return rs(t.getHours()%12||12,s.length)},H(t,s){return rs(t.getHours(),s.length)},m(t,s){return rs(t.getMinutes(),s.length)},s(t,s){return rs(t.getSeconds(),s.length)},S(t,s){const n=s.length,a=t.getMilliseconds(),o=Math.trunc(a*Math.pow(10,n-3));return rs(o,s.length)}},Do={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},nb={G:function(t,s,n){const a=t.getFullYear()>0?1:0;switch(s){case"G":case"GG":case"GGG":return n.era(a,{width:"abbreviated"});case"GGGGG":return n.era(a,{width:"narrow"});default:return n.era(a,{width:"wide"})}},y:function(t,s,n){if(s==="yo"){const a=t.getFullYear(),o=a>0?a:1-a;return n.ordinalNumber(o,{unit:"year"})}return oi.y(t,s)},Y:function(t,s,n,a){const o=pk(t,a),l=o>0?o:1-o;if(s==="YY"){const d=l%100;return rs(d,2)}return s==="Yo"?n.ordinalNumber(l,{unit:"year"}):rs(l,s.length)},R:function(t,s){const n=fk(t);return rs(n,s.length)},u:function(t,s){const n=t.getFullYear();return rs(n,s.length)},Q:function(t,s,n){const a=Math.ceil((t.getMonth()+1)/3);switch(s){case"Q":return String(a);case"QQ":return rs(a,2);case"Qo":return n.ordinalNumber(a,{unit:"quarter"});case"QQQ":return n.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(a,{width:"narrow",context:"formatting"});default:return n.quarter(a,{width:"wide",context:"formatting"})}},q:function(t,s,n){const a=Math.ceil((t.getMonth()+1)/3);switch(s){case"q":return String(a);case"qq":return rs(a,2);case"qo":return n.ordinalNumber(a,{unit:"quarter"});case"qqq":return n.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(a,{width:"narrow",context:"standalone"});default:return n.quarter(a,{width:"wide",context:"standalone"})}},M:function(t,s,n){const a=t.getMonth();switch(s){case"M":case"MM":return oi.M(t,s);case"Mo":return n.ordinalNumber(a+1,{unit:"month"});case"MMM":return n.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(a,{width:"narrow",context:"formatting"});default:return n.month(a,{width:"wide",context:"formatting"})}},L:function(t,s,n){const a=t.getMonth();switch(s){case"L":return String(a+1);case"LL":return rs(a+1,2);case"Lo":return n.ordinalNumber(a+1,{unit:"month"});case"LLL":return n.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(a,{width:"narrow",context:"standalone"});default:return n.month(a,{width:"wide",context:"standalone"})}},w:function(t,s,n,a){const o=O6(t,a);return s==="wo"?n.ordinalNumber(o,{unit:"week"}):rs(o,s.length)},I:function(t,s,n){const a=I6(t);return s==="Io"?n.ordinalNumber(a,{unit:"week"}):rs(a,s.length)},d:function(t,s,n){return s==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):oi.d(t,s)},D:function(t,s,n){const a=A6(t);return s==="Do"?n.ordinalNumber(a,{unit:"dayOfYear"}):rs(a,s.length)},E:function(t,s,n){const a=t.getDay();switch(s){case"E":case"EE":case"EEE":return n.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},e:function(t,s,n,a){const o=t.getDay(),l=(o-a.weekStartsOn+8)%7||7;switch(s){case"e":return String(l);case"ee":return rs(l,2);case"eo":return n.ordinalNumber(l,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});default:return n.day(o,{width:"wide",context:"formatting"})}},c:function(t,s,n,a){const o=t.getDay(),l=(o-a.weekStartsOn+8)%7||7;switch(s){case"c":return String(l);case"cc":return rs(l,s.length);case"co":return n.ordinalNumber(l,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});default:return n.day(o,{width:"wide",context:"standalone"})}},i:function(t,s,n){const a=t.getDay(),o=a===0?7:a;switch(s){case"i":return String(o);case"ii":return rs(o,s.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},a:function(t,s,n){const o=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(o,{width:"narrow",context:"formatting"});default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(t,s,n){const a=t.getHours();let o;switch(a===12?o=Do.noon:a===0?o=Do.midnight:o=a/12>
vendor: 4,193 bytes, line 60
60=1?"pm":"am",s){case"b":case"bb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(o,{width:"narrow",context:"formatting"});default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(t,s,n){const a=t.getHours();let o;switch(a>=17?o=Do.evening:a>=12?o=Do.afternoon:a>=4?o=Do.morning:o=Do.night,s){case"B":case"BB":case"BBB":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(o,{width:"narrow",context:"formatting"});default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(t,s,n){if(s==="ho"){let a=t.getHours()%12;return a===0&&(a=12),n.ordinalNumber(a,{unit:"hour"})}return oi.h(t,s)},H:function(t,s,n){return s==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):oi.H(t,s)},K:function(t,s,n){const a=t.getHours()%12;return s==="Ko"?n.ordinalNumber(a,{unit:"hour"}):rs(a,s.length)},k:function(t,s,n){let a=t.getHours();return a===0&&(a=24),s==="ko"?n.ordinalNumber(a,{unit:"hour"}):rs(a,s.length)},m:function(t,s,n){return s==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):oi.m(t,s)},s:function(t,s,n){return s==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):oi.s(t,s)},S:function(t,s){return oi.S(t,s)},X:function(t,s,n){const a=t.getTimezoneOffset();if(a===0)return"Z";switch(s){case"X":return ab(a);case"XXXX":case"XX":return Li(a);default:return Li(a,":")}},x:function(t,s,n){const a=t.getTimezoneOffset();switch(s){case"x":return ab(a);case"xxxx":case"xx":return Li(a);default:return Li(a,":")}},O:function(t,s,n){const a=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+rb(a,":");default:return"GMT"+Li(a,":")}},z:function(t,s,n){const a=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+rb(a,":");default:return"GMT"+Li(a,":")}},t:function(t,s,n){const a=Math.trunc(t.getTime()/1e3);return rs(a,s.length)},T:function(t,s,n){const a=t.getTime();return rs(a,s.length)}};function rb(t,s=""){const n=t>0?"-":"+",a=Math.abs(t),o=Math.trunc(a/60),l=a%60;return l===0?n+String(o):n+String(o)+s+rs(l,2)}function ab(t,s){return t%60===0?(t>0?"-":"+")+rs(Math.abs(t)/60,2):Li(t,s)}function Li(t,s=""){const n=t>0?"-":"+",a=Math.abs(t),o=rs(Math.trunc(a/60),2),l=rs(a%60,2);return n+o+s+l}const ib=(t,s)=>{switch(t){case"P":return s.date({width:"short"});case"PP":return s.date({width:"medium"});case"PPP":return s.date({width:"long"});default:return s.date({width:"full"})}},gk=(t,s)=>{switch(t){case"p":return s.time({width:"short"});case"pp":return s.time({width:"medium"});case"ppp":return s.time({width:"long"});default:return s.time({width:"full"})}},M6=(t,s)=>{const n=t.match(/(P+)(p+)?/)||[],a=n[1],o=n[2];if(!o)return ib(t,s);let l;switch(a){case"P":l=s.dateTime({width:"short"});break;case"PP":l=s.dateTime({width:"medium"});break;case"PPP":l=s.dateTime({width:"long"});break;default:l=s.dateTime({width:"full"});break}return l.replace("{{date}}",ib(a,s)).replace("{{time}}",gk(o,s))},L6={p:gk,P:M6},F6=/^D+$/,$6=/^Y+$/,U6=["D","DD","YY","YYYY"];function z6(t){return F6.test(t)}function B6(t){return $6.test(t)}function V6(t,s,n){const a=q6(t,s,n);if(console.warn(a),U6.includes(t))throw new RangeError(a)}function q6(t,s,n){const a=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${s}\`) for formatting ${a} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const K6=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,H6=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,W6=/^'([^]*?)'?$/,Q6=/''/g,G6=/[a-zA-Z]/;function Nr(t,s,n){const a=uh(),o=a.locale??R6,l=a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,d=a.weekStartsOn??a.locale?.options?.weekStartsOn??0,u=Qr(t);if(!Z$(u))throw new RangeError("Invalid time value");let h=s.match(H6).map(g=>{const x=g[0];if(x==="p"||x==="P"){const v=L6[x];return v(g,o.formatLong)}return g}).join("").match(K6).map(g=>{if(g==="''")return{isToken:!1,value:"'"};const x=g[0];if(x==="'")return{isToken:!1,value:Y6(g)};if(nb[x])return{isToken:!0,value:g};
60if(x.match(G6))throw new RangeError("Format string contains an unescaped latin alphabet character `"+x+"`");return{isToken:!1,value:g}});o.localize.preprocessor&&(h=o.localize.preprocessor(u,h));const f={firstWeekContainsDate:l,weekStartsOn:d,locale:o};return h.map(g=>{if(!g.isToken)return g.value;const x=g.value;(B6(x)||z6(x))&&V6(x,s,String(t));const v=nb[x[0]];return v(u,x,o.localize,f)}).join("")}function Y6(t){const s=t.match(W6);return s?s[1].replace(Q6,"'"):t}function Z6({clientId:t}){const{toast:s}=dt(),{user:n}=Da(),[a,o]=m.useState(!1),[l,d]=m.useState(!1),[u,h]=m.useState(!1),[f,g]=m.useState(!1),{data:x,isLoading:v,refetch:w}=je({queryKey:["/api/admin/subscription",t],queryFn:async()=>{const M=await fetch(`/api/admin/subscription/${t}`,{credentials:"include"});if(!M.ok)throw new Error("Failed to fetch subscription");return M.json()},enabled:!!t&&!!n?.id}),C=x?.subscription,j=async M=>{if(n?.id){o(!0);try{const z=await fetch("/api/admin/subscription/cancel",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({clientId:t,cancelImmediately:M})}),H=await z.json();if(!z.ok)throw new Error(H.error||"Failed to cancel");s({title:"Subscription updated",description:H.message}),d(!1),w()}catch(z){s({title:"Error",description:z.message,variant:"destructive"})}finally{o(!1)}}},b=async M=>{if(n?.id){h(!0);try{const z=await fetch("/api/admin/subscription/change-plan",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({clientId:t,newPlan:M})}),H=await z.json();if(!z.ok)throw new Error(H.error||"Failed to change plan");s({title:"Plan updated",description:H.message}),g(!1),w()}catch(z){s({title:"Error",description:z.message,variant:"destructive"})}finally{h(!1)}}};if(v)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx(be,{className:"h-48 w-full"})]});if(!C)return e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(di,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"font-medium text-lg mb-2",children:"No subscription found"}),e.jsx("p",{className:"text-muted-foreground text-sm text-center",children:"This client does not have an active subscription."})]})});const k=C.plan==="hosting"?"hosting":C.plan==="done_with_you"?"done_with_you":"diy",N=Dn[k],T=k==="hosting"?"diy":"hosting",P=Dn[T],I=k==="hosting",O=k==="done_with_you",F=C.currentPeriodEnd&&new Date(C.currentPeriodEnd).getTime()>0?Nr(new Date(C.currentPeriodEnd),"MMMM d, yyyy"):null;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs(ee,{className:"border-border/50",children:[e.jsx(qe,{children:e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(di,{className:"h-5 w-5"}),"Current Plan"]})}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-semibold",children:N.name}),e.jsxs("p",{className:"text-muted-foreground",children:["$",N.price,"/month"]})]}),e.jsx(Ce,{variant:C.status==="active"?"default":"secondary",children:C.status})]}),C.cancelAtPeriodEnd?e.jsx("div",{className:"p-3 bg-amber-50 dark:bg-amber-900/20 rounded-md border border-amber-200 dark:border-amber-800",children:e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:["Subscription will cancel",F?` on ${F}`:" at the end of the billing period"]})}):F?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Next billing date: ",F]}):null,C.status==="active"&&!C.cancelAtPeriodEnd&&!O&&e.jsxs(St,{open:f,onOpenChange:g,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{variant:I?"default":"outline",size:"sm","data-testid":"button-admin-change-plan",children:[e.jsx(gs,{className:"h-4 w-4 mr-2"}),I?"Upgrade to Creator":"Switch to Hosting"]})}),e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:I?"Upgrade Client to Creator":"Switch Client to Hosting"}),e.jsx(Gt,{children:I?"This will upgrade the client to the Creator plan, unlocking all AI features.":"This will downgrade the client to the Hosting plan. They will lose access to AI features."})]}
60),e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-md",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:P.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["$",P.price,"/month"]})]}),e.jsx(Ce,{variant:"outline",children:I?`+$${P.price-N.price}/mo`:`-$${N.price-P.price}/mo`})]}),I&&e.jsx("ul",{className:"space-y-2",children:["AI-powered writing assistant","AI procedure generation","AI step improvement","Voice transcription","Screen recording analysis"].map((M,z)=>e.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Sr,{className:"w-4 h-4 text-primary flex-shrink-0"}),e.jsx("span",{children:M})]},z))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The price change will be prorated for the remainder of the current billing period."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(D,{variant:"outline",onClick:()=>g(!1),disabled:u,children:"Cancel"}),e.jsxs(D,{onClick:()=>b(T),disabled:u,"data-testid":"button-admin-confirm-change-plan",children:[u&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),I?"Upgrade Now":"Switch Plan"]})]})]})]})]})]})]}),e.jsxs(ee,{className:"border-border/50",children:[e.jsx(qe,{children:e.jsx(tt,{children:"Stripe Info"})}),e.jsxs(te,{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Customer ID:"}),e.jsx("span",{className:"font-mono text-xs",children:C.stripeCustomerId})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subscription ID:"}),e.jsx("span",{className:"font-mono text-xs",children:C.stripeSubscriptionId||"N/A"})]})]})]})]}),!C.cancelAtPeriodEnd&&C.status==="active"&&C.stripeSubscriptionId&&e.jsxs(ee,{className:"border-destructive/50",children:[e.jsxs(qe,{children:[e.jsx(tt,{className:"text-destructive",children:"Cancel Subscription"}),e.jsx(Tt,{children:"End the client's subscription"})]}),e.jsx(te,{children:e.jsxs(St,{open:l,onOpenChange:d,children:[e.jsx(bs,{asChild:!0,children:e.jsx(D,{variant:"destructive","data-testid":"button-admin-cancel-subscription",children:"Cancel Subscription"})}),e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Cancel Client Subscription"}),e.jsx(Gt,{children:"Are you sure you want to cancel this client's subscription?"})]}),e.jsxs("div",{className:"flex flex-col gap-3 mt-4",children:[e.jsxs(D,{variant:"outline",onClick:()=>j(!1),disabled:a,"data-testid":"button-admin-cancel-at-period-end",children:[a&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Cancel at end of billing period"]}),e.jsxs(D,{variant:"destructive",onClick:()=>j(!0),disabled:a,"data-testid":"button-admin-cancel-immediately",children:[a&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Cancel immediately"]})]})]})]})})]})]})}function X6({clientId:t}){const{data:s,isLoading:n,isError:a}=je({queryKey:["/api/clients",t,"ai-usage"],enabled:!!t}),{data:o,isLoading:l,isError:d}=je({queryKey:["/api/clients",t,"ai-usage","summary"],enabled:!!t});if(!t)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:e.jsx("p",{children:"No client selected"})});if(a||d)return e.jsxs("div",{className:"text-center py-8",children:[e.jsx(qo,{className:"h-10 w-10 mx-auto mb-3 text-destructive opacity-50"}),e.jsx("p",{className:"text-destructive",children:"Failed to load AI usage data"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Please try refreshing the page"})]});const u=v=>`$${(v/100).toFixed(4)}`,h=v=>Nr(new Date(v),"MMM d, yyyy h:mm a");if(n||l)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(be,{className:"h-24"}),e.jsx(be,{className:"h-24"}),e.jsx(be,{className:"h-24"})]}),e.jsx(be,{className:"h-64"})]});const f=o?.totalCostCents||0,g=o?.serviceBreakdown?.find(v=>v.service==="claude"),x=o?.serviceBreakdown?.find(v=>v.service==="elevenlabs");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-medium text-lg",children:"AI Usage Overview"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track Claude and ElevenLabs API usage for this company"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(qo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-semibold",children:u(f)}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Estimated Cost"})]})]})}),e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(gs,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-semibold",children:u(g?.totalCost||0)}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Claude (",g?.count||0," calls)"]})]})]})}),e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/10 flex items-center justify-center",children:e.jsx(no,{className:"h-5 w-5 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-semibold",children:u(x?.totalCost||0)}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["ElevenLabs (",x?.count||0," calls)"]})]})]})})]}),o?.operationBreakdown&&o.operationBreakdown.length>0&&e.jsxs(ee,{className:"border-border/50",children:[e.jsx(qe,{children:e.jsx(tt,{className:"text-base",children:"Usage by Operation Type"})}),e.jsx(te,{children:e.jsx("div",{className:"space-y-3",children:o.operationBreakdown.map(v=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:"secondary",className:"font-mono text-xs",children:v.operationType.replace(/_/g," ")}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",v.count," calls)"]})]}),e.jsx("span",{className:"font-medium",children:u(v.totalCost)})]},v.operationType))})})]}),e.jsxs(ee,{className:"border-border/50",children:[e.jsxs(qe,{children:[e.jsx(tt,{className:"text-base",children:"Recent Activity"}),e.jsx(Tt,{children:"Last 50 AI API calls for this company"})]}),e.jsx(te,{children:!s||s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(qo,{className:"h-10 w-10 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"No AI usage recorded yet"})]}):e.jsx(jl,{className:"h-[400px]",children:e.jsx("div",{className:"space-y-2",children:s.slice(0,50).map(v=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-md bg-muted/30","data-testid":`ai-usage-log-${v.id}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ce,{variant:v.service==="claude"?"default":"secondary",children:v.service}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:v.operationType.replace(/_/g," ")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h(v.createdAt)})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"font-medium",children:u(v.estimatedCostCents)}),v.service==="claude"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[v.inputTokens?.toLocaleStr
60ing()," in / ",v.outputTokens?.toLocaleString()," out"]}),v.service==="elevenlabs"&&v.audioDurationSeconds&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[v.audioDurationSeconds.toFixed(1),"s audio"]})]})]},v.id))})})})]})]})}var xk="AlertDialog",[J6]=En(xk,[k0]),La=k0(),vk=t=>{const{__scopeAlertDialog:s,...n}=t,a=La(s);return e.jsx(rx,{...a,...n,modal:!0})};vk.displayName=xk;var eU="AlertDialogTrigger",tU=m.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...a}=t,o=La(n);return e.jsx(ax,{...o,...a,ref:s})});tU.displayName=eU;var sU="AlertDialogPortal",yk=t=>{const{__scopeAlertDialog:s,...n}=t,a=La(s);return e.jsx(ix,{...a,...n})};yk.displayName=sU;var nU="AlertDialogOverlay",jk=m.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...a}=t,o=La(n);return e.jsx(td,{...o,...a,ref:s})});jk.displayName=nU;var Xo="AlertDialogContent",[rU,aU]=J6(Xo),iU=qb("AlertDialogContent"),wk=m.forwardRef((t,s)=>{const{__scopeAlertDialog:n,children:a,...o}=t,l=La(n),d=m.useRef(null),u=At(s,d),h=m.useRef(null);return e.jsx(RA,{contentName:Xo,titleName:bk,docsSlug:"alert-dialog",children:e.jsx(rU,{scope:n,cancelRef:h,children:e.jsxs(sd,{role:"alertdialog",...l,...o,ref:u,onOpenAutoFocus:Ae(o.onOpenAutoFocus,f=>{f.preventDefault(),h.current?.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[e.jsx(iU,{children:a}),e.jsx(lU,{contentRef:d})]})})})});wk.displayName=Xo;var bk="AlertDialogTitle",Nk=m.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...a}=t,o=La(n);return e.jsx(nd,{...o,...a,ref:s})});Nk.displayName=bk;var Sk="AlertDialogDescription",Ck=m.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...a}=t,o=La(n);return e.jsx(rd,{...o,...a,ref:s})});Ck.displayName=Sk;var oU="AlertDialogAction",kk=m.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...a}=t,o=La(n);return e.jsx(Qm,{...o,...a,ref:s})});kk.displayName=oU;var Pk="AlertDialogCancel",Tk=m.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...a}=t,{cancelRef:o}=aU(Pk,n),l=La(n),d=At(s,o);return e.jsx(Qm,{...l,...a,ref:d})});Tk.displayName=Pk;var lU=({contentRef:t})=>{const s=`\`${Xo}\` requires a description for the component to be accessible for screen reader users.
61
62You can add a description to the \`${Xo}\` by passing a \`${Sk}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
63
64Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Xo}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
65
66For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return m.useEffect(()=>{document.getElementById(t.current?.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},cU=vk,dU=yk,Ek=jk,_k=wk,Rk=kk,Ak=Tk,Ik=Nk,Dk=Ck;const Ok=cU,uU=dU,Mk=m.forwardRef(({className:t,...s},n)=>e.jsx(Ek,{className:Oe("fixed inset-0 z-50 bg-black/80  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:n}));Mk.displayName=Ek.displayName;const Vx=m.forwardRef(({className:t,...s},n)=>e.jsxs(uU,{children:[e.jsx(Mk,{}),e.jsx(_k,{ref:n,className:Oe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s})]}));Vx.displayName=_k.displayName;const qx=({className:t,...s})=>e.jsx("div",{className:Oe("flex flex-col space-y-2 text-center sm:text-left",t),...s});qx.displayName="AlertDialogHeader";const Kx=({className:t,...s})=>e.jsx("div",{className:Oe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Kx.displayName="AlertDialogFooter";const Hx=m.forwardRef(({className:t,...s},n)=>e.jsx(Ik,{ref:n,className:Oe("text-lg font-semibold",t),...s}));Hx.displayName=Ik.displayName;const Wx=m.forwardRef(({className:t,...s},n)=>e.jsx(Dk,{ref:n,className:Oe("text-sm text-muted-foreground",t),...s}));Wx.displayName=Dk.displayName;const Qx=m.forwardRef(({className:t,...s},n)=>e.jsx(Rk,{ref:n,className:Oe(Zg(),t),...s}));Qx.displayName=Rk.displayName;const Gx=m.forwardRef(({className:t,...s},n)=>e.jsx(Ak,{ref:n,className:Oe(Zg({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));Gx.displayName=Ak.displayName;function mU({contactId:t,procedures:s}){const{toast:n}=dt(),{data:a,isLoading:o}=je({queryKey:["/api/contact-procedures",t]}),l=ye({mutationFn:async g=>
66ce("POST","/api/contact-procedures",g),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/contact-procedures",t]}),n({title:"Procedure assigned to contact"})},onError:()=>{n({title:"Failed to assign procedure",variant:"destructive"})}}),d=ye({mutationFn:async g=>ce("DELETE",`/api/contact-procedures/${t}/${g}`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/contact-procedures",t]}),n({title:"Procedure unassigned"})},onError:()=>{n({title:"Failed to unassign procedure",variant:"destructive"})}}),u=ye({mutationFn:async({procedureId:g,accessLevel:x})=>ce("PATCH",`/api/contact-procedures/${t}/${g}`,{accessLevel:x}),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/contact-procedures",t]}),n({title:"Access level updated"})},onError:()=>{n({title:"Failed to update access level",variant:"destructive"})}}),h=new Set(a?.map(g=>g.procedureId)||[]),f=s.filter(g=>!h.has(g.id));return e.jsxs("div",{className:"mt-4 pt-4 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Procedure Access"})]}),f.length>0&&e.jsxs(Gi,{children:[e.jsx(Yi,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm","data-testid":`button-assign-procedure-${t}`,children:[e.jsx(ds,{className:"h-3 w-3 mr-1"}),"Assign Procedure"]})}),e.jsx(pi,{align:"end",children:f.map(g=>e.jsx(on,{onClick:()=>l.mutate({contactId:t,procedureId:g.id,accessLevel:"view"}),"data-testid":`menu-assign-procedure-${g.id}`,children:g.title},g.id))})]})]}),o?e.jsx(be,{className:"h-12"}):a?.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No procedures assigned to this contact."}):e.jsx("div",{className:"space-y-2",children:a?.map(g=>{const x=s.find(v=>v.id===g.procedureId);return x?e.jsxs("div",{className:"flex items-center justify-between gap-4 p-2 rounded-md bg-muted/30","data-testid":`item-procedure-${g.procedureId}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pt,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:x.title})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(lt,{value:g.accessLevel,onValueChange:v=>u.mutate({procedureId:g.procedureId,accessLevel:v}),children:[e.jsx(it,{className:"w-24 h-8","data-testid":`select-access-${g.procedureId}`,children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"view",children:"View"}),e.jsx(me,{value:"edit",children:"Edit"})]})]}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>d.mutate(g.procedureId),"data-testid":`button-unassign-procedure-${g.procedureId}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]},g.procedureId):null})})]})}function hU({clientId:t}){const{toast:s}=dt(),[n,a]=m.useState(null),[o,l]=m.useState(!1),[d,u]=m.useState(null),[h,f]=m.useState(null),{data:g,isLoading:x}=je({queryKey:["/api/clients",t,"users"]}),{data:v}=je({queryKey:["/api/procedures"]}),w=ye({mutationFn:async N=>ce("POST","/api/client-users",N),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/clients",t,"users"]}),l(!1),s({title:"Contact created successfully"})},onError:()=>{s({title:"Failed to create contact",variant:"destructive"})}}),C=ye({mutationFn:async({id:N,data:T})=>ce("PATCH",`/api/client-users/${N}`,T),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/clients",t,"users"]}),a(null),s({title:"Contact updated successfully"})},onError:()=>{s({title:"Failed to update contact",variant:"destructive"})}}),j=ye({mutationFn:async N=>ce("DELETE",`/api/client-users/${N}`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/clients",t,"users"]}),s({title:"Contact deleted successfully"})},onError:()=>{s({title:"Failed to delete contact",variant:"destructive"})}}),b=N=>{N.preventDefault();const T=new FormData(N.currentTarget),P=T.get("firstName"),I=T.get("lastName");w.mutate({clientId:t,name:`${P} ${I}`.trim(),firstName:P,lastName:I,email:T.get("email"),role:T.get("role")||"viewer",status:"active"})},k=N=>{if(N.preventDefault(),!n)return;const T=new FormData(N.currentTarget),P=T.get("firstName"),I=T.get("lastName");C.mutate({id:n.id,data:{name:`${P} ${I}`.trim(),firstName:P,lastName:I,email:T.get("email"),role:T.get("role"),status:T.get("status")}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-medium text-lg",children:"Contacts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage contacts for this company"})]}),e.jsxs(St,{open:o,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{"data-testid":"button-add-contact",children:[e.jsx(ds,{className:"h-4 w-4 mr-1"}),"Add Contact"]})}),e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Add New Contact"}),e.jsx(Gt,{children:"Add a new contact to this company"})]}),e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"firstName",children:"First Name"}),e.jsx(fe,{id:"firstName",name:"firstName",required:!0,"data-testid":"input-contact-first-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"lastName",children:"Last Name"}),e.jsx(fe,{id:"lastName",name:"lastName",required:!0,"data-testid":"input-contact-last-name"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"email",children:"Email"}),e.jsx(fe,{id:"email",name:"email",type:"email",required:!0,"data-testid":"input-contact-email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"role",children:"Role"}),e.jsxs(lt,{name:"role",defaultValue:"viewer",children:[e.jsx(it,{"data-testid":"select-contact-role",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"admin",children:"Admin"}),e.jsx(me,{value:"manager",children:"Manager"}),e.jsx(me,{value:"editor",children:"Editor"}),e.jsx(me,{value:"viewer",children:"Viewer"})]})]})]}),e.jsx(Vs,{children:e.jsxs(D,{type:"submit",disabled:w.isPending,"data-testid":"button-save-contact",children:[w.isPending?e.jsx(Ve,{className:"h-4 w-4 animate-spin mr-1"}):null,"Add Contact"]})})]})]})]})]}),x?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(N=>e.jsx(be,{className:"h-16"}
66,N))}):g?.length===0?e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-8 text-center",children:[e.jsx(Bs,{className:"h-10 w-10 text-muted-foreground/50 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No contacts yet. Add your first contact."})]})}):e.jsx("div",{className:"space-y-3",children:g?.map(N=>e.jsx(ee,{className:"border-border/50","data-testid":`card-contact-${N.id}`,children:e.jsxs(te,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"text-primary font-medium text-sm",children:`${N.firstName?.[0]||""}${N.lastName?.[0]||""}`.toUpperCase()||N.email[0]?.toUpperCase()})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:`${N.firstName||""} ${N.lastName||""}`.trim()||N.email}),e.jsx("p",{className:"text-sm text-muted-foreground",children:N.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Ce,{variant:"secondary",children:N.role}),e.jsx(Ce,{variant:N.status==="active"?"default":"secondary",children:N.status}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>u(d===N.id?null:N.id),"data-testid":`button-expand-contact-${N.id}`,children:d===N.id?e.jsx(On,{className:"h-4 w-4"}):e.jsx(Bt,{className:"h-4 w-4"})}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>a(N),"data-testid":`button-edit-contact-${N.id}`,children:e.jsx(Ia,{className:"h-4 w-4"})}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>f(N),"data-testid":`button-delete-contact-${N.id}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]}),d===N.id&&e.jsx(mU,{contactId:N.id,procedures:v||[]})]})},N.id))}),e.jsx(St,{open:!!n,onOpenChange:N=>!N&&a(null),children:e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Edit Contact"}),e.jsx(Gt,{children:"Update contact information"})]}),e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-firstName",children:"First Name"}),e.jsx(fe,{id:"edit-firstName",name:"firstName",defaultValue:n?.firstName||"",required:!0,"data-testid":"input-edit-contact-first-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-lastName",children:"Last Name"}),e.jsx(fe,{id:"edit-lastName",name:"lastName",defaultValue:n?.lastName||"",required:!0,"data-testid":"input-edit-contact-last-name"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-email",children:"Email"}),e.jsx(fe,{id:"edit-email",name:"email",type:"email",defaultValue:n?.email,required:!0,"data-testid":"input-edit-contact-email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-role",children:"Role"}),e.jsxs(lt,{name:"role",defaultValue:n?.role,children:[e.jsx(it,{"data-testid":"select-edit-contact-role",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"admin",children:"Admin"}),e.jsx(me,{value:"manager",children:"Manager"}),e.jsx(me,{value:"editor",children:"Editor"}),e.jsx(me,{value:"viewer",children:"Viewer"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-status",children:"Status"}),e.jsxs(lt,{name:"status",defaultValue:n?.status,children:[e.jsx(it,{"data-testid":"select-edit-contact-status",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"active",children:"Active"}),e.jsx(me,{value:"inactive",children:"Inactive"})]})]})]}),e.jsx(Vs,{children:e.jsxs(D,{type:"submit",disabled:C.isPending,"data-testid":"button-update-contact",children:[C.isPending?e.jsx(Ve,{className:"h-4 w-4 animate-spin mr-1"}):null,"Update Contact"]})})]})]})}),e.jsx(Ok,{open:!!h,onOpenChange:N=>!N&&f(null),children:e.jsxs(Vx,{children:[e.jsxs(qx,{children:[e.jsxs(Hx,{className:"flex items-center gap-2",children:[e.jsx(pl,{className:"h-5 w-5 text-destructive"}),"Delete User"]}),e.jsxs(Wx,{children:['Are you sure you want to delete "',h?.firstName," ",h?.lastName,'"? This will permanently remove this user and their associated data from the system. This action cannot be undone.']})]}),e.jsxs(Kx,{children:[e.jsx(Gx,{"data-testid":"button-cancel-delete-user",children:"Cancel"}),e.jsxs(Qx,{onClick:()=>{h&&(j.mutate(h.id),f(null))},disabled:j.isPending,className:"bg-destructive text-destructive-foreground","data-testid":"button-confirm-delete-user",children:[j.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Delete User"]})]})]})})]})}function fU({clientId:t}){const{data:s,isLoading:n}=je({queryKey:["/api/clients",t,"email-logs"]}),{data:a}=je({queryKey:["/api/clients",t,"users"]}),o=d=>!d||!a?null:a.find(u=>u.id===d)?.name,l=d=>{switch(d){case"sent":return"default";case"opened":return"default";case"clicked":return"default";case"failed":return"destructive";case"bounced":return"destructive";default:return"secondary"}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-medium text-lg",children:"Email History"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All emails sent to contacts at this company"})]}),n?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(d=>e.jsx(be,{className:"h-16"},d))}):s?.length===0?e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-8 text-center",children:[e.jsx(Ta,{className:"h-10 w-10 text-muted-foreground
66/50 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No emails sent yet."})]})}):e.jsx("div",{className:"space-y-3",children:s?.map(d=>e.jsx(ee,{className:"border-border/50","data-testid":`card-email-${d.id}`,children:e.jsx(te,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Ta,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium truncate",children:d.subject}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",d.recipientName||d.recipientEmail,d.contactId&&o(d.contactId)&&e.jsxs("span",{className:"ml-1",children:["(",o(d.contactId),")"]})]}),d.sentAt&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Nr(new Date(d.sentAt),"MMM d, yyyy 'at' h:mm a")})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 flex-wrap",children:[e.jsx(Ce,{variant:"secondary",children:d.type}),e.jsx(Ce,{variant:l(d.status),children:d.status})]})]})})},d.id))})]})}const ob=[{name:"Playfair Display",category:"serif"},{name:"Merriweather",category:"serif"},{name:"Lora",category:"serif"},{name:"Crimson Text",category:"serif"},{name:"Libre Baskerville",category:"serif"},{name:"Cormorant Garamond",category:"serif"},{name:"EB Garamond",category:"serif"},{name:"Source Serif Pro",category:"serif"},{name:"Poppins",category:"sans-serif"},{name:"Montserrat",category:"sans-serif"},{name:"Raleway",category:"sans-serif"},{name:"Oswald",category:"sans-serif"}],lb=[{name:"Inter",category:"sans-serif"},{name:"Open Sans",category:"sans-serif"},{name:"Roboto",category:"sans-serif"},{name:"Lato",category:"sans-serif"},{name:"Source Sans Pro",category:"sans-serif"},{name:"Nunito",category:"sans-serif"},{name:"Work Sans",category:"sans-serif"},{name:"PT Sans",category:"sans-serif"},{name:"Merriweather",category:"serif"},{name:"Lora",category:"serif"},{name:"Crimson Text",category:"serif"},{name:"Source Serif Pro",category:"serif"}];function pU({client:t}){const{toast:s}=dt(),[n,a]=m.useState(t?.name||""),[o,l]=m.useState(t?.slug||""),[d,u]=m.useState(t?.status||"active"),[h,f]=m.useState(t?.logo||""),[g,x]=m.useState(t?.headingFont||"Playfair Display"),[v,w]=m.useState(t?.bodyFont||"Inter"),[C,j]=m.useState(!1),b=m.useRef(null);m.useEffect(()=>{t&&(a(t.name),l(t.slug),u(t.status),f(t.logo||""),x(t.headingFont||"Playfair Display"),w(t.bodyFont||"Inter"))},[t]);const k=ye({mutationFn:async P=>ce("PATCH",`/api/clients/${t?.id}`,P),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/clients"]}),de.invalidateQueries({queryKey:["/api/clients",t?.id]}),t?.slug&&de.invalidateQueries({queryKey:["/api/knowledge-bases/by-slug",t.slug]}),s({title:"Client updated successfully"})},onError:()=>{s({title:"Failed to update client",variant:"destructive"})}}),N=async P=>{const I=P.target.files?.[0];if(I){if(!I.type.startsWith("image/")){s({title:"Please select an image file",variant:"destructive"});return}if(I.size>2*1024*1024){s({title:"Logo must be under 2MB",variant:"destructive"});return}j(!0);try{const O=await fetch("/api/uploads/request-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:I.name,size:I.size,contentType:I.type,mediaType:"logo"})});if(!O.ok)throw new Error("Failed to get upload URL");const{uploadURL:R,objectPath:F}=await O.json();if(!(await fetch(R,{method:"PUT",body:I,headers:{"Content-Type":I.type}})).ok)throw new Error("Failed to upload logo");f(F),s({title:"Logo uploaded successfully"})}catch{s({title:"Failed to upload logo",variant:"destructive"})}finally{j(!1)}}},T=P=>{P.preventDefault(),k.mutate({name:n,slug:o,status:d,logo:h,headingFont:g,bodyFont:v})};return e.jsxs(ee,{className:"border-border/50",children:[e.jsxs(qe,{children:[e.jsx(tt,{children:"Client Settings"}),e.jsx(Tt,{children:"Manage client configuration and branding"})]}),e.jsx(te,{children:e.jsxs("form",{onSubmit:T,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Client Name"}),e.jsx(fe,{value:n,onChange:P=>a(P.target.value),"data-testid":"input-client-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Slug"}),e.jsx(fe,{value:o,onChange:P=>l(P.target.value),"data-testid":"input-client-slug"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Status"}),e.jsxs(lt,{value:d,onValueChange:u,children:[e.jsx(it,{"data-testid":"select-client-status",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"active",children:"Active"}),e.jsx(me,{value:"inactive",children:"Inactive"})]})]})]}),e.jsxs("div",{className:"border-t pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-1",children:"Branding"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Customize the look of your knowledge base portal"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Logo"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Recommended size: 160 x 50 pixels. Max file size: 2MB"}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[h?e.jsx("div",{className:"border rounded-md p-2 bg-muted/30",children:e.jsx("img",{src:h,alt:"Company logo",className:"max-h-[50px] max-w-[160px] object-contain","data-testid":"img-logo-preview"})}):e.jsx("div",{className:"border rounded-md p-4 bg-muted/30 text-muted-foreground text-sm flex items-center justify-center w-[160px] h-[50px]",children:"No logo"}),e.jsx("input",{ref:b,type:"file",accept:"image/*",onChange:N,className:"hidden","data-testid":"input-logo-file"}),e.jsxs(D,{type:"button",variant:"outline",size:"sm",onClick:()=>b.current?.click(),disabled:C,"data-testid":"button-upload-logo",children:[C?e.jsx(Ve,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(qi,{className:"h-4 w-4 mr-1"}),h?"Change Logo":"Upload Logo"]}),h&&e.jsxs(D,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(""),"data-testid":"button-remove-logo",children:[e.jsx(ts,{className:"h-4 w-4 mr-1"}),"Remove"]})]})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Heading Font"}),e.jsxs(lt,{value:g,onValueChange:x,children:[e.jsx(it,{"data-testid":"select-heading-font",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Serif"}),ob.filter(P=>P.category==="serif").map(P=>e.jsx(me,{value:P.name,children:e.jsx("span",{style:{fontFamily:`"${P.name}", serif`},children:P.name})},P.name)),e.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground mt-1",children:"Sans-Serif"}),ob.filter(P=>P.category==="sans-serif").map(P=>e.jsx(me,{value:P.name,children:e.jsx("span",{style:{fontFamily:`"${P.name}", sans-serif`},children:P.name})},P.name))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for titles and headings"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Body Font"}),e.jsxs(lt,{value:v,onValueChange:w,children:[e.jsx(it,{"data-testid":"select-body-font",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Sans-Serif"}),lb.filter(P=>P.category==="sans-serif").map(P=>e.jsx(me,{value:P.name,children:e.jsx("span",{style:{fontFamily:`"${P.name}", sans-serif`},children:P.name})},P.name)),e.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground mt-1",children:"Serif"}),lb.filter(P=>P.category==="serif").map(P=>e.jsx(me,{value:P.name,children:e.jsx("span",{style:{fontFamily:`"${P.name}", serif`},children:P.name})},P.name))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for body text and paragraphs"})]})]})]}),e.jsxs(D,{type:"submit",disabled:k.isPending,"data-testid":"button-save-client",children:[k.isPending?e.jsx(Ve,{className:"h-4 w-4 animate-spin mr-1"}):null,"Save Changes"]})]})})]})}var Yx="Switch",[gU]=En(Yx),[xU,vU]=gU(Yx),Lk=m.forwardRef((t,s)=>{const{__scopeSwitch:n,name:a,checked:o,defaultChecked:l,required:d,disabled:u,value:h="on",onCheckedChange:f,form:g,...x}
66=t,[v,w]=m.useState(null),C=At(s,T=>w(T)),j=m.useRef(!1),b=v?g||!!v.closest("form"):!0,[k=!1,N]=Ur({prop:o,defaultProp:l,onChange:f});return e.jsxs(xU,{scope:n,checked:k,disabled:u,children:[e.jsx(at.button,{type:"button",role:"switch","aria-checked":k,"aria-required":d,"data-state":Uk(k),"data-disabled":u?"":void 0,disabled:u,value:h,...x,ref:C,onClick:Ae(t.onClick,T=>{N(P=>!P),b&&(j.current=T.isPropagationStopped(),j.current||T.stopPropagation())})}),b&&e.jsx(yU,{control:v,bubbles:!j.current,name:a,value:h,checked:k,required:d,disabled:u,form:g,style:{transform:"translateX(-100%)"}})]})});Lk.displayName=Yx;var Fk="SwitchThumb",$k=m.forwardRef((t,s)=>{const{__scopeSwitch:n,...a}=t,o=vU(Fk,n);return e.jsx(at.span,{"data-state":Uk(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})});$k.displayName=Fk;var yU=t=>{const{control:s,checked:n,bubbles:a=!0,...o}=t,l=m.useRef(null),d=$x(n),u=Bg(s);return m.useEffect(()=>{const h=l.current,f=window.HTMLInputElement.prototype,x=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==n&&x){const v=new Event("click",{bubbles:a});x.call(h,n),h.dispatchEvent(v)}},[d,n,a]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:l,style:{...t.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function Uk(t){return t?"checked":"unchecked"}var zk=Lk,jU=$k;const As=m.forwardRef(({className:t,...s},n)=>e.jsx(zk,{className:Oe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...s,ref:n,children:e.jsx(jU,{className:Oe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));As.displayName=zk.displayName;function wU({kb:t,clientId:s}){const{toast:n}=dt(),[a,o]=m.useState(!1),[l,d]=m.useState(t.name),[u,h]=m.useState(t.description||""),[f,g]=m.useState(t.isPublic??!1);m.useEffect(()=>{a&&(d(t.name),h(t.description||""),g(t.isPublic??!1))},[a,t.name,t.description,t.isPublic]);const x=ye({mutationFn:async v=>ce("PATCH",`/api/knowledge-bases/${t.id}`,v),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/clients",s,"knowledge-bases"]}),de.invalidateQueries({queryKey:["/api/knowledge-bases",t.id]}),n({title:"Knowledge base updated"}),o(!1)}});return e.jsxs(St,{open:a,onOpenChange:o,children:[e.jsx(bs,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"icon",onClick:v=>v.stopPropagation(),"data-testid":`button-edit-kb-${t.id}`,children:e.jsx(Ia,{className:"h-4 w-4"})})}),e.jsxs(jt,{onClick:v=>v.stopPropagation(),children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Edit Knowledge Base"}),e.jsx(Gt,{children:"Update knowledge base settings."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-kb-name",children:"Name"}),e.jsx(fe,{id:"edit-kb-name",value:l,onChange:v=>d(v.target.value),placeholder:"Operations Manual","data-testid":"input-edit-kb-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-kb-description",children:"Description"}),e.jsx(ss,{id:"edit-kb-description",value:u,onChange:v=>h(v.target.value),placeholder:"Standard operating procedures for daily operations","data-testid":"input-edit-kb-description"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[f?e.jsx($n,{className:"h-4 w-4 text-primary"}):e.jsx(Pn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx(Z,{htmlFor:"edit-kb-public",className:"cursor-pointer",children:"Access"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f?"Visible to everyone":"Only visible to team members"})]})]}),e.jsx(As,{id:"edit-kb-public",checked:f,onCheckedChange:g,"data-testid":"switch-edit-kb-public"})]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(D,{onClick:()=>x.mutate({name:l,description:u,isPublic:f}),disabled:!l||x.isPending,"data-testid":"button-confirm-edit-kb",children:"Save Changes"})]})]})]})}function bU({kb:t,clientId:s,onSelect:n}){const{attributes:a,listeners:o,setNodeRef:l,transform:d,transition:u,isDragging:h}=ah({id:t.id}),f={transform:gi.Transform.toString(d),transition:u,opacity:h?.5:1};return e.jsx(ee,{ref:l,style:f,className:"border-border/50 hover-elevate cursor-pointer",onClick:n,"data-testid":`card-kb-${t.id}`,children:e.jsx(te,{className:"py-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{...a,...o,className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center cursor-grab active:cursor-grabbing flex-shrink-0",onClick:g=>g.stopPropagation(),children:e.jsx(Dm,{className:"h-4 w-4 text-primary"})}),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-medium truncate",children:t.name}),e.jsx(Ce,{variant:t.visibility==="public"||!t.visibility&&t.isPublic?"default":"secondary",className:"flex-shrink-0",children:t.visibility==="public"||!t.visibility&&t.isPublic?e.jsxs(e.Fragment,{children:[e.jsx($n,{className:"h-3 w-3 mr-1"})," Public"]}):e.jsxs(e.Fragment,{children:[e.jsx(Pn,{className:"h-3 w-3 mr-1"})," Private"]})})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5 line-clamp-1",children:t.description})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",onClick:g=>g.stopPropagation(),children:e.jsx(wU,{kb:t,clientId:s})})]})})})}function NU({clientId:t}){const{toast:s}=dt(),[n,a]=m.useState(!1),[o,l]=m.useState(""),[d,u]=m.useState(""),[h,f]=m.useState(!1),g=ye({mutationFn:async x=>ce("POST","/api/knowledge-bases",x),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/clients",t,"knowledge-bases"]}),s({title:"Knowledge base created"}),a(!1),l(""),u(""),f(!1)}});return e.jsxs(St,{open:n,onOpenChange:a,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{size:"sm","data-testid":"button-create-kb",children:[e.jsx(ds,{className:"h-4 w-4 mr-1"}),"Add Knowledge Base"]})}),e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Create Knowledge Base"}),e.jsx(Gt,{children:"Create a new knowledge base to organize procedures."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"kb-name",children:"Name"}),e.jsx(fe,{id:"kb-name",value:o,onChange:x=>l(x.target.value),placeholder:"Operations Manual","data-testid":"input-new-kb-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"kb-description",children:"Description"}),e.jsx(ss,{id:"kb-description",value:d,onChange:x=>u(x.target.value),placeholder:"Standard operating procedures for daily operations","data-testid":"input-new-kb-description"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[h?e.jsx($n,{className:"h-4 w-4 text-primary"}):e.jsx(Pn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx(Z,{htmlFor:"kb-public",className:"cursor-pointer",children:"Access"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h?"Visible to everyone":"Only visible to team members"})]})]}),e.jsx(As,{id:"kb-public",checked:h,onCheckedChange:f,"data-testid":"switch-new-kb-public"})]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(D,{onClick:()=>g.mutate({clientId:t,name:o,description:d,isPublic:h}),disabled:!o||g.isPending,"data-testid":"button-confirm-create-kb",children:"Create"})]})]})]})}function SU({knowledgeBaseId:t}){const{toast:s}=dt(),[n,a]=m.useState(!1),[o,l]=m.useState(""),[d,u]=m.useState(!0),h=ye({mutationFn:async f=>
66ce("POST","/api/categories",f),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/knowledge-bases",t,"categories"]}),s({title:"Category created"}),a(!1),l(""),u(!0)}});return e.jsxs(St,{open:n,onOpenChange:a,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{size:"sm",variant:"outline","data-testid":"button-create-category",children:[e.jsx(ds,{className:"h-4 w-4 mr-1"}),"Add"]})}),e.jsxs(jt,{children:[e.jsx(wt,{children:e.jsx(bt,{children:"Create Category"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"category-name",children:"Category Name"}),e.jsx(fe,{id:"category-name",value:o,onChange:f=>l(f.target.value),placeholder:"Onboarding","data-testid":"input-new-category-name"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d?e.jsx($n,{className:"h-4 w-4 text-primary"}):e.jsx(Pn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx(Z,{htmlFor:"category-public",className:"cursor-pointer",children:"Access"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d?"Visible to everyone":"Only visible to team members"})]})]}),e.jsx(As,{id:"category-public",checked:d,onCheckedChange:u,"data-testid":"switch-new-category-public"})]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(D,{onClick:()=>h.mutate({knowledgeBaseId:t,name:o,order:0,isPublic:d}),disabled:!o||h.isPending,"data-testid":"button-confirm-create-category",children:"Create"})]})]})]})}function CU({category:t,knowledgeBaseId:s}){const{toast:n}=dt(),[a,o]=m.useState(!1),[l,d]=m.useState(t.name),[u,h]=m.useState(t.isPublic??!0);m.useEffect(()=>{a&&(d(t.name),h(t.isPublic??!0))},[a,t.name,t.isPublic]);const f=ye({mutationFn:async g=>ce("PATCH",`/api/categories/${t.id}`,g),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/knowledge-bases",s,"categories"]}),n({title:"Category updated"}),o(!1)}});return e.jsxs(St,{open:a,onOpenChange:o,children:[e.jsx(bs,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"icon","data-testid":`button-edit-category-${t.id}`,children:e.jsx(Ia,{className:"h-4 w-4"})})}),e.jsxs(jt,{children:[e.jsx(wt,{children:e.jsx(bt,{children:"Edit Category"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-category-name",children:"Category Name"}),e.jsx(fe,{id:"edit-category-name",value:l,onChange:g=>d(g.target.value),placeholder:"Onboarding","data-testid":"input-edit-category-name"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u?e.jsx($n,{className:"h-4 w-4 text-primary"}):e.jsx(Pn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx(Z,{htmlFor:"edit-category-public",className:"cursor-pointer",children:"Access"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u?"Visible to everyone":"Only visible to team members"})]})]}),e.jsx(As,{id:"edit-category-public",checked:u,onCheckedChange:h,"data-testid":"switch-edit-category-public"})]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(D,{onClick:()=>f.mutate({name:l,isPublic:u}),disabled:!l||f.isPending,"data-testid":"button-confirm-edit-category",children:"Save Changes"})]})]})]})}function kU({categories:t,onEditProcedure:s}){const{toast:n}=dt(),[a,o]=m.useState(!1),[l,d]=m.useState(""),[u,h]=m.useState(""),[f,g]=m.useState(!0),x=ye({mutationFn:async v=>(await ce("POST","/api/procedures",v)).json(),onSuccess:v=>{de.invalidateQueries({queryKey:["/api/procedures"]}),n({title:"Procedure created"});const w=v?.id;o(!1),d(""),h(""),g(!0),s&&w&&setTimeout(()=>s(w),0)}});return e.jsxs(St,{open:a,onOpenChange:o,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{size:"sm",variant:"outline","data-testid":"button-create-procedure",children:[e.jsx(ds,{className:"h-4 w-4 mr-1"}),"Add"]})}),e.jsxs(jt,{children:[e.jsx(wt,{children:e.jsx(bt,{children:"Create Procedure"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"procedure-title",children:"Title"}
66),e.jsx(fe,{id:"procedure-title",value:l,onChange:v=>d(v.target.value),placeholder:"New Employee Onboarding","data-testid":"input-new-procedure-title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Category"}),e.jsxs(lt,{value:u,onValueChange:h,children:[e.jsx(it,{"data-testid":"select-new-procedure-category",children:e.jsx(ct,{placeholder:"Select a category"})}),e.jsx(ot,{children:t.map(v=>e.jsx(me,{value:v.id,children:v.name},v.id))})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[f?e.jsx($n,{className:"h-4 w-4 text-primary"}):e.jsx(Pn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx(Z,{htmlFor:"procedure-public",className:"cursor-pointer",children:"Access"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f?"Visible to everyone":"Only visible to team members"})]})]}),e.jsx(As,{id:"procedure-public",checked:f,onCheckedChange:g,"data-testid":"switch-new-procedure-public"})]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(D,{onClick:()=>x.mutate({categoryId:u,title:l,status:"draft",order:0,isPublic:f,version:1,contentType:"procedure"}),disabled:!l||!u||x.isPending,"data-testid":"button-confirm-create-procedure",children:"Create"})]})]})]})}function PU({templateId:t,templateName:s,onDelete:n,isDeleting:a}){const[o,l]=m.useState(!1);return e.jsxs(St,{open:o,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"icon","data-testid":`button-delete-template-${t}`,children:e.jsx(ts,{className:"h-4 w-4 text-destructive"})})}),e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Delete Template"}),e.jsxs(Gt,{children:['Are you sure you want to delete "',s,'"? This action cannot be undone.']})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>l(!1),"data-testid":"button-cancel-delete-template",children:"Cancel"}),e.jsx(D,{variant:"destructive",onClick:()=>{n(),l(!1)},disabled:a,"data-testid":"button-confirm-delete-template",children:a?"Deleting...":"Delete"})]})]})]})}const TU=["Analyzing your procedure...","Crafting detailed steps...","Structuring the workflow...","Refining instructions...","Polishing the details...","Almost there..."],EU=["Understanding your topic...","Researching best practices...","Building the procedure...","Writing clear instructions...","Adding finishing touches...","Almost there..."],_U=["Reading your content...","Enhancing clarity...","Refining the language...","Polishing the result...","Almost done..."],RU=["Processing your recording...","Transcribing your voice...","Cleaning up the text...","Formatting the result...","Almost ready..."],AU={"generate-steps":TU,"generate-procedure":EU,improve:_U,"voice-processing":RU},IU=2800;function Cl(t,s="generate-steps"){const[n,a]=m.useState(0),o=m.useRef(null),l=AU[s];return m.useEffect(()=>(t?(a(0),o.current=setInterval(()=>{a(d=>{const u=d+1;return u>=l.length?l.length-1:u})},IU)):(a(0),o.current&&(clearInterval(o.current),o.current=null)),()=>{o.current&&(clearInterval(o.current),o.current=null)}),[t,l.length]),l[n]}function cb({message:t}){return e.jsxs("div",{className:"flex flex-col items-center gap-3 py-4","data-testid":"ai-progress-indicator",children:[e.jsxs("div",{className:"relative flex items-center justify-center",children:[e.jsx("div",{className:"absolute h-10 w-10 rounded-full border-2 border-primary/20 animate-ping"}),e.jsx("div",{className:"relative h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(gs,{className:"h-5 w-5 text-primary animate-pulse"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground animate-pulse font-medium","data-testid":"text-ai-status",children:t}),e.jsx("div",{className:"w-full max-w-48 h-1 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary/60 rounded-full animate-[shimmer_2s_ease-in-out_infinite]",style:{background:"linear-gradient(90deg, transparent 0%, hsl(var(--primary) / 0.6) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"shimmer 2s ease-in-out infinite"}})}),e.jsx("style",{children:`
67        @keyframes shimmer {
68          0% { background-position: 200% 0; }
69          100% { background-position: -200% 0; }
70        }
71      `})]})}function DU({title:t,description:s,onGenerateSteps:n,clientId:a}){const{toast:o}=dt(),[l,d]=m.useState(!1),[u,h]=m.useState(""),[f,g]=m.useState("generate-steps"),x=ye({mutationFn:async()=>(await ce("POST","/api/ai/generate-steps",{title:t,description:s,clientId:a})).json(),onSuccess:b=>{n(b.steps),o({title:"Steps generated successfully"}),d(!1)},onError:b=>{b.message.includes("ai_upgrade_required")?o({title:"Upgrade Required",description:"AI features require the Creator plan. The client must upgrade to use AI tools.",variant:"destructive"}):o({title:"Failed to generate steps",description:b.message,variant:"destructive"})}}),v=ye({mutationFn:async()=>(await ce("POST","/api/ai/generate-procedure",{topic:u,clientId:a})).json(),onSuccess:b=>{n(b.steps),o({title:"Procedure generated successfully",description:`Generated "${b.title}" with ${b.steps.length} steps`}),d(!1),h("")},onError:b=>{b.message.includes("ai_upgrade_required")?o({title:"Upgrade Required",description:"AI features require the Creator plan. The client must upgrade to use AI tools.",variant:"destructive"}):o({title:"Failed to generate procedure",description:b.message,variant:"destructive"})}}),w=x.isPending||v.isPending,C=v.isPending?"generate-procedure":"generate-steps",j=Cl(w,C);return e.jsxs(St,{open:l,onOpenChange:d,children:[e.jsx(ee,{className:"border-border/50 bg-primary/5",children:e.jsxs(te,{className:"p-4 flex items-center gap-3",children:[e.jsx(gs,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"AI Assistant"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Let AI help you write and improve this procedure"})]}),e.jsx(bs,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm","data-testid":"button-ai-assist",children:[e.jsx(Ig,{className:"h-4 w-4 mr-1"}),"Generate with AI"]})})]})}),e.jsxs(jt,{className:"sm:max-w-md",children:[e.jsxs(wt,{children:[e.jsxs(bt,{className:"flex items-center gap-2",children:[e.jsx(gs,{className:"h-5 w-5 text-primary"}),"AI Assistant"]}),e.jsx(Gt,{children:"Use AI to generate steps or a complete procedure"})]}),e.jsxs(Ma,{value:f,onValueChange:b=>g(b),className:"w-full",children:[e.jsxs(ha,{className:"grid w-full grid-cols-2",children:[e.jsxs(ls,{value:"generate-steps",disabled:w,"data-testid":"tab-ai-generate-steps",children:[e.jsx(jN,{className:"h-4 w-4 mr-1"}),"Generate Steps"]}),e.jsxs(ls,{value:"generate-procedure",disabled:w,"data-testid":"tab-ai-generate-procedure",children:[e.jsx(Pt,{className:"h-4 w-4 mr-1"}),"From Topic"]})]}),e.jsx(Ss,{value:"generate-steps",className:"space-y-4 pt-4",children:x.isPending?e.jsx(cb,{message:j}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate steps based on the current procedure title and description."}),t?e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50",children:[e.jsx("p",{className:"text-sm font-medium",children:t}),s&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s})]}):e.jsx("p",{className:"text-sm text-destructive",children:"Please enter a procedure title first."})]}),e.jsxs(D,{onClick:()=>x.mutate(),disabled:!t||w,className:"w-full","data-testid":"button-ai-generate-steps",children:[e.jsx(gs,{className:"h-4 w-4 mr-2"}),"Generate Steps"]})]})}),e.jsx(Ss,{value:"generate-procedure",className:"space-y-4 pt-4",children:v.isPending?e.jsx(cb,{message:j}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"ai-topic",children:"What procedure do you want to create?"}),e.jsx(ss,{id:"ai-topic",value:u,onChange:b=>h(b.target.value),placeholder:"e.g., How to onboard a new customer, Processing refunds, Setting up a new employee...",rows:3,"data-testid":"input-ai-topic"})]}),e.jsxs(D,{onClick:()=>v.mutate(),disabled:!u||w,className:"w-full","data-testid":"button-ai-generate-procedure",children:[e.jsx(gs,{className:"h-4 w-4 mr-2"}),"Generate Procedure"]})]})})]})]})]})}function OU({knowledgeBaseId:t,clientSlug:s,categories:n,procedures:a,onBack:o,onEditProcedure:l}){const{data:d}=je({queryKey:["/api/knowledge-bases",t]}),u=s&&d?.slug?`/${s}/${d.slug}`:null;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(D,{variant:"ghost",size:"sm",onClick:o,"data-testid":"button-back-to-kbs",children:[e.jsx(kn,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-medium text-lg",children:d?.name}),d?.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]}),u&&e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:e.jsxs(D,{variant:"outline",size:"sm","data-testid":"button-view-kb",children:[e.jsx(Sn,{className:"h-4 w-4 mr-1"}),"View Knowledge Base"]})})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs(ee,{className:"border-border/50",children:[e.jsxs(qe,{className:"flex flex-row items-center justify-between space-y-0 gap-4 pb-4",children:[e.jsxs("div",{children:[e.jsx(tt,{className:"text-base",children:"Categories"}),e.jsx(Tt,{children:"Organize your procedures"})]}),e.jsx(SU,{knowledgeBaseId:t})]}),e.jsx(te,{className:"space-y-2",children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No categories yet"}):n.map(h=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fr,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:h.name}),e.jsx(Ce,{variant:h.isPublic?"default":"secondary",className:"text-xs",children:h.isPublic?e.jsx($n,{className:"h-3 w-3"}):e.jsx(Pn,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:"secondary",className:"text-xs",children:a.filter(f=>f.categoryId===h.id).length}),e.jsx(CU,{category:h,knowledgeBaseId:t})]})]}
71,h.id))})]}),e.jsxs(ee,{className:"border-border/50",children:[e.jsxs(qe,{className:"flex flex-row items-center justify-between space-y-0 gap-4 pb-4",children:[e.jsxs("div",{children:[e.jsx(tt,{className:"text-base",children:"Procedures"}),e.jsx(Tt,{children:"Document your processes"})]}),n.length>0&&e.jsx(kU,{categories:n,onEditProcedure:l})]}),e.jsx(te,{className:"space-y-2",children:a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:n.length===0?"Create a category first":"No procedures yet"}):a.map(h=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-border/50 hover-elevate cursor-pointer",onClick:()=>l(h.id),"data-testid":`card-procedure-${h.id}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pt,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:h.title}),h.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:h.description})]})]}),e.jsx(Ce,{variant:h.status==="published"?"default":"secondary",children:h.status})]},h.id))})]})]})]})}function MU({selectedClientSlug:t,onSelectClient:s,selectedKnowledgeBase:n,onSelectKnowledgeBase:a,onEditProcedure:o,activeTab:l,onTabChange:d}){const[u,h]=m.useState(""),[f,g]=m.useState("all"),[x,v]=m.useState("companies"),[w,C]=m.useState("contacts"),j=l||w,b=A=>{d?d(A):C(A)},{user:k}=Da(),N=k?.role==="admin"||k?.role==="super_admin",{data:T,isLoading:P}=je({queryKey:["/api/client-stats"]}),{data:I,isLoading:O}=je({queryKey:["/api/admin/all-contacts"],queryFn:async()=>{const A=await fetch("/api/admin/all-contacts");if(!A.ok)throw new Error("Failed to fetch contacts");return A.json()},enabled:x==="contacts"}),R=I?.filter(A=>{if(!u)return!0;const W=u.toLowerCase(),U=A.name?.toLowerCase().includes(W),Q=A.email?.toLowerCase().includes(W),we=A.clientName?.toLowerCase().includes(W);return U||Q||we})||[],{data:F}=je({queryKey:["/api/clients/by-slug",t],queryFn:async()=>{const A=await fetch(`/api/clients/by-slug/${t}`);if(!A.ok)throw new Error("Client not found");return A.json()},enabled:!!t}),{data:M}=je({queryKey:["/api/clients",F?.id,"knowledge-bases"],enabled:!!F?.id}),{data:z}=je({queryKey:["/api/knowledge-bases",n,"categories"],enabled:!!n}),{data:H}=je({queryKey:["/api/knowledge-bases",n,"procedures"],enabled:!!n}),{data:V}=je({queryKey:["/api/clients",F?.id,"all-content"],queryFn:async()=>{const A=await fetch(`/api/clients/${F?.id}/all-content`);if(!A.ok)throw new Error("Failed to fetch client content");return A.json()},enabled:!!F?.id}),B=V?.filter(A=>A.contentType==="procedure")||[],Y=V?.filter(A=>A.contentType==="overview")||[],L=Ix(al(md),al(ud,{coordinateGetter:Mx})),K=ye({mutationFn:async A=>ce("PATCH",`/api/clients/${F?.id}/knowledge-bases/reorder`,{orderedIds:A}),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/clients",F?.id,"knowledge-bases"]})}}),_=A=>{const{active:W,over:U}=A;if(U&&W.id!==U.id&&M){const Q=M.findIndex(Ie=>Ie.id===W.id),we=M.findIndex(Ie=>Ie.id===U.id),_e=il(M,Q,we);K.mutate(_e.map(Ie=>Ie.id))}},$=T?.clients.filter(A=>{if(f==="active"&&A.status!=="active"||f==="inactive"&&A.status==="active")return!1;if(!u)return!0;const W=u.toLowerCase(),U=A.name.toLowerCase().includes(W),Q=A.slug.toLowerCase().includes(W),we=A.searchableUserNames.some(_e=>_e.toLowerCase().includes(W));return U||Q||we})||[];return t?e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(D,{variant:"ghost",size:"sm",onClick:()=>{s(null),a(null)},"data-testid":"button-back-to-clients",children:[e.jsx(kn,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-serif text-2xl font-normal tracking-tight",children:F?.name||"Loading..."}),F?.slug&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["/",F.slug]})]})]}),e.jsxs(Ma,{value:j,onValueChange:A=>{b(A),A==="knowledge-bases"&&a(null)},className:"space-y-6",children:[e.jsxs(ha,{className:"flex-wrap",children:[e.jsxs(ls,{value:"contacts","data-testid":"tab-contacts",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Contacts"]}),e.jsxs(ls,{value:"knowledge-bases","data-testid":"tab-knowledge-bases",onClick:()=>a(null),children:[e.jsx(cs,{className:"h-4 w-4 mr-1"}),"Knowledge Bases ",M?.length?`(${M.length})`:""]}),e.jsxs(ls,{value:"all-content","data-testid":"tab-all-content",children:[e.jsx(Pa,{className:"h-4 w-4 mr-1"}),"All Content"]}),e.jsxs(ls,{value:"emails","data-testid":"tab-emails",children:[e.jsx(Ta,{className:"h-4 w-4 mr-1"}),"Emails"]}
71),e.jsxs(ls,{value:"settings","data-testid":"tab-settings",children:[e.jsx(Jc,{className:"h-4 w-4 mr-1"}),"Settings"]}),N&&e.jsxs(ls,{value:"ai-usage","data-testid":"tab-ai-usage",children:[e.jsx(qo,{className:"h-4 w-4 mr-1"}),"AI Usage"]}),N&&e.jsxs(ls,{value:"subscription","data-testid":"tab-subscription",children:[e.jsx(di,{className:"h-4 w-4 mr-1"}),"Subscription"]})]}),e.jsx(Ss,{value:"contacts",className:"space-y-6",children:e.jsx(hU,{clientId:F?.id||""})}),e.jsx(Ss,{value:"knowledge-bases",className:"space-y-6",children:n?e.jsx(OU,{knowledgeBaseId:n,clientSlug:F?.slug,categories:z||[],procedures:H||[],onBack:()=>a(null),onEditProcedure:o}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-medium text-lg",children:"Knowledge Bases"}),e.jsx(NU,{clientId:F?.id||""})]}),M?.length===0?e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-8 text-center",children:[e.jsx(cs,{className:"h-10 w-10 text-muted-foreground/50 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No knowledge bases yet."})]})}):e.jsx(om,{sensors:L,collisionDetection:am,onDragEnd:_,children:e.jsx(cm,{items:M?.map(A=>A.id)||[],strategy:lm,children:e.jsx("div",{className:"flex flex-col gap-3",children:M?.map(A=>e.jsx(bU,{kb:A,clientId:F?.id||"",onSelect:()=>a(A.id)},A.id))})})})]})}),e.jsx(Ss,{value:"all-content",className:"space-y-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("h2",{className:"font-medium text-lg",children:"All Content"}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pt,{className:"h-4 w-4"}),B.length," Procedures"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ln,{className:"h-4 w-4"}),Y.length," Overviews"]})]})]}),Y.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Overviews"}),e.jsx("div",{className:"space-y-2",children:Y.map(A=>e.jsx(ee,{className:"border-border/50 hover-elevate cursor-pointer",onClick:()=>o(A.id),children:e.jsxs(te,{className:"p-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(ln,{className:"h-4 w-4 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:A.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:A.knowledgeBaseName})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:A.status==="published"?"default":"secondary",children:A.status}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"})]})]})},A.id))})]}),B.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Procedures"}),e.jsx("div",{className:"space-y-2",children:B.map(A=>e.jsx(ee,{className:"border-border/50 hover-elevate cursor-pointer",onClick:()=>o(A.id),children:e.jsxs(te,{className:"p-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Pt,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:A.title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[A.knowledgeBaseName,A.categoryName&&` / ${A.categoryName}`]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:A.status==="published"?"default":"secondary",children:A.status}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"})]})]})},A.id))})]}),B.length===0&&Y.length===0&&e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-8 text-center",children:[e.jsx(Pt,{className:"h-10 w-10 text-muted-foreground
71/50 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No content yet. Create a knowledge base and add procedures."})]})})]})}),e.jsx(Ss,{value:"emails",className:"space-y-6",children:e.jsx(fU,{clientId:F?.id||""})}),e.jsx(Ss,{value:"settings",className:"space-y-6",children:e.jsx(pU,{client:F})}),e.jsx(Ss,{value:"ai-usage",className:"space-y-6",children:e.jsx(X6,{clientId:F?.id||""})}),e.jsx(Ss,{value:"subscription",className:"space-y-6",children:e.jsx(Z6,{clientId:F?.id||""})})]})]}):e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-serif text-2xl md:text-3xl font-normal tracking-tight",children:"Clients"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage your client organizations"})]}),e.jsx(Yp,{})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Qn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-semibold",children:T?.totals.totalClients??0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Clients"})]})]})}),e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-green-500/10 flex items-center justify-center",children:e.jsx(Sr,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-semibold",children:T?.totals.activeClients??0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active Clients"})]})]})}),e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(Pt,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-semibold",children:T?.totals.totalProcedures??0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Procedures"})]})]})}),e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/10 flex items-center justify-center",children:e.jsx(Bs,{className:"h-5 w-5 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-semibold",children:T?.totals.totalClientUsers??0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Client Users"})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center bg-muted rounded-lg p-1",children:[e.jsxs(D,{variant:x==="companies"?"default":"ghost",size:"sm",onClick:()=>v("companies"),"data-testid":"button-view-companies",children:[e.jsx(Qn,{className:"h-4 w-4 mr-1"}),"Companies"]}),e.jsxs(D,{variant:x==="contacts"?"default":"ghost",size:"sm",onClick:()=>v("contacts"),"data-testid":"button-view-contacts",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Contacts"]})]}),x==="companies"&&e.jsxs(lt,{value:f,onValueChange:A=>g(A),children:[e.jsx(it,{className:"w-[140px]","data-testid":"select-status-filter",children:e.jsx(ct,{placeholder:"Status"})}),e.jsxs(ot,{children:[e.jsx(me,{value:"all","data-testid":"select-status-all",children:"All Accounts"}),e.jsx(me,{value:"active","data-testid":"select-status-active",children:"Active"}),e.jsx(me,{value:"inactive","data-testid":"select-status-inactive",children:"Inactive"})]})]}),e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(Mm,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(fe,{placeholder:x==="companies"?"Search by company name, domain, or user name...":"Search contacts...",value:u,onChange:A=>h(A.target.value),className:"pl-10","data-testid":"input-search-clients"})]})]}),e.jsx("div",{className:"space-y-2",children:x==="companies"?e.jsx(e.Fragment,{children:P?[1,2,3,4,5].map(A=>e.jsx(be,{className:"h-16"},A)):$.length===0?e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-12 text-center",children:[e.jsx(Qn,{className:"h-12 w-12 text-muted-foreground
71/50 mx-auto mb-4"}),e.jsx("h3",{className:"font-medium text-lg mb-2",children:u||f!=="all"?`No ${f==="active"?"active ":f==="inactive"?"inactive ":""}companies match your criteria`:"No companies yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:u||f!=="all"?"Try adjusting your search or filter.":"Create your first client to start documenting their procedures."}),!u&&f==="all"&&e.jsx(Yp,{})]})}):$.map(A=>e.jsx(ee,{className:"border-border/50 hover-elevate cursor-pointer",onClick:()=>s(A.slug),"data-testid":`card-client-${A.id}`,children:e.jsxs(te,{className:"p-4 flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Qn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:A.name}),e.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:["/",A.slug]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",title:"Users",children:[e.jsx(Bs,{className:"h-4 w-4"}),e.jsx("span",{children:A.teamHeadCount})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",title:"Knowledge Bases",children:[e.jsx(cs,{className:"h-4 w-4"}),e.jsx("span",{children:A.knowledgeBaseCount})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",title:"Overviews",children:[e.jsx(ln,{className:"h-4 w-4"}),e.jsx("span",{children:A.overviewCount})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",title:"Procedures",children:[e.jsx(Pt,{className:"h-4 w-4"}),e.jsx("span",{children:A.procedureCount})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",title:"Categories",children:[e.jsx(Pa,{className:"h-4 w-4"}),e.jsx("span",{children:A.categoryCount})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",title:"Last active",children:[e.jsx(qo,{className:"h-4 w-4"}),e.jsx("span",{children:A.lastActiveAt?`${A.daysSinceLastActivity===0?"Today":A.daysSinceLastActivity===1?"1 day ago":`${A.daysSinceLastActivity} days ago`}`:"Never"})]}),e.jsx(Ce,{variant:A.status==="active"?"default":A.status==="canceling"?"outline":"secondary",children:A.status}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"})]})]})},A.id))}):e.jsx(e.Fragment,{children:O?[1,2,3,4,5].map(A=>e.jsx(be,{className:"h-16"},A)):R.length===0?e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-12 text-center",children:[e.jsx(Bs,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("h3",{className:"font-medium text-lg mb-2",children:u?"No contacts match your search":"No contacts yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:u?"Try adjusting your search terms.":"Add contacts to your client organizations to see them here."})]})}):R.map(A=>e.jsx(ee,{className:"border-border/50 hover-elevate cursor-pointer",onClick:()=>A.clientSlug&&s(A.clientSlug),"data-testid":`card-contact-${A.id}`,children:e.jsxs(te,{className:"p-4 flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/10 flex items-center justify-center shrink-0",children:e.jsx(Bs,{className:"h-5 w-5 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:A.name||"Unnamed"}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:A.email})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",title:"Company",children:[e.jsx(Qn,{className:"h-4 w-4"}),e.jsx("span",{children:A.clientName||"No company"})]}),e.jsx(Ce,{variant:A.status==="active"?"default":"secondary",children:A.status}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"})]})]})},A.id))})})]})}function LU({onEditProcedure:t}){const{data:s,isLoading:n}=je({queryKey:["/api/procedures"]});return e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-serif text-2xl md:text-3xl font-normal tracking-tight",children:"All Procedures"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"View and manage all procedures across clients"})]}),e.jsx("div",{className:"space-y-2",children:n?[1,2,3,4,5].map(a=>e.jsx(be,{className:"h-16"},a)):s?.length===0?e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-12 text-center",children:[e.jsx(Pt,{className:"h-12 w-12 text-muted-foreground
71/50 mx-auto mb-4"}),e.jsx("h3",{className:"font-medium text-lg mb-2",children:"No procedures yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Create a client and knowledge base first, then add procedures."})]})}):s?.map(a=>e.jsx(ee,{className:"border-border/50 hover-elevate cursor-pointer",onClick:()=>t(a.id),"data-testid":`card-procedure-all-${a.id}`,children:e.jsxs(te,{className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Pt,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium",children:a.title}),a.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:a.description})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Ce,{variant:a.status==="published"?"default":"secondary",children:a.status}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"})]})]})},a.id))})]})}function FU({onEditProcedure:t}){const{data:s,isLoading:n}=je({queryKey:["/api/procedures"],select:a=>a.filter(o=>o.contentType==="overview")});return e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-serif text-2xl md:text-3xl font-normal tracking-tight",children:"All Overviews"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"View and manage all overviews across clients"})]}),e.jsx("div",{className:"space-y-2",children:n?[1,2,3,4,5].map(a=>e.jsx(be,{className:"h-16"},a)):s?.length===0?e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-12 text-center",children:[e.jsx(ln,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("h3",{className:"font-medium text-lg mb-2",children:"No overviews yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Overviews are training videos and context documents. Create them from the client portal."})]})}):s?.map(a=>e.jsx(ee,{className:"border-border/50 hover-elevate cursor-pointer",onClick:()=>t(a.id),"data-testid":`card-overview-all-${a.id}`,children:e.jsxs(te,{className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(ln,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium",children:a.title}),a.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:a.description})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Ce,{variant:a.status==="published"?"default":"secondary",children:a.status}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"})]})]})},a.id))})]})}function fg({open:t,onOpenChange:s,type:n,onMediaSelected:a}){const{toast:o}=dt(),[l,d]=m.useState(!1),[u,h]=m.useState(""),[f,g]=m.useState(!1),[x,v]=m.useState(null),[w,C]=m.useState(0),[j,b]=m.useState(null),k=m.useRef(null),N=m.useRef(null),T=m.useRef(null),P=m.useRef(null),I=m.useRef([]);m.useEffect(()=>()=>{P.current&&clearInterval(P.current),T.current&&T.current.getTracks().forEach(L=>L.stop()),j&&URL.revokeObjectURL(j)},[j]);const O=async L=>{d(!0);try{const _=L.type.startsWith("video/")?"video":"image",$=await fetch("/api/uploads/request-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:L.name,size:L.size,contentType:L.type,mediaType:_})});if(!$.ok)throw new Error("Failed to get upload URL");const{uploadURL:A,objectPath:W}=await $.json();if(!(await fetch(A,{method:"PUT",body:L,headers:{"Content-Type":L.type}})).ok)throw new Error("Failed to upload file");a(W,n==="image"?"image":"video"),o({title:`${n==="image"?"Image":"Video"} uploaded successfully`}),s(!1)}catch(K){o({title:"Upload failed",description:K instanceof Error?K.message:"Unknown error",variant:"destructive"})}finally{d(!1)}},R=L=>{const K=L.target.files?.[0];K&&O(K)},F=L=>{const K=L.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]+)/);if(K)return{embedUrl:`https://www.youtube.com/embed/${K[1]}`,platform:"youtube"};const _=L.match(/(?:loom\.com\/share\/|loom\.com\/embed\/)([a-zA-Z0-9]+)/);if(_)return{embedUrl:`https://www.loom.com/embed/${_[1]}`,platform:"loom"};const $=L.match(/(?:vimeo\.com\/)(\d+)/);return $?{embedUrl:`https://player.vimeo.com/video/${$[1]}`,platform:"vimeo"}:null},M=()=>{const L=F(u);L?(a(L.embedUrl,`embed-${L.platform}`),o({title:"Video embedded successfully"}),s(!1),h("")):o({title:"Invalid URL",description:"Please enter a valid YouTube, Loom, or Vimeo URL",variant:"destructive"})},z=async()=>{try{const L=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},audio:!0});let K=null;try{K=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{console.log("Microphone not available, using system audio only")}const _=[...L.getTracks()];
71K&&K.getAudioTracks().forEach(U=>_.push(U));const $=new MediaStream(_);T.current=$;const A=MediaRecorder.isTypeSupported("video/mp4")?"video/mp4":MediaRecorder.isTypeSupported("video/mp4;codecs=avc1")?"video/mp4;codecs=avc1":"video/mp4",W=new MediaRecorder($,{mimeType:A});I.current=[],W.ondataavailable=U=>{U.data.size>0&&I.current.push(U.data)},W.onstop=()=>{const U=new Blob(I.current,{type:A});v(U),b(URL.createObjectURL(U)),g(!1),P.current&&clearInterval(P.current)},L.getVideoTracks()[0].onended=()=>{N.current?.state==="recording"&&H()},N.current=W,W.start(1e3),g(!0),C(0),P.current=setInterval(()=>{C(U=>U+1)},1e3)}catch(L){console.error("Recording error:",L),o({title:"Recording failed",description:L instanceof Error?L.message:"Could not start screen recording",variant:"destructive"})}},H=()=>{N.current&&N.current.state==="recording"&&N.current.stop(),T.current&&T.current.getTracks().forEach(L=>L.stop())},V=async()=>{if(x){d(!0);try{const L=`recording-${Date.now()}.mp4`,K=new File([x],L,{type:x.type});await O(K),v(null),j&&(URL.revokeObjectURL(j),b(null)),C(0)}catch(L){console.error("Upload error:",L)}finally{d(!1)}}},B=()=>{v(null),j&&(URL.revokeObjectURL(j),b(null)),C(0)},Y=L=>{const K=Math.floor(L/60),_=L%60;return`${K}:${_.toString().padStart(2,"0")}`};return e.jsx(St,{open:t,onOpenChange:s,children:e.jsxs(jt,{className:"sm:max-w-md",children:[e.jsxs(wt,{children:[e.jsxs(bt,{className:"flex items-center gap-2",children:[n==="image"?e.jsx(qi,{className:"h-5 w-5"}):e.jsx(lr,{className:"h-5 w-5"}),"Add ",n==="image"?"Image":"Video"]}),e.jsx(Gt,{children:n==="image"?"Upload an image to add to this step":"Upload, embed, or record a video for this step"})]}),n==="image"?e.jsxs("div",{className:"space-y-4",children:[e.jsx("input",{ref:k,type:"file",accept:"image/*",onChange:R,className:"hidden","data-testid":"input-image-file"}),e.jsx(D,{onClick:()=>k.current?.click(),className:"w-full",disabled:l,"data-testid":"button-upload-image",children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ou,{className:"h-4 w-4 mr-2"}),"Choose Image"]})})]}):e.jsxs(Ma,{defaultValue:"upload",className:"w-full",children:[e.jsxs(ha,{className:"grid w-full grid-cols-3",children:[e.jsx(ls,{value:"upload","data-testid":"tab-video-upload",children:"Upload"}),e.jsx(ls,{value:"embed","data-testid":"tab-video-embed",children:"Embed URL"}),e.jsx(ls,{value:"record","data-testid":"tab-video-record",children:"Record"})]}),e.jsxs(Ss,{value:"upload",className:"space-y-4",children:[e.jsx("input",{ref:k,type:"file",accept:"video/*",onChange:R,className:"hidden","data-testid":"input-video-file"}),e.jsx(D,{onClick:()=>k.current?.click(),className:"w-full",disabled:l,"data-testid":"button-upload-video",children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ou,{className:"h-4 w-4 mr-2"}),"Choose Video File"]})})]}),e.jsxs(Ss,{value:"embed",className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"embed-url",children:"Video URL"}),e.jsx(fe,{id:"embed-url",placeholder:"Paste YouTube, Loom, or Vimeo URL...",value:u,onChange:L=>h(L.target.value),"data-testid":"input-embed-url"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supports YouTube, Loom, and Vimeo links"})]}),e.jsxs(D,{onClick:M,className:"w-full",disabled:!u.trim(),"data-testid":"button-embed-video",children:[e.jsx(dE,{className:"h-4 w-4 mr-2"}),"Embed Video"]})]}),e.jsx(Ss,{value:"record",className:"space-y-4",children:x?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"aspect-video bg-muted rounded-md overflow-hidden",children:e.jsx("video",{src:j||void 0,controls:!0,playsInline:!0,preload:"metadata",className:"w-full h-full object-contain","data-testid":"video-preview"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(D,{onClick:B,variant:"outline",className:"flex-1",disabled:l,"data-testid":"button-discard-recording",children:[e.jsx(Zn,{className:"h-4 w-4 mr-2"}),"Discard"]}),e.jsx(D,{onClick:V,className:"flex-1",disabled:l,"data-testid":"button-save-recording",children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ou,{className:"h-4 w-4 mr-2"}),"Save Recording"]})})]})]}):e.jsx(ee,{children:e.jsx(te,{className:"pt-6 text-center",children:f?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(Vu,{className:"h-3 w-3 text-destructive animate-pulse fill-destructive"}),e.jsx("span",{className:"text-lg font-mono",children:Y(w)})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Recording screen..."}),e.jsxs(D,{onClick:H,variant:"destructive","data-testid":"button-stop-recording",children:[e.jsx(Pc,{className:"h-4 w-4 mr-2"}),"Stop Recording"]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx(lr,{className:"h-12 w-12 mx-auto text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Screen Recording"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Record your screen with audio"})]}),e.jsxs(D,{onClick:z,"data-testid":"button-start-recording",children:[e.jsx(Vu,{className:"h-4 w-4 mr-2 fill-destructive text-destructive"}),"Start Recording"]})]})})})})]})]})})}function wm({mediaUrl:t,mediaType:s,onRemove:n}){const[a,o]=m.useState(!1);if(!t||!s)return null;const l=s?.startsWith("embed-"),d=s==="image",u=s==="video";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative rounded-md overflow-hidden border border-border group",children:[e.jsxs("div",{className:"cursor-pointer",onClick:()=>o(!0),"data-testid":"media-preview-clickable",children:[d&&e.jsx("img",{src:t,alt:"Step media",className:"w-full h-32 object-cover","data-testid":"img-step-media"}
71),u&&e.jsx("video",{src:t,playsInline:!0,preload:"metadata",className:"w-full h-32 object-cover","data-testid":"video-step-media"}),l&&e.jsx("div",{className:"w-full h-32 bg-muted flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ku,{className:"h-8 w-8 mx-auto text-muted-foreground"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[s.replace("embed-","").charAt(0).toUpperCase()+s.slice(7)," Video"]})]})}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:e.jsx("span",{className:"text-white opacity-0 group-hover:opacity-100 text-sm font-medium transition-opacity",children:"Click to preview"})})]}),n&&e.jsxs(D,{size:"sm",variant:"destructive",className:"absolute top-1 right-1",onClick:h=>{h.stopPropagation(),n()},"data-testid":"button-remove-media",children:[e.jsx(Zn,{className:"h-3 w-3"}),"Remove"]})]}),e.jsx(St,{open:a,onOpenChange:o,children:e.jsxs(jt,{className:"max-w-4xl max-h-[90vh]",children:[e.jsx(wt,{children:e.jsx(bt,{children:"Media Preview"})}),e.jsxs("div",{className:"overflow-auto max-h-[70vh]",children:[d&&e.jsx("img",{src:t,alt:"Full preview",className:"w-full h-auto object-contain","data-testid":"img-preview-full"}),u&&e.jsx("video",{src:t,controls:!0,autoPlay:!0,playsInline:!0,preload:"metadata",className:"w-full aspect-video","data-testid":"video-preview-full"}),l&&e.jsx("div",{className:"aspect-video",children:e.jsx("iframe",{src:t,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Video preview","data-testid":"iframe-preview-full"})})]})]})})]})}function Bk(){const t=Gn();return t?{Authorization:`Bearer ${t}`}:{}}function Vk({onTranscription:t,context:s,cleanupEnabled:n=!0,className:a="",variant:o="icon",disabled:l=!1}){const[d,u]=m.useState(!1),[h,f]=m.useState(!1),g=Cl(h,"voice-processing"),[x,v]=m.useState(0),w=m.useRef(null),C=m.useRef(null),j=m.useRef([]),b=m.useRef(null),{toast:k}=dt(),N=m.useCallback(async()=>{try{const R=await navigator.mediaDevices.getUserMedia({audio:!0});C.current=R;const F=new MediaRecorder(R,{mimeType:MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4"});w.current=F,j.current=[],F.ondataavailable=M=>{M.data.size>0&&j.current.push(M.data)},F.onstop=async()=>{const M=new Blob(j.current,{type:F.mimeType});await P(M)},F.start(100),u(!0),v(0),b.current=setInterval(()=>{v(M=>M+1)},1e3)}catch(R){console.error("Failed to start recording:",R),k({title:"Microphone access denied",description:"Please allow microphone access to use voice input.",variant:"destructive"})}},[k]),T=m.useCallback(()=>{w.current&&d&&(w.current.stop(),u(!1),b.current&&(clearInterval(b.current),b.current=null),C.current&&(C.current.getTracks().forEach(R=>R.stop()),C.current=null))},[d]),P=async R=>{f(!0);try{const F=await R.arrayBuffer(),z=await fetch(n?"/api/voice/transcribe-clean":"/api/voice/transcribe",{method:"POST",headers:{"Content-Type":R.type,...s&&{"x-voice-context":s},...Bk()},credentials:"include",body:F});if(!z.ok){const B=await z.json();throw B.error==="ai_upgrade_required"?new Error("AI features require the Creator plan. Upgrade from the Billing page to unlock AI tools."):new Error(B.error||"Transcription failed")}const H=await z.json(),V=H.text||H.original||"";V?(t(V),k({title:"Transcription complete",description:n?"Your speech has been transcribed and cleaned up.":"Your speech has been transcribed."})):k({title:"No speech detected",description:"Please try speaking more clearly or for a longer duration.",variant:"destructive"})}catch(F){console.error("Processing error:",F),k({title:"Transcription failed",description:F instanceof Error?F.message:"Failed to process audio",variant:"destructive"})}finally{f(!1),v(0)}},I=R=>{const F=Math.floor(R/60),M=R%60;return`${F}:${M.toString().padStart(2,"0")}`},O=()=>{d?T():N()};return o==="icon"?e.jsx(D,{type:"button",size:"icon",variant:d?"destructive":"ghost",onClick:O,disabled:l||h,className:a,"data-testid":"button-voice-input",title:d?"Stop recording":"Start voice input",children:h?e.jsx(Ve,{className:"h-4 w-4 animate-spin"}):d?e.jsx(Pc,{className:"h-4 w-4"}):e.jsx(ka,{className:"h-4 w-4"})}):e.jsx("div",{className:`flex items-center gap-2 ${a}`,children:e.jsx(D,{type:"button",variant:d?"destructive":"outline",onClick:O,disabled:l||h,"data-testid":"button-voice-input-full",children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),e.jsx("span",{className:"animate-pulse",children:g})]}):d?e.jsxs(e.Fragment,{children:[e.jsx(Pc,{className:"h-4 w-4 mr-2"}),"Stop (",I(x),")"]}):e.jsxs(e.Fragment,{children:[e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Start Voice Input"]})})})}function qk({onProcedureGenerated:t,disabled:s=!1}){const[n,a]=m.useState(!1),[o,l]=m.useState(!1),d=Cl(o,"voice-processing"),[u,h]=m.useState(0),f=m.useRef(null),g=m.useRef(null),x=m.useRef([]),v=m.useRef(null),{toast:w}=dt(),C=m.useCallback(async()=>{try{const T=await navigator.mediaDevices.getUserMedia({audio:!0});g.current=T;
71const P=new MediaRecorder(T,{mimeType:MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4"});f.current=P,x.current=[],P.ondataavailable=I=>{I.data.size>0&&x.current.push(I.data)},P.onstop=async()=>{const I=new Blob(x.current,{type:P.mimeType});await b(I)},P.start(100),a(!0),h(0),v.current=setInterval(()=>{h(I=>I+1)},1e3)}catch(T){console.error("Failed to start recording:",T),w({title:"Microphone access denied",description:"Please allow microphone access to use voice input.",variant:"destructive"})}},[w]),j=m.useCallback(()=>{f.current&&n&&(f.current.stop(),a(!1),v.current&&(clearInterval(v.current),v.current=null),g.current&&(g.current.getTracks().forEach(T=>T.stop()),g.current=null))},[n]),b=async T=>{l(!0);try{const P=await T.arrayBuffer(),I=await fetch("/api/voice/generate-procedure",{method:"POST",headers:{"Content-Type":T.type,...Bk()},credentials:"include",body:P});if(!I.ok){const R=await I.json();throw R.error==="ai_upgrade_required"?new Error("AI features require the Creator plan. Upgrade from the Billing page to unlock AI tools."):new Error(R.error||"Failed to generate procedure from voice")}const O=await I.json();t(O),w({title:"Procedure generated",description:`Created "${O.title}" with ${O.steps.length} steps from your description.`})}catch(P){console.error("Processing error:",P),w({title:"Generation failed",description:P instanceof Error?P.message:"Failed to generate procedure from voice",variant:"destructive"})}finally{l(!1),h(0)}},k=T=>{const P=Math.floor(T/60),I=T%60;return`${P}:${I.toString().padStart(2,"0")}`},N=()=>{n?j():C()};return e.jsx(D,{type:"button",variant:n?"destructive":"outline",onClick:N,disabled:s||o,className:"w-full","data-testid":"button-voice-describe",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),e.jsx("span",{className:"animate-pulse",children:d})]}):n?e.jsxs(e.Fragment,{children:[e.jsx(bN,{className:"h-4 w-4 mr-2"}),"Stop Recording (",k(u),")"]}):e.jsxs(e.Fragment,{children:[e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Describe Your Procedure with Voice"]})})}var Zx="Progress",Xx=100,[$U]=En(Zx),[UU,zU]=$U(Zx),Kk=m.forwardRef((t,s)=>{const{__scopeProgress:n,value:a=null,max:o,getValueLabel:l=BU,...d}=t;(o||o===0)&&!db(o)&&console.error(VU(`${o}`,"Progress"));const u=db(o)?o:Xx;a!==null&&!ub(a,u)&&console.error(qU(`${a}`,"Progress"));const h=ub(a,u)?a:null,f=bm(h)?l(h,u):void 0;return e.jsx(UU,{scope:n,value:h,max:u,children:e.jsx(at.div,{"aria-valuemax":u,"aria-valuemin":0,"aria-valuenow":bm(h)?h:void 0,"aria-valuetext":f,role:"progressbar","data-state":Qk(h,u),"data-value":h??void 0,"data-max":u,...d,ref:s})})});Kk.displayName=Zx;var Hk="ProgressIndicator",Wk=m.forwardRef((t,s)=>{const{__scopeProgress:n,...a}=t,o=zU(Hk,n);return e.jsx(at.div,{"data-state":Qk(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...a,ref:s})});Wk.displayName=Hk;function BU(t,s){return`${Math.round(t/s*100)}%`}function Qk(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function bm(t){return typeof t=="number"}function db(t){return bm(t)&&!isNaN(t)&&t>0}function ub(t,s){return bm(t)&&!isNaN(t)&&t<=s&&t>=0}function VU(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Xx}\`.`}function qU(t,s){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${s}\`. The \`value\` prop must be:
72  - a positive number
73  - less than the value passed to \`max\` (or ${Xx} if no \`max\` prop is set)
74  - \`null\` or \`undefined\` if the progress is indeterminate.
75
76Defaulting to \`null\`.`}var Gk=Kk,KU=Wk;const Yk=m.forwardRef(({className:t,value:s,...n},a)=>e.jsx(Gk,{ref:a,className:Oe("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...n,children:e.jsx(KU,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));Yk.displayName=Gk.displayName;function HU(){const t=Gn();return t?{Authorization:`Bearer ${t}`}:{}}function WU(){const t=navigator.userAgent.toLowerCase();return t.includes("chrome")&&!t.includes("edg")?{name:"Chrome",supportsDocPiP:"documentPictureInPicture"in window}:t.includes("safari")&&!t.includes("chrome")?{name:"Safari",supportsDocPiP:!1}:t.includes("firefox")?{name:"Firefox",supportsDocPiP:!1}:t.includes("edg")?{name:"Edge",supportsDocPiP:!1}
76:{name:"Unknown",supportsDocPiP:!1}}function QU({open:t,onOpenChange:s,onProcedureGenerated:n,existingProcedureId:a,existingTitle:o,purpose:l="steps"}){const{toast:d}=dt(),u=l==="intro",[h,f]=m.useState("idle"),[g,x]=m.useState(0),[v,w]=m.useState(!1),[C,j]=m.useState(!u),[b,k]=m.useState(0),[N,T]=m.useState(""),[P,I]=m.useState(!1),[O,R]=m.useState(!1),[F,M]=m.useState(""),[z,H]=m.useState(!1),[V,B]=m.useState([]),[Y,L]=m.useState(!1),K=m.useRef(null),_=m.useRef(null),$=m.useRef(null),A=m.useRef(h),W=m.useRef(g),U=m.useRef(z),Q=m.useRef(C),we=m.useRef(F),_e=m.useRef(u),Ie=m.useRef([]);m.useEffect(()=>{A.current=h},[h]),m.useEffect(()=>{W.current=g},[g]),m.useEffect(()=>{U.current=z},[z]),m.useEffect(()=>{Q.current=C},[C]),m.useEffect(()=>{we.current=F},[F]),m.useEffect(()=>{_e.current=u},[u]),m.useEffect(()=>{Ie.current=V},[V]);const Te=m.useRef(null),ue=m.useRef(null),Re=m.useRef(null),$e=m.useRef([]),le=m.useRef(null),Me=m.useRef(null),He=m.useRef(null),ft=m.useCallback(async()=>{try{return(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(Xe=>Xe.stop()),w(!0),!0}catch{return w(!1),!1}},[]);m.useEffect(()=>{t&&ft()},[t,ft]),m.useEffect(()=>{(h==="recording"||h==="paused")&&Re.current&&Me.current&&(Me.current.srcObject=Re.current,Me.current.muted=!0,Me.current.playsInline=!0,Me.current.play().catch(()=>{}))},[h]);const Ct=m.useCallback(()=>{const ze=window.SpeechRecognition||window.webkitSpeechRecognition;if(!ze){d({title:"Speech recognition not supported",description:"Your browser doesn't support speech recognition. The video will still be recorded.",variant:"destructive"});return}const Xe=new ze;Xe.continuous=!0,Xe.interimResults=!0,Xe.lang="en-US";let ne="";Xe.onresult=pe=>{let ut="";for(let mt=pe.resultIndex;mt<pe.results.length;mt++){const ms=pe.results[mt][0].transcript;pe.results[mt].isFinal?ne+=ms+" ":ut+=ms}M(ne+ut)},Xe.onerror=pe=>{console.error("Speech recognition error:",pe.error),pe.error!=="no-speech"&&H(!1)},Xe.onend=()=>{if(h==="recording"&&He.current)try{Xe.start()}catch(pe){console.log("Recognition restart failed:",pe)}else H(!1)};try{Xe.start(),He.current=Xe,H(!0)}catch(pe){console.error("Failed to start speech recognition:",pe)}},[h,d]),zt=m.useCallback(()=>{He.current&&(He.current.stop(),He.current=null,H(!1))},[]),Wt=m.useCallback(()=>{_.current&&(clearInterval(_.current),_.current=null),K.current&&!K.current.closed&&K.current.close(),K.current=null,R(!1)},[]),Le=m.useCallback(()=>{le.current&&(clearInterval(le.current),le.current=null),Te.current&&(Te.current.getTracks().forEach(ze=>ze.stop()),Te.current=null),ue.current&&(ue.current.getTracks().forEach(ze=>ze.stop()),ue.current=null),Wt(),zt(),Re.current=null,$.current=null,$e.current=[]},[zt,Wt]),Nt=m.useCallback(async()=>{if(!Te.current||Y)return;if(!Te.current.getVideoTracks()[0]){d({title:"Screenshot failed",description:"No video track available.",variant:"destructive"});return}L(!0);try{const Xe=document.createElement("video");Xe.srcObject=Te.current,Xe.muted=!0,Xe.playsInline=!0,await new Promise((Ft,Jt)=>{Xe.onloadedmetadata=()=>{Xe.play().then(()=>Ft()).catch(Jt)},Xe.onerror=()=>Jt(new Error("Failed to load video")),setTimeout(()=>Jt(new Error("Video load timeout")),3e3)}),await new Promise(Ft=>setTimeout(Ft,50));const ne=document.createElement("canvas");ne.width=Xe.videoWidth||1920,ne.height=Xe.videoHeight||1080;const pe=ne.getContext("2d");if(!pe)throw new Error("Failed to get canvas context");pe.drawImage(Xe,0,0,ne.width,ne.height),Xe.pause(),Xe.srcObject=null;const ut=await new Promise((Ft,Jt)=>{ne.toBlob(vs=>{vs?Ft(vs):Jt(new Error("Failed to create blob"))},"image/png",.95)}),mt=W.current,kt=we.current.trim().split(" ").slice(-20).join(" "),xs=await fetch("/api/uploads/request-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:`screenshot-${Date.now()}.png`,size:ut.size,contentType:"image/png",mediaType:"image"})});if(!xs.ok)throw new Error("Failed to get upload URL for screenshot");const{uploadURL:hs,objectPath:Jn,publicUrl:_n}=await xs.json();await fetch(hs,{method:"PUT",body:ut,headers:{"Content-Type":"image/png"}});const en={timestamp:mt,imageUrl:_n||Jn,transcriptSnippet:kt||void 0};B(Ft=>[...Ft,en]),d({title:"Screenshot captured",description:`Captured at ${Math.floor(mt/60)}:${(mt%60).toString().padStart(2,"0")}`})}catch(Xe){console.error("Screenshot capture failed:",Xe),d({title:"Screenshot failed",description:Xe instanceof Error?Xe.message:"Failed to capture screenshot",variant:"destructive"})}finally{L(!1)}},[Y,d]),Xt=async()=>{try{const ze=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1});Te.current=ze;let Xe=ze;if(C)try{const ut=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}});ue.current=ut;const mt=[...ze.getVideoTracks(),...ut.getAudioTracks()];Xe=new MediaStream(mt),Ct()}catch{d({title:"Audio not available",description:"Recording without audio. Grant microphone permission for voice narration.",variant:"destructive"})}Re.current=Xe;
76const ne=MediaRecorder.isTypeSupported("video/mp4")?"video/mp4":MediaRecorder.isTypeSupported("video/mp4;codecs=avc1")?"video/mp4;codecs=avc1":"video/mp4",pe=new MediaRecorder(Xe,{mimeType:ne,videoBitsPerSecond:25e5});$.current=pe,$e.current=[],pe.ondataavailable=ut=>{ut.data.size>0&&$e.current.push(ut.data)},pe.start(1e3),f("recording"),x(0),M(""),B([]),le.current=setInterval(()=>{x(ut=>ut+1)},1e3),ze.getVideoTracks()[0].addEventListener("ended",()=>{qs()})}catch(ze){console.error("Failed to start recording:",ze),d({title:"Screen capture failed",description:"Please grant screen sharing permission and try again.",variant:"destructive"})}},qt=()=>{$.current&&h==="recording"&&($.current.pause(),zt(),f("paused"),le.current&&(clearInterval(le.current),le.current=null))},us=()=>{$.current&&h==="paused"&&($.current.resume(),Ct(),f("recording"),le.current=setInterval(()=>{x(ze=>ze+1)},1e3))},qs=async()=>{if($.current)return zt(),new Promise(ze=>{if(!$.current){ze();return}$.current.onstop=()=>{le.current&&(clearInterval(le.current),le.current=null),Te.current&&Te.current.getTracks().forEach(Xe=>Xe.stop()),ue.current&&ue.current.getTracks().forEach(Xe=>Xe.stop()),Me.current&&(Me.current.srcObject=null),f("idle"),ze()},$.current.stop()})},Ks=async()=>{if($e.current.length===0){d({title:"No recording",description:"Please record your screen first.",variant:"destructive"});return}const ze=u||!C,Xe=we.current;if(!ze&&(!Xe||Xe.trim().length<10)){d({title:"No narration detected",description:"Please speak clearly while recording to describe the procedure steps.",variant:"destructive"});return}Wt(),f("processing"),k(10),T(ze?"Preparing video...":"Preparing recording...");try{const ne=new Blob($e.current,{type:$.current?.mimeType||"video/mp4"});k(20),T("Uploading video...");const pe=await fetch("/api/uploads/request-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:`recording-${Date.now()}.mp4`,size:ne.size,contentType:ne.type})});if(!pe.ok)throw new Error("Failed to get upload URL");const{uploadURL:ut,objectPath:mt,publicUrl:ms}=await pe.json();k(40),T("Uploading to storage..."),await fetch(ut,{method:"PUT",body:ne,headers:{"Content-Type":ne.type}});let Kt=mt;if(ze)k(90),T("Finalizing video..."),k(100),T("Complete!"),n({title:o||(u?"Walkthrough Video":"Demo Video"),description:"",steps:[],videoUrl:Kt}),d({title:u?"Walkthrough video saved!":"Video saved!",description:"Your video has been uploaded and is ready to use."});else{k(60),T("Generating steps from transcript...");const kt=await fetch("/api/ai/generate-from-transcript",{method:"POST",headers:{"Content-Type":"application/json",...HU()},credentials:"include",body:JSON.stringify({transcript:Xe.trim(),videoUrl:Kt,existingTitle:o,procedureId:a,screenshots:Ie.current.map(hs=>({timestamp:hs.timestamp,imageUrl:hs.imageUrl,transcriptSnippet:hs.transcriptSnippet})),totalDuration:W.current})});if(!kt.ok){const hs=await kt.json();throw hs.error==="ai_upgrade_required"?new Error("AI features require the Creator plan. Upgrade from the Billing page to unlock AI tools."):new Error(hs.error||"Failed to process transcript")}k(90),T("Finalizing procedure...");const xs=await kt.json();k(100),T("Complete!"),n({title:xs.title,description:xs.description,steps:xs.steps,videoUrl:ms||mt,transcript:Xe.trim()}),d({title:xs.isUpdate?"Video added to procedure!":"Procedure generated!",description:`Created ${xs.steps?.length||0} steps from your narration.`})}Le(),M(""),x(0),B([]),f("idle"),s(!1)}catch(ne){console.error("Processing error:",ne),d({title:"Processing failed",description:ne instanceof Error?ne.message:"Failed to process recording",variant:"destructive"}),f("idle")}},xn=async()=>{if(!window.documentPictureInPicture){d({title:"Pop-out not supported",description:"Your browser doesn't support pop-out mode. Use the minimize button instead.",variant:"destructive"});return}try{const ze=await window.documentPictureInPicture.requestWindow({width:320,height:180});K.current=ze,R(!0);const Xe=ze.document.createElement("style");Xe.textContent=`
77        * { margin: 0; padding: 0; box-sizing: border-box; }
78        body {
79          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
80          background: linear-gradient(135deg, #1f1f23 0%, #121214 100%);
81          color: #f4f4f5;
82          padding: 20px;
83          display: flex;
84          flex-direction: column;
85          justify-content: center;
86          gap: 20px;
87          height: 100vh;
88        }
89        .status-bar {
90          display: flex;
91          align-items: center;
92          justify-content: center;
93          gap: 12px;
94          flex-wrap: wrap;
95          padding: 8px 0;
96        }
97        .badge {
98          padding: 6px 14px;
99          border-radius: 20px;
100          font-size: 13px;
101          font-weight: 600;
102          letter-spacing: 0.02em;
103          display: inline-flex;
104          align-items: center;
105          gap: 6px;
106        }
107        .recording { 
108          background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
109          box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
110        }
111        .paused { 
112          background: #3f3f46; 
113          color: #a1a1aa;
114        }
115        .listening { 
116          background: rgba(34, 197, 94, 0.15); 
117          color: #4ade80; 
118          border: 1px solid rgba(34, 197, 94, 0.4);
119        }
120        .intro-badge {
121          background: rgba(59, 130, 246, 0.15);
122          color: #60a5fa;
123          border: 1px solid rgba(59, 130, 246, 0.4);
124        }
125        @keyframes pulse { 
126          0%, 100% { opacity: 1; box-shadow: 0 0 12px rgba(239, 68, 68, 0.4); } 
127          50% { opacity: 0.85; box-shadow: 0 0 20px rgba(239, 68, 68, 0.6); } 
128        }
129        .recording { animation: pulse 2s ease-in-out infinite; }
130        .controls {
131          display: flex;
132          gap: 14px;
133          justify-content: center;
134          flex-wrap: wrap;
135        }
136        button {
137          padding: 10px 16px;
138          border-radius: 8px;
139          border: none;
140          font-size: 13px;
141          font-weight: 600;
142          cursor: pointer;
143          display: inline-flex;
144          align-items: center;
145          justify-content: center;
146          gap: 6px;
147          transition: all 0.15s ease;
148          min-height: 40px;
149        }
150        button:hover { transform: translateY(-1px); }
151        button:active { transform: translateY(0); }
152        button:focus { outline: 2px solid #B24884; outline-offset: 2px; }
153        .btn-outline { 
154          background: rgba(255, 255, 255, 0.08); 
155          border: 1px solid rgba(255, 255, 255, 0.15); 
156          color: #e4e4e7;
157        }
158        .btn-outline:hover { 
159          background: rgba(255, 255, 255, 0.12);
160          border-color: rgba(255, 255, 255, 0.25);
161        }
162        .btn-destructive { 
163          background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
164          color: white; 
165          box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
166        }
167        .btn-destructive:hover { 
168          background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
169          box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
170        }
171        .btn-primary { 
172          background: linear-gradient(135deg, #c026d3 0%, #B24884 100%);
173          color: white;
174          box-shadow: 0 2px 8px rgba(178, 72, 132, 0.3);
175        }
176        .icon { width: 16px; height: 16px; }
177      `,ze.document.head.appendChild(Xe);const ne=ze.document.createElement("div");ne.id="pip-controls",ze.document.body.appendChild(ne);const pe=()=>{const ut=A.current,mt=W.current,ms=U.current,Kt=Q.current,kt=_e.current,xs=ut==="recording",hs=ut==="paused",Jn='<svg class="icon" viewB
177ox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/></svg>',_n='<svg class="icon" viewBox="0 0 24 24" fill="currentColor"><polygon points="5,3 19,12 5,21"/></svg>',en='<svg class="icon" viewBox="0 0 24 24" fill="currentColor"><rect x="4" y="4" width="16" height="16" rx="2"/></svg>',Ft='<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/></svg>',Jt='<svg class="icon" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="6"/></svg>',vs='<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>',Fs=Ie.current;ne.innerHTML=`
178          <div class="status-bar">
179            <span class="badge ${xs?"recording":"paused"}">
180              ${xs?Jt:""} ${xs?"Recording":"Paused"} ${Ls(mt)}
181            </span>
182            ${ms&&Kt?'<span class="badge listening">Listening</span>':""}
183            ${kt?'<span class="badge intro-badge">Intro Video</span>':""}
184            ${Fs.length>0?`<span class="badge" style="background: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.4);">${Fs.length} screenshot${Fs.length!==1?"s":""}</span>`:""}
185          </div>
186          <div class="controls">
187            <button class="btn-outline" id="pip-toggle-playback">
188              ${hs?_n:Jn}
189              ${hs?"Resume":"Pause"}
190            </button>
191            ${kt?"":`
192              <button class="btn-primary" id="pip-screenshot" ${xs?"":'disabled style="opacity: 0.5; cursor: not-allowed;"'}>
193                ${vs}
194                Screenshot
195              </button>
196            `}
197            <button class="btn-destructive" id="pip-stop">
198              ${en}
199              ${kt?"Save Video":"Generate Steps"}
200            </button>
201            <button class="btn-outline" id="pip-back">
202              ${Ft}
203              Back
204            </button>
205          </div>
206        `,ze.document.getElementById("pip-toggle-playback")?.addEventListener("click",()=>{A.current==="paused"?us():qt()}),ze.document.getElementById("pip-screenshot")?.addEventListener("click",()=>{A.current==="recording"&&Nt()}),ze.document.getElementById("pip-stop")?.addEventListener("click",async()=>{await qs(),Wt(),Ks()}),ze.document.getElementById("pip-back")?.addEventListener("click",()=>{Wt()})};pe(),_.current=setInterval(()=>{if(ze.closed){_.current&&(clearInterval(_.current),_.current=null),R(!1),K.current=null;return}pe()},500),ze.addEventListener("pagehide",()=>{_.current&&(clearInterval(_.current),_.current=null),R(!1),K.current=null})}catch(ze){console.error("Failed to open PiP:",ze),d({title:"Pop-out failed",description:"Could not open pop-out window. Try using minimize instead.",variant:"destructive"})}},vn=()=>{Le(),M(""),x(0),f("idle"),s(!1)},Ls=ze=>{const Xe=Math.floor(ze/60),ne=ze%60;return`${Xe}:${ne.toString().padStart(2,"0")}`};if(P&&(h==="recording"||h==="paused"))return e.jsxs(e.Fragment,{children:[e.jsx("video",{ref:Me,className:"hidden",autoPlay:!0,muted:!0,playsInline:!0}),e.jsxs("div",{className:"fixed bottom-4 right-4 z-50 bg-background border rounded-lg shadow-lg p-3 flex items-center gap-3",children:[e.jsxs(Ce,{variant:h==="recording"?"destructive":"secondary",className:"animate-pulse",children:[h==="recording"?"Recording":"Paused"," ",Ls(g)]}),u&&e.jsx(Ce,{variant:"outline",className:"text-blue-500 border-blue-500/50",children:"Intro"}),e.jsxs("div",{className:"flex items-center gap-2",children:[h==="paused"?e.jsx(D,{size:"sm",variant:"outline",onClick:us,"data-testid":"button-mini-resume",children:e.jsx(Ku,{className:"h-4 w-4"})}):e.jsx(D,{size:"sm",variant:"outline",onClick:qt,"data-testid":"button-mini-pause",children:e.jsx($p,{className:"h-4 w-4"})}),!u&&e.jsx(D,{size:"sm",variant:"secondary",onClick:Nt,disabled:Y||h!=="recording",title:"Capture Step Screenshot","data-testid":"button-mini-screenshot",children:Y?e.jsx(Ve,{className:"h-4 w-4 animate-spin"}):e.jsx(rp,{className:"h-4 w-4"})}),e.jsx(D,{size:"sm",variant:"destructive",onClick:async()=>{await qs(),I(!1),Ks()},"data-testid":"button-mini-stop",children:e.jsx(Pc,{className:"h-4 w-4"})}),e.jsx(D,{size:"sm",variant:"outline",onClick:()=>I(!1),"data-testid":"button-mini-maximize",children:e.jsx(Jo,{className:"h-4 w-4"})})]}),z&&C&&e.jsxs(Ce,{variant:"outline",className:"text-green-600",children:[e.jsx(ka,{className:"h-3 w-3 mr-1 animate-pulse"}),"Listening"]})]})]});const $t=WU();return O&&(h==="recording"||h==="paused")?e.jsxs(e.Fragment,{children:[e.jsx("video",{ref:Me,className:"hidden",autoPlay:!0,muted:!0,playsInl
206ine:!0}),e.jsx(St,{open:t,onOpenChange:()=>{},children:e.jsxs(jt,{className:"max-w-sm",children:[e.jsxs(wt,{children:[e.jsxs(bt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Yn,{className:"h-4 w-4 text-primary"}),"Recording in Pop-out Window"]}),e.jsx(Gt,{className:"text-xs",children:"Your recording controls are in the floating pop-out window. You can now switch tabs freely."})]}),e.jsxs("div",{className:"text-center py-4 space-y-3",children:[e.jsxs(Ce,{variant:h==="recording"?"destructive":"secondary",className:h==="recording"?"animate-pulse":"",children:[h==="recording"?"Recording":"Paused"," ",Ls(g)]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Use the floating window to pause, stop, or return here."}),e.jsxs(D,{variant:"outline",onClick:Wt,"data-testid":"button-close-pip",children:[e.jsx(Jo,{className:"h-4 w-4 mr-2"}),"Return Controls Here"]})]})]})})]}):e.jsx(St,{open:t,onOpenChange:ze=>{!ze&&h!=="idle"||s(ze)},children:e.jsxs(jt,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(wt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(bt,{className:"flex items-center gap-2 text-base",children:[e.jsx(lr,{className:"h-4 w-4 text-primary"}),u?"Record Walkthrough Video":a?"Record & Generate Steps":"Record Procedure"]}),(h==="recording"||h==="paused")&&e.jsxs("div",{className:"flex items-center gap-1",children:[$t.supportsDocPiP&&e.jsx(D,{size:"icon",variant:"ghost",onClick:xn,title:"Pop out to floating window","data-testid":"button-popout",children:e.jsx(Yn,{className:"h-4 w-4"})}),e.jsx(D,{size:"icon",variant:"ghost",onClick:()=>I(!0),title:"Minimize to record other windows","data-testid":"button-minimize",children:e.jsx(kc,{className:"h-4 w-4"})})]})]}),e.jsx(Gt,{className:"text-xs",children:u?"Record a walkthrough video to introduce this procedure. Audio is optional.":"Record your screen while narrating each step. AI will convert your speech into structured procedure steps."})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h==="idle"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(ee,{children:e.jsx(te,{className:"p-4",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("div",{className:"w-12 h-12 mx-auto rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Rg,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"font-medium text-sm",children:"Ready to Record"}),e.jsx("p",{className:"text-xs text-muted-foreground max-w-sm mx-auto",children:u?"Record a walkthrough video to introduce your procedure. Toggle audio on or off as needed.":"Share your screen and narrate what you're doing. AI will automatically create procedure steps from your voice."})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[u?e.jsx(D,{variant:C?"default":"outline",size:"sm",onClick:()=>j(!C),"data-testid":"button-toggle-audio",children:C?e.jsxs(e.Fragment,{children:[e.jsx(ka,{className:"h-3 w-3 mr-1"}),"Audio On"]}):e.jsxs(e.Fragment,{children:[e.jsx(bN,{className:"h-3 w-3 mr-1"}),"Audio Off"]})}):e.jsxs(Ce,{variant:"default",className:"text-xs",children:[e.jsx(ka,{className:"h-3 w-3 mr-1"}),"Audio Required"]}),!v&&C&&e.jsxs(Ce,{variant:"secondary",className:"text-xs",children:[e.jsx(hl,{className:"h-3 w-3 mr-1"}),"Mic permission needed"]})]}),e.jsxs(D,{onClick:Xt,className:"px-6","data-testid":"button-start-recording",children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Start Recording"]})]})})}),u?e.jsx(ee,{className:"border-blue-500/50 bg-blue-500/5",children:e.jsxs(te,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(lr,{className:"h-3 w-3 text-blue-500"}),"Walkthrough Video"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This video will appear at the top of your procedure as an introduction or overview."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yr,{className:"h-3 w-3 text-green-500 shrink-0"}),e.jsx("span",{children:"No steps will be generated from this recording"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yr,{className:"h-3 w-3 text-green-500 shrink-0"}),e.jsx("span",{children:"Audio is optional - toggle above"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yr,{className:"h-3 w-3 text-green-500 shrink-0"}),e.jsx("span",{children:"Video will be hosted for viewing"})]})]})]})}):e.jsx(ee,{className:"border-primary/50 bg-primary/5",children:e.jsxs(te,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ka,{className:"h-3 w-3 text-primary"}),"Speak Clearly While Recording"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your voice narration will be transcribed and used to generate procedure steps."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yr,{className:"h-3 w-3 text-green-500 shrink-0"}),e.jsx("span",{children:"Speak clearly and at a moderate pace"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yr,{className:"h-3 w-3 text-green-500 shrink-0"}),e.jsx("span",{children:"Describe what you're clicking or doing"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yr,{className:"h-3 w-3 text-green-500 shrink-0"}),e.jsx("span",{children:"AI will generate steps from your narration"})]})]})]})}),!$t.supportsDocPiP&&$t.name!=="Chrome"&&e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-muted/50 text-xs text-muted-foreground",children:[e.jsx(ln,{className:"h-3 w-3 shrink-0 mt-0.5"}),e.jsxs("span",{children:["For the best experience with pop-out recording controls, we recommend using Chrome.",$t.name!=="Unknown"&&` You're currently using ${$t.name}.`]})]})]}),(h==="recording"||h==="paused")&&e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 flex-1 min-h-0",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"relative bg-black rounded-md overflow-hidden aspect-video",children:[e.jsx("video",{ref:Me,autoPlay:!0,muted:!0,playsInl
206ine:!0,className:"w-full h-full object-contain","data-testid":"video-preview"}),e.jsxs("div",{className:"absolute top-2 left-2 flex items-center gap-1.5 flex-wrap",children:[e.jsxs(Ce,{variant:h==="recording"?"destructive":"secondary",className:h==="recording"?"animate-pulse":"",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current mr-1"}),h==="recording"?"REC":"Paused"]}),e.jsx(Ce,{variant:"secondary",children:Ls(g)})]})]}),V.length>0&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-2",children:[e.jsx(rp,{className:"h-3 w-3"}),e.jsxs("span",{children:[V.length," screenshot",V.length!==1?"s":""," captured"]})]})]}),e.jsxs(ee,{className:"flex flex-col min-h-0 h-full",children:[e.jsx(qe,{className:"pb-2 shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(tt,{className:"text-sm font-medium",children:"Live Transcript"}),z&&e.jsxs(Ce,{variant:"outline",className:"bg-green-500/20 text-green-400 border-green-500/50 text-xs",children:[e.jsx(ka,{className:"h-2.5 w-2.5 mr-1 animate-pulse"}),"Listening"]})]})}),e.jsx(te,{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(jl,{className:"h-full max-h-[200px]",children:e.jsx("p",{className:"text-sm text-muted-foreground pr-3",children:F||"Start speaking to see your transcript appear here..."})})})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 pt-4 mt-auto border-t shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[h==="paused"?e.jsxs(D,{onClick:us,"data-testid":"button-resume",children:[e.jsx(Ku,{className:"h-4 w-4 mr-2"}),"Resume"]}):e.jsxs(D,{variant:"outline",onClick:qt,"data-testid":"button-pause",children:[e.jsx($p,{className:"h-4 w-4 mr-2"}),"Pause"]}),!u&&e.jsxs(D,{variant:"secondary",onClick:Nt,disabled:Y||h!=="recording","data-testid":"button-capture-screenshot",children:[Y?e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(rp,{className:"h-4 w-4 mr-2"}),"Screenshot"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{variant:"outline",onClick:vn,"data-testid":"button-cancel",children:"Cancel"}),e.jsxs(D,{variant:"destructive",onClick:async()=>{await qs(),Ks()},"data-testid":"button-stop-generate",children:[e.jsx(Pc,{className:"h-4 w-4 mr-2"}),u?"Stop & Save":"Generate Steps"]})]})]})]}),h==="processing"&&e.jsxs("div",{className:"space-y-6 py-8",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(Ve,{className:"h-12 w-12 mx-auto animate-spin text-primary"}),e.jsx("h3",{className:"font-medium",children:N}),e.jsx("p",{className:"text-sm text-muted-foreground",children:C?"AI is analyzing your narration to create procedure steps...":"Uploading your demo video..."})]}),e.jsx(Yk,{value:b,className:"h-2"}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:[b,"% complete"]})]})]})]})})}function Nm({onProcedureGenerated:t,existingProcedureId:s,existingTitle:n,purpose:a="steps"}){const[o,l]=m.useState(!1),d=a==="intro";return e.jsxs(e.Fragment,{children:[e.jsxs(D,{variant:"outline",onClick:()=>l(!0),"data-testid":d?"button-record-intro-video":"button-record-procedure",children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),d?"Create Walkthrough":"Record Screen"]}),e.jsx(QU,{open:o,onOpenChange:l,onProcedureGenerated:t,existingProcedureId:s,existingTitle:n,purpose:a})]})}function Zk({procedureId:t,onVersionRestored:s}){const{toast:n}=dt(),[a,o]=m.useState(!1),[l,d]=m.useState(null),[u,h]=m.useState(!1),[f,g]=m.useState(null),{data:x,isLoading:v}=je({queryKey:["/api/procedures",t,"versions"],enabled:!!t}),w=ye({mutationFn:async b=>ce("POST",`/api/procedure-versions/${b}/restore`,{changedBy:"Team Member"}),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/procedures",t]}),de.invalidateQueries({queryKey:["/api/procedures",t,"versions"]}),n({title:"Version restored successfully"}),h(!1),g(null),s?.()},onError:()=>{n({title:"Failed to restore version",variant:"destructive"})}}),C=b=>{g(b),h(!0)},j=b=>{d(l===b?null:b)};return t?v?e.jsxs(ee,{className:"border-border/50 h-full",children:[e.jsx(qe,{className:"pb-3",children:e.jsxs(tt,{className:"text-base flex items-center gap-2",children:[e.jsx(yc,{className:"h-4 w-4"}),"Version History"]})}),e.jsx(te,{className:"space-y-3",children:[1,2,3].map(b=>e.jsx(be,{className:"h-16 w-full"},b))})]}):e.jsxs(e.Fragment,{children:[e.jsx(Cn,{open:a,onOpenChange:o,children:e.jsxs(ee,{className:"border-border/50","data-testid":"section-version-history",children:[e.jsx(Mn,{asChild:!0,children:e.jsxs(qe,{className:"pb-3 cursor-pointer hover-elevate rounded-t-lg",children:[e.jsxs(tt,{className:"text-base flex items-center gap-2",children:[e.jsx(yc,{className:"h-4 w-4"}),"Version History",x&&x.length>0&&e.jsxs(Ce,{variant:"secondary",className:"text-xs ml-auto mr-2",children:[x.length," version",x.length!==1?"s":""]}),e.jsx(Bt,{className:`h-4 w-4 transition-transform duration-200 ${a?"rotate-90":""}`})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Click Save to update history"})]})}),e.jsx(Ln,{children:e.jsx(te,{className:"p-0",children:e.jsx(jl,{className:"max-h-[400px]",children:e.jsx("div",{className:"p-4 pt-2 space-y-2",children:!x||x.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Pt,{className:"h-8 w-8 text-muted-foreground
206/50 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No version history yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/70 mt-1",children:"Versions are created when you save changes"})]}):x.map((b,k)=>{const N=l===b.id,T=b.steps||[],P=k===0;return e.jsx(ee,{className:`border-border/30 hover-elevate ${P?"border-primary/30":""}`,"data-testid":`version-item-${b.id}`,children:e.jsxs(te,{className:"p-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsxs("span",{className:"font-medium text-sm",children:["Version ",b.version]}),P&&e.jsx(Ce,{variant:"default",className:"text-xs",children:"Current"}),b.source==="autosave"&&e.jsx(Ce,{variant:"outline",className:"text-xs text-muted-foreground",children:"Auto"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Vi,{className:"h-3 w-3"}),b.createdAt&&Nr(new Date(b.createdAt),"MMM d, yyyy h:mm a")]}),b.changedBy&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(Hr,{className:"h-3 w-3"}),b.changedBy]}),b.changeSummary&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-2",children:b.changeSummary})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(D,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>j(b.id),"data-testid":`button-expand-version-${b.id}`,children:N?e.jsx(Im,{className:"h-4 w-4"}):e.jsx(On,{className:"h-4 w-4"})}),!P&&e.jsx(D,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>C(b),"data-testid":`button-restore-version-${b.id}`,children:e.jsx(jc,{className:"h-4 w-4"})})]})]}),N&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-border/50 space-y-2",children:[e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"font-medium",children:"Title:"})," ",e.jsx("span",{className:"text-muted-foreground",children:b.title})]}),b.description&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"font-medium",children:"Description:"})," ",e.jsx("span",{className:"text-muted-foreground line-clamp-2",children:b.description})]}),e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"font-medium",children:"Status:"})," ",e.jsx(Ce,{variant:b.status==="published"?"default":"secondary",className:"text-xs ml-1",children:b.status})]}),T.length>0&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"font-medium",children:"Steps:"})," ",e.jsxs("span",{className:"text-muted-foreground",children:[T.length," step",T.length!==1?"s":""]})]})]})]})},b.id)})})})})})]})}),e.jsx(St,{open:u,onOpenChange:h,children:e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Restore Version"}),e.jsxs(Gt,{children:["Are you sure you want to restore this procedure to version ",f?.version,"? This will replace the current content with the selected version."]})]}),e.jsx("div",{className:"py-4",children:f&&e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-3 text-sm space-y-1",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Title:"})," ",f.title]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Created:"})," ",f.createdAt&&Nr(new Date(f.createdAt),"MMM d, yyyy h:mm a")]}),f.changeSummary&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Note:"})," ",f.changeSummary]})]})})}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>h(!1),children:"Cancel"}),e.jsx(D,{onClick:()=>f&&w.mutate(f.id),disabled:w.isPending,"data-testid":"button-confirm-restore",children:w.isPending?"Restoring...":"Restore Version"})]})]})})]}):e.jsxs(ee,{className:"border-border/50 h-full",children:[e.jsx(qe,{className:"pb-3",children:e.jsxs(tt,{className:"text-base flex items-center gap-2",children:[e.jsx(yc,{className:"h-4 w-4"}),"Version History"]})}),e.jsx(te,{children:e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"Select a procedure to view its history"})})]})}function GU({step:t,index:s,totalSteps:n,updateStep:a,removeStep:o,moveStepUp:l,moveStepDown:d,openMediaDialog:u,removeStepImage:h,removeStepVideo:f,improvingStepIndex:g,handleImproveStep:x}){const v=g===s,w=Cl(v,"improve");return e.jsx(ee,{className:"border-border/50","data-testid":`card-step-${s}`,children:e.jsx(te,{className:"p-4 space-y-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 flex-shrink-0 pt-1",children:[e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>l(s),disabled:s===0,"data-testid":`button-move-up-${s}`,children:e.jsx(Im,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-6 h-6 rounded-full bg-primary text-primary-foreground flex items-center justify-center text-xs font-medium",children:s+1}),e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>d(s),disabled:s===n-1,"data-testid":`button-move-down-${s}`,children:e.jsx(On,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(fe,{value:t.title||"",onChange:C=>a(s,"title",C.target.value),placeholder:"Step title",className:"font-medium","data-testid":`input-step-title-${s}`}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ss,{value:t.content||"",onChange:C=>a(s,"content",C.target.value),placeholder:"Step instructions...",rows:2,className:"flex-1","data-testid":`input-step-content-${s}`}),e.jsx(Vk,{onTranscription:C=>a(s,"content",(t.content||"")+(t.content?" ":"")+C),context:"step instructions in a procedure",className:"mt-1","data-testid":`button-voice-content-${s}`})]}),t.imageUrl&&e.jsx(wm,{mediaUrl:t.imageUrl,mediaType:"image",onRemove:()=>h(s)}),t.videoUrl&&e.jsx(wm,{mediaUrl:t.videoUrl,mediaType:t.videoType||"video",onRemove:()=>f(s)}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>u("image",s),"data-testid":`button-step-image-${s}`,children:[e.jsx(qi,{className:"h-4 w-4 mr-1"}),"Image"]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>u("video",s),"data-testid":`button-step-video-${s}`,children:[e.jsx(lr,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(Gi,{children:[e.jsx(Yi,{asChild:!0,children:e.jsx(D,{variant:"outline",size:"sm",disabled:v,"data-testid":`button-step-improve-${s}`,children:v?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-1 animate-spin"}),e.jsx("span",{className:"animate-pulse",children:w})]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"h-4 w-4 mr-1"}),"Improve",e.jsx(On,{className:"h-3 w-3 ml-1"})]})})}),e.jsxs(pi,{align:"start",children:[e.jsxs(on,{onClick:()=>x(s,"polish"),"data-testid":`button-step-polish-${s}`,children:[e.jsx(gs,{className:"h-4 w-4 mr-2"}),"Polish - Fix grammar and clarity"]}),e.jsxs(on,{onClick:()=>x(s,"simplify"),"data-testid":`button-step-simplify-${s}`,children:[e.jsx(kc,{className:"h-4 w-4 mr-2"}),"Simplify - Make it easier to follow"]}),e.jsxs(on,{onClick:()=>x(s,"expand"),"data-testid":`button-step-expand-${s}`,children:[e.jsx(Jo,{className:"h-4 w-4 mr-2"}),"Expand - Add more detail"]})]})]}),e.jsx("div",{className:"flex-1"}),e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>o(s),className:"text-destructive","data-testid":`button-step-delete-${s}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]})]})})})}function YU({procedureId:t,onBack:s}){const{toast:n}=dt(),{data:a,isLoading:o,dataUpdatedAt:l}=je({queryKey:["/api/procedures",t],enabled:!!t}),[d,u]=m.useState(""),[h,f]=m.useState(""),[g,x]=m.useState("draft"),[v,w]=m.useState(!0),[C,j]=m.useState("procedure"),[b,k]=m.useState([]),[N,T]=m.useState([]),[P,I]=m.useState(""),[O,R
206]=m.useState(null),[F,M]=m.useState(!0),[z,H]=m.useState(0),[V,B]=m.useState(!1),[Y,L]=m.useState(null),[K,_]=m.useState(null),$=m.useRef(null),{data:A=[]}=je({queryKey:["/api/knowledge-bases"]}),{data:W=[]}=je({queryKey:["/api/knowledge-bases",Y,"categories"],enabled:!!Y}),U=A.find(se=>se.id===Y),{data:Q}=je({queryKey:["/api/clients",U?.clientId],enabled:!!U?.clientId}),we=W.find(se=>se.id===K),[_e,Ie]=m.useState(null),[Te,ue]=m.useState(null),[Re,$e]=m.useState(!1),[le,Me]=m.useState(!1),[He,ft]=m.useState(!1);m.useEffect(()=>{(async()=>{if(K&&we&&(!we.slug||we.slug.trim()==="")){$e(!0);try{const Be=await(await ce("POST",`/api/categories/${K}/ensure-slug`)).json();Be.slug&&(Ie(Be.slug),de.invalidateQueries({queryKey:["/api/knowledge-bases",Y,"categories"]}))}catch(Ue){console.error("Failed to ensure category slug:",Ue)}finally{$e(!1)}}})()},[K,we,Y]),m.useEffect(()=>{(async()=>{if(t&&a&&(!a.slug||a.slug.trim()==="")){Me(!0);try{const Be=await(await ce("POST",`/api/procedures/${t}/ensure-slug`)).json();Be.slug&&(ue(Be.slug),de.invalidateQueries({queryKey:["/api/procedures",t]}))}catch(Ue){console.error("Failed to ensure procedure slug:",Ue)}finally{Me(!1)}}})()},[t,a]);const Ct=_e||we?.slug,zt=Te||a?.slug,Wt=Re||le,Le=Q?.slug&&U?.slug&&Ct&&zt?`/${Q.slug}/${U.slug}/${Ct}/${zt}`:null,Nt=(se,Ue=[])=>{const Be=new Map;return Ue.forEach(De=>{De.id&&De._tempId&&Be.set(De.id,De._tempId)}),se.map(De=>De._tempId?De:De.id&&Be.has(De.id)?{...De,_tempId:Be.get(De.id)}:De.id?De:{...De,_tempId:`temp-${Date.now()}-${Math.random().toString(36).substr(2,9)}`})};m.useEffect(()=>{a&&F&&l>z&&(u(a.title),f(a.description||""),x(a.status),w(a.isPublic??!0),j(a.contentType||"procedure"),R(a.videoUrl||null),k(Nt(a.steps||[])),T([]),L(a.knowledgeBaseId||null),_(a.categoryId||null),H(l),M(!1),Ls.current=JSON.stringify({title:a.title,description:a.description||"",status:a.status,isPublic:a.isPublic??!0,contentType:a.contentType||"procedure",videoUrl:a.videoUrl||null,knowledgeBaseId:a.knowledgeBaseId||null,categoryId:a.categoryId||null,steps:a.steps||[]}),setTimeout(()=>{B(!0)},100))},[a,F,l,z]);const Xt=m.useCallback(async se=>{if(!t)return;const Ue=se.deletedStepIds||N;for(const De of Ue)try{await ce("DELETE",`/api/steps/${De}`)}catch(st){if(!st.message?.includes("404"))throw st}const Be=[...se.steps];for(let De=0;De<se.steps.length;De++){const st=se.steps[De];if(st.id)try{await ce("PATCH",`/api/steps/${st.id}`,{title:st.title,content:st.content,order:st.order,type:st.type,imageUrl:st.imageUrl||null,videoUrl:st.videoUrl||null,videoType:st.videoType||null})}catch(ks){if(ks.message?.includes("404")){const fa=await(await ce("POST","/api/steps",{procedureId:t,title:st.title,content:st.content,order:st.order,type:st.type||"action",imageUrl:st.imageUrl||null,videoUrl:st.videoUrl||null,videoType:st.videoType||null})).json();fa?.id&&(Be[De]={...Be[De],id:fa.id})}else throw ks}else if(st.title||st.content){const Gr=await(await ce("POST","/api/steps",{procedureId:t,title:st.title,content:st.content,order:st.order,type:st.type||"action",imageUrl:st.imageUrl||null,videoUrl:st.videoUrl||null,videoType:st.videoType||null})).json();Gr?.id&&(Be[De]={...Be[De],id:Gr.id})}}await ce("PATCH",`/api/procedures/${t}`,{title:se.title,description:se.description,status:se.status,isPublic:se.isPublic,videoUrl:se.videoUrl,knowledgeBaseId:se.knowledgeBaseId,categoryId:se.categoryId,_saveSource:"autosave"}),k(Nt(Be,b)),T([]),H(Date.now()),de.invalidateQueries({queryKey:["/api/procedures",t,"versions"]})},[t,N]),[qt,us]=m.useState(!1),[qs,Ks]=m.useState(null),[xn,vn]=m.useState(!1),Ls=m.useRef(null),$t=m.useCallback(()=>JSON.stringify({title:d,description:h,status:g,isPublic:v,contentType:C,videoUrl:O,steps:b,knowledgeBaseId:Y,categoryId:K}),[d,h,g,v,C,O,b,Y,K]);m.useEffect(()=>{if(!t)return;const se=$t();if(Ls.current===null){Ls.current=se;return}vn(se!==Ls.current)},[$t,t]);const ze=m.useCallback(async()=>{if(qt||!t)return;us(!0);const se=C;try{await Xt({title:d,description:h,status:g,isPublic:v,contentType:C,videoUrl:O,steps:b,knowledgeBaseId:Y,categoryId:K}),Ls.current=$t(),Ks(new Date),vn(!1),n({title:se==="overview"?"Overview saved":"Procedure saved"})}catch(Ue){console.error("Save failed:",Ue),n({title:"Failed to save",variant:"destructive"})}finally{us(!1)}},[qt,t,Xt,d,h,g,v,C,O,b,Y,K,$t,n]),Xe=m.useCallback(()=>{$.current&&clearTimeout($.current),$.current=setTimeout(()=>{V&&!qt&&ze()},2e3)},[V,qt,ze]);m.useEffect(()=>{B(!1)},[t]),ye({mutationFn:async se=>ce("PATCH",`/api/procedures/${t}`,se),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/procedures"]})}}),ye({mutationFn:async se=>{for(const Be of N)try{await ce("DELETE",`/api/steps/${Be}`)}catch(De){if(!De.message?.includes("404"))throw De}const Ue=[...b];for(let Be=0;Be<b.length;Be++){const De=b[Be];if(De.id)try{await ce("PATCH",`/api/steps/${De.id}`,{title:De.title,content:De.content,order:De.order,type:De.type,imageUrl:De.imageUrl||null,videoUrl:De.videoUrl||null,videoType:De.videoType||null})}catch(st){if(st.message?.includes("404")){const Gr=await(await ce("POST","/api/steps",{procedureId:t,title:De.title,content:De.content,order:De.order,type:De.type||"action",imageUrl:De.imageUrl||null,videoUrl:De.videoUrl||null,videoType:De.videoType||null})).json();Gr?.id&&(Ue[Be]={...Ue[Be],id:Gr.id})}else throw st}
206else{const ks=await(await ce("POST","/api/steps",{procedureId:t,title:De.title,content:De.content,order:De.order,type:De.type||"action",imageUrl:De.imageUrl||null,videoUrl:De.videoUrl||null,videoType:De.videoType||null})).json();ks?.id&&(Ue[Be]={...Ue[Be],id:ks.id})}}return await ce("PATCH",`/api/procedures/${t}`,{title:d,description:h,status:g,isPublic:v,knowledgeBaseId:Y,categoryId:K,_saveSource:"manual"}),{updatedSteps:Ue,savedContentType:se}},onSuccess:async({updatedSteps:se,savedContentType:Ue})=>{k(Nt(se,b)),T([]),Ls.current=$t(),vn(!1),H(Date.now()),await de.invalidateQueries({queryKey:["/api/procedures"]}),await de.invalidateQueries({queryKey:["/api/procedures",t]}),await de.invalidateQueries({queryKey:["/api/procedures",t,"versions"]}),n({title:Ue==="overview"?"Overview saved":"Procedure saved"})},onError:se=>{n({title:"Failed to save",description:se.message,variant:"destructive"})}});const ne=ye({mutationFn:async se=>ce("POST",`/api/procedures/${t}/notes`,se),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/procedures",t]}),n({title:"Note added"}),I("")},onError:()=>{n({title:"Failed to add note",variant:"destructive"})}}),pe=ye({mutationFn:async se=>ce("DELETE",`/api/procedure-notes/${se}`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/procedures",t]}),n({title:"Note deleted"})}}),ut=()=>`temp-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,mt=()=>{k([...b,{order:b.length+1,title:"",content:"",type:"action",_tempId:ut()}]),Xe()},ms=se=>se.id?se.id:se._tempId?se._tempId:(console.warn("Step missing ID, generating fallback:",se),`fallback-${Date.now()}-${Math.random().toString(36).substr(2,9)}`),Kt=(se,Ue,Be)=>{const De=[...b];De[se]={...De[se],[Ue]:Be},k(De)},kt=se=>{const Ue=b[se];Ue?.id&&T(Be=>[...Be,Ue.id]),k(b.filter((Be,De)=>De!==se)),Xe()},xs=se=>{se!==0&&(k(Ue=>{const Be=[...Ue];return[Be[se-1],Be[se]]=[Be[se],Be[se-1]],Be.map((De,st)=>({...De,order:st+1}))}),Xe())},hs=se=>{se>=b.length-1||(k(Ue=>{const Be=[...Ue];return[Be[se],Be[se+1]]=[Be[se+1],Be[se]],Be.map((De,st)=>({...De,order:st+1}))}),Xe())},[Jn,_n]=m.useState(null),[en,Ft]=m.useState(!1),Jt=Cl(en,"improve"),[vs,Fs]=m.useState(!1),[Cs,Hs]=m.useState("image"),[Is,Rn]=m.useState(null),as=(se,Ue)=>{Hs(se),Rn(Ue),Fs(!0)},tn=(se,Ue)=>{if(Is!==null){const Be=Ue==="image";k(De=>{const st=[...De];return Be?st[Is]={...st[Is],imageUrl:se}:st[Is]={...st[Is],videoUrl:se,videoType:Ue},st})}Fs(!1)},$s=se=>{k(Ue=>{const Be=[...Ue];return Be[se]={...Be[se],imageUrl:null},Be})},un=se=>{k(Ue=>{const Be=[...Ue];return Be[se]={...Be[se],videoUrl:null,videoType:null},Be})},yn=ye({mutationFn:async({index:se,title:Ue,content:Be,mode:De})=>{const st=await ce("POST","/api/ai/improve-step",{title:Ue,content:Be,mode:De,clientId:a?.clientId});return{index:se,mode:De,result:await st.json()}},onSuccess:({index:se,mode:Ue,result:Be})=>{Kt(se,"title",Be.title),Kt(se,"content",Be.content),n({title:`Step ${{polish:"Polished",simplify:"Simplified",expand:"Expanded"}[Ue]||"improved"}`}),_n(null)},onError:se=>{se.message.includes("ai_upgrade_required")?n({title:"Upgrade Required",description:"AI features require the Creator plan. The client must upgrade to use AI tools.",variant:"destructive"}):n({title:"Failed to improve step",description:se.message,variant:"destructive"}),_n(null)}}),zn=ye({mutationFn:async({mode:se})=>{const Ue=await ce("POST","/api/ai/improve-description",{title:d||a?.title||"",description:h||a?.description||"",mode:se,clientId:a?.clientId});return{mode:se,result:await Ue.json()}},onSuccess:({mode:se,result:Ue})=>{f(Ue.description),n({title:`Description ${{polish:"Polished",simplify:"Simplified",expand:"Expanded"}[se]||"improved"}`}),Ft(!1)},onError:se=>{se.message.includes("ai_upgrade_required")?n({title:"Upgrade Required",description:"AI features require the Creator plan. The client must upgrade to use AI tools.",variant:"destructive"}):n({title:"Failed to improve description",description:se.message,variant:"destructive"}),Ft(!1)}}),Gs=se=>{const Ue=h||a?.description||"",Be=d||a?.title||"";if(!Ue){n({title:"Please enter a description first",variant:"destructive"});return}if(!Be){n({title:"Please enter a title first",variant:"destructive"});return}Ft(!0),zn.mutate({mode:se})},er=(se,Ue)=>{const Be=b[se];if(!Be?.title||!Be?.content){n({title:"Please enter step title and content first",variant:"destructive"});return}_n(se),yn.mutate({index:se,title:Be.title,content:Be.content,mode:Ue})};return t?o?e.jsxs("div",{className:"space-y-6 max-w-3xl",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx(be,{className:"h-10 w-full"}),e.jsx(be,{className:"h-20 w-full"}),e.jsx("div",{className:"space-y-4",children:[1,2,3].map(se=>e.jsx(be,{className:"h-24 w-full"},se))})]}):e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:items-start",children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-6 lg:max-w-3xl",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs(D,{variant:"ghost",size:"sm",onClick:s,"data-testid":"button-editor-back",children:[e.jsx(kn,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>ft(!0),"data-testid":"button-preview-procedure",children:[e.jsx(Sn,{className:"h-4 w-4 mr-1"}),"Preview"]}),Wt?e.jsxs(D,{variant:"outline",size:"sm",disabled:!0,"data-testid":"button-view-procedure-public-loading",children:[e.jsx(Ve,{className:"h-4 w-4 mr-1 animate-spin"}),"Preparing..."]}):Le?e.jsx("a",{href:Le,target:"_blank",rel:"noopener noreferrer",children:e.jsxs(D,{variant:"outline",size:"sm","data-testid":"button-view-procedure-public",children:[e.jsx(Yn,{className:"h-4 w-4 mr-1"}),"View Public"]})}):null]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"title",children:"Title"}),e.jsx(fe,{id:"title",value:d||a?.title||"",onChange:se=>u(se.target.value),placeholder:"Procedure title",className:"text-lg font-medium","data-testid":"input-procedure-title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Z,{htmlFor:"description",children:"Description"}),e.jsx("div",{className:"flex items-center gap-1",children:e.jsxs(Gi,{children:[e.jsx(Yi,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",disabled:en,"data-testid":"button-description-improve",children:en?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-1 animate-spin"}),e.jsx("span",{className:"animate-pulse",children:Jt})]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"h-4 w-4 mr-1"}),"Improve",e.jsx(On,{className:"h-3 w-3 ml-1"})]})})}),e.jsxs(pi,{align:"end",children:[e.jsxs(on,{onClick:()=>Gs("polish"),"data-testid":"button-description-polish",children:[e.jsx(gs,{className:"h-4 w-4 mr-2"}),"Polish - Fix grammar and clarity"]}),e.jsxs(on,{onClick:()=>Gs("simplify"),"data-testid":"button-description-simplify",children:[e.jsx(kc,{className:"h-4 w-4 mr-2"}),"Simplify - Make it easier to read"]}),e.jsxs(on,{onClick:()=>Gs("expand"),"data-testid":"button-description-expand",children:[e.jsx(Jo,{className:"h-4 w-4 mr-2"}),"Expand - Add more detail"]})]})]})})]}),e.jsx(ss,{id:"description",value:h||a?.description||"",onChange:se=>f(se.target.value),placeholder:"Brief description of this procedure",rows:3,"data-testid":"input-procedure-description"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"font-medium text-lg flex items-center gap-2",children:[e.jsx(Pa,{className:"h-5 w-5 text-primary"}),C==="overview"?"Key Points":"Steps"]})}),e.jsxs("div",{className:"space-y-3",children:[b.map((se,Ue)=>e.jsx(GU,{step:se,index:Ue,totalSteps:b.length,updateStep:Kt,removeStep:kt,moveStepUp:xs,moveStepDown:hs,openMediaDialog:as,removeStepImage:$s,removeStepVideo:un,improvingStepIndex:Jn,handleImproveStep:er},ms(se))),b.length===0&&e.jsx(ee,{className:"border-border/50 border-dashed",children:e.jsxs(te,{className:"p-8 text-center space-y-4",children:[e.jsx(Pa,{className:"h-8 w-8 text-muted-foreground
206/50 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"No steps yet. Use AI to generate steps or add them manually."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[e.jsx(qk,{onProcedureGenerated:se=>{if(se.title&&!d&&u(se.title),se.description&&!h&&f(se.description),se.steps&&se.steps.length>0){const Ue=new Set,De=se.steps.filter(st=>{const ks=`${st.title?.toLowerCase()}|${st.content?.toLowerCase()}`;return Ue.has(ks)?!1:(Ue.add(ks),!0)}).map((st,ks)=>({...st,order:ks+1}));k(Nt(De))}setTimeout(()=>ze(),100)}}),e.jsx(Nm,{onProcedureGenerated:se=>{if(se.title&&!d&&u(se.title),se.description&&!h&&f(se.description),se.steps&&se.steps.length>0){const Ue=new Set,De=se.steps.filter(st=>{const ks=`${st.title?.toLowerCase()}|${st.content?.toLowerCase()}`;return Ue.has(ks)?!1:(Ue.add(ks),!0)}).map((st,ks)=>({...st,order:ks+1}));k(Nt(De))}setTimeout(()=>ze(),100)}})]})]})}),e.jsxs(D,{variant:"outline",className:"w-full border-dashed",onClick:mt,"data-testid":"button-add-step",children:[e.jsx(ds,{className:"h-4 w-4 mr-2"}),"Add ",C==="overview"?"Key Point":"Step"]})]})]}),e.jsx(DU,{title:d||a?.title||"",description:h||a?.description||"",onGenerateSteps:se=>{k(Nt(se)),setTimeout(()=>ze(),100)}}),e.jsx(fg,{open:vs,onOpenChange:Fs,type:Cs,onMediaSelected:tn})]}),e.jsx("div",{className:"w-full lg:w-80 lg:flex-shrink-0 order-first lg:order-last",children:e.jsxs("div",{className:"lg:sticky lg:top-4 space-y-4",children:[e.jsx(Cn,{defaultOpen:!0,children:e.jsxs(ee,{className:"border-border/50",children:[e.jsx(Mn,{asChild:!0,children:e.jsx(qe,{className:"p-4 pb-2 cursor-pointer hover-elevate rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jc,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"font-medium text-sm",children:"Content Management"})]}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 [[data-state=open]>&]:rotate-90"})]})})}),e.jsx(Ln,{children:e.jsxs(te,{className:"p-4 pt-2 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-5 text-xs text-muted-foreground",children:xn?e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"Unsaved changes"}):qs?e.jsxs("span",{children:["Last saved ",qs.toLocaleTimeString()]}):null}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(lt,{value:g,onValueChange:x,children:[e.jsx(it,{className:"w-28","data-testid":"select-procedure-status",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"draft",children:"Draft"}),e.jsx(me,{value:"published",children:"Published"})]})]}),e.jsxs(D,{variant:xn?"default":"outline",size:"sm",onClick:()=>ze(),disabled:qt,"data-testid":"button-save-procedure",children:[qt?e.jsx(Ve,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Ki,{className:"h-4 w-4 mr-1"}),"Save"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{className:"text-xs text-muted-foreground",children:"Content Type"}),e.jsxs(lt,{value:C,onValueChange:se=>j(se),children:[e.jsx(it,{"data-testid":"select-content-type",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"procedure",children:"Procedure"}),e.jsx(me,{value:"overview",children:"Overview"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[v?e.jsx($n,{className:"h-4 w-4 text-primary"}):e.jsx(Pn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Access"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:v?"Visible to everyone":"Restricted access"})]})]}),e.jsx(As,{checked:v,onCheckedChange:w,"data-testid":"switch-procedure-public"})]})]})})]})}),e.jsx(Cn,{defaultOpen:!0,children:e.jsxs(ee,{className:"border-border/50",children:[e.jsx(Mn,{asChild:!0,children:e.jsx(qe,{className:"p-4 pb-2 cursor-pointer hover-elevate rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"font-medium text-sm",children:"Walkthrough Video"})]}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 [[data-state=open]>&]:rotate-90"})]})})}),e.jsx(Ln,{children:e.jsx(te,{className:"p-4 pt-2 space-y-3",children:O?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"rounded-lg border border-border overflow-hidden bg-muted",children:e.jsx(rl,{src:O,className:"w-full aspect-video","data-testid":"video-procedure-editor"})}),e.jsxs(D,{variant:"ghost",size:"sm",onClick:()=>R(null),className:"w-full","data-testid":"button-remove-video",children:[e.jsx(ts,{className:"h-4 w-4 mr-1"}),"Remove Video"]})]}):e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"This video will appear at the top of your procedure as an introduction or overview. Nothing is generated from this recording."}),e.jsx(Nm,{existingProcedureId:t||void 0,existingTitle:d,purpose:"intro",onProcedureGenerated:se=>{se.videoUrl&&R(se.videoUrl),setTimeout(()=>ze(),500)}})]})})})]})}),e.jsx(Cn,{defaultOpen:!1,children:e.jsxs(ee,{className:"border-border/50",children:[e.jsx(Mn,{asChild:!0,children:e.jsxs(qe,{className:"p-4 pb-2 cursor-pointer hover-elevate rounded-t-lg",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fr,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"font-medium text-sm",children:"Organization"})]}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 [[data-state=open]>&]:rotate-90"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Assign to a Knowledge Base and Category"})]})}),e.jsx(Ln,{children:e.jsxs(te,{className:"p-4 pt-2 space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"knowledgeBase",className:"text-xs",children:"Knowledge Base"}),e.jsxs(lt,{value:Y||"none",onValueChange:se=>{const Ue=se==="none"?null:se;L(Ue),Ue!==Y&&_(null)},children:[e.jsx(it,{"data-testid":"select-procedure-kb",children:e.jsx(ct,{placeholder:"Select knowledge base"})}),e.jsxs(ot,{children:[e.jsx(me,{value:"none",children:"None (Standalone)"}),A.map(se=>e.jsx(me,{value:se.id,children:se.name},se.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"category",className:"text-xs",children:"Category"}),e.jsxs(lt,{value:K||"none",onValueChange:se=>_(se==="none"?null:se),disabled:!Y,children:[e.jsx(it,{"data-testid":"select-procedure-category",children:e.jsx(ct,{placeholder:Y?"Select category":"Select a KB first"})}),e.jsxs(ot,{children:[e.jsx(me,{value:"none",children:"None (Uncategorized)"}),W.map(se=>e.jsx(me,{value:se.id,children:se.name},se.id))]})]})]})]})})]})}),e.jsx(Zk,{procedureId:t,onVersionRestored:()=>{M(!0),de.invalidateQueries({queryKey:["/api/procedures",t]})}}),e.jsx(Cn,{defaultOpen:!1,children:e.jsxs(ee,{className:"border-border/50",children:[e.jsx(Mn,{asChild:!0,children:e.jsx(qe,{className:"p-4 cursor-pointer hover-elevate rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(no,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"font-medium text-sm",children:"Internal Notes"}),e.jsx(Ce,{variant:"secondary",className:"text-xs",children:"Team Only"})]}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 [[data-state=open]>&]:rotate-90"})]})})}),e.jsx(Ln,{children:e.jsxs(te,{className:"p-4 pt-0 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ss,{value:P,onChange:se=>I(se.target.value),placeholder:"Add a note for the team...",rows:2,className:"flex-1","data-testid":"input-new-note"}),e.jsx(D,{onClick:()=>ne.mutate({author:"Team Member",content:P}),disabled:!P.trim()||ne.isPending,size:"sm","data-testid":"button-add-note",children:e.jsx(el,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:a?.notes&&a.notes.length>0?a.notes.map(se=>e.jsxs("div",{className:"p-3 rounded-lg border border-border/50 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-medium",children:se.author}),e.jsx("span",{className:"text-muted-foreground",children:se.createdAt&&Nr(new Date(se.createdAt),"MMM d, h:mm a")})]}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>pe.mutate(se.id),className:"h-6 w-6 text-muted-foreground","data-testid":`button-delete-note-${se.id}`,children:e.jsx(ts,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-sm text-foreground",children:se.content})]},se.id)):e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"No notes yet"})})]})})]})})]})}),e.jsx(St,{open:He,onOpenChange:ft,children:e.jsxs(jt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto","data-testid":"dialog-preview-content",children:[e.jsxs(wt,{children:[e.jsxs(bt,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5"}),"Content Preview"]}),e.jsx(Gt,{children:"This is how your content will appear to viewers"})]}),e.jsxs("div",{className:"space-y-6 py-4","data-testid":"preview-content-body",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h1",{className:"text-2xl font-bold","data-testid":"text-preview-title",children:d||a?.title||"Untitled Procedure"}),(h||a?.description)&&e.jsx("p",{className:"text-muted-foreground","data-testid":"text-preview-description",children:h||a?.description})]}),(b.length>0||a?.steps&&a.steps.length>0)&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold border-b pb-2",children:"Steps"}),e.jsx("div",{className:"space-y-6",children:(b.length>0?b:a?.steps||[]).map((se,Ue)=>e.jsxs("div",{className:"flex gap-4","data-testid":`preview-step-${Ue}`,children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary text-primary-foreground flex items-center justify-center text-sm font-medium",children:Ue+1}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("h3",{className:"font-medium","data-testid":`text-preview-step-title-${Ue}`,children:se.title||`Step ${Ue+1}`}),se.content&&e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap","data-testid":`text-preview-step-content-${Ue}`,children:se.content}),se.imageUrl&&e.jsx("img",{src:se.imageUrl,alt:se.title||`Step ${Ue+1}`,className:"rounded-lg max-w-full h-auto max-h-64 object-contain border","data-testid":`img-preview-step-${Ue}`}),se.videoUrl&&e.jsx(rl,{src:se.videoUrl,className:"rounded-lg max-w-full max-h-64","data-testid":`video-preview-step-${Ue}`})]})]},se.id||Ue))})]})]}),e.jsx(Vs,{children:e.jsx(D,{variant:"outline",onClick:()=>ft(!1),"data-testid":"button-close-preview",children:"Close"})})]})}),xn&&e.jsx("div",{className:"fixed bottom-6 right-6 z-50",children:e.jsxs(D,{size:"lg",onClick:()=>ze(),disabled:qt,className:"shadow-lg","data-testid":"button-floating-save",children:[qt?e.jsx(Ve,{className:"h-5 w-5 mr-2 animate-spin"}):e.jsx(Ki,{className:"h-5 w-5 mr-2"}),"Save Changes"]})})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Pt,{className:"h-12 w-12 text-muted-foreground
206/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Select a procedure to edit"}),e.jsxs(D,{variant:"ghost",onClick:s,className:"mt-4",children:[e.jsx(kn,{className:"h-4 w-4 mr-1"}),"Back to list"]})]})}function mb({template:t,onSave:s,onCancel:n,isSaving:a}){const[o,l]=m.useState(t?.name||""),[d,u]=m.useState(t?.slug||""),[h,f]=m.useState(t?.subject||""),[g,x]=m.useState(t?.htmlContent||""),[v,w]=m.useState(t?.textContent||""),[C,j]=m.useState(t?.description||""),[b,k]=m.useState(t?.isActive??!0),[N,T]=m.useState("html"),P=()=>{!o||!d||!h||!g||s({name:o,slug:d,subject:h,htmlContent:g,textContent:v||null,description:C||null,isActive:b})},I=o&&d&&h&&g;return e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(D,{variant:"ghost",size:"icon",onClick:n,"data-testid":"button-back-templates",children:e.jsx(kn,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-serif text-2xl font-normal tracking-tight",children:t?"Edit Template":"New Template"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:t?`Editing "${t.name}"`:"Create a new email template"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{variant:"outline",onClick:n,"data-testid":"button-cancel-template",children:"Cancel"}),e.jsx(D,{onClick:P,disabled:!I||a,"data-testid":"button-save-template",children:a?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ki,{className:"h-4 w-4 mr-1"}),"Save Template"]})})]})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ee,{className:"border-border/50",children:[e.jsx(qe,{children:e.jsx(tt,{className:"text-base",children:"Template Details"})}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"template-name",children:"Template Name"}),e.jsx(fe,{id:"template-name",value:o,onChange:O=>{l(O.target.value),t||u(O.target.value.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""))},placeholder:"Welcome Email","data-testid":"input-template-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"template-slug",children:"Slug"}),e.jsx(fe,{id:"template-slug",value:d,onChange:O=>u(O.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:"welcome","data-testid":"input-template-slug"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Used to identify this template in code (e.g., "welcome", "password-reset")'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"template-subject",children:"Subject Line"}),e.jsx(fe,{id:"template-subject",value:h,onChange:O=>f(O.target.value),placeholder:"Welcome to Outliner","data-testid":"input-template-subject"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{variable}}"," for dynamic content"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"template-description",children:"Description (Optional)"}),e.jsx(fe,{id:"template-description",value:C,onChange:O=>j(O.target.value),placeholder:"Sent to new users when they sign up","data-testid":"input-template-description"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-border/50",children:[e.jsxs("div",{children:[e.jsx(Z,{htmlFor:"template-active",className:"cursor-pointer",children:"Active"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable or disable this template"})]}),e.jsx(As,{id:"template-active",checked:b,onCheckedChange:k,"data-testid":"switch-template-active"})]})]})]}),e.jsxs(ee,{className:"border-border/50",children:[e.jsxs(qe,{children:[e.jsx(tt,{className:"text-base",children:"Template Variables"}),e.jsx(Tt,{children:"Available variables you can use in your template"})]}),e.jsx(te,{children:e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"px-2 py-1 rounded bg-muted text-xs",children:"{{firstName}}"}),e.jsx("span",{className:"text-muted-foreground",children:"Recipient's first name"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"px-2 py-1 rounded bg-muted text-xs",children:"{{email}}"}),e.jsx("span",{className:"text-muted-foreground",children:"Recipient's email"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"px-2 py-1 rounded bg-muted text-xs",children:"{{resetLink}}"}),e.jsx("span",{className:"text-muted-foreground",children:"Password reset link"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"px-2 py-1 rounded bg-muted text-xs",children:"{{title}}"}),e.jsx("span",{className:"text-muted-foreground",children:"Notification title"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"px-2 py-1 rounded bg-muted text-xs",children:"{{message}}"}),e.jsx("span",{className:"text-muted-foreground",children:"Notification message"})]})]})})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs(ee,{className:"border-border/50",children:[e.jsx(qe,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(tt,{className:"text-base",children:"Content"}),e.jsx(Ma,{value:N,onValueChange:O=>T(O),children:e.jsxs(ha,{className:"h-8",children:[e.jsx(ls,{value:"html",className:"text-xs px-2","data-testid":"tab-template-html",children:"HTML"}),e.jsx(ls,{value:"text",className:"text-xs px-2","data-testid":"tab-template-text",children:"Plain Text"}),e.jsx(ls,{value:"preview",className:"text-xs px-2","data-testid":"tab-template-preview",children:"Preview"})]})})]})}),e.jsxs(te,{children:[N==="html"&&e.jsx("div",{className:"space-y-2",children:e.jsx(ss,{value:g,onChange:O=>x(O.target.value),placeholder:"<div>Your HTML email content...</div>",rows:20,className:"font-mono text-sm","data-testid":"textarea-template-html"})}),N==="text"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ss,{value:v,onCh
206ange:O=>w(O.target.value),placeholder:"Plain text version of your email...",rows:20,className:"font-mono text-sm","data-testid":"textarea-template-text"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Fallback for email clients that don't support HTML"})]}),N==="preview"&&e.jsx("div",{className:"border rounded-lg bg-white dark:bg-zinc-950 min-h-[400px] p-4",children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:g}})})]})]})})]})]})}function ZU(){const{toast:t}=dt(),[s,n]=m.useState(null),[a,o]=m.useState(!1),[l,d]=m.useState(!1),{data:u,isLoading:h}=je({queryKey:["/api/email-templates"]}),f=ye({mutationFn:async v=>ce("POST","/api/email-templates",v),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/email-templates"]}),t({title:"Template created successfully"}),d(!1)},onError:()=>{t({title:"Failed to create template",variant:"destructive"})}}),g=ye({mutationFn:async({id:v,data:w})=>ce("PATCH",`/api/email-templates/${v}`,w),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/email-templates"]}),t({title:"Template updated successfully"}),o(!1),n(null)},onError:()=>{t({title:"Failed to update template",variant:"destructive"})}}),x=ye({mutationFn:async v=>ce("DELETE",`/api/email-templates/${v}`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/email-templates"]}),t({title:"Template deleted successfully"}),n(null)},onError:()=>{t({title:"Failed to delete template",variant:"destructive"})}});return a&&s?e.jsx(mb,{template:s,onSave:v=>g.mutate({id:s.id,data:v}),onCancel:()=>{o(!1),n(null)},isSaving:g.isPending}):l?e.jsx(mb,{template:null,onSave:v=>f.mutate(v),onCancel:()=>d(!1),isSaving:f.isPending}):e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-serif text-2xl md:text-3xl font-normal tracking-tight",children:"Email Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage your transactional email templates"})]}),e.jsxs(D,{onClick:()=>d(!0),"data-testid":"button-create-template",children:[e.jsx(ds,{className:"h-4 w-4 mr-1"}),"New Template"]})]}),e.jsx("div",{className:"grid gap-4",children:h?[1,2,3].map(v=>e.jsx(be,{className:"h-24"},v)):u?.length===0?e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"p-12 text-center",children:[e.jsx(Ta,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("h3",{className:"font-medium text-lg mb-2",children:"No email templates yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first email template to get started."}),e.jsxs(D,{onClick:()=>d(!0),"data-testid":"button-create-first-template",children:[e.jsx(ds,{className:"h-4 w-4 mr-1"}),"Create Template"]})]})}):u?.map(v=>e.jsx(ee,{className:"border-border/50","data-testid":`card-template-${v.id}`,children:e.jsx(te,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Ta,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-medium",children:v.name}),e.jsx(Ce,{variant:"secondary",className:"text-xs",children:v.slug}),!v.isActive&&e.jsx(Ce,{variant:"outline",className:"text-xs",children:"Inactive"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Subject: ",v.subject]}),v.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-1",children:v.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>{n(v),o(!0)},"data-testid":`button-edit-template-${v.id}`,children:[e.jsx(Ia,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(PU,{templateId:v.id,templateName:v.name,onDelete:()=>x.mutate(v.id),isDeleting:x.isPending})]})]})})},v.id))})]})}const kp=[{value:"user.registered",label:"User Registered"},{value:"user.updated",label:"User Updated"},{value:"user.login",label:"User Logged In"},{value:"user.password_reset",label:"Password Reset Requested"},{value:"procedure.published",label:"Procedure Published"},{value:"procedure.updated",label:"Procedure Updated"}];function XU(){const{toast:t}=dt(),[s,n]=m.useState(!1),[a,o]=m.useState(null),[l,d]=m.useState(""),[u,h]=m.useState(""),[f,g]=m.useState(""),[x,v]=m.useState(""),[w,C]=m.useState("0"),[j,b]=m.useState(!1),[k,N]=m.useState(""),[T,P]=m.useState("any"),{data:I,isLoading:O}=je({queryKey:["/api/automation-rules"]}),{data:R}=je({queryKey:["/api/email-templates"]}),F=ye({mutationFn:_=>
206ce("POST","/api/automation-rules",_),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/automation-rules"]}),t({title:"Automation created successfully"}),V(),n(!1)},onError:_=>{t({title:"Failed to create automation",description:_.message,variant:"destructive"})}}),M=ye({mutationFn:({id:_,data:$})=>ce("PATCH",`/api/automation-rules/${_}`,$),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/automation-rules"]}),t({title:"Automation updated successfully"}),V(),o(null)},onError:_=>{t({title:"Failed to update automation",description:_.message,variant:"destructive"})}}),z=ye({mutationFn:_=>ce("DELETE",`/api/automation-rules/${_}`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/automation-rules"]}),t({title:"Automation deleted successfully"})},onError:_=>{t({title:"Failed to delete automation",description:_.message,variant:"destructive"})}}),H=ye({mutationFn:({id:_,status:$})=>ce("PATCH",`/api/automation-rules/${_}`,{status:$}),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/automation-rules"]}),t({title:"Automation status updated"})},onError:_=>{t({title:"Failed to update status",description:_.message,variant:"destructive"})}}),V=()=>{d(""),h(""),g(""),v(""),C("0"),b(!1),N(""),P("any")},B=_=>{o(_),d(_.name),h(_.description||""),g(_.triggerEvent||""),v(_.templateId),C(String(_.delayMinutes||0)),b(_.isRecurring||!1),N(String(_.recurringIntervalMinutes||""));const A=(_.audienceFilters||[]).find(W=>W.field==="plan")?.value||"any";P(A)},Y=()=>{const _=T!=="any"?[{field:"plan",operator:"equals",value:T}]:[];if(a){const $={name:l,description:u||null,triggerEvent:f,templateId:x,delayMinutes:parseInt(w)||0,isRecurring:j,recurringIntervalMinutes:j&&parseInt(k)||null,audienceFilters:_};M.mutate({id:a.id,data:$})}else{const $={name:l,description:u||null,triggerType:"event",triggerEvent:f,templateId:x,delayMinutes:parseInt(w)||0,isRecurring:j,recurringIntervalMinutes:j&&parseInt(k)||null,status:"draft",audienceFilters:_};F.mutate($)}
206},L=_=>R?.find($=>$.id===_)?.name||"Unknown Template",K=_=>kp.find($=>$.value===_)?.label||_;return O?e.jsxs("div",{className:"space-y-4",children:[e.jsx(be,{className:"h-10 w-48"}),e.jsx(be,{className:"h-32 w-full"}),e.jsx(be,{className:"h-32 w-full"})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Email Automations"}),e.jsx("p",{className:"text-muted-foreground",children:"Automatically send emails based on events and schedules"})]}),e.jsxs(St,{open:s,onOpenChange:_=>{n(_),_||V()},children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{"data-testid":"button-create-automation",children:[e.jsx(ds,{className:"h-4 w-4 mr-2"}),"Create Automation"]})}),e.jsxs(jt,{className:"max-w-lg",children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Create Automation"}),e.jsx(Gt,{children:"Set up an automated email workflow triggered by events"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Name"}),e.jsx(fe,{value:l,onChange:_=>d(_.target.value),placeholder:"Welcome sequence","data-testid":"input-automation-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Description"}),e.jsx(ss,{value:u,onChange:_=>h(_.target.value),placeholder:"Optional description...",rows:2,"data-testid":"input-automation-description"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Trigger Event"}),e.jsxs(lt,{value:f,onValueChange:g,children:[e.jsx(it,{"data-testid":"select-automation-trigger",children:e.jsx(ct,{placeholder:"Select an event..."})}),e.jsx(ot,{children:kp.map(_=>e.jsx(me,{value:_.value,children:_.label},_.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Email Template"}),e.jsxs(lt,{value:x,onValueChange:v,children:[e.jsx(it,{"data-testid":"select-automation-template",children:e.jsx(ct,{placeholder:"Select a template..."})}),e.jsx(ot,{children:R?.map(_=>e.jsx(me,{value:_.id,children:_.name},_.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Subscription Plan Filter"}),e.jsxs(lt,{value:T,onValueChange:P,children:[e.jsx(it,{"data-testid":"select-automation-plan",children:e.jsx(ct,{placeholder:"All plans"})}),e.jsxs(ot,{children:[e.jsx(me,{value:"any",children:"All Plans"}),e.jsx(me,{value:"diy",children:"Outliner Platform"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only send to users on a specific plan"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Delay (minutes)"}),e.jsx(fe,{type:"number",min:"0",value:w,onChange:_=>C(_.target.value),placeholder:"0","data-testid":"input-automation-delay"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Wait this many minutes after the trigger before sending"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(As,{checked:j,onCheckedChange:b,"data-testid":"switch-automation-recurring"}),e.jsx(Z,{children:"Recurring automation"})]}),j&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Repeat Interval (minutes)"}),e.jsx(fe,{type:"number",min:"1",value:k,onChange:_=>N(_.target.value),placeholder:"1440 (24 hours)","data-testid":"input-automation-interval"})]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>n(!1),"data-testid":"button-cancel-automation",children:"Cancel"}),e.jsxs(D,{onClick:Y,disabled:!l||!f||!x||F.isPending,"data-testid":"button-save-automation",children:[F.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Create Automation"]})]})]})]})]}),I?.length===0?e.jsx(ee,{children:e.jsxs(te,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Wu,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No automations yet"}),e.jsx("p",{className:"text-muted-foreground text-center mb-4",children:"Create your first automation to start sending emails automatically"}),e.jsxs(D,{onClick:()=>n(!0),"data-testid":"button-create-first-automation",children:[e.jsx(ds,{className:"h-4 w-4 mr-2"}),"Create Automation"]})]})}):e.jsx("div",{className:"space-y-3",children:I?.map(_=>e.jsxs(ee,{"data-testid":`card-automation-${_.id}`,children:[e.jsxs(qe,{className:"flex flex-row items-center justify-between gap-4 space-y-0 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wu,{className:"h-4 w-4 text-primary"}),e.jsx(tt,{className:"text-base",children:_.name})]}),e.jsx(Ce,{variant:_.status==="active"?"default":"secondary",children:_.status}),_.isRecurring&&e.jsx(Ce,{variant:"outline",children:"Recurring"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(D,{size:"icon",variant:"ghost",onClick:()=>H.mutate({id:_.id,status:_.status==="active"?"paused":"active"}),"data-testid":`button-toggle-automation-${_.id}`,children:_.status==="active"?e.jsx($p,{className:"h-4 w-4"}):e.jsx(Ku,{className:"h-4 w-4"})}),e.jsx(D,{size:"icon",variant:"ghost",onClick:()=>B(_),"data-testid":`button-edit-automation-${_.id}`,children:e.jsx(Ia,{className:"h-4 w-4"})}),e.jsx(D,{size:"icon",variant:"ghost",onClick:()=>z.mutate(_.id),"data-testid":`button-delete-automation-${_.id}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]}),e.jsxs(te,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Trigger:"})," ",e.jsx("span",{className:"font-medium",children:K(_.triggerEvent||"")})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Template:"})," ",e.jsx("span",{className:"font-medium",children:L(_.templateId)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Delay:"})," ",e.jsx("span",{className:"font-medium",children:_.delayMinutes?`${_.delayMinutes} min`:"Immediate"})]})]}),_.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:_.description})]})]},_.id))}),e.jsx(St,{open:!!a,onOpenChange:_=>{_||(o(null),V())},children:e.jsxs(jt,{className:"max-w-lg",children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Edit Automation"}),e.jsx(Gt,{children:"Update your automation settings"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Name"}
206),e.jsx(fe,{value:l,onChange:_=>d(_.target.value),placeholder:"Welcome sequence","data-testid":"input-edit-automation-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Description"}),e.jsx(ss,{value:u,onChange:_=>h(_.target.value),placeholder:"Optional description...",rows:2,"data-testid":"input-edit-automation-description"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Trigger Event"}),e.jsxs(lt,{value:f,onValueChange:g,children:[e.jsx(it,{"data-testid":"select-edit-automation-trigger",children:e.jsx(ct,{placeholder:"Select an event..."})}),e.jsx(ot,{children:kp.map(_=>e.jsx(me,{value:_.value,children:_.label},_.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Email Template"}),e.jsxs(lt,{value:x,onValueChange:v,children:[e.jsx(it,{"data-testid":"select-edit-automation-template",children:e.jsx(ct,{placeholder:"Select a template..."})}),e.jsx(ot,{children:R?.map(_=>e.jsx(me,{value:_.id,children:_.name},_.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Subscription Plan Filter"}),e.jsxs(lt,{value:T,onValueChange:P,children:[e.jsx(it,{"data-testid":"select-edit-automation-plan",children:e.jsx(ct,{placeholder:"All plans"})}),e.jsxs(ot,{children:[e.jsx(me,{value:"any",children:"All Plans"}),e.jsx(me,{value:"diy",children:"Outliner Platform"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only send to users on a specific plan"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Delay (minutes)"}),e.jsx(fe,{type:"number",min:"0",value:w,onChange:_=>C(_.target.value),placeholder:"0","data-testid":"input-edit-automation-delay"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(As,{checked:j,onCheckedChange:b,"data-testid":"switch-edit-automation-recurring"}),e.jsx(Z,{children:"Recurring automation"})]}),j&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Repeat Interval (minutes)"}),e.jsx(fe,{type:"number",min:"1",value:k,onChange:_=>N(_.target.value),placeholder:"1440 (24 hours)","data-testid":"input-edit-automation-interval"})]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>{o(null),V()},"data-testid":"button-cancel-edit-automation",children:"Cancel"}),e.jsxs(D,{onClick:Y,disabled:!l||!f||!x||M.isPending,"data-testid":"button-update-automation",children:[M.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Changes"]})]})]})})]})}function JU(){const{toast:t}=dt(),[s,n]=m.useState(!1),[a,o]=m.useState(null),[l,d]=m.useState(""),[u,h]=m.useState(""),[f,g]=m.useState([{field:"status",operator:"equals",value:"active"}]),{data:x,isLoading:v}=je({queryKey:["/api/segments"]}),w=ye({mutationFn:async R=>(await ce("POST","/api/segments",R)).json(),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/segments"]}),t({title:"Segment created"}),n(!1),b()},onError:()=>{t({title:"Failed to create segment",variant:"destructive"})}}),C=ye({mutationFn:async({id:R,data:F})=>(await ce("PATCH",`/api/segments/${R}`,F)).json(),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/segments"]}),t({title:"Segment updated"}),o(null),b()},onError:()=>{t({title:"Failed to update segment",variant:"destructive"})}}),j=ye({mutationFn:async R=>{await ce("DELETE",`/api/segments/${R}`)},onSuccess:()=>{de.invalidateQueries({queryKey:["/api/segments"]}),t({title:"Segment deleted"})},onError:()=>{t({title:"Failed to delete segment",variant:"destructive"})}}),b=()=>{d(""),h(""),g([{field:"status",operator:"equals",value:"active"}])},k=()=>{l&&w.mutate({name:l,description:u,filters:f,isActive:!0})},N=()=>{!a||!l||C.mutate({id:a.id,data:{name:l,description:u,filters:f}})},T=()=>{g([...f,{field:"status",operator:"equals",value:""}])},P=R=>{g(f.filter((F,M)=>M!==R))},I=(R,F,M)=>{const z=[...f];z[R]={...z[R],[F]:M},g(z)},O=R=>{o(R),d(R.name),h(R.description||""),g(R.filters||[])};return v?e.jsxs("div",{className:"space-y-4",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx("div",{className:"grid gap-4",children:[1,2,3].map(R=>e.jsx(be,{className:"h-24"},R))})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold","data-testid":"text-segments-title",children:"Segments"}),e.jsx("p",{className:"text-muted-foreground",children:"Create audience segments based on client attributes"})]}),e.jsxs(St,{open:s,onOpenChange:n,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{"data-testid":"button-create-segment",children:[e.jsx(ds,{className:"h-4 w-4 mr-2"}),"Create Segment"]})}),e.jsxs(jt,{className:"max-w-xl",children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Create Segment"}),e.jsx(Gt,{children:"Define filters to group clients into a segment"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Segment Name"}
206),e.jsx(fe,{value:l,onChange:R=>d(R.target.value),placeholder:"e.g., Active US Clients","data-testid":"input-segment-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Description"}),e.jsx(ss,{value:u,onChange:R=>h(R.target.value),placeholder:"Optional description...","data-testid":"input-segment-description"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(Z,{children:"Filters"}),e.jsxs(D,{variant:"outline",size:"sm",onClick:T,"data-testid":"button-add-filter",children:[e.jsx(ds,{className:"h-3 w-3 mr-1"}),"Add Filter"]})]}),f.map((R,F)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(lt,{value:R.field,onValueChange:M=>I(F,"field",M),children:[e.jsx(it,{className:"w-[140px]","data-testid":`select-filter-field-${F}`,children:e.jsx(ct,{})}),e.jsx(ot,{children:Jw.map(M=>e.jsx(me,{value:M.value,children:M.label},M.value))})]}),e.jsxs(lt,{value:R.operator,onValueChange:M=>I(F,"operator",M),children:[e.jsx(it,{className:"w-[130px]","data-testid":`select-filter-operator-${F}`,children:e.jsx(ct,{})}),e.jsx(ot,{children:eb.map(M=>e.jsx(me,{value:M.value,children:M.label},M.value))})]}),e.jsx(fe,{value:R.value,onChange:M=>I(F,"value",M.target.value),placeholder:"Value",className:"flex-1","data-testid":`input-filter-value-${F}`}),f.length>1&&e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>P(F),"data-testid":`button-remove-filter-${F}`,children:e.jsx(Fp,{className:"h-4 w-4"})})]},F))]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>{n(!1),b()},children:"Cancel"}),e.jsxs(D,{onClick:k,disabled:!l||w.isPending,"data-testid":"button-save-segment",children:[w.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Create Segment"]})]})]})]})]}),x?.length===0?e.jsxs(ee,{className:"p-12 text-center",children:[e.jsx(Lm,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No segments yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first segment to target specific audiences"})]}):e.jsx("div",{className:"grid gap-4",children:x?.map(R=>e.jsxs(ee,{"data-testid":`card-segment-${R.id}`,children:[e.jsxs(qe,{className:"flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tt,{className:"text-lg",children:R.name}),e.jsx(Ce,{variant:R.isActive?"default":"secondary",children:R.isActive?"Active":"Inactive"})]}),R.description&&e.jsx(Tt,{className:"mt-1",children:R.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ce,{variant:"outline",children:[e.jsx(xE,{className:"h-3 w-3 mr-1"}),R.memberCount||0," clients"]}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>O(R),"data-testid":`button-edit-segment-${R.id}`,children:e.jsx(Ia,{className:"h-4 w-4"})}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>j.mutate(R.id),"data-testid":`button-delete-segment-${R.id}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]}),e.jsx(te,{children:e.jsx("div",{className:"flex flex-wrap gap-2",children:R.filters?.map((F,M)=>e.jsxs(Ce,{variant:"secondary",className:"text-xs",children:[e.jsx(iE,{className:"h-3 w-3 mr-1"}),F.field," ",F.operator.replace("_"," "),' "',F.value,'"']},M))})})]},R.id))}),e.jsx(St,{open:!!a,onOpenChange:R=>{R||(o(null),b())},children:e.jsxs(jt,{className:"max-w-xl",children:[e.jsx(wt,{children:e.jsx(bt,{children:"Edit Segment"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Segment Name"}),e.jsx(fe,{value:l,onChange:R=>d(R.target.value),placeholder:"e.g., Active US Clients","data-testid":"input-edit-segment-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Description"}),e.jsx(ss,{value:u,onChange:R=>h(R.target.value),placeholder:"Optional description...","data-testid":"input-edit-segment-description"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(Z,{children:"Filters"}),e.jsxs(D,{variant:"outline",size:"sm",onClick:T,children:[e.jsx(ds,{className:"h-3 w-3 mr-1"}),"Add Filter"]})]}),f.map((R,F)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(lt,{value:R.field,onValueChange:M=>I(F,"field",M),children:[e.jsx(it,{className:"w-[140px]",children:e.jsx(ct,{})}),e.jsx(ot,{children:Jw.map(M=>e.jsx(me,{value:M.value,children:M.label},M.value))})]}),e.jsxs(lt,{value:R.operator,onValueChange:M=>I(F,"operator",M),children:[e.jsx(it,{className:"w-[130px]",children:e.jsx(ct,{})}),e.jsx(ot,{children:eb.map(M=>e.jsx(me,{value:M.value,children:M.label},M.value))})]}),e.jsx(fe,{value:R.value,onChange:M=>I(F,"value",M.target.value),placeholder:"Value",className:"flex-1"}),f.length>1&&e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>P(F),children:e.jsx(Fp,{className:"h-4 w-4"})})]},F))]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>{o(null),b()},children:"Cancel"}),e.jsxs(D,{onClick:N,disabled:!l||C.isPending,"data-testid":"button-update-segment",children:[C.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Changes"]})]})]})})]})}function ez(){const{toast:t}=dt(),[s,n]=m.useState(!1),[a,o]=m.useState(""),[l,d]=m.useState(""),[u,h]=m.useState(""),[f,g]=m.useState("all"),[x,v]=m.useState(""),{data:w,isLoading:C}=je({queryKey:["/api/newsletters"]}),{data:j}=je({queryKey:["/api/email-templates"]}),{data:b}=je({queryKey:["/api/segments"]}),k=ye({mutationFn:async R=>(await ce("POST","/api/newsletters",R)).json(),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/newsletters"]}),t({title:"Newsletter campaign created"}),n(!1),P()},onError:()=>{t({title:"Failed to create newsletter",variant:"destructive"})}}),N=ye({mutationFn:async R=>(await ce("POST",`/api/newsletters/${R}/send`)).json(),onSuccess:R=>{de.invalidateQueries({queryKey:["/api/newsletters"]}),t({title:`Newsletter sent to ${R.sentCount} recipients`})},onError:()=>{t({title:"Failed to send newsletter",variant:"destructive"})}}),T=ye({mutationFn:async R=>{await ce("DELETE",`/api/newsletters/${R}`)},onSuccess:()=>{de.invalidateQueries({queryKey:["/api/newsletters"]}),t({title:"Newsletter deleted"})},onError:()=>{t({title:"Failed to delete newsletter",variant:"destructive"})}}),P=()=>{o(""),d(""),h(""),g("all"),v("")},I=()=>{!a||!l||!u||k.mutate({name:a,subject:l,templateId:u,audienceType:f,segmentId:f==="segment"?x:null,status:"draft"})},O=R=>{switch(R){case"draft":return"secondary";case"scheduled":return"outline";case"sending":return"default";case"sent":return"default";default:return"secondary"}};return C?e.jsxs("div",{className:"space-y-4",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx("div",{className:"grid gap-4",children:[1,2,3].map(R=>e.jsx(be,{className:"h-24"},R))})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold","data-testid":"text-newsletters-title",children:"Newsletters"}),e.jsx("p",{className:"text-muted-foreground",children:"Send bulk emails to all clients or specific segments"})]}),e.jsxs(St,{open:s,onOpenChange:n,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{"data-testid":"button-create-newsletter",children:[e.jsx(ds,{className:"h-4 w-4 mr-2"}),"Create Newsletter"]})}),e.jsxs(jt,{className:"max-w-xl",children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Create Newsletter Campaign"}),e.jsx(Gt,{children:"Set up a new newsletter to send to your audience"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Campaign Name"}),e.jsx(fe,{value:a,onChange:R=>o(R.target.value),placeholder:"e.g., December Product Update","data-testid":"input-newsletter-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Subject Line"}
206),e.jsx(fe,{value:l,onChange:R=>d(R.target.value),placeholder:"e.g., Exciting news from our team","data-testid":"input-newsletter-subject"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Email Template"}),e.jsxs(lt,{value:u,onValueChange:h,children:[e.jsx(it,{"data-testid":"select-newsletter-template",children:e.jsx(ct,{placeholder:"Select a template..."})}),e.jsx(ot,{children:j?.map(R=>e.jsx(me,{value:R.id,children:R.name},R.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Audience"}),e.jsxs(lt,{value:f,onValueChange:R=>g(R),children:[e.jsx(it,{"data-testid":"select-newsletter-audience",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"all",children:"All Clients"}),e.jsx(me,{value:"segment",children:"Specific Segment"})]})]})]}),f==="segment"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Select Segment"}),e.jsxs(lt,{value:x,onValueChange:v,children:[e.jsx(it,{"data-testid":"select-newsletter-segment",children:e.jsx(ct,{placeholder:"Choose a segment..."})}),e.jsx(ot,{children:b?.map(R=>e.jsxs(me,{value:R.id,children:[R.name," (",R.memberCount||0," clients)"]},R.id))})]})]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>{n(!1),P()},children:"Cancel"}),e.jsxs(D,{onClick:I,disabled:!a||!l||!u||f==="segment"&&!x||k.isPending,"data-testid":"button-save-newsletter",children:[k.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Create Campaign"]})]})]})]})]}),w?.length===0?e.jsxs(ee,{className:"p-12 text-center",children:[e.jsx(wN,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No newsletters yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first newsletter campaign to reach your audience"})]}):e.jsx("div",{className:"grid gap-4",children:w?.map(R=>e.jsxs(ee,{"data-testid":`card-newsletter-${R.id}`,children:[e.jsxs(qe,{className:"flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tt,{className:"text-lg",children:R.name}),e.jsx(Ce,{variant:O(R.status),children:R.status})]}),e.jsxs(Tt,{className:"mt-1",children:["Subject: ",R.subject]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[R.status==="sent"&&e.jsxs(Ce,{variant:"outline",children:[e.jsx(el,{className:"h-3 w-3 mr-1"}),R.sentCount||0," sent"]}),R.status==="draft"&&e.jsxs(D,{size:"sm",onClick:()=>N.mutate(R.id),disabled:N.isPending,"data-testid":`button-send-newsletter-${R.id}`,children:[N.isPending?e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(el,{className:"h-4 w-4 mr-2"}),"Send Now"]}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>T.mutate(R.id),disabled:R.status==="sending","data-testid":`button-delete-newsletter-${R.id}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]}),e.jsx(te,{children:e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Lm,{className:"h-4 w-4"}),R.audienceType==="all"?"All Clients":"Segment"]}),R.totalRecipients!==null&&R.totalRecipients>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Bs,{className:"h-4 w-4"}),R.totalRecipients," recipients"]}),R.sentAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vi,{className:"h-4 w-4"}),"Sent ",Nr(new Date(R.sentAt),"PPp")]})]})})]},R.id))})]})}function tz({onCreateAnnouncement:t,onEditAnnouncement:s}){const{toast:n}=dt(),{data:a,isLoading:o}=je({queryKey:["/api/portal-popups"]}),l=ye({mutationFn:async g=>{await ce("DELETE",`/api/portal-popups/${g}`)},onSuccess:()=>{de.invalidateQueries({queryKey:["/api/portal-popups"]}),n({title:"Announcement deleted"})},onError:()=>{n({title:"Failed to delete announcement",variant:"destructive"})}}),d={first_login:"First Login",once:"Once",always:"Always"},u={any:"Any Plan",diy:"Outliner Platform"},h={any:"Any Role",admin:"Admin",manager:"Manager",editor:"Editor",viewer:"Viewer"}
206,f={portal:"Client Portal Only",homepage:"Homepage Only",both:"Both Portal & Homepage"};return o?e.jsxs("div",{className:"space-y-4",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx("div",{className:"grid gap-4",children:[1,2,3].map(g=>e.jsx(be,{className:"h-24"},g))})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold","data-testid":"text-announcements-title",children:"Announcements"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage announcements shown to users"})]}),e.jsxs(D,{onClick:t,"data-testid":"button-create-announcement",children:[e.jsx(ds,{className:"h-4 w-4 mr-2"}),"Create Announcement"]})]}),a?.length===0?e.jsxs(ee,{className:"p-12 text-center",children:[e.jsx(no,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No announcements yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first announcement to engage users"})]}):e.jsx("div",{className:"grid gap-4",children:a?.map(g=>e.jsxs(ee,{"data-testid":`card-announcement-${g.id}`,children:[e.jsxs(qe,{className:"flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tt,{className:"text-lg",children:g.name}),e.jsx(Ce,{variant:g.isActive?"default":"secondary",children:g.isActive?"Active":"Inactive"})]}),e.jsx(Tt,{className:"mt-1",children:g.title})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>s(g.id),"data-testid":`button-edit-announcement-${g.id}`,children:e.jsx(Ia,{className:"h-4 w-4"})}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>l.mutate(g.id),"data-testid":`button-delete-announcement-${g.id}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]}),e.jsx(te,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Ce,{variant:"outline",children:d[g.triggerType]||g.triggerType}),e.jsx(Ce,{variant:"outline",children:f[g.displayLocation||"portal"]}),e.jsx(Ce,{variant:"outline",children:u[g.planFilter]||g.planFilter}),e.jsx(Ce,{variant:"outline",children:h[g.roleFilter]||g.roleFilter}),g.priority!==null&&g.priority>0&&e.jsxs(Ce,{variant:"secondary",children:["Priority: ",g.priority]}),g.embedCode&&e.jsx(Ce,{variant:"secondary",children:"Has Embed"})]})})]},g.id))})]})}function sz({onBack:t}){const{toast:s}=dt(),[n,a]=m.useState(""),[o,l]=m.useState(""),[d,u]=m.useState(""),[h,f]=m.useState(""),[g,x]=m.useState(""),[v,w]=m.useState(""),[C,j]=m.useState("once"),[b,k]=m.useState("any"),[N,T]=m.useState("any"),[P,I]=m.useState("portal"),[O,R]=m.useState(!0),[F,M]=m.useState(0),[z,H]=m.useState(!1),V=ye({mutationFn:async _=>(await ce("POST","/api/portal-popups",_)).json(),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/portal-popups"]}),s({title:"Announcement created"}),t()},onError:()=>{s({title:"Failed to create announcement",variant:"destructive"})}}),B=()=>{!n||!o||V.mutate({name:n,title:o,message:d||void 0,embedCode:h||void 0,buttonText:g||void 0,buttonUrl:v||void 0,triggerType:C,planFilter:b,roleFilter:N,displayLocation:P,isActive:O,priority:F})},Y={first_login:"First Login",once:"Once",always:"Always"},L={any:"Any Plan",diy:"Outliner Platform"},K={any:"Any Role",admin:"Admin",manager:"Manager",editor:"Editor",viewer:"Viewer"};return e.jsxs("div",{className:"space-y-6 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(D,{variant:"ghost",size:"icon",onClick:t,"data-testid":"button-back-announcements",children:e.jsx(kn,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold","data-testid":"text-create-announcement-title",children:"Create Announcement"}),e.jsx("p",{className:"text-muted-foreground",children:"Configure an announcement to display to users"})]})]}),e.jsx(ee,{children:e.jsxs(te,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"create-name",children:"Internal Name"}),e.jsx(fe,{id:"create-name",value:n,onChange:_=>a(_.target.value),placeholder:"e.g., onboarding-call-cta","data-testid":"input-announcement-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"create-title",children:"Display Title"}),e.jsx(fe,{id:"create-title",value:o,onChange:_=>l(_.target.value),placeholder:"e.g., Schedule Your Onboarding Call","data-testid":"input-announcement-title"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"create-message",children:"Message (optional)"}),e.jsx(ss,{id:"create-message",value:d,onChange:_=>u(_.target.value),placeholder:"Optional message to display...","data-testid":"input-announcement-message"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"create-embed",children:"Embed Code (optional)"}),e.jsx(ss,{id:"create-embed",value:h,onChange:_=>f(_.target.value),placeholder:"Paste embed code here (e.g., Cal.com booking widget)...",className:"font-mono text-sm","data-testid":"input-announcement-embed-code"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"create-button-text",children:"Button Text (optional)"}),e.jsx(fe,{id:"create-button-text",value:g,onChange:_=>x(_.target.value),placeholder:"e.g., Schedule a Call","data-testid":"input-announcement-button-text"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"create-button-url",children:"Button URL (optional)"}
206),e.jsx(fe,{id:"create-button-url",value:v,onChange:_=>w(_.target.value),placeholder:"e.g., https://cal.com/...","data-testid":"input-announcement-button-url"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Trigger Type"}),e.jsxs(lt,{value:C,onValueChange:j,children:[e.jsx(it,{"data-testid":"select-announcement-trigger-type",children:e.jsx(ct,{})}),e.jsx(ot,{children:dk.map(_=>e.jsx(me,{value:_,children:Y[_]||_},_))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Display Location"}),e.jsxs(lt,{value:P,onValueChange:I,children:[e.jsx(it,{"data-testid":"select-announcement-display-location",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"portal",children:"Client Portal Only"}),e.jsx(me,{value:"homepage",children:"Homepage Only"}),e.jsx(me,{value:"both",children:"Both Portal & Homepage"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Plan Filter"}),e.jsxs(lt,{value:b,onValueChange:k,children:[e.jsx(it,{"data-testid":"select-announcement-plan-filter",children:e.jsx(ct,{})}),e.jsx(ot,{children:mk.map(_=>e.jsx(me,{value:_,children:L[_]||_},_))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Role Filter"}),e.jsxs(lt,{value:N,onValueChange:T,children:[e.jsx(it,{"data-testid":"select-announcement-role-filter",children:e.jsx(ct,{})}),e.jsx(ot,{children:uk.map(_=>e.jsx(me,{value:_,children:K[_]||_},_))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"create-priority",children:"Priority"}),e.jsx(fe,{id:"create-priority",type:"number",value:F,onChange:_=>M(parseInt(_.target.value)||0),placeholder:"0","data-testid":"input-announcement-priority"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Higher priority announcements are shown first"})]}),e.jsxs("div",{className:"flex items-center justify-between space-y-0 pt-6",children:[e.jsx(Z,{children:"Active"}),e.jsx(As,{checked:O,onCheckedChange:R,"data-testid":"switch-announcement-active"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsxs(D,{variant:"outline",onClick:()=>H(!0),"data-testid":"button-preview-announcement",children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsx(D,{variant:"outline",onClick:t,"data-testid":"button-cancel-announcement",children:"Cancel"}),e.jsxs(D,{onClick:B,disabled:!n||!o||V.isPending,"data-testid":"button-save-announcement",children:[V.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Create Announcement"]})]})]})}),e.jsx(St,{open:z,onOpenChange:H,children:e.jsxs(jt,{className:"max-w-2xl max-h-[90vh] overflow-hidden flex flex-col","data-testid":"dialog-announcement-preview",children:[e.jsx(wt,{className:"flex-shrink-0",children:e.jsx(bt,{"data-testid":"text-preview-title",children:o||"Untitled Announcement"})}),e.jsxs("div",{className:"flex-1 overflow-auto space-y-4",children:[d&&e.jsx("div",{className:"text-muted-foreground whitespace-pre-wrap","data-testid":"text-preview-message",children:d}),h&&e.jsx("div",{className:"w-full min-h-[300px] rounded-lg overflow-hidden",dangerouslySetInnerHTML:{__html:h},"data-testid":"container-preview-embed"}),g&&v&&e.jsx("div",{className:"flex justify-center",children:e.jsx(D,{asChild:!0,children:e.jsx("a",{href:v,target:"_blank",rel:"noopener noreferrer",children:g})})}),!d&&!h&&e.jsx("p",{className:"text-muted-foreground italic",children:"No message or embed code provided yet."})]}),e.jsx("div",{className:"flex-shrink-0 pt-4 border-t",children:e.jsx(D,{onClick:()=>H(!1),className:"w-full","data-testid":"button-close-preview",children:"Close Preview"})})]})})]})}function nz({announcementId:t,onBack:s}){const{toast:n}=dt(),[a,o]=m.useState(""),[l,d]=m.useState(""),[u,h]=m.useState(""),[f,g]=m.useState(""),[x,v]=m.useState(""),[w,C]=m.useState(""),[j,b]=m.useState("once"),[k,N]=m.useState("any"),[T,P]=m.useState("any"),[I,O]=m.useState("portal"),[R,F]=m.useState(!0),[M,z]=m.useState(0),[H,V]=m.useState(!1),[B,Y]=m.useState(!1),{data:L,isLoading:K}=je({queryKey:["/api/portal-popups",t],enabled:!!t});m.useEffect(()=>{L&&!H&&(o(L.name),d(L.title),h(L.message||""),g(L.embedCode||""),v(L.buttonText||""),C(L.buttonUrl||""),b(L.triggerType),N(L.planFilter),P(L.roleFilter),O(L.displayLocation||"portal"),F(L.isActive??!0),z(L.priority??0),V(!0))},[L,H]);const _=ye({mutationFn:async Q=>(await ce("PATCH",`/api/portal-popups/${t}`,Q)).json(),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/portal-popups"]}),n({title:"Announcement updated"}),s()},onError:()=>{n({title:"Failed to update announcement",variant:"destructive"})}}),$=()=>{!a||!l||_.mutate({name:a,title:l,message:u||void 0,embedCode:f||void 0,buttonText:x||void 0,buttonUrl:w||void 0,triggerType:j,planFilter:k,roleFilter:T,displayLocation:I,isActive:R,priority:M})},A={first_login:"First Login",once:"Once",always:"Always"},W={any:"Any Plan",diy:"Outliner Platform"},U={any:"Any Role",admin:"Admin",manager:"Manager",editor:"Editor",viewer:"Viewer"};return K||!L?e.jsxs("div",{className:"space-y-6 max-w-3xl",children:[e.jsx(be,{className:"h-10 w-64"}),e.jsx(ee,{children:e.jsxs(te,{className:"pt-6 space-y-6",children:[e.jsx(be,{className:"h-10 w-full"}),e.jsx(be,{className:"h-10 w-full"}),e.jsx(be,{className:"h-24 w-full"})]})})]}):e.jsxs("div",{className:"space-y-6 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(D,{variant:"ghost",size:"icon",onClick:s,"data-testid":"button-back-announcements",children:e.jsx(kn,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold","data-testid":"text-edit-announcement-title",children:"Edit Announcement"}),e.jsx("p",{className:"text-muted-foreground",children:"Update the announcement configuration"})]})]}),e.jsx(ee,{children:e.jsxs(te,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-name",children:"Internal Name"}),e.jsx(fe,{id:"edit-name",value:a,onChange:Q=>o(Q.target.value),placeholder:"e.g., onboarding-call-cta","data-testid":"input-announcement-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-title",children:"Display Title"}
206),e.jsx(fe,{id:"edit-title",value:l,onChange:Q=>d(Q.target.value),placeholder:"e.g., Schedule Your Onboarding Call","data-testid":"input-announcement-title"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-message",children:"Message (optional)"}),e.jsx(ss,{id:"edit-message",value:u,onChange:Q=>h(Q.target.value),placeholder:"Optional message to display...","data-testid":"input-announcement-message"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-embed",children:"Embed Code (optional)"}),e.jsx(ss,{id:"edit-embed",value:f,onChange:Q=>g(Q.target.value),placeholder:"Paste embed code here (e.g., Cal.com booking widget)...",className:"font-mono text-sm","data-testid":"input-announcement-embed-code"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-button-text",children:"Button Text (optional)"}),e.jsx(fe,{id:"edit-button-text",value:x,onChange:Q=>v(Q.target.value),placeholder:"e.g., Schedule a Call","data-testid":"input-announcement-button-text"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-button-url",children:"Button URL (optional)"}),e.jsx(fe,{id:"edit-button-url",value:w,onChange:Q=>C(Q.target.value),placeholder:"e.g., https://cal.com/...","data-testid":"input-announcement-button-url"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Trigger Type"}),e.jsxs(lt,{value:j,onValueChange:b,children:[e.jsx(it,{"data-testid":"select-announcement-trigger-type",children:e.jsx(ct,{})}),e.jsx(ot,{children:dk.map(Q=>e.jsx(me,{value:Q,children:A[Q]||Q},Q))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Display Location"}),e.jsxs(lt,{value:I,onValueChange:O,children:[e.jsx(it,{"data-testid":"select-announcement-display-location",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"portal",children:"Client Portal Only"}),e.jsx(me,{value:"homepage",children:"Homepage Only"}),e.jsx(me,{value:"both",children:"Both Portal & Homepage"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Plan Filter"}),e.jsxs(lt,{value:k,onValueChange:N,children:[e.jsx(it,{"data-testid":"select-announcement-plan-filter",children:e.jsx(ct,{})}),e.jsx(ot,{children:mk.map(Q=>e.jsx(me,{value:Q,children:W[Q]||Q},Q))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Role Filter"}),e.jsxs(lt,{value:T,onValueChange:P,children:[e.jsx(it,{"data-testid":"select-announcement-role-filter",children:e.jsx(ct,{})}),e.jsx(ot,{children:uk.map(Q=>e.jsx(me,{value:Q,children:U[Q]||Q},Q))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"edit-priority",children:"Priority"}),e.jsx(fe,{id:"edit-priority",type:"number",value:M,onChange:Q=>z(parseInt(Q.target.value)||0),placeholder:"0","data-testid":"input-announcement-priority"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Higher priority announcements are shown first"})]}),e.jsxs("div",{className:"flex items-center justify-between space-y-0 pt-6",children:[e.jsx(Z,{children:"Active"}),e.jsx(As,{checked:R,onCheckedChange:F,"data-testid":"switch-announcement-active"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsxs(D,{variant:"outline",onClick:()=>Y(!0),"data-testid":"button-preview-announcement",children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsx(D,{variant:"outline",onClick:s,"data-testid":"button-cancel-announcement",children:"Cancel"}),e.jsxs(D,{onClick:$,disabled:!a||!l||_.isPending,"data-testid":"button-update-announcement",children:[_.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Changes"]})]})]})}),e.jsx(St,{open:B,onOpenChange:Y,children:e.jsxs(jt,{className:"max-w-2xl max-h-[90vh] overflow-hidden flex flex-col","data-testid":"dialog-announcement-preview",children:[e.jsx(wt,{className:"flex-shrink-0",children:e.jsx(bt,{"data-testid":"text-preview-title",children:l||"Untitled Announcement"})}),e.jsxs("div",{className:"flex-1 overflow-auto space-y-4",children:[u&&e.jsx("div",{className:"text-muted-foreground whitespace-pre-wrap","data-testid":"text-preview-message",children:u}),f&&e.jsx("div",{className:"w-full min-h-[300px] rounded-lg overflow-hidden",dangerouslySetInnerHTML:{__html:f},"data-testid":"container-preview-embed"}),x&&w&&e.jsx("div",{className:"flex justify-center",children:e.jsx(D,{asChild:!0,children:e.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",children:x})})}),!u&&!f&&e.jsx("p",{className:"text-muted-foreground italic",children:"No message or embed code provided yet."})]}),e.jsx("div",{className:"flex-shrink-0 pt-4 border-t",children:e.jsx(D,{onClick:()=>Y(!1),className:"w-full","data-testid":"button-close-preview",children:"Close Preview"})})]})})]})}function rz(){const{toast:t}=dt(),{user:s}=Da(),[n,a]=m.useState(!1),[o,l]=m.useState(null),[d,u]=m.useState(""),[h,f]=m.useState(""),[g,x]=m.useState(""),[v,w]=m.useState(""),[C,j]=m.useState(""),[b,k]=m.useState("admin"),N=s?.role==="super_admin"||s?.role==="admin",{data:T=[],isLoading:P}=je({queryKey:["/api/users"]}),I=ye({mutationFn:async B=>{const Y=await ce("POST","/api/auth/admin-reset-password",{targetUserId:B,initiatedByUserId:s?.id});if(!Y.ok){const L=await Y.json();throw new Error(L.error||"Failed to reset password")}return Y.json()},onSuccess:()=>{t({title:"Password reset email sent",description:"The user will receive an email to set a new password."})},onError:B=>{t({title:"Failed to reset password",description:B.message,variant:"destructive"})}}),O=ye({mutationFn:async B=>await ce("POST","/api/users",B),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/users"]}),a(!1),M(),t({title:"User created successfully"})},onError:B=>{t({title:"Failed to create user",description:B.message,variant:"destructive"})}}),R=ye({mutationFn:async({id:B,data:Y})=>await ce("PATCH",`/api/users/${B}`,Y),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/users"]}),l(null),M(),t({title:"User updated successfully"})},onError:B=>{t({title:"Failed to update user",description:B.message,variant:"destructive"})}}),F=ye({mutationFn:async B=>{await ce("DELETE",`/api/users/${B}`)},onSuccess:()=>{de.invalidateQueries({queryKey:["/api/users"]}),t({title:"User deleted successfully"})},onError:B=>{t({title:"Failed to delete user",description:B.message,variant:"destructive"})}}),M=()=>{u(""),f(""),x(""),w(""),j(""),k("admin")},z=()=>{!d||!h||!g||!v||!C||O.mutate({username:d,email:h,password:g,firstName:v,lastName:C,role:b})},H=()=>
206{if(!o)return;const B={username:d,email:h,firstName:v,lastName:C,role:b};g&&(B.password=g),R.mutate({id:o.id,data:B})},V=B=>{l(B),u(B.username),f(B.email),w(B.firstName),j(B.lastName),k(B.role),x("")};return P?e.jsxs("div",{className:"space-y-4 max-w-4xl",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx(be,{className:"h-64 w-full"})]}):e.jsxs("div",{className:"space-y-6 max-w-4xl",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-serif text-2xl font-normal tracking-tight",children:"Platform Users"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage users who have access to the admin platform"})]}),e.jsxs(St,{open:n,onOpenChange:B=>{a(B),B||M()},children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{"data-testid":"button-create-platform-user",children:[e.jsx(ds,{className:"h-4 w-4 mr-2"}),"Add User"]})}),e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Create Platform User"}),e.jsx(Gt,{children:"Add a new user to the admin platform"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"First Name"}),e.jsx(fe,{value:v,onChange:B=>w(B.target.value),placeholder:"John","data-testid":"input-user-first-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Last Name"}),e.jsx(fe,{value:C,onChange:B=>j(B.target.value),placeholder:"Doe","data-testid":"input-user-last-name"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Username"}),e.jsx(fe,{value:d,onChange:B=>u(B.target.value),placeholder:"johndoe","data-testid":"input-user-username"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Email"}),e.jsx(fe,{type:"email",value:h,onChange:B=>f(B.target.value),placeholder:"[email protected]","data-testid":"input-user-email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Password"}),e.jsx(fe,{type:"password",value:g,onChange:B=>x(B.target.value),placeholder:"Enter password","data-testid":"input-user-password"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Role"}),e.jsxs(lt,{value:b,onValueChange:B=>k(B),children:[e.jsx(it,{"data-testid":"select-user-role",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"super_admin",children:"Super Admin"}),e.jsx(me,{value:"admin",children:"Admin"}),e.jsx(me,{value:"support",children:"Support"}),e.jsx(me,{value:"billing",children:"Billing"})]})]})]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>{a(!1),M()},children:"Cancel"}),e.jsxs(D,{onClick:z,disabled:!d||!h||!g||!v||!C||O.isPending,"data-testid":"button-save-user",children:[O.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Create User"]})]})]})]})]}),T.length===0?e.jsxs(ee,{className:"p-12 text-center",children:[e.jsx(Ag,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No platform users yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Add your first platform user to get started"})]}):e.jsx("div",{className:"grid gap-4",children:T.map(B=>e.jsxs(ee,{"data-testid":`card-platform-user-${B.id}`,children:[e.jsxs(qe,{className:"flex flex-row items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center text-lg font-semibold",children:B.firstName?.charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsxs(tt,{className:"text-base",children:[B.firstName," ",B.lastName]}),e.jsx(Tt,{children:B.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:"secondary",children:Tx[B.role]||B.role}),N&&e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>I.mutate(B.id),disabled:I.isPending,title:"Reset Password","data-testid":`button-reset-password-${B.id}`,children:e.jsx(lE,{className:"h-4 w-4"})}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>V(B),"data-testid":`button-edit-user-${B.id}`,children:e.jsx(Ia,{className:"h-4 w-4"})}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>F.mutate(B.id),disabled:F.isPending,"data-testid":`button-delete-user-${B.id}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]}),e.jsx(te,{children:e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Hr,{className:"h-4 w-4"}),"@",B.username]}),B.createdAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vi,{className:"h-4 w-4"}),"Joined ",Nr(new Date(B.createdAt),"PP")]})]})})]},B.id))}),e.jsx(St,{open:!!o,onOpenChange:B=>{B||(l(null),M())},children:e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Edit User"}),e.jsx(Gt,{children:"Update user details"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"First Name"}
206),e.jsx(fe,{value:v,onChange:B=>w(B.target.value),"data-testid":"input-edit-user-first-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Last Name"}),e.jsx(fe,{value:C,onChange:B=>j(B.target.value),"data-testid":"input-edit-user-last-name"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Username"}),e.jsx(fe,{value:d,onChange:B=>u(B.target.value),"data-testid":"input-edit-user-username"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Email"}),e.jsx(fe,{type:"email",value:h,onChange:B=>f(B.target.value),"data-testid":"input-edit-user-email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Role"}),e.jsxs(lt,{value:b,onValueChange:B=>k(B),children:[e.jsx(it,{"data-testid":"select-edit-user-role",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"super_admin",children:"Super Admin"}),e.jsx(me,{value:"admin",children:"Admin"}),e.jsx(me,{value:"support",children:"Support"}),e.jsx(me,{value:"billing",children:"Billing"})]})]})]})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>{l(null),M()},children:"Cancel"}),e.jsxs(D,{onClick:H,disabled:!d||!h||!v||!C||R.isPending,"data-testid":"button-update-user",children:[R.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Changes"]})]})]})})]})}function az(){const{toast:t}=dt(),{user:s,isLoading:n}=Da(),[a,o]=m.useState(""),[l,d]=m.useState(""),[u,h]=m.useState(""),[f,g]=m.useState(!1),x=ye({mutationFn:async w=>(await ce("POST","/api/auth/request-password-change",w)).json(),onSuccess:()=>{t({title:"Verification Email Sent",description:"Please check your inbox and click the verification link to complete your password change."}),o(""),d(""),h(""),g(!1)},onError:w=>{t({title:"Failed to Request Password Change",description:w.message,variant:"destructive"})}}),v=()=>{if(!a||!l||!u){t({title:"Missing Fields",description:"Please fill in all password fields.",variant:"destructive"});return}if(l!==u){t({title:"Passwords Don't Match",description:"New password and confirmation must match.",variant:"destructive"});return}if(l.length<8){t({title:"Password Too Short",description:"Password must be at least 8 characters.",variant:"destructive"});return}s?.id&&x.mutate({userId:s.id,currentPassword:a,newPassword:l})};return n?e.jsxs("div",{className:"space-y-6 max-w-2xl",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx(ee,{children:e.jsxs(te,{className:"p-6 space-y-4",children:[e.jsx(be,{className:"h-10 w-full"}),e.jsx(be,{className:"h-10 w-full"}),e.jsx(be,{className:"h-10 w-full"})]})})]}):s?e.jsxs("div",{className:"space-y-6 max-w-2xl",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"My Profile"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage your account settings"})]}),e.jsxs(ee,{children:[e.jsx(qe,{children:e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(Hr,{className:"h-5 w-5"}),"Account Information"]})}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(Z,{className:"text-muted-foreground text-sm",children:"First Name"}),e.jsx("p",{className:"font-medium","data-testid":"text-profile-first-name",children:s.firstName})]}),e.jsxs("div",{children:[e.jsx(Z,{className:"text-muted-foreground text-sm",children:"Last Name"}),e.jsx("p",{className:"font-medium","data-testid":"text-profile-last-name",children:s.lastName})]})]}),e.jsxs("div",{children:[e.jsx(Z,{className:"text-muted-foreground text-sm",children:"Username"}),e.jsxs("p",{className:"font-medium","data-testid":"text-profile-username",children:["@",s.username]})]}),e.jsxs("div",{children:[e.jsx(Z,{className:"text-muted-foreground text-sm",children:"Email"}),e.jsx("p",{className:"font-medium","data-testid":"text-profile-email",children:s.email})]}),e.jsxs("div",{children:[e.jsx(Z,{className:"text-muted-foreground text-sm",children:"Role"}),e.jsx(Ce,{variant:"secondary",className:"mt-1","data-testid":"badge-profile-role",children:Tx[s.role]||s.role})]})]})]}),e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(Pn,{className:"h-5 w-5"}),"Change Password"]}),e.jsx(Tt,{children:"For security, password changes require email verification"})]}),e.jsx(te,{className:"space-y-4",children:f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"current-password",children:"Current Password"}),e.jsx(fe,{id:"current-password",type:"password",value:a,onChange:w=>o(w.target.value),placeholder:"Enter your current password","data-testid":"input-current-password"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"new-password",children:"New Password"}
206),e.jsx(fe,{id:"new-password",type:"password",value:l,onChange:w=>d(w.target.value),placeholder:"Enter new password (min 8 characters)","data-testid":"input-new-password"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"confirm-password",children:"Confirm New Password"}),e.jsx(fe,{id:"confirm-password",type:"password",value:u,onChange:w=>h(w.target.value),placeholder:"Confirm new password","data-testid":"input-confirm-password"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{variant:"outline",onClick:()=>{g(!1),o(""),d(""),h("")},"data-testid":"button-cancel-password-change",children:"Cancel"}),e.jsxs(D,{onClick:v,disabled:x.isPending||!a||!l||!u,"data-testid":"button-submit-password-change",children:[x.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Request Password Change"]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["A verification email will be sent to ",s.email,". Click the link in the email to complete the password change."]})]}):e.jsx(D,{onClick:()=>g(!0),"data-testid":"button-start-password-change",children:"Change Password"})})]})]}):e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-muted-foreground",children:"Unable to load profile"})})}const iz=[{key:"account.registered_paid",label:"Account Registered/Paid",category:"Stripe"},{key:"account.renewed",label:"Account Renewed",category:"Stripe"},{key:"account.canceled",label:"Account Canceled",category:"Stripe"},{key:"user.added_to_account",label:"User Added to Account",category:"User Management"},{key:"procedure.created",label:"Procedure Created",category:"Procedures"},{key:"procedure.updated",label:"Procedure Updated",category:"Procedures"},{key:"procedure.deleted",label:"Procedure Deleted",category:"Procedures"},{key:"overview.created",label:"Overview Created",category:"Overviews"},{key:"overview.updated",label:"Overview Updated",category:"Overviews"},{key:"overview.deleted",label:"Overview Deleted",category:"Overviews"},{key:"kb.created",label:"Knowledge Base Created",category:"Knowledge Bases"},{key:"kb.updated",label:"Knowledge Base Updated",category:"Knowledge Bases"},{key:"kb.deleted",label:"Knowledge Base Deleted",category:"Knowledge Bases"}];function oz(){const{toast:t}=dt(),{user:s}=Da(),{data:n,isLoading:a}=je({queryKey:[`/api/admin/notification-preferences/${s?.id}`],enabled:!!s?.id}),{data:o,isLoading:l}=je({queryKey:[`/api/admin/notifications/${s?.id}`],enabled:!!s?.id}),{data:d}=je({queryKey:[`/api/admin/notifications/${s?.id}/unread-count`],enabled:!!s?.id}),u=ye({mutationFn:async w=>{if(!s?.id)throw new Error("Not authenticated");return await ce("POST","/api/admin/notification-preferences",{...w,userId:s.id})},onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/admin/notification-preferences/${s?.id}`]}),t({title:"Preference updated"})},onError:()=>{t({title:"Failed to update preference",variant:"destructive"})}}),h=ye({mutationFn:async w=>await ce("PATCH",`/api/admin/notifications/${w}/read`),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/admin/notifications/${s?.id}`]}),de.invalidateQueries({queryKey:[`/api/admin/notifications/${s?.id}/unread-count`]})}}),f=ye({mutationFn:async()=>{if(!s?.id)throw new Error("Not authenticated");return await ce("POST",`/api/admin/notifications/${s.id}/mark-all-read`)},onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/admin/notifications/${s?.id}`]}),de.invalidateQueries({queryKey:[`/api/admin/notifications/${s?.id}/unread-count`]}),t({title:"All notifications marked as read"})}}),g=w=>n?.find(j=>j.eventType===w)||{emailEnabled:!1,inAppEnabled:!0},x=(w,C,j)=>{const b=g(w);u.mutate({eventType:w,emailEnabled:C==="emailEnabled"?j:b.emailEnabled,inAppEnabled:C==="inAppEnabled"?j:b.inAppEnabled})},v=iz.reduce((w,C)=>(w[C.category]||(w[C.category]=[]),w[C.category].push(C),w),{});return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold","data-testid":"text-notifications-title",children:"Notifications"}),e.jsx("p",{className:"text-muted-foreground",children:"View your notifications and manage preferences"})]}),e.jsxs(Ma,{defaultValue:"inbox",className:"w-full",children:[e.jsxs(ha,{children:[e.jsxs(ls,{value:"inbox",className:"relative","data-testid":"tab-inbox",children:["Inbox",(d?.count||0)>0&&e.jsx(Ce,{variant:"destructive",className:"ml-2 h-5 min-w-5 text-xs",children:d?.count})]}),e.jsx(ls,{value:"preferences","data-testid":"tab-preferences",children:"Preferences"})]}),e.jsx(Ss,{value:"preferences",className:"space-y-6 mt-4",children:a?e.jsx("div",{className:"space-y-4",children:[1,2,3].map(w=>e.jsx(be,{className:"h-32 w-full"},w))}):Object.entries(v).map(([w,C])=>e.jsxs(ee,{children:[e.jsx(qe,{children:e.jsx(tt,{className:"text-lg",children:w})}),e.jsx(te,{children:e.jsx("div",{className:"space-y-4",children:C.map(j=>{const b=g(j.key);return e.jsxs("div",{className:"flex items-center justify-between py-3 border-b last:border-0","data-testid":`pref-row-${j.key}`,children:[e.jsx("div",{children:e.jsx("p",{className:"font-medium",children:j.label})}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{htmlFor:`email-${j.key}`,className:"text-sm text-muted-foreground",children:"Email"}),e.jsx(As,{id:`email-${j.key}`,checked:b.emailEnabled,onCheckedChange:k=>x(j.key,"emailEnabled",k),"data-testid":`switch-email-${j.key}`})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{htmlFor:`inapp-${j.key}`,className:"text-sm text-muted-foreground",children:"In-App"}),e.jsx(As,{id:`inapp-${j.key}`,checked:b.inAppEnabled,onCheckedChange:k=>x(j.key,"inAppEnabled",k),"data-testid":`switch-inapp-${j.key}`})]})]})]},j.key)})})})]},w))}),e.jsx(Ss,{value:"inbox",className:"mt-4",children:e.jsxs(ee,{children:[e.jsxs(qe,{className:"flex flex-row items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(tt,{children:"Notification Inbox"}),e.jsx(Tt,{children:"Your recent notifications"})]}),(d?.count||0)>0&&e.jsx(D,{variant:"outline",size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,"data-testid":"button-mark-all-read",children:"Mark All Read"})]}),e.jsx(te,{children:l?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(w=>e.jsx(be,{className:"h-16 w-full"},w))}):o?.length?e.jsx(jl,{className:"h-[500px]",children:e.jsx("div",{className:"space-y-2",children:o.map(w=>e.jsx("div",{className:`p-4 rounded-lg border ${w.isRead?"":"bg-muted/50"}`,"data-testid":`notification-${w.id}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[!w.isRead&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-primary"}),e.jsx("p",{className:"font-medium",children:w.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:w.message}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:Nr(new Date(w.createdAt),"MMM d, yyyy 'at' h:mm a")})]}),!w.isRead&&e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>h.mutate(w.id),disabled:h.isPending,"data-testid":`button-mark-read-${w.id}`,children:e.jsx(yr,{className:"h-4 w-4"})})]})},w.id))})}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(nE,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"No notifications yet"})]})})]})})]})]})}function lz(){const{toast:t}=dt(),{user:s}=Da(),[n,a]=m.useState(""),[o,l]=m.useState(""),[d,u]=m.useState(""),[h,f]=m.useState("summary_large_image"),[g,x]=m.useState(""),[v,w]=m.useState(""),[C,j]=m.useState(""),[b,k]=m.useState(""),[N,T]=m.useState(!1),[P,I]=m.useState(!1),[O,R]=m.useState(!1),[F,M]=m.useState(!1),z=m.useRef(null),H=m.useRef(null),{data:V,isLoading:B}=je({queryKey:["/api/site-settings"]});m.useEffect(()=>{V&&(a(V.siteTitle||""),l(V.siteDescription||""),u(V.ogImageUrl||""),f(V.twitterCardType||"summary_large_image"),x(V.twitterSite||""),w(V.twitterTitle||""),j(V.twitterDescription||""),k(V.twitterImage||""),(V.twitterTitle||V.twitterDescription||V.twitterImage||V.twitterSite)&&T(!0))},[V]);const Y=async _=>{if(_){R(!0);try{const $=await fetch("/api/uploads/request-url",{method:"POST",headers:{"Content-Type":"application/json"}
206,credentials:"include",body:JSON.stringify({name:_.name,size:_.size,contentType:_.type,mediaType:"og-image"})});if(!$.ok)throw new Error("Failed to get upload URL");const{uploadURL:A,objectPath:W}=await $.json();if(!(await fetch(A,{method:"PUT",body:_,headers:{"Content-Type":_.type}})).ok)throw new Error("Failed to upload image");u(W),t({title:"Image uploaded",description:"Your social sharing image has been uploaded. Don't forget to save settings."})}catch{t({title:"Upload failed",description:"Failed to upload image. Please try again.",variant:"destructive"})}finally{R(!1)}}},L=async _=>{if(_){M(!0);try{const $=await fetch("/api/uploads/request-url",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:_.name,size:_.size,contentType:_.type,mediaType:"og-image"})});if(!$.ok)throw new Error("Failed to get upload URL");const{uploadURL:A,objectPath:W}=await $.json();if(!(await fetch(A,{method:"PUT",body:_,headers:{"Content-Type":_.type}})).ok)throw new Error("Failed to upload image");k(W),t({title:"Image uploaded",description:"Your Twitter image has been uploaded. Don't forget to save settings."})}catch{t({title:"Upload failed",description:"Failed to upload image. Please try again.",variant:"destructive"})}finally{M(!1)}}},K=async()=>{I(!0);try{await ce("PUT","/api/site-settings",{siteTitle:n||null,siteDescription:o||null,ogImageUrl:d||null,twitterCardType:h||null,twitterSite:g||null,twitterTitle:v||null,twitterDescription:C||null,twitterImage:b||null,updatedBy:s?.id||null}),de.invalidateQueries({queryKey:["/api/site-settings"]}),t({title:"Settings saved",description:"Your site settings have been updated."})}catch{t({title:"Error",description:"Failed to save settings. Please try again.",variant:"destructive"})}finally{I(!1)}};return B?e.jsxs("div",{className:"space-y-4 max-w-2xl",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx(be,{className:"h-20 w-full"}),e.jsx(be,{className:"h-32 w-full"}),e.jsx(be,{className:"h-20 w-full"})]}):e.jsxs("div",{className:"space-y-6 max-w-2xl",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold","data-testid":"text-site-settings-title",children:"Site Settings"}),e.jsx("p",{className:"text-muted-foreground",children:"Configure your site's title, description, and social sharing image. These settings affect how your site appears in search results and social media previews."})]}),e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx($n,{className:"h-5 w-5"}),"SEO & Social Sharing"]}),e.jsx(Tt,{children:"These settings are used for search engine optimization and social media link previews."})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"site-title",children:"Site Title"}),e.jsx(fe,{id:"site-title",value:n,onChange:_=>a(_.target.value),placeholder:"Outliner SOPs - Document, Train, Scale Your Operations","data-testid":"input-site-title"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This appears in browser tabs and search results. Keep it under 60 characters."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"site-description",children:"Site Description"}),e.jsx(ss,{id:"site-description",value:o,onChange:_=>l(_.target.value),placeholder:"Outliner helps you document procedures, train your team, and scale your operations.",rows:3,"data-testid":"input-site-description"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for meta descriptions in search results. Keep it under 160 characters."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Social Sharing Image"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{ref:z,type:"file",accept:"image/*",className:"hidden",onChange:_=>{const $=_.target.files?.[0];$&&Y($)},"data-testid":"input-og-image-file"}),e.jsx(D,{type:"button",variant:"outline",onClick:()=>z.current?.click(),disabled:O,"data-testid":"button-upload-og-image",children:O?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(qi,{className:"h-4 w-4 mr-2"}),"Upload Image"]})}),d&&e.jsx(D,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(""),"data-testid":"button-remove-og-image",children:e.jsx(ts,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used when your site is shared on social media. Recommended size: 1200x630 pixels."}),d&&e.jsx("div",{className:"mt-3 border rounded-lg overflow-hidden",children:e.jsx("img",{src:(d.startsWith("/"),d),alt:"Social sharing preview",className:"max-h-48 w-full object-cover",onError:_=>{_.target.style.display="none"}})})]}),e.jsxs(Cn,{open:N,onOpenChange:T,className:"border rounded-lg p-4 space-y-4",children:[e.jsxs(Mn,{className:"flex items-center justify-between w-full","data-testid":"button-toggle-twitter-section",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:"Twitter/X Overrides"}),e.jsx(Ce,{variant:"outline",className:"text-xs",children:"Optional"})]}),e.jsx(On,{className:`h-4 w-4 transition-transform ${N?"rotate-180":""}`})]}),e.jsxs(Ln,{className:"space-y-4 pt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Customize how your site appears when shared on Twitter/X. Leave blank to use the default values above."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"twitter-card-type",children:"Card Type"}),e.jsxs(lt,{value:h,onValueChange:f,children:[e.jsx(it,{"data-testid":"select-twitter-card-type",children:e.jsx(ct,{placeholder:"Select card type"})}),e.jsxs(ot,{children:[e.jsx(me,{value:"summary_large_image",children:"Summary Large Image (recommended)"}),e.jsx(me,{value:"summary",children:"Summary (small square)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Large image cards show a prominent image banner. Summary cards show a small square thumbnail."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"twitter-site",children:"Twitter Handle"}),e.jsx(fe,{id:"twitter-site",value:g,onChange:_=>x(_.target.value),placeholder:"@yourhandle","data-testid":"input-twitter-site"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Twitter/X handle (e.g., @yourcompany). Shown as the content source."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"twitter-title",children:"Title Override"}
206),e.jsx(fe,{id:"twitter-title",value:v,onChange:_=>w(_.target.value),placeholder:n||"Leave blank to use default title","data-testid":"input-twitter-title"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Leave blank to use the main site title."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"twitter-description",children:"Description Override"}),e.jsx(ss,{id:"twitter-description",value:C,onChange:_=>j(_.target.value),placeholder:o||"Leave blank to use default description",rows:2,"data-testid":"input-twitter-description"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Leave blank to use the main site description."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Image Override"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{ref:H,type:"file",accept:"image/*",className:"hidden",onChange:_=>{const $=_.target.files?.[0];$&&L($)},"data-testid":"input-twitter-image-file"}),e.jsx(D,{type:"button",variant:"outline",onClick:()=>H.current?.click(),disabled:F,"data-testid":"button-upload-twitter-image",children:F?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(qi,{className:"h-4 w-4 mr-2"}),"Upload Twitter Image"]})}),b&&e.jsx(D,{type:"button",variant:"ghost",size:"sm",onClick:()=>k(""),"data-testid":"button-remove-twitter-image",children:e.jsx(ts,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Leave blank to use the main sharing image. Recommended: 1200x675 pixels."}),b&&e.jsx("div",{className:"mt-3 border rounded-lg overflow-hidden",children:e.jsx("img",{src:(b.startsWith("/"),b),alt:"Twitter image preview",className:"max-h-32 w-full object-cover",onError:_=>{_.target.style.display="none"}})})]})]})]}),e.jsx("div",{className:"pt-4 border-t",children:e.jsxs(D,{onClick:K,disabled:P,"data-testid":"button-save-site-settings",children:[P&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),e.jsx(Ki,{className:"h-4 w-4 mr-2"}),"Save Settings"]})})]})]}),e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5"}),"Preview"]}),e.jsx(Tt,{children:"How your site might appear when shared on social media"})]}),e.jsx(te,{className:"space-y-4",children:e.jsxs(Ma,{defaultValue:"facebook",className:"w-full",children:[e.jsxs(ha,{className:"grid w-full grid-cols-2",children:[e.jsx(ls,{value:"facebook","data-testid":"tab-preview-facebook",children:"Facebook / LinkedIn"}),e.jsx(ls,{value:"twitter","data-testid":"tab-preview-twitter",children:"Twitter / X"})]}),e.jsxs(Ss,{value:"facebook",className:"space-y-4 mt-4",children:[d&&e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsx("img",{src:d,alt:"Social sharing preview",className:"w-full h-40 object-cover"})}),e.jsxs("div",{className:"border rounded-lg p-4 bg-muted/30",children:[e.jsx("div",{className:"text-foreground text-lg font-medium truncate",children:n||"Outliner SOPs - Document, Train, Scale Your Operations"}),e.jsx("div",{className:"text-green-700 dark:text-green-400 text-sm truncate",children:typeof window<"u"?window.location.origin:"https://yoursite.com"}),e.jsx("div",{className:"text-muted-foreground text-sm mt-1 line-clamp-2",children:o||"Outliner helps you document procedures, train your team, and scale your operations."})]})]}),e.jsxs(Ss,{value:"twitter",className:"space-y-4 mt-4",children:[h==="summary_large_image"&&(b||d)&&e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsx("img",{src:b||d,alt:"Twitter sharing preview",className:"w-full h-40 object-cover"})}),e.jsxs("div",{className:"border rounded-lg p-4 bg-muted/30",children:[h==="summary"&&(b||d)&&e.jsx("div",{className:"float-left mr-3 mb-2",children:e.jsx("img",{src:b||d,alt:"Twitter sharing preview",className:"w-16 h-16 object-cover rounded"})}),e.jsx("div",{className:"text-foreground text-lg font-medium truncate",children:v||n||"Outliner SOPs - Document, Train, Scale Your Operations"}),e.jsx("div",{className:"text-muted-foreground text-sm mt-1 line-clamp-2",children:C||o||"Outliner helps you document procedures, train your team, and scale your operations."}),g&&e.jsx("div",{className:"text-muted-foreground text-sm mt-2",children:g})]})]})]})})]})]})}function cz(){const{toast:t}=dt(),[s,n]=m.useState("30d"),[a,o]=m.useState(null),[l,d]=m.useState("platform"),u=()=>{const C=new Date;let j;return s==="7d"?j=new Date(C.getTime()-10080*60*1e3):s==="30d"?j=new Date(C.getTime()-720*60*60*1e3):s==="90
206d"?j=new Date(C.getTime()-2160*60*60*1e3):s==="12m"&&(j=new Date(C.getTime()-365*24*60*60*1e3)),j?`startDate=${j.toISOString()}`:""},{data:h}=je({queryKey:["/api/clients"]}),{data:f,isLoading:g}=je({queryKey:["/api/admin/analytics/platform",s],queryFn:async()=>{const C=u(),j=`/api/admin/analytics/platform${C?`?${C}`:""}`,b=await fetch(j,{credentials:"include"});if(!b.ok)throw new Error("Failed to fetch");return b.json()}}),{data:x,isLoading:v}=je({queryKey:["/api/admin/analytics/client",a,s],enabled:!!a,queryFn:async()=>{const C=u(),j=`/api/admin/analytics/client/${a}${C?`?${C}`:""}`,b=await fetch(j,{credentials:"include"});if(!b.ok)throw new Error("Failed to fetch");return b.json()}}),w=async C=>{try{const j=new URLSearchParams({type:C,format:"csv"}),b=u();b&&j.append("startDate",b.replace("startDate=",""));const k=`/api/admin/analytics/export?${j.toString()}`,N=await fetch(k,{credentials:"include"});if(!N.ok)throw new Error("Export failed");const T=await N.blob(),P=URL.createObjectURL(T),I=document.createElement("a");I.href=P,I.download=`platform-analytics-${C}-${new Date().toISOString().split("T")[0]}.csv`,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(P),t({title:"Export complete"})}catch{t({title:"Export failed",variant:"destructive"})}};return e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"font-serif text-2xl md:text-3xl font-normal tracking-tight flex items-center gap-2",children:[e.jsx(Am,{className:"h-7 w-7"}),"Analytics"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Monitor platform-wide and per-client usage metrics"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(lt,{value:s,onValueChange:C=>n(C),children:[e.jsx(it,{className:"w-[140px]","data-testid":"select-admin-date-range",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"7d",children:"Last 7 days"}),e.jsx(me,{value:"30d",children:"Last 30 days"}),e.jsx(me,{value:"90d",children:"Last 90 days"}),e.jsx(me,{value:"12m",children:"Last 12 months"}),e.jsx(me,{value:"all",children:"All time"})]})]})})]}),e.jsxs(Ma,{value:l,onValueChange:C=>d(C),children:[e.jsxs(ha,{children:[e.jsx(ls,{value:"platform","data-testid":"tab-platform",children:"Platform Overview"}),e.jsx(ls,{value:"clients","data-testid":"tab-clients",children:"Per-Client Analytics"})]}),e.jsx(Ss,{value:"platform",className:"space-y-6 mt-4",children:g?e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(be,{className:"h-24"}),e.jsx(be,{className:"h-24"}),e.jsx(be,{className:"h-24"}),e.jsx(be,{className:"h-24"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(ee,{children:e.jsx(te,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Logins"}),e.jsx("p",{className:"text-2xl font-bold",children:f?.eventStats?.totalLogins?.toLocaleString()||0})]}),e.jsx(Hr,{className:"h-8 w-8 text-muted-foreground"})]})})}),e.jsx(ee,{children:e.jsx(te,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Signups"}),e.jsx("p",{className:"text-2xl font-bold",children:f?.eventStats?.totalSignups?.toLocaleString()||0})]}),e.jsx(Bs,{className:"h-8 w-8 text-muted-foreground"})]})})}),e.jsx(ee,{children:e.jsx(te,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Page Views"}),e.jsx("p",{className:"text-2xl font-bold",children:f?.eventStats?.totalPageViews?.toLocaleString()||0})]}),e.jsx(Sn,{className:"h-8 w-8 text-muted-foreground"})]})})}),e.jsx(ee,{children:e.jsx(te,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active Clients"}),e.jsxs("p",{className:"text-2xl font-bold",children:[f?.activeClients||0," / ",f?.totalClients||0]})]}),e.jsx(Qn,{className:"h-8 w-8 text-muted-foreground"})]})})})]}),e.jsx("div",{className:"flex justify-end gap-2",children:e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>w("events"),"data-testid":"button-export-events",children:[e.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Export Events"]})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(qo,{className:"h-5 w-5"}),"Recent Activity"]}),e.jsx(Tt,{children:"Logins and signups over time"})]}),e.jsx(te,{children:f?.loginsByDay&&f.loginsByDay.length>0?e.jsx("div",{className:"space-y-2",children:f.loginsByDay.slice(-7).map(C=>e.jsxs("div",{className:"flex items-center justify-between py-1 border-b last:border-0",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:C.date}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(Ce,{variant:"secondary",children:[C.count," logins"]})})]},C.date))}):e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No login data in this period"})})]}),e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5"}),"Top Pages"]}),e.jsx(Tt,{children:"Most viewed pages on the platform"})]}),e.jsx(te,{children:f?.topPages&&f.topPages.length>
2060?e.jsx("div",{className:"space-y-2",children:f.topPages.slice(0,7).map((C,j)=>e.jsxs("div",{className:"flex items-center justify-between py-1 border-b last:border-0",children:[e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[200px]",children:C.path}),e.jsxs(Ce,{variant:"secondary",children:[C.views," views"]})]},j))}):e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No page view data in this period"})})]})]}),e.jsxs(ee,{children:[e.jsx(qe,{children:e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(Qn,{className:"h-5 w-5"}),"Client Overview"]})}),e.jsx(te,{children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"text-center p-4 rounded-lg border",children:[e.jsx("p",{className:"text-3xl font-bold text-green-600",children:f?.activeClients||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active Clients"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg border",children:[e.jsx("p",{className:"text-3xl font-bold text-red-600",children:f?.churnedClients||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Inactive Clients"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg border",children:[e.jsx("p",{className:"text-3xl font-bold",children:f?.totalClients||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Clients"})]})]})})]})]})}),e.jsxs(Ss,{value:"clients",className:"space-y-6 mt-4",children:[e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsx(tt,{children:"Select a Client"}),e.jsx(Tt,{children:"View detailed analytics for a specific client"})]}),e.jsx(te,{children:e.jsxs(lt,{value:a||"",onValueChange:o,children:[e.jsx(it,{className:"w-full md:w-[300px]","data-testid":"select-client",children:e.jsx(ct,{placeholder:"Choose a client..."})}),e.jsx(ot,{children:h?.map(C=>e.jsx(me,{value:C.id,children:C.name},C.id))})]})})]}),a&&(v?e.jsx("div",{className:"space-y-4",children:e.jsx(be,{className:"h-64"})}):x?.contentReport&&x.contentReport.length>0?e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(Pt,{className:"h-5 w-5"}),"Content Performance"]}),e.jsx(Tt,{children:"Views, feedback, and freshness for all content"})]}),e.jsx(te,{children:e.jsx("div",{className:"space-y-3",children:x.contentReport.sort((C,j)=>j.totalViews-C.totalViews).map(C=>{const j=C.companySlug&&C.kbSlug&&C.procedureSlug?`/${C.companySlug}/${C.kbSlug}/${C.categorySlug||"uncategorized"}/${C.procedureSlug}`:null;return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${j?"cursor-pointer hover-elevate":""}`,onClick:()=>j&&window.open(j,"_blank"),"data-testid":`client-content-${C.id}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ln,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:C.title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[C.contentType," | ",C.uniqueViewers," unique viewers",C.daysSinceUpdate!==null&&` | Updated ${C.daysSinceUpdate}d ago`]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"font-medium",children:C.totalViews}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"views"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(Tc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:C.helpfulCount})]}),e.jsxs("div",{className:"flex items-center gap-1 text-red-600",children:[e.jsx(Hu,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:C.notHelpfulCount})]})]}),C.helpfulRatio!==null&&e.jsxs(Ce,{variant:C.helpfulRatio>=70?"default":C.helpfulRatio>=50?"secondary":"destructive",children:[C.helpfulRatio,"%"]}),C.daysSinceUpdate!==null&&C.daysSinceUpdate>90&&e.jsx(hl,{className:"h-4 w-4 text-red-500"})]})]},C.id)})})})]}):a?e.jsx(ee,{children:e.jsxs(te,{className:"py-8 text-center",children:[e.jsx(Pt,{className:"h-12 w-12 mx-auto mb-3 text-muted-foreground"}),e.jsx("p",{className:"text-lg font-medium",children:"No content data available"}),e.jsx("p",{className:"text-muted-foreground",children:"This client has no procedures or overviews yet"})]})}):null)]})]})]})}function dz({onSelectClient:t,onSelectClientTab:s}){const{toast:n}=dt(),[a,o]=m.useState(null),[l,d]=m.useState(!1),[u,h]=m.useState(!1),{data:f=[],isLoading:g}=je({queryKey:["/api/admin/canceled-clients"]}),{data:x,isLoading:v}=je({queryKey:[`/api/clients/${a?.id}/deletion-stats`],enabled:!!a?.id&&(l||u)}),w=ye({mutationFn:async T=>{const P=await ce("POST",`/api/clients/${T}/archive`);if(!P.ok){const I=await P.json();throw new Error(I.error||"Failed to archive client")}return P.json()},onSuccess:()=>{de.invalidateQueries({queryKey:["/api/admin/canceled-clients"]}),de.invalidateQueries({queryKey:["/api/clients"]}),de.invalidateQueries({queryKey:["/api/client-stats"]}),h(!1),o(null),n({title:"Account archived",description:"The account has been archived successfully."})},onError:T=>{n({title:"Failed to archive account",description:T.message,variant:"destructive"})}}),C=ye({mutationFn:async T=>{const P=await ce("DELETE",`/api/clients/${T}/cascade`);if(!P.ok&&P.status!==204){const I=await P.json();throw new Error(I.error||"Failed to delete client")}return!0},onSuccess:()=>{de.invalidateQueries({queryKey:["/api/admin/canceled-clients"]}),de.invalidateQueries({queryKey:["/api/clients"]}),de.invalidateQueries({queryKey:["/api/client-stats"]}),d(!1),o(null),n({title:"Account permanently deleted",description:"The account and all associated data have been permanently deleted."})},onError:T=>{n({title:"Failed to delete account",description:T.message,variant:"destructive"})}}),j=T=>{o(T),h(!0)},b=T=>{o(T),d(!0)},k=()=>{a&&w.mutate(a.id)},N=()=>{a&&C.mutate(a.id)};return g?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx(be,{className:"h-8 w-64"}),e.jsx("div",{className:"grid gap-4",children:[1,2,3].map(T=>e.jsx(be,{className:"h-24 w-full"},T))})]}):e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold","data-testid":"text-page-title",children:"Canceled Accounts"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage accounts that have been canceled. You can archive them to hide from active views or permanently delete them along with all associated data."})]}),f.length===0?e.jsx(ee,{children:e.jsxs(te,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Qn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium",children:"No canceled accounts"}),e.jsx("p",{className:"text-muted-foreground text-center max-w-md mt-2",children:"There are currently no canceled accounts to manage."})]})}):e.jsx("div",{className:"grid gap-4",children:f.map(T=>e.jsxs(ee,{"data-testid":`card-client-${T.id}`,children:[e.jsx(qe,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 cursor-pointer hover-elevate rounded-md p-1 -m-1",onClick:()=>t?.(T.slug),"data-testid":`link-client-${T.id}`,children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md bg-muted",children:e.jsx(Qn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx(tt,{className:"text-lg","data-testid":`text-client-name-${T.id}`,children:T.name}),e.jsxs(Tt,{children:["/",T.slug]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Ce,{variant:"secondary",children:"Canceled"}),T.createdAt&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Created ",Nr(new Date(T.createdAt),"MMM d, yyyy")]})]})]})}),e.jsx(te,{children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-1 text-muted-foreground hover-elevate rounded px-2 py-1",onClick:()=>s?.(T.slug,"contacts"),"data-testid":`link-users-${T.id}`,children:[e.jsx(Bs,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:T.stats?.userCount??0})," Users"]}),e.jsxs("button",{type:"button",className:"flex items-center gap-1 text-muted-foreground hover-elevate rounded px-2 py-1",onClick:()=>s?.(T.slug,"knowledge-bases"),"data-testid":`link-kbs-${T.id}`,children:[e.jsx(cs,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:T.stats?.knowledgeBaseCount??0})," KBs"]}),e.jsxs("button",{type:"button",className:"flex items-center gap-1 text-muted-foreground hover-elevate rounded px-2 py-1",onClick:()=>s?.(T.slug,"all-content"),"data-testid":`link-procedures-${T.id}`,children:[e.jsx(Pt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:T.stats?.procedureCount??0})," Procedures"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:P=>{P.stopPropagation(),j(T)},"data-testid":`button-archive-${T.id}`,children:[e.jsx(Rm,{className:"h-4 w-4 mr-2"}),"Archive"]}),e.jsxs(D,{variant:"destructive",size:"sm",onClick:P=>{P.stopPropagation(),b(T)},"data-testid":`button-delete-${T.id}`,children:[e.jsx(ts,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},T.id))}),e.jsx(St,{open:u,onOpenChange:h,children:e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Archive Account"}),e.jsxs(Gt,{children:['Are you sure you want to archive "',a?.name,'"? The account will be hidden from active views but all data will be preserved.']})]}),v?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ve,{className:"h-6 w-6 animate-spin"})}):x&&e.jsxs("div",{className:"space-y-2 py-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"This account contains:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),x.userCount," user",x.userCount!==1?"s":""]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(cs,{className:"h-4 w-4"}),x.knowledgeBaseCount," knowledge base",x.knowledgeBaseCount!==1?"s":""]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(Pt,{className:"h-4 w-4"}),x.procedureCount," procedure",x.procedureCount!==1?"s":""]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"All data will be preserved and can be restored later."})]}),e.jsxs(Vs,{children:[e.jsx(D,{variant:"outline",onClick:()=>h(!1),"data-testid":"button-cancel-archive",children:"Cancel"}),e.jsxs(D,{onClick:k,disabled:w.isPending,"data-testid":"button-confirm-archive",children:[w.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Archive Account"]})]})]})}),e.jsx(Ok,{open:l,onOpenChange:d,children:e.jsxs(Vx,{children:[e.jsxs(qx,{children:[e.jsxs(Hx,{className:"flex items-center gap-2",children:[e.jsx(pl,{className:"h-5 w-5 text-destructive"}),"Permanently Delete Account"]}),e.jsxs(Wx,{children:['This action cannot be undone. This will permanently delete "',a?.name,'" and all associated data.']})]}),v?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ve,{className:"h-6 w-6 animate-spin"})}):x&&e.jsxs("div",{className:"space-y-2 py-4 border rounded-md p-4 bg-destructive/5",children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:"The following will be permanently deleted:"}),e.jsxs("ul",{className:"text-sm space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),x.userCount," user",x.userCount!==1?"s":""]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(cs,{className:"h-4 w-4"}),x.knowledgeBaseCount," knowledge base",x.knowledgeBaseCount!==1?"s":""]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(Pt,{className:"h-4 w-4"}),x.procedureCount," procedure",x.procedureCount!==1?"s":""]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),x.teamCount," team",x.teamCount!==1?"s":""]})]})]}),e.jsxs(Kx,{children:[e.jsx(Gx,{"data-testid":"button-cancel-delete",children:"Cancel"}),e.jsxs(Qx,{onClick:N,disabled:C.isPending,className:"bg-destructive text-destructive-foreground","data-testid":"button-confirm-delete",children:[C.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Delete Permanently"]})]})]})})]})}function Ru(){const[,t]=Kr(),[,s]=ar("/admin/:view/:clientSlug/:tab"),[,n]=ar("/admin/:view/:clientSlug"),[,a]=ar("/admin/:view"),o=s||n||a||{},l=o.view,d=o.clientSlug,u=o.tab,h=l||"dashboard",[f,g]=m.useState(null),[x,v]=m.useState(null),[w,C]=m.useState("procedures"),[j,b]=m.useState(null),{user:k,isLoading:N,setUser:T,logout:P}=Da(),{toast:I}=dt(),O=m.useCallback((_,$,A)=>{let W="/admin";_!=="dashboard"&&(W+=`/${_}`),$&&(W+=`/${$}`),A&&(W+=`/${A}`),t(W)},[t]),[R,F]=m.useState(""),[M,z]=m.useState(""),[H,V]=m.useState(""),[B,Y]=m.useState(!1),L=async()=>
206{if(!R||!M){V("Please enter username and password");return}Y(!0),V("");try{const _=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:R,password:M})}),$=await _.json();if(!_.ok){V($.error||"Login failed"),Y(!1);return}T($.user),I({title:"Welcome back!",description:`Logged in as ${$.user.firstName}`})}catch{V("Login failed. Please try again.")}finally{Y(!1)}},K={"--sidebar-width":"16rem","--sidebar-width-icon":"3rem"};return N?e.jsx("div",{className:"flex h-screen w-full items-center justify-center",children:e.jsx(Ve,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):k?e.jsx(pS,{style:K,children:e.jsxs("div",{className:"flex h-screen w-full",children:[e.jsx(hO,{currentView:h,onViewChange:_=>{_==="dashboard"&&(g(null),v(null)),O(_)},onLogout:P}),e.jsxs("div",{className:"flex flex-col flex-1",children:[e.jsxs("header",{className:"flex items-center justify-between gap-4 p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(xS,{"data-testid":"button-admin-sidebar-toggle"}),e.jsx(fO,{view:h,selectedClientSlug:d||null,selectedKnowledgeBase:f,selectedProcedure:x})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ra,{}),e.jsx(ht,{href:"/",children:e.jsxs(D,{variant:"ghost",size:"sm","data-testid":"button-admin-view-site",children:[e.jsx(Yn,{className:"h-4 w-4 mr-1"}),"View Knowledge Center"]})})]})]}),e.jsxs("main",{className:"flex-1 overflow-auto p-6",children:[h==="dashboard"&&e.jsx(pO,{onSelectClient:_=>{O("clients",_)}}),h==="clients"&&e.jsx(MU,{selectedClientSlug:d||null,onSelectClient:_=>{_?O("clients",_):O("clients")},selectedKnowledgeBase:f,onSelectKnowledgeBase:g,onEditProcedure:_=>{v(_),C("clients"),O("editor")},activeTab:u,onTabChange:_=>{d&&O("clients",d,_)}}),h==="procedures"&&e.jsx(LU,{onEditProcedure:_=>{v(_),C("procedures"),O("editor")}}),h==="overviews"&&e.jsx(FU,{onEditProcedure:_=>{v(_),C("procedures"),O("editor")}}),h==="editor"&&e.jsx(YU,{procedureId:x,onBack:()=>O(w)}),h==="email-templates"&&e.jsx(ZU,{}),h==="automations"&&e.jsx(XU,{}),h==="segments"&&e.jsx(JU,{}),h==="newsletters"&&e.jsx(ez,{}),h==="announcements"&&e.jsx(tz,{onCreateAnnouncement:()=>O("announcements-create"),onEditAnnouncement:_=>{b(_),O("announcements-edit")}}),h==="announcements-create"&&e.jsx(sz,{onBack:()=>O("announcements")}),h==="announcements-edit"&&e.jsx(nz,{announcementId:j,onBack:()=>{b(null),O("announcements")}}),h==="platform-users"&&e.jsx(rz,{}),h==="my-profile"&&e.jsx(az,{}),h==="notification-preferences"&&e.jsx(oz,{}),h==="site-settings"&&e.jsx(lz,{}),h==="analytics"&&e.jsx(cz,{}),h==="canceled-accounts"&&e.jsx(dz,{onSelectClient:_=>{O("clients",_)},onSelectClientTab:(_,$)=>{O("clients",_,$)}})]})]})]})}):e.jsx("div",{className:"flex h-screen w-full items-center justify-center bg-background",children:e.jsxs("div",{className:"w-full max-w-md 
206space-y-6 px-4",children:[e.jsx(ht,{href:"/",className:"block text-center","data-testid":"link-login-logo",children:e.jsx("span",{className:"font-serif text-3xl font-medium tracking-tight",children:"outliner"})}),e.jsxs(ee,{children:[e.jsxs(qe,{className:"text-center",children:[e.jsxs(tt,{className:"flex items-center justify-center gap-2",children:[e.jsx(Pn,{className:"h-5 w-5"}),"Admin Login"]}),e.jsx(Tt,{children:"Sign in to access the admin dashboard"})]}),e.jsxs(te,{className:"space-y-4",children:[H&&e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 text-center p-2 bg-red-50 dark:bg-red-900/20 rounded-md",children:H}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"login-username",children:"Username"}),e.jsx(fe,{id:"login-username",value:R,onChange:_=>F(_.target.value),placeholder:"Enter your username",onKeyDown:_=>_.key==="Enter"&&L(),"data-testid":"input-login-username"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"login-password",children:"Password"}),e.jsx(fe,{id:"login-password",type:"password",value:M,onChange:_=>z(_.target.value),placeholder:"Enter your password",onKeyDown:_=>_.key==="Enter"&&L(),"data-testid":"input-login-password"})]}),e.jsxs(D,{className:"w-full",onClick:L,disabled:B,"data-testid":"button-login",children:[B&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Sign In"]})]})]})]})})}function uz(){const[t,s]=m.useState(new Set),n=m.useRef(null),{data:a=[],isLoading:o}=je({queryKey:["/api/portal/popups"]}),l=ye({mutationFn:async f=>{await ce("POST",`/api/portal/popups/${f}/dismiss`)},onSuccess:()=>{de.invalidateQueries({queryKey:["/api/portal/popups"]})}}),u=m.useMemo(()=>a.filter(f=>!t.has(f.id)),[a,t])[0];m.useEffect(()=>{u?.embedCode&&n.current&&(n.current.innerHTML=u.embedCode,n.current.querySelectorAll("script").forEach(g=>{const x=document.createElement("script");Array.from(g.attributes).forEach(v=>{x.setAttribute(v.name,v.value)}),x.textContent=g.textContent,g.parentNode?.replaceChild(x,g)}))},[u?.embedCode,u?.id]);const h=()=>{u&&(u.triggerType!=="always"&&l.mutate(u.id),s(f=>new Set(f).add(u.id)))};return o||!u?null:e.jsx(St,{open:!!u,onOpenChange:()=>h(),children:e.jsxs(jt,{className:"max-w-2xl max-h-[90vh] overflow-hidden flex flex-col","data-testid":"dialog-portal-popup",children:[e.jsx(wt,{className:"flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(bt,{"data-testid":"text-popup-title",children:u.title}),e.jsx(D,{variant:"ghost",size:"icon",onClick:h,"data-testid":"button-popup-dismiss",children:e.jsx(Zn,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"flex-1 overflow-auto space-y-4",children:[u.message&&e.jsx("div",{className:"text-muted-foreground whitespace-pre-wrap","data-testid":"text-popup-message",children:u.message}),u.embedCode&&e.jsx("div",{ref:n,className:"w-full min-h-[400px] rounded-lg overflow-hidden","data-testid":"container-popup-embed"})]}),e.jsxs("div",{className:"flex-shrink-0 pt-4 border-t space-y-2",children:[u.buttonText&&u.buttonUrl&&e.jsx(D,{asChild:!0,className:"w-full","data-testid":"button-popup-cta",children:e.jsx("a",{href:u.buttonUrl,target:"_blank",rel:"noopener noreferrer",children:u.buttonText})}),e.jsx(D,{onClick:h,variant:u.buttonText&&u.buttonUrl?"outline":"default",className:"w-full","data-testid":"button-popup-got-it",children:u.buttonText&&u.buttonUrl?"Close":"Got it"})]})]})})}function mz(t){const s=[{id:"welcome",target:"",title:"Welcome to Outliner!",description:"Let's take a quick tour of the portal so you know where everything is. This will only take a minute.",placement:"center",minRole:"viewer"},{id:"knowledge-bases",target:"[data-testid='button-portal-nav-knowledge-bases']",title:"Knowledge Bases",description:"This is where you create and manage your Knowledge Bases. Each Knowledge Base contains Categories, and each Category holds Procedures and Overviews - your core content.",learnMoreUrl:"https://outliner.com/outliner/1-knowledge-bases",placement:"right",minRole:"viewer",navigateTo:"/p
206ortal/knowledge-bases"},{id:"procedures",target:"[data-testid='button-portal-nav-procedures']",title:"Procedures",description:"Need to quickly find a procedure? This tab gives you a searchable list of all procedures across every Knowledge Base - no digging required.",learnMoreUrl:"https://outliner.com/outliner/2-procedures",placement:"right",minRole:"viewer",navigateTo:"/portal/procedures"},{id:"overviews",target:"[data-testid='button-portal-nav-overviews']",title:"Overviews",description:"Similar to Procedures, this tab shows all your overview documents in one place. Overviews are great for high-level summaries and reference material.",learnMoreUrl:"https://outliner.com/outliner/3-overviews",placement:"right",minRole:"viewer",navigateTo:"/portal/overviews"},{id:"knowledge-center",target:"[data-testid='button-portal-view-site']",title:"Knowledge Center",description:"This opens your public Knowledge Center - the polished, reader-friendly view of your content. Share this link with your team or customers so they can access your published Knowledge Bases.",learnMoreUrl:"https://outliner.com/outliner",placement:"bottom",minRole:"viewer"},{id:"users",target:"[data-testid='button-portal-nav-users']",title:"Users",description:"Manage your team members here. Add new users, assign roles (Admin, Manager, Editor, Viewer), and control who can do what in the portal.",learnMoreUrl:"https://outliner.com/outliner/5-users",placement:"right",minRole:"manager",navigateTo:"/p
206ortal/users"},{id:"teams",target:"[data-testid='button-portal-nav-teams']",title:"Teams",description:"Organize your users into Teams. Teams let you control which groups of people can access specific Knowledge Bases and content.",learnMoreUrl:"https://outliner.com/outliner/6-teams",placement:"right",minRole:"manager",navigateTo:"/portal/teams"},{id:"analytics",target:"[data-testid='button-portal-nav-analytics']",title:"Analytics",description:"Track how your content is performing. See views, feedback, and content freshness metrics to keep your Knowledge Bases up to date.",learnMoreUrl:"https://outliner.com/outliner/7-analytics",placement:"right",minRole:"manager",navigateTo:"/portal/analytics"},{id:"company",target:"[data-testid='button-portal-nav-company']",title:"Company Settings",description:"Configure your company name, branding, and Knowledge Center appearance. This is where you make the portal yours.",learnMoreUrl:"https://outliner.com/outliner/8-company-settings",placement:"right",minRole:"admin",navigateTo:"/portal/company"},{id:"billing",target:"[data-testid='button-portal-nav-billing']",title:"Billing",description:"Manage your subscription, view invoices, and update payment details here.",learnMoreUrl:"https://outliner.com/outliner/8-company-settings/2-billing",placement:"right",minRole:"admin",navigateTo:"/p
206ortal/billing"},{id:"tour-complete",target:"",title:"You're All Set!",description:"That's the tour! You can always restart it from the help menu. For detailed guides, visit our Knowledge Center.",learnMoreUrl:"https://outliner.com/outliner",placement:"center",minRole:"viewer"}],n={admin:4,manager:3,editor:2,viewer:1},a=n[t]||1;return s.filter(o=>{const l=n[o.minRole]||1;return a>=l})}function hz({role:t,onComplete:s,onDismiss:n,onStepChange:a,initialStep:o=0}){const l=m.useMemo(()=>mz(t),[t]),d=Math.min(o,l.length-1),[u,h]=m.useState(d),[f,g]=m.useState({top:0,left:0}),[x,v]=m.useState(!1),[w,C]=m.useState(!1),j=m.useRef(null),[,b]=Kr(),k=l[u],N=u===0,T=u===l.length-1,P=!k?.target||k.placement==="center"||!w,I=m.useCallback(()=>{if(!k||!k.target||k.placement==="center"){C(!1);return}const B=document.querySelector(k.target);if(!B){C(!1);return}C(!0);const Y=B.getBoundingClientRect(),L=j.current;if(!L)return;const K=L.getBoundingClientRect(),_=16;let $=0,A=0;switch(k.placement){case"right":$=Y.top+Y.height/2-K.height/2,A=Y.right+_;break;case"bottom":$=Y.bottom+_,A=Y.left+Y.width/2-K.width/2;break;case"left":$=Y.top+Y.height/2-K.height/2,A=Y.left-K.width-_;break;case"top":$=Y.top-K.height-_,A=Y.left+Y.width/2-K.width/2;break}$=Math.max(_,Math.min($,window.innerHeight-K.height-_)),A=Math.max(_,Math.min(A,window.innerWidth-K.width-_)),g({top:$,left:A})},[k]);m.useEffect(()=>{if(!k)return;k.navigateTo&&b(k.navigateTo),C(!1);const B=setTimeout(()=>{I(),v(!1)},350),Y=setTimeout(I,600),L=()=>I();return window.addEventListener("resize",L),()=>{clearTimeout(B),clearTimeout(Y),window.removeEventListener("resize",L)}},[u,k,I,b]);const O=m.useCallback(B=>{v(!0),h(B),a(B)},[a]),R=m.useCallback(()=>{T?(b("/portal/knowledge-bases"),s()):O(u+1)},[T,u,O,s,b]),F=m.useCallback(()=>{N||O(u-1)},[N,u,O]),M=m.useCallback(()=>{b("/portal/knowledge-bases"),n()},[n,b]);if(!k)return null;const H=(w&&k.target?document.querySelector(k.target):null)?.getBoundingClientRect(),V=B=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex items-start justify-between ${B?"mb-2":"mb-4"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[!B&&e.jsx(gs,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:B?"text-sm font-semibold":"text-lg font-semibold",children:k.title})]}),e.jsx(D,{variant:"ghost",size:"icon",onClick:M,"data-testid":"button-dismiss-tour",className:B?"h-6 w-6 -mt-1 -mr-1":"h-8 w-8 -mt-1 -mr-2",children:e.jsx(Zn,{className:B?"h-3 w-3":"h-4 w-4"})})]}),e.jsx("p",{className:`text-muted-foreground leading-relaxed ${B?"text-xs mb-3":"mb-6"}`,children:k.description}),k.learnMoreUrl&&e.jsxs("a",{href:k.learnMoreUrl,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-primary hover:underline ${B?"text-xs mb-3":"text-sm mb-4"}`,"data-testid":"link-learn-more",children:[e.jsx(Yn,{className:"h-3 w-3"}),B?"Learn more":"Visit our Knowledge Center"]}),e.jsxs("div",{className:`flex items-center justify-between ${B?"":"mt-4"}`,children:[B?e.jsxs("span",{className:"text-xs text-muted-foreground",children:[u+1," / ",l.length]}):e.jsx("div",{className:"flex items-center gap-1.5",children:l.map((Y,L)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all duration-300 ${L===u?"w-6 bg-primary":L<u?"w-1.5 bg-primary/50":"w-1.5 bg-muted"}`},L))}),e.jsxs("div",{className:"flex gap-1.5",children:[!N&&e.jsxs(D,{variant:"outline",size:"sm",onClick:F,className:B?"h-7 text-xs px-2":"","data-testid":"button-tour-prev",children:[e.jsx(gN,{className:B?"h-3 w-3":"h-4 w-4 mr-1"}),!B&&"Back"]}),N&&!B&&e.jsxs(D,{variant:"ghost",size:"sm",onClick:M,"data-testid":"button-skip-tour",children:[e.jsx(pE,{className:"h-4 w-4 mr-1"}),"Skip Tutorial"]}),e.jsxs(D,{size:"sm",onClick:R,className:B?"h-7 text-xs px-3":"","data-testid":"button-tour-next",children:[T?"Get Started":"Next",!T&&!B&&e.jsx(Bt,{className:"h-4 w-4 ml-1"})]})]})]})]});return e.jsxs("div",{className:"fixed inset-0 z-[9999]","data-testid":"onboarding-tour-overlay",children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 transition-opacity duration-300"}),H&&!P&&e.jsx("div",{className:"fixed z-[10000] rounded-lg transition-all duration-300",style:{to
206p:H.top-4,left:H.left-4,width:H.width+8,height:H.height+8,boxShadow:"0 0 0 9999px rgba(0,0,0,0.6), 0 0 20px 4px rgba(59,130,246,0.5)",pointerEvents:"none"}}),P?e.jsx("div",{className:"fixed inset-0 z-[10001] flex items-center justify-center p-4",children:e.jsx(ee,{className:`w-full max-w-lg shadow-2xl border-primary/20 transition-all duration-300 ${x?"opacity-0 scale-95":"opacity-100 scale-100"}`,"data-testid":`tour-step-${k.id}`,children:e.jsx(te,{className:"p-6",children:V(!1)})})}):e.jsx("div",{ref:j,className:`fixed z-[10001] transition-all duration-300 ${x?"opacity-0 scale-95":"opacity-100 scale-100"}`,style:{top:f.top,left:f.left},children:e.jsx(ee,{className:"w-80 shadow-2xl border-primary/20","data-testid":`tour-step-${k.id}`,children:e.jsx(te,{className:"p-4",children:V(!0)})})})]})}function fz({onRestartTour:t}){const[s,n]=m.useState(!1),[a,o]=m.useState([]),[l,d]=m.useState(""),[u,h]=m.useState(!1),[f,g]=m.useState(!1),[x,v]=m.useState(""),[w,C]=m.useState(""),[j,b]=m.useState(!1),[k,N]=m.useState(!1),[T,P]=m.useState(!1),I=m.useRef(null),O=m.useRef(null),R=m.useCallback(()=>{I.current?.scrollIntoView({behavior:"smooth"})},[]);m.useEffect(()=>{R()},[a,R]),m.useEffect(()=>{s&&O.current&&!f&&O.current.focus()},[s,f]);const F=m.useCallback(async B=>{if(!B.trim()||u)return;const Y=B.trim(),L={role:"user",content:Y},K=[...a,L];o(K),d(""),h(!0);try{const $=await(await ce("POST","/api/portal/help-chat",{message:Y,conversationHistory:K.slice(0,-1)})).json();o(A=>[...A,{role:"assistant",content:$.reply}])}catch{o(_=>[..._,{role:"assistant",content:"Sorry, I couldn't process that request. Please try again or visit our [Knowledge Center](https://
206outliner.com/outliner) for help."}])}finally{h(!1)}},[u,a]),M=m.useCallback(()=>{F(l)},[l,F]),z=m.useCallback(B=>{B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),M())},[M]),H=async()=>{N(!0),P(!1);try{(await ce("POST","/api/portal/support-ticket",{subject:x.trim()||"Support Request",message:w.trim()})).ok?b(!0):P(!0)}catch{P(!0)}finally{N(!1)}},V=B=>B.split(/(\[.*?\]\(.*?\))/g).map((L,K)=>{const _=L.match(/\[(.*?)\]\((.*?)\)/);return _?e.jsxs("a",{href:_[2],target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-0.5",children:[_[1],e.jsx(Yn,{className:"h-3 w-3"})]},K):L.split(/(\*\*.*?\*\*)/g).map((A,W)=>A.startsWith("**")&&A.endsWith("**")?e.jsx("strong",{children:A.slice(2,-2)},`${K}-${W}`):e.jsx("span",{children:A},`${K}-${W}`))});return e.jsxs(e.Fragment,{children:[!s&&e.jsx("button",{onClick:()=>n(!0),className:"fixed bottom-6 right-6 z-[9990] h-12 w-12 rounded-full bg-primary text-primary-foreground shadow-lg hover:shadow-xl transition-all duration-200 hover:scale-105 flex items-center justify-center","data-testid":"button-help-chat-open","aria-label":"Open help chat",children:e.jsx(sw,{className:"h-6 w-6"})}),s&&e.jsxs(ee,{className:"fixed bottom-6 right-6 z-[9990] w-96 max-h-[500px] shadow-2xl border-primary/20 flex flex-col","data-testid":"help-chat-panel",children:[e.jsxs(qe,{className:"p-3 border-b flex flex-row items-center justify-between space-y-0",children:[e.jsx("div",{className:"flex items-center gap-2",children:f?e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>{g(!1),b(!1)},className:"h-7 w-7","data-testid":"button-ticket-back",children:e.jsx(kn,{className:"h-3.5 w-3.5"})}),e.jsx("h3",{className:"text-sm font-semibold",children:"Contact Support"})]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"h-4 w-4 text-primary"}),e.jsx("h3",{className:"text-sm font-semibold",children:"Outliner Help"})]})}),e.jsxs("div",{className:"flex items-center gap-1",children:[!f&&t&&e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>{n(!1),t()},className:"h-7 w-7","data-testid":"button-restart-tour",title:"Restart tutorial",children:e.jsx(jc,{className:"h-3.5 w-3.5"})}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>n(!1),className:"h-7 w-7","data-testid":"button-help-chat-close",children:e.jsx(Zn,{className:"h-3.5 w-3.5"})})]})]}),e.jsx(te,{className:"p-0 flex-1 flex flex-col min-h-0",children:f?e.jsx("div",{className:"p-4 space-y-3",children:j?e.jsxs("div",{className:"text-center py-8 space-y-3",children:[e.jsx(xN,{className:"h-10 w-10 mx-auto text-green-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Message sent!"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"We'll get back to you as soon as possible at the email on your account."}),e.jsx(D,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>{g(!1),b(!1),v(""),C("")},"data-testid":"button-ticket-back-to-chat",children:"Back to Help Chat"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Send a message to our support team and we'll get back to you as soon as possible."}),T&&e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-destructive/10 border border-destructive/20",children:[e.jsx(hl,{className:"h-3.5 w-3.5 text-destructive shrink-0"}),e.jsx("span",{className:"text-xs text-destructive",children:"Failed to send. Please try again or email [email protected] directly."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(fe,{value:x,onChange:B=>v(B.target.value),placeholder:"Subject (e.g., Need help with...)",className:"text-xs h-8",disabled:k,"data-testid":"input-ticket-subject"}),e.jsx(ss,{value:w,onChange:B=>C(B.target.value),placeholder:"Describe what you need help with...",rows:4,className:"text-xs",disabled:k,"data-testid":"input-ticket-message"})]}),e.jsx(D,{size:"sm",className:"w-full text-xs",onClick:H,disabled:!w.trim()||k,"data-testid":"button-ticket-submit",children:k?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-3.5 w-3.5 mr-1 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(el,{className:"h-3.5 w-3.5 mr-1"}),"Send Message"]})})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-3 min-h-[200px] max-h-[350px]",children:[a.length===0&&e.jsxs("div",{className:"text-center py-6 space-y-3",children:[e.jsx(sw,{className:"h-10 w-10 mx-auto text-muted-foreground
206/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"How can I help?"}),e.jsx("p",{className:"text-xs text-muted-foreground/70 mt-1",children:"Ask me anything about using Outliner"})]}),e.jsx("div",{className:"space-y-1.5",children:["How do I create a Knowledge Base?","How do I add team members?","How do I publish content?"].map(B=>e.jsx("button",{onClick:()=>F(B),className:"block w-full text-left text-xs px-3 py-2 rounded-md bg-muted/50 hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","data-testid":"button-suggested-question",children:B},B))}),e.jsxs("div",{className:"flex flex-col items-center gap-2 pt-1",children:[e.jsxs("a",{href:"https://outliner.com/outliner",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline","data-testid":"link-help-knowledge-center",children:[e.jsx(Yn,{className:"h-3 w-3"}),"Browse our Knowledge Center"]}),e.jsxs("button",{onClick:()=>g(!0),className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors","data-testid":"button-contact-support",children:[e.jsx(Ta,{className:"h-3 w-3"}),"Contact Support"]})]})]}),a.map((B,Y)=>e.jsx("div",{className:`flex ${B.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[80%] rounded-lg px-3 py-2 text-xs leading-relaxed ${B.role==="user"?"bg-primary text-primary-foreground":"bg-muted text-foreground"}`,"data-testid":`chat-message-${B.role}-${Y}`,children:V(B.content)})},Y)),u&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"bg-muted rounded-lg px-3 py-2",children:e.jsx(Ve,{className:"h-4 w-4 animate-spin text-muted-foreground"})})}),e.jsx("div",{ref:I})]}),e.jsxs("div",{className:"p-3 border-t space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(fe,{ref:O,value:l,onChange:B=>d(B.target.value),onKeyDown:z,placeholder:"Ask a question...",className:"text-xs h-8",disabled:u,"data-testid":"input-help-chat"}),e.jsx(D,{size:"icon",onClick:M,disabled:u||!l.trim(),className:"h-8 w-8 shrink-0","data-testid":"button-help-chat-send",children:e.jsx(el,{className:"h-3.5 w-3.5"})})]}),a.length>0&&e.jsx("button",{onClick:()=>g(!0),className:"w-full text-center text-[10px] text-muted-foreground hover:text-foreground transition-colors py-0.5","data-testid":"button-contact-support-footer",children:"Need more help? Contact Support"})]})]})})]})]})}const mc=["editor-description","editor-voice","editor-record-screen","editor-add-step","editor-ai-assistant","editor-content-management","editor-walkthrough-video","editor-organization","editor-version-history","editor-internal-notes"],pz={intro:{icon:gs,title:"Create Your First Knowledge Base",subtitle:"Let's walk through creating a Knowledge Base, Category, and Procedure using the real tools in your portal.",placement:"center"},"click-add-kb":{icon:cs,title:"Step 1: Add a Knowledge Base",subtitle:'Click the "Add Knowledge Base" button to create your first one.',target:"[data-testid='button-add-kb']",placement:"bottom",actionLabel:"Click the highlighted button"},"waiting-kb-created":{icon:cs,title:"Step 1: Create Your Knowledge Base",subtitle:'Fill in the details and click "Create" to save your new Knowledge Base.',placement:"center"},"click-add-category":{icon:Fr,title:"Step 2: Add a Category",subtitle:'Categories organize content within your Knowledge Base. Click "Add" to create one.',target:"[data-testid='button-add-category']",placement:"right",actionLabel:"Click the highlighted button"},"waiting-category-created":{icon:Fr,title:"Step 2: Create Your Category",subtitle:"Fill in the category details and save it.",placement:"center"},"click-add-procedure":{icon:Pt,title:"Step 3: Add a Procedure",subtitle:'Procedures are step-by-step guides for your team. Click "Add" to create one.',target:"[data-testid='button-add-procedure']",placement:"right",actionLabel:"Click the highlighted button"},"waiting-procedure-created":{icon:Pt,title:"Step 3: Create Your Procedure",subtitle:'Fill in the procedure details and click "Create Procedure" to save it.',placement:"center"},"editor-description":{icon:fE,title:"Description & AI Improver",subtitle:'A good description helps your team find this procedure quickly. Use the "Improve" dropdown to polish, simplify, or expand your text with AI.',target:"[data-testid='section-description']",placement:"bottom",isEditorStep:!0},"editor-voice":{icon:ka,title:"Describe with Voice",subtitle:"Don't want to type? Just speak! Describe your procedure verbally and it will automatically generate a title, description, and steps from what you say.",target:"[data-testid='button-voice-describe']",placement:"top",
206isEditorStep:!0},"editor-record-screen":{icon:Rg,title:"Record Your Screen",subtitle:"Record yourself performing the task on screen. The recording is analyzed by AI to automatically generate step-by-step instructions from your actions.",target:"[data-testid='button-record-procedure']",placement:"top",isEditorStep:!0},"editor-add-step":{icon:ds,title:"Add Steps Manually",subtitle:"Prefer to write steps yourself? Click here to add steps one at a time. Each step can have a title, description, images, and video.",target:"[data-testid='button-add-step']",placement:"top",isEditorStep:!0},"editor-ai-assistant":{icon:Ig,title:"Generate with AI",subtitle:'Click "Generate with AI" and the AI will use your title and description to create a full set of steps automatically. Great for getting a first draft quickly.',target:"[data-testid='section-ai-assistant']",placement:"top",isEditorStep:!0},"editor-content-management":{icon:Jc,title:"Content Management",subtitle:"Control your procedure's status (Draft or Published), choose the content type (Procedure or Overview), and set access visibility. Click Save when you're ready.",target:"[data-testid='section-content-management']",placement:"left",isEditorStep:!0},"editor-walkthrough-video":{icon:lr,title:"Walkthrough Video",subtitle:"Record an intro video that appears at the top of your procedure. This is for overview purposes only — no steps are generated from this recording.",target:"[data-testid='section-walkthrough-video']",placement:"left",isEditorStep:!0},"editor-organization":{icon:Fr,title:"Organization",subtitle:"Assign this procedure to a specific Knowledge Base and Category to keep your content organized and easy to find.",target:"[data-testid='section-organization']",placement:"left",isEditorStep:!0},"editor-version-history":{icon:oE,title:"Version History",subtitle:"Every time you save, a version is recorded. You can view past versions and restore any previous version if needed.",target:"[data-testid='section-version-history']",placement:"left",isEditorStep:!0},"editor-internal-notes":{icon:no,title:"Internal Notes",subtitle:"Leave notes for your team that are only visible internally — they won't appear in the published procedure. Great for collaboration and context.",target:"[data-testid='section-internal-notes']",placement:"left",isEditorStep:!0},done:{icon:xN,title:"You're All Set!",subtitle:"You've created your first Knowledge Base structure and learned about all the tools available to you.",placement:"center"}};function Oo(t){const s=document.querySelectorAll("[role='dialog']");for(const n of s)if(n.querySelector(`[data-testid='${t}']`))return!0;return!1}function gz({clientId:t,onComplete:s,onDismiss:n,onNavigateToKBList:a,onNavigateToKB:o}){const[l,d]=m.useState("intro"),[u,h]=m.useState(!1),[f,g]=m.useState(null),[x,v]=m.useState({top:0,left:0}),w=m.useRef(null),C=m.useRef(new Set),j=m.useRef(0),b=m.useRef(!1),k=m.useRef(null),N=pz[l],T=N.isEditorStep===!0,P=N.placement==="center"||!N.target||!u,I=m.useCallback(()=>(de.getQueryData([`/api/clients/${t}/knowledge-bases`])||[]).map(A=>A.id),[t]),O=m.useCallback(()=>k.current?(de.getQueryData([`/api/knowledge-bases/${k.current}/categories`])||[]).length:0,[]),R=m.useCallback($=>{const A=document.querySelector($);A&&A.scrollIntoView({behavior:"smooth",block:"center"})},[]),F=m.useCallback(()=>{if(!N.target||N.placement==="center"){h(!1),g(null);return}const $=document.querySelector(N.target);if(!$){h(!1),g(null);return}h(!0);const A=$.getBoundingClientRect();g(A);const W=w.current;if(!W)return;const U=W.getBoundingClientRect(),Q=16,we=window.innerWidth,_e=window.innerHeight,Ie=U.width,Te=U.height,ue=He=>{let ft=0,Ct=0;switch(He){case"bottom":ft=A.bottom+Q,Ct=A.left+A.width/2-Ie/2;break;case"top":ft=A.top-Te-Q,Ct=A.left+A.width/2-Ie/2;break;case"right":ft=A.top+A.height/2-Te/2,Ct=A.right+Q;break;case"left":ft=A.top+A.height/2-Te/2,Ct=A.left-Ie-Q;break}return{top:ft,left:Ct}},Re=He=>{const ft=He.left+Ie,Ct=He.top+Te,zt=He.left<A.right+4&&ft>A.left-4&&He.top<A.bottom+4&&Ct>A.top-4,Wt=He.top>=Q&&He.left>=Q&&ft<=we-Q&&Ct<=_e-Q;return!zt&&Wt},$e=N.placement,le=[$e,"bottom","right","left","top"].filter((He,ft,Ct)=>Ct.indexOf(He)===ft);let Me=ue($e);
206for(const He of le){const ft=ue(He);if(Re(ft)){Me=ft;break}}Me.top=Math.max(Q,Math.min(Me.top,_e-Te-Q)),Me.left=Math.max(Q,Math.min(Me.left,we-Ie-Q)),v(Me)},[N]);m.useEffect(()=>{if(l==="intro")return;l==="click-add-kb"&&(a(),C.current=new Set(I())),T&&N.target&&R(N.target),h(!1);const $=setTimeout(F,350),A=setTimeout(F,700);let W=null;N.target&&N.placement!=="center"&&(W=setInterval(()=>{F()},500));const U=()=>F();return window.addEventListener("resize",U),()=>{clearTimeout($),clearTimeout(A),W&&clearInterval(W),window.removeEventListener("resize",U)}},[l,F,a,I,T,N.target,R]),m.useEffect(()=>{if(l==="click-add-kb"){const A=setInterval(()=>{Oo("input-kb-name")&&(b.current=!0,d("waiting-kb-created"))},400);return()=>clearInterval(A)}if(l==="waiting-kb-created"){b.current=!0;const A=setInterval(()=>{if(Oo("input-kb-name")){b.current=!0;return}b.current&&(b.current=!1,de.refetchQueries({queryKey:[`/api/clients/${t}/knowledge-bases`]}).then(()=>{const U=I().find(Q=>!C.current.has(Q));U?(k.current=U,j.current=0,setTimeout(()=>{o(U),setTimeout(()=>d("click-add-category"),600)},300)):d("click-add-kb")}))},400);return()=>clearInterval(A)}if(l==="click-add-category"){j.current=O();const A=setInterval(()=>{if(Oo("input-category-name")){b.current=!0,d("waiting-category-created");return}document.querySelector("[data-testid='button-add-procedure']")&&!document.querySelector("[role='dialog']")&&d("click-add-procedure")},400);return()=>clearInterval(A)}if(l==="waiting-category-created"){b.current=!0;const A=setInterval(()=>{if(Oo("input-category-name")){b.current=!0;return}b.current&&(b.current=!1,k.current?de.refetchQueries({queryKey:[`/api/knowledge-bases/${k.current}/categories`]}).then(()=>{O()>j.current?setTimeout(()=>{d("click-add-procedure")},400):d("click-add-category")}):d("click-add-category"))},400);return()=>clearInterval(A)}if(l==="click-add-procedure"){const A=setInterval(()=>{if(Oo("input-procedure-title")){b.current=!0,d("waiting-procedure-created");return}document.querySelector("[data-testid='input-procedure-title']")&&!document.querySelector("[role='dialog']")&&setTimeout(()=>d("editor-description"),400)},400);return()=>clearInterval(A)}if(l==="waiting-procedure-created"){b.current=!0;const A=setInterval(()=>{if(Oo("input-procedure-title")){b.current=!0;return}if(!b.current)return;b.current=!1,document.querySelector("[data-testid='input-procedure-title']")&&!document.querySelector("[role='dialog']")?setTimeout(()=>d("editor-description"),800):d("click-add-procedure")},400);return()=>clearInterval(A)}},[l,o,I,O,t]);const M=l.startsWith("waiting-"),z=l.startsWith("click-"),H=mc.indexOf(l),V=mc.length,B=()=>{H>=0&&H<V-1?d(mc[H+1]):H===V-1&&d("done")},Y=()=>{H>0&&d(mc[H-1])},L=l==="intro"?0:l==="click-add-kb"||l==="waiting-kb-created"?1:l==="click-add-category"||l==="waiting-category-created"?2:l==="click-add-procedure"||l==="waiting-procedure-created"?3:4,K=N.icon,_=()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(K,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:N.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:N.subtitle})]})]}),e.jsx(D,{variant:"ghost",size:"icon",onClick:n,className:"h-7 w-7 -mt-1 -mr-1 shrink-0","data-testid":"button-dismiss-walkthrough",children:e.jsx(Zn,{className:"h-3.5 w-3.5"})})]}),N.actionLabel&&!M&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 p-2 rounded-md bg-primary/5 border border-primary/10",children:[e.jsx(mE,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-xs text-primary font-medium",children:N.actionLabel})]}),l==="intro"&&e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"We'll guide you through the real tools in your portal to create your first content. The structure goes:"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cs,{className:"h-3 w-3"})," Knowledge Base"]}),e.jsx("span",{className:"text-muted-foreground",children:"→"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fr,{className:"h-3 w-3"})," Category"]}),e.jsx("span",{className:"text-muted-foreground",children:"→"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pt,{className:"h-3 w-3"})," Procedure"]})]}),e.jsxs("a",{href:"https://outliner.com/outliner/1-knowledge-bases",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(Yn,{className:"h-3 w-3"}),"Learn more about Knowledge Bases"]})]}),l==="done"&&e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsx("div",{className:"p-3 rounded-lg bg-green-500/10 border border-green-500/20",children:e.jsx("p",{className:"text-xs leading-relaxed",children:"You've built your first content structure and explored all the key features. You can now add steps, create more content, and share your Knowledge Center with your team."})}),e.jsxs("a",{href:"https://outliner.com/outliner/2-procedures",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(Yn,{className:"h-3 w-3"}),"Learn more about Procedures"]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[T?e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs("span",{className:"text-[10px] text-muted-foreground font-medium whitespace-nowrap",children:[H+1," of ",V]}),e.jsx("div",{className:"flex items-center gap-0.5",children:mc.map(($,A)=>e.jsx("div",{className:`h-1 rounded-full transition-all duration-300 ${A===H?"w-3 bg-primary":A<H?"w-1.5 bg-primary/50":"w-1.5 bg-muted"}`},A))})]}):e.jsx("div",{className:"flex items-center gap-1.5",children:[0,1,2,3,4].map($=>e.jsx("div",{className:`h-1.5 rounded-full transition-all duration-300 ${$===L?"w-5 bg-primary":$<L?"w-1.5 bg-primary/50":"w-1.5 bg-muted"}`},$))}),e.jsxs("div",{className:"flex gap-2",children:[l==="intro"&&e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:n,"data-testid":"button-skip-walkthrough",children:"Skip"}),e.jsxs(D,{size:"sm",className:"h-7 text-xs",onClick:()=>d("click-add-kb"),"data-testid":"button-start-walkthrough",children:["Let's Go",e.jsx(Bt,{className:"h-3 w-3 ml-1"})]})]}),T&&e.jsxs(e.Fragment,{children:[e.jsxs(D,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:Y,disabled:H===0,"data-testid":"button-prev-editor-step",children:[e.jsx(gN,{className:"h-3 w-3 mr-1"}),"Back"]}),e.jsxs(D,{size:"sm",className:"h-7 text-xs",onClick:B,"data-testid":"button-next-editor-step",children:[H===V-1?"Finish":"Next",e.jsx(Bt,{className:"h-3 w-3 ml-1"})]})]}),l==="done"&&e.jsxs(D,{size:"sm",className:"h-7 text-xs",onClick:s,"data-testid":"button-finish-walkthrough",children:["Done",e.jsx(Bt,{className:"h-3 w-3 ml-1"})]})]})]})]});return M?e.jsx("div",{className:"fixed bottom-4 right-4 z-[9998]","data-testid":"kb-walkthrough-waiting",children:e.jsx(ee,{className:"w-80 shadow-lg border-primary/20 animate-in slide-in-from-bottom-2",children:e.jsx(te,{className:"p-4",children:_()})})}):T?e.jsxs("div",{className:"fixed inset-0 z-[9999]",style:{pointerEvents:"none"},"data-testid":"kb-walkthrough-editor-overlay",children:[e.jsx("div",{className:"fixed inset-0 bg-black/15 transition-opacity duration-300",style:{pointerEvents:"none"}}),f&&!P&&e.jsx("div",{className:"fixed z-[10000] rounded-lg transition-all duration-300",style:{to
206p:f.top-6,left:f.left-6,width:f.width+12,height:f.height+12,boxShadow:"0 0 0 9999px rgba(0,0,0,0.15), 0 0 16px 2px rgba(178,72,132,0.25)",pointerEvents:"none"}}),e.jsx("div",{ref:w,className:"fixed z-[10001] transition-all duration-300",style:{top:P?"50%":x.top,left:P?"50%":x.left,transform:P?"translate(-50%, -50%)":void 0,pointerEvents:"auto"},children:e.jsx(ee,{className:"w-96 shadow-2xl border-primary/20","data-testid":`kb-walkthrough-step-${l}`,children:e.jsx(te,{className:"p-5",children:_()})})})]}):e.jsxs("div",{className:"fixed inset-0 z-[9999]",style:{pointerEvents:z?"none":"auto"},"data-testid":"kb-walkthrough-overlay",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 transition-opacity duration-300",style:{pointerEvents:"none"}}),f&&!P&&e.jsx("div",{className:"fixed z-[10000] rounded-lg transition-all duration-300",style:{top:f.top-4,left:f.left-4,width:f.width+8,height:f.height+8,boxShadow:"0 0 0 9999px rgba(0,0,0,0.5), 0 0 20px 4px rgba(178,72,132,0.4)",pointerEvents:"none"}}),P?e.jsx("div",{className:"fixed inset-0 z-[10001] flex items-center justify-center p-4",style:{pointerEvents:"auto"}
206,children:e.jsx(ee,{className:"w-full max-w-md shadow-2xl border-primary/20","data-testid":`kb-walkthrough-step-${l}`,children:e.jsx(te,{className:"p-5",children:_()})})}):e.jsx("div",{ref:w,className:"fixed z-[10001] transition-all duration-300",style:{top:x.top,left:x.left,pointerEvents:"auto"},children:e.jsx(ee,{className:"w-80 shadow-2xl border-primary/20","data-testid":`kb-walkthrough-step-${l}`,children:e.jsx(te,{className:"p-4",children:_()})})})]})}function xz(t=!0){const[s,n]=m.useState(!1),[a,o]=m.useState(!1),{data:l,isLoading:d}=je({queryKey:["/api/portal/onboarding/status"],enabled:t,retry:1}),u=ye({mutationFn:async w=>(await ce("POST","/api/portal/onboarding/update",w)).json(),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/portal/onboarding/status"]})}}),h=ye({mutationFn:async()=>(await ce("POST","/api/portal/onboarding/reset")).json(),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/portal/onboarding/status"]})}});m.useEffect(()=>{!d&&l&&!a&&(o(!0),!l.onboardingCompleted&&!l.onboardingDismissed&&n(!0))},[l,d,a]);const f=m.useCallback(()=>{n(!1),u.mutate({onboardingCompleted:!0,onboardingStep:0})},[u]),g=m.useCallback(()=>{n(!1),u.mutate({onboardingDismissed:!0})},[u]),x=m.useCallback(w=>{u.mutate({onboardingStep:w})},[u]),v=m.useCallback(()=>{h.mutate(void 0,{onSuccess:()=>{o(!0),n(!0)}})},[h]);return{showTour:s,setShowTour:n,status:l,isLoading:d,initialStep:l?.onboardingStep||0,completeTour:f,dismissTour:g,updateStep:x,restartTour:v,role:l?.role||"viewer"}}const Xk={admin:"Administrator",manager:"Manager",editor:"Editor",viewer:"Viewer"},vz={"knowledge-bases":["admin","manager","editor","viewer"],procedures:["admin","manager","editor","viewer"],overviews:["admin","manager","editor","viewer"],company:["admin"],users:["admin","manager"],teams:["admin","manager"],profile:["admin","manager","editor","viewer"],archive:["admin"],billing:["admin"],export:["admin"],analytics:["admin","manager"]};function yz(t,s){return vz[s].includes(t)}function jz(t){return t==="admin"||t==="manager"||t==="editor"}function mh(t){return jz(t)}const pg={public:{label:"Public",description:"Anyone can view",icon:$n},org:{label:"Organization",description:"Any logged-in user in your organization",icon:Qn},teams:{label:"Specific Teams",description:"Only selected teams can view",icon:Hi}};function wz({visibility:t,selectedTeamIds:s,teams:n,onVisibilityChange:a,onTeamsChange:o,showLabel:l=!0,compact:d=!1}){const u=h=>{s.includes(h)?o(s.filter(f=>f!==h)):o([...s,h])};return e.jsxs("div",{className:"space-y-3",children:[l&&e.jsx(Z,{children:"Visibility"}),e.jsxs(lt,{value:t,onValueChange:h=>a(h),children:[e.jsx(it,{"data-testid":"select-visibility",children:e.jsx(ct,{})}),e.jsx(ot,{children:ck.map(h=>{const f=pg[h],g=f.icon;return e.jsx(me,{value:h,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{className:"w-4 h-4"}),e.jsx("span",{children:f.label})]})},h)})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:pg[t].description}),t==="teams"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{className:"text-sm",children:"Select Teams"}),n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No teams available. Create teams first in the Teams section."}):e.jsx("div",{className:`space-y-1 ${d?"max-h-32":"max-h-48"} overflow-y-auto`,children:n.map(h=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md hover-elevate cursor-pointer",onClick:()=>u(h.id),"data-testid":`checkbox-team-${h.id}`,children:[e.jsx("input",{type:"checkbox",checked:s.includes(h.id),onChange:()=>u(h.id),className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:h.name})]},h.id))}),t==="teams"&&s.length===0&&e.jsx("p",{className:"text-xs text-destructive",children:"Select at least one team"})]})]})}function bz({logout:t,userEmail:s}){const[,n]=Kr(),[a,o]=m.useState(!1),[l,d]=m.useState(""),[u,h]=m.useState(""),{toast:f}=dt(),g=Dn.diy,x=async()=>{if(!l.trim()||!u.trim()){f({title:"Name required",description:"Please enter your first and last name to continue.",variant:"destructive"});return}o(!0);try{const v=await fetch("/api/stripe/create-checkout-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:s,plan:"diy",firstName:l.trim(),lastName:u.trim()})});if(!v.ok){const C=await v.json();throw new Error(C.error||"Failed to create checkout session")}const{url:w}=await v.json();w&&(window.location.href=w)}catch(v){f({title:"Error",description:v.message||"Failed to start checkout",variant:"destructive"}),o(!1)}};return e.jsx("div",{className:"min-h-screen flex flex-col items-center justify-center p-4 bg-background",children:e.jsxs("div",{className:"max-w-2xl w-full space-y-8",children:[e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx(ht,{href:"/",children:e.jsx("span",{className:"font-serif text-3xl cursor-pointer","data-testid":"link-paywall-logo",children:"outliner"})}),e.jsx("h1",{className:"text-2xl font-semibold mt-4",children:"Complete Your Profile"}),e.jsxs("p",{className:"text-muted-foreground max-w-md mx-auto",children:["Enter your name to get started with ",g.name,"."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Signed in as ",s]})]}),e.jsxs(ee,{className:"max-w-md mx-auto",children:[e.jsx(qe,{children:e.jsx(tt,{className:"text-lg",children:"Your Information"})}),e.jsx(te,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"firstName",children:"First Name"}
206),e.jsx(fe,{id:"firstName",value:l,onChange:v=>d(v.target.value),placeholder:"John","data-testid":"input-paywall-firstName"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"lastName",children:"Last Name"}),e.jsx(fe,{id:"lastName",value:u,onChange:v=>h(v.target.value),placeholder:"Smith","data-testid":"input-paywall-lastName"})]})]})})]}),e.jsxs(ee,{className:"max-w-md mx-auto",children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(di,{className:"h-5 w-5"}),g.name]}),e.jsx(Tt,{children:g.description})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"text-3xl font-bold",children:["$",g.price,e.jsx("span",{className:"text-base font-normal text-muted-foreground",children:"/mo"})]}),e.jsx("ul",{className:"space-y-2 text-sm",children:g.features.map((v,w)=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(Sr,{className:"h-4 w-4 text-green-600 dark:text-green-400 flex-shrink-0"}),e.jsx("span",{children:v})]},w))}),e.jsx("div",{className:"pt-4 mt-4",children:e.jsxs(D,{className:"w-full",onClick:x,disabled:a,"data-testid":"button-subscribe",children:[a?e.jsx(Ve,{className:"h-4 w-4 animate-spin mr-2"}):null,"Subscribe Now"]})})]})]}),e.jsx("div",{className:"text-center mt-8",children:e.jsx(D,{variant:"ghost",onClick:()=>{t(),n("/")},"data-testid":"button-paywall-signout",children:"Sign out"})})]})})}const Nz=[{label:"Content",items:[{id:"knowledge-bases",label:"Knowledge Bases",icon:cs,feature:"knowledge-bases"},{id:"procedures",label:"Procedures",icon:Pt,feature:"procedures"},{id:"overviews",label:"Overviews",icon:ln,feature:"overviews"},{id:"archive",label:"Archive",icon:Rm,feature:"archive"}]},{label:"Team",items:[{id:"users",label:"Users",icon:Bs,feature:"users"},{id:"teams",label:"Teams",icon:Hi,feature:"teams"}]},{label:"Insights",items:[{id:"analytics",label:"Analytics",icon:Am,feature:"analytics"}]},{label:"Settings",items:[{id:"company",label:"Company",icon:Qn,feature:"company"},{id:"billing",label:"Billing",icon:di,feature:"billing"},{id:"export",label:"Export Data",icon:Fi,feature:"export"}]}],Jk=m.createContext({user:null,isLoading:!0,logout:()=>{}});function kl(){return m.useContext(Jk)}const Sz=["knowledge-bases","procedures","overviews","company","users","teams","profile","archive","billing","export","analytics"];function hb(t){return Sz.includes(t)}function Au(){const[t,s]=Kr(),[,n]=ar("/portal/:section"),[,a]=ar("/portal/procedures/:procedureId"),[,o]=ar("/portal/overviews/:procedureId"),{user:l,isLoading:d,logout:u}=Oa(),h=n?.section,f=a?.procedureId||o?.procedureId,g=a?.procedureId?"procedures":o?.procedureId?"overviews":null,x=g||(hb(h)?h:"knowledge-bases"),[v,w]=m.useState(x),[C,j]=m.useState(null),[b,k]=m.useState(null),[N,T]=m.useState(f||null);m.useEffect(()=>{if(f&&g){w(g),T(f);return}const le=hb(h)?h:"knowledge-bases";le!==v&&w(le),!h&&t==="/portal"&&s("/portal/knowledge-bases",{replace:!0})},[h,t,s,f,g]);const P=le=>{w(le),T(null),s(`/portal/${le}`)},I=m.useCallback((le,Me)=>{T(le),s(le?`/portal/${Me||(v==="overviews"?"overviews":"procedures")}/${le}`:`/portal/${v}`)},[v,s]),O=l?.clientId,{data:R}=je({queryKey:[`/api/clients/${O}`],enabled:!!O}),{data:F,isLoading:M}=je({queryKey:["/api/subscription/status",O],queryFn:async()=>{const le=await fetch(`/api/subscription/status?clientId=${O}`);if(!le.ok)throw new Error("Failed to check subscription");return le.json()},enabled:!!O}),{data:z}=je({queryKey:["/api/portal/analytics/settings"],enabled:!!O}),H=z?.monitorKbAging||!1,V=z?.monitorCategoryAging||!1,B=z?.monitorContentAging||!1;m.useEffect(()=>{!d&&!l&&s("/portal/login")},[d,l,s]);const Y=l,L=Y?.role||"viewer",K=mh(L),{showTour:_,completeTour:$,dismissTour:A,updateStep:W,restartTour:U,initialStep:Q,role:we}=xz(!!l),[_e,Ie]=m.useState(!1),Te=m.useCallback(()=>{$(),K&&O&&Ie(!0)},[$,K,O]),ue=m.useCallback(()=>{Ie(!1)},[]),Re=m.useRef(null);m.useEffect(()=>{Y?.id&&Re.current!==Y.id&&(Re.current=Y.id,ce("POST",`/api/client-users/${Y.id}/activity`,{}).catch(le=>console.error("Failed to track activity:",le)))},[Y?.id]);const $e={"--sidebar-width":"16rem","--sidebar-width-icon":"3rem"};return d||l&&!O||M?e.jsx("div",{className:"flex h-screen items-center justify-center",children:e.jsx(Ve,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):!l||!O?null:F?.hasActiveSubscription?e.jsx(Jk.Provider,{value:{user:Y,isLoading:d,logout:u},children:e.jsxs(pS,{style:$e,children:[e.jsxs("div",{className:"flex h-screen w-full",children:[e.jsx(Cz,{currentView:v,userRole:L,clientId:O,onViewChange:le=>{P(le),le==="knowledge-bases"&&(j(null),k(null))},onNavigateToKB:le=>{w("knowledge-bases"),j(le),k(null),I(null),s("/portal/knowledge-bases")},onNavigateToProcedure:(le,Me)=>
206{w("knowledge-bases"),Me&&(j(Me),k(null)),I(le,"procedures")}}),e.jsxs("div",{className:"flex flex-col flex-1",children:[e.jsxs("header",{className:"flex items-center justify-between gap-4 p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(xS,{"data-testid":"button-portal-sidebar-toggle"}),e.jsx(kz,{view:v,selectedKB:C,selectedCategory:b,selectedProcedure:N,onNavigateToView:()=>{j(null),k(null),I(null)},onNavigateToKB:()=>{k(null),I(null)},onNavigateToCategory:()=>{I(null)},clientId:O})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ra,{}),e.jsx("a",{href:R?.slug?`/${R.slug}`:"/",target:"_blank",rel:"noopener noreferrer",children:e.jsxs(D,{variant:"ghost","data-testid":"button-portal-view-site",children:[e.jsx(Yn,{className:"h-4 w-4 mr-1"}),"View Knowledge Center"]})})]})]}),e.jsxs("main",{className:"flex-1 overflow-auto p-6",children:[v==="knowledge-bases"&&O&&e.jsx(Pz,{clientId:O,selectedKB:C,onSelectKB:j,selectedCategory:b,onSelectCategory:k,selectedProcedure:N,onSelectProcedure:I,showKbFreshnessBadge:H,showCategoryFreshnessBadge:V,showContentFreshnessBadge:B,kbThreshold:z?.kbAgingThresholdDays||180,categoryThreshold:z?.categoryAgingThresholdDays||90,contentThreshold:z?.contentAgingThresholdDays||90,userCanEdit:K}),v==="procedures"&&O&&e.jsx(zz,{clientId:O,selectedProcedure:N,onSelectProcedure:I,showFreshnessBadge:B,contentThreshold:z?.contentAgingThresholdDays||90}),v==="overviews"&&O&&e.jsx(Bz,{clientId:O,selectedProcedure:N,onSelectProcedure:I,showFreshnessBadge:B,contentThreshold:z?.contentAgingThresholdDays||90}),v==="company"&&O&&e.jsx(Oz,{clientId:O}),v==="users"&&O&&e.jsx(Mz,{clientId:O}),v==="teams"&&O&&e.jsx(Fz,{clientId:O}),v==="profile"&&e.jsx($z,{}),v==="archive"&&e.jsx(Uz,{}),v==="billing"&&O&&e.jsx(Vz,{clientId:O}),v==="export"&&O&&e.jsx(qz,{clientId:O}),v==="analytics"&&O&&e.jsx(Kz,{clientId:O,onNavigateToContent:(le,Me,He)=>{j(le),k(Me),I(He,"procedures"),w("knowledge-bases")},onNavigateToKB:le=>{j(le),k(null),I(null),w("knowledge-bases"),s("/portal/knowledge-bases")}})]})]})]}),e.jsx(uz,{}),_&&e.jsx(hz,{role:we,onComplete:Te,onDismiss:A,onStepChange:W,initialStep:Q}),_e&&O&&e.jsx(gz,{clientId:O,onComplete:ue,onDismiss:()=>Ie(!1),onNavigateToKBList:()=>{P("knowledge-bases"),j(null),k(null),I(null)},onNavigateToKB:le=>{P("knowledge-bases"),j(le),k(null),I(null)}}),e.jsx(fz,{onRestartTour:U})]})}):e.jsx(bz,{logout:u,userEmail:l.email})}function Cz({currentView:t,userRole:s,clientId:n,onViewChange:a,onNavigateToKB:o,onNavigateToProcedure:l}){const{user:d,logout:u}=kl(),[,h]=Kr(),[f,g]=m.useState(""),[x,v]=m.useState(!1),{data:w=[]}=je({queryKey:[`/api/clients/${n}/knowledge-bases`]}),{data:C=[]}=je({queryKey:[`/api/clients/${n}/procedures`],queryFn:async()=>{const P=await fetch(`/api/clients/${n}/procedures`);if(!P.ok)throw new Error("Failed to fetch procedures");return P.json()}}),{data:j=[]}=je({queryKey:["/api/archive/procedures"]}),b=f.trim()?(()=>{const P=f.toLowerCase(),I=[];return w.forEach(O=>{(O.name.toLowerCase().includes(P)||O.description?.toLowerCase().includes(P))&&I.push({id:O.id,type:"kb",name:O.name,description:O.description||""})}),C.forEach(O=>{if(O.title.toLowerCase().includes(P)||O.description?.toLowerCase().includes(P)){const R=w.find(F=>F.id===O.knowledgeBaseId);I.push({id:O.id,type:O.contentType==="overview"?"overview":"procedure",name:O.title,description:O.description||"",kbId:O.knowledgeBaseId||void 0,kbName:R?.name,isArchived:!1})}}),j.forEach(O=>{(O.title.toLowerCase().includes(P)||O.description?.toLowerCase().includes(P))&&I.push({id:O.id,type:O.contentType==="overview"?"overview":"procedure",name:O.title,description:O.description||"",isArchived:!0})}),I.slice(0,10)})():[],k=P=>{P.key==="Enter"&&f.trim()&&v(!0),P.key==="Escape"&&(v(!1),g(""))},N=P=>{P.type==="kb"?o(P.id):P.isArchived?a("archive"):l(P.id,P.kbId),v(!1),g("")},T=Nz.map(P=>({...P,items:P.items.filter(I=>yz(s,I.feature))})).filter(P=>P.items.length>0);return e.jsxs(gS,{children:[e.jsx(vS,{className:"p-4 border-b border-sidebar-border",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ht,{href:"/portal",children:e.jsx("span",{className:"font-serif text-2xl cursor-pointer","data-testid":"link-portal-logo",children:"outliner"})}),e.jsx(Ce,{variant:"secondary",className:"text-xs",children:"Portal"})]})}),e.jsxs("div",{className:"p-3 border-b border-sidebar-border relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Mm,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-zinc-400"}),e.jsx("input",{type:"text",placeholder:"Search all content...",value:f,onChange:P=>g(P.target.value),onKeyDown:k,onFocus:()=>f.trim()&&v(!0),className:"w-full h-9 pl-8 pr-8 rounded-md bg-zinc-800 border border-zinc-700 text-zinc-100 placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary text-sm","data-testid":"input-global-search"}),f&&e.jsx("button",{onClick:()=>{g(""),v(!1)},className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-zinc-400 hover:text-zinc-200",children:e.jsx(Zn,{className:"h-4 w-4"})})]}),x&&f.trim()&&e.jsx("div",{className:"absolute left-3 right-3 top-full mt-2 bg-zinc-900 border border-zinc-700 rounded-lg shadow-2xl z-50 max-h-80 overflow-auto",children:b.length===0?e.jsxs("div",{className:"p-4 text-sm text-zinc-400 text-center",children:['No results found for "',f,'"']}):e.jsx("div",{className:"py-2",children:b.map(P=>e.jsxs("button",{onClick:()=>N(P),className:"w-full text-left px-4 py-3 hover:bg-zinc-800 transition-colors flex items-start gap-3 border-b border-zinc-800 last:border-b-0","data-testid":`search-result-${P.id}`,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-sm text-zinc-100 truncate",children:P.name}),e.jsxs("span",{className:"inline-flex items-center text-xs px-2 py-0.5 rounded-full bg-primary/20 text-primary border border-primary/30",children:[P.type==="
206kb"&&e.jsx(cs,{className:"w-3 h-3 mr-1"}),P.type==="procedure"&&e.jsx(Pt,{className:"w-3 h-3 mr-1"}),P.type==="overview"&&e.jsx(ln,{className:"w-3 h-3 mr-1"}),P.type==="kb"?"Knowledge Base":P.type==="procedure"?"Procedure":"Overview"]}),P.isArchived&&e.jsxs("span",{className:"inline-flex items-center text-xs px-2 py-0.5 rounded-full bg-orange-900/40 text-orange-400 border border-orange-700/50",children:[e.jsx(Rm,{className:"w-3 h-3 mr-1"}),"Archived"]})]}),P.kbName&&e.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:["in ",P.kbName]})]}),e.jsx(Bt,{className:"w-4 h-4 text-zinc-500 flex-shrink-0 mt-0.5"})]},`${P.type}-${P.id}`))})})]}),e.jsx(jS,{children:T.map(P=>e.jsxs(Mo,{children:[e.jsx(hc,{children:P.label}),e.jsx(Lo,{children:e.jsx(Fo,{children:P.items.map(I=>e.jsx($o,{children:e.jsxs(Uo,{isActive:t===I.id,onClick:()=>a(I.id),"data-testid":`button-portal-nav-${I.id}`,children:[e.jsx(I.icon,{className:"h-4 w-4"}),e.jsx("span",{children:I.label})]})},I.id))})})]},P.label))}),e.jsx(yS,{className:"p-3 border-t border-sidebar-border",children:e.jsxs(Gi,{children:[e.jsx(Yi,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-3 w-full p-2 rounded-md hover-elevate text-left","data-testid":"button-user-menu",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center text-sm font-semibold",children:d?.firstName?.charAt(0).toUpperCase()||d?.email?.charAt(0).toUpperCase()||"U"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:d?.firstName?`${d.firstName} ${d.lastName||""}`.trim():d?.email||"User"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:Xk[s]||s})]}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"})]})}),e.jsxs(pi,{align:"end",className:"w-56",children:[e.jsx(on,{asChild:!0,"data-testid":"button-go-to-profile",children:e.jsxs(ht,{href:"/portal/profile",children:[e.jsx(Hr,{className:"h-4 w-4 mr-2"}),"My Profile"]})}),e.jsx(Px,{}),e.jsxs(on,{onClick:()=>{u(),h("/portal/login")},"data-testid":"button-logout",children:[e.jsx(Om,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})})]})}function kz({view:t,selectedKB:s,selectedCategory:n,selectedProcedure:a,onNavigateToView:o,onNavigateToKB:l,onNavigateToCategory:d,clientId:u}){const{data:h=[]}=je({queryKey:[`/api/clients/${u}/knowledge-bases`],enabled:!!u}),{data:f=[]}=je({queryKey:s?[`/api/knowledge-bases/${s}/categories`]:["disabled-categories"],enabled:!!s}),g={"knowledge-bases":"Knowledge Bases",procedures:"Procedures",overviews:"Overviews",company:"Company",users:"Users",teams:"Teams",profile:"My Profile",archive:"Archive",billing:"Billing",export:"Export",analytics:"Analytics"},x=h.find(b=>b.id===s),v=f.find(b=>b.id===n),w=t==="knowledge-bases"&&(s||n||a),C=n||a,j=a;return e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[w?e.jsx("button",{onClick:o,className:"font-medium hover:underline","data-testid":"button-breadcrumb-view",children:g[t]}):e.jsx("span",{className:"font-medium","data-testid":"text-breadcrumb-view",children:g[t]}),s&&x&&e.jsxs(e.Fragment,{children:[e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"}),C?e.jsx("button",{onClick:l,className:"font-medium hover:underline","data-testid":"button-breadcrumb-kb",children:x.name}):e.jsx("span",{className:"font-medium","data-testid":"text-breadcrumb-kb",children:x.name})]}),n&&v&&e.jsxs(e.Fragment,{children:[e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"}),j?e.jsx("button",{onClick:d,className:"font-medium hover:underline","data-testid":"button-breadcrumb-category",children:v.name}):e.jsx("span",{className:"font-medium","data-testid":"text-breadcrumb-category",children:v.name})]})]})}function Pz({clientId:t,selectedKB:s,onSelectKB:n,selectedCategory:a,onSelectCategory:o,selectedProcedure:l,onSelectProcedure:d,showKbFreshnessBadge:u=!1,showCategoryFreshnessBadge:h=!1,showContentFreshnessBadge:f=!1,kbThreshold:g=180,categoryThreshold:x=90,contentThreshold:v=90,userCanEdit:w=!1}){return s?l?e.jsx(Jx,{procedureId:l,onBack:()=>d(null),clientId:t},l):e.jsx(Iz,{kbId:s,onBack:()=>n(null),onSelectProcedure:d,showCategoryFreshnessBadge:h,showContentFreshnessBadge:f,categoryThreshold:x,contentThreshold:v,userCanEdit:w}):e.jsx(Ez,{clientId:t,onSelectKB:n,showFreshnessBadge:u,kbThreshold:g,userCanEdit:w})}
206function io(t,s=90){if(!t)return{status:"stale",daysSinceUpdate:999};const n=typeof t=="string"?new Date(t):t,o=Math.floor((new Date().getTime()-n.getTime())/(1e3*60*60*24));return{status:o>s?"stale":"fresh",daysSinceUpdate:o}}function Ni({status:t,daysSinceUpdate:s,showDays:n=!1,testId:a,thresholdDays:o=90}){const l=s===0?"today":s===1?"1 day ago":`${s}d ago`,d={fresh:`This content is up to date. Last updated ${l}. Content is considered fresh when updated within the last ${o} days.`,aging:`This content may need review. Last updated ${l}. Content approaching the ${o}-day threshold should be reviewed.`,stale:`This content needs attention. Last updated ${l}. Content older than ${o} days should be reviewed for accuracy.`};return e.jsxs(d0,{children:[e.jsx(u0,{asChild:!0,children:e.jsxs(Ce,{variant:"default",className:`flex-shrink-0 no-default-hover-elevate no-default-active-elevate ${t==="fresh"?"bg-green-500/10 text-green-600 dark:bg-green-500/20 dark:text-green-400":t==="aging"?"bg-yellow-500/10 text-yellow-600 dark:bg-yellow-500/20 dark:text-yellow-400":"bg-red-500/10 text-red-600 dark:bg-red-500/20 dark:text-red-400"}`,"data-testid":a,children:[t==="stale"?e.jsx(pl,{className:"w-3 h-3 mr-1"}):e.jsx(Vi,{className:"w-3 h-3 mr-1"}),n?l:t==="fresh"?"Fresh":t==="aging"?"Review":"Stale"]})}),e.jsx(Yg,{side:"top",className:"max-w-xs",children:e.jsx("p",{className:"text-sm",children:d[t]})})]})}function Tz({kb:t,companySlug:s,onSelect:n,onEdit:a,onDelete:o,showFreshnessBadge:l=!1,kbThreshold:d=180,userCanEdit:u=!1}){const{attributes:h,listeners:f,setNodeRef:g,transform:x,transition:v,isDragging:w}=ah({id:t.id}),C={transform:gi.Transform.toString(x),transition:v,opacity:w?.5:1},{toast:j}=dt(),[b,k]=m.useState(!1),{data:N=[]}=je({queryKey:[`/api/knowledge-bases/${t.id}/categories`]}),{data:T=[]}=je({queryKey:[`/api/knowledge-bases/${t.id}/procedures`]}),P=T.filter(V=>V.contentType==="procedure").length,I=T.filter(V=>V.contentType==="overview").length,O=N.length,R=io(t.updatedAt||t.createdAt,d),F=t.slug?`/${s}/${t.slug}`:`/kb/${s}`,M=`${window.location.origin}${F}`,z=V=>{V.stopPropagation(),navigator.clipboard.writeText(M),k(!0),j({title:"Link copied to clipboard"}),setTimeout(()=>k(!1),2e3)},H=V=>{V.stopPropagation(),window.open(F,"_blank")};return e.jsx(ee,{ref:g,style:C,className:"hover-elevate transition-all cursor-pointer",onClick:n,"data-testid":`card-kb-${t.id}`,children:e.jsx(te,{className:"py-4 px-5",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{...h,...f,className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center cursor-grab active:cursor-grabbing flex-shrink-0",onClick:V=>V.stopPropagation(),children:e.jsx(Dm,{className:"h-4 w-4 text-primary"})}),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-medium truncate max-w-[200px] sm:max-w-none",children:t.name}),e.jsxs(Ce,{variant:t.visibility==="public"||!t.visibility&&t.isPublic?"default":"secondary",className:"flex-shrink-0",children:[t.visibility==="public"||!t.visibility&&t.isPublic?e.jsx($n,{className:"w-3 h-3 mr-1"}):t.visibility==="teams"?e.jsx(Hi,{className:"w-3 h-3 mr-1"}):e.jsx(Qn,{className:"w-3 h-3 mr-1"}),t.visibility==="public"||!t.visibility&&t.isPublic?"Public":t.visibility==="teams"?"Teams":"Org"]}),l&&e.jsx(Ni,{status:R.status,daysSinceUpdate:R.daysSinceUpdate,showDays:!0,testId:`badge-freshness-kb-${t.id}`,thresholdDays:d})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5 line-clamp-2",children:t.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 sm:pl-11",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1.5",title:"Categories",children:[e.jsx(Fr,{className:"w-4 h-4"}),e.jsx("span",{children:O})]}),e.jsxs("div",{className:"flex items-center gap-1.5",title:"Procedures",children:[e.jsx(Pt,{className:"w-4 h-4"}),e.jsx("span",{children:P})]}),e.jsxs("div",{className:"flex items-center gap-1.5",title:"Overviews",children:[e.jsx(ln,{className:"w-4 h-4"}),e.jsx("span",{children:I})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(D,{variant:"ghost",size:"icon",onClick:H,title:"Open in new tab","data-testid":`button-open-kb-${t.id}`,children:e.jsx(Yn,{className:"w-4 h-4"})}),e.jsx(D,{variant:"ghost",size:"icon",onClick:z,title:"Copy link","data-testid":`button-copy-kb-${t.id}`,children:b?e.jsx(yr,{className:"w-4 h-4"}):e.jsx(vN,{className:"w-4 h-4"})}),e.jsxs(D,{variant:"ghost",size:"sm",onClick:V=>{V.stopPropagation(),n()},"data-testid":`button-view-kb-${t.id}`,children:[e.jsx(Bt,{className:"w-4 h-4 mr-1"}),"View"]}
206),u&&e.jsx(D,{variant:"ghost",size:"icon",onClick:a,"data-testid":`button-edit-kb-${t.id}`,children:e.jsx(fl,{className:"w-4 h-4"})}),u&&e.jsx(D,{variant:"ghost",size:"icon",onClick:o,"data-testid":`button-delete-kb-${t.id}`,children:e.jsx(ts,{className:"w-4 h-4"})})]})]})]})})})}function Ez({clientId:t,onSelectKB:s,showFreshnessBadge:n=!1,kbThreshold:a=180,userCanEdit:o=!1}){const{toast:l}=dt(),[d,u]=m.useState(!1),[h,f]=m.useState(null),[g,x]=m.useState({name:"",slug:"",description:"",visibility:"org"}),[v,w]=m.useState(!1),[C,j]=m.useState([]),[b,k]=m.useState(null),N=Ix(al(md,{activationConstraint:{distance:8}}),al(ud,{coordinateGetter:Mx})),{data:T}=je({queryKey:[`/api/clients/${t}`]}),{data:P=[],isLoading:I}=je({queryKey:[`/api/clients/${t}/knowledge-bases`]}),{data:O=[]}=je({queryKey:[`/api/clients/${t}/teams`]}),R=ye({mutationFn:K=>ce("PATCH",`/api/clients/${t}/knowledge-bases/reorder`,{orderedIds:K}),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/clients/${t}/knowledge-bases`]})},onError:()=>{l({title:"Failed to reorder knowledge bases",variant:"destructive"})}}),F=K=>{const{active:_,over:$}=K;if(!$||_.id===$.id)return;const A=P.findIndex(Q=>Q.id===_.id),W=P.findIndex(Q=>Q.id===$.id),U=il(P,A,W);R.mutate(U.map(Q=>Q.id))},M=ye({mutationFn:async K=>{const _=await ce("POST","/api/knowledge-bases",K);return K.visibility==="teams"&&C.length>0&&await ce("POST",`/api/knowledge-bases/${_.id}/team-access`,{teamIds:C}),_},onSuccess:async()=>{await de.invalidateQueries({queryKey:[`/api/clients/${t}/knowledge-bases`]}),l({title:"Knowledge base created"}),V()}}),z=ye({mutationFn:async({id:K,data:_})=>{const $=await ce("PATCH",`/api/knowledge-bases/${K}`,_);return _.visibility==="teams"?await ce("POST",`/api/knowledge-bases/${K}/team-access`,{teamIds:C}):await ce("POST",`/api/knowledge-bases/${K}/team-access`,{teamIds:[]}),$},onSuccess:async()=>{await de.invalidateQueries({queryKey:[`/api/clients/${t}/knowledge-bases`]}),l({title:"Knowledge base updated"}),V()}}),H=ye({mutationFn:K=>ce("DELETE",`/api/knowledge-bases/${K}`),onSuccess:async()=>{await de.invalidateQueries({queryKey:[`/api/clients/${t}/knowledge-bases`]}),l({title:"Knowledge base archived"}),k(null)}}),V=()=>{x({name:"",slug:"",description:"",visibility:"org"}),w(!1),j([]),f(null),u(!1)},B=async(K,_)=>{if(K.stopPropagation(),f(_),w(!0),x({name:_.name,slug:_.slug||"",description:_.description||"",visibility:_.visibility||"org"}),_.visibility==="teams")try{const $=await fetch(`/api/knowledge-bases/${_.id}/team-access`).then(A=>A.json());j($.map(A=>A.teamId))}catch{j([])}else j([]);u(!0)},Y=(K,_)=>{K.stopPropagation(),k({id:_.id,name:_.name})},L=()=>{h?z.mutate({id:h.id,data:g}):M.mutate({...g,clientId:t})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold","data-testid":"text-kb-title",children:"Knowledge Bases"}),e.jsx("p",{className:"text-muted-foreground",children:"Click on a knowledge base to manage its categories and procedures"})]}),e.jsxs(St,{open:d,onOpenChange:u,children:[o&&e.jsx(bs,{asChild:!0,children:e.jsxs(D,{onClick:()=>{V(),u(!0)},"data-testid":"button-add-kb",children:[e.jsx(ds,{className:"w-4 h-4 mr-2"}),"Add Knowledge Base"]})}),e.jsxs(jt,{children:[e.jsx(wt,{children:e.jsx(bt,{children:h?"Edit Knowledge Base":"New Knowledge Base"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Name"}),e.jsx(fe,{value:g.name,onChange:K=>{const _=K.target.value;x({...g,name:_,slug:!h&&!v?_.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""):g.slug})},"data-testid":"input-kb-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"URL Slug"}),e.jsx(fe,{value:g.slug,onChange:K=>{w(!0),x({...g,slug:K.target.value.toLowerCase().replace(/[^a-z0-9-]+/g,"")})},placeholder:"e.g., operations-manual","data-testid":"input-kb-slug"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in the URL: /company-name/",e.jsx("span",{className:"font-medium",children:g.slug||"slug"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Description"}
206),e.jsx(ss,{value:g.description,onChange:K=>x({...g,description:K.target.value}),"data-testid":"input-kb-description"})]}),e.jsx(wz,{visibility:g.visibility,selectedTeamIds:C,teams:O,onVisibilityChange:K=>x({...g,visibility:K}),onTeamsChange:j}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(D,{onClick:L,disabled:g.visibility==="teams"&&C.length===0,"data-testid":"button-save-kb",children:h?"Update":"Create"}),e.jsx(D,{variant:"outline",onClick:V,children:"Cancel"})]})]})]})]})]}),I?e.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):P.length===0?e.jsx(ee,{children:e.jsxs(te,{className:"py-12 text-center",children:[e.jsx(cs,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"No knowledge bases yet. Create your first one to get started."})]})}):e.jsx(om,{sensors:N,collisionDetection:am,onDragEnd:F,children:e.jsx(cm,{items:P.map(K=>K.id),strategy:lm,children:e.jsx("div",{className:"flex flex-col gap-3",children:P.map(K=>e.jsx(Tz,{kb:K,companySlug:T?.slug||"",onSelect:()=>s(K.id),onEdit:_=>B(_,K),onDelete:_=>Y(_,K),showFreshnessBadge:n,kbThreshold:a,userCanEdit:o},K.id))})})}),e.jsx(St,{open:!!b,onOpenChange:()=>k(null),children:e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsxs(bt,{className:"flex items-center gap-2",children:[e.jsx(pl,{className:"h-5 w-5 text-destructive"}),"Move to Archive?"]}),e.jsxs(Gt,{children:['Are you sure you want to archive "',b?.name,'"? It will be kept for 30 days before permanent deletion. You can restore it from the Archive section. All categories and procedures in this knowledge base will also be archived.']})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsxs(D,{variant:"destructive",onClick:()=>b&&H.mutate(b.id),disabled:H.isPending,"data-testid":"button-confirm-archive-kb",children:[H.isPending&&e.jsx(Ve,{className:"h-4 w-4 animate-spin mr-2"}),"Archive"]}),e.jsx(D,{variant:"outline",onClick:()=>k(null),children:"Cancel"})]})]})})]})}function _z({procedure:t,onSelect:s,onDelete:n,getStatusColor:a,showFreshnessBadge:o=!1,contentThreshold:l=90,userCanEdit:d=!1,clientSlug:u,kbSlug:h,categorySlug:f}){const{attributes:g,listeners:x,setNodeRef:v,transform:w,transition:C,isDragging:j}=ah({id:t.id}),b={transform:gi.Transform.toString(w),transition:C,opacity:j?.5:1},k=()=>{!d&&u&&h&&f&&t.slug?window.open(`/${u}/${h}/${f}/${t.slug}`,"_blank"):s(t.id)};return e.jsxs("div",{ref:v,style:b,className:"flex items-center justify-between gap-2 p-3 rounded-lg border border-border/50 hover-elevate cursor-pointer bg-background",onClick:k,"data-testid":`card-procedure-${t.id}`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("div",{...g,...x,className:"cursor-grab touch-none",onClick:N=>N.stopPropagation(),children:e.jsx(Dm,{className:"h-4 w-4 text-muted-foreground shrink-0"})}),t.contentType==="overview"?e.jsx(ln,{className:"h-4 w-4 text-primary shrink-0"}):e.jsx(Pt,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium block truncate",children:t.title}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:t.description})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o&&(()=>{const N=io(t.updatedAt||t.createdAt,l);return e.jsx(Ni,{status:N.status,daysSinceUpdate:N.daysSinceUpdate,showDays:!0,testId:`badge-freshness-procedure-${t.id}`,thresholdDays:l})})(),e.jsx(Ce,{variant:a(t.status),children:t.status}),d&&e.jsx(D,{variant:"ghost",size:"icon",onClick:N=>n(N,t),"data-testid":`button-delete-procedure-${t.id}`,children:e.jsx(ts,{className:"w-4 h-4"})})]})]})}function Rz({category:t,isSelected:s,onSelect:n,onEdit:a,onDelete:o,procedureCount:l,showFreshnessBadge:d=!1,categoryThreshold:u=90,userCanEdit:h=!1}){const{attributes:f,listeners:g,setNodeRef:x,transform:v,transition:w,isDragging:C}=ah({id:t.id}),j={transform:gi.Transform.toString(v),transition:w,opacity:C?.5:1},b=io(t.updatedAt||t.createdAt,u);return e.jsxs("div",{ref:x,style:j,className:`flex items-center justify-between gap-2 p-3 rounded-lg border cursor-pointer transition-colors ${s?"border-primary bg-primary/5":"border-border/50 hover-elevate"}`,onClick:n,"data-testid":`button-category-${t.id}`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[h&&e.jsx("div",{...f,...g,className:"cursor-grab touch-none",onClick:k=>k.stopPropagation(),children:e.jsx(Dm,{className:"h-4 w-4 text-muted-foreground shrink-0"})}),e.jsx(Cc,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium truncate",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[d&&e.jsx(Ni,{status:b.status,daysSinceUpdate:b.daysSinceUpdate,showDays:!0,testId:`badge-freshness-category-${t.id}`,thresholdDays:u}),t.visibility&&e.jsx(Ce,{variant:t.visibility==="public"?"default":"secondary",className:"text-xs",children:t.visibility==="public"?e.jsx($n,{className:"h-3 w-3"}):t.visibility==="teams"?e.jsx(Hi,{className:"h-3 w-3"}):e.jsx(Qn,{className:"h-3 w-3"})}),e.jsx(Ce,{variant:"secondary",className:"text-xs",children:l}),h&&e.jsx(D,{variant:"ghost",size:"icon",onClick:k=>a(k,t),"data-testid":`button-edit-category-${t.id}`,children:e.jsx(fl,{className:"w-4 h-4"})}),h&&e.jsx(D,{variant:"ghost",size:"icon",onClick:k=>o(k,t),"data-testid":`button-delete-category-${t.id}`,children:e.jsx(ts,{className:"w-4 h-4"})})]})]})}function Az({procedure:t,onSelect:s,onDelete:n,getStatusColor:a,showFreshnessBadge:o=!1,contentThreshold:l=90,userCanEdit:d=!1,clientSlug:u,kbSlug:h,categorySlug:f}){const g=io(t.updatedAt||t.createdAt,l),x=()=>{!d&&u&&h&&f&&t.slug?window.open(`/${u}/${h}/${f}/${t.slug}`,"_blank"):s(t.id)};return e.jsxs("div",{className:"flex items-center justify-between gap-2 p-3 rounded-lg border border-border/50 hover-elevate cursor-pointer bg-background",onClick:x,"data-testid":`card-procedure-${t.id}`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[t.contentType==="overview"?e.jsx(ln,{className:"h-4 w-4 text-primary shrink-0"}):e.jsx(Pt,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium block truncate",children:t.title}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:t.description})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o&&e.jsx(Ni,{status:g.status,daysSinceUpdate:g.daysSinceUpdate,showDays:!0,testId:`badge-freshness-content-${t.id}`,thresholdDays:l}),e.jsx(Ce,{variant:a(t.status),children:t.status}),d&&e.jsx(D,{variant:"ghost",size:"icon",onClick:v=>n(v,t),"data-testid":`button-delete-procedure-${t.id}`,children:e.jsx(ts,{className:"w-4 h-4"})})]})]})}function Iz({kbId:t,onBack:s,onSelectProcedure:n,showCategoryFreshnessBadge:a=!1,showContentFreshnessBadge:o=!1,categoryThreshold:l=90,contentThreshold:d=90,userCanEdit:u=!1}){const{toast:h}=dt(),[f,g]=m.useState(!1),[x,v]=m.useState(!1),[w,C]=m.useState(null),[j,b]=m.useState(null),[k,N]=m.useState(null),[T,P]=m.useState({name:"",slug:"",visibility:null}),[I,O]=m.useState(!1),[R,F]=m.useState([]),[M,z]=m.useState({title:"",slug:"",description:"",status:"draft",owner:"",visibility:null,categoryId:"",contentType:"procedure"}),[H,V]=m.useState(!1),[B,Y]=m.useState([]),{data:L}=je({queryKey:[`/api/knowledge-bases/${t}`]}),{data:K=[],isLoading:_}=je({queryKey:[`/api/knowledge-bases/${t}/categories`]}),{data:$=[],isLoading:A}=je({queryKey:[`/api/knowledge-bases/${t}/procedures`]}),W=L?.clientId,{data:U}=je({queryKey:["/api/clients",W],enabled:!!W}),{data:Q=[]}=je({queryKey:[`/api/clients/${W}/teams`],enabled:!!W}),we=U?.slug&&L?.slug?`/${U.slug}/${L.slug}`:null,_e=m.useMemo(()=>{const ne={};
206return K.forEach(pe=>{pe.slug&&(ne[pe.id]=pe.slug)}),ne},[K]),Ie=ye({mutationFn:async ne=>{const pe=await ce("POST","/api/categories",ne);return ne.visibility==="teams"&&R.length>0&&await ce("POST",`/api/categories/${pe.id}/team-access`,{teamIds:R}),pe},onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/knowledge-bases/${t}/categories`]}),h({title:"Category created"}),zt()}}),Te=ye({mutationFn:async({id:ne,data:pe})=>{const ut=await ce("PATCH",`/api/categories/${ne}`,pe);return pe.visibility==="teams"?await ce("POST",`/api/categories/${ne}/team-access`,{teamIds:R}):await ce("POST",`/api/categories/${ne}/team-access`,{teamIds:[]}),ut},onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/knowledge-bases/${t}/categories`]}),h({title:"Category updated"}),zt()}}),ue=ye({mutationFn:ne=>ce("DELETE",`/api/categories/${ne}`),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/knowledge-bases/${t}/categories`]}),de.invalidateQueries({queryKey:[`/api/knowledge-bases/${t}/procedures`]}),h({title:"Category moved to archive",description:"You can restore it from the Archive section"}),N(null),b(null)}}),Re=ye({mutationFn:ne=>ce("DELETE",`/api/procedures/${ne}`),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/knowledge-bases/${t}/procedures`]}),h({title:"Procedure moved to archive",description:"You can restore it from the Archive section"}),N(null)}}),$e=ye({mutationFn:async ne=>(await ce("POST","/api/procedures",ne)).json(),onSuccess:ne=>{de.invalidateQueries({queryKey:[`/api/knowledge-bases/${t}/procedures`]});const pe=M.contentType==="overview"?"Overview":"Procedure";h({title:`${pe} created`}),Wt(),ne?.id&&setTimeout(()=>n(ne.id),0)}}),le=ye({mutationFn:ne=>ce("PATCH",`/api/knowledge-bases/${t}/content-order`,{orderedIds:ne}),onMutate:async ne=>{await de.cancelQueries({queryKey:[`/api/knowledge-bases/${t}/procedures`]});const pe=de.getQueryData([`/api/knowledge-bases/${t}/procedures`]);if(pe){const ut=ne.map((ms,Kt)=>{const kt=pe.find(xs=>xs.id===ms);return kt?{...kt,order:Kt}:null}).filter(Boolean),mt=pe.filter(ms=>!ne.includes(ms.id));de.setQueryData([`/api/knowledge-bases/${t}/procedures`],[...ut,...mt])}return{previousProcedures:pe}},onError:(ne,pe,ut)=>{ut?.previousProcedures&&de.setQueryData([`/api/knowledge-bases/${t}/procedures`],ut.previousProcedures),h({title:"Failed to reorder content",variant:"destructive"})},onSettled:()=>{de.invalidateQueries({queryKey:[`/api/knowledge-bases/${t}/procedures`]})}}),Me=ye({mutationFn:ne=>ce("PATCH",`/api/knowledge-bases/${t}/categories/reorder`,{orderedIds:ne}),onMutate:async ne=>{await de.cancelQueries({queryKey:[`/api/knowledge-bases/${t}/categories`]});const pe=de.getQueryData([`/api/knowledge-bases/${t}/categories`]);if(pe){const ut=ne.map((mt,ms)=>{const Kt=pe.find(kt=>kt.id===mt);return Kt?{...Kt,order:ms}:null}).filter(Boolean);de.setQueryData([`/api/knowledge-bases/${t}/categories`],ut)}return{previousCategories:pe}},onError:(ne,pe,ut)=>{ut?.previousCategories&&de.setQueryData([`/api/knowledge-bases/${t}/categories`],ut.previousCategories),h({title:"Failed to reorder categories",variant:"destructive"})},onSettled:()=>{de.invalidateQueries({queryKey:[`/api/knowledge-bases/${t}/categories`]})}}),He=Ix(al(md,{activationConstraint:{distance:8}}),al(ud,{coordinateGetter:Mx})),ft=ne=>{const{active:pe,over:ut}=ne;if(ut&&pe.id!==ut.id){const mt=K.findIndex(kt=>kt.id===pe.id),ms=K.findIndex(kt=>kt.id===ut.id),Kt=il(K,mt,ms);Me.mutate(Kt.map(kt=>kt.id))}},Ct=ne=>{const{active:pe,over:ut}=ne;if(ut&&pe.id!==ut.id){const mt=$t.findIndex(kt=>kt.id===pe.id),ms=$t.findIndex(kt=>kt.id===ut.id),Kt=il($t,mt,ms);le.mutate(Kt.map(kt=>kt.id))}},zt=()=>{P({name:"",slug:"",visibility:null}),O(!1),F([]),C(null),g(!1)},Wt=()=>{z({title:"",slug:"",description:"",status:"draft",owner:"",visibility:null,categoryId:K[0]?.id||"",contentType:"procedure"}),V(!1),Y([]),v(!1)},Le=async(ne,pe)=>{if(ne.stopPropagation(),C(pe),O(!0),P({name:pe.name,slug:pe.slug||"",visibility:pe.visibility||null}),pe.visibility==="teams")try{const ut=await fetch(`/api/categories/${pe.id}/team-access`).then(mt=>mt.json());F(ut.map(mt=>mt.teamId))}catch{F([])}else F([]);g(!0)},Nt=(ne,pe)=>{ne.stopPropagation();const ut=$.filter(mt=>mt.categoryId===pe.id);N({type:"category",id:pe.id,name:pe.name,hasContent:ut.length>0,confirmed:!1})},Xt=(ne,pe)=>{ne.stopPropagation(),N({type:"procedure",id:pe.id,name:pe.title})},qt=()=>{if(k)if(k.type==="category"){if(k.hasContent&&!k.confirmed){N({...k,confirmed:!0});return}ue.mutate(k.id)}else Re.mutate(k.id)},us=()=>{w?Te.mutate({id:w.id,data:T}):Ie.mutate({...T,knowledgeBaseId:t})},qs=()=>{$e.mutate({...M,knowledgeBaseId:t,categoryId:M.categoryId||null})},Ks="__uncategorized__",xn=ne=>$.filter(pe=>pe.categoryId===ne).length,vn=()=>$.filter(ne=>!ne.categoryId).length,Ls=ne=>ne==="published"?"default":"secondary",$t=(j===Ks?$.filter(ne=>
206!ne.categoryId):j?$.filter(ne=>ne.categoryId===j):$).sort((ne,pe)=>(ne.order||0)-(pe.order||0)),ze=j?K.find(ne=>ne.id===j):null,Xe=_||A;return e.jsxs("div",{className:"space-y-6 overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4 min-w-0",children:[e.jsxs(D,{variant:"ghost",size:"sm",onClick:s,"data-testid":"button-back-to-kbs",children:[e.jsx(kn,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden",children:[e.jsx("h2",{className:"font-medium text-lg truncate",children:L?.name}),L?.description&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:L.description})]}),we&&e.jsx("a",{href:we,target:"_blank",rel:"noopener noreferrer",children:e.jsxs(D,{variant:"outline",size:"sm","data-testid":"button-view-kb",children:[e.jsx(Sn,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"View Knowledge Base"}),e.jsx("span",{className:"sm:hidden",children:"View"})]})})]}),Xe?e.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(ee,{className:"border-border/50",children:[e.jsxs(qe,{className:"flex flex-row flex-wrap items-center justify-between gap-2 pb-4",children:[e.jsxs("div",{children:[e.jsx(tt,{className:"text-base",children:"Categories"}),e.jsx(Tt,{children:"Organize your procedures"})]}),e.jsxs(St,{open:f,onOpenChange:g,children:[u&&e.jsx(bs,{asChild:!0,children:e.jsxs(D,{size:"sm",variant:"outline",onClick:()=>{zt(),g(!0)},"data-testid":"button-add-category",children:[e.jsx(ds,{className:"w-4 h-4 mr-1"}),"Add"]})}),e.jsxs(jt,{children:[e.jsx(wt,{children:e.jsx(bt,{children:w?"Edit Category":"New Category"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Name"}),e.jsx(fe,{value:T.name,onChange:ne=>{const pe=ne.target.value;P({...T,name:pe,slug:!w&&!I?pe.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""):T.slug})},"data-testid":"input-category-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"URL Slug"}),e.jsx(fe,{value:T.slug,onChange:ne=>{O(!0),P({...T,slug:ne.target.value.toLowerCase().replace(/[^a-z0-9-]+/g,"")})},placeholder:"e.g., employee-onboarding","data-testid":"input-category-slug"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used in shareable URLs. Must be unique for your company."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Visibility (Optional)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty to inherit from knowledge base"}),e.jsxs(lt,{value:T.visibility||"inherit",onValueChange:ne=>P({...T,visibility:ne==="inherit"?null:ne}),children:[e.jsx(it,{"data-testid":"select-category-visibility",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"inherit",children:"Inherit from KB"}),ck.map(ne=>e.jsx(me,{value:ne,children:pg[ne].label},ne))]})]}),T.visibility==="teams"&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(Z,{className:"text-sm",children:"Select Teams"}),Q.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No teams available"}):e.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:Q.map(ne=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md hover-elevate cursor-pointer",onClick:()=>{R.includes(ne.id)?F(R.filter(pe=>pe!==ne.id)):F([...R,ne.id])},children:[e.jsx("input",{type:"checkbox",checked:R.includes(ne.id),onChange:()=>{},className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:ne.name})]},ne.id))})]})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(D,{onClick:us,disabled:T.visibility==="teams"&&R.length===0,"data-testid":"button-save-category",children:w?"Update":"Create"}),e.jsx(D,{variant:"outline",onClick:zt,children:"Cancel"})]})]})]})]})]}),e.jsx(te,{className:"space-y-2",children:K.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No categories yet"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors ${j===null?"border-primary bg-primary/5":"border-border/50 hover-elevate"}`,onClick:()=>b(null),"data-testid":"button-category-all",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cc,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"All Content"})]}),e.jsx(Ce,{variant:"secondary",className:"text-xs",children:$.length})]}),vn()>0&&e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors ${j===Ks?"border-primary bg-primary/5":"border-border/50 hover-elevate"}`,onClick:()=>b(Ks),"data-testid":"button-category-uncategorized",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pt,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Uncategorized"})]}),e.jsx(Ce,{variant:"secondary",className:"text-xs",children:vn()})]}),u?e.jsx(om,{sensors:He,collisionDetection:am,onDragEnd:ft,children:e.jsx(cm,{items:K.map(ne=>ne.id),strategy:lm,children:e.jsx("div",{className:"space-y-2",children:K.map(ne=>e.jsx(Rz,{category:ne,isSelected:j===ne.id,onSelect:()=>b(ne.id),onEdit:Le,onDelete:Nt,procedureCount:xn(ne.id),showFreshnessBadge:a,categoryThreshold:l,userCanEdit:u},ne.id))})})}):K.map(ne=>{const pe=io(ne.updatedAt||ne.createdAt,l);return e.jsxs("div",{className:`flex items-center justify-between gap-2 p-3 rounded-lg border cursor-pointer transition-colors ${j===ne.id?"border-primary bg-primary/5":"border-border/50 hover-elevate"}`,onClick:()=>b(ne.id),"data-testid":`button-category-${ne.id}`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(Cc,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium truncate",children:ne.name})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[a&&e.jsx(Ni,{status:pe.status,daysSinceUpdate:pe.daysSinceUpdate,showDays:!0,testId:`badge-freshness-category-${ne.id}`,thresholdDays:l}),ne.visibility&&e.jsx(Ce,{variant:ne.visibility==="public"?"default":"secondary",className:"text-xs",children:ne.visibility==="public"?e.jsx($n,{className:"h-3 w-3"}):ne.visibility==="teams"?e.jsx(Hi,{className:"h-3 w-3"}):e.jsx(Qn,{className:"h-3 w-3"})}),e.jsx(Ce,{variant:"secondary",className:"text-xs",children:xn(ne.id)})]})]},ne.id)})]})})]}),e.jsxs(ee,{className:"border-border/50",children:[e.jsxs(qe,{className:"flex flex-row flex-wrap items-center justify-between gap-2 pb-4",children:[e.jsxs("div",{children:[e.jsx(tt,{className:"text-base",children:ze?`${ze.name} Content`:"Content"}),e.jsx(Tt,{children:ze?`Showing ${$t.length} item${$t.length!==1?"s":""} in this category`:`${$t.length} item${$t.length!==1?"s":""} total`})]}),e.jsxs(St,{open:x,onOpenChange:v,children:[u&&e.jsx(bs,{asChild:!0,children:e.jsxs(D,{size:"sm",variant:"outline",onClick:()=>{const ne=j===Ks||!j?"":j;z(pe=>({...pe,categoryId:ne})),v(!0)},"data-testid":"button-add-procedure",children:[e.jsx(ds,{className:"w-4 h-4 mr-1"}),"Add"]})}),e.jsxs(jt,{children:[e.jsx(wt,{children:e.jsxs(bt,{children:["New ",M.contentType==="overview"?"Overview":"Procedure"]})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Content Type"}),e.jsxs(lt,{value:M.contentType,onValueChange:ne=>z({...M,contentType:ne}),children:[e.jsx(it,{"data-testid":"select-content-type",children:e.jsx(ct,{placeholder:"Select type"})}),e.jsxs(ot,{children:[e.jsx(me,{value:"procedure",children:"Procedure (Step-by-step instructions)"}),e.jsx(me,{value:"overview",children:"Overview (Key points for training)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Title"}),e.jsx(fe,{value:M.title,onChange:ne=>{const pe=ne.target.value;z({...M,title:pe,slug:!H?pe.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""):M.slug})},"data-testid":"input-procedure-title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"URL Slug"}),e.jsx(fe,{value:M.slug,onChange:ne=>{V(!0),z({...M,slug:ne.target.value.toLowerCase().replace(/[^a-z0-9-]+/g,"")})},placeholder:"e.g., new-employee-setup","data-testid":"input-procedure-slug"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used in shareable URLs. Must be unique for your company."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Description"}),e.jsx(ss,{value:M.description,onChange:ne=>z({...M,description:ne.target.value}),"data-testid":"input-procedure-description"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Category (Optional)"}),e.jsxs(lt,{value:M.categoryId||"none",onValueChange:ne=>z({...M,categoryId:ne==="none"?"":ne}),children:[e.jsx(it,{"data-testid":"select-procedure-category",children:e.jsx(ct,{placeholder:"Select category"})}),e.jsxs(ot,{children:[e.jsx(me,{value:"none",children:"No Category (Uncategorized)"}),K.map(ne=>e.jsx(me,{value:ne.id,children:ne.name},ne.id))]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(D,{onClick:qs,"data-testid":"button-create-procedure",children:"Create"}),e.jsx(D,{variant:"outline",onClick:Wt,children:"Cancel"})]})]})]})]})]}),e.jsx(te,{className:"space-y-2",children:$t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:j===Ks?"No uncategorized content":ze?"No content in this category":"No content yet. Click Add to create your first item."}):j?e.jsx(om,{sensors:He,collisionDetection:am,onDragEnd:Ct,children:e.jsx(cm,{items:$t.map(ne=>ne.id),strategy:lm,children:e.jsx("div",{className:"space-y-2",children:$t.map(ne=>e.jsx(_z,{procedure:ne,onSelect:n,onDelete:Xt,getStatusColor:Ls,showFreshnessBadge:o,contentThreshold:d,userCanEdit:u,clientSlug:U?.slug||void 0,kbSlug:L?.slug||void 0,categorySlug:ne.categoryId?_e[ne.categoryId]:void 0},ne.id))})})}):e.jsx("div",{className:"space-y-2",children:$t.map(ne=>e.jsx(Az,{procedure:ne,onSelect:n,onDelete:Xt,getStatusColor:Ls,showFreshnessBadge:o,contentThreshold:d,userCanEdit:u,clientSlug:U?.slug||void 0,kbSlug:L?.slug||void 0,categorySlug:ne.categoryId?_e[ne.categoryId]:void 0},ne.id))})})]})]}),e.jsx(St,{open:!!k,onOpenChange:()=>N(null),children:e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsxs(bt,{className:"flex items-center gap-2",children:[e.jsx(pl,{className:"h-5 w-5 text-destructive"}),k?.hasContent&&!k?.confirmed?"Category Contains Procedures":"Move to Archive?"]}),e.jsx(Gt,{children:k?.hasContent&&!k?.confirmed?e.jsxs(e.Fragment,{children:['The category "',k?.name,'" contains ',$.filter(ne=>ne.categoryId===k?.id).length,' procedure(s). Deleting this category will also archive all procedures in it. Click "Continue" to confirm.']}):k?.type==="category"?e.jsxs(e.Fragment,{children:['Are you sure you want to archive "',k?.name,'"? It will be kept for 30 days before permanent deleti
206on. You can restore it from the Archive section.']}):e.jsxs(e.Fragment,{children:['Are you sure you want to archive "',k?.name,'"? It will be kept for 30 days before permanent deletion. You can restore it from the Archive section.']})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsxs(D,{variant:"destructive",onClick:qt,disabled:ue.isPending||Re.isPending,"data-testid":"button-confirm-delete",children:[(ue.isPending||Re.isPending)&&e.jsx(Ve,{className:"h-4 w-4 animate-spin mr-2"}),k?.hasContent&&!k?.confirmed?"Continue":"Archive"]}),e.jsx(D,{variant:"outline",onClick:()=>N(null),children:"Cancel"})]})]})})]})}function Jx({procedureId:t,onBack:s,clientId:n}){const{toast:a}=dt(),{user:o}=Oa(),{user:l}=kl(),d=mh(l?.role||"viewer"),{data:u,isLoading:h,dataUpdatedAt:f}=je({queryKey:["/api/procedures",t],enabled:!!t}),{data:g,isLoading:x}=je({queryKey:["/api/subscription/status",n],queryFn:async()=>{const J=await fetch(`/api/subscription/status?clientId=${n}`);if(!J.ok)throw new Error("Failed to check subscription");return J.json()},enabled:!!n}),v=(()=>{if(x)return!0;if(!g?.subscription)return!1;const J=g.subscription.plan;return Dn[J]?.aiEnabled??!1})(),[w,C]=m.useState(""),[j,b]=m.useState(""),[k,N]=m.useState(""),[T,P]=m.useState("draft"),[I,O]=m.useState(!0),[R,F]=m.useState(null),[M,z]=m.useState(null),[H,V]=m.useState(null),[B,Y]=m.useState("procedure"),[L,K]=m.useState([]),[_,$]=m.useState([]),[A,W]=m.useState(""),[U,Q]=m.useState(!0),[we,_e]=m.useState(0),[Ie,Te]=m.useState(!1),[ue,Re]=m.useState(!1),$e=m.useRef(!1),le=m.useRef(0);m.useRef(!1);const Me=m.useRef(null),He=m.useRef(null);m.useEffect(()=>{Q(!0),_e(0),$e.current=!1},[t]);const{data:ft=[]}=je({queryKey:[`/api/clients/${n}/knowledge-bases`],enabled:!!n}),{data:Ct}=je({queryKey:["/api/clients",n],enabled:!!n}),{data:zt=[]}=je({queryKey:[`/api/knowledge-bases/${M}/categories`],enabled:!!M}),Wt=ft.find(J=>J.id===M),Le=zt.find(J=>J.id===H),[Nt,Xt]=m.useState(null),[qt,us]=m.useState(null),[qs,Ks]=m.useState(!1),[xn,vn]=m.useState(!1),[Ls,$t]=m.useState(!1);m.useEffect(()=>{(async()=>{if(H&&Le&&(!Le.slug||Le.slug.trim()==="")){Ks(!0);try{const Qe=await(await ce("POST",`/api/categories/${H}/ensure-slug`)).json();Qe.slug&&(Xt(Qe.slug),de.invalidateQueries({queryKey:[`/api/knowledge-bases/${M}/categories`]}))}catch(he){console.error("Failed to ensure category slug:",he)}finally{Ks(!1)}}})()},[H,Le,M]),m.useEffect(()=>{(async()=>{if(t&&u&&(!u.slug||u.slug.trim()==="")){vn(!0);try{const Qe=await(await ce("POST",`/api/procedures/${t}/ensure-slug`)).json();Qe.slug&&(us(Qe.slug),de.invalidateQueries({queryKey:["/api/procedures",t]}))}catch(he){console.error("Failed to ensure procedure slug:",he)}finally{vn(!1)}}})()},[t,u]);const ze=Nt||Le?.slug,Xe=qt||j||u?.slug,ne=qs||xn,pe=Ct?.slug&&Wt?.slug&&ze&&Xe?`/${Ct.slug}/${Wt.slug}/${ze}/${Xe}`:null;m.useEffect(()=>{M&&zt.length>0&&H&&(zt.some(he=>he.id===H)||V(null))},[M,zt,H]);const{data:ut}=je({queryKey:[`/api/categories/${H}`],enabled:!!H&&!M});m.useEffect(()=>{ut&&!M&&H&&z(ut.knowledgeBaseId)},[ut,M,H]);const mt=m.useRef({title:w,slug:j,description:k,status:T,isPublic:I,videoUrl:R,knowledgeBaseId:M,categoryId:H,contentType:B,steps:L,deletedStepIds:_});mt.current={title:w,slug:j,description:k,status:T,isPublic:I,videoUrl:R,knowledgeBaseId:M,categoryId:H,contentType:B,steps:L,deletedStepIds:_};const ms=m.useRef("");m.useEffect(()=>{if(u&&U&&f>we){C(u.title),b(u.slug||""),N(u.description||""),P(u.status),O(u.isPublic??!0),F(u.videoUrl||null),z(u.knowledgeBaseId||null),V(u.categoryId||null),Y(u.contentType||"procedure"),K(u.steps||[]),$([]),_e(f),Q(!1);const J=JSON.stringify({title:u.title,slug:u.slug||"",description:u.description||"",status:u.status,isPublic:u.isPublic??!0,knowledgeBaseId:u.knowledgeBaseId||null,categoryId:u.categoryId||null,contentType:u.contentType||"procedure",steps:u.steps||[]});Me.current=J,ms.current=J,setTimeout(()=>{$e.current=!0},100)}},[u,U,f,we]),m.useCallback(()=>{const{title:J,slug:he,description:Qe,status:_t,isPublic:Ge,videoUrl:es,knowledgeBaseId:Yr,categoryId:mn,steps:Si,deletedStepIds:Fa}=mt.current;return JSON.stringify({title:J,slug:he,description:Qe,status:_t,isPublic:Ge,videoUrl:es,knowledgeBaseId:Yr,categoryId:mn,steps:Si.map(Zr=>({id:Zr.id,title:Zr.title,content:Zr.content,order:Zr.order,type:Zr.type,imageUrl:Zr.imageUrl,videoUrl:Zr.videoUrl,videoType:Zr.videoType})),deletedStepIds:Fa})},[]),m.useEffect(()=>{if(!$e.current||!t||Date.now()<le.current)return;const J=JSON.stringify({title:w,slug:j,description:k,status:T,isPublic:I,knowledgeBaseId:M,categoryId:H,contentType:B,steps:L});if(Me.current===null){Me.current=J;return}Re(J!==Me.current)},[w,j,k,T,I,M,H,B,L,t]),m.useEffect(()=>{$e.current=!1,Re(!1),Me.current=null},[t]);const Kt=ye({mutationFn:async()=>
206{const J=JSON.parse(JSON.stringify(mt.current)),he=mt.current;await ce("PATCH",`/api/procedures/${t}`,{title:he.title,slug:he.slug,description:he.description,status:he.status,isPublic:he.isPublic,videoUrl:he.videoUrl,knowledgeBaseId:he.knowledgeBaseId,categoryId:he.categoryId,contentType:he.contentType});for(const _t of he.deletedStepIds)try{await ce("DELETE",`/api/steps/${_t}`)}catch(Ge){if(!Ge.message?.includes("404"))throw Ge}const Qe=[];for(let _t=0;_t<he.steps.length;_t++){const Ge=he.steps[_t];if(Ge.id)try{await ce("PATCH",`/api/steps/${Ge.id}`,{title:Ge.title,content:Ge.content,order:Ge.order,type:Ge.type,imageUrl:Ge.imageUrl||null,videoUrl:Ge.videoUrl||null,videoType:Ge.videoType||null})}catch(es){if(es.message?.includes("404")){const mn=await(await ce("POST","/api/steps",{procedureId:t,title:Ge.title,content:Ge.content,order:Ge.order,type:Ge.type||"action",imageUrl:Ge.imageUrl||null,videoUrl:Ge.videoUrl||null,videoType:Ge.videoType||null})).json();mn?.id&&Ge.tempId&&Qe.push({tempId:Ge.tempId,id:mn.id})}else throw es}else{const Yr=await(await ce("POST","/api/steps",{procedureId:t,title:Ge.title,content:Ge.content,order:Ge.order,type:Ge.type||"action",imageUrl:Ge.imageUrl||null,videoUrl:Ge.videoUrl||null,videoType:Ge.videoType||null})).json();Yr?.id&&Ge.tempId&&Qe.push({tempId:Ge.tempId,id:Yr.id})}}return{snapshot:J,newStepIds:Qe}},onSuccess:async({snapshot:J,newStepIds:he})=>{if(he.length>0){const es=new Map(he.map(({tempId:mn,id:Si})=>[mn,Si])),Yr=mt.current.steps.map(mn=>{if(!mn.id&&mn.tempId&&es.has(mn.tempId)){const{tempId:Si,...Fa}=mn;return{...Fa,id:es.get(mn.tempId)}}return mn});K(Yr),mt.current.steps=Yr}mt.current.deletedStepIds=[],$([]),Me.current=JSON.stringify({title:J.title,slug:J.slug,description:J.description,status:J.status,isPublic:J.isPublic,knowledgeBaseId:J.knowledgeBaseId,categoryId:J.categoryId,contentType:J.contentType,steps:J.steps});const Qe=JSON.stringify({title:mt.current.title,slug:mt.current.slug,description:mt.current.description,status:mt.current.status,isPublic:mt.current.isPublic,knowledgeBaseId:mt.current.knowledgeBaseId,categoryId:mt.current.categoryId,contentType:mt.current.contentType,steps:mt.current.steps});Re(Qe!==Me.current),await de.invalidateQueries({queryKey:["/api/procedures"]}),await de.invalidateQueries({queryKey:["/api/procedures",t]}),n&&await de.invalidateQueries({queryKey:[`/api/clients/${n}/procedures`]});const _t=mt.current.knowledgeBaseId;_t&&await de.invalidateQueries({queryKey:[`/api/knowledge-bases/${_t}/procedures`]}),_e(Date.now());const Ge=mt.current.contentType;a({title:Ge==="overview"?"Overview saved":"Procedure saved"})},onError:J=>{a({title:"Failed to save",description:J.message,variant:"destructive"})}}),kt=m.useCallback(()=>{He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{$e.current&&!Kt.isPending&&d&&Kt.mutate()},2e3)},[Kt,d]),xs=()=>{K([...L,{order:L.length+1,title:"",content:"",type:"action",tempId:`temp-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}]),kt()},hs=(J,he,Qe)=>{const _t=[...L];_t[J]={..._t[J],[he]:Qe},K(_t),kt()},Jn=J=>{const he=L[J];he?.id&&$(Qe=>[...Qe,he.id]),K(L.filter((Qe,_t)=>_t!==J)),kt()},_n=J=>{J!==0&&(K(he=>{const Qe=[...he];return[Qe[J-1],Qe[J]]=[Qe[J],Qe[J-1]],Qe.map((_t,Ge)=>({..._t,order:Ge+1}))}),kt())},en=J=>{J>=L.length-1||(K(he=>{const Qe=[...he];return[Qe[J],Qe[J+1]]=[Qe[J+1],Qe[J]],Qe.map((_t,Ge)=>({..._t,order:Ge+1}))}),kt())},[Ft,Jt]=m.useState(!1),[vs,Fs]=m.useState("image"),[Cs,Hs]=m.useState(null),[Is,Rn]=m.useState(!1),[as,tn]=m.useState(null),[$s,un]=m.useState(!1),yn=(J,he)=>{Fs(J),Hs(he),Jt(!0)},zn=(J,he)=>{if(Cs!==null){const Qe=he==="image";K(_t=>{const Ge=[..._t];return Qe?Ge[Cs]={...Ge[Cs],imageUrl:J}:Ge[Cs]={...Ge[Cs],videoUrl:J,videoType:he},Ge})}Jt(!1)},Gs=(J,he)=>{F(J),Rn(!1)},er=J=>{K(he=>{const Qe=[...he];return Qe[J]={...Qe[J],imageUrl:null},Qe})},se=J=>{K(he=>{const Qe=[...he];return Qe[J]={...Qe[J],videoUrl:null,videoType:null},Qe})},Ue=ye({mutationFn:async({index:J,title:he,content:Qe,mode:_t})=>{const Ge=await ce("POST","/api/ai/improve-step",{title:he,content:Qe,mode:_t,clientId:u?.clientId});return{index:J,mode:_t,result:await Ge.json()}},onSuccess:({index:J,mode:he,result:Qe})=>{hs(J,"title",Qe.title),hs(J,"content",Qe.content),a({title:`Step ${{polish:"Polished",simplify:"Simplified",expand:"Expanded"}[he]||"improved"}`}),tn(null)},onError:J=>{J.message.includes("ai_upgrade_required")?a({title:"Upgrade Required",description:"AI features require the Creator plan. Upgrade from the Billing page to unlock AI tools.",variant:"destructive"}):a({title:"Failed to improve step",description:J.message,variant:"destructive"}),tn(null)}}),Be=ye({mutationFn:async({mode:J})=>{const he=await ce("POST","/api/ai/improve-description",{title:w||u?.title||"",description:k||u?.description||"",mode:J,clientId:u?.clientId});return{mode:J,result:await he.json()}},onSuccess:({mode:J,result:he})=>{N(he.description),a({title:`Description ${{polish:"Polished",simplify:"Simplified",expand:"Expanded"}[J]||"improved"}`}),un(!1)},onError:J=>{J.message.includes("ai_upgrade_required")?a({title:"Upgrade Required",description:"AI features require the Creator plan. Upgrade from the Billing page to unlock AI tools.",variant:"destructive"}):a({title:"Failed to improve description",description:J.message,variant:"destructive"}),un(!1)}}),De=J=>{const he=k||u?.description||"",Qe=w||u?.title||"";if(!he){a({title:"Please enter a description first",variant:"destructive"});return}if(!Qe){a({title:"Please enter a title first",variant:"destructive"});return}un(!0),Be.mutate({mode:J})},{data:st=[]}=je({queryKey:["/api/portal/procedures",t,"notes"],queryFn:async()=>{const J=await fetch(`/api/portal/procedures/${t}/notes`);if(!J.ok)throw new Error("Failed to fetch notes");
206return J.json()},enabled:!!t}),ks=ye({mutationFn:async J=>ce("POST",`/api/portal/procedures/${t}/notes`,J),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/portal/procedures",t,"notes"]}),a({title:"Note added"}),W("")},onError:J=>{a({title:"Failed to add note",description:J.message,variant:"destructive"})}}),Gr=ye({mutationFn:async J=>ce("DELETE",`/api/procedure-notes/${J}`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/portal/procedures",t,"notes"]}),a({title:"Note deleted"})},onError:J=>{a({title:"Failed to delete note",description:J.message,variant:"destructive"})}}),fa=(J,he)=>{const Qe=L[J];if(!Qe?.title||!Qe?.content){a({title:"Please enter step title and content first",variant:"destructive"});return}tn(J),Ue.mutate({index:J,title:Qe.title,content:Qe.content,mode:he})};return h?e.jsxs("div",{className:"space-y-6 max-w-3xl",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx(be,{className:"h-10 w-full"}),e.jsx(be,{className:"h-20 w-full"}),e.jsx("div",{className:"space-y-4",children:[1,2,3].map(J=>e.jsx(be,{className:"h-24 w-full"},J))})]}):e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:items-start",children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-6 lg:max-w-3xl",children:[e.jsx(fg,{open:Ft,onOpenChange:Jt,type:vs,onMediaSelected:zn}),e.jsx(fg,{open:Is,onOpenChange:Rn,type:"video",onMediaSelected:Gs}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs(D,{variant:"ghost",size:"sm",onClick:s,"data-testid":"button-editor-back",children:[e.jsx(kn,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>$t(!0),"data-testid":"button-preview-procedure",children:[e.jsx(Sn,{className:"h-4 w-4 mr-1"}),"Preview"]}),ne?e.jsxs(D,{variant:"outline",size:"sm",disabled:!0,"data-testid":"button-view-procedure-public-loading",children:[e.jsx(Ve,{className:"h-4 w-4 mr-1 animate-spin"}),"Preparing..."]}):pe?e.jsx("a",{href:pe,target:"_blank",rel:"noopener noreferrer",children:e.jsxs(D,{variant:"outline",size:"sm","data-testid":"button-view-procedure-public",children:[e.jsx(Yn,{className:"h-4 w-4 mr-1"}),"View Public"]})}):null]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"title",children:"Title"}),e.jsx(fe,{id:"title",value:w,onChange:J=>C(J.target.value),placeholder:"Procedure title",className:"text-lg font-medium","data-testid":"input-procedure-title",disabled:!d})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"slug",children:"URL Slug"}),e.jsx(fe,{id:"slug",value:j,onChange:J=>b(J.target.value),placeholder:"e.g., new-employee-setup","data-testid":"input-procedure-slug",disabled:!d}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used in shareable URLs. Must be unique for your company."})]}),e.jsxs("div",{className:"space-y-2","data-testid":"section-description",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Z,{htmlFor:"description",children:"Description"}),e.jsx("div",{className:"flex items-center gap-1",children:v&&e.jsxs(Gi,{children:[e.jsx(Yi,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",disabled:$s||!d,"data-testid":"button-description-improve",children:$s?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-1 animate-spin"}),"Improving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"h-4 w-4 mr-1"}),"Improve",e.jsx(On,{className:"h-3 w-3 ml-1"})]})})}),e.jsxs(pi,{align:"end",children:[e.jsxs(on,{onClick:()=>De("polish"),children:[e.jsx(gs,{className:"h-4 w-4 mr-2"}),"Polish - Fix grammar and clarity"]}),e.jsxs(on,{onClick:()=>De("simplify"),children:[e.jsx(kc,{className:"h-4 w-4 mr-2"}),"Simplify - Make it easier to read"]}),e.jsxs(on,{onClick:()=>De("expand"),children:[e.jsx(Jo,{className:"h-4 w-4 mr-2"}),"Expand - Add more detail"]})]})]})})]}),e.jsx(ss,{id:"description",value:k,onChange:J=>N(J.target.value),placeholder:"Brief description of this procedure",rows:3,"data-testid":"input-procedure-description",disabled:!d})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h3",{className:"font-medium flex items-center gap-2",children:[e.jsx(Pa,{className:"h-4 w-4 text-primary"}),B==="overview"?"Key Points":"Steps"]})}),e.jsxs("div",{className:"space-y-4",children:[L.map((J,he)=>e.jsx(ee,{className:"border-border/50",children:e.jsx(te,{className:"p-4 space-y-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 flex-shrink-0 pt-1",children:[e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>_n(he),disabled:he===0,"data-testid":`button-move-up-${he}`,children:e.jsx(Im,{className:"h-4 w-4"})}),B==="overview"?e.jsx("div",{className:"w-2 h-2 rounded-full bg-primary shrink-0"}):e.jsx(Ce,{variant:"secondary",className:"text-xs",children:he+1}),e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>en(he),disabled:he===L.length-1,"data-testid":`button-move-down-${he}`,children:e.jsx(On,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(fe,{value:J.title||"",onChange:Qe=>hs(he,"title",Qe.target.value),placeholder:B==="overview"?"Key point title":"Step title",className:"font-medium","data-testid":`input-step-title-${he}`}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ss,{value:J.content||"",onChange:Qe=>hs(he,"content",Qe.target.value),placeholder:B==="overview"?"Key point content":"Step content",rows:3,className:"flex-1","data-testid":`input-step-content-${he}`}),v&&e.jsx(Vk,{onTranscription:Qe=>hs(he,"content",(J.content||"")+(J.content?" ":"")+Qe),context:"step instructions in a procedure",className:"mt-1","data-testid":`button-voice-content-${he}`})]}),J.imageUrl&&e.jsx(wm,{mediaUrl:J.imageUrl,mediaType:"image",onRemove:()=>er(he)}),J.videoUrl&&e.jsx(wm,{mediaUrl:J.videoUrl,mediaType:J.videoType||"video",onRemove:()=>se(he)}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>yn("image",he),"data-testid":`button-add-image-${he}`,children:[e.jsx(qi,{className:"h-4 w-4 mr-1"}),"Image"]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>yn("video",he),"data-testid":`button-add-video-${he}`,children:[e.jsx(lr,{className:"h-4 w-4 mr-1"}),"Video"]}),v&&e.jsxs(Gi,{children:[e.jsx(Yi,{asChild:!0,children:e.jsx(D,{variant:"outline",size:"sm",disabled:as===
206he,"data-testid":`button-improve-step-${he}`,children:as===he?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-1 animate-spin"}),"Improving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"h-4 w-4 mr-1"}),"Improve",e.jsx(On,{className:"h-3 w-3 ml-1"})]})})}),e.jsxs(pi,{align:"start",children:[e.jsxs(on,{onClick:()=>fa(he,"polish"),children:[e.jsx(gs,{className:"h-4 w-4 mr-2"}),"Polish"]}),e.jsxs(on,{onClick:()=>fa(he,"simplify"),children:[e.jsx(kc,{className:"h-4 w-4 mr-2"}),"Simplify"]}),e.jsxs(on,{onClick:()=>fa(he,"expand"),children:[e.jsx(Jo,{className:"h-4 w-4 mr-2"}),"Expand"]})]})]}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>Jn(he),className:"ml-auto","data-testid":`button-delete-step-${he}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]})]})})},J.id||`new-${he}`)),L.length===0&&e.jsx(ee,{className:"border-border/50 border-dashed","data-testid":"section-steps-empty",children:e.jsxs(te,{className:"p-8 text-center space-y-4",children:[e.jsx(Pa,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:B==="overview"?v?"No key points yet. Use AI to generate key points or add them manually.":"No key points yet. Add them manually below.":v?"No steps yet. Use AI to generate steps or add them manually.":"No steps yet. Add them manually below."}),v?e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[e.jsx(qk,{onProcedureGenerated:J=>{if(J.title&&!w&&C(J.title),J.description&&!k&&N(J.description),J.steps&&J.steps.length>0){const he=new Set,Qe=J.steps.filter(_t=>{const Ge=`${_t.title?.toLowerCase()}|${_t.content?.toLowerCase()}`;return he.has(Ge)?!1:(he.add(Ge),!0)});K(Qe.map((_t,Ge)=>({..._t,order:Ge+1,tempId:`temp-${Date.now()}-${Math.random().toString(36).substr(2,9)}-${Ge}`}))),kt()}}}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"or"}),e.jsx(Nm,{existingProcedureId:t,existingTitle:w,purpose:"steps",onProcedureGenerated:J=>{if(J.title&&!w&&C(J.title),J.description&&!k&&N(J.description),J.videoUrl&&F(J.videoUrl),J.steps&&J.steps.length>0){const he=new Set,Qe=J.steps.filter(_t=>{const Ge=`${_t.title?.toLowerCase()}|${_t.content?.toLowerCase()}`;return he.has(Ge)?!1:(he.add(Ge),!0)});K(Qe.map((_t,Ge)=>({..._t,order:Ge+1,tempId:`temp-${Date.now()}-${Math.random().toString(36).substr(2,9)}-${Ge}`}))),kt()}}})]}):e.jsx("div",{className:"text-center",children:e.jsxs("p",{className:"text-xs text-muted-foreground",children:["AI features require the Creator plan. ",e.jsx("a",{href:"/portal/billing",className:"text-primary underline","data-testid":"link-upgrade-ai",children:"Upgrade to unlock AI tools"}),"."]})})]})}),d&&e.jsxs(D,{variant:"outline",className:"w-full border-dashed",onClick:xs,"data-testid":"button-add-step",children:[e.jsx(ds,{className:"h-4 w-4 mr-2"}),"Add ",B==="overview"?"Key Point":"Step"]}),v&&e.jsx(Dz,{title:w,description:k,clientId:n,onGenerateSteps:J=>{if(J&&J.length>0){const he=new Set,Qe=J.filter(_t=>{const Ge=`${_t.title?.toLowerCase()}|${_t.content?.toLowerCase()}`;return he.has(Ge)?!1:(he.add(Ge),!0)});K(Qe.map((_t,Ge)=>({..._t,order:Ge+1,tempId:`temp-${Date.now()}-${Math.random().toString(36).substr(2,9)}-${Ge}`}))),kt()}}})]})]})]}),e.jsx("div",{className:"w-full lg:w-80 lg:flex-shrink-0 order-first lg:order-last",children:e.jsxs("div",{className:"lg:sticky lg:top-4 space-y-4",children:[e.jsx(Cn,{defaultOpen:!0,children:e.jsxs(ee,{className:"border-border/50","data-testid":"section-content-management",children:[e.jsx(Mn,{asChild:!0,children:e.jsx(qe,{className:"p-4 pb-2 cursor-pointer hover-elevate rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jc,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"font-medium text-sm",children:"Content Management"})]}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 [[data-state=open]>&]:rotate-90"})]})})}),e.jsx(Ln,{children:e.jsxs(te,{className:"p-4 pt-2 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-5 text-xs text-muted-foreground","data-testid":"save-status",children:ue?e.jsx("span",{className:"text-amber-600 dar
206k:text-amber-400",children:"Unsaved changes"}):e.jsx("span",{children:"All changes saved"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(lt,{value:T,onValueChange:P,disabled:!d,children:[e.jsx(it,{className:"w-28","data-testid":"select-procedure-status",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"draft",children:"Draft"}),e.jsx(me,{value:"published",children:"Published"})]})]}),d&&e.jsxs(D,{variant:ue?"default":"outline",size:"sm",onClick:()=>Kt.mutate(),disabled:Kt.isPending,"data-testid":"button-save-procedure",children:[Kt.isPending?e.jsx(Ve,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Ki,{className:"h-4 w-4 mr-1"}),"Save"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{className:"text-xs text-muted-foreground",children:"Content Type"}),e.jsxs(lt,{value:B,onValueChange:J=>Y(J),children:[e.jsx(it,{"data-testid":"select-content-type",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"procedure",children:"Procedure"}),e.jsx(me,{value:"overview",children:"Overview"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[I?e.jsx($n,{className:"h-4 w-4 text-primary"}):e.jsx(Pn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Access"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I?"Visible to everyone":"Restricted access"})]})]}),e.jsx(As,{checked:I,onCheckedChange:O,"data-testid":"switch-procedure-public"})]})]})})]})}),e.jsx(Cn,{defaultOpen:!0,children:e.jsxs(ee,{className:"border-border/50","data-testid":"section-walkthrough-video",children:[e.jsx(Mn,{asChild:!0,children:e.jsx(qe,{className:"p-4 pb-2 cursor-pointer hover-elevate rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"font-medium text-sm",children:"Walkthrough Video"})]}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 [[data-state=open]>&]:rotate-90"})]})})}),e.jsx(Ln,{children:e.jsx(te,{className:"p-4 pt-2 space-y-3",children:R?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"rounded-lg border border-border overflow-hidden bg-muted",children:R.includes("youtube.com/embed/")||R.includes("loom.com/embed/")||R.includes("player.vimeo.com/")?e.jsx("iframe",{src:R,className:"w-full aspect-video",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Walkthrough Video","data-testid":"iframe-procedure-editor"}):e.jsx(rl,{src:R,className:"w-full aspect-video","data-testid":"video-procedure-editor"})}),e.jsxs(D,{variant:"ghost",size:"sm",onClick:()=>F(null),className:"w-full","data-testid":"button-remove-video",children:[e.jsx(ts,{className:"h-4 w-4 mr-1"}),"Remove Video"]})]}):e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"This video will appear at the top of your procedure as an introduction or overview."}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>Rn(!0),className:"w-full","data-testid":"button-add-walkthrough-video",children:[e.jsx(Ou,{className:"h-4 w-4 mr-1"}),"Upload or Embed Video"]}),v&&e.jsx(Nm,{existingProcedureId:t,existingTitle:w,purpose:"intro",onProcedureGenerated:J=>{J.videoUrl&&F(J.videoUrl)}})]})})})]})}),e.jsx(Cn,{defaultOpen:!1,children:e.jsxs(ee,{className:"border-border/50","data-testid":"section-organization",children:[e.jsx(Mn,{asChild:!0,children:e.jsxs(qe,{className:"p-4 pb-2 cursor-pointer hover-elevate rounded-t-lg",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fr,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"font-medium text-sm",children:"Organization"})]}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 [[data-state=open]>&]:rotate-90"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Assign to a Knowledge Base and Category"})]})}),e.jsx(Ln,{children:e.jsxs(te,{className:"p-4 pt-2 space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"knowledgeBase",className:"text-xs",children:"Knowledge Base"}),e.jsxs(lt,{value:M||"none",onValueChange:J=>{const he=J==="none"?null:J;z(he),he!==M&&V(null)},children:[e.jsx(it,{"data-testid":"select-procedure-kb",children:e.jsx(ct,{placeholder:"Select knowledge base"})}),e.jsxs(ot,{children:[e.jsx(me,{value:"none",children:"None (Standalone)"}),ft.map(J=>e.jsx(me,{value:J.id,children:J.name},J.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"category",className:"text-xs",children:"Category"}),e.jsxs(lt,{value:H||"none",onValueChange:J=>V(J==="none"?null:J),disabled:!M,children:[e.jsx(it,{"data-testid":"select-procedure-category",children:e.jsx(ct,{placeholder:M?"Select category":"Select a KB first"})}),e.jsxs(ot,{children:[e.jsx(me,{value:"none",children:"None (Uncategorized)"}),zt.map(J=>e.jsx(me,{value:J.id,children:J.name},J.id))]})]})]})]})})]})}),e.jsx(Zk,{procedureId:t,onVersionRestored:()=>{Q(!0),de.invalidateQueries({queryKey:["/api/procedures",t]})}}),e.jsx(Cn,{defaultOpen:!1,children:e.jsxs(ee,{className:"border-border/50","data-testid":"section-internal-notes",children:[e.jsx(Mn,{asChild:!0,children:e.jsx(qe,{className:"p-4 cursor-pointer hover-elevate rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(no,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"font-medium text-sm",children:"Internal Notes"}),e.jsx(Ce,{variant:"secondary",className:"text-xs",children:"Team Only"})]}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 [[data-state=open]>&]:rotate-90"})]})})}),e.jsx(Ln,{children:e.jsxs(te,{className:"p-4 pt-0 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ss,{value:A,onChange:J=>W(J.target.value),placeholder:"Add a note for the team...",rows:2,className:"flex-1","data-testid":"input-new-note"}),e.jsx(D,{onClick:()=>ks.mutate({author:o?.firstName?`${o.firstName} ${o.lastName||""}`.trim():o?.email||"Team Member",content:A}),disabled:!A.trim()||ks.isPending,size:"sm","data-testid":"button-add-note",children:e.jsx(el,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:st&&st.length>0?st.map(J=>e.jsxs("div",{className:"p-3 rounded-lg border border-border/50 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-medium",children:J.author}),e.jsx("span",{className:"text-muted-foreground",children:J.createdAt&&Nr(new Date(J.createdAt),"MMM d, h:mm a")})]}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>Gr.mutate(J.id),className:"h-6 w-6 text-muted-foreground","data-testid":`button-delete-note-${J.id}`,children:e.jsx(ts,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-sm text-foreground",children:J.content})]},J.id)):e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"No notes yet"})})]})})]})})]})}),e.jsx(St,{open:Ls,onOpenChange:$t,children:e.jsxs(jt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto","data-testid":"dialog-preview-content",children:[e.jsxs(wt,{children:[e.jsxs(bt,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5"}),"Content Preview"]}),e.jsx(Gt,{children:"This is how your content will appear to viewers"})]}),e.jsxs("div",{className:"space-y-6 py-4","data-testid":"preview-content-body",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h1",{className:"text-2xl font-bold","data-testid":"text-preview-title",children:w||u?.title||"Untitled Procedure"}),(k||u?.description)&&e.jsx("p",{className:"text-muted-foreground","data-testid":"text-preview-description",children:k||u?.description})]}),(L.length>0||u?.steps&&u.steps.length>0)&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold border-b pb-2",children:"Steps"}),e.jsx("div",{className:"space-y-6",children:(L.length>0?L:u?.steps||[]).map((J,he)=>e.jsxs("div",{className:"flex gap-4","data-testid":`preview-step-${he}`,children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary text-primary-foreground flex items-center justify-center text-sm font-medium",children:he+1}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("h3",{className:"font-medium","data-testid":`text-preview-step-title-${he}`,children:J.title||`Step ${he+1}`}),J.content&&e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap","data-testid":`text-preview-step-content-${he}`,children:J.content}),J.imageUrl&&e.jsx("img",{src:J.imageUrl,alt:J.title||`Step ${he+1}`,className:"rounded-lg max-w-full h-auto max-h-64 object-contain border","data-testid":`img-preview-step-${he}`}),J.videoUrl&&e.jsx(rl,{src:J.videoUrl,className:"rounded-lg max-w-full max-h-64","data-testid":`video-preview-step-${he}`})]})]},J.id||he))})]})]}),e.jsx(Vs,{children:e.jsx(D,{variant:"outline",onClick:()=>$t(!1),"data-testid":"button-close-preview",children:"Close"})})]})}),ue&&d&&e.jsx("div",{className:"fixed bottom-6 right-6 z-50",children:e.jsxs(D,{size:"lg",onClick:()=>Kt.mutate(),disabled:Kt.isPending,className:"shadow-lg","data-testid":"button-floating-save",children:[Kt.isPending?e.jsx(Ve,{className:"h-5 w-5 mr-2 animate-spin"}):e.jsx(Ki,{className:"h-5 w-5 mr-2"}),"Save Changes"]})})]})}function Dz({title:t,description:s,onGenerateSteps:n,clientId:a}){const{toast:o}=dt(),[l,d]=m.useState(!1),[u,h]=m.useState(""),[f,g]=m.useState("generate-steps"),x=ye({mutationFn:async()=>(await ce("POST","/api/ai/generate-steps",{title:t,description:s,clientId:a})).json(),onSuccess:b=>{n(b.steps),o({title:"Steps generated successfully"}),d(!1)},onError:b=>{b.message.includes("ai_upgrade_required")?o({title:"Upgrade Required",description:"AI features require the Creator plan. Upgrade from the Billing page to unlock AI tools.",variant:"destructive"}):o({title:"Failed to generate steps",description:b.message,variant:"destructive"})}}),v=ye({mutationFn:async()=>(await ce("POST","/api/ai/generate-procedure",{topic:u,clientId:a})).json(),onSuccess:b=>{n(b.steps),o({title:"Procedure generated successfully",description:`Generated "${b.title}" with ${b.steps.length} steps`}),d(!1),h("")},onError:b=>{b.message.includes("ai_upgrade_required")?o({title:"Upgrade Required",description:"AI features require the Creator plan. Upgrade from the Billing page to unlock AI tools.",variant:"destructive"}):o({title:"Failed to generate procedure",description:b.message,variant:"destructive"})}}),w=x.isPending||v.isPending,C=v.isPending?"generate-procedure":"generate-steps",j=Cl(w,C);return e.jsxs(St,{open:l,onOpenChange:d,children:[e.jsx(ee,{className:"border-border/50 bg-primary/5","data-testid":"section-ai-assistant",children:e.jsxs(te,{className:"p-4 flex items-center gap-3",children:[e.jsx(gs,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"AI Assistant"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Let AI help you write and improve this procedure"})]}),e.jsx(bs,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm","data-testid":"button-ai-assist",children:[e.jsx(Ig,{className:"h-4 w-4 mr-1"}),"Generate with AI"]})})]})}),e.jsxs(jt,{className:"sm:max-w-md",children:[e.jsxs(wt,{children:[e.jsxs(bt,{className:"flex items-center gap-2",children:[e.jsx(gs,{className:"h-5 w-5 text-primary"}),"AI Assistant"]}),e.jsx(Gt,{children:"Use AI to generate steps or a complete procedure"})]}),e.jsxs(Ma,{value:f,onValueChange:b=>g(b),className:"w-full",children:[e.jsxs(ha,{className:"grid w-full grid-cols-2",children:[e.jsxs(ls,{value:"generate-steps","data-testid":"tab-ai-generate-steps",children:[e.jsx(jN,{className:"h-4 w-4 mr-1"}),"Generate Steps"]}),e.jsxs(ls,{value:"generate-procedure","data-testid":"tab-ai-generate-procedure",children:[e.jsx(Pt,{className:"h-4 w-4 mr-1"}),"From Topic"]})]}),e.jsxs(Ss,{value:"generate-steps",className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate steps based on the current procedure title and description."}),t?e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50",children:[e.jsx("p",{className:"text-sm font-medium",children:t}),s&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s})]}):e.jsx("p",{className:"text-sm text-destructive",children:"Please enter a procedure title first."})]}),e.jsx(D,{onClick:()=>x.mutate(),disabled:!t||w,className:"w-full","data-testid":"button-ai-generate-steps",children:x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),e.jsx("span",{className:"animate-pulse",children:j})]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"h-4 w-4 mr-2"}),"Generate Steps"]})})]}),e.jsxs(Ss,{value:"generate-procedure",className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"ai-topic",children:"What procedure do you want to create?"}),e.jsx(ss,{id:"ai-topic",value:u,onChange:b=>h(b.target.value),placeholder:"e.g., How to onboard a new customer, Processing refunds, Setting up a new employee...",rows:3,"data-testid":"input-ai-topic"})]}),e.jsx(D,{onClick:()=>v.mutate(),disabled:!u||w,className:"w-full","data-testid":"button-ai-generate-procedure",children:v.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),e.jsx("span",{className:"animate-pulse",children:j})]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"h-4 w-4 mr-2"}),"Generate Procedure"]})})]})]})]})]})}const fb=[{name:"Playfair Display",category:"serif"},{name:"Merriweather",category:"serif"},{name:"Lora",category:"serif"},{name:"Crimson Text",category:"serif"},{name:"Libre Baskerville",category:"serif"},{name:"Cormorant Garamond",category:"serif"},{name:"EB Garamond",category:"serif"},{name:"Source Serif Pro",category:"serif"},{name:"Poppins",category:"sans-serif"},{name:"Montserrat",category:"sans-serif"},{name:"Raleway",category:"sans-serif"},{name:"Oswald",category:"sans-serif"}],pb=[{name:"Inter",category:"sans-serif"},{name:"Open Sans",category:"sans-serif"},{name:"Roboto",category:"sans-serif"},{name:"Lato",category:"sans-serif"},{name:"Source Sans Pro",category:"sans-serif"},{name:"Nunito",category:"sans-serif"},{name:"Work Sans",category:"sans-serif"},{name:"PT Sans",category:"sans-serif"},{name:"Merriweather",category:"serif"},{name:"Lora",category:"serif"},{name:"Crimson Text",category:"serif"},{name:"Source Serif Pro",category:"serif"}];function Oz({clientId:t}){const{toast:s}=dt(),[n,a]=m.useState(!1),[o,l]=m.useState({}),[d,u]=m.useState(!1),h=m.useRef(null),{data:f,isLoading:g}=je({queryKey:[`/api/clients/${t}`]}),x=ye({mutationFn:j=>ce("PATCH",`/api/clients/${t}`,j),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/clients/${t}`]}),f?.slug&&de.invalidateQueries({queryKey:["/api/knowledge-bases/by-slug",f.slug]}),s({title:"Company info updated successfully"}),a(!1)},onError:()=>{s({title:"Failed to update company info",variant:"destructive"})}});if(g)return e.jsx("div",{className:"text-muted-foreground",children:"Loading..."});if(!f)return e.jsx("div",{className:"text-muted-foreground",children:"Client not found"});const v=()=>{l(f),a(!0)},w=()=>{x.mutate(o)},C=async j=>{const b=j.target.files?.[0];if(b){if(!b.type.startsWith("image/")){s({title:"Please select an image file",variant:"destructive"});return}if(b.size>2*1024*1024){s({title:"Logo must be under 2MB",variant:"destructive"});return}u(!0);try{const k=await fetch("/api/uploads/request-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name,size:b.size,contentType:b.type,mediaType:"logo"})});if(!k.ok)throw new Error("Failed to get upload URL");const{uploadURL:N,ob
206jectPath:T}=await k.json();if(!(await fetch(N,{method:"PUT",body:b,headers:{"Content-Type":b.type}})).ok)throw new Error("Failed to upload logo");l({...o,logo:T}),s({title:"Logo uploaded successfully"})}catch{s({title:"Failed to upload logo",variant:"destructive"})}finally{u(!1)}}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h1",{className:"text-2xl font-semibold","data-testid":"text-company-title",children:"Company Information"}),e.jsxs(ee,{className:"max-w-2xl",children:[e.jsxs(qe,{className:"flex flex-row items-center justify-between gap-4",children:[e.jsx(tt,{children:"Details"}),!n&&e.jsxs(D,{variant:"outline",onClick:v,"data-testid":"button-edit-company",children:[e.jsx(fl,{className:"w-4 h-4 mr-2"}),"Edit"]})]}),e.jsx(te,{className:"space-y-4",children:n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Company Name"}),e.jsx(fe,{value:o.name||"",onChange:j=>l({...o,name:j.target.value}),"data-testid":"input-company-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Slug (URL identifier)"}),e.jsx(fe,{value:o.slug||"",onChange:j=>l({...o,slug:j.target.value}),"data-testid":"input-company-slug"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Logo"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Supported formats: PNG, JPG, SVG. Recommended size: 160 x 50 pixels. Max file size: 2MB"}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[o.logo?e.jsx("div",{className:"border rounded-md p-2 bg-muted/30",children:e.jsx("img",{src:o.logo,alt:"Company logo",className:"max-h-[50px] max-w-[160px] object-contain","data-testid":"img-company-logo-preview"})}):e.jsx("div",{className:"border rounded-md p-4 bg-muted/30 text-muted-foreground text-sm flex items-center justify-center w-[160px] h-[50px]",children:"No logo"}),e.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:C,className:"hidden","data-testid":"input-company-logo-file"}),e.jsxs(D,{type:"button",variant:"outline",size:"sm",onClick:()=>h.current?.click(),disabled:d,"data-testid":"button-upload-company-logo",children:[d?e.jsx(Ve,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(qi,{className:"h-4 w-4 mr-1"}),o.logo?"Change Logo":"Upload Logo"]}),o.logo&&e.jsxs(D,{type:"button",variant:"ghost",size:"sm",onClick:()=>l({...o,logo:""}),"data-testid":"button-remove-company-logo",children:[e.jsx(ts,{className:"h-4 w-4 mr-1"}),"Remove"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{type:"color",value:o.primaryColor||"#B24884",onChange:j=>l({...o,primaryColor:j.target.value}),className:"w-16 h-10","data-testid":"input-company-color"}),e.jsx(fe,{value:o.primaryColor||"#B24884",onChange:j=>l({...o,primaryColor:j.target.value}),className:"flex-1"})]})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Heading Font"}),e.jsxs(lt,{value:o.headingFont||"Playfair Display",onValueChange:j=>l({...o,headingFont:j}),children:[e.jsx(it,{"data-testid":"select-company-heading-font",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Serif"}),fb.filter(j=>j.category==="serif").map(j=>e.jsx(me,{value:j.name,children:e.jsx("span",{style:{fontFamily:`"${j.name}", serif`},children:j.name})},j.name)),e.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground mt-1",children:"Sans-Serif"}),fb.filter(j=>j.category==="sans-serif").map(j=>e.jsx(me,{value:j.name,children:e.jsx("span",{style:{fontFamily:`"${j.name}", sans-serif`},children:j.name})},j.name))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for titles and headings on your KB portal"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Body Font"}),e.jsxs(lt,{value:o.bodyFont||"Inter",onValueChange:j=>l({...o,bodyFont:j}),children:[e.jsx(it,{"data-testid":"select-company-body-font",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Sans-Serif"}),pb.filter(j=>j.category==="sans-serif").map(j=>e.jsx(me,{value:j.name,children:e.jsx("span",{style:{fontFamily:`"${j.name}", sans-serif`},children:j.name})},j.name)),e.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground mt-1",children:"Serif"}),pb.filter(j=>j.category==="serif").map(j=>e.jsx(me,{value:j.name,children:e.jsx("span",{style:{fontFamily:`"${j.name}", serif`},children:j.name})},j.name))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for body text and paragraphs on your KB portal"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Knowledge Center Theme"}),e.jsxs(lt,{value:o.preferredTheme||"system",onValueChange:j=>l({...o,preferredTheme:j}),children:[e.jsx(it,{"data-testid":"select-company-theme",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"system",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rg,{className:"h-4 w-4"}),e.jsx("span",{children:"System Default"})]})}),e.jsx(me,{value:"light",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(SN,{className:"h-4 w-4"}),e.jsx("span",{children:"Light Mode"})]})}),e.jsx(me,{value:"dark",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(NN,{className:"h-4 w-4"}),e.jsx("span",{children:"Dark Mode"})]})})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Set the default theme for visitors viewing your knowledge center (visitors can still toggle)"})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(D,{onClick:w,disabled:x.isPending,"data-testid":"button-save-company",children:x.isPending?"Saving...":"Save Changes"}),e.jsx(D,{variant:"outline",onClick:()=>a(!1),"data-testid":"button-cancel-company",children:"Cancel"})]})]}):e.jsxs("div",{className:"grid gap-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[f.logo?e.jsx("div",{className:"border rounded-md p-2 bg-muted/30",children:e.jsx("img",{src:f.logo,alt:f.name,className:"max-h-[50px] max-w-[160px] object-contain","data-testid":"img-company-logo-display"})}):e.jsx("div",{className:"w-12 h-12 rounded-md flex items-center justify-center text-white font-bold",style:{backgroundColor:f.primaryColor||"#B24884"},children:f.name.charAt(0)}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-lg","data-testid":"text-company-name",children:f.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["/",f.slug]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded border",style:{backgroundColor:f.primaryColor||"#B24884"}}),e.jsx("span",{className:"text-sm font-mono",children:f.primaryColor})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Heading Font"}),e.jsx("p",{className:"text-sm",style:{fontFamily:`"${f.headingFont||"Playfair Display"}", serif`},"data-testid":"text-company-heading-font",children:f.headingFont||"Playfair Display"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Body Font"}),e.jsx("p",{className:"text-sm",style:{fontFamily:`"${f.bodyFont||"Inter"}", sans-serif`},"data-testid":"text-company-body-font",children:f.bodyFont||"Inter"})]})]})]})})]})]})}function Mz({clientId:t}){const{toast:s}=dt(),[n,a]=m.useState(!1),[o,l]=m.useState(null),[d,u]=m.useState({firstName:"",lastName:"",email:"",role:"viewer",status:"active"}),h=N=>`${N.firstName||""} ${N.lastName||""}`.trim()||N.email,{data:f=[],isLoading:g}=je({queryKey:[`/api/clients/${t}/users`]}),x=ye({mutationFn:N=>ce("POST","/api/client-users",N),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/clients/${t}/users`]}),s({title:"User created"}),C()}}),v=ye({mutationFn:({id:N,data:T})=>ce("PATCH",`/api/client-users/${N}`,T),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/clients/${t}/users`]}),s({title:"User updated"}),C()}}),w=ye({mutationFn:N=>ce("DELETE",`/api/client-users/${N}`),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/clients/${t}/users`]}),s({title:"User deleted"})}}),C=()=>{u({firstName:"",lastName:"",email:"",role:"viewer",status:"active"}),l(null),a(!1)},j=N=>{l(N),u({firstName:N.firstName||"",lastName:N.lastName||"",email:N.email,role:N.role,status:N.status}),a(!0)},b=()=>{o?v.mutate({id:o.id,data:d}):x.mutate({...d,clientId:t})},k=N=>{switch(N){case"admin":return"default";case"manager":return"secondary";case"editor":return"outline";case"viewer":return"secondary";default:return"secondary"}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold","data-testid":"text-users-title",children:"Users"}),e.jsxs(St,{open:n,onOpenChange:a,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{onClick:()=>{C(),a(!0)},"data-testid":"button-add-user",children:[e.jsx(ds,{className:"w-4 h-4 mr-2"}),"Add User"]})}),e.jsxs(jt,{children:[e.jsx(wt,{children:e.jsx(bt,{children:o?"Edit User":"New User"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"First Name"}),e.jsx(fe,{value:d.firstName,onChange:N=>u({...d,firstName:N.target.value}),"data-testid":"input-user-firstName"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Last Name"}),e.jsx(fe,{value:d.lastName,onChange:N=>u({...d,lastName:N.target.value}),"data-testid":"input-user-lastName"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Email"}),e.jsx(fe,{type:"email",value:d.email,onChange:N=>u({...d,email:N.target.value}),"data-testid":"input-user-email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Role"}),e.jsxs(lt,{value:d.role,onValueChange:N=>u({...d,role:N}),children:[e.jsx(it,{"data-testid":"select-user-role",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"admin",children:"Admin"}),e.jsx(me,{value:"manager",children:"Manager"}),e.jsx(me,{value:"editor",children:"Editor"}),e.jsx(me,{value:"viewer",children:"Viewer"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Status"}),e.jsxs(lt,{value:d.status,onValueChange:N=>u({...d,status:N}),children:[e.jsx(it,{"data-testid":"select-user-status",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"active",children:"Active"}),e.jsx(me,{value:"inactive",children:"Inactive"}),e.jsx(me,{value:"pending",children:"Pending"})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(D,{onClick:b,"data-testid":"button-save-user",children:o?"Update":"Create"}),e.jsx(D,{variant:"outline",onClick:C,children:"Cancel"})]})]})]})]})]}),g?e.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):f.length===0?e.jsx(ee,{children:e.jsxs(te,{className:"py-12 text-center",children:[e.jsx(Bs,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"No users yet. Add your first team member."})]})}):e.jsx("div",{className:"space-y-3",children:f.map(N=>e.jsx(ee,{"data-testid":`card-user-${N.id}`,children:e.jsxs(te,{className:"py-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center font-semibold",children:h(N).charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:h(N)}),e.jsx("p",{className:"text-sm text-muted-foreground",children:N.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:k(N.role),className:"capitalize",children:N.role}),e.jsx(Ce,{variant:N.status==="active"?"default":"secondary",children:N.status}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>j(N),"data-testid":`button-edit-user-${N.id}`,children:e.jsx(fl,{className:"w-4 h-4"})}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>w.mutate(N.id),"data-testid":`button-delete-user-${N.id}`,children:e.jsx(ts,{className:"w-4 h-4"})})]})]})},N.id))})]})}
206function Lz({team:t,clientId:s,open:n,onOpenChange:a}){const{toast:o}=dt(),[l,d]=m.useState(""),[u,h]=m.useState("member"),{data:f=[],isLoading:g}=je({queryKey:["/api/teams",t.id,"members"],queryFn:()=>fetch(`/api/teams/${t.id}/members`,{credentials:"include",headers:Gn()?{Authorization:`Bearer ${Gn()}`}:{}}).then(N=>N.json()),enabled:n}),{data:x=[]}=je({queryKey:[`/api/clients/${s}/users`],enabled:n}),v=ye({mutationFn:N=>ce("POST",`/api/teams/${t.id}/members`,N),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/teams",t.id,"members"]}),de.invalidateQueries({queryKey:[`/api/clients/${s}/teams`]}),o({title:"Member added to team"}),d(""),h("member")},onError:N=>{o({title:N.message||"Failed to add member",variant:"destructive"})}}),w=ye({mutationFn:N=>ce("DELETE",`/api/team-members/${N}`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/teams",t.id,"members"]}),de.invalidateQueries({queryKey:[`/api/clients/${s}/teams`]}),o({title:"Member removed from team"})}}),C=new Set(f.map(N=>N.clientUserId)),j=x.filter(N=>!C.has(N.id)),b=N=>{const T=x.find(I=>I.id===N);return T?`${T.firstName||""} ${T.lastName||""}`.trim()||T.email:"Unknown User"},k=N=>x.find(P=>P.id===N)?.email||"";return e.jsx(St,{open:n,onOpenChange:a,children:e.jsxs(jt,{className:"max-w-md",children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Manage Team Members"}),e.jsx(Gt,{children:t.name})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Add Member"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(lt,{value:l,onValueChange:d,children:[e.jsx(it,{className:"flex-1","data-testid":"select-add-member",children:e.jsx(ct,{placeholder:"Select user..."})}),e.jsx(ot,{children:j.length===0?e.jsx("div",{className:"p-2 text-sm text-muted-foreground",children:"No available users"}):j.map(N=>e.jsxs(me,{value:N.id,children:[b(N.id)," (",N.email,")"]},N.id))})]}),e.jsxs(lt,{value:u,onValueChange:h,children:[e.jsx(it,{className:"w-28","data-testid":"select-member-role",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"member",children:"Member"}),e.jsx(me,{value:"lead",children:"Lead"})]})]}),e.jsx(D,{onClick:()=>v.mutate({clientUserId:l,role:u}),disabled:!l||v.isPending,"data-testid":"button-add-member",children:e.jsx(ds,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Z,{children:["Current Members (",f.length,")"]}),g?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."}):f.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center",children:"No members in this team yet"}):e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:f.map(N=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50","data-testid":`member-${N.id}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hr,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:b(N.clientUserId)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:k(N.clientUserId)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:"secondary",className:"capitalize",children:N.role}),e.jsx(D,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>w.mutate(N.id),disabled:w.isPending,"data-testid":`button-remove-member-${N.id}`,children:e.jsx(Zn,{className:"w-3 h-3"})})]})]},N.id))})]})]})]})})}function Fz({clientId:t}){const{toast:s}=dt(),[n,a]=m.useState(!1),[o,l]=m.useState(null),[d,u]=m.useState({name:"",description:""}),[h,f]=m.useState(null),{data:g=[],isLoading:x}=je({queryKey:[`/api/clients/${t}/teams`]}),v=ye({mutationFn:N=>ce("POST","/api/teams",N),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/clients/${t}/teams`]}),s({title:"Team created"}),j()}}),w=ye({mutationFn:({id:N,data:T})=>ce("PATCH",`/api/teams/${N}`,T),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/clients/${t}/teams`]}),s({title:"Team updated"}),j()}}),C=ye({mutationFn:N=>ce("DELETE",`/api/teams/${N}`),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/clients/${t}/teams`]}),s({title:"Team deleted"})}}),j=()=>{u({name:"",description:""}),l(null),a(!1)},b=N=>{l(N),u({name:N.name,description:N.description||""}),a(!0)},k=()=>{o?w.mutate({id:o.id,data:d}):v.mutate({...d,clientId:t})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold","data-testid":"text-teams-title",children:"Teams"}),e.jsxs(St,{open:n,onOpenChange:a,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{onClick:()=>{j(),a(!0)},"data-testid":"button-add-team",children:[e.jsx(ds,{className:"w-4 h-4 mr-2"}),"Add Team"]})}),e.jsxs(jt,{children:[e.jsx(wt,{children:e.jsx(bt,{children:o?"Edit Team":"New Team"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Team Name"}),e.jsx(fe,{value:d.name,onChange:N=>u({...d,name:N.target.value}),"data-testid":"input-team-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Description"}),e.jsx(ss,{value:d.description,onChange:N=>u({...d,description:N.target.value}),"data-testid":"input-team-description"})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(D,{onClick:k,"data-testid":"button-save-team",children:o?"Update":"Create"}),e.jsx(D,{variant:"outline",onClick:j,children:"Cancel"})]})]})]})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Organize users into teams to control access to specific knowledge bases, categories, and procedures. Users can belong to multiple teams."}),x?e.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):g.length===0?e.jsx(ee,{children:e.jsxs(te,{className:"py-12 text-center",children:[e.jsx(Hi,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"No teams yet. Create your first team."})]})}):e.jsx("div",{className:"space-y-3",children:g.map(N=>e.jsx(ee,{"data-testid":`card-team-${N.id}`,children:e.jsxs(te,{className:"py-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 cursor-pointer hover-elevate rounded-md p-2 -m-2",onClick:()=>f(N),"data-testid":`button-manage-team-${N.id}`,children:[e.jsx(Hi,{className:"w-5 h-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:N.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>f(N),"data-testid":`button-members-team-${N.id}`,children:[e.jsx(Bs,{className:"w-4 h-4 mr-1"}),"Members"]}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>b(N),"data-testid":`button-edit-team-${N.id}`,children:e.jsx(fl,{className:"w-4 h-4"})}),e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>C.mutate(N.id),"data-testid":`button-delete-team-${N.id}`,children:e.jsx(ts,{className:"w-4 h-4"})})]})]})},N.id))}),h&&e.jsx(Lz,{team:h,clientId:t,open:!!h,onOpenChange:N=>!N&&f(null)})]})}function $z(){const{toast:t}=dt(),{user:s,isLoading:n}=kl(),{setUser:a}=Oa(),[o,l]=m.useState(!1),[d,u]=m.useState({firstName:"",lastName:"",email:""});m.useEffect(()=>{s&&u({firstName:s.firstName||"",lastName:s.lastName||"",email:s.email})},[s]);const h=ye({mutationFn:async w=>(await ce("PATCH",`/api/client-users/${s?.id}`,w)).json(),onSuccess:w=>{a(w),de.invalidateQueries({queryKey:[`/api/clients/${s?.clientId}/users`]}),t({title:"Profile updated successfully"}),l(!1)},onError:()=>{t({title:"Failed to update profile",variant:"destructive"})}});if(n)return e.jsxs("div",{className:"space-y-6",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx(ee,{className:"max-w-2xl",children:e.jsxs(te,{className:"p-6 space-y-4",children:[e.jsx(be,{className:"h-4 w-24"}),e.jsx(be,{className:"h-10 w-full"}),e.jsx(be,{className:"h-4 w-24"}),e.jsx(be,{className:"h-10 w-full"})]})})]});if(!s)return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"My Profile"}),e.jsx(ee,{className:"max-w-2xl",children:e.jsxs(te,{className:"py-12 text-center",children:[e.jsx(Hr,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"No user profile found"})]})})]});const f=()=>{u({firstName:s.firstName||"",lastName:s.lastName||"",email:s.email}),l(!0)},g=()=>{h.mutate(d)},x=()=>{u({firstName:s.firstName||"",lastName:s.lastName||"",email:s.email}),l(!1)},v=`${s.firstName||""} ${s.lastName||""}`.trim()||s.email;return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h1",{className:"text-2xl font-semibold","data-testid":"text-profile-title",children:"My Profile"}),e.jsxs(ee,{className:"max-w-2xl",children:[e.jsxs(qe,{className:"flex flex-row items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(tt,{children:"Personal Information"}),e.jsx(Tt,{children:"Update your profile details"})]}),!o&&e.jsxs(D,{variant:"outline",onClick:f,"data-testid":"button-edit-profile",children:[e.jsx(fl,{className:"w-4 h-4 mr-2"}),"Edit"]})]}),e.jsx(te,{className:"space-y-4",children:o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"profile-firstName",children:"First Name"}),e.jsx(fe,{id:"profile-firstName",value:d.firstName,onChange:w=>u({...d,firstName:w.target.value}),placeholder:"Enter your first name","data-testid":"input-profile-firstName"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"profile-lastName",children:"Last Name"}),e.jsx(fe,{id:"profile-lastName",value:d.lastName,onChange:w=>u({...d,lastName:w.target.value}),placeholder:"Enter your last name","data-testid":"input-profile-lastName"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"profile-email",children:"Email Address"}),e.jsx(fe,{id:"profile-email",type:"email",value:d.email,onChange:w=>u({...d,email:w.target.value}),placeholder:"Enter your email","data-testid":"input-profile-email"})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(D,{onClick:g,disabled:h.isPending,"data-testid":"button-save-profile",children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ki,{className:"w-4 h-4 mr-2"}),"Save Changes"]})}),e.jsx(D,{variant:"outline",onClick:x,"data-testid":"button-cancel-profile",children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center text-xl font-semibold",children:v.charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-lg","data-testid":"text-profile-name",children:v}),e.jsx("p",{className:"text-muted-foreground","data-testid":"text-profile-email",children:s.email})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-4 border-t",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Role"}),e.jsx(Ce,{className:"capitalize mt-1","data-testid":"badge-profile-role",children:Xk[s.role]||s.role})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Status"}),e.jsx(Ce,{variant:s.status==="active"?"default":"secondary",className:"mt-1","data-testid":"badge-profile-status",children:s.status})]})]})]})})]}),e.jsxs(ee,{className:"max-w-2xl",children:[e.jsxs(qe,{children:[e.jsx(tt,{children:"Account Information"}),e.jsx(Tt,{children:"Your account settings and role information"})]}),e.jsx(te,{children:e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"flex items-center justify-between py-2",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Role Permissions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.role==="admin"&&"Full access to all features including company settings and user management",s.role==="manager"&&"Can manage teams, users, and content",s.role==="editor"&&"Can create and edit knowledge base content",s.role==="viewer"&&"Can view knowledge bases and procedures"]})]})})})})]})]})}function Uz(){const{toast:t}=dt(),[s,n]=m.useState(null),{data:a=[],isLoading:o}=je({queryKey:["/api/archive/knowledge-bases"]}),{data:l=[],isLoading:d}=je({queryKey:["/api/archive/categories"]}),{data:u=[],isLoading:h}=je({queryKey:["/api/archive/procedures"]}),f=ye({mutationFn:N=>ce("POST",`/api/archive/knowledge-bases/${N}/restore`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/archive/knowledge-bases"]}),de.invalidateQueries({queryKey:["/api/archive/categories"]}),de.invalidateQueries({queryKey:["/api/archive/procedures"]}),t({title:"Knowledge base restored"})}}),g=ye({mutationFn:N=>ce("POST",`/api/archive/categories/${N}/restore`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/archive/categories"]}),de.invalidateQueries({queryKey:["/api/knowledge-bases"]}),t({title:"Category restored"})}}),x=ye({mutationFn:N=>ce("POST",`/api/archive/procedures/${N}/restore`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/archive/procedures"]}),de.invalidateQueries({queryKey:["/api/knowledge-bases"]}),t({title:"Procedure restored"})}}),v=ye({mutationFn:N=>ce("DELETE",`/api/archive/knowledge-bases/${N}/permanent`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/archive/knowledge-bases"]}),de.invalidateQueries({queryKey:["/api/archive/categories"]}),de.invalidateQueries({queryKey:["/api/archive/procedures"]}),t({title:"Knowledge base permanently deleted"}),n(null)}}),w=ye({mutationFn:N=>ce("DELETE",`/api/archive/categories/${N}/permanent`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/archive/categories"]}),t({title:"Category permanently deleted"}),n(null)}}),C=ye({mutationFn:N=>ce("DELETE",`/api/archive/procedures/${N}/permanent`),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/archive/procedures"]}),t({title:"Procedure permanently deleted"}),n(null)}}),j=N=>{if(!N)return 30;const T=new Date(N),P=new Date(T.getTime()+720*60*60*1e3),I=new Date,O=Math.ceil((P.getTime()-I.getTime())/(1440*60*1e3));return Math.max(0,O)},b=o||d||h,k=a.length>0||l.length>0||u.length>0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Archive"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Deleted items are kept for 30 days before permanent deleti
206on. You can restore them or delete them permanently."})]}),b?e.jsxs("div",{className:"space-y-4",children:[e.jsx(be,{className:"h-20 w-full"}),e.jsx(be,{className:"h-20 w-full"})]}):k?e.jsxs("div",{className:"space-y-6",children:[a.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-medium text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx(cs,{className:"h-4 w-4"}),"Archived Knowledge Bases (",a.length,")"]}),e.jsx("div",{className:"space-y-2",children:a.map(N=>e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(cs,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j(N.archivedAt)," days until permanent deletion"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>f.mutate(N.id),disabled:f.isPending,"data-testid":`button-restore-kb-${N.id}`,children:[e.jsx(jc,{className:"h-4 w-4 mr-1"}),"Restore"]}),e.jsx(D,{variant:"destructive",size:"sm",onClick:()=>n({type:"kb",id:N.id,name:N.name}),"data-testid":`button-delete-kb-${N.id}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]})},N.id))})]}),l.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-medium text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx(Cc,{className:"h-4 w-4"}),"Archived Categories (",l.length,")"]}),e.jsx("div",{className:"space-y-2",children:l.map(N=>e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Cc,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j(N.archivedAt)," days until permanent deletion"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>g.mutate(N.id),disabled:g.isPending,"data-testid":`button-restore-category-${N.id}`,children:[e.jsx(jc,{className:"h-4 w-4 mr-1"}),"Restore"]}),e.jsx(D,{variant:"destructive",size:"sm",onClick:()=>n({type:"category",id:N.id,name:N.name}),"data-testid":`button-delete-category-${N.id}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]})},N.id))})]}),u.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-medium text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx(Pt,{className:"h-4 w-4"}),"Archived Procedures (",u.length,")"]}),e.jsx("div",{className:"space-y-2",children:u.map(N=>e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pt,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N.title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j(N.archivedAt)," days until permanent deletion"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>x.mutate(N.id),disabled:x.isPending,"data-testid":`button-restore-procedure-${N.id}`,children:[e.jsx(jc,{className:"h-4 w-4 mr-1"}),"Restore"]}),e.jsx(D,{variant:"destructive",size:"sm",onClick:()=>n({type:"procedure",id:N.id,name:N.title}),"data-testid":`button-delete-procedure-${N.id}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]})},N.id))})]})]}):e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Rm,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"font-medium text-lg mb-2",children:"Archive is empty"}),e.jsx("p",{className:"text-muted-foreground text-sm text-center max-w-md",children:"When you delete knowledge bases, categories, or procedures, they will appear here for 30 days before being permanently removed."})]})}),e.jsx(St,{open:!!s,onOpenChange:()=>n(null),children:e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsxs(bt,{className:"flex items-center gap-2",children:[e.jsx(pl,{className:"h-5 w-5 text-destructive"}),"Permanently Delete?"]}),e.jsxs(Gt,{children:['Are you sure you want to permanently delete "',s?.name,'"? This action cannot be undone.']})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsxs(D,{variant:"destructive",onClick:()=>
206{s?.type==="kb"?v.mutate(s.id):s?.type==="category"?w.mutate(s.id):s?.type==="procedure"&&C.mutate(s.id)},disabled:v.isPending||w.isPending||C.isPending,"data-testid":"button-confirm-permanent-delete",children:[(v.isPending||w.isPending||C.isPending)&&e.jsx(Ve,{className:"h-4 w-4 animate-spin mr-2"}),"Delete Permanently"]}),e.jsx(D,{variant:"outline",onClick:()=>n(null),children:"Cancel"})]})]})})]})}function zz({clientId:t,selectedProcedure:s,onSelectProcedure:n,showFreshnessBadge:a=!1,contentThreshold:o=90}){const{toast:l}=dt(),{user:d}=kl(),u=mh(d?.role||"viewer"),[h,f]=m.useState(!1),[g,x]=m.useState(""),[v,w]=m.useState(""),[C,j]=m.useState(!1),{data:b}=je({queryKey:["/api/clients",t]}),{data:k=[]}=je({queryKey:[`/api/clients/${t}/knowledge-bases`]}),{data:N=[]}=je({queryKey:[`/api/clients/${t}/categories`]}),T=k.reduce((z,H)=>(z[H.id]=H.slug,z),{}),P=N.reduce((z,H)=>(H.slug&&(z[H.id]=H.slug),z),{}),I=z=>{if(!u&&b?.slug&&z.knowledgeBaseId&&z.categoryId&&z.slug){const H=T[z.knowledgeBaseId],V=P[z.categoryId];if(H&&V){window.open(`/${b.slug}/${H}/${V}/${z.slug}`,"_blank");return}}n(z.id)},{data:O=[],isLoading:R}=je({queryKey:[`/api/clients/${t}/procedures`,{contentType:"procedure"}],queryFn:async()=>{const z=await fetch(`/api/clients/${t}/procedures?contentType=procedure`,{credentials:"include",headers:Gn()?{Authorization:`Bearer ${Gn()}`}:{}});if(!z.ok)throw new Error("Failed to fetch procedures");return z.json()}}),F=ye({mutationFn:async z=>(await ce("POST","/api/procedures",z)).json(),onSuccess:z=>{de.invalidateQueries({queryKey:[`/api/clients/${t}/procedures`]}),l({title:"Procedure created"}),f(!1),x(""),w(""),j(!1),z?.id&&n(z.id)},onError:()=>{l({title:"Failed to create procedure",variant:"destructive"})}}),M=ye({mutationFn:z=>ce("DELETE",`/api/procedures/${z}`),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/clients/${t}/procedures`]}),l({title:"Procedure deleted"})}});return s?e.jsx(Jx,{procedureId:s,onBack:()=>n(null),clientId:t},s):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold","data-testid":"text-procedures-title",children:"Procedures"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Step-by-step numbered instructions for your team"})]}),u&&e.jsxs(St,{open:h,onOpenChange:f,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{"data-testid":"button-create-procedure",children:[e.jsx(ds,{className:"h-4 w-4 mr-1"}),"New Procedure"]})}),e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Create Procedure"}),e.jsx(Gt,{children:"Create a new step-by-step procedure. You can optionally assign it to a category later."})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"procedure-title",children:"Title"}),e.jsx(fe,{id:"procedure-title",value:g,onChange:z=>{const H=z.target.value;x(H),C||w(H.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"e.g., Onboarding New Employee","data-testid":"input-new-procedure-title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"procedure-slug",children:"URL Slug"}),e.jsx(fe,{id:"procedure-slug",value:v,onChange:z=>{j(!0),w(z.target.value.toLowerCase().replace(/[^a-z0-9-]+/g,""))},placeholder:"e.g., onboarding-new-employee","data-testid":"input-new-procedure-slug"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used in shareable URLs. Must be unique for your company."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(D,{onClick:()=>F.mutate({title:g,slug:v||void 0,clientId:t,contentType:"procedure"}),disabled:!g||F.isPending,"data-testid":"button-save-new-procedure",children:[F.isPending&&e.jsx(Ve,{className:"h-4 w-4 animate-spin mr-2"}),"Create"]}),e.jsx(D,{variant:"outline",onClick:()=>f(!1),children:"Cancel"})]})]})]})]})]}),R?e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"h-20 w-full"}),e.jsx(be,{className:"h-20 w-full"})]}):O.length===0?e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Pt,{className:"h-12 w-12 text-muted-foreground
206/50 mb-4"}),e.jsx("h3",{className:"font-medium text-lg mb-2",children:"No procedures yet"}),e.jsx("p",{className:"text-muted-foreground text-sm text-center max-w-md",children:"Create your first procedure to document step-by-step processes for your team."})]})}):e.jsx("div",{className:"space-y-3",children:O.map(z=>e.jsx(ee,{className:"border-border/50 cursor-pointer hover-elevate",onClick:()=>I(z),"data-testid":`card-procedure-${z.id}`,children:e.jsxs(te,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pt,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:z.title}),z.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:z.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a&&(()=>{const H=io(z.updatedAt||z.createdAt,o);return e.jsx(Ni,{status:H.status,daysSinceUpdate:H.daysSinceUpdate,showDays:!0,testId:`badge-freshness-proc-${z.id}`,thresholdDays:o})})(),e.jsx(Ce,{variant:z.status==="published"?"default":"secondary",children:z.status}),u&&e.jsx(D,{variant:"ghost",size:"icon",onClick:H=>{H.stopPropagation(),M.mutate(z.id)},"data-testid":`button-delete-procedure-${z.id}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]})},z.id))})]})}function Bz({clientId:t,selectedProcedure:s,onSelectProcedure:n,showFreshnessBadge:a=!1,contentThreshold:o=90}){const{toast:l}=dt(),{user:d}=kl(),u=mh(d?.role||"viewer"),[h,f]=m.useState(!1),[g,x]=m.useState(""),[v,w]=m.useState(""),[C,j]=m.useState(!1),{data:b}=je({queryKey:["/api/clients",t]}),{data:k=[]}=je({queryKey:[`/api/clients/${t}/knowledge-bases`]}),{data:N=[]}=je({queryKey:[`/api/clients/${t}/categories`]}),T=k.reduce((z,H)=>(z[H.id]=H.slug,z),{}),P=N.reduce((z,H)=>(H.slug&&(z[H.id]=H.slug),z),{}),I=z=>{if(!u&&b?.slug&&z.knowledgeBaseId&&z.categoryId&&z.slug){const H=T[z.knowledgeBaseId],V=P[z.categoryId];if(H&&V){window.open(`/${b.slug}/${H}/${V}/${z.slug}`,"_blank");return}}n(z.id)},{data:O=[],isLoading:R}=je({queryKey:[`/api/clients/${t}/procedures`,{contentType:"overview"}],queryFn:async()=>{const z=await fetch(`/api/clients/${t}/procedures?contentType=overview`,{credentials:"include",headers:Gn()?{Authorization:`Bearer ${Gn()}`}:{}});if(!z.ok)throw new Error("Failed to fetch overviews");return z.json()}}),F=ye({mutationFn:async z=>(await ce("POST","/api/procedures",z)).json(),onSuccess:z=>{de.invalidateQueries({queryKey:[`/api/clients/${t}/procedures`]}),l({title:"Overview created"}),f(!1),x(""),w(""),j(!1),z?.id&&n(z.id)},onError:()=>{l({title:"Failed to create overview",variant:"destructive"})}}),M=ye({mutationFn:z=>ce("DELETE",`/api/procedures/${z}`),onSuccess:()=>{de.invalidateQueries({queryKey:[`/api/clients/${t}/procedures`]}),l({title:"Overview deleted"})}});return s?e.jsx(Jx,{procedureId:s,onBack:()=>n(null),clientId:t},s):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold","data-testid":"text-overviews-title",children:"Overviews"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Training videos and context documents with bullet points"})]}),u&&e.jsxs(St,{open:h,onOpenChange:f,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{"data-testid":"button-create-overview",children:[e.jsx(ds,{className:"h-4 w-4 mr-1"}),"New Overview"]})}),e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Create Overview"}),e.jsx(Gt,{children:"Create a new overview with training content. You can optionally assign it to a category later."})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"overview-title",children:"Title"}),e.jsx(fe,{id:"overview-title",value:g,onChange:z=>{const H=z.target.value;x(H),C||w(H.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"e.g., Company Culture Training","data-testid":"input-new-overview-title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"overview-slug",children:"URL Slug"}
206),e.jsx(fe,{id:"overview-slug",value:v,onChange:z=>{j(!0),w(z.target.value.toLowerCase().replace(/[^a-z0-9-]+/g,""))},placeholder:"e.g., company-culture-training","data-testid":"input-new-overview-slug"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used in shareable URLs. Must be unique for your company."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(D,{onClick:()=>F.mutate({title:g,slug:v||void 0,clientId:t,contentType:"overview"}),disabled:!g||F.isPending,"data-testid":"button-save-new-overview",children:[F.isPending&&e.jsx(Ve,{className:"h-4 w-4 animate-spin mr-2"}),"Create"]}),e.jsx(D,{variant:"outline",onClick:()=>f(!1),children:"Cancel"})]})]})]})]})]}),R?e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"h-20 w-full"}),e.jsx(be,{className:"h-20 w-full"})]}):O.length===0?e.jsx(ee,{className:"border-border/50",children:e.jsxs(te,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(ln,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"font-medium text-lg mb-2",children:"No overviews yet"}),e.jsx("p",{className:"text-muted-foreground text-sm text-center max-w-md",children:"Create your first overview to share training videos and context documents with your team."})]})}):e.jsx("div",{className:"space-y-3",children:O.map(z=>e.jsx(ee,{className:"border-border/50 cursor-pointer hover-elevate",onClick:()=>I(z),"data-testid":`card-overview-${z.id}`,children:e.jsxs(te,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ln,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:z.title}),z.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:z.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a&&(()=>{const H=io(z.updatedAt||z.createdAt,o);return e.jsx(Ni,{status:H.status,daysSinceUpdate:H.daysSinceUpdate,showDays:!0,testId:`badge-freshness-overview-${z.id}`,thresholdDays:o})})(),e.jsx(Ce,{variant:z.status==="published"?"default":"secondary",children:z.status}),u&&e.jsx(D,{variant:"ghost",size:"icon",onClick:H=>{H.stopPropagation(),M.mutate(z.id)},"data-testid":`button-delete-overview-${z.id}`,children:e.jsx(ts,{className:"h-4 w-4"})})]})]})},z.id))})]})}function Vz({clientId:t}){const{toast:s}=dt(),[n,a]=m.useState(!1),[o,l]=m.useState(!1),[d,u]=m.useState(!1),[h,f]=m.useState(!1),[g,x]=m.useState(!1),{data:v,isLoading:w,refetch:C}=je({queryKey:["/api/subscription/status",t],queryFn:async()=>{const V=await fetch(`/api/subscription/status?clientId=${t}`,{credentials:"include",headers:Gn()?{Authorization:`Bearer ${Gn()}`}:{}});if(!V.ok)throw new Error("Failed to fetch subscription");return V.json()},enabled:!!t}),j=v?.subscription,b=async V=>{a(!0);try{const B=await fetch("/api/stripe/cancel-subscription",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t,cancelImmediately:V})}),Y=await B.json();if(!B.ok)throw new Error(Y.error||"Failed to cancel");s({title:"Subscription updated",description:Y.message}),l(!1),C()}catch(B){s({title:"Error",description:B.message,variant:"destructive"})}finally{a(!1)}},k=async()=>{try{const V=await fetch("/api/stripe/reactivate-subscription",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t})}),B=await V.json();if(!V.ok)throw new Error(B.error||"Failed to reactivate");s({title:"Subscription reactivated",description:B.message}),C()}catch(V){s({title:"Error",description:V.message,variant:"destructive"})}},N=async()=>{try{const V=await fetch("/api/stripe/create-portal-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t})}),B=await V.json();if(!V.ok)throw new Error(B.error||"Failed to open billing portal");window.open(B.url,"_blank")}catch(V){s({title:"Error",description:V.message,variant:"destructive"})}};if(w)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx(be,{className:"h-48 w-full"})]});if(!j)return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Billing"}),e.jsx(ee,{children:e.jsxs(te,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(di,{className:"h-12 w-12 text-muted-foreground
206/50 mb-4"}),e.jsx("h3",{className:"font-medium text-lg mb-2",children:"No subscription found"}),e.jsx("p",{className:"text-muted-foreground text-sm text-center",children:"Contact support if you believe this is an error."})]})})]});const T=j.plan==="hosting"?"hosting":j.plan==="done_with_you"?"done_with_you":"diy",P=Dn[T],I=T==="hosting"?"diy":"hosting",O=Dn[I],R=T==="hosting",F=T==="done_with_you",z=j.currentPeriodEnd&&new Date(j.currentPeriodEnd).getTime()>0?Nr(new Date(j.currentPeriodEnd),"MMMM d, yyyy"):null,H=async()=>{f(!0);try{const V=await fetch("/api/stripe/change-plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t,newPlan:I})}),B=await V.json();if(!V.ok)throw new Error(B.error||"Failed to change plan");s({title:"Plan updated",description:B.message}),x(!1),C()}catch(V){s({title:"Error",description:V.message,variant:"destructive"})}finally{f(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Billing"}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs(ee,{children:[e.jsx(qe,{children:e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(di,{className:"h-5 w-5"}),"Current Plan"]})}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-semibold",children:P.name}),e.jsxs("p",{className:"text-muted-foreground",children:["$",P.price,"/month"]})]}),e.jsx(Ce,{variant:j.status==="active"?"default":"secondary",children:j.status})]}),j.cancelAtPeriodEnd?e.jsxs("div",{className:"p-3 bg-amber-50 dark:bg-amber-900/20 rounded-md border border-amber-200 dark:border-amber-800",children:[e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:["Your subscription will cancel",z?` on ${z}`:" at the end of your billing period"]}),e.jsx(D,{variant:"outline",size:"sm",className:"mt-2",onClick:k,"data-testid":"button-reactivate-subscription",children:"Keep my subscription"})]}):z?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Next billing date: ",z]}):null,j.status==="active"&&!j.cancelAtPeriodEnd&&!F&&e.jsxs(St,{open:g,onOpenChange:x,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(D,{variant:R?"default":"outline",size:"sm","data-testid":"button-change-plan",children:[e.jsx(gs,{className:"h-4 w-4 mr-2"}),R?"Upgrade to Creator":"Switch to Hosting"]})}),e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:R?"Upgrade to Creator":"Switch to Hosting"}),e.jsx(Gt,{children:R?"Unlock AI-powered tools including procedure generation, step improvement, voice transcription, and screen recording analysis.":"Switch to the Hosting plan at $29/mo. You will lose access to AI features but keep all platform features."})]}),e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-md",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:O.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["$",O.price,"/month"]})]}),e.jsx(Ce,{variant:"outline",children:R?`+$${O.price-P.price}/mo`:`-$${P.price-O.price}/mo`})]}),R&&e.jsx("ul",{className:"space-y-2",children:["AI-powered writing assistant","AI procedure generation","AI step improvement","Voice transcription & SOP generation","Screen recording analysis"].map((V,B)=>e.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Sr,{className:"w-4 h-4 text-primary flex-shrink-0"}),e.jsx("span",{children:V})]},B))}),!R&&e.jsx("div",{className:"p-3 bg-amber-50 dark:bg-amber-900/20 rounded-md border border-amber-200 dark:border-amber-800",children:e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:"You will lose access to AI features. Your existing content will not be affected."})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The price change will be prorated for the remainder of your current billing period."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(D,{variant:"outline",onClick:()=>x(!1),disabled:h,children:"Cancel"}),e.jsxs(D,{onClick:H,disabled:h,"data-testid":"button-confirm-change-plan",children:[h&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),R?"Upgrade Now":"Switch Plan"]})]})]})]})]})]})]}),e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsx(tt,{children:"Payment Method"}),e.jsx(Tt,{children:"Manage your payment details"})]}),e.jsx(te,{children:e.jsxs(D,{variant:"outline",onClick:N,"data-testid":"button-update-payment",children:[e.jsx(di,{className:"h-4 w-4 mr-2"}
206),"Update Payment Method"]})})]})]}),!j.cancelAtPeriodEnd&&e.jsxs(ee,{className:"border-destructive/50",children:[e.jsxs(qe,{children:[e.jsx(tt,{className:"text-destructive",children:"Cancel Subscription"}),e.jsx(Tt,{children:"End your subscription"})]}),e.jsx(te,{children:e.jsxs(St,{open:o,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsx(D,{variant:"destructive","data-testid":"button-cancel-subscription",children:"Cancel"})}),e.jsxs(jt,{children:[e.jsxs(wt,{children:[e.jsx(bt,{children:"Cancel Subscription"}),e.jsx(Gt,{children:"Are you sure you want to cancel? Your subscription will remain active until the end of your current billing period."})]}),e.jsxs("div",{className:"flex gap-3 mt-4",children:[e.jsx(D,{variant:"outline",onClick:()=>l(!1),disabled:n,children:"Keep Subscription"}),e.jsxs(D,{variant:"destructive",onClick:()=>b(!1),disabled:n,"data-testid":"button-confirm-cancel",children:[n&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Cancel"]})]})]})]})})]})]})}function qz({clientId:t}){const{toast:s}=dt(),[n,a]=m.useState("full"),[o,l]=m.useState("json"),[d,u]=m.useState([]),[h,f]=m.useState(!0),[g,x]=m.useState(!0),[v,w]=m.useState(!1),[C,j]=m.useState(!1),[b,k]=m.useState(!1),{data:N,isLoading:T}=je({queryKey:["/api/portal/export/options"]}),{data:P=[],isLoading:I}=je({queryKey:["/api/portal/export/history"],enabled:b}),O=async()=>{j(!0);try{const M={};n==="knowledge_bases"&&d.length>0&&(M.knowledgeBaseIds=d),(n==="full"||n==="knowledge_bases")&&(M.includeUsers=h,M.includeTeams=g,M.includeArchivedContent=v);const z=Gn(),H={"Content-Type":"application/json"};z&&(H.Authorization=`Bearer ${z}`);const V=await fetch("/api/portal/export",{method:"POST",headers:H,credentials:"include",body:JSON.stringify({exportType:n,format:o,filters:M})});if(!V.ok){const A=await V.json();throw new Error(A.error||"Export failed")}const Y=V.headers.get("Content-Disposition")?.match(/filename="(.+)"/),L=Y?Y[1]:`export.${o}`,K=await V.blob(),_=URL.createObjectURL(K),$=document.createElement("a");$.href=_,$.download=L,document.body.appendChild($),$.click(),document.body.removeChild($),URL.revokeObjectURL(_),de.invalidateQueries({queryKey:["/api/portal/export/history"]}),s({title:"Export complete",description:"Your data has been downloaded."})}catch(M){s({title:"Export failed",description:M.message||"Something went wrong",variant:"destructive"})}finally{j(!1)}},R=M=>new Date(M).toLocaleString(),F=M=>M?M<1024?`${M} B`:M<1024*1024?`${(M/1024).toFixed(1)} KB`:`${(M/(1024*1024)).toFixed(1)} MB`:"N/A";return T?e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsx(be,{className:"h-32 w-full"}),e.jsx(be,{className:"h-32 w-full"})]}):e.jsxs("div",{className:"p-6 space-y-6 max-w-4xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Export Company Data"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Download your company's content and data securely"})]}),e.jsxs(D,{variant:"outline",onClick:()=>k(!b),"data-testid":"button-toggle-export-history",children:[e.jsx(yc,{className:"h-4 w-4 mr-2"}),b?"Hide History":"View History"]})]}),e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(Fi,{className:"h-5 w-5"}),"Export Options"]}),e.jsx(Tt,{children:"Choose what data to export and in what format"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Export Type"}),e.jsxs(lt,{value:n,onValueChange:a,children:[e.jsx(it,{"data-testid":"select-export-type",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"full",children:"Full Export (Everything)"}),e.jsx(me,{value:"knowledge_bases",children:"Knowledge Bases Only"}),e.jsx(me,{value:"procedures",children:"Procedures Only"}),e.jsx(me,{value:"users",children:"Users Only"}),e.jsx(me,{value:"teams",children:"Teams Only"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Export Format"}),e.jsxs(lt,{value:o,onValueChange:l,children:[e.jsx(it,{"data-testid":"select-export-format",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"json",children:"JSON (Data only)"}),e.jsx(me,{value:"csv",children:"CSV (Spreadsheet)"}),e.jsx(me,{value:"zip",children:"ZIP (Data + Media Files)"})]})]})]})]}),(n==="full"||n==="knowledge_bases")&&N&&e.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[e.jsx(Z,{className:"text-base font-medium",children:"Select Knowledge Bases"}),e.jsx("div",{className:"grid gap-2",children:N.available.knowledgeBases.map(M=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:`kb-${M.id}`,checked:d.length===0||d.includes(M.id),onChange:z=>
206{if(z.target.checked)d.length>0&&u([...d,M.id]);else if(d.length===0){const H=N.available.knowledgeBases.filter(V=>V.id!==M.id).map(V=>V.id);u(H)}else u(d.filter(H=>H!==M.id))},className:"h-4 w-4 rounded border-gray-300","data-testid":`checkbox-kb-${M.id}`}),e.jsx(Z,{htmlFor:`kb-${M.id}`,className:"font-normal cursor-pointer",children:M.name})]},M.id))}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.length===0?"All knowledge bases will be exported":`${d.length} knowledge base(s) selected`})]}),n==="full"&&e.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[e.jsx(Z,{className:"text-base font-medium",children:"Include Additional Data"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Z,{htmlFor:"include-users",children:["Users (",N?.available.totalUsers||0,")"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Include user accounts in export"})]}),e.jsx(As,{id:"include-users",checked:h,onCheckedChange:f,"data-testid":"switch-include-users"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Z,{htmlFor:"include-teams",children:["Teams (",N?.available.totalTeams||0,")"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Include team structure in export"})]}),e.jsx(As,{id:"include-teams",checked:g,onCheckedChange:x,"data-testid":"switch-include-teams"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Z,{htmlFor:"include-archived",children:"Archived Content"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Include archived procedures and categories"})]}),e.jsx(As,{id:"include-archived",checked:v,onCheckedChange:w,"data-testid":"switch-include-archived"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{children:"Data Summary:"}),e.jsxs("ul",{className:"list-disc list-inside mt-1",children:[e.jsxs("li",{children:[N?.available.knowledgeBases.length||0," Knowledge Bases"]}),e.jsxs("li",{children:[N?.available.totalProcedures||0," Procedures"]}),e.jsxs("li",{children:[N?.available.totalOverviews||0," Overviews"]}),e.jsxs("li",{children:[N?.available.totalImages||0," Images"]}),e.jsxs("li",{children:[N?.available.totalVideos||0," Videos"]}),e.jsxs("li",{children:[N?.available.totalUsers||0," Users"]}),e.jsxs("li",{children:[N?.available.totalTeams||0," Teams"]})]})]}),e.jsx(D,{onClick:O,disabled:C,size:"lg","data-testid":"button-export",children:C?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Exporting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Export Data"]})})]})]})]}),b&&e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(yc,{className:"h-5 w-5"}),"Export History"]}),e.jsx(Tt,{children:"Previous exports from your company"})]}),e.jsx(te,{children:I?e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"h-16 w-full"}),e.jsx(be,{className:"h-16 w-full"})]}):P.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No exports yet. Start by exporting your data above."}):e.jsx("div",{className:"space-y-3",children:P.map(M=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg","data-testid":`export-log-${M.id}`,children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:M.status==="completed"?"default":"secondary",children:M.exportType}),e.jsx(Ce,{variant:"outline",children:M.exportFormat.toUpperCase()})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Exported by ",M.requestedByEmail]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[R(M.createdAt)," - ",M.recordCount||0," records - ",F(M.fileSizeBytes)]})]}),e.jsx(Ce,{variant:M.status==="completed"?"default":"destructive",className:"ml-2",children:M.status})]},M.id))})})]}),e.jsx(ee,{className:"bg-muted/50",children:e.jsx(te,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Pn,{className:"h-5 w-5 text-muted-foreground mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Security Notice"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All exports are logged for security purposes. Exported data contains only your company's information and is scoped to your account. Export files should be stored securely and shared only with authorized personnel."})]})]})})})]})}function Kz({clientId:t,onNavigateToContent:s,onNavigateToKB:n}){const{toast:a}=dt(),[o,l]=m.useState("30d"),[d,u]=m.useState("aging"),{user:h}=kl(),f=h?.role==="admin",[g,x]=m.useState({kbAgingThresholdDays:180,categoryAgingThresholdDays:90,contentAgingThresholdDays:90,lowViewThreshold:10,lowHelpfulRatioThreshold:50}),v=m.useRef(null),w=()=>{const L=new Date;let K;return o==="7d"?K=new Date(L.getTime()-10080*60*1e3):o==="30d"?K=new Date(L.getTime()-720*60*60*1e3):o==="90d"?K=new Date(L.getTime()-2160*60*60*1e3):o==="12m"&&(K=new Date(L.getTime()-365*24*60*60*1e3)),K?`startDate=${K.toISOString()}`:""},{data:C,isLoading:j}=je({queryKey:["/api/portal/analytics/content-aging"]}),{data:b,isLoading:k}=je({queryKey:["/api/portal/analytics/content-views",o],queryFn:async()=>{const L=w(),K=`/api/portal/analytics/content-views${L?`?${L}`:""}`,_=await fetch(K,{credentials:"include",headers:{Authorization:`Bearer ${Gn()}`}});if(!_.ok)throw new Error("Failed to fetch");return _.json()}}),{data:N,isLoading:T}=je({queryKey:["/api/portal/analytics/settings"]}),P=ye({mutationFn:async L=>(await ce("PATCH","/api/portal/analytics/settings",L)).json(),onSuccess:()=>{de.invalidateQueries({queryKey:["/api/portal/analytics/settings"]}),de.invalidateQueries({queryKey:["/api/portal/analytics/content-aging"]}),a({title:"Settings updated"})},onError:()=>{a({title:"Failed to update settings",variant:"destructive"})}});m.useEffect(()=>{N&&x({kbAgingThresholdDays:N.kbAgingThresholdDays,categoryAgingThresholdDays:N.categoryAgingThresholdDays,contentAgingThresholdDays:N.contentAgingThresholdDays,lowViewThreshold:N.lowViewThreshold,lowHelpfulRatioThreshold:N.lowHelpfulRatioThreshold})},[N]);const I=(L,K)=>{const _=parseInt(K)||0;x($=>({...$,[L]:_})),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{P.mutate({[L]:_||O(L)})},800)}
206,O=L=>({kbAgingThresholdDays:180,categoryAgingThresholdDays:90,contentAgingThresholdDays:90,lowViewThreshold:10,lowHelpfulRatioThreshold:50})[L],R=async L=>{try{const K=new URLSearchParams({type:L,format:"csv"}),_=w();_&&K.append("startDate",_.replace("startDate=",""));const $=`/api/portal/analytics/export?${K.toString()}`,A=await fetch($,{credentials:"include",headers:{Authorization:`Bearer ${Gn()}`}});if(!A.ok)throw new Error("Export failed");const W=await A.blob(),U=URL.createObjectURL(W),Q=document.createElement("a");Q.href=U,Q.download=`analytics-${L}-${new Date().toISOString().split("T")[0]}.csv`,document.body.appendChild(Q),Q.click(),document.body.removeChild(Q),URL.revokeObjectURL(U),a({title:"Export complete"})}catch{a({title:"Export failed",variant:"destructive"})}},F=(L,K,_=90)=>{const $=L;return e.jsx(Ni,{status:$,daysSinceUpdate:K,showDays:!0,thresholdDays:_})};if(j&&k)return e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx(be,{className:"h-8 w-48"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(be,{className:"h-24"}),e.jsx(be,{className:"h-24"}),e.jsx(be,{className:"h-24"})]}),e.jsx(be,{className:"h-64"})]});const M=C?.knowledgeBases?.filter(L=>L.status==="stale").length||0,z=C?.knowledgeBases?.filter(L=>L.status==="aging").length||0,H=C?.content?.filter(L=>L.status==="stale").length||0,V=C?.content?.filter(L=>L.status==="aging").length||0,B=b?.report?.reduce((L,K)=>L+K.totalViews,0)||0,Y=b?.report?.reduce((L,K)=>L+K.helpfulCount+K.notHelpfulCount,0)||0;return e.jsxs("div",{className:"p-6 space-y-6 max-w-6xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(Am,{className:"h-6 w-6"}),"Analytics"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track content health, views, and user feedback"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(lt,{value:o,onValueChange:L=>l(L),children:[e.jsx(it,{className:"w-[140px]","data-testid":"select-date-range",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(me,{value:"7d",children:"Last 7 days"}),e.jsx(me,{value:"30d",children:"Last 30 days"}),e.jsx(me,{value:"90d",children:"Last 90 days"}),e.jsx(me,{value:"12m",children:"Last 12 months"}),e.jsx(me,{value:"all",children:"All time"})]})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(ee,{children:e.jsxs(te,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Content Needing Attention"}),e.jsx("p",{className:"text-2xl font-bold",children:H+V})]}),e.jsx(hl,{className:H>0?"h-8 w-8 text-red-500":"h-8 w-8 text-muted-foreground"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[H," stale, ",V," aging"]})]})}),e.jsx(ee,{children:e.jsxs(te,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Knowledge Bases"}),e.jsx("p",{className:"text-2xl font-bold",children:C?.knowledgeBases?.length||0})]}),e.jsx(cs,{className:"h-8 w-8 text-muted-foreground"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[M," stale, ",z," aging"]})]})}),e.jsx(ee,{children:e.jsxs(te,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Views"}),e.jsx("p",{className:"text-2xl font-bold",children:B.toLocaleString()})]}),e.jsx(Sn,{className:"h-8 w-8 text-muted-foreground"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"In selected period"})]})}),e.jsx(ee,{children:e.jsxs(te,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Feedback Received"}),e.jsx("p",{className:"text-2xl font-bold",children:Y})]}),e.jsx(Tc,{className:"h-8 w-8 text-muted-foreground"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Helpful/Not helpful responses"})]})})]}),e.jsxs(Ma,{value:d,onValueChange:L=>u(L),children:[e.jsxs(ha,{children:[e.jsx(ls,{value:"aging","data-testid":"tab-aging",children:"Content Freshness"}),e.jsx(ls,{value:"views","data-testid":"tab-views",children:"Views & Feedback"}),f&&e.jsx(ls,{value:"settings","data-testid":"tab-settings",children:"Settings"})]}
206),e.jsxs(Ss,{value:"aging",className:"space-y-4 mt-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>R("aging"),"data-testid":"button-export-aging",children:[e.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Export CSV"]})}),C?.content&&C.content.length>0?e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-5 w-5"}),"Content Freshness Report"]}),e.jsx(Tt,{children:"Content sorted by days since last update"})]}),e.jsx(te,{children:e.jsx("div",{className:"space-y-3",children:C.content.sort((L,K)=>K.daysSinceUpdate-L.daysSinceUpdate).map(L=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border cursor-pointer hover-elevate transition-colors","data-testid":`aging-item-${L.id}`,onClick:()=>{L.knowledgeBaseId&&s(L.knowledgeBaseId,L.categoryId||null,L.id)},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[L.contentType==="overview"?e.jsx(ln,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Pt,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.title||L.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:L.lastUpdated?`Last updated ${L.daysSinceUpdate} days ago`:"Never updated"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[F(L.status,L.daysSinceUpdate,N?.contentAgingThresholdDays||90),e.jsx(Yn,{className:"h-4 w-4 text-muted-foreground"})]})]},L.id))})})]}):e.jsx(ee,{children:e.jsxs(te,{className:"py-8 text-center",children:[e.jsx(Sr,{className:"h-12 w-12 mx-auto mb-3 text-green-500"}),e.jsx("p",{className:"text-lg font-medium",children:"All content is up to date"}),e.jsx("p",{className:"text-muted-foreground",children:"No stale or aging content detected"})]})})]}),e.jsxs(Ss,{value:"views",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>R("content_views"),"data-testid":"button-export-views",children:[e.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Export Views"]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>R("feedback"),"data-testid":"button-export-feedback",children:[e.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Export Feedback"]})]}),b?.enabled===!1?e.jsx(ee,{children:e.jsxs(te,{className:"py-8 text-center",children:[e.jsx(Sn,{className:"h-12 w-12 mx-auto mb-3 text-muted-foreground"}),e.jsx("p",{className:"text-lg font-medium",children:"Views Monitoring Disabled"}),e.jsx("p",{className:"text-muted-foreground",children:"Enable content views monitoring in Settings to track engagement"})]})}):b?.report&&b.report.length>0?e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5"}),"Content Engagement"]}),e.jsx(Tt,{children:"Views and feedback for your content"})]}),e.jsx(te,{children:e.jsx("div",{className:"space-y-3",children:b.report.sort((L,K)=>K.totalViews-L.totalViews).map(L=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border cursor-pointer hover-elevate transition-colors","data-testid":`views-item-${L.id}`,onClick:()=>{L.knowledgeBaseId&&s(L.knowledgeBaseId,L.categoryId||null,L.id)},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[L.contentType==="overview"?e.jsx(ln,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Pt,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[L.uniqueViewers," unique viewer",L.uniqueViewers!==1?"s":""]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"font-medium",children:L.totalViews}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"views"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(Tc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:L.helpfulCount})]}),e.jsxs("div",{className:"flex items-center gap-1 text-red-600",children:[e.jsx(Hu,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:L.notHelpfulCount})]})]}),L.helpfulRatio!==null&&e.jsxs(Ce,{variant:L.helpfulRatio>=70?"default":L.helpfulRatio>=50?"secondary":"destructive",children:[L.helpfulRatio,"% helpful"]}),e.jsx(Yn,{className:"h-4 w-4 text-muted-foreground"})]})]},L.id))})})]}):e.jsx(ee,{children:e.jsxs(te,{className:"py-8 text-center",children:[e.jsx(Sn,{className:"h-12 w-12 mx-auto mb-3 text-muted-foreground"}),e.jsx("p",{className:"text-lg font-medium",children:"No views data yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Views will appear here once users start viewing your content"})]})})]}
206),f&&e.jsx(Ss,{value:"settings",className:"space-y-4 mt-4",children:T?e.jsx(be,{className:"h-64"}):N?e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-5 w-5"}),"Content Aging Thresholds"]}),e.jsx(Tt,{children:"Configure when content is considered stale"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Z,{children:"Monitor Knowledge Bases"}),e.jsx(As,{checked:N.monitorKbAging,onCheckedChange:L=>P.mutate({monitorKbAging:L}),"data-testid":"switch-monitor-kb"})]}),N.monitorKbAging&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"KB Aging Threshold (days)"}),e.jsx(fe,{type:"number",value:g.kbAgingThresholdDays,onChange:L=>I("kbAgingThresholdDays",L.target.value),"data-testid":"input-kb-threshold"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Z,{children:"Monitor Categories"}),e.jsx(As,{checked:N.monitorCategoryAging,onCheckedChange:L=>P.mutate({monitorCategoryAging:L}),"data-testid":"switch-monitor-category"})]}),N.monitorCategoryAging&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Category Aging Threshold (days)"}),e.jsx(fe,{type:"number",value:g.categoryAgingThresholdDays,onChange:L=>I("categoryAgingThresholdDays",L.target.value),"data-testid":"input-category-threshold"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Z,{children:"Monitor Content (Procedures/Overviews)"}),e.jsx(As,{checked:N.monitorContentAging,onCheckedChange:L=>P.mutate({monitorContentAging:L}),"data-testid":"switch-monitor-content"})]}),N.monitorContentAging&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Content Aging Threshold (days)"}),e.jsx(fe,{type:"number",value:g.contentAgingThresholdDays,onChange:L=>I("contentAgingThresholdDays",L.target.value),"data-testid":"input-content-threshold"})]})]})]}),e.jsxs(ee,{children:[e.jsxs(qe,{children:[e.jsxs(tt,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5"}),"Engagement Monitoring"]}),e.jsx(Tt,{children:"Configure view and feedback tracking"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Z,{children:"Track Content Views"}),e.jsx(As,{checked:N.monitorContentViews,onCheckedChange:L=>P.mutate({monitorContentViews:L}),"data-testid":"switch-monitor-views"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Z,{children:"Track User Feedback"}),e.jsx(As,{checked:N.monitorUserFeedback,onCheckedChange:L=>P.mutate({monitorUserFeedback:L}),"data-testid":"switch-monitor-feedback"})]}),N.monitorContentViews&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Low View Threshold"}),e.jsx(fe,{type:"number",value:g.lowViewThreshold,onChange:L=>I("lowViewThreshold",L.target.value),"data-testid":"input-low-view-threshold"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Content below this is flagged as low engagement"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Low Helpful Ratio Threshold (%)"}),e.jsx(fe,{type:"number",value:g.lowHelpfulRatioThreshold,onChange:L=>I("lowHelpfulRatioThreshold",L.target.value),"data-testid":"input-helpful-threshold"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Content below this ratio may need improvement"})]})]})]})]})]}):null})]})]})}function Hz(){const t=km(),s=new URLSearchParams(t).get("token"),[n,a]=m.useState("loading"),[o,l]=m.useState(""),[d,u]=m.useState(""),[h,f]=m.useState(""),[g,x]=m.useState(""),{data:v,isLoading:w,error:C}=je({queryKey:["/api/auth/token-info",s],queryFn:async()=>{if(!s)throw new Error("No token");const k=await fetch(`/api/auth/token-info/${s}`);if(!k.ok){const N=await k.json();throw new Error(N.error||"Invalid token")}return k.json()},enabled:!!s,retry:!1}),j=ye({mutationFn:async({token:k,newPassword:N})=>{const T=await ce("POST","/api/auth/verify-password-change",{token:k,newPassword:N});if(!T.ok){const P=await T.json();throw new Error(P.error||"Verification failed")}return T.json()},onSuccess:()=>{a("success")},onError:k=>{a("error"),l(k.message)}});m.useEffect(()=>{if(!s){a("no-token");return}if(w){a("loading");return}if(C){a("error"),l(C.message);return}v&&(v.type==="admin"?a("password-form"):j.mutate({token:s}))},[s,v,w,C]);const b=()=>{if(x(""),!d||!h){x("Please fill in both password fields");return}if(d!==h){x("Passwords do not match");return}if(d.length<8){x("Password must be at least 8 characters");return}s&&j.mutate({token:s,newPassword:d})};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(ee,{className:"w-full max-w-md",children:[e.jsxs(qe,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[(n==="loading"||j.isPending)&&e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center",children:e.jsx(Ve,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),n==="password-form"&&!j.isPending&&e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Pn,{className:"h-8 w-8 text-primary"})}),n==="success"&&e.jsx("div",{className:"w-16 h-16 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:e.jsx(Sr,{className:"h-8 w-8 text-green-600 dark:text-green-400"})}),(n==="error"||n==="no-token")&&e.jsx("div",{className:"w-16 h-16 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:e.jsx(Fp,{className:"h-8 w-8 text-red-600 dark:text-red-400"})})]}),e.jsxs(tt,{className:"flex items-center justify-center gap-2",children:[e.jsx(Pn,{className:"h-5 w-5"}),(n==="loading"||j.isPending)&&"Verifying...",n==="password-form"&&!j.isPending&&"Set New Password",n==="success"&&"Password Changed",n==="error"&&"Verification Failed",n==="no-token"&&"Invalid Link"]}),e.jsxs(Tt,{children:[(n==="loading"||j.isPending)&&"Please wait while we process your request...",n==="password-form"&&!j.isPending&&e.jsxs(e.Fragment,{children:["An administrator has initiated a password reset for ",e.jsx("strong",{children:v?.userName||v?.userEmail}),". Please enter your new password below."]}),n==="success"&&"Your password has been successfully changed. You can now sign in with your new password.",n==="error"&&(o||"Something went wrong while verifying your password change."),n==="no-token"&&"This verification link is invali
206d. Please request a new password change."]})]}),e.jsxs(te,{className:"text-center",children:[n==="password-form"&&!j.isPending&&e.jsxs("div",{className:"space-y-4 text-left",children:[g&&e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 text-center p-2 bg-red-50 dark:bg-red-900/20 rounded-md",children:g}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"new-password",children:"New Password"}),e.jsx(fe,{id:"new-password",type:"password",value:d,onChange:k=>u(k.target.value),placeholder:"Enter new password","data-testid":"input-new-password"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"confirm-password",children:"Confirm Password"}),e.jsx(fe,{id:"confirm-password",type:"password",value:h,onChange:k=>f(k.target.value),placeholder:"Confirm new password",onKeyDown:k=>k.key==="Enter"&&b(),"data-testid":"input-confirm-password"})]}),e.jsx(D,{className:"w-full",onClick:b,"data-testid":"button-set-password",children:"Set Password"})]}),n==="success"&&e.jsx(ht,{href:"/admin",children:e.jsx(D,{"data-testid":"button-go-to-admin",children:"Go to Admin"})}),(n==="error"||n==="no-token")&&e.jsx(ht,{href:"/admin",children:e.jsx(D,{variant:"outline","data-testid":"button-back-to-admin",children:"Back to Admin"})})]})]})})}function Wz(){const[,t]=Kr(),{user:s,setUser:n}=Oa(),{toast:a}=dt(),[o,l]=m.useState("email"),[d,u]=m.useState(""),[h,f]=m.useState(""),x=new URLSearchParams(window.location.search).get("redirect")||"/portal",v=x.startsWith("/")&&!x.startsWith("//")?x:"/portal";m.useEffect(()=>{s&&t(v)},[s,t,v]);const w=ye({mutationFn:async k=>(await ce("POST","/api/portal/auth/request-login",{email:k})).json(),onSuccess:k=>{k.email&&u(k.email),l("code"),a({title:"Check your email for a login code"})},onError:k=>{a({title:"Failed to send login email",description:k.message,variant:"destructive"})}}),C=ye({mutationFn:async({email:k,code:N})=>(await ce("POST","/api/portal/auth/verify-code",{email:k,code:N})).json(),onSuccess:k=>{n(k.user,k.authToken),a({title:"Welcome back!"}),t(v)},onError:k=>{a({title:"Invalid code",description:k.message,variant:"destructive"})}}),j=k=>{k.preventDefault(),w.mutate(d)},b=k=>{k.preventDefault(),C.mutate({email:d,code:h})};return s?null:e.jsxs("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center p-4",children:[e.jsx("div",{className:"absolute top-4 right-4",children:e.jsx(Ra,{})}),e.jsx(ht,{href:"/",children:e.jsx("span",{className:"font-serif text-2xl mb-8 block cursor-pointer","data-testid":"link-portal-login-logo",children:"outliner"})}),e.jsxs(ee,{className:"w-full max-w-md",children:[e.jsxs(qe,{className:"text-center",children:[e.jsx(tt,{children:"Portal Login"}),e.jsx(Tt,{children:o==="email"?"Enter your email to receive a login code":"Enter the code sent to your email"})]}),e.jsx(te,{children:o==="email"?e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"email",children:"Email"}),e.jsx(fe,{id:"email",type:"email",placeholder:"[email protected]",value:d,onChange:k=>u(k.target.value),required:!0,"data-testid":"input-portal-email"})]}),e.jsxs(D,{type:"submit",className:"w-full",disabled:w.isPending,"data-testid":"button-send-code",children:[w.isPending?e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Send Login Code"]})]}):e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"code",children:"Verification Code"}),e.jsx(fe,{id:"code",type:"text",placeholder:"123456",value:h,onChange:k=>f(k.target.value),maxLength:6,className:"text-center text-2xl tracking-widest",required:!0,"data-testid":"input-portal-code"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Code sent to ",d]})]}),e.jsxs(D,{type:"submit",className:"w-full",disabled:C.isPending||h.length!==6,"data-testid":"button-verify-code",children:[C.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Verify Code"]}),e.jsxs(D,{type:"button",variant:"ghost",className:"w-full",onClick:()=>{l("email"),f("")},"data-testid":"button-back-to-email",children:[e.jsx(kn,{className:"h-4 w-4 mr-2"}),"Try a different email"]})]})})]})]})}function Qz(){const[,t]=Kr(),s=km(),{setUser:n}=Oa(),{toast:a}=dt(),[o,l]=m.useState(!1),u=new URLSearchParams(s).get("token"),h=ye({mutationFn:async g=>(await ce("POST","/api/portal/auth/verify-token",{token:g})).json(),onSuccess:g=>{n(g.user,g.authToken),a({title:"Welcome back!"}),t("/portal")},onError:g=>{a({title:"Invalid or expired link",description:g.message,variant:"destructive"})}}),f=()=>{u&&(l(!0),h.mutate(u))};return u?h.isError?e.jsxs("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center p-4",children:[e.jsx(ht,{href:"/",children:e.jsx("span",{className:"font-serif text-2xl mb-8 block cursor-pointer","data-testid":"link-portal-verify-logo",children:"outliner"})}),e.jsxs(ee,{className:"w-full max-w-md",children:[e.jsxs(qe,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(hl,{className:"h-12 w-12 text-destructive"})}),e.jsx(tt,{children:"Link Expired or Invalid"}),e.jsx(Tt,{children:"This login link has already been used or has expired. Please request a new login code."})]}),e.jsx(te,{className:"flex justify-center",children:e.jsx(D,{onClick:()=>t("/portal/login"),"data-testid":"button-request-new-code",children:"Request New Code"})})]})]}):e.jsxs("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center p-4",children:[e.jsx(ht,{href:"/",children:e.jsx("span",{className:"font-serif text-2xl mb-8 block cursor-pointer","data-testid":"link-portal-verify-logo",children:"outliner"})}),e.jsxs(ee,{className:"w-full max-w-md",children:[e.jsxs(qe,{className:"text-center",children:[e.jsx(tt,{children:o?"Logging you in...":"Confirm Login"}),!o&&e.jsx(Tt,{children:"Click the button below to complete your login to the Outliner Portal."})]}),e.jsx(te,{className:"flex justify-center py-6",children:o?e.jsx(Ve,{className:"h-8 w-8 animate-spin text-muted-foreground"}):e.jsxs(D,{size:"lg",onClick:f,disabled:h.isPending,"data-testid":"button-confirm-login",children:[e.jsx(qu,{className:"h-5 w-5 mr-2"}),"Log In to Portal"]})})]})]}):e.jsxs("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center p-4",children:[e.jsx(ht,{href:"/",children:e.jsx("span",{className:"font-serif text-2xl mb-8 block cursor-pointer","data-testid":"link-portal-verify-logo",children:"outliner"})}),e.jsxs(ee,{className:"w-full max-w-md",children:[e.jsxs(qe,{className:"text-center",children:[e.jsx(tt,{children:"Invalid Link"}
206),e.jsx(Tt,{children:"This login link is invalid or missing. Please request a new one."})]}),e.jsx(te,{className:"flex justify-center",children:e.jsx(D,{onClick:()=>t("/portal/login"),"data-testid":"button-go-to-login",children:"Go to Login"})})]})]})}var ev="Checkbox",[Gz]=En(ev),[Yz,Zz]=Gz(ev),e2=m.forwardRef((t,s)=>{const{__scopeCheckbox:n,name:a,checked:o,defaultChecked:l,required:d,disabled:u,value:h="on",onCheckedChange:f,form:g,...x}=t,[v,w]=m.useState(null),C=At(s,P=>w(P)),j=m.useRef(!1),b=v?g||!!v.closest("form"):!0,[k=!1,N]=Ur({prop:o,defaultProp:l,onChange:f}),T=m.useRef(k);return m.useEffect(()=>{const P=v?.form;if(P){const I=()=>N(T.current);return P.addEventListener("reset",I),()=>P.removeEventListener("reset",I)}},[v,N]),e.jsxs(Yz,{scope:n,state:k,disabled:u,children:[e.jsx(at.button,{type:"button",role:"checkbox","aria-checked":ui(k)?"mixed":k,"aria-required":d,"data-state":n2(k),"data-disabled":u?"":void 0,disabled:u,value:h,...x,ref:C,onKeyDown:Ae(t.onKeyDown,P=>{P.key==="Enter"&&P.preventDefault()}),onClick:Ae(t.onClick,P=>{N(I=>ui(I)?!0:!I),b&&(j.current=P.isPropagationStopped(),j.current||P.stopPropagation())})}),b&&e.jsx(Xz,{control:v,bubbles:!j.current,name:a,value:h,checked:k,required:d,disabled:u,form:g,style:{transform:"translateX(-100%)"},defaultChecked:ui(l)?!1:l})]})});e2.displayName=ev;var t2="CheckboxIndicator",s2=m.forwardRef((t,s)=>{const{__scopeCheckbox:n,forceMount:a,...o}=t,l=Zz(t2,n);return e.jsx(gn,{present:a||ui(l.state)||l.state===!0,children:e.jsx(at.span,{"data-state":n2(l.state),"data-disabled":l.disabled?"":void 0,...o,ref:s,style:{pointerEvents:"none",...t.style}})})});s2.displayName=t2;var Xz=t=>{const{control:s,checked:n,bubbles:a=!0,defaultChecked:o,...l}=t,d=m.useRef(null),u=$x(n),h=Bg(s);m.useEffect(()=>{const g=d.current,x=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(x,"checked").set;if(u!==n&&w){const C=new Event("click",{bubbles:a});g.indeterminate=ui(n),w.call(g,ui(n)?!1:n),g.dispatchEvent(C)}},[u,n,a]);const f=m.useRef(ui(n)?!1:n);return e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??f.current,...l,tabIndex:-1,ref:d,style:{...t.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function ui(t){return t==="indeterminate"}function n2(t){return ui(t)?"indeterminate":t?"checked":"unchecked"}var r2=e2,Jz=s2;const gg=m.forwardRef(({className:t,...s},n)=>e.jsx(r2,{ref:n,className:Oe("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...s,children:e.jsx(Jz,{className:Oe("flex items-center justify-center text-current"),children:e.jsx(yr,{className:"h-4 w-4"})})}));gg.displayName=r2.displayName;function eB(){const[,t]=Kr(),s=km(),{user:n,setUser:a}=Oa(),{toast:o}=dt(),l=new URLSearchParams(s),d=l.get("mode")==="login",u=l.get("plan"),[h,f]=m.useState("email"),[g,x]=m.useState(""),[v,w]=m.useState(""),[C,j]=m.useState(""),[b,k]=m.useState(""),[N,T]=m.useState(u==="hosting"?"hosting":"diy"),[P,I]=m.useState(!1),[O,R]=m.useState(d?!1:null),[F,M]=m.useState(d),[z,H]=m.useState(!1),V=Dn[N];m.useEffect(()=>{n&&t("/portal")},[n,t]);const B=ye({mutationFn:async({email:W})=>(await ce("POST","/api/auth/check-email",{email:W,plan:N})).json(),onSuccess:W=>{W.action==="login"?(R(!1),Y.mutate(g)):W.action==="checkout"&&(R(!0),K.mutate({email:g,firstName:v,lastName:C,startTrial:P}))},onError:W=>{o({title:"Something went wrong",description:W.message,variant:"destructive"})}}),Y=ye({mutationFn:async W=>(await ce("POST","/api/portal/auth/request-login",{email:W})).json(),onSuccess:W=>{W.email&&x(W.email),f("code"),o({title:"Check your email for a login code"})},onError:W=>{o({title:"Failed to send login email",description:W.message,variant:"destructive"})}}),L=ye({mutationFn:async({email:W,code:U})=>(await ce("POST","/api/portal/auth/verify-code",{email:W,code:U})).json(),onSuccess:W=>{a(W.user,W.authToken),o({title:"Welcome back!"}),t("/portal")},onError:W=>{o({title:"Invalid code",description:W.message,variant:"destructive"})}}),K=ye({mutationFn:async({email:W,firstName:U,lastName:Q,startTrial:we})=>(await ce("POST","/api/stripe/create-checkout-session",{email:W,plan:N,firstName:U,lastName:Q,startTrial:we})).json(),onSuccess:W=>{W.url&&(window.location.href=W.url)},onError:W=>{o({title:"Failed to start checkout",description:W.message,variant:"destructive"})}}),_=W=>{W.preventDefault(),g.trim()&&(F?Y.mutate(g):B.mutate({email:g}))},$=W=>{W.preventDefault(),b.trim()&&L.mutate({email:g,code:b})},A=B.isPending||Y.isPending||K.isPending;return e.jsxs("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center p-4 relative",children:[e.jsx("div",{className:"absolute top-4 right-4",children:e.jsx(Ra,{})}),h==="email"&&e.jsxs("div",{className:"flex flex-col items-center w-full max-w-2xl",children:[e.jsx(ht,{href:"/",children:e.jsx("span",{className:"font-serif text-3xl cursor-pointer mb-6 block","data-testid":"link-get-started-logo",children:"outliner"})}),!F&&e.jsxs("div",{className:"w-full mb-6 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(ee,{className:`w-full cursor-pointer transition-all hover-elevate ${N==="hosting"?"border-primary ring-2 ring-primary/20":"border-border"}`,onClick:()=>T("hosting"),"data-testid":"card-plan-hosting",children:e.jsxs(te,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-medium text-lg",children:Dn.hosting.name}),e.jsxs("div",{className:"text-right",children:[e.jsxs("span",{className:"text-2xl font-semibold",children:["$",Dn.hosting.price]}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"/mo"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:Dn.hosting.description}),e.jsxs("ul",{className:"space-y-1.5",children:[Dn.hosting.features.map((W,U)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Sr,{className:"w-3 h-3 text-primary flex-shrink-0"}),e.jsx("span",{children:W})]},U)),e.jsxs("li",{className:"flex items-center gap-2 text-xs text-muted-foreground
206/50",children:[e.jsx(Zn,{className:"w-3 h-3 flex-shrink-0"}),e.jsx("span",{children:"AI-powered tools"})]})]})]})}),e.jsx(ee,{className:`w-full cursor-pointer transition-all hover-elevate ${N==="diy"?"border-primary ring-2 ring-primary/20":"border-border"}`,onClick:()=>T("diy"),"data-testid":"card-plan-creator",children:e.jsxs(te,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-medium text-lg",children:Dn.diy.name}),e.jsx(Ce,{variant:"default",className:"text-xs","data-testid":"badge-popular",children:"Popular"})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("span",{className:"text-2xl font-semibold",children:["$",Dn.diy.price]}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"/mo"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:Dn.diy.description}),e.jsx("ul",{className:"space-y-1.5",children:Dn.diy.features.map((W,U)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(gs,{className:"w-3 h-3 flex-shrink-0 text-primary"}),e.jsx("span",{children:W})]},U))})]})})]}),e.jsx("div",{className:"text-center p-3 bg-muted rounded-md",children:e.jsx("p",{className:"text-sm",children:e.jsxs("span",{className:"font-semibold",children:["Monthly total: $",V.price.toLocaleString(),"/mo"]})})}),e.jsxs("div",{className:`flex items-center gap-3 p-3 border rounded-md cursor-pointer transition-all hover-elevate ${P?"border-primary bg-primary/5":"border-border"}`,onClick:()=>I(!P),"data-testid":"card-trial-option",children:[e.jsx(gg,{checked:P,onClick:W=>W.stopPropagation(),onCheckedChange:W=>I(W===!0),"data-testid":"checkbox-trial-option"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Start with a 7-day free trial"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Try the platform free for 7 days. Your card will be charged after the trial ends."})]})]})]}),e.jsxs(ee,{className:"w-full max-w-lg",children:[e.jsxs(qe,{className:"text-center",children:[e.jsxs(tt,{className:"flex items-center justify-center gap-2",children:[e.jsx(Ta,{className:"h-5 w-5"}),F?"Welcome back":"Get started"]}),e.jsx(Tt,{children:F?"Enter your email to receive a login code":"We'll check if you have an account or create one for you"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[!F&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"firstName",children:"First Name"}),e.jsx(fe,{id:"firstName",type:"text",placeholder:"John",value:v,onChange:W=>w(W.target.value),disabled:A,required:!0,"data-testid":"input-first-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"lastName",children:"Last Name"}),e.jsx(fe,{id:"lastName",type:"text",placeholder:"Smith",value:C,onChange:W=>j(W.target.value),disabled:A,required:!0,"data-testid":"input-last-name"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"email",children:"Email"}),e.jsx(fe,{id:"email",type:"email",placeholder:"[email protected]",value:g,onChange:W=>x(W.target.value),disabled:A,required:!0,"data-testid":"input-email"})]}),e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(gg,{id:"terms",checked:z,onCheckedChange:W=>H(W===!0),disabled:A,"data-testid":"checkbox-terms"}),e.jsxs("label",{htmlFor:"terms",className:"text-sm text-muted-foreground leading-relaxed cursor-pointer",children:["I have read and agree to the"," ",e.jsx(ht,{href:"/terms",className:"text-primary hover:underline","data-testid":"link-terms",children:"Terms of Service"})," ","and"," ",e.jsx(ht,{href:"/privacy",className:"text-primary hover:underline","data-testid":"link-privacy",children:"Privacy Policy"})]})]}),e.jsxs(D,{type:"submit",className:"w-full",disabled:A||!g.trim()||!z||!F&&(!v.trim()||!C.trim()),"data-testid":"button-continue",children:[A&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),F?"Continue":"Continue to Checkout",e.jsx(_g,{className:"ml-2 h-4 w-4"})]})]}),F&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Don't have an account?"," ",e.jsx("button",{onClick:()=>M(!1),className:"text-primary hover:underline","data-testid":"button-signup",children:"Sign up"})]}),!F&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Already have an account?"," ",e.jsx("button",{onClick:()=>M(!0),className:"text-primary hover:underline","data-testid":"button-login-instead",children:"Sign in"})]})]})]})]}),h==="code"&&e.jsxs("div",{className:"flex flex-col items-center w-full max-w-md",children:[e.jsx(ht,{href:"/",children:e.jsx("span",{className:"font-serif text-3xl cursor-pointer mb-6 block","data-testid":"link-get-started-logo-code",children:"outliner"})}),e.jsxs(ee,{className:"w-full",children:[e.jsxs(qe,{className:"text-center",children:[e.jsx(tt,{children:"Check your email"}),e.jsxs(Tt,{children:["We sent a 6-digit code to ",e.jsx("span",{className:"font-medium",children:g})]})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"code",children:"Verification Code"}),e.jsx(fe,{id:"code",type:"text",placeholder:"123456",value:b,onChange:W=>k(W.target.value.replace(/\D/g,"").slice(0,6)),disabled:L.isPending,maxLength:6,className:"text-center text-2xl tracking-widest",required:!0,"data-testid":"input-code"})]}),e.jsxs(D,{type:"submit",className:"w-full",disabled:L.isPending||b.length!==6,"data-testid":"button-verify",children:[L.isPending&&e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"}),"Verify & Sign In"]})]}),e.jsxs(D,{variant:"ghost",className:"w-full",onClick:()=>{f("email"),k("")},disabled:L.isPending,"data-testid":"button-back-to-email",children:[e.jsx(kn,{className:"h-4 w-4 mr-2"}),"Try a different email"]})]})]})]})]})}function tB(){const[,t]=Kr(),s=km(),{setUser:n}=Oa(),{toast:a}=dt(),[o,l]=m.useState("loading"),u=new URLSearchParams(s).get("session_id"),h=ye({mutationFn:async f=>(await ce("POST","/api/stripe/verify-session",{sessionId:f})).json(),onSuccess:f=>{f.user&&n(f.user,f.authToken),l("success"),a({title:"Welcome to Outliner!",description:"Your account is ready."})},onError:f=>{l("error"),a({title:"Verification failed",description:f.message,variant:"destructive"})}});return m.useEffect(()=>{u?h.mutate(u):l("error")},[u]),e.jsxs("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center p-4",children:[e.jsxs("div",{className:"flex items-center justify-between w-full max-w-md mb-8",children:[e.jsx(ht,{href:"/",children:e.jsx("span",{className:"font-serif text-2xl cursor-pointer","data-testid":"link-checkout-logo",children:"outliner"})}),e.jsx(Ra,{})]}),e.jsxs(ee,{className:"w-full max-w-md",children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsxs(qe,{className:"text-center",children:[e.jsx(tt,{children:"Setting up your account"}),e.jsx(Tt,{children:"Please wait while we finish setting things up..."})]}),e.jsx(te,{className:"flex justify-center py-8",children:e.jsx(Ve,{className:"h-8 w-8 animate-spin text-muted-foreground"})})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs(qe,{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-4",children:e.jsx(Sr,{className:"h-8 w-8 text-primary"})}),e.jsx(tt,{children:"Welcome to Outliner!"}),e.jsx(Tt,{children:"Your account has been created and you're ready to get started."})]}),e.jsx(te,{className:"space-y-4",children:e.jsxs(D,{className:"w-full",onClick:()=>t("/portal"),"data-testid":"button-go-to-portal",children:["Go to your portal",e.jsx(_g,{className:"ml-2 h-4 w-4"})]})})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsxs(qe,{className:"text-center",children:[e.jsx(tt,{children:"Something went wrong"}),e.jsx(Tt,{children:"We couldn't verify your payment. Please contact support if the issue persists."})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsx(ht,{href:"/get-started",children:e.jsx(D,{className:"w-full",variant:"outline","data-testid":"button-try-again",children:"Try again"})}),e.jsx(ht,{href:"/",children:e.jsx(D,{className:"w-full",variant:"ghost","data-testid":"button-back-home",children:"Back to home"})})]})]})]})]})}function sB(){return e.jsxs("div",{className:"h-screen flex flex-col",children:[e.jsxs("div",{className:"bg-sidebar border-b border-border px-4 py-3 flex items-center justify-between gap-4 flex-shrink-0",children:[e.jsxs("a",{href:"/",className:"flex items-center gap-2 hover:opacity-80 transition-opacity","data-testid":"link-demo-home",children:[e.jsx(yN,{className:"w-4 h-4 text-sidebar-foreground"}),e.jsx("span",{className:"font-serif text-lg text-sidebar-foreground",children:"outliner"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-sidebar-foreground
206/70 hidden sm:inline",children:"You're viewing a demo knowledge base"}),e.jsx("a",{href:"/get-started",children:e.jsxs(D,{size:"sm","data-testid":"button-demo-get-started",children:["Get Started",e.jsx(_g,{className:"ml-2 h-4 w-4"})]})})]})]}),e.jsx("iframe",{src:"/kb/demo",className:"flex-1 w-full border-0",title:"Demo Knowledge Base","data-testid":"iframe-demo-kb"})]})}function nB(){return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"sticky top-0 z-50 w-full border-b border-border/50 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:e.jsxs("div",{className:"container mx-auto flex h-16 items-center justify-between gap-4 px-4 md:px-6",children:[e.jsx(ht,{href:"/",children:e.jsx("span",{className:"font-serif text-[26px] font-medium tracking-tight cursor-pointer","data-testid":"link-logo",children:"outliner"})}),e.jsx(ht,{href:"/",children:e.jsxs(D,{variant:"ghost",size:"sm","data-testid":"button-back-home",children:[e.jsx(kn,{className:"mr-2 h-4 w-4"}),"Back to Home"]})})]})}),e.jsxs("main",{className:"container mx-auto px-4 md:px-6 py-16 max-w-4xl",children:[e.jsx("h1",{className:"font-serif text-4xl md:text-5xl font-normal tracking-tight mb-8",children:"Terms of Service"}),e.jsx("p",{className:"text-muted-foreground mb-8",children:"Last updated: January 2025"}),e.jsxs("div",{className:"prose prose-invert max-w-none space-y-8",children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"1. Agreement to Terms"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:'By accessing or using the Outliner platform ("Service"), you agree to be bound by these Terms of Service ("Terms"). If you do not agree to these Terms, you may not access or use the Service. Outliner is operated by Outliner LLC, a Missouri Limited Liability Company.'})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"2. Jurisdiction and Governing Law"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"These Terms shall be governed by and construed in accordance with the laws of the State of Missouri, without regard to its conflict of law provisions. Any legal action or proceeding arising out of or relating to these Terms or the Service shall be brought exclusively in the state or federal courts located in St. Louis, Missouri. You consent to the personal jurisdiction of such courts and waive any objection to venue in such courts."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"3. Intellectual Property Rights"}),e.jsxs("p",{className:"text-muted-foreground leading-relaxed",children:[e.jsx("strong",{className:"text-foreground",children:"Your Content:"}),' You retain all ownership rights to the Standard Operating Procedures (SOPs), documentation, and other content you create using the Service ("Your Content"). Outliner does not claim any ownership rights over Your Content. You grant Outliner a limited license to host, store, and display Your Content solely for the purpose of providing the Service to you.']}),e.jsxs("p",{className:"text-muted-foreground leading-relaxed mt-4",children:[e.jsx("strong",{className:"text-foreground",children:"Our Platform:"})," The Service, including its design, features, and underlying technology, is owned by Outliner LLC and protected by intellectual property laws."]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"4. Free Trial"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"Outliner may offer a free trial period for new subscribers. If you elect to start a free trial:"}),e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground mt-4 space-y-2",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Payment Information Required:"})," You must provide valid payment information to start a free trial. Your card will not be charged during the trial period."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Automatic Conversion:"})," Unless you cancel before the trial period ends, your subscription will automatically convert to a paid subscription, and 
206your payment method will be charged the applicable subscription fee."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Cancellation During Trial:"})," You may cancel at any time during the trial period through your account settings or by contacting us. If you cancel before the trial ends, you will not be charged."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"One Trial Per Customer:"})," Free trials are limited to one per customer. Outliner reserves the right to revoke trial access if we determine abuse of the trial program."]})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"5. Refund Policy"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"All payments are non-refundable unless Outliner, in its sole discretion, agrees to issue a refund. If you believe you are entitled to a refund, you may contact us to discuss your situation, but we are under no obligation to provide one. By subscribing to the Service, you acknowledge and accept this no-refund policy."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"6. Right to Refuse Service"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"Outliner reserves the right to refuse, suspend, or terminate service to any individual or organization at any time, for any reason, with or without notice. We are not obligated to provide an explanation for such decisions. This includes the right to decline new customers or terminate existing accounts."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"7. Acceptable Use Policy"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"You agree not to misuse the Service. Prohibited activities include, but are not limited to:"}),e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground mt-4 space-y-2",children:[e.jsx("li",{children:"Attempting to gain unauthorized access to the Service or its related systems"}),e.jsx("li",{children:"Using the Service to transmit harmful, illegal, or objectionable content"}),e.jsx("li",{children:"Interfering with or disrupting the integrity or performance of the Service"}),e.jsx("li",{children:"Attempting to reverse engineer or extract source code from the Service"}),e.jsx("li",{children:"Using automated systems to access the Service in a manner that exceeds reasonable use"}),e.jsx("li",{children:"Sharing account credentials with unauthorized parties"}),e.jsx("li",{children:"Using the Service for any illegal purpose"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"8. API Usage and Throttling"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"The Service utilizes third-party APIs, including ElevenLabs and Anthropic, to provide certain features. Outliner reserves the right to throttle, limit, or temporarily suspend your access to these features at any time to manage system resources, prevent abuse, or comply with third-party API limitations."}),e.jsxs("p",{className:"text-muted-foreground leading-relaxed mt-4",children:[e.jsx("strong",{className:"text-foreground",children:"No Compensation for Throttling:"})," You are not entitled to any refund, credit, discount, or compensation of any kind if your account is throttled or if API-dependent features are temporarily unavailable."]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"9. Account Termination"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"If Outliner determines, in its sole discretion, that you have violated these Terms or engaged in abusive behavior, we may immediately terminate or suspend your account without prior notice. In such cases:"}),e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground mt-4 space-y-2",children:[e.jsx("li",{children:"No refunds will be issued for any unused portion of your subscription"}),e.jsx("li",{children:"No discounts or credits will be provided"}),e.jsx("li",{children:"Access to your account and content may be immediately revoked"}),e.jsx("li",{children:"Outliner is not required to provide an explanation for the termination"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"10. Third-Party API Data Disclaimer"}),e.jsxs("p",{className:"text-muted-foreground leading-relaxed",children:["The Service integrates with third-party APIs (including Anthropic and ElevenLabs) to provide AI-powered features. While we implement reasonable measures to protect your data, ",e.jsx("strong",{className:"text-foreground",children:"we cannot guarantee that these third-party API providers will not use, store, or process your data"})," according to their own terms and policies. By using features powered by these APIs, you acknowledge and accept this risk. We encourage you to review the privacy policies and terms of service of these third-party providers."]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"11. Limitation of Liability"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"To the maximum extent permitted by law, Outliner LLC shall not be liable for any indirect, incidental, special, consequential, or punitive damages, or any loss of profits or revenues, whether incurred directly or indirectly, or any loss of data, use, goodwill, or other intangible losses resulting from your use of the Service."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"12. Changes to Terms"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"Outliner reserves the right to modify these Terms at any time. We will notify users of material changes by posting the updated Terms on the Service. Your continued use of the Service after such changes constitutes acceptance of the new Terms."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"13. Contact Information"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"If you have any questions about these Terms, please contact us at [email protected]."})]})]})]}),e.jsx("footer",{className:"py-12 border-t border-border",children:e.jsx("div",{className:"container mx-auto px-4 md:px-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-6",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-serif text-lg",children:"outliner"})}),e.jsxs("nav",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:[e.jsx(ht,{href:"/terms",className:"hover:text-foreground transition-colors","data-testid":"link-footer-terms",children:"Terms of Service"}),e.jsx(ht,{href:"/privacy",className:"hover:text-foreground transition-colors","data-testid":"link-footer-privacy",children:"Privacy Policy"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:e.jsxs("span",{children:["outliner 2025 - ",new Date().getFullYear()," All Rights Reserved"]})})]})})})]})}function rB(){return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"sticky top-0 z-50 w-full border-b border-border/50 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:e.jsxs("div",{className:"container mx-auto flex h-16 items-center justify-between gap-4 px-4 md:px-6",children:[e.jsx(ht,{href:"/",children:e.jsx("span",{className:"font-serif text-[26px] font-medium tracking-tight cursor-pointer","data-testid":"link-logo",children:"outliner"})}),e.jsx(ht,{href:"/",children:e.jsxs(D,{variant:"ghost",size:"sm","data-testid":"button-back-home",children:[e.jsx(kn,{className:"mr-2 h-4 w-4"}),"Back to Home"]})})]})}),e.jsxs("main",{className:"container mx-auto px-4 md:px-6 py-16 max-w-4xl",children:[e.jsx("h1",{className:"font-serif text-4xl md:text-5xl font-normal tracking-tight mb-8",children:"Privacy Policy"}),e.jsx("p",{className:"text-muted-foreground mb-8",children:"Last updated: January 2026"}),e.jsxs("div",{className:"prose prose-invert max-w-none space-y-8",children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"1. Introduction"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:'Outliner LLC ("we," "our," or "us") is committed to protecting your privacy. This Privacy Policy explains how we 
206collect, use, disclose, and safeguard your information when you use our Service. By using Outliner, you consent to the data practices described in this policy.'}),e.jsxs("p",{className:"text-muted-foreground leading-relaxed mt-4",children:[e.jsx("strong",{className:"text-foreground",children:"Data Controller:"})," Outliner LLC, a Missouri Limited Liability Company, is the data controller responsible for your personal data. For users in the European Economic Area (EEA), United Kingdom, or Switzerland, this policy also describes your rights under the General Data Protection Regulation (GDPR) and similar laws."]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"2. Information We Collect"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"We collect information you provide directly to us, including:"}),e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground mt-4 space-y-2",children:[e.jsx("li",{children:"Account information (name, email address, company name)"}),e.jsx("li",{children:"Content you create (SOPs, procedures, documentation)"}),e.jsx("li",{children:"Communications with our team"}),e.jsx("li",{children:"Billing and payment information"})]}),e.jsx("p",{className:"text-muted-foreground leading-relaxed mt-4",children:"We also automatically collect certain information when you use the Service, including usage data, device information, and interaction patterns."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"3. Legal Basis for Processing (EEA/UK Users)"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"If you are located in the European Economic Area (EEA), United Kingdom, or Switzerland, we process your personal data based on the following legal grounds:"}),e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground mt-4 space-y-2",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Contract Performance:"})," Processing necessary to provide you with our Service and fulfill our contractual obligations (e.g., account management, content hosting, customer support)."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Legitimate Interests:"})," Processing necessary for our legitimate business interests, such as improving our Service, preventing fraud, and ensuring security, where these interests are not overridden by your rights."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Consent:"})," Processing based on your explicit consent, such as for analytics cookies and marketing communications. You may withdraw consent at any time."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Legal Obligation:"})," Processing necessary to comply with applicable laws and regulations."]})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"4. Third-Party Services and Analytics"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"We use the following third-party services to operate and improve our Service. Each of these services may collect data according to their own privacy policies:"}),e.jsxs("div",{className:"mt-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium mb-2",children:"Analytics Services"}),e.jsx("ul",{className:"list-disc list-inside text-muted-foreground space-y-2",children:e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Google Analytics:"})," We use Google Analytics to understand how users interact with our Service. Google Analytics collects information such as how often users visit the site, what pages they visit, and what other sites they used prior to coming to our site. For users outside the United States, analytics cookies are only activated after you provide consent."]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium mb-2",children:"AI and Processing Services"}),e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground space-y-2",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Anthropic API:"})," We use Anthropic's Claude API to provide AI-powered features such as content generation and writing assistance. Content you submit for AI processing may be sent to Anthropic's servers."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"ElevenLabs API:"})," We use ElevenLabs for text-to-speech and voice-related features. Audio content and text submitted for processing may be sent to ElevenLabs' servers."]})]})]})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"5. International Data Transfers"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"Outliner is based in the United States. If you are accessing our Service from outside the United States, including from the European Economic Area (EEA), United Kingdom, or Switzerland, please be aware that your information may be transferred to, stored, and processed in the United States."}),e.jsx("p",{className:"text-muted-foreground leading-relaxed mt-4",children:"When we transfer personal data from the EEA, UK, or Switzerland to the United States, we rely on:"}),e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground mt-4 space-y-2",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Standard Contractual Clauses (SCCs):"})," We use European Commission-approved Standard Contractual Clauses to ensure adequate protection for personal data transferred to third-party service providers."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Adequacy Decisions:"})," Where applicable, we rely on adequacy decisions by the European Commission recognizing certain countries as providing adequate data protection."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Your Consent:"})," In some cases, we may transfer data based on your explicit consent."]})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"6. Billing Information Protection"}),e.jsxs("p",{className:"text-muted-foreground leading-relaxed",children:[e.jsx("strong",{className:"text-foreground",children:"Your billing information is protected."})," We do not share your payment card details, billing address, or other financial information with the third-party analytics, advertising, or AI services listed above. Your billing information is processed securely through our payment processor and is used solely for processing your subscription payments."]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"7. How We Use Your Information"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"We use the information we collect to:"}),e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground mt-4 space-y-2",children:[e.jsx("li",{children:"Provide, maintain, and improve the Service"}),e.jsx("li",{children:"Process transactions and send related information"}),e.jsx("li",{children:"Send technical notices, updates, and support messages"}),e.jsx("li",{children:"Respond to your comments, questions, and customer service requests"}),e.jsx("li",{children:"Monitor and analyze trends, usage, and activities"}),e.jsx("li",{children:"Detect, investigate, and prevent fraudulent transactions and abuse"}),e.jsx("li",{children:"Personalize and improve your experience"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"8. Data Sharing and Disclosure"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"We may share your information in the following circumstances:"}),e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground mt-4 space-y-2",children:[e.jsx("li",{children:"With service providers who assist in operating our Service"}),e.jsx("li",{children:"To comply with legal obligations or respond to lawful requests"}),e.jsx("li",{children:"To protect our rights, privacy, safety, or property"}),e.jsx("li",{children:"In connection with a merger, acquisition, or sale of assets"}),e.jsx("li",{children:"With your consent or at your direction"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"9. Data Security"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"We implement appropriate technical and organizational measures to protect your information, including encryption, access controls, and secure data storage. However, no method of transmission over the Internet or electronic storage is 100% secure, and we cannot guarantee absolute security."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"10. Data Retention"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"We retain your information for as long as your account is active or as needed to provide the Service. We may al
206so retain certain information as required by law or for legitimate business purposes. When we no longer need to retain your personal data, we will securely delete or anonymize it."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"11. Your Rights"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"Depending on your location, you may have certain rights regarding your personal information. To exercise any of these rights, please contact us at [email protected]."}),e.jsxs("div",{className:"mt-6 p-4 bg-muted/30 rounded-lg border border-border",children:[e.jsx("h3",{className:"text-lg font-medium mb-3",children:"Rights for EEA, UK, and Swiss Users (GDPR)"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed mb-4",children:"If you are located in the European Economic Area, United Kingdom, or Switzerland, you have the following rights under the GDPR:"}),e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground space-y-2",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Right of Access:"})," You have the right to request a copy of the personal data we hold about you."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Right to Rectification:"})," You have the right to request that we correct any inaccurate or incomplete personal data."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Right to Erasure:"}),' You have the right to request that we delete your personal data in certain circumstances (also known as the "right to be forgotten").']}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Right to Restrict Processing:"})," You have the right to request that we limit the processing of your personal data in certain circumstances."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Right to Data Portability:"})," You have the right to receive your personal data in a structured, commonly used, and machine-readable format and to transmit it to another controller."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Right to Object:"})," You have the right to object to processing of your personal data based on legitimate interests or for direct marketing purposes."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Right to Withdraw Consent:"})," Where we process your data based on consent, you have the right to withdraw that consent at any time without affecting the lawfulness of processing based on consent before its withdrawal."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Right to Lodge a Complaint:"})," You have the right to lodge a complaint with a supervisory authority in your country of residence if you believe we have violated your data protection rights."]})]})]}),e.jsx("p",{className:"text-muted-foreground leading-relaxed mt-4",children:"We will respond to your request within 30 days. In some cases, we may need to verify your identity before processing your request or may need additional time to fulfill complex requests."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"12. Cookies and Tracking Technologies"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"We use cookies and similar tracking technologies to collect information about your browsing activities."}),e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground mt-4 space-y-2",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Essential Cookies:"})," These cookies are necessary for the Service to function and cannot be switched off. They are usually set in response to actions you take, such as logging in or filling out forms."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"Analytics Cookies:"})," These cookies help us understand how visitors interact with our Service. For users outside the United States, we only set analytics cookies after you provide consent through our cookie banner."]}
206)]}),e.jsx("p",{className:"text-muted-foreground leading-relaxed mt-4",children:"You can manage your cookie preferences through our cookie consent banner (for users outside the US) or through your browser settings. Disabling certain cookies may affect your ability to use some features of the Service."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"13. Children's Privacy"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"The Service is not intended for individuals under the age of 18 (or 16 in some jurisdictions). We do not knowingly collect personal information from children. If we learn that we have collected personal information from a child, we will take steps to delete that information promptly."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"14. Changes to This Policy"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:'We may update this Privacy Policy from time to time. We will notify you of any material changes by posting the new Privacy Policy on this page and updating the "Last updated" date. For significant changes, we may also notify you by email.'})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-2xl font-medium mb-4",children:"15. Contact Us"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"If you have any questions about this Privacy Policy or wish to exercise your data protection rights, please contact us at:"}),e.jsxs("p",{className:"text-muted-foreground leading-relaxed mt-4",children:[e.jsx("strong",{className:"text-foreground",children:"Email:"})," [email protected]"]}),e.jsxs("p",{className:"text-muted-foreground leading-relaxed mt-2",children:[e.jsx("strong",{className:"text-foreground",children:"Outliner LLC"}),e.jsx("br",{}),"Missouri, United States"]})]})]})]}),e.jsx("footer",{className:"py-12 border-t border-border",children:e.jsx("div",{className:"container mx-auto px-4 md:px-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-6",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-serif text-lg",children:"outliner"})}),e.jsxs("nav",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:[e.jsx(ht,{href:"/terms",className:"hover:text-foreground transition-colors","data-testid":"link-footer-terms",children:"Terms of Service"}),e.jsx(ht,{href:"/privacy",className:"hover:text-foreground transition-colors","data-testid":"link-footer-privacy",children:"Privacy Policy"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:e.jsxs("span",{children:["outliner 2025 - ",new Date().getFullYear()," All Rights Reserved"]})})]})})})]})}function aB(){const t=m.useRef(null);return m.useEffect(()=>{document.title="Done-For-You Knowledge Base Service | Book a Discovery Call | Outliner";const s=document.querySelector('meta[name="description"]');s&&s.setAttribute("content","Let our experts extract knowledge from your team and create professional SOPs and documentation. Book a free discovery call to learn how our Done-For-You service works.");const n=document.createElement("script");return n.src="https://static.hsappstatic.net/MeetingsEmbed/ex/MeetingsEmbedCode.js",n.async=!0,document.body.appendChild(n),()=>{document.body.removeChild(n)}},[]),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b border-border/50",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 py-4 flex items-center justify-between",children:[e.jsx(ht,{href:"/",children:e.jsx("span",{className:"font-serif text-2xl cursor-pointer","data-testid":"link-discovery-logo",children:"outliner"})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ra,{}),e.jsx(ht,{href:"/get-started",children:e.jsx(D,{variant:"outline",size:"sm","data-testid":"button-discovery-get-started",children:"Get Started"})})]})]})}),e.jsxs("main",{children:[e.jsx("section",{className:"py-16 md:py-24",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 text-center",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-primary/10 text-primary text-sm font-medium mb-6",children:[e.jsx(gs,{className:"w-4 h-4"}),"Done-For-You Service"]}),e.jsx("h1",{className:"text-4xl md:text-5xl font-bold tracking-tight mb-6","data-testid":"text-discovery-heading",children:"We Build Your Knowledge Base For You"}),e.jsx("p",{className:"text-lg md:text-xl text-muted-foreground max-w-2xl mx-auto mb-8",children:"Put an end to tribal knowledge. Our team of experts will extract knowledge from your team, create professional SOPs, and deliver a complete knowledge base, hosted anywhere you choose."}),e.jsx(D,{size:"lg",className:"font-mono uppercase tracking-wider",style:{backgroundColor:"#B24884",color:"#FFFFF9"},onClick:()=>t.current?.scrollIntoView({behavior:"smooth"}),"data-testid":"button-discovery-book-call",children:"Book a Free Discovery Call"})]})}),e.jsx("section",{className:"py-16 bg-muted/30",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4",children:[e.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-center mb-12","data-testid":"text-how-it-works",children:"How It Works"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsx(ee,{className:"text-center",children:e.jsxs(te,{className:"pt-8 pb-6 px-6 space-y-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto",children:e.jsx(Bs,{className:"w-6 h-6 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold",children:"1. Knowledge Extraction"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"We interview your experts and document the processes your team already knows but hasn't documented."})]})}),e.jsx(ee,{className:"text-center",children:e.jsxs(te,{className:"pt-8 pb-6 px-6 space-y-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto",children:e.jsx(Pt,{className:"w-6 h-6 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold",children:"2. Professional SOP Creation"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"We turn raw knowledge into clear SOPs with step-by-step instructions and visuals your team can follow."})]})}),e.jsx(ee,{className:"text-center",children:e.jsxs(te,{className:"pt-8 pb-6 px-6 space-y-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto",children:e.jsx(cs,{className:"w-6 h-6 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold",children:"3. Delivery & Maintenance"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your knowledge base is delivered ready to use. Host it anywhere you like. The content is yours."})]})})]})]})}),e.jsx("section",{className:"py-16",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4",children:[e.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-center mb-12","data-testid":"text-whats-included",children:"What's Included"}),e.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:["Dedicated project manager for your account","Expert interviews with your team members","Professional SOP writing and formatting","Completed with visual documentation","Unlimited revisions during the engagement","Priority support and onboarding","It's your content, host it with us or anywhere else","Ongoing maintenance and updates available"].map((s,n)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Sr,{className:"w-5 h-5 text-primary flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-muted-foreground",children:s})]},n))})]})}),e.jsx("section",{className:"py-16 bg-muted/30",ref:t,children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("h2",{className:"text-2xl md:text-3xl font-bold mb-4","data-testid":"text-book-call",children:"Book Your Free Discovery Call"}),e.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:"Every organization is different. Schedule a call to discu
206ss your needs, and we'll create a custom plan tailored to your team."})]}),e.jsx("div",{className:"meetings-iframe-container rounded-lg overflow-hidden","data-src":"https://meetings-na2.hubspot.com/ben-surman/discovery?embed=true","data-testid":"hubspot-meeting-embed"})]})})]}),e.jsx("footer",{className:"border-t border-border/50 py-8",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 flex flex-col sm:flex-row items-center justify-between gap-4",children:[e.jsx(ht,{href:"/",children:e.jsx("span",{className:"font-serif text-lg cursor-pointer",children:"outliner"})}),e.jsxs("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:[e.jsx(ht,{href:"/terms",children:e.jsx("span",{className:"hover:text-foreground cursor-pointer","data-testid":"link-discovery-terms",children:"Terms"})}),e.jsx(ht,{href:"/privacy",children:e.jsx("span",{className:"hover:text-foreground cursor-pointer","data-testid":"link-discovery-privacy",children:"Privacy"})})]})]})})]})}const a2="outliner-cookie-consent",gb="outliner-geo-cache";function i2(){try{const t=localStorage.getItem(a2);if(t)return JSON.parse(t)}catch{}return null}function o2(t,s){try{const n={status:t,timestamp:Date.now(),isEU:s};localStorage.setItem(a2,JSON.stringify(n))}catch{}}async function iB(){try{const t=localStorage.getItem(gb);if(t){const s=JSON.parse(t),n=1440*60*1e3;if(Date.now()-s.timestamp<n)return s.isUS}}catch{}try{const t=await fetch("https://ipapi.co/json/",{signal:AbortSignal.timeout(3e3)});if(!t.ok)return null;const n=(await t.json()).country_code==="US";try{localStorage.setItem(gb,JSON.stringify({isUS:n,timestamp:Date.now()}))}catch{}return n}catch{return null}}function l2(){if(document.getElementById("ga-script"))return;const t="G-C0EE9K35SS",s=document.createElement("script");s.id="ga-script",s.async=!0,s.src=`https://www.googletagmanager.com/gtag/js?id=${t}`,document.head.appendChild(s);const n=document.createElement("script");n.id="ga-inline",n.textContent=`
207    window.dataLayer = window.dataLayer || [];
208    function gtag(){dataLayer.push(arguments);}
209    gtag('js', new Date());
210    gtag('config', '${t}');
211  `,document.head.appendChild(n)}function oB(){const t=i2();t&&(!t.isEU||t.status==="accepted")&&l2()}function xb(t){o2("accepted",t),l2()}function lB(t){o2("rejected",t)}function cB(){const[t,s]=m.useState(!1),[n,a]=m.useState(!1);m.useEffect(()=>{async function d(){const u=i2();if(u&&u.status!=="pending"){oB();return}if(await iB()===!0){xb(!1);return}a(!0),s(!0)}d()},[]);const o=()=>{xb(n),s(!1)},l=()=>{lB(n),s(!1)};return t?e.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-[100] p-4 bg-background/95 backdrop-blur-sm border-t border-border shadow-lg","data-testid":"cookie-consent-banner",children:e.jsx("div",{className:"container mx-auto max-w-4xl",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[e.jsx(aE,{className:"h-5 w-5 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-foreground",children:"We use cookies to analyze site traffic and improve your experience."}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:['By clicking "Accept", you consent to our use of cookies for analytics purposes.'," ",e.jsx(ht,{href:"/privacy",className:"underline hover:text-foreground transition-colors","data-testid":"link-cookie-privacy",children:"Learn more"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(D,{variant:"outline",size:"sm",onClick:l,"data-testid":"button-reject-cookies",children:"Reject"}),e.jsx(D,{size:"sm",onClick:o,"data-testid":"button-accept-cookies",children:"Accept"}),e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:l,"data-testid":"button-close-cookie-banner",children:[e.jsx(Zn,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]})})}):null}function dB(){return e.jsxs(PT,{children:[e.jsx(ps,{path:"/",component:XA}),e.jsx(ps,{path:"/demo",component:sB}),e.jsx(ps,{path:"/terms",component:nB}),e.jsx(ps,{path:"/privacy",component:rB}),e.jsx(ps,{path:"/discovery",component:aB}),e.jsx(ps,{path:"/admin",component:Ru}),e.jsx(ps,{path:"/admin/:view",component:Ru}),e.jsx(ps,{path:"/admin/:view/:clientSlug",component:Ru}),e.jsx(ps,{path:"/admin/:view/:clientSlug/:tab",component:Ru}),e.jsx(ps,{path:"/portal/login",component:Wz}),e.jsx(ps,{path:"/portal/verify",component:Qz}),e.jsx(ps,{path:"/portal/procedures/:procedureId",component:Au}),e.jsx(ps,{path:"/portal/overviews/:procedureId",component:Au}),e.jsx(ps,{path:"/portal/:section",component:Au}),e.jsx(ps,{path:"/portal",component:Au}),e.jsx(ps,{path:"/verify-password",component:Hz}),e.jsx(ps,{path:"/get-started",component:eB}),e.jsx(ps,{path:"/checkout/success",component:tB}),e.jsx(ps,{path:"/kb/:slug/:categoryId/:procedureId",component:Io}),e.jsx(ps,{path:"/kb/:slug/:categoryId",component:Io}),e.jsx(ps,{path:"/kb/:slug",component:Io}),e.jsx(ps,{path:"/:companySlug/:kbSlug/:categorySlug/:procedureSlug",component:Io}),e.jsx(ps,{path:"/:companySlug/:kbSlug/:categorySlug",component:Io}),e.jsx(ps,{path:"/:companySlug/:kbSlug",component:Io}),e.jsx(ps,{path:"/:companySlug",component:_I}),e.jsx(ps,{component:RR})]})}function uB(){return e.jsx(PR,{defaultTheme:"light",storageKey:"outliner-ui-theme",children:e.jsx(WT,{client:de,children:e.jsx(TR,{children:e.jsx(ER,{children:e.jsxs(c0,{children:[e.jsx(JE,{}),e.jsx(dB,{}),e.jsx(cB,{})]})})})})})}sT.createRoot(document.getElementById("root")).render(e.jsx(uB,{}));

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.