@journeeze/sdk 0.1.0 → 0.3.0-rc.1
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/AGENTS.md +2 -2
- package/CHANGELOG.md +25 -1
- package/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +22 -20
- package/dist/anchor-bnZCZtbG.js +1 -0
- package/dist/attach-EfetX0Vi.js +21 -0
- package/dist/chat-Coze4aH0.js +64 -0
- package/dist/claims-VKhPNjA7.js +1 -0
- package/dist/consent-bPengyOI.js +1 -0
- package/dist/contract.js +1 -1
- package/dist/feedback-DeMvbZnh.js +1 -0
- package/dist/help-phTc32Gg.js +105 -0
- package/dist/highlight-pU9nE3Qj.js +2 -0
- package/dist/{hook-DGWypoEO.js → hook-M34sajh9.js} +1 -1
- package/dist/index.js +6 -8
- package/dist/loader-DHgG5Y7t.js +127 -0
- package/dist/mask-audit-KFvSiJU0.js +5 -0
- package/dist/react.js +1 -1
- package/dist/resolve-CRDmtd4b.js +1 -0
- package/dist/script.js +1 -1
- package/dist/{signals-amjMQyOy.js → signals-C_WxFykA.js} +1 -1
- package/dist/telemetry-CdwMjZZZ.js +1 -0
- package/dist/{transport-B64CfIcF.js → transport-Wrkorx6z.js} +1 -1
- package/dist/types/chat/capture/attach.d.ts +2 -0
- package/dist/types/chat/shell/chat.d.ts +4 -2
- package/dist/types/chat/shell/converse.d.ts +2 -0
- package/dist/types/chat/shell/guide.d.ts +12 -0
- package/dist/types/chat/shell/session.d.ts +6 -0
- package/dist/types/chat/shell/walk.d.ts +49 -0
- package/dist/types/chat/transport.d.ts +1 -1
- package/dist/types/claims.d.ts +37 -0
- package/dist/types/help/core/client.d.ts +3 -0
- package/dist/types/help/core/events.d.ts +1 -1
- package/dist/types/help/core/routing.d.ts +2 -0
- package/dist/types/loader.d.ts +3 -0
- package/dist/types/preview/mask-audit.d.ts +3 -1
- package/dist/types/telemetry/telemetry.d.ts +4 -0
- package/dist/types/types.d.ts +34 -0
- package/dist/types/widget/feedback.d.ts +7 -1
- package/dist/types/widget/upload.d.ts +3 -2
- package/dist/{upload-Fu2qvSJV.js → upload-KvsGqMEV.js} +6 -6
- package/dist/walk-BEGYyGG3.js +1 -0
- package/dist/widget-BA2WH0yi.js +118 -0
- package/package.json +4 -3
- package/LICENSE.md +0 -27
- package/dist/anchor-cPvFFTOS.js +0 -1
- package/dist/attach-DpioALxW.js +0 -21
- package/dist/chat-BgmB0rnW.js +0 -64
- package/dist/consent-DckCUvYR.js +0 -1
- package/dist/context-UnG6_X61.js +0 -17
- package/dist/feedback-CtH1a_kQ.js +0 -1
- package/dist/help-w0O5Qu-4.js +0 -105
- package/dist/index-CwG2LrhO.js +0 -20
- package/dist/loader-BZiIDD1D.js +0 -96
- package/dist/mask-audit-Du3NPoG_.js +0 -5
- package/dist/resolve-BfWByuTp.js +0 -1
- package/dist/telemetry-CyRJDaVs.js +0 -1
- package/dist/widget-B6mR1J3P.js +0 -118
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
var Z=Object.defineProperty;var ee=(n,e,t)=>e in n?Z(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var N=(n,e,t)=>ee(n,typeof e!="symbol"?e+"":e,t);import{s as te,F as G,R as ne}from"./hook-M34sajh9.js";import{d as Q}from"./anchor-bnZCZtbG.js";import{C as ie,l as D,c as X,s as J,d as se,D as re,j as oe,h as ae,g as de,f as ce}from"./consent-bPengyOI.js";import{a as le,H as ue}from"./highlight-pU9nE3Qj.js";import{f as Me}from"./highlight-pU9nE3Qj.js";const B=n=>n.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^\p{L}\p{N}]+/u).filter(Boolean);function M(n,e){const t=B(e);if(t.length===0)return[...n];const s=[];return n.forEach((i,a)=>{const l=B(i.title??""),h=B(i.goal??""),b=(i.stepTitles??[]).flatMap(B);let E=0;for(const A of t){const F=o=>o.some(g=>g.startsWith(A)),q=F(l)?3:F(h)?2:F(b)?1:0;if(q===0)return;E+=q}s.push([i,E,a])}),s.sort((i,a)=>a[1]-i[1]||i[2]-a[2]).map(([i])=>i)}const pe=4e3;function L(n){return n instanceof ie&&n.code==="failed_precondition"}class he{constructor(e){N(this,"deps");N(this,"current",{view:"closed"});N(this,"listeners",new Set);N(this,"entries",[]);N(this,"generation",0);N(this,"asked",new Set);N(this,"pending");N(this,"pendingSignal");this.deps=e}get state(){return this.current}subscribe(e){return this.listeners.add(e),e(this.current),()=>this.listeners.delete(e)}probe(){return this.deps.loadIndex().then(()=>{},e=>{L(e)&&this.disable()})}open(){if(this.current.view==="disabled")return;const e=++this.generation;this.deps.clearHighlight(),this.set({view:"index",status:"loading",query:"",results:[],total:0}),this.deps.loadIndex().then(t=>{if(e!==this.generation)return;this.entries=(t.guides??[]).filter(a=>a.journeyId);const s=this.current.view==="index"?this.current.query:"",i=(t.jobs??[]).filter(a=>a.jobId&&a.title);this.set({view:"index",status:"ready",query:s,results:M(this.entries,s),total:this.entries.length,jobs:i})},t=>{if(e!==this.generation)return;if(L(t))return this.disable();const s=this.current.view==="index"?this.current.query:"";this.set({view:"index",status:"error",query:s,results:[],total:0})})}close(){this.current.view!=="disabled"&&(this.generation++,this.pending=void 0,this.pendingSignal=void 0,this.deps.clearHighlight(),this.set({view:"closed"}))}search(e){const t=this.current;if(t.view!=="index")return;const s=t.status==="ready"?M(this.entries,e):[];this.set({...t,query:e,results:s})}openGuide(e){if(this.current.view==="disabled")return;const t=++this.generation;this.pending=void 0,this.deps.clearHighlight(),this.set({view:"guide",status:"loading",journeyId:e,step:0,anchor:"none",checkin:"idle"}),this.deps.loadGuide(e).then(s=>{if(t!==this.generation)return;const i=ge(s,e,this.deps.endpoint);if(i.steps.length===0){this.set({view:"guide",status:"error",journeyId:e,step:0,anchor:"none",checkin:"idle"});return}this.showStep(i,0)},s=>{if(t===this.generation){if(L(s))return this.disable();this.set({view:"guide",status:"error",journeyId:e,step:0,anchor:"none",checkin:"idle"})}})}disable(){this.generation++,this.pending=void 0,this.deps.clearHighlight(),this.set({view:"disabled"})}back(){const e=this.current;if(e.view==="finished")return this.showStep(e.guide,e.guide.steps.length-1);if(e.view!=="guide"||!e.guide)return this.open();if(e.step===0)return this.open();this.generation++,this.pending=void 0,this.showStep(e.guide,e.step-1)}next(){const e=this.current;if(e.view!=="guide"||e.status!=="ready"||!e.guide||e.checkin!=="idle")return;const t=e.guide.steps[e.step];if(t&&!this.asked.has(P(e.guide,t))){this.set({...e,checkin:"asking",notice:void 0});return}this.advance()}answer(e){const t=this.current;if(!(t.view!=="guide"||t.checkin!=="asking"&&t.checkin!=="needs-consent")){if(!this.deps.hasConsent()){this.pending=e,this.set({...t,checkin:"needs-consent"});return}this.send(e)}}skipCheckin(){const e=this.current;e.view!=="guide"||e.checkin!=="asking"&&e.checkin!=="needs-consent"||(this.pending=void 0,this.markAsked(e),this.set({...e,checkin:"idle"}),this.advance())}giveConsent(){const e=this.pendingSignal,t=this.current;if(e&&(t.view==="index"||t.view==="guide")&&t.signal==="needs-consent"){this.pendingSignal=void 0,this.deps.giveConsent(),this.sendSignalNow(e);return}const s=this.current;if(s.view!=="guide"||s.checkin!=="needs-consent"||!this.pending)return;this.deps.giveConsent();const i=this.pending;this.pending=void 0,this.send(i)}declineConsent(){const e=this.current;if(this.pendingSignal&&(e.view==="index"||e.view==="guide")&&e.signal==="needs-consent"){this.pendingSignal=void 0,this.patchSignal({signal:"idle"});return}this.skipCheckin()}canSignal(){return this.deps.signalsAllowed?.()??true}hasConsent(){return this.deps.hasConsent()}sendCallout(e){if(!this.canSignal())return;const t=this.current;if(t.view!=="guide"||t.status!=="ready"||!t.guide||$(t.signal))return;const s=t.guide.steps.find(i=>i.index===e);s&&this.signal({kind:"callout",guide:t.guide,step:s})}sendRequest(e,t){if(!this.canSignal())return;const s=e.trim();if(!s||[...s].length>pe)return;const i=this.current;i.view==="index"&&!$(i.signal)?this.signal(t?{kind:"request",text:s,jobRequest:t}:{kind:"request",text:s}):i.view==="guide"&&i.status==="ready"&&i.guide&&!$(i.signal)&&this.signal({kind:"request",text:s,guide:i.guide,step:i.guide.steps[i.step]})}signal(e){if(!this.deps.hasConsent()){this.pendingSignal=e,this.patchSignal({signal:"needs-consent",signalNotice:void 0});return}this.sendSignalNow(e)}patchSignal(e){const t=this.current;(t.view==="index"||t.view==="guide")&&this.set({...t,...e})}async sendSignalNow(e){const t=this.generation;this.patchSignal({signal:"sending",signalNotice:void 0});let s;try{s=await this.deps.sendSignal(e)}catch{s="dropped"}t===this.generation&&this.patchSignal({signal:"idle",signalNotice:s})}async send(e){const t=this.current;if(t.view!=="guide"||!t.guide)return;const s=t.guide.steps[t.step];if(!s)return;this.markAsked(t);const i=this.generation;this.set({...t,checkin:"sending"});let a;try{a=await this.deps.sendCheckin({guide:t.guide,step:s,answer:e})}catch{a="dropped"}if(i!==this.generation)return;const l=this.current;l.view==="guide"&&(this.set({...l,checkin:"idle"}),this.advance(a))}refreshHighlight(){const e=this.current;if(e.view!=="guide"||e.status!=="ready"||!e.guide)return;const t=this.anchorFor(e.guide,e.step);t!==e.anchor&&this.set({...e,anchor:t})}markAsked(e){if(e.view!=="guide"||!e.guide)return;const t=e.guide.steps[e.step];t&&this.asked.add(P(e.guide,t))}advance(e){const t=this.current;if(!(t.view!=="guide"||!t.guide)){if(t.step+1<t.guide.steps.length)return this.showStep(t.guide,t.step+1,e);this.deps.clearHighlight(),this.set({view:"finished",guide:t.guide,notice:e})}}showStep(e,t,s){const i=this.anchorFor(e,t);this.set({view:"guide",status:"ready",journeyId:e.journeyId,guide:e,step:t,anchor:i,checkin:"idle",notice:s})}anchorFor(e,t){const s=this.deps.highlight(e.steps[t]?.targets);return typeof s=="string"?s:(s.then(i=>{const a=this.current;a.view==="guide"&&a.guide===e&&a.step===t&&a.anchor!==i&&this.set({...a,anchor:i})}),"none")}set(e){this.current=e;for(const t of this.listeners)t(e)}}const P=(n,e)=>`${n.journeyId}/${e.index}`;function ge(n,e,t){const s=(n.steps??[]).map((i,a)=>({index:i.index??a,title:i.title??"",instruction:i.instruction??"",tflowId:i.tflowId||void 0,targets:ve(i),stepRef:i.stepRef||void 0,screenshotUrl:D(t,i.screenshotUrl),videoStartMs:i.videoStartMs,videoEndMs:i.videoEndMs})).sort((i,a)=>i.index-a.index);return{journeyId:n.journeyId??e,slug:n.slug??"",title:n.title??"",goal:n.goal??"",steps:s,videoUrl:D(t,n.videoUrl),captionsUrl:D(t,n.captionsUrl),version:n.contentVersion||void 0}}function $(n){return n==="needs-consent"||n==="sending"}const fe=/^(tflow|testId|role|css)$/;function ve(n){const e=(n.targets??[]).filter(t=>fe.test(t.strategy??"")&&t.value).map(t=>({by:t.strategy,value:t.value,name:t.name||void 0}));return e.length||!n.tflowId?e:[{by:"tflow",value:n.tflowId}]}function be(n,e,t,s){let i;return{start(){i??(i=import("./telemetry-CdwMjZZZ.js").then(a=>a.startTelemetry({endpoint:n,siteKey:e,subscribe:l=>t.subscribe(l),claims:s}),()=>{i=void 0}))},checkin:a=>{i?.then(l=>l?.checkin(a))},job:a=>{i?.then(l=>l?.job(a))},stop:a=>{i?.then(l=>l?.stop(a))}}}const Oe=`
|
|
2
|
+
:host { all: initial; }
|
|
3
|
+
.launcher { position:fixed; left:24px; bottom:24px; z-index:2147483646; width:44px; height:44px; border-radius:22px;
|
|
4
|
+
border:1px solid #1D2024; background:#1D2024; color:#FFFFFF; font:600 18px/1 system-ui,sans-serif; cursor:pointer; }
|
|
5
|
+
.panel { position:fixed; left:24px; bottom:80px; z-index:2147483646; width:min(340px, calc(100vw - 48px));
|
|
6
|
+
max-height:min(70vh, 560px); overflow:auto; box-sizing:border-box; padding:16px; border:1px solid rgb(29 32 36/12%);
|
|
7
|
+
border-radius:10px; background:#FFFFFF; color:#1D2024; font:14px/1.45 system-ui,sans-serif; box-shadow:0 8px 24px rgb(0 0 0/12%); }
|
|
8
|
+
.panel h2 { font-size:15px; margin:0 0 8px; }
|
|
9
|
+
.panel p { margin:0 0 8px; }
|
|
10
|
+
.panel ul { list-style:none; padding:0; margin:8px 0 0; }
|
|
11
|
+
.panel li button { display:block; width:100%; text-align:left; padding:8px; margin:0 0 4px; border:1px solid rgb(29 32 36/12%);
|
|
12
|
+
border-radius:6px; background:#FFFFFF; color:inherit; font:inherit; cursor:pointer; }
|
|
13
|
+
.panel input { width:100%; box-sizing:border-box; padding:8px; border:1px solid rgb(29 32 36/24%); border-radius:6px; font:inherit; }
|
|
14
|
+
.panel .row { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
|
|
15
|
+
.panel .row button { padding:6px 12px; border:1px solid #1D2024; border-radius:6px; background:#FFFFFF; color:#1D2024; font:inherit; cursor:pointer; }
|
|
16
|
+
.panel .muted { color:#5D636B; font-size:13px; }
|
|
17
|
+
.panel img { max-width:100%; border:1px solid rgb(29 32 36/12%); border-radius:6px; }
|
|
18
|
+
:focus-visible { outline:2px solid #3D63C9; outline-offset:2px; }
|
|
19
|
+
.jz-help-highlight { position:fixed; z-index:2147483645; pointer-events:none; box-sizing:border-box;
|
|
20
|
+
border:2px solid #3D63C9; border-radius:6px; box-shadow:0 0 0 4px rgb(61 99 201/20%); }
|
|
21
|
+
`;function u(n,e={},...t){const s=document.createElement(n);for(const[i,a]of Object.entries(e))s.setAttribute(i,a);for(const i of t)i&&s.append(i);return s}const K={sent:"Thanks. Your answer was sent.",queued:"Saved. It will send when you're back online.",dropped:"Your answer couldn't be sent."},xe=(n,e,t)=>{const s=u("button",{type:"button",class:"launcher","aria-label":"Help","aria-expanded":"false","aria-controls":"jz-help-panel"},"?"),i=u("div",{id:"jz-help-panel",class:"panel",role:"dialog","aria-modal":"false","aria-label":"Help"});i.hidden=true,n.append(s,i);let a="",l=false,h;s.addEventListener("click",()=>e.state.view==="closed"?e.open():e.close()),i.addEventListener("keydown",o=>{o.key==="Escape"&&(o.stopPropagation(),e.close())});const b=(o,g,f={})=>{const C=u("button",{type:"button",...f},o);return C.addEventListener("click",g),C};function E(o){const g=n.activeElement,f=g!==null&&i.contains(g),C=f?g.id:"";s.hidden=o.view==="disabled";const m=o.view!=="closed"&&o.view!=="disabled";if(s.setAttribute("aria-expanded",String(m)),i.hidden=!m,o.view==="index"&&h&&i.contains(h.input)){F(o),f&&g&&!g.isConnected&&(C&&n.getElementById(C)||h.input).focus(),l=m;return}if(h=void 0,i.replaceChildren(...(m?A(o):[]).filter(k=>!!k)),m&&(!l||f)){const y=(C?n.getElementById(C):null)??i.querySelector("input, [role=group] button, button");y?.focus(),y instanceof HTMLInputElement&&y.setSelectionRange(y.value.length,y.value.length)}!m&&l&&s.focus(),l=m}function A(o){if(o.view==="index"){const k=u("input",{id:"jz-help-search",type:"search","aria-label":"Search help",placeholder:"How do I…",autocomplete:"off"});return k.value=o.query,k.addEventListener("input",()=>e.search(k.value)),h={input:k,status:u("p",{class:"muted",role:"status"}),retry:u("div",{class:"row"},b("Try again",()=>e.open())),list:u("ul",{"aria-label":"Guides"})},F(o),[u("h2",{},"How do I…"),k,h.status,h.retry,h.list,u("div",{class:"row"},b("Close",()=>e.close()))]}if(o.view==="finished")return[u("h2",{},`You finished “${o.guide.title}”`),o.notice&&u("p",{class:"muted",role:"status"},K[o.notice]??""),u("div",{class:"row"},b("More guides",()=>e.open(),{id:"jz-help-more"}),b("Back",()=>e.back()),b("Close",()=>e.close()))];if(o.view!=="guide")return[];if(o.status!=="ready"||!o.guide)return[u("p",{role:"status"},o.status==="loading"?"Loading guide…":"This guide isn't available right now."),u("div",{class:"row"},b("Back",()=>e.open()),b("Close",()=>e.close()))];const g=o.guide,f=g.steps[o.step];if(!f)return[];const C=o.step+1===g.steps.length,m=[u("h2",{},g.title),u("p",{class:"muted"},`Step ${o.step+1} of ${g.steps.length}`),u("p",{},u("strong",{},f.title)),f.instruction&&u("p",{},f.instruction),o.anchor==="missing"&&u("p",{class:"muted"},"The part of the page this step uses isn't shown here. Follow the steps in the text."),f.screenshotUrl&&u("img",{referrerpolicy:"no-referrer",src:f.screenshotUrl,alt:`Screenshot for: ${f.title}`,loading:"lazy"}),o.notice&&u("p",{class:"muted",role:"status"},K[o.notice]??"")];if(o.checkin==="asking")m.push(u("div",{role:"group","aria-label":"Step check-in"},u("p",{},"Did this step make sense?"),u("div",{class:"row"},b("Understood",()=>e.answer("understood"),{id:"jz-help-yes"}),b("Confused",()=>e.answer("confused")),b("Skip",()=>e.skipCheckin()))));else if(o.checkin==="needs-consent"){const k=u("p",{},a||"Loading…");a||t.consentText().then(y=>{a=y,k.textContent=y}),m.push(u("div",{role:"group","aria-label":"Consent"},k,u("div",{class:"row"},b("Allow and send",()=>e.giveConsent(),{id:"jz-help-allow"}),b("Not now",()=>e.declineConsent()))))}else o.checkin==="sending"?m.push(u("p",{role:"status"},"Sending…")):m.push(u("div",{class:"row"},b("Back",()=>e.back()),b(C?"Finish":"Next",()=>e.next(),{id:"jz-help-next"}),b("Close",()=>e.close())));return m}function F(o){if(!h)return;const{input:g,status:f,retry:C,list:m}=h;g.value!==o.query&&n.activeElement!==g&&(g.value=o.query),f.textContent=o.status==="loading"?"Loading guides…":o.status==="error"?"Help isn't available right now.":o.results.length===0?o.query?`No guide matches “${o.query}”.`:"No guides yet.":"",f.hidden=f.textContent==="",C.hidden=o.status!=="error",m.replaceChildren(...o.results.map((k,y)=>u("li",{},b(k.title||"Untitled guide",()=>e.openGuide(k.journeyId??""),{id:`jz-help-g${y}`}),k.goal?u("p",{class:"muted"},k.goal):void 0)))}const q=e.subscribe(E);return{destroy(){q(),s.remove(),i.remove()}}},V="http://www.w3.org/2000/svg",me="M6.1 6.2a2 2 0 1 1 2.7 1.9c-.7.3-1 .6-1 1.3v.5H6.4v-.6c0-1.1.4-1.6 1.2-2 .5-.2.8-.5.8-1a1 1 0 0 0-2 0v.1H6.1zM7.2 11.4h1.6V13H7.2z";function we(n){const e=document.createElementNS(V,"svg");e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("width","14"),e.setAttribute("height","14"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");const t=document.createElementNS(V,"path");return t.setAttribute("d",n),t.setAttribute("fill","currentColor"),e.append(t),e}function ke(n,e){const t=document.createElement("button");return t.type="button",t.id="jz-help-callout",t.className="callout-btn",t.append(we(me),document.createTextNode("This is confusing")),t.addEventListener("click",()=>n.sendCallout(e)),t}function ye(n,e){const t=document.createElement("form");t.setAttribute("aria-label","Ask for something you could not find");const s=document.createElement("p");s.textContent="Couldn't find it? Tell us what you were trying to do.";const i=document.createElement("textarea");i.id="jz-help-request",i.setAttribute("aria-label","What were you trying to do?"),i.maxLength=4e3,i.rows=3,i.value=`I couldn't find how to ${e}`;const a=document.createElement("button");return a.type="submit",a.id="jz-help-request-send",a.textContent="Send request",t.append(s,i,a),t.addEventListener("submit",l=>{l.preventDefault(),n.sendRequest(i.value)}),t}function d(n,e={},...t){const s=document.createElement(n);for(const[i,a]of Object.entries(e))s.setAttribute(i,a);for(const i of t)i&&s.append(i);return s}function O(n,e){const t=d(n,{...e,crossorigin:"anonymous"});return Object.assign(t,{referrerPolicy:"no-referrer"}),t.setAttribute("referrerpolicy","no-referrer"),t}const W="http://www.w3.org/2000/svg";function je(n){const e=document.createElementNS(W,"svg");e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("width","14"),e.setAttribute("height","14"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");const t=document.createElementNS(W,"path");return t.setAttribute("d",n),t.setAttribute("fill","currentColor"),e.append(t),e}const ze="M6.2 11.4 3 8.2l1.1-1.1 2.1 2.1 4.6-4.6 1.1 1.1z",Ce="M6.1 6.2a2 2 0 1 1 2.7 1.9c-.7.3-1 .6-1 1.3v.5H6.4v-.6c0-1.1.4-1.6 1.2-2 .5-.2.8-.5.8-1a1 1 0 0 0-2 0v.1H6.1zM7.2 11.4h1.6V13H7.2z",R={sent:"Thanks. Your answer was sent.",queued:"Saved. It will send when you're back online.",dropped:"Your answer couldn't be sent."},Y={sent:"Thanks. We'll take a look.",queued:"Saved. It will send when you're back online.",dropped:"Your request couldn't be sent."},Se=(n,e,t)=>{const s=d("button",{type:"button",class:"launcher","aria-label":"Help","aria-expanded":"false","aria-controls":"jz-help-panel"},"?"),i=d("div",{id:"jz-help-panel",class:"panel",role:"dialog","aria-modal":"false","aria-label":"Help"});i.hidden=true,n.append(s,i);let a="",l=false,h,b,E,A,F=false;const q=r=>!F&&r.view==="index"&&r.status==="ready"&&!!r.jobs?.length;s.addEventListener("click",()=>e.state.view==="closed"?e.open():e.close()),i.addEventListener("keydown",r=>{r.key==="Escape"&&(r.stopPropagation(),e.close())});const o=(r,p,v={})=>{const j=d("button",{type:"button",...v},r);return j.addEventListener("click",p),j},g=()=>{const r=d("p",{},a||"Loading…");return a||t.consentText().then(p=>{a=p,r.textContent=p}),d("div",{class:"checkin",role:"group","aria-label":"Consent"},r,d("div",{class:"row"},o("Allow and send",()=>e.giveConsent(),{id:"jz-help-allow",class:"primary"}),o("Not now",()=>e.declineConsent())))},f=()=>d("div",{class:"panel-head"},d("h2",{},"Help"),o("×",()=>e.close(),{class:"icon-btn","aria-label":"Close help"})),C=(r,p,v)=>{const j=d("button",{type:"button",id:`jz-help-${p}`,class:`checkin-btn ${p}`});return j.append(je(p==="understood"?ze:Ce),d("span",{},r)),j.addEventListener("click",v),j};function m(r){const p=n.activeElement,v=p!==null&&i.contains(p),j=v?p.id:"";s.hidden=r.view==="disabled";const z=r.view!=="closed"&&r.view!=="disabled";if(s.setAttribute("aria-expanded",String(z)),i.hidden=!z,r.view==="index"&&!q(r)&&h&&i.contains(h.input)){y(r),v&&p&&!p.isConnected&&(j&&n.getElementById(j)||h.input).focus(),l=z;return}if(h=void 0,i.replaceChildren(...(z?k(r):[]).filter(x=>!!x)),z&&(!l||v)){const T=(j?n.getElementById(j):null)??i.querySelector("[data-autofocus]")??i.querySelector("input, [role=group] button, button");T?.focus(),T instanceof HTMLInputElement&&T.setSelectionRange(T.value.length,T.value.length)}!z&&l&&s.focus(),l=z}function k(r){if(E?.owns(r))return E.content(r);if(q(r))return A??(A=import("./jobs-CAXbM5-g.js").then(S=>{E=S.jobsUi({controller:e,options:t,el:d,button:o,consentGroup:g,rerender:()=>m(e.state),checkinNotice:R})},()=>{F=true}).then(()=>m(e.state))),[f(),d("p",{class:"muted",role:"status"},"Loading…")];if(r.view==="index"){const S=d("input",{id:"jz-help-search",type:"search","aria-label":"Search help",placeholder:"How do I…",autocomplete:"off"});return S.value=r.query,S.addEventListener("input",()=>e.search(S.value)),h={input:S,status:d("p",{class:"muted",role:"status"}),retry:d("div",{class:"row"},o("Try again",()=>e.open())),request:d("div",{class:"request"}),signal:d("div",{class:"signal"}),list:d("ul",{"aria-label":"Guides"})},y(r),[f(),S,h.status,h.retry,h.request,h.signal,h.list]}if(r.view==="finished")return[f(),d("h2",{},`You finished “${r.guide.title}”`),r.notice&&d("p",{class:"muted",role:"status"},R[r.notice]??""),d("div",{class:"row"},o("More guides",()=>e.open(),{id:"jz-help-more"}),o("Back",()=>e.back()),o("Close",()=>e.close()))];if(r.view!=="guide")return[];if(r.status!=="ready"||!r.guide)return[f(),d("p",{role:"status"},r.status==="loading"?"Loading guide…":"This guide isn't available right now."),d("div",{class:"row"},o("Back",()=>e.open()),o("Close",()=>e.close()))];const p=r.guide,v=p.steps[r.step];if(!v)return[];const j=r.step+1===p.steps.length,z=p.steps.length,x=d("div",{class:"progress","aria-hidden":"true"},d("div",{class:"progress-fill"})),T=x.firstElementChild;T.style.width=`${Math.round((r.step+1)/z*100)}%`;const H=[d("h2",{},p.title),d("p",{class:"muted"},`Step ${r.step+1} of ${z}`),x,d("p",{class:"step-title"},v.title),v.instruction&&d("p",{},v.instruction),r.anchor==="missing"&&d("p",{class:"muted"},"The part of the page this step uses isn't shown here. Follow the steps in the text."),v.screenshotUrl&&O("img",{src:v.screenshotUrl,alt:`Screenshot for: ${v.title}`,loading:"lazy"})];if(p.videoUrl){const S=O("video",{controls:"",preload:"none",src:p.videoUrl});p.captionsUrl&&S.append(O("track",{kind:"captions",src:p.captionsUrl,default:""})),H.push(S)}const w=[f(),d("div",{class:"card"},...H),r.notice&&d("p",{class:"muted",role:"status"},R[r.notice]??"")];return r.checkin==="asking"?w.push(d("div",{class:"checkin",role:"group","aria-label":"Step check-in"},d("p",{},"Did this step make sense?"),d("div",{class:"row"},C("Understood","understood",()=>e.answer("understood")),C("Confused","confused",()=>e.answer("confused")),o("Skip",()=>e.skipCheckin())))):r.checkin==="needs-consent"?w.push(g()):r.checkin==="sending"?w.push(d("p",{role:"status"},"Sending…")):(r.signal==="needs-consent"?w.push(g()):r.signal==="sending"?w.push(d("p",{role:"status"},"Sending…")):r.signalNotice&&w.push(d("p",{class:"muted",role:"status"},Y[r.signalNotice]??"")),e.canSignal()&&w.push(ke(e,v.index)),w.push(d("div",{class:"row"},o("Back",()=>e.back()),o(j?"Finish":"Next",()=>e.next(),{id:"jz-help-next"}),o("Close",()=>e.close())))),w}function y(r){if(!h)return;const{input:p,status:v,retry:j,request:z,signal:x,list:T}=h;if(p.value!==r.query&&n.activeElement!==p&&(p.value=r.query),v.textContent=r.status==="loading"?"Loading guides…":r.status==="error"?"Help isn't available right now.":r.results.length===0?r.query?`No guide matches “${r.query}”.`:"No guides yet.":"",v.hidden=v.textContent==="",j.hidden=r.status!=="error",r.status==="ready"&&r.query.trim()!==""&&r.results.length===0&&e.canSignal()){const w=r.query.trim();(b!==w||!z.firstElementChild)&&(b=w,z.replaceChildren(ye(e,w)))}else z.firstElementChild&&(b=void 0,z.replaceChildren());r.signal==="needs-consent"?x.replaceChildren(g()):r.signal==="sending"?x.replaceChildren(d("p",{role:"status"},"Sending…")):r.signalNotice?x.replaceChildren(d("p",{class:"muted",role:"status"},Y[r.signalNotice]??"")):x.firstElementChild&&x.replaceChildren(),T.replaceChildren(...r.results.map((w,S)=>d("li",{},o(w.title||"Untitled guide",()=>e.openGuide(w.journeyId??""),{id:`jz-help-g${S}`}),w.goal?d("p",{class:"muted"},w.goal):void 0)))}const U=e.subscribe(m);return{destroy(){U(),E?.destroy(),s.remove(),i.remove()}}},Ee=500,Ie=6e3;async function Fe(n,e){const t=e.trim();if(!t||[...t].length>Ee||!n.canSignal()||!n.hasConsent())return;const s={siteKey:n.siteKey,consentGiven:true,text:t};n.reviewerToken&&(s.reviewerToken=n.reviewerToken);let i;try{const a=await Promise.race([Promise.resolve(n.claims?.()).then(l=>(l&&(s.claims=l),X(n.endpoint,"RouteIntent",s,n.fetchImpl))),new Promise(l=>i=setTimeout(l,Ie))]);return a?.jobId?{jobId:a.jobId,journeyId:a.journeyId||void 0}:void 0}catch{return}finally{clearTimeout(i)}}const Te=`
|
|
22
|
+
:host {
|
|
23
|
+
all: initial;
|
|
24
|
+
--jz-canvas:#F7F7F5; --jz-surface:#FFFFFF; --jz-raised:#F0F0EC; --jz-ink:#1D2024; --jz-muted:#5D636B;
|
|
25
|
+
--jz-faint:#6C727B; --jz-rule:rgb(29 32 36 / 12%); --jz-accent:#3D63C9; --jz-accent-ink:#FFFFFF;
|
|
26
|
+
--jz-accent-soft:rgb(61 99 201 / 10%); --jz-polished:#2F7D4F; --jz-confused:#6E4FC2;
|
|
27
|
+
--jz-shadow:0 1px 3px rgb(0 0 0 / 12%);
|
|
28
|
+
font: 400 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
29
|
+
color: var(--jz-ink); -webkit-font-smoothing: antialiased;
|
|
30
|
+
}
|
|
31
|
+
@media (prefers-color-scheme: dark) {
|
|
32
|
+
:host {
|
|
33
|
+
--jz-canvas:#111316; --jz-surface:#181B1F; --jz-raised:#20242A; --jz-ink:#E8EAED; --jz-muted:#A3A9B2;
|
|
34
|
+
--jz-faint:#8A919B; --jz-rule:rgb(232 234 237 / 12%); --jz-accent:#7F9CF0; --jz-accent-ink:#111316;
|
|
35
|
+
--jz-accent-soft:rgb(127 156 240 / 14%); --jz-polished:#5DBB84; --jz-confused:#A48BEA;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
39
|
+
button { font: inherit; color: inherit; cursor: pointer; }
|
|
40
|
+
:focus-visible { outline: 2px solid var(--jz-accent); outline-offset: 2px; }
|
|
41
|
+
button:disabled { opacity: .45; cursor: not-allowed; }
|
|
42
|
+
[hidden] { display: none !important; }
|
|
43
|
+
|
|
44
|
+
.launcher { position:fixed; left:24px; bottom:24px; z-index:2147483646; width:44px; height:44px; min-width:44px; min-height:44px;
|
|
45
|
+
display:flex; align-items:center; justify-content:center; padding:0; border:1px solid var(--jz-accent); border-radius:999px;
|
|
46
|
+
background:var(--jz-accent); color:var(--jz-accent-ink); font-size:18px; font-weight:600; box-shadow:var(--jz-shadow);
|
|
47
|
+
transition: background 180ms ease-out, transform 180ms ease-out; }
|
|
48
|
+
.launcher:hover, .launcher[aria-expanded="true"] { background:var(--jz-ink); border-color:var(--jz-ink); }
|
|
49
|
+
|
|
50
|
+
.panel { position:fixed; left:24px; bottom:80px; z-index:2147483646; width:min(360px, calc(100vw - 48px));
|
|
51
|
+
max-height:min(75vh, 580px); overflow:auto; padding:16px; border:1px solid var(--jz-rule); border-radius:10px;
|
|
52
|
+
background:var(--jz-surface); color:var(--jz-ink); box-shadow:var(--jz-shadow);
|
|
53
|
+
transition: opacity 180ms ease-out, transform 180ms ease-out; }
|
|
54
|
+
.panel-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:12px; }
|
|
55
|
+
.panel-head h2 { margin:0; font-size:14px; font-weight:600; }
|
|
56
|
+
.icon-btn { width:44px; height:44px; min-width:44px; display:flex; align-items:center; justify-content:center; padding:0;
|
|
57
|
+
border:0; border-radius:6px; background:transparent; color:var(--jz-faint); transition: color 180ms ease-out, background 180ms ease-out; }
|
|
58
|
+
.icon-btn:hover { color:var(--jz-ink); background:var(--jz-raised); }
|
|
59
|
+
|
|
60
|
+
.panel input { width:100%; min-height:44px; padding:8px 12px; border:1px solid var(--jz-rule); border-radius:6px;
|
|
61
|
+
background:var(--jz-canvas); color:var(--jz-ink); font:inherit; }
|
|
62
|
+
.panel input::placeholder { color:var(--jz-faint); }
|
|
63
|
+
.panel ul { list-style:none; padding:0; margin:12px 0 0; }
|
|
64
|
+
.panel li { margin:0 0 8px; }
|
|
65
|
+
.panel li button { display:block; width:100%; min-height:44px; text-align:left; padding:8px 12px; border:1px solid var(--jz-rule);
|
|
66
|
+
border-radius:6px; background:var(--jz-surface); color:inherit; font:inherit; transition: background 180ms ease-out, border-color 180ms ease-out; }
|
|
67
|
+
.panel li button:hover { background:var(--jz-raised); border-color:var(--jz-accent); }
|
|
68
|
+
.muted { color:var(--jz-muted); font-size:12px; margin:4px 0 0; }
|
|
69
|
+
.row { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
|
|
70
|
+
.row button { min-height:44px; padding:0 16px; border:1px solid var(--jz-rule); border-radius:6px; background:var(--jz-surface);
|
|
71
|
+
color:var(--jz-muted); transition: background 180ms ease-out, color 180ms ease-out; }
|
|
72
|
+
.row button:hover { color:var(--jz-ink); background:var(--jz-raised); }
|
|
73
|
+
.row .primary { border-color:var(--jz-accent); background:var(--jz-accent); color:var(--jz-accent-ink); }
|
|
74
|
+
|
|
75
|
+
.card { border:1px solid var(--jz-rule); border-radius:10px; padding:16px; }
|
|
76
|
+
.card h2 { margin:0 0 8px; font-size:14px; font-weight:600; }
|
|
77
|
+
.progress { height:4px; margin:8px 0 12px; border-radius:999px; background:var(--jz-raised); overflow:hidden; }
|
|
78
|
+
.progress-fill { height:100%; border-radius:999px; background:var(--jz-accent); transition: width 180ms ease-out; }
|
|
79
|
+
.step-title { margin:0 0 8px; font-weight:600; }
|
|
80
|
+
.panel img, .panel video { max-width:100%; margin-top:12px; border:1px solid var(--jz-rule); border-radius:6px; }
|
|
81
|
+
|
|
82
|
+
.checkin { margin-top:12px; padding-top:12px; border-top:1px solid var(--jz-rule); }
|
|
83
|
+
.checkin p { margin:0 0 8px; }
|
|
84
|
+
.callout-btn { display:inline-flex; align-items:center; gap:6px; margin-top:12px; min-height:44px; padding:0 16px;
|
|
85
|
+
border:1px solid var(--jz-confused); border-radius:6px; background:var(--jz-surface); color:var(--jz-confused);
|
|
86
|
+
transition: background 180ms ease-out, color 180ms ease-out; }
|
|
87
|
+
.callout-btn:hover { background:var(--jz-raised); }
|
|
88
|
+
.callout-btn svg { flex:none; }
|
|
89
|
+
.request { margin-top:12px; }
|
|
90
|
+
.request p { margin:0 0 8px; color:var(--jz-muted); font-size:12px; }
|
|
91
|
+
.request textarea { display:block; width:100%; padding:8px 12px; border:1px solid var(--jz-rule); border-radius:6px;
|
|
92
|
+
background:var(--jz-canvas); color:var(--jz-ink); font:inherit; resize:vertical; }
|
|
93
|
+
.request button { margin-top:8px; min-height:44px; padding:0 16px; border:1px solid var(--jz-accent);
|
|
94
|
+
border-radius:6px; background:var(--jz-accent); color:var(--jz-accent-ink); }
|
|
95
|
+
.checkin-btn { display:inline-flex; align-items:center; gap:6px; }
|
|
96
|
+
.checkin-btn.understood { color:var(--jz-polished); border-color:var(--jz-polished); }
|
|
97
|
+
.checkin-btn.confused { color:var(--jz-confused); border-color:var(--jz-confused); }
|
|
98
|
+
.checkin-btn svg { flex:none; }
|
|
99
|
+
|
|
100
|
+
@media (prefers-reduced-motion: reduce) {
|
|
101
|
+
:host *, :host *::before, :host *::after { animation-duration:1ms !important; transition-duration:1ms !important; }
|
|
102
|
+
}
|
|
103
|
+
.jz-help-highlight { position:fixed; z-index:2147483645; pointer-events:none; box-sizing:border-box;
|
|
104
|
+
border:2px solid var(--jz-accent); border-radius:6px; box-shadow:0 0 0 4px var(--jz-accent-soft); }
|
|
105
|
+
`;function _(n,e,t,s,i){const a={journeyId:e.slug||e.journeyId,journeyStep:String(t.index),pagePath:J(s),device:n.device||Q(i)};return n.persona&&(a.persona=n.persona),n.businessType&&(a.businessType=n.businessType),n.state&&(a.state=n.state),t.tflowId&&(a.tflowId=t.tflowId),a}function Ae(n,e,t,s){return _(n,e.guide,e.step,t,s)}function qe(n,e,t){const s={pagePath:J(e),device:n.device||Q(t)};return n.persona&&(s.persona=n.persona),n.journeyId&&(s.journeyId=n.journeyId),n.journeyStep&&(s.journeyStep=n.journeyStep),n.businessType&&(s.businessType=n.businessType),n.state&&(s.state=n.state),s}function Ne(n,e,t,s,i){if(t.kind==="callout")return{siteKey:n,consentGiven:true,kind:G.callout,context:_(e,t.guide,t.step,s,i)};const a=t.guide&&t.step?_(e,t.guide,t.step,s,i):qe(e,s,i),l={siteKey:n,consentGiven:true,kind:G.request,comment:t.text,context:a};return t.jobRequest&&(l.jobRequest=t.jobRequest),l}function He(n,e,t=xe){const s=se(n),i=n.claims!==void 0||n.getToken?import("./claims-VKhPNjA7.js").then(c=>c.claimsSource(n)):void 0,a=i&&(()=>i.then(c=>c.token()));a?.();let l,h;i?.then(c=>h=c);const b=new le({endpoint:s,siteKey:n.siteKey,reviewerToken:n.reviewerToken,claims:a});let E;const A=X(s,"GetWidgetConfig",{siteKey:n.siteKey}).then(c=>E=c,()=>{}),F=()=>!n.reviewerToken&&!n.userId,q=()=>F()&&E?.helpAudience!="reviewers",o=document.createElement("div");o.setAttribute("data-journeeze-help","");const g=o.attachShadow({mode:"closed"}),f=document.createElement("style");f.textContent=Te,n.nonce&&(f.nonce=n.nonce),g.append(f);const C=new ue(g);document.body.append(o);let m;const k=c=>(m??(m=import("./feedback-DeMvbZnh.js").then(I=>I.feedbackChannel(n,s,{memoryOnly:q(),claims:a})))).then(I=>I.outbox.enqueue(c),()=>"dropped");let y,U=false;const r=()=>de(n),p=()=>q()?null:void 0,v=()=>ae(r(),p()),j=te(n,s,e),z=()=>{U&&x.state.view!=="disabled"&&v()&&(y?.start(),j.start(A))},x=new he({endpoint:s,loadIndex:()=>b.index().then(c=>(l=c.persona||void 0,c)),loadGuide:c=>b.guide(c),highlight:c=>C.show(c),clearHighlight:()=>C.hide(),hasConsent:v,giveConsent(){oe(r(),p()),z()},signalsAllowed:()=>!F()||E?.anonymousAllowed==true,sendCheckin(c){return v()?(y?.checkin(c),k({siteKey:n.siteKey,consentGiven:true,context:Ae(e(),c,location.href,window.innerWidth),reaction:ne[c.answer]})):Promise.resolve("dropped")},sendSignal(c){return!x.canSignal()||!v()?Promise.resolve("dropped"):k(Ne(n.siteKey,e(),c,location.href,window.innerWidth))}});n.noTelemetry||(y=be(s,n.siteKey,x,()=>h?.current())),x.subscribe(z);let T,H=false,w;const S=c=>{const I=c.available?"on":c.reason;if(!(H||I===w)){w=I;try{n.onHelpStatus?.(c)}catch{}}};return x.subscribe(()=>{w!==void 0&&x.state.view==="disabled"&&S({available:false,reason:"disabled"})}),Promise.all([x.probe(),A]).then(()=>{if(!H){if(x.state.view==="disabled")return S({available:false,reason:"disabled"});S(E?.helpAudience=="reviewers"&&!n.reviewerToken?{available:false,reason:"audience"}:{available:true}),U=true,z(),T=t(g,x,{consentText:()=>A.then(c=>c?.consentText||re),persona:()=>l??e().persona,jobEvent(c){U&&x.state.view!=="disabled"&&v()&&y?.job(c)},routeIntent:c=>Fe({endpoint:s,siteKey:n.siteKey,reviewerToken:n.reviewerToken,claims:a,hasConsent:v,canSignal:()=>x.canSignal()},c),addStyle(c){const I=document.createElement("style");I.textContent=c,n.nonce&&(I.nonce=n.nonce),g.append(I)}})}}),{unmount(c){H=true,i?.then(I=>I.stop()),x.close(),y?.stop(c),j.stop(c),T?.destroy(),C.dispose(),o.remove(),m?.then(I=>I.dispose())},contextChanged:()=>{x.refreshHighlight(),j.contextChanged()}}}const Re=(n,e)=>He(n,()=>ce(e()),Se);export{le as HelpClient,he as HelpController,ue as Highlighter,pe as MAX_REQUEST_CHARS,Oe as PANEL_CSS,Ae as checkinContext,Me as findAnchor,_ as guideStepContext,L as isHelpDisabled,Re as mount,He as mountHelp,qe as pageContext,xe as placeholderView,M as searchGuides,Ne as signalRequest,ge as toView};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var g=Object.defineProperty;var w=(n,t,e)=>t in n?g(n,t,{enumerable:true,configurable:true,writable:true,value:e}):n[t]=e;var s=(n,t,e)=>w(n,typeof t!="symbol"?t+"":t,e);import{e as x}from"./consent-bPengyOI.js";import{T as m}from"./loader-DHgG5Y7t.js";const b=6e4;class L{constructor(t){s(this,"opts");s(this,"indexEntry");s(this,"guides",new Map);s(this,"inflight",new Map);s(this,"now");s(this,"freshMs");this.opts=t,this.now=t.now??Date.now,this.freshMs=t.freshMs??6e4}index(){return this.read("index","GetHelpIndex",{},()=>this.indexEntry,t=>this.indexEntry=t,()=>false)}guide(t){return this.read(`guide:${t}`,"GetGuide",{journeyId:t},()=>this.guides.get(t),e=>this.guides.set(t,e),e=>{const i=e.linksExpireAt?Date.parse(e.linksExpireAt):NaN;return Number.isFinite(i)&&i-this.now()<b})}body(t,e){const i=this.opts.reviewerToken;return{siteKey:this.opts.siteKey,...t,...i&&{reviewerToken:i},...e&&{claims:e}}}read(t,e,i,o,u,h){const a=this.opts.claims;return a?a().then(d=>this.readWith(t,e,i,d,o,u,h)):this.readWith(t,e,i,void 0,o,u,h)}readWith(t,e,i,o,u,h,a){const d=u(),r=d&&d.claims===o?d:void 0;if(r&&this.now()-r.at<this.freshMs&&!a(r.value))return Promise.resolve(r.value);const c=`${t}
|
|
2
|
+
${o??""}`,f=this.inflight.get(c);if(f)return f;const v=r&&!a(r.value)?r.etag:void 0,p=x(this.opts.endpoint,e,this.body(i,o),v,this.opts.fetchImpl).then(l=>{if(l.notModified){if(!r)throw new Error("304 without a cached value");return h({...r,at:this.now()}),r.value}return h({value:l.value,etag:l.etag,at:this.now(),claims:o}),l.value}).finally(()=>this.inflight.delete(c));return this.inflight.set(c,p),p}}const M=()=>import("./resolve-CRDmtd4b.js");function E(n,t=document){if(m.test(n))for(const e of t.querySelectorAll(`[data-tflow-id="${n}"]`)){const i=e.getBoundingClientRect();if(i.width>0||i.height>0)return e}}function y(n=window){try{return n.matchMedia?.("(prefers-reduced-motion: reduce)").matches??false}catch{return false}}class N{constructor(t,e=window,i=M){s(this,"win");s(this,"load");s(this,"target");s(this,"box");s(this,"onMove",()=>this.place());s(this,"seq",0);this.win=e,this.load=i,this.box=e.document.createElement("div"),this.box.className="jz-help-highlight",this.box.setAttribute("aria-hidden","true"),this.box.hidden=true,t.append(this.box)}show(t){this.hide();const e=this.seq,[i]=t??[];return i?t?.length===1&&i.by==="tflow"?this.outline(E(i.value,this.win.document)):this.load().then(o=>e===this.seq?this.outline(o.resolveTarget(t??[],this.win.document)):"none",()=>"missing"):"none"}outline(t){return t?(this.target=t,t.scrollIntoView?.({block:"center",inline:"nearest",behavior:y(this.win)?"auto":"smooth"}),this.win.addEventListener("scroll",this.onMove,{capture:true,passive:true}),this.win.addEventListener("resize",this.onMove,{passive:true}),this.box.hidden=false,this.place(),"found"):"missing"}hide(){this.seq++,this.target&&(this.target=void 0,this.box.hidden=true,this.win.removeEventListener("scroll",this.onMove,{capture:true}),this.win.removeEventListener("resize",this.onMove))}dispose(){this.hide(),this.box.remove()}place(){if(!this.target)return;if(!this.target.isConnected)return this.hide();const t=this.target.getBoundingClientRect();Object.assign(this.box.style,{left:`${t.left-4}px`,top:`${t.top-4}px`,width:`${t.width+8}px`,height:`${t.height+8}px`})}}export{N as H,L as a,E as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const u={like:"REACTION_LIKE",dislike:"REACTION_DISLIKE",understood:"REACTION_UNDERSTOOD",confused:"REACTION_CONFUSED"},E={request:"FEEDBACK_KIND_REQUEST",callout:"FEEDBACK_KIND_CALLOUT"},o=new WeakMap;function I(n,a,d){let i=o.get(n);i||o.set(n,i={holders:0});const e=i;let r=false;return{start(t){r||n.signals?.enabled!==true||n.noTelemetry||(r=true,e.holders++,e.running??(e.running=Promise.resolve(t).then(s=>{if(s?.signalsEnabled===true)return import("./signals-
|
|
1
|
+
const u={like:"REACTION_LIKE",dislike:"REACTION_DISLIKE",understood:"REACTION_UNDERSTOOD",confused:"REACTION_CONFUSED"},E={request:"FEEDBACK_KIND_REQUEST",callout:"FEEDBACK_KIND_CALLOUT"},o=new WeakMap;function I(n,a,d){let i=o.get(n);i||o.set(n,i={holders:0});const e=i;let r=false;return{start(t){r||n.signals?.enabled!==true||n.noTelemetry||(r=true,e.holders++,e.running??(e.running=Promise.resolve(t).then(s=>{if(s?.signalsEnabled===true)return import("./signals-C_WxFykA.js").then(l=>l.startSignals({options:n,endpoint:a,getContext:d,site:s}),()=>{e.running=void 0})})))},stop(t){if(!r||(r=false,--e.holders>0))return;const s=e.running;e.running=void 0,s?.then(l=>l?.stop(t))},contextChanged(){r&&e.running?.then(t=>t?.contextChanged())}}}export{E as F,u as R,I as s};
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { p as s, t as p } from "./context-UnG6_X61.js";
|
|
3
|
-
import { i } from "./index-CwG2LrhO.js";
|
|
1
|
+
import { c as s, i as t, p as o, t as r, a as i } from "./loader-DHgG5Y7t.js";
|
|
4
2
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
s as createJourneeze,
|
|
4
|
+
t as isMasked,
|
|
5
|
+
o as pagePath,
|
|
6
|
+
r as takeReviewerToken,
|
|
7
|
+
i as tflowIdAt
|
|
10
8
|
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
function j(e) {
|
|
2
|
+
const t = `jz:reviewer:${e}`;
|
|
3
|
+
let a = null;
|
|
4
|
+
try {
|
|
5
|
+
const n = new URL(location.href);
|
|
6
|
+
a = n.searchParams.get("jz_invite"), a ? (n.searchParams.delete("jz_invite"), history.replaceState(history.state, "", n.href), sessionStorage.setItem(t, a)) : a = sessionStorage.getItem(t);
|
|
7
|
+
} catch {
|
|
8
|
+
}
|
|
9
|
+
return a || void 0;
|
|
10
|
+
}
|
|
11
|
+
function I(e) {
|
|
12
|
+
try {
|
|
13
|
+
sessionStorage.removeItem(`jz:reviewer:${e}`);
|
|
14
|
+
} catch {
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const E = /^(?:[0-9a-f]{64}|[A-Za-z0-9_-]{43})$/, k = /^pk_[0-9a-f]{32}$/, T = () => import("./widget-BA2WH0yi.js"), C = () => import("./help-phTc32Gg.js"), _ = () => import("./chat-Coze4aH0.js").then((e) => e.c), w = /* @__PURE__ */ new Set();
|
|
18
|
+
function p(e) {
|
|
19
|
+
w.has(e) || (w.add(e), console.warn(`[journeeze] ${e}`));
|
|
20
|
+
}
|
|
21
|
+
function g(e) {
|
|
22
|
+
if (e === void 0 || E.test(e)) return e;
|
|
23
|
+
p("invalid userId ignored");
|
|
24
|
+
}
|
|
25
|
+
function y(e, t, a) {
|
|
26
|
+
let n, l, c = 0, u = -1;
|
|
27
|
+
const f = {
|
|
28
|
+
on() {
|
|
29
|
+
if (n) return Promise.resolve();
|
|
30
|
+
if (l && u === c) return l;
|
|
31
|
+
const o = u = c, r = e().then((i) => {
|
|
32
|
+
o === c && !n && (n = t(i, () => f.off()), a?.(!0));
|
|
33
|
+
}).finally(() => {
|
|
34
|
+
l === r && (l = void 0);
|
|
35
|
+
});
|
|
36
|
+
return l = r, r;
|
|
37
|
+
},
|
|
38
|
+
off(o) {
|
|
39
|
+
c++;
|
|
40
|
+
const r = n;
|
|
41
|
+
r && (n = void 0, r.unmount(o), a?.(!1));
|
|
42
|
+
},
|
|
43
|
+
mounted: () => n
|
|
44
|
+
};
|
|
45
|
+
return f;
|
|
46
|
+
}
|
|
47
|
+
const h = (e, t) => (...a) => {
|
|
48
|
+
try {
|
|
49
|
+
t(...a);
|
|
50
|
+
} catch (n) {
|
|
51
|
+
p(`${e} failed: ${String(n)}`);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
function R(e, t = T, a = e.chat ? _ : C) {
|
|
55
|
+
const { siteKey: n } = e, l = k.test(n);
|
|
56
|
+
l || p("invalid siteKey");
|
|
57
|
+
let c = g(e.userId), u = { ...e.context };
|
|
58
|
+
const f = () => u, o = { ...e };
|
|
59
|
+
Object.defineProperty(o, "userId", { get: () => c, enumerable: !0 }), e.respectGlobalPrivacyControl !== !1 && navigator.globalPrivacyControl && (o.noTelemetry = !0);
|
|
60
|
+
const r = y(t, (s, d) => s.mount(o, f, d), (s) => o.onModeChange?.(s)), i = y(a, (s, d) => s.mount(o, f, d)), v = (s) => async () => {
|
|
61
|
+
if (!l) throw new Error("[journeeze] invalid siteKey");
|
|
62
|
+
return s.on();
|
|
63
|
+
}, b = {
|
|
64
|
+
enable: v(r),
|
|
65
|
+
disable: h("disable", () => r.off()),
|
|
66
|
+
isEnabled: () => !!r.mounted(),
|
|
67
|
+
enableHelp: v(i),
|
|
68
|
+
disableHelp: h("disableHelp", () => i.off()),
|
|
69
|
+
isHelpEnabled: () => !!i.mounted(),
|
|
70
|
+
feedback: () => v(e.chat ? i : r)().then(() => i.mounted()?.report?.()),
|
|
71
|
+
setContext: h("setContext", (s) => {
|
|
72
|
+
u = { ...u, ...s }, r.mounted()?.contextChanged?.(), i.mounted()?.contextChanged?.();
|
|
73
|
+
}),
|
|
74
|
+
getContext: f,
|
|
75
|
+
setUser: h("setUser", (s, d) => {
|
|
76
|
+
const m = g(s);
|
|
77
|
+
c !== void 0 && m !== c && b.reset(), c = m, o.signature = m && d;
|
|
78
|
+
}),
|
|
79
|
+
reset: h("reset", () => {
|
|
80
|
+
const s = !!i.mounted(), d = { ...o, userId: c };
|
|
81
|
+
r.off(!0), i.off(!0), c = void 0, u = {}, delete o.reviewerToken, delete o.claims, I(n), import("./feedback-DeMvbZnh.js").then((m) => m.logout(d)).catch(() => {
|
|
82
|
+
}).then(() => {
|
|
83
|
+
s && !i.mounted() && i.on().catch(() => {
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
})
|
|
87
|
+
};
|
|
88
|
+
return b;
|
|
89
|
+
}
|
|
90
|
+
const x = /^[a-z0-9._:-]{1,96}$/;
|
|
91
|
+
function $(e) {
|
|
92
|
+
const t = e?.closest("[data-tflow-id]")?.getAttribute("data-tflow-id") ?? void 0;
|
|
93
|
+
return t !== void 0 && x.test(t) ? t : void 0;
|
|
94
|
+
}
|
|
95
|
+
function U(e) {
|
|
96
|
+
try {
|
|
97
|
+
return new URL(e).pathname;
|
|
98
|
+
} catch {
|
|
99
|
+
return "/";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const z = "input, textarea, select, [data-jz-mask]";
|
|
103
|
+
function S(e) {
|
|
104
|
+
if (e.isContentEditable === !0) return !0;
|
|
105
|
+
const t = e.getAttribute("contenteditable");
|
|
106
|
+
return t !== null && t.trim().toLowerCase() !== "false";
|
|
107
|
+
}
|
|
108
|
+
function P(e) {
|
|
109
|
+
return e.matches(z) || S(e);
|
|
110
|
+
}
|
|
111
|
+
function A(e) {
|
|
112
|
+
for (let t = e; t; t = t.parentElement)
|
|
113
|
+
if (P(t)) return !0;
|
|
114
|
+
return !1;
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
k as S,
|
|
118
|
+
x as T,
|
|
119
|
+
E as U,
|
|
120
|
+
$ as a,
|
|
121
|
+
P as b,
|
|
122
|
+
R as c,
|
|
123
|
+
A as i,
|
|
124
|
+
U as p,
|
|
125
|
+
j as t,
|
|
126
|
+
p as w
|
|
127
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{c as f,s as d}from"./consent-bPengyOI.js";import{w as h}from"./loader-DHgG5Y7t.js";const l=50,m=/^[a-z0-9._:-]{1,96}$/,g=/^\[data-tflow-id="([^"\\]*)"\]$/,k=/^[\x20-\x7e]{1,200}$/,w=/[{};@\\<`]|\/\*|::/,s=new Set;function $(e,n,r){const t=g.exec(e.selector)?.[1];if(t!==void 0&&m.test(t))return{anchor:t,pagePath:n,rule:e.rule,detectedAt:r};if(!(!k.test(e.selector)||w.test(e.selector)))return{selector:e.selector,pagePath:n,rule:e.rule,detectedAt:r}}function y(e){return n=>n.hasAttribute("data-jz-mask")||e.some(r=>{try{return n.matches(r)}catch{return true}})}function S(e,n){return n==="none"?"/":d(e)}function O(e,n,r,t,o,c){const a=S(r,c),u=o.toISOString();return e(n,y(t)).map(i=>$(i,a,u)).filter(i=>i!==void 0)}async function v(e){const r=O(e.scan,document.body,location.href,e.maskSelectors??[],(e.now??(()=>new Date))(),e.pagePath).filter(t=>{const o=`${t.pagePath}
|
|
2
|
+
${t.anchor??t.selector}
|
|
3
|
+
${t.rule}`;return s.has(o)?false:(s.add(o),true)});for(let t=0;t<r.length;t+=l){const o=r.slice(t,t+l);try{await f(e.endpoint,"SubmitMaskFindings",{siteKey:e.siteKey,reviewerToken:e.reviewerToken,findings:o},e.fetchImpl)}catch(c){for(const a of o)s.delete(`${a.pagePath}
|
|
4
|
+
${a.anchor??a.selector}
|
|
5
|
+
${a.rule}`);h(`mask audit not sent: ${String(c.code??c)}`)}}return r.length}function E(){s.clear()}export{O as auditPage,E as resetMaskAudit,v as runMaskAudit};
|
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as I } from "react/jsx-runtime";
|
|
2
2
|
import { createContext as O, useRef as l, useMemo as j, useEffect as f, useContext as N } from "react";
|
|
3
|
-
import { t as M, c as R, w as U } from "./loader-
|
|
3
|
+
import { t as M, c as R, w as U } from "./loader-DHgG5Y7t.js";
|
|
4
4
|
import { CONTEXT_FIELDS as H } from "./contract.js";
|
|
5
5
|
const T = O(null), a = () => {
|
|
6
6
|
}, $ = Object.freeze({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{T as c}from"./loader-DHgG5Y7t.js";const p=/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/,b=/^[a-z]{2,32}$/,m="input:not([type]),input[type=text],input[type=email],input[type=tel],input[type=url],input[type=password]",f={button:"button,input[type=button],input[type=submit],input[type=reset],input[type=image],summary",link:"a[href],area[href]",textbox:`textarea,${m}`,searchbox:"input[type=search]",checkbox:"input[type=checkbox]",radio:"input[type=radio]",combobox:"select:not([multiple]):not([size]),input[list]",listbox:"select[multiple],select[size],datalist",option:"option",slider:"input[type=range]",spinbutton:"input[type=number]",progressbar:"progress",heading:"h1,h2,h3,h4,h5,h6",img:"img[alt]:not([alt='']),svg[aria-label]",list:"ul,ol,menu",listitem:"li",table:"table",row:"tr",cell:"td",columnheader:"th",navigation:"nav",main:"main",form:"form",dialog:"dialog",article:"article",separator:"hr",group:"fieldset,details,optgroup"},d=new Set(["button","link","heading","option","cell","columnheader","row","listitem","tab","menuitem","checkbox","radio","switch","treeitem","tooltip"]),r=t=>(t??"").replace(/\s+/g," ").trim(),h=t=>{const o=t.getBoundingClientRect();return o.width>0||o.height>0};function g(t){const o=t.ownerDocument,e=[],n=t.getAttribute("id");if(n)for(const s of o.querySelectorAll("label"))s.getAttribute("for")===n&&e.push(s);const a=t.parentElement?.closest("label");return a&&!e.includes(a)&&e.push(a),e}function y(t,o){const e=t.ownerDocument,n=t.getAttribute("aria-labelledby");if(n){const i=r(n.split(/\s+/).map(l=>e.getElementById(l)?.textContent??"").join(" "));if(i)return i}const a=r(t.getAttribute("aria-label"));if(a)return a;const s=r(g(t).map(i=>i.textContent).join(" "));if(s)return s;const u=r(t.getAttribute("alt"));if(u)return u;if(t instanceof HTMLInputElement&&/^(button|submit|reset)$/.test(t.type)){const i=r(t.value);if(i)return i}if(d.has(o)){const i=r(t.textContent);if(i)return i}return r(t.getAttribute("title"))||r(t.getAttribute("placeholder"))}function v(t,o){const e=n=>[...o.querySelectorAll(n)];try{switch(t.by){case"tflow":return c.test(t.value)?e(`[data-tflow-id="${t.value}"]`):[];case"testId":return p.test(t.value)?e(`[data-testid="${t.value}"]`):[];case"role":{if(!b.test(t.value))return[];const n=f[t.value],a=e(n?`[role="${t.value}"],${n}`:`[role="${t.value}"]`),s=r(t.name);return a.filter(u=>{const i=u.getAttribute("role");return i&&i.split(/\s+/)[0]!==t.value?false:!s||y(u,t.value)===s})}case"css":return e(t.value)}}catch{}return[]}function A(t,o=document){for(const e of t){const n=v(e,o).filter(h);if(n.length===1)return n[0]}}export{y as accessibleName,A as resolveTarget};
|
package/dist/script.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as c, c as u } from "./loader-
|
|
1
|
+
import { t as c, c as u } from "./loader-DHgG5Y7t.js";
|
|
2
2
|
const e = document.querySelector("script[data-journeeze-site-key]"), o = e?.dataset.journeezeSiteKey;
|
|
3
3
|
if (o && !window.Journeeze) {
|
|
4
4
|
const n = c(o), t = e?.dataset ?? {}, a = t.journeezeEndpoint, r = t.journeezeApiHost, i = t.journeezeApiPath, s = u({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CONTEXT_ID_PATTERN as ye,CONTEXT_FIELDS as He}from"./contract.js";import{w as R}from"./loader-BZiIDD1D.js";import{p as Ze,s as Qe,j as we,m as Ye,M as Je,r as et}from"./transport-B64CfIcF.js";import{c as tt,C as _e}from"./consent-DckCUvYR.js";const nt=/[A-Za-z0-9_]/,ot=/^[A-Za-z_]\w{0,63}$/,Z=o=>!!o&&nt.test(o),ae=o=>!!o&&o>="0"&&o<="9";function je(o,n,s){const f=typeof o==typeof s;return n==="=="?f&&o===s:n==="!="?!(f&&o===s):!f||typeof o=="boolean"?false:n==="<"?o<s:n==="<="?o<=s:n===">"?o>s:o>=s}function it(o){if(!(o?.length<=1024))return;let n=0,s=0,f=0;const m=()=>{for(;n<o.length&&o[n]<=" ";)n++},p=()=>{const a=n;for(;n<o.length&&Z(o[n]);)n++;if(o.slice(a,n)!=="event"||o[n]!==".")return;n++;const d=n;for(;n<o.length&&Z(o[n]);)n++;const c=o.slice(d,n);if(c==="kind")return[true,""];if(c!=="fields"||o[n]!==".")return;n++;const v=n;for(;n<o.length&&Z(o[n]);)n++;const h=o.slice(v,n);return ot.test(h)?[false,h]:void 0},I=a=>{let d="";for(n++;n<o.length;){const c=o[n];if(c===a)return n++,d;if(c==="\\"){const v=o[n+1];if(v===void 0||!`\\"'`.includes(v))return;d+=v,n+=2;continue}if(c<" ")return;d+=c,n++}},O=()=>{const a=n;o[n]==="-"&&n++;const d=n;for(;n<o.length&&ae(o[n]);)n++;if(n!==d){if(o[n]==="."){n++;const c=n;for(;n<o.length&&ae(o[n]);)n++;if(n===c)return}return Number(o.slice(a,n))}},L=()=>{const a=o[n];if(a==='"'||a==="'")return I(a);if(a==="-"||ae(a))return O();const d=n;for(;n<o.length&&Z(o[n]);)n++;const c=o.slice(d,n);return c==="true"?true:c==="false"?false:void 0},k=()=>{const a=o[n],d=o[n+1];if(a==="="&&d==="=")return n+=2,"==";if(a==="!"&&d==="=")return n+=2,"!=";if(a==="<"||a===">")return n+=d==="="?2:1,d==="="?a+"=":a},N=()=>{if(m(),o[n]==="("){if(++f>8)return;n++;const h=F();return m(),!h||o[n]!==")"?void 0:(n++,f--,h)}const a=o[n]==="e",d=a?p():L();if(d===void 0)return;m();const c=k();if(!c)return;if(m(),a){const h=L();if(h===void 0||++s>32)return;const E=d;return S=>je(E[0]?S.kind:S.fields[E[1]],c,h)}const v=p();if(v&&!(++s>32))return h=>je(d,c,v[0]?h.kind:h.fields[v[1]])},b=(a,d,c)=>{let v=a();if(v)for(;;){if(m(),o[n]!==d||o[n+1]!==d)return v;n+=2;const h=a();if(!h)return;const E=v;v=c?S=>E(S)&&h(S):S=>E(S)||h(S)}},g=()=>b(N,"&",true),F=()=>b(g,"|",false),$=F();return m(),$&&n===o.length?$:void 0}const Q="step_completed",st=["lt5s","lt15s","lt60s","lt5m","ge5m"],rt=[5e3,15e3,6e4,3e5];function at(o){const n=rt.findIndex(s=>o<s);return st[n<0?4:n]}function ct(o){let n,s=0,f=-1;return{sync(m,p){if(m!==n&&(n=m,s=o(),f=-1),!p||p.journey!==n||p.index<=f)return;const I=o(),O=at(I-s);return s=I,f=p.index,{journey:p.journey,step:p.step,duration_bucket:O}}}}const dt="jz-platform@2",ce={abandoned_step:{step:"int"},hesitation:{dwell_ms:"int"},rage_click:{clicks:"int"},dead_click:{},step_target_missing:{journey:"id",step:"int",rev:"int",tried:"id"},[Q]:{step:"id",journey:"id",duration_bucket:"id"}},Se=/^[a-z][a-z0-9_]{0,63}$/,Pe=/^[a-z0-9._:-]{1,96}$/,lt=/^[a-z0-9._:-]{1,64}$/,ke=700,It=3,be=3e3,de=1e3,ut=12e4,ft=1e3,pt=1e4,mt=300,ht=64,Ee=50,Te=32*1024,ze=5e3,Ae=200,gt=256*1024,Ie=(o,n)=>typeof o=="function"&&n.every(s=>typeof o.prototype?.[s]=="function");function Me(o){const n=o;return!!n&&Ie(n.TFloBrowser,["init","addPattern","removePattern","ingest","flush","destroy"])&&Ie(n.Pattern,["when","then","notThen","within","emit"])}const vt=()=>import("./index-B_nob8S0.js");async function yt(o,n=vt){if(o!==void 0)try{const s=typeof o=="function"?await o():o;if(Me(s))return s;R("signals.tflo lacks the TFloBrowser/Pattern surface; using the SDK's own")}catch{R("signals.tflo failed to load; using the SDK's own")}try{const s=await n();if(Me(s))return s}catch{}R("tflo failed to load; signals off")}const xe="[data-jz-mask],[data-jz-block],input,textarea,select,[contenteditable]:not([contenteditable='false'])";function Oe(o,n=[]){let s=o instanceof Element?o:o instanceof Node?o.parentElement:null;if(!s)return;const f=[xe,...n].join(",");try{if(s.closest(f))return}catch{if(s.closest(xe))return}const p=s.closest("[data-tflow-id]")?.getAttribute("data-tflow-id")??void 0;return p!==void 0&&Pe.test(p)?p:void 0}const wt=o=>Math.round(o/500)*500;function _t(){return crypto.randomUUID()}const jt=128;async function Mt(o){const n=o.site;if(n.signalsEnabled!==true)return;const s=o.options.signals??{},f=await yt(s.tflo,o.loadOwn);if(!f)return;const m=o.now??(()=>performance.now()),p=o.fetchImpl??((...e)=>fetch(...e)),I=o.newId??_t,O=o.options.maskSelectors??[],L=new Map;for(const e of n.siteSignals??[]){if(!Se.test(e.name)||e.name in ce||e.name.startsWith("jz_"))continue;const t={};for(const i of(e.params??[]).slice(0,8))t[i.name]=i.type==="string"?"id":i.type;L.set(e.name,t)}let k=false;const N=[],b=(e,t,i)=>{e.addEventListener(t,i,{capture:true,passive:true}),N.push(()=>e.removeEventListener(t,i,{capture:true}))};let g=[],F=0,$=0,a,d=0,c,v=Promise.resolve();const h=e=>{k||c!==void 0||(c=setTimeout(()=>{c=void 0,v=v.then(Ce)},e))},E=(e,t=0)=>({siteKey:o.options.siteKey,consentGiven:true,ruleSet:dt,signals:e,...t>0?{droppedAtUnload:t}:{}}),S=(e,t)=>{const i=[];for(const r of e){if(i.length>=Ee||we(E([...i,r]))>t)break;i.push(r)}return i},Ce=async()=>{let e=a;if(!e&&g.length>0){const t=S(g,Te);g=g.slice(t.length),e={signals:t,retries:0,firstAt:Date.now(),dropped:d},d=0}if(!(!e||e.signals.length===0)){a=void 0;try{await tt(o.endpoint,"RecordSignals",E(e.signals,e.dropped),p)}catch(t){const i=t instanceof _e?t.status:0,r=t instanceof _e?t.retryAfterMs:void 0;if(!k&&Ye(e.retries,i)&&Date.now()-e.firstAt<Je){a={...e,retries:e.retries+1},h(et(e.retries+1,r));return}}g.length>0&&h(g.length>=Ee?0:ze)}},De=(e,t)=>{if(!(k||$>=mt)){for($++,g.push({eventId:I(),seq:++F,...e}),g.length>Ae&&(g=g.slice(-Ae));g.length>1&&we(g)>gt;)g=g.slice(1);t?(c!==void 0&&clearTimeout(c),c=void 0,h(0)):h(ze)}},le=new Map,W=new Map,K=new Map,ue=typeof s.appVersion=="string"&&ye.test(s.appVersion)?s.appVersion:void 0,Re=()=>{const e=o.getContext(),t={};for(const i of He){const r=e[i];typeof r=="string"&&ye.test(r)&&(t[i]=r)}return ue&&(t.appVersion=ue),t},Le=(e,t)=>{if(e==="int"&&typeof t=="number"&&Number.isFinite(t))return{intValue:String(Math.trunc(t))};if(e==="double"&&typeof t=="number"&&Number.isFinite(t))return{doubleValue:t};if(e==="bool"&&typeof t=="boolean")return{boolValue:t};if(e==="id"&&typeof t=="string"&<.test(t))return{stringValue:t}},Y=e=>{const t=e.payload??{};if(t.__drop===true)return;const i=ce[e.name],r=i??L.get(e.name);if(!r)return;const l=typeof t.target=="string"&&Pe.test(t.target)?t.target:void 0;if(e.name==="rage_click"&&l){const x=K.get(l);queueMicrotask(()=>j(()=>x?.reset()))}const u=e.name===Q?`${e.name} ${String(t.journey)} ${String(t.step)}`:`${e.name} ${l??""}`,_=m(),y=le.get(u);if(y!==void 0&&_-y<pt){e.name==="rage_click"&&typeof t.clicks=="number"&&W.set(u,(W.get(u)??0)+t.clicks);return}le.set(u,_);const H={};let D=0;for(const[x,Ge]of Object.entries(r)){let re=t[x];x==="clicks"&&typeof re=="number"&&(re+=W.get(u)??0,W.delete(u));const ve=Le(Ge,re);ve&&D<8&&(H[x]=ve,D++)}e.name===Q&&D!==3||De({name:e.name,source:i?"SIGNAL_SOURCE_PLATFORM":"SIGNAL_SOURCE_SITE",context:Re(),...l?{target:l}:{},...D>0?{params:H}:{}},e.name==="abandoned_step")},J=f.Pattern;let w;const fe=async()=>{const e=new f.TFloBrowser({sinks:[{name:"journeeze",send:Y}],onSinkError:()=>{}});try{await e.init()}catch{return R("tflo failed to initialise; signals off"),false}return k?(e.destroy(),false):(w=e,Xe(e),true)},P=(e,t={})=>{!k&&w&&j(()=>w.ingest({kind:e,ts:m(),fields:t}))},ee=e=>e.kind==="jz.end",T=new Map;let Ne=0,M;const V=e=>{T.delete(e.name),j(()=>w?.removePattern(e.name))},te=(e,t,i,r,l,u)=>{if(!w)return;for(const x of T.values())if(x.key===t)return;T.size>=jt&&V(T.values().next().value);const _=++Ne,y=`${e}#${_}`,H=r(new J(y),_).within(i).emit(l),D=w.addPattern(H);T.set(y,{name:y,key:t,runtime:D,deadline:m()+i}),P("jz.window",{...u,w:_}),M??(M=setInterval($e,ft))};function $e(){const e=m();for(const t of[...T.values()]){if(t.deadline>e)continue;const i=j(()=>t.runtime.flush())??[];V(t);for(const r of i)Y(r)}T.size===0&&M!==void 0&&(clearInterval(M),M=void 0)}const C=(e,t)=>{for(const i of[...T.values()])i.name.startsWith(`${e}#`)&&(t===void 0||i.key===t)&&V(i)};let Ue=0;const z=new Map,Be=e=>{if(!w)return;const t=z.get(e);if(t){z.delete(e),z.set(e,t);return}if(z.size>=ht){const[u,_]=z.entries().next().value;j(()=>w?.removePattern(_)),z.delete(u),K.delete(u)}const i=u=>u.kind==="jz.click"&&u.fields.target===e,r=`rage_click#${++Ue}`,l=w.addPattern(new J(r).when(i).then(i).then(i).within(ke).emit(u=>u.last().ts-u.first().ts<=ke?{name:"rage_click",payload:{target:e,clicks:u.length}}:{name:"rage_click",payload:{__drop:true}}));z.set(e,r),K.set(e,l)},Fe=(e,t)=>te("hesitation",e,be,(i,r)=>i.when(l=>l.fields.w===r).notThen(l=>ee(l)||(l.kind==="jz.unhover"||l.kind==="jz.blur"||l.kind==="jz.click"||l.kind==="jz.change")&&l.fields.target===e),i=>({name:"hesitation",payload:{target:e,dwell_ms:Math.max(be,wt(m()-i.first().ts))}}),{target:e,kind:t}),We=e=>te("dead_click",e,de,(t,i)=>t.when(r=>r.fields.w===i).notThen(r=>ee(r)||r.kind==="jz.effect"),()=>({name:"dead_click",payload:{target:e}}),{target:e});let Ke=0;const pe=[];for(const e of s.rules??[]){if(!Se.test(e.name)||e.name in ce||e.name.startsWith("jz_")){R(`site rule ${e.name} refused (name)`);continue}const t=typeof e.when=="function"?e.when:it(e.when);if(!t){R(`site rule ${e.name} refused (outside the SDK's CEL subset)`);continue}pe.push({rule:e,pred:t})}const Ve=e=>St.has(e.kind);function Xe(e){for(const{rule:t,pred:i}of pe)e.addPattern(new J(`site:${t.name}#${++Ke}`).when(r=>Ve(r)&&j(()=>i({kind:r.kind.slice(3),ts:r.ts,fields:{target:r.fields.target}}))===true).emit(r=>{const l=r.first(),u={target:l.fields.target};for(const[_,y]of Object.entries(t.params??{}))_!=="target"&&(u[_]=bt(l,y));return{name:t.name,payload:u}}))}let A;const qe=ct(m),ne=()=>{const e=o.getContext();A&&e.journeyId!==A.journey&&(C("abandoned_step"),A=void 0);const t=kt(n,e,A),i=qe.sync(e.journeyId,t&&e.journeyStep?{journey:t.journey,index:t.index,step:e.journeyStep}:void 0);if(i&&Y({name:Q,payload:{...i}}),!t||A&&t.index<=A.index||(A&&P("jz.step",{journey:t.journey,index:t.index}),C("abandoned_step"),A=t,t.last))return;const{journey:r,index:l}=t;te("abandoned_step",r,ut,(u,_)=>u.when(y=>y.fields.w===_).notThen(y=>ee(y)||y.kind==="jz.step"&&y.fields.journey===r&&y.fields.index>l),()=>({name:"abandoned_step",payload:{step:l+1}}),{journey:r,index:l})};let me=0;const X=()=>{m()>me||(P("jz.effect"),C("dead_click"))},U=typeof MutationObserver=="function"?new MutationObserver(X):void 0;let B;const oe=typeof PerformanceObserver=="function"?j(()=>new PerformanceObserver(e=>e.getEntries().length>0&&X())):void 0;j(()=>oe?.observe({type:"resource"}));const ie=e=>Oe(e.composedPath?.()[0]??e.target,O);b(document,"click",e=>{const t=ie(e);t&&(Be(t),P("jz.click",{target:t}),C("hesitation",t),me=m()+de,U&&(U.observe(document.documentElement,{childList:true,attributes:true,subtree:true}),B!==void 0&&clearTimeout(B),B=setTimeout(()=>U.disconnect(),de)),We(t))});const q=(e,t)=>b(document,e,i=>{t==="jz.focus"&&X();const r=ie(i);r&&((t==="jz.hover"||t==="jz.unhover")&&Oe(i.relatedTarget,O)===r||(P(t,{target:r}),t==="jz.hover"||t==="jz.focus"?Fe(r,t):C("hesitation",r)))});q("pointerover","jz.hover"),q("pointerout","jz.unhover"),q("focusin","jz.focus"),q("focusout","jz.blur"),b(document,"change",e=>{const t=ie(e);t&&(P("jz.change",{target:t}),C("hesitation",t))});for(const e of["popstate","hashchange"])b(window,e,X);let G=false;const se=()=>{if(k||G)return;G=true;const e=[...a?.signals??[],...g];if(e.length===0)return;const t=(a?.dropped??0)+d,i=S(e,Math.min(Ze(),Te));i.length>0&&Qe(o.endpoint,"RecordSignals",E(i,t),p)&&(a=void 0,g=[],d=e.length-i.length)},he=()=>{for(const e of[...T.values()])V(e);A=void 0},ge=()=>{he();for(const t of z.values())j(()=>w?.removePattern(t));z.clear(),K.clear();const e=w;w=void 0,j(()=>e?.destroy())};if(b(window,"pagehide",()=>{ge(),se()}),b(document,"visibilitychange",()=>{document.visibilityState==="hidden"?se():G=false}),b(window,"pageshow",e=>{G=false,!(!e.persisted||w)&&fe().then(t=>t&&j(ne))}),!await fe()){for(const e of N.splice(0))e();U?.disconnect(),oe?.disconnect();return}return j(ne),{contextChanged:()=>j(ne),stop(e){if(!k){he(),e||se(),k=true;for(const t of N.splice(0))t();M!==void 0&&clearInterval(M),c!==void 0&&clearTimeout(c),B!==void 0&&clearTimeout(B),U?.disconnect(),oe?.disconnect(),g=[],a=void 0,ge()}},idle:()=>v}}const St=new Set(["jz.click","jz.hover","jz.unhover","jz.focus","jz.blur","jz.change"]);function kt(o,n,s){if(!n.journeyId||!n.journeyStep)return;const f=o.publishedJourneys?.find(I=>I.journeyId===n.journeyId)?.stepIds;if(!f||f.length===0)return;const m=s&&s.journey===n.journeyId?s.index+1:0;let p=f.indexOf(n.journeyStep,m);return p<0&&(p=f.indexOf(n.journeyStep)),p>=0?{journey:n.journeyId,index:p,last:p===f.length-1}:void 0}function j(o){try{return o()}catch{return}}function bt(o,n){if(n==="event.kind")return o.kind.slice(3);const s=/^event\.fields\.([A-Za-z_][A-Za-z0-9_]{0,63})$/.exec(n);return s?o.fields[s[1]]:void 0}export{ut as ABANDON_MS,ft as CLOCK_MS,de as DEAD_CLICK_MS,ze as FLUSH_MS,be as HESITATION_MS,Ee as MAX_BATCH,Te as MAX_BATCH_BYTES,Ae as MAX_QUEUED,gt as MAX_QUEUED_BYTES,ht as MAX_TARGETS,jt as MAX_WINDOWS,mt as PAGE_CAP,It as RAGE_CLICKS,ke as RAGE_WINDOW_MS,dt as RULE_SET,pt as THROTTLE_MS,Me as hasFloor,kt as matchCheckpoint,yt as resolveTflo,Mt as startSignals,Oe as trackedId};
|
|
1
|
+
import{CONTEXT_ID_PATTERN as ye,CONTEXT_FIELDS as He}from"./contract.js";import{w as R}from"./loader-DHgG5Y7t.js";import{p as Ze,s as Qe,j as we,m as Ye,M as Je,r as et}from"./transport-Wrkorx6z.js";import{c as tt,C as _e}from"./consent-bPengyOI.js";const nt=/[A-Za-z0-9_]/,ot=/^[A-Za-z_]\w{0,63}$/,Z=o=>!!o&&nt.test(o),ae=o=>!!o&&o>="0"&&o<="9";function je(o,n,s){const f=typeof o==typeof s;return n==="=="?f&&o===s:n==="!="?!(f&&o===s):!f||typeof o=="boolean"?false:n==="<"?o<s:n==="<="?o<=s:n===">"?o>s:o>=s}function it(o){if(!(o?.length<=1024))return;let n=0,s=0,f=0;const m=()=>{for(;n<o.length&&o[n]<=" ";)n++},p=()=>{const a=n;for(;n<o.length&&Z(o[n]);)n++;if(o.slice(a,n)!=="event"||o[n]!==".")return;n++;const d=n;for(;n<o.length&&Z(o[n]);)n++;const c=o.slice(d,n);if(c==="kind")return[true,""];if(c!=="fields"||o[n]!==".")return;n++;const v=n;for(;n<o.length&&Z(o[n]);)n++;const h=o.slice(v,n);return ot.test(h)?[false,h]:void 0},I=a=>{let d="";for(n++;n<o.length;){const c=o[n];if(c===a)return n++,d;if(c==="\\"){const v=o[n+1];if(v===void 0||!`\\"'`.includes(v))return;d+=v,n+=2;continue}if(c<" ")return;d+=c,n++}},O=()=>{const a=n;o[n]==="-"&&n++;const d=n;for(;n<o.length&&ae(o[n]);)n++;if(n!==d){if(o[n]==="."){n++;const c=n;for(;n<o.length&&ae(o[n]);)n++;if(n===c)return}return Number(o.slice(a,n))}},L=()=>{const a=o[n];if(a==='"'||a==="'")return I(a);if(a==="-"||ae(a))return O();const d=n;for(;n<o.length&&Z(o[n]);)n++;const c=o.slice(d,n);return c==="true"?true:c==="false"?false:void 0},k=()=>{const a=o[n],d=o[n+1];if(a==="="&&d==="=")return n+=2,"==";if(a==="!"&&d==="=")return n+=2,"!=";if(a==="<"||a===">")return n+=d==="="?2:1,d==="="?a+"=":a},N=()=>{if(m(),o[n]==="("){if(++f>8)return;n++;const h=F();return m(),!h||o[n]!==")"?void 0:(n++,f--,h)}const a=o[n]==="e",d=a?p():L();if(d===void 0)return;m();const c=k();if(!c)return;if(m(),a){const h=L();if(h===void 0||++s>32)return;const E=d;return S=>je(E[0]?S.kind:S.fields[E[1]],c,h)}const v=p();if(v&&!(++s>32))return h=>je(d,c,v[0]?h.kind:h.fields[v[1]])},b=(a,d,c)=>{let v=a();if(v)for(;;){if(m(),o[n]!==d||o[n+1]!==d)return v;n+=2;const h=a();if(!h)return;const E=v;v=c?S=>E(S)&&h(S):S=>E(S)||h(S)}},g=()=>b(N,"&",true),F=()=>b(g,"|",false),$=F();return m(),$&&n===o.length?$:void 0}const Q="step_completed",st=["lt5s","lt15s","lt60s","lt5m","ge5m"],rt=[5e3,15e3,6e4,3e5];function at(o){const n=rt.findIndex(s=>o<s);return st[n<0?4:n]}function ct(o){let n,s=0,f=-1;return{sync(m,p){if(m!==n&&(n=m,s=o(),f=-1),!p||p.journey!==n||p.index<=f)return;const I=o(),O=at(I-s);return s=I,f=p.index,{journey:p.journey,step:p.step,duration_bucket:O}}}}const dt="jz-platform@2",ce={abandoned_step:{step:"int"},hesitation:{dwell_ms:"int"},rage_click:{clicks:"int"},dead_click:{},step_target_missing:{journey:"id",step:"int",rev:"int",tried:"id"},[Q]:{step:"id",journey:"id",duration_bucket:"id"}},Se=/^[a-z][a-z0-9_]{0,63}$/,Pe=/^[a-z0-9._:-]{1,96}$/,lt=/^[a-z0-9._:-]{1,64}$/,ke=700,It=3,be=3e3,de=1e3,ut=12e4,ft=1e3,pt=1e4,mt=300,ht=64,Ee=50,Te=32*1024,ze=5e3,Ae=200,gt=256*1024,Ie=(o,n)=>typeof o=="function"&&n.every(s=>typeof o.prototype?.[s]=="function");function Me(o){const n=o;return!!n&&Ie(n.TFloBrowser,["init","addPattern","removePattern","ingest","flush","destroy"])&&Ie(n.Pattern,["when","then","notThen","within","emit"])}const vt=()=>import("./index-B_nob8S0.js");async function yt(o,n=vt){if(o!==void 0)try{const s=typeof o=="function"?await o():o;if(Me(s))return s;R("signals.tflo lacks the TFloBrowser/Pattern surface; using the SDK's own")}catch{R("signals.tflo failed to load; using the SDK's own")}try{const s=await n();if(Me(s))return s}catch{}R("tflo failed to load; signals off")}const xe="[data-jz-mask],[data-jz-block],input,textarea,select,[contenteditable]:not([contenteditable='false'])";function Oe(o,n=[]){let s=o instanceof Element?o:o instanceof Node?o.parentElement:null;if(!s)return;const f=[xe,...n].join(",");try{if(s.closest(f))return}catch{if(s.closest(xe))return}const p=s.closest("[data-tflow-id]")?.getAttribute("data-tflow-id")??void 0;return p!==void 0&&Pe.test(p)?p:void 0}const wt=o=>Math.round(o/500)*500;function _t(){return crypto.randomUUID()}const jt=128;async function Mt(o){const n=o.site;if(n.signalsEnabled!==true)return;const s=o.options.signals??{},f=await yt(s.tflo,o.loadOwn);if(!f)return;const m=o.now??(()=>performance.now()),p=o.fetchImpl??((...e)=>fetch(...e)),I=o.newId??_t,O=o.options.maskSelectors??[],L=new Map;for(const e of n.siteSignals??[]){if(!Se.test(e.name)||e.name in ce||e.name.startsWith("jz_"))continue;const t={};for(const i of(e.params??[]).slice(0,8))t[i.name]=i.type==="string"?"id":i.type;L.set(e.name,t)}let k=false;const N=[],b=(e,t,i)=>{e.addEventListener(t,i,{capture:true,passive:true}),N.push(()=>e.removeEventListener(t,i,{capture:true}))};let g=[],F=0,$=0,a,d=0,c,v=Promise.resolve();const h=e=>{k||c!==void 0||(c=setTimeout(()=>{c=void 0,v=v.then(Ce)},e))},E=(e,t=0)=>({siteKey:o.options.siteKey,consentGiven:true,ruleSet:dt,signals:e,...t>0?{droppedAtUnload:t}:{}}),S=(e,t)=>{const i=[];for(const r of e){if(i.length>=Ee||we(E([...i,r]))>t)break;i.push(r)}return i},Ce=async()=>{let e=a;if(!e&&g.length>0){const t=S(g,Te);g=g.slice(t.length),e={signals:t,retries:0,firstAt:Date.now(),dropped:d},d=0}if(!(!e||e.signals.length===0)){a=void 0;try{await tt(o.endpoint,"RecordSignals",E(e.signals,e.dropped),p)}catch(t){const i=t instanceof _e?t.status:0,r=t instanceof _e?t.retryAfterMs:void 0;if(!k&&Ye(e.retries,i)&&Date.now()-e.firstAt<Je){a={...e,retries:e.retries+1},h(et(e.retries+1,r));return}}g.length>0&&h(g.length>=Ee?0:ze)}},De=(e,t)=>{if(!(k||$>=mt)){for($++,g.push({eventId:I(),seq:++F,...e}),g.length>Ae&&(g=g.slice(-Ae));g.length>1&&we(g)>gt;)g=g.slice(1);t?(c!==void 0&&clearTimeout(c),c=void 0,h(0)):h(ze)}},le=new Map,W=new Map,K=new Map,ue=typeof s.appVersion=="string"&&ye.test(s.appVersion)?s.appVersion:void 0,Re=()=>{const e=o.getContext(),t={};for(const i of He){const r=e[i];typeof r=="string"&&ye.test(r)&&(t[i]=r)}return ue&&(t.appVersion=ue),t},Le=(e,t)=>{if(e==="int"&&typeof t=="number"&&Number.isFinite(t))return{intValue:String(Math.trunc(t))};if(e==="double"&&typeof t=="number"&&Number.isFinite(t))return{doubleValue:t};if(e==="bool"&&typeof t=="boolean")return{boolValue:t};if(e==="id"&&typeof t=="string"&<.test(t))return{stringValue:t}},Y=e=>{const t=e.payload??{};if(t.__drop===true)return;const i=ce[e.name],r=i??L.get(e.name);if(!r)return;const l=typeof t.target=="string"&&Pe.test(t.target)?t.target:void 0;if(e.name==="rage_click"&&l){const x=K.get(l);queueMicrotask(()=>j(()=>x?.reset()))}const u=e.name===Q?`${e.name} ${String(t.journey)} ${String(t.step)}`:`${e.name} ${l??""}`,_=m(),y=le.get(u);if(y!==void 0&&_-y<pt){e.name==="rage_click"&&typeof t.clicks=="number"&&W.set(u,(W.get(u)??0)+t.clicks);return}le.set(u,_);const H={};let D=0;for(const[x,Ge]of Object.entries(r)){let re=t[x];x==="clicks"&&typeof re=="number"&&(re+=W.get(u)??0,W.delete(u));const ve=Le(Ge,re);ve&&D<8&&(H[x]=ve,D++)}e.name===Q&&D!==3||De({name:e.name,source:i?"SIGNAL_SOURCE_PLATFORM":"SIGNAL_SOURCE_SITE",context:Re(),...l?{target:l}:{},...D>0?{params:H}:{}},e.name==="abandoned_step")},J=f.Pattern;let w;const fe=async()=>{const e=new f.TFloBrowser({sinks:[{name:"journeeze",send:Y}],onSinkError:()=>{}});try{await e.init()}catch{return R("tflo failed to initialise; signals off"),false}return k?(e.destroy(),false):(w=e,Xe(e),true)},P=(e,t={})=>{!k&&w&&j(()=>w.ingest({kind:e,ts:m(),fields:t}))},ee=e=>e.kind==="jz.end",T=new Map;let Ne=0,M;const V=e=>{T.delete(e.name),j(()=>w?.removePattern(e.name))},te=(e,t,i,r,l,u)=>{if(!w)return;for(const x of T.values())if(x.key===t)return;T.size>=jt&&V(T.values().next().value);const _=++Ne,y=`${e}#${_}`,H=r(new J(y),_).within(i).emit(l),D=w.addPattern(H);T.set(y,{name:y,key:t,runtime:D,deadline:m()+i}),P("jz.window",{...u,w:_}),M??(M=setInterval($e,ft))};function $e(){const e=m();for(const t of[...T.values()]){if(t.deadline>e)continue;const i=j(()=>t.runtime.flush())??[];V(t);for(const r of i)Y(r)}T.size===0&&M!==void 0&&(clearInterval(M),M=void 0)}const C=(e,t)=>{for(const i of[...T.values()])i.name.startsWith(`${e}#`)&&(t===void 0||i.key===t)&&V(i)};let Ue=0;const z=new Map,Be=e=>{if(!w)return;const t=z.get(e);if(t){z.delete(e),z.set(e,t);return}if(z.size>=ht){const[u,_]=z.entries().next().value;j(()=>w?.removePattern(_)),z.delete(u),K.delete(u)}const i=u=>u.kind==="jz.click"&&u.fields.target===e,r=`rage_click#${++Ue}`,l=w.addPattern(new J(r).when(i).then(i).then(i).within(ke).emit(u=>u.last().ts-u.first().ts<=ke?{name:"rage_click",payload:{target:e,clicks:u.length}}:{name:"rage_click",payload:{__drop:true}}));z.set(e,r),K.set(e,l)},Fe=(e,t)=>te("hesitation",e,be,(i,r)=>i.when(l=>l.fields.w===r).notThen(l=>ee(l)||(l.kind==="jz.unhover"||l.kind==="jz.blur"||l.kind==="jz.click"||l.kind==="jz.change")&&l.fields.target===e),i=>({name:"hesitation",payload:{target:e,dwell_ms:Math.max(be,wt(m()-i.first().ts))}}),{target:e,kind:t}),We=e=>te("dead_click",e,de,(t,i)=>t.when(r=>r.fields.w===i).notThen(r=>ee(r)||r.kind==="jz.effect"),()=>({name:"dead_click",payload:{target:e}}),{target:e});let Ke=0;const pe=[];for(const e of s.rules??[]){if(!Se.test(e.name)||e.name in ce||e.name.startsWith("jz_")){R(`site rule ${e.name} refused (name)`);continue}const t=typeof e.when=="function"?e.when:it(e.when);if(!t){R(`site rule ${e.name} refused (outside the SDK's CEL subset)`);continue}pe.push({rule:e,pred:t})}const Ve=e=>St.has(e.kind);function Xe(e){for(const{rule:t,pred:i}of pe)e.addPattern(new J(`site:${t.name}#${++Ke}`).when(r=>Ve(r)&&j(()=>i({kind:r.kind.slice(3),ts:r.ts,fields:{target:r.fields.target}}))===true).emit(r=>{const l=r.first(),u={target:l.fields.target};for(const[_,y]of Object.entries(t.params??{}))_!=="target"&&(u[_]=bt(l,y));return{name:t.name,payload:u}}))}let A;const qe=ct(m),ne=()=>{const e=o.getContext();A&&e.journeyId!==A.journey&&(C("abandoned_step"),A=void 0);const t=kt(n,e,A),i=qe.sync(e.journeyId,t&&e.journeyStep?{journey:t.journey,index:t.index,step:e.journeyStep}:void 0);if(i&&Y({name:Q,payload:{...i}}),!t||A&&t.index<=A.index||(A&&P("jz.step",{journey:t.journey,index:t.index}),C("abandoned_step"),A=t,t.last))return;const{journey:r,index:l}=t;te("abandoned_step",r,ut,(u,_)=>u.when(y=>y.fields.w===_).notThen(y=>ee(y)||y.kind==="jz.step"&&y.fields.journey===r&&y.fields.index>l),()=>({name:"abandoned_step",payload:{step:l+1}}),{journey:r,index:l})};let me=0;const X=()=>{m()>me||(P("jz.effect"),C("dead_click"))},U=typeof MutationObserver=="function"?new MutationObserver(X):void 0;let B;const oe=typeof PerformanceObserver=="function"?j(()=>new PerformanceObserver(e=>e.getEntries().length>0&&X())):void 0;j(()=>oe?.observe({type:"resource"}));const ie=e=>Oe(e.composedPath?.()[0]??e.target,O);b(document,"click",e=>{const t=ie(e);t&&(Be(t),P("jz.click",{target:t}),C("hesitation",t),me=m()+de,U&&(U.observe(document.documentElement,{childList:true,attributes:true,subtree:true}),B!==void 0&&clearTimeout(B),B=setTimeout(()=>U.disconnect(),de)),We(t))});const q=(e,t)=>b(document,e,i=>{t==="jz.focus"&&X();const r=ie(i);r&&((t==="jz.hover"||t==="jz.unhover")&&Oe(i.relatedTarget,O)===r||(P(t,{target:r}),t==="jz.hover"||t==="jz.focus"?Fe(r,t):C("hesitation",r)))});q("pointerover","jz.hover"),q("pointerout","jz.unhover"),q("focusin","jz.focus"),q("focusout","jz.blur"),b(document,"change",e=>{const t=ie(e);t&&(P("jz.change",{target:t}),C("hesitation",t))});for(const e of["popstate","hashchange"])b(window,e,X);let G=false;const se=()=>{if(k||G)return;G=true;const e=[...a?.signals??[],...g];if(e.length===0)return;const t=(a?.dropped??0)+d,i=S(e,Math.min(Ze(),Te));i.length>0&&Qe(o.endpoint,"RecordSignals",E(i,t),p)&&(a=void 0,g=[],d=e.length-i.length)},he=()=>{for(const e of[...T.values()])V(e);A=void 0},ge=()=>{he();for(const t of z.values())j(()=>w?.removePattern(t));z.clear(),K.clear();const e=w;w=void 0,j(()=>e?.destroy())};if(b(window,"pagehide",()=>{ge(),se()}),b(document,"visibilitychange",()=>{document.visibilityState==="hidden"?se():G=false}),b(window,"pageshow",e=>{G=false,!(!e.persisted||w)&&fe().then(t=>t&&j(ne))}),!await fe()){for(const e of N.splice(0))e();U?.disconnect(),oe?.disconnect();return}return j(ne),{contextChanged:()=>j(ne),stop(e){if(!k){he(),e||se(),k=true;for(const t of N.splice(0))t();M!==void 0&&clearInterval(M),c!==void 0&&clearTimeout(c),B!==void 0&&clearTimeout(B),U?.disconnect(),oe?.disconnect(),g=[],a=void 0,ge()}},idle:()=>v}}const St=new Set(["jz.click","jz.hover","jz.unhover","jz.focus","jz.blur","jz.change"]);function kt(o,n,s){if(!n.journeyId||!n.journeyStep)return;const f=o.publishedJourneys?.find(I=>I.journeyId===n.journeyId)?.stepIds;if(!f||f.length===0)return;const m=s&&s.journey===n.journeyId?s.index+1:0;let p=f.indexOf(n.journeyStep,m);return p<0&&(p=f.indexOf(n.journeyStep)),p>=0?{journey:n.journeyId,index:p,last:p===f.length-1}:void 0}function j(o){try{return o()}catch{return}}function bt(o,n){if(n==="event.kind")return o.kind.slice(3);const s=/^event\.fields\.([A-Za-z_][A-Za-z0-9_]{0,63})$/.exec(n);return s?o.fields[s[1]]:void 0}export{ut as ABANDON_MS,ft as CLOCK_MS,de as DEAD_CLICK_MS,ze as FLUSH_MS,be as HESITATION_MS,Ee as MAX_BATCH,Te as MAX_BATCH_BYTES,Ae as MAX_QUEUED,gt as MAX_QUEUED_BYTES,ht as MAX_TARGETS,jt as MAX_WINDOWS,mt as PAGE_CAP,It as RAGE_CLICKS,ke as RAGE_WINDOW_MS,dt as RULE_SET,pt as THROTTLE_MS,Me as hasFloor,kt as matchCheckpoint,yt as resolveTflo,Mt as startSignals,Oe as trackedId};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as P,c as W,C as Y}from"./consent-bPengyOI.js";import{p as J,j as T,s as q,M as Q,m as z,r as Z}from"./transport-Wrkorx6z.js";function ee(n,u=globalThis.navigator){return n.respectGlobalPrivacyControl!==false&&u?.globalPrivacyControl===true}const M=50,x=32*1024,te=5e3,ne=1e3,ie=1e4,$=200,re=256*1024,f="HELP_EVENT_";function C(n,u){return n.version?{journeyId:n.journeyId,stepIndex:u,guideVersion:n.version}:{journeyId:n.journeyId,stepIndex:u}}const L=new Set([`${f}GUIDE_ABANDONED`,`${f}JOB_OUTCOME`]);function oe(n){return Math.min(Math.max(n??te,ne),ie)}function se(){return crypto.randomUUID()}function le(n){if(ee(n))return{checkin:()=>{},job:()=>{},stop:()=>{}};const u=n.fetchImpl??fetch,m=oe(n.flushMs),B=n.random??Math.random,k=n.newId??se;let t=[],o,s,l=false,y=false,_=0,g=0,r,A,N=false,j;const v=e=>{l||s||(s=setTimeout(()=>{s=void 0,D()},e))},K=()=>{for(t.length>$&&(t=t.slice(-$));t.length>0&&T(t)>re;)t=t.slice(1)},h=e=>{l||(_=_+1>>>0||1,t.push({...e,eventId:k(),seq:_}),K(),L.has(e.event)?(s&&clearTimeout(s),s=void 0,D()):v(m))},G=()=>{if(o)return o;if(t.length===0)return;const e=[];for(const i of t){if(e.length===M||e.length>0&&T([...e,i])>x)break;e.push(i)}return t=t.slice(e.length),{events:e,firstAttempt:Date.now(),retries:0}},b=e=>{const i={siteKey:n.siteKey,consentGiven:true,events:e};g>0&&(i.droppedAtUnload=g);const c=n.claims?.();return c&&(i.claims=c),i},D=async()=>{if(y||l)return;if(!P(n.siteKey)){t=[],o=void 0;return}if(typeof navigator<"u"&&navigator.onLine===false)return;const e=G();if(!e)return;if(o=void 0,Date.now()-e.firstAttempt>Q){t.length>0&&v(m);return}y=true;const i=g;try{await W(n.endpoint,"RecordHelpEvents",b(e.events),u),g-=i}catch(c){const d=c instanceof Y?c:void 0,a=d?.status??0;if(d?.code==="failed_precondition")l=true,t=[];else if(z(e.retries,a)){e.retries+=1,o=e,y=false,v(Z(e.retries,d?.retryAfterMs,B));return}}finally{y=false}!l&&(t.length>0||o)&&v(t.length>=M?0:m)},H=()=>{if(l&&t.length===0&&!o||(s&&clearTimeout(s),s=void 0,!P(n.siteKey)))return;const e=[...o?.events??[],...t];if(e.length===0)return;const i=[...e.filter(a=>L.has(a.event)),...e.filter(a=>!L.has(a.event))],c=Math.min(J(),x),d=[];for(const a of i){if(d.length===M||T(b([...d,a]))>c)break;d.push(a)}d.length!==0&&q(n.endpoint,"RecordHelpEvents",b(d),u)&&(g+=e.length-d.length,t=[],o=void 0)};let w=false;const I=()=>{w||(w=true,H())},R=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&I()},p=()=>{typeof document<"u"&&document.visibilityState!=="visible"||(w=false,(t.length>0||o)&&v(0))},U=()=>{(t.length>0||o)&&v(0)},S=()=>{r&&!r.done&&r.last!==void 0&&h({event:`${f}GUIDE_ABANDONED`,...C(r.guide,r.last)}),r=void 0,A=void 0},X=e=>{const i=j;if(j=e,i===void 0)return;if(e.view==="disabled"){l=true,t=[];return}i.view==="closed"&&(e.view==="index"||e.view==="guide")&&h({event:`${f}HELP_OPENED`,entry:e.view==="index"?"HELP_ENTRY_LAUNCHER":"HELP_ENTRY_API"});const c=e.view==="guide"||e.view==="finished"?e.guide:void 0,d=e.view==="guide"?e.journeyId:c?.journeyId;if(r&&d!==r.guide.journeyId&&S(),e.view==="guide"&&e.status==="ready"&&e.guide){r||(r={guide:e.guide,seen:new Set,done:false});const E=e.guide.steps[e.step],O=E&&`${e.guide.journeyId}/${e.step}`;E&&O!==A&&(A=O,r.last=E.index,h({event:`${f}${r.seen.has(E.index)?"STEP_REPEATED":"STEP_REACHED"}`,...C(e.guide,E.index)}),r.seen.add(E.index))}else e.view==="finished"&&r&&(r.done=true,S());const a=e.view==="index"&&e.status==="ready"&&e.query.trim()!==""&&e.results.length===0;a&&!N&&h({event:`${f}SEARCH_NO_RESULT`}),N=a},F=n.subscribe(X);addEventListener("pagehide",I),addEventListener("visibilitychange",R),addEventListener("visibilitychange",p),addEventListener("pageshow",p),addEventListener("online",U);const V=()=>{removeEventListener("pagehide",I),removeEventListener("visibilitychange",R),removeEventListener("visibilitychange",p),removeEventListener("pageshow",p),removeEventListener("online",U)};return{checkin(e){h({event:`${f}CHECKIN_ANSWERED`,...C(e.guide,e.step.index),answer:e.answer==="confused"?"CHECKIN_ANSWER_CONFUSED":"CHECKIN_ANSWER_UNDERSTOOD"})},job(e){const i={event:`${f}JOB_${e.event}`,jobId:e.jobId};e.jobVersion&&(i.jobVersion=e.jobVersion),e.persona&&(i.persona=e.persona),e.event==="OUTCOME"&&(i.jobAnswer=`JOB_ANSWER_${e.answer}`,e.harder!==void 0&&(i.harderThanExpected=e.harder)),h(i)},stop(e){if(F(),V(),!l){if(e){t=[],o=void 0,s&&clearTimeout(s),s=void 0,l=true;return}S(),l=true,H()}}}}export{te as FLUSH_MS,M as MAX_BATCH,x as MAX_BATCH_BYTES,ie as MAX_FLUSH_MS,$ as MAX_QUEUED,re as MAX_QUEUED_BYTES,ne as MIN_FLUSH_MS,ee as gpcRefusesTelemetry,le as startTelemetry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,T as d,R as f}from"./consent-
|
|
1
|
+
import{r as l,T as d,R as f}from"./consent-bPengyOI.js";const E=1e3,p=5,y=3,S=55*6e4;function h(e){return e===0||e===408||e===429||e===500||e===502||e===503||e===504}function _(e,n){return h(n)&&e<(n===0?y:p)}function T(e,n,o=Math.random){const t=Math.min(E*2**Math.max(e-1,0),f)*(.5+o());return Math.round(Math.max(Math.min(t,f),n??0))}const m=32*1024;function v(){try{return typeof Request<"u"&&"keepalive"in new Request("https://journeeze.invalid/",{method:"POST",keepalive:true})}catch{return false}}let r=0,u=false;function R(){if(u||typeof addEventListener!="function")return;u=true;const e=()=>{(typeof document>"u"||document.visibilityState==="visible")&&(r=0)};addEventListener("pageshow",e),addEventListener("visibilitychange",e)}function g(){return R(),Math.max(m-r,0)}function A(e,n,o,a=fetch){const t=JSON.stringify(o),i=new TextEncoder().encode(t).length;if(i>g())return false;const c=l(e,n);if(v()){r+=i;try{return a(c,{method:"POST",headers:{"content-type":d},body:t,keepalive:true,credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer"}).catch(()=>{}),true}catch{return false}}if(typeof navigator>"u"||typeof navigator.sendBeacon!="function")return false;const s=navigator.sendBeacon(c,new Blob([t],{type:d}));return s&&(r+=i),s}function b(e){return new TextEncoder().encode(JSON.stringify(e)).length}export{S as M,b as j,_ as m,g as p,T as r,A as s};
|
|
@@ -11,6 +11,8 @@ export interface PlusHost {
|
|
|
11
11
|
root: ShadowRoot;
|
|
12
12
|
options: MountOptions;
|
|
13
13
|
endpoint: string;
|
|
14
|
+
/** Signed claims v2 (contract §15): the chat's token source, if any. */
|
|
15
|
+
claims?: (() => Promise<string | undefined>) | undefined;
|
|
14
16
|
/** The chat's one `GetWidgetConfig` read (the site's mask selectors); rejects when it failed. */
|
|
15
17
|
config(): Promise<GetWidgetConfigResponse>;
|
|
16
18
|
/** Hides the chat while capturing or pointing; the result brings it back. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MountedWidget, MountOptions, WidgetModule } from "../../loader";
|
|
2
|
-
import type { HelpJobEntry, JourneezeContext } from "../../types";
|
|
2
|
+
import type { GetGuideResponse, HelpJobEntry, JourneezeContext } from "../../types";
|
|
3
3
|
import type { ConverseTransport, PlusItem } from "./converse";
|
|
4
4
|
import { type Copy } from "./copy";
|
|
5
5
|
import { type Chip, type ReportFacts } from "./model";
|
|
@@ -18,10 +18,12 @@ export interface ChatDeps {
|
|
|
18
18
|
loadJobs?: () => Promise<HelpJobEntry[]>;
|
|
19
19
|
/** A "+" menu item was chosen; default: the lazy capture chunk (`../capture/attach`). */
|
|
20
20
|
onPlusItem?: (item: PlusItem) => void;
|
|
21
|
+
/** Reads a guide's steps and targets for the in-page outline; default `GetGuide`. */
|
|
22
|
+
loadGuide?: (journeyId: string) => Promise<GetGuideResponse>;
|
|
21
23
|
}
|
|
22
24
|
/** The page facts a turn's context is built from (feedback/v2 `context`). */
|
|
23
25
|
export declare function pageFacts(options: MountOptions, ctx: Readonly<JourneezeContext>): ReportFacts;
|
|
24
26
|
/** The opening chips, badged with the site's `widget.ui.chip.*` copy. */
|
|
25
|
-
export declare function jobChips(jobs: readonly HelpJobEntry[], t: Copy): Chip[];
|
|
27
|
+
export declare function jobChips(jobs: readonly HelpJobEntry[], t: Copy, persona?: string): Chip[];
|
|
26
28
|
export declare function mountChat(options: MountOptions, getContext: () => Readonly<JourneezeContext>, deps?: ChatDeps): MountedChat;
|
|
27
29
|
export declare const mount: WidgetModule["mount"];
|
|
@@ -64,6 +64,8 @@ export interface ConverseRequest {
|
|
|
64
64
|
userId?: string;
|
|
65
65
|
userIdExp?: number;
|
|
66
66
|
userIdSig?: string;
|
|
67
|
+
/** Signed claims v2 (sdk-v1 contract §15), when the host supplies one. */
|
|
68
|
+
claims?: string;
|
|
67
69
|
overMasked?: OverMaskCount[];
|
|
68
70
|
}
|
|
69
71
|
export interface ConverseResponse {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HelpJobEntry } from "../../types";
|
|
2
|
+
/** The guide `Converse` plays for `job`: the job's own, else `persona`'s; none: no guide yet. */
|
|
3
|
+
export declare function guideFor(job: HelpJobEntry, persona: string | undefined): {
|
|
4
|
+
journeyId: string;
|
|
5
|
+
stepCount: number;
|
|
6
|
+
} | undefined;
|
|
7
|
+
/** Where the conversation is in a guide: 1-based `step`, and the step count the server sent. */
|
|
8
|
+
export interface GuidePosition {
|
|
9
|
+
jobId: string;
|
|
10
|
+
step: number;
|
|
11
|
+
of?: number | undefined;
|
|
12
|
+
}
|
|
@@ -100,6 +100,12 @@ export declare class ChatSession {
|
|
|
100
100
|
close(): void;
|
|
101
101
|
/** Opening the chat again after a close starts a new conversation (consent is kept). */
|
|
102
102
|
reopen(): void;
|
|
103
|
+
/** The guide step the conversation is on (1-based), while it is on one and open; else none. */
|
|
104
|
+
guidePosition(): {
|
|
105
|
+
jobId: string;
|
|
106
|
+
step: number;
|
|
107
|
+
of?: number | undefined;
|
|
108
|
+
} | undefined;
|
|
103
109
|
offers(type: ConverseAction["type"]): boolean;
|
|
104
110
|
/** The server's label of an action on offer ("" when it is not offered or has none). */
|
|
105
111
|
label(type: ConverseAction["type"]): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { GetGuideResponse } from "../../types";
|
|
2
|
+
import { type AnchorResult, type StepTarget } from "../../help/core/highlight";
|
|
3
|
+
import type { GuidePosition } from "./guide";
|
|
4
|
+
/** A guide's steps in order, each as its targets (unknown strategies dropped; a lone tflo id when none). */
|
|
5
|
+
export declare function guideTargets(g: GetGuideResponse): StepTarget[][];
|
|
6
|
+
export interface WalkerDeps {
|
|
7
|
+
/** The guide played for a job (from the opening job list), or `undefined`. */
|
|
8
|
+
journeyFor(jobId: string): string | undefined;
|
|
9
|
+
loadGuide(journeyId: string): Promise<GetGuideResponse>;
|
|
10
|
+
highlight(targets: readonly StepTarget[] | undefined): AnchorResult | Promise<AnchorResult>;
|
|
11
|
+
clearHighlight(): void;
|
|
12
|
+
}
|
|
13
|
+
/** Keeps the page outline on the conversation's current guide step. Never throws. */
|
|
14
|
+
export declare class GuideWalker {
|
|
15
|
+
private readonly deps;
|
|
16
|
+
private readonly guides;
|
|
17
|
+
private at;
|
|
18
|
+
/** Bumped on every move, so a guide that loads late never outlines a step already left. */
|
|
19
|
+
private seq;
|
|
20
|
+
/** What the last outline was for (`journeyId/step`), to skip redundant work on re-renders. */
|
|
21
|
+
private shown;
|
|
22
|
+
constructor(deps: WalkerDeps);
|
|
23
|
+
/** The conversation moved (or left the guide: `undefined`). */
|
|
24
|
+
sync(pos: GuidePosition | undefined): void;
|
|
25
|
+
/** The host's route or layout changed: find the current step's element again. */
|
|
26
|
+
refresh(): void;
|
|
27
|
+
stop(): void;
|
|
28
|
+
private point;
|
|
29
|
+
private guide;
|
|
30
|
+
}
|
|
31
|
+
export interface WalkOptions {
|
|
32
|
+
endpoint: string;
|
|
33
|
+
siteKey: string;
|
|
34
|
+
reviewerToken?: string | undefined;
|
|
35
|
+
claims?: (() => Promise<string | undefined>) | undefined;
|
|
36
|
+
/** The chat's shadow root: the outline is drawn there (captures drop it with the chat). */
|
|
37
|
+
root: ShadowRoot;
|
|
38
|
+
/** The host's CSP nonce for the injected style. */
|
|
39
|
+
nonce?: string | undefined;
|
|
40
|
+
journeyFor(jobId: string): string | undefined;
|
|
41
|
+
/** Test seam; default `GetGuide`. */
|
|
42
|
+
loadGuide?: ((journeyId: string) => Promise<GetGuideResponse>) | undefined;
|
|
43
|
+
}
|
|
44
|
+
/** The walker over the chat's shadow root, with its highlighter. `dispose()` removes the outline. */
|
|
45
|
+
export declare function createWalk(o: WalkOptions): {
|
|
46
|
+
walker: GuideWalker;
|
|
47
|
+
dispose(): void;
|
|
48
|
+
};
|
|
49
|
+
export type Walk = ReturnType<typeof createWalk>;
|
|
@@ -2,4 +2,4 @@ import type { MountOptions } from "../loader";
|
|
|
2
2
|
import { type ConverseTransport } from "./shell/converse";
|
|
3
3
|
/** {@link converseTransport} with the caller's identity on each turn, read live from the mount
|
|
4
4
|
* options (`setUser` can change the id). */
|
|
5
|
-
export declare function liveTransport(endpoint: string, options: MountOptions, fetchImpl?: typeof fetch): ConverseTransport;
|
|
5
|
+
export declare function liveTransport(endpoint: string, options: MountOptions, fetchImpl?: typeof fetch, claims?: () => Promise<string | undefined>): ConverseTransport;
|