@journeeze/sdk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -2
- package/CHANGELOG.md +13 -1
- package/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +22 -20
- package/dist/anchor-BhsfeHwL.js +1 -0
- package/dist/attach-D451Wj4h.js +21 -0
- package/dist/chat-ByOXN5k1.js +64 -0
- package/dist/claims-BfpRuIu-.js +1 -0
- package/dist/consent-BupCs23W.js +1 -0
- package/dist/contract.js +1 -1
- package/dist/feedback-DtMDnAam.js +1 -0
- package/dist/help-D_T0HiNa.js +106 -0
- package/dist/{hook-DGWypoEO.js → hook-BRnJ-lTk.js} +1 -1
- package/dist/index.js +6 -8
- package/dist/loader-k4pePzAw.js +127 -0
- package/dist/mask-audit-DtKNgOlT.js +5 -0
- package/dist/react.js +1 -1
- package/dist/resolve-7jVqhJhi.js +1 -0
- package/dist/script.js +1 -1
- package/dist/{signals-amjMQyOy.js → signals-eaZX2lNd.js} +1 -1
- package/dist/telemetry-DMGFJcw3.js +1 -0
- package/dist/{transport-B64CfIcF.js → transport-DokImbgl.js} +1 -1
- package/dist/types/chat/capture/attach.d.ts +2 -0
- package/dist/types/chat/shell/converse.d.ts +2 -0
- package/dist/types/chat/transport.d.ts +1 -1
- package/dist/types/claims.d.ts +37 -0
- package/dist/types/help/core/client.d.ts +3 -0
- package/dist/types/help/core/events.d.ts +1 -1
- package/dist/types/help/core/routing.d.ts +2 -0
- package/dist/types/loader.d.ts +3 -0
- package/dist/types/preview/mask-audit.d.ts +3 -1
- package/dist/types/telemetry/telemetry.d.ts +4 -0
- package/dist/types/types.d.ts +34 -0
- package/dist/types/widget/feedback.d.ts +7 -1
- package/dist/types/widget/upload.d.ts +3 -2
- package/dist/{upload-Fu2qvSJV.js → upload-DkAWrJhn.js} +6 -6
- package/dist/widget-CcAalO4B.js +118 -0
- package/package.json +4 -3
- package/LICENSE.md +0 -27
- package/dist/anchor-cPvFFTOS.js +0 -1
- package/dist/attach-DpioALxW.js +0 -21
- package/dist/chat-BgmB0rnW.js +0 -64
- package/dist/consent-DckCUvYR.js +0 -1
- package/dist/context-UnG6_X61.js +0 -17
- package/dist/feedback-CtH1a_kQ.js +0 -1
- package/dist/help-w0O5Qu-4.js +0 -105
- package/dist/index-CwG2LrhO.js +0 -20
- package/dist/loader-BZiIDD1D.js +0 -96
- package/dist/mask-audit-Du3NPoG_.js +0 -5
- package/dist/resolve-BfWByuTp.js +0 -1
- package/dist/telemetry-CyRJDaVs.js +0 -1
- package/dist/widget-B6mR1J3P.js +0 -118
package/dist/types/types.d.ts
CHANGED
|
@@ -155,6 +155,25 @@ export interface JourneezeConfigV1 extends Omit<JourneezeOptions, "endpoint">, J
|
|
|
155
155
|
userIdSig?: string;
|
|
156
156
|
/** Expiry of {@link userIdSig}, Unix seconds (at most 24 h ahead). */
|
|
157
157
|
userIdExp?: number;
|
|
158
|
+
/**
|
|
159
|
+
* Signed claims v2 (contract §15, v1.4 additive; needs Allumata sign-off): a token from the
|
|
160
|
+
* host's server, `base64url(payload) "." base64url(mac)` unpadded, where `payload` is the
|
|
161
|
+
* RFC 8785 canonical JSON of the claims and `mac` is HMAC-SHA256(site identity secret named by
|
|
162
|
+
* `kid`, `"jz-claims-v2\n" + payload`). A bearer token until its `exp` (at most 900 s after
|
|
163
|
+
* `iat`); deliver it like `userId` (authenticated, `no-store`). The SDK never computes it and
|
|
164
|
+
* never sends one that is malformed or expired. When it verifies, the collector takes the user,
|
|
165
|
+
* profile and entitlements from it (entitlement-gated guides are served only with it).
|
|
166
|
+
*/
|
|
167
|
+
claims?: string;
|
|
168
|
+
/**
|
|
169
|
+
* Refresh callback for {@link claims} (contract §15): the SDK calls it for a fresh token when the
|
|
170
|
+
* current one is missing or has 60 s or less left, and after {@link JourneezeHandleV1.reset}
|
|
171
|
+
* (a token for one profile is never used after a switch). A token's life is `exp − iat` from when
|
|
172
|
+
* the page first saw it (the page's clock may be wrong). One call at a time, at most one per 15 s
|
|
173
|
+
* while the current token still works; feedback and telemetry sends never wait for it. A
|
|
174
|
+
* rejection or a malformed result warns once and is never sent.
|
|
175
|
+
*/
|
|
176
|
+
getToken?: () => Promise<string>;
|
|
158
177
|
/**
|
|
159
178
|
* A CSP nonce set on every `<style>` the SDK injects (in its shadow roots), so hosts with
|
|
160
179
|
* `style-src 'nonce-…'` need no `'unsafe-inline'`.
|
|
@@ -290,6 +309,8 @@ export interface SubmitFeedbackRequest {
|
|
|
290
309
|
* the optional "so you can…" answer and the job it follows ("Not possible here").
|
|
291
310
|
*/
|
|
292
311
|
jobRequest?: WireJobRequest;
|
|
312
|
+
/** Signed claims v2 (contract §15): sent while well formed and unexpired. */
|
|
313
|
+
claims?: string;
|
|
293
314
|
}
|
|
294
315
|
/** `JobRequest` (engagement.proto): never telemetry, only ever inside a consented request. */
|
|
295
316
|
export interface WireJobRequest {
|
|
@@ -345,10 +366,14 @@ export interface CreateScreenshotUploadRequest {
|
|
|
345
366
|
userIdExp?: number;
|
|
346
367
|
/** Signed host identity (C0a §4 v1.3, collector.proto `user_id_sig = 8`). */
|
|
347
368
|
userIdSig?: string;
|
|
369
|
+
/** Signed claims v2 (contract §15): sent while well formed and unexpired. */
|
|
370
|
+
claims?: string;
|
|
348
371
|
}
|
|
349
372
|
/** `GetHelpIndex` (collector.proto): the site's published guides. Read-only, no consent needed. */
|
|
350
373
|
export interface GetHelpIndexRequest {
|
|
351
374
|
siteKey: string;
|
|
375
|
+
/** Signed claims v2 (contract §15): entitlement-gated guides are listed only with it. */
|
|
376
|
+
claims?: string;
|
|
352
377
|
}
|
|
353
378
|
export interface HelpIndexEntry {
|
|
354
379
|
journeyId?: string;
|
|
@@ -386,6 +411,11 @@ export interface GetHelpIndexResponse {
|
|
|
386
411
|
version?: string;
|
|
387
412
|
/** The project's approved jobs, in catalog order (P4e1). */
|
|
388
413
|
jobs?: HelpJobEntry[];
|
|
414
|
+
/**
|
|
415
|
+
* Signed claims v2 (contract §15): the verified `profile.kind`, empty without a verified token.
|
|
416
|
+
* Help picks persona guides for it over the page's unsigned `context.persona`.
|
|
417
|
+
*/
|
|
418
|
+
persona?: string;
|
|
389
419
|
}
|
|
390
420
|
/**
|
|
391
421
|
* `RouteIntent` (collector.proto, P6d): the reader's words in help's "Something else", matched to
|
|
@@ -397,6 +427,8 @@ export interface RouteIntentRequest {
|
|
|
397
427
|
/** Trimmed, 1..=500 characters. */
|
|
398
428
|
text: string;
|
|
399
429
|
reviewerToken?: string;
|
|
430
|
+
/** Signed claims v2 (contract §15): sent while well formed and unexpired. */
|
|
431
|
+
claims?: string;
|
|
400
432
|
}
|
|
401
433
|
/** A routed job and its guide for any persona, or empty fields: nothing routed. Never text. */
|
|
402
434
|
export interface RouteIntentResponse {
|
|
@@ -407,6 +439,8 @@ export interface RouteIntentResponse {
|
|
|
407
439
|
export interface GetGuideRequest {
|
|
408
440
|
siteKey: string;
|
|
409
441
|
journeyId: string;
|
|
442
|
+
/** Signed claims v2 (contract §15): an entitlement-gated guide is served only with it. */
|
|
443
|
+
claims?: string;
|
|
410
444
|
}
|
|
411
445
|
export interface GuideStep {
|
|
412
446
|
index?: number;
|
|
@@ -16,8 +16,14 @@ export interface FeedbackChannelHooks {
|
|
|
16
16
|
* help (ADR 0013 §3). Unsent items are then lost when the page goes away.
|
|
17
17
|
*/
|
|
18
18
|
memoryOnly?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Signed claims v2 (contract §15): refreshes the token for later sends. A send never waits for
|
|
21
|
+
* it (sends are keepalive and may run while the page unloads): it carries the current token
|
|
22
|
+
* while it is usable, else none. The token is never stored.
|
|
23
|
+
*/
|
|
24
|
+
claims?: (() => Promise<string | undefined>) | undefined;
|
|
19
25
|
}
|
|
20
|
-
type ChannelOptions = JourneezeOptions & Partial<Pick<MountOptions, "userId" | "pagePath" | "apiHost" | "apiPath">>;
|
|
26
|
+
type ChannelOptions = JourneezeOptions & Partial<Pick<MountOptions, "userId" | "pagePath" | "apiHost" | "apiPath" | "claims">>;
|
|
21
27
|
/**
|
|
22
28
|
* Whose outbox items these are (contract §9, v1.1): the reviewer token on reviewer sites, else the
|
|
23
29
|
* signed-in user, else anonymous. A page claims only its own owner's items.
|
|
@@ -9,6 +9,7 @@ export declare function uploadTarget(uploadUrl: string, endpoint: string): strin
|
|
|
9
9
|
/**
|
|
10
10
|
* Reserves and PUTs one masked image; resolves its `screenshotId`, or `undefined` when the bytes
|
|
11
11
|
* were refused. A failed reservation rejects with the collector's error (the caller decides
|
|
12
|
-
* whether uploads are unavailable). Call only after consent.
|
|
12
|
+
* whether uploads are unavailable). Call only after consent. `claims`: the signed claims v2 token
|
|
13
|
+
* to send (contract §15), already checked by the caller's claims source.
|
|
13
14
|
*/
|
|
14
|
-
export declare function putScreenshot(endpoint: string, options: MountOptions, blob: Blob, fetchImpl?: typeof fetch): Promise<string | undefined>;
|
|
15
|
+
export declare function putScreenshot(endpoint: string, options: MountOptions, blob: Blob, fetchImpl?: typeof fetch, claims?: string): Promise<string | undefined>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{
|
|
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(`
|
|
2
2
|
.______background-clip--text {
|
|
3
3
|
background-clip: text;
|
|
4
4
|
-webkit-background-clip: text;
|
|
5
5
|
}
|
|
6
|
-
`);return t.appendChild(r),t}function mt(e,t){let{width:r,height:n}=t;if(E(e)&&(!r||!n)){const s=e.getBoundingClientRect();r=r||s.width||Number(e.getAttribute("width"))||0,n=n||s.height||Number(e.getAttribute("height"))||0}return{width:r,height:n}}async function gt(e,t){const{log:r,timeout:n,drawImageCount:s,drawImageInterval:o}=t;r.time("image to canvas");const a=await _(e,{timeout:n,onWarn:t.log.warn}),{canvas:i,context2d:l}=ht(e.ownerDocument,t),m=()=>{try{l?.drawImage(a,0,0,i.width,i.height)}catch(c){t.log.warn("Failed to drawImage",c)}};if(m(),t.isEnable("fixSvgXmlDecode"))for(let c=0;c<s;c++)await new Promise(
|
|
7
|
-
`);let y=i.get(w);y||(y=[],i.set(w,y)),y.push(`.${f[0]}${c}`)}At.forEach(m),r&&Nt.forEach(m)}const
|
|
8
|
-
`))}else{const l=Array.from(r.styleSheets).filter(f=>{try{return"cssRules"in f&&!!f.cssRules.length}catch(d){return t.log.warn(`Error while reading CSS rules from ${f.href}`,d),false}}),m=r.implementation.createHTMLDocument(""),c=m.createElement("style");m.head.appendChild(c);const
|
|
6
|
+
`);return t.appendChild(r),t}function mt(e,t){let{width:r,height:n}=t;if(E(e)&&(!r||!n)){const s=e.getBoundingClientRect();r=r||s.width||Number(e.getAttribute("width"))||0,n=n||s.height||Number(e.getAttribute("height"))||0}return{width:r,height:n}}async function gt(e,t){const{log:r,timeout:n,drawImageCount:s,drawImageInterval:o}=t;r.time("image to canvas");const a=await _(e,{timeout:n,onWarn:t.log.warn}),{canvas:i,context2d:l}=ht(e.ownerDocument,t),m=()=>{try{l?.drawImage(a,0,0,i.width,i.height)}catch(c){t.log.warn("Failed to drawImage",c)}};if(m(),t.isEnable("fixSvgXmlDecode"))for(let c=0;c<s;c++)await new Promise(g=>{setTimeout(()=>{l?.clearRect(0,0,i.width,i.height),m(),g()},c+o)});return t.drawImageCount=0,r.timeEnd("image to canvas"),i}function ht(e,t){const{width:r,height:n,scale:s,backgroundColor:o,maximumCanvasSize:a}=t,i=e.createElement("canvas");i.width=Math.floor(r*s),i.height=Math.floor(n*s),i.style.width=`${r}px`,i.style.height=`${n}px`,a&&(i.width>a||i.height>a)&&(i.width>a&&i.height>a?i.width>i.height?(i.height*=a/i.width,i.width=a):(i.width*=a/i.height,i.height=a):i.width>a?(i.height*=a/i.width,i.width=a):(i.width*=a/i.height,i.height=a));const l=i.getContext("2d");return l&&o&&(l.fillStyle=o,l.fillRect(0,0,i.width,i.height)),{canvas:i,context2d:l}}function fe(e,t){if(e.ownerDocument)try{const o=e.toDataURL();if(o!=="data:,")return A(o,e.ownerDocument)}catch(o){t.log.warn("Failed to clone canvas",o)}const r=e.cloneNode(false),n=e.getContext("2d"),s=r.getContext("2d");try{return n&&s&&s.putImageData(n.getImageData(0,0,e.width,e.height),0,0),r}catch(o){t.log.warn("Failed to clone canvas",o)}return r}function pt(e,t){try{if(e?.contentDocument?.documentElement)return q(e.contentDocument.documentElement,t)}catch(r){t.log.warn("Failed to clone iframe",r)}return e.cloneNode(false)}function wt(e){const t=e.cloneNode(false);return e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager"),t}async function yt(e,t){if(e.ownerDocument&&!e.currentSrc&&e.poster)return A(e.poster,e.ownerDocument);const r=e.cloneNode(false);r.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(r.src=e.currentSrc);const n=r.ownerDocument;if(n){let s=true;if(await _(r,{onError:()=>s=false,onWarn:t.log.warn}),!s)return e.poster?A(e.poster,e.ownerDocument):r;r.currentTime=e.currentTime,await new Promise(a=>{r.addEventListener("seeked",a,{once:true})});const o=n.createElement("canvas");o.width=e.offsetWidth,o.height=e.offsetHeight;try{const a=o.getContext("2d");a&&a.drawImage(r,0,0,o.width,o.height)}catch(a){return t.log.warn("Failed to clone video",a),e.poster?A(e.poster,e.ownerDocument):r}return fe(o,t)}return r}function bt(e,t){return Ge(e)?fe(e,t):rt(e)?pt(e,t):k(e)?wt(e):$(e)?yt(e,t):e.cloneNode(false)}function St(e){let t=e.sandbox;if(!t){const{ownerDocument:r}=e;try{r&&(t=r.createElement("iframe"),t.id=`__SANDBOX__${ae()}`,t.width="0",t.height="0",t.style.visibility="hidden",t.style.position="fixed",r.body.appendChild(t),t.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',e.sandbox=t)}catch(n){e.log.warn("Failed to getSandBox",n)}}return t}const Et=["width","height","-webkit-text-fill-color"],vt=["stroke","fill"];function de(e,t,r){const{defaultComputedStyles:n}=r,s=e.nodeName.toLowerCase(),o=I(e)&&s!=="svg",a=o?vt.map(u=>[u,e.getAttribute(u)]).filter(([,u])=>u!==null):[],i=[o&&"svg",s,a.map((u,p)=>`${u}=${p}`).join(","),t].filter(Boolean).join(":");if(n.has(i))return n.get(i);const m=St(r)?.contentWindow;if(!m)return new Map;const c=m?.document;let g,h;o?(g=c.createElementNS(O,"svg"),h=g.ownerDocument.createElementNS(g.namespaceURI,s),a.forEach(([u,p])=>{h.setAttributeNS(null,u,p)}),g.appendChild(h)):g=h=c.createElement(s),h.textContent=" ",c.body.appendChild(g);const f=m.getComputedStyle(h,t),d=new Map;for(let u=f.length,p=0;p<u;p++){const w=f.item(p);Et.includes(w)||d.set(w,f.getPropertyValue(w))}return c.body.removeChild(g),n.set(i,d),d}function me(e,t,r){const n=new Map,s=[],o=new Map;if(r)for(const i of r)a(i);else for(let i=e.length,l=0;l<i;l++){const m=e.item(l);a(m)}for(let i=s.length,l=0;l<i;l++)o.get(s[l])?.forEach((m,c)=>n.set(c,m));function a(i){const l=e.getPropertyValue(i),m=e.getPropertyPriority(i),c=i.lastIndexOf("-"),g=c>-1?i.substring(0,c):void 0;if(g){let h=o.get(g);h||(h=new Map,o.set(g,h)),h.set(i,[l,m])}t.get(i)===l&&!m||(g?s.push(g):n.set(i,[l,m]))}return n}function Ct(e,t,r,n){const{ownerWindow:s,includeStyleProperties:o,currentParentNodeStyle:a}=n,i=t.style,l=s.getComputedStyle(e),m=de(e,null,n);a?.forEach((g,h)=>{m.delete(h)});const c=me(l,m,o);c.delete("transition-property"),c.delete("all"),c.delete("d"),c.delete("content"),r&&(c.delete("position"),c.delete("margin-top"),c.delete("margin-right"),c.delete("margin-bottom"),c.delete("margin-left"),c.delete("margin-block-start"),c.delete("margin-block-end"),c.delete("margin-inline-start"),c.delete("margin-inline-end"),c.set("box-sizing",["border-box",""])),c.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text"),oe&&(c.has("font-kerning")||c.set("font-kerning",["normal",""]),(c.get("overflow-x")?.[0]==="hidden"||c.get("overflow-y")?.[0]==="hidden")&&c.get("text-overflow")?.[0]==="ellipsis"&&e.scrollWidth===e.clientWidth&&c.set("text-overflow",["clip",""]));for(let g=i.length,h=0;h<g;h++)i.removeProperty(i.item(h));return c.forEach(([g,h],f)=>{i.setProperty(f,g,h)}),c}function Tt(e,t){(Ke(e)||Ye(e)||et(e))&&t.setAttribute("value",e.value)}const At=["::before","::after"],Nt=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];function kt(e,t,r,n,s){const{ownerWindow:o,svgStyleElement:a,svgStyles:i,currentNodeStyle:l}=n;if(!a||!o)return;function m(c){const g=o.getComputedStyle(e,c);let h=g.getPropertyValue("content");if(!h||h==="none")return;s?.(h),h=h.replace(/(')|(")|(counter\(.+\))/g,"");const f=[ae()],d=de(e,c,n);l?.forEach((b,S)=>{d.delete(S)});const u=me(g,d,n.includeStyleProperties);u.delete("content"),u.delete("-webkit-locale"),u.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text");const p=[`content: '${h}';`];if(u.forEach(([b,S],C)=>{p.push(`${C}: ${b}${S?" !important":""};`)}),p.length===1)return;try{t.className=[t.className,...f].join(" ")}catch(b){n.log.warn("Failed to copyPseudoClass",b);return}const w=p.join(`
|
|
7
|
+
`);let y=i.get(w);y||(y=[],i.set(w,y)),y.push(`.${f[0]}${c}`)}At.forEach(m),r&&Nt.forEach(m)}const G=new Set(["symbol"]);async function K(e,t,r,n,s){if(E(r)&&(Je(r)||Qe(r))||n.filter&&!n.filter(r))return;G.has(t.nodeName)||G.has(r.nodeName)?n.currentParentNodeStyle=void 0:n.currentParentNodeStyle=n.currentNodeStyle;const o=await q(r,n,false,s);n.isEnable("restoreScrollPosition")&&xt(e,o),t.appendChild(o)}async function Y(e,t,r,n){let s=e.firstChild;E(e)&&e.shadowRoot&&(s=e.shadowRoot?.firstChild,r.shadowRoots.push(e.shadowRoot));for(let o=s;o;o=o.nextSibling)if(!Xe(o))if(E(o)&&tt(o)&&typeof o.assignedNodes=="function"){const a=o.assignedNodes();for(let i=0;i<a.length;i++)await K(e,t,a[i],r,n)}else await K(e,t,o,r,n)}function xt(e,t){if(!R(e)||!R(t))return;const{scrollTop:r,scrollLeft:n}=e;if(!r&&!n)return;const{transform:s}=t.style,o=new DOMMatrix(s),{a,b:i,c:l,d:m}=o;o.a=1,o.b=0,o.c=0,o.d=1,o.translateSelf(-n,-r),o.a=a,o.b=i,o.c=l,o.d=m,t.style.transform=o.toString()}function Rt(e,t){const{backgroundColor:r,width:n,height:s,style:o}=t,a=e.style;if(r&&a.setProperty("background-color",r,"important"),n&&a.setProperty("width",`${n}px`,"important"),s&&a.setProperty("height",`${s}px`,"important"),o)for(const i in o)a[i]=o[i]}const _t=/^[\w-:]+$/;async function q(e,t,r=false,n){const{ownerDocument:s,ownerWindow:o,fontFamilies:a,onCloneEachNode:i}=t;if(s&&Ze(e))return n&&/\S/.test(e.data)&&n(e.data),s.createTextNode(e.data);if(s&&o&&E(e)&&(R(e)||I(e))){const m=await bt(e,t);if(t.isEnable("removeAbnormalAttributes")){const u=m.getAttributeNames();for(let p=u.length,w=0;w<p;w++){const y=u[w];_t.test(y)||m.removeAttribute(y)}}const c=t.currentNodeStyle=Ct(e,m,r,t);r&&Rt(m,t);let g=false;if(t.isEnable("copyScrollbar")){const u=[c.get("overflow-x")?.[0],c.get("overflow-y")?.[0]];g=u.includes("scroll")||(u.includes("auto")||u.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}const h=c.get("text-transform")?.[0],f=ce(c.get("font-family")?.[0]),d=f?u=>{h==="uppercase"?u=u.toUpperCase():h==="lowercase"?u=u.toLowerCase():h==="capitalize"&&(u=u[0].toUpperCase()+u.substring(1)),f.forEach(p=>{let w=a.get(p);w||a.set(p,w=new Set),u.split("").forEach(y=>w.add(y))})}:void 0;return kt(e,m,g,t,d),Tt(e,m),$(e)||await Y(e,m,t,d),await i?.(m),m}const l=e.cloneNode(false);return await Y(e,l,t),await i?.(l),l}function Dt(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){e.log.warn("Failed to destroyContext",t)}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[],e.shadowRoots=[]}function It(e){const{url:t,timeout:r,responseType:n,...s}=e,o=new AbortController,a=r?setTimeout(()=>o.abort(),r):void 0;return fetch(t,{signal:o.signal,...s}).then(i=>{if(!i.ok)throw new Error("Failed fetch, not 2xx response",{cause:i});switch(n){case"arrayBuffer":return i.arrayBuffer();case"dataUrl":return i.blob().then(ct);default:return i.text()}}).finally(()=>clearTimeout(a))}function D(e,t){const{url:r,requestType:n="text",responseType:s="text",imageDom:o}=t;let a=r;const{timeout:i,acceptOfImage:l,requests:m,fetchFn:c,fetch:{requestInit:g,bypassingCache:h,placeholderImage:f},font:d,workers:u,fontFamilies:p}=e;n==="image"&&(L||V)&&e.drawImageCount++;let w=m.get(r);if(!w){h&&h instanceof RegExp&&h.test(a)&&(a+=(/\?/.test(a)?"&":"?")+new Date().getTime());const y=n.startsWith("font")&&d&&d.minify,b=new Set;y&&n.split(";")[1].split(",").forEach(P=>{p.has(P)&&p.get(P).forEach(H=>b.add(H))});const S=y&&b.size,C={url:a,timeout:i,responseType:S?"arrayBuffer":s,headers:n==="image"?{accept:l}:void 0,...g};w={type:n,resolve:void 0,reject:void 0,response:null},w.response=(async()=>{if(c&&n==="image"){const v=await c(r);if(v)return v}return!L&&r.startsWith("http")&&u.length?new Promise((v,P)=>{u[m.size&u.length-1].postMessage({rawUrl:r,...C}),w.resolve=v,w.reject=P}):It(C)})().catch(v=>{if(m.delete(r),n==="image"&&f)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",a),typeof f=="string"?f:f(o);throw v}),m.set(r,w)}return w.response}async function ge(e,t,r,n){if(!he(e))return e;for(const[s,o]of Pt(e,t))try{const a=await D(r,{url:o,requestType:n?"image":"text",responseType:"dataUrl"});e=e.replace(Ft(s),`$1${a}$3`)}catch(a){r.log.warn("Failed to fetch css data url",s,a)}return e}function he(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}const pe=/url\((['"]?)([^'"]+?)\1\)/g;function Pt(e,t){const r=[];return e.replace(pe,(n,s,o)=>(r.push([o,ie(o,t)]),n)),r.filter(([n])=>!z(n))}function Ft(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}const Lt=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function $t(e,t){return Lt.map(r=>{const n=e.getPropertyValue(r);return!n||n==="none"?null:((L||V)&&t.drawImageCount++,ge(n,null,t,true).then(s=>{!s||n===s||e.setProperty(r,s,e.getPropertyPriority(r))}))}).filter(Boolean)}function Mt(e,t){if(k(e)){const r=e.currentSrc||e.src;if(!z(r))return[D(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(n=>{n&&(e.srcset="",e.dataset.originalSrc=r,e.src=n||"")})];(L||V)&&t.drawImageCount++}else if(I(e)&&!z(e.href.baseVal)){const r=e.href.baseVal;return[D(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(n=>{n&&(e.dataset.originalSrc=r,e.href.baseVal=n||"")})]}return[]}function Ot(e,t){const{ownerDocument:r,svgDefsElement:n}=t,s=e.getAttribute("href")??e.getAttribute("xlink:href");if(!s)return[];const[o,a]=s.split("#");if(a){const i=`#${a}`,l=t.shadowRoots.reduce((m,c)=>m??c.querySelector(`svg ${i}`),r?.querySelector(`svg ${i}`));if(o&&e.setAttribute("href",i),n?.querySelector(i))return[];if(l)return n?.appendChild(l.cloneNode(true)),[];if(o)return[D(t,{url:o,responseType:"text"}).then(m=>{n?.insertAdjacentHTML("beforeend",m)})]}return[]}function we(e,t){const{tasks:r}=t;E(e)&&((k(e)||se(e))&&r.push(...Mt(e,t)),He(e)&&r.push(...Ot(e,t))),R(e)&&r.push(...$t(e.style,t)),e.childNodes.forEach(n=>{we(n,t)})}async function Ut(e,t){const{ownerDocument:r,svgStyleElement:n,fontFamilies:s,fontCssTexts:o,tasks:a,font:i}=t;if(!(!r||!n||!s.size))if(i&&i.cssText){const l=Q(i.cssText,t);n.appendChild(r.createTextNode(`${l}
|
|
8
|
+
`))}else{const l=Array.from(r.styleSheets).filter(f=>{try{return"cssRules"in f&&!!f.cssRules.length}catch(d){return t.log.warn(`Error while reading CSS rules from ${f.href}`,d),false}}),m=r.implementation.createHTMLDocument(""),c=m.createElement("style");m.head.appendChild(c);const g=c.sheet;await Promise.all(l.flatMap(f=>Array.from(f.cssRules).map(async d=>{if(Ve(d)){const u=d.href;let p="";try{p=await D(t,{url:u,requestType:"text",responseType:"text"})}catch(y){t.log.warn(`Error fetch remote css import from ${u}`,y)}const w=p.replace(pe,(y,b,S)=>y.replace(S,ie(S,u)));for(const y of zt(w))try{g.insertRule(y,g.cssRules.length)}catch(b){t.log.warn("Error inserting rule from remote css import",{rule:y,error:b})}}}))),g.cssRules.length&&l.push(g);const h=[];l.forEach(f=>{W(f.cssRules,h)}),h.filter(f=>je(f)&&he(f.style.getPropertyValue("src"))&&ce(f.style.getPropertyValue("font-family"))?.some(d=>s.has(d))).forEach(f=>{const d=f,u=o.get(d.cssText);u?n.appendChild(r.createTextNode(`${u}
|
|
9
9
|
`)):a.push(ge(d.cssText,d.parentStyleSheet?d.parentStyleSheet.href:null,t).then(p=>{p=Q(p,t),o.set(d.cssText,p),n.appendChild(r.createTextNode(`${p}
|
|
10
|
-
`))}))})}}const Bt=/(\/\*[\s\S]*?\*\/)/g,J=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function zt(e){if(e==null)return[];const t=[];let r=e.replace(Bt,"");for(;;){const o=J.exec(r);if(!o)break;t.push(o[0])}r=r.replace(J,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let o=n.exec(r);if(o)s.lastIndex=n.lastIndex;else if(o=s.exec(r),o)n.lastIndex=s.lastIndex;else break;t.push(o[0])}return t}const Wt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,jt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Q(e,t){const{font:r}=t,n=r?r?.preferredFormat:void 0;return n?e.replace(jt,s=>{for(;;){const[o,,a]=Wt.exec(s)||[];if(!a)return"";if(a===n)return`src: ${o};`}}):e}function W(e,t=[]){for(const r of Array.from(e))qe(r)?t.push(...W(r.cssRules)):"cssRules"in r?W(r.cssRules,t):t.push(r);return t}const Vt=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;function qt(e){return Vt.test(e.innerHTML)}async function ye(e,t){const r=await le(e,t);if(E(r.node)&&I(r.node)&&!qt(r.node))return r.node;const{ownerDocument:n,log:s,tasks:o,svgStyleElement:a,svgDefsElement:i,svgStyles:l,font:m,progress:c,autoDestruct:
|
|
10
|
+
`))}))})}}const Bt=/(\/\*[\s\S]*?\*\/)/g,J=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function zt(e){if(e==null)return[];const t=[];let r=e.replace(Bt,"");for(;;){const o=J.exec(r);if(!o)break;t.push(o[0])}r=r.replace(J,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let o=n.exec(r);if(o)s.lastIndex=n.lastIndex;else if(o=s.exec(r),o)n.lastIndex=s.lastIndex;else break;t.push(o[0])}return t}const Wt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,jt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Q(e,t){const{font:r}=t,n=r?r?.preferredFormat:void 0;return n?e.replace(jt,s=>{for(;;){const[o,,a]=Wt.exec(s)||[];if(!a)return"";if(a===n)return`src: ${o};`}}):e}function W(e,t=[]){for(const r of Array.from(e))qe(r)?t.push(...W(r.cssRules)):"cssRules"in r?W(r.cssRules,t):t.push(r);return t}const Vt=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;function qt(e){return Vt.test(e.innerHTML)}async function ye(e,t){const r=await le(e,t);if(E(r.node)&&I(r.node)&&!qt(r.node))return r.node;const{ownerDocument:n,log:s,tasks:o,svgStyleElement:a,svgDefsElement:i,svgStyles:l,font:m,progress:c,autoDestruct:g,onCloneNode:h,onEmbedNode:f,onCreateForeignObjectSvg:d}=r;s.time("clone node");const u=await q(r.node,r,true);if(a&&n){let S="";l.forEach((C,v)=>{S+=`${C.join(`,
|
|
11
11
|
`)} {
|
|
12
12
|
${v}
|
|
13
13
|
}
|
|
14
|
-
`}),a.appendChild(n.createTextNode(S))}s.timeEnd("clone node"),await
|
|
14
|
+
`}),a.appendChild(n.createTextNode(S))}s.timeEnd("clone node"),await h?.(u),m!==false&&E(u)&&(s.time("embed web font"),await Ut(u,r),s.timeEnd("embed web font")),s.time("embed node"),we(u,r);const p=o.length;let w=0;const y=async()=>{for(;;){const S=o.pop();if(!S)break;try{await S}catch(C){r.log.warn("Failed to run task",C)}c?.(++w,p)}};c?.(w,p),await Promise.all([...Array.from({length:4})].map(y)),s.timeEnd("embed node"),await f?.(u);const b=Ht(u,r);return i&&b.insertBefore(i,b.children[0]),a&&b.insertBefore(a,b.children[0]),g&&Dt(r),await d?.(b),b}function Ht(e,t){const{width:r,height:n}=t,s=st(r,n,e.ownerDocument),o=s.ownerDocument.createElementNS(s.namespaceURI,"foreignObject");return o.setAttributeNS(null,"x","0%"),o.setAttributeNS(null,"y","0%"),o.setAttributeNS(null,"width","100%"),o.setAttributeNS(null,"height","100%"),o.append(e),s.appendChild(o),s}async function Xt(e,t){const r=await le(e,t),n=await ye(r),s=it(n,r.isEnable("removeControlCharacter"));r.autoDestruct||(r.svgStyleElement=ue(r.ownerDocument),r.svgDefsElement=r.ownerDocument?.createElementNS(O,"defs"),r.svgStyles.clear());const o=A(s,n.ownerDocument);return await gt(o,r)}const Zt="iframe, frame, object, embed, video, audio, canvas",Gt=e=>Te(e)||e.matches(Zt),Kt="[data-journeeze], [data-journeeze-chat]",Yt="[data-jz-block]",Jt=2*1024*1024,Qt=1600;class be extends Error{}const T=1,x=3,er=8;function Se(e,t={}){const r=[e],n=new Map,s=ir([...t.maskSelectors??[],...t.configMaskSelectors??[]]),o={},a=t.maskAllText===true,i=f=>Gt(f)||s.some(d=>{try{return f.matches(d)}catch{return true}});let l;const m=f=>{if(f.nodeType===T){const d=f;if(d.matches(Kt))return n.set(d,"drop"),false;if(d.matches(Yt))return n.set(d,"empty"),false;if(sr(d)||i(d))return n.set(d,"replace"),false;const u=B(d);if(u)return o[u]=(o[u]??0)+1,n.set(d,"replace"),false}return f.nodeType!==x&&r.push(f),true},c=f=>{const d=r.pop();if(!d||d.nodeName!==f.nodeName){l??(l="clone order mismatch");return}d.nodeType===T&&f.nodeType===T&&g(d,f)};function g(f,d){const u=Array.from(d.childNodes),p=d.ownerDocument??document;let w=0;for(const y of tr(f)){const b=n.get(y);if(b==="drop")continue;if(b==="replace"){d.insertBefore(nr(y,p),u[w]??null);continue}if(b==="empty"){d.insertBefore(or(y,p),u[w]??null);continue}const S=u[w];if(S===void 0){l??(l="missing clone child");return}w++,a&&y.nodeType===x&&S.nodeType===x&&y.data.trim()!==""&&d.replaceChild(ar(y,p),S)}w!==u.length&&(l??(l="unexpected clone child"))}return{filter:m,onCloneEachNode:c,onCloneNode:f=>{if(r.length!==0&&(l??(l="unbalanced clone traversal")),f.nodeType===T){const d=[f,...Array.from(f.querySelectorAll("*"))];d.some(u=>i(u)||B(u)!==void 0)&&(l??(l="maskable element in clone")),a&&d.some(ve)&&(l??(l="text in clone"))}if(l!==void 0)throw new be(l)},failure:()=>l,detectorCounts:()=>({...o})}}function tr(e){const t=[],r=e.shadowRoot?Array.from(e.shadowRoot.childNodes):Array.from(e.childNodes);for(const n of r)if(n.nodeType!==er){if(n.nodeType===T&&n.tagName==="SLOT"&&typeof n.assignedNodes=="function"){for(const s of n.assignedNodes())ee(s)||t.push(s);continue}ee(n)||t.push(n)}return t}function ee(e){return e.nodeType===T&&(e.tagName==="STYLE"||e.tagName==="SCRIPT")}const rr=["position","top","right","bottom","left","float","clear","z-index","margin-top","margin-right","margin-bottom","margin-left","flex-grow","flex-shrink","flex-basis","align-self","justify-self","order","grid-row-start","grid-row-end","grid-column-start","grid-column-end","vertical-align","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","transform","visibility"];function nr(e,t){return Ee(e,t,true)}function or(e,t){return Ee(e,t,false)}function Ee(e,t,r){const s=e.ownerDocument.defaultView?.getComputedStyle(e),o=e.getBoundingClientRect(),a=e instanceof HTMLElement?e.offsetWidth:o.width,i=e instanceof HTMLElement?e.offsetHeight:o.height,l=s?.display??"block",m=t.createElement(l.startsWith("inline")?"span":"div"),c=m.style;for(const g of rr){const h=s?.getPropertyValue(g);h&&c.setProperty(g,h)}return c.setProperty("display",l==="none"?"none":l==="inline"||l.startsWith("inline")?"inline-block":"block"),c.setProperty("box-sizing","border-box"),c.setProperty("width",`${a}px`),c.setProperty("height",`${i}px`),c.setProperty("border",r?"1px dashed #8A9099":"0"),c.setProperty("background",r?"repeating-linear-gradient(45deg, rgb(138 144 153 / 18%) 0 4px, rgb(138 144 153 / 32%) 4px 8px)":"transparent"),m.setAttribute(r?"data-jz-masked-placeholder":"data-jz-block-placeholder",""),m}function sr(e){if(!e.tagName.toLowerCase().includes("-")||e.shadowRoot)return false;const t=e.getBoundingClientRect();if(t.width<=0||t.height<=0)return false;for(const r of Array.from(e.childNodes))if(r.nodeType===T||r.nodeType===x&&r.data.trim()!=="")return false;return true}function ir(e){for(const t of e??[])try{document.createDocumentFragment().querySelector(t)}catch{throw te||console.warn("[journeeze] invalid maskSelectors entry: screenshots are off"),te=true,new be("invalid maskSelectors")}return[...e??[]]}let te=false;function ve(e){for(const t of Array.from(e.childNodes))if(t.nodeType===x&&t.data.trim()!==""||t.nodeType===T&&ve(t))return true;return false}function ar(e,t){const r=t.createRange();r.selectNodeContents(e);const n=r.getBoundingClientRect(),s=t.createElement("span"),o=s.style;return o.setProperty("display","inline-block"),o.setProperty("width",`${n.width}px`),o.setProperty("height",`${n.height}px`),o.setProperty("background","repeating-linear-gradient(45deg, rgb(138 144 153 / 18%) 0 4px, rgb(138 144 153 / 32%) 4px 8px)"),s.setAttribute("data-jz-masked-placeholder",""),s}function re(e,t){const r=parseFloat(e.ownerDocument.defaultView?.getComputedStyle(e).getPropertyValue(t)??"0");return Number.isFinite(r)?r:0}function Ce(e,t,r,n){const s=e.ownerDocument.defaultView??window;return{width:s.innerWidth,height:s.innerHeight,scale:r,quality:n,type:"image/webp",timeout:4e3,style:{marginTop:`${re(e,"margin-top")-s.scrollY}px`,marginLeft:`${re(e,"margin-left")-s.scrollX}px`},filter:t.filter,onCloneEachNode:t.onCloneEachNode,onCloneNode:t.onCloneNode}}async function hr(e=document.body,t={}){return(await cr(e,t)).blob}async function cr(e=document.body,t={}){const r=e.ownerDocument.defaultView??window,n=Math.min(r.devicePixelRatio||1,Qt/Math.max(1,r.innerWidth)),s=Se(e,t);let o=await Xt(e,Ce(e,s,n,1));const a=s.detectorCounts();for(const i of[.8,.6,.45]){const l=await lr(o,i);if(!l||l.type!=="image/webp"&&l.type!=="image/png")return{blob:void 0,detectorCounts:a};if(l.size<=Jt)return{blob:l,detectorCounts:a};o=ur(o,.75)}return{blob:void 0,detectorCounts:a}}function lr(e,t){return new Promise(r=>e.toBlob(r,"image/webp",t))}function ur(e,t){const r=e.ownerDocument.createElement("canvas");return r.width=Math.max(1,Math.round(e.width*t)),r.height=Math.max(1,Math.round(e.height*t)),r.getContext("2d")?.drawImage(e,0,0,r.width,r.height),r}async function pr(e=document.body,t={}){const r=Se(e,t),n=await ye(e,{...Ce(e,r,1,1),font:false});return new XMLSerializer().serializeToString(n)}function fr(e,t){try{const r=new URL(t.endsWith("/")?t:`${t}/`),n=new URL(e.replace(/^\/+/,""),r);return n.origin===r.origin?n.href:void 0}catch{return}}async function wr(e,t,r,n=(...o)=>fetch(...o),s){if(r.type!=="image/webp"&&r.type!=="image/png")return;const o={siteKey:t.siteKey,contentType:r.type,byteLength:r.size,...t.reviewerToken?{reviewerToken:t.reviewerToken}:{},...t.userId?{userId:t.userId,consentGiven:true,...Ae(t)}:{},...s?{claims:s,consentGiven:true}:{}},a=await Ne(e,"CreateScreenshotUpload",o,n),i=typeof a.uploadUrl=="string"?fr(a.uploadUrl,e):void 0;if(typeof a.screenshotId!="string"||!i)return;const l={"content-type":r.type};for(const[c,g]of Object.entries(a.headers??{}))typeof g=="string"&&(l[c]=g);return(await n(i,ke({method:"PUT",body:r,headers:l,credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer"}))).ok?a.screenshotId:void 0}export{cr as a,hr as c,pr as m,wr as p,gr as s,fr as u};
|
|
@@ -0,0 +1,118 @@
|
|
|
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=`
|
|
2
|
+
:host { all: initial; }
|
|
3
|
+
.jz {
|
|
4
|
+
--jz-canvas:#F7F7F5; --jz-surface:#FFFFFF; --jz-raised:#F0F0EC; --jz-ink:#1D2024; --jz-muted:#5D636B;
|
|
5
|
+
--jz-faint:#8A9099; --jz-rule:rgb(29 32 36 / 12%); --jz-accent:#3D63C9; --jz-accent-ink:#FFFFFF;
|
|
6
|
+
--jz-accent-soft:rgb(61 99 201 / 10%); --jz-polished:#2F7D4F; --jz-broken:#B42318; --jz-confused:#6E4FC2;
|
|
7
|
+
--jz-shadow:0 1px 3px rgb(0 0 0 / 12%);
|
|
8
|
+
font: 400 13px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
9
|
+
color: var(--jz-ink); -webkit-font-smoothing: antialiased;
|
|
10
|
+
}
|
|
11
|
+
@media (prefers-color-scheme: dark) {
|
|
12
|
+
.jz { --jz-canvas:#111316; --jz-surface:#181B1F; --jz-raised:#20242A; --jz-ink:#E8EAED; --jz-muted:#A3A9B2;
|
|
13
|
+
--jz-faint:#6F7680; --jz-rule:rgb(232 234 237 / 12%); --jz-accent:#7F9CF0; --jz-accent-ink:#111316;
|
|
14
|
+
--jz-accent-soft:rgb(127 156 240 / 14%); --jz-confused:#A48BEA; --jz-polished:#5DBB84; }
|
|
15
|
+
}
|
|
16
|
+
.jz *, .jz *::before, .jz *::after { box-sizing: border-box; }
|
|
17
|
+
/* Zero specificity: a component's own colour (.toggle, .primary, ...) must always win. */
|
|
18
|
+
:where(.jz button) { font: inherit; color: inherit; cursor: pointer; }
|
|
19
|
+
.jz :focus-visible { outline: 2px solid var(--jz-accent); outline-offset: 2px; }
|
|
20
|
+
.mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
21
|
+
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
|
|
22
|
+
|
|
23
|
+
.toggle { position:fixed; right:32px; bottom:32px; z-index:2147483646; height:44px; padding:0 16px; display:flex; align-items:center;
|
|
24
|
+
gap:8px; border:0; border-radius:999px; background:#1D2024; color:#FFFFFF; box-shadow:var(--jz-shadow); font-weight:500; }
|
|
25
|
+
.toggle .dot { width:8px; height:8px; border-radius:50%; background:var(--jz-polished); }
|
|
26
|
+
.toggle .exit { color:#8A9099; }
|
|
27
|
+
.toggle:hover .exit { color:#FFFFFF; }
|
|
28
|
+
|
|
29
|
+
.layer { position:fixed; inset:0; z-index:2147483640; pointer-events:none; }
|
|
30
|
+
.hl { position:fixed; display:none; outline:1px solid var(--jz-accent); outline-offset:-1px; border-radius:2px; }
|
|
31
|
+
.hl.masked { outline:1px dashed var(--jz-faint);
|
|
32
|
+
background:repeating-linear-gradient(45deg, rgb(138 144 153 / 10%) 0 4px, rgb(138 144 153 / 20%) 4px 8px); }
|
|
33
|
+
.tag { position:absolute; left:0; top:-18px; padding:1px 6px; border-radius:2px; background:var(--jz-accent); color:#FFFFFF;
|
|
34
|
+
font-size:10px; line-height:16px; white-space:nowrap; max-width:280px; overflow:hidden; text-overflow:ellipsis; }
|
|
35
|
+
.hl.masked .tag { background:var(--jz-muted); text-transform:uppercase; letter-spacing:.06em; }
|
|
36
|
+
.pin { position:fixed; width:24px; height:24px; margin:-12px 0 0 -12px; border-radius:50%; display:flex; align-items:center;
|
|
37
|
+
justify-content:center; background:var(--jz-accent); color:#FFFFFF; font-size:12px; font-weight:500; box-shadow:var(--jz-shadow); }
|
|
38
|
+
|
|
39
|
+
.pop, .sheet, .checkin, .toast { position:fixed; z-index:2147483645; background:var(--jz-surface); color:var(--jz-ink);
|
|
40
|
+
border:1px solid var(--jz-rule); box-shadow:var(--jz-shadow); }
|
|
41
|
+
.pop { width:400px; max-width:calc(100vw - 32px); max-height:calc(100vh - 32px); overflow:auto; padding:24px; border-radius:10px;
|
|
42
|
+
animation: jz-in 180ms ease-out; }
|
|
43
|
+
@keyframes jz-in { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }
|
|
44
|
+
.pop-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:20px; }
|
|
45
|
+
.pop h2 { margin:0; font-size:14px; font-weight:500; }
|
|
46
|
+
.close { width:32px; height:32px; display:flex; align-items:center; justify-content:center; border:0; border-radius:6px;
|
|
47
|
+
background:transparent; color:var(--jz-faint); }
|
|
48
|
+
.close:hover { color:var(--jz-ink); }
|
|
49
|
+
.chips { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:20px; }
|
|
50
|
+
.chip { display:inline-flex; align-items:center; gap:4px; padding:2px 8px; border-radius:999px; background:var(--jz-raised);
|
|
51
|
+
color:var(--jz-muted); font-size:11px; }
|
|
52
|
+
.reactions { display:flex; border:1px solid var(--jz-rule); border-radius:8px; overflow:hidden; margin-bottom:20px; }
|
|
53
|
+
.reaction { flex:1; min-height:56px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px;
|
|
54
|
+
padding:12px 4px; border:0; border-right:1px solid var(--jz-rule); background:transparent; color:var(--jz-muted); }
|
|
55
|
+
.reaction:last-child { border-right:0; }
|
|
56
|
+
.reaction:hover { background:var(--jz-canvas); }
|
|
57
|
+
.reaction span { font-size:10px; font-weight:500; }
|
|
58
|
+
.reaction[data-r="confused"] { color:var(--jz-confused); }
|
|
59
|
+
.reaction[aria-checked="true"] { background:var(--jz-accent-soft); color:var(--jz-accent); }
|
|
60
|
+
.reaction[data-r="confused"][aria-checked="true"] { background:rgb(110 79 194 / 10%); color:var(--jz-confused); }
|
|
61
|
+
.comment { display:block; width:100%; height:112px; padding:16px; margin-bottom:20px; resize:none; border:1px solid var(--jz-rule);
|
|
62
|
+
border-radius:8px; background:var(--jz-surface); color:var(--jz-ink); font:inherit; }
|
|
63
|
+
.comment::placeholder { color:var(--jz-faint); }
|
|
64
|
+
.comment:focus { outline:none; box-shadow:0 0 0 1px var(--jz-accent); }
|
|
65
|
+
.foot { display:flex; align-items:center; justify-content:space-between; gap:12px; }
|
|
66
|
+
.shot { display:flex; align-items:center; gap:12px; min-width:0; }
|
|
67
|
+
.thumb { flex:none; width:80px; height:48px; border-radius:8px; border:1px solid var(--jz-rule); background:var(--jz-canvas);
|
|
68
|
+
overflow:hidden; display:flex; align-items:center; justify-content:center; color:var(--jz-faint); font-size:8px; }
|
|
69
|
+
.thumb img { width:100%; height:100%; object-fit:cover; }
|
|
70
|
+
.thumb.hatch { background:repeating-linear-gradient(45deg, rgb(138 144 153 / 10%) 0 4px, rgb(138 144 153 / 20%) 4px 8px); }
|
|
71
|
+
.shot-open { display:block; width:100%; height:100%; padding:0; border:0; background:transparent; }
|
|
72
|
+
.optout-row { display:flex; align-items:center; gap:8px; margin-bottom:16px; color:var(--jz-muted); font-size:12px; }
|
|
73
|
+
.optout-row[hidden] { display:none; }
|
|
74
|
+
.note { font-size:11px; color:var(--jz-faint); line-height:1.3; }
|
|
75
|
+
.shot-full { position:fixed; inset:0; z-index:2147483647; display:flex; align-items:center; justify-content:center; padding:24px; background:rgb(0 0 0 / 72%); }
|
|
76
|
+
.shot-full img { max-width:100%; max-height:100%; object-fit:contain; border-radius:6px; background:var(--jz-surface); }
|
|
77
|
+
.shot-full .close { position:absolute; top:16px; right:16px; background:var(--jz-surface); color:var(--jz-ink); }
|
|
78
|
+
.primary { min-height:44px; padding:0 24px; border:0; border-radius:8px; background:var(--jz-accent); color:var(--jz-accent-ink); font-weight:500; }
|
|
79
|
+
.primary:disabled { opacity:.45; cursor:not-allowed; }
|
|
80
|
+
.secondary { min-height:44px; padding:0 16px; border:1px solid var(--jz-rule); border-radius:6px; background:transparent;
|
|
81
|
+
color:var(--jz-muted); font-weight:500; }
|
|
82
|
+
|
|
83
|
+
.sheet { left:32px; bottom:32px; width:340px; max-width:calc(100vw - 32px); padding:24px; border-radius:10px; }
|
|
84
|
+
.sheet h2 { display:flex; align-items:center; gap:8px; margin:0 0 12px; font-size:14px; font-weight:500; }
|
|
85
|
+
.sheet h2 svg { color:var(--jz-accent); }
|
|
86
|
+
.sheet p { margin:0 0 12px; color:var(--jz-muted); line-height:1.6; }
|
|
87
|
+
.sheet ul { margin:0 0 20px; padding-left:18px; color:var(--jz-muted); }
|
|
88
|
+
.row { display:flex; gap:8px; }
|
|
89
|
+
.row > * { flex:1; }
|
|
90
|
+
|
|
91
|
+
.checkin { right:32px; bottom:140px; display:flex; align-items:center; gap:8px; padding:8px 8px 8px 16px; border-radius:10px; }
|
|
92
|
+
.checkin .secondary { min-height:36px; }
|
|
93
|
+
.toast { right:32px; bottom:88px; padding:10px 16px; border-radius:10px; }
|
|
94
|
+
.toast.err { border-color:var(--jz-broken); }
|
|
95
|
+
|
|
96
|
+
@media (max-width: 479px) {
|
|
97
|
+
.toggle { right:24px; bottom:24px; height:48px; padding:0 20px; background:var(--jz-accent); color:var(--jz-accent-ink); }
|
|
98
|
+
.toggle .dot { background:var(--jz-accent-ink); }
|
|
99
|
+
.toggle .exit { color:inherit; opacity:.8; }
|
|
100
|
+
.pop { left:0 !important; right:0; top:auto !important; bottom:0; width:auto; max-width:none; max-height:85vh;
|
|
101
|
+
border-radius:16px 16px 0 0; border-width:1px 0 0; padding:12px 24px 34px; }
|
|
102
|
+
.pop::before { content:""; display:block; width:48px; height:4px; margin:0 auto 16px; border-radius:999px; background:var(--jz-raised); }
|
|
103
|
+
.chip { border-radius:4px; border:1px solid var(--jz-rule); }
|
|
104
|
+
.reactions { display:grid; grid-template-columns:repeat(4, 1fr); gap:12px; border:0; overflow:visible; }
|
|
105
|
+
.reaction { border:1px solid var(--jz-rule); border-radius:8px; padding:16px 4px; }
|
|
106
|
+
.reaction:last-child { border-right:1px solid var(--jz-rule); }
|
|
107
|
+
.reaction[aria-checked="true"] { border:2px solid var(--jz-accent); }
|
|
108
|
+
.reaction span { font-size:11px; }
|
|
109
|
+
.foot { flex-direction:column; align-items:stretch; }
|
|
110
|
+
.foot .primary { width:100%; min-height:52px; font-size:15px; }
|
|
111
|
+
.sheet { left:16px; right:16px; bottom:16px; width:auto; }
|
|
112
|
+
.toast { left:16px; right:16px; bottom:84px; }
|
|
113
|
+
.checkin { left:16px; right:16px; bottom:136px; }
|
|
114
|
+
}
|
|
115
|
+
@media (prefers-reduced-motion: reduce) {
|
|
116
|
+
.jz *, .jz *::before, .jz *::after { animation-duration:1ms !important; transition-duration:1ms !important; }
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@journeeze/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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": [
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"user-feedback",
|
|
11
11
|
"github-issues"
|
|
12
12
|
],
|
|
13
|
-
"license": "
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"registry": "https://registry.npmjs.org/",
|
|
16
16
|
"access": "public"
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
],
|
|
22
22
|
"files": [
|
|
23
23
|
"dist",
|
|
24
|
-
"LICENSE
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"NOTICE",
|
|
25
26
|
"CHANGELOG.md",
|
|
26
27
|
"AGENTS.md"
|
|
27
28
|
],
|
package/LICENSE.md
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# Journeeze SDK License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Matt Cochran Products. All rights reserved.
|
|
4
|
-
|
|
5
|
-
This package (`@journeeze/sdk`) is proprietary software. It is not open source.
|
|
6
|
-
|
|
7
|
-
You may install this package and include it, unmodified, in websites and applications
|
|
8
|
-
(including bundled and minified builds) solely to connect them to the Journeeze service, under
|
|
9
|
-
the terms of your agreement for that service.
|
|
10
|
-
|
|
11
|
-
You may not:
|
|
12
|
-
|
|
13
|
-
- modify, adapt or create derivative works of this package, other than the bundling and
|
|
14
|
-
minification your build tools perform;
|
|
15
|
-
- distribute this package on its own, or as part of anything other than a website or
|
|
16
|
-
application that uses the Journeeze service;
|
|
17
|
-
- decompile, reverse engineer or otherwise attempt to derive source code from this package,
|
|
18
|
-
except to the extent applicable law expressly permits it;
|
|
19
|
-
- use this package to build or operate a product or service that competes with Journeeze.
|
|
20
|
-
|
|
21
|
-
Third-party components included in this package are licensed under their own terms; see
|
|
22
|
-
`dist/THIRD_PARTY_LICENSES.txt`.
|
|
23
|
-
|
|
24
|
-
THIS PACKAGE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
25
|
-
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
26
|
-
NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
27
|
-
OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THIS PACKAGE OR ITS USE.
|
package/dist/anchor-cPvFFTOS.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as f}from"./context-UnG6_X61.js";const g=512,p=12;function b(t){const n=[];let o=t,e=false;for(let i=0;o&&i<p;i++){const r=o.hasAttribute("data-tflow-id")?f(o):void 0;if(r!==void 0&&o.getAttribute("data-tflow-id")===r){n.unshift(`[data-tflow-id="${r}"]`),e=true;break}const s=o.tagName.toLowerCase();if(s==="body"||s==="html"){n.unshift(s),e=true;break}const c=o,l=c.parentElement;let d=s;if(l){const u=Array.from(l.children).filter(m=>m.tagName===c.tagName);u.length>1&&(d+=`:nth-of-type(${u.indexOf(c)+1})`)}n.unshift(d),o=l}const a=n.join(" > ");return e&&a.length<=g?a:void 0}const h=t=>Number.isFinite(t)?Math.min(1,Math.max(0,t)):.5;function v(t,n,o){const e=t.getBoundingClientRect(),a={xRatio:h(e.width>0?(n-e.left)/e.width:.5),yRatio:h(e.height>0?(o-e.top)/e.height:.5)},i=f(t);i!==void 0&&(a.tflowId=i);const r=b(t);return r!==void 0&&(a.cssSelector=r),a}function A(t){return f(t)??t.tagName.toLowerCase()}function k(t){return t.closest("[data-jz-block]")!==null}function C(t){return t<768?"mobile":t<1024?"tablet":"desktop"}export{v as a,C as d,A as e,k as i};
|
package/dist/attach-DpioALxW.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import{t as K}from"./context-UnG6_X61.js";import{i as q}from"./anchor-cPvFFTOS.js";import{a as V,p as G}from"./upload-Fu2qvSJV.js";import{m as Se}from"./upload-Fu2qvSJV.js";import{M as I,u as J}from"./chat-BgmB0rnW.js";const R=10,j=.02,z=.01,h=(e,n,t)=>Number.isFinite(e)?Math.min(t,Math.max(n,e)):n,p=e=>Math.round(e*1e4)/1e4;function Q(e,n,t){return{x:h(t.width>0?(e-t.left)/t.width:0,0,1),y:h(t.height>0?(n-t.top)/t.height:0,0,1)}}function $(e,n,t){const i=h(n.x,0,1),a=h(n.y,0,1),r=h(t.x,0,1),s=h(t.y,0,1);return e==="arrow"?{type:e,x:p(i),y:p(a),w:p(r-i),h:p(s-a)}:{type:e,x:p(Math.min(i,r)),y:p(Math.min(a,s)),w:p(Math.abs(r-i)),h:p(Math.abs(s-a))}}function Z(e){return Math.abs(e.w)<z&&Math.abs(e.h)<z}function ee(e){return e==="arrow"?{type:e,x:.35,y:.35,w:.15,h:.15}:{type:e,x:.35,y:.4,w:.3,h:.2}}function te(e,n,t,i){const a=e.type==="arrow";if(i){const c=a?h(e.w+n,-e.x,1-e.x):h(e.w+n,z,1-e.x),u=a?h(e.h+t,-e.y,1-e.y):h(e.h+t,z,1-e.y);return{...e,w:p(c),h:p(u)}}const r=h(e.x+n,Math.max(0,-e.w),Math.min(1,1-e.w)),s=h(e.y+t,Math.max(0,-e.h),Math.min(1,1-e.h));return{...e,x:p(r),y:p(s)}}function U(e,n,t,i,a){const r=Math.atan2(i-n,t-e),s=c=>`${p(t-a*Math.cos(r+c))},${p(i-a*Math.sin(r+c))}`;return`${p(t)},${p(i)} ${s(Math.PI/7)} ${s(-Math.PI/7)}`}function ne(e,n,t,i){e.strokeStyle=e.fillStyle="#B42318",e.lineWidth=Math.max(2,Math.round(Math.max(t,i)/160));for(const a of n)if(e.beginPath(),a.type==="box"?e.rect(a.x*t,a.y*i,a.w*t,a.h*i):a.type==="circle"?e.ellipse((a.x+a.w/2)*t,(a.y+a.h/2)*i,a.w/2*t,a.h/2*i,0,0,Math.PI*2):(e.moveTo(a.x*t,a.y*i),e.lineTo((a.x+a.w)*t,(a.y+a.h)*i)),e.stroke(),a.type==="arrow"){const r=U(a.x*t,a.y*i,(a.x+a.w)*t,(a.y+a.h)*i,e.lineWidth*4).split(" ").map(s=>s.split(",").map(Number));e.beginPath(),r.forEach(([s,c],u)=>u?e.lineTo(s,c):e.moveTo(s,c)),e.fill()}}const ae="http://www.w3.org/2000/svg",B=["box","circle","arrow"];function m(e,n={},...t){const i=document.createElement(e);for(const[a,r]of Object.entries(n))i.setAttribute(a,r);return i.append(...t),i}function M(e,n){const t=document.createElementNS(ae,e);for(const[i,a]of Object.entries(n))t.setAttribute(i,String(a));return t}function ie(e,n,t){const i={fill:"none",stroke:"#B42318","stroke-width":3,"vector-effect":"non-scaling-stroke"};if(e.type==="box")return M("rect",{x:e.x*n,y:e.y*t,width:e.w*n,height:e.h*t,...i});if(e.type==="circle")return M("ellipse",{cx:(e.x+e.w/2)*n,cy:(e.y+e.h/2)*t,rx:e.w/2*n,ry:e.h/2*t,...i});const[a,r,s,c]=[e.x*n,e.y*t,(e.x+e.w)*n,(e.y+e.h)*t],u=M("g",{});return u.append(M("line",{x1:a,y1:r,x2:s,y2:c,...i}),M("polygon",{points:U(a,r,s,c,Math.max(n,t)/50),fill:"#B42318"})),u}function oe(e,n,t,i){return new Promise(a=>{let r="box",s=[],c,u;const v=B.map(o=>{const d=m("button",{type:"button",class:"tool","aria-pressed":String(o===r)},i(`draw.${o}`));return d.addEventListener("click",()=>{r=o,v.forEach((g,b)=>g.setAttribute("aria-pressed",String(B[b]===o)))}),d}),l=(o,d,g)=>{const b=m("button",{type:"button",class:d},o);return b.addEventListener("click",g),b},w=l(i("draw.undo"),"tool",()=>A(s.slice(0,-1),i("draw.removed_last"))),y=l(i("draw.clear"),"tool",()=>A([],i("draw.cleared"))),N=l(i("cancel"),"btn",()=>P(void 0)),X=l(i("draw.done"),"btn pri",()=>P(s)),T=M("svg",{viewBox:`0 0 ${t.w} ${t.h}`,preserveAspectRatio:"none","aria-hidden":"true"}),H=m("img",{src:n,alt:i("draw.image"),draggable:"false"}),W=m("span",{id:"jzd-k",class:"sr"},i("draw.keys")),f=m("div",{class:"stage",tabindex:"0",role:"group","aria-label":i("draw.stage"),"aria-describedby":"jzd-k"},H,T,W),L=m("p",{class:"msg",role:"status"}),E=m("div",{class:"jzd",role:"dialog","aria-modal":"true","aria-labelledby":"jzd-t","aria-describedby":"jzd-h"},m("header",{},m("h2",{id:"jzd-t"},i("draw.title")),m("p",{id:"jzd-h"},i("draw.hint"))),m("div",{class:"bar",role:"toolbar","aria-label":i("draw.tools")},...v,m("span",{class:"sep","aria-hidden":"true"}),w,y,m("span",{class:"end"},N,X)),m("div",{class:"wrap"},f),L);function k(){T.replaceChildren(...[...s,...u?[u]:[]].map(o=>ie(o,t.w,t.h))),w.disabled=y.disabled=s.length===0}function A(o,d){s=o,L.textContent=d,k()}function O(o){if(s.length>=R){L.textContent=i("draw.shape_limit",{max:R});return}A([...s,o],i(`draw.added.${o.type}`,{n:s.length+1,max:R}))}function S(){const o=f.parentElement,d=getComputedStyle(o),g=Math.max(1,o.clientWidth-parseFloat(d.paddingLeft||"0")-parseFloat(d.paddingRight||"0")),b=Math.max(1,o.clientHeight-parseFloat(d.paddingTop||"0")-parseFloat(d.paddingBottom||"0")),C=Math.min(g/t.w,b/t.h);f.style.width=`${Math.floor(t.w*C)}px`,f.style.height=`${Math.floor(t.h*C)}px`}const _=o=>Q(o.clientX,o.clientY,f.getBoundingClientRect());f.addEventListener("pointerdown",o=>{o.button===0&&(o.preventDefault(),f.setPointerCapture?.(o.pointerId),c=_(o))}),f.addEventListener("pointermove",o=>{c&&(u=$(r,c,_(o)),k())});const Y=o=>{if(!c)return;const d=$(r,c,_(o));c=u=void 0,Z(d)?k():O(d)};f.addEventListener("pointerup",Y),f.addEventListener("pointercancel",()=>{c=u=void 0,k()}),f.addEventListener("keydown",o=>{const d={ArrowLeft:[-j,0],ArrowRight:[j,0],ArrowUp:[0,-j],ArrowDown:[0,j]};if(o.key==="Enter"||o.key===" ")o.preventDefault(),O(ee(r));else if(d[o.key]&&s.length>0){o.preventDefault();const[g,b]=d[o.key];s=[...s.slice(0,-1),te(s[s.length-1],g,b,o.shiftKey)],k()}}),E.addEventListener("keydown",o=>{if(o.stopPropagation(),o.key==="Escape")o.preventDefault(),P(void 0);else if(o.key==="Tab"){const d=[...E.querySelectorAll("button:not([disabled]), [tabindex='0']")],g=d.indexOf(e.activeElement);(o.shiftKey?g<=0:g===d.length-1)&&(o.preventDefault(),d[o.shiftKey?d.length-1:0]?.focus())}}),window.addEventListener("resize",S);function P(o){window.removeEventListener("resize",S),E.remove(),a(o)}e.append(E),k(),S(),v[0].focus()})}const re=`
|
|
2
|
-
.jzd{position:fixed;inset:0;z-index:2147483647;display:flex;flex-direction:column;background:var(--c);color:var(--i)}
|
|
3
|
-
.jzd header{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;padding:12px 16px;border-bottom:1px solid var(--l);background:var(--s)}
|
|
4
|
-
.jzd h2{margin:0;font-size:14px;font-weight:600}
|
|
5
|
-
.jzd header p{margin:0;font-size:12px;color:var(--m)}
|
|
6
|
-
.jzd .bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:8px 16px;border-bottom:1px solid var(--l);background:var(--s)}
|
|
7
|
-
.jzd .bar .sep{width:1px;height:28px;background:var(--l);margin:0 4px}
|
|
8
|
-
.jzd .bar .end{margin-left:auto;display:flex;gap:6px}
|
|
9
|
-
.jzd .tool{min-width:44px;min-height:44px;padding:0 12px;border:1px solid var(--l);border-radius:6px;background:var(--s)}
|
|
10
|
-
.jzd .tool[aria-pressed=true]{background:var(--as);border-color:var(--a);color:var(--a);font-weight:600}
|
|
11
|
-
.jzd .wrap{flex:1;min-height:0;display:grid;place-items:center;padding:16px}
|
|
12
|
-
.jzd .stage{position:relative;border:1px solid var(--l);border-radius:6px;overflow:hidden;background:var(--r);touch-action:none;cursor:crosshair;user-select:none;-webkit-user-select:none}
|
|
13
|
-
.jzd .stage img,.jzd .stage svg{position:absolute;inset:0;width:100%;height:100%;display:block}
|
|
14
|
-
.jzd .stage svg{overflow:visible}
|
|
15
|
-
.jzd .stage *{pointer-events:none}
|
|
16
|
-
.jzd .msg{min-height:20px;margin:0;padding:0 16px 8px;font-size:12px;color:var(--m)}
|
|
17
|
-
.pick{position:fixed;inset:0;z-index:2147483647;cursor:crosshair;touch-action:none}
|
|
18
|
-
.pick .hl{position:fixed;border:2px solid var(--a);border-radius:4px;background:var(--as);pointer-events:none}
|
|
19
|
-
.pick .hint{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);display:flex;align-items:center;gap:8px;max-width:calc(100vw - 32px);padding:4px 4px 4px 16px;border:1px solid var(--l);border-radius:10px;background:var(--s);box-shadow:var(--sh);font-size:13px}
|
|
20
|
-
@media (max-width:640px){.jzd .bar .end{margin-left:0;width:100%}.jzd .bar .end .btn{flex:1}.jzd .wrap{padding:8px}}
|
|
21
|
-
`,D=["image/png","image/jpeg","image/webp","image/gif"],se=10*1024*1024,ce=2*1024*1024,de=1600,le="[data-journeeze], [data-journeeze-chat]",x=(e,n)=>e.session.note(e.session.t(n,{max:I}));async function ze(e,n){return pe(n),e==="point_at_it"?ge(n):n.options.reviewerToken||n.options.userId?n.session.attachments.length>=I?x(n,"note.attachment_limit"):e==="show_us_where"?he(n):xe(n):x(n,"note.signed_out")}function pe(e){if(e.root.querySelector("style[data-jz-capture]"))return;const n=document.createElement("style");n.setAttribute("data-jz-capture",""),n.textContent=re,e.options.nonce&&(n.nonce=e.options.nonce),e.root.append(n)}async function ue(e){const n=await e.config(),t=Array.isArray(n.maskSelectors)?n.maskSelectors:[],{maskSelectors:i,maskAllText:a}=e.options;return{...i?{maskSelectors:i}:{},...t.length?{configMaskSelectors:t}:{},...a?{maskAllText:a}:{}}}async function me(e){try{const n=await V(document.body,await ue(e));if(n.blob)for(const[t,i]of Object.entries(n.detectorCounts))i&&e.session.overMask.set(t,(e.session.overMask.get(t)??0)+i);return n.blob}catch{return}}async function he(e){const n=e.suspend(),t=await me(e);if(!t)return n(),x(e,"note.masking_failed");const i={w:Math.max(1,window.innerWidth),h:Math.max(1,window.innerHeight)},a=URL.createObjectURL(t),r=await oe(e.root,a,i,e.session.t);URL.revokeObjectURL(a),n(),r&&await F(e,t,i,r,"attachment.screenshot")}async function F(e,n,t,i,a){const r=await fe(n,t,i);e.session.addAttachment({id:J(),thumbnail:r,label:e.session.t(a,{n:e.session.attachments.length+1}),...i.length?{shapes:i}:{},upload:()=>G(e.endpoint,e.options,n),release:()=>URL.revokeObjectURL(r)})||(URL.revokeObjectURL(r),x(e,"note.attachment_limit"))}async function fe(e,n,t){try{const i=await createImageBitmap(e),a=document.createElement("canvas");a.width=256,a.height=Math.max(1,Math.round(256*n.h/n.w));const r=a.getContext("2d");r.drawImage(i,0,0,a.width,a.height),ne(r,t,a.width,a.height);const s=await new Promise(c=>a.toBlob(c,"image/webp",.8));if(s)return URL.createObjectURL(s)}catch{}return URL.createObjectURL(e)}async function ge(e){const n=e.suspend(),t=await be(e.root,e.session.t);if(n(),!t)return;const i=q(t)?void 0:K(t);i?e.session.setAnchor({tflowId:i}):x(e,"note.no_name")}function we(e,n){return document.elementsFromPoint(e,n).find(t=>!t.closest(le)&&t!==document.documentElement)}function be(e,n){return new Promise(t=>{const i=document.createElement("div");i.className="hl",i.hidden=true;const a=document.createElement("button");a.type="button",a.className="btn",a.textContent=n("cancel");const r=document.createElement("div");r.className="hint",r.setAttribute("role","dialog"),r.setAttribute("aria-label",n("point.label")),r.append(n("point.hint"),a);const s=document.createElement("div");s.className="pick",s.append(i,r);const c=l=>{const w=we(l.clientX,l.clientY);return w?.closest("[data-tflow-id]")??w};s.addEventListener("pointermove",l=>{const w=c(l);if(i.hidden=!w,!w)return;const y=w.getBoundingClientRect();Object.assign(i.style,{left:`${y.left}px`,top:`${y.top}px`,width:`${y.width}px`,height:`${y.height}px`})}),s.addEventListener("pointerup",l=>{r.contains(l.target)||v(c(l))}),a.addEventListener("click",()=>v(void 0));const u=l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),v(void 0))};document.addEventListener("keydown",u,true);function v(l){document.removeEventListener("keydown",u,true),s.remove(),t(l)}e.append(s),a.focus()})}function xe(e){return new Promise(n=>{const t=document.createElement("input");t.type="file",t.accept=D.join(","),t.hidden=true,e.root.append(t),t.addEventListener("change",()=>{const i=t.files?.[0];t.remove(),i?ve(e,i).then(n):n()}),t.addEventListener("cancel",()=>{t.remove(),n()}),t.click()})}async function ve(e,n){if(!D.includes(n.type)||n.size>se)return x(e,"note.file_type");if(e.session.attachments.length>=I)return x(e,"note.attachment_limit");const t=await ye(n).catch(()=>{});if(!t)return x(e,"note.file_read");await F(e,t.blob,t.size,[],"attachment.image")}async function ye(e){const n=await createImageBitmap(e,{imageOrientation:"from-image"});let t=Math.min(1,de/Math.max(n.width,n.height));for(const i of[.85,.7,.5]){const a=document.createElement("canvas");a.width=Math.max(1,Math.round(n.width*t)),a.height=Math.max(1,Math.round(n.height*t)),a.getContext("2d").drawImage(n,0,0,a.width,a.height);const r=await new Promise(s=>a.toBlob(s,"image/webp",i));if(!r||r.type!=="image/webp"&&r.type!=="image/png")return;if(r.size<=ce)return{blob:r,size:{w:a.width,h:a.height}};t*=.75}}export{D as IMAGE_TYPES,se as MAX_FILE_BYTES,ve as addFile,ue as maskOptions,me as maskedCapture,Se as maskedSnapshotSvg,we as pageElementAt,be as pick,ze as plusItem,ye as reencode};
|