@hanzo/browser-extension 1.9.55 → 1.9.59
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/README.md +11 -0
- package/chrome/background.js +527 -0
- package/chrome/content-script.js +550 -0
- package/{src → chrome}/manifest.json +2 -12
- package/{src → chrome}/newtab.css +2 -2
- package/chrome/newtab.js +230 -0
- package/chrome/onboarding.js +31 -0
- package/chrome/page.js +35 -0
- package/{src → chrome}/popup.css +2 -2
- package/{src → chrome}/popup.html +8 -0
- package/chrome/popup.js +48 -0
- package/{src → chrome}/sidebar.css +7 -7
- package/chrome/sidebar.js +291 -0
- package/firefox/ai-worker.js +571 -0
- package/firefox/background.js +235 -0
- package/firefox/callback.html +17 -0
- package/firefox/content-script.js +550 -0
- package/firefox/icon128.png +0 -0
- package/firefox/icon16.png +0 -0
- package/firefox/icon48.png +0 -0
- package/{src/manifest-firefox.json → firefox/manifest.json} +2 -3
- package/firefox/newtab.css +543 -0
- package/firefox/newtab.html +13 -0
- package/firefox/newtab.js +230 -0
- package/firefox/onboarding.css +78 -0
- package/firefox/onboarding.html +45 -0
- package/firefox/onboarding.js +31 -0
- package/firefox/page.js +35 -0
- package/firefox/popup.css +761 -0
- package/firefox/popup.html +413 -0
- package/firefox/popup.js +48 -0
- package/firefox/sidebar.css +1350 -0
- package/firefox/sidebar.html +388 -0
- package/firefox/sidebar.js +291 -0
- package/package.json +4 -52
- package/manifest.json +0 -34
- package/src/Chat.tsx +0 -164
- package/src/answer/AnswerEngine.tsx +0 -410
- package/src/answer/Mark.tsx +0 -14
- package/src/answer/Rail.tsx +0 -95
- package/src/answer/Stories.tsx +0 -27
- package/src/answer/Toolbar.tsx +0 -93
- package/src/answer/WidgetView.tsx +0 -136
- package/src/icon128.png +0 -0
- package/src/icon16.png +0 -0
- package/src/icon32.png +0 -0
- package/src/icon48.png +0 -0
- package/src/package.json +0 -41
- package/src/safari/SafariWebExtensionHandler.swift +0 -153
- package/src/shared/Prose.tsx +0 -29
- package/src/webgpu.d.ts +0 -131
- /package/{src → chrome}/ai-worker.js +0 -0
- /package/{src → chrome}/callback.html +0 -0
- /package/{images → chrome}/icon128.png +0 -0
- /package/{images → chrome}/icon16.png +0 -0
- /package/{images → chrome}/icon48.png +0 -0
- /package/{src → chrome}/newtab.html +0 -0
- /package/{src → chrome}/onboarding.css +0 -0
- /package/{src → chrome}/onboarding.html +0 -0
- /package/{src → chrome}/sidebar.html +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--bg: #0b0b0c;
|
|
3
|
+
--card: #131315;
|
|
4
|
+
--line: #26262a;
|
|
5
|
+
--text: #f4f4f5;
|
|
6
|
+
--muted: #9a9aa2;
|
|
7
|
+
--accent: #f4f4f5;
|
|
8
|
+
}
|
|
9
|
+
* { box-sizing: border-box; }
|
|
10
|
+
html, body {
|
|
11
|
+
margin: 0;
|
|
12
|
+
height: 100%;
|
|
13
|
+
background: var(--bg);
|
|
14
|
+
color: var(--text);
|
|
15
|
+
font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
16
|
+
}
|
|
17
|
+
body { display: grid; place-items: center; padding: 32px; }
|
|
18
|
+
.card {
|
|
19
|
+
width: 100%;
|
|
20
|
+
max-width: 520px;
|
|
21
|
+
background: var(--card);
|
|
22
|
+
border: 1px solid var(--line);
|
|
23
|
+
border-radius: 16px;
|
|
24
|
+
padding: 32px;
|
|
25
|
+
}
|
|
26
|
+
.brand { font-weight: 700; letter-spacing: 0.02em; opacity: 0.7; margin-bottom: 20px; }
|
|
27
|
+
h1 { font-size: 24px; margin: 0 0 8px; }
|
|
28
|
+
.lede { color: var(--muted); margin: 0 0 24px; }
|
|
29
|
+
.row {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: flex-start;
|
|
32
|
+
gap: 12px;
|
|
33
|
+
padding: 14px 0;
|
|
34
|
+
border-top: 1px solid var(--line);
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
}
|
|
37
|
+
.row input { position: absolute; opacity: 0; width: 0; height: 0; }
|
|
38
|
+
.switch {
|
|
39
|
+
flex: 0 0 auto;
|
|
40
|
+
width: 38px;
|
|
41
|
+
height: 22px;
|
|
42
|
+
border-radius: 999px;
|
|
43
|
+
background: #3a3a40;
|
|
44
|
+
position: relative;
|
|
45
|
+
transition: background 0.15s;
|
|
46
|
+
margin-top: 2px;
|
|
47
|
+
}
|
|
48
|
+
.switch::after {
|
|
49
|
+
content: "";
|
|
50
|
+
position: absolute;
|
|
51
|
+
top: 2px;
|
|
52
|
+
left: 2px;
|
|
53
|
+
width: 18px;
|
|
54
|
+
height: 18px;
|
|
55
|
+
border-radius: 50%;
|
|
56
|
+
background: #fff;
|
|
57
|
+
transition: transform 0.15s;
|
|
58
|
+
}
|
|
59
|
+
.row input:checked + .switch { background: var(--accent); }
|
|
60
|
+
.row input:checked + .switch::after { transform: translateX(16px); background: #0b0b0c; }
|
|
61
|
+
.text { display: flex; flex-direction: column; gap: 2px; }
|
|
62
|
+
.text strong { font-weight: 600; }
|
|
63
|
+
.text small { color: var(--muted); }
|
|
64
|
+
.cta {
|
|
65
|
+
width: 100%;
|
|
66
|
+
margin-top: 24px;
|
|
67
|
+
padding: 12px;
|
|
68
|
+
border: 0;
|
|
69
|
+
border-radius: 10px;
|
|
70
|
+
background: var(--accent);
|
|
71
|
+
color: #0b0b0c;
|
|
72
|
+
font-weight: 600;
|
|
73
|
+
font-size: 15px;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
}
|
|
76
|
+
.cta:active { transform: translateY(1px); }
|
|
77
|
+
.fine { color: var(--muted); font-size: 12px; text-align: center; margin: 16px 0 0; }
|
|
78
|
+
.fine a { color: var(--text); }
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>Welcome to Hanzo</title>
|
|
7
|
+
<link rel="stylesheet" href="onboarding.css" />
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<main class="card">
|
|
11
|
+
<div class="brand">Hanzo</div>
|
|
12
|
+
<h1>Welcome to Hanzo AI</h1>
|
|
13
|
+
<p class="lede">
|
|
14
|
+
Search, research and browse with Hanzo's own models. Before you start,
|
|
15
|
+
choose what you'd like to share — you can change this anytime in settings
|
|
16
|
+
or on your Hanzo account.
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<label class="row">
|
|
20
|
+
<input type="checkbox" id="ob-insights" checked />
|
|
21
|
+
<span class="switch"></span>
|
|
22
|
+
<span class="text">
|
|
23
|
+
<strong>Anonymous usage insights</strong>
|
|
24
|
+
<small>Helps us improve Hanzo. No search text, no personal data — just a random per-install id.</small>
|
|
25
|
+
</span>
|
|
26
|
+
</label>
|
|
27
|
+
|
|
28
|
+
<label class="row">
|
|
29
|
+
<input type="checkbox" id="ob-training" />
|
|
30
|
+
<span class="switch"></span>
|
|
31
|
+
<span class="text">
|
|
32
|
+
<strong>Contribute to training Hanzo's open models</strong>
|
|
33
|
+
<small>Share your own searches & answers so Hanzo's open models get better. Opt in — off unless you turn it on.</small>
|
|
34
|
+
</span>
|
|
35
|
+
</label>
|
|
36
|
+
|
|
37
|
+
<button id="ob-continue" class="cta">Get started</button>
|
|
38
|
+
<p class="fine">
|
|
39
|
+
Signed in? These choices save to your Hanzo account and stay in sync
|
|
40
|
+
everywhere. <a href="https://hanzo.ai/privacy" target="_blank" rel="noopener">Privacy</a>
|
|
41
|
+
</p>
|
|
42
|
+
</main>
|
|
43
|
+
<script src="onboarding.js"></script>
|
|
44
|
+
</body>
|
|
45
|
+
</html>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";(()=>{var He=Object.create;var ie=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Ye=Object.getPrototypeOf,Je=Object.prototype.hasOwnProperty;var Xe=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var Qe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of qe(t))!Je.call(e,s)&&s!==n&&ie(e,s,{get:()=>t[s],enumerable:!(r=Ze(t,s))||r.enumerable});return e};var et=(e,t,n)=>(n=e!=null?He(Ye(e)):{},Qe(t||!e||!e.__esModule?ie(n,"default",{value:e,enumerable:!0}):n,e));var ae=Xe((G,oe)=>{(function(e,t){if(typeof define=="function"&&define.amd)define("webextension-polyfill",["module"],t);else if(typeof G<"u")t(oe);else{var n={exports:{}};t(n),e.browser=n.exports}})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:G,function(e){"use strict";if(!(globalThis.chrome&&globalThis.chrome.runtime&&globalThis.chrome.runtime.id))throw new Error("This script should only be loaded in a browser extension.");if(globalThis.browser&&globalThis.browser.runtime&&globalThis.browser.runtime.id)e.exports=globalThis.browser;else{let t="The message port closed before a response was received.",n=r=>{let s={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(Object.keys(s).length===0)throw new Error("api-metadata.json has not been included in browser-polyfill");class o extends WeakMap{constructor(a,u=void 0){super(u),this.createItem=a}get(a){return this.has(a)||this.set(a,this.createItem(a)),super.get(a)}}let c=i=>i&&typeof i=="object"&&typeof i.then=="function",f=(i,a)=>(...u)=>{r.runtime.lastError?i.reject(new Error(r.runtime.lastError.message)):a.singleCallbackArg||u.length<=1&&a.singleCallbackArg!==!1?i.resolve(u[0]):i.resolve(u)},p=i=>i==1?"argument":"arguments",_=(i,a)=>function(m,...A){if(A.length<a.minArgs)throw new Error(`Expected at least ${a.minArgs} ${p(a.minArgs)} for ${i}(), got ${A.length}`);if(A.length>a.maxArgs)throw new Error(`Expected at most ${a.maxArgs} ${p(a.maxArgs)} for ${i}(), got ${A.length}`);return new Promise((y,b)=>{if(a.fallbackToNoCallback)try{m[i](...A,f({resolve:y,reject:b},a))}catch(l){console.warn(`${i} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `,l),m[i](...A),a.fallbackToNoCallback=!1,a.noCallback=!0,y()}else a.noCallback?(m[i](...A),y()):m[i](...A,f({resolve:y,reject:b},a))})},E=(i,a,u)=>new Proxy(a,{apply(m,A,y){return u.call(A,i,...y)}}),k=Function.call.bind(Object.prototype.hasOwnProperty),S=(i,a={},u={})=>{let m=Object.create(null),A={has(b,l){return l in i||l in m},get(b,l,T){if(l in m)return m[l];if(!(l in i))return;let h=i[l];if(typeof h=="function")if(typeof a[l]=="function")h=E(i,i[l],a[l]);else if(k(u,l)){let N=_(l,u[l]);h=E(i,i[l],N)}else h=h.bind(i);else if(typeof h=="object"&&h!==null&&(k(a,l)||k(u,l)))h=S(h,a[l],u[l]);else if(k(u,"*"))h=S(h,a[l],u["*"]);else return Object.defineProperty(m,l,{configurable:!0,enumerable:!0,get(){return i[l]},set(N){i[l]=N}}),h;return m[l]=h,h},set(b,l,T,h){return l in m?m[l]=T:i[l]=T,!0},defineProperty(b,l,T){return Reflect.defineProperty(m,l,T)},deleteProperty(b,l){return Reflect.deleteProperty(m,l)}},y=Object.create(i);return new Proxy(y,A)},C=i=>({addListener(a,u,...m){a.addListener(i.get(u),...m)},hasListener(a,u){return a.hasListener(i.get(u))},removeListener(a,u){a.removeListener(i.get(u))}}),Ke=new o(i=>typeof i!="function"?i:function(u){let m=S(u,{},{getContent:{minArgs:0,maxArgs:0}});i(m)}),re=new o(i=>typeof i!="function"?i:function(u,m,A){let y=!1,b,l=new Promise(D=>{b=function(x){y=!0,D(x)}}),T;try{T=i(u,m,b)}catch(D){T=Promise.reject(D)}let h=T!==!0&&c(T);if(T!==!0&&!h&&!y)return!1;let N=D=>{D.then(x=>{A(x)},x=>{let F;x&&(x instanceof Error||typeof x.message=="string")?F=x.message:F="An unexpected error occurred",A({__mozWebExtensionPolyfillReject__:!0,message:F})}).catch(x=>{console.error("Failed to send onMessage rejected reply",x)})};return N(h?T:l),!0}),Ve=({reject:i,resolve:a},u)=>{r.runtime.lastError?r.runtime.lastError.message===t?a():i(new Error(r.runtime.lastError.message)):u&&u.__mozWebExtensionPolyfillReject__?i(new Error(u.message)):a(u)},se=(i,a,u,...m)=>{if(m.length<a.minArgs)throw new Error(`Expected at least ${a.minArgs} ${p(a.minArgs)} for ${i}(), got ${m.length}`);if(m.length>a.maxArgs)throw new Error(`Expected at most ${a.maxArgs} ${p(a.maxArgs)} for ${i}(), got ${m.length}`);return new Promise((A,y)=>{let b=Ve.bind(null,{resolve:A,reject:y});m.push(b),u.sendMessage(...m)})},We={devtools:{network:{onRequestFinished:C(Ke)}},runtime:{onMessage:C(re),onMessageExternal:C(re),sendMessage:se.bind(null,"sendMessage",{minArgs:1,maxArgs:3})},tabs:{sendMessage:se.bind(null,"sendMessage",{minArgs:2,maxArgs:3})}},B={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return s.privacy={network:{"*":B},services:{"*":B},websites:{"*":B}},S(r,We,s)};e.exports=n(chrome)}})});var Dn=et(ae());var g={SIGNUP_VIEWED:"signup_viewed",SIGNUP_SUBMITTED:"signup_submitted",SIGNUP_VERIFIED:"signup_verified",SIGNUP_COMPLETED:"signup_completed",LOGIN_COMPLETED:"login_completed",FIRST_ACTION:"first_action",WAITLIST_JOINED:"waitlist_joined",WAITLIST_SHARED:"waitlist_shared",REFERRAL_USED:"referral_used",REFERRAL_CLAIMED:"referral_claimed",PRICING_VIEWED:"pricing_viewed",PLAN_CLICKED:"plan_clicked",CHECKOUT_STARTED:"checkout_started",ORDER_COMPLETED:"order_completed",FEATURE_USED:"feature_used",API_KEY_CREATED:"api_key_created",APP_CREATED:"app_created",PROJECT_CREATED:"project_created",AGENT_CREATED:"agent_created",CHAT_STARTED:"chat_started",CHAT_MESSAGE_SENT:"chat_message_sent",MODEL_SWITCHED:"model_switched",TASK_STARTED:"task_started",TASK_COMPLETED:"task_completed",BUILD_STARTED:"build_started",GENERATION_COMPLETED:"generation_completed",GENERATION_FAILED:"generation_failed",DEPLOY_STARTED:"deploy_started",DEPLOY_SUCCEEDED:"deploy_succeeded",DEPLOY_FAILED:"deploy_failed"},w="$pageview",O="$exception";var d=(e,t,n)=>({event:e,label:t,...n??{}}),j={signup:{label:"Signup",products:["site","id"],join:"aggregate",steps:[d(w,"Landed",{product:"site"}),d(g.SIGNUP_VIEWED,"Opened signup",{product:"site"}),d(g.SIGNUP_SUBMITTED,"Redirected to Hanzo ID",{product:"site"}),d(g.SIGNUP_VIEWED,"Saw the form",{product:"id"}),d(g.SIGNUP_SUBMITTED,"Submitted the form",{product:"id"}),d(g.SIGNUP_COMPLETED,"Account created",{product:"site"})]},apiActivation:{label:"API activation",products:["site","cloud"],join:"person",steps:[d(g.SIGNUP_COMPLETED,"Account created"),d(g.API_KEY_CREATED,"Key minted"),d(g.FIRST_ACTION,"First successful API call",{where:{property:"action",equals:"api_call"}})]},upgrade:{label:"Upgrade",products:["site","app","console","billing","pay"],join:"person",steps:[d(g.PRICING_VIEWED,"Viewed pricing"),d(g.PLAN_CLICKED,"Chose a plan"),d(g.CHECKOUT_STARTED,"Left for checkout",{product:"billing"}),d(g.CHECKOUT_STARTED,"Reached the card form",{product:"pay"}),d(g.ORDER_COMPLETED,"Paid")]},appShip:{label:"Describe \u2192 ship",products:["app"],join:"person",steps:[d(w,"Landed"),d(g.BUILD_STARTED,"Described an app"),d(g.GENERATION_COMPLETED,"Got a working build"),d(g.DEPLOY_STARTED,"Hit publish"),d(g.DEPLOY_SUCCEEDED,"Live URL")]},chatEngage:{label:"Chat engagement",products:["chat"],join:"person",steps:[d(w,"Landed"),d(g.CHAT_STARTED,"Started a conversation"),d(g.CHAT_MESSAGE_SENT,"Sent a message"),d(g.GENERATION_COMPLETED,"Got an answer")]},siteToChat:{label:"Site \u2192 Chat handoff",products:["site","chat"],join:"aggregate",steps:[d(g.CHAT_STARTED,"Submitted the hanzo.ai composer",{product:"site",where:{property:"source",equals:"composer"}}),d(g.CHAT_STARTED,"Landed in hanzo.chat",{product:"chat",where:{property:"referrerProduct",equals:"site"}}),d(g.GENERATION_COMPLETED,"Got an answer")]}};function I(e){return j[e].steps.map(t=>t.event)}var An=Object.freeze(Object.values(g)),_n=Object.freeze([w,O]);var rt=["facebook.","instagram.","twitter.","x.com","t.co","linkedin.","reddit.","youtube.","tiktok.","pinterest.","news.ycombinator.com"],st=["google.","bing.","duckduckgo.","yahoo.","baidu.","ecosia."];function it(e,t){let n=new URLSearchParams(e||""),r=o=>{let c=n.get(o);return c?c.trim():void 0},s={utm:{source:r("utm_source"),medium:r("utm_medium"),campaign:r("utm_campaign"),term:r("utm_term"),content:r("utm_content")},referrer:t?t.trim():void 0,refCode:r("ref")||r("refCode")||r("ref_code")||void 0};return s.channel=ve(s),s}function ve(e){let t=(e.utm.medium||"").toLowerCase();if(/(cpc|ppc|paid|paidsearch|display|cpm)/.test(t))return"paid";if(e.utm.source||e.utm.campaign)return"campaign";if(e.refCode)return"referral";let n=xe(e.referrer);return n?rt.some(r=>n.includes(r))?"social":st.some(r=>n.includes(r))?"organic":"referral":"direct"}function xe(e){if(!e)return"";let t=e.trim(),n=t.indexOf("://");n>=0&&(t=t.slice(n+3));let r=t.search(/[/?#]/);r>=0&&(t=t.slice(0,r));let s=t.indexOf("@");s>=0&&(t=t.slice(s+1));let o=t.indexOf(":");return o>=0&&(t=t.slice(0,o)),t.toLowerCase().trim()}function ot(e){return!!(e.utm.source||e.utm.medium||e.utm.campaign||e.utm.term||e.utm.content||e.refCode||e.referrer&&xe(e.referrer))}var at=Object.freeze({console:"019fa40b-94ae-7f1d-8f7b-e92f123fad42",app:"019f9b1e-57eb-7171-9d92-72c0b85e4b4b",site:"019f9b1e-5785-7359-ad0b-f75db8e58c99"});function ce(e,t){if(!e||!t)return;let n=at[e];if(n)return`https://${t}@api.hanzo.ai/v1/event/${n}`}var ct=Object.freeze({hanzo:Object.freeze(["hanzo.ai","hanzo.app","hanzo.bot","hanzo.chat","hanzo.codes","hanzo.id","hanzo.sh","hanzo.team","hanzo.ventures","hanzo.works","hanzoskills.com"]),lux:Object.freeze(["lux.network","lux.exchange","lux.market","lux.finance","lux.financial","lux.credit","lux.fund","lux.id"]),zoo:Object.freeze(["zoo.ngo","zoo.network","zoolabs.id","zoolabs.io"])}),we=Object.freeze({hanzo:"pk-rM_CdaF2MQckGCrla113SrR1oH4zvqN8xh2I95Z9tY8",lux:"pk-gUZp6ZVfhJzSwK-rb4oLbVkpCnMBx5uSCpxf_5yEhQk",zoo:"pk-3TKpKnERV9AQSsBUERWkZejC1O1mUxc1jRzsP3MPbs4"}),lt="pk-",gt=e=>e.trim().toLowerCase().replace(/\.$/,"").split(":")[0]??"";function ut(e){let t=gt(e);if(!t)return;let n,r=0;for(let[s,o]of Object.entries(ct))for(let c of o)(t===c||t.endsWith(`.${c}`))&&c.length>r&&(n=s,r=c.length);return n}function mt(e,t=we){let n=ut(e);if(!n)return;let r=t[n];if(typeof r!="string")return;let s=r.trim();return s.startsWith(lt)?s:void 0}function dt(e=we){if(!(typeof location>"u"))return mt(location.hostname,e)}var q="[redacted]",ft="[email]",le="[ip]",pt=[/-----BEGIN[ A-Z]*PRIVATE KEY-----[\s\S]*?-----END[ A-Z]*PRIVATE KEY-----/g,/eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}/g,/\bbearer\s+[A-Za-z0-9._~+/-]{12,}=*/gi,/\b(?:sk|pk|rk)-[A-Za-z0-9]{2,}-?[A-Za-z0-9]{12,}/g,/\b(?:sk|pk)_(?:live|test)_[A-Za-z0-9]{16,}/g,/\bhk-[A-Za-z0-9]{16,}/g,/\bAKIA[0-9A-Z]{16}\b/g,/\bASIA[0-9A-Z]{16}\b/g,/\bAIza[0-9A-Za-z_-]{20,}/g,/\bgh[posru]_[A-Za-z0-9]{20,}/g,/\bxox[baprs]-[A-Za-z0-9-]{10,}/g,/[a-zA-Z][a-zA-Z0-9+.-]{0,32}:\/\/[^\s:@/]{1,256}:[^\s@/]{1,256}@/g],ht=/\b(?:\d[ -]?){13,19}\b/g;function At(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let s=e.charCodeAt(r)-48;n&&(s*=2,s>9&&(s-=9)),t+=s,n=!n}return t%10===0}function _t(e){return e.replace(ht,t=>{let n=t.replace(/[ -]/g,"");return n.length<13||n.length>19?t:At(n)?q:t})}var Et=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,yt=/\b(?:\d{1,3}\.){3}\d{1,3}\b/g,bt=/\b(?:[0-9A-Fa-f]{1,4}:){2,7}[0-9A-Fa-f]{1,4}\b/g,Tt=["code","state","token","access_token","id_token","refresh_token","auth","authorization","secret","client_secret","password","passwd","pwd","api_key","apikey","key","session","session_id","sid","sig","signature","nonce","otp","invite","invitation","reset_token","confirmation_token","magic","ticket","assertion"],vt=new RegExp("([?&#;](?:"+Tt.join("|")+")=)[^&#;\\s]{1,4096}","gi");function xt(e){return e.replace(vt,(t,n)=>n+q)}function wt(e){e=xt(e);for(let t of pt)e=e.replace(t,q);return _t(e)}function kt(e){return e=e.replace(Et,ft),e=e.replace(bt,le),e=e.replace(yt,le),e}var St=8192;function Ct(e,t=St){return e.length>t?e.slice(0,t)+"\u2026 [truncated]":e}function z(e,t=!1){return e?(e=Ct(e),e=wt(e),t||(e=kt(e)),e):e??""}var L="iam-anon-id",K=["hz_anon_id","hz_id"],V="hanzo.ai",It=2*365*24*60*60,ge;function U(e){var t=new Uint8Array(16),n,r=typeof crypto<"u"?crypto:void 0;if(r&&typeof r.getRandomValues=="function")r.getRandomValues(t);else for(n=0;n<16;n++)t[n]=Math.random()*256|0;var s=Math.floor(e===void 0?Date.now():e);for(n=5;n>=0;n--)t[n]=s%256,s=Math.floor(s/256);t[6]=112|t[6]&15,t[8]=128|t[8]&63;var o="";for(n=0;n<16;n++)o+=(t[n]+256).toString(16).slice(1),(n===3||n===5||n===7||n===9)&&(o+="-");return o}function ke(){try{return typeof document>"u"||typeof document.cookie!="string"?null:document}catch{return null}}function Pt(){try{return typeof window>"u"||!window.localStorage?null:window.localStorage}catch{return null}}function Se(e,t){try{return e&&e.getItem(t)||""}catch{return""}}function Ce(e){var t=ke();if(!t)return"";for(var n=t.cookie.split(";"),r=0;r<n.length;r++){var s=n[r].indexOf("=");if(!(s<0||n[r].slice(0,s).trim()!==e)){var o=n[r].slice(s+1).trim();if(o)try{return decodeURIComponent(o)}catch{return o}}}return""}function Nt(e,t){var n=ke();if(n){var r="",s=!1;try{typeof window<"u"&&window.location&&(r=window.location.hostname||"",s=window.location.protocol==="https:")}catch{}var o=e+"="+encodeURIComponent(t);o+="; Path=/; Max-Age="+It+"; SameSite=Lax",("."+r).slice(-(V.length+1))==="."+V&&(o+="; Domain="+V),s&&(o+="; Secure");try{n.cookie=o}catch{}}}function Ot(e){for(var t=0;t<K.length;t++){var n=Ce(K[t])||Se(e,K[t]);if(n)return n}return""}function Rt(){if(typeof window>"u")return"";var e=Pt(),t=Ce(L)||Se(e,L)||Ot(e)||ge||U();ge=t,Nt(L,t);try{e&&e.getItem(L)!==t&&e.setItem(L,t)}catch{}return t}var Dt="0.3.41",Ie=Dt,ue=50,Lt=500,zt=2048,me=1024,Ut=50;function Mt(){return U().replace(/-/g,"")}function $t(e){return typeof TextEncoder<"u"?new TextEncoder().encode(e).length:typeof Buffer<"u"?Buffer.byteLength(e,"utf8"):e.length}function de(e){if(!e)return null;let t=/^(https?):\/\/([^@]+)@([^/]+)(\/.*)?$/.exec(e.trim());if(!t)return null;let n=t[1],r=t[2],s=t[3],o=t[4]??"";if(!r||!s)return null;let c=o.split("/").filter(Boolean),f=c.length>0?c[c.length-1]:"";if(!f)return null;let p=`${n}://${s}`,_=`${p}/${c.map(encodeURIComponent).join("/")}`,E=`${_}/envelope/?sentry_key=${encodeURIComponent(r)}`;return{publicKey:r,origin:p,projectId:f,base:_,ingestUrl:E}}var Bt=/^\s*at\s+(?:(.+?)\s+\()?(?:(.+?):(\d+):(\d+)|([^)]+))\)?\s*$/,Ft=/^\s*(?:(.*?)@)?(.+?):(\d+):(\d+)\s*$/;function Gt(e){return e?!(e.includes("node_modules")||e.startsWith("webpack-internal")||e.startsWith("webpack://")||e.startsWith("chrome-extension://")||e.startsWith("moz-extension://")):!1}function Pe(e){if(!e)return[];let t=e.split(`
|
|
2
|
+
`,Lt),n=[];for(let r of t){if(r.length>zt)continue;let s=r.trimEnd();if(!s)continue;let o,c="",f=0,p=0,_=Bt.exec(s);if(_)o=_[1],_[2]?(c=_[2],f=Number(_[3])||0,p=Number(_[4])||0):c=(_[5]||"").trim();else{let E=Ft.exec(s);if(!E)continue;o=E[1],c=E[2],f=Number(E[3])||0,p=Number(E[4])||0}!c&&!o||n.push({function:o||"<anonymous>",filename:c,abs_path:c,lineno:f,colno:p,in_app:Gt(c)})}return n.reverse(),n.length>ue?n.slice(n.length-ue):n}function Y(e){if(e instanceof Error){let t=W(e,"name"),n=W(e,"message"),r=W(e,"stack");return{name:typeof t=="string"&&t?t:"Error",message:typeof n=="string"&&n?n:H(e),stack:typeof r=="string"?r:void 0}}if(typeof e=="string")return{name:"Error",message:e};try{return{name:"Error",message:JSON.stringify(e)??H(e)}}catch{return{name:"Error",message:H(e)}}}function W(e,t){try{return e[t]}catch{return}}function H(e){try{return String(e)}catch{return"[unstringifiable]"}}function jt(e){let t=typeof e=="string"?e:(()=>{try{return JSON.stringify(e)??String(e)}catch{try{return String(e)}catch{return"[unstringifiable]"}}})();return t.length>me?t.slice(0,me):t}function Kt(e){let{error:t,options:n={},identity:r,capturePII:s=!1}=e,o=Y(t),c=n.handled!==!1,f=n.level??(c?"error":"fatal"),p={handled:String(c)};r.product&&(p.product=r.product),r.sessionId&&(p.session=r.sessionId);try{let E=n.properties??{},k=0;for(let S of Object.keys(E)){if(k>=Ut)break;try{let C=E[S];if(C==null)continue;p[S]=z(jt(C),s),k++}catch{continue}}}catch{}let _={event_id:e.id??Mt(),timestamp:(e.now??Date.now())/1e3,platform:"javascript",level:f,logger:r.product,environment:r.environment,release:r.release,exception:{values:[{type:o.name,value:z(o.message,s),stacktrace:{frames:Pe(o.stack)}}]},tags:p,sdk:{name:"@hanzo/event",version:Ie}};return r.userId&&(_.user={id:r.userId}),_}function Vt(e,t,n){let r=JSON.stringify(e),s=JSON.stringify({event_id:e.event_id,dsn:t.base,sent_at:n??new Date().toISOString()}),o=JSON.stringify({type:"event",content_type:"application/json",length:$t(r)});return`${s}
|
|
3
|
+
${o}
|
|
4
|
+
${r}
|
|
5
|
+
`}var Wt=4096;function Ne(e){let t="";for(let n of[2166136261,16777619,2654435769,2246822507]){let r=n>>>0;for(let s=0;s<e.length;s++)r^=e.charCodeAt(s),r=r+(r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24)>>>0;t+=r.toString(16).padStart(8,"0")}return t}function Ht(e){let t=e.filename??"",n=e.function??"<anonymous>",r=e.lineno??0,s=e.colno??0;return{raw_id:`${Ne(`${t}|${n}|${r}|${s}`)}/0`,mangled_name:n,source:t,line:r,column:s,in_app:e.in_app??!1,lang:"javascript",resolved:!1,resolve_failure:"no symbol set uploaded for this release",resolved_name:null,module:null}}function Zt(e,t){if(e.length<=t)return e;let n=t,r=e.charCodeAt(n-1);return r>=55296&&r<=56319&&n--,e.slice(0,n)}function qt(e,t){let n=Y(e),r=Pe(n.stack).slice(-50),s={id:t.id,type:n.name,value:Zt(n.message,Wt),mechanism:{type:"generic",handled:t.handled,synthetic:!(e instanceof Error)}};return r.length>0&&(s.stacktrace={type:"resolved",frames:r.map(Ht)}),s}function Yt(e){var r;let n=(((r=e.stacktrace)==null?void 0:r.frames)??[]).filter(s=>s.in_app).map(s=>`${s.mangled_name}@${s.source}`);return Ne([e.type,...n].join(`
|
|
6
|
+
`))}function Jt(e,t){var o,c;let n=qt(e,t),r=((o=n.stacktrace)==null?void 0:o.frames)??[],s=Yt(n);return{$exception_list:[n],$exception_fingerprint:s,$exception_fingerprint_record:[{type:"manual"}],$exception_type:n.type,$exception_message:n.value,$exception_level:t.level??"error",$exception_handled:t.handled,$exception_synthetic:((c=n.mechanism)==null?void 0:c.synthetic)??!1,$exception_types:[n.type],$exception_values:[n.value],$exception_sources:r.map(f=>f.source).filter(f=>!!f),$exception_functions:r.map(f=>f.resolved_name??f.mangled_name).filter(f=>!!f)}}var R={session:"hz_session",firstTouch:"hz_first_touch",cohort:"hz_cohort"},Xt=1800*1e3;function M(){try{return typeof window>"u"||!window.localStorage?void 0:window.localStorage}catch{return}}function fe(){return Rt()||void 0}function pe(e=Date.now()){let t=M();if(!t)return;let n=null;try{n=JSON.parse(t.getItem(R.session)||"null")}catch{n=null}return!n||e-n.last>Xt?n={id:U(e),last:e}:n.last=e,t.setItem(R.session,JSON.stringify(n)),n.id}function Oe(){let e=M();if(e)try{let t=e.getItem(R.firstTouch);return t?JSON.parse(t):void 0}catch{return}}function Qt(e){let t=M(),n=Oe();return n||(t&&t.setItem(R.firstTouch,JSON.stringify(e)),e)}function en(){let e=M();if(e)try{let t=e.getItem(R.cohort);return t?JSON.parse(t):void 0}catch{return}}function he(e){let t=M(),n=en()||{},r={signupWeek:n.signupWeek||e.signupWeek,channel:e.channel||n.channel,refCode:n.refCode||e.refCode};return t&&t.setItem(R.cohort,JSON.stringify(r)),r}var Ae="/v1/event",Re="https://api.hanzo.ai",tn="application/x-sentry-envelope",_e="text/plain";function Ee(){try{if(typeof process<"u"&&process.env)return process.env.NEXT_PUBLIC_HANZO_EVENT_DSN||process.env.HANZO_EVENT_DSN||void 0}catch{}}function Z(e){try{if(typeof process<"u"&&process.env)return process.env[e]||void 0}catch{}}function ye(e,t,n){return e+(e.includes("?")?"&":"?")+t+"="+encodeURIComponent(n)}function nn(e){let t=Y(e);return{type:t.name,message:t.message,stack:t.stack}}var P=()=>typeof window<"u"&&typeof document<"u";function rn(e){try{return JSON.stringify({batch:e})}catch{}let t=[];for(let n of e)try{t.push(JSON.stringify(n))}catch{try{t.push(JSON.stringify({...n,properties:{$unserializable:!0}}))}catch{}}return t.length>0?'{"batch":['+t.join(",")+"]}":null}var sn=class{send(e,t,n){if(n.beacon&&P()&&typeof navigator.sendBeacon=="function"){let c=n.ingestKey?ye(e,"ingest_key",n.ingestKey):e;try{if(navigator.sendBeacon(c,new Blob([t],{type:_e})))return;n.debug&&console.warn("[event] beacon refused, falling back to fetch")}catch{}}if(typeof fetch!="function")return;let r=n.ingestKey!==void 0&&n.contentType===void 0,s={"Content-Type":r?_e:n.contentType??"application/json"},o=r?void 0:n.ingestKey??n.token;o&&(s.Authorization=`Bearer ${o}`),fetch(r?ye(e,"ingest_key",n.ingestKey):e,{method:"POST",headers:s,body:t,keepalive:!0,credentials:r?"omit":"include"}).then(c=>{!c.ok&&n.debug&&console.warn("[event] ingest rejected",c.status,e.split("?")[0])}).catch(c=>{n.debug&&console.warn("[event] ingest failed",e.split("?")[0],c)})}},be=class{constructor(e){this.queue=[],this.timer=null,this.attribution={utm:{}},this.cohort={},this.started=!1,this.reentrant=!1,this.cfg={host:Re,batchSize:20,flushIntervalMs:5e3,enabled:!0,captureErrors:!0,...e,ingestKey:e.ingestKey??Z("NEXT_PUBLIC_PUBLISHABLE_KEY")??dt()},this.transport=e.transport??new sn,this.dsn=de(e.dsn??Ee()??ce(this.cfg.product,this.cfg.ingestKey))}adopt(e){e.ingestKey&&!this.cfg.ingestKey&&(this.cfg.ingestKey=e.ingestKey),e.getToken&&!this.cfg.getToken&&(this.cfg.getToken=e.getToken),this.dsn||(this.dsn=de(e.dsn??Ee()??ce(this.cfg.product,this.cfg.ingestKey)))}get errorPlaneEnabled(){return this.dsn!==null}get errorIngestUrl(){var e;return(e=this.dsn)==null?void 0:e.ingestUrl}init(){if(this.started||!this.cfg.enabled||(this.started=!0,!P()))return;let e=it(window.location.search,document.referrer);this.attribution=ot(e)?Qt(e):Oe()??e,this.cohort=he({channel:this.attribution.channel??ve(this.attribution),refCode:this.attribution.refCode});let t=()=>{document.visibilityState==="hidden"&&this.flush(!0)};window.addEventListener("visibilitychange",t),window.addEventListener("pagehide",()=>this.flush(!0)),this.cfg.captureErrors&&(window.addEventListener("error",n=>{this.captureError(n.error??n.message,{handled:!1})}),window.addEventListener("unhandledrejection",n=>{this.captureError(n.reason,{handled:!1})}))}identify(e,t){this.personId=e,this.enqueue("identify",void 0,{properties:t})}group(e,t){this.enqueue("group",void 0,{groupId:e,properties:t})}pageview(e,t){let n=e??(P()?window.location.pathname:void 0),r=(n??"")+"\0"+(P()?window.location.href:"");r!==this.counted&&(this.counted=r,this.enqueue("pageview",w,{path:n,properties:t}))}capture(e,t,n){this.enqueue("event",e,{properties:t,...n})}captureError(e,t){if(!this.reentrant){this.reentrant=!0;try{try{this.sendError(e,t)}catch{}try{let n=(t==null?void 0:t.handled)??!0,r=nn(e);r.handled=n,this.enqueue("event",O,{error:r,properties:{...t==null?void 0:t.properties,...Jt(e,{handled:n,id:U(),level:t==null?void 0:t.level})}}),this.flush()}catch{}}finally{this.reentrant=!1}}}setCohort(e){this.cohort=he(e)}flush(e=!1){var c,f,p;if(!this.cfg.enabled||this.queue.length===0)return;let t=this.queue;this.queue=[],this.clearTimer();let n=((f=(c=this.cfg).getToken)==null?void 0:f.call(c))??void 0,r=n?void 0:((p=this.cfg.ingestKey)==null?void 0:p.trim())||void 0,s=e&&!n,o=rn(t);if(o===null){this.cfg.debug&&console.debug("[event] flush \u2192 dropped, batch unserializable");return}this.cfg.debug&&console.debug("[event] flush \u2192",Ae,t.length),this.transport.send(this.cfg.host+Ae,o,{beacon:s,token:n,ingestKey:r,debug:this.cfg.debug})}sendError(e,t){if(!this.cfg.enabled||!this.dsn)return;let n=Kt({error:e,options:t,identity:this.errorIdentity(),capturePII:this.cfg.capturePII??!1}),r=Vt(n,this.dsn);this.cfg.debug&&console.debug("[event] error \u2192",this.dsn.ingestUrl,n.event_id),this.transport.send(this.dsn.ingestUrl,r,{beacon:!1,contentType:tn,debug:this.cfg.debug})}errorIdentity(){return{userId:this.personId??fe(),sessionId:pe(),product:this.cfg.product,release:this.cfg.release??Z("NEXT_PUBLIC_HANZO_RELEASE"),environment:this.cfg.environment??Z("NODE_ENV")}}enqueue(e,t,n){this.cfg.enabled&&(this.started||this.init(),this.queue.push(this.build(e,t,n)),this.queue.length>=this.cfg.batchSize?this.flush():this.schedule())}build(e,t,n){let r=fe(),s={messageId:U(),type:e,event:t,timestamp:new Date().toISOString(),distinctId:this.personId??r,anonymousId:r,personId:this.personId,sessionId:pe(),product:this.cfg.product,referrer:this.attribution.referrer,utm:this.attribution.utm,refCode:this.cohort.refCode??this.attribution.refCode,channel:this.cohort.channel??this.attribution.channel,signupWeek:this.cohort.signupWeek,url:P()?window.location.href:void 0,path:P()?window.location.pathname:void 0,library:"@hanzo/event",libraryVersion:Ie,...n},o=this.cfg.capturePII??!1;return s.url&&(s.url=z(s.url,o)),s.path&&(s.path=z(s.path,o)),s.referrer&&(s.referrer=z(s.referrer,o)),s}schedule(){this.timer||!this.cfg.enabled||(this.timer=setTimeout(()=>{this.timer=null,this.flush()},this.cfg.flushIntervalMs))}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}},Te=Symbol.for("hanzo.event.clients");function on(){let e=globalThis,t=e[Te];if(t)return t;let n=new Map;return e[Te]=n,n}function De(e){if(!P()||e.enabled===!1)return new be(e);let t=(e.host??Re)+"\0"+e.product,n=on(),r=n.get(t);if(r)return r.adopt(e),r;let s=new be(e);return n.set(t,s),s}var xn={signup:{label:"Signup",event:g.SIGNUP_COMPLETED,funnelId:"signup",funnel:I("signup")},sale:{label:"Sale",event:g.ORDER_COMPLETED,funnelId:"upgrade",funnel:I("upgrade"),filter:{property:"kind",equals:"plan"}},upgradeIntent:{label:"Upgrade Intent",event:g.PLAN_CLICKED,funnelId:"upgrade",funnel:I("upgrade")},activation:{label:"Activation",event:g.FIRST_ACTION,funnelId:"apiActivation",funnel:I("apiActivation")}};var $="https://api.hanzo.ai";var Le=void 0;var In=60*1e3;var v={insights:"hanzo_insights_enabled",training:"hanzo_share_training",onboarded:"hanzo_onboarded"},J=globalThis.browser??globalThis.chrome;function ze(){var e,t,n,r;return((t=(e=globalThis.chrome)==null?void 0:e.storage)==null?void 0:t.local)??((r=(n=globalThis.browser)==null?void 0:n.storage)==null?void 0:r.local)}function Ue(e){return new Promise(t=>{let n=ze();if(!n)return t({});try{n.get(e,r=>t(r||{}))}catch{t({})}})}function Q(e){return new Promise(t=>{let n=ze();if(!n)return t();try{n.set(e,()=>t())}catch{t()}})}async function Me(){var e,t;try{let n=await((t=(e=J==null?void 0:J.runtime)==null?void 0:e.sendMessage)==null?void 0:t.call(e,{action:"auth.getToken"}));return(n==null?void 0:n.token)??null}catch{return null}}function $e(e){return{insights:e[v.insights]!==!1,shareTraining:e[v.training]===!0}}async function an(){let e=$e(await Ue([v.insights,v.training])),t=await Me();if(!t)return e;try{let n=await fetch(`${$}/v1/iam/consent`,{headers:{authorization:`Bearer ${t}`}});if(n.ok){let r=await n.json(),s={insights:r.insights!==!1,shareTraining:r.shareTraining===!0};return await Q({[v.insights]:s.insights,[v.training]:s.shareTraining}),s}}catch{}return e}async function Be(e){let t=$e(await Ue([v.insights,v.training])),n={insights:e.insights??t.insights,shareTraining:e.shareTraining??t.shareTraining};await Q({[v.insights]:n.insights,[v.training]:n.shareTraining});let r=await Me();if(r)try{await fetch(`${$}/v1/iam/consent`,{method:"PUT",headers:{"content-type":"application/json",authorization:`Bearer ${r}`},body:JSON.stringify(n),keepalive:!0}).catch(()=>{})}catch{}}async function Fe(){await Q({[v.onboarded]:!0})}function cn(){if(typeof navigator>"u")return!0;let e=navigator,t=e.doNotTrack??e.msDoNotTrack;return!(t==="1"||t==="yes"||e.globalPrivacyControl)}var X=null;function ln(){return X||(X=De({product:"extension",host:$,ingestKey:Le,captureErrors:!1})),X}async function Ge(e,t){try{if(!cn()||!(await an()).insights)return;let r=ln();r.capture(e,t),r.flush(!0)}catch{}}var je=globalThis.browser??globalThis.chrome,ee=document.getElementById("ob-insights"),te=document.getElementById("ob-training"),ne=document.getElementById("ob-continue");ne==null||ne.addEventListener("click",async()=>{let e={insights:(ee==null?void 0:ee.checked)??!0,shareTraining:(te==null?void 0:te.checked)??!1};await Be(e),await Fe(),await Ge("onboarding_complete",{shareTraining:e.shareTraining});try{let t=await je.tabs.getCurrent();t!=null&&t.id?await je.tabs.remove(t.id):window.close()}catch{window.close()}});})();
|
|
7
|
+
/*! Bundled license information:
|
|
8
|
+
|
|
9
|
+
@hanzo/event/dist/index.mjs:
|
|
10
|
+
(*! anon.js — THE anonymous-identity chain. ONE implementation, two distributions.
|
|
11
|
+
*
|
|
12
|
+
* One browser is ONE person on every Hanzo surface, whichever client a page
|
|
13
|
+
* happens to have loaded. There were once three implementations writing TWO keys —
|
|
14
|
+
* `hz_anon_id` and `hz_id` — so the same visitor was several people depending on
|
|
15
|
+
* which snippet the surface shipped.
|
|
16
|
+
*
|
|
17
|
+
* The two call sites:
|
|
18
|
+
* 1. src/storage.ts — the bundled npm client; IMPORTS this file.
|
|
19
|
+
* 2. hanzoai/cloud apps/analytics/tag.js — the tag served at
|
|
20
|
+
* /v1/event.js; vendors this file and its tag.go serves the marked region
|
|
21
|
+
* with the tag as one asset, so cloud holds no second copy either.
|
|
22
|
+
*
|
|
23
|
+
* (2) has no bundler and cannot import anything, which is why the chain lives in a
|
|
24
|
+
* file that is plain ES5 rather than in a .ts: the region between the BEGIN and END
|
|
25
|
+
* markers is COPIED VERBATIM. Keep it ES5, dependency-free, `hz`-prefixed (it is
|
|
26
|
+
* spliced into other people's scopes) and unformatted — a reformat here is a diff
|
|
27
|
+
* against the vendored copy. After editing, resync that copy:
|
|
28
|
+
*
|
|
29
|
+
* curl -fsSL https://unpkg.com/@hanzo/event/src/anon.js -o apps/analytics/anon.js
|
|
30
|
+
*)
|
|
31
|
+
*/
|
package/firefox/page.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";(()=>{var R=new Set(["button","link","textbox","searchbox","checkbox","radio","switch","combobox","listbox","option","slider","spinbutton","tab","menuitem","menuitemcheckbox","menuitemradio","treeitem","clickable"]),Oe=new Set(["heading","img","cell","gridcell","columnheader","rowheader","dialog","alertdialog","article","region","navigation","form","iframe"]),fe=new Set(["button","link","heading","cell","gridcell","columnheader","rowheader","option","tab","menuitem","menuitemcheckbox","menuitemradio","treeitem","checkbox","radio","switch","tooltip","clickable"]),Re=new Set(["cell","gridcell","columnheader","rowheader"]),De=new Set(["textbox","searchbox","combobox","spinbutton","slider"]),Ke=new Set(["script","style","noscript","template","head","meta","link","title","base","object","embed","param","source","track","datalist"]),D=new Set(["inline","inline-block","inline-flex","inline-grid","contents"]),je=new Set(["hanzo-ai-overlay","hanzo-page-overlay-root","hanzo-picker-overlay","hanzo-console-root"]),me='a[href],area[href],button,input,select,textarea,summary,iframe,[tabindex],[contenteditable=""],[contenteditable="true"]',Be={fieldset:"legend",table:"caption",figure:"figcaption"},d=150,P=300,L=25,I=new Map,W=new WeakMap,x=0;function de(e){let n=W.get(e);return n||(n=`e${++x}`,W.set(e,n)),I.set(n,new WeakRef(e)),n}function he(e){return/^@?e\d+$/.test(e.trim())}function pe(e){return e.isConnected&&!!e.ownerDocument.defaultView}function h(e){var r;if(!e||!e.trim())throw new Error("selector required: a snapshot ref (@e2) or a CSS selector");let n=e.trim();if(he(n)){let o=n.replace(/^@/,""),i=(r=I.get(o))==null?void 0:r.deref();if(!i)throw new Error(`Unknown ref @${o}: this page has no such ref (it navigated, or the ref came from another tab). Run snapshot again for fresh refs.`);if(!pe(i))throw I.delete(o),new Error(`Stale ref @${o}: its element is no longer in the page. Run snapshot again for fresh refs.`);return i}let t;try{t=document.querySelector(n)}catch{throw new Error(`Invalid selector ${JSON.stringify(n)}: pass a snapshot ref (@e2) or a CSS selector.`)}if(!t)throw new Error(`No element matches ${JSON.stringify(n)}. Run snapshot to see what is on the page.`);return t}function g(e){return e.ownerDocument.defaultView.getComputedStyle(e)}function U(e){var t;let n=e;try{if(typeof n.openOrClosedShadowRoot=="function")return n.openOrClosedShadowRoot()??null;let r=(t=globalThis.chrome)==null?void 0:t.dom;if(r!=null&&r.openOrClosedShadowRoot&&e instanceof e.ownerDocument.defaultView.HTMLElement)return r.openOrClosedShadowRoot(e)??null}catch{}return e.shadowRoot}function $(e){let n=e instanceof Element?U(e):null,t=[];for(let r of Array.from((n??e).childNodes))if(r.nodeType===1&&r.localName==="slot"){let o=r,i=typeof o.assignedNodes=="function"?o.assignedNodes({flatten:!0}):[];t.push(...i.length?i:Array.from(o.childNodes))}else t.push(r);return t}function X(e){if(e.assignedSlot)return e.assignedSlot;let n=e.parentNode;return n?n.nodeType===11?n.host??null:n.nodeType===1?n:null:null}function Ve(e,n){for(let t=n;t;t=X(t))if(t===e)return!0;return!1}function k(e){if(Ke.has(e.localName)||je.has(e.id)||e.hidden||e.getAttribute("aria-hidden")==="true")return!0;let n=g(e).display;return n==="none"?!0:n!=="contents"&&typeof e.checkVisibility=="function"&&!e.checkVisibility()}function f(e){return e.replace(/\s+/g," ").trim()}function m(e,n){return e.length>n?`${e.slice(0,n-1)}\u2026`:e}function A(e,n=d*2){let t="",r=o=>{if(t.length>n)return;if(o.nodeType===3){t+=o.textContent;return}if(o.nodeType!==1)return;let i=o;if(k(i))return;let s=i.getAttribute("aria-label");if(s&&s.trim()){t+=` ${s} `;return}if(i.localName==="img"){t+=` ${i.getAttribute("alt")??""} `;return}if(i.localName==="input"){let c=i.type;(c==="submit"||c==="button"||c==="reset")&&(t+=` ${i.value} `);return}if(i.localName==="select"||i.localName==="textarea")return;let a=!D.has(g(i).display),l=t.length;a&&(t+=" ");for(let c of $(i))r(c);!t.slice(l).trim()&&i.getAttribute("title")&&(t+=` ${i.getAttribute("title")} `),a&&(t+=" ")};for(let o of $(e))r(o);return f(t)}function Pe(e,n){let t=e.getAttribute(n);if(!t)return"";let r=e.getRootNode();return f(t.split(/\s+/).map(o=>{var s;let i=((s=r.getElementById)==null?void 0:s.call(r,o))??e.ownerDocument.getElementById(o);return i?A(i):""}).join(" "))}function ne(e){for(let n=e.parentElement;n;n=n.parentElement)if(["article","aside","main","nav","section"].includes(n.localName))return!0;return!1}function We(e){var t;switch(e.localName){case"a":case"area":return e.hasAttribute("href")?"link":"";case"button":return"button";case"input":{let r=e.type;return r==="hidden"?"":r==="button"||r==="submit"||r==="reset"||r==="image"||r==="file"?"button":r==="checkbox"?"checkbox":r==="radio"?"radio":r==="range"?"slider":r==="number"?"spinbutton":e.hasAttribute("list")?"combobox":r==="search"?"searchbox":"textbox"}case"select":return e.multiple||e.size>1?"listbox":"combobox";case"option":return"option";case"textarea":return"textbox";case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return"heading";case"img":return e.getAttribute("alt")===""?"":"img";case"svg":return e.getAttribute("aria-label")||e.querySelector("title")?"img":"";case"ul":case"ol":case"menu":return"list";case"li":return"listitem";case"nav":return"navigation";case"main":return"main";case"header":return ne(e)?"":"banner";case"footer":return ne(e)?"":"contentinfo";case"aside":return"complementary";case"form":return"form";case"section":return e.hasAttribute("aria-label")||e.hasAttribute("aria-labelledby")?"region":"";case"article":return"article";case"table":return"table";case"tr":return"row";case"td":return"cell";case"th":return e.getAttribute("scope")==="row"?"rowheader":"columnheader";case"dialog":return"dialog";case"details":case"fieldset":return"group";case"summary":return"button";case"p":return"paragraph";case"blockquote":return"blockquote";case"hr":return"separator";case"progress":return"progressbar";case"meter":return"meter";case"output":return"status";case"iframe":return"iframe";case"figure":return"figure"}return e.isContentEditable&&!((t=e.parentElement)!=null&&t.isContentEditable)?"textbox":""}function z(e,n,t){let r=(e.getAttribute("role")||"").trim().split(/\s+/)[0].toLowerCase();if(r&&r!=="presentation"&&r!=="none"&&r!=="generic")return r;let o=We(e);if(o)return o;let i=e.localName;return i==="label"||i==="body"||i==="html"?"":e.hasAttribute("tabindex")&&e.tabIndex>=0||e.hasAttribute("onclick")||n==="pointer"&&t!=="pointer"?"clickable":""}function be(e){let n=e.localName;if(n==="select")return Array.from(e.selectedOptions).map(o=>f(o.label||o.text)).join(", ");if(n==="input"||n==="textarea"){let r=e;return r.type==="password"?r.value?"\u2022".repeat(Math.min(r.value.length,8)):"":r.value}return e.isContentEditable?f(e.textContent||""):e.getAttribute("aria-valuenow")??void 0}function ge(e,n){var s;let t=Pe(e,"aria-labelledby");if(t)return m(t,d);let r=e.getAttribute("aria-label");if(r&&r.trim())return m(f(r),d);let o=e.localName;if(o==="input"||o==="select"||o==="textarea"){let a=e;if(o==="input"&&(a.type==="submit"||a.type==="reset"||a.type==="button"))return m(a.value||(a.type==="submit"?"Submit":a.type==="reset"?"Reset":""),d);if(o==="input"&&a.type==="image")return m(a.alt||a.title||"Submit",d);let l=Array.from(a.labels??[]).map(c=>A(c)).filter(Boolean).join(" ");return m(l||f(a.placeholder||e.getAttribute("title")||""),d)}if(o==="img"||o==="area")return m(f(e.getAttribute("alt")||e.getAttribute("title")||""),d);if(o==="svg")return m(f(((s=e.querySelector("title"))==null?void 0:s.textContent)||""),d);let i=Be[o];if(i){let a=e.querySelector(`:scope > ${i}`);if(a)return m(A(a),d)}if(o==="iframe")return m(f(e.getAttribute("title")||e.getAttribute("name")||""),d);if(fe.has(n)){let a=A(e);if(a)return m(a,d)}return m(f(e.getAttribute("title")||""),d)}function T(e){try{if(e.matches(":disabled"))return!0}catch{}return!!e.closest('[aria-disabled="true"]')}function F(e){if(e.localName==="input"){let t=e;if(t.type==="checkbox"||t.type==="radio")return t.indeterminate?"mixed":t.checked}let n=e.getAttribute("aria-checked");if(n==="mixed")return"mixed";if(n==="true"||n==="false")return n==="true"}function Fe(e,n){var i;let t=[];if(n==="heading"){let s=/^h([1-6])$/.exec(e.localName);t.push(`level=${e.getAttribute("aria-level")||(s?s[1]:"2")}`)}let r=F(e);r==="mixed"?t.push("checked=mixed"):r===!0&&t.push("checked"),R.has(n)&&T(e)&&t.push("disabled");let o=e.getAttribute("aria-expanded");return o==="true"||o==="false"?t.push(`expanded=${o}`):e.localName==="summary"&&((i=e.parentElement)==null?void 0:i.localName)==="details"&&t.push(`expanded=${e.parentElement.open}`),(e.getAttribute("aria-selected")==="true"||e.localName==="option"&&e.selected)&&t.push("selected"),e.getAttribute("aria-pressed")==="true"&&t.push("pressed"),(e.required||e.getAttribute("aria-required")==="true")&&t.push("required"),t}function H(e){return e.text===void 0&&R.has(e.role)&&!!e.el||e.kids.some(H)}function _e(e,n){let t=e[e.length-1];t&&t.text!==void 0&&!t.closed?t.text+=n:e.push({role:"",name:"",text:n,props:[],kids:[]})}function v(e){let n=e[e.length-1];n&&n.text!==void 0&&(n.closed=!0)}function C(e,n,t,r){for(let o of $(e))o.nodeType===3?t||_e(n,o.textContent||""):o.nodeType===1&&Ee(o,n,r)}function Ee(e,n,t){if(k(e))return;let r=g(e),o=r.visibility!=="visible",i=o?"":z(e,r.cursor,t),s=!D.has(r.display);if(!i){s&&v(n),C(e,n,o,r.cursor),s&&v(n);return}let a={role:i,name:ge(e,i),el:e,props:Fe(e,i),kids:[]},l=[];if((De.has(i)||e.localName==="select")&&(a.value=be(e)),e.localName==="select"){let c=Array.from(e.options);for(let p of c.slice(0,L))a.kids.push({role:"option",name:m(f(p.label||p.text),d),props:p.selected?["selected"]:[],kids:[]});c.length>L&&a.kids.push({role:"",name:"",text:`\u2026 ${c.length-L} more options`,props:[],kids:[]})}else if(e.localName==="iframe"){let c=null;try{c=e.contentDocument}catch{}c!=null&&c.body?C(c.body,a.kids,!1,""):a.props.push("cross-origin")}else i==="img"||e.localName==="input"||e.localName==="textarea"||(C(e,a.kids,!1,r.cursor),l=a.kids,Re.has(i)&&a.kids.some(H)&&!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&(a.name=""),fe.has(i)&&a.name&&(a.kids=a.kids.filter(H)));if(i==="clickable"&&l.some(H)){s&&v(n),n.push(...l),s&&v(n);return}s&&v(n),n.push(a),s&&v(n)}function we(e){let n=[];for(let t of e){if(t.text!==void 0){let r=f(t.text);r&&n.push({...t,text:r});continue}t.kids=we(t.kids),!(ye(t)&&!t.kids.length&&t.role!=="separator")&&n.push(t)}return n}function ye(e){return!xe(e)&&!e.name&&e.value===void 0&&e.props.length===0}function xe(e){return e.el?R.has(e.role)||Oe.has(e.role)&&(!!e.name||e.role==="iframe"):!1}function ke(e){let n=[];for(let t of e){if(t.text!==void 0){n.push(t);continue}if(t.kids=ke(t.kids),ye(t)&&t.kids.length<=1){n.push(...t.kids);continue}n.push(t)}return n}function Y(e,n=[]){for(let t of e)t.text===void 0&&R.has(t.role)&&t.el&&n.push({...t,kids:[]}),Y(t.kids,n);return n}function Je(e,n){if(e.text!==void 0)return`${n}- text: ${m(e.text,P)}`;let t=`${n}- ${e.role}`;e.name&&(t+=` ${JSON.stringify(e.name)}`),xe(e)&&(t+=` [ref=${de(e.el)}]`);for(let r of e.props)t+=` [${r}]`;return t}function Te(e,n,t,r){let o=" ".repeat(n),i=!t.depth||n+1<t.depth;for(let s of e){let a=Je(s,o),l=s.kids;if(s.text===void 0){s.value&&(!l.length||!i)?a+=`: ${m(f(s.value),P)}`:l.length===1&&l[0].text!==void 0&&(a+=`: ${m(l[0].text,P)}`,l=[]);let c=t.urls&&s.role==="link"?s.el.href:"";(c||l.length&&i)&&(a+=":"),r.push(a),c&&r.push(`${o} - /url: ${c}`),i&&Te(l,n+1,t,r)}else r.push(a)}}function ve(e){let n=[];if(e.selector){let t=h(e.selector),r=X(t);Ee(t,n,r?g(r).cursor:"")}else{let t=document.body??document.documentElement;C(t,n,!1,"")}return n=we(n),e.compact?ke(n):n}function $e(){for(let[e,n]of I){let t=n.deref();(!t||!pe(t))&&I.delete(e)}}function Ne(e={}){e.base&&e.base>x&&(x=e.base),$e();let n=ve(e);e.interactive&&(n=Y(n));let t=[];Te(n,0,e,t);let r=t.filter(o=>o.includes("[ref=")).length;return{tree:t.join(`
|
|
2
|
+
`)||"(empty: nothing rendered)",refs:r,last:x,url:location.href,title:document.title}}function u(e){let n=z(e,"","")||e.localName,t=ge(e,n),r=W.get(e);return`${r?`@${r} `:""}(${n}${t?` ${JSON.stringify(m(t,60))}`:""})`}function Ue(e){let n=e.localName;e.id&&(n+=`#${e.id}`);let t=typeof e.className=="string"?e.className.trim().split(/\s+/).filter(Boolean).slice(0,2):[];t.length&&(n+=`.${t.join(".")}`);let r=m(A(e,80),60);return`<${n}>${r?` ${JSON.stringify(r)}`:""}`}function Xe(e){let n=e.ownerDocument.defaultView;return{width:n.innerWidth,height:n.innerHeight}}function N(e){let n=e.getBoundingClientRect();return n.width<=0||n.height<=0||g(e).visibility!=="visible"?null:n}function re(e,n,t){let r=e.elementFromPoint(n,t);for(;r;){let o=U(r);if(!o)break;let i=o.elementFromPoint(n,t);if(!i||i===r)break;r=i}return r}function oe(e,n,t,r){let o=n?Ue(n):"nothing (the point is outside the page)";return new Error(`${u(e)} is covered by ${o} at (${Math.round(t)}, ${Math.round(r)}). Dismiss or act on the covering element (a consent banner, modal or overlay), then run snapshot again before reusing refs.`)}function ze(e){var Z;if(!N(e))throw new Error(`${u(e)} is not visible (no box on screen). Run snapshot again; it may be collapsed or hidden.`);try{e.scrollIntoView({block:"center",inline:"center",behavior:"instant"})}catch{}let n=e.getBoundingClientRect(),t=Xe(e),r=Math.max(n.left,0),o=Math.min(n.right,t.width),i=Math.max(n.top,0),s=Math.min(n.bottom,t.height);if(o<=r||s<=i)throw new Error(`${u(e)} is outside the viewport and could not be scrolled into it.`);let a=(r+o)/2,l=(i+s)/2,c=re(e.ownerDocument,a,l),p=c==null?void 0:c.closest("label");if(!c||!(Ve(e,c)||(p==null?void 0:p.control)===e))throw oe(e,c,a,l);let j=e.ownerDocument,B=a,V=l;for(;j!==document;){let b=(Z=j.defaultView)==null?void 0:Z.frameElement;if(!b)break;let q=b.getBoundingClientRect(),ee=g(b);B+=q.left+b.clientLeft+parseFloat(ee.paddingLeft||"0"),V+=q.top+b.clientTop+parseFloat(ee.paddingTop||"0");let te=re(b.ownerDocument,B,V);if(te!==b)throw oe(e,te,B,V);j=b.ownerDocument}return{x:a,y:l,hit:c}}function w(e,n,t,r,o={}){let i=e.ownerDocument.defaultView,s=n.startsWith("pointer")?i.PointerEvent??i.MouseEvent:i.MouseEvent,a=n.endsWith("enter")||n.endsWith("leave");return e.dispatchEvent(new s(n,{bubbles:!a,cancelable:!a,composed:!0,clientX:t,clientY:r,screenX:t,screenY:r,button:0,buttons:0,detail:0,pointerId:1,pointerType:"mouse",isPrimary:!0,...o}))}function Ye(e){var n,t;for(let r=e;r;r=X(r))if(r.matches(me)&&!T(r)){r.focus({preventScroll:!0});return}(t=(n=e.ownerDocument.activeElement)==null?void 0:n.blur)==null||t.call(n)}function ie(e,n,t,r){w(e,"pointerdown",n,t,{buttons:1}),w(e,"mousedown",n,t,{buttons:1,detail:r})&&Ye(e),w(e,"pointerup",n,t),w(e,"mouseup",n,t,{detail:r}),w(e,"click",n,t,{detail:r})}function Se(e,n){if(n!=="hover"&&T(e))throw new Error(`${u(e)} is disabled.`);let{x:t,y:r,hit:o}=ze(e);for(let i of["pointerover","pointerenter","mouseover","mouseenter","pointermove","mousemove"])w(o,i,t,r);n!=="hover"&&(ie(o,t,r,1),n==="dblclick"&&(ie(o,t,r,2),w(o,"dblclick",t,r,{detail:2})))}var Ge=new Set(["","text","search","email","url","tel","password","number","date","datetime-local","month","week","time","color"]);function K(e){let n=e.localName;if(n==="textarea")return"field";if(n==="input"){let t=e.type;if(Ge.has(t))return"field";let r=t==="checkbox"||t==="radio"?"use check/uncheck":t==="file"?"use upload":"it takes no text";throw new Error(`${u(e)} is an <input type=${t}>: ${r}.`)}if(n==="select")throw new Error(`${u(e)} is a <select>: use select with the option's value or label.`);if(e.isContentEditable)return"rich";throw new Error(`${u(e)} is not editable. Run snapshot and pick a textbox.`)}function se(e){let n=K(e);if(T(e))throw new Error(`${u(e)} is disabled.`);if(e.readOnly)throw new Error(`${u(e)} is read-only.`);return n}function G(e,n){var r;let t=(r=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),"value"))==null?void 0:r.set;t?t.call(e,n):e.value=n}function O(e,n,t){let r=e.ownerDocument.defaultView;e.dispatchEvent(new(r.InputEvent??r.Event)("input",{bubbles:!0,composed:!0,inputType:n,data:t}))}function _(e,n){e.dispatchEvent(new e.ownerDocument.defaultView.Event(n,{bubbles:!0}))}function Me(e){try{let n=e.selectionStart,t=e.selectionEnd;if(n!==null&&t!==null)return[n,t]}catch{}return[e.value.length,e.value.length]}function J(e,n){var t;if(K(e)==="rich"){let r=e.ownerDocument;(t=r.execCommand)!=null&&t.call(r,"insertText",!1,n)||e.append(n)}else{let r=e,[o,i]=Me(r);G(r,r.value.slice(0,o)+n+r.value.slice(i));try{r.setSelectionRange(o+n.length,o+n.length)}catch{}}O(e,"insertText",n)}function Qe(e,n){if(K(e)!=="field")return;let t=e,[r,o]=Me(t);r===o&&(n?o=Math.min(t.value.length,o+1):r=Math.max(0,r-1)),G(t,t.value.slice(0,r)+t.value.slice(o));try{t.setSelectionRange(r,r)}catch{}O(e,n?"deleteContentForward":"deleteContentBackward",null)}function ae(e){if(e.ownerDocument.activeElement===e)return;e.focus({preventScroll:!0});let n=e;if(e.localName==="input"||e.localName==="textarea")try{n.setSelectionRange(n.value.length,n.value.length)}catch{}}function ce(){var n;let e=document.activeElement;for(;;){let t=e?((n=U(e))==null?void 0:n.activeElement)??null:null;if(t){e=t;continue}if((e==null?void 0:e.localName)==="iframe"){let r=null;try{r=e.contentDocument}catch{}if(r!=null&&r.activeElement){e=r.activeElement;continue}}break}return e??document.body}var Ze={enter:"Enter",return:"Enter",tab:"Tab",escape:"Escape",esc:"Escape",space:" ",backspace:"Backspace",delete:"Delete",del:"Delete",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",arrowup:"ArrowUp",arrowdown:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},qe={control:"ctrlKey",ctrl:"ctrlKey",shift:"shiftKey",alt:"altKey",option:"altKey",meta:"metaKey",cmd:"metaKey",command:"metaKey"};function et(e){let n=e.split("+").map(i=>i.trim());n[n.length-1]===""&&n.length>1&&(n.pop(),n[n.length-1]="+");let t={};for(let i of n.slice(0,-1)){let s=qe[i.toLowerCase()];if(!s)throw new Error(`Unknown modifier ${JSON.stringify(i)} in ${JSON.stringify(e)}: use Control, Shift, Alt or Meta.`);t[s]=!0}let r=n[n.length-1];return{key:Ze[r.toLowerCase()]??(r.length===1?r:r[0].toUpperCase()+r.slice(1)),mods:t}}function tt(e){return/^[a-z]$/i.test(e)?`Key${e.toUpperCase()}`:/^\d$/.test(e)?`Digit${e}`:e===" "?"Space":e}function y(e,n,t,r){let o=e.ownerDocument.defaultView;return e.dispatchEvent(new o.KeyboardEvent(n,{key:t,code:tt(t),bubbles:!0,cancelable:!0,composed:!0,...r}))}function nt(e){return Array.from(e.querySelectorAll(me)).filter(n=>n.tabIndex>=0&&!T(n)&&!!N(n))}var rt=new Set(["button","link","tab","menuitem","option","clickable"]),ot=new Set(["button","checkbox","radio","switch","tab","menuitem","option","clickable"]);function le(e,n){return n.has(z(e,"",""))?(e.click(),!0):!1}function it(e,n){let{key:t,mods:r}=et(n),o=r.ctrlKey||r.metaKey||r.altKey,i=t.length===1&&!o;if(y(e,"keydown",t,r)&&!(t===" "&&e.localName!=="input"&&e.localName!=="textarea"&&le(e,ot)))if(i)y(e,"keypress",t,r),(e.localName==="input"||e.localName==="textarea"||e.isContentEditable)&&J(e,t);else if(t==="Enter")if(y(e,"keypress",t,r),e.localName==="textarea")J(e,`
|
|
3
|
+
`);else if(e.localName==="input"&&e.form){let s=e.form;typeof s.requestSubmit=="function"?s.requestSubmit():s.submit()}else le(e,rt);else if(t==="Tab"){let s=nt(e.ownerDocument),a=s.indexOf(e),l=s[(a+(r.shiftKey?-1:1)+s.length)%s.length];l==null||l.focus()}else t==="Backspace"||t==="Delete"?Qe(e,t==="Delete"):(r.ctrlKey||r.metaKey)&&t.toLowerCase()==="a"&&K(e)==="field"&&e.select();y(e,"keyup",t,r)}function st(e,n){if(e.localName!=="select")throw new Error(`${u(e)} is not a <select>. For a custom dropdown: click it open, snapshot, then click the option.`);if(T(e))throw new Error(`${u(e)} is disabled.`);let t=e,r=Array.from(t.options),o=n.trim(),i=r.find(s=>s.value===n)??r.find(s=>f(s.label||s.text)===o)??r.find(s=>f(s.label||s.text).toLowerCase()===o.toLowerCase());if(!i){let s=r.slice(0,L).map(a=>JSON.stringify(f(a.label||a.text))).join(", ");throw new Error(`${u(e)} has no option ${JSON.stringify(n)}. Options: ${s}${r.length>L?", \u2026":""}.`)}if(i.disabled)throw new Error(`Option ${JSON.stringify(f(i.label))} of ${u(e)} is disabled.`);return t.focus(),i.selected=!0,_(t,"input"),_(t,"change"),{value:i.value,label:f(i.label||i.text)}}function at(e,n){let t=F(e);if(t===void 0)throw new Error(`${u(e)} is not a checkbox, radio or switch.`);if(t===n)return{checked:n,changed:!1};if(!n&&e.localName==="input"&&e.type==="radio")throw new Error(`${u(e)} is a radio: it unchecks when another option in its group is checked.`);let r=e.localName==="input"&&!N(e)?Array.from(e.labels??[]).find(o=>N(o)):void 0;if(T(e))throw new Error(`${u(e)} is disabled.`);if(Se(r??e,"click"),F(e)!==n)throw new Error(`Clicking ${u(e)} did not ${n?"check":"uncheck"} it.`);return{checked:n,changed:!0}}function ue(e){if(e.localName==="input"||e.localName==="textarea")return e.value;if(e.localName==="select")return be(e)??"";let n=e.innerText;return(typeof n=="string"?n:e.textContent||"").trim()}function Le(e){let n=e.op;switch(n){case"click":case"dblclick":case"hover":{let t=h(e.selector);return Se(t,n),{[n==="hover"?"hovered":"clicked"]:u(t)}}case"fill":{let t=h(e.selector),r=se(t),o=e.text??"";return t.focus({preventScroll:!0}),r==="rich"?(t.textContent=o,O(t,"insertText",o)):(G(t,o),O(t,"insertText",o),_(t,"change")),{filled:u(t),value:r==="rich"?o:t.value}}case"type":{let t=e.selector?h(e.selector):ce();se(t),e.selector&&ae(t);for(let r of e.text??"")y(t,"keydown",r,{}),y(t,"keypress",r,{}),J(t,r),y(t,"keyup",r,{});return{typed:u(t),value:ue(t)}}case"press":{if(!e.key)throw new Error("key required: Enter, Tab, Escape, ArrowDown, Control+a \u2026");let t=e.selector?h(e.selector):ce();return e.selector&&ae(t),it(t,e.key),{pressed:e.key,on:u(t)}}case"focus":{let t=h(e.selector);return t.focus({preventScroll:!0}),{focused:u(t)}}case"select":return{selected:st(h(e.selector),e.value??e.text??"")};case"check":case"uncheck":return at(h(e.selector),n==="check");case"text":return{text:ue(h(e.selector))};case"attribute":{if(!e.attribute)throw new Error("attribute required: the attribute name to read");return{value:h(e.selector).getAttribute(e.attribute)}}case"scrollIntoView":{let t=h(e.selector);return t.scrollIntoView({block:"center",inline:"center",behavior:"instant"}),{scrolled:u(t)}}case"scroll":{let t=e.selector?h(e.selector):document.scrollingElement??document.documentElement;return t.scrollBy({left:e.dx??0,top:e.dy??0,behavior:"instant"}),{x:t.scrollLeft,y:t.scrollTop}}case"count":{if(!e.selector)throw new Error("selector required: a CSS selector to count");return{count:document.querySelectorAll(e.selector).length}}}throw new Error(`Unknown page action ${JSON.stringify(n)}.`)}function Ae(e){let n=e.state==="hidden";if(e.text){let o=document.body,i=o==null?void 0:o.innerText;return{met:(typeof i=="string"?i:(o==null?void 0:o.textContent)||"").includes(e.text)!==n}}let t=null;try{t=h(e.selector)}catch(o){if(e.selector&&he(e.selector)&&!n)throw o}return{met:(!!t&&!!N(t))!==n}}function Ie(e=0){var t;e>x&&(x=e),$e();let n=[];for(let r of Y(ve({}))){let o=r.el,i=N(o);if(!i)continue;let s=i.left,a=i.top;for(let l=o.ownerDocument;l!==document;){let c=(t=l.defaultView)==null?void 0:t.frameElement;if(!c)break;let p=c.getBoundingClientRect();s+=p.left+c.clientLeft,a+=p.top+c.clientTop,l=c.ownerDocument}s+i.width<=0||a+i.height<=0||s>=innerWidth||a>=innerHeight||n.push({ref:de(o),label:`${r.role}${r.name?` ${JSON.stringify(m(r.name,60))}`:""}`,x:s,y:a,w:i.width,h:i.height})}return{boxes:n,last:x,width:innerWidth,height:innerHeight}}var Q=6e4,ct=new Set(["input","select","textarea","svg","canvas","video","audio","map"]);function M(e,n){let t=e.nodeType===9?e.body:e;return t?$(t).map(r=>ft(r,n)).join(""):""}function S(e,n){return f(M(e,n))}function E(e){return e.trim()?`
|
|
4
|
+
|
|
5
|
+
${e.trim()}
|
|
6
|
+
|
|
7
|
+
`:""}function lt(e,n){let t=e.localName==="ol",r=Number(e.getAttribute("start"))||1,o=" ".repeat(n),i=[];for(let s of $(e)){if(s.nodeType!==1||k(s))continue;let a=M(s,n+1).replace(/\n{2,}/g,`
|
|
8
|
+
`).trim();if(!a)continue;let[l,...c]=a.split(`
|
|
9
|
+
`);i.push(`${o}${t?`${r++}.`:"-"} ${l.trim()}`,...c)}return`
|
|
10
|
+
|
|
11
|
+
${i.join(`
|
|
12
|
+
`)}
|
|
13
|
+
|
|
14
|
+
`}function ut(e,n){let t=Array.from(e.querySelectorAll("tr")).filter(i=>i.closest("table")===e&&!k(i)).map(i=>Array.from(i.children).filter(s=>(s.localName==="td"||s.localName==="th")&&!k(s)).map(s=>S(s,n).replace(/\|/g,"\\|")));if(!t.length)return"";let r=Math.max(...t.map(i=>i.length)),o=i=>`| ${[...i,...Array(r-i.length).fill("")].join(" | ")} |`;return E([o(t[0]),o(Array(r).fill("---")),...t.slice(1).map(o)].join(`
|
|
15
|
+
`))}function ft(e,n){if(e.nodeType===3)return(e.textContent||"").replace(/\s+/g," ");if(e.nodeType!==1)return"";let t=e;if(k(t)||ct.has(t.localName))return"";let r=t.localName,o=/^h([1-6])$/.exec(r);if(o){let s=S(t,n);return s?E(`${"#".repeat(Number(o[1]))} ${s}`):""}switch(r){case"p":return E(S(t,n));case"br":return`
|
|
16
|
+
`;case"hr":return E("---");case"ul":case"ol":return lt(t,n);case"table":return ut(t,n);case"pre":{let s=t.innerText,a=typeof s=="string"?s:t.textContent||"";return E(`\`\`\`
|
|
17
|
+
${a.replace(/\n+$/,"")}
|
|
18
|
+
\`\`\``)}case"code":{let s=f(t.textContent||"");return s?`\`${s}\``:""}case"blockquote":{let s=M(t,n).trim().replace(/\n{3,}/g,`
|
|
19
|
+
|
|
20
|
+
`);return s?E(s.split(`
|
|
21
|
+
`).map(a=>`> ${a}`).join(`
|
|
22
|
+
`)):""}case"strong":case"b":{let s=S(t,n);return s?`**${s}**`:""}case"em":case"i":{let s=S(t,n);return s?`_${s}_`:""}case"a":{let s=S(t,n),a=t.href;return s?a&&!a.startsWith("javascript:")?`[${s}](${a})`:s:""}case"img":{let s=f(t.getAttribute("alt")||"");if(!s)return"";let a=t.src;return a&&!a.startsWith("data:")?``:`![${s}]`}case"iframe":{let s=null;try{s=t.contentDocument}catch{}return s?E(M(s,n)):""}}let i=M(t,n);return D.has(g(t).display)?i:E(i)}function mt(e){let n=!1;return e.split(`
|
|
23
|
+
`).map(t=>{if(t.trimStart().startsWith("```"))return n=!n,t.trim();if(n)return t;let[,r,o]=/^(\s*)(.*)$/.exec(t),i=o.replace(/[ \t]+/g," ").trim();return/^(-|\d+\.) /.test(i)?r+i:i}).join(`
|
|
24
|
+
`).replace(/\n{3,}/g,`
|
|
25
|
+
|
|
26
|
+
`).trim()}function He(e){let n=[],t=[],r=!1;for(let o of e.split(`
|
|
27
|
+
`))o.startsWith("```")&&(r=!r),!r&&/^#{1,6} /.test(o)&&t.length&&(n.push(t.join(`
|
|
28
|
+
`).trim()),t=[]),t.push(o);return t.length&&n.push(t.join(`
|
|
29
|
+
`).trim()),n.filter(Boolean)}function Ce(e={}){var o;let n=mt(M(document.body??document.documentElement,0)),t=(o=e.filter)==null?void 0:o.trim().toLowerCase();e.outline?n=He(n).map(i=>i.split(`
|
|
30
|
+
`)[0]).filter(i=>/^#{1,6} /.test(i)&&(!t||i.toLowerCase().includes(t))).join(`
|
|
31
|
+
`):t&&(n=He(n).filter(i=>i.toLowerCase().includes(t)).join(`
|
|
32
|
+
|
|
33
|
+
`)),n||(n=t?`(no section mentions ${JSON.stringify(e.filter)})`:e.outline?"(no headings)":"(no text)");let r=n.length>Q;return r&&(n=`${n.slice(0,Q)}
|
|
34
|
+
|
|
35
|
+
\u2026 (truncated at ${Q} characters: narrow with filter, or skim with outline)`),{title:document.title,url:location.href,markdown:n,truncated:r}}function dt(e){switch(e.op){case"snapshot":return Ne(e);case"read":return Ce(e);case"boxes":return Ie(e.base);case"probe":return Ae(e);default:return Le(e)}}var ht=globalThis;ht.__hanzoPage??=e=>{try{return{ok:!0,...dt(e)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}};})();
|