@gymmymac/bob-widget 1.1.6 → 1.1.10

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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Kr=t=>{throw TypeError(t)};var xr=(t,e,r)=>e.has(t)||Kr("Cannot "+r);var i=(t,e,r)=>(xr(t,e,"read from private field"),r?r.call(t):e.get(t)),M=(t,e,r)=>e.has(t)?Kr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),_=(t,e,r,s)=>(xr(t,e,"write to private field"),s?s.call(t,r):e.set(t,r),r),Q=(t,e,r)=>(xr(t,e,"access private method"),r);var hr=(t,e,r,s)=>({set _(a){_(t,e,a,r)},get _(){return i(t,e,s)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),zs=require("@supabase/supabase-js");function Gs(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const ve=Gs(d),nr="1.1.6",Ys=()=>nr;var wr={exports:{}},zt={};/**
1
+ "use strict";var zs=t=>{throw TypeError(t)};var xs=(t,e,s)=>e.has(t)||zs("Cannot "+s);var a=(t,e,s)=>(xs(t,e,"read from private field"),s?s.call(t):e.get(t)),M=(t,e,s)=>e.has(t)?zs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),k=(t,e,s,r)=>(xs(t,e,"write to private field"),r?r.call(t,s):e.set(t,s),s),q=(t,e,s)=>(xs(t,e,"access private method"),s);var fs=(t,e,s,r)=>({set _(o){k(t,e,o,s)},get _(){return a(t,e,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),Yr=require("@supabase/supabase-js");function Jr(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,r.get?r:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const Se=Jr(u),as="1.1.10",Xr=()=>as;var ws={exports:{}},Yt={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Vr;function Js(){if(Vr)return zt;Vr=1;var t=d,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function c(p,l,w){var m,h={},g=null,R=null;w!==void 0&&(g=""+w),l.key!==void 0&&(g=""+l.key),l.ref!==void 0&&(R=l.ref);for(m in l)s.call(l,m)&&!u.hasOwnProperty(m)&&(h[m]=l[m]);if(p&&p.defaultProps)for(m in l=p.defaultProps,l)h[m]===void 0&&(h[m]=l[m]);return{$$typeof:e,type:p,key:g,ref:R,props:h,_owner:a.current}}return zt.Fragment=r,zt.jsx=c,zt.jsxs=c,zt}var Gt={};/**
9
+ */var Hs;function Zr(){if(Hs)return Yt;Hs=1;var t=u,e=Symbol.for("react.element"),s=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(g,d,w){var h,m={},b=null,E=null;w!==void 0&&(b=""+w),d.key!==void 0&&(b=""+d.key),d.ref!==void 0&&(E=d.ref);for(h in d)r.call(d,h)&&!l.hasOwnProperty(h)&&(m[h]=d[h]);if(g&&g.defaultProps)for(h in d=g.defaultProps,d)m[h]===void 0&&(m[h]=d[h]);return{$$typeof:e,type:g,key:b,ref:E,props:m,_owner:o.current}}return Yt.Fragment=s,Yt.jsx=c,Yt.jsxs=c,Yt}var Jt={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,20 +14,20 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var Hr;function Xs(){return Hr||(Hr=1,process.env.NODE_ENV!=="production"&&function(){var t=d,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),p=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),R=Symbol.for("react.offscreen"),I=Symbol.iterator,T="@@iterator";function j(n){if(n===null||typeof n!="object")return null;var x=I&&n[I]||n[T];return typeof x=="function"?x:null}var k=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(n){{for(var x=arguments.length,P=new Array(x>1?x-1:0),A=1;A<x;A++)P[A-1]=arguments[A];E("error",n,P)}}function E(n,x,P){{var A=k.ReactDebugCurrentFrame,V=A.getStackAddendum();V!==""&&(x+="%s",P=P.concat([V]));var z=P.map(function(K){return String(K)});z.unshift("Warning: "+x),Function.prototype.apply.call(console[n],console,z)}}var f=!1,y=!1,v=!1,N=!1,O=!1,F;F=Symbol.for("react.module.reference");function C(n){return!!(typeof n=="string"||typeof n=="function"||n===s||n===u||O||n===a||n===w||n===m||N||n===R||f||y||v||typeof n=="object"&&n!==null&&(n.$$typeof===g||n.$$typeof===h||n.$$typeof===c||n.$$typeof===p||n.$$typeof===l||n.$$typeof===F||n.getModuleId!==void 0))}function S(n,x,P){var A=n.displayName;if(A)return A;var V=x.displayName||x.name||"";return V!==""?P+"("+V+")":P}function B(n){return n.displayName||"Context"}function L(n){if(n==null)return null;if(typeof n.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case s:return"Fragment";case r:return"Portal";case u:return"Profiler";case a:return"StrictMode";case w:return"Suspense";case m:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case p:var x=n;return B(x)+".Consumer";case c:var P=n;return B(P._context)+".Provider";case l:return S(n,n.render,"ForwardRef");case h:var A=n.displayName||null;return A!==null?A:L(n.type)||"Memo";case g:{var V=n,z=V._payload,K=V._init;try{return L(K(z))}catch{return null}}}return null}var D=Object.assign,J=0,xe,U,ne,fe,Be,G,rt;function ar(){}ar.__reactDisabledLog=!0;function we(){{if(J===0){xe=console.log,U=console.info,ne=console.warn,fe=console.error,Be=console.group,G=console.groupCollapsed,rt=console.groupEnd;var n={configurable:!0,enumerable:!0,value:ar,writable:!0};Object.defineProperties(console,{info:n,log:n,warn:n,error:n,group:n,groupCollapsed:n,groupEnd:n})}J++}}function gr(){{if(J--,J===0){var n={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},n,{value:xe}),info:D({},n,{value:U}),warn:D({},n,{value:ne}),error:D({},n,{value:fe}),group:D({},n,{value:Be}),groupCollapsed:D({},n,{value:G}),groupEnd:D({},n,{value:rt})})}J<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Rt=k.ReactCurrentDispatcher,or;function qt(n,x,P){{if(or===void 0)try{throw Error()}catch(V){var A=V.stack.trim().match(/\n( *(at )?)/);or=A&&A[1]||""}return`
18
- `+or+n}}var ur=!1,$t;{var Wr=typeof WeakMap=="function"?WeakMap:Map;$t=new Wr}function br(n,x){if(!n||ur)return"";{var P=$t.get(n);if(P!==void 0)return P}var A;ur=!0;var V=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var z;z=Rt.current,Rt.current=null,we();try{if(x){var K=function(){throw Error()};if(Object.defineProperty(K.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(K,[])}catch(le){A=le}Reflect.construct(n,[],K)}else{try{K.call()}catch(le){A=le}n.call(K.prototype)}}else{try{throw Error()}catch(le){A=le}n()}}catch(le){if(le&&A&&typeof le.stack=="string"){for(var q=le.stack.split(`
19
- `),ae=A.stack.split(`
20
- `),X=q.length-1,Z=ae.length-1;X>=1&&Z>=0&&q[X]!==ae[Z];)Z--;for(;X>=1&&Z>=0;X--,Z--)if(q[X]!==ae[Z]){if(X!==1||Z!==1)do if(X--,Z--,Z<0||q[X]!==ae[Z]){var ge=`
21
- `+q[X].replace(" at new "," at ");return n.displayName&&ge.includes("<anonymous>")&&(ge=ge.replace("<anonymous>",n.displayName)),typeof n=="function"&&$t.set(n,ge),ge}while(X>=1&&Z>=0);break}}}finally{ur=!1,Rt.current=z,gr(),Error.prepareStackTrace=V}var kt=n?n.displayName||n.name:"",ht=kt?qt(kt):"";return typeof n=="function"&&$t.set(n,ht),ht}function cr(n,x,P){return br(n,!1)}function lr(n){var x=n.prototype;return!!(x&&x.isReactComponent)}function st(n,x,P){if(n==null)return"";if(typeof n=="function")return br(n,lr(n));if(typeof n=="string")return qt(n);switch(n){case w:return qt("Suspense");case m:return qt("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case l:return cr(n.render);case h:return st(n.type,x,P);case g:{var A=n,V=A._payload,z=A._init;try{return st(z(V),x,P)}catch{}}}return""}var Ue=Object.prototype.hasOwnProperty,$={},ee=k.ReactDebugCurrentFrame;function te(n){if(n){var x=n._owner,P=st(n.type,n._source,x?x.type:null);ee.setExtraStackFrame(P)}else ee.setExtraStackFrame(null)}function ce(n,x,P,A,V){{var z=Function.call.bind(Ue);for(var K in n)if(z(n,K)){var q=void 0;try{if(typeof n[K]!="function"){var ae=Error((A||"React class")+": "+P+" type `"+K+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[K]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ae.name="Invariant Violation",ae}q=n[K](x,K,A,P,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(X){q=X}q&&!(q instanceof Error)&&(te(V),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",A||"React class",P,K,typeof q),te(null)),q instanceof Error&&!(q.message in $)&&($[q.message]=!0,te(V),b("Failed %s type: %s",P,q.message),te(null))}}}var qe=Array.isArray;function nt(n){return qe(n)}function it(n){{var x=typeof Symbol=="function"&&Symbol.toStringTag,P=x&&n[Symbol.toStringTag]||n.constructor.name||"Object";return P}}function at(n){try{return ot(n),!1}catch{return!0}}function ot(n){return""+n}function $e(n){if(at(n))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",it(n)),ot(n)}var Qe=k.ReactCurrentOwner,Ce={key:!0,ref:!0,__self:!0,__source:!0},ut,ct;function _e(n){if(Ue.call(n,"ref")){var x=Object.getOwnPropertyDescriptor(n,"ref").get;if(x&&x.isReactWarning)return!1}return n.ref!==void 0}function Se(n){if(Ue.call(n,"key")){var x=Object.getOwnPropertyDescriptor(n,"key").get;if(x&&x.isReactWarning)return!1}return n.key!==void 0}function Fe(n,x){typeof n.ref=="string"&&Qe.current}function lt(n,x){{var P=function(){ut||(ut=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",x))};P.isReactWarning=!0,Object.defineProperty(n,"key",{get:P,configurable:!0})}}function Ee(n,x){{var P=function(){ct||(ct=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",x))};P.isReactWarning=!0,Object.defineProperty(n,"ref",{get:P,configurable:!0})}}var pe=function(n,x,P,A,V,z,K){var q={$$typeof:e,type:n,key:x,ref:P,props:K,_owner:z};return q._store={},Object.defineProperty(q._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(q,"_self",{configurable:!1,enumerable:!1,writable:!1,value:A}),Object.defineProperty(q,"_source",{configurable:!1,enumerable:!1,writable:!1,value:V}),Object.freeze&&(Object.freeze(q.props),Object.freeze(q)),q};function Re(n,x,P,A,V){{var z,K={},q=null,ae=null;P!==void 0&&($e(P),q=""+P),Se(x)&&($e(x.key),q=""+x.key),_e(x)&&(ae=x.ref,Fe(x,V));for(z in x)Ue.call(x,z)&&!Ce.hasOwnProperty(z)&&(K[z]=x[z]);if(n&&n.defaultProps){var X=n.defaultProps;for(z in X)K[z]===void 0&&(K[z]=X[z])}if(q||ae){var Z=typeof n=="function"?n.displayName||n.name||"Unknown":n;q&&lt(K,Z),ae&&Ee(K,Z)}return pe(n,q,ae,V,A,Qe.current,K)}}var Oe=k.ReactCurrentOwner,Qt=k.ReactDebugCurrentFrame;function We(n){if(n){var x=n._owner,P=st(n.type,n._source,x?x.type:null);Qt.setExtraStackFrame(P)}else Qt.setExtraStackFrame(null)}var jt;jt=!1;function me(n){return typeof n=="object"&&n!==null&&n.$$typeof===e}function Ke(){{if(Oe.current){var n=L(Oe.current.type);if(n)return`
17
+ */var Gs;function en(){return Gs||(Gs=1,process.env.NODE_ENV!=="production"&&function(){var t=u,e=Symbol.for("react.element"),s=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),g=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),E=Symbol.for("react.offscreen"),I=Symbol.iterator,T="@@iterator";function R(i){if(i===null||typeof i!="object")return null;var v=I&&i[I]||i[T];return typeof v=="function"?v:null}var _=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(i){{for(var v=arguments.length,O=new Array(v>1?v-1:0),D=1;D<v;D++)O[D-1]=arguments[D];j("error",i,O)}}function j(i,v,O){{var D=_.ReactDebugCurrentFrame,V=D.getStackAddendum();V!==""&&(v+="%s",O=O.concat([V]));var H=O.map(function(K){return String(K)});H.unshift("Warning: "+v),Function.prototype.apply.call(console[i],console,H)}}var p=!1,f=!1,C=!1,N=!1,P=!1,F;F=Symbol.for("react.module.reference");function x(i){return!!(typeof i=="string"||typeof i=="function"||i===r||i===l||P||i===o||i===w||i===h||N||i===E||p||f||C||typeof i=="object"&&i!==null&&(i.$$typeof===b||i.$$typeof===m||i.$$typeof===c||i.$$typeof===g||i.$$typeof===d||i.$$typeof===F||i.getModuleId!==void 0))}function S(i,v,O){var D=i.displayName;if(D)return D;var V=v.displayName||v.name||"";return V!==""?O+"("+V+")":O}function W(i){return i.displayName||"Context"}function B(i){if(i==null)return null;if(typeof i.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case r:return"Fragment";case s:return"Portal";case l:return"Profiler";case o:return"StrictMode";case w:return"Suspense";case h:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case g:var v=i;return W(v)+".Consumer";case c:var O=i;return W(O._context)+".Provider";case d:return S(i,i.render,"ForwardRef");case m:var D=i.displayName||null;return D!==null?D:B(i.type)||"Memo";case b:{var V=i,H=V._payload,K=V._init;try{return B(K(H))}catch{return null}}}return null}var A=Object.assign,Y=0,oe,L,G,ae,ge,J,De;function Rt(){}Rt.__reactDisabledLog=!0;function me(){{if(Y===0){oe=console.log,L=console.info,G=console.warn,ae=console.error,ge=console.group,J=console.groupCollapsed,De=console.groupEnd;var i={configurable:!0,enumerable:!0,value:Rt,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}Y++}}function qt(){{if(Y--,Y===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},i,{value:oe}),info:A({},i,{value:L}),warn:A({},i,{value:G}),error:A({},i,{value:ae}),group:A({},i,{value:ge}),groupCollapsed:A({},i,{value:J}),groupEnd:A({},i,{value:De})})}Y<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var be=_.ReactCurrentDispatcher,ls;function Qt(i,v,O){{if(ls===void 0)try{throw Error()}catch(V){var D=V.stack.trim().match(/\n( *(at )?)/);ls=D&&D[1]||""}return`
18
+ `+ls+i}}var cs=!1,Wt;{var Vs=typeof WeakMap=="function"?WeakMap:Map;Wt=new Vs}function gs(i,v){if(!i||cs)return"";{var O=Wt.get(i);if(O!==void 0)return O}var D;cs=!0;var V=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var H;H=be.current,be.current=null,me();try{if(v){var K=function(){throw Error()};if(Object.defineProperty(K.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(K,[])}catch(he){D=he}Reflect.construct(i,[],K)}else{try{K.call()}catch(he){D=he}i.call(K.prototype)}}else{try{throw Error()}catch(he){D=he}i()}}catch(he){if(he&&D&&typeof he.stack=="string"){for(var U=he.stack.split(`
19
+ `),le=D.stack.split(`
20
+ `),Z=U.length-1,ee=le.length-1;Z>=1&&ee>=0&&U[Z]!==le[ee];)ee--;for(;Z>=1&&ee>=0;Z--,ee--)if(U[Z]!==le[ee]){if(Z!==1||ee!==1)do if(Z--,ee--,ee<0||U[Z]!==le[ee]){var xe=`
21
+ `+U[Z].replace(" at new "," at ");return i.displayName&&xe.includes("<anonymous>")&&(xe=xe.replace("<anonymous>",i.displayName)),typeof i=="function"&&Wt.set(i,xe),xe}while(Z>=1&&ee>=0);break}}}finally{cs=!1,be.current=H,qt(),Error.prepareStackTrace=V}var kt=i?i.displayName||i.name:"",ft=kt?Qt(kt):"";return typeof i=="function"&&Wt.set(i,ft),ft}function us(i,v,O){return gs(i,!1)}function ds(i){var v=i.prototype;return!!(v&&v.isReactComponent)}function nt(i,v,O){if(i==null)return"";if(typeof i=="function")return gs(i,ds(i));if(typeof i=="string")return Qt(i);switch(i){case w:return Qt("Suspense");case h:return Qt("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case d:return us(i.render);case m:return nt(i.type,v,O);case b:{var D=i,V=D._payload,H=D._init;try{return nt(H(V),v,O)}catch{}}}return""}var qe=Object.prototype.hasOwnProperty,$={},te=_.ReactDebugCurrentFrame;function se(i){if(i){var v=i._owner,O=nt(i.type,i._source,v?v.type:null);te.setExtraStackFrame(O)}else te.setExtraStackFrame(null)}function de(i,v,O,D,V){{var H=Function.call.bind(qe);for(var K in i)if(H(i,K)){var U=void 0;try{if(typeof i[K]!="function"){var le=Error((D||"React class")+": "+O+" type `"+K+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[K]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw le.name="Invariant Violation",le}U=i[K](v,K,D,O,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Z){U=Z}U&&!(U instanceof Error)&&(se(V),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",D||"React class",O,K,typeof U),se(null)),U instanceof Error&&!(U.message in $)&&($[U.message]=!0,se(V),y("Failed %s type: %s",O,U.message),se(null))}}}var Qe=Array.isArray;function it(i){return Qe(i)}function at(i){{var v=typeof Symbol=="function"&&Symbol.toStringTag,O=v&&i[Symbol.toStringTag]||i.constructor.name||"Object";return O}}function ot(i){try{return lt(i),!1}catch{return!0}}function lt(i){return""+i}function We(i){if(ot(i))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",at(i)),lt(i)}var Ke=_.ReactCurrentOwner,Ee={key:!0,ref:!0,__self:!0,__source:!0},ct,ut;function Oe(i){if(qe.call(i,"ref")){var v=Object.getOwnPropertyDescriptor(i,"ref").get;if(v&&v.isReactWarning)return!1}return i.ref!==void 0}function Ce(i){if(qe.call(i,"key")){var v=Object.getOwnPropertyDescriptor(i,"key").get;if(v&&v.isReactWarning)return!1}return i.key!==void 0}function Le(i,v){typeof i.ref=="string"&&Ke.current}function dt(i,v){{var O=function(){ct||(ct=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",v))};O.isReactWarning=!0,Object.defineProperty(i,"key",{get:O,configurable:!0})}}function Re(i,v){{var O=function(){ut||(ut=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",v))};O.isReactWarning=!0,Object.defineProperty(i,"ref",{get:O,configurable:!0})}}var ye=function(i,v,O,D,V,H,K){var U={$$typeof:e,type:i,key:v,ref:O,props:K,_owner:H};return U._store={},Object.defineProperty(U._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(U,"_self",{configurable:!1,enumerable:!1,writable:!1,value:D}),Object.defineProperty(U,"_source",{configurable:!1,enumerable:!1,writable:!1,value:V}),Object.freeze&&(Object.freeze(U.props),Object.freeze(U)),U};function Te(i,v,O,D,V){{var H,K={},U=null,le=null;O!==void 0&&(We(O),U=""+O),Ce(v)&&(We(v.key),U=""+v.key),Oe(v)&&(le=v.ref,Le(v,V));for(H in v)qe.call(v,H)&&!Ee.hasOwnProperty(H)&&(K[H]=v[H]);if(i&&i.defaultProps){var Z=i.defaultProps;for(H in Z)K[H]===void 0&&(K[H]=Z[H])}if(U||le){var ee=typeof i=="function"?i.displayName||i.name||"Unknown":i;U&&dt(K,ee),le&&Re(K,ee)}return ye(i,U,le,V,D,Ke.current,K)}}var Ie=_.ReactCurrentOwner,Kt=_.ReactDebugCurrentFrame;function Ve(i){if(i){var v=i._owner,O=nt(i.type,i._source,v?v.type:null);Kt.setExtraStackFrame(O)}else Kt.setExtraStackFrame(null)}var Tt;Tt=!1;function ve(i){return typeof i=="object"&&i!==null&&i.$$typeof===e}function ze(){{if(Ie.current){var i=B(Ie.current.type);if(i)return`
22
22
 
23
- Check the render method of \``+n+"`."}return""}}function Wt(n){return""}var je={};function dr(n){{var x=Ke();if(!x){var P=typeof n=="string"?n:n.displayName||n.name;P&&(x=`
23
+ Check the render method of \``+i+"`."}return""}}function Vt(i){return""}var _e={};function hs(i){{var v=ze();if(!v){var O=typeof i=="string"?i:i.displayName||i.name;O&&(v=`
24
24
 
25
- Check the top-level render call using <`+P+">.")}return x}}function re(n,x){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var P=dr(x);if(je[P])return;je[P]=!0;var A="";n&&n._owner&&n._owner!==Oe.current&&(A=" It was passed a child from "+L(n._owner.type)+"."),We(n),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',P,A),We(null)}}function Kt(n,x){{if(typeof n!="object")return;if(nt(n))for(var P=0;P<n.length;P++){var A=n[P];me(A)&&re(A,x)}else if(me(n))n._store&&(n._store.validated=!0);else if(n){var V=j(n);if(typeof V=="function"&&V!==n.entries)for(var z=V.call(n),K;!(K=z.next()).done;)me(K.value)&&re(K.value,x)}}}function Vt(n){{var x=n.type;if(x==null||typeof x=="string")return;var P;if(typeof x=="function")P=x.propTypes;else if(typeof x=="object"&&(x.$$typeof===l||x.$$typeof===h))P=x.propTypes;else return;if(P){var A=L(x);ce(P,n.props,"prop",A,n)}else if(x.PropTypes!==void 0&&!jt){jt=!0;var V=L(x);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",V||"Unknown")}typeof x.getDefaultProps=="function"&&!x.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function dt(n){{for(var x=Object.keys(n.props),P=0;P<x.length;P++){var A=x[P];if(A!=="children"&&A!=="key"){We(n),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",A),We(null);break}}n.ref!==null&&(We(n),b("Invalid attribute `ref` supplied to `React.Fragment`."),We(null))}}var Tt={};function Ht(n,x,P,A,V,z){{var K=C(n);if(!K){var q="";(n===void 0||typeof n=="object"&&n!==null&&Object.keys(n).length===0)&&(q+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ae=Wt();ae?q+=ae:q+=Ke();var X;n===null?X="null":nt(n)?X="array":n!==void 0&&n.$$typeof===e?(X="<"+(L(n.type)||"Unknown")+" />",q=" Did you accidentally export a JSX literal instead of a component?"):X=typeof n,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",X,q)}var Z=Re(n,x,P,V,z);if(Z==null)return Z;if(K){var ge=x.children;if(ge!==void 0)if(A)if(nt(ge)){for(var kt=0;kt<ge.length;kt++)Kt(ge[kt],n);Object.freeze&&Object.freeze(ge)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Kt(ge,n)}if(Ue.call(x,"key")){var ht=L(n),le=Object.keys(x).filter(function(Hs){return Hs!=="key"}),vr=le.length>0?"{key: someKey, "+le.join(": ..., ")+": ...}":"{key: someKey}";if(!Tt[ht+vr]){var Vs=le.length>0?"{"+le.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+O+">.")}return v}}function re(i,v){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var O=hs(v);if(_e[O])return;_e[O]=!0;var D="";i&&i._owner&&i._owner!==Ie.current&&(D=" It was passed a child from "+B(i._owner.type)+"."),Ve(i),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',O,D),Ve(null)}}function zt(i,v){{if(typeof i!="object")return;if(it(i))for(var O=0;O<i.length;O++){var D=i[O];ve(D)&&re(D,v)}else if(ve(i))i._store&&(i._store.validated=!0);else if(i){var V=R(i);if(typeof V=="function"&&V!==i.entries)for(var H=V.call(i),K;!(K=H.next()).done;)ve(K.value)&&re(K.value,v)}}}function Ht(i){{var v=i.type;if(v==null||typeof v=="string")return;var O;if(typeof v=="function")O=v.propTypes;else if(typeof v=="object"&&(v.$$typeof===d||v.$$typeof===m))O=v.propTypes;else return;if(O){var D=B(v);de(O,i.props,"prop",D,i)}else if(v.PropTypes!==void 0&&!Tt){Tt=!0;var V=B(v);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",V||"Unknown")}typeof v.getDefaultProps=="function"&&!v.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ht(i){{for(var v=Object.keys(i.props),O=0;O<v.length;O++){var D=v[O];if(D!=="children"&&D!=="key"){Ve(i),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",D),Ve(null);break}}i.ref!==null&&(Ve(i),y("Invalid attribute `ref` supplied to `React.Fragment`."),Ve(null))}}var _t={};function Gt(i,v,O,D,V,H){{var K=x(i);if(!K){var U="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(U+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var le=Vt();le?U+=le:U+=ze();var Z;i===null?Z="null":it(i)?Z="array":i!==void 0&&i.$$typeof===e?(Z="<"+(B(i.type)||"Unknown")+" />",U=" Did you accidentally export a JSX literal instead of a component?"):Z=typeof i,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Z,U)}var ee=Te(i,v,O,V,H);if(ee==null)return ee;if(K){var xe=v.children;if(xe!==void 0)if(D)if(it(xe)){for(var kt=0;kt<xe.length;kt++)zt(xe[kt],i);Object.freeze&&Object.freeze(xe)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else zt(xe,i)}if(qe.call(v,"key")){var ft=B(i),he=Object.keys(v).filter(function(Gr){return Gr!=="key"}),vs=he.length>0?"{key: someKey, "+he.join(": ..., ")+": ...}":"{key: someKey}";if(!_t[ft+vs]){var Hr=he.length>0?"{"+he.join(": ..., ")+": ...}":"{}";y(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,vr,ht,Vs,ht),Tt[ht+vr]=!0}}return n===s?dt(Z):Vt(Z),Z}}function yr(n,x,P){return Ht(n,x,P,!0)}function Qs(n,x,P){return Ht(n,x,P,!1)}var Ws=Qs,Ks=yr;Gt.Fragment=s,Gt.jsx=Ws,Gt.jsxs=Ks}()),Gt}process.env.NODE_ENV==="production"?wr.exports=Js():wr.exports=Xs();var o=wr.exports,ir=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Zs={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Pe,pt,us,en=(us=class{constructor(){M(this,Pe,Zs);M(this,pt,!1)}setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&i(this,pt)&&t!==i(this,Pe)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:i(this,Pe),provider:t}),_(this,Pe,t),process.env.NODE_ENV!=="production"&&_(this,pt,!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&_(this,pt,!0),i(this,Pe).setTimeout(t,e)}clearTimeout(t){i(this,Pe).clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&_(this,pt,!0),i(this,Pe).setInterval(t,e)}clearInterval(t){i(this,Pe).clearInterval(t)}},Pe=new WeakMap,pt=new WeakMap,us),ft=new en;function tn(t){setTimeout(t,0)}var Et=typeof window>"u"||"Deno"in globalThis;function he(){}function rn(t,e){return typeof t=="function"?t(e):t}function Cr(t){return typeof t=="number"&&t>=0&&t!==1/0}function ys(t,e){return Math.max(t+(e||0)-Date.now(),0)}function et(t,e){return typeof t=="function"?t(e):t}function ye(t,e){return typeof t=="function"?t(e):t}function zr(t,e){const{type:r="all",exact:s,fetchStatus:a,predicate:u,queryKey:c,stale:p}=t;if(c){if(s){if(e.queryHash!==Lr(c,e.options))return!1}else if(!Xt(e.queryKey,c))return!1}if(r!=="all"){const l=e.isActive();if(r==="active"&&!l||r==="inactive"&&l)return!1}return!(typeof p=="boolean"&&e.isStale()!==p||a&&a!==e.state.fetchStatus||u&&!u(e))}function Gr(t,e){const{exact:r,status:s,predicate:a,mutationKey:u}=t;if(u){if(!e.options.mutationKey)return!1;if(r){if(Jt(e.options.mutationKey)!==Jt(u))return!1}else if(!Xt(e.options.mutationKey,u))return!1}return!(s&&e.state.status!==s||a&&!a(e))}function Lr(t,e){return((e==null?void 0:e.queryKeyHashFn)||Jt)(t)}function Jt(t){return JSON.stringify(t,(e,r)=>Rr(r)?Object.keys(r).sort().reduce((s,a)=>(s[a]=r[a],s),{}):r)}function Xt(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>Xt(t[r],e[r])):!1}var sn=Object.prototype.hasOwnProperty;function Sr(t,e){if(t===e)return t;const r=Yr(t)&&Yr(e);if(!r&&!(Rr(t)&&Rr(e)))return e;const a=(r?t:Object.keys(t)).length,u=r?e:Object.keys(e),c=u.length,p=r?new Array(c):{};let l=0;for(let w=0;w<c;w++){const m=r?w:u[w],h=t[m],g=e[m];if(h===g){p[m]=h,(r?w<a:sn.call(t,m))&&l++;continue}if(h===null||g===null||typeof h!="object"||typeof g!="object"){p[m]=g;continue}const R=Sr(h,g);p[m]=R,R===h&&l++}return a===c&&l===a?t:p}function Er(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(t[r]!==e[r])return!1;return!0}function Yr(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Rr(t){if(!Jr(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!Jr(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Jr(t){return Object.prototype.toString.call(t)==="[object Object]"}function nn(t){return new Promise(e=>{ft.setTimeout(e,t)})}function jr(t,e,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(t,e);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Sr(t,e)}catch(s){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${s}`),s}return Sr(t,e)}return e}function an(t,e,r=0){const s=[...t,e];return r&&s.length>r?s.slice(1):s}function on(t,e,r=0){const s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}var pr=Symbol();function vs(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===pr&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===pr?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function un(t,e){return typeof t=="function"?t(...e):!!t}function cn(t,e,r){let s=!1,a;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(a??(a=e()),s||(s=!0,a.aborted?r():a.addEventListener("abort",r,{once:!0})),a)}),t}var mt,He,_t,cs,ln=(cs=class extends ir{constructor(){super();M(this,mt);M(this,He);M(this,_t);_(this,_t,e=>{if(!Et&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){i(this,He)||this.setEventListener(i(this,_t))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,He))==null||e.call(this),_(this,He,void 0))}setEventListener(e){var r;_(this,_t,e),(r=i(this,He))==null||r.call(this),_(this,He,e(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(e){i(this,mt)!==e&&(_(this,mt,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof i(this,mt)=="boolean"?i(this,mt):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},mt=new WeakMap,He=new WeakMap,_t=new WeakMap,cs),Dr=new ln;function Tr(){let t,e;const r=new Promise((a,u)=>{t=a,e=u});r.status="pending",r.catch(()=>{});function s(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{s({status:"fulfilled",value:a}),t(a)},r.reject=a=>{s({status:"rejected",reason:a}),e(a)},r}var dn=tn;function hn(){let t=[],e=0,r=p=>{p()},s=p=>{p()},a=dn;const u=p=>{e?t.push(p):a(()=>{r(p)})},c=()=>{const p=t;t=[],p.length&&a(()=>{s(()=>{p.forEach(l=>{r(l)})})})};return{batch:p=>{let l;e++;try{l=p()}finally{e--,e||c()}return l},batchCalls:p=>(...l)=>{u(()=>{p(...l)})},schedule:u,setNotifyFunction:p=>{r=p},setBatchNotifyFunction:p=>{s=p},setScheduler:p=>{a=p}}}var ie=hn(),Ot,ze,Pt,ls,fn=(ls=class extends ir{constructor(){super();M(this,Ot,!0);M(this,ze);M(this,Pt);_(this,Pt,e=>{if(!Et&&window.addEventListener){const r=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",s)}}})}onSubscribe(){i(this,ze)||this.setEventListener(i(this,Pt))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,ze))==null||e.call(this),_(this,ze,void 0))}setEventListener(e){var r;_(this,Pt,e),(r=i(this,ze))==null||r.call(this),_(this,ze,e(this.setOnline.bind(this)))}setOnline(e){i(this,Ot)!==e&&(_(this,Ot,e),this.listeners.forEach(s=>{s(e)}))}isOnline(){return i(this,Ot)}},Ot=new WeakMap,ze=new WeakMap,Pt=new WeakMap,ls),mr=new fn;function pn(t){return Math.min(1e3*2**t,3e4)}function xs(t){return(t??"online")==="online"?mr.isOnline():!0}var kr=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function ws(t){let e=!1,r=0,s;const a=Tr(),u=()=>a.status!=="pending",c=T=>{var j;if(!u()){const k=new kr(T);g(k),(j=t.onCancel)==null||j.call(t,k)}},p=()=>{e=!0},l=()=>{e=!1},w=()=>Dr.isFocused()&&(t.networkMode==="always"||mr.isOnline())&&t.canRun(),m=()=>xs(t.networkMode)&&t.canRun(),h=T=>{u()||(s==null||s(),a.resolve(T))},g=T=>{u()||(s==null||s(),a.reject(T))},R=()=>new Promise(T=>{var j;s=k=>{(u()||w())&&T(k)},(j=t.onPause)==null||j.call(t)}).then(()=>{var T;s=void 0,u()||(T=t.onContinue)==null||T.call(t)}),I=()=>{if(u())return;let T;const j=r===0?t.initialPromise:void 0;try{T=j??t.fn()}catch(k){T=Promise.reject(k)}Promise.resolve(T).then(h).catch(k=>{var v;if(u())return;const b=t.retry??(Et?0:3),E=t.retryDelay??pn,f=typeof E=="function"?E(r,k):E,y=b===!0||typeof b=="number"&&r<b||typeof b=="function"&&b(r,k);if(e||!y){g(k);return}r++,(v=t.onFail)==null||v.call(t,r,k),nn(f).then(()=>w()?void 0:R()).then(()=>{e?g(k):I()})})};return{promise:a,status:()=>a.status,cancel:c,continue:()=>(s==null||s(),a),cancelRetry:p,continueRetry:l,canStart:m,start:()=>(m()?I():R().then(I),a)}}var gt,ds,Cs=(ds=class{constructor(){M(this,gt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Cr(this.gcTime)&&_(this,gt,ft.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Et?1/0:5*60*1e3))}clearGcTimeout(){i(this,gt)&&(ft.clearTimeout(i(this,gt)),_(this,gt,void 0))}},gt=new WeakMap,ds),bt,It,be,yt,se,Zt,vt,Te,Ae,hs,mn=(hs=class extends Cs{constructor(e){super();M(this,Te);M(this,bt);M(this,It);M(this,be);M(this,yt);M(this,se);M(this,Zt);M(this,vt);_(this,vt,!1),_(this,Zt,e.defaultOptions),this.setOptions(e.options),this.observers=[],_(this,yt,e.client),_(this,be,i(this,yt).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,_(this,bt,Zr(this.options)),this.state=e.state??i(this,bt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=i(this,se))==null?void 0:e.promise}setOptions(e){if(this.options={...i(this,Zt),...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=Zr(this.options);r.data!==void 0&&(this.setState(Xr(r.data,r.dataUpdatedAt)),_(this,bt,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&i(this,be).remove(this)}setData(e,r){const s=jr(this.state.data,e,this.options);return Q(this,Te,Ae).call(this,{data:s,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),s}setState(e,r){Q(this,Te,Ae).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var s,a;const r=(s=i(this,se))==null?void 0:s.promise;return(a=i(this,se))==null||a.cancel(e),r?r.then(he).catch(he):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(i(this,bt))}isActive(){return this.observers.some(e=>ye(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===pr||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>et(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!ys(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(s=>s.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=i(this,se))==null||r.continue()}onOnline(){var r;const e=this.observers.find(s=>s.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=i(this,se))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),i(this,be).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(i(this,se)&&(i(this,vt)?i(this,se).cancel({revert:!0}):i(this,se).cancelRetry()),this.scheduleGc()),i(this,be).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Q(this,Te,Ae).call(this,{type:"invalidate"})}async fetch(e,r){var l,w,m,h,g,R,I,T,j,k,b,E;if(this.state.fetchStatus!=="idle"&&((l=i(this,se))==null?void 0:l.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(i(this,se))return i(this,se).continueRetry(),i(this,se).promise}if(e&&this.setOptions(e),!this.options.queryFn){const f=this.observers.find(y=>y.options.queryFn);f&&this.setOptions(f.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const s=new AbortController,a=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(_(this,vt,!0),s.signal)})},u=()=>{const f=vs(this.options,r),v=(()=>{const N={client:i(this,yt),queryKey:this.queryKey,meta:this.meta};return a(N),N})();return _(this,vt,!1),this.options.persister?this.options.persister(f,v,this):f(v)},p=(()=>{const f={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:i(this,yt),state:this.state,fetchFn:u};return a(f),f})();(w=this.options.behavior)==null||w.onFetch(p,this),_(this,It,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((m=p.fetchOptions)==null?void 0:m.meta))&&Q(this,Te,Ae).call(this,{type:"fetch",meta:(h=p.fetchOptions)==null?void 0:h.meta}),_(this,se,ws({initialPromise:r==null?void 0:r.initialPromise,fn:p.fetchFn,onCancel:f=>{f instanceof kr&&f.revert&&this.setState({...i(this,It),fetchStatus:"idle"}),s.abort()},onFail:(f,y)=>{Q(this,Te,Ae).call(this,{type:"failed",failureCount:f,error:y})},onPause:()=>{Q(this,Te,Ae).call(this,{type:"pause"})},onContinue:()=>{Q(this,Te,Ae).call(this,{type:"continue"})},retry:p.options.retry,retryDelay:p.options.retryDelay,networkMode:p.options.networkMode,canRun:()=>!0}));try{const f=await i(this,se).start();if(f===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(f),(R=(g=i(this,be).config).onSuccess)==null||R.call(g,f,this),(T=(I=i(this,be).config).onSettled)==null||T.call(I,f,this.state.error,this),f}catch(f){if(f instanceof kr){if(f.silent)return i(this,se).promise;if(f.revert){if(this.state.data===void 0)throw f;return this.state.data}}throw Q(this,Te,Ae).call(this,{type:"error",error:f}),(k=(j=i(this,be).config).onError)==null||k.call(j,f,this),(E=(b=i(this,be).config).onSettled)==null||E.call(b,this.state.data,f,this),f}finally{this.scheduleGc()}}},bt=new WeakMap,It=new WeakMap,be=new WeakMap,yt=new WeakMap,se=new WeakMap,Zt=new WeakMap,vt=new WeakMap,Te=new WeakSet,Ae=function(e){const r=s=>{switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...Ss(s.data,this.options),fetchMeta:e.meta??null};case"success":const a={...s,...Xr(e.data,e.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return _(this,It,e.manual?a:void 0),a;case"error":const u=e.error;return{...s,error:u,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:u,fetchStatus:"idle",status:"error"};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=r(this.state),ie.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),i(this,be).notify({query:this,type:"updated",action:e})})},hs);function Ss(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:xs(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Xr(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Zr(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,s=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var de,W,er,oe,xt,Nt,Le,Ge,tr,Mt,Ft,wt,Ct,Ye,At,H,Yt,_r,Or,Pr,Ir,Nr,Mr,Fr,Es,fs,gn=(fs=class extends ir{constructor(e,r){super();M(this,H);M(this,de);M(this,W);M(this,er);M(this,oe);M(this,xt);M(this,Nt);M(this,Le);M(this,Ge);M(this,tr);M(this,Mt);M(this,Ft);M(this,wt);M(this,Ct);M(this,Ye);M(this,At,new Set);this.options=r,_(this,de,e),_(this,Ge,null),_(this,Le,Tr()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,W).addObserver(this),es(i(this,W),this.options)?Q(this,H,Yt).call(this):this.updateResult(),Q(this,H,Ir).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ar(i(this,W),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ar(i(this,W),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Q(this,H,Nr).call(this),Q(this,H,Mr).call(this),i(this,W).removeObserver(this)}setOptions(e){const r=this.options,s=i(this,W);if(this.options=i(this,de).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ye(this.options.enabled,i(this,W))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Q(this,H,Fr).call(this),i(this,W).setOptions(this.options),r._defaulted&&!Er(this.options,r)&&i(this,de).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,W),observer:this});const a=this.hasListeners();a&&ts(i(this,W),s,this.options,r)&&Q(this,H,Yt).call(this),this.updateResult(),a&&(i(this,W)!==s||ye(this.options.enabled,i(this,W))!==ye(r.enabled,i(this,W))||et(this.options.staleTime,i(this,W))!==et(r.staleTime,i(this,W)))&&Q(this,H,_r).call(this);const u=Q(this,H,Or).call(this);a&&(i(this,W)!==s||ye(this.options.enabled,i(this,W))!==ye(r.enabled,i(this,W))||u!==i(this,Ye))&&Q(this,H,Pr).call(this,u)}getOptimisticResult(e){const r=i(this,de).getQueryCache().build(i(this,de),e),s=this.createResult(r,e);return yn(this,s)&&(_(this,oe,s),_(this,Nt,this.options),_(this,xt,i(this,W).state)),s}getCurrentResult(){return i(this,oe)}trackResult(e,r){return new Proxy(e,{get:(s,a)=>(this.trackProp(a),r==null||r(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&i(this,Le).status==="pending"&&i(this,Le).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,a))})}trackProp(e){i(this,At).add(e)}getCurrentQuery(){return i(this,W)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=i(this,de).defaultQueryOptions(e),s=i(this,de).getQueryCache().build(i(this,de),r);return s.fetch().then(()=>this.createResult(s,r))}fetch(e){return Q(this,H,Yt).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,oe)))}createResult(e,r){var F;const s=i(this,W),a=this.options,u=i(this,oe),c=i(this,xt),p=i(this,Nt),w=e!==s?e.state:i(this,er),{state:m}=e;let h={...m},g=!1,R;if(r._optimisticResults){const C=this.hasListeners(),S=!C&&es(e,r),B=C&&ts(e,s,r,a);(S||B)&&(h={...h,...Ss(m.data,e.options)}),r._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:I,errorUpdatedAt:T,status:j}=h;R=h.data;let k=!1;if(r.placeholderData!==void 0&&R===void 0&&j==="pending"){let C;u!=null&&u.isPlaceholderData&&r.placeholderData===(p==null?void 0:p.placeholderData)?(C=u.data,k=!0):C=typeof r.placeholderData=="function"?r.placeholderData((F=i(this,Ft))==null?void 0:F.state.data,i(this,Ft)):r.placeholderData,C!==void 0&&(j="success",R=jr(u==null?void 0:u.data,C,r),g=!0)}if(r.select&&R!==void 0&&!k)if(u&&R===(c==null?void 0:c.data)&&r.select===i(this,tr))R=i(this,Mt);else try{_(this,tr,r.select),R=r.select(R),R=jr(u==null?void 0:u.data,R,r),_(this,Mt,R),_(this,Ge,null)}catch(C){_(this,Ge,C)}i(this,Ge)&&(I=i(this,Ge),R=i(this,Mt),T=Date.now(),j="error");const b=h.fetchStatus==="fetching",E=j==="pending",f=j==="error",y=E&&b,v=R!==void 0,O={status:j,fetchStatus:h.fetchStatus,isPending:E,isSuccess:j==="success",isError:f,isInitialLoading:y,isLoading:y,data:R,dataUpdatedAt:h.dataUpdatedAt,error:I,errorUpdatedAt:T,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>w.dataUpdateCount||h.errorUpdateCount>w.errorUpdateCount,isFetching:b,isRefetching:b&&!E,isLoadingError:f&&!v,isPaused:h.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:f&&v,isStale:Br(e,r),refetch:this.refetch,promise:i(this,Le),isEnabled:ye(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const C=L=>{O.status==="error"?L.reject(O.error):O.data!==void 0&&L.resolve(O.data)},S=()=>{const L=_(this,Le,O.promise=Tr());C(L)},B=i(this,Le);switch(B.status){case"pending":e.queryHash===s.queryHash&&C(B);break;case"fulfilled":(O.status==="error"||O.data!==B.value)&&S();break;case"rejected":(O.status!=="error"||O.error!==B.reason)&&S();break}}return O}updateResult(){const e=i(this,oe),r=this.createResult(i(this,W),this.options);if(_(this,xt,i(this,W).state),_(this,Nt,this.options),i(this,xt).data!==void 0&&_(this,Ft,i(this,W)),Er(r,e))return;_(this,oe,r);const s=()=>{if(!e)return!0;const{notifyOnChangeProps:a}=this.options,u=typeof a=="function"?a():a;if(u==="all"||!u&&!i(this,At).size)return!0;const c=new Set(u??i(this,At));return this.options.throwOnError&&c.add("error"),Object.keys(i(this,oe)).some(p=>{const l=p;return i(this,oe)[l]!==e[l]&&c.has(l)})};Q(this,H,Es).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Q(this,H,Ir).call(this)}},de=new WeakMap,W=new WeakMap,er=new WeakMap,oe=new WeakMap,xt=new WeakMap,Nt=new WeakMap,Le=new WeakMap,Ge=new WeakMap,tr=new WeakMap,Mt=new WeakMap,Ft=new WeakMap,wt=new WeakMap,Ct=new WeakMap,Ye=new WeakMap,At=new WeakMap,H=new WeakSet,Yt=function(e){Q(this,H,Fr).call(this);let r=i(this,W).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(he)),r},_r=function(){Q(this,H,Nr).call(this);const e=et(this.options.staleTime,i(this,W));if(Et||i(this,oe).isStale||!Cr(e))return;const s=ys(i(this,oe).dataUpdatedAt,e)+1;_(this,wt,ft.setTimeout(()=>{i(this,oe).isStale||this.updateResult()},s))},Or=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,W)):this.options.refetchInterval)??!1},Pr=function(e){Q(this,H,Mr).call(this),_(this,Ye,e),!(Et||ye(this.options.enabled,i(this,W))===!1||!Cr(i(this,Ye))||i(this,Ye)===0)&&_(this,Ct,ft.setInterval(()=>{(this.options.refetchIntervalInBackground||Dr.isFocused())&&Q(this,H,Yt).call(this)},i(this,Ye)))},Ir=function(){Q(this,H,_r).call(this),Q(this,H,Pr).call(this,Q(this,H,Or).call(this))},Nr=function(){i(this,wt)&&(ft.clearTimeout(i(this,wt)),_(this,wt,void 0))},Mr=function(){i(this,Ct)&&(ft.clearInterval(i(this,Ct)),_(this,Ct,void 0))},Fr=function(){const e=i(this,de).getQueryCache().build(i(this,de),this.options);if(e===i(this,W))return;const r=i(this,W);_(this,W,e),_(this,er,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},Es=function(e){ie.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(i(this,oe))}),i(this,de).getQueryCache().notify({query:i(this,W),type:"observerResultsUpdated"})})},fs);function bn(t,e){return ye(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function es(t,e){return bn(t,e)||t.state.data!==void 0&&Ar(t,e,e.refetchOnMount)}function Ar(t,e,r){if(ye(e.enabled,t)!==!1&&et(e.staleTime,t)!=="static"){const s=typeof r=="function"?r(t):r;return s==="always"||s!==!1&&Br(t,e)}return!1}function ts(t,e,r,s){return(t!==e||ye(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&Br(t,r)}function Br(t,e){return ye(e.enabled,t)!==!1&&t.isStaleByTime(et(e.staleTime,t))}function yn(t,e){return!Er(t.getCurrentResult(),e)}function rs(t){return{onFetch:(e,r)=>{var m,h,g,R,I;const s=e.options,a=(g=(h=(m=e.fetchOptions)==null?void 0:m.meta)==null?void 0:h.fetchMore)==null?void 0:g.direction,u=((R=e.state.data)==null?void 0:R.pages)||[],c=((I=e.state.data)==null?void 0:I.pageParams)||[];let p={pages:[],pageParams:[]},l=0;const w=async()=>{let T=!1;const j=E=>{cn(E,()=>e.signal,()=>T=!0)},k=vs(e.options,e.fetchOptions),b=async(E,f,y)=>{if(T)return Promise.reject();if(f==null&&E.pages.length)return Promise.resolve(E);const N=(()=>{const S={client:e.client,queryKey:e.queryKey,pageParam:f,direction:y?"backward":"forward",meta:e.options.meta};return j(S),S})(),O=await k(N),{maxPages:F}=e.options,C=y?on:an;return{pages:C(E.pages,O,F),pageParams:C(E.pageParams,f,F)}};if(a&&u.length){const E=a==="backward",f=E?vn:ss,y={pages:u,pageParams:c},v=f(s,y);p=await b(y,v,E)}else{const E=t??u.length;do{const f=l===0?c[0]??s.initialPageParam:ss(s,p);if(l>0&&f==null)break;p=await b(p,f),l++}while(l<E)}return p};e.options.persister?e.fetchFn=()=>{var T,j;return(j=(T=e.options).persister)==null?void 0:j.call(T,w,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=w}}}function ss(t,{pages:e,pageParams:r}){const s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}function vn(t,{pages:e,pageParams:r}){var s;return e.length>0?(s=t.getPreviousPageParam)==null?void 0:s.call(t,e[0],e,r[0],r):void 0}var rr,Ie,ue,St,Ne,Ve,ps,xn=(ps=class extends Cs{constructor(e){super();M(this,Ne);M(this,rr);M(this,Ie);M(this,ue);M(this,St);_(this,rr,e.client),this.mutationId=e.mutationId,_(this,ue,e.mutationCache),_(this,Ie,[]),this.state=e.state||wn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){i(this,Ie).includes(e)||(i(this,Ie).push(e),this.clearGcTimeout(),i(this,ue).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){_(this,Ie,i(this,Ie).filter(r=>r!==e)),this.scheduleGc(),i(this,ue).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){i(this,Ie).length||(this.state.status==="pending"?this.scheduleGc():i(this,ue).remove(this))}continue(){var e;return((e=i(this,St))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var c,p,l,w,m,h,g,R,I,T,j,k,b,E,f,y,v,N,O,F;const r=()=>{Q(this,Ne,Ve).call(this,{type:"continue"})},s={client:i(this,rr),meta:this.options.meta,mutationKey:this.options.mutationKey};_(this,St,ws({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(C,S)=>{Q(this,Ne,Ve).call(this,{type:"failed",failureCount:C,error:S})},onPause:()=>{Q(this,Ne,Ve).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>i(this,ue).canRun(this)}));const a=this.state.status==="pending",u=!i(this,St).canStart();try{if(a)r();else{Q(this,Ne,Ve).call(this,{type:"pending",variables:e,isPaused:u}),await((p=(c=i(this,ue).config).onMutate)==null?void 0:p.call(c,e,this,s));const S=await((w=(l=this.options).onMutate)==null?void 0:w.call(l,e,s));S!==this.state.context&&Q(this,Ne,Ve).call(this,{type:"pending",context:S,variables:e,isPaused:u})}const C=await i(this,St).start();return await((h=(m=i(this,ue).config).onSuccess)==null?void 0:h.call(m,C,e,this.state.context,this,s)),await((R=(g=this.options).onSuccess)==null?void 0:R.call(g,C,e,this.state.context,s)),await((T=(I=i(this,ue).config).onSettled)==null?void 0:T.call(I,C,null,this.state.variables,this.state.context,this,s)),await((k=(j=this.options).onSettled)==null?void 0:k.call(j,C,null,e,this.state.context,s)),Q(this,Ne,Ve).call(this,{type:"success",data:C}),C}catch(C){try{throw await((E=(b=i(this,ue).config).onError)==null?void 0:E.call(b,C,e,this.state.context,this,s)),await((y=(f=this.options).onError)==null?void 0:y.call(f,C,e,this.state.context,s)),await((N=(v=i(this,ue).config).onSettled)==null?void 0:N.call(v,void 0,C,this.state.variables,this.state.context,this,s)),await((F=(O=this.options).onSettled)==null?void 0:F.call(O,void 0,C,e,this.state.context,s)),C}finally{Q(this,Ne,Ve).call(this,{type:"error",error:C})}}finally{i(this,ue).runNext(this)}}},rr=new WeakMap,Ie=new WeakMap,ue=new WeakMap,St=new WeakMap,Ne=new WeakSet,Ve=function(e){const r=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),ie.batch(()=>{i(this,Ie).forEach(s=>{s.onMutationUpdate(e)}),i(this,ue).notify({mutation:this,type:"updated",action:e})})},ps);function wn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var De,ke,sr,ms,Cn=(ms=class extends ir{constructor(e={}){super();M(this,De);M(this,ke);M(this,sr);this.config=e,_(this,De,new Set),_(this,ke,new Map),_(this,sr,0)}build(e,r,s){const a=new xn({client:e,mutationCache:this,mutationId:++hr(this,sr)._,options:e.defaultMutationOptions(r),state:s});return this.add(a),a}add(e){i(this,De).add(e);const r=fr(e);if(typeof r=="string"){const s=i(this,ke).get(r);s?s.push(e):i(this,ke).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(i(this,De).delete(e)){const r=fr(e);if(typeof r=="string"){const s=i(this,ke).get(r);if(s)if(s.length>1){const a=s.indexOf(e);a!==-1&&s.splice(a,1)}else s[0]===e&&i(this,ke).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=fr(e);if(typeof r=="string"){const s=i(this,ke).get(r),a=s==null?void 0:s.find(u=>u.state.status==="pending");return!a||a===e}else return!0}runNext(e){var s;const r=fr(e);if(typeof r=="string"){const a=(s=i(this,ke).get(r))==null?void 0:s.find(u=>u!==e&&u.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ie.batch(()=>{i(this,De).forEach(e=>{this.notify({type:"removed",mutation:e})}),i(this,De).clear(),i(this,ke).clear()})}getAll(){return Array.from(i(this,De))}find(e){const r={exact:!0,...e};return this.getAll().find(s=>Gr(r,s))}findAll(e={}){return this.getAll().filter(r=>Gr(e,r))}notify(e){ie.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return ie.batch(()=>Promise.all(e.map(r=>r.continue().catch(he))))}},De=new WeakMap,ke=new WeakMap,sr=new WeakMap,ms);function fr(t){var e;return(e=t.options.scope)==null?void 0:e.id}var Me,gs,Sn=(gs=class extends ir{constructor(e={}){super();M(this,Me);this.config=e,_(this,Me,new Map)}build(e,r,s){const a=r.queryKey,u=r.queryHash??Lr(a,r);let c=this.get(u);return c||(c=new mn({client:e,queryKey:a,queryHash:u,options:e.defaultQueryOptions(r),state:s,defaultOptions:e.getQueryDefaults(a)}),this.add(c)),c}add(e){i(this,Me).has(e.queryHash)||(i(this,Me).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=i(this,Me).get(e.queryHash);r&&(e.destroy(),r===e&&i(this,Me).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ie.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return i(this,Me).get(e)}getAll(){return[...i(this,Me).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(s=>zr(r,s))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(s=>zr(e,s)):r}notify(e){ie.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){ie.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ie.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Me=new WeakMap,gs),Y,Je,Xe,Lt,Dt,Ze,Bt,Ut,bs,En=(bs=class{constructor(t={}){M(this,Y);M(this,Je);M(this,Xe);M(this,Lt);M(this,Dt);M(this,Ze);M(this,Bt);M(this,Ut);_(this,Y,t.queryCache||new Sn),_(this,Je,t.mutationCache||new Cn),_(this,Xe,t.defaultOptions||{}),_(this,Lt,new Map),_(this,Dt,new Map),_(this,Ze,0)}mount(){hr(this,Ze)._++,i(this,Ze)===1&&(_(this,Bt,Dr.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,Y).onFocus())})),_(this,Ut,mr.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,Y).onOnline())})))}unmount(){var t,e;hr(this,Ze)._--,i(this,Ze)===0&&((t=i(this,Bt))==null||t.call(this),_(this,Bt,void 0),(e=i(this,Ut))==null||e.call(this),_(this,Ut,void 0))}isFetching(t){return i(this,Y).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return i(this,Je).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=i(this,Y).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=i(this,Y).build(this,e),s=r.state.data;return s===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(et(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(t){return i(this,Y).findAll(t).map(({queryKey:e,state:r})=>{const s=r.data;return[e,s]})}setQueryData(t,e,r){const s=this.defaultQueryOptions({queryKey:t}),a=i(this,Y).get(s.queryHash),u=a==null?void 0:a.state.data,c=rn(e,u);if(c!==void 0)return i(this,Y).build(this,s).setData(c,{...r,manual:!0})}setQueriesData(t,e,r){return ie.batch(()=>i(this,Y).findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=i(this,Y).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=i(this,Y);ie.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=i(this,Y);return ie.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},s=ie.batch(()=>i(this,Y).findAll(t).map(a=>a.cancel(r)));return Promise.all(s).then(he).catch(he)}invalidateQueries(t,e={}){return ie.batch(()=>(i(this,Y).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},s=ie.batch(()=>i(this,Y).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let u=a.fetch(void 0,r);return r.throwOnError||(u=u.catch(he)),a.state.fetchStatus==="paused"?Promise.resolve():u}));return Promise.all(s).then(he)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=i(this,Y).build(this,e);return r.isStaleByTime(et(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(he).catch(he)}fetchInfiniteQuery(t){return t.behavior=rs(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(he).catch(he)}ensureInfiniteQueryData(t){return t.behavior=rs(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return mr.isOnline()?i(this,Je).resumePausedMutations():Promise.resolve()}getQueryCache(){return i(this,Y)}getMutationCache(){return i(this,Je)}getDefaultOptions(){return i(this,Xe)}setDefaultOptions(t){_(this,Xe,t)}setQueryDefaults(t,e){i(this,Lt).set(Jt(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...i(this,Lt).values()],r={};return e.forEach(s=>{Xt(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){i(this,Dt).set(Jt(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...i(this,Dt).values()],r={};return e.forEach(s=>{Xt(t,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...i(this,Xe).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Lr(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===pr&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...i(this,Xe).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){i(this,Y).clear(),i(this,Je).clear()}},Y=new WeakMap,Je=new WeakMap,Xe=new WeakMap,Lt=new WeakMap,Dt=new WeakMap,Ze=new WeakMap,Bt=new WeakMap,Ut=new WeakMap,bs),Rs=ve.createContext(void 0),js=t=>{const e=ve.useContext(Rs);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Rn=({client:t,children:e})=>(ve.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),o.jsx(Rs.Provider,{value:t,children:e})),Ts=ve.createContext(!1),jn=()=>ve.useContext(Ts);Ts.Provider;function Tn(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var kn=ve.createContext(Tn()),_n=()=>ve.useContext(kn),On=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Pn=t=>{ve.useEffect(()=>{t.clearReset()},[t])},In=({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:a})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(a&&t.data===void 0||un(r,[t.error,s])),Nn=t=>{if(t.suspense){const r=a=>a==="static"?a:Math.max(a??1e3,1e3),s=t.staleTime;t.staleTime=typeof s=="function"?(...a)=>r(s(...a)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Mn=(t,e)=>t.isLoading&&t.isFetching&&!e,Fn=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,ns=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function An(t,e,r){var h,g,R,I,T;if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const s=jn(),a=_n(),u=js(),c=u.defaultQueryOptions(t);(g=(h=u.getDefaultOptions().queries)==null?void 0:h._experimental_beforeQuery)==null||g.call(h,c),process.env.NODE_ENV!=="production"&&(c.queryFn||console.error(`[${c.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),c._optimisticResults=s?"isRestoring":"optimistic",Nn(c),On(c,a),Pn(a);const p=!u.getQueryCache().get(c.queryHash),[l]=ve.useState(()=>new e(u,c)),w=l.getOptimisticResult(c),m=!s&&t.subscribed!==!1;if(ve.useSyncExternalStore(ve.useCallback(j=>{const k=m?l.subscribe(ie.batchCalls(j)):he;return l.updateResult(),k},[l,m]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),ve.useEffect(()=>{l.setOptions(c)},[c,l]),Fn(c,w))throw ns(c,l,a);if(In({result:w,errorResetBoundary:a,throwOnError:c.throwOnError,query:u.getQueryCache().get(c.queryHash),suspense:c.suspense}))throw w.error;if((I=(R=u.getDefaultOptions().queries)==null?void 0:R._experimental_afterQuery)==null||I.call(R,c,w),c.experimental_prefetchInRender&&!Et&&Mn(w,s)){const j=p?ns(c,l,a):(T=u.getQueryCache().get(c.queryHash))==null?void 0:T.promise;j==null||j.catch(he).finally(()=>{l.updateResult()})}return c.notifyOnChangeProps?w:l.trackResult(w)}function ks(t,e){return An(t,gn)}const _s=d.createContext(null);function Os({children:t,bobConfig:e,hostApiConfig:r,hostContext:s={},callbacks:a={},queryClient:u}){const c=d.useMemo(()=>new En({defaultOptions:{queries:{retry:1,staleTime:3e5}}}),[]),p=u||c,l=!!u;d.useEffect(()=>{console.log(`[BobWidget] v${nr} initialized`),console.log(`[BobWidget] QueryClient: ${l?"external (shared)":"internal"}`)},[l]);const w=d.useMemo(()=>zs.createClient(e.supabaseUrl,e.supabaseKey),[e.supabaseUrl,e.supabaseKey]),[m,h]=d.useState(s);d.useEffect(()=>{h(s)},[s]);const g=d.useCallback(I=>{h(T=>({...T,...I}))},[]),R=d.useMemo(()=>({bobSupabase:w,bobConfig:e,hostApiConfig:r,hostContext:m,callbacks:a,updateHostContext:g}),[w,e,r,m,a,g]);return o.jsx(Rn,{client:p,children:o.jsx(_s.Provider,{value:R,children:t})})}function tt(){const t=d.useContext(_s);if(!t)throw new Error("useBobContext must be used within a BobProvider");return t}function Ur(){const{bobSupabase:t}=tt();return t}function Ln(){const{hostContext:t}=tt();return t}function Dn(){const{hostApiConfig:t}=tt();return t}function Bn(){const{callbacks:t}=tt();return t}const is=8e3,Ps=({onStart:t,onEnd:e,onFailed:r}={})=>{const{bobConfig:s}=tt(),[a,u]=d.useState(!1),c=d.useRef(null),p=d.useRef(null),l=d.useRef(!1),w=d.useRef(t),m=d.useRef(e),h=d.useRef(r);d.useEffect(()=>{w.current=t,m.current=e,h.current=r},[t,e,r]);const g=d.useCallback(()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]),R=d.useCallback(()=>{var b;l.current||(l.current=!0,console.log("[BobWidget TTS] Fallback: triggering onStart without audio"),(b=w.current)==null||b.call(w))},[]),I=d.useCallback(async b=>{var E,f,y;if(b.trim()){l.current=!1,g(),c.current&&(c.current.pause(),c.current=null),p.current=setTimeout(()=>{var v,N;console.warn("[BobWidget TTS] Timeout after 5s - triggering fallback callbacks"),R(),u(!1),(v=m.current)==null||v.call(m),(N=h.current)==null||N.call(h),c.current=null},is);try{const v=new AbortController,N=setTimeout(()=>v.abort(),is-1e3),O=await fetch(`${s.supabaseUrl}/functions/v1/bob-tts`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.supabaseKey}`},body:JSON.stringify({text:b}),signal:v.signal});if(clearTimeout(N),!O.ok){const S=await O.json().catch(()=>({}));throw console.error("[BobWidget TTS] Request failed:",S),new Error("TTS request failed")}const{audioContent:F}=await O.json(),C=new Audio(`data:audio/mp3;base64,${F}`);c.current=C,C.onplay=()=>{var S;g(),l.current||(l.current=!0,u(!0),console.log("[BobWidget TTS] Audio playing, triggering onStart"),(S=w.current)==null||S.call(w))},C.onended=()=>{var S;g(),u(!1),(S=m.current)==null||S.call(m),c.current=null},C.onerror=S=>{var B,L;g(),console.warn("[BobWidget TTS] Audio playback error:",S),R(),u(!1),(B=m.current)==null||B.call(m),(L=h.current)==null||L.call(h),c.current=null};try{await C.play()}catch(S){console.warn("[BobWidget TTS] Audio play() failed (autoplay policy), will retry on user interaction:",S),g(),R(),u(!1),(E=m.current)==null||E.call(m)}}catch(v){g(),console.error("[BobWidget TTS] Speech synthesis error:",v),R(),u(!1),(f=m.current)==null||f.call(m),(y=h.current)==null||y.call(h)}}},[s.supabaseUrl,s.supabaseKey,g,R]),T=d.useCallback(()=>{g(),c.current&&(c.current.pause(),c.current=null),u(!1)},[g]),j=d.useCallback(()=>{var b;(b=c.current)==null||b.pause()},[]),k=d.useCallback(()=>{var b;(b=c.current)==null||b.play()},[]);return d.useEffect(()=>()=>{g(),c.current&&(c.current.pause(),c.current=null)},[g]),{speak:I,stop:T,pause:j,resume:k,isSpeaking:a,isSupported:!0}},Un=["what version","which version","software version","bob version","your version","current version","running version","version number","what ver","which ver"],as=["recommend","suggest","need","part","filter","brake","rotor","oil","price","$","stock","available","pads","disc","spark plug","battery","clutch","alternator","starter","muffler","exhaust","service pack","add-on","tyre shine","windscreen wash"],qn=["WIPER BLADE FRONT","WIPER BLADE REAR","WIPER BLADE SET","BRAKE PAD KIT","BRAKE PAD KIT FRONT","BRAKE PAD KIT REAR","BRAKE ROTOR","BRAKE ROTOR FRONT","BRAKE ROTOR REAR","BRAKE DISC","AIR FILTER","OIL FILTER","CABIN FILTER","FUEL FILTER","SPARK PLUG SET","SPARK PLUG","BALL JOINT","TIE ROD END","CONTROL ARM","WHEEL BEARING","CV JOINT","DRIVE SHAFT","TIMING BELT KIT","SERPENTINE BELT","DRIVE BELT","SHOCK ABSORBER","STRUT","COIL SPRING","CLUTCH KIT","CLUTCH PLATE","ALTERNATOR","STARTER MOTOR","WATER PUMP","THERMOSTAT","RADIATOR","RADIATOR HOSE","EXHAUST","MUFFLER","CATALYTIC CONVERTER","brake pads","brake rotors","brake discs","brakes","air filter","oil filter","cabin filter","fuel filter","spark plugs","spark plug","wiper","wipers","battery","batteries","clutch","clutch kit","alternator","starter motor","muffler","exhaust","cv joint","axle","timing belt","serpentine belt","shock absorber","struts","suspension"],Is=({setAnimationState:t,manualMode:e=!1,talkingState:r="talk",thinkingState:s="research",completeState:a="complete",idleState:u="idle",listenState:c="talk_pause",onStreamStart:p,onStreamComplete:l,onShowingProduct:w,onResearchStart:m,onReadyToSpeak:h,onHighlightPart:g,onHighlightProduct:R,onNoPartsFound:I,onAutoFetchComplete:T})=>{var cr,lr,st,Ue;const{bobConfig:j,hostApiConfig:k,hostContext:b,callbacks:E}=tt(),[f,y]=d.useState([]),[v,N]=d.useState(""),[O,F]=d.useState(!1),[C,S]=d.useState(!1),[B,L]=d.useState(null),D=d.useRef(null),J=d.useRef(!1),xe=d.useRef(!1),U=d.useRef(""),ne=d.useRef(!1),fe=d.useRef(null),Be=()=>{fe.current&&(clearTimeout(fe.current),fe.current=null)},{speak:G,stop:rt,isSpeaking:ar}=Ps({onStart:()=>{Be(),ne.current=!0,console.log("[BobWidget] Speech started - revealing products"),h==null||h(),e||we(r)},onEnd:()=>{Be();const $=as.some(ee=>U.current.toLowerCase().includes(ee.toLowerCase()));e||($&&w?w():l?l():(we(a),setTimeout(()=>we(c),3e3)))},onFailed:()=>{console.warn("[BobWidget] Speech synthesis failed - fallback triggered")}});d.useEffect(()=>{var $;($=D.current)==null||$.scrollIntoView({behavior:"smooth"})},[f]),d.useEffect(()=>{var ee,te;const $=(ee=b.vehicle)==null?void 0:ee.selectedVehicle;$&&!B&&(console.log("[BobWidget] Setting vehicle from host context:",$),L($),(te=E.onVehicleIdentified)==null||te.call(E,$))},[(cr=b.vehicle)==null?void 0:cr.selectedVehicle]),d.useEffect(()=>{var $;if(f.length===0&&!xe.current){xe.current=!0;const ee=($=b.vehicle)==null?void 0:$.selectedVehicle;let te;ee?te=`G'day! Saw you've got the ${`${ee.year} ${ee.make} ${ee.model}`} - choice wagon! What can I help you find for it today?`:te="G'day! Bob from CARFIX here. How can I help ya today?",y([{role:"assistant",content:te}]),C||setTimeout(()=>{console.log("[BobWidget] Speaking initial greeting"),G(te)},800)}},[(lr=b.vehicle)==null?void 0:lr.selectedVehicle,f.length,C,G]),d.useEffect(()=>{var it,at;const $=(it=b.vehicle)==null?void 0:it.selectedVehicle;if(!$||J.current)return;const ee=$.vehicle_id??$.id,te=Number.parseInt(String(ee),10);if(!Number.isFinite(te)){console.warn("[BobWidget] Vehicle has invalid vehicle_id, cannot auto-fetch:",$);return}J.current=!0;const ce={...$,vehicle_id:String(te)},qe=(at=b.user)==null?void 0:at.email;(async()=>{var $e,Qe;const ot=`${j.supabaseUrl}/functions/v1/bob-chat`;try{const Ce=await fetch(ot,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${j.supabaseKey}`},body:JSON.stringify({messages:[],vehicleContext:ce,customerEmail:qe,autoFetchParts:!0,hostConfig:k,hostContext:b})});if(!Ce.ok||!Ce.body){console.error("[BobWidget] Auto-fetch failed:",Ce.status);return}const ut=Ce.body.getReader(),ct=new TextDecoder;let _e="";for(;;){const{done:Se,value:Fe}=await ut.read();if(Se)break;_e+=ct.decode(Fe,{stream:!0});let lt;for(;(lt=_e.indexOf(`
31
- `))!==-1;){let Ee=_e.slice(0,lt);if(_e=_e.slice(lt+1),Ee.endsWith("\r")&&(Ee=Ee.slice(0,-1)),Ee.startsWith(":")||Ee.trim()===""||!Ee.startsWith("data: "))continue;const pe=Ee.slice(6).trim();if(pe==="[DONE]")break;try{const Re=JSON.parse(pe);Re.type==="service_packages_found"&&Re.packages&&(($e=E.onServicePackagesFound)==null||$e.call(E,Re.packages)),Re.type==="parts_found"&&Re.parts&&((Qe=E.onPartsFound)==null||Qe.call(E,Re.parts))}catch{}}}T==null||T()}catch(Ce){console.error("[BobWidget] Auto-fetch error:",Ce)}})()},[(st=b.vehicle)==null?void 0:st.selectedVehicle,(Ue=b.user)==null?void 0:Ue.email]);const we=$=>{try{t($)}catch{console.warn(`[BobWidget] State "${$}" not available`)}},gr=async $=>{var ce,qe,nt,it,at,ot,$e,Qe,Ce,ut,ct,_e;const ee=`${j.supabaseUrl}/functions/v1/bob-chat`,te=(ce=b.user)==null?void 0:ce.email;try{const Se={messages:[...f,$],hostConfig:k,hostContext:b};B&&(Se.vehicleContext=B),te&&(Se.customerEmail=te);const Fe=await fetch(ee,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${j.supabaseKey}`},body:JSON.stringify(Se)});if(!Fe.ok){if(Fe.status===429){(qe=E.onError)==null||qe.call(E,new Error("Rate limit exceeded"));return}if(Fe.status===402){(nt=E.onError)==null||nt.call(E,new Error("Payment required"));return}throw new Error("Failed to start stream")}if(!Fe.body)throw new Error("No response body");const lt=Fe.body.getReader(),Ee=new TextDecoder;let pe="",Re=!1,Oe="";for(;!Re;){const{done:me,value:Ke}=await lt.read();if(me)break;pe+=Ee.decode(Ke,{stream:!0});let Wt;for(;(Wt=pe.indexOf(`
32
- `))!==-1;){let je=pe.slice(0,Wt);if(pe=pe.slice(Wt+1),je.endsWith("\r")&&(je=je.slice(0,-1)),je.startsWith(":")||je.trim()===""||!je.startsWith("data: "))continue;const dr=je.slice(6).trim();if(dr==="[DONE]"){Re=!0;break}try{const re=JSON.parse(dr);if(re.type==="vehicle_identified"&&re.vehicle){L(re.vehicle),(it=E.onVehicleIdentified)==null||it.call(E,re.vehicle);continue}if(re.type==="service_packages_found"&&re.packages){(at=E.onServicePackagesFound)==null||at.call(E,re.packages);continue}if(re.type==="parts_found"&&re.parts){(ot=E.onPartsFound)==null||ot.call(E,re.parts);continue}if(re.type==="no_parts_found"){I==null||I();continue}if(re.type==="cart_updated"&&re.items){($e=E.onCartUpdated)==null||$e.call(E,re.items);continue}const Kt=(ut=(Ce=(Qe=re.choices)==null?void 0:Qe[0])==null?void 0:Ce.delta)==null?void 0:ut.content;if(Kt){Oe+=Kt;const Vt=Oe.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");y(dt=>{const Tt=dt[dt.length-1];return(Tt==null?void 0:Tt.role)==="assistant"?dt.map((Ht,yr)=>yr===dt.length-1?{...Ht,content:Vt}:Ht):[...dt,{role:"assistant",content:Vt}]}),(ct=E.onBobMessage)==null||ct.call(E,Vt)}}catch{pe=je+`
33
- `+pe;break}}}U.current=Oe.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");const Qt=as.some(me=>Oe.toLowerCase().includes(me.toLowerCase())),We=Oe.toLowerCase();for(const me of qn)if(We.includes(me.toLowerCase())){const Ke=me.replace(/s\s*$/i,"").toUpperCase();g==null||g(Ke);break}const jt=Oe.match(/(?:go with|recommend|suggest|grab|try)\s+(?:the\s+)?(\w+)\s+(?:at|for)\s+\$(\d+(?:\.\d{2})?)/i);if(jt){const[,me,Ke]=jt;R==null||R({brand:me,price:parseFloat(Ke)})}!C&&U.current.trim()?(ne.current=!1,Be(),G(U.current),fe.current=setTimeout(()=>{ne.current||(console.warn("[BobWidget] Speech fallback after 2s"),h==null||h(),e||(Qt&&w?w():l?l():(we(a),setTimeout(()=>we(c),3e3))))},2e3)):(h==null||h(),e||(Qt&&w?w():l?l():(we(a),setTimeout(()=>we(c),3e3))))}catch(Se){console.error("[BobWidget] Chat error:",Se),(_e=E.onError)==null||_e.call(E,Se instanceof Error?Se:new Error("Unknown error")),e||we(u)}},Rt=async()=>{if(!v.trim()||O)return;rt();const $={role:"user",content:v};y(ce=>[...ce,$]),N("");const ee=v.toLowerCase();if(Un.some(ce=>ee.includes(ce))){const ce=`G'day mate! I'm running Bob v${nr} - she's running sweet as! Anything else I can help ya with?`;y(qe=>[...qe,{role:"assistant",content:ce}]),C||G(ce);return}F(!0),m==null||m(),e||we(s),await gr($),F(!1)};return{messages:f,input:v,setInput:N,isLoading:O,handleSend:Rt,handleKeyPress:$=>{$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),Rt())},handleInputFocus:()=>{},handleInputBlur:()=>{},chatEndRef:D,clearMessages:()=>{y([{role:"assistant",content:"G'day! Bob from CARFIX here. How can I help ya today?"}])},isMuted:C,toggleMute:()=>{S($=>!$),C||rt()},isSpeaking:ar,identifiedVehicle:B,clearVehicle:()=>{L(null)}}},Ns=t=>{const e=js(),r=Ur();return d.useEffect(()=>{const s=r.channel("animation-states-changes").on("postgres_changes",{event:"*",schema:"public",table:"animation_states"},()=>{e.invalidateQueries({queryKey:["bob-animation-data"]})}).subscribe(),a=r.channel("bob-animations-changes").on("postgres_changes",{event:"*",schema:"public",table:"bob_animations"},()=>{e.invalidateQueries({queryKey:["bob-animation-data"]})}).subscribe();return()=>{r.removeChannel(s),r.removeChannel(a)}},[e,r]),ks({queryKey:["bob-animation-data",t],queryFn:async()=>{var j;const{data:s,error:a}=await r.from("bob_looks").select("*").order("display_order");if(a)throw a;const u=(s||[]).find(k=>k.is_active),c=t||(u==null?void 0:u.id)||s&&((j=s[0])==null?void 0:j.id)||null;if(!c)return{states:[],configs:[],uploadedImages:[],looks:s||[],activeLookId:null};const{data:p,error:l}=await r.from("animation_states").select("*").eq("is_active",!0).eq("look_id",c).order("display_order");if(l)throw l;const{data:w,error:m}=await r.from("bob_animations").select("*").eq("is_active",!0).eq("look_id",c).order("animation_state").order("sequence_order");if(m)throw m;const h=new Set((p||[]).map(k=>k.state_key)),g=(w||[]).filter(k=>h.has(k.animation_state)),{data:R,error:I}=await r.storage.from("bob-images").list();if(I)throw I;const T=(R||[]).map(k=>{const{data:b}=r.storage.from("bob-images").getPublicUrl(k.name);return b.publicUrl});return g.forEach(k=>{const b=new Image;b.src=k.image_url}),{states:p||[],configs:g,uploadedImages:T,looks:s||[],activeLookId:c}},staleTime:30*1e3,gcTime:5*60*1e3})},Ms=()=>{const[t,e]=d.useState(""),[r,s]=d.useState(0),[a,u]=d.useState(400),[c,p]=d.useState(!1),l=d.useRef(),{data:w,isLoading:m}=Ns(),h=d.useRef({}),{imageUrlsMap:g,alternateImages:R,offsetsMap:I,scalesMap:T,availableStates:j}=d.useMemo(()=>{if(!w)return{imageUrlsMap:{},alternateImages:{},offsetsMap:{},scalesMap:{},availableStates:[]};const f={},y={},v={},N={},O=w.states.map(F=>F.state_key);return O.forEach(F=>{const C=w.configs.filter(D=>D.animation_state===F),S=C.map(D=>D.image_url),B=C.map(D=>D.vertical_offset||0),L=C.map(D=>D.scale||100);if(S.length>0){const D=w.states.find(J=>J.state_key===F);f[F]={url:S[0],animation_speed:(D==null?void 0:D.animation_speed)||400,pause_duration:(D==null?void 0:D.pause_duration)||0,loop_count:(D==null?void 0:D.loop_count)||0},y[F]=S,v[F]=B,N[F]=L}}),{imageUrlsMap:f,alternateImages:y,offsetsMap:v,scalesMap:N,availableStates:O}},[w]);return d.useEffect(()=>{h.current=g},[g]),d.useEffect(()=>{j.length>0&&!t&&e(j[0])},[j,t]),d.useEffect(()=>{const f=R[t];if(l.current&&clearInterval(l.current),f&&f.length>1){s(0);const y=h.current[t],v=(y==null?void 0:y.animation_speed)||a||400,N=(y==null?void 0:y.loop_count)||0,O=(y==null?void 0:y.pause_duration)||0;let F=0,C=!1;const S=()=>{l.current=setInterval(()=>{C||s(B=>{const L=(B+1)%f.length;return L===0&&(F++,N>0&&F>=N)?(clearInterval(l.current),O>0&&(C=!0,setTimeout(()=>{F=0,C=!1,S()},O)),B):L})},v)};S()}else s(0);return()=>{l.current&&clearInterval(l.current)}},[t,R]),{animationState:t,setAnimationState:e,getCurrentImage:()=>{const f=R[t];if(!f||f.length===0){const y=j.find(v=>{var N;return((N=R[v])==null?void 0:N.length)>0});return y?R[y][0]:""}return f[r]||f[0]},getCurrentOffset:()=>{const f=I[t];if(!f||f.length===0){const y=j.find(v=>{var N;return((N=I[v])==null?void 0:N.length)>0});return y?I[y][0]:0}return f[r]||f[0]},getCurrentScale:()=>{const f=T[t];if(!f||f.length===0){const y=j.find(v=>{var N;return((N=T[v])==null?void 0:N.length)>0});return y?T[y][0]:100}return f[r]||f[0]},imageUrls:g,availableStates:j,setTalkSpeed:u,manualMode:c,setManualMode:p,isLoading:m}},Fs=()=>{const t=Ur(),{data:e=[],isLoading:r}=ks({queryKey:["bob-backdrops"],queryFn:async()=>{const{data:a,error:u}=await t.from("bob_backdrops").select("*").order("display_order",{ascending:!0});if(u)throw u;return a},staleTime:5*60*1e3,gcTime:10*60*1e3}),s=e.find(a=>a.is_active);return{backdrops:e,activeBackdrop:s,isLoading:r}},As=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:s,counterHeightPercent:a=12,className:u="",verticalOffset:c=0,scale:p=100})=>{const l=c+a,w=55*(p/100);return o.jsx("div",{className:`flex flex-col items-center justify-center gap-6 w-full ${u}`,children:o.jsxs("div",{className:"relative w-full max-w-[600px] mx-auto aspect-[16/10] overflow-hidden",children:[r&&o.jsx("img",{src:r,alt:"Backdrop",className:"absolute inset-0 z-0 w-full h-full object-cover object-bottom"}),o.jsx("img",{src:t,alt:`Bob ${e}`,className:"absolute z-10 h-auto object-contain left-1/2 -translate-x-1/2",style:{bottom:`${l}%`,width:`${w}%`,maxWidth:`${220*(p/100)}px`,transformOrigin:"center bottom"}}),s&&o.jsx("img",{src:s,alt:"Counter",className:"absolute z-20 bottom-0 left-0 w-full object-cover object-bottom",style:{height:`${a}%`}})]})})},Ls=({messages:t,input:e,setInput:r,isLoading:s,onSend:a,onKeyPress:u,onInputFocus:c,onInputBlur:p,chatEndRef:l,isMuted:w=!1,onToggleMute:m,isSpeaking:h=!1,className:g=""})=>o.jsx("div",{className:`w-full max-w-6xl mx-auto px-4 pb-8 ${g}`,children:o.jsxs("div",{className:"bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg overflow-hidden",children:[o.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800",children:o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{value:e,onChange:R=>r(R.target.value),onKeyPress:u,onFocus:c,onBlur:p,placeholder:"Ask Bob about car parts...",disabled:s,className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500"}),m&&o.jsx("button",{onClick:m,className:`shrink-0 p-2 border border-gray-300 dark:border-gray-600 rounded-md ${h?"animate-pulse":""}`,title:w?"Unmute Bob's voice":"Mute Bob's voice",children:w?"🔇":"🔊"}),o.jsx("button",{onClick:a,disabled:s||!e.trim(),className:"shrink-0 px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:"Send"})]})}),o.jsxs("div",{className:"overflow-y-auto p-4 space-y-3 h-[300px] md:h-[400px]",children:[[...t].reverse().map((R,I)=>o.jsx("div",{className:`flex ${R.role==="user"?"justify-end":"justify-start"}`,children:o.jsx("div",{className:`max-w-[80%] rounded-lg px-4 py-2 text-sm md:text-base ${R.role==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-gray-100"}`,children:R.content})},I)),o.jsx("div",{ref:l})]})]})}),qr=({currentImage:t,animationState:e,counterOverlayUrl:r,counterHeightPercent:s=15,scale:a=100,position:u="center"})=>{const c=65*a/100,p=320*a/100,l=u==="center"?"5%":"-25%";return o.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:[o.jsx("div",{className:"absolute left-0 z-40",style:{bottom:`${s-2}%`,maxHeight:`${100-s-5}%`,transform:`translateX(${l})`,width:`${c}%`,maxWidth:`${p}px`,transition:"transform 0.4s ease-out"},children:o.jsx("img",{src:t,alt:`Bob ${e}`,className:"w-full h-auto object-contain",style:{display:"block",maxHeight:"100%"}})}),r&&o.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-50",style:{height:`${s}%`},children:o.jsx("img",{src:r,alt:"Shop counter",className:"w-full h-full object-cover object-top"})})]})},os=(t,e)=>{if(!t||!e)return!1;const r=t.toLowerCase();return e.toLowerCase().replace(/s\b/g,"").split(/\s+/).filter(Boolean).every(a=>r.includes(a))},$n=(t,e)=>{var a;const r=((a=t.brand)==null?void 0:a.toLowerCase())===e.brand.toLowerCase(),s=Math.abs(t.price-e.price)<1;return r&&s},$r=({products:t,servicePackages:e,highlightedPartType:r,highlightedProduct:s,onProductClick:a,onPackageSelect:u,isResearching:c,visible:p=!0,counterHeightPercent:l=22,hasVehicle:w=!1})=>{const m=d.useRef(null),h=d.useRef({}),g=d.useRef(null),R=d.useMemo(()=>{const b={};return t.forEach(f=>{const y=f.partslotDescription||"Other Parts";b[y]||(b[y]=[]),b[y].push(f)}),Object.keys(b).sort((f,y)=>f.localeCompare(y)).map(f=>({name:f,products:b[f]}))},[t]);d.useEffect(()=>{var b;if(r){const E=R.find(f=>os(f.name,r));E&&h.current[E.name]&&((b=h.current[E.name])==null||b.scrollIntoView({behavior:"smooth",block:"start"}))}},[r,R]),d.useEffect(()=>{s&&g.current&&g.current.scrollIntoView({behavior:"smooth",block:"center"})},[s]);const I=t.length>0||e.length>0,T=c,j=I&&!c,k=w?"56px":"8px";return o.jsxs("div",{ref:m,className:`absolute right-2 w-[52%] max-w-[220px] overflow-y-auto overflow-x-hidden z-30 flex flex-col gap-2 pb-4 transition-all duration-300 ease-out ${p?"opacity-100 translate-x-0":"opacity-0 translate-x-8 pointer-events-none"}`,style:{top:k,bottom:`calc(${l}% + 16px)`,paddingTop:"env(safe-area-inset-top, 4px)"},children:[T&&o.jsx("div",{className:"rounded-lg p-3",children:o.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[o.jsx("div",{className:"w-4 h-4 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"}),o.jsx("span",{children:"Finding parts..."})]})}),j&&e.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"text-xs font-semibold text-blue-600 flex items-center gap-1 px-1",children:[o.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),"Service Packages"]}),e.map(b=>o.jsxs("div",{onClick:()=>u==null?void 0:u(b),className:"cursor-pointer hover:shadow-md transition-all bg-white/80 rounded-lg border border-gray-200 p-2",children:[o.jsx("p",{className:"text-xs font-medium line-clamp-1",children:b.title}),o.jsxs("p",{className:"text-sm font-bold text-blue-600",children:["$",b.from_price.toFixed(0)]})]},b.id))]}),j&&R.map(({name:b,products:E},f)=>{const y=r&&os(b,r);return o.jsxs("section",{ref:v=>{h.current[b]=v},className:`rounded-lg transition-all border border-transparent ${y?"ring-2 ring-blue-600 p-2 bg-blue-50/50 shadow-lg":""}`,children:[o.jsxs("h3",{className:"text-xs font-semibold mb-2 flex items-center gap-1 px-1 text-gray-900",children:[o.jsx("svg",{className:"h-3 w-3 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),o.jsx("span",{className:"truncate",children:b}),o.jsxs("span",{className:"text-[10px] text-gray-500",children:["(",E.length,")"]})]}),o.jsx("div",{className:"space-y-2",children:E.map((v,N)=>{const O=s&&$n(v,s);return o.jsxs("div",{ref:O?g:void 0,onClick:()=>a==null?void 0:a(v),className:`cursor-pointer transition-all bg-white/80 rounded-lg border border-gray-200 relative ${O?"ring-4 ring-blue-600 scale-105 z-10":"hover:shadow-md"}`,children:[O&&o.jsxs("span",{className:"absolute -top-2 -right-2 bg-blue-600 text-white text-[8px] px-1 py-0.5 rounded z-20 flex items-center",children:[o.jsx("svg",{className:"h-2 w-2 mr-0.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),"Pick"]}),o.jsxs("div",{className:"p-2",children:[o.jsx("div",{className:"aspect-square bg-gradient-to-br from-gray-50 to-gray-100 rounded-md mb-1 flex items-center justify-center overflow-hidden border border-gray-200/50",children:v.image_url?o.jsx("img",{src:v.image_url,alt:v.name,className:"w-full h-full object-contain"}):o.jsxs("div",{className:"flex flex-col items-center justify-center text-gray-400",children:[o.jsx("svg",{className:"h-6 w-6 mb-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),o.jsx("span",{className:"text-[8px] font-medium uppercase tracking-wide",children:"No Image"})]})}),o.jsx("p",{className:"text-xs font-medium line-clamp-2",children:v.name}),v.brand&&o.jsx("p",{className:"text-[10px] text-gray-500",children:v.brand})]}),o.jsx("div",{className:"px-2 pb-2",children:o.jsx("span",{className:"text-sm font-bold text-blue-600",children:v.price>0?`$${v.price.toFixed(2)}`:"Price on request"})}),o.jsx("div",{className:"px-2 pb-2",children:o.jsx("button",{className:"w-full bg-blue-600 text-white text-xs py-1.5 rounded-md hover:bg-blue-700",onClick:F=>{F.stopPropagation(),a==null||a(v)},children:"Buy Now"})})]},`${v.id}-${N}`)})})]},b)})]})},Qr=({onTranscript:t,onSpeechEnd:e,language:r="en-NZ",mode:s="toggle"}={})=>{const[a,u]=d.useState(!1),[c,p]=d.useState(""),[l,w]=d.useState(""),[m,h]=d.useState(null),[g,R]=d.useState(!1),I=d.useRef(null),T=d.useRef(""),j=d.useRef(t),k=d.useRef(e);d.useEffect(()=>{j.current=t,k.current=e},[t,e]),d.useEffect(()=>{const y=window.SpeechRecognition||window.webkitSpeechRecognition;if(y){R(!0);const v=new y;v.continuous=s==="ptt",v.interimResults=!0,v.lang=r,v.maxAlternatives=1,v.onstart=()=>{u(!0),h(null)},v.onresult=N=>{let O="",F="";for(let C=N.resultIndex;C<N.results.length;C++){const S=N.results[C][0].transcript;N.results[C].isFinal?F+=S:O+=S}F&&(T.current=F,p(F),j.current&&j.current(F)),w(O)},v.onerror=N=>{switch(u(!1),N.error){case"no-speech":h("No speech detected. Please try again.");break;case"audio-capture":h("No microphone found. Please check your device.");break;case"not-allowed":h("Microphone permission denied. Please allow access.");break;default:h("Speech recognition error. Please try again.")}},v.onend=()=>{u(!1),w(""),T.current&&k.current&&k.current(T.current),T.current=""},I.current=v}return()=>{I.current&&I.current.stop()}},[r,s]);const b=()=>{I.current&&!a&&(p(""),w(""),h(null),I.current.start())},E=()=>{I.current&&a&&I.current.stop()};return{isListening:a,transcript:c,interimTranscript:l,error:m,isSupported:g,startListening:b,stopListening:E,toggleListening:()=>{a?E():b()}}},Ds=({messages:t,input:e,setInput:r,isLoading:s,onSend:a,onKeyPress:u,onInputFocus:c,onInputBlur:p,chatEndRef:l,isMuted:w=!1,onToggleMute:m,isSpeaking:h=!1})=>{const[g,R]=d.useState(!1),I=d.useRef(null),T=d.useRef(!1),{isListening:j,interimTranscript:k,error:b,isSupported:E,startListening:f,stopListening:y}=Qr({onTranscript:C=>r(C),language:"en-NZ",mode:"ptt"});d.useEffect(()=>{k&&r(k)},[k,r]);const v=d.useCallback(()=>{s||T.current||(T.current=!0,navigator.vibrate&&navigator.vibrate(10),f())},[s,f]),N=d.useCallback(()=>{T.current&&(T.current=!1,navigator.vibrate&&navigator.vibrate(10),y(),setTimeout(()=>{a()},150))},[y,a]),O=[...t].reverse().find(C=>C.role==="assistant"),F=O!=null&&O.content?O.content.length>50?O.content.slice(0,50)+"...":O.content:"Ask Bob about car parts...";return o.jsxs("div",{ref:I,className:`fixed bottom-0 left-0 right-0 bg-white/95 backdrop-blur-md border-t border-gray-200 transition-all duration-300 ease-out shadow-[0_-4px_20px_rgba(0,0,0,0.15)] ${g?"h-[55vh]":"h-auto"}`,style:{zIndex:60,paddingBottom:"env(safe-area-inset-bottom, 8px)"},children:[o.jsx("button",{onClick:()=>R(!g),className:"absolute -top-5 left-1/2 -translate-x-1/2 bg-white border border-gray-200 rounded-full p-1.5 shadow-lg z-40","aria-label":g?"Collapse chat":"Expand chat",children:g?o.jsx("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):o.jsx("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!g&&o.jsx("div",{className:"px-3 pt-2 pb-0.5",onClick:()=>R(!0),children:o.jsx("p",{className:"text-xs text-gray-500 line-clamp-1",children:F})}),g&&o.jsxs("div",{className:"h-[calc(100%-100px)] overflow-y-auto p-4 space-y-2",children:[[...t].reverse().map((C,S)=>o.jsx("div",{className:`flex ${C.role==="user"?"justify-end":"justify-start"}`,children:o.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${C.role==="user"?"bg-blue-600 text-white":"bg-gray-100 text-gray-900"}`,children:C.content})},S)),o.jsx("div",{ref:l})]}),o.jsxs("div",{className:`px-2 pb-1.5 ${g?"pt-2 border-t border-gray-200":"pt-0.5"}`,children:[j&&o.jsxs("div",{className:"mb-2 text-xs text-gray-500 flex items-center gap-2",children:[o.jsx("span",{className:"inline-block w-2 h-2 bg-red-500 rounded-full animate-pulse"}),"Listening..."]}),b&&o.jsx("div",{className:"mb-2 text-xs text-red-500",children:b}),o.jsxs("div",{className:"flex gap-1.5 items-center",children:[m&&g&&o.jsx("button",{onClick:m,className:`shrink-0 h-9 w-9 flex items-center justify-center rounded-md hover:bg-gray-100 ${h?"text-blue-600 animate-pulse":"text-gray-600"}`,title:w?"Unmute":"Mute",children:w?o.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):o.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})})}),o.jsx("input",{type:"text",value:e,onChange:C=>r(C.target.value),onKeyPress:u,onFocus:c,onBlur:p,placeholder:"Message Bob...",disabled:s,className:"flex-1 h-10 text-base px-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50"}),E&&o.jsx("button",{onTouchStart:v,onTouchEnd:N,onTouchCancel:N,onMouseDown:v,onMouseUp:N,onMouseLeave:N,disabled:s,className:`shrink-0 h-12 w-12 rounded-full flex items-center justify-center select-none touch-none ${j?"bg-red-500 text-white animate-pulse ring-2 ring-red-300 scale-110":"bg-blue-600 text-white"} disabled:opacity-50`,title:"Hold to talk",children:o.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]})]})]})},Bs=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:s,counterHeightPercent:a=22,messages:u,input:c,setInput:p,isLoading:l,onSend:w,onKeyPress:m,onInputFocus:h,onInputBlur:g,chatEndRef:R,isMuted:I,onToggleMute:T,isSpeaking:j,products:k,servicePackages:b,highlightedPartType:E,highlightedProduct:f,onProductClick:y,onPackageSelect:v,isResearching:N,vehicle:O,onChangeVehicle:F})=>{const C=typeof window<"u"&&window.self!==window.top,[S,B]=d.useState("center"),[L,D]=d.useState("hidden"),J=k.length>0||b.length>0;d.useEffect(()=>{if(N&&L!=="loading"&&L!=="visible")D("loading"),S==="center"&&B("left");else if(J&&L!=="visible")if(S==="center"){B("left"),D("transitioning");const U=setTimeout(()=>{D("visible")},400);return()=>clearTimeout(U)}else D("visible");else!J&&!N&&L!=="hidden"&&(D("hidden"),B("center"))},[J,N,L,S]);const xe=L!=="hidden";return o.jsxs("div",{className:"fixed inset-0 overflow-hidden",style:{height:"100dvh",touchAction:"manipulation"},children:[r&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"absolute inset-0 z-0",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center bottom",filter:"blur(12px) brightness(0.7)",transform:"scale(1.1)"}}),o.jsx("div",{className:"absolute inset-0 z-[1]",style:{background:"linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.6) 100%)"}})]}),o.jsx(qr,{currentImage:t,animationState:e,counterOverlayUrl:s,counterHeightPercent:a,scale:200,position:S}),O&&!C&&o.jsx("div",{className:"absolute top-2 left-2 right-2 z-20",children:o.jsxs("div",{className:"bg-white/90 backdrop-blur-sm rounded-lg px-3 py-2 border border-gray-200 shadow-lg flex items-center justify-between",style:{paddingTop:"calc(env(safe-area-inset-top, 4px) + 8px)"},children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("p",{className:"text-xs font-medium text-gray-900 truncate",children:[O.year," ",O.make," ",O.model]}),O.rego&&o.jsx("p",{className:"text-[10px] text-gray-500",children:O.rego})]}),F&&o.jsx("button",{onClick:F,className:"text-xs text-blue-600 hover:underline ml-2 shrink-0",children:"Change"})]})}),o.jsx($r,{products:k,servicePackages:b,highlightedPartType:E,highlightedProduct:f,onProductClick:y,onPackageSelect:v,isResearching:N,visible:xe,counterHeightPercent:a,hasVehicle:!!O}),o.jsx(Ds,{messages:u,input:c,setInput:p,isLoading:l,onSend:w,onKeyPress:m,onInputFocus:h,onInputBlur:g,chatEndRef:R,isMuted:I,onToggleMute:T,isSpeaking:j})]})},Us=({messages:t,input:e,setInput:r,isLoading:s,onSend:a,onKeyPress:u,onInputFocus:c,onInputBlur:p,chatEndRef:l,isMuted:w=!1,onToggleMute:m,isSpeaking:h=!1})=>{const[g,R]=d.useState(!1),I=d.useRef(null),T=d.useRef(!1),{isListening:j,interimTranscript:k,error:b,isSupported:E,startListening:f,stopListening:y}=Qr({onTranscript:C=>r(C),language:"en-NZ",mode:"ptt"});d.useEffect(()=>{k&&r(k)},[k,r]);const v=d.useCallback(()=>{s||T.current||(T.current=!0,navigator.vibrate&&navigator.vibrate(10),f())},[s,f]),N=d.useCallback(()=>{T.current&&(T.current=!1,navigator.vibrate&&navigator.vibrate(10),y(),setTimeout(()=>{a()},150))},[y,a]),O=[...t].reverse().find(C=>C.role==="assistant"),F=O!=null&&O.content?O.content.length>50?O.content.slice(0,50)+"...":O.content:"Ask Bob about car parts...";return o.jsxs("div",{ref:I,className:`absolute bottom-0 left-0 right-0 bg-white/95 backdrop-blur-md border-t border-gray-200 transition-all duration-300 ease-out shadow-[0_-4px_20px_rgba(0,0,0,0.15)] ${g?"h-[55%]":"h-auto"}`,style:{zIndex:60,paddingBottom:"env(safe-area-inset-bottom, 8px)"},children:[o.jsx("button",{onClick:()=>R(!g),className:"absolute -top-5 left-1/2 -translate-x-1/2 bg-white border border-gray-200 rounded-full p-1.5 shadow-lg z-40","aria-label":g?"Collapse chat":"Expand chat",children:g?o.jsx("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):o.jsx("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!g&&o.jsx("div",{className:"px-3 pt-1.5 pb-1",onClick:()=>R(!0),children:o.jsx("p",{className:"text-xs text-gray-500 line-clamp-1",children:F})}),g&&o.jsxs("div",{className:"h-[calc(100%-100px)] overflow-y-auto p-4 space-y-2",children:[[...t].reverse().map((C,S)=>o.jsx("div",{className:`flex ${C.role==="user"?"justify-end":"justify-start"}`,children:o.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${C.role==="user"?"bg-blue-600 text-white":"bg-gray-100 text-gray-900"}`,children:C.content})},S)),o.jsx("div",{ref:l})]}),o.jsxs("div",{className:`px-3 pb-1 ${g?"pt-2 border-t border-gray-200":"pt-1"}`,children:[j&&o.jsxs("div",{className:"mb-2 text-xs text-gray-500 flex items-center gap-2",children:[o.jsx("span",{className:"inline-block w-2 h-2 bg-red-500 rounded-full animate-pulse"}),"Listening..."]}),b&&o.jsx("div",{className:"mb-2 text-xs text-red-500",children:b}),o.jsxs("div",{className:"flex gap-1.5 items-center",children:[m&&g&&o.jsx("button",{onClick:m,className:`shrink-0 h-9 w-9 flex items-center justify-center rounded-md hover:bg-gray-100 ${h?"text-blue-600 animate-pulse":"text-gray-600"}`,title:w?"Unmute":"Mute",children:w?o.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):o.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})})}),o.jsx("input",{type:"text",value:e,onChange:C=>r(C.target.value),onKeyPress:u,onFocus:c,onBlur:p,placeholder:"Message Bob...",disabled:s,className:"flex-1 h-10 text-base px-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50"}),E&&o.jsx("button",{onTouchStart:v,onTouchEnd:N,onTouchCancel:N,onMouseDown:v,onMouseUp:N,onMouseLeave:N,disabled:s,className:`shrink-0 h-12 w-12 rounded-full flex items-center justify-center select-none touch-none ${j?"bg-red-500 text-white animate-pulse ring-2 ring-red-300 scale-110":"bg-blue-600 text-white"} disabled:opacity-50`,title:"Hold to talk",children:o.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]})]})]})},qs=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:s,counterHeightPercent:a=22,messages:u,input:c,setInput:p,isLoading:l,onSend:w,onKeyPress:m,onInputFocus:h,onInputBlur:g,chatEndRef:R,isMuted:I,onToggleMute:T,isSpeaking:j,products:k,servicePackages:b,highlightedPartType:E,highlightedProduct:f,onProductClick:y,onPackageSelect:v,isResearching:N,vehicle:O,onChangeVehicle:F})=>{const[C,S]=d.useState("center"),[B,L]=d.useState("hidden"),D=k.length>0||b.length>0;d.useEffect(()=>{if(N&&B!=="loading"&&B!=="visible")L("loading"),C==="center"&&S("left");else if(D&&B!=="visible")if(C==="center"){S("left"),L("transitioning");const xe=setTimeout(()=>{L("visible")},400);return()=>clearTimeout(xe)}else L("visible");else!D&&!N&&B!=="hidden"&&(L("hidden"),S("center"))},[D,N,B,C]);const J=B!=="hidden";return o.jsxs("div",{className:"absolute inset-0 overflow-hidden",style:{touchAction:"manipulation"},children:[r&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"absolute inset-0 z-0",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center bottom",filter:"blur(12px) brightness(0.7)",transform:"scale(1.1)"}}),o.jsx("div",{className:"absolute inset-0 z-[1]",style:{background:"linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.6) 100%)"}})]}),o.jsx(qr,{currentImage:t,animationState:e,counterOverlayUrl:s,counterHeightPercent:a,scale:130,position:C}),O&&o.jsx("div",{className:"absolute top-2 left-2 right-2 z-20",children:o.jsxs("div",{className:"bg-white/90 backdrop-blur-sm rounded-lg px-3 py-2 border border-gray-200 shadow-lg flex items-center justify-between",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("p",{className:"text-xs font-medium text-gray-900 truncate",children:[O.year," ",O.make," ",O.model]}),O.rego&&o.jsx("p",{className:"text-[10px] text-gray-500",children:O.rego})]}),F&&o.jsx("button",{onClick:F,className:"text-xs text-blue-600 hover:underline ml-2 shrink-0",children:"Change"})]})}),o.jsx($r,{products:k,servicePackages:b,highlightedPartType:E,highlightedProduct:f,onProductClick:y,onPackageSelect:v,isResearching:N,visible:J,counterHeightPercent:a,hasVehicle:!!O}),o.jsx(Us,{messages:u,input:c,setInput:p,isLoading:l,onSend:w,onKeyPress:m,onInputFocus:h,onInputBlur:g,chatEndRef:R,isMuted:I,onToggleMute:T,isSpeaking:j})]})},$s=({variant:t="inline",initialState:e="idle",showChat:r=!0,className:s="",backdropUrl:a,counterOverlayUrl:u,counterHeightPercent:c,defaultBobImage:p,verticalOffset:l=0,scale:w=100})=>{const{callbacks:m}=tt(),{animationState:h,setAnimationState:g,getCurrentImage:R,availableStates:I,isLoading:T}=Ms(),{activeBackdrop:j}=Fs(),[k,b]=d.useState([]),[E,f]=d.useState([]),[y,v]=d.useState(null),[N,O]=d.useState(null),[F,C]=d.useState(!1),S=Is({setAnimationState:g,manualMode:!1,onReadyToSpeak:()=>{console.log("[BobWidget] Ready to speak")},onStreamComplete:()=>{g(I.find(U=>U.includes("idle"))||"idle")},onResearchStart:()=>{C(!0)},onHighlightPart:U=>{v(U),setTimeout(()=>v(null),8e3)},onHighlightProduct:U=>{O(U),setTimeout(()=>O(null),8e3)},onAutoFetchComplete:()=>{C(!1)}});d.useEffect(()=>{const U=m.onPartsFound,ne=m.onServicePackagesFound;return m.onPartsFound=fe=>{C(!1);const Be=fe.map((G,rt)=>({id:G.SKU||G.sku||`part-${rt}`,name:G["Part Product Type"]||G.partslot_description||"Unknown Part",brand:G.Brand||G.brand,price:G["Metro Retail Price"]||G.price||0,sku:G.SKU||G.sku,partNumber:G["Part Number"]||G.part_number,partslotDescription:G["Part Product Type"]||G.partslot_description,image_url:G.image_url}));b(Be),U==null||U(fe)},m.onServicePackagesFound=fe=>{f(fe),ne==null||ne(fe)},()=>{m.onPartsFound=U,m.onServicePackagesFound=ne}},[m]);const B=a||(j==null?void 0:j.image_url),L=u||(j==null?void 0:j.counter_overlay_url)||void 0,D=c||(j==null?void 0:j.counter_height_percent)||12,J=R()||p||"";if(t==="mobile"||t==="fullscreen")return o.jsx(Bs,{currentImage:J,animationState:h,backdropUrl:B,counterOverlayUrl:L,counterHeightPercent:D,messages:S.messages,input:S.input,setInput:S.setInput,isLoading:S.isLoading,onSend:S.handleSend,onKeyPress:S.handleKeyPress,onInputFocus:S.handleInputFocus,onInputBlur:S.handleInputBlur,chatEndRef:S.chatEndRef,isMuted:S.isMuted,onToggleMute:S.toggleMute,isSpeaking:S.isSpeaking,products:k,servicePackages:E,highlightedPartType:y,highlightedProduct:N,onProductClick:U=>{var ne;return(ne=m.onAddToCart)==null?void 0:ne.call(m,{product_id:U.id,product_name:U.name,quantity:1,unit_price:U.price,sku:U.sku,brand:U.brand})},onPackageSelect:U=>console.log("[BobWidget] Package selected:",U),isResearching:F,vehicle:S.identifiedVehicle});if(t==="inline"&&r)return o.jsx("div",{className:`relative w-full h-full ${s}`,children:o.jsx(qs,{currentImage:J,animationState:h,backdropUrl:B,counterOverlayUrl:L,counterHeightPercent:D,messages:S.messages,input:S.input,setInput:S.setInput,isLoading:S.isLoading,onSend:S.handleSend,onKeyPress:S.handleKeyPress,onInputFocus:S.handleInputFocus,onInputBlur:S.handleInputBlur,chatEndRef:S.chatEndRef,isMuted:S.isMuted,onToggleMute:S.toggleMute,isSpeaking:S.isSpeaking,products:k,servicePackages:E,highlightedPartType:y,highlightedProduct:N,onProductClick:U=>{var ne;return(ne=m.onAddToCart)==null?void 0:ne.call(m,{product_id:U.id,product_name:U.name,quantity:1,unit_price:U.price,sku:U.sku,brand:U.brand})},onPackageSelect:U=>console.log("[BobWidget] Package selected:",U),isResearching:F,vehicle:S.identifiedVehicle})});const xe={inline:"",floating:"fixed bottom-4 right-4 w-96 z-50 shadow-2xl rounded-lg overflow-hidden"};return o.jsxs("div",{className:`${xe[t]||""} ${s}`,children:[J&&o.jsx(As,{currentImage:J,animationState:h,backdropUrl:B,counterOverlayUrl:L,counterHeightPercent:D,verticalOffset:l,scale:w}),r&&o.jsx(Ls,{messages:S.messages,input:S.input,setInput:S.setInput,isLoading:S.isLoading,onSend:S.handleSend,onKeyPress:S.handleKeyPress,onInputFocus:S.handleInputFocus,onInputBlur:S.handleInputBlur,chatEndRef:S.chatEndRef,isMuted:S.isMuted,onToggleMute:S.toggleMute,isSpeaking:S.isSpeaking})]})},Qn=({bobConfig:t,hostApiConfig:e,hostContext:r,callbacks:s,variant:a="mobile",initialState:u,showChat:c,className:p,backdropUrl:l,counterOverlayUrl:w,counterHeightPercent:m,defaultBobImage:h,verticalOffset:g,scale:R})=>o.jsx(Os,{bobConfig:t,hostApiConfig:e,hostContext:r,callbacks:s,children:o.jsx($s,{variant:a,initialState:u,showChat:c,className:p,backdropUrl:l,counterOverlayUrl:w,counterHeightPercent:m,defaultBobImage:h,verticalOffset:g,scale:R})}),Wn=6e4,Kn=({states:t,setAnimationState:e,manualMode:r})=>{const[s,a]=d.useState("page_load"),[u,c]=d.useState(!1),p=d.useRef(null),l=d.useCallback(y=>t.find(v=>v.chat_trigger===y&&v.is_active),[t]),w=d.useCallback(()=>t.find(y=>y.chat_trigger==="awaiting_input"||y.state_key==="talk_pause"||y.title.toLowerCase().includes("listen")||y.title.toLowerCase().includes("pause")),[t]),m=d.useCallback(()=>t.find(y=>y.state_key==="idle"||y.title.toLowerCase().includes("idle")),[t]),h=d.useCallback(y=>{const v=t.find(N=>N.state_key===y);return{speed:(v==null?void 0:v.animation_speed)||400,pauseDuration:(v==null?void 0:v.pause_duration)||0,loopCount:(v==null?void 0:v.loop_count)||0}},[t]),g=d.useCallback(()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]),R=d.useCallback(()=>{g(),!r&&(p.current=setTimeout(()=>{const y=m();y&&(a("idle"),e(y.state_key))},Wn))},[r,m,e,g]),I=d.useCallback(y=>{if(r)return;const v=l(y);v&&e(v.state_key)},[r,l,e]),T=d.useCallback(()=>{if(r)return;const y=w();y&&(a("awaiting_input"),e(y.state_key),R())},[r,w,e,R]),j=d.useCallback(()=>{u||r||(c(!0),a("page_load"),I("page_load"),setTimeout(()=>{T()},3e3))},[u,r,I,T]),k=d.useCallback(()=>{g(),a("processing_input"),I("processing_input")},[I,g]),b=d.useCallback(()=>{g(),a("streaming_response"),I("streaming_response")},[I,g]),E=d.useCallback(()=>{a("response_complete"),I("response_complete"),setTimeout(()=>{T()},3e3)},[I,T]),f=d.useCallback(()=>{a("showing_product");const y=t.find(v=>v.chat_trigger==="showing_product"||v.state_key==="showing_product");y&&e(y.state_key),setTimeout(()=>{T()},4e3)},[t,e,T]);return d.useEffect(()=>()=>g(),[g]),{chatStage:s,initialize:j,onUserInput:k,onStreamStart:b,onStreamComplete:E,onShowingProduct:f,getStateSettings:h}};console.log(`[BobWidget] Package loaded - v${nr}`);exports.BOB_VERSION=nr;exports.Bob=$s;exports.BobCharacter=As;exports.BobProvider=Os;exports.BobWidget=Qn;exports.ChatInterface=Ls;exports.ContainedChatDrawer=Us;exports.ContainedMobileBobLayout=qs;exports.MobileBobCharacter=qr;exports.MobileBobLayout=Bs;exports.MobileChatDrawer=Ds;exports.MobileProductColumn=$r;exports.getBobVersion=Ys;exports.useBobAnimation=Ms;exports.useBobAnimationData=Ns;exports.useBobBackdrop=Fs;exports.useBobCallbacks=Bn;exports.useBobChat=Is;exports.useBobContext=tt;exports.useBobStateTransitions=Kn;exports.useBobSupabase=Ur;exports.useHostApiConfig=Dn;exports.useHostContext=Ln;exports.useSpeechRecognition=Qr;exports.useSpeechSynthesis=Ps;
30
+ <%s key={someKey} {...props} />`,vs,ft,Hr,ft),_t[ft+vs]=!0}}return i===r?ht(ee):Ht(ee),ee}}function ys(i,v,O){return Gt(i,v,O,!0)}function Kr(i,v,O){return Gt(i,v,O,!1)}var Vr=Kr,zr=ys;Jt.Fragment=r,Jt.jsx=Vr,Jt.jsxs=zr}()),Jt}process.env.NODE_ENV==="production"?ws.exports=Zr():ws.exports=en();var n=ws.exports,os=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},tn={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Pe,mt,ur,sn=(ur=class{constructor(){M(this,Pe,tn);M(this,mt,!1)}setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&a(this,mt)&&t!==a(this,Pe)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:a(this,Pe),provider:t}),k(this,Pe,t),process.env.NODE_ENV!=="production"&&k(this,mt,!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&k(this,mt,!0),a(this,Pe).setTimeout(t,e)}clearTimeout(t){a(this,Pe).clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&k(this,mt,!0),a(this,Pe).setInterval(t,e)}clearInterval(t){a(this,Pe).clearInterval(t)}},Pe=new WeakMap,mt=new WeakMap,ur),pt=new sn;function rn(t){setTimeout(t,0)}var Ct=typeof window>"u"||"Deno"in globalThis;function pe(){}function nn(t,e){return typeof t=="function"?t(e):t}function js(t){return typeof t=="number"&&t>=0&&t!==1/0}function xr(t,e){return Math.max(t+(e||0)-Date.now(),0)}function st(t,e){return typeof t=="function"?t(e):t}function je(t,e){return typeof t=="function"?t(e):t}function Ys(t,e){const{type:s="all",exact:r,fetchStatus:o,predicate:l,queryKey:c,stale:g}=t;if(c){if(r){if(e.queryHash!==Ds(c,e.options))return!1}else if(!es(e.queryKey,c))return!1}if(s!=="all"){const d=e.isActive();if(s==="active"&&!d||s==="inactive"&&d)return!1}return!(typeof g=="boolean"&&e.isStale()!==g||o&&o!==e.state.fetchStatus||l&&!l(e))}function Js(t,e){const{exact:s,status:r,predicate:o,mutationKey:l}=t;if(l){if(!e.options.mutationKey)return!1;if(s){if(Zt(e.options.mutationKey)!==Zt(l))return!1}else if(!es(e.options.mutationKey,l))return!1}return!(r&&e.state.status!==r||o&&!o(e))}function Ds(t,e){return((e==null?void 0:e.queryKeyHashFn)||Zt)(t)}function Zt(t){return JSON.stringify(t,(e,s)=>Cs(s)?Object.keys(s).sort().reduce((r,o)=>(r[o]=s[o],r),{}):s)}function es(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(s=>es(t[s],e[s])):!1}var an=Object.prototype.hasOwnProperty;function Ss(t,e){if(t===e)return t;const s=Xs(t)&&Xs(e);if(!s&&!(Cs(t)&&Cs(e)))return e;const o=(s?t:Object.keys(t)).length,l=s?e:Object.keys(e),c=l.length,g=s?new Array(c):{};let d=0;for(let w=0;w<c;w++){const h=s?w:l[w],m=t[h],b=e[h];if(m===b){g[h]=m,(s?w<o:an.call(t,h))&&d++;continue}if(m===null||b===null||typeof m!="object"||typeof b!="object"){g[h]=b;continue}const E=Ss(m,b);g[h]=E,E===m&&d++}return o===c&&d===o?t:g}function Es(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}function Xs(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Cs(t){if(!Zs(t))return!1;const e=t.constructor;if(e===void 0)return!0;const s=e.prototype;return!(!Zs(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Zs(t){return Object.prototype.toString.call(t)==="[object Object]"}function on(t){return new Promise(e=>{pt.setTimeout(e,t)})}function Rs(t,e,s){if(typeof s.structuralSharing=="function")return s.structuralSharing(t,e);if(s.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Ss(t,e)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${r}`),r}return Ss(t,e)}return e}function ln(t,e,s=0){const r=[...t,e];return s&&r.length>s?r.slice(1):r}function cn(t,e,s=0){const r=[e,...t];return s&&r.length>s?r.slice(0,-1):r}var ms=Symbol();function wr(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===ms&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===ms?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function un(t,e){return typeof t=="function"?t(...e):!!t}function dn(t,e,s){let r=!1,o;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(o??(o=e()),r||(r=!0,o.aborted?s():o.addEventListener("abort",s,{once:!0})),o)}),t}var bt,Ge,Nt,dr,hn=(dr=class extends os{constructor(){super();M(this,bt);M(this,Ge);M(this,Nt);k(this,Nt,e=>{if(!Ct&&window.addEventListener){const s=()=>e();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){a(this,Ge)||this.setEventListener(a(this,Nt))}onUnsubscribe(){var e;this.hasListeners()||((e=a(this,Ge))==null||e.call(this),k(this,Ge,void 0))}setEventListener(e){var s;k(this,Nt,e),(s=a(this,Ge))==null||s.call(this),k(this,Ge,e(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(e){a(this,bt)!==e&&(k(this,bt,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(s=>{s(e)})}isFocused(){var e;return typeof a(this,bt)=="boolean"?a(this,bt):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},bt=new WeakMap,Ge=new WeakMap,Nt=new WeakMap,dr),Ls=new hn;function Ts(){let t,e;const s=new Promise((o,l)=>{t=o,e=l});s.status="pending",s.catch(()=>{});function r(o){Object.assign(s,o),delete s.resolve,delete s.reject}return s.resolve=o=>{r({status:"fulfilled",value:o}),t(o)},s.reject=o=>{r({status:"rejected",reason:o}),e(o)},s}var fn=rn;function pn(){let t=[],e=0,s=g=>{g()},r=g=>{g()},o=fn;const l=g=>{e?t.push(g):o(()=>{s(g)})},c=()=>{const g=t;t=[],g.length&&o(()=>{r(()=>{g.forEach(d=>{s(d)})})})};return{batch:g=>{let d;e++;try{d=g()}finally{e--,e||c()}return d},batchCalls:g=>(...d)=>{l(()=>{g(...d)})},schedule:l,setNotifyFunction:g=>{s=g},setBatchNotifyFunction:g=>{r=g},setScheduler:g=>{o=g}}}var ie=pn(),Ot,Ye,It,hr,mn=(hr=class extends os{constructor(){super();M(this,Ot,!0);M(this,Ye);M(this,It);k(this,It,e=>{if(!Ct&&window.addEventListener){const s=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",r)}}})}onSubscribe(){a(this,Ye)||this.setEventListener(a(this,It))}onUnsubscribe(){var e;this.hasListeners()||((e=a(this,Ye))==null||e.call(this),k(this,Ye,void 0))}setEventListener(e){var s;k(this,It,e),(s=a(this,Ye))==null||s.call(this),k(this,Ye,e(this.setOnline.bind(this)))}setOnline(e){a(this,Ot)!==e&&(k(this,Ot,e),this.listeners.forEach(r=>{r(e)}))}isOnline(){return a(this,Ot)}},Ot=new WeakMap,Ye=new WeakMap,It=new WeakMap,hr),bs=new mn;function bn(t){return Math.min(1e3*2**t,3e4)}function jr(t){return(t??"online")==="online"?bs.isOnline():!0}var _s=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Sr(t){let e=!1,s=0,r;const o=Ts(),l=()=>o.status!=="pending",c=T=>{var R;if(!l()){const _=new _s(T);b(_),(R=t.onCancel)==null||R.call(t,_)}},g=()=>{e=!0},d=()=>{e=!1},w=()=>Ls.isFocused()&&(t.networkMode==="always"||bs.isOnline())&&t.canRun(),h=()=>jr(t.networkMode)&&t.canRun(),m=T=>{l()||(r==null||r(),o.resolve(T))},b=T=>{l()||(r==null||r(),o.reject(T))},E=()=>new Promise(T=>{var R;r=_=>{(l()||w())&&T(_)},(R=t.onPause)==null||R.call(t)}).then(()=>{var T;r=void 0,l()||(T=t.onContinue)==null||T.call(t)}),I=()=>{if(l())return;let T;const R=s===0?t.initialPromise:void 0;try{T=R??t.fn()}catch(_){T=Promise.reject(_)}Promise.resolve(T).then(m).catch(_=>{var C;if(l())return;const y=t.retry??(Ct?0:3),j=t.retryDelay??bn,p=typeof j=="function"?j(s,_):j,f=y===!0||typeof y=="number"&&s<y||typeof y=="function"&&y(s,_);if(e||!f){b(_);return}s++,(C=t.onFail)==null||C.call(t,s,_),on(p).then(()=>w()?void 0:E()).then(()=>{e?b(_):I()})})};return{promise:o,status:()=>o.status,cancel:c,continue:()=>(r==null||r(),o),cancelRetry:g,continueRetry:d,canStart:h,start:()=>(h()?I():E().then(I),o)}}var gt,fr,Er=(fr=class{constructor(){M(this,gt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),js(this.gcTime)&&k(this,gt,pt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Ct?1/0:5*60*1e3))}clearGcTimeout(){a(this,gt)&&(pt.clearTimeout(a(this,gt)),k(this,gt,void 0))}},gt=new WeakMap,fr),yt,Pt,we,vt,ne,ts,xt,ke,Be,pr,gn=(pr=class extends Er{constructor(e){super();M(this,ke);M(this,yt);M(this,Pt);M(this,we);M(this,vt);M(this,ne);M(this,ts);M(this,xt);k(this,xt,!1),k(this,ts,e.defaultOptions),this.setOptions(e.options),this.observers=[],k(this,vt,e.client),k(this,we,a(this,vt).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,k(this,yt,tr(this.options)),this.state=e.state??a(this,yt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=a(this,ne))==null?void 0:e.promise}setOptions(e){if(this.options={...a(this,ts),...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const s=tr(this.options);s.data!==void 0&&(this.setState(er(s.data,s.dataUpdatedAt)),k(this,yt,s))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&a(this,we).remove(this)}setData(e,s){const r=Rs(this.state.data,e,this.options);return q(this,ke,Be).call(this,{data:r,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),r}setState(e,s){q(this,ke,Be).call(this,{type:"setState",state:e,setStateOptions:s})}cancel(e){var r,o;const s=(r=a(this,ne))==null?void 0:r.promise;return(o=a(this,ne))==null||o.cancel(e),s?s.then(pe).catch(pe):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(a(this,yt))}isActive(){return this.observers.some(e=>je(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ms||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>st(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!xr(this.state.dataUpdatedAt,e)}onFocus(){var s;const e=this.observers.find(r=>r.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(s=a(this,ne))==null||s.continue()}onOnline(){var s;const e=this.observers.find(r=>r.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(s=a(this,ne))==null||s.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),a(this,we).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(s=>s!==e),this.observers.length||(a(this,ne)&&(a(this,xt)?a(this,ne).cancel({revert:!0}):a(this,ne).cancelRetry()),this.scheduleGc()),a(this,we).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||q(this,ke,Be).call(this,{type:"invalidate"})}async fetch(e,s){var d,w,h,m,b,E,I,T,R,_,y,j;if(this.state.fetchStatus!=="idle"&&((d=a(this,ne))==null?void 0:d.status())!=="rejected"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(a(this,ne))return a(this,ne).continueRetry(),a(this,ne).promise}if(e&&this.setOptions(e),!this.options.queryFn){const p=this.observers.find(f=>f.options.queryFn);p&&this.setOptions(p.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(k(this,xt,!0),r.signal)})},l=()=>{const p=wr(this.options,s),C=(()=>{const N={client:a(this,vt),queryKey:this.queryKey,meta:this.meta};return o(N),N})();return k(this,xt,!1),this.options.persister?this.options.persister(p,C,this):p(C)},g=(()=>{const p={fetchOptions:s,options:this.options,queryKey:this.queryKey,client:a(this,vt),state:this.state,fetchFn:l};return o(p),p})();(w=this.options.behavior)==null||w.onFetch(g,this),k(this,Pt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=g.fetchOptions)==null?void 0:h.meta))&&q(this,ke,Be).call(this,{type:"fetch",meta:(m=g.fetchOptions)==null?void 0:m.meta}),k(this,ne,Sr({initialPromise:s==null?void 0:s.initialPromise,fn:g.fetchFn,onCancel:p=>{p instanceof _s&&p.revert&&this.setState({...a(this,Pt),fetchStatus:"idle"}),r.abort()},onFail:(p,f)=>{q(this,ke,Be).call(this,{type:"failed",failureCount:p,error:f})},onPause:()=>{q(this,ke,Be).call(this,{type:"pause"})},onContinue:()=>{q(this,ke,Be).call(this,{type:"continue"})},retry:g.options.retry,retryDelay:g.options.retryDelay,networkMode:g.options.networkMode,canRun:()=>!0}));try{const p=await a(this,ne).start();if(p===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(p),(E=(b=a(this,we).config).onSuccess)==null||E.call(b,p,this),(T=(I=a(this,we).config).onSettled)==null||T.call(I,p,this.state.error,this),p}catch(p){if(p instanceof _s){if(p.silent)return a(this,ne).promise;if(p.revert){if(this.state.data===void 0)throw p;return this.state.data}}throw q(this,ke,Be).call(this,{type:"error",error:p}),(_=(R=a(this,we).config).onError)==null||_.call(R,p,this),(j=(y=a(this,we).config).onSettled)==null||j.call(y,this.state.data,p,this),p}finally{this.scheduleGc()}}},yt=new WeakMap,Pt=new WeakMap,we=new WeakMap,vt=new WeakMap,ne=new WeakMap,ts=new WeakMap,xt=new WeakMap,ke=new WeakSet,Be=function(e){const s=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Cr(r.data,this.options),fetchMeta:e.meta??null};case"success":const o={...r,...er(e.data,e.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return k(this,Pt,e.manual?o:void 0),o;case"error":const l=e.error;return{...r,error:l,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:l,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=s(this.state),ie.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),a(this,we).notify({query:this,type:"updated",action:e})})},pr);function Cr(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:jr(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function er(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function tr(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,s=e!==void 0,r=s?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var fe,Q,ss,ce,wt,Mt,Ue,Je,rs,Ft,At,jt,St,Xe,Dt,z,Xt,ks,Ns,Os,Is,Ps,Ms,Fs,Rr,mr,yn=(mr=class extends os{constructor(e,s){super();M(this,z);M(this,fe);M(this,Q);M(this,ss);M(this,ce);M(this,wt);M(this,Mt);M(this,Ue);M(this,Je);M(this,rs);M(this,Ft);M(this,At);M(this,jt);M(this,St);M(this,Xe);M(this,Dt,new Set);this.options=s,k(this,fe,e),k(this,Je,null),k(this,Ue,Ts()),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(a(this,Q).addObserver(this),sr(a(this,Q),this.options)?q(this,z,Xt).call(this):this.updateResult(),q(this,z,Is).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return As(a(this,Q),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return As(a(this,Q),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,q(this,z,Ps).call(this),q(this,z,Ms).call(this),a(this,Q).removeObserver(this)}setOptions(e){const s=this.options,r=a(this,Q);if(this.options=a(this,fe).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof je(this.options.enabled,a(this,Q))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");q(this,z,Fs).call(this),a(this,Q).setOptions(this.options),s._defaulted&&!Es(this.options,s)&&a(this,fe).getQueryCache().notify({type:"observerOptionsUpdated",query:a(this,Q),observer:this});const o=this.hasListeners();o&&rr(a(this,Q),r,this.options,s)&&q(this,z,Xt).call(this),this.updateResult(),o&&(a(this,Q)!==r||je(this.options.enabled,a(this,Q))!==je(s.enabled,a(this,Q))||st(this.options.staleTime,a(this,Q))!==st(s.staleTime,a(this,Q)))&&q(this,z,ks).call(this);const l=q(this,z,Ns).call(this);o&&(a(this,Q)!==r||je(this.options.enabled,a(this,Q))!==je(s.enabled,a(this,Q))||l!==a(this,Xe))&&q(this,z,Os).call(this,l)}getOptimisticResult(e){const s=a(this,fe).getQueryCache().build(a(this,fe),e),r=this.createResult(s,e);return xn(this,r)&&(k(this,ce,r),k(this,Mt,this.options),k(this,wt,a(this,Q).state)),r}getCurrentResult(){return a(this,ce)}trackResult(e,s){return new Proxy(e,{get:(r,o)=>(this.trackProp(o),s==null||s(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&a(this,Ue).status==="pending"&&a(this,Ue).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,o))})}trackProp(e){a(this,Dt).add(e)}getCurrentQuery(){return a(this,Q)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const s=a(this,fe).defaultQueryOptions(e),r=a(this,fe).getQueryCache().build(a(this,fe),s);return r.fetch().then(()=>this.createResult(r,s))}fetch(e){return q(this,z,Xt).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),a(this,ce)))}createResult(e,s){var F;const r=a(this,Q),o=this.options,l=a(this,ce),c=a(this,wt),g=a(this,Mt),w=e!==r?e.state:a(this,ss),{state:h}=e;let m={...h},b=!1,E;if(s._optimisticResults){const x=this.hasListeners(),S=!x&&sr(e,s),W=x&&rr(e,r,s,o);(S||W)&&(m={...m,...Cr(h.data,e.options)}),s._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:I,errorUpdatedAt:T,status:R}=m;E=m.data;let _=!1;if(s.placeholderData!==void 0&&E===void 0&&R==="pending"){let x;l!=null&&l.isPlaceholderData&&s.placeholderData===(g==null?void 0:g.placeholderData)?(x=l.data,_=!0):x=typeof s.placeholderData=="function"?s.placeholderData((F=a(this,At))==null?void 0:F.state.data,a(this,At)):s.placeholderData,x!==void 0&&(R="success",E=Rs(l==null?void 0:l.data,x,s),b=!0)}if(s.select&&E!==void 0&&!_)if(l&&E===(c==null?void 0:c.data)&&s.select===a(this,rs))E=a(this,Ft);else try{k(this,rs,s.select),E=s.select(E),E=Rs(l==null?void 0:l.data,E,s),k(this,Ft,E),k(this,Je,null)}catch(x){k(this,Je,x)}a(this,Je)&&(I=a(this,Je),E=a(this,Ft),T=Date.now(),R="error");const y=m.fetchStatus==="fetching",j=R==="pending",p=R==="error",f=j&&y,C=E!==void 0,P={status:R,fetchStatus:m.fetchStatus,isPending:j,isSuccess:R==="success",isError:p,isInitialLoading:f,isLoading:f,data:E,dataUpdatedAt:m.dataUpdatedAt,error:I,errorUpdatedAt:T,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:m.dataUpdateCount>0||m.errorUpdateCount>0,isFetchedAfterMount:m.dataUpdateCount>w.dataUpdateCount||m.errorUpdateCount>w.errorUpdateCount,isFetching:y,isRefetching:y&&!j,isLoadingError:p&&!C,isPaused:m.fetchStatus==="paused",isPlaceholderData:b,isRefetchError:p&&C,isStale:Bs(e,s),refetch:this.refetch,promise:a(this,Ue),isEnabled:je(s.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const x=B=>{P.status==="error"?B.reject(P.error):P.data!==void 0&&B.resolve(P.data)},S=()=>{const B=k(this,Ue,P.promise=Ts());x(B)},W=a(this,Ue);switch(W.status){case"pending":e.queryHash===r.queryHash&&x(W);break;case"fulfilled":(P.status==="error"||P.data!==W.value)&&S();break;case"rejected":(P.status!=="error"||P.error!==W.reason)&&S();break}}return P}updateResult(){const e=a(this,ce),s=this.createResult(a(this,Q),this.options);if(k(this,wt,a(this,Q).state),k(this,Mt,this.options),a(this,wt).data!==void 0&&k(this,At,a(this,Q)),Es(s,e))return;k(this,ce,s);const r=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,l=typeof o=="function"?o():o;if(l==="all"||!l&&!a(this,Dt).size)return!0;const c=new Set(l??a(this,Dt));return this.options.throwOnError&&c.add("error"),Object.keys(a(this,ce)).some(g=>{const d=g;return a(this,ce)[d]!==e[d]&&c.has(d)})};q(this,z,Rr).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&q(this,z,Is).call(this)}},fe=new WeakMap,Q=new WeakMap,ss=new WeakMap,ce=new WeakMap,wt=new WeakMap,Mt=new WeakMap,Ue=new WeakMap,Je=new WeakMap,rs=new WeakMap,Ft=new WeakMap,At=new WeakMap,jt=new WeakMap,St=new WeakMap,Xe=new WeakMap,Dt=new WeakMap,z=new WeakSet,Xt=function(e){q(this,z,Fs).call(this);let s=a(this,Q).fetch(this.options,e);return e!=null&&e.throwOnError||(s=s.catch(pe)),s},ks=function(){q(this,z,Ps).call(this);const e=st(this.options.staleTime,a(this,Q));if(Ct||a(this,ce).isStale||!js(e))return;const r=xr(a(this,ce).dataUpdatedAt,e)+1;k(this,jt,pt.setTimeout(()=>{a(this,ce).isStale||this.updateResult()},r))},Ns=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(a(this,Q)):this.options.refetchInterval)??!1},Os=function(e){q(this,z,Ms).call(this),k(this,Xe,e),!(Ct||je(this.options.enabled,a(this,Q))===!1||!js(a(this,Xe))||a(this,Xe)===0)&&k(this,St,pt.setInterval(()=>{(this.options.refetchIntervalInBackground||Ls.isFocused())&&q(this,z,Xt).call(this)},a(this,Xe)))},Is=function(){q(this,z,ks).call(this),q(this,z,Os).call(this,q(this,z,Ns).call(this))},Ps=function(){a(this,jt)&&(pt.clearTimeout(a(this,jt)),k(this,jt,void 0))},Ms=function(){a(this,St)&&(pt.clearInterval(a(this,St)),k(this,St,void 0))},Fs=function(){const e=a(this,fe).getQueryCache().build(a(this,fe),this.options);if(e===a(this,Q))return;const s=a(this,Q);k(this,Q,e),k(this,ss,e.state),this.hasListeners()&&(s==null||s.removeObserver(this),e.addObserver(this))},Rr=function(e){ie.batch(()=>{e.listeners&&this.listeners.forEach(s=>{s(a(this,ce))}),a(this,fe).getQueryCache().notify({query:a(this,Q),type:"observerResultsUpdated"})})},mr);function vn(t,e){return je(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function sr(t,e){return vn(t,e)||t.state.data!==void 0&&As(t,e,e.refetchOnMount)}function As(t,e,s){if(je(e.enabled,t)!==!1&&st(e.staleTime,t)!=="static"){const r=typeof s=="function"?s(t):s;return r==="always"||r!==!1&&Bs(t,e)}return!1}function rr(t,e,s,r){return(t!==e||je(r.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&Bs(t,s)}function Bs(t,e){return je(e.enabled,t)!==!1&&t.isStaleByTime(st(e.staleTime,t))}function xn(t,e){return!Es(t.getCurrentResult(),e)}function nr(t){return{onFetch:(e,s)=>{var h,m,b,E,I;const r=e.options,o=(b=(m=(h=e.fetchOptions)==null?void 0:h.meta)==null?void 0:m.fetchMore)==null?void 0:b.direction,l=((E=e.state.data)==null?void 0:E.pages)||[],c=((I=e.state.data)==null?void 0:I.pageParams)||[];let g={pages:[],pageParams:[]},d=0;const w=async()=>{let T=!1;const R=j=>{dn(j,()=>e.signal,()=>T=!0)},_=wr(e.options,e.fetchOptions),y=async(j,p,f)=>{if(T)return Promise.reject();if(p==null&&j.pages.length)return Promise.resolve(j);const N=(()=>{const S={client:e.client,queryKey:e.queryKey,pageParam:p,direction:f?"backward":"forward",meta:e.options.meta};return R(S),S})(),P=await _(N),{maxPages:F}=e.options,x=f?cn:ln;return{pages:x(j.pages,P,F),pageParams:x(j.pageParams,p,F)}};if(o&&l.length){const j=o==="backward",p=j?wn:ir,f={pages:l,pageParams:c},C=p(r,f);g=await y(f,C,j)}else{const j=t??l.length;do{const p=d===0?c[0]??r.initialPageParam:ir(r,g);if(d>0&&p==null)break;g=await y(g,p),d++}while(d<j)}return g};e.options.persister?e.fetchFn=()=>{var T,R;return(R=(T=e.options).persister)==null?void 0:R.call(T,w,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},s)}:e.fetchFn=w}}}function ir(t,{pages:e,pageParams:s}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,s[r],s):void 0}function wn(t,{pages:e,pageParams:s}){var r;return e.length>0?(r=t.getPreviousPageParam)==null?void 0:r.call(t,e[0],e,s[0],s):void 0}var ns,Me,ue,Et,Fe,He,br,jn=(br=class extends Er{constructor(e){super();M(this,Fe);M(this,ns);M(this,Me);M(this,ue);M(this,Et);k(this,ns,e.client),this.mutationId=e.mutationId,k(this,ue,e.mutationCache),k(this,Me,[]),this.state=e.state||Sn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){a(this,Me).includes(e)||(a(this,Me).push(e),this.clearGcTimeout(),a(this,ue).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){k(this,Me,a(this,Me).filter(s=>s!==e)),this.scheduleGc(),a(this,ue).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){a(this,Me).length||(this.state.status==="pending"?this.scheduleGc():a(this,ue).remove(this))}continue(){var e;return((e=a(this,Et))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var c,g,d,w,h,m,b,E,I,T,R,_,y,j,p,f,C,N,P,F;const s=()=>{q(this,Fe,He).call(this,{type:"continue"})},r={client:a(this,ns),meta:this.options.meta,mutationKey:this.options.mutationKey};k(this,Et,Sr({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(new Error("No mutationFn found")),onFail:(x,S)=>{q(this,Fe,He).call(this,{type:"failed",failureCount:x,error:S})},onPause:()=>{q(this,Fe,He).call(this,{type:"pause"})},onContinue:s,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>a(this,ue).canRun(this)}));const o=this.state.status==="pending",l=!a(this,Et).canStart();try{if(o)s();else{q(this,Fe,He).call(this,{type:"pending",variables:e,isPaused:l}),await((g=(c=a(this,ue).config).onMutate)==null?void 0:g.call(c,e,this,r));const S=await((w=(d=this.options).onMutate)==null?void 0:w.call(d,e,r));S!==this.state.context&&q(this,Fe,He).call(this,{type:"pending",context:S,variables:e,isPaused:l})}const x=await a(this,Et).start();return await((m=(h=a(this,ue).config).onSuccess)==null?void 0:m.call(h,x,e,this.state.context,this,r)),await((E=(b=this.options).onSuccess)==null?void 0:E.call(b,x,e,this.state.context,r)),await((T=(I=a(this,ue).config).onSettled)==null?void 0:T.call(I,x,null,this.state.variables,this.state.context,this,r)),await((_=(R=this.options).onSettled)==null?void 0:_.call(R,x,null,e,this.state.context,r)),q(this,Fe,He).call(this,{type:"success",data:x}),x}catch(x){try{throw await((j=(y=a(this,ue).config).onError)==null?void 0:j.call(y,x,e,this.state.context,this,r)),await((f=(p=this.options).onError)==null?void 0:f.call(p,x,e,this.state.context,r)),await((N=(C=a(this,ue).config).onSettled)==null?void 0:N.call(C,void 0,x,this.state.variables,this.state.context,this,r)),await((F=(P=this.options).onSettled)==null?void 0:F.call(P,void 0,x,e,this.state.context,r)),x}finally{q(this,Fe,He).call(this,{type:"error",error:x})}}finally{a(this,ue).runNext(this)}}},ns=new WeakMap,Me=new WeakMap,ue=new WeakMap,Et=new WeakMap,Fe=new WeakSet,He=function(e){const s=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=s(this.state),ie.batch(()=>{a(this,Me).forEach(r=>{r.onMutationUpdate(e)}),a(this,ue).notify({mutation:this,type:"updated",action:e})})},br);function Sn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $e,Ne,is,gr,En=(gr=class extends os{constructor(e={}){super();M(this,$e);M(this,Ne);M(this,is);this.config=e,k(this,$e,new Set),k(this,Ne,new Map),k(this,is,0)}build(e,s,r){const o=new jn({client:e,mutationCache:this,mutationId:++fs(this,is)._,options:e.defaultMutationOptions(s),state:r});return this.add(o),o}add(e){a(this,$e).add(e);const s=ps(e);if(typeof s=="string"){const r=a(this,Ne).get(s);r?r.push(e):a(this,Ne).set(s,[e])}this.notify({type:"added",mutation:e})}remove(e){if(a(this,$e).delete(e)){const s=ps(e);if(typeof s=="string"){const r=a(this,Ne).get(s);if(r)if(r.length>1){const o=r.indexOf(e);o!==-1&&r.splice(o,1)}else r[0]===e&&a(this,Ne).delete(s)}}this.notify({type:"removed",mutation:e})}canRun(e){const s=ps(e);if(typeof s=="string"){const r=a(this,Ne).get(s),o=r==null?void 0:r.find(l=>l.state.status==="pending");return!o||o===e}else return!0}runNext(e){var r;const s=ps(e);if(typeof s=="string"){const o=(r=a(this,Ne).get(s))==null?void 0:r.find(l=>l!==e&&l.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ie.batch(()=>{a(this,$e).forEach(e=>{this.notify({type:"removed",mutation:e})}),a(this,$e).clear(),a(this,Ne).clear()})}getAll(){return Array.from(a(this,$e))}find(e){const s={exact:!0,...e};return this.getAll().find(r=>Js(s,r))}findAll(e={}){return this.getAll().filter(s=>Js(e,s))}notify(e){ie.batch(()=>{this.listeners.forEach(s=>{s(e)})})}resumePausedMutations(){const e=this.getAll().filter(s=>s.state.isPaused);return ie.batch(()=>Promise.all(e.map(s=>s.continue().catch(pe))))}},$e=new WeakMap,Ne=new WeakMap,is=new WeakMap,gr);function ps(t){var e;return(e=t.options.scope)==null?void 0:e.id}var Ae,yr,Cn=(yr=class extends os{constructor(e={}){super();M(this,Ae);this.config=e,k(this,Ae,new Map)}build(e,s,r){const o=s.queryKey,l=s.queryHash??Ds(o,s);let c=this.get(l);return c||(c=new gn({client:e,queryKey:o,queryHash:l,options:e.defaultQueryOptions(s),state:r,defaultOptions:e.getQueryDefaults(o)}),this.add(c)),c}add(e){a(this,Ae).has(e.queryHash)||(a(this,Ae).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const s=a(this,Ae).get(e.queryHash);s&&(e.destroy(),s===e&&a(this,Ae).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ie.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return a(this,Ae).get(e)}getAll(){return[...a(this,Ae).values()]}find(e){const s={exact:!0,...e};return this.getAll().find(r=>Ys(s,r))}findAll(e={}){const s=this.getAll();return Object.keys(e).length>0?s.filter(r=>Ys(e,r)):s}notify(e){ie.batch(()=>{this.listeners.forEach(s=>{s(e)})})}onFocus(){ie.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ie.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Ae=new WeakMap,yr),X,Ze,et,Lt,Bt,tt,Ut,$t,vr,Rn=(vr=class{constructor(t={}){M(this,X);M(this,Ze);M(this,et);M(this,Lt);M(this,Bt);M(this,tt);M(this,Ut);M(this,$t);k(this,X,t.queryCache||new Cn),k(this,Ze,t.mutationCache||new En),k(this,et,t.defaultOptions||{}),k(this,Lt,new Map),k(this,Bt,new Map),k(this,tt,0)}mount(){fs(this,tt)._++,a(this,tt)===1&&(k(this,Ut,Ls.subscribe(async t=>{t&&(await this.resumePausedMutations(),a(this,X).onFocus())})),k(this,$t,bs.subscribe(async t=>{t&&(await this.resumePausedMutations(),a(this,X).onOnline())})))}unmount(){var t,e;fs(this,tt)._--,a(this,tt)===0&&((t=a(this,Ut))==null||t.call(this),k(this,Ut,void 0),(e=a(this,$t))==null||e.call(this),k(this,$t,void 0))}isFetching(t){return a(this,X).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return a(this,Ze).findAll({...t,status:"pending"}).length}getQueryData(t){var s;const e=this.defaultQueryOptions({queryKey:t});return(s=a(this,X).get(e.queryHash))==null?void 0:s.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),s=a(this,X).build(this,e),r=s.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&s.isStaleByTime(st(e.staleTime,s))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return a(this,X).findAll(t).map(({queryKey:e,state:s})=>{const r=s.data;return[e,r]})}setQueryData(t,e,s){const r=this.defaultQueryOptions({queryKey:t}),o=a(this,X).get(r.queryHash),l=o==null?void 0:o.state.data,c=nn(e,l);if(c!==void 0)return a(this,X).build(this,r).setData(c,{...s,manual:!0})}setQueriesData(t,e,s){return ie.batch(()=>a(this,X).findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,s)]))}getQueryState(t){var s;const e=this.defaultQueryOptions({queryKey:t});return(s=a(this,X).get(e.queryHash))==null?void 0:s.state}removeQueries(t){const e=a(this,X);ie.batch(()=>{e.findAll(t).forEach(s=>{e.remove(s)})})}resetQueries(t,e){const s=a(this,X);return ie.batch(()=>(s.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const s={revert:!0,...e},r=ie.batch(()=>a(this,X).findAll(t).map(o=>o.cancel(s)));return Promise.all(r).then(pe).catch(pe)}invalidateQueries(t,e={}){return ie.batch(()=>(a(this,X).findAll(t).forEach(s=>{s.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const s={...e,cancelRefetch:e.cancelRefetch??!0},r=ie.batch(()=>a(this,X).findAll(t).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let l=o.fetch(void 0,s);return s.throwOnError||(l=l.catch(pe)),o.state.fetchStatus==="paused"?Promise.resolve():l}));return Promise.all(r).then(pe)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const s=a(this,X).build(this,e);return s.isStaleByTime(st(e.staleTime,s))?s.fetch(e):Promise.resolve(s.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(pe).catch(pe)}fetchInfiniteQuery(t){return t.behavior=nr(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(pe).catch(pe)}ensureInfiniteQueryData(t){return t.behavior=nr(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return bs.isOnline()?a(this,Ze).resumePausedMutations():Promise.resolve()}getQueryCache(){return a(this,X)}getMutationCache(){return a(this,Ze)}getDefaultOptions(){return a(this,et)}setDefaultOptions(t){k(this,et,t)}setQueryDefaults(t,e){a(this,Lt).set(Zt(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...a(this,Lt).values()],s={};return e.forEach(r=>{es(t,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(t,e){a(this,Bt).set(Zt(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...a(this,Bt).values()],s={};return e.forEach(r=>{es(t,r.mutationKey)&&Object.assign(s,r.defaultOptions)}),s}defaultQueryOptions(t){if(t._defaulted)return t;const e={...a(this,et).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Ds(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===ms&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...a(this,et).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){a(this,X).clear(),a(this,Ze).clear()}},X=new WeakMap,Ze=new WeakMap,et=new WeakMap,Lt=new WeakMap,Bt=new WeakMap,tt=new WeakMap,Ut=new WeakMap,$t=new WeakMap,vr),Tr=Se.createContext(void 0),_r=t=>{const e=Se.useContext(Tr);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Tn=({client:t,children:e})=>(Se.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),n.jsx(Tr.Provider,{value:t,children:e})),kr=Se.createContext(!1),_n=()=>Se.useContext(kr);kr.Provider;function kn(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Nn=Se.createContext(kn()),On=()=>Se.useContext(Nn),In=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Pn=t=>{Se.useEffect(()=>{t.clearReset()},[t])},Mn=({result:t,errorResetBoundary:e,throwOnError:s,query:r,suspense:o})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(o&&t.data===void 0||un(s,[t.error,r])),Fn=t=>{if(t.suspense){const s=o=>o==="static"?o:Math.max(o??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...o)=>s(r(...o)):s(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},An=(t,e)=>t.isLoading&&t.isFetching&&!e,Dn=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,ar=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function Ln(t,e,s){var m,b,E,I,T;if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=_n(),o=On(),l=_r(),c=l.defaultQueryOptions(t);(b=(m=l.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||b.call(m,c),process.env.NODE_ENV!=="production"&&(c.queryFn||console.error(`[${c.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),c._optimisticResults=r?"isRestoring":"optimistic",Fn(c),In(c,o),Pn(o);const g=!l.getQueryCache().get(c.queryHash),[d]=Se.useState(()=>new e(l,c)),w=d.getOptimisticResult(c),h=!r&&t.subscribed!==!1;if(Se.useSyncExternalStore(Se.useCallback(R=>{const _=h?d.subscribe(ie.batchCalls(R)):pe;return d.updateResult(),_},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),Se.useEffect(()=>{d.setOptions(c)},[c,d]),Dn(c,w))throw ar(c,d,o);if(Mn({result:w,errorResetBoundary:o,throwOnError:c.throwOnError,query:l.getQueryCache().get(c.queryHash),suspense:c.suspense}))throw w.error;if((I=(E=l.getDefaultOptions().queries)==null?void 0:E._experimental_afterQuery)==null||I.call(E,c,w),c.experimental_prefetchInRender&&!Ct&&An(w,r)){const R=g?ar(c,d,o):(T=l.getQueryCache().get(c.queryHash))==null?void 0:T.promise;R==null||R.catch(pe).finally(()=>{d.updateResult()})}return c.notifyOnChangeProps?w:d.trackResult(w)}function Nr(t,e){return Ln(t,yn)}const Or=u.createContext(null);function Ir({children:t,bobConfig:e,hostApiConfig:s,hostContext:r={},callbacks:o={},queryClient:l}){const c=u.useMemo(()=>new Rn({defaultOptions:{queries:{retry:1,staleTime:3e5}}}),[]),g=l||c,d=!!l;u.useEffect(()=>{console.log(`[BobWidget] v${as} initialized`),console.log(`[BobWidget] QueryClient: ${d?"external (shared)":"internal"}`)},[d]);const w=u.useMemo(()=>Yr.createClient(e.supabaseUrl,e.supabaseKey),[e.supabaseUrl,e.supabaseKey]),[h,m]=u.useState(r);u.useEffect(()=>{m(r)},[r]);const b=u.useCallback(I=>{m(T=>({...T,...I}))},[]),E=u.useMemo(()=>({bobSupabase:w,bobConfig:e,hostApiConfig:s,hostContext:h,callbacks:o,updateHostContext:b}),[w,e,s,h,o,b]);return n.jsx(Tn,{client:g,children:n.jsx(Or.Provider,{value:E,children:t})})}function rt(){const t=u.useContext(Or);if(!t)throw new Error("useBobContext must be used within a BobProvider");return t}function Us(){const{bobSupabase:t}=rt();return t}function Bn(){const{hostContext:t}=rt();return t}function Un(){const{hostApiConfig:t}=rt();return t}function $n(){const{callbacks:t}=rt();return t}const or=8e3,Pr=({onStart:t,onEnd:e,onFailed:s}={})=>{const{bobConfig:r}=rt(),[o,l]=u.useState(!1),c=u.useRef(null),g=u.useRef(null),d=u.useRef(!1),w=u.useRef(t),h=u.useRef(e),m=u.useRef(s);u.useEffect(()=>{w.current=t,h.current=e,m.current=s},[t,e,s]);const b=u.useCallback(()=>{g.current&&(clearTimeout(g.current),g.current=null)},[]),E=u.useCallback(()=>{var y;d.current||(d.current=!0,console.log("[BobWidget TTS] Fallback: triggering onStart without audio"),(y=w.current)==null||y.call(w))},[]),I=u.useCallback(async y=>{var j,p,f;if(y.trim()){d.current=!1,b(),c.current&&(c.current.pause(),c.current=null),g.current=setTimeout(()=>{var C,N;console.warn("[BobWidget TTS] Timeout after 5s - triggering fallback callbacks"),E(),l(!1),(C=h.current)==null||C.call(h),(N=m.current)==null||N.call(m),c.current=null},or);try{const C=new AbortController,N=setTimeout(()=>C.abort(),or-1e3),P=await fetch(`${r.supabaseUrl}/functions/v1/bob-tts`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r.supabaseKey}`},body:JSON.stringify({text:y}),signal:C.signal});if(clearTimeout(N),!P.ok){const S=await P.json().catch(()=>({}));throw console.error("[BobWidget TTS] Request failed:",S),new Error("TTS request failed")}const{audioContent:F}=await P.json(),x=new Audio(`data:audio/mp3;base64,${F}`);c.current=x,x.onplay=()=>{var S;b(),d.current||(d.current=!0,l(!0),console.log("[BobWidget TTS] Audio playing, triggering onStart"),(S=w.current)==null||S.call(w))},x.onended=()=>{var S;b(),l(!1),(S=h.current)==null||S.call(h),c.current=null},x.onerror=S=>{var W,B;b(),console.warn("[BobWidget TTS] Audio playback error:",S),E(),l(!1),(W=h.current)==null||W.call(h),(B=m.current)==null||B.call(m),c.current=null};try{await x.play()}catch(S){console.warn("[BobWidget TTS] Audio play() failed (autoplay policy), will retry on user interaction:",S),b(),E(),l(!1),(j=h.current)==null||j.call(h)}}catch(C){b(),console.error("[BobWidget TTS] Speech synthesis error:",C),E(),l(!1),(p=h.current)==null||p.call(h),(f=m.current)==null||f.call(m)}}},[r.supabaseUrl,r.supabaseKey,b,E]),T=u.useCallback(()=>{b(),c.current&&(c.current.pause(),c.current=null),l(!1)},[b]),R=u.useCallback(()=>{var y;(y=c.current)==null||y.pause()},[]),_=u.useCallback(()=>{var y;(y=c.current)==null||y.play()},[]);return u.useEffect(()=>()=>{b(),c.current&&(c.current.pause(),c.current=null)},[b]),{speak:I,stop:T,pause:R,resume:_,isSpeaking:o,isSupported:!0}},qn=["what version","which version","software version","bob version","your version","current version","running version","version number","what ver","which ver"],lr=["recommend","suggest","need","part","filter","brake","rotor","oil","price","$","stock","available","pads","disc","spark plug","battery","clutch","alternator","starter","muffler","exhaust","service pack","add-on","tyre shine","windscreen wash"],Qn=["WIPER BLADE FRONT","WIPER BLADE REAR","WIPER BLADE SET","BRAKE PAD KIT","BRAKE PAD KIT FRONT","BRAKE PAD KIT REAR","BRAKE ROTOR","BRAKE ROTOR FRONT","BRAKE ROTOR REAR","BRAKE DISC","AIR FILTER","OIL FILTER","CABIN FILTER","FUEL FILTER","SPARK PLUG SET","SPARK PLUG","BALL JOINT","TIE ROD END","CONTROL ARM","WHEEL BEARING","CV JOINT","DRIVE SHAFT","TIMING BELT KIT","SERPENTINE BELT","DRIVE BELT","SHOCK ABSORBER","STRUT","COIL SPRING","CLUTCH KIT","CLUTCH PLATE","ALTERNATOR","STARTER MOTOR","WATER PUMP","THERMOSTAT","RADIATOR","RADIATOR HOSE","EXHAUST","MUFFLER","CATALYTIC CONVERTER","brake pads","brake rotors","brake discs","brakes","air filter","oil filter","cabin filter","fuel filter","spark plugs","spark plug","wiper","wipers","battery","batteries","clutch","clutch kit","alternator","starter motor","muffler","exhaust","cv joint","axle","timing belt","serpentine belt","shock absorber","struts","suspension"],Mr=({setAnimationState:t,manualMode:e=!1,talkingState:s="talk",thinkingState:r="research",completeState:o="complete",idleState:l="idle",listenState:c="talk_pause",onStreamStart:g,onStreamComplete:d,onShowingProduct:w,onResearchStart:h,onReadyToSpeak:m,onHighlightPart:b,onHighlightProduct:E,onNoPartsFound:I,onAutoFetchComplete:T})=>{var us,ds,nt,qe;const{bobConfig:R,hostApiConfig:_,hostContext:y,callbacks:j}=rt(),[p,f]=u.useState([]),[C,N]=u.useState(""),[P,F]=u.useState(!1),[x,S]=u.useState(!1),[W,B]=u.useState(null),A=u.useRef(null),Y=u.useRef(!1),oe=u.useRef(!1),L=u.useRef(""),G=u.useRef(!1),ae=u.useRef(null),ge=()=>{ae.current&&(clearTimeout(ae.current),ae.current=null)},{speak:J,stop:De,isSpeaking:Rt}=Pr({onStart:()=>{ge(),G.current=!0,console.log("[BobWidget] Speech started - revealing products"),m==null||m(),e||me(s)},onEnd:()=>{ge();const $=lr.some(te=>L.current.toLowerCase().includes(te.toLowerCase()));e||($&&w?w():d?d():(me(o),setTimeout(()=>me(c),3e3)))},onFailed:()=>{console.warn("[BobWidget] Speech synthesis failed - fallback triggered")}});u.useEffect(()=>{var $;($=A.current)==null||$.scrollIntoView({behavior:"smooth"})},[p]),u.useEffect(()=>{var te,se;const $=(te=y.vehicle)==null?void 0:te.selectedVehicle;$&&!W&&(console.log("[BobWidget] Setting vehicle from host context:",$),B($),(se=j.onVehicleIdentified)==null||se.call(j,$))},[(us=y.vehicle)==null?void 0:us.selectedVehicle]),u.useEffect(()=>{var $;if(p.length===0&&!oe.current){oe.current=!0;const te=($=y.vehicle)==null?void 0:$.selectedVehicle;let se;te?se=`G'day! Saw you've got the ${`${te.year} ${te.make} ${te.model}`} - choice wagon! What can I help you find for it today?`:se="G'day! Bob from CARFIX here. How can I help ya today?",f([{role:"assistant",content:se}]),x||setTimeout(()=>{console.log("[BobWidget] Speaking initial greeting"),J(se)},800)}},[(ds=y.vehicle)==null?void 0:ds.selectedVehicle,p.length,x,J]),u.useEffect(()=>{var at,ot;const $=(at=y.vehicle)==null?void 0:at.selectedVehicle;if(!$||Y.current)return;const te=$.vehicle_id??$.id,se=Number.parseInt(String(te),10);if(!Number.isFinite(se)){console.warn("[BobWidget] Vehicle has invalid vehicle_id, cannot auto-fetch:",$);return}Y.current=!0;const de={...$,vehicle_id:String(se)},Qe=(ot=y.user)==null?void 0:ot.email;(async()=>{var We,Ke;const lt=`${R.supabaseUrl}/functions/v1/bob-chat`;try{const Ee=await fetch(lt,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${R.supabaseKey}`},body:JSON.stringify({messages:[],vehicleContext:de,customerEmail:Qe,autoFetchParts:!0,hostConfig:_,hostContext:y})});if(!Ee.ok||!Ee.body){console.error("[BobWidget] Auto-fetch failed:",Ee.status);return}const ct=Ee.body.getReader(),ut=new TextDecoder;let Oe="";for(;;){const{done:Ce,value:Le}=await ct.read();if(Ce)break;Oe+=ut.decode(Le,{stream:!0});let dt;for(;(dt=Oe.indexOf(`
31
+ `))!==-1;){let Re=Oe.slice(0,dt);if(Oe=Oe.slice(dt+1),Re.endsWith("\r")&&(Re=Re.slice(0,-1)),Re.startsWith(":")||Re.trim()===""||!Re.startsWith("data: "))continue;const ye=Re.slice(6).trim();if(ye==="[DONE]")break;try{const Te=JSON.parse(ye);Te.type==="service_packages_found"&&Te.packages&&((We=j.onServicePackagesFound)==null||We.call(j,Te.packages)),Te.type==="parts_found"&&Te.parts&&((Ke=j.onPartsFound)==null||Ke.call(j,Te.parts))}catch{}}}T==null||T()}catch(Ee){console.error("[BobWidget] Auto-fetch error:",Ee)}})()},[(nt=y.vehicle)==null?void 0:nt.selectedVehicle,(qe=y.user)==null?void 0:qe.email]);const me=$=>{try{t($)}catch{console.warn(`[BobWidget] State "${$}" not available`)}},qt=async $=>{var de,Qe,it,at,ot,lt,We,Ke,Ee,ct,ut,Oe;const te=`${R.supabaseUrl}/functions/v1/bob-chat`,se=(de=y.user)==null?void 0:de.email;try{const Ce={messages:[...p,$],hostConfig:_,hostContext:y};W&&(Ce.vehicleContext=W),se&&(Ce.customerEmail=se);const Le=await fetch(te,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${R.supabaseKey}`},body:JSON.stringify(Ce)});if(!Le.ok){if(Le.status===429){(Qe=j.onError)==null||Qe.call(j,new Error("Rate limit exceeded"));return}if(Le.status===402){(it=j.onError)==null||it.call(j,new Error("Payment required"));return}throw new Error("Failed to start stream")}if(!Le.body)throw new Error("No response body");const dt=Le.body.getReader(),Re=new TextDecoder;let ye="",Te=!1,Ie="";for(;!Te;){const{done:ve,value:ze}=await dt.read();if(ve)break;ye+=Re.decode(ze,{stream:!0});let Vt;for(;(Vt=ye.indexOf(`
32
+ `))!==-1;){let _e=ye.slice(0,Vt);if(ye=ye.slice(Vt+1),_e.endsWith("\r")&&(_e=_e.slice(0,-1)),_e.startsWith(":")||_e.trim()===""||!_e.startsWith("data: "))continue;const hs=_e.slice(6).trim();if(hs==="[DONE]"){Te=!0;break}try{const re=JSON.parse(hs);if(re.type==="vehicle_identified"&&re.vehicle){B(re.vehicle),(at=j.onVehicleIdentified)==null||at.call(j,re.vehicle);continue}if(re.type==="service_packages_found"&&re.packages){(ot=j.onServicePackagesFound)==null||ot.call(j,re.packages);continue}if(re.type==="parts_found"&&re.parts){(lt=j.onPartsFound)==null||lt.call(j,re.parts);continue}if(re.type==="no_parts_found"){I==null||I();continue}if(re.type==="cart_updated"&&re.items){(We=j.onCartUpdated)==null||We.call(j,re.items);continue}const zt=(ct=(Ee=(Ke=re.choices)==null?void 0:Ke[0])==null?void 0:Ee.delta)==null?void 0:ct.content;if(zt){Ie+=zt;const Ht=Ie.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");f(ht=>{const _t=ht[ht.length-1];return(_t==null?void 0:_t.role)==="assistant"?ht.map((Gt,ys)=>ys===ht.length-1?{...Gt,content:Ht}:Gt):[...ht,{role:"assistant",content:Ht}]}),(ut=j.onBobMessage)==null||ut.call(j,Ht)}}catch{ye=_e+`
33
+ `+ye;break}}}L.current=Ie.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");const Kt=lr.some(ve=>Ie.toLowerCase().includes(ve.toLowerCase())),Ve=Ie.toLowerCase();for(const ve of Qn)if(Ve.includes(ve.toLowerCase())){const ze=ve.replace(/s\s*$/i,"").toUpperCase();b==null||b(ze);break}const Tt=Ie.match(/(?:go with|recommend|suggest|grab|try)\s+(?:the\s+)?(\w+)\s+(?:at|for)\s+\$(\d+(?:\.\d{2})?)/i);if(Tt){const[,ve,ze]=Tt;E==null||E({brand:ve,price:parseFloat(ze)})}!x&&L.current.trim()?(G.current=!1,ge(),J(L.current),ae.current=setTimeout(()=>{G.current||(console.warn("[BobWidget] Speech fallback after 2s"),m==null||m(),e||(Kt&&w?w():d?d():(me(o),setTimeout(()=>me(c),3e3))))},2e3)):(m==null||m(),e||(Kt&&w?w():d?d():(me(o),setTimeout(()=>me(c),3e3))))}catch(Ce){console.error("[BobWidget] Chat error:",Ce),(Oe=j.onError)==null||Oe.call(j,Ce instanceof Error?Ce:new Error("Unknown error")),e||me(l)}},be=async()=>{if(!C.trim()||P)return;De();const $={role:"user",content:C};f(de=>[...de,$]),N("");const te=C.toLowerCase();if(qn.some(de=>te.includes(de))){const de=`G'day mate! I'm running Bob v${as} - she's running sweet as! Anything else I can help ya with?`;f(Qe=>[...Qe,{role:"assistant",content:de}]),x||J(de);return}F(!0),h==null||h(),e||me(r),await qt($),F(!1)};return{messages:p,input:C,setInput:N,isLoading:P,handleSend:be,handleKeyPress:$=>{$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),be())},handleInputFocus:()=>{},handleInputBlur:()=>{},chatEndRef:A,clearMessages:()=>{f([{role:"assistant",content:"G'day! Bob from CARFIX here. How can I help ya today?"}])},isMuted:x,toggleMute:()=>{S($=>!$),x||De()},isSpeaking:Rt,identifiedVehicle:W,clearVehicle:()=>{B(null)}}},Fr=t=>{const e=_r(),s=Us();return u.useEffect(()=>{const r=s.channel("animation-states-changes").on("postgres_changes",{event:"*",schema:"public",table:"animation_states"},()=>{e.invalidateQueries({queryKey:["bob-animation-data"]})}).subscribe(),o=s.channel("bob-animations-changes").on("postgres_changes",{event:"*",schema:"public",table:"bob_animations"},()=>{e.invalidateQueries({queryKey:["bob-animation-data"]})}).subscribe();return()=>{s.removeChannel(r),s.removeChannel(o)}},[e,s]),Nr({queryKey:["bob-animation-data",t],queryFn:async()=>{var R;const{data:r,error:o}=await s.from("bob_looks").select("*").order("display_order");if(o)throw o;const l=(r||[]).find(_=>_.is_active),c=t||(l==null?void 0:l.id)||r&&((R=r[0])==null?void 0:R.id)||null;if(!c)return{states:[],configs:[],uploadedImages:[],looks:r||[],activeLookId:null};const{data:g,error:d}=await s.from("animation_states").select("*").eq("is_active",!0).eq("look_id",c).order("display_order");if(d)throw d;const{data:w,error:h}=await s.from("bob_animations").select("*").eq("is_active",!0).eq("look_id",c).order("animation_state").order("sequence_order");if(h)throw h;const m=new Set((g||[]).map(_=>_.state_key)),b=(w||[]).filter(_=>m.has(_.animation_state)),{data:E,error:I}=await s.storage.from("bob-images").list();if(I)throw I;const T=(E||[]).map(_=>{const{data:y}=s.storage.from("bob-images").getPublicUrl(_.name);return y.publicUrl});return b.forEach(_=>{const y=new Image;y.src=_.image_url}),{states:g||[],configs:b,uploadedImages:T,looks:r||[],activeLookId:c}},staleTime:30*1e3,gcTime:5*60*1e3})},Ar=()=>{const[t,e]=u.useState(""),[s,r]=u.useState(0),[o,l]=u.useState(400),[c,g]=u.useState(!1),d=u.useRef(),{data:w,isLoading:h}=Fr(),m=u.useRef({}),{imageUrlsMap:b,alternateImages:E,offsetsMap:I,scalesMap:T,availableStates:R}=u.useMemo(()=>{if(!w)return{imageUrlsMap:{},alternateImages:{},offsetsMap:{},scalesMap:{},availableStates:[]};const p={},f={},C={},N={},P=w.states.map(F=>F.state_key);return P.forEach(F=>{const x=w.configs.filter(A=>A.animation_state===F),S=x.map(A=>A.image_url),W=x.map(A=>A.vertical_offset||0),B=x.map(A=>A.scale||100);if(S.length>0){const A=w.states.find(Y=>Y.state_key===F);p[F]={url:S[0],animation_speed:(A==null?void 0:A.animation_speed)||400,pause_duration:(A==null?void 0:A.pause_duration)||0,loop_count:(A==null?void 0:A.loop_count)||0},f[F]=S,C[F]=W,N[F]=B}}),{imageUrlsMap:p,alternateImages:f,offsetsMap:C,scalesMap:N,availableStates:P}},[w]);return u.useEffect(()=>{m.current=b},[b]),u.useEffect(()=>{R.length>0&&!t&&e(R[0])},[R,t]),u.useEffect(()=>{const p=E[t];if(d.current&&clearInterval(d.current),p&&p.length>1){r(0);const f=m.current[t],C=(f==null?void 0:f.animation_speed)||o||400,N=(f==null?void 0:f.loop_count)||0,P=(f==null?void 0:f.pause_duration)||0;let F=0,x=!1;const S=()=>{d.current=setInterval(()=>{x||r(W=>{const B=(W+1)%p.length;return B===0&&(F++,N>0&&F>=N)?(clearInterval(d.current),P>0&&(x=!0,setTimeout(()=>{F=0,x=!1,S()},P)),W):B})},C)};S()}else r(0);return()=>{d.current&&clearInterval(d.current)}},[t,E]),{animationState:t,setAnimationState:e,getCurrentImage:()=>{const p=E[t];if(!p||p.length===0){const f=R.find(C=>{var N;return((N=E[C])==null?void 0:N.length)>0});return f?E[f][0]:""}return p[s]||p[0]},getCurrentOffset:()=>{const p=I[t];if(!p||p.length===0){const f=R.find(C=>{var N;return((N=I[C])==null?void 0:N.length)>0});return f?I[f][0]:0}return p[s]||p[0]},getCurrentScale:()=>{const p=T[t];if(!p||p.length===0){const f=R.find(C=>{var N;return((N=T[C])==null?void 0:N.length)>0});return f?T[f][0]:100}return p[s]||p[0]},imageUrls:b,availableStates:R,setTalkSpeed:l,manualMode:c,setManualMode:g,isLoading:h}},Dr=()=>{const t=Us(),{data:e=[],isLoading:s}=Nr({queryKey:["bob-backdrops"],queryFn:async()=>{const{data:o,error:l}=await t.from("bob_backdrops").select("*").order("display_order",{ascending:!0});if(l)throw l;return o},staleTime:5*60*1e3,gcTime:10*60*1e3}),r=e.find(o=>o.is_active);return{backdrops:e,activeBackdrop:r,isLoading:s}},Lr=({currentImage:t,animationState:e,backdropUrl:s,counterOverlayUrl:r,counterHeightPercent:o=12,className:l="",verticalOffset:c=0,scale:g=100})=>{const d=c+o,w=55*(g/100);return n.jsx("div",{className:`flex flex-col items-center justify-center gap-6 w-full ${l}`,children:n.jsxs("div",{className:"relative w-full max-w-[600px] mx-auto aspect-[16/10] overflow-hidden",children:[s&&n.jsx("img",{src:s,alt:"Backdrop",className:"absolute inset-0 z-0 w-full h-full object-cover object-bottom"}),n.jsx("img",{src:t,alt:`Bob ${e}`,className:"absolute z-10 h-auto object-contain left-1/2 -translate-x-1/2",style:{bottom:`${d}%`,width:`${w}%`,maxWidth:`${220*(g/100)}px`,transformOrigin:"center bottom"}}),r&&n.jsx("img",{src:r,alt:"Counter",className:"absolute z-20 bottom-0 left-0 w-full object-cover object-bottom",style:{height:`${o}%`}})]})})},Br=({messages:t,input:e,setInput:s,isLoading:r,onSend:o,onKeyPress:l,onInputFocus:c,onInputBlur:g,chatEndRef:d,isMuted:w=!1,onToggleMute:h,isSpeaking:m=!1,className:b=""})=>n.jsx("div",{className:`w-full max-w-6xl mx-auto px-4 pb-8 ${b}`,children:n.jsxs("div",{className:"bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg overflow-hidden",children:[n.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800",children:n.jsxs("div",{className:"flex gap-2",children:[n.jsx("input",{value:e,onChange:E=>s(E.target.value),onKeyPress:l,onFocus:c,onBlur:g,placeholder:"Ask Bob about car parts...",disabled:r,className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500"}),h&&n.jsx("button",{onClick:h,className:`shrink-0 p-2 border border-gray-300 dark:border-gray-600 rounded-md ${m?"animate-pulse":""}`,title:w?"Unmute Bob's voice":"Mute Bob's voice",children:w?"🔇":"🔊"}),n.jsx("button",{onClick:o,disabled:r||!e.trim(),className:"shrink-0 px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:"Send"})]})}),n.jsxs("div",{className:"overflow-y-auto p-4 space-y-3 h-[300px] md:h-[400px]",children:[[...t].reverse().map((E,I)=>n.jsx("div",{className:`flex ${E.role==="user"?"justify-end":"justify-start"}`,children:n.jsx("div",{className:`max-w-[80%] rounded-lg px-4 py-2 text-sm md:text-base ${E.role==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-gray-100"}`,children:E.content})},I)),n.jsx("div",{ref:d})]})]})}),$s=({currentImage:t,animationState:e,counterOverlayUrl:s,counterHeightPercent:r=15,scale:o=100,position:l="center"})=>{const c=65*o/100,g=320*o/100,d=l==="center"?"5%":"-25%";return n.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:[n.jsx("div",{className:"absolute left-0 z-40",style:{bottom:`${r-2}%`,maxHeight:`${100-r-5}%`,transform:`translateX(${d})`,width:`${c}%`,maxWidth:`${g}px`,transition:"transform 0.4s ease-out"},children:n.jsx("img",{src:t,alt:`Bob ${e}`,className:"w-full h-auto object-contain",style:{display:"block",maxHeight:"100%"}})}),s&&n.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-50",style:{height:`${r}%`},children:n.jsx("img",{src:s,alt:"Shop counter",className:"w-full h-full object-cover object-top"})})]})},cr=(t,e)=>{if(!t||!e)return!1;const s=t.toLowerCase();return e.toLowerCase().replace(/s\b/g,"").split(/\s+/).filter(Boolean).every(o=>s.includes(o))},Wn=(t,e)=>{var o;const s=((o=t.brand)==null?void 0:o.toLowerCase())===e.brand.toLowerCase(),r=Math.abs(t.price-e.price)<1;return s&&r},Kn=({product:t,isSpotlighted:e,spotlightedRef:s,onProductClick:r})=>n.jsxs("div",{ref:e?s:void 0,onClick:()=>r==null?void 0:r(t),className:`md:hidden cursor-pointer active:scale-[0.98] transition-all duration-200 bg-white rounded-xl border relative overflow-hidden ${e?"ring-2 ring-blue-500 shadow-lg border-blue-200":"border-gray-100 shadow-md"}`,children:[e&&n.jsx(qs,{}),n.jsx("div",{className:"aspect-[16/10] bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center overflow-hidden",children:t.image_url?n.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-2"}):n.jsx(Qs,{size:"sm"})}),n.jsxs("div",{className:"p-2.5",children:[n.jsx("p",{className:"text-sm font-semibold text-gray-900 line-clamp-1 mb-0.5",children:t.name}),t.brand&&n.jsx("p",{className:"text-xs text-gray-500 mb-1.5",children:t.brand}),n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-base font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"}),n.jsx("button",{className:"bg-blue-600 text-white text-xs font-semibold px-3 py-1.5 rounded-lg hover:bg-blue-700 active:bg-blue-800 transition-colors",onClick:o=>{o.stopPropagation(),r==null||r(t)},children:"View"})]})]})]}),Vn=({product:t,isSpotlighted:e,spotlightedRef:s,onProductClick:r})=>n.jsxs("div",{ref:e?s:void 0,onClick:()=>r==null?void 0:r(t),className:`hidden md:block lg:hidden cursor-pointer transition-all duration-300 bg-white rounded-2xl border relative overflow-hidden hover:shadow-xl hover:scale-[1.02] hover:-translate-y-1 ${e?"ring-2 ring-blue-500 shadow-xl border-blue-200":"border-gray-100 shadow-lg"}`,children:[e&&n.jsx(qs,{}),n.jsx("div",{className:"aspect-[4/3] bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center overflow-hidden",children:t.image_url?n.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-4"}):n.jsx(Qs,{size:"md"})}),n.jsxs("div",{className:"p-4",children:[n.jsx("p",{className:"text-base font-semibold text-gray-900 line-clamp-2 mb-1",children:t.name}),t.brand&&n.jsxs("p",{className:"text-sm text-gray-600 font-medium mb-2 flex items-center gap-1",children:[n.jsx("span",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full"}),t.brand]}),n.jsx("div",{className:"flex items-center justify-between",children:n.jsx("span",{className:"text-xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"})}),n.jsx("button",{className:"mt-3 w-full bg-gradient-to-r from-blue-600 to-blue-500 text-white text-sm font-semibold py-2.5 rounded-xl hover:from-blue-700 hover:to-blue-600 active:from-blue-800 active:to-blue-700 transition-all shadow-md",onClick:o=>{o.stopPropagation(),r==null||r(t)},children:"View Details"})]})]}),zn=({product:t,isSpotlighted:e,spotlightedRef:s,onProductClick:r})=>n.jsxs("div",{ref:e?s:void 0,onClick:()=>r==null?void 0:r(t),className:`hidden lg:flex flex-row cursor-pointer transition-all duration-300 bg-white rounded-2xl border relative overflow-hidden hover:shadow-2xl hover:scale-[1.01] hover:-translate-y-0.5 group ${e?"ring-2 ring-blue-500 shadow-xl border-blue-200":"border-gray-100 shadow-lg"}`,style:{minHeight:"140px"},children:[e&&n.jsx(qs,{variant:"horizontal"}),n.jsx("div",{className:"w-36 shrink-0 bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center overflow-hidden",children:t.image_url?n.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-3 group-hover:scale-105 transition-transform duration-300"}):n.jsx(Qs,{size:"lg"})}),n.jsxs("div",{className:"flex-1 p-4 flex flex-col justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-base font-semibold text-gray-900 line-clamp-2 mb-1 group-hover:text-blue-700 transition-colors",children:t.name}),t.brand&&n.jsx("div",{className:"flex items-center gap-2 mb-2",children:n.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-gray-600 bg-gray-100 px-2 py-0.5 rounded-full",children:[n.jsx("svg",{className:"w-3 h-3 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20",children:n.jsx("path",{fillRule:"evenodd",d:"M6.267 3.455a3.066 3.066 0 001.745-.723 3.066 3.066 0 013.976 0 3.066 3.066 0 001.745.723 3.066 3.066 0 012.812 2.812c.051.643.304 1.254.723 1.745a3.066 3.066 0 010 3.976 3.066 3.066 0 00-.723 1.745 3.066 3.066 0 01-2.812 2.812 3.066 3.066 0 00-1.745.723 3.066 3.066 0 01-3.976 0 3.066 3.066 0 00-1.745-.723 3.066 3.066 0 01-2.812-2.812 3.066 3.066 0 00-.723-1.745 3.066 3.066 0 010-3.976 3.066 3.066 0 00.723-1.745 3.066 3.066 0 012.812-2.812zm7.44 5.252a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),t.brand]})})]}),n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("span",{className:"text-2xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{className:"px-4 py-2 border border-gray-200 text-gray-700 text-sm font-medium rounded-lg hover:bg-gray-50 hover:border-gray-300 transition-all opacity-0 group-hover:opacity-100",onClick:o=>{o.stopPropagation(),r==null||r(t)},children:"Details"}),n.jsx("button",{className:"px-4 py-2 bg-gradient-to-r from-blue-600 to-blue-500 text-white text-sm font-semibold rounded-lg hover:from-blue-700 hover:to-blue-600 transition-all shadow-md",onClick:o=>{o.stopPropagation(),r==null||r(t)},children:"View"})]})]})]})]}),qs=({variant:t="default"})=>n.jsxs("span",{className:`absolute bg-gradient-to-r from-blue-600 to-blue-500 text-white text-xs px-2.5 py-1 rounded-full z-20 flex items-center gap-1 font-semibold shadow-md ${t==="horizontal"?"top-2 left-2":"top-3 right-3"}`,children:[n.jsx("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 20 20",children:n.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),"Bob's Pick"]}),Qs=({size:t})=>{const e={sm:"h-8 w-8",md:"h-10 w-10",lg:"h-12 w-12"};return n.jsxs("div",{className:"flex flex-col items-center justify-center text-gray-400",children:[n.jsx("svg",{className:e[t],fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),n.jsx("span",{className:"text-xs font-medium uppercase tracking-wide mt-1",children:"No Image"})]})},Ws=({products:t,servicePackages:e,highlightedPartType:s,highlightedProduct:r,onProductClick:o,onPackageSelect:l,isResearching:c,visible:g=!0,counterHeightPercent:d=22,hasVehicle:w=!1})=>{const h=u.useRef(null),m=u.useRef({}),b=u.useRef(null),E=u.useMemo(()=>{const y={};return t.forEach(p=>{const f=p.partslotDescription||"Other Parts";y[f]||(y[f]=[]),y[f].push(p)}),Object.keys(y).sort((p,f)=>p.localeCompare(f)).map(p=>({name:p,products:y[p]}))},[t]);u.useEffect(()=>{var y;if(s){const j=E.find(p=>cr(p.name,s));j&&m.current[j.name]&&((y=m.current[j.name])==null||y.scrollIntoView({behavior:"smooth",block:"start"}))}},[s,E]),u.useEffect(()=>{r&&b.current&&b.current.scrollIntoView({behavior:"smooth",block:"center"})},[r]);const I=t.length>0||e.length>0,T=c,R=I&&!c,_=w?"56px":"8px";return n.jsxs("div",{ref:h,className:`absolute right-2 md:right-3 lg:right-4 w-[52%] md:w-[55%] lg:w-[58%] max-w-[280px] md:max-w-[400px] lg:max-w-[520px] overflow-y-auto overflow-x-hidden z-30 flex flex-col gap-3 md:gap-4 lg:gap-5 pb-4 transition-all duration-300 ease-out ${g?"opacity-100 translate-x-0":"opacity-0 translate-x-8 pointer-events-none"}`,style:{top:_,bottom:"calc(70px + env(safe-area-inset-bottom, 8px))",paddingTop:"env(safe-area-inset-top, 4px)"},children:[T&&n.jsx("div",{className:"rounded-xl bg-white/90 backdrop-blur-sm p-4 shadow-lg border border-gray-100",children:n.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-600",children:[n.jsx("div",{className:"w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"}),n.jsx("span",{className:"font-medium",children:"Finding parts..."})]})}),R&&e.length>0&&n.jsxs("div",{className:"space-y-2 md:space-y-3",children:[n.jsxs("div",{className:"text-xs font-bold text-blue-700 flex items-center gap-1.5 px-1 uppercase tracking-wide",children:[n.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),"Service Packages"]}),e.map(y=>n.jsxs("div",{onClick:()=>l==null?void 0:l(y),className:"cursor-pointer active:scale-[0.98] transition-all bg-white rounded-xl md:rounded-2xl border border-gray-100 p-3 md:p-4 shadow-md hover:shadow-lg md:hover:scale-[1.02]",children:[n.jsx("p",{className:"text-sm md:text-base font-semibold text-gray-900 line-clamp-2 mb-1",children:y.title}),n.jsxs("p",{className:"text-lg md:text-xl font-bold text-blue-600",children:["From $",y.from_price.toFixed(0)]})]},y.id))]}),R&&E.map(({name:y,products:j})=>{const p=s&&cr(y,s);return n.jsxs("section",{ref:f=>{m.current[y]=f},className:`rounded-xl md:rounded-2xl transition-all ${p?"ring-2 ring-blue-500 bg-blue-50/80 p-2 md:p-3 shadow-lg":""}`,children:[n.jsxs("h3",{className:"text-xs md:text-sm font-bold mb-2 md:mb-3 flex items-center gap-1.5 px-1 text-gray-800 uppercase tracking-wide",children:[n.jsx("svg",{className:"h-3.5 w-3.5 md:h-4 md:w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),n.jsx("span",{className:"truncate",children:y}),n.jsxs("span",{className:"text-[10px] md:text-xs text-gray-500 font-medium",children:["(",j.length,")"]})]}),n.jsx("div",{className:"flex flex-col gap-3 md:grid md:grid-cols-2 md:gap-4 lg:flex lg:flex-col lg:gap-4",children:j.map((f,C)=>{const N=r&&Wn(f,r);return n.jsxs(u.Fragment,{children:[n.jsx(Kn,{product:f,isSpotlighted:N,spotlightedRef:b,onProductClick:o}),n.jsx(Vn,{product:f,isSpotlighted:N,spotlightedRef:b,onProductClick:o}),n.jsx(zn,{product:f,isSpotlighted:N,spotlightedRef:b,onProductClick:o})]},`${f.id}-${C}`)})})]},y)})]})},Ks=({onTranscript:t,onSpeechEnd:e,language:s="en-NZ",mode:r="toggle"}={})=>{const[o,l]=u.useState(!1),[c,g]=u.useState(""),[d,w]=u.useState(""),[h,m]=u.useState(null),[b,E]=u.useState(!1),I=u.useRef(null),T=u.useRef(""),R=u.useRef(t),_=u.useRef(e);u.useEffect(()=>{R.current=t,_.current=e},[t,e]),u.useEffect(()=>{const f=window.SpeechRecognition||window.webkitSpeechRecognition;if(f){E(!0);const C=new f;C.continuous=r==="ptt",C.interimResults=!0,C.lang=s,C.maxAlternatives=1,C.onstart=()=>{l(!0),m(null)},C.onresult=N=>{let P="",F="";for(let x=N.resultIndex;x<N.results.length;x++){const S=N.results[x][0].transcript;N.results[x].isFinal?F+=S:P+=S}F&&(T.current=F,g(F),R.current&&R.current(F)),w(P)},C.onerror=N=>{switch(l(!1),N.error){case"no-speech":m("No speech detected. Please try again.");break;case"audio-capture":m("No microphone found. Please check your device.");break;case"not-allowed":m("Microphone permission denied. Please allow access.");break;default:m("Speech recognition error. Please try again.")}},C.onend=()=>{l(!1),w(""),T.current&&_.current&&_.current(T.current),T.current=""},I.current=C}return()=>{I.current&&I.current.stop()}},[s,r]);const y=()=>{I.current&&!o&&(g(""),w(""),m(null),I.current.start())},j=()=>{I.current&&o&&I.current.stop()};return{isListening:o,transcript:c,interimTranscript:d,error:h,isSupported:b,startListening:y,stopListening:j,toggleListening:()=>{o?j():y()}}},Ur=({messages:t,input:e,setInput:s,isLoading:r,onSend:o,onKeyPress:l,onInputFocus:c,onInputBlur:g,chatEndRef:d,isMuted:w=!1,onToggleMute:h,isSpeaking:m=!1})=>{const[b,E]=u.useState(!1),I=u.useRef(null),T=u.useRef(!1),{isListening:R,interimTranscript:_,error:y,isSupported:j,startListening:p,stopListening:f}=Ks({onTranscript:x=>s(x),language:"en-NZ",mode:"ptt"});u.useEffect(()=>{_&&s(_)},[_,s]);const C=u.useCallback(()=>{r||T.current||(T.current=!0,navigator.vibrate&&navigator.vibrate(10),p())},[r,p]),N=u.useCallback(()=>{T.current&&(T.current=!1,navigator.vibrate&&navigator.vibrate(10),f(),setTimeout(()=>{o()},150))},[f,o]),P=[...t].reverse().find(x=>x.role==="assistant"),F=P!=null&&P.content?P.content.length>50?P.content.slice(0,50)+"...":P.content:"Ask Bob about car parts...";return n.jsxs("div",{ref:I,className:`fixed bottom-0 left-0 right-0 bg-white/95 backdrop-blur-md border-t border-gray-200 transition-all duration-300 ease-out shadow-[0_-4px_20px_rgba(0,0,0,0.15)] ${b?"h-[55vh]":"h-auto"}`,style:{zIndex:60,paddingBottom:"env(safe-area-inset-bottom, 8px)"},children:[n.jsx("button",{onClick:()=>E(!b),className:"absolute -top-5 left-1/2 -translate-x-1/2 bg-white border border-gray-200 rounded-full p-1.5 shadow-lg z-40","aria-label":b?"Collapse chat":"Expand chat",children:b?n.jsx("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):n.jsx("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!b&&n.jsx("div",{className:"px-3 pt-2 pb-0.5",onClick:()=>E(!0),children:n.jsx("p",{className:"text-xs text-gray-500 line-clamp-1",children:F})}),b&&n.jsxs("div",{className:"h-[calc(100%-100px)] overflow-y-auto p-4 space-y-2",children:[[...t].reverse().map((x,S)=>n.jsx("div",{className:`flex ${x.role==="user"?"justify-end":"justify-start"}`,children:n.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${x.role==="user"?"bg-blue-600 text-white":"bg-gray-100 text-gray-900"}`,children:x.content})},S)),n.jsx("div",{ref:d})]}),n.jsxs("div",{className:`px-2 pb-1.5 ${b?"pt-2 border-t border-gray-200":"pt-0.5"}`,children:[R&&n.jsxs("div",{className:"mb-2 text-xs text-gray-500 flex items-center gap-2",children:[n.jsx("span",{className:"inline-block w-2 h-2 bg-red-500 rounded-full animate-pulse"}),"Listening..."]}),y&&n.jsx("div",{className:"mb-2 text-xs text-red-500",children:y}),n.jsxs("div",{className:"flex gap-1.5 items-center",children:[h&&b&&n.jsx("button",{onClick:h,className:`shrink-0 h-9 w-9 flex items-center justify-center rounded-md hover:bg-gray-100 ${m?"text-blue-600 animate-pulse":"text-gray-600"}`,title:w?"Unmute":"Mute",children:w?n.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}),n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):n.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})})}),n.jsx("input",{type:"text",value:e,onChange:x=>s(x.target.value),onKeyPress:l,onFocus:c,onBlur:g,placeholder:"Message Bob...",disabled:r,className:"flex-1 h-10 text-base px-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50"}),j&&n.jsx("button",{onTouchStart:C,onTouchEnd:N,onTouchCancel:N,onMouseDown:C,onMouseUp:N,onMouseLeave:N,disabled:r,className:`shrink-0 h-12 w-12 rounded-full flex items-center justify-center select-none touch-none ${R?"bg-red-500 text-white animate-pulse ring-2 ring-red-300 scale-110":"bg-blue-600 text-white"} disabled:opacity-50`,title:"Hold to talk",children:n.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]})]})]})},$r=({currentImage:t,animationState:e,backdropUrl:s,counterOverlayUrl:r,counterHeightPercent:o=22,messages:l,input:c,setInput:g,isLoading:d,onSend:w,onKeyPress:h,onInputFocus:m,onInputBlur:b,chatEndRef:E,isMuted:I,onToggleMute:T,isSpeaking:R,products:_,servicePackages:y,highlightedPartType:j,highlightedProduct:p,onProductClick:f,onPackageSelect:C,isResearching:N,vehicle:P,onChangeVehicle:F})=>{const x=typeof window<"u"&&window.self!==window.top,[S,W]=u.useState("center"),[B,A]=u.useState("hidden"),Y=_.length>0||y.length>0;u.useEffect(()=>{if(N&&B!=="loading"&&B!=="visible")A("loading"),S==="center"&&W("left");else if(Y&&B!=="visible")if(S==="center"){W("left"),A("transitioning");const L=setTimeout(()=>{A("visible")},400);return()=>clearTimeout(L)}else A("visible");else!Y&&!N&&B!=="hidden"&&(A("hidden"),W("center"))},[Y,N,B,S]);const oe=B!=="hidden";return n.jsxs("div",{className:"fixed inset-0 overflow-hidden",style:{height:"100dvh",touchAction:"manipulation"},children:[s&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"absolute inset-0 z-0",style:{backgroundImage:`url(${s})`,backgroundSize:"cover",backgroundPosition:"center bottom",filter:"blur(12px) brightness(0.7)",transform:"scale(1.1)"}}),n.jsx("div",{className:"absolute inset-0 z-[1]",style:{background:"linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.6) 100%)"}})]}),n.jsx($s,{currentImage:t,animationState:e,counterOverlayUrl:r,counterHeightPercent:o,scale:200,position:S}),P&&!x&&n.jsx("div",{className:"absolute top-2 left-2 right-2 z-20",children:n.jsxs("div",{className:"bg-white/90 backdrop-blur-sm rounded-lg px-3 py-2 border border-gray-200 shadow-lg flex items-center justify-between",style:{paddingTop:"calc(env(safe-area-inset-top, 4px) + 8px)"},children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("p",{className:"text-xs font-medium text-gray-900 truncate",children:[P.year," ",P.make," ",P.model]}),P.rego&&n.jsx("p",{className:"text-[10px] text-gray-500",children:P.rego})]}),F&&n.jsx("button",{onClick:F,className:"text-xs text-blue-600 hover:underline ml-2 shrink-0",children:"Change"})]})}),n.jsx(Ws,{products:_,servicePackages:y,highlightedPartType:j,highlightedProduct:p,onProductClick:f,onPackageSelect:C,isResearching:N,visible:oe,counterHeightPercent:o,hasVehicle:!!P}),n.jsx(Ur,{messages:l,input:c,setInput:g,isLoading:d,onSend:w,onKeyPress:h,onInputFocus:m,onInputBlur:b,chatEndRef:E,isMuted:I,onToggleMute:T,isSpeaking:R})]})},qr=({messages:t,input:e,setInput:s,isLoading:r,onSend:o,onKeyPress:l,onInputFocus:c,onInputBlur:g,chatEndRef:d,isMuted:w=!1,onToggleMute:h,isSpeaking:m=!1})=>{const[b,E]=u.useState(!1),I=u.useRef(null),T=u.useRef(!1),{isListening:R,interimTranscript:_,error:y,isSupported:j,startListening:p,stopListening:f}=Ks({onTranscript:x=>s(x),language:"en-NZ",mode:"ptt"});u.useEffect(()=>{_&&s(_)},[_,s]);const C=u.useCallback(()=>{r||T.current||(T.current=!0,navigator.vibrate&&navigator.vibrate(10),p())},[r,p]),N=u.useCallback(()=>{T.current&&(T.current=!1,navigator.vibrate&&navigator.vibrate(10),f(),setTimeout(()=>{o()},150))},[f,o]),P=[...t].reverse().find(x=>x.role==="assistant"),F=P!=null&&P.content?P.content.length>50?P.content.slice(0,50)+"...":P.content:"Ask Bob about car parts...";return n.jsxs("div",{ref:I,className:`absolute bottom-0 left-0 right-0 bg-white/95 backdrop-blur-md border-t border-gray-200 transition-all duration-300 ease-out shadow-[0_-4px_20px_rgba(0,0,0,0.15)] ${b?"h-[55%]":"overflow-hidden"}`,style:{zIndex:60,paddingBottom:"env(safe-area-inset-bottom, 8px)",height:b?void 0:"70px"},children:[n.jsx("button",{onClick:()=>E(!b),className:"absolute -top-5 left-1/2 -translate-x-1/2 z-40 bg-white border border-gray-200 rounded-full p-1.5 shadow-lg","aria-label":b?"Collapse chat":"Expand chat",children:b?n.jsx("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):n.jsx("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!b&&n.jsx("div",{className:"px-3 pt-1.5 pb-1 h-[26px] overflow-hidden",onClick:()=>E(!0),children:n.jsx("p",{className:"text-xs text-gray-500 line-clamp-1",children:F})}),b&&n.jsxs("div",{className:"h-[calc(100%-100px)] overflow-y-auto p-4 space-y-2",children:[[...t].reverse().map((x,S)=>n.jsx("div",{className:`flex ${x.role==="user"?"justify-end":"justify-start"}`,children:n.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${x.role==="user"?"bg-blue-600 text-white":"bg-gray-100 text-gray-900"}`,children:x.content})},S)),n.jsx("div",{ref:d})]}),n.jsxs("div",{className:`px-3 pb-1 ${b?"pt-2 border-t border-gray-200":"pt-1"}`,children:[R&&n.jsxs("div",{className:"mb-2 text-xs text-gray-500 flex items-center gap-2",children:[n.jsx("span",{className:"inline-block w-2 h-2 bg-red-500 rounded-full animate-pulse"}),"Listening..."]}),y&&n.jsx("div",{className:"mb-2 text-xs text-red-500",children:y}),n.jsxs("div",{className:"flex gap-1.5 items-center",children:[h&&b&&n.jsx("button",{onClick:h,className:`shrink-0 h-9 w-9 flex items-center justify-center rounded-md hover:bg-gray-100 ${m?"text-blue-600 animate-pulse":"text-gray-600"}`,title:w?"Unmute":"Mute",children:w?n.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}),n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):n.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})})}),n.jsx("input",{type:"text",value:e,onChange:x=>s(x.target.value),onKeyPress:l,onFocus:c,onBlur:g,placeholder:"Message Bob...",disabled:r,className:"flex-1 h-10 text-base px-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50"}),j&&n.jsx("button",{onTouchStart:C,onTouchEnd:N,onTouchCancel:N,onMouseDown:C,onMouseUp:N,onMouseLeave:N,disabled:r,className:`shrink-0 h-12 w-12 rounded-full flex items-center justify-center select-none touch-none ${R?"bg-red-500 text-white animate-pulse ring-2 ring-red-300 scale-110":"bg-blue-600 text-white"} disabled:opacity-50`,title:"Hold to talk",children:n.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]})]})]})},Hn=({product:t,onBack:e,onAddToCart:s,onNavigateToProductPage:r})=>{const o=t.product_url||r;return n.jsxs("div",{className:"absolute inset-0 z-35 flex flex-col bg-white/95 backdrop-blur-md overflow-hidden",children:[n.jsx("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-gray-200 bg-white/80 backdrop-blur-sm",children:n.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 text-blue-600 font-medium text-sm hover:text-blue-700 active:scale-95 transition-all",children:[n.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back to Products"]})}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n.jsx("div",{className:"aspect-square bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center",children:t.image_url?n.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-4"}):n.jsxs("div",{className:"flex flex-col items-center justify-center text-gray-400",children:[n.jsx("svg",{className:"h-16 w-16 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),n.jsx("span",{className:"text-sm font-medium uppercase tracking-wide",children:"No Image Available"})]})}),n.jsxs("div",{className:"p-4 space-y-4",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-xl font-bold text-gray-900 mb-1",children:t.name}),t.brand&&n.jsx("p",{className:"text-sm text-gray-600 font-medium",children:t.brand})]}),n.jsxs("div",{className:"bg-blue-50 rounded-xl p-4",children:[n.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Price"}),n.jsx("p",{className:"text-2xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"Price on Request"}),t.price>0&&n.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Inc. GST"})]}),n.jsxs("div",{className:"space-y-3",children:[t.partslotDescription&&n.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[n.jsx("span",{className:"text-sm text-gray-500",children:"Category"}),n.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.partslotDescription})]}),t.sku&&n.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[n.jsx("span",{className:"text-sm text-gray-500",children:"SKU"}),n.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.sku})]}),t.part_number&&n.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[n.jsx("span",{className:"text-sm text-gray-500",children:"Part Number"}),n.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.part_number})]})]}),o&&n.jsx("a",{href:t.product_url||"#",onClick:l=>{r&&(l.preventDefault(),r(t))},target:t.product_url&&!r?"_blank":void 0,rel:t.product_url&&!r?"noopener noreferrer":void 0,className:"block text-center text-blue-600 text-sm font-medium hover:underline py-2",children:"View Full Details on CARFIX →"})]})]}),n.jsx("div",{className:"p-4 border-t border-gray-200 bg-white/95 backdrop-blur-sm",children:n.jsx("button",{onClick:()=>s==null?void 0:s(t),className:"w-full bg-blue-600 text-white text-base font-semibold py-3 rounded-xl hover:bg-blue-700 active:bg-blue-800 transition-colors shadow-lg",children:"Add to Cart"})})]})},Qr=({currentImage:t,animationState:e,backdropUrl:s,counterOverlayUrl:r,counterHeightPercent:o=22,messages:l,input:c,setInput:g,isLoading:d,onSend:w,onKeyPress:h,onInputFocus:m,onInputBlur:b,chatEndRef:E,isMuted:I,onToggleMute:T,isSpeaking:R,products:_,servicePackages:y,highlightedPartType:j,highlightedProduct:p,onProductClick:f,onPackageSelect:C,isResearching:N,onAddToCart:P,onNavigateToProductPage:F,vehicle:x,onChangeVehicle:S})=>{const[W,B]=u.useState("center"),[A,Y]=u.useState("hidden"),[oe,L]=u.useState("products"),[G,ae]=u.useState(null),ge=_.length>0||y.length>0,J=oe==="productDetail"?65:130;u.useEffect(()=>{if(N&&A!=="loading"&&A!=="visible")Y("loading"),W==="center"&&B("left");else if(ge&&A!=="visible")if(W==="center"){B("left"),Y("transitioning");const be=setTimeout(()=>{Y("visible")},400);return()=>clearTimeout(be)}else Y("visible");else!ge&&!N&&A!=="hidden"&&(Y("hidden"),B("center"))},[ge,N,A,W]);const De=be=>{if(F){F(be),f==null||f(be);return}ae(be),L("productDetail"),f==null||f(be)},Rt=()=>{ae(null),L("products")},me=A!=="hidden"&&oe==="products",qt=A!=="hidden";return n.jsxs("div",{className:"absolute inset-0 overflow-hidden",style:{touchAction:"manipulation"},children:[s&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"absolute inset-0 z-0 transition-all duration-500 ease-out",style:{backgroundImage:`url(${s})`,backgroundSize:"cover",backgroundPosition:"center bottom",filter:qt?"blur(12px) brightness(0.7)":"blur(0px) brightness(1)",transform:"scale(1.1)"}}),n.jsx("div",{className:"absolute inset-0 z-[1]",style:{background:"linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.6) 100%)"}})]}),n.jsx($s,{currentImage:t,animationState:e,counterOverlayUrl:r,counterHeightPercent:o,scale:J,position:"left"}),x&&oe==="products"&&n.jsx("div",{className:"absolute top-2 left-2 right-2 z-20",children:n.jsxs("div",{className:"bg-white/90 backdrop-blur-sm rounded-lg px-3 py-2 border border-gray-200 shadow-lg flex items-center justify-between",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("p",{className:"text-xs font-medium text-gray-900 truncate",children:[x.year," ",x.make," ",x.model]}),x.rego&&n.jsx("p",{className:"text-[10px] text-gray-500",children:x.rego})]}),S&&n.jsx("button",{onClick:S,className:"text-xs text-blue-600 hover:underline ml-2 shrink-0",children:"Change"})]})}),n.jsx(Ws,{products:_,servicePackages:y,highlightedPartType:j,highlightedProduct:p,onProductClick:De,onPackageSelect:C,isResearching:N,visible:me,counterHeightPercent:o,hasVehicle:!!x}),oe==="productDetail"&&G&&n.jsx(Hn,{product:G,onBack:Rt,onAddToCart:P,onNavigateToProductPage:F}),oe==="products"&&n.jsx(qr,{messages:l,input:c,setInput:g,isLoading:d,onSend:w,onKeyPress:h,onInputFocus:m,onInputBlur:b,chatEndRef:E,isMuted:I,onToggleMute:T,isSpeaking:R})]})},Wr=({variant:t="inline",initialState:e="idle",showChat:s=!0,className:r="",backdropUrl:o,counterOverlayUrl:l,counterHeightPercent:c,defaultBobImage:g,verticalOffset:d=0,scale:w=100})=>{const{callbacks:h}=rt(),{animationState:m,setAnimationState:b,getCurrentImage:E,availableStates:I,isLoading:T}=Ar(),{activeBackdrop:R}=Dr(),[_,y]=u.useState([]),[j,p]=u.useState([]),[f,C]=u.useState(null),[N,P]=u.useState(null),[F,x]=u.useState(!1),S=Mr({setAnimationState:b,manualMode:!1,onReadyToSpeak:()=>{console.log("[BobWidget] Ready to speak")},onStreamComplete:()=>{b(I.find(L=>L.includes("idle"))||"idle")},onResearchStart:()=>{x(!0)},onHighlightPart:L=>{C(L),setTimeout(()=>C(null),8e3)},onHighlightProduct:L=>{P(L),setTimeout(()=>P(null),8e3)},onAutoFetchComplete:()=>{x(!1)}});u.useEffect(()=>{const L=h.onPartsFound,G=h.onServicePackagesFound;return h.onPartsFound=ae=>{x(!1);const ge=ae.map((J,De)=>({id:J.SKU||J.sku||`part-${De}`,name:J["Part Product Type"]||J.partslot_description||"Unknown Part",brand:J.Brand||J.brand,price:J["Metro Retail Price"]||J.price||0,sku:J.SKU||J.sku,partNumber:J["Part Number"]||J.part_number,partslotDescription:J["Part Product Type"]||J.partslot_description,image_url:J.image_url}));y(ge),L==null||L(ae)},h.onServicePackagesFound=ae=>{p(ae),G==null||G(ae)},()=>{h.onPartsFound=L,h.onServicePackagesFound=G}},[h]);const W=o||(R==null?void 0:R.image_url),B=l||(R==null?void 0:R.counter_overlay_url)||void 0,A=c||(R==null?void 0:R.counter_height_percent)||12,Y=E()||g||"";if(t==="mobile"||t==="fullscreen")return n.jsx($r,{currentImage:Y,animationState:m,backdropUrl:W,counterOverlayUrl:B,counterHeightPercent:A,messages:S.messages,input:S.input,setInput:S.setInput,isLoading:S.isLoading,onSend:S.handleSend,onKeyPress:S.handleKeyPress,onInputFocus:S.handleInputFocus,onInputBlur:S.handleInputBlur,chatEndRef:S.chatEndRef,isMuted:S.isMuted,onToggleMute:S.toggleMute,isSpeaking:S.isSpeaking,products:_,servicePackages:j,highlightedPartType:f,highlightedProduct:N,onAddToCart:L=>{var G;return(G=h.onAddToCart)==null?void 0:G.call(h,{product_id:L.id,product_name:L.name,quantity:1,unit_price:L.price,sku:L.sku,brand:L.brand})},onNavigateToProductPage:L=>{var G;return(G=h.onNavigateToProductPage)==null?void 0:G.call(h,L)},onPackageSelect:L=>console.log("[BobWidget] Package selected:",L),isResearching:F,vehicle:S.identifiedVehicle});if(t==="inline"&&s)return n.jsx("div",{className:`relative w-full h-full ${r}`,children:n.jsx(Qr,{currentImage:Y,animationState:m,backdropUrl:W,counterOverlayUrl:B,counterHeightPercent:A,messages:S.messages,input:S.input,setInput:S.setInput,isLoading:S.isLoading,onSend:S.handleSend,onKeyPress:S.handleKeyPress,onInputFocus:S.handleInputFocus,onInputBlur:S.handleInputBlur,chatEndRef:S.chatEndRef,isMuted:S.isMuted,onToggleMute:S.toggleMute,isSpeaking:S.isSpeaking,products:_,servicePackages:j,highlightedPartType:f,highlightedProduct:N,onAddToCart:L=>{var G;return(G=h.onAddToCart)==null?void 0:G.call(h,{product_id:L.id,product_name:L.name,quantity:1,unit_price:L.price,sku:L.sku,brand:L.brand})},onNavigateToProductPage:L=>{var G;return(G=h.onNavigateToProductPage)==null?void 0:G.call(h,L)},onPackageSelect:L=>console.log("[BobWidget] Package selected:",L),isResearching:F,vehicle:S.identifiedVehicle})});const oe={inline:"",floating:"fixed bottom-4 right-4 w-96 z-50 shadow-2xl rounded-lg overflow-hidden"};return n.jsxs("div",{className:`${oe[t]||""} ${r}`,children:[Y&&n.jsx(Lr,{currentImage:Y,animationState:m,backdropUrl:W,counterOverlayUrl:B,counterHeightPercent:A,verticalOffset:d,scale:w}),s&&n.jsx(Br,{messages:S.messages,input:S.input,setInput:S.setInput,isLoading:S.isLoading,onSend:S.handleSend,onKeyPress:S.handleKeyPress,onInputFocus:S.handleInputFocus,onInputBlur:S.handleInputBlur,chatEndRef:S.chatEndRef,isMuted:S.isMuted,onToggleMute:S.toggleMute,isSpeaking:S.isSpeaking})]})},Gn=({bobConfig:t,hostApiConfig:e,hostContext:s,callbacks:r,variant:o="mobile",initialState:l,showChat:c,className:g,backdropUrl:d,counterOverlayUrl:w,counterHeightPercent:h,defaultBobImage:m,verticalOffset:b,scale:E})=>n.jsx(Ir,{bobConfig:t,hostApiConfig:e,hostContext:s,callbacks:r,children:n.jsx(Wr,{variant:o,initialState:l,showChat:c,className:g,backdropUrl:d,counterOverlayUrl:w,counterHeightPercent:h,defaultBobImage:m,verticalOffset:b,scale:E})}),Yn=6e4,Jn=({states:t,setAnimationState:e,manualMode:s})=>{const[r,o]=u.useState("page_load"),[l,c]=u.useState(!1),g=u.useRef(null),d=u.useCallback(f=>t.find(C=>C.chat_trigger===f&&C.is_active),[t]),w=u.useCallback(()=>t.find(f=>f.chat_trigger==="awaiting_input"||f.state_key==="talk_pause"||f.title.toLowerCase().includes("listen")||f.title.toLowerCase().includes("pause")),[t]),h=u.useCallback(()=>t.find(f=>f.state_key==="idle"||f.title.toLowerCase().includes("idle")),[t]),m=u.useCallback(f=>{const C=t.find(N=>N.state_key===f);return{speed:(C==null?void 0:C.animation_speed)||400,pauseDuration:(C==null?void 0:C.pause_duration)||0,loopCount:(C==null?void 0:C.loop_count)||0}},[t]),b=u.useCallback(()=>{g.current&&(clearTimeout(g.current),g.current=null)},[]),E=u.useCallback(()=>{b(),!s&&(g.current=setTimeout(()=>{const f=h();f&&(o("idle"),e(f.state_key))},Yn))},[s,h,e,b]),I=u.useCallback(f=>{if(s)return;const C=d(f);C&&e(C.state_key)},[s,d,e]),T=u.useCallback(()=>{if(s)return;const f=w();f&&(o("awaiting_input"),e(f.state_key),E())},[s,w,e,E]),R=u.useCallback(()=>{l||s||(c(!0),o("page_load"),I("page_load"),setTimeout(()=>{T()},3e3))},[l,s,I,T]),_=u.useCallback(()=>{b(),o("processing_input"),I("processing_input")},[I,b]),y=u.useCallback(()=>{b(),o("streaming_response"),I("streaming_response")},[I,b]),j=u.useCallback(()=>{o("response_complete"),I("response_complete"),setTimeout(()=>{T()},3e3)},[I,T]),p=u.useCallback(()=>{o("showing_product");const f=t.find(C=>C.chat_trigger==="showing_product"||C.state_key==="showing_product");f&&e(f.state_key),setTimeout(()=>{T()},4e3)},[t,e,T]);return u.useEffect(()=>()=>b(),[b]),{chatStage:r,initialize:R,onUserInput:_,onStreamStart:y,onStreamComplete:j,onShowingProduct:p,getStateSettings:m}};console.log(`[BobWidget] Package loaded - v${as}`);exports.BOB_VERSION=as;exports.Bob=Wr;exports.BobCharacter=Lr;exports.BobProvider=Ir;exports.BobWidget=Gn;exports.ChatInterface=Br;exports.ContainedChatDrawer=qr;exports.ContainedMobileBobLayout=Qr;exports.MobileBobCharacter=$s;exports.MobileBobLayout=$r;exports.MobileChatDrawer=Ur;exports.MobileProductColumn=Ws;exports.getBobVersion=Xr;exports.useBobAnimation=Ar;exports.useBobAnimationData=Fr;exports.useBobBackdrop=Dr;exports.useBobCallbacks=$n;exports.useBobChat=Mr;exports.useBobContext=rt;exports.useBobStateTransitions=Jn;exports.useBobSupabase=Us;exports.useHostApiConfig=Un;exports.useHostContext=Bn;exports.useSpeechRecognition=Ks;exports.useSpeechSynthesis=Pr;