@ahoo-wang/fetcher-react 2.6.10 → 2.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,7 +1,7 @@
1
- (function(C,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("react"),require("@ahoo-wang/fetcher")):typeof define=="function"&&define.amd?define(["exports","react","@ahoo-wang/fetcher"],h):(C=typeof globalThis<"u"?globalThis:C||self,h(C.FetcherReact={},C.React,C.Fetcher))})(this,(function(C,h,x){"use strict";function se(){const e=h.useRef(!1),t=h.useCallback(()=>e.current,[]);return h.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),t}function Y(e){const t=h.useRef(e);return t.current=e,t}var Ae=(e=>(e.IDLE="idle",e.LOADING="loading",e.SUCCESS="success",e.ERROR="error",e))(Ae||{});function ye(e){const[t,r]=h.useState(e?.initialStatus??"idle"),[a,s]=h.useState(void 0),[u,f]=h.useState(void 0),T=se(),w=Y(e),b=h.useCallback(()=>{T()&&(r("loading"),f(void 0))},[T]),M=h.useCallback(async R=>{if(T()){s(R),r("success"),f(void 0);try{await w.current?.onSuccess?.(R)}catch(O){console.warn("PromiseState onSuccess callback error:",O)}}},[T,w]),_=h.useCallback(async R=>{if(T()){f(R),r("error"),s(void 0);try{await w.current?.onError?.(R)}catch(O){console.warn("PromiseState onError callback error:",O)}}},[T,w]),P=h.useCallback(()=>{T()&&(r("idle"),f(void 0),s(void 0))},[T]);return h.useMemo(()=>({status:t,loading:t==="loading",result:a,error:u,setLoading:b,setSuccess:M,setError:_,setIdle:P}),[t,a,u,b,M,_,P])}function ve(){const e=h.useRef(0),t=h.useCallback(()=>++e.current,[]),r=h.useCallback(()=>e.current,[]),a=h.useCallback(f=>f===e.current,[]),s=h.useCallback(()=>{e.current++},[]),u=h.useCallback(()=>{e.current=0},[]);return h.useMemo(()=>({generate:t,current:r,isLatest:a,invalidate:s,reset:u}),[t,r,a,s,u])}function z(e){const t=ye(e),r=se(),a=ve(),s=h.useCallback(async f=>{if(!r())throw new Error("Component is unmounted");const T=a.generate();t.setLoading();try{const b=await(typeof f=="function"?f():f);return r()&&a.isLatest(T)&&await t.setSuccess(b),b}catch(w){if(r()&&a.isLatest(T)&&await t.setError(w),e?.propagateError)throw w;return w}},[t,r,a,e]),u=h.useCallback(()=>{r()&&t.setIdle()},[t,r]);return h.useMemo(()=>({loading:t.loading,result:t.result,error:t.error,execute:s,reset:u,status:t.status}),[t.loading,t.result,t.error,s,u,t.status])}function rt(e){const t=h.useCallback(u=>e.addListener(u),[e]),r=h.useCallback(()=>e.get(),[e]),a=h.useSyncExternalStore(t,r,r),s=h.useCallback(u=>e.set(u),[e]);return[a,s]}function nt(e){const{fetcher:t=x.fetcherRegistrar.default}=e||{},r=ye(e),[a,s]=h.useState(void 0),u=se(),f=h.useRef(),T=ve(),w=Y(e),b=x.getFetcher(t),M=h.useCallback(async _=>{f.current&&f.current.abort(),f.current=_.abortController??new AbortController,_.abortController=f.current;const P=T.generate();r.setLoading();try{const R=await b.exchange(_,w.current);u()&&T.isLatest(P)&&s(R);const O=await R.extractResult();u()&&T.isLatest(P)&&await r.setSuccess(O)}catch(R){if(R instanceof Error&&R.name==="AbortError"){u()&&r.setIdle();return}u()&&T.isLatest(P)&&await r.setError(R)}finally{f.current===_.abortController&&(f.current=void 0)}},[b,u,w,r,T]);return h.useEffect(()=>()=>{f.current?.abort(),f.current=void 0},[]),h.useMemo(()=>({...r,exchange:a,execute:M}),[r,a,M])}let at=class{constructor(){this.buffer=""}transform(t,r){try{this.buffer+=t;const a=this.buffer.split(`
2
- `);this.buffer=a.pop()||"";for(const s of a)r.enqueue(s)}catch(a){r.error(a)}}flush(t){try{this.buffer&&t.enqueue(this.buffer)}catch(r){t.error(r)}}};class ot extends TransformStream{constructor(){super(new at)}}const te=class{};te.ID="id",te.RETRY="retry",te.EVENT="event",te.DATA="data";let ue=te;function it(e,t,r){switch(e){case ue.EVENT:r.event=t;break;case ue.DATA:r.data.push(t);break;case ue.ID:r.id=t;break;case ue.RETRY:{const a=parseInt(t,10);isNaN(a)||(r.retry=a);break}}}const Z="message";let st=class{constructor(){this.currentEvent={event:Z,id:void 0,retry:void 0,data:[]}}transform(t,r){const a=this.currentEvent;try{if(t.trim()===""){a.data.length>0&&(r.enqueue({event:a.event||Z,data:a.data.join(`
3
- `),id:a.id||"",retry:a.retry}),a.event=Z,a.data=[]);return}if(t.startsWith(":"))return;const s=t.indexOf(":");let u,f;s===-1?(u=t.toLowerCase(),f=""):(u=t.substring(0,s).toLowerCase(),f=t.substring(s+1),f.startsWith(" ")&&(f=f.substring(1))),u=u.trim(),f=f.trim(),it(u,f,a)}catch(s){r.error(s instanceof Error?s:new Error(String(s))),a.event=Z,a.id=void 0,a.retry=void 0,a.data=[]}}flush(t){const r=this.currentEvent;try{r.data.length>0&&t.enqueue({event:r.event||Z,data:r.data.join(`
4
- `),id:r.id||"",retry:r.retry})}catch(a){t.error(a instanceof Error?a:new Error(String(a)))}finally{r.event=Z,r.id=void 0,r.retry=void 0,r.data=[]}}};class ut extends TransformStream{constructor(){super(new st)}}class re extends x.FetcherError{constructor(t,r,a){super(r,a),this.response=t,this.name="EventStreamConvertError",Object.setPrototypeOf(this,re.prototype)}}function ct(e){if(!e.body)throw new re(e,"Response body is null");return e.body.pipeThrough(new TextDecoderStream("utf-8")).pipeThrough(new ot).pipeThrough(new ut)}let ft=class{transform(t,r){const a=JSON.parse(t.data);r.enqueue({data:a,event:t.event,id:t.id,retry:t.retry})}},lt=class extends TransformStream{constructor(){super(new ft)}};function dt(e){return e.pipeThrough(new lt)}const ce=e=>e.requiredResponse.requiredJsonEventStream();Object.defineProperty(Response.prototype,"contentType",{get(){return this.headers.get(x.CONTENT_TYPE_HEADER)}}),Object.defineProperty(Response.prototype,"isEventStream",{get(){const e=this.contentType;return e?e.includes(x.ContentTypeValues.TEXT_EVENT_STREAM):!1}}),Response.prototype.eventStream=function(){return this.isEventStream?ct(this):null},Response.prototype.requiredEventStream=function(){const e=this.eventStream();if(!e)throw new re(this,`Event stream is not available. Response content-type: [${this.contentType}]`);return e},Response.prototype.jsonEventStream=function(){const e=this.eventStream();return e?dt(e):null},Response.prototype.requiredJsonEventStream=function(){const e=this.jsonEventStream();if(!e)throw new re(this,`Event stream is not available. Response content-type: [${this.contentType}]`);return e};class ht{constructor(t){this.stream=t,this._locked=!0,this.reader=t.getReader()}get locked(){return this._locked}releaseLock(){if(!this._locked)return!1;this._locked=!1;try{return this.reader.releaseLock(),!0}catch(t){return console.debug("Failed to release reader lock:",t),!1}}[Symbol.asyncIterator](){return this}async next(){try{const{done:t,value:r}=await this.reader.read();return t?(this.releaseLock(),{done:!0,value:void 0}):{done:!1,value:r}}catch(t){throw this.releaseLock(),t}}async return(){try{await this.reader.cancel()}catch(t){console.debug("Failed to cancel stream reader:",t)}finally{this.releaseLock()}return{done:!0,value:void 0}}async throw(t){return console.debug("Throwing error:",t),this.releaseLock(),{done:!0,value:void 0}}}typeof ReadableStream.prototype[Symbol.asyncIterator]=="function"||(ReadableStream.prototype[Symbol.asyncIterator]=function(){return new ht(this)});var ke=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ce={};/*! *****************************************************************************
1
+ (function(P,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react"),require("@ahoo-wang/fetcher")):typeof define=="function"&&define.amd?define(["exports","react","@ahoo-wang/fetcher"],d):(P=typeof globalThis<"u"?globalThis:P||self,d(P.FetcherReact={},P.React,P.Fetcher))})(this,(function(P,d,x){"use strict";function ie(){const e=d.useRef(!1),t=d.useCallback(()=>e.current,[]);return d.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),t}function Y(e){const t=d.useRef(e);return t.current=e,t}var Ae=(e=>(e.IDLE="idle",e.LOADING="loading",e.SUCCESS="success",e.ERROR="error",e))(Ae||{});function ye(e){const[t,r]=d.useState(e?.initialStatus??"idle"),[a,i]=d.useState(void 0),[u,f]=d.useState(void 0),E=ie(),w=Y(e),b=d.useCallback(()=>{E()&&(r("loading"),f(void 0))},[E]),O=d.useCallback(async g=>{if(E()){i(g),r("success"),f(void 0);try{await w.current?.onSuccess?.(g)}catch(M){console.warn("PromiseState onSuccess callback error:",M)}}},[E,w]),_=d.useCallback(async g=>{if(E()){f(g),r("error"),i(void 0);try{await w.current?.onError?.(g)}catch(M){console.warn("PromiseState onError callback error:",M)}}},[E,w]),A=d.useCallback(()=>{E()&&(r("idle"),f(void 0),i(void 0))},[E]);return d.useMemo(()=>({status:t,loading:t==="loading",result:a,error:u,setLoading:b,setSuccess:O,setError:_,setIdle:A}),[t,a,u,b,O,_,A])}function Ee(){const e=d.useRef(0),t=d.useCallback(()=>++e.current,[]),r=d.useCallback(()=>e.current,[]),a=d.useCallback(f=>f===e.current,[]),i=d.useCallback(()=>{e.current++},[]),u=d.useCallback(()=>{e.current=0},[]);return d.useMemo(()=>({generate:t,current:r,isLatest:a,invalidate:i,reset:u}),[t,r,a,i,u])}function Z(e){const t=ye(e),r=ie(),a=Ee(),i=d.useCallback(async f=>{if(!r())throw new Error("Component is unmounted");const E=a.generate();t.setLoading();try{const b=await(typeof f=="function"?f():f);return r()&&a.isLatest(E)&&await t.setSuccess(b),b}catch(w){if(r()&&a.isLatest(E)&&await t.setError(w),e?.propagateError)throw w;return w}},[t,r,a,e]),u=d.useCallback(()=>{r()&&t.setIdle()},[t,r]);return d.useMemo(()=>({loading:t.loading,result:t.result,error:t.error,execute:i,reset:u,status:t.status}),[t.loading,t.result,t.error,i,u,t.status])}function rt(e){const t=d.useCallback(u=>e.addListener(u),[e]),r=d.useCallback(()=>e.get(),[e]),a=d.useSyncExternalStore(t,r,r),i=d.useCallback(u=>e.set(u),[e]);return[a,i]}function nt(e){const{fetcher:t=x.fetcherRegistrar.default}=e||{},r=ye(e),[a,i]=d.useState(void 0),u=ie(),f=d.useRef(),E=Ee(),w=Y(e),b=x.getFetcher(t),O=d.useCallback(async _=>{f.current&&f.current.abort(),f.current=_.abortController??new AbortController,_.abortController=f.current;const A=E.generate();r.setLoading();try{const g=await b.exchange(_,w.current);u()&&E.isLatest(A)&&i(g);const M=await g.extractResult();u()&&E.isLatest(A)&&await r.setSuccess(M)}catch(g){if(g instanceof Error&&g.name==="AbortError"){u()&&r.setIdle();return}u()&&E.isLatest(A)&&await r.setError(g)}finally{f.current===_.abortController&&(f.current=void 0)}},[b,u,w,r,E]);return d.useEffect(()=>()=>{f.current?.abort(),f.current=void 0},[]),d.useMemo(()=>({...r,exchange:a,execute:O}),[r,a,O])}let at=class{constructor(){this.buffer=""}transform(t,r){try{this.buffer+=t;const a=this.buffer.split(`
2
+ `);this.buffer=a.pop()||"";for(const i of a)r.enqueue(i)}catch(a){r.error(a)}}flush(t){try{this.buffer&&t.enqueue(this.buffer)}catch(r){t.error(r)}}};class ot extends TransformStream{constructor(){super(new at)}}const re=class{};re.ID="id",re.RETRY="retry",re.EVENT="event",re.DATA="data";let ue=re;function st(e,t,r){switch(e){case ue.EVENT:r.event=t;break;case ue.DATA:r.data.push(t);break;case ue.ID:r.id=t;break;case ue.RETRY:{const a=parseInt(t,10);isNaN(a)||(r.retry=a);break}}}const K="message";let it=class{constructor(){this.currentEvent={event:K,id:void 0,retry:void 0,data:[]}}transform(t,r){const a=this.currentEvent;try{if(t.trim()===""){a.data.length>0&&(r.enqueue({event:a.event||K,data:a.data.join(`
3
+ `),id:a.id||"",retry:a.retry}),a.event=K,a.data=[]);return}if(t.startsWith(":"))return;const i=t.indexOf(":");let u,f;i===-1?(u=t.toLowerCase(),f=""):(u=t.substring(0,i).toLowerCase(),f=t.substring(i+1),f.startsWith(" ")&&(f=f.substring(1))),u=u.trim(),f=f.trim(),st(u,f,a)}catch(i){r.error(i instanceof Error?i:new Error(String(i))),a.event=K,a.id=void 0,a.retry=void 0,a.data=[]}}flush(t){const r=this.currentEvent;try{r.data.length>0&&t.enqueue({event:r.event||K,data:r.data.join(`
4
+ `),id:r.id||"",retry:r.retry})}catch(a){t.error(a instanceof Error?a:new Error(String(a)))}finally{r.event=K,r.id=void 0,r.retry=void 0,r.data=[]}}};class ut extends TransformStream{constructor(){super(new it)}}class ne extends x.FetcherError{constructor(t,r,a){super(r,a),this.response=t,this.name="EventStreamConvertError",Object.setPrototypeOf(this,ne.prototype)}}function ct(e){if(!e.body)throw new ne(e,"Response body is null");return e.body.pipeThrough(new TextDecoderStream("utf-8")).pipeThrough(new ot).pipeThrough(new ut)}let ft=class{transform(t,r){const a=JSON.parse(t.data);r.enqueue({data:a,event:t.event,id:t.id,retry:t.retry})}},lt=class extends TransformStream{constructor(){super(new ft)}};function dt(e){return e.pipeThrough(new lt)}const ce=e=>e.requiredResponse.requiredJsonEventStream();Object.defineProperty(Response.prototype,"contentType",{get(){return this.headers.get(x.CONTENT_TYPE_HEADER)}}),Object.defineProperty(Response.prototype,"isEventStream",{get(){const e=this.contentType;return e?e.includes(x.ContentTypeValues.TEXT_EVENT_STREAM):!1}}),Response.prototype.eventStream=function(){return this.isEventStream?ct(this):null},Response.prototype.requiredEventStream=function(){const e=this.eventStream();if(!e)throw new ne(this,`Event stream is not available. Response content-type: [${this.contentType}]`);return e},Response.prototype.jsonEventStream=function(){const e=this.eventStream();return e?dt(e):null},Response.prototype.requiredJsonEventStream=function(){const e=this.jsonEventStream();if(!e)throw new ne(this,`Event stream is not available. Response content-type: [${this.contentType}]`);return e};class ht{constructor(t){this.stream=t,this._locked=!0,this.reader=t.getReader()}get locked(){return this._locked}releaseLock(){if(!this._locked)return!1;this._locked=!1;try{return this.reader.releaseLock(),!0}catch(t){return console.debug("Failed to release reader lock:",t),!1}}[Symbol.asyncIterator](){return this}async next(){try{const{done:t,value:r}=await this.reader.read();return t?(this.releaseLock(),{done:!0,value:void 0}):{done:!1,value:r}}catch(t){throw this.releaseLock(),t}}async return(){try{await this.reader.cancel()}catch(t){console.debug("Failed to cancel stream reader:",t)}finally{this.releaseLock()}return{done:!0,value:void 0}}async throw(t){return console.debug("Throwing error:",t),this.releaseLock(),{done:!0,value:void 0}}}typeof ReadableStream.prototype[Symbol.asyncIterator]=="function"||(ReadableStream.prototype[Symbol.asyncIterator]=function(){return new ht(this)});var ke=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ce={};/*! *****************************************************************************
5
5
  Copyright (C) Microsoft. All rights reserved.
6
6
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
7
7
  this file except in compliance with the License. You may obtain a copy of the
@@ -14,5 +14,5 @@
14
14
 
15
15
  See the Apache Version 2.0 License for specific language governing permissions
16
16
  and limitations under the License.
17
- ***************************************************************************** */var Pe;function pt(){if(Pe)return Ce;Pe=1;var e;return(function(t){(function(r){var a=typeof globalThis=="object"?globalThis:typeof ke=="object"?ke:typeof self=="object"?self:typeof this=="object"?this:w(),s=u(t);typeof a.Reflect<"u"&&(s=u(a.Reflect,s)),r(s,a),typeof a.Reflect>"u"&&(a.Reflect=t);function u(b,M){return function(_,P){Object.defineProperty(b,_,{configurable:!0,writable:!0,value:P}),M&&M(_,P)}}function f(){try{return Function("return this;")()}catch{}}function T(){try{return(0,eval)("(function() { return this; })()")}catch{}}function w(){return f()||T()}})(function(r,a){var s=Object.prototype.hasOwnProperty,u=typeof Symbol=="function",f=u&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",T=u&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",w=typeof Object.create=="function",b={__proto__:[]}instanceof Array,M=!w&&!b,_={create:w?function(){return Oe(Object.create(null))}:b?function(){return Oe({__proto__:null})}:function(){return Oe({})},has:M?function(n,o){return s.call(n,o)}:function(n,o){return o in n},get:M?function(n,o){return s.call(n,o)?n[o]:void 0}:function(n,o){return n[o]}},P=Object.getPrototypeOf(Function),R=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:hr(),O=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:pr(),oe=typeof WeakMap=="function"?WeakMap:yr(),U=u?Symbol.for("@reflect-metadata:registry"):void 0,he=fr(),qe=lr(he);function Vt(n,o,i,c){if(E(i)){if(!Be(n))throw new TypeError;if(!Xe(o))throw new TypeError;return rr(n,o)}else{if(!Be(n))throw new TypeError;if(!I(o))throw new TypeError;if(!I(c)&&!E(c)&&!ee(c))throw new TypeError;return ee(c)&&(c=void 0),i=F(i),nr(n,o,i,c)}}r("decorate",Vt);function Yt(n,o){function i(c,v){if(!I(c))throw new TypeError;if(!E(v)&&!ur(v))throw new TypeError;We(n,o,c,v)}return i}r("metadata",Yt);function Bt(n,o,i,c){if(!I(i))throw new TypeError;return E(c)||(c=F(c)),We(n,o,i,c)}r("defineMetadata",Bt);function Xt(n,o,i){if(!I(o))throw new TypeError;return E(i)||(i=F(i)),He(n,o,i)}r("hasMetadata",Xt);function Jt(n,o,i){if(!I(o))throw new TypeError;return E(i)||(i=F(i)),ge(n,o,i)}r("hasOwnMetadata",Jt);function zt(n,o,i){if(!I(o))throw new TypeError;return E(i)||(i=F(i)),Ue(n,o,i)}r("getMetadata",zt);function Zt(n,o,i){if(!I(o))throw new TypeError;return E(i)||(i=F(i)),$e(n,o,i)}r("getOwnMetadata",Zt);function Kt(n,o){if(!I(n))throw new TypeError;return E(o)||(o=F(o)),Qe(n,o)}r("getMetadataKeys",Kt);function er(n,o){if(!I(n))throw new TypeError;return E(o)||(o=F(o)),Fe(n,o)}r("getOwnMetadataKeys",er);function tr(n,o,i){if(!I(o))throw new TypeError;if(E(i)||(i=F(i)),!I(o))throw new TypeError;E(i)||(i=F(i));var c=ie(o,i,!1);return E(c)?!1:c.OrdinaryDeleteMetadata(n,o,i)}r("deleteMetadata",tr);function rr(n,o){for(var i=n.length-1;i>=0;--i){var c=n[i],v=c(o);if(!E(v)&&!ee(v)){if(!Xe(v))throw new TypeError;o=v}}return o}function nr(n,o,i,c){for(var v=n.length-1;v>=0;--v){var A=n[v],L=A(o,i,c);if(!E(L)&&!ee(L)){if(!I(L))throw new TypeError;c=L}}return c}function He(n,o,i){var c=ge(n,o,i);if(c)return!0;var v=Me(o);return ee(v)?!1:He(n,v,i)}function ge(n,o,i){var c=ie(o,i,!1);return E(c)?!1:Ye(c.OrdinaryHasOwnMetadata(n,o,i))}function Ue(n,o,i){var c=ge(n,o,i);if(c)return $e(n,o,i);var v=Me(o);if(!ee(v))return Ue(n,v,i)}function $e(n,o,i){var c=ie(o,i,!1);if(!E(c))return c.OrdinaryGetOwnMetadata(n,o,i)}function We(n,o,i,c){var v=ie(i,c,!0);v.OrdinaryDefineOwnMetadata(n,o,i,c)}function Qe(n,o){var i=Fe(n,o),c=Me(n);if(c===null)return i;var v=Qe(c,o);if(v.length<=0)return i;if(i.length<=0)return v;for(var A=new O,L=[],S=0,l=i;S<l.length;S++){var d=l[S],p=A.has(d);p||(A.add(d),L.push(d))}for(var y=0,m=v;y<m.length;y++){var d=m[y],p=A.has(d);p||(A.add(d),L.push(d))}return L}function Fe(n,o){var i=ie(n,o,!1);return i?i.OrdinaryOwnMetadataKeys(n,o):[]}function Ve(n){if(n===null)return 1;switch(typeof n){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return n===null?1:6;default:return 6}}function E(n){return n===void 0}function ee(n){return n===null}function ar(n){return typeof n=="symbol"}function I(n){return typeof n=="object"?n!==null:typeof n=="function"}function or(n,o){switch(Ve(n)){case 0:return n;case 1:return n;case 2:return n;case 3:return n;case 4:return n;case 5:return n}var i="string",c=Je(n,f);if(c!==void 0){var v=c.call(n,i);if(I(v))throw new TypeError;return v}return ir(n)}function ir(n,o){var i,c,v;{var A=n.toString;if(pe(A)){var c=A.call(n);if(!I(c))return c}var i=n.valueOf;if(pe(i)){var c=i.call(n);if(!I(c))return c}}throw new TypeError}function Ye(n){return!!n}function sr(n){return""+n}function F(n){var o=or(n);return ar(o)?o:sr(o)}function Be(n){return Array.isArray?Array.isArray(n):n instanceof Object?n instanceof Array:Object.prototype.toString.call(n)==="[object Array]"}function pe(n){return typeof n=="function"}function Xe(n){return typeof n=="function"}function ur(n){switch(Ve(n)){case 3:return!0;case 4:return!0;default:return!1}}function Re(n,o){return n===o||n!==n&&o!==o}function Je(n,o){var i=n[o];if(i!=null){if(!pe(i))throw new TypeError;return i}}function ze(n){var o=Je(n,T);if(!pe(o))throw new TypeError;var i=o.call(n);if(!I(i))throw new TypeError;return i}function Ze(n){return n.value}function Ke(n){var o=n.next();return o.done?!1:o}function et(n){var o=n.return;o&&o.call(n)}function Me(n){var o=Object.getPrototypeOf(n);if(typeof n!="function"||n===P||o!==P)return o;var i=n.prototype,c=i&&Object.getPrototypeOf(i);if(c==null||c===Object.prototype)return o;var v=c.constructor;return typeof v!="function"||v===n?o:v}function cr(){var n;!E(U)&&typeof a.Reflect<"u"&&!(U in a.Reflect)&&typeof a.Reflect.defineMetadata=="function"&&(n=dr(a.Reflect));var o,i,c,v=new oe,A={registerProvider:L,getProvider:l,setProvider:p};return A;function L(y){if(!Object.isExtensible(A))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case n===y:break;case E(o):o=y;break;case o===y:break;case E(i):i=y;break;case i===y:break;default:c===void 0&&(c=new O),c.add(y);break}}function S(y,m){if(!E(o)){if(o.isProviderFor(y,m))return o;if(!E(i)){if(i.isProviderFor(y,m))return o;if(!E(c))for(var g=ze(c);;){var k=Ke(g);if(!k)return;var W=Ze(k);if(W.isProviderFor(y,m))return et(g),W}}}if(!E(n)&&n.isProviderFor(y,m))return n}function l(y,m){var g=v.get(y),k;return E(g)||(k=g.get(m)),E(k)&&(k=S(y,m),E(k)||(E(g)&&(g=new R,v.set(y,g)),g.set(m,k))),k}function d(y){if(E(y))throw new TypeError;return o===y||i===y||!E(c)&&c.has(y)}function p(y,m,g){if(!d(g))throw new Error("Metadata provider not registered.");var k=l(y,m);if(k!==g){if(!E(k))return!1;var W=v.get(y);E(W)&&(W=new R,v.set(y,W)),W.set(m,g)}return!0}}function fr(){var n;return!E(U)&&I(a.Reflect)&&Object.isExtensible(a.Reflect)&&(n=a.Reflect[U]),E(n)&&(n=cr()),!E(U)&&I(a.Reflect)&&Object.isExtensible(a.Reflect)&&Object.defineProperty(a.Reflect,U,{enumerable:!1,configurable:!1,writable:!1,value:n}),n}function lr(n){var o=new oe,i={isProviderFor:function(d,p){var y=o.get(d);return E(y)?!1:y.has(p)},OrdinaryDefineOwnMetadata:L,OrdinaryHasOwnMetadata:v,OrdinaryGetOwnMetadata:A,OrdinaryOwnMetadataKeys:S,OrdinaryDeleteMetadata:l};return he.registerProvider(i),i;function c(d,p,y){var m=o.get(d),g=!1;if(E(m)){if(!y)return;m=new R,o.set(d,m),g=!0}var k=m.get(p);if(E(k)){if(!y)return;if(k=new R,m.set(p,k),!n.setProvider(d,p,i))throw m.delete(p),g&&o.delete(d),new Error("Wrong provider for target.")}return k}function v(d,p,y){var m=c(p,y,!1);return E(m)?!1:Ye(m.has(d))}function A(d,p,y){var m=c(p,y,!1);if(!E(m))return m.get(d)}function L(d,p,y,m){var g=c(y,m,!0);g.set(d,p)}function S(d,p){var y=[],m=c(d,p,!1);if(E(m))return y;for(var g=m.keys(),k=ze(g),W=0;;){var tt=Ke(k);if(!tt)return y.length=W,y;var vr=Ze(tt);try{y[W]=vr}catch(Er){try{et(k)}finally{throw Er}}W++}}function l(d,p,y){var m=c(p,y,!1);if(E(m)||!m.delete(d))return!1;if(m.size===0){var g=o.get(p);E(g)||(g.delete(y),g.size===0&&o.delete(g))}return!0}}function dr(n){var o=n.defineMetadata,i=n.hasOwnMetadata,c=n.getOwnMetadata,v=n.getOwnMetadataKeys,A=n.deleteMetadata,L=new oe,S={isProviderFor:function(l,d){var p=L.get(l);return!E(p)&&p.has(d)?!0:v(l,d).length?(E(p)&&(p=new O,L.set(l,p)),p.add(d),!0):!1},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:i,OrdinaryGetOwnMetadata:c,OrdinaryOwnMetadataKeys:v,OrdinaryDeleteMetadata:A};return S}function ie(n,o,i){var c=he.getProvider(n,o);if(!E(c))return c;if(i){if(he.setProvider(n,o,qe))return qe;throw new Error("Illegal state.")}}function hr(){var n={},o=[],i=(function(){function S(l,d,p){this._index=0,this._keys=l,this._values=d,this._selector=p}return S.prototype["@@iterator"]=function(){return this},S.prototype[T]=function(){return this},S.prototype.next=function(){var l=this._index;if(l>=0&&l<this._keys.length){var d=this._selector(this._keys[l],this._values[l]);return l+1>=this._keys.length?(this._index=-1,this._keys=o,this._values=o):this._index++,{value:d,done:!1}}return{value:void 0,done:!0}},S.prototype.throw=function(l){throw this._index>=0&&(this._index=-1,this._keys=o,this._values=o),l},S.prototype.return=function(l){return this._index>=0&&(this._index=-1,this._keys=o,this._values=o),{value:l,done:!0}},S})(),c=(function(){function S(){this._keys=[],this._values=[],this._cacheKey=n,this._cacheIndex=-2}return Object.defineProperty(S.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),S.prototype.has=function(l){return this._find(l,!1)>=0},S.prototype.get=function(l){var d=this._find(l,!1);return d>=0?this._values[d]:void 0},S.prototype.set=function(l,d){var p=this._find(l,!0);return this._values[p]=d,this},S.prototype.delete=function(l){var d=this._find(l,!1);if(d>=0){for(var p=this._keys.length,y=d+1;y<p;y++)this._keys[y-1]=this._keys[y],this._values[y-1]=this._values[y];return this._keys.length--,this._values.length--,Re(l,this._cacheKey)&&(this._cacheKey=n,this._cacheIndex=-2),!0}return!1},S.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=n,this._cacheIndex=-2},S.prototype.keys=function(){return new i(this._keys,this._values,v)},S.prototype.values=function(){return new i(this._keys,this._values,A)},S.prototype.entries=function(){return new i(this._keys,this._values,L)},S.prototype["@@iterator"]=function(){return this.entries()},S.prototype[T]=function(){return this.entries()},S.prototype._find=function(l,d){if(!Re(this._cacheKey,l)){this._cacheIndex=-1;for(var p=0;p<this._keys.length;p++)if(Re(this._keys[p],l)){this._cacheIndex=p;break}}return this._cacheIndex<0&&d&&(this._cacheIndex=this._keys.length,this._keys.push(l),this._values.push(void 0)),this._cacheIndex},S})();return c;function v(S,l){return S}function A(S,l){return l}function L(S,l){return[S,l]}}function pr(){var n=(function(){function o(){this._map=new R}return Object.defineProperty(o.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),o.prototype.has=function(i){return this._map.has(i)},o.prototype.add=function(i){return this._map.set(i,i),this},o.prototype.delete=function(i){return this._map.delete(i)},o.prototype.clear=function(){this._map.clear()},o.prototype.keys=function(){return this._map.keys()},o.prototype.values=function(){return this._map.keys()},o.prototype.entries=function(){return this._map.entries()},o.prototype["@@iterator"]=function(){return this.keys()},o.prototype[T]=function(){return this.keys()},o})();return n}function yr(){var n=16,o=_.create(),i=c();return(function(){function l(){this._key=c()}return l.prototype.has=function(d){var p=v(d,!1);return p!==void 0?_.has(p,this._key):!1},l.prototype.get=function(d){var p=v(d,!1);return p!==void 0?_.get(p,this._key):void 0},l.prototype.set=function(d,p){var y=v(d,!0);return y[this._key]=p,this},l.prototype.delete=function(d){var p=v(d,!1);return p!==void 0?delete p[this._key]:!1},l.prototype.clear=function(){this._key=c()},l})();function c(){var l;do l="@@WeakMap@@"+S();while(_.has(o,l));return o[l]=!0,l}function v(l,d){if(!s.call(l,i)){if(!d)return;Object.defineProperty(l,i,{value:_.create()})}return l[i]}function A(l,d){for(var p=0;p<d;++p)l[p]=Math.random()*255|0;return l}function L(l){if(typeof Uint8Array=="function"){var d=new Uint8Array(l);return typeof crypto<"u"?crypto.getRandomValues(d):typeof msCrypto<"u"?msCrypto.getRandomValues(d):A(d,l),d}return A(new Array(l),l)}function S(){var l=L(n);l[6]=l[6]&79|64,l[8]=l[8]&191|128;for(var d="",p=0;p<n;++p){var y=l[p];(p===4||p===6||p===8)&&(d+="-"),y<16&&(d+="0"),d+=y.toString(16).toLowerCase()}return d}}function Oe(n){return n.__=void 0,delete n.__,n}})})(e||(e={})),Ce}pt();const Ie=Symbol("endpoint:metadata");function Ee(e,t,r={}){return function(a,s){const u={method:e,path:t,...r};Reflect.defineMetadata(Ie,u,a,s)}}function q(e="",t={}){return Ee(x.HttpMethod.POST,e,t)}var Te=(e=>(e.EXCHANGE="Exchange",e.RESULT="Result",e))(Te||{});const yt="__decorator_target__",vt="__decorator_metadata__";let Et=class{constructor(t,r){this.target=t,this.metadata=r}async execute(t){const r=this.metadata.fetcher,a=this.metadata.resolveExchangeInit(t);a.attributes?.set(yt,this.target),a.attributes?.set(vt,this.metadata);const s=this.metadata.resolveResultExtractor(),u=this.metadata.resolveEndpointReturnType(),f=await r.exchange(a.request,{resultExtractor:s,attributes:a.attributes});return u===Te.EXCHANGE?f:await f.extractResult()}};const ne=new WeakMap;function Tt(e){if(typeof e!="function")throw new TypeError("Expected a function");if(ne.has(e))return ne.get(e);try{const t=e.toString().trim(),r=wt(t);if(!mt(r)){const s=[];return ne.set(e,s),s}const a=bt(r);return ne.set(e,a),a}catch{const t=[];return ne.set(e,t),t}}function St(e,t,r,a){if(a)return a;try{const s=e[t];if(s&&typeof s=="function"){const u=Tt(s);if(r<u.length)return u[r]}}catch{}}function mt(e){return e!=null&&e.trim()!==""}function wt(e){if(e.startsWith("(")){const a=Le(e,0);return a===-1?"":e.substring(1,a)}const t=e.indexOf("(");if(t===-1)return"";const r=Le(e,t);return r===-1?"":e.substring(t+1,r)}function Le(e,t){let r=1;for(let a=t+1;a<e.length;a++){const s=e[a];if(s==="(")r++;else if(s===")"&&(r--,r===0))return a}return-1}function bt(e){return e.split(",").map(_t).filter(gt).map(Rt)}function _t(e){return e.trim()}function gt(e){return e.length>0}function Rt(e){let t=Mt(e);return t=Ot(t),t.trim()}function Mt(e){const t=e.indexOf("=");return t!==-1?e.substring(0,t):e}function Ot(e){const t=e.indexOf(":");return t!==-1?e.substring(0,t):e}var J=(e=>(e.PATH="path",e.QUERY="query",e.HEADER="header",e.BODY="body",e.REQUEST="request",e.ATTRIBUTE="attribute",e))(J||{});const Se=Symbol("parameter:metadata");function me(e,t=""){return function(r,a,s){const u=St(r,a,s,t),f=Reflect.getMetadata(Se,r,a)||new Map,T={type:e,name:u,index:s};f.set(s,T),Reflect.defineMetadata(Se,f,r,a)}}function H(){return me("body")}function Ne(){return me("request")}function D(e=""){return me("attribute",e)}let xe=class{constructor(t,r,a,s){this.name=t,this.api=r,this.endpoint=a,this.parameters=s}get fetcher(){return x.getFetcher(this.endpoint.fetcher??this.api.fetcher)}resolvePath(t){const r=this.endpoint.basePath||this.api.basePath||"",a=t||this.endpoint.path||"";return x.combineURLs(r,a)}resolveTimeout(){return this.endpoint.timeout||this.api.timeout}resolveResultExtractor(){return this.endpoint.resultExtractor||this.api.resultExtractor||x.JsonResultExtractor}resolveAttributes(){const t=x.mergeRecordToMap(this.api.attributes);return x.mergeRecordToMap(this.endpoint.attributes,t)}resolveEndpointReturnType(){return this.endpoint.returnType||this.api.returnType||Te.RESULT}resolveExchangeInit(t){const r={},a={},s={...this.api.headers,...this.endpoint.headers};let u,f,T,w={};const b=this.resolveAttributes();t.forEach((O,oe)=>{if(O instanceof AbortSignal){f=O;return}if(O instanceof AbortController){T=O;return}const U=this.parameters.get(oe);if(U)switch(U.type){case J.PATH:this.processPathParam(U,O,r);break;case J.QUERY:this.processQueryParam(U,O,a);break;case J.HEADER:this.processHeaderParam(U,O,s);break;case J.BODY:u=O;break;case J.REQUEST:w=this.processRequestParam(O);break;case J.ATTRIBUTE:this.processAttributeParam(U,O,b);break}});const M={path:r,query:a},_={method:this.endpoint.method,urlParams:M,headers:s,body:u,timeout:this.resolveTimeout(),signal:f,abortController:T},P=x.mergeRequest(_,w),R=w.path;return P.url=this.resolvePath(R),{request:P,attributes:b}}processHttpParam(t,r,a){if(r==null)return;if(typeof r=="object"){Object.entries(r).forEach(([u,f])=>{a[u]=f});return}const s=t.name||`param${t.index}`;a[s]=r}processPathParam(t,r,a){this.processHttpParam(t,r,a)}processQueryParam(t,r,a){this.processHttpParam(t,r,a)}processHeaderParam(t,r,a){this.processHttpParam(t,r,a)}processRequestParam(t){if(!t)return{};const r=t;return{...r,headers:r.headers||{},urlParams:r.urlParams||{path:{},query:{}}}}processAttributeParam(t,r,a){if(typeof r=="object"||r instanceof Map){x.mergeRecordToMap(r,a);return}t.name&&r!==void 0&&a.set(t.name,r)}};const At=Symbol("api:metadata");function kt(e,t,r){const a=e.prototype[t];if(t==="constructor"||typeof a!="function")return;const s=Reflect.getMetadata(Ie,e.prototype,t);if(!s)return;const u=Reflect.getMetadata(Se,e.prototype,t)||new Map,f=new xe(t,r,s,u);e.prototype[t]=async function(...T){return await Ct(this,f).execute(T)}}function Ct(e,t){let r=e.requestExecutors;r||(r=new Map,e.requestExecutors=r);let a=r.get(t.name);if(a)return a;const s=e.apiMetadata,u={...t.api,...s};return a=new Et(e,new xe(t.name,u,t.endpoint,t.parameters)),r.set(t.name,a),a}function we(e="",t={}){return function(r){const a={basePath:e,...t};return Reflect.defineMetadata(At,a,r),Object.getOwnPropertyNames(r.prototype).forEach(s=>{kt(r,s,a)}),r}}let Pt=class extends Error{constructor(){super("Implementation will be generated automatically."),this.name="AutoGenerated"}};const G=(...e)=>new Pt;var It=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,be=(e,t,r,a)=>{for(var s=a>1?void 0:a?Lt(t,r):t,u=e.length-1,f;u>=0;u--)(f=e[u])&&(s=(a?f(t,r,s):f(s))||s);return a&&s&&It(t,r,s),s},fe=(e,t)=>(r,a)=>t(r,a,e);let le=class{constructor(e){this.apiMetadata=e}send(e,t){throw G(e,t)}sendAndWaitStream(e,t){throw G(e,t)}};be([Ee(),fe(0,Ne()),fe(1,D())],le.prototype,"send",1),be([Ee(void 0,void 0,{headers:{Accept:x.ContentTypeValues.TEXT_EVENT_STREAM},resultExtractor:ce}),fe(0,Ne()),fe(1,D())],le.prototype,"sendAndWaitStream",1),le=be([we()],le);var je=(e=>(e.AND="AND",e.OR="OR",e.NOR="NOR",e.ID="ID",e.IDS="IDS",e.AGGREGATE_ID="AGGREGATE_ID",e.AGGREGATE_IDS="AGGREGATE_IDS",e.TENANT_ID="TENANT_ID",e.OWNER_ID="OWNER_ID",e.DELETED="DELETED",e.ALL="ALL",e.EQ="EQ",e.NE="NE",e.GT="GT",e.LT="LT",e.GTE="GTE",e.LTE="LTE",e.CONTAINS="CONTAINS",e.IN="IN",e.NOT_IN="NOT_IN",e.BETWEEN="BETWEEN",e.ALL_IN="ALL_IN",e.STARTS_WITH="STARTS_WITH",e.ENDS_WITH="ENDS_WITH",e.ELEM_MATCH="ELEM_MATCH",e.NULL="NULL",e.NOT_NULL="NOT_NULL",e.TRUE="TRUE",e.FALSE="FALSE",e.EXISTS="EXISTS",e.TODAY="TODAY",e.BEFORE_TODAY="BEFORE_TODAY",e.TOMORROW="TOMORROW",e.THIS_WEEK="THIS_WEEK",e.NEXT_WEEK="NEXT_WEEK",e.LAST_WEEK="LAST_WEEK",e.THIS_MONTH="THIS_MONTH",e.LAST_MONTH="LAST_MONTH",e.RECENT_DAYS="RECENT_DAYS",e.EARLIER_DAYS="EARLIER_DAYS",e.RAW="RAW",e))(je||{});function _e(){return{operator:je.ALL}}const De={index:1,size:10};function Nt({condition:e=_e(),projection:t,sort:r}={}){return{condition:e,projection:t,sort:r}}function xt({condition:e=_e(),projection:t,sort:r,limit:a=De.size}={}){return{condition:e,projection:t,sort:r,limit:a}}function jt({condition:e=_e(),projection:t,sort:r,pagination:a=De}={}){return{condition:e,projection:t,sort:r,pagination:a}}const B=class{};B.EVENT_STREAM_RESOURCE_NAME="event",B.COUNT=`${B.EVENT_STREAM_RESOURCE_NAME}/count`,B.LIST=`${B.EVENT_STREAM_RESOURCE_NAME}/list`,B.PAGED=`${B.EVENT_STREAM_RESOURCE_NAME}/paged`;let de=B;var Dt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,ae=(e,t,r,a)=>{for(var s=a>1?void 0:a?Gt(t,r):t,u=e.length-1,f;u>=0;u--)(f=e[u])&&(s=(a?f(t,r,s):f(s))||s);return a&&s&&Dt(t,r,s),s},X=(e,t)=>(r,a)=>t(r,a,e);let K=class{constructor(e){this.apiMetadata=e}count(e,t){throw G(e,t)}list(e,t){throw G(e,t)}listStream(e,t){throw G(e,t)}paged(e,t){throw G(e,t)}};ae([q(de.COUNT),X(0,H()),X(1,D())],K.prototype,"count",1),ae([q(de.LIST),X(0,H()),X(1,D())],K.prototype,"list",1),ae([q(de.LIST,{headers:{Accept:x.ContentTypeValues.TEXT_EVENT_STREAM},resultExtractor:ce}),X(0,H()),X(1,D())],K.prototype,"listStream",1),ae([q(de.PAGED),X(0,H()),X(1,D())],K.prototype,"paged",1),K=ae([we()],K);const j=class{};j.SNAPSHOT_RESOURCE_NAME="snapshot",j.COUNT=`${j.SNAPSHOT_RESOURCE_NAME}/count`,j.LIST=`${j.SNAPSHOT_RESOURCE_NAME}/list`,j.LIST_STATE=`${j.LIST}/state`,j.PAGED=`${j.SNAPSHOT_RESOURCE_NAME}/paged`,j.PAGED_STATE=`${j.PAGED}/state`,j.SINGLE=`${j.SNAPSHOT_RESOURCE_NAME}/single`,j.SINGLE_STATE=`${j.SINGLE}/state`;let V=j;var qt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Q=(e,t,r,a)=>{for(var s=a>1?void 0:a?Ht(t,r):t,u=e.length-1,f;u>=0;u--)(f=e[u])&&(s=(a?f(t,r,s):f(s))||s);return a&&s&&qt(t,r,s),s},N=(e,t)=>(r,a)=>t(r,a,e);let $=class{constructor(e){this.apiMetadata=e}count(e,t){throw G(e,t)}list(e,t){throw G(e,t)}listStream(e,t){throw G(e,t)}listState(e,t){throw G(e,t)}listStateStream(e,t){throw G(e,t)}paged(e,t){throw G(e,t)}pagedState(e,t){throw G(e,t)}single(e,t){throw G(e,t)}singleState(e,t){throw G(e,t)}};Q([q(V.COUNT),N(0,H()),N(1,D())],$.prototype,"count",1),Q([q(V.LIST),N(0,H()),N(1,D())],$.prototype,"list",1),Q([q(V.LIST,{headers:{Accept:x.ContentTypeValues.TEXT_EVENT_STREAM},resultExtractor:ce}),N(0,H()),N(1,D())],$.prototype,"listStream",1),Q([q(V.LIST_STATE),N(0,H()),N(1,D())],$.prototype,"listState",1),Q([q(V.LIST_STATE,{headers:{Accept:x.ContentTypeValues.TEXT_EVENT_STREAM},resultExtractor:ce}),N(0,H()),N(1,D())],$.prototype,"listStateStream",1),Q([q(V.PAGED),N(0,H()),N(1,D())],$.prototype,"paged",1),Q([q(V.PAGED_STATE),N(0,H()),N(1,D())],$.prototype,"pagedState",1),Q([q(V.SINGLE),N(0,H()),N(1,D())],$.prototype,"single",1),Q([q(V.SINGLE_STATE),N(0,H()),N(1,D())],$.prototype,"singleState",1),$=Q([we()],$);function Ut(e){const{initialQuery:t}=e,r=z(e),[a,s]=h.useState(t.condition),[u,f]=h.useState(t.pagination),[T,w]=h.useState(t.projection),[b,M]=h.useState(t.sort),_=Y(e),P=h.useCallback(async()=>{const O=jt({condition:a,pagination:u,projection:T,sort:b});return _.current.query(O,_.current.attributes)},[a,T,u,b,_]),R=h.useCallback(()=>r.execute(P),[r,P]);return h.useMemo(()=>({...r,execute:R,setCondition:s,setProjection:w,setPagination:f,setSort:M}),[r,R,s,w,f,M])}function $t(e){const{initialQuery:t}=e,r=z(e),[a,s]=h.useState(t.condition),[u,f]=h.useState(t.projection),[T,w]=h.useState(t.sort),b=Y(e),M=h.useCallback(async()=>{const P=Nt({condition:a,projection:u,sort:T});return b.current.query(P,b.current.attributes)},[a,u,T,b]),_=h.useCallback(()=>r.execute(M),[r,M]);return h.useMemo(()=>({...r,execute:_,setCondition:s,setProjection:f,setSort:w}),[r,_,s,f,w])}function Wt(e){const{initialCondition:t}=e,r=z(e),[a,s]=h.useState(t),u=Y(e),f=h.useCallback(async()=>u.current.count(a,u.current.attributes),[a,u]),T=h.useCallback(()=>r.execute(f),[r,f]);return h.useMemo(()=>({...r,execute:T,setCondition:s}),[r,T,s])}function Ge(e){const{initialQuery:t}=e,[r,a]=h.useState(t.condition),[s,u]=h.useState(t.projection),[f,T]=h.useState(t.sort),[w,b]=h.useState(t.limit),M=h.useCallback(()=>xt({condition:r,projection:s,sort:f,limit:w}),[r,s,f,w]);return h.useMemo(()=>({condition:r,projection:s,sort:f,limit:w,setCondition:a,setProjection:u,setSort:T,setLimit:b,buildQuery:M}),[r,s,f,w,a,u,T,b,M])}function Qt(e){const t=z(e),r=Ge({initialQuery:e.initialQuery}),a=Y(e),s=h.useCallback(async()=>{const f=r.buildQuery();return a.current.list(f,a.current.attributes)},[r,a]),u=h.useCallback(()=>t.execute(s),[t,s]);return h.useMemo(()=>({...t,execute:u,setCondition:r.setCondition,setProjection:r.setProjection,setSort:r.setSort,setLimit:r.setLimit}),[t,u,r.setCondition,r.setProjection,r.setSort,r.setLimit])}function Ft(e){const t=z(e),r=Ge({initialQuery:e.initialQuery}),a=Y(e),s=h.useCallback(async()=>{const f=r.buildQuery();return a.current.listStream(f,a.current.attributes)},[r,a]),u=h.useCallback(()=>t.execute(s),[t,s]);return h.useMemo(()=>({...t,execute:u,setCondition:r.setCondition,setProjection:r.setProjection,setSort:r.setSort,setLimit:r.setLimit}),[t,u,r.setCondition,r.setProjection,r.setSort,r.setLimit])}C.PromiseStatus=Ae,C.useCountQuery=Wt,C.useExecutePromise=z,C.useFetcher=nt,C.useKeyStorage=rt,C.useLatest=Y,C.useListQuery=Qt,C.useListStreamQuery=Ft,C.useMounted=se,C.usePagedQuery=Ut,C.usePromiseState=ye,C.useRequestId=ve,C.useSingleQuery=$t,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})}));
17
+ ***************************************************************************** */var Pe;function pt(){if(Pe)return Ce;Pe=1;var e;return(function(t){(function(r){var a=typeof globalThis=="object"?globalThis:typeof ke=="object"?ke:typeof self=="object"?self:typeof this=="object"?this:w(),i=u(t);typeof a.Reflect<"u"&&(i=u(a.Reflect,i)),r(i,a),typeof a.Reflect>"u"&&(a.Reflect=t);function u(b,O){return function(_,A){Object.defineProperty(b,_,{configurable:!0,writable:!0,value:A}),O&&O(_,A)}}function f(){try{return Function("return this;")()}catch{}}function E(){try{return(0,eval)("(function() { return this; })()")}catch{}}function w(){return f()||E()}})(function(r,a){var i=Object.prototype.hasOwnProperty,u=typeof Symbol=="function",f=u&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",E=u&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",w=typeof Object.create=="function",b={__proto__:[]}instanceof Array,O=!w&&!b,_={create:w?function(){return Oe(Object.create(null))}:b?function(){return Oe({__proto__:null})}:function(){return Oe({})},has:O?function(n,o){return i.call(n,o)}:function(n,o){return o in n},get:O?function(n,o){return i.call(n,o)?n[o]:void 0}:function(n,o){return n[o]}},A=Object.getPrototypeOf(Function),g=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:hr(),M=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:pr(),z=typeof WeakMap=="function"?WeakMap:yr(),U=u?Symbol.for("@reflect-metadata:registry"):void 0,he=fr(),qe=lr(he);function Vt(n,o,s,c){if(T(s)){if(!Be(n))throw new TypeError;if(!Xe(o))throw new TypeError;return rr(n,o)}else{if(!Be(n))throw new TypeError;if(!I(o))throw new TypeError;if(!I(c)&&!T(c)&&!te(c))throw new TypeError;return te(c)&&(c=void 0),s=F(s),nr(n,o,s,c)}}r("decorate",Vt);function Yt(n,o){function s(c,v){if(!I(c))throw new TypeError;if(!T(v)&&!ur(v))throw new TypeError;We(n,o,c,v)}return s}r("metadata",Yt);function Bt(n,o,s,c){if(!I(s))throw new TypeError;return T(c)||(c=F(c)),We(n,o,s,c)}r("defineMetadata",Bt);function Xt(n,o,s){if(!I(o))throw new TypeError;return T(s)||(s=F(s)),He(n,o,s)}r("hasMetadata",Xt);function Jt(n,o,s){if(!I(o))throw new TypeError;return T(s)||(s=F(s)),ge(n,o,s)}r("hasOwnMetadata",Jt);function zt(n,o,s){if(!I(o))throw new TypeError;return T(s)||(s=F(s)),Ue(n,o,s)}r("getMetadata",zt);function Zt(n,o,s){if(!I(o))throw new TypeError;return T(s)||(s=F(s)),$e(n,o,s)}r("getOwnMetadata",Zt);function Kt(n,o){if(!I(n))throw new TypeError;return T(o)||(o=F(o)),Qe(n,o)}r("getMetadataKeys",Kt);function er(n,o){if(!I(n))throw new TypeError;return T(o)||(o=F(o)),Fe(n,o)}r("getOwnMetadataKeys",er);function tr(n,o,s){if(!I(o))throw new TypeError;if(T(s)||(s=F(s)),!I(o))throw new TypeError;T(s)||(s=F(s));var c=se(o,s,!1);return T(c)?!1:c.OrdinaryDeleteMetadata(n,o,s)}r("deleteMetadata",tr);function rr(n,o){for(var s=n.length-1;s>=0;--s){var c=n[s],v=c(o);if(!T(v)&&!te(v)){if(!Xe(v))throw new TypeError;o=v}}return o}function nr(n,o,s,c){for(var v=n.length-1;v>=0;--v){var k=n[v],L=k(o,s,c);if(!T(L)&&!te(L)){if(!I(L))throw new TypeError;c=L}}return c}function He(n,o,s){var c=ge(n,o,s);if(c)return!0;var v=Me(o);return te(v)?!1:He(n,v,s)}function ge(n,o,s){var c=se(o,s,!1);return T(c)?!1:Ye(c.OrdinaryHasOwnMetadata(n,o,s))}function Ue(n,o,s){var c=ge(n,o,s);if(c)return $e(n,o,s);var v=Me(o);if(!te(v))return Ue(n,v,s)}function $e(n,o,s){var c=se(o,s,!1);if(!T(c))return c.OrdinaryGetOwnMetadata(n,o,s)}function We(n,o,s,c){var v=se(s,c,!0);v.OrdinaryDefineOwnMetadata(n,o,s,c)}function Qe(n,o){var s=Fe(n,o),c=Me(n);if(c===null)return s;var v=Qe(c,o);if(v.length<=0)return s;if(s.length<=0)return v;for(var k=new M,L=[],S=0,l=s;S<l.length;S++){var h=l[S],p=k.has(h);p||(k.add(h),L.push(h))}for(var y=0,m=v;y<m.length;y++){var h=m[y],p=k.has(h);p||(k.add(h),L.push(h))}return L}function Fe(n,o){var s=se(n,o,!1);return s?s.OrdinaryOwnMetadataKeys(n,o):[]}function Ve(n){if(n===null)return 1;switch(typeof n){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return n===null?1:6;default:return 6}}function T(n){return n===void 0}function te(n){return n===null}function ar(n){return typeof n=="symbol"}function I(n){return typeof n=="object"?n!==null:typeof n=="function"}function or(n,o){switch(Ve(n)){case 0:return n;case 1:return n;case 2:return n;case 3:return n;case 4:return n;case 5:return n}var s="string",c=Je(n,f);if(c!==void 0){var v=c.call(n,s);if(I(v))throw new TypeError;return v}return sr(n)}function sr(n,o){var s,c,v;{var k=n.toString;if(pe(k)){var c=k.call(n);if(!I(c))return c}var s=n.valueOf;if(pe(s)){var c=s.call(n);if(!I(c))return c}}throw new TypeError}function Ye(n){return!!n}function ir(n){return""+n}function F(n){var o=or(n);return ar(o)?o:ir(o)}function Be(n){return Array.isArray?Array.isArray(n):n instanceof Object?n instanceof Array:Object.prototype.toString.call(n)==="[object Array]"}function pe(n){return typeof n=="function"}function Xe(n){return typeof n=="function"}function ur(n){switch(Ve(n)){case 3:return!0;case 4:return!0;default:return!1}}function Re(n,o){return n===o||n!==n&&o!==o}function Je(n,o){var s=n[o];if(s!=null){if(!pe(s))throw new TypeError;return s}}function ze(n){var o=Je(n,E);if(!pe(o))throw new TypeError;var s=o.call(n);if(!I(s))throw new TypeError;return s}function Ze(n){return n.value}function Ke(n){var o=n.next();return o.done?!1:o}function et(n){var o=n.return;o&&o.call(n)}function Me(n){var o=Object.getPrototypeOf(n);if(typeof n!="function"||n===A||o!==A)return o;var s=n.prototype,c=s&&Object.getPrototypeOf(s);if(c==null||c===Object.prototype)return o;var v=c.constructor;return typeof v!="function"||v===n?o:v}function cr(){var n;!T(U)&&typeof a.Reflect<"u"&&!(U in a.Reflect)&&typeof a.Reflect.defineMetadata=="function"&&(n=dr(a.Reflect));var o,s,c,v=new z,k={registerProvider:L,getProvider:l,setProvider:p};return k;function L(y){if(!Object.isExtensible(k))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case n===y:break;case T(o):o=y;break;case o===y:break;case T(s):s=y;break;case s===y:break;default:c===void 0&&(c=new M),c.add(y);break}}function S(y,m){if(!T(o)){if(o.isProviderFor(y,m))return o;if(!T(s)){if(s.isProviderFor(y,m))return o;if(!T(c))for(var R=ze(c);;){var C=Ke(R);if(!C)return;var W=Ze(C);if(W.isProviderFor(y,m))return et(R),W}}}if(!T(n)&&n.isProviderFor(y,m))return n}function l(y,m){var R=v.get(y),C;return T(R)||(C=R.get(m)),T(C)&&(C=S(y,m),T(C)||(T(R)&&(R=new g,v.set(y,R)),R.set(m,C))),C}function h(y){if(T(y))throw new TypeError;return o===y||s===y||!T(c)&&c.has(y)}function p(y,m,R){if(!h(R))throw new Error("Metadata provider not registered.");var C=l(y,m);if(C!==R){if(!T(C))return!1;var W=v.get(y);T(W)&&(W=new g,v.set(y,W)),W.set(m,R)}return!0}}function fr(){var n;return!T(U)&&I(a.Reflect)&&Object.isExtensible(a.Reflect)&&(n=a.Reflect[U]),T(n)&&(n=cr()),!T(U)&&I(a.Reflect)&&Object.isExtensible(a.Reflect)&&Object.defineProperty(a.Reflect,U,{enumerable:!1,configurable:!1,writable:!1,value:n}),n}function lr(n){var o=new z,s={isProviderFor:function(h,p){var y=o.get(h);return T(y)?!1:y.has(p)},OrdinaryDefineOwnMetadata:L,OrdinaryHasOwnMetadata:v,OrdinaryGetOwnMetadata:k,OrdinaryOwnMetadataKeys:S,OrdinaryDeleteMetadata:l};return he.registerProvider(s),s;function c(h,p,y){var m=o.get(h),R=!1;if(T(m)){if(!y)return;m=new g,o.set(h,m),R=!0}var C=m.get(p);if(T(C)){if(!y)return;if(C=new g,m.set(p,C),!n.setProvider(h,p,s))throw m.delete(p),R&&o.delete(h),new Error("Wrong provider for target.")}return C}function v(h,p,y){var m=c(p,y,!1);return T(m)?!1:Ye(m.has(h))}function k(h,p,y){var m=c(p,y,!1);if(!T(m))return m.get(h)}function L(h,p,y,m){var R=c(y,m,!0);R.set(h,p)}function S(h,p){var y=[],m=c(h,p,!1);if(T(m))return y;for(var R=m.keys(),C=ze(R),W=0;;){var tt=Ke(C);if(!tt)return y.length=W,y;var Er=Ze(tt);try{y[W]=Er}catch(vr){try{et(C)}finally{throw vr}}W++}}function l(h,p,y){var m=c(p,y,!1);if(T(m)||!m.delete(h))return!1;if(m.size===0){var R=o.get(p);T(R)||(R.delete(y),R.size===0&&o.delete(R))}return!0}}function dr(n){var o=n.defineMetadata,s=n.hasOwnMetadata,c=n.getOwnMetadata,v=n.getOwnMetadataKeys,k=n.deleteMetadata,L=new z,S={isProviderFor:function(l,h){var p=L.get(l);return!T(p)&&p.has(h)?!0:v(l,h).length?(T(p)&&(p=new M,L.set(l,p)),p.add(h),!0):!1},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:s,OrdinaryGetOwnMetadata:c,OrdinaryOwnMetadataKeys:v,OrdinaryDeleteMetadata:k};return S}function se(n,o,s){var c=he.getProvider(n,o);if(!T(c))return c;if(s){if(he.setProvider(n,o,qe))return qe;throw new Error("Illegal state.")}}function hr(){var n={},o=[],s=(function(){function S(l,h,p){this._index=0,this._keys=l,this._values=h,this._selector=p}return S.prototype["@@iterator"]=function(){return this},S.prototype[E]=function(){return this},S.prototype.next=function(){var l=this._index;if(l>=0&&l<this._keys.length){var h=this._selector(this._keys[l],this._values[l]);return l+1>=this._keys.length?(this._index=-1,this._keys=o,this._values=o):this._index++,{value:h,done:!1}}return{value:void 0,done:!0}},S.prototype.throw=function(l){throw this._index>=0&&(this._index=-1,this._keys=o,this._values=o),l},S.prototype.return=function(l){return this._index>=0&&(this._index=-1,this._keys=o,this._values=o),{value:l,done:!0}},S})(),c=(function(){function S(){this._keys=[],this._values=[],this._cacheKey=n,this._cacheIndex=-2}return Object.defineProperty(S.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),S.prototype.has=function(l){return this._find(l,!1)>=0},S.prototype.get=function(l){var h=this._find(l,!1);return h>=0?this._values[h]:void 0},S.prototype.set=function(l,h){var p=this._find(l,!0);return this._values[p]=h,this},S.prototype.delete=function(l){var h=this._find(l,!1);if(h>=0){for(var p=this._keys.length,y=h+1;y<p;y++)this._keys[y-1]=this._keys[y],this._values[y-1]=this._values[y];return this._keys.length--,this._values.length--,Re(l,this._cacheKey)&&(this._cacheKey=n,this._cacheIndex=-2),!0}return!1},S.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=n,this._cacheIndex=-2},S.prototype.keys=function(){return new s(this._keys,this._values,v)},S.prototype.values=function(){return new s(this._keys,this._values,k)},S.prototype.entries=function(){return new s(this._keys,this._values,L)},S.prototype["@@iterator"]=function(){return this.entries()},S.prototype[E]=function(){return this.entries()},S.prototype._find=function(l,h){if(!Re(this._cacheKey,l)){this._cacheIndex=-1;for(var p=0;p<this._keys.length;p++)if(Re(this._keys[p],l)){this._cacheIndex=p;break}}return this._cacheIndex<0&&h&&(this._cacheIndex=this._keys.length,this._keys.push(l),this._values.push(void 0)),this._cacheIndex},S})();return c;function v(S,l){return S}function k(S,l){return l}function L(S,l){return[S,l]}}function pr(){var n=(function(){function o(){this._map=new g}return Object.defineProperty(o.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),o.prototype.has=function(s){return this._map.has(s)},o.prototype.add=function(s){return this._map.set(s,s),this},o.prototype.delete=function(s){return this._map.delete(s)},o.prototype.clear=function(){this._map.clear()},o.prototype.keys=function(){return this._map.keys()},o.prototype.values=function(){return this._map.keys()},o.prototype.entries=function(){return this._map.entries()},o.prototype["@@iterator"]=function(){return this.keys()},o.prototype[E]=function(){return this.keys()},o})();return n}function yr(){var n=16,o=_.create(),s=c();return(function(){function l(){this._key=c()}return l.prototype.has=function(h){var p=v(h,!1);return p!==void 0?_.has(p,this._key):!1},l.prototype.get=function(h){var p=v(h,!1);return p!==void 0?_.get(p,this._key):void 0},l.prototype.set=function(h,p){var y=v(h,!0);return y[this._key]=p,this},l.prototype.delete=function(h){var p=v(h,!1);return p!==void 0?delete p[this._key]:!1},l.prototype.clear=function(){this._key=c()},l})();function c(){var l;do l="@@WeakMap@@"+S();while(_.has(o,l));return o[l]=!0,l}function v(l,h){if(!i.call(l,s)){if(!h)return;Object.defineProperty(l,s,{value:_.create()})}return l[s]}function k(l,h){for(var p=0;p<h;++p)l[p]=Math.random()*255|0;return l}function L(l){if(typeof Uint8Array=="function"){var h=new Uint8Array(l);return typeof crypto<"u"?crypto.getRandomValues(h):typeof msCrypto<"u"?msCrypto.getRandomValues(h):k(h,l),h}return k(new Array(l),l)}function S(){var l=L(n);l[6]=l[6]&79|64,l[8]=l[8]&191|128;for(var h="",p=0;p<n;++p){var y=l[p];(p===4||p===6||p===8)&&(h+="-"),y<16&&(h+="0"),h+=y.toString(16).toLowerCase()}return h}}function Oe(n){return n.__=void 0,delete n.__,n}})})(e||(e={})),Ce}pt();const Ie=Symbol("endpoint:metadata");function ve(e,t,r={}){return function(a,i){const u={method:e,path:t,...r};Reflect.defineMetadata(Ie,u,a,i)}}function q(e="",t={}){return ve(x.HttpMethod.POST,e,t)}var Te=(e=>(e.EXCHANGE="Exchange",e.RESULT="Result",e))(Te||{});const yt="__decorator_target__",Et="__decorator_metadata__";let vt=class{constructor(t,r){this.target=t,this.metadata=r}async execute(t){const r=this.metadata.fetcher,a=this.metadata.resolveExchangeInit(t);a.attributes?.set(yt,this.target),a.attributes?.set(Et,this.metadata);const i=this.metadata.resolveResultExtractor(),u=this.metadata.resolveEndpointReturnType(),f=await r.exchange(a.request,{resultExtractor:i,attributes:a.attributes});return u===Te.EXCHANGE?f:await f.extractResult()}};const ae=new WeakMap;function Tt(e){if(typeof e!="function")throw new TypeError("Expected a function");if(ae.has(e))return ae.get(e);try{const t=e.toString().trim(),r=wt(t);if(!mt(r)){const i=[];return ae.set(e,i),i}const a=bt(r);return ae.set(e,a),a}catch{const t=[];return ae.set(e,t),t}}function St(e,t,r,a){if(a)return a;try{const i=e[t];if(i&&typeof i=="function"){const u=Tt(i);if(r<u.length)return u[r]}}catch{}}function mt(e){return e!=null&&e.trim()!==""}function wt(e){if(e.startsWith("(")){const a=Le(e,0);return a===-1?"":e.substring(1,a)}const t=e.indexOf("(");if(t===-1)return"";const r=Le(e,t);return r===-1?"":e.substring(t+1,r)}function Le(e,t){let r=1;for(let a=t+1;a<e.length;a++){const i=e[a];if(i==="(")r++;else if(i===")"&&(r--,r===0))return a}return-1}function bt(e){return e.split(",").map(_t).filter(gt).map(Rt)}function _t(e){return e.trim()}function gt(e){return e.length>0}function Rt(e){let t=Mt(e);return t=Ot(t),t.trim()}function Mt(e){const t=e.indexOf("=");return t!==-1?e.substring(0,t):e}function Ot(e){const t=e.indexOf(":");return t!==-1?e.substring(0,t):e}var J=(e=>(e.PATH="path",e.QUERY="query",e.HEADER="header",e.BODY="body",e.REQUEST="request",e.ATTRIBUTE="attribute",e))(J||{});const Se=Symbol("parameter:metadata");function me(e,t=""){return function(r,a,i){const u=St(r,a,i,t),f=Reflect.getMetadata(Se,r,a)||new Map,E={type:e,name:u,index:i};f.set(i,E),Reflect.defineMetadata(Se,f,r,a)}}function H(){return me("body")}function Ne(){return me("request")}function D(e=""){return me("attribute",e)}let xe=class{constructor(t,r,a,i){this.name=t,this.api=r,this.endpoint=a,this.parameters=i}get fetcher(){return x.getFetcher(this.endpoint.fetcher??this.api.fetcher)}resolvePath(t){const r=this.endpoint.basePath||this.api.basePath||"",a=t||this.endpoint.path||"";return x.combineURLs(r,a)}resolveTimeout(){return this.endpoint.timeout||this.api.timeout}resolveResultExtractor(){return this.endpoint.resultExtractor||this.api.resultExtractor||x.JsonResultExtractor}resolveAttributes(){const t=x.mergeRecordToMap(this.api.attributes);return x.mergeRecordToMap(this.endpoint.attributes,t)}resolveEndpointReturnType(){return this.endpoint.returnType||this.api.returnType||Te.RESULT}resolveExchangeInit(t){const r={},a={},i={...this.api.headers,...this.endpoint.headers};let u,f,E,w={};const b=this.resolveAttributes();t.forEach((M,z)=>{if(M instanceof AbortSignal){f=M;return}if(M instanceof AbortController){E=M;return}const U=this.parameters.get(z);if(U)switch(U.type){case J.PATH:this.processPathParam(U,M,r);break;case J.QUERY:this.processQueryParam(U,M,a);break;case J.HEADER:this.processHeaderParam(U,M,i);break;case J.BODY:u=M;break;case J.REQUEST:w=this.processRequestParam(M);break;case J.ATTRIBUTE:this.processAttributeParam(U,M,b);break}});const O={path:r,query:a},_={method:this.endpoint.method,urlParams:O,headers:i,body:u,timeout:this.resolveTimeout(),signal:f,abortController:E},A=x.mergeRequest(_,w),g=w.path;return A.url=this.resolvePath(g),{request:A,attributes:b}}processHttpParam(t,r,a){if(r==null)return;if(typeof r=="object"){Object.entries(r).forEach(([u,f])=>{a[u]=f});return}const i=t.name||`param${t.index}`;a[i]=r}processPathParam(t,r,a){this.processHttpParam(t,r,a)}processQueryParam(t,r,a){this.processHttpParam(t,r,a)}processHeaderParam(t,r,a){this.processHttpParam(t,r,a)}processRequestParam(t){if(!t)return{};const r=t;return{...r,headers:r.headers||{},urlParams:r.urlParams||{path:{},query:{}}}}processAttributeParam(t,r,a){if(typeof r=="object"||r instanceof Map){x.mergeRecordToMap(r,a);return}t.name&&r!==void 0&&a.set(t.name,r)}};const At=Symbol("api:metadata");function kt(e,t,r){const a=e.prototype[t];if(t==="constructor"||typeof a!="function")return;const i=Reflect.getMetadata(Ie,e.prototype,t);if(!i)return;const u=Reflect.getMetadata(Se,e.prototype,t)||new Map,f=new xe(t,r,i,u);e.prototype[t]=async function(...E){return await Ct(this,f).execute(E)}}function Ct(e,t){let r=e.requestExecutors;r||(r=new Map,e.requestExecutors=r);let a=r.get(t.name);if(a)return a;const i=e.apiMetadata,u={...t.api,...i};return a=new vt(e,new xe(t.name,u,t.endpoint,t.parameters)),r.set(t.name,a),a}function we(e="",t={}){return function(r){const a={basePath:e,...t};return Reflect.defineMetadata(At,a,r),Object.getOwnPropertyNames(r.prototype).forEach(i=>{kt(r,i,a)}),r}}let Pt=class extends Error{constructor(){super("Implementation will be generated automatically."),this.name="AutoGenerated"}};const G=(...e)=>new Pt;var It=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,be=(e,t,r,a)=>{for(var i=a>1?void 0:a?Lt(t,r):t,u=e.length-1,f;u>=0;u--)(f=e[u])&&(i=(a?f(t,r,i):f(i))||i);return a&&i&&It(t,r,i),i},fe=(e,t)=>(r,a)=>t(r,a,e);let le=class{constructor(e){this.apiMetadata=e}send(e,t){throw G(e,t)}sendAndWaitStream(e,t){throw G(e,t)}};be([ve(),fe(0,Ne()),fe(1,D())],le.prototype,"send",1),be([ve(void 0,void 0,{headers:{Accept:x.ContentTypeValues.TEXT_EVENT_STREAM},resultExtractor:ce}),fe(0,Ne()),fe(1,D())],le.prototype,"sendAndWaitStream",1),le=be([we()],le);var je=(e=>(e.AND="AND",e.OR="OR",e.NOR="NOR",e.ID="ID",e.IDS="IDS",e.AGGREGATE_ID="AGGREGATE_ID",e.AGGREGATE_IDS="AGGREGATE_IDS",e.TENANT_ID="TENANT_ID",e.OWNER_ID="OWNER_ID",e.DELETED="DELETED",e.ALL="ALL",e.EQ="EQ",e.NE="NE",e.GT="GT",e.LT="LT",e.GTE="GTE",e.LTE="LTE",e.CONTAINS="CONTAINS",e.IN="IN",e.NOT_IN="NOT_IN",e.BETWEEN="BETWEEN",e.ALL_IN="ALL_IN",e.STARTS_WITH="STARTS_WITH",e.ENDS_WITH="ENDS_WITH",e.ELEM_MATCH="ELEM_MATCH",e.NULL="NULL",e.NOT_NULL="NOT_NULL",e.TRUE="TRUE",e.FALSE="FALSE",e.EXISTS="EXISTS",e.TODAY="TODAY",e.BEFORE_TODAY="BEFORE_TODAY",e.TOMORROW="TOMORROW",e.THIS_WEEK="THIS_WEEK",e.NEXT_WEEK="NEXT_WEEK",e.LAST_WEEK="LAST_WEEK",e.THIS_MONTH="THIS_MONTH",e.LAST_MONTH="LAST_MONTH",e.RECENT_DAYS="RECENT_DAYS",e.EARLIER_DAYS="EARLIER_DAYS",e.RAW="RAW",e))(je||{});function _e(){return{operator:je.ALL}}const De={index:1,size:10};function Nt({condition:e=_e(),projection:t,sort:r}={}){return{condition:e,projection:t,sort:r}}function xt({condition:e=_e(),projection:t,sort:r,limit:a=De.size}={}){return{condition:e,projection:t,sort:r,limit:a}}function jt({condition:e=_e(),projection:t,sort:r,pagination:a=De}={}){return{condition:e,projection:t,sort:r,pagination:a}}const B=class{};B.EVENT_STREAM_RESOURCE_NAME="event",B.COUNT=`${B.EVENT_STREAM_RESOURCE_NAME}/count`,B.LIST=`${B.EVENT_STREAM_RESOURCE_NAME}/list`,B.PAGED=`${B.EVENT_STREAM_RESOURCE_NAME}/paged`;let de=B;var Dt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,oe=(e,t,r,a)=>{for(var i=a>1?void 0:a?Gt(t,r):t,u=e.length-1,f;u>=0;u--)(f=e[u])&&(i=(a?f(t,r,i):f(i))||i);return a&&i&&Dt(t,r,i),i},X=(e,t)=>(r,a)=>t(r,a,e);let ee=class{constructor(e){this.apiMetadata=e}count(e,t){throw G(e,t)}list(e,t){throw G(e,t)}listStream(e,t){throw G(e,t)}paged(e,t){throw G(e,t)}};oe([q(de.COUNT),X(0,H()),X(1,D())],ee.prototype,"count",1),oe([q(de.LIST),X(0,H()),X(1,D())],ee.prototype,"list",1),oe([q(de.LIST,{headers:{Accept:x.ContentTypeValues.TEXT_EVENT_STREAM},resultExtractor:ce}),X(0,H()),X(1,D())],ee.prototype,"listStream",1),oe([q(de.PAGED),X(0,H()),X(1,D())],ee.prototype,"paged",1),ee=oe([we()],ee);const j=class{};j.SNAPSHOT_RESOURCE_NAME="snapshot",j.COUNT=`${j.SNAPSHOT_RESOURCE_NAME}/count`,j.LIST=`${j.SNAPSHOT_RESOURCE_NAME}/list`,j.LIST_STATE=`${j.LIST}/state`,j.PAGED=`${j.SNAPSHOT_RESOURCE_NAME}/paged`,j.PAGED_STATE=`${j.PAGED}/state`,j.SINGLE=`${j.SNAPSHOT_RESOURCE_NAME}/single`,j.SINGLE_STATE=`${j.SINGLE}/state`;let V=j;var qt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Q=(e,t,r,a)=>{for(var i=a>1?void 0:a?Ht(t,r):t,u=e.length-1,f;u>=0;u--)(f=e[u])&&(i=(a?f(t,r,i):f(i))||i);return a&&i&&qt(t,r,i),i},N=(e,t)=>(r,a)=>t(r,a,e);let $=class{constructor(e){this.apiMetadata=e}count(e,t){throw G(e,t)}list(e,t){throw G(e,t)}listStream(e,t){throw G(e,t)}listState(e,t){throw G(e,t)}listStateStream(e,t){throw G(e,t)}paged(e,t){throw G(e,t)}pagedState(e,t){throw G(e,t)}single(e,t){throw G(e,t)}singleState(e,t){throw G(e,t)}};Q([q(V.COUNT),N(0,H()),N(1,D())],$.prototype,"count",1),Q([q(V.LIST),N(0,H()),N(1,D())],$.prototype,"list",1),Q([q(V.LIST,{headers:{Accept:x.ContentTypeValues.TEXT_EVENT_STREAM},resultExtractor:ce}),N(0,H()),N(1,D())],$.prototype,"listStream",1),Q([q(V.LIST_STATE),N(0,H()),N(1,D())],$.prototype,"listState",1),Q([q(V.LIST_STATE,{headers:{Accept:x.ContentTypeValues.TEXT_EVENT_STREAM},resultExtractor:ce}),N(0,H()),N(1,D())],$.prototype,"listStateStream",1),Q([q(V.PAGED),N(0,H()),N(1,D())],$.prototype,"paged",1),Q([q(V.PAGED_STATE),N(0,H()),N(1,D())],$.prototype,"pagedState",1),Q([q(V.SINGLE),N(0,H()),N(1,D())],$.prototype,"single",1),Q([q(V.SINGLE_STATE),N(0,H()),N(1,D())],$.prototype,"singleState",1),$=Q([we()],$);function Ut(e){const{initialQuery:t}=e,r=Z(e),[a,i]=d.useState(t.condition),[u,f]=d.useState(t.pagination),[E,w]=d.useState(t.projection),[b,O]=d.useState(t.sort),_=Y(e),A=d.useCallback(async()=>{const z=jt({condition:a,pagination:u,projection:E,sort:b});return _.current.query(z,_.current.attributes)},[a,E,u,b,_]),g=d.useCallback(()=>r.execute(A),[r,A]),{autoExecute:M}=e;return d.useEffect(()=>{M&&g()},[M,g]),d.useMemo(()=>({...r,execute:g,setCondition:i,setProjection:w,setPagination:f,setSort:O}),[r,g,i,w,f,O])}function $t(e){const{initialQuery:t}=e,r=Z(e),[a,i]=d.useState(t.condition),[u,f]=d.useState(t.projection),[E,w]=d.useState(t.sort),b=Y(e),O=d.useCallback(async()=>{const g=Nt({condition:a,projection:u,sort:E});return b.current.query(g,b.current.attributes)},[a,u,E,b]),_=d.useCallback(()=>r.execute(O),[r,O]),{autoExecute:A}=e;return d.useEffect(()=>{A&&_()},[A,_]),d.useMemo(()=>({...r,execute:_,setCondition:i,setProjection:f,setSort:w}),[r,_,i,f,w])}function Wt(e){const{initialCondition:t}=e,r=Z(e),[a,i]=d.useState(t),u=Y(e),f=d.useCallback(async()=>u.current.count(a,u.current.attributes),[a,u]),E=d.useCallback(()=>r.execute(f),[r,f]),{autoExecute:w}=e;return d.useEffect(()=>{w&&E()},[w,E]),d.useMemo(()=>({...r,execute:E,setCondition:i}),[r,E,i])}function Ge(e){const{initialQuery:t}=e,[r,a]=d.useState(t.condition),[i,u]=d.useState(t.projection),[f,E]=d.useState(t.sort),[w,b]=d.useState(t.limit),O=d.useCallback(()=>xt({condition:r,projection:i,sort:f,limit:w}),[r,i,f,w]);return d.useMemo(()=>({condition:r,projection:i,sort:f,limit:w,setCondition:a,setProjection:u,setSort:E,setLimit:b,buildQuery:O}),[r,i,f,w,a,u,E,b,O])}function Qt(e){const t=Z(e),r=Ge({initialQuery:e.initialQuery}),a=Y(e),i=d.useCallback(async()=>{const E=r.buildQuery();return a.current.list(E,a.current.attributes)},[r,a]),u=d.useCallback(()=>t.execute(i),[t,i]),{autoExecute:f}=e;return d.useEffect(()=>{f&&u()},[f,u]),d.useMemo(()=>({...t,execute:u,setCondition:r.setCondition,setProjection:r.setProjection,setSort:r.setSort,setLimit:r.setLimit}),[t,u,r.setCondition,r.setProjection,r.setSort,r.setLimit])}function Ft(e){const t=Z(e),r=Ge({initialQuery:e.initialQuery}),a=Y(e),i=d.useCallback(async()=>{const E=r.buildQuery();return a.current.listStream(E,a.current.attributes)},[r,a]),u=d.useCallback(()=>t.execute(i),[t,i]),{autoExecute:f}=e;return d.useEffect(()=>{f&&u()},[f,u]),d.useMemo(()=>({...t,execute:u,setCondition:r.setCondition,setProjection:r.setProjection,setSort:r.setSort,setLimit:r.setLimit}),[t,u,r.setCondition,r.setProjection,r.setSort,r.setLimit])}P.PromiseStatus=Ae,P.useCountQuery=Wt,P.useExecutePromise=Z,P.useFetcher=nt,P.useKeyStorage=rt,P.useLatest=Y,P.useListQuery=Qt,P.useListStreamQuery=Ft,P.useMounted=ie,P.usePagedQuery=Ut,P.usePromiseState=ye,P.useRequestId=Ee,P.useSingleQuery=$t,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})}));
18
18
  //# sourceMappingURL=index.umd.js.map