@veltdev/sdk-dev 6.0.20 → 6.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/app/models/data/comment-resolver.data.model.d.ts +22 -0
  2. package/app/models/data/suggestion.data.model.d.ts +15 -3
  3. package/{chunk-E4QNS7VC.js → chunk-3M5GZFCG.js} +1 -1
  4. package/{chunk-6KHIJTYE.js → chunk-3PSEC6OK.js} +1 -1
  5. package/{chunk-PF5MHE5Q.js → chunk-5GFU7BU6.js} +1 -1
  6. package/{chunk-4WU3OMP2.js → chunk-6BCXLMAY.js} +1 -1
  7. package/{chunk-J3PDCLKW.js → chunk-6F7MEOHL.js} +1 -1
  8. package/{chunk-4NYZ7Q5F.js → chunk-C3DWGOTZ.js} +1 -1
  9. package/chunk-CJVRXVE5.js +1 -0
  10. package/chunk-COMT5MGY.js +1 -0
  11. package/{chunk-4PAKODQF.js → chunk-CQZ7DKJB.js} +1 -1
  12. package/{chunk-CLK24UPS.js → chunk-D2UJGDHP.js} +1 -1
  13. package/{chunk-KV2F6ZIJ.js → chunk-EC25EQB5.js} +1 -1
  14. package/{chunk-2K4M4I5G.js → chunk-EIDOVJ3L.js} +1 -1
  15. package/{chunk-ENQ42YAR.js → chunk-F2XJIYNI.js} +1 -1
  16. package/{chunk-5FPHCROD.js → chunk-F2Z7K4AL.js} +1 -1
  17. package/{chunk-ZJUF7S5H.js → chunk-GUBXZVJ3.js} +1 -1
  18. package/{chunk-VWOXXP3V.js → chunk-J2NS4TI4.js} +1 -1
  19. package/{chunk-MVAJQILF.js → chunk-KE64O5B7.js} +1 -1
  20. package/{chunk-RBFBB2SC.js → chunk-KXEU5HGR.js} +1 -1
  21. package/{chunk-GSCT27LN.js → chunk-M5AN4E5A.js} +1 -1
  22. package/{chunk-4LTEANME.js → chunk-MAEEPXIL.js} +1 -1
  23. package/{chunk-Y6Q4SFD6.js → chunk-MGORC6ST.js} +1 -1
  24. package/{chunk-UMIDGOUI.js → chunk-MU6RYO5X.js} +1 -1
  25. package/{chunk-N2YYT47V.js → chunk-N2ZDAA6T.js} +1 -1
  26. package/{chunk-LYIFCKA6.js → chunk-O4J2GUCR.js} +1 -1
  27. package/{chunk-I24IAAR4.js → chunk-RCOPSCV6.js} +1 -1
  28. package/{chunk-MHSBCVFV.js → chunk-TDVYFBCW.js} +1 -1
  29. package/{chunk-ZQSDSZOY.js → chunk-TM2JOAC4.js} +1 -1
  30. package/{chunk-VXMLF2G3.js → chunk-TVANUSZU.js} +1 -1
  31. package/{chunk-XI2QEQ25.js → chunk-UFGQLAOK.js} +1 -1
  32. package/{chunk-GY5ZVUQW.js → chunk-UWH2AIKJ.js} +1 -1
  33. package/{chunk-XNDAIOIN.js → chunk-V53LQO22.js} +26 -26
  34. package/{chunk-Z7RCORHX.js → chunk-VFYLOVTK.js} +1 -1
  35. package/chunk-XAZILV5B.js +2 -0
  36. package/{chunk-3EAHY5AQ.js → chunk-ZEWGJF7N.js} +1 -1
  37. package/{chunk-D3WKAG4L.js → chunk-ZURN7SUE.js} +1 -1
  38. package/package.json +1 -1
  39. package/velt-activity-log.js +1 -1
  40. package/velt-area.js +1 -1
  41. package/velt-arrow.js +1 -1
  42. package/velt-comment.js +7 -7
  43. package/velt-crdt.js +1 -1
  44. package/velt-cursor.js +1 -1
  45. package/velt-huddle.js +1 -1
  46. package/velt-live-state-sync.js +1 -1
  47. package/velt-notification.js +1 -1
  48. package/velt-portable.js +1 -1
  49. package/velt-presence.js +1 -1
  50. package/velt-reaction.js +1 -1
  51. package/velt-recorder.js +1 -1
  52. package/velt-rewriter.js +1 -1
  53. package/velt-selection.js +1 -1
  54. package/velt-tag.js +1 -1
  55. package/velt-user-invite.js +1 -1
  56. package/velt-user-request.js +1 -1
  57. package/velt-video-player.js +1 -1
  58. package/velt-views.js +1 -1
  59. package/velt.js +2 -2
  60. package/chunk-7CGDY3KI.js +0 -2
  61. package/chunk-IH7GHE67.js +0 -1
  62. package/chunk-OBUNJ4HX.js +0 -1
@@ -3,6 +3,7 @@ import { PartialAttachment } from "./attachment-resolver.data.model";
3
3
  import { BaseMetadata } from "./base-metadata.data.model";
4
4
  import { CommentAnnotation } from "./comment-annotation.data.model";
5
5
  import { ResolverConfig, ResolverResponse } from "./resolver.data.model";
