@veltdev/sdk-dev 6.0.17-beta.1 → 6.0.18
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/app/models/data/comment-resolver.data.model.d.ts +23 -0
- package/app/models/element/comment-element.model.d.ts +2 -2
- package/{chunk-F5REFWTQ.js → chunk-2IJ3Z5ZV.js} +1 -1
- package/{chunk-5H4ODM5U.js → chunk-2NGUPIJA.js} +1 -1
- package/{chunk-D24LAR5L.js → chunk-3IPAYZ7Y.js} +1 -1
- package/{chunk-FFTR7QJM.js → chunk-4I63DKJ7.js} +1 -1
- package/{chunk-KHL24R7O.js → chunk-4YYL5LBM.js} +1 -1
- package/{chunk-44HAZKIE.js → chunk-6TEVC4VB.js} +1 -1
- package/{chunk-BB2UXAYE.js → chunk-6YDKDS43.js} +1 -1
- package/chunk-76EHFLIO.js +1 -0
- package/{chunk-AWSU4IMS.js → chunk-BDVYEZ5H.js} +1 -1
- package/{chunk-DFQFM4NV.js → chunk-BKZUXK5Q.js} +1 -1
- package/{chunk-ZPO5AK7X.js → chunk-BOHOH3YV.js} +1 -1
- package/{chunk-RGBU7P5H.js → chunk-D6IQX3MS.js} +1 -1
- package/chunk-DR75AZG3.js +1 -0
- package/{chunk-HEFEC6O6.js → chunk-EVKWK3QF.js} +1 -1
- package/{chunk-MVVXZ2D6.js → chunk-FL7TUF6U.js} +1 -1
- package/{chunk-2BXOD5Z7.js → chunk-GXA7WFCW.js} +1 -1
- package/{chunk-FEA5HRMI.js → chunk-HKOM6NRJ.js} +1 -1
- package/{chunk-XZD6KKXD.js → chunk-JFPFA27E.js} +1 -1
- package/{chunk-VECW5ME3.js → chunk-JPR7TB3V.js} +1 -1
- package/chunk-LFLSU76Z.js +1 -0
- package/{chunk-LEIUFK3K.js → chunk-MIPUERB4.js} +1 -1
- package/chunk-MV36YVGA.js +174 -0
- package/{chunk-NSGBIR4C.js → chunk-NXVDUKNP.js} +1 -1
- package/{chunk-ND3RYLBW.js → chunk-P3UR2XTS.js} +1 -1
- package/{chunk-QZ5UHEP2.js → chunk-PKCY7NTA.js} +1 -1
- package/chunk-RBD735AI.js +1 -0
- package/{chunk-IUD3QEEM.js → chunk-T7KP622G.js} +1 -1
- package/{chunk-CYAQOX2W.js → chunk-TQYZX2M7.js} +1 -1
- package/{chunk-FPEVLQAP.js → chunk-TT7PKTGG.js} +1 -1
- package/{chunk-UCURXRPI.js → chunk-TZAGYSHE.js} +1 -1
- package/{chunk-BTNNHMUJ.js → chunk-UV3WG5EA.js} +1 -1
- package/{chunk-OLHFUO6O.js → chunk-VXHKBDMP.js} +1 -1
- package/chunk-WN7NM6YW.js +1 -0
- package/{chunk-6P3LPEPY.js → chunk-XMTWJMU7.js} +1 -1
- package/{chunk-SKNIB72F.js → chunk-YFUTJBEE.js} +1 -1
- package/package.json +1 -1
- package/velt-activity-log.js +1 -1
- package/velt-area.js +1 -1
- package/velt-arrow.js +1 -1
- package/velt-comment.js +6 -6
- package/velt-crdt.js +1 -1
- package/velt-cursor.js +1 -1
- package/velt-huddle.js +1 -1
- package/velt-live-state-sync.js +1 -1
- package/velt-notification.js +1 -1
- package/velt-portable.js +1 -1
- package/velt-presence.js +1 -1
- package/velt-reaction.js +1 -1
- package/velt-recorder.js +1 -1
- package/velt-rewriter.js +1 -1
- package/velt-selection.js +1 -1
- package/velt-tag.js +1 -1
- package/velt-user-invite.js +1 -1
- package/velt-user-request.js +1 -1
- package/velt-video-player.js +1 -1
- package/velt-views.js +1 -1
- package/velt.js +3 -3
- package/chunk-5ZUX3AU3.js +0 -1
- package/chunk-A52PJCIA.js +0 -1
- package/chunk-B3U3OLF6.js +0 -1
- package/chunk-EPQLN2EE.js +0 -1
- package/chunk-SMANT45B.js +0 -1
- package/chunk-TAGMM5ED.js +0 -174
package/velt-rewriter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Dt,b as Lt}from"./chunk-BTNNHMUJ.js";import{t as Mt}from"./chunk-SKNIB72F.js";import"./chunk-LEIUFK3K.js";import{b as et,c as tt,g as it,l as nt}from"./chunk-FEA5HRMI.js";import{c as Ze,d as We}from"./chunk-AWSU4IMS.js";import{a as at,c as st,d as ct}from"./chunk-UCURXRPI.js";import"./chunk-BB2UXAYE.js";import{a as Pt}from"./chunk-CYAQOX2W.js";import"./chunk-HEFEC6O6.js";import"./chunk-KHL24R7O.js";import{b as At}from"./chunk-MVVXZ2D6.js";import{a as qe}from"./chunk-ND3RYLBW.js";import{A as Xe,G as ze,H as Qe,I as Ke,r as $e,t as Ye}from"./chunk-IUD3QEEM.js";import{a as kt}from"./chunk-FFTR7QJM.js";import"./chunk-EPQLN2EE.js";import{Bb as p,E as le,Fb as re,Ff as gt,Fj as B,Ga as Ve,Gb as oe,Gg as Ee,Gj as _e,Ha as g,Hb as ae,Hc as je,He as x,Hg as de,Hi as Rt,Ia as me,Ic as ge,Ig as ht,Ii as Et,K as Pe,Kb as W,Lg as Ct,Mb as L,Oa as Ne,Pb as D,Qb as se,Qd as Je,Qi as Tt,Ra as R,Rb as N,Rc as Ge,Rg as _t,Ri as bt,Tg as he,Ub as Se,Ug as ut,V as Me,Va as Be,Vb as ye,Vd as rt,Vg as Ce,Wa as G,Wb as Re,Wd as ot,Wg as ft,Xa as He,Xe as pt,Xi as q,Yi as J,Ze as mt,Zi as h,_i as It,a as M,ab as E,b as k,ba as z,ca as ke,cc as Ue,ce as lt,cj as Ot,db as Fe,ea as b,fa as De,fb as Z,g as V,gh as vt,hi as xt,ja as C,ji as St,k as xe,ka as _,l as X,la as I,ma as F,mc as v,na as Le,nb as u,nc as w,nh as wt,ob as c,pb as l,pi as O,qb as f,qi as yt,r as j,rc as $,rg as dt,sa as pe,ub as Q,v as Oe,vb as K,xb as A,z as Ae,zb as S}from"./chunk-TAGMM5ED.js";var te=(()=>{let o=class o{constructor(e){this.loggingService=e,this.actionSubjects=new Map}onTextSelected(e){try{this.triggerAction(lt.TEXT_SELECTED,e)}catch(t){this.loggingService.catch("Error in RewriterActionsService onTextSelected: ",t)}}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new xe),this.actionSubjects.get(e)?.next(t)}catch(i){this.loggingService.catch("Error in RewriterActionsService triggerAction: ",i)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new xe),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in RewriterActionsService onAction: ",t),j(null)}}};o.\u0275fac=function(t){return new(t||o)(b(h))},o.\u0275prov=z({token:o,factory:o.\u0275fac,providedIn:"root"});let r=o;return r})();var P=(()=>{let o=class o{constructor(e,t,i,a,s,m,d,y){this.analyticsService=e,this.authService=t,this.configService=i,this.domService=a,this.loggingService=s,this.functions=m,this.rewriterActionsService=d,this.serviceBook=y,this.endpointsService=De(Ot),this.rewriterAnnotations$=new X([]),this.rewriterEnabled$=new X(!1),this.defaultUIEnabled$=new X(!0),this.commentActionsService=null,this.latestSelection=null,this.replaceTextInFlight=!1,this.addCommentInFlight=!1,this.serviceBook.observe(Et).subscribe(T=>this.commentActionsService=T),this.getRewriterEnabled$().subscribe(T=>{try{if(T){let H=document.querySelectorAll(x.TAGS.SNIPPYLY_REWRITER);if(!document.querySelectorAll(x.TAGS.VELT_REWRITER)?.length&&!H?.length){let U=document.createElement(x.TAGS.VELT_REWRITER);document.body.appendChild(U),this.authService.getUser$().pipe(le(ne=>!!ne),Pe(1)).subscribe(ne=>{this.analyticsService.trackEvent(O.Events.Rewriter.REWRITER_ENABLED,{isMobileDevice:this.domService.isMobileDevice()})})}}else{let H=document.querySelectorAll(x.TAGS.SNIPPYLY_REWRITER);H?.length&&H.forEach(U=>{U.remove()});let ie=document.querySelectorAll(x.TAGS.VELT_REWRITER);ie?.length&&ie.forEach(U=>{U.remove()})}}catch(H){this.loggingService.catch("Error in rewriterEnabled$: ",H)}},T=>{this.loggingService.catch("Error in rewriterEnabled$ subscription: ",T)})}getRewriterAnnotations$(){try{return this.rewriterAnnotations$.asObservable()}catch(e){return this.loggingService.catch("Error in getRewriterAnnotations$(): ",e),j([])}}addRewriter(e,t,i){this.loggingService.log("%c[WB] Calling FUNCTION: addRewriter","color: green;");try{let a=this.authService.getUser();if(a)if(a.isReadOnly||a.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add rewriters.");else{let s=new gt;s.from=a,s.color=x.DEFAULT_ANNOTATION_COLOR,t&&(s.targetTextRange=t),i&&(s.rewriterType=i),this.saveRewriterToDb(s)}}catch(a){this.loggingService.catch("Error in RewriterService addRewriter: ",a)}}saveRewriterToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveRewriterToDb","color: green;");try{e?.annotationId||(e.annotationId=Math.random().toString(36).substring(2)+Date.now().toString(36));let t=this.rewriterAnnotations$.getValue();t.push(e),this.rewriterAnnotations$.next(t),this.domService.toggleAnnotationSelection(e)}catch(t){this.loggingService.catch("Error in RewriterService saveRewriterToDb: ",t)}}removeRewriter(e){try{let t=this.rewriterAnnotations$.getValue(),i=t.findIndex(a=>a.annotationId===e.annotationId);i>-1&&(t.splice(i,1),this.rewriterAnnotations$.next(t))}catch(t){this.loggingService.catch("Error in RewriterService removeRewriter: ",t)}}enableRewriter(){try{this.rewriterEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in RewriterService enableRewriter: ",e)}}disableRewriter(){try{this.rewriterEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in RewriterService disableRewriter: ",e)}}getRewriterEnabled$(){try{return this.rewriterEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in RewriterService getRewriterEnabled$: ",e),j(!1)}}enableDefaultUI(){try{this.defaultUIEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in RewriterService enableDefaultUI: ",e)}}disableDefaultUI(){try{this.defaultUIEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in RewriterService disableDefaultUI: ",e)}}getDefaultUIEnabled$(){try{return this.defaultUIEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in RewriterService getDefaultUIEnabled$: ",e),j(!0)}}resetRewriter(){try{this.domService.resetSelectedAnnotationsMap(!1,"rewriter"),this.rewriterAnnotations$.next([])}catch(e){this.loggingService.catch("Error in RewriterService resetRewriter: ",e)}}generateSelectionId(){try{return Math.random().toString(36).substring(2)+Date.now().toString(36)}catch(e){return this.loggingService.catch("Error in RewriterService generateSelectionId:",e),Date.now().toString(36)}}storeSelection(e,t){try{this.latestSelection={event:e,range:t}}catch(i){this.loggingService.catch("Error in RewriterService storeSelection: ",i)}}getSelectionById(e){try{return this.latestSelection?.event.selectionId===e?this.latestSelection:null}catch(t){return this.loggingService.catch("Error in RewriterService getSelectionById:",t),null}}emitAndStoreTextSelected(e,t){try{if(he(e)){this.loggingService.log("[Velt] rewriter textSelected skipped: the selection touches a ProseMirror/TipTap editor.");return}let i=this.domService.getTargetTextRangeFromSelectionRange(e);if(!i)return;let s={selectionId:this.generateSelectionId(),text:t,targetTextRange:i};this.rewriterActionsService.onTextSelected(s),this.storeSelection(s,e)}catch(i){this.loggingService.catch("Error in RewriterService emitAndStoreTextSelected:",i)}}isReplaceTextInFlight(){return this.replaceTextInFlight}setReplaceTextInFlight(e){this.replaceTextInFlight=e}isAddCommentInFlight(){return this.addCommentInFlight}setAddCommentInFlight(e){this.addCommentInFlight=e}askAi(e){return V(this,null,function*(){try{if(!e.selectedText?.trim())return{text:"",success:!1,error:"No text provided"};let t=this.authService.getUser()?.userId;if(!t)return{text:"",success:!1,error:"User not authenticated"};let i=yt(this.functions,St({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()})),a=yield xt({methodName:"rewriterAskAi",data:{type:"rewriterAskAi",data:{model:e.model,prompt:e.prompt,text:e.selectedText}},getSdkProxy:i,userId:t});return Gt(a)}catch(t){return this.loggingService.catch("Error in RewriterService askAi: ",t),{text:"",success:!1,error:"Failed to call AI completion"}}})}replaceText(e){return V(this,null,function*(){try{if(this.replaceTextInFlight)return{success:!1,originalText:"",replacedText:"",error:"Operation already in progress"};this.replaceTextInFlight=!0;try{let t=e.event.targetTextRange,i=e.event.text;return!t?.text||!t?.commonAncestorContainer?{success:!1,originalText:"",replacedText:"",error:"Invalid selection data"}:e.text?.trim()?this.replaceTextInDom(t,e.text)?{success:!0,originalText:i,replacedText:e.text}:{success:!1,originalText:i,replacedText:"",error:"Failed to replace text in DOM"}:{success:!1,originalText:i,replacedText:"",error:"Replacement text is empty"}}finally{this.replaceTextInFlight=!1}}catch(t){return this.loggingService.catch("Error in RewriterService replaceText: ",t),{success:!1,originalText:"",replacedText:"",error:"An unexpected error occurred"}}})}addComment(e){return V(this,null,function*(){try{if(this.addCommentInFlight)return{success:!1,error:"Operation already in progress"};this.addCommentInFlight=!0;try{let t=e.event.targetTextRange;if(!t?.text||!t?.commonAncestorContainer)return{success:!1,error:"Invalid selection data"};if(!e.text?.trim())return{success:!1,error:"Comment text is empty"};let i=this.authService.getUser();if(!i)return{success:!1,error:"User not authenticated"};let a=this.getRangeFromTargetTextRange(t);if(!a)return{success:!1,error:"Could not locate selected text in DOM"};let s=new pt;s.annotationId=Math.random().toString(36).substring(2)+Date.now().toString(36),s.from=i,s.color=x.DEFAULT_ANNOTATION_COLOR,s.targetTextRange=t;let m=a.getBoundingClientRect();s.positionX=m.x,s.positionY=m.y,s.screenWidth=window.innerWidth,s.screenHeight=window.innerHeight;let d=new mt;return d.commentText=e.text,d.from=i,s.comments=[d],yield this.commentActionsService?.addCommentAnnotation({annotation:s},"external"),{success:!0,annotationId:s.annotationId,commentText:e.text}}finally{this.addCommentInFlight=!1}}catch(t){return this.loggingService.catch("Error in RewriterService addComment: ",t),{success:!1,error:"An unexpected error occurred"}}})}getRangeFromTargetTextRange(e){try{if(!e?.text||!e?.commonAncestorContainer)return null;let t=this.domService.getElementFromTargetTextRange(e);if(!t)return null;let i=de(e.text,t,e.occurrence);if(!i?.length)return null;let a=new Range;return a.setStart(i[0].textNode,i[0].startOffset||0),a.setEnd(i[i.length-1].textNode,i[i.length-1].endOffset||0),a.toString()!==e.text?null:a}catch(t){return this.loggingService.catch("Error in RewriterService getRangeFromTargetTextRange: ",t),null}}replaceTextInDom(e,t){try{let i=this.getRangeFromTargetTextRange(e);return i?ut(i)||!ft(i)?(this.loggingService.log("[Velt] rewriter replaceText skipped: the selection touches a ProseMirror/TipTap editor."),!1):(i.deleteContents(),i.insertNode(document.createTextNode(t)),Ce(i.commonAncestorContainer.parentElement),!0):(this.loggingService.catch("Error in RewriterService replaceTextInDom: Could not reconstruct range from targetTextRange"),!1)}catch(i){return this.loggingService.catch("Error in RewriterService replaceTextInDom: ",i),!1}}};o.\u0275fac=function(t){return new(t||o)(b(J),b(_e),b(It),b(B),b(h),b(Je),b(te),b(q))},o.\u0275prov=z({token:o,factory:o.\u0275fac,providedIn:"root"});let r=o;return r})();function Gt(r){return r?.text?{text:r.text,success:!0}:r?.error?{text:"",success:!1,error:r.error}:{text:"",success:!1,error:"AI returned empty response"}}var Wt=["copywriterContainer"],$t=["searchInput"];function Yt(r,o){}function Xt(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",35)(3,"rect",36),l())}function zt(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",36),l())}function Qt(r,o){if(r&1){let n=A();Q(0),c(1,"div",30),S("click",function(t){let i=C(n).index,a=p(3).ngIf,s=p();return a.selectedOptionIndex===i?t.stopPropagation():s.onSelectOption(i),_(t.stopPropagation())}),E(2,Xt,4,0,"svg",31)(3,zt,3,0,"ng-template",null,3,$),c(5,"span",32),D(6),l()(),K()}if(r&2){let n=o.$implicit,e=o.index,t=W(4),i=p(3).ngIf;g(),L("s-selected",i.selectedOptionIndex===e),g(),u("ngIf",i.selectedOptionIndex===e)("ngIfElse",t),g(4),se(n)}}function Kt(r,o){r&1&&(c(0,"div",37),I(),c(1,"svg",38)(2,"circle",39),f(3,"animate",40),l(),c(4,"circle",41),f(5,"animate",42),l(),c(6,"circle",43),f(7,"animate",44),l(),c(8,"circle",45),f(9,"animate",46),l()()())}function qt(r,o){if(r&1){let n=A();c(0,"span",47),S("click",function(){C(n);let t=p(4);return _(t.onShowOriginalTextClick())}),D(1),v(2,"translate"),l()}r&2&&(g(),se(w(2,1,"Show original text")))}function Jt(r,o){r&1&&(c(0,"div",16),D(1),v(2,"translate"),l()),r&2&&(g(),N(" ",w(2,1,"Select a rewritten text to create a task")))}function ei(r,o){if(r&1){let n=A();c(0,"button",48),S("click",function(t){C(n);let i=p(3).ngIf,a=p();return i.selectedOptionIndex<0||a.createTask(),_(t.stopPropagation())}),E(1,Jt,3,3,"div",49),D(2),v(3,"translate"),l()}if(r&2){let n=p(3).ngIf;L("disabled",n.selectedOptionIndex<0),g(),u("ngIf",n.selectedOptionIndex<0),g(),N(" ",w(3,4,"Create Task")," ")}}function ti(r,o){if(r&1){let n=A();c(0,"div",9),S("pointerdown",function(t){return C(n),_(t.stopPropagation())})("click",function(t){return C(n),_(t.stopPropagation())}),c(1,"div",10)(2,"div",11),I(),c(3,"svg",12)(4,"g"),f(5,"path",13),l()(),D(6),v(7,"translate"),l(),F(),c(8,"div",14)(9,"div",15),S("click",function(){C(n);let t=p(2).ngIf,i=p();return _(!t.loading&&t.searchCount<3?i.onRefresh():null)}),c(10,"div",16),D(11),v(12,"translate"),v(13,"translate"),v(14,"translate"),v(15,"translate"),v(16,"translate"),l(),I(),c(17,"svg",17),f(18,"path",18),l()(),F(),c(19,"div",19),S("click",function(t){return C(n),p(3).onCloseDialog(),_(t.stopPropagation())}),I(),c(20,"svg",17),f(21,"path",20),l()()()(),F(),c(22,"div",21),E(23,Qt,7,5,"ng-container",22)(24,Kt,10,0,"div",23),l(),c(25,"div",24),E(26,qt,3,3,"span",25),f(27,"div"),E(28,ei,4,6,"button",26),l(),I(),c(29,"svg",27),f(30,"path",28)(31,"path",29),l()()}if(r&2){let n=p(2).ngIf;L("bottom-sheet",n.bottomSheetMode),g(6),N(" ",w(7,10,"Rewrite")," "),g(3),L("disabled",n.loading||n.searchCount>=3),g(2),N("",n.loading?w(12,12,"Getting data ..."):n.searchCount===0?w(13,14,"Get more options"):n.searchCount<3?w(14,16,"Get more options")+" ("+(3-n.searchCount)+" "+w(15,18,"left")+")":w(16,20,"Max 3 rewrites allowed")," "),g(12),u("ngForOf",n.options),g(),u("ngIf",n.loading),g(2),u("ngIf",n.selectedOptionIndex>=0),g(2),u("ngIf",n.options==null?null:n.options.length)}}function ii(r,o){if(r&1&&E(0,ti,32,22,"div",8),r&2){let n=p(2);u("ngIf",n.type==="copywriter")}}function ni(r,o){if(r&1){let n=A();c(0,"div",55),S("click",function(){C(n);let t=p(4);return _(t.getRewriterOptions())}),I(),c(1,"svg",56),f(2,"path",57),l()()}if(r&2){let n=p(4);L("disabled",!(n.prompt!=null&&n.prompt.length))}}function ri(r,o){if(r&1){let n=A();c(0,"div",9),S("pointerdown",function(t){return C(n),_(t.stopPropagation())})("click",function(t){return C(n),_(t.stopPropagation())}),c(1,"div",50)(2,"div",10)(3,"div",11),I(),c(4,"svg",51),f(5,"path",52),l(),F(),c(6,"input",53,4),v(8,"translate"),Re("ngModelChange",function(t){C(n);let i=p(3);return ye(i.prompt,t)||(i.prompt=t),_(t)}),S("keyup.enter",function(){C(n);let t=p(3);return _(t.getRewriterOptions())}),l()(),E(9,ni,3,2,"div",54),l()()()}if(r&2){let n=p(2).ngIf,e=p();L("bottom-sheet",n.bottomSheetMode),g(6),u("placeholder",w(8,6,"How would you like to change this copy?")),Se("ngModel",e.prompt),u("disabled",n.loading||n.searchCount>=e.MAX_SEARCH_COUNT),g(3),u("ngIf",!n.loading)}}function oi(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",35)(3,"rect",36),l())}function ai(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",36),l())}function si(r,o){if(r&1){let n=A();Q(0),c(1,"div",30),S("click",function(t){let i=C(n).index,a=p(3).ngIf,s=p();return a.selectedOptionIndex===i?t.stopPropagation():s.onSelectOption(i),_(t.stopPropagation())}),E(2,oi,4,0,"svg",31)(3,ai,3,0,"ng-template",null,3,$),c(5,"span",32),D(6),v(7,"translate"),l()(),K()}if(r&2){let n=o.$implicit,e=o.index,t=W(4),i=p(3).ngIf;g(),L("s-selected",i.selectedOptionIndex===e),g(),u("ngIf",i.selectedOptionIndex===e)("ngIfElse",t),g(4),se(w(7,5,n))}}function ci(r,o){r&1&&(c(0,"div",37),I(),c(1,"svg",38)(2,"circle",39),f(3,"animate",40),l(),c(4,"circle",41),f(5,"animate",42),l(),c(6,"circle",43),f(7,"animate",44),l(),c(8,"circle",45),f(9,"animate",46),l()()())}function li(r,o){if(r&1){let n=A();c(0,"span",47),S("click",function(){C(n);let t=p(4);return _(t.onShowOriginalTextClick())}),D(1),v(2,"translate"),l()}r&2&&(g(),se(w(2,1,"Show original text")))}function pi(r,o){r&1&&(c(0,"div",16),D(1),v(2,"translate"),l()),r&2&&(g(),N(" ",w(2,1,"Select a rewritten text to create a task")))}function mi(r,o){if(r&1){let n=A();c(0,"button",48),S("click",function(t){C(n);let i=p(3).ngIf,a=p();return i.selectedOptionIndex<0||a.createTask(),_(t.stopPropagation())}),E(1,pi,3,3,"div",49),D(2),v(3,"translate"),l()}if(r&2){let n=p(3).ngIf;L("disabled",n.selectedOptionIndex<0),g(),u("ngIf",n.selectedOptionIndex<0),g(),N(" ",w(3,4,"Create Task")," ")}}function gi(r,o){if(r&1){let n=A();c(0,"div",9),S("pointerdown",function(t){return C(n),_(t.stopPropagation())})("click",function(t){return C(n),_(t.stopPropagation())}),c(1,"div",50)(2,"div",10)(3,"div",11),I(),c(4,"svg",51),f(5,"path",52),l(),F(),c(6,"input",53,4),v(8,"translate"),Re("ngModelChange",function(t){C(n);let i=p(3);return ye(i.prompt,t)||(i.prompt=t),_(t)}),S("keyup.enter",function(){C(n);let t=p(3);return _(t.getRewriterOptions())}),l()(),c(9,"div",58),S("click",function(){C(n);let t=p(2).ngIf,i=p();return _(t.loading?null:i.getRewriterOptions())}),c(10,"div",16),D(11),v(12,"translate"),v(13,"translate"),v(14,"translate"),v(15,"translate"),v(16,"translate"),l(),I(),c(17,"svg",56),f(18,"path",59),l()()(),F(),f(19,"hr",60),l(),c(20,"div",10)(21,"div",11),D(22),v(23,"translate"),l(),c(24,"div",14)(25,"div",15),S("click",function(){C(n);let t=p(2).ngIf,i=p();return _(!t.loading&&t.searchCount<3?i.onRefresh():null)}),c(26,"div",16),D(27),v(28,"translate"),v(29,"translate"),v(30,"translate"),v(31,"translate"),v(32,"translate"),l(),I(),c(33,"svg",17),f(34,"path",18),l()(),F(),c(35,"div",19),S("click",function(t){return C(n),p(3).onCloseDialog(),_(t.stopPropagation())}),I(),c(36,"svg",17),f(37,"path",20),l()()()(),F(),c(38,"div",21),E(39,si,8,7,"ng-container",22),l(),E(40,ci,10,0,"div",23),c(41,"div",24),E(42,li,3,3,"span",25),f(43,"div"),E(44,mi,4,6,"button",26),l(),I(),c(45,"svg",27),f(46,"path",28)(47,"path",29),l()()}if(r&2){let n=p(2).ngIf,e=p();L("bottom-sheet",n.bottomSheetMode),g(6),u("placeholder",w(8,16,"How would you like to change this copy?")),Se("ngModel",e.prompt),u("disabled",n.loading||n.searchCount>=e.MAX_SEARCH_COUNT),g(3),L("disabled",n.loading||n.searchCount>=3),g(2),N("",n.loading?w(12,18,"Getting data ..."):n.searchCount===0?w(13,20,"Get more options"):n.searchCount<3?w(14,22,"Get more options")+" ("+(3-n.searchCount)+" "+w(15,24,"left")+")":w(16,26,"Max 3 rewrites allowed")," "),g(11),N(" ",w(23,28,"Suggestions")," "),g(3),L("disabled",n.loading||n.searchCount>=3),g(2),N("",n.loading?w(28,30,"Getting data ..."):n.searchCount===0?w(29,32,"Get more options"):n.searchCount<3?w(30,34,"Get more options")+" ("+(3-n.searchCount)+" "+w(31,36,"left")+")":w(32,38,"Max 3 rewrites allowed")," "),g(12),u("ngForOf",n.options),g(),u("ngIf",n.loading),g(2),u("ngIf",n.selectedOptionIndex>=0),g(2),u("ngIf",n.options==null?null:n.options.length)}}function di(r,o){if(r&1&&E(0,ri,10,8,"div",8)(1,gi,48,40,"div",8),r&2){let n=p().ngIf;u("ngIf",!n.apiCalled),g(),u("ngIf",n.apiCalled)}}function hi(r,o){if(r&1){let n=A();Q(0),c(1,"div",6,0),S("clickOutside",function(){C(n);let t=p();return _(t.onClickOutside())}),E(3,Yt,0,0,"ng-template",7),l(),E(4,ii,1,1,"ng-template",null,1,$)(6,di,2,2,"ng-template",null,2,$),K()}if(r&2){let n=W(5),e=W(7),t=p();g(3),u("ngIf",t.type==="copywriter")("ngIfThen",n)("ngIfElse",e)}}var ce=(()=>{let o=class o{onClick(e){this.onClickOutside()}constructor(e,t,i,a,s,m){this.analyticsService=e,this.serviceBook=t,this.domService=i,this.loggingService=a,this.rewriterService=s,this.bottomSheetData=m,this.type="copywriter",this.selectOption=new me,this.hideDialog=!1,this.subscriptions=[],this.prompt="",this.lastAskAiCalledAt=0,this.MAX_SEARCH_COUNT=3,this.componentConfigSignal=pe({searchCount:0,loading:!1,bottomSheetMode:!1,apiCalled:!1,options:[],selectedOptionIndex:-1}),this.veltElement=!0,this.commentService=null,this.serviceBook.observe(Rt).subscribe(d=>{this.commentService=d}),m&&this.subscriptions.push(m.subscribe(d=>{d&&(this.bottomSheetContainerData=d,this.annotation=d.annotation,this.type=this.annotation?.rewriterType||"copywriter",this.componentConfigSignal.update(y=>k(M({},y),{bottomSheetMode:!0})),this.getRewriterOptions())}))}ngOnInit(){}ngAfterViewInit(){try{this.bottomSheetData||(this.type=this.annotation?.rewriterType||"copywriter",this.getRewriterOptions()),setTimeout(()=>{this.searchInput?.nativeElement&&this.searchInput?.nativeElement?.focus()},1e3)}catch(e){this.loggingService.catch("Error in RewriterDialogComponent ngAfterViewInit:",e)}}getRewriterOptions(){return V(this,null,function*(){try{if(this.type!=="copywriter"&&!this.prompt||this.lastAskAiCalledAt&&Date.now()-this.lastAskAiCalledAt<1e3)return;this.lastAskAiCalledAt=Date.now(),this.componentConfigSignal.update(d=>k(M({},d),{loading:!0}));let e=wt(this.annotation?.targetTextRange?.text?.trim()||""),t=e.join(" "),i=this.componentConfigSignal().options,a;this.type==="copywriter"?a=`Act as a website copywriter and rewrite this website copy in less than ${e?.length} words. Make it very simple, exciting and more compelling. Return exactly 3 different rewritten options, one per line. Do not number them or add any prefixes.`:a=`${this.prompt}
|
|
1
|
+
import{a as Dt,b as Lt}from"./chunk-UV3WG5EA.js";import{t as Mt}from"./chunk-YFUTJBEE.js";import"./chunk-MIPUERB4.js";import{b as et,c as tt,g as it,l as nt}from"./chunk-HKOM6NRJ.js";import{c as Ze,d as We}from"./chunk-BDVYEZ5H.js";import{a as at,c as st,d as ct}from"./chunk-TZAGYSHE.js";import"./chunk-6YDKDS43.js";import{a as Pt}from"./chunk-TQYZX2M7.js";import"./chunk-EVKWK3QF.js";import"./chunk-4YYL5LBM.js";import{b as At}from"./chunk-FL7TUF6U.js";import{a as qe}from"./chunk-P3UR2XTS.js";import{A as Xe,G as ze,H as Qe,I as Ke,r as $e,t as Ye}from"./chunk-T7KP622G.js";import{a as kt}from"./chunk-4I63DKJ7.js";import"./chunk-LFLSU76Z.js";import{$i as bt,Ai as yt,Bb as p,E as le,Fb as re,Ff as gt,Ga as Ve,Gb as oe,Ha as g,Hb as ae,Hc as je,He as x,Hg as Ee,Ia as me,Ic as ge,Ig as de,Jg as ht,K as Pe,Kb as W,Mb as L,Mg as Ct,Oa as Ne,Oj as B,Pb as D,Pj as _e,Qb as se,Qd as Je,Ra as R,Rb as N,Rc as Ge,Ri as Rt,Sg as _t,Si as Et,Ub as Se,Ug as he,V as Me,Va as Be,Vb as ye,Vd as rt,Vg as ut,Wa as G,Wb as Re,Wd as ot,Wg as Ce,Xa as He,Xe as pt,Xg as ft,Ze as mt,_i as Tt,a as M,ab as E,b as k,ba as z,ca as ke,cc as Ue,ce as lt,db as Fe,ea as b,fa as De,fb as Z,fj as q,g as V,gj as J,hh as vt,hj as h,ii as xt,ij as It,ja as C,k as xe,ka as _,ki as St,l as X,la as I,ma as F,mc as v,mj as Ot,na as Le,nb as u,nc as w,ob as c,oh as wt,pb as l,qb as f,r as j,rc as $,sa as pe,sg as dt,ub as Q,v as Oe,vb as K,xb as A,z as Ae,zb as S,zi as O}from"./chunk-MV36YVGA.js";var te=(()=>{let o=class o{constructor(e){this.loggingService=e,this.actionSubjects=new Map}onTextSelected(e){try{this.triggerAction(lt.TEXT_SELECTED,e)}catch(t){this.loggingService.catch("Error in RewriterActionsService onTextSelected: ",t)}}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new xe),this.actionSubjects.get(e)?.next(t)}catch(i){this.loggingService.catch("Error in RewriterActionsService triggerAction: ",i)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new xe),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in RewriterActionsService onAction: ",t),j(null)}}};o.\u0275fac=function(t){return new(t||o)(b(h))},o.\u0275prov=z({token:o,factory:o.\u0275fac,providedIn:"root"});let r=o;return r})();var P=(()=>{let o=class o{constructor(e,t,i,a,s,m,d,y){this.analyticsService=e,this.authService=t,this.configService=i,this.domService=a,this.loggingService=s,this.functions=m,this.rewriterActionsService=d,this.serviceBook=y,this.endpointsService=De(Ot),this.rewriterAnnotations$=new X([]),this.rewriterEnabled$=new X(!1),this.defaultUIEnabled$=new X(!0),this.commentActionsService=null,this.latestSelection=null,this.replaceTextInFlight=!1,this.addCommentInFlight=!1,this.serviceBook.observe(Et).subscribe(T=>this.commentActionsService=T),this.getRewriterEnabled$().subscribe(T=>{try{if(T){let H=document.querySelectorAll(x.TAGS.SNIPPYLY_REWRITER);if(!document.querySelectorAll(x.TAGS.VELT_REWRITER)?.length&&!H?.length){let U=document.createElement(x.TAGS.VELT_REWRITER);document.body.appendChild(U),this.authService.getUser$().pipe(le(ne=>!!ne),Pe(1)).subscribe(ne=>{this.analyticsService.trackEvent(O.Events.Rewriter.REWRITER_ENABLED,{isMobileDevice:this.domService.isMobileDevice()})})}}else{let H=document.querySelectorAll(x.TAGS.SNIPPYLY_REWRITER);H?.length&&H.forEach(U=>{U.remove()});let ie=document.querySelectorAll(x.TAGS.VELT_REWRITER);ie?.length&&ie.forEach(U=>{U.remove()})}}catch(H){this.loggingService.catch("Error in rewriterEnabled$: ",H)}},T=>{this.loggingService.catch("Error in rewriterEnabled$ subscription: ",T)})}getRewriterAnnotations$(){try{return this.rewriterAnnotations$.asObservable()}catch(e){return this.loggingService.catch("Error in getRewriterAnnotations$(): ",e),j([])}}addRewriter(e,t,i){this.loggingService.log("%c[WB] Calling FUNCTION: addRewriter","color: green;");try{let a=this.authService.getUser();if(a)if(a.isReadOnly||a.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add rewriters.");else{let s=new gt;s.from=a,s.color=x.DEFAULT_ANNOTATION_COLOR,t&&(s.targetTextRange=t),i&&(s.rewriterType=i),this.saveRewriterToDb(s)}}catch(a){this.loggingService.catch("Error in RewriterService addRewriter: ",a)}}saveRewriterToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveRewriterToDb","color: green;");try{e?.annotationId||(e.annotationId=Math.random().toString(36).substring(2)+Date.now().toString(36));let t=this.rewriterAnnotations$.getValue();t.push(e),this.rewriterAnnotations$.next(t),this.domService.toggleAnnotationSelection(e)}catch(t){this.loggingService.catch("Error in RewriterService saveRewriterToDb: ",t)}}removeRewriter(e){try{let t=this.rewriterAnnotations$.getValue(),i=t.findIndex(a=>a.annotationId===e.annotationId);i>-1&&(t.splice(i,1),this.rewriterAnnotations$.next(t))}catch(t){this.loggingService.catch("Error in RewriterService removeRewriter: ",t)}}enableRewriter(){try{this.rewriterEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in RewriterService enableRewriter: ",e)}}disableRewriter(){try{this.rewriterEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in RewriterService disableRewriter: ",e)}}getRewriterEnabled$(){try{return this.rewriterEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in RewriterService getRewriterEnabled$: ",e),j(!1)}}enableDefaultUI(){try{this.defaultUIEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in RewriterService enableDefaultUI: ",e)}}disableDefaultUI(){try{this.defaultUIEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in RewriterService disableDefaultUI: ",e)}}getDefaultUIEnabled$(){try{return this.defaultUIEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in RewriterService getDefaultUIEnabled$: ",e),j(!0)}}resetRewriter(){try{this.domService.resetSelectedAnnotationsMap(!1,"rewriter"),this.rewriterAnnotations$.next([])}catch(e){this.loggingService.catch("Error in RewriterService resetRewriter: ",e)}}generateSelectionId(){try{return Math.random().toString(36).substring(2)+Date.now().toString(36)}catch(e){return this.loggingService.catch("Error in RewriterService generateSelectionId:",e),Date.now().toString(36)}}storeSelection(e,t){try{this.latestSelection={event:e,range:t}}catch(i){this.loggingService.catch("Error in RewriterService storeSelection: ",i)}}getSelectionById(e){try{return this.latestSelection?.event.selectionId===e?this.latestSelection:null}catch(t){return this.loggingService.catch("Error in RewriterService getSelectionById:",t),null}}emitAndStoreTextSelected(e,t){try{if(he(e)){this.loggingService.log("[Velt] rewriter textSelected skipped: the selection touches a ProseMirror/TipTap editor.");return}let i=this.domService.getTargetTextRangeFromSelectionRange(e);if(!i)return;let s={selectionId:this.generateSelectionId(),text:t,targetTextRange:i};this.rewriterActionsService.onTextSelected(s),this.storeSelection(s,e)}catch(i){this.loggingService.catch("Error in RewriterService emitAndStoreTextSelected:",i)}}isReplaceTextInFlight(){return this.replaceTextInFlight}setReplaceTextInFlight(e){this.replaceTextInFlight=e}isAddCommentInFlight(){return this.addCommentInFlight}setAddCommentInFlight(e){this.addCommentInFlight=e}askAi(e){return V(this,null,function*(){try{if(!e.selectedText?.trim())return{text:"",success:!1,error:"No text provided"};let t=this.authService.getUser()?.userId;if(!t)return{text:"",success:!1,error:"User not authenticated"};let i=yt(this.functions,St({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()})),a=yield xt({methodName:"rewriterAskAi",data:{type:"rewriterAskAi",data:{model:e.model,prompt:e.prompt,text:e.selectedText}},getSdkProxy:i,userId:t});return Gt(a)}catch(t){return this.loggingService.catch("Error in RewriterService askAi: ",t),{text:"",success:!1,error:"Failed to call AI completion"}}})}replaceText(e){return V(this,null,function*(){try{if(this.replaceTextInFlight)return{success:!1,originalText:"",replacedText:"",error:"Operation already in progress"};this.replaceTextInFlight=!0;try{let t=e.event.targetTextRange,i=e.event.text;return!t?.text||!t?.commonAncestorContainer?{success:!1,originalText:"",replacedText:"",error:"Invalid selection data"}:e.text?.trim()?this.replaceTextInDom(t,e.text)?{success:!0,originalText:i,replacedText:e.text}:{success:!1,originalText:i,replacedText:"",error:"Failed to replace text in DOM"}:{success:!1,originalText:i,replacedText:"",error:"Replacement text is empty"}}finally{this.replaceTextInFlight=!1}}catch(t){return this.loggingService.catch("Error in RewriterService replaceText: ",t),{success:!1,originalText:"",replacedText:"",error:"An unexpected error occurred"}}})}addComment(e){return V(this,null,function*(){try{if(this.addCommentInFlight)return{success:!1,error:"Operation already in progress"};this.addCommentInFlight=!0;try{let t=e.event.targetTextRange;if(!t?.text||!t?.commonAncestorContainer)return{success:!1,error:"Invalid selection data"};if(!e.text?.trim())return{success:!1,error:"Comment text is empty"};let i=this.authService.getUser();if(!i)return{success:!1,error:"User not authenticated"};let a=this.getRangeFromTargetTextRange(t);if(!a)return{success:!1,error:"Could not locate selected text in DOM"};let s=new pt;s.annotationId=Math.random().toString(36).substring(2)+Date.now().toString(36),s.from=i,s.color=x.DEFAULT_ANNOTATION_COLOR,s.targetTextRange=t;let m=a.getBoundingClientRect();s.positionX=m.x,s.positionY=m.y,s.screenWidth=window.innerWidth,s.screenHeight=window.innerHeight;let d=new mt;return d.commentText=e.text,d.from=i,s.comments=[d],yield this.commentActionsService?.addCommentAnnotation({annotation:s},"external"),{success:!0,annotationId:s.annotationId,commentText:e.text}}finally{this.addCommentInFlight=!1}}catch(t){return this.loggingService.catch("Error in RewriterService addComment: ",t),{success:!1,error:"An unexpected error occurred"}}})}getRangeFromTargetTextRange(e){try{if(!e?.text||!e?.commonAncestorContainer)return null;let t=this.domService.getElementFromTargetTextRange(e);if(!t)return null;let i=de(e.text,t,e.occurrence);if(!i?.length)return null;let a=new Range;return a.setStart(i[0].textNode,i[0].startOffset||0),a.setEnd(i[i.length-1].textNode,i[i.length-1].endOffset||0),a.toString()!==e.text?null:a}catch(t){return this.loggingService.catch("Error in RewriterService getRangeFromTargetTextRange: ",t),null}}replaceTextInDom(e,t){try{let i=this.getRangeFromTargetTextRange(e);return i?ut(i)||!ft(i)?(this.loggingService.log("[Velt] rewriter replaceText skipped: the selection touches a ProseMirror/TipTap editor."),!1):(i.deleteContents(),i.insertNode(document.createTextNode(t)),Ce(i.commonAncestorContainer.parentElement),!0):(this.loggingService.catch("Error in RewriterService replaceTextInDom: Could not reconstruct range from targetTextRange"),!1)}catch(i){return this.loggingService.catch("Error in RewriterService replaceTextInDom: ",i),!1}}};o.\u0275fac=function(t){return new(t||o)(b(J),b(_e),b(It),b(B),b(h),b(Je),b(te),b(q))},o.\u0275prov=z({token:o,factory:o.\u0275fac,providedIn:"root"});let r=o;return r})();function Gt(r){return r?.text?{text:r.text,success:!0}:r?.error?{text:"",success:!1,error:r.error}:{text:"",success:!1,error:"AI returned empty response"}}var Wt=["copywriterContainer"],$t=["searchInput"];function Yt(r,o){}function Xt(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",35)(3,"rect",36),l())}function zt(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",36),l())}function Qt(r,o){if(r&1){let n=A();Q(0),c(1,"div",30),S("click",function(t){let i=C(n).index,a=p(3).ngIf,s=p();return a.selectedOptionIndex===i?t.stopPropagation():s.onSelectOption(i),_(t.stopPropagation())}),E(2,Xt,4,0,"svg",31)(3,zt,3,0,"ng-template",null,3,$),c(5,"span",32),D(6),l()(),K()}if(r&2){let n=o.$implicit,e=o.index,t=W(4),i=p(3).ngIf;g(),L("s-selected",i.selectedOptionIndex===e),g(),u("ngIf",i.selectedOptionIndex===e)("ngIfElse",t),g(4),se(n)}}function Kt(r,o){r&1&&(c(0,"div",37),I(),c(1,"svg",38)(2,"circle",39),f(3,"animate",40),l(),c(4,"circle",41),f(5,"animate",42),l(),c(6,"circle",43),f(7,"animate",44),l(),c(8,"circle",45),f(9,"animate",46),l()()())}function qt(r,o){if(r&1){let n=A();c(0,"span",47),S("click",function(){C(n);let t=p(4);return _(t.onShowOriginalTextClick())}),D(1),v(2,"translate"),l()}r&2&&(g(),se(w(2,1,"Show original text")))}function Jt(r,o){r&1&&(c(0,"div",16),D(1),v(2,"translate"),l()),r&2&&(g(),N(" ",w(2,1,"Select a rewritten text to create a task")))}function ei(r,o){if(r&1){let n=A();c(0,"button",48),S("click",function(t){C(n);let i=p(3).ngIf,a=p();return i.selectedOptionIndex<0||a.createTask(),_(t.stopPropagation())}),E(1,Jt,3,3,"div",49),D(2),v(3,"translate"),l()}if(r&2){let n=p(3).ngIf;L("disabled",n.selectedOptionIndex<0),g(),u("ngIf",n.selectedOptionIndex<0),g(),N(" ",w(3,4,"Create Task")," ")}}function ti(r,o){if(r&1){let n=A();c(0,"div",9),S("pointerdown",function(t){return C(n),_(t.stopPropagation())})("click",function(t){return C(n),_(t.stopPropagation())}),c(1,"div",10)(2,"div",11),I(),c(3,"svg",12)(4,"g"),f(5,"path",13),l()(),D(6),v(7,"translate"),l(),F(),c(8,"div",14)(9,"div",15),S("click",function(){C(n);let t=p(2).ngIf,i=p();return _(!t.loading&&t.searchCount<3?i.onRefresh():null)}),c(10,"div",16),D(11),v(12,"translate"),v(13,"translate"),v(14,"translate"),v(15,"translate"),v(16,"translate"),l(),I(),c(17,"svg",17),f(18,"path",18),l()(),F(),c(19,"div",19),S("click",function(t){return C(n),p(3).onCloseDialog(),_(t.stopPropagation())}),I(),c(20,"svg",17),f(21,"path",20),l()()()(),F(),c(22,"div",21),E(23,Qt,7,5,"ng-container",22)(24,Kt,10,0,"div",23),l(),c(25,"div",24),E(26,qt,3,3,"span",25),f(27,"div"),E(28,ei,4,6,"button",26),l(),I(),c(29,"svg",27),f(30,"path",28)(31,"path",29),l()()}if(r&2){let n=p(2).ngIf;L("bottom-sheet",n.bottomSheetMode),g(6),N(" ",w(7,10,"Rewrite")," "),g(3),L("disabled",n.loading||n.searchCount>=3),g(2),N("",n.loading?w(12,12,"Getting data ..."):n.searchCount===0?w(13,14,"Get more options"):n.searchCount<3?w(14,16,"Get more options")+" ("+(3-n.searchCount)+" "+w(15,18,"left")+")":w(16,20,"Max 3 rewrites allowed")," "),g(12),u("ngForOf",n.options),g(),u("ngIf",n.loading),g(2),u("ngIf",n.selectedOptionIndex>=0),g(2),u("ngIf",n.options==null?null:n.options.length)}}function ii(r,o){if(r&1&&E(0,ti,32,22,"div",8),r&2){let n=p(2);u("ngIf",n.type==="copywriter")}}function ni(r,o){if(r&1){let n=A();c(0,"div",55),S("click",function(){C(n);let t=p(4);return _(t.getRewriterOptions())}),I(),c(1,"svg",56),f(2,"path",57),l()()}if(r&2){let n=p(4);L("disabled",!(n.prompt!=null&&n.prompt.length))}}function ri(r,o){if(r&1){let n=A();c(0,"div",9),S("pointerdown",function(t){return C(n),_(t.stopPropagation())})("click",function(t){return C(n),_(t.stopPropagation())}),c(1,"div",50)(2,"div",10)(3,"div",11),I(),c(4,"svg",51),f(5,"path",52),l(),F(),c(6,"input",53,4),v(8,"translate"),Re("ngModelChange",function(t){C(n);let i=p(3);return ye(i.prompt,t)||(i.prompt=t),_(t)}),S("keyup.enter",function(){C(n);let t=p(3);return _(t.getRewriterOptions())}),l()(),E(9,ni,3,2,"div",54),l()()()}if(r&2){let n=p(2).ngIf,e=p();L("bottom-sheet",n.bottomSheetMode),g(6),u("placeholder",w(8,6,"How would you like to change this copy?")),Se("ngModel",e.prompt),u("disabled",n.loading||n.searchCount>=e.MAX_SEARCH_COUNT),g(3),u("ngIf",!n.loading)}}function oi(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",35)(3,"rect",36),l())}function ai(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",36),l())}function si(r,o){if(r&1){let n=A();Q(0),c(1,"div",30),S("click",function(t){let i=C(n).index,a=p(3).ngIf,s=p();return a.selectedOptionIndex===i?t.stopPropagation():s.onSelectOption(i),_(t.stopPropagation())}),E(2,oi,4,0,"svg",31)(3,ai,3,0,"ng-template",null,3,$),c(5,"span",32),D(6),v(7,"translate"),l()(),K()}if(r&2){let n=o.$implicit,e=o.index,t=W(4),i=p(3).ngIf;g(),L("s-selected",i.selectedOptionIndex===e),g(),u("ngIf",i.selectedOptionIndex===e)("ngIfElse",t),g(4),se(w(7,5,n))}}function ci(r,o){r&1&&(c(0,"div",37),I(),c(1,"svg",38)(2,"circle",39),f(3,"animate",40),l(),c(4,"circle",41),f(5,"animate",42),l(),c(6,"circle",43),f(7,"animate",44),l(),c(8,"circle",45),f(9,"animate",46),l()()())}function li(r,o){if(r&1){let n=A();c(0,"span",47),S("click",function(){C(n);let t=p(4);return _(t.onShowOriginalTextClick())}),D(1),v(2,"translate"),l()}r&2&&(g(),se(w(2,1,"Show original text")))}function pi(r,o){r&1&&(c(0,"div",16),D(1),v(2,"translate"),l()),r&2&&(g(),N(" ",w(2,1,"Select a rewritten text to create a task")))}function mi(r,o){if(r&1){let n=A();c(0,"button",48),S("click",function(t){C(n);let i=p(3).ngIf,a=p();return i.selectedOptionIndex<0||a.createTask(),_(t.stopPropagation())}),E(1,pi,3,3,"div",49),D(2),v(3,"translate"),l()}if(r&2){let n=p(3).ngIf;L("disabled",n.selectedOptionIndex<0),g(),u("ngIf",n.selectedOptionIndex<0),g(),N(" ",w(3,4,"Create Task")," ")}}function gi(r,o){if(r&1){let n=A();c(0,"div",9),S("pointerdown",function(t){return C(n),_(t.stopPropagation())})("click",function(t){return C(n),_(t.stopPropagation())}),c(1,"div",50)(2,"div",10)(3,"div",11),I(),c(4,"svg",51),f(5,"path",52),l(),F(),c(6,"input",53,4),v(8,"translate"),Re("ngModelChange",function(t){C(n);let i=p(3);return ye(i.prompt,t)||(i.prompt=t),_(t)}),S("keyup.enter",function(){C(n);let t=p(3);return _(t.getRewriterOptions())}),l()(),c(9,"div",58),S("click",function(){C(n);let t=p(2).ngIf,i=p();return _(t.loading?null:i.getRewriterOptions())}),c(10,"div",16),D(11),v(12,"translate"),v(13,"translate"),v(14,"translate"),v(15,"translate"),v(16,"translate"),l(),I(),c(17,"svg",56),f(18,"path",59),l()()(),F(),f(19,"hr",60),l(),c(20,"div",10)(21,"div",11),D(22),v(23,"translate"),l(),c(24,"div",14)(25,"div",15),S("click",function(){C(n);let t=p(2).ngIf,i=p();return _(!t.loading&&t.searchCount<3?i.onRefresh():null)}),c(26,"div",16),D(27),v(28,"translate"),v(29,"translate"),v(30,"translate"),v(31,"translate"),v(32,"translate"),l(),I(),c(33,"svg",17),f(34,"path",18),l()(),F(),c(35,"div",19),S("click",function(t){return C(n),p(3).onCloseDialog(),_(t.stopPropagation())}),I(),c(36,"svg",17),f(37,"path",20),l()()()(),F(),c(38,"div",21),E(39,si,8,7,"ng-container",22),l(),E(40,ci,10,0,"div",23),c(41,"div",24),E(42,li,3,3,"span",25),f(43,"div"),E(44,mi,4,6,"button",26),l(),I(),c(45,"svg",27),f(46,"path",28)(47,"path",29),l()()}if(r&2){let n=p(2).ngIf,e=p();L("bottom-sheet",n.bottomSheetMode),g(6),u("placeholder",w(8,16,"How would you like to change this copy?")),Se("ngModel",e.prompt),u("disabled",n.loading||n.searchCount>=e.MAX_SEARCH_COUNT),g(3),L("disabled",n.loading||n.searchCount>=3),g(2),N("",n.loading?w(12,18,"Getting data ..."):n.searchCount===0?w(13,20,"Get more options"):n.searchCount<3?w(14,22,"Get more options")+" ("+(3-n.searchCount)+" "+w(15,24,"left")+")":w(16,26,"Max 3 rewrites allowed")," "),g(11),N(" ",w(23,28,"Suggestions")," "),g(3),L("disabled",n.loading||n.searchCount>=3),g(2),N("",n.loading?w(28,30,"Getting data ..."):n.searchCount===0?w(29,32,"Get more options"):n.searchCount<3?w(30,34,"Get more options")+" ("+(3-n.searchCount)+" "+w(31,36,"left")+")":w(32,38,"Max 3 rewrites allowed")," "),g(12),u("ngForOf",n.options),g(),u("ngIf",n.loading),g(2),u("ngIf",n.selectedOptionIndex>=0),g(2),u("ngIf",n.options==null?null:n.options.length)}}function di(r,o){if(r&1&&E(0,ri,10,8,"div",8)(1,gi,48,40,"div",8),r&2){let n=p().ngIf;u("ngIf",!n.apiCalled),g(),u("ngIf",n.apiCalled)}}function hi(r,o){if(r&1){let n=A();Q(0),c(1,"div",6,0),S("clickOutside",function(){C(n);let t=p();return _(t.onClickOutside())}),E(3,Yt,0,0,"ng-template",7),l(),E(4,ii,1,1,"ng-template",null,1,$)(6,di,2,2,"ng-template",null,2,$),K()}if(r&2){let n=W(5),e=W(7),t=p();g(3),u("ngIf",t.type==="copywriter")("ngIfThen",n)("ngIfElse",e)}}var ce=(()=>{let o=class o{onClick(e){this.onClickOutside()}constructor(e,t,i,a,s,m){this.analyticsService=e,this.serviceBook=t,this.domService=i,this.loggingService=a,this.rewriterService=s,this.bottomSheetData=m,this.type="copywriter",this.selectOption=new me,this.hideDialog=!1,this.subscriptions=[],this.prompt="",this.lastAskAiCalledAt=0,this.MAX_SEARCH_COUNT=3,this.componentConfigSignal=pe({searchCount:0,loading:!1,bottomSheetMode:!1,apiCalled:!1,options:[],selectedOptionIndex:-1}),this.veltElement=!0,this.commentService=null,this.serviceBook.observe(Rt).subscribe(d=>{this.commentService=d}),m&&this.subscriptions.push(m.subscribe(d=>{d&&(this.bottomSheetContainerData=d,this.annotation=d.annotation,this.type=this.annotation?.rewriterType||"copywriter",this.componentConfigSignal.update(y=>k(M({},y),{bottomSheetMode:!0})),this.getRewriterOptions())}))}ngOnInit(){}ngAfterViewInit(){try{this.bottomSheetData||(this.type=this.annotation?.rewriterType||"copywriter",this.getRewriterOptions()),setTimeout(()=>{this.searchInput?.nativeElement&&this.searchInput?.nativeElement?.focus()},1e3)}catch(e){this.loggingService.catch("Error in RewriterDialogComponent ngAfterViewInit:",e)}}getRewriterOptions(){return V(this,null,function*(){try{if(this.type!=="copywriter"&&!this.prompt||this.lastAskAiCalledAt&&Date.now()-this.lastAskAiCalledAt<1e3)return;this.lastAskAiCalledAt=Date.now(),this.componentConfigSignal.update(d=>k(M({},d),{loading:!0}));let e=wt(this.annotation?.targetTextRange?.text?.trim()||""),t=e.join(" "),i=this.componentConfigSignal().options,a;this.type==="copywriter"?a=`Act as a website copywriter and rewrite this website copy in less than ${e?.length} words. Make it very simple, exciting and more compelling. Return exactly 3 different rewritten options, one per line. Do not number them or add any prefixes.`:a=`${this.prompt}
|
|
2
2
|
|
|
3
3
|
Return exactly 3 different options, one per line. Do not number them or add any prefixes.`,i.length&&(a+=`
|
|
4
4
|
|
package/velt-selection.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as tt,b as it}from"./chunk-BTNNHMUJ.js";import{t as Ze}from"./chunk-SKNIB72F.js";import"./chunk-LEIUFK3K.js";import"./chunk-FEA5HRMI.js";import"./chunk-BB2UXAYE.js";import"./chunk-CYAQOX2W.js";import"./chunk-HEFEC6O6.js";import"./chunk-KHL24R7O.js";import{b as Qe,d as qe}from"./chunk-MVVXZ2D6.js";import{G as Le,H as Ae,I as we,r as ke,t as Ue,v as Ne}from"./chunk-IUD3QEEM.js";import{a as et}from"./chunk-FFTR7QJM.js";import{v as Je,w as Ke}from"./chunk-EPQLN2EE.js";import{Bb as v,Dg as ie,E as N,Fb as _e,Fj as Xe,Gb as Ie,Gd as Re,Gf as F,Gg as ne,Gj as Ye,Ha as p,Hb as ye,Hc as Oe,He as y,Hf as X,Hg as $e,Ic as Pe,If as H,J as le,K as se,Kb as Q,Lb as R,M as ae,O as ce,Oa as pe,Pb as z,Qb as Ce,Ra as j,Rb as q,Rc as De,V as T,Va as Se,Vg as Be,Wa as fe,Xa as Ee,Y as G,Yf as Fe,Yi as je,Z as ge,Zi as g,_i as ze,a as b,ab as x,b as I,ba as he,ca as me,cc as Te,db as be,dc as xe,dh as He,ea as E,eh as Me,fb as L,fh as Ge,g as oe,l as k,mc as W,na as de,nb as _,nc as V,ob as w,pb as B,pi as S,qb as K,qg as te,r as C,rc as Z,re as ee,rj as We,sa as ue,ub as O,uj as Ve,v as U,vb as P,ya as ve}from"./chunk-TAGMM5ED.js";var ht=["selectionElementPortalOverlay"],mt=()=>["velt-overlay-panel"],dt=s=>[s];function ut(s,n){if(s&1&&(O(0),w(1,"span",10),z(2),W(3,"translate"),B(),P()),s&2){let o=v(),e=o.$implicit,t=o.index,i=v(5);p(),R("--velt-selection-color",e==null||e.user==null?null:e.user.color),L("data-testid",i.componentId+"-user-name-"+t),p(),Ce(V(3,4,(e==null||e.user==null?null:e.user.name)||(e==null||e.user==null?null:e.user.email)))}}function vt(s,n){if(s&1&&(O(0),x(1,ut,4,6,"ng-container",3),P()),s&2){let o=n.index,e=v(5);p(),_("ngIf",o<e.maxCount)}}function pt(s,n){if(s&1&&(w(0,"span",11),z(1),B()),s&2){let o=v(4).ngIf,e=v();R("--velt-selection-color",(o.selections[0]==null||o.selections[0].user==null?null:o.selections[0].user.color)||"white"),L("data-testid",e.componentId+"-additional-count")("aria-label",(o.selections==null?null:o.selections.length)-e.maxCount+" additional users"),p(),q("+",(o.selections==null?null:o.selections.length)-e.maxCount)}}function St(s,n){if(s&1&&(O(0),w(1,"div",7),W(2,"translate"),x(3,vt,2,1,"ng-container",8)(4,pt,2,5,"span",9),B(),P()),s&2){let o=v(3).ngIf,e=v();p(),L("data-testid",e.componentId+"-label-container")("aria-label",V(2,4,"Selected users")),p(2),_("ngForOf",o.selections),p(),_("ngIf",(o.selections==null?null:o.selections.length)>e.maxCount)}}function ft(s,n){if(s&1&&(O(0),K(1,"snippyly-user-avatar",13),P()),s&2){let o=v(),e=o.$implicit,t=o.index;p(),R("--velt-selection-color",e==null||e.user==null?null:e.user.color)("--velt-selection-user-index",t),_("size",20)("user",e==null?null:e.user)}}function Et(s,n){if(s&1&&(O(0),x(1,ft,2,6,"ng-container",3),P()),s&2){let o=n.index,e=v(5);p(),_("ngIf",o<e.maxCount)}}function bt(s,n){if(s&1&&(w(0,"div",14),W(1,"translate"),w(2,"span",15),z(3),B()()),s&2){let o=v(4).ngIf,e=v();R("--velt-selection-user-index",o.selections==null?null:o.selections.length)("background-color",(o.selections[(o.selections==null?null:o.selections.length)-1]==null||o.selections[(o.selections==null?null:o.selections.length)-1].user==null?null:o.selections[(o.selections==null?null:o.selections.length)-1].user.color)||"white"),L("data-testid",e.componentId+"-additional-avatars")("aria-label",(o.selections==null?null:o.selections.length)-e.maxCount+" "+V(1,7,"additional users")),p(3),q("+",(o.selections==null?null:o.selections.length)-e.maxCount)}}function _t(s,n){if(s&1&&x(0,Et,2,1,"ng-container",8)(1,bt,4,9,"div",12),s&2){let o=v(3).ngIf,e=v();_("ngForOf",o.selections),p(),_("ngIf",(o.selections==null?null:o.selections.length)>e.maxCount)}}function It(s,n){if(s&1&&x(0,St,5,6,"ng-container",6)(1,_t,2,2,"ng-template",null,2,Z),s&2){let o=Q(2),e=v(2).ngIf,t=v();_("ngIf",(e==null?null:e.userIndicatorType)===(t.userIndicatorTypes==null?null:t.userIndicatorTypes.Label))("ngIfElse",o)}}function yt(s,n){if(s&1&&(O(0),K(1,"div",4,0),x(3,It,3,2,"ng-template",5,1,Z),P()),s&2){let o=Q(2),e=v().ngIf,t=v();p(),R("top",(e==null||e.position==null?null:e.position.top)+t.offsetTop,"px")("left",(e==null||e.position==null?null:e.position.left)+t.offsetLeft,"px"),_("id","selection-element-contianer-"+(t.highlight.user==null?null:t.highlight.user.userSnippylyId)),L("data-testid",t.componentId),p(2),_("cdkConnectedOverlayOrigin",o)("cdkConnectedOverlayOpen",!0)("cdkConnectedOverlayLockPosition",!1)("cdkConnectedOverlayGrowAfterOpen",!0)("cdkConnectedOverlayDisableClose",!0)("cdkConnectedOverlayPanelClass",Te(13,mt))("cdkConnectedOverlayPositions",xe(14,dt,e==null?null:e.overlayPosition))}}function Ct(s,n){if(s&1&&(O(0),x(1,yt,5,16,"ng-container",3),P()),s&2){let o=n.ngIf;p(),_("ngIf",o==null?null:o.position)}}var re=(()=>{let n=class n{get highlight(){return this._highlight}set highlight(e){this._highlight=e,this.calculatePosition()}constructor(e,t,i){this.loggingService=e,this.selectionService=t,this.elementRef=i,this._highlight=new F,this.position=null,this.userIndicatorTypes=H,this.offsetLeft=0,this.offsetTop=0,this.maxCount=1,this.componentConfigSignal=ue({userIndicatorPosition:X.End,userIndicatorType:H.Avatar,position:null,overlayPosition:{originX:"end",originY:"top",overlayX:"end",overlayY:"top"},selections:[]}),this.veltElement=!0,this.componentId="velt-selection-element";try{this.loggingService.log("%c[WB] Creating CLASS: SelectionElementPortalComponent","color: blue;");let r=this.selectionService.getUserIndicatorPosition(),h=this.selectionService.getUserIndicatorType();this.componentConfigSignal.update(d=>(d=I(b({},d),{userIndicatorPosition:r,userIndicatorType:h}),d)),this.setOverlayPosition(r)}catch(r){this.loggingService.log("Error in SelectionElementPortalComponent constructor: ",r)}}ngOnInit(){try{this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in SelectionElementPortalComponent ngOnInit:",e)}}setupA11yAttributes(){try{let e=this.elementRef.nativeElement;e.setAttribute("data-testid",this.componentId+"-container"),e.setAttribute("role","complementary"),e.setAttribute("aria-label","Selection portal")}catch(e){this.loggingService.catch("Error in SelectionElementPortalComponent setupA11yAttributes:",e)}}setSelections(e){try{this.componentConfigSignal.update(t=>(t=I(b({},t),{selections:e}),t))}catch(t){this.loggingService.catch("Error in SelectionElementPortalComponent setSelections: ",t)}}addSelection(e){try{this.componentConfigSignal.update(t=>(t=b({},t),t.selections.push(e),t))}catch(t){this.loggingService.catch("Error in SelectionElementPortalComponent addSelection: ",t)}}ngAfterViewInit(){try{this.loggingService.log("%c[WB] Calling SelectionElementPortalComponent FUNCTION: ngAfterViewInit","color: green;"),this.updateOverlayPosition()}catch(e){this.loggingService.catch("Error in ngAfterViewInit: ",e)}}setOverlayPosition(e){try{this.loggingService.log("%c[WB] Calling SelectionElementPortalComponent FUNCTION: setOverlayPosition","color: green;"),e==="start"?this.componentConfigSignal.update(t=>(t=I(b({},t),{overlayPosition:{originX:"start",originY:"top",overlayX:"start",overlayY:"top"}}),t)):this.componentConfigSignal.update(t=>(t=I(b({},t),{overlayPosition:{originX:"end",originY:"top",overlayX:"end",overlayY:"top"}}),t)),this.updateOverlayPosition()}catch(t){this.loggingService.catch("Error in SelectionElementPortalComponent setOverlayPosition: ",t)}}updateOverlayPosition(){try{this.loggingService.log("%c[WB] Calling SelectionElementPortalComponent FUNCTION: updateOverlayPosition","color: green;"),this.selectionElementPortalOverlay&&this.selectionElementPortalOverlay?.overlayRef?.updatePosition()}catch(e){this.loggingService.catch("Error in SelectionElementPortalComponent updateOverlayPosition: ",e)}}calculatePosition(){try{if(this.loggingService.log("%c[WB] Calling SelectionElementPortalComponent FUNCTION: calculatePosition","color: green;"),this.highlight?.targetElement){let e=He(this.highlight.targetElement);if(e){let t=e.iterateNext(),i,r=null,h=null;try{i=JSON.parse(t?.getAttribute(y.ATTRIBUTES.VELT_SELECTION_CONFIG)||"{}"),r=t?.getAttribute(y.ATTRIBUTES.VELT_LIVE_SELECTION_USER_INDICATOR_POSITION)||this.componentConfigSignal().userIndicatorPosition,r&&this.setOverlayPosition(r),h=t?.getAttribute(y.ATTRIBUTES.VELT_LIVE_SELECTION_USER_INDICATOR_TYPE)||this.componentConfigSignal().userIndicatorType,this.componentConfigSignal.update(a=>(a=I(b({},a),{userIndicatorPosition:r,userIndicatorType:h}),a))}catch{}let d;if(i?.horizontal&&(d=i.horizontal),r==="start"?d="top-start":d="top-right",t){let a=t.getBoundingClientRect();if(a&&a.width&&a.height)switch(d){case"left":this.position={top:a.height/2-16,left:-4};break;case"left-start":this.position={top:0,left:-4};break;case"top-start":this.position={top:-32,left:0};break;case"top-right":this.position={top:-32,left:a.width};break;case"bottom-left":this.position={top:a.height+4,left:0};break;case"bottom-right":this.position={top:a.height+4,left:a.width-32};break;case"center-left":this.position={top:a.height/2-16,left:-32};break;case"center-right":this.position={top:a.height/2-16,left:a.width+4};break;default:this.position={top:-32,left:a.width}}else this.position=null}else this.position=null}else this.position=null}this.componentConfigSignal.update(e=>(e=I(b({},e),{position:this.position}),e))}catch(e){this.loggingService.catch("Error in SelectionElementPortalComponent calculatePosition: ",e)}}};n.\u0275fac=function(t){return new(t||n)(j(g),j(f),j(ve))},n.\u0275cmp=fe({type:n,selectors:[["app-selection-element-portal"]],viewQuery:function(t,i){if(t&1&&_e(ht,5),t&2){let r;Ie(r=ye())&&(i.selectionElementPortalOverlay=r.first)}},hostVars:1,hostBindings:function(t,i){t&2&&L("data-velt-element",i.veltElement)},inputs:{highlight:"highlight",offsetLeft:"offsetLeft",offsetTop:"offsetTop"},standalone:!1,decls:1,vars:1,consts:[["trigger","cdkOverlayOrigin"],["selectionElementPortalOverlay","cdkConnectedOverlay"],["defaultAvatarTypeTemplate",""],[4,"ngIf"],["cdkOverlayOrigin","","role","presentation",1,"selection-element-portal",3,"id"],["cdkConnectedOverlay","",3,"cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayLockPosition","cdkConnectedOverlayGrowAfterOpen","cdkConnectedOverlayDisableClose","cdkConnectedOverlayPanelClass","cdkConnectedOverlayPositions"],[4,"ngIf","ngIfElse"],["role","list",1,"velt-live-selection-element-user-name-container"],[4,"ngFor","ngForOf"],["class","velt-live-selection-element-user-name-plus","role","listitem",3,"--velt-selection-color",4,"ngIf"],["role","listitem",1,"velt-live-selection-element-user-name"],["role","listitem",1,"velt-live-selection-element-user-name-plus"],["class","photo-container","role","listitem",3,"--velt-selection-user-index","background-color",4,"ngIf"],[1,"photo-container","selection-user-avatar",3,"size","user"],["role","listitem",1,"photo-container"],[1,"s-selection-element-avatar-initial"]],template:function(t,i){t&1&&x(0,Ct,2,1,"ng-container",3),t&2&&_("ngIf",i.componentConfigSignal())},dependencies:[Oe,Pe,Ae,Le,qe,Qe],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%]{--velt-green: var(--velt-light-mode-green);--velt-magenta: var(--velt-light-mode-magenta);--velt-amber: var(--velt-light-mode-amber);--velt-purple: var(--velt-light-mode-purple);--velt-cyan: var(--velt-light-mode-cyan);--velt-orange: var(--velt-light-mode-orange);--velt-black: var(--velt-light-mode-black);--velt-white: var(--velt-light-mode-white);--velt-gray: var(--velt-light-mode-gray);--velt-error: var(--velt-light-mode-error);--velt-error-hover: var(--velt-light-mode-error-hover);--velt-error-foreground: var(--velt-light-mode-error-foreground);--velt-error-light: var(--velt-light-mode-error-light);--velt-error-transparent: var(--velt-light-mode-error-transparent);--velt-warning: var(--velt-light-mode-warning);--velt-warning-hover: var(--velt-light-mode-warning-hover);--velt-warning-foreground: var(--velt-light-mode-warning-foreground);--velt-warning-light: var(--velt-light-mode-warning-light);--velt-warning-transparent: var(--velt-light-mode-warning-transparent);--velt-agent-accent: #4495ff;--velt-agent-accent-transparent: rgba(68, 149, 255, .2);--velt-success: var(--velt-light-mode-success);--velt-success-hover: var(--velt-light-mode-success-hover);--velt-success-foreground: var(--velt-light-mode-success-foreground);--velt-success-light: var(--velt-light-mode-success-light);--velt-success-transparent: var(--velt-light-mode-success-transparent);--velt-accent: var(--velt-light-mode-accent);--velt-accent-text: var(--velt-light-mode-accent-text);--velt-accent-hover: var(--velt-light-mode-accent-hover);--velt-accent-foreground: var(--velt-light-mode-accent-foreground);--velt-accent-light: var(--velt-light-mode-accent-light);--velt-accent-transparent: var(--velt-light-mode-accent-transparent);--velt-text-0: var(--velt-light-mode-text-0);--velt-text-1: var(--velt-light-mode-text-1);--velt-text-2: var(--velt-light-mode-text-2);--velt-text-3: var(--velt-light-mode-text-3);--velt-text-4: var(--velt-light-mode-text-4);--velt-text-5: var(--velt-light-mode-text-5);--velt-text-6: var(--velt-light-mode-text-6);--velt-text-7: var(--velt-light-mode-text-7);--velt-text-8: var(--velt-light-mode-text-8);--velt-text-9: var(--velt-light-mode-text-9);--velt-text-10: var(--velt-light-mode-text-10);--velt-text-11: var(--velt-light-mode-text-11);--velt-text-12: var(--velt-light-mode-text-12);--velt-background-0: var(--velt-light-mode-background-0);--velt-background-1: var(--velt-light-mode-background-1);--velt-background-2: var(--velt-light-mode-background-2);--velt-background-3: var(--velt-light-mode-background-3);--velt-background-4: var(--velt-light-mode-background-4);--velt-background-5: var(--velt-light-mode-background-5);--velt-background-6: var(--velt-light-mode-background-6);--velt-background-7: var(--velt-light-mode-background-7);--velt-background-8: var(--velt-light-mode-background-8);--velt-background-9: var(--velt-light-mode-background-9);--velt-background-10: var(--velt-light-mode-background-10);--velt-border-0: var(--velt-light-mode-border-0);--velt-border-1: var(--velt-light-mode-border-1);--velt-border-2: var(--velt-light-mode-border-2);--velt-border-3: var(--velt-light-mode-border-3);--velt-border-4: var(--velt-light-mode-border-4);--velt-border-5: var(--velt-light-mode-border-5);--velt-border-6: var(--velt-light-mode-border-6);--velt-border-7: var(--velt-light-mode-border-7);--velt-border-8: var(--velt-light-mode-border-8);--velt-border-9: var(--velt-light-mode-border-9);--velt-border-10: var(--velt-light-mode-border-10);--velt-background-transparent: var(--velt-light-mode-background-transparent);--velt-border-transparent: var(--velt-light-mode-border-transparent);--velt-animation-transparent: var(--velt-light-mode-animation-transparent);position:absolute;top:0;left:0;box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0);outline:none;margin:0;padding:0;height:unset;width:unset;text-align:left}*[_ngcontent-%COMP%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0);outline:none;margin:0;padding:0;height:unset;width:unset;text-align:left;line-height:1.5;color:#000;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert}.selection-element-portal[_ngcontent-%COMP%]{display:none;position:absolute;top:0;left:0;white-space:nowrap;z-index:1;font-size:var(--velt-font-size-xs)}.photo-container[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:calc((1.5rem + 0px) * var(--velt-base-rem-unit));height:calc((1.5rem + 0px) * var(--velt-base-rem-unit));box-sizing:border-box;background-clip:padding-box;border-radius:50%;color:var(--velt-light-mode-white);border:2px solid var(--velt-selection-color);margin-left:-5px;z-index:calc(var(--velt-selection-user-index, 0) * -1)}.photo-container[_ngcontent-%COMP%] .s-selection-element-avatar-initial[_ngcontent-%COMP%]{color:var(--velt-light-mode-white)}.photo-container[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:100%;height:100%;border-radius:50%;object-fit:cover} snippyly-user-avatar.selection-user-avatar .s-user-avatar-initial{font-size:var(--velt-font-size-md)}.velt-live-selection-element-user-name-container[_ngcontent-%COMP%]{display:flex;gap:var(--velt-spacing-xs);margin-top:5px}.velt-live-selection-element-user-name-container[_ngcontent-%COMP%] .velt-live-selection-element-user-name[_ngcontent-%COMP%]{color:var(--velt-light-mode-white);display:flex;background:var(--velt-selection-color);padding:var(--velt-spacing-xs) var(--velt-spacing-sm);font-size:var(--velt-spacing-md);font-style:normal;font-weight:400;line-height:100%;border-radius:var(--velt-border-radius-md);font-family:var(--velt-default-font-family)}.velt-live-selection-element-user-name-container[_ngcontent-%COMP%] .velt-live-selection-element-user-name-plus[_ngcontent-%COMP%]{color:var(--velt-light-mode-white);display:flex;background:var(--velt-selection-color);padding:var(--velt-spacing-x);font-size:var(--velt-font-size-xs);font-style:normal;font-weight:400;line-height:100%;border-radius:var(--velt-border-radius-md);font-family:var(--velt-default-font-family)}"],changeDetection:0});let s=n;return s})();var f=(()=>{let n=class n{constructor(e,t,i,r,h,d,a,D,J,ot,lt,st,at){this.afAuth=e,this.analyticsService=t,this.authService=i,this.configService=r,this.databaseService=h,this.docService=d,this.domService=a,this.componentFactoryResolver=D,this.injector=J,this.appRef=ot,this.loggingService=lt,this.commonDbService=st,this.realtimeAdapter=at,this.documentPaths=null,this.textSelections={},this.enableSelections$=new k(!1),this.userIndicatorEnabled$=new k(!0),this.userIndicatorPosition$=new k(X.End),this.userIndicatorType$=new k(H.Avatar),this.defaultElementsTrackingEnabled$=new k(!0),this.defaultStylingEnabled$=new k(!0),this.inactivityTime=300*1e3,this.userIdleStateDetectionSubscription=null,this.elementSelections={},this.databaseService.getDb().pipe(N(l=>!!l),se(1)).subscribe(l=>{l&&(this.updateOnDocumentFocusChange(),this.updateOnUserDbConnectionStateChange(l).subscribe(()=>{},m=>{this.loggingService.catch("Error in SelectionService constructor updateOnUserDbConnectionStateChange: ",m)}))},l=>{this.loggingService.catch("Error in SelectionService getDb subscription: ",l)}),this.authService.getUser$().subscribe(l=>{l?this.detectUserIdleState():this.unsubscribeUserIdleStateDetectionSubscription()}),this.docService.getDocumentPaths$().subscribe(l=>{this.documentPaths=l},l=>{this.loggingService.catch("Error in SelectionService getDocumentPaths subscription: ",l)}),this.domService.onDocumentClick$().subscribe(l=>{try{if(this.enableSelections$.value&&this.isFeatureAllowed()&&l?.target&&!window.getSelection()?.toString()){let m=this.getSelectionEnabledElement(l.target);if(m&&!ie(m)){let u=this.domService.getXPath(m);if(u){let c=new F;c.type="click",c.targetElement=u,c.timestamp=this.timestamp,this.setSelection(c)}}else this.removeSelection()}}catch(m){this.loggingService.catch("Error in SelectionService onDocumentClick$: ",m)}},l=>{this.loggingService.catch("Error in SelectionService onDocumentClick$ subscription: ",l)}),this.domService.onDocumentFocus$().subscribe(l=>{try{if(this.enableSelections$.value&&this.isFeatureAllowed()&&l?.target){let m=this.getSelectionEnabledElement(l.target);if(m&&!ie(m)){let u=this.domService.getXPath(m);if(u){let c=new F;c.type="focus",c.targetElement=u,c.timestamp=this.timestamp,this.setSelection(c)}}else this.removeSelection()}}catch(m){this.loggingService.catch("Error in SelectionService onDocumentFocus$: ",m)}},l=>{this.loggingService.catch("Error in SelectionService onDocumentFocus$ subscription: ",l)}),this.domService.onWindowKeyupEsc$().subscribe(l=>{this.removeSelection()},l=>{this.loggingService.catch("Error in SelectionService onWindowKeyupEsc$ subscription: ",l)}),this.enableSelections$.pipe(T(()=>this.isFeatureAllowed$({})),N(l=>l?.config&&l?.user)).subscribe(l=>{(!l?.featureAllowed||!this.enableSelections$.value)&&this.removeSelection()},l=>{this.loggingService.catch("Error in SelectionService enableSelections$ subscription: ",l)}),this.domService.onSelectionChange$().subscribe(()=>{try{if(this.enableSelections$.value&&this.isFeatureAllowed()&&window.getSelection()?.toString()){let l=window.getSelection()?.getRangeAt(0);if(l.commonAncestorContainer&&!l?.collapsed){let m=Me([l]),u=new F;u.type="selection",u.targetTextRange=m?.length?m[0]:null,u.timestamp=this.timestamp,this.setSelection(u)}}}catch(l){this.loggingService.catch("Error in SelectionService onSelectionChange$: ",l)}},l=>{this.loggingService.catch("Error in SelectionService onSelectionChange$ subscription: ",l)}),this.authService.getUser$().subscribe(l=>{this.user=l},l=>{this.loggingService.catch("Error in SelectionService getUser$ subscription: ",l)}),this.getSelectionsOnCurrentDocument().pipe(ce()).subscribe(([l,m])=>{try{if(l){let u=[];Object.keys(l).forEach(c=>{let A=l[c],$=m?m[c]:null;!ne(A,$)&&c!==this.getUserIdHash(this.user)&&u.push(A)}),u.forEach(c=>{if(c.targetElement){let A=this.elementSelections[c?.targetElement]?.portalRef,M=(this.elementSelections[c?.targetElement]?.selections||[]).filter(ct=>this.getUserIdHash(ct.user)!==this.getUserIdHash(c?.user));M?.length?(A.instance.setSelections(M.slice()),this.elementSelections[c?.targetElement].selections=M.slice(),this.highlightElement(M[0])):(this.removeHighlightFromElement(c),this.removeSelectionElement(c))}else c.targetTextRange&&this.removeHighlightFromText(c)})}if(m){let u=[];Object.keys(m).forEach(c=>{let A=l?l[c]:null,$=m[c];!ne(A,$)&&c!==this.getUserIdHash(this.user)&&u.push($)}),u.forEach(c=>{c.targetElement?(this.highlightElement(c),this.getUserIndicatorEnabled()&&this.setElementHighlight(c)):c.targetTextRange&&this.highlightText(c)})}}catch(u){this.loggingService.catch("Error in SelectionService getSelectionsOnCurrentDocument: ",u)}},l=>{this.loggingService.catch("Error in SelectionService getSelectionsOnCurrentDocument subscription: ",l)}),this.authService.addPreSignOutFuction("highlight-signout",this.signOutUser.bind(this))}detectUserIdleState(){try{this.unsubscribeUserIdleStateDetectionSubscription();let e=!1;this.userIdleStateDetectionSubscription=this.domService.onWindowPointerMove$().pipe(ge(2e3),G(()=>{e&&(e=!1)}),le(this.inactivityTime),G(()=>{this.removeSelection(),e=!0})).subscribe()}catch(e){this.loggingService.catch("Error in detectUserIdleState: ",e)}}unsubscribeUserIdleStateDetectionSubscription(){try{this.userIdleStateDetectionSubscription&&(this.userIdleStateDetectionSubscription.unsubscribe(),this.userIdleStateDetectionSubscription=null)}catch(e){this.loggingService.catch("Error in unsubscribeUserIdleStateDetectionSubscription: ",e)}}isFeatureAllowed(){return te(this.configService.getConfig(),this.authService.getUser(),ee.LIVE_SELECTION)}updateOnDocumentFocusChange(){this.loggingService.log("%c[WB] Calling FUNCTION: updateOnDocumentFocusChange","color: green;");try{document&&document.addEventListener("visibilitychange",e=>{this.user&&document.visibilityState==="hidden"&&this.removeSelection()})}catch(e){this.loggingService.catch("Error in updateOnDocumentFocusChange:",e)}}getSelectionsOnCurrentDocument(){return this.loggingService.log("%c[WB] Calling FUNCTION: getSelectionsOnCurrentDocument","color: green;"),this.authService.getAuthState$().pipe(N(e=>!!e),T(e=>this.isFeatureAllowed$({firebaseUser:e})),T(e=>e.featureAllowed?C(e).pipe(T(t=>this.docService.getDocumentPaths$().pipe(U(i=>(this.documentPaths=i,t)))),T(t=>t?.user?t?.user?.isAnonymous?C(null):this.documentPaths?this.databaseService.getDb().pipe(N(i=>!!i),T(i=>this.documentPaths?.selection?this.commonDbService.dbListener({feature:"allSelections",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(U(r=>r?.data),U(r=>this.filterActiveSelections(r))):C(null))):C(null):C(null))):C(null)))}isFeatureAllowed$(e){return this.configService.getConfig$().pipe(N(t=>!!t),U(t=>I(b({},e),{config:t})),T(t=>this.authService.getUser$().pipe(U(i=>(this.user=i,I(b({},t),{user:i}))))),T(t=>te(t.config,t.user,ee.LIVE_SELECTION)?C(I(b({},t),{featureAllowed:!0})):(this.loggingService.warn("Live Selection feature is not allowed."),C(I(b({},t),{featureAllowed:!1})))),ae((t,i)=>t?.featureAllowed===i?.featureAllowed))}filterActiveSelections(e){this.loggingService.log("%c[WB] Calling FUNCTION: filterOnlineUsers","color: green;");try{if(e&&typeof e=="object"&&Object.keys(e).length){let t={},i=this.commonDbService.getServerTimestamp();return Object.keys(e).forEach(r=>{let h=e[r];h?.timestamp&&Math.abs(i-h.timestamp)<this.inactivityTime&&(t[r]=h)}),t}return e}catch(t){return this.loggingService.catch("Error in filterOnlineUsers:",t),e}}setSelection(e){try{if(this.user?.userId&&this.documentPaths?.selection){e.user=this.user;let t=JSON.parse(JSON.stringify(e));t&&!t?.timestamp&&(t.timestamp=this.timestamp),this.commonDbService.updateData({feature:"selection",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:this.getUserIdHash(this.user)??"",skipFirestore:!0},data:t})}}catch(t){this.loggingService.catch("Error in SelectionService setSelection: ",t)}}removeSelection(){try{this.user?.userId&&this.documentPaths?.selection&&this.commonDbService.deleteData({feature:"selection",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:this.getUserIdHash(this.user)??"",skipFirestore:!0}})}catch(e){this.loggingService.catch("Error in SelectionService removeSelection: ",e)}}updateOnUserDbConnectionStateChange(e){return this.loggingService.log("%c[WB] Calling FUNCTION: updateOnUserDbConnectionStateChange","color: green;"),this.authService.getAuthState$().pipe(N(t=>!!t),T(t=>this.docService.getDocumentPaths$().pipe(U(i=>t))),G(t=>oe(this,null,function*(){try{if(this.documentPaths&&t){let i=yield this.authService.getIdTokenResultForUser(t,!0).catch(h=>null);if(!i)return;let{user:r}=i.claims;if(r&&this.documentPaths?.selection){let h=this.getUserIdHash(r);if(h){let d=`${this.documentPaths.selection}/${h}`,a=this.realtimeAdapter.rtdbRef(e,d);this.realtimeAdapter.rtdbOnDisconnectRemove("selection",a).catch(D=>{this.loggingService.catch("Error in SelectionService updateOnUserDbConnectionStateChange onDisconnect:",D)})}}}}catch(i){this.loggingService.catch("Error in SelectionService updateOnUserDbConnectionStateChange:",i)}})))}highlightElement(e){try{let t=this.domService.getXPath(e.targetElement);if(t){let i=t.iterateNext();if(i){let r=["input","textarea","select","button"],h;try{i?.getAttribute(y.ATTRIBUTES.VELT_SELECTION_CONFIG)&&(h=JSON.parse(i?.getAttribute(y.ATTRIBUTES.VELT_SELECTION_CONFIG)||"{}"))}catch{}(!h||h?.border)&&this.domService.highlightUserElement(i,e?.user?.color,e?.user?.name,this.getDefaultStylingEnabled())}}}catch(t){this.loggingService.catch("Error in SelectionService highlightElement: ",t)}}removeHighlightFromElement(e){try{let t=this.domService.getXPath(e.targetElement);if(t){let i=t.iterateNext();i&&this.domService.removeHighlightUserFromElement(i)}}catch(t){this.loggingService.catch("Error in SelectionService removeHighlightFromElement: ",t)}}highlightText(e){try{if(e?.targetTextRange){let t=$e(e.targetTextRange?.text,this.domService.getXPath(e.targetTextRange?.commonAncestorContainer).iterateNext(),e.targetTextRange?.occurrence),i=new Range;try{i.setStart(t[0].textNode,t[0].startOffset||0),i.setEnd(t[t.length-1].textNode,t[t.length-1].endOffset||0)}catch{}if(i.toString()===e.targetTextRange?.text){let r=tt(i,y.TAGS.SNIPPYLY_HIGHLIGHT_USER_TEXT),h=[],d=this.getSelectionUserMarker(e.user);if(r&&r.length&&(r.forEach(a=>{a?.textContent?.trim()&&(this.domService.addClassToElement(a,a.tagName?.toLowerCase()),this.domService.addClassToElement(a,y.VELT_LIVE_SELECTION_ON_TEXT),this.getDefaultStylingEnabled()&&this.domService.addClassToElement(a,y.VELT_LIVE_SELECTION_ON_TEXT_DEFAULT),e.user?.color&&a.style.setProperty(y.VELT_SELECTION_COLOR,e.user?.color+"55"),h.push({element:a,textNode:a.childNodes[0]}))}),d)){let a=r.filter(J=>J?.textContent?.trim()),D=a?.length?a[a?.length-1]:null;D&&D.parentNode.insertBefore(d,D.nextSibling)}this.textSelections[this.getUserIdHash(e?.user)]={textNodes:h,marker:d}}}}catch(t){this.loggingService.catch("Error in SelectionService highlightText: ",t)}}removeHighlightFromText(e){try{let t=this.getUserIdHash(e?.user);t&&this.textSelections[t]?.textNodes?.length&&(this.textSelections[t].textNodes.forEach(i=>{let r=i?.element?.parentNode??i?.textNode?.parentNode;i?.element&&i?.textNode&&it(i.element,i.textNode),i.textNode&&Be(r)}),this.textSelections[t]?.marker&&this.textSelections[t]?.marker?.remove())}catch(t){this.loggingService.catch("Error in SelectionService removeHighlightFromText: ",t)}}getSelectionUserMarker(e){try{let t=document.createElement("span");t.classList.add("snippyly-user-marker","active"),t.setAttribute("data-name",e?.name+""),t.style.setProperty("--velt-selection-marker-color",e?.color||"#000");let i=document.createElement("span");i.classList.add("snippyly-user-marker-line");let r=document.createElement("span");return r.classList.add("snippyly-user-marker-dot"),i.appendChild(r),t.appendChild(i),setTimeout(()=>{t?.classList?.remove("active")},1e3),t}catch(t){return this.loggingService.catch("Error in SelectionService getSelectionUserMarker: ",t),null}}signOutUser(e){return new Promise((t,i)=>{try{this.documentPaths?.selection&&e?this.commonDbService.getData({feature:"selection",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0}}).then(r=>{r&&this.commonDbService.deleteData({feature:"selection",errorCallback:h=>{i(h)},callback:()=>{t(null)},properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:this.getUserIdHash(this.user)??"",skipFirestore:!0}}),t(null)}).catch(r=>{this.loggingService.catch("Error in SelectionService signOutUser subscription: ",r),i(r)}):t(null)}catch(r){this.loggingService.catch("Error in SelectionService signOutUser:",r),i(r)}})}setInactivityTime(e){try{this.inactivityTime=e,this.analyticsService.trackEvent(S.Events.Selection.SELECTION_SET_CUSTOM_INACTIVITY_TIMER,{inactivityTime:this.inactivityTime}),this.detectUserIdleState()}catch(t){this.loggingService.catch("Error in SelectionService setInactivityTime: ",t)}}getInactivityTime(){return this.inactivityTime}enableSelections(e){try{this.enableSelections$.next(e)}catch(t){this.loggingService.catch("Error in SelectionService enableSelections: ",t)}}enableUserIndicator(){try{if(this.userIndicatorEnabled$.value===!0)return;this.userIndicatorEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in SelectionService enableUserIndicator: ",e)}}disableUserIndicator(){try{if(this.userIndicatorEnabled$.value===!1)return;this.userIndicatorEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in SelectionService disableUserIndicator: ",e)}}getUserIndicatorEnabled$(){return this.userIndicatorEnabled$.asObservable()}getUserIndicatorEnabled(){return this.userIndicatorEnabled$.value}setUserIndicatorPosition(e){try{this.userIndicatorPosition$.next(e)}catch(t){this.loggingService.catch("Error in SelectionService setUserIndicatorPosition: ",t)}}getUserIndicatorPosition$(){return this.userIndicatorPosition$.asObservable()}getUserIndicatorPosition(){return this.userIndicatorPosition$.value}setUserIndicatorType(e){try{this.userIndicatorType$.next(e)}catch(t){this.loggingService.catch("Error in SelectionService setUserIndicatorType: ",t)}}getUserIndicatorType$(){return this.userIndicatorType$.asObservable()}getUserIndicatorType(){return this.userIndicatorType$.value}enableDefaultElementsTracking(){try{if(this.defaultElementsTrackingEnabled$.value===!0)return;this.defaultElementsTrackingEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in SelectionService enableDefaultElementsTracking: ",e)}}disableDefaultElementsTracking(){try{if(this.defaultElementsTrackingEnabled$.value===!1)return;this.defaultElementsTrackingEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in SelectionService disableDefaultElementsTracking: ",e)}}getDefaultElementsTrackingEnabled$(){return this.defaultElementsTrackingEnabled$.asObservable()}getDefaultElementsTrackingEnabled(){return this.defaultElementsTrackingEnabled$.value}enableDefaultStyling(){try{if(this.defaultStylingEnabled$.value===!0)return;this.defaultStylingEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in SelectionService enableDefaultStyling: ",e)}}disableDefaultStyling(){try{if(this.defaultStylingEnabled$.value===!1)return;this.defaultStylingEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in SelectionService disableDefaultStyling: ",e)}}getDefaultStylingEnabled$(){return this.defaultStylingEnabled$.asObservable()}getDefaultStylingEnabled(){return this.defaultStylingEnabled$.value}getSelectionEnabledElement(e){try{let t=this.getDefaultElementsTrackingEnabled();return t&&y.SELECTION_ENABLED_ELEMENTS[e.tagName?.toLowerCase()]?e:Ge(e,t)}catch(t){return this.loggingService.catch("Error in SelectionService isElementAllowed: ",t),null}}setElementHighlight(e){try{if(!this.elementSelections[e.targetElement])this.setSelectionElement(e);else{let t=this.elementSelections[e.targetElement].portalRef;this.elementSelections[e.targetElement].selections?.find(r=>this.getUserIdHash(r.user)===this.getUserIdHash(e?.user))||(t.instance.addSelection(e),this.elementSelections[e.targetElement].selections.push(e))}}catch(t){this.loggingService.catch("Error in SelectionService setElementSelection: ",t)}}setSelectionElement(e){try{let t=this.domService.getXPath(e.targetElement);if(t){let i=t.iterateNext();if(i){let r=this.domService.getHostElement(i),h=new ke(re),d=new Ue(r,this.appRef,this.injector),a=d.attach(h);a.instance.highlight=e,a.instance.setSelections([e]),this.elementSelections[e.targetElement]={selectionHostDomPortalOutlet:d,selectionElementPortal:h,portalRef:a,selections:[JSON.parse(JSON.stringify(e))],userTargetElement:i,selectionHostElement:r,targetElement:e.targetElement},this.updateElementOffset(e)}}}catch(t){this.loggingService.catch("Error in SelectionService setSelectionElement: ",t)}}updateElementOffset(e){try{let{portalRef:t,userTargetElement:i,selectionHostElement:r}=this.elementSelections[e.targetElement],h=this.domService.getElementOffset(i,r);t.instance.offsetLeft=h.offsetLeft,t.instance.offsetTop=h.offsetTop}catch(t){this.loggingService.catch("Error in SelectionService updateElementOffset: ",t)}}checkElementHighlightsToRemove(e){try{let t=e.map(i=>i.targetElement);Object.keys(this.elementSelections).forEach(i=>{if(!t.includes(i)){let r=this.elementSelections[i];r&&(r.selectionHostDomPortalOutlet.detach(),this.domService.removeHighlightFromElement(r.selectionHostElement)),delete this.elementSelections[i]}})}catch(t){this.loggingService.catch("Error in SelectionService checkElementHighlightsToRemove: ",t)}}removeSelectionElement(e){try{let t=this.elementSelections[e.targetElement];t&&(t.selectionHostDomPortalOutlet.detach(),this.domService.removeHighlightFromElement(t.selectionHostElement)),delete this.elementSelections[e.targetElement]}catch(t){this.loggingService.catch("Error in SelectionService removeSelectionElement: ",t)}}getUserIdHash(e){try{return e?.userId?Fe(e?.userId):null}catch(t){return this.loggingService.catch("Error in SelectionService getUserIdHash: ",t),null}}get timestamp(){return this.commonDbService.getServerTimestamp()}};n.\u0275fac=function(t){return new(t||n)(E(Re),E(je),E(Ye),E(ze),E(We),E(Ke),E(Xe),E(pe),E(de),E(be),E(g),E(Je),E(Ve))},n.\u0275prov=he({token:n,factory:n.\u0275fac,providedIn:"root"});let s=n;return s})();var Y=class extends et{constructor(n){super(n),this.getService(g).log("%c[WB] Creating CLASS: SelectionElement","color: blue;"),this.enableLiveSelection=this._enableLiveSelection,this.disableLiveSelection=this._disableLiveSelection,this.enableUserIndicator=this._enableUserIndicator,this.disableUserIndicator=this._disableUserIndicator,this.setUserIndicatorPosition=this._setUserIndicatorPosition,this.setUserIndicatorType=this._setUserIndicatorType,this.enableDefaultElementsTracking=this._enableDefaultElementsTracking,this.disableDefaultElementsTracking=this._disableDefaultElementsTracking,this.enableDefaultStyling=this._enableDefaultStyling,this.disableDefaultStyling=this._disableDefaultStyling,this.getLiveSelectionData=this._getLiveSelectionData,this.setInactivityTime=this._setInactivityTime}_enableLiveSelection(){this.getService(g).log("%c[WB] Calling FUNCTION: _enableLiveSelection","color: green;");try{this.trackEvent(S.Events.Selection.ENABLE_LIVE_SELECTION_TRIGGERED),this.getService(f).enableSelections(!0)}catch(n){this.getService(g).catch("Error in enableLiveSelection: ",n)}}_disableLiveSelection(){this.getService(g).log("%c[WB] Calling FUNCTION: _disableLiveSelection","color: green;");try{this.trackEvent(S.Events.Selection.DISABLE_LIVE_SELECTION_TRIGGERED),this.getService(f).enableSelections(!1)}catch(n){this.getService(g).catch("Error in disableLiveSelection: ",n)}}_enableUserIndicator(){this.getService(g).log("%c[WB] Calling FUNCTION: enableUserIndicator","color: green;");try{this.trackEvent(S.Events.Selection.ENABLE_USER_INDICATOR_TRIGGERED),this.getService(f).enableUserIndicator()}catch(n){this.getService(g).catch("Error in _enableUserIndicator: ",n)}}_disableUserIndicator(){this.getService(g).log("%c[WB] Calling FUNCTION: disableUserIndicator","color: green;");try{this.trackEvent(S.Events.Selection.DISABLE_USER_INDICATOR_TRIGGERED),this.getService(f).disableUserIndicator()}catch(n){this.getService(g).catch("Error in _disableUserIndicator: ",n)}}_setUserIndicatorPosition(n){this.getService(g).log("%c[WB] Calling FUNCTION: setUserIndicatorPosition","color: green;");try{this.trackEvent(S.Events.Selection.SET_USER_INDICATOR_POSITION_TRIGGERED,{payload:{position:n}}),this.getService(f).setUserIndicatorPosition(n)}catch(o){this.getService(g).catch("Error in _setUserIndicatorPosition: ",o)}}_setUserIndicatorType(n){this.getService(g).log("%c[WB] Calling FUNCTION: setUserIndicatorType","color: green;");try{this.trackEvent(S.Events.Selection.SET_USER_INDICATOR_TYPE_TRIGGERED,{payload:{type:n}}),this.getService(f).setUserIndicatorType(n)}catch(o){this.getService(g).catch("Error in _setUserIndicatorType: ",o)}}_enableDefaultElementsTracking(){this.getService(g).log("%c[WB] Calling FUNCTION: enableDefaultElementsTracking","color: green;");try{this.trackEvent(S.Events.Selection.ENABLE_DEFAULT_ELEMENTS_TRACKING_TRIGGERED),this.getService(f).enableDefaultElementsTracking()}catch(n){this.getService(g).catch("Error in _enableDefaultElementsTracking: ",n)}}_disableDefaultElementsTracking(){this.getService(g).log("%c[WB] Calling FUNCTION: disableDefaultElementsTracking","color: green;");try{this.trackEvent(S.Events.Selection.DISABLE_DEFAULT_ELEMENTS_TRACKING_TRIGGERED),this.getService(f).disableDefaultElementsTracking()}catch(n){this.getService(g).catch("Error in _disableDefaultElementsTracking: ",n)}}_enableDefaultStyling(){this.getService(g).log("%c[WB] Calling FUNCTION: enableDefaultStyling","color: green;");try{this.trackEvent(S.Events.Selection.ENABLE_DEFAULT_STYLING_TRIGGERED),this.getService(f).enableDefaultStyling()}catch(n){this.getService(g).catch("Error in _enableDefaultStyling: ",n)}}_disableDefaultStyling(){this.getService(g).log("%c[WB] Calling FUNCTION: disableDefaultStyling","color: green;");try{this.trackEvent(S.Events.Selection.DISABLE_DEFAULT_STYLING_TRIGGERED),this.getService(f).disableDefaultStyling()}catch(n){this.getService(g).catch("Error in _disableDefaultStyling: ",n)}}_getLiveSelectionData(){this.getService(g).log("%c[WB] Calling FUNCTION: getLiveSelectionData","color: green;");try{return this.trackEvent(S.Events.Selection.GET_LIVE_SELECTION_DATA_TRIGGERED),this.getService(f).getSelectionsOnCurrentDocument()}catch(n){return this.getService(g).catch("Error in _getLiveSelectionData: ",n),C(null)}}_setInactivityTime(n){this.getService(g).log("%c[WB] Calling FUNCTION: _setInactivityTime","color: green;");try{this.trackEvent(S.Events.Selection.SET_INACTIVITY_TIME_TRIGGERED,{payload:{time:n}}),!isNaN(n)&&n>0?this.getService(f).setInactivityTime(n):this.getService(g).catch("Error in setInactivityTime: ","Provided value must be a positive number greater than zero.")}catch(o){this.getService(g).catch("Error in setInactivityTime: ",o)}}};var rt=(()=>{let n=class n{};n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=Ee({type:n}),n.\u0275inj=me({imports:[De,we,Ne,Ze]});let s=n;return s})();function xt(s){return s.get(g).log("%c[WB] Loading selection feature chunk","color: blue;"),Se(rt,s),new Y(s)}export{xt as default};
|
|
1
|
+
import{a as tt,b as it}from"./chunk-UV3WG5EA.js";import{t as Ze}from"./chunk-YFUTJBEE.js";import"./chunk-MIPUERB4.js";import"./chunk-HKOM6NRJ.js";import"./chunk-6YDKDS43.js";import"./chunk-TQYZX2M7.js";import"./chunk-EVKWK3QF.js";import"./chunk-4YYL5LBM.js";import{b as Qe,d as qe}from"./chunk-FL7TUF6U.js";import{G as Le,H as Ae,I as we,r as ke,t as Ue,v as Ne}from"./chunk-T7KP622G.js";import{a as et}from"./chunk-4I63DKJ7.js";import{A as Ke,y as Je}from"./chunk-LFLSU76Z.js";import{Bb as v,Bj as We,E as N,Eg as ie,Ej as Ve,Fb as _e,Gb as Ie,Gd as Re,Gf as F,Ha as p,Hb as ye,Hc as Oe,He as y,Hf as X,Hg as ne,Ic as Pe,If as H,Ig as $e,J as le,K as se,Kb as Q,Lb as R,M as ae,O as ce,Oa as pe,Oj as Xe,Pb as z,Pj as Ye,Qb as Ce,Ra as j,Rb as q,Rc as De,V as T,Va as Se,Wa as fe,Wg as Be,Xa as Ee,Y as G,Z as ge,Zf as Fe,a as b,ab as x,b as I,ba as he,ca as me,cc as Te,db as be,dc as xe,ea as E,eh as He,fb as L,fh as Me,g as oe,gh as Ge,gj as je,hj as g,ij as ze,l as k,mc as W,na as de,nb as _,nc as V,ob as w,pb as B,qb as K,r as C,rc as Z,re as ee,rg as te,sa as ue,ub as O,v as U,vb as P,ya as ve,zi as S}from"./chunk-MV36YVGA.js";var ht=["selectionElementPortalOverlay"],mt=()=>["velt-overlay-panel"],dt=s=>[s];function ut(s,n){if(s&1&&(O(0),w(1,"span",10),z(2),W(3,"translate"),B(),P()),s&2){let o=v(),e=o.$implicit,t=o.index,i=v(5);p(),R("--velt-selection-color",e==null||e.user==null?null:e.user.color),L("data-testid",i.componentId+"-user-name-"+t),p(),Ce(V(3,4,(e==null||e.user==null?null:e.user.name)||(e==null||e.user==null?null:e.user.email)))}}function vt(s,n){if(s&1&&(O(0),x(1,ut,4,6,"ng-container",3),P()),s&2){let o=n.index,e=v(5);p(),_("ngIf",o<e.maxCount)}}function pt(s,n){if(s&1&&(w(0,"span",11),z(1),B()),s&2){let o=v(4).ngIf,e=v();R("--velt-selection-color",(o.selections[0]==null||o.selections[0].user==null?null:o.selections[0].user.color)||"white"),L("data-testid",e.componentId+"-additional-count")("aria-label",(o.selections==null?null:o.selections.length)-e.maxCount+" additional users"),p(),q("+",(o.selections==null?null:o.selections.length)-e.maxCount)}}function St(s,n){if(s&1&&(O(0),w(1,"div",7),W(2,"translate"),x(3,vt,2,1,"ng-container",8)(4,pt,2,5,"span",9),B(),P()),s&2){let o=v(3).ngIf,e=v();p(),L("data-testid",e.componentId+"-label-container")("aria-label",V(2,4,"Selected users")),p(2),_("ngForOf",o.selections),p(),_("ngIf",(o.selections==null?null:o.selections.length)>e.maxCount)}}function ft(s,n){if(s&1&&(O(0),K(1,"snippyly-user-avatar",13),P()),s&2){let o=v(),e=o.$implicit,t=o.index;p(),R("--velt-selection-color",e==null||e.user==null?null:e.user.color)("--velt-selection-user-index",t),_("size",20)("user",e==null?null:e.user)}}function Et(s,n){if(s&1&&(O(0),x(1,ft,2,6,"ng-container",3),P()),s&2){let o=n.index,e=v(5);p(),_("ngIf",o<e.maxCount)}}function bt(s,n){if(s&1&&(w(0,"div",14),W(1,"translate"),w(2,"span",15),z(3),B()()),s&2){let o=v(4).ngIf,e=v();R("--velt-selection-user-index",o.selections==null?null:o.selections.length)("background-color",(o.selections[(o.selections==null?null:o.selections.length)-1]==null||o.selections[(o.selections==null?null:o.selections.length)-1].user==null?null:o.selections[(o.selections==null?null:o.selections.length)-1].user.color)||"white"),L("data-testid",e.componentId+"-additional-avatars")("aria-label",(o.selections==null?null:o.selections.length)-e.maxCount+" "+V(1,7,"additional users")),p(3),q("+",(o.selections==null?null:o.selections.length)-e.maxCount)}}function _t(s,n){if(s&1&&x(0,Et,2,1,"ng-container",8)(1,bt,4,9,"div",12),s&2){let o=v(3).ngIf,e=v();_("ngForOf",o.selections),p(),_("ngIf",(o.selections==null?null:o.selections.length)>e.maxCount)}}function It(s,n){if(s&1&&x(0,St,5,6,"ng-container",6)(1,_t,2,2,"ng-template",null,2,Z),s&2){let o=Q(2),e=v(2).ngIf,t=v();_("ngIf",(e==null?null:e.userIndicatorType)===(t.userIndicatorTypes==null?null:t.userIndicatorTypes.Label))("ngIfElse",o)}}function yt(s,n){if(s&1&&(O(0),K(1,"div",4,0),x(3,It,3,2,"ng-template",5,1,Z),P()),s&2){let o=Q(2),e=v().ngIf,t=v();p(),R("top",(e==null||e.position==null?null:e.position.top)+t.offsetTop,"px")("left",(e==null||e.position==null?null:e.position.left)+t.offsetLeft,"px"),_("id","selection-element-contianer-"+(t.highlight.user==null?null:t.highlight.user.userSnippylyId)),L("data-testid",t.componentId),p(2),_("cdkConnectedOverlayOrigin",o)("cdkConnectedOverlayOpen",!0)("cdkConnectedOverlayLockPosition",!1)("cdkConnectedOverlayGrowAfterOpen",!0)("cdkConnectedOverlayDisableClose",!0)("cdkConnectedOverlayPanelClass",Te(13,mt))("cdkConnectedOverlayPositions",xe(14,dt,e==null?null:e.overlayPosition))}}function Ct(s,n){if(s&1&&(O(0),x(1,yt,5,16,"ng-container",3),P()),s&2){let o=n.ngIf;p(),_("ngIf",o==null?null:o.position)}}var re=(()=>{let n=class n{get highlight(){return this._highlight}set highlight(e){this._highlight=e,this.calculatePosition()}constructor(e,t,i){this.loggingService=e,this.selectionService=t,this.elementRef=i,this._highlight=new F,this.position=null,this.userIndicatorTypes=H,this.offsetLeft=0,this.offsetTop=0,this.maxCount=1,this.componentConfigSignal=ue({userIndicatorPosition:X.End,userIndicatorType:H.Avatar,position:null,overlayPosition:{originX:"end",originY:"top",overlayX:"end",overlayY:"top"},selections:[]}),this.veltElement=!0,this.componentId="velt-selection-element";try{this.loggingService.log("%c[WB] Creating CLASS: SelectionElementPortalComponent","color: blue;");let r=this.selectionService.getUserIndicatorPosition(),h=this.selectionService.getUserIndicatorType();this.componentConfigSignal.update(d=>(d=I(b({},d),{userIndicatorPosition:r,userIndicatorType:h}),d)),this.setOverlayPosition(r)}catch(r){this.loggingService.log("Error in SelectionElementPortalComponent constructor: ",r)}}ngOnInit(){try{this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in SelectionElementPortalComponent ngOnInit:",e)}}setupA11yAttributes(){try{let e=this.elementRef.nativeElement;e.setAttribute("data-testid",this.componentId+"-container"),e.setAttribute("role","complementary"),e.setAttribute("aria-label","Selection portal")}catch(e){this.loggingService.catch("Error in SelectionElementPortalComponent setupA11yAttributes:",e)}}setSelections(e){try{this.componentConfigSignal.update(t=>(t=I(b({},t),{selections:e}),t))}catch(t){this.loggingService.catch("Error in SelectionElementPortalComponent setSelections: ",t)}}addSelection(e){try{this.componentConfigSignal.update(t=>(t=b({},t),t.selections.push(e),t))}catch(t){this.loggingService.catch("Error in SelectionElementPortalComponent addSelection: ",t)}}ngAfterViewInit(){try{this.loggingService.log("%c[WB] Calling SelectionElementPortalComponent FUNCTION: ngAfterViewInit","color: green;"),this.updateOverlayPosition()}catch(e){this.loggingService.catch("Error in ngAfterViewInit: ",e)}}setOverlayPosition(e){try{this.loggingService.log("%c[WB] Calling SelectionElementPortalComponent FUNCTION: setOverlayPosition","color: green;"),e==="start"?this.componentConfigSignal.update(t=>(t=I(b({},t),{overlayPosition:{originX:"start",originY:"top",overlayX:"start",overlayY:"top"}}),t)):this.componentConfigSignal.update(t=>(t=I(b({},t),{overlayPosition:{originX:"end",originY:"top",overlayX:"end",overlayY:"top"}}),t)),this.updateOverlayPosition()}catch(t){this.loggingService.catch("Error in SelectionElementPortalComponent setOverlayPosition: ",t)}}updateOverlayPosition(){try{this.loggingService.log("%c[WB] Calling SelectionElementPortalComponent FUNCTION: updateOverlayPosition","color: green;"),this.selectionElementPortalOverlay&&this.selectionElementPortalOverlay?.overlayRef?.updatePosition()}catch(e){this.loggingService.catch("Error in SelectionElementPortalComponent updateOverlayPosition: ",e)}}calculatePosition(){try{if(this.loggingService.log("%c[WB] Calling SelectionElementPortalComponent FUNCTION: calculatePosition","color: green;"),this.highlight?.targetElement){let e=He(this.highlight.targetElement);if(e){let t=e.iterateNext(),i,r=null,h=null;try{i=JSON.parse(t?.getAttribute(y.ATTRIBUTES.VELT_SELECTION_CONFIG)||"{}"),r=t?.getAttribute(y.ATTRIBUTES.VELT_LIVE_SELECTION_USER_INDICATOR_POSITION)||this.componentConfigSignal().userIndicatorPosition,r&&this.setOverlayPosition(r),h=t?.getAttribute(y.ATTRIBUTES.VELT_LIVE_SELECTION_USER_INDICATOR_TYPE)||this.componentConfigSignal().userIndicatorType,this.componentConfigSignal.update(a=>(a=I(b({},a),{userIndicatorPosition:r,userIndicatorType:h}),a))}catch{}let d;if(i?.horizontal&&(d=i.horizontal),r==="start"?d="top-start":d="top-right",t){let a=t.getBoundingClientRect();if(a&&a.width&&a.height)switch(d){case"left":this.position={top:a.height/2-16,left:-4};break;case"left-start":this.position={top:0,left:-4};break;case"top-start":this.position={top:-32,left:0};break;case"top-right":this.position={top:-32,left:a.width};break;case"bottom-left":this.position={top:a.height+4,left:0};break;case"bottom-right":this.position={top:a.height+4,left:a.width-32};break;case"center-left":this.position={top:a.height/2-16,left:-32};break;case"center-right":this.position={top:a.height/2-16,left:a.width+4};break;default:this.position={top:-32,left:a.width}}else this.position=null}else this.position=null}else this.position=null}this.componentConfigSignal.update(e=>(e=I(b({},e),{position:this.position}),e))}catch(e){this.loggingService.catch("Error in SelectionElementPortalComponent calculatePosition: ",e)}}};n.\u0275fac=function(t){return new(t||n)(j(g),j(f),j(ve))},n.\u0275cmp=fe({type:n,selectors:[["app-selection-element-portal"]],viewQuery:function(t,i){if(t&1&&_e(ht,5),t&2){let r;Ie(r=ye())&&(i.selectionElementPortalOverlay=r.first)}},hostVars:1,hostBindings:function(t,i){t&2&&L("data-velt-element",i.veltElement)},inputs:{highlight:"highlight",offsetLeft:"offsetLeft",offsetTop:"offsetTop"},standalone:!1,decls:1,vars:1,consts:[["trigger","cdkOverlayOrigin"],["selectionElementPortalOverlay","cdkConnectedOverlay"],["defaultAvatarTypeTemplate",""],[4,"ngIf"],["cdkOverlayOrigin","","role","presentation",1,"selection-element-portal",3,"id"],["cdkConnectedOverlay","",3,"cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayLockPosition","cdkConnectedOverlayGrowAfterOpen","cdkConnectedOverlayDisableClose","cdkConnectedOverlayPanelClass","cdkConnectedOverlayPositions"],[4,"ngIf","ngIfElse"],["role","list",1,"velt-live-selection-element-user-name-container"],[4,"ngFor","ngForOf"],["class","velt-live-selection-element-user-name-plus","role","listitem",3,"--velt-selection-color",4,"ngIf"],["role","listitem",1,"velt-live-selection-element-user-name"],["role","listitem",1,"velt-live-selection-element-user-name-plus"],["class","photo-container","role","listitem",3,"--velt-selection-user-index","background-color",4,"ngIf"],[1,"photo-container","selection-user-avatar",3,"size","user"],["role","listitem",1,"photo-container"],[1,"s-selection-element-avatar-initial"]],template:function(t,i){t&1&&x(0,Ct,2,1,"ng-container",3),t&2&&_("ngIf",i.componentConfigSignal())},dependencies:[Oe,Pe,Ae,Le,qe,Qe],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%]{--velt-green: var(--velt-light-mode-green);--velt-magenta: var(--velt-light-mode-magenta);--velt-amber: var(--velt-light-mode-amber);--velt-purple: var(--velt-light-mode-purple);--velt-cyan: var(--velt-light-mode-cyan);--velt-orange: var(--velt-light-mode-orange);--velt-black: var(--velt-light-mode-black);--velt-white: var(--velt-light-mode-white);--velt-gray: var(--velt-light-mode-gray);--velt-error: var(--velt-light-mode-error);--velt-error-hover: var(--velt-light-mode-error-hover);--velt-error-foreground: var(--velt-light-mode-error-foreground);--velt-error-light: var(--velt-light-mode-error-light);--velt-error-transparent: var(--velt-light-mode-error-transparent);--velt-warning: var(--velt-light-mode-warning);--velt-warning-hover: var(--velt-light-mode-warning-hover);--velt-warning-foreground: var(--velt-light-mode-warning-foreground);--velt-warning-light: var(--velt-light-mode-warning-light);--velt-warning-transparent: var(--velt-light-mode-warning-transparent);--velt-agent-accent: #4495ff;--velt-agent-accent-transparent: rgba(68, 149, 255, .2);--velt-success: var(--velt-light-mode-success);--velt-success-hover: var(--velt-light-mode-success-hover);--velt-success-foreground: var(--velt-light-mode-success-foreground);--velt-success-light: var(--velt-light-mode-success-light);--velt-success-transparent: var(--velt-light-mode-success-transparent);--velt-accent: var(--velt-light-mode-accent);--velt-accent-text: var(--velt-light-mode-accent-text);--velt-accent-hover: var(--velt-light-mode-accent-hover);--velt-accent-foreground: var(--velt-light-mode-accent-foreground);--velt-accent-light: var(--velt-light-mode-accent-light);--velt-accent-transparent: var(--velt-light-mode-accent-transparent);--velt-text-0: var(--velt-light-mode-text-0);--velt-text-1: var(--velt-light-mode-text-1);--velt-text-2: var(--velt-light-mode-text-2);--velt-text-3: var(--velt-light-mode-text-3);--velt-text-4: var(--velt-light-mode-text-4);--velt-text-5: var(--velt-light-mode-text-5);--velt-text-6: var(--velt-light-mode-text-6);--velt-text-7: var(--velt-light-mode-text-7);--velt-text-8: var(--velt-light-mode-text-8);--velt-text-9: var(--velt-light-mode-text-9);--velt-text-10: var(--velt-light-mode-text-10);--velt-text-11: var(--velt-light-mode-text-11);--velt-text-12: var(--velt-light-mode-text-12);--velt-background-0: var(--velt-light-mode-background-0);--velt-background-1: var(--velt-light-mode-background-1);--velt-background-2: var(--velt-light-mode-background-2);--velt-background-3: var(--velt-light-mode-background-3);--velt-background-4: var(--velt-light-mode-background-4);--velt-background-5: var(--velt-light-mode-background-5);--velt-background-6: var(--velt-light-mode-background-6);--velt-background-7: var(--velt-light-mode-background-7);--velt-background-8: var(--velt-light-mode-background-8);--velt-background-9: var(--velt-light-mode-background-9);--velt-background-10: var(--velt-light-mode-background-10);--velt-border-0: var(--velt-light-mode-border-0);--velt-border-1: var(--velt-light-mode-border-1);--velt-border-2: var(--velt-light-mode-border-2);--velt-border-3: var(--velt-light-mode-border-3);--velt-border-4: var(--velt-light-mode-border-4);--velt-border-5: var(--velt-light-mode-border-5);--velt-border-6: var(--velt-light-mode-border-6);--velt-border-7: var(--velt-light-mode-border-7);--velt-border-8: var(--velt-light-mode-border-8);--velt-border-9: var(--velt-light-mode-border-9);--velt-border-10: var(--velt-light-mode-border-10);--velt-background-transparent: var(--velt-light-mode-background-transparent);--velt-border-transparent: var(--velt-light-mode-border-transparent);--velt-animation-transparent: var(--velt-light-mode-animation-transparent);position:absolute;top:0;left:0;box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0);outline:none;margin:0;padding:0;height:unset;width:unset;text-align:left}*[_ngcontent-%COMP%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0);outline:none;margin:0;padding:0;height:unset;width:unset;text-align:left;line-height:1.5;color:#000;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert}.selection-element-portal[_ngcontent-%COMP%]{display:none;position:absolute;top:0;left:0;white-space:nowrap;z-index:1;font-size:var(--velt-font-size-xs)}.photo-container[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:calc((1.5rem + 0px) * var(--velt-base-rem-unit));height:calc((1.5rem + 0px) * var(--velt-base-rem-unit));box-sizing:border-box;background-clip:padding-box;border-radius:50%;color:var(--velt-light-mode-white);border:2px solid var(--velt-selection-color);margin-left:-5px;z-index:calc(var(--velt-selection-user-index, 0) * -1)}.photo-container[_ngcontent-%COMP%] .s-selection-element-avatar-initial[_ngcontent-%COMP%]{color:var(--velt-light-mode-white)}.photo-container[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:100%;height:100%;border-radius:50%;object-fit:cover} snippyly-user-avatar.selection-user-avatar .s-user-avatar-initial{font-size:var(--velt-font-size-md)}.velt-live-selection-element-user-name-container[_ngcontent-%COMP%]{display:flex;gap:var(--velt-spacing-xs);margin-top:5px}.velt-live-selection-element-user-name-container[_ngcontent-%COMP%] .velt-live-selection-element-user-name[_ngcontent-%COMP%]{color:var(--velt-light-mode-white);display:flex;background:var(--velt-selection-color);padding:var(--velt-spacing-xs) var(--velt-spacing-sm);font-size:var(--velt-spacing-md);font-style:normal;font-weight:400;line-height:100%;border-radius:var(--velt-border-radius-md);font-family:var(--velt-default-font-family)}.velt-live-selection-element-user-name-container[_ngcontent-%COMP%] .velt-live-selection-element-user-name-plus[_ngcontent-%COMP%]{color:var(--velt-light-mode-white);display:flex;background:var(--velt-selection-color);padding:var(--velt-spacing-x);font-size:var(--velt-font-size-xs);font-style:normal;font-weight:400;line-height:100%;border-radius:var(--velt-border-radius-md);font-family:var(--velt-default-font-family)}"],changeDetection:0});let s=n;return s})();var f=(()=>{let n=class n{constructor(e,t,i,r,h,d,a,D,J,ot,lt,st,at){this.afAuth=e,this.analyticsService=t,this.authService=i,this.configService=r,this.databaseService=h,this.docService=d,this.domService=a,this.componentFactoryResolver=D,this.injector=J,this.appRef=ot,this.loggingService=lt,this.commonDbService=st,this.realtimeAdapter=at,this.documentPaths=null,this.textSelections={},this.enableSelections$=new k(!1),this.userIndicatorEnabled$=new k(!0),this.userIndicatorPosition$=new k(X.End),this.userIndicatorType$=new k(H.Avatar),this.defaultElementsTrackingEnabled$=new k(!0),this.defaultStylingEnabled$=new k(!0),this.inactivityTime=300*1e3,this.userIdleStateDetectionSubscription=null,this.elementSelections={},this.databaseService.getDb().pipe(N(l=>!!l),se(1)).subscribe(l=>{l&&(this.updateOnDocumentFocusChange(),this.updateOnUserDbConnectionStateChange(l).subscribe(()=>{},m=>{this.loggingService.catch("Error in SelectionService constructor updateOnUserDbConnectionStateChange: ",m)}))},l=>{this.loggingService.catch("Error in SelectionService getDb subscription: ",l)}),this.authService.getUser$().subscribe(l=>{l?this.detectUserIdleState():this.unsubscribeUserIdleStateDetectionSubscription()}),this.docService.getDocumentPaths$().subscribe(l=>{this.documentPaths=l},l=>{this.loggingService.catch("Error in SelectionService getDocumentPaths subscription: ",l)}),this.domService.onDocumentClick$().subscribe(l=>{try{if(this.enableSelections$.value&&this.isFeatureAllowed()&&l?.target&&!window.getSelection()?.toString()){let m=this.getSelectionEnabledElement(l.target);if(m&&!ie(m)){let u=this.domService.getXPath(m);if(u){let c=new F;c.type="click",c.targetElement=u,c.timestamp=this.timestamp,this.setSelection(c)}}else this.removeSelection()}}catch(m){this.loggingService.catch("Error in SelectionService onDocumentClick$: ",m)}},l=>{this.loggingService.catch("Error in SelectionService onDocumentClick$ subscription: ",l)}),this.domService.onDocumentFocus$().subscribe(l=>{try{if(this.enableSelections$.value&&this.isFeatureAllowed()&&l?.target){let m=this.getSelectionEnabledElement(l.target);if(m&&!ie(m)){let u=this.domService.getXPath(m);if(u){let c=new F;c.type="focus",c.targetElement=u,c.timestamp=this.timestamp,this.setSelection(c)}}else this.removeSelection()}}catch(m){this.loggingService.catch("Error in SelectionService onDocumentFocus$: ",m)}},l=>{this.loggingService.catch("Error in SelectionService onDocumentFocus$ subscription: ",l)}),this.domService.onWindowKeyupEsc$().subscribe(l=>{this.removeSelection()},l=>{this.loggingService.catch("Error in SelectionService onWindowKeyupEsc$ subscription: ",l)}),this.enableSelections$.pipe(T(()=>this.isFeatureAllowed$({})),N(l=>l?.config&&l?.user)).subscribe(l=>{(!l?.featureAllowed||!this.enableSelections$.value)&&this.removeSelection()},l=>{this.loggingService.catch("Error in SelectionService enableSelections$ subscription: ",l)}),this.domService.onSelectionChange$().subscribe(()=>{try{if(this.enableSelections$.value&&this.isFeatureAllowed()&&window.getSelection()?.toString()){let l=window.getSelection()?.getRangeAt(0);if(l.commonAncestorContainer&&!l?.collapsed){let m=Me([l]),u=new F;u.type="selection",u.targetTextRange=m?.length?m[0]:null,u.timestamp=this.timestamp,this.setSelection(u)}}}catch(l){this.loggingService.catch("Error in SelectionService onSelectionChange$: ",l)}},l=>{this.loggingService.catch("Error in SelectionService onSelectionChange$ subscription: ",l)}),this.authService.getUser$().subscribe(l=>{this.user=l},l=>{this.loggingService.catch("Error in SelectionService getUser$ subscription: ",l)}),this.getSelectionsOnCurrentDocument().pipe(ce()).subscribe(([l,m])=>{try{if(l){let u=[];Object.keys(l).forEach(c=>{let A=l[c],$=m?m[c]:null;!ne(A,$)&&c!==this.getUserIdHash(this.user)&&u.push(A)}),u.forEach(c=>{if(c.targetElement){let A=this.elementSelections[c?.targetElement]?.portalRef,M=(this.elementSelections[c?.targetElement]?.selections||[]).filter(ct=>this.getUserIdHash(ct.user)!==this.getUserIdHash(c?.user));M?.length?(A.instance.setSelections(M.slice()),this.elementSelections[c?.targetElement].selections=M.slice(),this.highlightElement(M[0])):(this.removeHighlightFromElement(c),this.removeSelectionElement(c))}else c.targetTextRange&&this.removeHighlightFromText(c)})}if(m){let u=[];Object.keys(m).forEach(c=>{let A=l?l[c]:null,$=m[c];!ne(A,$)&&c!==this.getUserIdHash(this.user)&&u.push($)}),u.forEach(c=>{c.targetElement?(this.highlightElement(c),this.getUserIndicatorEnabled()&&this.setElementHighlight(c)):c.targetTextRange&&this.highlightText(c)})}}catch(u){this.loggingService.catch("Error in SelectionService getSelectionsOnCurrentDocument: ",u)}},l=>{this.loggingService.catch("Error in SelectionService getSelectionsOnCurrentDocument subscription: ",l)}),this.authService.addPreSignOutFuction("highlight-signout",this.signOutUser.bind(this))}detectUserIdleState(){try{this.unsubscribeUserIdleStateDetectionSubscription();let e=!1;this.userIdleStateDetectionSubscription=this.domService.onWindowPointerMove$().pipe(ge(2e3),G(()=>{e&&(e=!1)}),le(this.inactivityTime),G(()=>{this.removeSelection(),e=!0})).subscribe()}catch(e){this.loggingService.catch("Error in detectUserIdleState: ",e)}}unsubscribeUserIdleStateDetectionSubscription(){try{this.userIdleStateDetectionSubscription&&(this.userIdleStateDetectionSubscription.unsubscribe(),this.userIdleStateDetectionSubscription=null)}catch(e){this.loggingService.catch("Error in unsubscribeUserIdleStateDetectionSubscription: ",e)}}isFeatureAllowed(){return te(this.configService.getConfig(),this.authService.getUser(),ee.LIVE_SELECTION)}updateOnDocumentFocusChange(){this.loggingService.log("%c[WB] Calling FUNCTION: updateOnDocumentFocusChange","color: green;");try{document&&document.addEventListener("visibilitychange",e=>{this.user&&document.visibilityState==="hidden"&&this.removeSelection()})}catch(e){this.loggingService.catch("Error in updateOnDocumentFocusChange:",e)}}getSelectionsOnCurrentDocument(){return this.loggingService.log("%c[WB] Calling FUNCTION: getSelectionsOnCurrentDocument","color: green;"),this.authService.getAuthState$().pipe(N(e=>!!e),T(e=>this.isFeatureAllowed$({firebaseUser:e})),T(e=>e.featureAllowed?C(e).pipe(T(t=>this.docService.getDocumentPaths$().pipe(U(i=>(this.documentPaths=i,t)))),T(t=>t?.user?t?.user?.isAnonymous?C(null):this.documentPaths?this.databaseService.getDb().pipe(N(i=>!!i),T(i=>this.documentPaths?.selection?this.commonDbService.dbListener({feature:"allSelections",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(U(r=>r?.data),U(r=>this.filterActiveSelections(r))):C(null))):C(null):C(null))):C(null)))}isFeatureAllowed$(e){return this.configService.getConfig$().pipe(N(t=>!!t),U(t=>I(b({},e),{config:t})),T(t=>this.authService.getUser$().pipe(U(i=>(this.user=i,I(b({},t),{user:i}))))),T(t=>te(t.config,t.user,ee.LIVE_SELECTION)?C(I(b({},t),{featureAllowed:!0})):(this.loggingService.warn("Live Selection feature is not allowed."),C(I(b({},t),{featureAllowed:!1})))),ae((t,i)=>t?.featureAllowed===i?.featureAllowed))}filterActiveSelections(e){this.loggingService.log("%c[WB] Calling FUNCTION: filterOnlineUsers","color: green;");try{if(e&&typeof e=="object"&&Object.keys(e).length){let t={},i=this.commonDbService.getServerTimestamp();return Object.keys(e).forEach(r=>{let h=e[r];h?.timestamp&&Math.abs(i-h.timestamp)<this.inactivityTime&&(t[r]=h)}),t}return e}catch(t){return this.loggingService.catch("Error in filterOnlineUsers:",t),e}}setSelection(e){try{if(this.user?.userId&&this.documentPaths?.selection){e.user=this.user;let t=JSON.parse(JSON.stringify(e));t&&!t?.timestamp&&(t.timestamp=this.timestamp),this.commonDbService.updateData({feature:"selection",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:this.getUserIdHash(this.user)??"",skipFirestore:!0},data:t})}}catch(t){this.loggingService.catch("Error in SelectionService setSelection: ",t)}}removeSelection(){try{this.user?.userId&&this.documentPaths?.selection&&this.commonDbService.deleteData({feature:"selection",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:this.getUserIdHash(this.user)??"",skipFirestore:!0}})}catch(e){this.loggingService.catch("Error in SelectionService removeSelection: ",e)}}updateOnUserDbConnectionStateChange(e){return this.loggingService.log("%c[WB] Calling FUNCTION: updateOnUserDbConnectionStateChange","color: green;"),this.authService.getAuthState$().pipe(N(t=>!!t),T(t=>this.docService.getDocumentPaths$().pipe(U(i=>t))),G(t=>oe(this,null,function*(){try{if(this.documentPaths&&t){let i=yield this.authService.getIdTokenResultForUser(t,!0).catch(h=>null);if(!i)return;let{user:r}=i.claims;if(r&&this.documentPaths?.selection){let h=this.getUserIdHash(r);if(h){let d=`${this.documentPaths.selection}/${h}`,a=this.realtimeAdapter.rtdbRef(e,d);this.realtimeAdapter.rtdbOnDisconnectRemove("selection",a).catch(D=>{this.loggingService.catch("Error in SelectionService updateOnUserDbConnectionStateChange onDisconnect:",D)})}}}}catch(i){this.loggingService.catch("Error in SelectionService updateOnUserDbConnectionStateChange:",i)}})))}highlightElement(e){try{let t=this.domService.getXPath(e.targetElement);if(t){let i=t.iterateNext();if(i){let r=["input","textarea","select","button"],h;try{i?.getAttribute(y.ATTRIBUTES.VELT_SELECTION_CONFIG)&&(h=JSON.parse(i?.getAttribute(y.ATTRIBUTES.VELT_SELECTION_CONFIG)||"{}"))}catch{}(!h||h?.border)&&this.domService.highlightUserElement(i,e?.user?.color,e?.user?.name,this.getDefaultStylingEnabled())}}}catch(t){this.loggingService.catch("Error in SelectionService highlightElement: ",t)}}removeHighlightFromElement(e){try{let t=this.domService.getXPath(e.targetElement);if(t){let i=t.iterateNext();i&&this.domService.removeHighlightUserFromElement(i)}}catch(t){this.loggingService.catch("Error in SelectionService removeHighlightFromElement: ",t)}}highlightText(e){try{if(e?.targetTextRange){let t=$e(e.targetTextRange?.text,this.domService.getXPath(e.targetTextRange?.commonAncestorContainer).iterateNext(),e.targetTextRange?.occurrence),i=new Range;try{i.setStart(t[0].textNode,t[0].startOffset||0),i.setEnd(t[t.length-1].textNode,t[t.length-1].endOffset||0)}catch{}if(i.toString()===e.targetTextRange?.text){let r=tt(i,y.TAGS.SNIPPYLY_HIGHLIGHT_USER_TEXT),h=[],d=this.getSelectionUserMarker(e.user);if(r&&r.length&&(r.forEach(a=>{a?.textContent?.trim()&&(this.domService.addClassToElement(a,a.tagName?.toLowerCase()),this.domService.addClassToElement(a,y.VELT_LIVE_SELECTION_ON_TEXT),this.getDefaultStylingEnabled()&&this.domService.addClassToElement(a,y.VELT_LIVE_SELECTION_ON_TEXT_DEFAULT),e.user?.color&&a.style.setProperty(y.VELT_SELECTION_COLOR,e.user?.color+"55"),h.push({element:a,textNode:a.childNodes[0]}))}),d)){let a=r.filter(J=>J?.textContent?.trim()),D=a?.length?a[a?.length-1]:null;D&&D.parentNode.insertBefore(d,D.nextSibling)}this.textSelections[this.getUserIdHash(e?.user)]={textNodes:h,marker:d}}}}catch(t){this.loggingService.catch("Error in SelectionService highlightText: ",t)}}removeHighlightFromText(e){try{let t=this.getUserIdHash(e?.user);t&&this.textSelections[t]?.textNodes?.length&&(this.textSelections[t].textNodes.forEach(i=>{let r=i?.element?.parentNode??i?.textNode?.parentNode;i?.element&&i?.textNode&&it(i.element,i.textNode),i.textNode&&Be(r)}),this.textSelections[t]?.marker&&this.textSelections[t]?.marker?.remove())}catch(t){this.loggingService.catch("Error in SelectionService removeHighlightFromText: ",t)}}getSelectionUserMarker(e){try{let t=document.createElement("span");t.classList.add("snippyly-user-marker","active"),t.setAttribute("data-name",e?.name+""),t.style.setProperty("--velt-selection-marker-color",e?.color||"#000");let i=document.createElement("span");i.classList.add("snippyly-user-marker-line");let r=document.createElement("span");return r.classList.add("snippyly-user-marker-dot"),i.appendChild(r),t.appendChild(i),setTimeout(()=>{t?.classList?.remove("active")},1e3),t}catch(t){return this.loggingService.catch("Error in SelectionService getSelectionUserMarker: ",t),null}}signOutUser(e){return new Promise((t,i)=>{try{this.documentPaths?.selection&&e?this.commonDbService.getData({feature:"selection",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0}}).then(r=>{r&&this.commonDbService.deleteData({feature:"selection",errorCallback:h=>{i(h)},callback:()=>{t(null)},properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:this.getUserIdHash(this.user)??"",skipFirestore:!0}}),t(null)}).catch(r=>{this.loggingService.catch("Error in SelectionService signOutUser subscription: ",r),i(r)}):t(null)}catch(r){this.loggingService.catch("Error in SelectionService signOutUser:",r),i(r)}})}setInactivityTime(e){try{this.inactivityTime=e,this.analyticsService.trackEvent(S.Events.Selection.SELECTION_SET_CUSTOM_INACTIVITY_TIMER,{inactivityTime:this.inactivityTime}),this.detectUserIdleState()}catch(t){this.loggingService.catch("Error in SelectionService setInactivityTime: ",t)}}getInactivityTime(){return this.inactivityTime}enableSelections(e){try{this.enableSelections$.next(e)}catch(t){this.loggingService.catch("Error in SelectionService enableSelections: ",t)}}enableUserIndicator(){try{if(this.userIndicatorEnabled$.value===!0)return;this.userIndicatorEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in SelectionService enableUserIndicator: ",e)}}disableUserIndicator(){try{if(this.userIndicatorEnabled$.value===!1)return;this.userIndicatorEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in SelectionService disableUserIndicator: ",e)}}getUserIndicatorEnabled$(){return this.userIndicatorEnabled$.asObservable()}getUserIndicatorEnabled(){return this.userIndicatorEnabled$.value}setUserIndicatorPosition(e){try{this.userIndicatorPosition$.next(e)}catch(t){this.loggingService.catch("Error in SelectionService setUserIndicatorPosition: ",t)}}getUserIndicatorPosition$(){return this.userIndicatorPosition$.asObservable()}getUserIndicatorPosition(){return this.userIndicatorPosition$.value}setUserIndicatorType(e){try{this.userIndicatorType$.next(e)}catch(t){this.loggingService.catch("Error in SelectionService setUserIndicatorType: ",t)}}getUserIndicatorType$(){return this.userIndicatorType$.asObservable()}getUserIndicatorType(){return this.userIndicatorType$.value}enableDefaultElementsTracking(){try{if(this.defaultElementsTrackingEnabled$.value===!0)return;this.defaultElementsTrackingEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in SelectionService enableDefaultElementsTracking: ",e)}}disableDefaultElementsTracking(){try{if(this.defaultElementsTrackingEnabled$.value===!1)return;this.defaultElementsTrackingEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in SelectionService disableDefaultElementsTracking: ",e)}}getDefaultElementsTrackingEnabled$(){return this.defaultElementsTrackingEnabled$.asObservable()}getDefaultElementsTrackingEnabled(){return this.defaultElementsTrackingEnabled$.value}enableDefaultStyling(){try{if(this.defaultStylingEnabled$.value===!0)return;this.defaultStylingEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in SelectionService enableDefaultStyling: ",e)}}disableDefaultStyling(){try{if(this.defaultStylingEnabled$.value===!1)return;this.defaultStylingEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in SelectionService disableDefaultStyling: ",e)}}getDefaultStylingEnabled$(){return this.defaultStylingEnabled$.asObservable()}getDefaultStylingEnabled(){return this.defaultStylingEnabled$.value}getSelectionEnabledElement(e){try{let t=this.getDefaultElementsTrackingEnabled();return t&&y.SELECTION_ENABLED_ELEMENTS[e.tagName?.toLowerCase()]?e:Ge(e,t)}catch(t){return this.loggingService.catch("Error in SelectionService isElementAllowed: ",t),null}}setElementHighlight(e){try{if(!this.elementSelections[e.targetElement])this.setSelectionElement(e);else{let t=this.elementSelections[e.targetElement].portalRef;this.elementSelections[e.targetElement].selections?.find(r=>this.getUserIdHash(r.user)===this.getUserIdHash(e?.user))||(t.instance.addSelection(e),this.elementSelections[e.targetElement].selections.push(e))}}catch(t){this.loggingService.catch("Error in SelectionService setElementSelection: ",t)}}setSelectionElement(e){try{let t=this.domService.getXPath(e.targetElement);if(t){let i=t.iterateNext();if(i){let r=this.domService.getHostElement(i),h=new ke(re),d=new Ue(r,this.appRef,this.injector),a=d.attach(h);a.instance.highlight=e,a.instance.setSelections([e]),this.elementSelections[e.targetElement]={selectionHostDomPortalOutlet:d,selectionElementPortal:h,portalRef:a,selections:[JSON.parse(JSON.stringify(e))],userTargetElement:i,selectionHostElement:r,targetElement:e.targetElement},this.updateElementOffset(e)}}}catch(t){this.loggingService.catch("Error in SelectionService setSelectionElement: ",t)}}updateElementOffset(e){try{let{portalRef:t,userTargetElement:i,selectionHostElement:r}=this.elementSelections[e.targetElement],h=this.domService.getElementOffset(i,r);t.instance.offsetLeft=h.offsetLeft,t.instance.offsetTop=h.offsetTop}catch(t){this.loggingService.catch("Error in SelectionService updateElementOffset: ",t)}}checkElementHighlightsToRemove(e){try{let t=e.map(i=>i.targetElement);Object.keys(this.elementSelections).forEach(i=>{if(!t.includes(i)){let r=this.elementSelections[i];r&&(r.selectionHostDomPortalOutlet.detach(),this.domService.removeHighlightFromElement(r.selectionHostElement)),delete this.elementSelections[i]}})}catch(t){this.loggingService.catch("Error in SelectionService checkElementHighlightsToRemove: ",t)}}removeSelectionElement(e){try{let t=this.elementSelections[e.targetElement];t&&(t.selectionHostDomPortalOutlet.detach(),this.domService.removeHighlightFromElement(t.selectionHostElement)),delete this.elementSelections[e.targetElement]}catch(t){this.loggingService.catch("Error in SelectionService removeSelectionElement: ",t)}}getUserIdHash(e){try{return e?.userId?Fe(e?.userId):null}catch(t){return this.loggingService.catch("Error in SelectionService getUserIdHash: ",t),null}}get timestamp(){return this.commonDbService.getServerTimestamp()}};n.\u0275fac=function(t){return new(t||n)(E(Re),E(je),E(Ye),E(ze),E(We),E(Ke),E(Xe),E(pe),E(de),E(be),E(g),E(Je),E(Ve))},n.\u0275prov=he({token:n,factory:n.\u0275fac,providedIn:"root"});let s=n;return s})();var Y=class extends et{constructor(n){super(n),this.getService(g).log("%c[WB] Creating CLASS: SelectionElement","color: blue;"),this.enableLiveSelection=this._enableLiveSelection,this.disableLiveSelection=this._disableLiveSelection,this.enableUserIndicator=this._enableUserIndicator,this.disableUserIndicator=this._disableUserIndicator,this.setUserIndicatorPosition=this._setUserIndicatorPosition,this.setUserIndicatorType=this._setUserIndicatorType,this.enableDefaultElementsTracking=this._enableDefaultElementsTracking,this.disableDefaultElementsTracking=this._disableDefaultElementsTracking,this.enableDefaultStyling=this._enableDefaultStyling,this.disableDefaultStyling=this._disableDefaultStyling,this.getLiveSelectionData=this._getLiveSelectionData,this.setInactivityTime=this._setInactivityTime}_enableLiveSelection(){this.getService(g).log("%c[WB] Calling FUNCTION: _enableLiveSelection","color: green;");try{this.trackEvent(S.Events.Selection.ENABLE_LIVE_SELECTION_TRIGGERED),this.getService(f).enableSelections(!0)}catch(n){this.getService(g).catch("Error in enableLiveSelection: ",n)}}_disableLiveSelection(){this.getService(g).log("%c[WB] Calling FUNCTION: _disableLiveSelection","color: green;");try{this.trackEvent(S.Events.Selection.DISABLE_LIVE_SELECTION_TRIGGERED),this.getService(f).enableSelections(!1)}catch(n){this.getService(g).catch("Error in disableLiveSelection: ",n)}}_enableUserIndicator(){this.getService(g).log("%c[WB] Calling FUNCTION: enableUserIndicator","color: green;");try{this.trackEvent(S.Events.Selection.ENABLE_USER_INDICATOR_TRIGGERED),this.getService(f).enableUserIndicator()}catch(n){this.getService(g).catch("Error in _enableUserIndicator: ",n)}}_disableUserIndicator(){this.getService(g).log("%c[WB] Calling FUNCTION: disableUserIndicator","color: green;");try{this.trackEvent(S.Events.Selection.DISABLE_USER_INDICATOR_TRIGGERED),this.getService(f).disableUserIndicator()}catch(n){this.getService(g).catch("Error in _disableUserIndicator: ",n)}}_setUserIndicatorPosition(n){this.getService(g).log("%c[WB] Calling FUNCTION: setUserIndicatorPosition","color: green;");try{this.trackEvent(S.Events.Selection.SET_USER_INDICATOR_POSITION_TRIGGERED,{payload:{position:n}}),this.getService(f).setUserIndicatorPosition(n)}catch(o){this.getService(g).catch("Error in _setUserIndicatorPosition: ",o)}}_setUserIndicatorType(n){this.getService(g).log("%c[WB] Calling FUNCTION: setUserIndicatorType","color: green;");try{this.trackEvent(S.Events.Selection.SET_USER_INDICATOR_TYPE_TRIGGERED,{payload:{type:n}}),this.getService(f).setUserIndicatorType(n)}catch(o){this.getService(g).catch("Error in _setUserIndicatorType: ",o)}}_enableDefaultElementsTracking(){this.getService(g).log("%c[WB] Calling FUNCTION: enableDefaultElementsTracking","color: green;");try{this.trackEvent(S.Events.Selection.ENABLE_DEFAULT_ELEMENTS_TRACKING_TRIGGERED),this.getService(f).enableDefaultElementsTracking()}catch(n){this.getService(g).catch("Error in _enableDefaultElementsTracking: ",n)}}_disableDefaultElementsTracking(){this.getService(g).log("%c[WB] Calling FUNCTION: disableDefaultElementsTracking","color: green;");try{this.trackEvent(S.Events.Selection.DISABLE_DEFAULT_ELEMENTS_TRACKING_TRIGGERED),this.getService(f).disableDefaultElementsTracking()}catch(n){this.getService(g).catch("Error in _disableDefaultElementsTracking: ",n)}}_enableDefaultStyling(){this.getService(g).log("%c[WB] Calling FUNCTION: enableDefaultStyling","color: green;");try{this.trackEvent(S.Events.Selection.ENABLE_DEFAULT_STYLING_TRIGGERED),this.getService(f).enableDefaultStyling()}catch(n){this.getService(g).catch("Error in _enableDefaultStyling: ",n)}}_disableDefaultStyling(){this.getService(g).log("%c[WB] Calling FUNCTION: disableDefaultStyling","color: green;");try{this.trackEvent(S.Events.Selection.DISABLE_DEFAULT_STYLING_TRIGGERED),this.getService(f).disableDefaultStyling()}catch(n){this.getService(g).catch("Error in _disableDefaultStyling: ",n)}}_getLiveSelectionData(){this.getService(g).log("%c[WB] Calling FUNCTION: getLiveSelectionData","color: green;");try{return this.trackEvent(S.Events.Selection.GET_LIVE_SELECTION_DATA_TRIGGERED),this.getService(f).getSelectionsOnCurrentDocument()}catch(n){return this.getService(g).catch("Error in _getLiveSelectionData: ",n),C(null)}}_setInactivityTime(n){this.getService(g).log("%c[WB] Calling FUNCTION: _setInactivityTime","color: green;");try{this.trackEvent(S.Events.Selection.SET_INACTIVITY_TIME_TRIGGERED,{payload:{time:n}}),!isNaN(n)&&n>0?this.getService(f).setInactivityTime(n):this.getService(g).catch("Error in setInactivityTime: ","Provided value must be a positive number greater than zero.")}catch(o){this.getService(g).catch("Error in setInactivityTime: ",o)}}};var rt=(()=>{let n=class n{};n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=Ee({type:n}),n.\u0275inj=me({imports:[De,we,Ne,Ze]});let s=n;return s})();function xt(s){return s.get(g).log("%c[WB] Loading selection feature chunk","color: blue;"),Se(rt,s),new Y(s)}export{xt as default};
|