@hanzo/browser-extension 1.9.49 → 1.9.53

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/content-script.js DELETED
@@ -1,550 +0,0 @@
1
- "use strict";(()=>{var te=Object.create;var R=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var se=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var ae=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of re(e))!oe.call(o,i)&&i!==t&&R(o,i,{get:()=>e[i],enumerable:!(n=ne(e,i))||n.enumerable});return o};var le=(o,e,t)=>(t=o!=null?te(ie(o)):{},ae(e||!o||!o.__esModule?R(t,"default",{value:o,enumerable:!0}):t,o));var G=se((K,V)=>{(function(o,e){if(typeof define=="function"&&define.amd)define("webextension-polyfill",["module"],e);else if(typeof K<"u")e(V);else{var t={exports:{}};e(t),o.browser=t.exports}})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:K,function(o){"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)o.exports=globalThis.browser;else{let e="The message port closed before a response was received.",t=n=>{let i={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(i).length===0)throw new Error("api-metadata.json has not been included in browser-polyfill");class d extends WeakMap{constructor(s,c=void 0){super(c),this.createItem=s}get(s){return this.has(s)||this.set(s,this.createItem(s)),super.get(s)}}let a=r=>r&&typeof r=="object"&&typeof r.then=="function",u=(r,s)=>(...c)=>{n.runtime.lastError?r.reject(new Error(n.runtime.lastError.message)):s.singleCallbackArg||c.length<=1&&s.singleCallbackArg!==!1?r.resolve(c[0]):r.resolve(c)},g=r=>r==1?"argument":"arguments",S=(r,s)=>function(m,...b){if(b.length<s.minArgs)throw new Error(`Expected at least ${s.minArgs} ${g(s.minArgs)} for ${r}(), got ${b.length}`);if(b.length>s.maxArgs)throw new Error(`Expected at most ${s.maxArgs} ${g(s.maxArgs)} for ${r}(), got ${b.length}`);return new Promise((v,l)=>{if(s.fallbackToNoCallback)try{m[r](...b,u({resolve:v,reject:l},s))}catch(h){console.warn(`${r} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `,h),m[r](...b),s.fallbackToNoCallback=!1,s.noCallback=!0,v()}else s.noCallback?(m[r](...b),v()):m[r](...b,u({resolve:v,reject:l},s))})},A=(r,s,c)=>new Proxy(s,{apply(m,b,v){return c.call(b,r,...v)}}),_=Function.call.bind(Object.prototype.hasOwnProperty),L=(r,s={},c={})=>{let m=Object.create(null),b={has(l,h){return h in r||h in m},get(l,h,T){if(h in m)return m[h];if(!(h in r))return;let w=r[h];if(typeof w=="function")if(typeof s[h]=="function")w=A(r,r[h],s[h]);else if(_(c,h)){let H=S(h,c[h]);w=A(r,r[h],H)}else w=w.bind(r);else if(typeof w=="object"&&w!==null&&(_(s,h)||_(c,h)))w=L(w,s[h],c[h]);else if(_(c,"*"))w=L(w,s[h],c["*"]);else return Object.defineProperty(m,h,{configurable:!0,enumerable:!0,get(){return r[h]},set(H){r[h]=H}}),w;return m[h]=w,w},set(l,h,T,w){return h in m?m[h]=T:r[h]=T,!0},defineProperty(l,h,T){return Reflect.defineProperty(m,h,T)},deleteProperty(l,h){return Reflect.deleteProperty(m,h)}},v=Object.create(r);return new Proxy(v,b)},p=r=>({addListener(s,c,...m){s.addListener(r.get(c),...m)},hasListener(s,c){return s.hasListener(r.get(c))},removeListener(s,c){s.removeListener(r.get(c))}}),f=new d(r=>typeof r!="function"?r:function(c){let m=L(c,{},{getContent:{minArgs:0,maxArgs:0}});r(m)}),x=new d(r=>typeof r!="function"?r:function(c,m,b){let v=!1,l,h=new Promise($=>{l=function(C){v=!0,$(C)}}),T;try{T=r(c,m,l)}catch($){T=Promise.reject($)}let w=T!==!0&&a(T);if(T!==!0&&!w&&!v)return!1;let H=$=>{$.then(C=>{b(C)},C=>{let W;C&&(C instanceof Error||typeof C.message=="string")?W=C.message:W="An unexpected error occurred",b({__mozWebExtensionPolyfillReject__:!0,message:W})}).catch(C=>{console.error("Failed to send onMessage rejected reply",C)})};return H(w?T:h),!0}),y=({reject:r,resolve:s},c)=>{n.runtime.lastError?n.runtime.lastError.message===e?s():r(new Error(n.runtime.lastError.message)):c&&c.__mozWebExtensionPolyfillReject__?r(new Error(c.message)):s(c)},z=(r,s,c,...m)=>{if(m.length<s.minArgs)throw new Error(`Expected at least ${s.minArgs} ${g(s.minArgs)} for ${r}(), got ${m.length}`);if(m.length>s.maxArgs)throw new Error(`Expected at most ${s.maxArgs} ${g(s.maxArgs)} for ${r}(), got ${m.length}`);return new Promise((b,v)=>{let l=y.bind(null,{resolve:b,reject:v});m.push(l),c.sendMessage(...m)})},E={devtools:{network:{onRequestFinished:p(f)}},runtime:{onMessage:p(x),onMessageExternal:p(x),sendMessage:z.bind(null,"sendMessage",{minArgs:1,maxArgs:3})},tabs:{sendMessage:z.bind(null,"sendMessage",{minArgs:2,maxArgs:3})}},k={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return i.privacy={network:{"*":k},services:{"*":k},websites:{"*":k}},L(n,E,i)};o.exports=t(chrome)}})});var he=le(G());var N="hanzo_shortcut_inspect",O={ctrl:!0,meta:!1,alt:!1,shift:!1,key:""};function F(o,e){return!(e.ctrl&&!o.ctrlKey||e.meta&&!o.metaKey||e.alt&&!o.altKey||e.shift&&!o.shiftKey||!e.ctrl&&o.ctrlKey||!e.meta&&o.metaKey||!e.alt&&o.altKey||!e.shift&&o.shiftKey||e.key&&(o.key||"").toLowerCase()!==e.key.toLowerCase())}async function X(o){try{let t=(await o.get([N]))[N];if(t&&typeof t=="object"&&typeof t.ctrl=="boolean"&&typeof t.alt=="boolean"&&typeof t.shift=="boolean"&&typeof t.meta=="boolean"&&typeof t.key=="string")return t}catch{}return{...O}}var j=class{constructor(){this.inspectShortcut={...O};this.loadShortcut(),this.watchShortcut(),this.setupClickHandler(),this.injectHelpers(),this.setupMessageHandlers()}async loadShortcut(){try{this.inspectShortcut=await X(chrome.storage.local)}catch{this.inspectShortcut={...O}}}watchShortcut(){try{chrome.storage.onChanged.addListener((e,t)=>{if(t!=="local")return;let n=e[N];n&&(n.newValue&&typeof n.newValue=="object"?this.inspectShortcut=n.newValue:this.inspectShortcut={...O})})}catch{}}setupClickHandler(){document.addEventListener("click",e=>{if(!F(e,this.inspectShortcut))return;e.preventDefault(),e.stopPropagation();let t=e.target,n=this.extractSourceLocation(t),i=this.getDOMPath(t),d={event:"elementSelected",framework:this.detectFramework(),domPath:i,source:n,fallbackId:t.getAttribute("data-hanzo-id")||void 0};chrome.runtime.sendMessage({action:"elementSelected",data:d})})}setupMessageHandlers(){chrome.runtime.onMessage.addListener((e,t,n)=>{var i;switch(e.action){case"ai.control.start":return P.show(e.task||"AI is controlling this page"),n({success:!0}),!0;case"ai.control.stop":return P.hide(),n({success:!0}),!0;case"ai.control.cursor":return P.moveCursor(e.x,e.y),n({success:!0}),!0;case"ai.control.highlight":return P.highlight(e.selector),n({success:!0}),!0;case"ai.control.status":return P.updateStatus(e.text),n({success:!0}),!0;case"page.overlay.toggle":return(e.side==="left"||e.side==="right")&&M.setSide(e.side),(e.mode==="push"||e.mode==="overlay")&&M.setMode(e.mode),(e.width==="compact"||e.width==="default"||e.width==="wide")&&M.setWidth(e.width),n({success:!0,open:M.toggle()}),!0;case"page.overlay.show":return(e.side==="left"||e.side==="right")&&M.setSide(e.side),(e.mode==="push"||e.mode==="overlay")&&M.setMode(e.mode),(e.width==="compact"||e.width==="default"||e.width==="wide")&&M.setWidth(e.width),M.show(),n({success:!0,open:!0}),!0;case"page.overlay.hide":return M.hide(),n({success:!0,open:!1}),!0;case"page.overlay.status":return n({success:!0,open:M.isOpen(),side:M.getSide(),mode:M.getMode()}),!0;case"page.overlay.setSide":return e.side==="left"||e.side==="right"?(M.setSide(e.side),n({success:!0,side:e.side})):n({success:!1,error:'side must be "left" or "right"'}),!0;case"page.overlay.setMode":return e.mode==="push"||e.mode==="overlay"?(M.setMode(e.mode),n({success:!0,mode:e.mode})):n({success:!1,error:'mode must be "push" or "overlay"'}),!0;case"page.overlay.setWidth":return e.width==="compact"||e.width==="default"||e.width==="wide"?(M.setWidth(e.width),n({success:!0,width:e.width})):n({success:!1,error:"width must be compact|default|wide"}),!0;case"page.overlay.setEnabled":return typeof e.enabled=="boolean"?(M.setEnabled(e.enabled),n({success:!0,enabled:e.enabled})):n({success:!1,error:"enabled must be boolean"}),!0;case"tool.picker.start":return Z.start(),n({success:!0}),!0;case"tool.picker.stop":return Z.stop(),n({success:!0}),!0;case"tool.pageinfo":return n({success:!0,info:ce()}),!0;case"tool.console.start":return Q.show(),n({success:!0}),!0;case"tool.console.hide":return Q.hide(),n({success:!0}),!0}return e.action==="getContent"?(n({content:((i=document.documentElement)==null?void 0:i.outerHTML)||""}),!0):e.action==="setContent"?(typeof e.content=="string"&&(document.open(),document.write(e.content),document.close()),n({success:!0}),!0):!1})}extractSourceLocation(e){switch(this.detectFramework()){case"react":return this.extractReactSource(e);case"vue":return this.extractVueSource(e);case"svelte":return this.extractSvelteSource(e);default:return}}extractReactSource(e){var d,a;if(!window.__REACT_DEVTOOLS_GLOBAL_HOOK__)return;let n=this.findReactFiber(e);if(!n)return;let i=n._debugSource||((d=n.pendingProps)==null?void 0:d.__source)||((a=n.memoizedProps)==null?void 0:a.__source);if(i&&i.fileName)return{file:i.fileName,line:i.lineNumber,column:i.columnNumber}}findReactFiber(e){let t=Object.keys(e).find(n=>n.startsWith("__reactInternalInstance$")||n.startsWith("__reactFiber$"));return t?e[t]:null}extractVueSource(e){var i,d;if(!window.__VUE_DEVTOOLS_GLOBAL_HOOK__)return;let n=e.__vueParentComponent;if(n||(n=e.__vue__),(i=n==null?void 0:n.type)!=null&&i.__file){let a={file:n.type.__file,line:1};return(d=n.vnode)!=null&&d.loc&&(a.line=n.vnode.loc.start.line,a.column=n.vnode.loc.start.column),a}}extractSvelteSource(e){var n,i;let t=e.__svelte_component;if((i=(n=t==null?void 0:t.$$)==null?void 0:n.ctx)!=null&&i.$$_location)return t.$$.ctx.$$_location}detectFramework(){return window.__REACT_DEVTOOLS_GLOBAL_HOOK__?"react":window.__VUE_DEVTOOLS_GLOBAL_HOOK__?"vue":window.__svelte?"svelte":null}getDOMPath(e){let t=[],n=e;for(;n&&n!==document.body;){let i=n.tagName.toLowerCase();n.id?i+=`#${n.id}`:n.className&&(i+=`.${n.className.split(" ").join(".")}`),t.unshift(i),n=n.parentElement}return t.join(" > ")}injectHelpers(){let e=document.createElement("style");e.textContent=`
2
- [data-hanzo-hover] {
3
- outline: 2px dashed #ff6b6b !important;
4
- outline-offset: 2px !important;
5
- }
6
- `,document.head.appendChild(e),document.addEventListener("mousemove",t=>{document.querySelectorAll("[data-hanzo-hover]").forEach(n=>{n.removeAttribute("data-hanzo-hover")}),F(t,this.inspectShortcut)&&t.target instanceof HTMLElement&&t.target.setAttribute("data-hanzo-hover","true")})}},P=(()=>{let o=null,e=null,t=null,n=null,i=null,d=[],a=!1,u="hanzo-ai-overlay",g="hanzo-ai-overlay-styles",S=["click","dblclick","mousedown","mouseup","contextmenu","pointerdown","pointerup","touchstart","touchmove","touchend","wheel","keydown","keyup","keypress"];function A(){if(document.getElementById(g))return;let r=document.createElement("style");r.id=g,r.textContent=`
7
- /* ---- Overlay backdrop ---- */
8
- #${u} {
9
- position: fixed;
10
- inset: 0;
11
- z-index: 2147483646;
12
- pointer-events: all;
13
- background:
14
- radial-gradient(90vw 90vh at 15% 8%, rgba(56, 189, 248, 0.10), transparent 55%),
15
- radial-gradient(65vw 65vh at 84% 82%, rgba(99, 102, 241, 0.10), transparent 60%),
16
- rgba(2, 4, 10, 0.42);
17
- backdrop-filter: blur(1.5px);
18
- opacity: 0;
19
- transition: opacity 300ms ease;
20
- }
21
- #${u}.hanzo-visible {
22
- opacity: 1;
23
- }
24
-
25
- /* ---- Pulsing cyan glow cursor ---- */
26
- .hanzo-ai-cursor {
27
- position: fixed;
28
- width: 24px;
29
- height: 24px;
30
- z-index: 2147483647;
31
- pointer-events: none;
32
- border-radius: 50%;
33
- border: 2px solid rgba(6, 182, 212, 0.95);
34
- box-shadow:
35
- 0 0 8px 2px rgba(6, 182, 212, 0.45),
36
- 0 0 24px 6px rgba(6, 182, 212, 0.18);
37
- transform: translate(-50%, -50%);
38
- transition: left 0.18s ease-out, top 0.18s ease-out;
39
- animation: hanzo-cursor-pulse 1.6s ease-in-out infinite;
40
- opacity: 0;
41
- }
42
- .hanzo-ai-cursor.hanzo-visible {
43
- opacity: 1;
44
- transition: left 0.18s ease-out, top 0.18s ease-out, opacity 300ms ease;
45
- }
46
- @keyframes hanzo-cursor-pulse {
47
- 0%, 100% {
48
- box-shadow:
49
- 0 0 8px 2px rgba(6, 182, 212, 0.45),
50
- 0 0 24px 6px rgba(6, 182, 212, 0.18);
51
- }
52
- 50% {
53
- box-shadow:
54
- 0 0 14px 4px rgba(6, 182, 212, 0.65),
55
- 0 0 36px 10px rgba(6, 182, 212, 0.28);
56
- }
57
- }
58
-
59
- /* ---- Cursor trail ---- */
60
- .hanzo-cursor-trail {
61
- position: fixed;
62
- width: 6px;
63
- height: 6px;
64
- border-radius: 50%;
65
- background: rgba(6, 182, 212, 0.7);
66
- z-index: 2147483646;
67
- pointer-events: none;
68
- transform: translate(-50%, -50%);
69
- animation: hanzo-trail-fade 0.4s ease-out forwards;
70
- }
71
- @keyframes hanzo-trail-fade {
72
- from { opacity: 0.7; transform: translate(-50%, -50%) scale(1); }
73
- to { opacity: 0; transform: translate(-50%, -50%) scale(0.15); }
74
- }
75
-
76
- /* ---- Status banner (top center pill) ---- */
77
- .hanzo-ai-status {
78
- position: fixed;
79
- top: 16px;
80
- left: 50%;
81
- transform: translateX(-50%);
82
- z-index: 2147483647;
83
- display: flex;
84
- align-items: center;
85
- gap: 10px;
86
- max-width: 90vw;
87
- padding: 10px 14px;
88
- border-radius: 16px;
89
- background: linear-gradient(135deg, rgba(8, 12, 20, 0.94), rgba(10, 16, 24, 0.96));
90
- border: 1px solid rgba(56, 189, 248, 0.26);
91
- color: #f3f4f6;
92
- font: 13px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
93
- box-shadow:
94
- 0 10px 36px rgba(0, 0, 0, 0.46),
95
- inset 0 1px 0 rgba(255, 255, 255, 0.08);
96
- opacity: 0;
97
- transition: opacity 300ms ease;
98
- overflow: hidden;
99
- }
100
- .hanzo-ai-status::before {
101
- content: '';
102
- position: absolute;
103
- inset: -2px auto -2px -20%;
104
- width: 40%;
105
- background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16), transparent);
106
- transform: skewX(-18deg);
107
- animation: hanzo-status-sheen 3.6s ease-in-out infinite;
108
- pointer-events: none;
109
- }
110
- @keyframes hanzo-status-sheen {
111
- 0%, 68% { left: -30%; opacity: 0; }
112
- 72% { opacity: 0.4; }
113
- 100% { left: 130%; opacity: 0; }
114
- }
115
- .hanzo-ai-status > * {
116
- position: relative;
117
- }
118
- .hanzo-ai-status.hanzo-visible {
119
- opacity: 1;
120
- }
121
-
122
- .hanzo-ai-status .hanzo-brand-bubble {
123
- display: inline-flex;
124
- align-items: center;
125
- justify-content: center;
126
- height: 20px;
127
- min-width: 30px;
128
- padding: 0 8px;
129
- border-radius: 9999px;
130
- font-size: 10px;
131
- letter-spacing: 0.25px;
132
- font-weight: 700;
133
- text-transform: uppercase;
134
- color: #e0f2fe;
135
- background: linear-gradient(180deg, rgba(14, 116, 144, 0.95), rgba(15, 23, 42, 0.95));
136
- border: 1px solid rgba(56, 189, 248, 0.35);
137
- }
138
-
139
- .hanzo-ai-status .hanzo-pulse-dot {
140
- width: 8px;
141
- height: 8px;
142
- border-radius: 9999px;
143
- background: #06b6d4;
144
- animation: hanzo-dot-pulse 1.4s ease-in-out infinite;
145
- }
146
- @keyframes hanzo-dot-pulse {
147
- 0%, 100% { opacity: 1; }
148
- 50% { opacity: 0.4; }
149
- }
150
-
151
- .hanzo-ai-status .hanzo-label {
152
- max-width: 46vw;
153
- overflow: hidden;
154
- text-overflow: ellipsis;
155
- white-space: nowrap;
156
- }
157
-
158
- .hanzo-ai-status .hanzo-dots::after {
159
- content: '';
160
- animation: hanzo-animated-dots 1.5s steps(4) infinite;
161
- }
162
- @keyframes hanzo-animated-dots {
163
- 0% { content: ''; }
164
- 25% { content: '.'; }
165
- 50% { content: '..'; }
166
- 75% { content: '...'; }
167
- }
168
-
169
- .hanzo-ai-status .hanzo-stop-btn {
170
- border: 1px solid rgba(255, 255, 255, 0.24);
171
- background: rgba(0, 0, 0, 0.18);
172
- color: #f8fafc;
173
- border-radius: 10px;
174
- padding: 4px 12px;
175
- font-size: 12px;
176
- cursor: pointer;
177
- transition: background 0.15s, border-color 0.15s;
178
- }
179
- .hanzo-ai-status .hanzo-stop-btn:hover {
180
- background: rgba(220, 38, 38, 0.28);
181
- border-color: rgba(248, 113, 113, 0.6);
182
- }
183
-
184
- /* ---- "Take Back Control" button (bottom-right) ---- */
185
- .hanzo-ai-cancel {
186
- position: fixed;
187
- bottom: 24px;
188
- right: 24px;
189
- z-index: 2147483647;
190
- padding: 12px 24px;
191
- border-radius: 10px;
192
- border: 1px solid rgba(255, 255, 255, 0.2);
193
- background: rgba(15, 18, 24, 0.95);
194
- color: #f3f4f6;
195
- font: 600 14px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
196
- cursor: pointer;
197
- box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
198
- pointer-events: auto;
199
- opacity: 0;
200
- transition: opacity 300ms ease, background 0.15s;
201
- }
202
- .hanzo-ai-cancel.hanzo-visible {
203
- opacity: 1;
204
- }
205
- .hanzo-ai-cancel:hover {
206
- background: rgba(220, 38, 38, 0.35);
207
- border-color: rgba(220, 38, 38, 0.5);
208
- }
209
-
210
- /* ---- Element highlight ---- */
211
- .hanzo-ai-highlight {
212
- position: fixed;
213
- z-index: 2147483647;
214
- pointer-events: none;
215
- border: 2px solid rgba(6, 182, 212, 0.85);
216
- border-radius: 6px;
217
- box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
218
- transition: left 0.15s, top 0.15s, width 0.15s, height 0.15s;
219
- }
220
- `,document.head.appendChild(r)}function _(r){return r instanceof Node?!!(o!=null&&o.contains(r)||t!=null&&t.contains(r)||n!=null&&n.contains(r)||e!=null&&e.contains(r)||i!=null&&i.contains(r)):!1}function L(r){if(a){if(r instanceof KeyboardEvent&&r.key==="Escape"){chrome.runtime.sendMessage({action:"ai.control.cancel"}),x();return}_(r.target)||(r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation())}}function p(r){if(a!==r){a=r;for(let s of S)r?document.addEventListener(s,L,!0):document.removeEventListener(s,L,!0)}}function f(r){var s;o&&x(),A(),p(!0),o=document.createElement("div"),o.id=u,document.body.appendChild(o),e=document.createElement("div"),e.className="hanzo-ai-cursor",e.style.left=`${window.innerWidth/2}px`,e.style.top=`${window.innerHeight/2}px`,document.body.appendChild(e),t=document.createElement("div"),t.className="hanzo-ai-status",t.innerHTML=`
221
- <span class="hanzo-brand-bubble">AI</span>
222
- <div class="hanzo-pulse-dot"></div>
223
- <span class="hanzo-label">${k(r||"Hanzo AI is controlling this tab")}</span><span class="hanzo-dots"></span>
224
- <button class="hanzo-stop-btn">Stop</button>
225
- `,document.body.appendChild(t),(s=t.querySelector(".hanzo-stop-btn"))==null||s.addEventListener("click",()=>{chrome.runtime.sendMessage({action:"ai.control.cancel"}),x()}),n=document.createElement("button"),n.className="hanzo-ai-cancel",n.textContent="Take Back Control",n.addEventListener("click",()=>{chrome.runtime.sendMessage({action:"ai.control.cancel"}),x()}),document.body.appendChild(n),requestAnimationFrame(()=>{o==null||o.classList.add("hanzo-visible"),e==null||e.classList.add("hanzo-visible"),t==null||t.classList.add("hanzo-visible"),n==null||n.classList.add("hanzo-visible")})}function x(){o==null||o.classList.remove("hanzo-visible"),e==null||e.classList.remove("hanzo-visible"),t==null||t.classList.remove("hanzo-visible"),n==null||n.classList.remove("hanzo-visible");let r={overlay:o,cursor:e,statusEl:t,cancelBtn:n,highlightEl:i},s=[...d];setTimeout(()=>{var c,m,b,v,l;(c=r.overlay)==null||c.remove(),(m=r.cursor)==null||m.remove(),(b=r.statusEl)==null||b.remove(),(v=r.cancelBtn)==null||v.remove(),(l=r.highlightEl)==null||l.remove();for(let h of s)h.remove()},320),p(!1),o=null,e=null,t=null,n=null,i=null,d=[]}function y(r,s){var v;if(!e)return;let c=Math.max(0,Math.min(window.innerWidth,Number.isFinite(r)?r:0)),m=Math.max(0,Math.min(window.innerHeight,Number.isFinite(s)?s:0)),b=document.createElement("div");for(b.className="hanzo-cursor-trail",b.style.left=`${c}px`,b.style.top=`${m}px`,document.body.appendChild(b),d.push(b),setTimeout(()=>{b.remove(),d=d.filter(l=>l!==b)},400);d.length>10;)(v=d.shift())==null||v.remove();e.style.left=`${c}px`,e.style.top=`${m}px`}function z(r){if(i==null||i.remove(),i=null,!(!r||typeof r!="string"))try{let s=document.querySelector(r);if(!s)return;let c=s.getBoundingClientRect();if(c.width===0&&c.height===0)return;i=document.createElement("div"),i.className="hanzo-ai-highlight",i.style.left=`${Math.max(0,c.left-4)}px`,i.style.top=`${Math.max(0,c.top-4)}px`,i.style.width=`${c.width+8}px`,i.style.height=`${c.height+8}px`,document.body.appendChild(i)}catch{}}function E(r){if(!t)return;let s=t.querySelector(".hanzo-label");s&&(s.textContent=r||"Hanzo AI is controlling this tab")}function k(r){let s=document.createElement("div");return s.textContent=r,s.innerHTML}return{show:f,hide:x,moveCursor:y,highlight:z,updateStatus:E}})(),Y={compact:320,default:420,wide:560},U=class{constructor(){this.mounted=!1;this.enabled=!1;this.open=!1;this.side="right";this.mode="overlay";this.width="default";this.sending=!1;this.watchMode=!1;this.editMode=!1;this.modelsLoaded=!1;this.messages=[];this.selectedContext=null;this.hoveredElement=null;this.editingElement=null;this.root=null;this.launcher=null;this.panel=null;this.messagesEl=null;this.inputEl=null;this.sendBtn=null;this.modelEl=null;this.contextEl=null;this.watchBtn=null;this.editBtn=null;this.statusEl=null;this.highlightBox=null;this.injectStyles(),this.mount(),this.bindGlobalEvents(),this.restorePrefs()}restorePrefs(){var e,t;try{let n=(t=(e=typeof browser<"u"?browser:chrome)==null?void 0:e.storage)==null?void 0:t.sync;if(!(n!=null&&n.get))return;let i=n.get(["overlaySide","overlayMode","overlayWidth"]),d=a=>{var u,g;((a==null?void 0:a.overlaySide)==="left"||(a==null?void 0:a.overlaySide)==="right")&&(this.side=a.overlaySide,(u=this.root)==null||u.setAttribute("data-side",this.side)),((a==null?void 0:a.overlayMode)==="push"||(a==null?void 0:a.overlayMode)==="overlay")&&(this.mode=a.overlayMode,(g=this.root)==null||g.setAttribute("data-mode",this.mode)),((a==null?void 0:a.overlayWidth)==="compact"||(a==null?void 0:a.overlayWidth)==="default"||(a==null?void 0:a.overlayWidth)==="wide")&&(this.width=a.overlayWidth,this.applyWidth()),this.applyPushIfOpen()};i&&typeof i.then=="function"?i.then(d).catch(()=>{}):n.get(["overlaySide","overlayMode","overlayWidth"],d)}catch{}}applyWidth(){let e=Y[this.width]??Y.default;this.root&&(this.root.style.setProperty("--hanzo-overlay-width",`${e}px`),this.root.style.width=`min(${e}px, 100vw)`),document.documentElement.style.setProperty("--hanzo-overlay-width",`${e}px`)}applyPushIfOpen(){let e=document.documentElement;e.classList.remove("hanzo-overlay-push","hanzo-overlay-push-left","hanzo-overlay-push-right"),this.open&&this.enabled&&this.mode==="push"&&e.classList.add("hanzo-overlay-push",`hanzo-overlay-push-${this.side}`)}toggle(){return!this.enabled||!this.open?(this.show(),!0):(this.hide(),!1)}isOpen(){return this.open}getSide(){return this.side}getMode(){return this.mode}setSide(e){var t;this.side=e,(t=this.root)==null||t.setAttribute("data-side",e),this.applyPushIfOpen(),this.persist({overlaySide:e})}setMode(e){var t;this.mode=e,(t=this.root)==null||t.setAttribute("data-mode",e),this.applyPushIfOpen(),this.persist({overlayMode:e})}setWidth(e){this.width=e,this.applyWidth(),this.persist({overlayWidth:e})}setEnabled(e){var t;this.enabled=e,(t=this.root)==null||t.setAttribute("data-enabled",e?"true":"false"),e||this.hide(),this.persist({overlayEnabled:e})}persist(e){var t,n,i;try{let d=(n=(t=typeof browser<"u"?browser:chrome)==null?void 0:t.storage)==null?void 0:n.sync;(i=d==null?void 0:d.set)==null||i.call(d,e)}catch{}}show(){var e,t;this.ensureMounted(),this.enabled=!0,this.open=!0,(e=this.root)==null||e.setAttribute("data-enabled","true"),(t=this.root)==null||t.setAttribute("data-open","true"),this.applyPushIfOpen(),this.loadModels(),this.focusInput()}hide(){var e;this.open=!1,(e=this.root)==null||e.setAttribute("data-open","false"),this.applyPushIfOpen(),this.updateStatus(""),this.clearHighlight(),this.setWatchMode(!1),this.setEditMode(!1)}ensureMounted(){this.mounted||this.mount()}injectStyles(){if(document.getElementById("hanzo-page-overlay-styles"))return;let e=document.createElement("style");e.id="hanzo-page-overlay-styles",e.textContent=`
226
- /* Edge-pinned sidebar panel \u2014 no FAB, opened from extension popup.
227
- Hanzo brand: monochrome (white primary, neutral surfaces). No blue. */
228
- #hanzo-page-overlay-root {
229
- position: fixed;
230
- top: 0;
231
- bottom: 0;
232
- right: 0;
233
- width: min(var(--hanzo-overlay-width, 420px), 100vw);
234
- z-index: 2147483645;
235
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
236
- pointer-events: none;
237
- }
238
-
239
- #hanzo-page-overlay-root[data-side="left"] {
240
- right: auto;
241
- left: 0;
242
- }
243
-
244
- #hanzo-page-overlay-root * {
245
- box-sizing: border-box;
246
- }
247
-
248
- /* Push mode: when the user pins the panel as a dock, html shifts so
249
- page content reflows beside it instead of being covered. Applied to
250
- <html> from setMode('push') + open. */
251
- html.hanzo-overlay-push.hanzo-overlay-push-right {
252
- margin-right: var(--hanzo-overlay-width, 420px) !important;
253
- transition: margin-right 0.18s ease;
254
- }
255
- html.hanzo-overlay-push.hanzo-overlay-push-left {
256
- margin-left: var(--hanzo-overlay-width, 420px) !important;
257
- transition: margin-left 0.18s ease;
258
- }
259
-
260
- .hanzo-page-panel {
261
- width: 100%;
262
- height: 100%;
263
- border-left: 1px solid rgba(255, 255, 255, 0.16);
264
- background: linear-gradient(180deg, rgba(10, 10, 11, 0.97), rgba(7, 7, 8, 0.97));
265
- color: #f5f5f5;
266
- overflow: hidden;
267
- box-shadow: -22px 0 48px rgba(0, 0, 0, 0.45);
268
- transform: translateX(100%);
269
- opacity: 0;
270
- pointer-events: none;
271
- display: flex;
272
- flex-direction: column;
273
- min-height: 0;
274
- transition: transform 0.18s ease, opacity 0.18s ease;
275
- }
276
-
277
- #hanzo-page-overlay-root[data-side="left"] .hanzo-page-panel {
278
- border-left: none;
279
- border-right: 1px solid rgba(255, 255, 255, 0.16);
280
- box-shadow: 22px 0 48px rgba(0, 0, 0, 0.45);
281
- transform: translateX(-100%);
282
- }
283
-
284
- #hanzo-page-overlay-root[data-open="true"] .hanzo-page-panel {
285
- transform: translateX(0);
286
- opacity: 1;
287
- pointer-events: auto;
288
- }
289
-
290
- .hanzo-page-header {
291
- display: flex;
292
- align-items: center;
293
- justify-content: space-between;
294
- padding: 12px 14px;
295
- border-bottom: 1px solid rgba(255, 255, 255, 0.10);
296
- background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
297
- flex-shrink: 0;
298
- }
299
-
300
- .hanzo-page-brand {
301
- font-weight: 700;
302
- letter-spacing: 0.2px;
303
- font-size: 13px;
304
- color: #f5f5f5;
305
- }
306
-
307
- .hanzo-page-header-actions {
308
- display: inline-flex;
309
- align-items: center;
310
- gap: 6px;
311
- }
312
-
313
- .hanzo-chip-btn {
314
- border: 1px solid rgba(255, 255, 255, 0.2);
315
- border-radius: 9999px;
316
- padding: 4px 10px;
317
- background: transparent;
318
- color: rgba(245, 245, 245, 0.85);
319
- cursor: pointer;
320
- font-size: 11px;
321
- transition: background 0.15s, color 0.15s, border-color 0.15s;
322
- }
323
-
324
- .hanzo-chip-btn:hover {
325
- background: rgba(255, 255, 255, 0.06);
326
- color: #fff;
327
- }
328
-
329
- .hanzo-chip-btn[data-active="true"] {
330
- border-color: rgba(255, 255, 255, 0.7);
331
- background: rgba(255, 255, 255, 0.10);
332
- color: #fff;
333
- }
334
-
335
- .hanzo-icon-btn {
336
- width: 28px;
337
- height: 28px;
338
- border-radius: 8px;
339
- border: 1px solid rgba(255, 255, 255, 0.18);
340
- background: transparent;
341
- color: #f5f5f5;
342
- cursor: pointer;
343
- font-size: 14px;
344
- display: inline-flex;
345
- align-items: center;
346
- justify-content: center;
347
- padding: 0;
348
- transition: background 0.15s, border-color 0.15s;
349
- }
350
-
351
- .hanzo-icon-btn:hover {
352
- background: rgba(255, 255, 255, 0.06);
353
- }
354
-
355
- .hanzo-icon-btn[data-active="true"] {
356
- background: rgba(255, 255, 255, 0.12);
357
- border-color: rgba(255, 255, 255, 0.5);
358
- }
359
-
360
- .hanzo-icon-btn svg {
361
- width: 14px;
362
- height: 14px;
363
- }
364
-
365
- .hanzo-page-meta {
366
- padding: 10px 14px 6px 14px;
367
- display: grid;
368
- grid-template-columns: 1fr auto;
369
- gap: 8px;
370
- align-items: center;
371
- flex-shrink: 0;
372
- }
373
-
374
- .hanzo-page-context {
375
- font-size: 11px;
376
- color: rgba(245, 245, 245, 0.65);
377
- overflow: hidden;
378
- text-overflow: ellipsis;
379
- white-space: nowrap;
380
- }
381
-
382
- .hanzo-page-status {
383
- font-size: 11px;
384
- color: rgba(245, 245, 245, 0.55);
385
- }
386
-
387
- .hanzo-model-row {
388
- padding: 0 14px 8px 14px;
389
- flex-shrink: 0;
390
- }
391
-
392
- .hanzo-model-row select {
393
- width: 100%;
394
- border-radius: 8px;
395
- border: 1px solid rgba(255, 255, 255, 0.16);
396
- background: rgba(255, 255, 255, 0.03);
397
- color: #f5f5f5;
398
- padding: 7px 9px;
399
- font-size: 12px;
400
- }
401
-
402
- /* The chat scroller: takes ALL remaining vertical space so the
403
- composer below stays sticky against the bottom of the panel. */
404
- .hanzo-page-messages {
405
- flex: 1 1 auto;
406
- min-height: 0;
407
- overflow-y: auto;
408
- padding: 8px 14px 12px 14px;
409
- display: flex;
410
- flex-direction: column;
411
- gap: 8px;
412
- }
413
-
414
- .hanzo-page-msg {
415
- padding: 9px 10px;
416
- border-radius: 10px;
417
- font-size: 12px;
418
- line-height: 1.45;
419
- word-break: break-word;
420
- }
421
-
422
- .hanzo-page-msg.user {
423
- align-self: flex-end;
424
- max-width: 88%;
425
- background: rgba(255, 255, 255, 0.10);
426
- border: 1px solid rgba(255, 255, 255, 0.18);
427
- }
428
-
429
- .hanzo-page-msg.assistant {
430
- align-self: flex-start;
431
- max-width: 92%;
432
- background: rgba(255, 255, 255, 0.04);
433
- border: 1px solid rgba(255, 255, 255, 0.10);
434
- }
435
-
436
- /* Composer pinned to bottom of the panel. flex-shrink: 0 prevents
437
- it from collapsing when the messages scroller grows. */
438
- .hanzo-page-composer {
439
- border-top: 1px solid rgba(255, 255, 255, 0.10);
440
- padding: 10px 12px;
441
- display: flex;
442
- gap: 8px;
443
- align-items: flex-end;
444
- background: rgba(0, 0, 0, 0.35);
445
- flex-shrink: 0;
446
- }
447
-
448
- .hanzo-page-composer textarea {
449
- flex: 1;
450
- min-height: 38px;
451
- max-height: 110px;
452
- resize: none;
453
- border-radius: 10px;
454
- border: 1px solid rgba(255, 255, 255, 0.17);
455
- background: rgba(255, 255, 255, 0.03);
456
- color: #f5f5f5;
457
- padding: 9px 11px;
458
- font-size: 12px;
459
- }
460
-
461
- /* Primary action: WHITE per @hanzo/brand monochrome guidelines. */
462
- .hanzo-page-composer button {
463
- min-width: 68px;
464
- height: 38px;
465
- border-radius: 10px;
466
- border: 1px solid #ffffff;
467
- background: #ffffff;
468
- color: #0a0a0b;
469
- font-weight: 600;
470
- font-size: 12px;
471
- cursor: pointer;
472
- transition: background 0.12s, transform 0.08s;
473
- }
474
-
475
- .hanzo-page-composer button:hover:not(:disabled) {
476
- background: #f5f5f5;
477
- }
478
-
479
- .hanzo-page-composer button:active:not(:disabled) {
480
- transform: translateY(1px);
481
- }
482
-
483
- .hanzo-page-composer button:disabled {
484
- opacity: 0.55;
485
- cursor: default;
486
- }
487
-
488
- .hanzo-page-highlight {
489
- position: fixed;
490
- z-index: 2147483644;
491
- pointer-events: none;
492
- border: 2px solid rgba(255, 255, 255, 0.95);
493
- border-radius: 6px;
494
- box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
495
- }
496
-
497
- [data-hanzo-inline-editing="true"] {
498
- outline: 2px solid rgba(255, 255, 255, 0.92) !important;
499
- outline-offset: 2px !important;
500
- }
501
- `,document.head.appendChild(e)}mount(){var t,n,i,d,a,u;if(this.mounted)return;this.root=document.createElement("div"),this.root.id="hanzo-page-overlay-root",this.root.setAttribute("data-open","false"),this.root.setAttribute("data-enabled","false"),this.root.setAttribute("data-side",this.side),this.root.setAttribute("data-mode",this.mode),this.applyWidth(),this.root.innerHTML=`
502
- <div class="hanzo-page-panel" role="dialog" aria-label="Hanzo Page Assistant">
503
- <div class="hanzo-page-header">
504
- <div class="hanzo-page-brand">Hanzo</div>
505
- <div class="hanzo-page-header-actions">
506
- <button class="hanzo-chip-btn" data-role="watch" data-active="false" title="Watch elements on hover">Watch</button>
507
- <button class="hanzo-chip-btn" data-role="edit" data-active="false" title="Click any element to edit text">Edit</button>
508
- <button class="hanzo-icon-btn" data-role="pin-mode" title="Toggle: pin (push content) vs overlay (float over page)">
509
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
510
- <path d="M9 4v16M3 4h12a4 4 0 0 1 4 4v8a4 4 0 0 1-4 4H3z"/>
511
- </svg>
512
- </button>
513
- <button class="hanzo-icon-btn" data-role="close" title="Hide overlay">\xD7</button>
514
- </div>
515
- </div>
516
- <div class="hanzo-page-meta">
517
- <div class="hanzo-page-context">Use Watch to inspect page elements.</div>
518
- <span class="hanzo-page-status"></span>
519
- </div>
520
- <div class="hanzo-model-row">
521
- <select data-role="model">
522
- <option value="claude-sonnet-4-20250514">Claude Sonnet 4</option>
523
- <option value="claude-opus-4-20250514">Claude Opus 4</option>
524
- <option value="gpt-4o">GPT-4o</option>
525
- <option value="zen-coder-flash">Zen Coder Flash</option>
526
- <option value="zen-max">Zen Max</option>
527
- </select>
528
- </div>
529
- <div class="hanzo-page-messages" data-role="messages">
530
- <div class="hanzo-page-msg assistant">Ask about this page, inspect any element, or turn on Edit mode to change text in-place.</div>
531
- </div>
532
- <div class="hanzo-page-composer">
533
- <textarea data-role="input" rows="1" placeholder="Ask about this page..."></textarea>
534
- <button data-role="send" type="button">Ask</button>
535
- </div>
536
- </div>
537
- `,this.panel=this.root.querySelector(".hanzo-page-panel"),this.launcher=null,this.messagesEl=this.root.querySelector('[data-role="messages"]'),this.inputEl=this.root.querySelector('[data-role="input"]'),this.sendBtn=this.root.querySelector('[data-role="send"]'),this.modelEl=this.root.querySelector('[data-role="model"]'),this.contextEl=this.root.querySelector(".hanzo-page-context"),this.watchBtn=this.root.querySelector('[data-role="watch"]'),this.editBtn=this.root.querySelector('[data-role="edit"]'),this.statusEl=this.root.querySelector(".hanzo-page-status"),(t=this.root.querySelector('[data-role="close"]'))==null||t.addEventListener("click",()=>this.hide());let e=this.root.querySelector('[data-role="pin-mode"]');e==null||e.setAttribute("data-active",this.mode==="push"?"true":"false"),e==null||e.addEventListener("click",()=>{let g=this.mode==="push"?"overlay":"push";this.setMode(g),e.setAttribute("data-active",g==="push"?"true":"false")}),(n=this.watchBtn)==null||n.addEventListener("click",()=>this.setWatchMode(!this.watchMode)),(i=this.editBtn)==null||i.addEventListener("click",()=>this.setEditMode(!this.editMode)),(d=this.sendBtn)==null||d.addEventListener("click",()=>this.askPageQuestion()),(a=this.inputEl)==null||a.addEventListener("keydown",g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),this.askPageQuestion())}),(u=this.inputEl)==null||u.addEventListener("input",()=>{this.inputEl&&(this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,110)}px`)}),document.documentElement.appendChild(this.root),this.mounted=!0}bindGlobalEvents(){document.addEventListener("mousemove",e=>this.onMouseMove(e),!0),document.addEventListener("click",e=>this.onDocumentClick(e),!0),document.addEventListener("keydown",e=>this.onKeyDown(e),!0)}onMouseMove(e){if(!this.watchMode)return;let t=this.getPageTarget(e.target);t&&(this.hoveredElement=t,this.showHighlight(t),this.selectedContext||this.contextEl&&(this.contextEl.textContent=this.getElementSummary(t)))}onDocumentClick(e){if(!this.watchMode&&!this.editMode)return;let t=this.getPageTarget(e.target);t&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.watchMode&&(this.selectedContext=this.captureElementContext(t),this.contextEl&&(this.contextEl.textContent=this.getElementSummary(t)),this.updateStatus("Element selected")),this.editMode&&(this.enableInlineEdit(t),this.updateStatus("Editing element")))}onKeyDown(e){if(e.key==="Escape"){if(this.editingElement){this.disableInlineEdit(this.editingElement,!1),this.updateStatus("Edit canceled"),e.preventDefault();return}this.open&&(this.hide(),e.preventDefault())}}getPageTarget(e){var t;return!(e instanceof HTMLElement)||(t=this.root)!=null&&t.contains(e)||!e.isConnected||e.tagName.toLowerCase()==="html"||e.tagName.toLowerCase()==="body"?null:e}setWatchMode(e){var t;this.watchMode=e,e&&this.setEditMode(!1),(t=this.watchBtn)==null||t.setAttribute("data-active",e?"true":"false"),e?this.updateStatus("Watch mode on"):(this.hoveredElement=null,this.clearHighlight(),!this.selectedContext&&this.contextEl&&(this.contextEl.textContent="Use Watch to inspect page elements."))}setEditMode(e){var t;this.editMode=e,e&&this.setWatchMode(!1),(t=this.editBtn)==null||t.setAttribute("data-active",e?"true":"false"),!e&&this.editingElement?this.disableInlineEdit(this.editingElement,!0):e&&this.updateStatus("Edit mode on")}enableInlineEdit(e){if(this.editingElement&&this.editingElement!==e&&this.disableInlineEdit(this.editingElement,!0),e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){e.focus(),this.editingElement=e;return}e.hasAttribute("data-hanzo-original-html")||e.setAttribute("data-hanzo-original-html",e.innerHTML),e.setAttribute("contenteditable","true"),e.setAttribute("spellcheck","true"),e.setAttribute("data-hanzo-inline-editing","true"),e.focus(),this.editingElement=e;let t=i=>{i.key==="Escape"&&(this.disableInlineEdit(e,!1),this.updateStatus("Edit reverted")),i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),this.disableInlineEdit(e,!0),this.updateStatus("Edit applied"))},n=()=>{this.disableInlineEdit(e,!0),this.updateStatus("Edit applied")};e.addEventListener("keydown",t,{once:!0}),e.addEventListener("blur",n,{once:!0})}disableInlineEdit(e,t){if(!t){let n=e.getAttribute("data-hanzo-original-html");n!==null&&(e.innerHTML=n)}e.removeAttribute("contenteditable"),e.removeAttribute("spellcheck"),e.removeAttribute("data-hanzo-inline-editing"),e.removeAttribute("data-hanzo-original-html"),this.editingElement===e&&(this.editingElement=null)}showHighlight(e){let t=e.getBoundingClientRect();if(t.width===0&&t.height===0){this.clearHighlight();return}this.highlightBox||(this.highlightBox=document.createElement("div"),this.highlightBox.className="hanzo-page-highlight",document.documentElement.appendChild(this.highlightBox)),this.highlightBox.style.left=`${Math.max(0,t.left-3)}px`,this.highlightBox.style.top=`${Math.max(0,t.top-3)}px`,this.highlightBox.style.width=`${t.width+6}px`,this.highlightBox.style.height=`${t.height+6}px`}clearHighlight(){var e;(e=this.highlightBox)==null||e.remove(),this.highlightBox=null}captureElementContext(e){let t=this.normalizeText(e.innerText||e.textContent||"");return{selector:this.buildSelector(e),tag:e.tagName.toLowerCase(),text:t.slice(0,800),html:e.outerHTML.slice(0,1200)}}buildSelector(e){if(e.id)return`#${e.id}`;let t=[],n=e,i=0;for(;n&&i<6;){let d=n.tagName.toLowerCase();if(n.classList.length>0){let u=Array.from(n.classList).slice(0,2).join(".");u&&(d+=`.${u}`)}let a=n.parentElement;if(a){let u=Array.from(a.children).filter(g=>g.tagName===n.tagName);if(u.length>1){let g=u.indexOf(n)+1;d+=`:nth-of-type(${g})`}}t.unshift(d),n=a,i+=1}return t.join(" > ")}normalizeText(e){return e.replace(/\s+/g," ").trim()}getElementSummary(e){let t=this.captureElementContext(e);return`${t.tag} \u2022 ${t.selector}`}async loadModels(){if(!(this.modelsLoaded||!this.modelEl))try{let e=await chrome.runtime.sendMessage({action:"chat.listModels"});if(!(e!=null&&e.success)||!Array.isArray(e.models)||!e.models.length)return;let t=this.modelEl.value;this.modelEl.innerHTML="";for(let n of e.models){if(!(n!=null&&n.id))continue;let i=document.createElement("option");i.value=n.id,i.textContent=n.name||n.id,this.modelEl.appendChild(i)}t&&Array.from(this.modelEl.options).some(n=>n.value===t)&&(this.modelEl.value=t),this.modelsLoaded=!0}catch{}}focusInput(){this.inputEl&&this.inputEl.focus()}appendMessage(e,t){if(!this.messagesEl)return;let n=document.createElement("div");n.className=`hanzo-page-msg ${e}`,n.textContent=t,this.messagesEl.appendChild(n),this.messagesEl.scrollTop=this.messagesEl.scrollHeight}updateStatus(e){this.statusEl&&(this.statusEl.textContent=e)}buildPageContext(){var i,d;let e=this.normalizeText(((d=(i=window.getSelection)==null?void 0:i.call(window))==null?void 0:d.toString())||""),t=[`URL: ${location.href}`,`Title: ${document.title||"Untitled"}`];e&&t.push(`TextSelection: ${e.slice(0,600)}`);let n=this.selectedContext||(this.hoveredElement?this.captureElementContext(this.hoveredElement):null);return n&&(t.push(`ElementSelector: ${n.selector}`),n.text&&t.push(`ElementText: ${n.text.slice(0,600)}`),t.push(`ElementHTML: ${n.html.slice(0,800)}`)),t.join(`
538
- `)}async askPageQuestion(){var a;if(this.sending||!this.inputEl)return;let e=this.normalizeText(this.inputEl.value);if(!e)return;let t=await chrome.runtime.sendMessage({action:"auth.getToken"});if(!(t!=null&&t.success)||!t.token){this.appendMessage("assistant","Please sign in from the Hanzo sidebar/popup before using page chat.");return}this.sending=!0,this.updateStatus("Thinking..."),this.sendBtn&&(this.sendBtn.disabled=!0),this.inputEl.value="",this.inputEl.style.height="auto",this.appendMessage("user",e);let n=this.buildPageContext(),i=((a=this.modelEl)==null?void 0:a.value)||"gpt-4o",d=[{role:"system",content:["You are Hanzo page overlay assistant.","Use provided page context and selected element context when relevant.","Be concise and provide concrete UI or DOM edit suggestions when asked.","",n].join(`
539
- `)},...this.messages.slice(-8),{role:"user",content:e}];try{let u=await chrome.runtime.sendMessage({action:"chat.complete",model:i,messages:d});if(!(u!=null&&u.success)||!u.content)throw new Error((u==null?void 0:u.error)||"No response from chat service");let g=String(u.content).trim();this.appendMessage("assistant",g||"No response content."),this.messages.push({role:"user",content:e},{role:"assistant",content:g}),this.messages=this.messages.slice(-20),this.updateStatus("Ready")}catch(u){this.appendMessage("assistant",`Error: ${(u==null?void 0:u.message)||"Chat request failed"}`),this.updateStatus("Error")}finally{this.sending=!1,this.sendBtn&&(this.sendBtn.disabled=!1),this.focusInput()}}},M=new U,Z=(()=>{let o=!1,e=null,t=null,n=null;function i(p){if(p.id)return`#${p.id}`;let f=p.tagName.toLowerCase(),x=Array.from(p.classList).filter(E=>!E.startsWith("hanzo-")).slice(0,3),y=f;if(x.length&&(y+=`.${x.join(".")}`),document.querySelectorAll(y).length>1){let E=p.parentElement;if(E){let k=Array.from(E.children).indexOf(p)+1;y+=`:nth-child(${k})`}}return y}function d(p){let f=[],x=p;for(;x&&x!==document.documentElement;)f.unshift(i(x)),x=x.parentElement;return f.join(" > ")}function a(){e||(e=document.createElement("div"),e.id="hanzo-picker-overlay",e.style.cssText="position:fixed;pointer-events:none;z-index:2147483646;border:2px solid #fff;border-radius:3px;background:rgba(255,255,255,0.06);transition:all 0.1s ease;display:none;",t=document.createElement("div"),t.id="hanzo-picker-label",t.style.cssText="position:fixed;z-index:2147483647;pointer-events:none;background:#000;color:#fff;font:11px/1.4 Geist Mono,Menlo,monospace;padding:3px 8px;border-radius:4px;max-width:400px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:none;box-shadow:0 2px 8px rgba(0,0,0,0.4);",document.body.appendChild(e),document.body.appendChild(t))}function u(p){var k,r,s,c,m,b,v;if(!p)return;let f=(k=p.closest)==null?void 0:k.call(p,"[data-at]");if(f)return{at:f.getAttribute("data-at")||"",component:f.getAttribute("data-is")||"",usedIn:f.getAttribute("data-in")||"",via:"gui"};let x=Object.keys(p).find(l=>l.startsWith("__reactFiber$")||l.startsWith("__reactInternalInstance$")),y=x?p[x]:null;for(;y;){let l=y._debugSource||((r=y._debugInfo)==null?void 0:r[0]);if(l!=null&&l.fileName)return{at:`${String(l.fileName).split("/").pop()}:${l.lineNumber??0}`,file:l.fileName,line:l.lineNumber??0,component:typeof y.type=="function"?y.type.displayName||y.type.name||"":String(y.type||""),via:"react"};y=y.return}let z=p;for(;z;){let l=(s=z.__svelte_meta)==null?void 0:s.loc;if(l!=null&&l.file)return{at:`${String(l.file).split("/").pop()}:${l.line??0}`,file:l.file,line:l.line??0,via:"svelte"};z=z.parentElement}let E=p;for(;E;){let l=E.__vueParentComponent||E.__vue__,h=((c=l==null?void 0:l.type)==null?void 0:c.__file)||((m=l==null?void 0:l.$options)==null?void 0:m.__file);if(h)return{at:String(h).split("/").pop()||String(h),file:h,component:((b=l==null?void 0:l.type)==null?void 0:b.name)||((v=l==null?void 0:l.$options)==null?void 0:v.name)||"",via:"vue"};E=E.parentElement}return{at:location.pathname,file:location.href,selector:i(p),via:"dom"}}function g(p){var y;if(!o)return;let f=p.target;if(!f||f===e||f===t||(y=f.id)!=null&&y.startsWith("hanzo-picker"))return;n=f;let x=f.getBoundingClientRect();if(e&&(e.style.display="block",e.style.top=x.top+"px",e.style.left=x.left+"px",e.style.width=x.width+"px",e.style.height=x.height+"px"),t){t.style.display="block",t.textContent=i(f);let z=x.top-28;t.style.top=(z>0?z:x.bottom+4)+"px",t.style.left=x.left+"px"}}function S(p){if(!o)return;p.preventDefault(),p.stopPropagation(),p.stopImmediatePropagation();let f=n||p.target;if(!f)return;let x=i(f),y=d(f),z=f.tagName.toLowerCase(),E=(f.textContent||"").trim().slice(0,80),k=f.getBoundingClientRect(),r=[`Selector: ${x}`,`Path: ${y}`,`Tag: ${z}`,`Size: ${Math.round(k.width)}x${Math.round(k.height)}`,f.id?`ID: ${f.id}`:"",f.className?`Classes: ${f.className}`:"",E?`Text: "${E}"`:""].filter(Boolean).join(`
540
- `);navigator.clipboard.writeText(r).catch(()=>{}),chrome.runtime.sendMessage({action:"elementSelected",data:{selector:x,fullPath:y,tag:z,text:E,source:u(f),rect:{x:k.x,y:k.y,w:k.width,h:k.height}}}),L()}function A(p){p.key==="Escape"&&(p.preventDefault(),L())}function _(){o||(o=!0,a(),document.addEventListener("mousemove",g,!0),document.addEventListener("click",S,!0),document.addEventListener("keydown",A,!0),document.body.style.cursor="crosshair")}function L(){o=!1,document.removeEventListener("mousemove",g,!0),document.removeEventListener("click",S,!0),document.removeEventListener("keydown",A,!0),document.body.style.cursor="",e&&(e.style.display="none"),t&&(t.style.display="none"),n=null}return{start:_,stop:L}})();function ce(){let o=g=>{var S;return((S=document.querySelector(`meta[name="${g}"], meta[property="${g}"]`))==null?void 0:S.getAttribute("content"))||""},e=[`Title: ${document.title}`,`URL: ${location.href}`,`Description: ${o("description")||o("og:description")}`,`Charset: ${document.characterSet}`,`Language: ${document.documentElement.lang||"unknown"}`,`Viewport: ${o("viewport")}`],t=[];window.__REACT_DEVTOOLS_GLOBAL_HOOK__&&t.push("React"),window.__VUE_DEVTOOLS_GLOBAL_HOOK__&&t.push("Vue"),window.__svelte&&t.push("Svelte"),window.__NEXT_DATA__&&t.push("Next.js"),window.__NUXT__&&t.push("Nuxt"),document.querySelector("[ng-version]")&&t.push("Angular"),t.length&&e.push(`Frameworks: ${t.join(", ")}`);let n=document.querySelectorAll("script[src]").length,i=document.querySelectorAll('link[rel="stylesheet"]').length,d=document.querySelectorAll("img").length,a=document.querySelectorAll("a[href]").length;e.push(`Resources: ${n} scripts, ${i} stylesheets, ${d} images, ${a} links`);let u=performance.getEntriesByType("navigation")[0];return u&&e.push(`Load: ${Math.round(u.loadEventEnd-u.startTime)}ms (DOM: ${Math.round(u.domContentLoadedEventEnd-u.startTime)}ms)`),e.filter(g=>!g.endsWith(": ")).join(`
541
- `)}var Q=(()=>{let o=null,e=null,t=null,n=!1;function i(){o||(o=document.createElement("div"),o.id="hanzo-console-root",o.style.cssText="position:fixed;bottom:20px;left:20px;right:20px;z-index:2147483646;font-family:Geist Mono,Menlo,Consolas,monospace;font-size:12px;display:none;",o.innerHTML=`
542
- <div style="background:rgba(0,0,0,0.92);backdrop-filter:blur(12px);border:1px solid rgba(255,255,255,0.15);border-radius:10px;overflow:hidden;box-shadow:0 8px 32px rgba(0,0,0,0.5);">
543
- <div id="hanzo-console-output" style="max-height:200px;overflow-y:auto;padding:8px 12px;color:#ccc;white-space:pre-wrap;word-break:break-all;"></div>
544
- <div style="display:flex;align-items:center;border-top:1px solid rgba(255,255,255,0.1);padding:0 12px;">
545
- <span style="color:#666;margin-right:6px;">&gt;</span>
546
- <input id="hanzo-console-input" type="text" placeholder="eval(...)" style="flex:1;background:transparent;border:none;color:#fff;font:inherit;padding:10px 0;outline:none;">
547
- <span style="color:#444;font-size:10px;margin-left:8px;">Esc to close</span>
548
- </div>
549
- </div>
550
- `,document.body.appendChild(o),e=o.querySelector("#hanzo-console-input"),t=o.querySelector("#hanzo-console-output"),e==null||e.addEventListener("keydown",g=>{if(g.key==="Escape"){u();return}if(g.key!=="Enter"||!(e!=null&&e.value.trim()))return;let S=e.value.trim();e.value="",d(`> ${S}`,"#888");try{let A=(0,eval)(S);d(String(A),"#4CAF50")}catch(A){d((A==null?void 0:A.message)||String(A),"#F44336")}}))}function d(g,S){if(!t)return;let A=document.createElement("div");A.style.color=S,A.textContent=g,t.appendChild(A),t.scrollTop=t.scrollHeight}function a(){i(),o&&(o.style.display="block"),n=!0,setTimeout(()=>e==null?void 0:e.focus(),50)}function u(){o&&(o.style.display="none"),n=!1}return{show:a,hide:u,isVisible:()=>n}})();new j;var I,J,B,q,D,ee;try{let o=((J=(I=browser==null?void 0:browser.runtime)==null?void 0:I.connect)==null?void 0:J.call(I,{name:"zap-keepalive"}))||((q=(B=chrome==null?void 0:chrome.runtime)==null?void 0:B.connect)==null?void 0:q.call(B,{name:"zap-keepalive"}));if(o){let e=setInterval(()=>{try{o.postMessage({type:"ping",t:Date.now()})}catch{clearInterval(e)}},1e4);(ee=(D=o.onDisconnect)==null?void 0:D.addListener)==null||ee.call(D,()=>clearInterval(e))}}catch{}})();