bloby-bot 0.60.1 → 0.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,10 +17,10 @@ Error generating stack: `+e.message+`
17
17
  `),()=>{s.current?.removeAttribute(`data-motion-pop-id`),v.contains(_)&&v.removeChild(_)}},[t]),(0,G.jsx)(ul,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:v.cloneElement(e,{ref:u})})}var fl=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=Ie(pl),d=(0,v.useId)(),f=!0,p=(0,v.useMemo)(()=>(f=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>u.delete(e))}),[n,u,r]);return a&&f&&(p={...p}),(0,v.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),v.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,G.jsx)(dl,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,G.jsx)(Re.Provider,{value:p,children:e})};function pl(){return new Map}function ml(e=!0){let t=(0,v.useContext)(Re);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,v.useId)();(0,v.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,v.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var hl=e=>e.key||``;function gl(e){let t=[];return v.Children.forEach(e,e=>{(0,v.isValidElement)(e)&&t.push(e)}),t}var _l=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=ml(o),f=(0,v.useMemo)(()=>gl(e),[e]),p=o&&!u?[]:f.map(hl),m=(0,v.useRef)(!0),h=(0,v.useRef)(f),g=Ie(()=>new Map),_=(0,v.useRef)(new Set),[y,b]=(0,v.useState)(f),[x,S]=(0,v.useState)(f);Le(()=>{m.current=!1,h.current=f;for(let e=0;e<x.length;e++){let t=hl(x[e]);p.includes(t)?(g.delete(t),_.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[x,p.length,p.join(`-`)]);let C=[];if(f!==y){let e=[...f];for(let t=0;t<x.length;t++){let n=x[t],r=hl(n);p.includes(r)||(e.splice(t,0,n),C.push(n))}return a===`wait`&&C.length&&(e=C),S(gl(e)),b(f),null}let{forceRender:ee}=(0,v.useContext)(Fe);return(0,G.jsx)(G.Fragment,{children:x.map(e=>{let v=hl(e),y=o&&!u?!1:f===x||p.includes(v);return(0,G.jsx)(fl,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(_.current.has(v))return;if(g.has(v))_.current.add(v),g.set(v,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(ee?.(),S(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},v)})})},vl=(0,v.createContext)({strict:!1}),yl={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},bl=!1;function xl(){if(bl)return;let e={};for(let t in yl)e[t]={isEnabled:e=>yl[t].some(t=>!!e[t])};wo(e),bl=!0}function Sl(){return xl(),To()}function Cl(e){let t=Sl();for(let n in e)t[n]={...t[n],...e[n]};wo(t)}var wl=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function Tl(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||wl.has(e)}var El=i({default:()=>Dl}),Dl,Ol=e((()=>{throw Dl={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),kl=e=>!Tl(e);function Al(e){typeof e==`function`&&(kl=t=>t.startsWith(`on`)?!Tl(t):e(t))}try{Al((Ol(),o(El)).default)}catch{}function jl(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||Gi(e[i])||(kl(i)||n===!0&&Tl(i)||!t&&!Tl(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var Ml=(0,v.createContext)({});function Nl(e,t){if(ho(e)){let{initial:t,animate:n}=e;return{initial:t===!1||fo(t)?t:void 0,animate:fo(n)?n:void 0}}return e.inherit===!1?{}:t}function Pl(e){let{initial:t,animate:n}=Nl(e,(0,v.useContext)(Ml));return(0,v.useMemo)(()=>({initial:t,animate:n}),[Fl(t),Fl(n)])}function Fl(e){return Array.isArray(e)?e.join(` `):e}var Il=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ll(e,t,n){for(let r in t)!Gi(t[r])&&!as(r,n)&&(e[r]=t[r])}function Rl({transformTemplate:e},t){return(0,v.useMemo)(()=>{let n=Il();return $o(n,t,e),Object.assign({},n.vars,n.style)},[t])}function K(e,t){let n=e.style||{},r={};return Ll(r,n,e),Object.assign(r,Rl(e,t)),r}function q(e,t){let n={},r=K(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var J=()=>({...Il(),attrs:{}});function Y(e,t,n,r){let i=(0,v.useMemo)(()=>{let n=J();return ps(n,t,hs(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Ll(t,e.style,e),i.style={...t,...i.style}}return i}var X=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function zl(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(X.indexOf(e)>-1||/[A-Z]/u.test(e))}function Bl(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??zl(e)?Y:q)(t,r,i,e),c=jl(t,typeof e==`string`,a),l=e===v.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,v.useMemo)(()=>Gi(u)?u.get():u,[u]);return(0,v.createElement)(e,{...l,children:d})}function Vl({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Hl(n,r,i,e),renderState:t()}}function Hl(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=Sc(a[e]);let{initial:o,animate:s}=e,c=ho(e),l=go(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!U(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=R(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var Ul=e=>(t,n)=>{let r=(0,v.useContext)(Ml),i=(0,v.useContext)(Re),a=()=>Vl(e,t,r,i);return n?a():Ie(a)},Wl=Ul({scrapeMotionValuesFromProps:os,createRenderState:Il}),Gl=Ul({scrapeMotionValuesFromProps:_s,createRenderState:J}),Kl=Symbol.for(`motionComponentSymbol`);function ql(e,t,n){let r=(0,v.useRef)(n);(0,v.useInsertionEffect)(()=>{r.current=n});let i=(0,v.useRef)(null);return(0,v.useCallback)(n=>{n&&e.onMount?.(n);let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n);t&&(n?t.mount(n):t.unmount())},[t])}var Jl=(0,v.createContext)({});function Yl(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Xl(e,t,n,r,i,a){let{visualElement:o}=(0,v.useContext)(Ml),s=(0,v.useContext)(vl),c=(0,v.useContext)(Re),l=(0,v.useContext)(ol),u=l.reducedMotion,d=l.skipAnimations,f=(0,v.useRef)(null),p=(0,v.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,v.useContext)(Jl);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&Zl(f.current,n,i,h);let g=(0,v.useRef)(!1);(0,v.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[Yi],y=(0,v.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return Le(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),y.current&&m.animationState&&m.animationState.animateChanges())}),(0,v.useEffect)(()=>{m&&(!y.current&&m.animationState&&m.animationState.animateChanges(),y.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function Zl(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:Ql(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&Yl(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function Ql(e){if(e)return e.options.allowProjection===!1?Ql(e.parent):e.projection}function $l(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&Cl(r);let a=n?n===`svg`:zl(e),o=a?Gl:Wl;function s(n,s){let c,l={...(0,v.useContext)(ol),...n,layoutId:eu(n)},{isStatic:u}=l,d=Pl(n),f=o(n,u);if(!u&&typeof window<`u`){tu(l,r);let t=nu(l);c=t.MeasureLayout,d.visualElement=Xl(e,f,l,i,t.ProjectionNode,a)}return(0,G.jsxs)(Ml.Provider,{value:d,children:[c&&d.visualElement?(0,G.jsx)(c,{visualElement:d.visualElement,...l}):null,Bl(e,n,ql(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,v.forwardRef)(s);return c[Kl]=e,c}function eu({layoutId:e}){let t=(0,v.useContext)(Fe).id;return t&&e!==void 0?t+`-`+e:e}function tu(e,t){(0,v.useContext)(vl).strict}function nu(e){let{drag:t,layout:n}=Sl();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function ru(e,t){if(typeof Proxy>`u`)return $l;let n=new Map,r=(n,r)=>$l(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,$l(a,void 0,e,t)),n.get(a))})}var iu=(e,t)=>t.isSVG??zl(e)?new vs(t):new cs(t,{allowProjection:e!==v.Fragment}),au=class extends Oo{constructor(e){super(e),e.animationState||=Ts(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();U(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},ou=0,su={animation:{Feature:au},exit:{Feature:class extends Oo{constructor(){super(...arguments),this.id=ou++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`){let n=z(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function cu(e){return{point:{x:e.pageX,y:e.pageY}}}var lu=e=>t=>Na(t)&&e(t,cu(t));function uu(e,t,n,r){return vc(e,t,lu(n),r)}var du=({current:e})=>e?e.ownerDocument.defaultView:null,fu=(e,t)=>Math.abs(e-t);function pu(e,t){let n=fu(e.x,t.x),r=fu(e.y,t.y);return Math.sqrt(n**2+r**2)}var mu=new Set([`auto`,`scroll`]),hu=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=gu(this.lastRawMoveEventInfo,this.transformPagePoint));let e=vu(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=pu(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=N;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=gu(t,this.transformPagePoint),j.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=vu(e.type===`pointercancel`?this.lastMoveEventInfo:gu(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Na(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=gu(cu(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=N;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,vu(s,this.history)),this.removeListeners=Je(uu(this.contextWindow,`pointermove`,this.handlePointerMove),uu(this.contextWindow,`pointerup`,this.handlePointerUp),uu(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(mu.has(e.overflowX)||mu.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),j.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),M(this.updatePoint)}};function gu(e,t){return t?{point:t(e.point)}:e}function _u(e,t){return{x:e.x-t.x,y:e.y-t.y}}function vu({point:e},t){return{point:e,delta:_u(e,bu(t)),offset:_u(e,yu(t)),velocity:xu(t,.1)}}function yu(e){return e[0]}function bu(e){return e[e.length-1]}function xu(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=bu(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Ze(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Ze(t)*2&&(r=e[1]);let a=Qe(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Su(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?I(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?I(n,e,r.max):Math.min(e,n)),e}function Cu(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function wu(e,{top:t,left:n,bottom:r,right:i}){return{x:Cu(e.x,n,i),y:Cu(e.y,t,r)}}function Tu(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function Eu(e,t){return{x:Tu(e.x,t.x),y:Tu(e.y,t.y)}}function Du(e,t){let n=.5,r=Rs(e),i=Rs(t);return i>r?n=Ye(t.min,t.max-r,e.min):r>i&&(n=Ye(e.min,e.max-i,t.min)),Ve(0,1,n)}function Ou(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var ku=.35;function Au(e=ku){return e===!1?e=0:e===!0&&(e=ku),{x:ju(e,`left`,`right`),y:ju(e,`top`,`bottom`)}}function ju(e,t,n){return{min:Mu(e,t),max:Mu(e,n)}}function Mu(e,t){return typeof e==`number`?e:e[t]||0}var Nu=new WeakMap,Pu=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=V(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(cu(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Oa(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),oc(e=>{let t=this.getAxisMotionValue(e).get()||0;if($t.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=Rs(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&j.update(()=>i(e,t),!1,!0),qi(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=Ru(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&j.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new hu(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:du(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&j.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!Lu(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Su(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&Yl(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=wu(n.layoutBox,e):this.constraints=!1,this.elastic=Au(t),r!==this.constraints&&!Yl(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&oc(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=Ou(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Yl(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=Yo(n,r.root,this.visualElement.getTransformPagePoint()),a=Eu(r.layout.layoutBox,i);if(t){let e=t(Ao(a));this.hasMutatedConstraints=!!e,e&&(a=ko(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=oc(o=>{if(!Lu(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return qi(this.visualElement,e),n.start(Ni(e,n,0,t,this.visualElement,!1))}stopAnimation(){oc(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps();return n[t]||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){oc(t=>{let{drag:n}=this.getProps();if(!Lu(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-I(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Yl(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};oc(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Du({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),oc(t=>{if(!Lu(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(I(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Nu.set(this.visualElement,this);let e=this.visualElement.current,t=uu(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&La(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();Yl(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=Iu(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),j.read(r);let o=vc(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(oc(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=ku,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function Fu(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Iu(e,t,n){let r=ao(e,Fu(n)),i=ao(t,Fu(n));return()=>{r(),i()}}function Lu(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Ru(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var zu=class extends Oo{constructor(e){super(e),this.removeGroupControls=k,this.removeListeners=k,this.controls=new Pu(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||k}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},Bu=e=>(t,n)=>{e&&j.update(()=>e(t,n),!1,!0)},Vu=class extends Oo{constructor(){super(...arguments),this.removePointerDownListener=k}onPointerDown(e){this.session=new hu(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:du(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Bu(e),onStart:Bu(t),onMove:Bu(n),onEnd:(e,t)=>{delete this.session,r&&j.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=uu(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Hu=!1,Uu=class extends v.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),Hu&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),wc.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),Hu=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||j.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),wa.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Hu=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function Wu(e){let[t,n]=ml(),r=(0,v.useContext)(Fe);return(0,G.jsx)(Uu,{...e,layoutGroup:r,switchLayoutGroup:(0,v.useContext)(Jl),isPresent:t,safeToRemove:n})}var Z={pan:{Feature:Vu},drag:{Feature:zu,ProjectionNode:al,MeasureLayout:Wu}};function Gu(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&j.postRender(()=>i(t,cu(t)))}var Ku=class extends Oo{mount(){let{current:e}=this.node;e&&(this.unmount=ja(e,(e,t)=>(Gu(this.node,t,`Start`),e=>Gu(this.node,e,`End`))))}unmount(){}},qu=class extends Oo{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=Je(vc(this.node.current,`focus`,()=>this.onFocus()),vc(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Ju(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&j.postRender(()=>i(t,cu(t)))}var Yu=class extends Oo{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Wa(e,(e,t)=>(Ju(this.node,t,`Start`),(e,{success:t})=>Ju(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},Xu=new WeakMap,Zu=new WeakMap,Qu=e=>{let t=Xu.get(e.target);t&&t(e)},$u=e=>{e.forEach(Qu)};function ed({root:e,...t}){let n=e||document;Zu.has(n)||Zu.set(n,{});let r=Zu.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver($u,{root:e,...t})),r[i]}function td(e,t,n){let r=ed(t);return Xu.set(e,n),r.observe(e),()=>{Xu.delete(e),r.unobserve(e)}}var nd={some:0,all:1},rd=class extends Oo{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:nd[r]};this.stopObserver=td(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)})}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(id(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function id({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var ad={inView:{Feature:rd},tap:{Feature:Yu},focus:{Feature:qu},hover:{Feature:Ku}},od={layout:{ProjectionNode:al,MeasureLayout:Wu}},sd=ru({...su,...ad,...Z,...od},iu),cd=r();function ld(e){let t=e.match(/^100\.(\d+)\./);if(t&&+t[1]>=64&&+t[1]<=127)return`tailscale`;if(/^192\.168\./.test(e)||/^10\./.test(e))return`lan`;let n=e.match(/^172\.(\d+)\./);return n&&+n[1]>=16&&+n[1]<=31?`lan`:e===`localhost`||e===`127.0.0.1`?`localhost`:e.endsWith(`.trycloudflare.com`)?`tunnel`:e.endsWith(`.bloby.bot`)?`relay`:`custom-domain`}function ud(e){return e===`tailscale`||e===`lan`||e===`localhost`}var dd={tailscale:`Tailscale`,lan:`Local network`,localhost:`Localhost`,tunnel:`Cloudflare tunnel`,relay:`Relay`,"custom-domain":`Custom domain`},fd=30,pd=[{id:`bloby`,name:`Bloby`,subtitle:`Coming Soon..`,icon:`/morphy.png`,comingSoon:!0,iconHeight:30},{id:`anthropic`,name:`Claude`,subtitle:`By
18
18
  Anthropic`,icon:`/icons/claude.png`,comingSoon:!1,iconHeight:30},{id:`openai`,name:`Codex`,subtitle:`By
19
19
  OpenAI`,icon:`/codex.svg`,comingSoon:!1,iconHeight:34},{id:`pi`,name:`Pi`,subtitle:`Bring your
20
- own model`,icon:`/pi-logo.svg`,comingSoon:!1,iconHeight:33}],md={anthropic:[{id:`claude-opus-4-7[1m]`,label:`Opus 4.7 (1M context)`},{id:`claude-opus-4-7`,label:`Opus 4.7`},{id:`claude-sonnet-4-6`,label:`Sonnet 4.6 (1M context)`},{id:`claude-haiku-4-5`,label:`Haiku 4.5`}],openai:[{id:`gpt-5.5:high`,label:`GPT-5.5 High`},{id:`gpt-5.5:medium`,label:`GPT-5.5 Medium`},{id:`gpt-5.5:xhigh`,label:`GPT-5.5 Extra High`},{id:`gpt-5.4:medium`,label:`GPT-5.4 Medium`},{id:`gpt-5.4:high`,label:`GPT-5.4 High`},{id:`gpt-5.4:xhigh`,label:`GPT-5.4 Extra High`},{id:`gpt-5.4-mini:medium`,label:`GPT-5.4-Mini Medium`},{id:`gpt-5.4-mini:high`,label:`GPT-5.4-Mini High`},{id:`gpt-5.4-mini:xhigh`,label:`GPT-5.4-Mini Extra High`}]};function hd({models:e,value:t,onChange:n,placeholder:r=`Choose a model...`,menuMaxHeight:i=`max-h-[320px]`}){let[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),l=(0,v.useRef)(null),u=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!a)return;let e=()=>{let e=l.current?.getBoundingClientRect();e&&c({top:e.bottom+4,left:e.left,width:e.width})};e();let t=e=>{let t=e.target;l.current?.contains(t)||u.current?.contains(t)||o(!1)};return document.addEventListener(`mousedown`,t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{document.removeEventListener(`mousedown`,t),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[a]);let d=e.find(e=>e.id===t);return(0,G.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,G.jsxs)(`button`,{ref:l,type:`button`,onClick:()=>o(e=>!e),className:`w-full flex items-center justify-between gap-2 bg-white/[0.03] border border-white/[0.08] text-white rounded-xl px-4 py-2.5 text-[13px] outline-none hover:border-white/15 focus:border-[#0069FE]/30 transition-colors overflow-hidden`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate text-left ${d?`text-white`:`text-white/20`}`,children:d?d.label:r}),(0,G.jsx)(re,{className:`h-4 w-4 shrink-0 text-white/30 transition-transform ${a?`rotate-180`:``}`})]}),a&&s&&(0,cd.createPortal)((0,G.jsx)(`div`,{ref:u,style:{position:`fixed`,top:s.top,left:s.left,width:s.width,zIndex:1e3},className:`bg-[#222] border border-white/[0.08] rounded-xl shadow-xl py-1 ${i} overflow-y-auto`,children:e.map(e=>(0,G.jsx)(`button`,{onClick:()=>{n(e.id),o(!1)},className:`w-full text-left px-4 py-2 text-[13px] transition-colors ${t===e.id?`text-[#0069FE] bg-[#0069FE]/10`:`text-white/70 hover:bg-white/[0.04] hover:text-white`}`,children:e.label},e.id))}),document.body)]})}var gd=[{step:1,label:`Personal Info`},{step:2,label:`Agent Name & Access`},{step:3,label:`Security`},{step:4,label:`AI Provider`},{step:5,label:`Voice Messages`},{step:6,label:`Environment Variables`},{step:7,label:`Pulse & Crons`}];function _d({onJump:e}){let[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(null),a=(0,v.useRef)(null),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!t)return;let e=()=>{let e=a.current?.getBoundingClientRect();e&&i({top:e.bottom+6,right:window.innerWidth-e.right})};e();let r=e=>{let t=e.target;a.current?.contains(t)||o.current?.contains(t)||n(!1)};return document.addEventListener(`mousedown`,r),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{document.removeEventListener(`mousedown`,r),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[t]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{ref:a,type:`button`,onClick:()=>n(e=>!e),className:`flex items-center gap-1 text-white/50 hover:text-white/80 text-[12px] font-medium px-2.5 py-1 rounded-lg hover:bg-white/[0.05] transition-colors`,children:[`Go to`,(0,G.jsx)(re,{className:`h-3.5 w-3.5 transition-transform ${t?`rotate-180`:``}`})]}),t&&r&&(0,cd.createPortal)((0,G.jsx)(`div`,{ref:o,style:{position:`fixed`,top:r.top,right:r.right,zIndex:1e3},className:`bg-[#222] border border-white/[0.08] rounded-xl shadow-xl py-1 min-w-[200px] max-h-[188px] overflow-y-auto`,children:gd.map(t=>(0,G.jsx)(`button`,{onClick:()=>{e(t.step),n(!1)},className:`w-full text-left px-4 py-2 text-[13px] text-white/70 hover:bg-white/[0.04] hover:text-white transition-colors`,children:t.label},t.step))}),document.body)]})}var vd=/^[A-Za-z_][A-Za-z0-9_]*$/;function yd({cacheRef:e}){let t=(0,v.useRef)(e.current!=null).current,n=e.current,[r,i]=(0,v.useState)(n?.groups??[]),[a,o]=(0,v.useState)(!t),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(n?.values??{}),[d,f]=(0,v.useState)(n?.originals??{}),[p,m]=(0,v.useState)(new Set(n?.revealed??[])),[h,g]=(0,v.useState)(new Set(n?.removed??[])),[_,y]=(0,v.useState)(n?.newRows??[]),b=(0,v.useRef)(n?.newRowSeq??0),[x,S]=(0,v.useState)(!1),[C,ee]=(0,v.useState)(n?.saved??!1),[w,te]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(t)return;let e=!1;return Pe(`/api/env`).then(e=>e.ok?e.json():Promise.reject(Error(`Failed to load environment variables`))).then(t=>{if(e)return;let n=Array.isArray(t.groups)?t.groups:[],r={};for(let e of n)for(let t of e.vars)r[t.name]=t.value;i(n),u(r),f(r),o(!1)}).catch(t=>{e||(c(t.message||`Failed to load`),o(!1))}),()=>{e=!0}},[t]),(0,v.useEffect)(()=>{a||(e.current={groups:r,values:l,originals:d,revealed:Array.from(p),removed:Array.from(h),newRows:_,newRowSeq:b.current,saved:C})});let re=_.filter(e=>e.name.trim()&&e.value.trim()&&vd.test(e.name.trim())),ie=[...h].filter(e=>e in d),ae=Object.keys(l).filter(e=>l[e]!==d[e]&&!h.has(e)),oe=ae.length>0||re.length>0||ie.length>0,se=e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ce=e=>{ee(!1),g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Environment Variables`}),(0,G.jsxs)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:[`API keys and secrets stored in your workspace`,` `,(0,G.jsx)(`code`,{className:`text-white/55 font-mono text-[12px]`,children:`.env`}),`. Your agent reads and writes these as you build.`]}),a?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-12 text-white/40`,children:(0,G.jsx)(D,{className:`h-5 w-5 animate-spin`})}):s?(0,G.jsxs)(`div`,{className:`mt-5 flex items-center gap-2 text-[13px] text-red-400`,children:[(0,G.jsx)(Ce,{className:`h-4 w-4 shrink-0`}),s]}):(0,G.jsxs)(`div`,{className:`mt-5 space-y-5 max-h-[44vh] overflow-y-auto pr-1 -mr-1`,children:[r.length===0&&_.length===0&&(0,G.jsxs)(`div`,{className:`rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-7 text-center`,children:[(0,G.jsx)(fe,{className:`h-5 w-5 text-white/25 mx-auto mb-2`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px]`,children:`No environment variables yet.`}),(0,G.jsx)(`p`,{className:`text-white/25 text-[12px] mt-1`,children:`Ask your agent to add an integration, or add one manually below.`})]}),r.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,G.jsx)(fe,{className:`h-3.5 w-3.5 text-[#0069FE]/70`}),(0,G.jsx)(`span`,{className:`text-[12px] font-semibold text-white/70 uppercase tracking-wide`,children:e.title||`Other`})]}),(0,G.jsx)(`div`,{className:`space-y-2.5`,children:e.vars.map(e=>{let t=h.has(e.name),n=!t&&l[e.name]!==d[e.name],r=p.has(e.name);return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[11px] text-white/40 mb-1`,children:[(0,G.jsx)(`code`,{className:`font-mono ${t?`text-white/30 line-through`:`text-white/50`}`,children:e.name}),n&&(0,G.jsx)(`span`,{className:`text-[#0069FE] text-[10px] font-medium`,children:`• edited`}),t&&(0,G.jsx)(`span`,{className:`text-red-400/80 text-[10px] font-medium`,children:`• will be removed`})]}),t?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2.5 rounded-xl border border-red-500/20 bg-red-500/[0.04]`,children:[(0,G.jsx)(`span`,{className:`flex-1 text-[13px] text-white/30 font-mono`,children:`••••••••`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>ce(e.name),className:`text-[11px] text-white/50 hover:text-white/80 transition-colors`,children:`Undo`})]}):(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(`input`,{type:r?`text`:`password`,value:l[e.name]??``,onChange:t=>u(n=>({...n,[e.name]:t.target.value})),autoComplete:`off`,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":`true`,className:`w-full bg-white/[0.03] border border-white/[0.08] text-white rounded-xl pl-4 pr-10 py-2.5 text-[13px] font-mono outline-none focus:border-[#0069FE]/30 transition-colors`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>se(e.name),className:`absolute right-3 top-1/2 -translate-y-1/2 text-white/30 hover:text-white/60 transition-colors`,"aria-label":r?`Hide value`:`Reveal value`,children:r?(0,G.jsx)(le,{className:`h-4 w-4`}):(0,G.jsx)(ue,{className:`h-4 w-4`})})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>ce(e.name),className:`shrink-0 p-2 text-white/25 hover:text-red-400 hover:bg-red-500/[0.06] rounded-lg transition-colors`,title:`Remove variable`,"aria-label":`Remove variable`,children:(0,G.jsx)(Se,{className:`h-4 w-4`})})]})]},e.name)})})]},e.title||`__untitled`)),_.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,G.jsx)(ge,{className:`h-3.5 w-3.5 text-emerald-400/70`}),(0,G.jsx)(`span`,{className:`text-[12px] font-semibold text-white/70 uppercase tracking-wide`,children:`New`})]}),(0,G.jsx)(`div`,{className:`space-y-3`,children:_.map(e=>{let t=e.name.trim().length>0&&!vd.test(e.name.trim());return(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,G.jsx)(`input`,{type:`text`,value:e.name,onChange:t=>y(n=>n.map(n=>n.id===e.id?{...n,name:t.target.value}:n)),placeholder:`VARIABLE_NAME`,autoComplete:`off`,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":`true`,className:`w-full bg-white/[0.03] border ${t?`border-red-500/40`:`border-white/[0.08]`} text-white rounded-xl px-4 py-2.5 text-[13px] font-mono outline-none focus:border-[#0069FE]/30 transition-colors`}),(0,G.jsx)(`input`,{type:`text`,value:e.value,onChange:t=>y(n=>n.map(n=>n.id===e.id?{...n,value:t.target.value}:n)),placeholder:`value`,autoComplete:`off`,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":`true`,className:`w-full bg-white/[0.03] border border-white/[0.08] text-white rounded-xl px-4 py-2.5 text-[13px] font-mono outline-none focus:border-[#0069FE]/30 transition-colors`}),t&&(0,G.jsx)(`p`,{className:`text-red-400/80 text-[11px]`,children:`Use letters, numbers and underscores; can't start with a number.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>y(t=>t.filter(t=>t.id!==e.id)),className:`mt-2 text-white/25 hover:text-red-400/80 transition-colors`,"aria-label":`Remove`,children:(0,G.jsx)(Ee,{className:`h-4 w-4`})})]},e.id)})})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>y(e=>[...e,{id:b.current++,name:``,value:``}]),className:`flex items-center gap-1.5 text-[12px] text-white/50 hover:text-white/80 transition-colors`,children:[(0,G.jsx)(ge,{className:`h-3.5 w-3.5`}),` Add new`]})]}),oe&&!x&&(0,G.jsxs)(`div`,{className:`mt-4 flex items-start gap-2.5 bg-amber-500/[0.06] border border-amber-500/20 rounded-xl px-4 py-3`,children:[(0,G.jsx)(Ce,{className:`h-4 w-4 text-amber-400 mt-0.5 shrink-0`}),(0,G.jsx)(`p`,{className:`text-amber-300/80 text-[12px] leading-relaxed`,children:`Changes detected. Your workspace backend will be restarted when you save.`})]}),C&&!oe&&(0,G.jsxs)(`div`,{className:`mt-4 flex items-center gap-2.5 bg-emerald-500/[0.06] border border-emerald-500/20 rounded-xl px-4 py-3`,children:[(0,G.jsx)(ne,{className:`h-4 w-4 text-emerald-400 shrink-0`}),(0,G.jsx)(`p`,{className:`text-emerald-300/90 text-[12px]`,children:`Saved — your workspace backend is restarting.`})]}),w&&(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5 text-[12px] text-red-400`,children:[(0,G.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0`}),w]}),(0,G.jsx)(`button`,{onClick:async()=>{if(!oe||x)return;S(!0),te(``),ee(!1);let e={};for(let t of ae)e[t]=l[t];for(let t of re)e[t.name.trim()]=t.value.trim();let t=ie;try{let n=await Pe(`/api/env`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({vars:e,remove:t})});if(!n.ok){let e=await n.json().catch(()=>({error:`Save failed`}));throw Error(e.error||`Save failed`)}let r={...l};for(let e of re)r[e.name.trim()]=e.value.trim();for(let e of t)delete r[e];i(e=>{let t=e.map(e=>({...e,vars:e.vars.filter(e=>!h.has(e.name))})),n=new Set(t.flatMap(e=>e.vars.map(e=>e.name))),i=re.map(e=>e.name.trim()).filter(e=>!n.has(e));if(i.length){let e=t.find(e=>e.title===`Custom`);e||(e={title:`Custom`,vars:[]},t.push(e));for(let t of i)e.vars.push({name:t,value:r[t]})}return t.filter(e=>e.vars.length>0)}),u(r),f(r),y([]),g(new Set),ee(!0),S(!1)}catch(e){te(e.message||`Save failed`),S(!1)}},disabled:!oe||x,className:`w-full mt-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40 disabled:cursor-not-allowed`,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Saving...`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(_e,{className:`h-4 w-4`}),`Save & restart backend`]})})]})}var Q={enabled:!1,intervalMinutes:60,quietHours:{start:`22:00`,end:`07:00`}},bd=[{mins:10,label:`10m`},{mins:30,label:`30m`},{mins:60,label:`1h`},{mins:120,label:`2h`},{mins:180,label:`3h`},{mins:360,label:`6h`},{mins:720,label:`12h`},{mins:-1,label:`Custom`}],xd=bd.length-1,Sd=/^([01]\d|2[0-3]):[0-5]\d$/;function Cd(e){let t=bd.findIndex(t=>t.mins===e);return t===-1?xd:t}function wd(e){if(!Number.isFinite(e)||e<=0)return`Every —`;if(e%60==0){let t=e/60;return`Every ${t} hour${t===1?``:`s`}`}return e<60?`Every ${e} minute${e===1?``:`s`}`:`Every ${Math.floor(e/60)}h ${e%60}m`}function Td(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let n=new Date,r=t.getTime()-n.getTime(),i=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});if(r>0&&r<3600*1e3)return`in ${Math.max(1,Math.round(r/6e4))}m`;if(r>0&&r<360*60*1e3)return`in ${Math.round(r/36e5)}h`;let a=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),o=Math.round((a(t).getTime()-a(n).getTime())/864e5);return o===0?`Today ${i}`:o===1?`Tomorrow ${i}`:o>1&&o<7?`${t.toLocaleDateString([],{weekday:`long`})} ${i}`:`${t.toLocaleDateString([],{month:`short`,day:`numeric`})}, ${i}`}function Ed({pulse:e,original:t,setPulse:n,onPulseSaved:r}){let[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(Cd(e.intervalMinutes)===xd),f=Cd(e.intervalMinutes),p=u,m=u?xd:f,h=Sd.test(e.quietHours.start)&&Sd.test(e.quietHours.end),g=Number.isFinite(e.intervalMinutes)&&e.intervalMinutes>=1&&e.intervalMinutes<=1440,_=t!=null&&(e.enabled!==t.enabled||e.intervalMinutes!==t.intervalMinutes||e.quietHours.start!==t.quietHours.start||e.quietHours.end!==t.quietHours.end),y=_&&g&&h&&!i,b=t=>{o&&s(!1),c&&l(``),n({...e,...t})},x=t=>{t===xd?(d(!0),b({intervalMinutes:u||f===xd?e.intervalMinutes:45})):(d(!1),b({intervalMinutes:bd[t].mins}))},S=async()=>{if(y){a(!0),l(``),s(!1);try{let t=await Pe(`/api/pulse`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e.enabled,intervalMinutes:e.intervalMinutes,quietHours:e.quietHours})});if(!t.ok){let e=await t.json().catch(()=>({error:`Save failed`}));throw Error(e.error||`Save failed`)}r(e),s(!0),a(!1)}catch(e){l(e?.message||`Save failed`),a(!1)}}};return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-[#0069FE]/10 flex items-center justify-center shrink-0`,children:(0,G.jsx)(C,{className:`h-[18px] w-[18px] text-[#0069FE]`})}),(0,G.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,G.jsx)(`h2`,{className:`text-[15px] font-bold text-white tracking-tight`,children:`Pulse`})}),(0,G.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,"aria-label":`Enable pulse`,onClick:()=>b({enabled:!e.enabled}),className:`w-10 h-[22px] rounded-full transition-colors duration-200 flex items-center px-0.5 shrink-0 ${e.enabled?`bg-gradient-brand`:`bg-white/[0.08]`}`,children:(0,G.jsx)(`div`,{className:`w-[18px] h-[18px] rounded-full bg-white shadow-sm transition-transform duration-200 ${e.enabled?`translate-x-[18px]`:`translate-x-0`}`})})]}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-2 leading-relaxed`,children:`Pulse periodically wakes the agent inside the main session, letting it surface anything that needs attention without spamming you.`}),(0,G.jsxs)(`div`,{className:`mt-5 transition-opacity duration-200 ${e.enabled?``:`opacity-50 pointer-events-none select-none`}`,"aria-disabled":!e.enabled,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2.5`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-semibold text-white/70 uppercase tracking-wide`,children:`Frequency`}),(0,G.jsx)(`span`,{className:`text-[11px] font-medium text-[#0069FE] bg-[#0069FE]/10 rounded-full px-2.5 py-1`,children:p?`Custom interval`:wd(e.intervalMinutes)})]}),(0,G.jsx)(`input`,{type:`range`,min:0,max:xd,step:1,value:m,onChange:e=>x(Number(e.target.value)),"aria-label":`Pulse interval`,className:`w-full h-1.5 appearance-none rounded-full bg-white/[0.08] accent-[#0069FE] cursor-pointer
20
+ own model`,icon:`/pi-logo.svg`,comingSoon:!1,iconHeight:33}],md={anthropic:[{id:`claude-opus-4-8[1m]`,label:`Opus 4.8 (1M context)`},{id:`claude-opus-4-8`,label:`Opus 4.8`},{id:`claude-opus-4-7[1m]`,label:`Opus 4.7 (1M context)`},{id:`claude-opus-4-7`,label:`Opus 4.7`},{id:`claude-sonnet-4-6`,label:`Sonnet 4.6 (1M context)`},{id:`claude-haiku-4-5`,label:`Haiku 4.5`}],openai:[{id:`gpt-5.5:high`,label:`GPT-5.5 High`},{id:`gpt-5.5:medium`,label:`GPT-5.5 Medium`},{id:`gpt-5.5:xhigh`,label:`GPT-5.5 Extra High`},{id:`gpt-5.4:medium`,label:`GPT-5.4 Medium`},{id:`gpt-5.4:high`,label:`GPT-5.4 High`},{id:`gpt-5.4:xhigh`,label:`GPT-5.4 Extra High`},{id:`gpt-5.4-mini:medium`,label:`GPT-5.4-Mini Medium`},{id:`gpt-5.4-mini:high`,label:`GPT-5.4-Mini High`},{id:`gpt-5.4-mini:xhigh`,label:`GPT-5.4-Mini Extra High`}]};function hd({models:e,value:t,onChange:n,placeholder:r=`Choose a model...`,menuMaxHeight:i=`max-h-[320px]`}){let[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),l=(0,v.useRef)(null),u=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!a)return;let e=()=>{let e=l.current?.getBoundingClientRect();e&&c({top:e.bottom+4,left:e.left,width:e.width})};e();let t=e=>{let t=e.target;l.current?.contains(t)||u.current?.contains(t)||o(!1)};return document.addEventListener(`mousedown`,t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{document.removeEventListener(`mousedown`,t),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[a]);let d=e.find(e=>e.id===t);return(0,G.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,G.jsxs)(`button`,{ref:l,type:`button`,onClick:()=>o(e=>!e),className:`w-full flex items-center justify-between gap-2 bg-white/[0.03] border border-white/[0.08] text-white rounded-xl px-4 py-2.5 text-[13px] outline-none hover:border-white/15 focus:border-[#0069FE]/30 transition-colors overflow-hidden`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate text-left ${d?`text-white`:`text-white/20`}`,children:d?d.label:r}),(0,G.jsx)(re,{className:`h-4 w-4 shrink-0 text-white/30 transition-transform ${a?`rotate-180`:``}`})]}),a&&s&&(0,cd.createPortal)((0,G.jsx)(`div`,{ref:u,style:{position:`fixed`,top:s.top,left:s.left,width:s.width,zIndex:1e3},className:`bg-[#222] border border-white/[0.08] rounded-xl shadow-xl py-1 ${i} overflow-y-auto`,children:e.map(e=>(0,G.jsx)(`button`,{onClick:()=>{n(e.id),o(!1)},className:`w-full text-left px-4 py-2 text-[13px] transition-colors ${t===e.id?`text-[#0069FE] bg-[#0069FE]/10`:`text-white/70 hover:bg-white/[0.04] hover:text-white`}`,children:e.label},e.id))}),document.body)]})}var gd=[{step:1,label:`Personal Info`},{step:2,label:`Agent Name & Access`},{step:3,label:`Security`},{step:4,label:`AI Provider`},{step:5,label:`Voice Messages`},{step:6,label:`Environment Variables`},{step:7,label:`Pulse & Crons`}];function _d({onJump:e}){let[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(null),a=(0,v.useRef)(null),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!t)return;let e=()=>{let e=a.current?.getBoundingClientRect();e&&i({top:e.bottom+6,right:window.innerWidth-e.right})};e();let r=e=>{let t=e.target;a.current?.contains(t)||o.current?.contains(t)||n(!1)};return document.addEventListener(`mousedown`,r),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{document.removeEventListener(`mousedown`,r),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[t]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{ref:a,type:`button`,onClick:()=>n(e=>!e),className:`flex items-center gap-1 text-white/50 hover:text-white/80 text-[12px] font-medium px-2.5 py-1 rounded-lg hover:bg-white/[0.05] transition-colors`,children:[`Go to`,(0,G.jsx)(re,{className:`h-3.5 w-3.5 transition-transform ${t?`rotate-180`:``}`})]}),t&&r&&(0,cd.createPortal)((0,G.jsx)(`div`,{ref:o,style:{position:`fixed`,top:r.top,right:r.right,zIndex:1e3},className:`bg-[#222] border border-white/[0.08] rounded-xl shadow-xl py-1 min-w-[200px] max-h-[188px] overflow-y-auto`,children:gd.map(t=>(0,G.jsx)(`button`,{onClick:()=>{e(t.step),n(!1)},className:`w-full text-left px-4 py-2 text-[13px] text-white/70 hover:bg-white/[0.04] hover:text-white transition-colors`,children:t.label},t.step))}),document.body)]})}var vd=/^[A-Za-z_][A-Za-z0-9_]*$/;function yd({cacheRef:e}){let t=(0,v.useRef)(e.current!=null).current,n=e.current,[r,i]=(0,v.useState)(n?.groups??[]),[a,o]=(0,v.useState)(!t),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(n?.values??{}),[d,f]=(0,v.useState)(n?.originals??{}),[p,m]=(0,v.useState)(new Set(n?.revealed??[])),[h,g]=(0,v.useState)(new Set(n?.removed??[])),[_,y]=(0,v.useState)(n?.newRows??[]),b=(0,v.useRef)(n?.newRowSeq??0),[x,S]=(0,v.useState)(!1),[C,ee]=(0,v.useState)(n?.saved??!1),[w,te]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(t)return;let e=!1;return Pe(`/api/env`).then(e=>e.ok?e.json():Promise.reject(Error(`Failed to load environment variables`))).then(t=>{if(e)return;let n=Array.isArray(t.groups)?t.groups:[],r={};for(let e of n)for(let t of e.vars)r[t.name]=t.value;i(n),u(r),f(r),o(!1)}).catch(t=>{e||(c(t.message||`Failed to load`),o(!1))}),()=>{e=!0}},[t]),(0,v.useEffect)(()=>{a||(e.current={groups:r,values:l,originals:d,revealed:Array.from(p),removed:Array.from(h),newRows:_,newRowSeq:b.current,saved:C})});let re=_.filter(e=>e.name.trim()&&e.value.trim()&&vd.test(e.name.trim())),ie=[...h].filter(e=>e in d),ae=Object.keys(l).filter(e=>l[e]!==d[e]&&!h.has(e)),oe=ae.length>0||re.length>0||ie.length>0,se=e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ce=e=>{ee(!1),g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Environment Variables`}),(0,G.jsxs)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:[`API keys and secrets stored in your workspace`,` `,(0,G.jsx)(`code`,{className:`text-white/55 font-mono text-[12px]`,children:`.env`}),`. Your agent reads and writes these as you build.`]}),a?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-12 text-white/40`,children:(0,G.jsx)(D,{className:`h-5 w-5 animate-spin`})}):s?(0,G.jsxs)(`div`,{className:`mt-5 flex items-center gap-2 text-[13px] text-red-400`,children:[(0,G.jsx)(Ce,{className:`h-4 w-4 shrink-0`}),s]}):(0,G.jsxs)(`div`,{className:`mt-5 space-y-5 max-h-[44vh] overflow-y-auto pr-1 -mr-1`,children:[r.length===0&&_.length===0&&(0,G.jsxs)(`div`,{className:`rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-7 text-center`,children:[(0,G.jsx)(fe,{className:`h-5 w-5 text-white/25 mx-auto mb-2`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px]`,children:`No environment variables yet.`}),(0,G.jsx)(`p`,{className:`text-white/25 text-[12px] mt-1`,children:`Ask your agent to add an integration, or add one manually below.`})]}),r.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,G.jsx)(fe,{className:`h-3.5 w-3.5 text-[#0069FE]/70`}),(0,G.jsx)(`span`,{className:`text-[12px] font-semibold text-white/70 uppercase tracking-wide`,children:e.title||`Other`})]}),(0,G.jsx)(`div`,{className:`space-y-2.5`,children:e.vars.map(e=>{let t=h.has(e.name),n=!t&&l[e.name]!==d[e.name],r=p.has(e.name);return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[11px] text-white/40 mb-1`,children:[(0,G.jsx)(`code`,{className:`font-mono ${t?`text-white/30 line-through`:`text-white/50`}`,children:e.name}),n&&(0,G.jsx)(`span`,{className:`text-[#0069FE] text-[10px] font-medium`,children:`• edited`}),t&&(0,G.jsx)(`span`,{className:`text-red-400/80 text-[10px] font-medium`,children:`• will be removed`})]}),t?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2.5 rounded-xl border border-red-500/20 bg-red-500/[0.04]`,children:[(0,G.jsx)(`span`,{className:`flex-1 text-[13px] text-white/30 font-mono`,children:`••••••••`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>ce(e.name),className:`text-[11px] text-white/50 hover:text-white/80 transition-colors`,children:`Undo`})]}):(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(`input`,{type:r?`text`:`password`,value:l[e.name]??``,onChange:t=>u(n=>({...n,[e.name]:t.target.value})),autoComplete:`off`,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":`true`,className:`w-full bg-white/[0.03] border border-white/[0.08] text-white rounded-xl pl-4 pr-10 py-2.5 text-[13px] font-mono outline-none focus:border-[#0069FE]/30 transition-colors`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>se(e.name),className:`absolute right-3 top-1/2 -translate-y-1/2 text-white/30 hover:text-white/60 transition-colors`,"aria-label":r?`Hide value`:`Reveal value`,children:r?(0,G.jsx)(le,{className:`h-4 w-4`}):(0,G.jsx)(ue,{className:`h-4 w-4`})})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>ce(e.name),className:`shrink-0 p-2 text-white/25 hover:text-red-400 hover:bg-red-500/[0.06] rounded-lg transition-colors`,title:`Remove variable`,"aria-label":`Remove variable`,children:(0,G.jsx)(Se,{className:`h-4 w-4`})})]})]},e.name)})})]},e.title||`__untitled`)),_.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,G.jsx)(ge,{className:`h-3.5 w-3.5 text-emerald-400/70`}),(0,G.jsx)(`span`,{className:`text-[12px] font-semibold text-white/70 uppercase tracking-wide`,children:`New`})]}),(0,G.jsx)(`div`,{className:`space-y-3`,children:_.map(e=>{let t=e.name.trim().length>0&&!vd.test(e.name.trim());return(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,G.jsx)(`input`,{type:`text`,value:e.name,onChange:t=>y(n=>n.map(n=>n.id===e.id?{...n,name:t.target.value}:n)),placeholder:`VARIABLE_NAME`,autoComplete:`off`,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":`true`,className:`w-full bg-white/[0.03] border ${t?`border-red-500/40`:`border-white/[0.08]`} text-white rounded-xl px-4 py-2.5 text-[13px] font-mono outline-none focus:border-[#0069FE]/30 transition-colors`}),(0,G.jsx)(`input`,{type:`text`,value:e.value,onChange:t=>y(n=>n.map(n=>n.id===e.id?{...n,value:t.target.value}:n)),placeholder:`value`,autoComplete:`off`,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":`true`,className:`w-full bg-white/[0.03] border border-white/[0.08] text-white rounded-xl px-4 py-2.5 text-[13px] font-mono outline-none focus:border-[#0069FE]/30 transition-colors`}),t&&(0,G.jsx)(`p`,{className:`text-red-400/80 text-[11px]`,children:`Use letters, numbers and underscores; can't start with a number.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>y(t=>t.filter(t=>t.id!==e.id)),className:`mt-2 text-white/25 hover:text-red-400/80 transition-colors`,"aria-label":`Remove`,children:(0,G.jsx)(Ee,{className:`h-4 w-4`})})]},e.id)})})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>y(e=>[...e,{id:b.current++,name:``,value:``}]),className:`flex items-center gap-1.5 text-[12px] text-white/50 hover:text-white/80 transition-colors`,children:[(0,G.jsx)(ge,{className:`h-3.5 w-3.5`}),` Add new`]})]}),oe&&!x&&(0,G.jsxs)(`div`,{className:`mt-4 flex items-start gap-2.5 bg-amber-500/[0.06] border border-amber-500/20 rounded-xl px-4 py-3`,children:[(0,G.jsx)(Ce,{className:`h-4 w-4 text-amber-400 mt-0.5 shrink-0`}),(0,G.jsx)(`p`,{className:`text-amber-300/80 text-[12px] leading-relaxed`,children:`Changes detected. Your workspace backend will be restarted when you save.`})]}),C&&!oe&&(0,G.jsxs)(`div`,{className:`mt-4 flex items-center gap-2.5 bg-emerald-500/[0.06] border border-emerald-500/20 rounded-xl px-4 py-3`,children:[(0,G.jsx)(ne,{className:`h-4 w-4 text-emerald-400 shrink-0`}),(0,G.jsx)(`p`,{className:`text-emerald-300/90 text-[12px]`,children:`Saved — your workspace backend is restarting.`})]}),w&&(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5 text-[12px] text-red-400`,children:[(0,G.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0`}),w]}),(0,G.jsx)(`button`,{onClick:async()=>{if(!oe||x)return;S(!0),te(``),ee(!1);let e={};for(let t of ae)e[t]=l[t];for(let t of re)e[t.name.trim()]=t.value.trim();let t=ie;try{let n=await Pe(`/api/env`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({vars:e,remove:t})});if(!n.ok){let e=await n.json().catch(()=>({error:`Save failed`}));throw Error(e.error||`Save failed`)}let r={...l};for(let e of re)r[e.name.trim()]=e.value.trim();for(let e of t)delete r[e];i(e=>{let t=e.map(e=>({...e,vars:e.vars.filter(e=>!h.has(e.name))})),n=new Set(t.flatMap(e=>e.vars.map(e=>e.name))),i=re.map(e=>e.name.trim()).filter(e=>!n.has(e));if(i.length){let e=t.find(e=>e.title===`Custom`);e||(e={title:`Custom`,vars:[]},t.push(e));for(let t of i)e.vars.push({name:t,value:r[t]})}return t.filter(e=>e.vars.length>0)}),u(r),f(r),y([]),g(new Set),ee(!0),S(!1)}catch(e){te(e.message||`Save failed`),S(!1)}},disabled:!oe||x,className:`w-full mt-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40 disabled:cursor-not-allowed`,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Saving...`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(_e,{className:`h-4 w-4`}),`Save & restart backend`]})})]})}var Q={enabled:!1,intervalMinutes:60,quietHours:{start:`22:00`,end:`07:00`}},bd=[{mins:10,label:`10m`},{mins:30,label:`30m`},{mins:60,label:`1h`},{mins:120,label:`2h`},{mins:180,label:`3h`},{mins:360,label:`6h`},{mins:720,label:`12h`},{mins:-1,label:`Custom`}],xd=bd.length-1,Sd=/^([01]\d|2[0-3]):[0-5]\d$/;function Cd(e){let t=bd.findIndex(t=>t.mins===e);return t===-1?xd:t}function wd(e){if(!Number.isFinite(e)||e<=0)return`Every —`;if(e%60==0){let t=e/60;return`Every ${t} hour${t===1?``:`s`}`}return e<60?`Every ${e} minute${e===1?``:`s`}`:`Every ${Math.floor(e/60)}h ${e%60}m`}function Td(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let n=new Date,r=t.getTime()-n.getTime(),i=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});if(r>0&&r<3600*1e3)return`in ${Math.max(1,Math.round(r/6e4))}m`;if(r>0&&r<360*60*1e3)return`in ${Math.round(r/36e5)}h`;let a=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),o=Math.round((a(t).getTime()-a(n).getTime())/864e5);return o===0?`Today ${i}`:o===1?`Tomorrow ${i}`:o>1&&o<7?`${t.toLocaleDateString([],{weekday:`long`})} ${i}`:`${t.toLocaleDateString([],{month:`short`,day:`numeric`})}, ${i}`}function Ed({pulse:e,original:t,setPulse:n,onPulseSaved:r}){let[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(Cd(e.intervalMinutes)===xd),f=Cd(e.intervalMinutes),p=u,m=u?xd:f,h=Sd.test(e.quietHours.start)&&Sd.test(e.quietHours.end),g=Number.isFinite(e.intervalMinutes)&&e.intervalMinutes>=1&&e.intervalMinutes<=1440,_=t!=null&&(e.enabled!==t.enabled||e.intervalMinutes!==t.intervalMinutes||e.quietHours.start!==t.quietHours.start||e.quietHours.end!==t.quietHours.end),y=_&&g&&h&&!i,b=t=>{o&&s(!1),c&&l(``),n({...e,...t})},x=t=>{t===xd?(d(!0),b({intervalMinutes:u||f===xd?e.intervalMinutes:45})):(d(!1),b({intervalMinutes:bd[t].mins}))},S=async()=>{if(y){a(!0),l(``),s(!1);try{let t=await Pe(`/api/pulse`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e.enabled,intervalMinutes:e.intervalMinutes,quietHours:e.quietHours})});if(!t.ok){let e=await t.json().catch(()=>({error:`Save failed`}));throw Error(e.error||`Save failed`)}r(e),s(!0),a(!1)}catch(e){l(e?.message||`Save failed`),a(!1)}}};return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-[#0069FE]/10 flex items-center justify-center shrink-0`,children:(0,G.jsx)(C,{className:`h-[18px] w-[18px] text-[#0069FE]`})}),(0,G.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,G.jsx)(`h2`,{className:`text-[15px] font-bold text-white tracking-tight`,children:`Pulse`})}),(0,G.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,"aria-label":`Enable pulse`,onClick:()=>b({enabled:!e.enabled}),className:`w-10 h-[22px] rounded-full transition-colors duration-200 flex items-center px-0.5 shrink-0 ${e.enabled?`bg-gradient-brand`:`bg-white/[0.08]`}`,children:(0,G.jsx)(`div`,{className:`w-[18px] h-[18px] rounded-full bg-white shadow-sm transition-transform duration-200 ${e.enabled?`translate-x-[18px]`:`translate-x-0`}`})})]}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-2 leading-relaxed`,children:`Pulse periodically wakes the agent inside the main session, letting it surface anything that needs attention without spamming you.`}),(0,G.jsxs)(`div`,{className:`mt-5 transition-opacity duration-200 ${e.enabled?``:`opacity-50 pointer-events-none select-none`}`,"aria-disabled":!e.enabled,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2.5`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-semibold text-white/70 uppercase tracking-wide`,children:`Frequency`}),(0,G.jsx)(`span`,{className:`text-[11px] font-medium text-[#0069FE] bg-[#0069FE]/10 rounded-full px-2.5 py-1`,children:p?`Custom interval`:wd(e.intervalMinutes)})]}),(0,G.jsx)(`input`,{type:`range`,min:0,max:xd,step:1,value:m,onChange:e=>x(Number(e.target.value)),"aria-label":`Pulse interval`,className:`w-full h-1.5 appearance-none rounded-full bg-white/[0.08] accent-[#0069FE] cursor-pointer
21
21
  [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4
22
22
  [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-white
23
23
  [&::-webkit-slider-thumb]:shadow-[0_0_0_3px_rgba(0,105,254,0.35)] [&::-webkit-slider-thumb]:cursor-pointer
24
24
  [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:rounded-full
25
25
  [&::-moz-range-thumb]:bg-white [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:shadow-[0_0_0_3px_rgba(0,105,254,0.35)]`}),(0,G.jsx)(`div`,{className:`flex justify-between mt-2 px-[1px]`,children:bd.map((e,t)=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>x(t),className:`text-[10px] leading-none transition-colors ${t===m?`text-[#0069FE] font-semibold`:`text-white/30 hover:text-white/55`}`,children:e.label},e.label))}),p&&(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-2.5`,children:[(0,G.jsx)(`input`,{type:`number`,min:1,max:1440,value:Number.isFinite(e.intervalMinutes)?e.intervalMinutes:``,onChange:e=>{let t=parseInt(e.target.value,10);b({intervalMinutes:Number.isFinite(t)?t:NaN})},placeholder:`45`,className:`w-28 bg-white/[0.03] border border-white/[0.08] text-white rounded-xl px-4 py-2.5 text-[13px] outline-none focus:border-[#0069FE]/30 transition-colors placeholder:text-white/20 font-mono`}),(0,G.jsx)(`span`,{className:`text-[12px] text-white/40`,children:`minutes between pulses`})]}),p&&!g&&(0,G.jsx)(`p`,{className:`text-amber-400/80 text-[11px] mt-1.5`,children:`Enter a whole number of minutes (1–1440).`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-6 mb-2.5`,children:[(0,G.jsx)(me,{className:`h-3.5 w-3.5 text-[#0069FE]/70`}),(0,G.jsx)(`span`,{className:`text-[12px] font-semibold text-white/70 uppercase tracking-wide`,children:`Quiet hours`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`text-[11px] text-white/40 mb-1 block`,children:`Start`}),(0,G.jsx)(`input`,{type:`time`,value:e.quietHours.start,onChange:t=>b({quietHours:{...e.quietHours,start:t.target.value}}),className:`w-full bg-white/[0.03] border border-white/[0.08] text-white rounded-xl px-4 py-2.5 text-[13px] outline-none focus:border-[#0069FE]/30 transition-colors [color-scheme:dark]`})]}),(0,G.jsx)(w,{className:`h-4 w-4 text-white/25 mt-5 shrink-0`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`text-[11px] text-white/40 mb-1 block`,children:`End`}),(0,G.jsx)(`input`,{type:`time`,value:e.quietHours.end,onChange:t=>b({quietHours:{...e.quietHours,end:t.target.value}}),className:`w-full bg-white/[0.03] border border-white/[0.08] text-white rounded-xl px-4 py-2.5 text-[13px] outline-none focus:border-[#0069FE]/30 transition-colors [color-scheme:dark]`})]})]}),(0,G.jsx)(`p`,{className:`text-white/35 text-[12px] mt-2 leading-relaxed`,children:`No pulses fire between these times.`})]}),o&&!_&&(0,G.jsxs)(`div`,{className:`mt-4 flex items-center gap-2.5 bg-emerald-500/[0.06] border border-emerald-500/20 rounded-xl px-4 py-3`,children:[(0,G.jsx)(ne,{className:`h-4 w-4 text-emerald-400 shrink-0`}),(0,G.jsx)(`p`,{className:`text-emerald-300/90 text-[12px]`,children:`Saved — the scheduler picks this up within a minute.`})]}),c&&(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5 text-[12px] text-red-400`,children:[(0,G.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0`}),c]}),_&&(0,G.jsx)(`button`,{type:`button`,onClick:S,disabled:!y,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40 disabled:cursor-not-allowed`,children:i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Saving...`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ve,{className:`h-4 w-4`}),`Save pulse settings`]})})]})}function Dd({crons:e,onChanged:t,onLocalUpdate:n}){let[r,i]=(0,v.useState)({}),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(new Set),p=(e,t)=>i(n=>({...n,[e]:t})),m=e=>f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),h=async e=>{if(!r[e.id]){u(``),p(e.id,`pause`);try{let r=await Pe(`/api/crons/pause`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:e.id,paused:!e.paused})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error||`Failed to update`)}n(t=>t.map(t=>t.id===e.id?{...t,paused:!e.paused}:t)),t()}catch(e){u(e.message||`Failed to update`)}finally{p(e.id,void 0)}}},g=async e=>{if(!r[e.id]){u(``),p(e.id,`delete`);try{let r=await Pe(`/api/crons/delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:e.id})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error||`Failed to delete`)}o(null),n(t=>t.filter(t=>t.id!==e.id)),t()}catch(e){u(e.message||`Failed to delete`)}finally{p(e.id,void 0)}}},_=async e=>{if(!s[e.id]){u(``),c(t=>({...t,[e.id]:!0}));try{let t=await Pe(`/api/crons/task?id=${encodeURIComponent(e.id)}`);if(!t.ok)throw Error(`Could not download task file`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.id}.md`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){u(e.message||`Download failed`)}finally{c(t=>({...t,[e.id]:!1}))}}};return(0,G.jsxs)(`div`,{className:`mt-8`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(te,{className:`h-4 w-4 text-[#0069FE]/70 shrink-0`}),(0,G.jsx)(`h2`,{className:`text-[15px] font-bold text-white tracking-tight`,children:`Crons`})]}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`Crons let your agent schedule tasks inside the main session, running them daily, hourly, or on any schedule you choose. They can also be one-shot tasks that run once at a specific time.`}),(0,G.jsxs)(`div`,{className:`mt-2 flex items-start gap-1.5 text-white/30 text-[12px] leading-relaxed`,children:[(0,G.jsx)(de,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,G.jsx)(`span`,{children:`To change or add a cron, just ask your agent. To delete or pause, use the buttons below.`})]}),l&&(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5 text-[12px] text-red-400`,children:[(0,G.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0`}),l]}),(0,G.jsx)(`div`,{className:`mt-4 space-y-2.5`,children:e.length===0?(0,G.jsxs)(`div`,{className:`rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-7 text-center`,children:[(0,G.jsx)(te,{className:`h-5 w-5 text-white/25 mx-auto mb-2`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px]`,children:`No scheduled tasks yet.`}),(0,G.jsx)(`p`,{className:`text-white/25 text-[12px] mt-1`,children:`Ask your agent to schedule something.`})]}):e.map(e=>{let t=!!e.paused,n=r[e.id],i=d.has(e.id),c=Td(e.nextRun);return(0,G.jsxs)(`div`,{className:`rounded-xl border transition-colors ${t?`border-white/[0.05] bg-white/[0.015]`:`border-white/[0.06] bg-white/[0.02]`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 p-2.5`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>m(e.id),className:`flex items-center gap-2.5 flex-1 min-w-0 text-left`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${t?`bg-white/[0.04]`:e.oneShot?`bg-amber-500/10`:`bg-[#0069FE]/10`}`,children:e.oneShot?(0,G.jsx)(De,{className:`h-4 w-4 ${t?`text-white/40`:`text-amber-400`}`}):(0,G.jsx)(ae,{className:`h-4 w-4 ${t?`text-white/40`:`text-[#0069FE]`}`})}),(0,G.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-[13px] ${t?`text-white/45`:`text-white`}`,children:e.task||`(untitled task)`}),t&&(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium text-white/40 bg-white/[0.05] rounded-full px-2 py-0.5`,children:`Paused`})]}),a===e.id?(0,G.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-white/45 mr-0.5`,children:`Delete?`}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>g(e),disabled:n===`delete`,className:`inline-flex items-center gap-1 rounded-md bg-red-500/15 hover:bg-red-500/25 border border-red-500/30 text-red-300 text-[11px] font-medium px-2 py-1 transition-colors disabled:opacity-50`,children:[n===`delete`?(0,G.jsx)(D,{className:`h-3 w-3 animate-spin`}):(0,G.jsx)(Se,{className:`h-3 w-3`}),`Delete`]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(null),disabled:n===`delete`,className:`rounded-md text-white/40 hover:text-white/70 text-[11px] px-1.5 py-1 transition-colors`,children:`Cancel`})]}):(0,G.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>h(e),disabled:!!n,title:t?`Resume`:`Pause`,"aria-label":t?`Resume`:`Pause`,className:`p-1.5 rounded-lg text-white/40 hover:text-white/80 hover:bg-white/[0.05] transition-colors disabled:opacity-50`,children:n===`pause`?(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}):t?(0,G.jsx)(he,{className:`h-4 w-4`}):(0,G.jsx)(O,{className:`h-4 w-4`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(e.id),disabled:!!n,title:`Delete`,"aria-label":`Delete`,className:`p-1.5 rounded-lg text-white/30 hover:text-red-400 hover:bg-red-500/[0.06] transition-colors disabled:opacity-50`,children:(0,G.jsx)(Se,{className:`h-4 w-4`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>m(e.id),title:i?`Collapse`:`Expand`,"aria-label":i?`Collapse`:`Expand`,className:`p-1.5 rounded-lg text-white/30 hover:text-white/70 hover:bg-white/[0.05] transition-colors`,children:(0,G.jsx)(re,{className:`h-4 w-4 transition-transform ${i?`rotate-180`:``}`})})]})]}),i&&(0,G.jsxs)(`div`,{className:`px-2.5 pb-3 pl-[52px] -mt-0.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[12px] text-white/45`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(ae,{className:`h-3 w-3 text-white/30 shrink-0`}),e.description]}),e.oneShot&&(0,G.jsx)(`span`,{className:`text-amber-300/70`,children:`· One-time`}),!t&&c&&(0,G.jsxs)(`span`,{className:`text-[#4AA8FF]`,children:[`· Next: `,c]})]}),e.hasTaskFile&&(0,G.jsxs)(`button`,{type:`button`,onClick:()=>_(e),disabled:s[e.id],className:`group mt-2 inline-flex items-center gap-1.5 rounded-md bg-white/[0.04] hover:bg-white/[0.07] border border-white/[0.06] hover:border-white/[0.12] text-white/50 hover:text-white/80 text-[11px] font-mono px-2 py-1 transition-colors disabled:opacity-50`,title:`Download task instructions`,children:[s[e.id]?(0,G.jsx)(D,{className:`h-3 w-3 animate-spin`}):(0,G.jsx)(T,{className:`h-3 w-3 shrink-0`}),e.id,`.md`,(0,G.jsx)(se,{className:`h-3 w-3 opacity-0 group-hover:opacity-100 transition-opacity`})]})]})]},e.id)})})]})}function Od({cacheRef:e}){let t=(0,v.useRef)(e.current!=null).current,n=e.current,[r,i]=(0,v.useState)(!t),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(n?.pulse??Q),[l,u]=(0,v.useState)(n?.original??null),[d,f]=(0,v.useState)(n?.crons??[]),p=async e=>{let t=await Pe(`/api/schedule`);if(!t.ok)throw Error(`Failed to load schedule`);let n=await t.json();if(f(Array.isArray(n.crons)?n.crons:[]),e){let e={enabled:!!n.pulse?.enabled,intervalMinutes:Number(n.pulse?.intervalMinutes)||60,quietHours:{start:n.pulse?.quietHours?.start??`22:00`,end:n.pulse?.quietHours?.end??`07:00`}};c(e),u(e)}};return(0,v.useEffect)(()=>{if(t)return;let e=!1;return p(!0).then(()=>{e||i(!1)}).catch(t=>{e||(o(t.message||`Failed to load`),i(!1))}),()=>{e=!0}},[t]),(0,v.useEffect)(()=>{r||(e.current={pulse:s,original:l,crons:d})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Pulse & Crons`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`Background wake-ups and scheduled tasks your agent runs on its own.`}),r?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-12 text-white/40`,children:(0,G.jsx)(D,{className:`h-5 w-5 animate-spin`})}):a?(0,G.jsxs)(`div`,{className:`mt-5 flex items-center gap-2 text-[13px] text-red-400`,children:[(0,G.jsx)(Ce,{className:`h-4 w-4 shrink-0`}),a]}):(0,G.jsxs)(`div`,{className:`mt-6 max-h-[50vh] overflow-y-auto pr-1 -mr-1`,children:[(0,G.jsx)(Ed,{pulse:s,original:l,setPulse:c,onPulseSaved:e=>u(e)}),(0,G.jsx)(Dd,{crons:d,onLocalUpdate:e=>f(e),onChanged:()=>{p(!1).catch(()=>{})}})]})]})}function kd({onComplete:e,isInitialSetup:t=!1,onSave:n,onTunnelSwitch:r}){let[i,a]=(0,v.useState)(0),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(`anthropic`),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)({anthropic:`idle`,openai:`idle`,pi:`idle`}),[g,_]=(0,v.useState)([]),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(``),[C,te]=(0,v.useState)(``),[re,ae]=(0,v.useState)(``),[se,T]=(0,v.useState)(!1),[de,fe]=(0,v.useState)(!1),[me,O]=(0,v.useState)(),[he,ge]=(0,v.useState)(null),[ve,Se]=(0,v.useState)(!1),[De,Oe]=(0,v.useState)(``),[ke,Ae]=(0,v.useState)(!1),[je,Me]=(0,v.useState)(),[Ne,Pe]=(0,v.useState)(!1),[Fe,Ie]=(0,v.useState)(`device`),[Le,Re]=(0,v.useState)(`idle`),[ze,Be]=(0,v.useState)(``),[Ve,He]=(0,v.useState)(``),[Ue,We]=(0,v.useState)(!1),[Ge,Ke]=(0,v.useState)(!1),[k,qe]=(0,v.useState)(!1),[Je,Ye]=(0,v.useState)(``),[Xe,Ze]=(0,v.useState)(!1),[Qe,$e]=(0,v.useState)(),[et,tt]=(0,v.useState)(!1),[A,nt]=(0,v.useState)(``),[rt,it]=(0,v.useState)(null),[at,ot]=(0,v.useState)(``),[st,ct]=(0,v.useState)({}),[lt,ut]=(0,v.useState)(``),[dt,ft]=(0,v.useState)(!1),[pt,mt]=(0,v.useState)(!1),[ht,gt]=(0,v.useState)(``),_t=(0,v.useRef)(null),[vt,yt]=(0,v.useState)(`quick`),[bt,xt]=(0,v.useState)(``),[St,Ct]=(0,v.useState)(``),[wt,Tt]=(0,v.useState)(`relay`),[j,M]=(0,v.useState)(null),[N,Et]=(0,v.useState)(!1),[Dt,Ot]=(0,v.useState)(!1),[kt,At]=(0,v.useState)({}),[jt,Mt]=(0,v.useState)(!1),[Nt,Pt]=(0,v.useState)(``),[Ft,It]=(0,v.useState)(``),[Lt,Rt]=(0,v.useState)(!1),[zt,Bt]=(0,v.useState)(`tunnel`),[Vt,Ht]=(0,v.useState)(!1),[Ut,Wt]=(0,v.useState)(``),[Gt,Kt]=(0,v.useState)(!1),[qt,Jt]=(0,v.useState)(``),[Yt,Xt]=(0,v.useState)(!1),[Zt,Qt]=(0,v.useState)(!1),[$t,P]=(0,v.useState)(``),[en,tn]=(0,v.useState)(`admin`),[nn,rn]=(0,v.useState)(``),[F,an]=(0,v.useState)(``),[on,sn]=(0,v.useState)(!1),[cn,ln]=(0,v.useState)(!1),[un,dn]=(0,v.useState)(!1),[fn,pn]=(0,v.useState)(!1),[mn,hn]=(0,v.useState)(``),[gn,_n]=(0,v.useState)(``),[vn,yn]=(0,v.useState)(!1),[bn,xn]=(0,v.useState)(!1),[Sn,Cn]=(0,v.useState)(!1),[I,wn]=(0,v.useState)(!1),[Tn,En]=(0,v.useState)(``),[Dn,On]=(0,v.useState)(!1),[kn,An]=(0,v.useState)(``),[jn,Mn]=(0,v.useState)(``),[Nn,Pn]=(0,v.useState)(``),[Fn,In]=(0,v.useState)(``),[Ln,Rn]=(0,v.useState)(!1),[zn,Bn]=(0,v.useState)(!1),[Vn,Hn]=(0,v.useState)(``),[L,Un]=(0,v.useState)([]),[Wn,Gn]=(0,v.useState)(!1),[Kn,qn]=(0,v.useState)(!1),[Jn,Yn]=(0,v.useState)(``),[Xn,Zn]=(0,v.useState)(``),[Qn,$n]=(0,v.useState)(!1),[er,tr]=(0,v.useState)(`password`),[nr,rr]=(0,v.useState)(!1),ir=(0,v.useRef)(!1),ar=(0,v.useRef)(null),or=(0,v.useRef)(null),[sr,cr]=(0,v.useState)({userName:``,botName:``,provider:``,model:``,whisperEnabled:!1,whisperKey:``}),[lr,ur]=(0,v.useState)(!1),[dr,fr]=(0,v.useState)(!1),[pr,mr]=(0,v.useState)(``),hr=m[c]===`connected`,gr=`bloby_totp_setup`;function _r(){try{sessionStorage.setItem(gr,JSON.stringify({secret:kn,qrUri:jn,otpauthUri:Nn,phase:er,portalPass:nn,portalPassConfirm:F}))}catch{}}function vr(){try{let e=sessionStorage.getItem(gr);if(!e)return!1;let t=JSON.parse(e);if(t.secret&&t.phase===`totp-setup`)return An(t.secret),Mn(t.qrUri||``),Pn(t.otpauthUri||``),On(!0),tr(`totp-setup`),a(3),t.portalPass&&(rn(t.portalPass),an(t.portalPassConfirm||``)),!0}catch{}return!1}function yr(){try{sessionStorage.removeItem(gr)}catch{}}(0,v.useEffect)(()=>{fetch(`/api/onboard/status`).then(e=>e.json()).then(e=>{e.userName&&s(e.userName),e.handle?(nt(e.handle.username),ut(e.handle.tier||`at`),M({username:e.handle.username,tier:e.handle.tier,url:e.handle.url}),mt(!0),gt(e.handle.url)):e.agentName&&nt(e.agentName),e.portalUser&&tn(e.portalUser),e.portalConfigured&&ln(!0),e.provider&&l(e.provider),e.model&&d(e.model),e.whisperEnabled&&(wn(!0),En(e.whisperKey||``)),e.totpEnabled&&(On(!0),Rn(!0)),e.tunnelMode&&yt(e.tunnelMode),e.tunnelDomain&&xt(e.tunnelDomain),e.tunnelUrl&&Ct(e.tunnelUrl),e.handle||Tt(`tunnel`),cr({userName:e.userName||``,botName:e.handle&&e.handle.username||e.agentName||``,provider:e.provider||``,model:e.model||``,whisperEnabled:!!e.whisperEnabled,whisperKey:e.whisperKey||``}),ir.current=!0,e.totpEnabled||vr()}).catch(()=>{ir.current=!0})},[]),(0,v.useEffect)(()=>{Bt(ld(window.location.hostname))},[]),(0,v.useEffect)(()=>{$n(window.matchMedia(`(max-width: 768px)`).matches||`ontouchstart`in window)},[]),(0,v.useEffect)(()=>{c!==`anthropic`||m.anthropic===`connected`||fetch(`/api/auth/claude/status`).then(e=>e.json()).then(e=>{e.authenticated&&h(e=>({...e,anthropic:`connected`}))}).catch(()=>{})},[c]),(0,v.useEffect)(()=>{c!==`openai`||m.openai===`connected`||fetch(`/api/auth/codex/status`).then(e=>e.json()).then(e=>{e.authenticated&&h(e=>({...e,openai:`connected`}))}).catch(()=>{})},[c]),(0,v.useEffect)(()=>{if(_t.current&&clearTimeout(_t.current),!ir.current||vt===`off`||j&&pt&&A===j.username)return;it(null),ot(``),ct({}),At({}),Mt(!1),Pt(``),It(``),mt(!1),gt(``);let e=A.trim();if(e){if(e.length<3){it(`invalid`),ot(`At least 3 characters`);return}return it(`checking`),_t.current=setTimeout(async()=>{try{let t=await(await fetch(`/api/handle/check/${encodeURIComponent(e)}`)).json();if(!t.valid)it(`invalid`),ot(t.error);else{let e={},n={};for(let r of t.handles)e[r.tier]=r.available,r.reserved&&(n[r.tier]=!0);ct(e),At(n),it(`ready`),ut(``)}}catch{it(null)}},400),()=>{_t.current&&clearTimeout(_t.current)}}},[A]),(0,v.useEffect)(()=>{if(!A||A.length<3||rt!==`ready`)return;let e=async()=>{try{let e=await(await fetch(`/api/handle/check/${encodeURIComponent(A.trim())}`)).json();if(e.valid){let t={},n={};for(let r of e.handles)t[r.tier]=r.available,r.reserved&&(n[r.tier]=!0);ct(t),At(n)}}catch{}};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[A,rt]);let br=e=>{nt(e.toLowerCase().replace(/[^a-z0-9-]/g,``))},xr=async()=>{if(!(!A||rt!==`ready`||!st[lt])){ft(!0);try{let e=await(await fetch(`/api/handle/register`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:A,tier:lt})})).json();e.ok?(mt(!0),gt(e.url)):(ot(e.error||`Registration failed`),it(`invalid`))}catch{ot(`Could not reach server`),it(`invalid`)}finally{ft(!1)}}},Sr=async()=>{if(!(!A||rt!==`ready`||!st[lt])){Ot(!0);try{let e=await(await fetch(`/api/handle/change`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:A,tier:lt})})).json();e.ok?(mt(!0),gt(e.url),M({username:A,tier:lt,url:e.url}),Et(!1)):(ot(e.error||`Handle change failed`),it(`invalid`))}catch{ot(`Could not reach server`),it(`invalid`)}finally{Ot(!1)}}},Cr=async()=>{if(!(!A||!Nt)){Rt(!0),It(``);try{let e=await(await fetch(`/api/handle/claim-reserved`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({handle:A,hash:Nt})})).json();e.ok?(mt(!0),gt(e.url),Mt(!1),Pt(``),ut(`premium`),Tt(`relay`)):It(e.error||`Invalid activation code`)}catch{It(`Could not reach server`)}finally{Rt(!1)}}},wr=e=>{c===`openai`&&e!==`openai`&&(k&&fetch(`/api/auth/codex/cancel`,{method:`POST`}),Le===`pending`&&fetch(`/api/auth/codex/device/cancel`,{method:`POST`})),l(e),d(e===`openai`?`gpt-5.5:high`:``),Se(!1),Oe(``),Me(void 0),qe(!1),Ye(``),Re(`idle`),Be(``),He(``),Ie(`device`),$e(void 0),O(void 0)};(0,v.useEffect)(()=>{if(c!==`pi`)return;let e=!1;return(async()=>{try{let[t,n]=await Promise.all([fetch(`/api/auth/pi/providers`),fetch(`/api/auth/pi/status`)]),r=await t.json(),i=await n.json();if(e)return;let a=r?.providers||[];_(a),i?.configured?(b(i.subProvider||``),ae(i.modelId||``),te(i.baseUrl||``),h(e=>({...e,pi:`connected`})),ge({subProvider:i.subProvider,modelId:i.modelId,baseUrl:i.baseUrl}),d(`${i.subProvider}/${i.modelId||``}`)):!y&&a[0]&&(b(a[0].id),te(a[0].baseUrl||``),ae(a[0].defaultModel||``))}catch(t){e||O(t?.message||`Failed to load Bloby providers`)}})(),()=>{e=!0}},[c]);let Tr=g.find(e=>e.id===y),Er=e=>{let t=g.find(t=>t.id===e);b(e),te(t?.baseUrl||``),ae(t?.defaultModel||``),O(void 0),m.pi===`connected`&&(h(e=>({...e,pi:`idle`})),ge(null))},Dr=async()=>{if(y){O(void 0),fe(!0);try{let e={subProvider:y,apiKey:x.trim()||void 0,baseUrl:C.trim()||void 0,modelId:re.trim()||void 0},t=await(await fetch(`/api/auth/pi/test`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();if(!t?.ok){O(t?.error||`Connection test failed`);return}let n=await(await fetch(`/api/auth/pi/save`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();if(!n?.ok){O(n?.error||`Failed to save credentials`);return}h(e=>({...e,pi:`connected`})),ge(n.status||null),d(`${y}/${re||Tr?.defaultModel||``}`),S(``)}catch(e){O(e?.message||`Connection failed`)}finally{fe(!1)}}},Or=async()=>{try{await fetch(`/api/auth/pi`,{method:`DELETE`})}catch{}h(e=>({...e,pi:`idle`})),ge(null),d(``)},kr=e=>{if(window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0){let t=document.createElement(`a`);t.href=e,t.target=`_blank`,t.rel=`noopener noreferrer`,document.body.appendChild(t),t.click(),document.body.removeChild(t)}else window.open(e,`_blank`,`noopener,noreferrer`)},Ar=async()=>{Me(void 0);try{let e=await(await fetch(`/api/auth/claude/start`,{method:`POST`})).json();e.success&&e.authUrl?(kr(e.authUrl),Se(!0)):Me(e.error||`Failed to start authentication`)}catch(e){Me(e.message)}},jr=async()=>{if(De.trim()){Ae(!0),Me(void 0);try{let e=await(await fetch(`/api/auth/claude/exchange`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:De.trim()})})).json();e.success?h(e=>({...e,anthropic:`connected`})):Me(e.error||`Code exchange failed`)}catch(e){Me(e.message)}finally{Ae(!1)}}},Mr=async()=>{try{let e=await navigator.clipboard.readText();e&&Oe(e.trim())}catch{}},Nr=async()=>{Pe(!0),Me(void 0);try{(await(await fetch(`/api/auth/claude/status`)).json()).authenticated?h(e=>({...e,anthropic:`connected`})):Me(`No active session found. Please authenticate first.`)}catch{}finally{Pe(!1)}},Pr=async()=>{$e(void 0),We(!0),Re(`pending`);try{let e=await(await fetch(`/api/auth/codex/device/start`,{method:`POST`})).json();e.success?(Be(e.userCode||``),He(e.verificationUrl||``),e.verificationUrl&&kr(e.verificationUrl)):(Re(`error`),$e(e.error||`Failed to start device-code login`))}catch(e){Re(`error`),$e(e.message)}finally{We(!1)}},Fr=async()=>{try{await fetch(`/api/auth/codex/device/cancel`,{method:`POST`})}catch{}Re(`idle`),Be(``),He(``)},Ir=async()=>{try{await navigator.clipboard.writeText(ze),Ke(!0),setTimeout(()=>Ke(!1),1500)}catch{}};(0,v.useEffect)(()=>{if(Le!==`pending`||!ze)return;let e=setInterval(async()=>{try{let e=await(await fetch(`/api/auth/codex/device/status`)).json();e.state===`success`?(Re(`success`),h(e=>({...e,openai:`connected`}))):e.state===`error`&&(Re(`error`),$e(e.error||`Device-code login failed`))}catch{}},2e3);return()=>clearInterval(e)},[Le,ze]);let Lr=async()=>{$e(void 0);try{let e=await(await fetch(`/api/auth/codex/start`,{method:`POST`})).json();e.success&&e.authUrl?(kr(e.authUrl),qe(!0)):$e(e.error||`Failed to start authentication`)}catch(e){$e(e.message)}},Rr=async()=>{if(Je.trim()){Ze(!0),$e(void 0);try{let e=await(await fetch(`/api/auth/codex/exchange`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:Je.trim()})})).json();e.success?(h(e=>({...e,openai:`connected`})),Ye(``)):$e(e.error||`Code exchange failed`)}catch(e){$e(e.message)}finally{Ze(!1)}}},zr=async()=>{try{let e=await navigator.clipboard.readText();e&&Ye(e.trim())}catch{}},Br=async()=>{tt(!0),$e(void 0);try{(await(await fetch(`/api/auth/codex/status`)).json()).authenticated?h(e=>({...e,openai:`connected`})):$e(`No active session found. Please authenticate first.`)}catch{}finally{tt(!1)}},Vr=nn===F,Hr=nn.length>=6&&Vr,Ur=cn?nn.length===0||vn&&Hr:Hr,Wr=(()=>{switch(i){case 0:return!0;case 1:return o.trim().length>0;case 2:return Vt||Yt?!1:vt===`off`||vt===`named`||wt===`tunnel`?A.trim().length>=3:pt;case 3:return!(er!==`password`||!Ur||Dn&&!Ln);case 4:return!!(c&&u&&hr);case 5:return!0;case 6:return!0;case 7:return!0;default:return!1}})(),Gr=()=>{t&&Wr&&i<6&&a(e=>e+1)},Kr=()=>{i>0&&a(e=>e-1)},qr=e=>{e.key===`Enter`&&Wr&&Gr()},Jr=(()=>{if(t)return!1;switch(i){case 1:return o.trim()!==sr.userName;case 2:return A.trim()!==sr.botName;case 3:return er===`password`&&nn.length>0&&Hr&&(cn?vn:!0);case 4:return(c!==sr.provider||u!==sr.model)&&hr&&!!u;case 5:return(I!==sr.whisperEnabled||I&&Tn!==sr.whisperKey)&&!(I&&(!Tn.startsWith(`sk-`)||Tn.length<20));default:return!1}})();(0,v.useEffect)(()=>{fr(!1),mr(``)},[i]);let Yr=async()=>{if(!Jr||lr)return;ur(!0),mr(``),fr(!1);let e={userName:sr.userName,agentName:sr.botName||`Bloby`,provider:sr.provider,model:sr.model,apiKey:``,whisperEnabled:sr.whisperEnabled,whisperKey:sr.whisperEnabled?sr.whisperKey:``,portalUser:en.trim(),portalPass:``};switch(i){case 1:e.userName=o.trim();break;case 2:e.agentName=A.trim()||`Bloby`;break;case 3:e.portalPass=nn;break;case 4:e.provider=c,e.model=u;break;case 5:e.whisperEnabled=I,e.whisperKey=I?Tn:``;break}try{n?await n(e):await fetch(`/api/onboard`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),cr(e=>{switch(i){case 1:return{...e,userName:o.trim()};case 2:return{...e,botName:A.trim()};case 4:return{...e,provider:c,model:u};case 5:return{...e,whisperEnabled:I,whisperKey:Tn};default:return e}}),i===3&&(rn(``),an(``),hn(``),yn(!1),Cn(!1),ln(!0)),fr(!0),ur(!1)}catch(e){mr(e.message||`Save failed`),ur(!1)}},Xr=async()=>{p(!0);let r={userName:o.trim(),agentName:A.trim()||`Bloby`,provider:c,model:u,apiKey:``,whisperEnabled:I,whisperKey:I?Tn:``,portalUser:en.trim(),portalPass:nn};try{n?await n(r):await fetch(`/api/onboard`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),t?(p(!1),a(6)):e()}catch(e){console.error(`[OnboardWizard] Onboard failed:`,e),p(!1)}},Zr=`w-full bg-white/[0.05] border border-white/[0.08] text-white rounded-xl px-4 py-3 text-base outline-none input-glow placeholder:text-white/20 transition-all`,Qr=`w-full bg-white/[0.03] border border-white/[0.08] text-white rounded-xl px-4 py-2.5 text-[13px] outline-none input-glow placeholder:text-white/20 transition-all`;return(0,G.jsxs)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center p-4`,children:[(0,G.jsx)(`div`,{className:`absolute inset-0 bg-black/85 backdrop-blur-md`}),(0,G.jsxs)(sd.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.3},className:`relative w-full max-w-[480px] bg-[#181818] border border-white/[0.06] rounded-[24px] shadow-2xl overflow-hidden`,children:[t?(0,G.jsx)(`div`,{className:`flex justify-center gap-2 pt-6`,children:Array.from({length:7},(e,t)=>(0,G.jsx)(`div`,{className:`h-1.5 rounded-full transition-all duration-300 ${t===i?`w-7 bg-gradient-brand`:t<i?`w-1.5 bg-gradient-brand opacity-60`:`w-1.5 bg-white/10`}`},t))}):(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-5 pt-4 pb-1`,children:[i===0?(0,G.jsx)(`span`,{className:`text-[13px] font-semibold text-white/80 pl-1`,children:`Settings`}):(0,G.jsxs)(`button`,{onClick:()=>a(0),className:`flex items-center gap-1 text-white/50 hover:text-white/80 text-[13px] font-medium pl-1 pr-2 py-1 rounded-lg hover:bg-white/[0.05] transition-colors`,children:[(0,G.jsx)(ee,{className:`h-3.5 w-3.5`}),` Settings`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[i!==0&&(0,G.jsx)(_d,{onJump:e=>a(e)}),(0,G.jsx)(`button`,{onClick:e,className:`text-white/40 hover:text-white/80 p-1.5 rounded-lg hover:bg-white/[0.05] transition-colors`,"aria-label":`Close settings`,children:(0,G.jsx)(Ee,{className:`h-4 w-4`})})]})]}),(0,G.jsx)(_l,{mode:`wait`,children:(0,G.jsxs)(sd.div,{initial:{opacity:0,x:30},animate:{opacity:1,x:0},exit:{opacity:0,x:-30},transition:{duration:.2,ease:`easeOut`},className:`px-8 pt-6 pb-8`,children:[i===0&&t&&(0,G.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,G.jsxs)(`video`,{autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:`h-[180px] mb-4`,children:[(0,G.jsx)(`source`,{src:`/bloby_say_hi.mov`,type:`video/mp4; codecs="hvc1"`}),(0,G.jsx)(`source`,{src:`/bloby_say_hi.webm`,type:`video/webm`})]}),(0,G.jsx)(`h1`,{className:`text-2xl font-bold text-white tracking-tight`,children:`Welcome to Bloby`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[14px] mt-2 leading-relaxed max-w-[320px]`,children:`Let's set up your AI assistant in just a few steps.`}),(0,G.jsxs)(`button`,{onClick:Gr,className:`mt-6 px-7 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center gap-2`,children:[`Get Started`,(0,G.jsx)(w,{className:`h-4 w-4`})]})]}),i===0&&!t&&(0,G.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,G.jsxs)(`video`,{autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:`h-[150px] mb-4`,children:[(0,G.jsx)(`source`,{src:`/bloby_say_hi.mov`,type:`video/mp4; codecs="hvc1"`}),(0,G.jsx)(`source`,{src:`/bloby_say_hi.webm`,type:`video/webm`})]}),(0,G.jsx)(`h1`,{className:`text-2xl font-bold text-white tracking-tight`,children:`Settings`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[14px] mt-2 leading-relaxed max-w-[320px]`,children:`What would you like to change?`}),(0,G.jsx)(`div`,{className:`w-full mt-5`,children:(0,G.jsx)(hd,{models:gd.map(e=>({id:String(e.step),label:e.label})),value:``,placeholder:`Select a setting…`,menuMaxHeight:`max-h-[188px]`,onChange:e=>a(Number(e))})})]}),i===1&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`What's your name?`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`This is how your agent will address you.`}),(0,G.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[(0,G.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:qr,placeholder:`Enter your name`,autoFocus:!0,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,className:Zr+` flex-1`}),t&&(0,G.jsx)(`button`,{onClick:Gr,disabled:!Wr,className:`shrink-0 h-12 w-12 flex items-center justify-center rounded-full bg-gradient-brand hover:opacity-90 text-white transition-colors disabled:opacity-30`,children:(0,G.jsx)(w,{className:`h-5 w-5`})})]})]}),i===2&&vt===`off`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Agent Name & Access`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`Give your bot a name. This is used throughout the app as your bot's identity.`}),(0,G.jsx)(`div`,{className:`relative mt-5`,children:(0,G.jsx)(`input`,{type:`text`,value:A,onChange:e=>br(e.target.value),maxLength:30,placeholder:`your-bot-name`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,autoFocus:!0,className:Zr+` pr-10 font-mono`})}),(0,G.jsx)(`div`,{className:`mt-4 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:(0,G.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:`Private network mode — your bot is only accessible via your local network or VPN. No public URL will be created.`})}),!t&&(0,G.jsx)(`div`,{className:`mt-3 flex items-center gap-2`,children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-medium border ${ud(zt)?`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`:`bg-blue-500/10 text-blue-400 border-blue-500/20`}`,children:[ud(zt)?(0,G.jsx)(we,{className:`h-3 w-3`}):(0,G.jsx)(E,{className:`h-3 w-3`}),`Accessing via `,dd[zt]]})}),!t&&!Yt&&(0,G.jsxs)(`button`,{onClick:()=>{Xt(!0),P(``)},className:`w-full mt-4 flex items-center justify-between px-4 py-3 rounded-xl border border-white/[0.06] bg-white/[0.02] hover:border-white/10 hover:bg-white/[0.04] transition-all text-left`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[13px] text-white/70 font-medium`,children:`Re-enable public tunnel access`}),(0,G.jsx)(`p`,{className:`text-[11px] text-white/30 mt-0.5`,children:`Start a Cloudflare tunnel to make your bot accessible from anywhere`})]}),(0,G.jsx)(E,{className:`h-4 w-4 text-white/30 shrink-0 ml-3`})]}),Yt&&(0,G.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,G.jsx)(`div`,{className:`bg-amber-500/8 border border-amber-500/20 rounded-xl px-4 py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(Ce,{className:`h-4 w-4 text-amber-400 shrink-0 mt-0.5`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-amber-400/90 text-[13px] font-medium`,children:`Enable public access?`}),(0,G.jsxs)(`p`,{className:`text-amber-400/60 text-[12px] mt-1 leading-relaxed`,children:[`This will start a Cloudflare tunnel, making your bot reachable from the internet.`,j&&` Your handle will reconnect automatically.`]})]})]})}),$t&&(0,G.jsx)(`p`,{className:`text-red-400/70 text-[12px]`,children:$t}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`button`,{onClick:async()=>{if(r){Qt(!0),P(``);try{await r(`quick`),yt(`quick`),Xt(!1)}catch(e){P(e.message||`Failed to start tunnel`)}finally{Qt(!1)}}},disabled:Zt||!r,className:`flex-1 py-2.5 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:Zt?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Starting tunnel...`]}):`Enable Tunnel`}),(0,G.jsx)(`button`,{onClick:()=>{Xt(!1),P(``)},disabled:Zt,className:`px-5 py-2.5 bg-white/[0.04] hover:bg-white/[0.08] border border-white/[0.08] text-white/60 text-[13px] font-medium rounded-full transition-colors`,children:`Cancel`})]})]}),t&&(0,G.jsxs)(`button`,{onClick:Gr,disabled:!Wr,className:`w-full mt-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Continue`,(0,G.jsx)(w,{className:`h-4 w-4`})]})]}),i===2&&vt===`named`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Agent Name & Access`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`This is your bot's identity. Your named tunnel domain is already configured.`}),(0,G.jsx)(`div`,{className:`relative mt-5`,children:(0,G.jsx)(`input`,{type:`text`,value:A,onChange:e=>br(e.target.value),maxLength:30,placeholder:`your-bot-name`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,autoFocus:!0,className:Zr+` pr-10 font-mono`})}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,G.jsxs)(`span`,{className:`font-mono text-[13px] text-white/70 truncate flex-1 text-left`,children:[`https://`,bt]}),(0,G.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(`https://${bt}`),sn(!0),setTimeout(()=>sn(!1),2e3)},className:`shrink-0 text-white/30 hover:text-white/60 transition-colors`,children:on?(0,G.jsx)(ne,{className:`h-4 w-4 text-emerald-400`}):(0,G.jsx)(ie,{className:`h-4 w-4`})})]})]}),i===2&&vt===`quick`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Agent Name & Access`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`This is your bot's name and permanent handle — access it from anywhere.`}),j&&pt&&!N&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-4 bg-emerald-500/8 border border-emerald-500/15 rounded-xl px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ne,{className:`h-4 w-4 text-emerald-400`}),(0,G.jsx)(`p`,{className:`text-emerald-400/90 text-[13px] font-medium`,children:`Current handle`})]}),(0,G.jsx)(`p`,{className:`text-emerald-400/60 text-[12px] mt-1 font-mono`,children:ht})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 mt-4`,children:[t&&(0,G.jsxs)(`button`,{onClick:Gr,className:`flex-1 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2`,children:[`Continue`,(0,G.jsx)(w,{className:`h-4 w-4`})]}),(0,G.jsx)(`button`,{onClick:()=>{Et(!0),mt(!1),nt(``),it(null),ct({}),Tt(`relay`)},className:`px-5 py-3 bg-white/[0.04] hover:bg-white/[0.08] border border-white/[0.08] text-white/60 text-[13px] font-medium rounded-full transition-colors`,children:`Change`})]})]}),N&&!pt&&(0,G.jsxs)(`div`,{className:`mt-4 bg-amber-500/8 border border-amber-500/20 rounded-xl px-4 py-3`,children:[(0,G.jsx)(`p`,{className:`text-amber-400/90 text-[13px] font-medium`,children:`Changing your handle`}),(0,G.jsxs)(`p`,{className:`text-amber-400/60 text-[12px] mt-1`,children:[`Your current handle `,(0,G.jsx)(`span`,{className:`font-mono`,children:j?.url}),` will be released and become available for others.`]})]}),(!j||N||!pt)&&!(j&&pt&&!N)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`relative mt-5`,children:[(0,G.jsx)(`input`,{type:`text`,value:A,onChange:e=>br(e.target.value),maxLength:30,placeholder:`your-bot-name`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,autoFocus:!0,disabled:pt,className:Zr+` pr-10 font-mono`+(pt?` opacity-50`:``)}),rt&&A.length>0&&!pt&&(0,G.jsxs)(`div`,{className:`absolute right-4 top-1/2 -translate-y-1/2`,children:[rt===`checking`&&(0,G.jsx)(`div`,{className:`w-5 h-5 border-2 border-white/10 border-t-[#0069FE] rounded-full animate-spin`}),rt===`invalid`&&(0,G.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-amber-500/15 flex items-center justify-center`,children:(0,G.jsx)(`svg`,{className:`w-3.5 h-3.5 text-amber-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:3,children:(0,G.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v3m0 4h.01`})})})]})]}),rt===`invalid`&&at&&(0,G.jsx)(`p`,{className:`text-amber-400 text-[12px] mt-2`,children:at}),rt===`ready`&&A.length>0&&!pt&&(0,G.jsxs)(`div`,{className:`space-y-3 mt-4`,children:[(()=>{let e=st.at===!1,t=wt===`relay`&&lt===`at`;return(0,G.jsxs)(`button`,{onClick:()=>{e||(ut(`at`),Tt(`relay`))},disabled:e,className:`w-full rounded-xl border transition-all duration-200 text-left px-4 py-3 ${e?`border-white/[0.04] opacity-50 cursor-not-allowed`:t?`border-[#0069FE]/30 bg-white/[0.04]`:`border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-semibold text-white/60 uppercase tracking-wider`,children:`Free`}),(0,G.jsx)(`span`,{className:`text-[11px] font-medium px-2.5 py-0.5 rounded-full border ${e?`bg-red-500/10 text-red-400 border-red-500/20`:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`}`,children:e?`Taken`:`Available`})]}),(0,G.jsxs)(`p`,{className:`font-mono text-[13px] mt-1.5 ${t?`text-white/80`:`text-white/40`}`,children:[`open.bloby.bot/`,A]})]})})(),(()=>{let e=st.premium,t=e===!1,n=t&&kt.premium;return(0,G.jsxs)(`div`,{className:`rounded-xl border transition-all duration-200 text-left px-4 py-3 ${n?`border-[#0069FE]/20`:`border-white/[0.06]`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-semibold text-white/60 uppercase tracking-wider`,children:`Premium`}),(0,G.jsx)(`span`,{className:`text-[11px] font-medium px-2.5 py-0.5 rounded-full border bg-[#0069FE]/15 text-[#0069FE] border-[#0069FE]/20`,children:`$5`})]}),(0,G.jsx)(`span`,{className:`text-[11px] font-medium px-2.5 py-0.5 rounded-full border ${n?`bg-[#0069FE]/10 text-[#0069FE] border-[#0069FE]/20`:t?`bg-red-500/10 text-red-400 border-red-500/20`:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`}`,children:n?`Reserved`:t?`Taken`:`Available`})]}),(0,G.jsxs)(`p`,{className:`font-mono text-[13px] mt-1.5 text-white/40`,children:[`bloby.bot/`,A]}),e&&(0,G.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-white/[0.06] flex items-center justify-between`,children:[(0,G.jsx)(`p`,{className:`text-[12px] text-white/40`,children:`Purchase on bloby.bot`}),(0,G.jsx)(`a`,{href:`https://www.bloby.bot/#reserve`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[12px] font-medium text-[#0069FE] hover:text-[#3391FF] transition-colors`,children:`Purchase`})]}),n&&(0,G.jsx)(`div`,{className:`mt-3 pt-3 border-t border-[#0069FE]/10`,children:jt?(0,G.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,G.jsxs)(`p`,{className:`text-[12px] text-white/40`,children:[`Enter the 5-character code from your `,(0,G.jsx)(`span`,{className:`text-white/60 font-medium`,children:`bloby.bot`}),` account`]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{type:`text`,value:Nt,onChange:e=>Pt(e.target.value.trim()),maxLength:5,placeholder:`e.g. a3Kx9`,spellCheck:!1,autoComplete:`off`,autoFocus:!0,className:`flex-1 bg-white/[0.05] border border-white/[0.08] text-white rounded-lg px-3 py-2 text-[13px] font-mono outline-none focus:border-[#0069FE]/30 transition-colors placeholder:text-white/20 tracking-widest text-center`}),(0,G.jsx)(`button`,{onClick:Cr,disabled:Lt||Nt.length<5,className:`px-4 py-2 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-semibold rounded-lg transition-colors flex items-center gap-1.5 disabled:opacity-40`,children:Lt?(0,G.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}):`Activate`})]}),Ft&&(0,G.jsx)(`p`,{className:`text-red-400 text-[12px]`,children:Ft}),(0,G.jsx)(`button`,{onClick:()=>{Mt(!1),Pt(``),It(``)},className:`text-[11px] text-white/25 hover:text-white/40 transition-colors`,children:`Cancel`})]}):(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`p`,{className:`text-[12px] text-white/40`,children:`Is that yours?`}),(0,G.jsx)(`button`,{onClick:()=>{Mt(!0),Pt(``),It(``)},className:`text-[12px] font-medium text-[#0069FE] hover:text-[#3391FF] transition-colors`,children:`Activate`})]})})]})})(),(0,G.jsxs)(`button`,{onClick:()=>{Tt(`tunnel`),ut(`skip`)},className:`w-full rounded-xl border transition-all duration-200 text-left px-4 py-3 ${lt===`skip`?`border-[#0069FE]/30 bg-white/[0.04]`:`border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-semibold text-white/60 uppercase tracking-wider`,children:`No handle`}),(0,G.jsx)(`p`,{className:`text-[13px] mt-1.5 ${lt===`skip`?`text-white/60`:`text-white/30`}`,children:`I'll use the random tunnel URL`})]})]}),pt&&(0,G.jsxs)(`div`,{className:`mt-4 bg-emerald-500/8 border border-emerald-500/15 rounded-xl px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ne,{className:`h-4 w-4 text-emerald-400`}),(0,G.jsx)(`p`,{className:`text-emerald-400/90 text-[13px] font-medium`,children:`Handle claimed!`})]}),(0,G.jsx)(`p`,{className:`text-emerald-400/60 text-[12px] mt-1 font-mono`,children:ht})]}),rt===`ready`&&A.length>0&&!pt&&(0,G.jsx)(`button`,{onClick:lt===`skip`?Gr:wt===`relay`&&lt===`at`?N?Sr:xr:void 0,disabled:!lt||dt||Dt||lt===`at`&&!st.at,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40 disabled:cursor-not-allowed`,children:dt||Dt?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}),N?`Changing...`:`Claiming...`]}):lt?lt===`skip`?(0,G.jsxs)(G.Fragment,{children:[`Continue`,(0,G.jsx)(w,{className:`h-4 w-4`})]}):(0,G.jsxs)(G.Fragment,{children:[N?`Change Handle`:`Claim & Continue`,(0,G.jsx)(w,{className:`h-4 w-4`})]}):(0,G.jsx)(G.Fragment,{children:`Select an option to continue`})}),t&&pt&&(0,G.jsxs)(`button`,{onClick:Gr,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2`,children:[`Continue`,(0,G.jsx)(w,{className:`h-4 w-4`})]}),N&&!pt&&(0,G.jsx)(`button`,{onClick:()=>{Et(!1),nt(j.username),mt(!0),gt(j.url),ut(j.tier),Tt(`relay`),it(null)},className:`w-full mt-2 py-2 text-white/25 hover:text-white/40 text-[12px] transition-colors`,children:`Cancel — keep current handle`})]}),!t&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`mt-5 flex items-center gap-2`,children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-medium border ${ud(zt)?`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`:`bg-blue-500/10 text-blue-400 border-blue-500/20`}`,children:[ud(zt)?(0,G.jsx)(Te,{className:`h-3 w-3`}):(0,G.jsx)(E,{className:`h-3 w-3`}),`Accessing via `,dd[zt]]})}),!Vt&&(0,G.jsxs)(`button`,{onClick:()=>{ud(zt)&&(Ht(!0),Wt(``),Jt(``))},disabled:!ud(zt),className:`w-full mt-3 flex items-center justify-between px-4 py-3 rounded-xl border transition-all text-left ${ud(zt)?`border-white/[0.06] bg-white/[0.02] hover:border-white/10 hover:bg-white/[0.04] cursor-pointer`:`border-white/[0.04] bg-transparent opacity-50 cursor-not-allowed`}`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[13px] text-white/70 font-medium`,children:`Switch to private network only`}),(0,G.jsx)(`p`,{className:`text-[11px] text-white/30 mt-0.5`,children:ud(zt)?`Stop the tunnel and relay — access only via Tailscale or LAN`:`Connect via Tailscale or private network to unlock`})]}),(0,G.jsx)(we,{className:`h-4 w-4 text-white/30 shrink-0 ml-3`})]}),Vt&&(0,G.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,G.jsx)(`div`,{className:`bg-amber-500/8 border border-amber-500/20 rounded-xl px-4 py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(Ce,{className:`h-4 w-4 text-amber-400 shrink-0 mt-0.5`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-amber-400/90 text-[13px] font-medium`,children:`Switch to private network only?`}),(0,G.jsx)(`p`,{className:`text-amber-400/60 text-[12px] mt-1 leading-relaxed`,children:`This will stop the Cloudflare tunnel and relay connection. Your bot will only be accessible via your private network.`}),j&&(0,G.jsx)(`p`,{className:`text-amber-400/50 text-[12px] mt-1.5`,children:`Your handle will be preserved and can be re-activated later.`})]})]})}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:[`Type `,(0,G.jsx)(`span`,{className:`font-mono text-white/60`,children:`I confirm`}),` to proceed`]}),(0,G.jsx)(`input`,{type:`text`,value:Ut,onChange:e=>Wt(e.target.value),placeholder:`I confirm`,spellCheck:!1,autoFocus:!0,className:Qr})]}),qt&&(0,G.jsx)(`p`,{className:`text-red-400/70 text-[12px]`,children:qt}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`button`,{onClick:async()=>{if(!(!r||Ut.trim().toLowerCase()!==`i confirm`)){Kt(!0),Jt(``);try{await r(`off`),yt(`off`),Ht(!1)}catch(e){Jt(e.message||`Failed to switch`)}finally{Kt(!1)}}},disabled:Gt||Ut.trim().toLowerCase()!==`i confirm`||!r,className:`flex-1 py-2.5 bg-amber-600 hover:bg-amber-500 text-white text-[13px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:Gt?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Switching...`]}):`Confirm Switch`}),(0,G.jsx)(`button`,{onClick:()=>{Ht(!1),Wt(``),Jt(``)},disabled:Gt,className:`px-5 py-2.5 bg-white/[0.04] hover:bg-white/[0.08] border border-white/[0.08] text-white/60 text-[13px] font-medium rounded-full transition-colors`,children:`Cancel`})]})]})]})]}),i===3&&(0,G.jsx)(`div`,{children:(0,G.jsxs)(_l,{mode:`wait`,children:[er===`password`&&(0,G.jsxs)(sd.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.15},children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:cn?`Password & 2FA`:`Set a password`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:cn?`Your Bloby Chat password is already set — you can keep it as-is or change it below.`:`You'll need this password to access your Bloby Chat. Keep it safe — anyone with your URL will need it to log in.`}),cn&&!Sn&&(0,G.jsxs)(`div`,{className:`mt-5 flex items-center justify-between bg-white/[0.02] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white/70 text-[13px] font-medium`,children:`Bloby Chat Password`}),(0,G.jsx)(`p`,{className:`text-white/30 text-[11px] mt-0.5`,children:`Already configured.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{Cn(!0),hn(``),_n(``),yn(!1),rn(``),an(``)},className:`shrink-0 px-3.5 py-2 bg-white/[0.04] hover:bg-white/[0.08] text-white/70 hover:text-white text-[12px] font-medium rounded-lg transition-colors`,children:`Change password`})]}),cn&&Sn&&(0,G.jsxs)(`div`,{className:`mt-5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium`,children:`Current password`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{Cn(!1),hn(``),_n(``),yn(!1),rn(``),an(``)},className:`text-white/30 hover:text-white/60 text-[11px] transition-colors`,children:`Cancel`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`password`,value:mn,onChange:e=>{hn(e.target.value),_n(``),yn(!1)},placeholder:`Enter your current password`,autoComplete:`current-password`,className:Zr+` flex-1`}),mn.length>0&&!vn&&(0,G.jsx)(`button`,{onClick:async()=>{xn(!0),_n(``);try{(await(await fetch(`/api/portal/verify-password`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:mn})})).json()).valid?yn(!0):_n(`Incorrect password`)}catch{_n(`Could not verify`)}finally{xn(!1)}},disabled:bn,className:`shrink-0 px-4 py-3 bg-white/[0.06] hover:bg-white/[0.1] text-white/60 text-[13px] font-medium rounded-xl transition-colors disabled:opacity-40`,children:bn?(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}):`Verify`}),vn&&(0,G.jsx)(`div`,{className:`shrink-0 w-10 h-10 flex items-center justify-center`,children:(0,G.jsx)(ne,{className:`h-4 w-4 text-emerald-400`})})]}),gn&&(0,G.jsx)(`p`,{className:`text-red-400/70 text-[11px] mt-1`,children:gn})]}),(!cn||Sn&&vn)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:cn?`mt-3`:`mt-5`,children:[(0,G.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:cn?`New password`:`Password`}),(0,G.jsx)(`input`,{type:`password`,value:nn,onChange:e=>rn(e.target.value),placeholder:`••••••••`,autoComplete:`new-password`,autoFocus:!cn,onKeyDown:qr,className:Zr}),nn.length>0&&nn.length<6&&(0,G.jsx)(`p`,{className:`text-amber-400/70 text-[11px] mt-1`,children:`At least 6 characters`})]}),(0,G.jsxs)(`div`,{className:`mt-3`,children:[(0,G.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:cn?`Confirm new password`:`Confirm password`}),(0,G.jsx)(`input`,{type:`password`,value:F,onChange:e=>an(e.target.value),placeholder:`••••••••`,autoComplete:`new-password`,onKeyDown:qr,className:Zr}),F.length>0&&!Vr&&(0,G.jsx)(`p`,{className:`text-red-400/70 text-[11px] mt-1`,children:`Passwords don't match`})]})]}),(0,G.jsxs)(`div`,{className:`mt-5 border border-white/[0.06] rounded-xl overflow-hidden`,children:[(0,G.jsxs)(`button`,{onClick:async()=>{if(Dn&&Ln){qn(!0);return}if(Dn)On(!1),Mn(``),An(``),Pn(``);else{if(On(!0),Hn(``),In(``),cn&&!vn){Cn(!0),Hn(`Enter your current portal password above first, then toggle 2FA again.`),On(!1);return}if(jn)tr(`totp-setup`);else try{let e=await fetch(`/api/portal/totp/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:cn?mn:nn})}),t=await e.json();e.ok?(An(t.secret),Mn(t.qrDataUri),Pn(t.otpauthUri),tr(`totp-setup`)):(Hn(t.error||`Setup failed`),On(!1))}catch{Hn(`Could not reach server`),On(!1)}}},type:`button`,className:`w-full flex items-center gap-3 px-4 py-3 text-left`,children:[(0,G.jsx)(`div`,{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${Dn&&Ln?`bg-emerald-500/10`:`bg-white/[0.04]`}`,children:Dn&&Ln?(0,G.jsx)(ye,{className:`h-[18px] w-[18px] text-emerald-400`}):(0,G.jsx)(be,{className:`h-[18px] w-[18px] text-white/30`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`span`,{className:`text-[13px] font-medium text-white block`,children:`Two-Factor Auth`}),(0,G.jsx)(`p`,{className:`text-[11px] text-white/30 mt-0.5`,children:Dn&&Ln?(0,G.jsx)(`span`,{className:`text-emerald-400/70`,children:`Active — authenticator app required`}):vt===`quick`||vt===`named`?(0,G.jsx)(`span`,{children:`Recommended for public bots`}):(0,G.jsx)(`span`,{children:`Extra security with an authenticator app`})})]}),(0,G.jsx)(`div`,{className:`w-10 h-6 rounded-full transition-colors relative shrink-0 ${Dn?`bg-emerald-500`:`bg-white/10`}`,children:(0,G.jsx)(`div`,{className:`absolute top-1 w-4 h-4 rounded-full bg-white shadow transition-transform ${Dn?`translate-x-5`:`translate-x-1`}`})})]}),Kn&&(0,G.jsxs)(`div`,{className:`px-4 pb-3 border-t border-white/[0.06]`,children:[(0,G.jsx)(`p`,{className:`text-[12px] text-white/40 mt-3 mb-2`,children:`Enter your current TOTP code to disable 2FA:`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,value:Jn,onChange:e=>{Yn(e.target.value.replace(/\D/g,``)),Zn(``)},placeholder:`000000`,className:Qr+` flex-1 tracking-[0.3em] text-center font-mono`}),(0,G.jsx)(`button`,{onClick:async()=>{if(Jn.length===6)try{let e=await fetch(`/api/portal/totp/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:cn?mn:nn,code:Jn})}),t=await e.json();e.ok?(On(!1),Rn(!1),An(``),Mn(``),Pn(``),qn(!1),Yn(``),Un([]),Gn(!1)):Zn(t.error||`Failed to disable`)}catch{Zn(`Could not reach server`)}},disabled:Jn.length!==6,className:`shrink-0 px-4 py-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-400 text-[13px] font-medium rounded-xl transition-colors disabled:opacity-40`,children:`Disable`})]}),Xn&&(0,G.jsx)(`p`,{className:`text-red-400/70 text-[11px] mt-1`,children:Xn}),(0,G.jsx)(`button`,{onClick:()=>{qn(!1),Yn(``),Zn(``)},className:`text-[11px] text-white/30 hover:text-white/50 mt-2`,children:`Cancel`})]}),Vn&&er===`password`&&(0,G.jsx)(`div`,{className:`mx-4 mb-3 bg-red-500/8 border border-red-500/15 rounded-xl px-3 py-2`,children:(0,G.jsx)(`p`,{className:`text-red-400/90 text-[11px]`,children:Vn})})]}),t&&(0,G.jsxs)(`button`,{onClick:Gr,disabled:!Wr,className:`w-full mt-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Continue`,(0,G.jsx)(w,{className:`h-4 w-4`})]})]},`password`),er===`totp-setup`&&(0,G.jsxs)(sd.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.15},children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[(0,G.jsx)(`button`,{onClick:()=>{On(!1),Mn(``),An(``),Pn(``),In(``),Hn(``),tr(`password`),yr()},className:`w-7 h-7 rounded-full bg-white/[0.04] flex items-center justify-center text-white/40 hover:text-white/70 transition-colors shrink-0`,children:(0,G.jsx)(ee,{className:`h-4 w-4`})}),(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Set up 2FA`})]}),Vn&&(0,G.jsx)(`div`,{className:`mt-3 bg-red-500/8 border border-red-500/15 rounded-xl px-3 py-2`,children:(0,G.jsx)(`p`,{className:`text-red-400/90 text-[11px]`,children:Vn})}),jn&&(0,G.jsxs)(G.Fragment,{children:[Qn?(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] leading-relaxed mb-4`,children:`Add Bloby to your authenticator app, then enter the 6-digit code below to confirm.`}),(0,G.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(kn),rr(!0),setTimeout(()=>rr(!1),3e3)},className:`w-full py-3 text-[14px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 ${nr?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:`bg-white/[0.05] text-white/70 hover:bg-white/[0.08] border border-white/[0.08]`}`,children:nr?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ne,{className:`h-4 w-4`}),`Secret key copied`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(oe,{className:`h-4 w-4`}),`Copy secret key`]})}),(0,G.jsx)(`p`,{className:`text-[11px] text-white/20 text-center mt-2`,children:`Paste it in your authenticator app → Add account → Enter key`}),(0,G.jsxs)(`a`,{href:Nn,onClick:()=>_r(),className:`w-full mt-3 py-2.5 text-[13px] text-white/30 hover:text-white/50 flex items-center justify-center gap-1.5 transition-colors`,children:[(0,G.jsx)(xe,{className:`h-3.5 w-3.5`}),`Or open directly in authenticator`]})]}):(0,G.jsxs)(`div`,{className:`mt-4 flex gap-4 items-start`,children:[(0,G.jsx)(`div`,{className:`shrink-0`,children:(0,G.jsx)(`div`,{className:`bg-white rounded-xl p-1.5`,children:(0,G.jsx)(`img`,{src:jn,alt:`TOTP QR Code`,className:`w-[140px] h-[140px]`})})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] leading-relaxed`,children:`Scan this QR code with your authenticator app.`}),(0,G.jsx)(`p`,{className:`text-white/25 text-[11px] mt-2 leading-relaxed`,children:`Google Authenticator, Authy, 1Password, or any TOTP app.`}),(0,G.jsxs)(`button`,{onClick:()=>{navigator.clipboard.writeText(kn)},className:`mt-3 text-[11px] text-white/25 hover:text-white/40 flex items-center gap-1 transition-colors`,children:[(0,G.jsx)(oe,{className:`h-3 w-3`}),`Copy secret key`]})]})]}),(0,G.jsxs)(`div`,{className:`mt-5`,children:[(0,G.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:`Enter the 6-digit code from your app`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,value:Fn,onChange:e=>{In(e.target.value.replace(/\D/g,``)),Hn(``)},placeholder:`000000`,autoFocus:!0,className:Zr+` tracking-[0.3em] text-center font-mono flex-1`}),(0,G.jsx)(`button`,{onClick:async()=>{if(Fn.length===6){Bn(!0),Hn(``);try{let e=await fetch(`/api/portal/totp/verify-setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:Fn,password:cn?mn:nn})}),t=await e.json();e.ok&&t.success?(Rn(!0),Un(t.recoveryCodes||[]),tr(`recovery`),yr()):Hn(t.error||`Verification failed`)}catch{Hn(`Could not reach server`)}finally{Bn(!1)}}},disabled:Fn.length!==6||zn,className:`shrink-0 px-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-xl transition-colors flex items-center gap-2 disabled:opacity-40`,children:zn?(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}):`Verify`})]})]})]})]},`totp-setup`),er===`recovery`&&(0,G.jsxs)(sd.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.15},children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[(0,G.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-emerald-500/10 flex items-center justify-center shrink-0`,children:(0,G.jsx)(ye,{className:`h-[18px] w-[18px] text-emerald-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`2FA enabled`}),(0,G.jsx)(`p`,{className:`text-emerald-400/70 text-[12px]`,children:`Save your recovery codes`})]})]}),(0,G.jsx)(`p`,{className:`text-white/35 text-[13px] mt-3 leading-relaxed`,children:`If you lose your authenticator app, you can use one of these codes to sign in. Each code works once. Store them somewhere safe.`}),(0,G.jsx)(`div`,{className:`mt-4 grid grid-cols-2 gap-1.5`,children:L.map((e,t)=>(0,G.jsx)(`div`,{className:`bg-white/[0.03] border border-white/[0.06] rounded-lg px-3 py-2 text-center`,children:(0,G.jsx)(`code`,{className:`text-[13px] text-white/60 font-mono tracking-wider`,children:e})},t))}),(0,G.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(L.join(`
26
- `)),Gn(!0)},className:`w-full mt-4 py-3 text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 ${Wn?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:`bg-white/[0.05] text-white/60 hover:bg-white/[0.08] border border-white/[0.08]`}`,children:Wn?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ne,{className:`h-4 w-4`}),`Copied`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(oe,{className:`h-4 w-4`}),`Copy recovery codes`]})}),(0,G.jsxs)(`button`,{onClick:()=>{Un([]),tr(`password`),yr()},disabled:!Wn,className:`w-full mt-3 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Done`,(0,G.jsx)(w,{className:`h-4 w-4`})]})]},`recovery`)]})}),i===4&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Choose your AI provider`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`Pick one provider to power your bot, authenticate, and select a model.`}),(0,G.jsx)(`div`,{className:`flex gap-2.5 mt-4`,children:pd.map(e=>(0,G.jsxs)(`button`,{onClick:()=>wr(e.id),className:`flex-1 relative rounded-xl border transition-all duration-200 p-3 text-left ${c===e.id?`bg-white/[0.04] border-[#0069FE]/40`:`bg-transparent border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 py-0.5`,children:[(()=>{let t=e.iconHeight??fd;return(0,G.jsx)(`div`,{className:`flex items-center justify-center`,style:{height:`${Math.max(fd,t)}px`},children:e.icon?(0,G.jsx)(`img`,{src:e.icon,alt:e.name,className:`w-auto object-contain`,style:{height:`${t}px`}}):(0,G.jsx)(`div`,{className:`rounded-lg bg-white/[0.06] flex items-center justify-center text-white/50 text-sm font-bold`,style:{height:`${t}px`,width:`${t}px`}})})})(),(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(`div`,{className:`text-[13px] font-medium text-white`,children:e.name}),(0,G.jsx)(`div`,{className:`text-[10px] text-white/30 whitespace-pre-line leading-tight`,children:e.subtitle})]})]}),m[e.id]===`connected`?(0,G.jsx)(`div`,{className:`absolute top-2 right-2 w-4 h-4 rounded-full bg-emerald-500/15 flex items-center justify-center`,children:(0,G.jsx)(ne,{className:`h-2.5 w-2.5 text-emerald-400`})}):c===e.id?(0,G.jsx)(`div`,{className:`absolute top-2 right-2 w-2 h-2 rounded-full bg-gradient-brand`}):null]},e.id))}),(0,G.jsx)(`div`,{className:`border-t border-white/[0.06] mt-4 mb-3`}),c===`pi`&&(0,G.jsx)(`div`,{className:`space-y-2`,children:m.pi===`connected`&&he?(0,G.jsxs)(`div`,{className:`flex items-center justify-between bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3 py-2`,children:[(0,G.jsxs)(`p`,{className:`text-emerald-400/90 text-[12px] truncate`,children:[`Connected — `,g.find(e=>e.id===he.subProvider)?.name||he.subProvider,he.modelId?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(`span`,{className:`font-mono`,children:he.modelId})]}):null]}),(0,G.jsxs)(`button`,{onClick:Or,className:`text-white/30 hover:text-white/60 text-[11px] flex items-center gap-1 shrink-0 ml-2`,children:[(0,G.jsx)(_e,{className:`h-3 w-3`}),`Change`]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-white/40 font-medium mb-1 block`,children:`Provider`}),(0,G.jsx)(hd,{models:g.map(e=>({id:e.id,label:e.name})),value:y,onChange:Er})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-white/40 font-medium mb-1 block`,children:`Model`}),Tr&&Array.isArray(Tr.models)?(0,G.jsx)(hd,{models:Tr.models,value:re,onChange:ae}):(0,G.jsx)(`input`,{type:`text`,value:re,onChange:e=>ae(e.target.value),placeholder:Tr?.defaultModel||`model-id`,className:Qr+` font-mono`})]})]}),Tr?.needsBaseUrl&&(0,G.jsx)(`input`,{type:`text`,value:C,onChange:e=>te(e.target.value),placeholder:Tr.baseUrl||`https://example.com/v1`,className:Qr+` font-mono`}),Tr?.needsApiKey&&(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:se?`text`:`password`,value:x,onChange:e=>S(e.target.value),onKeyDown:e=>e.key===`Enter`&&Dr(),placeholder:`API key…`,className:Qr+` pr-16 font-mono`}),(0,G.jsxs)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1.5`,children:[Tr.apiKeyUrl&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>kr(Tr.apiKeyUrl),className:`text-white/25 hover:text-white/55 transition-colors`,title:`Get a key`,children:(0,G.jsx)(ce,{className:`h-3.5 w-3.5`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>T(e=>!e),className:`text-white/25 hover:text-white/55 transition-colors`,children:se?(0,G.jsx)(le,{className:`h-3.5 w-3.5`}):(0,G.jsx)(ue,{className:`h-3.5 w-3.5`})})]})]}),me&&(0,G.jsx)(`div`,{className:`bg-red-500/8 border border-red-500/15 rounded-lg px-3 py-2`,children:(0,G.jsx)(`p`,{className:`text-[12px] text-red-400/90 break-words`,children:me})}),(0,G.jsx)(`button`,{onClick:Dr,disabled:de||!y||!!Tr?.needsApiKey&&!x.trim()||!!Tr?.needsBaseUrl&&!C.trim()||!re.trim(),className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:de?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}),`Connecting…`]}):(0,G.jsxs)(G.Fragment,{children:[`Test & connect`,(0,G.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})})]})}),c===`bloby`&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-[12px] text-white/40 leading-relaxed`,children:`Bloby (managed) is on the way. Sign in with Google once it ships and your bot will be hosted, updated, and billed by us — no API keys to manage.`}),(0,G.jsxs)(`button`,{type:`button`,disabled:!0,title:`Coming soon`,className:`w-full py-2.5 px-4 bg-white/[0.04] border border-white/[0.06] text-white/35 text-[13px] font-medium rounded-xl flex items-center justify-center gap-2 cursor-not-allowed`,children:[(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 opacity-50`,fill:`currentColor`,children:(0,G.jsx)(`path`,{d:`M21.35 11.1h-9.17v2.96h5.27c-.23 1.39-1.62 4.08-5.27 4.08-3.17 0-5.76-2.62-5.76-5.85s2.59-5.85 5.76-5.85c1.81 0 3.02.77 3.71 1.43l2.53-2.43C16.85 3.91 14.74 3 12.18 3 7.03 3 2.86 7.17 2.86 12.29s4.17 9.29 9.32 9.29c5.38 0 8.94-3.79 8.94-9.12 0-.61-.07-1.08-.17-1.55Z`})}),`Login with Google`]}),(0,G.jsx)(`p`,{className:`text-[10.5px] text-white/25 text-center`,children:`Not available yet.`})]}),c===`anthropic`&&(0,G.jsxs)(`div`,{className:`space-y-2.5`,children:[hr&&(0,G.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,G.jsx)(`div`,{className:`bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5`,children:(0,G.jsx)(`p`,{className:`text-emerald-400/90 text-[12px]`,children:`Connected — Anthropic subscription is active.`})}),(0,G.jsxs)(`button`,{onClick:()=>{h(e=>({...e,anthropic:`idle`})),Se(!1),Oe(``),Me(``)},className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5`,children:[(0,G.jsx)(_e,{className:`h-3 w-3`}),`Re-authenticate`]})]}),!hr&&(0,G.jsxs)(G.Fragment,{children:[je&&(0,G.jsx)(`div`,{className:`bg-red-500/8 border border-red-500/15 rounded-lg px-3.5 py-2.5`,children:(0,G.jsx)(`p`,{className:`text-red-400/90 text-[12px]`,children:je})}),(0,G.jsx)(`div`,{className:`space-y-1.5`,children:[`Click the button below to open Anthropic's login page`,`Sign in with your Anthropic account — a code will be generated`,`Copy the code and paste it in the field below`].map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`flex-shrink-0 w-[18px] h-[18px] rounded-full bg-white/[0.06] text-white/30 text-[10px] font-medium flex items-center justify-center mt-px`,children:t+1}),(0,G.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:e})]},t))}),(0,G.jsx)(`button`,{onClick:Ar,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2`,children:ve?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ce,{className:`h-3.5 w-3.5 opacity-60`}),`Open authentication page again`]}):(0,G.jsxs)(G.Fragment,{children:[`Authenticate with Anthropic`,(0,G.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:`text`,value:De,onChange:e=>Oe(e.target.value),onKeyDown:e=>e.key===`Enter`&&jr(),placeholder:`Paste your code here...`,className:Qr+` pr-10 font-mono`}),(0,G.jsx)(`button`,{onClick:Mr,className:`absolute right-3 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/50 transition-colors`,children:(0,G.jsx)(ie,{className:`h-3.5 w-3.5`})})]}),(0,G.jsx)(`button`,{onClick:jr,disabled:!De.trim()||ke,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:ke?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}),`Verifying...`]}):`Connect`}),(0,G.jsxs)(`button`,{onClick:Nr,disabled:Ne,className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5 disabled:opacity-50`,children:[Ne?(0,G.jsx)(D,{className:`h-3 w-3 animate-spin`}):(0,G.jsx)(_e,{className:`h-3 w-3`}),Ne?`Checking...`:`I'm already authenticated`]})]})]}),c===`openai`&&(0,G.jsxs)(`div`,{className:`space-y-2.5`,children:[hr&&(0,G.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,G.jsx)(`div`,{className:`bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5`,children:(0,G.jsx)(`p`,{className:`text-emerald-400/90 text-[12px]`,children:`Connected — ChatGPT subscription is active.`})}),(0,G.jsxs)(`button`,{onClick:()=>{h(e=>({...e,openai:`idle`})),$e(``)},className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5`,children:[(0,G.jsx)(_e,{className:`h-3 w-3`}),`Re-authenticate`]})]}),!hr&&(0,G.jsxs)(G.Fragment,{children:[Qe&&(0,G.jsx)(`div`,{className:`bg-red-500/8 border border-red-500/15 rounded-lg px-3.5 py-2.5`,children:(0,G.jsx)(`p`,{className:`text-red-400/90 text-[12px]`,children:Qe})}),Fe===`device`&&Le!==`pending`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`space-y-1.5`,children:[`Click below — we'll open auth.openai.com/codex/device for you`,`Sign in with your ChatGPT Plus or Pro account`,`Type the one-time code shown here on that page`].map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`flex-shrink-0 w-[18px] h-[18px] rounded-full bg-white/[0.06] text-white/30 text-[10px] font-medium flex items-center justify-center mt-px`,children:t+1}),(0,G.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:e})]},t))}),(0,G.jsx)(`button`,{onClick:Pr,disabled:Ue,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-60`,children:Ue?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}),`Requesting code...`]}):(0,G.jsxs)(G.Fragment,{children:[`Sign in with ChatGPT`,(0,G.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})})]}),Fe===`device`&&Le===`pending`&&ze&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`bg-white/[0.03] border border-white/[0.06] rounded-xl p-4`,children:[(0,G.jsx)(`p`,{className:`text-[11px] text-white/40 mb-1`,children:`1. Open this URL in any browser`}),(0,G.jsxs)(`button`,{onClick:()=>kr(Ve),className:`w-full text-left py-2 px-3 bg-white/[0.04] hover:bg-white/[0.07] rounded-lg text-[12px] font-mono text-white/80 flex items-center justify-between transition-colors`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:Ve}),(0,G.jsx)(ce,{className:`h-3.5 w-3.5 ml-2 opacity-60 shrink-0`})]}),(0,G.jsx)(`p`,{className:`text-[11px] text-white/40 mt-3 mb-1`,children:`2. Enter this code`}),(0,G.jsxs)(`button`,{onClick:Ir,className:`w-full py-3 px-3 bg-white/[0.04] hover:bg-white/[0.07] rounded-lg text-center transition-colors flex items-center justify-center gap-3 group`,children:[(0,G.jsx)(`span`,{className:`text-[20px] font-mono font-semibold text-white tracking-widest`,children:ze}),Ge?(0,G.jsx)(ne,{className:`h-4 w-4 text-emerald-400`}):(0,G.jsx)(oe,{className:`h-4 w-4 text-white/30 group-hover:text-white/60`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 mt-3 text-[11px] text-white/40`,children:[(0,G.jsx)(D,{className:`h-3 w-3 animate-spin`}),`Waiting for you to approve...`]})]}),(0,G.jsx)(`button`,{onClick:Fr,className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors`,children:`Cancel`})]}),Fe===`paste`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`space-y-1.5`,children:[`Click below to open ChatGPT sign-in`,`Sign in with your ChatGPT Plus or Pro account`,`Your browser will say "site can't be reached" — that's expected. Copy the FULL URL from the address bar and paste it below.`].map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`flex-shrink-0 w-[18px] h-[18px] rounded-full bg-white/[0.06] text-white/30 text-[10px] font-medium flex items-center justify-center mt-px`,children:t+1}),(0,G.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:e})]},t))}),(0,G.jsx)(`button`,{onClick:Lr,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2`,children:k?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ce,{className:`h-3.5 w-3.5 opacity-60`}),`Open authentication page again`]}):(0,G.jsxs)(G.Fragment,{children:[`Authenticate with ChatGPT`,(0,G.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:`text`,value:Je,onChange:e=>Ye(e.target.value),onKeyDown:e=>e.key===`Enter`&&Rr(),placeholder:`Paste callback URL or code here...`,className:Qr+` pr-10 font-mono`}),(0,G.jsx)(`button`,{onClick:zr,className:`absolute right-3 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/50 transition-colors`,children:(0,G.jsx)(ie,{className:`h-3.5 w-3.5`})})]}),(0,G.jsx)(`button`,{onClick:Rr,disabled:!Je.trim()||Xe,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:Xe?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}),`Verifying...`]}):`Connect`})]}),Le!==`pending`&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,children:[(0,G.jsx)(`button`,{onClick:()=>{$e(void 0),Ie(Fe===`device`?`paste`:`device`)},className:`text-white/25 text-[11px] hover:text-white/40 transition-colors`,children:Fe===`device`?`Use callback URL instead`:`Use device code instead`}),(0,G.jsxs)(`button`,{onClick:Br,disabled:et,className:`text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center gap-1.5 disabled:opacity-50`,children:[et?(0,G.jsx)(D,{className:`h-3 w-3 animate-spin`}):(0,G.jsx)(_e,{className:`h-3 w-3`}),et?`Checking...`:`I'm already authenticated`]})]})]})]}),hr&&c!==`pi`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`border-t border-white/[0.06] mt-4 mb-3`}),(0,G.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:`Select a model`}),(0,G.jsx)(hd,{models:md[c]||[],value:u,onChange:d})]}),t&&hr&&(0,G.jsxs)(`button`,{onClick:Gr,disabled:!Wr,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Continue`,(0,G.jsx)(w,{className:`h-4 w-4`})]})]}),i===5&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight mb-1`,children:`Voice Messages`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1 leading-relaxed`,children:`Voice input works out of the box using your browser's built-in speech recognition. For better accuracy, you can optionally enable OpenAI Whisper.`}),(0,G.jsx)(`div`,{className:`w-full mt-5 rounded-xl border border-emerald-500/20 bg-emerald-500/[0.04] p-4`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3.5`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-emerald-500/10 flex items-center justify-center shrink-0`,children:(0,G.jsx)(pe,{className:`h-5 w-5 text-emerald-400`})}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-[14px] font-medium text-white`,children:`Browser Speech Recognition`}),(0,G.jsx)(`div`,{className:`text-[12px] text-white/35 mt-0.5 leading-relaxed`,children:`Built-in voice input — no setup needed. Works in Chrome, Edge, and Safari.`})]}),(0,G.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6 rounded-full bg-emerald-500/20 shrink-0`,children:(0,G.jsx)(ne,{className:`h-3.5 w-3.5 text-emerald-400`})})]})}),(0,G.jsx)(`button`,{onClick:()=>wn(e=>!e),className:`w-full mt-3 rounded-xl border transition-all duration-200 p-4 text-left ${I?`bg-white/[0.04] border-[#0069FE]/40`:`bg-transparent border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3.5`,children:[(0,G.jsx)(`img`,{src:`/icons/openai.svg`,alt:`OpenAI`,className:`w-10 h-10 rounded-xl bg-white/[0.04] p-1.5`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-[14px] font-medium text-white`,children:`OpenAI Whisper`}),(0,G.jsx)(`div`,{className:`text-[12px] text-white/35 mt-0.5 leading-relaxed`,children:`Upgrade to more accurate transcription that works in all browsers including Firefox.`})]}),(0,G.jsx)(`div`,{className:`w-10 h-[22px] rounded-full transition-colors duration-200 flex items-center px-0.5 shrink-0 ${I?`bg-gradient-brand`:`bg-white/[0.08]`}`,children:(0,G.jsx)(`div`,{className:`w-[18px] h-[18px] rounded-full bg-white shadow-sm transition-transform duration-200 ${I?`translate-x-[18px]`:`translate-x-0`}`})})]})}),I&&(0,G.jsxs)(`div`,{className:`mt-3`,children:[(0,G.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:`OpenAI API Key`}),(0,G.jsx)(`input`,{type:`password`,value:Tn,onChange:e=>En(e.target.value.trim()),placeholder:`sk-...`,autoComplete:`off`,className:Zr+` font-mono text-[13px]`}),Tn.length>0&&!Tn.startsWith(`sk-`)&&(0,G.jsx)(`p`,{className:`text-amber-400/70 text-[11px] mt-1`,children:`Key should start with sk-`}),Tn.length>0&&Tn.startsWith(`sk-`)&&Tn.length<20&&(0,G.jsx)(`p`,{className:`text-amber-400/70 text-[11px] mt-1`,children:`Key looks too short`}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2.5 mt-3 bg-white/[0.02] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,G.jsx)(pe,{className:`h-4 w-4 text-[#0069FE]/60 mt-0.5 shrink-0`}),(0,G.jsx)(`p`,{className:`text-white/35 text-[12px] leading-relaxed`,children:`Whisper provides more accurate transcription and works in all browsers including Firefox.`})]})]}),t&&(0,G.jsx)(`button`,{onClick:Xr,disabled:f||I&&(!Tn.startsWith(`sk-`)||Tn.length<20),className:`w-full mt-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:f?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Setting up...`]}):(0,G.jsxs)(G.Fragment,{children:[`Complete Setup`,(0,G.jsx)(w,{className:`h-4 w-4`})]})}),!I&&(0,G.jsx)(`p`,{className:`text-center text-white/20 text-[11px] mt-2.5`,children:`Voice input is active using your browser's built-in speech recognition.`})]}),i===6&&t&&(()=>{let e=vt===`off`,t=e?window.location.origin:vt===`named`?`https://${bt}`:wt===`relay`&&ht?ht:St||`http://localhost:3000`,n=t.startsWith(`http`)?t:`https://${t}`;return(0,G.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,G.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center mb-5`,children:(0,G.jsx)(ne,{className:`h-8 w-8 text-emerald-400`})}),(0,G.jsx)(`h1`,{className:`text-2xl font-bold text-white tracking-tight`,children:`All Set!`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-2 leading-relaxed max-w-[340px]`,children:e?`Your agent is running on your private network. Access it from any device on your local network or VPN.`:vt===`named`?`Access your agent at your custom domain.`:wt===`relay`&&ht?`Your agent is live and ready. From now on, access it using your custom URL below.`:`Your agent is live and ready. Your tunnel URL is shown below. Note: this URL changes on restart.`}),(0,G.jsxs)(`div`,{className:`w-full mt-6 flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[13px] text-white/70 truncate flex-1 text-left`,children:t}),(0,G.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(n),sn(!0),setTimeout(()=>sn(!1),2e3)},className:`shrink-0 text-white/30 hover:text-white/60 transition-colors`,children:on?(0,G.jsx)(ne,{className:`h-4 w-4 text-emerald-400`}):(0,G.jsxs)(`svg`,{className:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:[(0,G.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,G.jsx)(`path`,{d:`M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1`})]})})]}),(0,G.jsxs)(`div`,{className:`w-full mt-3`,children:[(0,G.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block text-left`,children:`Your password`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[13px] text-white/70 truncate flex-1 text-left`,children:un?nn:`•`.repeat(Math.max(nn.length,8))}),(0,G.jsx)(`button`,{onClick:()=>dn(e=>!e),className:`shrink-0 text-white/30 hover:text-white/60 transition-colors`,children:un?(0,G.jsx)(le,{className:`h-4 w-4`}):(0,G.jsx)(ue,{className:`h-4 w-4`})})]})]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2.5 mt-6 cursor-pointer text-left select-none`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:fn,onChange:e=>pn(e.target.checked),className:`mt-0.5 h-4 w-4 rounded border-white/20 bg-white/5 accent-emerald-500 shrink-0`}),(0,G.jsxs)(`span`,{className:`text-[12px] text-white/50 leading-relaxed`,children:[`I accept the`,` `,(0,G.jsx)(`a`,{href:`https://www.bloby.bot/terms`,target:`_blank`,rel:`noopener noreferrer`,className:`text-white/70 underline hover:text-white/90`,children:`terms`}),` `,`and`,` `,(0,G.jsx)(`a`,{href:`https://www.bloby.bot/privacy`,target:`_blank`,rel:`noopener noreferrer`,className:`text-white/70 underline hover:text-white/90`,children:`privacy policy`})]})]}),(0,G.jsxs)(`button`,{disabled:!fn,onClick:()=>{e?(window.top||window).location.href=`/`:(window.top||window).location.href=n},className:`w-full mt-4 py-3 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 ${fn?`bg-gradient-brand hover:opacity-90`:`bg-white/10 cursor-not-allowed opacity-50`}`,children:[e?`Go to dashboard`:`Go to your agent`,(0,G.jsx)(ce,{className:`h-4 w-4`})]}),(0,G.jsx)(`p`,{className:`text-white/20 text-[11px] mt-3 leading-relaxed`,children:e?`Access from any device on your network using the URL above.`:`You'll be redirected to your ${vt===`named`?`custom domain`:wt===`relay`?`custom URL`:`tunnel URL`}.`})]})})(),i===6&&!t&&(0,G.jsx)(yd,{cacheRef:ar}),i===7&&!t&&(0,G.jsx)(Od,{cacheRef:or})]},i)}),t&&i>0&&i<6&&(0,G.jsx)(`div`,{className:`px-8 pb-5 -mt-3`,children:(0,G.jsx)(`button`,{onClick:Kr,className:`text-white/25 hover:text-white/50 text-[12px] transition-colors`,children:`← Back`})}),!t&&i>=1&&i<=5&&(Jr||lr||dr||pr)&&(0,G.jsxs)(`div`,{className:`px-8 pb-6 -mt-2`,children:[pr&&(0,G.jsxs)(`p`,{className:`text-red-400 text-[12px] mb-2 flex items-center gap-1.5`,children:[(0,G.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0`}),pr]}),dr&&!Jr?(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-3 text-emerald-400 text-[13px] font-medium`,children:[(0,G.jsx)(ne,{className:`h-4 w-4`}),` Saved`]}):(0,G.jsx)(`button`,{onClick:Yr,disabled:lr||!Jr,className:`w-full py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40 disabled:cursor-not-allowed`,children:lr?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Saving...`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ne,{className:`h-4 w-4`}),`Save changes`]})})]})]})]})}export{w as C,d as E,ne as S,S as T,fe as _,Me as a,se as b,je as c,xe as d,be as f,D as g,pe as h,Pe as i,Ee as l,O as m,sd as n,Ae as o,he as p,_l as r,Ne as s,kd as t,Se as u,E as v,ee as w,oe as x,ce as y};
26
+ `)),Gn(!0)},className:`w-full mt-4 py-3 text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 ${Wn?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:`bg-white/[0.05] text-white/60 hover:bg-white/[0.08] border border-white/[0.08]`}`,children:Wn?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ne,{className:`h-4 w-4`}),`Copied`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(oe,{className:`h-4 w-4`}),`Copy recovery codes`]})}),(0,G.jsxs)(`button`,{onClick:()=>{Un([]),tr(`password`),yr()},disabled:!Wn,className:`w-full mt-3 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Done`,(0,G.jsx)(w,{className:`h-4 w-4`})]})]},`recovery`)]})}),i===4&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Choose your AI provider`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`Pick one provider to power your bot, authenticate, and select a model.`}),(0,G.jsx)(`div`,{className:`flex gap-2.5 mt-4`,children:pd.map(e=>(0,G.jsxs)(`button`,{onClick:()=>wr(e.id),className:`flex-1 relative rounded-xl border transition-all duration-200 p-3 text-left ${c===e.id?`bg-white/[0.04] border-[#0069FE]/40`:`bg-transparent border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 py-0.5`,children:[(()=>{let t=e.iconHeight??fd;return(0,G.jsx)(`div`,{className:`flex items-center justify-center`,style:{height:`${Math.max(fd,t)}px`},children:e.icon?(0,G.jsx)(`img`,{src:e.icon,alt:e.name,className:`w-auto object-contain`,style:{height:`${t}px`}}):(0,G.jsx)(`div`,{className:`rounded-lg bg-white/[0.06] flex items-center justify-center text-white/50 text-sm font-bold`,style:{height:`${t}px`,width:`${t}px`}})})})(),(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(`div`,{className:`text-[13px] font-medium text-white`,children:e.name}),(0,G.jsx)(`div`,{className:`text-[10px] text-white/30 whitespace-pre-line leading-tight`,children:e.subtitle})]})]}),m[e.id]===`connected`?(0,G.jsx)(`div`,{className:`absolute top-2 right-2 w-4 h-4 rounded-full bg-emerald-500/15 flex items-center justify-center`,children:(0,G.jsx)(ne,{className:`h-2.5 w-2.5 text-emerald-400`})}):c===e.id?(0,G.jsx)(`div`,{className:`absolute top-2 right-2 w-2 h-2 rounded-full bg-gradient-brand`}):null]},e.id))}),(0,G.jsx)(`div`,{className:`border-t border-white/[0.06] mt-4 mb-3`}),c===`pi`&&(0,G.jsx)(`div`,{className:`space-y-2`,children:m.pi===`connected`&&he?(0,G.jsxs)(`div`,{className:`flex items-center justify-between bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3 py-2`,children:[(0,G.jsxs)(`p`,{className:`text-emerald-400/90 text-[12px] truncate`,children:[`Connected — `,g.find(e=>e.id===he.subProvider)?.name||he.subProvider,he.modelId?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(`span`,{className:`font-mono`,children:he.modelId})]}):null]}),(0,G.jsxs)(`button`,{onClick:Or,className:`text-white/30 hover:text-white/60 text-[11px] flex items-center gap-1 shrink-0 ml-2`,children:[(0,G.jsx)(_e,{className:`h-3 w-3`}),`Change`]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-white/40 font-medium mb-1 block`,children:`Provider`}),(0,G.jsx)(hd,{models:g.map(e=>({id:e.id,label:e.name})),value:y,onChange:Er})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-white/40 font-medium mb-1 block`,children:`Model`}),Tr&&Array.isArray(Tr.models)?(0,G.jsx)(hd,{models:Tr.models,value:re,onChange:ae}):(0,G.jsx)(`input`,{type:`text`,value:re,onChange:e=>ae(e.target.value),placeholder:Tr?.defaultModel||`model-id`,className:Qr+` font-mono`})]})]}),Tr?.needsBaseUrl&&(0,G.jsx)(`input`,{type:`text`,value:C,onChange:e=>te(e.target.value),placeholder:Tr.baseUrl||`https://example.com/v1`,className:Qr+` font-mono`}),Tr?.needsApiKey&&(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:se?`text`:`password`,value:x,onChange:e=>S(e.target.value),onKeyDown:e=>e.key===`Enter`&&Dr(),placeholder:`API key…`,className:Qr+` pr-16 font-mono`}),(0,G.jsxs)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1.5`,children:[Tr.apiKeyUrl&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>kr(Tr.apiKeyUrl),className:`text-white/25 hover:text-white/55 transition-colors`,title:`Get a key`,children:(0,G.jsx)(ce,{className:`h-3.5 w-3.5`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>T(e=>!e),className:`text-white/25 hover:text-white/55 transition-colors`,children:se?(0,G.jsx)(le,{className:`h-3.5 w-3.5`}):(0,G.jsx)(ue,{className:`h-3.5 w-3.5`})})]})]}),me&&(0,G.jsx)(`div`,{className:`bg-red-500/8 border border-red-500/15 rounded-lg px-3 py-2`,children:(0,G.jsx)(`p`,{className:`text-[12px] text-red-400/90 break-words`,children:me})}),(0,G.jsx)(`button`,{onClick:Dr,disabled:de||!y||!!Tr?.needsApiKey&&!x.trim()||!!Tr?.needsBaseUrl&&!C.trim()||!re.trim(),className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:de?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}),`Connecting…`]}):(0,G.jsxs)(G.Fragment,{children:[`Test & connect`,(0,G.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})})]})}),c===`bloby`&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-[12px] text-white/40 leading-relaxed`,children:`Bloby (managed) is on the way. Sign in with Google once it ships and your bot will be hosted, updated, and billed by us — no API keys to manage.`}),(0,G.jsxs)(`button`,{type:`button`,disabled:!0,title:`Coming soon`,className:`w-full py-2.5 px-4 bg-white/[0.04] border border-white/[0.06] text-white/35 text-[13px] font-medium rounded-xl flex items-center justify-center gap-2 cursor-not-allowed`,children:[(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 opacity-50`,fill:`currentColor`,children:(0,G.jsx)(`path`,{d:`M21.35 11.1h-9.17v2.96h5.27c-.23 1.39-1.62 4.08-5.27 4.08-3.17 0-5.76-2.62-5.76-5.85s2.59-5.85 5.76-5.85c1.81 0 3.02.77 3.71 1.43l2.53-2.43C16.85 3.91 14.74 3 12.18 3 7.03 3 2.86 7.17 2.86 12.29s4.17 9.29 9.32 9.29c5.38 0 8.94-3.79 8.94-9.12 0-.61-.07-1.08-.17-1.55Z`})}),`Login with Google`]}),(0,G.jsx)(`p`,{className:`text-[10.5px] text-white/25 text-center`,children:`Not available yet.`})]}),c===`anthropic`&&(0,G.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-amber-500/20 bg-amber-500/[0.06] px-4 py-3.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,G.jsx)(Ce,{className:`h-4 w-4 text-amber-400 shrink-0`}),(0,G.jsx)(`h3`,{className:`text-[12.5px] font-semibold text-amber-200/90`,children:`Anthropic Third-Party App Policy Update`})]}),(0,G.jsxs)(`div`,{className:`space-y-2 text-amber-100/70 text-[12px] leading-relaxed`,children:[(0,G.jsx)(`p`,{children:`Starting June 15, 2026, Anthropic will provide a separate Third-Party App credit equal to the amount you pay for your subscription.`}),(0,G.jsx)(`p`,{children:`For example, if you have the Max 5x plan at $100/month, you will receive $100 in credits to use with third-party tools like Bloby.`}),(0,G.jsx)(`p`,{children:`Unfortunately, this is only a fraction of the usage Bloby users had before. We don't control Anthropic's rules, but we do need to follow them.`}),(0,G.jsxs)(`p`,{children:[`The best alternative right now is a `,(0,G.jsx)(`span`,{className:`font-medium text-amber-100/90`,children:`ChatGPT subscription`}),`, which also offers $100 and $200 plans with much higher usage limits for Bloby.`]}),(0,G.jsx)(`p`,{children:`In the short term, Bloby will be optimized for ChatGPT. In the long term, we are building our own model harness so Bloby has more control, more flexibility, and does not depend too heavily on providers that can change their rules at any moment.`})]})]}),hr&&(0,G.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,G.jsx)(`div`,{className:`bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5`,children:(0,G.jsx)(`p`,{className:`text-emerald-400/90 text-[12px]`,children:`Connected — Anthropic subscription is active.`})}),(0,G.jsxs)(`button`,{onClick:()=>{h(e=>({...e,anthropic:`idle`})),Se(!1),Oe(``),Me(``)},className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5`,children:[(0,G.jsx)(_e,{className:`h-3 w-3`}),`Re-authenticate`]})]}),!hr&&(0,G.jsxs)(G.Fragment,{children:[je&&(0,G.jsx)(`div`,{className:`bg-red-500/8 border border-red-500/15 rounded-lg px-3.5 py-2.5`,children:(0,G.jsx)(`p`,{className:`text-red-400/90 text-[12px]`,children:je})}),(0,G.jsx)(`div`,{className:`space-y-1.5`,children:[`Click the button below to open Anthropic's login page`,`Sign in with your Anthropic account — a code will be generated`,`Copy the code and paste it in the field below`].map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`flex-shrink-0 w-[18px] h-[18px] rounded-full bg-white/[0.06] text-white/30 text-[10px] font-medium flex items-center justify-center mt-px`,children:t+1}),(0,G.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:e})]},t))}),(0,G.jsx)(`button`,{onClick:Ar,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2`,children:ve?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ce,{className:`h-3.5 w-3.5 opacity-60`}),`Open authentication page again`]}):(0,G.jsxs)(G.Fragment,{children:[`Authenticate with Anthropic`,(0,G.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:`text`,value:De,onChange:e=>Oe(e.target.value),onKeyDown:e=>e.key===`Enter`&&jr(),placeholder:`Paste your code here...`,className:Qr+` pr-10 font-mono`}),(0,G.jsx)(`button`,{onClick:Mr,className:`absolute right-3 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/50 transition-colors`,children:(0,G.jsx)(ie,{className:`h-3.5 w-3.5`})})]}),(0,G.jsx)(`button`,{onClick:jr,disabled:!De.trim()||ke,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:ke?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}),`Verifying...`]}):`Connect`}),(0,G.jsxs)(`button`,{onClick:Nr,disabled:Ne,className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5 disabled:opacity-50`,children:[Ne?(0,G.jsx)(D,{className:`h-3 w-3 animate-spin`}):(0,G.jsx)(_e,{className:`h-3 w-3`}),Ne?`Checking...`:`I'm already authenticated`]})]})]}),c===`openai`&&(0,G.jsxs)(`div`,{className:`space-y-2.5`,children:[hr&&(0,G.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,G.jsx)(`div`,{className:`bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5`,children:(0,G.jsx)(`p`,{className:`text-emerald-400/90 text-[12px]`,children:`Connected — ChatGPT subscription is active.`})}),(0,G.jsxs)(`button`,{onClick:()=>{h(e=>({...e,openai:`idle`})),$e(``)},className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5`,children:[(0,G.jsx)(_e,{className:`h-3 w-3`}),`Re-authenticate`]})]}),!hr&&(0,G.jsxs)(G.Fragment,{children:[Qe&&(0,G.jsx)(`div`,{className:`bg-red-500/8 border border-red-500/15 rounded-lg px-3.5 py-2.5`,children:(0,G.jsx)(`p`,{className:`text-red-400/90 text-[12px]`,children:Qe})}),Fe===`device`&&Le!==`pending`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`space-y-1.5`,children:[`Click below — we'll open auth.openai.com/codex/device for you`,`Sign in with your ChatGPT Plus or Pro account`,`Type the one-time code shown here on that page`].map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`flex-shrink-0 w-[18px] h-[18px] rounded-full bg-white/[0.06] text-white/30 text-[10px] font-medium flex items-center justify-center mt-px`,children:t+1}),(0,G.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:e})]},t))}),(0,G.jsx)(`button`,{onClick:Pr,disabled:Ue,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-60`,children:Ue?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}),`Requesting code...`]}):(0,G.jsxs)(G.Fragment,{children:[`Sign in with ChatGPT`,(0,G.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})})]}),Fe===`device`&&Le===`pending`&&ze&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`bg-white/[0.03] border border-white/[0.06] rounded-xl p-4`,children:[(0,G.jsx)(`p`,{className:`text-[11px] text-white/40 mb-1`,children:`1. Open this URL in any browser`}),(0,G.jsxs)(`button`,{onClick:()=>kr(Ve),className:`w-full text-left py-2 px-3 bg-white/[0.04] hover:bg-white/[0.07] rounded-lg text-[12px] font-mono text-white/80 flex items-center justify-between transition-colors`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:Ve}),(0,G.jsx)(ce,{className:`h-3.5 w-3.5 ml-2 opacity-60 shrink-0`})]}),(0,G.jsx)(`p`,{className:`text-[11px] text-white/40 mt-3 mb-1`,children:`2. Enter this code`}),(0,G.jsxs)(`button`,{onClick:Ir,className:`w-full py-3 px-3 bg-white/[0.04] hover:bg-white/[0.07] rounded-lg text-center transition-colors flex items-center justify-center gap-3 group`,children:[(0,G.jsx)(`span`,{className:`text-[20px] font-mono font-semibold text-white tracking-widest`,children:ze}),Ge?(0,G.jsx)(ne,{className:`h-4 w-4 text-emerald-400`}):(0,G.jsx)(oe,{className:`h-4 w-4 text-white/30 group-hover:text-white/60`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 mt-3 text-[11px] text-white/40`,children:[(0,G.jsx)(D,{className:`h-3 w-3 animate-spin`}),`Waiting for you to approve...`]})]}),(0,G.jsx)(`button`,{onClick:Fr,className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors`,children:`Cancel`})]}),Fe===`paste`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`space-y-1.5`,children:[`Click below to open ChatGPT sign-in`,`Sign in with your ChatGPT Plus or Pro account`,`Your browser will say "site can't be reached" — that's expected. Copy the FULL URL from the address bar and paste it below.`].map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`flex-shrink-0 w-[18px] h-[18px] rounded-full bg-white/[0.06] text-white/30 text-[10px] font-medium flex items-center justify-center mt-px`,children:t+1}),(0,G.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:e})]},t))}),(0,G.jsx)(`button`,{onClick:Lr,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2`,children:k?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ce,{className:`h-3.5 w-3.5 opacity-60`}),`Open authentication page again`]}):(0,G.jsxs)(G.Fragment,{children:[`Authenticate with ChatGPT`,(0,G.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:`text`,value:Je,onChange:e=>Ye(e.target.value),onKeyDown:e=>e.key===`Enter`&&Rr(),placeholder:`Paste callback URL or code here...`,className:Qr+` pr-10 font-mono`}),(0,G.jsx)(`button`,{onClick:zr,className:`absolute right-3 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/50 transition-colors`,children:(0,G.jsx)(ie,{className:`h-3.5 w-3.5`})})]}),(0,G.jsx)(`button`,{onClick:Rr,disabled:!Je.trim()||Xe,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:Xe?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}),`Verifying...`]}):`Connect`})]}),Le!==`pending`&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,children:[(0,G.jsx)(`button`,{onClick:()=>{$e(void 0),Ie(Fe===`device`?`paste`:`device`)},className:`text-white/25 text-[11px] hover:text-white/40 transition-colors`,children:Fe===`device`?`Use callback URL instead`:`Use device code instead`}),(0,G.jsxs)(`button`,{onClick:Br,disabled:et,className:`text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center gap-1.5 disabled:opacity-50`,children:[et?(0,G.jsx)(D,{className:`h-3 w-3 animate-spin`}):(0,G.jsx)(_e,{className:`h-3 w-3`}),et?`Checking...`:`I'm already authenticated`]})]})]})]}),hr&&c!==`pi`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`border-t border-white/[0.06] mt-4 mb-3`}),(0,G.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:`Select a model`}),(0,G.jsx)(hd,{models:md[c]||[],value:u,onChange:d})]}),t&&hr&&(0,G.jsxs)(`button`,{onClick:Gr,disabled:!Wr,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Continue`,(0,G.jsx)(w,{className:`h-4 w-4`})]})]}),i===5&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight mb-1`,children:`Voice Messages`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1 leading-relaxed`,children:`Voice input works out of the box using your browser's built-in speech recognition. For better accuracy, you can optionally enable OpenAI Whisper.`}),(0,G.jsx)(`div`,{className:`w-full mt-5 rounded-xl border border-emerald-500/20 bg-emerald-500/[0.04] p-4`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3.5`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-emerald-500/10 flex items-center justify-center shrink-0`,children:(0,G.jsx)(pe,{className:`h-5 w-5 text-emerald-400`})}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-[14px] font-medium text-white`,children:`Browser Speech Recognition`}),(0,G.jsx)(`div`,{className:`text-[12px] text-white/35 mt-0.5 leading-relaxed`,children:`Built-in voice input — no setup needed. Works in Chrome, Edge, and Safari.`})]}),(0,G.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6 rounded-full bg-emerald-500/20 shrink-0`,children:(0,G.jsx)(ne,{className:`h-3.5 w-3.5 text-emerald-400`})})]})}),(0,G.jsx)(`button`,{onClick:()=>wn(e=>!e),className:`w-full mt-3 rounded-xl border transition-all duration-200 p-4 text-left ${I?`bg-white/[0.04] border-[#0069FE]/40`:`bg-transparent border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3.5`,children:[(0,G.jsx)(`img`,{src:`/icons/openai.svg`,alt:`OpenAI`,className:`w-10 h-10 rounded-xl bg-white/[0.04] p-1.5`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-[14px] font-medium text-white`,children:`OpenAI Whisper`}),(0,G.jsx)(`div`,{className:`text-[12px] text-white/35 mt-0.5 leading-relaxed`,children:`Upgrade to more accurate transcription that works in all browsers including Firefox.`})]}),(0,G.jsx)(`div`,{className:`w-10 h-[22px] rounded-full transition-colors duration-200 flex items-center px-0.5 shrink-0 ${I?`bg-gradient-brand`:`bg-white/[0.08]`}`,children:(0,G.jsx)(`div`,{className:`w-[18px] h-[18px] rounded-full bg-white shadow-sm transition-transform duration-200 ${I?`translate-x-[18px]`:`translate-x-0`}`})})]})}),I&&(0,G.jsxs)(`div`,{className:`mt-3`,children:[(0,G.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:`OpenAI API Key`}),(0,G.jsx)(`input`,{type:`password`,value:Tn,onChange:e=>En(e.target.value.trim()),placeholder:`sk-...`,autoComplete:`off`,className:Zr+` font-mono text-[13px]`}),Tn.length>0&&!Tn.startsWith(`sk-`)&&(0,G.jsx)(`p`,{className:`text-amber-400/70 text-[11px] mt-1`,children:`Key should start with sk-`}),Tn.length>0&&Tn.startsWith(`sk-`)&&Tn.length<20&&(0,G.jsx)(`p`,{className:`text-amber-400/70 text-[11px] mt-1`,children:`Key looks too short`}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2.5 mt-3 bg-white/[0.02] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,G.jsx)(pe,{className:`h-4 w-4 text-[#0069FE]/60 mt-0.5 shrink-0`}),(0,G.jsx)(`p`,{className:`text-white/35 text-[12px] leading-relaxed`,children:`Whisper provides more accurate transcription and works in all browsers including Firefox.`})]})]}),t&&(0,G.jsx)(`button`,{onClick:Xr,disabled:f||I&&(!Tn.startsWith(`sk-`)||Tn.length<20),className:`w-full mt-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:f?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Setting up...`]}):(0,G.jsxs)(G.Fragment,{children:[`Complete Setup`,(0,G.jsx)(w,{className:`h-4 w-4`})]})}),!I&&(0,G.jsx)(`p`,{className:`text-center text-white/20 text-[11px] mt-2.5`,children:`Voice input is active using your browser's built-in speech recognition.`})]}),i===6&&t&&(()=>{let e=vt===`off`,t=e?window.location.origin:vt===`named`?`https://${bt}`:wt===`relay`&&ht?ht:St||`http://localhost:3000`,n=t.startsWith(`http`)?t:`https://${t}`;return(0,G.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,G.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center mb-5`,children:(0,G.jsx)(ne,{className:`h-8 w-8 text-emerald-400`})}),(0,G.jsx)(`h1`,{className:`text-2xl font-bold text-white tracking-tight`,children:`All Set!`}),(0,G.jsx)(`p`,{className:`text-white/40 text-[13px] mt-2 leading-relaxed max-w-[340px]`,children:e?`Your agent is running on your private network. Access it from any device on your local network or VPN.`:vt===`named`?`Access your agent at your custom domain.`:wt===`relay`&&ht?`Your agent is live and ready. From now on, access it using your custom URL below.`:`Your agent is live and ready. Your tunnel URL is shown below. Note: this URL changes on restart.`}),(0,G.jsxs)(`div`,{className:`w-full mt-6 flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[13px] text-white/70 truncate flex-1 text-left`,children:t}),(0,G.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(n),sn(!0),setTimeout(()=>sn(!1),2e3)},className:`shrink-0 text-white/30 hover:text-white/60 transition-colors`,children:on?(0,G.jsx)(ne,{className:`h-4 w-4 text-emerald-400`}):(0,G.jsxs)(`svg`,{className:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:[(0,G.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,G.jsx)(`path`,{d:`M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1`})]})})]}),(0,G.jsxs)(`div`,{className:`w-full mt-3`,children:[(0,G.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block text-left`,children:`Your password`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[13px] text-white/70 truncate flex-1 text-left`,children:un?nn:`•`.repeat(Math.max(nn.length,8))}),(0,G.jsx)(`button`,{onClick:()=>dn(e=>!e),className:`shrink-0 text-white/30 hover:text-white/60 transition-colors`,children:un?(0,G.jsx)(le,{className:`h-4 w-4`}):(0,G.jsx)(ue,{className:`h-4 w-4`})})]})]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2.5 mt-6 cursor-pointer text-left select-none`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:fn,onChange:e=>pn(e.target.checked),className:`mt-0.5 h-4 w-4 rounded border-white/20 bg-white/5 accent-emerald-500 shrink-0`}),(0,G.jsxs)(`span`,{className:`text-[12px] text-white/50 leading-relaxed`,children:[`I accept the`,` `,(0,G.jsx)(`a`,{href:`https://www.bloby.bot/terms`,target:`_blank`,rel:`noopener noreferrer`,className:`text-white/70 underline hover:text-white/90`,children:`terms`}),` `,`and`,` `,(0,G.jsx)(`a`,{href:`https://www.bloby.bot/privacy`,target:`_blank`,rel:`noopener noreferrer`,className:`text-white/70 underline hover:text-white/90`,children:`privacy policy`})]})]}),(0,G.jsxs)(`button`,{disabled:!fn,onClick:()=>{e?(window.top||window).location.href=`/`:(window.top||window).location.href=n},className:`w-full mt-4 py-3 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 ${fn?`bg-gradient-brand hover:opacity-90`:`bg-white/10 cursor-not-allowed opacity-50`}`,children:[e?`Go to dashboard`:`Go to your agent`,(0,G.jsx)(ce,{className:`h-4 w-4`})]}),(0,G.jsx)(`p`,{className:`text-white/20 text-[11px] mt-3 leading-relaxed`,children:e?`Access from any device on your network using the URL above.`:`You'll be redirected to your ${vt===`named`?`custom domain`:wt===`relay`?`custom URL`:`tunnel URL`}.`})]})})(),i===6&&!t&&(0,G.jsx)(yd,{cacheRef:ar}),i===7&&!t&&(0,G.jsx)(Od,{cacheRef:or})]},i)}),t&&i>0&&i<6&&(0,G.jsx)(`div`,{className:`px-8 pb-5 -mt-3`,children:(0,G.jsx)(`button`,{onClick:Kr,className:`text-white/25 hover:text-white/50 text-[12px] transition-colors`,children:`← Back`})}),!t&&i>=1&&i<=5&&(Jr||lr||dr||pr)&&(0,G.jsxs)(`div`,{className:`px-8 pb-6 -mt-2`,children:[pr&&(0,G.jsxs)(`p`,{className:`text-red-400 text-[12px] mb-2 flex items-center gap-1.5`,children:[(0,G.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0`}),pr]}),dr&&!Jr?(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-3 text-emerald-400 text-[13px] font-medium`,children:[(0,G.jsx)(ne,{className:`h-4 w-4`}),` Saved`]}):(0,G.jsx)(`button`,{onClick:Yr,disabled:lr||!Jr,className:`w-full py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40 disabled:cursor-not-allowed`,children:lr?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Saving...`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ne,{className:`h-4 w-4`}),`Save changes`]})})]})]})]})}export{w as C,d as E,ne as S,S as T,fe as _,Me as a,se as b,je as c,xe as d,be as f,D as g,pe as h,Pe as i,Ee as l,O as m,sd as n,Ae as o,he as p,_l as r,Ne as s,kd as t,Se as u,E as v,ee as w,oe as x,ce as y};