PageSourceSearch

https://www.threadify.app/_next/static/chunks/02fpgkztz17ng.js

js threadify.app collected 2026-10-04 08:42:17 UTC 42,953 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,180166,e=>{"use strict";var t={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},r=new class{#e=t;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};e.s(["systemSetTimeoutZero",0,function(e){setTimeout(e,0)},"timeoutManager",0,r])},540143,e=>{"use strict";let t,r,i,s,n,a;var o=e.i(180166).systemSetTimeoutZero,u=(t=[],r=0,i=e=>{e()},s=e=>{e()},n=o,{batch:e=>{let a;r++;try{a=e()}finally{let e;--r||(e=t,t=[],e.length&&n(()=>{s(()=>{e.forEach(e=>{i(e)})})}))}return a},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a=e=>{r?t.push(e):n(()=>{i(e)})},setNotifyFunction:e=>{i=e},setBatchNotifyFunction:e=>{s=e},setScheduler:e=>{n=e}});e.s(["notifyManager",0,u])},175555,915823,e=>{"use strict";var t=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};e.s(["Subscribable",0,t],915823);var r=new class extends t{#r;#i;#s;constructor(){super(),this.#s=e=>{if("u">typeof window&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#i||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#i?.(),this.#i=void 0)}setEventListener(e){this.#s=e,this.#i?.(),this.#i=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#r!==e&&(this.#r=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#r?this.#r:globalThis.document?.visibilityState!=="hidden"}};e.s(["focusManager",0,r],175555)},273911,619273,e=>{"use strict";let t;e.i(247167);var r=e.i(180166),i="u"<typeof window||"Deno"in globalThis;function s(e,t){return(t?.queryKeyHashFn||n)(e)}function n(e){return JSON.stringify(e,(e,t)=>l(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function a(e,t){return e===t||typeof e==typeof t&&!!e&&!!t&&"object"==typeof e&&"object"==typeof t&&Object.keys(t).every(r=>a(e[r],t[r]))}var o=Object.prototype.hasOwnProperty;function u(e,t,r=0){if(e===t)return e;if(r>500)return t;let i=c(e)&&c(t);if(!i&&!(l(e)&&l(t)))return t;let s=(i?e:Object.keys(e)).length,n=i?t:Object.keys(t),a=n.length,h=i?Array(a):{},d=0;for(let c=0;c<a;c++){let a=i?c:n[c],l=e[a],f=t[a];if(l===f){h[a]=l,(i?c<s:o.call(e,a))&&d++;continue}if(null===l||null===f||"object"!=typeof l||"object"!=typeof f){h[a]=f;continue}let p=u(l,f,r+1);h[a]=p,p===l&&d++}return s===a&&d===s?e:h}function c(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function l(e){if(!h(e))return!1;let t=e.constructor;if(void 0===t)return!0;let r=t.prototype;return!!h(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function h(e){return"[object Object]"===Object.prototype.toString.call(e)}var d=Symbol();e.s(["addConsumeAwareSignal",0,function(e,t,r){let i,s=!1;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),s||(s=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i)}),e},"addToEnd",0,function(e,t,r=0){let i=[...e,t];return r&&i.length>r?i.slice(1):i},"addToStart",0,function(e,t,r=0){let i=[t,...e];return r&&i.length>r?i.slice(0,-1):i},"ensureQueryFn",0,function(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==d?e.queryFn:()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`))},"functionalUpdate",0,function(e,t){return"function"==typeof e?e(t):e},"hashKey",0,n,"hashQueryKeyByOptions",0,s,"isServer",0,i,"isValidTimeout",0,function(e){return"number"==typeof e&&e>=0&&e!==1/0},"keepPreviousData",0,function(e){return e},"matchMutation",0,function(e,t){let{exact:r,status:i,predicate:s,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(r){if(n(t.options.mutationKey)!==n(o))return!1}else if(!a(t.options.mutationKey,o))return!1}return(!i||t.state.status===i)&&(!s||!!s(t))},"matchQuery",0,function(e,t){let{type:r="all",exact:i,fetchStatus:n,predicate:o,queryKey:u,stale:c}=e;if(u){if(i){if(t.queryHash!==s(u,t.options))return!1}else if(!a(t.queryKey,u))return!1}if("all"!==r){let e=t.isActive();if("active"===r&&!e||"inactive"===r&&e)return!1}return("boolean"!=typeof c||t.isStale()===c)&&(!n||n===t.state.fetchStatus)&&(!o||!!o(t))},"noop",0,function(){},"partialMatchKey",0,a,"replaceData",0,function(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?u(e,t):t},"replaceEqualDeep",0,u,"resolveEnabled",0,function(e,t){return"function"==typeof e?e(t):e},"resolveStaleTime",0,function(e,t){return"function"==typeof e?e(t):e},"shallowEqualObjects",0,function(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(e[r]!==t[r])return!1;return!0},"shouldThrowError",0,function(e,t){return"function"==typeof e?e(...t):!!e},"skipToken",0,d,"sleep",0,function(e){return new Promise(t=>{r.timeoutManager.setTimeout(t,e)})},"timeUntilStale",0,function(e,t){return Math.max(e+(t||0)-Date.now(),0)}],619273);var f=(t=()=>i,{isServer:()=>t(),setIsServer(e){t=e}});e.s(["environmentManager",0,f],273911)},936553,814448,793803,e=>{"use strict";var t=e.i(175555),r=e.i(915823),i=new class extends r.Subscribable{#n=!0;#i;#s;constructor(){super(),this.#s=e=>{if("u">typeof window&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#i||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#i?.(),this.#i=void 0)}setEventListener(e){this.#s=e,this.#i?.(),this.#i=e(this.setOnline.bind(this))}
1setOnline(e){this.#n!==e&&(this.#n=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#n}};e.s(["onlineManager",0,i],814448);var s=e.i(619273);function n(){let e,t,r=new Promise((r,i)=>{e=r,t=i});function i(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{i({status:"fulfilled",value:t}),e(t)},r.reject=e=>{i({status:"rejected",reason:e}),t(e)},r}e.s(["pendingThenable",0,n],793803);var a=e.i(273911);function o(e){return Math.min(1e3*2**e,3e4)}function u(e){return(e??"online")!=="online"||i.isOnline()}var c=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};e.s(["CancelledError",0,c,"canFetch",0,u,"createRetryer",0,function(e){let r,l=!1,h=0,d=n(),f=()=>t.focusManager.isFocused()&&("always"===e.networkMode||i.isOnline())&&e.canRun(),p=()=>u(e.networkMode)&&e.canRun(),y=e=>{"pending"===d.status&&(r?.(),d.resolve(e))},m=e=>{"pending"===d.status&&(r?.(),d.reject(e))},v=()=>new Promise(t=>{r=e=>{("pending"!==d.status||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,"pending"===d.status&&e.onContinue?.()}),g=()=>{let t;if("pending"!==d.status)return;let r=0===h?e.initialPromise:void 0;try{t=r??e.fn()}catch(e){t=Promise.reject(e)}Promise.resolve(t).then(y).catch(t=>{if("pending"!==d.status)return;let r=e.retry??3*!a.environmentManager.isServer(),i=e.retryDelay??o,n="function"==typeof i?i(h,t):i,u=!0===r||"number"==typeof r&&h<r||"function"==typeof r&&r(h,t);l||!u?m(t):(h++,e.onFail?.(h,t),(0,s.sleep)(n).then(()=>f()?void 0:v()).then(()=>{l?m(t):g()}))})};return{promise:d,status:()=>d.status,cancel:t=>{if("pending"===d.status){let r=new c(t);m(r),e.onCancel?.(r)}},continue:()=>(r?.(),d),cancelRetry:()=>{l=!0},continueRetry:()=>{l=!1},canStart:p,start:()=>(p()?g():v().then(g),d)}}],936553)},88587,e=>{"use strict";var t=e.i(180166),r=e.i(273911),i=e.i(619273),s=class{#a;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),(0,i.isValidTimeout)(this.gcTime)&&(this.#a=t.timeoutManager.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(r.environmentManager.isServer()?1/0:3e5))}clearGcTimeout(){void 0!==this.#a&&(t.timeoutManager.clearTimeout(this.#a),this.#a=void 0)}};e.s(["Removable",0,s])},912598,e=>{"use strict";var t=e.i(271645),r=e.i(843476),i=t.createContext(void 0);e.s(["QueryClientProvider",0,({client:e,children:s})=>(t.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,r.jsx)(i.Provider,{value:e,children:s})),"useQueryClient",0,e=>{let r=t.useContext(i);if(e)return e;if(!r)throw Error("No QueryClient set, use QueryClientProvider to set one");return r}])},869230,286491,e=>{"use strict";var t=e.i(175555),r=e.i(273911),i=e.i(540143);e.i(247167);var s=e.i(619273),n=e.i(936553),a=e.i(88587),o=class extends a.Removable{#o;#u;#c;#l;#h;#d;#f;constructor(e){super(),this.#f=!1,this.#d=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#l=e.client,this.#c=this.#l.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#o=l(this.options),this.state=e.state??this.#o,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#h?.promise}setOptions(e){if(this.options={...this.#d,...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){let e=l(this.options);void 0!==e.data&&(this.setState(c(e.data,e.dataUpdatedAt)),this.#o=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#c.remove(this)}setData(e,t){let r=(0,s.replaceData)(this.state.data,e,this.options);return this.#p({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#p({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#h?.promise;return this.#h?.cancel(e),t?t.then(s.noop).catch(s.noop):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#o}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>!1!==(0,s.resolveEnabled)(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===s.skipToken||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdate
1Count>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===(0,s.resolveStaleTime)(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!(0,s.timeUntilStale)(this.state.dataUpdatedAt,e))}onFocus(){let e=this.observers.find(e=>e.shouldFetchOnWindowFocus());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}onOnline(){let e=this.observers.find(e=>e.shouldFetchOnReconnect());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#c.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#h&&(this.#f||this.#y()?this.#h.cancel({revert:!0}):this.#h.cancelRetry()),this.scheduleGc()),this.#c.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#y(){return"paused"===this.state.fetchStatus&&"pending"===this.state.status}invalidate(){this.state.isInvalidated||this.#p({type:"invalidate"})}async fetch(e,t){let r;if("idle"!==this.state.fetchStatus&&this.#h?.status()!=="rejected"){if(void 0!==this.state.data&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#h)return this.#h.continueRetry(),this.#h.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let i=new AbortController,a=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#f=!0,i.signal)})},o=()=>{let e,r=(0,s.ensureQueryFn)(this.options,t),i=(a(e={client:this.#l,queryKey:this.queryKey,meta:this.meta}),e);return(this.#f=!1,this.options.persister)?this.options.persister(r,i,this):r(i)},u=(a(r={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#l,state:this.state,fetchFn:o}),r);this.options.behavior?.onFetch(u,this),this.#u=this.state,("idle"===this.state.fetchStatus||this.state.fetchMeta!==u.fetchOptions?.meta)&&this.#p({type:"fetch",meta:u.fetchOptions?.meta}),this.#h=(0,n.createRetryer)({initialPromise:t?.initialPromise,fn:u.fetchFn,onCancel:e=>{e instanceof n.CancelledError&&e.revert&&this.setState({...this.#u,fetchStatus:"idle"}),i.abort()},onFail:(e,t)=>{this.#p({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#p({type:"pause"})},onContinue:()=>{this.#p({type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0});try{let e=await this.#h.start();if(void 0===e)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#c.config.onSuccess?.(e,this),this.#c.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof n.CancelledError){if(e.silent)return this.#h.promise;else if(e.revert){if(void 0===this.state.data)throw e;return this.state.data}}throw this.#p({type:"error",error:e}),this.#c.config.onError?.(e,this),this.#c.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#p(e){let t=t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...u(t.data,this.options),fetchMeta:e.meta??null};case"success":let r={...t,...c(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#u=e.manual?r:void 0,r;case"error":let i=e.error;return{...t,error:i,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}};this.state=t(this.state),i.notifyManager.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#c.notify({query:this,type:"updated",action:e})})}};function u(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:(0,n.canFetch)(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function c(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function l(e){let t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,i=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?i??Date.now():0,error:null,errorUpdate
1Count:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}e.s(["Query",0,o,"fetchState",0,u],286491);var h=e.i(915823),d=e.i(793803),f=e.i(180166),p=class extends h.Subscribable{constructor(e,t){super(),this.options=t,this.#l=e,this.#m=null,this.#v=(0,d.pendingThenable)(),this.bindMethods(),this.setOptions(t)}#l;#g=void 0;#w=void 0;#b=void 0;#S;#E;#v;#m;#T;#R;#O;#_;#C;#I;#k=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#g.addObserver(this),y(this.#g,this.options)?this.#A():this.updateResult(),this.#P())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return m(this.#g,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return m(this.#g,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#F(),this.#Q(),this.#g.removeObserver(this)}setOptions(e){let t=this.options,r=this.#g;if(this.options=this.#l.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof(0,s.resolveEnabled)(this.options.enabled,this.#g))throw Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#U(),this.#g.setOptions(this.options),t._defaulted&&!(0,s.shallowEqualObjects)(this.options,t)&&this.#l.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#g,observer:this});let i=this.hasListeners();i&&v(this.#g,r,this.options,t)&&this.#A(),this.updateResult(),i&&(this.#g!==r||(0,s.resolveEnabled)(this.options.enabled,this.#g)!==(0,s.resolveEnabled)(t.enabled,this.#g)||(0,s.resolveStaleTime)(this.options.staleTime,this.#g)!==(0,s.resolveStaleTime)(t.staleTime,this.#g))&&this.#N();let n=this.#D();i&&(this.#g!==r||(0,s.resolveEnabled)(this.options.enabled,this.#g)!==(0,s.resolveEnabled)(t.enabled,this.#g)||n!==this.#I)&&this.#j(n)}getOptimisticResult(e){var t,r;let i=this.#l.getQueryCache().build(this.#l,e),n=this.createResult(i,e);return t=this,r=n,(0,s.shallowEqualObjects)(t.getCurrentResult(),r)||(this.#b=n,this.#E=this.options,this.#S=this.#g.state),n}getCurrentResult(){return this.#b}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#v.status||this.#v.reject(Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#k.add(e)}getCurrentQuery(){return this.#g}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#l.defaultQueryOptions(e),r=this.#l.getQueryCache().build(this.#l,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#A({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#b))}#A(e){this.#U();let t=this.#g.fetch(this.options,e);return e?.throwOnError||(t=t.catch(s.noop)),t}#N(){this.#F();let e=(0,s.resolveStaleTime)(this.options.staleTime,this.#g);if(r.environmentManager.isServer()||this.#b.isStale||!(0,s.isValidTimeout)(e))return;let t=(0,s.timeUntilStale)(this.#b.dataUpdatedAt,e);this.#_=f.timeoutManager.setTimeout(()=>{this.#b.isStale||this.updateResult()},t+1)}#D(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#g):this.options.refetchInterval)??!1}#j(e){this.#Q(),this.#I=e,!r.environmentManager.isServer()&&!1!==(0,s.resolveEnabled)(this.options.enabled,this.#g)&&(0,s.isValidTimeout)(this.#I)&&0!==this.#I&&(this.#C=f.timeoutManager.setInterval(()=>{(this.options.refetchIntervalInBackground||t.focusManager.isFocused())&&this.#A()},this.#I))}#P(){this.#N(),this.#j(this.#D())}#F(){void 0!==this.#_&&(f.timeoutManager.clearTimeout(this.#_),this.#_=void 0)}#Q(){void 0!==this.#C&&(f.timeoutManager.clearInterval(this.#C),this.#C=void 0)}createResult(e,t){let r,i=this.#g,n=this.options,a=this.#b,o=this.#S,c=this.#E,l=e!==i?e.state:this.#w,{state:h}=e,f={...h},p=!1;if(t._optimisticResults){let r=this.hasListeners(),s=!r&&y(e,t),a=r&&v(e,i,t,n);(s||a)&&(f={...f,...u(h.data,e.options)}),"isRestoring"===t._optimisticResults&&(f.fetchStatus="idle")}let{error:m,errorUpdatedAt:w,status:b}=f;r=f.data;let S=!1;if(void 0!==t.placeholderData&&void 0===r&&"pending"===b){let e;a?.isPlaceholderData&&t.placeholderData===c?.placeholderData?(e=a.data,S=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#O?.state.data,this.#O):t.placeholderData,void 0!==e&&(b="success",r=(0,s.replaceData)(a?.data,e,t),p=!0)}if(t.select&&void 0!==r&&!S)if(a&&r===o?.data&&t.select===this.#T)r=this.#R;else try{this.#T=t.select,r=t.select(r),r=(0,s.replaceData)(a?.data,r,t),this.#R=r,this.#m=null}catch(e){this.#m=e}this.#m&&(m=this.#m,r=this.#R,w=Date.now(),b="error");let E="fetching"===f.fetchStatus,T="pending"===b,R="error"===b,O=T&&E,_=void 0!==r,C={status:b,fetchStatus:f.fetchStatus,isPending:T,isSuccess:"success"===b,isError:R,isInitialLoading:O,isLoading:O,data:r,dataUpdatedAt:f.dataUpdatedAt,error:m,errorUpdatedAt:w,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdate
1Count:f.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:f.dataUpdateCount>l.dataUpdateCount||f.errorUpdateCount>l.errorUpdateCount,isFetching:E,isRefetching:E&&!T,isLoadingError:R&&!_,isPaused:"paused"===f.fetchStatus,isPlaceholderData:p,isRefetchError:R&&_,isStale:g(e,t),refetch:this.refetch,promise:this.#v,isEnabled:!1!==(0,s.resolveEnabled)(t.enabled,e)};if(this.options.experimental_prefetchInRender){let t=void 0!==C.data,r="error"===C.status&&!t,s=e=>{r?e.reject(C.error):t&&e.resolve(C.data)},n=()=>{s(this.#v=C.promise=(0,d.pendingThenable)())},a=this.#v;switch(a.status){case"pending":e.queryHash===i.queryHash&&s(a);break;case"fulfilled":(r||C.data!==a.value)&&n();break;case"rejected":r&&C.error===a.reason||n()}}return C}updateResult(){let e=this.#b,t=this.createResult(this.#g,this.options);if(this.#S=this.#g.state,this.#E=this.options,void 0!==this.#S.data&&(this.#O=this.#g),(0,s.shallowEqualObjects)(t,e))return;this.#b=t;let r=()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#k.size)return!0;let i=new Set(r??this.#k);return this.options.throwOnError&&i.add("error"),Object.keys(this.#b).some(t=>this.#b[t]!==e[t]&&i.has(t))};this.#L({listeners:r()})}#U(){let e=this.#l.getQueryCache().build(this.#l,this.options);if(e===this.#g)return;let t=this.#g;this.#g=e,this.#w=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#P()}#L(e){i.notifyManager.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#b)}),this.#l.getQueryCache().notify({query:this.#g,type:"observerResultsUpdated"})})}};function y(e,t){return!1!==(0,s.resolveEnabled)(t.enabled,e)&&void 0===e.state.data&&("error"!==e.state.status||!1!==t.retryOnMount)||void 0!==e.state.data&&m(e,t,t.refetchOnMount)}function m(e,t,r){if(!1!==(0,s.resolveEnabled)(t.enabled,e)&&"static"!==(0,s.resolveStaleTime)(t.staleTime,e)){let i="function"==typeof r?r(e):r;return"always"===i||!1!==i&&g(e,t)}return!1}function v(e,t,r,i){return(e!==t||!1===(0,s.resolveEnabled)(i.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&g(e,r)}function g(e,t){return!1!==(0,s.resolveEnabled)(t.enabled,e)&&e.isStaleByTime((0,s.resolveStaleTime)(t.staleTime,e))}e.s(["QueryObserver",0,p],869230)},266027,673664,427001,381384,254440,469637,e=>{"use strict";let t;var r=e.i(869230);e.i(247167);var i=e.i(271645),s=e.i(273911),n=e.i(619273),a=e.i(540143),o=e.i(912598);e.i(843476);var u=i.createContext((t=!1,{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t})),c=()=>i.useContext(u);e.s(["useQueryErrorResetBoundary",0,c],673664);var l=(e,t,r)=>{let i=r?.state.error&&"function"==typeof e.throwOnError?(0,n.shouldThrowError)(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||i)&&!t.isReset()&&(e.retryOnMount=!1)},h=e=>{i.useEffect(()=>{e.clearReset()},[e])},d=({result:e,errorResetBoundary:t,throwOnError:r,query:i,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&i&&(s&&void 0===e.data||(0,n.shouldThrowError)(r,[e.error,i]));e.s(["ensurePreventErrorBoundaryRetry",0,l,"getHasError",0,d,"useClearResetErrorBoundary",0,h],427001);var f=i.createContext(!1),p=()=>i.useContext(f);f.Provider,e.s(["useIsRestoring",0,p],381384);var y=e=>{if(e.suspense){let t=e=>"static"===e?e:Math.max(e??1e3,1e3),r=e.staleTime;e.staleTime="function"==typeof r?(...e)=>t(r(...e)):t(r),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,1e3))}},m=(e,t)=>e.isLoading&&e.isFetching&&!t,v=(e,t)=>e?.suspense&&t.isPending,g=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function w(e,t,r){let u=p(),f=c(),w=(0,o.useQueryClient)(r),b=w.defaultQueryOptions(e);w.getDefaultOptions().queries?._experimental_beforeQuery?.(b);let S=w.getQueryCache().get(b.queryHash);b._optimisticResults=u?"isRestoring":"optimistic",y(b),l(b,f,S),h(f);let E=!w.getQueryCache().get(b.queryHash),[T]=i.useState(()=>new t(w,b)),R=T.getOptimisticResult(b),O=!u&&!1!==e.subscribed;if(i.useSyncExternalStore(i.useCallback(e=>{let t=O?T.subscribe(a.notifyManager.batchCalls(e)):n.noop;return T.updateResult(),t},[T,O]),()=>T.getCurrentResult(),()=>T.getCurrentResult()),i.useEffect(()=>{T.setOptions(b)},[b,T]),v(b,R))throw g(b,T,f);if(d({result:R,errorResetBoundary:f,throwOnError:b.throwOnError,query:S,suspense:b.suspense}))throw R.error;if(w.getDefaultOptions().queries?._experimental_afterQuery?.(b,R),b.experimental_prefetchInRender&&!s.environmentManager.isServer()&&m(R,u)){let e=E?g(b,T,f):S?.promise;e?.catch(n.noop).finally(()=>{T.updateResult()})}return b.notifyOnChangeProps?R:T.trackResult(R)}e.s(["ensureSuspenseTimers",0,y,"fetchOptimistic",0,g,"shouldSuspend",0,v,"willFetch",0,m],254440),e.s(["useBaseQuery",0,w],469637),e.s(["useQuery",0,function(e,t){return w(e,r.QueryObserver,t)}],266027)},134340,e=>{"use strict";let t="threadify_visitor_id",r="threadify_session_id",i="threadify_entry_session",s="threadify_entry_captured",n="threadify_analytics_id",a=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;function o(e){if(!e)return null;let t=e.trim().slice(0,128);return a.test(t)?t:null}function u(){return"u">typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}function c(e){if("u"<typeof document)return null;let t=`${e}=`,r=document.cookie.split("; ").find(e=>e.startsWith(t));if(!r)return null;try{return o(decodeURIComponent(r.slice(t.length)))}catch{return null}}function l(e,t,r){"u">typeof document&&(document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${r}; SameSite=Lax${"https:"===window.location.protocol?"; Secure":""}`)}e.s(["ANALYTICS_ENTRY_CAPTURED_COOKIE_NAME",0,s,"ANALYTICS_ENTRY_SESSION_COOKIE_NAME",0,i,"ANALYTICS_SESSION_COOKIE_NAME",0,r,"getOrCreateClientAnalyticsIdentity",0,function(e={}){let i=c(r),s=c(t)||function(){try{return o(localStorage.getItem(n))}catch{return null}}()||i||u(),a=!e.rotateSession&&i||u();try{localStorage.setItem(n,s)}catch{}return l(t,s,3456e4),l(r,a,1800),{visitorId:s,sessionId:a}},"markClientAnalyticsEntryCaptured",0,function(e){let t=o(e);t&&l(s,t,300)},"markClientAnalyticsEntrySession",0,function(e){let t=o(e);t&&l(i,t,300)},"readClientAnalyticsCookie",0,c])},473347,e=>{"use strict";var t=e.i(737671);let r="threadify:threads-oauth-browser-returned";
1class i extends Error{}let s=null;async function n(i,s){let n,a,o=new AbortController;s.cancelledPromise.then(()=>o.abort());try{n=await (0,t.fetchWithAuth)(i,{signal:o.signal})}catch(e){if(s.cancelled)return;throw e}if(s.cancelled)return;if(!n.ok)throw Error("Failed to get auth URL");let u=await n.json();if(s.cancelled)return;if("string"!=typeof u.url||"string"!=typeof u.state)throw Error("Threads auth response was missing its URL or state");let{Browser:c}=await e.A(875192);if(s.cancelled)return;let l=new Promise(e=>{a=e}),h=await c.addListener("browserFinished",()=>{a?.()}),d=e=>{e instanceof CustomEvent&&e.detail?.state===u.state&&a?.()};window.addEventListener(r,d);try{if(s.cancelled)return;s.browserStarted=!0;let e=c.open({url:u.url});if(e.catch(()=>{}),await Promise.race([e,s.cancelledPromise]),s.cancelled)return;await e,await Promise.race([l,s.cancelledPromise])}finally{window.removeEventListener(r,d);try{await h.remove()}catch(e){}}}async function a(t){let r=s;if(r&&(!t||r.userId!==t)){if(r.control.cancel(),r.control.browserStarted)try{let{Browser:t}=await e.A(875192);await t.close()}catch(e){}await r.promise}}async function o(t){let r=t.brandId?`brand=${encodeURIComponent(t.brandId)}`:null,a=r?`/api/threads/auth?${r}`:"/api/threads/auth",o=`${t.userId}:${t.brandId??"personal"}`;try{let{Capacitor:u}=await e.A(349070),c=u.isNativePlatform();if(s){if(s.key!==o)throw new i("A Threads connection is already active for another account or brand");await s.promise;return}if(c){let e,i,a=r?`/api/threads/auth?native=true&${r}`:"/api/threads/auth?native=true",u=i={cancelled:!1,cancel:()=>{i.cancelled=!0,e()},cancelledPromise:new Promise(t=>{e=t}),browserStarted:!1},c=n(a,u).finally(()=>{s?.promise===c&&(s=null)});s={key:o,userId:t.userId,promise:c,control:u},await s.promise}else window.location.href=a}catch(e){if(e instanceof i)throw e;console.error("Error connecting Threads account:",e),window.location.href=a}}e.s(["THREADS_OAUTH_BROWSER_RETURNED_EVENT",0,r,"cancelNativeThreadsConnect",0,a,"connectThreadsAccount",0,o])},501894,e=>{"use strict";function t(){return!!window.Capacitor?.isNativePlatform?.()}e.s(["getCurrentUrl",0,function(){return window.location.href},"isInAppBrowser",0,function(){if(t())return!1;let e=navigator.userAgent||"";return[/FBAN|FBAV/i,/Instagram/i,/Twitter/i,/LinkedInApp/i,/Threads/i,/Line\//i,/KAKAOTALK/i,/Snapchat/i,/Pinterest/i,/Musical\.ly/i,/BytedanceWebview/i,/TikTok/i,/GSA\//i,/DuckDuckGo/i,/YaBrowser/i,/SamsungBrowser.*Mobile VR/i,/NAVER/i,/Electron/i].some(t=>t.test(e))},"isNativePlatform",0,t])},804012,e=>{"use strict";var t=e.i(843476),r=e.i(271645),i=e.i(920755),s=e.i(737671);function n(){if("u">typeof document)for(let e of function(e,t=".threadify.app"){if(!e)return[];let r=new Set,i=[];for(let s of e.split(";")){let e=s.trim().split("=")[0];e.startsWith("sb-")&&!r.has(e)&&(r.add(e),i.push(`${e}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=${t};path=/`))}return i}(document.cookie))document.cookie=e}var a=e.i(501894),o=e.i(618566),u=e.i(891563),c=e.i(598268);function l(e){try{return localStorage.getItem(e)||void 0}catch{return}}async function h(e){if(!e?.user)return"skipped_server";if(!function(e,t=Date.now()){return(0,c.hasPendingOwnedSignupDelivery)(e.id)||(0,c.isWithinOwnedSignupCaptureWindow)(e.created_at,t)}(e.user))return"skipped_not_new_user";let t=function(e){try{let t;return{user_id:e.id,signup_created_at:e.created_at,method:(t=e.app_metadata?.provider,"google"===t?"google":"apple"===t?"apple":"email"),referral_source:function(){try{return document.cookie.match(/(?:^|;\s*)threadify_ref=([^;]+)/)?.[1]||null}catch{return null}}(),referral_code:(0,u.getAffiliateReferralCode)(),utm_source:l("threadify_utm_source"),utm_medium:l("threadify_utm_medium"),utm_campaign:l("threadify_utm_campaign"),utm_term:l("threadify_utm_term"),utm_content:l("threadify_utm_content"),initial_referrer:l("threadify_initial_referrer")}}catch{return null}}(e.user);return t?(0,u.trackSignup)(t):"unavailable"}var d=e.i(473347);let f=(0,r.createContext)(void 0);e.s(["AuthProvider",0,function({children:u}){let[c,l]=(0,r.useState)(null),[p,y]=(0,r.useState)(null),[m,v]=(0,r.useState)(!0),g=(0,o.usePathname)(),w=(0,o.useRouter)();(0,r.useRef)(g).current=g;let b=(0,r.useMemo)(()=>(0,i.createClient)(),[]),S=(0,r.useRef)(null),E=(0,r.useRef)(!1),T=(0,r.useRef)(w);T.current=w;let R=(0,r.useCallback)(()=>{y(null),l(null),v(!1),S.current=null},[]),O=(0,r.useCallback)(async()=>{await (0,d.cancelNativeThreadsConnect)(),R(),n(),await b.auth.signOut({scope:"local"}),localStorage.removeItem("agent_pin_auth"),w.replace("/login")},[R,b,w]);(0,r.useEffect)(()=>{S.current=p},[p]),(0,r.useEffect)(()=>{b.auth.getSession().then(({data:{session:e}})=>{y(e),l(e?.user??null),v(!1),h(e)}).catch(e=>{y(null),l(null),v(!1)});let{data:{subscription:e}}=b.auth.onAuthStateChange((e,t)=>{if("SIGNED_OUT"===e?(0,d.cancelNativeThreadsConnect)():("INITIAL_SESSION"===e||"SIGNED_IN"===e)&&(0,d.cancelNativeThreadsConnect)(t?.user.id),y(t),l(t?.user??null),v(!1),("INITIAL_SESSION"===e||"SIGNED_IN"===e||"TOKEN_REFRESHED"===e)&&h(t),"SIGNED_OUT"===e&&(E.current=!1,n(),localStorage.removeItem("agent_pin_auth"),"/login"!==window.location.pathname&&(window.Capacitor?.isNativePlatform?.()?window.location.replace(`${window.location.origin}/login`):T.current.replace("/login"))),("TOKEN_REFRESHED"===e||"SIGNED_IN"===e)&&(E.current=!1,"SIGNED_IN"===e&&t?.user?.email))try{let e=document.cookie.match(/threadify_ref=([^;
1]+)/)?.[1];(0,s.fetchWithAuth)("/api/affiliates/auto-attribute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({referral_code:e})}).catch(()=>{})}catch{}});return()=>{e.unsubscribe()}},[b]),(0,r.useEffect)(()=>{let e=()=>{O()};return window.addEventListener(s.SESSION_EXPIRED_EVENT,e),()=>{window.removeEventListener(s.SESSION_EXPIRED_EVENT,e)}},[O]),(0,r.useEffect)(()=>{let t=null;return(async()=>{try{let{Capacitor:r}=await e.A(349070);if(!r.isNativePlatform())return;let{App:i}=await e.A(746046);i.addListener("appStateChange",({isActive:e})=>{e?(b.auth.startAutoRefresh(),b.auth.getSession().catch(()=>{})):b.auth.stopAutoRefresh()}).then(e=>{t=e})}catch{}})(),()=>{t?.remove()}},[b]),(0,r.useEffect)(()=>{let t=null,r=!1;return e.A(349070).then(({Capacitor:i})=>{i.isNativePlatform()&&e.A(746046).then(({App:i})=>{i.addListener("appUrlOpen",async t=>{if(t.url.startsWith("com.threadify.app://google-auth"))try{let r=new URL(t.url),i=r.hash.substring(1),s=new URLSearchParams(i),n=s.get("access_token"),a=s.get("refresh_token"),o=r.searchParams.get("code");if(n&&a){let{error:e}=await b.auth.setSession({access_token:n,refresh_token:a});if(e)throw e}else if(o){let{error:e}=await b.auth.exchangeCodeForSession(o);if(e)throw e}setTimeout(()=>{e.A(875192).then(({Browser:e})=>{e.close()})},500)}catch(t){console.error("Error handling deep link:",t),e.A(875192).then(({Browser:e})=>{e.close()})}if(t.url.startsWith("com.threadify.app://threads-auth")){let r=null;try{let i=new URL(t.url),n=i.searchParams.get("code"),a=i.searchParams.get("state"),o=i.searchParams.get("error");r=a;let{Browser:u}=await e.A(875192);try{await u.close()}catch(e){}if(o){console.error("Threads OAuth error:",o),window.location.href=`/?threads_error=${o}`;return}if(n&&a){let e=await (0,s.fetchWithAuth)(`/api/threads/callback?code=${encodeURIComponent(n)}&state=${encodeURIComponent(a)}&webview=true`,{credentials:"include"});if(e.ok)if((await e.json()).threads_connected)window.location.href="/?threads_connected=true";else throw Error("Threads callback did not confirm connection");else throw Error("Failed to complete OAuth")}else window.location.href="/?threads_error=no_code"}catch(e){console.error("Error handling Threads callback in native:",e),window.location.href="/?threads_error=callback_error"}finally{r&&window.dispatchEvent(new CustomEvent(d.THREADS_OAUTH_BROWSER_RETURNED_EVENT,{detail:{state:r}}))}}}).then(e=>{r?e.remove():t=e})})}),()=>{r=!0,t?.remove()}},[b]),(0,r.useEffect)(()=>{let t=null;return e.A(349070).then(({Capacitor:r})=>{r.isNativePlatform()&&e.A(746046).then(({App:e})=>{e.addListener("backButton",({canGoBack:t})=>{t?window.history.back():e.exitApp()}).then(e=>{t=e})})}).catch(()=>{}),()=>{t?.remove()}},[]),(0,r.useEffect)(()=>{e.A(349070).then(({Capacitor:t})=>{t.isNativePlatform()&&e.A(102499).then(({StatusBar:e,Style:t})=>{e.setOverlaysWebView({overlay:!0}).catch(()=>{});let r=document.documentElement.classList.contains("dark");e.setStyle({style:r?t.Dark:t.Light}).catch(()=>{});let i=new MutationObserver(()=>{let r=document.documentElement.classList.contains("dark");e.setStyle({style:r?t.Dark:t.Light}).catch(()=>{})});return i.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>i.disconnect()})}).catch(()=>{})},[]);let _=(0,r.useCallback)(async t=>{if((0,a.isInAppBrowser)())throw Error("IN_APP_BROWSER");n();let r=!1;try{let{Capacitor:t}=await e.A(349070);r=t.isNativePlatform()}catch(e){}if(r)try{let{FirebaseAuthentication:t}=await e.A(492485),r=await t.signInWithGoogle(),i=r.credential?.idToken,s=r.credential?.nonce;if(!i)throw Error("Google Sign-In succeeded natively, but no ID Token was returned.");let{error:n}=await b.auth.signInWithIdToken({provider:"google",token:i,nonce:s});if(n)throw n}catch(e){throw console.error("[Google Auth] Native Firebase Auth failed:",e),Error(e?.message||"Native Google Sign-In failed")}else{let e=new URLSearchParams(window.location.search),r=new URLSearchParams;for(let t of(r.set("provider","google"),["utm_source","utm_medium","utm_campaign","utm_term","utm_content"])){let i=e.get(t);i&&r.set(t,i)}if(t?.redirectTo)r.set("redirect_to",t.redirectTo);else{let t=e.get("redirect");t&&r.set("redirect_to",t)}window.location.assign(`/api/auth/login?${r.toString()}`)}},[b]),C=(0,r.useCallback)(async t=>{n();let r=!1;try{let{Capacitor:t}=await e.A(349070);r=t.isNativePlatform()}catch(e){}if(r)try{let{FirebaseAuthentication:t}=await e.A(492485),r=await t.signInWithApple(),i=r.credential?.idToken,s=r.credential?.nonce;if(!i)throw Error("Apple Sign-In succeeded natively, but no ID Token was returned.");let{error:n}=await b.auth.signInWithIdToken({provider:"apple",token:i,nonce:s});if(n)throw n}catch(e){throw console.error("[Apple Auth] Native Firebase Auth failed:",e),Error(e?.message||"Native Apple Sign-In failed")}
1else{let e=new URLSearchParams(window.location.search),r=new URLSearchParams;for(let t of(r.set("provider","apple"),["utm_source","utm_medium","utm_campaign","utm_term","utm_content"])){let i=e.get(t);i&&r.set(t,i)}if(t?.redirectTo)r.set("redirect_to",t.redirectTo);else{let t=e.get("redirect");t&&r.set("redirect_to",t)}window.location.assign(`/api/auth/login?${r.toString()}`)}},[b]),I=(0,r.useCallback)(async(e,t)=>{try{let r=await (0,s.fetchWithAuth)("/api/auth/send-login-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:t})}),i=await r.json();if(!r.ok)return{error:i.error||"Failed to send verification code."};if(i.bypassOtp&&i.session)return await b.auth.setSession({access_token:i.session.access_token,refresh_token:i.session.refresh_token}),{error:null,bypassOtp:!0};return{error:null}}catch{return{error:"Failed to send verification code. Please try again."}}},[b]),k=(0,r.useCallback)(async(e,t,r)=>{try{let i=await (0,s.fetchWithAuth)("/api/auth/verify-login-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,code:t,password:r})}),n=await i.json();if(!i.ok)return{error:n.error||"Verification failed."};return n.session&&await b.auth.setSession({access_token:n.session.access_token,refresh_token:n.session.refresh_token}),{error:null}}catch{return{error:"Verification failed. Please try again."}}},[b]),A=(0,r.useCallback)(async e=>{try{let t=await (0,s.fetchWithAuth)("/api/auth/send-signup-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})}),r=await t.json();if(!t.ok)return{error:r.error||"Failed to send verification code."};return{error:null}}catch{return{error:"Failed to send verification code. Please try again."}}},[]),P=(0,r.useCallback)(async(e,t,r)=>{try{let i=await (0,s.fetchWithAuth)("/api/auth/verify-signup-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,code:t,password:r})}),n=await i.json();if(!i.ok)return{error:n.error||"Verification failed.",confirmEmail:!1};return n.session&&await b.auth.setSession({access_token:n.session.access_token,refresh_token:n.session.refresh_token}),{error:null,confirmEmail:!1}}catch{return{error:"Verification failed. Please try again.",confirmEmail:!1}}},[b]),F=(0,r.useCallback)(async e=>{let{error:t}=await b.auth.resetPasswordForEmail(e,{redirectTo:`${window.location.origin}/reset-password`});return t?{error:t.message}:{error:null}},[b]),Q=(0,r.useCallback)(async()=>{window.__threadify_signing_out=!0,await (0,d.cancelNativeThreadsConnect)();let{error:e}=await b.auth.signOut({scope:"local"});if(e)throw window.__threadify_signing_out=!1,console.error("Error signing out:",e),e;if(localStorage.removeItem("agent_pin_auth"),window.Capacitor?.isNativePlatform?.()){let e=`${window.location.origin}/login`;window.location.replace(e)}else w.replace("/login")},[b,w]),U=(0,r.useCallback)(async()=>{let{data:e,error:t}=await b.auth.getUserIdentities();return t?{identities:[],error:t.message}:{identities:e.identities??[],error:null}},[b]),N=(0,r.useCallback)(async()=>{let{error:e}=await b.auth.linkIdentity({provider:"google",options:{redirectTo:`${window.location.origin}/api/auth/callback?redirect_to=/settings`}});if(e)throw console.error("Error linking Google identity:",e),e},[b]),D=(0,r.useCallback)(async()=>{let{data:e,error:t}=await b.auth.getUserIdentities();if(t)return{error:t.message};let r=e.identities?.find(e=>"google"===e.provider);if(!r)return{error:"No Google identity found to disconnect."};if((e.identities?.length??0)<2)return{error:"You must have another login method before disconnecting Google."};let{error:i}=await b.auth.unlinkIdentity(r);return i?{error:i.message}:{error:null}},[b]),j=(0,r.useCallback)(async()=>{try{let e=await (0,s.fetchWithAuth)("/api/auth/set-password-email",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectTo:`${window.location.origin}/reset-password`})}),t=await e.json();if(!e.ok)return{error:t.error||"Failed to send password setup email."};return{error:null}}catch{return{error:"Failed to send password setup email. Please try again."}}},[]),L=(0,r.useCallback)(async(e,t)=>{try{let r=await (0,s.fetchWithAuth)("/api/auth/verify-set-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,password:t})}),i=await r.json();if(!r.ok)return{error:i.error||"Failed to set password."};return{error:null}}catch{return{error:"Failed to set password. Please try again."}}},[]),M=(0,r.useCallback)(async(e,t)=>{try{let r=await (0,s.fetchWithAuth)("/api/auth/send-email-change-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newEmail:e,password:t})}),i=await r.json();if(!r.ok)return{error:i.error||"Failed to send verification code."};return{error:null}}catch{return{error:"Failed to send verification code. Please try again."}}},[]),x=(0,r.useCallback)(async(e,t)=>{try{let r=await (0,s.fetchWithAuth)("/api/auth/verify-email-change",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newEmail:e,code:t})}),i=await r.json();if(!r.ok)return{error:i.error||"Failed to change email."};return await b.auth.refreshSession(),{error:null}}catch{return{error:"Failed to change email. Please try again."}}},[b]),q=(0,r.useMemo)(()=>({user:c,session:p,loading:m,signInWithGoogle:_,signInWithApple:C,sendLoginOtp:I,verifyLoginOtp:k,sendSignupOtp:A,verifySignupOtp:P,resetPassword:F,signOut:Q,getUserIdentities:U,linkGoogle:N,unlinkGoogle:D,sendSetPasswordEmail:j,verifyAndSetPassword:L,sendEmailChangeOtp:M,verifyEmailChange:x}),[c,p,m,_,C,I,k,A,P,F,Q,U,N,D,j,L,M,x]);return(0,t.jsx)(f.Provider,{value:q,children:u})},"useAuth",0,function(){let e=(0,r.useContext)(f);if(void 0===e)throw Error("useAuth must be used within an AuthProvider");return e}],804012)}]);

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