@veltdev/sdk 6.0.25 → 6.0.26

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.
package/velt-tag.js CHANGED
@@ -1 +1 @@
1
- import{b as we}from"./chunk-IXIU5ZJS.js";import"./chunk-AP33ZJ2C.js";import{b as ye,t as Ie}from"./chunk-Z7JR4TW6.js";import"./chunk-ZH5R4MP6.js";import"./chunk-B3ZPP3EZ.js";import{b as Xt,c as Kt,d as Jt}from"./chunk-BJ5O5D7F.js";import"./chunk-2JSXDPYO.js";import"./chunk-GB46XS3O.js";import"./chunk-TN7X7OZD.js";import{b as be}from"./chunk-NNZNLREA.js";import{b as Ce,d as Ee}from"./chunk-G3BZ4EU4.js";import{a as Ae}from"./chunk-CCZ3WXF4.js";import{a as ie}from"./chunk-LCACRBV3.js";import{A as Zt,Fa as Pe,G as te,H as ee,I as ne,r as Qt,t as qt,za as re}from"./chunk-NY2Q7SEG.js";import{a as Oe}from"./chunk-MEI3IAPO.js";import{C as Se,D as _e}from"./chunk-BR7AO7YV.js";import{Bb as h,Cb as Ft,Db as Ht,E as D,Fb as Z,Gb as tt,Gc as Wt,Gd as oe,Gi as b,Ha as v,Hb as et,He as d,Ia as at,Ic as H,Ig as lt,Ji as he,K as $,Kb as N,Lb as Vt,Lf as _t,Mb as st,Nc as zt,Nj as fe,Oa as Dt,Pb as Q,Qb as Tt,Ra as m,Rb as St,Rc as Yt,Rh as pe,Sb as Ut,Sg as Ct,Sh as me,V as C,Va as Mt,Wa as k,Xa as kt,Yj as Te,Zf as Pt,_g as bt,a as G,ab as O,b as K,ba as rt,bk as L,ca as wt,cc as jt,ck as U,db as Bt,ea as f,ec as Gt,fb as M,fh as ge,g as ot,ja as T,je as ct,ka as S,l as J,la as W,mc as R,mj as ue,na as xt,nb as u,nc as F,nj as B,ob as _,oj as p,pb as P,pj as ve,qb as z,r as E,rc as nt,re as V,rf as ae,rh as de,tg as se,ub as Lt,ug as ce,v as I,vb as Nt,wb as ft,xb as x,xg as le,yb as Rt,zb as A,zc as $t}from"./chunk-CNB6D3KX.js";var w=(()=>{let r=class r{constructor(t,e,n,i,l,s,c,y,X,Me,ke,Be,Le,Ne,Re){this.analyticsService=t,this.configService=e,this.docService=n,this.databaseService=i,this.authService=l,this.domService=s,this.afAuth=c,this.iamService=y,this.avatarService=X,this.contactService=Me,this.storageService=ke,this.dialog=Be,this.loggingService=Le,this.serviceBook=Ne,this.commonDbService=Re,this.tagAnnotations$=new J({}),this.tagAnnotationsByDocumentId$=new J({}),this.documentPaths=null,this.allowedElementIds$=new J([]),this.addTagMode$=new J(!1),this.enableTextTags$=new J(!1),this.notificationService=null,this.loggingService.log("%c[WB] Creating CLASS: TagService","color: blue;"),this.serviceBook.observe(he).subscribe(g=>{this.notificationService=g}),this.databaseService.getDb().pipe(D(g=>!!g),$(1)).subscribe(g=>{g&&this.getDocumentPaths()},g=>{this.loggingService.catch("Error in TagService getDb subscription: ",g)}),this.domService.onWindowPointerMove$().subscribe(g=>{if(this.addTagMode$.value){this.hightlightElement&&this.domService.removeHighlightFromElement(this.hightlightElement);let j=this.domService.getBackgroundElement(g.clientX,g.clientY);j&&(this.isElementInsideAllowedElements(j)?bt(g.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.hightlightElement=j,this.domService.highlightElement(this.hightlightElement,d.CURSOR.TAG_PIN)):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},g=>{this.loggingService.catch("Error in TagService onWindowPointerMove$ subscription: ",g)}),this.domService.onWindowKeyupEsc$().subscribe(g=>{this.addTagMode$.value&&this.disableAddTagMode()},g=>{this.loggingService.catch("Error in TagService onWindowKeyupEsc$ subscription: ",g)}),this.domService.onDocumentClick$().subscribe(g=>{if(g&&this.addTagMode$.value){if(g.preventDefault(),g.stopPropagation(),!bt(g.target)){let j=this.domService.getBackgroundElement(g.clientX,g.clientY);j&&this.isElementInsideAllowedElements(j)&&this.addTag(g)}this.disableAddTagMode()}},g=>{this.loggingService.catch("Error in TagService onDocumentClick$ subscription: ",g)}),this.addTagMode$.subscribe(g=>{this.hightlightElement&&this.domService.removeHighlightFromElement(this.hightlightElement),g?this.domService.addClassToElement(document.body,"snippyly-add-tag-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-tag-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},g=>{this.loggingService.catch("Error in TagService addTagMode$ subscription: ",g)}),this.domService.onWindowKeyupBackspace$().subscribe(g=>{this.deleteTagPinAnnotations("keyupBackspace")},g=>{this.loggingService.catch("Error in TagService onWindowKeyupBackspace$ subscription: ",g)}),this.domService.onWindowKeyupDelete$().subscribe(g=>{this.deleteTagPinAnnotations("keyupDelete")},g=>{this.loggingService.catch("Error in TagService onWindowKeyupDelete$ subscription: ",g)}),this.domService.getDeleteCommmentAnnotations$().subscribe(g=>{g?.length&&(g?.filter(vt=>vt.type==="tag")).forEach(vt=>ot(this,null,function*(){yield this.deleteTagPinAnnotation(vt)}))},g=>{this.loggingService.catch("Error in TagService onWindowKeyupDelete$ subscription: ",g)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}getAnonymousAvatarImage(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAnonymousAvatarImage","color: green;"),this.avatarService.generateUserImage()}setAllowedElementIds(t){this.allowedElementIds$.next(t||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getAllTagAnnotations(t,e,n){this.loggingService.log("%c[WB] Calling FUNCTION: getAllTagAnnotations","color: green;");let i,l;try{if(t&&(l=Pt(t)),e&&typeof e=="object"){let s=le(e);i=Pt(JSON.stringify(s))}}catch(s){this.loggingService.catch("Error in TagService getAllTagAnnotations: ",s)}return this.authService.getAuthState$().pipe(D(s=>!!s),C(s=>this.isFeatureAllowed({firebaseUser:s,annotations:[],filteredAnnotations:[]})),C(s=>s.featureAllowed?this.iamService.isUserAllowed$().pipe(I(c=>(s.featureAllowed=c,s))):E(s)),C(s=>s.featureAllowed?this.authService.isPlanExpired$().pipe(I(c=>(s.featureAllowed=!c,s))):E(s)),C(s=>s.featureAllowed?E(s).pipe(C(c=>this.docService.getDocumentPaths$().pipe(I(y=>(this.documentPaths=y,c.documentPaths=y,c)))),C(c=>this.getDataFromDocumentId(l).pipe(I(y=>(c.annotations=y||[],G({},c))))),C(c=>this.docService.getLocation$().pipe(I(y=>(c.location=y,c)))),C(c=>this.docService.getLocations$().pipe(I(y=>(c.customLocations=y,c)))),I(c=>{if(c.filteredAnnotations=[],l&&!i)return c.filteredAnnotations=c.annotations?.slice(),c;{let y=[];return i?y.push(i):(y.push(c?.location?.locationId),y.push(...Object.values(c?.customLocations||[]).map(X=>X.locationId))),c.filteredAnnotations=this.filterAnnotationsByLocationIds(c?.annotations,y),c}}),C(c=>n?E(c):c?.annotations?.length?this.domService.onWindowResize$().pipe(I(()=>c)):E(c)),C(c=>n?E(c):c?.annotations?.length?this.domService.onDomChange$("TagService getAllTagAnnotations").pipe(I(()=>c)):E(c)),I(c=>(c?.filteredAnnotations?.forEach(y=>{this.calculateTagAnnotationPosition(y)}),c)),C(c=>c?.filteredAnnotations?E(c?.filteredAnnotations||[]):E([]))):E([])))}isFeatureAllowed(t){return this.configService.getConfig$().pipe(D(e=>!!e),I(e=>K(G({},t),{config:e})),C(e=>this.authService.getUser$().pipe(I(n=>K(G({},e),{user:n})))),C(e=>se(e.config,e.user,V.TAG)?E(K(G({},e),{featureAllowed:!0})):(this.loggingService.warn("Tag feature is not allowed."),E(K(G({},e),{featureAllowed:!1})))))}getDataFromDocumentId(t){return this.databaseService.getDb().pipe(D(e=>!!e),C(e=>this.configService?.getApiKey()&&this.documentPaths?.tag?this.commonDbService.dbListener({feature:"allTags",properties:{documentId:t??this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(I(n=>n?.data),I(n=>{let i=[];return n&&(i=Object.values(n).filter(l=>typeof l=="object")),this.setTagAnnotationsByDocumentId(t||this.documentPaths?.documentId,i),i})):E([])))}setTagAnnotationsByDocumentId(t,e){try{t&&this.tagAnnotationsByDocumentId$.next(K(G({},this.tagAnnotationsByDocumentId$.value),{[t]:e}))}catch(n){this.loggingService.catch("Error in TagService setTagAnnotationsByDocumentId:",n)}}filterAnnotationsByLocationIds(t,e){try{return t.filter(n=>e.includes(n.locationId))}catch(n){return this.loggingService.catch("Error in TagService filterAnnotationsByLocations:",n),[]}}calculateTagAnnotationPosition(t){try{if(t.targetElement){let e=this.domService.getXPath(t.targetElement?.xpath);if(e){let n=e.iterateNext();if(n&&lt(n)){let i=n.getBoundingClientRect();if(i&&i.width&&i.height){let{height:l,width:s}=pe(n);t.position={top:l*t.targetElement.topPercentage/100,left:s*t.targetElement.leftPercentage/100}}else t.position=null}else t.position=null}else t.position=null}}catch(e){this.loggingService.catch("Error in TagService calculateTagAnnotationPosition:",e)}}filterPinAnnotations(t,e,n){this.loggingService.log("%c[WB] Calling FUNCTION: filterPinAnnotations","color: green;");try{let i=t?Object.values(t):[];i.forEach((s,c)=>{s?.annotationId&&(s.annotationIndex=c+1)});let l=[];if(e)n?l=i.filter(s=>s.locationId===n):l=i.slice();else{let s=this.docService.getLocation();s&&s.locationId?l=i.filter(c=>c.locationId===s.locationId):l=i.filter(c=>!c.locationId)}return l}catch(i){return this.loggingService.catch("Error in TagService filterPinAnnotations:",i),[]}}addTag(t,e){this.loggingService.log("%c[WB] Calling FUNCTION: addTag","color: green;");try{let n=this.authService.getUser();if(n)if(n.isReadOnly||n.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add tags.");else{let i=new _t;i.from=n,i.color=d.DEFAULT_ANNOTATION_COLOR,i.resolved=!1,i.lastUpdated=this.timestamp;let{topPositionX:l,topPositionY:s}=this.domService.getTopLeftPosition();i.positionX=l,i.positionY=s;let c=this.domService.getCurrentWindowSizeValue();if(i.screenWidth=c.screenWidth,i.screenHeight=c.screenHeight,i.screenScrollHeight=c.screenScrollHeight,i.taggedElementPath="",t&&(i.targetElement=this.domService.getTargetElementForCursorPosition(t)),e&&(i.targetTextRange=e),i?.targetElement?.xpath){let y=this.domService.getXPath(i.targetElement.xpath);if(y){let X=y.iterateNext();X&&(lt(X)||(i.targetElement=null))}}this.setLocationToTagAnnotation(i),i.pageInfo=Ct(),i.pageInfo&&(i.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveTagToDb(i)}}catch(n){this.loggingService.catch("Error in TagService addTag: ",n)}}setLocationToTagAnnotation(t){try{let e=this.docService.getLocation();e?(t.locationId=e.locationId,t.location=e.location):(delete t.locationId,delete t.location);try{let n;t.targetElement?.xpath?n=this.domService.getElementFromXPath(t.targetElement.xpath):t.targetTextRange?.commonAncestorContainer&&(n=this.domService.getElementFromXPath(t.targetTextRange.commonAncestorContainer));let i=this.docService.getAdditionLocationFromElement(n);if(i){let l=this.docService.addLocation({location:i,source:"internal"});l?.[0]&&(t.locationId=l[0].locationId,t.location=l[0].location)}}catch{}}catch(e){this.loggingService.catch("Error in TagService setLocationToTagAnnotation:",e)}}saveTagToDb(t){this.loggingService.log("%c[WB] Calling FUNCTION: saveTagToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(V.TAG)&&this.docService.getDocumentPaths$().pipe(D(e=>!!e),$(1),C(e=>(this.documentPaths=e,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(D(n=>!!n),$(1),C(n=>{if(this.documentPaths?.tag){t.annotationId=this.commonDbService.generateDocumentId(),t.pageInfo&&(t.pageInfo.tagUrl=this.generateTagUrl(t));let i=JSON.parse(JSON.stringify(t));return i.position=null,this.domService.toggleAnnotationSelection(i),t.targetTextRange&&sessionStorage.setItem(d.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,t.annotationId),this.analyticsService.trackEvent(b.Events.Tag.TAG_DRAFT_ADDED,{annotationId:t.annotationId}),this.commonDbService.setData({feature:"tag",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0},data:i})}else return E(null)}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in TagService saveTagToDb subscription: ",e)})}catch(e){this.loggingService.catch("Error in TagService saveTagToDb: ",e)}}updateTag(t,e=!1,n){try{n&&this.setLocationToTagAnnotation(t),e&&this.updateNotificationsDatabase(t,ct.UPDATED),this.updateTagToDb(t)}catch(i){this.loggingService.catch("Error in TagService updateTag: ",i)}}resolveTag(t){try{t.resolved=!0,this.domService.resetSelectedAnnotationsMap(!1),this.updateNotificationsDatabase(t,ct.RESOLVED),this.updateTagToDb(t),this.domService.updateSelectedAnnotationInMap([t]),this.analyticsService.trackEvent(b.Events.Tag.TAG_RESOLVED,{annotationId:t.annotationId})}catch(e){this.loggingService.catch("Error in TagService resolveTag: ",e)}}updateTagToDb(t){this.loggingService.log("%c[WB] Calling FUNCTION: updateTagToDb","color: green;");try{if(t?.targetElement?.xpath){let e=this.domService.getXPath(t.targetElement.xpath);if(e){let n=e.iterateNext();n&&(lt(n)||(t.targetElement=null))}}this.domService.updateSelectedAnnotationInMap([t]),this.authService.getUser()&&this.authService.isFeatureAllowed(V.TAG)&&this.docService.getDocumentPaths$().pipe(D(e=>!!e),$(1),C(e=>(this.documentPaths=e,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(D(n=>!!n),$(1),C(n=>{if(this.documentPaths?.tag&&t?.annotationId){let i=JSON.parse(JSON.stringify(t));return i.position=null,this.commonDbService.setData({feature:"tag",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0},data:i})}else return E(null)}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in TagService updateTagToDb subscription: ",e)})}catch(e){this.loggingService.catch("Error in TagService updateTagToDb: ",e)}}deleteTagPinAnnotations(t){try{let e=this.domService.getSelectedAnnotationsMap(),n=this.authService.getUser(),i=[];Object.keys(e).forEach(l=>ot(this,null,function*(){let s=e[l];s.type==="tag"&&n&&s.from&&(n?.isAdmin||s.from.userId===n.userId)&&i.push(s)})),i?.length&&(this.analyticsService.trackEvent(b.Events.Tag.TAG_DELETE_TRIGGERED,{triggerType:t,annotationId:i.map(l=>l.annotationId).join()}),this.dialog.open(be,{panelClass:"velt-mat-dialog-container",data:{title:"Delete tag?",message:"This selected tag will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"tag"}}).afterClosed().pipe($(1)).subscribe(l=>{l&&(i.forEach(s=>ot(this,null,function*(){yield this.deleteTagPinAnnotation(s)})),setTimeout(()=>{document.querySelectorAll(`[${d.SNIPPYLY_HIGHLIGHT}]`).forEach(c=>{this.domService.removeHighlightFromElement(c)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"tag")}catch(e){this.loggingService.catch("Error in TagService deleteTagPinAnnotations: ",e)}}deleteTagPinAnnotation(t){return this.authService.isFeatureAllowed(V.TAG)&&this.documentPaths?.tag&&t?.annotationId?(this.updateNotificationsDatabase(t,ct.DELETED),this.analyticsService.trackEvent(b.Events.Tag.TAG_DELETED,{annotationId:t.annotationId}),this.commonDbService.deleteData({feature:"tag",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0}})):Promise.resolve()}enableAddTagMode(){this.authService.isFeatureAllowed(V.TAG)?(this.analyticsService.trackEvent(b.Events.Tag.TAG_ADD_MODE_ENABLED),this.addTagMode$.next(!0)):this.loggingService.catch("Error in TagService enableAddTagMode: ","Tag feature is not enabled.")}disableAddTagMode(){this.analyticsService.trackEvent(b.Events.Tag.TAG_ADD_MODE_DISABLED),this.addTagMode$.next(!1)}addTagModeChange(){return this.addTagMode$.asObservable()}enableTextTags(t){this.enableTextTags$.next(t)}getEnableTextTags$(){return this.enableTextTags$.asObservable()}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(t){try{return this.domService.isElementInsideListedElementIds(t,this.allowedElementIds$.value)}catch(e){return this.loggingService.catch("Error in TagService isElementInsideAllowedElements: ",e),!1}}attachTag(t,e=[]){let n=de(t,e);if(n){let i=this.domService.getXPath(n),l=this.getTagPinAnnotationObject();l&&(l.targetElement={xpath:i,topPercentage:50,leftPercentage:90},this.saveTagToDb(l))}}getTagPinAnnotationObject(){let t=this.authService.getUser();if(t)if(t.isReadOnly||t.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add tags.");else{let e=new _t;e.from=t,e.color=d.DEFAULT_ANNOTATION_COLOR,e.resolved=!1,e.lastUpdated=this.timestamp;let{topPositionX:n,topPositionY:i}=this.domService.getTopLeftPosition();e.positionX=n,e.positionY=i;let l=this.domService.getCurrentWindowSizeValue();e.screenWidth=l.screenWidth,e.screenHeight=l.screenHeight,e.screenScrollHeight=l.screenScrollHeight,e.taggedElementPath="";let s=this.docService.getLocation();return s&&(e.locationId=s.locationId,e.location=s.location),e}return null}updateNotificationsDatabase(t,e){try{let n={annotationData:t,actionType:e,notificationSource:"tag"};this.notificationService?.updateNotificationDatabase(n)}catch(n){this.loggingService.catch("Error in TagService updateNotificationsDatabase: ",n)}}getUserContacts$(){return this.contactService.getUserContacts$()}addUserContact(t){this.contactService.addUserContact(t)}getTagUrl(t){try{return t?.pageInfo?.tagUrl?t.pageInfo.tagUrl:(t?.pageInfo||(t.pageInfo=Ct(),t.pageInfo&&(t.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),t.pageInfo.tagUrl=this.generateTagUrl(t),this.updateTag(t),t.pageInfo?.tagUrl)}catch(e){this.loggingService.catch("Error in TagService getTagUrl: ",e);return}}uploadFile(t,e){let n=`${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${d.FIREBASE_PARTIAL_PATH_TAG}/${e.annotationId}`;return this.documentPaths?.organizationId&&(n=`${d.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${d.FIREBASE_PARTIAL_PATH_TAG}/${e.annotationId}`),this.storageService.uploadFile({path:n,file:t})}downloadAttachment(t){this.storageService.downloadAttachment(t)}deleteAttachment(t){return this.storageService.deleteAttachment({attachment:t})}generateTagUrl(t){let e;try{e=new URL(t?.pageInfo?.url||window.location.href)}catch(n){this.loggingService.catch("Error in TagService generateTagUrl: ",n),e=new URL(window.location.href)}return e.searchParams.delete(d.URL_PARAMS.TAG_ID),e.searchParams.append(d.URL_PARAMS.TAG_ID,t.annotationId),e.href}};r.\u0275fac=function(e){return new(e||r)(f(B),f(ve),f(_e),f(fe),f(U),f(L),f(oe),f(Ae),f(Te),f(Pe),f(we),f(re),f(p),f(ue),f(Se))},r.\u0275prov=rt({token:r,factory:r.\u0275fac,providedIn:"root"});let a=r;return a})();var Fe=["customBtnRef"],He=["*"];function Ve(a,r){a&1&&ft(0)}function Ue(a,r){if(a&1&&O(0,Ve,1,0,"ng-container",5),a&2){h();let o=N(5);u("ngTemplateOutlet",o)}}function je(a,r){a&1&&(_(0,"div",8),W(),_(1,"svg",9),z(2,"circle",10)(3,"path",11),P()())}function Ge(a,r){a&1&&ft(0)}function $e(a,r){if(a&1&&(O(0,je,4,0,"div",6),_(1,"div",7,2),O(3,Ge,1,0,"ng-container",5),P()),a&2){let o=h(),t=N(5);u("ngIf",o.showDefaultBtn),v(3),u("ngTemplateOutlet",t)}}function We(a,r){a&1&&Ht(0)}var pt=(()=>{let r=class r{constructor(t,e,n,i,l){this.analyticsService=t,this.authService=e,this.tagService=n,this.loggingService=i,this.cdr=l,this.showDefaultBtn=!1,this.subscriptions=[],this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(s=>{this.user=s},s=>{this.loggingService.catch("Error in TagsToolComponent getUser$ subscription: ",s)}))}ngOnInit(){}ngAfterViewInit(){try{this.customBtnRef?.nativeElement?.children?.length||(this.showDefaultBtn=!0,this.cdr.detectChanges())}catch(t){this.loggingService.catch("Error in TagsToolComponent AfterViewInit: ",t)}}addTag(){this.loggingService.log("%c[WB] Calling FUNCTION: addTag","color: green;");try{this.analyticsService.trackEvent(b.Events.Tag.TAG_TOOL_CLICKED,{toolType:this.customBtnRef?.nativeElement?.children?.length?"custom":"default"}),this.user&&(this.user.isReadOnly||this.user.isAnonymous?this.loggingService.catch("Anonymous/Readonly users cannot add tags."):this.targetTagElementId?this.tagService.attachTag(this.targetTagElementId,["id","data-id"]):this.tagService.enableAddTagMode())}catch(t){this.loggingService.catch("Error in TagsToolComponent addTag: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in TagsToolComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in TagsToolComponent unsubscribe: ",t)}}};r.\u0275fac=function(e){return new(e||r)(m(B),m(U),m(w),m(p),m($t))},r.\u0275cmp=k({type:r,selectors:[["snippyly-tags-tool"]],viewQuery:function(e,n){if(e&1&&Z(Fe,5),e&2){let i;tt(i=et())&&(n.customBtnRef=i.first)}},hostVars:1,hostBindings:function(e,n){e&2&&M("data-velt-element",n.veltElement)},inputs:{targetTagElementId:"targetTagElementId"},standalone:!1,ngContentSelectors:He,decls:6,vars:2,consts:[["tagToolBtn",""],["content",""],["customBtnRef",""],[1,"snippyly-tag-btn-container",3,"click"],[3,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],["class","action-btn",4,"ngIf"],[1,"custom-btn-container"],[1,"action-btn"],["xmlns","http://www.w3.org/2000/svg",0,"xmlns","bx","https://boxy-svg.com","viewBox","0 0 32 32","width","32","height","32","fill","none",1,"action-btn-icon"],["cx","16","cy","10.751","r","3.751",0,"bx","origin","0.5 1.19976","has-stroke","",2,"stroke-width","2px"],["d","M 10 24.964 L 10 24.251 C 10 20.936 12.687 18.251 16 18.251 C 19.313 18.251 22 20.936 22 24.251 L 22 25","stroke-linecap","round",0,"bx","origin","0.5 -0.333481","has-stroke","",2,"stroke-width","2px"]],template:function(e,n){if(e&1){let i=x();Ft(),_(0,"div",3),A("click",function(s){return T(i),n.addTag(),S(s.stopPropagation())}),O(1,Ue,1,1,"ng-template",4)(2,$e,4,2,"ng-template",null,0,nt),P(),O(4,We,1,0,"ng-template",null,1,nt)}if(e&2){let i=N(3);v(),u("ngIf",n.targetTagElementId)("ngIfElse",i)}},dependencies:[H,zt],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;height:unset;width:unset;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}.snippyly-tag-btn-container[_ngcontent-%COMP%]{display:inline-block}.action-btn[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center}.action-btn-icon[_ngcontent-%COMP%]{width:32px;height:32px;border-radius:50px;cursor:pointer;transition:.5s!important}.action-btn-icon[_ngcontent-%COMP%] *[has-stroke][_ngcontent-%COMP%]{stroke:#8f95b2!important}.action-btn-icon[_ngcontent-%COMP%] *[_ngcontent-%COMP%]:not([has-stroke]){fill:#8f95b2!important}.action-btn-icon[_ngcontent-%COMP%]:hover{background:#eae8f9}.action-btn-icon[_ngcontent-%COMP%]:active, .action-btn-icon.active[_ngcontent-%COMP%]{background:#625df5}.action-btn-icon[_ngcontent-%COMP%]:active *[has-stroke][_ngcontent-%COMP%], .action-btn-icon.active[_ngcontent-%COMP%] *[has-stroke][_ngcontent-%COMP%]{stroke:#fff!important}.action-btn-icon[_ngcontent-%COMP%]:active *[_ngcontent-%COMP%]:not([has-stroke]), .action-btn-icon.active[_ngcontent-%COMP%] *[_ngcontent-%COMP%]:not([has-stroke]){fill:#fff!important}"],changeDetection:0});let a=r;return a})();function ze(a,r){if(a&1){let o=x();_(0,"div",7),A("click",function(e){return T(o),h(2).copyLink(),S(e.stopPropagation())}),Q(1),R(2,"translate"),P()}if(a&2){let o=h(2);v(),St(" ",F(2,1,o.copyLinkText))}}function Ye(a,r){if(a&1){let o=x();_(0,"div",7),A("click",function(e){T(o);let n=h(2);return n.editMode=!0,S(e.stopPropagation())}),Q(1),R(2,"translate"),P()}a&2&&(v(),Tt(F(2,1,"Reassign")))}function Xe(a,r){if(a&1){let o=x();_(0,"div",7),A("click",function(e){T(o);let n=h(2);return n.editMode=!0,n.resolveTag(),S(e.stopPropagation())}),Q(1),R(2,"translate"),P()}a&2&&(v(),Tt(F(2,1,"Resolve")))}function Ke(a,r){if(a&1){let o=x();_(0,"div",7),A("click",function(e){return T(o),h(2).removeTag(),S(e.stopPropagation())}),Q(1),R(2,"translate"),P()}a&2&&(v(),St(" ",F(2,1,"Remove")))}function Je(a,r){if(a&1&&(_(0,"div",4)(1,"div",5),Q(2),R(3,"translate"),R(4,"translate"),P(),O(5,ze,3,3,"div",6)(6,Ye,3,3,"div",6)(7,Xe,3,3,"div",6)(8,Ke,3,3,"div",6),P()),a&2){let o=h();v(2),Ut("",F(3,6,"Assigned to:")," ",!(o.annotation==null||o.annotation.to[0]==null)&&o.annotation.to[0].name?o.annotation==null||o.annotation.to[0]==null?null:o.annotation.to[0].name:F(4,8,o.annotation==null||o.annotation.to[0]==null?null:o.annotation.to[0].email)),v(3),u("ngIf",o.tagPinSelected),v(),u("ngIf",o.tagPinSelected&&(o.allowedActions==null?null:o.allowedActions.update)),v(),u("ngIf",o.tagPinSelected&&(o.allowedActions==null?null:o.allowedActions.resolve)),v(),u("ngIf",o.tagPinSelected&&(o.allowedActions==null?null:o.allowedActions.remove))}}function Qe(a,r){if(a&1){let o=x();W(),_(0,"svg",11),A("click",function(){T(o);let e=h(2);return S(!(e.annotation==null||e.annotation.to==null)&&e.annotation.to.length?e.editMode=!1:e.removeTag())}),z(1,"path",12)(2,"path",13),P()}}function qe(a,r){if(a&1){let o=x();Lt(0),_(1,"div",8)(2,"velt-autocomplete-panel-internal",9,0),R(4,"translate"),A("optionSelected",function(e){T(o);let n=h();return S(n.saveTag(e))}),P(),O(5,Qe,3,0,"svg",10),P(),Nt()}if(a&2){let o=N(3),t=h();v(2),u("placeholder",F(4,3,"Please select a contact to assign"))("enableOnFocus",!0),v(3),u("ngIf",(t.annotation==null||t.annotation.to==null?null:t.annotation.to.length)||!(!(o==null||o.userContacts==null)&&o.userContacts.length))}}var It=(()=>{let r=class r{get user(){return this._user}set user(t){this._user=t,this.checkToShowActions()}get tagPinSelected(){return this._tagPinSelected}set tagPinSelected(t){this._tagPinSelected=t,this.tagPinSelected&&this.setTagReadInAnalytics()}constructor(t,e,n){this.analyticsService=t,this.tagService=e,this.loggingService=n,this.subscriptions=[],this.editMode=!1,this.copyLinkText="Copy Link",this._user=new ae,this.allowedActions=null,this._tagPinSelected=!1,this.veltElement=!0}ngOnInit(){try{this.checkToShowActions(),this.annotation?.to?.length||(this.editMode=!0)}catch(t){this.loggingService.catch("Error in TagDialogComponent OnInit: ",t)}}ngAfterViewInit(){try{this.setTagReadInAnalytics()}catch(t){this.loggingService.catch("Error in TagDialogComponent view init: ",t)}}trackByUserContact(t,e){return e?.email||t}setTagReadInAnalytics(){try{this.annotation&&this.analyticsService.trackEvent(b.Events.Tag.TAG_READ,{annotationId:this.annotation.annotationId,readType:this.tagPinSelected?"open":"hover"})}catch(t){this.loggingService.catch("Error in CommentDialogComponent setCommentReadInAnalytics: ",t)}}saveTag(t){try{this.analyticsService.trackEvent(b.Events.Tag.TAG_ADDED,{annotationId:this.annotation.annotationId}),this.annotation.to=[t],this.tagService.updateTag(this.annotation,!0),this.editMode=!1}catch(e){this.loggingService.catch("Error in TagDialogComponent saveTag: ",e)}}checkToShowActions(){try{this.user&&this.annotation?this.annotation.from?.userId===this.user.userId?(this.allowedActions||(this.allowedActions={}),this.allowedActions.update=!0,this.allowedActions.remove=!0):!this.annotation?.resolved&&this.annotation?.to?.find(t=>t?.email===this.user?.email)&&(this.allowedActions||(this.allowedActions={}),this.allowedActions.resolve=!0):this.allowedActions=null}catch(t){this.loggingService.catch("Error in TagDialogComponent checkToShowActions: ",t)}}resolveTag(){try{this.tagService.resolveTag(this.annotation),this.editMode=!1}catch(t){this.loggingService.catch("Error in TagDialogComponent resolveTag: ",t)}}removeTag(){try{this.tagService.deleteTagPinAnnotations("deleteOption")}catch(t){this.loggingService.catch("Error in TagDialogComponent removeTag: ",t)}}copyLink(){try{let t=this.copyLinkText;this.copyLinkText="Link Copied!",setTimeout(()=>{this.copyLinkText=t},2e3);let e=this.tagService.getTagUrl(this.annotation);e&&ge(e),this.analyticsService.trackEvent(b.Events.Tag.TAG_LINK_COPIED,{annotationId:this.annotation.annotationId})}catch(t){this.loggingService.catch("Error in TagDialogComponent copyLink: ",t)}}};r.\u0275fac=function(e){return new(e||r)(m(B),m(w),m(p))},r.\u0275cmp=k({type:r,selectors:[["snippyly-tag-dialog"]],hostVars:1,hostBindings:function(e,n){e&2&&M("data-velt-element",n.veltElement)},inputs:{annotation:"annotation",user:"user",tagPinSelected:"tagPinSelected"},standalone:!1,decls:3,vars:5,consts:[["userSelectorRef",""],[1,"tag-dialog-container",3,"pointerdown","pointerup"],["velt-ignore-change-detection","true",4,"ngIf"],[4,"ngIf"],["velt-ignore-change-detection","true"],[1,"tag-user-details"],["class","tag-action-button",3,"click",4,"ngIf"],[1,"tag-action-button",3,"click"],[1,"tag-input-container"],[3,"optionSelected","placeholder","enableOnFocus"],["xmlns","http://www.w3.org/2000/svg","width","16","height","16","fill","currentColor","class","bi bi-x-circle","viewBox","0 0 16 16",3,"click",4,"ngIf"],["xmlns","http://www.w3.org/2000/svg","width","16","height","16","fill","currentColor","viewBox","0 0 16 16",1,"bi","bi-x-circle",3,"click"],["d","M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"],["d","M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"]],template:function(e,n){e&1&&(_(0,"div",1),A("pointerdown",function(l){return l.stopPropagation()})("pointerup",function(l){return l.stopPropagation()}),O(1,Je,9,10,"div",2)(2,qe,6,5,"ng-container",3),P()),e&2&&(st("edit-mode",n.editMode),M("data-velt-annotation-draft",n.editMode?n.annotation==null?null:n.annotation.annotationId:null),v(),u("ngIf",(n.annotation==null||n.annotation.to==null?null:n.annotation.to.length)&&!n.editMode),v(),u("ngIf",n.editMode))},dependencies:[H,ye,Ce],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;height:unset;width:unset;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}.tag-dialog-container[_ngcontent-%COMP%]{background-color:#fff;padding-top:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;padding-bottom:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:100%;padding-right:calc((.75rem + 0px) * var(--velt-base-rem-unit))!important;padding-left:calc((.75rem + 0px) * var(--velt-base-rem-unit))!important;margin-right:auto!important;margin-left:auto!important;font-size:calc((.875rem + 0px) * var(--velt-base-rem-unit));border-radius:10px!important;box-shadow:0 calc((1rem + 0px) * var(--velt-base-rem-unit)) calc((3rem + 0px) * var(--velt-base-rem-unit)) #0000002d!important;border:1px solid #dee2e6!important;max-height:fit-content!important;max-width:300px;min-width:300px}.tag-dialog-container[_ngcontent-%COMP%]:not(.edit-mode){background-color:#141416!important;padding-left:0!important;padding-right:0!important;max-width:250px;min-width:250px;border:none!important}.tag-dialog-container[_ngcontent-%COMP%]:not(.edit-mode) *[_ngcontent-%COMP%]{color:#fff!important}.tag-dialog-container[_ngcontent-%COMP%]:not(.edit-mode) .tag-user-details[_ngcontent-%COMP%]{margin-bottom:calc((.25rem + 0px) * var(--velt-base-rem-unit))!important;padding-right:calc((.75rem + 0px) * var(--velt-base-rem-unit))!important;padding-left:calc((.75rem + 0px) * var(--velt-base-rem-unit))!important;word-break:break-word}.tag-dialog-container[_ngcontent-%COMP%]:not(.edit-mode) .tag-action-button[_ngcontent-%COMP%]{padding:calc((.25rem + 0px) * var(--velt-base-rem-unit)) calc((.75rem + 0px) * var(--velt-base-rem-unit))!important;cursor:pointer}.tag-dialog-container[_ngcontent-%COMP%]:not(.edit-mode) .tag-action-button[_ngcontent-%COMP%]:hover{background-color:#353537}.tag-dialog-container[_ngcontent-%COMP%] .tag-input-container[_ngcontent-%COMP%]{display:flex}.tag-dialog-container[_ngcontent-%COMP%] .tag-input-container[_ngcontent-%COMP%] input[_ngcontent-%COMP%]{width:100%!important;border:0!important} .snippyly-tag-autocomplete-panel{box-shadow:0 calc((.3rem + 0px) * var(--velt-base-rem-unit)) calc((1.5rem + 0px) * var(--velt-base-rem-unit)) #0000002e!important} .snippyly-tag-autocomplete-panel::-webkit-scrollbar{display:none!important;width:0!important;height:0!important} .snippyly-tag-autocomplete-panel::-webkit-scrollbar{width:0;height:0} .snippyly-tag-autocomplete-panel::-webkit-scrollbar-button{width:0;height:0} .snippyly-tag-autocomplete-panel .user-selection-container{background:#fff;border-radius:8px;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) 0!important} .snippyly-tag-autocomplete-panel .user-selection-container .mat-mdc-option{padding:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important} .snippyly-tag-autocomplete-panel .user-selection-container .mat-mdc-option.mat-mdc-option-active{background-color:#f2f2f2!important}.contact-container[_ngcontent-%COMP%]{display:flex;align-items:center}.photo-container[_ngcontent-%COMP%]{min-width:calc((2.5rem + 0px) * var(--velt-base-rem-unit));width:calc((2.5rem + 0px) * var(--velt-base-rem-unit));min-height:calc((2.5rem + 0px) * var(--velt-base-rem-unit));height:calc((2.5rem + 0px) * var(--velt-base-rem-unit));box-sizing:border-box;background-clip:padding-box;border:solid 2px transparent;display:flex;align-items:center;justify-content:center;position:relative;margin-right:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}.photo-container-small[_ngcontent-%COMP%]{width:calc((2rem + 0px) * var(--velt-base-rem-unit));height:calc((2rem + 0px) * var(--velt-base-rem-unit));min-width:calc((2rem + 0px) * var(--velt-base-rem-unit));min-height:calc((2rem + 0px) * var(--velt-base-rem-unit));margin-right:calc((.8rem + 0px) * var(--velt-base-rem-unit))!important}.photo-container[_ngcontent-%COMP%]:before{content:"";position:absolute;inset:0;z-index:1;border-radius:inherit;background:inherit}.photo-container[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:100%;height:100%;border-radius:50%;z-index:2;object-fit:cover}.contact-details[_ngcontent-%COMP%]{overflow:hidden}.contact-details[_ngcontent-%COMP%] .contact-name[_ngcontent-%COMP%], .contact-details[_ngcontent-%COMP%] .contact-email[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;line-height:calc((1rem + 0px) * var(--velt-base-rem-unit));font-size:calc((.875rem + 0px) * var(--velt-base-rem-unit))!important}.contact-details[_ngcontent-%COMP%] .contact-email[_ngcontent-%COMP%]{color:#6c757d!important}.photo-placeholder[_ngcontent-%COMP%]{z-index:2;opacity:.8}.tag-buttons-container[_ngcontent-%COMP%]{display:flex;flex-direction:row;align-items:center;padding-top:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;background:#fff}.tag-button[_ngcontent-%COMP%]{background-color:#625df5;color:#fff!important;border:0;border-radius:4px;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) calc((1rem + 0px) * var(--velt-base-rem-unit))!important;margin-right:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;cursor:pointer!important}.tag-button[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{color:#fff!important}.tag-button.green[_ngcontent-%COMP%]{background-color:#0dcf82!important}.tag-button[_ngcontent-%COMP%]:hover{background-color:#44aeff!important;color:#fff!important}.tag-button[_ngcontent-%COMP%]:hover.green{background-color:#10b372!important}.tag-button[disabled][_ngcontent-%COMP%], .tag-button[disabled][_ngcontent-%COMP%]:hover{background-color:#0000001a!important;color:#0006!important}.cancel-button[_ngcontent-%COMP%]{border:0;border-radius:4px;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) calc((1rem + 0px) * var(--velt-base-rem-unit))!important;margin-right:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;cursor:pointer!important}.cancel-button[_ngcontent-%COMP%]:hover{color:#e91e63}.no-contacts-message[_ngcontent-%COMP%]{text-align:center!important} .tag-input-container velt-autocomplete-panel-internal{width:100%!important} .tag-input-container velt-autocomplete-panel-internal input{width:100%!important;border:0!important}'],changeDetection:0});let a=r;return a})();var tn=["overlay"],en=["pin"],nn=(a,r)=>({"tag-pin-selected":a,"mutiple-pins-selected":r}),on=()=>["snippyly-overlay-panel","snippyly-tag-dialog-overlay-panel","velt-overlay-panel"];function rn(a,r){a&1&&(W(),z(0,"path",8))}function an(a,r){if(a&1){let o=x();_(0,"snippyly-user-avatar",9),A("pointerover",function(e){return T(o),h().onPointerOver(e),S(e.stopPropagation())})("pointerout",function(){T(o);let e=h();return S(e.onPointerOut())}),P()}if(a&2){let o=h();u("user",o.tagPinAnnotation==null?null:o.tagPinAnnotation.to[0])("background","rgb(162, 89, 254) !important")("size",26)}}function sn(a,r){if(a&1){let o=x();_(0,"snippyly-tag-dialog",10),A("saveTag",function(e){T(o);let n=h();return S(n.saveTag.emit(e))}),P()}if(a&2){let o=h();u("annotation",o.tagPinAnnotation)("user",o.user)("tagPinSelected",o.tagPinSelected)}}var At=(()=>{let r=class r{get tagPinAnnotation(){return this._tagPinAnnotation}set tagPinAnnotation(t){this._tagPinAnnotation=t}get tagPinSelected(){return this._tagPinSelected}set tagPinSelected(t){this._tagPinSelected=t,this.updateHighlightOnElement()}get tagPinHover(){return this._tagPinHover}set tagPinHover(t){this._tagPinHover=t,this.updateHighlightOnElement()}constructor(t,e,n){this.tagService=t,this.domService=e,this.loggingService=n,this._tagPinSelected=!1,this.multipleTagPinsSelected=!1,this.avatarErrorImage="",this.deleteTagThread=new at,this.saveTag=new at,this.signInToAccessFeature=new at,this.overlayOriginX="start",this.overlayOriginY="top",this._tagPinHover=!1,this.subscriptions=[],this.positions=d.OVERLAY_POSITIONS.map(i=>new Zt({originX:i.originX,originY:i.originY},{overlayX:i.overlayX,overlayY:i.overlayY})),this.veltElement=!0,this.loggingService.log("%c[WB] Creating COMPONENT TagPinComponent","color: blue;")}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{this.updateHighlightOnElement(),this.subscriptions.push(this.overlay.positionChange.subscribe(t=>{this.overlayOriginX=t.connectionPair.originX,this.overlayOriginY=t.connectionPair.originY},t=>{this.loggingService.catch("Error in TagPinComponent positionChange subscription: ",t)}))}catch(t){this.loggingService.catch("Error in TagPinComponent AfterViewInit: ",t)}}updateHighlightOnElement(){try{this.targetElement&&(this.tagPinSelected||this.tagPinHover?this.domService.highlightElement(this.targetElement):this.domService.removeHighlightFromElement(this.targetElement))}catch(t){this.loggingService.catch("Error in TagPinComponent updateHighlightOnElement: ",t)}}onPointerOver(t){try{t.buttons?this.tagPinHover&&(this.tagPinHover=!1):this.tagPinHover||(this.tagPinHover=!0)}catch(e){this.loggingService.catch("Error in TagPinComponent onPointerOver: ",e)}}onPointerOut(){this.tagPinHover=!1}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in TagPinComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in TagPinComponent unsubscribe: ",t)}}};r.\u0275fac=function(e){return new(e||r)(m(w),m(L),m(p))},r.\u0275cmp=k({type:r,selectors:[["snippyly-tag-pin"]],viewQuery:function(e,n){if(e&1&&(Z(tn,5),Z(en,5)),e&2){let i;tt(i=et())&&(n.overlay=i.first),tt(i=et())&&(n.pin=i.first)}},hostVars:1,hostBindings:function(e,n){e&2&&M("data-velt-element",n.veltElement)},inputs:{tagPinAnnotation:"tagPinAnnotation",tagPinSelected:"tagPinSelected",multipleTagPinsSelected:"multipleTagPinsSelected",avatarErrorImage:"avatarErrorImage",user:"user",targetElement:"targetElement"},outputs:{deleteTagThread:"deleteTagThread",saveTag:"saveTag",signInToAccessFeature:"signInToAccessFeature"},standalone:!1,decls:8,vars:15,consts:[["trigger","cdkOverlayOrigin"],["overlay","cdkConnectedOverlay"],["cdkOverlayOrigin","",1,"tag-pin-container",3,"click","ngClass"],["xmlns","http://www.w3.org/2000/svg","viewBox","0 0 100 100",1,"tag-pin"],["cx","50","cy","50","rx","50","ry","50",2,"stroke","rgb(0, 0, 0)","fill","rgb(162, 89, 254)","paint-order","fill","stroke-width","0px"],["d","M 24.999 77 C 24.999 77 20 77 20 72.001 C 20 66.999 24.999 51.999 50 51.999 C 75.001 51.999 80 66.999 80 72.001 C 80 77 75.001 77 75.001 77 L 24.999 77 Z M 50 47 C 61.548 47 68.764 34.5 62.991 24.499 C 60.312 19.857 55.359 17 50 17 C 38.452 17 31.236 29.5 37.009 39.499 C 39.688 44.14 44.641 47 50 47 Z","style","fill: rgb(255, 255, 255);",4,"ngIf"],["class","photo-container tag-user-avatar",3,"user","background","size","pointerover","pointerout",4,"ngIf"],["cdkConnectedOverlay","",3,"cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayPanelClass","cdkConnectedOverlayOffsetY","cdkConnectedOverlayBackdropClass","cdkConnectedOverlayLockPosition","cdkConnectedOverlayPositions","cdkConnectedOverlayGrowAfterOpen"],["d","M 24.999 77 C 24.999 77 20 77 20 72.001 C 20 66.999 24.999 51.999 50 51.999 C 75.001 51.999 80 66.999 80 72.001 C 80 77 75.001 77 75.001 77 L 24.999 77 Z M 50 47 C 61.548 47 68.764 34.5 62.991 24.499 C 60.312 19.857 55.359 17 50 17 C 38.452 17 31.236 29.5 37.009 39.499 C 39.688 44.14 44.641 47 50 47 Z",2,"fill","rgb(255, 255, 255)"],[1,"photo-container","tag-user-avatar",3,"pointerover","pointerout","user","background","size"],[3,"saveTag","annotation","user","tagPinSelected"]],template:function(e,n){if(e&1){let i=x();_(0,"div",2,0),A("click",function(s){return T(i),S(s.preventDefault())}),W(),_(2,"svg",3),z(3,"ellipse",4),O(4,rn,1,0,"path",5),P(),O(5,an,1,3,"snippyly-user-avatar",6),P(),O(6,sn,1,3,"ng-template",7,1,nt)}if(e&2){let i=N(1);u("ngClass",Gt(11,nn,n.tagPinSelected,n.multipleTagPinsSelected)),v(4),u("ngIf",!(!(n.tagPinAnnotation==null||n.tagPinAnnotation.to==null)&&n.tagPinAnnotation.to.length&&(!(n.tagPinAnnotation==null||n.tagPinAnnotation.to[0]==null)&&n.tagPinAnnotation.to[0].photoUrl))),v(),u("ngIf",n.tagPinAnnotation==null||n.tagPinAnnotation.to==null?null:n.tagPinAnnotation.to.length),v(),u("cdkConnectedOverlayOrigin",i)("cdkConnectedOverlayOpen",n.tagPinSelected||n.tagPinHover)("cdkConnectedOverlayPanelClass",jt(14,on))("cdkConnectedOverlayOffsetY",n.overlayOriginY==="top"?-8:2)("cdkConnectedOverlayBackdropClass","snippyly-overlay-backdrop")("cdkConnectedOverlayLockPosition",!1)("cdkConnectedOverlayPositions",n.positions)("cdkConnectedOverlayGrowAfterOpen",!0)}},dependencies:[Wt,H,ee,te,Ee,It],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;height:unset;width:unset;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}.tag-pin-container[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:32px;height:32px;text-align:center;color:#fff;font-size:calc((.8rem + 0px) * var(--velt-base-rem-unit));font-weight:500;cursor:pointer}.tag-pin[_ngcontent-%COMP%]{position:absolute;left:0;top:0;width:32px;height:32px;transition:left .12s ease-in-out,top .12s ease-in-out,width .12s ease-in-out,height .12s ease-in-out,transform .12s ease-in-out}.tag-pin-container[_ngcontent-%COMP%]:hover{filter:brightness(110%) saturate(110%)}.tag-pin-container[_ngcontent-%COMP%]:hover .tag-pin[_ngcontent-%COMP%], .tag-pin-selected[_ngcontent-%COMP%] .tag-pin[_ngcontent-%COMP%], .tag-pin-container[_ngcontent-%COMP%]:hover .photo-container[_ngcontent-%COMP%], .tag-pin-selected[_ngcontent-%COMP%] .photo-container[_ngcontent-%COMP%]{transform:scale(1.2) translateY(-4px);transition:left .12s ease-in-out,top .12s ease-in-out,width .12s ease-in-out,height .12s ease-in-out,transform .12s ease-in-out}.tag-index[_ngcontent-%COMP%]{position:absolute;border-radius:50%;border:1px solid #fff;width:20px;height:20px;text-align:center;top:-8px;right:-8px;font-size:calc((.8rem + 0px) * var(--velt-base-rem-unit));color:#000;background:#fff}.tag-pin-selected[_ngcontent-%COMP%]{filter:brightness(110%) saturate(110%)}.tag-resolved[_ngcontent-%COMP%]{background-color:#0dcf82!important}.bi-check-lg[_ngcontent-%COMP%]{color:#fff}.mutiple-pins-selected[_ngcontent-%COMP%]{border-color:#9746ff!important}.photo-container[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;position:absolute;width:32px;height:32px;box-sizing:border-box;background-clip:padding-box;border-radius:50%;padding:calc((.2rem + 0px) * var(--velt-base-rem-unit))!important;transition:top .12s ease-in-out,width .12s ease-in-out,height .12s ease-in-out,transform .12s ease-in-out;text-transform:capitalize}.photo-container[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:100%;height:100%;border-radius:50%;object-fit:cover}.photo-placeholder[_ngcontent-%COMP%]{z-index:2;opacity:.8} snippyly-user-avatar.tag-user-avatar{background-color:#a259fe!important} snippyly-user-avatar.tag-user-avatar .s-user-avatar-initial{font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important} .snippyly-tag-dialog-overlay-panel{z-index:2147483567!important}"],changeDetection:0});let a=r;return a})();function ln(a,r){if(a&1){let o=x();_(0,"div",1),A("pointerup",function(e){return T(o),h().togglePinSelection(),S(e.stopPropagation())})("pointerdown",function(e){return T(o),S(e.stopPropagation())})("click",function(e){return T(o),S(e.stopPropagation())})("cdkDragStarted",function(){T(o);let e=h();return S(e.onPinDragStart())})("cdkDragMoved",function(e){T(o);let n=h();return S(n.onPinMove(e))})("cdkDragReleased",function(){T(o);let e=h();return S(e.onPinRelease())}),_(1,"snippyly-tag-pin",2),A("saveTag",function(e){T(o);let n=h();return S(n.saveTag(e))}),P()()}if(a&2){let o=h();Vt("top",o.annotationDraging?(o.dragPosition==null?null:o.dragPosition.top)-16:(o.tagPinAnnotation==null||o.tagPinAnnotation.position==null?null:o.tagPinAnnotation.position.top)-16+o.offsetTop,"px")("left",o.annotationDraging?(o.dragPosition==null?null:o.dragPosition.left)-16:(o.tagPinAnnotation==null||o.tagPinAnnotation.position==null?null:o.tagPinAnnotation.position.left)-16+o.offsetLeft,"px"),st("pin-dragging",o.annotationDraging),u("id","tag-pin-contianer-"+(o.tagPinAnnotation==null?null:o.tagPinAnnotation.annotationId))("cdkDragDisabled",(o.tagPinAnnotation==null||o.tagPinAnnotation.from==null?null:o.tagPinAnnotation.from.userId)!==(o.user==null?null:o.user.userId)),v(),u("tagPinAnnotation",o.tagPinAnnotation)("tagPinSelected",o.selectedAnnotationsMap[o.tagPinAnnotation==null?null:o.tagPinAnnotation.annotationId]&&!o.annotationDraging&&o.objectKeys(o.selectedAnnotationsMap).length===1)("multipleTagPinSelected",o.selectedAnnotationsMap[o.tagPinAnnotation==null?null:o.tagPinAnnotation.annotationId]&&o.objectKeys(o.selectedAnnotationsMap).length>1)("targetElement",o.targetElement)("user",o.user)}}var Ot=(()=>{let r=class r{get tagPinAnnotation(){return this._tagPinAnnotation}set tagPinAnnotation(t){this._tagPinAnnotation=t,this.id=t.annotationId}constructor(t,e,n,i,l){this.analyticsService=t,this.authService=e,this.domService=n,this.tagService=i,this.loggingService=l,this.multipleTagPinsSelected=!1,this.avatarErrorImage="",this.offsetLeft=0,this.offsetTop=0,this.objectKeys=Object.keys,this.selectedAnnotationsMap={},this.subscriptions=[],this.annotationDraging=!1,this.dragPosition=null,this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(s=>{this.user=s},s=>{this.loggingService.catch("Error in TagPinPortalComponent getUser$ subscription: ",s)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(s=>{this.selectedAnnotationsMap=s},s=>{this.loggingService.catch("Error in TagPinPortalComponent getSelectedAnnotationsMap$ subscription: ",s)}))}ngOnInit(){}togglePinSelection(){try{this.domService.toggleAnnotationSelection(this.tagPinAnnotation)}catch(t){this.loggingService.catch("Error in TagPinPortalComponent togglePinSelection: ",t)}}onPinDragStart(){this.selectedAnnotationsMap[this.tagPinAnnotation.annotationId]&&this.domService.toggleAnnotationSelection(this.tagPinAnnotation);let t=document.getElementById(this.tagPinAnnotation.annotationId);t&&(this.parentElement=t.parentElement,document.body.appendChild(t)),this.annotationDraging=!0}onPinMove(t){try{this.updateCurrentPinPosition(t)}catch(e){this.loggingService.catch("Error in TagPinPortalComponent onPinMove: ",e)}}updateCurrentPinPosition(t){try{this.domService.removeHighlightFromElement(this.targetElement);let e=t.event,n=e?.touches?.length?e.touches[0]?.clientX:e.clientX,i=e?.touches?.length?e.touches[0]?.clientY:e.clientY,l=this.domService.getBackgroundElement(n,i);l&&(this.targetElement=l,this.domService.highlightElement(this.targetElement),this.pointerMoveEvent=t.event,this.dragPosition={top:i,left:n})}catch(e){this.loggingService.catch("Error in TagPinPortalComponent updateCurrentPinPosition: ",e)}}onPinRelease(){try{let t=document.getElementById(this.tagPinAnnotation.annotationId);t&&this.parentElement&&this.parentElement.appendChild(t);let e=this.domService.getElementFromXPath(this.tagPinAnnotation.targetElement?.xpath);this.pointerMoveEvent&&(this.tagPinAnnotation.targetElement=this.domService.getTargetElementForCursorPosition(this.pointerMoveEvent));let n=this.domService.getElementFromXPath(this.tagPinAnnotation.targetElement?.xpath),i=this.domService.isElementInsideAdditionalLocationContainer(e)||this.domService.isElementInsideAdditionalLocationContainer(n);this.tagService.updateTag(this.tagPinAnnotation,!1,i),setTimeout(()=>{this.annotationDraging=!1,this.dragPosition=null,this.domService.removeHighlightFromElement(this.targetElement)},100),this.analyticsService.trackEvent(b.Events.Tag.TAG_DRAGGED,{annotationId:this.tagPinAnnotation.annotationId})}catch(t){this.loggingService.catch("Error in TagPinPortalComponent onPinRelease: ",t)}}saveTag(t){}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in TagPinPortalComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in TagPinPortalComponent unsubscribe: ",t)}}};r.\u0275fac=function(e){return new(e||r)(m(B),m(U),m(L),m(w),m(p))},r.\u0275cmp=k({type:r,selectors:[["snippyly-tag-pin-portal"]],hostVars:2,hostBindings:function(e,n){e&2&&(Rt("id",n.id),M("data-velt-element",n.veltElement))},inputs:{tagPinAnnotation:"tagPinAnnotation",multipleTagPinsSelected:"multipleTagPinsSelected",avatarErrorImage:"avatarErrorImage",user:"user",offsetLeft:"offsetLeft",offsetTop:"offsetTop",targetElement:"targetElement"},standalone:!1,decls:1,vars:1,consts:[["class","tag-pin-portal","cdkDrag","","cdkDragHandle","",3,"id","pin-dragging","top","left","cdkDragDisabled","pointerup","pointerdown","click","cdkDragStarted","cdkDragMoved","cdkDragReleased",4,"ngIf"],["cdkDrag","","cdkDragHandle","",1,"tag-pin-portal",3,"pointerup","pointerdown","click","cdkDragStarted","cdkDragMoved","cdkDragReleased","id","cdkDragDisabled"],[3,"saveTag","tagPinAnnotation","tagPinSelected","multipleTagPinSelected","targetElement","user"]],template:function(e,n){e&1&&O(0,ln,2,13,"div",0),e&2&&u("ngIf",n.tagPinAnnotation==null?null:n.tagPinAnnotation.position)},dependencies:[H,Kt,Xt,At],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}[_nghost-%COMP%]{position:absolute!important;top:0!important;left:0!important;box-sizing:border-box!important;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;height:unset!important;width:unset!important;text-align:left!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;height:unset;width:unset;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}.tag-pin-portal[_ngcontent-%COMP%]{position:absolute;transform:none!important;transform-origin:0 0!important;transform-box:fill-box!important;top:0;left:0}.tag-pin-portal.pin-dragging[_ngcontent-%COMP%]{position:fixed;z-index:2147483557!important}"],changeDetection:0});let a=r;return a})();var xe=(()=>{let r=class r{constructor(t,e,n,i,l){this.domService=t,this.componentFactoryResolver=e,this.injector=n,this.appRef=i,this.loggingService=l,this.tagsPinById={}}setTagPin(t){try{if(!this.tagsPinById[t.annotationId])this.setPinPortal(t);else if(t.targetElement?.xpath===this.tagsPinById[t.annotationId]?.annotation?.targetElement?.xpath){let e=this.tagsPinById[t.annotationId].portalRef,n=this.tagsPinById[t.annotationId].userTargetElement,i=this.tagsPinById[t.annotationId].pinHostElement;if(document.body.contains(n)&&document.body.contains(i))e&&(e.instance.tagPinAnnotation=JSON.parse(JSON.stringify(t)),this.updateElementOffset(t));else{let l=this.tagsPinById[t.annotationId].pinHostDomPortalOutlet;l&&(this.tagsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST),this.tagsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST_STATIC),l.detach(),delete this.tagsPinById[t.annotationId],this.setPinPortal(t))}}else{let e=this.tagsPinById[t.annotationId].pinHostDomPortalOutlet;e&&(this.tagsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST),this.tagsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST_STATIC),e.detach(),delete this.tagsPinById[t.annotationId],this.setPinPortal(t))}}catch(e){this.loggingService.catch("Error in TagPinPortalService setTagPin: ",e)}}setPinPortal(t){try{let e=this.domService.getXPath(t.targetElement?.xpath);if(e){let n=e.iterateNext();if(n){let i=this.domService.getHostElement(n),l=new Qt(Ot),s=new qt(i,this.appRef,this.injector),c=s.attach(l);c.instance.tagPinAnnotation=JSON.parse(JSON.stringify(t)),c.instance.targetElement=n,this.tagsPinById[t.annotationId]={pinHostDomPortalOutlet:s,pinPortal:l,portalRef:c,annotation:JSON.parse(JSON.stringify(t)),userTargetElement:n,pinHostElement:i},i.setAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST,t.annotationId),window.getComputedStyle(i).position==="static"&&(me(i)||i.setAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST_STATIC,"true")),this.updateElementOffset(t)}}}catch(e){this.loggingService.catch("Error in TagPinPortalService setPinPortal: ",e)}}updateElementOffset(t){try{let{portalRef:e,userTargetElement:n,pinHostElement:i}=this.tagsPinById[t.annotationId],l=this.domService.getElementOffset(n,i);e.instance.offsetLeft=l.offsetLeft,e.instance.offsetTop=l.offsetTop}catch(e){this.loggingService.catch("Error in TagPinPortalService updateElementOffset: ",e)}}checkPinsToRemove(t){try{let e=t.map(n=>n.annotationId);Object.keys(this.tagsPinById).forEach(n=>{if(!e.includes(n)){let i=this.tagsPinById[n];i.pinHostDomPortalOutlet.detach(),i.pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST),i.pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST_STATIC),this.domService.removeHighlightFromElement(i.pinHostElement),delete this.tagsPinById[n]}})}catch(e){this.loggingService.catch("Error in TagPinPortalService checkPinsToRemove: ",e)}}};r.\u0275fac=function(e){return new(e||r)(f(L),f(Dt),f(xt),f(Bt),f(p))},r.\u0275prov=rt({token:r,factory:r.\u0275fac,providedIn:"root"});let a=r;return a})();var mt=(()=>{let r=class r{get pinHighlighterClass(){return this._pinHighlighterClass}set pinHighlighterClass(t){this._pinHighlighterClass=t,this.domService.setPinHighlighterClass(t)}constructor(t,e,n,i,l,s){this.analyticsService=t,this.authService=e,this.domService=n,this.tagService=i,this.tagPinPortalService=l,this.loggingService=s,this._pinHighlighterClass=null,this.tagPinAnnotations=[],this.subscriptions=[],this.isFirstComponent=!0,this.selectedAnnotationsMap={},this.tagAnnotationFocused=!1,this.veltId=ce(),this.veltElement=!0;try{this.loggingService.log("%c[WB] Creating CLASS: TagsContainerComponent","color: blue;");let c=new URL(window.location.href);this.focusTagAnnotationId=c.searchParams.get(d.URL_PARAMS.TAG_ID)}catch(c){this.loggingService.catch("Error in TagsContainerComponent constructor: ",c)}}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{let t=document.querySelector(d.TAGS.SNIPPYLY_TAGS),e=document.querySelector(d.TAGS.VELT_TAGS);e?this.veltId===e?.getAttribute(d.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent()):this.veltId===t?.getAttribute(d.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent())}catch(t){this.loggingService.catch("Error in TagsContainerComponent AfterViewInit: ",t)}}initComponent(){try{this.subscriptions.push(this.authService.getUser$().pipe(D(t=>!!t)).subscribe(t=>{t&&this.setTagInstalledInAnalytics()},t=>{this.loggingService.catch("Error in getUser: ",t)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(t=>{this.selectedAnnotationsMap=t},t=>{this.loggingService.catch("Error in TagsContainerComponent getSidebarVisibility$ subscription: ",t)})),this.getAllTagsOnCurrentDocument()}catch(t){this.loggingService.catch("Error in TagsContainerComponent initComponent: ",t)}}getAllTagsOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllTagsOnCurrentDocument","color: green;");try{this.subscriptions.push(this.tagService.getAllTagAnnotations().pipe(D(t=>!!t),C(t=>this.domService.getSelectedAnnotationsMap$().pipe(I(e=>({annotations:t,selectedAnnotationsMap:e||{}}))))).subscribe(t=>{try{this.loggingService.log(t),this.tagPinAnnotations=t?.annotations;let e=this.tagPinAnnotations.filter(n=>n.targetElement);e=e.filter(n=>!(n.resolved&&!t.selectedAnnotationsMap[n.annotationId])),this.tagPinPortalService.checkPinsToRemove(e),e.forEach(n=>{this.tagPinPortalService.setTagPin(n)}),this.focusTagAnnotation()}catch(e){this.loggingService.catch("Error in TagsContainerComponent getAllTagsOnCurrentDocument inside subscription: ",e)}},t=>{this.loggingService.catch("Error in TagsContainerComponent getAllTagsOnCurrentDocument subscription: ",t)}))}catch(t){this.loggingService.catch("Error in TagsContainerComponent getAllTagsOnCurrentDocument: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in TagsContainerComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in TagsContainerComponent unsubscribe: ",t)}}focusTagAnnotation(){if(this.focusTagAnnotationId&&!this.tagAnnotationFocused){let t=this.tagPinAnnotations.find(e=>e.annotationId===this.focusTagAnnotationId);t&&(this.tagAnnotationFocused=!0,this.selectedAnnotationsMap[t.annotationId]||this.domService.toggleAnnotationSelection(t),setTimeout(()=>{let e=null;t.targetElement?e=document.getElementById(`tag-pin-contianer-${t.annotationId}`):e=document.querySelector(`[data-velt-id='${t.annotationId}']`),e&&e.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})},100))}}setTagInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(V.TAG)}catch(t){this.loggingService.catch("Error in TagsContainerComponent setTagInstalledInAnalytics: ",t)}}};r.\u0275fac=function(e){return new(e||r)(m(B),m(U),m(L),m(w),m(xe),m(p))},r.\u0275cmp=k({type:r,selectors:[["app-tags-container"]],hostVars:2,hostBindings:function(e,n){e&2&&M("data-velt-id",n.veltId)("data-velt-element",n.veltElement)},inputs:{pinHighlighterClass:"pinHighlighterClass"},standalone:!1,decls:0,vars:0,template:function(e,n){},encapsulation:2,changeDetection:0});let a=r;return a})();var ht=class extends Oe{constructor(r){super(r),this.getService(p).log("%c[WB] Creating CLASS: TagElement","color: blue;"),this.getAllTagAnnotations=this._getAllTagAnnotations,this.deleteTag=this._deleteTag,this.allowedElementIds=this._allowedElementIds,this.attachTag=this._attachTag,this.addTagModeChange=this._addTagModeChange}_getAllTagAnnotations(r,o){this.getService(p).log("%c[WB] Calling FUNCTION: getOnlineUsers","color: green;");try{return this.trackEvent(b.Events.Tag.GET_ALL_TAG_ANNOTATIONS_TRIGGERED,{payload:{documentId:r,location:o}}),this.getService(w).getAllTagAnnotations(r,o)}catch(t){return this.getService(p).catch("Error in _getLiveTagsOnCurrentDocument: ",t),E(null)}}_deleteTag(){this.getService(p).log("%c[WB] Calling FUNCTION: deleteTag","color: green;");try{this.trackEvent(b.Events.Tag.DELETE_TAG_TRIGGERED),this.getService(w).deleteTagPinAnnotations("tagElement")}catch(r){this.getService(p).catch("Error in _deleteTag: ",r)}}_allowedElementIds(r){this.getService(p).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(b.Events.Tag.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:r}}),this.getService(w).setAllowedElementIds(r)}catch(o){this.getService(p).catch("Error in allowedElementIds: ",o)}}_attachTag(r){this.getService(p).log("%c[WB] Calling FUNCTION: attachTag","color: green;");try{this.trackEvent(b.Events.Tag.ATTACH_TAG_TRIGGERED,{payload:{elementId:r}}),this.getService(w).attachTag(r,["id","data-id"])}catch(o){this.getService(p).catch("Error in _attachTag: ",o)}}_addTagModeChange(){this.getService(p).log("%c[WB] Calling FUNCTION: addTagModeChange","color: green;");try{return this.trackEvent(b.Events.Tag.ADD_TAG_MODE_CHANGE_TRIGGERED),this.getService(w).addTagModeChange()}catch(r){return this.getService(p).catch("Error in _addTagModeChange: ",r),E(!1)}}};var De=(()=>{let r=class r{};r.\u0275fac=function(e){return new(e||r)},r.\u0275mod=kt({type:r}),r.\u0275inj=wt({imports:[Yt,ne,Jt,Ie]});let a=r;return a})();function dn(a){a.get(p).log("%c[WB] Loading tag feature chunk","color: blue;");let t=Mt(De,a).injector;return ut(t,d.TAGS.VELT_TAG_TOOL,pt),ut(t,d.TAGS.SNIPPYLY_TAG_TOOL,pt),ut(t,d.TAGS.VELT_TAGS,mt),ut(t,d.TAGS.SNIPPYLY_TAGS,mt),new ht(a)}function ut(a,r,o){if(customElements.get(r))return;let t=ie(o,a);customElements.define(r,t)}export{dn as default};
1
+ import{b as we}from"./chunk-ZF7OTWYC.js";import"./chunk-AP33ZJ2C.js";import{b as ye,t as Ie}from"./chunk-Z7JR4TW6.js";import"./chunk-ZH5R4MP6.js";import"./chunk-B3ZPP3EZ.js";import{b as Xt,c as Kt,d as Jt}from"./chunk-BJ5O5D7F.js";import"./chunk-2JSXDPYO.js";import"./chunk-GB46XS3O.js";import"./chunk-TN7X7OZD.js";import{b as be}from"./chunk-NNZNLREA.js";import{b as Ce,d as Ee}from"./chunk-G3BZ4EU4.js";import{a as Ae}from"./chunk-CCZ3WXF4.js";import{a as ie}from"./chunk-LCACRBV3.js";import{A as Zt,Fa as Pe,G as te,H as ee,I as ne,r as Qt,t as qt,za as re}from"./chunk-NY2Q7SEG.js";import{a as Oe}from"./chunk-MEI3IAPO.js";import{C as Se,D as _e}from"./chunk-BR7AO7YV.js";import{Bb as h,Cb as Ft,Db as Ht,E as D,Fb as Z,Gb as tt,Gc as Wt,Gd as oe,Gi as b,Ha as v,Hb as et,He as d,Ia as at,Ic as H,Ig as lt,Ji as he,K as $,Kb as N,Lb as Vt,Lf as _t,Mb as st,Nc as zt,Nj as fe,Oa as Dt,Pb as Q,Qb as Tt,Ra as m,Rb as St,Rc as Yt,Rh as pe,Sb as Ut,Sg as Ct,Sh as me,V as C,Va as Mt,Wa as k,Xa as kt,Yj as Te,Zf as Pt,_g as bt,a as G,ab as O,b as K,ba as rt,bk as L,ca as wt,cc as jt,ck as U,db as Bt,ea as f,ec as Gt,fb as M,fh as ge,g as ot,ja as T,je as ct,ka as S,l as J,la as W,mc as R,mj as ue,na as xt,nb as u,nc as F,nj as B,ob as _,oj as p,pb as P,pj as ve,qb as z,r as E,rc as nt,re as V,rf as ae,rh as de,tg as se,ub as Lt,ug as ce,v as I,vb as Nt,wb as ft,xb as x,xg as le,yb as Rt,zb as A,zc as $t}from"./chunk-CNB6D3KX.js";var w=(()=>{let r=class r{constructor(t,e,n,i,l,s,c,y,X,Me,ke,Be,Le,Ne,Re){this.analyticsService=t,this.configService=e,this.docService=n,this.databaseService=i,this.authService=l,this.domService=s,this.afAuth=c,this.iamService=y,this.avatarService=X,this.contactService=Me,this.storageService=ke,this.dialog=Be,this.loggingService=Le,this.serviceBook=Ne,this.commonDbService=Re,this.tagAnnotations$=new J({}),this.tagAnnotationsByDocumentId$=new J({}),this.documentPaths=null,this.allowedElementIds$=new J([]),this.addTagMode$=new J(!1),this.enableTextTags$=new J(!1),this.notificationService=null,this.loggingService.log("%c[WB] Creating CLASS: TagService","color: blue;"),this.serviceBook.observe(he).subscribe(g=>{this.notificationService=g}),this.databaseService.getDb().pipe(D(g=>!!g),$(1)).subscribe(g=>{g&&this.getDocumentPaths()},g=>{this.loggingService.catch("Error in TagService getDb subscription: ",g)}),this.domService.onWindowPointerMove$().subscribe(g=>{if(this.addTagMode$.value){this.hightlightElement&&this.domService.removeHighlightFromElement(this.hightlightElement);let j=this.domService.getBackgroundElement(g.clientX,g.clientY);j&&(this.isElementInsideAllowedElements(j)?bt(g.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.hightlightElement=j,this.domService.highlightElement(this.hightlightElement,d.CURSOR.TAG_PIN)):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},g=>{this.loggingService.catch("Error in TagService onWindowPointerMove$ subscription: ",g)}),this.domService.onWindowKeyupEsc$().subscribe(g=>{this.addTagMode$.value&&this.disableAddTagMode()},g=>{this.loggingService.catch("Error in TagService onWindowKeyupEsc$ subscription: ",g)}),this.domService.onDocumentClick$().subscribe(g=>{if(g&&this.addTagMode$.value){if(g.preventDefault(),g.stopPropagation(),!bt(g.target)){let j=this.domService.getBackgroundElement(g.clientX,g.clientY);j&&this.isElementInsideAllowedElements(j)&&this.addTag(g)}this.disableAddTagMode()}},g=>{this.loggingService.catch("Error in TagService onDocumentClick$ subscription: ",g)}),this.addTagMode$.subscribe(g=>{this.hightlightElement&&this.domService.removeHighlightFromElement(this.hightlightElement),g?this.domService.addClassToElement(document.body,"snippyly-add-tag-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-tag-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},g=>{this.loggingService.catch("Error in TagService addTagMode$ subscription: ",g)}),this.domService.onWindowKeyupBackspace$().subscribe(g=>{this.deleteTagPinAnnotations("keyupBackspace")},g=>{this.loggingService.catch("Error in TagService onWindowKeyupBackspace$ subscription: ",g)}),this.domService.onWindowKeyupDelete$().subscribe(g=>{this.deleteTagPinAnnotations("keyupDelete")},g=>{this.loggingService.catch("Error in TagService onWindowKeyupDelete$ subscription: ",g)}),this.domService.getDeleteCommmentAnnotations$().subscribe(g=>{g?.length&&(g?.filter(vt=>vt.type==="tag")).forEach(vt=>ot(this,null,function*(){yield this.deleteTagPinAnnotation(vt)}))},g=>{this.loggingService.catch("Error in TagService onWindowKeyupDelete$ subscription: ",g)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}getAnonymousAvatarImage(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAnonymousAvatarImage","color: green;"),this.avatarService.generateUserImage()}setAllowedElementIds(t){this.allowedElementIds$.next(t||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getAllTagAnnotations(t,e,n){this.loggingService.log("%c[WB] Calling FUNCTION: getAllTagAnnotations","color: green;");let i,l;try{if(t&&(l=Pt(t)),e&&typeof e=="object"){let s=le(e);i=Pt(JSON.stringify(s))}}catch(s){this.loggingService.catch("Error in TagService getAllTagAnnotations: ",s)}return this.authService.getAuthState$().pipe(D(s=>!!s),C(s=>this.isFeatureAllowed({firebaseUser:s,annotations:[],filteredAnnotations:[]})),C(s=>s.featureAllowed?this.iamService.isUserAllowed$().pipe(I(c=>(s.featureAllowed=c,s))):E(s)),C(s=>s.featureAllowed?this.authService.isPlanExpired$().pipe(I(c=>(s.featureAllowed=!c,s))):E(s)),C(s=>s.featureAllowed?E(s).pipe(C(c=>this.docService.getDocumentPaths$().pipe(I(y=>(this.documentPaths=y,c.documentPaths=y,c)))),C(c=>this.getDataFromDocumentId(l).pipe(I(y=>(c.annotations=y||[],G({},c))))),C(c=>this.docService.getLocation$().pipe(I(y=>(c.location=y,c)))),C(c=>this.docService.getLocations$().pipe(I(y=>(c.customLocations=y,c)))),I(c=>{if(c.filteredAnnotations=[],l&&!i)return c.filteredAnnotations=c.annotations?.slice(),c;{let y=[];return i?y.push(i):(y.push(c?.location?.locationId),y.push(...Object.values(c?.customLocations||[]).map(X=>X.locationId))),c.filteredAnnotations=this.filterAnnotationsByLocationIds(c?.annotations,y),c}}),C(c=>n?E(c):c?.annotations?.length?this.domService.onWindowResize$().pipe(I(()=>c)):E(c)),C(c=>n?E(c):c?.annotations?.length?this.domService.onDomChange$("TagService getAllTagAnnotations").pipe(I(()=>c)):E(c)),I(c=>(c?.filteredAnnotations?.forEach(y=>{this.calculateTagAnnotationPosition(y)}),c)),C(c=>c?.filteredAnnotations?E(c?.filteredAnnotations||[]):E([]))):E([])))}isFeatureAllowed(t){return this.configService.getConfig$().pipe(D(e=>!!e),I(e=>K(G({},t),{config:e})),C(e=>this.authService.getUser$().pipe(I(n=>K(G({},e),{user:n})))),C(e=>se(e.config,e.user,V.TAG)?E(K(G({},e),{featureAllowed:!0})):(this.loggingService.warn("Tag feature is not allowed."),E(K(G({},e),{featureAllowed:!1})))))}getDataFromDocumentId(t){return this.databaseService.getDb().pipe(D(e=>!!e),C(e=>this.configService?.getApiKey()&&this.documentPaths?.tag?this.commonDbService.dbListener({feature:"allTags",properties:{documentId:t??this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(I(n=>n?.data),I(n=>{let i=[];return n&&(i=Object.values(n).filter(l=>typeof l=="object")),this.setTagAnnotationsByDocumentId(t||this.documentPaths?.documentId,i),i})):E([])))}setTagAnnotationsByDocumentId(t,e){try{t&&this.tagAnnotationsByDocumentId$.next(K(G({},this.tagAnnotationsByDocumentId$.value),{[t]:e}))}catch(n){this.loggingService.catch("Error in TagService setTagAnnotationsByDocumentId:",n)}}filterAnnotationsByLocationIds(t,e){try{return t.filter(n=>e.includes(n.locationId))}catch(n){return this.loggingService.catch("Error in TagService filterAnnotationsByLocations:",n),[]}}calculateTagAnnotationPosition(t){try{if(t.targetElement){let e=this.domService.getXPath(t.targetElement?.xpath);if(e){let n=e.iterateNext();if(n&&lt(n)){let i=n.getBoundingClientRect();if(i&&i.width&&i.height){let{height:l,width:s}=pe(n);t.position={top:l*t.targetElement.topPercentage/100,left:s*t.targetElement.leftPercentage/100}}else t.position=null}else t.position=null}else t.position=null}}catch(e){this.loggingService.catch("Error in TagService calculateTagAnnotationPosition:",e)}}filterPinAnnotations(t,e,n){this.loggingService.log("%c[WB] Calling FUNCTION: filterPinAnnotations","color: green;");try{let i=t?Object.values(t):[];i.forEach((s,c)=>{s?.annotationId&&(s.annotationIndex=c+1)});let l=[];if(e)n?l=i.filter(s=>s.locationId===n):l=i.slice();else{let s=this.docService.getLocation();s&&s.locationId?l=i.filter(c=>c.locationId===s.locationId):l=i.filter(c=>!c.locationId)}return l}catch(i){return this.loggingService.catch("Error in TagService filterPinAnnotations:",i),[]}}addTag(t,e){this.loggingService.log("%c[WB] Calling FUNCTION: addTag","color: green;");try{let n=this.authService.getUser();if(n)if(n.isReadOnly||n.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add tags.");else{let i=new _t;i.from=n,i.color=d.DEFAULT_ANNOTATION_COLOR,i.resolved=!1,i.lastUpdated=this.timestamp;let{topPositionX:l,topPositionY:s}=this.domService.getTopLeftPosition();i.positionX=l,i.positionY=s;let c=this.domService.getCurrentWindowSizeValue();if(i.screenWidth=c.screenWidth,i.screenHeight=c.screenHeight,i.screenScrollHeight=c.screenScrollHeight,i.taggedElementPath="",t&&(i.targetElement=this.domService.getTargetElementForCursorPosition(t)),e&&(i.targetTextRange=e),i?.targetElement?.xpath){let y=this.domService.getXPath(i.targetElement.xpath);if(y){let X=y.iterateNext();X&&(lt(X)||(i.targetElement=null))}}this.setLocationToTagAnnotation(i),i.pageInfo=Ct(),i.pageInfo&&(i.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveTagToDb(i)}}catch(n){this.loggingService.catch("Error in TagService addTag: ",n)}}setLocationToTagAnnotation(t){try{let e=this.docService.getLocation();e?(t.locationId=e.locationId,t.location=e.location):(delete t.locationId,delete t.location);try{let n;t.targetElement?.xpath?n=this.domService.getElementFromXPath(t.targetElement.xpath):t.targetTextRange?.commonAncestorContainer&&(n=this.domService.getElementFromXPath(t.targetTextRange.commonAncestorContainer));let i=this.docService.getAdditionLocationFromElement(n);if(i){let l=this.docService.addLocation({location:i,source:"internal"});l?.[0]&&(t.locationId=l[0].locationId,t.location=l[0].location)}}catch{}}catch(e){this.loggingService.catch("Error in TagService setLocationToTagAnnotation:",e)}}saveTagToDb(t){this.loggingService.log("%c[WB] Calling FUNCTION: saveTagToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(V.TAG)&&this.docService.getDocumentPaths$().pipe(D(e=>!!e),$(1),C(e=>(this.documentPaths=e,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(D(n=>!!n),$(1),C(n=>{if(this.documentPaths?.tag){t.annotationId=this.commonDbService.generateDocumentId(),t.pageInfo&&(t.pageInfo.tagUrl=this.generateTagUrl(t));let i=JSON.parse(JSON.stringify(t));return i.position=null,this.domService.toggleAnnotationSelection(i),t.targetTextRange&&sessionStorage.setItem(d.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,t.annotationId),this.analyticsService.trackEvent(b.Events.Tag.TAG_DRAFT_ADDED,{annotationId:t.annotationId}),this.commonDbService.setData({feature:"tag",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0},data:i})}else return E(null)}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in TagService saveTagToDb subscription: ",e)})}catch(e){this.loggingService.catch("Error in TagService saveTagToDb: ",e)}}updateTag(t,e=!1,n){try{n&&this.setLocationToTagAnnotation(t),e&&this.updateNotificationsDatabase(t,ct.UPDATED),this.updateTagToDb(t)}catch(i){this.loggingService.catch("Error in TagService updateTag: ",i)}}resolveTag(t){try{t.resolved=!0,this.domService.resetSelectedAnnotationsMap(!1),this.updateNotificationsDatabase(t,ct.RESOLVED),this.updateTagToDb(t),this.domService.updateSelectedAnnotationInMap([t]),this.analyticsService.trackEvent(b.Events.Tag.TAG_RESOLVED,{annotationId:t.annotationId})}catch(e){this.loggingService.catch("Error in TagService resolveTag: ",e)}}updateTagToDb(t){this.loggingService.log("%c[WB] Calling FUNCTION: updateTagToDb","color: green;");try{if(t?.targetElement?.xpath){let e=this.domService.getXPath(t.targetElement.xpath);if(e){let n=e.iterateNext();n&&(lt(n)||(t.targetElement=null))}}this.domService.updateSelectedAnnotationInMap([t]),this.authService.getUser()&&this.authService.isFeatureAllowed(V.TAG)&&this.docService.getDocumentPaths$().pipe(D(e=>!!e),$(1),C(e=>(this.documentPaths=e,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(D(n=>!!n),$(1),C(n=>{if(this.documentPaths?.tag&&t?.annotationId){let i=JSON.parse(JSON.stringify(t));return i.position=null,this.commonDbService.setData({feature:"tag",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0},data:i})}else return E(null)}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in TagService updateTagToDb subscription: ",e)})}catch(e){this.loggingService.catch("Error in TagService updateTagToDb: ",e)}}deleteTagPinAnnotations(t){try{let e=this.domService.getSelectedAnnotationsMap(),n=this.authService.getUser(),i=[];Object.keys(e).forEach(l=>ot(this,null,function*(){let s=e[l];s.type==="tag"&&n&&s.from&&(n?.isAdmin||s.from.userId===n.userId)&&i.push(s)})),i?.length&&(this.analyticsService.trackEvent(b.Events.Tag.TAG_DELETE_TRIGGERED,{triggerType:t,annotationId:i.map(l=>l.annotationId).join()}),this.dialog.open(be,{panelClass:"velt-mat-dialog-container",data:{title:"Delete tag?",message:"This selected tag will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"tag"}}).afterClosed().pipe($(1)).subscribe(l=>{l&&(i.forEach(s=>ot(this,null,function*(){yield this.deleteTagPinAnnotation(s)})),setTimeout(()=>{document.querySelectorAll(`[${d.SNIPPYLY_HIGHLIGHT}]`).forEach(c=>{this.domService.removeHighlightFromElement(c)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"tag")}catch(e){this.loggingService.catch("Error in TagService deleteTagPinAnnotations: ",e)}}deleteTagPinAnnotation(t){return this.authService.isFeatureAllowed(V.TAG)&&this.documentPaths?.tag&&t?.annotationId?(this.updateNotificationsDatabase(t,ct.DELETED),this.analyticsService.trackEvent(b.Events.Tag.TAG_DELETED,{annotationId:t.annotationId}),this.commonDbService.deleteData({feature:"tag",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0}})):Promise.resolve()}enableAddTagMode(){this.authService.isFeatureAllowed(V.TAG)?(this.analyticsService.trackEvent(b.Events.Tag.TAG_ADD_MODE_ENABLED),this.addTagMode$.next(!0)):this.loggingService.catch("Error in TagService enableAddTagMode: ","Tag feature is not enabled.")}disableAddTagMode(){this.analyticsService.trackEvent(b.Events.Tag.TAG_ADD_MODE_DISABLED),this.addTagMode$.next(!1)}addTagModeChange(){return this.addTagMode$.asObservable()}enableTextTags(t){this.enableTextTags$.next(t)}getEnableTextTags$(){return this.enableTextTags$.asObservable()}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(t){try{return this.domService.isElementInsideListedElementIds(t,this.allowedElementIds$.value)}catch(e){return this.loggingService.catch("Error in TagService isElementInsideAllowedElements: ",e),!1}}attachTag(t,e=[]){let n=de(t,e);if(n){let i=this.domService.getXPath(n),l=this.getTagPinAnnotationObject();l&&(l.targetElement={xpath:i,topPercentage:50,leftPercentage:90},this.saveTagToDb(l))}}getTagPinAnnotationObject(){let t=this.authService.getUser();if(t)if(t.isReadOnly||t.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add tags.");else{let e=new _t;e.from=t,e.color=d.DEFAULT_ANNOTATION_COLOR,e.resolved=!1,e.lastUpdated=this.timestamp;let{topPositionX:n,topPositionY:i}=this.domService.getTopLeftPosition();e.positionX=n,e.positionY=i;let l=this.domService.getCurrentWindowSizeValue();e.screenWidth=l.screenWidth,e.screenHeight=l.screenHeight,e.screenScrollHeight=l.screenScrollHeight,e.taggedElementPath="";let s=this.docService.getLocation();return s&&(e.locationId=s.locationId,e.location=s.location),e}return null}updateNotificationsDatabase(t,e){try{let n={annotationData:t,actionType:e,notificationSource:"tag"};this.notificationService?.updateNotificationDatabase(n)}catch(n){this.loggingService.catch("Error in TagService updateNotificationsDatabase: ",n)}}getUserContacts$(){return this.contactService.getUserContacts$()}addUserContact(t){this.contactService.addUserContact(t)}getTagUrl(t){try{return t?.pageInfo?.tagUrl?t.pageInfo.tagUrl:(t?.pageInfo||(t.pageInfo=Ct(),t.pageInfo&&(t.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),t.pageInfo.tagUrl=this.generateTagUrl(t),this.updateTag(t),t.pageInfo?.tagUrl)}catch(e){this.loggingService.catch("Error in TagService getTagUrl: ",e);return}}uploadFile(t,e){let n=`${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${d.FIREBASE_PARTIAL_PATH_TAG}/${e.annotationId}`;return this.documentPaths?.organizationId&&(n=`${d.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${d.FIREBASE_PARTIAL_PATH_TAG}/${e.annotationId}`),this.storageService.uploadFile({path:n,file:t})}downloadAttachment(t){this.storageService.downloadAttachment(t)}deleteAttachment(t){return this.storageService.deleteAttachment({attachment:t})}generateTagUrl(t){let e;try{e=new URL(t?.pageInfo?.url||window.location.href)}catch(n){this.loggingService.catch("Error in TagService generateTagUrl: ",n),e=new URL(window.location.href)}return e.searchParams.delete(d.URL_PARAMS.TAG_ID),e.searchParams.append(d.URL_PARAMS.TAG_ID,t.annotationId),e.href}};r.\u0275fac=function(e){return new(e||r)(f(B),f(ve),f(_e),f(fe),f(U),f(L),f(oe),f(Ae),f(Te),f(Pe),f(we),f(re),f(p),f(ue),f(Se))},r.\u0275prov=rt({token:r,factory:r.\u0275fac,providedIn:"root"});let a=r;return a})();var Fe=["customBtnRef"],He=["*"];function Ve(a,r){a&1&&ft(0)}function Ue(a,r){if(a&1&&O(0,Ve,1,0,"ng-container",5),a&2){h();let o=N(5);u("ngTemplateOutlet",o)}}function je(a,r){a&1&&(_(0,"div",8),W(),_(1,"svg",9),z(2,"circle",10)(3,"path",11),P()())}function Ge(a,r){a&1&&ft(0)}function $e(a,r){if(a&1&&(O(0,je,4,0,"div",6),_(1,"div",7,2),O(3,Ge,1,0,"ng-container",5),P()),a&2){let o=h(),t=N(5);u("ngIf",o.showDefaultBtn),v(3),u("ngTemplateOutlet",t)}}function We(a,r){a&1&&Ht(0)}var pt=(()=>{let r=class r{constructor(t,e,n,i,l){this.analyticsService=t,this.authService=e,this.tagService=n,this.loggingService=i,this.cdr=l,this.showDefaultBtn=!1,this.subscriptions=[],this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(s=>{this.user=s},s=>{this.loggingService.catch("Error in TagsToolComponent getUser$ subscription: ",s)}))}ngOnInit(){}ngAfterViewInit(){try{this.customBtnRef?.nativeElement?.children?.length||(this.showDefaultBtn=!0,this.cdr.detectChanges())}catch(t){this.loggingService.catch("Error in TagsToolComponent AfterViewInit: ",t)}}addTag(){this.loggingService.log("%c[WB] Calling FUNCTION: addTag","color: green;");try{this.analyticsService.trackEvent(b.Events.Tag.TAG_TOOL_CLICKED,{toolType:this.customBtnRef?.nativeElement?.children?.length?"custom":"default"}),this.user&&(this.user.isReadOnly||this.user.isAnonymous?this.loggingService.catch("Anonymous/Readonly users cannot add tags."):this.targetTagElementId?this.tagService.attachTag(this.targetTagElementId,["id","data-id"]):this.tagService.enableAddTagMode())}catch(t){this.loggingService.catch("Error in TagsToolComponent addTag: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in TagsToolComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in TagsToolComponent unsubscribe: ",t)}}};r.\u0275fac=function(e){return new(e||r)(m(B),m(U),m(w),m(p),m($t))},r.\u0275cmp=k({type:r,selectors:[["snippyly-tags-tool"]],viewQuery:function(e,n){if(e&1&&Z(Fe,5),e&2){let i;tt(i=et())&&(n.customBtnRef=i.first)}},hostVars:1,hostBindings:function(e,n){e&2&&M("data-velt-element",n.veltElement)},inputs:{targetTagElementId:"targetTagElementId"},standalone:!1,ngContentSelectors:He,decls:6,vars:2,consts:[["tagToolBtn",""],["content",""],["customBtnRef",""],[1,"snippyly-tag-btn-container",3,"click"],[3,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],["class","action-btn",4,"ngIf"],[1,"custom-btn-container"],[1,"action-btn"],["xmlns","http://www.w3.org/2000/svg",0,"xmlns","bx","https://boxy-svg.com","viewBox","0 0 32 32","width","32","height","32","fill","none",1,"action-btn-icon"],["cx","16","cy","10.751","r","3.751",0,"bx","origin","0.5 1.19976","has-stroke","",2,"stroke-width","2px"],["d","M 10 24.964 L 10 24.251 C 10 20.936 12.687 18.251 16 18.251 C 19.313 18.251 22 20.936 22 24.251 L 22 25","stroke-linecap","round",0,"bx","origin","0.5 -0.333481","has-stroke","",2,"stroke-width","2px"]],template:function(e,n){if(e&1){let i=x();Ft(),_(0,"div",3),A("click",function(s){return T(i),n.addTag(),S(s.stopPropagation())}),O(1,Ue,1,1,"ng-template",4)(2,$e,4,2,"ng-template",null,0,nt),P(),O(4,We,1,0,"ng-template",null,1,nt)}if(e&2){let i=N(3);v(),u("ngIf",n.targetTagElementId)("ngIfElse",i)}},dependencies:[H,zt],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;height:unset;width:unset;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}.snippyly-tag-btn-container[_ngcontent-%COMP%]{display:inline-block}.action-btn[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center}.action-btn-icon[_ngcontent-%COMP%]{width:32px;height:32px;border-radius:50px;cursor:pointer;transition:.5s!important}.action-btn-icon[_ngcontent-%COMP%] *[has-stroke][_ngcontent-%COMP%]{stroke:#8f95b2!important}.action-btn-icon[_ngcontent-%COMP%] *[_ngcontent-%COMP%]:not([has-stroke]){fill:#8f95b2!important}.action-btn-icon[_ngcontent-%COMP%]:hover{background:#eae8f9}.action-btn-icon[_ngcontent-%COMP%]:active, .action-btn-icon.active[_ngcontent-%COMP%]{background:#625df5}.action-btn-icon[_ngcontent-%COMP%]:active *[has-stroke][_ngcontent-%COMP%], .action-btn-icon.active[_ngcontent-%COMP%] *[has-stroke][_ngcontent-%COMP%]{stroke:#fff!important}.action-btn-icon[_ngcontent-%COMP%]:active *[_ngcontent-%COMP%]:not([has-stroke]), .action-btn-icon.active[_ngcontent-%COMP%] *[_ngcontent-%COMP%]:not([has-stroke]){fill:#fff!important}"],changeDetection:0});let a=r;return a})();function ze(a,r){if(a&1){let o=x();_(0,"div",7),A("click",function(e){return T(o),h(2).copyLink(),S(e.stopPropagation())}),Q(1),R(2,"translate"),P()}if(a&2){let o=h(2);v(),St(" ",F(2,1,o.copyLinkText))}}function Ye(a,r){if(a&1){let o=x();_(0,"div",7),A("click",function(e){T(o);let n=h(2);return n.editMode=!0,S(e.stopPropagation())}),Q(1),R(2,"translate"),P()}a&2&&(v(),Tt(F(2,1,"Reassign")))}function Xe(a,r){if(a&1){let o=x();_(0,"div",7),A("click",function(e){T(o);let n=h(2);return n.editMode=!0,n.resolveTag(),S(e.stopPropagation())}),Q(1),R(2,"translate"),P()}a&2&&(v(),Tt(F(2,1,"Resolve")))}function Ke(a,r){if(a&1){let o=x();_(0,"div",7),A("click",function(e){return T(o),h(2).removeTag(),S(e.stopPropagation())}),Q(1),R(2,"translate"),P()}a&2&&(v(),St(" ",F(2,1,"Remove")))}function Je(a,r){if(a&1&&(_(0,"div",4)(1,"div",5),Q(2),R(3,"translate"),R(4,"translate"),P(),O(5,ze,3,3,"div",6)(6,Ye,3,3,"div",6)(7,Xe,3,3,"div",6)(8,Ke,3,3,"div",6),P()),a&2){let o=h();v(2),Ut("",F(3,6,"Assigned to:")," ",!(o.annotation==null||o.annotation.to[0]==null)&&o.annotation.to[0].name?o.annotation==null||o.annotation.to[0]==null?null:o.annotation.to[0].name:F(4,8,o.annotation==null||o.annotation.to[0]==null?null:o.annotation.to[0].email)),v(3),u("ngIf",o.tagPinSelected),v(),u("ngIf",o.tagPinSelected&&(o.allowedActions==null?null:o.allowedActions.update)),v(),u("ngIf",o.tagPinSelected&&(o.allowedActions==null?null:o.allowedActions.resolve)),v(),u("ngIf",o.tagPinSelected&&(o.allowedActions==null?null:o.allowedActions.remove))}}function Qe(a,r){if(a&1){let o=x();W(),_(0,"svg",11),A("click",function(){T(o);let e=h(2);return S(!(e.annotation==null||e.annotation.to==null)&&e.annotation.to.length?e.editMode=!1:e.removeTag())}),z(1,"path",12)(2,"path",13),P()}}function qe(a,r){if(a&1){let o=x();Lt(0),_(1,"div",8)(2,"velt-autocomplete-panel-internal",9,0),R(4,"translate"),A("optionSelected",function(e){T(o);let n=h();return S(n.saveTag(e))}),P(),O(5,Qe,3,0,"svg",10),P(),Nt()}if(a&2){let o=N(3),t=h();v(2),u("placeholder",F(4,3,"Please select a contact to assign"))("enableOnFocus",!0),v(3),u("ngIf",(t.annotation==null||t.annotation.to==null?null:t.annotation.to.length)||!(!(o==null||o.userContacts==null)&&o.userContacts.length))}}var It=(()=>{let r=class r{get user(){return this._user}set user(t){this._user=t,this.checkToShowActions()}get tagPinSelected(){return this._tagPinSelected}set tagPinSelected(t){this._tagPinSelected=t,this.tagPinSelected&&this.setTagReadInAnalytics()}constructor(t,e,n){this.analyticsService=t,this.tagService=e,this.loggingService=n,this.subscriptions=[],this.editMode=!1,this.copyLinkText="Copy Link",this._user=new ae,this.allowedActions=null,this._tagPinSelected=!1,this.veltElement=!0}ngOnInit(){try{this.checkToShowActions(),this.annotation?.to?.length||(this.editMode=!0)}catch(t){this.loggingService.catch("Error in TagDialogComponent OnInit: ",t)}}ngAfterViewInit(){try{this.setTagReadInAnalytics()}catch(t){this.loggingService.catch("Error in TagDialogComponent view init: ",t)}}trackByUserContact(t,e){return e?.email||t}setTagReadInAnalytics(){try{this.annotation&&this.analyticsService.trackEvent(b.Events.Tag.TAG_READ,{annotationId:this.annotation.annotationId,readType:this.tagPinSelected?"open":"hover"})}catch(t){this.loggingService.catch("Error in CommentDialogComponent setCommentReadInAnalytics: ",t)}}saveTag(t){try{this.analyticsService.trackEvent(b.Events.Tag.TAG_ADDED,{annotationId:this.annotation.annotationId}),this.annotation.to=[t],this.tagService.updateTag(this.annotation,!0),this.editMode=!1}catch(e){this.loggingService.catch("Error in TagDialogComponent saveTag: ",e)}}checkToShowActions(){try{this.user&&this.annotation?this.annotation.from?.userId===this.user.userId?(this.allowedActions||(this.allowedActions={}),this.allowedActions.update=!0,this.allowedActions.remove=!0):!this.annotation?.resolved&&this.annotation?.to?.find(t=>t?.email===this.user?.email)&&(this.allowedActions||(this.allowedActions={}),this.allowedActions.resolve=!0):this.allowedActions=null}catch(t){this.loggingService.catch("Error in TagDialogComponent checkToShowActions: ",t)}}resolveTag(){try{this.tagService.resolveTag(this.annotation),this.editMode=!1}catch(t){this.loggingService.catch("Error in TagDialogComponent resolveTag: ",t)}}removeTag(){try{this.tagService.deleteTagPinAnnotations("deleteOption")}catch(t){this.loggingService.catch("Error in TagDialogComponent removeTag: ",t)}}copyLink(){try{let t=this.copyLinkText;this.copyLinkText="Link Copied!",setTimeout(()=>{this.copyLinkText=t},2e3);let e=this.tagService.getTagUrl(this.annotation);e&&ge(e),this.analyticsService.trackEvent(b.Events.Tag.TAG_LINK_COPIED,{annotationId:this.annotation.annotationId})}catch(t){this.loggingService.catch("Error in TagDialogComponent copyLink: ",t)}}};r.\u0275fac=function(e){return new(e||r)(m(B),m(w),m(p))},r.\u0275cmp=k({type:r,selectors:[["snippyly-tag-dialog"]],hostVars:1,hostBindings:function(e,n){e&2&&M("data-velt-element",n.veltElement)},inputs:{annotation:"annotation",user:"user",tagPinSelected:"tagPinSelected"},standalone:!1,decls:3,vars:5,consts:[["userSelectorRef",""],[1,"tag-dialog-container",3,"pointerdown","pointerup"],["velt-ignore-change-detection","true",4,"ngIf"],[4,"ngIf"],["velt-ignore-change-detection","true"],[1,"tag-user-details"],["class","tag-action-button",3,"click",4,"ngIf"],[1,"tag-action-button",3,"click"],[1,"tag-input-container"],[3,"optionSelected","placeholder","enableOnFocus"],["xmlns","http://www.w3.org/2000/svg","width","16","height","16","fill","currentColor","class","bi bi-x-circle","viewBox","0 0 16 16",3,"click",4,"ngIf"],["xmlns","http://www.w3.org/2000/svg","width","16","height","16","fill","currentColor","viewBox","0 0 16 16",1,"bi","bi-x-circle",3,"click"],["d","M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"],["d","M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"]],template:function(e,n){e&1&&(_(0,"div",1),A("pointerdown",function(l){return l.stopPropagation()})("pointerup",function(l){return l.stopPropagation()}),O(1,Je,9,10,"div",2)(2,qe,6,5,"ng-container",3),P()),e&2&&(st("edit-mode",n.editMode),M("data-velt-annotation-draft",n.editMode?n.annotation==null?null:n.annotation.annotationId:null),v(),u("ngIf",(n.annotation==null||n.annotation.to==null?null:n.annotation.to.length)&&!n.editMode),v(),u("ngIf",n.editMode))},dependencies:[H,ye,Ce],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;height:unset;width:unset;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}.tag-dialog-container[_ngcontent-%COMP%]{background-color:#fff;padding-top:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;padding-bottom:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:100%;padding-right:calc((.75rem + 0px) * var(--velt-base-rem-unit))!important;padding-left:calc((.75rem + 0px) * var(--velt-base-rem-unit))!important;margin-right:auto!important;margin-left:auto!important;font-size:calc((.875rem + 0px) * var(--velt-base-rem-unit));border-radius:10px!important;box-shadow:0 calc((1rem + 0px) * var(--velt-base-rem-unit)) calc((3rem + 0px) * var(--velt-base-rem-unit)) #0000002d!important;border:1px solid #dee2e6!important;max-height:fit-content!important;max-width:300px;min-width:300px}.tag-dialog-container[_ngcontent-%COMP%]:not(.edit-mode){background-color:#141416!important;padding-left:0!important;padding-right:0!important;max-width:250px;min-width:250px;border:none!important}.tag-dialog-container[_ngcontent-%COMP%]:not(.edit-mode) *[_ngcontent-%COMP%]{color:#fff!important}.tag-dialog-container[_ngcontent-%COMP%]:not(.edit-mode) .tag-user-details[_ngcontent-%COMP%]{margin-bottom:calc((.25rem + 0px) * var(--velt-base-rem-unit))!important;padding-right:calc((.75rem + 0px) * var(--velt-base-rem-unit))!important;padding-left:calc((.75rem + 0px) * var(--velt-base-rem-unit))!important;word-break:break-word}.tag-dialog-container[_ngcontent-%COMP%]:not(.edit-mode) .tag-action-button[_ngcontent-%COMP%]{padding:calc((.25rem + 0px) * var(--velt-base-rem-unit)) calc((.75rem + 0px) * var(--velt-base-rem-unit))!important;cursor:pointer}.tag-dialog-container[_ngcontent-%COMP%]:not(.edit-mode) .tag-action-button[_ngcontent-%COMP%]:hover{background-color:#353537}.tag-dialog-container[_ngcontent-%COMP%] .tag-input-container[_ngcontent-%COMP%]{display:flex}.tag-dialog-container[_ngcontent-%COMP%] .tag-input-container[_ngcontent-%COMP%] input[_ngcontent-%COMP%]{width:100%!important;border:0!important} .snippyly-tag-autocomplete-panel{box-shadow:0 calc((.3rem + 0px) * var(--velt-base-rem-unit)) calc((1.5rem + 0px) * var(--velt-base-rem-unit)) #0000002e!important} .snippyly-tag-autocomplete-panel::-webkit-scrollbar{display:none!important;width:0!important;height:0!important} .snippyly-tag-autocomplete-panel::-webkit-scrollbar{width:0;height:0} .snippyly-tag-autocomplete-panel::-webkit-scrollbar-button{width:0;height:0} .snippyly-tag-autocomplete-panel .user-selection-container{background:#fff;border-radius:8px;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) 0!important} .snippyly-tag-autocomplete-panel .user-selection-container .mat-mdc-option{padding:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important} .snippyly-tag-autocomplete-panel .user-selection-container .mat-mdc-option.mat-mdc-option-active{background-color:#f2f2f2!important}.contact-container[_ngcontent-%COMP%]{display:flex;align-items:center}.photo-container[_ngcontent-%COMP%]{min-width:calc((2.5rem + 0px) * var(--velt-base-rem-unit));width:calc((2.5rem + 0px) * var(--velt-base-rem-unit));min-height:calc((2.5rem + 0px) * var(--velt-base-rem-unit));height:calc((2.5rem + 0px) * var(--velt-base-rem-unit));box-sizing:border-box;background-clip:padding-box;border:solid 2px transparent;display:flex;align-items:center;justify-content:center;position:relative;margin-right:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}.photo-container-small[_ngcontent-%COMP%]{width:calc((2rem + 0px) * var(--velt-base-rem-unit));height:calc((2rem + 0px) * var(--velt-base-rem-unit));min-width:calc((2rem + 0px) * var(--velt-base-rem-unit));min-height:calc((2rem + 0px) * var(--velt-base-rem-unit));margin-right:calc((.8rem + 0px) * var(--velt-base-rem-unit))!important}.photo-container[_ngcontent-%COMP%]:before{content:"";position:absolute;inset:0;z-index:1;border-radius:inherit;background:inherit}.photo-container[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:100%;height:100%;border-radius:50%;z-index:2;object-fit:cover}.contact-details[_ngcontent-%COMP%]{overflow:hidden}.contact-details[_ngcontent-%COMP%] .contact-name[_ngcontent-%COMP%], .contact-details[_ngcontent-%COMP%] .contact-email[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;line-height:calc((1rem + 0px) * var(--velt-base-rem-unit));font-size:calc((.875rem + 0px) * var(--velt-base-rem-unit))!important}.contact-details[_ngcontent-%COMP%] .contact-email[_ngcontent-%COMP%]{color:#6c757d!important}.photo-placeholder[_ngcontent-%COMP%]{z-index:2;opacity:.8}.tag-buttons-container[_ngcontent-%COMP%]{display:flex;flex-direction:row;align-items:center;padding-top:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;background:#fff}.tag-button[_ngcontent-%COMP%]{background-color:#625df5;color:#fff!important;border:0;border-radius:4px;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) calc((1rem + 0px) * var(--velt-base-rem-unit))!important;margin-right:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;cursor:pointer!important}.tag-button[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{color:#fff!important}.tag-button.green[_ngcontent-%COMP%]{background-color:#0dcf82!important}.tag-button[_ngcontent-%COMP%]:hover{background-color:#44aeff!important;color:#fff!important}.tag-button[_ngcontent-%COMP%]:hover.green{background-color:#10b372!important}.tag-button[disabled][_ngcontent-%COMP%], .tag-button[disabled][_ngcontent-%COMP%]:hover{background-color:#0000001a!important;color:#0006!important}.cancel-button[_ngcontent-%COMP%]{border:0;border-radius:4px;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) calc((1rem + 0px) * var(--velt-base-rem-unit))!important;margin-right:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;cursor:pointer!important}.cancel-button[_ngcontent-%COMP%]:hover{color:#e91e63}.no-contacts-message[_ngcontent-%COMP%]{text-align:center!important} .tag-input-container velt-autocomplete-panel-internal{width:100%!important} .tag-input-container velt-autocomplete-panel-internal input{width:100%!important;border:0!important}'],changeDetection:0});let a=r;return a})();var tn=["overlay"],en=["pin"],nn=(a,r)=>({"tag-pin-selected":a,"mutiple-pins-selected":r}),on=()=>["snippyly-overlay-panel","snippyly-tag-dialog-overlay-panel","velt-overlay-panel"];function rn(a,r){a&1&&(W(),z(0,"path",8))}function an(a,r){if(a&1){let o=x();_(0,"snippyly-user-avatar",9),A("pointerover",function(e){return T(o),h().onPointerOver(e),S(e.stopPropagation())})("pointerout",function(){T(o);let e=h();return S(e.onPointerOut())}),P()}if(a&2){let o=h();u("user",o.tagPinAnnotation==null?null:o.tagPinAnnotation.to[0])("background","rgb(162, 89, 254) !important")("size",26)}}function sn(a,r){if(a&1){let o=x();_(0,"snippyly-tag-dialog",10),A("saveTag",function(e){T(o);let n=h();return S(n.saveTag.emit(e))}),P()}if(a&2){let o=h();u("annotation",o.tagPinAnnotation)("user",o.user)("tagPinSelected",o.tagPinSelected)}}var At=(()=>{let r=class r{get tagPinAnnotation(){return this._tagPinAnnotation}set tagPinAnnotation(t){this._tagPinAnnotation=t}get tagPinSelected(){return this._tagPinSelected}set tagPinSelected(t){this._tagPinSelected=t,this.updateHighlightOnElement()}get tagPinHover(){return this._tagPinHover}set tagPinHover(t){this._tagPinHover=t,this.updateHighlightOnElement()}constructor(t,e,n){this.tagService=t,this.domService=e,this.loggingService=n,this._tagPinSelected=!1,this.multipleTagPinsSelected=!1,this.avatarErrorImage="",this.deleteTagThread=new at,this.saveTag=new at,this.signInToAccessFeature=new at,this.overlayOriginX="start",this.overlayOriginY="top",this._tagPinHover=!1,this.subscriptions=[],this.positions=d.OVERLAY_POSITIONS.map(i=>new Zt({originX:i.originX,originY:i.originY},{overlayX:i.overlayX,overlayY:i.overlayY})),this.veltElement=!0,this.loggingService.log("%c[WB] Creating COMPONENT TagPinComponent","color: blue;")}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{this.updateHighlightOnElement(),this.subscriptions.push(this.overlay.positionChange.subscribe(t=>{this.overlayOriginX=t.connectionPair.originX,this.overlayOriginY=t.connectionPair.originY},t=>{this.loggingService.catch("Error in TagPinComponent positionChange subscription: ",t)}))}catch(t){this.loggingService.catch("Error in TagPinComponent AfterViewInit: ",t)}}updateHighlightOnElement(){try{this.targetElement&&(this.tagPinSelected||this.tagPinHover?this.domService.highlightElement(this.targetElement):this.domService.removeHighlightFromElement(this.targetElement))}catch(t){this.loggingService.catch("Error in TagPinComponent updateHighlightOnElement: ",t)}}onPointerOver(t){try{t.buttons?this.tagPinHover&&(this.tagPinHover=!1):this.tagPinHover||(this.tagPinHover=!0)}catch(e){this.loggingService.catch("Error in TagPinComponent onPointerOver: ",e)}}onPointerOut(){this.tagPinHover=!1}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in TagPinComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in TagPinComponent unsubscribe: ",t)}}};r.\u0275fac=function(e){return new(e||r)(m(w),m(L),m(p))},r.\u0275cmp=k({type:r,selectors:[["snippyly-tag-pin"]],viewQuery:function(e,n){if(e&1&&(Z(tn,5),Z(en,5)),e&2){let i;tt(i=et())&&(n.overlay=i.first),tt(i=et())&&(n.pin=i.first)}},hostVars:1,hostBindings:function(e,n){e&2&&M("data-velt-element",n.veltElement)},inputs:{tagPinAnnotation:"tagPinAnnotation",tagPinSelected:"tagPinSelected",multipleTagPinsSelected:"multipleTagPinsSelected",avatarErrorImage:"avatarErrorImage",user:"user",targetElement:"targetElement"},outputs:{deleteTagThread:"deleteTagThread",saveTag:"saveTag",signInToAccessFeature:"signInToAccessFeature"},standalone:!1,decls:8,vars:15,consts:[["trigger","cdkOverlayOrigin"],["overlay","cdkConnectedOverlay"],["cdkOverlayOrigin","",1,"tag-pin-container",3,"click","ngClass"],["xmlns","http://www.w3.org/2000/svg","viewBox","0 0 100 100",1,"tag-pin"],["cx","50","cy","50","rx","50","ry","50",2,"stroke","rgb(0, 0, 0)","fill","rgb(162, 89, 254)","paint-order","fill","stroke-width","0px"],["d","M 24.999 77 C 24.999 77 20 77 20 72.001 C 20 66.999 24.999 51.999 50 51.999 C 75.001 51.999 80 66.999 80 72.001 C 80 77 75.001 77 75.001 77 L 24.999 77 Z M 50 47 C 61.548 47 68.764 34.5 62.991 24.499 C 60.312 19.857 55.359 17 50 17 C 38.452 17 31.236 29.5 37.009 39.499 C 39.688 44.14 44.641 47 50 47 Z","style","fill: rgb(255, 255, 255);",4,"ngIf"],["class","photo-container tag-user-avatar",3,"user","background","size","pointerover","pointerout",4,"ngIf"],["cdkConnectedOverlay","",3,"cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayPanelClass","cdkConnectedOverlayOffsetY","cdkConnectedOverlayBackdropClass","cdkConnectedOverlayLockPosition","cdkConnectedOverlayPositions","cdkConnectedOverlayGrowAfterOpen"],["d","M 24.999 77 C 24.999 77 20 77 20 72.001 C 20 66.999 24.999 51.999 50 51.999 C 75.001 51.999 80 66.999 80 72.001 C 80 77 75.001 77 75.001 77 L 24.999 77 Z M 50 47 C 61.548 47 68.764 34.5 62.991 24.499 C 60.312 19.857 55.359 17 50 17 C 38.452 17 31.236 29.5 37.009 39.499 C 39.688 44.14 44.641 47 50 47 Z",2,"fill","rgb(255, 255, 255)"],[1,"photo-container","tag-user-avatar",3,"pointerover","pointerout","user","background","size"],[3,"saveTag","annotation","user","tagPinSelected"]],template:function(e,n){if(e&1){let i=x();_(0,"div",2,0),A("click",function(s){return T(i),S(s.preventDefault())}),W(),_(2,"svg",3),z(3,"ellipse",4),O(4,rn,1,0,"path",5),P(),O(5,an,1,3,"snippyly-user-avatar",6),P(),O(6,sn,1,3,"ng-template",7,1,nt)}if(e&2){let i=N(1);u("ngClass",Gt(11,nn,n.tagPinSelected,n.multipleTagPinsSelected)),v(4),u("ngIf",!(!(n.tagPinAnnotation==null||n.tagPinAnnotation.to==null)&&n.tagPinAnnotation.to.length&&(!(n.tagPinAnnotation==null||n.tagPinAnnotation.to[0]==null)&&n.tagPinAnnotation.to[0].photoUrl))),v(),u("ngIf",n.tagPinAnnotation==null||n.tagPinAnnotation.to==null?null:n.tagPinAnnotation.to.length),v(),u("cdkConnectedOverlayOrigin",i)("cdkConnectedOverlayOpen",n.tagPinSelected||n.tagPinHover)("cdkConnectedOverlayPanelClass",jt(14,on))("cdkConnectedOverlayOffsetY",n.overlayOriginY==="top"?-8:2)("cdkConnectedOverlayBackdropClass","snippyly-overlay-backdrop")("cdkConnectedOverlayLockPosition",!1)("cdkConnectedOverlayPositions",n.positions)("cdkConnectedOverlayGrowAfterOpen",!0)}},dependencies:[Wt,H,ee,te,Ee,It],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;height:unset;width:unset;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}.tag-pin-container[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:32px;height:32px;text-align:center;color:#fff;font-size:calc((.8rem + 0px) * var(--velt-base-rem-unit));font-weight:500;cursor:pointer}.tag-pin[_ngcontent-%COMP%]{position:absolute;left:0;top:0;width:32px;height:32px;transition:left .12s ease-in-out,top .12s ease-in-out,width .12s ease-in-out,height .12s ease-in-out,transform .12s ease-in-out}.tag-pin-container[_ngcontent-%COMP%]:hover{filter:brightness(110%) saturate(110%)}.tag-pin-container[_ngcontent-%COMP%]:hover .tag-pin[_ngcontent-%COMP%], .tag-pin-selected[_ngcontent-%COMP%] .tag-pin[_ngcontent-%COMP%], .tag-pin-container[_ngcontent-%COMP%]:hover .photo-container[_ngcontent-%COMP%], .tag-pin-selected[_ngcontent-%COMP%] .photo-container[_ngcontent-%COMP%]{transform:scale(1.2) translateY(-4px);transition:left .12s ease-in-out,top .12s ease-in-out,width .12s ease-in-out,height .12s ease-in-out,transform .12s ease-in-out}.tag-index[_ngcontent-%COMP%]{position:absolute;border-radius:50%;border:1px solid #fff;width:20px;height:20px;text-align:center;top:-8px;right:-8px;font-size:calc((.8rem + 0px) * var(--velt-base-rem-unit));color:#000;background:#fff}.tag-pin-selected[_ngcontent-%COMP%]{filter:brightness(110%) saturate(110%)}.tag-resolved[_ngcontent-%COMP%]{background-color:#0dcf82!important}.bi-check-lg[_ngcontent-%COMP%]{color:#fff}.mutiple-pins-selected[_ngcontent-%COMP%]{border-color:#9746ff!important}.photo-container[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;position:absolute;width:32px;height:32px;box-sizing:border-box;background-clip:padding-box;border-radius:50%;padding:calc((.2rem + 0px) * var(--velt-base-rem-unit))!important;transition:top .12s ease-in-out,width .12s ease-in-out,height .12s ease-in-out,transform .12s ease-in-out;text-transform:capitalize}.photo-container[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:100%;height:100%;border-radius:50%;object-fit:cover}.photo-placeholder[_ngcontent-%COMP%]{z-index:2;opacity:.8} snippyly-user-avatar.tag-user-avatar{background-color:#a259fe!important} snippyly-user-avatar.tag-user-avatar .s-user-avatar-initial{font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important} .snippyly-tag-dialog-overlay-panel{z-index:2147483567!important}"],changeDetection:0});let a=r;return a})();function ln(a,r){if(a&1){let o=x();_(0,"div",1),A("pointerup",function(e){return T(o),h().togglePinSelection(),S(e.stopPropagation())})("pointerdown",function(e){return T(o),S(e.stopPropagation())})("click",function(e){return T(o),S(e.stopPropagation())})("cdkDragStarted",function(){T(o);let e=h();return S(e.onPinDragStart())})("cdkDragMoved",function(e){T(o);let n=h();return S(n.onPinMove(e))})("cdkDragReleased",function(){T(o);let e=h();return S(e.onPinRelease())}),_(1,"snippyly-tag-pin",2),A("saveTag",function(e){T(o);let n=h();return S(n.saveTag(e))}),P()()}if(a&2){let o=h();Vt("top",o.annotationDraging?(o.dragPosition==null?null:o.dragPosition.top)-16:(o.tagPinAnnotation==null||o.tagPinAnnotation.position==null?null:o.tagPinAnnotation.position.top)-16+o.offsetTop,"px")("left",o.annotationDraging?(o.dragPosition==null?null:o.dragPosition.left)-16:(o.tagPinAnnotation==null||o.tagPinAnnotation.position==null?null:o.tagPinAnnotation.position.left)-16+o.offsetLeft,"px"),st("pin-dragging",o.annotationDraging),u("id","tag-pin-contianer-"+(o.tagPinAnnotation==null?null:o.tagPinAnnotation.annotationId))("cdkDragDisabled",(o.tagPinAnnotation==null||o.tagPinAnnotation.from==null?null:o.tagPinAnnotation.from.userId)!==(o.user==null?null:o.user.userId)),v(),u("tagPinAnnotation",o.tagPinAnnotation)("tagPinSelected",o.selectedAnnotationsMap[o.tagPinAnnotation==null?null:o.tagPinAnnotation.annotationId]&&!o.annotationDraging&&o.objectKeys(o.selectedAnnotationsMap).length===1)("multipleTagPinSelected",o.selectedAnnotationsMap[o.tagPinAnnotation==null?null:o.tagPinAnnotation.annotationId]&&o.objectKeys(o.selectedAnnotationsMap).length>1)("targetElement",o.targetElement)("user",o.user)}}var Ot=(()=>{let r=class r{get tagPinAnnotation(){return this._tagPinAnnotation}set tagPinAnnotation(t){this._tagPinAnnotation=t,this.id=t.annotationId}constructor(t,e,n,i,l){this.analyticsService=t,this.authService=e,this.domService=n,this.tagService=i,this.loggingService=l,this.multipleTagPinsSelected=!1,this.avatarErrorImage="",this.offsetLeft=0,this.offsetTop=0,this.objectKeys=Object.keys,this.selectedAnnotationsMap={},this.subscriptions=[],this.annotationDraging=!1,this.dragPosition=null,this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(s=>{this.user=s},s=>{this.loggingService.catch("Error in TagPinPortalComponent getUser$ subscription: ",s)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(s=>{this.selectedAnnotationsMap=s},s=>{this.loggingService.catch("Error in TagPinPortalComponent getSelectedAnnotationsMap$ subscription: ",s)}))}ngOnInit(){}togglePinSelection(){try{this.domService.toggleAnnotationSelection(this.tagPinAnnotation)}catch(t){this.loggingService.catch("Error in TagPinPortalComponent togglePinSelection: ",t)}}onPinDragStart(){this.selectedAnnotationsMap[this.tagPinAnnotation.annotationId]&&this.domService.toggleAnnotationSelection(this.tagPinAnnotation);let t=document.getElementById(this.tagPinAnnotation.annotationId);t&&(this.parentElement=t.parentElement,document.body.appendChild(t)),this.annotationDraging=!0}onPinMove(t){try{this.updateCurrentPinPosition(t)}catch(e){this.loggingService.catch("Error in TagPinPortalComponent onPinMove: ",e)}}updateCurrentPinPosition(t){try{this.domService.removeHighlightFromElement(this.targetElement);let e=t.event,n=e?.touches?.length?e.touches[0]?.clientX:e.clientX,i=e?.touches?.length?e.touches[0]?.clientY:e.clientY,l=this.domService.getBackgroundElement(n,i);l&&(this.targetElement=l,this.domService.highlightElement(this.targetElement),this.pointerMoveEvent=t.event,this.dragPosition={top:i,left:n})}catch(e){this.loggingService.catch("Error in TagPinPortalComponent updateCurrentPinPosition: ",e)}}onPinRelease(){try{let t=document.getElementById(this.tagPinAnnotation.annotationId);t&&this.parentElement&&this.parentElement.appendChild(t);let e=this.domService.getElementFromXPath(this.tagPinAnnotation.targetElement?.xpath);this.pointerMoveEvent&&(this.tagPinAnnotation.targetElement=this.domService.getTargetElementForCursorPosition(this.pointerMoveEvent));let n=this.domService.getElementFromXPath(this.tagPinAnnotation.targetElement?.xpath),i=this.domService.isElementInsideAdditionalLocationContainer(e)||this.domService.isElementInsideAdditionalLocationContainer(n);this.tagService.updateTag(this.tagPinAnnotation,!1,i),setTimeout(()=>{this.annotationDraging=!1,this.dragPosition=null,this.domService.removeHighlightFromElement(this.targetElement)},100),this.analyticsService.trackEvent(b.Events.Tag.TAG_DRAGGED,{annotationId:this.tagPinAnnotation.annotationId})}catch(t){this.loggingService.catch("Error in TagPinPortalComponent onPinRelease: ",t)}}saveTag(t){}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in TagPinPortalComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in TagPinPortalComponent unsubscribe: ",t)}}};r.\u0275fac=function(e){return new(e||r)(m(B),m(U),m(L),m(w),m(p))},r.\u0275cmp=k({type:r,selectors:[["snippyly-tag-pin-portal"]],hostVars:2,hostBindings:function(e,n){e&2&&(Rt("id",n.id),M("data-velt-element",n.veltElement))},inputs:{tagPinAnnotation:"tagPinAnnotation",multipleTagPinsSelected:"multipleTagPinsSelected",avatarErrorImage:"avatarErrorImage",user:"user",offsetLeft:"offsetLeft",offsetTop:"offsetTop",targetElement:"targetElement"},standalone:!1,decls:1,vars:1,consts:[["class","tag-pin-portal","cdkDrag","","cdkDragHandle","",3,"id","pin-dragging","top","left","cdkDragDisabled","pointerup","pointerdown","click","cdkDragStarted","cdkDragMoved","cdkDragReleased",4,"ngIf"],["cdkDrag","","cdkDragHandle","",1,"tag-pin-portal",3,"pointerup","pointerdown","click","cdkDragStarted","cdkDragMoved","cdkDragReleased","id","cdkDragDisabled"],[3,"saveTag","tagPinAnnotation","tagPinSelected","multipleTagPinSelected","targetElement","user"]],template:function(e,n){e&1&&O(0,ln,2,13,"div",0),e&2&&u("ngIf",n.tagPinAnnotation==null?null:n.tagPinAnnotation.position)},dependencies:[H,Kt,Xt,At],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}[_nghost-%COMP%]{position:absolute!important;top:0!important;left:0!important;box-sizing:border-box!important;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;height:unset!important;width:unset!important;text-align:left!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;height:unset;width:unset;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}.tag-pin-portal[_ngcontent-%COMP%]{position:absolute;transform:none!important;transform-origin:0 0!important;transform-box:fill-box!important;top:0;left:0}.tag-pin-portal.pin-dragging[_ngcontent-%COMP%]{position:fixed;z-index:2147483557!important}"],changeDetection:0});let a=r;return a})();var xe=(()=>{let r=class r{constructor(t,e,n,i,l){this.domService=t,this.componentFactoryResolver=e,this.injector=n,this.appRef=i,this.loggingService=l,this.tagsPinById={}}setTagPin(t){try{if(!this.tagsPinById[t.annotationId])this.setPinPortal(t);else if(t.targetElement?.xpath===this.tagsPinById[t.annotationId]?.annotation?.targetElement?.xpath){let e=this.tagsPinById[t.annotationId].portalRef,n=this.tagsPinById[t.annotationId].userTargetElement,i=this.tagsPinById[t.annotationId].pinHostElement;if(document.body.contains(n)&&document.body.contains(i))e&&(e.instance.tagPinAnnotation=JSON.parse(JSON.stringify(t)),this.updateElementOffset(t));else{let l=this.tagsPinById[t.annotationId].pinHostDomPortalOutlet;l&&(this.tagsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST),this.tagsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST_STATIC),l.detach(),delete this.tagsPinById[t.annotationId],this.setPinPortal(t))}}else{let e=this.tagsPinById[t.annotationId].pinHostDomPortalOutlet;e&&(this.tagsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST),this.tagsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST_STATIC),e.detach(),delete this.tagsPinById[t.annotationId],this.setPinPortal(t))}}catch(e){this.loggingService.catch("Error in TagPinPortalService setTagPin: ",e)}}setPinPortal(t){try{let e=this.domService.getXPath(t.targetElement?.xpath);if(e){let n=e.iterateNext();if(n){let i=this.domService.getHostElement(n),l=new Qt(Ot),s=new qt(i,this.appRef,this.injector),c=s.attach(l);c.instance.tagPinAnnotation=JSON.parse(JSON.stringify(t)),c.instance.targetElement=n,this.tagsPinById[t.annotationId]={pinHostDomPortalOutlet:s,pinPortal:l,portalRef:c,annotation:JSON.parse(JSON.stringify(t)),userTargetElement:n,pinHostElement:i},i.setAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST,t.annotationId),window.getComputedStyle(i).position==="static"&&(me(i)||i.setAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST_STATIC,"true")),this.updateElementOffset(t)}}}catch(e){this.loggingService.catch("Error in TagPinPortalService setPinPortal: ",e)}}updateElementOffset(t){try{let{portalRef:e,userTargetElement:n,pinHostElement:i}=this.tagsPinById[t.annotationId],l=this.domService.getElementOffset(n,i);e.instance.offsetLeft=l.offsetLeft,e.instance.offsetTop=l.offsetTop}catch(e){this.loggingService.catch("Error in TagPinPortalService updateElementOffset: ",e)}}checkPinsToRemove(t){try{let e=t.map(n=>n.annotationId);Object.keys(this.tagsPinById).forEach(n=>{if(!e.includes(n)){let i=this.tagsPinById[n];i.pinHostDomPortalOutlet.detach(),i.pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST),i.pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_TAG_PIN_HOST_STATIC),this.domService.removeHighlightFromElement(i.pinHostElement),delete this.tagsPinById[n]}})}catch(e){this.loggingService.catch("Error in TagPinPortalService checkPinsToRemove: ",e)}}};r.\u0275fac=function(e){return new(e||r)(f(L),f(Dt),f(xt),f(Bt),f(p))},r.\u0275prov=rt({token:r,factory:r.\u0275fac,providedIn:"root"});let a=r;return a})();var mt=(()=>{let r=class r{get pinHighlighterClass(){return this._pinHighlighterClass}set pinHighlighterClass(t){this._pinHighlighterClass=t,this.domService.setPinHighlighterClass(t)}constructor(t,e,n,i,l,s){this.analyticsService=t,this.authService=e,this.domService=n,this.tagService=i,this.tagPinPortalService=l,this.loggingService=s,this._pinHighlighterClass=null,this.tagPinAnnotations=[],this.subscriptions=[],this.isFirstComponent=!0,this.selectedAnnotationsMap={},this.tagAnnotationFocused=!1,this.veltId=ce(),this.veltElement=!0;try{this.loggingService.log("%c[WB] Creating CLASS: TagsContainerComponent","color: blue;");let c=new URL(window.location.href);this.focusTagAnnotationId=c.searchParams.get(d.URL_PARAMS.TAG_ID)}catch(c){this.loggingService.catch("Error in TagsContainerComponent constructor: ",c)}}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{let t=document.querySelector(d.TAGS.SNIPPYLY_TAGS),e=document.querySelector(d.TAGS.VELT_TAGS);e?this.veltId===e?.getAttribute(d.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent()):this.veltId===t?.getAttribute(d.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent())}catch(t){this.loggingService.catch("Error in TagsContainerComponent AfterViewInit: ",t)}}initComponent(){try{this.subscriptions.push(this.authService.getUser$().pipe(D(t=>!!t)).subscribe(t=>{t&&this.setTagInstalledInAnalytics()},t=>{this.loggingService.catch("Error in getUser: ",t)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(t=>{this.selectedAnnotationsMap=t},t=>{this.loggingService.catch("Error in TagsContainerComponent getSidebarVisibility$ subscription: ",t)})),this.getAllTagsOnCurrentDocument()}catch(t){this.loggingService.catch("Error in TagsContainerComponent initComponent: ",t)}}getAllTagsOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllTagsOnCurrentDocument","color: green;");try{this.subscriptions.push(this.tagService.getAllTagAnnotations().pipe(D(t=>!!t),C(t=>this.domService.getSelectedAnnotationsMap$().pipe(I(e=>({annotations:t,selectedAnnotationsMap:e||{}}))))).subscribe(t=>{try{this.loggingService.log(t),this.tagPinAnnotations=t?.annotations;let e=this.tagPinAnnotations.filter(n=>n.targetElement);e=e.filter(n=>!(n.resolved&&!t.selectedAnnotationsMap[n.annotationId])),this.tagPinPortalService.checkPinsToRemove(e),e.forEach(n=>{this.tagPinPortalService.setTagPin(n)}),this.focusTagAnnotation()}catch(e){this.loggingService.catch("Error in TagsContainerComponent getAllTagsOnCurrentDocument inside subscription: ",e)}},t=>{this.loggingService.catch("Error in TagsContainerComponent getAllTagsOnCurrentDocument subscription: ",t)}))}catch(t){this.loggingService.catch("Error in TagsContainerComponent getAllTagsOnCurrentDocument: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in TagsContainerComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in TagsContainerComponent unsubscribe: ",t)}}focusTagAnnotation(){if(this.focusTagAnnotationId&&!this.tagAnnotationFocused){let t=this.tagPinAnnotations.find(e=>e.annotationId===this.focusTagAnnotationId);t&&(this.tagAnnotationFocused=!0,this.selectedAnnotationsMap[t.annotationId]||this.domService.toggleAnnotationSelection(t),setTimeout(()=>{let e=null;t.targetElement?e=document.getElementById(`tag-pin-contianer-${t.annotationId}`):e=document.querySelector(`[data-velt-id='${t.annotationId}']`),e&&e.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})},100))}}setTagInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(V.TAG)}catch(t){this.loggingService.catch("Error in TagsContainerComponent setTagInstalledInAnalytics: ",t)}}};r.\u0275fac=function(e){return new(e||r)(m(B),m(U),m(L),m(w),m(xe),m(p))},r.\u0275cmp=k({type:r,selectors:[["app-tags-container"]],hostVars:2,hostBindings:function(e,n){e&2&&M("data-velt-id",n.veltId)("data-velt-element",n.veltElement)},inputs:{pinHighlighterClass:"pinHighlighterClass"},standalone:!1,decls:0,vars:0,template:function(e,n){},encapsulation:2,changeDetection:0});let a=r;return a})();var ht=class extends Oe{constructor(r){super(r),this.getService(p).log("%c[WB] Creating CLASS: TagElement","color: blue;"),this.getAllTagAnnotations=this._getAllTagAnnotations,this.deleteTag=this._deleteTag,this.allowedElementIds=this._allowedElementIds,this.attachTag=this._attachTag,this.addTagModeChange=this._addTagModeChange}_getAllTagAnnotations(r,o){this.getService(p).log("%c[WB] Calling FUNCTION: getOnlineUsers","color: green;");try{return this.trackEvent(b.Events.Tag.GET_ALL_TAG_ANNOTATIONS_TRIGGERED,{payload:{documentId:r,location:o}}),this.getService(w).getAllTagAnnotations(r,o)}catch(t){return this.getService(p).catch("Error in _getLiveTagsOnCurrentDocument: ",t),E(null)}}_deleteTag(){this.getService(p).log("%c[WB] Calling FUNCTION: deleteTag","color: green;");try{this.trackEvent(b.Events.Tag.DELETE_TAG_TRIGGERED),this.getService(w).deleteTagPinAnnotations("tagElement")}catch(r){this.getService(p).catch("Error in _deleteTag: ",r)}}_allowedElementIds(r){this.getService(p).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(b.Events.Tag.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:r}}),this.getService(w).setAllowedElementIds(r)}catch(o){this.getService(p).catch("Error in allowedElementIds: ",o)}}_attachTag(r){this.getService(p).log("%c[WB] Calling FUNCTION: attachTag","color: green;");try{this.trackEvent(b.Events.Tag.ATTACH_TAG_TRIGGERED,{payload:{elementId:r}}),this.getService(w).attachTag(r,["id","data-id"])}catch(o){this.getService(p).catch("Error in _attachTag: ",o)}}_addTagModeChange(){this.getService(p).log("%c[WB] Calling FUNCTION: addTagModeChange","color: green;");try{return this.trackEvent(b.Events.Tag.ADD_TAG_MODE_CHANGE_TRIGGERED),this.getService(w).addTagModeChange()}catch(r){return this.getService(p).catch("Error in _addTagModeChange: ",r),E(!1)}}};var De=(()=>{let r=class r{};r.\u0275fac=function(e){return new(e||r)},r.\u0275mod=kt({type:r}),r.\u0275inj=wt({imports:[Yt,ne,Jt,Ie]});let a=r;return a})();function dn(a){a.get(p).log("%c[WB] Loading tag feature chunk","color: blue;");let t=Mt(De,a).injector;return ut(t,d.TAGS.VELT_TAG_TOOL,pt),ut(t,d.TAGS.SNIPPYLY_TAG_TOOL,pt),ut(t,d.TAGS.VELT_TAGS,mt),ut(t,d.TAGS.SNIPPYLY_TAGS,mt),new ht(a)}function ut(a,r,o){if(customElements.get(r))return;let t=ie(o,a);customElements.define(r,t)}export{dn as default};
package/velt.js CHANGED
@@ -1,7 +1,7 @@
1
- var SNIPPYLY_VERSION = '6.0.25';
1
+ var SNIPPYLY_VERSION = '6.0.26';
2
2
  Promise.allSettled||(Promise.allSettled=function(t){return Promise.all(t.map(function(r){return Promise.resolve(r).then(function(e){return{status:"fulfilled",value:e}}).catch(function(e){return{status:"rejected",reason:e}})}))});
3
3
 
4
- import{a as ws}from"./chunk-6BTXSFDP.js";import{a as Ls}from"./chunk-TMLYEZEQ.js";import{d as T}from"./chunk-R4FWZKFA.js";import{b as ko,d as re}from"./chunk-JICLHDU3.js";import"./chunk-CLRO2X6T.js";import{a as jo,d as Wo}from"./chunk-AP33ZJ2C.js";import{b as Ds,c as xs,j as Ps,q as hi,t as Ns}from"./chunk-Z7JR4TW6.js";import"./chunk-ZH5R4MP6.js";import"./chunk-LM54BOTU.js";import"./chunk-FJAMH4UH.js";import{l as Ho,m as $o,o as Xo,r as Jo,s as ts,u as is,v as rs,w as ns}from"./chunk-B3ZPP3EZ.js";import{d as Ao}from"./chunk-BJ5O5D7F.js";import{d as Zo}from"./chunk-JAKGBQ5D.js";import{a as pi}from"./chunk-JPOBXW24.js";import{a as Ms}from"./chunk-2JSXDPYO.js";import"./chunk-GB46XS3O.js";import"./chunk-FJ6KQ3QL.js";import"./chunk-W47H5WHD.js";import"./chunk-VYZZWZPY.js";import{A as Rs,B as ks,C as Pr,F as ye,G as Te,a as Ye,b as ai,f as li,g as st,i as Cs,j as ci,k as di,l as ui,m as At,n as bs,o as Ss,p as Es,q as Ts,r as Os,y as Is,z as As}from"./chunk-TN7X7OZD.js";import{a as _s}from"./chunk-NNZNLREA.js";import{a as Ke,b as xe,c as Rt,d as mi}from"./chunk-G3BZ4EU4.js";import{a as at}from"./chunk-CCZ3WXF4.js";import{a as xr}from"./chunk-LCACRBV3.js";import{Ea as es,Fa as ee,Ha as It,I as ri,l as To,na as Yo,o as Oo,p as Io,ta as bt,v as Ro,y as Dr}from"./chunk-NY2Q7SEG.js";import{a as Pe}from"./chunk-MEI3IAPO.js";import{D,o as Ot,p as ms,q as ps,s as gs,t as fs,u as vs,y as ys}from"./chunk-BR7AO7YV.js";import{$ as I,Ad as Po,Ba as Sr,Bb as B,Bd as Mo,Ca as ho,Cb as Ge,Db as je,Dd as No,E as no,Ea as mo,Ed as wo,Fa as po,Fb as Kt,Fd as Lo,Gb as Xt,Gi as g,Ha as W,Hb as Jt,Hc as ei,He as A,Ia as go,Ic as Qe,Id as Fo,Ja as Er,Jd as zo,K as oo,Kb as Or,Kd as Uo,M as so,Mb as yt,Md as qo,Nc as Ct,Pa as fo,Pb as We,Pe as ni,Qb as Ir,Qe as as,Ra as R,Rb as _t,Rd as Bo,Re as Et,Rg as cs,Sc as ti,Sd as Vo,Tc as Co,Td as Go,Uc as bo,Vc as ii,Vd as Qo,Wa as H,Wd as Ko,Xa as ke,Xc as So,Xd as St,Yc as Eo,Yd as fe,Yf as ls,Zj as si,_a as Tr,_f as oi,a as k,ab as ue,ac as Ar,b as j,ba as le,bc as De,bk as ve,c as Zn,ca as Re,cc as vo,ck as ie,d as fl,da as ao,e as Gt,ea as U,ec as Zt,ee as os,f as eo,fa as Fe,fb as Ue,g as L,hb as qe,hc as yo,i as jt,ib as Be,ja as Wt,ka as Ht,l as to,la as $t,li as ds,m as M,mc as He,na as Ee,nb as q,nc as $e,nj as Tt,oa as br,ob as $,od as Do,oj as l,pb as J,pj as V,qa as lo,qb as Z,r as x,rc as Rr,re as C,rj as us,sa as co,sc as _o,sj as hs,ub as ft,ue as ss,v as io,vb as vt,w as ro,wa as Qt,xa as uo,xb as Yt,ya as ze,zb as Ve,zc as kr,zd as xo}from"./chunk-CNB6D3KX.js";var $n=fl((Sv,Hn)=>{"use strict";var p={};p.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)};p.localCName=p.generateIdentifier();p.splitLines=function(r){return r.trim().split(`
4
+ import{a as ws}from"./chunk-6BTXSFDP.js";import{a as Ls}from"./chunk-TMLYEZEQ.js";import{d as T}from"./chunk-2KJYRR7X.js";import{b as ko,d as re}from"./chunk-JICLHDU3.js";import"./chunk-CLRO2X6T.js";import{a as jo,d as Wo}from"./chunk-AP33ZJ2C.js";import{b as Ds,c as xs,j as Ps,q as hi,t as Ns}from"./chunk-Z7JR4TW6.js";import"./chunk-ZH5R4MP6.js";import"./chunk-LM54BOTU.js";import"./chunk-FJAMH4UH.js";import{l as Ho,m as $o,o as Xo,r as Jo,s as ts,u as is,v as rs,w as ns}from"./chunk-B3ZPP3EZ.js";import{d as Ao}from"./chunk-BJ5O5D7F.js";import{d as Zo}from"./chunk-JAKGBQ5D.js";import{a as pi}from"./chunk-JPOBXW24.js";import{a as Ms}from"./chunk-2JSXDPYO.js";import"./chunk-GB46XS3O.js";import"./chunk-FJ6KQ3QL.js";import"./chunk-W47H5WHD.js";import"./chunk-VYZZWZPY.js";import{A as Rs,B as ks,C as Pr,F as ye,G as Te,a as Ye,b as ai,f as li,g as st,i as Cs,j as ci,k as di,l as ui,m as At,n as bs,o as Ss,p as Es,q as Ts,r as Os,y as Is,z as As}from"./chunk-TN7X7OZD.js";import{a as _s}from"./chunk-NNZNLREA.js";import{a as Ke,b as xe,c as Rt,d as mi}from"./chunk-G3BZ4EU4.js";import{a as at}from"./chunk-CCZ3WXF4.js";import{a as xr}from"./chunk-LCACRBV3.js";import{Ea as es,Fa as ee,Ha as It,I as ri,l as To,na as Yo,o as Oo,p as Io,ta as bt,v as Ro,y as Dr}from"./chunk-NY2Q7SEG.js";import{a as Pe}from"./chunk-MEI3IAPO.js";import{D,o as Ot,p as ms,q as ps,s as gs,t as fs,u as vs,y as ys}from"./chunk-BR7AO7YV.js";import{$ as I,Ad as Po,Ba as Sr,Bb as B,Bd as Mo,Ca as ho,Cb as Ge,Db as je,Dd as No,E as no,Ea as mo,Ed as wo,Fa as po,Fb as Kt,Fd as Lo,Gb as Xt,Gi as g,Ha as W,Hb as Jt,Hc as ei,He as A,Ia as go,Ic as Qe,Id as Fo,Ja as Er,Jd as zo,K as oo,Kb as Or,Kd as Uo,M as so,Mb as yt,Md as qo,Nc as Ct,Pa as fo,Pb as We,Pe as ni,Qb as Ir,Qe as as,Ra as R,Rb as _t,Rd as Bo,Re as Et,Rg as cs,Sc as ti,Sd as Vo,Tc as Co,Td as Go,Uc as bo,Vc as ii,Vd as Qo,Wa as H,Wd as Ko,Xa as ke,Xc as So,Xd as St,Yc as Eo,Yd as fe,Yf as ls,Zj as si,_a as Tr,_f as oi,a as k,ab as ue,ac as Ar,b as j,ba as le,bc as De,bk as ve,c as Zn,ca as Re,cc as vo,ck as ie,d as fl,da as ao,e as Gt,ea as U,ec as Zt,ee as os,f as eo,fa as Fe,fb as Ue,g as L,hb as qe,hc as yo,i as jt,ib as Be,ja as Wt,ka as Ht,l as to,la as $t,li as ds,m as M,mc as He,na as Ee,nb as q,nc as $e,nj as Tt,oa as br,ob as $,od as Do,oj as l,pb as J,pj as V,qa as lo,qb as Z,r as x,rc as Rr,re as C,rj as us,sa as co,sc as _o,sj as hs,ub as ft,ue as ss,v as io,vb as vt,w as ro,wa as Qt,xa as uo,xb as Yt,ya as ze,zb as Ve,zc as kr,zd as xo}from"./chunk-CNB6D3KX.js";var $n=fl((Sv,Hn)=>{"use strict";var p={};p.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)};p.localCName=p.generateIdentifier();p.splitLines=function(r){return r.trim().split(`
5
5
  `).map(e=>e.trim())};p.splitSections=function(r){return r.split(`
6
6
  m=`).map((t,i)=>(i>0?"m="+t:t).trim()+`\r
7
7
  `)};p.getDescription=function(r){let e=p.splitSections(r);return e&&e[0]};p.getMediaSections=function(r){let e=p.splitSections(r);return e.shift(),e};p.matchPrefix=function(r,e){return p.splitLines(r).filter(t=>t.indexOf(e)===0)};p.parseCandidate=function(r){let e;r.indexOf("a=candidate:")===0?e=r.substring(12).split(" "):e=r.substring(10).split(" ");let t={foundation:e[0],component:{1:"rtp",2:"rtcp"}[e[1]]||e[1],protocol:e[2].toLowerCase(),priority:parseInt(e[3],10),ip:e[4],address:e[4],port:parseInt(e[5],10),type:e[7]};for(let i=8;i<e.length;i+=2)switch(e[i]){case"raddr":t.relatedAddress=e[i+1];break;case"rport":t.relatedPort=parseInt(e[i+1],10);break;case"tcptype":t.tcpType=e[i+1];break;case"ufrag":t.ufrag=e[i+1],t.usernameFragment=e[i+1];break;default:t[e[i]]===void 0&&(t[e[i]]=e[i+1]);break}return t};p.writeCandidate=function(r){let e=[];e.push(r.foundation);let t=r.component;t==="rtp"?e.push(1):t==="rtcp"?e.push(2):e.push(t),e.push(r.protocol.toUpperCase()),e.push(r.priority),e.push(r.address||r.ip),e.push(r.port);let i=r.type;return e.push("typ"),e.push(i),i!=="host"&&r.relatedAddress&&r.relatedPort&&(e.push("raddr"),e.push(r.relatedAddress),e.push("rport"),e.push(r.relatedPort)),r.tcpType&&r.protocol.toLowerCase()==="tcp"&&(e.push("tcptype"),e.push(r.tcpType)),(r.usernameFragment||r.ufrag)&&(e.push("ufrag"),e.push(r.usernameFragment||r.ufrag)),"candidate:"+e.join(" ")};p.parseIceOptions=function(r){return r.substring(14).split(" ")};p.parseRtpMap=function(r){let e=r.substring(9).split(" "),t={payloadType:parseInt(e.shift(),10)};return e=e[0].split("/"),t.name=e[0],t.clockRate=parseInt(e[1],10),t.channels=e.length===3?parseInt(e[2],10):1,t.numChannels=t.channels,t};p.writeRtpMap=function(r){let e=r.payloadType;r.preferredPayloadType!==void 0&&(e=r.preferredPayloadType);let t=r.channels||r.numChannels||1;return"a=rtpmap:"+e+" "+r.name+"/"+r.clockRate+(t!==1?"/"+t:"")+`\r
package/chunk-IXIU5ZJS.js DELETED
@@ -1 +0,0 @@
1
- import{b as $,c as z,d as U,e as H,f as j}from"./chunk-AP33ZJ2C.js";import{A as J,b as Y,n as O,q as Z}from"./chunk-BR7AO7YV.js";import{Ej as _,Gi as k,He as K,Ie as V,Rj as G,Sj as q,Vj as M,Wj as W,Yd as S,Zj as X,_d as E,_j as Q,a as b,ba as A,bf as x,ck as T,ea as g,ee as R,g as p,i as L,na as N,oj as y,pj as w,qj as C,sa as P,ug as F}from"./chunk-CNB6D3KX.js";var de=1e4,pe=6e4,ee=3e4,ge=3e4,me=900*1e3;function te(s){let n=Math.max(0,Math.min(Math.floor(Number.isFinite(s)?s:1)-1,16));return Math.min(ge*2**n,me)}var fe=3600*1e3,re=250,ie=1200*1e3,Ae=1024,Se={fetch:(s,n)=>fetch(s,n)},ve="The browser could not send the file to the storage URL the gateway signed. The usual cause is the storage account's CORS rules, which must allow this page's origin for PUT; they are set by the operator of the deployment, not by the SDK.",oe="The browser could not read the file from the storage URL the gateway signed. The usual cause is the storage account's CORS rules, which must allow this page's origin for GET; they are set by the operator of the deployment, not by the SDK.",m=class extends Error{constructor(n,d){super(d),this.code=n,this.name="PortableAttachmentError"}};function v(s){return!!s&&!s.url&&s.isAttachmentResolverUsed!==!0&&typeof s.bucketPath=="string"&&s.bucketPath.length>0&&s.attachmentId!==void 0&&s.attachmentId!==null&&String(s.attachmentId).length>0}function be(s,n,d){let e={organizationId:n,documentId:d};return typeof s?.name=="string"&&s.name.length>0&&s.name.length<=Ae&&(e.fileName=s.name),typeof s?.type=="string"&&s.type.length>0&&(e.contentType=s.type),Number.isInteger(s?.size)&&s.size>=0&&(e.sizeBytes=s.size),e}function ye(s){return typeof s=="string"&&/^[A-Za-z0-9._-]{1,128}$/.test(s)&&!/^\.+$/.test(s)}function we(s){return!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.values(s).every(n=>typeof n=="string")}function Te(s){let n=s;return!n||typeof n!="object"||!ye(n.attachmentId)||typeof n.key!="string"||!n.key||typeof n.url!="string"||!C(n.url)||n.method!=="PUT"||!we(n.headers)?null:{attachmentId:n.attachmentId,key:n.key,url:n.url,method:"PUT",headers:b({},n.headers),expiresAtMs:typeof n.expiresAtMs=="number"?n.expiresAtMs:0}}function Ie(s){let n=s;return!n||typeof n!="object"||typeof n.url!="string"||!C(n.url)?null:{key:typeof n.key=="string"?n.key:"",url:n.url,expiresAtMs:typeof n.expiresAtMs=="number"&&Number.isFinite(n.expiresAtMs)?n.expiresAtMs:0}}function Pe(s,n,d){let e=Number.isFinite(s)?s-(n+(Number.isFinite(d)?d:0)):0;return n+Math.min(Math.max(e,0),fe)}var se=(()=>{let n=class n{constructor(e,t){this.injector=e,this.loggingService=t,this.urlGeneration=P(0),this.urlKeyVersions=new Map,this.userWatched=!1,this.watchedUserId=null,this.urlCache=new Map,this.urlInFlight=new Map,this.urlFailures=new Map,this.urlMissing=new Set,this.cacheOwner=null,this.attachmentsAnnounced=!1,this.hookedRealtime=null,this.offCapabilities=null,this.availabilityListeners=new Set,this.veltStorageRefusalsReported=new Set,this.reportedOpFailures=new Set,this.invalidReadUrlReported=!1,this.hotPathReported=new Set,this.portableSessionSeen=!1}get selector(){return this._selector??=this.injector.get(W)}get auth(){return this._auth??=this.injector.get(T)}get config(){return this._config??=this.injector.get(w)}isPortableSession(){try{if(!this.auth.getPortableBackend?.())return!1;let e=this.selector.isPortableSession()===!0;return e&&(this.portableSessionSeen=!0),e}catch(e){return this.loggingService.catch("Error in PortableAttachmentStorageService isPortableSession: ",e,void 0,!0),!1}}isPortableAttachmentDeployment(){if(this.isPortableSession())return!0;if(!this.portableSessionSeen)return!1;try{return this.config.getEnablePortableBackend()===!0}catch(e){return this.loggingService.catch("Error in PortableAttachmentStorageService isPortableAttachmentDeployment: ",e,void 0,!0),!0}}captureSessionUser(){return this.isPortableSession()?this.currentUserId():null}isSameSessionUser(e){return this.isSameSession(e??null)}isPortableAttachment(e){return v(e)&&this.isPortableSession()}upload(l){return p(this,arguments,function*({attachment:e,file:t,scope:r,sessionUserId:i}){let o=this.scopeIds(r);if(!o)throw this.notSent("upload","the comment has no organization or document id");let c=i===void 0?this.currentUserId():i;if(!c)throw this.notSent("upload","no user is signed in");if(!this.isSameSession(c))throw this.notSent("upload","the session changed before the upload started");if(!(yield this.waitForActiveBackend())||!this.isSameSession(c))throw this.notSent("upload","the portable backend is not active");let a=yield this.callOp("getUploadUrl",be(t,o.organizationId,o.documentId));if(!this.isSameSession(c))throw this.dropped("the session changed while getUploadUrl ran; the file was not uploaded");if(!a?.ok){this.reportOpFailure("getUploadUrl",a);let u=`${a?.code??"unknown"}${a?.message?` (${a.message})`:""}`;throw new m(a?.code??"failed-precondition",O(a)?`Tier B comment attachments are not available on this deployment: getUploadUrl answered ${u}`:`Tier B getUploadUrl failed: ${u}`)}let h=Te(a.data);if(!h){let u=new m("failed-precondition",'Tier B getUploadUrl answered a signed upload this SDK will not use (it needs method PUT, an https URL, string headers, an attachmentId of 1-128 letters, digits, ".", "_" or "-", and a key); the file was not uploaded');throw this.loggingService.catch(u.message,void 0,void 0,!0),u}if(yield this.putSignedUpload(h,t),!this.isSameSession(c))throw this.dropped("the session changed while the file uploaded; the attachment is not added");return e.attachmentId=h.attachmentId,e.bucketPath=h.key,e.url="",e.clientOrganizationId=o.organizationId,e.clientDocumentId=o.documentId,e})}putSignedUpload(e,t){return p(this,null,function*(){let r=typeof AbortController=="function"?new AbortController:null,i=null,l=new Promise((o,c)=>{i=setTimeout(()=>{r?.abort(),c(new m("put-failed",`Tier B attachment upload failed: the storage did not answer the PUT within ${ie/6e4} minutes`))},ie)});try{let o=yield Promise.race([Se.fetch(e.url,b({method:"PUT",headers:b({},e.headers),body:t.slice(0,t.size,""),redirect:"error",credentials:"omit",referrerPolicy:"no-referrer"},r?{signal:r.signal}:{})),l]);if(!o?.ok)throw new m("put-failed",`Tier B attachment upload failed: the storage answered the PUT with HTTP ${o?.status}`)}catch(o){let c=o instanceof m?o:new m("put-failed",`Tier B attachment upload failed in transport: ${o?.message??o}. ${ve}`);throw this.loggingService.catch(c.message,void 0,void 0,!0),c}finally{i!==null&&clearTimeout(i)}})}refuseVeltStorage(e){let t=new m("unimplemented",`Tier B ${e} was not sent: media outside comment attachments (recorder, tag) is not served by the portable backend, and Velt's storage is never used on a portable deployment`);try{this.veltStorageRefusalsReported.has(e)?this.loggingService.log(t.message):(this.veltStorageRefusalsReported.add(e),this.loggingService.catch(t.message,void 0,void 0,!0))}catch{}return t}delete(r){return p(this,arguments,function*({attachment:e,scope:t}){try{let i=this.attachmentIds(e,t),l=e?.attachmentId;if(!i||l===void 0||l===null||String(l).length===0){this.loggingService.catch("Tier B deleteAttachment was not sent: the attachment has no id, or the comment no organization or document id",void 0,void 0,!0);return}let o=this.currentUserId();if(!o||!(yield this.waitForActiveBackend())||!this.isSameSession(o)){this.loggingService.catch("Tier B deleteAttachment was not sent: the portable backend is not active",void 0,void 0,!0);return}let c=yield this.callOp("deleteAttachment",{organizationId:i.organizationId,documentId:i.documentId,attachmentId:String(l)});c?.ok||this.reportOpFailure("deleteAttachment",c)}catch(i){this.loggingService.catch("Error in PortableAttachmentStorageService delete: ",i,void 0,!0)}})}resolveDownloadUrl(e,t){try{if(!this.isPortableAttachment(e))return Promise.resolve(e?.url||null);let r=this.urlContext(e,t);if(!r||this.urlMissing.has(r.key))return Promise.resolve(null);let i=this.urlCache.get(r.key);return i&&this.isFresh(i,Date.now())?Promise.resolve(i.url):this.fetchDownloadUrl(r.key,e,r.ids,r.userId,!1)}catch(r){return this.loggingService.catch("Error in PortableAttachmentStorageService resolveDownloadUrl: ",r,void 0,!0),Promise.resolve(null)}}getDisplayUrl(e,t){if(!v(e))return e?.url;if(this.urlGeneration(),this.watchUser(),!this.isPortableSession())return e.url;try{let r=this.urlContext(e,t);if(!r)return e.url;if(this.keyVersion(r.key),this.urlMissing.has(r.key))return"";let i=Date.now(),l=this.urlCache.get(r.key);return l&&this.isFresh(l,i)?l.url:(this.inFailureBackoff(r.key,i)||this.fetchDownloadUrl(r.key,e,r.ids,r.userId,!1),l&&i<l.expiresAtMs?l.url:"")}catch(r){return this.loggingService.catch("Error in PortableAttachmentStorageService getDisplayUrl: ",r,void 0,!0),e.url}}isDisplayPending(e,t){if(!v(e)||!this.isPortableSession())return!1;try{if(this.getDisplayUrl(e,t))return!1;let r=this.urlContext(e,t);return!!r&&!this.urlMissing.has(r.key)&&!this.inFailureBackoff(r.key,Date.now())}catch(r){return this.loggingService.catch("Error in PortableAttachmentStorageService isDisplayPending: ",r,void 0,!0),!1}}reportLoadError(e,t,r){try{if(!this.isPortableAttachment(e))return;let i=this.urlContext(e,t),l=i?this.urlCache.get(i.key):void 0;if(!i||!l||l.afterLoadError||!r||l.url!==r)return;this.urlCache.delete(i.key),this.fetchDownloadUrl(i.key,e,i.ids,i.userId,!0),this.bumpKey(i.key)}catch(i){this.loggingService.catch("Error in PortableAttachmentStorageService reportLoadError: ",i,void 0,!0)}}fetchDownloadUrl(e,t,r,i,l){let o=this.urlInFlight.get(e);if(o)return o;let c;return c=p(this,null,function*(){try{if(!(yield this.waitForActiveBackend()))return this.recordUrlFailure(e),null;if(!this.isSameSession(i))return null;let a=this.serverTimeOffsetMs(),h=yield this.callOp("getDownloadUrl",{organizationId:r.organizationId,documentId:r.documentId,attachmentId:String(t.attachmentId)}),u=yield a;if(!this.isSameSession(i))return null;if(!h?.ok)return this.reportOpFailure("getDownloadUrl",h,!0),h?.code==="not-found"?(this.urlMissing.add(e),this.urlCache.delete(e),null):(this.recordUrlFailure(e),null);let f=Ie(h.data);if(!f)return this.invalidReadUrlReported||(this.invalidReadUrlReported=!0,console.error("Velt [portable backend]: getDownloadUrl answered a read URL that is not https (loopback http excepted); the attachment is not shown. Check the storage endpoint the gateway signs URLs for.")),this.recordUrlFailure(e),null;let I=Date.now();return this.pruneUrlCache(I),this.urlCache.set(e,{url:f.url,expiresAtMs:Pe(f.expiresAtMs,I,u),receivedAtMs:I,afterLoadError:l}),this.urlFailures.delete(e),f.url}catch(a){return this.loggingService.catch("Error in PortableAttachmentStorageService getDownloadUrl: ",a,void 0,!0),this.recordUrlFailure(e),null}finally{this.urlInFlight.get(e)===c&&this.urlInFlight.delete(e),this.bumpKey(e)}}),this.urlInFlight.set(e,c),c}isFresh(e,t){return t<e.expiresAtMs-pe||t-e.receivedAtMs<ee}inFailureBackoff(e,t){let r=this.urlFailures.get(e);return r!==void 0&&t-r.at<te(r.count)}keyVersion(e){let t=this.urlKeyVersions.get(e);return t||(t=P(0),this.urlKeyVersions.set(e,t)),t()}bumpKey(e){this.urlKeyVersions.get(e)?.update(t=>t+1)}recordUrlFailure(e){let t=(this.urlFailures.get(e)?.count??0)+1;this.urlFailures.set(e,{at:Date.now(),count:t}),setTimeout(()=>this.bumpKey(e),te(t)+50)}pruneUrlCache(e){if(!(this.urlCache.size<re)){for(let[t,r]of Array.from(this.urlCache))e>=r.expiresAtMs&&e-r.receivedAtMs>=ee&&this.urlCache.delete(t);for(let t of Array.from(this.urlCache.keys())){if(this.urlCache.size<2*re)break;this.urlCache.delete(t)}}}watchUser(){if(!this.userWatched){this.userWatched=!0;try{let e=!0;this.watchedUserId=this.currentUserId(),this.auth.getUser$().subscribe(t=>{let r=typeof t?.userId=="string"&&t.userId.length>0?t.userId:null;if(e||r===this.watchedUserId){this.watchedUserId=r;return}this.watchedUserId=r,this.urlCache.clear(),this.urlFailures.clear(),this.urlMissing.clear(),this.urlKeyVersions.clear(),this.cacheOwner=r,queueMicrotask(()=>this.urlGeneration.update(i=>i+1))}),e=!1}catch(e){this.loggingService.catch("Error in PortableAttachmentStorageService watchUser: ",e,void 0,!0)}}}serverTimeOffsetMs(){return p(this,null,function*(){try{let e=yield M()?.realtime?.getServerTimeOffset?.();return typeof e=="number"&&Number.isFinite(e)?e:0}catch{return 0}})}urlContext(e,t){let r=this.attachmentIds(e,t),i=this.currentUserId();return!r||!i?null:(this.cacheOwner!==i&&(this.urlCache.clear(),this.urlFailures.clear(),this.urlMissing.clear(),this.cacheOwner=i),{ids:r,userId:i,key:`${i}\0${r.organizationId}\0${r.documentId}\0${String(e.attachmentId)}`})}attachmentsAvailable$(){return new L(e=>{let t,r=()=>{try{let o=this.evaluateAvailability();o!==t&&(t=o,e.next(o))}catch(o){this.loggingService.catch("Error in PortableAttachmentStorageService attachmentsAvailable$: ",o,void 0,!0)}};this.hookRealtime(),this.availabilityListeners.add(r);let i=G(()=>{this.hookRealtime(),r()});r();let l=null;try{l=this.auth.getUser$().subscribe(()=>r())}catch(o){this.loggingService.catch("Error in PortableAttachmentStorageService attachmentsAvailable$ user stream: ",o,void 0,!0)}return()=>{this.availabilityListeners.delete(r),i(),l?.unsubscribe()}})}isUploadUnavailable(){try{this.hookRealtime()}catch(e){this.loggingService.catch("Error in PortableAttachmentStorageService isUploadUnavailable: ",e,void 0,!0)}return!this.evaluateAvailability()}evaluateAvailability(){return this.isPortableSession()?this.attachmentsAnnounced:!this.isPortableAttachmentDeployment()}hookRealtime(){try{let e=M()?.realtime??null;if(!e||e===this.hookedRealtime)return;this.offCapabilities?.(),this.hookedRealtime=e,this.attachmentsAnnounced=e.hasCapability?.(_)===!0,this.offCapabilities=e.onCapabilitiesChanged?.(t=>{this.attachmentsAnnounced=!!t&&typeof t.has=="function"&&t.has(_),this.notifyAvailability()})??null}catch(e){this.loggingService.catch("Error in PortableAttachmentStorageService hookRealtime: ",e,void 0,!0)}}notifyAvailability(){for(let e of Array.from(this.availabilityListeners))e()}attachmentIds(e,t){return this.scopeIds({organizationId:e?.clientOrganizationId,documentId:e?.clientDocumentId})??this.scopeIds(t)}scopeIds(e){let t=typeof e?.organizationId=="string"&&e.organizationId.length>0?e.organizationId:null,r=typeof e?.documentId=="string"&&e.documentId.length>0?e.documentId:null;return t&&r?{organizationId:t,documentId:r}:null}currentUserId(){try{let e=this.auth.getUser()?.userId;return typeof e=="string"&&e.length>0?e:null}catch{return null}}isSameSession(e){return!!e&&this.isPortableSession()&&this.currentUserId()===e}waitForActiveBackend(){return p(this,null,function*(){try{return this.selector.isPortableBackendActive()===!0?!0:(this.selector.isPortableBackendPending?.()===!0&&(yield q(de)),this.selector.isPortableBackendActive()===!0)}catch(e){return this.loggingService.catch("Error in PortableAttachmentStorageService waitForActiveBackend: ",e,void 0,!0),!1}})}callOp(e,t){let r=this.selector.resolveDbAdapter(),i=r?.[e];return typeof i!="function"?Promise.resolve({ok:!1,code:"unimplemented",message:`the portable adapter does not implement '${e}'`}):i.call(r,{scope:"doc",data:t})}reportOpFailure(e,t,r=!1){try{if(O(t)){let i=t?.code??"unknown";this.loggingService.log(`Tier B ${e} is not served by this deployment (${i}): comment attachments are not available`);return}if(r){let i=t?.code??"unknown",l=`${e}:${i}`;if(this.hotPathReported.has(l)){this.loggingService.log(`Tier B ${e} refused again: ${i}`);return}this.hotPathReported.add(l)}Y(e,t,{logCatch:(i,l)=>this.loggingService.catch(i,l,void 0,!0),reported:this.reportedOpFailures,isOutcomeUnknown:J})}catch{}}notSent(e,t){let r=new m("failed-precondition",`Tier B attachment ${e} was not sent: ${t}`);return this.loggingService.catch(r.message,void 0,void 0,!0),r}dropped(e){let t=new m("failed-precondition",`Tier B attachment upload was dropped: ${e}`);return this.loggingService.catch(t.message,void 0,void 0,!0),t}};n.\u0275fac=function(t){return new(t||n)(g(N),g(y))},n.\u0275prov=A({token:n,factory:n.\u0275fac,providedIn:"root"});let s=n;return s})();var ae=s=>{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 Q.sanitize(s,n)}catch(n){return S.catch("Error in File utils sanitizeSvg: ",n),""}},le=s=>{try{return s.name.split(".").slice(0,-1).join(".")}catch(n){S.catch("Error in File utils getFileName: ",n);return}},D=s=>{try{return/(?:\.([^.]+))?$/.exec(s?.name)[1]}catch(n){S.catch("Error in File utils getFileExtension: ",n);return}},ce=(s,n)=>{try{let d=s.slice(0,-1,s.type);return new File([d],n+"."+D(s),{type:s.type})}catch(d){S.catch("Error in File utils updateFile: ",d);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 he=(()=>{let n=class n{getStorageInstance(e){return e?U(void 0,e):U()}ref(e,t){return H(e,t)}uploadBytesResumable(e,t,r){return j(e,t,r)}getDownloadURL(e){return z(e)}deleteObject(e){return $(e)}};n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=A({token:n,factory:n.\u0275fac,providedIn:"root"});let s=n;return s})();var rt=(()=>{let n=class n{constructor(e,t,r,i,l,o,c){this.authService=e,this.configService=t,this.coreActionsService=r,this.loggingService=i,this.attachmentResolverService=l,this.storageAdapter=o,this.portableAttachments=c,this.storage=this.storageAdapter.getStorageInstance();try{this.configService.getApiKey$().subscribe(a=>{this.apiKey=a}),this.authService.getFirebaseConfig$().subscribe(a=>{if(a&&a.firebaseOptions?.storageBucket){this.storage=this.storageAdapter.getStorageInstance(a?.firebaseOptions?.storageBucket);let h=this.configService.getProxyConfig();h?.storageHost&&(this.storage.host=h.storageHost)}},a=>{this.loggingService.catch("Error in StorageService constructor: ",a)})}catch(a){this.loggingService.catch("Error in StorageService constructor:",a)}}createAttachment({path:e,file:t}){try{let r=new V;r.name=t.name;let i=ce(t,`${r.attachmentId}_${le(t)}`),l=`${this.apiKey}/${e}/${i?.name}`;return r.bucketPath=l,r.size=t.size,r.type=D(t),r?.type&&(r.mimeType=B[r?.type]),r}catch(r){return this.loggingService.catch("Error in StorageService createAttachment: ",r),null}}sanitizeSvgFile(e){return p(this,null,function*(){if(e.type===B.svg)try{let t=yield e.text(),r=ae(t);return new File([r],e.name,{type:e.type})}catch(t){return this.loggingService.catch("Error in StorageService sanitizeSvgFile: ",t),e}return e})}uploadAttachmentToStorage(l){return p(this,arguments,function*({attachment:e,file:t,resolve:r,reject:i}){try{let o=this.storageAdapter.ref(this.storage,e.bucketPath),c=this.storageAdapter.uploadBytesResumable(o,t,{cacheControl:"public,max-age=3600"});c.on("state_changed",a=>{let h=a.bytesTransferred/a.totalBytes*100},a=>{i(a)},()=>{this.storageAdapter.getDownloadURL(c.snapshot.ref).then(a=>{e.url=a,r(e)})})}catch(o){this.loggingService.catch("Error in StorageService uploadAttachmentToStorage: ",o),i(o)}})}uploadToResolver(c){return p(this,arguments,function*({file:e,attachment:t,metadata:r,resolve:i,reject:l,scope:o}){try{r.attachmentId=t.attachmentId;let a={attachmentId:t.attachmentId,name:t.name,file:e,metadata:r,mimeType:t.mimeType},h=F();this.coreActionsService.triggerAction(R.ATTACHMENT_RESOLVER,{event:k.Events.Resolver.ATTACHMENT_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:h,methodName:x.UPLOAD_TO_RESOLVER,source:"internal",payload:{attachment:a,eventType:E.ATTACHMENT_ADD}});let u=yield this.attachmentResolverService.saveAttachment({attachment:a,eventType:E.ATTACHMENT_ADD},h,o);u&&u.data?.url?(t.url=u.data?.url,i(t)):l(new Error("Failed to upload attachment to resolver"))}catch(a){this.loggingService.catch("Error in StorageService uploadToResolver: ",a),l(a)}})}uploadFile({path:e,file:t,useAttachmentResolver:r,metadata:i,attachmentScope:l,portableScope:o}){return new Promise((c,a)=>p(this,null,function*(){try{if(!this.apiKey)throw new Error("API key not configured");let h=o&&!r?this.portableAttachments.captureSessionUser():null,u=yield this.sanitizeSvgFile(t),f=this.createAttachment({path:e,file:u});if(!f)throw new Error("Attachment not created");r?this.uploadToResolver({file:u,attachment:f,metadata:i,resolve:c,reject:a,scope:l}):o&&(h||this.portableAttachments.isPortableAttachmentDeployment())?this.portableAttachments.upload({attachment:f,file:u,scope:o,sessionUserId:h??void 0}).then(c,a):this.portableAttachments.isPortableAttachmentDeployment()?a(this.portableAttachments.refuseVeltStorage("uploadFile")):this.uploadAttachmentToStorage({attachment:f,file:u,resolve:c,reject:a})}catch(h){this.loggingService.catch("Error in StorageService uploadFile:",h),a(h)}}))}uploadChunk(e,t,r,i){return new Promise((l,o)=>{try{if(i?.useAttachmentResolver){let c=this.createAttachment({path:e,file:t});if(!c){o(new Error("Attachment not created for chunk upload"));return}this.uploadToResolver({file:t,attachment:c,metadata:i.metadata,resolve:a=>l(a.url),reject:o,scope:i.attachmentScope});return}if(this.portableAttachments.isPortableAttachmentDeployment()){o(this.portableAttachments.refuseVeltStorage("uploadChunk"));return}if(this.apiKey){let c=`${this.apiKey}/${e}/${t.name}`,a=this.storageAdapter.ref(this.storage,c),h=this.storageAdapter.uploadBytesResumable(a,t,{cacheControl:"public,max-age=3600"});h.on("state_changed",u=>{let f=u.bytesTransferred/u.totalBytes*100},u=>{o(u)},()=>{this.storageAdapter.getDownloadURL(h.snapshot.ref).then(u=>{l(u)}).catch(u=>{this.loggingService.catch(`[uploadChunk] Error getting download URL for chunk ${r}:`,u),o(u)})})}else{let c=new Error("API key not available");this.loggingService.catch("[uploadChunk] API key not available",c),o(c)}}catch(c){this.loggingService.catch(`[uploadChunk] Error in StorageService uploadChunk for chunk ${r}: `,c),o(c)}})}downloadAttachment(e,t){try{if(this.portableAttachments.isPortableAttachment(e)){let r=this.portableAttachments.captureSessionUser();this.portableAttachments.resolveDownloadUrl(e,t).then(i=>{i&&this.portableAttachments.isSameSessionUser(r)?this.downloadFromUrl(e,i,!0):i||this.loggingService.catch("Tier B attachment download: no read URL could be resolved; nothing was downloaded")}).catch(i=>{this.loggingService.catch("Error in StorageService downloadAttachment (Tier B): ",i)});return}e.url&&this.downloadFromUrl(e,e.url)}catch(r){this.loggingService.catch("Error in StorageService downloadAttachment: ",r)}}downloadFromUrl(e,t,r=!1){try{let i=new XMLHttpRequest;i.responseType="blob",i.onload=()=>{if(r&&(i.status<200||i.status>=300)){this.loggingService.catch(`Tier B attachment download failed: the storage answered HTTP ${i.status}`);return}let l=i.response,o=document.createElement("a"),c=window.URL.createObjectURL(l);o.setAttribute("type","hidden"),o.setAttribute(K.ATTRIBUTES.VELT_DOWNLOAD_BUTTON,"true"),o.classList.add("snippyly-overlay-panel"),o.href=c,e?.name&&(o.download=e?.name),document.body.appendChild(o);let a=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});o.dispatchEvent(a),window.URL.revokeObjectURL(c),o.remove()},i.onerror=()=>{r?(this.loggingService.catch(`Tier B attachment download failed in transport; opening it in a new tab instead. ${oe}`),window.open(t,"_blank","noopener,noreferrer")):window.open(t,"_blank")},i.open("GET",t),i.send()}catch(i){this.loggingService.catch("Error in StorageService downloadAttachment: ",i)}}deleteAttachment({attachment:e,metadata:t,useAttachmentResolver:r,attachmentScope:i,portableScope:l}){return new Promise((o,c)=>{if(r){let a=F();this.coreActionsService.triggerAction(R.ATTACHMENT_RESOLVER,{event:k.Events.Resolver.ATTACHMENT_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:a,methodName:x.DELETE_ATTACHMENT,source:"internal",payload:{attachmentId:e.attachmentId,metadata:t}}),this.attachmentResolverService.deleteAttachment({attachmentId:e.attachmentId,metadata:t},a,i).then(()=>{o(null)}).catch(h=>{c(h)})}else if((l||v(e))&&this.portableAttachments.isPortableAttachmentDeployment())this.portableAttachments.delete({attachment:e,scope:l}).then(()=>o(null),()=>o(null));else if(this.portableAttachments.isPortableAttachmentDeployment())this.portableAttachments.refuseVeltStorage("deleteAttachment"),o(null);else{let a=this.storageAdapter.ref(this.storage,e.bucketPath);this.storageAdapter.deleteObject(a).then(()=>{o(null)}).catch(h=>{o(null)})}})}getAttachmentDisplayUrl(e,t){return this.portableAttachments.getDisplayUrl(e,t)}isAttachmentDisplayPending(e,t){return this.portableAttachments.isDisplayPending(e,t)}isPortableAttachment(e){return this.portableAttachments.isPortableAttachment(e)}resolveAttachmentUrl(e,t){return this.portableAttachments.resolveDownloadUrl(e,t)}reportAttachmentLoadError(e,t,r){this.portableAttachments.reportLoadError(e,t,r)}deleteFileFromPath(e){return new Promise((t,r)=>{if(this.portableAttachments.isPortableAttachmentDeployment()){r(this.portableAttachments.refuseVeltStorage("deleteFileFromPath"));return}let i=this.storageAdapter.ref(this.storage,e);this.storageAdapter.deleteObject(i).then(()=>{t(null)}).catch(l=>{r(l)})})}};n.\u0275fac=function(t){return new(t||n)(g(T),g(w),g(X),g(y),g(Z),g(he),g(se))},n.\u0275prov=A({token:n,factory:n.\u0275fac,providedIn:"root"});let s=n;return s})();export{se as a,rt as b};
File without changes