@veltdev/sdk 6.0.27 → 6.0.28
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/{chunk-4GWTY2QW.js → chunk-3BCXNETY.js} +1 -1
- package/{chunk-PIBUTN6R.js → chunk-3Q5TRC4E.js} +1 -1
- package/{chunk-T32PAZYN.js → chunk-4HAFXUDN.js} +1 -1
- package/chunk-4P3GYHGY.js +1 -0
- package/{chunk-Z7CCKSEO.js → chunk-5ACPKO6C.js} +1 -1
- package/{chunk-PBA6NIAI.js → chunk-67RGQF3Z.js} +1 -1
- package/{chunk-2MYJTN75.js → chunk-CR275X25.js} +1 -1
- package/{chunk-FHFEI7VF.js → chunk-EB7SHB2S.js} +1 -1
- package/{chunk-WWK6NPFJ.js → chunk-FWIDRPYU.js} +1 -1
- package/{chunk-K6LCTVYG.js → chunk-GAWI762G.js} +1 -1
- package/{chunk-DKI2JSNJ.js → chunk-GHN6NWBT.js} +1 -1
- package/{chunk-UKCZENKX.js → chunk-HCM2TAE7.js} +1 -1
- package/{chunk-IVZBIMXH.js → chunk-HIEV42PB.js} +1 -1
- package/{chunk-CXZSNTWV.js → chunk-IS7ZDK65.js} +1 -1
- package/{chunk-7J6SWBKB.js → chunk-J35LMO3C.js} +1 -1
- package/{chunk-V2VL4H4R.js → chunk-J3IQ7DYW.js} +1 -1
- package/{chunk-ABA7YQYU.js → chunk-JQZKADOA.js} +1 -1
- package/{chunk-KHGHU7FE.js → chunk-JWSICAW6.js} +1 -1
- package/{chunk-2C7WPTQD.js → chunk-JZCDUWAA.js} +1 -1
- package/{chunk-NZUJK3CJ.js → chunk-KNYRVMQK.js} +1 -1
- package/{chunk-ZVRUGR3J.js → chunk-MP2SDO2E.js} +1 -1
- package/{chunk-KWZM6CNH.js → chunk-N3IQEYGG.js} +1 -1
- package/{chunk-72TEWHMQ.js → chunk-NTFMMZRZ.js} +1 -1
- package/{chunk-4CPJN52I.js → chunk-R7EWRVMV.js} +1 -1
- package/{chunk-JR3BVUP3.js → chunk-R7PIAWZF.js} +1 -1
- package/{chunk-YI3LAD3Z.js → chunk-RPLZXBLF.js} +1 -1
- package/{chunk-M3XIT6ZY.js → chunk-SN6HOFPK.js} +1 -1
- package/{chunk-QQIKH4VS.js → chunk-SYLJZSJP.js} +1 -1
- package/{chunk-WBOPOSCN.js → chunk-TLEK2ADO.js} +1 -1
- package/{chunk-YUGCY3BB.js → chunk-TSC5TWPQ.js} +1 -1
- package/{chunk-HV37SAIK.js → chunk-URKI6WZP.js} +1 -1
- package/{chunk-J3DYWDYQ.js → chunk-VESMHAEV.js} +1 -1
- package/{chunk-DF2C2V7B.js → chunk-VJPZ6E4S.js} +1 -1
- package/{chunk-WNH4SCIB.js → chunk-XEXFF5FD.js} +1 -1
- package/{chunk-BTJTZEPV.js → chunk-YBLQ2JHR.js} +1 -1
- package/{chunk-G6V3RCTP.js → chunk-ZRITZXNF.js} +1 -1
- package/package.json +1 -1
- package/velt-activity-log.js +1 -1
- package/velt-area.js +1 -1
- package/velt-arrow.js +1 -1
- package/velt-comment.js +7 -7
- package/velt-crdt.js +1 -1
- package/velt-cursor.js +1 -1
- package/velt-huddle.js +1 -1
- package/velt-live-state-sync.js +1 -1
- package/velt-notification.js +1 -1
- package/velt-portable.js +1 -1
- package/velt-presence.js +1 -1
- package/velt-reaction.js +1 -1
- package/velt-recorder.js +1 -1
- package/velt-rewriter.js +1 -1
- package/velt-selection.js +1 -1
- package/velt-tag.js +1 -1
- package/velt-user-invite.js +1 -1
- package/velt-user-request.js +1 -1
- package/velt-video-player.js +1 -1
- package/velt-views.js +1 -1
- package/velt.js +2 -2
- package/chunk-4JE45AVC.js +0 -1
package/velt-area.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Xt,b as Kt}from"./chunk-ABA7YQYU.js";import{t as Wt}from"./chunk-T32PAZYN.js";import"./chunk-2MYJTN75.js";import"./chunk-M3XIT6ZY.js";import{c as ut,d as ft}from"./chunk-FHFEI7VF.js";import{a as Jt}from"./chunk-WWK6NPFJ.js";import"./chunk-7J6SWBKB.js";import"./chunk-KHGHU7FE.js";import"./chunk-NZUJK3CJ.js";import{b as jt}from"./chunk-Z7CCKSEO.js";import"./chunk-4GWTY2QW.js";import{a as Pe}from"./chunk-G6V3RCTP.js";import{a as Et}from"./chunk-QQIKH4VS.js";import{I as Pt,r as At,t as vt,v as St,za as _t}from"./chunk-DKI2JSNJ.js";import{a as Gt}from"./chunk-PBA6NIAI.js";import{D as $t,E as Se,g as Be}from"./chunk-72TEWHMQ.js";import{Aj as Ne,Bb as _,C as We,Cb as rt,D as Ge,Db as at,E as q,Fb as st,Fj as V,Gb as ct,Gd as Ct,Ha as x,Hb as lt,He as h,Hg as se,Hi as N,Ic as ue,Ij as Ht,Jg as fe,K as he,Kb as dt,Ki as Ft,Lb as U,M as ae,Mb as ee,Mc as ht,Nc as gt,Ne as bt,Nj as Vt,O as Xe,Oa as Qe,Pj as Ut,Qh as Ae,Ra as I,Rc as pt,Rh as Me,Te as yt,Tg as Le,Th as Mt,V as S,Va as qe,Wa as ne,Xa as et,Zf as Re,Zi as te,_ as ge,a as g,ab as j,ai as Nt,b as E,ba as pe,bh as we,ca as Ke,cc as Oe,ci as Bt,db as tt,ea as b,ei as ve,fb as ie,g as le,i as $e,ij as kt,ja as y,ka as T,kg as Tt,l as re,la as Je,mh as wt,na as Ye,nb as L,nj as W,o as je,ob as R,oj as G,p as de,pb as B,pe as xe,pj as D,qb as nt,qj as zt,r as C,rc as mt,re as M,rg as Dt,rk as X,sa as Ze,se as It,sg as Ot,sk as K,ub as Te,ug as xt,v,vb as De,vg as Rt,w as me,wb as it,xb as oe,yb as ot,yg as Lt,zb as w}from"./chunk-J3DYWDYQ.js";var H=(()=>{let l=class l{constructor(e,t,n,o,s,r,a,c,u,P,f,p,A){this.analyticsService=e,this.configService=t,this.docService=n,this.databaseService=o,this.commonDbService=s,this.authService=r,this.domService=a,this.afAuth=c,this.iamService=u,this.dialog=P,this.loggingService=f,this.userPermissionService=p,this.serviceBook=A,this.areaAnnotationById$=new re({}),this.documentPaths=null,this.areaEnabled$=new re(!0),this.allowedElementIds$=new re([]),this.addAreaMode$=new re(!1),this.notificationService=null,this.loggingService.log("%c[WB] Creating CLASS: AreaService","color: blue;"),this.serviceBook.observe(Ft).subscribe(m=>this.notificationService=m),this.areaDbReadyGate$().pipe(he(1)).subscribe(()=>{this.getDocumentPaths()},m=>{this.loggingService.catch("Error in AreaService getDb subscription: ",m)}),this.domService.onWindowPointerMove$().subscribe(m=>{if(this.addAreaMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let O=this.domService.getBackgroundElement(m.clientX,m.clientY);O&&(this.isElementInsideAllowedElements(O)?we(m.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=O,this.domService.highlightElement(this.highlightElement,h.CURSOR.AREA_PIN)):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},m=>{this.loggingService.catch("Error in AreaService onWindowPointerMove$ subscription: ",m)}),this.domService.onWindowKeyupEsc$().subscribe(m=>{this.addAreaMode$.value&&this.disableAddAreaMode()},m=>{this.loggingService.catch("Error in AreaService onWindowKeyupEsc$ subscription: ",m)}),this.domService.onDocumentClick$().subscribe(m=>{if(m&&this.addAreaMode$.value){if(m.preventDefault(),m.stopPropagation(),!we(m.target)){let O=this.domService.getBackgroundElement(m.clientX,m.clientY);O&&this.isElementInsideAllowedElements(O)&&this.addArea(m)}this.disableAddAreaMode()}},m=>{this.loggingService.catch("Error in AreaService onDocumentClick$ subscription: ",m)}),this.addAreaMode$.subscribe(m=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),m?this.domService.addClassToElement(document.body,"snippyly-add-area-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-area-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},m=>{this.loggingService.catch("Error in AreaService addAreaMode$ subscription: ",m)}),this.domService.onWindowKeyupBackspace$().subscribe(m=>{this.deleteAreaPinAnnotations("keyupBackspace")},m=>{this.loggingService.catch("Error in AreaService onWindowKeyupBackspace$ subscription: ",m)}),this.domService.onWindowKeyupDelete$().subscribe(m=>{this.deleteAreaPinAnnotations("keyupDelete")},m=>{this.loggingService.catch("Error in AreaService onWindowKeyupDelete$ subscription: ",m)})}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in AreaService","color: green;");try{this.areaAnnotationById$.next({}),this.areaEnabled$.next(!0),this.allowedElementIds$.next([]),this.addAreaMode$.next(!1),this.highlightElement=null}catch(e){this.loggingService.catch("Error in AreaService clearCache: ",e)}}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}setAllowedElementIds(e){this.allowedElementIds$.next(e||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getAllAreaAnnotations(e,t,n){this.loggingService.log("%c[WB] Calling FUNCTION: getAllAreaAnnotations","color: green;");let o,s;try{if(e&&(s=Re(e)),t&&typeof t=="object"){let r=Lt(t);o=Re(JSON.stringify(r))}}catch(r){this.loggingService.catch("Error in AreaService getAllAreaAnnotations: ",r)}return Ge(C(null),new $e(r=>Vt(()=>r.next(null)))).pipe(S(()=>this.authService.getAuthState$()),q(r=>!!r),S(r=>this.isFeatureAllowed({firebaseUser:r,annotations:[],filteredAnnotations:[]})),S(r=>r.featureAllowed?this.iamService.isUserAllowed$().pipe(v(a=>(r.featureAllowed=a,r))):C(r)),S(r=>r.featureAllowed?this.authService.isPlanExpired$().pipe(v(a=>(r.featureAllowed=!a,r))):C(r)),S(r=>r.featureAllowed?C(r).pipe(S(a=>this.docService.getDocumentPaths$().pipe(v(c=>(this.documentPaths=c,a.documentPaths=c,a)))),S(a=>s?this.getDataFromDocumentIds([s]).pipe(v(c=>(a.annotations=c||[],g({},a)))):this.docService.getDocumentIds$().pipe(S(c=>{let u=c?.length>0?c.map(P=>P.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(u).pipe(v(P=>(a.annotations=P||[],g({},a))))}))),S(a=>this.docService.getLocation$().pipe(v(c=>(a.location=c,a)))),S(a=>this.docService.getLocations$().pipe(v(c=>(a.customLocations=c,a)))),S(a=>this.docService.getExcludedLocationIds$().pipe(v(c=>(a.excludedLocationIds=c,a)))),v(a=>{if(a.filteredAnnotations=[],s&&!o)return a.filteredAnnotations=a.annotations?.slice(),a.filteredAnnotations=this.applyExcludedLocationIds(a.filteredAnnotations,a.excludedLocationIds),a;{let c=[],u=[];return o?c.push(o):(c.push(a?.location?.locationId),c.push(...Object.values(a?.customLocations||[]).map(P=>P.locationId)),a?.location?.location?.id&&u.push(a?.location?.location?.id),u.push(...Object.values(a?.customLocations||{}).map(P=>P.location?.id).filter(P=>!!P))),a.filteredAnnotations=this.filterAnnotationsByLocationIds(a?.annotations,c,u),a.filteredAnnotations=this.applyExcludedLocationIds(a.filteredAnnotations,a.excludedLocationIds),a}}),S(a=>n?C(a):a?.annotations?.length?this.domService.onWindowResize$().pipe(v(()=>a)):C(a)),S(a=>n?C(a):a?.annotations?.length?this.domService.onDomChange$("AreaService getAllAreaAnnotations").pipe(v(()=>a)):C(a)),v(a=>(a.filteredAnnotations=a.filteredAnnotations?.map(c=>{let u=Object.assign({},c);return this.shouldSkipAreaPositionCalculation(u)?u.areaProperties=void 0:u.areaProperties=this.calculateAreaAnnotationPosition(u),u}),a)),S(a=>a?.filteredAnnotations?C(a?.filteredAnnotations||[]):C([])),S(a=>{if(this.authService.isFeatureAllowed(M.COMMENT))return C(a);{let c=a?.filter(u=>!u?.targetAnnotations?.filter(P=>P?.type===M.COMMENT)?.length);return C(c)}})):C([])),ae(Bt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(q(t=>!!t),v(t=>E(g({},e),{config:t})),S(t=>this.authService.getUser$().pipe(v(n=>E(g({},t),{user:n})))),S(t=>xt(t.config,t.user,M.AREA)?C(E(g({},t),{featureAllowed:!0})):(this.loggingService.warn("Area feature is not allowed."),C(E(g({},t),{featureAllowed:!1})))),ae((t,n)=>t?.featureAllowed===n?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getDataFromDocuments(e){if(this.configService.getApiKey()){let{documentIds:t,filters:n}=e;if(t?.some(f=>!f)||!this.documentPaths)return C([]);let o=this.docService.getDocumentPaths()?.veltFolderId,s=C([]),r={useCollectionGroup:!0,isCollection:!0,useQuery:!0};this.commonDbService.shouldUseFirestore()||(r.documentId=t?.length?t[0]:void 0,r.organizationId=this.documentPaths?.organizationId);let a=this.commonDbService.usesPortableChannelFeed(Be),c=this.userPermissionService?.getIsContextEnabled(),u=a?Xt():null,P=a&&c?[h.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()]:null;if(a)s=this.commonDbService.dbListener({feature:"allAreas",properties:E(g({},r),{organizationId:this.documentPaths?.organizationId,documentIds:t})}).pipe(ge(),v(f=>ve(JSON.parse(JSON.stringify([f])))));else if(c){let f=[h.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],p=[];for(let A=0;A<(f?.length??0);A+=h.LISTENER_CONTEXT_BATCH_SIZE)p.push(f?.slice(A,A+h.LISTENER_CONTEXT_BATCH_SIZE)??[]);s=me(p.map(A=>this.commonDbService.dbListener({feature:"allAreas",properties:E(g({},r),{firestoreQuery:[Ne(V("metadata.apiKey","==",this.configService?.getApiKey()),V("metadata.documentId","in",t),V("metadata.organizationId","==",this.documentPaths?.organizationId),...o?[V("metadata.veltFolderId","==",o)]:[],...A?.length?[V("context.accessFields","array-contains-any",A)]:[])]})}).pipe(ge()))).pipe(v(A=>ve(A)))}else{let f=[];for(let p=0;p<(t?.length??0);p+=h.LISTENER_BATCH_SIZE)f.push(t?.slice(p,p+h.LISTENER_BATCH_SIZE)??[]);s=me(f.map(p=>this.commonDbService.dbListener({feature:"allAreas",properties:E(g({},r),{firestoreQuery:[Ne(V("metadata.apiKey","==",this.configService?.getApiKey()),V("metadata.documentId","in",p),V("metadata.organizationId","==",this.documentPaths?.organizationId),...o?[V("metadata.veltFolderId","==",o)]:[])]})}).pipe(ge()))).pipe(v(p=>ve(p)))}return s.pipe(v(({data:f,operation:p})=>{let A=[];return f&&(A=Object.values(f??{}).filter(m=>typeof m=="object")),A=this.applyPortableQueryScopeFilter(A,{isPortableFeed:a,scope:{veltFolderId:o},contextFields:P,evictDropped:!n,resultSet:u}),{data:A,operation:p}}),v(({data:f,operation:p})=>{if(!t)return{data:f,documentMap:{},operation:p};let A=f.reduce((m,O)=>{let $=O.metadata?.documentId;return $&&(m[$]||(m[$]=[]),m[$].push(O)),m},{});return{data:f,documentMap:A,operation:p}}),v(({data:f,documentMap:p,operation:A})=>{if(!n)if(A?.type==="removed"){if(A?.ids?.length){let m=this.areaAnnotationById$.value;A?.ids?.forEach(O=>{delete m?.[O]}),this.areaAnnotationById$.next(m)}}else Object.entries(p??{}).forEach(([m,O])=>{this.setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:m,annotations:O})});return f}))}else return C([])}setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:n,queryHash:o}){try{if(t){e||(e=h.NO_ORGANIZATION_ID),o||(o=h.DEFAULT_QUERY_HASH);let s={};n?.forEach(a=>{a?.annotationId&&(s[a?.annotationId]=a)});let r=g(g({},this.areaAnnotationById$.value),s);this.areaAnnotationById$.next(r)}}catch(s){this.loggingService.catch("Error in AreaService setAreaAnnotationsByOrganizationIdAndDocumentId:",s)}}applyPortableQueryScopeFilter(e,t){try{let{kept:n,departed:o}=Kt(e,t,s=>Ot(Dt(s,t.scope),t.contextFields));return o.length&&this.evictAreaAnnotationsFromLocalCache(o),n}catch(n){return this.loggingService.catch("Error in AreaService applyPortableQueryScopeFilter: ",n),e}}evictAreaAnnotationsFromLocalCache(e){try{if(!e?.length)return;let t=this.areaAnnotationById$?.value;if(t&&e.some(n=>n in t)){let n=g({},t);e.forEach(o=>{delete n[o]}),this.areaAnnotationById$.next(n)}}catch(t){this.loggingService.catch("Error in AreaService evictAreaAnnotationsFromLocalCache: ",t)}}getAnnotationById(e){try{return this.areaAnnotationById$.value?.[e]?this.areaAnnotationById$.value?.[e]:void 0}catch(t){this.loggingService.catch("Error in AreaService getAnnotationById: ",t);return}}applyExcludedLocationIds(e,t){return t?.length?e?.filter(n=>n?.location?.id?!t.includes(n.location.id):!0):e}filterAnnotationsByLocationIds(e,t,n){try{return e.filter(o=>t.includes(o.locationId)||n?.includes(o?.location?.id)||t?.find(s=>s==o?.location?.id)||n?.find(s=>s==o?.locationId+""))}catch(o){return this.loggingService.catch("Error in AreaService filterAnnotationsByLocations:",o),[]}}calculateAreaAnnotationPosition(e,t=!1){try{if(e.targetElements?.length){let n=e.targetElements[0],o=e.targetElements[1];if(n?.xpath&&o?.xpath||n?.anchor&&o?.anchor){let s=null,r=null;if(s=this.resolveAreaPointElement(n),r=this.resolveAreaPointElement(o),s&&r){let a=Ae(s,r);if(a){let c=s,u=r,P=c.getBoundingClientRect(),f=u.getBoundingClientRect(),p=t?P.width:c.offsetWidth||P.width,A=t?P.height:c.offsetHeight||P.height,m=t?f.width:u.offsetWidth||f.width,O=t?f.height:u.offsetHeight||f.height,$={};p&&A&&($={top:A*n.topPercentage/100,left:p*n.leftPercentage/100});let ye={};m&&O&&(ye={top:O*o.topPercentage/100,left:m*o.leftPercentage/100});let Ue=!t,F=Me($.left,$.top,s,a,Ue),k=Me(ye.left,ye.top,r,a,Ue),J,Y,Z,Q,z={};F.x>k.x?F.y>k.y?(Q={x:F.x,y:F.y},J={x:k.x,y:k.y},z.handle1=Q,z.handle2=J):(Y={x:F.x,y:F.y},Z={x:k.x,y:k.y},z.handle1=Y,z.handle2=Z):F.y>k.y?(Z={x:F.x,y:F.y},Y={x:k.x,y:k.y},z.handle1=Z,z.handle2=Y):(J={x:F.x,y:F.y},Q={x:k.x,y:k.y},z.handle1=J,z.handle2=Q);let en={topLeft:J||{x:Z?.x,y:Y?.y},bottomRight:Q||{x:Y?.x,y:Z?.y},topRight:Y||{x:Q?.x,y:J?.y},bottomLeft:Z||{x:J?.x,y:Q?.y}};return z.coordinates=en,z.targetElement=this.domService.getXPath(a),z}}}}return}catch(n){this.loggingService.catch("Error in AreaService calculateAreaAnnotationPosition:",n);return}}addArea(e,t=[],n,o,s,r){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{let a=this.authService.getUser();if(a)if(a.isReadOnly||a.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add areas.");else{let c=new yt;o&&(c.annotationId=o),c.from=a,c.color=h.DEFAULT_ANNOTATION_COLOR,c.lastUpdated=this.timestamp,n&&(c.targetAnnotations=[n]),c.props=new bt;let u=this.domService.getCurrentWindowSizeValue();if(c.props.screenWidth=u.screenWidth,c.props.screenHeight=u.screenHeight,c.props.screenScrollHeight=u.screenScrollHeight,c.props.viewportWidth=window.innerWidth,c.props.viewportHeight=window.innerHeight,e||t?.length>0){let p=e?this.getPointsForAreaPinAnnotation(e):t;c.targetElements=[],p.forEach(A=>{c.targetElements.push(this.domService.getTargetElementForCursorPosition(e,void 0,void 0,void 0,void 0,!0,{clientX:A.x,clientY:A.y}))})}this.setLocationToAreaAnnotation(c),s&&(c.locationId=s.locationId,c.location=s.location),c.pageInfo=Le(),c.pageInfo&&(c.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let P=this.getElementForAreaAnnotation(c),f=this.docService.getBaseMetadata("area",{element:P});if(c?.metadata||(c.metadata={}),c.metadata=g(g({},c.metadata),f),r?.access&&r?.accessFields){if(!this.userPermissionService?.hasUserContextAccess({userId:a.userId,accessFields:r.accessFields})){this.loggingService.catch("User does not have context access to add area annotation.",void 0,void 0,!0);return}r.accessFields.some(p=>Tt(p))||(c.context={access:r.access,accessFields:r.accessFields})}return this.saveAreaToDb(c),c}return}catch(a){this.loggingService.catch("Error in AreaService addArea: ",a);return}}setLocationToAreaAnnotation(e){try{let t=this.docService.getLocation();t?(e.locationId=t.locationId,e.location=t.location):(delete e.locationId,delete e.location)}catch(t){this.loggingService.catch("Error in AreaService setLocationToAreaAnnotation:",t)}}shouldSkipAreaPositionCalculation(e){try{if(!e?.locationId)return!1;let t=this.docService.getLocation();if(Nt({location:t?.location,locationId:t?.locationId},{location:e?.location,locationId:e?.locationId}))return!1;let n=this.resolveAreaCommonParent(e),o=this.docService.getAdditionLocationFromElement(n),s=o?this.docService.genarateLocationId(o):void 0,r;return e?.location?.id&&e?.location?.id===o?.id||s&&s===e?.locationId?r=!1:r=!0,r}catch(t){return this.loggingService.catch("Error in AreaService shouldSkipAreaPositionCalculation:",t),!1}}resolveAreaPointElement(e){let t=null;if(e?.anchor){let n=this.domService.resolveAnchorRecord(e.anchor);return n?.element&&n?.element instanceof HTMLElement&&!se(n.element)&&this.domService.isElementVisible(n.element)&&fe(n.element)&&(t=n.element),t}return e?.xpath&&(t=this.domService.getElementFromXPath(e.xpath),t&&se(t)&&(t=null),this.domService.isXpathWithId(e.xpath)||(!t&&e.cfXpath&&(t=this.domService.getElementFromXPath(e.cfXpath),t&&se(t)&&(t=null)),!t&&e.fXpath&&(t=this.domService.getElementFromXPath(e.fXpath),t&&se(t)&&(t=null)))),t}resolveAreaCommonParent(e){let t=this.resolveAreaPointElement(e?.targetElements?.[0]),n=this.resolveAreaPointElement(e?.targetElements?.[1]);return t&&n?Ae(t,n):null}getElementForAreaAnnotation(e){try{let t,n,o;if(e.targetElements?.length){if(e.targetElements[0]?.anchor){let s=this.domService.resolveAnchorRecord(e.targetElements[0].anchor);s?.element&&this.domService.isElementVisible(s.element)&&fe(s.element)&&(n=s.element)}else e.targetElements[0]?.xpath&&(n=this.domService.getElementFromXPath(e.targetElements[0].xpath));if(e.targetElements[1]?.anchor){let s=this.domService.resolveAnchorRecord(e.targetElements[1].anchor);s?.element&&this.domService.isElementVisible(s.element)&&fe(s.element)&&(o=s.element)}else e.targetElements[1]?.xpath&&(o=this.domService.getElementFromXPath(e.targetElements[1].xpath))}return n&&o&&(t=Ae(n,o)),t}catch(t){return this.loggingService.catch("Error in AreaService getElementForAreaAnnotation: ",t),null}}saveAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveAreaToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(M.AREA)&&me([this.docService.getDocumentPaths$(),this.areaDbReadyGate$().pipe(v(()=>!0))]).pipe(q(([t,n])=>!!t&&!!n),he(1),S(([t,n])=>{if(this.documentPaths=t,this.documentPaths?.area){e.annotationId||(e.annotationId=this.commonDbService.generateDocumentId()),e.pageInfo&&(e.pageInfo.areaUrl=this.generateAreaUrl(e));let o=JSON.parse(JSON.stringify(e));if(o.position=null,!o?.metadata?.documentId){o?.metadata||(o.metadata={});let a=this.docService.getBaseMetadata("area");o.metadata=g(g({},o?.metadata),a)}this.domService.toggleAnnotationSelection(o),this.analyticsService.trackEvent(N.Events.Area.AREA_ADDED,{annotationId:e.annotationId});let{documentId:s,organizationId:r}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:s,organizationId:r},data:JSON.parse(JSON.stringify(o))})}else return C(null)})).subscribe(()=>{},t=>{this.loggingService.catch("Error in AreaService saveAreaToDb subscription: ",t)})}catch(t){this.loggingService.catch("Error in AreaService saveAreaToDb: ",t)}}areaDbReadyGate$(){return Ut({isPortableFeedActive:()=>this.commonDbService?.usesPortableChannelFeed(Be),firebaseDb$:()=>this.databaseService.getDb(),onError:(e,t)=>this.loggingService.catch(`Error in AreaService areaDbReadyGate$ ${e}: `,t)})}getDocumentIdAndOrganizationIdFromAreaAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(t){return this.loggingService.catch("Error in AreaService getDocumentIdAndOrganizationIdFromAreaAnnotation: ",t),{}}}updateArea(e,t=!1,n){try{n&&this.setLocationToAreaAnnotation(e),t&&this.updateNotificationsDatabase(e,xe.UPDATED),this.updateAreaToDb(e)}catch(o){this.loggingService.catch("Error in AreaService updateArea: ",o)}}updateAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateAreaToDb","color: green;");try{if(this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(M.AREA)){let t=JSON.parse(JSON.stringify(e));if(t.position=null,!t?.metadata?.documentId){t?.metadata||(t.metadata={});let s=this.docService.getBaseMetadata("area");t.metadata=g(g({},t?.metadata),s)}let{documentId:n,organizationId:o}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:n,organizationId:o},data:JSON.parse(JSON.stringify(t))})}}catch(t){this.loggingService.catch("Error in AreaService updateAreaToDb: ",t)}}deleteAreaPinAnnotations(e){try{let t=this.domService.getSelectedAnnotationsMap(),n=this.authService.getUser(),o=[];Object.keys(t??{}).forEach(s=>le(this,null,function*(){let r=t[s];r.type==="area"&&n&&r.from&&(n?.isAdmin||r.from.userId===n.userId)&&o.push(r)})),o?.length&&(this.analyticsService.trackEvent(N.Events.Area.AREA_DELETE_TRIGGERED,{triggerType:e,annotationId:o.map(s=>s.annotationId).join()}),this.dialog.open(jt,{panelClass:"velt-mat-dialog-container",data:{title:"Delete area?",message:"This selected area will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"area"}}).afterClosed().pipe(he(1)).subscribe(s=>{s&&(o.forEach(r=>le(this,null,function*(){yield this.deleteAreaPinAnnotation(r)})),setTimeout(()=>{document.querySelectorAll(`[${h.SNIPPYLY_HIGHLIGHT}]`).forEach(a=>{this.domService.removeHighlightFromElement(a)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"area")}catch(t){this.loggingService.catch("Error in AreaService deleteAreaPinAnnotations: ",t)}}getAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let n={};return Object.values(this.areaAnnotationById$.value??{}).forEach(o=>{o?.metadata?.documentId==t&&o?.metadata?.organizationId==e&&(n[o?.annotationId]=o)}),Object.values(n??{})}catch(n){return this.loggingService.catch("Error in AreaService getAreaAnnotationsByOrganizationIdAndDocumentId:",n),[]}}onDeleteTargetAnnotation(e,t){try{if(this.docService.getDocumentId()&&this.areaAnnotationById$.value){let o=Object.values(this.areaAnnotationById$.value||{}),s;t?s=o.find(r=>r?.annotationId===t):s=o.find(r=>r?.targetAnnotations?.find(a=>a?.annotationId===e)),s&&(s.targetAnnotations=s.targetAnnotations?.filter(r=>r?.annotationId!==e),s.targetAnnotations?.length?this.updateAreaToDb(s):this.deleteAreaPinAnnotation(s))}}catch(n){this.loggingService.catch("Error in AreaService onDeleteTargetAnnotation: ",n)}}deleteAreaPinAnnotation(e){if(this.authService.isFeatureAllowed(M.AREA)&&this.documentPaths?.area&&e?.annotationId){this.updateNotificationsDatabase(e,xe.DELETED),this.analyticsService.trackEvent(N.Events.Area.AREA_DELETED,{annotationId:e.annotationId});let{documentId:t,organizationId:n}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.deleteData({feature:"area",properties:{id:e.annotationId,documentId:t,organizationId:n}})}else return Promise.resolve()}enableArea(){try{this.areaEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in AreaService enableArea: ",e)}}disableArea(){try{this.areaEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in AreaService disableArea: ",e)}}getAreaEnabled$(){try{return this.areaEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled$: ",e),C(!1)}}getAreaEnabled(){try{return this.areaEnabled$.value}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled: ",e),!1}}enableAddAreaMode(){this.authService.isFeatureAllowed(M.AREA)?(this.analyticsService.trackEvent(N.Events.Area.AREA_ADD_MODE_ENABLED),this.addAreaMode$.next(!0)):this.loggingService.catch("Error in AreaService enableAddAreaMode: ","Area feature is not enabled.")}disableAddAreaMode(){this.analyticsService.trackEvent(N.Events.Area.AREA_ADD_MODE_DISABLED),this.addAreaMode$.next(!1)}addAreaModeChange(){return this.addAreaMode$.asObservable()}getPointsForAreaPinAnnotation(e){let t=[],n=e,o=n?.touches?.length?n.touches[0]?.clientX:n.clientX,s=n?.touches?.length?n.touches[0]?.clientY:n.clientY;return t.push({x:o,y:s}),t.push({x:o+100,y:s+100}),t}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(e){try{return this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)}catch(t){return this.loggingService.catch("Error in AreaService isElementInsideAllowedElements: ",t),!1}}updateNotificationsDatabase(e,t){try{let n={annotationData:e,actionType:t,notificationSource:"area"};this.notificationService?.updateNotificationDatabase(n)}catch(n){this.loggingService.catch("Error in AreaService updateNotificationsDatabase: ",n)}}getAreaUrl(e){try{return e?.pageInfo?.areaUrl?e.pageInfo.areaUrl:(e?.pageInfo||(e.pageInfo=Le(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.areaUrl=this.generateAreaUrl(e),this.updateArea(e),e.pageInfo?.areaUrl)}catch(t){this.loggingService.catch("Error in AreaService getAreaUrl: ",t);return}}generateAreaUrl(e){let t;try{t=new URL(e?.pageInfo?.url||window.location.href)}catch(n){this.loggingService.catch("Error in AreaService generateAreaUrl: ",n),t=new URL(window.location.href)}return t.searchParams.delete(h.URL_PARAMS.TAG_ID),t.searchParams.append(h.URL_PARAMS.TAG_ID,e.annotationId),t.href}generateAreaAnnotationId(){return le(this,null,function*(){try{if(this.docService.getDocumentPaths()?.area){let t=this.commonDbService.generateDocumentId();return yield wt(10),t||""}else return""}catch(e){return this.loggingService.catch("Error in AreaService generateAreaAnnotationId: ",e),""}})}};l.\u0275fac=function(t){return new(t||l)(b(G),b(zt),b(Se),b(Ht),b($t),b(K),b(X),b(Ct),b(Pe),b(_t),b(D),b(Jt),b(W))},l.\u0275prov=pe({token:l,factory:l.\u0275fac,providedIn:"root"});let d=l;return d})();var Zt=()=>({bottom:"calc(100% - 8px)",color:"green"});function rn(d,l){if(d&1){let i=oe();R(0,"div",8),w("click",function(){y(i);let t=_(3);return T(t.togglePinSelection())}),R(1,"velt-comment-pin-embed",9),w("saveComment",function(t){y(i);let n=_(3);return T(n.saveComment(n.veltEmit(t)))}),B()()}if(d&2){let i=_(2).ngIf,e=_();L("id","comment-pin-container-"+(i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId)),x(),U("left",8,"px"),L("ngStyle",Oe(9,Zt))("annotationDragging",i.isResizing)("annotation",i.commentPinAnnotation)("commentPinSelected",i.selectedAnnotationsMap[i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId]&&e.objectKeys(i.selectedAnnotationsMap).length===1)("multipleCommentPinSelected",i.selectedAnnotationsMap[i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId]&&e.objectKeys(i.selectedAnnotationsMap).length>1)("user",e.user)}}function an(d,l){if(d&1){let i=oe();R(0,"div",8),w("click",function(){y(i);let t=_(3);return T(t.togglePinSelection())}),R(1,"velt-comment-pin-embed",9),w("saveComment",function(t){y(i);let n=_(3);return T(n.saveComment(n.veltEmit(t)))}),B()()}if(d&2){let i=_(2).ngIf,e=_();L("id","comment-pin-container-"+(i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId)),x(),U("left",8,"px"),L("ngStyle",Oe(9,Zt))("annotationDragging",i.isResizing)("annotation",i.multiThreadCommentAnnotation)("commentPinSelected",!!i.selectedAnnotationsMap[i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId])("multipleCommentPinSelected",i.selectedAnnotationsMap[i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId]&&e.objectKeys(i.selectedAnnotationsMap).length>1)("user",e.user)}}function sn(d,l){if(d&1){let i=oe();Te(0),R(1,"div",1),w("click",function(){y(i);let t=_(2);return T(t.togglePinSelection())}),B(),R(2,"div",2),w("click",function(){y(i);let t=_(2);return T(t.togglePinSelection())}),B(),R(3,"div",3),w("click",function(){y(i);let t=_(2);return T(t.togglePinSelection())}),B(),R(4,"div",4),w("click",function(){y(i);let t=_(2);return T(t.togglePinSelection())}),B(),R(5,"div",5),w("cdkDragStarted",function(){y(i);let t=_(2);return T(t.onResizeHandleDragStart("topLeft"))})("cdkDragMoved",function(t){y(i);let n=_(2);return T(n.onResizeHandleDragMove(t,"topLeft"))})("cdkDragEnded",function(){y(i);let t=_(2);return T(t.onResizeHandleDragEnd("topLeft"))})("click",function(){y(i);let t=_(2);return T(t.togglePinSelection())}),B(),R(6,"div",6),w("cdkDragStarted",function(){y(i);let t=_(2);return T(t.onResizeHandleDragStart("bottomRight"))})("cdkDragMoved",function(t){y(i);let n=_(2);return T(n.onResizeHandleDragMove(t,"bottomRight"))})("cdkDragEnded",function(){y(i);let t=_(2);return T(t.onResizeHandleDragEnd("bottomRight"))})("click",function(){y(i);let t=_(2);return T(t.togglePinSelection())}),j(7,rn,2,10,"div",7)(8,an,2,10,"div",7),B(),De()}if(d&2){let i=_().ngIf,e=_();x(),U("border-color",i.areaAnnotationColor)("width",e.LINE_THICKNESS,"px")("height",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.y)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.y),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),x(),U("border-color",i.areaAnnotationColor)("height",e.LINE_THICKNESS,"px")("width",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomRight==null?null:i.areaProperties.coordinates.bottomRight.x)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.x),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),x(),U("border-color",i.areaAnnotationColor)("width",e.LINE_THICKNESS,"px")("height",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomRight==null?null:i.areaProperties.coordinates.bottomRight.y)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topRight==null?null:i.areaProperties.coordinates.topRight.y),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomRight==null?null:i.areaProperties.coordinates.bottomRight.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topRight==null?null:i.areaProperties.coordinates.topRight.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),x(),U("border-color",i.areaAnnotationColor)("height",e.LINE_THICKNESS,"px")("width",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topRight==null?null:i.areaProperties.coordinates.topRight.x)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.x),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),x(),U("background-color",i.areaAnnotationColor)("width",e.DRAG_HANDLE_SIZE,"px")("height",e.DRAG_HANDLE_SIZE,"px")("left",(i.areaProperties==null||i.areaProperties.handle1==null?null:i.areaProperties.handle1.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft)-e.DRAG_HANDLE_SIZE/2,"px")("top",(i.areaProperties==null||i.areaProperties.handle1==null?null:i.areaProperties.handle1.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop)-e.DRAG_HANDLE_SIZE/2,"px"),ee("drag-disabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),L("cdkDragDisabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x(),U("background-color",i.areaAnnotationColor)("width",e.DRAG_HANDLE_SIZE,"px")("height",e.DRAG_HANDLE_SIZE,"px")("left",(i.areaProperties==null||i.areaProperties.handle2==null?null:i.areaProperties.handle2.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft)-e.DRAG_HANDLE_SIZE/2,"px")("top",(i.areaProperties==null||i.areaProperties.handle2==null?null:i.areaProperties.handle2.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop)-e.DRAG_HANDLE_SIZE/2,"px"),ee("drag-disabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),L("cdkDragDisabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x(),L("ngIf",i.commentPinAnnotation),x(),L("ngIf",i.multiThreadCommentAnnotation)}}function cn(d,l){if(d&1&&(Te(0),j(1,sn,9,68,"ng-container",0),De()),d&2){let i=l.ngIf,e=_();x(),L("ngIf",!i.hideAreaAnnotation||e.selected)}}var Ve=(()=>{let l=class l{get resizing(){return this.componentConfigSignal().isResizing}onMouseEnter(){this.setAreaPinHover(!0)}onMouseLeave(){this.setAreaPinHover(!1)}constructor(e,t,n,o,s,r,a){this.analyticsService=e,this.authService=t,this.serviceBook=n,this.docService=o,this.domService=s,this.areaService=r,this.loggingService=a,this.multipleAreaPinsSelected=!1,this.avatarErrorImage="",this.objectKeys=Object.keys,this.subscriptions=[],this.annotationDragging=!1,this.dragPosition=null,this.LINE_THICKNESS=0,this.DRAG_HANDLE_SIZE=10,this.skipValueUpdate=!1,this.areaPinHover=!1,this.resolvedCommentsOnDom=!1,this.componentConfigSignal=Ze({hideAreaAnnotation:!1,selected:!1,areaAnnotationColor:"#625DF5",areaProperties:void 0,resizingOffset:{top:0,left:0},offsetLeft:0,offsetTop:0,isResizing:!1,areaPinAnnotation:void 0,user:void 0,commentPinAnnotation:void 0,selectedAnnotationsMap:{},pinDragEnabled:!0}),this.selected=!1,this.veltElement=!0,this.commentService=null,this.serviceBook.observe(te).subscribe(c=>{this.commentService=c}),this.subscriptions.push(this.authService.getUser$().subscribe(c=>{this.user=c},c=>{this.catchError("Error in AreaPinPortalComponent getUser$ subscription: ",c)})),this.subscriptions.push(this.serviceBook.observe(te).pipe(S(c=>c?c.getPinDrag$():de)).subscribe(c=>{this.componentConfigSignal.update(u=>E(g({},u),{pinDragEnabled:c}))},c=>{this.catchError("Error in AreaPinPortalComponent getPinDrag$ subscription: ",c)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(c=>{this.componentConfigSignal.update(u=>(u=E(g({},u),{selectedAnnotationsMap:c}),u)),this.componentConfigSignal().areaPinAnnotation?.annotationId&&this.componentConfigSignal().selectedAnnotationsMap&&(this.selected=!!this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().areaPinAnnotation.annotationId],this.componentConfigSignal().commentPinAnnotation?this.selected=!!this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().commentPinAnnotation?.annotationId]:this.componentConfigSignal().multiThreadCommentAnnotation&&(this.selected=!!this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().multiThreadCommentAnnotation?.annotationId])),this.updateAreaActiveAttributeOnElement()},c=>{this.catchError("Error in AreaPinPortalComponent getSelectedAnnotationsMap$ subscription: ",c)}))}ngOnInit(){}ngAfterViewInit(){try{let e=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===M.COMMENT)?.annotationId,t=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===M.MULTI_THREAD)?.annotationId;e?(this.componentConfigSignal.update(n=>(n=E(g({},n),{hideAreaAnnotation:!0}),n)),this.subscriptions.push(this.serviceBook.observe(te).pipe(S(n=>n?n.getCommentAnnotationByAnnotationId(e):de),S(n=>(this.commentService?.getResolvedCommentsOnDom$()??C(!0)).pipe(v(o=>(this.resolvedCommentsOnDom=o,n))))).subscribe(n=>{this.componentConfigSignal.update(o=>(o=E(g({},o),{commentPinAnnotation:n}),o.commentPinAnnotation?(o.areaAnnotationColor=o.commentPinAnnotation?.status.color,!this.resolvedCommentsOnDom&&!(this.commentService?.getFilterCommentsOnDom()&&this.commentService?.getCommentsFromSidebarMap())&&o.commentPinAnnotation?.status.type==="terminal"?o.hideAreaAnnotation=!0:o.hideAreaAnnotation=!1):o.hideAreaAnnotation=!0,o))}))):t?(this.componentConfigSignal.update(n=>(n=E(g({},n),{hideAreaAnnotation:!0}),n)),this.subscriptions.push(this.serviceBook.observe(te).pipe(S(n=>n?n.getMultiThreadCommentAnnotationByAnnotationId(t):de),S(n=>(this.commentService?.getResolvedCommentsOnDom$()??C(!0)).pipe(v(o=>(this.resolvedCommentsOnDom=o,n))))).subscribe(n=>{this.componentConfigSignal.update(o=>(o=E(g({},o),{multiThreadCommentAnnotation:n}),o.hideAreaAnnotation=!1,o))}))):this.componentConfigSignal.update(n=>(n=E(g({},n),{areaAnnotationColor:this.componentConfigSignal().areaPinAnnotation?.from?.color||"#625DF5"}),n)),this.componentConfigSignal().areaPinAnnotation?.targetElements?.length&&this.componentConfigSignal().areaPinAnnotation?.targetElements?.forEach(n=>{if(n?.xpath){let o=this.domService.getElementFromXPath(n?.xpath);!o&&n?.cfXpath&&(o=this.domService.getElementFromXPath(n?.cfXpath)),!o&&n?.fXpath&&(o=this.domService.getElementFromXPath(n?.fXpath)),o&&this.detectPositionChange(o)}})}catch(e){this.catchError("Error in AreaPinPortalComponent ngAfterViewInit: ",e)}}setAreaPinAnnotation(e){try{this.componentConfigSignal.update(t=>(!this.skipValueUpdate&&!t.isResizing&&(t=E(g({},t),{areaPinAnnotation:e}),this.id=e.annotationId,t.isResizing||(t.areaProperties=e.areaProperties)),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setAreaPinAnnotation: ",t)}}setOffsetLeft(e){try{this.componentConfigSignal.update(t=>(t=E(g({},t),{offsetLeft:e}),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setOffsetLeft: ",t)}}setOffsetTop(e){try{this.componentConfigSignal.update(t=>(t=E(g({},t),{offsetTop:e}),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setOffsetTop: ",t)}}togglePinSelection(){try{let e=!0;this.componentConfigSignal().commentPinAnnotation&&(e=!(this.domService.getDraftCommentAnnotationDialogs()||[])?.length,this.domService.resetSelectedAnnotationsMap(!0,"comments")),e&&(this.domService.toggleAnnotationSelection(this.componentConfigSignal().areaPinAnnotation),this.componentConfigSignal().commentPinAnnotation?this.domService.toggleAnnotationSelection(this.componentConfigSignal().commentPinAnnotation):this.componentConfigSignal().multiThreadCommentAnnotation&&this.domService.toggleAnnotationSelection(this.componentConfigSignal().multiThreadCommentAnnotation))}catch(e){this.catchError("Error in AreaPinPortalComponent togglePinSelection: ",e)}}saveComment(e){try{this.componentConfigSignal().commentPinAnnotation?this.commentService?.saveComment(this.componentConfigSignal().commentPinAnnotation,e):this.componentConfigSignal().multiThreadCommentAnnotation&&this.commentService?.saveComment(this.componentConfigSignal().multiThreadCommentAnnotation,e)}catch(t){this.catchError("Error in AreaPinPortalComponent saveComment: ",t)}}veltEmit(e){return typeof CustomEvent<"u"&&e instanceof CustomEvent?e.detail:e}calculateResizingOffset(e){try{if(!e)return{top:0,left:0};let t=e.getBoundingClientRect(),n=t.left+window.scrollX;return{top:t.top+window.scrollY,left:n}}catch(t){return this.catchError("Error in AreaPinPortalComponent calculateResizingOffset: ",t),{top:0,left:0}}}onResizeHandleDragStart(e){try{document.body.classList.add(h.BODY_CLASSES.VELT_PIN_DRAGGING);let t=document.getElementById(this.componentConfigSignal().areaPinAnnotation.annotationId);t&&(this.parentElement=t.parentElement,document.body.appendChild(t)),this.componentConfigSignal.update(a=>(a=E(g({},a),{isResizing:!0}),a));let n=this.domService.getElementFromXPath(this.componentConfigSignal().areaProperties?.targetElement),o=this.calculateResizingOffset(n),s=JSON.parse(JSON.stringify(this.componentConfigSignal().areaPinAnnotation)),r=this.areaService.calculateAreaAnnotationPosition(s,!0);this.componentConfigSignal.update(a=>(a=g(E(g({},a),{resizingOffset:o}),r?{areaProperties:r}:{}),a))}catch(t){this.catchError("Error in AreaPinPortalComponent onResizeHandleDragStart: ",t)}}onResizeHandleDragMove(e,t){try{let n=this.domService.getTargetElementForCursorPosition(e.event);if(this.componentConfigSignal().commentPinAnnotation){let o=this.domService.getElementFromXPath(n?.xpath);if(o&&!this.commentService?.isElementInsideAllowedElements(o))return}if(n){let o=JSON.parse(JSON.stringify(this.componentConfigSignal().areaPinAnnotation)),s=o.targetElements||[];switch(t){case"topLeft":s[0]=n;break;case"bottomRight":s[1]=n;break;default:break}o.targetElements=s;let r=this.areaService.calculateAreaAnnotationPosition(o,!0),a=this.componentConfigSignal().areaProperties?.targetElement,c=r?.targetElement,u=a!==c,P,f;if(u&&r?.targetElement){let p=this.domService.getElementFromXPath(r.targetElement),A=this.calculateResizingOffset(p);P=A.top,f=A.left}else{let p=this.componentConfigSignal().resizingOffset;P=p.top,f=p.left}this.componentConfigSignal.update(p=>(p=E(g({},p),{areaProperties:r,resizingOffset:{top:P,left:f},areaPinAnnotationOnResize:o}),p))}}catch(n){this.catchError("Error in AreaPinComponent onResizeHandleDragMove: ",n)}}onResizeHandleDragEnd(e){try{document.body.classList.remove(h.BODY_CLASSES.VELT_PIN_DRAGGING);let t=document.getElementById(this.componentConfigSignal().areaPinAnnotation.annotationId);t&&this.parentElement&&(this.parentElement.appendChild(t),t.style.opacity="0");let n=this.componentConfigSignal().areaPinAnnotationOnResize||this.componentConfigSignal().areaPinAnnotation;if(n){let r=this.areaService.calculateAreaAnnotationPosition(n,!1);r&&this.componentConfigSignal.update(a=>(a=E(g({},a),{areaProperties:r}),a))}this.componentConfigSignal.update(r=>(r=E(g({},r),{isResizing:!1}),r)),this.skipValueUpdate=!0;let o=this.domService.getElementFromXPath(this.componentConfigSignal().areaProperties?.targetElement),s=this.docService.getAdditionalDocumentIdFromElement(o)||this.docService.getDocumentPaths()?.clientDocumentId;!this.componentConfigSignal().areaPinAnnotation?.metadata?.clientDocumentId||this.componentConfigSignal().areaPinAnnotation?.metadata?.clientDocumentId==s?(this.componentConfigSignal.update(r=>(r=g({},r),r.areaPinAnnotationOnResize&&(r.areaPinAnnotation=JSON.parse(JSON.stringify(r.areaPinAnnotationOnResize))),delete r.areaPinAnnotationOnResize,r)),this.areaService.updateArea(this.componentConfigSignal().areaPinAnnotation,!1),this.analyticsService.trackEvent(N.Events.Area.AREA_DRAGGED,{annotationId:this.componentConfigSignal().areaPinAnnotation.annotationId})):this.componentConfigSignal.update(r=>(r=g({},r),r.areaProperties=r.areaPinAnnotation.areaProperties,r)),setTimeout(()=>{this.skipValueUpdate=!1,t&&(t.style.opacity="1")},50)}catch(t){this.catchError("Error in AreaPinComponent onResizeHandleDragEnd: ",t)}}detectPositionChange(e){try{let t=We(0,je).pipe(v(()=>{let n=e.getBoundingClientRect();return{top:n.top,left:n.left}}),ae((n,o)=>n.top===o.top&&n.left===o.left),Xe());this.subscriptions.push(t.subscribe(()=>{this.componentConfigSignal.update(n=>(n=E(g({},n),{areaProperties:this.areaService.calculateAreaAnnotationPosition(n.areaPinAnnotation)}),n))},n=>{}))}catch(t){this.catchError("Error in AreaPinPortalComponent detectPositionChange: ",t)}}setAreaPinHover(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setAreaPinHover","color: green;"),e&&this.targetElement&&!this.domService.isElementVisibleOnScreen(this.targetElement)&&(e=!1),this.areaPinHover=e,this.updateAreaActiveAttributeOnElement()}catch(t){this.catchError("Error in AreaPinPortalComponent setAreaPinHover: ",t)}}updateAreaActiveAttributeOnElement(){try{this.loggingService.log("%c[WB] Calling FUNCTION: updateAreaActiveAttributeOnElement","color: green;"),this.selected||this.areaPinHover?this.targetElement&&(this.targetElement?.hasAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE)||this.targetElement?.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE,"true")):this.targetElement&&this.targetElement?.hasAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE)&&this.targetElement?.removeAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE)}catch(e){this.catchError("Error in AreaPinPortalComponent updateAreaActiveAttributeOnElement: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe(),this.componentConfigSignal()?.isResizing&&document.body.classList.remove(h.BODY_CLASSES.VELT_PIN_DRAGGING)}catch(e){this.catchError("Error in AreaPinPortalComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.catchError("Error in AreaPinPortalComponent unsubscribe: ",e)}}catchError(e,t,n){try{this.loggingService.catch(e,t,E(g({},n||{}),{annotationId:this.componentConfigSignal()?.areaPinAnnotation?.annotationId}))}catch{}}};l.\u0275fac=function(t){return new(t||l)(I(G),I(K),I(W),I(Se),I(X),I(H),I(D))},l.\u0275cmp=ne({type:l,selectors:[["snippyly-area-pin-portal"]],hostVars:6,hostBindings:function(t,n){t&1&&w("mouseenter",function(){return n.onMouseEnter()})("mouseleave",function(){return n.onMouseLeave()}),t&2&&(ot("id",n.id),ie("data-velt-element",n.veltElement),ee("selected",n.selected)("resizing",n.resizing))},inputs:{multipleAreaPinsSelected:"multipleAreaPinsSelected",avatarErrorImage:"avatarErrorImage",user:"user",targetElement:"targetElement"},standalone:!1,decls:1,vars:1,consts:[[4,"ngIf"],["id","line1",1,"line","vertical",3,"click"],["id","line2",1,"line","horizontal",3,"click"],["id","line3",1,"line","vertical",3,"click"],["id","line4",1,"line","horizontal",3,"click"],["id","handle1","cdkDrag","",1,"handle",3,"cdkDragStarted","cdkDragMoved","cdkDragEnded","click","cdkDragDisabled"],["id","handle2","cdkDrag","",1,"handle",3,"cdkDragStarted","cdkDragMoved","cdkDragEnded","click","cdkDragDisabled"],[3,"id","click",4,"ngIf"],[3,"click","id"],[3,"saveComment","ngStyle","annotationDragging","annotation","commentPinSelected","multipleCommentPinSelected","user"]],template:function(t,n){t&1&&j(0,cn,2,1,"ng-container",0),t&2&&L("ngIf",n.componentConfigSignal())},dependencies:[ue,ht,ut],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;z-index:var(--velt-comment-pin-z-index)!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));-webkit-text-fill-color:initial!important}*[_ngcontent-%COMP%]:empty{display:revert!important}.line[_ngcontent-%COMP%]{position:absolute;opacity:.4;transition:opacity .2s ease-in-out}.line.vertical[_ngcontent-%COMP%]{border-left:1px dashed;border-right:1px dashed}.line.horizontal[_ngcontent-%COMP%]{border-top:1px dashed;border-bottom:1px dashed}.handle[_ngcontent-%COMP%]{position:absolute;transform:none!important;border-radius:100%}.handle[_ngcontent-%COMP%]:not(.drag-disabled){cursor:grab}#handle1[_ngcontent-%COMP%]{opacity:.4;transition:opacity,transform .2s ease-in-out}#handle2[_ngcontent-%COMP%]{background-color:transparent!important}.resizing[_nghost-%COMP%] div[_ngcontent-%COMP%]{z-index:1}.resizing[_nghost-%COMP%] .handle[_ngcontent-%COMP%]{cursor:grabbing}[_nghost-%COMP%]:hover #handle1[_ngcontent-%COMP%], .resizing[_nghost-%COMP%] #handle1[_ngcontent-%COMP%], .selected[_nghost-%COMP%] #handle1[_ngcontent-%COMP%]{opacity:1;transform:scale(2)!important}[_nghost-%COMP%]:hover .line[_ngcontent-%COMP%], .resizing[_nghost-%COMP%] .line[_ngcontent-%COMP%], .selected[_nghost-%COMP%] .line[_ngcontent-%COMP%]{opacity:1}snippyly-comment-pin[_ngcontent-%COMP%], velt-comment-pin-embed[_ngcontent-%COMP%], snippyly-comment-pin-embed[_ngcontent-%COMP%]{position:absolute;bottom:calc(100% - 8px)}.s-metadata[_ngcontent-%COMP%]{position:fixed;bottom:10px;right:10px;background:#fff;font-size:14px;border:1px solid;padding:10px;box-shadow:1px 1px 1px 1px;border-radius:4px}.s-metadata[_ngcontent-%COMP%] table[_ngcontent-%COMP%]{border-collapse:collapse}.s-metadata[_ngcontent-%COMP%] table[_ngcontent-%COMP%] td[_ngcontent-%COMP%], .s-metadata[_ngcontent-%COMP%] table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{border:1px solid;padding:4px 8px}"],changeDetection:0});let d=l;return d})();var Qt=(()=>{let l=class l{constructor(e,t,n,o,s){this.domService=e,this.componentFactoryResolver=t,this.injector=n,this.appRef=o,this.loggingService=s,this.areasPinById={}}setAreaPin(e){try{if(!this.areasPinById[e.annotationId])this.setPinPortal(e);else{let t=this.areasPinById[e.annotationId].portalRef?.instance?.componentConfigSignal().isResizing;if(e.areaProperties?.targetElement===this.areasPinById[e.annotationId]?.annotation?.areaProperties?.targetElement||t){let n=this.areasPinById[e.annotationId].portalRef,o=this.areasPinById[e.annotationId].userTargetElement,s=this.areasPinById[e.annotationId].pinHostElement;if(document.body.contains(o)&&document.body.contains(s))n&&(n.instance.setAreaPinAnnotation(JSON.parse(JSON.stringify(e))),this.updateElementOffset(e));else{let r=this.areasPinById[e.annotationId].pinHostDomPortalOutlet;r&&(this.removeAreaPinHostAttributes(e.annotationId,this.areasPinById[e.annotationId].pinHostElement),r.detach(),delete this.areasPinById[e.annotationId],this.setPinPortal(e))}}else{let n=this.areasPinById[e.annotationId].pinHostDomPortalOutlet;n&&(this.removeAreaPinHostAttributes(e.annotationId,this.areasPinById[e.annotationId].pinHostElement),n.detach(),delete this.areasPinById[e.annotationId],this.setPinPortal(e))}}}catch(t){this.loggingService.catch("Error in AreaPinPortalService setAreaPin: ",t)}}setPinPortal(e){try{if(e?.areaProperties?.targetElement){let t=this.domService.getElementFromXPath(e?.areaProperties?.targetElement);if(t){let n=this.domService.getHostElement(t),o=new At(Ve),s=new vt(n,this.appRef,this.injector),r=s.attach(o);r.instance.setAreaPinAnnotation(JSON.parse(JSON.stringify(e))),r.instance.targetElement=t,this.areasPinById[e.annotationId]={pinHostDomPortalOutlet:s,pinPortal:o,portalRef:r,annotation:JSON.parse(JSON.stringify(e)),userTargetElement:t,pinHostElement:n},this.setAreaPinHostAttributes(e.annotationId,n),this.updateElementOffset(e)}}}catch(t){this.loggingService.catch("Error in AreaPinPortalService setPinPortal: ",t)}}setAreaPinHostAttributes(e,t){try{let n=t.getAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST);if(n){let o=n.split(",");o.includes(e)||(o.push(e),t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST,o.join(",")))}else t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST,e);this.domService.isElementOriginallyStatic(t)&&(Mt(t)||t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST_STATIC,"true"))}catch(n){this.loggingService.catch("Error in AreaPinPortalService setAreaPinHostAttributes: ",n)}}removeAreaPinHostAttributes(e,t){try{let n=t.getAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST);if(n){let o=n.split(","),s=o.indexOf(e);s>-1&&(o.splice(s,1),o.length>0?t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST,o.join(",")):t.removeAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST))}t?.getAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST)||t.removeAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST_STATIC)}catch(n){this.loggingService.catch("Error in AreaPinPortalService removeAreaPinHostAttributes: ",n)}}updateElementOffset(e){try{let{portalRef:t,userTargetElement:n,pinHostElement:o}=this.areasPinById[e.annotationId],s=this.domService.getElementOffset(n,o);t.instance.setOffsetLeft(s.offsetLeft),t.instance.setOffsetTop(s.offsetTop)}catch(t){this.loggingService.catch("Error in AreaPinPortalService updateElementOffset: ",t)}}checkPinsToRemove(e){try{let t=e.map(n=>n.annotationId);Object.keys(this.areasPinById).forEach(n=>{if(!t.includes(n)){let o=this.areasPinById[n];o.pinHostDomPortalOutlet.detach(),this.removeAreaPinHostAttributes(n,o.pinHostElement),this.domService.removeHighlightFromElement(o.pinHostElement),delete this.areasPinById[n]}})}catch(t){this.loggingService.catch("Error in AreaPinPortalService checkPinsToRemove: ",t)}}};l.\u0275fac=function(t){return new(t||l)(b(X),b(Qe),b(Ye),b(tt),b(D))},l.\u0275prov=pe({token:l,factory:l.\u0275fac,providedIn:"root"});let d=l;return d})();var Ce=(()=>{let l=class l{constructor(e,t,n,o,s,r,a){this.analyticsService=e,this.authService=t,this.domService=n,this.areaService=o,this.areaPinPortalService=s,this.serviceBook=r,this.loggingService=a,this.areaPinAnnotations=[],this.subscriptions=[],this.isFirstComponent=!0,this.commentsOnDom=!0,this.commentService=null,this.veltId=Rt(),this.veltElement=!0;try{this.loggingService.log("%c[WB] Creating CLASS: AreasContainerComponent","color: blue;"),this.serviceBook.observe(te).subscribe(c=>{this.commentService=c})}catch(c){this.loggingService.catch("Error in AreasContainerComponent constructor: ",c)}}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{let e=document.querySelector(h.TAGS.SNIPPYLY_AREAS),t=document.querySelector(h.TAGS.VELT_AREAS);t?this.veltId===t?.getAttribute(h.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent()):this.veltId===e?.getAttribute(h.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent())}catch(e){this.loggingService.catch("Error in AreasContainerComponent AfterViewInit: ",e)}}initComponent(){try{this.subscriptions.push(this.authService.getUser$().pipe(q(e=>!!e)).subscribe(e=>{e&&this.setAreaInstalledInAnalytics()},e=>{this.loggingService.catch("Error in getUser: ",e)})),this.getAllAreasOnCurrentDocument()}catch(e){this.loggingService.catch("Error in AreasContainerComponent initComponent: ",e)}}getAllAreasOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllAreasOnCurrentDocument","color: green;");try{this.subscriptions.push(this.areaService.getAllAreaAnnotations().pipe(q(e=>!!e),S(e=>this.domService.getSelectedAnnotationsMap$().pipe(v(t=>({annotations:e,selectedAnnotationsMap:t||{}})))),S(e=>(this.commentService?.getCommentsOnDom$()??C(!0)).pipe(v(t=>(this.commentsOnDom=t,{annotations:e.annotations,selectedAnnotationsMap:e.selectedAnnotationsMap,commentsOnDom:t||{}}))))).subscribe(e=>{try{this.loggingService.log(e),this.areaPinAnnotations=e?.annotations,this.commentsOnDom||(this.areaPinAnnotations=this.areaPinAnnotations?.filter(n=>!n?.targetAnnotations?.filter(o=>o?.type===M.COMMENT)?.length));let t=this.areaPinAnnotations.filter(n=>n?.areaProperties?.targetElement);this.areaPinPortalService.checkPinsToRemove(t),t.forEach(n=>{this.areaPinPortalService.setAreaPin(n)})}catch(t){this.loggingService.catch("Error in AreasContainerComponent getAllAreasOnCurrentDocument inside subscription: ",t)}},e=>{this.loggingService.catch("Error in AreasContainerComponent getAllAreasOnCurrentDocument subscription: ",e)}))}catch(e){this.loggingService.catch("Error in AreasContainerComponent getAllAreasOnCurrentDocument: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.loggingService.catch("Error in AreasContainerComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in AreasContainerComponent unsubscribe: ",e)}}setAreaInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(It.AREA_COMMENT)}catch(e){this.loggingService.catch("Error in AreasContainerComponent setAreaInstalledInAnalytics: ",e)}}};l.\u0275fac=function(t){return new(t||l)(I(G),I(K),I(X),I(H),I(Qt),I(W),I(D))},l.\u0275cmp=ne({type:l,selectors:[["snippyly-area-container"]],hostVars:2,hostBindings:function(t,n){t&2&&ie("data-velt-id",n.veltId)("data-velt-element",n.veltElement)},standalone:!1,decls:0,vars:0,template:function(t,n){},encapsulation:2,changeDetection:0});let d=l;return d})();var dn=["customBtnRef"],mn=["*"];function hn(d,l){if(d&1&&(R(0,"div",6),Je(),R(1,"svg",7),nt(2,"path",8),B()()),d&2){let i=_();x(),ee("active",i.addAreaMode)}}function gn(d,l){d&1&&it(0)}function pn(d,l){d&1&&at(0)}var _e=(()=>{let l=class l{constructor(e,t,n,o,s){this.analyticsService=e,this.authService=t,this.areaService=n,this.iamService=o,this.loggingService=s,this.showDefaultBtn=!1,this.addAreaMode=!1,this.subscriptions=[],this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(r=>{this.user=r},r=>{this.loggingService.catch("Error in AreasToolComponent getUser$ subscription: ",r)}))}ngOnInit(){}ngAfterViewInit(){try{this.customBtnRef?.nativeElement?.children?.length||(this.showDefaultBtn=!0),this.subscriptions.push(this.areaService.addAreaModeChange().subscribe(e=>{this.addAreaMode=e}))}catch(e){this.loggingService.catch("Error in AreasToolComponent AfterViewInit: ",e)}}addArea(){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{this.analyticsService.trackEvent(N.Events.Area.AREA_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 areas."):!this.authService.isPlanExpired()&&this.iamService.getRole()?this.areaService.enableAddAreaMode():this.loggingService.catch("User does not have permission to add areas."))}catch(e){this.loggingService.catch("Error in AreasToolComponent addArea: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.loggingService.catch("Error in AreasToolComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in AreasToolComponent unsubscribe: ",e)}}};l.\u0275fac=function(t){return new(t||l)(I(G),I(K),I(H),I(Pe),I(D))},l.\u0275cmp=ne({type:l,selectors:[["snippyly-area-tool"]],viewQuery:function(t,n){if(t&1&&st(dn,5),t&2){let o;ct(o=lt())&&(n.customBtnRef=o.first)}},hostVars:1,hostBindings:function(t,n){t&2&&ie("data-velt-element",n.veltElement)},standalone:!1,ngContentSelectors:mn,decls:7,vars:4,consts:[["customBtnRef",""],["content",""],[1,"snippyly-area-btn-container",3,"click"],["class","action-btn",4,"ngIf"],[1,"custom-btn-container"],[4,"ngTemplateOutlet"],[1,"action-btn"],["width","32","height","32","viewBox","0 0 32 32","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon"],["fill-rule","evenodd","clip-rule","evenodd","d","M22.6315 18.0207C23.3673 17.9913 23.9399 17.371 23.9105 16.6352L23.6567 10.2894C23.6289 9.59486 23.0723 9.03819 22.3778 9.01041L16.0319 8.75654C15.2961 8.7271 14.6758 9.29972 14.6463 10.0355C14.6169 10.7713 15.1895 11.3916 15.9253 11.4211L19.2283 11.5532L10.0679 20.7136C9.54724 21.2343 9.54724 22.0785 10.0679 22.5992C10.5886 23.1199 11.4329 23.1199 11.9536 22.5992L21.1139 13.4389L21.246 16.7418C21.2754 17.4775 21.8957 18.0502 22.6315 18.0207Z","fill","#8F95B2"]],template:function(t,n){if(t&1){let o=oe();rt(),R(0,"div",2),w("click",function(r){return y(o),n.addArea(),T(r.stopPropagation())}),j(1,hn,3,2,"div",3),R(2,"div",4,0),j(4,gn,1,0,"ng-container",5),B()(),j(5,pn,1,0,"ng-template",null,1,mt)}if(t&2){let o=dt(6);ee("active",n.addAreaMode),x(),L("ngIf",n.showDefaultBtn),x(3),L("ngTemplateOutlet",o)}},dependencies:[ue,gt],encapsulation:2,changeDetection:0});let d=l;return d})();var Ie=class extends Gt{constructor(l){super(l),this.getService(D).log("%c[WB] Creating CLASS: AreaElement","color: blue;"),this.enableArea=this._enableAreaComment,this.disableArea=this._disableAreaComment,this.enableAreaComment=this._enableAreaComment,this.disableAreaComment=this._disableAreaComment}_enableAreaComment(){this.getService(D).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(N.Events.Area.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(H).enableArea()}catch(l){this.getService(D).catch("Error in _enableAreaComment: ",l)}}_disableAreaComment(){this.getService(D).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(N.Events.Area.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(H).disableArea()}catch(l){this.getService(D).catch("Error in _disableAreaComment: ",l)}}};var qt=(()=>{let l=class l{};l.\u0275fac=function(t){return new(t||l)},l.\u0275mod=et({type:l}),l.\u0275inj=Ke({imports:[pt,Pt,St,ft,Wt]});let d=l;return d})();function un(d){d.get(D).log("%c[WB] Loading area feature chunk","color: blue;"),d.get(W).set(kt,d.get(H));let t=qe(qt,d).injector;return be(t,h.TAGS.VELT_AREA_TOOL,_e),be(t,h.TAGS.SNIPPYLY_AREA_TOOL,_e),be(t,h.TAGS.VELT_AREAS,Ce),be(t,h.TAGS.SNIPPYLY_AREAS,Ce),new Ie(d)}function be(d,l,i){if(customElements.get(l))return;let e=Et(i,d);customElements.define(l,e)}export{un as default};
|
|
1
|
+
import{a as Xt,b as Kt}from"./chunk-JQZKADOA.js";import{t as Wt}from"./chunk-4HAFXUDN.js";import"./chunk-CR275X25.js";import"./chunk-SN6HOFPK.js";import{c as ut,d as ft}from"./chunk-EB7SHB2S.js";import{a as Jt}from"./chunk-FWIDRPYU.js";import"./chunk-J35LMO3C.js";import"./chunk-JWSICAW6.js";import"./chunk-KNYRVMQK.js";import{b as jt}from"./chunk-5ACPKO6C.js";import"./chunk-3BCXNETY.js";import{a as Pe}from"./chunk-ZRITZXNF.js";import{a as Et}from"./chunk-SYLJZSJP.js";import{I as Pt,r as At,t as vt,v as St,za as _t}from"./chunk-GHN6NWBT.js";import{a as Gt}from"./chunk-67RGQF3Z.js";import{D as $t,E as Se,g as Be}from"./chunk-NTFMMZRZ.js";import{Aj as Ne,Bb as _,C as We,Cb as rt,D as Ge,Db as at,E as q,Fb as st,Fj as V,Gb as ct,Gd as Ct,Ha as x,Hb as lt,He as h,Hg as se,Hi as N,Ic as ue,Ij as Ht,Jg as fe,K as he,Kb as dt,Ki as Ft,Lb as U,M as ae,Mb as ee,Mc as ht,Nc as gt,Ne as bt,Nj as Vt,O as Xe,Oa as Qe,Pj as Ut,Qh as Ae,Ra as I,Rc as pt,Rh as Me,Te as yt,Tg as Le,Th as Mt,V as S,Va as qe,Wa as ne,Xa as et,Zf as Re,Zi as te,_ as ge,a as g,ab as j,ai as Nt,b as E,ba as pe,bh as we,ca as Ke,cc as Oe,ci as Bt,db as tt,ea as b,ei as ve,fb as ie,g as le,i as $e,ij as kt,ja as y,ka as T,kg as Tt,l as re,la as Je,mh as wt,na as Ye,nb as L,nj as W,o as je,ob as R,oj as G,p as de,pb as B,pe as xe,pj as D,qb as nt,qj as zt,r as C,rc as mt,re as M,rg as Dt,rk as X,sa as Ze,se as It,sg as Ot,sk as K,ub as Te,ug as xt,v,vb as De,vg as Rt,w as me,wb as it,xb as oe,yb as ot,yg as Lt,zb as w}from"./chunk-VESMHAEV.js";var H=(()=>{let l=class l{constructor(e,t,n,o,s,r,a,c,u,P,f,p,A){this.analyticsService=e,this.configService=t,this.docService=n,this.databaseService=o,this.commonDbService=s,this.authService=r,this.domService=a,this.afAuth=c,this.iamService=u,this.dialog=P,this.loggingService=f,this.userPermissionService=p,this.serviceBook=A,this.areaAnnotationById$=new re({}),this.documentPaths=null,this.areaEnabled$=new re(!0),this.allowedElementIds$=new re([]),this.addAreaMode$=new re(!1),this.notificationService=null,this.loggingService.log("%c[WB] Creating CLASS: AreaService","color: blue;"),this.serviceBook.observe(Ft).subscribe(m=>this.notificationService=m),this.areaDbReadyGate$().pipe(he(1)).subscribe(()=>{this.getDocumentPaths()},m=>{this.loggingService.catch("Error in AreaService getDb subscription: ",m)}),this.domService.onWindowPointerMove$().subscribe(m=>{if(this.addAreaMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let O=this.domService.getBackgroundElement(m.clientX,m.clientY);O&&(this.isElementInsideAllowedElements(O)?we(m.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=O,this.domService.highlightElement(this.highlightElement,h.CURSOR.AREA_PIN)):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},m=>{this.loggingService.catch("Error in AreaService onWindowPointerMove$ subscription: ",m)}),this.domService.onWindowKeyupEsc$().subscribe(m=>{this.addAreaMode$.value&&this.disableAddAreaMode()},m=>{this.loggingService.catch("Error in AreaService onWindowKeyupEsc$ subscription: ",m)}),this.domService.onDocumentClick$().subscribe(m=>{if(m&&this.addAreaMode$.value){if(m.preventDefault(),m.stopPropagation(),!we(m.target)){let O=this.domService.getBackgroundElement(m.clientX,m.clientY);O&&this.isElementInsideAllowedElements(O)&&this.addArea(m)}this.disableAddAreaMode()}},m=>{this.loggingService.catch("Error in AreaService onDocumentClick$ subscription: ",m)}),this.addAreaMode$.subscribe(m=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),m?this.domService.addClassToElement(document.body,"snippyly-add-area-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-area-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},m=>{this.loggingService.catch("Error in AreaService addAreaMode$ subscription: ",m)}),this.domService.onWindowKeyupBackspace$().subscribe(m=>{this.deleteAreaPinAnnotations("keyupBackspace")},m=>{this.loggingService.catch("Error in AreaService onWindowKeyupBackspace$ subscription: ",m)}),this.domService.onWindowKeyupDelete$().subscribe(m=>{this.deleteAreaPinAnnotations("keyupDelete")},m=>{this.loggingService.catch("Error in AreaService onWindowKeyupDelete$ subscription: ",m)})}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in AreaService","color: green;");try{this.areaAnnotationById$.next({}),this.areaEnabled$.next(!0),this.allowedElementIds$.next([]),this.addAreaMode$.next(!1),this.highlightElement=null}catch(e){this.loggingService.catch("Error in AreaService clearCache: ",e)}}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}setAllowedElementIds(e){this.allowedElementIds$.next(e||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getAllAreaAnnotations(e,t,n){this.loggingService.log("%c[WB] Calling FUNCTION: getAllAreaAnnotations","color: green;");let o,s;try{if(e&&(s=Re(e)),t&&typeof t=="object"){let r=Lt(t);o=Re(JSON.stringify(r))}}catch(r){this.loggingService.catch("Error in AreaService getAllAreaAnnotations: ",r)}return Ge(C(null),new $e(r=>Vt(()=>r.next(null)))).pipe(S(()=>this.authService.getAuthState$()),q(r=>!!r),S(r=>this.isFeatureAllowed({firebaseUser:r,annotations:[],filteredAnnotations:[]})),S(r=>r.featureAllowed?this.iamService.isUserAllowed$().pipe(v(a=>(r.featureAllowed=a,r))):C(r)),S(r=>r.featureAllowed?this.authService.isPlanExpired$().pipe(v(a=>(r.featureAllowed=!a,r))):C(r)),S(r=>r.featureAllowed?C(r).pipe(S(a=>this.docService.getDocumentPaths$().pipe(v(c=>(this.documentPaths=c,a.documentPaths=c,a)))),S(a=>s?this.getDataFromDocumentIds([s]).pipe(v(c=>(a.annotations=c||[],g({},a)))):this.docService.getDocumentIds$().pipe(S(c=>{let u=c?.length>0?c.map(P=>P.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(u).pipe(v(P=>(a.annotations=P||[],g({},a))))}))),S(a=>this.docService.getLocation$().pipe(v(c=>(a.location=c,a)))),S(a=>this.docService.getLocations$().pipe(v(c=>(a.customLocations=c,a)))),S(a=>this.docService.getExcludedLocationIds$().pipe(v(c=>(a.excludedLocationIds=c,a)))),v(a=>{if(a.filteredAnnotations=[],s&&!o)return a.filteredAnnotations=a.annotations?.slice(),a.filteredAnnotations=this.applyExcludedLocationIds(a.filteredAnnotations,a.excludedLocationIds),a;{let c=[],u=[];return o?c.push(o):(c.push(a?.location?.locationId),c.push(...Object.values(a?.customLocations||[]).map(P=>P.locationId)),a?.location?.location?.id&&u.push(a?.location?.location?.id),u.push(...Object.values(a?.customLocations||{}).map(P=>P.location?.id).filter(P=>!!P))),a.filteredAnnotations=this.filterAnnotationsByLocationIds(a?.annotations,c,u),a.filteredAnnotations=this.applyExcludedLocationIds(a.filteredAnnotations,a.excludedLocationIds),a}}),S(a=>n?C(a):a?.annotations?.length?this.domService.onWindowResize$().pipe(v(()=>a)):C(a)),S(a=>n?C(a):a?.annotations?.length?this.domService.onDomChange$("AreaService getAllAreaAnnotations").pipe(v(()=>a)):C(a)),v(a=>(a.filteredAnnotations=a.filteredAnnotations?.map(c=>{let u=Object.assign({},c);return this.shouldSkipAreaPositionCalculation(u)?u.areaProperties=void 0:u.areaProperties=this.calculateAreaAnnotationPosition(u),u}),a)),S(a=>a?.filteredAnnotations?C(a?.filteredAnnotations||[]):C([])),S(a=>{if(this.authService.isFeatureAllowed(M.COMMENT))return C(a);{let c=a?.filter(u=>!u?.targetAnnotations?.filter(P=>P?.type===M.COMMENT)?.length);return C(c)}})):C([])),ae(Bt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(q(t=>!!t),v(t=>E(g({},e),{config:t})),S(t=>this.authService.getUser$().pipe(v(n=>E(g({},t),{user:n})))),S(t=>xt(t.config,t.user,M.AREA)?C(E(g({},t),{featureAllowed:!0})):(this.loggingService.warn("Area feature is not allowed."),C(E(g({},t),{featureAllowed:!1})))),ae((t,n)=>t?.featureAllowed===n?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getDataFromDocuments(e){if(this.configService.getApiKey()){let{documentIds:t,filters:n}=e;if(t?.some(f=>!f)||!this.documentPaths)return C([]);let o=this.docService.getDocumentPaths()?.veltFolderId,s=C([]),r={useCollectionGroup:!0,isCollection:!0,useQuery:!0};this.commonDbService.shouldUseFirestore()||(r.documentId=t?.length?t[0]:void 0,r.organizationId=this.documentPaths?.organizationId);let a=this.commonDbService.usesPortableChannelFeed(Be),c=this.userPermissionService?.getIsContextEnabled(),u=a?Xt():null,P=a&&c?[h.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()]:null;if(a)s=this.commonDbService.dbListener({feature:"allAreas",properties:E(g({},r),{organizationId:this.documentPaths?.organizationId,documentIds:t})}).pipe(ge(),v(f=>ve(JSON.parse(JSON.stringify([f])))));else if(c){let f=[h.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],p=[];for(let A=0;A<(f?.length??0);A+=h.LISTENER_CONTEXT_BATCH_SIZE)p.push(f?.slice(A,A+h.LISTENER_CONTEXT_BATCH_SIZE)??[]);s=me(p.map(A=>this.commonDbService.dbListener({feature:"allAreas",properties:E(g({},r),{firestoreQuery:[Ne(V("metadata.apiKey","==",this.configService?.getApiKey()),V("metadata.documentId","in",t),V("metadata.organizationId","==",this.documentPaths?.organizationId),...o?[V("metadata.veltFolderId","==",o)]:[],...A?.length?[V("context.accessFields","array-contains-any",A)]:[])]})}).pipe(ge()))).pipe(v(A=>ve(A)))}else{let f=[];for(let p=0;p<(t?.length??0);p+=h.LISTENER_BATCH_SIZE)f.push(t?.slice(p,p+h.LISTENER_BATCH_SIZE)??[]);s=me(f.map(p=>this.commonDbService.dbListener({feature:"allAreas",properties:E(g({},r),{firestoreQuery:[Ne(V("metadata.apiKey","==",this.configService?.getApiKey()),V("metadata.documentId","in",p),V("metadata.organizationId","==",this.documentPaths?.organizationId),...o?[V("metadata.veltFolderId","==",o)]:[])]})}).pipe(ge()))).pipe(v(p=>ve(p)))}return s.pipe(v(({data:f,operation:p})=>{let A=[];return f&&(A=Object.values(f??{}).filter(m=>typeof m=="object")),A=this.applyPortableQueryScopeFilter(A,{isPortableFeed:a,scope:{veltFolderId:o},contextFields:P,evictDropped:!n,resultSet:u}),{data:A,operation:p}}),v(({data:f,operation:p})=>{if(!t)return{data:f,documentMap:{},operation:p};let A=f.reduce((m,O)=>{let $=O.metadata?.documentId;return $&&(m[$]||(m[$]=[]),m[$].push(O)),m},{});return{data:f,documentMap:A,operation:p}}),v(({data:f,documentMap:p,operation:A})=>{if(!n)if(A?.type==="removed"){if(A?.ids?.length){let m=this.areaAnnotationById$.value;A?.ids?.forEach(O=>{delete m?.[O]}),this.areaAnnotationById$.next(m)}}else Object.entries(p??{}).forEach(([m,O])=>{this.setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:m,annotations:O})});return f}))}else return C([])}setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:n,queryHash:o}){try{if(t){e||(e=h.NO_ORGANIZATION_ID),o||(o=h.DEFAULT_QUERY_HASH);let s={};n?.forEach(a=>{a?.annotationId&&(s[a?.annotationId]=a)});let r=g(g({},this.areaAnnotationById$.value),s);this.areaAnnotationById$.next(r)}}catch(s){this.loggingService.catch("Error in AreaService setAreaAnnotationsByOrganizationIdAndDocumentId:",s)}}applyPortableQueryScopeFilter(e,t){try{let{kept:n,departed:o}=Kt(e,t,s=>Ot(Dt(s,t.scope),t.contextFields));return o.length&&this.evictAreaAnnotationsFromLocalCache(o),n}catch(n){return this.loggingService.catch("Error in AreaService applyPortableQueryScopeFilter: ",n),e}}evictAreaAnnotationsFromLocalCache(e){try{if(!e?.length)return;let t=this.areaAnnotationById$?.value;if(t&&e.some(n=>n in t)){let n=g({},t);e.forEach(o=>{delete n[o]}),this.areaAnnotationById$.next(n)}}catch(t){this.loggingService.catch("Error in AreaService evictAreaAnnotationsFromLocalCache: ",t)}}getAnnotationById(e){try{return this.areaAnnotationById$.value?.[e]?this.areaAnnotationById$.value?.[e]:void 0}catch(t){this.loggingService.catch("Error in AreaService getAnnotationById: ",t);return}}applyExcludedLocationIds(e,t){return t?.length?e?.filter(n=>n?.location?.id?!t.includes(n.location.id):!0):e}filterAnnotationsByLocationIds(e,t,n){try{return e.filter(o=>t.includes(o.locationId)||n?.includes(o?.location?.id)||t?.find(s=>s==o?.location?.id)||n?.find(s=>s==o?.locationId+""))}catch(o){return this.loggingService.catch("Error in AreaService filterAnnotationsByLocations:",o),[]}}calculateAreaAnnotationPosition(e,t=!1){try{if(e.targetElements?.length){let n=e.targetElements[0],o=e.targetElements[1];if(n?.xpath&&o?.xpath||n?.anchor&&o?.anchor){let s=null,r=null;if(s=this.resolveAreaPointElement(n),r=this.resolveAreaPointElement(o),s&&r){let a=Ae(s,r);if(a){let c=s,u=r,P=c.getBoundingClientRect(),f=u.getBoundingClientRect(),p=t?P.width:c.offsetWidth||P.width,A=t?P.height:c.offsetHeight||P.height,m=t?f.width:u.offsetWidth||f.width,O=t?f.height:u.offsetHeight||f.height,$={};p&&A&&($={top:A*n.topPercentage/100,left:p*n.leftPercentage/100});let ye={};m&&O&&(ye={top:O*o.topPercentage/100,left:m*o.leftPercentage/100});let Ue=!t,F=Me($.left,$.top,s,a,Ue),k=Me(ye.left,ye.top,r,a,Ue),J,Y,Z,Q,z={};F.x>k.x?F.y>k.y?(Q={x:F.x,y:F.y},J={x:k.x,y:k.y},z.handle1=Q,z.handle2=J):(Y={x:F.x,y:F.y},Z={x:k.x,y:k.y},z.handle1=Y,z.handle2=Z):F.y>k.y?(Z={x:F.x,y:F.y},Y={x:k.x,y:k.y},z.handle1=Z,z.handle2=Y):(J={x:F.x,y:F.y},Q={x:k.x,y:k.y},z.handle1=J,z.handle2=Q);let en={topLeft:J||{x:Z?.x,y:Y?.y},bottomRight:Q||{x:Y?.x,y:Z?.y},topRight:Y||{x:Q?.x,y:J?.y},bottomLeft:Z||{x:J?.x,y:Q?.y}};return z.coordinates=en,z.targetElement=this.domService.getXPath(a),z}}}}return}catch(n){this.loggingService.catch("Error in AreaService calculateAreaAnnotationPosition:",n);return}}addArea(e,t=[],n,o,s,r){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{let a=this.authService.getUser();if(a)if(a.isReadOnly||a.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add areas.");else{let c=new yt;o&&(c.annotationId=o),c.from=a,c.color=h.DEFAULT_ANNOTATION_COLOR,c.lastUpdated=this.timestamp,n&&(c.targetAnnotations=[n]),c.props=new bt;let u=this.domService.getCurrentWindowSizeValue();if(c.props.screenWidth=u.screenWidth,c.props.screenHeight=u.screenHeight,c.props.screenScrollHeight=u.screenScrollHeight,c.props.viewportWidth=window.innerWidth,c.props.viewportHeight=window.innerHeight,e||t?.length>0){let p=e?this.getPointsForAreaPinAnnotation(e):t;c.targetElements=[],p.forEach(A=>{c.targetElements.push(this.domService.getTargetElementForCursorPosition(e,void 0,void 0,void 0,void 0,!0,{clientX:A.x,clientY:A.y}))})}this.setLocationToAreaAnnotation(c),s&&(c.locationId=s.locationId,c.location=s.location),c.pageInfo=Le(),c.pageInfo&&(c.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let P=this.getElementForAreaAnnotation(c),f=this.docService.getBaseMetadata("area",{element:P});if(c?.metadata||(c.metadata={}),c.metadata=g(g({},c.metadata),f),r?.access&&r?.accessFields){if(!this.userPermissionService?.hasUserContextAccess({userId:a.userId,accessFields:r.accessFields})){this.loggingService.catch("User does not have context access to add area annotation.",void 0,void 0,!0);return}r.accessFields.some(p=>Tt(p))||(c.context={access:r.access,accessFields:r.accessFields})}return this.saveAreaToDb(c),c}return}catch(a){this.loggingService.catch("Error in AreaService addArea: ",a);return}}setLocationToAreaAnnotation(e){try{let t=this.docService.getLocation();t?(e.locationId=t.locationId,e.location=t.location):(delete e.locationId,delete e.location)}catch(t){this.loggingService.catch("Error in AreaService setLocationToAreaAnnotation:",t)}}shouldSkipAreaPositionCalculation(e){try{if(!e?.locationId)return!1;let t=this.docService.getLocation();if(Nt({location:t?.location,locationId:t?.locationId},{location:e?.location,locationId:e?.locationId}))return!1;let n=this.resolveAreaCommonParent(e),o=this.docService.getAdditionLocationFromElement(n),s=o?this.docService.genarateLocationId(o):void 0,r;return e?.location?.id&&e?.location?.id===o?.id||s&&s===e?.locationId?r=!1:r=!0,r}catch(t){return this.loggingService.catch("Error in AreaService shouldSkipAreaPositionCalculation:",t),!1}}resolveAreaPointElement(e){let t=null;if(e?.anchor){let n=this.domService.resolveAnchorRecord(e.anchor);return n?.element&&n?.element instanceof HTMLElement&&!se(n.element)&&this.domService.isElementVisible(n.element)&&fe(n.element)&&(t=n.element),t}return e?.xpath&&(t=this.domService.getElementFromXPath(e.xpath),t&&se(t)&&(t=null),this.domService.isXpathWithId(e.xpath)||(!t&&e.cfXpath&&(t=this.domService.getElementFromXPath(e.cfXpath),t&&se(t)&&(t=null)),!t&&e.fXpath&&(t=this.domService.getElementFromXPath(e.fXpath),t&&se(t)&&(t=null)))),t}resolveAreaCommonParent(e){let t=this.resolveAreaPointElement(e?.targetElements?.[0]),n=this.resolveAreaPointElement(e?.targetElements?.[1]);return t&&n?Ae(t,n):null}getElementForAreaAnnotation(e){try{let t,n,o;if(e.targetElements?.length){if(e.targetElements[0]?.anchor){let s=this.domService.resolveAnchorRecord(e.targetElements[0].anchor);s?.element&&this.domService.isElementVisible(s.element)&&fe(s.element)&&(n=s.element)}else e.targetElements[0]?.xpath&&(n=this.domService.getElementFromXPath(e.targetElements[0].xpath));if(e.targetElements[1]?.anchor){let s=this.domService.resolveAnchorRecord(e.targetElements[1].anchor);s?.element&&this.domService.isElementVisible(s.element)&&fe(s.element)&&(o=s.element)}else e.targetElements[1]?.xpath&&(o=this.domService.getElementFromXPath(e.targetElements[1].xpath))}return n&&o&&(t=Ae(n,o)),t}catch(t){return this.loggingService.catch("Error in AreaService getElementForAreaAnnotation: ",t),null}}saveAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveAreaToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(M.AREA)&&me([this.docService.getDocumentPaths$(),this.areaDbReadyGate$().pipe(v(()=>!0))]).pipe(q(([t,n])=>!!t&&!!n),he(1),S(([t,n])=>{if(this.documentPaths=t,this.documentPaths?.area){e.annotationId||(e.annotationId=this.commonDbService.generateDocumentId()),e.pageInfo&&(e.pageInfo.areaUrl=this.generateAreaUrl(e));let o=JSON.parse(JSON.stringify(e));if(o.position=null,!o?.metadata?.documentId){o?.metadata||(o.metadata={});let a=this.docService.getBaseMetadata("area");o.metadata=g(g({},o?.metadata),a)}this.domService.toggleAnnotationSelection(o),this.analyticsService.trackEvent(N.Events.Area.AREA_ADDED,{annotationId:e.annotationId});let{documentId:s,organizationId:r}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:s,organizationId:r},data:JSON.parse(JSON.stringify(o))})}else return C(null)})).subscribe(()=>{},t=>{this.loggingService.catch("Error in AreaService saveAreaToDb subscription: ",t)})}catch(t){this.loggingService.catch("Error in AreaService saveAreaToDb: ",t)}}areaDbReadyGate$(){return Ut({isPortableFeedActive:()=>this.commonDbService?.usesPortableChannelFeed(Be),firebaseDb$:()=>this.databaseService.getDb(),onError:(e,t)=>this.loggingService.catch(`Error in AreaService areaDbReadyGate$ ${e}: `,t)})}getDocumentIdAndOrganizationIdFromAreaAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(t){return this.loggingService.catch("Error in AreaService getDocumentIdAndOrganizationIdFromAreaAnnotation: ",t),{}}}updateArea(e,t=!1,n){try{n&&this.setLocationToAreaAnnotation(e),t&&this.updateNotificationsDatabase(e,xe.UPDATED),this.updateAreaToDb(e)}catch(o){this.loggingService.catch("Error in AreaService updateArea: ",o)}}updateAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateAreaToDb","color: green;");try{if(this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(M.AREA)){let t=JSON.parse(JSON.stringify(e));if(t.position=null,!t?.metadata?.documentId){t?.metadata||(t.metadata={});let s=this.docService.getBaseMetadata("area");t.metadata=g(g({},t?.metadata),s)}let{documentId:n,organizationId:o}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:n,organizationId:o},data:JSON.parse(JSON.stringify(t))})}}catch(t){this.loggingService.catch("Error in AreaService updateAreaToDb: ",t)}}deleteAreaPinAnnotations(e){try{let t=this.domService.getSelectedAnnotationsMap(),n=this.authService.getUser(),o=[];Object.keys(t??{}).forEach(s=>le(this,null,function*(){let r=t[s];r.type==="area"&&n&&r.from&&(n?.isAdmin||r.from.userId===n.userId)&&o.push(r)})),o?.length&&(this.analyticsService.trackEvent(N.Events.Area.AREA_DELETE_TRIGGERED,{triggerType:e,annotationId:o.map(s=>s.annotationId).join()}),this.dialog.open(jt,{panelClass:"velt-mat-dialog-container",data:{title:"Delete area?",message:"This selected area will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"area"}}).afterClosed().pipe(he(1)).subscribe(s=>{s&&(o.forEach(r=>le(this,null,function*(){yield this.deleteAreaPinAnnotation(r)})),setTimeout(()=>{document.querySelectorAll(`[${h.SNIPPYLY_HIGHLIGHT}]`).forEach(a=>{this.domService.removeHighlightFromElement(a)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"area")}catch(t){this.loggingService.catch("Error in AreaService deleteAreaPinAnnotations: ",t)}}getAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let n={};return Object.values(this.areaAnnotationById$.value??{}).forEach(o=>{o?.metadata?.documentId==t&&o?.metadata?.organizationId==e&&(n[o?.annotationId]=o)}),Object.values(n??{})}catch(n){return this.loggingService.catch("Error in AreaService getAreaAnnotationsByOrganizationIdAndDocumentId:",n),[]}}onDeleteTargetAnnotation(e,t){try{if(this.docService.getDocumentId()&&this.areaAnnotationById$.value){let o=Object.values(this.areaAnnotationById$.value||{}),s;t?s=o.find(r=>r?.annotationId===t):s=o.find(r=>r?.targetAnnotations?.find(a=>a?.annotationId===e)),s&&(s.targetAnnotations=s.targetAnnotations?.filter(r=>r?.annotationId!==e),s.targetAnnotations?.length?this.updateAreaToDb(s):this.deleteAreaPinAnnotation(s))}}catch(n){this.loggingService.catch("Error in AreaService onDeleteTargetAnnotation: ",n)}}deleteAreaPinAnnotation(e){if(this.authService.isFeatureAllowed(M.AREA)&&this.documentPaths?.area&&e?.annotationId){this.updateNotificationsDatabase(e,xe.DELETED),this.analyticsService.trackEvent(N.Events.Area.AREA_DELETED,{annotationId:e.annotationId});let{documentId:t,organizationId:n}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.deleteData({feature:"area",properties:{id:e.annotationId,documentId:t,organizationId:n}})}else return Promise.resolve()}enableArea(){try{this.areaEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in AreaService enableArea: ",e)}}disableArea(){try{this.areaEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in AreaService disableArea: ",e)}}getAreaEnabled$(){try{return this.areaEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled$: ",e),C(!1)}}getAreaEnabled(){try{return this.areaEnabled$.value}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled: ",e),!1}}enableAddAreaMode(){this.authService.isFeatureAllowed(M.AREA)?(this.analyticsService.trackEvent(N.Events.Area.AREA_ADD_MODE_ENABLED),this.addAreaMode$.next(!0)):this.loggingService.catch("Error in AreaService enableAddAreaMode: ","Area feature is not enabled.")}disableAddAreaMode(){this.analyticsService.trackEvent(N.Events.Area.AREA_ADD_MODE_DISABLED),this.addAreaMode$.next(!1)}addAreaModeChange(){return this.addAreaMode$.asObservable()}getPointsForAreaPinAnnotation(e){let t=[],n=e,o=n?.touches?.length?n.touches[0]?.clientX:n.clientX,s=n?.touches?.length?n.touches[0]?.clientY:n.clientY;return t.push({x:o,y:s}),t.push({x:o+100,y:s+100}),t}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(e){try{return this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)}catch(t){return this.loggingService.catch("Error in AreaService isElementInsideAllowedElements: ",t),!1}}updateNotificationsDatabase(e,t){try{let n={annotationData:e,actionType:t,notificationSource:"area"};this.notificationService?.updateNotificationDatabase(n)}catch(n){this.loggingService.catch("Error in AreaService updateNotificationsDatabase: ",n)}}getAreaUrl(e){try{return e?.pageInfo?.areaUrl?e.pageInfo.areaUrl:(e?.pageInfo||(e.pageInfo=Le(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.areaUrl=this.generateAreaUrl(e),this.updateArea(e),e.pageInfo?.areaUrl)}catch(t){this.loggingService.catch("Error in AreaService getAreaUrl: ",t);return}}generateAreaUrl(e){let t;try{t=new URL(e?.pageInfo?.url||window.location.href)}catch(n){this.loggingService.catch("Error in AreaService generateAreaUrl: ",n),t=new URL(window.location.href)}return t.searchParams.delete(h.URL_PARAMS.TAG_ID),t.searchParams.append(h.URL_PARAMS.TAG_ID,e.annotationId),t.href}generateAreaAnnotationId(){return le(this,null,function*(){try{if(this.docService.getDocumentPaths()?.area){let t=this.commonDbService.generateDocumentId();return yield wt(10),t||""}else return""}catch(e){return this.loggingService.catch("Error in AreaService generateAreaAnnotationId: ",e),""}})}};l.\u0275fac=function(t){return new(t||l)(b(G),b(zt),b(Se),b(Ht),b($t),b(K),b(X),b(Ct),b(Pe),b(_t),b(D),b(Jt),b(W))},l.\u0275prov=pe({token:l,factory:l.\u0275fac,providedIn:"root"});let d=l;return d})();var Zt=()=>({bottom:"calc(100% - 8px)",color:"green"});function rn(d,l){if(d&1){let i=oe();R(0,"div",8),w("click",function(){y(i);let t=_(3);return T(t.togglePinSelection())}),R(1,"velt-comment-pin-embed",9),w("saveComment",function(t){y(i);let n=_(3);return T(n.saveComment(n.veltEmit(t)))}),B()()}if(d&2){let i=_(2).ngIf,e=_();L("id","comment-pin-container-"+(i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId)),x(),U("left",8,"px"),L("ngStyle",Oe(9,Zt))("annotationDragging",i.isResizing)("annotation",i.commentPinAnnotation)("commentPinSelected",i.selectedAnnotationsMap[i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId]&&e.objectKeys(i.selectedAnnotationsMap).length===1)("multipleCommentPinSelected",i.selectedAnnotationsMap[i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId]&&e.objectKeys(i.selectedAnnotationsMap).length>1)("user",e.user)}}function an(d,l){if(d&1){let i=oe();R(0,"div",8),w("click",function(){y(i);let t=_(3);return T(t.togglePinSelection())}),R(1,"velt-comment-pin-embed",9),w("saveComment",function(t){y(i);let n=_(3);return T(n.saveComment(n.veltEmit(t)))}),B()()}if(d&2){let i=_(2).ngIf,e=_();L("id","comment-pin-container-"+(i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId)),x(),U("left",8,"px"),L("ngStyle",Oe(9,Zt))("annotationDragging",i.isResizing)("annotation",i.multiThreadCommentAnnotation)("commentPinSelected",!!i.selectedAnnotationsMap[i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId])("multipleCommentPinSelected",i.selectedAnnotationsMap[i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId]&&e.objectKeys(i.selectedAnnotationsMap).length>1)("user",e.user)}}function sn(d,l){if(d&1){let i=oe();Te(0),R(1,"div",1),w("click",function(){y(i);let t=_(2);return T(t.togglePinSelection())}),B(),R(2,"div",2),w("click",function(){y(i);let t=_(2);return T(t.togglePinSelection())}),B(),R(3,"div",3),w("click",function(){y(i);let t=_(2);return T(t.togglePinSelection())}),B(),R(4,"div",4),w("click",function(){y(i);let t=_(2);return T(t.togglePinSelection())}),B(),R(5,"div",5),w("cdkDragStarted",function(){y(i);let t=_(2);return T(t.onResizeHandleDragStart("topLeft"))})("cdkDragMoved",function(t){y(i);let n=_(2);return T(n.onResizeHandleDragMove(t,"topLeft"))})("cdkDragEnded",function(){y(i);let t=_(2);return T(t.onResizeHandleDragEnd("topLeft"))})("click",function(){y(i);let t=_(2);return T(t.togglePinSelection())}),B(),R(6,"div",6),w("cdkDragStarted",function(){y(i);let t=_(2);return T(t.onResizeHandleDragStart("bottomRight"))})("cdkDragMoved",function(t){y(i);let n=_(2);return T(n.onResizeHandleDragMove(t,"bottomRight"))})("cdkDragEnded",function(){y(i);let t=_(2);return T(t.onResizeHandleDragEnd("bottomRight"))})("click",function(){y(i);let t=_(2);return T(t.togglePinSelection())}),j(7,rn,2,10,"div",7)(8,an,2,10,"div",7),B(),De()}if(d&2){let i=_().ngIf,e=_();x(),U("border-color",i.areaAnnotationColor)("width",e.LINE_THICKNESS,"px")("height",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.y)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.y),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),x(),U("border-color",i.areaAnnotationColor)("height",e.LINE_THICKNESS,"px")("width",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomRight==null?null:i.areaProperties.coordinates.bottomRight.x)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.x),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),x(),U("border-color",i.areaAnnotationColor)("width",e.LINE_THICKNESS,"px")("height",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomRight==null?null:i.areaProperties.coordinates.bottomRight.y)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topRight==null?null:i.areaProperties.coordinates.topRight.y),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomRight==null?null:i.areaProperties.coordinates.bottomRight.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topRight==null?null:i.areaProperties.coordinates.topRight.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),x(),U("border-color",i.areaAnnotationColor)("height",e.LINE_THICKNESS,"px")("width",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topRight==null?null:i.areaProperties.coordinates.topRight.x)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.x),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),x(),U("background-color",i.areaAnnotationColor)("width",e.DRAG_HANDLE_SIZE,"px")("height",e.DRAG_HANDLE_SIZE,"px")("left",(i.areaProperties==null||i.areaProperties.handle1==null?null:i.areaProperties.handle1.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft)-e.DRAG_HANDLE_SIZE/2,"px")("top",(i.areaProperties==null||i.areaProperties.handle1==null?null:i.areaProperties.handle1.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop)-e.DRAG_HANDLE_SIZE/2,"px"),ee("drag-disabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),L("cdkDragDisabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x(),U("background-color",i.areaAnnotationColor)("width",e.DRAG_HANDLE_SIZE,"px")("height",e.DRAG_HANDLE_SIZE,"px")("left",(i.areaProperties==null||i.areaProperties.handle2==null?null:i.areaProperties.handle2.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft)-e.DRAG_HANDLE_SIZE/2,"px")("top",(i.areaProperties==null||i.areaProperties.handle2==null?null:i.areaProperties.handle2.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop)-e.DRAG_HANDLE_SIZE/2,"px"),ee("drag-disabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),L("cdkDragDisabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x(),L("ngIf",i.commentPinAnnotation),x(),L("ngIf",i.multiThreadCommentAnnotation)}}function cn(d,l){if(d&1&&(Te(0),j(1,sn,9,68,"ng-container",0),De()),d&2){let i=l.ngIf,e=_();x(),L("ngIf",!i.hideAreaAnnotation||e.selected)}}var Ve=(()=>{let l=class l{get resizing(){return this.componentConfigSignal().isResizing}onMouseEnter(){this.setAreaPinHover(!0)}onMouseLeave(){this.setAreaPinHover(!1)}constructor(e,t,n,o,s,r,a){this.analyticsService=e,this.authService=t,this.serviceBook=n,this.docService=o,this.domService=s,this.areaService=r,this.loggingService=a,this.multipleAreaPinsSelected=!1,this.avatarErrorImage="",this.objectKeys=Object.keys,this.subscriptions=[],this.annotationDragging=!1,this.dragPosition=null,this.LINE_THICKNESS=0,this.DRAG_HANDLE_SIZE=10,this.skipValueUpdate=!1,this.areaPinHover=!1,this.resolvedCommentsOnDom=!1,this.componentConfigSignal=Ze({hideAreaAnnotation:!1,selected:!1,areaAnnotationColor:"#625DF5",areaProperties:void 0,resizingOffset:{top:0,left:0},offsetLeft:0,offsetTop:0,isResizing:!1,areaPinAnnotation:void 0,user:void 0,commentPinAnnotation:void 0,selectedAnnotationsMap:{},pinDragEnabled:!0}),this.selected=!1,this.veltElement=!0,this.commentService=null,this.serviceBook.observe(te).subscribe(c=>{this.commentService=c}),this.subscriptions.push(this.authService.getUser$().subscribe(c=>{this.user=c},c=>{this.catchError("Error in AreaPinPortalComponent getUser$ subscription: ",c)})),this.subscriptions.push(this.serviceBook.observe(te).pipe(S(c=>c?c.getPinDrag$():de)).subscribe(c=>{this.componentConfigSignal.update(u=>E(g({},u),{pinDragEnabled:c}))},c=>{this.catchError("Error in AreaPinPortalComponent getPinDrag$ subscription: ",c)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(c=>{this.componentConfigSignal.update(u=>(u=E(g({},u),{selectedAnnotationsMap:c}),u)),this.componentConfigSignal().areaPinAnnotation?.annotationId&&this.componentConfigSignal().selectedAnnotationsMap&&(this.selected=!!this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().areaPinAnnotation.annotationId],this.componentConfigSignal().commentPinAnnotation?this.selected=!!this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().commentPinAnnotation?.annotationId]:this.componentConfigSignal().multiThreadCommentAnnotation&&(this.selected=!!this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().multiThreadCommentAnnotation?.annotationId])),this.updateAreaActiveAttributeOnElement()},c=>{this.catchError("Error in AreaPinPortalComponent getSelectedAnnotationsMap$ subscription: ",c)}))}ngOnInit(){}ngAfterViewInit(){try{let e=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===M.COMMENT)?.annotationId,t=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===M.MULTI_THREAD)?.annotationId;e?(this.componentConfigSignal.update(n=>(n=E(g({},n),{hideAreaAnnotation:!0}),n)),this.subscriptions.push(this.serviceBook.observe(te).pipe(S(n=>n?n.getCommentAnnotationByAnnotationId(e):de),S(n=>(this.commentService?.getResolvedCommentsOnDom$()??C(!0)).pipe(v(o=>(this.resolvedCommentsOnDom=o,n))))).subscribe(n=>{this.componentConfigSignal.update(o=>(o=E(g({},o),{commentPinAnnotation:n}),o.commentPinAnnotation?(o.areaAnnotationColor=o.commentPinAnnotation?.status.color,!this.resolvedCommentsOnDom&&!(this.commentService?.getFilterCommentsOnDom()&&this.commentService?.getCommentsFromSidebarMap())&&o.commentPinAnnotation?.status.type==="terminal"?o.hideAreaAnnotation=!0:o.hideAreaAnnotation=!1):o.hideAreaAnnotation=!0,o))}))):t?(this.componentConfigSignal.update(n=>(n=E(g({},n),{hideAreaAnnotation:!0}),n)),this.subscriptions.push(this.serviceBook.observe(te).pipe(S(n=>n?n.getMultiThreadCommentAnnotationByAnnotationId(t):de),S(n=>(this.commentService?.getResolvedCommentsOnDom$()??C(!0)).pipe(v(o=>(this.resolvedCommentsOnDom=o,n))))).subscribe(n=>{this.componentConfigSignal.update(o=>(o=E(g({},o),{multiThreadCommentAnnotation:n}),o.hideAreaAnnotation=!1,o))}))):this.componentConfigSignal.update(n=>(n=E(g({},n),{areaAnnotationColor:this.componentConfigSignal().areaPinAnnotation?.from?.color||"#625DF5"}),n)),this.componentConfigSignal().areaPinAnnotation?.targetElements?.length&&this.componentConfigSignal().areaPinAnnotation?.targetElements?.forEach(n=>{if(n?.xpath){let o=this.domService.getElementFromXPath(n?.xpath);!o&&n?.cfXpath&&(o=this.domService.getElementFromXPath(n?.cfXpath)),!o&&n?.fXpath&&(o=this.domService.getElementFromXPath(n?.fXpath)),o&&this.detectPositionChange(o)}})}catch(e){this.catchError("Error in AreaPinPortalComponent ngAfterViewInit: ",e)}}setAreaPinAnnotation(e){try{this.componentConfigSignal.update(t=>(!this.skipValueUpdate&&!t.isResizing&&(t=E(g({},t),{areaPinAnnotation:e}),this.id=e.annotationId,t.isResizing||(t.areaProperties=e.areaProperties)),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setAreaPinAnnotation: ",t)}}setOffsetLeft(e){try{this.componentConfigSignal.update(t=>(t=E(g({},t),{offsetLeft:e}),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setOffsetLeft: ",t)}}setOffsetTop(e){try{this.componentConfigSignal.update(t=>(t=E(g({},t),{offsetTop:e}),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setOffsetTop: ",t)}}togglePinSelection(){try{let e=!0;this.componentConfigSignal().commentPinAnnotation&&(e=!(this.domService.getDraftCommentAnnotationDialogs()||[])?.length,this.domService.resetSelectedAnnotationsMap(!0,"comments")),e&&(this.domService.toggleAnnotationSelection(this.componentConfigSignal().areaPinAnnotation),this.componentConfigSignal().commentPinAnnotation?this.domService.toggleAnnotationSelection(this.componentConfigSignal().commentPinAnnotation):this.componentConfigSignal().multiThreadCommentAnnotation&&this.domService.toggleAnnotationSelection(this.componentConfigSignal().multiThreadCommentAnnotation))}catch(e){this.catchError("Error in AreaPinPortalComponent togglePinSelection: ",e)}}saveComment(e){try{this.componentConfigSignal().commentPinAnnotation?this.commentService?.saveComment(this.componentConfigSignal().commentPinAnnotation,e):this.componentConfigSignal().multiThreadCommentAnnotation&&this.commentService?.saveComment(this.componentConfigSignal().multiThreadCommentAnnotation,e)}catch(t){this.catchError("Error in AreaPinPortalComponent saveComment: ",t)}}veltEmit(e){return typeof CustomEvent<"u"&&e instanceof CustomEvent?e.detail:e}calculateResizingOffset(e){try{if(!e)return{top:0,left:0};let t=e.getBoundingClientRect(),n=t.left+window.scrollX;return{top:t.top+window.scrollY,left:n}}catch(t){return this.catchError("Error in AreaPinPortalComponent calculateResizingOffset: ",t),{top:0,left:0}}}onResizeHandleDragStart(e){try{document.body.classList.add(h.BODY_CLASSES.VELT_PIN_DRAGGING);let t=document.getElementById(this.componentConfigSignal().areaPinAnnotation.annotationId);t&&(this.parentElement=t.parentElement,document.body.appendChild(t)),this.componentConfigSignal.update(a=>(a=E(g({},a),{isResizing:!0}),a));let n=this.domService.getElementFromXPath(this.componentConfigSignal().areaProperties?.targetElement),o=this.calculateResizingOffset(n),s=JSON.parse(JSON.stringify(this.componentConfigSignal().areaPinAnnotation)),r=this.areaService.calculateAreaAnnotationPosition(s,!0);this.componentConfigSignal.update(a=>(a=g(E(g({},a),{resizingOffset:o}),r?{areaProperties:r}:{}),a))}catch(t){this.catchError("Error in AreaPinPortalComponent onResizeHandleDragStart: ",t)}}onResizeHandleDragMove(e,t){try{let n=this.domService.getTargetElementForCursorPosition(e.event);if(this.componentConfigSignal().commentPinAnnotation){let o=this.domService.getElementFromXPath(n?.xpath);if(o&&!this.commentService?.isElementInsideAllowedElements(o))return}if(n){let o=JSON.parse(JSON.stringify(this.componentConfigSignal().areaPinAnnotation)),s=o.targetElements||[];switch(t){case"topLeft":s[0]=n;break;case"bottomRight":s[1]=n;break;default:break}o.targetElements=s;let r=this.areaService.calculateAreaAnnotationPosition(o,!0),a=this.componentConfigSignal().areaProperties?.targetElement,c=r?.targetElement,u=a!==c,P,f;if(u&&r?.targetElement){let p=this.domService.getElementFromXPath(r.targetElement),A=this.calculateResizingOffset(p);P=A.top,f=A.left}else{let p=this.componentConfigSignal().resizingOffset;P=p.top,f=p.left}this.componentConfigSignal.update(p=>(p=E(g({},p),{areaProperties:r,resizingOffset:{top:P,left:f},areaPinAnnotationOnResize:o}),p))}}catch(n){this.catchError("Error in AreaPinComponent onResizeHandleDragMove: ",n)}}onResizeHandleDragEnd(e){try{document.body.classList.remove(h.BODY_CLASSES.VELT_PIN_DRAGGING);let t=document.getElementById(this.componentConfigSignal().areaPinAnnotation.annotationId);t&&this.parentElement&&(this.parentElement.appendChild(t),t.style.opacity="0");let n=this.componentConfigSignal().areaPinAnnotationOnResize||this.componentConfigSignal().areaPinAnnotation;if(n){let r=this.areaService.calculateAreaAnnotationPosition(n,!1);r&&this.componentConfigSignal.update(a=>(a=E(g({},a),{areaProperties:r}),a))}this.componentConfigSignal.update(r=>(r=E(g({},r),{isResizing:!1}),r)),this.skipValueUpdate=!0;let o=this.domService.getElementFromXPath(this.componentConfigSignal().areaProperties?.targetElement),s=this.docService.getAdditionalDocumentIdFromElement(o)||this.docService.getDocumentPaths()?.clientDocumentId;!this.componentConfigSignal().areaPinAnnotation?.metadata?.clientDocumentId||this.componentConfigSignal().areaPinAnnotation?.metadata?.clientDocumentId==s?(this.componentConfigSignal.update(r=>(r=g({},r),r.areaPinAnnotationOnResize&&(r.areaPinAnnotation=JSON.parse(JSON.stringify(r.areaPinAnnotationOnResize))),delete r.areaPinAnnotationOnResize,r)),this.areaService.updateArea(this.componentConfigSignal().areaPinAnnotation,!1),this.analyticsService.trackEvent(N.Events.Area.AREA_DRAGGED,{annotationId:this.componentConfigSignal().areaPinAnnotation.annotationId})):this.componentConfigSignal.update(r=>(r=g({},r),r.areaProperties=r.areaPinAnnotation.areaProperties,r)),setTimeout(()=>{this.skipValueUpdate=!1,t&&(t.style.opacity="1")},50)}catch(t){this.catchError("Error in AreaPinComponent onResizeHandleDragEnd: ",t)}}detectPositionChange(e){try{let t=We(0,je).pipe(v(()=>{let n=e.getBoundingClientRect();return{top:n.top,left:n.left}}),ae((n,o)=>n.top===o.top&&n.left===o.left),Xe());this.subscriptions.push(t.subscribe(()=>{this.componentConfigSignal.update(n=>(n=E(g({},n),{areaProperties:this.areaService.calculateAreaAnnotationPosition(n.areaPinAnnotation)}),n))},n=>{}))}catch(t){this.catchError("Error in AreaPinPortalComponent detectPositionChange: ",t)}}setAreaPinHover(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setAreaPinHover","color: green;"),e&&this.targetElement&&!this.domService.isElementVisibleOnScreen(this.targetElement)&&(e=!1),this.areaPinHover=e,this.updateAreaActiveAttributeOnElement()}catch(t){this.catchError("Error in AreaPinPortalComponent setAreaPinHover: ",t)}}updateAreaActiveAttributeOnElement(){try{this.loggingService.log("%c[WB] Calling FUNCTION: updateAreaActiveAttributeOnElement","color: green;"),this.selected||this.areaPinHover?this.targetElement&&(this.targetElement?.hasAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE)||this.targetElement?.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE,"true")):this.targetElement&&this.targetElement?.hasAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE)&&this.targetElement?.removeAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE)}catch(e){this.catchError("Error in AreaPinPortalComponent updateAreaActiveAttributeOnElement: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe(),this.componentConfigSignal()?.isResizing&&document.body.classList.remove(h.BODY_CLASSES.VELT_PIN_DRAGGING)}catch(e){this.catchError("Error in AreaPinPortalComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.catchError("Error in AreaPinPortalComponent unsubscribe: ",e)}}catchError(e,t,n){try{this.loggingService.catch(e,t,E(g({},n||{}),{annotationId:this.componentConfigSignal()?.areaPinAnnotation?.annotationId}))}catch{}}};l.\u0275fac=function(t){return new(t||l)(I(G),I(K),I(W),I(Se),I(X),I(H),I(D))},l.\u0275cmp=ne({type:l,selectors:[["snippyly-area-pin-portal"]],hostVars:6,hostBindings:function(t,n){t&1&&w("mouseenter",function(){return n.onMouseEnter()})("mouseleave",function(){return n.onMouseLeave()}),t&2&&(ot("id",n.id),ie("data-velt-element",n.veltElement),ee("selected",n.selected)("resizing",n.resizing))},inputs:{multipleAreaPinsSelected:"multipleAreaPinsSelected",avatarErrorImage:"avatarErrorImage",user:"user",targetElement:"targetElement"},standalone:!1,decls:1,vars:1,consts:[[4,"ngIf"],["id","line1",1,"line","vertical",3,"click"],["id","line2",1,"line","horizontal",3,"click"],["id","line3",1,"line","vertical",3,"click"],["id","line4",1,"line","horizontal",3,"click"],["id","handle1","cdkDrag","",1,"handle",3,"cdkDragStarted","cdkDragMoved","cdkDragEnded","click","cdkDragDisabled"],["id","handle2","cdkDrag","",1,"handle",3,"cdkDragStarted","cdkDragMoved","cdkDragEnded","click","cdkDragDisabled"],[3,"id","click",4,"ngIf"],[3,"click","id"],[3,"saveComment","ngStyle","annotationDragging","annotation","commentPinSelected","multipleCommentPinSelected","user"]],template:function(t,n){t&1&&j(0,cn,2,1,"ng-container",0),t&2&&L("ngIf",n.componentConfigSignal())},dependencies:[ue,ht,ut],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;z-index:var(--velt-comment-pin-z-index)!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));-webkit-text-fill-color:initial!important}*[_ngcontent-%COMP%]:empty{display:revert!important}.line[_ngcontent-%COMP%]{position:absolute;opacity:.4;transition:opacity .2s ease-in-out}.line.vertical[_ngcontent-%COMP%]{border-left:1px dashed;border-right:1px dashed}.line.horizontal[_ngcontent-%COMP%]{border-top:1px dashed;border-bottom:1px dashed}.handle[_ngcontent-%COMP%]{position:absolute;transform:none!important;border-radius:100%}.handle[_ngcontent-%COMP%]:not(.drag-disabled){cursor:grab}#handle1[_ngcontent-%COMP%]{opacity:.4;transition:opacity,transform .2s ease-in-out}#handle2[_ngcontent-%COMP%]{background-color:transparent!important}.resizing[_nghost-%COMP%] div[_ngcontent-%COMP%]{z-index:1}.resizing[_nghost-%COMP%] .handle[_ngcontent-%COMP%]{cursor:grabbing}[_nghost-%COMP%]:hover #handle1[_ngcontent-%COMP%], .resizing[_nghost-%COMP%] #handle1[_ngcontent-%COMP%], .selected[_nghost-%COMP%] #handle1[_ngcontent-%COMP%]{opacity:1;transform:scale(2)!important}[_nghost-%COMP%]:hover .line[_ngcontent-%COMP%], .resizing[_nghost-%COMP%] .line[_ngcontent-%COMP%], .selected[_nghost-%COMP%] .line[_ngcontent-%COMP%]{opacity:1}snippyly-comment-pin[_ngcontent-%COMP%], velt-comment-pin-embed[_ngcontent-%COMP%], snippyly-comment-pin-embed[_ngcontent-%COMP%]{position:absolute;bottom:calc(100% - 8px)}.s-metadata[_ngcontent-%COMP%]{position:fixed;bottom:10px;right:10px;background:#fff;font-size:14px;border:1px solid;padding:10px;box-shadow:1px 1px 1px 1px;border-radius:4px}.s-metadata[_ngcontent-%COMP%] table[_ngcontent-%COMP%]{border-collapse:collapse}.s-metadata[_ngcontent-%COMP%] table[_ngcontent-%COMP%] td[_ngcontent-%COMP%], .s-metadata[_ngcontent-%COMP%] table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{border:1px solid;padding:4px 8px}"],changeDetection:0});let d=l;return d})();var Qt=(()=>{let l=class l{constructor(e,t,n,o,s){this.domService=e,this.componentFactoryResolver=t,this.injector=n,this.appRef=o,this.loggingService=s,this.areasPinById={}}setAreaPin(e){try{if(!this.areasPinById[e.annotationId])this.setPinPortal(e);else{let t=this.areasPinById[e.annotationId].portalRef?.instance?.componentConfigSignal().isResizing;if(e.areaProperties?.targetElement===this.areasPinById[e.annotationId]?.annotation?.areaProperties?.targetElement||t){let n=this.areasPinById[e.annotationId].portalRef,o=this.areasPinById[e.annotationId].userTargetElement,s=this.areasPinById[e.annotationId].pinHostElement;if(document.body.contains(o)&&document.body.contains(s))n&&(n.instance.setAreaPinAnnotation(JSON.parse(JSON.stringify(e))),this.updateElementOffset(e));else{let r=this.areasPinById[e.annotationId].pinHostDomPortalOutlet;r&&(this.removeAreaPinHostAttributes(e.annotationId,this.areasPinById[e.annotationId].pinHostElement),r.detach(),delete this.areasPinById[e.annotationId],this.setPinPortal(e))}}else{let n=this.areasPinById[e.annotationId].pinHostDomPortalOutlet;n&&(this.removeAreaPinHostAttributes(e.annotationId,this.areasPinById[e.annotationId].pinHostElement),n.detach(),delete this.areasPinById[e.annotationId],this.setPinPortal(e))}}}catch(t){this.loggingService.catch("Error in AreaPinPortalService setAreaPin: ",t)}}setPinPortal(e){try{if(e?.areaProperties?.targetElement){let t=this.domService.getElementFromXPath(e?.areaProperties?.targetElement);if(t){let n=this.domService.getHostElement(t),o=new At(Ve),s=new vt(n,this.appRef,this.injector),r=s.attach(o);r.instance.setAreaPinAnnotation(JSON.parse(JSON.stringify(e))),r.instance.targetElement=t,this.areasPinById[e.annotationId]={pinHostDomPortalOutlet:s,pinPortal:o,portalRef:r,annotation:JSON.parse(JSON.stringify(e)),userTargetElement:t,pinHostElement:n},this.setAreaPinHostAttributes(e.annotationId,n),this.updateElementOffset(e)}}}catch(t){this.loggingService.catch("Error in AreaPinPortalService setPinPortal: ",t)}}setAreaPinHostAttributes(e,t){try{let n=t.getAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST);if(n){let o=n.split(",");o.includes(e)||(o.push(e),t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST,o.join(",")))}else t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST,e);this.domService.isElementOriginallyStatic(t)&&(Mt(t)||t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST_STATIC,"true"))}catch(n){this.loggingService.catch("Error in AreaPinPortalService setAreaPinHostAttributes: ",n)}}removeAreaPinHostAttributes(e,t){try{let n=t.getAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST);if(n){let o=n.split(","),s=o.indexOf(e);s>-1&&(o.splice(s,1),o.length>0?t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST,o.join(",")):t.removeAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST))}t?.getAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST)||t.removeAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST_STATIC)}catch(n){this.loggingService.catch("Error in AreaPinPortalService removeAreaPinHostAttributes: ",n)}}updateElementOffset(e){try{let{portalRef:t,userTargetElement:n,pinHostElement:o}=this.areasPinById[e.annotationId],s=this.domService.getElementOffset(n,o);t.instance.setOffsetLeft(s.offsetLeft),t.instance.setOffsetTop(s.offsetTop)}catch(t){this.loggingService.catch("Error in AreaPinPortalService updateElementOffset: ",t)}}checkPinsToRemove(e){try{let t=e.map(n=>n.annotationId);Object.keys(this.areasPinById).forEach(n=>{if(!t.includes(n)){let o=this.areasPinById[n];o.pinHostDomPortalOutlet.detach(),this.removeAreaPinHostAttributes(n,o.pinHostElement),this.domService.removeHighlightFromElement(o.pinHostElement),delete this.areasPinById[n]}})}catch(t){this.loggingService.catch("Error in AreaPinPortalService checkPinsToRemove: ",t)}}};l.\u0275fac=function(t){return new(t||l)(b(X),b(Qe),b(Ye),b(tt),b(D))},l.\u0275prov=pe({token:l,factory:l.\u0275fac,providedIn:"root"});let d=l;return d})();var Ce=(()=>{let l=class l{constructor(e,t,n,o,s,r,a){this.analyticsService=e,this.authService=t,this.domService=n,this.areaService=o,this.areaPinPortalService=s,this.serviceBook=r,this.loggingService=a,this.areaPinAnnotations=[],this.subscriptions=[],this.isFirstComponent=!0,this.commentsOnDom=!0,this.commentService=null,this.veltId=Rt(),this.veltElement=!0;try{this.loggingService.log("%c[WB] Creating CLASS: AreasContainerComponent","color: blue;"),this.serviceBook.observe(te).subscribe(c=>{this.commentService=c})}catch(c){this.loggingService.catch("Error in AreasContainerComponent constructor: ",c)}}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{let e=document.querySelector(h.TAGS.SNIPPYLY_AREAS),t=document.querySelector(h.TAGS.VELT_AREAS);t?this.veltId===t?.getAttribute(h.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent()):this.veltId===e?.getAttribute(h.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent())}catch(e){this.loggingService.catch("Error in AreasContainerComponent AfterViewInit: ",e)}}initComponent(){try{this.subscriptions.push(this.authService.getUser$().pipe(q(e=>!!e)).subscribe(e=>{e&&this.setAreaInstalledInAnalytics()},e=>{this.loggingService.catch("Error in getUser: ",e)})),this.getAllAreasOnCurrentDocument()}catch(e){this.loggingService.catch("Error in AreasContainerComponent initComponent: ",e)}}getAllAreasOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllAreasOnCurrentDocument","color: green;");try{this.subscriptions.push(this.areaService.getAllAreaAnnotations().pipe(q(e=>!!e),S(e=>this.domService.getSelectedAnnotationsMap$().pipe(v(t=>({annotations:e,selectedAnnotationsMap:t||{}})))),S(e=>(this.commentService?.getCommentsOnDom$()??C(!0)).pipe(v(t=>(this.commentsOnDom=t,{annotations:e.annotations,selectedAnnotationsMap:e.selectedAnnotationsMap,commentsOnDom:t||{}}))))).subscribe(e=>{try{this.loggingService.log(e),this.areaPinAnnotations=e?.annotations,this.commentsOnDom||(this.areaPinAnnotations=this.areaPinAnnotations?.filter(n=>!n?.targetAnnotations?.filter(o=>o?.type===M.COMMENT)?.length));let t=this.areaPinAnnotations.filter(n=>n?.areaProperties?.targetElement);this.areaPinPortalService.checkPinsToRemove(t),t.forEach(n=>{this.areaPinPortalService.setAreaPin(n)})}catch(t){this.loggingService.catch("Error in AreasContainerComponent getAllAreasOnCurrentDocument inside subscription: ",t)}},e=>{this.loggingService.catch("Error in AreasContainerComponent getAllAreasOnCurrentDocument subscription: ",e)}))}catch(e){this.loggingService.catch("Error in AreasContainerComponent getAllAreasOnCurrentDocument: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.loggingService.catch("Error in AreasContainerComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in AreasContainerComponent unsubscribe: ",e)}}setAreaInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(It.AREA_COMMENT)}catch(e){this.loggingService.catch("Error in AreasContainerComponent setAreaInstalledInAnalytics: ",e)}}};l.\u0275fac=function(t){return new(t||l)(I(G),I(K),I(X),I(H),I(Qt),I(W),I(D))},l.\u0275cmp=ne({type:l,selectors:[["snippyly-area-container"]],hostVars:2,hostBindings:function(t,n){t&2&&ie("data-velt-id",n.veltId)("data-velt-element",n.veltElement)},standalone:!1,decls:0,vars:0,template:function(t,n){},encapsulation:2,changeDetection:0});let d=l;return d})();var dn=["customBtnRef"],mn=["*"];function hn(d,l){if(d&1&&(R(0,"div",6),Je(),R(1,"svg",7),nt(2,"path",8),B()()),d&2){let i=_();x(),ee("active",i.addAreaMode)}}function gn(d,l){d&1&&it(0)}function pn(d,l){d&1&&at(0)}var _e=(()=>{let l=class l{constructor(e,t,n,o,s){this.analyticsService=e,this.authService=t,this.areaService=n,this.iamService=o,this.loggingService=s,this.showDefaultBtn=!1,this.addAreaMode=!1,this.subscriptions=[],this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(r=>{this.user=r},r=>{this.loggingService.catch("Error in AreasToolComponent getUser$ subscription: ",r)}))}ngOnInit(){}ngAfterViewInit(){try{this.customBtnRef?.nativeElement?.children?.length||(this.showDefaultBtn=!0),this.subscriptions.push(this.areaService.addAreaModeChange().subscribe(e=>{this.addAreaMode=e}))}catch(e){this.loggingService.catch("Error in AreasToolComponent AfterViewInit: ",e)}}addArea(){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{this.analyticsService.trackEvent(N.Events.Area.AREA_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 areas."):!this.authService.isPlanExpired()&&this.iamService.getRole()?this.areaService.enableAddAreaMode():this.loggingService.catch("User does not have permission to add areas."))}catch(e){this.loggingService.catch("Error in AreasToolComponent addArea: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.loggingService.catch("Error in AreasToolComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in AreasToolComponent unsubscribe: ",e)}}};l.\u0275fac=function(t){return new(t||l)(I(G),I(K),I(H),I(Pe),I(D))},l.\u0275cmp=ne({type:l,selectors:[["snippyly-area-tool"]],viewQuery:function(t,n){if(t&1&&st(dn,5),t&2){let o;ct(o=lt())&&(n.customBtnRef=o.first)}},hostVars:1,hostBindings:function(t,n){t&2&&ie("data-velt-element",n.veltElement)},standalone:!1,ngContentSelectors:mn,decls:7,vars:4,consts:[["customBtnRef",""],["content",""],[1,"snippyly-area-btn-container",3,"click"],["class","action-btn",4,"ngIf"],[1,"custom-btn-container"],[4,"ngTemplateOutlet"],[1,"action-btn"],["width","32","height","32","viewBox","0 0 32 32","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon"],["fill-rule","evenodd","clip-rule","evenodd","d","M22.6315 18.0207C23.3673 17.9913 23.9399 17.371 23.9105 16.6352L23.6567 10.2894C23.6289 9.59486 23.0723 9.03819 22.3778 9.01041L16.0319 8.75654C15.2961 8.7271 14.6758 9.29972 14.6463 10.0355C14.6169 10.7713 15.1895 11.3916 15.9253 11.4211L19.2283 11.5532L10.0679 20.7136C9.54724 21.2343 9.54724 22.0785 10.0679 22.5992C10.5886 23.1199 11.4329 23.1199 11.9536 22.5992L21.1139 13.4389L21.246 16.7418C21.2754 17.4775 21.8957 18.0502 22.6315 18.0207Z","fill","#8F95B2"]],template:function(t,n){if(t&1){let o=oe();rt(),R(0,"div",2),w("click",function(r){return y(o),n.addArea(),T(r.stopPropagation())}),j(1,hn,3,2,"div",3),R(2,"div",4,0),j(4,gn,1,0,"ng-container",5),B()(),j(5,pn,1,0,"ng-template",null,1,mt)}if(t&2){let o=dt(6);ee("active",n.addAreaMode),x(),L("ngIf",n.showDefaultBtn),x(3),L("ngTemplateOutlet",o)}},dependencies:[ue,gt],encapsulation:2,changeDetection:0});let d=l;return d})();var Ie=class extends Gt{constructor(l){super(l),this.getService(D).log("%c[WB] Creating CLASS: AreaElement","color: blue;"),this.enableArea=this._enableAreaComment,this.disableArea=this._disableAreaComment,this.enableAreaComment=this._enableAreaComment,this.disableAreaComment=this._disableAreaComment}_enableAreaComment(){this.getService(D).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(N.Events.Area.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(H).enableArea()}catch(l){this.getService(D).catch("Error in _enableAreaComment: ",l)}}_disableAreaComment(){this.getService(D).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(N.Events.Area.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(H).disableArea()}catch(l){this.getService(D).catch("Error in _disableAreaComment: ",l)}}};var qt=(()=>{let l=class l{};l.\u0275fac=function(t){return new(t||l)},l.\u0275mod=et({type:l}),l.\u0275inj=Ke({imports:[pt,Pt,St,ft,Wt]});let d=l;return d})();function un(d){d.get(D).log("%c[WB] Loading area feature chunk","color: blue;"),d.get(W).set(kt,d.get(H));let t=qe(qt,d).injector;return be(t,h.TAGS.VELT_AREA_TOOL,_e),be(t,h.TAGS.SNIPPYLY_AREA_TOOL,_e),be(t,h.TAGS.VELT_AREAS,Ce),be(t,h.TAGS.SNIPPYLY_AREAS,Ce),new Ie(d)}function be(d,l,i){if(customElements.get(l))return;let e=Et(i,d);customElements.define(l,e)}export{un as default};
|
package/velt-arrow.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as zt,c as Gt,d as Xt}from"./chunk-FHFEI7VF.js";import{b as ue}from"./chunk-Z7CCKSEO.js";import{a as ut}from"./chunk-G6V3RCTP.js";import{a as Kt}from"./chunk-QQIKH4VS.js";import{Ga as pt,Ha as me,Ja as pe,r as Yt,t as Jt,za as qt}from"./chunk-DKI2JSNJ.js";import{a as we}from"./chunk-PBA6NIAI.js";import{D as de,E as he,p as ge}from"./chunk-72TEWHMQ.js";import{Ab as Pt,Bb as b,E as I,Fb as X,G as Ot,Gb as Y,Gd as Qt,Ha as O,Hb as J,He as d,Hi as _,Ia as at,Ic as ct,Ij as le,Jg as dt,Ji as ae,K as F,Ki as se,Lb as K,M as St,Mb as N,Mc as $t,Ne as gt,Oa as Wt,Ph as ht,Ra as p,Rc as lt,Sh as ie,Tg as yt,Th as ne,Ue as Zt,V as f,Wa as k,Zf as Ct,_a as kt,a as w,ab as $,ac as Ut,ah as bt,b as y,ba as j,ci as oe,db as Bt,dc as jt,ea as v,fb as B,g as At,ja as E,ka as C,l as tt,la as et,na as Rt,nb as R,nj as mt,ob as W,oe as Et,oj as x,pb as z,pj as A,qb as st,qj as ce,r as P,rb as rt,re as H,rk as D,sa as Mt,sb as Nt,sk as V,tb as Ht,ub as xt,ug as te,v as S,vb as Vt,vg as ee,wa as Lt,xb as G,ya as ot,yb as Ft,yg as re,zb as U}from"./chunk-J3DYWDYQ.js";var M=(()=>{let s=class s{constructor(t,e,r,i,n,o,a,m,h,u,T,L){this.analyticsService=t,this.configService=e,this.docService=r,this.databaseService=i,this.authService=n,this.domService=o,this.afAuth=a,this.iamService=m,this.dialog=h,this.loggingService=u,this.serviceBook=T,this.commonDbService=L,this.arrowAnnotations$=new tt({}),this.arrowAnnotationsByDocumentId$=new tt({}),this.documentPaths=null,this.allowedElementIds$=new tt([]),this.addArrowMode$=new tt(!1),this.loggingService.log("%c[WB] Creating CLASS: ArrowService","color: blue;"),this.databaseService.getDb().pipe(I(g=>!!g),F(1)).subscribe(g=>{g&&this.getDocumentPaths()},g=>{this.loggingService.catch("Error in ArrowService getDb subscription: ",g)}),this.domService.onWindowPointerMove$().subscribe(g=>{if(this.addArrowMode$.value){let Z=!0,nt=this.domService.getBackgroundElement(g.clientX,g.clientY);nt&&(this.isElementInsideAllowedElements(nt)?bt(g.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement&&this.highlightElement!==nt&&this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=nt,this.domService.highlightElement(this.highlightElement,d.CURSOR.ARROW_PIN),Z=!1):this.domService.removeClassFromElement(document.body,"show-pin-cursor")),this.highlightElement&&Z&&(this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=null)}},g=>{this.loggingService.catch("Error in ArrowService onWindowPointerMove$ subscription: ",g)}),this.domService.onWindowKeyupEsc$().subscribe(g=>{this.addArrowMode$.value&&this.disableAddArrowMode()},g=>{this.loggingService.catch("Error in ArrowService onWindowKeyupEsc$ subscription: ",g)}),this.domService.onDocumentClick$().subscribe(g=>{if(g&&this.addArrowMode$.value){if(!bt(g.target)){let Z=this.domService.getBackgroundElement(g.clientX,g.clientY);Z&&this.isElementInsideAllowedElements(Z)&&(g.preventDefault(),g.stopPropagation(),this.addArrow(g))}this.disableAddArrowMode()}},g=>{this.loggingService.catch("Error in ArrowService onDocumentClick$ subscription: ",g)}),this.addArrowMode$.subscribe(g=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),g?this.domService.addClassToElement(document.body,"snippyly-add-arrow-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-arrow-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},g=>{this.loggingService.catch("Error in ArrowService addArrowMode$ subscription: ",g)}),this.domService.onWindowKeyupBackspace$().subscribe(g=>{this.deleteArrowPinAnnotations("keyupBackspace")},g=>{this.loggingService.catch("Error in ArrowService onWindowKeyupBackspace$ subscription: ",g)}),this.domService.onWindowKeyupDelete$().subscribe(g=>{this.deleteArrowPinAnnotations("keyupDelete")},g=>{this.loggingService.catch("Error in ArrowService onWindowKeyupDelete$ subscription: ",g)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}setAllowedElementIds(t){this.allowedElementIds$.next(t||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getAllArrowAnnotations(t,e,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowAnnotations","color: green;");let i,n;try{if(t&&(n=Ct(t)),e&&typeof e=="object"){let o=re(e);i=Ct(JSON.stringify(o))}}catch(o){this.loggingService.catch("Error in ArrowService getAllArrowAnnotations: ",o)}return this.authService.getAuthState$().pipe(I(o=>!!o),f(o=>this.isFeatureAllowed({firebaseUser:o,annotations:[],filteredAnnotations:[]})),f(o=>o.featureAllowed?this.iamService.isUserAllowed$().pipe(S(a=>(o.featureAllowed=a,o))):P(o)),f(o=>o.featureAllowed?this.authService.isPlanExpired$().pipe(S(a=>(o.featureAllowed=!a,o))):P(o)),f(o=>o.featureAllowed?P(o).pipe(f(a=>this.docService.getDocumentPaths$().pipe(S(m=>(this.documentPaths=m,a.documentPaths=m,a)))),f(a=>this.getDataFromDocumentId(n).pipe(S(m=>(a.annotations=m||[],w({},a))))),f(a=>this.docService.getLocation$().pipe(S(m=>(a.location=m,a)))),f(a=>this.docService.getLocations$().pipe(S(m=>(a.customLocations=m,a)))),S(a=>{if(a.filteredAnnotations=[],n&&!i)return a.filteredAnnotations=a.annotations?.slice(),a;{let m=[];return i?m.push(i):(m.push(a?.location?.locationId),m.push(...Object.values(a?.customLocations||[]).map(h=>h.locationId))),a.filteredAnnotations=this.filterAnnotationsByLocationIds(a?.annotations,m),a}}),f(a=>r?P(a):a?.annotations?.length?this.domService.onWindowResize$().pipe(S(()=>a)):P(a)),f(a=>r?P(a):a?.annotations?.length?this.domService.onDomChange$("ArrowService getAllArrowAnnotations").pipe(S(()=>a)):P(a)),S(a=>(a?.filteredAnnotations?.forEach(m=>{this.calculateArrowAnnotationPosition(m)}),a)),f(a=>a?.filteredAnnotations?P(a?.filteredAnnotations||[]):P([]))):P([])),St(oe))}isFeatureAllowed(t){return this.configService.getConfig$().pipe(I(e=>!!e),S(e=>y(w({},t),{config:e})),f(e=>this.authService.getUser$().pipe(S(r=>y(w({},e),{user:r})))),f(e=>te(e.config,e.user,H.ARROW)?P(y(w({},e),{featureAllowed:!0})):(this.loggingService.warn("Arrow feature is not allowed."),P(y(w({},e),{featureAllowed:!1})))),St((e,r)=>e?.featureAllowed===r?.featureAllowed))}getDataFromDocumentId(t){return this.databaseService.getDb().pipe(I(e=>!!e),f(e=>this.configService.getApiKey()&&this.documentPaths?.arrow&&this.documentPaths?this.commonDbService.dbListener({feature:"allArrows",properties:{documentId:t??this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(S(r=>({data:r?.data,operation:r?.operation})),S(({data:r,operation:i})=>{let n=[];return r&&(n=Object.values(r).filter(o=>typeof o=="object")),{data:n,operation:i}}),Ot(r=>(this.loggingService.catch("Error in ArrowService getDataFromDocumentId: ",r),P({data:[],operation:null}))),S(({data:r,operation:i})=>{if(i?.type==="removed"){if(i?.ids?.length){let n=this.arrowAnnotationsByDocumentId$.value;i?.ids?.forEach(o=>{delete n?.[o]}),this.arrowAnnotationsByDocumentId$.next(n)}}else this.setArrowAnnotationsByDocumentId(t||this.documentPaths?.documentId,r);return r})):P([])))}setArrowAnnotationsByDocumentId(t,e){try{if(t){let r=y(w({},this.arrowAnnotationsByDocumentId$.value),{[t]:e});this.arrowAnnotationsByDocumentId$.next(r)}}catch(r){this.loggingService.catch("Error in ArrowService setArrowAnnotationsByDocumentId:",r)}}filterAnnotationsByLocationIds(t,e){try{return t.filter(r=>e.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in ArrowService filterAnnotationsByLocations:",r),[]}}calculateArrowAnnotationPosition(t){try{if(t.targetElement){let e=this.domService.getXPath(t.targetElement?.xpath);if(e){let r=e.iterateNext();if(r&&dt(r)){let i=r.getBoundingClientRect();if(i&&i.width&&i.height){let{height:n,width:o}=ie(r);t.position={top:n*t.targetElement.topPercentage/100,left:o*t.targetElement.leftPercentage/100}}else t.position=null}else t.position=null}else t.position=null}}catch(e){this.loggingService.catch("Error in ArrowService calculateArrowAnnotationPosition:",e)}}addArrow(t){this.loggingService.log("%c[WB] Calling FUNCTION: addArrow","color: green;");try{let e=this.authService.getUser();if(e)if(e.isReadOnly||e.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add arrows.");else{let r=new Zt;r.from=e,r.color=e?.color||d.DEFAULT_ANNOTATION_COLOR,r.lastUpdated=this.timestamp,r.props=new gt;let i=this.domService.getCurrentWindowSizeValue();if(r.props.screenWidth=i.screenWidth,r.props.screenHeight=i.screenHeight,r.props.screenScrollHeight=i.screenScrollHeight,r.props.viewportWidth=window.innerWidth,r.props.viewportHeight=window.innerHeight,r.props.arrowLength=d.VELT_MIN_ARROW_LENGTH,(t?.clientX||0)>d.VELT_MIN_ARROW_LENGTH?r.props.arrowAngle=135:r.props.arrowAngle=45,t&&(r.targetElement=this.domService.getTargetElementForCursorPosition(t)),r?.targetElement?.xpath){let n=this.domService.getXPath(r.targetElement.xpath);if(n){let o=n.iterateNext();o&&(dt(o)||(r.targetElement=null))}}this.setLocationToArrowAnnotation(r),r.pageInfo=yt(),r.pageInfo&&(r.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveArrowToDb(r)}}catch(e){this.loggingService.catch("Error in ArrowService addArrow: ",e)}}setLocationToArrowAnnotation(t){try{let e=this.docService.getLocation();e?(t.locationId=e.locationId,t.location=e.location):(delete t.locationId,delete t.location);try{if(t.targetElement?.xpath){let r=this.domService.getElementFromXPath(t.targetElement.xpath),i=this.docService.getAdditionLocationFromElement(r);if(i){let n=this.docService.addLocation({location:i,source:"internal"});n?.[0]&&(t.locationId=n[0].locationId,t.location=n[0].location)}}}catch{}}catch(e){this.loggingService.catch("Error in ArrowService setLocationToArrowAnnotation:",e)}}saveArrowToDb(t){this.loggingService.log("%c[WB] Calling FUNCTION: saveArrowToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(H.ARROW)&&this.docService.getDocumentPaths$().pipe(I(e=>!!e),F(1),f(e=>(this.documentPaths=e,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(I(r=>!!r),F(1),f(r=>{if(this.documentPaths?.arrow){t.annotationId=this.commonDbService.generateDocumentId(),t.pageInfo&&(t.pageInfo.arrowUrl=this.generateArrowUrl(t));let i=JSON.parse(JSON.stringify(t));return i.position=null,this.domService.toggleAnnotationSelection(i),this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DRAFT_ADDED,{annotationId:t.annotationId}),this.commonDbService.setData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0},data:JSON.parse(JSON.stringify(i))})}else return P(null)}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in ArrowService saveArrowToDb subscription: ",e)})}catch(e){this.loggingService.catch("Error in ArrowService saveArrowToDb: ",e)}}updateArrow(t,e=!1,r){try{r&&this.setLocationToArrowAnnotation(t),e&&this.updateNotificationsDatabase(t,Et.UPDATED),this.updateArrowToDb(t)}catch(i){this.loggingService.catch("Error in ArrowService updateArrow: ",i)}}updateArrowToDb(t){this.loggingService.log("%c[WB] Calling FUNCTION: updateArrowToDb","color: green;");try{if(t?.targetElement?.xpath){let e=this.domService.getXPath(t.targetElement.xpath);if(e){let r=e.iterateNext();r&&(dt(r)||(t.targetElement=null))}}this.domService.updateSelectedAnnotationInMap([t]),this.authService.getUser()&&this.authService.isFeatureAllowed(H.ARROW)&&this.docService.getDocumentPaths$().pipe(I(e=>!!e),F(1),f(e=>(this.documentPaths=e,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(I(r=>!!r),F(1),f(r=>{if(this.documentPaths?.arrow&&t?.annotationId){let i=JSON.parse(JSON.stringify(t));return i.position=null,this.commonDbService.setData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0},data:JSON.parse(JSON.stringify(i))})}else return P(null)}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in ArrowService updateArrowToDb subscription: ",e)})}catch(e){this.loggingService.catch("Error in ArrowService updateArrowToDb: ",e)}}deleteArrowPinAnnotations(t){try{let e=this.domService.getSelectedAnnotationsMap(),r=this.authService.getUser(),i=[];Object.keys(e).forEach(n=>At(this,null,function*(){let o=e[n];if(o.type==="arrow"){let a=r&&!r?.isAnonymous&&!r?.isGuest;r&&o.from&&(a||o.from.userId===r.userId)&&i.push(o)}})),i?.length&&(this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DELETE_TRIGGERED,{triggerType:t,annotationId:i.map(n=>n.annotationId).join()}),this.dialog.open(ue,{panelClass:"velt-mat-dialog-container",data:{title:"Delete arrow?",message:"This selected arrow will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"arrow"}}).afterClosed().pipe(F(1)).subscribe(n=>{n&&(i.forEach(o=>At(this,null,function*(){yield this.deleteArrowPinAnnotation(o)})),setTimeout(()=>{document.querySelectorAll(`[${d.SNIPPYLY_HIGHLIGHT}]`).forEach(a=>{this.domService.removeHighlightFromElement(a)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"arrow")}catch(e){this.loggingService.catch("Error in ArrowService deleteArrowPinAnnotations: ",e)}}deleteArrowPinAnnotation(t){return this.authService.isFeatureAllowed(H.ARROW)&&this.documentPaths?.arrow&&t?.annotationId?(this.updateNotificationsDatabase(t,Et.DELETED),this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DELETED,{annotationId:t.annotationId}),this.commonDbService.deleteData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0}})):Promise.resolve()}enableAddArrowMode(){this.authService.isFeatureAllowed(H.ARROW)?(this.analyticsService.trackEvent(_.Events.Arrow.ARROW_ADD_MODE_ENABLED),this.addArrowMode$.next(!0)):this.loggingService.catch("Error in ArrowService enableAddArrowMode: ","Arrow feature is not enabled.")}disableAddArrowMode(){this.analyticsService.trackEvent(_.Events.Arrow.ARROW_ADD_MODE_DISABLED),this.addArrowMode$.next(!1)}addArrowModeChange(){return this.addArrowMode$.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 ArrowService isElementInsideAllowedElements: ",e),!1}}updateNotificationsDatabase(t,e){try{let r={annotationData:t,actionType:e,notificationSource:"arrow"};this.serviceBook.get(se)?.updateNotificationDatabase(r)}catch(r){this.loggingService.catch("Error in ArrowService updateNotificationsDatabase: ",r)}}getArrowUrl(t){try{return t?.pageInfo?.arrowUrl?t.pageInfo.arrowUrl:(t?.pageInfo||(t.pageInfo=yt(),t.pageInfo&&(t.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),t.pageInfo.arrowUrl=this.generateArrowUrl(t),this.updateArrow(t),t.pageInfo?.arrowUrl)}catch(e){this.loggingService.catch("Error in ArrowService getArrowUrl: ",e);return}}generateArrowUrl(t){let e;try{e=new URL(t?.pageInfo?.url||window.location.href)}catch(r){this.loggingService.catch("Error in ArrowService generateArrowUrl: ",r),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}};s.\u0275fac=function(e){return new(e||s)(v(x),v(ce),v(he),v(le),v(V),v(D),v(Qt),v(ut),v(qt),v(A),v(mt),v(de))},s.\u0275prov=j({token:s,factory:s.\u0275fac,providedIn:"root"});let l=s;return l})();var Ce=["handle"],ye=["arrowRef"],be=["headRef"],Ie=l=>({transform:l});function _e(l,s){if(l&1){let c=G();W(0,"div",8,2),U("cdkDragStarted",function(e){E(c);let r=b();return C(r.onDragStarted(e))})("cdkDragMoved",function(e){E(c);let r=b();return C(r.onDragMoved(e))})("cdkDragReleased",function(e){E(c);let r=b();return C(r.onDragReleased(e))}),et(),W(2,"svg",9),st(3,"path",10)(4,"path",11),z()()}if(l&2){let c=b();N("s-arrow-annotation-handle-dragging",c.isResizing),R("cdkDragRootElement","arrow-pin-container-"+(c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId))("cdkDragDisabled",!c.isEditable||c.isResizing)}}function De(l,s){if(l&1){let c=G();W(0,"div",12,2),U("cdkDragStarted",function(){E(c);let e=b();return C(e.onResizeHandleDragStarted())})("cdkDragMoved",function(e){E(c);let r=b();return C(r.onResizeHandleDragMoved(e))})("cdkDragReleased",function(){E(c);let e=b();return C(e.onResizeHandleDragReleased())}),et(),W(2,"svg",13),st(3,"path",14),z()()}if(l&2){let c=b();N("s-arrow-annotation-handle-dragging",c.isResizing)}}var ve=(()=>{let s=class s{get arrowPinAnnotation(){return this._arrowPinAnnotation}set arrowPinAnnotation(t){this._arrowPinAnnotation=t,this.updatedArrowAngle&&this.arrowPinAnnotation?.props&&(this.arrowPinAnnotation.props.arrowAngle=this.updatedArrowAngle),this.calculateArrowWidthBasedOnViewport()}get arrowPinSelected(){return this._arrowPinSelected}set arrowPinSelected(t){this._arrowPinSelected=t,this.updateHighlightOnElement()}get arrowPinHover(){return this._arrowPinHover}set arrowPinHover(t){this._arrowPinHover=t,this.updateHighlightOnElement()}constructor(t,e,r,i){this.arrowService=t,this.domService=e,this.loggingService=r,this.elementRef=i,this._arrowPinSelected=!1,this.multipleArrowPinsSelected=!1,this.dragStarted=new at,this.dragMoved=new at,this.dragReleased=new at,this._arrowPinHover=!1,this.subscriptions=[],this.veltElement=!0,this.isDragging=!1,this.isResizing=!1,this.isEditable=!1,this.centerX=0,this.centerY=0,this.newAngle=0,this.newWidth=0,this.updatedArrowAngle=0,this.MIN_ARROW_LENGTH=d.VELT_MIN_ARROW_LENGTH,this.pointerEventSubscriptions=[],this.loggingService.log("%c[WB] Creating COMPONENT ArrowPinComponent","color: blue;")}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{this.updateHighlightOnElement(),setTimeout(()=>{this.calculateArrowWidthBasedOnViewport()},100)}catch(t){this.loggingService.catch("Error in ArrowPinComponent AfterViewInit: ",t)}}ngOnChanges(t){try{t.arrowPinAnnotation&&this.checkIsEditable(),t.user&&this.checkIsEditable()}catch(e){this.loggingService.catch("Error in ArrowPinComponent ngOnChanges: ",e)}}checkIsEditable(){try{this.user?.userId===this.arrowPinAnnotation?.from?.userId?this.isEditable=!0:this.user&&!this.user.isAnonymous&&!this.user.isGuest?this.isEditable=!0:this.isEditable=!1}catch(t){this.loggingService.catch("Error in ArrowPinComponent checkIsEditable: ",t)}}onResizeHandleDragStarted(){try{this.isResizing||(this.updatedArrowAngle=0,this.updateCenter(),this.isResizing=!0)}catch(t){this.loggingService.catch("Error in ArrowPinComponent onResizeHandleDragStarted: ",t)}}onResizeHandleDragMoved(t){try{let e=t.event;if(!this.isResizing||!this.isWithinViewport(e))return;let r=this.getAngleAndDistanceFromMouseEvent(e);this.newAngle=r.angle,this.newWidth=Math.min(r.distance,this.getMaxAllowedArrowLength()),e.stopPropagation()}catch(e){this.loggingService.catch("Error in ArrowPinComponent onResizeHandleDragMoved: ",e)}}onResizeHandleDragReleased(){try{this.isResizing=!1,this.updateArrowPinAnnotationProps(),setTimeout(()=>{this.newAngle=0,this.newWidth=0},100)}catch(t){this.loggingService.catch("Error in ArrowPinComponent onResizeHandleDragReleased: ",t)}}updateCenter(){try{let t=this.elementRef.nativeElement.getBoundingClientRect();this.centerX=t.x,this.centerY=t.y}catch(t){this.loggingService.catch("Error in ArrowPinComponent updateCenter: ",t)}}getAngleAndDistanceFromMouseEvent(t){try{let e=t instanceof MouseEvent?t.clientX:t.touches[0].clientX,r=t instanceof MouseEvent?t.clientY:t.touches[0].clientY,i=e-this.centerX,n=r-this.centerY,a=Math.atan2(n,i)*(180/Math.PI);a=a<0?a+360:a;let m=Math.sqrt(i*i+n*n);return{angle:a,distance:m}}catch(e){return this.loggingService.catch("Error in ArrowPinComponent getAngleAndDistanceFromMouseEvent: ",e),{angle:0,distance:0}}}isWithinViewport(t){try{return typeof TouchEvent<"u"&&t instanceof TouchEvent?t.touches[0].clientX>=0&&t.touches[0].clientX<=window?.innerWidth&&t.touches[0].clientY>=0&&t.touches[0].clientY<=window?.innerHeight:t.clientX>=0&&t.clientX<=window?.innerWidth&&t.clientY>=0&&t.clientY<=window?.innerHeight}catch(e){return this.loggingService.catch("Error in ArrowPinComponent isWithinViewport: ",e),!1}}calculateArrowWidthBasedOnViewport(){try{if(this.isDragging)return;if(this.arrowPinAnnotation?.props){let t=this.arrowPinAnnotation.props.viewportWidth||0,e=this.arrowPinAnnotation.props.viewportHeight||0,r=window.innerWidth,i=window.innerHeight;this.arrowPinAnnotation.props.arrowLength||(this.arrowPinAnnotation.props.arrowLength=0);let n=(this.arrowPinAnnotation.props.arrowAngle||0)%360;n>45&&n<135||n>225&&n<315?e>0&&(this.arrowPinAnnotation.props.arrowLength=this.arrowPinAnnotation.props.arrowLength*i/e):t>0&&(this.arrowPinAnnotation.props.arrowLength=this.arrowPinAnnotation.props.arrowLength*r/t);let o=this.arrowRef?.nativeElement?.getBoundingClientRect();if(o){n<0&&(n=360+n);let a=n,m=n>90&&n<=180,h=n>180&&n<=270,u=r-o.x;(m||h)&&(u=o.right,a=180-n);let T=ht(u-d.VELT_ARROW_VIEWPORT_PADDING,a);if(T>0&&this.arrowPinAnnotation.props.arrowLength>T)if(T<this.MIN_ARROW_LENGTH){let L=(this.arrowPinAnnotation.props.arrowAngle||0)%360;L>=90&&L<=270?this.updatedArrowAngle=45:this.updatedArrowAngle=135,this.arrowPinAnnotation.props.arrowLength=this.MIN_ARROW_LENGTH}else this.arrowPinAnnotation.props.arrowLength=T}this.arrowPinAnnotation.props.arrowLength=Math.min(this.arrowPinAnnotation.props.arrowLength,this.getMaxAllowedArrowLength())}}catch(t){this.loggingService.catch("Error in ArrowPinComponent calculateArrowWidthBasedOnViewport: ",t)}}getMaxAllowedArrowLength(){try{return Math.max(window.innerWidth,window.innerHeight)*.8}catch(t){return this.loggingService.catch("Error in ArrowPinComponent getMaxAllowedArrowLength: ",t),0}}updateHighlightOnElement(){try{this.targetElement&&(this.arrowPinSelected||this.arrowPinHover?this.domService.highlightElement(this.targetElement):this.domService.removeHighlightFromElement(this.targetElement))}catch(t){this.loggingService.catch("Error in ArrowPinComponent updateHighlightOnElement: ",t)}}updateArrowPinAnnotationProps(){try{this.arrowPinAnnotation?.props||(this.arrowPinAnnotation.props=new gt),this.arrowPinAnnotation.props.viewportWidth=window.innerWidth,this.arrowPinAnnotation.props.viewportHeight=window.innerHeight,this.arrowPinAnnotation.props.arrowAngle=this.newAngle,this.arrowPinAnnotation.props.arrowLength=this.newWidth,this.arrowService.updateArrow(this.arrowPinAnnotation)}catch(t){this.loggingService.catch("Error in ArrowPinComponent updateArrowPinAnnotation: ",t)}}onPointerOver(t){try{t.buttons?this.arrowPinHover&&(this.arrowPinHover=!1):this.arrowPinHover||(this.arrowPinHover=!0)}catch(e){this.loggingService.catch("Error in ArrowPinComponent onPointerOver: ",e)}}onDragStarted(t){this.isDragging=!0,this.dragStarted.emit(t)}onDragMoved(t){this.dragMoved.emit(t)}onDragReleased(t){this.isDragging=!1,this.dragReleased.emit(t)}onPointerOut(){this.arrowPinHover=!1}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowPinComponent 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 ArrowPinComponent unsubscribe: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(M),p(D),p(A),p(ot))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrow-pin"]],viewQuery:function(e,r){if(e&1&&(X(Ce,5),X(ye,5),X(be,5)),e&2){let i;Y(i=J())&&(r.handle=i.first),Y(i=J())&&(r.arrowRef=i.first),Y(i=J())&&(r.headRef=i.first)}},hostVars:1,hostBindings:function(e,r){e&2&&B("data-velt-element",r.veltElement)},inputs:{arrowPinAnnotation:"arrowPinAnnotation",arrowPinSelected:"arrowPinSelected",multipleArrowPinsSelected:"multipleArrowPinsSelected",user:"user",targetElement:"targetElement"},outputs:{dragStarted:"dragStarted",dragMoved:"dragMoved",dragReleased:"dragReleased"},features:[Lt],decls:7,vars:15,consts:[["arrowRef",""],["headRef",""],["handle",""],[1,"s-arrow-annotation",3,"pointerover","pointerout","click","ngStyle"],["class","s-arrow-annotation-drag-handle","cdkDrag","","cdkDragHandle","",3,"s-arrow-annotation-handle-dragging","cdkDragRootElement","cdkDragDisabled","cdkDragStarted","cdkDragMoved","cdkDragReleased",4,"ngIf"],[1,"s-arrow-annotation-head"],[1,"s-arrow-annotation-line"],["class","s-arrow-annotation-handle","cdkDrag","",3,"s-arrow-annotation-handle-dragging","cdkDragStarted","cdkDragMoved","cdkDragReleased",4,"ngIf"],["cdkDrag","","cdkDragHandle","",1,"s-arrow-annotation-drag-handle",3,"cdkDragStarted","cdkDragMoved","cdkDragReleased","cdkDragRootElement","cdkDragDisabled"],["width","32","height","32","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M18.0039 5.99219H14.4039M18.0039 5.99219V9.59219M18.0039 5.99219L13.8039 10.1922M6.00391 17.9922H9.60391M6.00391 17.9922V14.3922M6.00391 17.9922L10.2039 13.7922","stroke","#0093FF","stroke-width","1.2","stroke-linecap","round","stroke-linejoin","round"],["d","M6 5.99219H9.6M6 5.99219V9.59219M6 5.99219L10.2 10.1922M18 17.9922H14.4M18 17.9922V14.3922M18 17.9922L13.8 13.7922","stroke","#0093FF","stroke-width","1.2","stroke-linecap","round","stroke-linejoin","round"],["cdkDrag","",1,"s-arrow-annotation-handle",3,"cdkDragStarted","cdkDragMoved","cdkDragReleased"],["width","16","height","16","viewBox","0 0 10 10","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M1 5C1 3.11438 1 2.17157 1.58579 1.58579C2.17157 1 3.11438 1 5 1C6.88562 1 7.82843 1 8.41421 1.58579C9 2.17157 9 3.11438 9 5C9 6.88562 9 7.82843 8.41421 8.41421C7.82843 9 6.88562 9 5 9C3.11438 9 2.17157 9 1.58579 8.41421C1 7.82843 1 6.88562 1 5Z","stroke","#0093FF","stroke-width","1.5"]],template:function(e,r){if(e&1){let i=G();W(0,"div",3,0),U("pointerover",function(o){return E(i),C(r.onPointerOver(o))})("pointerout",function(){return E(i),C(r.onPointerOut())})("click",function(o){return E(i),C(o.preventDefault())}),$(2,_e,5,4,"div",4),st(3,"div",5,1)(5,"div",6),$(6,De,4,2,"div",7),z()}e&2&&(K("width",r.newWidth||(r.arrowPinAnnotation==null||r.arrowPinAnnotation.props==null?null:r.arrowPinAnnotation.props.arrowLength)||r.MIN_ARROW_LENGTH,"px"),N("s-arrow-annotation-selected",r.arrowPinSelected)("s-arrow-annotation-draggable",r.isEditable),R("ngStyle",jt(13,Ie,"rotate("+(r.newAngle||r.updatedArrowAngle||(r.arrowPinAnnotation==null||r.arrowPinAnnotation.props==null?null:r.arrowPinAnnotation.props.arrowAngle)||0)+"deg)")),O(2),R("ngIf",r.isEditable),O(),K("border-right-color",((r.arrowPinAnnotation==null||r.arrowPinAnnotation.from==null?null:r.arrowPinAnnotation.from.color)||(r.arrowPinAnnotation==null?null:r.arrowPinAnnotation.color))+" !important"),O(2),K("background-color",((r.arrowPinAnnotation==null||r.arrowPinAnnotation.from==null?null:r.arrowPinAnnotation.from.color)||(r.arrowPinAnnotation==null?null:r.arrowPinAnnotation.color))+" !important"),O(),R("ngIf",r.isEditable))},dependencies:[lt,ct,$t,Xt,Gt,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}.s-arrow-annotation[_ngcontent-%COMP%]{position:absolute!important;z-index:20!important;height:calc((.4rem + 0px) * var(--velt-base-rem-unit))!important;transform-origin:0 100%!important;left:50%!important;top:50%!important;display:flex!important;align-items:center!important;justify-content:flex-end!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-line[_ngcontent-%COMP%]{height:calc((.4rem + 0px) * var(--velt-base-rem-unit))!important;transform-origin:0 100%!important;width:100%!important;background-color:#625df5!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-head[_ngcontent-%COMP%]{width:0!important;height:0!important;border-top:calc((1.1rem + 0px) * var(--velt-base-rem-unit)) solid transparent!important;border-bottom:calc((1.1rem + 0px) * var(--velt-base-rem-unit)) solid transparent!important;border-right:calc((1.1rem + 0px) * var(--velt-base-rem-unit)) solid #625DF5!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-drag-handle[_ngcontent-%COMP%]{transform:none!important;cursor:move!important;display:flex!important;position:absolute!important;left:-20px!important;opacity:0!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-handle[_ngcontent-%COMP%]{transform:none!important;display:flex!important;opacity:0!important;cursor:grab!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-handle[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;height:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-handle.s-arrow-annotation-handle-dragging[_ngcontent-%COMP%]{cursor:grabbing!important}.s-arrow-annotation[_ngcontent-%COMP%]:hover .s-arrow-annotation-drag-handle[_ngcontent-%COMP%], .s-arrow-annotation.s-arrow-annotation-selected[_ngcontent-%COMP%] .s-arrow-annotation-drag-handle[_ngcontent-%COMP%], .s-arrow-annotation[_ngcontent-%COMP%]:hover .s-arrow-annotation-handle[_ngcontent-%COMP%], .s-arrow-annotation.s-arrow-annotation-selected[_ngcontent-%COMP%] .s-arrow-annotation-handle[_ngcontent-%COMP%]{opacity:1!important}"],changeDetection:0});let l=s;return l})();var Te=["arrowPinRef"];function Oe(l,s){if(l&1){let c=G();W(0,"div",3),U("pointerup",function(e){return E(c),b(2).togglePinSelection(),C(e.stopPropagation())})("pointerdown",function(e){return E(c),C(e.stopPropagation())})("click",function(e){return E(c),C(e.stopPropagation())}),W(1,"snippyly-arrow-pin",4,0),U("dragStarted",function(){E(c);let e=b(2);return C(e.onPinDragStart())})("dragMoved",function(e){E(c);let r=b(2);return C(r.onPinMove(e))})("dragReleased",function(){E(c);let e=b(2);return C(e.onPinRelease())}),z()()}if(l&2){let c=b().ngIf,t=b();K("top",c.annotationDragging?c.dragPosition==null?null:c.dragPosition.top:(c.arrowPinAnnotation==null||c.arrowPinAnnotation.position==null?null:c.arrowPinAnnotation.position.top)+c.offsetTop,"px")("left",c.annotationDragging?c.dragPosition==null?null:c.dragPosition.left:(c.arrowPinAnnotation==null||c.arrowPinAnnotation.position==null?null:c.arrowPinAnnotation.position.left)+c.offsetLeft,"px"),N("pin-dragging",c.annotationDragging),R("id","arrow-pin-container-"+(c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId)),O(),R("arrowPinAnnotation",c.arrowPinAnnotation)("arrowPinSelected",c.selectedAnnotationsMap[c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId]&&!c.annotationDragging&&t.objectKeys(c.selectedAnnotationsMap).length===1)("multipleArrowPinsSelected",c.selectedAnnotationsMap[c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId]&&t.objectKeys(c.selectedAnnotationsMap).length>1)("targetElement",c.targetElement)("user",c.user)}}function Re(l,s){if(l&1&&(xt(0),$(1,Oe,3,12,"div",2),Vt()),l&2){let c=s.ngIf;O(),R("ngIf",c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.position)}}var fe=(()=>{let s=class s{constructor(t,e,r,i,n){this.analyticsService=t,this.authService=e,this.domService=r,this.arrowService=i,this.loggingService=n,this.multipleArrowPinsSelected=!1,this.avatarErrorImage="",this.objectKeys=Object.keys,this.subscriptions=[],this.componentConfigSignal=Mt({arrowPinAnnotation:void 0,annotationDragging:!1,dragPosition:null,offsetTop:0,offsetLeft:0,selectedAnnotationsMap:{},targetElement:void 0,user:void 0}),this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(o=>{this.componentConfigSignal.update(a=>(a=y(w({},a),{user:o}),a))},o=>{this.loggingService.catch("Error in ArrowPinPortalComponent getUser$ subscription: ",o)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(o=>{this.componentConfigSignal.update(a=>(a=y(w({},a),{selectedAnnotationsMap:o}),a))},o=>{this.loggingService.catch("Error in ArrowPinPortalComponent getSelectedAnnotationsMap$ subscription: ",o)}))}ngOnInit(){}setArrowPinAnnotation(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{arrowPinAnnotation:t}),e)),this.id=this.componentConfigSignal().arrowPinAnnotation?.annotationId}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setArrowPinAnnotation: ",e)}}setTargetElement(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{targetElement:t}),e))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setTargetElement: ",e)}}setOffsetLeft(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{offsetLeft:t}),e))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setOffsetLeft: ",e)}}setOffsetTop(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{offsetTop:t}),e))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setOffsetTop: ",e)}}togglePinSelection(){try{this.domService.toggleAnnotationSelection(this.componentConfigSignal().arrowPinAnnotation)}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent togglePinSelection: ",t)}}onPinDragStart(){this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().arrowPinAnnotation.annotationId]&&this.domService.toggleAnnotationSelection(this.componentConfigSignal().arrowPinAnnotation);let t=document.getElementById(this.componentConfigSignal().arrowPinAnnotation.annotationId);t&&(this.parentElement=t.parentElement,t.style.opacity="0",document.body.appendChild(t)),this.componentConfigSignal.update(e=>(e=y(w({},e),{annotationDragging:!0}),e)),setTimeout(()=>{t&&(t.style.opacity="1")},50)}onPinMove(t){try{this.updateCurrentPinPosition(t)}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent onPinMove: ",e)}}updateCurrentPinPosition(t){try{this.domService.removeHighlightFromElement(this.componentConfigSignal().targetElement);let e=t.event,r=e?.touches?.length?e.touches[0]?.clientX:e.clientX,i=e?.touches?.length?e.touches[0]?.clientY:e.clientY,n=this.domService.getBackgroundElement(r,i);n&&(this.componentConfigSignal.update(o=>(o=y(w({},o),{targetElement:n}),o)),this.domService.highlightElement(this.componentConfigSignal().targetElement),this.pointerMoveEvent=t.event,this.componentConfigSignal.update(o=>(o=y(w({},o),{dragPosition:{top:i,left:r}}),o)))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent updateCurrentPinPosition: ",e)}}onPinRelease(){try{let t=document.getElementById(this.componentConfigSignal().arrowPinAnnotation.annotationId);t&&this.parentElement&&this.parentElement.appendChild(t);let e=this.domService.getElementFromXPath(this.componentConfigSignal().arrowPinAnnotation.targetElement?.xpath);if(this.pointerMoveEvent){this.componentConfigSignal.update(h=>(h=w({},h),h.arrowPinAnnotation.targetElement=this.domService.getTargetElementForCursorPosition(this.pointerMoveEvent),h));let n=this.pointerMoveEvent,o=n?.touches?.length?n.touches[0]?.clientX:n.clientX,a=!1;if(o<d.VELT_MIN_ARROW_LENGTH){let h=this.componentConfigSignal().arrowPinAnnotation.props.arrowAngle||0;h>=90&&h<=270&&(this.componentConfigSignal.update(u=>(u=w({},u),u.arrowPinAnnotation.props.arrowAngle=45,u)),a=!0)}if(o>window?.innerWidth-d.VELT_MIN_ARROW_LENGTH){let h=this.componentConfigSignal().arrowPinAnnotation.props.arrowAngle||0;(h>=270&&h<=360||h>=0&&h<=90)&&(this.componentConfigSignal.update(u=>(u=w({},u),u.arrowPinAnnotation.props.arrowAngle=135,u)),a=!0)}if(!a){let h=o,u=this.componentConfigSignal().arrowPinAnnotation.props.arrowAngle||0;u>=0&&u<=90||u>=270&&u<=360?h=window.innerWidth-o:u=180-u;let T=ht(h-d.VELT_ARROW_VIEWPORT_PADDING,u);T>0&&T<(this.componentConfigSignal().arrowPinAnnotation.props.arrowLength||0)&&this.componentConfigSignal.update(L=>(L=w({},L),L.arrowPinAnnotation.props.arrowLength=T,L))}let m=this.domService.getCurrentWindowSizeValue();this.componentConfigSignal.update(h=>(h=w({},h),h.arrowPinAnnotation.props.screenWidth=m.screenWidth,h.arrowPinAnnotation.props.screenHeight=m.screenHeight,h.arrowPinAnnotation.props.screenScrollHeight=m.screenScrollHeight,h.arrowPinAnnotation.props.viewportWidth=window.innerWidth,h.arrowPinAnnotation.props.viewportHeight=window.innerHeight,h))}let r=this.domService.getElementFromXPath(this.componentConfigSignal().arrowPinAnnotation.targetElement?.xpath),i=this.domService.isElementInsideAdditionalLocationContainer(e)||this.domService.isElementInsideAdditionalLocationContainer(r);this.arrowService.updateArrow(this.componentConfigSignal().arrowPinAnnotation,!1,i),setTimeout(()=>{this.componentConfigSignal.update(n=>(n=w({},n),n.annotationDragging=!1,n.dragPosition=null,n)),this.domService.removeHighlightFromElement(this.componentConfigSignal().targetElement),this.arrowPinRef&&(this.arrowPinRef.updatedArrowAngle=0)},100),this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DRAGGED,{annotationId:this.componentConfigSignal().arrowPinAnnotation.annotationId})}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent onPinRelease: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent 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 ArrowPinPortalComponent unsubscribe: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(x),p(V),p(D),p(M),p(A))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrow-pin-portal"]],viewQuery:function(e,r){if(e&1&&X(Te,5),e&2){let i;Y(i=J())&&(r.arrowPinRef=i.first)}},hostVars:2,hostBindings:function(e,r){e&2&&(Ft("id",r.id),B("data-velt-element",r.veltElement))},inputs:{multipleArrowPinsSelected:"multipleArrowPinsSelected",avatarErrorImage:"avatarErrorImage"},decls:1,vars:1,consts:[["arrowPinRef",""],[4,"ngIf"],["class","arrow-pin-portal",3,"id","pin-dragging","top","left","pointerup","pointerdown","click",4,"ngIf"],[1,"arrow-pin-portal",3,"pointerup","pointerdown","click","id"],[3,"dragStarted","dragMoved","dragReleased","arrowPinAnnotation","arrowPinSelected","multipleArrowPinsSelected","targetElement","user"]],template:function(e,r){e&1&&$(0,Re,2,1,"ng-container",1),e&2&&R("ngIf",r.componentConfigSignal())},dependencies:[lt,ct,ve],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}.arrow-pin-portal[_ngcontent-%COMP%]{position:absolute;transform:none!important;top:0;left:0}.arrow-pin-portal.pin-dragging[_ngcontent-%COMP%]{position:fixed;z-index:var(--velt-arrow-z-index)!important}"],changeDetection:0});let l=s;return l})();var Ae=(()=>{let s=class s{constructor(t,e,r,i,n){this.domService=t,this.componentFactoryResolver=e,this.injector=r,this.appRef=i,this.loggingService=n,this.arrowsPinById={}}setArrowPin(t){try{if(!this.arrowsPinById[t.annotationId])this.setPinPortal(t);else if(t.targetElement?.xpath===this.arrowsPinById[t.annotationId]?.annotation?.targetElement?.xpath){let e=this.arrowsPinById[t.annotationId].portalRef,r=this.arrowsPinById[t.annotationId].userTargetElement,i=this.arrowsPinById[t.annotationId].pinHostElement;if(document.body.contains(r)&&document.body.contains(i))e&&(e.instance.setArrowPinAnnotation(JSON.parse(JSON.stringify(t))),this.updateElementOffset(t));else{let n=this.arrowsPinById[t.annotationId].pinHostDomPortalOutlet;n&&(this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST),this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC),n.detach(),delete this.arrowsPinById[t.annotationId],this.setPinPortal(t))}}else{let e=this.arrowsPinById[t.annotationId].pinHostDomPortalOutlet;e&&(this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST),this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC),e.detach(),delete this.arrowsPinById[t.annotationId],this.setPinPortal(t))}}catch(e){this.loggingService.catch("Error in ArrowPinPortalService setArrowPin: ",e)}}setPinPortal(t){try{let e=this.domService.getXPath(t.targetElement?.xpath);if(e){let r=e.iterateNext();if(r){let i=this.domService.getHostElement(r),n=new Yt(fe),o=new Jt(i,this.appRef,this.injector),a=o.attach(n);a.instance.setArrowPinAnnotation(JSON.parse(JSON.stringify(t))),a.instance.setTargetElement(r),this.arrowsPinById[t.annotationId]={pinHostDomPortalOutlet:o,pinPortal:n,portalRef:a,annotation:JSON.parse(JSON.stringify(t)),userTargetElement:r,pinHostElement:i},i.setAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST,t.annotationId),window.getComputedStyle(i).position==="static"&&(ne(i)||i.setAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC,"true")),this.updateElementOffset(t)}}}catch(e){this.loggingService.catch("Error in ArrowPinPortalService setPinPortal: ",e)}}updateElementOffset(t){try{let{portalRef:e,userTargetElement:r,pinHostElement:i}=this.arrowsPinById[t.annotationId],n=this.domService.getElementOffset(r,i);e.instance.setOffsetLeft(n.offsetLeft),e.instance.setOffsetTop(n.offsetTop)}catch(e){this.loggingService.catch("Error in ArrowPinPortalService updateElementOffset: ",e)}}checkPinsToRemove(t){try{let e=t.map(r=>r.annotationId);Object.keys(this.arrowsPinById).forEach(r=>{if(!e.includes(r)){let i=this.arrowsPinById[r];i.pinHostDomPortalOutlet.detach(),i.pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST),i.pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC),this.domService.removeHighlightFromElement(i.pinHostElement),delete this.arrowsPinById[r]}})}catch(e){this.loggingService.catch("Error in ArrowPinPortalService checkPinsToRemove: ",e)}}};s.\u0275fac=function(e){return new(e||s)(v(D),v(Wt),v(Rt),v(Bt),v(A))},s.\u0275prov=j({token:s,factory:s.\u0275fac,providedIn:"root"});let l=s;return l})();var Dt=(()=>{let s=class s{constructor(t,e,r,i,n,o){this.analyticsService=t,this.authService=e,this.domService=r,this.arrowService=i,this.arrowPinPortalService=n,this.loggingService=o,this.arrowPinAnnotations=[],this.subscriptions=[],this.isFirstComponent=!0,this.veltId=ee(),this.veltElement=!0;try{this.loggingService.log("%c[WB] Creating CLASS: ArrowsContainerComponent","color: blue;")}catch(a){this.loggingService.catch("Error in ArrowsContainerComponent constructor: ",a)}}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{let t=document.querySelector(d.TAGS.SNIPPYLY_ARROWS),e=document.querySelector(d.TAGS.VELT_ARROWS);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 ArrowsContainerComponent AfterViewInit: ",t)}}initComponent(){try{this.subscriptions.push(this.authService.getUser$().pipe(I(t=>!!t)).subscribe(t=>{t&&this.setArrowInstalledInAnalytics()},t=>{this.loggingService.catch("Error in getUser: ",t)})),this.getAllArrowsOnCurrentDocument()}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent initComponent: ",t)}}getAllArrowsOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowsOnCurrentDocument","color: green;");try{this.subscriptions.push(this.arrowService.getAllArrowAnnotations().pipe(I(t=>!!t),f(t=>this.domService.getSelectedAnnotationsMap$().pipe(S(e=>({annotations:t,selectedAnnotationsMap:e||{}}))))).subscribe(t=>{try{this.loggingService.log(t),this.arrowPinAnnotations=t?.annotations;let e=this.arrowPinAnnotations.filter(r=>r.targetElement);this.arrowPinPortalService.checkPinsToRemove(e),e.forEach(r=>{this.arrowPinPortalService.setArrowPin(r)})}catch(e){this.loggingService.catch("Error in ArrowsContainerComponent getAllArrowsOnCurrentDocument inside subscription: ",e)}},t=>{this.loggingService.catch("Error in ArrowsContainerComponent getAllArrowsOnCurrentDocument subscription: ",t)}))}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent getAllArrowsOnCurrentDocument: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent 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 ArrowsContainerComponent unsubscribe: ",t)}}setArrowInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(H.ARROW)}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent setArrowInstalledInAnalytics: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(x),p(V),p(D),p(M),p(Ae),p(A))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrows-container"]],hostVars:2,hostBindings:function(e,r){e&2&&B("data-velt-id",r.veltId)("data-velt-element",r.veltElement)},decls:0,vars:0,template:function(e,r){},encapsulation:2,changeDetection:0});let l=s;return l})();var Tt=(()=>{let s=class s extends pe{constructor(t,e,r,i,n,o,a,m,h){super(a,o,void 0,void 0,void 0,m,n),this.analyticsService=t,this.authService=e,this.arrowService=r,this.iamService=i,this.loggingService=n,this.themeService=o,this.elementRef=a,this.dynamicDataService=m,this.domService=h,this.customButtonAdded=!1,this.disabled=!1,this.addArrowMode=!1,this.subscriptions=[],this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(u=>{this.user=u},u=>{this.loggingService.catch("Error in ArrowsToolComponent getUser$ subscription: ",u)}))}ngAfterViewInit(){try{this.subscriptions.push(this.domService.subscribeInjectCustomCss(this.elementRef)),this.subscriptions.push(this.arrowService.addArrowModeChange().subscribe(t=>{this.addArrowMode=t})),this.subscriptions.push(this.iamService.getFeaturesAccessLevel$().subscribe(t=>{this.disabled=!!t?.all?.disabled}))}catch(t){this.loggingService.catch("Error in ArrowsToolComponent AfterViewInit: ",t)}}onButtonSlotChange(){this.customButtonAdded=!0}addArrow(){this.loggingService.log("%c[WB] Calling FUNCTION: addArrow","color: green;");try{if(this.analyticsService.trackEvent(_.Events.Arrow.ARROW_TOOL_CLICKED,{toolType:this.customButtonAdded?"custom":"default"}),this.user){if(this.disabled){this.loggingService.catch("Arrows are disabled.");return}this.user.isReadOnly||this.user.isAnonymous?this.loggingService.catch("Anonymous/Readonly users cannot add arrows."):!this.authService.isPlanExpired()&&this.iamService.getRole()?this.arrowService.enableAddArrowMode():this.loggingService.catch("User does not have permission to add arrows.")}else this.loggingService.catch("Velt sdk not authenticated.")}catch(t){this.loggingService.catch("Error in ArrowsToolComponent addArrow: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{super.ngOnDestroy(),this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowsToolComponent 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 ArrowsToolComponent unsubscribe: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(x),p(V),p(M),p(ut),p(A),p(me),p(ot),p(pt),p(D))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrows-tool"]],hostVars:1,hostBindings:function(e,r){e&2&&B("data-velt-element",r.veltElement)},features:[Ut([pt]),kt],decls:5,vars:2,consts:[["part","container",1,"snippyly-arrow-btn-container",3,"click"],["name","button",3,"slotchange"],["part","button-container","tabindex","0",1,"action-btn"],["part","button-icon","width","24","height","24","viewBox","0 0 25 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon"],["d","M17.5 7L7.5 17M17.5 7H10M17.5 7V14.5","stroke","currentColor","stroke-width","1.5","stroke-linecap","round","stroke-linejoin","round"]],template:function(e,r){e&1&&(rt(0,"div",0),Pt("click",function(n){return r.addArrow(),n.stopPropagation()}),rt(1,"slot",1),Pt("slotchange",function(){return r.onButtonSlotChange()}),rt(2,"div",2),et(),rt(3,"svg",3),Ht(4,"path",4),Nt()()()()),e&2&&(O(2),N("active",r.addArrowMode))},styles:[`html{--velt-base-rem-unit: 1}*[data-snippyly-element=true],*[data-velt-element=true]{font-family:var(--velt-default-font-family)}velt-wireframe{display:none!important}body.velt-pin-dragging iframe{pointer-events:none!important}*{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;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*:empty{display:revert!important}.snippyly-arrow-btn-container{display:inline-block}.action-btn{display:flex;justify-content:center;align-items:center;padding:6px!important;border-radius:var(--legacy-velt-tool-border-radius);border:var(--legacy-velt-tool-border);background-color:var(--legacy-velt-tool-bg-color)}.action-btn .action-btn-icon{width:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-icon-color);cursor:pointer}.action-btn:focus{border-radius:var(--legacy-velt-tool-focus-border-radius);border:var(--legacy-velt-tool-focus-border);background-color:var(--legacy-velt-tool-focus-bg-color)}.action-btn:focus .action-btn-icon{width:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-focus-icon-color)}.action-btn:hover{border-radius:var(--legacy-velt-tool-hover-border-radius);border:var(--legacy-velt-tool-hover-border);background-color:var(--legacy-velt-tool-hover-bg-color)}.action-btn:hover .action-btn-icon{width:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-hover-icon-color)}.action-btn:active,.action-btn.active{border-radius:var(--legacy-velt-tool-active-border-radius);border:var(--legacy-velt-tool-active-border);background-color:var(--legacy-velt-tool-active-bg-color)}.action-btn:active .action-btn-icon,.action-btn.active .action-btn-icon{width:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-active-icon-color)}
|
|
1
|
+
import{b as zt,c as Gt,d as Xt}from"./chunk-EB7SHB2S.js";import{b as ue}from"./chunk-5ACPKO6C.js";import{a as ut}from"./chunk-ZRITZXNF.js";import{a as Kt}from"./chunk-SYLJZSJP.js";import{Ga as pt,Ha as me,Ja as pe,r as Yt,t as Jt,za as qt}from"./chunk-GHN6NWBT.js";import{a as we}from"./chunk-67RGQF3Z.js";import{D as de,E as he,p as ge}from"./chunk-NTFMMZRZ.js";import{Ab as Pt,Bb as b,E as I,Fb as X,G as Ot,Gb as Y,Gd as Qt,Ha as O,Hb as J,He as d,Hi as _,Ia as at,Ic as ct,Ij as le,Jg as dt,Ji as ae,K as F,Ki as se,Lb as K,M as St,Mb as N,Mc as $t,Ne as gt,Oa as Wt,Ph as ht,Ra as p,Rc as lt,Sh as ie,Tg as yt,Th as ne,Ue as Zt,V as f,Wa as k,Zf as Ct,_a as kt,a as w,ab as $,ac as Ut,ah as bt,b as y,ba as j,ci as oe,db as Bt,dc as jt,ea as v,fb as B,g as At,ja as E,ka as C,l as tt,la as et,na as Rt,nb as R,nj as mt,ob as W,oe as Et,oj as x,pb as z,pj as A,qb as st,qj as ce,r as P,rb as rt,re as H,rk as D,sa as Mt,sb as Nt,sk as V,tb as Ht,ub as xt,ug as te,v as S,vb as Vt,vg as ee,wa as Lt,xb as G,ya as ot,yb as Ft,yg as re,zb as U}from"./chunk-VESMHAEV.js";var M=(()=>{let s=class s{constructor(t,e,r,i,n,o,a,m,h,u,T,L){this.analyticsService=t,this.configService=e,this.docService=r,this.databaseService=i,this.authService=n,this.domService=o,this.afAuth=a,this.iamService=m,this.dialog=h,this.loggingService=u,this.serviceBook=T,this.commonDbService=L,this.arrowAnnotations$=new tt({}),this.arrowAnnotationsByDocumentId$=new tt({}),this.documentPaths=null,this.allowedElementIds$=new tt([]),this.addArrowMode$=new tt(!1),this.loggingService.log("%c[WB] Creating CLASS: ArrowService","color: blue;"),this.databaseService.getDb().pipe(I(g=>!!g),F(1)).subscribe(g=>{g&&this.getDocumentPaths()},g=>{this.loggingService.catch("Error in ArrowService getDb subscription: ",g)}),this.domService.onWindowPointerMove$().subscribe(g=>{if(this.addArrowMode$.value){let Z=!0,nt=this.domService.getBackgroundElement(g.clientX,g.clientY);nt&&(this.isElementInsideAllowedElements(nt)?bt(g.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement&&this.highlightElement!==nt&&this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=nt,this.domService.highlightElement(this.highlightElement,d.CURSOR.ARROW_PIN),Z=!1):this.domService.removeClassFromElement(document.body,"show-pin-cursor")),this.highlightElement&&Z&&(this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=null)}},g=>{this.loggingService.catch("Error in ArrowService onWindowPointerMove$ subscription: ",g)}),this.domService.onWindowKeyupEsc$().subscribe(g=>{this.addArrowMode$.value&&this.disableAddArrowMode()},g=>{this.loggingService.catch("Error in ArrowService onWindowKeyupEsc$ subscription: ",g)}),this.domService.onDocumentClick$().subscribe(g=>{if(g&&this.addArrowMode$.value){if(!bt(g.target)){let Z=this.domService.getBackgroundElement(g.clientX,g.clientY);Z&&this.isElementInsideAllowedElements(Z)&&(g.preventDefault(),g.stopPropagation(),this.addArrow(g))}this.disableAddArrowMode()}},g=>{this.loggingService.catch("Error in ArrowService onDocumentClick$ subscription: ",g)}),this.addArrowMode$.subscribe(g=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),g?this.domService.addClassToElement(document.body,"snippyly-add-arrow-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-arrow-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},g=>{this.loggingService.catch("Error in ArrowService addArrowMode$ subscription: ",g)}),this.domService.onWindowKeyupBackspace$().subscribe(g=>{this.deleteArrowPinAnnotations("keyupBackspace")},g=>{this.loggingService.catch("Error in ArrowService onWindowKeyupBackspace$ subscription: ",g)}),this.domService.onWindowKeyupDelete$().subscribe(g=>{this.deleteArrowPinAnnotations("keyupDelete")},g=>{this.loggingService.catch("Error in ArrowService onWindowKeyupDelete$ subscription: ",g)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}setAllowedElementIds(t){this.allowedElementIds$.next(t||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getAllArrowAnnotations(t,e,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowAnnotations","color: green;");let i,n;try{if(t&&(n=Ct(t)),e&&typeof e=="object"){let o=re(e);i=Ct(JSON.stringify(o))}}catch(o){this.loggingService.catch("Error in ArrowService getAllArrowAnnotations: ",o)}return this.authService.getAuthState$().pipe(I(o=>!!o),f(o=>this.isFeatureAllowed({firebaseUser:o,annotations:[],filteredAnnotations:[]})),f(o=>o.featureAllowed?this.iamService.isUserAllowed$().pipe(S(a=>(o.featureAllowed=a,o))):P(o)),f(o=>o.featureAllowed?this.authService.isPlanExpired$().pipe(S(a=>(o.featureAllowed=!a,o))):P(o)),f(o=>o.featureAllowed?P(o).pipe(f(a=>this.docService.getDocumentPaths$().pipe(S(m=>(this.documentPaths=m,a.documentPaths=m,a)))),f(a=>this.getDataFromDocumentId(n).pipe(S(m=>(a.annotations=m||[],w({},a))))),f(a=>this.docService.getLocation$().pipe(S(m=>(a.location=m,a)))),f(a=>this.docService.getLocations$().pipe(S(m=>(a.customLocations=m,a)))),S(a=>{if(a.filteredAnnotations=[],n&&!i)return a.filteredAnnotations=a.annotations?.slice(),a;{let m=[];return i?m.push(i):(m.push(a?.location?.locationId),m.push(...Object.values(a?.customLocations||[]).map(h=>h.locationId))),a.filteredAnnotations=this.filterAnnotationsByLocationIds(a?.annotations,m),a}}),f(a=>r?P(a):a?.annotations?.length?this.domService.onWindowResize$().pipe(S(()=>a)):P(a)),f(a=>r?P(a):a?.annotations?.length?this.domService.onDomChange$("ArrowService getAllArrowAnnotations").pipe(S(()=>a)):P(a)),S(a=>(a?.filteredAnnotations?.forEach(m=>{this.calculateArrowAnnotationPosition(m)}),a)),f(a=>a?.filteredAnnotations?P(a?.filteredAnnotations||[]):P([]))):P([])),St(oe))}isFeatureAllowed(t){return this.configService.getConfig$().pipe(I(e=>!!e),S(e=>y(w({},t),{config:e})),f(e=>this.authService.getUser$().pipe(S(r=>y(w({},e),{user:r})))),f(e=>te(e.config,e.user,H.ARROW)?P(y(w({},e),{featureAllowed:!0})):(this.loggingService.warn("Arrow feature is not allowed."),P(y(w({},e),{featureAllowed:!1})))),St((e,r)=>e?.featureAllowed===r?.featureAllowed))}getDataFromDocumentId(t){return this.databaseService.getDb().pipe(I(e=>!!e),f(e=>this.configService.getApiKey()&&this.documentPaths?.arrow&&this.documentPaths?this.commonDbService.dbListener({feature:"allArrows",properties:{documentId:t??this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(S(r=>({data:r?.data,operation:r?.operation})),S(({data:r,operation:i})=>{let n=[];return r&&(n=Object.values(r).filter(o=>typeof o=="object")),{data:n,operation:i}}),Ot(r=>(this.loggingService.catch("Error in ArrowService getDataFromDocumentId: ",r),P({data:[],operation:null}))),S(({data:r,operation:i})=>{if(i?.type==="removed"){if(i?.ids?.length){let n=this.arrowAnnotationsByDocumentId$.value;i?.ids?.forEach(o=>{delete n?.[o]}),this.arrowAnnotationsByDocumentId$.next(n)}}else this.setArrowAnnotationsByDocumentId(t||this.documentPaths?.documentId,r);return r})):P([])))}setArrowAnnotationsByDocumentId(t,e){try{if(t){let r=y(w({},this.arrowAnnotationsByDocumentId$.value),{[t]:e});this.arrowAnnotationsByDocumentId$.next(r)}}catch(r){this.loggingService.catch("Error in ArrowService setArrowAnnotationsByDocumentId:",r)}}filterAnnotationsByLocationIds(t,e){try{return t.filter(r=>e.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in ArrowService filterAnnotationsByLocations:",r),[]}}calculateArrowAnnotationPosition(t){try{if(t.targetElement){let e=this.domService.getXPath(t.targetElement?.xpath);if(e){let r=e.iterateNext();if(r&&dt(r)){let i=r.getBoundingClientRect();if(i&&i.width&&i.height){let{height:n,width:o}=ie(r);t.position={top:n*t.targetElement.topPercentage/100,left:o*t.targetElement.leftPercentage/100}}else t.position=null}else t.position=null}else t.position=null}}catch(e){this.loggingService.catch("Error in ArrowService calculateArrowAnnotationPosition:",e)}}addArrow(t){this.loggingService.log("%c[WB] Calling FUNCTION: addArrow","color: green;");try{let e=this.authService.getUser();if(e)if(e.isReadOnly||e.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add arrows.");else{let r=new Zt;r.from=e,r.color=e?.color||d.DEFAULT_ANNOTATION_COLOR,r.lastUpdated=this.timestamp,r.props=new gt;let i=this.domService.getCurrentWindowSizeValue();if(r.props.screenWidth=i.screenWidth,r.props.screenHeight=i.screenHeight,r.props.screenScrollHeight=i.screenScrollHeight,r.props.viewportWidth=window.innerWidth,r.props.viewportHeight=window.innerHeight,r.props.arrowLength=d.VELT_MIN_ARROW_LENGTH,(t?.clientX||0)>d.VELT_MIN_ARROW_LENGTH?r.props.arrowAngle=135:r.props.arrowAngle=45,t&&(r.targetElement=this.domService.getTargetElementForCursorPosition(t)),r?.targetElement?.xpath){let n=this.domService.getXPath(r.targetElement.xpath);if(n){let o=n.iterateNext();o&&(dt(o)||(r.targetElement=null))}}this.setLocationToArrowAnnotation(r),r.pageInfo=yt(),r.pageInfo&&(r.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveArrowToDb(r)}}catch(e){this.loggingService.catch("Error in ArrowService addArrow: ",e)}}setLocationToArrowAnnotation(t){try{let e=this.docService.getLocation();e?(t.locationId=e.locationId,t.location=e.location):(delete t.locationId,delete t.location);try{if(t.targetElement?.xpath){let r=this.domService.getElementFromXPath(t.targetElement.xpath),i=this.docService.getAdditionLocationFromElement(r);if(i){let n=this.docService.addLocation({location:i,source:"internal"});n?.[0]&&(t.locationId=n[0].locationId,t.location=n[0].location)}}}catch{}}catch(e){this.loggingService.catch("Error in ArrowService setLocationToArrowAnnotation:",e)}}saveArrowToDb(t){this.loggingService.log("%c[WB] Calling FUNCTION: saveArrowToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(H.ARROW)&&this.docService.getDocumentPaths$().pipe(I(e=>!!e),F(1),f(e=>(this.documentPaths=e,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(I(r=>!!r),F(1),f(r=>{if(this.documentPaths?.arrow){t.annotationId=this.commonDbService.generateDocumentId(),t.pageInfo&&(t.pageInfo.arrowUrl=this.generateArrowUrl(t));let i=JSON.parse(JSON.stringify(t));return i.position=null,this.domService.toggleAnnotationSelection(i),this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DRAFT_ADDED,{annotationId:t.annotationId}),this.commonDbService.setData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0},data:JSON.parse(JSON.stringify(i))})}else return P(null)}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in ArrowService saveArrowToDb subscription: ",e)})}catch(e){this.loggingService.catch("Error in ArrowService saveArrowToDb: ",e)}}updateArrow(t,e=!1,r){try{r&&this.setLocationToArrowAnnotation(t),e&&this.updateNotificationsDatabase(t,Et.UPDATED),this.updateArrowToDb(t)}catch(i){this.loggingService.catch("Error in ArrowService updateArrow: ",i)}}updateArrowToDb(t){this.loggingService.log("%c[WB] Calling FUNCTION: updateArrowToDb","color: green;");try{if(t?.targetElement?.xpath){let e=this.domService.getXPath(t.targetElement.xpath);if(e){let r=e.iterateNext();r&&(dt(r)||(t.targetElement=null))}}this.domService.updateSelectedAnnotationInMap([t]),this.authService.getUser()&&this.authService.isFeatureAllowed(H.ARROW)&&this.docService.getDocumentPaths$().pipe(I(e=>!!e),F(1),f(e=>(this.documentPaths=e,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(I(r=>!!r),F(1),f(r=>{if(this.documentPaths?.arrow&&t?.annotationId){let i=JSON.parse(JSON.stringify(t));return i.position=null,this.commonDbService.setData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0},data:JSON.parse(JSON.stringify(i))})}else return P(null)}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in ArrowService updateArrowToDb subscription: ",e)})}catch(e){this.loggingService.catch("Error in ArrowService updateArrowToDb: ",e)}}deleteArrowPinAnnotations(t){try{let e=this.domService.getSelectedAnnotationsMap(),r=this.authService.getUser(),i=[];Object.keys(e).forEach(n=>At(this,null,function*(){let o=e[n];if(o.type==="arrow"){let a=r&&!r?.isAnonymous&&!r?.isGuest;r&&o.from&&(a||o.from.userId===r.userId)&&i.push(o)}})),i?.length&&(this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DELETE_TRIGGERED,{triggerType:t,annotationId:i.map(n=>n.annotationId).join()}),this.dialog.open(ue,{panelClass:"velt-mat-dialog-container",data:{title:"Delete arrow?",message:"This selected arrow will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"arrow"}}).afterClosed().pipe(F(1)).subscribe(n=>{n&&(i.forEach(o=>At(this,null,function*(){yield this.deleteArrowPinAnnotation(o)})),setTimeout(()=>{document.querySelectorAll(`[${d.SNIPPYLY_HIGHLIGHT}]`).forEach(a=>{this.domService.removeHighlightFromElement(a)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"arrow")}catch(e){this.loggingService.catch("Error in ArrowService deleteArrowPinAnnotations: ",e)}}deleteArrowPinAnnotation(t){return this.authService.isFeatureAllowed(H.ARROW)&&this.documentPaths?.arrow&&t?.annotationId?(this.updateNotificationsDatabase(t,Et.DELETED),this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DELETED,{annotationId:t.annotationId}),this.commonDbService.deleteData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0}})):Promise.resolve()}enableAddArrowMode(){this.authService.isFeatureAllowed(H.ARROW)?(this.analyticsService.trackEvent(_.Events.Arrow.ARROW_ADD_MODE_ENABLED),this.addArrowMode$.next(!0)):this.loggingService.catch("Error in ArrowService enableAddArrowMode: ","Arrow feature is not enabled.")}disableAddArrowMode(){this.analyticsService.trackEvent(_.Events.Arrow.ARROW_ADD_MODE_DISABLED),this.addArrowMode$.next(!1)}addArrowModeChange(){return this.addArrowMode$.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 ArrowService isElementInsideAllowedElements: ",e),!1}}updateNotificationsDatabase(t,e){try{let r={annotationData:t,actionType:e,notificationSource:"arrow"};this.serviceBook.get(se)?.updateNotificationDatabase(r)}catch(r){this.loggingService.catch("Error in ArrowService updateNotificationsDatabase: ",r)}}getArrowUrl(t){try{return t?.pageInfo?.arrowUrl?t.pageInfo.arrowUrl:(t?.pageInfo||(t.pageInfo=yt(),t.pageInfo&&(t.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),t.pageInfo.arrowUrl=this.generateArrowUrl(t),this.updateArrow(t),t.pageInfo?.arrowUrl)}catch(e){this.loggingService.catch("Error in ArrowService getArrowUrl: ",e);return}}generateArrowUrl(t){let e;try{e=new URL(t?.pageInfo?.url||window.location.href)}catch(r){this.loggingService.catch("Error in ArrowService generateArrowUrl: ",r),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}};s.\u0275fac=function(e){return new(e||s)(v(x),v(ce),v(he),v(le),v(V),v(D),v(Qt),v(ut),v(qt),v(A),v(mt),v(de))},s.\u0275prov=j({token:s,factory:s.\u0275fac,providedIn:"root"});let l=s;return l})();var Ce=["handle"],ye=["arrowRef"],be=["headRef"],Ie=l=>({transform:l});function _e(l,s){if(l&1){let c=G();W(0,"div",8,2),U("cdkDragStarted",function(e){E(c);let r=b();return C(r.onDragStarted(e))})("cdkDragMoved",function(e){E(c);let r=b();return C(r.onDragMoved(e))})("cdkDragReleased",function(e){E(c);let r=b();return C(r.onDragReleased(e))}),et(),W(2,"svg",9),st(3,"path",10)(4,"path",11),z()()}if(l&2){let c=b();N("s-arrow-annotation-handle-dragging",c.isResizing),R("cdkDragRootElement","arrow-pin-container-"+(c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId))("cdkDragDisabled",!c.isEditable||c.isResizing)}}function De(l,s){if(l&1){let c=G();W(0,"div",12,2),U("cdkDragStarted",function(){E(c);let e=b();return C(e.onResizeHandleDragStarted())})("cdkDragMoved",function(e){E(c);let r=b();return C(r.onResizeHandleDragMoved(e))})("cdkDragReleased",function(){E(c);let e=b();return C(e.onResizeHandleDragReleased())}),et(),W(2,"svg",13),st(3,"path",14),z()()}if(l&2){let c=b();N("s-arrow-annotation-handle-dragging",c.isResizing)}}var ve=(()=>{let s=class s{get arrowPinAnnotation(){return this._arrowPinAnnotation}set arrowPinAnnotation(t){this._arrowPinAnnotation=t,this.updatedArrowAngle&&this.arrowPinAnnotation?.props&&(this.arrowPinAnnotation.props.arrowAngle=this.updatedArrowAngle),this.calculateArrowWidthBasedOnViewport()}get arrowPinSelected(){return this._arrowPinSelected}set arrowPinSelected(t){this._arrowPinSelected=t,this.updateHighlightOnElement()}get arrowPinHover(){return this._arrowPinHover}set arrowPinHover(t){this._arrowPinHover=t,this.updateHighlightOnElement()}constructor(t,e,r,i){this.arrowService=t,this.domService=e,this.loggingService=r,this.elementRef=i,this._arrowPinSelected=!1,this.multipleArrowPinsSelected=!1,this.dragStarted=new at,this.dragMoved=new at,this.dragReleased=new at,this._arrowPinHover=!1,this.subscriptions=[],this.veltElement=!0,this.isDragging=!1,this.isResizing=!1,this.isEditable=!1,this.centerX=0,this.centerY=0,this.newAngle=0,this.newWidth=0,this.updatedArrowAngle=0,this.MIN_ARROW_LENGTH=d.VELT_MIN_ARROW_LENGTH,this.pointerEventSubscriptions=[],this.loggingService.log("%c[WB] Creating COMPONENT ArrowPinComponent","color: blue;")}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{this.updateHighlightOnElement(),setTimeout(()=>{this.calculateArrowWidthBasedOnViewport()},100)}catch(t){this.loggingService.catch("Error in ArrowPinComponent AfterViewInit: ",t)}}ngOnChanges(t){try{t.arrowPinAnnotation&&this.checkIsEditable(),t.user&&this.checkIsEditable()}catch(e){this.loggingService.catch("Error in ArrowPinComponent ngOnChanges: ",e)}}checkIsEditable(){try{this.user?.userId===this.arrowPinAnnotation?.from?.userId?this.isEditable=!0:this.user&&!this.user.isAnonymous&&!this.user.isGuest?this.isEditable=!0:this.isEditable=!1}catch(t){this.loggingService.catch("Error in ArrowPinComponent checkIsEditable: ",t)}}onResizeHandleDragStarted(){try{this.isResizing||(this.updatedArrowAngle=0,this.updateCenter(),this.isResizing=!0)}catch(t){this.loggingService.catch("Error in ArrowPinComponent onResizeHandleDragStarted: ",t)}}onResizeHandleDragMoved(t){try{let e=t.event;if(!this.isResizing||!this.isWithinViewport(e))return;let r=this.getAngleAndDistanceFromMouseEvent(e);this.newAngle=r.angle,this.newWidth=Math.min(r.distance,this.getMaxAllowedArrowLength()),e.stopPropagation()}catch(e){this.loggingService.catch("Error in ArrowPinComponent onResizeHandleDragMoved: ",e)}}onResizeHandleDragReleased(){try{this.isResizing=!1,this.updateArrowPinAnnotationProps(),setTimeout(()=>{this.newAngle=0,this.newWidth=0},100)}catch(t){this.loggingService.catch("Error in ArrowPinComponent onResizeHandleDragReleased: ",t)}}updateCenter(){try{let t=this.elementRef.nativeElement.getBoundingClientRect();this.centerX=t.x,this.centerY=t.y}catch(t){this.loggingService.catch("Error in ArrowPinComponent updateCenter: ",t)}}getAngleAndDistanceFromMouseEvent(t){try{let e=t instanceof MouseEvent?t.clientX:t.touches[0].clientX,r=t instanceof MouseEvent?t.clientY:t.touches[0].clientY,i=e-this.centerX,n=r-this.centerY,a=Math.atan2(n,i)*(180/Math.PI);a=a<0?a+360:a;let m=Math.sqrt(i*i+n*n);return{angle:a,distance:m}}catch(e){return this.loggingService.catch("Error in ArrowPinComponent getAngleAndDistanceFromMouseEvent: ",e),{angle:0,distance:0}}}isWithinViewport(t){try{return typeof TouchEvent<"u"&&t instanceof TouchEvent?t.touches[0].clientX>=0&&t.touches[0].clientX<=window?.innerWidth&&t.touches[0].clientY>=0&&t.touches[0].clientY<=window?.innerHeight:t.clientX>=0&&t.clientX<=window?.innerWidth&&t.clientY>=0&&t.clientY<=window?.innerHeight}catch(e){return this.loggingService.catch("Error in ArrowPinComponent isWithinViewport: ",e),!1}}calculateArrowWidthBasedOnViewport(){try{if(this.isDragging)return;if(this.arrowPinAnnotation?.props){let t=this.arrowPinAnnotation.props.viewportWidth||0,e=this.arrowPinAnnotation.props.viewportHeight||0,r=window.innerWidth,i=window.innerHeight;this.arrowPinAnnotation.props.arrowLength||(this.arrowPinAnnotation.props.arrowLength=0);let n=(this.arrowPinAnnotation.props.arrowAngle||0)%360;n>45&&n<135||n>225&&n<315?e>0&&(this.arrowPinAnnotation.props.arrowLength=this.arrowPinAnnotation.props.arrowLength*i/e):t>0&&(this.arrowPinAnnotation.props.arrowLength=this.arrowPinAnnotation.props.arrowLength*r/t);let o=this.arrowRef?.nativeElement?.getBoundingClientRect();if(o){n<0&&(n=360+n);let a=n,m=n>90&&n<=180,h=n>180&&n<=270,u=r-o.x;(m||h)&&(u=o.right,a=180-n);let T=ht(u-d.VELT_ARROW_VIEWPORT_PADDING,a);if(T>0&&this.arrowPinAnnotation.props.arrowLength>T)if(T<this.MIN_ARROW_LENGTH){let L=(this.arrowPinAnnotation.props.arrowAngle||0)%360;L>=90&&L<=270?this.updatedArrowAngle=45:this.updatedArrowAngle=135,this.arrowPinAnnotation.props.arrowLength=this.MIN_ARROW_LENGTH}else this.arrowPinAnnotation.props.arrowLength=T}this.arrowPinAnnotation.props.arrowLength=Math.min(this.arrowPinAnnotation.props.arrowLength,this.getMaxAllowedArrowLength())}}catch(t){this.loggingService.catch("Error in ArrowPinComponent calculateArrowWidthBasedOnViewport: ",t)}}getMaxAllowedArrowLength(){try{return Math.max(window.innerWidth,window.innerHeight)*.8}catch(t){return this.loggingService.catch("Error in ArrowPinComponent getMaxAllowedArrowLength: ",t),0}}updateHighlightOnElement(){try{this.targetElement&&(this.arrowPinSelected||this.arrowPinHover?this.domService.highlightElement(this.targetElement):this.domService.removeHighlightFromElement(this.targetElement))}catch(t){this.loggingService.catch("Error in ArrowPinComponent updateHighlightOnElement: ",t)}}updateArrowPinAnnotationProps(){try{this.arrowPinAnnotation?.props||(this.arrowPinAnnotation.props=new gt),this.arrowPinAnnotation.props.viewportWidth=window.innerWidth,this.arrowPinAnnotation.props.viewportHeight=window.innerHeight,this.arrowPinAnnotation.props.arrowAngle=this.newAngle,this.arrowPinAnnotation.props.arrowLength=this.newWidth,this.arrowService.updateArrow(this.arrowPinAnnotation)}catch(t){this.loggingService.catch("Error in ArrowPinComponent updateArrowPinAnnotation: ",t)}}onPointerOver(t){try{t.buttons?this.arrowPinHover&&(this.arrowPinHover=!1):this.arrowPinHover||(this.arrowPinHover=!0)}catch(e){this.loggingService.catch("Error in ArrowPinComponent onPointerOver: ",e)}}onDragStarted(t){this.isDragging=!0,this.dragStarted.emit(t)}onDragMoved(t){this.dragMoved.emit(t)}onDragReleased(t){this.isDragging=!1,this.dragReleased.emit(t)}onPointerOut(){this.arrowPinHover=!1}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowPinComponent 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 ArrowPinComponent unsubscribe: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(M),p(D),p(A),p(ot))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrow-pin"]],viewQuery:function(e,r){if(e&1&&(X(Ce,5),X(ye,5),X(be,5)),e&2){let i;Y(i=J())&&(r.handle=i.first),Y(i=J())&&(r.arrowRef=i.first),Y(i=J())&&(r.headRef=i.first)}},hostVars:1,hostBindings:function(e,r){e&2&&B("data-velt-element",r.veltElement)},inputs:{arrowPinAnnotation:"arrowPinAnnotation",arrowPinSelected:"arrowPinSelected",multipleArrowPinsSelected:"multipleArrowPinsSelected",user:"user",targetElement:"targetElement"},outputs:{dragStarted:"dragStarted",dragMoved:"dragMoved",dragReleased:"dragReleased"},features:[Lt],decls:7,vars:15,consts:[["arrowRef",""],["headRef",""],["handle",""],[1,"s-arrow-annotation",3,"pointerover","pointerout","click","ngStyle"],["class","s-arrow-annotation-drag-handle","cdkDrag","","cdkDragHandle","",3,"s-arrow-annotation-handle-dragging","cdkDragRootElement","cdkDragDisabled","cdkDragStarted","cdkDragMoved","cdkDragReleased",4,"ngIf"],[1,"s-arrow-annotation-head"],[1,"s-arrow-annotation-line"],["class","s-arrow-annotation-handle","cdkDrag","",3,"s-arrow-annotation-handle-dragging","cdkDragStarted","cdkDragMoved","cdkDragReleased",4,"ngIf"],["cdkDrag","","cdkDragHandle","",1,"s-arrow-annotation-drag-handle",3,"cdkDragStarted","cdkDragMoved","cdkDragReleased","cdkDragRootElement","cdkDragDisabled"],["width","32","height","32","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M18.0039 5.99219H14.4039M18.0039 5.99219V9.59219M18.0039 5.99219L13.8039 10.1922M6.00391 17.9922H9.60391M6.00391 17.9922V14.3922M6.00391 17.9922L10.2039 13.7922","stroke","#0093FF","stroke-width","1.2","stroke-linecap","round","stroke-linejoin","round"],["d","M6 5.99219H9.6M6 5.99219V9.59219M6 5.99219L10.2 10.1922M18 17.9922H14.4M18 17.9922V14.3922M18 17.9922L13.8 13.7922","stroke","#0093FF","stroke-width","1.2","stroke-linecap","round","stroke-linejoin","round"],["cdkDrag","",1,"s-arrow-annotation-handle",3,"cdkDragStarted","cdkDragMoved","cdkDragReleased"],["width","16","height","16","viewBox","0 0 10 10","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M1 5C1 3.11438 1 2.17157 1.58579 1.58579C2.17157 1 3.11438 1 5 1C6.88562 1 7.82843 1 8.41421 1.58579C9 2.17157 9 3.11438 9 5C9 6.88562 9 7.82843 8.41421 8.41421C7.82843 9 6.88562 9 5 9C3.11438 9 2.17157 9 1.58579 8.41421C1 7.82843 1 6.88562 1 5Z","stroke","#0093FF","stroke-width","1.5"]],template:function(e,r){if(e&1){let i=G();W(0,"div",3,0),U("pointerover",function(o){return E(i),C(r.onPointerOver(o))})("pointerout",function(){return E(i),C(r.onPointerOut())})("click",function(o){return E(i),C(o.preventDefault())}),$(2,_e,5,4,"div",4),st(3,"div",5,1)(5,"div",6),$(6,De,4,2,"div",7),z()}e&2&&(K("width",r.newWidth||(r.arrowPinAnnotation==null||r.arrowPinAnnotation.props==null?null:r.arrowPinAnnotation.props.arrowLength)||r.MIN_ARROW_LENGTH,"px"),N("s-arrow-annotation-selected",r.arrowPinSelected)("s-arrow-annotation-draggable",r.isEditable),R("ngStyle",jt(13,Ie,"rotate("+(r.newAngle||r.updatedArrowAngle||(r.arrowPinAnnotation==null||r.arrowPinAnnotation.props==null?null:r.arrowPinAnnotation.props.arrowAngle)||0)+"deg)")),O(2),R("ngIf",r.isEditable),O(),K("border-right-color",((r.arrowPinAnnotation==null||r.arrowPinAnnotation.from==null?null:r.arrowPinAnnotation.from.color)||(r.arrowPinAnnotation==null?null:r.arrowPinAnnotation.color))+" !important"),O(2),K("background-color",((r.arrowPinAnnotation==null||r.arrowPinAnnotation.from==null?null:r.arrowPinAnnotation.from.color)||(r.arrowPinAnnotation==null?null:r.arrowPinAnnotation.color))+" !important"),O(),R("ngIf",r.isEditable))},dependencies:[lt,ct,$t,Xt,Gt,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}.s-arrow-annotation[_ngcontent-%COMP%]{position:absolute!important;z-index:20!important;height:calc((.4rem + 0px) * var(--velt-base-rem-unit))!important;transform-origin:0 100%!important;left:50%!important;top:50%!important;display:flex!important;align-items:center!important;justify-content:flex-end!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-line[_ngcontent-%COMP%]{height:calc((.4rem + 0px) * var(--velt-base-rem-unit))!important;transform-origin:0 100%!important;width:100%!important;background-color:#625df5!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-head[_ngcontent-%COMP%]{width:0!important;height:0!important;border-top:calc((1.1rem + 0px) * var(--velt-base-rem-unit)) solid transparent!important;border-bottom:calc((1.1rem + 0px) * var(--velt-base-rem-unit)) solid transparent!important;border-right:calc((1.1rem + 0px) * var(--velt-base-rem-unit)) solid #625DF5!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-drag-handle[_ngcontent-%COMP%]{transform:none!important;cursor:move!important;display:flex!important;position:absolute!important;left:-20px!important;opacity:0!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-handle[_ngcontent-%COMP%]{transform:none!important;display:flex!important;opacity:0!important;cursor:grab!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-handle[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;height:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-handle.s-arrow-annotation-handle-dragging[_ngcontent-%COMP%]{cursor:grabbing!important}.s-arrow-annotation[_ngcontent-%COMP%]:hover .s-arrow-annotation-drag-handle[_ngcontent-%COMP%], .s-arrow-annotation.s-arrow-annotation-selected[_ngcontent-%COMP%] .s-arrow-annotation-drag-handle[_ngcontent-%COMP%], .s-arrow-annotation[_ngcontent-%COMP%]:hover .s-arrow-annotation-handle[_ngcontent-%COMP%], .s-arrow-annotation.s-arrow-annotation-selected[_ngcontent-%COMP%] .s-arrow-annotation-handle[_ngcontent-%COMP%]{opacity:1!important}"],changeDetection:0});let l=s;return l})();var Te=["arrowPinRef"];function Oe(l,s){if(l&1){let c=G();W(0,"div",3),U("pointerup",function(e){return E(c),b(2).togglePinSelection(),C(e.stopPropagation())})("pointerdown",function(e){return E(c),C(e.stopPropagation())})("click",function(e){return E(c),C(e.stopPropagation())}),W(1,"snippyly-arrow-pin",4,0),U("dragStarted",function(){E(c);let e=b(2);return C(e.onPinDragStart())})("dragMoved",function(e){E(c);let r=b(2);return C(r.onPinMove(e))})("dragReleased",function(){E(c);let e=b(2);return C(e.onPinRelease())}),z()()}if(l&2){let c=b().ngIf,t=b();K("top",c.annotationDragging?c.dragPosition==null?null:c.dragPosition.top:(c.arrowPinAnnotation==null||c.arrowPinAnnotation.position==null?null:c.arrowPinAnnotation.position.top)+c.offsetTop,"px")("left",c.annotationDragging?c.dragPosition==null?null:c.dragPosition.left:(c.arrowPinAnnotation==null||c.arrowPinAnnotation.position==null?null:c.arrowPinAnnotation.position.left)+c.offsetLeft,"px"),N("pin-dragging",c.annotationDragging),R("id","arrow-pin-container-"+(c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId)),O(),R("arrowPinAnnotation",c.arrowPinAnnotation)("arrowPinSelected",c.selectedAnnotationsMap[c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId]&&!c.annotationDragging&&t.objectKeys(c.selectedAnnotationsMap).length===1)("multipleArrowPinsSelected",c.selectedAnnotationsMap[c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId]&&t.objectKeys(c.selectedAnnotationsMap).length>1)("targetElement",c.targetElement)("user",c.user)}}function Re(l,s){if(l&1&&(xt(0),$(1,Oe,3,12,"div",2),Vt()),l&2){let c=s.ngIf;O(),R("ngIf",c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.position)}}var fe=(()=>{let s=class s{constructor(t,e,r,i,n){this.analyticsService=t,this.authService=e,this.domService=r,this.arrowService=i,this.loggingService=n,this.multipleArrowPinsSelected=!1,this.avatarErrorImage="",this.objectKeys=Object.keys,this.subscriptions=[],this.componentConfigSignal=Mt({arrowPinAnnotation:void 0,annotationDragging:!1,dragPosition:null,offsetTop:0,offsetLeft:0,selectedAnnotationsMap:{},targetElement:void 0,user:void 0}),this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(o=>{this.componentConfigSignal.update(a=>(a=y(w({},a),{user:o}),a))},o=>{this.loggingService.catch("Error in ArrowPinPortalComponent getUser$ subscription: ",o)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(o=>{this.componentConfigSignal.update(a=>(a=y(w({},a),{selectedAnnotationsMap:o}),a))},o=>{this.loggingService.catch("Error in ArrowPinPortalComponent getSelectedAnnotationsMap$ subscription: ",o)}))}ngOnInit(){}setArrowPinAnnotation(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{arrowPinAnnotation:t}),e)),this.id=this.componentConfigSignal().arrowPinAnnotation?.annotationId}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setArrowPinAnnotation: ",e)}}setTargetElement(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{targetElement:t}),e))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setTargetElement: ",e)}}setOffsetLeft(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{offsetLeft:t}),e))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setOffsetLeft: ",e)}}setOffsetTop(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{offsetTop:t}),e))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setOffsetTop: ",e)}}togglePinSelection(){try{this.domService.toggleAnnotationSelection(this.componentConfigSignal().arrowPinAnnotation)}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent togglePinSelection: ",t)}}onPinDragStart(){this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().arrowPinAnnotation.annotationId]&&this.domService.toggleAnnotationSelection(this.componentConfigSignal().arrowPinAnnotation);let t=document.getElementById(this.componentConfigSignal().arrowPinAnnotation.annotationId);t&&(this.parentElement=t.parentElement,t.style.opacity="0",document.body.appendChild(t)),this.componentConfigSignal.update(e=>(e=y(w({},e),{annotationDragging:!0}),e)),setTimeout(()=>{t&&(t.style.opacity="1")},50)}onPinMove(t){try{this.updateCurrentPinPosition(t)}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent onPinMove: ",e)}}updateCurrentPinPosition(t){try{this.domService.removeHighlightFromElement(this.componentConfigSignal().targetElement);let e=t.event,r=e?.touches?.length?e.touches[0]?.clientX:e.clientX,i=e?.touches?.length?e.touches[0]?.clientY:e.clientY,n=this.domService.getBackgroundElement(r,i);n&&(this.componentConfigSignal.update(o=>(o=y(w({},o),{targetElement:n}),o)),this.domService.highlightElement(this.componentConfigSignal().targetElement),this.pointerMoveEvent=t.event,this.componentConfigSignal.update(o=>(o=y(w({},o),{dragPosition:{top:i,left:r}}),o)))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent updateCurrentPinPosition: ",e)}}onPinRelease(){try{let t=document.getElementById(this.componentConfigSignal().arrowPinAnnotation.annotationId);t&&this.parentElement&&this.parentElement.appendChild(t);let e=this.domService.getElementFromXPath(this.componentConfigSignal().arrowPinAnnotation.targetElement?.xpath);if(this.pointerMoveEvent){this.componentConfigSignal.update(h=>(h=w({},h),h.arrowPinAnnotation.targetElement=this.domService.getTargetElementForCursorPosition(this.pointerMoveEvent),h));let n=this.pointerMoveEvent,o=n?.touches?.length?n.touches[0]?.clientX:n.clientX,a=!1;if(o<d.VELT_MIN_ARROW_LENGTH){let h=this.componentConfigSignal().arrowPinAnnotation.props.arrowAngle||0;h>=90&&h<=270&&(this.componentConfigSignal.update(u=>(u=w({},u),u.arrowPinAnnotation.props.arrowAngle=45,u)),a=!0)}if(o>window?.innerWidth-d.VELT_MIN_ARROW_LENGTH){let h=this.componentConfigSignal().arrowPinAnnotation.props.arrowAngle||0;(h>=270&&h<=360||h>=0&&h<=90)&&(this.componentConfigSignal.update(u=>(u=w({},u),u.arrowPinAnnotation.props.arrowAngle=135,u)),a=!0)}if(!a){let h=o,u=this.componentConfigSignal().arrowPinAnnotation.props.arrowAngle||0;u>=0&&u<=90||u>=270&&u<=360?h=window.innerWidth-o:u=180-u;let T=ht(h-d.VELT_ARROW_VIEWPORT_PADDING,u);T>0&&T<(this.componentConfigSignal().arrowPinAnnotation.props.arrowLength||0)&&this.componentConfigSignal.update(L=>(L=w({},L),L.arrowPinAnnotation.props.arrowLength=T,L))}let m=this.domService.getCurrentWindowSizeValue();this.componentConfigSignal.update(h=>(h=w({},h),h.arrowPinAnnotation.props.screenWidth=m.screenWidth,h.arrowPinAnnotation.props.screenHeight=m.screenHeight,h.arrowPinAnnotation.props.screenScrollHeight=m.screenScrollHeight,h.arrowPinAnnotation.props.viewportWidth=window.innerWidth,h.arrowPinAnnotation.props.viewportHeight=window.innerHeight,h))}let r=this.domService.getElementFromXPath(this.componentConfigSignal().arrowPinAnnotation.targetElement?.xpath),i=this.domService.isElementInsideAdditionalLocationContainer(e)||this.domService.isElementInsideAdditionalLocationContainer(r);this.arrowService.updateArrow(this.componentConfigSignal().arrowPinAnnotation,!1,i),setTimeout(()=>{this.componentConfigSignal.update(n=>(n=w({},n),n.annotationDragging=!1,n.dragPosition=null,n)),this.domService.removeHighlightFromElement(this.componentConfigSignal().targetElement),this.arrowPinRef&&(this.arrowPinRef.updatedArrowAngle=0)},100),this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DRAGGED,{annotationId:this.componentConfigSignal().arrowPinAnnotation.annotationId})}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent onPinRelease: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent 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 ArrowPinPortalComponent unsubscribe: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(x),p(V),p(D),p(M),p(A))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrow-pin-portal"]],viewQuery:function(e,r){if(e&1&&X(Te,5),e&2){let i;Y(i=J())&&(r.arrowPinRef=i.first)}},hostVars:2,hostBindings:function(e,r){e&2&&(Ft("id",r.id),B("data-velt-element",r.veltElement))},inputs:{multipleArrowPinsSelected:"multipleArrowPinsSelected",avatarErrorImage:"avatarErrorImage"},decls:1,vars:1,consts:[["arrowPinRef",""],[4,"ngIf"],["class","arrow-pin-portal",3,"id","pin-dragging","top","left","pointerup","pointerdown","click",4,"ngIf"],[1,"arrow-pin-portal",3,"pointerup","pointerdown","click","id"],[3,"dragStarted","dragMoved","dragReleased","arrowPinAnnotation","arrowPinSelected","multipleArrowPinsSelected","targetElement","user"]],template:function(e,r){e&1&&$(0,Re,2,1,"ng-container",1),e&2&&R("ngIf",r.componentConfigSignal())},dependencies:[lt,ct,ve],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}.arrow-pin-portal[_ngcontent-%COMP%]{position:absolute;transform:none!important;top:0;left:0}.arrow-pin-portal.pin-dragging[_ngcontent-%COMP%]{position:fixed;z-index:var(--velt-arrow-z-index)!important}"],changeDetection:0});let l=s;return l})();var Ae=(()=>{let s=class s{constructor(t,e,r,i,n){this.domService=t,this.componentFactoryResolver=e,this.injector=r,this.appRef=i,this.loggingService=n,this.arrowsPinById={}}setArrowPin(t){try{if(!this.arrowsPinById[t.annotationId])this.setPinPortal(t);else if(t.targetElement?.xpath===this.arrowsPinById[t.annotationId]?.annotation?.targetElement?.xpath){let e=this.arrowsPinById[t.annotationId].portalRef,r=this.arrowsPinById[t.annotationId].userTargetElement,i=this.arrowsPinById[t.annotationId].pinHostElement;if(document.body.contains(r)&&document.body.contains(i))e&&(e.instance.setArrowPinAnnotation(JSON.parse(JSON.stringify(t))),this.updateElementOffset(t));else{let n=this.arrowsPinById[t.annotationId].pinHostDomPortalOutlet;n&&(this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST),this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC),n.detach(),delete this.arrowsPinById[t.annotationId],this.setPinPortal(t))}}else{let e=this.arrowsPinById[t.annotationId].pinHostDomPortalOutlet;e&&(this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST),this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC),e.detach(),delete this.arrowsPinById[t.annotationId],this.setPinPortal(t))}}catch(e){this.loggingService.catch("Error in ArrowPinPortalService setArrowPin: ",e)}}setPinPortal(t){try{let e=this.domService.getXPath(t.targetElement?.xpath);if(e){let r=e.iterateNext();if(r){let i=this.domService.getHostElement(r),n=new Yt(fe),o=new Jt(i,this.appRef,this.injector),a=o.attach(n);a.instance.setArrowPinAnnotation(JSON.parse(JSON.stringify(t))),a.instance.setTargetElement(r),this.arrowsPinById[t.annotationId]={pinHostDomPortalOutlet:o,pinPortal:n,portalRef:a,annotation:JSON.parse(JSON.stringify(t)),userTargetElement:r,pinHostElement:i},i.setAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST,t.annotationId),window.getComputedStyle(i).position==="static"&&(ne(i)||i.setAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC,"true")),this.updateElementOffset(t)}}}catch(e){this.loggingService.catch("Error in ArrowPinPortalService setPinPortal: ",e)}}updateElementOffset(t){try{let{portalRef:e,userTargetElement:r,pinHostElement:i}=this.arrowsPinById[t.annotationId],n=this.domService.getElementOffset(r,i);e.instance.setOffsetLeft(n.offsetLeft),e.instance.setOffsetTop(n.offsetTop)}catch(e){this.loggingService.catch("Error in ArrowPinPortalService updateElementOffset: ",e)}}checkPinsToRemove(t){try{let e=t.map(r=>r.annotationId);Object.keys(this.arrowsPinById).forEach(r=>{if(!e.includes(r)){let i=this.arrowsPinById[r];i.pinHostDomPortalOutlet.detach(),i.pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST),i.pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC),this.domService.removeHighlightFromElement(i.pinHostElement),delete this.arrowsPinById[r]}})}catch(e){this.loggingService.catch("Error in ArrowPinPortalService checkPinsToRemove: ",e)}}};s.\u0275fac=function(e){return new(e||s)(v(D),v(Wt),v(Rt),v(Bt),v(A))},s.\u0275prov=j({token:s,factory:s.\u0275fac,providedIn:"root"});let l=s;return l})();var Dt=(()=>{let s=class s{constructor(t,e,r,i,n,o){this.analyticsService=t,this.authService=e,this.domService=r,this.arrowService=i,this.arrowPinPortalService=n,this.loggingService=o,this.arrowPinAnnotations=[],this.subscriptions=[],this.isFirstComponent=!0,this.veltId=ee(),this.veltElement=!0;try{this.loggingService.log("%c[WB] Creating CLASS: ArrowsContainerComponent","color: blue;")}catch(a){this.loggingService.catch("Error in ArrowsContainerComponent constructor: ",a)}}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{let t=document.querySelector(d.TAGS.SNIPPYLY_ARROWS),e=document.querySelector(d.TAGS.VELT_ARROWS);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 ArrowsContainerComponent AfterViewInit: ",t)}}initComponent(){try{this.subscriptions.push(this.authService.getUser$().pipe(I(t=>!!t)).subscribe(t=>{t&&this.setArrowInstalledInAnalytics()},t=>{this.loggingService.catch("Error in getUser: ",t)})),this.getAllArrowsOnCurrentDocument()}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent initComponent: ",t)}}getAllArrowsOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowsOnCurrentDocument","color: green;");try{this.subscriptions.push(this.arrowService.getAllArrowAnnotations().pipe(I(t=>!!t),f(t=>this.domService.getSelectedAnnotationsMap$().pipe(S(e=>({annotations:t,selectedAnnotationsMap:e||{}}))))).subscribe(t=>{try{this.loggingService.log(t),this.arrowPinAnnotations=t?.annotations;let e=this.arrowPinAnnotations.filter(r=>r.targetElement);this.arrowPinPortalService.checkPinsToRemove(e),e.forEach(r=>{this.arrowPinPortalService.setArrowPin(r)})}catch(e){this.loggingService.catch("Error in ArrowsContainerComponent getAllArrowsOnCurrentDocument inside subscription: ",e)}},t=>{this.loggingService.catch("Error in ArrowsContainerComponent getAllArrowsOnCurrentDocument subscription: ",t)}))}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent getAllArrowsOnCurrentDocument: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent 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 ArrowsContainerComponent unsubscribe: ",t)}}setArrowInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(H.ARROW)}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent setArrowInstalledInAnalytics: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(x),p(V),p(D),p(M),p(Ae),p(A))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrows-container"]],hostVars:2,hostBindings:function(e,r){e&2&&B("data-velt-id",r.veltId)("data-velt-element",r.veltElement)},decls:0,vars:0,template:function(e,r){},encapsulation:2,changeDetection:0});let l=s;return l})();var Tt=(()=>{let s=class s extends pe{constructor(t,e,r,i,n,o,a,m,h){super(a,o,void 0,void 0,void 0,m,n),this.analyticsService=t,this.authService=e,this.arrowService=r,this.iamService=i,this.loggingService=n,this.themeService=o,this.elementRef=a,this.dynamicDataService=m,this.domService=h,this.customButtonAdded=!1,this.disabled=!1,this.addArrowMode=!1,this.subscriptions=[],this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(u=>{this.user=u},u=>{this.loggingService.catch("Error in ArrowsToolComponent getUser$ subscription: ",u)}))}ngAfterViewInit(){try{this.subscriptions.push(this.domService.subscribeInjectCustomCss(this.elementRef)),this.subscriptions.push(this.arrowService.addArrowModeChange().subscribe(t=>{this.addArrowMode=t})),this.subscriptions.push(this.iamService.getFeaturesAccessLevel$().subscribe(t=>{this.disabled=!!t?.all?.disabled}))}catch(t){this.loggingService.catch("Error in ArrowsToolComponent AfterViewInit: ",t)}}onButtonSlotChange(){this.customButtonAdded=!0}addArrow(){this.loggingService.log("%c[WB] Calling FUNCTION: addArrow","color: green;");try{if(this.analyticsService.trackEvent(_.Events.Arrow.ARROW_TOOL_CLICKED,{toolType:this.customButtonAdded?"custom":"default"}),this.user){if(this.disabled){this.loggingService.catch("Arrows are disabled.");return}this.user.isReadOnly||this.user.isAnonymous?this.loggingService.catch("Anonymous/Readonly users cannot add arrows."):!this.authService.isPlanExpired()&&this.iamService.getRole()?this.arrowService.enableAddArrowMode():this.loggingService.catch("User does not have permission to add arrows.")}else this.loggingService.catch("Velt sdk not authenticated.")}catch(t){this.loggingService.catch("Error in ArrowsToolComponent addArrow: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{super.ngOnDestroy(),this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowsToolComponent 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 ArrowsToolComponent unsubscribe: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(x),p(V),p(M),p(ut),p(A),p(me),p(ot),p(pt),p(D))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrows-tool"]],hostVars:1,hostBindings:function(e,r){e&2&&B("data-velt-element",r.veltElement)},features:[Ut([pt]),kt],decls:5,vars:2,consts:[["part","container",1,"snippyly-arrow-btn-container",3,"click"],["name","button",3,"slotchange"],["part","button-container","tabindex","0",1,"action-btn"],["part","button-icon","width","24","height","24","viewBox","0 0 25 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon"],["d","M17.5 7L7.5 17M17.5 7H10M17.5 7V14.5","stroke","currentColor","stroke-width","1.5","stroke-linecap","round","stroke-linejoin","round"]],template:function(e,r){e&1&&(rt(0,"div",0),Pt("click",function(n){return r.addArrow(),n.stopPropagation()}),rt(1,"slot",1),Pt("slotchange",function(){return r.onButtonSlotChange()}),rt(2,"div",2),et(),rt(3,"svg",3),Ht(4,"path",4),Nt()()()()),e&2&&(O(2),N("active",r.addArrowMode))},styles:[`html{--velt-base-rem-unit: 1}*[data-snippyly-element=true],*[data-velt-element=true]{font-family:var(--velt-default-font-family)}velt-wireframe{display:none!important}body.velt-pin-dragging iframe{pointer-events:none!important}*{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;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*:empty{display:revert!important}.snippyly-arrow-btn-container{display:inline-block}.action-btn{display:flex;justify-content:center;align-items:center;padding:6px!important;border-radius:var(--legacy-velt-tool-border-radius);border:var(--legacy-velt-tool-border);background-color:var(--legacy-velt-tool-bg-color)}.action-btn .action-btn-icon{width:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-icon-color);cursor:pointer}.action-btn:focus{border-radius:var(--legacy-velt-tool-focus-border-radius);border:var(--legacy-velt-tool-focus-border);background-color:var(--legacy-velt-tool-focus-bg-color)}.action-btn:focus .action-btn-icon{width:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-focus-icon-color)}.action-btn:hover{border-radius:var(--legacy-velt-tool-hover-border-radius);border:var(--legacy-velt-tool-hover-border);background-color:var(--legacy-velt-tool-hover-bg-color)}.action-btn:hover .action-btn-icon{width:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-hover-icon-color)}.action-btn:active,.action-btn.active{border-radius:var(--legacy-velt-tool-active-border-radius);border:var(--legacy-velt-tool-active-border);background-color:var(--legacy-velt-tool-active-bg-color)}.action-btn:active .action-btn-icon,.action-btn.active .action-btn-icon{width:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-active-icon-color)}
|
|
2
2
|
`],encapsulation:3,changeDetection:0});let l=s;return l})();var vt=class extends we{constructor(s){super(s),this.getService(A).log("%c[WB] Creating CLASS: ArrowElement","color: blue;"),this.allowedElementIds=this._allowedElementIds}_allowedElementIds(s){this.getService(A).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(_.Events.Arrow.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:s}}),this.getService(M).setAllowedElementIds(s)}catch(c){this.getService(A).catch("Error in allowedElementIds: ",c)}}};var Se=(()=>{let s=class s{constructor(t,e){this.loggingService=t,this.usersService=e}getUserIdsToResolveFromArrowAnnotations(t){try{this.loggingService.log("%c[WB] Calling ArrowUtilsService FUNCTION: getUserIdsToResolveFromArrowAnnotations","color: green;");let e=new Set;for(let r of t)r?.from?.userId&&e.add(r?.from?.userId);return Array.from(e)}catch(e){return this.loggingService.catch("Error in ArrowUtilsService getUserIdsToResolveFromArrowAnnotations:",e),[]}}mergeArrowWithUser(t){try{if(this.loggingService.log("%c[WB] Calling ArrowUtilsService FUNCTION: mergeArrowWithUser","color: green;"),t?.from?.userId){let e=this.usersService.getUserById(t?.from?.userId);e&&(t.from=e)}return t}catch(e){return this.loggingService.catch("Error in ArrowUtilsService mergeArrowWithUser:",e),t}}formatArrowData(t){try{return this.loggingService.log("%c[WB] Calling ArrowUtilsService FUNCTION: formatArrowData","color: green;"),this.usersService.userDataProviderAvailable()&&t?.from?.userId&&(t.from={userId:t.from.userId}),t}catch(e){return this.loggingService.catch("Error in ArrowUtilsService formatArrowData:",e),t}}};s.\u0275fac=function(e){return new(e||s)(v(A),v(ge))},s.\u0275prov=j({token:s,factory:s.\u0275fac,providedIn:"root"});let l=s;return l})();function Le(l){return l.get(A).log("%c[WB] Loading arrow feature chunk","color: blue;"),l.get(mt).set(ae,l.get(Se)),ft(l,d.TAGS.VELT_ARROW_TOOL,Tt),ft(l,d.TAGS.VELT_ARROWS,Dt),ft(l,d.TAGS.SNIPPYLY_ARROW_TOOL,Tt),ft(l,d.TAGS.SNIPPYLY_ARROWS,Dt),new vt(l)}function ft(l,s,c){if(customElements.get(s))return;let t=Kt(c,l);customElements.define(s,t)}export{Le as default};
|