@gymmymac/bob-widget 1.1.4 → 1.1.5

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 Qr=t=>{throw TypeError(t)};var xr=(t,e,r)=>e.has(t)||Qr("Cannot "+r);var i=(t,e,r)=>(xr(t,e,"read from private field"),r?r.call(t):e.get(t)),F=(t,e,r)=>e.has(t)?Qr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),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 dr=(t,e,r,s)=>({set _(a){R(t,e,a,r)},get _(){return i(t,e,s)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react"),Vs=require("@supabase/supabase-js");function Hs(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=Hs(f),nr="1.1.4",zs=()=>nr;var wr={exports:{}},zt={};/**
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)),F=(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),O=(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){O(t,e,a,r)},get _(){return i(t,e,s)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),Hs=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.5",Ys=()=>nr;var wr={exports:{}},Ht={};/**
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 $r;function Gs(){if($r)return zt;$r=1;var t=f,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,o={key:!0,ref:!0,__self:!0,__source:!0};function u(p,c,w){var m,l={},v=null,E=null;w!==void 0&&(v=""+w),c.key!==void 0&&(v=""+c.key),c.ref!==void 0&&(E=c.ref);for(m in c)s.call(c,m)&&!o.hasOwnProperty(m)&&(l[m]=c[m]);if(p&&p.defaultProps)for(m in c=p.defaultProps,c)l[m]===void 0&&(l[m]=c[m]);return{$$typeof:e,type:p,key:v,ref:E,props:l,_owner:a.current}}return zt.Fragment=r,zt.jsx=u,zt.jsxs=u,zt}var Gt={};/**
9
+ */var Vr;function Js(){if(Vr)return Ht;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,S=null;w!==void 0&&(g=""+w),l.key!==void 0&&(g=""+l.key),l.ref!==void 0&&(S=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:S,props:h,_owner:a.current}}return Ht.Fragment=r,Ht.jsx=c,Ht.jsxs=c,Ht}var Gt={};/**
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 Wr;function Ys(){return Wr||(Wr=1,process.env.NODE_ENV!=="production"&&function(){var t=f,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),p=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),l=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),E=Symbol.for("react.offscreen"),P=Symbol.iterator,T="@@iterator";function S(n){if(n===null||typeof n!="object")return null;var b=P&&n[P]||n[T];return typeof b=="function"?b:null}var j=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function g(n){{for(var b=arguments.length,O=new Array(b>1?b-1:0),A=1;A<b;A++)O[A-1]=arguments[A];C("error",n,O)}}function C(n,b,O){{var A=j.ReactDebugCurrentFrame,K=A.getStackAddendum();K!==""&&(b+="%s",O=O.concat([K]));var z=O.map(function(W){return String(W)});z.unshift("Warning: "+b),Function.prototype.apply.call(console[n],console,z)}}var d=!1,y=!1,x=!1,I=!1,N=!1,M;M=Symbol.for("react.module.reference");function _(n){return!!(typeof n=="string"||typeof n=="function"||n===s||n===o||N||n===a||n===w||n===m||I||n===E||d||y||x||typeof n=="object"&&n!==null&&(n.$$typeof===v||n.$$typeof===l||n.$$typeof===u||n.$$typeof===p||n.$$typeof===c||n.$$typeof===M||n.getModuleId!==void 0))}function k(n,b,O){var A=n.displayName;if(A)return A;var K=b.displayName||b.name||"";return K!==""?O+"("+K+")":O}function L(n){return n.displayName||"Context"}function U(n){if(n==null)return null;if(typeof n.tag=="number"&&g("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 o:return"Profiler";case a:return"StrictMode";case w:return"Suspense";case m:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case p:var b=n;return L(b)+".Consumer";case u:var O=n;return L(O._context)+".Provider";case c:return k(n,n.render,"ForwardRef");case l:var A=n.displayName||null;return A!==null?A:U(n.type)||"Memo";case v:{var K=n,z=K._payload,W=K._init;try{return U(W(z))}catch{return null}}}return null}var D=Object.assign,ee=0,Fe,H,ue,de,Be,Y,rt;function ar(){}ar.__reactDisabledLog=!0;function xe(){{if(ee===0){Fe=console.log,H=console.info,ue=console.warn,de=console.error,Be=console.group,Y=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})}ee++}}function gr(){{if(ee--,ee===0){var n={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},n,{value:Fe}),info:D({},n,{value:H}),warn:D({},n,{value:ue}),error:D({},n,{value:de}),group:D({},n,{value:Be}),groupCollapsed:D({},n,{value:Y}),groupEnd:D({},n,{value:rt})})}ee<0&&g("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Rt=j.ReactCurrentDispatcher,or;function qt(n,b,O){{if(or===void 0)try{throw Error()}catch(K){var A=K.stack.trim().match(/\n( *(at )?)/);or=A&&A[1]||""}return`
18
- `+or+n}}var ur=!1,Qt;{var qr=typeof WeakMap=="function"?WeakMap:Map;Qt=new qr}function br(n,b){if(!n||ur)return"";{var O=Qt.get(n);if(O!==void 0)return O}var A;ur=!0;var K=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var z;z=Rt.current,Rt.current=null,xe();try{if(b){var W=function(){throw Error()};if(Object.defineProperty(W.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(W,[])}catch(ce){A=ce}Reflect.construct(n,[],W)}else{try{W.call()}catch(ce){A=ce}n.call(W.prototype)}}else{try{throw Error()}catch(ce){A=ce}n()}}catch(ce){if(ce&&A&&typeof ce.stack=="string"){for(var B=ce.stack.split(`
19
- `),ie=A.stack.split(`
20
- `),J=B.length-1,X=ie.length-1;J>=1&&X>=0&&B[J]!==ie[X];)X--;for(;J>=1&&X>=0;J--,X--)if(B[J]!==ie[X]){if(J!==1||X!==1)do if(J--,X--,X<0||B[J]!==ie[X]){var ge=`
21
- `+B[J].replace(" at new "," at ");return n.displayName&&ge.includes("<anonymous>")&&(ge=ge.replace("<anonymous>",n.displayName)),typeof n=="function"&&Qt.set(n,ge),ge}while(J>=1&&X>=0);break}}}finally{ur=!1,Rt.current=z,gr(),Error.prepareStackTrace=K}var Ot=n?n.displayName||n.name:"",dt=Ot?qt(Ot):"";return typeof n=="function"&&Qt.set(n,dt),dt}function cr(n,b,O){return br(n,!1)}function lr(n){var b=n.prototype;return!!(b&&b.isReactComponent)}function st(n,b,O){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 c:return cr(n.render);case l:return st(n.type,b,O);case v:{var A=n,K=A._payload,z=A._init;try{return st(z(K),b,O)}catch{}}}return""}var Ue=Object.prototype.hasOwnProperty,q={},Z=j.ReactDebugCurrentFrame;function ne(n){if(n){var b=n._owner,O=st(n.type,n._source,b?b.type:null);Z.setExtraStackFrame(O)}else Z.setExtraStackFrame(null)}function fe(n,b,O,A,K){{var z=Function.call.bind(Ue);for(var W in n)if(z(n,W)){var B=void 0;try{if(typeof n[W]!="function"){var ie=Error((A||"React class")+": "+O+" type `"+W+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[W]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ie.name="Invariant Violation",ie}B=n[W](b,W,A,O,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(J){B=J}B&&!(B instanceof Error)&&(ne(K),g("%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",O,W,typeof B),ne(null)),B instanceof Error&&!(B.message in q)&&(q[B.message]=!0,ne(K),g("Failed %s type: %s",O,B.message),ne(null))}}}var qe=Array.isArray;function nt(n){return qe(n)}function it(n){{var b=typeof Symbol=="function"&&Symbol.toStringTag,O=b&&n[Symbol.toStringTag]||n.constructor.name||"Object";return O}}function at(n){try{return ot(n),!1}catch{return!0}}function ot(n){return""+n}function Qe(n){if(at(n))return g("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 $e=j.ReactCurrentOwner,we={key:!0,ref:!0,__self:!0,__source:!0},ut,ct;function Oe(n){if(Ue.call(n,"ref")){var b=Object.getOwnPropertyDescriptor(n,"ref").get;if(b&&b.isReactWarning)return!1}return n.ref!==void 0}function Ce(n){if(Ue.call(n,"key")){var b=Object.getOwnPropertyDescriptor(n,"key").get;if(b&&b.isReactWarning)return!1}return n.key!==void 0}function Me(n,b){typeof n.ref=="string"&&$e.current}function lt(n,b){{var O=function(){ut||(ut=!0,g("%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)",b))};O.isReactWarning=!0,Object.defineProperty(n,"key",{get:O,configurable:!0})}}function Ee(n,b){{var O=function(){ct||(ct=!0,g("%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)",b))};O.isReactWarning=!0,Object.defineProperty(n,"ref",{get:O,configurable:!0})}}var pe=function(n,b,O,A,K,z,W){var B={$$typeof:e,type:n,key:b,ref:O,props:W,_owner:z};return B._store={},Object.defineProperty(B._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(B,"_self",{configurable:!1,enumerable:!1,writable:!1,value:A}),Object.defineProperty(B,"_source",{configurable:!1,enumerable:!1,writable:!1,value:K}),Object.freeze&&(Object.freeze(B.props),Object.freeze(B)),B};function Se(n,b,O,A,K){{var z,W={},B=null,ie=null;O!==void 0&&(Qe(O),B=""+O),Ce(b)&&(Qe(b.key),B=""+b.key),Oe(b)&&(ie=b.ref,Me(b,K));for(z in b)Ue.call(b,z)&&!we.hasOwnProperty(z)&&(W[z]=b[z]);if(n&&n.defaultProps){var J=n.defaultProps;for(z in J)W[z]===void 0&&(W[z]=J[z])}if(B||ie){var X=typeof n=="function"?n.displayName||n.name||"Unknown":n;B&&lt(W,X),ie&&Ee(W,X)}return pe(n,B,ie,K,A,$e.current,W)}}var je=j.ReactCurrentOwner,$t=j.ReactDebugCurrentFrame;function We(n){if(n){var b=n._owner,O=st(n.type,n._source,b?b.type:null);$t.setExtraStackFrame(O)}else $t.setExtraStackFrame(null)}var Tt;Tt=!1;function me(n){return typeof n=="object"&&n!==null&&n.$$typeof===e}function Ke(){{if(je.current){var n=U(je.current.type);if(n)return`
17
+ */var zr;function Xs(){return zr||(zr=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"),S=Symbol.for("react.offscreen"),N=Symbol.iterator,T="@@iterator";function j(n){if(n===null||typeof n!="object")return null;var v=N&&n[N]||n[T];return typeof v=="function"?v:null}var k=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(n){{for(var v=arguments.length,I=new Array(v>1?v-1:0),L=1;L<v;L++)I[L-1]=arguments[L];C("error",n,I)}}function C(n,v,I){{var L=k.ReactDebugCurrentFrame,V=L.getStackAddendum();V!==""&&(v+="%s",I=I.concat([V]));var H=I.map(function(K){return String(K)});H.unshift("Warning: "+v),Function.prototype.apply.call(console[n],console,H)}}var f=!1,y=!1,x=!1,P=!1,_=!1,M;M=Symbol.for("react.module.reference");function E(n){return!!(typeof n=="string"||typeof n=="function"||n===s||n===u||_||n===a||n===w||n===m||P||n===S||f||y||x||typeof n=="object"&&n!==null&&(n.$$typeof===g||n.$$typeof===h||n.$$typeof===c||n.$$typeof===p||n.$$typeof===l||n.$$typeof===M||n.getModuleId!==void 0))}function R(n,v,I){var L=n.displayName;if(L)return L;var V=v.displayName||v.name||"";return V!==""?I+"("+V+")":I}function A(n){return n.displayName||"Context"}function B(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 v=n;return A(v)+".Consumer";case c:var I=n;return A(I._context)+".Provider";case l:return R(n,n.render,"ForwardRef");case h:var L=n.displayName||null;return L!==null?L:B(n.type)||"Memo";case g:{var V=n,H=V._payload,K=V._init;try{return B(K(H))}catch{return null}}}return null}var D=Object.assign,Y=0,xe,U,se,he,Be,J,rt;function ar(){}ar.__reactDisabledLog=!0;function we(){{if(Y===0){xe=console.log,U=console.info,se=console.warn,he=console.error,Be=console.group,J=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})}Y++}}function gr(){{if(Y--,Y===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:se}),error:D({},n,{value:he}),group:D({},n,{value:Be}),groupCollapsed:D({},n,{value:J}),groupEnd:D({},n,{value:rt})})}Y<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Rt=k.ReactCurrentDispatcher,or;function qt(n,v,I){{if(or===void 0)try{throw Error()}catch(V){var L=V.stack.trim().match(/\n( *(at )?)/);or=L&&L[1]||""}return`
18
+ `+or+n}}var ur=!1,$t;{var Wr=typeof WeakMap=="function"?WeakMap:Map;$t=new Wr}function br(n,v){if(!n||ur)return"";{var I=$t.get(n);if(I!==void 0)return I}var L;ur=!0;var V=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var H;H=Rt.current,Rt.current=null,we();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(ce){L=ce}Reflect.construct(n,[],K)}else{try{K.call()}catch(ce){L=ce}n.call(K.prototype)}}else{try{throw Error()}catch(ce){L=ce}n()}}catch(ce){if(ce&&L&&typeof ce.stack=="string"){for(var q=ce.stack.split(`
19
+ `),ae=L.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=H,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,v,I){return br(n,!1)}function lr(n){var v=n.prototype;return!!(v&&v.isReactComponent)}function st(n,v,I){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,v,I);case g:{var L=n,V=L._payload,H=L._init;try{return st(H(V),v,I)}catch{}}}return""}var Ue=Object.prototype.hasOwnProperty,$={},ee=k.ReactDebugCurrentFrame;function ie(n){if(n){var v=n._owner,I=st(n.type,n._source,v?v.type:null);ee.setExtraStackFrame(I)}else ee.setExtraStackFrame(null)}function fe(n,v,I,L,V){{var H=Function.call.bind(Ue);for(var K in n)if(H(n,K)){var q=void 0;try{if(typeof n[K]!="function"){var ae=Error((L||"React class")+": "+I+" 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](v,K,L,I,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(X){q=X}q&&!(q instanceof Error)&&(ie(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).",L||"React class",I,K,typeof q),ie(null)),q instanceof Error&&!(q.message in $)&&($[q.message]=!0,ie(V),b("Failed %s type: %s",I,q.message),ie(null))}}}var qe=Array.isArray;function nt(n){return qe(n)}function it(n){{var v=typeof Symbol=="function"&&Symbol.toStringTag,I=v&&n[Symbol.toStringTag]||n.constructor.name||"Object";return I}}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 v=Object.getOwnPropertyDescriptor(n,"ref").get;if(v&&v.isReactWarning)return!1}return n.ref!==void 0}function Se(n){if(Ue.call(n,"key")){var v=Object.getOwnPropertyDescriptor(n,"key").get;if(v&&v.isReactWarning)return!1}return n.key!==void 0}function Fe(n,v){typeof n.ref=="string"&&Qe.current}function lt(n,v){{var I=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)",v))};I.isReactWarning=!0,Object.defineProperty(n,"key",{get:I,configurable:!0})}}function Ee(n,v){{var I=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)",v))};I.isReactWarning=!0,Object.defineProperty(n,"ref",{get:I,configurable:!0})}}var pe=function(n,v,I,L,V,H,K){var q={$$typeof:e,type:n,key:v,ref:I,props:K,_owner:H};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:L}),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,v,I,L,V){{var H,K={},q=null,ae=null;I!==void 0&&($e(I),q=""+I),Se(v)&&($e(v.key),q=""+v.key),_e(v)&&(ae=v.ref,Fe(v,V));for(H in v)Ue.call(v,H)&&!Ce.hasOwnProperty(H)&&(K[H]=v[H]);if(n&&n.defaultProps){var X=n.defaultProps;for(H in X)K[H]===void 0&&(K[H]=X[H])}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,L,Qe.current,K)}}var Oe=k.ReactCurrentOwner,Qt=k.ReactDebugCurrentFrame;function We(n){if(n){var v=n._owner,I=st(n.type,n._source,v?v.type:null);Qt.setExtraStackFrame(I)}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=B(Oe.current.type);if(n)return`
22
22
 
23
- Check the render method of \``+n+"`."}return""}}function Wt(n){return""}var Re={};function hr(n){{var b=Ke();if(!b){var O=typeof n=="string"?n:n.displayName||n.name;O&&(b=`
23
+ Check the render method of \``+n+"`."}return""}}function Wt(n){return""}var je={};function dr(n){{var v=Ke();if(!v){var I=typeof n=="string"?n:n.displayName||n.name;I&&(v=`
24
24
 
25
- Check the top-level render call using <`+O+">.")}return b}}function te(n,b){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var O=hr(b);if(Re[O])return;Re[O]=!0;var A="";n&&n._owner&&n._owner!==je.current&&(A=" It was passed a child from "+U(n._owner.type)+"."),We(n),g('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',O,A),We(null)}}function Kt(n,b){{if(typeof n!="object")return;if(nt(n))for(var O=0;O<n.length;O++){var A=n[O];me(A)&&te(A,b)}else if(me(n))n._store&&(n._store.validated=!0);else if(n){var K=S(n);if(typeof K=="function"&&K!==n.entries)for(var z=K.call(n),W;!(W=z.next()).done;)me(W.value)&&te(W.value,b)}}}function Vt(n){{var b=n.type;if(b==null||typeof b=="string")return;var O;if(typeof b=="function")O=b.propTypes;else if(typeof b=="object"&&(b.$$typeof===c||b.$$typeof===l))O=b.propTypes;else return;if(O){var A=U(b);fe(O,n.props,"prop",A,n)}else if(b.PropTypes!==void 0&&!Tt){Tt=!0;var K=U(b);g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",K||"Unknown")}typeof b.getDefaultProps=="function"&&!b.getDefaultProps.isReactClassApproved&&g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ht(n){{for(var b=Object.keys(n.props),O=0;O<b.length;O++){var A=b[O];if(A!=="children"&&A!=="key"){We(n),g("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),g("Invalid attribute `ref` supplied to `React.Fragment`."),We(null))}}var _t={};function Ht(n,b,O,A,K,z){{var W=_(n);if(!W){var B="";(n===void 0||typeof n=="object"&&n!==null&&Object.keys(n).length===0)&&(B+=" 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 ie=Wt();ie?B+=ie:B+=Ke();var J;n===null?J="null":nt(n)?J="array":n!==void 0&&n.$$typeof===e?(J="<"+(U(n.type)||"Unknown")+" />",B=" Did you accidentally export a JSX literal instead of a component?"):J=typeof n,g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",J,B)}var X=Se(n,b,O,K,z);if(X==null)return X;if(W){var ge=b.children;if(ge!==void 0)if(A)if(nt(ge)){for(var Ot=0;Ot<ge.length;Ot++)Kt(ge[Ot],n);Object.freeze&&Object.freeze(ge)}else g("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(b,"key")){var dt=U(n),ce=Object.keys(b).filter(function(Ks){return Ks!=="key"}),vr=ce.length>0?"{key: someKey, "+ce.join(": ..., ")+": ...}":"{key: someKey}";if(!_t[dt+vr]){var Ws=ce.length>0?"{"+ce.join(": ..., ")+": ...}":"{}";g(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+I+">.")}return v}}function te(n,v){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var I=dr(v);if(je[I])return;je[I]=!0;var L="";n&&n._owner&&n._owner!==Oe.current&&(L=" It was passed a child from "+B(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.',I,L),We(null)}}function Kt(n,v){{if(typeof n!="object")return;if(nt(n))for(var I=0;I<n.length;I++){var L=n[I];me(L)&&te(L,v)}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 H=V.call(n),K;!(K=H.next()).done;)me(K.value)&&te(K.value,v)}}}function Vt(n){{var v=n.type;if(v==null||typeof v=="string")return;var I;if(typeof v=="function")I=v.propTypes;else if(typeof v=="object"&&(v.$$typeof===l||v.$$typeof===h))I=v.propTypes;else return;if(I){var L=B(v);fe(I,n.props,"prop",L,n)}else if(v.PropTypes!==void 0&&!jt){jt=!0;var V=B(v);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",V||"Unknown")}typeof v.getDefaultProps=="function"&&!v.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function dt(n){{for(var v=Object.keys(n.props),I=0;I<v.length;I++){var L=v[I];if(L!=="children"&&L!=="key"){We(n),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",L),We(null);break}}n.ref!==null&&(We(n),b("Invalid attribute `ref` supplied to `React.Fragment`."),We(null))}}var Tt={};function zt(n,v,I,L,V,H){{var K=E(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="<"+(B(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,v,I,V,H);if(Z==null)return Z;if(K){var ge=v.children;if(ge!==void 0)if(L)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(v,"key")){var ht=B(n),ce=Object.keys(v).filter(function(zs){return zs!=="key"}),vr=ce.length>0?"{key: someKey, "+ce.join(": ..., ")+": ...}":"{key: someKey}";if(!Tt[ht+vr]){var Vs=ce.length>0?"{"+ce.join(": ..., ")+": ...}":"{}";b(`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,dt,Ws,dt),_t[dt+vr]=!0}}return n===s?ht(X):Vt(X),X}}function yr(n,b,O){return Ht(n,b,O,!0)}function qs(n,b,O){return Ht(n,b,O,!1)}var Qs=qs,$s=yr;Gt.Fragment=s,Gt.jsx=Qs,Gt.jsxs=$s}()),Gt}process.env.NODE_ENV==="production"?wr.exports=Gs():wr.exports=Ys();var h=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(){}},Js={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},ke,pt,is,Xs=(is=class{constructor(){F(this,ke,Js);F(this,pt,!1)}setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&i(this,pt)&&t!==i(this,ke)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:i(this,ke),provider:t}),R(this,ke,t),process.env.NODE_ENV!=="production"&&R(this,pt,!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&R(this,pt,!0),i(this,ke).setTimeout(t,e)}clearTimeout(t){i(this,ke).clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&R(this,pt,!0),i(this,ke).setInterval(t,e)}clearInterval(t){i(this,ke).clearInterval(t)}},ke=new WeakMap,pt=new WeakMap,is),ft=new Xs;function Zs(t){setTimeout(t,0)}var St=typeof window>"u"||"Deno"in globalThis;function he(){}function en(t,e){return typeof t=="function"?t(e):t}function Cr(t){return typeof t=="number"&&t>=0&&t!==1/0}function ms(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 Kr(t,e){const{type:r="all",exact:s,fetchStatus:a,predicate:o,queryKey:u,stale:p}=t;if(u){if(s){if(e.queryHash!==Dr(u,e.options))return!1}else if(!Xt(e.queryKey,u))return!1}if(r!=="all"){const c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof p=="boolean"&&e.isStale()!==p||a&&a!==e.state.fetchStatus||o&&!o(e))}function Vr(t,e){const{exact:r,status:s,predicate:a,mutationKey:o}=t;if(o){if(!e.options.mutationKey)return!1;if(r){if(Jt(e.options.mutationKey)!==Jt(o))return!1}else if(!Xt(e.options.mutationKey,o))return!1}return!(s&&e.state.status!==s||a&&!a(e))}function Dr(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 tn=Object.prototype.hasOwnProperty;function Er(t,e){if(t===e)return t;const r=Hr(t)&&Hr(e);if(!r&&!(Rr(t)&&Rr(e)))return e;const a=(r?t:Object.keys(t)).length,o=r?e:Object.keys(e),u=o.length,p=r?new Array(u):{};let c=0;for(let w=0;w<u;w++){const m=r?w:o[w],l=t[m],v=e[m];if(l===v){p[m]=l,(r?w<a:tn.call(t,m))&&c++;continue}if(l===null||v===null||typeof l!="object"||typeof v!="object"){p[m]=v;continue}const E=Er(l,v);p[m]=E,E===l&&c++}return a===u&&c===a?t:p}function Sr(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 Hr(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Rr(t){if(!zr(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!zr(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function zr(t){return Object.prototype.toString.call(t)==="[object Object]"}function rn(t){return new Promise(e=>{ft.setTimeout(e,t)})}function Tr(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 Er(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 Er(t,e)}return e}function sn(t,e,r=0){const s=[...t,e];return r&&s.length>r?s.slice(1):s}function nn(t,e,r=0){const s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}var pr=Symbol();function gs(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 an(t,e){return typeof t=="function"?t(...e):!!t}function on(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,jt,as,un=(as=class extends ir{constructor(){super();F(this,mt);F(this,He);F(this,jt);R(this,jt,e=>{if(!St&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){i(this,He)||this.setEventListener(i(this,jt))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,He))==null||e.call(this),R(this,He,void 0))}setEventListener(e){var r;R(this,jt,e),(r=i(this,He))==null||r.call(this),R(this,He,e(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(e){i(this,mt)!==e&&(R(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,jt=new WeakMap,as),Lr=new un;function _r(){let t,e;const r=new Promise((a,o)=>{t=a,e=o});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 cn=Zs;function ln(){let t=[],e=0,r=p=>{p()},s=p=>{p()},a=cn;const o=p=>{e?t.push(p):a(()=>{r(p)})},u=()=>{const p=t;t=[],p.length&&a(()=>{s(()=>{p.forEach(c=>{r(c)})})})};return{batch:p=>{let c;e++;try{c=p()}finally{e--,e||u()}return c},batchCalls:p=>(...c)=>{o(()=>{p(...c)})},schedule:o,setNotifyFunction:p=>{r=p},setBatchNotifyFunction:p=>{s=p},setScheduler:p=>{a=p}}}var se=ln(),kt,ze,Pt,os,hn=(os=class extends ir{constructor(){super();F(this,kt,!0);F(this,ze);F(this,Pt);R(this,Pt,e=>{if(!St&&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),R(this,ze,void 0))}setEventListener(e){var r;R(this,Pt,e),(r=i(this,ze))==null||r.call(this),R(this,ze,e(this.setOnline.bind(this)))}setOnline(e){i(this,kt)!==e&&(R(this,kt,e),this.listeners.forEach(s=>{s(e)}))}isOnline(){return i(this,kt)}},kt=new WeakMap,ze=new WeakMap,Pt=new WeakMap,os),mr=new hn;function dn(t){return Math.min(1e3*2**t,3e4)}function bs(t){return(t??"online")==="online"?mr.isOnline():!0}var Or=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function ys(t){let e=!1,r=0,s;const a=_r(),o=()=>a.status!=="pending",u=T=>{var S;if(!o()){const j=new Or(T);v(j),(S=t.onCancel)==null||S.call(t,j)}},p=()=>{e=!0},c=()=>{e=!1},w=()=>Lr.isFocused()&&(t.networkMode==="always"||mr.isOnline())&&t.canRun(),m=()=>bs(t.networkMode)&&t.canRun(),l=T=>{o()||(s==null||s(),a.resolve(T))},v=T=>{o()||(s==null||s(),a.reject(T))},E=()=>new Promise(T=>{var S;s=j=>{(o()||w())&&T(j)},(S=t.onPause)==null||S.call(t)}).then(()=>{var T;s=void 0,o()||(T=t.onContinue)==null||T.call(t)}),P=()=>{if(o())return;let T;const S=r===0?t.initialPromise:void 0;try{T=S??t.fn()}catch(j){T=Promise.reject(j)}Promise.resolve(T).then(l).catch(j=>{var x;if(o())return;const g=t.retry??(St?0:3),C=t.retryDelay??dn,d=typeof C=="function"?C(r,j):C,y=g===!0||typeof g=="number"&&r<g||typeof g=="function"&&g(r,j);if(e||!y){v(j);return}r++,(x=t.onFail)==null||x.call(t,r,j),rn(d).then(()=>w()?void 0:E()).then(()=>{e?v(j):P()})})};return{promise:a,status:()=>a.status,cancel:u,continue:()=>(s==null||s(),a),cancelRetry:p,continueRetry:c,canStart:m,start:()=>(m()?P():E().then(P),a)}}var gt,us,vs=(us=class{constructor(){F(this,gt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Cr(this.gcTime)&&R(this,gt,ft.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(St?1/0:5*60*1e3))}clearGcTimeout(){i(this,gt)&&(ft.clearTimeout(i(this,gt)),R(this,gt,void 0))}},gt=new WeakMap,us),bt,It,be,yt,re,Zt,vt,Te,Ae,cs,fn=(cs=class extends vs{constructor(e){super();F(this,Te);F(this,bt);F(this,It);F(this,be);F(this,yt);F(this,re);F(this,Zt);F(this,vt);R(this,vt,!1),R(this,Zt,e.defaultOptions),this.setOptions(e.options),this.observers=[],R(this,yt,e.client),R(this,be,i(this,yt).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,R(this,bt,Yr(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,re))==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=Yr(this.options);r.data!==void 0&&(this.setState(Gr(r.data,r.dataUpdatedAt)),R(this,bt,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&i(this,be).remove(this)}setData(e,r){const s=Tr(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,re))==null?void 0:s.promise;return(a=i(this,re))==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:!ms(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(s=>s.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=i(this,re))==null||r.continue()}onOnline(){var r;const e=this.observers.find(s=>s.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=i(this,re))==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,re)&&(i(this,vt)?i(this,re).cancel({revert:!0}):i(this,re).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 c,w,m,l,v,E,P,T,S,j,g,C;if(this.state.fetchStatus!=="idle"&&((c=i(this,re))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(i(this,re))return i(this,re).continueRetry(),i(this,re).promise}if(e&&this.setOptions(e),!this.options.queryFn){const d=this.observers.find(y=>y.options.queryFn);d&&this.setOptions(d.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=d=>{Object.defineProperty(d,"signal",{enumerable:!0,get:()=>(R(this,vt,!0),s.signal)})},o=()=>{const d=gs(this.options,r),x=(()=>{const I={client:i(this,yt),queryKey:this.queryKey,meta:this.meta};return a(I),I})();return R(this,vt,!1),this.options.persister?this.options.persister(d,x,this):d(x)},p=(()=>{const d={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:i(this,yt),state:this.state,fetchFn:o};return a(d),d})();(w=this.options.behavior)==null||w.onFetch(p,this),R(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:(l=p.fetchOptions)==null?void 0:l.meta}),R(this,re,ys({initialPromise:r==null?void 0:r.initialPromise,fn:p.fetchFn,onCancel:d=>{d instanceof Or&&d.revert&&this.setState({...i(this,It),fetchStatus:"idle"}),s.abort()},onFail:(d,y)=>{Q(this,Te,Ae).call(this,{type:"failed",failureCount:d,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 d=await i(this,re).start();if(d===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(d),(E=(v=i(this,be).config).onSuccess)==null||E.call(v,d,this),(T=(P=i(this,be).config).onSettled)==null||T.call(P,d,this.state.error,this),d}catch(d){if(d instanceof Or){if(d.silent)return i(this,re).promise;if(d.revert){if(this.state.data===void 0)throw d;return this.state.data}}throw Q(this,Te,Ae).call(this,{type:"error",error:d}),(j=(S=i(this,be).config).onError)==null||j.call(S,d,this),(C=(g=i(this,be).config).onSettled)==null||C.call(g,this.state.data,d,this),d}finally{this.scheduleGc()}}},bt=new WeakMap,It=new WeakMap,be=new WeakMap,yt=new WeakMap,re=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,...xs(s.data,this.options),fetchMeta:e.meta??null};case"success":const a={...s,...Gr(e.data,e.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return R(this,It,e.manual?a:void 0),a;case"error":const o=e.error;return{...s,error:o,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=r(this.state),se.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),i(this,be).notify({query:this,type:"updated",action:e})})},cs);function xs(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:bs(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Gr(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Yr(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 le,$,er,ae,xt,Nt,De,Ge,tr,Ft,Mt,wt,Ct,Ye,At,V,Yt,jr,kr,Pr,Ir,Nr,Fr,Mr,ws,ls,pn=(ls=class extends ir{constructor(e,r){super();F(this,V);F(this,le);F(this,$);F(this,er);F(this,ae);F(this,xt);F(this,Nt);F(this,De);F(this,Ge);F(this,tr);F(this,Ft);F(this,Mt);F(this,wt);F(this,Ct);F(this,Ye);F(this,At,new Set);this.options=r,R(this,le,e),R(this,Ge,null),R(this,De,_r()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,$).addObserver(this),Jr(i(this,$),this.options)?Q(this,V,Yt).call(this):this.updateResult(),Q(this,V,Ir).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ar(i(this,$),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ar(i(this,$),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Q(this,V,Nr).call(this),Q(this,V,Fr).call(this),i(this,$).removeObserver(this)}setOptions(e){const r=this.options,s=i(this,$);if(this.options=i(this,le).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ye(this.options.enabled,i(this,$))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Q(this,V,Mr).call(this),i(this,$).setOptions(this.options),r._defaulted&&!Sr(this.options,r)&&i(this,le).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,$),observer:this});const a=this.hasListeners();a&&Xr(i(this,$),s,this.options,r)&&Q(this,V,Yt).call(this),this.updateResult(),a&&(i(this,$)!==s||ye(this.options.enabled,i(this,$))!==ye(r.enabled,i(this,$))||et(this.options.staleTime,i(this,$))!==et(r.staleTime,i(this,$)))&&Q(this,V,jr).call(this);const o=Q(this,V,kr).call(this);a&&(i(this,$)!==s||ye(this.options.enabled,i(this,$))!==ye(r.enabled,i(this,$))||o!==i(this,Ye))&&Q(this,V,Pr).call(this,o)}getOptimisticResult(e){const r=i(this,le).getQueryCache().build(i(this,le),e),s=this.createResult(r,e);return gn(this,s)&&(R(this,ae,s),R(this,Nt,this.options),R(this,xt,i(this,$).state)),s}getCurrentResult(){return i(this,ae)}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,De).status==="pending"&&i(this,De).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,$)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=i(this,le).defaultQueryOptions(e),s=i(this,le).getQueryCache().build(i(this,le),r);return s.fetch().then(()=>this.createResult(s,r))}fetch(e){return Q(this,V,Yt).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,ae)))}createResult(e,r){var M;const s=i(this,$),a=this.options,o=i(this,ae),u=i(this,xt),p=i(this,Nt),w=e!==s?e.state:i(this,er),{state:m}=e;let l={...m},v=!1,E;if(r._optimisticResults){const _=this.hasListeners(),k=!_&&Jr(e,r),L=_&&Xr(e,s,r,a);(k||L)&&(l={...l,...xs(m.data,e.options)}),r._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:P,errorUpdatedAt:T,status:S}=l;E=l.data;let j=!1;if(r.placeholderData!==void 0&&E===void 0&&S==="pending"){let _;o!=null&&o.isPlaceholderData&&r.placeholderData===(p==null?void 0:p.placeholderData)?(_=o.data,j=!0):_=typeof r.placeholderData=="function"?r.placeholderData((M=i(this,Mt))==null?void 0:M.state.data,i(this,Mt)):r.placeholderData,_!==void 0&&(S="success",E=Tr(o==null?void 0:o.data,_,r),v=!0)}if(r.select&&E!==void 0&&!j)if(o&&E===(u==null?void 0:u.data)&&r.select===i(this,tr))E=i(this,Ft);else try{R(this,tr,r.select),E=r.select(E),E=Tr(o==null?void 0:o.data,E,r),R(this,Ft,E),R(this,Ge,null)}catch(_){R(this,Ge,_)}i(this,Ge)&&(P=i(this,Ge),E=i(this,Ft),T=Date.now(),S="error");const g=l.fetchStatus==="fetching",C=S==="pending",d=S==="error",y=C&&g,x=E!==void 0,N={status:S,fetchStatus:l.fetchStatus,isPending:C,isSuccess:S==="success",isError:d,isInitialLoading:y,isLoading:y,data:E,dataUpdatedAt:l.dataUpdatedAt,error:P,errorUpdatedAt:T,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>w.dataUpdateCount||l.errorUpdateCount>w.errorUpdateCount,isFetching:g,isRefetching:g&&!C,isLoadingError:d&&!x,isPaused:l.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:d&&x,isStale:Br(e,r),refetch:this.refetch,promise:i(this,De),isEnabled:ye(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const _=U=>{N.status==="error"?U.reject(N.error):N.data!==void 0&&U.resolve(N.data)},k=()=>{const U=R(this,De,N.promise=_r());_(U)},L=i(this,De);switch(L.status){case"pending":e.queryHash===s.queryHash&&_(L);break;case"fulfilled":(N.status==="error"||N.data!==L.value)&&k();break;case"rejected":(N.status!=="error"||N.error!==L.reason)&&k();break}}return N}updateResult(){const e=i(this,ae),r=this.createResult(i(this,$),this.options);if(R(this,xt,i(this,$).state),R(this,Nt,this.options),i(this,xt).data!==void 0&&R(this,Mt,i(this,$)),Sr(r,e))return;R(this,ae,r);const s=()=>{if(!e)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!i(this,At).size)return!0;const u=new Set(o??i(this,At));return this.options.throwOnError&&u.add("error"),Object.keys(i(this,ae)).some(p=>{const c=p;return i(this,ae)[c]!==e[c]&&u.has(c)})};Q(this,V,ws).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Q(this,V,Ir).call(this)}},le=new WeakMap,$=new WeakMap,er=new WeakMap,ae=new WeakMap,xt=new WeakMap,Nt=new WeakMap,De=new WeakMap,Ge=new WeakMap,tr=new WeakMap,Ft=new WeakMap,Mt=new WeakMap,wt=new WeakMap,Ct=new WeakMap,Ye=new WeakMap,At=new WeakMap,V=new WeakSet,Yt=function(e){Q(this,V,Mr).call(this);let r=i(this,$).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(he)),r},jr=function(){Q(this,V,Nr).call(this);const e=et(this.options.staleTime,i(this,$));if(St||i(this,ae).isStale||!Cr(e))return;const s=ms(i(this,ae).dataUpdatedAt,e)+1;R(this,wt,ft.setTimeout(()=>{i(this,ae).isStale||this.updateResult()},s))},kr=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,$)):this.options.refetchInterval)??!1},Pr=function(e){Q(this,V,Fr).call(this),R(this,Ye,e),!(St||ye(this.options.enabled,i(this,$))===!1||!Cr(i(this,Ye))||i(this,Ye)===0)&&R(this,Ct,ft.setInterval(()=>{(this.options.refetchIntervalInBackground||Lr.isFocused())&&Q(this,V,Yt).call(this)},i(this,Ye)))},Ir=function(){Q(this,V,jr).call(this),Q(this,V,Pr).call(this,Q(this,V,kr).call(this))},Nr=function(){i(this,wt)&&(ft.clearTimeout(i(this,wt)),R(this,wt,void 0))},Fr=function(){i(this,Ct)&&(ft.clearInterval(i(this,Ct)),R(this,Ct,void 0))},Mr=function(){const e=i(this,le).getQueryCache().build(i(this,le),this.options);if(e===i(this,$))return;const r=i(this,$);R(this,$,e),R(this,er,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},ws=function(e){se.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(i(this,ae))}),i(this,le).getQueryCache().notify({query:i(this,$),type:"observerResultsUpdated"})})},ls);function mn(t,e){return ye(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Jr(t,e){return mn(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 Xr(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 gn(t,e){return!Sr(t.getCurrentResult(),e)}function Zr(t){return{onFetch:(e,r)=>{var m,l,v,E,P;const s=e.options,a=(v=(l=(m=e.fetchOptions)==null?void 0:m.meta)==null?void 0:l.fetchMore)==null?void 0:v.direction,o=((E=e.state.data)==null?void 0:E.pages)||[],u=((P=e.state.data)==null?void 0:P.pageParams)||[];let p={pages:[],pageParams:[]},c=0;const w=async()=>{let T=!1;const S=C=>{on(C,()=>e.signal,()=>T=!0)},j=gs(e.options,e.fetchOptions),g=async(C,d,y)=>{if(T)return Promise.reject();if(d==null&&C.pages.length)return Promise.resolve(C);const I=(()=>{const k={client:e.client,queryKey:e.queryKey,pageParam:d,direction:y?"backward":"forward",meta:e.options.meta};return S(k),k})(),N=await j(I),{maxPages:M}=e.options,_=y?nn:sn;return{pages:_(C.pages,N,M),pageParams:_(C.pageParams,d,M)}};if(a&&o.length){const C=a==="backward",d=C?bn:es,y={pages:o,pageParams:u},x=d(s,y);p=await g(y,x,C)}else{const C=t??o.length;do{const d=c===0?u[0]??s.initialPageParam:es(s,p);if(c>0&&d==null)break;p=await g(p,d),c++}while(c<C)}return p};e.options.persister?e.fetchFn=()=>{var T,S;return(S=(T=e.options).persister)==null?void 0:S.call(T,w,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=w}}}function es(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 bn(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,Pe,oe,Et,Ie,Ve,hs,yn=(hs=class extends vs{constructor(e){super();F(this,Ie);F(this,rr);F(this,Pe);F(this,oe);F(this,Et);R(this,rr,e.client),this.mutationId=e.mutationId,R(this,oe,e.mutationCache),R(this,Pe,[]),this.state=e.state||vn(),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,Pe).includes(e)||(i(this,Pe).push(e),this.clearGcTimeout(),i(this,oe).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){R(this,Pe,i(this,Pe).filter(r=>r!==e)),this.scheduleGc(),i(this,oe).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){i(this,Pe).length||(this.state.status==="pending"?this.scheduleGc():i(this,oe).remove(this))}continue(){var e;return((e=i(this,Et))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var u,p,c,w,m,l,v,E,P,T,S,j,g,C,d,y,x,I,N,M;const r=()=>{Q(this,Ie,Ve).call(this,{type:"continue"})},s={client:i(this,rr),meta:this.options.meta,mutationKey:this.options.mutationKey};R(this,Et,ys({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(_,k)=>{Q(this,Ie,Ve).call(this,{type:"failed",failureCount:_,error:k})},onPause:()=>{Q(this,Ie,Ve).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>i(this,oe).canRun(this)}));const a=this.state.status==="pending",o=!i(this,Et).canStart();try{if(a)r();else{Q(this,Ie,Ve).call(this,{type:"pending",variables:e,isPaused:o}),await((p=(u=i(this,oe).config).onMutate)==null?void 0:p.call(u,e,this,s));const k=await((w=(c=this.options).onMutate)==null?void 0:w.call(c,e,s));k!==this.state.context&&Q(this,Ie,Ve).call(this,{type:"pending",context:k,variables:e,isPaused:o})}const _=await i(this,Et).start();return await((l=(m=i(this,oe).config).onSuccess)==null?void 0:l.call(m,_,e,this.state.context,this,s)),await((E=(v=this.options).onSuccess)==null?void 0:E.call(v,_,e,this.state.context,s)),await((T=(P=i(this,oe).config).onSettled)==null?void 0:T.call(P,_,null,this.state.variables,this.state.context,this,s)),await((j=(S=this.options).onSettled)==null?void 0:j.call(S,_,null,e,this.state.context,s)),Q(this,Ie,Ve).call(this,{type:"success",data:_}),_}catch(_){try{throw await((C=(g=i(this,oe).config).onError)==null?void 0:C.call(g,_,e,this.state.context,this,s)),await((y=(d=this.options).onError)==null?void 0:y.call(d,_,e,this.state.context,s)),await((I=(x=i(this,oe).config).onSettled)==null?void 0:I.call(x,void 0,_,this.state.variables,this.state.context,this,s)),await((M=(N=this.options).onSettled)==null?void 0:M.call(N,void 0,_,e,this.state.context,s)),_}finally{Q(this,Ie,Ve).call(this,{type:"error",error:_})}}finally{i(this,oe).runNext(this)}}},rr=new WeakMap,Pe=new WeakMap,oe=new WeakMap,Et=new WeakMap,Ie=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),se.batch(()=>{i(this,Pe).forEach(s=>{s.onMutationUpdate(e)}),i(this,oe).notify({mutation:this,type:"updated",action:e})})},hs);function vn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Le,_e,sr,ds,xn=(ds=class extends ir{constructor(e={}){super();F(this,Le);F(this,_e);F(this,sr);this.config=e,R(this,Le,new Set),R(this,_e,new Map),R(this,sr,0)}build(e,r,s){const a=new yn({client:e,mutationCache:this,mutationId:++dr(this,sr)._,options:e.defaultMutationOptions(r),state:s});return this.add(a),a}add(e){i(this,Le).add(e);const r=fr(e);if(typeof r=="string"){const s=i(this,_e).get(r);s?s.push(e):i(this,_e).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(i(this,Le).delete(e)){const r=fr(e);if(typeof r=="string"){const s=i(this,_e).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,_e).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=fr(e);if(typeof r=="string"){const s=i(this,_e).get(r),a=s==null?void 0:s.find(o=>o.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,_e).get(r))==null?void 0:s.find(o=>o!==e&&o.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){se.batch(()=>{i(this,Le).forEach(e=>{this.notify({type:"removed",mutation:e})}),i(this,Le).clear(),i(this,_e).clear()})}getAll(){return Array.from(i(this,Le))}find(e){const r={exact:!0,...e};return this.getAll().find(s=>Vr(r,s))}findAll(e={}){return this.getAll().filter(r=>Vr(e,r))}notify(e){se.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return se.batch(()=>Promise.all(e.map(r=>r.continue().catch(he))))}},Le=new WeakMap,_e=new WeakMap,sr=new WeakMap,ds);function fr(t){var e;return(e=t.options.scope)==null?void 0:e.id}var Ne,fs,wn=(fs=class extends ir{constructor(e={}){super();F(this,Ne);this.config=e,R(this,Ne,new Map)}build(e,r,s){const a=r.queryKey,o=r.queryHash??Dr(a,r);let u=this.get(o);return u||(u=new fn({client:e,queryKey:a,queryHash:o,options:e.defaultQueryOptions(r),state:s,defaultOptions:e.getQueryDefaults(a)}),this.add(u)),u}add(e){i(this,Ne).has(e.queryHash)||(i(this,Ne).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=i(this,Ne).get(e.queryHash);r&&(e.destroy(),r===e&&i(this,Ne).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){se.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return i(this,Ne).get(e)}getAll(){return[...i(this,Ne).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(s=>Kr(r,s))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(s=>Kr(e,s)):r}notify(e){se.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){se.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){se.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Ne=new WeakMap,fs),G,Je,Xe,Dt,Lt,Ze,Bt,Ut,ps,Cn=(ps=class{constructor(t={}){F(this,G);F(this,Je);F(this,Xe);F(this,Dt);F(this,Lt);F(this,Ze);F(this,Bt);F(this,Ut);R(this,G,t.queryCache||new wn),R(this,Je,t.mutationCache||new xn),R(this,Xe,t.defaultOptions||{}),R(this,Dt,new Map),R(this,Lt,new Map),R(this,Ze,0)}mount(){dr(this,Ze)._++,i(this,Ze)===1&&(R(this,Bt,Lr.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,G).onFocus())})),R(this,Ut,mr.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,G).onOnline())})))}unmount(){var t,e;dr(this,Ze)._--,i(this,Ze)===0&&((t=i(this,Bt))==null||t.call(this),R(this,Bt,void 0),(e=i(this,Ut))==null||e.call(this),R(this,Ut,void 0))}isFetching(t){return i(this,G).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,G).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=i(this,G).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,G).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,G).get(s.queryHash),o=a==null?void 0:a.state.data,u=en(e,o);if(u!==void 0)return i(this,G).build(this,s).setData(u,{...r,manual:!0})}setQueriesData(t,e,r){return se.batch(()=>i(this,G).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,G).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=i(this,G);se.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=i(this,G);return se.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},s=se.batch(()=>i(this,G).findAll(t).map(a=>a.cancel(r)));return Promise.all(s).then(he).catch(he)}invalidateQueries(t,e={}){return se.batch(()=>(i(this,G).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=se.batch(()=>i(this,G).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(he)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(s).then(he)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=i(this,G).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=Zr(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(he).catch(he)}ensureInfiniteQueryData(t){return t.behavior=Zr(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return mr.isOnline()?i(this,Je).resumePausedMutations():Promise.resolve()}getQueryCache(){return i(this,G)}getMutationCache(){return i(this,Je)}getDefaultOptions(){return i(this,Xe)}setDefaultOptions(t){R(this,Xe,t)}setQueryDefaults(t,e){i(this,Dt).set(Jt(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...i(this,Dt).values()],r={};return e.forEach(s=>{Xt(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){i(this,Lt).set(Jt(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...i(this,Lt).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=Dr(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,G).clear(),i(this,Je).clear()}},G=new WeakMap,Je=new WeakMap,Xe=new WeakMap,Dt=new WeakMap,Lt=new WeakMap,Ze=new WeakMap,Bt=new WeakMap,Ut=new WeakMap,ps),Cs=ve.createContext(void 0),Es=t=>{const e=ve.useContext(Cs);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},En=({client:t,children:e})=>(ve.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),h.jsx(Cs.Provider,{value:t,children:e})),Ss=ve.createContext(!1),Sn=()=>ve.useContext(Ss);Ss.Provider;function Rn(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Tn=ve.createContext(Rn()),_n=()=>ve.useContext(Tn),On=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},jn=t=>{ve.useEffect(()=>{t.clearReset()},[t])},kn=({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:a})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(a&&t.data===void 0||an(r,[t.error,s])),Pn=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))}},In=(t,e)=>t.isLoading&&t.isFetching&&!e,Nn=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,ts=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function Fn(t,e,r){var l,v,E,P,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=Sn(),a=_n(),o=Es(),u=o.defaultQueryOptions(t);(v=(l=o.getDefaultOptions().queries)==null?void 0:l._experimental_beforeQuery)==null||v.call(l,u),process.env.NODE_ENV!=="production"&&(u.queryFn||console.error(`[${u.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`)),u._optimisticResults=s?"isRestoring":"optimistic",Pn(u),On(u,a),jn(a);const p=!o.getQueryCache().get(u.queryHash),[c]=ve.useState(()=>new e(o,u)),w=c.getOptimisticResult(u),m=!s&&t.subscribed!==!1;if(ve.useSyncExternalStore(ve.useCallback(S=>{const j=m?c.subscribe(se.batchCalls(S)):he;return c.updateResult(),j},[c,m]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),ve.useEffect(()=>{c.setOptions(u)},[u,c]),Nn(u,w))throw ts(u,c,a);if(kn({result:w,errorResetBoundary:a,throwOnError:u.throwOnError,query:o.getQueryCache().get(u.queryHash),suspense:u.suspense}))throw w.error;if((P=(E=o.getDefaultOptions().queries)==null?void 0:E._experimental_afterQuery)==null||P.call(E,u,w),u.experimental_prefetchInRender&&!St&&In(w,s)){const S=p?ts(u,c,a):(T=o.getQueryCache().get(u.queryHash))==null?void 0:T.promise;S==null||S.catch(he).finally(()=>{c.updateResult()})}return u.notifyOnChangeProps?w:c.trackResult(w)}function Rs(t,e){return Fn(t,pn)}const Ts=f.createContext(null);function _s({children:t,bobConfig:e,hostApiConfig:r,hostContext:s={},callbacks:a={},queryClient:o}){const u=f.useMemo(()=>new Cn({defaultOptions:{queries:{retry:1,staleTime:3e5}}}),[]),p=o||u,c=!!o;f.useEffect(()=>{console.log(`[BobWidget] v${nr} initialized`),console.log(`[BobWidget] QueryClient: ${c?"external (shared)":"internal"}`)},[c]);const w=f.useMemo(()=>Vs.createClient(e.supabaseUrl,e.supabaseKey),[e.supabaseUrl,e.supabaseKey]),[m,l]=f.useState(s);f.useEffect(()=>{l(s)},[s]);const v=f.useCallback(P=>{l(T=>({...T,...P}))},[]),E=f.useMemo(()=>({bobSupabase:w,bobConfig:e,hostApiConfig:r,hostContext:m,callbacks:a,updateHostContext:v}),[w,e,r,m,a,v]);return h.jsx(En,{client:p,children:h.jsx(Ts.Provider,{value:E,children:t})})}function tt(){const t=f.useContext(Ts);if(!t)throw new Error("useBobContext must be used within a BobProvider");return t}function Ur(){const{bobSupabase:t}=tt();return t}function Mn(){const{hostContext:t}=tt();return t}function An(){const{hostApiConfig:t}=tt();return t}function Dn(){const{callbacks:t}=tt();return t}const rs=5e3,Os=({onStart:t,onEnd:e,onFailed:r}={})=>{const{bobConfig:s}=tt(),[a,o]=f.useState(!1),u=f.useRef(null),p=f.useRef(null),c=f.useRef(!1),w=f.useRef(t),m=f.useRef(e),l=f.useRef(r);f.useEffect(()=>{w.current=t,m.current=e,l.current=r},[t,e,r]);const v=f.useCallback(()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]),E=f.useCallback(()=>{var g;c.current||(c.current=!0,console.log("[BobWidget TTS] Fallback: triggering onStart without audio"),(g=w.current)==null||g.call(w))},[]),P=f.useCallback(async g=>{var C,d,y,x;if(g.trim()){c.current=!1,v(),u.current&&(u.current.pause(),u.current=null),p.current=setTimeout(()=>{var I,N;console.warn("[BobWidget TTS] Timeout after 5s - triggering fallback callbacks"),E(),o(!1),(I=m.current)==null||I.call(m),(N=l.current)==null||N.call(l),u.current=null},rs);try{const I=new AbortController,N=setTimeout(()=>I.abort(),rs-1e3),M=await fetch(`${s.supabaseUrl}/functions/v1/bob-tts`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.supabaseKey}`},body:JSON.stringify({text:g}),signal:I.signal});if(clearTimeout(N),!M.ok){const L=await M.json().catch(()=>({}));throw console.error("[BobWidget TTS] Request failed:",L),new Error("TTS request failed")}const{audioContent:_}=await M.json(),k=new Audio(`data:audio/mp3;base64,${_}`);u.current=k,k.onplay=()=>{var L;v(),c.current||(c.current=!0,o(!0),console.log("[BobWidget TTS] Audio playing, triggering onStart"),(L=w.current)==null||L.call(w))},k.onended=()=>{var L;v(),o(!1),(L=m.current)==null||L.call(m),u.current=null},k.onerror=L=>{var U,D;v(),console.warn("[BobWidget TTS] Audio playback error:",L),E(),o(!1),(U=m.current)==null||U.call(m),(D=l.current)==null||D.call(l),u.current=null};try{await k.play()}catch(L){console.warn("[BobWidget TTS] Audio play() failed (likely autoplay policy):",L),v(),E(),o(!1),(C=m.current)==null||C.call(m),(d=l.current)==null||d.call(l),u.current=null}}catch(I){v(),console.error("[BobWidget TTS] Speech synthesis error:",I),E(),o(!1),(y=m.current)==null||y.call(m),(x=l.current)==null||x.call(l)}}},[s.supabaseUrl,s.supabaseKey,v,E]),T=f.useCallback(()=>{v(),u.current&&(u.current.pause(),u.current=null),o(!1)},[v]),S=f.useCallback(()=>{var g;(g=u.current)==null||g.pause()},[]),j=f.useCallback(()=>{var g;(g=u.current)==null||g.play()},[]);return f.useEffect(()=>()=>{v(),u.current&&(u.current.pause(),u.current=null)},[v]),{speak:P,stop:T,pause:S,resume:j,isSpeaking:a,isSupported:!0}},Ln=["what version","which version","software version","bob version","your version","current version","running version","version number","what ver","which ver"],ss=["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"],Bn=["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"],js=({setAnimationState:t,manualMode:e=!1,talkingState:r="talk",thinkingState:s="research",completeState:a="complete",idleState:o="idle",listenState:u="talk_pause",onStreamStart:p,onStreamComplete:c,onShowingProduct:w,onResearchStart:m,onReadyToSpeak:l,onHighlightPart:v,onHighlightProduct:E,onNoPartsFound:P,onAutoFetchComplete:T})=>{var cr,lr,st,Ue;const{bobConfig:S,hostApiConfig:j,hostContext:g,callbacks:C}=tt(),[d,y]=f.useState([]),[x,I]=f.useState(""),[N,M]=f.useState(!1),[_,k]=f.useState(!1),[L,U]=f.useState(null),D=f.useRef(null),ee=f.useRef(!1),Fe=f.useRef(!1),H=f.useRef(""),ue=f.useRef(!1),de=f.useRef(null),Be=()=>{de.current&&(clearTimeout(de.current),de.current=null)},{speak:Y,stop:rt,isSpeaking:ar}=Os({onStart:()=>{Be(),ue.current=!0,console.log("[BobWidget] Speech started - revealing products"),l==null||l(),e||xe(r)},onEnd:()=>{Be();const q=ss.some(Z=>H.current.toLowerCase().includes(Z.toLowerCase()));e||(q&&w?w():c?c():(xe(a),setTimeout(()=>xe(u),3e3)))},onFailed:()=>{console.warn("[BobWidget] Speech synthesis failed - fallback triggered")}});f.useEffect(()=>{var q;(q=D.current)==null||q.scrollIntoView({behavior:"smooth"})},[d]),f.useEffect(()=>{var Z,ne;const q=(Z=g.vehicle)==null?void 0:Z.selectedVehicle;q&&!L&&(console.log("[BobWidget] Setting vehicle from host context:",q),U(q),(ne=C.onVehicleIdentified)==null||ne.call(C,q))},[(cr=g.vehicle)==null?void 0:cr.selectedVehicle]),f.useEffect(()=>{var q;if(d.length===0&&!Fe.current){const Z=(q=g.vehicle)==null?void 0:q.selectedVehicle;if(Z){Fe.current=!0;const ne=`${Z.year} ${Z.make} ${Z.model}`;y([{role:"assistant",content:`G'day! Saw you've got the ${ne} - choice wagon! What can I help you find for it today?`}])}else y([{role:"assistant",content:"G'day! Bob from CARFIX here. How can I help ya today?"}])}},[(lr=g.vehicle)==null?void 0:lr.selectedVehicle,d.length]),f.useEffect(()=>{var it,at;const q=(it=g.vehicle)==null?void 0:it.selectedVehicle;if(!q||ee.current)return;const Z=q.vehicle_id??q.id,ne=Number.parseInt(String(Z),10);if(!Number.isFinite(ne)){console.warn("[BobWidget] Vehicle has invalid vehicle_id, cannot auto-fetch:",q);return}ee.current=!0;const fe={...q,vehicle_id:String(ne)},qe=(at=g.user)==null?void 0:at.email;(async()=>{var Qe,$e;const ot=`${S.supabaseUrl}/functions/v1/bob-chat`;try{const we=await fetch(ot,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${S.supabaseKey}`},body:JSON.stringify({messages:[],vehicleContext:fe,customerEmail:qe,autoFetchParts:!0,hostConfig:j,hostContext:g})});if(!we.ok||!we.body){console.error("[BobWidget] Auto-fetch failed:",we.status);return}const ut=we.body.getReader(),ct=new TextDecoder;let Oe="";for(;;){const{done:Ce,value:Me}=await ut.read();if(Ce)break;Oe+=ct.decode(Me,{stream:!0});let lt;for(;(lt=Oe.indexOf(`
31
- `))!==-1;){let Ee=Oe.slice(0,lt);if(Oe=Oe.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 Se=JSON.parse(pe);Se.type==="service_packages_found"&&Se.packages&&((Qe=C.onServicePackagesFound)==null||Qe.call(C,Se.packages)),Se.type==="parts_found"&&Se.parts&&(($e=C.onPartsFound)==null||$e.call(C,Se.parts))}catch{}}}T==null||T()}catch(we){console.error("[BobWidget] Auto-fetch error:",we)}})()},[(st=g.vehicle)==null?void 0:st.selectedVehicle,(Ue=g.user)==null?void 0:Ue.email]);const xe=q=>{try{t(q)}catch{console.warn(`[BobWidget] State "${q}" not available`)}},gr=async q=>{var fe,qe,nt,it,at,ot,Qe,$e,we,ut,ct,Oe;const Z=`${S.supabaseUrl}/functions/v1/bob-chat`,ne=(fe=g.user)==null?void 0:fe.email;try{const Ce={messages:[...d,q],hostConfig:j,hostContext:g};L&&(Ce.vehicleContext=L),ne&&(Ce.customerEmail=ne);const Me=await fetch(Z,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${S.supabaseKey}`},body:JSON.stringify(Ce)});if(!Me.ok){if(Me.status===429){(qe=C.onError)==null||qe.call(C,new Error("Rate limit exceeded"));return}if(Me.status===402){(nt=C.onError)==null||nt.call(C,new Error("Payment required"));return}throw new Error("Failed to start stream")}if(!Me.body)throw new Error("No response body");const lt=Me.body.getReader(),Ee=new TextDecoder;let pe="",Se=!1,je="";for(;!Se;){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 Re=pe.slice(0,Wt);if(pe=pe.slice(Wt+1),Re.endsWith("\r")&&(Re=Re.slice(0,-1)),Re.startsWith(":")||Re.trim()===""||!Re.startsWith("data: "))continue;const hr=Re.slice(6).trim();if(hr==="[DONE]"){Se=!0;break}try{const te=JSON.parse(hr);if(te.type==="vehicle_identified"&&te.vehicle){U(te.vehicle),(it=C.onVehicleIdentified)==null||it.call(C,te.vehicle);continue}if(te.type==="service_packages_found"&&te.packages){(at=C.onServicePackagesFound)==null||at.call(C,te.packages);continue}if(te.type==="parts_found"&&te.parts){(ot=C.onPartsFound)==null||ot.call(C,te.parts);continue}if(te.type==="no_parts_found"){P==null||P();continue}if(te.type==="cart_updated"&&te.items){(Qe=C.onCartUpdated)==null||Qe.call(C,te.items);continue}const Kt=(ut=(we=($e=te.choices)==null?void 0:$e[0])==null?void 0:we.delta)==null?void 0:ut.content;if(Kt){je+=Kt;const Vt=je.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");y(ht=>{const _t=ht[ht.length-1];return(_t==null?void 0:_t.role)==="assistant"?ht.map((Ht,yr)=>yr===ht.length-1?{...Ht,content:Vt}:Ht):[...ht,{role:"assistant",content:Vt}]}),(ct=C.onBobMessage)==null||ct.call(C,Vt)}}catch{pe=Re+`
33
- `+pe;break}}}H.current=je.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");const $t=ss.some(me=>je.toLowerCase().includes(me.toLowerCase())),We=je.toLowerCase();for(const me of Bn)if(We.includes(me.toLowerCase())){const Ke=me.replace(/s\s*$/i,"").toUpperCase();v==null||v(Ke);break}const Tt=je.match(/(?:go with|recommend|suggest|grab|try)\s+(?:the\s+)?(\w+)\s+(?:at|for)\s+\$(\d+(?:\.\d{2})?)/i);if(Tt){const[,me,Ke]=Tt;E==null||E({brand:me,price:parseFloat(Ke)})}!_&&H.current.trim()?(ue.current=!1,Be(),Y(H.current),de.current=setTimeout(()=>{ue.current||(console.warn("[BobWidget] Speech fallback after 2s"),l==null||l(),e||($t&&w?w():c?c():(xe(a),setTimeout(()=>xe(u),3e3))))},2e3)):(l==null||l(),e||($t&&w?w():c?c():(xe(a),setTimeout(()=>xe(u),3e3))))}catch(Ce){console.error("[BobWidget] Chat error:",Ce),(Oe=C.onError)==null||Oe.call(C,Ce instanceof Error?Ce:new Error("Unknown error")),e||xe(o)}},Rt=async()=>{if(!x.trim()||N)return;rt();const q={role:"user",content:x};y(fe=>[...fe,q]),I("");const Z=x.toLowerCase();if(Ln.some(fe=>Z.includes(fe))){const fe=`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:fe}]),_||Y(fe);return}M(!0),m==null||m(),e||xe(s),await gr(q),M(!1)};return{messages:d,input:x,setInput:I,isLoading:N,handleSend:Rt,handleKeyPress:q=>{q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),Rt())},handleInputFocus:()=>{},handleInputBlur:()=>{},chatEndRef:D,clearMessages:()=>{y([{role:"assistant",content:"G'day! Bob from CARFIX here. How can I help ya today?"}])},isMuted:_,toggleMute:()=>{k(q=>!q),_||rt()},isSpeaking:ar,identifiedVehicle:L,clearVehicle:()=>{U(null)}}},ks=t=>{const e=Es(),r=Ur();return f.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]),Rs({queryKey:["bob-animation-data",t],queryFn:async()=>{var S;const{data:s,error:a}=await r.from("bob_looks").select("*").order("display_order");if(a)throw a;const o=(s||[]).find(j=>j.is_active),u=t||(o==null?void 0:o.id)||s&&((S=s[0])==null?void 0:S.id)||null;if(!u)return{states:[],configs:[],uploadedImages:[],looks:s||[],activeLookId:null};const{data:p,error:c}=await r.from("animation_states").select("*").eq("is_active",!0).eq("look_id",u).order("display_order");if(c)throw c;const{data:w,error:m}=await r.from("bob_animations").select("*").eq("is_active",!0).eq("look_id",u).order("animation_state").order("sequence_order");if(m)throw m;const l=new Set((p||[]).map(j=>j.state_key)),v=(w||[]).filter(j=>l.has(j.animation_state)),{data:E,error:P}=await r.storage.from("bob-images").list();if(P)throw P;const T=(E||[]).map(j=>{const{data:g}=r.storage.from("bob-images").getPublicUrl(j.name);return g.publicUrl});return v.forEach(j=>{const g=new Image;g.src=j.image_url}),{states:p||[],configs:v,uploadedImages:T,looks:s||[],activeLookId:u}},staleTime:30*1e3,gcTime:5*60*1e3})},Ps=()=>{const[t,e]=f.useState(""),[r,s]=f.useState(0),[a,o]=f.useState(400),[u,p]=f.useState(!1),c=f.useRef(),{data:w,isLoading:m}=ks(),l=f.useRef({}),{imageUrlsMap:v,alternateImages:E,offsetsMap:P,scalesMap:T,availableStates:S}=f.useMemo(()=>{if(!w)return{imageUrlsMap:{},alternateImages:{},offsetsMap:{},scalesMap:{},availableStates:[]};const d={},y={},x={},I={},N=w.states.map(M=>M.state_key);return N.forEach(M=>{const _=w.configs.filter(D=>D.animation_state===M),k=_.map(D=>D.image_url),L=_.map(D=>D.vertical_offset||0),U=_.map(D=>D.scale||100);if(k.length>0){const D=w.states.find(ee=>ee.state_key===M);d[M]={url:k[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[M]=k,x[M]=L,I[M]=U}}),{imageUrlsMap:d,alternateImages:y,offsetsMap:x,scalesMap:I,availableStates:N}},[w]);return f.useEffect(()=>{l.current=v},[v]),f.useEffect(()=>{S.length>0&&!t&&e(S[0])},[S,t]),f.useEffect(()=>{const d=E[t];if(c.current&&clearInterval(c.current),d&&d.length>1){s(0);const y=l.current[t],x=(y==null?void 0:y.animation_speed)||a||400,I=(y==null?void 0:y.loop_count)||0,N=(y==null?void 0:y.pause_duration)||0;let M=0,_=!1;const k=()=>{c.current=setInterval(()=>{_||s(L=>{const U=(L+1)%d.length;return U===0&&(M++,I>0&&M>=I)?(clearInterval(c.current),N>0&&(_=!0,setTimeout(()=>{M=0,_=!1,k()},N)),L):U})},x)};k()}else s(0);return()=>{c.current&&clearInterval(c.current)}},[t,E]),{animationState:t,setAnimationState:e,getCurrentImage:()=>{const d=E[t];if(!d||d.length===0){const y=S.find(x=>{var I;return((I=E[x])==null?void 0:I.length)>0});return y?E[y][0]:""}return d[r]||d[0]},getCurrentOffset:()=>{const d=P[t];if(!d||d.length===0){const y=S.find(x=>{var I;return((I=P[x])==null?void 0:I.length)>0});return y?P[y][0]:0}return d[r]||d[0]},getCurrentScale:()=>{const d=T[t];if(!d||d.length===0){const y=S.find(x=>{var I;return((I=T[x])==null?void 0:I.length)>0});return y?T[y][0]:100}return d[r]||d[0]},imageUrls:v,availableStates:S,setTalkSpeed:o,manualMode:u,setManualMode:p,isLoading:m}},Is=()=>{const t=Ur(),{data:e=[],isLoading:r}=Rs({queryKey:["bob-backdrops"],queryFn:async()=>{const{data:a,error:o}=await t.from("bob_backdrops").select("*").order("display_order",{ascending:!0});if(o)throw o;return a},staleTime:5*60*1e3,gcTime:10*60*1e3}),s=e.find(a=>a.is_active);return{backdrops:e,activeBackdrop:s,isLoading:r}},Ns=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:s,counterHeightPercent:a=12,className:o="",verticalOffset:u=0,scale:p=100})=>{const c=u+a,w=55*(p/100);return h.jsx("div",{className:`flex flex-col items-center justify-center gap-6 w-full ${o}`,children:h.jsxs("div",{className:"relative w-full max-w-[600px] mx-auto aspect-[16/10] overflow-hidden",children:[r&&h.jsx("img",{src:r,alt:"Backdrop",className:"absolute inset-0 z-0 w-full h-full object-cover object-bottom"}),h.jsx("img",{src:t,alt:`Bob ${e}`,className:"absolute z-10 h-auto object-contain left-1/2 -translate-x-1/2",style:{bottom:`${c}%`,width:`${w}%`,maxWidth:`${220*(p/100)}px`,transformOrigin:"center bottom"}}),s&&h.jsx("img",{src:s,alt:"Counter",className:"absolute z-20 bottom-0 left-0 w-full object-cover object-bottom",style:{height:`${a}%`}})]})})},Fs=({messages:t,input:e,setInput:r,isLoading:s,onSend:a,onKeyPress:o,onInputFocus:u,onInputBlur:p,chatEndRef:c,isMuted:w=!1,onToggleMute:m,isSpeaking:l=!1,className:v=""})=>h.jsx("div",{className:`w-full max-w-6xl mx-auto px-4 pb-8 ${v}`,children:h.jsxs("div",{className:"bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg overflow-hidden",children:[h.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800",children:h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{value:e,onChange:E=>r(E.target.value),onKeyPress:o,onFocus:u,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&&h.jsx("button",{onClick:m,className:`shrink-0 p-2 border border-gray-300 dark:border-gray-600 rounded-md ${l?"animate-pulse":""}`,title:w?"Unmute Bob's voice":"Mute Bob's voice",children:w?"🔇":"🔊"}),h.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"})]})}),h.jsxs("div",{className:"overflow-y-auto p-4 space-y-3 h-[300px] md:h-[400px]",children:[[...t].reverse().map((E,P)=>h.jsx("div",{className:`flex ${E.role==="user"?"justify-end":"justify-start"}`,children:h.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})},P)),h.jsx("div",{ref:c})]})]})}),Ms=({currentImage:t,animationState:e,counterOverlayUrl:r,counterHeightPercent:s=15,scale:a=100,position:o="center"})=>{const u=85*a/100,p=400*a/100,c=o==="center"?"-20%":"-35%";return h.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:[h.jsx("div",{className:"absolute left-0 z-40",style:{bottom:`${s-2}%`,transform:`translateX(${c})`,width:`${u}%`,maxWidth:`${p}px`,transition:"transform 0.4s ease-out"},children:h.jsx("img",{src:t,alt:`Bob ${e}`,className:"w-full h-auto object-contain",style:{display:"block"}})}),r&&h.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-50",style:{height:`${s}%`},children:h.jsx("img",{src:r,alt:"Shop counter",className:"w-full h-full object-cover object-top"})})]})},ns=(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))},Un=(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},As=({products:t,servicePackages:e,highlightedPartType:r,highlightedProduct:s,onProductClick:a,onPackageSelect:o,isResearching:u,visible:p=!0,counterHeightPercent:c=22,hasVehicle:w=!1})=>{const m=f.useRef(null),l=f.useRef({}),v=f.useRef(null),E=f.useMemo(()=>{const g={};return t.forEach(d=>{const y=d.partslotDescription||"Other Parts";g[y]||(g[y]=[]),g[y].push(d)}),Object.keys(g).sort((d,y)=>d.localeCompare(y)).map(d=>({name:d,products:g[d]}))},[t]);f.useEffect(()=>{var g;if(r){const C=E.find(d=>ns(d.name,r));C&&l.current[C.name]&&((g=l.current[C.name])==null||g.scrollIntoView({behavior:"smooth",block:"start"}))}},[r,E]),f.useEffect(()=>{s&&v.current&&v.current.scrollIntoView({behavior:"smooth",block:"center"})},[s]);const P=t.length>0||e.length>0,T=u,S=P&&!u,j=w?"56px":"8px";return h.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:j,bottom:`calc(${c}% + 16px)`,paddingTop:"env(safe-area-inset-top, 4px)"},children:[T&&h.jsx("div",{className:"rounded-lg p-3",children:h.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[h.jsx("div",{className:"w-4 h-4 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"}),h.jsx("span",{children:"Finding parts..."})]})}),S&&e.length>0&&h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"text-xs font-semibold text-blue-600 flex items-center gap-1 px-1",children:[h.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.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(g=>h.jsxs("div",{onClick:()=>o==null?void 0:o(g),className:"cursor-pointer hover:shadow-md transition-all bg-white/80 rounded-lg border border-gray-200 p-2",children:[h.jsx("p",{className:"text-xs font-medium line-clamp-1",children:g.title}),h.jsxs("p",{className:"text-sm font-bold text-blue-600",children:["$",g.from_price.toFixed(0)]})]},g.id))]}),S&&E.map(({name:g,products:C},d)=>{const y=r&&ns(g,r);return h.jsxs("section",{ref:x=>{l.current[g]=x},className:`rounded-lg transition-all border border-transparent ${y?"ring-2 ring-blue-600 p-2 bg-blue-50/50 shadow-lg":""}`,children:[h.jsxs("h3",{className:"text-xs font-semibold mb-2 flex items-center gap-1 px-1 text-gray-900",children:[h.jsx("svg",{className:"h-3 w-3 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.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"})}),h.jsx("span",{className:"truncate",children:g}),h.jsxs("span",{className:"text-[10px] text-gray-500",children:["(",C.length,")"]})]}),h.jsx("div",{className:"space-y-2",children:C.map((x,I)=>{const N=s&&Un(x,s);return h.jsxs("div",{ref:N?v:void 0,onClick:()=>a==null?void 0:a(x),className:`cursor-pointer transition-all bg-white/80 rounded-lg border border-gray-200 relative ${N?"ring-4 ring-blue-600 scale-105 z-10":"hover:shadow-md"}`,children:[N&&h.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:[h.jsx("svg",{className:"h-2 w-2 mr-0.5",fill:"currentColor",viewBox:"0 0 20 20",children:h.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"]}),h.jsxs("div",{className:"p-2",children:[h.jsx("div",{className:"aspect-square bg-gray-100 rounded-md mb-1 flex items-center justify-center overflow-hidden",children:x.image_url?h.jsx("img",{src:x.image_url,alt:x.name,className:"w-full h-full object-contain"}):h.jsx("svg",{className:"h-8 w-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.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"})})}),h.jsx("p",{className:"text-xs font-medium line-clamp-2",children:x.name}),x.brand&&h.jsx("p",{className:"text-[10px] text-gray-500",children:x.brand})]}),h.jsx("div",{className:"px-2 pb-2",children:h.jsx("span",{className:"text-sm font-bold text-blue-600",children:x.price>0?`$${x.price.toFixed(2)}`:"Price on request"})}),h.jsx("div",{className:"px-2 pb-2",children:h.jsx("button",{className:"w-full bg-blue-600 text-white text-xs py-1.5 rounded-md hover:bg-blue-700",onClick:M=>{M.stopPropagation(),a==null||a(x)},children:"Buy Now"})})]},`${x.id}-${I}`)})})]},g)})]})},Ds=({onTranscript:t,onSpeechEnd:e,language:r="en-NZ",mode:s="toggle"}={})=>{const[a,o]=f.useState(!1),[u,p]=f.useState(""),[c,w]=f.useState(""),[m,l]=f.useState(null),[v,E]=f.useState(!1),P=f.useRef(null),T=f.useRef(""),S=f.useRef(t),j=f.useRef(e);f.useEffect(()=>{S.current=t,j.current=e},[t,e]),f.useEffect(()=>{const y=window.SpeechRecognition||window.webkitSpeechRecognition;if(y){E(!0);const x=new y;x.continuous=s==="ptt",x.interimResults=!0,x.lang=r,x.maxAlternatives=1,x.onstart=()=>{o(!0),l(null)},x.onresult=I=>{let N="",M="";for(let _=I.resultIndex;_<I.results.length;_++){const k=I.results[_][0].transcript;I.results[_].isFinal?M+=k:N+=k}M&&(T.current=M,p(M),S.current&&S.current(M)),w(N)},x.onerror=I=>{switch(o(!1),I.error){case"no-speech":l("No speech detected. Please try again.");break;case"audio-capture":l("No microphone found. Please check your device.");break;case"not-allowed":l("Microphone permission denied. Please allow access.");break;default:l("Speech recognition error. Please try again.")}},x.onend=()=>{o(!1),w(""),T.current&&j.current&&j.current(T.current),T.current=""},P.current=x}return()=>{P.current&&P.current.stop()}},[r,s]);const g=()=>{P.current&&!a&&(p(""),w(""),l(null),P.current.start())},C=()=>{P.current&&a&&P.current.stop()};return{isListening:a,transcript:u,interimTranscript:c,error:m,isSupported:v,startListening:g,stopListening:C,toggleListening:()=>{a?C():g()}}},Ls=({messages:t,input:e,setInput:r,isLoading:s,onSend:a,onKeyPress:o,onInputFocus:u,onInputBlur:p,chatEndRef:c,isMuted:w=!1,onToggleMute:m,isSpeaking:l=!1})=>{const[v,E]=f.useState(!1),P=f.useRef(null),T=f.useRef(!1),{isListening:S,interimTranscript:j,error:g,isSupported:C,startListening:d,stopListening:y}=Ds({onTranscript:_=>r(_),language:"en-NZ",mode:"ptt"});f.useEffect(()=>{j&&r(j)},[j,r]);const x=f.useCallback(()=>{s||T.current||(T.current=!0,navigator.vibrate&&navigator.vibrate(10),d())},[s,d]),I=f.useCallback(()=>{T.current&&(T.current=!1,navigator.vibrate&&navigator.vibrate(10),y(),setTimeout(()=>{a()},150))},[y,a]),N=[...t].reverse().find(_=>_.role==="assistant"),M=N!=null&&N.content?N.content.length>50?N.content.slice(0,50)+"...":N.content:"Ask Bob about car parts...";return h.jsxs("div",{ref:P,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)] ${v?"h-[55vh]":"h-auto"}`,style:{zIndex:60,paddingBottom:"env(safe-area-inset-bottom, 8px)"},children:[h.jsx("button",{onClick:()=>E(!v),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":v?"Collapse chat":"Expand chat",children:v?h.jsx("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):h.jsx("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!v&&h.jsx("div",{className:"px-3 pt-2 pb-0.5",onClick:()=>E(!0),children:h.jsx("p",{className:"text-xs text-gray-500 line-clamp-1",children:M})}),v&&h.jsxs("div",{className:"h-[calc(100%-100px)] overflow-y-auto p-4 space-y-2",children:[[...t].reverse().map((_,k)=>h.jsx("div",{className:`flex ${_.role==="user"?"justify-end":"justify-start"}`,children:h.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${_.role==="user"?"bg-blue-600 text-white":"bg-gray-100 text-gray-900"}`,children:_.content})},k)),h.jsx("div",{ref:c})]}),h.jsxs("div",{className:`px-2 pb-1.5 ${v?"pt-2 border-t border-gray-200":"pt-0.5"}`,children:[S&&h.jsxs("div",{className:"mb-2 text-xs text-gray-500 flex items-center gap-2",children:[h.jsx("span",{className:"inline-block w-2 h-2 bg-red-500 rounded-full animate-pulse"}),"Listening..."]}),g&&h.jsx("div",{className:"mb-2 text-xs text-red-500",children:g}),h.jsxs("div",{className:"flex gap-1.5 items-center",children:[m&&v&&h.jsx("button",{onClick:m,className:`shrink-0 h-9 w-9 flex items-center justify-center rounded-md hover:bg-gray-100 ${l?"text-blue-600 animate-pulse":"text-gray-600"}`,title:w?"Unmute":"Mute",children:w?h.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[h.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"}),h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):h.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.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"})})}),h.jsx("input",{type:"text",value:e,onChange:_=>r(_.target.value),onKeyPress:o,onFocus:u,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"}),C&&h.jsx("button",{onTouchStart:x,onTouchEnd:I,onTouchCancel:I,onMouseDown:x,onMouseUp:I,onMouseLeave:I,disabled:s,className:`shrink-0 h-12 w-12 rounded-full flex items-center justify-center select-none touch-none ${S?"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:h.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.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:o,input:u,setInput:p,isLoading:c,onSend:w,onKeyPress:m,onInputFocus:l,onInputBlur:v,chatEndRef:E,isMuted:P,onToggleMute:T,isSpeaking:S,products:j,servicePackages:g,highlightedPartType:C,highlightedProduct:d,onProductClick:y,onPackageSelect:x,isResearching:I,vehicle:N,onChangeVehicle:M})=>{const _=typeof window<"u"&&window.self!==window.top,[k,L]=f.useState("center"),[U,D]=f.useState("hidden"),ee=j.length>0||g.length>0;f.useEffect(()=>{if(I&&U!=="loading"&&U!=="visible")D("loading"),k==="center"&&L("left");else if(ee&&U!=="visible")if(k==="center"){L("left"),D("transitioning");const H=setTimeout(()=>{D("visible")},400);return()=>clearTimeout(H)}else D("visible");else!ee&&!I&&U!=="hidden"&&(D("hidden"),L("center"))},[ee,I,U,k]);const Fe=U!=="hidden";return h.jsxs("div",{className:"fixed inset-0 overflow-hidden",style:{height:"100dvh",touchAction:"manipulation"},children:[r&&h.jsxs(h.Fragment,{children:[h.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)"}}),h.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%)"}})]}),h.jsx(Ms,{currentImage:t,animationState:e,counterOverlayUrl:s,counterHeightPercent:a,scale:200,position:k}),N&&!_&&h.jsx("div",{className:"absolute top-2 left-2 right-2 z-20",children:h.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:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("p",{className:"text-xs font-medium text-gray-900 truncate",children:[N.year," ",N.make," ",N.model]}),N.rego&&h.jsx("p",{className:"text-[10px] text-gray-500",children:N.rego})]}),M&&h.jsx("button",{onClick:M,className:"text-xs text-blue-600 hover:underline ml-2 shrink-0",children:"Change"})]})}),h.jsx(As,{products:j,servicePackages:g,highlightedPartType:C,highlightedProduct:d,onProductClick:y,onPackageSelect:x,isResearching:I,visible:Fe,counterHeightPercent:a,hasVehicle:!!N}),h.jsx(Ls,{messages:o,input:u,setInput:p,isLoading:c,onSend:w,onKeyPress:m,onInputFocus:l,onInputBlur:v,chatEndRef:E,isMuted:P,onToggleMute:T,isSpeaking:S})]})},Us=({variant:t="inline",initialState:e="idle",showChat:r=!0,className:s="",backdropUrl:a,counterOverlayUrl:o,counterHeightPercent:u,defaultBobImage:p,verticalOffset:c=0,scale:w=100})=>{const{callbacks:m}=tt(),{animationState:l,setAnimationState:v,getCurrentImage:E,availableStates:P,isLoading:T}=Ps(),{activeBackdrop:S}=Is(),[j,g]=f.useState([]),[C,d]=f.useState([]),[y,x]=f.useState(null),[I,N]=f.useState(null),[M,_]=f.useState(!1),k=js({setAnimationState:v,manualMode:!1,onReadyToSpeak:()=>{console.log("[BobWidget] Ready to speak")},onStreamComplete:()=>{v(P.find(H=>H.includes("idle"))||"idle")},onResearchStart:()=>{_(!0)},onHighlightPart:H=>{x(H),setTimeout(()=>x(null),8e3)},onHighlightProduct:H=>{N(H),setTimeout(()=>N(null),8e3)},onAutoFetchComplete:()=>{_(!1)}});f.useEffect(()=>{const H=m.onPartsFound,ue=m.onServicePackagesFound;return m.onPartsFound=de=>{_(!1);const Be=de.map((Y,rt)=>({id:Y.SKU||Y.sku||`part-${rt}`,name:Y["Part Product Type"]||Y.partslot_description||"Unknown Part",brand:Y.Brand||Y.brand,price:Y["Metro Retail Price"]||Y.price||0,sku:Y.SKU||Y.sku,partNumber:Y["Part Number"]||Y.part_number,partslotDescription:Y["Part Product Type"]||Y.partslot_description,image_url:Y.image_url}));g(Be),H==null||H(de)},m.onServicePackagesFound=de=>{d(de),ue==null||ue(de)},()=>{m.onPartsFound=H,m.onServicePackagesFound=ue}},[m]);const L=a||(S==null?void 0:S.image_url),U=o||(S==null?void 0:S.counter_overlay_url)||void 0,D=u||(S==null?void 0:S.counter_height_percent)||12,ee=E()||p||"";if(t==="mobile"||t==="fullscreen")return h.jsx(Bs,{currentImage:ee,animationState:l,backdropUrl:L,counterOverlayUrl:U,counterHeightPercent:D,messages:k.messages,input:k.input,setInput:k.setInput,isLoading:k.isLoading,onSend:k.handleSend,onKeyPress:k.handleKeyPress,onInputFocus:k.handleInputFocus,onInputBlur:k.handleInputBlur,chatEndRef:k.chatEndRef,isMuted:k.isMuted,onToggleMute:k.toggleMute,isSpeaking:k.isSpeaking,products:j,servicePackages:C,highlightedPartType:y,highlightedProduct:I,onProductClick:H=>{var ue;return(ue=m.onAddToCart)==null?void 0:ue.call(m,{product_id:H.id,product_name:H.name,quantity:1,unit_price:H.price,sku:H.sku,brand:H.brand})},onPackageSelect:H=>console.log("[BobWidget] Package selected:",H),isResearching:M,vehicle:k.identifiedVehicle});const Fe={inline:"",floating:"fixed bottom-4 right-4 w-96 z-50 shadow-2xl rounded-lg overflow-hidden",fullscreen:"fixed inset-0 z-50 bg-black/80",mobile:""};return h.jsxs("div",{className:`${Fe[t]} ${s}`,children:[ee&&h.jsx(Ns,{currentImage:ee,animationState:l,backdropUrl:L,counterOverlayUrl:U,counterHeightPercent:D,verticalOffset:c,scale:w}),r&&h.jsx(Fs,{messages:k.messages,input:k.input,setInput:k.setInput,isLoading:k.isLoading,onSend:k.handleSend,onKeyPress:k.handleKeyPress,onInputFocus:k.handleInputFocus,onInputBlur:k.handleInputBlur,chatEndRef:k.chatEndRef,isMuted:k.isMuted,onToggleMute:k.toggleMute,isSpeaking:k.isSpeaking})]})},qn=({bobConfig:t,hostApiConfig:e,hostContext:r,callbacks:s,variant:a="mobile",initialState:o,showChat:u,className:p,backdropUrl:c,counterOverlayUrl:w,counterHeightPercent:m,defaultBobImage:l,verticalOffset:v,scale:E})=>h.jsx(_s,{bobConfig:t,hostApiConfig:e,hostContext:r,callbacks:s,children:h.jsx(Us,{variant:a,initialState:o,showChat:u,className:p,backdropUrl:c,counterOverlayUrl:w,counterHeightPercent:m,defaultBobImage:l,verticalOffset:v,scale:E})}),Qn=6e4,$n=({states:t,setAnimationState:e,manualMode:r})=>{const[s,a]=f.useState("page_load"),[o,u]=f.useState(!1),p=f.useRef(null),c=f.useCallback(y=>t.find(x=>x.chat_trigger===y&&x.is_active),[t]),w=f.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=f.useCallback(()=>t.find(y=>y.state_key==="idle"||y.title.toLowerCase().includes("idle")),[t]),l=f.useCallback(y=>{const x=t.find(I=>I.state_key===y);return{speed:(x==null?void 0:x.animation_speed)||400,pauseDuration:(x==null?void 0:x.pause_duration)||0,loopCount:(x==null?void 0:x.loop_count)||0}},[t]),v=f.useCallback(()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]),E=f.useCallback(()=>{v(),!r&&(p.current=setTimeout(()=>{const y=m();y&&(a("idle"),e(y.state_key))},Qn))},[r,m,e,v]),P=f.useCallback(y=>{if(r)return;const x=c(y);x&&e(x.state_key)},[r,c,e]),T=f.useCallback(()=>{if(r)return;const y=w();y&&(a("awaiting_input"),e(y.state_key),E())},[r,w,e,E]),S=f.useCallback(()=>{o||r||(u(!0),a("page_load"),P("page_load"),setTimeout(()=>{T()},3e3))},[o,r,P,T]),j=f.useCallback(()=>{v(),a("processing_input"),P("processing_input")},[P,v]),g=f.useCallback(()=>{v(),a("streaming_response"),P("streaming_response")},[P,v]),C=f.useCallback(()=>{a("response_complete"),P("response_complete"),setTimeout(()=>{T()},3e3)},[P,T]),d=f.useCallback(()=>{a("showing_product");const y=t.find(x=>x.chat_trigger==="showing_product"||x.state_key==="showing_product");y&&e(y.state_key),setTimeout(()=>{T()},4e3)},[t,e,T]);return f.useEffect(()=>()=>v(),[v]),{chatStage:s,initialize:S,onUserInput:j,onStreamStart:g,onStreamComplete:C,onShowingProduct:d,getStateSettings:l}};console.log(`[BobWidget] Package loaded - v${nr}`);exports.BOB_VERSION=nr;exports.Bob=Us;exports.BobCharacter=Ns;exports.BobProvider=_s;exports.BobWidget=qn;exports.ChatInterface=Fs;exports.MobileBobCharacter=Ms;exports.MobileBobLayout=Bs;exports.MobileChatDrawer=Ls;exports.MobileProductColumn=As;exports.getBobVersion=zs;exports.useBobAnimation=Ps;exports.useBobAnimationData=ks;exports.useBobBackdrop=Is;exports.useBobCallbacks=Dn;exports.useBobChat=js;exports.useBobContext=tt;exports.useBobStateTransitions=$n;exports.useBobSupabase=Ur;exports.useHostApiConfig=An;exports.useHostContext=Mn;exports.useSpeechRecognition=Ds;exports.useSpeechSynthesis=Os;
30
+ <%s key={someKey} {...props} />`,vr,ht,Vs,ht),Tt[ht+vr]=!0}}return n===s?dt(Z):Vt(Z),Z}}function yr(n,v,I){return zt(n,v,I,!0)}function Qs(n,v,I){return zt(n,v,I,!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(){F(this,Pe,Zs);F(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}),O(this,Pe,t),process.env.NODE_ENV!=="production"&&O(this,pt,!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&O(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"&&O(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 de(){}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 Hr(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 S=Sr(h,g);p[m]=S,S===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,ze,_t,cs,ln=(cs=class extends ir{constructor(){super();F(this,mt);F(this,ze);F(this,_t);O(this,_t,e=>{if(!Et&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){i(this,ze)||this.setEventListener(i(this,_t))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,ze))==null||e.call(this),O(this,ze,void 0))}setEventListener(e){var r;O(this,_t,e),(r=i(this,ze))==null||r.call(this),O(this,ze,e(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(e){i(this,mt)!==e&&(O(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,ze=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 ne=hn(),Ot,He,Pt,ls,fn=(ls=class extends ir{constructor(){super();F(this,Ot,!0);F(this,He);F(this,Pt);O(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,He)||this.setEventListener(i(this,Pt))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,He))==null||e.call(this),O(this,He,void 0))}setEventListener(e){var r;O(this,Pt,e),(r=i(this,He))==null||r.call(this),O(this,He,e(this.setOnline.bind(this)))}setOnline(e){i(this,Ot)!==e&&(O(this,Ot,e),this.listeners.forEach(s=>{s(e)}))}isOnline(){return i(this,Ot)}},Ot=new WeakMap,He=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))},S=()=>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)}),N=()=>{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 x;if(u())return;const b=t.retry??(Et?0:3),C=t.retryDelay??pn,f=typeof C=="function"?C(r,k):C,y=b===!0||typeof b=="number"&&r<b||typeof b=="function"&&b(r,k);if(e||!y){g(k);return}r++,(x=t.onFail)==null||x.call(t,r,k),nn(f).then(()=>w()?void 0:S()).then(()=>{e?g(k):N()})})};return{promise:a,status:()=>a.status,cancel:c,continue:()=>(s==null||s(),a),cancelRetry:p,continueRetry:l,canStart:m,start:()=>(m()?N():S().then(N),a)}}var gt,ds,Cs=(ds=class{constructor(){F(this,gt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Cr(this.gcTime)&&O(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)),O(this,gt,void 0))}},gt=new WeakMap,ds),bt,It,be,yt,re,Zt,vt,Te,Ae,hs,mn=(hs=class extends Cs{constructor(e){super();F(this,Te);F(this,bt);F(this,It);F(this,be);F(this,yt);F(this,re);F(this,Zt);F(this,vt);O(this,vt,!1),O(this,Zt,e.defaultOptions),this.setOptions(e.options),this.observers=[],O(this,yt,e.client),O(this,be,i(this,yt).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,O(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,re))==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)),O(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,re))==null?void 0:s.promise;return(a=i(this,re))==null||a.cancel(e),r?r.then(de).catch(de):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,re))==null||r.continue()}onOnline(){var r;const e=this.observers.find(s=>s.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=i(this,re))==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,re)&&(i(this,vt)?i(this,re).cancel({revert:!0}):i(this,re).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,S,N,T,j,k,b,C;if(this.state.fetchStatus!=="idle"&&((l=i(this,re))==null?void 0:l.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(i(this,re))return i(this,re).continueRetry(),i(this,re).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:()=>(O(this,vt,!0),s.signal)})},u=()=>{const f=vs(this.options,r),x=(()=>{const P={client:i(this,yt),queryKey:this.queryKey,meta:this.meta};return a(P),P})();return O(this,vt,!1),this.options.persister?this.options.persister(f,x,this):f(x)},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),O(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}),O(this,re,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,re).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),(S=(g=i(this,be).config).onSuccess)==null||S.call(g,f,this),(T=(N=i(this,be).config).onSettled)==null||T.call(N,f,this.state.error,this),f}catch(f){if(f instanceof kr){if(f.silent)return i(this,re).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),(C=(b=i(this,be).config).onSettled)==null||C.call(b,this.state.data,f,this),f}finally{this.scheduleGc()}}},bt=new WeakMap,It=new WeakMap,be=new WeakMap,yt=new WeakMap,re=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 O(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),ne.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 le,W,er,oe,xt,Nt,Le,Ge,tr,Mt,Ft,wt,Ct,Ye,At,z,Yt,_r,Or,Pr,Ir,Nr,Mr,Fr,Es,fs,gn=(fs=class extends ir{constructor(e,r){super();F(this,z);F(this,le);F(this,W);F(this,er);F(this,oe);F(this,xt);F(this,Nt);F(this,Le);F(this,Ge);F(this,tr);F(this,Mt);F(this,Ft);F(this,wt);F(this,Ct);F(this,Ye);F(this,At,new Set);this.options=r,O(this,le,e),O(this,Ge,null),O(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,z,Yt).call(this):this.updateResult(),Q(this,z,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,z,Nr).call(this),Q(this,z,Mr).call(this),i(this,W).removeObserver(this)}setOptions(e){const r=this.options,s=i(this,W);if(this.options=i(this,le).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,z,Fr).call(this),i(this,W).setOptions(this.options),r._defaulted&&!Er(this.options,r)&&i(this,le).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,z,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,z,_r).call(this);const u=Q(this,z,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,z,Pr).call(this,u)}getOptimisticResult(e){const r=i(this,le).getQueryCache().build(i(this,le),e),s=this.createResult(r,e);return yn(this,s)&&(O(this,oe,s),O(this,Nt,this.options),O(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,le).defaultQueryOptions(e),s=i(this,le).getQueryCache().build(i(this,le),r);return s.fetch().then(()=>this.createResult(s,r))}fetch(e){return Q(this,z,Yt).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,oe)))}createResult(e,r){var M;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,S;if(r._optimisticResults){const E=this.hasListeners(),R=!E&&es(e,r),A=E&&ts(e,s,r,a);(R||A)&&(h={...h,...Ss(m.data,e.options)}),r._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:N,errorUpdatedAt:T,status:j}=h;S=h.data;let k=!1;if(r.placeholderData!==void 0&&S===void 0&&j==="pending"){let E;u!=null&&u.isPlaceholderData&&r.placeholderData===(p==null?void 0:p.placeholderData)?(E=u.data,k=!0):E=typeof r.placeholderData=="function"?r.placeholderData((M=i(this,Ft))==null?void 0:M.state.data,i(this,Ft)):r.placeholderData,E!==void 0&&(j="success",S=jr(u==null?void 0:u.data,E,r),g=!0)}if(r.select&&S!==void 0&&!k)if(u&&S===(c==null?void 0:c.data)&&r.select===i(this,tr))S=i(this,Mt);else try{O(this,tr,r.select),S=r.select(S),S=jr(u==null?void 0:u.data,S,r),O(this,Mt,S),O(this,Ge,null)}catch(E){O(this,Ge,E)}i(this,Ge)&&(N=i(this,Ge),S=i(this,Mt),T=Date.now(),j="error");const b=h.fetchStatus==="fetching",C=j==="pending",f=j==="error",y=C&&b,x=S!==void 0,_={status:j,fetchStatus:h.fetchStatus,isPending:C,isSuccess:j==="success",isError:f,isInitialLoading:y,isLoading:y,data:S,dataUpdatedAt:h.dataUpdatedAt,error:N,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&&!C,isLoadingError:f&&!x,isPaused:h.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:f&&x,isStale:Br(e,r),refetch:this.refetch,promise:i(this,Le),isEnabled:ye(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const E=B=>{_.status==="error"?B.reject(_.error):_.data!==void 0&&B.resolve(_.data)},R=()=>{const B=O(this,Le,_.promise=Tr());E(B)},A=i(this,Le);switch(A.status){case"pending":e.queryHash===s.queryHash&&E(A);break;case"fulfilled":(_.status==="error"||_.data!==A.value)&&R();break;case"rejected":(_.status!=="error"||_.error!==A.reason)&&R();break}}return _}updateResult(){const e=i(this,oe),r=this.createResult(i(this,W),this.options);if(O(this,xt,i(this,W).state),O(this,Nt,this.options),i(this,xt).data!==void 0&&O(this,Ft,i(this,W)),Er(r,e))return;O(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,z,Es).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Q(this,z,Ir).call(this)}},le=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,z=new WeakSet,Yt=function(e){Q(this,z,Fr).call(this);let r=i(this,W).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(de)),r},_r=function(){Q(this,z,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;O(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,z,Mr).call(this),O(this,Ye,e),!(Et||ye(this.options.enabled,i(this,W))===!1||!Cr(i(this,Ye))||i(this,Ye)===0)&&O(this,Ct,ft.setInterval(()=>{(this.options.refetchIntervalInBackground||Dr.isFocused())&&Q(this,z,Yt).call(this)},i(this,Ye)))},Ir=function(){Q(this,z,_r).call(this),Q(this,z,Pr).call(this,Q(this,z,Or).call(this))},Nr=function(){i(this,wt)&&(ft.clearTimeout(i(this,wt)),O(this,wt,void 0))},Mr=function(){i(this,Ct)&&(ft.clearInterval(i(this,Ct)),O(this,Ct,void 0))},Fr=function(){const e=i(this,le).getQueryCache().build(i(this,le),this.options);if(e===i(this,W))return;const r=i(this,W);O(this,W,e),O(this,er,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},Es=function(e){ne.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(i(this,oe))}),i(this,le).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,S,N;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=((S=e.state.data)==null?void 0:S.pages)||[],c=((N=e.state.data)==null?void 0:N.pageParams)||[];let p={pages:[],pageParams:[]},l=0;const w=async()=>{let T=!1;const j=C=>{cn(C,()=>e.signal,()=>T=!0)},k=vs(e.options,e.fetchOptions),b=async(C,f,y)=>{if(T)return Promise.reject();if(f==null&&C.pages.length)return Promise.resolve(C);const P=(()=>{const R={client:e.client,queryKey:e.queryKey,pageParam:f,direction:y?"backward":"forward",meta:e.options.meta};return j(R),R})(),_=await k(P),{maxPages:M}=e.options,E=y?on:an;return{pages:E(C.pages,_,M),pageParams:E(C.pageParams,f,M)}};if(a&&u.length){const C=a==="backward",f=C?vn:ss,y={pages:u,pageParams:c},x=f(s,y);p=await b(y,x,C)}else{const C=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<C)}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();F(this,Ne);F(this,rr);F(this,Ie);F(this,ue);F(this,St);O(this,rr,e.client),this.mutationId=e.mutationId,O(this,ue,e.mutationCache),O(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){O(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,S,N,T,j,k,b,C,f,y,x,P,_,M;const r=()=>{Q(this,Ne,Ve).call(this,{type:"continue"})},s={client:i(this,rr),meta:this.options.meta,mutationKey:this.options.mutationKey};O(this,St,ws({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(E,R)=>{Q(this,Ne,Ve).call(this,{type:"failed",failureCount:E,error:R})},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 R=await((w=(l=this.options).onMutate)==null?void 0:w.call(l,e,s));R!==this.state.context&&Q(this,Ne,Ve).call(this,{type:"pending",context:R,variables:e,isPaused:u})}const E=await i(this,St).start();return await((h=(m=i(this,ue).config).onSuccess)==null?void 0:h.call(m,E,e,this.state.context,this,s)),await((S=(g=this.options).onSuccess)==null?void 0:S.call(g,E,e,this.state.context,s)),await((T=(N=i(this,ue).config).onSettled)==null?void 0:T.call(N,E,null,this.state.variables,this.state.context,this,s)),await((k=(j=this.options).onSettled)==null?void 0:k.call(j,E,null,e,this.state.context,s)),Q(this,Ne,Ve).call(this,{type:"success",data:E}),E}catch(E){try{throw await((C=(b=i(this,ue).config).onError)==null?void 0:C.call(b,E,e,this.state.context,this,s)),await((y=(f=this.options).onError)==null?void 0:y.call(f,E,e,this.state.context,s)),await((P=(x=i(this,ue).config).onSettled)==null?void 0:P.call(x,void 0,E,this.state.variables,this.state.context,this,s)),await((M=(_=this.options).onSettled)==null?void 0:M.call(_,void 0,E,e,this.state.context,s)),E}finally{Q(this,Ne,Ve).call(this,{type:"error",error:E})}}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),ne.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();F(this,De);F(this,ke);F(this,sr);this.config=e,O(this,De,new Set),O(this,ke,new Map),O(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(){ne.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){ne.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return ne.batch(()=>Promise.all(e.map(r=>r.continue().catch(de))))}},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();F(this,Me);this.config=e,O(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(){ne.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=>Hr(r,s))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(s=>Hr(e,s)):r}notify(e){ne.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){ne.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ne.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Me=new WeakMap,gs),G,Je,Xe,Lt,Dt,Ze,Bt,Ut,bs,En=(bs=class{constructor(t={}){F(this,G);F(this,Je);F(this,Xe);F(this,Lt);F(this,Dt);F(this,Ze);F(this,Bt);F(this,Ut);O(this,G,t.queryCache||new Sn),O(this,Je,t.mutationCache||new Cn),O(this,Xe,t.defaultOptions||{}),O(this,Lt,new Map),O(this,Dt,new Map),O(this,Ze,0)}mount(){hr(this,Ze)._++,i(this,Ze)===1&&(O(this,Bt,Dr.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,G).onFocus())})),O(this,Ut,mr.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,G).onOnline())})))}unmount(){var t,e;hr(this,Ze)._--,i(this,Ze)===0&&((t=i(this,Bt))==null||t.call(this),O(this,Bt,void 0),(e=i(this,Ut))==null||e.call(this),O(this,Ut,void 0))}isFetching(t){return i(this,G).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,G).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=i(this,G).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,G).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,G).get(s.queryHash),u=a==null?void 0:a.state.data,c=rn(e,u);if(c!==void 0)return i(this,G).build(this,s).setData(c,{...r,manual:!0})}setQueriesData(t,e,r){return ne.batch(()=>i(this,G).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,G).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=i(this,G);ne.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=i(this,G);return ne.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},s=ne.batch(()=>i(this,G).findAll(t).map(a=>a.cancel(r)));return Promise.all(s).then(de).catch(de)}invalidateQueries(t,e={}){return ne.batch(()=>(i(this,G).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=ne.batch(()=>i(this,G).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let u=a.fetch(void 0,r);return r.throwOnError||(u=u.catch(de)),a.state.fetchStatus==="paused"?Promise.resolve():u}));return Promise.all(s).then(de)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=i(this,G).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(de).catch(de)}fetchInfiniteQuery(t){return t.behavior=rs(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(de).catch(de)}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,G)}getMutationCache(){return i(this,Je)}getDefaultOptions(){return i(this,Xe)}setDefaultOptions(t){O(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,G).clear(),i(this,Je).clear()}},G=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,S,N,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(ne.batchCalls(j)):de;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((N=(S=u.getDefaultOptions().queries)==null?void 0:S._experimental_afterQuery)==null||N.call(S,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(de).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(()=>Hs.createClient(e.supabaseUrl,e.supabaseKey),[e.supabaseUrl,e.supabaseKey]),[m,h]=d.useState(s);d.useEffect(()=>{h(s)},[s]);const g=d.useCallback(N=>{h(T=>({...T,...N}))},[]),S=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:S,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=5e3,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)},[]),S=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))},[]),N=d.useCallback(async b=>{var C,f,y,x;if(b.trim()){l.current=!1,g(),c.current&&(c.current.pause(),c.current=null),p.current=setTimeout(()=>{var P,_;console.warn("[BobWidget TTS] Timeout after 5s - triggering fallback callbacks"),S(),u(!1),(P=m.current)==null||P.call(m),(_=h.current)==null||_.call(h),c.current=null},is);try{const P=new AbortController,_=setTimeout(()=>P.abort(),is-1e3),M=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:P.signal});if(clearTimeout(_),!M.ok){const A=await M.json().catch(()=>({}));throw console.error("[BobWidget TTS] Request failed:",A),new Error("TTS request failed")}const{audioContent:E}=await M.json(),R=new Audio(`data:audio/mp3;base64,${E}`);c.current=R,R.onplay=()=>{var A;g(),l.current||(l.current=!0,u(!0),console.log("[BobWidget TTS] Audio playing, triggering onStart"),(A=w.current)==null||A.call(w))},R.onended=()=>{var A;g(),u(!1),(A=m.current)==null||A.call(m),c.current=null},R.onerror=A=>{var B,D;g(),console.warn("[BobWidget TTS] Audio playback error:",A),S(),u(!1),(B=m.current)==null||B.call(m),(D=h.current)==null||D.call(h),c.current=null};try{await R.play()}catch(A){console.warn("[BobWidget TTS] Audio play() failed (likely autoplay policy):",A),g(),S(),u(!1),(C=m.current)==null||C.call(m),(f=h.current)==null||f.call(h),c.current=null}}catch(P){g(),console.error("[BobWidget TTS] Speech synthesis error:",P),S(),u(!1),(y=m.current)==null||y.call(m),(x=h.current)==null||x.call(h)}}},[s.supabaseUrl,s.supabaseKey,g,S]),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:N,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:S,onNoPartsFound:N,onAutoFetchComplete:T})=>{var cr,lr,st,Ue;const{bobConfig:j,hostApiConfig:k,hostContext:b,callbacks:C}=tt(),[f,y]=d.useState([]),[x,P]=d.useState(""),[_,M]=d.useState(!1),[E,R]=d.useState(!1),[A,B]=d.useState(null),D=d.useRef(null),Y=d.useRef(!1),xe=d.useRef(!1),U=d.useRef(""),se=d.useRef(!1),he=d.useRef(null),Be=()=>{he.current&&(clearTimeout(he.current),he.current=null)},{speak:J,stop:rt,isSpeaking:ar}=Ps({onStart:()=>{Be(),se.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,ie;const $=(ee=b.vehicle)==null?void 0:ee.selectedVehicle;$&&!A&&(console.log("[BobWidget] Setting vehicle from host context:",$),B($),(ie=C.onVehicleIdentified)==null||ie.call(C,$))},[(cr=b.vehicle)==null?void 0:cr.selectedVehicle]),d.useEffect(()=>{var $;if(f.length===0&&!xe.current){const ee=($=b.vehicle)==null?void 0:$.selectedVehicle;if(ee){xe.current=!0;const ie=`${ee.year} ${ee.make} ${ee.model}`;y([{role:"assistant",content:`G'day! Saw you've got the ${ie} - choice wagon! What can I help you find for it today?`}])}else y([{role:"assistant",content:"G'day! Bob from CARFIX here. How can I help ya today?"}])}},[(lr=b.vehicle)==null?void 0:lr.selectedVehicle,f.length]),d.useEffect(()=>{var it,at;const $=(it=b.vehicle)==null?void 0:it.selectedVehicle;if(!$||Y.current)return;const ee=$.vehicle_id??$.id,ie=Number.parseInt(String(ee),10);if(!Number.isFinite(ie)){console.warn("[BobWidget] Vehicle has invalid vehicle_id, cannot auto-fetch:",$);return}Y.current=!0;const fe={...$,vehicle_id:String(ie)},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:fe,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=C.onServicePackagesFound)==null||$e.call(C,Re.packages)),Re.type==="parts_found"&&Re.parts&&((Qe=C.onPartsFound)==null||Qe.call(C,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 fe,qe,nt,it,at,ot,$e,Qe,Ce,ut,ct,_e;const ee=`${j.supabaseUrl}/functions/v1/bob-chat`,ie=(fe=b.user)==null?void 0:fe.email;try{const Se={messages:[...f,$],hostConfig:k,hostContext:b};A&&(Se.vehicleContext=A),ie&&(Se.customerEmail=ie);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=C.onError)==null||qe.call(C,new Error("Rate limit exceeded"));return}if(Fe.status===402){(nt=C.onError)==null||nt.call(C,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 te=JSON.parse(dr);if(te.type==="vehicle_identified"&&te.vehicle){B(te.vehicle),(it=C.onVehicleIdentified)==null||it.call(C,te.vehicle);continue}if(te.type==="service_packages_found"&&te.packages){(at=C.onServicePackagesFound)==null||at.call(C,te.packages);continue}if(te.type==="parts_found"&&te.parts){(ot=C.onPartsFound)==null||ot.call(C,te.parts);continue}if(te.type==="no_parts_found"){N==null||N();continue}if(te.type==="cart_updated"&&te.items){($e=C.onCartUpdated)==null||$e.call(C,te.items);continue}const Kt=(ut=(Ce=(Qe=te.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((zt,yr)=>yr===dt.length-1?{...zt,content:Vt}:zt):[...dt,{role:"assistant",content:Vt}]}),(ct=C.onBobMessage)==null||ct.call(C,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;S==null||S({brand:me,price:parseFloat(Ke)})}!E&&U.current.trim()?(se.current=!1,Be(),J(U.current),he.current=setTimeout(()=>{se.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=C.onError)==null||_e.call(C,Se instanceof Error?Se:new Error("Unknown error")),e||we(u)}},Rt=async()=>{if(!x.trim()||_)return;rt();const $={role:"user",content:x};y(fe=>[...fe,$]),P("");const ee=x.toLowerCase();if(Un.some(fe=>ee.includes(fe))){const fe=`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:fe}]),E||J(fe);return}M(!0),m==null||m(),e||we(s),await gr($),M(!1)};return{messages:f,input:x,setInput:P,isLoading:_,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:E,toggleMute:()=>{R($=>!$),E||rt()},isSpeaking:ar,identifiedVehicle:A,clearVehicle:()=>{B(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:S,error:N}=await r.storage.from("bob-images").list();if(N)throw N;const T=(S||[]).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:S,offsetsMap:N,scalesMap:T,availableStates:j}=d.useMemo(()=>{if(!w)return{imageUrlsMap:{},alternateImages:{},offsetsMap:{},scalesMap:{},availableStates:[]};const f={},y={},x={},P={},_=w.states.map(M=>M.state_key);return _.forEach(M=>{const E=w.configs.filter(D=>D.animation_state===M),R=E.map(D=>D.image_url),A=E.map(D=>D.vertical_offset||0),B=E.map(D=>D.scale||100);if(R.length>0){const D=w.states.find(Y=>Y.state_key===M);f[M]={url:R[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[M]=R,x[M]=A,P[M]=B}}),{imageUrlsMap:f,alternateImages:y,offsetsMap:x,scalesMap:P,availableStates:_}},[w]);return d.useEffect(()=>{h.current=g},[g]),d.useEffect(()=>{j.length>0&&!t&&e(j[0])},[j,t]),d.useEffect(()=>{const f=S[t];if(l.current&&clearInterval(l.current),f&&f.length>1){s(0);const y=h.current[t],x=(y==null?void 0:y.animation_speed)||a||400,P=(y==null?void 0:y.loop_count)||0,_=(y==null?void 0:y.pause_duration)||0;let M=0,E=!1;const R=()=>{l.current=setInterval(()=>{E||s(A=>{const B=(A+1)%f.length;return B===0&&(M++,P>0&&M>=P)?(clearInterval(l.current),_>0&&(E=!0,setTimeout(()=>{M=0,E=!1,R()},_)),A):B})},x)};R()}else s(0);return()=>{l.current&&clearInterval(l.current)}},[t,S]),{animationState:t,setAnimationState:e,getCurrentImage:()=>{const f=S[t];if(!f||f.length===0){const y=j.find(x=>{var P;return((P=S[x])==null?void 0:P.length)>0});return y?S[y][0]:""}return f[r]||f[0]},getCurrentOffset:()=>{const f=N[t];if(!f||f.length===0){const y=j.find(x=>{var P;return((P=N[x])==null?void 0:P.length)>0});return y?N[y][0]:0}return f[r]||f[0]},getCurrentScale:()=>{const f=T[t];if(!f||f.length===0){const y=j.find(x=>{var P;return((P=T[x])==null?void 0:P.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:S=>r(S.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((S,N)=>o.jsx("div",{className:`flex ${S.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 ${S.role==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-gray-100"}`,children:S.content})},N)),o.jsx("div",{ref:l})]})]})}),qr=({currentImage:t,animationState:e,counterOverlayUrl:r,counterHeightPercent:s=15,scale:a=100,position:u="center"})=>{const c=85*a/100,p=400*a/100,l=u==="center"?"-20%":"-35%";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}%`,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"}})}),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),S=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 C=S.find(f=>os(f.name,r));C&&h.current[C.name]&&((b=h.current[C.name])==null||b.scrollIntoView({behavior:"smooth",block:"start"}))}},[r,S]),d.useEffect(()=>{s&&g.current&&g.current.scrollIntoView({behavior:"smooth",block:"center"})},[s]);const N=t.length>0||e.length>0,T=c,j=N&&!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&&S.map(({name:b,products:C},f)=>{const y=r&&os(b,r);return o.jsxs("section",{ref:x=>{h.current[b]=x},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:["(",C.length,")"]})]}),o.jsx("div",{className:"space-y-2",children:C.map((x,P)=>{const _=s&&$n(x,s);return o.jsxs("div",{ref:_?g:void 0,onClick:()=>a==null?void 0:a(x),className:`cursor-pointer transition-all bg-white/80 rounded-lg border border-gray-200 relative ${_?"ring-4 ring-blue-600 scale-105 z-10":"hover:shadow-md"}`,children:[_&&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-gray-100 rounded-md mb-1 flex items-center justify-center overflow-hidden",children:x.image_url?o.jsx("img",{src:x.image_url,alt:x.name,className:"w-full h-full object-contain"}):o.jsx("svg",{className:"h-8 w-8 text-gray-400",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("p",{className:"text-xs font-medium line-clamp-2",children:x.name}),x.brand&&o.jsx("p",{className:"text-[10px] text-gray-500",children:x.brand})]}),o.jsx("div",{className:"px-2 pb-2",children:o.jsx("span",{className:"text-sm font-bold text-blue-600",children:x.price>0?`$${x.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:M=>{M.stopPropagation(),a==null||a(x)},children:"Buy Now"})})]},`${x.id}-${P}`)})})]},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,S]=d.useState(!1),N=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){S(!0);const x=new y;x.continuous=s==="ptt",x.interimResults=!0,x.lang=r,x.maxAlternatives=1,x.onstart=()=>{u(!0),h(null)},x.onresult=P=>{let _="",M="";for(let E=P.resultIndex;E<P.results.length;E++){const R=P.results[E][0].transcript;P.results[E].isFinal?M+=R:_+=R}M&&(T.current=M,p(M),j.current&&j.current(M)),w(_)},x.onerror=P=>{switch(u(!1),P.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.")}},x.onend=()=>{u(!1),w(""),T.current&&k.current&&k.current(T.current),T.current=""},N.current=x}return()=>{N.current&&N.current.stop()}},[r,s]);const b=()=>{N.current&&!a&&(p(""),w(""),h(null),N.current.start())},C=()=>{N.current&&a&&N.current.stop()};return{isListening:a,transcript:c,interimTranscript:l,error:m,isSupported:g,startListening:b,stopListening:C,toggleListening:()=>{a?C():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,S]=d.useState(!1),N=d.useRef(null),T=d.useRef(!1),{isListening:j,interimTranscript:k,error:b,isSupported:C,startListening:f,stopListening:y}=Qr({onTranscript:E=>r(E),language:"en-NZ",mode:"ptt"});d.useEffect(()=>{k&&r(k)},[k,r]);const x=d.useCallback(()=>{s||T.current||(T.current=!0,navigator.vibrate&&navigator.vibrate(10),f())},[s,f]),P=d.useCallback(()=>{T.current&&(T.current=!1,navigator.vibrate&&navigator.vibrate(10),y(),setTimeout(()=>{a()},150))},[y,a]),_=[...t].reverse().find(E=>E.role==="assistant"),M=_!=null&&_.content?_.content.length>50?_.content.slice(0,50)+"...":_.content:"Ask Bob about car parts...";return o.jsxs("div",{ref:N,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:()=>S(!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:()=>S(!0),children:o.jsx("p",{className:"text-xs text-gray-500 line-clamp-1",children:M})}),g&&o.jsxs("div",{className:"h-[calc(100%-100px)] overflow-y-auto p-4 space-y-2",children:[[...t].reverse().map((E,R)=>o.jsx("div",{className:`flex ${E.role==="user"?"justify-end":"justify-start"}`,children:o.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${E.role==="user"?"bg-blue-600 text-white":"bg-gray-100 text-gray-900"}`,children:E.content})},R)),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:E=>r(E.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"}),C&&o.jsx("button",{onTouchStart:x,onTouchEnd:P,onTouchCancel:P,onMouseDown:x,onMouseUp:P,onMouseLeave:P,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:S,isMuted:N,onToggleMute:T,isSpeaking:j,products:k,servicePackages:b,highlightedPartType:C,highlightedProduct:f,onProductClick:y,onPackageSelect:x,isResearching:P,vehicle:_,onChangeVehicle:M})=>{const E=typeof window<"u"&&window.self!==window.top,[R,A]=d.useState("center"),[B,D]=d.useState("hidden"),Y=k.length>0||b.length>0;d.useEffect(()=>{if(P&&B!=="loading"&&B!=="visible")D("loading"),R==="center"&&A("left");else if(Y&&B!=="visible")if(R==="center"){A("left"),D("transitioning");const U=setTimeout(()=>{D("visible")},400);return()=>clearTimeout(U)}else D("visible");else!Y&&!P&&B!=="hidden"&&(D("hidden"),A("center"))},[Y,P,B,R]);const xe=B!=="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:R}),_&&!E&&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:[_.year," ",_.make," ",_.model]}),_.rego&&o.jsx("p",{className:"text-[10px] text-gray-500",children:_.rego})]}),M&&o.jsx("button",{onClick:M,className:"text-xs text-blue-600 hover:underline ml-2 shrink-0",children:"Change"})]})}),o.jsx($r,{products:k,servicePackages:b,highlightedPartType:C,highlightedProduct:f,onProductClick:y,onPackageSelect:x,isResearching:P,visible:xe,counterHeightPercent:a,hasVehicle:!!_}),o.jsx(Ds,{messages:u,input:c,setInput:p,isLoading:l,onSend:w,onKeyPress:m,onInputFocus:h,onInputBlur:g,chatEndRef:S,isMuted:N,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,S]=d.useState(!1),N=d.useRef(null),T=d.useRef(!1),{isListening:j,interimTranscript:k,error:b,isSupported:C,startListening:f,stopListening:y}=Qr({onTranscript:E=>r(E),language:"en-NZ",mode:"ptt"});d.useEffect(()=>{k&&r(k)},[k,r]);const x=d.useCallback(()=>{s||T.current||(T.current=!0,navigator.vibrate&&navigator.vibrate(10),f())},[s,f]),P=d.useCallback(()=>{T.current&&(T.current=!1,navigator.vibrate&&navigator.vibrate(10),y(),setTimeout(()=>{a()},150))},[y,a]),_=[...t].reverse().find(E=>E.role==="assistant"),M=_!=null&&_.content?_.content.length>50?_.content.slice(0,50)+"...":_.content:"Ask Bob about car parts...";return o.jsxs("div",{ref:N,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},children:[o.jsx("button",{onClick:()=>S(!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:()=>S(!0),children:o.jsx("p",{className:"text-xs text-gray-500 line-clamp-1",children:M})}),g&&o.jsxs("div",{className:"h-[calc(100%-100px)] overflow-y-auto p-4 space-y-2",children:[[...t].reverse().map((E,R)=>o.jsx("div",{className:`flex ${E.role==="user"?"justify-end":"justify-start"}`,children:o.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${E.role==="user"?"bg-blue-600 text-white":"bg-gray-100 text-gray-900"}`,children:E.content})},R)),o.jsx("div",{ref:l})]}),o.jsxs("div",{className:`px-2 pb-2 ${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:E=>r(E.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"}),C&&o.jsx("button",{onTouchStart:x,onTouchEnd:P,onTouchCancel:P,onMouseDown:x,onMouseUp:P,onMouseLeave:P,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:S,isMuted:N,onToggleMute:T,isSpeaking:j,products:k,servicePackages:b,highlightedPartType:C,highlightedProduct:f,onProductClick:y,onPackageSelect:x,isResearching:P,vehicle:_,onChangeVehicle:M})=>{const[E,R]=d.useState("center"),[A,B]=d.useState("hidden"),D=k.length>0||b.length>0;d.useEffect(()=>{if(P&&A!=="loading"&&A!=="visible")B("loading"),E==="center"&&R("left");else if(D&&A!=="visible")if(E==="center"){R("left"),B("transitioning");const xe=setTimeout(()=>{B("visible")},400);return()=>clearTimeout(xe)}else B("visible");else!D&&!P&&A!=="hidden"&&(B("hidden"),R("center"))},[D,P,A,E]);const Y=A!=="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:200,position:E}),_&&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:[_.year," ",_.make," ",_.model]}),_.rego&&o.jsx("p",{className:"text-[10px] text-gray-500",children:_.rego})]}),M&&o.jsx("button",{onClick:M,className:"text-xs text-blue-600 hover:underline ml-2 shrink-0",children:"Change"})]})}),o.jsx($r,{products:k,servicePackages:b,highlightedPartType:C,highlightedProduct:f,onProductClick:y,onPackageSelect:x,isResearching:P,visible:Y,counterHeightPercent:a,hasVehicle:!!_}),o.jsx(Us,{messages:u,input:c,setInput:p,isLoading:l,onSend:w,onKeyPress:m,onInputFocus:h,onInputBlur:g,chatEndRef:S,isMuted:N,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:S,availableStates:N,isLoading:T}=Ms(),{activeBackdrop:j}=Fs(),[k,b]=d.useState([]),[C,f]=d.useState([]),[y,x]=d.useState(null),[P,_]=d.useState(null),[M,E]=d.useState(!1),R=Is({setAnimationState:g,manualMode:!1,onReadyToSpeak:()=>{console.log("[BobWidget] Ready to speak")},onStreamComplete:()=>{g(N.find(U=>U.includes("idle"))||"idle")},onResearchStart:()=>{E(!0)},onHighlightPart:U=>{x(U),setTimeout(()=>x(null),8e3)},onHighlightProduct:U=>{_(U),setTimeout(()=>_(null),8e3)},onAutoFetchComplete:()=>{E(!1)}});d.useEffect(()=>{const U=m.onPartsFound,se=m.onServicePackagesFound;return m.onPartsFound=he=>{E(!1);const Be=he.map((J,rt)=>({id:J.SKU||J.sku||`part-${rt}`,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}));b(Be),U==null||U(he)},m.onServicePackagesFound=he=>{f(he),se==null||se(he)},()=>{m.onPartsFound=U,m.onServicePackagesFound=se}},[m]);const A=a||(j==null?void 0:j.image_url),B=u||(j==null?void 0:j.counter_overlay_url)||void 0,D=c||(j==null?void 0:j.counter_height_percent)||12,Y=S()||p||"";if(t==="mobile"||t==="fullscreen")return o.jsx(Bs,{currentImage:Y,animationState:h,backdropUrl:A,counterOverlayUrl:B,counterHeightPercent:D,messages:R.messages,input:R.input,setInput:R.setInput,isLoading:R.isLoading,onSend:R.handleSend,onKeyPress:R.handleKeyPress,onInputFocus:R.handleInputFocus,onInputBlur:R.handleInputBlur,chatEndRef:R.chatEndRef,isMuted:R.isMuted,onToggleMute:R.toggleMute,isSpeaking:R.isSpeaking,products:k,servicePackages:C,highlightedPartType:y,highlightedProduct:P,onProductClick:U=>{var se;return(se=m.onAddToCart)==null?void 0:se.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:M,vehicle:R.identifiedVehicle});if(t==="inline"&&r)return o.jsx("div",{className:`relative w-full h-full ${s}`,children:o.jsx(qs,{currentImage:Y,animationState:h,backdropUrl:A,counterOverlayUrl:B,counterHeightPercent:D,messages:R.messages,input:R.input,setInput:R.setInput,isLoading:R.isLoading,onSend:R.handleSend,onKeyPress:R.handleKeyPress,onInputFocus:R.handleInputFocus,onInputBlur:R.handleInputBlur,chatEndRef:R.chatEndRef,isMuted:R.isMuted,onToggleMute:R.toggleMute,isSpeaking:R.isSpeaking,products:k,servicePackages:C,highlightedPartType:y,highlightedProduct:P,onProductClick:U=>{var se;return(se=m.onAddToCart)==null?void 0:se.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:M,vehicle:R.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:[Y&&o.jsx(As,{currentImage:Y,animationState:h,backdropUrl:A,counterOverlayUrl:B,counterHeightPercent:D,verticalOffset:l,scale:w}),r&&o.jsx(Ls,{messages:R.messages,input:R.input,setInput:R.setInput,isLoading:R.isLoading,onSend:R.handleSend,onKeyPress:R.handleKeyPress,onInputFocus:R.handleInputFocus,onInputBlur:R.handleInputBlur,chatEndRef:R.chatEndRef,isMuted:R.isMuted,onToggleMute:R.toggleMute,isSpeaking:R.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:S})=>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:S})}),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(x=>x.chat_trigger===y&&x.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 x=t.find(P=>P.state_key===y);return{speed:(x==null?void 0:x.animation_speed)||400,pauseDuration:(x==null?void 0:x.pause_duration)||0,loopCount:(x==null?void 0:x.loop_count)||0}},[t]),g=d.useCallback(()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]),S=d.useCallback(()=>{g(),!r&&(p.current=setTimeout(()=>{const y=m();y&&(a("idle"),e(y.state_key))},Wn))},[r,m,e,g]),N=d.useCallback(y=>{if(r)return;const x=l(y);x&&e(x.state_key)},[r,l,e]),T=d.useCallback(()=>{if(r)return;const y=w();y&&(a("awaiting_input"),e(y.state_key),S())},[r,w,e,S]),j=d.useCallback(()=>{u||r||(c(!0),a("page_load"),N("page_load"),setTimeout(()=>{T()},3e3))},[u,r,N,T]),k=d.useCallback(()=>{g(),a("processing_input"),N("processing_input")},[N,g]),b=d.useCallback(()=>{g(),a("streaming_response"),N("streaming_response")},[N,g]),C=d.useCallback(()=>{a("response_complete"),N("response_complete"),setTimeout(()=>{T()},3e3)},[N,T]),f=d.useCallback(()=>{a("showing_product");const y=t.find(x=>x.chat_trigger==="showing_product"||x.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:C,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;