@veltdev/sdk-staging 6.0.10 → 6.0.12
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-EQBACTBQ.js → chunk-2TTZAEAX.js} +1 -1
- package/{chunk-F6CKB7IS.js → chunk-3KTIE7HV.js} +1 -1
- package/{chunk-ID3E7CBZ.js → chunk-3T4C47NJ.js} +1 -1
- package/{chunk-FUYX2CTL.js → chunk-4RMON7GG.js} +1 -1
- package/{chunk-F4PYCUAT.js → chunk-5QRNDPMH.js} +1 -1
- package/{chunk-XHBAKZVU.js → chunk-6IT34HSZ.js} +1 -1
- package/{chunk-RLD74EXO.js → chunk-6YWJCXYF.js} +1 -1
- package/{chunk-IU25BW6T.js → chunk-7WO33FST.js} +1 -1
- package/{chunk-CI2SH5RY.js → chunk-A4JS2VN5.js} +1 -1
- package/{chunk-6RWQRJ7Z.js → chunk-BONBMEV3.js} +1 -1
- package/{chunk-XISY42XO.js → chunk-BVT5OSMI.js} +1 -1
- package/{chunk-F44SU3DK.js → chunk-ELF6PPR2.js} +1 -1
- package/{chunk-VMY3F7K3.js → chunk-FC5NQAL4.js} +1 -1
- package/{chunk-VMW7PJFD.js → chunk-FDTMKWPR.js} +1 -1
- package/{chunk-F36WWKDQ.js → chunk-JNSX6ALY.js} +1 -1
- package/{chunk-FVDWCK7Z.js → chunk-JWWUK2VE.js} +1 -1
- package/{chunk-ZJH32HDL.js → chunk-KQMIVRAC.js} +1 -1
- package/{chunk-UKJTOZK4.js → chunk-KTSX5UPA.js} +1 -1
- package/chunk-L7ZARA4D.js +193 -0
- package/{chunk-JHMDMOHO.js → chunk-LAPY2IGZ.js} +1 -1
- package/{chunk-BJRSXB3P.js → chunk-MJ2UHGNE.js} +1 -1
- package/{chunk-SYSCTHS4.js → chunk-MUYDAXFY.js} +1 -1
- package/{chunk-5R5ZQKPN.js → chunk-NSNHSRHX.js} +1 -1
- package/{chunk-CQX575C2.js → chunk-O7XCI74W.js} +1 -1
- package/{chunk-F7SQEW6P.js → chunk-ORPUXE2Y.js} +1 -1
- package/{chunk-WFO2GRDO.js → chunk-QT7Z7KCA.js} +1 -1
- package/{chunk-SY46UNW5.js → chunk-S5R4NUEK.js} +1 -1
- package/{chunk-QTF4Y24I.js → chunk-SGVDVSBF.js} +1 -1
- package/{chunk-TW7O56QU.js → chunk-UI5F5IQU.js} +1 -1
- package/{chunk-IBGPKEZW.js → chunk-UKSG7LZP.js} +1 -1
- package/{chunk-7RRXZUH7.js → chunk-UW45SPLT.js} +1 -1
- package/{chunk-3ORHWUHZ.js → chunk-WASG3GA7.js} +1 -1
- package/{chunk-VKGZ33MA.js → chunk-Z3CHFM5M.js} +24 -24
- 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-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-AOHWVH4J.js +0 -193
package/velt-area.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as ht,d as gt}from"./chunk-VMY3F7K3.js";import{t as Ft}from"./chunk-AOHWVH4J.js";import"./chunk-5R5ZQKPN.js";import"./chunk-XISY42XO.js";import{a as Ht}from"./chunk-WFO2GRDO.js";import"./chunk-TW7O56QU.js";import"./chunk-7RRXZUH7.js";import"./chunk-CI2SH5RY.js";import{b as kt}from"./chunk-CQX575C2.js";import"./chunk-F6CKB7IS.js";import{a as zt}from"./chunk-FUYX2CTL.js";import{a as Ae}from"./chunk-RLD74EXO.js";import{a as vt}from"./chunk-QTF4Y24I.js";import{I as At,Y as Pt,r as pt,t as ut,v as ft}from"./chunk-3ORHWUHZ.js";import{$ as he,Ab as nt,Ai as Nt,Bb as it,Bf as xe,C as $e,Ch as L,Db as ot,Dg as Dt,E as $,Eb as rt,Ed as St,Ee as h,Fa as D,Fb as at,Fh as wt,Fi as fe,Gc as ge,He as Ct,Ib as st,J as me,Jb as U,Kb as q,Kc as lt,L as re,Lc as dt,M as je,Ma as Je,Me as _t,Mf as It,Pa as C,Pc as mt,Pi as Bt,T as A,Ta as Ye,Ua as te,Uf as bt,Uh as ee,Va as Ze,Vf as yt,Y as be,Yf as Tt,_a as j,a as p,aa as We,ac as De,b as S,bb as Qe,ca as _,ch as ue,db as ne,dh as Le,di as Lt,eg as ae,fh as Ot,g as ce,gg as pe,ha as b,ia as y,ii as W,ja as Ge,ji as G,ki as T,l as oe,la as Xe,lb as x,li as Mt,mb as O,me as Oe,nb as M,o as Ue,ob as qe,oe as w,oh as xt,p as le,pc as ct,pe as Et,qa as Ke,qg as Re,qh as Rt,r as P,sb as ye,sh as Me,si as X,tb as Te,ti as K,ub as et,ug as we,ui as Ne,v as f,vb as ie,w as de,wb as tt,xb as R,zb as v,zi as H}from"./chunk-VKGZ33MA.js";var F=(()=>{let l=class l{constructor(e,t,n,o,c,a,r,s,m,u,I,E,z){this.analyticsService=e,this.configService=t,this.docService=n,this.databaseService=o,this.commonDbService=c,this.authService=a,this.domService=r,this.afAuth=s,this.iamService=m,this.dialog=u,this.loggingService=I,this.userPermissionService=E,this.serviceBook=z,this.areaAnnotationById$=new oe({}),this.documentPaths=null,this.areaEnabled$=new oe(!0),this.allowedElementIds$=new oe([]),this.addAreaMode$=new oe(!1),this.notificationService=null,this.loggingService.log("%c[WB] Creating CLASS: AreaService","color: blue;"),this.serviceBook.observe(wt).subscribe(g=>this.notificationService=g),this.databaseService.getDb().pipe($(g=>!!g),me(1)).subscribe(g=>{g&&this.getDocumentPaths()},g=>{this.loggingService.catch("Error in AreaService getDb subscription: ",g)}),this.domService.onWindowPointerMove$().subscribe(g=>{if(this.addAreaMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let V=this.domService.getBackgroundElement(g.clientX,g.clientY);V&&(this.isElementInsideAllowedElements(V)?we(g.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=V,this.domService.highlightElement(this.highlightElement,h.CURSOR.AREA_PIN)):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},g=>{this.loggingService.catch("Error in AreaService onWindowPointerMove$ subscription: ",g)}),this.domService.onWindowKeyupEsc$().subscribe(g=>{this.addAreaMode$.value&&this.disableAddAreaMode()},g=>{this.loggingService.catch("Error in AreaService onWindowKeyupEsc$ subscription: ",g)}),this.domService.onDocumentClick$().subscribe(g=>{if(g&&this.addAreaMode$.value){if(g.preventDefault(),g.stopPropagation(),!we(g.target)){let V=this.domService.getBackgroundElement(g.clientX,g.clientY);V&&this.isElementInsideAllowedElements(V)&&this.addArea(g)}this.disableAddAreaMode()}},g=>{this.loggingService.catch("Error in AreaService onDocumentClick$ subscription: ",g)}),this.addAreaMode$.subscribe(g=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),g?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"))},g=>{this.loggingService.catch("Error in AreaService addAreaMode$ subscription: ",g)}),this.domService.onWindowKeyupBackspace$().subscribe(g=>{this.deleteAreaPinAnnotations("keyupBackspace")},g=>{this.loggingService.catch("Error in AreaService onWindowKeyupBackspace$ subscription: ",g)}),this.domService.onWindowKeyupDelete$().subscribe(g=>{this.deleteAreaPinAnnotations("keyupDelete")},g=>{this.loggingService.catch("Error in AreaService onWindowKeyupDelete$ subscription: ",g)})}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,c;try{if(e&&(c=xe(e)),t&&typeof t=="object"){let a=Tt(t);o=xe(JSON.stringify(a))}}catch(a){this.loggingService.catch("Error in AreaService getAllAreaAnnotations: ",a)}return this.authService.getAuthState$().pipe($(a=>!!a),A(a=>this.isFeatureAllowed({firebaseUser:a,annotations:[],filteredAnnotations:[]})),A(a=>a.featureAllowed?this.iamService.isUserAllowed$().pipe(f(r=>(a.featureAllowed=r,a))):P(a)),A(a=>a.featureAllowed?this.authService.isPlanExpired$().pipe(f(r=>(a.featureAllowed=!r,a))):P(a)),A(a=>a.featureAllowed?P(a).pipe(A(r=>this.docService.getDocumentPaths$().pipe(f(s=>(this.documentPaths=s,r.documentPaths=s,r)))),A(r=>c?this.getDataFromDocumentIds([c]).pipe(f(s=>(r.annotations=s||[],p({},r)))):this.docService.getDocumentIds$().pipe(A(s=>{let m=s?.length>0?s.map(u=>u.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(m).pipe(f(u=>(r.annotations=u||[],p({},r))))}))),A(r=>this.docService.getLocation$().pipe(f(s=>(r.location=s,r)))),A(r=>this.docService.getLocations$().pipe(f(s=>(r.customLocations=s,r)))),A(r=>this.docService.getExcludedLocationIds$().pipe(f(s=>(r.excludedLocationIds=s,r)))),f(r=>{if(r.filteredAnnotations=[],c&&!o)return r.filteredAnnotations=r.annotations?.slice(),r.filteredAnnotations=this.applyExcludedLocationIds(r.filteredAnnotations,r.excludedLocationIds),r;{let s=[],m=[];return o?s.push(o):(s.push(r?.location?.locationId),s.push(...Object.values(r?.customLocations||[]).map(u=>u.locationId)),r?.location?.location?.id&&m.push(r?.location?.location?.id),m.push(...Object.values(r?.customLocations||{}).map(u=>u.location?.id).filter(u=>!!u))),r.filteredAnnotations=this.filterAnnotationsByLocationIds(r?.annotations,s,m),r.filteredAnnotations=this.applyExcludedLocationIds(r.filteredAnnotations,r.excludedLocationIds),r}}),A(r=>n?P(r):r?.annotations?.length?this.domService.onWindowResize$().pipe(f(()=>r)):P(r)),A(r=>n?P(r):r?.annotations?.length?this.domService.onDomChange$("AreaService getAllAreaAnnotations").pipe(f(()=>r)):P(r)),f(r=>(r.filteredAnnotations=r.filteredAnnotations?.map(s=>{let m=Object.assign({},s);return this.shouldSkipAreaPositionCalculation(m)?m.areaProperties=void 0:m.areaProperties=this.calculateAreaAnnotationPosition(m),m}),r)),A(r=>r?.filteredAnnotations?P(r?.filteredAnnotations||[]):P([])),A(r=>{if(this.authService.isFeatureAllowed(w.COMMENT))return P(r);{let s=r?.filter(m=>!m?.targetAnnotations?.filter(u=>u?.type===w.COMMENT)?.length);return P(s)}})):P([])),re(Rt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe($(t=>!!t),f(t=>S(p({},e),{config:t})),A(t=>this.authService.getUser$().pipe(f(n=>S(p({},t),{user:n})))),A(t=>bt(t.config,t.user,w.AREA)?P(S(p({},t),{featureAllowed:!0})):(this.loggingService.warn("Area feature is not allowed."),P(S(p({},t),{featureAllowed:!1})))),re((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(r=>!r)||!this.documentPaths)return P([]);let o=this.docService.getDocumentPaths()?.veltFolderId,c=P([]),a={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(a.documentId=t?.length?t[0]:void 0,a.organizationId=this.documentPaths?.organizationId),this.userPermissionService?.getIsContextEnabled()){let r=[h.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],s=[];for(let m=0;m<(r?.length??0);m+=h.LISTENER_CONTEXT_BATCH_SIZE)s.push(r?.slice(m,m+h.LISTENER_CONTEXT_BATCH_SIZE)??[]);c=de(s.map(m=>this.commonDbService.dbListener({feature:"allAreas",properties:S(p({},a),{firestoreQuery:[Ne(H("metadata.apiKey","==",this.configService?.getApiKey()),H("metadata.documentId","in",t),H("metadata.organizationId","==",this.documentPaths?.organizationId),...o?[H("metadata.veltFolderId","==",o)]:[],...m?.length?[H("context.accessFields","array-contains-any",m)]:[])]})}).pipe(be()))).pipe(f(m=>Me(m)))}else{let r=[];for(let s=0;s<(t?.length??0);s+=h.LISTENER_BATCH_SIZE)r.push(t?.slice(s,s+h.LISTENER_BATCH_SIZE)??[]);c=de(r.map(s=>this.commonDbService.dbListener({feature:"allAreas",properties:S(p({},a),{firestoreQuery:[Ne(H("metadata.apiKey","==",this.configService?.getApiKey()),H("metadata.documentId","in",s),H("metadata.organizationId","==",this.documentPaths?.organizationId),...o?[H("metadata.veltFolderId","==",o)]:[])]})}).pipe(be()))).pipe(f(s=>Me(s)))}return c.pipe(f(({data:r,operation:s})=>{let m=[];return r&&(m=Object.values(r??{}).filter(u=>typeof u=="object")),{data:m,operation:s}}),f(({data:r,operation:s})=>{if(!t)return{data:r,documentMap:{},operation:s};let m=r.reduce((u,I)=>{let E=I.metadata?.documentId;return E&&(u[E]||(u[E]=[]),u[E].push(I)),u},{});return{data:r,documentMap:m,operation:s}}),f(({data:r,documentMap:s,operation:m})=>{if(!n)if(m?.type==="removed"){if(m?.ids?.length){let u=this.areaAnnotationById$.value;m?.ids?.forEach(I=>{delete u?.[I]}),this.areaAnnotationById$.next(u)}}else Object.entries(s??{}).forEach(([u,I])=>{this.setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:u,annotations:I})});return r}))}else return P([])}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 c={};n?.forEach(r=>{r?.annotationId&&(c[r?.annotationId]=r)});let a=p(p({},this.areaAnnotationById$.value),c);this.areaAnnotationById$.next(a)}}catch(c){this.loggingService.catch("Error in AreaService setAreaAnnotationsByOrganizationIdAndDocumentId:",c)}}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(c=>c==o?.location?.id)||n?.find(c=>c==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 c=null,a=null;if(c=this.resolveAreaPointElement(n),a=this.resolveAreaPointElement(o),c&&a){let r=ue(c,a);if(r){let s=c,m=a,u=s.getBoundingClientRect(),I=m.getBoundingClientRect(),E=t?u.width:s.offsetWidth||u.width,z=t?u.height:s.offsetHeight||u.height,g=t?I.width:m.offsetWidth||I.width,V=t?I.height:m.offsetHeight||I.height,_e={};E&&z&&(_e={top:z*n.topPercentage/100,left:E*n.leftPercentage/100});let Ie={};g&&V&&(Ie={top:V*o.topPercentage/100,left:g*o.leftPercentage/100});let Ve=!t,N=Le(_e.left,_e.top,c,r,Ve),B=Le(Ie.left,Ie.top,a,r,Ve),J,Y,Z,Q,k={};N.x>B.x?N.y>B.y?(Q={x:N.x,y:N.y},J={x:B.x,y:B.y},k.handle1=Q,k.handle2=J):(Y={x:N.x,y:N.y},Z={x:B.x,y:B.y},k.handle1=Y,k.handle2=Z):N.y>B.y?(Z={x:N.x,y:N.y},Y={x:B.x,y:B.y},k.handle1=Z,k.handle2=Y):(J={x:N.x,y:N.y},Q={x:B.x,y:B.y},k.handle1=J,k.handle2=Q);let Wt={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 k.coordinates=Wt,k.targetElement=this.domService.getXPath(r),k}}}}return}catch(n){this.loggingService.catch("Error in AreaService calculateAreaAnnotationPosition:",n);return}}addArea(e,t=[],n,o,c,a){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{let r=this.authService.getUser();if(r)if(r.isReadOnly||r.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add areas.");else{let s=new _t;o&&(s.annotationId=o),s.from=r,s.color=h.DEFAULT_ANNOTATION_COLOR,s.lastUpdated=this.timestamp,n&&(s.targetAnnotations=[n]),s.props=new Ct;let m=this.domService.getCurrentWindowSizeValue();if(s.props.screenWidth=m.screenWidth,s.props.screenHeight=m.screenHeight,s.props.screenScrollHeight=m.screenScrollHeight,s.props.viewportWidth=window.innerWidth,s.props.viewportHeight=window.innerHeight,e||t?.length>0){let E=e?this.getPointsForAreaPinAnnotation(e):t;s.targetElements=[],E.forEach(z=>{s.targetElements.push(this.domService.getTargetElementForCursorPosition(e,void 0,void 0,void 0,void 0,!0,{clientX:z.x,clientY:z.y}))})}this.setLocationToAreaAnnotation(s),c&&(s.locationId=c.locationId,s.location=c.location),s.pageInfo=Re(),s.pageInfo&&(s.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let u=this.getElementForAreaAnnotation(s),I=this.docService.getBaseMetadata("area",{element:u});if(s?.metadata||(s.metadata={}),s.metadata=p(p({},s.metadata),I),a?.access&&a?.accessFields){if(!this.userPermissionService?.hasUserContextAccess({userId:r.userId,accessFields:a.accessFields})){this.loggingService.catch("User does not have context access to add area annotation.",void 0,void 0,!0);return}a.accessFields.some(E=>It(E))||(s.context={access:a.access,accessFields:a.accessFields})}return this.saveAreaToDb(s),s}return}catch(r){this.loggingService.catch("Error in AreaService addArea: ",r);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(xt({location:t?.location,locationId:t?.locationId},{location:e?.location,locationId:e?.locationId}))return!1;let n=this.resolveAreaCommonParent(e),o=this.docService.getAdditionLocationFromElement(n),c=o?this.docService.genarateLocationId(o):void 0,a;return e?.location?.id&&e?.location?.id===o?.id||c&&c===e?.locationId?a=!1:a=!0,a}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&&!ae(n.element)&&this.domService.isElementVisible(n.element)&&pe(n.element)&&(t=n.element),t}return e?.xpath&&(t=this.domService.getElementFromXPath(e.xpath),t&&ae(t)&&(t=null),this.domService.isXpathWithId(e.xpath)||(!t&&e.cfXpath&&(t=this.domService.getElementFromXPath(e.cfXpath),t&&ae(t)&&(t=null)),!t&&e.fXpath&&(t=this.domService.getElementFromXPath(e.fXpath),t&&ae(t)&&(t=null)))),t}resolveAreaCommonParent(e){let t=this.resolveAreaPointElement(e?.targetElements?.[0]),n=this.resolveAreaPointElement(e?.targetElements?.[1]);return t&&n?ue(t,n):null}getElementForAreaAnnotation(e){try{let t,n,o;if(e.targetElements?.length){if(e.targetElements[0]?.anchor){let c=this.domService.resolveAnchorRecord(e.targetElements[0].anchor);c?.element&&this.domService.isElementVisible(c.element)&&pe(c.element)&&(n=c.element)}else e.targetElements[0]?.xpath&&(n=this.domService.getElementFromXPath(e.targetElements[0].xpath));if(e.targetElements[1]?.anchor){let c=this.domService.resolveAnchorRecord(e.targetElements[1].anchor);c?.element&&this.domService.isElementVisible(c.element)&&pe(c.element)&&(o=c.element)}else e.targetElements[1]?.xpath&&(o=this.domService.getElementFromXPath(e.targetElements[1].xpath))}return n&&o&&(t=ue(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(w.AREA)&&de([this.docService.getDocumentPaths$(),this.databaseService.getDb()]).pipe($(([t,n])=>!!t&&!!n),me(1),A(([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 r=this.docService.getBaseMetadata("area");o.metadata=p(p({},o?.metadata),r)}this.domService.toggleAnnotationSelection(o),this.analyticsService.trackEvent(L.Events.Area.AREA_ADDED,{annotationId:e.annotationId});let{documentId:c,organizationId:a}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:c,organizationId:a},data:JSON.parse(JSON.stringify(o))})}else return P(null)})).subscribe(()=>{},t=>{this.loggingService.catch("Error in AreaService saveAreaToDb subscription: ",t)})}catch(t){this.loggingService.catch("Error in AreaService saveAreaToDb: ",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,Oe.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(w.AREA)){let t=JSON.parse(JSON.stringify(e));if(t.position=null,!t?.metadata?.documentId){t?.metadata||(t.metadata={});let c=this.docService.getBaseMetadata("area");t.metadata=p(p({},t?.metadata),c)}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(c=>ce(this,null,function*(){let a=t[c];a.type==="area"&&n&&a.from&&(n?.isAdmin||a.from.userId===n.userId)&&o.push(a)})),o?.length&&(this.analyticsService.trackEvent(L.Events.Area.AREA_DELETE_TRIGGERED,{triggerType:e,annotationId:o.map(c=>c.annotationId).join()}),this.dialog.open(kt,{panelClass:"velt-mat-dialog-container",data:{title:"Delete area?",message:"This selected area will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"area"}}).afterClosed().pipe(me(1)).subscribe(c=>{c&&(o.forEach(a=>ce(this,null,function*(){yield this.deleteAreaPinAnnotation(a)})),setTimeout(()=>{document.querySelectorAll(`[${h.SNIPPYLY_HIGHLIGHT}]`).forEach(r=>{this.domService.removeHighlightFromElement(r)})},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||{}),c;t?c=o.find(a=>a?.annotationId===t):c=o.find(a=>a?.targetAnnotations?.find(r=>r?.annotationId===e)),c&&(c.targetAnnotations=c.targetAnnotations?.filter(a=>a?.annotationId!==e),c.targetAnnotations?.length?this.updateAreaToDb(c):this.deleteAreaPinAnnotation(c))}}catch(n){this.loggingService.catch("Error in AreaService onDeleteTargetAnnotation: ",n)}}deleteAreaPinAnnotation(e){if(this.authService.isFeatureAllowed(w.AREA)&&this.documentPaths?.area&&e?.annotationId){this.updateNotificationsDatabase(e,Oe.DELETED),this.analyticsService.trackEvent(L.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),P(!1)}}getAreaEnabled(){try{return this.areaEnabled$.value}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled: ",e),!1}}enableAddAreaMode(){this.authService.isFeatureAllowed(w.AREA)?(this.analyticsService.trackEvent(L.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(L.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,c=n?.touches?.length?n.touches[0]?.clientY:n.clientY;return t.push({x:o,y:c}),t.push({x:o+100,y:c+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=Re(),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 ce(this,null,function*(){try{if(this.docService.getDocumentPaths()?.area){let t=this.commonDbService.generateDocumentId();return yield Dt(10),t||""}else return""}catch(e){return this.loggingService.catch("Error in AreaService generateAreaAnnotationId: ",e),""}})}};l.\u0275fac=function(t){return new(t||l)(_(G),_(Mt),_(fe),_(Nt),_(Bt),_(K),_(X),_(St),_(Ae),_(Pt),_(T),_(Ht),_(W))},l.\u0275prov=he({token:l,factory:l.\u0275fac,providedIn:"root"});let d=l;return d})();var Ut=()=>({bottom:"calc(100% - 8px)",color:"green"});function Jt(d,l){if(d&1){let i=ie();O(0,"div",8),R("click",function(){b(i);let t=v(3);return y(t.togglePinSelection())}),O(1,"velt-comment-pin-embed",9),R("saveComment",function(t){b(i);let n=v(3);return y(n.saveComment(n.veltEmit(t)))}),M()()}if(d&2){let i=v(2).ngIf,e=v();x("id","comment-pin-container-"+(i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId)),D(),U("left",8,"px"),x("ngStyle",De(9,Ut))("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 Yt(d,l){if(d&1){let i=ie();O(0,"div",8),R("click",function(){b(i);let t=v(3);return y(t.togglePinSelection())}),O(1,"velt-comment-pin-embed",9),R("saveComment",function(t){b(i);let n=v(3);return y(n.saveComment(n.veltEmit(t)))}),M()()}if(d&2){let i=v(2).ngIf,e=v();x("id","comment-pin-container-"+(i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId)),D(),U("left",8,"px"),x("ngStyle",De(9,Ut))("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 Zt(d,l){if(d&1){let i=ie();ye(0),O(1,"div",1),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(2,"div",2),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(3,"div",3),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(4,"div",4),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(5,"div",5),R("cdkDragStarted",function(){b(i);let t=v(2);return y(t.onResizeHandleDragStart("topLeft"))})("cdkDragMoved",function(t){b(i);let n=v(2);return y(n.onResizeHandleDragMove(t,"topLeft"))})("cdkDragEnded",function(){b(i);let t=v(2);return y(t.onResizeHandleDragEnd("topLeft"))})("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(6,"div",6),R("cdkDragStarted",function(){b(i);let t=v(2);return y(t.onResizeHandleDragStart("bottomRight"))})("cdkDragMoved",function(t){b(i);let n=v(2);return y(n.onResizeHandleDragMove(t,"bottomRight"))})("cdkDragEnded",function(){b(i);let t=v(2);return y(t.onResizeHandleDragEnd("bottomRight"))})("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),j(7,Jt,2,10,"div",7)(8,Yt,2,10,"div",7),M(),Te()}if(d&2){let i=v().ngIf,e=v();D(),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"),D(),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"),D(),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"),D(),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"),D(),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"),q("drag-disabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x("cdkDragDisabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),D(),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"),q("drag-disabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x("cdkDragDisabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),D(),x("ngIf",i.commentPinAnnotation),D(),x("ngIf",i.multiThreadCommentAnnotation)}}function Qt(d,l){if(d&1&&(ye(0),j(1,Zt,9,68,"ng-container",0),Te()),d&2){let i=l.ngIf,e=v();D(),x("ngIf",!i.hideAreaAnnotation||e.selected)}}var He=(()=>{let l=class l{get resizing(){return this.componentConfigSignal().isResizing}onMouseEnter(){this.setAreaPinHover(!0)}onMouseLeave(){this.setAreaPinHover(!1)}constructor(e,t,n,o,c,a,r){this.analyticsService=e,this.authService=t,this.serviceBook=n,this.docService=o,this.domService=c,this.areaService=a,this.loggingService=r,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=Ke({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(ee).subscribe(s=>{this.commentService=s}),this.subscriptions.push(this.authService.getUser$().subscribe(s=>{this.user=s},s=>{this.catchError("Error in AreaPinPortalComponent getUser$ subscription: ",s)})),this.subscriptions.push(this.serviceBook.observe(ee).pipe(A(s=>s?s.getPinDrag$():le)).subscribe(s=>{this.componentConfigSignal.update(m=>S(p({},m),{pinDragEnabled:s}))},s=>{this.catchError("Error in AreaPinPortalComponent getPinDrag$ subscription: ",s)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(s=>{this.componentConfigSignal.update(m=>(m=S(p({},m),{selectedAnnotationsMap:s}),m)),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()},s=>{this.catchError("Error in AreaPinPortalComponent getSelectedAnnotationsMap$ subscription: ",s)}))}ngOnInit(){}ngAfterViewInit(){try{let e=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===w.COMMENT)?.annotationId,t=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===w.MULTI_THREAD)?.annotationId;e?(this.componentConfigSignal.update(n=>(n=S(p({},n),{hideAreaAnnotation:!0}),n)),this.subscriptions.push(this.serviceBook.observe(ee).pipe(A(n=>n?n.getCommentAnnotationByAnnotationId(e):le),A(n=>(this.commentService?.getResolvedCommentsOnDom$()??P(!0)).pipe(f(o=>(this.resolvedCommentsOnDom=o,n))))).subscribe(n=>{this.componentConfigSignal.update(o=>(o=S(p({},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=S(p({},n),{hideAreaAnnotation:!0}),n)),this.subscriptions.push(this.serviceBook.observe(ee).pipe(A(n=>n?n.getMultiThreadCommentAnnotationByAnnotationId(t):le),A(n=>(this.commentService?.getResolvedCommentsOnDom$()??P(!0)).pipe(f(o=>(this.resolvedCommentsOnDom=o,n))))).subscribe(n=>{this.componentConfigSignal.update(o=>(o=S(p({},o),{multiThreadCommentAnnotation:n}),o.hideAreaAnnotation=!1,o))}))):this.componentConfigSignal.update(n=>(n=S(p({},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=S(p({},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=S(p({},t),{offsetLeft:e}),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setOffsetLeft: ",t)}}setOffsetTop(e){try{this.componentConfigSignal.update(t=>(t=S(p({},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(r=>(r=S(p({},r),{isResizing:!0}),r));let n=this.domService.getElementFromXPath(this.componentConfigSignal().areaProperties?.targetElement),o=this.calculateResizingOffset(n),c=JSON.parse(JSON.stringify(this.componentConfigSignal().areaPinAnnotation)),a=this.areaService.calculateAreaAnnotationPosition(c,!0);this.componentConfigSignal.update(r=>(r=p(S(p({},r),{resizingOffset:o}),a?{areaProperties:a}:{}),r))}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)),c=o.targetElements||[];switch(t){case"topLeft":c[0]=n;break;case"bottomRight":c[1]=n;break;default:break}o.targetElements=c;let a=this.areaService.calculateAreaAnnotationPosition(o,!0),r=this.componentConfigSignal().areaProperties?.targetElement,s=a?.targetElement,m=r!==s,u,I;if(m&&a?.targetElement){let E=this.domService.getElementFromXPath(a.targetElement),z=this.calculateResizingOffset(E);u=z.top,I=z.left}else{let E=this.componentConfigSignal().resizingOffset;u=E.top,I=E.left}this.componentConfigSignal.update(E=>(E=S(p({},E),{areaProperties:a,resizingOffset:{top:u,left:I},areaPinAnnotationOnResize:o}),E))}}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 a=this.areaService.calculateAreaAnnotationPosition(n,!1);a&&this.componentConfigSignal.update(r=>(r=S(p({},r),{areaProperties:a}),r))}this.componentConfigSignal.update(a=>(a=S(p({},a),{isResizing:!1}),a)),this.skipValueUpdate=!0;let o=this.domService.getElementFromXPath(this.componentConfigSignal().areaProperties?.targetElement),c=this.docService.getAdditionalDocumentIdFromElement(o)||this.docService.getDocumentPaths()?.clientDocumentId;!this.componentConfigSignal().areaPinAnnotation?.metadata?.clientDocumentId||this.componentConfigSignal().areaPinAnnotation?.metadata?.clientDocumentId==c?(this.componentConfigSignal.update(a=>(a=p({},a),a.areaPinAnnotationOnResize&&(a.areaPinAnnotation=JSON.parse(JSON.stringify(a.areaPinAnnotationOnResize))),delete a.areaPinAnnotationOnResize,a)),this.areaService.updateArea(this.componentConfigSignal().areaPinAnnotation,!1),this.analyticsService.trackEvent(L.Events.Area.AREA_DRAGGED,{annotationId:this.componentConfigSignal().areaPinAnnotation.annotationId})):this.componentConfigSignal.update(a=>(a=p({},a),a.areaProperties=a.areaPinAnnotation.areaProperties,a)),setTimeout(()=>{this.skipValueUpdate=!1,t&&(t.style.opacity="1")},50)}catch(t){this.catchError("Error in AreaPinComponent onResizeHandleDragEnd: ",t)}}detectPositionChange(e){try{let t=$e(0,Ue).pipe(f(()=>{let n=e.getBoundingClientRect();return{top:n.top,left:n.left}}),re((n,o)=>n.top===o.top&&n.left===o.left),je());this.subscriptions.push(t.subscribe(()=>{this.componentConfigSignal.update(n=>(n=S(p({},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,S(p({},n||{}),{annotationId:this.componentConfigSignal()?.areaPinAnnotation?.annotationId}))}catch{}}};l.\u0275fac=function(t){return new(t||l)(C(G),C(K),C(W),C(fe),C(X),C(F),C(T))},l.\u0275cmp=te({type:l,selectors:[["snippyly-area-pin-portal"]],hostVars:6,hostBindings:function(t,n){t&1&&R("mouseenter",function(){return n.onMouseEnter()})("mouseleave",function(){return n.onMouseLeave()}),t&2&&(tt("id",n.id),ne("data-velt-element",n.veltElement),q("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,Qt,2,1,"ng-container",0),t&2&&x("ngIf",n.componentConfigSignal())},dependencies:[ge,lt,ht],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 $t=(()=>{let l=class l{constructor(e,t,n,o,c){this.domService=e,this.componentFactoryResolver=t,this.injector=n,this.appRef=o,this.loggingService=c,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,c=this.areasPinById[e.annotationId].pinHostElement;if(document.body.contains(o)&&document.body.contains(c))n&&(n.instance.setAreaPinAnnotation(JSON.parse(JSON.stringify(e))),this.updateElementOffset(e));else{let a=this.areasPinById[e.annotationId].pinHostDomPortalOutlet;a&&(this.removeAreaPinHostAttributes(e.annotationId,this.areasPinById[e.annotationId].pinHostElement),a.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 pt(He),c=new ut(n,this.appRef,this.injector),a=c.attach(o);a.instance.setAreaPinAnnotation(JSON.parse(JSON.stringify(e))),a.instance.targetElement=t,this.areasPinById[e.annotationId]={pinHostDomPortalOutlet:c,pinPortal:o,portalRef:a,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)&&(Ot(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(","),c=o.indexOf(e);c>-1&&(o.splice(c,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],c=this.domService.getElementOffset(n,o);t.instance.setOffsetLeft(c.offsetLeft),t.instance.setOffsetTop(c.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)(_(X),_(Je),_(Xe),_(Qe),_(T))},l.\u0275prov=he({token:l,factory:l.\u0275fac,providedIn:"root"});let d=l;return d})();var Se=(()=>{let l=class l{constructor(e,t,n,o,c,a,r){this.analyticsService=e,this.authService=t,this.domService=n,this.areaService=o,this.areaPinPortalService=c,this.serviceBook=a,this.loggingService=r,this.areaPinAnnotations=[],this.subscriptions=[],this.isFirstComponent=!0,this.commentsOnDom=!0,this.commentService=null,this.veltId=yt(),this.veltElement=!0;try{this.loggingService.log("%c[WB] Creating CLASS: AreasContainerComponent","color: blue;"),this.serviceBook.observe(ee).subscribe(s=>{this.commentService=s})}catch(s){this.loggingService.catch("Error in AreasContainerComponent constructor: ",s)}}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($(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($(e=>!!e),A(e=>this.domService.getSelectedAnnotationsMap$().pipe(f(t=>({annotations:e,selectedAnnotationsMap:t||{}})))),A(e=>(this.commentService?.getCommentsOnDom$()??P(!0)).pipe(f(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===w.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(Et.AREA_COMMENT)}catch(e){this.loggingService.catch("Error in AreasContainerComponent setAreaInstalledInAnalytics: ",e)}}};l.\u0275fac=function(t){return new(t||l)(C(G),C(K),C(X),C(F),C($t),C(W),C(T))},l.\u0275cmp=te({type:l,selectors:[["snippyly-area-container"]],hostVars:2,hostBindings:function(t,n){t&2&&ne("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 en=["customBtnRef"],tn=["*"];function nn(d,l){if(d&1&&(O(0,"div",6),Ge(),O(1,"svg",7),qe(2,"path",8),M()()),d&2){let i=v();D(),q("active",i.addAreaMode)}}function on(d,l){d&1&&et(0)}function rn(d,l){d&1&&it(0)}var Pe=(()=>{let l=class l{constructor(e,t,n,o,c){this.analyticsService=e,this.authService=t,this.areaService=n,this.iamService=o,this.loggingService=c,this.showDefaultBtn=!1,this.addAreaMode=!1,this.subscriptions=[],this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(a=>{this.user=a},a=>{this.loggingService.catch("Error in AreasToolComponent getUser$ subscription: ",a)}))}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(L.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)(C(G),C(K),C(F),C(Ae),C(T))},l.\u0275cmp=te({type:l,selectors:[["snippyly-area-tool"]],viewQuery:function(t,n){if(t&1&&ot(en,5),t&2){let o;rt(o=at())&&(n.customBtnRef=o.first)}},hostVars:1,hostBindings:function(t,n){t&2&&ne("data-velt-element",n.veltElement)},standalone:!1,ngContentSelectors:tn,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=ie();nt(),O(0,"div",2),R("click",function(a){return b(o),n.addArea(),y(a.stopPropagation())}),j(1,nn,3,2,"div",3),O(2,"div",4,0),j(4,on,1,0,"ng-container",5),M()(),j(5,rn,1,0,"ng-template",null,1,ct)}if(t&2){let o=st(6);q("active",n.addAreaMode),D(),x("ngIf",n.showDefaultBtn),D(3),x("ngTemplateOutlet",o)}},dependencies:[ge,dt],encapsulation:2,changeDetection:0});let d=l;return d})();var Ee=class extends zt{constructor(l){super(l),this.getService(T).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(T).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(L.Events.Area.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(F).enableArea()}catch(l){this.getService(T).catch("Error in _enableAreaComment: ",l)}}_disableAreaComment(){this.getService(T).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(L.Events.Area.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(F).disableArea()}catch(l){this.getService(T).catch("Error in _disableAreaComment: ",l)}}};var jt=(()=>{let l=class l{};l.\u0275fac=function(t){return new(t||l)},l.\u0275mod=Ze({type:l}),l.\u0275inj=We({imports:[mt,At,ft,gt,Ft]});let d=l;return d})();function an(d){d.get(T).log("%c[WB] Loading area feature chunk","color: blue;"),d.get(W).set(Lt,d.get(F));let t=Ye(jt,d).injector;return Ce(t,h.TAGS.VELT_AREA_TOOL,Pe),Ce(t,h.TAGS.SNIPPYLY_AREA_TOOL,Pe),Ce(t,h.TAGS.VELT_AREAS,Se),Ce(t,h.TAGS.SNIPPYLY_AREAS,Se),new Ee(d)}function Ce(d,l,i){if(customElements.get(l))return;let e=vt(i,{injector:d});customElements.define(l,e)}export{an as default};
|
|
1
|
+
import{c as ht,d as gt}from"./chunk-FC5NQAL4.js";import{t as Ft}from"./chunk-L7ZARA4D.js";import"./chunk-NSNHSRHX.js";import"./chunk-BVT5OSMI.js";import{a as Ht}from"./chunk-QT7Z7KCA.js";import"./chunk-UI5F5IQU.js";import"./chunk-UW45SPLT.js";import"./chunk-A4JS2VN5.js";import{b as kt}from"./chunk-O7XCI74W.js";import"./chunk-3KTIE7HV.js";import{a as zt}from"./chunk-4RMON7GG.js";import{a as Ae}from"./chunk-6YWJCXYF.js";import{a as vt}from"./chunk-SGVDVSBF.js";import{I as At,Y as Pt,r as pt,t as ut,v as ft}from"./chunk-WASG3GA7.js";import{$ as he,Ab as nt,Bb as it,Bf as xe,C as $e,Ci as H,Db as ot,Dg as Dt,Di as Nt,E as $,Eb as rt,Ed as St,Ee as h,Fa as D,Fb as at,Fh as L,Gc as ge,He as Ct,Ib as st,Ih as wt,Ii as fe,J as me,Jb as U,Kb as q,Kc as lt,L as re,Lc as dt,M as je,Ma as Je,Me as _t,Mf as It,Pa as C,Pc as mt,Si as Bt,T as A,Ta as Ye,Ua as te,Uf as bt,Va as Ze,Vf as yt,Xh as ee,Y as be,Yf as Tt,_a as j,a as p,aa as We,ac as De,b as S,bb as Qe,ca as _,db as ne,eg as ae,fh as ue,g as ce,gg as pe,gh as Le,gi as Lt,ha as b,ia as y,ih as Ot,ja as Ge,l as oe,la as Xe,lb as x,li as W,mb as O,me as Oe,mi as G,nb as M,ni as T,o as Ue,ob as qe,oe as w,oi as Mt,p as le,pc as ct,pe as Et,qa as Ke,qg as Re,r as P,rh as xt,sb as ye,tb as Te,th as Rt,ub as et,ug as we,v as f,vb as ie,vh as Me,vi as X,w as de,wb as tt,wi as K,xb as R,xi as Ne,zb as v}from"./chunk-Z3CHFM5M.js";var F=(()=>{let l=class l{constructor(e,t,n,o,c,a,r,s,m,u,I,E,z){this.analyticsService=e,this.configService=t,this.docService=n,this.databaseService=o,this.commonDbService=c,this.authService=a,this.domService=r,this.afAuth=s,this.iamService=m,this.dialog=u,this.loggingService=I,this.userPermissionService=E,this.serviceBook=z,this.areaAnnotationById$=new oe({}),this.documentPaths=null,this.areaEnabled$=new oe(!0),this.allowedElementIds$=new oe([]),this.addAreaMode$=new oe(!1),this.notificationService=null,this.loggingService.log("%c[WB] Creating CLASS: AreaService","color: blue;"),this.serviceBook.observe(wt).subscribe(g=>this.notificationService=g),this.databaseService.getDb().pipe($(g=>!!g),me(1)).subscribe(g=>{g&&this.getDocumentPaths()},g=>{this.loggingService.catch("Error in AreaService getDb subscription: ",g)}),this.domService.onWindowPointerMove$().subscribe(g=>{if(this.addAreaMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let V=this.domService.getBackgroundElement(g.clientX,g.clientY);V&&(this.isElementInsideAllowedElements(V)?we(g.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=V,this.domService.highlightElement(this.highlightElement,h.CURSOR.AREA_PIN)):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},g=>{this.loggingService.catch("Error in AreaService onWindowPointerMove$ subscription: ",g)}),this.domService.onWindowKeyupEsc$().subscribe(g=>{this.addAreaMode$.value&&this.disableAddAreaMode()},g=>{this.loggingService.catch("Error in AreaService onWindowKeyupEsc$ subscription: ",g)}),this.domService.onDocumentClick$().subscribe(g=>{if(g&&this.addAreaMode$.value){if(g.preventDefault(),g.stopPropagation(),!we(g.target)){let V=this.domService.getBackgroundElement(g.clientX,g.clientY);V&&this.isElementInsideAllowedElements(V)&&this.addArea(g)}this.disableAddAreaMode()}},g=>{this.loggingService.catch("Error in AreaService onDocumentClick$ subscription: ",g)}),this.addAreaMode$.subscribe(g=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),g?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"))},g=>{this.loggingService.catch("Error in AreaService addAreaMode$ subscription: ",g)}),this.domService.onWindowKeyupBackspace$().subscribe(g=>{this.deleteAreaPinAnnotations("keyupBackspace")},g=>{this.loggingService.catch("Error in AreaService onWindowKeyupBackspace$ subscription: ",g)}),this.domService.onWindowKeyupDelete$().subscribe(g=>{this.deleteAreaPinAnnotations("keyupDelete")},g=>{this.loggingService.catch("Error in AreaService onWindowKeyupDelete$ subscription: ",g)})}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,c;try{if(e&&(c=xe(e)),t&&typeof t=="object"){let a=Tt(t);o=xe(JSON.stringify(a))}}catch(a){this.loggingService.catch("Error in AreaService getAllAreaAnnotations: ",a)}return this.authService.getAuthState$().pipe($(a=>!!a),A(a=>this.isFeatureAllowed({firebaseUser:a,annotations:[],filteredAnnotations:[]})),A(a=>a.featureAllowed?this.iamService.isUserAllowed$().pipe(f(r=>(a.featureAllowed=r,a))):P(a)),A(a=>a.featureAllowed?this.authService.isPlanExpired$().pipe(f(r=>(a.featureAllowed=!r,a))):P(a)),A(a=>a.featureAllowed?P(a).pipe(A(r=>this.docService.getDocumentPaths$().pipe(f(s=>(this.documentPaths=s,r.documentPaths=s,r)))),A(r=>c?this.getDataFromDocumentIds([c]).pipe(f(s=>(r.annotations=s||[],p({},r)))):this.docService.getDocumentIds$().pipe(A(s=>{let m=s?.length>0?s.map(u=>u.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(m).pipe(f(u=>(r.annotations=u||[],p({},r))))}))),A(r=>this.docService.getLocation$().pipe(f(s=>(r.location=s,r)))),A(r=>this.docService.getLocations$().pipe(f(s=>(r.customLocations=s,r)))),A(r=>this.docService.getExcludedLocationIds$().pipe(f(s=>(r.excludedLocationIds=s,r)))),f(r=>{if(r.filteredAnnotations=[],c&&!o)return r.filteredAnnotations=r.annotations?.slice(),r.filteredAnnotations=this.applyExcludedLocationIds(r.filteredAnnotations,r.excludedLocationIds),r;{let s=[],m=[];return o?s.push(o):(s.push(r?.location?.locationId),s.push(...Object.values(r?.customLocations||[]).map(u=>u.locationId)),r?.location?.location?.id&&m.push(r?.location?.location?.id),m.push(...Object.values(r?.customLocations||{}).map(u=>u.location?.id).filter(u=>!!u))),r.filteredAnnotations=this.filterAnnotationsByLocationIds(r?.annotations,s,m),r.filteredAnnotations=this.applyExcludedLocationIds(r.filteredAnnotations,r.excludedLocationIds),r}}),A(r=>n?P(r):r?.annotations?.length?this.domService.onWindowResize$().pipe(f(()=>r)):P(r)),A(r=>n?P(r):r?.annotations?.length?this.domService.onDomChange$("AreaService getAllAreaAnnotations").pipe(f(()=>r)):P(r)),f(r=>(r.filteredAnnotations=r.filteredAnnotations?.map(s=>{let m=Object.assign({},s);return this.shouldSkipAreaPositionCalculation(m)?m.areaProperties=void 0:m.areaProperties=this.calculateAreaAnnotationPosition(m),m}),r)),A(r=>r?.filteredAnnotations?P(r?.filteredAnnotations||[]):P([])),A(r=>{if(this.authService.isFeatureAllowed(w.COMMENT))return P(r);{let s=r?.filter(m=>!m?.targetAnnotations?.filter(u=>u?.type===w.COMMENT)?.length);return P(s)}})):P([])),re(Rt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe($(t=>!!t),f(t=>S(p({},e),{config:t})),A(t=>this.authService.getUser$().pipe(f(n=>S(p({},t),{user:n})))),A(t=>bt(t.config,t.user,w.AREA)?P(S(p({},t),{featureAllowed:!0})):(this.loggingService.warn("Area feature is not allowed."),P(S(p({},t),{featureAllowed:!1})))),re((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(r=>!r)||!this.documentPaths)return P([]);let o=this.docService.getDocumentPaths()?.veltFolderId,c=P([]),a={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(a.documentId=t?.length?t[0]:void 0,a.organizationId=this.documentPaths?.organizationId),this.userPermissionService?.getIsContextEnabled()){let r=[h.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],s=[];for(let m=0;m<(r?.length??0);m+=h.LISTENER_CONTEXT_BATCH_SIZE)s.push(r?.slice(m,m+h.LISTENER_CONTEXT_BATCH_SIZE)??[]);c=de(s.map(m=>this.commonDbService.dbListener({feature:"allAreas",properties:S(p({},a),{firestoreQuery:[Ne(H("metadata.apiKey","==",this.configService?.getApiKey()),H("metadata.documentId","in",t),H("metadata.organizationId","==",this.documentPaths?.organizationId),...o?[H("metadata.veltFolderId","==",o)]:[],...m?.length?[H("context.accessFields","array-contains-any",m)]:[])]})}).pipe(be()))).pipe(f(m=>Me(m)))}else{let r=[];for(let s=0;s<(t?.length??0);s+=h.LISTENER_BATCH_SIZE)r.push(t?.slice(s,s+h.LISTENER_BATCH_SIZE)??[]);c=de(r.map(s=>this.commonDbService.dbListener({feature:"allAreas",properties:S(p({},a),{firestoreQuery:[Ne(H("metadata.apiKey","==",this.configService?.getApiKey()),H("metadata.documentId","in",s),H("metadata.organizationId","==",this.documentPaths?.organizationId),...o?[H("metadata.veltFolderId","==",o)]:[])]})}).pipe(be()))).pipe(f(s=>Me(s)))}return c.pipe(f(({data:r,operation:s})=>{let m=[];return r&&(m=Object.values(r??{}).filter(u=>typeof u=="object")),{data:m,operation:s}}),f(({data:r,operation:s})=>{if(!t)return{data:r,documentMap:{},operation:s};let m=r.reduce((u,I)=>{let E=I.metadata?.documentId;return E&&(u[E]||(u[E]=[]),u[E].push(I)),u},{});return{data:r,documentMap:m,operation:s}}),f(({data:r,documentMap:s,operation:m})=>{if(!n)if(m?.type==="removed"){if(m?.ids?.length){let u=this.areaAnnotationById$.value;m?.ids?.forEach(I=>{delete u?.[I]}),this.areaAnnotationById$.next(u)}}else Object.entries(s??{}).forEach(([u,I])=>{this.setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:u,annotations:I})});return r}))}else return P([])}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 c={};n?.forEach(r=>{r?.annotationId&&(c[r?.annotationId]=r)});let a=p(p({},this.areaAnnotationById$.value),c);this.areaAnnotationById$.next(a)}}catch(c){this.loggingService.catch("Error in AreaService setAreaAnnotationsByOrganizationIdAndDocumentId:",c)}}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(c=>c==o?.location?.id)||n?.find(c=>c==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 c=null,a=null;if(c=this.resolveAreaPointElement(n),a=this.resolveAreaPointElement(o),c&&a){let r=ue(c,a);if(r){let s=c,m=a,u=s.getBoundingClientRect(),I=m.getBoundingClientRect(),E=t?u.width:s.offsetWidth||u.width,z=t?u.height:s.offsetHeight||u.height,g=t?I.width:m.offsetWidth||I.width,V=t?I.height:m.offsetHeight||I.height,_e={};E&&z&&(_e={top:z*n.topPercentage/100,left:E*n.leftPercentage/100});let Ie={};g&&V&&(Ie={top:V*o.topPercentage/100,left:g*o.leftPercentage/100});let Ve=!t,N=Le(_e.left,_e.top,c,r,Ve),B=Le(Ie.left,Ie.top,a,r,Ve),J,Y,Z,Q,k={};N.x>B.x?N.y>B.y?(Q={x:N.x,y:N.y},J={x:B.x,y:B.y},k.handle1=Q,k.handle2=J):(Y={x:N.x,y:N.y},Z={x:B.x,y:B.y},k.handle1=Y,k.handle2=Z):N.y>B.y?(Z={x:N.x,y:N.y},Y={x:B.x,y:B.y},k.handle1=Z,k.handle2=Y):(J={x:N.x,y:N.y},Q={x:B.x,y:B.y},k.handle1=J,k.handle2=Q);let Wt={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 k.coordinates=Wt,k.targetElement=this.domService.getXPath(r),k}}}}return}catch(n){this.loggingService.catch("Error in AreaService calculateAreaAnnotationPosition:",n);return}}addArea(e,t=[],n,o,c,a){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{let r=this.authService.getUser();if(r)if(r.isReadOnly||r.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add areas.");else{let s=new _t;o&&(s.annotationId=o),s.from=r,s.color=h.DEFAULT_ANNOTATION_COLOR,s.lastUpdated=this.timestamp,n&&(s.targetAnnotations=[n]),s.props=new Ct;let m=this.domService.getCurrentWindowSizeValue();if(s.props.screenWidth=m.screenWidth,s.props.screenHeight=m.screenHeight,s.props.screenScrollHeight=m.screenScrollHeight,s.props.viewportWidth=window.innerWidth,s.props.viewportHeight=window.innerHeight,e||t?.length>0){let E=e?this.getPointsForAreaPinAnnotation(e):t;s.targetElements=[],E.forEach(z=>{s.targetElements.push(this.domService.getTargetElementForCursorPosition(e,void 0,void 0,void 0,void 0,!0,{clientX:z.x,clientY:z.y}))})}this.setLocationToAreaAnnotation(s),c&&(s.locationId=c.locationId,s.location=c.location),s.pageInfo=Re(),s.pageInfo&&(s.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let u=this.getElementForAreaAnnotation(s),I=this.docService.getBaseMetadata("area",{element:u});if(s?.metadata||(s.metadata={}),s.metadata=p(p({},s.metadata),I),a?.access&&a?.accessFields){if(!this.userPermissionService?.hasUserContextAccess({userId:r.userId,accessFields:a.accessFields})){this.loggingService.catch("User does not have context access to add area annotation.",void 0,void 0,!0);return}a.accessFields.some(E=>It(E))||(s.context={access:a.access,accessFields:a.accessFields})}return this.saveAreaToDb(s),s}return}catch(r){this.loggingService.catch("Error in AreaService addArea: ",r);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(xt({location:t?.location,locationId:t?.locationId},{location:e?.location,locationId:e?.locationId}))return!1;let n=this.resolveAreaCommonParent(e),o=this.docService.getAdditionLocationFromElement(n),c=o?this.docService.genarateLocationId(o):void 0,a;return e?.location?.id&&e?.location?.id===o?.id||c&&c===e?.locationId?a=!1:a=!0,a}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&&!ae(n.element)&&this.domService.isElementVisible(n.element)&&pe(n.element)&&(t=n.element),t}return e?.xpath&&(t=this.domService.getElementFromXPath(e.xpath),t&&ae(t)&&(t=null),this.domService.isXpathWithId(e.xpath)||(!t&&e.cfXpath&&(t=this.domService.getElementFromXPath(e.cfXpath),t&&ae(t)&&(t=null)),!t&&e.fXpath&&(t=this.domService.getElementFromXPath(e.fXpath),t&&ae(t)&&(t=null)))),t}resolveAreaCommonParent(e){let t=this.resolveAreaPointElement(e?.targetElements?.[0]),n=this.resolveAreaPointElement(e?.targetElements?.[1]);return t&&n?ue(t,n):null}getElementForAreaAnnotation(e){try{let t,n,o;if(e.targetElements?.length){if(e.targetElements[0]?.anchor){let c=this.domService.resolveAnchorRecord(e.targetElements[0].anchor);c?.element&&this.domService.isElementVisible(c.element)&&pe(c.element)&&(n=c.element)}else e.targetElements[0]?.xpath&&(n=this.domService.getElementFromXPath(e.targetElements[0].xpath));if(e.targetElements[1]?.anchor){let c=this.domService.resolveAnchorRecord(e.targetElements[1].anchor);c?.element&&this.domService.isElementVisible(c.element)&&pe(c.element)&&(o=c.element)}else e.targetElements[1]?.xpath&&(o=this.domService.getElementFromXPath(e.targetElements[1].xpath))}return n&&o&&(t=ue(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(w.AREA)&&de([this.docService.getDocumentPaths$(),this.databaseService.getDb()]).pipe($(([t,n])=>!!t&&!!n),me(1),A(([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 r=this.docService.getBaseMetadata("area");o.metadata=p(p({},o?.metadata),r)}this.domService.toggleAnnotationSelection(o),this.analyticsService.trackEvent(L.Events.Area.AREA_ADDED,{annotationId:e.annotationId});let{documentId:c,organizationId:a}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:c,organizationId:a},data:JSON.parse(JSON.stringify(o))})}else return P(null)})).subscribe(()=>{},t=>{this.loggingService.catch("Error in AreaService saveAreaToDb subscription: ",t)})}catch(t){this.loggingService.catch("Error in AreaService saveAreaToDb: ",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,Oe.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(w.AREA)){let t=JSON.parse(JSON.stringify(e));if(t.position=null,!t?.metadata?.documentId){t?.metadata||(t.metadata={});let c=this.docService.getBaseMetadata("area");t.metadata=p(p({},t?.metadata),c)}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(c=>ce(this,null,function*(){let a=t[c];a.type==="area"&&n&&a.from&&(n?.isAdmin||a.from.userId===n.userId)&&o.push(a)})),o?.length&&(this.analyticsService.trackEvent(L.Events.Area.AREA_DELETE_TRIGGERED,{triggerType:e,annotationId:o.map(c=>c.annotationId).join()}),this.dialog.open(kt,{panelClass:"velt-mat-dialog-container",data:{title:"Delete area?",message:"This selected area will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"area"}}).afterClosed().pipe(me(1)).subscribe(c=>{c&&(o.forEach(a=>ce(this,null,function*(){yield this.deleteAreaPinAnnotation(a)})),setTimeout(()=>{document.querySelectorAll(`[${h.SNIPPYLY_HIGHLIGHT}]`).forEach(r=>{this.domService.removeHighlightFromElement(r)})},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||{}),c;t?c=o.find(a=>a?.annotationId===t):c=o.find(a=>a?.targetAnnotations?.find(r=>r?.annotationId===e)),c&&(c.targetAnnotations=c.targetAnnotations?.filter(a=>a?.annotationId!==e),c.targetAnnotations?.length?this.updateAreaToDb(c):this.deleteAreaPinAnnotation(c))}}catch(n){this.loggingService.catch("Error in AreaService onDeleteTargetAnnotation: ",n)}}deleteAreaPinAnnotation(e){if(this.authService.isFeatureAllowed(w.AREA)&&this.documentPaths?.area&&e?.annotationId){this.updateNotificationsDatabase(e,Oe.DELETED),this.analyticsService.trackEvent(L.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),P(!1)}}getAreaEnabled(){try{return this.areaEnabled$.value}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled: ",e),!1}}enableAddAreaMode(){this.authService.isFeatureAllowed(w.AREA)?(this.analyticsService.trackEvent(L.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(L.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,c=n?.touches?.length?n.touches[0]?.clientY:n.clientY;return t.push({x:o,y:c}),t.push({x:o+100,y:c+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=Re(),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 ce(this,null,function*(){try{if(this.docService.getDocumentPaths()?.area){let t=this.commonDbService.generateDocumentId();return yield Dt(10),t||""}else return""}catch(e){return this.loggingService.catch("Error in AreaService generateAreaAnnotationId: ",e),""}})}};l.\u0275fac=function(t){return new(t||l)(_(G),_(Mt),_(fe),_(Nt),_(Bt),_(K),_(X),_(St),_(Ae),_(Pt),_(T),_(Ht),_(W))},l.\u0275prov=he({token:l,factory:l.\u0275fac,providedIn:"root"});let d=l;return d})();var Ut=()=>({bottom:"calc(100% - 8px)",color:"green"});function Jt(d,l){if(d&1){let i=ie();O(0,"div",8),R("click",function(){b(i);let t=v(3);return y(t.togglePinSelection())}),O(1,"velt-comment-pin-embed",9),R("saveComment",function(t){b(i);let n=v(3);return y(n.saveComment(n.veltEmit(t)))}),M()()}if(d&2){let i=v(2).ngIf,e=v();x("id","comment-pin-container-"+(i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId)),D(),U("left",8,"px"),x("ngStyle",De(9,Ut))("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 Yt(d,l){if(d&1){let i=ie();O(0,"div",8),R("click",function(){b(i);let t=v(3);return y(t.togglePinSelection())}),O(1,"velt-comment-pin-embed",9),R("saveComment",function(t){b(i);let n=v(3);return y(n.saveComment(n.veltEmit(t)))}),M()()}if(d&2){let i=v(2).ngIf,e=v();x("id","comment-pin-container-"+(i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId)),D(),U("left",8,"px"),x("ngStyle",De(9,Ut))("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 Zt(d,l){if(d&1){let i=ie();ye(0),O(1,"div",1),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(2,"div",2),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(3,"div",3),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(4,"div",4),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(5,"div",5),R("cdkDragStarted",function(){b(i);let t=v(2);return y(t.onResizeHandleDragStart("topLeft"))})("cdkDragMoved",function(t){b(i);let n=v(2);return y(n.onResizeHandleDragMove(t,"topLeft"))})("cdkDragEnded",function(){b(i);let t=v(2);return y(t.onResizeHandleDragEnd("topLeft"))})("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(6,"div",6),R("cdkDragStarted",function(){b(i);let t=v(2);return y(t.onResizeHandleDragStart("bottomRight"))})("cdkDragMoved",function(t){b(i);let n=v(2);return y(n.onResizeHandleDragMove(t,"bottomRight"))})("cdkDragEnded",function(){b(i);let t=v(2);return y(t.onResizeHandleDragEnd("bottomRight"))})("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),j(7,Jt,2,10,"div",7)(8,Yt,2,10,"div",7),M(),Te()}if(d&2){let i=v().ngIf,e=v();D(),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"),D(),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"),D(),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"),D(),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"),D(),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"),q("drag-disabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x("cdkDragDisabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),D(),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"),q("drag-disabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x("cdkDragDisabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),D(),x("ngIf",i.commentPinAnnotation),D(),x("ngIf",i.multiThreadCommentAnnotation)}}function Qt(d,l){if(d&1&&(ye(0),j(1,Zt,9,68,"ng-container",0),Te()),d&2){let i=l.ngIf,e=v();D(),x("ngIf",!i.hideAreaAnnotation||e.selected)}}var He=(()=>{let l=class l{get resizing(){return this.componentConfigSignal().isResizing}onMouseEnter(){this.setAreaPinHover(!0)}onMouseLeave(){this.setAreaPinHover(!1)}constructor(e,t,n,o,c,a,r){this.analyticsService=e,this.authService=t,this.serviceBook=n,this.docService=o,this.domService=c,this.areaService=a,this.loggingService=r,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=Ke({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(ee).subscribe(s=>{this.commentService=s}),this.subscriptions.push(this.authService.getUser$().subscribe(s=>{this.user=s},s=>{this.catchError("Error in AreaPinPortalComponent getUser$ subscription: ",s)})),this.subscriptions.push(this.serviceBook.observe(ee).pipe(A(s=>s?s.getPinDrag$():le)).subscribe(s=>{this.componentConfigSignal.update(m=>S(p({},m),{pinDragEnabled:s}))},s=>{this.catchError("Error in AreaPinPortalComponent getPinDrag$ subscription: ",s)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(s=>{this.componentConfigSignal.update(m=>(m=S(p({},m),{selectedAnnotationsMap:s}),m)),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()},s=>{this.catchError("Error in AreaPinPortalComponent getSelectedAnnotationsMap$ subscription: ",s)}))}ngOnInit(){}ngAfterViewInit(){try{let e=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===w.COMMENT)?.annotationId,t=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===w.MULTI_THREAD)?.annotationId;e?(this.componentConfigSignal.update(n=>(n=S(p({},n),{hideAreaAnnotation:!0}),n)),this.subscriptions.push(this.serviceBook.observe(ee).pipe(A(n=>n?n.getCommentAnnotationByAnnotationId(e):le),A(n=>(this.commentService?.getResolvedCommentsOnDom$()??P(!0)).pipe(f(o=>(this.resolvedCommentsOnDom=o,n))))).subscribe(n=>{this.componentConfigSignal.update(o=>(o=S(p({},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=S(p({},n),{hideAreaAnnotation:!0}),n)),this.subscriptions.push(this.serviceBook.observe(ee).pipe(A(n=>n?n.getMultiThreadCommentAnnotationByAnnotationId(t):le),A(n=>(this.commentService?.getResolvedCommentsOnDom$()??P(!0)).pipe(f(o=>(this.resolvedCommentsOnDom=o,n))))).subscribe(n=>{this.componentConfigSignal.update(o=>(o=S(p({},o),{multiThreadCommentAnnotation:n}),o.hideAreaAnnotation=!1,o))}))):this.componentConfigSignal.update(n=>(n=S(p({},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=S(p({},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=S(p({},t),{offsetLeft:e}),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setOffsetLeft: ",t)}}setOffsetTop(e){try{this.componentConfigSignal.update(t=>(t=S(p({},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(r=>(r=S(p({},r),{isResizing:!0}),r));let n=this.domService.getElementFromXPath(this.componentConfigSignal().areaProperties?.targetElement),o=this.calculateResizingOffset(n),c=JSON.parse(JSON.stringify(this.componentConfigSignal().areaPinAnnotation)),a=this.areaService.calculateAreaAnnotationPosition(c,!0);this.componentConfigSignal.update(r=>(r=p(S(p({},r),{resizingOffset:o}),a?{areaProperties:a}:{}),r))}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)),c=o.targetElements||[];switch(t){case"topLeft":c[0]=n;break;case"bottomRight":c[1]=n;break;default:break}o.targetElements=c;let a=this.areaService.calculateAreaAnnotationPosition(o,!0),r=this.componentConfigSignal().areaProperties?.targetElement,s=a?.targetElement,m=r!==s,u,I;if(m&&a?.targetElement){let E=this.domService.getElementFromXPath(a.targetElement),z=this.calculateResizingOffset(E);u=z.top,I=z.left}else{let E=this.componentConfigSignal().resizingOffset;u=E.top,I=E.left}this.componentConfigSignal.update(E=>(E=S(p({},E),{areaProperties:a,resizingOffset:{top:u,left:I},areaPinAnnotationOnResize:o}),E))}}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 a=this.areaService.calculateAreaAnnotationPosition(n,!1);a&&this.componentConfigSignal.update(r=>(r=S(p({},r),{areaProperties:a}),r))}this.componentConfigSignal.update(a=>(a=S(p({},a),{isResizing:!1}),a)),this.skipValueUpdate=!0;let o=this.domService.getElementFromXPath(this.componentConfigSignal().areaProperties?.targetElement),c=this.docService.getAdditionalDocumentIdFromElement(o)||this.docService.getDocumentPaths()?.clientDocumentId;!this.componentConfigSignal().areaPinAnnotation?.metadata?.clientDocumentId||this.componentConfigSignal().areaPinAnnotation?.metadata?.clientDocumentId==c?(this.componentConfigSignal.update(a=>(a=p({},a),a.areaPinAnnotationOnResize&&(a.areaPinAnnotation=JSON.parse(JSON.stringify(a.areaPinAnnotationOnResize))),delete a.areaPinAnnotationOnResize,a)),this.areaService.updateArea(this.componentConfigSignal().areaPinAnnotation,!1),this.analyticsService.trackEvent(L.Events.Area.AREA_DRAGGED,{annotationId:this.componentConfigSignal().areaPinAnnotation.annotationId})):this.componentConfigSignal.update(a=>(a=p({},a),a.areaProperties=a.areaPinAnnotation.areaProperties,a)),setTimeout(()=>{this.skipValueUpdate=!1,t&&(t.style.opacity="1")},50)}catch(t){this.catchError("Error in AreaPinComponent onResizeHandleDragEnd: ",t)}}detectPositionChange(e){try{let t=$e(0,Ue).pipe(f(()=>{let n=e.getBoundingClientRect();return{top:n.top,left:n.left}}),re((n,o)=>n.top===o.top&&n.left===o.left),je());this.subscriptions.push(t.subscribe(()=>{this.componentConfigSignal.update(n=>(n=S(p({},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,S(p({},n||{}),{annotationId:this.componentConfigSignal()?.areaPinAnnotation?.annotationId}))}catch{}}};l.\u0275fac=function(t){return new(t||l)(C(G),C(K),C(W),C(fe),C(X),C(F),C(T))},l.\u0275cmp=te({type:l,selectors:[["snippyly-area-pin-portal"]],hostVars:6,hostBindings:function(t,n){t&1&&R("mouseenter",function(){return n.onMouseEnter()})("mouseleave",function(){return n.onMouseLeave()}),t&2&&(tt("id",n.id),ne("data-velt-element",n.veltElement),q("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,Qt,2,1,"ng-container",0),t&2&&x("ngIf",n.componentConfigSignal())},dependencies:[ge,lt,ht],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 $t=(()=>{let l=class l{constructor(e,t,n,o,c){this.domService=e,this.componentFactoryResolver=t,this.injector=n,this.appRef=o,this.loggingService=c,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,c=this.areasPinById[e.annotationId].pinHostElement;if(document.body.contains(o)&&document.body.contains(c))n&&(n.instance.setAreaPinAnnotation(JSON.parse(JSON.stringify(e))),this.updateElementOffset(e));else{let a=this.areasPinById[e.annotationId].pinHostDomPortalOutlet;a&&(this.removeAreaPinHostAttributes(e.annotationId,this.areasPinById[e.annotationId].pinHostElement),a.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 pt(He),c=new ut(n,this.appRef,this.injector),a=c.attach(o);a.instance.setAreaPinAnnotation(JSON.parse(JSON.stringify(e))),a.instance.targetElement=t,this.areasPinById[e.annotationId]={pinHostDomPortalOutlet:c,pinPortal:o,portalRef:a,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)&&(Ot(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(","),c=o.indexOf(e);c>-1&&(o.splice(c,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],c=this.domService.getElementOffset(n,o);t.instance.setOffsetLeft(c.offsetLeft),t.instance.setOffsetTop(c.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)(_(X),_(Je),_(Xe),_(Qe),_(T))},l.\u0275prov=he({token:l,factory:l.\u0275fac,providedIn:"root"});let d=l;return d})();var Se=(()=>{let l=class l{constructor(e,t,n,o,c,a,r){this.analyticsService=e,this.authService=t,this.domService=n,this.areaService=o,this.areaPinPortalService=c,this.serviceBook=a,this.loggingService=r,this.areaPinAnnotations=[],this.subscriptions=[],this.isFirstComponent=!0,this.commentsOnDom=!0,this.commentService=null,this.veltId=yt(),this.veltElement=!0;try{this.loggingService.log("%c[WB] Creating CLASS: AreasContainerComponent","color: blue;"),this.serviceBook.observe(ee).subscribe(s=>{this.commentService=s})}catch(s){this.loggingService.catch("Error in AreasContainerComponent constructor: ",s)}}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($(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($(e=>!!e),A(e=>this.domService.getSelectedAnnotationsMap$().pipe(f(t=>({annotations:e,selectedAnnotationsMap:t||{}})))),A(e=>(this.commentService?.getCommentsOnDom$()??P(!0)).pipe(f(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===w.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(Et.AREA_COMMENT)}catch(e){this.loggingService.catch("Error in AreasContainerComponent setAreaInstalledInAnalytics: ",e)}}};l.\u0275fac=function(t){return new(t||l)(C(G),C(K),C(X),C(F),C($t),C(W),C(T))},l.\u0275cmp=te({type:l,selectors:[["snippyly-area-container"]],hostVars:2,hostBindings:function(t,n){t&2&&ne("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 en=["customBtnRef"],tn=["*"];function nn(d,l){if(d&1&&(O(0,"div",6),Ge(),O(1,"svg",7),qe(2,"path",8),M()()),d&2){let i=v();D(),q("active",i.addAreaMode)}}function on(d,l){d&1&&et(0)}function rn(d,l){d&1&&it(0)}var Pe=(()=>{let l=class l{constructor(e,t,n,o,c){this.analyticsService=e,this.authService=t,this.areaService=n,this.iamService=o,this.loggingService=c,this.showDefaultBtn=!1,this.addAreaMode=!1,this.subscriptions=[],this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(a=>{this.user=a},a=>{this.loggingService.catch("Error in AreasToolComponent getUser$ subscription: ",a)}))}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(L.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)(C(G),C(K),C(F),C(Ae),C(T))},l.\u0275cmp=te({type:l,selectors:[["snippyly-area-tool"]],viewQuery:function(t,n){if(t&1&&ot(en,5),t&2){let o;rt(o=at())&&(n.customBtnRef=o.first)}},hostVars:1,hostBindings:function(t,n){t&2&&ne("data-velt-element",n.veltElement)},standalone:!1,ngContentSelectors:tn,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=ie();nt(),O(0,"div",2),R("click",function(a){return b(o),n.addArea(),y(a.stopPropagation())}),j(1,nn,3,2,"div",3),O(2,"div",4,0),j(4,on,1,0,"ng-container",5),M()(),j(5,rn,1,0,"ng-template",null,1,ct)}if(t&2){let o=st(6);q("active",n.addAreaMode),D(),x("ngIf",n.showDefaultBtn),D(3),x("ngTemplateOutlet",o)}},dependencies:[ge,dt],encapsulation:2,changeDetection:0});let d=l;return d})();var Ee=class extends zt{constructor(l){super(l),this.getService(T).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(T).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(L.Events.Area.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(F).enableArea()}catch(l){this.getService(T).catch("Error in _enableAreaComment: ",l)}}_disableAreaComment(){this.getService(T).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(L.Events.Area.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(F).disableArea()}catch(l){this.getService(T).catch("Error in _disableAreaComment: ",l)}}};var jt=(()=>{let l=class l{};l.\u0275fac=function(t){return new(t||l)},l.\u0275mod=Ze({type:l}),l.\u0275inj=We({imports:[mt,At,ft,gt,Ft]});let d=l;return d})();function an(d){d.get(T).log("%c[WB] Loading area feature chunk","color: blue;"),d.get(W).set(Lt,d.get(F));let t=Ye(jt,d).injector;return Ce(t,h.TAGS.VELT_AREA_TOOL,Pe),Ce(t,h.TAGS.SNIPPYLY_AREA_TOOL,Pe),Ce(t,h.TAGS.VELT_AREAS,Se),Ce(t,h.TAGS.SNIPPYLY_AREAS,Se),new Ee(d)}function Ce(d,l,i){if(customElements.get(l))return;let e=vt(i,{injector:d});customElements.define(l,e)}export{an as default};
|
package/velt-arrow.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as zt,c as Gt,d as Xt}from"./chunk-VMY3F7K3.js";import{b as ue}from"./chunk-CQX575C2.js";import{a as we}from"./chunk-FUYX2CTL.js";import{a as ut}from"./chunk-RLD74EXO.js";import{a as Kt}from"./chunk-QTF4Y24I.js";import{Y as qt,da as pt,ea as me,ga as pe,r as Yt,t as Jt}from"./chunk-3ORHWUHZ.js";import{$ as j,Ai as le,Bf as Ct,Ch as _,Db as X,E as I,Eb as Y,Ed as Qt,Ee as d,Eh as ae,Fa as O,Fb as J,Fh as se,Fi as ge,G as Ot,Ga as at,Gc as ct,Gi as de,He as gt,J as F,Jb as K,Kb as N,Kc as $t,L as St,Ma as Wt,Ne as Zt,Pa as p,Pc as lt,Pi as he,T as f,Ua as k,Uf as te,Vf as ee,Ya as kt,Yf as re,_a as $,_b as Ut,a as w,b as y,bb as Bt,bc as jt,bh as ht,ca as v,db as B,eh as ie,fh as ne,g as At,gg as dt,ha as E,ia as C,ii as mt,ja as et,ji as x,ki as A,l as tt,la as Rt,lb as R,le as Et,li as ce,mb as W,nb as z,ob as st,oe as H,pb as rt,qa as Mt,qb as Nt,qg as yt,qh as oe,r as P,rb as Ht,sb as xt,si as D,tb as Vt,tg as bt,ti as V,ua as Lt,v as S,vb as G,wa as ot,wb as Ft,xb as U,yb as Pt,zb as b}from"./chunk-VKGZ33MA.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(ge),v(le),v(V),v(D),v(Qt),v(ut),v(qt),v(A),v(mt),v(he))},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-FC5NQAL4.js";import{b as ue}from"./chunk-O7XCI74W.js";import{a as we}from"./chunk-4RMON7GG.js";import{a as ut}from"./chunk-6YWJCXYF.js";import{a as Kt}from"./chunk-SGVDVSBF.js";import{Y as qt,da as pt,ea as me,ga as pe,r as Yt,t as Jt}from"./chunk-WASG3GA7.js";import{$ as j,Bf as Ct,Db as X,Di as le,E as I,Eb as Y,Ed as Qt,Ee as d,Fa as O,Fb as J,Fh as _,G as Ot,Ga as at,Gc as ct,He as gt,Hh as ae,Ih as se,Ii as ge,J as F,Jb as K,Ji as de,Kb as N,Kc as $t,L as St,Ma as Wt,Ne as Zt,Pa as p,Pc as lt,Si as he,T as f,Ua as k,Uf as te,Vf as ee,Ya as kt,Yf as re,_a as $,_b as Ut,a as w,b as y,bb as Bt,bc as jt,ca as v,db as B,eh as ht,g as At,gg as dt,ha as E,hh as ie,ia as C,ih as ne,ja as et,l as tt,la as Rt,lb as R,le as Et,li as mt,mb as W,mi as x,nb as z,ni as A,ob as st,oe as H,oi as ce,pb as rt,qa as Mt,qb as Nt,qg as yt,r as P,rb as Ht,sb as xt,tb as Vt,tg as bt,th as oe,ua as Lt,v as S,vb as G,vi as D,wa as ot,wb as Ft,wi as V,xb as U,yb as Pt,zb as b}from"./chunk-Z3CHFM5M.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(ge),v(le),v(V),v(D),v(Qt),v(ut),v(qt),v(A),v(mt),v(he))},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(de))},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,{injector:l});customElements.define(s,t)}export{Le as default};
|