1import{a as A}from"./chunk-JP6CW4V3.js";import{a as h,b as B,h as E,j as x,k as O,l as i,m as f,n as $,o as b}from"./chunk-ZI736UF5.js";import{da as P}from"./chunk-D56USZBB.js";import{$ as T,c as w,la as k,qa as y,ua as j,va as r}from"./chunk-UM6OWAC4.js";import{a as l,b as u,l as n}from"./chunk-ADXSR5XT.js";var I=class o{db=y(B);auth=y(P);injector=y(j);pathTo(e,t){let a=e.bucket==="async"?`groups/${e.groupUid}/async/${e.collection}`:`groups/${e.groupUid}/sessions/${e.sessionUid}/${e.collection}`;return t?`${a}/${t}`:a}emit(e,t){return n(this,null,function*(){let a=this.auth.currentUser?.uid;if(!a)throw new Error("CommandBus.emit: kein Auth-User");let s=this.pathTo(e);return yield r(this.injector,()=>n(this,null,function*(){let p=i(this.db,s),d=O(p),m=d.key??"",c=l({commandUid:m,type:t.type,payload:t.payload,emittedBy:a,emittedByRole:t.emittedByRole,emittedAt:h(),status:t.status??"pending"},t.targetCharUid?{targetCharUid:t.targetCharUid}:{});return yield $(d,C(c)),A("CommandBus","emit",{path:s,commandUid:m,type:t.type,targetCharUid:t.targetCharUid,emittedByRole:t.emittedByRole}),u(l({},e),{commandUid:m})}))})}markApplied(e,t){return n(this,null,function*(){yield r(this.injector,()=>n(this,null,function*(){let a=i(this.db,this.pathTo(e,e.commandUid));yield b(a,l(l({status:t?.status??"applied",appliedAt:h()},t?.appliedByFallback?{appliedByFallback:!0}:{}),t?.extra??{}))}))})}markTerminal(e,t,a){return n(this,null,function*(){yield r(this.injector,()=>n(this,null,function*(){let s=i(this.db,this.pathTo(e,e.commandUid));yield b(s,l({status:t},a??{}))}))})}remove(e){return n(this,null,function*(){yield r(this.injector,()=>n(this,null,function*(){let t=i(this.db,this.pathTo(e,e.commandUid));yield f(t)}))})}streamCache=new Map;streamCollection(e){let t=this.pathTo(e),a=this.streamCache.get(t);if(a)return a;let s=new w(p=>{let d=null,m=null;return r(this.injector,()=>{d=i(this.db,t),m=x(d,c=>{let g=c.val(),R=new Map;if(g)for(let[U,v]of Object.entries(g))v&&R.set(U,u(l({},v),{commandUid:U}));p.next(R)},c=>p.error(c))}),()=>{d&&r(this.injector,()=>E(d)),m&&m()}}).pipe(T({bufferSize:1,refCount:!0}));return this.streamCache.set(t,s),s}flushBucket(e){return n(this,null,function*(){yield r(this.injector,()=>n(this,null,function*(){let t=e.bucket==="async"?`groups/${e.groupUid}/async`:`groups/${e.groupUid}/sessions/${e.sessionUid}`;yield f(i(this.db,t))}))})}refOf(e){return r(this.injector,()=>i(this.db,this.pathTo(e,e.commandUid)))}static \u0275fac=function(t){return new(t||o)};static \u0275prov=k({token:o,factory:o.\u0275fac,providedIn:"root"})};function C(o){if(Array.isArray(o))return o.map(e=>C(e));if(o&&typeof o=="object"){let e={};for(let[t,a]of Object.entries(o))a!==void 0&&(e[t]=C(a));return e}return o}export{I as a};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.