@journeeze/sdk 0.2.0 → 0.3.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/{anchor-BhsfeHwL.js → anchor-bnZCZtbG.js} +1 -1
  3. package/dist/{attach-D451Wj4h.js → attach-EfetX0Vi.js} +1 -1
  4. package/dist/chat-Coze4aH0.js +64 -0
  5. package/dist/{claims-BfpRuIu-.js → claims-VKhPNjA7.js} +1 -1
  6. package/dist/{consent-BupCs23W.js → consent-bPengyOI.js} +1 -1
  7. package/dist/contract.js +1 -1
  8. package/dist/{feedback-DtMDnAam.js → feedback-DeMvbZnh.js} +1 -1
  9. package/dist/help-phTc32Gg.js +105 -0
  10. package/dist/highlight-pU9nE3Qj.js +2 -0
  11. package/dist/{hook-BRnJ-lTk.js → hook-M34sajh9.js} +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/{loader-k4pePzAw.js → loader-DHgG5Y7t.js} +2 -2
  14. package/dist/{mask-audit-DtKNgOlT.js → mask-audit-KFvSiJU0.js} +1 -1
  15. package/dist/react.js +1 -1
  16. package/dist/{resolve-7jVqhJhi.js → resolve-CRDmtd4b.js} +1 -1
  17. package/dist/script.js +1 -1
  18. package/dist/{signals-eaZX2lNd.js → signals-C_WxFykA.js} +1 -1
  19. package/dist/{telemetry-DMGFJcw3.js → telemetry-CdwMjZZZ.js} +1 -1
  20. package/dist/{transport-DokImbgl.js → transport-Wrkorx6z.js} +1 -1
  21. package/dist/types/chat/shell/chat.d.ts +4 -2
  22. package/dist/types/chat/shell/guide.d.ts +12 -0
  23. package/dist/types/chat/shell/session.d.ts +6 -0
  24. package/dist/types/chat/shell/walk.d.ts +49 -0
  25. package/dist/{upload-DkAWrJhn.js → upload-KvsGqMEV.js} +1 -1
  26. package/dist/walk-BEGYyGG3.js +1 -0
  27. package/dist/{widget-CcAalO4B.js → widget-BA2WH0yi.js} +2 -2
  28. package/package.json +1 -1
  29. package/dist/chat-ByOXN5k1.js +0 -64
  30. package/dist/help-D_T0HiNa.js +0 -106
