import{g as e}from"./p-a599f720.js";import{u as t,I as o,J as r}from"./p-9811c98c.js";function n(){return function(n,s){const{connectedCallback:c,disconnectedCallback:a}=n;n.connectedCallback=function(){const n=e(this),a=n[s];n[`_rtkStoreToCleanup-${s}`]=t,a||(n[s]=t.state[s],o(s,n,t));const u=e=>{if(e.detail.requestId===n._storeRequestId){const c=e.detail.store.state[s];n.componentOnReady().then((()=>{n[s]=c})),o(s,n,e.detail.store),n[`_rtkStoreToCleanup-${s}`]=e.detail.store,r(s,n,t)}};n[`_rtkStoreResponseListener-${s}`]=u,document.addEventListener("rtkProvideStore",u);const d=`${n.tagName}-${Date.now()}-${Math.random()}`;n._storeRequestId=d;const i=new CustomEvent("rtkRequestStore",{detail:{element:n,propName:s,requestId:d},bubbles:!0,composed:!0});n.dispatchEvent(i);const l=()=>{const e=`${n.tagName}-${Date.now()}-${Math.random().toString(36)}`;n._storeRequestId=e;const t=new CustomEvent("rtkRequestStore",{detail:{element:n,propName:s,requestId:e},bubbles:!0,composed:!0});n.dispatchEvent(t)};return n[`_rtkStoreReadyListener-${s}`]=l,document.addEventListener("rtkPeerStoreReady",l),null==c?void 0:c.call(this)},n.disconnectedCallback=function(){const t=e(this);r(s,t,t[`_rtkStoreToCleanup-${s}`]);const o=t[`_rtkStoreResponseListener-${s}`];o&&(document.removeEventListener("rtkProvideStore",o),delete t[`_rtkStoreResponseListener-${s}`]);const n=t[`_rtkStoreReadyListener-${s}`];return n&&(document.removeEventListener("rtkPeerStoreReady",n),delete t[`_rtkStoreReadyListener-${s}`]),null==a?void 0:a.call(this)}}}export{n as S}