6
+ import { SuggestionData } from "./suggestion.data.model";
6
7
  export interface CommentAnnotationDataProvider {
7
8
  get?: (request: GetCommentResolverRequest) => Promise<ResolverResponse<Record<string, PartialCommentAnnotation>>>;
8
9
  save?: (request: SaveCommentResolverRequest) => Promise<ResolverResponse<undefined>>;
@@ -29,6 +30,11 @@ export interface SaveCommentResolverRequest {
29
30
  * The save event. One of the 4 core PII events (`ResolverActions`) or, when the customer
30
31
  * opts in via `ResolverConfig.additionalSaveEvents`, a non-core annotation-level event
31
32
  * (`CommentResolverSaveEvent`). See specs/comment-resolver iteration-2.
33
+ *
34
+ * Exception (comment-resolver iteration-3): `comment_annotation.suggestion_reject` is sent WITHOUT
35
+ * opt-in whenever the annotation carries a `suggestion` — it is the only suggestion transition that
36
+ * carries new content (`rejectReason`). A backend must answer 2xx and upsert for ANY event value,
37
+ * and an event name alone never means "apply the change": read `suggestion.status`.
32
38
  */
33
39
  event?: ResolverActions | CommentResolverSaveEvent;
34
40
  metadata?: BaseMetadata;
@@ -73,6 +79,13 @@ export interface PartialCommentAnnotationResult {
73
79
  * `CommonDbUtilsService` forwards it to the Velt-DB filter as `keepContextText`.
74
80
  */
75
81
  veltCopyKeepsContextText?: boolean;
82
+ /**
83
+ * INTERNAL (SDK write path only, never sent to a resolver). True when `originalData.suggestion`
84
+ * still carries its content keys on purpose (comment-resolver AC-032): a legacy row whose resolver
85
+ * copy does not hold them yet and this save is not a core hand-off. Forwarded by
86
+ * `CommonDbUtilsService` to the Velt-DB filter as `keepSuggestionContent`.
87
+ */
88
+ veltCopyKeepsSuggestionContent?: boolean;
76
89
  }
77
90
  export interface PartialTargetTextRange {
78
91
  text: string;
@@ -103,5 +116,14 @@ export interface PartialCommentAnnotation {
103
116
  };
104
117
  targetTextRange?: PartialTargetTextRange;
105
118
  resolvedByUserId?: string | null;
119
+ /**
120
+ * The suggestion (comment-resolver iteration-3) — present when the annotation carries one. Its
121
+ * content keys (`oldValue`, `newValue`, `summary`, `rejectReason`) are PII: they live only here,
122
+ * never in Velt. When sent it is always COMPLETE (the content your store already holds plus this
123
+ * write), so a backend may replace the stored value wholesale. `resolvedBy` may be `{ userId }`
124
+ * under a user resolver. On `get`, only the content keys are read back — Velt stays authoritative
125
+ * for `status`, `resolvedBy` and `resolvedAt`. Backends must persist and return it.
126
+ */
127
+ suggestion?: Partial<SuggestionData>;
106
128
  [key: string]: any;
107
129
  }
@@ -116,7 +116,7 @@ export interface TargetEditCommitResult {
116
116
  * attributes are preserved.
117
117
  */
118
118
  summaryHtml?: string;
119
- /** Customer metadata persisted on the resulting Suggestion. */
119
+ /** Customer metadata persisted on the resulting suggestion (`Suggestion.metadata`). */
120
120
  metadata?: Record<string, unknown>;
121
121
  }
122
122
  /**
@@ -204,6 +204,11 @@ export interface SuggestionData {
204
204
  */
205
205
  resolvedBy: User | null;
206
206
  resolvedAt: number | null;
207
+ /**
208
+ * Customer metadata from `CommitSuggestionConfig.metadata` (a JSON clone; absent when none was given).
209
+ * Self-hosting: content — with a comment resolver it is stored by the resolver only.
210
+ */
211
+ metadata?: Record<string, unknown>;
207
212
  }
208
213
  /**
209
214
  * Fields shared across every Suggestion regardless of status.
@@ -222,7 +227,10 @@ interface SuggestionBase<T = unknown> {
222
227
  newValue: T;
223
228
  /** Optional human-readable description. */
224
229
  summary: string | null;
225
- /** Customer-defined metadata supplied via CommitSuggestionConfig.metadata. */
230
+ /**
231
+ * Customer-defined metadata supplied via CommitSuggestionConfig.metadata (always an object;
232
+ * `{}` when none was given). Contains only the customer's keys.
233
+ */
226
234
  metadata: Record<string, any>;
227
235
  /** True iff the live value at approve time differed from oldValue. */
228
236
  driftDetected: boolean;
@@ -297,7 +305,11 @@ export interface CommitSuggestionConfig<T = unknown> {
297
305
  * `style` attributes are preserved so rich diff styling survives.
298
306
  */
299
307
  summaryHtml?: string;
300
- /** Optional customer-defined metadata. Stored on Suggestion.metadata. */
308
+ /**
309
+ * Optional customer-defined metadata (a plain JSON object). Stored on the suggestion
310
+ * (`annotation.suggestion.metadata`) and returned as `Suggestion.metadata`. With a comment
311
+ * resolver (self-hosting) it is stored by the resolver only.
312
+ */
301
313
  metadata?: Record<string, unknown>;
302
314
  }
303
315
  /**
@@ -1,4 +1,4 @@
1
- import{Cd as qe,Hd as $e,Ja as ke,ad as ye,bd as ne,cd as Ee,da as Re,dd as Ue,ed as Ae,fd as Oe,g as K,ga as Te,gd as C,hd as Se,id as Ie,jd as Pe,kd as Ne,ld as Ce,md as xe,na as we,nd as H,sd as ve,td as De,ud as Le,va as $,vd as Be,wd as x,xd as Me,yd as Fe}from"./chunk-XNDAIOIN.js";var Ke="firebasestorage.googleapis.com",Ze="storageBucket",Tt=120*1e3,wt=600*1e3,kt=1e3;var d=class t extends Oe{constructor(e,n,s=0){super(se(e),`Firebase Storage: ${n} (${se(e)})`),this.status_=s,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,t.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return se(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
1
+ import{Cd as qe,Hd as $e,Ja as ke,ad as ye,bd as ne,cd as Ee,da as Re,dd as Ue,ed as Ae,fd as Oe,g as K,ga as Te,gd as C,hd as Se,id as Ie,jd as Pe,kd as Ne,ld as Ce,md as xe,na as we,nd as H,sd as ve,td as De,ud as Le,va as $,vd as Be,wd as x,xd as Me,yd as Fe}from"./chunk-V53LQO22.js";var Ke="firebasestorage.googleapis.com",Ze="storageBucket",Tt=120*1e3,wt=600*1e3,kt=1e3;var d=class t extends Oe{constructor(e,n,s=0){super(se(e),`Firebase Storage: ${n} (${se(e)})`),this.status_=s,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,t.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return se(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
2
2
  ${this.customData.serverResponse}`:this.message=this._baseMessage}},h=(function(t){return t.UNKNOWN="unknown",t.OBJECT_NOT_FOUND="object-not-found",t.BUCKET_NOT_FOUND="bucket-not-found",t.PROJECT_NOT_FOUND="project-not-found",t.QUOTA_EXCEEDED="quota-exceeded",t.UNAUTHENTICATED="unauthenticated",t.UNAUTHORIZED="unauthorized",t.UNAUTHORIZED_APP="unauthorized-app",t.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",t.INVALID_CHECKSUM="invalid-checksum",t.CANCELED="canceled",t.INVALID_EVENT_NAME="invalid-event-name",t.INVALID_URL="invalid-url",t.INVALID_DEFAULT_BUCKET="invalid-default-bucket",t.NO_DEFAULT_BUCKET="no-default-bucket",t.CANNOT_SLICE_BLOB="cannot-slice-blob",t.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",t.NO_DOWNLOAD_URL="no-download-url",t.INVALID_ARGUMENT="invalid-argument",t.INVALID_ARGUMENT_COUNT="invalid-argument-count",t.APP_DELETED="app-deleted",t.INVALID_ROOT_OPERATION="invalid-root-operation",t.INVALID_FORMAT="invalid-format",t.INTERNAL_ERROR="internal-error",t.UNSUPPORTED_ENVIRONMENT="unsupported-environment",t})(h||{});function se(t){return"storage/"+t}function de(){let t="An unknown error occurred, please check the error payload for server response.";return new d(h.UNKNOWN,t)}function yt(t){return new d(h.OBJECT_NOT_FOUND,"Object '"+t+"' does not exist.")}function Et(t){return new d(h.QUOTA_EXCEEDED,"Quota for bucket '"+t+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function Ut(){let t="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new d(h.UNAUTHENTICATED,t)}function At(){return new d(h.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function Ot(t){return new d(h.UNAUTHORIZED,"User does not have permission to access '"+t+"'.")}function Ye(){return new d(h.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function Je(){return new d(h.CANCELED,"User canceled the upload/download.")}function St(t){return new d(h.INVALID_URL,"Invalid URL '"+t+"'.")}function It(t){return new d(h.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+t+"'.")}function Pt(){return new d(h.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+Ze+"' property when initializing the app?")}function Qe(){return new d(h.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function Nt(){return new d(h.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.")}function Ct(){return new d(h.NO_DOWNLOAD_URL,"The given file does not have any download URLs.")}function xt(t){return new d(h.UNSUPPORTED_ENVIRONMENT,`${t} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function oe(t){return new d(h.INVALID_ARGUMENT,t)}function et(){return new d(h.APP_DELETED,"The Firebase app was deleted.")}function vt(t){return new d(h.INVALID_ROOT_OPERATION,"The operation '"+t+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function z(t,e){return new d(h.INVALID_FORMAT,"String does not match format '"+t+"': "+e)}function j(t){throw new d(h.INTERNAL_ERROR,"Internal error: "+t)}var y=class t{constructor(e,n){this.bucket=e,this.path_=n}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){let e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,n){let s;try{s=t.makeFromUrl(e,n)}catch{return new t(e,"")}if(s.path==="")return s;throw It(e)}static makeFromUrl(e,n){let s=null,r="([A-Za-z0-9.\\-_]+)";function o(b){b.path.charAt(b.path.length-1)==="/"&&(b.path_=b.path_.slice(0,-1))}let i="(/(.*))?$",u=new RegExp("^gs://"+r+i,"i"),a={bucket:1,path:3};function c(b){b.path_=decodeURIComponent(b.path)}let l="v[A-Za-z0-9_]+",f=n.replace(/[.]/g,"\\."),p="(/([^?#]*).*)?$",m=new RegExp(`^https?://${f}/${l}/b/${r}/o${p}`,"i"),g={bucket:1,path:3},w=n===Ke?"(?:storage.googleapis.com|storage.cloud.google.com)":n,_="([^?#]*)",U=new RegExp(`^https?://${w}/${r}/${_}`,"i"),T=[{regex:u,indices:a,postModify:o},{regex:m,indices:g,postModify:c},{regex:U,indices:{bucket:1,path:2},postModify:c}];for(let b=0;b<T.length;b++){let P=T[b],N=P.regex.exec(e);if(N){let ee=N[P.indices.bucket],q=N[P.indices.path];q||(q=""),s=new t(ee,q),P.postModify(s);break}}if(s==null)throw St(e);return s}},ie=class{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}};function Dt(t,e,n){let s=1,r=null,o=null,i=!1,u=0;function a(){return u===2}let c=!1;function l(..._){c||(c=!0,e.apply(null,_))}function f(_){r=setTimeout(()=>{r=null,t(m,a())},_)}function p(){o&&clearTimeout(o)}function m(_,...U){if(c){p();return}if(_){p(),l.call(null,_,...U);return}if(a()||i){p(),l.call(null,_,...U);return}s<64&&(s*=2);let T;u===1?(u=2,T=0):T=(s+Math.random())*1e3,f(T)}let g=!1;function w(_){g||(g=!0,p(),!c&&(r!==null?(_||(u=2),clearTimeout(r),f(0)):_||(u=1)))}return f(0),o=setTimeout(()=>{i=!0,w(!0)},n),w}function Lt(t){t(!1)}function Bt(t){return t!==void 0}function Mt(t){return typeof t=="function"}function Ft(t){return typeof t=="object"&&!Array.isArray(t)}function Q(t){return typeof t=="string"||t instanceof String}function He(t){return fe()&&t instanceof Blob}function fe(){return typeof Blob<"u"}function je(t,e,n,s){if(s<e)throw oe(`Invalid value for '${t}'. Expected ${e} or greater.`);if(s>n)throw oe(`Invalid value for '${t}'. Expected ${n} or less.`)}function F(t,e,n){let s=e;return n==null&&(s=`https://${e}`),`${n}://${s}/v0${t}`}function tt(t){let e=encodeURIComponent,n="?";for(let s in t)if(t.hasOwnProperty(s)){let r=e(s)+"="+e(t[s]);n=n+r+"&"}return n=n.slice(0,-1),n}var L=(function(t){return t[t.NO_ERROR=0]="NO_ERROR",t[t.NETWORK_ERROR=1]="NETWORK_ERROR",t[t.ABORT=2]="ABORT",t})(L||{});function nt(t,e){let n=t>=500&&t<600,r=[408,429].indexOf(t)!==-1,o=e.indexOf(t)!==-1;return n||r||o}var ae=class{constructor(e,n,s,r,o,i,u,a,c,l,f,p=!0,m=!1){this.url_=e,this.method_=n,this.headers_=s,this.body_=r,this.successCodes_=o,this.additionalRetryCodes_=i,this.callback_=u,this.errorCallback_=a,this.timeout_=c,this.progressCallback_=l,this.connectionFactory_=f,this.retry=p,this.isUsingEmulator=m,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((g,w)=>{this.resolve_=g,this.reject_=w,this.start_()})}start_(){let e=(s,r)=>{if(r){s(!1,new D(!1,null,!0));return}let o=this.connectionFactory_();this.pendingConnection_=o;let i=u=>{let a=u.loaded,c=u.lengthComputable?u.total:-1;this.progressCallback_!==null&&this.progressCallback_(a,c)};this.progressCallback_!==null&&o.addUploadProgressListener(i),o.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&o.removeUploadProgressListener(i),this.pendingConnection_=null;let u=o.getErrorCode()===L.NO_ERROR,a=o.getStatus();if(!u||nt(a,this.additionalRetryCodes_)&&this.retry){let l=o.getErrorCode()===L.ABORT;s(!1,new D(!1,null,l));return}let c=this.successCodes_.indexOf(a)!==-1;s(!0,new D(c,o))})},n=(s,r)=>{let o=this.resolve_,i=this.reject_,u=r.connection;if(r.wasSuccessCode)try{let a=this.callback_(u,u.getResponse());Bt(a)?o(a):o()}catch(a){i(a)}else if(u!==null){let a=de();a.serverResponse=u.getErrorText(),this.errorCallback_?i(this.errorCallback_(u,a)):i(a)}else if(r.canceled){let a=this.appDelete_?et():Je();i(a)}else{let a=Ye();i(a)}};this.canceled_?n(!1,new D(!1,null,!0)):this.backoffId_=Dt(e,n,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&Lt(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}},D=class{constructor(e,n,s){this.wasSuccessCode=e,this.connection=n,this.canceled=!!s}};function qt(t,e){e!==null&&e.length>0&&(t.Authorization="Firebase "+e)}function $t(t,e){t["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function Ht(t,e){e&&(t["X-Firebase-GMPID"]=e)}function jt(t,e){e!==null&&(t["X-Firebase-AppCheck"]=e)}function zt(t,e,n,s,r,o,i=!0,u=!1){let a=tt(t.urlParams),c=t.url+a,l=Object.assign({},t.headers);return Ht(l,e),qt(l,n),$t(l,o),jt(l,s),new ae(c,t.method,l,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,r,i,u)}function Gt(){return typeof BlobBuilder<"u"?BlobBuilder:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:void 0}function Wt(...t){let e=Gt();if(e!==void 0){let n=new e;for(let s=0;s<t.length;s++)n.append(t[s]);return n.getBlob()}else{if(fe())return new Blob(t);throw new d(h.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}}function Vt(t,e,n){return t.webkitSlice?t.webkitSlice(e,n):t.mozSlice?t.mozSlice(e,n):t.slice?t.slice(e,n):null}function Xt(t){if(typeof atob>"u")throw xt("base-64");return atob(t)}var E={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"},G=class{constructor(e,n){this.data=e,this.contentType=n||null}};function Kt(t,e){switch(t){case E.RAW:return new G(st(e));case E.BASE64:case E.BASE64URL:return new G(rt(t,e));case E.DATA_URL:return new G(Yt(e),Jt(e))}throw de()}function st(t){let e=[];for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);if(s<=127)e.push(s);else if(s<=2047)e.push(192|s>>6,128|s&63);else if((s&64512)===55296)if(!(n<t.length-1&&(t.charCodeAt(n+1)&64512)===56320))e.push(239,191,189);else{let o=s,i=t.charCodeAt(++n);s=65536|(o&1023)<<10|i&1023,e.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|s&63)}else(s&64512)===56320?e.push(239,191,189):e.push(224|s>>12,128|s>>6&63,128|s&63)}return new Uint8Array(e)}function Zt(t){let e;try{e=decodeURIComponent(t)}catch{throw z(E.DATA_URL,"Malformed data URL.")}return st(e)}function rt(t,e){switch(t){case E.BASE64:{let r=e.indexOf("-")!==-1,o=e.indexOf("_")!==-1;if(r||o)throw z(t,"Invalid character '"+(r?"-":"_")+"' found: is it base64url encoded?");break}case E.BASE64URL:{let r=e.indexOf("+")!==-1,o=e.indexOf("/")!==-1;if(r||o)throw z(t,"Invalid character '"+(r?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let n;try{n=Xt(e)}catch(r){throw r.message.includes("polyfill")?r:z(t,"Invalid character found")}let s=new Uint8Array(n.length);for(let r=0;r<n.length;r++)s[r]=n.charCodeAt(r);return s}var Y=class{constructor(e){this.base64=!1,this.contentType=null;let n=e.match(/^data:([^,]+)?,/);if(n===null)throw z(E.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");let s=n[1]||null;s!=null&&(this.base64=Qt(s,";base64"),this.contentType=this.base64?s.substring(0,s.length-7):s),this.rest=e.substring(e.indexOf(",")+1)}};function Yt(t){let e=new Y(t);return e.base64?rt(E.BASE64,e.rest):Zt(e.rest)}function Jt(t){return new Y(t).contentType}function Qt(t,e){return t.length>=e.length?t.substring(t.length-e.length)===e:!1}var J=class t{constructor(e,n){let s=0,r="";He(e)?(this.data_=e,s=e.size,r=e.type):e instanceof ArrayBuffer?(n?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),s=this.data_.length):e instanceof Uint8Array&&(n?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),s=e.length),this.size_=s,this.type_=r}size(){return this.size_}type(){return this.type_}slice(e,n){if(He(this.data_)){let s=this.data_,r=Vt(s,e,n);return r===null?null:new t(r)}else{let s=new Uint8Array(this.data_.buffer,e,n-e);return new t(s,!0)}}static getBlob(...e){if(fe()){let n=e.map(s=>s instanceof t?s.data_:s);return new t(Wt.apply(null,n))}else{let n=e.map(i=>Q(i)?Kt(E.RAW,i).data:i.data_),s=0;n.forEach(i=>{s+=i.byteLength});let r=new Uint8Array(s),o=0;return n.forEach(i=>{for(let u=0;u<i.length;u++)r[o++]=i[u]}),new t(r,!0)}}uploadData(){return this.data_}};function ot(t){let e;try{e=JSON.parse(t)}catch{return null}return Ft(e)?e:null}function en(t){if(t.length===0)return null;let e=t.lastIndexOf("/");return e===-1?"":t.slice(0,e)}function tn(t,e){let n=e.split("/").filter(s=>s.length>0).join("/");return t.length===0?n:t+"/"+n}function it(t){let e=t.lastIndexOf("/",t.length-2);return e===-1?t:t.slice(e+1)}function nn(t,e){return e}var R=class{constructor(e,n,s,r){this.server=e,this.local=n||e,this.writable=!!s,this.xform=r||nn}},Z=null;function sn(t){return!Q(t)||t.length<2?t:it(t)}function at(){if(Z)return Z;let t=[];t.push(new R("bucket")),t.push(new R("generation")),t.push(new R("metageneration")),t.push(new R("name","fullPath",!0));function e(o,i){return sn(i)}let n=new R("name");n.xform=e,t.push(n);function s(o,i){return i!==void 0?Number(i):i}let r=new R("size");return r.xform=s,t.push(r),t.push(new R("timeCreated")),t.push(new R("updated")),t.push(new R("md5Hash",null,!0)),t.push(new R("cacheControl",null,!0)),t.push(new R("contentDisposition",null,!0)),t.push(new R("contentEncoding",null,!0)),t.push(new R("contentLanguage",null,!0)),t.push(new R("contentType",null,!0)),t.push(new R("metadata","customMetadata",!0)),Z=t,Z}function rn(t,e){function n(){let s=t.bucket,r=t.fullPath,o=new y(s,r);return e._makeStorageReference(o)}Object.defineProperty(t,"ref",{get:n})}function on(t,e,n){let s={};s.type="file";let r=n.length;for(let o=0;o<r;o++){let i=n[o];s[i.local]=i.xform(s,e[i.server])}return rn(s,t),s}function ut(t,e,n){let s=ot(e);return s===null?null:on(t,s,n)}function an(t,e,n,s){let r=ot(e);if(r===null||!Q(r.downloadTokens))return null;let o=r.downloadTokens;if(o.length===0)return null;let i=encodeURIComponent;return o.split(",").map(c=>{let l=t.bucket,f=t.fullPath,p="/b/"+i(l)+"/o/"+i(f),m=F(p,n,s),g=tt({alt:"media",token:c});return m+g})[0]}function ct(t,e){let n={},s=e.length;for(let r=0;r<s;r++){let o=e[r];o.writable&&(n[o.server]=t[o.local])}return JSON.stringify(n)}var S=class{constructor(e,n,s,r){this.url=e,this.method=n,this.handler=s,this.timeout=r,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}};function O(t){if(!t)throw de()}function _e(t,e){function n(s,r){let o=ut(t,r,e);return O(o!==null),o}return n}function un(t,e){function n(s,r){let o=ut(t,r,e);return O(o!==null),an(o,r,t.host,t._protocol)}return n}function V(t){function e(n,s){let r;return n.getStatus()===401?n.getErrorText().includes("Firebase App Check token is invalid")?r=At():r=Ut():n.getStatus()===402?r=Et(t.bucket):n.getStatus()===403?r=Ot(t.path):r=s,r.status=n.getStatus(),r.serverResponse=s.serverResponse,r}return e}function pe(t){let e=V(t);function n(s,r){let o=e(s,r);return s.getStatus()===404&&(o=yt(t.path)),o.serverResponse=r.serverResponse,o}return n}function cn(t,e,n){let s=e.fullServerUrl(),r=F(s,t.host,t._protocol),o="GET",i=t.maxOperationRetryTime,u=new S(r,o,_e(t,n),i);return u.errorHandler=pe(e),u}function ln(t,e,n){let s=e.fullServerUrl(),r=F(s,t.host,t._protocol),o="GET",i=t.maxOperationRetryTime,u=new S(r,o,un(t,n),i);return u.errorHandler=pe(e),u}function hn(t,e){let n=e.fullServerUrl(),s=F(n,t.host,t._protocol),r="DELETE",o=t.maxOperationRetryTime;function i(a,c){}let u=new S(s,r,i,o);return u.successCodes=[200,204],u.errorHandler=pe(e),u}function dn(t,e){return t&&t.contentType||e&&e.type()||"application/octet-stream"}function lt(t,e,n){let s=Object.assign({},n);return s.fullPath=t.path,s.size=e.size(),s.contentType||(s.contentType=dn(null,e)),s}function fn(t,e,n,s,r){let o=e.bucketOnlyServerUrl(),i={"X-Goog-Upload-Protocol":"multipart"};function u(){let T="";for(let b=0;b<2;b++)T=T+Math.random().toString().slice(2);return T}let a=u();i["Content-Type"]="multipart/related; boundary="+a;let c=lt(e,s,r),l=ct(c,n),f="--"+a+`\r
3
3
  Content-Type: application/json; charset=utf-8\r
4
4
  \r
@@ -1 +1 @@
1
- import{B as s,K as a,ba as c,ea as n,hj as h,l as o}from"./chunk-XNDAIOIN.js";var u=(()=>{let r=class r{constructor(t){this.loggingService=t,this.toasts$=new o([])}setToast(t){try{t.id||(t.id=Math.random()),this.toasts$.next([...this.toasts$.value,t]),t.duration&&t.duration>0&&s(t.duration).pipe(a(1)).subscribe(()=>{this.removeToast(t)},i=>{this.loggingService.catch("Error in ToastService setToast timer subscription: ",i)})}catch(i){this.loggingService.catch("Error in ToastService setToast: ",i)}}removeToast(t){try{this.toasts$.next(this.toasts$.value.filter(i=>i.id!==t.id))}catch(i){this.loggingService.catch("Error in ToastService removeToast: ",i)}}getToasts$(){return this.toasts$.asObservable()}};r.\u0275fac=function(i){return new(i||r)(n(h))},r.\u0275prov=c({token:r,factory:r.\u0275fac,providedIn:"root"});let e=r;return e})();export{u as a};
1
+ import{B as s,K as a,ba as c,ea as n,l as o,nj as h}from"./chunk-V53LQO22.js";var u=(()=>{let r=class r{constructor(t){this.loggingService=t,this.toasts$=new o([])}setToast(t){try{t.id||(t.id=Math.random()),this.toasts$.next([...this.toasts$.value,t]),t.duration&&t.duration>0&&s(t.duration).pipe(a(1)).subscribe(()=>{this.removeToast(t)},i=>{this.loggingService.catch("Error in ToastService setToast timer subscription: ",i)})}catch(i){this.loggingService.catch("Error in ToastService setToast: ",i)}}removeToast(t){try{this.toasts$.next(this.toasts$.value.filter(i=>i.id!==t.id))}catch(i){this.loggingService.catch("Error in ToastService removeToast: ",i)}}getToasts$(){return this.toasts$.asObservable()}};r.\u0275fac=function(i){return new(i||r)(n(h))},r.\u0275prov=c({token:r,factory:r.\u0275fac,providedIn:"root"});let e=r;return e})();export{u as a};
@@ -1 +1 @@
1
- import{b as x,c as R,d as f,e as F,f as k}from"./chunk-E4QNS7VC.js";import{m as N}from"./chunk-IH7GHE67.js";import{He as I,Ie as C,Mj as D,Nj as P,Rj as j,Yd as u,_d as y,ba as v,bf as S,ea as d,ee as A,g,hj as L,ij as O,sg as w,zi as E}from"./chunk-XNDAIOIN.js";var z=l=>{try{let n={USE_PROFILES:{svg:!0,svgFilters:!0},FORBID_ATTR:["onerror","onload","onclick","onmouseover","onmouseout","onmouseenter","onmouseleave","onmousemove","onmousedown","onmouseup","onwheel","onscroll","onkeydown","onkeyup","onkeypress","onfocus","onblur","onchange","onsubmit","on*"],FORBID_TAGS:["script","style","iframe","object","embed","form"]};return P.sanitize(l,n)}catch(n){return u.catch("Error in File utils sanitizeSvg: ",n),""}},U=l=>{try{return l.name.split(".").slice(0,-1).join(".")}catch(n){u.catch("Error in File utils getFileName: ",n);return}},T=l=>{try{return/(?:\.([^.]+))?$/.exec(l?.name)[1]}catch(n){u.catch("Error in File utils getFileExtension: ",n);return}},M=(l,n)=>{try{let h=l.slice(0,-1,l.type);return new File([h],n+"."+T(l),{type:l.type})}catch(h){u.catch("Error in File utils updateFile: ",h);return}};var b={mp4:"video/mp4",mov:"video/quicktime",avi:"video/x-msvideo",wmv:"video/x-ms-wmv",flv:"video/x-flv",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",webm:"video/webm",mkv:"video/x-matroska",m4v:"video/x-m4v",m4a:"audio/x-m4a",aac:"audio/aac","3gp":"video/3gpp","3g2":"video/3gpp2",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",svg:"image/svg+xml",webp:"image/webp",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",odt:"application/vnd.oasis.opendocument.text",ods:"application/vnd.oasis.opendocument.spreadsheet",zip:"application/zip",rar:"application/x-rar-compressed",txt:"text/plain",rtf:"application/rtf",html:"text/html",htm:"text/html",csv:"text/csv",ics:"text/calendar",vcf:"text/x-vcard",js:"application/javascript",css:"text/css",json:"application/json",xml:"application/xml",swf:"application/x-shockwave-flash"};var _=(()=>{let n=class n{getStorageInstance(t){return t?f(void 0,t):f()}ref(t,e){return F(t,e)}uploadBytesResumable(t,e,o){return k(t,e,o)}getDownloadURL(t){return R(t)}deleteObject(t){return x(t)}};n.\u0275fac=function(e){return new(e||n)},n.\u0275prov=v({token:n,factory:n.\u0275fac,providedIn:"root"});let l=n;return l})();var ae=(()=>{let n=class n{constructor(t,e,o,a,c,s){this.authService=t,this.configService=e,this.coreActionsService=o,this.loggingService=a,this.attachmentResolverService=c,this.storageAdapter=s,this.storage=this.storageAdapter.getStorageInstance();try{this.configService.getApiKey$().subscribe(r=>{this.apiKey=r}),this.authService.getFirebaseConfig$().subscribe(r=>{if(r&&r.firebaseOptions?.storageBucket){this.storage=this.storageAdapter.getStorageInstance(r?.firebaseOptions?.storageBucket);let i=this.configService.getProxyConfig();i?.storageHost&&(this.storage.host=i.storageHost)}},r=>{this.loggingService.catch("Error in StorageService constructor: ",r)})}catch(r){this.loggingService.catch("Error in StorageService constructor:",r)}}createAttachment({path:t,file:e}){try{let o=new C;o.name=e.name;let a=M(e,`${o.attachmentId}_${U(e)}`),c=`${this.apiKey}/${t}/${a?.name}`;return o.bucketPath=c,o.size=e.size,o.type=T(e),o?.type&&(o.mimeType=b[o?.type]),o}catch(o){return this.loggingService.catch("Error in StorageService createAttachment: ",o),null}}sanitizeSvgFile(t){return g(this,null,function*(){if(t.type===b.svg)try{let e=yield t.text(),o=z(e);return new File([o],t.name,{type:t.type})}catch(e){return this.loggingService.catch("Error in StorageService sanitizeSvgFile: ",e),t}return t})}uploadAttachmentToStorage(c){return g(this,arguments,function*({attachment:t,file:e,resolve:o,reject:a}){try{let s=this.storageAdapter.ref(this.storage,t.bucketPath),r=this.storageAdapter.uploadBytesResumable(s,e,{cacheControl:"public,max-age=3600"});r.on("state_changed",i=>{let m=i.bytesTransferred/i.totalBytes*100},i=>{a(i)},()=>{this.storageAdapter.getDownloadURL(r.snapshot.ref).then(i=>{t.url=i,o(t)})})}catch(s){this.loggingService.catch("Error in StorageService uploadAttachmentToStorage: ",s),a(s)}})}uploadToResolver(r){return g(this,arguments,function*({file:t,attachment:e,metadata:o,resolve:a,reject:c,scope:s}){try{o.attachmentId=e.attachmentId;let i={attachmentId:e.attachmentId,name:e.name,file:t,metadata:o,mimeType:e.mimeType},m=w();this.coreActionsService.triggerAction(A.ATTACHMENT_RESOLVER,{event:E.Events.Resolver.ATTACHMENT_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:m,methodName:S.UPLOAD_TO_RESOLVER,source:"internal",payload:{attachment:i,eventType:y.ATTACHMENT_ADD}});let p=yield this.attachmentResolverService.saveAttachment({attachment:i,eventType:y.ATTACHMENT_ADD},m,s);p&&p.data?.url?(e.url=p.data?.url,a(e)):c(new Error("Failed to upload attachment to resolver"))}catch(i){this.loggingService.catch("Error in StorageService uploadToResolver: ",i),c(i)}})}uploadFile({path:t,file:e,useAttachmentResolver:o,metadata:a,attachmentScope:c}){return new Promise((s,r)=>g(this,null,function*(){try{if(!this.apiKey)throw new Error("API key not configured");let i=yield this.sanitizeSvgFile(e),m=this.createAttachment({path:t,file:i});if(!m)throw new Error("Attachment not created");o?this.uploadToResolver({file:i,attachment:m,metadata:a,resolve:s,reject:r,scope:c}):this.uploadAttachmentToStorage({attachment:m,file:i,resolve:s,reject:r})}catch(i){this.loggingService.catch("Error in StorageService uploadFile:",i),r(i)}}))}uploadChunk(t,e,o,a){return new Promise((c,s)=>{try{if(a?.useAttachmentResolver){let r=this.createAttachment({path:t,file:e});if(!r){s(new Error("Attachment not created for chunk upload"));return}this.uploadToResolver({file:e,attachment:r,metadata:a.metadata,resolve:i=>c(i.url),reject:s,scope:a.attachmentScope});return}if(this.apiKey){let r=`${this.apiKey}/${t}/${e.name}`,i=this.storageAdapter.ref(this.storage,r),m=this.storageAdapter.uploadBytesResumable(i,e,{cacheControl:"public,max-age=3600"});m.on("state_changed",p=>{let H=p.bytesTransferred/p.totalBytes*100},p=>{s(p)},()=>{this.storageAdapter.getDownloadURL(m.snapshot.ref).then(p=>{c(p)}).catch(p=>{this.loggingService.catch(`[uploadChunk] Error getting download URL for chunk ${o}:`,p),s(p)})})}else{let r=new Error("API key not available");this.loggingService.catch("[uploadChunk] API key not available",r),s(r)}}catch(r){this.loggingService.catch(`[uploadChunk] Error in StorageService uploadChunk for chunk ${o}: `,r),s(r)}})}downloadAttachment(t){try{if(t.url){let e=new XMLHttpRequest;e.responseType="blob",e.onload=()=>{let o=e.response,a=document.createElement("a"),c=window.URL.createObjectURL(o);a.setAttribute("type","hidden"),a.setAttribute(I.ATTRIBUTES.VELT_DOWNLOAD_BUTTON,"true"),a.classList.add("snippyly-overlay-panel"),a.href=c,t?.name&&(a.download=t?.name),document.body.appendChild(a);let s=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});a.dispatchEvent(s),window.URL.revokeObjectURL(c),a.remove()},e.onerror=()=>{window.open(t.url,"_blank")},e.open("GET",t.url),e.send()}}catch(e){this.loggingService.catch("Error in StorageService downloadAttachment: ",e)}}deleteAttachment({attachment:t,metadata:e,useAttachmentResolver:o,attachmentScope:a}){return new Promise((c,s)=>{if(o){let r=w();this.coreActionsService.triggerAction(A.ATTACHMENT_RESOLVER,{event:E.Events.Resolver.ATTACHMENT_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:r,methodName:S.DELETE_ATTACHMENT,source:"internal",payload:{attachmentId:t.attachmentId,metadata:e}}),this.attachmentResolverService.deleteAttachment({attachmentId:t.attachmentId,metadata:e},r,a).then(()=>{c(null)}).catch(i=>{s(i)})}else{let r=this.storageAdapter.ref(this.storage,t.bucketPath);this.storageAdapter.deleteObject(r).then(()=>{c(null)}).catch(i=>{c(null)})}})}deleteFileFromPath(t){return new Promise((e,o)=>{let a=this.storageAdapter.ref(this.storage,t);this.storageAdapter.deleteObject(a).then(()=>{e(null)}).catch(c=>{o(c)})})}};n.\u0275fac=function(e){return new(e||n)(d(j),d(O),d(D),d(L),d(N),d(_))},n.\u0275prov=v({token:n,factory:n.\u0275fac,providedIn:"root"});let l=n;return l})();export{ae as a};
1
+ import{b as x,c as R,d as f,e as F,f as k}from"./chunk-3M5GZFCG.js";import{n as N}from"./chunk-COMT5MGY.js";import{$j as j,Fi as E,He as I,Ie as C,Wj as D,Xj as P,Yd as u,_d as y,ba as v,bf as S,ea as d,ee as A,g,nj as L,oj as O,tg as w}from"./chunk-V53LQO22.js";var z=l=>{try{let n={USE_PROFILES:{svg:!0,svgFilters:!0},FORBID_ATTR:["onerror","onload","onclick","onmouseover","onmouseout","onmouseenter","onmouseleave","onmousemove","onmousedown","onmouseup","onwheel","onscroll","onkeydown","onkeyup","onkeypress","onfocus","onblur","onchange","onsubmit","on*"],FORBID_TAGS:["script","style","iframe","object","embed","form"]};return P.sanitize(l,n)}catch(n){return u.catch("Error in File utils sanitizeSvg: ",n),""}},U=l=>{try{return l.name.split(".").slice(0,-1).join(".")}catch(n){u.catch("Error in File utils getFileName: ",n);return}},T=l=>{try{return/(?:\.([^.]+))?$/.exec(l?.name)[1]}catch(n){u.catch("Error in File utils getFileExtension: ",n);return}},M=(l,n)=>{try{let h=l.slice(0,-1,l.type);return new File([h],n+"."+T(l),{type:l.type})}catch(h){u.catch("Error in File utils updateFile: ",h);return}};var b={mp4:"video/mp4",mov:"video/quicktime",avi:"video/x-msvideo",wmv:"video/x-ms-wmv",flv:"video/x-flv",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",webm:"video/webm",mkv:"video/x-matroska",m4v:"video/x-m4v",m4a:"audio/x-m4a",aac:"audio/aac","3gp":"video/3gpp","3g2":"video/3gpp2",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",svg:"image/svg+xml",webp:"image/webp",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",odt:"application/vnd.oasis.opendocument.text",ods:"application/vnd.oasis.opendocument.spreadsheet",zip:"application/zip",rar:"application/x-rar-compressed",txt:"text/plain",rtf:"application/rtf",html:"text/html",htm:"text/html",csv:"text/csv",ics:"text/calendar",vcf:"text/x-vcard",js:"application/javascript",css:"text/css",json:"application/json",xml:"application/xml",swf:"application/x-shockwave-flash"};var _=(()=>{let n=class n{getStorageInstance(t){return t?f(void 0,t):f()}ref(t,e){return F(t,e)}uploadBytesResumable(t,e,o){return k(t,e,o)}getDownloadURL(t){return R(t)}deleteObject(t){return x(t)}};n.\u0275fac=function(e){return new(e||n)},n.\u0275prov=v({token:n,factory:n.\u0275fac,providedIn:"root"});let l=n;return l})();var ae=(()=>{let n=class n{constructor(t,e,o,a,c,s){this.authService=t,this.configService=e,this.coreActionsService=o,this.loggingService=a,this.attachmentResolverService=c,this.storageAdapter=s,this.storage=this.storageAdapter.getStorageInstance();try{this.configService.getApiKey$().subscribe(r=>{this.apiKey=r}),this.authService.getFirebaseConfig$().subscribe(r=>{if(r&&r.firebaseOptions?.storageBucket){this.storage=this.storageAdapter.getStorageInstance(r?.firebaseOptions?.storageBucket);let i=this.configService.getProxyConfig();i?.storageHost&&(this.storage.host=i.storageHost)}},r=>{this.loggingService.catch("Error in StorageService constructor: ",r)})}catch(r){this.loggingService.catch("Error in StorageService constructor:",r)}}createAttachment({path:t,file:e}){try{let o=new C;o.name=e.name;let a=M(e,`${o.attachmentId}_${U(e)}`),c=`${this.apiKey}/${t}/${a?.name}`;return o.bucketPath=c,o.size=e.size,o.type=T(e),o?.type&&(o.mimeType=b[o?.type]),o}catch(o){return this.loggingService.catch("Error in StorageService createAttachment: ",o),null}}sanitizeSvgFile(t){return g(this,null,function*(){if(t.type===b.svg)try{let e=yield t.text(),o=z(e);return new File([o],t.name,{type:t.type})}catch(e){return this.loggingService.catch("Error in StorageService sanitizeSvgFile: ",e),t}return t})}uploadAttachmentToStorage(c){return g(this,arguments,function*({attachment:t,file:e,resolve:o,reject:a}){try{let s=this.storageAdapter.ref(this.storage,t.bucketPath),r=this.storageAdapter.uploadBytesResumable(s,e,{cacheControl:"public,max-age=3600"});r.on("state_changed",i=>{let m=i.bytesTransferred/i.totalBytes*100},i=>{a(i)},()=>{this.storageAdapter.getDownloadURL(r.snapshot.ref).then(i=>{t.url=i,o(t)})})}catch(s){this.loggingService.catch("Error in StorageService uploadAttachmentToStorage: ",s),a(s)}})}uploadToResolver(r){return g(this,arguments,function*({file:t,attachment:e,metadata:o,resolve:a,reject:c,scope:s}){try{o.attachmentId=e.attachmentId;let i={attachmentId:e.attachmentId,name:e.name,file:t,metadata:o,mimeType:e.mimeType},m=w();this.coreActionsService.triggerAction(A.ATTACHMENT_RESOLVER,{event:E.Events.Resolver.ATTACHMENT_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:m,methodName:S.UPLOAD_TO_RESOLVER,source:"internal",payload:{attachment:i,eventType:y.ATTACHMENT_ADD}});let p=yield this.attachmentResolverService.saveAttachment({attachment:i,eventType:y.ATTACHMENT_ADD},m,s);p&&p.data?.url?(e.url=p.data?.url,a(e)):c(new Error("Failed to upload attachment to resolver"))}catch(i){this.loggingService.catch("Error in StorageService uploadToResolver: ",i),c(i)}})}uploadFile({path:t,file:e,useAttachmentResolver:o,metadata:a,attachmentScope:c}){return new Promise((s,r)=>g(this,null,function*(){try{if(!this.apiKey)throw new Error("API key not configured");let i=yield this.sanitizeSvgFile(e),m=this.createAttachment({path:t,file:i});if(!m)throw new Error("Attachment not created");o?this.uploadToResolver({file:i,attachment:m,metadata:a,resolve:s,reject:r,scope:c}):this.uploadAttachmentToStorage({attachment:m,file:i,resolve:s,reject:r})}catch(i){this.loggingService.catch("Error in StorageService uploadFile:",i),r(i)}}))}uploadChunk(t,e,o,a){return new Promise((c,s)=>{try{if(a?.useAttachmentResolver){let r=this.createAttachment({path:t,file:e});if(!r){s(new Error("Attachment not created for chunk upload"));return}this.uploadToResolver({file:e,attachment:r,metadata:a.metadata,resolve:i=>c(i.url),reject:s,scope:a.attachmentScope});return}if(this.apiKey){let r=`${this.apiKey}/${t}/${e.name}`,i=this.storageAdapter.ref(this.storage,r),m=this.storageAdapter.uploadBytesResumable(i,e,{cacheControl:"public,max-age=3600"});m.on("state_changed",p=>{let H=p.bytesTransferred/p.totalBytes*100},p=>{s(p)},()=>{this.storageAdapter.getDownloadURL(m.snapshot.ref).then(p=>{c(p)}).catch(p=>{this.loggingService.catch(`[uploadChunk] Error getting download URL for chunk ${o}:`,p),s(p)})})}else{let r=new Error("API key not available");this.loggingService.catch("[uploadChunk] API key not available",r),s(r)}}catch(r){this.loggingService.catch(`[uploadChunk] Error in StorageService uploadChunk for chunk ${o}: `,r),s(r)}})}downloadAttachment(t){try{if(t.url){let e=new XMLHttpRequest;e.responseType="blob",e.onload=()=>{let o=e.response,a=document.createElement("a"),c=window.URL.createObjectURL(o);a.setAttribute("type","hidden"),a.setAttribute(I.ATTRIBUTES.VELT_DOWNLOAD_BUTTON,"true"),a.classList.add("snippyly-overlay-panel"),a.href=c,t?.name&&(a.download=t?.name),document.body.appendChild(a);let s=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});a.dispatchEvent(s),window.URL.revokeObjectURL(c),a.remove()},e.onerror=()=>{window.open(t.url,"_blank")},e.open("GET",t.url),e.send()}}catch(e){this.loggingService.catch("Error in StorageService downloadAttachment: ",e)}}deleteAttachment({attachment:t,metadata:e,useAttachmentResolver:o,attachmentScope:a}){return new Promise((c,s)=>{if(o){let r=w();this.coreActionsService.triggerAction(A.ATTACHMENT_RESOLVER,{event:E.Events.Resolver.ATTACHMENT_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:r,methodName:S.DELETE_ATTACHMENT,source:"internal",payload:{attachmentId:t.attachmentId,metadata:e}}),this.attachmentResolverService.deleteAttachment({attachmentId:t.attachmentId,metadata:e},r,a).then(()=>{c(null)}).catch(i=>{s(i)})}else{let r=this.storageAdapter.ref(this.storage,t.bucketPath);this.storageAdapter.deleteObject(r).then(()=>{c(null)}).catch(i=>{c(null)})}})}deleteFileFromPath(t){return new Promise((e,o)=>{let a=this.storageAdapter.ref(this.storage,t);this.storageAdapter.deleteObject(a).then(()=>{e(null)}).catch(c=>{o(c)})})}};n.\u0275fac=function(e){return new(e||n)(d(j),d(O),d(D),d(L),d(N),d(_))},n.\u0275prov=v({token:n,factory:n.\u0275fac,providedIn:"root"});let l=n;return l})();export{ae as a};
@@ -1 +1 @@
1
- import{x as Z}from"./chunk-D3WKAG4L.js";import{b as N}from"./chunk-I24IAAR4.js";import{xa as T,ya as B}from"./chunk-2K4M4I5G.js";import{Bb as f,Ha as a,Hc as A,He as j,Ic as E,Kb as k,Lh as z,Mb as P,Pb as d,Qb as b,Ra as y,Rb as u,Re as R,Wa as I,ab as w,fb as L,g as V,hj as F,ja as v,ka as g,la as D,ma as S,mc as p,nb as h,nc as m,ob as r,pb as s,qb as _,xb as M,zb as C}from"./chunk-XNDAIOIN.js";function G(o,l){if(o&1){let n=M();r(0,"div",18),C("click",function(){let i=v(n).$implicit,e=f(2);return g(e.selectAudioDevice(i))}),d(1),p(2,"translate"),s()}if(o&2){let n=l.$implicit,t=f(2);P("selected",n.deviceId===(t.selectedAudioDevice==null?null:t.selectedAudioDevice.deviceId)),a(),u(" ",m(2,3,n.label)," ")}}function H(o,l){if(o&1&&(r(0,"div",12)(1,"div",13),d(2),p(3,"translate"),s(),d(4),p(5,"translate"),r(6,"div",14)(7,"div",15),w(8,G,3,5,"div",16),s(),d(9),p(10,"translate"),D(),r(11,"svg",4),_(12,"path",17),s()()()),o&2){let n=f();a(2),b(m(3,4,"Audio")),a(2),u(" ",m(5,6,"Microphone")," "),a(4),h("ngForOf",n.audioDevices),a(),u(" ",m(10,8,n.selectedAudioDevice==null?null:n.selectedAudioDevice.label)," ")}}function U(o,l){if(o&1){let n=M();r(0,"div",18),C("click",function(){let i=v(n).$implicit,e=f(2);return g(e.selectVideoDevice(i))}),d(1),p(2,"translate"),s()}if(o&2){let n=l.$implicit,t=f(2);P("selected",n.deviceId===(t.selectedVideoDevice==null?null:t.selectedVideoDevice.deviceId)),a(),u(" ",m(2,3,n.label)," ")}}function $(o,l){if(o&1&&(r(0,"div",12)(1,"div",13),d(2),p(3,"translate"),s(),d(4),p(5,"translate"),r(6,"div",14)(7,"div",15),w(8,U,3,5,"div",16),s(),d(9),p(10,"translate"),D(),r(11,"svg",4),_(12,"path",17),s()()()),o&2){let n=f();a(2),b(m(3,4,"Video")),a(2),u(" ",m(5,6,"Camera")," "),a(4),h("ngForOf",n.videoDevices),a(),u(" ",m(10,8,n.selectedVideoDevice==null?null:n.selectedVideoDevice.label)," ")}}var ne=(()=>{let l=class l{constructor(t,i,e){this.loggingService=t,this.dialogRef=i,this.devices=[],this.audioDevices=[],this.videoDevices=[],this.settingsVisible={audio:!0,video:!0},this.defaultMediaSourceOptions=z(),this.veltElement=!0;try{e&&(this.selectedAudioDevice=e.selectedAudioDevice,this.selectedVideoDevice=e.selectedVideoDevice,e.settingsVisible&&(this.settingsVisible=e.settingsVisible)),this.getDevices()}catch(c){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent constructor: ",c)}}ngOnInit(){try{this.dialogRef.addPanelClass("snippyly-media-source-options-dialog")}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent ngOnInit: ",t)}}getDevices(){return V(this,null,function*(){try{let t=new R;if(t.getBrowserName()?.toLowerCase()==="safari"||t.getBrowserName()?.toLowerCase()==="firefox")try{let i=yield navigator.mediaDevices.getUserMedia({audio:!0,video:!0});i&&i.getTracks().forEach(e=>e.stop())}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices getUserMedia catch: ",i)}navigator.mediaDevices.enumerateDevices().then(i=>{if(this.devices=i.filter(e=>e.kind==="audioinput"||e.kind==="videoinput"),this.audioDevices=this.devices.filter(e=>e.kind==="audioinput"),this.videoDevices=this.devices.filter(e=>e.kind==="videoinput"),this.audioDevices.length>0&&!this.selectedAudioDevice){if(this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId){let e=this.audioDevices.find(c=>c.deviceId===this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId);e&&(this.selectedAudioDevice=e)}this.selectedAudioDevice||(this.selectedAudioDevice=this.audioDevices[0])}if(this.videoDevices.length>0&&!this.selectedVideoDevice){if(this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId){let e=this.videoDevices.find(c=>c.deviceId===this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId);e&&(this.selectedVideoDevice=e)}this.selectedVideoDevice||(this.selectedVideoDevice=this.videoDevices[0])}}).catch(i=>{this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices enumerateDevices catch: ",i)})}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices: ",t)}})}selectAudioDevice(t){try{this.selectedAudioDevice=t}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent selectAudioDevice: ",i)}}selectVideoDevice(t){try{this.selectedVideoDevice=t}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent selectVideoDevice: ",i)}}saveChanges(){try{let t={};this.settingsVisible.audio&&(t.selectedAudioDevice=this.selectedAudioDevice),this.settingsVisible.video&&(t.selectedVideoDevice=this.selectedVideoDevice),localStorage.setItem(j.LOCAL_STORAGE.SNIPPYLY_DEFAULT_MEDIA_SOURCE_OPTIONS,JSON.stringify(t||{})),this.closeDialog(t)}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent saveChanges: ",t)}}closeDialog(t){try{this.dialogRef.close(t)}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent closeDialog: ",i)}}};l.\u0275fac=function(i){return new(i||l)(y(F),y(T),y(B,8))},l.\u0275cmp=I({type:l,selectors:[["snippyly-media-source-options-dialog"]],hostVars:1,hostBindings:function(i,e){i&2&&L("data-velt-element",e.veltElement)},standalone:!1,decls:17,vars:10,consts:[["mediaSourceOptionsDialogRef",""],[1,"s-video-settings-modal",3,"pointerdown","pointerup","click","snippylyOverlay","snippylyOverlayZIndex"],[1,"s-video-header"],[1,"s-video-header-name"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M19.5 12C19.5 11.77 19.49 11.55 19.47 11.32L21.33 9.91C21.73 9.61 21.84 9.05 21.59 8.61L19.72 5.38C19.47 4.94 18.93 4.76 18.47 4.96L16.32 5.87C15.95 5.61 15.56 5.38 15.15 5.19L14.86 2.88C14.8 2.38 14.37 2 13.87 2H10.14C9.63 2 9.2 2.38 9.14 2.88L8.85 5.19C8.44 5.38 8.05 5.61 7.68 5.87L5.53 4.96C5.07 4.76 4.53 4.94 4.28 5.38L2.41 8.62C2.16 9.06 2.27 9.61 2.67 9.92L4.53 11.33C4.51 11.55 4.5 11.77 4.5 12C4.5 12.23 4.51 12.45 4.53 12.68L2.67 14.09C2.27 14.39 2.16 14.95 2.41 15.39L4.28 18.62C4.53 19.06 5.07 19.24 5.53 19.04L7.68 18.13C8.05 18.39 8.44 18.62 8.85 18.81L9.14 21.12C9.2 21.62 9.63 22 10.13 22H13.86C14.36 22 14.79 21.62 14.85 21.12L15.14 18.81C15.55 18.62 15.94 18.39 16.31 18.13L18.46 19.04C18.92 19.24 19.46 19.06 19.71 18.62L21.58 15.39C21.83 14.95 21.72 14.4 21.32 14.09L19.46 12.68C19.49 12.45 19.5 12.23 19.5 12ZM12.04 15.5C10.11 15.5 8.54 13.93 8.54 12C8.54 10.07 10.11 8.5 12.04 8.5C13.97 8.5 15.54 10.07 15.54 12C15.54 13.93 13.97 15.5 12.04 15.5Z","fill","white"],[1,"s-icon-button",3,"click"],["width","20","height","20","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M4.41076 4.41058C4.7362 4.08514 5.26384 4.08514 5.58928 4.41058L10 8.82133L14.4108 4.41058C14.7362 4.08514 15.2638 4.08514 15.5893 4.41058C15.9147 4.73602 15.9147 5.26366 15.5893 5.58909L11.1785 9.99984L15.5893 14.4106C15.9147 14.736 15.9147 15.2637 15.5893 15.5891C15.2638 15.9145 14.7362 15.9145 14.4108 15.5891L10 11.1783L5.58928 15.5891C5.26384 15.9145 4.7362 15.9145 4.41076 15.5891C4.08533 15.2637 4.08533 14.736 4.41076 14.4106L8.82151 9.99984L4.41076 5.58909C4.08533 5.26366 4.08533 4.73602 4.41076 4.41058Z","fill","white"],["class","s-video-settings-modal-item",4,"ngIf"],[1,"s-flex-fill"],[1,"s-button","s-primary","s-save-button",3,"click"],[1,"s-video-settings-modal-item"],[1,"s-heading"],[1,"s-input","dropdown"],[1,"dropdown-content"],["class","dropdown-item",3,"selected","click",4,"ngFor","ngForOf"],["fill-rule","evenodd","clip-rule","evenodd","d","M16.2071 9.79289C15.8166 9.40237 15.1834 9.40237 14.7929 9.79289L12 12.5858L9.20711 9.79289C8.81658 9.40237 8.18342 9.40237 7.79289 9.79289C7.40237 10.1834 7.40237 10.8166 7.79289 11.2071L11.2929 14.7071C11.6834 15.0976 12.3166 15.0976 12.7071 14.7071L16.2071 11.2071C16.5976 10.8166 16.5976 10.1834 16.2071 9.79289Z","fill","#80808A"],[1,"dropdown-item",3,"click"]],template:function(i,e){if(i&1){let c=M();r(0,"div",1,0),C("pointerdown",function(x){return v(c),g(x.stopPropagation())})("pointerup",function(x){return v(c),g(x.stopPropagation())})("click",function(x){return v(c),g(x.stopPropagation())}),r(2,"div",2)(3,"div",3),D(),r(4,"svg",4),_(5,"path",5),s(),d(6),p(7,"translate"),s(),S(),r(8,"div",6),C("click",function(){return v(c),g(e.closeDialog())}),D(),r(9,"svg",7),_(10,"path",8),s()()(),w(11,H,13,10,"div",9)(12,$,13,10,"div",9),S(),_(13,"div",10),r(14,"div",11),C("click",function(){return v(c),g(e.saveChanges())}),d(15),p(16,"translate"),s()()}if(i&2){let c=k(1);h("snippylyOverlay",c)("snippylyOverlayZIndex",3e3),a(6),u(" ",m(7,6,"Settings")," "),a(5),h("ngIf",e.settingsVisible==null?null:e.settingsVisible.audio),a(),h("ngIf",e.settingsVisible==null?null:e.settingsVisible.video),a(3),b(m(16,8,"Save changes"))}},dependencies:[A,E,Z,N],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}*[_ngcontent-%COMP%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){height:unset;width:unset}*[_ngcontent-%COMP%]:empty:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){display:revert!important}.s-video-settings-modal[_ngcontent-%COMP%], .s-video-header[_ngcontent-%COMP%], .s-video-header-name[_ngcontent-%COMP%], .s-video-settings-modal-item[_ngcontent-%COMP%], .s-input[_ngcontent-%COMP%]{display:flex!important;color:#fff!important}.s-video-settings-modal-item[_ngcontent-%COMP%]{flex-direction:column!important;align-items:flex-start!important;justify-content:flex-start!important;width:100%!important;color:#91919c!important;font-size:calc((.8rem + 0px) * var(--velt-base-rem-unit))!important;gap:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}.s-video-settings-modal[_ngcontent-%COMP%]{flex-direction:column!important;align-items:flex-end!important;padding:calc((2rem + 0px) * var(--velt-base-rem-unit))!important;gap:calc((2rem + 0px) * var(--velt-base-rem-unit))!important;background:#141416!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:calc((40rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important}.s-video-header[_ngcontent-%COMP%]{justify-content:space-between!important;width:100%!important;align-items:center!important}.s-video-header-name[_ngcontent-%COMP%]{gap:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;font-weight:600!important;font-size:calc((1.2rem + 0px) * var(--velt-base-rem-unit))!important;display:flex!important;align-items:center!important}.s-button[_ngcontent-%COMP%]{display:flex!important;align-items:center!important;justify-content:center!important;padding:calc((1rem + 0px) * var(--velt-base-rem-unit)) calc((2rem + 0px) * var(--velt-base-rem-unit))!important;border-radius:calc((4rem + 0px) * var(--velt-base-rem-unit))!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;transition:.1s ease!important;cursor:pointer!important}.s-primary[_ngcontent-%COMP%]{background:#625df5!important;color:#fff!important}.s-primary[_ngcontent-%COMP%]:hover{background:#4f4bbf!important}.s-video-settings-modal-item[_ngcontent-%COMP%] .s-heading[_ngcontent-%COMP%]{font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;color:#fff!important;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) 0!important}.s-input[_ngcontent-%COMP%]{position:relative!important;padding:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;color:#91919c!important;width:100%!important;justify-content:space-between!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important;align-items:center!important;cursor:pointer!important;transition:.2s ease!important}.s-input[_ngcontent-%COMP%]:hover{background:#303034!important}.dropdown[_ngcontent-%COMP%] .dropdown-content[_ngcontent-%COMP%]{position:absolute!important;top:0!important;right:0!important;z-index:1!important}.dropdown-content[_ngcontent-%COMP%]{width:100%!important;overflow:hidden!important;display:flex!important;flex-direction:column!important;justify-content:flex-start!important;align-items:flex-start!important;border-radius:calc((.9rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important;color:#91919c!important;background:#141416!important;cursor:pointer!important;visibility:hidden!important;opacity:0!important;transition:all .1s ease!important}.dropdown[_ngcontent-%COMP%]:hover .dropdown-content[_ngcontent-%COMP%]{visibility:visible!important;opacity:1!important}.dropdown-item[_ngcontent-%COMP%]{padding:calc((1.2rem + 0px) * var(--velt-base-rem-unit)) calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:100%!important;display:flex!important;justify-content:flex-start!important;align-items:center!important;gap:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;transition:all .1s ease!important;color:#91919c!important}.dropdown-item.selected[_ngcontent-%COMP%]{color:#fff!important}.dropdown-item[_ngcontent-%COMP%]:hover{background:#303034!important;color:#fff!important}.s-icon-button[_ngcontent-%COMP%]{padding:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;display:flex!important;align-items:center!important;justify-content:center!important;border-radius:100px!important;cursor:pointer!important}.s-icon-button[_ngcontent-%COMP%] svg[_ngcontent-%COMP%] path[_ngcontent-%COMP%]{fill:#777e91!important}.s-icon-button[_ngcontent-%COMP%]:hover{background:#222226!important}.s-icon-button[_ngcontent-%COMP%]:hover svg[_ngcontent-%COMP%] path[_ngcontent-%COMP%]{fill:#fff!important}.s-flex-fill[_ngcontent-%COMP%]{flex-grow:1!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog{max-width:unset} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{background-color:transparent!important;padding:0!important;margin:0!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}@media screen and (max-width:768px){.s-video-settings-modal[_ngcontent-%COMP%]{width:calc(.8 * var(--legacy-velt-viewport-width))!important}}@media screen and (max-width:425px){ .velt-mat-dialog-container.snippyly-media-source-options-dialog{width:calc(1 * var(--legacy-velt-viewport-width))!important;max-width:calc(1 * var(--legacy-velt-viewport-width))!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{width:calc(1 * var(--legacy-velt-viewport-width))!important;height:calc(1 * var(--legacy-velt-viewport-height))!important;border-radius:calc((0rem + 0px) * var(--velt-base-rem-unit))!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface .s-video-settings-modal{width:calc(1 * var(--legacy-velt-viewport-width))!important;height:calc(1 * var(--legacy-velt-viewport-height))!important;border-radius:0!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface .s-save-button{width:100%!important}}"],changeDetection:0});let o=l;return o})();export{ne as a};
1
+ import{x as Z}from"./chunk-ZURN7SUE.js";import{b as N}from"./chunk-RCOPSCV6.js";import{xa as T,ya as B}from"./chunk-EIDOVJ3L.js";import{Bb as f,Ha as a,Hc as A,He as j,Ic as E,Kb as k,Mb as P,Mh as z,Pb as d,Qb as b,Ra as y,Rb as u,Re as R,Wa as I,ab as w,fb as L,g as V,ja as v,ka as g,la as D,ma as S,mc as p,nb as h,nc as m,nj as F,ob as r,pb as s,qb as _,xb as M,zb as C}from"./chunk-V53LQO22.js";function G(o,l){if(o&1){let n=M();r(0,"div",18),C("click",function(){let i=v(n).$implicit,e=f(2);return g(e.selectAudioDevice(i))}),d(1),p(2,"translate"),s()}if(o&2){let n=l.$implicit,t=f(2);P("selected",n.deviceId===(t.selectedAudioDevice==null?null:t.selectedAudioDevice.deviceId)),a(),u(" ",m(2,3,n.label)," ")}}function H(o,l){if(o&1&&(r(0,"div",12)(1,"div",13),d(2),p(3,"translate"),s(),d(4),p(5,"translate"),r(6,"div",14)(7,"div",15),w(8,G,3,5,"div",16),s(),d(9),p(10,"translate"),D(),r(11,"svg",4),_(12,"path",17),s()()()),o&2){let n=f();a(2),b(m(3,4,"Audio")),a(2),u(" ",m(5,6,"Microphone")," "),a(4),h("ngForOf",n.audioDevices),a(),u(" ",m(10,8,n.selectedAudioDevice==null?null:n.selectedAudioDevice.label)," ")}}function U(o,l){if(o&1){let n=M();r(0,"div",18),C("click",function(){let i=v(n).$implicit,e=f(2);return g(e.selectVideoDevice(i))}),d(1),p(2,"translate"),s()}if(o&2){let n=l.$implicit,t=f(2);P("selected",n.deviceId===(t.selectedVideoDevice==null?null:t.selectedVideoDevice.deviceId)),a(),u(" ",m(2,3,n.label)," ")}}function $(o,l){if(o&1&&(r(0,"div",12)(1,"div",13),d(2),p(3,"translate"),s(),d(4),p(5,"translate"),r(6,"div",14)(7,"div",15),w(8,U,3,5,"div",16),s(),d(9),p(10,"translate"),D(),r(11,"svg",4),_(12,"path",17),s()()()),o&2){let n=f();a(2),b(m(3,4,"Video")),a(2),u(" ",m(5,6,"Camera")," "),a(4),h("ngForOf",n.videoDevices),a(),u(" ",m(10,8,n.selectedVideoDevice==null?null:n.selectedVideoDevice.label)," ")}}var ne=(()=>{let l=class l{constructor(t,i,e){this.loggingService=t,this.dialogRef=i,this.devices=[],this.audioDevices=[],this.videoDevices=[],this.settingsVisible={audio:!0,video:!0},this.defaultMediaSourceOptions=z(),this.veltElement=!0;try{e&&(this.selectedAudioDevice=e.selectedAudioDevice,this.selectedVideoDevice=e.selectedVideoDevice,e.settingsVisible&&(this.settingsVisible=e.settingsVisible)),this.getDevices()}catch(c){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent constructor: ",c)}}ngOnInit(){try{this.dialogRef.addPanelClass("snippyly-media-source-options-dialog")}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent ngOnInit: ",t)}}getDevices(){return V(this,null,function*(){try{let t=new R;if(t.getBrowserName()?.toLowerCase()==="safari"||t.getBrowserName()?.toLowerCase()==="firefox")try{let i=yield navigator.mediaDevices.getUserMedia({audio:!0,video:!0});i&&i.getTracks().forEach(e=>e.stop())}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices getUserMedia catch: ",i)}navigator.mediaDevices.enumerateDevices().then(i=>{if(this.devices=i.filter(e=>e.kind==="audioinput"||e.kind==="videoinput"),this.audioDevices=this.devices.filter(e=>e.kind==="audioinput"),this.videoDevices=this.devices.filter(e=>e.kind==="videoinput"),this.audioDevices.length>0&&!this.selectedAudioDevice){if(this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId){let e=this.audioDevices.find(c=>c.deviceId===this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId);e&&(this.selectedAudioDevice=e)}this.selectedAudioDevice||(this.selectedAudioDevice=this.audioDevices[0])}if(this.videoDevices.length>0&&!this.selectedVideoDevice){if(this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId){let e=this.videoDevices.find(c=>c.deviceId===this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId);e&&(this.selectedVideoDevice=e)}this.selectedVideoDevice||(this.selectedVideoDevice=this.videoDevices[0])}}).catch(i=>{this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices enumerateDevices catch: ",i)})}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices: ",t)}})}selectAudioDevice(t){try{this.selectedAudioDevice=t}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent selectAudioDevice: ",i)}}selectVideoDevice(t){try{this.selectedVideoDevice=t}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent selectVideoDevice: ",i)}}saveChanges(){try{let t={};this.settingsVisible.audio&&(t.selectedAudioDevice=this.selectedAudioDevice),this.settingsVisible.video&&(t.selectedVideoDevice=this.selectedVideoDevice),localStorage.setItem(j.LOCAL_STORAGE.SNIPPYLY_DEFAULT_MEDIA_SOURCE_OPTIONS,JSON.stringify(t||{})),this.closeDialog(t)}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent saveChanges: ",t)}}closeDialog(t){try{this.dialogRef.close(t)}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent closeDialog: ",i)}}};l.\u0275fac=function(i){return new(i||l)(y(F),y(T),y(B,8))},l.\u0275cmp=I({type:l,selectors:[["snippyly-media-source-options-dialog"]],hostVars:1,hostBindings:function(i,e){i&2&&L("data-velt-element",e.veltElement)},standalone:!1,decls:17,vars:10,consts:[["mediaSourceOptionsDialogRef",""],[1,"s-video-settings-modal",3,"pointerdown","pointerup","click","snippylyOverlay","snippylyOverlayZIndex"],[1,"s-video-header"],[1,"s-video-header-name"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M19.5 12C19.5 11.77 19.49 11.55 19.47 11.32L21.33 9.91C21.73 9.61 21.84 9.05 21.59 8.61L19.72 5.38C19.47 4.94 18.93 4.76 18.47 4.96L16.32 5.87C15.95 5.61 15.56 5.38 15.15 5.19L14.86 2.88C14.8 2.38 14.37 2 13.87 2H10.14C9.63 2 9.2 2.38 9.14 2.88L8.85 5.19C8.44 5.38 8.05 5.61 7.68 5.87L5.53 4.96C5.07 4.76 4.53 4.94 4.28 5.38L2.41 8.62C2.16 9.06 2.27 9.61 2.67 9.92L4.53 11.33C4.51 11.55 4.5 11.77 4.5 12C4.5 12.23 4.51 12.45 4.53 12.68L2.67 14.09C2.27 14.39 2.16 14.95 2.41 15.39L4.28 18.62C4.53 19.06 5.07 19.24 5.53 19.04L7.68 18.13C8.05 18.39 8.44 18.62 8.85 18.81L9.14 21.12C9.2 21.62 9.63 22 10.13 22H13.86C14.36 22 14.79 21.62 14.85 21.12L15.14 18.81C15.55 18.62 15.94 18.39 16.31 18.13L18.46 19.04C18.92 19.24 19.46 19.06 19.71 18.62L21.58 15.39C21.83 14.95 21.72 14.4 21.32 14.09L19.46 12.68C19.49 12.45 19.5 12.23 19.5 12ZM12.04 15.5C10.11 15.5 8.54 13.93 8.54 12C8.54 10.07 10.11 8.5 12.04 8.5C13.97 8.5 15.54 10.07 15.54 12C15.54 13.93 13.97 15.5 12.04 15.5Z","fill","white"],[1,"s-icon-button",3,"click"],["width","20","height","20","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M4.41076 4.41058C4.7362 4.08514 5.26384 4.08514 5.58928 4.41058L10 8.82133L14.4108 4.41058C14.7362 4.08514 15.2638 4.08514 15.5893 4.41058C15.9147 4.73602 15.9147 5.26366 15.5893 5.58909L11.1785 9.99984L15.5893 14.4106C15.9147 14.736 15.9147 15.2637 15.5893 15.5891C15.2638 15.9145 14.7362 15.9145 14.4108 15.5891L10 11.1783L5.58928 15.5891C5.26384 15.9145 4.7362 15.9145 4.41076 15.5891C4.08533 15.2637 4.08533 14.736 4.41076 14.4106L8.82151 9.99984L4.41076 5.58909C4.08533 5.26366 4.08533 4.73602 4.41076 4.41058Z","fill","white"],["class","s-video-settings-modal-item",4,"ngIf"],[1,"s-flex-fill"],[1,"s-button","s-primary","s-save-button",3,"click"],[1,"s-video-settings-modal-item"],[1,"s-heading"],[1,"s-input","dropdown"],[1,"dropdown-content"],["class","dropdown-item",3,"selected","click",4,"ngFor","ngForOf"],["fill-rule","evenodd","clip-rule","evenodd","d","M16.2071 9.79289C15.8166 9.40237 15.1834 9.40237 14.7929 9.79289L12 12.5858L9.20711 9.79289C8.81658 9.40237 8.18342 9.40237 7.79289 9.79289C7.40237 10.1834 7.40237 10.8166 7.79289 11.2071L11.2929 14.7071C11.6834 15.0976 12.3166 15.0976 12.7071 14.7071L16.2071 11.2071C16.5976 10.8166 16.5976 10.1834 16.2071 9.79289Z","fill","#80808A"],[1,"dropdown-item",3,"click"]],template:function(i,e){if(i&1){let c=M();r(0,"div",1,0),C("pointerdown",function(x){return v(c),g(x.stopPropagation())})("pointerup",function(x){return v(c),g(x.stopPropagation())})("click",function(x){return v(c),g(x.stopPropagation())}),r(2,"div",2)(3,"div",3),D(),r(4,"svg",4),_(5,"path",5),s(),d(6),p(7,"translate"),s(),S(),r(8,"div",6),C("click",function(){return v(c),g(e.closeDialog())}),D(),r(9,"svg",7),_(10,"path",8),s()()(),w(11,H,13,10,"div",9)(12,$,13,10,"div",9),S(),_(13,"div",10),r(14,"div",11),C("click",function(){return v(c),g(e.saveChanges())}),d(15),p(16,"translate"),s()()}if(i&2){let c=k(1);h("snippylyOverlay",c)("snippylyOverlayZIndex",3e3),a(6),u(" ",m(7,6,"Settings")," "),a(5),h("ngIf",e.settingsVisible==null?null:e.settingsVisible.audio),a(),h("ngIf",e.settingsVisible==null?null:e.settingsVisible.video),a(3),b(m(16,8,"Save changes"))}},dependencies:[A,E,Z,N],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}*[_ngcontent-%COMP%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){height:unset;width:unset}*[_ngcontent-%COMP%]:empty:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){display:revert!important}.s-video-settings-modal[_ngcontent-%COMP%], .s-video-header[_ngcontent-%COMP%], .s-video-header-name[_ngcontent-%COMP%], .s-video-settings-modal-item[_ngcontent-%COMP%], .s-input[_ngcontent-%COMP%]{display:flex!important;color:#fff!important}.s-video-settings-modal-item[_ngcontent-%COMP%]{flex-direction:column!important;align-items:flex-start!important;justify-content:flex-start!important;width:100%!important;color:#91919c!important;font-size:calc((.8rem + 0px) * var(--velt-base-rem-unit))!important;gap:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}.s-video-settings-modal[_ngcontent-%COMP%]{flex-direction:column!important;align-items:flex-end!important;padding:calc((2rem + 0px) * var(--velt-base-rem-unit))!important;gap:calc((2rem + 0px) * var(--velt-base-rem-unit))!important;background:#141416!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:calc((40rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important}.s-video-header[_ngcontent-%COMP%]{justify-content:space-between!important;width:100%!important;align-items:center!important}.s-video-header-name[_ngcontent-%COMP%]{gap:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;font-weight:600!important;font-size:calc((1.2rem + 0px) * var(--velt-base-rem-unit))!important;display:flex!important;align-items:center!important}.s-button[_ngcontent-%COMP%]{display:flex!important;align-items:center!important;justify-content:center!important;padding:calc((1rem + 0px) * var(--velt-base-rem-unit)) calc((2rem + 0px) * var(--velt-base-rem-unit))!important;border-radius:calc((4rem + 0px) * var(--velt-base-rem-unit))!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;transition:.1s ease!important;cursor:pointer!important}.s-primary[_ngcontent-%COMP%]{background:#625df5!important;color:#fff!important}.s-primary[_ngcontent-%COMP%]:hover{background:#4f4bbf!important}.s-video-settings-modal-item[_ngcontent-%COMP%] .s-heading[_ngcontent-%COMP%]{font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;color:#fff!important;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) 0!important}.s-input[_ngcontent-%COMP%]{position:relative!important;padding:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;color:#91919c!important;width:100%!important;justify-content:space-between!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important;align-items:center!important;cursor:pointer!important;transition:.2s ease!important}.s-input[_ngcontent-%COMP%]:hover{background:#303034!important}.dropdown[_ngcontent-%COMP%] .dropdown-content[_ngcontent-%COMP%]{position:absolute!important;top:0!important;right:0!important;z-index:1!important}.dropdown-content[_ngcontent-%COMP%]{width:100%!important;overflow:hidden!important;display:flex!important;flex-direction:column!important;justify-content:flex-start!important;align-items:flex-start!important;border-radius:calc((.9rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important;color:#91919c!important;background:#141416!important;cursor:pointer!important;visibility:hidden!important;opacity:0!important;transition:all .1s ease!important}.dropdown[_ngcontent-%COMP%]:hover .dropdown-content[_ngcontent-%COMP%]{visibility:visible!important;opacity:1!important}.dropdown-item[_ngcontent-%COMP%]{padding:calc((1.2rem + 0px) * var(--velt-base-rem-unit)) calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:100%!important;display:flex!important;justify-content:flex-start!important;align-items:center!important;gap:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;transition:all .1s ease!important;color:#91919c!important}.dropdown-item.selected[_ngcontent-%COMP%]{color:#fff!important}.dropdown-item[_ngcontent-%COMP%]:hover{background:#303034!important;color:#fff!important}.s-icon-button[_ngcontent-%COMP%]{padding:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;display:flex!important;align-items:center!important;justify-content:center!important;border-radius:100px!important;cursor:pointer!important}.s-icon-button[_ngcontent-%COMP%] svg[_ngcontent-%COMP%] path[_ngcontent-%COMP%]{fill:#777e91!important}.s-icon-button[_ngcontent-%COMP%]:hover{background:#222226!important}.s-icon-button[_ngcontent-%COMP%]:hover svg[_ngcontent-%COMP%] path[_ngcontent-%COMP%]{fill:#fff!important}.s-flex-fill[_ngcontent-%COMP%]{flex-grow:1!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog{max-width:unset} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{background-color:transparent!important;padding:0!important;margin:0!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}@media screen and (max-width:768px){.s-video-settings-modal[_ngcontent-%COMP%]{width:calc(.8 * var(--legacy-velt-viewport-width))!important}}@media screen and (max-width:425px){ .velt-mat-dialog-container.snippyly-media-source-options-dialog{width:calc(1 * var(--legacy-velt-viewport-width))!important;max-width:calc(1 * var(--legacy-velt-viewport-width))!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{width:calc(1 * var(--legacy-velt-viewport-width))!important;height:calc(1 * var(--legacy-velt-viewport-height))!important;border-radius:calc((0rem + 0px) * var(--velt-base-rem-unit))!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface .s-video-settings-modal{width:calc(1 * var(--legacy-velt-viewport-width))!important;height:calc(1 * var(--legacy-velt-viewport-height))!important;border-radius:0!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface .s-save-button{width:100%!important}}"],changeDetection:0});let o=l;return o})();export{ne as a};
@@ -1 +1 @@
1
- import{$ as w,_ as V,aa as j,ba as T,ca as Z}from"./chunk-2K4M4I5G.js";import{D as E,Ja as R,La as S,Ma as F,Oa as l,V as b,db as C,i as g,m as y,na as I,ta as v}from"./chunk-XNDAIOIN.js";var _={schedule(n,t){let e=setTimeout(n,t);return()=>clearTimeout(e)}};function O(n){return n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function k(n){return!!n&&n.nodeType===Node.ELEMENT_NODE}var h;function N(n,t){if(!h){let e=Element.prototype;h=e.matches||e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector}return n.nodeType===Node.ELEMENT_NODE?h.call(n,t):!1}function z(n){let t={};return n.forEach(({propName:e,templateName:s,transform:u})=>{t[O(s)]=[e,u]}),t}function A(n,t){return t.get(l).resolveComponentFactory(n).inputs}function P(n,t){let e=n.childNodes,s=t.map(()=>[]),u=-1;t.some((r,o)=>r==="*"?(u=o,!0):!1);for(let r=0,o=e.length;r<o;++r){let i=e[r],c=L(i,t,u);c!==-1&&s[c].push(i)}return s}function L(n,t,e){let s=e;return k(n)&&t.some((u,r)=>u!=="*"&&N(n,u)?(s=r,!0):!1),s}var Y=10,p=class{componentFactory;inputMap=new Map;constructor(t,e){this.componentFactory=e.get(l).resolveComponentFactory(t);for(let s of this.componentFactory.inputs)this.inputMap.set(s.propName,s.templateName)}create(t){return new m(this.componentFactory,t,this.inputMap)}},m=class{componentFactory;injector;inputMap;eventEmitters=new y(1);events=this.eventEmitters.pipe(b(t=>E(...t)));componentRef=null;scheduledDestroyFn=null;initialInputValues=new Map;ngZone;elementZone;appRef;cdScheduler;constructor(t,e,s){this.componentFactory=t,this.injector=e,this.inputMap=s,this.ngZone=this.injector.get(R),this.appRef=this.injector.get(C),this.cdScheduler=e.get(v),this.elementZone=typeof Zone>"u"?null:this.ngZone.run(()=>Zone.current)}connect(t){this.runInZone(()=>{if(this.scheduledDestroyFn!==null){this.scheduledDestroyFn(),this.scheduledDestroyFn=null;return}this.componentRef===null&&this.initializeComponent(t)})}disconnect(){this.runInZone(()=>{this.componentRef===null||this.scheduledDestroyFn!==null||(this.scheduledDestroyFn=_.schedule(()=>{this.componentRef!==null&&(this.componentRef.destroy(),this.componentRef=null)},Y))})}getInputValue(t){return this.runInZone(()=>this.componentRef===null?this.initialInputValues.get(t):this.componentRef.instance[t])}setInputValue(t,e){if(this.componentRef===null){this.initialInputValues.set(t,e);return}this.runInZone(()=>{this.componentRef.setInput(this.inputMap.get(t)??t,e),S(this.componentRef.hostView)&&(F(this.componentRef.changeDetectorRef),this.cdScheduler.notify(6))})}initializeComponent(t){let e=I.create({providers:[],parent:this.injector}),s=P(t,this.componentFactory.ngContentSelectors);this.componentRef=this.componentFactory.create(e,s,t),this.initializeInputs(),this.initializeOutputs(this.componentRef),this.appRef.attachView(this.componentRef.hostView),this.componentRef.hostView.detectChanges()}initializeInputs(){for(let[t,e]of this.initialInputValues)this.setInputValue(t,e);this.initialInputValues.clear()}initializeOutputs(t){let e=this.componentFactory.outputs.map(({propName:s,templateName:u})=>{let r=t.instance[s];return new g(o=>{let i=r.subscribe(c=>o.next({name:u,value:c}));return()=>i.unsubscribe()})});this.eventEmitters.next(e)}runInZone(t){return this.elementZone&&Zone.current!==this.elementZone?this.ngZone.run(t):t()}},f=class extends HTMLElement{ngElementEventsSubscription=null};function D(n,t){let e=A(n,t.injector),s=t.strategyFactory||new p(n,t.injector),u=z(e);class r extends f{injector;static observedAttributes=Object.keys(u);get ngElementStrategy(){if(!this._ngElementStrategy){let i=this._ngElementStrategy=s.create(this.injector||t.injector);e.forEach(({propName:c,transform:a})=>{if(!this.hasOwnProperty(c))return;let d=this[c];delete this[c],i.setInputValue(c,d,a)})}return this._ngElementStrategy}_ngElementStrategy;constructor(i){super(),this.injector=i}attributeChangedCallback(i,c,a,d){let[M,x]=u[i];this.ngElementStrategy.setInputValue(M,a,x)}connectedCallback(){let i=!1;this.ngElementStrategy.events&&(this.subscribeToEvents(),i=!0),this.ngElementStrategy.connect(this),i||this.subscribeToEvents()}disconnectedCallback(){this._ngElementStrategy&&this._ngElementStrategy.disconnect(),this.ngElementEventsSubscription&&(this.ngElementEventsSubscription.unsubscribe(),this.ngElementEventsSubscription=null)}subscribeToEvents(){this.ngElementEventsSubscription=this.ngElementStrategy.events.subscribe(i=>{let c=new CustomEvent(i.name,{detail:i.value});this.dispatchEvent(c)})}}return e.forEach(({propName:o,transform:i})=>{Object.defineProperty(r.prototype,o,{get(){return this.ngElementStrategy.getInputValue(o)},set(c){this.ngElementStrategy.setInputValue(o,c,i)},configurable:!0,enumerable:!0})}),r}function K(n,t){let e=D(n,{injector:t});class s extends e{connectedCallback(){let r;try{let o=this;Z(o),r=V(o)}catch{}super.connectedCallback?.();try{if(w(r),r){let o=this;setTimeout(()=>{j(o),T(o)},0)}}catch{}}}return s}export{K as a};
1
+ import{$ as w,_ as V,aa as j,ba as T,ca as Z}from"./chunk-EIDOVJ3L.js";import{D as E,Ja as R,La as S,Ma as F,Oa as l,V as b,db as C,i as g,m as y,na as I,ta as v}from"./chunk-V53LQO22.js";var _={schedule(n,t){let e=setTimeout(n,t);return()=>clearTimeout(e)}};function O(n){return n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function k(n){return!!n&&n.nodeType===Node.ELEMENT_NODE}var h;function N(n,t){if(!h){let e=Element.prototype;h=e.matches||e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector}return n.nodeType===Node.ELEMENT_NODE?h.call(n,t):!1}function z(n){let t={};return n.forEach(({propName:e,templateName:s,transform:u})=>{t[O(s)]=[e,u]}),t}function A(n,t){return t.get(l).resolveComponentFactory(n).inputs}function P(n,t){let e=n.childNodes,s=t.map(()=>[]),u=-1;t.some((r,o)=>r==="*"?(u=o,!0):!1);for(let r=0,o=e.length;r<o;++r){let i=e[r],c=L(i,t,u);c!==-1&&s[c].push(i)}return s}function L(n,t,e){let s=e;return k(n)&&t.some((u,r)=>u!=="*"&&N(n,u)?(s=r,!0):!1),s}var Y=10,p=class{componentFactory;inputMap=new Map;constructor(t,e){this.componentFactory=e.get(l).resolveComponentFactory(t);for(let s of this.componentFactory.inputs)this.inputMap.set(s.propName,s.templateName)}create(t){return new m(this.componentFactory,t,this.inputMap)}},m=class{componentFactory;injector;inputMap;eventEmitters=new y(1);events=this.eventEmitters.pipe(b(t=>E(...t)));componentRef=null;scheduledDestroyFn=null;initialInputValues=new Map;ngZone;elementZone;appRef;cdScheduler;constructor(t,e,s){this.componentFactory=t,this.injector=e,this.inputMap=s,this.ngZone=this.injector.get(R),this.appRef=this.injector.get(C),this.cdScheduler=e.get(v),this.elementZone=typeof Zone>"u"?null:this.ngZone.run(()=>Zone.current)}connect(t){this.runInZone(()=>{if(this.scheduledDestroyFn!==null){this.scheduledDestroyFn(),this.scheduledDestroyFn=null;return}this.componentRef===null&&this.initializeComponent(t)})}disconnect(){this.runInZone(()=>{this.componentRef===null||this.scheduledDestroyFn!==null||(this.scheduledDestroyFn=_.schedule(()=>{this.componentRef!==null&&(this.componentRef.destroy(),this.componentRef=null)},Y))})}getInputValue(t){return this.runInZone(()=>this.componentRef===null?this.initialInputValues.get(t):this.componentRef.instance[t])}setInputValue(t,e){if(this.componentRef===null){this.initialInputValues.set(t,e);return}this.runInZone(()=>{this.componentRef.setInput(this.inputMap.get(t)??t,e),S(this.componentRef.hostView)&&(F(this.componentRef.changeDetectorRef),this.cdScheduler.notify(6))})}initializeComponent(t){let e=I.create({providers:[],parent:this.injector}),s=P(t,this.componentFactory.ngContentSelectors);this.componentRef=this.componentFactory.create(e,s,t),this.initializeInputs(),this.initializeOutputs(this.componentRef),this.appRef.attachView(this.componentRef.hostView),this.componentRef.hostView.detectChanges()}initializeInputs(){for(let[t,e]of this.initialInputValues)this.setInputValue(t,e);this.initialInputValues.clear()}initializeOutputs(t){let e=this.componentFactory.outputs.map(({propName:s,templateName:u})=>{let r=t.instance[s];return new g(o=>{let i=r.subscribe(c=>o.next({name:u,value:c}));return()=>i.unsubscribe()})});this.eventEmitters.next(e)}runInZone(t){return this.elementZone&&Zone.current!==this.elementZone?this.ngZone.run(t):t()}},f=class extends HTMLElement{ngElementEventsSubscription=null};function D(n,t){let e=A(n,t.injector),s=t.strategyFactory||new p(n,t.injector),u=z(e);class r extends f{injector;static observedAttributes=Object.keys(u);get ngElementStrategy(){if(!this._ngElementStrategy){let i=this._ngElementStrategy=s.create(this.injector||t.injector);e.forEach(({propName:c,transform:a})=>{if(!this.hasOwnProperty(c))return;let d=this[c];delete this[c],i.setInputValue(c,d,a)})}return this._ngElementStrategy}_ngElementStrategy;constructor(i){super(),this.injector=i}attributeChangedCallback(i,c,a,d){let[M,x]=u[i];this.ngElementStrategy.setInputValue(M,a,x)}connectedCallback(){let i=!1;this.ngElementStrategy.events&&(this.subscribeToEvents(),i=!0),this.ngElementStrategy.connect(this),i||this.subscribeToEvents()}disconnectedCallback(){this._ngElementStrategy&&this._ngElementStrategy.disconnect(),this.ngElementEventsSubscription&&(this.ngElementEventsSubscription.unsubscribe(),this.ngElementEventsSubscription=null)}subscribeToEvents(){this.ngElementEventsSubscription=this.ngElementStrategy.events.subscribe(i=>{let c=new CustomEvent(i.name,{detail:i.value});this.dispatchEvent(c)})}}return e.forEach(({propName:o,transform:i})=>{Object.defineProperty(r.prototype,o,{get(){return this.ngElementStrategy.getInputValue(o)},set(c){this.ngElementStrategy.setInputValue(o,c,i)},configurable:!0,enumerable:!0})}),r}function K(n,t){let e=D(n,{injector:t});class s extends e{connectedCallback(){let r;try{let o=this;Z(o),r=V(o)}catch{}super.connectedCallback?.();try{if(w(r),r){let o=this;setTimeout(()=>{j(o),T(o)},0)}}catch{}}}return s}export{K as a};
@@ -1 +1 @@
1
- import{Qj as s,Ra as c,Za as o}from"./chunk-XNDAIOIN.js";var n=(()=>{let r=class r{constructor(t){this.domService=t}transform(t){try{return this.domService.sanitizeHtml(t)}catch{return t}}};r.\u0275fac=function(i){return new(i||r)(c(s,16))},r.\u0275pipe=o({name:"sanitizeHtml",type:r,pure:!0});let e=r;return e})();export{n as a};
1
+ import{Ra as c,Za as o,_j as s}from"./chunk-V53LQO22.js";var n=(()=>{let r=class r{constructor(t){this.domService=t}transform(t){try{return this.domService.sanitizeHtml(t)}catch{return t}}};r.\u0275fac=function(i){return new(i||r)(c(s,16))},r.\u0275pipe=o({name:"sanitizeHtml",type:r,pure:!0});let e=r;return e})();export{n as a};
@@ -0,0 +1 @@
1
+ import{a as ci}from"./chunk-KXEU5HGR.js";import{a as ai}from"./chunk-TM2JOAC4.js";import{A as ni,b as ei,g as ut,j as oi,l as it,m as et,o as ot,t as mt,v as rt,w as ri,z as si}from"./chunk-COMT5MGY.js";import{$f as Pt,$j as tt,Ai as Lt,Bg as zt,Cg as gt,Dj as Wt,E as P,Ej as Jt,Fi as _,G as j,Gd as yt,Gi as X,Gj as Kt,He as R,Ig as K,Ii as jt,Ij as dt,K as Y,Ki as _t,Lj as Qt,M as k,Nj as Xt,O as at,Oj as qt,Pj as ht,Q as Nt,Qd as Dt,Qf as Ut,Tj as Zt,U as It,Uf as Et,V as y,Vi as Ht,Wf as $t,Wj as ti,Xf as wt,Xi as Vt,Y as Ot,Zd as Ct,Zf as ct,_f as F,_j as ii,a as I,ai as Bt,b as U,ba as G,bg as lt,ea as m,ee as At,fa as bt,g as D,i as vt,ji as ft,l as b,li as Q,lj as q,mj as Yt,ni as xt,nj as Z,oj as kt,p as V,q as nt,r as C,re as Tt,sg as Rt,sj as Gt,tf as W,tg as Ft,uf as J,v as p,w as H,wg as Mt,x as pt}from"./chunk-V53LQO22.js";var li=(()=>{let u=class u{constructor(t,i,e,o,r,a,s){this.commentUtilsService=t,this.loggingService=i,this.usersService=e,this.authService=o,this.commentAnnotationsResolverService=r,this.notificationResolverService=a,this.serviceBook=s,this.serviceBook.set(_t,this)}getUserIdsToResolveFromNotifications(t){try{let i=new Set;for(let e of t){let{notification:o}=e;switch(o?.actionUser?.userId&&i.add(o?.actionUser?.userId),o?.displayHeadlineMessageTemplateData?.actionUser?.userId&&i.add(o?.displayHeadlineMessageTemplateData?.actionUser?.userId),o?.displayHeadlineMessageTemplateData?.recipientUser?.userId&&i.add(o?.displayHeadlineMessageTemplateData?.recipientUser?.userId),o?.notificationSource){case"comment":if(o?.notificationSourceData){let r=this.commentUtilsService.getUserIdsToResolveFromComments([o?.notificationSourceData]);for(let a of r)i.add(a)}break}}return Array.from(i)}catch(i){return this.loggingService.catch("Error in ReactionUtilsService getUserIdsToResolveFromRecorders:",i),[]}}mergeStrippedDataWithNotification(t){try{if(this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeStrippedDataWithNotification","color: green;"),!this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())return t;let i=this.commentAnnotationsResolverService.getAnnotationById(t?.notification?.targetAnnotationId),e=t?.raw?.targetAnnotationData?.commentId,o=i?.comments?.[e]?.commentText,r=i?.comments?.[e]?.commentHtml;return o&&r&&t?.raw?.notificationSource==="comment"&&(t.notification.displayBodyMessageTemplate=o,t.raw.targetAnnotationData.commentText=o,t.raw.targetAnnotationData.commentHtml=r),t}catch(i){return this.loggingService.catch("Error in NotificationUtilsService mergeStrippedDataWithNotification:",i),t}}mergeLocationWithNotification(t,i){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeLocationWithNotification","color: green;");let e=t?.notification?.notificationSourceData?.location?.id,o=t?.notification?.notificationSourceData?.metadata?.documentId;if(!e||!o)return t;let r=i?.[o]?.[e];return r&&(t.notification.notificationSourceData.location=r?.location,t?.raw?.annotationData?.location&&(t.raw.annotationData.location=r?.location)),t}catch(e){return this.loggingService.catch("Error in NotificationUtilsService mergeLocationWithNotification:",e),t}}mergeNotificationWithUser(t){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeNotificationWithUser","color: green;");let{notification:i}=t;if(i?.actionUser?.userId){let e=this.usersService.getUserById(i?.actionUser?.userId);e&&(i.actionUser=e)}if(i?.displayHeadlineMessageTemplateData?.actionUser?.userId){let e=this.usersService.getUserById(i?.displayHeadlineMessageTemplateData?.actionUser?.userId);e&&(i.displayHeadlineMessageTemplateData.actionUser=e)}if(i?.displayHeadlineMessageTemplateData?.recipientUser?.userId){let e=this.usersService.getUserById(i?.displayHeadlineMessageTemplateData?.recipientUser?.userId);e&&(i.displayHeadlineMessageTemplateData.recipientUser=e)}return i?.notificationSource==="comment"&&i?.notificationSourceData&&this.commentUtilsService.mergeCommentWithUser(i?.notificationSourceData),t}catch(i){return this.loggingService.catch("Error in NotificationUtilsService mergeNotificationWithUser:",i),t}}formatNotification(t,i){try{if(typeof t=="object"&&(t=JSON.parse(JSON.stringify(t))),this.usersService.userDataProviderAvailable()&&t?.actionUser&&(t.actionUser={userId:t.actionUser.userId}),this.usersService.userResolverConfigured?.()&&t&&typeof t=="object")for(let e of Object.keys(t))e!=="annotationData"&&e!=="targetAnnotationData"&&Lt(t[e])&&(t[e]=xt(t[e],Et));switch(t.notificationSource){case"comment":this.commentUtilsService.formatCommentData(t.annotationData),this.commentUtilsService.formatCommentThreadData(t.targetAnnotationData),t=this.commentUtilsService.stripCommentNotificationPayload(t);break;default:u.carriesCommentPayload(t)&&(t=this.commentUtilsService.stripCommentNotificationPayload(t));break;case"recorder":this.serviceBook.get(Ht)?.formatRecorderData(t.annotationData,i);break}return t}catch(e){return this.loggingService.catch("Error in NotificationUtilsService formatNotification: ",e),u.carriesCommentPayload(t)?this.commentUtilsService?.stripCommentNotificationPayload?.(I({},t))??t:t}}static carriesCommentPayload(t){return!t||typeof t!="object"?!1:t.notificationSource==="comment"||t.notificationSource===void 0&&Array.isArray(t.annotationData?.comments)}getTargetAnnotationIdsFromNotifications(t){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: getTargetAnnotationIdsFromNotifications","color: green;");let i=[];return Object.values(t).forEach(e=>{e?.notification?.targetAnnotationId&&e?.raw?.notificationSource==="comment"&&i.push(e.notification.targetAnnotationId)}),i}catch(i){return this.loggingService.catch("Error in NotificationUtilsService getTargetAnnotationIdsFromNotifications:",i),[]}}handleNotificationEncryption(i){return D(this,arguments,function*({data:t}){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: handleNotificationEncryption","color: green;");let e="notificationwithdocumentidstoencryptanddecryptonsdk"+(this.authService.getUser()?.userId??"");return yield zt(t,e)}catch(e){return this.loggingService.catch("Error in NotificationUtilsService handleNotificationEncryption:",e),t}})}getCustomNotificationIdsToResolve(t){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: getCustomNotificationIdsToResolve","color: green;");let i=new Set,e=Array.isArray(t)?t:Object.values(t||{});for(let o of e)if(o?.raw?.notificationSource==="custom"){let r=o?.notification?.id||o?.notificationId;r&&i.add(r)}return Array.from(i)}catch(i){return this.loggingService.catch("Error in NotificationUtilsService getCustomNotificationIdsToResolve:",i),[]}}mergeResolvedNotificationData(t){try{if(this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeResolvedNotificationData","color: green;"),!this.notificationResolverService.notificationDataProviderAvailable()||t?.raw?.notificationSource!=="custom")return t;let i=t?.notification?.id||t?.notificationId;if(!i)return t;let e=this.notificationResolverService.getNotificationById(i);if(!e)return t;let o=["displayHeadlineMessageTemplate","displayHeadlineMessageTemplateData","displayBodyMessage","displayBodyMessageTemplate","displayBodyMessageTemplateData","notificationSourceData"];for(let r of o)e[r]!==void 0&&(t.notification&&(t.notification[r]=e[r]),t.raw&&(t.raw[r]=e[r]));return Object.keys(e).forEach(r=>{!o.includes(r)&&r!=="notificationId"&&(t.notification&&(t.notification[r]=e[r]),t.raw&&(t.raw[r]=e[r]))}),t.notification&&(t.notification.isNotificationResolverUsed=!0),t}catch(i){return this.loggingService.catch("Error in NotificationUtilsService mergeResolvedNotificationData:",i),t}}};u.\u0275fac=function(i){return new(i||u)(m(ot),m(Z),m(it),m(tt),m(et),m(rt),m(q))},u.\u0275prov=G({token:u,factory:u.\u0275fac,providedIn:"root"});let S=u;return S})();function St(S,u=new Date){let M=S>0?S:15,t=new Date(u.getTime());return t.setDate(t.getDate()-M),t.getTime()}function gi(S){let u={startAtTimestamp:S.startAtTimestamp};return S.currentDocumentOnly&&S.currentDocumentId&&(u.documentId=S.currentDocumentId),S.currentDocumentOnly||(u.limit=S.limit),u}function fi(S,u){let M=[];if(!S||typeof S!="object")return{};for(let e of Object.keys(S)){let o=S[e];if(!o||typeof o!="object")continue;let r=o.timestamp;typeof r!="number"||Number.isNaN(r)||!(r>=u.startAtTimestamp)||u.documentId!==void 0&&o.metadata?.documentId!==u.documentId||M.push({id:e,timestamp:r,row:S[e]})}let t=M;u.limit!==void 0&&(t=[...M].sort((e,o)=>o.timestamp-e.timestamp||(e.id<o.id?1:e.id>o.id?-1:0)).slice(0,Math.max(0,u.limit)));let i={};for(let e of t)i[e.id]=e.row;return i}function di(S){if(typeof S!="number"||!Number.isFinite(S))return 25;let t=Math.floor(S);return t<1?25:Math.min(200,t)}function hi(S,u){let M=t=>!!t&&typeof t=="object"&&Object.keys(t).length>0;return M(S)?S:M(u)?u:{}}var ae=(()=>{let u=class u{constructor(t,i,e,o,r,a,s,c,n,g,l,f,d,h,N,A,$,z,B,x,L,O){this.afAuth=t,this.analyticsService=i,this.authService=e,this.configService=o,this.commonDbService=r,this.commonDbUtilsService=a,this.commentUtilsService=s,this.commentAnnotationsResolverService=c,this.notificationResolverService=n,this.databaseService=g,this.docService=l,this.domService=f,this.iamService=d,this.loggingService=h,this.notificationUtilsService=N,this.usersService=A,this.functions=$,this.userPermissionService=z,this.coreActionsService=B,this.serviceBook=x,this.realtimeAdapter=L,this.adapterSelectorService=O,this.endpointsService=bt(Gt),this.db=null,this.notificationsDb=null,this.documentPaths=null,this.notifications$=new b([]),this.rawNotificationsByIdMap$=new b(new Map),this.processedNotifications$=new b([]),this.userNotificationsFromServer$=new b(null),this.readNotificationsOnForYouTab$=new b(!1),this.currentDocumentOnly$=new b(!1),this.notificationViews$=new b({}),this.notificationsByIdMap$=new b(new Map),this.historyPanelVisible$=new b(!1),this.notificationsForYou$=new b(null),this.notificationsByDocumentIdMap$=new b(null),this.notificationsByDocumentIdSubscription={},this.notificationsHubDisabled=!1,this.reportedDroppedHubPushes=new Set,this.allowedDocumentMetadataMap$=new b(null),this.documentIdsPipelineOnPortableTrigger=!1,this.maxNotificationDays$=new b(15),this.tabConfig$=new b({people:{enable:!1}}),this.settingsConfig$=new b(null),this.setSettingsConfigByOrganization$=new b(!1),this.muteAllNotifications$=new b(!1),this.enableSettings$=new b(!1),this.selfNotifications$=new b(!1),this.userScopedNotifications$=new b({enabled:!1,limit:25}),this.settingsInitialConfig$=new b([{name:"Inbox",id:"inbox",default:"ALL",enable:!0,values:[{name:"All",id:"ALL"},{name:"Only Involved",id:"MINE"},{name:"None",id:"NONE"}]},{name:"Email",id:"email",default:"MINE",enable:!0,values:[{name:"All",id:"ALL"},{name:"Only Involved",id:"MINE"},{name:"None",id:"NONE"}]}]),this.settingsConfigGeneration=0,this.notificationsPanelVisible$=new b(!1),this.crossOrganizationConfig$=new b({enabled:!1}),this.crossOrgNotifications$=new b([]),this.crossOrgIndexOrgs=[],this.crossOrgIndexTimestamps={},this.crossOrgSeenTimestamps={},this.crossOrgInitialFetchDone=!1,this.crossOrgFetchPending=!1,this.lastCrossOrgFetchTime=0,this.CROSS_ORG_FETCH_WINDOW_MS=500,this.CROSS_ORG_PAGE_SIZE=50,this.crossOrgGeneration=0,this.crossOrgResolveRoundInFlight=!1,this.crossOrgStragglerRetryUsed=!1,this.CROSS_ORG_STRAGGLER_RETRY_MS=3e4;try{this.serviceBook.set(jt,this),this.serviceBook.observe(Vt).subscribe(v=>{this.commentService=v??void 0}),this.subscribeNotificationsData().subscribe(),this.commentUtilsService.setNotificationService(this),this.databaseService.getDb().pipe(P(v=>!!v),Y(1)).subscribe(v=>{if(v){this.db=v;try{let T=this.configService.getProxyConfig(),E=this.endpointsService.getNotificationsDbUrl();$t(E)?(this.notificationsDb=null,this.notificationsHubDisabled=!0):(T?.v1DbHost&&E&&(E=wt(E,T.v1DbHost)),this.notificationsDb=this.realtimeAdapter.getDatabaseInstance(E),T?.v1DbHost&&E&&this.databaseService.lockDatabaseHost(this.notificationsDb))}catch(T){this.loggingService.catch("Error initializing notifications DB, using default: ",T),this.notificationsDb=v}this.getDocumentIds(),this.subscribeGetNotificationsForYou()}},v=>{this.loggingService.catch("Error in NotificationService getDb subscription: ",v)}),this.authService.getUser$().subscribe(v=>{v?(this.subscribeGetNotificationsForYou(),this.getDocumentIds(),this.subscribeToUserSettings()):(Object.keys(this.notificationsByDocumentIdSubscription).forEach(T=>{this.notificationsByDocumentIdSubscription[T]?.unsubscribe()}),this.notificationForYouSubscription?.unsubscribe(),this.documentIdsSubscription?.unsubscribe(),this.resetCacheData())}),ht(()=>{try{if(this.adapterSelectorService?.isPortableBackendActive()){if(this.documentIdsPipelineOnPortableTrigger)return;this.getDocumentIds()}}catch(v){this.loggingService.catch("Error re-evaluating portable notification list on chunk registration: ",v)}}),this.docService.getLocationMetadata$().subscribe(v=>{if(v){let T=this.notificationsByDocumentIdMap$.getValue()?JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue())):null;Object.keys(v||{}).forEach(E=>{let w=T?.[E]?.notifications;w?.length&&w.forEach(st=>{this.notificationUtilsService.mergeLocationWithNotification({notification:st},v)?.notification})}),this.notificationsByDocumentIdMap$.next(T)}})}catch(v){this.loggingService.catch("Error in NotificationService constructor: ",v)}}setDBConfigDataToInitialConfig(t){try{let i=JSON.parse(JSON.stringify(this.settingsConfig$.getValue()??{}));Object.entries(t||{}).forEach(([e,o])=>{i[e]=o}),this.settingsConfig$.next(i)}catch(i){this.loggingService.catch("Error in NotificationService setDBConfigDataToInitialConfig: ",i)}}getInitialConfigFromDB(t){return D(this,null,function*(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: getInitialConfigFromDB","color: green;");let i=++this.settingsConfigGeneration,e=F(this.authService.getUser()?.userId??""),o=yield this.commonDbService.getData({feature:"userConfig",properties:{useCollectionGroup:!1,isCollection:!1,documentId:this.getSettingsConfigByOrganization()?void 0:t?.documentId,organizationId:t?.organizationId??this.docService.getOrganizationConfig()?.organizationId,userId:e}});if(i!==this.settingsConfigGeneration)return;if(o?.notificationsConfig)this.setDBConfigDataToInitialConfig(o?.notificationsConfig);else{this.setSettingsInitialConfig(this.settingsInitialConfig$.getValue());let r={};this.settingsInitialConfig$.getValue().forEach(s=>{if(s.enable){let c=s?.values?.find(n=>n.id===s.default);r[s.id]=c||s?.values?.[0]||{id:"NONE",name:"None"}}});let a={};Object.keys(r).forEach(s=>{a[s]=r[s].id}),yield this.updateSettingsConfigToDb(a)}}catch(i){this.loggingService.catch("Error in NotificationService getInitialConfigFromDB: ",i)}})}subscribeToUserSettings(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: subscribeToUserSettings","color: green;"),this.userSettingsSubscription&&this.userSettingsSubscription.unsubscribe();let t=F(this.authService.getUser()?.userId??"");this.userSettingsSubscription=this.enableSettings$.pipe(P(i=>i===!0),y(()=>H([this.docService.getDocumentPaths$(),this.getSettingsConfigByOrganization$(),this.docService.getOrganizationConfig$()]).pipe(P(([i,e,o])=>(e||!!i)&&!!o?.organizationId),y(([i,e,o])=>nt(this.getInitialConfigFromDB(i)).pipe(y(()=>this.commonDbService.dbListener({feature:"userConfig",properties:{useCollectionGroup:!1,isCollection:!1,documentId:e?void 0:i?.documentId,organizationId:i?.organizationId??o?.organizationId,userId:t}}).pipe(p(r=>{r?.data?.notificationsConfig&&!K(r?.data?.notificationsConfig??{},this.settingsConfig$.getValue()??{})&&this.setDBConfigDataToInitialConfig(r?.data?.notificationsConfig)})))))))).subscribe()}catch(t){this.loggingService.catch("Error in NotificationService subscribeToUserSettings: ",t)}}resetCacheData(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: resetCacheData","color: green;"),this.setUserNotificationsFromServer(null),this.notificationsByDocumentIdMap$.next(null),this.notificationsForYou$.next(null),this.settingsConfig$.next(null),this.resetCrossOrgForUser()}catch(t){this.loggingService.catch("Error in NotificationService resetCacheData: ",t)}}subscribeGetNotificationsForYou(){try{this.notificationForYouSubscription&&this.notificationForYouSubscription.unsubscribe(),this.notificationForYouSubscription=this.getNotificationsForYou().subscribe(()=>{},t=>{this.loggingService.catch("Error in NotificationService getNotificationsForYou subscription: ",t)})}catch(t){this.loggingService.catch("Error in NotificationService subscriveGetNotificationsForYou: ",t)}}setCommentService(t){try{this.commentService=t}catch(i){this.loggingService.catch("Error in NotificationService setCommentService: ",i)}}getDocumentIds(){try{this.documentIdsSubscription&&this.documentIdsSubscription.unsubscribe(),this.documentIdsSubscription=pt(()=>{let t=!!this.adapterSelectorService?.isPortableBackendActive();return this.documentIdsPipelineOnPortableTrigger=t,this.notificationListPipeline$(t)}).subscribe(()=>{},t=>{this.loggingService.catch("Error in NotificationService getDocumentIds subscription: ",t)})}catch(t){this.loggingService.catch("Error in NotificationService getDocumentIds: ",t)}}notificationListPipeline$(t=!1){return this.selfNotifications$.pipe(y(()=>this.getCurrentDocumentOnly$().pipe(y(i=>i?this.docService.getDocumentPaths$().pipe(p(e=>{})):C(void 0)))),Ot(()=>{this.notificationsByDocumentIdMap$.next(null)}),y(()=>this.getDocumentIdsByLastNotificationTimestamp(void 0,t).pipe(at(),p(([i,e])=>{let o=i?.map(n=>n.documentId),r=e?.map(n=>n.documentId),a=o?.filter(n=>!r?.includes(n)),s=r?.map(n=>({documentId:n,timestamp:e?.find(g=>g.documentId===n)?.timestamp})).filter(n=>!o?.includes(n.documentId)),c=r?.map(n=>{let g=e?.find(l=>l.documentId===n)?.timestamp;return{documentId:n,timestamp:g}}).filter(n=>{let g=i?.find(l=>l.documentId===n.documentId)?.timestamp;return g&&n.timestamp&&g!==n.timestamp});s?.length&&this.fetchNotificationsForDocumentIds(s),c?.length&&this.fetchNotificationsForDocumentIds(c,1),a?.forEach(n=>{this.removeNotificationsForDocumentId(n)}),e&&!e?.length&&!this.notificationsByDocumentIdMap$.getValue()&&(this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([]))}))))}portableNotificationTriggerRows$(t,i){return new vt(e=>{let o=!1,r=null,a=()=>{try{r?.unsubscribe()}catch(n){this.loggingService.catch("Error releasing the notification trigger subscription: ",n)}r=null},s=()=>{o||(a(),r=this.openPortableNotificationTrigger(t,n=>e.next(n),i))},c=ht(s);return s(),()=>{o=!0;try{c()}catch(n){this.loggingService.catch("Error disposing the notification trigger registration listener: ",n)}a()}})}openPortableNotificationTrigger(t,i,e){try{let o=oi(ut,{apiKey:this.configService.getApiKey(),organizationId:t}),r=this.adapterSelectorService?.resolveRealtimeAdapter?.();if(!o||!r)return null;let a=Xt(o.feature)?.mode??"persistent",s={},c={},n=!1,g=!1;return r.subscribe(o,a,l=>{try{if(g)return;if(typeof l.seq=="number"){let f=c[l.id];if(f!==void 0&&l.seq<=f)return;c[l.id]=l.seq}l.type==="removed"?delete s[l.id]:s[l.id]=l.data,n&&typeof l.seq=="number"&&i(I({},s))}catch(f){this.loggingService.catch("Error materializing a notification trigger delta: ",f)}},I({onSnapshotComplete:l=>{try{if(g)return;if(l?.full===!0)for(let f of Object.keys(c))delete c[f];n=!0,i(I({},s))}catch(f){this.loggingService.catch("Error completing the notification trigger snapshot: ",f)}},onError:l=>{g=!0,this.loggingService.catch(`Portable channel denied for ${ut}: `,{ok:!1,code:l})}},e?{documentId:e}:{}))}catch(o){return this.loggingService.catch("Error subscribing the notification trigger channel: ",o),null}}getDocumentIdsByLastNotificationTimestamp(t=15,i=!1){try{return this.authService.getUser$().pipe(y(e=>this.docService.getOrganizationConfig$().pipe(p(o=>{let r=null,a=this.configService.getApiKey(),s=o?.organizationId||e?.organizationId,c=o?.clientOrganizationId||e?.clientOrganizationId||"";return a&&s&&(r=new mt({apiKey:a,organizationId:s})),{user:e,documentPaths:r,clientOrganizationId:c}}))),y(e=>{let{user:o,documentPaths:r,clientOrganizationId:a}=e;if(this.getCurrentDocumentOnly()&&!this.docService?.getDocumentPaths()?.documentId)return C(null);if(o&&r?.organizationNotificationsLastNotificationTimestamp){let s=St(this.maxNotificationDays$.getValue()),c=gi({startAtTimestamp:s,currentDocumentOnly:this.getCurrentDocumentOnly(),currentDocumentId:this.docService.getDocumentPaths()?.documentId,limit:t}),n=o?.userId??"";return nt(this.userPermissionService?.getUserPermissionsFromCacheOrFetch({organizationId:a})??Promise.resolve({})).pipe(y(g=>n&&a&&g?.[n]?.organization?.[a]?.errorCode===Ut.PERMISSION_DENIED?C(null):this.lastNotificationTimestampRows$(r,c,i).pipe(p(l=>{let f=()=>i||this.commonDbService.shouldUseFirestore(),d=[];return Object.keys(l||{}).forEach(h=>{let N=f()?l[h]?.timestamp??0:l[h],A=f()?l[h]?.deletedNotification??!1:!1;if(A&&A.id&&A?.timestamp===N){let $=A.id,z=l[h]?.metadata?.documentId,B=JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue()??{})),x=B?.[z]??{documentMetadata:null,notifications:[]},L=x.notifications??[],O=L?.findIndex(v=>v.id===$);O!==-1&&(L.splice(O,1),this.notificationsByDocumentIdMap$.next(U(I({},B),{[z]:U(I({},x),{notifications:L})}))),this.notificationResolverService.notificationDataProviderAvailable()&&this.notificationResolverService.getNotificationById($)&&this.notificationResolverService.deleteNotification($,this.docService.getDocumentPaths()?.clientOrganizationId??"")}d.push({documentId:h,timestamp:N})}),d}),j(l=>(this.loggingService.catch("Error in NotificationService getDocumentIdsByLastNotificationTimestamp: ",l),C([]))))))}return C(null)}))}catch(e){return this.loggingService.catch("Error in NotificationService getDocumentIdsByLastNotificationTimestamp: ",e),C([])}}lastNotificationTimestampRows$(t,i,e=!1){return e?this.portableNotificationTriggerRows$(t?.organizationId,i.documentId).pipe(p(o=>fi(o,i)),It(void 0)):this.commonDbService.dbListener({feature:"allLastNotificationTimestamp",properties:{organizationId:t?.organizationId,isCollection:!0,useQuery:!0,firestoreQuery:this.toFirestoreTriggerQuery(i)}}).pipe(p(o=>o?.data))}toFirestoreTriggerQuery(t){let i=[Wt(dt("timestamp",">=",t.startAtTimestamp),...t.documentId!==void 0?[dt("metadata.documentId","==",t.documentId)]:[])];return t.limit!==void 0&&(i.push(Kt("timestamp","desc")),i.push(Jt(t.limit))),i}resolveAndUpdateDocumentNotifications(t,i){try{Object.keys(t).forEach(e=>{let o=t[e]?.documentMetadata||this.docService.getAllDocumentMetadataMap()?.[e]||{},r;if(i==="user")r=this.commonDbUtilsService.mergeUsersWithData({feature:"allDocNotifications",data:t[e]?.notifications||[]});else if(i==="notification"){let a=t[e]?.notifications?.reduce((c,n)=>(c[n.notificationId]=n,c),{}),s=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allDocNotifications",data:a});r=Object.values(s??{})}else{let a=t[e]?.notifications?.reduce((c,n)=>(c[n.notificationId]=n,c),{}),s=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allDocNotifications",data:a});r=Object.values(s??{})}r.forEach(a=>{a.notification=this.getClientNotificationObject(a)}),this.setNotificationForDocumentIdInCache(e,o,r)})}catch(e){this.loggingService.catch("Error in NotificationService resolveAndUpdateDocumentNotifications: ",e)}}resolveAndMergeUserNotifications(t,i,e=!1){try{let o=t;if(e&&i==="comment"){let n=this.getUserNotificationsFromServer()??[],g=new Set(t.map(l=>l.notificationId));o=n.filter(l=>g.has(l.notificationId)).concat(t.filter(l=>!n.some(f=>f.notificationId===l.notificationId)))}let r=o.reduce((n,g)=>(n[g.notificationId]=g,n),{}),a;if(i==="user"){let n=this.commonDbUtilsService.mergeUsersWithData({feature:"allUserNotifications",data:r});a=Object.values(n??{})}else if(i==="notification"){let n=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allUserNotifications",data:r});a=Object.values(n??{})}else{let n=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allUserNotifications",data:r});a=Object.values(n??{})}a.forEach(n=>{n.notification=this.getClientNotificationObject(n)});let s=this.getUserNotificationsFromServer()??[],c=new Map(s.map(n=>[n.notificationId,n]));a.forEach(n=>{c.set(n.notificationId,n)}),this.setUserNotificationsFromServer(Array.from(c.values()))}catch(o){this.loggingService.catch("Error in NotificationService resolveAndMergeUserNotifications: ",o)}}fetchNotificationsForDocumentIds(t,i=15){return D(this,null,function*(){try{if(t?.length){let e=this.docService.getOrganizationConfig()?.organizationId??"";if(!e)return[];let o=this.getStartAtTimestamp(),r={};t.forEach(h=>{if(h?.documentId){let N=this.getAllowedDocumentMetadataByDocumentId(h.documentId);N&&(r[h.documentId]=N)}}),this.userPermissionService?.isPermissionProviderAvailable()&&(t=yield this.filterDocumentIdsByPermissionProvider(t));let a=this.userScopedNotifications$.getValue(),s=!!a?.enabled&&i!==1&&!this.getCurrentDocumentOnly();if(!t.length&&(this.notificationsByDocumentIdMap$.getValue()||(this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([])),!s))return[];let c=this.userPermissionService?.getPermissionsCache()?.filter(h=>h.type===J.CONTEXT),n=I({organizationId:e,documentIds:t.filter(h=>!!h.documentId&&!!h.timestamp).map(h=>({documentId:h.documentId,timestamp:h.timestamp??0})),timestamp:o,limitToLast:i,selfNotifications:this.selfNotifications$.value,isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable(),getUserNotifications:!0,isContextEnabled:this.userPermissionService?.getIsContextEnabled(),cachedData:c,isSettingsConfigByOrganization:this.getSettingsConfigByOrganization(),retryConfig:this.userPermissionService?.getPermissionProviderRetryConfig()},s&&{getUserNotificationsForOrganization:!0,userNotificationsLimitToLast:di(a?.limit)}),{notificationsByDocumentId:g,userNotifications:l=[],userNotificationIdsInDocNotifications:f=[],permissionResults:d=[]}=yield this.callGetNotificationsForDocuments(n);if(this.userPermissionService?.getIsContextEnabled()){let h=[...this.userPermissionService?.getPermissionsCache()??[],...d??[]];this.userPermissionService?.setPermissionsCache(h)}if(g&&typeof g=="object"){let h=this.usersService.userDataProviderAvailable(),N=this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable(),A=this.notificationResolverService.notificationDataProviderAvailable(),$=[],z=[],B=[];Object.keys(g).forEach((O,v)=>{let T=g[O].documentMetadata??this.docService.getAllDocumentMetadataMap()?.[O];if(T){let w=this.allowedDocumentMetadataMap$.value||{};(!w?.[O]||!K(w?.[O],T))&&this.allowedDocumentMetadataMap$.next(U(I({},w),{[O]:T}))}let E=g[O].notifications||[];E.forEach(w=>{f.includes(w.notificationId)&&!l.find(st=>st.notificationId===w.notificationId)&&l.push(JSON.parse(JSON.stringify(w))),w.notification=this.getClientNotificationObject(w)}),this.setNotificationForDocumentIdInCache(O,T,E),h&&($.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:E,shouldAwait:!0,forceResolve:!0})),$.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:l,shouldAwait:!0,forceResolve:!0}))),N&&(z.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:E,shouldCommentAnnotationsResolverAwait:!0})),z.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:l,shouldCommentAnnotationsResolverAwait:!0}))),A&&(B.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:E,shouldNotificationResolverAwait:!0})),B.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:l,shouldNotificationResolverAwait:!0})))});let x=JSON.parse(JSON.stringify(l));if(s){let O=new Map((this.getUserNotificationsFromServer()??[]).map(v=>[v?.notificationId,v]));l.forEach(v=>O.set(v?.notificationId,v)),this.setUserNotificationsFromServer(Array.from(O.values()))}else this.setUserNotificationsFromServer([...this.getUserNotificationsFromServer()??[],...l]);(A||h||N)&&(()=>{let O=Promise.resolve();if(A&&(O=O.then(()=>Promise.allSettled(B)).then(()=>{this.resolveAndUpdateDocumentNotifications(g,"notification"),this.resolveAndMergeUserNotifications(x,"notification")})),h&&(O=O.then(()=>Promise.allSettled($)).then(()=>{this.resolveAndUpdateDocumentNotifications(g,"user"),this.resolveAndMergeUserNotifications(x,"user")})),N){let v=A||h;O=O.then(()=>Promise.allSettled(z)).then(()=>{this.resolveAndUpdateDocumentNotifications(g,"comment"),this.resolveAndMergeUserNotifications(x,"comment",v)})}return O})().catch(O=>{this.loggingService.catch("Error in NotificationService resolveChain: ",O)})}}}catch(e){return this.loggingService.catch("Error in NotificationService fetchNotificationsForDocumentIds: ",e),[]}})}filterDocumentIdsByPermissionProvider(t){return D(this,null,function*(){try{let i=[];if(t.forEach(s=>{this.docService.getDocumentMetadata(s.documentId)||i.push(s.documentId)}),i.length){let s=this.authService.getUser(),c={type:"getDocumentMetadataFromIds",metadata:{organizationId:s?.clientOrganizationId,folderId:this.documentPaths?.folderId},documentIds:i},n=!!this.adapterSelectorService?.isPortableBackendActive(),g=n?void 0:X(this.functions,Q({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));try{let l=n?yield this.invokePortableSdkProxyOp("getDocumentMetadataFromIds",c):yield ft({methodName:"getDocumentMetadataFromIds",data:c,getSdkProxy:g,userId:s?.userId??""});if(l?.data?.length){let f={};l.data.forEach(d=>{d?.documentId&&(f[d.documentId]=d)}),this.docService.setAllDocumentMetadata(I(I({},this.docService.getAllDocumentMetadataMap()),f))}}catch(l){this.loggingService.warn("Error in NotificationService fetchNotificationsForDocumentIds: ",l)}}let e=[],o=[];t.forEach(s=>{let c=this.docService.getDocumentMetadata(s.documentId);c?.clientDocumentId?e.push({userId:this.authService.getUser()?.userId??"",resource:I({id:c.clientDocumentId,type:J.DOCUMENT,source:W.GET_NOTIFICATIONS,organizationId:this.docService.getOrganizationConfig()?.clientOrganizationId??""},c.folderId&&{parentFolderId:c.folderId})}):o.push(s.documentId)}),o.length&&(t=t.filter(s=>!o.includes(s.documentId)));let r=Ft();this.coreActionsService.triggerAction(At.PERMISSION_PROVIDER,{event:_.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:r,methodName:W.GET_NOTIFICATIONS,source:"internal",payload:{requests:e}});let a=yield this.userPermissionService?.onResourceAccessRequired({requests:e,uniqueId:r,methodName:W.GET_NOTIFICATIONS});return a?.success&&a?.data?.length?a.data.forEach(s=>{!s.hasAccess&&s.resourceId&&(t=t.filter(c=>c.documentId!==Pt(s.resourceId)))}):t=[],t}catch(i){return this.loggingService.warn("Error in NotificationService fetchNotificationsForDocumentIds: ",i),[]}})}callGetNotificationsForDocuments(t){return D(this,null,function*(){if(this.adapterSelectorService?.isPortableBackendActive())return this.callPortableGetNotificationsForDocuments(t);let i=X(this.functions,Q({url:this.endpointsService.getCloudFunctionUrl("getNotificationsForDocuments"),apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:1200*1e3}),e=yield this.notificationUtilsService.handleNotificationEncryption({data:t}),o=yield i({veltData:e}),r=o?.data?.data?.veltData||{},a=o?.data?.data?.veltAdditionalData||{},s="notificationwithdocumentidstoencryptanddecryptonsdk"+(this.authService.getUser()?.userId??""),c=yield gt(r,s),{userNotifications:n,userNotificationIdsInDocNotifications:g,permissionResults:l}=yield gt(a,s);return{notificationsByDocumentId:c,userNotifications:n,userNotificationIdsInDocNotifications:g,permissionResults:l}})}callPortableGetNotificationsForDocuments(t){return D(this,null,function*(){let i=yield this.adapterSelectorService.resolveDbAdapter().getNotificationsForDocuments({scope:"org",data:t});if(!i?.ok)throw new Error(`getNotificationsForDocuments failed on the portable gateway: ${i?.code??"unknown"}`);let e=i.data??{},o=e.veltData??{},{userNotifications:r,userNotificationIdsInDocNotifications:a,permissionResults:s}=e.veltAdditionalData??{};return{notificationsByDocumentId:o,userNotifications:r,userNotificationIdsInDocNotifications:a,permissionResults:s}})}invokePortableSdkProxyOp(t,i){return D(this,null,function*(){try{let e=yield this.adapterSelectorService.resolveDbAdapter()[t]({scope:"org",data:i});return e?.ok?e.data?.veltData:(this.loggingService.catch(`Error in NotificationService ${t} (portable gateway): `,e),i)}catch(e){return this.loggingService.catch(`Error in NotificationService ${t} (portable gateway): `,e),i}})}getUserNotificationsFromServer$(){return this.userNotificationsFromServer$.asObservable()}setUserNotificationsFromServer(t){try{let i=JSON.parse(JSON.stringify(t));i=i?.filter((e,o,r)=>o===r.findIndex(a=>a.notificationId===e.notificationId)),this.userNotificationsFromServer$.next(i)}catch(i){this.loggingService.catch("Error in NotificationService setUserNotificationsFromServer: ",i)}}getUserNotificationsFromServer(){return this.userNotificationsFromServer$.getValue()}setNotificationForDocumentIdInCache(t,i,e,o){try{let r=this.docService.getOrganizationConfig()?.organizationId??"",a=this.docService.getOrganizationMetadata(r);i||(i=this.getOwnDocumentMetadata(t)),a||(a=JSON.parse(JSON.stringify(this.docService.getOrganizationMetadata(r)||{})));let s=this.notificationsByDocumentIdMap$.getValue(),c=s?.[t]?.notifications||[],n=this.docService.getLocationMetadatas(),g=e?.map(d=>{let h=d?.notification;return h?(h.metadata&&(h.metadata.documentName=i?.documentName||h.metadata.documentName,h.metadata.organizationMetadata=a||h.metadata.organizationMetadata,h.metadata.documentMetadata=hi(i,h.metadata.documentMetadata)),n&&(h=this.notificationUtilsService.mergeLocationWithNotification({notification:h},n)?.notification),h):null})?.filter(d=>!!d)||[],l=new Map(c.map(d=>[d.id,d]));g.forEach(d=>{l.set(d.id,d)});let f=Array.from(l.values()).sort((d,h)=>(h.timestamp||0)-(d.timestamp||0));this.notificationsByDocumentIdMap$.next(U(I({},s),{[t]:{notifications:f,documentMetadata:i||{}}}))}catch(r){this.loggingService.catch("Error in NotificationService setNotificationForDocumentIdInCache: ",r)}}removeNotificationsForDocumentId(t){try{this.notificationsByDocumentIdSubscription[t]&&this.notificationsByDocumentIdSubscription[t].unsubscribe();let i=this.notificationsByDocumentIdMap$.getValue();delete i?.[t],this.notificationsByDocumentIdMap$.next(i)}catch(i){this.loggingService.catch("Error in NotificationService removeNotificationsForDocumentId: ",i)}}getStartAtTimestamp(){try{return St(this.maxNotificationDays$.getValue())}catch(t){return this.loggingService.catch("Error in NotificationService getStartAtTimestamp: ",t),0}}getCurrentOrgNotificationsForYou(){try{return this.getUserNotificationsFromServer$().pipe(y(t=>C(t).pipe(P(i=>!!i),p(i=>{let e=this.usersService.userDataProviderAvailable(),o=this.commentAnnotationsResolverService?.commentAnnotationDataProviderAvailable(),r=this.notificationResolverService?.notificationDataProviderAvailable();if(r||e||o){let s=i?.reduce((c,n)=>(c[n.notificationId]=n,c),{});r&&(s=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allUserNotifications",data:s||[]})),e&&(s=this.commonDbUtilsService.mergeUsersWithData({feature:"allUserNotifications",data:s||[]})),o&&(s=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allUserNotifications",data:s||[]})),i=Object.values(s??{})}return i.forEach(s=>{s.notification=this.getClientNotificationObject(s)}),i.sort((s,c)=>c.timestamp-s.timestamp),i.map(s=>s.notification).filter(s=>!!s)}),y(i=>{let e={data:i?.reduce((o,r)=>(o[r.id]={notification:r},o),{}),operation:null};return this.commonDbUtilsService.mergeLocationMetadataWithData$({data:e,feature:"allUserNotifications"}).pipe(p(o=>Object.values(o?.data||{}).map(r=>r?.notification)))}))),y(t=>{let i=this.docService.getOrganizationConfig()?.organizationId??"";return this.docService.getOrganizationMetadata$(i).pipe(p(()=>t))}),y(t=>this.allowedDocumentMetadataMap$.pipe(p(()=>t))),p(t=>(t?.length&&(t=t.map(i=>{if(i?.metadata){let e=this.docService.getOrganizationConfig()?.organizationId??"",o=this.getAllowedDocumentMetadataByDocumentId(i.metadata.documentId),r=this.docService.getOrganizationMetadata(e);o||(o=this.getOwnDocumentMetadata(i.metadata.documentId)),r||(r=JSON.parse(JSON.stringify(this.docService.getOrganizationMetadata(e)||{}))),i.metadata.documentName=o?.documentName||i.metadata.documentName,i.metadata.organizationMetadata=r||i.metadata.organizationMetadata,i.metadata.documentMetadata=hi(o,i.metadata.documentMetadata)}return i})),t)))}catch(t){return this.loggingService.catch("Error in NotificationService getCurrentOrgNotificationsForYou: ",t),C(null)}}getNotificationsForYou(){try{return H([this.getCurrentOrgNotificationsForYou(),this.crossOrgNotifications$.asObservable()]).pipe(p(([t,i])=>{let e=this.mergeCrossOrgForYou(t,i);return e===null?this.notificationsForYou$.next(null):e?.length?this.notificationsForYou$.next(JSON.parse(JSON.stringify(e))):this.notificationsForYou$.next([]),e}))}catch(t){return this.loggingService.catch("Error in NotificationService getNotificationsForYou: ",t),C({})}}mergeCrossOrgForYou(t,i){try{let e=Array.isArray(i)?i:[];if(!e.length)return t;let o=Array.isArray(t)?t:[],r=c=>c?.id??c?.notificationId,a=new Set;o.forEach(c=>{let n=r(c);n!=null&&a.add(n)});let s=[...o];return e.forEach(c=>{let n=r(c);n!=null&&a.has(n)||(n!=null&&a.add(n),s.push(c))}),s.sort((c,n)=>(n?.timestamp||0)-(c?.timestamp||0))}catch(e){return this.loggingService.catch("Error in NotificationService mergeCrossOrgForYou: ",e),t}}enableCrossOrganization(t){try{if(t&&typeof t=="object"&&t.enabled===!1){this.disableCrossOrganization();return}this.setCrossOrganizationConfig(U(I({},t||{}),{enabled:!0})),this.crossOrgUserSubscription?this.crossOrgIndexSubscription&&(this.crossOrgInitialFetchDone=!1,this.scheduleCrossOrgFetch()):this.attachCrossOrgIndexListener()}catch(i){this.loggingService.catch("Error in NotificationService enableCrossOrganization: ",i)}}disableCrossOrganization(){try{this.teardownCrossOrg();let t=this.crossOrganizationConfig$.getValue();this.crossOrganizationConfig$.next(U(I({},t||{}),{enabled:!1}))}catch(t){this.loggingService.catch("Error in NotificationService disableCrossOrganization: ",t)}}setCrossOrganizationConfig(t){try{let i=t||{},e=Array.isArray(i.feeds)&&i.feeds.length?i.feeds:["forYou"];e.includes("all")&&this.loggingService.warn('NotificationService: cross-organization notifications only support the "forYou" feed; ignoring "all".'),e=e.filter(r=>r==="forYou"),e.length||(e=["forYou"]);let o={enabled:i.enabled??!0,organizationIds:i.organizationIds,excludeOrganizationIds:i.excludeOrganizationIds,feeds:e};this.crossOrganizationConfig$.next(o)}catch(i){this.loggingService.catch("Error in NotificationService setCrossOrganizationConfig: ",i)}}getCrossOrganizationConfig(){return this.crossOrganizationConfig$.getValue()}getCrossOrganizationConfig$(){return this.crossOrganizationConfig$.asObservable()}attachCrossOrgIndexListener(){try{this.teardownCrossOrgUserWatcher(),this.crossOrgUserSubscription=this.authService.getUser$().pipe(p(t=>t?.userId),k(),P(t=>!!t),j(t=>(this.loggingService.catch("Error in NotificationService cross-org user watcher: ",t),V))).subscribe(t=>{try{this.teardownCrossOrgPerUserListeners(),this.resetCrossOrgDeltaState(),this.crossOrgNotifications$.next([]),this.bindCrossOrgListenersForUser(t)}catch(i){this.loggingService.catch("Error in NotificationService cross-org user-change handler: ",i)}})}catch(t){this.loggingService.catch("Error in NotificationService attachCrossOrgIndexListener: ",t)}}bindCrossOrgListenersForUser(t){this.crossOrgIndexSubscription=this.commonDbService.dbListener({feature:"userNotificationIndex",properties:{id:F(t),isCollection:!1,useCollectionGroup:!1}}).pipe(j(i=>(this.loggingService.catch("Error in NotificationService cross-org index listener: ",i),V))).subscribe(i=>{try{let e=this.extractIndexOrgTimestamps(i);this.crossOrgIndexTimestamps=e;let o=Object.keys(e);this.crossOrgIndexOrgs=o,this.pruneCrossOrgBufferToAllowedOrgs(),o.length&&this.scheduleCrossOrgFetch()}catch(e){this.loggingService.catch("Error in NotificationService cross-org index snapshot: ",e)}}),this.crossOrgOrgSwitchSubscription=this.docService.getOrganizationConfig$().pipe(p(i=>i?.organizationId??""),k(),at(),P(([i])=>!!i),j(i=>(this.loggingService.catch("Error in NotificationService cross-org org-switch listener: ",i),V))).subscribe(()=>{this.crossOrgInitialFetchDone=!1,this.crossOrgSeenTimestamps={},this.scheduleCrossOrgFetch()})}extractIndexOrgTimestamps(t){let i={};try{let e=t?.data??t,o=e?.organizationIds??e?.orgs;return Array.isArray(o)?(o.forEach(r=>{typeof r=="string"&&r.length&&(i[r]=0)}),i):(o&&typeof o=="object"&&Object.keys(o).forEach(r=>{if(typeof r=="string"&&r.length){let a=Number(o[r]);i[r]=Number.isFinite(a)?a:0}}),i)}catch(e){return this.loggingService.catch("Error in NotificationService extractIndexOrgTimestamps: ",e),i}}scheduleCrossOrgFetch(){try{let t=Date.now();t-this.lastCrossOrgFetchTime>=this.CROSS_ORG_FETCH_WINDOW_MS?(this.lastCrossOrgFetchTime=t,this.crossOrgFetchPending=!1,this.fetchCrossOrgUserNotifications(),this.armCrossOrgTrailingTimer()):this.crossOrgFetchPending=!0}catch(t){this.loggingService.catch("Error in NotificationService scheduleCrossOrgFetch: ",t)}}pruneCrossOrgBufferToAllowedOrgs(){try{let t=this.crossOrgNotifications$.getValue();if(!t.length)return;let i=this.crossOrgIndexOrgs||[];if(!i.length){this.crossOrgNotifications$.next([]);return}let e=t.filter(o=>i.includes(o?.metadata?.organizationId));e.length!==t.length&&this.crossOrgNotifications$.next(e)}catch(t){this.loggingService.catch("Error in NotificationService pruneCrossOrgBufferToAllowedOrgs: ",t)}}armCrossOrgTrailingTimer(){this.crossOrgFetchTimer&&clearTimeout(this.crossOrgFetchTimer),this.crossOrgFetchTimer=setTimeout(()=>{this.crossOrgFetchPending&&(this.crossOrgFetchPending=!1,this.lastCrossOrgFetchTime=Date.now(),this.fetchCrossOrgUserNotifications())},this.CROSS_ORG_FETCH_WINDOW_MS)}toCrossOrgClientNotification(t){try{if(!t)return null;if(t.notification){let e=this.getClientNotificationObject(t);if(!e)return null;let o=t?.metadata?.organizationId??e?.metadata?.organizationId;return o!=null&&(e.metadata=U(I({},e.metadata||{}),{organizationId:o})),e}let i=t.id??t.notificationId;return i==null?null:t.id!=null?t:U(I({},t),{id:i})}catch(i){return this.loggingService.catch("Error in NotificationService toCrossOrgClientNotification: ",i),null}}resolveCrossOrgSelfHostedData(t){return D(this,null,function*(){try{if(!t?.length)return t;let i=!!this.notificationResolverService?.notificationDataProviderAvailable?.(),e=!!this.usersService?.userDataProviderAvailable?.(),o=!!this.commentAnnotationsResolverService?.commentAnnotationDataProviderAvailable?.();if(!i&&!e&&!o)return t;let r=this.commonDbService?.isPortableSession?.()===!0,a=new Map;for(let c of t){let n=r?c?.metadata?.clientOrganizationId??"":c?.metadata?.clientOrganizationId??c?.metadata?.organizationId??"",g=a.get(n);g?g.push(c):a.set(n,[c])}let s=[];for(let[c,n]of a){if(r&&!c){s.push(...n);continue}let g=n.reduce((f,d,h)=>{let N=d?.notificationId??d?.id??`__cross_org_${h}`;return f[N]=d,f},{});yield this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:g,organizationId:c||void 0,shouldAwait:!0,shouldNotificationResolverAwait:!0,shouldCommentAnnotationsResolverAwait:!0});let l=g;i&&(l=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allUserNotifications",data:l??{}})),e&&(l=this.commonDbUtilsService.mergeUsersWithData({feature:"allUserNotifications",data:l??{}})),o&&(l=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allUserNotifications",data:l??{}})),s.push(...Object.values(l??{}))}return s}catch(i){return this.loggingService.catch("Error in NotificationService resolveCrossOrgSelfHostedData: ",i),t}})}fetchCrossOrgUserNotifications(){return D(this,null,function*(){let t=this.crossOrgGeneration;if(this.crossOrgResolveRoundInFlight){this.crossOrgFetchPending=!0;return}this.crossOrgResolveRoundInFlight=!0;try{let i=this.crossOrganizationConfig$.getValue(),e=this.docService.getOrganizationConfig()?.organizationId??"",o=!this.crossOrgInitialFetchDone,r=this.crossOrgIndexTimestamps||{},a=o?[]:Object.keys(r).filter(f=>f!==e&&(r[f]??0)>(this.crossOrgSeenTimestamps[f]??-1));if(!o&&!a.length)return;let s=this.buildCrossOrgRequestData(i,e,{isInitial:o,bumpedOrgs:a}),c=yield this.callGetCrossOrgUserNotifications(s);if(t!==this.crossOrgGeneration)return;let n=Array.isArray(c?.pendingPermissionQueries)?c.pendingPermissionQueries:[],g=!!this.userPermissionService?.isClientDevResolverActive?.(),l=!n.length||!g;if(yield this.processCrossOrgResponse(c,{fetchGeneration:t,currentOrg:e,isInitial:o,indexTimestamps:r,advanceCursors:l}),t!==this.crossOrgGeneration||l){l&&t===this.crossOrgGeneration&&this.clearCrossOrgStragglerRetry();return}yield this.runCrossOrgResolveRound(n,{fetchGeneration:t,config:i,currentOrg:e,isInitial:o,bumpedOrgs:a,indexTimestamps:r})}catch(i){this.loggingService.catch("Error in NotificationService fetchCrossOrgUserNotifications: ",i)}finally{this.crossOrgResolveRoundInFlight=!1,this.crossOrgFetchPending&&t===this.crossOrgGeneration&&(this.crossOrgFetchPending=!1,this.lastCrossOrgFetchTime=Date.now(),this.fetchCrossOrgUserNotifications())}})}runCrossOrgResolveRound(t,i){return D(this,null,function*(){try{let e=yield this.userPermissionService.resolveClientSidePermissions(t);if(i.fetchGeneration!==this.crossOrgGeneration)return;let o=this.buildCrossOrgRequestData(i.config,i.currentOrg,{isInitial:i.isInitial,bumpedOrgs:i.bumpedOrgs});o.clientResolvedResults=e;let r=yield this.callGetCrossOrgUserNotifications(o);if(i.fetchGeneration!==this.crossOrgGeneration)return;yield this.processCrossOrgResponse(r,{fetchGeneration:i.fetchGeneration,currentOrg:i.currentOrg,isInitial:i.isInitial,indexTimestamps:i.indexTimestamps,advanceCursors:!0}),i.fetchGeneration===this.crossOrgGeneration&&this.clearCrossOrgStragglerRetry()}catch(e){this.loggingService.catch("Error in NotificationService runCrossOrgResolveRound: ",e),this.armCrossOrgStragglerRetry(i.fetchGeneration)}})}processCrossOrgResponse(t,i){return D(this,null,function*(){if(this.userPermissionService?.getIsContextEnabled?.()&&t?.permissionResults?.length){let g=[...this.userPermissionService?.getPermissionsCache?.()??[],...t.permissionResults];this.userPermissionService?.setPermissionsCache?.(g)}let e=Array.isArray(t?.forYou)?t.forYou:[],o=this.crossOrgIndexOrgs||[],r=g=>o.includes(g),a=e.filter(g=>{let l=g?.metadata?.organizationId;if(l===i.currentOrg)return this.loggingService.log("%c[WB] Cross-org: dropping current-org echo: "+l,"color: orange;"),!1;let f=r(l);return f||this.loggingService.log("%c[WB] Cross-org: dropping entry from un-indexed org: "+l,"color: orange;"),f}),s=yield this.resolveCrossOrgSelfHostedData(a);if(i.fetchGeneration!==this.crossOrgGeneration)return;let c=s.map(g=>this.toCrossOrgClientNotification(g)).filter(g=>!!g),n;i.isInitial?n=c:n=this.mergeCrossOrgForYou(c,this.crossOrgNotifications$.getValue()).filter(g=>r(g?.metadata?.organizationId)),i.advanceCursors&&(Object.keys(i.indexTimestamps).forEach(g=>{this.crossOrgSeenTimestamps[g]=i.indexTimestamps[g]}),this.crossOrgInitialFetchDone=!0),this.crossOrgNotifications$.next(n)})}armCrossOrgStragglerRetry(t){this.crossOrgStragglerRetryUsed||(this.crossOrgStragglerRetryUsed=!0,this.crossOrgStragglerRetryTimer&&clearTimeout(this.crossOrgStragglerRetryTimer),this.crossOrgStragglerRetryTimer=setTimeout(()=>{this.crossOrgStragglerRetryTimer=void 0,t===this.crossOrgGeneration&&this.fetchCrossOrgUserNotifications()},this.CROSS_ORG_STRAGGLER_RETRY_MS))}clearCrossOrgStragglerRetry(){this.crossOrgStragglerRetryUsed=!1,this.crossOrgStragglerRetryTimer&&(clearTimeout(this.crossOrgStragglerRetryTimer),this.crossOrgStragglerRetryTimer=void 0)}callGetCrossOrgUserNotifications(t){return D(this,null,function*(){if(this.adapterSelectorService?.isPortableBackendActive())return this.invokePortableSdkProxyOp("getCrossOrgUserNotifications",I({type:"getCrossOrgUserNotifications"},t));let i=this.authService.getUser(),e=X(this.functions,Q({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));return yield ft({methodName:"getCrossOrgUserNotifications",data:I({type:"getCrossOrgUserNotifications"},t),getSdkProxy:e,userId:i?.userId??""})})}buildCrossOrgRequestData(t,i,e){let o=t||{},r=e?.isInitial??!0,a=e?.bumpedOrgs??[],s=Array.isArray(o.organizationIds),c=s?o.organizationIds.filter(d=>!!d).map(d=>lt(d)):[],n=(o.excludeOrganizationIds||[]).filter(d=>!!d).map(d=>lt(d)),g=new Set(n);i&&g.add(i);let l=this.userPermissionService?.getPermissionsCache?.()?.filter(d=>d?.type===J.CONTEXT),f={organizationId:i,excludeOrganizationIds:Array.from(g),timestamp:this.getStartAtTimestamp(),limitToLast:this.CROSS_ORG_PAGE_SIZE,isContextEnabled:this.userPermissionService?.getIsContextEnabled?.(),cachedData:l,isSettingsConfigByOrganization:this.getSettingsConfigByOrganization(),retryConfig:this.userPermissionService?.getPermissionProviderRetryConfig?.()};if(this.userPermissionService?.isClientDevResolverActive?.()&&(f.clientResolverAvailable=!0),r)s&&(f.organizationIds=this.dedupeIncludeOrgs(c,g));else{let d=a.filter(N=>!!N&&!g.has(N));if(s){let N=new Set(c);d=d.filter(A=>N.has(A))}d=Array.from(new Set(d)),f.organizationIds=d;let h={};d.forEach(N=>{h[N]=this.crossOrgSeenTimestamps[N]??this.getStartAtTimestamp()}),f.orgTimestamps=h}return f}dedupeIncludeOrgs(t,i){let e=new Set;return t.filter(o=>o==null||i.has(o)||e.has(o)?!1:(e.add(o),!0))}teardownCrossOrgPerUserListeners(){this.crossOrgGeneration++,this.crossOrgIndexSubscription&&(this.crossOrgIndexSubscription.unsubscribe(),this.crossOrgIndexSubscription=void 0),this.crossOrgOrgSwitchSubscription&&(this.crossOrgOrgSwitchSubscription.unsubscribe(),this.crossOrgOrgSwitchSubscription=void 0),this.crossOrgFetchTimer&&(clearTimeout(this.crossOrgFetchTimer),this.crossOrgFetchTimer=void 0),this.crossOrgFetchPending=!1,this.clearCrossOrgStragglerRetry()}teardownCrossOrgUserWatcher(){this.teardownCrossOrgPerUserListeners(),this.crossOrgUserSubscription&&(this.crossOrgUserSubscription.unsubscribe(),this.crossOrgUserSubscription=void 0)}resetCrossOrgDeltaState(){this.crossOrgIndexOrgs=[],this.crossOrgIndexTimestamps={},this.crossOrgSeenTimestamps={},this.crossOrgInitialFetchDone=!1}resetCrossOrgForUser(){this.teardownCrossOrgPerUserListeners(),this.resetCrossOrgDeltaState(),this.crossOrgNotifications$.getValue().length&&this.crossOrgNotifications$.next([])}teardownCrossOrg(){this.teardownCrossOrgUserWatcher(),this.resetCrossOrgDeltaState(),this.crossOrgNotifications$.next([])}markCrossOrgEntriesRead(t){try{let i=this.crossOrgNotifications$.getValue();if(!i?.length)return;let e=new Set((t||[]).map(s=>s?.id??s?.notificationId).filter(s=>s!=null));if(!e.size)return;let o=!this.getReadNotificationsOnForYouTab(),r=!1,a=o?i.filter(s=>{let c=s?.id??s?.notificationId,n=c!=null&&e.has(c);return n&&(r=!0),!n}):i.map(s=>{let c=s?.id??s?.notificationId;return c!=null&&e.has(c)&&s?.isUnread!==!1?(r=!0,U(I({},s),{isUnread:!1})):s});r&&this.crossOrgNotifications$.next(a)}catch(i){this.loggingService.catch("Error in NotificationService markCrossOrgEntriesRead: ",i)}}subscribeNotificationsData(t,i){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeViewsData","color: green;");let e,o;try{if(t&&(o=ct(t)),i&&typeof i=="object"){let r=Mt(i);e=ct(JSON.stringify(r))}}catch(r){this.loggingService.catch("Error in ViewsService subscribeViewsData: ",r)}return this.authService.getAuthState$().pipe(P(r=>!!r),y(r=>this.isFeatureAllowed({firebaseUser:r})),y(r=>r.featureAllowed?this.iamService.isUserAllowed$().pipe(p(a=>(r.featureAllowed=a,r))):C(r)),y(r=>!r.featureAllowed||r?.user?.organizationId?(this.notifications$.next([]),this.rawNotificationsByIdMap$.next(new Map),this.processedNotifications$.next([]),this.notificationsByIdMap$.next(new Map),this.notificationViews$.next({}),this.setNotificationsByIdMap(),C([])):C(r).pipe(y(a=>this.docService.getDocumentPaths$().pipe(p(s=>(this.documentPaths=s,a.documentPaths=s,a)))),y(a=>this.getDataFromDocumentId(o)))))}isFeatureAllowed(t){return this.configService.getConfig$().pipe(P(i=>!!i),p(i=>U(I({},t),{config:i})),y(i=>this.authService.getUser$().pipe(p(e=>U(I({},i),{user:e})))),y(i=>Rt(i.config,i.user,Tt.NOTIFICATION)?C(U(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Notification feature is not allowed."),C(U(I({},i),{featureAllowed:!1})))))}getDataFromDocumentId(t){return this.databaseService.getDb().pipe(P(i=>!!i),y(i=>{if(this.db=i,this.loggingService.log(this.db),this.configService?.getApiKey()&&this.documentPaths?.views){let e=`${this.configService.getApiKey()}`;this.documentPaths?.organizationId&&(e+=`/${R.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}`);let o=this.realtimeAdapter.rtdbRef(this.db,`${t?e+"/"+R.FIREBASE_PARTIAL_PATH_DOCS+"/"+t+"/"+R.FIREBASE_PARTIAL_PATH_VIEWS+"/":this.documentPaths?.notifications}`);return this.realtimeAdapter.rtdbObjectVal$("notification",o).pipe(j(r=>(this.loggingService.catch("Error in NotificationService getDataFromDocumentId: ",r),C(null))),p(r=>{let a=[],s=new Map;r?.raw&&(Object.keys(r?.raw||{}).forEach(n=>{let g=r?.raw[n];g?.id&&a.push(g)}),a.forEach(n=>{n.id&&s.set(n.id,n)})),this.notifications$.next(a),this.rawNotificationsByIdMap$.next(s);let c=[];r?.processed&&Object.keys(r?.processed||{}).forEach(n=>{let g=r?.processed[n];g?.id&&c.push(g)}),this.processedNotifications$.next(c),this.setNotificationsByIdMap()}))}else return C(null)}))}setNotificationsByIdMap(){try{let t=this.authService.getUser();if(t){let i=this.notificationViews$.getValue(),e;t?.email&&(e=F(t?.email));let o;t?.userId&&(o=F(t?.userId));let r=new Map;this.processedNotifications$.getValue().forEach(s=>{if(s.id&&s?.displayHeadlineMessageTemplate){let c=!1;(e&&s.notifyUsers?.[e]||o&&s.notifyUsers?.[o])&&(c=!0);let n={id:s.id,notificationSource:s.notificationSource,actionType:s.actionType,actionUser:s.actionUser,timestamp:s.timestamp,targetAnnotationId:s.targetAnnotationId,displayHeadlineMessage:this.getNotificationHeadlineMessage(s),displayBodyMessage:this.getNotificationBodyMessage(s),forYou:c,notificationSourceData:s.notificationSourceData},g=this.getRawNotificationById(n.id);if(g?.metadata&&(n.metadata={apiKey:g.metadata.apiKey,organizationId:g.metadata.organizationId,clientOrganizationId:g.metadata.clientOrganizationId,documentId:g.metadata.documentId,clientDocumentId:g.metadata.clientDocumentId,location:g?.location,locationId:g?.locationId}),n?.notificationSource==="comment"&&n?.targetAnnotationId){let l=this.commentService?.getAnnotationById(n.targetAnnotationId);l||g?.annotationData&&(l=g.annotationData),l&&(n.notificationSourceData=this.commentService?.getCommentAnnotationForClient(l))}r.set(s.id,n)}}),r.forEach((s,c)=>{s.isUnread=s?.actionUser?.userSnippylyId!==t?.userSnippylyId&&!i?.notification?.[c]?.views?.[t?.userSnippylyId],r.set(c,s)}),this.notificationsByIdMap$.next(r)}}catch(t){this.loggingService.catch("Error in NotificationService setNotificationsByIdMap: ",t)}}getClientNotificationObject({processed:t,raw:i,metadata:e,views:o,notification:r}){try{let a=this.authService.getUser(),s=r||t;if(s.id&&s?.displayHeadlineMessageTemplate&&a){let c=null;a?.email&&(c=F(a?.email));let n=null;a?.userId&&(n=F(a?.userId));let g=!1,l=!0;(c&&s.notifyUsers?.[c]||n&&s.notifyUsersByUserId?.[n])&&(g=!0),n&&o?.[n]&&(l=!1);let f={id:s.id};if(r?f=U(I(I({},f),r),{displayHeadlineMessage:this.getNotificationHeadlineMessage(r),displayBodyMessage:this.getNotificationBodyMessage(r),forYou:g,isUnread:l}):f={id:t.id,notificationSource:t.notificationSource,actionType:t.actionType,actionUser:t.actionUser,timestamp:t.timestamp,targetAnnotationId:t.targetAnnotationId,displayHeadlineMessage:this.getNotificationHeadlineMessage(t),displayBodyMessage:this.getNotificationBodyMessage(t),forYou:g,isUnread:l,metadata:e},f?.notificationSource==="comment"&&f?.targetAnnotationId){let d=this.commentService?.getAnnotationById(f.targetAnnotationId);d||r?.notificationSourceData&&(d=r?.notificationSourceData),d||i?.annotationData&&(d=i.annotationData),d&&(f.notificationSourceData=this.commentService?.getCommentAnnotationForClient(d))}return i?.targetAnnotationData?.isCommentResolverUsed&&(f.isCommentResolverUsed=i?.targetAnnotationData?.isCommentResolverUsed),r?.isNotificationResolverUsed&&(f.isNotificationResolverUsed=r.isNotificationResolverUsed),f}return}catch(a){this.loggingService.catch("Error in NotificationService getClientNotificationObject: ",a);return}}getNotificationsForYou$(){return this.notificationsForYou$.asObservable()}getNotificationsByDocumentId$(){return this.notificationsByDocumentIdMap$.asObservable().pipe(p(t=>t?Object.keys(t??{}).map(i=>{let e=t[i].notifications||[],o=e.filter(a=>a.isUnread).length,r=e.length>0&&e[0]?.timestamp||0;return{documentId:i,notifications:t[i]?.notifications,unreadNotificationsCount:o,latestNotificationTimestamp:r,documentMetadata:t[i]?.documentMetadata}}).filter(i=>i.notifications?.length>0).sort((i,e)=>e.latestNotificationTimestamp-i.latestNotificationTimestamp):null))}getAllNotifications$(){return H([this.getNotificationsByDocumentId$(),this.crossOrgNotifications$.asObservable(),this.getUserScopedAllTabRows$()]).pipe(p(([t,i,e])=>{let o=Array.isArray(i)?i:[],r=Array.isArray(e)?e:[],a=null;if(t&&(a=[],t.forEach(c=>{c.notifications.forEach(n=>{a?.push(n)})})),!o.length&&!r.length)return t?a.sort((c,n)=>n.timestamp-c.timestamp):null;if(!t)return null;let s=a||[];return r.length&&(s=this.mergeCrossOrgForYou(s,r)),o.length&&(s=this.mergeCrossOrgForYou(s,o)),s}))}getUserScopedAllTabRows$(){return H([this.userScopedNotifications$,this.userNotificationsFromServer$.asObservable()]).pipe(p(([t,i])=>!t?.enabled||!i?.length?[]:i.map(e=>e?.notification??this.getClientNotificationObject(e)).filter(e=>!!e)))}processNotificationData(t){try{let i=t?.annotationData?.metadata,e=this.docService.getOrganizationConfig()?.organizationId;t.metadata=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata(i?.documentId)||{})),t.metadata||(t.metadata={},this.loggingService.catch("Warning in NotificationService updateNotificationDatabase: ","Document metadata not found")),delete t.metadata.locations,t.metadata.documentMetadata=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata(i?.documentId)||{})),t?.metadata?.documentMetadata?.clientDocumentId&&t?.metadata?.documentMetadata?.documentId&&(t.metadata.documentMetadata.documentId=t?.metadata?.documentMetadata?.clientDocumentId),delete t.metadata.documentMetadata.locations,t.metadata.organizationMetadata=JSON.parse(JSON.stringify(e?this.docService.getOrganizationMetadata(e)||{}:{})),t?.metadata?.organizationMetadata?.clientOrganizationId&&t?.metadata?.organizationMetadata?.organizationId&&(t.metadata.organizationMetadata.organizationId=t?.metadata?.organizationMetadata?.clientOrganizationId);let o=this.configService.getApiKey();t.metadata.apiKey=o,t.platform=this.configService.getSF()?"sf":"sdk",t.actionUser=this.authService.getUser();let r=i?.documentId?new mt({apiKey:o,documentId:i.documentId,organizationId:i?.organizationId}):this.docService.getDocumentPaths();t?.actionUser?.organizationId&&(t.metadata.organizationId=r?.organizationId||t.actionUser.organizationId,t.metadata.clientOrganizationId=r?.clientOrganizationId||t.actionUser.clientOrganizationId);let a=this.docService.getLocation();a&&(t.location=a?.location,t.locationId=a?.locationId),this.loggingService.log(`[NOTIFICATION] ${t?.notificationSource} ${t?.actionType}`,t);let s=this.commonDbService.getServerTimestamp(),c=this.notificationUtilsService.formatNotification(t,s);return JSON.parse(JSON.stringify(c))}catch(i){return this.loggingService.catch("Error in NotificationService processNotificationData: ",i),null}}reportDroppedHubPush(t){try{if(!this.notificationsHubDisabled)return;let i=String(t?.notificationSource??"comment");if(this.isCarriedByPortableDeleteOp(t)||this.reportedDroppedHubPushes.has(i))return;this.reportedDroppedHubPushes.add(i),this.loggingService.catch(`Velt [self-hosted]: a client-side notification-hub push (source '${i}') was dropped \u2014 the notifications hub is deliberately disabled on this deployment (no-egress). Whatever this push fed (in-app notification, email, or webhook fan-out) will not happen for this source.`,void 0,void 0,!0)}catch{}}isCarriedByPortableDeleteOp(t){try{return t?.notificationSource==="comment"&&t?.actionType===Ct.DELETED&&!t?.annotationData?.isDraft&&!!this.adapterSelectorService?.isPortableBackendActive()}catch{return!1}}updateNotificationDatabase(t){try{if(!this.notificationsDb){this.reportDroppedHubPush(t);return}let i=this.realtimeAdapter.rtdbRef(this.notificationsDb),e=this.processNotificationData(t);try{ei(t,e)}catch(o){this.loggingService.catch("Error applying notification visibility in updateNotificationDatabase: ",o)}this.realtimeAdapter.rtdbPush("notificationIndex",i,JSON.parse(JSON.stringify(e)))}catch(i){this.loggingService.catch("Error in NotificationService updateNotificationDatabase: ",i)}}getRawNotifications$(){return this.notifications$.asObservable()}getProcessedNotifications$(){return this.processedNotifications$.asObservable()}getNotifications$(t){return this.authService.getUser$().pipe(y(i=>i?i.organizationId?this.getAllNotifications$().pipe(y(e=>this.notificationsForYou$.pipe(p(o=>{if(e||o){let r=new Map;return(!t?.type||["all","documents"].includes(t.type))&&(e||[]).forEach(a=>{a.id&&r.set(a.id,a)}),(!t?.type||["all","forYou"].includes(t.type))&&(o||[]).forEach(a=>{a.id&&!r.has(a.id)&&r.set(a.id,a)}),Array.from(r.values()).sort((a,s)=>(s.timestamp||0)-(a.timestamp||0))}else return null})))):this.notificationsByIdMap$.asObservable().pipe(p(e=>Array.from(e.values())),p(e=>e.sort((o,r)=>r.timestamp-o.timestamp)),Nt()):C(null)),k(Bt))}getRawNotificationById(t){try{return this.rawNotificationsByIdMap$.getValue()?.get(t)}catch(i){this.loggingService.catch("Error in NotificationService getRawNotificationById: ",i);return}}setNotificationViews(t){try{this.notificationViews$.next(t),this.setNotificationsByIdMap()}catch(i){this.loggingService.catch("Error in NotificationService setNotificationViews: ",i)}}getNotificationHeadlineMessage(t){try{let i=this.authService.getUser();if(t?.displayHeadlineMessageTemplate&&t?.displayHeadlineMessageTemplateData){let e=t.displayHeadlineMessageTemplate,o=t.displayHeadlineMessageTemplateData,r=/\{(\w+)\}/g,a=e.replace(r,(s,c)=>(c==="actionUser"||c==="recipientUser")&&o[c]?i?.email&&o[c].email===i?.email||i?.userId&&o[c]?.userId===i?.userId?"You":o[c].name||o[c].email||' <velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader> ':o[c]?o[c]:s);return this.domService.sanitizeHtml(a)}return this.domService.sanitizeHtml(t.displayHeadlineMessageTemplate||"")}catch(i){return this.loggingService.catch("Error in NotificationService getNotificationHeadlineMessage: ",i),""}}getNotificationBodyMessage(t){try{if(t?.displayBodyMessageTemplate&&t?.displayBodyMessageTemplateData){let i=t?.displayBodyMessageTemplate;return t?.displayBodyMessageTemplateData&&t?.displayBodyMessageTemplateData?.users?.forEach(e=>{if(e?.userId){let o=this.usersService.getUserById(e?.userId);i=i?.replaceAll(`{{${e.userId}}}`,o?.name||o?.email||'<velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader>'),i=i?.replaceAll(`@User ${e.userId}`,o?.name||o?.email||'<velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader>')}}),this.domService.sanitizeHtml(i)}return this.domService.sanitizeHtml(t.displayBodyMessage||"")}catch(i){return this.loggingService.catch("Error in NotificationService getNotificationBodyMessage: ",i),""}}setHistoryPanelVisibility(t,i=!1,e=!1){try{t?document.querySelector(R.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL)?this.historyPanelVisible$.next(t):this.loggingService.catch("Error in NotificationService setHistoryPanelVisibility: ",`<${R.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`):this.historyPanelVisible$.next(t),t?this.analyticsService.trackEvent(_.Events.Notifications.NOTIFICATION_HISTORY_PANEL_OPENED):this.analyticsService.trackEvent(_.Events.Notifications.NOTIFICATION_HISTORY_PANEL_CLOSED)}catch{this.loggingService.catch("Error in NotificationService setHistoryPanelVisibility: ",`<${R.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}}toggleHistoryPanelVisibility(t=!1,i=!1){try{this.historyPanelVisible$.value?this.historyPanelVisible$.next(!this.historyPanelVisible$.value):document.querySelector(R.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL)?(this.historyPanelVisible$.next(!this.historyPanelVisible$.value),this.historyPanelVisible$.value?this.analyticsService.trackEvent(_.Events.Notifications.NOTIFICATION_HISTORY_PANEL_TOGGLED,{action:"closed"}):this.analyticsService.trackEvent(_.Events.Notifications.NOTIFICATION_HISTORY_PANEL_TOGGLED,{action:"opened"})):this.loggingService.catch("Error in NotificationService toggleHistoryPanelVisibility: ",`<${R.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}catch{this.loggingService.catch("Error in NotificationService toggleHistoryPanelVisibility: ",`<${R.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}}getHistoryPanelVisibility$(){return this.historyPanelVisible$.asObservable()}setNotificationsAsRead(t){return D(this,null,function*(){try{let i=JSON.parse(JSON.stringify(this.getUserNotificationsFromServer()??[]));if(t?.length){for(let a=0;a<t.length;a+=50){let c=t.slice(a,a+50).filter(l=>l?.id),n=c.map(l=>this.setNotificationAsRead({notification:l,userNotifications:JSON.parse(JSON.stringify(i))})),g=yield Promise.all(n);c.forEach((l,f)=>{let d=g[f];if(!d.some(N=>N.notificationId===l.id))i=i.filter(N=>N.notificationId!==l.id);else{let N=i.find($=>$.notificationId===l.id),A=d.find($=>$.notificationId===l.id);N&&A?.views&&(N.views=A.views)}})}let o=JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue()||{}));t.forEach(a=>{let s=a.metadata?.documentId;if(s&&o?.[s]){let c=o?.[s]?.notifications||[],n=c.find(g=>g.id===a.id);n&&(n.isUnread=!1),o[s].notifications=c}}),this.notificationsByDocumentIdMap$.next(o),this.markCrossOrgEntriesRead(t),!K(i,this.getUserNotificationsFromServer())&&this.setUserNotificationsFromServer(i)}}catch(i){this.loggingService.catch("Error in NotificationService setNotificationsAsRead: ",i)}})}setAllNotificationsAsRead(t){return D(this,null,function*(){try{if(t?.tabId==="for-you"){let i=this.notificationsForYou$.value||[];this.setNotificationsAsRead(i)}else this.getNotifications$().pipe(Y(1)).subscribe(i=>{i&&this.setNotificationsAsRead(i)})}catch(i){this.loggingService.catch("Error in NotificationService setAllNotificationsAsRead: ",i)}})}getUnreadNotificationsCount$(){try{return this.notificationsForYou$.pipe(p(t=>t?.filter(e=>e?.isUnread)?.length??null),y(t=>this.getNotifications$().pipe(p(i=>{let e=i?.filter(o=>o?.isUnread)?.length??null;return{forYou:t,all:e}}))))}catch(t){return this.loggingService.catch("Error in NotificationService getUnreadNotificationsCount$: ",t),C({forYou:null,all:null})}}setNotificationAsRead(e){return D(this,arguments,function*({notification:t,userNotifications:i}){try{let o=this.authService.getUser();if(o&&t?.id){let r=F(o?.userId),{metadata:a}=t;if(a){let{apiKey:s,organizationId:c,documentId:n}=a;if(s&&c&&n&&r){let g=yield this.commonDbService.getData({feature:"docNotification",properties:{id:t.id,organizationId:c,documentId:n,apiKey:s}});g?.notificationId&&(g?.views?.[r]||(g.views||(g.views={}),g.views[r]={timestamp:Date.now()},this.commonDbService.updateData({feature:"docNotificationViews",properties:{id:t.id,organizationId:c,documentId:n,apiKey:s},data:g})));let l=yield this.commonDbService.getData({feature:"userNotification",properties:{id:t.id,userId:r,documentId:n,organizationId:c}});if(l?.notificationId){if(!this.getReadNotificationsOnForYouTab())yield this.commonDbService.deleteData({feature:"userNotification",properties:{id:t.id,userId:r,documentId:n,organizationId:c}}),i=i.filter(f=>f.notificationId!==t.id);else if(!l?.views?.[r]){l.views||(l.views={}),l.views[r]={timestamp:Date.now()};let f=i.find(d=>d.notificationId===t.id);f&&(f.views=l.views),this.commonDbService.updateData({feature:"userNotificationViews",properties:{id:t.id,userId:r,documentId:n,organizationId:c},data:l})}}}}}return i}catch(o){return this.loggingService.catch("Error in NotificationService setNotificationAsRead: ",o),i}})}setMaxDays(t){try{t>0?this.maxNotificationDays$.next(t):this.maxNotificationDays$.next(15)}catch(i){this.loggingService.catch("Error in NotificationService setMaxDays: ",i)}}setTabConfig(t){try{t&&this.tabConfig$.next(t)}catch(i){this.loggingService.catch("Error in NotificationService setTabConfig: ",i)}}getTabConfig$(){return this.tabConfig$.asObservable()}getTabConfig(){return this.tabConfig$.value}enableReadNotificationsOnForYouTab(){this.readNotificationsOnForYouTab$.next(!0)}disableReadNotificationsOnForYouTab(){this.readNotificationsOnForYouTab$.next(!1)}getReadNotificationsOnForYouTab$(){return this.readNotificationsOnForYouTab$.asObservable()}getReadNotificationsOnForYouTab(){return this.readNotificationsOnForYouTab$.value}enableCurrentDocumentOnly(){try{if(this.currentDocumentOnly$.value===!0)return;this.currentDocumentOnly$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService enableCurrentDocumentOnly: ",t)}}disableCurrentDocumentOnly(){try{if(this.currentDocumentOnly$.value===!1)return;this.currentDocumentOnly$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService disableCurrentDocumentOnly: ",t)}}getCurrentDocumentOnly$(){return this.currentDocumentOnly$.asObservable()}getCurrentDocumentOnly(){return this.currentDocumentOnly$.value}markNotificationAsReadById(t){return D(this,null,function*(){try{this.getNotifications$().pipe(Y(1)).subscribe(i=>{if(i){let e=i.filter(o=>o.id===t);this.setNotificationsAsRead(e)}})}catch(i){this.loggingService.catch("Error in NotificationService markNotificationAsReadById: ",i)}})}getOwnDocumentMetadata(t){try{let i=t==null||t===""?null:this.docService.getDocumentMetadata(String(t));return i?JSON.parse(JSON.stringify(i)):null}catch(i){return this.loggingService.catch("Error in NotificationService getOwnDocumentMetadata: ",i),null}}getAllowedDocumentMetadataByDocumentId(t){try{return this.allowedDocumentMetadataMap$.value?.[t]||null}catch(i){return this.loggingService.catch("Error in NotificationService getAllowedDocumentMetadataByDocumentId: ",i),null}}setSettingsConfig(t){try{this.enableSettings$.value&&this.settingsConfig$.next(t)}catch(i){this.loggingService.catch("Error in NotificationService setSettingsConfig: ",i)}}setSettingsConfigWithDB(t){try{this.enableSettings$.value&&(this.settingsConfig$.next(t),this.updateSettingsConfigToDb())}catch(i){this.loggingService.catch("Error in NotificationService setSettingsConfigWithDB: ",i)}}getSettingsConfig$(){return this.settingsConfig$.asObservable()}getSettingsConfig(){return this.settingsConfig$.value}setMuteAllNotifications(){try{this.muteAllNotifications$.value!==!0&&this.muteAllNotifications$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService setSettingsMuteAll: ",t)}}getMuteAllNotifications$(){return this.muteAllNotifications$.asObservable()}getMuteAllNotifications(){return this.muteAllNotifications$.value}enableSettings(){try{this.enableSettings$.value!==!0&&this.enableSettings$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService enableSettings: ",t)}}enableSettingsConfigByOrganization(){try{this.getSettingsConfigByOrganization()!==!0&&this.setSettingsConfigByOrganization$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService enableSettingsConfigByOrganization: ",t)}}disableSettingsConfigByOrganization(){try{this.getSettingsConfigByOrganization()!==!1&&this.setSettingsConfigByOrganization$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService disableSettingsConfigByOrganization: ",t)}}getSettingsConfigByOrganization$(){return this.setSettingsConfigByOrganization$.asObservable()}getSettingsConfigByOrganization(){return this.setSettingsConfigByOrganization$.value}enableSelfNotifications(){try{this.selfNotifications$.value!==!0&&this.selfNotifications$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService enableSelfNotifications: ",t)}}disableSelfNotifications(){try{this.selfNotifications$.value!==!1&&this.selfNotifications$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService disableSelfNotifications: ",t)}}enableUserScopedNotifications(t){try{if(t&&typeof t=="object"&&t.enabled===!1){this.disableUserScopedNotifications();return}this.userScopedNotifications$.next({enabled:!0,limit:di(t?.limit)})}catch(i){this.loggingService.catch("Error in NotificationService enableUserScopedNotifications: ",i)}}disableUserScopedNotifications(){try{this.userScopedNotifications$.value.enabled!==!1&&this.userScopedNotifications$.next({enabled:!1,limit:this.userScopedNotifications$.value.limit})}catch(t){this.loggingService.catch("Error in NotificationService disableUserScopedNotifications: ",t)}}disableSettings(){try{this.enableSettings$.value!==!1&&this.enableSettings$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService disableSettings: ",t)}}getEnableSettings$(){return this.enableSettings$.asObservable()}getEnableSettings(){return this.enableSettings$.value}setSettingsInitialConfig(t){try{let i=!1;if(t.forEach(e=>{["email","inbox"].includes(e.id)&&(i=!e.values?.every(o=>["ALL","NONE","MINE"].includes(o.id)))}),i){this.loggingService.catch("Invalid config values for email or inbox, It should have only ALL, NONE, MINE values");return}this.settingsInitialConfig$.next(t)}catch(i){this.loggingService.catch("Error in NotificationService setSettingsInitialConfig: ",i)}}getSettingsInitialConfig$(){return this.settingsInitialConfig$.asObservable()}getSettingsInitialConfig(){return this.settingsInitialConfig$.value}updateSettingsConfigToDb(t){return D(this,null,function*(){try{let i=this.authService.getUser(),e=F(i?.userId??""),o=this.docService.getDocumentPaths(),r=this.docService.getOrganizationConfig(),a=o?.organizationId??r?.organizationId,s=o?.clientOrganizationId??r?.clientOrganizationId,c={apiKey:this.configService.getApiKey(),organizationId:a,documentId:o?.documentId,clientOrganizationId:s,clientDocumentId:o?.clientDocumentId,userId:e,clientUserId:this.authService.getUser()?.userId};e&&this.getEnableSettings()&&this.enableSettings$.value&&(this.getSettingsConfigByOrganization()?this.docService.addUserInfoToOrganization({organizationId:s??i?.clientOrganizationId??"",user:{userId:i?.userId??""},notificationsConfig:t||this.settingsConfig$.getValue()}):o?.documentId&&(yield this.commonDbService.updateData({feature:"userConfig",properties:{documentId:o?.documentId,userId:e},data:{id:o?.documentId,notificationsConfig:t||this.settingsConfig$.getValue(),metadata:c}})))}catch(i){this.loggingService.catch("Error in NotificationService updateSettingsConfigToDb: ",i)}})}openNotificationsPanel(){try{this.notificationsPanelVisible$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService openNotificationsPanel: ",t)}}closeNotificationsPanel(){try{this.notificationsPanelVisible$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService closeNotificationsPanel: ",t)}}getNotificationsPanelVisible$(){return this.notificationsPanelVisible$.asObservable()}getNotificationsPanelVisible(){return this.notificationsPanelVisible$.value}};u.\u0275fac=function(i){return new(i||u)(m(yt),m(Yt),m(tt),m(kt),m(si),m(ri),m(ot),m(et),m(rt),m(Qt),m(ni),m(ii),m(ai),m(Z),m(li),m(it),m(Dt),m(ci),m(ti),m(q),m(qt),m(Zt))},u.\u0275prov=G({token:u,factory:u.\u0275fac,providedIn:"root"});let S=u;return S})();export{li as a,ae as b};