@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,106 +0,0 @@
1
- var Z=Object.defineProperty;var ee=(n,e,t)=>e in n?Z(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var j=(n,e,t)=>ee(n,typeof e!="symbol"?e+"":e,t);import{s as te,F as G,R as ne}from"./hook-BRnJ-lTk.js";import{d as Q}from"./anchor-BhsfeHwL.js";import{k as ie,C as se,l as $,c as X,s as J,d as re,D as oe,i as ae,h as de,f as ce,e as le}from"./consent-BupCs23W.js";import{T as ue}from"./loader-k4pePzAw.js";const he=6e4;class pe{constructor(e){j(this,"opts");j(this,"indexEntry");j(this,"guides",new Map);j(this,"inflight",new Map);j(this,"now");j(this,"freshMs");this.opts=e,this.now=e.now??Date.now,this.freshMs=e.freshMs??6e4}index(){return this.read("index","GetHelpIndex",{},()=>this.indexEntry,e=>this.indexEntry=e,()=>false)}guide(e){return this.read(`guide:${e}`,"GetGuide",{journeyId:e},()=>this.guides.get(e),t=>this.guides.set(e,t),t=>{const s=t.linksExpireAt?Date.parse(t.linksExpireAt):NaN;return Number.isFinite(s)&&s-this.now()<he})}body(e,t){const s=this.opts.reviewerToken;return{siteKey:this.opts.siteKey,...e,...s&&{reviewerToken:s},...t&&{claims:t}}}read(e,t,s,i,o,c){const u=this.opts.claims;return u?u().then(g=>this.readWith(e,t,s,g,i,o,c)):this.readWith(e,t,s,void 0,i,o,c)}readWith(e,t,s,i,o,c,u){const g=o(),x=g&&g.claims===i?g:void 0;if(x&&this.now()-x.at<this.freshMs&&!u(x.value))return Promise.resolve(x.value);const T=`${e}
2
- ${i??""}`,F=this.inflight.get(T);if(F)return F;const q=x&&!u(x.value)?x.etag:void 0,a=ie(this.opts.endpoint,t,this.body(s,i),q,this.opts.fetchImpl).then(h=>{if(h.notModified){if(!x)throw new Error("304 without a cached value");return c({...x,at:this.now()}),x.value}return c({value:h.value,etag:h.etag,at:this.now(),claims:i}),h.value}).finally(()=>this.inflight.delete(T));return this.inflight.set(T,a),a}}const L=n=>n.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^\p{L}\p{N}]+/u).filter(Boolean);function _(n,e){const t=L(e);if(t.length===0)return[...n];const s=[];return n.forEach((i,o)=>{const c=L(i.title??""),u=L(i.goal??""),g=(i.stepTitles??[]).flatMap(L);let x=0;for(const T of t){const F=a=>a.some(h=>h.startsWith(T)),q=F(c)?3:F(u)?2:F(g)?1:0;if(q===0)return;x+=q}s.push([i,x,o])}),s.sort((i,o)=>o[1]-i[1]||i[2]-o[2]).map(([i])=>i)}const ge=4e3;function B(n){return n instanceof se&&n.code==="failed_precondition"}class fe{constructor(e){j(this,"deps");j(this,"current",{view:"closed"});j(this,"listeners",new Set);j(this,"entries",[]);j(this,"generation",0);j(this,"asked",new Set);j(this,"pending");j(this,"pendingSignal");this.deps=e}get state(){return this.current}subscribe(e){return this.listeners.add(e),e(this.current),()=>this.listeners.delete(e)}probe(){return this.deps.loadIndex().then(()=>{},e=>{B(e)&&this.disable()})}open(){if(this.current.view==="disabled")return;const e=++this.generation;this.deps.clearHighlight(),this.set({view:"index",status:"loading",query:"",results:[],total:0}),this.deps.loadIndex().then(t=>{if(e!==this.generation)return;this.entries=(t.guides??[]).filter(o=>o.journeyId);const s=this.current.view==="index"?this.current.query:"",i=(t.jobs??[]).filter(o=>o.jobId&&o.title);this.set({view:"index",status:"ready",query:s,results:_(this.entries,s),total:this.entries.length,jobs:i})},t=>{if(e!==this.generation)return;if(B(t))return this.disable();const s=this.current.view==="index"?this.current.query:"";this.set({view:"index",status:"error",query:s,results:[],total:0})})}close(){this.current.view!=="disabled"&&(this.generation++,this.pending=void 0,this.pendingSignal=void 0,this.deps.clearHighlight(),this.set({view:"closed"}))}search(e){const t=this.current;if(t.view!=="index")return;const s=t.status==="ready"?_(this.entries,e):[];this.set({...t,query:e,results:s})}openGuide(e){if(this.current.view==="disabled")return;const t=++this.generation;this.pending=void 0,this.deps.clearHighlight(),this.set({view:"guide",status:"loading",journeyId:e,step:0,anchor:"none",checkin:"idle"}),this.deps.loadGuide(e).then(s=>{if(t!==this.generation)return;const i=ve(s,e,this.deps.endpoint);if(i.steps.length===0){this.set({view:"guide",status:"error",journeyId:e,step:0,anchor:"none",checkin:"idle"});return}this.showStep(i,0)},s=>{if(t===this.generation){if(B(s))return this.disable();this.set({view:"guide",status:"error",journeyId:e,step:0,anchor:"none",checkin:"idle"})}})}disable(){this.generation++,this.pending=void 0,this.deps.clearHighlight(),this.set({view:"disabled"})}back(){const e=this.current;if(e.view==="finished")return this.showStep(e.guide,e.guide.steps.length-1);if(e.view!=="guide"||!e.guide)return this.open();if(e.step===0)return this.open();this.generation++,this.pending=void 0,this.showStep(e.guide,e.step-1)}next(){const e=this.current;if(e.view!=="guide"||e.status!=="ready"||!e.guide||e.checkin!=="idle")return;const t=e.guide.steps[e.step];if(t&&!this.asked.has(P(e.guide,t))){this.set({...e,checkin:"asking",notice:void 0});return}this.advance()}answer(e){const t=this.current;if(!(t.view!=="guide"||t.checkin!=="asking"&&t.checkin!=="needs-consent")){if(!this.deps.hasConsent()){this.pending=e,this.set({...t,checkin:"needs-consent"});return}this.send(e)}}skipCheckin(){const e=this.current;e.view!=="guide"||e.checkin!=="asking"&&e.checkin!=="needs-consent"||(this.pending=void 0,this.markAsked(e),this.set({...e,checkin:"idle"}),this.advance())}giveConsent(){const e=this.pendingSignal,t=this.current;if(e&&(t.view==="index"||t.view==="guide")&&t.signal==="needs-consent"){this.pendingSignal=void 0,this.deps.giveConsent(),this.sendSignalNow(e);return}const s=this.current;if(s.view!=="guide"||s.checkin!=="needs-consent"||!this.pending)return;this.deps.giveConsent();const i=this.pending;this.pending=void 0,this.send(i)}declineConsent(){const e=this.current;if(this.pendingSignal&&(e.view==="index"||e.view==="guide")&&e.signal==="needs-consent"){this.pendingSignal=void 0,this.patchSignal({signal:"idle"});return}this.skipCheckin()}canSignal(){return this.deps.signalsAllowed?.()??true}hasConsent(){return this.deps.hasConsent()}sendCallout(e){if(!this.canSignal())return;const t=this.current;if(t.view!=="guide"||t.status!=="ready"||!t.guide||D(t.signal))return;const s=t.guide.steps.find(i=>i.index===e);s&&this.signal({kind:"callout",guide:t.guide,step:s})}sendRequest(e,t){if(!this.canSignal())return;const s=e.trim();if(!s||[...s].length>ge)return;const i=this.current;i.view==="index"&&!D(i.signal)?this.signal(t?{kind:"request",text:s,jobRequest:t}:{kind:"request",text:s}):i.view==="guide"&&i.status==="ready"&&i.guide&&!D(i.signal)&&this.signal({kind:"request",text:s,guide:i.guide,step:i.guide.steps[i.step]})}signal(e){if(!this.deps.hasConsent()){this.pendingSignal=e,this.patchSignal({signal:"needs-consent",signalNotice:void 0});return}this.sendSignalNow(e)}patchSignal(e){const t=this.current;(t.view==="index"||t.view==="guide")&&this.set({...t,...e})}async sendSignalNow(e){const t=this.generation;this.patchSignal({signal:"sending",signalNotice:void 0});let s;try{s=await this.deps.sendSignal(e)}catch{s="dropped"}t===this.generation&&this.patchSignal({signal:"idle",signalNotice:s})}async send(e){const t=this.current;if(t.view!=="guide"||!t.guide)return;const s=t.guide.steps[t.step];if(!s)return;this.markAsked(t);const i=this.generation;this.set({...t,checkin:"sending"});let o;try{o=await this.deps.sendCheckin({guide:t.guide,step:s,answer:e})}catch{o="dropped"}if(i!==this.generation)return;const c=this.current;c.view==="guide"&&(this.set({...c,checkin:"idle"}),this.advance(o))}refreshHighlight(){const e=this.current;if(e.view!=="guide"||e.status!=="ready"||!e.guide)return;const t=this.anchorFor(e.guide,e.step);t!==e.anchor&&this.set({...e,anchor:t})}markAsked(e){if(e.view!=="guide"||!e.guide)return;const t=e.guide.steps[e.step];t&&this.asked.add(P(e.guide,t))}advance(e){const t=this.current;if(!(t.view!=="guide"||!t.guide)){if(t.step+1<t.guide.steps.length)return this.showStep(t.guide,t.step+1,e);this.deps.clearHighlight(),this.set({view:"finished",guide:t.guide,notice:e})}}showStep(e,t,s){const i=this.anchorFor(e,t);this.set({view:"guide",status:"ready",journeyId:e.journeyId,guide:e,step:t,anchor:i,checkin:"idle",notice:s})}anchorFor(e,t){const s=this.deps.highlight(e.steps[t]?.targets);return typeof s=="string"?s:(s.then(i=>{const o=this.current;o.view==="guide"&&o.guide===e&&o.step===t&&o.anchor!==i&&this.set({...o,anchor:i})}),"none")}set(e){this.current=e;for(const t of this.listeners)t(e)}}const P=(n,e)=>`${n.journeyId}/${e.index}`;function ve(n,e,t){const s=(n.steps??[]).map((i,o)=>({index:i.index??o,title:i.title??"",instruction:i.instruction??"",tflowId:i.tflowId||void 0,targets:xe(i),stepRef:i.stepRef||void 0,screenshotUrl:$(t,i.screenshotUrl),videoStartMs:i.videoStartMs,videoEndMs:i.videoEndMs})).sort((i,o)=>i.index-o.index);return{journeyId:n.journeyId??e,slug:n.slug??"",title:n.title??"",goal:n.goal??"",steps:s,videoUrl:$(t,n.videoUrl),captionsUrl:$(t,n.captionsUrl),version:n.contentVersion||void 0}}function D(n){return n==="needs-consent"||n==="sending"}const be=/^(tflow|testId|role|css)$/;function xe(n){const e=(n.targets??[]).filter(t=>be.test(t.strategy??"")&&t.value).map(t=>({by:t.strategy,value:t.value,name:t.name||void 0}));return e.length||!n.tflowId?e:[{by:"tflow",value:n.tflowId}]}const we=()=>import("./resolve-7jVqhJhi.js");function me(n,e=document){if(ue.test(n))for(const t of e.querySelectorAll(`[data-tflow-id="${n}"]`)){const s=t.getBoundingClientRect();if(s.width>0||s.height>0)return t}}function ye(n=window){try{return n.matchMedia?.("(prefers-reduced-motion: reduce)").matches??false}catch{return false}}class ke{constructor(e,t=window,s=we){j(this,"win");j(this,"load");j(this,"target");j(this,"box");j(this,"onMove",()=>this.place());j(this,"seq",0);this.win=t,this.load=s,this.box=t.document.createElement("div"),this.box.className="jz-help-highlight",this.box.setAttribute("aria-hidden","true"),this.box.hidden=true,e.append(this.box)}show(e){this.hide();const t=this.seq,[s]=e??[];return s?e?.length===1&&s.by==="tflow"?this.outline(me(s.value,this.win.document)):this.load().then(i=>t===this.seq?this.outline(i.resolveTarget(e??[],this.win.document)):"none",()=>"missing"):"none"}outline(e){return e?(this.target=e,e.scrollIntoView?.({block:"center",inline:"nearest",behavior:ye(this.win)?"auto":"smooth"}),this.win.addEventListener("scroll",this.onMove,{capture:true,passive:true}),this.win.addEventListener("resize",this.onMove,{passive:true}),this.box.hidden=false,this.place(),"found"):"missing"}hide(){this.seq++,this.target&&(this.target=void 0,this.box.hidden=true,this.win.removeEventListener("scroll",this.onMove,{capture:true}),this.win.removeEventListener("resize",this.onMove))}dispose(){this.hide(),this.box.remove()}place(){if(!this.target)return;if(!this.target.isConnected)return this.hide();const e=this.target.getBoundingClientRect();Object.assign(this.box.style,{left:`${e.left-4}px`,top:`${e.top-4}px`,width:`${e.width+8}px`,height:`${e.height+8}px`})}}function je(n,e,t,s){let i;return{start(){i??(i=import("./telemetry-DMGFJcw3.js").then(o=>o.startTelemetry({endpoint:n,siteKey:e,subscribe:c=>t.subscribe(c),claims:s}),()=>{i=void 0}))},checkin:o=>{i?.then(c=>c?.checkin(o))},job:o=>{i?.then(c=>c?.job(o))},stop:o=>{i?.then(c=>c?.stop(o))}}}const Ke=`
3
- :host { all: initial; }
4
- .launcher { position:fixed; left:24px; bottom:24px; z-index:2147483646; width:44px; height:44px; border-radius:22px;
5
- border:1px solid #1D2024; background:#1D2024; color:#FFFFFF; font:600 18px/1 system-ui,sans-serif; cursor:pointer; }
6
- .panel { position:fixed; left:24px; bottom:80px; z-index:2147483646; width:min(340px, calc(100vw - 48px));
7
- max-height:min(70vh, 560px); overflow:auto; box-sizing:border-box; padding:16px; border:1px solid rgb(29 32 36/12%);
8
- border-radius:10px; background:#FFFFFF; color:#1D2024; font:14px/1.45 system-ui,sans-serif; box-shadow:0 8px 24px rgb(0 0 0/12%); }
9
- .panel h2 { font-size:15px; margin:0 0 8px; }
10
- .panel p { margin:0 0 8px; }
11
- .panel ul { list-style:none; padding:0; margin:8px 0 0; }
12
- .panel li button { display:block; width:100%; text-align:left; padding:8px; margin:0 0 4px; border:1px solid rgb(29 32 36/12%);
13
- border-radius:6px; background:#FFFFFF; color:inherit; font:inherit; cursor:pointer; }
14
- .panel input { width:100%; box-sizing:border-box; padding:8px; border:1px solid rgb(29 32 36/24%); border-radius:6px; font:inherit; }
15
- .panel .row { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
16
- .panel .row button { padding:6px 12px; border:1px solid #1D2024; border-radius:6px; background:#FFFFFF; color:#1D2024; font:inherit; cursor:pointer; }
17
- .panel .muted { color:#5D636B; font-size:13px; }
18
- .panel img { max-width:100%; border:1px solid rgb(29 32 36/12%); border-radius:6px; }
19
- :focus-visible { outline:2px solid #3D63C9; outline-offset:2px; }
20
- .jz-help-highlight { position:fixed; z-index:2147483645; pointer-events:none; box-sizing:border-box;
21
- border:2px solid #3D63C9; border-radius:6px; box-shadow:0 0 0 4px rgb(61 99 201/20%); }
22
- `;function p(n,e={},...t){const s=document.createElement(n);for(const[i,o]of Object.entries(e))s.setAttribute(i,o);for(const i of t)i&&s.append(i);return s}const K={sent:"Thanks. Your answer was sent.",queued:"Saved. It will send when you're back online.",dropped:"Your answer couldn't be sent."},ze=(n,e,t)=>{const s=p("button",{type:"button",class:"launcher","aria-label":"Help","aria-expanded":"false","aria-controls":"jz-help-panel"},"?"),i=p("div",{id:"jz-help-panel",class:"panel",role:"dialog","aria-modal":"false","aria-label":"Help"});i.hidden=true,n.append(s,i);let o="",c=false,u;s.addEventListener("click",()=>e.state.view==="closed"?e.open():e.close()),i.addEventListener("keydown",a=>{a.key==="Escape"&&(a.stopPropagation(),e.close())});const g=(a,h,v={})=>{const E=p("button",{type:"button",...v},a);return E.addEventListener("click",h),E};function x(a){const h=n.activeElement,v=h!==null&&i.contains(h),E=v?h.id:"";s.hidden=a.view==="disabled";const m=a.view!=="closed"&&a.view!=="disabled";if(s.setAttribute("aria-expanded",String(m)),i.hidden=!m,a.view==="index"&&u&&i.contains(u.input)){F(a),v&&h&&!h.isConnected&&(E&&n.getElementById(E)||u.input).focus(),c=m;return}if(u=void 0,i.replaceChildren(...(m?T(a):[]).filter(k=>!!k)),m&&(!c||v)){const z=(E?n.getElementById(E):null)??i.querySelector("input, [role=group] button, button");z?.focus(),z instanceof HTMLInputElement&&z.setSelectionRange(z.value.length,z.value.length)}!m&&c&&s.focus(),c=m}function T(a){if(a.view==="index"){const k=p("input",{id:"jz-help-search",type:"search","aria-label":"Search help",placeholder:"How do I…",autocomplete:"off"});return k.value=a.query,k.addEventListener("input",()=>e.search(k.value)),u={input:k,status:p("p",{class:"muted",role:"status"}),retry:p("div",{class:"row"},g("Try again",()=>e.open())),list:p("ul",{"aria-label":"Guides"})},F(a),[p("h2",{},"How do I…"),k,u.status,u.retry,u.list,p("div",{class:"row"},g("Close",()=>e.close()))]}if(a.view==="finished")return[p("h2",{},`You finished “${a.guide.title}”`),a.notice&&p("p",{class:"muted",role:"status"},K[a.notice]??""),p("div",{class:"row"},g("More guides",()=>e.open(),{id:"jz-help-more"}),g("Back",()=>e.back()),g("Close",()=>e.close()))];if(a.view!=="guide")return[];if(a.status!=="ready"||!a.guide)return[p("p",{role:"status"},a.status==="loading"?"Loading guide…":"This guide isn't available right now."),p("div",{class:"row"},g("Back",()=>e.open()),g("Close",()=>e.close()))];const h=a.guide,v=h.steps[a.step];if(!v)return[];const E=a.step+1===h.steps.length,m=[p("h2",{},h.title),p("p",{class:"muted"},`Step ${a.step+1} of ${h.steps.length}`),p("p",{},p("strong",{},v.title)),v.instruction&&p("p",{},v.instruction),a.anchor==="missing"&&p("p",{class:"muted"},"The part of the page this step uses isn't shown here. Follow the steps in the text."),v.screenshotUrl&&p("img",{referrerpolicy:"no-referrer",src:v.screenshotUrl,alt:`Screenshot for: ${v.title}`,loading:"lazy"}),a.notice&&p("p",{class:"muted",role:"status"},K[a.notice]??"")];if(a.checkin==="asking")m.push(p("div",{role:"group","aria-label":"Step check-in"},p("p",{},"Did this step make sense?"),p("div",{class:"row"},g("Understood",()=>e.answer("understood"),{id:"jz-help-yes"}),g("Confused",()=>e.answer("confused")),g("Skip",()=>e.skipCheckin()))));else if(a.checkin==="needs-consent"){const k=p("p",{},o||"Loading…");o||t.consentText().then(z=>{o=z,k.textContent=z}),m.push(p("div",{role:"group","aria-label":"Consent"},k,p("div",{class:"row"},g("Allow and send",()=>e.giveConsent(),{id:"jz-help-allow"}),g("Not now",()=>e.declineConsent()))))}else a.checkin==="sending"?m.push(p("p",{role:"status"},"Sending…")):m.push(p("div",{class:"row"},g("Back",()=>e.back()),g(E?"Finish":"Next",()=>e.next(),{id:"jz-help-next"}),g("Close",()=>e.close())));return m}function F(a){if(!u)return;const{input:h,status:v,retry:E,list:m}=u;h.value!==a.query&&n.activeElement!==h&&(h.value=a.query),v.textContent=a.status==="loading"?"Loading guides…":a.status==="error"?"Help isn't available right now.":a.results.length===0?a.query?`No guide matches “${a.query}”.`:"No guides yet.":"",v.hidden=v.textContent==="",E.hidden=a.status!=="error",m.replaceChildren(...a.results.map((k,z)=>p("li",{},g(k.title||"Untitled guide",()=>e.openGuide(k.journeyId??""),{id:`jz-help-g${z}`}),k.goal?p("p",{class:"muted"},k.goal):void 0)))}const q=e.subscribe(x);return{destroy(){q(),s.remove(),i.remove()}}},W="http://www.w3.org/2000/svg",Ce="M6.1 6.2a2 2 0 1 1 2.7 1.9c-.7.3-1 .6-1 1.3v.5H6.4v-.6c0-1.1.4-1.6 1.2-2 .5-.2.8-.5.8-1a1 1 0 0 0-2 0v.1H6.1zM7.2 11.4h1.6V13H7.2z";function Se(n){const e=document.createElementNS(W,"svg");e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("width","14"),e.setAttribute("height","14"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");const t=document.createElementNS(W,"path");return t.setAttribute("d",n),t.setAttribute("fill","currentColor"),e.append(t),e}function Ee(n,e){const t=document.createElement("button");return t.type="button",t.id="jz-help-callout",t.className="callout-btn",t.append(Se(Ce),document.createTextNode("This is confusing")),t.addEventListener("click",()=>n.sendCallout(e)),t}function Ie(n,e){const t=document.createElement("form");t.setAttribute("aria-label","Ask for something you could not find");const s=document.createElement("p");s.textContent="Couldn't find it? Tell us what you were trying to do.";const i=document.createElement("textarea");i.id="jz-help-request",i.setAttribute("aria-label","What were you trying to do?"),i.maxLength=4e3,i.rows=3,i.value=`I couldn't find how to ${e}`;const o=document.createElement("button");return o.type="submit",o.id="jz-help-request-send",o.textContent="Send request",t.append(s,i,o),t.addEventListener("submit",c=>{c.preventDefault(),n.sendRequest(i.value)}),t}function d(n,e={},...t){const s=document.createElement(n);for(const[i,o]of Object.entries(e))s.setAttribute(i,o);for(const i of t)i&&s.append(i);return s}function U(n,e){const t=d(n,{...e,crossorigin:"anonymous"});return Object.assign(t,{referrerPolicy:"no-referrer"}),t.setAttribute("referrerpolicy","no-referrer"),t}const V="http://www.w3.org/2000/svg";function Fe(n){const e=document.createElementNS(V,"svg");e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("width","14"),e.setAttribute("height","14"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");const t=document.createElementNS(V,"path");return t.setAttribute("d",n),t.setAttribute("fill","currentColor"),e.append(t),e}const Te="M6.2 11.4 3 8.2l1.1-1.1 2.1 2.1 4.6-4.6 1.1 1.1z",Ae="M6.1 6.2a2 2 0 1 1 2.7 1.9c-.7.3-1 .6-1 1.3v.5H6.4v-.6c0-1.1.4-1.6 1.2-2 .5-.2.8-.5.8-1a1 1 0 0 0-2 0v.1H6.1zM7.2 11.4h1.6V13H7.2z",R={sent:"Thanks. Your answer was sent.",queued:"Saved. It will send when you're back online.",dropped:"Your answer couldn't be sent."},Y={sent:"Thanks. We'll take a look.",queued:"Saved. It will send when you're back online.",dropped:"Your request couldn't be sent."},qe=(n,e,t)=>{const s=d("button",{type:"button",class:"launcher","aria-label":"Help","aria-expanded":"false","aria-controls":"jz-help-panel"},"?"),i=d("div",{id:"jz-help-panel",class:"panel",role:"dialog","aria-modal":"false","aria-label":"Help"});i.hidden=true,n.append(s,i);let o="",c=false,u,g,x,T,F=false;const q=r=>!F&&r.view==="index"&&r.status==="ready"&&!!r.jobs?.length;s.addEventListener("click",()=>e.state.view==="closed"?e.open():e.close()),i.addEventListener("keydown",r=>{r.key==="Escape"&&(r.stopPropagation(),e.close())});const a=(r,f,b={})=>{const C=d("button",{type:"button",...b},r);return C.addEventListener("click",f),C},h=()=>{const r=d("p",{},o||"Loading…");return o||t.consentText().then(f=>{o=f,r.textContent=f}),d("div",{class:"checkin",role:"group","aria-label":"Consent"},r,d("div",{class:"row"},a("Allow and send",()=>e.giveConsent(),{id:"jz-help-allow",class:"primary"}),a("Not now",()=>e.declineConsent())))},v=()=>d("div",{class:"panel-head"},d("h2",{},"Help"),a("×",()=>e.close(),{class:"icon-btn","aria-label":"Close help"})),E=(r,f,b)=>{const C=d("button",{type:"button",id:`jz-help-${f}`,class:`checkin-btn ${f}`});return C.append(Fe(f==="understood"?Te:Ae),d("span",{},r)),C.addEventListener("click",b),C};function m(r){const f=n.activeElement,b=f!==null&&i.contains(f),C=b?f.id:"";s.hidden=r.view==="disabled";const S=r.view!=="closed"&&r.view!=="disabled";if(s.setAttribute("aria-expanded",String(S)),i.hidden=!S,r.view==="index"&&!q(r)&&u&&i.contains(u.input)){z(r),b&&f&&!f.isConnected&&(C&&n.getElementById(C)||u.input).focus(),c=S;return}if(u=void 0,i.replaceChildren(...(S?k(r):[]).filter(w=>!!w)),S&&(!c||b)){const N=(C?n.getElementById(C):null)??i.querySelector("[data-autofocus]")??i.querySelector("input, [role=group] button, button");N?.focus(),N instanceof HTMLInputElement&&N.setSelectionRange(N.value.length,N.value.length)}!S&&c&&s.focus(),c=S}function k(r){if(x?.owns(r))return x.content(r);if(q(r))return T??(T=import("./jobs-CAXbM5-g.js").then(I=>{x=I.jobsUi({controller:e,options:t,el:d,button:a,consentGroup:h,rerender:()=>m(e.state),checkinNotice:R})},()=>{F=true}).then(()=>m(e.state))),[v(),d("p",{class:"muted",role:"status"},"Loading…")];if(r.view==="index"){const I=d("input",{id:"jz-help-search",type:"search","aria-label":"Search help",placeholder:"How do I…",autocomplete:"off"});return I.value=r.query,I.addEventListener("input",()=>e.search(I.value)),u={input:I,status:d("p",{class:"muted",role:"status"}),retry:d("div",{class:"row"},a("Try again",()=>e.open())),request:d("div",{class:"request"}),signal:d("div",{class:"signal"}),list:d("ul",{"aria-label":"Guides"})},z(r),[v(),I,u.status,u.retry,u.request,u.signal,u.list]}if(r.view==="finished")return[v(),d("h2",{},`You finished “${r.guide.title}”`),r.notice&&d("p",{class:"muted",role:"status"},R[r.notice]??""),d("div",{class:"row"},a("More guides",()=>e.open(),{id:"jz-help-more"}),a("Back",()=>e.back()),a("Close",()=>e.close()))];if(r.view!=="guide")return[];if(r.status!=="ready"||!r.guide)return[v(),d("p",{role:"status"},r.status==="loading"?"Loading guide…":"This guide isn't available right now."),d("div",{class:"row"},a("Back",()=>e.open()),a("Close",()=>e.close()))];const f=r.guide,b=f.steps[r.step];if(!b)return[];const C=r.step+1===f.steps.length,S=f.steps.length,w=d("div",{class:"progress","aria-hidden":"true"},d("div",{class:"progress-fill"})),N=w.firstElementChild;N.style.width=`${Math.round((r.step+1)/S*100)}%`;const H=[d("h2",{},f.title),d("p",{class:"muted"},`Step ${r.step+1} of ${S}`),w,d("p",{class:"step-title"},b.title),b.instruction&&d("p",{},b.instruction),r.anchor==="missing"&&d("p",{class:"muted"},"The part of the page this step uses isn't shown here. Follow the steps in the text."),b.screenshotUrl&&U("img",{src:b.screenshotUrl,alt:`Screenshot for: ${b.title}`,loading:"lazy"})];if(f.videoUrl){const I=U("video",{controls:"",preload:"none",src:f.videoUrl});f.captionsUrl&&I.append(U("track",{kind:"captions",src:f.captionsUrl,default:""})),H.push(I)}const y=[v(),d("div",{class:"card"},...H),r.notice&&d("p",{class:"muted",role:"status"},R[r.notice]??"")];return r.checkin==="asking"?y.push(d("div",{class:"checkin",role:"group","aria-label":"Step check-in"},d("p",{},"Did this step make sense?"),d("div",{class:"row"},E("Understood","understood",()=>e.answer("understood")),E("Confused","confused",()=>e.answer("confused")),a("Skip",()=>e.skipCheckin())))):r.checkin==="needs-consent"?y.push(h()):r.checkin==="sending"?y.push(d("p",{role:"status"},"Sending…")):(r.signal==="needs-consent"?y.push(h()):r.signal==="sending"?y.push(d("p",{role:"status"},"Sending…")):r.signalNotice&&y.push(d("p",{class:"muted",role:"status"},Y[r.signalNotice]??"")),e.canSignal()&&y.push(Ee(e,b.index)),y.push(d("div",{class:"row"},a("Back",()=>e.back()),a(C?"Finish":"Next",()=>e.next(),{id:"jz-help-next"}),a("Close",()=>e.close())))),y}function z(r){if(!u)return;const{input:f,status:b,retry:C,request:S,signal:w,list:N}=u;if(f.value!==r.query&&n.activeElement!==f&&(f.value=r.query),b.textContent=r.status==="loading"?"Loading guides…":r.status==="error"?"Help isn't available right now.":r.results.length===0?r.query?`No guide matches “${r.query}”.`:"No guides yet.":"",b.hidden=b.textContent==="",C.hidden=r.status!=="error",r.status==="ready"&&r.query.trim()!==""&&r.results.length===0&&e.canSignal()){const y=r.query.trim();(g!==y||!S.firstElementChild)&&(g=y,S.replaceChildren(Ie(e,y)))}else S.firstElementChild&&(g=void 0,S.replaceChildren());r.signal==="needs-consent"?w.replaceChildren(h()):r.signal==="sending"?w.replaceChildren(d("p",{role:"status"},"Sending…")):r.signalNotice?w.replaceChildren(d("p",{class:"muted",role:"status"},Y[r.signalNotice]??"")):w.firstElementChild&&w.replaceChildren(),N.replaceChildren(...r.results.map((y,I)=>d("li",{},a(y.title||"Untitled guide",()=>e.openGuide(y.journeyId??""),{id:`jz-help-g${I}`}),y.goal?d("p",{class:"muted"},y.goal):void 0)))}const M=e.subscribe(m);return{destroy(){M(),x?.destroy(),s.remove(),i.remove()}}},Ne=500,He=6e3;async function Me(n,e){const t=e.trim();if(!t||[...t].length>Ne||!n.canSignal()||!n.hasConsent())return;const s={siteKey:n.siteKey,consentGiven:true,text:t};n.reviewerToken&&(s.reviewerToken=n.reviewerToken);let i;try{const o=await Promise.race([Promise.resolve(n.claims?.()).then(c=>(c&&(s.claims=c),X(n.endpoint,"RouteIntent",s,n.fetchImpl))),new Promise(c=>i=setTimeout(c,He))]);return o?.jobId?{jobId:o.jobId,journeyId:o.journeyId||void 0}:void 0}catch{return}finally{clearTimeout(i)}}const Le=`
23
- :host {
24
- all: initial;
25
- --jz-canvas:#F7F7F5; --jz-surface:#FFFFFF; --jz-raised:#F0F0EC; --jz-ink:#1D2024; --jz-muted:#5D636B;
26
- --jz-faint:#6C727B; --jz-rule:rgb(29 32 36 / 12%); --jz-accent:#3D63C9; --jz-accent-ink:#FFFFFF;
27
- --jz-accent-soft:rgb(61 99 201 / 10%); --jz-polished:#2F7D4F; --jz-confused:#6E4FC2;
28
- --jz-shadow:0 1px 3px rgb(0 0 0 / 12%);
29
- font: 400 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
30
- color: var(--jz-ink); -webkit-font-smoothing: antialiased;
31
- }
32
- @media (prefers-color-scheme: dark) {
33
- :host {
34
- --jz-canvas:#111316; --jz-surface:#181B1F; --jz-raised:#20242A; --jz-ink:#E8EAED; --jz-muted:#A3A9B2;
35
- --jz-faint:#8A919B; --jz-rule:rgb(232 234 237 / 12%); --jz-accent:#7F9CF0; --jz-accent-ink:#111316;
36
- --jz-accent-soft:rgb(127 156 240 / 14%); --jz-polished:#5DBB84; --jz-confused:#A48BEA;
37
- }
38
- }
39
- *, *::before, *::after { box-sizing: border-box; }
40
- button { font: inherit; color: inherit; cursor: pointer; }
41
- :focus-visible { outline: 2px solid var(--jz-accent); outline-offset: 2px; }
42
- button:disabled { opacity: .45; cursor: not-allowed; }
43
- [hidden] { display: none !important; }
44
-
45
- .launcher { position:fixed; left:24px; bottom:24px; z-index:2147483646; width:44px; height:44px; min-width:44px; min-height:44px;
46
- display:flex; align-items:center; justify-content:center; padding:0; border:1px solid var(--jz-accent); border-radius:999px;
47
- background:var(--jz-accent); color:var(--jz-accent-ink); font-size:18px; font-weight:600; box-shadow:var(--jz-shadow);
48
- transition: background 180ms ease-out, transform 180ms ease-out; }
49
- .launcher:hover, .launcher[aria-expanded="true"] { background:var(--jz-ink); border-color:var(--jz-ink); }
50
-
51
- .panel { position:fixed; left:24px; bottom:80px; z-index:2147483646; width:min(360px, calc(100vw - 48px));
52
- max-height:min(75vh, 580px); overflow:auto; padding:16px; border:1px solid var(--jz-rule); border-radius:10px;
53
- background:var(--jz-surface); color:var(--jz-ink); box-shadow:var(--jz-shadow);
54
- transition: opacity 180ms ease-out, transform 180ms ease-out; }
55
- .panel-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:12px; }
56
- .panel-head h2 { margin:0; font-size:14px; font-weight:600; }
57
- .icon-btn { width:44px; height:44px; min-width:44px; display:flex; align-items:center; justify-content:center; padding:0;
58
- border:0; border-radius:6px; background:transparent; color:var(--jz-faint); transition: color 180ms ease-out, background 180ms ease-out; }
59
- .icon-btn:hover { color:var(--jz-ink); background:var(--jz-raised); }
60
-
61
- .panel input { width:100%; min-height:44px; padding:8px 12px; border:1px solid var(--jz-rule); border-radius:6px;
62
- background:var(--jz-canvas); color:var(--jz-ink); font:inherit; }
63
- .panel input::placeholder { color:var(--jz-faint); }
64
- .panel ul { list-style:none; padding:0; margin:12px 0 0; }
65
- .panel li { margin:0 0 8px; }
66
- .panel li button { display:block; width:100%; min-height:44px; text-align:left; padding:8px 12px; border:1px solid var(--jz-rule);
67
- border-radius:6px; background:var(--jz-surface); color:inherit; font:inherit; transition: background 180ms ease-out, border-color 180ms ease-out; }
68
- .panel li button:hover { background:var(--jz-raised); border-color:var(--jz-accent); }
69
- .muted { color:var(--jz-muted); font-size:12px; margin:4px 0 0; }
70
- .row { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
71
- .row button { min-height:44px; padding:0 16px; border:1px solid var(--jz-rule); border-radius:6px; background:var(--jz-surface);
72
- color:var(--jz-muted); transition: background 180ms ease-out, color 180ms ease-out; }
73
- .row button:hover { color:var(--jz-ink); background:var(--jz-raised); }
74
- .row .primary { border-color:var(--jz-accent); background:var(--jz-accent); color:var(--jz-accent-ink); }
75
-
76
- .card { border:1px solid var(--jz-rule); border-radius:10px; padding:16px; }
77
- .card h2 { margin:0 0 8px; font-size:14px; font-weight:600; }
78
- .progress { height:4px; margin:8px 0 12px; border-radius:999px; background:var(--jz-raised); overflow:hidden; }
79
- .progress-fill { height:100%; border-radius:999px; background:var(--jz-accent); transition: width 180ms ease-out; }
80
- .step-title { margin:0 0 8px; font-weight:600; }
81
- .panel img, .panel video { max-width:100%; margin-top:12px; border:1px solid var(--jz-rule); border-radius:6px; }
82
-
83
- .checkin { margin-top:12px; padding-top:12px; border-top:1px solid var(--jz-rule); }
84
- .checkin p { margin:0 0 8px; }
85
- .callout-btn { display:inline-flex; align-items:center; gap:6px; margin-top:12px; min-height:44px; padding:0 16px;
86
- border:1px solid var(--jz-confused); border-radius:6px; background:var(--jz-surface); color:var(--jz-confused);
87
- transition: background 180ms ease-out, color 180ms ease-out; }
88
- .callout-btn:hover { background:var(--jz-raised); }
89
- .callout-btn svg { flex:none; }
90
- .request { margin-top:12px; }
91
- .request p { margin:0 0 8px; color:var(--jz-muted); font-size:12px; }
92
- .request textarea { display:block; width:100%; padding:8px 12px; border:1px solid var(--jz-rule); border-radius:6px;
93
- background:var(--jz-canvas); color:var(--jz-ink); font:inherit; resize:vertical; }
94
- .request button { margin-top:8px; min-height:44px; padding:0 16px; border:1px solid var(--jz-accent);
95
- border-radius:6px; background:var(--jz-accent); color:var(--jz-accent-ink); }
96
- .checkin-btn { display:inline-flex; align-items:center; gap:6px; }
97
- .checkin-btn.understood { color:var(--jz-polished); border-color:var(--jz-polished); }
98
- .checkin-btn.confused { color:var(--jz-confused); border-color:var(--jz-confused); }
99
- .checkin-btn svg { flex:none; }
100
-
101
- @media (prefers-reduced-motion: reduce) {
102
- :host *, :host *::before, :host *::after { animation-duration:1ms !important; transition-duration:1ms !important; }
103
- }
104
- .jz-help-highlight { position:fixed; z-index:2147483645; pointer-events:none; box-sizing:border-box;
105
- border:2px solid var(--jz-accent); border-radius:6px; box-shadow:0 0 0 4px var(--jz-accent-soft); }
106
- `;function O(n,e,t,s,i){const o={journeyId:e.slug||e.journeyId,journeyStep:String(t.index),pagePath:J(s),device:n.device||Q(i)};return n.persona&&(o.persona=n.persona),n.businessType&&(o.businessType=n.businessType),n.state&&(o.state=n.state),t.tflowId&&(o.tflowId=t.tflowId),o}function $e(n,e,t,s){return O(n,e.guide,e.step,t,s)}function Be(n,e,t){const s={pagePath:J(e),device:n.device||Q(t)};return n.persona&&(s.persona=n.persona),n.journeyId&&(s.journeyId=n.journeyId),n.journeyStep&&(s.journeyStep=n.journeyStep),n.businessType&&(s.businessType=n.businessType),n.state&&(s.state=n.state),s}function De(n,e,t,s,i){if(t.kind==="callout")return{siteKey:n,consentGiven:true,kind:G.callout,context:O(e,t.guide,t.step,s,i)};const o=t.guide&&t.step?O(e,t.guide,t.step,s,i):Be(e,s,i),c={siteKey:n,consentGiven:true,kind:G.request,comment:t.text,context:o};return t.jobRequest&&(c.jobRequest=t.jobRequest),c}function Ue(n,e,t=ze){const s=re(n),i=n.claims!==void 0||n.getToken?import("./claims-BfpRuIu-.js").then(l=>l.claimsSource(n)):void 0,o=i&&(()=>i.then(l=>l.token()));o?.();let c,u;i?.then(l=>u=l);const g=new pe({endpoint:s,siteKey:n.siteKey,reviewerToken:n.reviewerToken,claims:o});let x;const T=X(s,"GetWidgetConfig",{siteKey:n.siteKey}).then(l=>x=l,()=>{}),F=()=>!n.reviewerToken&&!n.userId,q=()=>F()&&x?.helpAudience!="reviewers",a=document.createElement("div");a.setAttribute("data-journeeze-help","");const h=a.attachShadow({mode:"closed"}),v=document.createElement("style");v.textContent=Le,n.nonce&&(v.nonce=n.nonce),h.append(v);const E=new ke(h);document.body.append(a);let m;const k=l=>(m??(m=import("./feedback-DtMDnAam.js").then(A=>A.feedbackChannel(n,s,{memoryOnly:q(),claims:o})))).then(A=>A.outbox.enqueue(l),()=>"dropped");let z,M=false;const r=()=>ce(n),f=()=>q()?null:void 0,b=()=>de(r(),f()),C=te(n,s,e),S=()=>{M&&w.state.view!=="disabled"&&b()&&(z?.start(),C.start(T))},w=new fe({endpoint:s,loadIndex:()=>g.index().then(l=>(c=l.persona||void 0,l)),loadGuide:l=>g.guide(l),highlight:l=>E.show(l),clearHighlight:()=>E.hide(),hasConsent:b,giveConsent(){ae(r(),f()),S()},signalsAllowed:()=>!F()||x?.anonymousAllowed==true,sendCheckin(l){return b()?(z?.checkin(l),k({siteKey:n.siteKey,consentGiven:true,context:$e(e(),l,location.href,window.innerWidth),reaction:ne[l.answer]})):Promise.resolve("dropped")},sendSignal(l){return!w.canSignal()||!b()?Promise.resolve("dropped"):k(De(n.siteKey,e(),l,location.href,window.innerWidth))}});n.noTelemetry||(z=je(s,n.siteKey,w,()=>u?.current())),w.subscribe(S);let N,H=false,y;const I=l=>{const A=l.available?"on":l.reason;if(!(H||A===y)){y=A;try{n.onHelpStatus?.(l)}catch{}}};return w.subscribe(()=>{y!==void 0&&w.state.view==="disabled"&&I({available:false,reason:"disabled"})}),Promise.all([w.probe(),T]).then(()=>{if(!H){if(w.state.view==="disabled")return I({available:false,reason:"disabled"});I(x?.helpAudience=="reviewers"&&!n.reviewerToken?{available:false,reason:"audience"}:{available:true}),M=true,S(),N=t(h,w,{consentText:()=>T.then(l=>l?.consentText||oe),persona:()=>c??e().persona,jobEvent(l){M&&w.state.view!=="disabled"&&b()&&z?.job(l)},routeIntent:l=>Me({endpoint:s,siteKey:n.siteKey,reviewerToken:n.reviewerToken,claims:o,hasConsent:b,canSignal:()=>w.canSignal()},l),addStyle(l){const A=document.createElement("style");A.textContent=l,n.nonce&&(A.nonce=n.nonce),h.append(A)}})}}),{unmount(l){H=true,i?.then(A=>A.stop()),w.close(),z?.stop(l),C.stop(l),N?.destroy(),E.dispose(),a.remove(),m?.then(A=>A.dispose())},contextChanged:()=>{w.refreshHighlight(),C.contextChanged()}}}const We=(n,e)=>Ue(n,()=>le(e()),qe);export{pe as HelpClient,fe as HelpController,ke as Highlighter,ge as MAX_REQUEST_CHARS,Ke as PANEL_CSS,$e as checkinContext,me as findAnchor,O as guideStepContext,B as isHelpDisabled,We as mount,Ue as mountHelp,Be as pageContext,ze as placeholderView,_ as searchGuides,De as signalRequest,ve as toView};