bariweb-widget 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1346 @@
1
+ (function(){var e=Object.defineProperty,t=(e,t)=>()=>(e&&(t=e(e=0)),t),n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},r={bodySerializer:e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t)};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});var i=({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:r,responseValidator:i,sseDefaultRetryDelay:a,sseMaxRetryAttempts:o,sseMaxRetryDelay:s,sseSleepFn:c,url:l,...u})=>{let d,f=c??(e=>new Promise(t=>setTimeout(t,e)));return{stream:async function*(){let c=a??3e3,p=0,m=u.signal??new AbortController().signal;for(;!m.aborted;){p++;let a=u.headers instanceof Headers?u.headers:new Headers(u.headers);d!==void 0&&a.set(`Last-Event-ID`,d);try{let t={redirect:`follow`,...u,body:u.serializedBody,headers:a,signal:m},o=new Request(l,t);e&&(o=await e(l,t));let s=await(u.fetch??globalThis.fetch)(o);if(!s.ok)throw Error(`SSE failed: ${s.status} ${s.statusText}`);if(!s.body)throw Error(`No body in SSE response`);let f=s.body.pipeThrough(new TextDecoderStream).getReader(),p=``,ee=()=>{try{f.cancel()}catch{}};m.addEventListener(`abort`,ee);try{for(;;){let{done:e,value:t}=await f.read();if(e)break;p+=t,p=p.replace(/\r\n/g,`
2
+ `).replace(/\r/g,`
3
+ `);let a=p.split(`
4
+
5
+ `);p=a.pop()??``;for(let e of a){let t=e.split(`
6
+ `),a=[],o;for(let e of t)if(e.startsWith(`data:`))a.push(e.replace(/^data:\s*/,``));else if(e.startsWith(`event:`))o=e.replace(/^event:\s*/,``);else if(e.startsWith(`id:`))d=e.replace(/^id:\s*/,``);else if(e.startsWith(`retry:`)){let t=Number.parseInt(e.replace(/^retry:\s*/,``),10);Number.isNaN(t)||(c=t)}let s,l=!1;if(a.length){let e=a.join(`
7
+ `);try{s=JSON.parse(e),l=!0}catch{s=e}}l&&(i&&await i(s),r&&(s=await r(s))),n?.({data:s,event:o,id:d,retry:c}),a.length&&(yield s)}}}finally{m.removeEventListener(`abort`,ee),f.releaseLock()}break}catch(e){if(t?.(e),o!==void 0&&p>=o)break;await f(Math.min(c*2**(p-1),s??3e4))}}}()}},a=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},o=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},s=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},c=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(o(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let s=a(r),c=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):l({allowReserved:e,name:n,value:t})).join(s);return r===`label`||r===`matrix`?s+c:c},l=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},u=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=s(r),c=Object.entries(i).map(([t,i])=>l({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+c:c},d=/\{[^{}]+\}/g,f=({path:e,url:t})=>{let n=t,r=t.match(d);if(r)for(let t of r){let r=!1,i=t.substring(1,t.length-1),a=`simple`;i.endsWith(`*`)&&(r=!0,i=i.substring(0,i.length-1)),i.startsWith(`.`)?(i=i.substring(1),a=`label`):i.startsWith(`;`)&&(i=i.substring(1),a=`matrix`);let o=e[i];if(o==null)continue;if(Array.isArray(o)){n=n.replace(t,c({explode:r,name:i,style:a,value:o}));continue}if(typeof o==`object`){n=n.replace(t,u({explode:r,name:i,style:a,value:o,valueOnly:!0}));continue}if(a===`matrix`){n=n.replace(t,`;${l({name:i,value:o})}`);continue}let s=encodeURIComponent(a===`label`?`.${o}`:o);n=n.replace(t,s)}return n},p=({baseUrl:e,path:t,query:n,querySerializer:r,url:i})=>{let a=i.startsWith(`/`)?i:`/${i}`,o=(e??``)+a;t&&(o=f({path:t,url:o}));let s=n?r(n):``;return s.startsWith(`?`)&&(s=s.substring(1)),s&&(o+=`?${s}`),o};function m(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return`serializedBody`in e?e.serializedBody!==void 0&&e.serializedBody!==``?e.serializedBody:null:e.body===``?null:e.body;if(t)return e.body}var ee=async(e,t)=>{let n=typeof t==`function`?await t(e):t;if(n)return e.scheme===`bearer`?`Bearer ${n}`:e.scheme===`basic`?`Basic ${btoa(n)}`:n},te=({parameters:e={},...t}={})=>n=>{let r=[];if(n&&typeof n==`object`)for(let i in n){let a=n[i];if(a==null)continue;let o=e[i]||t;if(Array.isArray(a)){let e=c({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=u({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=l({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},ne=e=>{if(!e)return`stream`;let t=e.split(`;`)[0]?.trim();if(t){if(t.startsWith(`application/json`)||t.endsWith(`+json`))return`json`;if(t===`multipart/form-data`)return`formData`;if([`application/`,`audio/`,`image/`,`video/`].some(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},re=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get(`Cookie`)?.includes(`${t}=`)):!1,ie=async({security:e,...t})=>{for(let n of e){if(re(t,n.name))continue;let e=await ee(n,t.auth);if(!e)continue;let r=n.name??`Authorization`;switch(n.in){case`query`:t.query||={},t.query[r]=e;break;case`cookie`:t.headers.append(`Cookie`,`${r}=${e}`);break;default:t.headers.set(r,e);break}}},ae=e=>p({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==`function`?e.querySerializer:te(e.querySerializer),url:e.url}),oe=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith(`/`)&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=ce(e.headers,t.headers),n},se=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},ce=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?se(n):Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t},h=class{constructor(){this.fns=[]}clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e==`number`?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let n=this.getInterceptorIndex(e);return this.fns[n]?(this.fns[n]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}},le=()=>({error:new h,request:new h,response:new h}),ue=te({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),de={"Content-Type":`application/json`},fe=(e={})=>({...r,headers:de,parseAs:`auto`,querySerializer:ue,...e}),pe=((e={})=>{let t=oe(fe(),e),n=()=>({...t}),r=e=>(t=oe(t,e),n()),a=le(),o=async e=>{let n={...t,...e,fetch:e.fetch??t.fetch??globalThis.fetch,headers:ce(t.headers,e.headers),serializedBody:void 0};return n.security&&await ie({...n,security:n.security}),n.requestValidator&&await n.requestValidator(n),n.body!==void 0&&n.bodySerializer&&(n.serializedBody=n.bodySerializer(n.body)),(n.body===void 0||n.serializedBody===``)&&n.headers.delete(`Content-Type`),{opts:n,url:ae(n)}},s=async e=>{let{opts:t,url:n}=await o(e),r={redirect:`follow`,...t,body:m(t)},i=new Request(n,r);for(let e of a.request.fns)e&&(i=await e(i,t));let s=t.fetch,c;try{c=await s(i)}catch(e){let n=e;for(let r of a.error.fns)r&&(n=await r(e,void 0,i,t));if(n||={},t.throwOnError)throw n;return t.responseStyle===`data`?void 0:{error:n,request:i,response:void 0}}for(let e of a.response.fns)e&&(c=await e(c,i,t));let l={request:i,response:c};if(c.ok){let e=(t.parseAs===`auto`?ne(c.headers.get(`Content-Type`)):t.parseAs)??`json`;if(c.status===204||c.headers.get(`Content-Length`)===`0`){let n;switch(e){case`arrayBuffer`:case`blob`:case`text`:n=await c[e]();break;case`formData`:n=new FormData;break;case`stream`:n=c.body;break;default:n={};break}return t.responseStyle===`data`?n:{data:n,...l}}let n;switch(e){case`arrayBuffer`:case`blob`:case`formData`:case`text`:n=await c[e]();break;case`json`:{let e=await c.text();n=e?JSON.parse(e):{};break}case`stream`:return t.responseStyle===`data`?c.body:{data:c.body,...l}}return e===`json`&&(t.responseValidator&&await t.responseValidator(n),t.responseTransformer&&(n=await t.responseTransformer(n))),t.responseStyle===`data`?n:{data:n,...l}}let u=await c.text(),d;try{d=JSON.parse(u)}catch{}let f=d??u,p=f;for(let e of a.error.fns)e&&(p=await e(f,c,i,t));if(p||={},t.throwOnError)throw p;return t.responseStyle===`data`?void 0:{error:p,...l}},c=e=>t=>s({...t,method:e}),l=e=>async t=>{let{opts:n,url:r}=await o(t);return i({...n,body:n.body,headers:n.headers,method:e,onRequest:async(e,t)=>{let r=new Request(e,t);for(let e of a.request.fns)e&&(r=await e(r,n));return r},serializedBody:m(n),url:r})};return{buildUrl:e=>ae({...t,...e}),connect:c(`CONNECT`),delete:c(`DELETE`),get:c(`GET`),getConfig:n,head:c(`HEAD`),interceptors:a,options:c(`OPTIONS`),patch:c(`PATCH`),post:c(`POST`),put:c(`PUT`),request:s,setConfig:r,sse:{connect:l(`CONNECT`),delete:l(`DELETE`),get:l(`GET`),head:l(`HEAD`),options:l(`OPTIONS`),patch:l(`PATCH`),post:l(`POST`),put:l(`PUT`),trace:l(`TRACE`)},trace:c(`TRACE`)}})(fe({baseUrl:`http://localhost:8000`})),g=globalThis,me=g.ShadowRoot&&(g.ShadyCSS===void 0||g.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,_=Symbol(),he=new WeakMap,ge=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==_)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(me&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=he.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&he.set(t,e))}return e}toString(){return this.cssText}},_e=e=>new ge(typeof e==`string`?e:e+``,void 0,_),ve=(e,...t)=>new ge(e.length===1?e[0]:t.reduce((t,n,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if(typeof e==`number`)return e;throw Error(`Value passed to 'css' function must be a 'css' function result: `+e+`. Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.`)})(n)+e[r+1],e[0]),e,_),ye=(e,t)=>{if(me)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of t){let t=document.createElement(`style`),r=g.litNonce;r!==void 0&&t.setAttribute(`nonce`,r),t.textContent=n.cssText,e.appendChild(t)}},be=me?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return _e(t)})(e):e,{is:xe,defineProperty:Se,getOwnPropertyDescriptor:Ce,getOwnPropertyNames:we,getOwnPropertySymbols:Te,getPrototypeOf:Ee}=Object,v=globalThis,De=v.trustedTypes,Oe=De?De.emptyScript:``,ke=v.reactiveElementPolyfillSupport,y=(e,t)=>e,b={toAttribute(e,t){switch(t){case Boolean:e=e?Oe:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},x=(e,t)=>!xe(e,t),Ae={attribute:!0,type:String,converter:b,reflect:!1,useDefault:!1,hasChanged:x};Symbol.metadata??=Symbol(`metadata`),v.litPropertyMetadata??=new WeakMap;var S=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Ae){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&Se(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=Ce(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Ae}static _$Ei(){if(this.hasOwnProperty(y(`elementProperties`)))return;let e=Ee(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(y(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(y(`properties`))){let e=this.properties,t=[...we(e),...Te(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(be(e))}else e!==void 0&&t.push(be(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ye(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?b:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?b:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??=a.getPropertyOptions(e),!((n.hasChanged??x)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==i||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===r&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};S.elementStyles=[],S.shadowRootOptions={mode:`open`},S[y(`elementProperties`)]=new Map,S[y(`finalized`)]=new Map,ke?.({ReactiveElement:S}),(v.reactiveElementVersions??=[]).push(`2.1.2`);var je=globalThis,Me=e=>e,C=je.trustedTypes,Ne=C?C.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,Pe=`$lit$`,w=`lit$${Math.random().toFixed(9).slice(2)}$`,Fe=`?`+w,Ie=`<${Fe}>`,T=document,E=()=>T.createComment(``),D=e=>e===null||typeof e!=`object`&&typeof e!=`function`,Le=Array.isArray,Re=e=>Le(e)||typeof e?.[Symbol.iterator]==`function`,O=`[
8
+ \f\r]`,k=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ze=/-->/g,Be=/>/g,A=RegExp(`>|${O}(?:([^\\s"'>=/]+)(${O}*=${O}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),Ve=/'/g,He=/"/g,Ue=/^(?:script|style|textarea|title)$/i,j=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),M=Symbol.for(`lit-noChange`),N=Symbol.for(`lit-nothing`),We=new WeakMap,P=T.createTreeWalker(T,129);function Ge(e,t){if(!Le(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return Ne===void 0?t:Ne.createHTML(t)}var Ke=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=k;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===k?c[1]===`!--`?o=ze:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=A):(Ue.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=A):o=Be:o===A?c[0]===`>`?(o=i??k,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?A:c[3]===`"`?He:Ve):o===He||o===Ve?o=A:o===ze||o===Be?o=k:(o=A,i=void 0);let d=o===A&&e[t+1].startsWith(`/>`)?` `:``;a+=o===k?n+Ie:l>=0?(r.push(s),n.slice(0,l)+Pe+n.slice(l)+w+d):n+w+(l===-2?t:d)}return[Ge(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},qe=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=Ke(t,n);if(this.el=e.createElement(l,r),P.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=P.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(Pe)){let t=u[o++],n=i.getAttribute(e).split(w),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?Ye:r[1]===`?`?Xe:r[1]===`@`?Ze:L}),i.removeAttribute(e)}else e.startsWith(w)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(Ue.test(i.tagName)){let e=i.textContent.split(w),t=e.length-1;if(t>0){i.textContent=C?C.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],E()),P.nextNode(),c.push({type:2,index:++a});i.append(e[t],E())}}}else if(i.nodeType===8)if(i.data===Fe)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(w,e+1))!==-1;)c.push({type:7,index:a}),e+=w.length-1}a++}}static createElement(e,t){let n=T.createElement(`template`);return n.innerHTML=e,n}};function F(e,t,n=e,r){if(t===M)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=D(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=F(e,i._$AS(e,t.values),i,r)),t}var Je=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??T).importNode(t,!0);P.currentNode=r;let i=P.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new I(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new Qe(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=P.nextNode(),a++)}return P.currentNode=T,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},I=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=N,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=F(this,e,t),D(e)?e===N||e==null||e===``?(this._$AH!==N&&this._$AR(),this._$AH=N):e!==this._$AH&&e!==M&&this._(e):e._$litType$===void 0?e.nodeType===void 0?Re(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==N&&D(this._$AH)?this._$AA.nextSibling.data=e:this.T(T.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=qe.createElement(Ge(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new Je(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=We.get(e.strings);return t===void 0&&We.set(e.strings,t=new qe(e)),t}k(t){Le(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(E()),this.O(E()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=Me(e).nextSibling;Me(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},L=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=N,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=N}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=F(this,e,t,0),a=!D(e)||e!==this._$AH&&e!==M,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=F(this,r[n+o],t,o),s===M&&(s=this._$AH[o]),a||=!D(s)||s!==this._$AH[o],s===N?e=N:e!==N&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===N?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},Ye=class extends L{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===N?void 0:e}},Xe=class extends L{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==N)}},Ze=class extends L{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=F(this,e,t,0)??N)===M)return;let n=this._$AH,r=e===N&&n!==N||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==N&&(n===N||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},Qe=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){F(this,e)}},$e=je.litHtmlPolyfillSupport;$e?.(qe,I),(je.litHtmlVersions??=[]).push(`3.3.2`);var et=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new I(t.insertBefore(E(),e),e,void 0,n??{})}return i._$AI(e),i},tt=globalThis,R=class extends S{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=et(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return M}};R._$litElement$=!0,R.finalized=!0,tt.litElementHydrateSupport?.({LitElement:R});var nt=tt.litElementPolyfillSupport;nt?.({LitElement:R}),(tt.litElementVersions??=[]).push(`4.2.2`);var rt=e=>(t,n)=>{n===void 0?customElements.define(e,t):n.addInitializer(()=>{customElements.define(e,t)})},it={attribute:!0,type:String,converter:b,reflect:!1,hasChanged:x},at=(e=it,t,n)=>{let{kind:r,metadata:i}=n,a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),r===`setter`&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),r===`accessor`){let{name:r}=n;return{set(n){let i=t.get.call(this);t.set.call(this,n),this.requestUpdate(r,i,e,!0,n)},init(t){return t!==void 0&&this.C(r,void 0,e,t),t}}}if(r===`setter`){let{name:r}=n;return function(n){let i=this[r];t.call(this,n),this.requestUpdate(r,i,e,!0,n)}}throw Error(`Unsupported decorator location: `+r)};function ot(e){return(t,n)=>typeof n==`object`?at(e,t,n):((e,t,n)=>{let r=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),r?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function z(e){return ot({...e,state:!0,attribute:!1})}var st=(e,t,n)=>(n.configurable=!0,n.enumerable=!0,Reflect.decorate&&typeof t!=`object`&&Object.defineProperty(e,t,n),n);function ct(e,t){return(n,r,i)=>{let a=t=>t.renderRoot?.querySelector(e)??null;if(t){let{get:e,set:t}=typeof r==`object`?n:i??(()=>{let e=Symbol();return{get(){return this[e]},set(t){this[e]=t}}})();return st(n,r,{get(){let n=e.call(this);return n===void 0&&(n=a(this),(n!==null||this.hasUpdated)&&t.call(this,n)),n}})}return st(n,r,{get(){return a(this)}})}}var lt={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ut=e=>(...t)=>({_$litDirective$:e,values:t}),dt=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}},B=class extends dt{constructor(e){if(super(e),this.it=N,e.type!==lt.CHILD)throw Error(this.constructor.directiveName+`() can only be used in child bindings`)}render(e){if(e===N||e==null)return this._t=void 0,this.it=e;if(e===M)return e;if(typeof e!=`string`)throw Error(this.constructor.directiveName+`() called with a non-string value`);if(e===this.it)return this._t;this.it=e;let t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};B.directiveName=`unsafeHTML`,B.resultType=1;var ft=ut(B),V=e=>j`${ft(`
9
+ <svg
10
+ viewBox="0 0 24 24"
11
+ fill="none"
12
+ stroke="currentColor"
13
+ stroke-width="2"
14
+ stroke-linecap="round"
15
+ stroke-linejoin="round"
16
+ >
17
+ ${e}
18
+ </svg>
19
+ `)}`,H={accessibility:V(`<circle cx="12" cy="12" r="10" stroke-width="1.5" stroke-dasharray="3 3" stroke-linecap="butt"/><circle cx="12" cy="5" r="1.5"/><path d="M12 7v5"/><path d="M6 8h12"/><path d="M12 12l-3 5"/><path d="M12 12l3 5"/>`),mic:V(`<path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/>`),close:V(`<path d="M18 6 6 18"/><path d="m6 6 12 12"/>`),languages:V(`<path d="m5 8 6 6"/><path d="m4 14 6-6 2-3"/><path d="M2 5h12"/><path d="M7 2h1"/><path d="m22 22-5-10-5 10"/><path d="M14 18h6"/>`),profiles:V(`<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>`),textSize:V(`<polyline points="4 7 4 4 20 4 20 7"/><line x1="9" y1="20" x2="15" y2="20"/><line x1="12" y1="4" x2="12" y2="20"/>`),contrast:V(`<circle cx="12" cy="12" r="10"/><path d="M12 18a6 6 0 0 0 0-12v12z"/>`),grayscale:V(`<circle cx="12" cy="12" r="10"/><path d="M12 2v20"/><path d="M12 18a6 6 0 0 0 0-12"/><path d="M12 14a2 2 0 0 0 0-4"/>`),cursor:V(`<path d="M4 4l11.73 4.58a0.5 0 0 1 0 0.94l-4.47 1.35 1.35 4.47a0.5 0 0 1-0.94 0L6.7 9.61 4 4z"/>`),screenReader:V(`<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M15.54 8.46a5 5 0 0 1 0 7.07"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14"/>`),visualImpair:V(`<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0z"/><circle cx="12" cy="12" r="3"/>`),seizureSafe:V(`<path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"/>`),cognitive:V(`<path d="M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 4.44-2.54z"/><path d="M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-4.44-2.54z"/>`),info:V(`<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>`),check:V(`<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/>`),chevronDown:V(`<path d="m6 9 6 6 6-6"/>`),sun:V(`<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>`),moon:V(`<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9z"/>`),droplet:V(`<path d="M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5s-3 3.5-3 5.5a7 7 0 0 0 7 7z"/>`),refresh:V(`<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M3 21v-5h5"/>`),send:V(`<line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/>`)},pt=ve`
20
+ :host {
21
+ display: block;
22
+ pointer-events: none;
23
+ user-select: none;
24
+
25
+ --bw-primary: #6d28d9;
26
+ --bw-primary-light: #7c3aed;
27
+ --bw-primary-fg: #ffffff;
28
+ --bw-bg: #ffffff;
29
+ --bw-fg: #0f172a;
30
+ --bw-fg-muted: #64748b;
31
+ --bw-border: #e2e8f0;
32
+ --bw-bg-hover: #f8fafc;
33
+ --bw-bg-subtle: #f1f5f9;
34
+ --bw-radius: 14px;
35
+ --bw-radius-sm: 8px;
36
+ --bw-shadow-panel: 0 20px 60px -10px rgba(0,0,0,0.18), 0 8px 24px -4px rgba(0,0,0,0.1);
37
+
38
+ font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
39
+ font-size: 15px;
40
+ line-height: 1.5;
41
+ -webkit-font-smoothing: antialiased;
42
+ }
43
+
44
+ /* ─── Accessibility themes ─── */
45
+ :host([data-contrast="high"]) { --bw-bg: #000; --bw-fg: #ff0; --bw-primary: #fff; --bw-border: #fff; --bw-bg-hover: #111; --bw-primary-fg: #000; }
46
+ :host([data-contrast="light"]) { --bw-bg: #f8fafc; --bw-fg: #64748b; --bw-border: #e2e8f0; }
47
+ :host([data-text-spacing]) { line-height: var(--bw-line-height) !important; letter-spacing: var(--bw-letter-spacing) !important; }
48
+ :host([data-dyslexic]) { font-family: "Comic Sans MS", "Comic Neue", sans-serif !important; }
49
+ :host([data-focus-visualizer]) *:focus-visible { outline: 4px solid #f59e0b !important; outline-offset: 2px !important; }
50
+ :host([data-cursor-magnifier]) { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z'/%3E%3C/svg%3E"), auto !important; }
51
+ :host([data-no-animations]) *, :host([data-no-animations]) { transition: none !important; animation: none !important; }
52
+ :host([data-link-highlight]) a { text-decoration: underline !important; background-color: #fef08a !important; color: #000 !important; padding: 0 2px !important; border-radius: 2px !important; }
53
+
54
+ /* ─── Widget container ─── */
55
+ .widget-container {
56
+ display: block;
57
+ pointer-events: none;
58
+ }
59
+
60
+ /* ─── FAB Trigger ─── */
61
+ .trigger {
62
+ position: fixed;
63
+ bottom: 24px;
64
+ left: 24px;
65
+ width: 60px;
66
+ height: 60px;
67
+ pointer-events: auto;
68
+ transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
69
+ z-index: 2147483646;
70
+ }
71
+ .trigger:hover { transform: scale(1.08); }
72
+
73
+ /* ─── Main Panel ─── */
74
+ .bw-panel {
75
+ position: fixed;
76
+ top: 0;
77
+ left: 0;
78
+ width: 360px;
79
+ max-width: 100vw;
80
+ height: 100dvh;
81
+ height: 100vh;
82
+ background: var(--bw-bg);
83
+ border-right: 1px solid var(--bw-border);
84
+ box-shadow: var(--bw-shadow-panel);
85
+ display: flex;
86
+ flex-direction: column;
87
+ pointer-events: auto;
88
+ z-index: 2147483647;
89
+ transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
90
+ will-change: transform, opacity;
91
+ overflow: hidden;
92
+ }
93
+
94
+ .bw-panel.panel-hidden {
95
+ transform: translateX(-100%);
96
+ opacity: 0;
97
+ pointer-events: none;
98
+ }
99
+
100
+ .bw-panel.panel-visible ~ .trigger {
101
+ transform: scale(0);
102
+ opacity: 0;
103
+ pointer-events: none;
104
+ }
105
+
106
+ /* ─── Header ─── */
107
+ .bw-header {
108
+ display: flex;
109
+ align-items: center;
110
+ justify-content: space-between;
111
+ padding: 16px 20px;
112
+ border-bottom: 1px solid var(--bw-border);
113
+ flex-shrink: 0;
114
+ background: var(--bw-bg);
115
+ }
116
+
117
+ .header-branding {
118
+ display: flex;
119
+ align-items: center;
120
+ gap: 10px;
121
+ cursor: pointer;
122
+ user-select: none;
123
+ padding: 4px;
124
+ border-radius: var(--bw-radius-sm);
125
+ transition: background 0.15s;
126
+ }
127
+ .header-branding:active { background: var(--bw-bg-hover); }
128
+ .header-branding svg { width: 22px; height: 22px; color: var(--bw-primary); }
129
+ .header-branding-text { display: flex; flex-direction: column; }
130
+ .header-brand-name { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; color: var(--bw-fg); line-height: 1.1; }
131
+ .header-brand-sub { font-size: 11px; color: var(--bw-fg-muted); line-height: 1; }
132
+
133
+ .close-btn {
134
+ width: 36px;
135
+ height: 36px;
136
+ border: none;
137
+ background: var(--bw-bg-hover);
138
+ cursor: pointer;
139
+ display: flex;
140
+ align-items: center;
141
+ justify-content: center;
142
+ border-radius: 50%;
143
+ transition: all 0.2s;
144
+ color: var(--bw-fg-muted);
145
+ }
146
+ .close-btn:hover { background: #fee2e2; color: #ef4444; transform: rotate(90deg); }
147
+ .close-btn svg { width: 18px; height: 18px; }
148
+
149
+ /* ─── Segmented Tab Control ─── */
150
+ .bw-tabs {
151
+ display: flex;
152
+ padding: 12px 16px;
153
+ gap: 6px;
154
+ flex-shrink: 0;
155
+ background: var(--bw-bg);
156
+ border-bottom: 1px solid var(--bw-border);
157
+ }
158
+
159
+ .bw-tab {
160
+ flex: 1;
161
+ display: flex;
162
+ align-items: center;
163
+ justify-content: center;
164
+ gap: 6px;
165
+ padding: 10px 8px;
166
+ border: none;
167
+ border-radius: var(--bw-radius-sm);
168
+ background: var(--bw-bg-subtle);
169
+ color: var(--bw-fg-muted);
170
+ font-size: 13px;
171
+ font-weight: 600;
172
+ cursor: pointer;
173
+ transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
174
+ min-height: 40px;
175
+ white-space: nowrap;
176
+ }
177
+ .bw-tab:hover { background: var(--bw-bg-hover); color: var(--bw-fg); }
178
+ .bw-tab[active] {
179
+ background: var(--bw-primary);
180
+ color: white;
181
+ box-shadow: 0 2px 8px rgba(109, 40, 217, 0.3);
182
+ }
183
+
184
+ /* ─── Content area ─── */
185
+ .bw-content {
186
+ flex: 1;
187
+ min-height: 0;
188
+ display: flex;
189
+ flex-direction: column;
190
+ position: relative;
191
+ overflow: hidden;
192
+ }
193
+
194
+ .tab-panel {
195
+ display: none;
196
+ flex-direction: column;
197
+ flex: 1;
198
+ min-height: 0;
199
+ overflow: hidden;
200
+ }
201
+ .tab-panel[active] { display: flex; }
202
+
203
+ /* ─── Footer ─── */
204
+ .bw-footer {
205
+ display: flex;
206
+ align-items: center;
207
+ justify-content: space-between;
208
+ padding: 10px 20px;
209
+ border-top: 1px solid var(--bw-border);
210
+ flex-shrink: 0;
211
+ background: var(--bw-bg);
212
+ }
213
+ .footer-brand {
214
+ display: flex;
215
+ align-items: center;
216
+ gap: 6px;
217
+ font-size: 12px;
218
+ font-weight: 700;
219
+ color: var(--bw-primary);
220
+ cursor: pointer;
221
+ user-select: none;
222
+ }
223
+ .footer-brand svg { width: 14px; height: 14px; }
224
+ .bw-footer span { font-size: 11px; color: var(--bw-fg-muted); }
225
+
226
+ /* ════════════════════════════════ */
227
+ /* CHAT TAB */
228
+ /* ════════════════════════════════ */
229
+
230
+ .chat-messages {
231
+ flex: 1;
232
+ overflow-y: auto;
233
+ padding: 16px;
234
+ display: flex;
235
+ flex-direction: column;
236
+ gap: 10px;
237
+ min-height: 0;
238
+ scroll-behavior: smooth;
239
+ overscroll-behavior-y: contain;
240
+ scrollbar-width: thin;
241
+ scrollbar-color: var(--bw-border) transparent;
242
+ }
243
+ .chat-messages::-webkit-scrollbar { width: 4px; }
244
+ .chat-messages::-webkit-scrollbar-thumb { background: var(--bw-border); border-radius: 4px; }
245
+
246
+ .chat-empty {
247
+ flex: 1;
248
+ display: flex;
249
+ flex-direction: column;
250
+ align-items: center;
251
+ justify-content: center;
252
+ gap: 12px;
253
+ padding: 2rem;
254
+ text-align: center;
255
+ color: var(--bw-fg-muted);
256
+ }
257
+ .chat-empty svg { width: 44px; height: 44px; opacity: 0.35; }
258
+ .chat-empty-title { font-size: 15px; font-weight: 600; color: var(--bw-fg); margin: 0; }
259
+ .chat-empty-sub { font-size: 13px; color: var(--bw-fg-muted); margin: 0; line-height: 1.5; }
260
+
261
+ .chat-bubble {
262
+ max-width: 82%;
263
+ padding: 10px 14px;
264
+ border-radius: 18px;
265
+ font-size: 14px;
266
+ line-height: 1.5;
267
+ white-space: pre-wrap;
268
+ word-break: break-word;
269
+ animation: bubblePop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
270
+ }
271
+ @keyframes bubblePop { from { opacity: 0; transform: scale(0.9) translateY(4px); } to { opacity: 1; transform: none; } }
272
+
273
+ .chat-bubble.user {
274
+ align-self: flex-end;
275
+ background: var(--bw-primary);
276
+ color: white;
277
+ border-bottom-right-radius: 4px;
278
+ }
279
+ .chat-bubble.assistant {
280
+ align-self: flex-start;
281
+ background: var(--bw-bg-subtle);
282
+ color: var(--bw-fg);
283
+ border-bottom-left-radius: 4px;
284
+ border: 1px solid var(--bw-border);
285
+ }
286
+
287
+ .screen-label-badge {
288
+ background: rgba(16, 185, 129, 0.08);
289
+ border: 1px solid rgba(16, 185, 129, 0.2);
290
+ border-radius: var(--bw-radius-sm);
291
+ padding: 6px 12px;
292
+ font-size: 12px;
293
+ color: #059669;
294
+ display: flex;
295
+ align-items: center;
296
+ gap: 6px;
297
+ flex-shrink: 0;
298
+ }
299
+ .screen-label-badge svg { width: 12px; height: 12px; flex-shrink: 0; }
300
+
301
+ /* System log details */
302
+ .system-log {
303
+ background: var(--bw-bg-subtle);
304
+ border: 1px solid var(--bw-border);
305
+ border-radius: var(--bw-radius-sm);
306
+ font-size: 12px;
307
+ color: var(--bw-fg-muted);
308
+ overflow: hidden;
309
+ }
310
+ .system-log-header {
311
+ padding: 8px 12px;
312
+ cursor: pointer;
313
+ user-select: none;
314
+ list-style: none;
315
+ display: flex;
316
+ align-items: center;
317
+ gap: 8px;
318
+ }
319
+ .system-log-header::-webkit-details-marker { display: none; }
320
+ .system-log-details { padding: 8px 12px; border-top: 1px solid var(--bw-border); white-space: pre-wrap; word-break: break-all; }
321
+
322
+ /* Typing indicator */
323
+ .typing-indicator {
324
+ display: flex;
325
+ align-self: flex-start;
326
+ gap: 4px;
327
+ padding: 12px 16px;
328
+ background: var(--bw-bg-subtle);
329
+ border: 1px solid var(--bw-border);
330
+ border-radius: 18px;
331
+ border-bottom-left-radius: 4px;
332
+ }
333
+ .typing-dot {
334
+ width: 7px;
335
+ height: 7px;
336
+ background: var(--bw-fg-muted);
337
+ border-radius: 50%;
338
+ animation: typingBounce 1.2s infinite ease-in-out;
339
+ }
340
+ .typing-dot:nth-child(1) { animation-delay: 0s; }
341
+ .typing-dot:nth-child(2) { animation-delay: 0.2s; }
342
+ .typing-dot:nth-child(3) { animation-delay: 0.4s; }
343
+ @keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }
344
+
345
+ /* Confirm panel */
346
+ .confirm-panel {
347
+ padding: 14px 16px;
348
+ border-top: 1px solid var(--bw-border);
349
+ display: flex;
350
+ flex-direction: column;
351
+ gap: 8px;
352
+ flex-shrink: 0;
353
+ background: var(--bw-bg);
354
+ }
355
+ .btn-confirm {
356
+ width: 100%; min-height: 46px; border-radius: var(--bw-radius-sm);
357
+ background: var(--bw-primary); color: white; border: none;
358
+ font-weight: 700; font-size: 14px; cursor: pointer;
359
+ transition: all 0.2s; box-shadow: 0 4px 12px rgba(109, 40, 217, 0.25);
360
+ }
361
+ .btn-confirm:hover { filter: brightness(1.1); transform: translateY(-1px); }
362
+ .btn-cancel {
363
+ width: 100%; min-height: 44px; border-radius: var(--bw-radius-sm);
364
+ background: transparent; color: #ef4444; border: 1px solid #fecaca;
365
+ font-weight: 600; font-size: 13px; cursor: pointer; transition: all 0.2s;
366
+ }
367
+ .btn-cancel:hover { background: #fef2f2; }
368
+
369
+ /* Chat input area */
370
+ .chat-input-area {
371
+ border-top: 1px solid var(--bw-border);
372
+ display: flex;
373
+ flex-direction: column;
374
+ gap: 8px;
375
+ padding: 12px 14px;
376
+ flex-shrink: 0;
377
+ background: var(--bw-bg);
378
+ }
379
+
380
+ .stt-banner {
381
+ display: flex;
382
+ align-items: center;
383
+ gap: 8px;
384
+ font-size: 12px;
385
+ padding: 6px 10px;
386
+ border-radius: var(--bw-radius-sm);
387
+ }
388
+ .stt-banner.recording { color: #dc2626; background: rgba(220,38,38,0.08); }
389
+ .stt-banner.processing { color: #2563eb; background: rgba(37,99,235,0.08); }
390
+ .stt-banner.error { color: #dc2626; background: rgba(220,38,38,0.06); }
391
+
392
+ .chat-input-row {
393
+ display: flex;
394
+ align-items: center;
395
+ gap: 8px;
396
+ }
397
+ .chat-input {
398
+ flex: 1;
399
+ min-width: 0;
400
+ height: 38px;
401
+ padding: 0 14px;
402
+ border: 1px solid var(--bw-border);
403
+ border-radius: 999px;
404
+ font-size: 14px;
405
+ font-family: inherit;
406
+ background: var(--bw-bg-subtle);
407
+ color: var(--bw-fg);
408
+ outline: none;
409
+ transition: border-color 0.2s;
410
+ }
411
+ .chat-input:focus { border-color: var(--bw-primary); background: var(--bw-bg); }
412
+ .chat-input:disabled { opacity: 0.5; cursor: not-allowed; }
413
+ .chat-input::placeholder { color: var(--bw-fg-muted); }
414
+
415
+ .chat-icon-btn {
416
+ flex-shrink: 0;
417
+ width: 44px;
418
+ height: 44px;
419
+ border-radius: 50%;
420
+ border: 1px solid var(--bw-border);
421
+ background: var(--bw-bg-subtle);
422
+ color: var(--bw-fg-muted);
423
+ cursor: pointer;
424
+ display: flex;
425
+ align-items: center;
426
+ justify-content: center;
427
+ transition: all 0.18s;
428
+ font-size: 16px;
429
+ line-height: 1;
430
+ }
431
+ .chat-icon-btn:hover:not(:disabled) { border-color: var(--bw-primary); color: var(--bw-primary); background: var(--bw-bg-hover); }
432
+ .chat-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
433
+ .chat-icon-btn svg { width: 17px; height: 17px; }
434
+
435
+ /* Specialized Mic Button (Accessibility Target) */
436
+ #bw-voice-btn {
437
+ width: 56px;
438
+ height: 56px;
439
+ background: var(--bw-bg-subtle);
440
+ border: 2px solid var(--bw-primary);
441
+ color: var(--bw-primary);
442
+ margin-right: 12px; /* Physical buffer from send button */
443
+ }
444
+ #bw-voice-btn:hover { background: rgba(109, 40, 217, 0.08); transform: scale(1.05); }
445
+ #bw-voice-btn.recording {
446
+ background: #fef2f2;
447
+ border-color: #dc2626;
448
+ color: #dc2626;
449
+ animation: micPulse 1.5s infinite;
450
+ }
451
+ @keyframes micPulse {
452
+ 0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); transform: scale(1.05); }
453
+ 100% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); transform: scale(1.05); }
454
+ }
455
+
456
+ .chat-icon-btn.tts-on { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.4); color: #059669; }
457
+
458
+ .chat-send-btn {
459
+ flex-shrink: 0;
460
+ width: 44px;
461
+ height: 44px;
462
+ border-radius: 50%;
463
+ border: none;
464
+ background: var(--bw-primary);
465
+ color: white;
466
+ cursor: pointer;
467
+ display: flex;
468
+ align-items: center;
469
+ justify-content: center;
470
+ transition: all 0.2s;
471
+ box-shadow: 0 2px 8px rgba(109,40,217,0.3);
472
+ margin-left: 6px;
473
+ }
474
+ .chat-send-btn:hover:not(:disabled) { transform: scale(1.08); filter: brightness(1.1); }
475
+ .chat-send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }
476
+ .chat-send-btn svg { width: 18px; height: 18px; }
477
+
478
+ /* ════════════════════════════════ */
479
+ /* SETTINGS (A11Y) TAB */
480
+ /* ════════════════════════════════ */
481
+
482
+ .a11y-scroller {
483
+ flex: 1;
484
+ overflow-y: auto;
485
+ overscroll-behavior-y: contain;
486
+ scrollbar-width: thin;
487
+ scrollbar-color: var(--bw-border) transparent;
488
+ display: flex;
489
+ flex-direction: column;
490
+ gap: 0;
491
+ min-height: 0;
492
+ }
493
+ .a11y-scroller::-webkit-scrollbar { width: 4px; }
494
+ .a11y-scroller::-webkit-scrollbar-thumb { background: var(--bw-border); border-radius: 4px; }
495
+
496
+ /* Settings grid */
497
+ .settings-grid {
498
+ display: grid;
499
+ grid-template-columns: 1fr 1fr;
500
+ gap: 10px;
501
+ padding: 14px 14px 0;
502
+ }
503
+
504
+ .settings-card {
505
+ background: var(--bw-bg-subtle);
506
+ border: 1.5px solid var(--bw-border);
507
+ border-radius: var(--bw-radius);
508
+ padding: 0;
509
+ display: flex;
510
+ flex-direction: column;
511
+ align-items: center;
512
+ justify-content: center;
513
+ gap: 8px;
514
+ cursor: pointer;
515
+ transition: all 0.18s cubic-bezier(0.4,0,0.2,1);
516
+ position: relative;
517
+ text-align: center;
518
+ min-height: 90px;
519
+ user-select: none;
520
+ overflow: hidden;
521
+ }
522
+ .settings-card:hover { border-color: var(--bw-primary); background: var(--bw-bg); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,0.07); }
523
+ .settings-card[active] {
524
+ border-color: var(--bw-primary);
525
+ background: rgba(109, 40, 217, 0.06);
526
+ box-shadow: 0 0 0 1px var(--bw-primary);
527
+ }
528
+ .settings-card[active] svg { color: var(--bw-primary); }
529
+ .settings-card svg { width: 22px; height: 22px; color: var(--bw-fg-muted); transition: color 0.18s; }
530
+ .settings-card-label { font-size: 12px; font-weight: 600; color: var(--bw-fg); }
531
+ .settings-card[active] .settings-card-label { color: var(--bw-primary); }
532
+ .settings-card-value { font-size: 11px; color: var(--bw-fg-muted); font-weight: 500; }
533
+
534
+ .active-badge {
535
+ position: absolute;
536
+ top: 6px;
537
+ right: 6px;
538
+ width: 18px;
539
+ height: 18px;
540
+ background: var(--bw-primary);
541
+ border-radius: 50%;
542
+ display: flex;
543
+ align-items: center;
544
+ justify-content: center;
545
+ }
546
+ .active-badge svg { width: 10px; height: 10px; color: white; stroke-width: 3; }
547
+
548
+ /* Color section */
549
+ .color-section {
550
+ margin: 12px 14px 0;
551
+ padding: 14px;
552
+ border: 1.5px solid var(--bw-border);
553
+ border-radius: var(--bw-radius);
554
+ background: var(--bw-bg-subtle);
555
+ }
556
+
557
+ .color-section-header {
558
+ display: flex;
559
+ align-items: center;
560
+ gap: 8px;
561
+ margin-bottom: 12px;
562
+ }
563
+ .color-section-header svg { width: 16px; height: 16px; color: var(--bw-primary); }
564
+ .color-section-title { font-size: 13px; font-weight: 700; color: var(--bw-fg); margin: 0; }
565
+
566
+ .color-tabs {
567
+ display: flex;
568
+ gap: 6px;
569
+ margin-bottom: 12px;
570
+ }
571
+ .color-tab {
572
+ flex: 1;
573
+ border: 1px solid var(--bw-border);
574
+ border-radius: 6px;
575
+ padding: 6px 4px;
576
+ font-size: 11px;
577
+ font-weight: 600;
578
+ text-align: center;
579
+ cursor: pointer;
580
+ background: var(--bw-bg);
581
+ color: var(--bw-fg-muted);
582
+ transition: all 0.15s;
583
+ }
584
+ .color-tab[active] { background: var(--bw-primary); color: white; border-color: var(--bw-primary); }
585
+
586
+ .hue-row {
587
+ display: flex;
588
+ align-items: center;
589
+ gap: 10px;
590
+ }
591
+ .hue-step-btn {
592
+ width: 32px; height: 32px; border: 1px solid var(--bw-border);
593
+ border-radius: 50%; background: var(--bw-bg); cursor: pointer;
594
+ display: flex; align-items: center; justify-content: center;
595
+ font-size: 18px; font-weight: 700; color: var(--bw-fg); flex-shrink: 0;
596
+ transition: all 0.15s;
597
+ }
598
+ .hue-step-btn:hover { border-color: var(--bw-primary); color: var(--bw-primary); }
599
+ .hue-slider {
600
+ flex: 1; height: 8px; border-radius: 4px; -webkit-appearance: none;
601
+ background: linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, red);
602
+ cursor: pointer; outline: none; border: none;
603
+ }
604
+ .hue-slider::-webkit-slider-thumb {
605
+ -webkit-appearance: none; width: 20px; height: 20px;
606
+ background: white; border: 2.5px solid var(--bw-primary);
607
+ border-radius: 50%; cursor: pointer;
608
+ box-shadow: 0 1px 4px rgba(0,0,0,0.2);
609
+ }
610
+
611
+ /* AI Tools section */
612
+ .ai-tools-section {
613
+ margin: 12px 14px 14px;
614
+ display: flex;
615
+ flex-direction: column;
616
+ gap: 8px;
617
+ }
618
+
619
+ .trigger svg {
620
+ width: 28px;
621
+ height: 28px;
622
+ }
623
+
624
+ .ai-tool-btn {
625
+ width: 100%;
626
+ padding: 12px 16px;
627
+ border-radius: var(--bw-radius-sm);
628
+ border: 1.5px solid var(--bw-border);
629
+ background: var(--bw-bg);
630
+ color: var(--bw-fg);
631
+ font-size: 13px;
632
+ font-weight: 600;
633
+ cursor: pointer;
634
+ display: flex;
635
+ align-items: center;
636
+ gap: 10px;
637
+ transition: all 0.18s;
638
+ text-align: left;
639
+ min-height: 46px;
640
+ }
641
+ .ai-tool-btn:hover { border-color: var(--bw-primary); color: var(--bw-primary); background: rgba(109,40,217,0.04); }
642
+ .ai-tool-btn.active { background: rgba(109,40,217,0.08); border-color: var(--bw-primary); color: var(--bw-primary); }
643
+ .ai-tool-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
644
+ .ai-tool-btn-label { flex: 1; }
645
+ .ai-tool-badge { font-size: 10px; background: var(--bw-primary); color: white; padding: 2px 7px; border-radius: 99px; font-weight: 700; }
646
+ .ai-tool-badge.on { background: #059669; }
647
+
648
+ /* ════════════════════════════════ */
649
+ /* ADMIN PANEL */
650
+ /* ════════════════════════════════ */
651
+ .admin-overlay {
652
+ position: absolute;
653
+ inset: 0;
654
+ background: var(--bw-bg);
655
+ z-index: 50;
656
+ display: flex;
657
+ flex-direction: column;
658
+ align-items: center;
659
+ justify-content: center;
660
+ padding: 32px 24px;
661
+ text-align: center;
662
+ animation: adminFadeIn 0.25s ease;
663
+ }
664
+ @keyframes adminFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
665
+
666
+ .admin-overlay .admin-icon { font-size: 32px; margin-bottom: 12px; }
667
+ .admin-overlay h4 { font-size: 17px; font-weight: 700; margin: 0 0 6px; color: var(--bw-fg); }
668
+ .admin-overlay p { font-size: 13px; color: var(--bw-fg-muted); margin: 0 0 20px; }
669
+ .admin-overlay input {
670
+ width: 100%; padding: 12px 14px; border-radius: var(--bw-radius-sm);
671
+ border: 1.5px solid var(--bw-border); background: var(--bw-bg-subtle);
672
+ color: var(--bw-fg); font-size: 14px; outline: none; margin-bottom: 10px;
673
+ transition: border-color 0.2s;
674
+ }
675
+ .admin-overlay input:focus { border-color: var(--bw-primary); }
676
+ .admin-login-btn {
677
+ width: 100%; padding: 12px; border-radius: var(--bw-radius-sm);
678
+ background: var(--bw-primary); color: white; border: none;
679
+ font-weight: 700; font-size: 14px; cursor: pointer; margin-bottom: 8px;
680
+ transition: all 0.2s;
681
+ }
682
+ .admin-login-btn:hover { filter: brightness(1.1); }
683
+ .admin-logout-btn {
684
+ width: 100%; padding: 12px; border-radius: var(--bw-radius-sm);
685
+ background: #fef2f2; color: #ef4444; border: 1px solid #fecaca;
686
+ font-weight: 600; font-size: 14px; cursor: pointer; margin-bottom: 8px;
687
+ transition: all 0.2s;
688
+ }
689
+ .admin-logout-btn:hover { background: #fee2e2; }
690
+ .admin-close-btn {
691
+ background: none; border: none; color: var(--bw-fg-muted);
692
+ font-size: 13px; cursor: pointer; padding: 6px; text-decoration: underline;
693
+ margin-top: 4px;
694
+ }
695
+ .auth-error { color: #ef4444; font-size: 12px; margin: 0 0 12px; }
696
+ .admin-status { color: #059669; font-size: 14px; font-weight: 600; margin: 0 0 16px; }
697
+ `,mt=`bw-a11y-settings-v2`,U={monochrome:!1,darkHighContrast:!1,brightHighContrast:!1,lowSaturation:!1,highSaturation:!1,contrastMode:!1,customBgHue:null,customHeaderHue:null,customContentHue:null,activeColorTab:`background`,textScale:1,highlightHeaders:!1,enlargeButtons:!1,textSpacing:!1,dyslexicFont:!1,focusVisualizer:!1,cursorMagnifier:!1,animationsDisabled:!1,linkHighlight:!1},ht=class{constructor(e){this.settings={...U},(this.host=e).addController(this),this._loadSettings()}hostConnected(){this._applySettings()}_loadSettings(){let e=localStorage.getItem(mt);if(e)try{let t=JSON.parse(e);this.settings={...U,...t}}catch(e){console.error(`BariWeb: Failed to parse a11y settings`,e)}}_saveSettings(){localStorage.setItem(mt,JSON.stringify(this.settings)),this._applySettings(),this.host.requestUpdate()}_ensureGlobalStyles(){let e=`bw-global-a11y-styles`,t=document.getElementById(e);t||(t=document.createElement(`style`),t.id=e,document.head.appendChild(t)),t.textContent=`
698
+ /* Global Filters */
699
+ html {
700
+ filter:
701
+ grayscale(var(--bw-grayscale, 0%))
702
+ saturate(var(--bw-saturation, 1)) !important;
703
+ transition: filter 0.3s ease;
704
+ }
705
+
706
+ /* Text Spacing */
707
+ html[data-bw-text-spacing], html[data-bw-text-spacing] * {
708
+ line-height: 1.8 !important;
709
+ letter-spacing: 0.12em !important;
710
+ word-spacing: 0.16em !important;
711
+ }
712
+
713
+ /* Dyslexic Font */
714
+ html[data-bw-dyslexic], html[data-bw-dyslexic] * {
715
+ font-family: "OpenDyslexic", "Comic Sans MS", "Chalkboard SE", sans-serif !important;
716
+ }
717
+
718
+ /* Focus Visualizer (Read Focus) - More distinctive */
719
+ html[data-bw-focus-visualizer] *:focus,
720
+ html[data-bw-focus-visualizer] *:focus-visible {
721
+ outline: 8px solid #3b82f6 !important;
722
+ outline-offset: 4px !important;
723
+ box-shadow: 0 0 0 12px rgba(59, 130, 246, 0.4) !important;
724
+ z-index: 99999 !important;
725
+ position: relative;
726
+ }
727
+ html[data-bw-focus-visualizer] *:hover {
728
+ outline: 2px solid rgba(59, 130, 246, 0.3) !important;
729
+ outline-offset: 2px !important;
730
+ }
731
+
732
+ /* Cursor Magnifier - Standing out */
733
+ html[data-bw-cursor-magnifier], html[data-bw-cursor-magnifier] * {
734
+ cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 24 24' fill='%233b82f6' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z'%3E%3C/path%3E%3Cpath d='M13 13l6 6'%3E%3C/path%3E%3C/svg%3E") 0 0, auto !important;
735
+ }
736
+
737
+ /* Link Highlight */
738
+ html[data-bw-link-highlight] a {
739
+ text-decoration: underline !important;
740
+ text-decoration-thickness: 3px !important;
741
+ background-color: #fef08a !important;
742
+ color: #000000 !important;
743
+ padding: 0 4px !important;
744
+ border-radius: 4px !important;
745
+ font-weight: bold !important;
746
+ }
747
+
748
+ /* Highlight Headers */
749
+ html[data-bw-highlight-headers] h1,
750
+ html[data-bw-highlight-headers] h2,
751
+ html[data-bw-highlight-headers] h3,
752
+ html[data-bw-highlight-headers] h4,
753
+ html[data-bw-highlight-headers] h5,
754
+ html[data-bw-highlight-headers] h6 {
755
+ background-color: #3b82f6 !important;
756
+ color: #ffffff !important;
757
+ padding: 4px 8px !important;
758
+ border-radius: 4px !important;
759
+ display: inline-block !important;
760
+ }
761
+
762
+ /* Enlarge Buttons */
763
+ html[data-bw-enlarge-buttons] button,
764
+ html[data-bw-enlarge-buttons] [role="button"],
765
+ html[data-bw-enlarge-buttons] input[type="button"],
766
+ html[data-bw-enlarge-buttons] input[type="submit"] {
767
+ transform: scale(1.2) !important;
768
+ margin: 10px !important;
769
+ }
770
+
771
+ /* Stop Animations */
772
+ html[data-bw-no-animations], html[data-bw-no-animations] * {
773
+ transition: none !important;
774
+ animation: none !important;
775
+ scroll-behavior: auto !important;
776
+ }
777
+
778
+ /* --- High Contrast Modes --- */
779
+
780
+ /* Dark High Contrast */
781
+ html[data-bw-dark-high-contrast],
782
+ html[data-bw-dark-high-contrast] body,
783
+ html[data-bw-dark-high-contrast] *:not(bw-widget):not(bw-widget *) {
784
+ background-color: #000000 !important;
785
+ color: #00ff00 !important; /* High-Visibility Green on Black */
786
+ border-color: #00ff00 !important;
787
+ background-image: none !important;
788
+ }
789
+ html[data-bw-dark-high-contrast] a { color: #ffff00 !important; }
790
+
791
+ /* Bright High Contrast */
792
+ html[data-bw-bright-high-contrast],
793
+ html[data-bw-bright-high-contrast] body,
794
+ html[data-bw-bright-high-contrast] *:not(bw-widget):not(bw-widget *) {
795
+ background-color: #ffffff !important;
796
+ color: #000000 !important;
797
+ border-color: #000000 !important;
798
+ background-image: none !important;
799
+ }
800
+ html[data-bw-bright-high-contrast] a { color: #0000ff !important; font-weight: bold !important; }
801
+
802
+ /* Contrast Mode (Classic) */
803
+ html[data-bw-contrast-mode],
804
+ html[data-bw-contrast-mode] body,
805
+ html[data-bw-contrast-mode] *:not(bw-widget):not(bw-widget *) {
806
+ background-color: #000 !important;
807
+ color: #fff !important;
808
+ border-color: #fff !important;
809
+ }
810
+
811
+ /* --- Custom Colors --- */
812
+ html[data-bw-has-custom-bg] body,
813
+ html[data-bw-has-custom-bg] *:not(bw-widget):not(bw-widget *) {
814
+ background-color: var(--bw-custom-bg) !important;
815
+ background-image: none !important;
816
+ }
817
+ html[data-bw-has-custom-header] h1,
818
+ html[data-bw-has-custom-header] h2,
819
+ html[data-bw-has-custom-header] h3 {
820
+ color: var(--bw-custom-header) !important;
821
+ }
822
+ html[data-bw-has-custom-content] p,
823
+ html[data-bw-has-custom-content] span,
824
+ html[data-bw-has-custom-content] div:not(bw-widget *) {
825
+ color: var(--bw-custom-content) !important;
826
+ }
827
+ `}_applySettings(){let e=document.documentElement;this._ensureGlobalStyles(),e.style.setProperty(`--bw-grayscale`,this.settings.monochrome?`100%`:`0%`);let t=1;this.settings.lowSaturation&&(t=.3),this.settings.highSaturation&&(t=2.5),e.style.setProperty(`--bw-saturation`,t.toString()),this.settings.customBgHue===null?e.removeAttribute(`data-bw-has-custom-bg`):(e.style.setProperty(`--bw-custom-bg`,`hsl(${this.settings.customBgHue}, 50%, 95%)`),e.setAttribute(`data-bw-has-custom-bg`,``)),this.settings.customHeaderHue===null?e.removeAttribute(`data-bw-has-custom-header`):(e.style.setProperty(`--bw-custom-header`,`hsl(${this.settings.customHeaderHue}, 70%, 30%)`),e.setAttribute(`data-bw-has-custom-header`,``)),this.settings.customContentHue===null?e.removeAttribute(`data-bw-has-custom-content`):(e.style.setProperty(`--bw-custom-content`,`hsl(${this.settings.customContentHue}, 60%, 40%)`),e.setAttribute(`data-bw-has-custom-content`,``)),this.settings.textScale>1?e.style.fontSize=`${this.settings.textScale*100}%`:e.style.fontSize=``;let n={"data-bw-monochrome":this.settings.monochrome,"data-bw-dark-high-contrast":this.settings.darkHighContrast,"data-bw-bright-high-contrast":this.settings.brightHighContrast,"data-bw-contrast-mode":this.settings.contrastMode,"data-bw-text-spacing":this.settings.textSpacing,"data-bw-dyslexic":this.settings.dyslexicFont,"data-bw-focus-visualizer":this.settings.focusVisualizer,"data-bw-cursor-magnifier":this.settings.cursorMagnifier,"data-bw-no-animations":this.settings.animationsDisabled,"data-bw-link-highlight":this.settings.linkHighlight,"data-bw-highlight-headers":this.settings.highlightHeaders,"data-bw-enlarge-buttons":this.settings.enlargeButtons};Object.entries(n).forEach(([t,n])=>{n?e.setAttribute(t,``):e.removeAttribute(t)});let r=this.host;r&&r.style.setProperty(`--bw-font-scale`,this.settings.textScale.toString())}toggleMonochrome(){this.settings.monochrome=!this.settings.monochrome,this._saveSettings()}toggleDarkHighContrast(){this.settings.darkHighContrast=!this.settings.darkHighContrast,this.settings.darkHighContrast&&(this.settings.brightHighContrast=!1,this.settings.contrastMode=!1),this._saveSettings()}toggleBrightHighContrast(){this.settings.brightHighContrast=!this.settings.brightHighContrast,this.settings.brightHighContrast&&(this.settings.darkHighContrast=!1,this.settings.contrastMode=!1),this._saveSettings()}toggleLowSaturation(){this.settings.lowSaturation=!this.settings.lowSaturation,this.settings.lowSaturation&&(this.settings.highSaturation=!1),this._saveSettings()}toggleHighSaturation(){this.settings.highSaturation=!this.settings.highSaturation,this.settings.highSaturation&&(this.settings.lowSaturation=!1),this._saveSettings()}toggleContrastMode(){this.settings.contrastMode=!this.settings.contrastMode,this.settings.contrastMode&&(this.settings.darkHighContrast=!1,this.settings.brightHighContrast=!1),this._saveSettings()}setCustomHue(e){this.settings.activeColorTab===`background`?this.settings.customBgHue=e:this.settings.activeColorTab===`header`?this.settings.customHeaderHue=e:this.settings.customContentHue=e,this._saveSettings()}resetCustomColors(){this.settings.customBgHue=null,this.settings.customHeaderHue=null,this.settings.customContentHue=null,this._saveSettings()}toggleHighlightHeaders(){this.settings.highlightHeaders=!this.settings.highlightHeaders,this._saveSettings()}toggleEnlargeButtons(){this.settings.enlargeButtons=!this.settings.enlargeButtons,this._saveSettings()}incrementTextScale(){this.settings.textScale>=1.5?this.settings.textScale=1:this.settings.textScale=parseFloat((this.settings.textScale+.1).toFixed(1)),this._saveSettings()}toggleTextSpacing(){this.settings.textSpacing=!this.settings.textSpacing,this._saveSettings()}toggleDyslexicFont(){this.settings.dyslexicFont=!this.settings.dyslexicFont,this._saveSettings()}toggleFocusVisualizer(){this.settings.focusVisualizer=!this.settings.focusVisualizer,this._saveSettings()}toggleCursorMagnifier(){this.settings.cursorMagnifier=!this.settings.cursorMagnifier,this._saveSettings()}toggleAnimations(){this.settings.animationsDisabled=!this.settings.animationsDisabled,this._saveSettings()}toggleLinkHighlight(){this.settings.linkHighlight=!this.settings.linkHighlight,this._saveSettings()}reset(){this.settings={...U},this._saveSettings()}};function W(e){try{let t=new URL(e),n=t.pathname;n=n.replace(yt,`:id`),n=n.replace(bt,`/:id`),n=n.replace(xt,`/:slug`),n=n.replace(St,`/:id`);let r=new URLSearchParams;t.searchParams.forEach((e,t)=>{Ct.has(t)?r.set(`:${t}`,``):e.length<30&&!/^\d+$/.test(e)&&r.set(t,e)});let i=r.toString();return n.replace(/\/$/,``)+(i?`?${i}`:``)}catch{return e.replace(yt,`:id`).replace(/\/\d{1,20}(?=\/|$)/g,`/:id`).split(`?`)[0]}}function G(e){let t=[`dialog`,`tooltip`,`menu`,`listbox`,`alertdialog`],n=e;for(;n&&n!==document.body;){let e=n.getAttribute(`role`)||``;if(t.includes(e)||n.hasAttribute(`data-radix-popper-content-wrapper`)||n.hasAttribute(`data-floating-ui-portal`))return!0;let r=typeof n.className==`string`?n.className:``;if(/popover|tooltip|dropdown-menu|floating|overlay/i.test(r))return!0;n=n.parentElement}return!1}function gt(e){let t=[`li`,`article`,`tr`,`dd`],n=e.parentElement,r=0;for(;n&&n!==document.body&&r<8;){let e=n.tagName.toLowerCase();if(t.includes(e))return!0;let i=typeof n.className==`string`?n.className:``;if(/\b(card|item|tile|post|entry|product|row-item|list-item|feed-item|cell)\b/i.test(i)){let e=n.parentElement?.children;if(e&&e.length>2)return!0}let a=n.getAttribute(`role`)||``;if(a===`listitem`||a===`row`||a===`gridcell`)return!0;n=n.parentElement,r++}return!1}function _t(e){let t=e,n=(t.getAttribute(`aria-label`)||t.getAttribute(`title`)||t.innerText||t.getAttribute(`placeholder`)||``).trim().toLowerCase();return!n||n.length<2||n.length>40||/^[\d\s₸$€%.,\-+:()]+$/.test(n)||/^\d{1,2}[./]\d{1,2}/.test(n)||wt.has(n)?``:n.replace(/^[\p{Emoji}\s]+/u,``).trim().slice(0,30)}function vt(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(16)}function K(){let e=[],t=W(window.location.href);e.push(`route:${t}`);let n=document.querySelector(`h1`);if(n){let t=n.innerText?.trim().toLowerCase();t&&t.length>1&&t.length<50&&!/\d{3,}/.test(t)&&e.push(`h1:${t.slice(0,30)}`)}let r=Array.from(document.querySelectorAll(`input:not([type="hidden"]):not([type="submit"]):not([type="radio"]):not([type="checkbox"]), textarea, select`)).slice(0,8);for(let t of r){if(G(t))continue;let n=t,r=(n.getAttribute(`name`)||n.getAttribute(`placeholder`)||n.getAttribute(`aria-label`)||``).toLowerCase().trim().slice(0,25);r&&r.length>1&&!wt.has(r)&&e.push(`field:${r}`)}let i=Array.from(document.querySelectorAll(`nav a, [role="navigation"] a`)).slice(0,6);for(let t of i){if(G(t))continue;let n=_t(t);n&&e.push(`nav:${n}`)}let a=document.querySelector(`main`)||document.querySelector(`[role="main"]`)||document.getElementById(`root`);return a&&Array.from(a.querySelectorAll(`button:not([aria-hidden="true"]), [role="button"]:not([aria-hidden="true"])`)).filter(e=>!G(e)&&!gt(e)).map(_t).filter(e=>e.length>1).reduce((e,t)=>e.includes(t)?e:[...e,t],[]).slice(0,3).forEach(t=>e.push(`btn:${t}`)),[...new Set(e)].sort().slice(0,15)}function q(){return`bw-${vt(K().join(`|`))}`}var yt,bt,xt,St,Ct,wt,Tt=t((()=>{yt=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,bt=/\/\d{1,20}(?=\/|$)/g,xt=/\/[a-z0-9]+(?:-[a-z0-9]+)*-\d+(?=\/|$)/g,St=/\/[0-9a-f]{8,}(?=\/|$)/gi,Ct=new Set([`id`,`userId`,`user_id`,`orderId`,`order_id`,`itemId`,`item_id`,`productId`,`product_id`,`token`,`key`,`ref`,`code`,`session`]),wt=new Set(`ok,ок,okay,close,закрыть,cancel,отмена,yes,da,no,нет,да,submit,отправить,back,назад,next,далее,more,ещё,еще,menu,меню,...,•,·,loading,загрузка,open,открыть,expand,collapse,toggle,sort`.split(`,`))}));function Et(e,t){let n=new Set([...e].filter(e=>t.has(e))),r=new Set([...e,...t]);return r.size===0?1:n.size/r.size}var Dt,J,Ot=t((()=>{Tt(),Dt=class{constructor(e=1500){this._observer=null,this._debounceTimer=null,this._lastTokens=new Set,this._lastUrl=``,this._callbacks=[],this._discoveryCallbacks=[],this._isDiscovering=!1,this.isAutoDiscoveryEnabled=!1,this._debounceMs=e}start(){this._observer||(this._lastTokens=new Set(K()),this._lastUrl=W(window.location.href),this._observer=new MutationObserver(()=>{this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>this._onMutation(),this._debounceMs)}),this._observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}stop(){this._observer?.disconnect(),this._observer=null,this._debounceTimer&&clearTimeout(this._debounceTimer)}onStateChange(e){this._callbacks.push(e)}onDiscovery(e){this._discoveryCallbacks.push(e)}get isDiscovering(){return this._isDiscovering}getLiveSnapshot(){let e=(e,t)=>{if(e.hasAttribute(`bw-private`)||e.hasAttribute(`data-bw-private`))return`[MASKED]`;if(!t)return t;let n=t.replace(/(?:\d[ \-]*?){13,16}/g,`****`);return n=n.replace(/\b\d{12}\b/g,`****`),n},t=Array.from(document.querySelectorAll(`h1, h2`)).map(t=>e(t,t.innerText?.trim()||``)).filter(Boolean).slice(0,3),n=Array.from(document.querySelectorAll(`button, a[href], [role="button"]`)).map(t=>{let n=t,r=e(n,(n.getAttribute(`aria-label`)||n.innerText||``).trim().slice(0,60));return{id:n.id||``,text:r}}).filter(e=>e.text.length>0).slice(0,30);return{url:window.location.href,headings:t,fingerprint:q(),elements:n}}async _onMutation(){if(document.readyState!==`complete`)return;let e=W(window.location.href),t=new Set(K());if(t.size<2)return;let n=q(),r=e!==this._lastUrl,i=Et(this._lastTokens,t);if(r||i<.55){let a=r?`URL: ${this._lastUrl} → ${e}`:`Sim: ${i.toFixed(2)}`;console.log(`[Watcher] Screen change (${a})`),this._lastUrl=e,this._lastTokens=t;let o=this.getLiveSnapshot();if(this.isAutoDiscoveryEnabled){let e=this._buildTypedTokens();this._discover(n,e).catch(()=>{})}this._callbacks.forEach(e=>e(o))}}_buildTypedTokens(){let e=new Set,t=[],n=(n,r)=>{let i=r.trim().slice(0,40);if(!i||i.length<2)return;let a=`${n}:${i}`;e.has(a)||(e.add(a),t.push(a))};return document.querySelectorAll(`button, [role="button"]`).forEach(e=>{let t=e.innerText?.trim();t&&n(`btn`,t)}),document.querySelectorAll(`a[href]`).forEach(e=>{let t=(e.getAttribute(`aria-label`)||e.innerText)?.trim();t&&n(`a`,t)}),document.querySelectorAll(`input:not([type=hidden]), textarea, select`).forEach(e=>{let t=e.placeholder||e.name;t&&n(`input`,t)}),t.slice(0,8)}async _discover(e,t){let n=localStorage.getItem(`bw_admin_token`);if(n){this._isDiscovering=!0;try{let r=await fetch(`http://localhost:8000/v1/training/discover`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${n}`},body:JSON.stringify({fingerprint:e,tokens:t,page_url:window.location.href})});if(r.ok){let e=await r.json();console.log(`[Discovery] ${e.status} — ${e.label}`),this._discoveryCallbacks.forEach(t=>t(e))}else r.status===401?(console.warn(`[Discovery] Token expired — disabling auto-discovery`),localStorage.removeItem(`bw_admin_token`),this.isAutoDiscoveryEnabled=!1):console.warn(`[Discovery] Server error ${r.status}`)}catch(e){console.warn(`[Discovery] Network error`,e)}finally{this._isDiscovering=!1}}}async forceDiscovery(){let e=[...new Set(K())],t=q();await this._discover(t,e)}},J=new Dt(1500)}));Ot();var kt=`http://localhost:8000`,At=class{constructor(e){this.isFixing=!1,this.simplifyEnabled=!1,this.autoA11yEnabled=!1,this._onParagraphClick=async e=>{if(!this.simplifyEnabled)return;let t=e.target;if(t.closest(`bw-widget`)||t.closest(`.bw-ai-tooltip`))return;let n=t.tagName.toLowerCase();if([`p`,`span`,`div`,`li`,`article`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`].includes(n)){let n=t.innerText?.trim();if(n&&n.length>20){e.preventDefault(),e.stopPropagation(),document.querySelectorAll(`.bw-ai-tooltip`).forEach(e=>e.remove());let r=window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches,i=document.createElement(`div`);i.className=`bw-ai-tooltip bw-ai-tooltip-loading`,r&&i.setAttribute(`data-theme`,`dark`),i.innerHTML=`
828
+ <div class="bw-ai-tooltip-header">
829
+ <span>✨ AI Упрощение</span>
830
+ <button class="bw-ai-tooltip-close">✕</button>
831
+ </div>
832
+ <div class="bw-ai-tooltip-content">
833
+ Ожидаем ответ от ИИ...
834
+ </div>
835
+ `,document.body.appendChild(i),i.style.left=`${Math.max(10,e.pageX-160)}px`,i.style.top=`${e.pageY+20}px`;let a=t.style.outline,o=t.style.backgroundColor;t.style.outline=`2px dashed #a855f7`,t.style.backgroundColor=`rgba(168, 85, 247, 0.05)`,i.querySelector(`.bw-ai-tooltip-close`)?.addEventListener(`click`,()=>{i.remove(),t.style.outline=a,t.style.backgroundColor=o});try{let e=window.BariwebConfig?.clientId||``,t=await fetch(`${kt}/v1/widget/a11y/simplify`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Client-ID":e},body:JSON.stringify({text:n})});if(t.ok){let e=await t.json();if(e.text)i.classList.remove(`bw-ai-tooltip-loading`),i.querySelector(`.bw-ai-tooltip-content`).innerHTML=e.text;else throw Error(`Empty response`)}else throw Error(`Server error`)}catch(e){console.error(`BariWeb AI: Simplify failed`,e),i.classList.remove(`bw-ai-tooltip-loading`),i.querySelector(`.bw-ai-tooltip-content`).innerHTML=`<span style="color:#ef4444; font-size:13px;">Ошибка создания упрощенного текста. Попробуйте еще раз.</span>`}}}},(this.host=e).addController(this),this.simplifyEnabled=localStorage.getItem(`bw-ai-simplify`)===`true`,this.autoA11yEnabled=localStorage.getItem(`bw-ai-autofix`)===`true`,J.onStateChange(()=>{this.autoA11yEnabled&&!this.isFixing&&this.fixMarkup()}),this.autoA11yEnabled&&setTimeout(()=>this.fixMarkup(),1e3)}toggleAutoA11y(){this.autoA11yEnabled=!this.autoA11yEnabled,localStorage.setItem(`bw-ai-autofix`,this.autoA11yEnabled?`true`:`false`),this.autoA11yEnabled&&!this.isFixing&&this.fixMarkup(),this.host.requestUpdate()}hostConnected(){}hostDisconnected(){this.simplifyEnabled&&(document.body.removeEventListener(`click`,this._onParagraphClick,{capture:!0}),document.body.classList.remove(`bw-simplify-mode`))}async fixMarkup(){this.isFixing=!0,this.host.requestUpdate();try{let e=[];if(document.querySelectorAll(`img:not([alt]), img[alt=""]`).forEach(t=>{t.hasAttribute(`data-bw-ai-id`)||t.setAttribute(`data-bw-ai-id`,`ai-img-`+Math.random().toString(36).substring(2,9)),e.push({id:t.getAttribute(`data-bw-ai-id`),html:t.outerHTML.substring(0,300)+(t.outerHTML.length>300?`...>`:``)})}),document.querySelectorAll(`button:not([aria-label]), a:not([aria-label]), [role="button"]:not([aria-label])`).forEach(t=>{if(t.tagName===`INPUT`)return;let n=t;n.innerText?.trim()||n.textContent?.trim()||(t.hasAttribute(`data-bw-ai-id`)||t.setAttribute(`data-bw-ai-id`,`ai-btn-`+Math.random().toString(36).substring(2,9)),e.push({id:t.getAttribute(`data-bw-ai-id`),html:t.outerHTML.substring(0,300)+(t.outerHTML.length>300?`...>`:``)}))}),e.length===0){console.log(`BariWeb AI: No broken elements found.`);return}console.log(`BariWeb AI: Found ${e.length} broken elements. Processing...`);let t=window.BariwebConfig?.clientId||``;for(let n=0;n<e.length;n+=10){let r=e.slice(n,n+10),i=await fetch(`${kt}/v1/widget/a11y/fix`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Client-ID":t},body:JSON.stringify({elements:r})});i.ok&&(await i.json()).forEach(e=>{let t=document.querySelector(`[data-bw-ai-id="${e.id}"]`);if(t&&e.value&&(e.attribute===`alt`||e.attribute===`aria-label`)){t.setAttribute(e.attribute,e.value);let n=t,r=n.style.outline;n.style.outline=`3px solid #10b981`,setTimeout(()=>{n.style.outline=r},2e3)}})}}catch(e){console.error(`BariWeb AI: A11y Fix failed`,e)}finally{this.isFixing=!1,this.host.requestUpdate()}}toggleSimplify(){if(this.simplifyEnabled=!this.simplifyEnabled,this.simplifyEnabled){if(document.body.addEventListener(`click`,this._onParagraphClick,{capture:!0}),document.documentElement.style.setProperty(`--bw-simplify-cursor`,`help`),!document.getElementById(`bw-simplify-mode-style`)){let e=document.createElement(`style`);e.id=`bw-simplify-mode-style`,e.textContent=`
836
+ body.bw-simplify-mode *:hover {
837
+ cursor: help !important;
838
+ background-color: rgba(168, 85, 247, 0.1) !important;
839
+ outline: 1px dashed rgba(168, 85, 247, 0.4) !important;
840
+ }
841
+ bw-widget.bw-simplify-mode *:hover, .bw-ai-tooltip *:hover {
842
+ cursor: inherit !important;
843
+ background-color: transparent !important;
844
+ outline: none !important;
845
+ }
846
+ .bw-ai-tooltip {
847
+ position: absolute;
848
+ width: 320px;
849
+ background: #ffffff;
850
+ border: 1px solid #e2e8f0;
851
+ border-radius: 12px;
852
+ box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
853
+ color: #0f172a;
854
+ font-family: system-ui, -apple-system, sans-serif;
855
+ z-index: 999999;
856
+ overflow: hidden;
857
+ animation: bwAiFadeIn 0.2s ease-out;
858
+ }
859
+ .bw-ai-tooltip[data-theme="dark"] {
860
+ background: #1e293b;
861
+ border-color: #334155;
862
+ color: #f8fafc;
863
+ }
864
+ .bw-ai-tooltip-header {
865
+ display: flex;
866
+ justify-content: space-between;
867
+ align-items: center;
868
+ padding: 8px 12px;
869
+ background: #f8fafc;
870
+ border-bottom: 1px solid #e2e8f0;
871
+ font-size: 11px;
872
+ font-weight: 700;
873
+ color: #64748b;
874
+ }
875
+ .bw-ai-tooltip[data-theme="dark"] .bw-ai-tooltip-header {
876
+ background: #0f172a;
877
+ border-bottom-color: #334155;
878
+ color: #94a3b8;
879
+ }
880
+ .bw-ai-tooltip-close {
881
+ background: transparent;
882
+ border: none;
883
+ color: inherit;
884
+ cursor: pointer;
885
+ font-size: 14px;
886
+ padding: 2px 6px;
887
+ border-radius: 4px;
888
+ }
889
+ .bw-ai-tooltip-close:hover {
890
+ background: rgba(0,0,0,0.05);
891
+ }
892
+ .bw-ai-tooltip[data-theme="dark"] .bw-ai-tooltip-close:hover {
893
+ background: rgba(255,255,255,0.1);
894
+ }
895
+ .bw-ai-tooltip-content {
896
+ padding: 14px;
897
+ font-size: 14px;
898
+ line-height: 1.6;
899
+ }
900
+ .bw-ai-tooltip-loading .bw-ai-tooltip-content {
901
+ display: flex;
902
+ align-items: center;
903
+ gap: 10px;
904
+ color: #64748b;
905
+ font-style: italic;
906
+ font-size: 13px;
907
+ }
908
+ @keyframes bwAiFadeIn {
909
+ from { opacity: 0; transform: translateY(4px); }
910
+ to { opacity: 1; transform: translateY(0); }
911
+ }
912
+ `,document.head.appendChild(e)}document.body.classList.add(`bw-simplify-mode`)}else document.body.removeEventListener(`click`,this._onParagraphClick,{capture:!0}),document.body.classList.remove(`bw-simplify-mode`),document.documentElement.style.removeProperty(`--bw-simplify-cursor`);this.host.requestUpdate()}},jt=`bw-tts-enabled-v1`,Mt=class{constructor(){this.enabled=!0,this.enabled=this.loadEnabled()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e;try{localStorage.setItem(jt,e?`1`:`0`)}catch{}e||this.stop()}stop(){`speechSynthesis`in window&&window.speechSynthesis.cancel()}speak(e){if(!this.enabled||!(`speechSynthesis`in window))return;let t=(e||``).trim();if(t)try{window.speechSynthesis.cancel();let e=new SpeechSynthesisUtterance(t),n=this.detectLanguage(t);e.lang=n;let r=this.pickVoice(n);r&&(e.voice=r),e.rate=1,e.pitch=1,window.speechSynthesis.speak(e)}catch(e){console.warn(`TTS speak failed`,e)}}loadEnabled(){try{let e=localStorage.getItem(jt);return e===null?!0:e!==`0`}catch{return!0}}detectLanguage(e){let t=e.toLowerCase();return/[әіңғүұқөһ]/i.test(t)?`kk-KZ`:/[а-яё]/i.test(t)?`ru-RU`:/[a-z]/i.test(t)?`en-US`:`ru-RU`}pickVoice(e){if(!(`speechSynthesis`in window))return null;let t=window.speechSynthesis.getVoices();if(!t||t.length===0)return null;let n=e.split(`-`)[0].toLowerCase();return t.find(t=>t.lang.toLowerCase()===e.toLowerCase())||t.find(e=>e.lang.toLowerCase().startsWith(n))||t[0]||null}};Tt();var Nt=`http://localhost:8000`,Pt=5,Ft=[/(submit|отправить|оплатить|сгенерировать|сохранить|перевести|подтвердит|купить|удалить|delete|pay|purchase|buy|send|transfer|confirm|place.?order|checkout|remove|drop|unsubscribe|sign.?out|выйти|уволить)/i];function It(e){if(e.type!==`click_element`||!e.element_id)return!1;let t=document.getElementById(e.element_id);if(!t)return!1;if(t.getAttribute(`type`)===`submit`||t.tagName.toLowerCase()===`button`&&t.closest(`form`)!==null&&t.getAttribute(`type`)!==`button`)return!0;let n=[t.textContent?.trim()||``,t.getAttribute(`aria-label`)||``,t.getAttribute(`title`)||``,t.getAttribute(`name`)||``,t.getAttribute(`value`)||``].join(` `);return Ft.some(e=>e.test(n))}var Lt=class{constructor(e){this.messages=[],this.isLoading=!1,this.error=null,this._tts=new Mt,this._voiceMode=!1,this.pendingConfirmation=null,(this.host=e).addController(this),this._loadMessages()}hostConnected(){}hostDisconnected(){this._tts.stop()}_loadMessages(){try{let e=sessionStorage.getItem(`bw-chat-history`);e&&(this.messages=JSON.parse(e),this.messages.length>0&&typeof this.host.setOpen==`function`&&setTimeout(()=>this.host.setOpen(!0),100));let t=sessionStorage.getItem(`bw-auto-resume`);if(t===`true`||t===`verify-only`){sessionStorage.removeItem(`bw-auto-resume`);let e=t===`verify-only`?`Страница загрузилась после отправки формы. Проверь новый DOM: если авторизация прошла успешно (нет формы входа, есть контент приложения) — сообщи об успехе. НЕ нажимай ничего снова.`:`Страница загрузилась. Продолжай выполнение задачи с учетом нового контекста и DOM.`;setTimeout(()=>{this._agentStep(e)},1e3)}}catch(e){console.error(`Failed to load chat history`,e)}}_saveMessages(){try{sessionStorage.setItem(`bw-chat-history`,JSON.stringify(this.messages))}catch(e){console.error(`Failed to save chat history`,e)}}gatherContext(){let e=window.location.href,t=document.body?.innerText?.slice(0,3e3)??``,n=Array.from(document.querySelectorAll(`a[href], button, [role="button"], input:not([type="hidden"]), textarea, select`)).filter(e=>!e.hasAttribute(`bw-private`)).map(e=>{let t=e,n=t.tagName.toLowerCase(),r=n===`input`||n===`textarea`||n===`select`,i=t.getAttribute(`type`)||(n===`input`?`text`:n===`button`?`button`:n),a=t.getAttribute(`name`)||``,o=t.getAttribute(`placeholder`)||``,s=r?(t.value||``).slice(0,80):``;s&&=(s=s.replace(/\b\d{13,19}\b/g,e=>e.slice(0,4)+` **** **** `+e.slice(-4)),s.replace(/\b\d{12}\b/g,`**** **** ****`));let c=t.id&&!t.getAttribute(`data-bw-auto`)?t.id:t.getAttribute(`data-id`)||t.getAttribute(`data-testid`)||``;if(!c){let e=`${n}|${i}|${a}|${o}|${(t.className||``).toString().replace(/\s+/g,`-`).slice(0,40)}|${t.href||``}|${(t.textContent||``).trim().slice(0,30)}|${t.parentElement?.tagName?.toLowerCase()||`root`}`,r=5381;for(let t=0;t<e.length;t++)r=(r<<5)+r^e.charCodeAt(t);c=`bw-${(r>>>0).toString(16)}`,t.id=c,t.setAttribute(`data-bw-auto`,`true`)}let l=t.getAttribute(`aria-label`)||``;if(!l&&c){let e=document.querySelector(`label[for="${c}"]`);e&&(l=e.textContent?.trim()||``)}if(!l){let e=t.parentElement;for(;e&&e.tagName.toLowerCase()!==`form`&&e.tagName.toLowerCase()!==`body`;){if(e.tagName.toLowerCase()===`label`){l=(e.textContent||``).replace(t.textContent||``,``).trim();break}e=e.parentElement}}if(l||=(t.textContent||``).trim().slice(0,80),l||=t.getAttribute(`title`)||``,!l&&o&&(l=o),!l&&n===`button`){let e=t.querySelector(`svg`);if(e&&typeof e.className?.baseVal==`string`){let t=e.className.baseVal.match(/lucide-([a-z0-9\-]+)/);l=t?`[icon:${t[1]}]`:`[icon]`}else l=`[btn:${(t.className||``).toString().slice(0,30)}]`}return{id:c,label:l.trim(),tag:n,type:i,name:a,placeholder:o,value:s}}).filter(e=>e.label.length>0||(e.placeholder??``).length>0||(e.name??``).length>0).slice(0,100).map(e=>`[`+[e.tag,e.type||``,e.id,e.name||``,e.placeholder||``,e.value||``,e.label].join(`|`)+`]`).join(``),r=t;return r=r.replace(/\b\d{13,19}\b/g,`**** **** **** ****`),r=r.replace(/\b\d{12}\b/g,`**** **** ****`),{page_text:r,elements:n,page_url:e}}executeAction(e){if(e.type===`click_element`&&e.element_id){let t=document.getElementById(e.element_id);if(t){if(t.tagName.toLowerCase()===`a`&&t.href){let n=t.href;return new URL(n,window.location.origin).origin===window.location.origin&&sessionStorage.setItem(`bw-auto-resume`,`true`),t.click(),{result:`✅ Нажал на "${t.textContent?.trim()||e.element_id}"`,causesNavigation:!0}}return t.getAttribute(`type`)===`submit`||t.tagName.toLowerCase()===`button`&&t.closest(`form`)!==null&&t.getAttribute(`type`)!==`button`?(sessionStorage.setItem(`bw-auto-resume`,`verify-only`),t.click(),{result:`✅ Нажал на "${t.textContent?.trim()||e.element_id}"`,causesNavigation:!0}):(t.click(),{result:`✅ Нажал на "${t.textContent?.trim()||e.element_id}"`,causesNavigation:!1})}return{result:`⚠️ Элемент "${e.element_id}" не найден.`,causesNavigation:!1}}if(e.type===`navigate`&&e.url)return sessionStorage.setItem(`bw-auto-resume`,`true`),window.location.href=e.url,{result:`🔀 Перехожу на ${e.url}...`,causesNavigation:!0};if(e.type===`input_text`&&e.element_id&&e.value!==void 0){let t=document.getElementById(e.element_id);if(t){let n=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set,r=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,`value`)?.set;return t.tagName.toLowerCase()===`textarea`&&r?r.call(t,e.value):n?n.call(t,e.value):t.value=e.value,t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0})),{result:`⌨️ Ввел текст "${e.value}" в поле.`,causesNavigation:!1}}return{result:`⚠️ Поле ввода "${e.element_id}" не найдено.`,causesNavigation:!1}}return e.type===`continue`?{result:`🔄 Анализирую страницу...`,causesNavigation:!1}:{result:`⚠️ Неизвестное действие.`,causesNavigation:!1}}async _callAPI(e){let{page_text:t,elements:n,page_url:r}=this.gatherContext(),i=q(),a=this.host.clientId||window.__BARIWEB_CLIENT_ID__||``,o=null;try{let e=await fetch(`${Nt}/v1/training/match-screen`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Client-ID":a},body:JSON.stringify({fingerprint:i})});if(e.ok){let t=await e.json();t.matched&&(o=t.label)}}catch(e){console.warn(`Failed to match screen fingerprint`,e)}let s=await fetch(`${Nt}/v1/chat`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Client-ID":a},body:JSON.stringify({query:e,history:this._compressedHistory(),page_text:t,elements:n,page_url:r,screen_label:o,screen_fingerprint:i})});if(!s.ok)throw Error(`HTTP ${s.status}: ${s.statusText}`);let c=await s.json();if(c.text&&c.text.trimStart().startsWith(`{`))try{let e=JSON.parse(c.text);e.text&&(c.text=e.text,e.action&&!c.action&&(c.action=e.action))}catch{c.text=c.text.replace(/^\{"text"\s*:\s*"/,``).replace(/",?\s*"action".*$/,``)}return c}_compressedHistory(){let e=this.messages.map(e=>({role:e.role,text:e.text}));if(e.length<=3)return e;let t=-1;for(let n=e.length-1;n>=0;n--)if(e[n].role===`user`){t=n;break}return t===-1?e.slice(-3):[e[t],...e.slice(t+1).filter(e=>e.role===`assistant`).slice(-2)]}async _agentLoop(e,t,n=!1){if(this.isLoading)return;this.isLoading=!0,this.error=null,this._voiceMode=n,t&&(this.messages=[...this.messages,{role:`user`,text:e,timestamp:Date.now()}],this._saveMessages()),this.host.requestUpdate();let r=e,i=0;try{for(;i<Pt;){i++;let e=await this._callAPI(r),t=e.text;if(e.action){if(It(e.action)){let t=document.getElementById(e.action.element_id||``)?.textContent?.trim()||e.action.element_id||`кнопку`;this.pendingConfirmation={text:`${e.text}\n\n⚠️ Нажать «${t}»?`,action:e.action,currentQuery:r,step:i},this.messages=[...this.messages,{role:`assistant`,text:`${e.text}\n\n🛑 **Подтвердите действие:** нажать «${t}»?`,timestamp:Date.now()}],this._saveMessages(),this._voiceMode&&this._tts.speak(e.text),this.isLoading=!1,this.host.requestUpdate();return}let n=this.gatherContext().page_text,{result:a,causesNavigation:o}=this.executeAction(e.action);if(e.action.type===`continue`){this.messages=[...this.messages,{role:`assistant`,text:`🔄 Анализирую...`,timestamp:Date.now()}],this._saveMessages(),this._voiceMode&&this._tts.speak(`Анализирую...`),this.host.requestUpdate(),await this._waitForDom(800),r=`Страница обновилась. Продолжай задачу, прочитай DOM.`;continue}if(t=`${e.text}\n${a}`,o){this.messages=[...this.messages,{role:`assistant`,text:t,timestamp:Date.now()}],this._saveMessages(),this._voiceMode&&this._tts.speak(t),this.host.requestUpdate(),await this._waitForDom(1500);let e=sessionStorage.getItem(`bw-auto-resume`);if(e===`true`||e===`verify-only`){sessionStorage.removeItem(`bw-auto-resume`),r=e===`verify-only`?`Страница загрузилась после отправки формы (SPA навигация). Проверь новый DOM: если задача выполнена — сообщи об успехе. НЕ нажимай ничего снова.`:`Страница загрузилась (SPA навигация). Продолжай задачу, прочитай новый DOM.`;continue}break}this.messages=[...this.messages,{role:`assistant`,text:t,timestamp:Date.now()}],this._saveMessages(),this._voiceMode&&this._tts.speak(t),this.host.requestUpdate(),e.action.type===`input_text`&&e.action.element_id?(await this._waitForDom(800),r=(document.getElementById(e.action.element_id)?.value??``).length>0?`✅ Поле заполнено. Переходи к СЛЕДУЮЩЕМУ незаполненному полю или нажми кнопку отправки. НЕ повторяй ввод.`:`⚠️ Поле не получило значение. Попробуй ввести снова в id="${e.action.element_id}".`):(await this._waitForDom(800),r=n===this.gatherContext().page_text?`⚠️ Страница не изменилась. Возможно кнопка не сработала. Проверь DOM.`:`Действие выполнено. Если задача готова — сообщи. Иначе продолжай.`);continue}this.messages=[...this.messages,{role:`assistant`,text:t,timestamp:Date.now()}],this._saveMessages(),this._voiceMode&&this._tts.speak(t);break}}catch(e){this.error=e.message??`Ошибка соединения`,this.messages=[...this.messages,{role:`assistant`,text:`❌ Ошибка: ${this.error}`,timestamp:Date.now()}],this._saveMessages(),this._voiceMode&&this._tts.speak(`Ошибка: ${this.error}`)}finally{this.isLoading=!1,this.host.requestUpdate()}}async confirmAction(){if(!this.pendingConfirmation)return;let{action:e}=this.pendingConfirmation;this.pendingConfirmation=null,this.messages=[...this.messages,{role:`user`,text:`✅ Подтверждаю`,timestamp:Date.now()}],this._saveMessages(),this.host.requestUpdate();let{result:t,causesNavigation:n}=this.executeAction(e);this.messages=[...this.messages,{role:`assistant`,text:t,timestamp:Date.now()}],this._saveMessages(),this._voiceMode&&this._tts.speak(t),this.host.requestUpdate(),!n&&(await this._waitForDom(1200),await this._agentStep(`Действие подтверждено и выполнено. Проверь результат в DOM.`))}cancelAction(){this.pendingConfirmation&&(this.pendingConfirmation=null,this.messages=[...this.messages,{role:`user`,text:`❌ Отмена`,timestamp:Date.now()},{role:`assistant`,text:`🚫 Действие отменено. Чем ещё могу помочь?`,timestamp:Date.now()}],this._saveMessages(),this._voiceMode&&this._tts.speak(`Действие отменено. Чем ещё могу помочь?`),this.host.requestUpdate())}_waitForDom(e){return new Promise(t=>setTimeout(t,e))}async sendMessage(e,t=!1){!e.trim()||this.isLoading||(await this._agentLoop(e,!0,t),this.host.updateComplete?.then(()=>{let e=this.host.renderRoot?.querySelector(`.chat-messages`);e&&(e.scrollTop=e.scrollHeight)}))}async _agentStep(e){await this._agentLoop(e,!1,this._voiceMode),this.host.updateComplete?.then(()=>{let e=this.host.renderRoot?.querySelector(`.chat-messages`);e&&(e.scrollTop=e.scrollHeight)})}clearMessages(){this.messages=[],this.error=null,this.pendingConfirmation=null,this._saveMessages(),this.host.requestUpdate()}isTtsEnabled(){return this._tts.isEnabled()}setTtsEnabled(e){this._tts.setEnabled(e),this.host.requestUpdate()}async transcribeAudio(e,t){let n=this.host.clientId||window.__BARIWEB_CLIENT_ID__||``,r=new FormData;r.append(`language_mode`,t),r.append(`audio`,e,`speech.wav`);let i=await fetch(`${Nt}/v1/stt/transcribe`,{method:`POST`,headers:{"X-Client-ID":n},body:r});if(!i.ok){let e=`HTTP ${i.status}`;try{e=(await i.json())?.detail||e}catch{}throw Error(e)}return await i.json()}};function Y(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var Rt=n({initAdminMode:()=>Ht,mountAdminPanel:()=>Vt});function zt(){if(!X)return;let e=K(),t=q(),n=Z?.is_trained===!0,r=Z&&!Z.is_trained,i=Z?.label||null,a=Z?.description||null,o=n?`active`:r?`draft`:`idle`,s=n?`trained`:r?`draft`:`idle`,c=n?`✅ Обучено`:r?`📝 Черновик (не подтверждено)`:`🔍 Сканирование...`,l=X.querySelector(`#bw-admin-panel`);l&&(l.className=n?`trained`:`discovering`,l.id=`bw-admin-panel`,n&&l.classList.add(`trained`));let u=X.querySelector(`#bw-panel-content`);u&&(u.innerHTML=`
913
+ <div class="bw-status-box ${n?`trained`:r?`draft`:``}">
914
+ <div class="bw-status-indicator">
915
+ <span class="bw-status-dot ${o}"></span>
916
+ <span class="bw-status-text ${s}">${c}</span>
917
+ </div>
918
+ ${i?`<div class="bw-label-display">${i}</div>`:``}
919
+ ${a?`<div class="bw-desc-display">${a}</div>`:``}
920
+ </div>
921
+
922
+ <div class="bw-fp-mini">🔑 ${t}</div>
923
+
924
+ <div class="bw-tokens-list">
925
+ ${e.map(e=>`<span class="bw-token-tag" data-token="${e}">${e}</span>`).join(``)}
926
+ </div>
927
+
928
+ <div class="bw-discovery-bar">
929
+ <div class="spinner"></div>
930
+ 🤖 Система обучается в фоновом режиме...
931
+ </div>
932
+ `,u.querySelectorAll(`.bw-token-tag`).forEach(e=>{let t=e;t.onmouseenter=()=>Bt(t.dataset.token||``),t.onmouseleave=()=>document.querySelectorAll(`.bw-highlight-rect`).forEach(e=>e.remove())}))}function Bt(e){document.querySelectorAll(`.bw-highlight-rect`).forEach(e=>e.remove());let t=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT),n;for(;n=t.nextNode();)if((n.innerText||``).toLowerCase()===e.toLowerCase()&&n.offsetWidth>0){let e=n.getBoundingClientRect(),t=document.createElement(`div`);t.className=`bw-highlight-rect`,t.style.top=`${e.top+window.scrollY}px`,t.style.left=`${e.left+window.scrollX}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,document.body.appendChild(t)}}async function Vt(){if(X)return;let e=document.createElement(`div`);e.id=`bw-admin-wrapper`,e.innerHTML=`
933
+ <style>${Ut}</style>
934
+ <div id="bw-admin-panel">
935
+ <div class="bw-panel-header">
936
+ <span class="bw-panel-title">🧠 Discovery Mode</span>
937
+ <button class="bw-panel-close" id="bw-admin-close">✕</button>
938
+ </div>
939
+ <div id="bw-panel-content"></div>
940
+ </div>
941
+ `,document.body.appendChild(e),X=e;let t=e.querySelector(`#bw-admin-close`);t.onclick=()=>{X?.remove(),X=null},J.onDiscovery(e=>{Z=e,zt()}),zt(),await J.forceDiscovery()}function Ht(){Vt()}var Ut,X,Z,Wt=t((()=>{Ot(),Tt(),Ut=`
942
+ #bw-admin-panel {
943
+ position: fixed;
944
+ bottom: 160px;
945
+ right: 20px;
946
+ z-index: 2147483647;
947
+ width: 320px;
948
+ background: #0f172a;
949
+ border: 1px solid #334155;
950
+ border-radius: 16px;
951
+ padding: 16px;
952
+ box-shadow: 0 12px 50px rgba(0,0,0,0.6);
953
+ font-family: Inter, system-ui, sans-serif;
954
+ color: #f1f5f9;
955
+ transition: border-color 0.3s;
956
+ }
957
+ #bw-admin-panel.trained {
958
+ border-color: #10b981;
959
+ }
960
+ #bw-admin-panel.discovering {
961
+ border-color: #a78bfa;
962
+ }
963
+
964
+ .bw-panel-header {
965
+ display: flex;
966
+ justify-content: space-between;
967
+ align-items: center;
968
+ margin-bottom: 12px;
969
+ }
970
+ .bw-panel-title {
971
+ font-size: 13px;
972
+ font-weight: 700;
973
+ color: #a78bfa;
974
+ }
975
+ .bw-panel-close {
976
+ background: none;
977
+ border: none;
978
+ color: #64748b;
979
+ cursor: pointer;
980
+ font-size: 16px;
981
+ padding: 0;
982
+ line-height: 1;
983
+ }
984
+ .bw-panel-close:hover { color: #f87171; }
985
+
986
+ .bw-status-box {
987
+ background: #1e293b;
988
+ border-radius: 10px;
989
+ padding: 12px;
990
+ margin-bottom: 12px;
991
+ border: 1px solid #334155;
992
+ transition: all 0.3s;
993
+ }
994
+ .bw-status-box.trained {
995
+ border-color: #10b981;
996
+ background: rgba(16, 185, 129, 0.08);
997
+ }
998
+ .bw-status-box.draft {
999
+ border-color: #f59e0b;
1000
+ background: rgba(245, 158, 11, 0.05);
1001
+ }
1002
+
1003
+ .bw-status-indicator {
1004
+ display: flex;
1005
+ align-items: center;
1006
+ gap: 8px;
1007
+ margin-bottom: 6px;
1008
+ }
1009
+ .bw-status-dot {
1010
+ width: 8px;
1011
+ height: 8px;
1012
+ border-radius: 50%;
1013
+ flex-shrink: 0;
1014
+ }
1015
+ .bw-status-dot.active { background: #4ade80; box-shadow: 0 0 8px #4ade80; animation: bw-pulse 2s infinite; }
1016
+ .bw-status-dot.draft { background: #f59e0b; }
1017
+ .bw-status-dot.idle { background: #475569; }
1018
+
1019
+ @keyframes bw-pulse {
1020
+ 0%, 100% { opacity: 1; }
1021
+ 50% { opacity: 0.4; }
1022
+ }
1023
+
1024
+ .bw-status-text {
1025
+ font-size: 11px;
1026
+ font-weight: 600;
1027
+ }
1028
+ .bw-status-text.trained { color: #4ade80; }
1029
+ .bw-status-text.draft { color: #f59e0b; }
1030
+ .bw-status-text.idle { color: #94a3b8; }
1031
+
1032
+ .bw-label-display {
1033
+ font-size: 14px;
1034
+ font-weight: 700;
1035
+ color: #e2e8f0;
1036
+ margin: 4px 0;
1037
+ word-break: break-word;
1038
+ }
1039
+ .bw-desc-display {
1040
+ font-size: 11px;
1041
+ color: #94a3b8;
1042
+ line-height: 1.4;
1043
+ margin-top: 4px;
1044
+ }
1045
+
1046
+ .bw-fp-mini {
1047
+ font-family: monospace;
1048
+ font-size: 9px;
1049
+ color: #475569;
1050
+ margin-bottom: 10px;
1051
+ word-break: break-all;
1052
+ }
1053
+
1054
+ .bw-tokens-list {
1055
+ display: flex;
1056
+ flex-wrap: wrap;
1057
+ gap: 4px;
1058
+ }
1059
+ .bw-token-tag {
1060
+ background: #334155;
1061
+ color: #e2e8f0;
1062
+ font-size: 9px;
1063
+ padding: 2px 6px;
1064
+ border-radius: 4px;
1065
+ cursor: help;
1066
+ transition: all 0.15s;
1067
+ }
1068
+ .bw-token-tag:hover {
1069
+ background: #7c3aed;
1070
+ color: white;
1071
+ transform: translateY(-1px);
1072
+ }
1073
+
1074
+ .bw-discovery-bar {
1075
+ display: flex;
1076
+ align-items: center;
1077
+ gap: 6px;
1078
+ padding: 8px 10px;
1079
+ background: rgba(167, 139, 250, 0.08);
1080
+ border: 1px solid rgba(167, 139, 250, 0.2);
1081
+ border-radius: 8px;
1082
+ font-size: 10px;
1083
+ color: #a78bfa;
1084
+ margin-top: 8px;
1085
+ }
1086
+ .bw-discovery-bar .spinner {
1087
+ width: 12px;
1088
+ height: 12px;
1089
+ border: 2px solid rgba(167, 139, 250, 0.3);
1090
+ border-top-color: #a78bfa;
1091
+ border-radius: 50%;
1092
+ animation: bw-spin 0.8s linear infinite;
1093
+ }
1094
+ @keyframes bw-spin {
1095
+ to { transform: rotate(360deg); }
1096
+ }
1097
+
1098
+ .bw-highlight-rect {
1099
+ position: absolute;
1100
+ pointer-events: none;
1101
+ border: 2px solid #7c3aed;
1102
+ background: rgba(124, 58, 237, 0.1);
1103
+ box-shadow: 0 0 10px #7c3aed;
1104
+ z-index: 100000;
1105
+ border-radius: 4px;
1106
+ transition: all 0.15s ease-out;
1107
+ }
1108
+ `,X=null,Z=null}));Ot();var Gt=`bw-stt-lang-v1`,Kt=200,qt=.015,Jt=1200,Yt=2e4,Xt=350,Q={kz:{langLabel:`Тану және виджет тілі`,langKz:`Қазақша`,langRu:`Орысша`,langEn:`Ағылшынша`,chatTab:`💬 Чат`,settingsTab:`♿ Баптаулар`,brandSub:`Инклюзия`,madeIn:`Қазақстанда жасалған 🇰🇿`,voiceBtnInit:`Дауыс`,voiceBtnRec:`Жазылуда...`,micBannerRec:`🎙️ Тыңдаудамын... (тыныштық болса тоқтаймын)`,micBannerWait:`⏳ Сөзді тану...`,micBannerErr:`⚠️`,micAriaL:`Голостық енгізуді қосу (жазу үшін ұстап тұрыңыз)`,inputAriaL:`Хабарламаны енгізу өрісі`,inputPl:`Хабарлама енгізіңіз...`,ttsAriaOn:`Жауапты дыбыстауды өшіру`,ttsAriaOff:`Жауапты дыбыстауды қосу`,sendAria:`Хабарлама жіберу`,onPage:`Бетте:`,emptyChatTitle:`Сіздің көмекшіңіз`,emptyChatSub:`Тапсырманы сипаттаңыз — мен қажетті түймелерді тауып, өрістерді сіз үшін толтырамын.`,confirmAction:`✅ Әрекетті растау`,cancelAction:`Болдырмау`,textScale:`Мәтін өлшемі`,monochrome:`А/Қ`,monochromeVal:`Монохром`,contrast:`Контраст`,contrastVal:`Қараңғы`,links:`Сілтемелер`,linksVal:`Ерекшелеу`,spacing:`Аралық`,spacingVal:`Үлкейту`,font:`Қаріп`,fontVal:`Дислексия`,cursor:`Курсор`,cursorVal:`Үлкейту`,colorSettingsTitle:`Түс баптаулары`,colorBg:`Фон`,colorHeader:`Бас киім`,colorText:`Мәтін`,aiSimplifyTitle:`AI Мәтінді оңтайландыру`,aiBlindTitle:`Зағиптар режимі (AI)`,on:`ҚОСУЛЫ`,off:`ӨШІРУЛІ`,closeAria:`Жабу`},ru:{langLabel:`Язык распознавания и виджета`,langKz:`Казахский`,langRu:`Русский`,langEn:`Английский`,chatTab:`💬 Чат`,settingsTab:`♿ Настройки`,brandSub:`Инклюзия`,madeIn:`Сделано в Казахстане 🇰🇿`,voiceBtnInit:`Нажмите`,voiceBtnRec:`Запись...`,micBannerRec:`🎙️ Слушаю... (остановлюсь по тишине)`,micBannerWait:`⏳ Распознаю речь...`,micBannerErr:`⚠️`,micAriaL:`Включить голосовой ввод (удерживайте для записи)`,inputAriaL:`Текстовое поле ввода сообщения`,inputPl:`Введите сообщение...`,ttsAriaOn:`Выключить озвучку ответа`,ttsAriaOff:`Включить озвучку ответа`,sendAria:`Отправить сообщение`,onPage:`На странице:`,emptyChatTitle:`Ваш помощник`,emptyChatSub:`Опишите задачу — я найду нужные кнопки и заполню поля за вас.`,confirmAction:`✅ Подтвердить действие`,cancelAction:`Отменить`,textScale:`Размер текста`,monochrome:`Ч/Б`,monochromeVal:`Монохром`,contrast:`Контраст`,contrastVal:`Тёмный`,links:`Ссылки`,linksVal:`Выделить`,spacing:`Отступы`,spacingVal:`Увеличить`,font:`Шрифт`,fontVal:`Дислексия`,cursor:`Курсор`,cursorVal:`Увеличить`,colorSettingsTitle:`Настройка цвета`,colorBg:`Фон`,colorHeader:`Шапка`,colorText:`Текст`,aiSimplifyTitle:`AI Упрощение текста`,aiBlindTitle:`Режим для незрячих (AI)`,on:`ВКЛ`,off:`ВЫКЛ`,closeAria:`Закрыть`},en:{langLabel:`Widget & Recognition Language`,langKz:`Kazakh`,langRu:`Russian`,langEn:`English`,chatTab:`💬 Chat`,settingsTab:`♿ Settings`,brandSub:`Inclusion`,madeIn:`Made in Kazakhstan 🇰🇿`,voiceBtnInit:`Press`,voiceBtnRec:`Recording...`,micBannerRec:`🎙️ Listening... (stops on silence)`,micBannerWait:`⏳ Recognizing...`,micBannerErr:`⚠️`,micAriaL:`Enable voice input (hold to record)`,inputAriaL:`Text input field`,inputPl:`Type a message...`,ttsAriaOn:`Disable answer TTS`,ttsAriaOff:`Enable answer TTS`,sendAria:`Send message`,onPage:`On page:`,emptyChatTitle:`Your Assistant`,emptyChatSub:`Describe the task — I will find buttons and fill fields for you.`,confirmAction:`✅ Confirm Action`,cancelAction:`Cancel`,textScale:`Text size`,monochrome:`B/W`,monochromeVal:`Monochrome`,contrast:`Contrast`,contrastVal:`Dark`,links:`Links`,linksVal:`Highlight`,spacing:`Spacing`,spacingVal:`Increase`,font:`Font`,fontVal:`Dyslexia`,cursor:`Cursor`,cursorVal:`Increase`,colorSettingsTitle:`Color Settings`,colorBg:`Bg`,colorHeader:`Header`,colorText:`Text`,aiSimplifyTitle:`AI Text Simplification`,aiBlindTitle:`Blind Mode (AI)`,on:`ON`,off:`OFF`,closeAria:`Close`}},$=class extends R{static{this.styles=[pt]}constructor(){super(),this._a11y=new ht(this),this._aiA11y=new At(this),this._chat=new Lt(this),this.clientId=``,this._isOpen=!1,this._activeTab=`chat`,this._inputValue=``,this._isAdmin=!1,this._adminPassword=``,this._authError=``,this._currentScreenLabel=``,this._sttState=`idle`,this._sttLanguageMode=`ru`,this._sttError=``,this._adminClickCount=0,this._showAdminLogin=!1,this._mediaStream=null,this._audioContext=null,this._analyser=null,this._scriptProcessor=null,this._pcmChunks=[],this._sampleRate=44100,this._recordingStartTs=0,this._silenceStartedTs=null,this._silenceIntervalId=null,this._maxDurationTimeoutId=null,this._adminClickTimer=null,this._handleGlobalKeydown=e=>{this._isOpen&&e.altKey&&e.code===`KeyV`&&(e.preventDefault(),this._toggleVoice())};try{let e=localStorage.getItem(Gt);(e===`kz`||e===`ru`||e===`en`)&&(this._sttLanguageMode=e)}catch{}this._checkAuthStatus()}_setSttLanguageMode(e){this._sttLanguageMode=e;try{localStorage.setItem(Gt,e)}catch{}}async _checkAuthStatus(){let e=localStorage.getItem(`bw_admin_token`);if(e)try{(await fetch(`http://localhost:8000/auth/login/widget/verify`,{headers:{Authorization:`Bearer ${e}`}})).ok?(this._isAdmin=!0,this._loadAdminUI()):localStorage.removeItem(`bw_admin_token`)}catch{try{let t=JSON.parse(atob(e.split(`.`)[1]));t.exp*1e3>Date.now()&&t.role===`admin`?(this._isAdmin=!0,this._loadAdminUI()):localStorage.removeItem(`bw_admin_token`)}catch{localStorage.removeItem(`bw_admin_token`)}}}async _loadAdminUI(){try{let{initAdminMode:e}=await Promise.resolve().then(()=>(Wt(),Rt));e(),J.isAutoDiscoveryEnabled=!0}catch(e){console.error(`Admin UI load failed`,e)}}async _handleAdminLogin(){if(this._authError=``,!this.clientId){this._authError=`Client ID not configured`;return}try{let e=await fetch(`http://localhost:8000/auth/login/widget`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({client_public_id:this.clientId,admin_key:this._adminPassword})});if(e.ok){let{access_token:t}=await e.json();localStorage.setItem(`bw_admin_token`,t),this._isAdmin=!0,this._showAdminLogin=!1,this._loadAdminUI()}else this._authError=(await e.json().catch(()=>({}))).detail||`Invalid admin key`}catch{this._authError=`Connection failed`}}_handleAdminLogout(){localStorage.removeItem(`bw_admin_token`),this._isAdmin=!1,this._adminPassword=``,this._showAdminLogin=!1,J.isAutoDiscoveryEnabled=!1,document.querySelector(`#bw-admin-wrapper`)?.remove()}_handleLogoClick(){this._adminClickCount++,this._adminClickCount>=5&&(this._showAdminLogin=!this._showAdminLogin,this._adminClickCount=0),this._adminClickTimer&&clearTimeout(this._adminClickTimer),this._adminClickTimer=setTimeout(()=>{this._adminClickCount=0},2e3)}connectedCallback(){super.connectedCallback(),J.start(),J.onStateChange(async e=>{try{let t=await fetch(`http://localhost:8000/v1/training/match-screen`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Client-ID":this.clientId||window.__BARIWEB_CLIENT_ID__||``},body:JSON.stringify({fingerprint:e.fingerprint})});if(t.ok){let e=await t.json();this._currentScreenLabel=e.matched?e.label:``}}catch{}}),window.addEventListener(`keydown`,this._handleGlobalKeydown)}disconnectedCallback(){super.disconnectedCallback(),J.stop(),this._cleanupRecording(),window.removeEventListener(`keydown`,this._handleGlobalKeydown)}_beep(e){let t=new(window.AudioContext||window.webkitAudioContext),n=t.createOscillator(),r=t.createGain();n.type=`sine`,n.frequency.setValueAtTime(e,t.currentTime),r.gain.setValueAtTime(.1,t.currentTime),r.gain.exponentialRampToValueAtTime(1e-5,t.currentTime+.1),n.connect(r),r.connect(t.destination),n.start(),n.stop(t.currentTime+.1)}_toggle(){this._isOpen=!this._isOpen}setOpen(e){this._isOpen=e}_setTab(e){this._activeTab=e}_handleInput(e){this._inputValue=e.target.value}_handleKeydown(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),this._handleSend()),e.code===`Space`&&e.target.tagName!==`INPUT`&&(e.preventDefault(),this._sttState===`idle`&&this._startRecording())}async _handleSend(){let e=this._inputValue.trim();!e||this._chat.isLoading||this._sttState!==`idle`||(this._inputValue=``,await this._chat.sendMessage(e,!1),this._scrollMessages())}_scrollMessages(){this.updateComplete.then(()=>{this._messagesEl&&(this._messagesEl.scrollTop=this._messagesEl.scrollHeight)})}_getCurrentHue(){let e=this._a11y.settings;return e.activeColorTab===`background`?e.customBgHue||0:e.activeColorTab===`header`?e.customHeaderHue||0:e.customContentHue||0}_clearSttTimers(){this._silenceIntervalId!==null&&(window.clearInterval(this._silenceIntervalId),this._silenceIntervalId=null),this._maxDurationTimeoutId!==null&&(window.clearTimeout(this._maxDurationTimeoutId),this._maxDurationTimeoutId=null)}_cleanupRecording(){this._clearSttTimers(),this._analyser=null,this._scriptProcessor&&=(this._scriptProcessor.disconnect(),this._scriptProcessor.onaudioprocess=null,null),this._audioContext&&=(this._audioContext.close().catch(()=>{}),null),this._mediaStream&&=(this._mediaStream.getTracks().forEach(e=>e.stop()),null),this._pcmChunks=[],this._silenceStartedTs=null}async _toggleVoice(){if(this._sttState!==`processing`){if(this._sttState===`recording`){this._stopRecording();return}await this._startRecording()}}async _startRecording(){if(!navigator.mediaDevices?.getUserMedia){this._sttState=`error`,this._sttError=`Микрофон не поддерживается.`;return}try{this._cleanupRecording(),this._sttError=``;let e=await navigator.mediaDevices.getUserMedia({audio:!0});this._mediaStream=e,this._pcmChunks=[],this._recordingStartTs=Date.now(),this._silenceStartedTs=null,this._audioContext=new AudioContext,this._sampleRate=this._audioContext.sampleRate;let t=this._audioContext.createMediaStreamSource(e);this._analyser=this._audioContext.createAnalyser(),this._analyser.fftSize=2048,t.connect(this._analyser),this._scriptProcessor=this._audioContext.createScriptProcessor(4096,1,1),t.connect(this._scriptProcessor),this._scriptProcessor.connect(this._audioContext.destination),this._scriptProcessor.onaudioprocess=e=>{this._sttState===`recording`&&(this._pcmChunks.push(new Float32Array(e.inputBuffer.getChannelData(0))),e.outputBuffer.getChannelData(0).fill(0))},this._sttState=`recording`,this._beep(880),this._maxDurationTimeoutId=window.setTimeout(()=>{this._sttState===`recording`&&this._stopRecording()},Yt);let n=new Uint8Array(this._analyser.fftSize);this._silenceIntervalId=window.setInterval(()=>{if(!this._analyser||this._sttState!==`recording`)return;this._analyser.getByteTimeDomainData(n);let e=0;for(let t=0;t<n.length;t++){let r=(n[t]-128)/128;e+=r*r}Math.sqrt(e/n.length)<qt?this._silenceStartedTs?Date.now()-this._silenceStartedTs>=Jt&&this._stopRecording():this._silenceStartedTs=Date.now():this._silenceStartedTs=null},Kt)}catch{this._sttState=`error`,this._sttError=`Нет доступа к микрофону.`,this._cleanupRecording()}}_stopRecording(){this._sttState===`recording`&&(this._clearSttTimers(),this._sttState=`processing`,this._beep(440),this._finalizeRecording().catch(e=>{this._sttState=`error`,this._sttError=e?.message||`Ошибка обработки.`}))}async _finalizeRecording(){let e=Date.now()-this._recordingStartTs,t=this._pcmChunks.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let e of this._pcmChunks)n.set(e,r),r+=e.length;let i=this._encodeWav(n,this._sampleRate);if(this._cleanupRecording(),e<Xt||i.size===0){this._sttState=`error`,this._sttError=`Слишком короткая запись.`;return}try{let e=(await this._chat.transcribeAudio(i,this._sttLanguageMode)).text?.trim();if(!e){this._sttState=`error`,this._sttError=`Речь не распознана.`;return}await this._chat.sendMessage(e,!0),this._sttState=`idle`,this._sttError=``,this._inputValue=``,this._scrollMessages()}catch(e){this._sttState=`error`,this._sttError=e?.message||`Ошибка распознавания.`}}_encodeWav(e,t){let n=t*2,r=e.length*2,i=new ArrayBuffer(44+r),a=new DataView(i),o=(e,t)=>{for(let n=0;n<t.length;n++)a.setUint8(e+n,t.charCodeAt(n))};o(0,`RIFF`),a.setUint32(4,36+r,!0),o(8,`WAVE`),o(12,`fmt `),a.setUint32(16,16,!0),a.setUint16(20,1,!0),a.setUint16(22,1,!0),a.setUint32(24,t,!0),a.setUint32(28,n,!0),a.setUint16(32,2,!0),a.setUint16(34,16,!0),o(36,`data`),a.setUint32(40,r,!0);let s=44;for(let t=0;t<e.length;t++){let n=Math.max(-1,Math.min(1,e[t]));a.setInt16(s,n<0?n*32768:n*32767,!0),s+=2}return new Blob([i],{type:`audio/wav`})}_vibrate(){`vibrate`in navigator&&navigator.vibrate(20)}_renderChatTab(){let e=Q[this._sttLanguageMode],t=this._chat.messages,n=this._chat.isLoading,r=this._chat.pendingConfirmation,i=n||this._sttState!==`idle`;return j`
1109
+ <div class="chat-messages" id="bw-chat-messages">
1110
+ ${this._currentScreenLabel?j`
1111
+ <div class="screen-label-badge">
1112
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" width="12" height="12"><polyline points="20 6 9 17 4 12"/></svg>
1113
+ ${e.onPage} <strong>${this._currentScreenLabel}</strong>
1114
+ </div>
1115
+ `:``}
1116
+
1117
+ ${t.length===0?j`
1118
+ <div class="chat-empty">
1119
+ ${H.accessibility}
1120
+ <p class="chat-empty-title">${e.emptyChatTitle}</p>
1121
+ <p class="chat-empty-sub">${e.emptyChatSub}</p>
1122
+ </div>
1123
+ `:t.map(e=>e.role===`assistant`&&(e.text.includes(`✅`)||e.text.includes(`⌨️`)||e.text.includes(`🔄`))?j`
1124
+ <details class="system-log">
1125
+ <summary class="system-log-header"><span>${e.text.split(`
1126
+ `)[0]}</span></summary>
1127
+ <div class="system-log-details">${e.text}</div>
1128
+ </details>`:j`<div class="chat-bubble ${e.role}">${e.text}</div>`)}
1129
+
1130
+ ${n?j`
1131
+ <div class="typing-indicator">
1132
+ <div class="typing-dot"></div><div class="typing-dot"></div><div class="typing-dot"></div>
1133
+ </div>`:``}
1134
+ </div>
1135
+
1136
+ ${r?j`
1137
+ <div class="confirm-panel">
1138
+ <button class="btn-confirm" @click=${()=>this._chat.confirmAction()} id="bw-confirm-action">
1139
+ ${e.confirmAction}
1140
+ </button>
1141
+ <button class="btn-cancel" @click=${()=>this._chat.cancelAction()} id="bw-cancel-action">
1142
+ ${e.cancelAction}
1143
+ </button>
1144
+ </div>
1145
+ `:j`
1146
+ <div class="chat-input-area">
1147
+ ${this._sttState===`idle`?``:j`
1148
+ <div class="stt-banner ${this._sttState}">
1149
+ ${this._sttState===`recording`?e.micBannerRec:this._sttState===`processing`?e.micBannerWait:`${e.micBannerErr} ${this._sttError}`}
1150
+ </div>`}
1151
+ <div class="chat-input-row">
1152
+ <!-- 🎙️ Primary Mic Button (Large Target Size) -->
1153
+ <button class="chat-icon-btn ${this._sttState===`recording`?`recording`:``}"
1154
+ @mouseenter=${this._vibrate}
1155
+ @focus=${this._vibrate}
1156
+ @mousedown=${this._startRecording}
1157
+ @mouseup=${this._stopRecording}
1158
+ @touchstart=${e=>{e.preventDefault(),this._startRecording(),this._vibrate()}}
1159
+ @touchend=${e=>{e.preventDefault(),this._stopRecording()}}
1160
+ @click=${this._toggleVoice}
1161
+ ?disabled=${this._sttState===`processing`||n}
1162
+ id="bw-voice-btn"
1163
+ aria-label="${e.micAriaL}">
1164
+ ${H.mic}
1165
+ </button>
1166
+
1167
+ <input
1168
+ class="chat-input"
1169
+ type="text"
1170
+ placeholder="${e.inputPl}"
1171
+ .value=${this._inputValue}
1172
+ @input=${this._handleInput}
1173
+ @keydown=${this._handleKeydown}
1174
+ ?disabled=${i}
1175
+ id="bw-chat-input"
1176
+ aria-label="${e.inputAriaL}"
1177
+ />
1178
+
1179
+ <!-- ▶ Send Button -->
1180
+ <button class="chat-send-btn" @click=${this._handleSend}
1181
+ ?disabled=${!this._inputValue.trim()||i}
1182
+ id="bw-send-btn"
1183
+ aria-label="${e.sendAria}">
1184
+ ${H.send}
1185
+ </button>
1186
+ </div>
1187
+ </div>
1188
+ `}
1189
+ `}_renderA11yTab(){let e=Q[this._sttLanguageMode],t=this._a11y.settings,n=[{id:`bw-tile-textscale`,icon:H.textSize,label:e.textScale,value:`${Math.round(t.textScale*100)}%`,active:t.textScale>1,action:()=>this._a11y.incrementTextScale()},{id:`bw-tile-monochrome`,icon:H.visualImpair,label:e.monochrome,value:e.monochromeVal,active:t.monochrome,action:()=>this._a11y.toggleMonochrome()},{id:`bw-tile-contrast`,icon:H.moon,label:e.contrast,value:e.contrastVal,active:t.darkHighContrast,action:()=>this._a11y.toggleDarkHighContrast()},{id:`bw-tile-links`,icon:H.visualImpair,label:e.links,value:e.linksVal,active:t.linkHighlight,action:()=>this._a11y.toggleLinkHighlight()},{id:`bw-tile-spacing`,icon:H.textSize,label:e.spacing,value:e.spacingVal,active:t.textSpacing,action:()=>this._a11y.toggleTextSpacing()},{id:`bw-tile-font`,icon:H.textSize,label:e.font,value:e.fontVal,active:t.dyslexicFont,action:()=>this._a11y.toggleDyslexicFont()},{id:`bw-tile-cursor`,icon:H.cursor,label:e.cursor,value:e.cursorVal,active:t.cursorMagnifier,action:()=>this._a11y.toggleCursorMagnifier()},{id:`bw-tile-voice`,icon:null,label:e.voiceBtnInit,value:this._sttState===`recording`?e.voiceBtnRec:e.voiceBtnInit,active:this._sttState===`recording`,action:()=>this._toggleVoice()}];return j`
1190
+ <div class="a11y-scroller">
1191
+
1192
+ <!-- Language config mapped to TOP of settings tab -->
1193
+ <div style="padding: 16px 16px 0;">
1194
+ <div style="display: flex; align-items: center; justify-content: space-between; padding: 12px; background: var(--bw-bg-subtle, #f8fafc); border-radius: var(--bw-radius, 14px); margin-bottom: 0px;">
1195
+ <div style="display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; color: var(--bw-fg, #1e293b);">
1196
+ ${H.languages} ${e.langLabel}
1197
+ </div>
1198
+ <select style="height: 34px; padding: 0 8px; border: 1px solid var(--bw-primary, #6d28d9); border-radius: 8px; background: rgba(109, 40, 217, 0.05); color: var(--bw-primary, #6d28d9); cursor: pointer; outline: none; font-size: 13px; font-weight: 600;"
1199
+ .value=${this._sttLanguageMode}
1200
+ @change=${e=>{this._setSttLanguageMode(e.target.value),this.requestUpdate()}}
1201
+ aria-label="${e.langLabel}">
1202
+ <option value="kz">${Q.kz.langKz}</option>
1203
+ <option value="ru">${Q.ru.langRu}</option>
1204
+ <option value="en">${Q.en.langEn}</option>
1205
+ </select>
1206
+ </div>
1207
+ </div>
1208
+
1209
+ <div class="settings-grid">
1210
+ ${n.map(e=>j`
1211
+ <button class="settings-card" ?active=${e.active} @click=${e.action} id=${e.id}
1212
+ aria-pressed=${e.active?`true`:`false`} aria-label=${e.label}>
1213
+ ${e.icon||H.mic}
1214
+ <span class="settings-card-label">${e.label}</span>
1215
+ <span class="settings-card-value">${e.value}</span>
1216
+ ${e.active?j`<span class="active-badge">${H.check}</span>`:``}
1217
+ </button>
1218
+ `)}
1219
+ </div>
1220
+
1221
+ <div class="color-section">
1222
+ <div class="color-section-header">
1223
+ ${H.droplet}
1224
+ <h4 class="color-section-title">${e.colorSettingsTitle}</h4>
1225
+ </div>
1226
+ <div class="color-tabs">
1227
+ <button class="color-tab" ?active=${t.activeColorTab===`background`}
1228
+ @click=${()=>{t.activeColorTab=`background`,this.requestUpdate()}}>${e.colorBg}</button>
1229
+ <button class="color-tab" ?active=${t.activeColorTab===`header`}
1230
+ @click=${()=>{t.activeColorTab=`header`,this.requestUpdate()}}>${e.colorHeader}</button>
1231
+ <button class="color-tab" ?active=${t.activeColorTab===`content`}
1232
+ @click=${()=>{t.activeColorTab=`content`,this.requestUpdate()}}>${e.colorText}</button>
1233
+ </div>
1234
+ <div class="hue-row">
1235
+ <button class="hue-step-btn" @click=${()=>this._a11y.setCustomHue((this._getCurrentHue()-15+360)%360)} aria-label="Уменьшить">–</button>
1236
+ <input type="range" class="hue-slider" min="0" max="360"
1237
+ .value=${String(this._getCurrentHue())}
1238
+ @input=${e=>this._a11y.setCustomHue(parseInt(e.target.value))}
1239
+ aria-label="Оттенок" />
1240
+ <button class="hue-step-btn" @click=${()=>this._a11y.setCustomHue((this._getCurrentHue()+15)%360)} aria-label="Увеличить">+</button>
1241
+ </div>
1242
+ </div>
1243
+
1244
+ <div class="ai-tools-section" style="margin-top: 16px;">
1245
+ <button class="ai-tool-btn ${this._aiA11y.simplifyEnabled?`active`:``}"
1246
+ @click=${()=>this._aiA11y.toggleSimplify()} id="bw-ai-simplify">
1247
+ ${H.textSize}
1248
+ <span class="ai-tool-btn-label">${e.aiSimplifyTitle}</span>
1249
+ <span class="ai-tool-badge ${this._aiA11y.simplifyEnabled?`on`:``}">
1250
+ ${this._aiA11y.simplifyEnabled?e.on:e.off}
1251
+ </span>
1252
+ </button>
1253
+
1254
+ <button class="ai-tool-btn ${this._aiA11y.autoA11yEnabled?`active`:``}"
1255
+ @click=${()=>this._aiA11y.toggleAutoA11y()}
1256
+ id="bw-ai-fix">
1257
+ ${H.accessibility}
1258
+ <span class="ai-tool-btn-label">${e.aiBlindTitle}</span>
1259
+ <span class="ai-tool-badge ${this._aiA11y.autoA11yEnabled?`on`:``}">
1260
+ ${this._aiA11y.autoA11yEnabled?e.on:e.off}
1261
+ </span>
1262
+ </button>
1263
+ </div>
1264
+ </div>
1265
+ `}_renderAdminOverlay(){return this._showAdminLogin?j`
1266
+ <div class="admin-overlay">
1267
+ <div class="admin-icon">🔐</div>
1268
+ <h4>${this._isAdmin?`Режим администратора`:`Admin доступ`}</h4>
1269
+ ${this._isAdmin?j`
1270
+ <p class="admin-status">✅ Вы вошли как администратор</p>
1271
+ <button class="admin-logout-btn" @click=${this._handleAdminLogout}>Выйти из аккаунта</button>
1272
+ `:j`
1273
+ <p>Введите ключ для активации режима обучения</p>
1274
+ <input type="password" placeholder="Admin Key"
1275
+ .value=${this._adminPassword}
1276
+ @input=${e=>{this._adminPassword=e.target.value}}
1277
+ @keydown=${e=>{e.key===`Enter`&&this._handleAdminLogin()}} />
1278
+ ${this._authError?j`<p class="auth-error">${this._authError}</p>`:``}
1279
+ <button class="admin-login-btn" @click=${this._handleAdminLogin}>Войти</button>
1280
+ `}
1281
+ <button class="admin-close-btn" @click=${()=>{this._showAdminLogin=!1,this._authError=``}}>
1282
+ Закрыть
1283
+ </button>
1284
+ </div>
1285
+ `:``}render(){let e=Q[this._sttLanguageMode];return j`
1286
+ <div class="widget-container">
1287
+ <!-- Panel -->
1288
+ <div class="bw-panel ${this._isOpen?`panel-visible`:`panel-hidden`}"
1289
+ role="dialog" aria-modal="true" aria-label="BariWeb Accessibility Widget">
1290
+
1291
+ <!-- Header -->
1292
+ <div class="bw-header">
1293
+ <div class="header-branding" @click=${this._handleLogoClick} id="bw-logo">
1294
+ ${H.accessibility}
1295
+ <div class="header-branding-text">
1296
+ <span class="header-brand-name">BariWeb</span>
1297
+ <span class="header-brand-sub">${e.brandSub}</span>
1298
+ </div>
1299
+ </div>
1300
+ <button class="close-btn" @click=${this._toggle} aria-label="${e.closeAria}" id="bw-close">
1301
+ ${H.close}
1302
+ </button>
1303
+ </div>
1304
+
1305
+ <!-- Tabs -->
1306
+ <div class="bw-tabs" role="tablist">
1307
+ <button class="bw-tab" ?active=${this._activeTab===`chat`}
1308
+ @click=${()=>this._setTab(`chat`)} role="tab"
1309
+ aria-selected=${this._activeTab===`chat`} id="bw-tab-chat">
1310
+ ${e.chatTab}
1311
+ </button>
1312
+ <button class="bw-tab" ?active=${this._activeTab===`a11y`}
1313
+ @click=${()=>this._setTab(`a11y`)} role="tab"
1314
+ aria-selected=${this._activeTab===`a11y`} id="bw-tab-settings">
1315
+ ${e.settingsTab}
1316
+ </button>
1317
+ </div>
1318
+
1319
+ <!-- Content -->
1320
+ <div class="bw-content">
1321
+ <div class="tab-panel" ?active=${this._activeTab===`chat`} role="tabpanel">
1322
+ ${this._renderChatTab()}
1323
+ </div>
1324
+ <div class="tab-panel" ?active=${this._activeTab===`a11y`} role="tabpanel">
1325
+ ${this._renderA11yTab()}
1326
+ </div>
1327
+ ${this._renderAdminOverlay()}
1328
+ </div>
1329
+
1330
+ <!-- Footer -->
1331
+ <div class="bw-footer" @click=${this._handleLogoClick}>
1332
+ <div class="footer-brand">
1333
+ ${H.accessibility} BariWeb
1334
+ </div>
1335
+ <span>${e.madeIn}</span>
1336
+ </div>
1337
+ </div>
1338
+
1339
+ <!-- FAB Trigger -->
1340
+ <button class="trigger" @click=${this._toggle}
1341
+ aria-expanded=${this._isOpen} aria-label="Открыть/Закрыть меню доступности"
1342
+ id="bw-trigger" style="position:fixed; bottom:24px; left:24px; width:60px; height:60px; border-radius:50%; background:var(--bw-primary,#6d28d9); color:white; border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; pointer-events:auto; box-shadow:0 4px 20px rgba(109,40,217,0.4); transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s;">
1343
+ ${this._isOpen?H.close:H.accessibility}
1344
+ </button>
1345
+ </div>
1346
+ `}};Y([ot({type:String,attribute:`client-id`})],$.prototype,`clientId`,void 0),Y([z()],$.prototype,`_isOpen`,void 0),Y([z()],$.prototype,`_activeTab`,void 0),Y([z()],$.prototype,`_inputValue`,void 0),Y([z()],$.prototype,`_isAdmin`,void 0),Y([z()],$.prototype,`_adminPassword`,void 0),Y([z()],$.prototype,`_authError`,void 0),Y([z()],$.prototype,`_currentScreenLabel`,void 0),Y([z()],$.prototype,`_sttState`,void 0),Y([z()],$.prototype,`_sttLanguageMode`,void 0),Y([z()],$.prototype,`_sttError`,void 0),Y([z()],$.prototype,`_adminClickCount`,void 0),Y([z()],$.prototype,`_showAdminLogin`,void 0),Y([ct(`.chat-messages`)],$.prototype,`_messagesEl`,void 0),$=Y([rt(`bw-widget`)],$);var Zt=()=>{let e=document.querySelector(`bw-widget`)?.getAttribute(`client-id`);if(e)return e;let t=(document.currentScript||document.querySelector(`script[src*="bariweb"]`))?.getAttribute(`data-client-id`);return t||=document.querySelector(`script[data-client-id]`)?.getAttribute(`data-client-id`)||``,t||window.__BARIWEB_CLIENT_ID__||``},Qt=Zt();window.__BARIWEB_CLIENT_ID__=Qt,pe.setConfig({baseUrl:`http://localhost:8000`}),pe.interceptors.request.use(e=>{let t=Zt();return e.headers.set(`X-Client-ID`,t),e})})();