import{d as l}from"./preact.js";import{a as s,_ as p}from"./tslib.js";function c(n){return n}function d(n,e){e===void 0&&(e=c);var r=[],i=!1,h={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:n},useMedium:function(u){var t=e(u,i);return r.push(t),function(){r=r.filter(function(a){return a!==t})}},assignSyncMedium:function(u){for(i=!0;r.length;){var t=r;r=[],t.forEach(u)}r={push:function(a){return u(a)},filter:function(){return r}}},assignMedium:function(u){i=!0;var t=[];if(r.length){var a=r;r=[],a.forEach(u),t=r}var v=function(){var o=t;t=[],o.forEach(u)},f=function(){return Promise.resolve().then(v)};f(),r={push:function(o){t.push(o),f()},filter:function(o){return t=t.filter(o),r}}}};return h}function S(n,e){return e===void 0&&(e=c),d(n,e)}function C(n){n===void 0&&(n={});var e=d(null);return e.options=s({async:!0,ssr:!1},n),e}var m=function(n){var e=n.sideCar,r=p(n,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=e.read();if(!i)throw new Error("Sidecar medium not found");return l(i,s({},r))};m.isSideCarExport=!0;function E(n,e){return n.useMedium(e),m}export{C as a,S as c,E as e};
