@hiver/connector-agent 3.1.2 → 3.1.3-fixSearchBarVis-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/global-search/components/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,UAAU,iBAAiB;IACzB,cAAc,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACxC,iBAAiB,EAAE,QAAQ,CAAC,cAAc,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAAC;IACrE,kBAAkB,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACvD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CA2E9C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/global-search/components/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,UAAU,iBAAiB;IACzB,cAAc,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACxC,iBAAiB,EAAE,QAAQ,CAAC,cAAc,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAAC;IACrE,kBAAkB,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACvD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CA+E9C,CAAC"}
package/index.es.js CHANGED
@@ -16061,7 +16061,7 @@ const L4 = (e) => new Promise((t) => setTimeout(t, e)), F4 = ({
16061
16061
  }).filter((p) => !!p), [v, u]), d = (p) => {
16062
16062
  t(p), p && y("" + p.value);
16063
16063
  };
16064
- return /* @__PURE__ */ E.jsxs(Q, { children: [
16064
+ return f.length ? /* @__PURE__ */ E.jsxs(Q, { children: [
16065
16065
  /* @__PURE__ */ E.jsx(
16066
16066
  Gx,
16067
16067
  {
@@ -16084,7 +16084,7 @@ const L4 = (e) => new Promise((t) => setTimeout(t, e)), F4 = ({
16084
16084
  },
16085
16085
  e.value
16086
16086
  ) : null
16087
- ] });
16087
+ ] }) : null;
16088
16088
  }, j4 = "data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.00483%2012.5052C7.73146%2012.7786%207.73146%2013.2218%208.00483%2013.4952C8.2782%2013.7685%208.72141%2013.7685%208.99478%2013.4952L11.9948%2010.4952C12.2681%2010.2218%2012.2681%209.77859%2011.9948%209.50522L8.99478%206.50522C8.72141%206.23185%208.2782%206.23185%208.00483%206.50522C7.73146%206.77859%207.73146%207.2218%208.00483%207.49517L10.5099%2010.0002L8.00483%2012.5052Z'%20fill='%236C7B94'/%3e%3c/svg%3e", H4 = async ({ id: e, externalResourceId: t, conversationId: n, channelType: r = "email" }) => {
16089
16089
  const i = new URLSearchParams();
16090
16090
  i.append("channel_type", r), await vt({
package/index.umd.js CHANGED
@@ -847,7 +847,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
847
847
  color: ${x.theme.palette.gray.gray3};
848
848
  font-size: 11px;
849
849
  text-transform: uppercase;
850
- `,cx=({onSelect:e,selectedOption:t,options:n})=>n.length?E.jsxs(sx,{children:[E.jsx(ix,{children:NE}),E.jsx(ax,{children:PE}),n.map(r=>E.jsx(gf,{data:r,isSelected:t===r,onSelect:e},r.label+r.description))]}):null;var cr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},kn=typeof window>"u"||"Deno"in globalThis;function vt(){}function ux(e,t){return typeof e=="function"?e(t):e}function na(e){return typeof e=="number"&&e>=0&&e!==1/0}function mf(e,t){return Math.max(e+(t||0)-Date.now(),0)}function ur(e,t){return typeof e=="function"?e(t):e}function _t(e,t){return typeof e=="function"?e(t):e}function bf(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:s,queryKey:i,stale:c}=e;if(i){if(r){if(t.queryHash!==ra(i,t.options))return!1}else if(!Qr(t.queryKey,i))return!1}if(n!=="all"){const a=t.isActive();if(n==="active"&&!a||n==="inactive"&&a)return!1}return!(typeof c=="boolean"&&t.isStale()!==c||o&&o!==t.state.fetchStatus||s&&!s(t))}function yf(e,t){const{exact:n,status:r,predicate:o,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(Nn(t.options.mutationKey)!==Nn(s))return!1}else if(!Qr(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function ra(e,t){return((t==null?void 0:t.queryKeyHashFn)||Nn)(e)}function Nn(e){return JSON.stringify(e,(t,n)=>sa(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function Qr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!Qr(e[n],t[n])):!1}function oa(e,t){if(e===t)return e;const n=vf(e)&&vf(t);if(n||sa(e)&&sa(t)){const r=n?e:Object.keys(e),o=r.length,s=n?t:Object.keys(t),i=s.length,c=n?[]:{};let a=0;for(let u=0;u<i;u++){const l=n?u:s[u];(!n&&r.includes(l)||n)&&e[l]===void 0&&t[l]===void 0?(c[l]=void 0,a++):(c[l]=oa(e[l],t[l]),c[l]===e[l]&&e[l]!==void 0&&a++)}return o===i&&a===o?e:c}return t}function ms(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function vf(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function sa(e){if(!Cf(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Cf(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Cf(e){return Object.prototype.toString.call(e)==="[object Object]"}function lx(e){return new Promise(t=>{setTimeout(t,e)})}function ia(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return oa(e,t)}catch(r){console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`)}return oa(e,t)}return t}function dx(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function fx(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var bs=Symbol();function If(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===bs&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===bs?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var px=(Hf=class extends cr{constructor(){super();$(this,Pn);$(this,un);$(this,lr);W(this,lr,t=>{if(!kn&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){L(this,un)||this.setEventListener(L(this,lr))}onUnsubscribe(){var t;this.hasListeners()||((t=L(this,un))==null||t.call(this),W(this,un,void 0))}setEventListener(t){var n;W(this,lr,t),(n=L(this,un))==null||n.call(this),W(this,un,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){L(this,Pn)!==t&&(W(this,Pn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof L(this,Pn)=="boolean"?L(this,Pn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Pn=new WeakMap,un=new WeakMap,lr=new WeakMap,Hf),aa=new px,hx=(Wf=class extends cr{constructor(){super();$(this,dr,!0);$(this,ln);$(this,fr);W(this,fr,t=>{if(!kn&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){L(this,ln)||this.setEventListener(L(this,fr))}onUnsubscribe(){var t;this.hasListeners()||((t=L(this,ln))==null||t.call(this),W(this,ln,void 0))}setEventListener(t){var n;W(this,fr,t),(n=L(this,ln))==null||n.call(this),W(this,ln,t(this.setOnline.bind(this)))}setOnline(t){L(this,dr)!==t&&(W(this,dr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return L(this,dr)}},dr=new WeakMap,ln=new WeakMap,fr=new WeakMap,Wf),ys=new hx;function ca(){let e,t;const n=new Promise((o,s)=>{e=o,t=s});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}function gx(e){return Math.min(1e3*2**e,3e4)}function Ef(e){return(e??"online")==="online"?ys.isOnline():!0}var xf=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function ua(e){return e instanceof xf}function wf(e){let t=!1,n=0,r=!1,o;const s=ca(),i=p=>{var f;r||(y(new xf(p)),(f=e.abort)==null||f.call(e))},c=()=>{t=!0},a=()=>{t=!1},u=()=>aa.isFocused()&&(e.networkMode==="always"||ys.isOnline())&&e.canRun(),l=()=>Ef(e.networkMode)&&e.canRun(),g=p=>{var f;r||(r=!0,(f=e.onSuccess)==null||f.call(e,p),o==null||o(),s.resolve(p))},y=p=>{var f;r||(r=!0,(f=e.onError)==null||f.call(e,p),o==null||o(),s.reject(p))},v=()=>new Promise(p=>{var f;o=d=>{(r||u())&&p(d)},(f=e.onPause)==null||f.call(e)}).then(()=>{var p;o=void 0,r||(p=e.onContinue)==null||p.call(e)}),b=()=>{if(r)return;let p;const f=n===0?e.initialPromise:void 0;try{p=f??e.fn()}catch(d){p=Promise.reject(d)}Promise.resolve(p).then(g).catch(d=>{var w;if(r)return;const h=e.retry??(kn?0:3),m=e.retryDelay??gx,I=typeof m=="function"?m(n,d):m,C=h===!0||typeof h=="number"&&n<h||typeof h=="function"&&h(n,d);if(t||!C){y(d);return}n++,(w=e.onFail)==null||w.call(e,n,d),lx(I).then(()=>u()?void 0:v()).then(()=>{t?y(d):b()})})};return{promise:s,cancel:i,continue:()=>(o==null||o(),s),cancelRetry:c,continueRetry:a,canStart:l,start:()=>(l()?b():v().then(b),s)}}function mx(){let e=[],t=0,n=c=>{c()},r=c=>{c()},o=c=>setTimeout(c,0);const s=c=>{t?e.push(c):o(()=>{n(c)})},i=()=>{const c=e;e=[],c.length&&o(()=>{r(()=>{c.forEach(a=>{n(a)})})})};return{batch:c=>{let a;t++;try{a=c()}finally{t--,t||i()}return a},batchCalls:c=>(...a)=>{s(()=>{c(...a)})},schedule:s,setNotifyFunction:c=>{n=c},setBatchNotifyFunction:c=>{r=c},setScheduler:c=>{o=c}}}var Ge=mx(),Af=(Zf=class{constructor(){$(this,Mn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),na(this.gcTime)&&W(this,Mn,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(kn?1/0:5*60*1e3))}clearGcTimeout(){L(this,Mn)&&(clearTimeout(L(this,Mn)),W(this,Mn,void 0))}},Mn=new WeakMap,Zf),bx=(Xf=class extends Af{constructor(t){super();$(this,Ot);$(this,pr);$(this,hr);$(this,Ct);$(this,Bn);$(this,Ye);$(this,qr);$(this,Gn);W(this,Gn,!1),W(this,qr,t.defaultOptions),this.setOptions(t.options),this.observers=[],W(this,Bn,t.client),W(this,Ct,L(this,Bn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,W(this,pr,yx(this.options)),this.state=t.state??L(this,pr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=L(this,Ye))==null?void 0:t.promise}setOptions(t){this.options={...L(this,qr),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&L(this,Ct).remove(this)}setData(t,n){const r=ia(this.state.data,t,this.options);return ue(this,Ot,tn).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){ue(this,Ot,tn).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=L(this,Ye))==null?void 0:r.promise;return(o=L(this,Ye))==null||o.cancel(t),n?n.then(vt).catch(vt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(L(this,pr))}isActive(){return this.observers.some(t=>_t(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===bs||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(t=0){return this.state.isInvalidated||this.state.data===void 0||!mf(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=L(this,Ye))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=L(this,Ye))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),L(this,Ct).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(L(this,Ye)&&(L(this,Gn)?L(this,Ye).cancel({revert:!0}):L(this,Ye).cancelRetry()),this.scheduleGc()),L(this,Ct).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ue(this,Ot,tn).call(this,{type:"invalidate"})}fetch(t,n){var a,u,l;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(L(this,Ye))return L(this,Ye).continueRetry(),L(this,Ye).promise}if(t&&this.setOptions(t),!this.options.queryFn){const g=this.observers.find(y=>y.options.queryFn);g&&this.setOptions(g.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(W(this,Gn,!0),r.signal)})},s=()=>{const g=If(this.options,n),y={client:L(this,Bn),queryKey:this.queryKey,meta:this.meta};return o(y),W(this,Gn,!1),this.options.persister?this.options.persister(g,y,this):g(y)},i={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:L(this,Bn),state:this.state,fetchFn:s};o(i),(a=this.options.behavior)==null||a.onFetch(i,this),W(this,hr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=i.fetchOptions)==null?void 0:u.meta))&&ue(this,Ot,tn).call(this,{type:"fetch",meta:(l=i.fetchOptions)==null?void 0:l.meta});const c=g=>{var y,v,b,p;ua(g)&&g.silent||ue(this,Ot,tn).call(this,{type:"error",error:g}),ua(g)||((v=(y=L(this,Ct).config).onError)==null||v.call(y,g,this),(p=(b=L(this,Ct).config).onSettled)==null||p.call(b,this.state.data,g,this)),this.scheduleGc()};return W(this,Ye,wf({initialPromise:n==null?void 0:n.initialPromise,fn:i.fetchFn,abort:r.abort.bind(r),onSuccess:g=>{var y,v,b,p;if(g===void 0){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}`),c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(g)}catch(f){c(f);return}(v=(y=L(this,Ct).config).onSuccess)==null||v.call(y,g,this),(p=(b=L(this,Ct).config).onSettled)==null||p.call(b,g,this.state.error,this),this.scheduleGc()},onError:c,onFail:(g,y)=>{ue(this,Ot,tn).call(this,{type:"failed",failureCount:g,error:y})},onPause:()=>{ue(this,Ot,tn).call(this,{type:"pause"})},onContinue:()=>{ue(this,Ot,tn).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),L(this,Ye).start()}},pr=new WeakMap,hr=new WeakMap,Ct=new WeakMap,Bn=new WeakMap,Ye=new WeakMap,qr=new WeakMap,Gn=new WeakMap,Ot=new WeakSet,tn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Tf(r.data,this.options),fetchMeta:t.meta??null};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return ua(o)&&o.revert&&L(this,hr)?{...L(this,hr),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Ge.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),L(this,Ct).notify({query:this,type:"updated",action:t})})},Xf);function Tf(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ef(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function yx(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var vx=(zf=class extends cr{constructor(t={}){super();$(this,Ht);this.config=t,W(this,Ht,new Map)}build(t,n,r){const o=n.queryKey,s=n.queryHash??ra(o,n);let i=this.get(s);return i||(i=new bx({client:t,queryKey:o,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(i)),i}add(t){L(this,Ht).has(t.queryHash)||(L(this,Ht).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=L(this,Ht).get(t.queryHash);n&&(t.destroy(),n===t&&L(this,Ht).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ge.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return L(this,Ht).get(t)}getAll(){return[...L(this,Ht).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>bf(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>bf(t,r)):n}notify(t){Ge.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Ge.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ge.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ht=new WeakMap,zf),Cx=(Yf=class extends Af{constructor(t){super();$(this,Zt);$(this,Wt);$(this,Ue);$(this,jn);this.mutationId=t.mutationId,W(this,Ue,t.mutationCache),W(this,Wt,[]),this.state=t.state||Sf(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){L(this,Wt).includes(t)||(L(this,Wt).push(t),this.clearGcTimeout(),L(this,Ue).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){W(this,Wt,L(this,Wt).filter(n=>n!==t)),this.scheduleGc(),L(this,Ue).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){L(this,Wt).length||(this.state.status==="pending"?this.scheduleGc():L(this,Ue).remove(this))}continue(){var t;return((t=L(this,jn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,s,i,c,a,u,l,g,y,v,b,p,f,d,h,m,I,C,w,A;W(this,jn,wf({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(T,_)=>{ue(this,Zt,vn).call(this,{type:"failed",failureCount:T,error:_})},onPause:()=>{ue(this,Zt,vn).call(this,{type:"pause"})},onContinue:()=>{ue(this,Zt,vn).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>L(this,Ue).canRun(this)}));const n=this.state.status==="pending",r=!L(this,jn).canStart();try{if(!n){ue(this,Zt,vn).call(this,{type:"pending",variables:t,isPaused:r}),await((s=(o=L(this,Ue).config).onMutate)==null?void 0:s.call(o,t,this));const _=await((c=(i=this.options).onMutate)==null?void 0:c.call(i,t));_!==this.state.context&&ue(this,Zt,vn).call(this,{type:"pending",context:_,variables:t,isPaused:r})}const T=await L(this,jn).start();return await((u=(a=L(this,Ue).config).onSuccess)==null?void 0:u.call(a,T,t,this.state.context,this)),await((g=(l=this.options).onSuccess)==null?void 0:g.call(l,T,t,this.state.context)),await((v=(y=L(this,Ue).config).onSettled)==null?void 0:v.call(y,T,null,this.state.variables,this.state.context,this)),await((p=(b=this.options).onSettled)==null?void 0:p.call(b,T,null,t,this.state.context)),ue(this,Zt,vn).call(this,{type:"success",data:T}),T}catch(T){try{throw await((d=(f=L(this,Ue).config).onError)==null?void 0:d.call(f,T,t,this.state.context,this)),await((m=(h=this.options).onError)==null?void 0:m.call(h,T,t,this.state.context)),await((C=(I=L(this,Ue).config).onSettled)==null?void 0:C.call(I,void 0,T,this.state.variables,this.state.context,this)),await((A=(w=this.options).onSettled)==null?void 0:A.call(w,void 0,T,t,this.state.context)),T}finally{ue(this,Zt,vn).call(this,{type:"error",error:T})}}finally{L(this,Ue).runNext(this)}}},Wt=new WeakMap,Ue=new WeakMap,jn=new WeakMap,Zt=new WeakSet,vn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Ge.batch(()=>{L(this,Wt).forEach(r=>{r.onMutationUpdate(t)}),L(this,Ue).notify({mutation:this,type:"updated",action:t})})},Yf);function Sf(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ix=(Jf=class extends cr{constructor(t={}){super();$(this,$t);$(this,Lt);$(this,$r);this.config=t,W(this,$t,new Set),W(this,Lt,new Map),W(this,$r,0)}build(t,n,r){const o=new Cx({mutationCache:this,mutationId:++Cs(this,$r)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){L(this,$t).add(t);const n=vs(t);if(typeof n=="string"){const r=L(this,Lt).get(n);r?r.push(t):L(this,Lt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(L(this,$t).delete(t)){const n=vs(t);if(typeof n=="string"){const r=L(this,Lt).get(n);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&L(this,Lt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=vs(t);if(typeof n=="string"){const r=L(this,Lt).get(n),o=r==null?void 0:r.find(s=>s.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const n=vs(t);if(typeof n=="string"){const o=(r=L(this,Lt).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Ge.batch(()=>{L(this,$t).forEach(t=>{this.notify({type:"removed",mutation:t})}),L(this,$t).clear(),L(this,Lt).clear()})}getAll(){return Array.from(L(this,$t))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>yf(n,r))}findAll(t={}){return this.getAll().filter(n=>yf(t,n))}notify(t){Ge.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Ge.batch(()=>Promise.all(t.map(n=>n.continue().catch(vt))))}},$t=new WeakMap,Lt=new WeakMap,$r=new WeakMap,Jf);function vs(e){var t;return(t=e.options.scope)==null?void 0:t.id}function _f(e){return{onFetch:(t,n)=>{var l,g,y,v,b;const r=t.options,o=(y=(g=(l=t.fetchOptions)==null?void 0:l.meta)==null?void 0:g.fetchMore)==null?void 0:y.direction,s=((v=t.state.data)==null?void 0:v.pages)||[],i=((b=t.state.data)==null?void 0:b.pageParams)||[];let c={pages:[],pageParams:[]},a=0;const u=async()=>{let p=!1;const f=m=>{Object.defineProperty(m,"signal",{enumerable:!0,get:()=>(t.signal.aborted?p=!0:t.signal.addEventListener("abort",()=>{p=!0}),t.signal)})},d=If(t.options,t.fetchOptions),h=async(m,I,C)=>{if(p)return Promise.reject();if(I==null&&m.pages.length)return Promise.resolve(m);const w={client:t.client,queryKey:t.queryKey,pageParam:I,direction:C?"backward":"forward",meta:t.options.meta};f(w);const A=await d(w),{maxPages:T}=t.options,_=C?fx:dx;return{pages:_(m.pages,A,T),pageParams:_(m.pageParams,I,T)}};if(o&&s.length){const m=o==="backward",I=m?Ex:Of,C={pages:s,pageParams:i},w=I(r,C);c=await h(C,w,m)}else{const m=e??s.length;do{const I=a===0?i[0]??r.initialPageParam:Of(r,c);if(a>0&&I==null)break;c=await h(c,I),a++}while(a<m)}return c};t.options.persister?t.fetchFn=()=>{var p,f;return(f=(p=t.options).persister)==null?void 0:f.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Of(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ex(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var xx=(Uf=class{constructor(e={}){$(this,De);$(this,dn);$(this,fn);$(this,gr);$(this,mr);$(this,pn);$(this,br);$(this,yr);W(this,De,e.queryCache||new vx),W(this,dn,e.mutationCache||new Ix),W(this,fn,e.defaultOptions||{}),W(this,gr,new Map),W(this,mr,new Map),W(this,pn,0)}mount(){Cs(this,pn)._++,L(this,pn)===1&&(W(this,br,aa.subscribe(async e=>{e&&(await this.resumePausedMutations(),L(this,De).onFocus())})),W(this,yr,ys.subscribe(async e=>{e&&(await this.resumePausedMutations(),L(this,De).onOnline())})))}unmount(){var e,t;Cs(this,pn)._--,L(this,pn)===0&&((e=L(this,br))==null||e.call(this),W(this,br,void 0),(t=L(this,yr))==null||t.call(this),W(this,yr,void 0))}isFetching(e){return L(this,De).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return L(this,dn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=L(this,De).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=L(this,De).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(ur(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return L(this,De).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=L(this,De).get(r.queryHash),s=o==null?void 0:o.state.data,i=ux(t,s);if(i!==void 0)return L(this,De).build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Ge.batch(()=>L(this,De).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=L(this,De).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=L(this,De);Ge.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=L(this,De);return Ge.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ge.batch(()=>L(this,De).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(vt).catch(vt)}invalidateQueries(e,t={}){return Ge.batch(()=>(L(this,De).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ge.batch(()=>L(this,De).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let s=o.fetch(void 0,n);return n.throwOnError||(s=s.catch(vt)),o.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(vt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=L(this,De).build(this,t);return n.isStaleByTime(ur(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(vt).catch(vt)}fetchInfiniteQuery(e){return e.behavior=_f(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(vt).catch(vt)}ensureInfiniteQueryData(e){return e.behavior=_f(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ys.isOnline()?L(this,dn).resumePausedMutations():Promise.resolve()}getQueryCache(){return L(this,De)}getMutationCache(){return L(this,dn)}getDefaultOptions(){return L(this,fn)}setDefaultOptions(e){W(this,fn,e)}setQueryDefaults(e,t){L(this,gr).set(Nn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...L(this,gr).values()],n={};return t.forEach(r=>{Qr(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){L(this,mr).set(Nn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...L(this,mr).values()],n={};return t.forEach(r=>{Qr(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...L(this,fn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ra(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===bs&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...L(this,fn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){L(this,De).clear(),L(this,dn).clear()}},De=new WeakMap,dn=new WeakMap,fn=new WeakMap,gr=new WeakMap,mr=new WeakMap,pn=new WeakMap,br=new WeakMap,yr=new WeakMap,Uf),wx=(Qf=class extends cr{constructor(t,n){super();$(this,we);$(this,it);$(this,fe);$(this,Kr);$(this,Qe);$(this,Vn);$(this,vr);$(this,hn);$(this,Xt);$(this,eo);$(this,Cr);$(this,Ir);$(this,Hn);$(this,Wn);$(this,gn);$(this,Er,new Set);this.options=n,W(this,it,t),W(this,Xt,null),W(this,hn,ca()),this.options.experimental_prefetchInRender||L(this,hn).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(L(this,fe).addObserver(this),Lf(L(this,fe),this.options)?ue(this,we,ro).call(this):this.updateResult(),ue(this,we,Aa).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return la(L(this,fe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return la(L(this,fe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ue(this,we,Ta).call(this),ue(this,we,Sa).call(this),L(this,fe).removeObserver(this)}setOptions(t,n){const r=this.options,o=L(this,fe);if(this.options=L(this,it).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof _t(this.options.enabled,L(this,fe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ue(this,we,_a).call(this),L(this,fe).setOptions(this.options),r._defaulted&&!ms(this.options,r)&&L(this,it).getQueryCache().notify({type:"observerOptionsUpdated",query:L(this,fe),observer:this});const s=this.hasListeners();s&&Rf(L(this,fe),o,this.options,r)&&ue(this,we,ro).call(this),this.updateResult(n),s&&(L(this,fe)!==o||_t(this.options.enabled,L(this,fe))!==_t(r.enabled,L(this,fe))||ur(this.options.staleTime,L(this,fe))!==ur(r.staleTime,L(this,fe)))&&ue(this,we,Ea).call(this);const i=ue(this,we,xa).call(this);s&&(L(this,fe)!==o||_t(this.options.enabled,L(this,fe))!==_t(r.enabled,L(this,fe))||i!==L(this,gn))&&ue(this,we,wa).call(this,i)}getOptimisticResult(t){const n=L(this,it).getQueryCache().build(L(this,it),t),r=this.createResult(n,t);return Tx(this,r)&&(W(this,Qe,r),W(this,vr,this.options),W(this,Vn,L(this,fe).state)),r}getCurrentResult(){return L(this,Qe)}trackResult(t,n){const r={};return Object.keys(t).forEach(o=>{Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(o),n==null||n(o),t[o])})}),r}trackProp(t){L(this,Er).add(t)}getCurrentQuery(){return L(this,fe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=L(this,it).defaultQueryOptions(t),r=L(this,it).getQueryCache().build(L(this,it),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return ue(this,we,ro).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),L(this,Qe)))}createResult(t,n){var T;const r=L(this,fe),o=this.options,s=L(this,Qe),i=L(this,Vn),c=L(this,vr),u=t!==r?t.state:L(this,Kr),{state:l}=t;let g={...l},y=!1,v;if(n._optimisticResults){const _=this.hasListeners(),k=!_&&Lf(t,n),R=_&&Rf(t,r,n,o);(k||R)&&(g={...g,...Tf(l.data,t.options)}),n._optimisticResults==="isRestoring"&&(g.fetchStatus="idle")}let{error:b,errorUpdatedAt:p,status:f}=g;if(n.select&&g.data!==void 0)if(s&&g.data===(i==null?void 0:i.data)&&n.select===L(this,eo))v=L(this,Cr);else try{W(this,eo,n.select),v=n.select(g.data),v=ia(s==null?void 0:s.data,v,n),W(this,Cr,v),W(this,Xt,null)}catch(_){W(this,Xt,_)}else v=g.data;if(n.placeholderData!==void 0&&v===void 0&&f==="pending"){let _;if(s!=null&&s.isPlaceholderData&&n.placeholderData===(c==null?void 0:c.placeholderData))_=s.data;else if(_=typeof n.placeholderData=="function"?n.placeholderData((T=L(this,Ir))==null?void 0:T.state.data,L(this,Ir)):n.placeholderData,n.select&&_!==void 0)try{_=n.select(_),W(this,Xt,null)}catch(k){W(this,Xt,k)}_!==void 0&&(f="success",v=ia(s==null?void 0:s.data,_,n),y=!0)}L(this,Xt)&&(b=L(this,Xt),v=L(this,Cr),p=Date.now(),f="error");const d=g.fetchStatus==="fetching",h=f==="pending",m=f==="error",I=h&&d,C=v!==void 0,A={status:f,fetchStatus:g.fetchStatus,isPending:h,isSuccess:f==="success",isError:m,isInitialLoading:I,isLoading:I,data:v,dataUpdatedAt:g.dataUpdatedAt,error:b,errorUpdatedAt:p,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>u.dataUpdateCount||g.errorUpdateCount>u.errorUpdateCount,isFetching:d,isRefetching:d&&!h,isLoadingError:m&&!C,isPaused:g.fetchStatus==="paused",isPlaceholderData:y,isRefetchError:m&&C,isStale:da(t,n),refetch:this.refetch,promise:L(this,hn)};if(this.options.experimental_prefetchInRender){const _=N=>{A.status==="error"?N.reject(A.error):A.data!==void 0&&N.resolve(A.data)},k=()=>{const N=W(this,hn,A.promise=ca());_(N)},R=L(this,hn);switch(R.status){case"pending":t.queryHash===r.queryHash&&_(R);break;case"fulfilled":(A.status==="error"||A.data!==R.value)&&k();break;case"rejected":(A.status!=="error"||A.error!==R.reason)&&k();break}}return A}updateResult(t){const n=L(this,Qe),r=this.createResult(L(this,fe),this.options);if(W(this,Vn,L(this,fe).state),W(this,vr,this.options),L(this,Vn).data!==void 0&&W(this,Ir,L(this,fe)),ms(r,n))return;W(this,Qe,r);const o={},s=()=>{if(!n)return!0;const{notifyOnChangeProps:i}=this.options,c=typeof i=="function"?i():i;if(c==="all"||!c&&!L(this,Er).size)return!0;const a=new Set(c??L(this,Er));return this.options.throwOnError&&a.add("error"),Object.keys(L(this,Qe)).some(u=>{const l=u;return L(this,Qe)[l]!==n[l]&&a.has(l)})};(t==null?void 0:t.listeners)!==!1&&s()&&(o.listeners=!0),ue(this,we,l0).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ue(this,we,Aa).call(this)}},it=new WeakMap,fe=new WeakMap,Kr=new WeakMap,Qe=new WeakMap,Vn=new WeakMap,vr=new WeakMap,hn=new WeakMap,Xt=new WeakMap,eo=new WeakMap,Cr=new WeakMap,Ir=new WeakMap,Hn=new WeakMap,Wn=new WeakMap,gn=new WeakMap,Er=new WeakMap,we=new WeakSet,ro=function(t){ue(this,we,_a).call(this);let n=L(this,fe).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(vt)),n},Ea=function(){ue(this,we,Ta).call(this);const t=ur(this.options.staleTime,L(this,fe));if(kn||L(this,Qe).isStale||!na(t))return;const r=mf(L(this,Qe).dataUpdatedAt,t)+1;W(this,Hn,setTimeout(()=>{L(this,Qe).isStale||this.updateResult()},r))},xa=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(L(this,fe)):this.options.refetchInterval)??!1},wa=function(t){ue(this,we,Sa).call(this),W(this,gn,t),!(kn||_t(this.options.enabled,L(this,fe))===!1||!na(L(this,gn))||L(this,gn)===0)&&W(this,Wn,setInterval(()=>{(this.options.refetchIntervalInBackground||aa.isFocused())&&ue(this,we,ro).call(this)},L(this,gn)))},Aa=function(){ue(this,we,Ea).call(this),ue(this,we,wa).call(this,ue(this,we,xa).call(this))},Ta=function(){L(this,Hn)&&(clearTimeout(L(this,Hn)),W(this,Hn,void 0))},Sa=function(){L(this,Wn)&&(clearInterval(L(this,Wn)),W(this,Wn,void 0))},_a=function(){const t=L(this,it).getQueryCache().build(L(this,it),this.options);if(t===L(this,fe))return;const n=L(this,fe);W(this,fe,t),W(this,Kr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},l0=function(t){Ge.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(L(this,Qe))}),L(this,it).getQueryCache().notify({query:L(this,fe),type:"observerResultsUpdated"})})},Qf);function Ax(e,t){return _t(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Lf(e,t){return Ax(e,t)||e.state.data!==void 0&&la(e,t,t.refetchOnMount)}function la(e,t,n){if(_t(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&da(e,t)}return!1}function Rf(e,t,n,r){return(e!==t||_t(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&da(e,n)}function da(e,t){return _t(t.enabled,e)!==!1&&e.isStaleByTime(ur(t.staleTime,e))}function Tx(e,t){return!ms(e.getCurrentResult(),t)}var Sx=(qf=class extends cr{constructor(t,n){super();$(this,en);$(this,mn);$(this,bn);$(this,at);$(this,Kt);W(this,mn,t),this.setOptions(n),this.bindMethods(),ue(this,en,Is).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=L(this,mn).defaultMutationOptions(t),ms(this.options,n)||L(this,mn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:L(this,at),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Nn(n.mutationKey)!==Nn(this.options.mutationKey)?this.reset():((r=L(this,at))==null?void 0:r.state.status)==="pending"&&L(this,at).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=L(this,at))==null||t.removeObserver(this)}onMutationUpdate(t){ue(this,en,Is).call(this),ue(this,en,Oa).call(this,t)}getCurrentResult(){return L(this,bn)}reset(){var t;(t=L(this,at))==null||t.removeObserver(this),W(this,at,void 0),ue(this,en,Is).call(this),ue(this,en,Oa).call(this)}mutate(t,n){var r;return W(this,Kt,n),(r=L(this,at))==null||r.removeObserver(this),W(this,at,L(this,mn).getMutationCache().build(L(this,mn),this.options)),L(this,at).addObserver(this),L(this,at).execute(t)}},mn=new WeakMap,bn=new WeakMap,at=new WeakMap,Kt=new WeakMap,en=new WeakSet,Is=function(){var n;const t=((n=L(this,at))==null?void 0:n.state)??Sf();W(this,bn,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Oa=function(t){Ge.batch(()=>{var n,r,o,s,i,c,a,u;if(L(this,Kt)&&this.hasListeners()){const l=L(this,bn).variables,g=L(this,bn).context;(t==null?void 0:t.type)==="success"?((r=(n=L(this,Kt)).onSuccess)==null||r.call(n,t.data,l,g),(s=(o=L(this,Kt)).onSettled)==null||s.call(o,t.data,null,l,g)):(t==null?void 0:t.type)==="error"&&((c=(i=L(this,Kt)).onError)==null||c.call(i,t.error,l,g),(u=(a=L(this,Kt)).onSettled)==null||u.call(a,void 0,t.error,l,g))}this.listeners.forEach(l=>{l(L(this,bn))})})},qf),Ff=B.createContext(void 0),Df=e=>{const t=B.useContext(Ff);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},_x=({client:e,children:t})=>(B.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),E.jsx(Ff.Provider,{value:e,children:t})),kf=B.createContext(!1),Ox=()=>B.useContext(kf);kf.Provider;function Lx(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Rx=B.createContext(Lx()),Fx=()=>B.useContext(Rx);function Nf(e,t){return typeof e=="function"?e(...t):!!e}function fa(){}var Dx=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},kx=e=>{B.useEffect(()=>{e.clearReset()},[e])},Nx=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||Nf(n,[e.error,r])),Px=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...n)=>Math.max(t(...n),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},Mx=(e,t)=>e.isLoading&&e.isFetching&&!t,Bx=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Pf=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Gx(e,t,n){var g,y,v,b,p;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=Df(),o=Ox(),s=Fx(),i=r.defaultQueryOptions(e);(y=(g=r.getDefaultOptions().queries)==null?void 0:g._experimental_beforeQuery)==null||y.call(g,i),process.env.NODE_ENV!=="production"&&(i.queryFn||console.error(`[${i.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`)),i._optimisticResults=o?"isRestoring":"optimistic",Px(i),Dx(i,s),kx(s);const c=!r.getQueryCache().get(i.queryHash),[a]=B.useState(()=>new t(r,i)),u=a.getOptimisticResult(i),l=!o&&e.subscribed!==!1;if(B.useSyncExternalStore(B.useCallback(f=>{const d=l?a.subscribe(Ge.batchCalls(f)):fa;return a.updateResult(),d},[a,l]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),B.useEffect(()=>{a.setOptions(i,{listeners:!1})},[i,a]),Bx(i,u))throw Pf(i,a,s);if(Nx({result:u,errorResetBoundary:s,throwOnError:i.throwOnError,query:r.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw u.error;if((b=(v=r.getDefaultOptions().queries)==null?void 0:v._experimental_afterQuery)==null||b.call(v,i,u),i.experimental_prefetchInRender&&!kn&&Mx(u,o)){const f=c?Pf(i,a,s):(p=r.getQueryCache().get(i.queryHash))==null?void 0:p.promise;f==null||f.catch(fa).finally(()=>{a.updateResult()})}return i.notifyOnChangeProps?u:a.trackResult(u)}function Mf(e,t){return Gx(e,wx)}function Bf(e,t){const n=Df(),[r]=B.useState(()=>new Sx(n,e));B.useEffect(()=>{r.setOptions(e)},[r,e]);const o=B.useSyncExternalStore(B.useCallback(i=>r.subscribe(Ge.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=B.useCallback((i,c)=>{r.mutate(i,c).catch(fa)},[r]);if(o.error&&Nf(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:s,mutateAsync:o.mutate}}const jx=e=>new Promise(t=>setTimeout(t,e)),Vx=({apiFn:e,intervalMillis:t,maxRetries:n,isSatisfied:r})=>(...s)=>{const i=async(c=0)=>{const a=await e(...s);if(r(a))return a;if(c>=n)throw a;return c++,jx(t).then(()=>i(c))};return i()},Hx=async({conversationId:e,senderEmail:t})=>{try{const n=await rt({url:Pr(ib,{conversationId:e}),params:{senderEmail:t},method:pt.GET});return n==null?void 0:n.data}catch(n){throw console.error(n),n}},Gf=({conversationId:e,senderEmail:t,enabled:n})=>Mf({queryKey:["Global","ConversationMetaData",e,t],queryFn:()=>Hx({conversationId:e,senderEmail:t}),refetchOnMount:!1,enabled:n}),jf="/v1/api",Wx=`${jf}/connectors/forms/:formId/search`,Zx=`${jf}/connectors/conversation/:conversationId/smart-suggestions`,Xx=e=>{if(e.status!=="completed")return e;const t=e.smart_suggestions??[],n=[];for(const r of t)n.push({label:r.search_string,description:`${r.connector_name??""} - ${r.object_name??""}`,avatarUrl:r.connector_logo,value:r.form_id,connectorName:r.connector_name,objectName:r.object_name});return{...e,suggestedOptions:n}},zx=Vx({apiFn:async({conversationId:e})=>{try{const t=await rt({url:Pr(Zx,{conversationId:e}),method:pt.GET}),n=t==null?void 0:t.data;return Xx(n)}catch(t){throw console.error(t),t}},intervalMillis:1500,maxRetries:5,isSatisfied:e=>e.status!=="pending"}),Yx=({conversationId:e,senderEmail:t,enabled:n})=>{const{isSuccess:r}=Gf({conversationId:e,senderEmail:t,enabled:n});return Mf({queryKey:["GlobalSearch","SmartSuggestions",e],queryFn:()=>zx({conversationId:e}),enabled:n&&r})},Jx=({selectedObject:e,setSelectedObject:t,fetchSearchResults:n,onReset:r})=>{const[o,s]=S.useState(""),{conversationId:i,email:c,availableFeatures:a}=S.useContext(Ke),u=me(RE),l=me(hf),g=St(a,ig),{sortedObjectList:y,updatePriority:v}=ox({objectList:u}),{data:b}=Yx({enabled:g&&!!i,conversationId:String(i),senderEmail:c}),p=(b==null?void 0:b.suggestedOptions)??[],f=S.useMemo(()=>!l||!y.length?[]:y.map(({value:h})=>{const m=l[h];return m?{description:`${m.connectorName??""} - ${m.searchObject}`,avatarUrl:m.logoUrl,label:"",value:h,connectorName:m.connectorName,objectName:m.searchObject}:null}).filter(h=>!!h),[y,l]),d=h=>{t(h),h&&v(""+h.value)};return E.jsxs(x.Stack,{children:[E.jsx(JE,{value:e,options:f.map(h=>({...h,label:o})),inputValue:o,onInputChange:s,onChange:d,onReset:r,NoOptionsMessage:({selectOption:h})=>E.jsx(cx,{selectedOption:e,onSelect:h,options:p}),menuOpen:!o&&!p.length?!1:void 0}),e?E.jsx(QE,{objectId:e.value,searchString:e.label,fetchSearchResults:n},e.value):null]})},Ux="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.00483%2012.5052C7.73146%2012.7786%207.73146%2013.2218%208.00483%2013.4952C8.2782%2013.7685%208.72141%2013.7685%208.99478%2013.4952L11.9948%2010.4952C12.2681%2010.2218%2012.2681%209.77859%2011.9948%209.50522L8.99478%206.50522C8.72141%206.23185%208.2782%206.23185%208.00483%206.50522C7.73146%206.77859%207.73146%207.2218%208.00483%207.49517L10.5099%2010.0002L8.00483%2012.5052Z'%20fill='%236C7B94'/%3e%3c/svg%3e",Qx=async({id:e,externalResourceId:t,conversationId:n,channelType:r="email"})=>{const o=new URLSearchParams;o.append("channel_type",r),await rt({url:`${cb.replace(":id",e)}?${o.toString()}`,method:pt.POST,data:{externalResourceId:t,conversationId:n}})},qx=({onSuccess:e})=>Bf({mutationFn:Qx,onSuccess:()=>{ke({message:S1,type:cn}),e==null||e()},onError:()=>{ke({message:_1,type:mt})}}),$x="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_8444_63907)'%3e%3cpath%20d='M7.99967%2013.333L8.93967%2012.393L5.21968%208.66634H13.333V7.33301L5.21968%207.33301L8.93967%203.60634L7.99967%202.66634L2.66634%207.99967L7.99967%2013.333Z'%20fill='%23343C45'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_8444_63907'%3e%3crect%20width='16'%20height='16'%20fill='white'%20transform='matrix(-1%200%200%20-1%2016%2016)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",Kx=x.styled(x.Stack)`
850
+ `,cx=({onSelect:e,selectedOption:t,options:n})=>n.length?E.jsxs(sx,{children:[E.jsx(ix,{children:NE}),E.jsx(ax,{children:PE}),n.map(r=>E.jsx(gf,{data:r,isSelected:t===r,onSelect:e},r.label+r.description))]}):null;var cr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},kn=typeof window>"u"||"Deno"in globalThis;function vt(){}function ux(e,t){return typeof e=="function"?e(t):e}function na(e){return typeof e=="number"&&e>=0&&e!==1/0}function mf(e,t){return Math.max(e+(t||0)-Date.now(),0)}function ur(e,t){return typeof e=="function"?e(t):e}function _t(e,t){return typeof e=="function"?e(t):e}function bf(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:s,queryKey:i,stale:c}=e;if(i){if(r){if(t.queryHash!==ra(i,t.options))return!1}else if(!Qr(t.queryKey,i))return!1}if(n!=="all"){const a=t.isActive();if(n==="active"&&!a||n==="inactive"&&a)return!1}return!(typeof c=="boolean"&&t.isStale()!==c||o&&o!==t.state.fetchStatus||s&&!s(t))}function yf(e,t){const{exact:n,status:r,predicate:o,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(Nn(t.options.mutationKey)!==Nn(s))return!1}else if(!Qr(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function ra(e,t){return((t==null?void 0:t.queryKeyHashFn)||Nn)(e)}function Nn(e){return JSON.stringify(e,(t,n)=>sa(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function Qr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!Qr(e[n],t[n])):!1}function oa(e,t){if(e===t)return e;const n=vf(e)&&vf(t);if(n||sa(e)&&sa(t)){const r=n?e:Object.keys(e),o=r.length,s=n?t:Object.keys(t),i=s.length,c=n?[]:{};let a=0;for(let u=0;u<i;u++){const l=n?u:s[u];(!n&&r.includes(l)||n)&&e[l]===void 0&&t[l]===void 0?(c[l]=void 0,a++):(c[l]=oa(e[l],t[l]),c[l]===e[l]&&e[l]!==void 0&&a++)}return o===i&&a===o?e:c}return t}function ms(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function vf(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function sa(e){if(!Cf(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Cf(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Cf(e){return Object.prototype.toString.call(e)==="[object Object]"}function lx(e){return new Promise(t=>{setTimeout(t,e)})}function ia(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return oa(e,t)}catch(r){console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`)}return oa(e,t)}return t}function dx(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function fx(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var bs=Symbol();function If(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===bs&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===bs?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var px=(Hf=class extends cr{constructor(){super();$(this,Pn);$(this,un);$(this,lr);W(this,lr,t=>{if(!kn&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){L(this,un)||this.setEventListener(L(this,lr))}onUnsubscribe(){var t;this.hasListeners()||((t=L(this,un))==null||t.call(this),W(this,un,void 0))}setEventListener(t){var n;W(this,lr,t),(n=L(this,un))==null||n.call(this),W(this,un,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){L(this,Pn)!==t&&(W(this,Pn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof L(this,Pn)=="boolean"?L(this,Pn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Pn=new WeakMap,un=new WeakMap,lr=new WeakMap,Hf),aa=new px,hx=(Wf=class extends cr{constructor(){super();$(this,dr,!0);$(this,ln);$(this,fr);W(this,fr,t=>{if(!kn&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){L(this,ln)||this.setEventListener(L(this,fr))}onUnsubscribe(){var t;this.hasListeners()||((t=L(this,ln))==null||t.call(this),W(this,ln,void 0))}setEventListener(t){var n;W(this,fr,t),(n=L(this,ln))==null||n.call(this),W(this,ln,t(this.setOnline.bind(this)))}setOnline(t){L(this,dr)!==t&&(W(this,dr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return L(this,dr)}},dr=new WeakMap,ln=new WeakMap,fr=new WeakMap,Wf),ys=new hx;function ca(){let e,t;const n=new Promise((o,s)=>{e=o,t=s});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}function gx(e){return Math.min(1e3*2**e,3e4)}function Ef(e){return(e??"online")==="online"?ys.isOnline():!0}var xf=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function ua(e){return e instanceof xf}function wf(e){let t=!1,n=0,r=!1,o;const s=ca(),i=p=>{var f;r||(y(new xf(p)),(f=e.abort)==null||f.call(e))},c=()=>{t=!0},a=()=>{t=!1},u=()=>aa.isFocused()&&(e.networkMode==="always"||ys.isOnline())&&e.canRun(),l=()=>Ef(e.networkMode)&&e.canRun(),g=p=>{var f;r||(r=!0,(f=e.onSuccess)==null||f.call(e,p),o==null||o(),s.resolve(p))},y=p=>{var f;r||(r=!0,(f=e.onError)==null||f.call(e,p),o==null||o(),s.reject(p))},v=()=>new Promise(p=>{var f;o=d=>{(r||u())&&p(d)},(f=e.onPause)==null||f.call(e)}).then(()=>{var p;o=void 0,r||(p=e.onContinue)==null||p.call(e)}),b=()=>{if(r)return;let p;const f=n===0?e.initialPromise:void 0;try{p=f??e.fn()}catch(d){p=Promise.reject(d)}Promise.resolve(p).then(g).catch(d=>{var w;if(r)return;const h=e.retry??(kn?0:3),m=e.retryDelay??gx,I=typeof m=="function"?m(n,d):m,C=h===!0||typeof h=="number"&&n<h||typeof h=="function"&&h(n,d);if(t||!C){y(d);return}n++,(w=e.onFail)==null||w.call(e,n,d),lx(I).then(()=>u()?void 0:v()).then(()=>{t?y(d):b()})})};return{promise:s,cancel:i,continue:()=>(o==null||o(),s),cancelRetry:c,continueRetry:a,canStart:l,start:()=>(l()?b():v().then(b),s)}}function mx(){let e=[],t=0,n=c=>{c()},r=c=>{c()},o=c=>setTimeout(c,0);const s=c=>{t?e.push(c):o(()=>{n(c)})},i=()=>{const c=e;e=[],c.length&&o(()=>{r(()=>{c.forEach(a=>{n(a)})})})};return{batch:c=>{let a;t++;try{a=c()}finally{t--,t||i()}return a},batchCalls:c=>(...a)=>{s(()=>{c(...a)})},schedule:s,setNotifyFunction:c=>{n=c},setBatchNotifyFunction:c=>{r=c},setScheduler:c=>{o=c}}}var Ge=mx(),Af=(Zf=class{constructor(){$(this,Mn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),na(this.gcTime)&&W(this,Mn,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(kn?1/0:5*60*1e3))}clearGcTimeout(){L(this,Mn)&&(clearTimeout(L(this,Mn)),W(this,Mn,void 0))}},Mn=new WeakMap,Zf),bx=(Xf=class extends Af{constructor(t){super();$(this,Ot);$(this,pr);$(this,hr);$(this,Ct);$(this,Bn);$(this,Ye);$(this,qr);$(this,Gn);W(this,Gn,!1),W(this,qr,t.defaultOptions),this.setOptions(t.options),this.observers=[],W(this,Bn,t.client),W(this,Ct,L(this,Bn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,W(this,pr,yx(this.options)),this.state=t.state??L(this,pr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=L(this,Ye))==null?void 0:t.promise}setOptions(t){this.options={...L(this,qr),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&L(this,Ct).remove(this)}setData(t,n){const r=ia(this.state.data,t,this.options);return ue(this,Ot,tn).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){ue(this,Ot,tn).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=L(this,Ye))==null?void 0:r.promise;return(o=L(this,Ye))==null||o.cancel(t),n?n.then(vt).catch(vt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(L(this,pr))}isActive(){return this.observers.some(t=>_t(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===bs||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(t=0){return this.state.isInvalidated||this.state.data===void 0||!mf(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=L(this,Ye))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=L(this,Ye))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),L(this,Ct).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(L(this,Ye)&&(L(this,Gn)?L(this,Ye).cancel({revert:!0}):L(this,Ye).cancelRetry()),this.scheduleGc()),L(this,Ct).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ue(this,Ot,tn).call(this,{type:"invalidate"})}fetch(t,n){var a,u,l;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(L(this,Ye))return L(this,Ye).continueRetry(),L(this,Ye).promise}if(t&&this.setOptions(t),!this.options.queryFn){const g=this.observers.find(y=>y.options.queryFn);g&&this.setOptions(g.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(W(this,Gn,!0),r.signal)})},s=()=>{const g=If(this.options,n),y={client:L(this,Bn),queryKey:this.queryKey,meta:this.meta};return o(y),W(this,Gn,!1),this.options.persister?this.options.persister(g,y,this):g(y)},i={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:L(this,Bn),state:this.state,fetchFn:s};o(i),(a=this.options.behavior)==null||a.onFetch(i,this),W(this,hr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=i.fetchOptions)==null?void 0:u.meta))&&ue(this,Ot,tn).call(this,{type:"fetch",meta:(l=i.fetchOptions)==null?void 0:l.meta});const c=g=>{var y,v,b,p;ua(g)&&g.silent||ue(this,Ot,tn).call(this,{type:"error",error:g}),ua(g)||((v=(y=L(this,Ct).config).onError)==null||v.call(y,g,this),(p=(b=L(this,Ct).config).onSettled)==null||p.call(b,this.state.data,g,this)),this.scheduleGc()};return W(this,Ye,wf({initialPromise:n==null?void 0:n.initialPromise,fn:i.fetchFn,abort:r.abort.bind(r),onSuccess:g=>{var y,v,b,p;if(g===void 0){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}`),c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(g)}catch(f){c(f);return}(v=(y=L(this,Ct).config).onSuccess)==null||v.call(y,g,this),(p=(b=L(this,Ct).config).onSettled)==null||p.call(b,g,this.state.error,this),this.scheduleGc()},onError:c,onFail:(g,y)=>{ue(this,Ot,tn).call(this,{type:"failed",failureCount:g,error:y})},onPause:()=>{ue(this,Ot,tn).call(this,{type:"pause"})},onContinue:()=>{ue(this,Ot,tn).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),L(this,Ye).start()}},pr=new WeakMap,hr=new WeakMap,Ct=new WeakMap,Bn=new WeakMap,Ye=new WeakMap,qr=new WeakMap,Gn=new WeakMap,Ot=new WeakSet,tn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Tf(r.data,this.options),fetchMeta:t.meta??null};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return ua(o)&&o.revert&&L(this,hr)?{...L(this,hr),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Ge.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),L(this,Ct).notify({query:this,type:"updated",action:t})})},Xf);function Tf(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ef(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function yx(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var vx=(zf=class extends cr{constructor(t={}){super();$(this,Ht);this.config=t,W(this,Ht,new Map)}build(t,n,r){const o=n.queryKey,s=n.queryHash??ra(o,n);let i=this.get(s);return i||(i=new bx({client:t,queryKey:o,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(i)),i}add(t){L(this,Ht).has(t.queryHash)||(L(this,Ht).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=L(this,Ht).get(t.queryHash);n&&(t.destroy(),n===t&&L(this,Ht).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ge.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return L(this,Ht).get(t)}getAll(){return[...L(this,Ht).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>bf(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>bf(t,r)):n}notify(t){Ge.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Ge.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ge.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ht=new WeakMap,zf),Cx=(Yf=class extends Af{constructor(t){super();$(this,Zt);$(this,Wt);$(this,Ue);$(this,jn);this.mutationId=t.mutationId,W(this,Ue,t.mutationCache),W(this,Wt,[]),this.state=t.state||Sf(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){L(this,Wt).includes(t)||(L(this,Wt).push(t),this.clearGcTimeout(),L(this,Ue).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){W(this,Wt,L(this,Wt).filter(n=>n!==t)),this.scheduleGc(),L(this,Ue).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){L(this,Wt).length||(this.state.status==="pending"?this.scheduleGc():L(this,Ue).remove(this))}continue(){var t;return((t=L(this,jn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,s,i,c,a,u,l,g,y,v,b,p,f,d,h,m,I,C,w,A;W(this,jn,wf({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(T,_)=>{ue(this,Zt,vn).call(this,{type:"failed",failureCount:T,error:_})},onPause:()=>{ue(this,Zt,vn).call(this,{type:"pause"})},onContinue:()=>{ue(this,Zt,vn).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>L(this,Ue).canRun(this)}));const n=this.state.status==="pending",r=!L(this,jn).canStart();try{if(!n){ue(this,Zt,vn).call(this,{type:"pending",variables:t,isPaused:r}),await((s=(o=L(this,Ue).config).onMutate)==null?void 0:s.call(o,t,this));const _=await((c=(i=this.options).onMutate)==null?void 0:c.call(i,t));_!==this.state.context&&ue(this,Zt,vn).call(this,{type:"pending",context:_,variables:t,isPaused:r})}const T=await L(this,jn).start();return await((u=(a=L(this,Ue).config).onSuccess)==null?void 0:u.call(a,T,t,this.state.context,this)),await((g=(l=this.options).onSuccess)==null?void 0:g.call(l,T,t,this.state.context)),await((v=(y=L(this,Ue).config).onSettled)==null?void 0:v.call(y,T,null,this.state.variables,this.state.context,this)),await((p=(b=this.options).onSettled)==null?void 0:p.call(b,T,null,t,this.state.context)),ue(this,Zt,vn).call(this,{type:"success",data:T}),T}catch(T){try{throw await((d=(f=L(this,Ue).config).onError)==null?void 0:d.call(f,T,t,this.state.context,this)),await((m=(h=this.options).onError)==null?void 0:m.call(h,T,t,this.state.context)),await((C=(I=L(this,Ue).config).onSettled)==null?void 0:C.call(I,void 0,T,this.state.variables,this.state.context,this)),await((A=(w=this.options).onSettled)==null?void 0:A.call(w,void 0,T,t,this.state.context)),T}finally{ue(this,Zt,vn).call(this,{type:"error",error:T})}}finally{L(this,Ue).runNext(this)}}},Wt=new WeakMap,Ue=new WeakMap,jn=new WeakMap,Zt=new WeakSet,vn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Ge.batch(()=>{L(this,Wt).forEach(r=>{r.onMutationUpdate(t)}),L(this,Ue).notify({mutation:this,type:"updated",action:t})})},Yf);function Sf(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ix=(Jf=class extends cr{constructor(t={}){super();$(this,$t);$(this,Lt);$(this,$r);this.config=t,W(this,$t,new Set),W(this,Lt,new Map),W(this,$r,0)}build(t,n,r){const o=new Cx({mutationCache:this,mutationId:++Cs(this,$r)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){L(this,$t).add(t);const n=vs(t);if(typeof n=="string"){const r=L(this,Lt).get(n);r?r.push(t):L(this,Lt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(L(this,$t).delete(t)){const n=vs(t);if(typeof n=="string"){const r=L(this,Lt).get(n);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&L(this,Lt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=vs(t);if(typeof n=="string"){const r=L(this,Lt).get(n),o=r==null?void 0:r.find(s=>s.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const n=vs(t);if(typeof n=="string"){const o=(r=L(this,Lt).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Ge.batch(()=>{L(this,$t).forEach(t=>{this.notify({type:"removed",mutation:t})}),L(this,$t).clear(),L(this,Lt).clear()})}getAll(){return Array.from(L(this,$t))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>yf(n,r))}findAll(t={}){return this.getAll().filter(n=>yf(t,n))}notify(t){Ge.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Ge.batch(()=>Promise.all(t.map(n=>n.continue().catch(vt))))}},$t=new WeakMap,Lt=new WeakMap,$r=new WeakMap,Jf);function vs(e){var t;return(t=e.options.scope)==null?void 0:t.id}function _f(e){return{onFetch:(t,n)=>{var l,g,y,v,b;const r=t.options,o=(y=(g=(l=t.fetchOptions)==null?void 0:l.meta)==null?void 0:g.fetchMore)==null?void 0:y.direction,s=((v=t.state.data)==null?void 0:v.pages)||[],i=((b=t.state.data)==null?void 0:b.pageParams)||[];let c={pages:[],pageParams:[]},a=0;const u=async()=>{let p=!1;const f=m=>{Object.defineProperty(m,"signal",{enumerable:!0,get:()=>(t.signal.aborted?p=!0:t.signal.addEventListener("abort",()=>{p=!0}),t.signal)})},d=If(t.options,t.fetchOptions),h=async(m,I,C)=>{if(p)return Promise.reject();if(I==null&&m.pages.length)return Promise.resolve(m);const w={client:t.client,queryKey:t.queryKey,pageParam:I,direction:C?"backward":"forward",meta:t.options.meta};f(w);const A=await d(w),{maxPages:T}=t.options,_=C?fx:dx;return{pages:_(m.pages,A,T),pageParams:_(m.pageParams,I,T)}};if(o&&s.length){const m=o==="backward",I=m?Ex:Of,C={pages:s,pageParams:i},w=I(r,C);c=await h(C,w,m)}else{const m=e??s.length;do{const I=a===0?i[0]??r.initialPageParam:Of(r,c);if(a>0&&I==null)break;c=await h(c,I),a++}while(a<m)}return c};t.options.persister?t.fetchFn=()=>{var p,f;return(f=(p=t.options).persister)==null?void 0:f.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Of(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ex(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var xx=(Uf=class{constructor(e={}){$(this,De);$(this,dn);$(this,fn);$(this,gr);$(this,mr);$(this,pn);$(this,br);$(this,yr);W(this,De,e.queryCache||new vx),W(this,dn,e.mutationCache||new Ix),W(this,fn,e.defaultOptions||{}),W(this,gr,new Map),W(this,mr,new Map),W(this,pn,0)}mount(){Cs(this,pn)._++,L(this,pn)===1&&(W(this,br,aa.subscribe(async e=>{e&&(await this.resumePausedMutations(),L(this,De).onFocus())})),W(this,yr,ys.subscribe(async e=>{e&&(await this.resumePausedMutations(),L(this,De).onOnline())})))}unmount(){var e,t;Cs(this,pn)._--,L(this,pn)===0&&((e=L(this,br))==null||e.call(this),W(this,br,void 0),(t=L(this,yr))==null||t.call(this),W(this,yr,void 0))}isFetching(e){return L(this,De).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return L(this,dn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=L(this,De).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=L(this,De).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(ur(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return L(this,De).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=L(this,De).get(r.queryHash),s=o==null?void 0:o.state.data,i=ux(t,s);if(i!==void 0)return L(this,De).build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Ge.batch(()=>L(this,De).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=L(this,De).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=L(this,De);Ge.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=L(this,De);return Ge.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ge.batch(()=>L(this,De).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(vt).catch(vt)}invalidateQueries(e,t={}){return Ge.batch(()=>(L(this,De).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ge.batch(()=>L(this,De).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let s=o.fetch(void 0,n);return n.throwOnError||(s=s.catch(vt)),o.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(vt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=L(this,De).build(this,t);return n.isStaleByTime(ur(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(vt).catch(vt)}fetchInfiniteQuery(e){return e.behavior=_f(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(vt).catch(vt)}ensureInfiniteQueryData(e){return e.behavior=_f(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ys.isOnline()?L(this,dn).resumePausedMutations():Promise.resolve()}getQueryCache(){return L(this,De)}getMutationCache(){return L(this,dn)}getDefaultOptions(){return L(this,fn)}setDefaultOptions(e){W(this,fn,e)}setQueryDefaults(e,t){L(this,gr).set(Nn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...L(this,gr).values()],n={};return t.forEach(r=>{Qr(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){L(this,mr).set(Nn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...L(this,mr).values()],n={};return t.forEach(r=>{Qr(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...L(this,fn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ra(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===bs&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...L(this,fn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){L(this,De).clear(),L(this,dn).clear()}},De=new WeakMap,dn=new WeakMap,fn=new WeakMap,gr=new WeakMap,mr=new WeakMap,pn=new WeakMap,br=new WeakMap,yr=new WeakMap,Uf),wx=(Qf=class extends cr{constructor(t,n){super();$(this,we);$(this,it);$(this,fe);$(this,Kr);$(this,Qe);$(this,Vn);$(this,vr);$(this,hn);$(this,Xt);$(this,eo);$(this,Cr);$(this,Ir);$(this,Hn);$(this,Wn);$(this,gn);$(this,Er,new Set);this.options=n,W(this,it,t),W(this,Xt,null),W(this,hn,ca()),this.options.experimental_prefetchInRender||L(this,hn).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(L(this,fe).addObserver(this),Lf(L(this,fe),this.options)?ue(this,we,ro).call(this):this.updateResult(),ue(this,we,Aa).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return la(L(this,fe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return la(L(this,fe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ue(this,we,Ta).call(this),ue(this,we,Sa).call(this),L(this,fe).removeObserver(this)}setOptions(t,n){const r=this.options,o=L(this,fe);if(this.options=L(this,it).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof _t(this.options.enabled,L(this,fe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ue(this,we,_a).call(this),L(this,fe).setOptions(this.options),r._defaulted&&!ms(this.options,r)&&L(this,it).getQueryCache().notify({type:"observerOptionsUpdated",query:L(this,fe),observer:this});const s=this.hasListeners();s&&Rf(L(this,fe),o,this.options,r)&&ue(this,we,ro).call(this),this.updateResult(n),s&&(L(this,fe)!==o||_t(this.options.enabled,L(this,fe))!==_t(r.enabled,L(this,fe))||ur(this.options.staleTime,L(this,fe))!==ur(r.staleTime,L(this,fe)))&&ue(this,we,Ea).call(this);const i=ue(this,we,xa).call(this);s&&(L(this,fe)!==o||_t(this.options.enabled,L(this,fe))!==_t(r.enabled,L(this,fe))||i!==L(this,gn))&&ue(this,we,wa).call(this,i)}getOptimisticResult(t){const n=L(this,it).getQueryCache().build(L(this,it),t),r=this.createResult(n,t);return Tx(this,r)&&(W(this,Qe,r),W(this,vr,this.options),W(this,Vn,L(this,fe).state)),r}getCurrentResult(){return L(this,Qe)}trackResult(t,n){const r={};return Object.keys(t).forEach(o=>{Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(o),n==null||n(o),t[o])})}),r}trackProp(t){L(this,Er).add(t)}getCurrentQuery(){return L(this,fe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=L(this,it).defaultQueryOptions(t),r=L(this,it).getQueryCache().build(L(this,it),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return ue(this,we,ro).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),L(this,Qe)))}createResult(t,n){var T;const r=L(this,fe),o=this.options,s=L(this,Qe),i=L(this,Vn),c=L(this,vr),u=t!==r?t.state:L(this,Kr),{state:l}=t;let g={...l},y=!1,v;if(n._optimisticResults){const _=this.hasListeners(),k=!_&&Lf(t,n),R=_&&Rf(t,r,n,o);(k||R)&&(g={...g,...Tf(l.data,t.options)}),n._optimisticResults==="isRestoring"&&(g.fetchStatus="idle")}let{error:b,errorUpdatedAt:p,status:f}=g;if(n.select&&g.data!==void 0)if(s&&g.data===(i==null?void 0:i.data)&&n.select===L(this,eo))v=L(this,Cr);else try{W(this,eo,n.select),v=n.select(g.data),v=ia(s==null?void 0:s.data,v,n),W(this,Cr,v),W(this,Xt,null)}catch(_){W(this,Xt,_)}else v=g.data;if(n.placeholderData!==void 0&&v===void 0&&f==="pending"){let _;if(s!=null&&s.isPlaceholderData&&n.placeholderData===(c==null?void 0:c.placeholderData))_=s.data;else if(_=typeof n.placeholderData=="function"?n.placeholderData((T=L(this,Ir))==null?void 0:T.state.data,L(this,Ir)):n.placeholderData,n.select&&_!==void 0)try{_=n.select(_),W(this,Xt,null)}catch(k){W(this,Xt,k)}_!==void 0&&(f="success",v=ia(s==null?void 0:s.data,_,n),y=!0)}L(this,Xt)&&(b=L(this,Xt),v=L(this,Cr),p=Date.now(),f="error");const d=g.fetchStatus==="fetching",h=f==="pending",m=f==="error",I=h&&d,C=v!==void 0,A={status:f,fetchStatus:g.fetchStatus,isPending:h,isSuccess:f==="success",isError:m,isInitialLoading:I,isLoading:I,data:v,dataUpdatedAt:g.dataUpdatedAt,error:b,errorUpdatedAt:p,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>u.dataUpdateCount||g.errorUpdateCount>u.errorUpdateCount,isFetching:d,isRefetching:d&&!h,isLoadingError:m&&!C,isPaused:g.fetchStatus==="paused",isPlaceholderData:y,isRefetchError:m&&C,isStale:da(t,n),refetch:this.refetch,promise:L(this,hn)};if(this.options.experimental_prefetchInRender){const _=N=>{A.status==="error"?N.reject(A.error):A.data!==void 0&&N.resolve(A.data)},k=()=>{const N=W(this,hn,A.promise=ca());_(N)},R=L(this,hn);switch(R.status){case"pending":t.queryHash===r.queryHash&&_(R);break;case"fulfilled":(A.status==="error"||A.data!==R.value)&&k();break;case"rejected":(A.status!=="error"||A.error!==R.reason)&&k();break}}return A}updateResult(t){const n=L(this,Qe),r=this.createResult(L(this,fe),this.options);if(W(this,Vn,L(this,fe).state),W(this,vr,this.options),L(this,Vn).data!==void 0&&W(this,Ir,L(this,fe)),ms(r,n))return;W(this,Qe,r);const o={},s=()=>{if(!n)return!0;const{notifyOnChangeProps:i}=this.options,c=typeof i=="function"?i():i;if(c==="all"||!c&&!L(this,Er).size)return!0;const a=new Set(c??L(this,Er));return this.options.throwOnError&&a.add("error"),Object.keys(L(this,Qe)).some(u=>{const l=u;return L(this,Qe)[l]!==n[l]&&a.has(l)})};(t==null?void 0:t.listeners)!==!1&&s()&&(o.listeners=!0),ue(this,we,l0).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ue(this,we,Aa).call(this)}},it=new WeakMap,fe=new WeakMap,Kr=new WeakMap,Qe=new WeakMap,Vn=new WeakMap,vr=new WeakMap,hn=new WeakMap,Xt=new WeakMap,eo=new WeakMap,Cr=new WeakMap,Ir=new WeakMap,Hn=new WeakMap,Wn=new WeakMap,gn=new WeakMap,Er=new WeakMap,we=new WeakSet,ro=function(t){ue(this,we,_a).call(this);let n=L(this,fe).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(vt)),n},Ea=function(){ue(this,we,Ta).call(this);const t=ur(this.options.staleTime,L(this,fe));if(kn||L(this,Qe).isStale||!na(t))return;const r=mf(L(this,Qe).dataUpdatedAt,t)+1;W(this,Hn,setTimeout(()=>{L(this,Qe).isStale||this.updateResult()},r))},xa=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(L(this,fe)):this.options.refetchInterval)??!1},wa=function(t){ue(this,we,Sa).call(this),W(this,gn,t),!(kn||_t(this.options.enabled,L(this,fe))===!1||!na(L(this,gn))||L(this,gn)===0)&&W(this,Wn,setInterval(()=>{(this.options.refetchIntervalInBackground||aa.isFocused())&&ue(this,we,ro).call(this)},L(this,gn)))},Aa=function(){ue(this,we,Ea).call(this),ue(this,we,wa).call(this,ue(this,we,xa).call(this))},Ta=function(){L(this,Hn)&&(clearTimeout(L(this,Hn)),W(this,Hn,void 0))},Sa=function(){L(this,Wn)&&(clearInterval(L(this,Wn)),W(this,Wn,void 0))},_a=function(){const t=L(this,it).getQueryCache().build(L(this,it),this.options);if(t===L(this,fe))return;const n=L(this,fe);W(this,fe,t),W(this,Kr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},l0=function(t){Ge.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(L(this,Qe))}),L(this,it).getQueryCache().notify({query:L(this,fe),type:"observerResultsUpdated"})})},Qf);function Ax(e,t){return _t(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Lf(e,t){return Ax(e,t)||e.state.data!==void 0&&la(e,t,t.refetchOnMount)}function la(e,t,n){if(_t(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&da(e,t)}return!1}function Rf(e,t,n,r){return(e!==t||_t(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&da(e,n)}function da(e,t){return _t(t.enabled,e)!==!1&&e.isStaleByTime(ur(t.staleTime,e))}function Tx(e,t){return!ms(e.getCurrentResult(),t)}var Sx=(qf=class extends cr{constructor(t,n){super();$(this,en);$(this,mn);$(this,bn);$(this,at);$(this,Kt);W(this,mn,t),this.setOptions(n),this.bindMethods(),ue(this,en,Is).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=L(this,mn).defaultMutationOptions(t),ms(this.options,n)||L(this,mn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:L(this,at),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Nn(n.mutationKey)!==Nn(this.options.mutationKey)?this.reset():((r=L(this,at))==null?void 0:r.state.status)==="pending"&&L(this,at).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=L(this,at))==null||t.removeObserver(this)}onMutationUpdate(t){ue(this,en,Is).call(this),ue(this,en,Oa).call(this,t)}getCurrentResult(){return L(this,bn)}reset(){var t;(t=L(this,at))==null||t.removeObserver(this),W(this,at,void 0),ue(this,en,Is).call(this),ue(this,en,Oa).call(this)}mutate(t,n){var r;return W(this,Kt,n),(r=L(this,at))==null||r.removeObserver(this),W(this,at,L(this,mn).getMutationCache().build(L(this,mn),this.options)),L(this,at).addObserver(this),L(this,at).execute(t)}},mn=new WeakMap,bn=new WeakMap,at=new WeakMap,Kt=new WeakMap,en=new WeakSet,Is=function(){var n;const t=((n=L(this,at))==null?void 0:n.state)??Sf();W(this,bn,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Oa=function(t){Ge.batch(()=>{var n,r,o,s,i,c,a,u;if(L(this,Kt)&&this.hasListeners()){const l=L(this,bn).variables,g=L(this,bn).context;(t==null?void 0:t.type)==="success"?((r=(n=L(this,Kt)).onSuccess)==null||r.call(n,t.data,l,g),(s=(o=L(this,Kt)).onSettled)==null||s.call(o,t.data,null,l,g)):(t==null?void 0:t.type)==="error"&&((c=(i=L(this,Kt)).onError)==null||c.call(i,t.error,l,g),(u=(a=L(this,Kt)).onSettled)==null||u.call(a,void 0,t.error,l,g))}this.listeners.forEach(l=>{l(L(this,bn))})})},qf),Ff=B.createContext(void 0),Df=e=>{const t=B.useContext(Ff);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},_x=({client:e,children:t})=>(B.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),E.jsx(Ff.Provider,{value:e,children:t})),kf=B.createContext(!1),Ox=()=>B.useContext(kf);kf.Provider;function Lx(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Rx=B.createContext(Lx()),Fx=()=>B.useContext(Rx);function Nf(e,t){return typeof e=="function"?e(...t):!!e}function fa(){}var Dx=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},kx=e=>{B.useEffect(()=>{e.clearReset()},[e])},Nx=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||Nf(n,[e.error,r])),Px=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...n)=>Math.max(t(...n),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},Mx=(e,t)=>e.isLoading&&e.isFetching&&!t,Bx=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Pf=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Gx(e,t,n){var g,y,v,b,p;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=Df(),o=Ox(),s=Fx(),i=r.defaultQueryOptions(e);(y=(g=r.getDefaultOptions().queries)==null?void 0:g._experimental_beforeQuery)==null||y.call(g,i),process.env.NODE_ENV!=="production"&&(i.queryFn||console.error(`[${i.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`)),i._optimisticResults=o?"isRestoring":"optimistic",Px(i),Dx(i,s),kx(s);const c=!r.getQueryCache().get(i.queryHash),[a]=B.useState(()=>new t(r,i)),u=a.getOptimisticResult(i),l=!o&&e.subscribed!==!1;if(B.useSyncExternalStore(B.useCallback(f=>{const d=l?a.subscribe(Ge.batchCalls(f)):fa;return a.updateResult(),d},[a,l]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),B.useEffect(()=>{a.setOptions(i,{listeners:!1})},[i,a]),Bx(i,u))throw Pf(i,a,s);if(Nx({result:u,errorResetBoundary:s,throwOnError:i.throwOnError,query:r.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw u.error;if((b=(v=r.getDefaultOptions().queries)==null?void 0:v._experimental_afterQuery)==null||b.call(v,i,u),i.experimental_prefetchInRender&&!kn&&Mx(u,o)){const f=c?Pf(i,a,s):(p=r.getQueryCache().get(i.queryHash))==null?void 0:p.promise;f==null||f.catch(fa).finally(()=>{a.updateResult()})}return i.notifyOnChangeProps?u:a.trackResult(u)}function Mf(e,t){return Gx(e,wx)}function Bf(e,t){const n=Df(),[r]=B.useState(()=>new Sx(n,e));B.useEffect(()=>{r.setOptions(e)},[r,e]);const o=B.useSyncExternalStore(B.useCallback(i=>r.subscribe(Ge.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=B.useCallback((i,c)=>{r.mutate(i,c).catch(fa)},[r]);if(o.error&&Nf(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:s,mutateAsync:o.mutate}}const jx=e=>new Promise(t=>setTimeout(t,e)),Vx=({apiFn:e,intervalMillis:t,maxRetries:n,isSatisfied:r})=>(...s)=>{const i=async(c=0)=>{const a=await e(...s);if(r(a))return a;if(c>=n)throw a;return c++,jx(t).then(()=>i(c))};return i()},Hx=async({conversationId:e,senderEmail:t})=>{try{const n=await rt({url:Pr(ib,{conversationId:e}),params:{senderEmail:t},method:pt.GET});return n==null?void 0:n.data}catch(n){throw console.error(n),n}},Gf=({conversationId:e,senderEmail:t,enabled:n})=>Mf({queryKey:["Global","ConversationMetaData",e,t],queryFn:()=>Hx({conversationId:e,senderEmail:t}),refetchOnMount:!1,enabled:n}),jf="/v1/api",Wx=`${jf}/connectors/forms/:formId/search`,Zx=`${jf}/connectors/conversation/:conversationId/smart-suggestions`,Xx=e=>{if(e.status!=="completed")return e;const t=e.smart_suggestions??[],n=[];for(const r of t)n.push({label:r.search_string,description:`${r.connector_name??""} - ${r.object_name??""}`,avatarUrl:r.connector_logo,value:r.form_id,connectorName:r.connector_name,objectName:r.object_name});return{...e,suggestedOptions:n}},zx=Vx({apiFn:async({conversationId:e})=>{try{const t=await rt({url:Pr(Zx,{conversationId:e}),method:pt.GET}),n=t==null?void 0:t.data;return Xx(n)}catch(t){throw console.error(t),t}},intervalMillis:1500,maxRetries:5,isSatisfied:e=>e.status!=="pending"}),Yx=({conversationId:e,senderEmail:t,enabled:n})=>{const{isSuccess:r}=Gf({conversationId:e,senderEmail:t,enabled:n});return Mf({queryKey:["GlobalSearch","SmartSuggestions",e],queryFn:()=>zx({conversationId:e}),enabled:n&&r})},Jx=({selectedObject:e,setSelectedObject:t,fetchSearchResults:n,onReset:r})=>{const[o,s]=S.useState(""),{conversationId:i,email:c,availableFeatures:a}=S.useContext(Ke),u=me(RE),l=me(hf),g=St(a,ig),{sortedObjectList:y,updatePriority:v}=ox({objectList:u}),{data:b}=Yx({enabled:g&&!!i,conversationId:String(i),senderEmail:c}),p=(b==null?void 0:b.suggestedOptions)??[],f=S.useMemo(()=>!l||!y.length?[]:y.map(({value:h})=>{const m=l[h];return m?{description:`${m.connectorName??""} - ${m.searchObject}`,avatarUrl:m.logoUrl,label:"",value:h,connectorName:m.connectorName,objectName:m.searchObject}:null}).filter(h=>!!h),[y,l]),d=h=>{t(h),h&&v(""+h.value)};return f.length?E.jsxs(x.Stack,{children:[E.jsx(JE,{value:e,options:f.map(h=>({...h,label:o})),inputValue:o,onInputChange:s,onChange:d,onReset:r,NoOptionsMessage:({selectOption:h})=>E.jsx(cx,{selectedOption:e,onSelect:h,options:p}),menuOpen:!o&&!p.length?!1:void 0}),e?E.jsx(QE,{objectId:e.value,searchString:e.label,fetchSearchResults:n},e.value):null]}):null},Ux="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.00483%2012.5052C7.73146%2012.7786%207.73146%2013.2218%208.00483%2013.4952C8.2782%2013.7685%208.72141%2013.7685%208.99478%2013.4952L11.9948%2010.4952C12.2681%2010.2218%2012.2681%209.77859%2011.9948%209.50522L8.99478%206.50522C8.72141%206.23185%208.2782%206.23185%208.00483%206.50522C7.73146%206.77859%207.73146%207.2218%208.00483%207.49517L10.5099%2010.0002L8.00483%2012.5052Z'%20fill='%236C7B94'/%3e%3c/svg%3e",Qx=async({id:e,externalResourceId:t,conversationId:n,channelType:r="email"})=>{const o=new URLSearchParams;o.append("channel_type",r),await rt({url:`${cb.replace(":id",e)}?${o.toString()}`,method:pt.POST,data:{externalResourceId:t,conversationId:n}})},qx=({onSuccess:e})=>Bf({mutationFn:Qx,onSuccess:()=>{ke({message:S1,type:cn}),e==null||e()},onError:()=>{ke({message:_1,type:mt})}}),$x="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_8444_63907)'%3e%3cpath%20d='M7.99967%2013.333L8.93967%2012.393L5.21968%208.66634H13.333V7.33301L5.21968%207.33301L8.93967%203.60634L7.99967%202.66634L2.66634%207.99967L7.99967%2013.333Z'%20fill='%23343C45'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_8444_63907'%3e%3crect%20width='16'%20height='16'%20fill='white'%20transform='matrix(-1%200%200%20-1%2016%2016)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",Kx=x.styled(x.Stack)`
851
851
  width: fit-content;
852
852
  cursor: pointer;
853
853
  gap: 8px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiver/connector-agent",
3
- "version": "3.1.2",
3
+ "version": "3.1.3-fixSearchBarVis-beta.0",
4
4
  "main": "index.es.js",
5
5
  "module": "index.es.js",
6
6
  "types": "index.d.ts",