@veltdev/sdk-staging 6.0.8 → 6.0.9-beta.2
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/element/comment-element.model.d.ts +34 -2
- package/{chunk-UQI5JFMO.js → chunk-3ORHWUHZ.js} +1 -1
- package/{chunk-O64Y7CY5.js → chunk-5R5ZQKPN.js} +1 -1
- package/{chunk-JKLS6423.js → chunk-6RWQRJ7Z.js} +1 -1
- package/{chunk-QYY5QDZZ.js → chunk-7RRXZUH7.js} +1 -1
- package/{chunk-H3AESJRG.js → chunk-AJXYT2YT.js} +1 -1
- package/{chunk-PDOET6TG.js → chunk-AOHWVH4J.js} +1 -1
- package/{chunk-4BWTKX3J.js → chunk-BJRSXB3P.js} +1 -1
- package/{chunk-3T53AUKI.js → chunk-CFLYO4ZJ.js} +1 -1
- package/{chunk-MVFPB6P2.js → chunk-CI2SH5RY.js} +1 -1
- package/{chunk-GDYKECHB.js → chunk-CQX575C2.js} +1 -1
- package/{chunk-SHXQBB7N.js → chunk-EQBACTBQ.js} +1 -1
- package/{chunk-OK6SKS5O.js → chunk-F36WWKDQ.js} +1 -1
- package/{chunk-FKN5MCLS.js → chunk-F44SU3DK.js} +1 -1
- package/{chunk-UUEOTEBS.js → chunk-F4PYCUAT.js} +1 -1
- package/{chunk-KPCULYW2.js → chunk-F6CKB7IS.js} +1 -1
- package/{chunk-MUZB4ZRW.js → chunk-FUYX2CTL.js} +1 -1
- package/{chunk-23YNPJA6.js → chunk-IBGPKEZW.js} +1 -1
- package/{chunk-7AHH7XWM.js → chunk-ID3E7CBZ.js} +1 -1
- package/{chunk-CQ2PFN5H.js → chunk-IU25BW6T.js} +1 -1
- package/{chunk-QHAOMKNT.js → chunk-JHMDMOHO.js} +1 -1
- package/{chunk-23Y35Q3J.js → chunk-PSVE75CB.js} +1 -1
- package/{chunk-E2Q3RJVJ.js → chunk-QTF4Y24I.js} +1 -1
- package/{chunk-3QB54TU3.js → chunk-RLD74EXO.js} +1 -1
- package/{chunk-2N7F6RD7.js → chunk-SY46UNW5.js} +1 -1
- package/{chunk-6AS4UBOQ.js → chunk-SYSCTHS4.js} +1 -1
- package/{chunk-4ZVKEG33.js → chunk-TW7O56QU.js} +1 -1
- package/{chunk-PPWVFIE5.js → chunk-UKJTOZK4.js} +1 -1
- package/{chunk-4EV2AXDK.js → chunk-VKGZ33MA.js} +1 -1
- package/{chunk-ABE26DFY.js → chunk-VMW7PJFD.js} +1 -1
- package/{chunk-ZWTASV4Q.js → chunk-VMY3F7K3.js} +1 -1
- package/{chunk-TVHRQJC4.js → chunk-WFO2GRDO.js} +1 -1
- package/{chunk-S7J3GTUB.js → chunk-XISY42XO.js} +1 -1
- package/{chunk-F7UEUUNI.js → chunk-ZJH32HDL.js} +1 -1
- package/package.json +1 -1
- package/velt-activity-log.js +1 -1
- package/velt-area.js +1 -1
- package/velt-arrow.js +1 -1
- package/velt-comment.js +7 -7
- package/velt-crdt.js +1 -1
- package/velt-cursor.js +1 -1
- package/velt-huddle.js +1 -1
- package/velt-live-state-sync.js +1 -1
- package/velt-notification.js +1 -1
- package/velt-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 +5 -5
package/velt-rewriter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ot}from"./chunk-CQ2PFN5H.js";import{c as je,d as Ge}from"./chunk-ZWTASV4Q.js";import{a as rt,c as ot,d as at}from"./chunk-FKN5MCLS.js";import{t as Tt}from"./chunk-PDOET6TG.js";import"./chunk-O64Y7CY5.js";import{b as qe,c as Je,g as et,l as tt}from"./chunk-S7J3GTUB.js";import"./chunk-4ZVKEG33.js";import{a as bt}from"./chunk-QYY5QDZZ.js";import"./chunk-MVFPB6P2.js";import"./chunk-GDYKECHB.js";import{b as Et}from"./chunk-KPCULYW2.js";import{a as It}from"./chunk-MUZB4ZRW.js";import{a as Qe}from"./chunk-E2Q3RJVJ.js";import{A as $e,G as Ye,H as Xe,I as ze,r as We,t as Ze}from"./chunk-UQI5JFMO.js";import{$ as z,$d as st,Bg as ht,Ch as O,Db as re,Dh as ft,E as le,Ea as ke,Eb as oe,Ee as x,Fa as g,Fb as ae,Fc as Fe,Ga as me,Gc as ge,Ib as Z,Ig as Ct,J as Oe,Kb as L,Ma as Le,Nb as k,Ob as se,Od as Ke,Pa as R,Pb as N,Pc as Ue,Qe as ct,Sb as we,Se as lt,T as Ae,Ta as Ve,Tb as xe,Td as it,Ua as G,Ub as Se,Ud as nt,Uh as vt,Va as Ne,Vf as mt,Vh as wt,_a as E,a as M,aa as Pe,ac as He,b as D,bb as Be,bi as xt,ca as T,ci as St,da as Me,db as W,g as V,ha as C,hg as ye,ia as _,ig as de,ii as q,ja as I,jg as gt,ji as J,k as ve,ka as F,kc as v,kf as pt,ki as h,l as X,la as De,lb as u,lc as w,li as yt,mb as c,mg as dt,nb as l,ob as f,oi as Rt,pc as $,qa as pe,r as j,sb as Q,si as B,tb as K,ti as he,v as Te,vb as A,xb as S,xh as _t,z as Ie,zb as p,zh as ut}from"./chunk-4EV2AXDK.js";var te=(()=>{let o=class o{constructor(e){this.loggingService=e,this.actionSubjects=new Map}onTextSelected(e){try{this.triggerAction(st.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 ve),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 ve),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)(T(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=Me(Rt),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(wt).subscribe(b=>this.commentActionsService=b),this.getRewriterEnabled$().subscribe(b=>{try{if(b){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),Oe(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)}},b=>{this.loggingService.catch("Error in rewriterEnabled$ subscription: ",b)})}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 pt;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{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=ft(this.functions,ut({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()})),a=yield _t({methodName:"rewriterAskAi",data:{type:"rewriterAskAi",data:{model:e.model,prompt:e.prompt,text:e.selectedText}},getSdkProxy:i,userId:t});return Nt(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 ct;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 lt;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?(i.deleteContents(),i.insertNode(document.createTextNode(t)),i.commonAncestorContainer.parentElement?.normalize(),!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)(T(J),T(he),T(yt),T(B),T(h),T(Ke),T(te),T(q))},o.\u0275prov=z({token:o,factory:o.\u0275fac,providedIn:"root"});let r=o;return r})();function Nt(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 Ht=["copywriterContainer"],Ft=["searchInput"];function Ut(r,o){}function jt(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",35)(3,"rect",36),l())}function Gt(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",36),l())}function Wt(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,jt,4,0,"svg",31)(3,Gt,3,0,"ng-template",null,3,$),c(5,"span",32),k(6),l()(),K()}if(r&2){let n=o.$implicit,e=o.index,t=Z(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 Zt(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 $t(r,o){if(r&1){let n=A();c(0,"span",47),S("click",function(){C(n);let t=p(4);return _(t.onShowOriginalTextClick())}),k(1),v(2,"translate"),l()}r&2&&(g(),se(w(2,1,"Show original text")))}function Yt(r,o){r&1&&(c(0,"div",16),k(1),v(2,"translate"),l()),r&2&&(g(),N(" ",w(2,1,"Select a rewritten text to create a task")))}function Xt(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,Yt,3,3,"div",49),k(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 zt(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()(),k(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),k(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,Wt,7,5,"ng-container",22)(24,Zt,10,0,"div",23),l(),c(25,"div",24),E(26,$t,3,3,"span",25),f(27,"div"),E(28,Xt,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 Qt(r,o){if(r&1&&E(0,zt,32,22,"div",8),r&2){let n=p(2);u("ngIf",n.type==="copywriter")}}function Kt(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 qt(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"),Se("ngModelChange",function(t){C(n);let i=p(3);return xe(i.prompt,t)||(i.prompt=t),_(t)}),S("keyup.enter",function(){C(n);let t=p(3);return _(t.getRewriterOptions())}),l()(),E(9,Kt,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?")),we("ngModel",e.prompt),u("disabled",n.loading||n.searchCount>=e.MAX_SEARCH_COUNT),g(3),u("ngIf",!n.loading)}}function Jt(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",35)(3,"rect",36),l())}function ei(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",36),l())}function ti(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,Jt,4,0,"svg",31)(3,ei,3,0,"ng-template",null,3,$),c(5,"span",32),k(6),v(7,"translate"),l()(),K()}if(r&2){let n=o.$implicit,e=o.index,t=Z(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 ii(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 ni(r,o){if(r&1){let n=A();c(0,"span",47),S("click",function(){C(n);let t=p(4);return _(t.onShowOriginalTextClick())}),k(1),v(2,"translate"),l()}r&2&&(g(),se(w(2,1,"Show original text")))}function ri(r,o){r&1&&(c(0,"div",16),k(1),v(2,"translate"),l()),r&2&&(g(),N(" ",w(2,1,"Select a rewritten text to create a task")))}function oi(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,ri,3,3,"div",49),k(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 ai(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"),Se("ngModelChange",function(t){C(n);let i=p(3);return xe(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),k(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),k(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),k(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,ti,8,7,"ng-container",22),l(),E(40,ii,10,0,"div",23),c(41,"div",24),E(42,ni,3,3,"span",25),f(43,"div"),E(44,oi,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?")),we("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 si(r,o){if(r&1&&E(0,qt,10,8,"div",8)(1,ai,48,40,"div",8),r&2){let n=p().ngIf;u("ngIf",!n.apiCalled),g(),u("ngIf",n.apiCalled)}}function ci(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,Ut,0,0,"ng-template",7),l(),E(4,Qt,1,1,"ng-template",null,1,$)(6,si,2,2,"ng-template",null,2,$),K()}if(r&2){let n=Z(5),e=Z(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(vt).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=>D(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=>D(M({},d),{loading:!0}));let e=Ct(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 Ot}from"./chunk-IU25BW6T.js";import{c as je,d as Ge}from"./chunk-VMY3F7K3.js";import{a as rt,c as ot,d as at}from"./chunk-F44SU3DK.js";import{t as Tt}from"./chunk-AOHWVH4J.js";import"./chunk-5R5ZQKPN.js";import{b as qe,c as Je,g as et,l as tt}from"./chunk-XISY42XO.js";import"./chunk-TW7O56QU.js";import{a as bt}from"./chunk-7RRXZUH7.js";import"./chunk-CI2SH5RY.js";import"./chunk-CQX575C2.js";import{b as Et}from"./chunk-F6CKB7IS.js";import{a as It}from"./chunk-FUYX2CTL.js";import{a as Qe}from"./chunk-QTF4Y24I.js";import{A as $e,G as Ye,H as Xe,I as ze,r as We,t as Ze}from"./chunk-3ORHWUHZ.js";import{$ as z,$d as st,Bg as ht,Ch as O,Db as re,Dh as ft,E as le,Ea as ke,Eb as oe,Ee as x,Fa as g,Fb as ae,Fc as Fe,Ga as me,Gc as ge,Ib as Z,Ig as Ct,J as Oe,Kb as L,Ma as Le,Nb as k,Ob as se,Od as Ke,Pa as R,Pb as N,Pc as Ue,Qe as ct,Sb as we,Se as lt,T as Ae,Ta as Ve,Tb as xe,Td as it,Ua as G,Ub as Se,Ud as nt,Uh as vt,Va as Ne,Vf as mt,Vh as wt,_a as E,a as M,aa as Pe,ac as He,b as D,bb as Be,bi as xt,ca as T,ci as St,da as Me,db as W,g as V,ha as C,hg as ye,ia as _,ig as de,ii as q,ja as I,jg as gt,ji as J,k as ve,ka as F,kc as v,kf as pt,ki as h,l as X,la as De,lb as u,lc as w,li as yt,mb as c,mg as dt,nb as l,ob as f,oi as Rt,pc as $,qa as pe,r as j,sb as Q,si as B,tb as K,ti as he,v as Te,vb as A,xb as S,xh as _t,z as Ie,zb as p,zh as ut}from"./chunk-VKGZ33MA.js";var te=(()=>{let o=class o{constructor(e){this.loggingService=e,this.actionSubjects=new Map}onTextSelected(e){try{this.triggerAction(st.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 ve),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 ve),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)(T(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=Me(Rt),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(wt).subscribe(b=>this.commentActionsService=b),this.getRewriterEnabled$().subscribe(b=>{try{if(b){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),Oe(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)}},b=>{this.loggingService.catch("Error in rewriterEnabled$ subscription: ",b)})}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 pt;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{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=ft(this.functions,ut({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()})),a=yield _t({methodName:"rewriterAskAi",data:{type:"rewriterAskAi",data:{model:e.model,prompt:e.prompt,text:e.selectedText}},getSdkProxy:i,userId:t});return Nt(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 ct;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 lt;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?(i.deleteContents(),i.insertNode(document.createTextNode(t)),i.commonAncestorContainer.parentElement?.normalize(),!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)(T(J),T(he),T(yt),T(B),T(h),T(Ke),T(te),T(q))},o.\u0275prov=z({token:o,factory:o.\u0275fac,providedIn:"root"});let r=o;return r})();function Nt(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 Ht=["copywriterContainer"],Ft=["searchInput"];function Ut(r,o){}function jt(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",35)(3,"rect",36),l())}function Gt(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",36),l())}function Wt(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,jt,4,0,"svg",31)(3,Gt,3,0,"ng-template",null,3,$),c(5,"span",32),k(6),l()(),K()}if(r&2){let n=o.$implicit,e=o.index,t=Z(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 Zt(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 $t(r,o){if(r&1){let n=A();c(0,"span",47),S("click",function(){C(n);let t=p(4);return _(t.onShowOriginalTextClick())}),k(1),v(2,"translate"),l()}r&2&&(g(),se(w(2,1,"Show original text")))}function Yt(r,o){r&1&&(c(0,"div",16),k(1),v(2,"translate"),l()),r&2&&(g(),N(" ",w(2,1,"Select a rewritten text to create a task")))}function Xt(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,Yt,3,3,"div",49),k(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 zt(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()(),k(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),k(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,Wt,7,5,"ng-container",22)(24,Zt,10,0,"div",23),l(),c(25,"div",24),E(26,$t,3,3,"span",25),f(27,"div"),E(28,Xt,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 Qt(r,o){if(r&1&&E(0,zt,32,22,"div",8),r&2){let n=p(2);u("ngIf",n.type==="copywriter")}}function Kt(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 qt(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"),Se("ngModelChange",function(t){C(n);let i=p(3);return xe(i.prompt,t)||(i.prompt=t),_(t)}),S("keyup.enter",function(){C(n);let t=p(3);return _(t.getRewriterOptions())}),l()(),E(9,Kt,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?")),we("ngModel",e.prompt),u("disabled",n.loading||n.searchCount>=e.MAX_SEARCH_COUNT),g(3),u("ngIf",!n.loading)}}function Jt(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",35)(3,"rect",36),l())}function ei(r,o){r&1&&(I(),c(0,"svg",33),f(1,"rect",34)(2,"rect",36),l())}function ti(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,Jt,4,0,"svg",31)(3,ei,3,0,"ng-template",null,3,$),c(5,"span",32),k(6),v(7,"translate"),l()(),K()}if(r&2){let n=o.$implicit,e=o.index,t=Z(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 ii(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 ni(r,o){if(r&1){let n=A();c(0,"span",47),S("click",function(){C(n);let t=p(4);return _(t.onShowOriginalTextClick())}),k(1),v(2,"translate"),l()}r&2&&(g(),se(w(2,1,"Show original text")))}function ri(r,o){r&1&&(c(0,"div",16),k(1),v(2,"translate"),l()),r&2&&(g(),N(" ",w(2,1,"Select a rewritten text to create a task")))}function oi(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,ri,3,3,"div",49),k(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 ai(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"),Se("ngModelChange",function(t){C(n);let i=p(3);return xe(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),k(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),k(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),k(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,ti,8,7,"ng-container",22),l(),E(40,ii,10,0,"div",23),c(41,"div",24),E(42,ni,3,3,"span",25),f(43,"div"),E(44,oi,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?")),we("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 si(r,o){if(r&1&&E(0,qt,10,8,"div",8)(1,ai,48,40,"div",8),r&2){let n=p().ngIf;u("ngIf",!n.apiCalled),g(),u("ngIf",n.apiCalled)}}function ci(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,Ut,0,0,"ng-template",7),l(),E(4,Qt,1,1,"ng-template",null,1,$)(6,si,2,2,"ng-template",null,2,$),K()}if(r&2){let n=Z(5),e=Z(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(vt).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=>D(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=>D(M({},d),{loading:!0}));let e=Ct(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 et}from"./chunk-CQ2PFN5H.js";import{t as qe}from"./chunk-PDOET6TG.js";import"./chunk-O64Y7CY5.js";import"./chunk-S7J3GTUB.js";import"./chunk-4ZVKEG33.js";import"./chunk-QYY5QDZZ.js";import"./chunk-MVFPB6P2.js";import"./chunk-GDYKECHB.js";import{b as Ke,d as Qe}from"./chunk-KPCULYW2.js";import{a as Ze}from"./chunk-MUZB4ZRW.js";import{G as Le,H as Ae,I as we,r as ke,t as Ue,v as Ne}from"./chunk-UQI5JFMO.js";import{$ as he,Ag as Me,Ai as Ve,Cf as Fe,Ch as S,Db as _e,E as N,Eb as Ie,Ed as Re,Ee as y,Fa as p,Fb as ye,Fc as Oe,Fi as Xe,Gc as Pe,I as le,Ib as Q,J as se,Jb as R,L as ae,M as ce,Ma as pe,Nb as z,Ob as Ce,Oi as Ye,Pa as j,Pb as q,Pc as De,Pi as Je,T,Ta as Se,Ua as fe,Uf as te,Va as Ee,W as G,X as ge,_a as x,a as b,aa as me,ac as Te,b as I,bb as be,bc as xe,ca as E,db as L,eg as ie,g as oe,hg as ne,ig as $e,ji as Ge,kc as W,ki as g,l as k,la as de,lb as _,lc as V,lf as F,li as je,mb as w,mf as X,nb as B,nf as H,ob as K,oe as ee,pc as Z,qa as ue,r as C,sb as O,si as ze,tb as P,ti as We,v as U,wa as ve,yg as Be,zb as v,zg as He}from"./chunk-4EV2AXDK.js";var ct=["selectionElementPortalOverlay"],gt=()=>["velt-overlay-panel"],ht=s=>[s];function mt(s,n){if(s&1&&(O(0),w(1,"span",10),z(2),W(3,"translate"),B(),P()),s&2){let r=v(),e=r.$implicit,t=r.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 dt(s,n){if(s&1&&(O(0),x(1,mt,4,6,"ng-container",3),P()),s&2){let r=n.index,e=v(5);p(),_("ngIf",r<e.maxCount)}}function ut(s,n){if(s&1&&(w(0,"span",11),z(1),B()),s&2){let r=v(4).ngIf,e=v();R("--velt-selection-color",(r.selections[0]==null||r.selections[0].user==null?null:r.selections[0].user.color)||"white"),L("data-testid",e.componentId+"-additional-count")("aria-label",(r.selections==null?null:r.selections.length)-e.maxCount+" additional users"),p(),q("+",(r.selections==null?null:r.selections.length)-e.maxCount)}}function vt(s,n){if(s&1&&(O(0),w(1,"div",7),W(2,"translate"),x(3,dt,2,1,"ng-container",8)(4,ut,2,5,"span",9),B(),P()),s&2){let r=v(3).ngIf,e=v();p(),L("data-testid",e.componentId+"-label-container")("aria-label",V(2,4,"Selected users")),p(2),_("ngForOf",r.selections),p(),_("ngIf",(r.selections==null?null:r.selections.length)>e.maxCount)}}function pt(s,n){if(s&1&&(O(0),K(1,"snippyly-user-avatar",13),P()),s&2){let r=v(),e=r.$implicit,t=r.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 St(s,n){if(s&1&&(O(0),x(1,pt,2,6,"ng-container",3),P()),s&2){let r=n.index,e=v(5);p(),_("ngIf",r<e.maxCount)}}function ft(s,n){if(s&1&&(w(0,"div",14),W(1,"translate"),w(2,"span",15),z(3),B()()),s&2){let r=v(4).ngIf,e=v();R("--velt-selection-user-index",r.selections==null?null:r.selections.length)("background-color",(r.selections[(r.selections==null?null:r.selections.length)-1]==null||r.selections[(r.selections==null?null:r.selections.length)-1].user==null?null:r.selections[(r.selections==null?null:r.selections.length)-1].user.color)||"white"),L("data-testid",e.componentId+"-additional-avatars")("aria-label",(r.selections==null?null:r.selections.length)-e.maxCount+" "+V(1,7,"additional users")),p(3),q("+",(r.selections==null?null:r.selections.length)-e.maxCount)}}function Et(s,n){if(s&1&&x(0,St,2,1,"ng-container",8)(1,ft,4,9,"div",12),s&2){let r=v(3).ngIf,e=v();_("ngForOf",r.selections),p(),_("ngIf",(r.selections==null?null:r.selections.length)>e.maxCount)}}function bt(s,n){if(s&1&&x(0,vt,5,6,"ng-container",6)(1,Et,2,2,"ng-template",null,2,Z),s&2){let r=Q(2),e=v(2).ngIf,t=v();_("ngIf",(e==null?null:e.userIndicatorType)===(t.userIndicatorTypes==null?null:t.userIndicatorTypes.Label))("ngIfElse",r)}}function _t(s,n){if(s&1&&(O(0),K(1,"div",4,0),x(3,bt,3,2,"ng-template",5,1,Z),P()),s&2){let r=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",r)("cdkConnectedOverlayOpen",!0)("cdkConnectedOverlayLockPosition",!1)("cdkConnectedOverlayGrowAfterOpen",!0)("cdkConnectedOverlayDisableClose",!0)("cdkConnectedOverlayPanelClass",Te(13,gt))("cdkConnectedOverlayPositions",xe(14,ht,e==null?null:e.overlayPosition))}}function It(s,n){if(s&1&&(O(0),x(1,_t,5,16,"ng-container",3),P()),s&2){let r=n.ngIf;p(),_("ngIf",r==null?null:r.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 o=this.selectionService.getUserIndicatorPosition(),h=this.selectionService.getUserIndicatorType();this.componentConfigSignal.update(d=>(d=I(b({},d),{userIndicatorPosition:o,userIndicatorType:h}),d)),this.setOverlayPosition(o)}catch(o){this.loggingService.log("Error in SelectionElementPortalComponent constructor: ",o)}}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=Be(this.highlight.targetElement);if(e){let t=e.iterateNext(),i,o=null,h=null;try{i=JSON.parse(t?.getAttribute(y.ATTRIBUTES.VELT_SELECTION_CONFIG)||"{}"),o=t?.getAttribute(y.ATTRIBUTES.VELT_LIVE_SELECTION_USER_INDICATOR_POSITION)||this.componentConfigSignal().userIndicatorPosition,o&&this.setOverlayPosition(o),h=t?.getAttribute(y.ATTRIBUTES.VELT_LIVE_SELECTION_USER_INDICATOR_TYPE)||this.componentConfigSignal().userIndicatorType,this.componentConfigSignal.update(a=>(a=I(b({},a),{userIndicatorPosition:o,userIndicatorType:h}),a))}catch{}let d;if(i?.horizontal&&(d=i.horizontal),o==="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(ct,5),t&2){let o;Ie(o=ye())&&(i.selectionElementPortalOverlay=o.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,It,2,1,"ng-container",3),t&2&&_("ngIf",i.componentConfigSignal())},dependencies:[Oe,Pe,Ae,Le,Qe,Ke],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,o,h,d,a,D,J,nt,rt,ot,lt){this.afAuth=e,this.analyticsService=t,this.authService=i,this.configService=o,this.databaseService=h,this.docService=d,this.domService=a,this.componentFactoryResolver=D,this.injector=J,this.appRef=nt,this.loggingService=rt,this.commonDbService=ot,this.realtimeAdapter=lt,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=He([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(st=>this.getUserIdHash(st.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(o=>o?.data),U(o=>this.filterActiveSelections(o))):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(o=>{let h=e[o];h?.timestamp&&Math.abs(i-h.timestamp)<this.inactivityTime&&(t[o]=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:o}=i.claims;if(o&&this.documentPaths?.selection){let h=this.getUserIdHash(o);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 o=["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 o=et(i,y.TAGS.SNIPPYLY_HIGHLIGHT_USER_TEXT),h=[],d=this.getSelectionUserMarker(e.user);if(o&&o.length&&(o.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=o.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=>{i?.element&&i?.textNode&&i.element.replaceWith(i.textNode),i.textNode&&i.textNode.parentNode?.normalize()}),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 o=document.createElement("span");return o.classList.add("snippyly-user-marker-dot"),i.appendChild(o),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(o=>{o&&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(o=>{this.loggingService.catch("Error in SelectionService signOutUser subscription: ",o),i(o)}):t(null)}catch(o){this.loggingService.catch("Error in SelectionService signOutUser:",o),i(o)}})}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:Me(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(o=>this.getUserIdHash(o.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 o=this.domService.getHostElement(i),h=new ke(re),d=new Ue(o,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:o,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:o}=this.elementSelections[e.targetElement],h=this.domService.getElementOffset(i,o);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 o=this.elementSelections[i];o&&(o.selectionHostDomPortalOutlet.detach(),this.domService.removeHighlightFromElement(o.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(Ge),E(We),E(je),E(Ve),E(Xe),E(ze),E(pe),E(de),E(be),E(g),E(Je),E(Ye))},n.\u0275prov=he({token:n,factory:n.\u0275fac,providedIn:"root"});let s=n;return s})();var Y=class extends Ze{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(r){this.getService(g).catch("Error in _setUserIndicatorPosition: ",r)}}_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(r){this.getService(g).catch("Error in _setUserIndicatorType: ",r)}}_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(r){this.getService(g).catch("Error in setInactivityTime: ",r)}}};var it=(()=>{let n=class n{};n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=Ee({type:n}),n.\u0275inj=me({imports:[De,we,Ne,qe]});let s=n;return s})();function Ct(s){return s.get(g).log("%c[WB] Loading selection feature chunk","color: blue;"),Se(it,s),new Y(s)}export{Ct as default};
|
|
1
|
+
import{a as et}from"./chunk-IU25BW6T.js";import{t as qe}from"./chunk-AOHWVH4J.js";import"./chunk-5R5ZQKPN.js";import"./chunk-XISY42XO.js";import"./chunk-TW7O56QU.js";import"./chunk-7RRXZUH7.js";import"./chunk-CI2SH5RY.js";import"./chunk-CQX575C2.js";import{b as Ke,d as Qe}from"./chunk-F6CKB7IS.js";import{a as Ze}from"./chunk-FUYX2CTL.js";import{G as Le,H as Ae,I as we,r as ke,t as Ue,v as Ne}from"./chunk-3ORHWUHZ.js";import{$ as he,Ag as Me,Ai as Ve,Cf as Fe,Ch as S,Db as _e,E as N,Eb as Ie,Ed as Re,Ee as y,Fa as p,Fb as ye,Fc as Oe,Fi as Xe,Gc as Pe,I as le,Ib as Q,J as se,Jb as R,L as ae,M as ce,Ma as pe,Nb as z,Ob as Ce,Oi as Ye,Pa as j,Pb as q,Pc as De,Pi as Je,T,Ta as Se,Ua as fe,Uf as te,Va as Ee,W as G,X as ge,_a as x,a as b,aa as me,ac as Te,b as I,bb as be,bc as xe,ca as E,db as L,eg as ie,g as oe,hg as ne,ig as $e,ji as Ge,kc as W,ki as g,l as k,la as de,lb as _,lc as V,lf as F,li as je,mb as w,mf as X,nb as B,nf as H,ob as K,oe as ee,pc as Z,qa as ue,r as C,sb as O,si as ze,tb as P,ti as We,v as U,wa as ve,yg as Be,zb as v,zg as He}from"./chunk-VKGZ33MA.js";var ct=["selectionElementPortalOverlay"],gt=()=>["velt-overlay-panel"],ht=s=>[s];function mt(s,n){if(s&1&&(O(0),w(1,"span",10),z(2),W(3,"translate"),B(),P()),s&2){let r=v(),e=r.$implicit,t=r.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 dt(s,n){if(s&1&&(O(0),x(1,mt,4,6,"ng-container",3),P()),s&2){let r=n.index,e=v(5);p(),_("ngIf",r<e.maxCount)}}function ut(s,n){if(s&1&&(w(0,"span",11),z(1),B()),s&2){let r=v(4).ngIf,e=v();R("--velt-selection-color",(r.selections[0]==null||r.selections[0].user==null?null:r.selections[0].user.color)||"white"),L("data-testid",e.componentId+"-additional-count")("aria-label",(r.selections==null?null:r.selections.length)-e.maxCount+" additional users"),p(),q("+",(r.selections==null?null:r.selections.length)-e.maxCount)}}function vt(s,n){if(s&1&&(O(0),w(1,"div",7),W(2,"translate"),x(3,dt,2,1,"ng-container",8)(4,ut,2,5,"span",9),B(),P()),s&2){let r=v(3).ngIf,e=v();p(),L("data-testid",e.componentId+"-label-container")("aria-label",V(2,4,"Selected users")),p(2),_("ngForOf",r.selections),p(),_("ngIf",(r.selections==null?null:r.selections.length)>e.maxCount)}}function pt(s,n){if(s&1&&(O(0),K(1,"snippyly-user-avatar",13),P()),s&2){let r=v(),e=r.$implicit,t=r.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 St(s,n){if(s&1&&(O(0),x(1,pt,2,6,"ng-container",3),P()),s&2){let r=n.index,e=v(5);p(),_("ngIf",r<e.maxCount)}}function ft(s,n){if(s&1&&(w(0,"div",14),W(1,"translate"),w(2,"span",15),z(3),B()()),s&2){let r=v(4).ngIf,e=v();R("--velt-selection-user-index",r.selections==null?null:r.selections.length)("background-color",(r.selections[(r.selections==null?null:r.selections.length)-1]==null||r.selections[(r.selections==null?null:r.selections.length)-1].user==null?null:r.selections[(r.selections==null?null:r.selections.length)-1].user.color)||"white"),L("data-testid",e.componentId+"-additional-avatars")("aria-label",(r.selections==null?null:r.selections.length)-e.maxCount+" "+V(1,7,"additional users")),p(3),q("+",(r.selections==null?null:r.selections.length)-e.maxCount)}}function Et(s,n){if(s&1&&x(0,St,2,1,"ng-container",8)(1,ft,4,9,"div",12),s&2){let r=v(3).ngIf,e=v();_("ngForOf",r.selections),p(),_("ngIf",(r.selections==null?null:r.selections.length)>e.maxCount)}}function bt(s,n){if(s&1&&x(0,vt,5,6,"ng-container",6)(1,Et,2,2,"ng-template",null,2,Z),s&2){let r=Q(2),e=v(2).ngIf,t=v();_("ngIf",(e==null?null:e.userIndicatorType)===(t.userIndicatorTypes==null?null:t.userIndicatorTypes.Label))("ngIfElse",r)}}function _t(s,n){if(s&1&&(O(0),K(1,"div",4,0),x(3,bt,3,2,"ng-template",5,1,Z),P()),s&2){let r=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",r)("cdkConnectedOverlayOpen",!0)("cdkConnectedOverlayLockPosition",!1)("cdkConnectedOverlayGrowAfterOpen",!0)("cdkConnectedOverlayDisableClose",!0)("cdkConnectedOverlayPanelClass",Te(13,gt))("cdkConnectedOverlayPositions",xe(14,ht,e==null?null:e.overlayPosition))}}function It(s,n){if(s&1&&(O(0),x(1,_t,5,16,"ng-container",3),P()),s&2){let r=n.ngIf;p(),_("ngIf",r==null?null:r.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 o=this.selectionService.getUserIndicatorPosition(),h=this.selectionService.getUserIndicatorType();this.componentConfigSignal.update(d=>(d=I(b({},d),{userIndicatorPosition:o,userIndicatorType:h}),d)),this.setOverlayPosition(o)}catch(o){this.loggingService.log("Error in SelectionElementPortalComponent constructor: ",o)}}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=Be(this.highlight.targetElement);if(e){let t=e.iterateNext(),i,o=null,h=null;try{i=JSON.parse(t?.getAttribute(y.ATTRIBUTES.VELT_SELECTION_CONFIG)||"{}"),o=t?.getAttribute(y.ATTRIBUTES.VELT_LIVE_SELECTION_USER_INDICATOR_POSITION)||this.componentConfigSignal().userIndicatorPosition,o&&this.setOverlayPosition(o),h=t?.getAttribute(y.ATTRIBUTES.VELT_LIVE_SELECTION_USER_INDICATOR_TYPE)||this.componentConfigSignal().userIndicatorType,this.componentConfigSignal.update(a=>(a=I(b({},a),{userIndicatorPosition:o,userIndicatorType:h}),a))}catch{}let d;if(i?.horizontal&&(d=i.horizontal),o==="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(ct,5),t&2){let o;Ie(o=ye())&&(i.selectionElementPortalOverlay=o.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,It,2,1,"ng-container",3),t&2&&_("ngIf",i.componentConfigSignal())},dependencies:[Oe,Pe,Ae,Le,Qe,Ke],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,o,h,d,a,D,J,nt,rt,ot,lt){this.afAuth=e,this.analyticsService=t,this.authService=i,this.configService=o,this.databaseService=h,this.docService=d,this.domService=a,this.componentFactoryResolver=D,this.injector=J,this.appRef=nt,this.loggingService=rt,this.commonDbService=ot,this.realtimeAdapter=lt,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=He([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(st=>this.getUserIdHash(st.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(o=>o?.data),U(o=>this.filterActiveSelections(o))):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(o=>{let h=e[o];h?.timestamp&&Math.abs(i-h.timestamp)<this.inactivityTime&&(t[o]=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:o}=i.claims;if(o&&this.documentPaths?.selection){let h=this.getUserIdHash(o);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 o=["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 o=et(i,y.TAGS.SNIPPYLY_HIGHLIGHT_USER_TEXT),h=[],d=this.getSelectionUserMarker(e.user);if(o&&o.length&&(o.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=o.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=>{i?.element&&i?.textNode&&i.element.replaceWith(i.textNode),i.textNode&&i.textNode.parentNode?.normalize()}),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 o=document.createElement("span");return o.classList.add("snippyly-user-marker-dot"),i.appendChild(o),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(o=>{o&&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(o=>{this.loggingService.catch("Error in SelectionService signOutUser subscription: ",o),i(o)}):t(null)}catch(o){this.loggingService.catch("Error in SelectionService signOutUser:",o),i(o)}})}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:Me(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(o=>this.getUserIdHash(o.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 o=this.domService.getHostElement(i),h=new ke(re),d=new Ue(o,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:o,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:o}=this.elementSelections[e.targetElement],h=this.domService.getElementOffset(i,o);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 o=this.elementSelections[i];o&&(o.selectionHostDomPortalOutlet.detach(),this.domService.removeHighlightFromElement(o.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(Ge),E(We),E(je),E(Ve),E(Xe),E(ze),E(pe),E(de),E(be),E(g),E(Je),E(Ye))},n.\u0275prov=he({token:n,factory:n.\u0275fac,providedIn:"root"});let s=n;return s})();var Y=class extends Ze{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(r){this.getService(g).catch("Error in _setUserIndicatorPosition: ",r)}}_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(r){this.getService(g).catch("Error in _setUserIndicatorType: ",r)}}_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(r){this.getService(g).catch("Error in setInactivityTime: ",r)}}};var it=(()=>{let n=class n{};n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=Ee({type:n}),n.\u0275inj=me({imports:[De,we,Ne,qe]});let s=n;return s})();function Ct(s){return s.get(g).log("%c[WB] Loading selection feature chunk","color: blue;"),Se(it,s),new Y(s)}export{Ct as default};
|