import{Ba as d,Fa as f,Ga as y,Ha as D,Sc as g,Tc as w,c as l,ea as m,f as p,la as b,ra as a,za as v}from"./chunk-GJDGQISV.js";function E(t){t||(t=a(d));let e=new l(n=>{if(t.destroyed){n.next();return}return t.onDestroy(n.next.bind(n))});return n=>n.pipe(m(e))}function U(t,e){let n=e?.injector??a(v),r=new p(1),u=D(()=>{let o;try{o=t()}catch(i){g(()=>r.error(i));return}g(()=>r.next(o))},{injector:n,manualCleanup:!0});return n.get(d).onDestroy(()=>{u.destroy(),r.complete()}),r.asObservable()}function T(t,e){let r=!e?.manualCleanup?e?.injector?.get(d)??a(d):null,u=x(e?.equal),o;e?.requireSync?o=f({kind:0},{equal:u}):o=f({kind:1,value:e?.initialValue},{equal:u});let i,c=t.subscribe({next:s=>o.set({kind:1,value:s}),error:s=>{o.set({kind:2,error:s}),i?.()},complete:()=>{i?.()}});if(e?.requireSync&&o().kind===0)throw new b(601,!1);return i=r?.onDestroy(c.unsubscribe.bind(c)),w(()=>{let s=o();switch(s.kind){case 1:return s.value;case 2:throw s.error;case 0:throw new b(601,!1)}},{equal:e?.equal})}function x(t=Object.is){return(e,n)=>e.kind===1&&n.kind===1&&t(e.value,n.value)}function F(t){t===void 0&&(t=a(v));let e=t.get(y);return n=>new l(r=>{let u=e.add(),o=!1;function i(){o||(u(),o=!0)}let c=n.subscribe({next:s=>{r.next(s),i()},complete:()=>{r.complete(),i()},error:s=>{r.error(s),i()}});return c.add(()=>{r.unsubscribe(),i()}),c})}export{E as a,U as b,T as c,F as d};
