/* esm.sh - @assistant-ui/store@0.3.22/dist/useClientLookup */
import{ClientResource as p}from"./useClientResource.mjs";import{c as x}from"../../../../tap@0.9.24/X-ZHJlYWN0QDE5LjMuMQ/es2022/react-shim/compiler-runtime.mjs";import"../../../../tap@0.9.24/X-ZHJlYWN0QDE5LjMuMQ/es2022/react-shim.mjs";import{useResources as y,withKey as l}from"../../../../tap@0.9.24/X-ZHJlYWN0QDE5LjMuMQ/es2022/tap.mjs";var h=t=>{if(t.key===void 0)throw new Error("useClientLookup: Element has no key");return t.key};function L(t){let e=x(12),o;e[0]!==t?(o=t.map(a),e[0]=t,e[1]=o):o=e[1];let r=y(o),s;e[2]!==t?(s=t.reduce(w,Object.create(null)),e[2]=t,e[3]=s):s=e[3];let d=s,u;e[4]!==r?(u=r.map(g),e[4]=r,e[5]=u):u=e[5];let c=u,i;e[6]!==d||e[7]!==r?(i=n=>{if("index"in n){if(n.index<0||n.index>=r.length)throw new Error(`useClientLookup: index ${n.index} out of bounds (length: ${r.length}) (ignore if recovered)`);return r[n.index].methods}let m=d[n.key];if(m===void 0)throw new Error(`useClientLookup: key "${n.key}" not found (ignore if recovered)`);return r[m].methods},e[6]=d,e[7]=r,e[8]=i):i=e[8];let f;return e[9]!==c||e[10]!==i?(f={state:c,get:i},e[9]=c,e[10]=i,e[11]=f):f=e[11],f}function g(t){return t.state}function w(t,e,o){return t[h(e)]=o,t}function a(t){return l(h(t),p(t),t.deps)}export{L as useClientLookup};
//# sourceMappingURL=useClientLookup.mjs.map