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