@@ -1 +1 @@
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"&&lt.test(t))return{stringValue:t}},Y=e=>{const t=e.payload??{};if(t.__drop===true)return;const i=ce[e.name],r=i??L.get(e.name);if(!r)return;const l=typeof t.target=="string"&&Pe.test(t.target)?t.target:void 0;if(e.name==="rage_click"&&l){const x=K.get(l);queueMicrotask(()=>j(()=>x?.reset()))}const u=e.name===Q?`${e.name} ${String(t.journey)} ${String(t.step)}`:`${e.name} ${l??""}`,_=m(),y=le.get(u);if(y!==void 0&&_-y<pt){e.name==="rage_click"&&typeof t.clicks=="number"&&W.set(u,(W.get(u)??0)+t.clicks);return}le.set(u,_);const H={};let D=0;for(const[x,Ge]of Object.entries(r)){let re=t[x];x==="clicks"&&typeof re=="number"&&(re+=W.get(u)??0,W.delete(u));const ve=Le(Ge,re);ve&&D<8&&(H[x]=ve,D++)}e.name===Q&&D!==3||De({name:e.name,source:i?"SIGNAL_SOURCE_PLATFORM":"SIGNAL_SOURCE_SITE",context:Re(),...l?{target:l}:{},...D>0?{params:H}:{}},e.name==="abandoned_step")},J=f.Pattern;let w;const fe=async()=>{const e=new f.TFloBrowser({sinks:[{name:"journeeze",send:Y}],onSinkError:()=>{}});try{await e.init()}catch{return R("tflo failed to initialise; signals off"),false}return k?(e.destroy(),false):(w=e,Xe(e),true)},P=(e,t={})=>{!k&&w&&j(()=>w.ingest({kind:e,ts:m(),fields:t}))},ee=e=>e.kind==="jz.end",T=new Map;let Ne=0,M;const V=e=>{T.delete(e.name),j(()=>w?.removePattern(e.name))},te=(e,t,i,r,l,u)=>{if(!w)return;for(const x of T.values())if(x.key===t)return;T.size>=jt&&V(T.values().next().value);const _=++Ne,y=`${e}#${_}`,H=r(new J(y),_).within(i).emit(l),D=w.addPattern(H);T.set(y,{name:y,key:t,runtime:D,deadline:m()+i}),P("jz.window",{...u,w:_}),M??(M=setInterval($e,ft))};function $e(){const e=m();for(const t of[...T.values()]){if(t.deadline>e)continue;const i=j(()=>t.runtime.flush())??[];V(t);for(const r of i)Y(r)}T.size===0&&M!==void 0&&(clearInterval(M),M=void 0)}const C=(e,t)=>{for(const i of[...T.values()])i.name.startsWith(`${e}#`)&&(t===void 0||i.key===t)&&V(i)};let Ue=0;const z=new Map,Be=e=>{if(!w)return;const t=z.get(e);if(t){z.delete(e),z.set(e,t);return}if(z.size>=ht){const[u,_]=z.entries().next().value;j(()=>w?.removePattern(_)),z.delete(u),K.delete(u)}const i=u=>u.kind==="jz.click"&&u.fields.target===e,r=`rage_click#${++Ue}`,l=w.addPattern(new J(r).when(i).then(i).then(i).within(ke).emit(u=>u.last().ts-u.first().ts<=ke?{name:"rage_click",payload:{target:e,clicks:u.length}}:{name:"rage_click",payload:{__drop:true}}));z.set(e,r),K.set(e,l)},Fe=(e,t)=>te("hesitation",e,be,(i,r)=>i.when(l=>l.fields.w===r).notThen(l=>ee(l)||(l.kind==="jz.unhover"||l.kind==="jz.blur"||l.kind==="jz.click"||l.kind==="jz.change")&&l.fields.target===e),i=>({name:"hesitation",payload:{target:e,dwell_ms:Math.max(be,wt(m()-i.first().ts))}}),{target:e,kind:t}),We=e=>te("dead_click",e,de,(t,i)=>t.when(r=>r.fields.w===i).notThen(r=>ee(r)||r.kind==="jz.effect"),()=>({name:"dead_click",payload:{target:e}}),{target:e});let Ke=0;const pe=[];for(const e of s.rules??[]){if(!Se.test(e.name)||e.name in ce||e.name.startsWith("jz_")){R(`site rule ${e.name} refused (name)`);continue}const t=typeof e.when=="function"?e.when:it(e.when);if(!t){R(`site rule ${e.name} refused (outside the SDK's CEL subset)`);continue}pe.push({rule:e,pred:t})}const Ve=e=>St.has(e.kind);function Xe(e){for(const{rule:t,pred:i}of pe)e.addPattern(new J(`site:${t.name}#${++Ke}`).when(r=>Ve(r)&&j(()=>i({kind:r.kind.slice(3),ts:r.ts,fields:{target:r.fields.target}}))===true).emit(r=>{const l=r.first(),u={target:l.fields.target};for(const[_,y]of Object.entries(t.params??{}))_!=="target"&&(u[_]=bt(l,y));return{name:t.name,payload:u}}))}let A;const qe=ct(m),ne=()=>{const e=o.getContext();A&&e.journeyId!==A.journey&&(C("abandoned_step"),A=void 0);const t=kt(n,e,A),i=qe.sync(e.journeyId,t&&e.journeyStep?{journey:t.journey,index:t.index,step:e.journeyStep}:void 0);if(i&&Y({name:Q,payload:{...i}}),!t||A&&t.index<=A.index||(A&&P("jz.step",{journey:t.journey,index:t.index}),C("abandoned_step"),A=t,t.last))return;const{journey:r,index:l}=t;te("abandoned_step",r,ut,(u,_)=>u.when(y=>y.fields.w===_).notThen(y=>ee(y)||y.kind==="jz.step"&&y.fields.journey===r&&y.fields.index>l),()=>({name:"abandoned_step",payload:{step:l+1}}),{journey:r,index:l})};let me=0;const X=()=>{m()>me||(P("jz.effect"),C("dead_click"))},U=typeof MutationObserver=="function"?new MutationObserver(X):void 0;let B;const oe=typeof PerformanceObserver=="function"?j(()=>new PerformanceObserver(e=>e.getEntries().length>0&&X())):void 0;j(()=>oe?.observe({type:"resource"}));const ie=e=>Oe(e.composedPath?.()[0]??e.target,O);b(document,"click",e=>{const t=ie(e);t&&(Be(t),P("jz.click",{target:t}),C("hesitation",t),me=m()+de,U&&(U.observe(document.documentElement,{childList:true,attributes:true,subtree:true}),B!==void 0&&clearTimeout(B),B=setTimeout(()=>U.disconnect(),de)),We(t))});const q=(e,t)=>b(document,e,i=>{t==="jz.focus"&&X();const r=ie(i);r&&((t==="jz.hover"||t==="jz.unhover")&&Oe(i.relatedTarget,O)===r||(P(t,{target:r}),t==="jz.hover"||t==="jz.focus"?Fe(r,t):C("hesitation",r)))});q("pointerover","jz.hover"),q("pointerout","jz.unhover"),q("focusin","jz.focus"),q("focusout","jz.blur"),b(document,"change",e=>{const t=ie(e);t&&(P("jz.change",{target:t}),C("hesitation",t))});for(const e of["popstate","hashchange"])b(window,e,X);let G=false;const se=()=>{if(k||G)return;G=true;const e=[...a?.signals??[],...g];if(e.length===0)return;const t=(a?.dropped??0)+d,i=S(e,Math.min(Ze(),Te));i.length>0&&Qe(o.endpoint,"RecordSignals",E(i,t),p)&&(a=void 0,g=[],d=e.length-i.length)},he=()=>{for(const e of[...T.values()])V(e);A=void 0},ge=()=>{he();for(const t of z.values())j(()=>w?.removePattern(t));z.clear(),K.clear();const e=w;w=void 0,j(()=>e?.destroy())};if(b(window,"pagehide",()=>{ge(),se()}),b(document,"visibilitychange",()=>{document.visibilityState==="hidden"?se():G=false}),b(window,"pageshow",e=>{G=false,!(!e.persisted||w)&&fe().then(t=>t&&j(ne))}),!await fe()){for(const e of N.splice(0))e();U?.disconnect(),oe?.disconnect();return}return j(ne),{contextChanged:()=>j(ne),stop(e){if(!k){he(),e||se(),k=true;for(const t of N.splice(0))t();M!==void 0&&clearInterval(M),c!==void 0&&clearTimeout(c),B!==void 0&&clearTimeout(B),U?.disconnect(),oe?.disconnect(),g=[],a=void 0,ge()}},idle:()=>v}}const St=new Set(["jz.click","jz.hover","jz.unhover","jz.focus","jz.blur","jz.change"]);function kt(o,n,s){if(!n.journeyId||!n.journeyStep)return;const f=o.publishedJourneys?.find(I=>I.journeyId===n.journeyId)?.stepIds;if(!f||f.length===0)return;const m=s&&s.journey===n.journeyId?s.index+1:0;let p=f.indexOf(n.journeyStep,m);return p<0&&(p=f.indexOf(n.journeyStep)),p>=0?{journey:n.journeyId,index:p,last:p===f.length-1}:void 0}function j(o){try{return o()}catch{return}}function bt(o,n){if(n==="event.kind")return o.kind.slice(3);const s=/^event\.fields\.([A-Za-z_][A-Za-z0-9_]{0,63})$/.exec(n);return s?o.fields[s[1]]:void 0}export{ut as ABANDON_MS,ft as CLOCK_MS,de as DEAD_CLICK_MS,ze as FLUSH_MS,be as HESITATION_MS,Ee as MAX_BATCH,Te as MAX_BATCH_BYTES,Ae as MAX_QUEUED,gt as MAX_QUEUED_BYTES,ht as MAX_TARGETS,jt as MAX_WINDOWS,mt as PAGE_CAP,It as RAGE_CLICKS,ke as RAGE_WINDOW_MS,dt as RULE_SET,pt as THROTTLE_MS,Me as hasFloor,kt as matchCheckpoint,yt as resolveTflo,Mt as startSignals,Oe as trackedId};
1
+ import{CONTEXT_ID_PATTERN as ye,CONTEXT_FIELDS as He}from"./contract.js";import{w as R}from"./loader-DHgG5Y7t.js";import{p as Ze,s as Qe,j as we,m as Ye,M as Je,r as et}from"./transport-Wrkorx6z.js";import{c as tt,C as _e}from"./consent-bPengyOI.js";const nt=/[A-Za-z0-9_]/,ot=/^[A-Za-z_]\w{0,63}$/,Z=o=>!!o&&nt.test(o),ae=o=>!!o&&o>="0"&&o<="9";function je(o,n,s){const f=typeof o==typeof s;return n==="=="?f&&o===s:n==="!="?!(f&&o===s):!f||typeof o=="boolean"?false:n==="<"?o<s:n==="<="?o<=s:n===">"?o>s:o>=s}function it(o){if(!(o?.length<=1024))return;let n=0,s=0,f=0;const m=()=>{for(;n<o.length&&o[n]<=" ";)n++},p=()=>{const a=n;for(;n<o.length&&Z(o[n]);)n++;if(o.slice(a,n)!=="event"||o[n]!==".")return;n++;const d=n;for(;n<o.length&&Z(o[n]);)n++;const c=o.slice(d,n);if(c==="kind")return[true,""];if(c!=="fields"||o[n]!==".")return;n++;const v=n;for(;n<o.length&&Z(o[n]);)n++;const h=o.slice(v,n);return ot.test(h)?[false,h]:void 0},I=a=>{let d="";for(n++;n<o.length;){const c=o[n];if(c===a)return n++,d;if(c==="\\"){const v=o[n+1];if(v===void 0||!`\\"'`.includes(v))return;d+=v,n+=2;continue}if(c<" ")return;d+=c,n++}},O=()=>{const a=n;o[n]==="-"&&n++;const d=n;for(;n<o.length&&ae(o[n]);)n++;if(n!==d){if(o[n]==="."){n++;const c=n;for(;n<o.length&&ae(o[n]);)n++;if(n===c)return}return Number(o.slice(a,n))}},L=()=>{const a=o[n];if(a==='"'||a==="'")return I(a);if(a==="-"||ae(a))return O();const d=n;for(;n<o.length&&Z(o[n]);)n++;const c=o.slice(d,n);return c==="true"?true:c==="false"?false:void 0},k=()=>{const a=o[n],d=o[n+1];if(a==="="&&d==="=")return n+=2,"==";if(a==="!"&&d==="=")return n+=2,"!=";if(a==="<"||a===">")return n+=d==="="?2:1,d==="="?a+"=":a},N=()=>{if(m(),o[n]==="("){if(++f>8)return;n++;const h=F();return m(),!h||o[n]!==")"?void 0:(n++,f--,h)}const a=o[n]==="e",d=a?p():L();if(d===void 0)return;m();const c=k();if(!c)return;if(m(),a){const h=L();if(h===void 0||++s>32)return;const E=d;return S=>je(E[0]?S.kind:S.fields[E[1]],c,h)}const v=p();if(v&&!(++s>32))return h=>je(d,c,v[0]?h.kind:h.fields[v[1]])},b=(a,d,c)=>{let v=a();if(v)for(;;){if(m(),o[n]!==d||o[n+1]!==d)return v;n+=2;const h=a();if(!h)return;const E=v;v=c?S=>E(S)&&h(S):S=>E(S)||h(S)}},g=()=>b(N,"&",true),F=()=>b(g,"|",false),$=F();return m(),$&&n===o.length?$:void 0}const Q="step_completed",st=["lt5s","lt15s","lt60s","lt5m","ge5m"],rt=[5e3,15e3,6e4,3e5];function at(o){const n=rt.findIndex(s=>o<s);return st[n<0?4:n]}function ct(o){let n,s=0,f=-1;return{sync(m,p){if(m!==n&&(n=m,s=o(),f=-1),!p||p.journey!==n||p.index<=f)return;const I=o(),O=at(I-s);return s=I,f=p.index,{journey:p.journey,step:p.step,duration_bucket:O}}}}const dt="jz-platform@2",ce={abandoned_step:{step:"int"},hesitation:{dwell_ms:"int"},rage_click:{clicks:"int"},dead_click:{},step_target_missing:{journey:"id",step:"int",rev:"int",tried:"id"},[Q]:{step:"id",journey:"id",duration_bucket:"id"}},Se=/^[a-z][a-z0-9_]{0,63}$/,Pe=/^[a-z0-9._:-]{1,96}$/,lt=/^[a-z0-9._:-]{1,64}$/,ke=700,It=3,be=3e3,de=1e3,ut=12e4,ft=1e3,pt=1e4,mt=300,ht=64,Ee=50,Te=32*1024,ze=5e3,Ae=200,gt=256*1024,Ie=(o,n)=>typeof o=="function"&&n.every(s=>typeof o.prototype?.[s]=="function");function Me(o){const n=o;return!!n&&Ie(n.TFloBrowser,["init","addPattern","removePattern","ingest","flush","destroy"])&&Ie(n.Pattern,["when","then","notThen","within","emit"])}const vt=()=>import("./index-B_nob8S0.js");async function yt(o,n=vt){if(o!==void 0)try{const s=typeof o=="function"?await o():o;if(Me(s))return s;R("signals.tflo lacks the TFloBrowser/Pattern surface; using the SDK's own")}catch{R("signals.tflo failed to load; using the SDK's own")}try{const s=await n();if(Me(s))return s}catch{}R("tflo failed to load; signals off")}const xe="[data-jz-mask],[data-jz-block],input,textarea,select,[contenteditable]:not([contenteditable='false'])";function Oe(o,n=[]){let s=o instanceof Element?o:o instanceof Node?o.parentElement:null;if(!s)return;const f=[xe,...n].join(",");try{if(s.closest(f))return}catch{if(s.closest(xe))return}const p=s.closest("[data-tflow-id]")?.getAttribute("data-tflow-id")??void 0;return p!==void 0&&Pe.test(p)?p:void 0}const wt=o=>Math.round(o/500)*500;function _t(){return crypto.randomUUID()}const jt=128;async function Mt(o){const n=o.site;if(n.signalsEnabled!==true)return;const s=o.options.signals??{},f=await yt(s.tflo,o.loadOwn);if(!f)return;const m=o.now??(()=>performance.now()),p=o.fetchImpl??((...e)=>fetch(...e)),I=o.newId??_t,O=o.options.maskSelectors??[],L=new Map;for(const e of n.siteSignals??[]){if(!Se.test(e.name)||e.name in ce||e.name.startsWith("jz_"))continue;const t={};for(const i of(e.params??[]).slice(0,8))t[i.name]=i.type==="string"?"id":i.type;L.set(e.name,t)}let k=false;const N=[],b=(e,t,i)=>{e.addEventListener(t,i,{capture:true,passive:true}),N.push(()=>e.removeEventListener(t,i,{capture:true}))};let g=[],F=0,$=0,a,d=0,c,v=Promise.resolve();const h=e=>{k||c!==void 0||(c=setTimeout(()=>{c=void 0,v=v.then(Ce)},e))},E=(e,t=0)=>({siteKey:o.options.siteKey,consentGiven:true,ruleSet:dt,signals:e,...t>0?{droppedAtUnload:t}:{}}),S=(e,t)=>{const i=[];for(const r of e){if(i.length>=Ee||we(E([...i,r]))>t)break;i.push(r)}return i},Ce=async()=>{let e=a;if(!e&&g.length>0){const t=S(g,Te);g=g.slice(t.length),e={signals:t,retries:0,firstAt:Date.now(),dropped:d},d=0}if(!(!e||e.signals.length===0)){a=void 0;try{await tt(o.endpoint,"RecordSignals",E(e.signals,e.dropped),p)}catch(t){const i=t instanceof _e?t.status:0,r=t instanceof _e?t.retryAfterMs:void 0;if(!k&&Ye(e.retries,i)&&Date.now()-e.firstAt<Je){a={...e,retries:e.retries+1},h(et(e.retries+1,r));return}}g.length>0&&h(g.length>=Ee?0:ze)}},De=(e,t)=>{if(!(k||$>=mt)){for($++,g.push({eventId:I(),seq:++F,...e}),g.length>Ae&&(g=g.slice(-Ae));g.length>1&&we(g)>gt;)g=g.slice(1);t?(c!==void 0&&clearTimeout(c),c=void 0,h(0)):h(ze)}},le=new Map,W=new Map,K=new Map,ue=typeof s.appVersion=="string"&&ye.test(s.appVersion)?s.appVersion:void 0,Re=()=>{const e=o.getContext(),t={};for(const i of He){const r=e[i];typeof r=="string"&&ye.test(r)&&(t[i]=r)}return ue&&(t.appVersion=ue),t},Le=(e,t)=>{if(e==="int"&&typeof t=="number"&&Number.isFinite(t))return{intValue:String(Math.trunc(t))};if(e==="double"&&typeof t=="number"&&Number.isFinite(t))return{doubleValue:t};if(e==="bool"&&typeof t=="boolean")return{boolValue:t};if(e==="id"&&typeof t=="string"&&lt.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 +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
+ import{h as P,c as W,C as Y}from"./consent-bPengyOI.js";import{p as J,j as T,s as q,M as Q,m as z,r as Z}from"./transport-Wrkorx6z.js";function ee(n,u=globalThis.navigator){return n.respectGlobalPrivacyControl!==false&&u?.globalPrivacyControl===true}const M=50,x=32*1024,te=5e3,ne=1e3,ie=1e4,$=200,re=256*1024,f="HELP_EVENT_";function C(n,u){return n.version?{journeyId:n.journeyId,stepIndex:u,guideVersion:n.version}:{journeyId:n.journeyId,stepIndex:u}}const L=new Set([`${f}GUIDE_ABANDONED`,`${f}JOB_OUTCOME`]);function oe(n){return Math.min(Math.max(n??te,ne),ie)}function se(){return crypto.randomUUID()}function le(n){if(ee(n))return{checkin:()=>{},job:()=>{},stop:()=>{}};const u=n.fetchImpl??fetch,m=oe(n.flushMs),B=n.random??Math.random,k=n.newId??se;let t=[],o,s,l=false,y=false,_=0,g=0,r,A,N=false,j;const v=e=>{l||s||(s=setTimeout(()=>{s=void 0,D()},e))},K=()=>{for(t.length>$&&(t=t.slice(-$));t.length>0&&T(t)>re;)t=t.slice(1)},h=e=>{l||(_=_+1>>>0||1,t.push({...e,eventId:k(),seq:_}),K(),L.has(e.event)?(s&&clearTimeout(s),s=void 0,D()):v(m))},G=()=>{if(o)return o;if(t.length===0)return;const e=[];for(const i of t){if(e.length===M||e.length>0&&T([...e,i])>x)break;e.push(i)}return t=t.slice(e.length),{events:e,firstAttempt:Date.now(),retries:0}},b=e=>{const i={siteKey:n.siteKey,consentGiven:true,events:e};g>0&&(i.droppedAtUnload=g);const c=n.claims?.();return c&&(i.claims=c),i},D=async()=>{if(y||l)return;if(!P(n.siteKey)){t=[],o=void 0;return}if(typeof navigator<"u"&&navigator.onLine===false)return;const e=G();if(!e)return;if(o=void 0,Date.now()-e.firstAttempt>Q){t.length>0&&v(m);return}y=true;const i=g;try{await W(n.endpoint,"RecordHelpEvents",b(e.events),u),g-=i}catch(c){const d=c instanceof Y?c:void 0,a=d?.status??0;if(d?.code==="failed_precondition")l=true,t=[];else if(z(e.retries,a)){e.retries+=1,o=e,y=false,v(Z(e.retries,d?.retryAfterMs,B));return}}finally{y=false}!l&&(t.length>0||o)&&v(t.length>=M?0:m)},H=()=>{if(l&&t.length===0&&!o||(s&&clearTimeout(s),s=void 0,!P(n.siteKey)))return;const e=[...o?.events??[],...t];if(e.length===0)return;const i=[...e.filter(a=>L.has(a.event)),...e.filter(a=>!L.has(a.event))],c=Math.min(J(),x),d=[];for(const a of i){if(d.length===M||T(b([...d,a]))>c)break;d.push(a)}d.length!==0&&q(n.endpoint,"RecordHelpEvents",b(d),u)&&(g+=e.length-d.length,t=[],o=void 0)};let w=false;const I=()=>{w||(w=true,H())},R=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&I()},p=()=>{typeof document<"u"&&document.visibilityState!=="visible"||(w=false,(t.length>0||o)&&v(0))},U=()=>{(t.length>0||o)&&v(0)},S=()=>{r&&!r.done&&r.last!==void 0&&h({event:`${f}GUIDE_ABANDONED`,...C(r.guide,r.last)}),r=void 0,A=void 0},X=e=>{const i=j;if(j=e,i===void 0)return;if(e.view==="disabled"){l=true,t=[];return}i.view==="closed"&&(e.view==="index"||e.view==="guide")&&h({event:`${f}HELP_OPENED`,entry:e.view==="index"?"HELP_ENTRY_LAUNCHER":"HELP_ENTRY_API"});const c=e.view==="guide"||e.view==="finished"?e.guide:void 0,d=e.view==="guide"?e.journeyId:c?.journeyId;if(r&&d!==r.guide.journeyId&&S(),e.view==="guide"&&e.status==="ready"&&e.guide){r||(r={guide:e.guide,seen:new Set,done:false});const E=e.guide.steps[e.step],O=E&&`${e.guide.journeyId}/${e.step}`;E&&O!==A&&(A=O,r.last=E.index,h({event:`${f}${r.seen.has(E.index)?"STEP_REPEATED":"STEP_REACHED"}`,...C(e.guide,E.index)}),r.seen.add(E.index))}else e.view==="finished"&&r&&(r.done=true,S());const a=e.view==="index"&&e.status==="ready"&&e.query.trim()!==""&&e.results.length===0;a&&!N&&h({event:`${f}SEARCH_NO_RESULT`}),N=a},F=n.subscribe(X);addEventListener("pagehide",I),addEventListener("visibilitychange",R),addEventListener("visibilitychange",p),addEventListener("pageshow",p),addEventListener("online",U);const V=()=>{removeEventListener("pagehide",I),removeEventListener("visibilitychange",R),removeEventListener("visibilitychange",p),removeEventListener("pageshow",p),removeEventListener("online",U)};return{checkin(e){h({event:`${f}CHECKIN_ANSWERED`,...C(e.guide,e.step.index),answer:e.answer==="confused"?"CHECKIN_ANSWER_CONFUSED":"CHECKIN_ANSWER_UNDERSTOOD"})},job(e){const i={event:`${f}JOB_${e.event}`,jobId:e.jobId};e.jobVersion&&(i.jobVersion=e.jobVersion),e.persona&&(i.persona=e.persona),e.event==="OUTCOME"&&(i.jobAnswer=`JOB_ANSWER_${e.answer}`,e.harder!==void 0&&(i.harderThanExpected=e.harder)),h(i)},stop(e){if(F(),V(),!l){if(e){t=[],o=void 0,s&&clearTimeout(s),s=void 0,l=true;return}S(),l=true,H()}}}}export{te as FLUSH_MS,M as MAX_BATCH,x as MAX_BATCH_BYTES,ie as MAX_FLUSH_MS,$ as MAX_QUEUED,re as MAX_QUEUED_BYTES,ne as MIN_FLUSH_MS,ee as gpcRefusesTelemetry,le as startTelemetry};
@@ -1 +1 @@
1
- import{r as l,T as d,R as f}from"./consent-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};
1
+ import{r as l,T as d,R as f}from"./consent-bPengyOI.js";const E=1e3,p=5,y=3,S=55*6e4;function h(e){return e===0||e===408||e===429||e===500||e===502||e===503||e===504}function _(e,n){return h(n)&&e<(n===0?y:p)}function T(e,n,o=Math.random){const t=Math.min(E*2**Math.max(e-1,0),f)*(.5+o());return Math.round(Math.max(Math.min(t,f),n??0))}const m=32*1024;function v(){try{return typeof Request<"u"&&"keepalive"in new Request("https://journeeze.invalid/",{method:"POST",keepalive:true})}catch{return false}}let r=0,u=false;function R(){if(u||typeof addEventListener!="function")return;u=true;const e=()=>{(typeof document>"u"||document.visibilityState==="visible")&&(r=0)};addEventListener("pageshow",e),addEventListener("visibilitychange",e)}function g(){return R(),Math.max(m-r,0)}function A(e,n,o,a=fetch){const t=JSON.stringify(o),i=new TextEncoder().encode(t).length;if(i>g())return false;const c=l(e,n);if(v()){r+=i;try{return a(c,{method:"POST",headers:{"content-type":d},body:t,keepalive:true,credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer"}).catch(()=>{}),true}catch{return false}}if(typeof navigator>"u"||typeof navigator.sendBeacon!="function")return false;const s=navigator.sendBeacon(c,new Blob([t],{type:d}));return s&&(r+=i),s}function b(e){return new TextEncoder().encode(JSON.stringify(e)).length}export{S as M,b as j,_ as m,g as p,T as r,A as s};
@@ -1,5 +1,5 @@
1
1
  import type { MountedWidget, MountOptions, WidgetModule } from "../../loader";
2
- import type { HelpJobEntry, JourneezeContext } from "../../types";
2
+ import type { GetGuideResponse, HelpJobEntry, JourneezeContext } from "../../types";
3
3
  import type { ConverseTransport, PlusItem } from "./converse";
4
4
  import { type Copy } from "./copy";
5
5
  import { type Chip, type ReportFacts } from "./model";
@@ -18,10 +18,12 @@ export interface ChatDeps {
18
18
  loadJobs?: () => Promise<HelpJobEntry[]>;
19
19
  /** A "+" menu item was chosen; default: the lazy capture chunk (`../capture/attach`). */
20
20
  onPlusItem?: (item: PlusItem) => void;
21
+ /** Reads a guide's steps and targets for the in-page outline; default `GetGuide`. */
22
+ loadGuide?: (journeyId: string) => Promise<GetGuideResponse>;
21
23
  }
22
24
  /** The page facts a turn's context is built from (feedback/v2 `context`). */
23
25
  export declare function pageFacts(options: MountOptions, ctx: Readonly<JourneezeContext>): ReportFacts;
24
26
  /** The opening chips, badged with the site's `widget.ui.chip.*` copy. */
25
- export declare function jobChips(jobs: readonly HelpJobEntry[], t: Copy): Chip[];
27
+ export declare function jobChips(jobs: readonly HelpJobEntry[], t: Copy, persona?: string): Chip[];
26
28
  export declare function mountChat(options: MountOptions, getContext: () => Readonly<JourneezeContext>, deps?: ChatDeps): MountedChat;
27
29
  export declare const mount: WidgetModule["mount"];
@@ -0,0 +1,12 @@
1
+ import type { HelpJobEntry } from "../../types";
2
+ /** The guide `Converse` plays for `job`: the job's own, else `persona`'s; none: no guide yet. */
3
+ export declare function guideFor(job: HelpJobEntry, persona: string | undefined): {
4
+ journeyId: string;
5
+ stepCount: number;
6
+ } | undefined;
7
+ /** Where the conversation is in a guide: 1-based `step`, and the step count the server sent. */
8
+ export interface GuidePosition {
9
+ jobId: string;
10
+ step: number;
11
+ of?: number | undefined;
12
+ }
@@ -100,6 +100,12 @@ export declare class ChatSession {
100
100
  close(): void;
101
101
  /** Opening the chat again after a close starts a new conversation (consent is kept). */
102
102
  reopen(): void;
103
+ /** The guide step the conversation is on (1-based), while it is on one and open; else none. */
104
+ guidePosition(): {
105
+ jobId: string;
106
+ step: number;
107
+ of?: number | undefined;
108
+ } | undefined;
103
109
  offers(type: ConverseAction["type"]): boolean;
104
110
  /** The server's label of an action on offer ("" when it is not offered or has none). */
105
111
  label(type: ConverseAction["type"]): string;
@@ -0,0 +1,49 @@
1
+ import type { GetGuideResponse } from "../../types";
2
+ import { type AnchorResult, type StepTarget } from "../../help/core/highlight";
3
+ import type { GuidePosition } from "./guide";
4
+ /** A guide's steps in order, each as its targets (unknown strategies dropped; a lone tflo id when none). */
5
+ export declare function guideTargets(g: GetGuideResponse): StepTarget[][];
6
+ export interface WalkerDeps {
7
+ /** The guide played for a job (from the opening job list), or `undefined`. */
8
+ journeyFor(jobId: string): string | undefined;
9
+ loadGuide(journeyId: string): Promise<GetGuideResponse>;
10
+ highlight(targets: readonly StepTarget[] | undefined): AnchorResult | Promise<AnchorResult>;
11
+ clearHighlight(): void;
12
+ }
13
+ /** Keeps the page outline on the conversation's current guide step. Never throws. */
14
+ export declare class GuideWalker {
15
+ private readonly deps;
16
+ private readonly guides;
17
+ private at;
18
+ /** Bumped on every move, so a guide that loads late never outlines a step already left. */
19
+ private seq;
20
+ /** What the last outline was for (`journeyId/step`), to skip redundant work on re-renders. */
21
+ private shown;
22
+ constructor(deps: WalkerDeps);
23
+ /** The conversation moved (or left the guide: `undefined`). */
24
+ sync(pos: GuidePosition | undefined): void;
25
+ /** The host's route or layout changed: find the current step's element again. */
26
+ refresh(): void;
27
+ stop(): void;
28
+ private point;
29
+ private guide;
30
+ }
31
+ export interface WalkOptions {
32
+ endpoint: string;
33
+ siteKey: string;
34
+ reviewerToken?: string | undefined;
35
+ claims?: (() => Promise<string | undefined>) | undefined;
36
+ /** The chat's shadow root: the outline is drawn there (captures drop it with the chat). */
37
+ root: ShadowRoot;
38
+ /** The host's CSP nonce for the injected style. */
39
+ nonce?: string | undefined;
40
+ journeyFor(jobId: string): string | undefined;
41
+ /** Test seam; default `GetGuide`. */
42
+ loadGuide?: ((journeyId: string) => Promise<GetGuideResponse>) | undefined;
43
+ }
44
+ /** The walker over the chat's shadow root, with its highlighter. `dispose()` removes the outline. */
45
+ export declare function createWalk(o: WalkOptions): {
46
+ walker: GuideWalker;
47
+ dispose(): void;
48
+ };
49
+ export type Walk = ReturnType<typeof createWalk>;
@@ -1,4 +1,4 @@
1
- import{b as Te}from"./loader-k4pePzAw.js";import{j as Ae,c as Ne,w as ke}from"./consent-BupCs23W.js";const xe=new Set(["cc-number","cc-csc","cc-exp","cc-exp-month","cc-exp-year"]),Re=new Set(["current-password","new-password"]),_e=/\b(?:password|passcode|ssn|social security(?: number)?|card number|cvc|cvv|iban|api key|secret|token)\b/,F=512,De=/(?:^|[^A-Za-z0-9_-])(?:sk-[A-Za-z0-9_-]{16,}|sk_(?:live|test)_[A-Za-z0-9]{16,}|ghp_[A-Za-z0-9]{36}|xox[bp]-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+)/,Ie=/(?:\d[ -]?){12,18}\d/g,Pe=/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/;function Fe(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z])([A-Z][a-z])/g,"$1 $2").replace(/[_.\-:[\]]+/g," ").toLowerCase()}const U=e=>!!e&&_e.test(Fe(e));function Le(e){const t=e.getAttribute("autocomplete");if(t)for(const r of t.trim().toLowerCase().split(/\s+/)){if(xe.has(r))return"autocomplete_cc";if(r==="one-time-code")return"autocomplete_otp";if(Re.has(r))return"autocomplete_password"}}function $e(e){const t=[],r=e.getAttribute("aria-label");r&&t.push(r);const n=e.ownerDocument;for(const o of(e.getAttribute("aria-labelledby")??"").split(/\s+/)){const a=o?n?.getElementById(o)?.textContent:void 0;a&&t.push(a.slice(0,F))}const s=e.labels;if(s)for(const o of Array.from(s))t.push((o.textContent??"").slice(0,F));return t}function Me(e){let t="";for(const r of Array.from(e.childNodes))if(r.nodeType===3&&(t+=r.data),t.length>=F)break;return t.slice(0,F)}function Oe(e){let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(e.length-1-r)-48;r%2===1&&(n*=2,n>9&&(n-=9)),t+=n}return t%10===0}function Ue(e){for(const t of e.matchAll(Ie)){const r=t[0].replace(/[ -]/g,"");if(r.length>=13&&r.length<=19&&Oe(r))return true}return false}function B(e){if(/^(?:style|script)$/i.test(e.tagName))return;const t=Le(e);if(t)return t;if(e.tagName==="INPUT"&&(e.getAttribute("type")??"").trim().toLowerCase()==="password")return"input_password";if(U(e.getAttribute("name"))||U(e.id))return"name_sensitive";if($e(e).some(U))return"label_sensitive";const r=Me(e);if(r.trim()!==""){if(De.test(r))return"value_key_shaped";if(Ue(r))return"value_card_shaped";if(Pe.test(r))return"value_email_shaped"}}function Be(e){const t=e.getAttribute("data-tflow-id");if(t)return`[data-tflow-id="${X(t)}"]`;const r=e.getAttribute("data-testid");if(r)return`[data-testid="${X(r)}"]`;const n=[];for(let s=e;s&&n.length<6;s=s.parentElement){const o=s.tagName.toLowerCase();if(o==="html"||o==="body")break;const a=s.parentElement,i=a?Array.from(a.children).filter(l=>l.tagName===s.tagName).indexOf(s)+1:1;n.unshift(`${o}:nth-of-type(${i})`)}return n.join(" > ")||e.tagName.toLowerCase()}function X(e){return e.replace(/["\\]/g,"\\$&").slice(0,96)}function gr(e,t=()=>false){const r=[],n=s=>{if(t(s))return;const o=B(s);if(o){r.push({rule:o,selector:Be(s)});return}for(const a of Array.from(s.children))n(a)};for(const s of Array.from(e.children))n(s);return r}const ne="[modern-screenshot]",N=typeof window<"u",ze=N&&"Worker"in window,j=N?window.navigator?.userAgent:"",oe=j.includes("Chrome"),L=j.includes("AppleWebKit")&&!oe,V=j.includes("Firefox"),We=e=>e&&"__CONTEXT__"in e,je=e=>e.constructor.name==="CSSFontFaceRule",Ve=e=>e.constructor.name==="CSSImportRule",qe=e=>e.constructor.name==="CSSLayerBlockRule",E=e=>e.nodeType===1,I=e=>typeof e.className=="object",se=e=>e.tagName==="image",He=e=>e.tagName==="use",R=e=>E(e)&&typeof e.style<"u"&&!I(e),Xe=e=>e.nodeType===8,Ze=e=>e.nodeType===3,k=e=>e.tagName==="IMG",$=e=>e.tagName==="VIDEO",Ge=e=>e.tagName==="CANVAS",Ke=e=>e.tagName==="TEXTAREA",Ye=e=>e.tagName==="INPUT",Je=e=>e.tagName==="STYLE",Qe=e=>e.tagName==="SCRIPT",et=e=>e.tagName==="SELECT",tt=e=>e.tagName==="SLOT",rt=e=>e.tagName==="IFRAME",nt=(...e)=>console.warn(ne,...e);function ot(e){const t=e?.createElement?.("canvas");return t&&(t.height=t.width=1),!!t&&"toDataURL"in t&&!!t.toDataURL("image/webp").includes("image/webp")}const z=e=>e.startsWith("data:");function ie(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(N&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!N)return e;const r=M().implementation.createHTMLDocument(),n=r.createElement("base"),s=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(s),t&&(n.href=t),s.href=e,s.href}function M(e){return(e&&E(e)?e?.ownerDocument:e)??window.document}const O="http://www.w3.org/2000/svg";function st(e,t,r){const n=M(r).createElementNS(O,"svg");return n.setAttributeNS(null,"width",e.toString()),n.setAttributeNS(null,"height",t.toString()),n.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),n}function it(e,t){let r=new XMLSerializer().serializeToString(e);return t&&(r=r.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`}function at(e,t){return new Promise((r,n)=>{const s=new FileReader;s.onload=()=>r(s.result),s.onerror=()=>n(s.error),s.onabort=()=>n(new Error(`Failed read blob to ${t}`)),s.readAsDataURL(e)})}const ct=e=>at(e,"dataUrl");function A(e,t){const r=M(t).createElement("img");return r.decoding="sync",r.loading="eager",r.src=e,r}function _(e,t){return new Promise(r=>{const{timeout:n,ownerDocument:s,onError:o,onWarn:a}=t??{},i=typeof e=="string"?A(e,M(s)):e;let l=null,m=null;function c(){r(i),l&&clearTimeout(l),m?.()}if(n&&(l=setTimeout(c,n)),$(i)){const g=i.currentSrc||i.src;if(!g)return i.poster?_(i.poster,t).then(r):c();if(i.readyState>=2)return c();const h=c,f=d=>{a?.("Failed video load",g,d),o?.(d),c()};m=()=>{i.removeEventListener("loadeddata",h),i.removeEventListener("error",f)},i.addEventListener("loadeddata",h,{once:true}),i.addEventListener("error",f,{once:true})}else{const g=se(i)?i.href.baseVal:i.currentSrc||i.src;if(!g)return c();const h=async()=>{if(k(i)&&"decode"in i)try{await i.decode()}catch(d){a?.("Failed to decode image, trying to render anyway",i.dataset.originalSrc||g,d)}c()},f=d=>{a?.("Failed image load",i.dataset.originalSrc||g,d),c()};if(k(i)&&i.complete)return h();m=()=>{i.removeEventListener("load",h),i.removeEventListener("error",f)},i.addEventListener("load",h,{once:true}),i.addEventListener("error",f,{once:true})}})}async function lt(e,t){R(e)&&(k(e)||$(e)?await _(e,t):await Promise.all(["img","video"].flatMap(r=>Array.from(e.querySelectorAll(r)).map(n=>_(n,t)))))}const ae=(function(){let t=0;const r=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${r()}${t}`)})();function ce(e){return e?.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}let Z=0;function ut(e){const t=`${ne}[#${Z}]`;return Z++,{time:r=>e&&console.time(`${t} ${r}`),timeEnd:r=>e&&console.timeEnd(`${t} ${r}`),warn:(...r)=>e&&nt(...r)}}function ft(e){return{cache:e?"no-cache":"force-cache"}}async function le(e,t){return We(e)?e:dt(e,{...t,autoDestruct:true})}async function dt(e,t){const{scale:r=1,workerUrl:n,workerNumber:s=1}=t||{},o=!!t?.debug,a=t?.features??true,i=e.ownerDocument??(N?window.document:void 0),l=e.ownerDocument?.defaultView??(N?window:void 0),m=new Map,c={width:0,height:0,quality:1,type:"image/png",scale:r,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:o,fetch:{requestInit:ft(t?.fetch?.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:false,...t?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:s,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:false,...t,__CONTEXT__:true,log:ut(o),node:e,ownerDocument:i,ownerWindow:l,dpi:r===1?null:96*r,svgStyleElement:ue(i),svgDefsElement:i?.createElementNS(O,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:ze&&n&&s?s:0})].map(()=>{try{const f=new Worker(n);return f.onmessage=async d=>{const{url:u,result:p}=d.data;p?m.get(u)?.resolve?.(p):m.get(u)?.reject?.(new Error(`Error receiving message from worker: ${u}`))},f.onmessageerror=d=>{const{url:u}=d.data;m.get(u)?.reject?.(new Error(`Error receiving message from worker: ${u}`))},f}catch(f){return c.log.warn("Failed to new Worker",f),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[ot(i)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:m,drawImageCount:0,tasks:[],features:a,isEnable:f=>f==="restoreScrollPosition"?typeof a=="boolean"?false:a[f]??false:typeof a=="boolean"?a:a[f]??true,shadowRoots:[]};c.log.time("wait until load"),await lt(e,{timeout:c.timeout,onWarn:c.log.warn}),c.log.timeEnd("wait until load");const{width:g,height:h}=mt(e,c);return c.width=g,c.height=h,c}function ue(e){if(!e)return;const t=e.createElement("style"),r=t.ownerDocument.createTextNode(`
1
+ import{b as Te}from"./loader-DHgG5Y7t.js";import{k as Ae,c as Ne,w as ke}from"./consent-bPengyOI.js";const xe=new Set(["cc-number","cc-csc","cc-exp","cc-exp-month","cc-exp-year"]),Re=new Set(["current-password","new-password"]),_e=/\b(?:password|passcode|ssn|social security(?: number)?|card number|cvc|cvv|iban|api key|secret|token)\b/,F=512,De=/(?:^|[^A-Za-z0-9_-])(?:sk-[A-Za-z0-9_-]{16,}|sk_(?:live|test)_[A-Za-z0-9]{16,}|ghp_[A-Za-z0-9]{36}|xox[bp]-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+)/,Ie=/(?:\d[ -]?){12,18}\d/g,Pe=/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/;function Fe(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z])([A-Z][a-z])/g,"$1 $2").replace(/[_.\-:[\]]+/g," ").toLowerCase()}const U=e=>!!e&&_e.test(Fe(e));function Le(e){const t=e.getAttribute("autocomplete");if(t)for(const r of t.trim().toLowerCase().split(/\s+/)){if(xe.has(r))return"autocomplete_cc";if(r==="one-time-code")return"autocomplete_otp";if(Re.has(r))return"autocomplete_password"}}function $e(e){const t=[],r=e.getAttribute("aria-label");r&&t.push(r);const n=e.ownerDocument;for(const o of(e.getAttribute("aria-labelledby")??"").split(/\s+/)){const a=o?n?.getElementById(o)?.textContent:void 0;a&&t.push(a.slice(0,F))}const s=e.labels;if(s)for(const o of Array.from(s))t.push((o.textContent??"").slice(0,F));return t}function Me(e){let t="";for(const r of Array.from(e.childNodes))if(r.nodeType===3&&(t+=r.data),t.length>=F)break;return t.slice(0,F)}function Oe(e){let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(e.length-1-r)-48;r%2===1&&(n*=2,n>9&&(n-=9)),t+=n}return t%10===0}function Ue(e){for(const t of e.matchAll(Ie)){const r=t[0].replace(/[ -]/g,"");if(r.length>=13&&r.length<=19&&Oe(r))return true}return false}function B(e){if(/^(?:style|script)$/i.test(e.tagName))return;const t=Le(e);if(t)return t;if(e.tagName==="INPUT"&&(e.getAttribute("type")??"").trim().toLowerCase()==="password")return"input_password";if(U(e.getAttribute("name"))||U(e.id))return"name_sensitive";if($e(e).some(U))return"label_sensitive";const r=Me(e);if(r.trim()!==""){if(De.test(r))return"value_key_shaped";if(Ue(r))return"value_card_shaped";if(Pe.test(r))return"value_email_shaped"}}function Be(e){const t=e.getAttribute("data-tflow-id");if(t)return`[data-tflow-id="${X(t)}"]`;const r=e.getAttribute("data-testid");if(r)return`[data-testid="${X(r)}"]`;const n=[];for(let s=e;s&&n.length<6;s=s.parentElement){const o=s.tagName.toLowerCase();if(o==="html"||o==="body")break;const a=s.parentElement,i=a?Array.from(a.children).filter(l=>l.tagName===s.tagName).indexOf(s)+1:1;n.unshift(`${o}:nth-of-type(${i})`)}return n.join(" > ")||e.tagName.toLowerCase()}function X(e){return e.replace(/["\\]/g,"\\$&").slice(0,96)}function gr(e,t=()=>false){const r=[],n=s=>{if(t(s))return;const o=B(s);if(o){r.push({rule:o,selector:Be(s)});return}for(const a of Array.from(s.children))n(a)};for(const s of Array.from(e.children))n(s);return r}const ne="[modern-screenshot]",N=typeof window<"u",ze=N&&"Worker"in window,j=N?window.navigator?.userAgent:"",oe=j.includes("Chrome"),L=j.includes("AppleWebKit")&&!oe,V=j.includes("Firefox"),We=e=>e&&"__CONTEXT__"in e,je=e=>e.constructor.name==="CSSFontFaceRule",Ve=e=>e.constructor.name==="CSSImportRule",qe=e=>e.constructor.name==="CSSLayerBlockRule",E=e=>e.nodeType===1,I=e=>typeof e.className=="object",se=e=>e.tagName==="image",He=e=>e.tagName==="use",R=e=>E(e)&&typeof e.style<"u"&&!I(e),Xe=e=>e.nodeType===8,Ze=e=>e.nodeType===3,k=e=>e.tagName==="IMG",$=e=>e.tagName==="VIDEO",Ge=e=>e.tagName==="CANVAS",Ke=e=>e.tagName==="TEXTAREA",Ye=e=>e.tagName==="INPUT",Je=e=>e.tagName==="STYLE",Qe=e=>e.tagName==="SCRIPT",et=e=>e.tagName==="SELECT",tt=e=>e.tagName==="SLOT",rt=e=>e.tagName==="IFRAME",nt=(...e)=>console.warn(ne,...e);function ot(e){const t=e?.createElement?.("canvas");return t&&(t.height=t.width=1),!!t&&"toDataURL"in t&&!!t.toDataURL("image/webp").includes("image/webp")}const z=e=>e.startsWith("data:");function ie(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(N&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!N)return e;const r=M().implementation.createHTMLDocument(),n=r.createElement("base"),s=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(s),t&&(n.href=t),s.href=e,s.href}function M(e){return(e&&E(e)?e?.ownerDocument:e)??window.document}const O="http://www.w3.org/2000/svg";function st(e,t,r){const n=M(r).createElementNS(O,"svg");return n.setAttributeNS(null,"width",e.toString()),n.setAttributeNS(null,"height",t.toString()),n.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),n}function it(e,t){let r=new XMLSerializer().serializeToString(e);return t&&(r=r.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`}function at(e,t){return new Promise((r,n)=>{const s=new FileReader;s.onload=()=>r(s.result),s.onerror=()=>n(s.error),s.onabort=()=>n(new Error(`Failed read blob to ${t}`)),s.readAsDataURL(e)})}const ct=e=>at(e,"dataUrl");function A(e,t){const r=M(t).createElement("img");return r.decoding="sync",r.loading="eager",r.src=e,r}function _(e,t){return new Promise(r=>{const{timeout:n,ownerDocument:s,onError:o,onWarn:a}=t??{},i=typeof e=="string"?A(e,M(s)):e;let l=null,m=null;function c(){r(i),l&&clearTimeout(l),m?.()}if(n&&(l=setTimeout(c,n)),$(i)){const g=i.currentSrc||i.src;if(!g)return i.poster?_(i.poster,t).then(r):c();if(i.readyState>=2)return c();const h=c,f=d=>{a?.("Failed video load",g,d),o?.(d),c()};m=()=>{i.removeEventListener("loadeddata",h),i.removeEventListener("error",f)},i.addEventListener("loadeddata",h,{once:true}),i.addEventListener("error",f,{once:true})}else{const g=se(i)?i.href.baseVal:i.currentSrc||i.src;if(!g)return c();const h=async()=>{if(k(i)&&"decode"in i)try{await i.decode()}catch(d){a?.("Failed to decode image, trying to render anyway",i.dataset.originalSrc||g,d)}c()},f=d=>{a?.("Failed image load",i.dataset.originalSrc||g,d),c()};if(k(i)&&i.complete)return h();m=()=>{i.removeEventListener("load",h),i.removeEventListener("error",f)},i.addEventListener("load",h,{once:true}),i.addEventListener("error",f,{once:true})}})}async function lt(e,t){R(e)&&(k(e)||$(e)?await _(e,t):await Promise.all(["img","video"].flatMap(r=>Array.from(e.querySelectorAll(r)).map(n=>_(n,t)))))}const ae=(function(){let t=0;const r=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${r()}${t}`)})();function ce(e){return e?.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}let Z=0;function ut(e){const t=`${ne}[#${Z}]`;return Z++,{time:r=>e&&console.time(`${t} ${r}`),timeEnd:r=>e&&console.timeEnd(`${t} ${r}`),warn:(...r)=>e&&nt(...r)}}function ft(e){return{cache:e?"no-cache":"force-cache"}}async function le(e,t){return We(e)?e:dt(e,{...t,autoDestruct:true})}async function dt(e,t){const{scale:r=1,workerUrl:n,workerNumber:s=1}=t||{},o=!!t?.debug,a=t?.features??true,i=e.ownerDocument??(N?window.document:void 0),l=e.ownerDocument?.defaultView??(N?window:void 0),m=new Map,c={width:0,height:0,quality:1,type:"image/png",scale:r,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:o,fetch:{requestInit:ft(t?.fetch?.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:false,...t?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:s,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:false,...t,__CONTEXT__:true,log:ut(o),node:e,ownerDocument:i,ownerWindow:l,dpi:r===1?null:96*r,svgStyleElement:ue(i),svgDefsElement:i?.createElementNS(O,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:ze&&n&&s?s:0})].map(()=>{try{const f=new Worker(n);return f.onmessage=async d=>{const{url:u,result:p}=d.data;p?m.get(u)?.resolve?.(p):m.get(u)?.reject?.(new Error(`Error receiving message from worker: ${u}`))},f.onmessageerror=d=>{const{url:u}=d.data;m.get(u)?.reject?.(new Error(`Error receiving message from worker: ${u}`))},f}catch(f){return c.log.warn("Failed to new Worker",f),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[ot(i)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:m,drawImageCount:0,tasks:[],features:a,isEnable:f=>f==="restoreScrollPosition"?typeof a=="boolean"?false:a[f]??false:typeof a=="boolean"?a:a[f]??true,shadowRoots:[]};c.log.time("wait until load"),await lt(e,{timeout:c.timeout,onWarn:c.log.warn}),c.log.timeEnd("wait until load");const{width:g,height:h}=mt(e,c);return c.width=g,c.height=h,c}function ue(e){if(!e)return;const t=e.createElement("style"),r=t.ownerDocument.createTextNode(`
2
2
  .______background-clip--text {
3
3
  background-clip: text;
4
4
  -webkit-background-clip: text;
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty;var l=(i,e,t)=>e in i?a(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t;var r=(i,e,t)=>l(i,typeof e!="symbol"?e+"":e,t);import{H as c,a as p}from"./highlight-pU9nE3Qj.js";const g=/^(tflow|testId|role|css)$/,u=".jz-help-highlight{position:fixed;z-index:2147483645;pointer-events:none;box-sizing:border-box;border:2px solid #3D63C9;border-radius:6px;box-shadow:0 0 0 4px rgb(61 99 201/20%)}";function f(i){return[...i.steps??[]].map((e,t)=>({st:e,at:e.index??t})).sort((e,t)=>e.at-t.at).map(({st:e})=>{const t=(e.targets??[]).filter(s=>g.test(s.strategy??"")&&s.value).map(s=>({by:s.strategy,value:s.value,name:s.name||void 0}));return t.length||!e.tflowId?t:[{by:"tflow",value:e.tflowId}]})}class w{constructor(e){r(this,"deps");r(this,"guides",new Map);r(this,"at");r(this,"seq",0);r(this,"shown");this.deps=e}sync(e){const t=e&&`${e.jobId}/${e.step}/${e.of??""}`,s=this.at&&`${this.at.jobId}/${this.at.step}/${this.at.of??""}`;t!==s&&(this.at=e,this.point(false))}refresh(){this.point(true)}stop(){this.at=void 0,this.seq++,this.shown=void 0,this.deps.clearHighlight()}point(e){const t=++this.seq,s=this.at,o=s&&this.deps.journeyFor(s.jobId);if(!s||!o){this.shown=void 0,this.deps.clearHighlight();return}const n=`${o}/${s.step}`;!e&&n===this.shown||this.guide(o).then(h=>{if(t!==this.seq)return;const d=h?.[s.step-1];if(!h||!d||s.of!==void 0&&s.of!==h.length){this.shown=void 0,this.deps.clearHighlight();return}this.shown=n;try{Promise.resolve(this.deps.highlight(d)).catch(()=>{})}catch{}})}guide(e){let t=this.guides.get(e);return t||(t=this.deps.loadGuide(e).then(s=>f(s),()=>{this.guides.delete(e)}),this.guides.set(e,t)),t}}function y(i){const e=document.createElement("style");e.textContent=u,i.nonce&&(e.nonce=i.nonce),i.root.append(e);const t=new c(i.root),s=new p({endpoint:i.endpoint,siteKey:i.siteKey,reviewerToken:i.reviewerToken,claims:i.claims}),o=new w({journeyFor:i.journeyFor,loadGuide:i.loadGuide??(n=>s.guide(n)),highlight:n=>t.show(n),clearHighlight:()=>t.hide()});return{walker:o,dispose(){o.stop(),t.dispose(),e.remove()}}}export{w as GuideWalker,y as createWalk,f as guideTargets};
@@ -1,4 +1,4 @@
1
- var $=Object.defineProperty;var N=(d,t,e)=>t in d?$(d,t,{enumerable:true,configurable:true,writable:true,value:e}):d[t]=e;var n=(d,t,e)=>N(d,typeof t!="symbol"?t+"":t,e);import{e as B,s as W,d as K,h as _,f as O,C as M,D as H,g as q,i as Y,j as G}from"./consent-BupCs23W.js";import{i as R}from"./loader-k4pePzAw.js";import{c as J,s as V,p as X}from"./upload-DkAWrJhn.js";import{m as St,u as Ft}from"./upload-DkAWrJhn.js";import{s as Z,R as Q}from"./hook-BRnJ-lTk.js";import{d as tt,i as I,e as et,a as ot}from"./anchor-BhsfeHwL.js";import{feedbackChannel as it,widgetConfig as st}from"./feedback-DtMDnAam.js";import{claimsSource as nt}from"./claims-BfpRuIu-.js";const S="jz:preview",w="mask-audit";function rt(){try{const d=new URL(location.href),t=d.searchParams.get("jz_preview");return t===null?sessionStorage.getItem(S)===w:(d.searchParams.delete("jz_preview"),history.replaceState(history.state,"",d.href),t===w?sessionStorage.setItem(S,w):sessionStorage.removeItem(S),t===w)}catch{return false}}const U='<path d="M9 9h.01"/><path d="M15 9h.01"/>',at={like:`<circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/>${U}`,dislike:`<circle cx="12" cy="12" r="10"/><path d="M16 16s-1.5-2-4-2-4 2-4 2"/>${U}`,understood:'<circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/>',confused:'<circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/>',close:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',persona:'<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>',step:'<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>',info:'<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>'};function x(d,t=20){const e=document.createElement("template");return e.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${at[d]}</svg>`,e.content.firstElementChild}const ct=`
1
+ var $=Object.defineProperty;var N=(d,t,e)=>t in d?$(d,t,{enumerable:true,configurable:true,writable:true,value:e}):d[t]=e;var n=(d,t,e)=>N(d,typeof t!="symbol"?t+"":t,e);import{f as B,s as W,d as K,h as _,g as O,C as M,D as H,i as q,j as Y,k as G}from"./consent-bPengyOI.js";import{i as R}from"./loader-DHgG5Y7t.js";import{c as J,s as V,p as X}from"./upload-KvsGqMEV.js";import{m as St,u as Ft}from"./upload-KvsGqMEV.js";import{s as Z,R as Q}from"./hook-M34sajh9.js";import{d as tt,i as I,e as et,a as ot}from"./anchor-bnZCZtbG.js";import{feedbackChannel as it,widgetConfig as st}from"./feedback-DeMvbZnh.js";import{claimsSource as nt}from"./claims-VKhPNjA7.js";const S="jz:preview",w="mask-audit";function rt(){try{const d=new URL(location.href),t=d.searchParams.get("jz_preview");return t===null?sessionStorage.getItem(S)===w:(d.searchParams.delete("jz_preview"),history.replaceState(history.state,"",d.href),t===w?sessionStorage.setItem(S,w):sessionStorage.removeItem(S),t===w)}catch{return false}}const U='<path d="M9 9h.01"/><path d="M15 9h.01"/>',at={like:`<circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/>${U}`,dislike:`<circle cx="12" cy="12" r="10"/><path d="M16 16s-1.5-2-4-2-4 2-4 2"/>${U}`,understood:'<circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/>',confused:'<circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/>',close:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',persona:'<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>',step:'<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>',info:'<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>'};function x(d,t=20){const e=document.createElement("template");return e.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${at[d]}</svg>`,e.content.firstElementChild}const ct=`
2
2
  :host { all: initial; }
3
3
  .jz {
4
4
  --jz-canvas:#F7F7F5; --jz-surface:#FFFFFF; --jz-raised:#F0F0EC; --jz-ink:#1D2024; --jz-muted:#5D636B;
@@ -115,4 +115,4 @@ var $=Object.defineProperty;var N=(d,t,e)=>t in d?$(d,t,{enumerable:true,configu
115
115
  @media (prefers-reduced-motion: reduce) {
116
116
  .jz *, .jz *::before, .jz *::after { animation-duration:1ms !important; transition-duration:1ms !important; }
117
117
  }
118
- `,dt=[["like","Like"],["dislike","Dislike"],["understood","Understood"],["confused","Confused"]],ht=5e3;function s(d,t={},...e){const o=document.createElement(d);for(const[i,r]of Object.entries(t))r===void 0||r===false||o.setAttribute(i,r===true?"":r);return o.append(...e),o}function lt(d,t,e,o){const i={pagePath:W(t),device:d.device||tt(e)},r=a=>{const c=d[a];typeof c=="string"&&c.trim()!==""&&(i[a]=c.trim())};return r("persona"),r("journeyId"),r("journeyStep"),r("businessType"),r("state"),o!==void 0&&(i.tflowId=o),i}class pt{constructor(t,e,o){n(this,"options");n(this,"getContext");n(this,"exit");n(this,"host",s("div",{"data-journeeze":""}));n(this,"root");n(this,"shell",s("div",{class:"jz"}));n(this,"layer",s("div",{class:"layer"}));n(this,"highlight",s("div",{class:"hl"}));n(this,"tag",s("div",{class:"tag mono"}));n(this,"live",s("div",{class:"sr","aria-live":"polite"}));n(this,"toggle");n(this,"channel");n(this,"outbox");n(this,"endpoint");n(this,"cleanups",[]);n(this,"phase","consent");n(this,"config",{});n(this,"pinCount",0);n(this,"popover");n(this,"fullShot");n(this,"fullShotOpener");n(this,"consentSheet");n(this,"checkin");n(this,"toastEl");n(this,"toastTimer");n(this,"lastCtx");n(this,"lastWhere");n(this,"askedSteps",new Set);n(this,"objectUrls",[]);n(this,"disposed",false);n(this,"exitTimer");n(this,"screenshotsUnavailable",false);n(this,"uploadNotFound",0);n(this,"pending",new Set);n(this,"signals");n(this,"configReady",Promise.resolve());n(this,"configLoaded",false);n(this,"maskAuditOn");n(this,"claims");this.options=t,this.getContext=e,this.exit=o,this.endpoint=K(t),this.claims=nt(t),this.claims.token(),this.signals=Z(t,this.endpoint,e),this.root=this.host.attachShadow({mode:"closed"}),this.root.append(s("style",t.nonce?{nonce:t.nonce}:{},ct),this.shell),this.toggle=s("button",{type:"button",class:"toggle","aria-pressed":"true","aria-label":"Feedback mode on. Exit feedback mode"},s("span",{class:"dot","aria-hidden":"true"}),s("span",{},"Feedback mode on"),s("span",{class:"exit","aria-hidden":"true"},"· Exit")),this.toggle.addEventListener("click",()=>this.exit());for(const i of["keydown","keyup","keypress"])this.shell.addEventListener(i,r=>this.onWidgetKey(r));this.highlight.append(this.tag),this.layer.append(this.highlight),this.shell.append(this.layer,this.toggle,this.live),this.channel=it(t,this.endpoint,{beforePersist:()=>this.stashPending(),onDropped:i=>this.toast(ut(i),true),claims:()=>this.claims.token()}),this.outbox=this.channel.outbox,document.body.append(this.host),this.listen(window,"keydown",i=>this.onKey(i)),this.lastCtx={...e()},this.lastWhere=j(),this.configReady=this.loadConfig(),this.maskAuditOn=!!t.reviewerToken&&rt(),this.maskAuditOn&&this.configReady.then(()=>this.maskAudit()),_(O(t))?this.startPointing():this.showConsent()}api(){return{unmount:t=>this.dispose(t),contextChanged:()=>this.onContextChanged()}}listen(t,e,o,i=false,r=false){t.addEventListener(e,o,{capture:i,passive:r}),this.cleanups.push(()=>t.removeEventListener(e,o,{capture:i}))}dispose(t){if(!this.disposed){this.disposed=true,this.claims.stop(),this.signals.stop(t);for(const e of this.cleanups.splice(0))e();this.exitTimer!==void 0&&clearTimeout(this.exitTimer),this.stashPending(),this.channel.dispose(),this.toastTimer!==void 0&&clearTimeout(this.toastTimer);for(const e of this.objectUrls.splice(0))URL.revokeObjectURL(e);this.host.remove()}}async loadConfig(){try{if(this.config=await st(this.endpoint,this.options.siteKey),this.configLoaded=true,this.config.consentText&&this.consentSheet){const t=this.consentSheet.querySelector("p");t&&(t.textContent=this.config.consentText)}this.config.enabled!==true&&(this.toast("Feedback isn't switched on for this site yet.",true),this.exitTimer=setTimeout(()=>{this.disposed||this.exit()},2500))}catch(t){t instanceof M&&t.status===404&&(this.toast("Feedback isn't set up on this site yet.",true),this.exitTimer=setTimeout(()=>{this.disposed||this.exit()},2500))}}showConsent(){this.phase="consent";const t=s("h2",{id:"jz-consent-title"},x("info",18),"Suggest an improvement"),e=s("button",{type:"button",class:"primary"},"Allow and continue"),o=s("button",{type:"button",class:"secondary"},"Not now"),i=s("div",{class:"sheet",role:"dialog","aria-modal":"false","aria-labelledby":"jz-consent-title"},t,s("p",{},this.config.consentText||(this.screenshotsAllowed()?H:q)),s("div",{class:"row"},e,o));e.addEventListener("click",()=>{Y(O(this.options)),i.remove(),this.consentSheet=void 0,this.startPointing(),this.toggle.focus()}),o.addEventListener("click",()=>this.exit()),this.trapTab(i),this.consentSheet=i,this.shell.append(i),e.focus()}startPointing(){this.phase="pointing",this.signals.start(this.configReady.then(()=>this.config)),this.announce("Feedback mode on. Click any part of the page to comment on it. Press Escape to exit."),this.listen(document,"pointermove",t=>this.onMove(t),true,true);for(const t of["pointerdown","mousedown","mouseup","pointerup"])this.listen(window,t,e=>this.swallow(e),true);for(const t of["touchstart","touchend"])this.listen(window,t,e=>{this.phase==="pointing"&&this.targetOf(e)&&e.stopPropagation()},true,true);this.listen(window,"click",t=>this.onClick(t),true),this.listen(window,"scroll",()=>this.reposition(),true,true),this.listen(window,"resize",()=>this.reposition(),false,true),this.outbox.flush()}targetOf(t){const e=t.composedPath();if(e.includes(this.host))return;const o=e[0];return o instanceof Element?o:void 0}swallow(t){this.phase!=="pointing"||!t.isTrusted||!this.targetOf(t)||(t.preventDefault(),t.stopPropagation())}onMove(t){const e=this.phase==="pointing"?this.targetOf(t):void 0;if(!e){this.highlight.style.display="none";return}const o=e.getBoundingClientRect(),i=R(e)||I(e);Object.assign(this.highlight.style,{display:"block",left:`${o.left}px`,top:`${o.top}px`,width:`${o.width}px`,height:`${o.height}px`}),this.highlight.classList.toggle("masked",i),this.tag.textContent=i?"Masked":et(e),this.tag.style.top=o.top<20?"0":"-18px"}onClick(t){if(this.phase!=="pointing"||!t.isTrusted)return;const e=this.targetOf(t);e&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),this.highlight.style.display="none",!I(e)&&this.openPopover(e,t.clientX,t.clientY))}openPopover(t,e,o){this.phase="composing";const i=this.screenshotsUnavailable||!this.screenshotsAllowed()?Promise.resolve(void 0):this.configReady.then(()=>this.configLoaded?J(document.body,this.maskOptions()):void 0).catch(()=>{}),r=ot(t,e,o),a=s("div",{class:"pin","aria-hidden":"true"},String(++this.pinCount));let c;const h=s("h2",{id:"jz-pop-title"},"How does this feel?"),f=s("button",{type:"button",class:"close","aria-label":"Close without sending"},x("close")),m=s("div",{class:"chips"}),g=this.getContext(),D=j(),F=(l,u,p)=>m.append(s("span",{class:"chip","aria-label":`${u}: ${p}`},x(l,12),p));g.persona&&F("persona","Persona",g.persona),g.journeyStep&&F("step","Journey step",g.journeyStep);const C=s("div",{class:"reactions",role:"radiogroup","aria-label":"Reaction"}),E=dt.map(([l,u])=>{const p=s("button",{type:"button",class:"reaction",role:"radio","aria-checked":"false","data-r":l},x(l),s("span",{},u));return p.addEventListener("click",()=>{c=c===l?void 0:l;for(const L of E)L.setAttribute("aria-checked",String(L.dataset.r===c));z()}),C.append(p),p}),k=s("textarea",{class:"comment","aria-label":"Comment (optional)",placeholder:"What could be improved?",maxlength:"4000"}),v=s("div",{class:"thumb hatch mono"},"CAPTURING"),T=s("span",{class:"note"},"Masked fields are hidden"),P=s("input",{type:"checkbox",class:"optout"}),A=s("label",{class:"optout-row",hidden:true},P,"Don't include screenshot"),b=s("button",{type:"button",class:"primary"},"Send"),y=s("div",{class:"pop",role:"dialog","aria-modal":"false","aria-labelledby":"jz-pop-title"},s("div",{class:"pop-head"},h,f),m,C,k,A,s("div",{class:"foot"},s("div",{class:"shot"},v,T),b)),z=()=>{b.disabled=c===void 0&&k.value.trim()===""};k.addEventListener("input",z),z(),i.then(l=>{if(this.popover?.el===y)if(v.textContent="",l){const u=URL.createObjectURL(l);this.objectUrls.push(u),v.classList.remove("hatch");const p=s("button",{type:"button",class:"shot-open","aria-label":"View screenshot full size"},s("img",{referrerpolicy:"no-referrer",src:u,alt:"Screenshot of this page with masked fields hidden"}));p.addEventListener("click",()=>this.openFullShot(u,p)),v.append(p),A.hidden=false}else v.textContent="No screenshot attached",T.textContent="Screenshot unavailable; your feedback still sends"}),f.addEventListener("click",()=>this.closePopover()),b.addEventListener("click",()=>{if(b.disabled)return;b.disabled=true;const l=k.value.trim(),u=!P.checked;this.closePopover(),this.deliver(r,c,l,u?i:Promise.resolve(void 0),g,D)}),this.trapTab(y),this.popover={el:y,pin:a,target:t,anchor:r},this.layer.append(a),this.shell.append(y),this.reposition(),E[0]?.focus()}closePopover(){if(this.popover){this.closeFullShot(),this.popover.el.remove(),this.popover.pin.remove(),this.popover=void 0;for(const t of this.objectUrls.splice(0))URL.revokeObjectURL(t);this.phase="pointing",this.toggle.focus()}}openFullShot(t,e){if(this.fullShot)return;const o=s("button",{type:"button",class:"close","aria-label":"Close full-size screenshot"},x("close")),i=s("div",{class:"shot-full",role:"dialog","aria-modal":"true","aria-label":"Screenshot"},s("img",{referrerpolicy:"no-referrer",src:t,alt:"Screenshot of this page with masked fields hidden"}),o);o.addEventListener("click",()=>this.closeFullShot()),this.trapTab(i),this.fullShot=i,this.fullShotOpener=e,this.shell.append(i),o.focus()}closeFullShot(){const t=this.fullShot;if(!t)return;this.fullShot=void 0,t.remove();const e=this.fullShotOpener;this.fullShotOpener=void 0,e?.focus()}maskOptions(){const{maskSelectors:t,maskAllText:e}=this.options,o=Array.isArray(this.config.maskSelectors)?this.config.maskSelectors:[];return{...t?{maskSelectors:t}:{},...o.length?{configMaskSelectors:o}:{},...e?{maskAllText:e}:{}}}reposition(){const t=this.popover;if(!t||!t.target.isConnected)return;const e=t.target.getBoundingClientRect(),o=e.left+t.anchor.xRatio*e.width,i=e.top+t.anchor.yRatio*e.height;if(Object.assign(t.pin.style,{left:`${o}px`,top:`${i}px`}),window.innerWidth<480)return;const r=t.el.getBoundingClientRect(),a=16;let c=e.right+a;c+r.width>window.innerWidth-a&&(c=e.left-a-r.width),c<a&&(c=Math.min(Math.max(a,o+a),window.innerWidth-r.width-a));const h=Math.min(Math.max(a,i-24),window.innerHeight-r.height-a);Object.assign(t.el.style,{left:`${Math.max(a,c)}px`,top:`${Math.max(a,h)}px`})}maskAudit(){if(this.disposed||!this.configLoaded||this.config.enabled!==true||!this.options.reviewerToken)return;const t=[...this.options.maskSelectors??[],...Array.isArray(this.config.maskSelectors)?this.config.maskSelectors:[]],{endpoint:e}=this,{siteKey:o,reviewerToken:i,pagePath:r}=this.options;import("./mask-audit-DtKNgOlT.js").then(a=>this.disposed?0:a.runMaskAudit({scan:V,endpoint:e,siteKey:o,reviewerToken:i,maskSelectors:t,...r?{pagePath:r}:{}})).catch(()=>{})}onContextChanged(){this.signals.contextChanged(),this.maskAuditOn&&this.maskAudit();const t=this.getContext();if(t.journeyStep===this.lastCtx.journeyStep&&t.journeyId===this.lastCtx.journeyId)return;const e=this.lastCtx,o=this.lastWhere;this.lastCtx={...t},this.lastWhere=j(),this.checkin?.remove(),this.checkin=void 0,this.maybeCheckin(e,o)}maybeCheckin(t,e){const o=t,i=o.journeyStep;if(this.phase==="consent"||!i)return;const r=`${o.journeyId??""}/${i}`;if(this.askedSteps.has(r))return;this.askedSteps.add(r),this.checkin?.remove();const a=(f,m)=>{const g=s("button",{type:"button",class:"secondary"},x(f,16),m);return g.addEventListener("click",()=>{h.remove(),this.deliver(void 0,f,"",Promise.resolve(void 0),t,e)}),g},c=s("button",{type:"button",class:"close","aria-label":"Dismiss"},x("close",16)),h=s("div",{class:"checkin",role:"group","aria-label":"Step check-in"},s("span",{},"Did this step make sense?"),a("understood","Understood"),a("confused","Confused"),c);c.addEventListener("click",()=>h.remove()),this.checkin=h,this.shell.append(h)}async deliver(t,e,o,i,r=this.getContext(),a=j()){const c={siteKey:this.options.siteKey,consentGiven:true,context:lt(r,a.href,a.width,t?.tflowId)};this.options.userId!==void 0&&Object.assign(c,{userId:this.options.userId},G(this.options)),t&&(c.anchor=t),e&&(c.reaction=Q[e]),o&&(c.comment=o);const h={request:c,stashed:false};this.pending.add(h);const f=await this.uploadScreenshot(i);if(this.pending.delete(h),h.stashed||this.disposed)return;f&&(c.screenshotId=f);const m=await this.outbox.enqueue(c);this.disposed||(m==="sent"?this.toast("Sent. Thank you."):m==="queued"&&this.toast("Saved. It will send when you're back online."))}stashPending(){for(const t of this.pending)t.stashed=true,this.outbox.stash(t.request);this.pending.clear()}screenshotsAllowed(){return!!(this.options.reviewerToken||this.options.userId||this.options.claims||this.options.getToken)}async uploadScreenshot(t){if(!this.screenshotsUnavailable)try{let e;const o=await Promise.race([t,new Promise(r=>e=setTimeout(()=>r(void 0),ht))]).finally(()=>clearTimeout(e));if(!o)return;const i=await X(this.endpoint,this.options,o,void 0,await this.claims.token());return this.uploadNotFound=0,i}catch(e){e instanceof M&&(this.uploadNotFound=e.status===404?this.uploadNotFound+1:0,(e.code==="unimplemented"||this.uploadNotFound>=3)&&(this.screenshotsUnavailable=true));return}}onKey(t){if(t.key!=="Escape")return;const e=t.composedPath()[0];if(t.defaultPrevented||e instanceof Element&&R(e))return;const o=document.activeElement;o&&o!==document.body&&o!==document.documentElement&&o!==this.host||(this.popover?this.closePopover():this.exit())}onWidgetKey(t){if(t.stopPropagation(),t.type!=="keydown"||t.key!=="Escape")return;if(this.fullShot){this.closeFullShot();return}const e=t.target;if(e instanceof HTMLTextAreaElement&&e.value.trim()!==""&&this.popover){this.popover.el.querySelector(".close")?.focus();return}this.popover?this.closePopover():this.exit()}trapTab(t){t.addEventListener("keydown",e=>{if(e.key!=="Tab")return;const o=Array.from(t.querySelectorAll("button:not([disabled]), textarea")),i=o[0],r=o[o.length-1],a=this.root.activeElement;!i||!r||(e.shiftKey&&a===i?(e.preventDefault(),r.focus()):!e.shiftKey&&a===r&&(e.preventDefault(),i.focus()))})}announce(t){this.live.textContent=t}toast(t,e=false){this.toastEl?.remove(),this.toastTimer!==void 0&&clearTimeout(this.toastTimer);const o=s("div",{class:e?"toast err":"toast",role:"status"},t);this.toastEl=o,this.shell.append(o),this.toastTimer=setTimeout(()=>o.remove(),e?6e3:3e3)}}function j(){return{href:location.href,width:window.innerWidth}}function ut(d){return d.code==="unauthenticated"?"Open the review link from your invitation to send feedback.":d.code==="failed_precondition"?"Consent is needed before feedback can be sent.":"This feedback couldn't be sent."}const wt=(d,t,e)=>new pt(d,()=>B(t()),e).api();export{St as maskedSnapshotSvg,wt as mount,G as signedIdentity,Ft as uploadTarget,lt as wireContext};
118
+ `,dt=[["like","Like"],["dislike","Dislike"],["understood","Understood"],["confused","Confused"]],ht=5e3;function s(d,t={},...e){const o=document.createElement(d);for(const[i,r]of Object.entries(t))r===void 0||r===false||o.setAttribute(i,r===true?"":r);return o.append(...e),o}function lt(d,t,e,o){const i={pagePath:W(t),device:d.device||tt(e)},r=a=>{const c=d[a];typeof c=="string"&&c.trim()!==""&&(i[a]=c.trim())};return r("persona"),r("journeyId"),r("journeyStep"),r("businessType"),r("state"),o!==void 0&&(i.tflowId=o),i}class pt{constructor(t,e,o){n(this,"options");n(this,"getContext");n(this,"exit");n(this,"host",s("div",{"data-journeeze":""}));n(this,"root");n(this,"shell",s("div",{class:"jz"}));n(this,"layer",s("div",{class:"layer"}));n(this,"highlight",s("div",{class:"hl"}));n(this,"tag",s("div",{class:"tag mono"}));n(this,"live",s("div",{class:"sr","aria-live":"polite"}));n(this,"toggle");n(this,"channel");n(this,"outbox");n(this,"endpoint");n(this,"cleanups",[]);n(this,"phase","consent");n(this,"config",{});n(this,"pinCount",0);n(this,"popover");n(this,"fullShot");n(this,"fullShotOpener");n(this,"consentSheet");n(this,"checkin");n(this,"toastEl");n(this,"toastTimer");n(this,"lastCtx");n(this,"lastWhere");n(this,"askedSteps",new Set);n(this,"objectUrls",[]);n(this,"disposed",false);n(this,"exitTimer");n(this,"screenshotsUnavailable",false);n(this,"uploadNotFound",0);n(this,"pending",new Set);n(this,"signals");n(this,"configReady",Promise.resolve());n(this,"configLoaded",false);n(this,"maskAuditOn");n(this,"claims");this.options=t,this.getContext=e,this.exit=o,this.endpoint=K(t),this.claims=nt(t),this.claims.token(),this.signals=Z(t,this.endpoint,e),this.root=this.host.attachShadow({mode:"closed"}),this.root.append(s("style",t.nonce?{nonce:t.nonce}:{},ct),this.shell),this.toggle=s("button",{type:"button",class:"toggle","aria-pressed":"true","aria-label":"Feedback mode on. Exit feedback mode"},s("span",{class:"dot","aria-hidden":"true"}),s("span",{},"Feedback mode on"),s("span",{class:"exit","aria-hidden":"true"},"· Exit")),this.toggle.addEventListener("click",()=>this.exit());for(const i of["keydown","keyup","keypress"])this.shell.addEventListener(i,r=>this.onWidgetKey(r));this.highlight.append(this.tag),this.layer.append(this.highlight),this.shell.append(this.layer,this.toggle,this.live),this.channel=it(t,this.endpoint,{beforePersist:()=>this.stashPending(),onDropped:i=>this.toast(ut(i),true),claims:()=>this.claims.token()}),this.outbox=this.channel.outbox,document.body.append(this.host),this.listen(window,"keydown",i=>this.onKey(i)),this.lastCtx={...e()},this.lastWhere=j(),this.configReady=this.loadConfig(),this.maskAuditOn=!!t.reviewerToken&&rt(),this.maskAuditOn&&this.configReady.then(()=>this.maskAudit()),_(O(t))?this.startPointing():this.showConsent()}api(){return{unmount:t=>this.dispose(t),contextChanged:()=>this.onContextChanged()}}listen(t,e,o,i=false,r=false){t.addEventListener(e,o,{capture:i,passive:r}),this.cleanups.push(()=>t.removeEventListener(e,o,{capture:i}))}dispose(t){if(!this.disposed){this.disposed=true,this.claims.stop(),this.signals.stop(t);for(const e of this.cleanups.splice(0))e();this.exitTimer!==void 0&&clearTimeout(this.exitTimer),this.stashPending(),this.channel.dispose(),this.toastTimer!==void 0&&clearTimeout(this.toastTimer);for(const e of this.objectUrls.splice(0))URL.revokeObjectURL(e);this.host.remove()}}async loadConfig(){try{if(this.config=await st(this.endpoint,this.options.siteKey),this.configLoaded=true,this.config.consentText&&this.consentSheet){const t=this.consentSheet.querySelector("p");t&&(t.textContent=this.config.consentText)}this.config.enabled!==true&&(this.toast("Feedback isn't switched on for this site yet.",true),this.exitTimer=setTimeout(()=>{this.disposed||this.exit()},2500))}catch(t){t instanceof M&&t.status===404&&(this.toast("Feedback isn't set up on this site yet.",true),this.exitTimer=setTimeout(()=>{this.disposed||this.exit()},2500))}}showConsent(){this.phase="consent";const t=s("h2",{id:"jz-consent-title"},x("info",18),"Suggest an improvement"),e=s("button",{type:"button",class:"primary"},"Allow and continue"),o=s("button",{type:"button",class:"secondary"},"Not now"),i=s("div",{class:"sheet",role:"dialog","aria-modal":"false","aria-labelledby":"jz-consent-title"},t,s("p",{},this.config.consentText||(this.screenshotsAllowed()?H:q)),s("div",{class:"row"},e,o));e.addEventListener("click",()=>{Y(O(this.options)),i.remove(),this.consentSheet=void 0,this.startPointing(),this.toggle.focus()}),o.addEventListener("click",()=>this.exit()),this.trapTab(i),this.consentSheet=i,this.shell.append(i),e.focus()}startPointing(){this.phase="pointing",this.signals.start(this.configReady.then(()=>this.config)),this.announce("Feedback mode on. Click any part of the page to comment on it. Press Escape to exit."),this.listen(document,"pointermove",t=>this.onMove(t),true,true);for(const t of["pointerdown","mousedown","mouseup","pointerup"])this.listen(window,t,e=>this.swallow(e),true);for(const t of["touchstart","touchend"])this.listen(window,t,e=>{this.phase==="pointing"&&this.targetOf(e)&&e.stopPropagation()},true,true);this.listen(window,"click",t=>this.onClick(t),true),this.listen(window,"scroll",()=>this.reposition(),true,true),this.listen(window,"resize",()=>this.reposition(),false,true),this.outbox.flush()}targetOf(t){const e=t.composedPath();if(e.includes(this.host))return;const o=e[0];return o instanceof Element?o:void 0}swallow(t){this.phase!=="pointing"||!t.isTrusted||!this.targetOf(t)||(t.preventDefault(),t.stopPropagation())}onMove(t){const e=this.phase==="pointing"?this.targetOf(t):void 0;if(!e){this.highlight.style.display="none";return}const o=e.getBoundingClientRect(),i=R(e)||I(e);Object.assign(this.highlight.style,{display:"block",left:`${o.left}px`,top:`${o.top}px`,width:`${o.width}px`,height:`${o.height}px`}),this.highlight.classList.toggle("masked",i),this.tag.textContent=i?"Masked":et(e),this.tag.style.top=o.top<20?"0":"-18px"}onClick(t){if(this.phase!=="pointing"||!t.isTrusted)return;const e=this.targetOf(t);e&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),this.highlight.style.display="none",!I(e)&&this.openPopover(e,t.clientX,t.clientY))}openPopover(t,e,o){this.phase="composing";const i=this.screenshotsUnavailable||!this.screenshotsAllowed()?Promise.resolve(void 0):this.configReady.then(()=>this.configLoaded?J(document.body,this.maskOptions()):void 0).catch(()=>{}),r=ot(t,e,o),a=s("div",{class:"pin","aria-hidden":"true"},String(++this.pinCount));let c;const h=s("h2",{id:"jz-pop-title"},"How does this feel?"),f=s("button",{type:"button",class:"close","aria-label":"Close without sending"},x("close")),m=s("div",{class:"chips"}),g=this.getContext(),D=j(),F=(l,u,p)=>m.append(s("span",{class:"chip","aria-label":`${u}: ${p}`},x(l,12),p));g.persona&&F("persona","Persona",g.persona),g.journeyStep&&F("step","Journey step",g.journeyStep);const C=s("div",{class:"reactions",role:"radiogroup","aria-label":"Reaction"}),E=dt.map(([l,u])=>{const p=s("button",{type:"button",class:"reaction",role:"radio","aria-checked":"false","data-r":l},x(l),s("span",{},u));return p.addEventListener("click",()=>{c=c===l?void 0:l;for(const L of E)L.setAttribute("aria-checked",String(L.dataset.r===c));z()}),C.append(p),p}),k=s("textarea",{class:"comment","aria-label":"Comment (optional)",placeholder:"What could be improved?",maxlength:"4000"}),v=s("div",{class:"thumb hatch mono"},"CAPTURING"),T=s("span",{class:"note"},"Masked fields are hidden"),P=s("input",{type:"checkbox",class:"optout"}),A=s("label",{class:"optout-row",hidden:true},P,"Don't include screenshot"),b=s("button",{type:"button",class:"primary"},"Send"),y=s("div",{class:"pop",role:"dialog","aria-modal":"false","aria-labelledby":"jz-pop-title"},s("div",{class:"pop-head"},h,f),m,C,k,A,s("div",{class:"foot"},s("div",{class:"shot"},v,T),b)),z=()=>{b.disabled=c===void 0&&k.value.trim()===""};k.addEventListener("input",z),z(),i.then(l=>{if(this.popover?.el===y)if(v.textContent="",l){const u=URL.createObjectURL(l);this.objectUrls.push(u),v.classList.remove("hatch");const p=s("button",{type:"button",class:"shot-open","aria-label":"View screenshot full size"},s("img",{referrerpolicy:"no-referrer",src:u,alt:"Screenshot of this page with masked fields hidden"}));p.addEventListener("click",()=>this.openFullShot(u,p)),v.append(p),A.hidden=false}else v.textContent="No screenshot attached",T.textContent="Screenshot unavailable; your feedback still sends"}),f.addEventListener("click",()=>this.closePopover()),b.addEventListener("click",()=>{if(b.disabled)return;b.disabled=true;const l=k.value.trim(),u=!P.checked;this.closePopover(),this.deliver(r,c,l,u?i:Promise.resolve(void 0),g,D)}),this.trapTab(y),this.popover={el:y,pin:a,target:t,anchor:r},this.layer.append(a),this.shell.append(y),this.reposition(),E[0]?.focus()}closePopover(){if(this.popover){this.closeFullShot(),this.popover.el.remove(),this.popover.pin.remove(),this.popover=void 0;for(const t of this.objectUrls.splice(0))URL.revokeObjectURL(t);this.phase="pointing",this.toggle.focus()}}openFullShot(t,e){if(this.fullShot)return;const o=s("button",{type:"button",class:"close","aria-label":"Close full-size screenshot"},x("close")),i=s("div",{class:"shot-full",role:"dialog","aria-modal":"true","aria-label":"Screenshot"},s("img",{referrerpolicy:"no-referrer",src:t,alt:"Screenshot of this page with masked fields hidden"}),o);o.addEventListener("click",()=>this.closeFullShot()),this.trapTab(i),this.fullShot=i,this.fullShotOpener=e,this.shell.append(i),o.focus()}closeFullShot(){const t=this.fullShot;if(!t)return;this.fullShot=void 0,t.remove();const e=this.fullShotOpener;this.fullShotOpener=void 0,e?.focus()}maskOptions(){const{maskSelectors:t,maskAllText:e}=this.options,o=Array.isArray(this.config.maskSelectors)?this.config.maskSelectors:[];return{...t?{maskSelectors:t}:{},...o.length?{configMaskSelectors:o}:{},...e?{maskAllText:e}:{}}}reposition(){const t=this.popover;if(!t||!t.target.isConnected)return;const e=t.target.getBoundingClientRect(),o=e.left+t.anchor.xRatio*e.width,i=e.top+t.anchor.yRatio*e.height;if(Object.assign(t.pin.style,{left:`${o}px`,top:`${i}px`}),window.innerWidth<480)return;const r=t.el.getBoundingClientRect(),a=16;let c=e.right+a;c+r.width>window.innerWidth-a&&(c=e.left-a-r.width),c<a&&(c=Math.min(Math.max(a,o+a),window.innerWidth-r.width-a));const h=Math.min(Math.max(a,i-24),window.innerHeight-r.height-a);Object.assign(t.el.style,{left:`${Math.max(a,c)}px`,top:`${Math.max(a,h)}px`})}maskAudit(){if(this.disposed||!this.configLoaded||this.config.enabled!==true||!this.options.reviewerToken)return;const t=[...this.options.maskSelectors??[],...Array.isArray(this.config.maskSelectors)?this.config.maskSelectors:[]],{endpoint:e}=this,{siteKey:o,reviewerToken:i,pagePath:r}=this.options;import("./mask-audit-KFvSiJU0.js").then(a=>this.disposed?0:a.runMaskAudit({scan:V,endpoint:e,siteKey:o,reviewerToken:i,maskSelectors:t,...r?{pagePath:r}:{}})).catch(()=>{})}onContextChanged(){this.signals.contextChanged(),this.maskAuditOn&&this.maskAudit();const t=this.getContext();if(t.journeyStep===this.lastCtx.journeyStep&&t.journeyId===this.lastCtx.journeyId)return;const e=this.lastCtx,o=this.lastWhere;this.lastCtx={...t},this.lastWhere=j(),this.checkin?.remove(),this.checkin=void 0,this.maybeCheckin(e,o)}maybeCheckin(t,e){const o=t,i=o.journeyStep;if(this.phase==="consent"||!i)return;const r=`${o.journeyId??""}/${i}`;if(this.askedSteps.has(r))return;this.askedSteps.add(r),this.checkin?.remove();const a=(f,m)=>{const g=s("button",{type:"button",class:"secondary"},x(f,16),m);return g.addEventListener("click",()=>{h.remove(),this.deliver(void 0,f,"",Promise.resolve(void 0),t,e)}),g},c=s("button",{type:"button",class:"close","aria-label":"Dismiss"},x("close",16)),h=s("div",{class:"checkin",role:"group","aria-label":"Step check-in"},s("span",{},"Did this step make sense?"),a("understood","Understood"),a("confused","Confused"),c);c.addEventListener("click",()=>h.remove()),this.checkin=h,this.shell.append(h)}async deliver(t,e,o,i,r=this.getContext(),a=j()){const c={siteKey:this.options.siteKey,consentGiven:true,context:lt(r,a.href,a.width,t?.tflowId)};this.options.userId!==void 0&&Object.assign(c,{userId:this.options.userId},G(this.options)),t&&(c.anchor=t),e&&(c.reaction=Q[e]),o&&(c.comment=o);const h={request:c,stashed:false};this.pending.add(h);const f=await this.uploadScreenshot(i);if(this.pending.delete(h),h.stashed||this.disposed)return;f&&(c.screenshotId=f);const m=await this.outbox.enqueue(c);this.disposed||(m==="sent"?this.toast("Sent. Thank you."):m==="queued"&&this.toast("Saved. It will send when you're back online."))}stashPending(){for(const t of this.pending)t.stashed=true,this.outbox.stash(t.request);this.pending.clear()}screenshotsAllowed(){return!!(this.options.reviewerToken||this.options.userId||this.options.claims||this.options.getToken)}async uploadScreenshot(t){if(!this.screenshotsUnavailable)try{let e;const o=await Promise.race([t,new Promise(r=>e=setTimeout(()=>r(void 0),ht))]).finally(()=>clearTimeout(e));if(!o)return;const i=await X(this.endpoint,this.options,o,void 0,await this.claims.token());return this.uploadNotFound=0,i}catch(e){e instanceof M&&(this.uploadNotFound=e.status===404?this.uploadNotFound+1:0,(e.code==="unimplemented"||this.uploadNotFound>=3)&&(this.screenshotsUnavailable=true));return}}onKey(t){if(t.key!=="Escape")return;const e=t.composedPath()[0];if(t.defaultPrevented||e instanceof Element&&R(e))return;const o=document.activeElement;o&&o!==document.body&&o!==document.documentElement&&o!==this.host||(this.popover?this.closePopover():this.exit())}onWidgetKey(t){if(t.stopPropagation(),t.type!=="keydown"||t.key!=="Escape")return;if(this.fullShot){this.closeFullShot();return}const e=t.target;if(e instanceof HTMLTextAreaElement&&e.value.trim()!==""&&this.popover){this.popover.el.querySelector(".close")?.focus();return}this.popover?this.closePopover():this.exit()}trapTab(t){t.addEventListener("keydown",e=>{if(e.key!=="Tab")return;const o=Array.from(t.querySelectorAll("button:not([disabled]), textarea")),i=o[0],r=o[o.length-1],a=this.root.activeElement;!i||!r||(e.shiftKey&&a===i?(e.preventDefault(),r.focus()):!e.shiftKey&&a===r&&(e.preventDefault(),i.focus()))})}announce(t){this.live.textContent=t}toast(t,e=false){this.toastEl?.remove(),this.toastTimer!==void 0&&clearTimeout(this.toastTimer);const o=s("div",{class:e?"toast err":"toast",role:"status"},t);this.toastEl=o,this.shell.append(o),this.toastTimer=setTimeout(()=>o.remove(),e?6e3:3e3)}}function j(){return{href:location.href,width:window.innerWidth}}function ut(d){return d.code==="unauthenticated"?"Open the review link from your invitation to send feedback.":d.code==="failed_precondition"?"Consent is needed before feedback can be sent.":"This feedback couldn't be sent."}const wt=(d,t,e)=>new pt(d,()=>B(t()),e).api();export{St as maskedSnapshotSvg,wt as mount,G as signedIdentity,Ft as uploadTarget,lt as wireContext};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@journeeze/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.0-rc.1",
4
4
  "description": "In-app help and opt-in, element-anchored feedback for your web app, with triage and GitHub issues through Journeeze.",
5
5
  "homepage": "https://journeeze.dev",
6
6
  "keywords": [
@@ -1,64 +0,0 @@
1
- var X=Object.defineProperty;var Y=(i,e,t)=>e in i?X(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t;var c=(i,e,t)=>Y(i,typeof e!="symbol"?e+"":e,t);import{c as q,C as Q,j as Z,d as ee,i as te,f as H,h as ne,s as ie,e as re}from"./consent-BupCs23W.js";const ae="journeeze.turn/v1";class se extends Error{constructor(t,n){super(t);c(this,"kind");c(this,"status");this.kind=t,this.status=n}}function L(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const i=crypto.getRandomValues(new Uint8Array(16));i[6]=i[6]&15|64,i[8]=i[8]&63|128;const e=[...i].map(t=>t.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function oe(i){const e=i instanceof Q?i.status:0,t=e===429?"busy":e===400?"invalid":"unavailable";return new se(t,e)}function de(i,e=(...t)=>fetch(...t)){return{turn:t=>q(i,"Converse",t,e).then(n=>({...n,messages:n.messages??[],actions:n.actions??[],requiresConsent:!!n.requiresConsent}),n=>{throw oe(n)})}}function le(i,e,t,n){const r=de(i,t);return{turn:async d=>{const h=await n?.();return r.turn({...d,...e.reviewerToken&&{reviewerToken:e.reviewerToken},...d.consentGiven&&e.userId&&{userId:e.userId,...Z(e)},...h&&{claims:h}})}}}const ce="Help";function pe(i){return(e,t)=>(i?.["widget.ui."+e]??"").replace(/\{(\w+)\}/g,(n,r)=>String(t?.[r]??""))}function he(i,e){const t=e.toLowerCase().split(/\s+/).filter(Boolean);return i.filter(n=>t.every(r=>n.title.toLowerCase().includes(r)))}function ue(i){return typeof i.steps=="number"&&i.steps>0?i.steps:void 0}function fe(i){return/Edg\//.test(i)?"Edge":/Firefox\//.test(i)?"Firefox":/Chrome\/|CriOS\//.test(i)?"Chrome":/Safari\//.test(i)?"Safari":"Other"}function be(i,e,t){const n=[],r=(d,h,o=true)=>{h&&!e.has(d)&&n.push({key:d,label:h,removable:o})};return r("page",i.pagePath&&t("context.page",{value:i.pagePath})),r("job",i.job,false),r("step",i.step!==void 0&&t("context.step",{step:i.step}),false),r("persona",i.persona&&t("context.persona",{value:i.persona})),r("browser",i.browser),r("device",i.device&&(i.viewport?`${i.device} · ${i.viewport.w}×${i.viewport.h}`:i.device)),r("build",i.build&&t("context.build",{value:i.build})),n}const me=["page","persona","browser","device","viewport","build"];function ve(i,e){const t=new Set(e);t.has("device")&&t.add("viewport");const n={pagePath:t.has("page")?"":i.pagePath};i.persona&&!t.has("persona")&&(n.persona=i.persona),i.browser&&!t.has("browser")&&(n.browser=i.browser),i.device&&!t.has("device")&&(n.device=i.device),i.viewport&&!t.has("viewport")&&(n.viewport=i.viewport),i.build&&!t.has("build")&&(n.build=i.build);const r=me.filter(d=>t.has(d));return r.length>0&&(n.removed=r),n}const ge=5,xe="clarify_tap_only";class D{constructor(e){c(this,"deps");c(this,"conversationId",L());c(this,"entries",[]);c(this,"state","choose_job");c(this,"actions",[]);c(this,"requiresConsent",false);c(this,"pending",false);c(this,"error");c(this,"tapOnly",false);c(this,"consentAsked",false);c(this,"filed");c(this,"attachments",[]);c(this,"anchor");c(this,"removed",new Set);c(this,"team",{});c(this,"job");c(this,"step",0);c(this,"last");c(this,"ended",false);c(this,"opening",{chips:[]});c(this,"overMask",new Map);c(this,"listeners",new Set);c(this,"consent");c(this,"t");this.deps=e,this.consent=e.hasConsent(),this.t=e.t}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(){for(const e of this.listeners)e()}start(e){this.opening={chips:e},this.entries=[{kind:"assistant",copyId:"ask_job",text:this.t("greeting")}],this.actions=[...e,{type:"other_need",label:this.t("other_need")}],this.emit()}close(){if(this.ended||(this.ended=true,!this.last))return;const e=this.conversationId,t={kind:"action",action:"cancel"};this.send({turnId:L(),input:t}).then(n=>{e===this.conversationId&&(this.apply(t,n),this.emit())},()=>{})}reopen(){if(!this.ended)return;for(const t of this.attachments)t.release?.();const{chips:e}=this.opening;Object.assign(this,new D(this.deps),{listeners:this.listeners,overMask:this.overMask}),this.start(e)}offers(e){return this.actions.some(t=>t.type===e)}label(e){return this.actions.find(t=>t.type===e)?.label??""}chips(){return this.actions.filter(e=>e.type==="chip")}plusItems(){for(const e of this.actions)if(e.type==="plus_menu")return e.menu??e.items.map(t=>({id:t,label:""}));return[]}needsConsent(){return!this.consent&&(this.requiresConsent||this.offers("consent"))}allow(){this.deps.giveConsent(),this.consent=true,this.consentAsked=false,this.emit()}contextChips(){return be(this.facts(),this.removed,this.t)}removeContext(e){this.removed.add(e),this.emit()}setTeam(e){this.team={...this.team,...e}}teamOnWire(){const e={};return this.team.verdict&&(e.verdict=this.team.verdict),this.team.severity&&(e.severity=this.team.severity),e}addAttachment(e){const t=this.attachments.filter(n=>n.id!==e.id);return t.length>=ge?false:(this.attachments=[...t,e],this.emit(),true)}removeAttachment(e){this.attachments.find(t=>t.id===e)?.release?.(),this.attachments=this.attachments.filter(t=>t.id!==e),this.emit()}setAnchor(e){this.anchor=e,this.emit()}note(e){this.entries=[...this.entries,{kind:"note",text:e}],this.emit()}async uploadPending(){if(!this.consent)return;const e=this.attachments.filter(r=>!r.screenshotId&&r.upload),t=await Promise.all(e.map(r=>r.upload().catch(()=>{})));let n=false;e.forEach((r,d)=>{const h=t[d];h?this.attachments=this.attachments.map(o=>o===r?{...r,screenshotId:h}:o):(n=true,r.release?.(),this.attachments=this.attachments.filter(o=>o!==r))}),n&&(this.entries=[...this.entries,{kind:"note",text:this.t("note.upload_failed")}])}draft(){if(!this.consent)return;const e=this.attachments.flatMap(n=>n.screenshotId?[{screenshotId:n.screenshotId,...n.shapes?.length?{shapes:n.shapes}:{}}]:[]),t={};return e.length>0&&(t.attachments=e),this.anchor&&(t.anchor=this.anchor.tflowId),t.attachments||t.anchor?t:void 0}pickJob(e){this.job={id:e.jobId,title:e.title,of:ue(e)},this.run({kind:"action",action:"pick_job",jobId:e.jobId},e.title)}other(){this.run({kind:"action",action:"other_need"},this.label("other_need"))}next(){this.job&&this.run({kind:"action",action:"guide_next",jobId:this.job.id,step:this.step})}back(){this.state==="guide_step"&&this.job?this.run({kind:"action",action:"guide_back",jobId:this.job.id,step:this.step}):this.run({kind:"action",action:"guide_back"})}didntWork(){this.run({kind:"action",action:"didnt_work"},this.label("didnt_work"))}talk(){this.run({kind:"action",action:"talk_to_assistant"},this.label("talk_to_assistant"))}reportProblem(){this.run({kind:"action",action:"report_problem"},this.t("report_problem"))}sendText(e){const t=e.trim().slice(0,2e3);return!t||this.tapOnly||this.pending?false:this.needsConsent()?this.askConsent():(this.run({kind:"text",text:t},t),true)}sendReport(){return this.needsConsent()?this.askConsent():(this.run({kind:"action",action:"send"},this.label("send")),true)}retry(){this.last&&!this.pending&&this.exec(this.last)}askConsent(){return this.consentAsked=true,this.emit(),false}facts(){const e=this.deps.facts();return this.job?{...e,job:this.job.title,...this.step>0?{step:this.step}:{}}:e}run(e,t){this.pending||(t&&(this.entries=[...this.entries,{kind:"user",text:t}]),this.exec(this.last={turnId:L(),input:e}))}exec(e){this.pending=true,this.error=void 0,this.emit();const t=this.conversationId;this.uploadPending().then(()=>this.send(e)).then(n=>{t===this.conversationId&&this.apply(e.input,n)},n=>{t===this.conversationId&&(this.error=n.kind??"unavailable",this.error==="unavailable"&&(this.tapOnly=true))}).finally(()=>{this.pending=false,this.emit()})}send(e){const t=this.draft(),n=this.consent?[...this.overMask].map(([r,d])=>({rule:r,count:d})):[];return this.deps.transport.turn({siteKey:this.deps.siteKey,conversationId:this.conversationId,turnId:e.turnId,consentGiven:this.consent,context:ve(this.facts(),this.removed),schema:ae,payload:{input:e.input,...t?{draft:t}:{},...this.deps.reviewer&&(this.team.verdict||this.team.severity)?{team:this.teamOnWire()}:{}},...n.length?{overMasked:n}:{}}).then(r=>(n.length&&this.overMask.clear(),r))}apply(e,t){const n=this.state,r=e.kind==="action"?e.action:void 0;t.state==="guide_step"&&(r==="pick_job"?this.step=1:r==="guide_next"?this.step+=1:r==="guide_back"&&(this.step=Math.max(1,this.step-1)));const d=this.entries.map(o=>o.kind==="card"&&o.live?{...o,live:false}:o);let h;for(const o of t.messages)d.push({kind:"assistant",copyId:o.copyId,text:o.text}),o.card&&(o.card.step&&(this.step=o.card.step),this.job&&o.card.of&&(this.job.of=o.card.of),h={kind:"card",job:this.job?.title??"",step:this.step,of:o.card.of??this.job?.of,title:o.card.title,instruction:o.card.instruction,live:true});if(t.state==="guide_step"&&this.job&&d.push(h??{kind:"card",job:this.job.title,step:this.step,of:this.job.of,live:true}),t.state==="unmet_need"&&n!=="unmet_need"&&d.push({kind:"note",text:this.t("note.unmet")}),this.entries=d,this.tapOnly=t.messages.some(o=>o.copyId===xe),this.actions=t.actions,this.requiresConsent=t.requiresConsent,this.state=t.state,this.filed=t.filed?t.filed.kind??"problem":void 0,t.filed){for(const o of this.attachments)o.release?.();this.attachments=[],this.anchor=void 0,this.removed.clear(),this.team={}}["guide_step","didnt_work","gather","confirm_send"].includes(t.state)||(this.job=void 0,this.step=0)}}const ke=`
2
- :host{all:initial;--c:#F7F7F5;--s:#FFF;--r:#F0F0EC;--i:#1D2024;--m:#5D636B;--f:#6C727B;--l:rgb(29 32 36/12%);--a:#3D63C9;--ai:#FFF;--as:rgb(61 99 201/10%);--sh:0 1px 3px rgb(0 0 0/12%),0 4px 12px rgb(0 0 0/8%);
3
- font:400 13px/1.45 Inter,system-ui,-apple-system,"Segoe UI",sans-serif;color:var(--i);-webkit-font-smoothing:antialiased}
4
- @media (prefers-color-scheme:dark){:host{--c:#111316;--s:#181B1F;--r:#20242A;--i:#E8EAED;--m:#A3A9B2;--f:#8A919B;--l:rgb(232 234 237/12%);--a:#7F9CF0;--ai:#111316;--as:rgb(127 156 240/14%)}}
5
- *,*::before,*::after{box-sizing:border-box}
6
- button,input,select{font:inherit;color:inherit}
7
- button{cursor:pointer}
8
- button:disabled,input:disabled{cursor:not-allowed;opacity:.55}
9
- :focus-visible{outline:2px solid var(--a);outline-offset:2px}
10
- [hidden]{display:none!important}
11
- .sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
12
- .launcher{position:fixed;right:24px;bottom:24px;z-index:2147483646;width:56px;height:56px;border-radius:999px;border:0;background:var(--a);color:var(--ai);font-size:24px;font-weight:600;box-shadow:var(--sh)}
13
- .panel{position:fixed;right:24px;bottom:92px;z-index:2147483646;width:min(360px,calc(100vw - 48px));height:min(600px,calc(100vh - 116px));display:flex;flex-direction:column;background:var(--s);border:1px solid var(--l);border-radius:10px;box-shadow:var(--sh);overflow:hidden}
14
- .head{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:8px 8px 8px 16px;border-bottom:1px solid var(--l);background:var(--c)}
15
- .head h2{margin:0;font-size:13px;font-weight:600}
16
- .head p{margin:0;font-size:12px;color:var(--f)}
17
- .x{width:44px;height:44px;border:0;border-radius:6px;background:transparent;color:var(--m);font-size:20px}
18
- .log{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px}
19
- .msg{max-width:85%;padding:8px 12px;border:1px solid var(--l);border-radius:12px;white-space:pre-wrap;overflow-wrap:anywhere}
20
- .as{align-self:flex-start;background:var(--s);border-bottom-left-radius:2px}
21
- .us{align-self:flex-end;background:var(--as);border-bottom-right-radius:2px}
22
- .note{align-self:flex-start;margin:0;font-size:12px;color:var(--m)}
23
- .card{align-self:flex-start;width:90%;padding:12px;border:1px solid var(--l);border-radius:10px;background:var(--c)}
24
- .card h3{margin:0 0 4px;font-size:12px;font-weight:600;color:var(--a)}
25
- .card p{margin:0 0 8px;color:var(--m)}
26
- .row{display:flex;gap:8px;flex-wrap:wrap}
27
- .btn{min-height:44px;padding:0 16px;border:1px solid var(--l);border-radius:6px;background:var(--s)}
28
- .pri{background:var(--a);border-color:var(--a);color:var(--ai);font-weight:600}
29
- .link{min-height:44px;padding:0 4px;border:0;background:none;color:var(--a);text-decoration:underline}
30
- .foot{border-top:1px solid var(--l);padding:12px;display:flex;flex-direction:column;gap:8px;background:var(--s)}
31
- .dyn{display:flex;flex-direction:column;gap:8px}.dyn:empty{display:none}
32
- .chips{display:flex;flex-wrap:wrap;gap:6px}
33
- .chip{min-height:44px;padding:0 12px;border:1px solid var(--l);border-radius:999px;background:var(--s);color:var(--m)}
34
- .chip.job{border-color:var(--a);color:var(--a)}
35
- .err{margin:0;padding:8px;border-radius:6px;background:var(--r);color:var(--i)}
36
- .consent{margin:0;font-size:12px;color:var(--m)}
37
- .consent.ask{color:var(--i);font-weight:600}
38
- details{font-size:12px;color:var(--m)}
39
- summary{cursor:pointer;min-height:24px}
40
- .ctx{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px;padding:0;list-style:none}
41
- .ctx li{display:flex;align-items:center;gap:2px;padding-left:8px;border:1px solid var(--l);border-radius:6px;background:var(--r);color:var(--i)}
42
- .ctx li.fixed{padding-right:8px;min-height:32px}
43
- .ctx button,.att button{width:32px;height:32px;border:0;background:none;color:var(--m)}
44
- .team{display:flex;gap:8px;margin-top:6px}
45
- .team label{display:flex;flex-direction:column;gap:2px;color:var(--i)}
46
- .team select{min-height:32px;border:1px solid var(--l);border-radius:6px;background:var(--s)}
47
- .atts{display:flex;flex-wrap:wrap;gap:8px;margin:0;padding:0;list-style:none}
48
- .att{position:relative;width:64px;height:48px;border:1px solid var(--l);border-radius:6px;overflow:hidden;background:var(--r)}
49
- .att img{width:100%;height:100%;object-fit:cover}
50
- .pt{display:flex;align-items:center;gap:2px;padding-left:8px;border:1px solid var(--l);border-radius:6px;background:var(--r);font-size:12px;max-width:100%;overflow-wrap:anywhere}
51
- .pt button{width:32px;height:32px;border:0;background:none;color:var(--m)}
52
- .att button{position:absolute;top:0;right:0;background:var(--i);color:var(--s);border-radius:0 0 0 6px}
53
- .comp{position:relative;display:flex;gap:6px;align-items:center}
54
- .comp input{flex:1;min-width:0;min-height:44px;padding:0 12px;border:1px solid var(--l);border-radius:6px;background:var(--c)}
55
- .ico{width:44px;height:44px;flex:none;border:1px solid var(--l);border-radius:6px;background:var(--s);font-size:18px}
56
- .send{background:var(--a);border-color:var(--a);color:var(--ai)}
57
- .menu{position:absolute;left:0;right:0;bottom:52px;z-index:1;padding:4px;margin:0;list-style:none;background:var(--s);border:1px solid var(--l);border-radius:10px;box-shadow:var(--sh)}
58
- .menu button{display:block;width:100%;min-height:44px;padding:4px 12px;border:0;border-radius:6px;background:none;text-align:left}
59
- .menu button:hover,.menu button:focus-visible{background:var(--c)}
60
- .menu small{display:block;color:var(--f)}
61
- .dots{align-self:flex-start;color:var(--f)}
62
- @media (max-width:640px){.panel{inset:0;width:auto;height:auto;border-radius:0;border:0}.launcher[aria-expanded=true]{display:none}}
63
- @media (prefers-reduced-motion:reduce){*{transition-duration:1ms!important}}
64
- `,we=["unreviewed","polished","needs_polish","broken"],ye=["low","medium","high","critical"],_e=["didnt_work","gather","confirm_send","unmet_need"];function s(i,e={},...t){const n=document.createElement(i);for(const[r,d]of Object.entries(e))n.setAttribute(r,d);for(const r of t)r&&n.append(r);return n}function x(i,e,t,n={}){const r=s("button",{type:"button",class:e,...n},i);return r.addEventListener("click",t),r}function Ce(i,e,t){const n=e.t,r=s("button",{type:"button",class:"launcher","aria-label":n("launcher")||ce,"aria-expanded":"false","aria-controls":"jz-chat"},"?"),d=s("div",{class:"log",role:"log","aria-live":"polite","aria-label":n("conversation")}),h=s("div",{class:"dyn"});s("div");const o=s("input",{id:"jz-in",type:"text",autocomplete:"off",maxlength:"2000","aria-describedby":"jz-hint"}),S=s("span",{id:"jz-hint",class:"sr"}),k=s("button",{type:"button",class:"ico","aria-label":n("add_to_message"),"aria-haspopup":"menu","aria-expanded":"false","aria-controls":"jz-menu"},"+"),g=s("ul",{id:"jz-menu",class:"menu",role:"menu","aria-label":n("add_to_message")}),O=s("button",{type:"submit",class:"ico send","aria-label":n("send")},"➤"),C=s("form",{class:"comp"},g,k,s("label",{for:"jz-in",class:"sr"},n("message")),o,S,O),v=s("section",{id:"jz-chat",class:"panel",role:"dialog","aria-modal":"false","aria-labelledby":"jz-title"},s("header",{class:"head"},s("div",{},s("h2",{id:"jz-title"},n("title")),s("p",{},n("subtitle"))),x("✕","x",()=>A(),{"aria-label":n("close")})),d,s("div",{class:"foot"},h,C));v.hidden=true,g.hidden=true,i.append(r,v);let I=[],f=[];const T={ctx:false,team:false};r.addEventListener("click",()=>v.hidden?F():A()),o.addEventListener("input",()=>R()),C.addEventListener("submit",a=>{a.preventDefault(),e.sendText(o.value)&&(o.value="")}),k.addEventListener("click",()=>g.hidden?$():w(true)),g.addEventListener("keydown",a=>{const l=[...g.querySelectorAll("button")],b=l.indexOf(i.activeElement);a.key==="ArrowDown"||a.key==="ArrowUp"?(a.preventDefault(),l[(b+(a.key==="ArrowDown"?1:l.length-1))%l.length]?.focus()):a.key==="Tab"&&w(false)}),v.addEventListener("keydown",a=>{a.key==="Escape"&&(a.stopPropagation(),g.hidden?A():w(true))});function $(){g.replaceChildren(...e.plusItems().map(a=>{const l=s("button",{type:"button",role:"menuitem"},a.label,a.hint&&s("small",{},a.hint));return l.addEventListener("click",()=>{w(true),t.onPlusItem(a.id)}),s("li",{role:"none"},l)})),g.hidden=false,k.setAttribute("aria-expanded","true"),g.querySelector("button")?.focus()}function w(a){g.hidden=true,k.setAttribute("aria-expanded","false"),a&&k.focus()}function F(){e.reopen(),v.hidden=false,r.setAttribute("aria-expanded","true"),P(),(o.disabled?h.querySelector("button"):o)?.focus()}function A(){w(false),e.close(),v.hidden=true,r.setAttribute("aria-expanded","false"),r.focus()}function z(a){if(a.kind==="assistant")return s("div",{class:"msg as"},s("span",{class:"sr"},`${n("speaker.assistant")} `),a.text);if(a.kind==="user")return s("div",{class:"msg us"},s("span",{class:"sr"},`${n("speaker.you")} `),a.text);if(a.kind==="note")return s("p",{class:"note"},a.text);const l=`${a.job} · ${n(a.of?"card.step_of":"card.step",{step:a.step,of:a.of??""})}`,b=s("div",{class:"card",role:"group","aria-label":l},s("h3",{},l),a.title&&s("p",{},s("strong",{},a.title)),a.instruction&&s("p",{},a.instruction));if(a.live){const p=e.pending,j=x(e.label("guide_back"),"btn",()=>e.back(),{"data-back":""});j.disabled=p||a.step<=1;const _=x(e.label("guide_next"),"btn pri",()=>e.next());_.disabled=p;const y=x(e.label("didnt_work"),"link",()=>e.didntWork());y.disabled=p,b.append(s("div",{class:"row"},j,_),y)}return b}function M(){const a=e.entries;(a.length<f.length||a[0]!==f[0])&&(d.replaceChildren(),I=[],f=[]),a.forEach((l,b)=>{if(f[b]===l)return;const p=z(l);I[b]?l.kind==="card"?I[b].querySelectorAll(".row, .link").forEach(j=>j.remove()):I[b].replaceWith(p):(I[b]=p,d.append(p))}),a.forEach((l,b)=>{l.kind==="card"&&l.live&&I[b].querySelectorAll("button").forEach(p=>p.disabled=e.pending||p.hasAttribute("data-back")&&l.step<=1)}),f=[...a],d.querySelector(".dots")?.remove(),d.setAttribute("aria-busy",String(e.pending)),e.pending&&d.append(s("p",{class:"dots","aria-hidden":"true"},"…")),d.scrollTop=d.scrollHeight}function R(){const a=i.activeElement,l=a&&h.contains(a)?a.dataset.k:void 0,b=e.pending,p=[];e.error&&p.push(s("p",{class:"err",role:"status"},n(`error.${e.error}`)," ",x(n("try_again"),"link",()=>e.retry(),{"data-k":"retry"})));const j=e.tapOnly?e.chips():he(e.chips(),o.value),_=e.offers("other_need");if(j.length>0||_){const m=s("div",{class:"chips",role:"group","aria-label":n("suggestions")});for(const u of j){const E=x(u.badge?`${u.title} · ${u.badge}`:u.title,"chip job",()=>e.pickJob(u),{"data-k":`job:${u.jobId}`});E.disabled=b,m.append(E)}if(_){const u=x(e.label("other_need"),"chip",()=>e.other(),{"data-k":"other"});u.disabled=b,m.append(u)}p.push(m)}const y=s("div",{class:"row"});if(e.offers("guide_back")&&e.state!=="guide_step"&&y.append(x(e.label("guide_back"),"btn",()=>e.back(),{"data-k":"back"})),e.offers("talk_to_assistant")&&y.append(x(e.label("talk_to_assistant"),"btn",()=>e.talk(),{"data-k":"talk"})),e.offers("send")&&y.append(x(e.label("send"),"btn pri",()=>e.sendReport(),{"data-k":"send",...e.needsConsent()?{"aria-describedby":"jz-consent"}:{}})),y.querySelectorAll("button").forEach(m=>m.disabled=b),y.childElementCount>0&&p.push(y),e.needsConsent()){const m=x(e.label("consent")||n("allow"),"link",()=>{e.allow(),o.focus()},{"data-k":"allow"});p.push(s("p",{id:"jz-consent",class:e.consentAsked?"consent ask":"consent"},`${n("consent_line")} · `,m))}if(_e.includes(e.state)||e.offers("send")){const m=s("ul",{class:"ctx"});for(const u of e.contextChips()){const E=s("li",u.removable?{}:{class:"fixed"},u.label);u.removable&&E.append(x("✕","",()=>e.removeContext(u.key),{"aria-label":n("remove",{name:u.label}),"data-k":`ctx:${u.key}`})),m.append(E)}p.push(U("ctx",n("context.title"),m)),t.reviewer&&p.push(U("team",n("team.title"),W()))}if(e.attachments.length>0||e.anchor){const m=s("ul",{class:"atts","aria-label":n("attachments")});if(e.anchor){const u=n("pointed_at",{name:e.anchor.tflowId});m.append(s("li",{class:"pt"},u,x("✕","",()=>e.setAnchor(void 0),{"aria-label":n("remove",{name:u}),"data-k":"anchor"})))}e.attachments.forEach((u,E)=>{const B=u.label??n("attachment.screenshot",{n:E+1});m.append(s("li",{class:"att"},s("img",{src:u.thumbnail,alt:B}),x("✕","",()=>e.removeAttachment(u.id),{"aria-label":n("remove",{name:B}),"data-k":`att:${u.id}`})))}),p.push(m)}const J=e.state==="closed";o.disabled=e.tapOnly||J,o.placeholder=n(e.tapOnly?"input.tap_only":"input.placeholder"),S.textContent=e.tapOnly?n("input.paused"):"",O.disabled=o.disabled||b,k.hidden=e.plusItems().length===0,k.hidden&&!g.hidden&&w(false),h.replaceChildren(...p.filter(m=>!!m&&typeof m!="string")),e.consentAsked?h.querySelector("[data-k=allow]")?.focus():l&&(h.querySelector(`[data-k="${l}"]`)??(o.disabled?h.querySelector("button"):o))?.focus()}function U(a,l,b){const p=s("details",{},s("summary",{},l),b);return p.open=T[a],p.addEventListener("toggle",()=>T[a]=p.open),p}function W(){const a=(l,b,p,j)=>{const _=s("select",{},s("option",{value:""},"—"),...b.map(y=>s("option",{value:y},n(`team.${l}.${y}`))));return _.value=p??"",_.addEventListener("change",()=>j(_.value)),s("label",{},n(`team.${l}`),_)};return s("div",{class:"team"},a("verdict",we,e.team.verdict,l=>e.setTeam({verdict:l||void 0})),a("severity",ye,e.team.severity,l=>e.setTeam({severity:l||void 0})))}function P(){v.hidden||(M(),R())}const G=e.subscribe(P);return{open:F,close:A,isOpen:()=>!v.hidden,suspend(){w(false);const a=!v.hidden;return v.hidden=true,r.hidden=true,()=>{r.hidden=false,a&&(v.hidden=false,P(),(k.hidden?o:k).focus())}},destroy(){G(),r.remove(),v.remove()}}}const je=["desktop","tablet","mobile"];function K(i,e){const t=window.innerWidth,n=e.device&&je.includes(e.device)?e.device:t<768?"mobile":t<1024?"tablet":"desktop",r=i.signals?.appVersion;return{pagePath:i.pagePath==="none"?"":ie(location.href).slice(0,512),persona:e.persona,browser:fe(navigator.userAgent),device:n,viewport:{w:Math.min(t,2e4),h:Math.min(window.innerHeight,2e4)},build:r&&r.length<=64?r:void 0}}async function Ie(i,e,t){const n=await t?.(),r={siteKey:e.siteKey,...e.reviewerToken?{reviewerToken:e.reviewerToken}:{},...n?{claims:n}:{}};return q(i,"GetHelpIndex",r).then(d=>d.jobs??[])}function N(i,e){return i.flatMap(t=>{if(!t.jobId||!t.title)return[];const n=t.stepCount;return[{type:"chip",jobId:t.jobId,title:t.title,label:t.title,badge:n?n===1?e("chip.one_step"):e("chip.steps",{n}):e("chip.no_guide"),...n?{steps:n}:{}}]})}function V(i,e,t={}){const n=ee(i),r=i.claims!==void 0||i.getToken?import("./claims-BfpRuIu-.js").then(f=>f.claimsSource(i)):void 0,d=r&&(()=>r.then(f=>f.token()));d?.();const h=document.createElement("div");h.setAttribute("data-journeeze-chat","");const o=h.attachShadow({mode:"closed"}),S=document.createElement("style");S.textContent=ke,i.nonce&&(S.nonce=i.nonce),o.append(S),document.body.append(h);let k;const g=()=>k??(k=q(n,"GetWidgetConfig",{siteKey:i.siteKey}).catch(f=>{throw k=void 0,f})),O=(t.loadJobs??(()=>Ie(n,i,d)))().catch(()=>[]);let C,v=false;const I=g().then(f=>f.copy,()=>{}).then(async f=>{if(v)return;const T=pe(f),$=()=>i.reviewerToken||i.userId?void 0:null,w=new D({siteKey:i.siteKey,reviewer:!!i.reviewerToken,transport:t.transport??le(n,i,void 0,d),t:T,facts:()=>K(i,e()),hasConsent:()=>ne(H(i),$()),giveConsent:()=>te(H(i),$())}),F=z=>import("./attach-D451Wj4h.js").then(M=>M.plusItem(z,{session:w,root:o,options:i,endpoint:n,claims:d,config:g,suspend:()=>A.suspend()}),()=>w.note(T("note.capture_unavailable"))),A=Ce(o,w,{reviewer:!!i.reviewerToken,onPlusItem:t.onPlusItem??(z=>{F(z)})});C={session:w,view:A},w.start(N(await O,T))});return{unmount(){v=true,r?.then(f=>f.stop()),C?.view.destroy(),h.remove()},report(){I.then(()=>{C?.view.open(),C?.session.reportProblem()})},addAttachment:f=>!!C?.session.addAttachment(f),removeAttachment:f=>C?.session.removeAttachment(f)}}const Ae=(i,e)=>V(i,()=>re(e())),Te=Object.freeze(Object.defineProperty({__proto__:null,jobChips:N,mount:Ae,mountChat:V,pageFacts:K},Symbol.toStringTag,{value:"Module"}));export{ge as M,Te as c,L as u};