@journeeze/sdk 0.1.0-rc.4 → 0.2.0
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 +13 -1
- package/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +22 -20
- package/dist/anchor-BhsfeHwL.js +1 -0
- package/dist/attach-D451Wj4h.js +21 -0
- package/dist/chat-ByOXN5k1.js +64 -0
- package/dist/claims-BfpRuIu-.js +1 -0
- package/dist/consent-BupCs23W.js +1 -0
- package/dist/contract.js +1 -1
- package/dist/feedback-DtMDnAam.js +1 -0
- package/dist/help-D_T0HiNa.js +106 -0
- package/dist/{hook-DGWypoEO.js → hook-BRnJ-lTk.js} +1 -1
- package/dist/index.js +6 -8
- package/dist/loader-k4pePzAw.js +127 -0
- package/dist/mask-audit-DtKNgOlT.js +5 -0
- package/dist/react.js +1 -1
- package/dist/resolve-7jVqhJhi.js +1 -0
- package/dist/script.js +1 -1
- package/dist/{signals-amjMQyOy.js → signals-eaZX2lNd.js} +1 -1
- package/dist/telemetry-DMGFJcw3.js +1 -0
- package/dist/{transport-B64CfIcF.js → transport-DokImbgl.js} +1 -1
- package/dist/types/chat/capture/attach.d.ts +2 -0
- package/dist/types/chat/shell/converse.d.ts +2 -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-DkAWrJhn.js} +6 -6
- package/dist/widget-CcAalO4B.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,106 @@
|
|
|
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 j=(n,e,t)=>ee(n,typeof e!="symbol"?e+"":e,t);import{s as te,F as G,R as ne}from"./hook-BRnJ-lTk.js";import{d as Q}from"./anchor-BhsfeHwL.js";import{k as ie,C as se,l as $,c as X,s as J,d as re,D as oe,i as ae,h as de,f as ce,e as le}from"./consent-BupCs23W.js";import{T as ue}from"./loader-k4pePzAw.js";const he=6e4;class pe{constructor(e){j(this,"opts");j(this,"indexEntry");j(this,"guides",new Map);j(this,"inflight",new Map);j(this,"now");j(this,"freshMs");this.opts=e,this.now=e.now??Date.now,this.freshMs=e.freshMs??6e4}index(){return this.read("index","GetHelpIndex",{},()=>this.indexEntry,e=>this.indexEntry=e,()=>false)}guide(e){return this.read(`guide:${e}`,"GetGuide",{journeyId:e},()=>this.guides.get(e),t=>this.guides.set(e,t),t=>{const s=t.linksExpireAt?Date.parse(t.linksExpireAt):NaN;return Number.isFinite(s)&&s-this.now()<he})}body(e,t){const s=this.opts.reviewerToken;return{siteKey:this.opts.siteKey,...e,...s&&{reviewerToken:s},...t&&{claims:t}}}read(e,t,s,i,o,c){const u=this.opts.claims;return u?u().then(g=>this.readWith(e,t,s,g,i,o,c)):this.readWith(e,t,s,void 0,i,o,c)}readWith(e,t,s,i,o,c,u){const g=o(),x=g&&g.claims===i?g:void 0;if(x&&this.now()-x.at<this.freshMs&&!u(x.value))return Promise.resolve(x.value);const T=`${e}
|
|
2
|
+
${i??""}`,F=this.inflight.get(T);if(F)return F;const q=x&&!u(x.value)?x.etag:void 0,a=ie(this.opts.endpoint,t,this.body(s,i),q,this.opts.fetchImpl).then(h=>{if(h.notModified){if(!x)throw new Error("304 without a cached value");return c({...x,at:this.now()}),x.value}return c({value:h.value,etag:h.etag,at:this.now(),claims:i}),h.value}).finally(()=>this.inflight.delete(T));return this.inflight.set(T,a),a}}const L=n=>n.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^\p{L}\p{N}]+/u).filter(Boolean);function _(n,e){const t=L(e);if(t.length===0)return[...n];const s=[];return n.forEach((i,o)=>{const c=L(i.title??""),u=L(i.goal??""),g=(i.stepTitles??[]).flatMap(L);let x=0;for(const T of t){const F=a=>a.some(h=>h.startsWith(T)),q=F(c)?3:F(u)?2:F(g)?1:0;if(q===0)return;x+=q}s.push([i,x,o])}),s.sort((i,o)=>o[1]-i[1]||i[2]-o[2]).map(([i])=>i)}const ge=4e3;function B(n){return n instanceof se&&n.code==="failed_precondition"}class fe{constructor(e){j(this,"deps");j(this,"current",{view:"closed"});j(this,"listeners",new Set);j(this,"entries",[]);j(this,"generation",0);j(this,"asked",new Set);j(this,"pending");j(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=>{B(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(o=>o.journeyId);const s=this.current.view==="index"?this.current.query:"",i=(t.jobs??[]).filter(o=>o.jobId&&o.title);this.set({view:"index",status:"ready",query:s,results:_(this.entries,s),total:this.entries.length,jobs:i})},t=>{if(e!==this.generation)return;if(B(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"?_(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=ve(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(B(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||D(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>ge)return;const i=this.current;i.view==="index"&&!D(i.signal)?this.signal(t?{kind:"request",text:s,jobRequest:t}:{kind:"request",text:s}):i.view==="guide"&&i.status==="ready"&&i.guide&&!D(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 o;try{o=await this.deps.sendCheckin({guide:t.guide,step:s,answer:e})}catch{o="dropped"}if(i!==this.generation)return;const c=this.current;c.view==="guide"&&(this.set({...c,checkin:"idle"}),this.advance(o))}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 o=this.current;o.view==="guide"&&o.guide===e&&o.step===t&&o.anchor!==i&&this.set({...o,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 ve(n,e,t){const s=(n.steps??[]).map((i,o)=>({index:i.index??o,title:i.title??"",instruction:i.instruction??"",tflowId:i.tflowId||void 0,targets:xe(i),stepRef:i.stepRef||void 0,screenshotUrl:$(t,i.screenshotUrl),videoStartMs:i.videoStartMs,videoEndMs:i.videoEndMs})).sort((i,o)=>i.index-o.index);return{journeyId:n.journeyId??e,slug:n.slug??"",title:n.title??"",goal:n.goal??"",steps:s,videoUrl:$(t,n.videoUrl),captionsUrl:$(t,n.captionsUrl),version:n.contentVersion||void 0}}function D(n){return n==="needs-consent"||n==="sending"}const be=/^(tflow|testId|role|css)$/;function xe(n){const e=(n.targets??[]).filter(t=>be.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}]}const we=()=>import("./resolve-7jVqhJhi.js");function me(n,e=document){if(ue.test(n))for(const t of e.querySelectorAll(`[data-tflow-id="${n}"]`)){const s=t.getBoundingClientRect();if(s.width>0||s.height>0)return t}}function ye(n=window){try{return n.matchMedia?.("(prefers-reduced-motion: reduce)").matches??false}catch{return false}}class ke{constructor(e,t=window,s=we){j(this,"win");j(this,"load");j(this,"target");j(this,"box");j(this,"onMove",()=>this.place());j(this,"seq",0);this.win=t,this.load=s,this.box=t.document.createElement("div"),this.box.className="jz-help-highlight",this.box.setAttribute("aria-hidden","true"),this.box.hidden=true,e.append(this.box)}show(e){this.hide();const t=this.seq,[s]=e??[];return s?e?.length===1&&s.by==="tflow"?this.outline(me(s.value,this.win.document)):this.load().then(i=>t===this.seq?this.outline(i.resolveTarget(e??[],this.win.document)):"none",()=>"missing"):"none"}outline(e){return e?(this.target=e,e.scrollIntoView?.({block:"center",inline:"nearest",behavior:ye(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 e=this.target.getBoundingClientRect();Object.assign(this.box.style,{left:`${e.left-4}px`,top:`${e.top-4}px`,width:`${e.width+8}px`,height:`${e.height+8}px`})}}function je(n,e,t,s){let i;return{start(){i??(i=import("./telemetry-DMGFJcw3.js").then(o=>o.startTelemetry({endpoint:n,siteKey:e,subscribe:c=>t.subscribe(c),claims:s}),()=>{i=void 0}))},checkin:o=>{i?.then(c=>c?.checkin(o))},job:o=>{i?.then(c=>c?.job(o))},stop:o=>{i?.then(c=>c?.stop(o))}}}const Ke=`
|
|
3
|
+
:host { all: initial; }
|
|
4
|
+
.launcher { position:fixed; left:24px; bottom:24px; z-index:2147483646; width:44px; height:44px; border-radius:22px;
|
|
5
|
+
border:1px solid #1D2024; background:#1D2024; color:#FFFFFF; font:600 18px/1 system-ui,sans-serif; cursor:pointer; }
|
|
6
|
+
.panel { position:fixed; left:24px; bottom:80px; z-index:2147483646; width:min(340px, calc(100vw - 48px));
|
|
7
|
+
max-height:min(70vh, 560px); overflow:auto; box-sizing:border-box; padding:16px; border:1px solid rgb(29 32 36/12%);
|
|
8
|
+
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%); }
|
|
9
|
+
.panel h2 { font-size:15px; margin:0 0 8px; }
|
|
10
|
+
.panel p { margin:0 0 8px; }
|
|
11
|
+
.panel ul { list-style:none; padding:0; margin:8px 0 0; }
|
|
12
|
+
.panel li button { display:block; width:100%; text-align:left; padding:8px; margin:0 0 4px; border:1px solid rgb(29 32 36/12%);
|
|
13
|
+
border-radius:6px; background:#FFFFFF; color:inherit; font:inherit; cursor:pointer; }
|
|
14
|
+
.panel input { width:100%; box-sizing:border-box; padding:8px; border:1px solid rgb(29 32 36/24%); border-radius:6px; font:inherit; }
|
|
15
|
+
.panel .row { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
|
|
16
|
+
.panel .row button { padding:6px 12px; border:1px solid #1D2024; border-radius:6px; background:#FFFFFF; color:#1D2024; font:inherit; cursor:pointer; }
|
|
17
|
+
.panel .muted { color:#5D636B; font-size:13px; }
|
|
18
|
+
.panel img { max-width:100%; border:1px solid rgb(29 32 36/12%); border-radius:6px; }
|
|
19
|
+
:focus-visible { outline:2px solid #3D63C9; outline-offset:2px; }
|
|
20
|
+
.jz-help-highlight { position:fixed; z-index:2147483645; pointer-events:none; box-sizing:border-box;
|
|
21
|
+
border:2px solid #3D63C9; border-radius:6px; box-shadow:0 0 0 4px rgb(61 99 201/20%); }
|
|
22
|
+
`;function p(n,e={},...t){const s=document.createElement(n);for(const[i,o]of Object.entries(e))s.setAttribute(i,o);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."},ze=(n,e,t)=>{const s=p("button",{type:"button",class:"launcher","aria-label":"Help","aria-expanded":"false","aria-controls":"jz-help-panel"},"?"),i=p("div",{id:"jz-help-panel",class:"panel",role:"dialog","aria-modal":"false","aria-label":"Help"});i.hidden=true,n.append(s,i);let o="",c=false,u;s.addEventListener("click",()=>e.state.view==="closed"?e.open():e.close()),i.addEventListener("keydown",a=>{a.key==="Escape"&&(a.stopPropagation(),e.close())});const g=(a,h,v={})=>{const E=p("button",{type:"button",...v},a);return E.addEventListener("click",h),E};function x(a){const h=n.activeElement,v=h!==null&&i.contains(h),E=v?h.id:"";s.hidden=a.view==="disabled";const m=a.view!=="closed"&&a.view!=="disabled";if(s.setAttribute("aria-expanded",String(m)),i.hidden=!m,a.view==="index"&&u&&i.contains(u.input)){F(a),v&&h&&!h.isConnected&&(E&&n.getElementById(E)||u.input).focus(),c=m;return}if(u=void 0,i.replaceChildren(...(m?T(a):[]).filter(k=>!!k)),m&&(!c||v)){const z=(E?n.getElementById(E):null)??i.querySelector("input, [role=group] button, button");z?.focus(),z instanceof HTMLInputElement&&z.setSelectionRange(z.value.length,z.value.length)}!m&&c&&s.focus(),c=m}function T(a){if(a.view==="index"){const k=p("input",{id:"jz-help-search",type:"search","aria-label":"Search help",placeholder:"How do I…",autocomplete:"off"});return k.value=a.query,k.addEventListener("input",()=>e.search(k.value)),u={input:k,status:p("p",{class:"muted",role:"status"}),retry:p("div",{class:"row"},g("Try again",()=>e.open())),list:p("ul",{"aria-label":"Guides"})},F(a),[p("h2",{},"How do I…"),k,u.status,u.retry,u.list,p("div",{class:"row"},g("Close",()=>e.close()))]}if(a.view==="finished")return[p("h2",{},`You finished “${a.guide.title}”`),a.notice&&p("p",{class:"muted",role:"status"},K[a.notice]??""),p("div",{class:"row"},g("More guides",()=>e.open(),{id:"jz-help-more"}),g("Back",()=>e.back()),g("Close",()=>e.close()))];if(a.view!=="guide")return[];if(a.status!=="ready"||!a.guide)return[p("p",{role:"status"},a.status==="loading"?"Loading guide…":"This guide isn't available right now."),p("div",{class:"row"},g("Back",()=>e.open()),g("Close",()=>e.close()))];const h=a.guide,v=h.steps[a.step];if(!v)return[];const E=a.step+1===h.steps.length,m=[p("h2",{},h.title),p("p",{class:"muted"},`Step ${a.step+1} of ${h.steps.length}`),p("p",{},p("strong",{},v.title)),v.instruction&&p("p",{},v.instruction),a.anchor==="missing"&&p("p",{class:"muted"},"The part of the page this step uses isn't shown here. Follow the steps in the text."),v.screenshotUrl&&p("img",{referrerpolicy:"no-referrer",src:v.screenshotUrl,alt:`Screenshot for: ${v.title}`,loading:"lazy"}),a.notice&&p("p",{class:"muted",role:"status"},K[a.notice]??"")];if(a.checkin==="asking")m.push(p("div",{role:"group","aria-label":"Step check-in"},p("p",{},"Did this step make sense?"),p("div",{class:"row"},g("Understood",()=>e.answer("understood"),{id:"jz-help-yes"}),g("Confused",()=>e.answer("confused")),g("Skip",()=>e.skipCheckin()))));else if(a.checkin==="needs-consent"){const k=p("p",{},o||"Loading…");o||t.consentText().then(z=>{o=z,k.textContent=z}),m.push(p("div",{role:"group","aria-label":"Consent"},k,p("div",{class:"row"},g("Allow and send",()=>e.giveConsent(),{id:"jz-help-allow"}),g("Not now",()=>e.declineConsent()))))}else a.checkin==="sending"?m.push(p("p",{role:"status"},"Sending…")):m.push(p("div",{class:"row"},g("Back",()=>e.back()),g(E?"Finish":"Next",()=>e.next(),{id:"jz-help-next"}),g("Close",()=>e.close())));return m}function F(a){if(!u)return;const{input:h,status:v,retry:E,list:m}=u;h.value!==a.query&&n.activeElement!==h&&(h.value=a.query),v.textContent=a.status==="loading"?"Loading guides…":a.status==="error"?"Help isn't available right now.":a.results.length===0?a.query?`No guide matches “${a.query}”.`:"No guides yet.":"",v.hidden=v.textContent==="",E.hidden=a.status!=="error",m.replaceChildren(...a.results.map((k,z)=>p("li",{},g(k.title||"Untitled guide",()=>e.openGuide(k.journeyId??""),{id:`jz-help-g${z}`}),k.goal?p("p",{class:"muted"},k.goal):void 0)))}const q=e.subscribe(x);return{destroy(){q(),s.remove(),i.remove()}}},W="http://www.w3.org/2000/svg",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";function Se(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}function Ee(n,e){const t=document.createElement("button");return t.type="button",t.id="jz-help-callout",t.className="callout-btn",t.append(Se(Ce),document.createTextNode("This is confusing")),t.addEventListener("click",()=>n.sendCallout(e)),t}function Ie(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 o=document.createElement("button");return o.type="submit",o.id="jz-help-request-send",o.textContent="Send request",t.append(s,i,o),t.addEventListener("submit",c=>{c.preventDefault(),n.sendRequest(i.value)}),t}function d(n,e={},...t){const s=document.createElement(n);for(const[i,o]of Object.entries(e))s.setAttribute(i,o);for(const i of t)i&&s.append(i);return s}function U(n,e){const t=d(n,{...e,crossorigin:"anonymous"});return Object.assign(t,{referrerPolicy:"no-referrer"}),t.setAttribute("referrerpolicy","no-referrer"),t}const V="http://www.w3.org/2000/svg";function Fe(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}const Te="M6.2 11.4 3 8.2l1.1-1.1 2.1 2.1 4.6-4.6 1.1 1.1z",Ae="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."},qe=(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 o="",c=false,u,g,x,T,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 a=(r,f,b={})=>{const C=d("button",{type:"button",...b},r);return C.addEventListener("click",f),C},h=()=>{const r=d("p",{},o||"Loading…");return o||t.consentText().then(f=>{o=f,r.textContent=f}),d("div",{class:"checkin",role:"group","aria-label":"Consent"},r,d("div",{class:"row"},a("Allow and send",()=>e.giveConsent(),{id:"jz-help-allow",class:"primary"}),a("Not now",()=>e.declineConsent())))},v=()=>d("div",{class:"panel-head"},d("h2",{},"Help"),a("×",()=>e.close(),{class:"icon-btn","aria-label":"Close help"})),E=(r,f,b)=>{const C=d("button",{type:"button",id:`jz-help-${f}`,class:`checkin-btn ${f}`});return C.append(Fe(f==="understood"?Te:Ae),d("span",{},r)),C.addEventListener("click",b),C};function m(r){const f=n.activeElement,b=f!==null&&i.contains(f),C=b?f.id:"";s.hidden=r.view==="disabled";const S=r.view!=="closed"&&r.view!=="disabled";if(s.setAttribute("aria-expanded",String(S)),i.hidden=!S,r.view==="index"&&!q(r)&&u&&i.contains(u.input)){z(r),b&&f&&!f.isConnected&&(C&&n.getElementById(C)||u.input).focus(),c=S;return}if(u=void 0,i.replaceChildren(...(S?k(r):[]).filter(w=>!!w)),S&&(!c||b)){const N=(C?n.getElementById(C):null)??i.querySelector("[data-autofocus]")??i.querySelector("input, [role=group] button, button");N?.focus(),N instanceof HTMLInputElement&&N.setSelectionRange(N.value.length,N.value.length)}!S&&c&&s.focus(),c=S}function k(r){if(x?.owns(r))return x.content(r);if(q(r))return T??(T=import("./jobs-CAXbM5-g.js").then(I=>{x=I.jobsUi({controller:e,options:t,el:d,button:a,consentGroup:h,rerender:()=>m(e.state),checkinNotice:R})},()=>{F=true}).then(()=>m(e.state))),[v(),d("p",{class:"muted",role:"status"},"Loading…")];if(r.view==="index"){const I=d("input",{id:"jz-help-search",type:"search","aria-label":"Search help",placeholder:"How do I…",autocomplete:"off"});return I.value=r.query,I.addEventListener("input",()=>e.search(I.value)),u={input:I,status:d("p",{class:"muted",role:"status"}),retry:d("div",{class:"row"},a("Try again",()=>e.open())),request:d("div",{class:"request"}),signal:d("div",{class:"signal"}),list:d("ul",{"aria-label":"Guides"})},z(r),[v(),I,u.status,u.retry,u.request,u.signal,u.list]}if(r.view==="finished")return[v(),d("h2",{},`You finished “${r.guide.title}”`),r.notice&&d("p",{class:"muted",role:"status"},R[r.notice]??""),d("div",{class:"row"},a("More guides",()=>e.open(),{id:"jz-help-more"}),a("Back",()=>e.back()),a("Close",()=>e.close()))];if(r.view!=="guide")return[];if(r.status!=="ready"||!r.guide)return[v(),d("p",{role:"status"},r.status==="loading"?"Loading guide…":"This guide isn't available right now."),d("div",{class:"row"},a("Back",()=>e.open()),a("Close",()=>e.close()))];const f=r.guide,b=f.steps[r.step];if(!b)return[];const C=r.step+1===f.steps.length,S=f.steps.length,w=d("div",{class:"progress","aria-hidden":"true"},d("div",{class:"progress-fill"})),N=w.firstElementChild;N.style.width=`${Math.round((r.step+1)/S*100)}%`;const H=[d("h2",{},f.title),d("p",{class:"muted"},`Step ${r.step+1} of ${S}`),w,d("p",{class:"step-title"},b.title),b.instruction&&d("p",{},b.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."),b.screenshotUrl&&U("img",{src:b.screenshotUrl,alt:`Screenshot for: ${b.title}`,loading:"lazy"})];if(f.videoUrl){const I=U("video",{controls:"",preload:"none",src:f.videoUrl});f.captionsUrl&&I.append(U("track",{kind:"captions",src:f.captionsUrl,default:""})),H.push(I)}const y=[v(),d("div",{class:"card"},...H),r.notice&&d("p",{class:"muted",role:"status"},R[r.notice]??"")];return r.checkin==="asking"?y.push(d("div",{class:"checkin",role:"group","aria-label":"Step check-in"},d("p",{},"Did this step make sense?"),d("div",{class:"row"},E("Understood","understood",()=>e.answer("understood")),E("Confused","confused",()=>e.answer("confused")),a("Skip",()=>e.skipCheckin())))):r.checkin==="needs-consent"?y.push(h()):r.checkin==="sending"?y.push(d("p",{role:"status"},"Sending…")):(r.signal==="needs-consent"?y.push(h()):r.signal==="sending"?y.push(d("p",{role:"status"},"Sending…")):r.signalNotice&&y.push(d("p",{class:"muted",role:"status"},Y[r.signalNotice]??"")),e.canSignal()&&y.push(Ee(e,b.index)),y.push(d("div",{class:"row"},a("Back",()=>e.back()),a(C?"Finish":"Next",()=>e.next(),{id:"jz-help-next"}),a("Close",()=>e.close())))),y}function z(r){if(!u)return;const{input:f,status:b,retry:C,request:S,signal:w,list:N}=u;if(f.value!==r.query&&n.activeElement!==f&&(f.value=r.query),b.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.":"",b.hidden=b.textContent==="",C.hidden=r.status!=="error",r.status==="ready"&&r.query.trim()!==""&&r.results.length===0&&e.canSignal()){const y=r.query.trim();(g!==y||!S.firstElementChild)&&(g=y,S.replaceChildren(Ie(e,y)))}else S.firstElementChild&&(g=void 0,S.replaceChildren());r.signal==="needs-consent"?w.replaceChildren(h()):r.signal==="sending"?w.replaceChildren(d("p",{role:"status"},"Sending…")):r.signalNotice?w.replaceChildren(d("p",{class:"muted",role:"status"},Y[r.signalNotice]??"")):w.firstElementChild&&w.replaceChildren(),N.replaceChildren(...r.results.map((y,I)=>d("li",{},a(y.title||"Untitled guide",()=>e.openGuide(y.journeyId??""),{id:`jz-help-g${I}`}),y.goal?d("p",{class:"muted"},y.goal):void 0)))}const M=e.subscribe(m);return{destroy(){M(),x?.destroy(),s.remove(),i.remove()}}},Ne=500,He=6e3;async function Me(n,e){const t=e.trim();if(!t||[...t].length>Ne||!n.canSignal()||!n.hasConsent())return;const s={siteKey:n.siteKey,consentGiven:true,text:t};n.reviewerToken&&(s.reviewerToken=n.reviewerToken);let i;try{const o=await Promise.race([Promise.resolve(n.claims?.()).then(c=>(c&&(s.claims=c),X(n.endpoint,"RouteIntent",s,n.fetchImpl))),new Promise(c=>i=setTimeout(c,He))]);return o?.jobId?{jobId:o.jobId,journeyId:o.journeyId||void 0}:void 0}catch{return}finally{clearTimeout(i)}}const Le=`
|
|
23
|
+
:host {
|
|
24
|
+
all: initial;
|
|
25
|
+
--jz-canvas:#F7F7F5; --jz-surface:#FFFFFF; --jz-raised:#F0F0EC; --jz-ink:#1D2024; --jz-muted:#5D636B;
|
|
26
|
+
--jz-faint:#6C727B; --jz-rule:rgb(29 32 36 / 12%); --jz-accent:#3D63C9; --jz-accent-ink:#FFFFFF;
|
|
27
|
+
--jz-accent-soft:rgb(61 99 201 / 10%); --jz-polished:#2F7D4F; --jz-confused:#6E4FC2;
|
|
28
|
+
--jz-shadow:0 1px 3px rgb(0 0 0 / 12%);
|
|
29
|
+
font: 400 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
30
|
+
color: var(--jz-ink); -webkit-font-smoothing: antialiased;
|
|
31
|
+
}
|
|
32
|
+
@media (prefers-color-scheme: dark) {
|
|
33
|
+
:host {
|
|
34
|
+
--jz-canvas:#111316; --jz-surface:#181B1F; --jz-raised:#20242A; --jz-ink:#E8EAED; --jz-muted:#A3A9B2;
|
|
35
|
+
--jz-faint:#8A919B; --jz-rule:rgb(232 234 237 / 12%); --jz-accent:#7F9CF0; --jz-accent-ink:#111316;
|
|
36
|
+
--jz-accent-soft:rgb(127 156 240 / 14%); --jz-polished:#5DBB84; --jz-confused:#A48BEA;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
40
|
+
button { font: inherit; color: inherit; cursor: pointer; }
|
|
41
|
+
:focus-visible { outline: 2px solid var(--jz-accent); outline-offset: 2px; }
|
|
42
|
+
button:disabled { opacity: .45; cursor: not-allowed; }
|
|
43
|
+
[hidden] { display: none !important; }
|
|
44
|
+
|
|
45
|
+
.launcher { position:fixed; left:24px; bottom:24px; z-index:2147483646; width:44px; height:44px; min-width:44px; min-height:44px;
|
|
46
|
+
display:flex; align-items:center; justify-content:center; padding:0; border:1px solid var(--jz-accent); border-radius:999px;
|
|
47
|
+
background:var(--jz-accent); color:var(--jz-accent-ink); font-size:18px; font-weight:600; box-shadow:var(--jz-shadow);
|
|
48
|
+
transition: background 180ms ease-out, transform 180ms ease-out; }
|
|
49
|
+
.launcher:hover, .launcher[aria-expanded="true"] { background:var(--jz-ink); border-color:var(--jz-ink); }
|
|
50
|
+
|
|
51
|
+
.panel { position:fixed; left:24px; bottom:80px; z-index:2147483646; width:min(360px, calc(100vw - 48px));
|
|
52
|
+
max-height:min(75vh, 580px); overflow:auto; padding:16px; border:1px solid var(--jz-rule); border-radius:10px;
|
|
53
|
+
background:var(--jz-surface); color:var(--jz-ink); box-shadow:var(--jz-shadow);
|
|
54
|
+
transition: opacity 180ms ease-out, transform 180ms ease-out; }
|
|
55
|
+
.panel-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:12px; }
|
|
56
|
+
.panel-head h2 { margin:0; font-size:14px; font-weight:600; }
|
|
57
|
+
.icon-btn { width:44px; height:44px; min-width:44px; display:flex; align-items:center; justify-content:center; padding:0;
|
|
58
|
+
border:0; border-radius:6px; background:transparent; color:var(--jz-faint); transition: color 180ms ease-out, background 180ms ease-out; }
|
|
59
|
+
.icon-btn:hover { color:var(--jz-ink); background:var(--jz-raised); }
|
|
60
|
+
|
|
61
|
+
.panel input { width:100%; min-height:44px; padding:8px 12px; border:1px solid var(--jz-rule); border-radius:6px;
|
|
62
|
+
background:var(--jz-canvas); color:var(--jz-ink); font:inherit; }
|
|
63
|
+
.panel input::placeholder { color:var(--jz-faint); }
|
|
64
|
+
.panel ul { list-style:none; padding:0; margin:12px 0 0; }
|
|
65
|
+
.panel li { margin:0 0 8px; }
|
|
66
|
+
.panel li button { display:block; width:100%; min-height:44px; text-align:left; padding:8px 12px; border:1px solid var(--jz-rule);
|
|
67
|
+
border-radius:6px; background:var(--jz-surface); color:inherit; font:inherit; transition: background 180ms ease-out, border-color 180ms ease-out; }
|
|
68
|
+
.panel li button:hover { background:var(--jz-raised); border-color:var(--jz-accent); }
|
|
69
|
+
.muted { color:var(--jz-muted); font-size:12px; margin:4px 0 0; }
|
|
70
|
+
.row { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
|
|
71
|
+
.row button { min-height:44px; padding:0 16px; border:1px solid var(--jz-rule); border-radius:6px; background:var(--jz-surface);
|
|
72
|
+
color:var(--jz-muted); transition: background 180ms ease-out, color 180ms ease-out; }
|
|
73
|
+
.row button:hover { color:var(--jz-ink); background:var(--jz-raised); }
|
|
74
|
+
.row .primary { border-color:var(--jz-accent); background:var(--jz-accent); color:var(--jz-accent-ink); }
|
|
75
|
+
|
|
76
|
+
.card { border:1px solid var(--jz-rule); border-radius:10px; padding:16px; }
|
|
77
|
+
.card h2 { margin:0 0 8px; font-size:14px; font-weight:600; }
|
|
78
|
+
.progress { height:4px; margin:8px 0 12px; border-radius:999px; background:var(--jz-raised); overflow:hidden; }
|
|
79
|
+
.progress-fill { height:100%; border-radius:999px; background:var(--jz-accent); transition: width 180ms ease-out; }
|
|
80
|
+
.step-title { margin:0 0 8px; font-weight:600; }
|
|
81
|
+
.panel img, .panel video { max-width:100%; margin-top:12px; border:1px solid var(--jz-rule); border-radius:6px; }
|
|
82
|
+
|
|
83
|
+
.checkin { margin-top:12px; padding-top:12px; border-top:1px solid var(--jz-rule); }
|
|
84
|
+
.checkin p { margin:0 0 8px; }
|
|
85
|
+
.callout-btn { display:inline-flex; align-items:center; gap:6px; margin-top:12px; min-height:44px; padding:0 16px;
|
|
86
|
+
border:1px solid var(--jz-confused); border-radius:6px; background:var(--jz-surface); color:var(--jz-confused);
|
|
87
|
+
transition: background 180ms ease-out, color 180ms ease-out; }
|
|
88
|
+
.callout-btn:hover { background:var(--jz-raised); }
|
|
89
|
+
.callout-btn svg { flex:none; }
|
|
90
|
+
.request { margin-top:12px; }
|
|
91
|
+
.request p { margin:0 0 8px; color:var(--jz-muted); font-size:12px; }
|
|
92
|
+
.request textarea { display:block; width:100%; padding:8px 12px; border:1px solid var(--jz-rule); border-radius:6px;
|
|
93
|
+
background:var(--jz-canvas); color:var(--jz-ink); font:inherit; resize:vertical; }
|
|
94
|
+
.request button { margin-top:8px; min-height:44px; padding:0 16px; border:1px solid var(--jz-accent);
|
|
95
|
+
border-radius:6px; background:var(--jz-accent); color:var(--jz-accent-ink); }
|
|
96
|
+
.checkin-btn { display:inline-flex; align-items:center; gap:6px; }
|
|
97
|
+
.checkin-btn.understood { color:var(--jz-polished); border-color:var(--jz-polished); }
|
|
98
|
+
.checkin-btn.confused { color:var(--jz-confused); border-color:var(--jz-confused); }
|
|
99
|
+
.checkin-btn svg { flex:none; }
|
|
100
|
+
|
|
101
|
+
@media (prefers-reduced-motion: reduce) {
|
|
102
|
+
:host *, :host *::before, :host *::after { animation-duration:1ms !important; transition-duration:1ms !important; }
|
|
103
|
+
}
|
|
104
|
+
.jz-help-highlight { position:fixed; z-index:2147483645; pointer-events:none; box-sizing:border-box;
|
|
105
|
+
border:2px solid var(--jz-accent); border-radius:6px; box-shadow:0 0 0 4px var(--jz-accent-soft); }
|
|
106
|
+
`;function O(n,e,t,s,i){const o={journeyId:e.slug||e.journeyId,journeyStep:String(t.index),pagePath:J(s),device:n.device||Q(i)};return n.persona&&(o.persona=n.persona),n.businessType&&(o.businessType=n.businessType),n.state&&(o.state=n.state),t.tflowId&&(o.tflowId=t.tflowId),o}function $e(n,e,t,s){return O(n,e.guide,e.step,t,s)}function Be(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 De(n,e,t,s,i){if(t.kind==="callout")return{siteKey:n,consentGiven:true,kind:G.callout,context:O(e,t.guide,t.step,s,i)};const o=t.guide&&t.step?O(e,t.guide,t.step,s,i):Be(e,s,i),c={siteKey:n,consentGiven:true,kind:G.request,comment:t.text,context:o};return t.jobRequest&&(c.jobRequest=t.jobRequest),c}function Ue(n,e,t=ze){const s=re(n),i=n.claims!==void 0||n.getToken?import("./claims-BfpRuIu-.js").then(l=>l.claimsSource(n)):void 0,o=i&&(()=>i.then(l=>l.token()));o?.();let c,u;i?.then(l=>u=l);const g=new pe({endpoint:s,siteKey:n.siteKey,reviewerToken:n.reviewerToken,claims:o});let x;const T=X(s,"GetWidgetConfig",{siteKey:n.siteKey}).then(l=>x=l,()=>{}),F=()=>!n.reviewerToken&&!n.userId,q=()=>F()&&x?.helpAudience!="reviewers",a=document.createElement("div");a.setAttribute("data-journeeze-help","");const h=a.attachShadow({mode:"closed"}),v=document.createElement("style");v.textContent=Le,n.nonce&&(v.nonce=n.nonce),h.append(v);const E=new ke(h);document.body.append(a);let m;const k=l=>(m??(m=import("./feedback-DtMDnAam.js").then(A=>A.feedbackChannel(n,s,{memoryOnly:q(),claims:o})))).then(A=>A.outbox.enqueue(l),()=>"dropped");let z,M=false;const r=()=>ce(n),f=()=>q()?null:void 0,b=()=>de(r(),f()),C=te(n,s,e),S=()=>{M&&w.state.view!=="disabled"&&b()&&(z?.start(),C.start(T))},w=new fe({endpoint:s,loadIndex:()=>g.index().then(l=>(c=l.persona||void 0,l)),loadGuide:l=>g.guide(l),highlight:l=>E.show(l),clearHighlight:()=>E.hide(),hasConsent:b,giveConsent(){ae(r(),f()),S()},signalsAllowed:()=>!F()||x?.anonymousAllowed==true,sendCheckin(l){return b()?(z?.checkin(l),k({siteKey:n.siteKey,consentGiven:true,context:$e(e(),l,location.href,window.innerWidth),reaction:ne[l.answer]})):Promise.resolve("dropped")},sendSignal(l){return!w.canSignal()||!b()?Promise.resolve("dropped"):k(De(n.siteKey,e(),l,location.href,window.innerWidth))}});n.noTelemetry||(z=je(s,n.siteKey,w,()=>u?.current())),w.subscribe(S);let N,H=false,y;const I=l=>{const A=l.available?"on":l.reason;if(!(H||A===y)){y=A;try{n.onHelpStatus?.(l)}catch{}}};return w.subscribe(()=>{y!==void 0&&w.state.view==="disabled"&&I({available:false,reason:"disabled"})}),Promise.all([w.probe(),T]).then(()=>{if(!H){if(w.state.view==="disabled")return I({available:false,reason:"disabled"});I(x?.helpAudience=="reviewers"&&!n.reviewerToken?{available:false,reason:"audience"}:{available:true}),M=true,S(),N=t(h,w,{consentText:()=>T.then(l=>l?.consentText||oe),persona:()=>c??e().persona,jobEvent(l){M&&w.state.view!=="disabled"&&b()&&z?.job(l)},routeIntent:l=>Me({endpoint:s,siteKey:n.siteKey,reviewerToken:n.reviewerToken,claims:o,hasConsent:b,canSignal:()=>w.canSignal()},l),addStyle(l){const A=document.createElement("style");A.textContent=l,n.nonce&&(A.nonce=n.nonce),h.append(A)}})}}),{unmount(l){H=true,i?.then(A=>A.stop()),w.close(),z?.stop(l),C.stop(l),N?.destroy(),E.dispose(),a.remove(),m?.then(A=>A.dispose())},contextChanged:()=>{w.refreshHighlight(),C.contextChanged()}}}const We=(n,e)=>Ue(n,()=>le(e()),qe);export{pe as HelpClient,fe as HelpController,ke as Highlighter,ge as MAX_REQUEST_CHARS,Ke as PANEL_CSS,$e as checkinContext,me as findAnchor,O as guideStepContext,B as isHelpDisabled,We as mount,Ue as mountHelp,Be as pageContext,ze as placeholderView,_ as searchGuides,De as signalRequest,ve as toView};
|
|
@@ -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-eaZX2lNd.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-k4pePzAw.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-CcAalO4B.js"), C = () => import("./help-D_T0HiNa.js"), _ = () => import("./chat-ByOXN5k1.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-DtMDnAam.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-BupCs23W.js";import{w as h}from"./loader-k4pePzAw.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-k4pePzAw.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-k4pePzAw.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-k4pePzAw.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-k4pePzAw.js";import{p as Ze,s as Qe,j as we,m as Ye,M as Je,r as et}from"./transport-DokImbgl.js";import{c as tt,C as _e}from"./consent-BupCs23W.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-BupCs23W.js";import{p as J,j as T,s as q,M as Q,m as z,r as Z}from"./transport-DokImbgl.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-BupCs23W.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. */
|
|
@@ -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 {
|
|
@@ -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;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** `base64url(payload) "." base64url(mac)`, unpadded; the mac is an HMAC-SHA256 tag (43). */
|
|
2
|
+
export declare const CLAIMS_TOKEN_PATTERN: RegExp;
|
|
3
|
+
/** Largest token the SDK sends (the collector's bound). */
|
|
4
|
+
export declare const CLAIMS_TOKEN_MAX_LEN = 4096;
|
|
5
|
+
/** A token this close to its end (seconds) is refreshed before it is sent. */
|
|
6
|
+
export declare const CLAIMS_REFRESH_MARGIN_S = 60;
|
|
7
|
+
/** At most one `getToken()` call per this many milliseconds while a usable token is held. */
|
|
8
|
+
export declare const CLAIMS_MIN_REFRESH_INTERVAL_MS = 15000;
|
|
9
|
+
/** The options a claims source reads and writes (the chunks' shared mount options). */
|
|
10
|
+
export interface ClaimsOptions {
|
|
11
|
+
claims?: string | undefined;
|
|
12
|
+
getToken?: (() => Promise<string>) | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** Whether `token` has the v2 token shape. */
|
|
15
|
+
export declare function wellFormedClaims(token: unknown): token is string;
|
|
16
|
+
/** The token's `exp` (Unix seconds), read from its payload; `undefined` when it cannot be read. */
|
|
17
|
+
export declare function claimsExp(token: string): number | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* The page-clock time (ms) the token stops being usable: first seen + (`exp − iat`). `undefined`
|
|
20
|
+
* when its payload has no integer `exp` and `iat`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function claimsEnd(token: string, now?: number): number | undefined;
|
|
23
|
+
/** `token` when it is well formed and more than `margin` seconds from its end, else `undefined`. */
|
|
24
|
+
export declare function usableClaims(token: unknown, margin?: number, now?: number): string | undefined;
|
|
25
|
+
export interface ClaimsSource {
|
|
26
|
+
/** The token to send now, refreshed through `getToken()` when needed; `undefined`: send none. */
|
|
27
|
+
token(): Promise<string | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* The token to send now without waiting (unload and keepalive sends): the current one while
|
|
30
|
+
* it is usable, else none. It may start a refresh in the background for the next send.
|
|
31
|
+
*/
|
|
32
|
+
current(): string | undefined;
|
|
33
|
+
/** The chunk unmounted: a `getToken()` still in flight is discarded, never stored. */
|
|
34
|
+
stop(): void;
|
|
35
|
+
}
|
|
36
|
+
/** One chunk's view of the host's claims (one `getToken()` call at a time). */
|
|
37
|
+
export declare function claimsSource(options: ClaimsOptions, now?: () => number): ClaimsSource;
|
|
@@ -4,6 +4,8 @@ export interface HelpClientOptions {
|
|
|
4
4
|
siteKey: string;
|
|
5
5
|
/** Sent on help reads when set: reviewers sites require it, public sites validate it (ADR 0013 §1). */
|
|
6
6
|
reviewerToken?: string | undefined;
|
|
7
|
+
/** Signed claims v2 (contract §15): the token to send now, if any. */
|
|
8
|
+
claims?: (() => Promise<string | undefined>) | undefined;
|
|
7
9
|
fetchImpl?: typeof fetch;
|
|
8
10
|
now?: () => number;
|
|
9
11
|
/** How long a value is used without asking the collector again. */
|
|
@@ -23,4 +25,5 @@ export declare class HelpClient {
|
|
|
23
25
|
guide(journeyId: string): Promise<GetGuideResponse>;
|
|
24
26
|
private body;
|
|
25
27
|
private read;
|
|
28
|
+
private readWith;
|
|
26
29
|
}
|
|
@@ -29,4 +29,4 @@ export interface TelemetryHook {
|
|
|
29
29
|
/** `discard` (a logout): drop queued events instead of sending them. */
|
|
30
30
|
stop(discard?: boolean): void;
|
|
31
31
|
}
|
|
32
|
-
export declare function telemetryHook(endpoint: string, siteKey: string, controller: HelpController): TelemetryHook;
|
|
32
|
+
export declare function telemetryHook(endpoint: string, siteKey: string, controller: HelpController, claims?: () => string | undefined): TelemetryHook;
|
|
@@ -6,6 +6,8 @@ export interface RouteDeps {
|
|
|
6
6
|
endpoint: string;
|
|
7
7
|
siteKey: string;
|
|
8
8
|
reviewerToken?: string | undefined;
|
|
9
|
+
/** Signed claims v2 (contract §15): the token to send, if any (gated guides route only with it). */
|
|
10
|
+
claims?: (() => Promise<string | undefined>) | undefined;
|
|
9
11
|
/** The site's consent, read on every call. */
|
|
10
12
|
hasConsent(): boolean;
|
|
11
13
|
/** Whether this reader may send requests at all. */
|
package/dist/types/loader.d.ts
CHANGED
|
@@ -31,6 +31,9 @@ export interface MountOptions extends JourneezeOptions {
|
|
|
31
31
|
userIdExp?: number | undefined;
|
|
32
32
|
/** The signature last given to `setUser` (it wins over the config's). */
|
|
33
33
|
signature?: JourneezeUserIdSignature | "" | undefined;
|
|
34
|
+
/** Signed claims v2 (contract §15): read and refreshed by the chunks (`claims.ts`). */
|
|
35
|
+
claims?: string | undefined;
|
|
36
|
+
getToken?: (() => Promise<string>) | undefined;
|
|
34
37
|
maskSelectors?: readonly string[];
|
|
35
38
|
maskAllText?: boolean;
|
|
36
39
|
nonce?: string;
|
|
@@ -18,11 +18,13 @@ export interface MaskAuditOptions {
|
|
|
18
18
|
reviewerToken: string;
|
|
19
19
|
/** Host and journey-configuration selectors: elements they cover are already masked. */
|
|
20
20
|
maskSelectors?: readonly string[];
|
|
21
|
+
/** The host's `pagePath` option: `"none"` sends no page path. */
|
|
22
|
+
pagePath?: "redacted" | "none";
|
|
21
23
|
fetchImpl?: typeof fetch;
|
|
22
24
|
now?: () => Date;
|
|
23
25
|
}
|
|
24
26
|
/** The page's findings, value-free. Pure apart from reading the DOM. */
|
|
25
|
-
export declare function auditPage(scan: Scan, root: Element, href: string, selectors: readonly string[], now: Date): MaskFindingWire[];
|
|
27
|
+
export declare function auditPage(scan: Scan, root: Element, href: string, selectors: readonly string[], now: Date, pagePathMode?: "redacted" | "none"): MaskFindingWire[];
|
|
26
28
|
/** Audits the current page and submits what is new for this tab. Never throws into the host. */
|
|
27
29
|
export declare function runMaskAudit(opts: MaskAuditOptions): Promise<number>;
|
|
28
30
|
/** Test helper: forget what this tab sent. */
|
|
@@ -26,6 +26,8 @@ export interface RecordHelpEventsRequest {
|
|
|
26
26
|
events: WireHelpEvent[];
|
|
27
27
|
/** C0b v1.1 §4: events this page load dropped at an earlier page end (aggregate, no ids). */
|
|
28
28
|
droppedAtUnload?: number;
|
|
29
|
+
/** Signed claims v2 (contract §15): events about entitlement-gated guides count only with it. */
|
|
30
|
+
claims?: string;
|
|
29
31
|
}
|
|
30
32
|
export interface TelemetryOptions {
|
|
31
33
|
endpoint: string;
|
|
@@ -45,6 +47,8 @@ export interface TelemetryOptions {
|
|
|
45
47
|
* Do Not Track is ignored (C0a §7).
|
|
46
48
|
*/
|
|
47
49
|
respectGlobalPrivacyControl?: boolean;
|
|
50
|
+
/** The current usable claims token, never awaited (page-end sends included). */
|
|
51
|
+
claims?: (() => string | undefined) | undefined;
|
|
48
52
|
}
|
|
49
53
|
/** Whether Global Privacy Control turns telemetry off for these options. */
|
|
50
54
|
export declare function gpcRefusesTelemetry(opts: Pick<TelemetryOptions, "respectGlobalPrivacyControl">, nav?: object | undefined): boolean;
|