@yuktishaalaa/yuktai 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -18
- package/dist/index.js +50 -50
- package/dist/index.mjs +21 -21
- package/dist/renderer.global.js +16 -16
- package/package.json +27 -6
- package/vanilla/README.md +162 -0
- package/vanilla/index.js +6801 -0
- package/vanilla/index.min.js +542 -0
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
/*! yuktai vanilla 5.2.0 — accessible data grid, page agents and WCAG tools for plain HTML.
|
|
2
|
+
* No framework, no API keys, runs in the browser. ISC © Sandeep Miriyala, Yuktishaalaa AI Lab.
|
|
3
|
+
* Built from github.com/sandeepmiriyala03/yuktai (vanilla/src + src/agentic, src/grid, src/core). */
|
|
4
|
+
"use strict";(()=>{var Eo=Object.defineProperty;var Lo=(e,t)=>{for(var n in t)Eo(e,n,{get:t[n],enumerable:!0})};var Jn={};Lo(Jn,{AUDIT_RULES:()=>Xe,DEFAULT_A11Y_SETTINGS:()=>rt,FONT_MAX:()=>Kn,FONT_MIN:()=>Un,FONT_STEP:()=>Qt,accessibleName:()=>he,aggregate:()=>qe,analyzePage:()=>Nn,answerGridQuestion:()=>Lt,applyGridFilters:()=>Re,askAboutPage:()=>zt,askInsight:()=>It,auditToJSON:()=>Dt,auditToMarkdown:()=>bt,clearFilters:()=>yn,clearSort:()=>wn,comparePeriods:()=>Rn,contrastRatio:()=>Pt,countGrid:()=>mn,createA11yCopilot:()=>Ot,createContextIndex:()=>qt,createGridTools:()=>Je,createVoiceA11yController:()=>Yt,detectAnomalies:()=>Oe,detectPageIntent:()=>Fn,executeGridQuery:()=>Ee,filterGrid:()=>bn,findMentionedColumn:()=>ge,getColumns:()=>fn,getRow:()=>hn,getRowId:()=>ee,gridPassages:()=>Gn,groupBy:()=>$n,highlightRows:()=>Ye,moveGridRowFocus:()=>Yn,openRow:()=>pt,pagePassages:()=>Pn,parseAmount:()=>gt,parseColor:()=>ft,parseGridQuery:()=>Ie,parseVoiceA11yCommand:()=>Qn,planTasks:()=>mt,readFormFields:()=>Mn,relativeLuminance:()=>Ft,reviewDesign:()=>Bt,reviewForm:()=>In,reviewForms:()=>Ze,runGridQuery:()=>Tn,runQaAudit:()=>be,runTasks:()=>Nt,searchGrid:()=>gn,selectRow:()=>dt,sortGrid:()=>vn,summarizeRows:()=>ze,toGridToolColumns:()=>Me,tokenize:()=>et,trend:()=>En,wcagPlugin:()=>He});var Mo={en:{found:e=>`${e} row(s) found.`,count:e=>`${e} row(s).`,columns:"Grid columns retrieved.",rowFound:"Row found.",notFound:e=>`Row "${e}" not found.`,noneFound:"None of the given rows were found.",highlighted:e=>`${e} row(s) highlighted.`,selected:e=>`Row "${e}" selected.`,opened:e=>`Row "${e}" opened.`,notSupported:e=>`This grid does not support "${e}".`,emptyQuery:"Please enter something to search.",noIds:"No row IDs were given.",unknownColumn:e=>`Unknown column "${e}".`,badOperator:e=>`Unknown filter operator "${e}".`,badValue:"The filter value is not valid for this column.",filtered:e=>`Filter applied: ${e} row(s) match.`,filtersCleared:"All filters cleared.",sorted:(e,t)=>`Sorted by ${e} (${t==="asc"?"ascending":"descending"}).`,sortCleared:"Sorting cleared.",internal:"Something went wrong while running this action."},te:{found:e=>`${e} \u0C35\u0C30\u0C41\u0C38(\u0C32\u0C41) \u0C26\u0C4A\u0C30\u0C3F\u0C15\u0C3E\u0C2F\u0C3F.`,count:e=>`\u0C2E\u0C4A\u0C24\u0C4D\u0C24\u0C02 ${e} \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41.`,columns:"\u0C15\u0C3E\u0C32\u0C2E\u0C4D\u200C\u0C32 \u0C35\u0C3F\u0C35\u0C30\u0C3E\u0C32\u0C41.",rowFound:"\u0C35\u0C30\u0C41\u0C38 \u0C26\u0C4A\u0C30\u0C3F\u0C15\u0C3F\u0C02\u0C26\u0C3F.",notFound:e=>`"${e}" \u0C35\u0C30\u0C41\u0C38 \u0C26\u0C4A\u0C30\u0C15\u0C32\u0C47\u0C26\u0C41.`,noneFound:"\u0C07\u0C1A\u0C4D\u0C1A\u0C3F\u0C28 \u0C35\u0C30\u0C41\u0C38\u0C32\u0C47\u0C35\u0C40 \u0C26\u0C4A\u0C30\u0C15\u0C32\u0C47\u0C26\u0C41.",highlighted:e=>`${e} \u0C35\u0C30\u0C41\u0C38(\u0C32\u0C41) \u0C39\u0C48\u0C32\u0C48\u0C1F\u0C4D \u0C1A\u0C47\u0C36\u0C3E\u0C28\u0C41.`,selected:e=>`"${e}" \u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41.`,opened:e=>`"${e}" \u0C24\u0C46\u0C30\u0C3F\u0C1A\u0C3E\u0C28\u0C41.`,notSupported:e=>`\u0C08 \u0C2A\u0C1F\u0C4D\u0C1F\u0C3F\u0C15\u0C32\u0C4B "${e}" \u0C38\u0C4C\u0C15\u0C30\u0C4D\u0C2F\u0C02 \u0C32\u0C47\u0C26\u0C41.`,emptyQuery:"\u0C35\u0C46\u0C24\u0C15\u0C21\u0C3E\u0C28\u0C3F\u0C15\u0C3F \u0C0F\u0C26\u0C48\u0C28\u0C3E \u0C30\u0C3E\u0C2F\u0C02\u0C21\u0C3F.",noIds:"\u0C35\u0C30\u0C41\u0C38 ID\u0C32\u0C41 \u0C07\u0C35\u0C4D\u0C35\u0C32\u0C47\u0C26\u0C41.",unknownColumn:e=>`"${e}" \u0C05\u0C28\u0C47 \u0C15\u0C3E\u0C32\u0C2E\u0C4D \u0C32\u0C47\u0C26\u0C41.`,badOperator:e=>`"${e}" \u0C05\u0C28\u0C47 \u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D \u0C35\u0C3F\u0C27\u0C3E\u0C28\u0C02 \u0C32\u0C47\u0C26\u0C41.`,badValue:"\u0C08 \u0C15\u0C3E\u0C32\u0C2E\u0C4D\u200C\u0C15\u0C3F \u0C08 \u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D \u0C35\u0C3F\u0C32\u0C41\u0C35 \u0C38\u0C30\u0C3F\u0C2A\u0C4B\u0C26\u0C41.",filtered:e=>`\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D \u0C35\u0C47\u0C36\u0C3E\u0C28\u0C41: ${e} \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41 \u0C38\u0C30\u0C3F\u0C2A\u0C4B\u0C2F\u0C3E\u0C2F\u0C3F.`,filtersCleared:"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C28\u0C4D\u0C28\u0C40 \u0C24\u0C40\u0C38\u0C47\u0C36\u0C3E\u0C28\u0C41.",sorted:(e,t)=>`${e} \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C15\u0C4D\u0C30\u0C2E\u0C02 (${t==="asc"?"\u0C06\u0C30\u0C4B\u0C39\u0C23":"\u0C05\u0C35\u0C30\u0C4B\u0C39\u0C23"}).`,sortCleared:"\u0C15\u0C4D\u0C30\u0C2E\u0C02 \u0C24\u0C40\u0C38\u0C47\u0C36\u0C3E\u0C28\u0C41.",internal:"\u0C08 \u0C2A\u0C28\u0C3F \u0C1A\u0C47\u0C38\u0C4D\u0C24\u0C41\u0C02\u0C21\u0C17\u0C3E \u0C38\u0C2E\u0C38\u0C4D\u0C2F \u0C35\u0C1A\u0C4D\u0C1A\u0C3F\u0C02\u0C26\u0C3F."}};function fe(e){return Mo[e.locale??"en"]}function xe(e,t){return{success:!0,message:e,data:t}}function Q(e,t){return{success:!1,message:t,error:{code:e}}}var br=["contains","equals","startsWith","endsWith","greaterThan","lessThan","between"];function ee(e,t="id"){let n=e==null?void 0:e[t];return n==null?"":String(n)}function De(e){return String(e??"").normalize("NFC").toLowerCase().trim()}function yr(e){if(typeof e=="number")return Number.isFinite(e)?e:null;let t=String(e??"").trim();if(t==="")return null;let n=Number(t);return Number.isFinite(n)?n:null}function vr(e){if(e instanceof Date)return e.getTime();let t=new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null}function wr(e){return(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>String(n).trim()).filter(Boolean)}function pn(e,t){let n=De(t);return e.columns.find(r=>De(r.key)===n||De(r.label)===n)}function Rt(e,t){return e.data.find(n=>ee(n,e.rowKey)===t)}function Io(e,t){return e[t]}function No(e,t,n){let r=Io(e,n.key),a=n.type??"text";if(a==="number"||a==="date"){let l=a==="number"?yr:vr,s=l(r);if(s===null)return!1;if(t.operator==="between"){let[p,f]=t.value,b=l(p),d=l(f);return b!==null&&d!==null&&s>=Math.min(b,d)&&s<=Math.max(b,d)}let u=l(t.value);if(u===null)return!1;switch(t.operator){case"equals":return s===u;case"greaterThan":return s>u;case"lessThan":return s<u;default:break}}let i=De(r),o=De(t.value);switch(t.operator){case"equals":return i===o;case"startsWith":return i.startsWith(o);case"endsWith":return i.endsWith(o);case"contains":return i.includes(o);default:return!1}}function Fo(e,t){let n=t.type??"text",r=n==="date"?vr:yr;return e.operator==="between"?n==="text"||!Array.isArray(e.value)||e.value.length!==2?!1:r(e.value[0])!==null&&r(e.value[1])!==null:e.operator==="greaterThan"||e.operator==="lessThan"?n!=="text"&&r(e.value)!==null:!Array.isArray(e.value)&&String(e.value).trim()!==""}function Re(e,t,n){return n.length?xr({data:e,columns:t},n):e}function Me(e){return e.map(t=>({key:String(t.key),label:t.label,type:t.type==="number"?"number":t.type==="date"?"date":"text"}))}function xr(e,t){return e.data.filter(n=>t.every(r=>{let a=pn(e,r.key);return a?No(n,r,a):!0}))}function gn(e,t){var o;let n=fe(e),r=De(t);if(!r)return Q("INVALID_INPUT",n.emptyQuery);let a=e.data.filter(l=>e.columns.some(s=>De(l[s.key]).includes(r))),i=a.map(l=>ee(l,e.rowKey)).filter(Boolean);return(o=e.onHighlightRows)==null||o.call(e,i),xe(n.found(a.length),a)}function mn(e){return xe(fe(e).count(e.data.length),e.data.length)}function fn(e){return xe(fe(e).columns,e.columns)}function hn(e,t){let n=fe(e),r=String(t??"").trim();if(!r)return Q("INVALID_INPUT",n.noIds);let a=Rt(e,r);return a?xe(n.rowFound,a):Q("NOT_FOUND",n.notFound(r))}function Ye(e,t){let n=fe(e),r=wr(t);if(r.length===0)return Q("INVALID_INPUT",n.noIds);if(!e.onHighlightRows)return Q("NOT_SUPPORTED",n.notSupported("highlight"));let a=r.filter(i=>Rt(e,i)!==void 0);return a.length===0?Q("NOT_FOUND",n.noneFound):(e.onHighlightRows(a),xe(n.highlighted(a.length),a))}function dt(e,t){let n=fe(e),r=String(t??"").trim();return r?e.onSelectRow?Rt(e,r)?(e.onSelectRow(r),xe(n.selected(r),r)):Q("NOT_FOUND",n.notFound(r)):Q("NOT_SUPPORTED",n.notSupported("select")):Q("INVALID_INPUT",n.noIds)}function pt(e,t){let n=fe(e),r=String(t??"").trim();return r?e.onOpenRow?Rt(e,r)?(e.onOpenRow(r),xe(n.opened(r),r)):Q("NOT_FOUND",n.notFound(r)):Q("NOT_SUPPORTED",n.notSupported("open")):Q("INVALID_INPUT",n.noIds)}function bn(e,t){let n=fe(e),r=pn(e,(t==null?void 0:t.key)??"");if(!r)return Q("INVALID_INPUT",n.unknownColumn(String((t==null?void 0:t.key)??"")));if(!br.includes(t.operator))return Q("INVALID_INPUT",n.badOperator(String(t.operator)));let a={...t,key:r.key};if(!Fo(a,r))return Q("INVALID_INPUT",n.badValue);if(!e.onFiltersChange)return Q("NOT_SUPPORTED",n.notSupported("filter"));let i=[...(e.filters??[]).filter(l=>l.key!==r.key),a],o=xr(e,i).length;return e.onFiltersChange(i),xe(n.filtered(o),{filters:i,count:o})}function yn(e){let t=fe(e);return e.onFiltersChange?(e.onFiltersChange([]),xe(t.filtersCleared,[])):Q("NOT_SUPPORTED",t.notSupported("clear filters"))}function vn(e,t,n="asc"){let r=fe(e),a=pn(e,t);if(!a)return Q("INVALID_INPUT",r.unknownColumn(String(t)));if(n!=="asc"&&n!=="desc")return Q("INVALID_INPUT",r.badValue);if(!e.onSortChange)return Q("NOT_SUPPORTED",r.notSupported("sort"));let i={key:a.key,direction:n};return e.onSortChange(i),xe(r.sorted(a.label,n),i)}function wn(e){let t=fe(e);return e.onSortChange?(e.onSortChange(null),xe(t.sortCleared,null)):Q("NOT_SUPPORTED",t.notSupported("clear sort"))}var Po={search:"Search all columns for text. Matching rows are highlighted.",count:"Count the rows currently in the grid.",columns:"List the grid's columns with their keys, labels and types.",get_row:"Get one row by its ID.",highlight:"Highlight one or more rows by ID without filtering the grid.",select:"Select one row by ID.",open:"Open one row by ID to show its full details.",filter:"Filter the grid by one column. Replaces any existing filter on that column.",clear_filters:"Remove all filters.",sort:"Sort the grid by one column, ascending or descending.",clear_sort:"Remove sorting."},hr={en:{search:"Search",count:"Count",columns:"Columns",get_row:"Get row",highlight:"Highlight",select:"Select",open:"Open",filter:"Filter",clear_filters:"Clear filters",sort:"Sort",clear_sort:"Clear sort"},te:{search:"\u0C35\u0C46\u0C24\u0C41\u0C15\u0C41",count:"\u0C32\u0C46\u0C15\u0C4D\u0C15",columns:"\u0C15\u0C3E\u0C32\u0C2E\u0C4D\u200C\u0C32\u0C41",get_row:"\u0C35\u0C30\u0C41\u0C38 \u0C1A\u0C42\u0C2A\u0C41",highlight:"\u0C39\u0C48\u0C32\u0C48\u0C1F\u0C4D",select:"\u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C4B",open:"\u0C24\u0C46\u0C30\u0C41\u0C35\u0C41",filter:"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D",clear_filters:"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F",sort:"\u0C15\u0C4D\u0C30\u0C2E\u0C02",clear_sort:"\u0C15\u0C4D\u0C30\u0C2E\u0C02 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F"}};async function Go(e,t){try{return t()}catch{return Q("INTERNAL",fe(e).internal)}}function Je(e,t={}){let n=t.name??"yuktai_grid",r=hr[e.locale??"en"],a=s=>{var u;return((u=t.descriptions)==null?void 0:u[s])??Po[s]},i={id:{type:"string",description:"Row ID"}},o=e.columns.map(s=>s.key);return[{id:"search",available:!0,schema:{type:"object",properties:{query:{type:"string"}},required:["query"]},run:s=>gn(e,String(s.query??""))},{id:"count",available:!0,schema:{type:"object",properties:{}},run:()=>mn(e)},{id:"columns",available:!0,schema:{type:"object",properties:{}},run:()=>fn(e)},{id:"get_row",available:!0,schema:{type:"object",properties:i,required:["id"]},run:s=>hn(e,String(s.id??""))},{id:"highlight",available:!!e.onHighlightRows,schema:{type:"object",properties:{ids:{type:"array",items:{type:"string"},description:"Row IDs"}},required:["ids"]},run:s=>Ye(e,wr(s.ids))},{id:"select",available:!!e.onSelectRow,schema:{type:"object",properties:i,required:["id"]},run:s=>dt(e,String(s.id??""))},{id:"open",available:!!e.onOpenRow,schema:{type:"object",properties:i,required:["id"]},run:s=>pt(e,String(s.id??""))},{id:"filter",available:!!e.onFiltersChange,schema:{type:"object",properties:{key:{type:"string",enum:o},operator:{type:"string",enum:br},value:{description:"Text or number; for 'between' an array of two numbers or dates"}},required:["key","operator","value"]},run:s=>bn(e,{key:String(s.key??""),operator:String(s.operator??""),value:s.value})},{id:"clear_filters",available:!!e.onFiltersChange,schema:{type:"object",properties:{}},run:()=>yn(e)},{id:"sort",available:!!e.onSortChange,schema:{type:"object",properties:{key:{type:"string",enum:o},direction:{type:"string",enum:["asc","desc"]}},required:["key"]},run:s=>vn(e,String(s.key??""),s.direction==="desc"?"desc":"asc")},{id:"clear_sort",available:!!e.onSortChange,schema:{type:"object",properties:{}},run:()=>wn(e)}].filter(s=>s.available).map(s=>({name:`${n}_${s.id}`,title:hr.en[s.id],description:a(s.id),label:r[s.id],inputSchema:s.schema,execute:u=>Go(e,()=>s.run(u??{}))}))}var Se=e=>String(e??"").normalize("NFC").toLowerCase().replace(/\s+/g," ").trim(),Do=new Set("show me find list get give which who what all the a an rows row records record entries with where that are is have has having and or of for in on to please display only those whose any".split(" "));function gt(e){let t=Se(e).replace(/(₹|rs\.?|inr|\$|usd|€|£)/g," ").match(/(-?\d[\d,]*(?:\.\d+)?|-?\.\d+)\s*(k|thousand|lakhs?|lacs?|crores?|cr|mn|million|m|bn|billion)?(?![\p{L}])/u);if(!t)return null;let n=Number(t[1].replace(/,/g,""));if(!Number.isFinite(n))return null;let r=t[2]??"",a=/^k|thousand/.test(r)?1e3:/^la/.test(r)?1e5:/^(crore|cr)/.test(r)?1e7:/^(m|mn|million)$/.test(r)?1e6:/^(bn|billion)$/.test(r)?1e9:1;return n*a}function Tr(e){let t=new Set([Se(e.label),Se(e.key),Se(e.key.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2"))]);for(let n of Array.from(t))n.endsWith("s")?t.add(n.slice(0,-1)):t.add(`${n}s`);return Array.from(t).filter(n=>n.length>1)}function ge(e,t,n){let r=` ${Se(e)} `,a;for(let i of t)if(!(n&&(i.type??"text")!==n))for(let o of Tr(i)){let l=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(^|[^\\p{L}\\p{M}\\p{N}])${l}($|[^\\p{L}\\p{M}\\p{N}])`,"u").test(r)&&(!a||o.length>a.length)&&(a={column:i,length:o.length})}return a==null?void 0:a.column}var Oo=/amount|balance|total|price|salary|value|due|revenue|cost|fee|sales|outstanding|paid/i;function xn(e){let t=e.filter(n=>n.type==="number");return t.find(n=>Oo.test(`${n.key} ${n.label}`))??t[0]}var Et=/(>=|=>|>|\bover\b|\babove\b|\bmore than\b|\bgreater than\b|\bexceeds?\b|\bexceeding\b|\bhigher than\b|\bat least\b|\bminimum\b|\bmin\b|కంటే ఎక్కువ)/,kn=/(<=|=<|<|\bunder\b|\bbelow\b|\bless than\b|\blower than\b|\bat most\b|\bmaximum\b|\bmax\b|\bup to\b|కంటే తక్కువ)/,kr=/\b(after|since|from)\b/,zo=/\b(before|until|till)\b/,qo="(?:\\s*(?:k|thousand|lakhs?|lacs?|crores?|cr|mn|million|m|bn|billion))?",An=`(?:\u20B9|rs\\.?\\s*|\\$)?\\s*-?\\d[\\d,]*(?:\\.\\d+)?${qo}`;function Ie(e,t,n={}){var S;let r={filters:[],search:[],sort:null,limit:null,notes:[],explanation:""},a=Se(e).replace(/[?!]+/g," ").replace(/\.(?!\d)/g," ").trim(),i=[],o=a.match(/\b(top|first|bottom|last|lowest|highest)\s+(\d+)\b/);o&&(r.limit=Number(o[2]),a=a.replace(o[0],` ${o[1]} `));let l=a.match(/\b(?:sort(?:ed)?|order(?:ed)?)\s+by\s+([\p{L}\p{M}\p{N} _]+?)(?:\s+(asc|ascending|desc|descending))?(?=$|,|\band\b|\bthen\b)/u),s=a.match(/\b(top|highest|largest|biggest|most|bottom|lowest|smallest|least)\b(?:\s+\d+)?\s+(?:by\s+)?([\p{L}\p{M}\p{N} _]+)/u);if(l){let y=ge(l[1],t);y&&(r.sort={key:y.key,direction:/^desc/.test(l[2]??"")?"desc":"asc"},a=a.replace(l[0]," "))}else if(s){let y=ge(s[2],t,"number")??ge(s[2],t)??xn(t);if(y){let m=/top|highest|largest|biggest|most/.test(s[1]);r.sort={key:y.key,direction:m?"desc":"asc"},a=a.replace(new RegExp(`\\b${s[1]}\\b`)," "),!o&&/top|bottom/.test(s[1])&&(r.limit=10)}}let u=new RegExp(`\\bbetween\\s+(${An}|\\d{4}-\\d{2}-\\d{2})\\s+(?:and|to|-)\\s+(${An}|\\d{4}-\\d{2}-\\d{2})`,"u"),p;for(;p=a.match(u);){let y=a.slice(Math.max(0,(p.index??0)-40),p.index??0),m=/\d{4}-\d{2}-\d{2}/.test(p[1]),C=m?ge(y,t,"date")??t.find(h=>h.type==="date"):ge(y,t,"number")??xn(t),E=m?p[1]:gt(p[1]),k=m?p[2]:gt(p[2]);C&&E!==null&&k!==null&&(r.filters.push({key:C.key,operator:"between",value:[E,k]}),i.push(`${C.label} between ${p[1]} and ${p[2]}`)),a=a.replace(p[0]," ")}let f=a.split(new RegExp("\\s*(?:(?<!\\d),|,(?!\\d)|;|\\band\\b|(?<!(?:starts?|starting|ends?|ending|begins?|beginning)\\s)\\bwith\\b|\\bwhere\\b|\\bwho\\b|\\bthat\\b|&|\u0C2E\u0C30\u0C3F\u0C2F\u0C41)\\s*","u")).map(y=>y.trim()).filter(Boolean),b=t.filter(y=>(y.type??"text")==="text"),d=new Map;for(let y of b){let m=new Set;for(let C of(n.data??[]).slice(0,5e3)){let E=Se(C[y.key]);if(E&&E.length<=40&&m.add(E),m.size>300)break}m.size&&m.size<=300&&d.set(y.key,m)}for(let y of f){let m=r.filters.length,C=ge(y,t),E=y.match(new RegExp(An,"u")),k=y.match(/\d{4}-\d{2}-\d{2}/);if(k&&(kr.test(y)||zo.test(y)||Et.test(y)||kn.test(y))){let h=((C==null?void 0:C.type)==="date"?C:void 0)??t.find(w=>w.type==="date");if(h){let w=kr.test(y)||Et.test(y);r.filters.push({key:h.key,operator:w?"greaterThan":"lessThan",value:k[0]}),i.push(`${h.label} ${w?"after":"before"} ${k[0]}`)}}else if(E&&(Et.test(y)||kn.test(y)||(C==null?void 0:C.type)==="number"&&/\b(is|equals?)\b|=/.test(y))){let h=(C==null?void 0:C.type)==="number"?C:void 0;h||(h=xn(t),h&&r.notes.push(`Assumed "${y}" refers to ${h.label}.`));let w=gt(E[0]);if(h&&w!==null){let v=/at least|minimum|\bmin\b|>=|=>|at most|maximum|\bmax\b|up to|<=|=</.test(y);Et.test(y)?(r.filters.push({key:h.key,operator:"greaterThan",value:v?w-1e-9:w}),i.push(`${h.label} ${v?"\u2265":">"} ${w.toLocaleString("en-IN")}`)):kn.test(y)?(r.filters.push({key:h.key,operator:"lessThan",value:v?w+1e-9:w}),i.push(`${h.label} ${v?"\u2264":"<"} ${w.toLocaleString("en-IN")}`)):(r.filters.push({key:h.key,operator:"equals",value:w}),i.push(`${h.label} = ${w.toLocaleString("en-IN")}`))}}else{let h=y.match(/\b(?:starts?|starting|begins?|beginning)\s+with\s+(.+)$/),w=y.match(/\b(?:ends?|ending)\s+with\s+(.+)$/),v=y.match(/\b(?:contains?|containing|including|includes?|mentions?)\s+(.+)$/),L=y.match(/\b(?:is|equals?|=|:)\s+(.+)$/),x=h??w??v??L;if(x){let $=C??b[0],I=x[1].replace(/^["'“‘]|["'”’]$/g,"").trim();if($&&I){let T=h?"startsWith":w?"endsWith":v?"contains":"equals";r.filters.push({key:$.key,operator:T,value:I}),i.push(`${$.label} ${T==="equals"?"is":T==="contains"?"contains":T==="startsWith"?"starts with":"ends with"} "${I}"`),C||r.notes.push(`Assumed "${y}" refers to ${$.label}.`)}}}if(r.filters.length===m)for(let[h,w]of d){let v="";for(let L of w){if(L.length<2||L.length<=v.length)continue;let x=L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(^|[^\\p{L}\\p{M}\\p{N}])${x}($|[^\\p{L}\\p{M}\\p{N}])`,"u").test(y)&&(v=L)}if(v){let L=t.find(x=>x.key===h);r.filters.push({key:h,operator:"equals",value:v}),i.push(`${L.label} is "${v}"`)}}if(r.filters.length===m){let h=y.split(/\s+/).filter(v=>!Do.has(v)&&!/^(top|first|bottom|last|lowest|highest|by|desc|asc|sort(ed)?)$/.test(v)),w=h.length>0&&h.every(v=>t.some(L=>Tr(L).includes(v)));if(h.length&&!w&&!(C&&h.length===1)){let v=h.join(" ");/^(customers?|users?|people|items?|entries|poems?|orders?|products?|employees?|students?|members?)$/.test(v)||(r.search.push(v),i.push(`any column contains "${v}"`))}}}if(r.sort){let y=((S=t.find(m=>m.key===r.sort.key))==null?void 0:S.label)??r.sort.key;i.push(`sorted by ${y} ${r.sort.direction==="desc"?"high \u2192 low":"low \u2192 high"}`)}return r.limit&&i.push(`first ${r.limit}`),r.explanation=i.length?`Showing rows where ${i.join(", ")}.`:"No conditions understood \u2014 showing all rows.",r}function Bo(e,t,n){return n==="number"?(Number(e)||0)-(Number(t)||0):n==="date"?(new Date(String(e)).getTime()||0)-(new Date(String(t)).getTime()||0):String(e??"").localeCompare(String(t??""),void 0,{numeric:!0})}function Ee(e,t,n){let r=Re(e,t,n.filters);for(let a of n.search)r=r.filter(i=>t.some(o=>Se(i[o.key]).includes(a)));if(n.sort){let a=t.find(o=>o.key===n.sort.key),i=n.sort.direction==="desc"?-1:1;r=[...r].sort((o,l)=>i*Bo(o[n.sort.key],l[n.sort.key],a==null?void 0:a.type))}return n.limit&&(r=r.slice(0,n.limit)),r}function Tn(e,t,n={}){var l,s,u;let r=Ie(e,t.columns,{data:t.data}),a=Ee(t.data,t.columns,r),i=a.map(p=>ee(p,t.rowKey)).filter(Boolean);n.apply!==!1&&(r.filters.length&&((l=t.onFiltersChange)==null||l.call(t,r.filters)),r.sort&&((s=t.onSortChange)==null||s.call(t,r.sort)),i.length&&((u=t.onHighlightRows)==null||u.call(t,i)));let o=a.length?`${a.length} row(s) found. ${r.explanation}${r.notes.length?` (${r.notes.join(" ")})`:""}`:`No rows match. ${r.explanation}`;return{rows:a,ids:i,parsed:r,message:o}}function Ar(e,t){let n=(e.length-1)*t,r=Math.floor(n),a=n-r;return e[r+1]!==void 0?e[r]+a*(e[r+1]-e[r]):e[r]}function Oe(e,t,n={}){let r=n.factor??1.5,a=[],i=t.filter(u=>u.type==="number"&&(!n.columns||n.columns.includes(u.key))),o=u=>u.toLocaleString("en-IN",{maximumFractionDigits:2});for(let u of i){let p=e.map(C=>Number(C[u.key])).filter(C=>Number.isFinite(C));if(p.length<5)continue;let f=[...p].sort((C,E)=>C-E),b=Ar(f,.25),d=Ar(f,.75),S=d-b;if(S===0)continue;let y=b-r*S,m=d+r*S;for(let C of e){let E=Number(C[u.key]);!Number.isFinite(E)||E>=y&&E<=m||a.push({rowId:ee(C,n.rowKey),column:u.key,label:u.label,value:E,kind:E>m?"high":"low",reason:`${u.label} ${o(E)} is far ${E>m?"above":"below"} the typical range (${o(b)}\u2013${o(d)}).`})}}let l=n.rowKey??"id",s=new Map;for(let u of e){let p=JSON.stringify(t.filter(d=>d.key!==l).map(d=>Se(u[d.key]))),f=ee(u,n.rowKey),b=s.get(p);b!==void 0?a.push({rowId:f,column:l,label:"Row",value:f,kind:"duplicate",reason:`Row ${f} has the same values as row ${b}.`}):s.set(p,f)}return a}function ze(e,t){if(!e.length)return"No rows to summarise.";let n=[`${e.length} row(s).`],r=a=>a.toLocaleString("en-IN",{maximumFractionDigits:2});for(let a of t){let i=e.map(o=>o[a.key]);if(a.type==="number"){let o=i.map(Number).filter(Number.isFinite);if(!o.length)continue;let l=o.reduce((s,u)=>s+u,0);n.push(`${a.label}: total ${r(l)}, average ${r(l/o.length)}, range ${r(Math.min(...o))}\u2013${r(Math.max(...o))}.`)}else if(a.type==="date"){let o=i.map(s=>new Date(String(s)).getTime()).filter(Number.isFinite);if(!o.length)continue;let l=s=>new Date(s).toISOString().slice(0,10);n.push(`${a.label}: from ${l(Math.min(...o))} to ${l(Math.max(...o))}.`)}else{let o=new Map;for(let s of i){let u=String(s??"").trim();u&&o.set(u,(o.get(u)??0)+1)}if(o.size===0||o.size>Math.max(8,e.length/3))continue;let l=Array.from(o.entries()).sort((s,u)=>u[1]-s[1]).slice(0,4);n.push(`${a.label}: ${l.map(([s,u])=>`${s} (${u})`).join(", ")}.`)}}return n.join(`
|
|
5
|
+
`)}function Lt(e,t){var a;let n=Se(e);if(/unusual|anomal|outlier|odd|strange|suspicious|duplicate|అసాధారణ/.test(n)){let i=Oe(t.data,t.columns,{rowKey:t.rowKey}),o=Array.from(new Set(i.map(s=>s.rowId)));o.length&&((a=t.onHighlightRows)==null||a.call(t,o));let l=new Set(o);return{kind:"anomalies",message:i.length?`${o.length} unusual row(s):
|
|
6
|
+
${i.slice(0,10).map(s=>`\u2022 ${s.reason}`).join(`
|
|
7
|
+
`)}`:"Nothing unusual found.",ids:o,rows:t.data.filter(s=>l.has(ee(s,t.rowKey))),anomalies:i}}if(/summar|overview|describe|సారాంశం/.test(n)){let i=Re(t.data,t.columns,t.filters??[]);return{kind:"summary",message:ze(i,t.columns),ids:[],rows:i}}let r=Tn(e,t);return{kind:"query",message:r.message,ids:r.ids,rows:r.rows}}var Mt=e=>{let t=typeof e=="number"?e:Number(String(e??"").replace(/[,₹$%\s]/g,""));return Number.isFinite(t)?t:null},Sr=e=>{let t=e instanceof Date?e.getTime():new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null};function qe(e,t){if(t==="count")return e.length;if(!e.length)return 0;switch(t){case"sum":return e.reduce((n,r)=>n+r,0);case"avg":return e.reduce((n,r)=>n+r,0)/e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function $n(e,t,n,r="sum"){let a=new Map;for(let i of e){let o=String(i[t]??"\u2014").trim()||"\u2014",l=a.get(o)??[];if(n===null||r==="count")l.push(1);else{let s=Mt(i[n]);s!==null&&l.push(s)}a.set(o,l)}return Array.from(a.entries()).map(([i,o])=>({group:i,value:qe(o,r),count:o.length})).sort((i,o)=>o.value-i.value)}function Cr(e,t,n=1){let r=new Date(e);return r.setHours(0,0,0,0),t==="week"&&r.setDate(r.getDate()-(r.getDay()-n+7)%7),t==="month"&&r.setDate(1),t==="quarter"&&r.setMonth(Math.floor(r.getMonth()/3)*3,1),t==="year"&&r.setMonth(0,1),r}function Cn(e,t,n){let r=new Date(e);return t==="day"&&r.setDate(r.getDate()+n),t==="week"&&r.setDate(r.getDate()+7*n),t==="month"&&r.setMonth(r.getMonth()+n),t==="quarter"&&r.setMonth(r.getMonth()+3*n),t==="year"&&r.setFullYear(r.getFullYear()+n),r}function Rn(e,t){let n=t.referenceDate?new Date(t.referenceDate):new Date,r=Cr(n,t.period,t.weekStartsOn),a=t.toDate===!1?Cn(r,t.period,1):new Date(Math.max(n.getTime()+1,r.getTime()+1)),i=Cn(r,t.period,-1),o=t.toDate===!1?r:new Date(i.getTime()+(a.getTime()-r.getTime())),l=t.agg??"sum",s=new Map,u=new Map;for(let b of e){let d=Sr(b[t.dateKey]);if(d===null)continue;let S=d>=r.getTime()&&d<a.getTime()?s:d>=i.getTime()&&d<o.getTime()?u:null;if(!S)continue;let y=t.groupKey?String(b[t.groupKey]??"\u2014"):"All",m=l==="count"?1:Mt(b[t.metricKey]);m!==null&&S.set(y,[...S.get(y)??[],m])}let p=new Set([...s.keys(),...u.keys()]),f=Array.from(p).map(b=>{let d=qe(s.get(b)??[],l),S=qe(u.get(b)??[],l);return{group:b,current:d,previous:S,change:d-S,changePct:S===0?null:(d-S)/Math.abs(S)*100}});return{period:t.period,current:{from:r,to:a},previous:{from:i,to:o},rows:f}}function En(e,t,n,r,a="sum"){let i=new Map;for(let o of e){let l=Sr(o[t]),s=a==="count"?1:Mt(o[n]);if(l===null||s===null)continue;let u=Cr(new Date(l),r).getTime();i.set(u,[...i.get(u)??[],s])}return Array.from(i.entries()).sort((o,l)=>o[0]-l[0]).map(([o,l])=>({start:new Date(o),value:qe(l,a)}))}var Ho=/rate|conversion|ratio|percent|%|score|rating|margin|ctr|avg|average/i;function _o(e){let t=e.match(/\b(today|yesterday|this|last|previous|past)\s*(day|week|month|quarter|year)?\b/);return t?t[1]==="today"?{period:"day",shift:0}:t[1]==="yesterday"?{period:"day",shift:-1}:t[2]?{period:t[2],shift:t[1]==="this"?0:-1}:null:null}var ae=e=>e.toLocaleString("en-IN",{maximumFractionDigits:2}),Sn=e=>e===null?"new":`${e>0?"+":""}${e.toFixed(1)}%`;function It(e,t,n,r={}){var k;let a=e.toLowerCase(),i=n.filter(h=>h.type==="number"),o=ge(a,n,"number")??i.find(h=>/amount|revenue|sales|total|value/i.test(`${h.key} ${h.label}`))??i[0],l=n.find(h=>h.type==="date")??n.find(h=>/date|time|day|created|month/i.test(`${h.key} ${h.label}`)),s=((k=a.match(/\b(?:which|by|per|each|across|every|top|for each)\s+([\p{L}\p{M}\p{N} _]+)/u))==null?void 0:k[1])??"",u=ge(s,n,"text"),p=/how many|number of|count/.test(a),f=p?"count":/average|avg|mean/.test(a)?"avg":/\btotal\b|\bsum\b/.test(a)?"sum":o&&Ho.test(`${o.key} ${o.label}`)?"avg":"sum",b=/drop|decline|decrease|fell|fall|down|worst|lost|shrink|reduc/.test(a),d=/increase|growth|grew|rise|rose|up\b|best|improv|gain/.test(a),S=/lowest|least|smallest|bottom|worst|minimum/.test(a),y=_o(a);if(!o&&!p)return{kind:"unknown",answer:"I couldn't find a numeric column to analyse.",table:[]};let m=p?"rows":o.label;if(y&&l&&(d||b||/change|compare|vs|versus/.test(a))){let h=r.referenceDate?new Date(r.referenceDate):new Date,w=y.shift?Cn(h,y.period,y.shift):h,L=[...Rn(t,{dateKey:l.key,metricKey:(o==null?void 0:o.key)??l.key,groupKey:u==null?void 0:u.key,agg:f,period:y.period,referenceDate:w,toDate:y.shift===0}).rows].sort((F,B)=>b?F.change-B.change:B.change-F.change),x=L.map(F=>({[(u==null?void 0:u.label)??"Group"]:F.group,Current:ae(F.current),Previous:ae(F.previous),Change:ae(F.change),"Change %":Sn(F.changePct)}));if(!L.length)return{kind:"period-change",answer:`No ${m} data in this ${y.period} or the one before.`,table:x};let $=L[0],I=`${y.shift?"last":"this"} ${y.period} vs the ${y.period} before`,T=$.change===0?"did not change":$.change<0?`dropped ${ae(Math.abs($.change))}`:`rose ${ae($.change)}`,R=`${m} ${T} (${ae($.previous)} \u2192 ${ae($.current)}, ${Sn($.changePct)}) \u2014 ${I}.`,G=b&&$.change>=0||d&&$.change<=0;return{kind:"period-change",answer:u?G?`No ${u.label.toLowerCase()} ${b?"dropped":"grew"}. Closest is ${$.group}: ${R}`:`${$.group}: ${R}`:R,table:x}}if(/trend|over time|month by month|week by week/.test(a)&&l&&o){let h=/week/.test(a)?"week":/day|daily/.test(a)?"day":/year/.test(a)?"year":"month",w=En(t,l.key,o.key,h,f),v=w.map(I=>({Period:I.start.toISOString().slice(0,10),[o.label]:ae(I.value)}));if(w.length<2)return{kind:"trend",answer:`Not enough ${h}s of data for a trend.`,table:v};let L=w[0].value,x=w[w.length-1].value,$=w.reduce((I,T)=>T.value>I.value?T:I);return{kind:"trend",answer:`${o.label} went from ${ae(L)} to ${ae(x)} over ${w.length} ${h}s (${Sn(L?(x-L)/Math.abs(L)*100:null)}). Peak: ${ae($.value)} in the ${h} of ${$.start.toISOString().slice(0,10)}.`,table:v}}if(u){let h=$n(t,u.key,(o==null?void 0:o.key)??null,f),w=S?[...h].reverse():h,v=w.map(x=>({[u.label]:x.group,[`${f} of ${m}`]:ae(x.value),Rows:x.count}));if(!w.length)return{kind:"group",answer:"No data.",table:v};let L=w[0];return{kind:"group",answer:`${L.group} has the ${S?"lowest":"highest"} ${f==="sum"?"total":f==="avg"?"average":f} ${m}: ${ae(L.value)} (across ${w.length} ${u.label.toLowerCase()} groups).`,table:v}}let C=p?t.map(()=>1):t.map(h=>Mt(h[o.key])).filter(h=>h!==null),E=qe(C,f);return{kind:"total",answer:`${f==="avg"?"Average":f==="count"?"Count of":f==="sum"?"Total":f} ${m}: ${ae(E)} across ${t.length} row(s).`,table:[{Metric:m,Aggregation:f,Value:ae(E)}]}}var Er="highlight|mark|flag|sort|order|rank|arrange|summari[sz]e|summary|recap|count|how many|open|select|pick|show|filter|find|list|clear|reset|remove|detect|spot|tell";function mt(e){return e.replace(/[?!]/g," ").split(/\s*(?:;|\.(?!\d)\s*|,?\s*\band then\b|,?\s*\bthen\b|,?\s*\bafter that\b|,?\s*\bfinally\b|,?\s*\bnext\b|ఆ తర్వాత)\s*/i).flatMap(r=>r.split(new RegExp(`\\s*(?:,|\\band\\b)\\s+(?=(?:${Er})\\b)`,"i"))).map(r=>r.trim()).filter(r=>r.length>1).map(r=>({action:Vo(r),text:r}))}function Vo(e){let t=e.toLowerCase();return/^(clear|reset|remove)\b/.test(t)?"clear":/unusual|anomal|outlier|suspicious|odd ones|duplicate/.test(t)?"anomalies":/summari[sz]e|summary|what changed|recap|overview/.test(t)?"summarize":/^(highlight|mark|flag)\b/.test(t)?"highlight":/^(sort|order|rank|arrange)\b/.test(t)?"sort":/^(count|how many)\b/.test(t)?"count":/^(open|go to)\b/.test(t)&&!/filtered|results?/.test(t)?"open":/^(select|pick)\b/.test(t)?"select":"filter"}function jo(e){return e.replace(new RegExp(`^\\s*(?:${Er}|open|go to)\\b`,"i")," ").replace(/\b(the|filtered|results?|rows?|records?|entries|items?|ones|them|those|only|me|all)\b/gi," ").replace(/\s+/g," ").trim()}function $r(e,t){var i;let n=((i=t.find(o=>o.key===e.key))==null?void 0:i.label)??e.key,r=Array.isArray(e.value)?`${e.value[0]}\u2013${e.value[1]}`:typeof e.value=="number"?e.value.toLocaleString("en-IN",{maximumFractionDigits:2}):`"${e.value}"`,a={contains:"contains",equals:"is",startsWith:"starts with",endsWith:"ends with",greaterThan:">",lessThan:"<",between:"between"}[e.operator];return`${n} ${a} ${r}`}async function Nt(e,t,n={}){var y,m,C,E,k,h,w,v,L;let r=mt(e),{columns:a,data:i}=t,o=[...t.filters??[]],l=[],s=null,u=[],p=()=>Ee(i,a,{filters:o,search:l,sort:s,limit:null,notes:[],explanation:""}),f={rows:p().length,filters:[...o]},b=[],d=()=>({...t,filters:o});for(let x=0;x<r.length;x++){let $=r[x],I=jo($.text),T;try{switch($.action){case"clear":{o=[],l=[],s=null,u=[],(y=t.onFiltersChange)==null||y.call(t,[]),(m=t.onSortChange)==null||m.call(t,null),(C=t.onHighlightRows)==null||C.call(t,[]),T={...$,success:!0,message:`Cleared filters, sorting and highlights. ${i.length} row(s) shown.`};break}case"filter":{let R=Ie(I,a,{data:i});if(!R.filters.length&&!R.search.length&&!R.sort){T={...$,success:!0,message:`Showing ${p().length} row(s) with the current filters.`};break}for(let F of R.filters)o=[...o.filter(B=>B.key!==F.key),F];l=[...l,...R.search],R.sort&&(s=R.sort,(E=t.onSortChange)==null||E.call(t,s)),(k=t.onFiltersChange)==null||k.call(t,o);let G=p(),N=G.map(F=>ee(F,t.rowKey)).filter(Boolean);R.search.length&&N.length&&(u=N,(h=t.onHighlightRows)==null||h.call(t,N)),T={...$,success:!0,message:`${G.length} row(s) now shown. ${R.explanation}`,ids:N};break}case"highlight":{let R=p(),G=Ie(I,a,{data:R}),F=(G.filters.length||G.search.length?Ee(R,a,{...G,sort:null,limit:G.limit}):R).map(pe=>ee(pe,t.rowKey)).filter(Boolean);if(!F.length){T={...$,success:!1,message:`Nothing to highlight for "${I||"all rows"}".`};break}let B=Ye(d(),F);B.success&&(u=B.data??F),T={...$,success:B.success,message:B.success?`Highlighted ${u.length} row(s)${I?` matching "${I}"`:""}.`:B.message,ids:u};break}case"sort":{let G=Ie($.text,a,{data:i}).sort;if(!G){let F=ge(I,a);F&&(G={key:F.key,direction:/desc|high|large|big|most|newest|latest|z.?to.?a/i.test($.text)?"desc":"asc"})}if(!G){T={...$,success:!1,message:`Which column should I sort by? Columns: ${a.map(F=>F.label).join(", ")}.`};break}s=G,(w=t.onSortChange)==null||w.call(t,s);let N=((v=a.find(F=>F.key===s.key))==null?void 0:v.label)??s.key;T={...$,success:!0,message:`Sorted by ${N} (${s.direction==="desc"?"high \u2192 low":"low \u2192 high"}).`};break}case"count":{T={...$,success:!0,message:`${p().length} row(s) shown${u.length?`, ${u.length} highlighted`:""}.`};break}case"anomalies":{let R=p(),G=Oe(R,a,{rowKey:t.rowKey}),N=Array.from(new Set(G.map(F=>F.rowId)));if(N.length){let F=Ye(d(),N);F.success&&(u=F.data??N)}T={...$,success:!0,message:G.length?`${N.length} unusual row(s): ${G.slice(0,5).map(F=>F.reason).join(" ")}`:"Nothing unusual in the shown rows.",ids:N};break}case"open":case"select":{let R=p(),N=R.find(pe=>I&&ee(pe,t.rowKey).toLowerCase()===I.toLowerCase())??Ee(R,a,Ie(I,a,{data:R}))[0]??(I?void 0:R[0]);if(!N){T={...$,success:!1,message:`No row matches "${I}".`};break}let F=ee(N,t.rowKey),B=$.action==="open"?pt(d(),F):dt(d(),F);T={...$,success:B.success,message:B.message,ids:[F]};break}case"summarize":{let R=p();T={...$,success:!0,message:`${Rr(f,R.length,o,s,u,a)}
|
|
8
|
+
${ze(R,a)}`};break}}}catch(R){T={...$,success:!1,message:`This step failed: ${R instanceof Error?R.message:String(R)}`}}b.push(T),(L=n.onStep)==null||L.call(n,T,x,r.length)}let S=p().length;return{steps:b,before:f,after:{rows:S,filters:o,sort:s,highlighted:u},summary:Rr(f,S,o,s,u,a)}}function Rr(e,t,n,r,a,i){var u;let o=[`Rows: ${e.rows} \u2192 ${t}.`],l=n.filter(p=>!e.filters.some(f=>JSON.stringify(f)===JSON.stringify(p))),s=e.filters.filter(p=>!n.some(f=>JSON.stringify(p)===JSON.stringify(f)));return l.length&&o.push(`Filters added: ${l.map(p=>$r(p,i)).join("; ")}.`),s.length&&o.push(`Filters removed: ${s.map(p=>$r(p,i)).join("; ")}.`),r&&o.push(`Sorted by ${((u=i.find(p=>p.key===r.key))==null?void 0:u.label)??r.key} ${r.direction==="desc"?"high \u2192 low":"low \u2192 high"}.`),a.length&&o.push(`${a.length} row(s) highlighted.`),o.join(" ")}var Wo="[data-yuktai-panel]";function ke(){return typeof window<"u"&&typeof document<"u"}function Be(e){return typeof e=="object"&&e!==null&&e.nodeType===9}function me(e){return e||(ke()?document:null)}function z(e,t,n={}){return Array.from(e.querySelectorAll(t)).filter(r=>!r.closest(Wo)&&(n.includeHidden||Uo(r)))}function Uo(e){if(!ke()||e.closest("[hidden],[aria-hidden='true']"))return!1;let t=e;for(;t;){let n=window.getComputedStyle(t);if(n.display==="none"||n.visibility==="hidden")return!1;t=t.parentElement}return!0}function te(e){return(e??"").replace(/\s+/g," ").trim()}function ne(e,t=60){let n=te(e);return n.length>t?`${n.slice(0,t-1)}\u2026`:n}function Ce(e){let t=[],n=e;for(;n&&n.nodeType===1&&t.length<4;){let r=n.tagName.toLowerCase();if(n.id&&/^[A-Za-z][\w-]*$/.test(n.id)){t.unshift(`${r}#${n.id}`);break}let a=n.parentElement;if(!a){t.unshift(r);break}let i=Array.from(a.children).filter(o=>o.tagName===n.tagName);t.unshift(i.length>1?`${r}:nth-of-type(${i.indexOf(n)+1})`:r),n=a}return t.join(" > ")}function Ko(e,t){return e.split(/\s+/).map(n=>{var r;return te((r=t.getElementById(n))==null?void 0:r.textContent)}).filter(Boolean).join(" ")}function he(e){let t=e.ownerDocument,n=e.getAttribute("aria-labelledby");if(n){let i=Ko(n,t);if(i)return i}let r=te(e.getAttribute("aria-label"));if(r)return r;let a=e.tagName.toLowerCase();if(a==="input"||a==="select"||a==="textarea"){let i=e.getAttribute("id");if(i){let s=t.querySelector(`label[for="${Qo(i)}"]`),u=te(s==null?void 0:s.textContent);if(u)return u}let o=e.closest("label");if(o){let s=te(o.textContent);if(s)return s}let l=(e.getAttribute("type")??"").toLowerCase();if(l==="submit"||l==="button"||l==="reset")return te(e.getAttribute("value"))||(l==="submit"?"Submit":"");if(l==="image")return te(e.getAttribute("alt"))}if(a==="img")return te(e.getAttribute("alt"));if(a==="button"||a==="a"||e.getAttribute("role")){let i=te(e.textContent);if(i)return i;let o=Array.from(e.querySelectorAll("img[alt], svg[aria-label]")).map(l=>te(l.getAttribute("alt")??l.getAttribute("aria-label"))).filter(Boolean).join(" ");if(o)return o}return te(e.getAttribute("title"))}function Qo(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function ft(e){if(!e)return null;let t=e.trim().toLowerCase();if(t==="transparent")return{r:0,g:0,b:0,a:0};let n=t.match(/^rgba?\(([^)]+)\)$/);if(n){let a=n[1].split(/[\s,/]+/).filter(Boolean),[i,o,l]=a.slice(0,3).map(Number),s=a[3],u=s===void 0?1:s.endsWith("%")?Number(s.slice(0,-1))/100:Number(s);return[i,o,l,u].some(p=>!Number.isFinite(p))?null:{r:i,g:o,b:l,a:u}}let r=t.match(/^#([0-9a-f]{3,8})$/);if(r){let a=r[1];return(a.length===3||a.length===4)&&(a=a.split("").map(i=>i+i).join("")),a.length!==6&&a.length!==8?null:{r:parseInt(a.slice(0,2),16),g:parseInt(a.slice(2,4),16),b:parseInt(a.slice(4,6),16),a:a.length===8?parseInt(a.slice(6,8),16)/255:1}}return null}function Ln(e,t){let n=e.a+t.a*(1-e.a);if(n===0)return{r:0,g:0,b:0,a:0};let r=(a,i)=>(a*e.a+i*t.a*(1-e.a))/n;return{r:r(e.r,t.r),g:r(e.g,t.g),b:r(e.b,t.b),a:n}}function Ft(e){let t=n=>{let r=n/255;return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function Pt(e,t){let n=t.a<1?Ln(t,{r:255,g:255,b:255,a:1}):t,r=e.a<1?Ln(e,n):e,a=Ft(r),i=Ft(n),[o,l]=a>i?[a,i]:[i,a];return Math.round((o+.05)/(l+.05)*100)/100}function Lr(e){let t=[],n=e;for(;n;){let a=window.getComputedStyle(n);if(a.backgroundImage&&a.backgroundImage!=="none")return null;let i=ft(a.backgroundColor);if(i&&i.a>0&&(t.push(i),i.a>=1))break;n=n.parentElement}let r={r:255,g:255,b:255,a:1};for(let a=t.length-1;a>=0;a--)r=Ln(t[a],r);return r}function Mr(e){let t=window.getComputedStyle(e),n=parseFloat(t.fontSize)||16,r=parseInt(t.fontWeight,10)||400;return n>=24||n>=18.66&&r>=700}function ht(e){return Array.from(e.childNodes).some(t=>t.nodeType===3&&te(t.textContent).length>0)}var Ir="a[href],button,input:not([type='hidden']),select,textarea,summary,[tabindex]:not([tabindex='-1']),[contenteditable='true']",Gt="a[href],button,input:not([type='hidden']),select,textarea,summary,[role='button'],[role='link'],[role='checkbox'],[role='tab'],[role='menuitem']";var Xe={"html-lang":{title:"Page language is set",wcag:"3.1.1",severity:"serious",why:"Screen readers pick their voice and pronunciation from the page language. Without it, Telugu or Hindi text may be read with English rules."},"page-title":{title:"Page has a title",wcag:"2.4.2",severity:"serious",why:"The title is the first thing announced and the name shown on browser tabs and bookmarks."},"image-alt":{title:"Images have alternative text",wcag:"1.1.1",severity:"critical",why:'People who cannot see the image get no information from it unless alt text describes it (or alt="" marks it as decorative).'},"heading-order":{title:"Headings follow a logical order",wcag:"1.3.1",severity:"moderate",why:"Many screen-reader users jump between headings. Skipped levels make the page outline confusing."},"single-h1":{title:"Page has one main heading",wcag:"best practice",severity:"minor",why:"A single h1 tells everyone what the page is about."},"landmark-main":{title:"Main content landmark exists",wcag:"1.3.1 / 2.4.1",severity:"moderate",why:"A <main> region lets keyboard and screen-reader users skip straight past menus to the content."},"form-label":{title:"Form fields have labels",wcag:"1.3.1 / 4.1.2",severity:"critical",why:'Without a label, a screen reader just says "edit text" and the user has to guess what to type.'},"button-name":{title:"Buttons have names",wcag:"4.1.2",severity:"critical",why:'An icon-only button with no name is announced as just "button", so its purpose is unknown.'},"link-name":{title:"Links have names",wcag:"2.4.4",severity:"serious",why:"Links are often read out of context in a list. An empty link gives no clue where it goes."},"color-contrast":{title:"Text has enough contrast",wcag:"1.4.3",severity:"serious",why:"Low-contrast text is hard to read for older users, people with low vision, and anyone outdoors on a phone."},"positive-tabindex":{title:"No positive tabindex",wcag:"2.4.3",severity:"moderate",why:"tabindex greater than 0 forces a custom keyboard order that usually doesn't match the visual order."},"keyboard-access":{title:"Clickable things work with a keyboard",wcag:"2.1.1",severity:"critical",why:"A div or span with a click handler can't be reached or activated with Tab and Enter, locking out keyboard users."},"duplicate-id":{title:"IDs are unique",wcag:"best practice",severity:"minor",why:"Labels and ARIA references point at ids. Duplicates make them point at the wrong element."},"form-error":{title:"Errors are linked to their fields",wcag:"3.3.1",severity:"serious",why:"When a field is marked invalid, the error message must be connected to it so it's announced together with the field."},"target-size":{title:"Touch targets are large enough",wcag:"2.5.8",severity:"moderate",why:"Small targets are hard to tap for people with tremors, seniors and everyone on mobile."}},Yo={critical:10,serious:5,moderate:2,minor:1};function be(e={}){let t=me(e.root),n=new Set(e.skip??[]),r=[],a={},i=t?Be(t)?t:t.ownerDocument:null,o=(l,s,u,p,f=!1)=>{if(n.has(l))return;let b=Xe[l],d=a[l]=(a[l]??0)+1;r.push({id:`${l}-${d}`,rule:l,severity:b.severity,wcag:b.wcag,message:u,why:b.why,fix:p,selector:s?Ce(s):"document",snippet:s?ne(s.outerHTML,120):"",autoFixable:f,element:s??void 0})};if(t&&i){i.documentElement.getAttribute("lang")||o("html-lang",i.documentElement,"The <html> element has no lang attribute.",'Add lang to <html>, e.g. <html lang="te"> or "en".',!0),i.title.trim()||o("page-title",null,"The page has no <title>.","Add a short, descriptive <title> that names this page.");for(let m of z(t,"img"))if(!(m.getAttribute("role")==="presentation"||m.getAttribute("role")==="none")&&!m.hasAttribute("alt")&&!m.getAttribute("aria-label")&&!m.getAttribute("aria-labelledby")){let C=m.getAttribute("title");o("image-alt",m,`Image has no alt text${m.getAttribute("src")?` (${ne(m.getAttribute("src")??"",40)})`:""}.`,C?`Use the title as alt: alt="${ne(C,40)}".`:'Describe the image in alt, or use alt="" if it is purely decorative.',!!C)}let l=z(t,"h1,h2,h3,h4,h5,h6"),s=0;for(let m of l){let C=Number(m.tagName[1]);s>0&&C>s+1&&o("heading-order",m,`Heading jumps from h${s} to h${C}: "${ne(m.textContent??"",40)}".`,`Change it to h${s+1}, or add the missing level above it.`),s=C}let u=l.filter(m=>m.tagName==="H1");u.length===0?o("single-h1",null,"The page has no h1.","Add one h1 that names the page."):u.length>1&&o("single-h1",u[1],`The page has ${u.length} h1 headings.`,"Keep one h1; turn the others into h2."),t.querySelectorAll("main,[role='main']").length===0&&o("landmark-main",null,"No <main> landmark found.","Wrap the primary content in <main>.");let p=z(t,"input,select,textarea").filter(m=>{let C=(m.getAttribute("type")??"text").toLowerCase();return!["hidden","submit","button","reset","image"].includes(C)});for(let m of p){if(!he(m)){let C=m.getAttribute("placeholder")||m.getAttribute("name");o("form-label",m,`Form field has no label${C?` (placeholder/name: "${ne(C,30)}")`:""}.`,C?`Add a visible <label>. Quick fix: aria-label="${ne(C,30)}".`:"Add a visible <label for=\u2026> describing what to enter.",!!C)}m.getAttribute("aria-invalid")==="true"&&(m.getAttribute("aria-describedby")||m.getAttribute("aria-errormessage")||o("form-error",m,"Field is marked invalid but no error message is linked to it.","Put the error text in an element with an id and point aria-describedby at it."))}for(let m of z(t,"button,[role='button'],input[type='submit'],input[type='button']"))if(!he(m)){let C=m.getAttribute("title");o("button-name",m,"Button has no accessible name.",C?`Use the title as the name: aria-label="${C}".`:"Add visible text or an aria-label that says what the button does.",!!C)}for(let m of z(t,"a[href]"))if(!he(m)){let C=m.getAttribute("title");o("link-name",m,`Link has no text (${ne(m.getAttribute("href")??"",40)}).`,C?`Use the title as the name: aria-label="${C}".`:"Add link text that says where it goes.",!!C)}for(let m of z(t,"[tabindex]"))Number(m.getAttribute("tabindex"))>0&&o("positive-tabindex",m,`tabindex="${m.getAttribute("tabindex")}" overrides the natural tab order.`,'Use tabindex="0" and fix the order in the HTML instead.',!0);let f="a[href],button,input,select,textarea,summary";for(let m of z(t,"[onclick],[role='button'],[role='link']"))m.matches(f)||m.hasAttribute("tabindex")||o("keyboard-access",m,`<${m.tagName.toLowerCase()}> is clickable but can't be reached with the keyboard.`,'Use a real <button>, or add tabindex="0", a role and Enter/Space key handling.',!0);let b=new Map;for(let m of Array.from(t.querySelectorAll("[id]")))m.closest("[data-yuktai-panel]")||b.set(m.id,(b.get(m.id)??0)+1);for(let[m,C]of b)C>1&&o("duplicate-id",t.querySelector(`[id="${m.replace(/"/g,'\\"')}"]`),`id="${m}" is used ${C} times.`,"Give each element a unique id.");let d=e.maxContrastChecks??600,S=0;for(let m of z(t,"body *")){if(S>=d)break;if(!ht(m)||["SCRIPT","STYLE","NOSCRIPT","OPTION"].includes(m.tagName))continue;S++;let C=ft(window.getComputedStyle(m).color),E=Lr(m);if(!C||!E)continue;let k=Pt(C,E),h=Mr(m)?3:4.5;k<h&&o("color-contrast",m,`Contrast ${k}:1 is below ${h}:1 for "${ne(m.textContent??"",30)}".`,`Darken the text or lighten the background until the ratio is at least ${h}:1.`)}let y=e.minTargetSize??24;for(let m of z(t,Gt)){let C=m.getBoundingClientRect();C.width===0&&C.height===0||m.tagName==="A"&&m.closest("p,li,td")||(C.width<y||C.height<y)&&o("target-size",m,`Target is ${Math.round(C.width)}\xD7${Math.round(C.height)}px (minimum ${y}\xD7${y}).`,`Increase padding so it's at least ${y}\xD7${y}px (44\xD744 is better for seniors).`)}}return Jo(r,i,n)}function Jo(e,t,n){var s;let r=Object.keys(Xe).filter(u=>!n.has(u)).map(u=>{let p=e.filter(f=>f.rule===u).length;return{rule:u,title:Xe[u].title,passed:p===0,issueCount:p}}),a=0;for(let u of r){let p=Yo[Xe[u.rule].severity];a+=Math.min(25,u.issueCount*p)}let i=Math.max(0,100-a),o=r.filter(u=>!u.passed),l=e.filter(u=>u.severity==="critical").length;return{url:((s=t==null?void 0:t.location)==null?void 0:s.href)??"",title:(t==null?void 0:t.title)??"",generatedAt:new Date().toISOString(),score:i,passed:l===0&&i>=80,checks:r,issues:e,summary:e.length===0?`All ${r.length} checks passed.`:`${r.length-o.length} of ${r.length} checks passed. ${e.length} issue(s) found, ${l} critical. Score ${i}/100.`}}function bt(e){let t=["# Accessibility QA report","",`- Page: ${e.title||"(untitled)"} ${e.url}`,`- Generated: ${e.generatedAt}`,`- Score: **${e.score}/100** \u2014 ${e.passed?"PASS":"FAIL"}`,"",e.summary,"","## Checks","","| Check | Result | Issues |","|---|---|---|",...e.checks.map(n=>`| ${n.title} | ${n.passed?"\u2705 Pass":"\u274C Fail"} | ${n.issueCount} |`)];if(e.issues.length){t.push("","## Issues","");for(let n of e.issues)t.push(`### ${n.id} \xB7 ${n.severity} \xB7 WCAG ${n.wcag}`,"",`- **Problem:** ${n.message}`,`- **Why it matters:** ${n.why}`,`- **Fix:** ${n.fix}`,`- **Where:** \`${n.selector}\``,"")}return t.join(`
|
|
9
|
+
`)}function Dt(e){return JSON.stringify({...e,issues:e.issues.map(({element:t,...n})=>n)},null,2)}function Ot(e={}){let t=null,n=null,r=null,a=!1,i=[],o=()=>({report:t,watching:n!==null,appliedFixes:i.length}),l=()=>{var b;return(b=e.onUpdate)==null?void 0:b.call(e,o())},s=b=>t==null?void 0:t.issues.find(d=>d.id===b),u=(b,d,S)=>{i.push({element:b,attribute:d,previous:b.getAttribute(d)}),b.setAttribute(d,S)};function p(b){let d=b.element,S=(y,m)=>({issueId:b.id,applied:y,message:m});if(!b.autoFixable||!d)return S(!1,"This needs a human decision \u2014 see the suggested fix.");switch(b.rule){case"html-lang":{let y=e.defaultLang||(ke()?navigator.language:"")||"en";return u(d,"lang",y),S(!0,`Set lang="${y}" on <html>.`)}case"image-alt":{let y=d.getAttribute("title");if(!y)break;return u(d,"alt",y),S(!0,`Used the image title as alt text: "${y}".`)}case"form-label":{let y=d.getAttribute("placeholder")||d.getAttribute("name");if(!y)break;let m=y.replace(/[_-]+/g," ").trim();return u(d,"aria-label",m),S(!0,`Added aria-label="${m}". A visible <label> is still better.`)}case"button-name":case"link-name":{let y=d.getAttribute("title");if(!y)break;return u(d,"aria-label",y),S(!0,`Added aria-label="${y}".`)}case"positive-tabindex":return u(d,"tabindex","0"),S(!0,"Changed tabindex to 0 so the natural order applies.");case"keyboard-access":{u(d,"tabindex","0"),d.getAttribute("role")||u(d,"role","button");let y=m=>{let C=m.key;(C==="Enter"||C===" ")&&(m.preventDefault(),d.click())};return d.addEventListener("keydown",y),i.push({element:d,attribute:"",previous:null,listener:y}),S(!0,"Made it focusable and added Enter/Space support.")}default:break}return S(!1,"No safe automatic fix for this one \u2014 see the suggested fix.")}function f(){if(t=be(e),e.autoApply){a=!0;let b=t.issues.filter(d=>d.autoFixable).map(p);a=!1,b.some(d=>d.applied)&&(t=be(e))}return l(),t}return{start(){if(!ke()||n)return;let b=me(e.root),d=Be(b)?b.body:b;d&&(n=new MutationObserver(S=>{a||!S.some(m=>{var C,E;return!((E=(C=m.target).closest)!=null&&E.call(C,"[data-yuktai-panel]"))})||(r&&clearTimeout(r),r=setTimeout(f,e.debounceMs??600))}),n.observe(d,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["alt","aria-label","aria-invalid","tabindex","lang","title"]}),f())},stop(){n==null||n.disconnect(),n=null,r&&clearTimeout(r),r=null,l()},scan:f,explain(b){let d=s(b);return d?[`${d.message}`,`Why it matters: ${d.why}`,`How to fix: ${d.fix}`,`Standard: WCAG ${d.wcag} (${d.severity}).`,d.autoFixable?"I can apply a safe fix for this in the browser.":"This one needs a change in your code."].join(`
|
|
10
|
+
`):`No issue "${b}" in the current report. Run a scan first.`},applyFix(b){let d=s(b);if(!d)return{issueId:b,applied:!1,message:"Issue not found. Run a scan first."};a=!0;let S=p(d);return a=!1,S.applied&&f(),S},applyAllFixes(){t||f(),a=!0;let b=((t==null?void 0:t.issues)??[]).filter(d=>d.autoFixable).map(p);return a=!1,f(),b},undoAll(){let b=i.length;for(a=!0;i.length;){let d=i.pop();d.listener?d.element.removeEventListener("keydown",d.listener):d.previous===null?d.element.removeAttribute(d.attribute):d.element.setAttribute(d.attribute,d.previous)}return a=!1,f(),b},getState:o}}var Xo=/^(field|input|value|text|enter|details?|info|data|\*|:)$/i,Zo=/^(go|ok|submit|send|click here|>|→|next)$/i,ei=[[/e-?mail/i,"email","email"],[/phone|mobile|tel/i,"tel","tel"],[/^(full)?name$|full.?name/i,"name"],[/first.?name|given/i,"given-name"],[/last.?name|surname|family/i,"family-name"],[/address|street/i,"street-address"],[/zip|postal|pin.?code|pincode/i,"postal-code"],[/city|town/i,"address-level2"],[/country/i,"country-name"],[/password/i,"current-password","password"],[/dob|birth/i,"bday"]];function ti(e){let t=e.getAttribute("id");return t&&e.ownerDocument.querySelector(`label[for="${t.replace(/"/g,'\\"')}"]`)?!0:!!e.closest("label")}function Mn(e){return z(e,"input,select,textarea").filter(t=>!["hidden","submit","button","reset","image"].includes((t.getAttribute("type")??"text").toLowerCase())).map(t=>({label:he(t),type:t.tagName==="INPUT"?(t.getAttribute("type")??"text").toLowerCase():t.tagName.toLowerCase(),name:t.getAttribute("name")??t.getAttribute("id")??"",required:t.hasAttribute("required")||t.getAttribute("aria-required")==="true",hasVisibleLabel:ti(t),selector:Ce(t),element:t}))}function In(e,t={}){var b;let n=t.seniorFriendly!==!1,r=t.maxFieldsPerStep??8,a=Mn(e),i=[],o=(d,S,y,m)=>i.push({level:d,message:S,suggestion:y,field:(m==null?void 0:m.label)||(m==null?void 0:m.name),selector:m==null?void 0:m.selector});for(let d of a){let S=d.element,y=d.label||d.name||d.type,m=S.getAttribute("placeholder");!d.label&&m?o("problem",`"${m}" uses only a placeholder as its label.`,"Placeholders disappear when typing starts and aren't read by every screen reader. Add a visible label above the field.",d):d.label?!d.hasVisibleLabel&&m&&!S.getAttribute("aria-label")?o("problem",`"${y}" uses only a placeholder as its label.`,"Placeholders disappear when typing starts. Add a visible label above the field.",d):Xo.test(d.label)&&o("improvement",`The label "${d.label}" is unclear.`,'Say exactly what is needed, e.g. "Mobile number (10 digits)".',d):o("problem",`A ${d.type} field${d.name?` ("${d.name}")`:""} has no label.`,"Add a visible <label> that says exactly what to enter.",d),d.required&&d.label&&!/\*|required|mandatory|తప్పనిసరి|आवश्यक/i.test(d.label)&&o("improvement",`"${y}" is required but the label doesn't say so.`,'Add "(required)" to the label so everyone knows before submitting.',d);let C=`${d.name} ${d.label}`;for(let[E,k,h]of ei)if(E.test(C)){S.getAttribute("autocomplete")||o("improvement",`"${y}" has no autocomplete hint.`,`Add autocomplete="${k}" so browsers can fill it in (WCAG 1.3.5).`,d),h&&d.type==="text"&&o("improvement",`"${y}" uses type="text".`,`Use type="${h}" for the right mobile keyboard and validation.`,d);break}if(S.getAttribute("aria-invalid")==="true"&&!S.getAttribute("aria-describedby")&&!S.getAttribute("aria-errormessage")&&o("problem",`"${y}" shows an error that isn't connected to the field.`,"Link the error text with aria-describedby and explain how to fix it.",d),n){let E=parseFloat(window.getComputedStyle(S).fontSize)||16;E<16&&o("improvement",`"${y}" text is ${E}px.`,"Use at least 16px in inputs; it is easier to read and stops mobile browsers from zooming.",d)}}a.length>r&&o("improvement",`This form has ${a.length} fields on one screen.`,`Split it into steps of about ${r} fields with a progress indicator.`);let l=z(e,"button,input[type='submit'],input[type='button']");if(l.length===0)o("problem","No submit button found.",'Add a clear <button type="submit"> so the form can be completed with the keyboard.');else if(n){let d=te(he(l[l.length-1]));Zo.test(d)&&o("improvement",`The button says "${d}".`,'Name the result, e.g. "Send message" or "Book appointment".')}!z(e,"[role='alert'],[aria-live]",{includeHidden:!0}).length&&a.some(d=>d.required)&&o("improvement","No live region for error messages.",'Add an element with role="alert" so errors are announced when the form is submitted.');let s=i.filter(d=>d.level==="problem").length,u=i.length-s,p=Math.max(0,100-s*15-u*4),f=e.getAttribute("aria-label")||te((b=e.querySelector("legend,h1,h2,h3"))==null?void 0:b.textContent)||e.getAttribute("name")||e.getAttribute("id")||"Form";return{name:ne(f,50),selector:Ce(e),fields:a,findings:i,score:p,summary:i.length===0?`"${ne(f,40)}" looks clear: ${a.length} labelled field(s), nothing to fix.`:`"${ne(f,40)}" has ${a.length} field(s): ${s} problem(s) and ${u} suggestion(s). Score ${p}/100.`}}function Ze(e={}){let t=me(e.root);return t?z(t,"form,[role='form']").map(n=>In(n,e)):[]}function Nn(e){var p;let t=me(e),n={title:"",description:"",language:"",headings:[],landmarks:{},counts:{links:0,buttons:0,images:0,forms:0,tables:0,fields:0},unlabeledFields:[],imagesWithoutAlt:[],purpose:""};if(!t)return n;let r=Be(t)?t:t.ownerDocument,a=z(t,"h1,h2,h3,h4,h5,h6").map(f=>({level:Number(f.tagName[1]),text:ne(f.textContent??"",80)})),i={};for(let[f,b]of Object.entries({header:"header,[role='banner']",navigation:"nav,[role='navigation']",main:"main,[role='main']",search:"search,[role='search']",footer:"footer,[role='contentinfo']"}))i[f]=z(t,b).length;let o=z(t,"input,select,textarea").filter(f=>!["hidden","submit","button","reset","image"].includes((f.getAttribute("type")??"text").toLowerCase())),l=o.filter(f=>!he(f)).map(f=>({type:f.tagName==="INPUT"?f.getAttribute("type")??"text":f.tagName.toLowerCase(),hint:f.getAttribute("placeholder")||f.getAttribute("name")||"",selector:Ce(f)})),s=z(t,"img:not([alt])").map(f=>({src:f.getAttribute("src")??"",selector:Ce(f)})),u={title:r.title,description:te((p=r.querySelector('meta[name="description"]'))==null?void 0:p.getAttribute("content")),language:r.documentElement.getAttribute("lang")??"",headings:a,landmarks:i,counts:{links:z(t,"a[href]").length,buttons:z(t,"button,[role='button'],input[type='submit']").length,images:z(t,"img").length,forms:z(t,"form,[role='form']").length,tables:z(t,"table,[role='grid'],[role='table']").length,fields:o.length},unlabeledFields:l,imagesWithoutAlt:s,purpose:""};return u.purpose=ni(u,o),u}function ni(e,t){var o;let n=((o=e.headings.find(l=>l.level===1))==null?void 0:o.text)||e.title||"This page",r=t.map(l=>`${l.getAttribute("type")} ${l.getAttribute("name")} ${he(l)}`).join(" ").toLowerCase(),a=[];/password/.test(r)?a.push("sign in or create an account"):(/search|query|వెతుకు/.test(r)||e.landmarks.search)&&a.push("search"),/message|comment|feedback|contact|enquiry/.test(r)&&a.push("send a message"),/card|payment|upi|amount/.test(r)&&a.push("make a payment"),e.counts.tables&&a.push(`browse ${e.counts.tables} table(s) of data`),!a.length&&e.counts.forms&&a.push(`fill in ${e.counts.forms} form(s)`),a.length||a.push("read content");let i=e.headings.filter(l=>l.level===2).slice(0,5).map(l=>l.text);return[`"${n}" lets you ${a.join(", ")}.`,e.description?`It describes itself as: ${ne(e.description,140)}`:"",i.length?`Main sections: ${i.join(" \xB7 ")}.`:""].filter(Boolean).join(" ")}var ri=[["missing-labels",/label|unlabel|లేబుల్/i],["images",/image|alt text|picture|photo|చిత్ర/i],["structure",/heading|structure|outline|section|landmark|శీర్షిక/i],["forms",/form|field|input|ఫారం/i],["links",/link|లింక్/i],["counts",/how many|count|ఎన్ని/i],["purpose",/what (does|is)|purpose|about|summar|explain|ఏమి|గురించి/i]];function Fn(e){for(let[t,n]of ri)if(n.test(e))return t;return"unknown"}async function zt(e,t={}){var a;let n=Nn(t.root),r=Fn(e);switch(r){case"missing-labels":return n.unlabeledFields.length?{intent:r,answer:`${n.unlabeledFields.length} of ${n.counts.fields} field(s) have no label: ${n.unlabeledFields.map(i=>`${i.type}${i.hint?` ("${i.hint}")`:""}`).join(", ")}.`,targets:n.unlabeledFields.map(i=>i.selector),suggestions:["Add a visible <label for=\u2026> to each field.","Run the Accessibility Copilot to add aria-labels from placeholders as a quick fix."]}:{intent:r,answer:`All ${n.counts.fields} form field(s) have labels.`,targets:[],suggestions:[]};case"images":return{intent:r,answer:n.imagesWithoutAlt.length?`${n.imagesWithoutAlt.length} of ${n.counts.images} image(s) have no alt text.`:`All ${n.counts.images} image(s) have alt text.`,targets:n.imagesWithoutAlt.map(i=>i.selector),suggestions:n.imagesWithoutAlt.length?['Describe meaningful images in alt; use alt="" for decorative ones.']:[]};case"structure":{let i=n.headings.slice(0,15).map(l=>`${" ".repeat(l.level-1)}h${l.level} ${l.text}`).join(`
|
|
11
|
+
`),o=Object.entries(n.landmarks).filter(([,l])=>l===0).map(([l])=>l);return{intent:r,answer:`${n.headings.length} heading(s).
|
|
12
|
+
${i}${o.length?`
|
|
13
|
+
Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("main")?["Wrap the primary content in <main>."]:[]}}case"forms":{let i=Ze({root:t.root});return{intent:r,answer:i.length?i.map(o=>o.summary).join(`
|
|
14
|
+
`):"There are no forms on this page.",targets:i.flatMap(o=>o.findings.map(l=>l.selector).filter(l=>!!l)),suggestions:i.flatMap(o=>o.findings.slice(0,3).map(l=>l.suggestion))}}case"links":case"counts":{let i=n.counts;return{intent:r,answer:`${i.links} links, ${i.buttons} buttons, ${i.fields} form fields in ${i.forms} form(s), ${i.images} images, ${i.tables} tables.`,targets:[],suggestions:[]}}case"purpose":case"unknown":{let i=n.purpose;if(t.summarize)try{let l=me(t.root),s=te((a=l&&Be(l)?l.body:l)==null?void 0:a.textContent).slice(0,4e3);i=await t.summarize(s)||i}catch{}let o=[];return n.unlabeledFields.length&&o.push(`${n.unlabeledFields.length} form field(s) need labels.`),n.imagesWithoutAlt.length&&o.push(`${n.imagesWithoutAlt.length} image(s) need alt text.`),{intent:r,answer:i,targets:[],suggestions:o}}}}var oi=new Set("a an the is are was were be to of and or in on at for with what which who whom how why when where does do did this that these those it its from by as about any all please tell me show give".split(" "));function et(e){return(e.normalize("NFC").toLowerCase().match(/[\p{L}\p{M}\p{N}]+/gu)??[]).filter(t=>t.length>1&&!oi.has(t))}function Pn(e,t=600){let n=me(e);if(!n)return[];let r=[],a="",i="",o=()=>{i.trim()&&r.push({id:`page-${r.length+1}`,source:"page",text:i.trim(),ref:a||void 0}),i=""};for(let l of z(n,"h1,h2,h3,h4,p,li,td,th,dt,dd,blockquote,figcaption,label,summary")){if(l.querySelector("p,li,h1,h2,h3,h4"))continue;let s=te(l.textContent);if(s){if(/^H[1-4]$/.test(l.tagName)){o(),a=s,i=`${s}. `;continue}i.length+s.length>t&&o(),i+=`${s} `}}return o(),r}function Gn(e,t,n="id"){return e.map((r,a)=>{let i=r,o=String(i[n]??a+1);return{id:`grid-${o}`,source:"grid",ref:o,text:t.map(l=>`${l.label}: ${String(i[l.key]??"")}`).join(". ")}})}function qt(e={}){let t=[],n=[],r=new Map,a=0;function i(){t=[...e.includePage===!1?[]:Pn(e.root),...e.rows&&e.columns?Gn(e.rows,e.columns,e.rowKey):[],...(e.documents??[]).map(s=>({id:s.id,source:"custom",text:s.text}))],n=t.map(s=>et(s.text)),r=new Map;for(let s of n)for(let u of new Set(s))r.set(u,(r.get(u)??0)+1);a=n.reduce((s,u)=>s+u.length,0)/Math.max(1,n.length)}i();function o(s,u=5){let p=et(s);if(!p.length)return[];let f=n.length;return n.map((d,S)=>{let y=0;for(let m of p){let C=0;for(let k of d)(k===m||m.length>=4&&k.startsWith(m)||k.length>=4&&m.startsWith(k))&&C++;if(!C)continue;let E=Math.log(1+(f-(r.get(m)??1)+.5)/((r.get(m)??1)+.5));y+=E*(C*2.2/(C+1.2*(.25+.75*(d.length/(a||1)))))}return{...t[S],score:y}}).filter(d=>d.score>0).sort((d,S)=>S.score-d.score).slice(0,u)}async function l(s,u={}){let p=o(s,u.k??4);if(!p.length)return{answer:"I couldn't find anything about that on this page or in the data.",hits:p,generated:!1};if(u.generate)try{let S=p.map((m,C)=>`[${C+1}] ${m.text}`).join(`
|
|
15
|
+
`),y=await u.generate(s,S);if(y!=null&&y.trim())return{answer:y.trim(),hits:p,generated:!0}}catch{}let f=new Set(et(s)),b=p.flatMap(S=>S.text.split(new RegExp("(?<=[.!?\u0964])\\s+|\\.\\s+(?=\\p{Lu})","u")).map(y=>({s:y.trim(),h:S}))).map(({s:S,h:y})=>({s:S,h:y,overlap:et(S).filter(m=>f.has(m)).length})).filter(S=>S.s&&S.overlap>0).sort((S,y)=>y.overlap-S.overlap).slice(0,3);return{answer:b.length?b.map(S=>S.h.source==="grid"?`Row ${S.h.ref}: ${S.s}`:S.s).join(`
|
|
16
|
+
`):p[0].text.slice(0,300),hits:p,generated:!1}}return{search:o,ask:l,rebuild:i,update(s){Object.assign(e,s),i()},size:()=>t.length}}var Nr={high:12,medium:6,low:2};function Bt(e={}){let t=me(e.root),n=[],r=(l,s,u,p,f)=>n.push({category:l,severity:s,message:u,suggestion:p,selector:f?Ce(f):void 0});if(t&&ke()){let l=e.minFontSize??14,s=e.maxLineLength??90,u=T=>window.getComputedStyle(T),p=z(t,"h1");p.length===0&&r("hierarchy","medium","There is no h1, so the page has no clear main title.","Add one prominent h1 near the top."),p.length>1&&r("hierarchy","low",`${p.length} h1 headings compete for attention.`,"Keep one h1 and demote the rest.",p[1]);let f=T=>{let R=z(t,T)[0];return R&&parseFloat(u(R).fontSize)||0},[b,d,S]=[f("h1"),f("h2"),f("h3")];b&&d&&d>=b&&r("hierarchy","medium",`h2 (${d}px) is as large as or larger than h1 (${b}px).`,"Make each heading level visibly smaller than the one above it."),d&&S&&S>d&&r("hierarchy","low",`h3 (${S}px) is larger than h2 (${d}px).`,"Keep heading sizes in descending order.");let y=be({root:e.root,skip:["color-contrast","target-size","duplicate-id","page-title","html-lang","form-error","positive-tabindex"]});for(let T of y.issues.filter(R=>R.rule==="heading-order").slice(0,3))r("hierarchy","low",T.message,T.fix,T.element);let m=0,C;for(let T of z(t,"p,li,td,span,a,label,small,div").slice(0,1500)){if(!ht(T))continue;(parseFloat(u(T).fontSize)||16)<l&&(m++,C??=T)}m&&r("readability",m>10?"high":"medium",`${m} text element(s) are smaller than ${l}px, e.g. "${ne((C==null?void 0:C.textContent)??"",30)}".`,`Use at least ${l}px for body text (16px for senior-friendly pages).`,C);for(let T of z(t,"p").slice(0,200)){let R=u(T),G=parseFloat(R.fontSize)||16,N=T.getBoundingClientRect().width,F=N/(G*.5);if(N>0&&F>s&&(T.textContent??"").length>s){r("readability","low",`A paragraph is about ${Math.round(F)} characters wide.`,`Limit text width to ~${s} characters (e.g. max-width: 70ch).`,T);break}let B=parseFloat(R.lineHeight);if(Number.isFinite(B)&&B/G<1.3){r("readability","low",`Line height is ${(B/G).toFixed(2)}\xD7 the font size.`,"Use line-height of at least 1.5 for body text (WCAG 1.4.12).",T);break}}let E=be({root:e.root,skip:["html-lang","page-title","image-alt","heading-order","single-h1","landmark-main","form-label","button-name","link-name","positive-tabindex","keyboard-access","duplicate-id","form-error","target-size"]});E.issues.length&&r("readability",E.issues.length>5?"high":"medium",`${E.issues.length} text element(s) have weak contrast. ${E.issues[0].message}`,"Raise contrast to at least 4.5:1 for body text.",E.issues[0].element);let k=ii();k.length&&r("interaction","high",`Focus outlines are removed by CSS (${k.slice(0,2).join(", ")}) with no replacement.`,"Never remove outlines without a visible :focus-visible style (WCAG 2.4.7).");let h=z(t,Gt).filter(T=>{let R=T.getBoundingClientRect();return R.width>0&&R.height>0&&(R.width<24||R.height<24)&&!(T.tagName==="A"&&T.closest("p,li"))});h.length&&r("interaction",h.length>5?"high":"medium",`${h.length} control(s) are smaller than 24\xD724px.`,"Give controls at least 24\xD724px, ideally 44\xD744px for touch and seniors.",h[0]);let w=window.innerHeight||800,v=z(t,Ir).filter(T=>{let R=T.getBoundingClientRect();return R.height>0&&R.top<w});v.length>40&&r("clutter","medium",`${v.length} interactive elements in the first screen.`,"Group secondary actions into menus and keep the first screen focused on one task.");let L=z(t,"button,a[href],[role='button']").filter(T=>{let R=T.getBoundingClientRect();if(R.height===0||R.top>w)return!1;let G=u(T).backgroundColor;return!!G&&!/rgba\(0, 0, 0, 0\)|transparent/.test(G)&&!/rgb\(255, 255, 255\)/.test(G)});L.length>4&&r("clutter","medium",`${L.length} filled buttons compete in the first screen.`,"Keep one primary action per view; make the rest secondary (outline or text).",L[0]);let x=new Set,$=new Set;for(let T of z(t,"body *").slice(0,2e3)){if(!ht(T))continue;let R=u(T);x.add(R.fontFamily.split(",")[0].replace(/["']/g,"").trim().toLowerCase()),$.add(Math.round(parseFloat(R.fontSize)||0))}x.size>4&&r("consistency","low",`${x.size} different font families are used.`,"Stick to 1\u20132 font families (e.g. one Telugu + one Latin)."),$.size>10&&r("consistency","low",`${$.size} different font sizes are used.`,"Use a small type scale (5\u20137 sizes) for a calmer page.");let I=z(t,"img:not([width]):not([height])").filter(T=>!u(T).aspectRatio||u(T).aspectRatio==="auto");I.length>3&&r("consistency","low",`${I.length} images have no width/height, so the layout jumps while loading.`,"Set width and height (or aspect-ratio) on images.",I[0])}let a=["hierarchy","readability","interaction","clutter","consistency"].reduce((l,s)=>{let u=n.filter(p=>p.category===s);return l[s]={score:Math.max(0,100-u.reduce((p,f)=>p+Nr[f.severity]*2,0)),findings:u.length},l},{}),i=Math.max(0,100-n.reduce((l,s)=>l+Nr[s.severity],0)),o=Object.entries(a).sort((l,s)=>l[1].score-s[1].score)[0];return{score:i,categories:a,findings:n,summary:n.length?`Design score ${i}/100 with ${n.length} finding(s). Weakest area: ${o[0]}.`:"No design issues found by the automatic review."}}function ii(){let e=[],t=!1,n=r=>{for(let a of Array.from(r)){let i=a.cssRules;i&&n(i);let o=a;if(!o.selectorText||!/:focus/.test(o.selectorText))continue;let l=`${o.style.outline} ${o.style.outlineStyle} ${o.style.outlineWidth}`,s=/\bnone\b|\b0(px)?\b/.test(l),u=!!(o.style.boxShadow&&o.style.boxShadow!=="none")||!!o.style.borderColor||!!o.style.backgroundColor||!!o.style.textDecoration;/:focus-visible/.test(o.selectorText)&&(!s||u)&&(t=!0),s&&!u&&e.push(o.selectorText)}};for(let r of Array.from(document.styleSheets))try{n(r.cssRules)}catch{}return t?[]:e}function Fr(){var t;let e=window;return e.Rewriter||((t=e.ai)==null?void 0:t.rewriter)||null}async function Dn(){try{let e=Fr();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}if(typeof e.capabilities=="function"){let t=await e.capabilities();return(t==null?void 0:t.available)!=="no"}return typeof e.create=="function"}catch{return!1}}async function ai(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=Fr();if(!t)throw new Error("Rewriter API not available");let n=await t.create({tone:"more-casual",format:"plain-text",length:"as-is",outputLanguage:"en"}),r=await n.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return n.destroy(),{success:!0,original:e,rewritten:r.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function Pr(){var r;if(!await Dn())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),n=0;for(let a of t){let i=(r=a.innerText)==null?void 0:r.trim();if(!i||i.length<20||a.closest("[data-yuktai-panel]"))continue;let o=await ai(i);o.success&&o.rewritten!==i&&(a.dataset.yuktaiOriginal=i,a.innerText=o.rewritten,n++)}return{fixed:n}}function Gr(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let n=t.dataset.yuktaiOriginal;n&&(t.innerText=n,delete t.dataset.yuktaiOriginal)}}var Dr="yuktai-summary-box";function Or(){var t;let e=window;return e.Summarizer||((t=e.ai)==null?void 0:t.summarizer)||null}async function On(){try{let e=Or();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}if(typeof e.capabilities=="function"){let t=await e.capabilities();return(t==null?void 0:t.available)!=="no"}return typeof e.create=="function"}catch{return!1}}function si(){var n;let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let r of e){if(r.closest("[data-yuktai-panel]"))continue;let a=window.getComputedStyle(r);if(a.display==="none"||a.visibility==="hidden")continue;let i=(n=r.innerText)==null?void 0:n.trim();i&&i.length>10&&t.push(i)}return t.join(" ").slice(0,5e3)}async function zr(){if(!await On())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=si();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let n=Or();if(!n)throw new Error("Summarizer API not available");let r=await n.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),a=await r.summarize(t,{context:"Summarise this page in 2-3 simple sentences for a screen reader user who wants to know if this page is relevant to them."});return r.destroy(),li(a.trim()),{success:!0,summary:a.trim()}}catch(n){return{success:!1,summary:"",error:n instanceof Error?n.message:"Summary failed"}}}function li(e){Ht();let t=document.createElement("div");t.id=Dr,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
|
|
17
|
+
position: fixed;
|
|
18
|
+
top: 0;
|
|
19
|
+
left: 0;
|
|
20
|
+
right: 0;
|
|
21
|
+
z-index: 9990;
|
|
22
|
+
background: #0d9488;
|
|
23
|
+
color: #ffffff;
|
|
24
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
25
|
+
font-size: 14px;
|
|
26
|
+
line-height: 1.6;
|
|
27
|
+
padding: 10px 20px;
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: flex-start;
|
|
30
|
+
justify-content: space-between;
|
|
31
|
+
gap: 12px;
|
|
32
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
|
33
|
+
`;let n=document.createElement("p");n.style.cssText="margin: 0; flex: 1;",n.textContent=`\u{1F4CB} Page summary: ${e}`;let r=document.createElement("button");r.textContent="\xD7",r.setAttribute("aria-label","Close page summary"),r.style.cssText=`
|
|
34
|
+
background: none; border: none; color: #ffffff;
|
|
35
|
+
font-size: 20px; cursor: pointer; padding: 0 4px;
|
|
36
|
+
line-height: 1; flex-shrink: 0;
|
|
37
|
+
`,r.addEventListener("click",Ht),t.appendChild(n),t.appendChild(r),document.body.prepend(t)}function Ht(){let e=document.getElementById(Dr);e&&e.remove()}var qr=[{code:"en",label:"English"},{code:"hi",label:"Hindi"},{code:"es",label:"Spanish"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"pt",label:"Portuguese"},{code:"nl",label:"Dutch"},{code:"pl",label:"Polish"},{code:"ru",label:"Russian"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"zh",label:"Chinese"},{code:"ar",label:"Arabic"},{code:"tr",label:"Turkish"},{code:"vi",label:"Vietnamese"},{code:"bn",label:"Bengali"},{code:"id",label:"Indonesian"}],_t="en";function ci(){let e=window;return e.Translator||e.translation||null}async function ui(e){try{let t=window;if(!ci())return!1;if(t.Translator&&typeof t.Translator.availability=="function")try{let r=await t.Translator.availability({sourceLanguage:"en",targetLanguage:e});return r==="readily"||r==="available"||r==="downloadable"||r==="after-download"}catch{}return t.Translator&&typeof t.Translator.canTranslate=="function"?await t.Translator.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":t.translation&&typeof t.translation.canTranslate=="function"?await t.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function di(e){let t=window,n={sourceLanguage:"en",targetLanguage:e};if(t.Translator&&typeof t.Translator.create=="function")return await t.Translator.create(n);if(t.translation&&typeof t.translation.createTranslator=="function")return await t.translation.createTranslator(n);throw new Error("Translation API not available")}async function Br(e){var n;if(e===_t)return{success:!0,language:e,fixed:0};if(e==="en")return zn(),_t="en",{success:!0,language:"en",fixed:0};if(!await ui(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let r=await di(e),a=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),i=0;for(let o of a){if(o.closest("[data-yuktai-panel]")||o.children.length>0)continue;let l=(n=o.innerText)==null?void 0:n.trim();if(!l||l.length<2)continue;o.dataset.yuktaiTranslationOriginal||(o.dataset.yuktaiTranslationOriginal=l);let s=await r.translate(l);s&&s!==l&&(o.innerText=s,i++)}return typeof r.destroy=="function"&&r.destroy(),_t=e,{success:!0,language:e,fixed:i}}catch(r){return{success:!1,language:e,fixed:0,error:r instanceof Error?r.message:"Translation failed"}}}function zn(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let n=t.dataset.yuktaiTranslationOriginal;n&&(t.innerText=n,delete t.dataset.yuktaiTranslationOriginal)}_t="en"}var pi=[{phrases:["go to main","skip to main","main content"],action:"focus-main",label:"Jump to main content"},{phrases:["go to navigation","go to nav","open menu"],action:"focus-nav",label:"Jump to navigation"},{phrases:["go to search","search","find"],action:"focus-search",label:"Jump to search"},{phrases:["scroll down","page down","next"],action:"scroll-down",label:"Scroll down"},{phrases:["scroll up","page up","back up"],action:"scroll-up",label:"Scroll up"},{phrases:["go back","previous page"],action:"go-back",label:"Go back"},{phrases:["click","press","select"],action:"click-focused",label:"Click focused element"},{phrases:["next item","tab forward","tab"],action:"tab-forward",label:"Move to next element"},{phrases:["previous item","tab back","shift tab"],action:"tab-back",label:"Move to previous element"},{phrases:["stop listening","stop voice","quiet"],action:"stop-voice",label:"Stop voice control"}],ce=null,Vt=!1,tt=null;function qn(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function gi(e){let t=e.toLowerCase().trim();for(let n of pi)for(let r of n.phrases)if(t.includes(r))return{action:n.action,label:n.label};return null}function mi(e){switch(e){case"focus-main":{let t=document.querySelector("main, [role='main'], #main");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-nav":{let t=document.querySelector("nav, [role='navigation']");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-search":{let t=document.querySelector("input[type='search'], input[role='searchbox'], [aria-label*='search' i]");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"scroll-down":{window.scrollBy({top:400,behavior:"smooth"});break}case"scroll-up":{window.scrollBy({top:-400,behavior:"smooth"});break}case"go-back":{window.history.back();break}case"click-focused":{let t=document.activeElement;t&&t!==document.body&&t.click();break}case"tab-forward":{let t=Hr(),n=t.indexOf(document.activeElement),r=t[n+1]||t[0];r&&r.focus();break}case"tab-back":{let t=Hr(),n=t.indexOf(document.activeElement),r=t[n-1]||t[t.length-1];r&&r.focus();break}case"stop-voice":{Bn();break}}}function Hr(){return Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>!e.closest("[data-yuktai-panel]"))}function _r(e){if(!qn())return!1;if(Vt)return!0;e&&(tt=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return ce=new t,ce.continuous=!0,ce.interimResults=!1,ce.lang="en-US",ce.onresult=n=>{let r=n.results[n.results.length-1][0].transcript,a=gi(r);if(a){mi(a.action);let i={success:!0,command:r,action:a.label};if(tt&&tt(i),a.action==="stop-voice")return}},ce.onend=()=>{Vt&&(ce==null||ce.start())},ce.onerror=n=>{n.error!=="no-speech"&&tt&&tt({success:!1,command:"",action:"",error:`Voice error: ${n.error}`})},ce.start(),Vt=!0,fi(),!0}function Bn(){Vt=!1,ce&&(ce.stop(),ce=null),tt=null,jr()}var Vr="yuktai-voice-indicator";function fi(){jr();let e=document.createElement("div");e.id=Vr,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
|
|
38
|
+
position: fixed;
|
|
39
|
+
bottom: 80px;
|
|
40
|
+
left: 50%;
|
|
41
|
+
transform: translateX(-50%);
|
|
42
|
+
z-index: 9995;
|
|
43
|
+
background: #0d9488;
|
|
44
|
+
color: #ffffff;
|
|
45
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
46
|
+
font-size: 13px;
|
|
47
|
+
font-weight: 500;
|
|
48
|
+
padding: 6px 14px;
|
|
49
|
+
border-radius: 99px;
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
gap: 8px;
|
|
53
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
`;let t=document.createElement("span");if(t.style.cssText=`
|
|
56
|
+
width: 8px;
|
|
57
|
+
height: 8px;
|
|
58
|
+
border-radius: 50%;
|
|
59
|
+
background: #ffffff;
|
|
60
|
+
animation: yuktai-pulse 1.2s infinite;
|
|
61
|
+
flex-shrink: 0;
|
|
62
|
+
`,!document.getElementById("yuktai-pulse-style")){let r=document.createElement("style");r.id="yuktai-pulse-style",r.textContent=`
|
|
63
|
+
@keyframes yuktai-pulse {
|
|
64
|
+
0%, 100% { opacity: 1; transform: scale(1); }
|
|
65
|
+
50% { opacity: 0.4; transform: scale(0.7); }
|
|
66
|
+
}
|
|
67
|
+
`,document.head.appendChild(r)}let n=document.createElement("span");n.textContent="Listening for commands...",e.appendChild(t),e.appendChild(n),document.body.appendChild(e)}function jr(){let e=document.getElementById(Vr);e&&e.remove()}var hi=["button:not([aria-label]):not([aria-labelledby])","a:not([aria-label]):not([aria-labelledby])","input:not([aria-label]):not([aria-labelledby]):not([id])","select:not([aria-label]):not([aria-labelledby])","textarea:not([aria-label]):not([aria-labelledby])","[role='button']:not([aria-label])","[role='link']:not([aria-label])","[role='checkbox']:not([aria-label])","[role='tab']:not([aria-label])"].join(", ");function Wr(){var t;let e=window;return e.Writer||((t=e.ai)==null?void 0:t.writer)||null}async function Hn(){try{let e=Wr();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}if(typeof e.capabilities=="function"){let t=await e.capabilities();return(t==null?void 0:t.available)!=="no"}return typeof e.create=="function"}catch{return!1}}function bi(e){var u,p,f,b,d,S,y;let t=[],n=(u=e.innerText)==null?void 0:u.trim();n&&t.push(`element text: "${n}"`);let r=(p=e.placeholder)==null?void 0:p.trim();r&&t.push(`placeholder: "${r}"`);let a=(f=e.getAttribute("name"))==null?void 0:f.trim();a&&t.push(`name: "${a}"`);let i=(b=e.getAttribute("type"))==null?void 0:b.trim();i&&t.push(`type: "${i}"`);let o=e.id;if(o){let m=document.querySelector(`label[for="${o}"]`);m&&t.push(`label: "${(d=m.innerText)==null?void 0:d.trim()}"`)}let l=(y=(S=e.parentElement)==null?void 0:S.innerText)==null?void 0:y.trim().slice(0,60);l&&t.push(`parent context: "${l}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let s=e.getAttribute("role");return s&&t.push(`role: ${s}`),t.join(". ")}async function yi(e,t){let n=`
|
|
68
|
+
Generate a short, clear aria-label for an HTML element.
|
|
69
|
+
The label must be 2-6 words maximum.
|
|
70
|
+
The label must describe what the element does or what it is.
|
|
71
|
+
Do not include punctuation.
|
|
72
|
+
Do not explain \u2014 just output the label text only.
|
|
73
|
+
|
|
74
|
+
Element details:
|
|
75
|
+
${t}
|
|
76
|
+
|
|
77
|
+
Output only the label. Nothing else.
|
|
78
|
+
`.trim();return(await e.write(n)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Ur(){if(!await Hn())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(hi);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let n=Wr();if(!n)throw new Error("Writer API not available");let r=await n.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),a=0,i=[];for(let o of t){if(o.closest("[data-yuktai-panel]"))continue;let l=window.getComputedStyle(o);if(l.display==="none"||l.visibility==="hidden")continue;let s=bi(o),u=await yi(r,s);u&&u.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",u),a++,i.push({tag:o.tagName.toLowerCase(),label:u}))}return r.destroy(),{success:!0,fixed:a,elements:i}}catch(n){return{success:!1,fixed:0,elements:[],error:n instanceof Error?n.message:"Label generation failed"}}}function Kr(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let n=t.dataset.yuktaiLabelOriginal;n?t.setAttribute("aria-label",n):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var Ut=null,Qr=null;var Yr=null,_n=null,X=null,nt=null,jt=null,Vn=null,ue=null,Wt={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Jr=new Set(["input","select","textarea"]);var jn={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function Wn(e,t="polite"){if(typeof window>"u"||!(ue!=null&&ue.speechEnabled)||!window.speechSynthesis)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(e);n.rate=1,n.pitch=1,n.volume=1;let r=window.speechSynthesis.getVoices();r.length>0&&(n.voice=r[0]),window.speechSynthesis.speak(n)}function io(e,t="info"){if(typeof document>"u")return;let r={success:{bg:"#0a7a44",border:"#075e34",icon:"\u2713"},error:{bg:"#b52a1c",border:"#8f2116",icon:"\u2715"},warning:{bg:"#a35f00",border:"#7a4700",icon:"\u26A0"},info:{bg:"#1557b0",border:"#0f4287",icon:"\u2139"}}[t];X||(X=document.createElement("div"),X.setAttribute("role","alert"),X.setAttribute("aria-live","assertive"),X.setAttribute("aria-atomic","true"),X.style.cssText=`
|
|
79
|
+
position: fixed;
|
|
80
|
+
top: 80px;
|
|
81
|
+
right: 16px;
|
|
82
|
+
left: auto;
|
|
83
|
+
z-index: 999999;
|
|
84
|
+
max-width: 320px;
|
|
85
|
+
width: calc(100% - 32px);
|
|
86
|
+
border-radius: 8px;
|
|
87
|
+
padding: 12px 16px;
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
gap: 10px;
|
|
91
|
+
font-family: system-ui, sans-serif;
|
|
92
|
+
font-size: 14px;
|
|
93
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
94
|
+
transition: transform 0.3s, opacity 0.3s;
|
|
95
|
+
transform: translateX(120%);
|
|
96
|
+
opacity: 0;
|
|
97
|
+
`,document.body.appendChild(X)),X.style.background=r.bg,X.style.border=`1px solid ${r.border}`,X.style.color="#fff",X.innerHTML=`
|
|
98
|
+
<span style="font-size:18px;font-weight:700">${r.icon}</span>
|
|
99
|
+
<span style="flex:1;line-height:1.4">${e}</span>
|
|
100
|
+
<button
|
|
101
|
+
onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
|
|
102
|
+
style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
|
|
103
|
+
aria-label="Close notification">\xD7</button>
|
|
104
|
+
`,window.innerWidth<=480&&(X.style.right="8px",X.style.left="8px",X.style.maxWidth="none",X.style.width="auto"),requestAnimationFrame(()=>{X&&(X.style.transform="translateX(0)",X.style.opacity="1")}),setTimeout(()=>{X&&(X.style.transform="translateX(120%)",X.style.opacity="0")},5e3)}function V(e,t="info",n=!0){Ut&&(Ut.textContent=e),io(e,t),n&&Wn(e,t==="error"?"assertive":"polite")}function vi(){if(typeof document>"u"||Yr)return;let e=[{label:"Skip to main content",selector:"main,[role='main'],#main,#main-content"},{label:"Skip to navigation",selector:"nav,[role='navigation'],#nav,#navigation"},{label:"Skip to search",selector:"[role='search'],#search,input[type='search']"}],t=document.createElement("div");t.setAttribute("data-yuktai-skip-bar","true"),t.setAttribute("role","navigation"),t.setAttribute("aria-label","Skip links"),t.style.cssText=`
|
|
105
|
+
position: fixed;
|
|
106
|
+
top: 0;
|
|
107
|
+
left: 0;
|
|
108
|
+
right: 0;
|
|
109
|
+
z-index: 999999;
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-wrap: wrap;
|
|
112
|
+
gap: 4px;
|
|
113
|
+
padding: 4px;
|
|
114
|
+
background: #111;
|
|
115
|
+
transform: translateY(-100%);
|
|
116
|
+
transition: transform 0.2s ease;
|
|
117
|
+
font-family: system-ui, sans-serif;
|
|
118
|
+
`;let n=!1;if(e.forEach(({label:a,selector:i})=>{let o=document.querySelector(i);if(!o)return;n=!0,o.getAttribute("tabindex")||o.setAttribute("tabindex","-1");let l=document.createElement("a");l.href="#",l.textContent=a,l.style.cssText=`
|
|
119
|
+
color: #fff;
|
|
120
|
+
background: #1a73e8;
|
|
121
|
+
padding: 8px 14px;
|
|
122
|
+
border-radius: 4px;
|
|
123
|
+
font-size: 13px;
|
|
124
|
+
font-weight: 600;
|
|
125
|
+
text-decoration: none;
|
|
126
|
+
white-space: nowrap;
|
|
127
|
+
border: 2px solid transparent;
|
|
128
|
+
transition: background 0.15s, border-color 0.15s;
|
|
129
|
+
`,l.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),l.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),l.addEventListener("click",s=>{s.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),V(`Jumped to ${a.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(l)}),!n)return;window.innerWidth<768&&(t.style.transform="translateY(0)",t.style.position="sticky"),window.addEventListener("resize",()=>{window.innerWidth<768&&(t.style.transform="translateY(0)")}),document.body.insertBefore(t,document.body.firstChild),Yr=t}function wi(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
|
|
130
|
+
|
|
131
|
+
/* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
|
|
132
|
+
[data-yuktai-a11y] *:focus-visible {
|
|
133
|
+
outline: 3px solid #1a73e8 !important;
|
|
134
|
+
outline-offset: 3px !important;
|
|
135
|
+
border-radius: 2px !important;
|
|
136
|
+
box-shadow: 0 0 0 6px rgba(26,115,232,0.15) !important;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* \u2500\u2500 High contrast focus \u2500\u2500 */
|
|
140
|
+
[data-yuktai-high-contrast] *:focus-visible {
|
|
141
|
+
outline: 3px solid #ffff00 !important;
|
|
142
|
+
outline-offset: 3px !important;
|
|
143
|
+
box-shadow: 0 0 0 6px rgba(255,255,0,0.2) !important;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* \u2500\u2500 Keyboard hint mode \u2500\u2500 */
|
|
147
|
+
[data-yuktai-keyboard] *:focus {
|
|
148
|
+
outline: 3px solid #ff6b35 !important;
|
|
149
|
+
outline-offset: 3px !important;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* \u2500\u2500 Remove default outline \u2014 replaced above \u2500\u2500 */
|
|
153
|
+
[data-yuktai-a11y] *:focus:not(:focus-visible) {
|
|
154
|
+
outline: none !important;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* \u2500\u2500 Large targets \u2014 WCAG 2.5.8 \u2500\u2500 */
|
|
158
|
+
[data-yuktai-large-targets] button,
|
|
159
|
+
[data-yuktai-large-targets] a,
|
|
160
|
+
[data-yuktai-large-targets] input,
|
|
161
|
+
[data-yuktai-large-targets] select,
|
|
162
|
+
[data-yuktai-large-targets] [role="button"] {
|
|
163
|
+
min-height: 44px !important;
|
|
164
|
+
min-width: 44px !important;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* \u2500\u2500 Reduce motion \u2014 WCAG 2.3.3 \u2500\u2500 */
|
|
168
|
+
[data-yuktai-reduce-motion] *,
|
|
169
|
+
[data-yuktai-reduce-motion] *::before,
|
|
170
|
+
[data-yuktai-reduce-motion] *::after {
|
|
171
|
+
animation-duration: 0.001ms !important;
|
|
172
|
+
transition-duration: 0.001ms !important;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* \u2500\u2500 High contrast mode \u2500\u2500 */
|
|
176
|
+
[data-yuktai-high-contrast] {
|
|
177
|
+
filter: contrast(1.4) brightness(1.05) !important;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* \u2500\u2500 Dark mode \u2500\u2500 */
|
|
181
|
+
[data-yuktai-dark] {
|
|
182
|
+
filter: invert(1) hue-rotate(180deg) !important;
|
|
183
|
+
}
|
|
184
|
+
[data-yuktai-dark] img,
|
|
185
|
+
[data-yuktai-dark] video,
|
|
186
|
+
[data-yuktai-dark] canvas {
|
|
187
|
+
filter: invert(1) hue-rotate(180deg) !important;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* \u2500\u2500 Dyslexia font \u2500\u2500 */
|
|
191
|
+
[data-yuktai-dyslexia] * {
|
|
192
|
+
font-family: "Atkinson Hyperlegible", "Arial", sans-serif !important;
|
|
193
|
+
letter-spacing: 0.05em !important;
|
|
194
|
+
word-spacing: 0.1em !important;
|
|
195
|
+
line-height: 1.8 !important;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* \u2500\u2500 Link underline enforcement \u2500\u2500 */
|
|
199
|
+
[data-yuktai-a11y] a:not([role]):not([class]) {
|
|
200
|
+
text-decoration: underline !important;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
204
|
+
RESPONSIVE BREAKPOINTS
|
|
205
|
+
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
206
|
+
|
|
207
|
+
/* Skip link bar \u2014 wrap on small screens */
|
|
208
|
+
@media (max-width: 768px) {
|
|
209
|
+
[data-yuktai-skip-bar] {
|
|
210
|
+
flex-wrap: wrap;
|
|
211
|
+
}
|
|
212
|
+
[data-yuktai-skip-bar] a {
|
|
213
|
+
font-size: 12px !important;
|
|
214
|
+
padding: 6px 10px !important;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* Preference panel \u2014 bottom sheet on mobile */
|
|
219
|
+
@media (max-width: 480px) {
|
|
220
|
+
[data-yuktai-panel] {
|
|
221
|
+
width: 100% !important;
|
|
222
|
+
right: 0 !important;
|
|
223
|
+
left: 0 !important;
|
|
224
|
+
bottom: 0 !important;
|
|
225
|
+
border-radius: 16px 16px 0 0 !important;
|
|
226
|
+
max-height: 85vh !important;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/* FAB button \u2014 reposition on mobile */
|
|
231
|
+
@media (max-width: 480px) {
|
|
232
|
+
[data-yuktai-pref-toggle] {
|
|
233
|
+
bottom: 12px !important;
|
|
234
|
+
right: 12px !important;
|
|
235
|
+
width: 44px !important;
|
|
236
|
+
height: 44px !important;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/* Audit badge \u2014 reposition on mobile */
|
|
241
|
+
@media (max-width: 480px) {
|
|
242
|
+
[data-yuktai-badge] {
|
|
243
|
+
bottom: 12px !important;
|
|
244
|
+
left: 12px !important;
|
|
245
|
+
font-size: 11px !important;
|
|
246
|
+
padding: 4px 10px !important;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* Keyboard cheatsheet \u2014 full width on mobile */
|
|
251
|
+
@media (max-width: 480px) {
|
|
252
|
+
[data-yuktai-cheatsheet] {
|
|
253
|
+
width: calc(100vw - 32px) !important;
|
|
254
|
+
max-height: 80vh !important;
|
|
255
|
+
overflow-y: auto !important;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/* Timeout warning \u2014 full width on mobile */
|
|
260
|
+
@media (max-width: 480px) {
|
|
261
|
+
[data-yuktai-timeout] {
|
|
262
|
+
width: calc(100vw - 32px) !important;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/* Visual alert \u2014 full width on mobile */
|
|
267
|
+
@media (max-width: 480px) {
|
|
268
|
+
[data-yuktai-alert] {
|
|
269
|
+
right: 8px !important;
|
|
270
|
+
left: 8px !important;
|
|
271
|
+
max-width: none !important;
|
|
272
|
+
width: auto !important;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
`,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function xi(){typeof document>"u"||document.querySelector("[data-yuktai-kb-init]")||(document.documentElement.setAttribute("data-yuktai-kb-init","true"),document.addEventListener("keydown",e=>{var r,a,i,o,l,s,u;let t=document.activeElement;if(!t)return;let n=t.getAttribute("role")||"";if(e.key==="Escape"){let p=t.closest("[role='dialog'],[role='alertdialog']");if(p){p.style.display="none",V("Dialog closed","info");return}let f=t.closest("[role='menu'],[role='menubar']");f&&(f.style.display="none",V("Menu closed","info"))}if(n==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let p=t.closest("[role='menu'],[role='menubar']");if(!p)return;let f=Array.from(p.querySelectorAll("[role='menuitem']:not([disabled])")),b=f.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),(r=f[(b+1)%f.length])==null||r.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),(a=f[(b-1+f.length)%f.length])==null||a.focus()):e.key==="Home"?(e.preventDefault(),(i=f[0])==null||i.focus()):e.key==="End"&&(e.preventDefault(),(o=f[f.length-1])==null||o.focus())}if(n==="tab"||t.closest("[role='tablist']")){let p=t.closest("[role='tablist']");if(!p)return;let f=Array.from(p.querySelectorAll("[role='tab']:not([disabled])")),b=f.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let d=f[(b+1)%f.length];d==null||d.focus(),d==null||d.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let d=f[(b-1+f.length)%f.length];d==null||d.focus(),d==null||d.click()}}if(n==="option"||t.closest("[role='listbox']")){let p=t.closest("[role='listbox']");if(!p)return;let f=Array.from(p.querySelectorAll("[role='option']:not([aria-disabled='true'])")),b=f.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),(l=f[(b+1)%f.length])==null||l.focus()):e.key==="ArrowUp"?(e.preventDefault(),(s=f[(b-1+f.length)%f.length])==null||s.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),f.forEach(d=>{d!==t&&d.setAttribute("aria-selected","false")}),V(`Selected: ${(u=t.textContent)==null?void 0:u.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),ki()),e.key==="Tab"&&(ue!=null&&ue.speechEnabled)&&setTimeout(()=>{var d;let p=document.activeElement;if(!p)return;let f=p.getAttribute("aria-label")||p.getAttribute("title")||((d=p.textContent)==null?void 0:d.trim())||p.tagName.toLowerCase(),b=p.getAttribute("role")||p.tagName.toLowerCase();Wn(`${f}, ${b}`)},100)}))}function Kt(e){let t=e.querySelectorAll('button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"]),[role="button"]');if(t.length===0)return;let n=t[0],r=t[t.length-1];n.focus(),e.addEventListener("keydown",a=>{a.key==="Tab"&&(a.shiftKey?document.activeElement===n&&(a.preventDefault(),r.focus()):document.activeElement===r&&(a.preventDefault(),n.focus()))})}function ki(){if(typeof document>"u")return;if(nt){nt.remove(),nt=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
|
|
276
|
+
position: fixed;
|
|
277
|
+
top: 50%;
|
|
278
|
+
left: 50%;
|
|
279
|
+
transform: translate(-50%, -50%);
|
|
280
|
+
z-index: 999999;
|
|
281
|
+
background: #1a1a2e;
|
|
282
|
+
color: #fff;
|
|
283
|
+
border-radius: 12px;
|
|
284
|
+
padding: 24px;
|
|
285
|
+
width: min(320px, calc(100vw - 32px));
|
|
286
|
+
max-height: 80vh;
|
|
287
|
+
overflow-y: auto;
|
|
288
|
+
box-shadow: 0 20px 60px rgba(0,0,0,0.5);
|
|
289
|
+
font-family: system-ui, sans-serif;
|
|
290
|
+
`;let t=[["Alt + A","Open/close this menu"],["Tab","Next focusable element"],["Shift+Tab","Previous focusable element"],["Enter","Activate button or link"],["Space","Check checkbox / scroll"],["Arrow keys","Navigate lists and menus"],["Escape","Close dialog or menu"],["Home","First item in list"],["End","Last item in list"]];e.innerHTML=`
|
|
291
|
+
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:16px">
|
|
292
|
+
<h2 style="margin:0;font-size:16px;font-weight:700;color:#74c0fc">
|
|
293
|
+
\u2328 Keyboard shortcuts
|
|
294
|
+
</h2>
|
|
295
|
+
<button data-yuktai-close
|
|
296
|
+
style="background:none;border:none;color:#aaa;cursor:pointer;font-size:20px;padding:0;line-height:1"
|
|
297
|
+
aria-label="Close shortcuts">\xD7</button>
|
|
298
|
+
</div>
|
|
299
|
+
${t.map(([r,a])=>`
|
|
300
|
+
<div style="display:flex;justify-content:space-between;align-items:center;padding:6px 0;border-bottom:1px solid #2a2a4a">
|
|
301
|
+
<kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${r}</kbd>
|
|
302
|
+
<span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${a}</span>
|
|
303
|
+
</div>
|
|
304
|
+
`).join("")}
|
|
305
|
+
`;let n=e.querySelector("[data-yuktai-close]");n==null||n.addEventListener("click",()=>{e.remove(),nt=null}),e.addEventListener("keydown",r=>{r.key==="Escape"&&(e.remove(),nt=null)}),document.body.appendChild(e),nt=e,Kt(e),V("Keyboard shortcuts opened. Press Escape to close.","info")}function Ai(e){if(typeof document>"u"||!(ue!=null&&ue.showAuditBadge)||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;_n&&_n.remove();let t=e.score,n=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",r=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",a=document.createElement("button");a.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),a.setAttribute("data-yuktai-badge","true"),a.style.cssText=`
|
|
306
|
+
position: fixed;
|
|
307
|
+
bottom: 16px;
|
|
308
|
+
left: 16px;
|
|
309
|
+
z-index: 999998;
|
|
310
|
+
background: ${n};
|
|
311
|
+
color: #fff;
|
|
312
|
+
border: none;
|
|
313
|
+
border-radius: 20px;
|
|
314
|
+
cursor: pointer;
|
|
315
|
+
padding: 6px 12px;
|
|
316
|
+
font-size: 12px;
|
|
317
|
+
font-weight: 700;
|
|
318
|
+
font-family: system-ui, sans-serif;
|
|
319
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
|
320
|
+
display: flex;
|
|
321
|
+
align-items: center;
|
|
322
|
+
gap: 6px;
|
|
323
|
+
transition: transform 0.15s;
|
|
324
|
+
`,a.innerHTML=`${r} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,a.addEventListener("click",()=>Ti(e)),document.body.appendChild(a),_n=a}function Ti(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let n=document.createElement("div");n.setAttribute("data-yuktai-audit-details","true"),n.setAttribute("role","dialog"),n.setAttribute("aria-label","Accessibility audit details"),n.style.cssText=`
|
|
325
|
+
position: fixed;
|
|
326
|
+
bottom: 56px;
|
|
327
|
+
left: 16px;
|
|
328
|
+
right: 16px;
|
|
329
|
+
z-index: 999999;
|
|
330
|
+
background: #1a1a2e;
|
|
331
|
+
color: #fff;
|
|
332
|
+
border-radius: 12px;
|
|
333
|
+
padding: 16px;
|
|
334
|
+
width: auto;
|
|
335
|
+
max-width: 340px;
|
|
336
|
+
max-height: 60vh;
|
|
337
|
+
overflow-y: auto;
|
|
338
|
+
box-shadow: 0 8px 32px rgba(0,0,0,0.5);
|
|
339
|
+
font-family: system-ui, sans-serif;
|
|
340
|
+
font-size: 12px;
|
|
341
|
+
`;let r={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};n.innerHTML=`
|
|
342
|
+
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
|
|
343
|
+
<strong style="font-size:14px;color:#74c0fc">Audit report</strong>
|
|
344
|
+
<span style="color:#aaa">${e.fixed} fixed \xB7 ${e.renderTime}ms</span>
|
|
345
|
+
</div>
|
|
346
|
+
${e.details.slice(0,20).map(a=>`
|
|
347
|
+
<div style="padding:6px 0;border-bottom:1px solid #2a2a4a">
|
|
348
|
+
<div style="display:flex;gap:6px;align-items:center">
|
|
349
|
+
<span style="background:${r[a.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${a.severity}</span>
|
|
350
|
+
<code style="color:#74c0fc"><${a.tag}></code>
|
|
351
|
+
</div>
|
|
352
|
+
<div style="color:#ccc;margin-top:3px">${a.fix}</div>
|
|
353
|
+
</div>
|
|
354
|
+
`).join("")}
|
|
355
|
+
${e.details.length>20?`<div style="color:#888;padding:8px 0;text-align:center">+${e.details.length-20} more issues</div>`:""}
|
|
356
|
+
`,n.addEventListener("keydown",a=>{a.key==="Escape"&&n.remove()}),document.body.appendChild(n),Kt(n)}function ao(e){typeof document>"u"||(Vn&&clearTimeout(Vn),Vn=setTimeout(()=>{if(jt)return;let t=document.createElement("div");t.setAttribute("role","alertdialog"),t.setAttribute("aria-label","Session timeout warning"),t.setAttribute("aria-modal","true"),t.setAttribute("data-yuktai-timeout","true"),t.style.cssText=`
|
|
357
|
+
position: fixed;
|
|
358
|
+
top: 50%;
|
|
359
|
+
left: 50%;
|
|
360
|
+
transform: translate(-50%, -50%);
|
|
361
|
+
z-index: 999999;
|
|
362
|
+
background: #fff;
|
|
363
|
+
color: #111;
|
|
364
|
+
border-radius: 12px;
|
|
365
|
+
padding: 24px;
|
|
366
|
+
width: min(320px, calc(100vw - 32px));
|
|
367
|
+
box-shadow: 0 20px 60px rgba(0,0,0,0.4);
|
|
368
|
+
font-family: system-ui, sans-serif;
|
|
369
|
+
border: 2px solid #d93025;
|
|
370
|
+
`,t.innerHTML=`
|
|
371
|
+
<h2 style="margin:0 0 8px;font-size:18px;color:#d93025">\u23F1 Session timeout</h2>
|
|
372
|
+
<p style="margin:0 0 16px;font-size:14px;line-height:1.5;color:#444">
|
|
373
|
+
Your session will expire soon. Do you need more time?
|
|
374
|
+
</p>
|
|
375
|
+
<div style="display:flex;gap:8px;flex-wrap:wrap">
|
|
376
|
+
<button data-yuktai-extend
|
|
377
|
+
style="flex:1;min-width:120px;padding:10px;background:#1a73e8;color:#fff;border:none;border-radius:8px;cursor:pointer;font-size:14px;font-weight:600">
|
|
378
|
+
Yes, more time
|
|
379
|
+
</button>
|
|
380
|
+
<button data-yuktai-dismiss
|
|
381
|
+
style="flex:1;min-width:120px;padding:10px;background:#f1f3f4;color:#111;border:none;border-radius:8px;cursor:pointer;font-size:14px">
|
|
382
|
+
No, sign out
|
|
383
|
+
</button>
|
|
384
|
+
</div>
|
|
385
|
+
`;let n=t.querySelector("[data-yuktai-extend]"),r=t.querySelector("[data-yuktai-dismiss]");n==null||n.addEventListener("click",()=>{t.remove(),jt=null,V("Session extended. You have more time.","success"),ue!=null&&ue.timeoutWarning&&ao(ue.timeoutWarning)}),r==null||r.addEventListener("click",()=>{t.remove(),jt=null}),document.body.appendChild(t),jt=t,Kt(t),V("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function Si(e){if(typeof document>"u")return;let t=document.documentElement;if(t.toggleAttribute("data-yuktai-high-contrast",!!e.highContrast),t.toggleAttribute("data-yuktai-dark",!!e.darkMode),t.toggleAttribute("data-yuktai-reduce-motion",!!e.reduceMotion),t.toggleAttribute("data-yuktai-large-targets",!!e.largeTargets),t.toggleAttribute("data-yuktai-keyboard",!!e.keyboardHints),t.toggleAttribute("data-yuktai-dyslexia",!!e.dyslexiaFont),e.localFont?document.body.style.fontFamily=`"${e.localFont}", system-ui, sans-serif`:e.dyslexiaFont||(document.body.style.fontFamily=""),e.fontSizeMultiplier&&e.fontSizeMultiplier!==1?document.documentElement.style.fontSize=`${e.fontSizeMultiplier*100}%`:document.documentElement.style.fontSize="",e.colorBlindMode&&e.colorBlindMode!=="none"){let n=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${Wt[e.colorBlindMode]})`;document.body.style.filter=n}else document.body.style.filter=""}function Ci(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function Xr(e){if(e){if(!await Dn()){V("Plain English requires Chrome 127+","warning");return}V("Rewriting page in plain English...","info",!1);let n=await Pr();V(n.error?`Plain English failed: ${n.error}`:`${n.fixed} sections rewritten in plain English`,n.error?"error":"success",!1)}else Gr(),V("Original text restored","info",!1)}async function Zr(e){if(e){if(!await On()){V("Page summariser requires Chrome 127+","warning");return}V("Generating page summary...","info",!1);let n=await zr();V(n.error?`Summary failed: ${n.error}`:"Page summary added at top",n.error?"error":"success",!1)}else Ht(),V("Page summary removed","info",!1)}async function eo(e){if(e==="en"){zn(),V("Page restored to English","info",!1);return}V(`Translating page to ${e}...`,"info",!1);let t=await Br(e);V(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function to(e){if(e){if(!qn()){V("Voice control not supported in this browser","warning");return}_r(t=>{t.success&&V(`Voice: ${t.action}`,"info",!1)}),V("Voice control started. Say a command.","success",!1)}else Bn(),V("Voice control stopped","info",!1)}async function no(e){if(e){if(!await Hn()){V("Smart labels requires Chrome 127+","warning");return}V("Generating smart labels...","info",!1);let n=await Ur();V(n.error?`Smart labels failed: ${n.error}`:`${n.fixed} elements labelled`,n.error?"error":"success",!1)}else Kr(),V("Smart labels removed","info",!1)}function $i(){if(typeof document>"u"||Ut)return;let e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("aria-relevant","text"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);",document.body.appendChild(e),Ut=e}function Ri(){if(typeof document>"u"||Qr)return;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",e.innerHTML=`
|
|
386
|
+
<defs>
|
|
387
|
+
<filter id="${Wt.deuteranopia}">
|
|
388
|
+
<feColorMatrix type="matrix"
|
|
389
|
+
values="0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0"/>
|
|
390
|
+
</filter>
|
|
391
|
+
<filter id="${Wt.protanopia}">
|
|
392
|
+
<feColorMatrix type="matrix"
|
|
393
|
+
values="0.567 0.433 0 0 0 0.558 0.442 0 0 0 0 0.242 0.758 0 0 0 0 0 1 0"/>
|
|
394
|
+
</filter>
|
|
395
|
+
<filter id="${Wt.tritanopia}">
|
|
396
|
+
<feColorMatrix type="matrix"
|
|
397
|
+
values="0.95 0.05 0 0 0 0 0.433 0.567 0 0 0 0.475 0.525 0 0 0 0 0 1 0"/>
|
|
398
|
+
</filter>
|
|
399
|
+
</defs>
|
|
400
|
+
`,document.body.appendChild(e),Qr=e}function ro(e){var t,n,r;return(t=e.getAttribute("aria-label"))!=null&&t.trim()||e.getAttribute("aria-labelledby")||(n=e.getAttribute("title"))!=null&&n.trim()||(r=e.textContent)!=null&&r.trim()?!0:!!e.querySelector("img[alt]:not([alt='']), svg[aria-label], svg title, [aria-label]")}function oo(e){let t={critical:20,serious:10,moderate:5,minor:2},n=e.details.reduce((r,a)=>r+(t[a.severity]||0),0);return Math.max(0,Math.min(100,100-n))}var He={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";ue=e,Ci(e),$i(),Ri(),wi(),xi(),e.showSkipLinks!==!1&&vi(),e.showPreferencePanel,Si(e);let t=this.applyFixes(e);t.score=oo(t),e.showAuditBadge&&Ai(t),e.timeoutWarning&&ao(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Xr(!0),e.summarisePage&&await Zr(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await eo(e.translateLanguage),e.voiceControl&&await to(!0),e.smartLabels&&await no(!0);let n=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return V(n,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${n} Scanned ${t.scanned} elements in ${t.renderTime}ms.`},applyFixes(e){let t={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return t;let n=performance.now(),r=document.querySelectorAll("*");t.scanned=r.length;let a=(i,o,l,s)=>{t.details.push({tag:i,fix:o,severity:l,element:s.outerHTML.slice(0,100)}),t.fixed++};return r.forEach(i=>{var p,f;let o=i,l=o.tagName.toLowerCase();if(l==="html"&&!o.getAttribute("lang")&&(o.setAttribute("lang","en"),a(l,'lang="en" added',"critical",o)),l==="meta"){let b=o.getAttribute("name"),d=o.getAttribute("content")||"";b==="viewport"&&d.includes("user-scalable=no")&&(o.setAttribute("content",d.replace("user-scalable=no","user-scalable=yes")),a(l,"user-scalable=yes restored","serious",o)),b==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(d)&&(o.setAttribute("content",d.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),a(l,"maximum-scale=5 restored","serious",o))}if(l==="main"&&!o.getAttribute("tabindex")&&(o.setAttribute("tabindex","-1"),o.getAttribute("id")||o.setAttribute("id","main-content")),l==="img"&&(o.hasAttribute("alt")||(o.setAttribute("alt",""),o.setAttribute("aria-hidden","true"),a(l,'alt="" aria-hidden="true"',"serious",o))),l==="svg"&&(!o.getAttribute("aria-hidden")&&!o.getAttribute("aria-label")&&!i.querySelector("title")&&(o.setAttribute("aria-hidden","true"),a(l,'aria-hidden="true" (decorative svg)',"minor",o)),o.getAttribute("focusable")||o.setAttribute("focusable","false")),l==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&(o.setAttribute("title","embedded content"),o.setAttribute("aria-label","embedded content"),a(l,"title + aria-label added","serious",o)),l==="button"){if(!ro(o)){let b=o.getAttribute("title")||"button";o.setAttribute("aria-label",b),a(l,`aria-label="${b}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(l==="a"){let b=o;ro(o)||(o.setAttribute("aria-label",o.getAttribute("title")||"link"),a(l,"aria-label added (empty link)","critical",o)),b.target==="_blank"&&!((p=b.rel)!=null&&p.includes("noopener"))&&(b.rel="noopener noreferrer",t.fixed++)}if(Jr.has(l)){let b=o;if(!(!!(b.labels&&b.labels.length)||!!o.getAttribute("title")||b.type==="hidden"||b.type==="submit"||b.type==="button"||b.type==="reset")&&!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let S=o.getAttribute("placeholder")||o.getAttribute("name")||l;o.setAttribute("aria-label",S),a(l,`aria-label="${S}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),l==="input"&&!b.autocomplete){let S=b.name||"",y=b.type==="email"||S.includes("email")?"email":b.type==="tel"||S.includes("tel")?"tel":b.type==="password"?"current-password":"";y&&(b.autocomplete=y,t.fixed++)}}l==="th"&&!o.getAttribute("scope")&&(o.setAttribute("scope",o.closest("thead")?"col":"row"),a(l,"scope added to <th>","moderate",o));let s=(l==="header"||l==="footer")&&!!((f=o.parentElement)!=null&&f.closest("article,aside,main,nav,section,[role='dialog'],[role='region']"));jn[l]&&!o.getAttribute("role")&&!s&&(o.setAttribute("role",jn[l]),a(l,`role="${jn[l]}"`,"minor",o));let u=o.getAttribute("role")||"";u==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(u)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",u==="alert"?"assertive":"polite"),a(l,`aria-live added on role=${u}`,"moderate",o)),u==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),a(l,'aria-expanded="false" on combobox',"serious",o)),(u==="checkbox"||u==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),a(l,`aria-checked="false" on role=${u}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-n).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),n=document.querySelectorAll("*");e.scanned=n.length;let r=(a,i,o,l)=>e.details.push({tag:a,fix:i,severity:o,element:l.outerHTML.slice(0,100)});return n.forEach(a=>{var l;let i=a,o=i.tagName.toLowerCase();(o==="a"||o==="button")&&!((l=i.innerText)!=null&&l.trim())&&!i.getAttribute("aria-label")&&r(o,"needs aria-label (empty)","critical",i),o==="img"&&!i.hasAttribute("alt")&&r(o,"needs alt text","serious",i),Jr.has(o)&&!i.getAttribute("aria-label")&&!i.getAttribute("aria-labelledby")&&r(o,"needs aria-label","serious",i),o==="iframe"&&!i.getAttribute("title")&&!i.getAttribute("aria-label")&&r(o,"iframe needs title","serious",i)}),e.fixed=e.details.length,e.score=oo(e),e.renderTime=parseFloat((performance.now()-t).toFixed(2)),e},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(e)),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){var e;(e=this.observer)==null||e.disconnect(),this.observer=null},announce:V,speak:Wn,showVisualAlert:io,trapFocus:Kt,handlePlainEnglish:Xr,handleSummarisePage:Zr,handleTranslate:eo,handleVoiceControl:to,handleSmartLabels:no,SUPPORTED_LANGUAGES:qr};var Ei=/\b(off|disable|stop|remove|no more|turn off|switch off|deactivate)\b|ఆఫ్|ఆపు|తీసివేయి|बंद/i,Li=[{pattern:/high contrast|contrast|హై కాంట్రాస్ట్|కాంట్రాస్ట్/i,key:"highContrast",name:"High contrast"},{pattern:/dark mode|dark theme|night mode|డార్క్ మోడ్|చీకటి/i,key:"darkMode",name:"Dark mode"},{pattern:/reduce motion|less motion|stop animation|animations?|కదలికలు/i,key:"reduceMotion",name:"Reduced motion"},{pattern:/large targets?|bigger buttons?|big buttons?|larger buttons?|పెద్ద బటన్/i,key:"largeTargets",name:"Large targets"},{pattern:/dyslexia|readable font|easy font/i,key:"dyslexiaFont",name:"Dyslexia-friendly font"},{pattern:/speak on focus|read aloud|read out|screen reader|speech|చదివి వినిపించు/i,key:"speechEnabled",name:"Speak on focus"},{pattern:/skip links?/i,key:"showSkipLinks",name:"Skip links"}],Mi=[[/deuteranop|green.?blind/i,"deuteranopia"],[/protanop|red.?blind/i,"protanopia"],[/tritanop|blue.?blind/i,"tritanopia"],[/grey ?scale|gray ?scale|achromat|black and white/i,"achromatopsia"]],Qt=.1,Un=.8,Kn=1.3;function Qn(e,t={}){let n=e.trim().toLowerCase();if(!n)return null;if(/\b(next|down)\s+(row|line|record|item)\b|తర్వాతి (వరుస|అంశం)/.test(n))return{type:"grid",action:"next-row",say:"Next row."};if(/\b(previous|prev|back|up)\s+(row|line|record|item)\b|ముందరి (వరుస|అంశం)|వెనుక (వరుస|అంశం)/.test(n))return{type:"grid",action:"previous-row",say:"Previous row."};if(/\bfirst\s+(row|record|item)\b|మొదటి (వరుస|అంశం)/.test(n))return{type:"grid",action:"first-row",say:"First row."};if(/\blast\s+(row|record|item)\b|చివరి (వరుస|అంశం)/.test(n))return{type:"grid",action:"last-row",say:"Last row."};if(/\b(open|expand|read)\s+(this\s+)?(row|record|item)\b|ఈ (వరుస|అంశం) తెరువు/.test(n))return{type:"grid",action:"open-row",say:"Opening row."};if(/\b(reset|default|restore)\b.*\b(settings?|accessibility|everything|all)\b|^reset$|రీసెట్/.test(n))return{type:"reset",say:"Accessibility settings reset."};let r=t.fontSizeMultiplier??1,a=o=>Math.round(Math.min(Kn,Math.max(Un,o))*100)/100;if(/\b(bigger|larger|increase|zoom in)\b.*\b(text|font|letters?)\b|\b(text|font)\b.*\b(bigger|larger|up)\b|పెద్ద అక్షరాలు|అక్షరాలు పెద్ద/.test(n)){let o=a(r+Qt);return{type:"setting",patch:{fontSizeMultiplier:o},say:`Text size ${Math.round(o*100)}%.`}}if(/\b(smaller|decrease|reduce|zoom out)\b.*\b(text|font|letters?)\b|\b(text|font)\b.*\b(smaller|down)\b|చిన్న అక్షరాలు|అక్షరాలు చిన్న/.test(n)){let o=a(r-Qt);return{type:"setting",patch:{fontSizeMultiplier:o},say:`Text size ${Math.round(o*100)}%.`}}if(/\b(normal|default|reset)\b.*\b(text|font)\s*(size)?\b/.test(n))return{type:"setting",patch:{fontSizeMultiplier:1},say:"Text size 100%."};let i=Ei.test(n);for(let[o,l]of Mi)if(o.test(n))return i?{type:"setting",patch:{colorBlindMode:"none"},say:"Colour filter off."}:{type:"setting",patch:{colorBlindMode:l},say:`${l} filter on.`};if(/colou?r.?blind/.test(n)&&i)return{type:"setting",patch:{colorBlindMode:"none"},say:"Colour filter off."};for(let o of Li){if(!o.pattern.test(n))continue;let l=/\btoggle\b/.test(n)?!t[o.key]:!i;return o.key==="reduceMotion"&&!/reduce motion|less motion|కదలికలు తగ్గించు/.test(n)&&/animations?/.test(n)&&(l=i||/\bno\b/.test(n)),{type:"setting",patch:{[o.key]:l},say:`${o.name} ${l?"on":"off"}.`}}return null}var rt={highContrast:!1,darkMode:!1,reduceMotion:!1,largeTargets:!1,dyslexiaFont:!1,speechEnabled:!1,colorBlindMode:"none",fontSizeMultiplier:1};function Yn(e,t={}){var u,p;if(!ke())return null;let n=t.root??document,r=t.rowSelector??"[data-yuktai-row-id], [role='row']",a=Array.from(n.querySelectorAll(r)).filter(f=>!f.querySelector("th,[role='columnheader']"));if(!a.length)return null;let i=(u=document.activeElement)==null?void 0:u.closest(r),o=i?a.indexOf(i):-1;if(e==="open-row"){let f=o>=0?a[o]:a[0];return f.click(),f}let l=e==="first-row"?0:e==="last-row"?a.length-1:e==="next-row"?Math.min(a.length-1,o+1):Math.max(0,o-1),s=a[l];return s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1"),s.focus(),(p=s.scrollIntoView)==null||p.call(s,{block:"nearest"}),s}function Yt(e={}){let t={enabled:!0,...rt,...e.initial},n=null,r=!1,a=async u=>e.apply?e.apply(u):He.execute(u),i=u=>{if(e.speak===!1||!ke()||!("speechSynthesis"in window))return;let p=new SpeechSynthesisUtterance(u);p.lang=e.lang??"en-IN",window.speechSynthesis.cancel(),window.speechSynthesis.speak(p)};async function o(u){var f;let p=Qn(u,t);if((f=e.onTranscript)==null||f.call(e,u,p),!p)return null;if(p.type==="grid"){let b=Yn(p.action,{root:e.gridRoot});return i(b?p.say:"No table rows found."),p}return t=p.type==="reset"?{...t,...rt}:{...t,...p.patch},await a(t),i(p.say),p}function l(){if(!ke()||r)return r;let u=window,p=u.SpeechRecognition??u.webkitSpeechRecognition;return p?(n=new p,n.lang=e.lang??"en-IN",n.continuous=!0,n.interimResults=!1,n.onresult=f=>{var S;let b=f.results,d=b[b.length-1];(S=d==null?void 0:d[0])!=null&&S.transcript&&o(d[0].transcript)},n.onend=()=>{r&&(n==null||n.start())},n.onerror=f=>{(f.error==="not-allowed"||f.error==="service-not-allowed")&&(r=!1)},r=!0,n.start(),!0):!1}function s(){r=!1,n==null||n.stop(),n=null}return{start:l,stop:s,handle:o,isListening:()=>r,getConfig:()=>({...t})}}function co(){let e=new Set;return{subscribe(t){return e.add(t),()=>e.delete(t)},emit(t){e.forEach(n=>{try{n(t)}catch(r){console.error("[yuktai] listener failed",r)}})}}}var Xn=e=>e instanceof Error?e:new Error(String(e)),Ii={en:{done:"Done.",toolMissing:e=>`The action "${e}" is not available here.`,missingInput:e=>`Missing: ${e}.`,notUnderstood:"Sorry, I didn't understand. Try: a word to search, \u201Csort by <column>\u201D, or \u201Cclear filters\u201D.",noMatch:e=>`Nothing matched "${e}".`,failed:"Something went wrong while running this action."},te:{done:"\u0C2A\u0C42\u0C30\u0C4D\u0C24\u0C2F\u0C3F\u0C02\u0C26\u0C3F.",toolMissing:e=>`"${e}" \u0C38\u0C4C\u0C15\u0C30\u0C4D\u0C2F\u0C02 \u0C07\u0C15\u0C4D\u0C15\u0C21 \u0C05\u0C02\u0C26\u0C41\u0C2C\u0C3E\u0C1F\u0C41\u0C32\u0C4B \u0C32\u0C47\u0C26\u0C41.`,missingInput:e=>`\u0C07\u0C35\u0C3F \u0C15\u0C3E\u0C35\u0C3E\u0C32\u0C3F: ${e}.`,notUnderstood:"\u0C15\u0C4D\u0C37\u0C2E\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F, \u0C05\u0C30\u0C4D\u0C25\u0C02 \u0C15\u0C3E\u0C32\u0C47\u0C26\u0C41. \u0C07\u0C32\u0C3E \u0C2A\u0C4D\u0C30\u0C2F\u0C24\u0C4D\u0C28\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F: \u0C35\u0C46\u0C24\u0C15\u0C3E\u0C32\u0C4D\u0C38\u0C3F\u0C28 \u0C2A\u0C26\u0C02, \u201C<\u0C15\u0C3E\u0C32\u0C2E\u0C4D> \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C15\u0C4D\u0C30\u0C2E\u0C02\u201D, \u0C32\u0C47\u0C26\u0C3E \u201C\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F\u201D.",noMatch:e=>`"${e}" \u0C15\u0C3F \u0C0F\u0C2E\u0C40 \u0C38\u0C30\u0C3F\u0C2A\u0C4B\u0C32\u0C47\u0C26\u0C41.`,failed:"\u0C08 \u0C2A\u0C28\u0C3F \u0C1A\u0C47\u0C38\u0C4D\u0C24\u0C41\u0C02\u0C21\u0C17\u0C3E \u0C38\u0C2E\u0C38\u0C4D\u0C2F \u0C35\u0C1A\u0C4D\u0C1A\u0C3F\u0C02\u0C26\u0C3F."}},so=e=>String(e??"").normalize("NFC").toLowerCase().trim(),Ne={clearFilters:/\b(clear|remove|reset)\b.*\bfilters?\b|ఫిల్టర్.*(తీసే|తొలగ)/i,clearSort:/\b(clear|remove|reset)\b.*\bsort(ing)?\b|క్రమం.*(తీసే|తొలగ)/i,count:/^\s*(how many|count)\b|ఎన్ని|లెక్క/i,sort:/\bsort\b|\border by\b|క్రమ|అమర్చ|సార్ట్/i,desc:/\b(desc|descending|z\s*-\s*a|highest|largest|most)\b|అవరోహణ|తగ్గే|పెద్ద|అధిక|చివర|ఎక్కువ నుండి/i,openEn:/^\s*open\s+(.+?)\s*$/i,openTe:/^\s*(.+?)\s*(తెరువు|తెరవండి|తెరవు)\s*$/,searchFiller:/^\s*(search(\s+for)?|find|show(\s+me)?|filter(\s+by)?|look\s+for|వెతుకు|వెతకండి|శోధించు|శోధించండి|చూపించు|చూపించండి)\s+|\s+(వెతుకు|వెతకండి|శోధించు|శోధించండి|చూపించు|చూపించండి)\s*$/gi};function Ni(e,t){let n=so(e),r=null;for(let a of t)for(let i of[a.label,a.key]){let o=so(i);o&&n.includes(o)&&(!r||o.length>r.len)&&(r={key:a.key,len:o.length})}return r?r.key:null}function Zn(e,t){let n=String(e??"").trim();if(!n)return null;let r=t&&t.columns||[];if(Ne.clearFilters.test(n))return{kind:"tool",tool:"clear_filters",input:{}};if(Ne.clearSort.test(n))return{kind:"tool",tool:"clear_sort",input:{}};if(Ne.count.test(n))return{kind:"tool",tool:"count",input:{}};if(Ne.sort.test(n)){let o=Ni(n,r);return o?{kind:"tool",tool:"sort",input:{key:o,direction:Ne.desc.test(n)?"desc":"asc"}}:null}let a=n.match(Ne.openEn)||n.match(Ne.openTe);if(a&&a[1])return{kind:"open",text:a[1].trim()};let i=n.replace(Ne.searchFiller,"").trim();return i?{kind:"tool",tool:"search",input:{query:i}}:null}function Fi(e){return!!e&&typeof e=="object"&&typeof e.success=="boolean"&&typeof e.message=="string"}function Pi(e,t){let n=e.inputSchema&&e.inputSchema.required;return Array.isArray(n)?n.map(String).filter(r=>t[r]===void 0||t[r]===null||String(t[r]).trim()===""):[]}function Gi(e,t){let n=e.find(a=>a.name===t);if(n)return n;let r=e.filter(a=>a.name.endsWith(`_${t}`)).sort((a,i)=>a.name.length-i.name.length);if(r.length&&!(r.length>1&&r[0].name.length===r[1].name.length))return r[0]}var lo=e=>String(e??"").normalize("NFC").trim().toLocaleLowerCase();function Di(e,t){let n=lo(e);return(t||[]).find(r=>(r.phrases||[]).some(a=>{let i=lo(a);return i.length>0&&n.includes(i)}))}function Jt(e={}){let t=E=>typeof E=="function"?E():E,n={locale:"en",rowKey:"id",historyLimit:20,customRules:[],...e},r=co(),a=0,i=null,o=null,l=[],s=0,u=()=>Ii[n.locale==="te"?"te":"en"],p=()=>t(n.tools)||[],f=()=>({loading:a>0,lastResult:i,lastError:o,history:l.slice()}),b=()=>r.emit(f());function d(E,k,h,w,v){v===s&&(i=h),l=[...l,{id:v,tool:E,input:k,result:h,source:w,at:Date.now()}].slice(-n.historyLimit),b()}async function S(E,k,h){let w=++s,v=Gi(p(),E);if(!v){let x={success:!1,message:u().toolMissing(E),error:{code:"NOT_SUPPORTED"}};return o=new Error(x.message),n.onError&&n.onError(o),d(E,k,x,h,w),x}let L=Pi(v,k);if(L.length){let x={success:!1,message:u().missingInput(L.join(", ")),error:{code:"INVALID_INPUT"},tool:v.name};return d(v.name,k,x,h,w),n.onResult&&n.onResult(x),x}a++,b();try{let x=await v.execute(k),$=Fi(x)?{...x,tool:v.name}:{success:!0,message:u().done,data:x,tool:v.name};return $.success&&(o=null),d(v.name,k,$,h,w),n.onResult&&n.onResult($),$}catch(x){o=Xn(x);let $={success:!1,message:u().failed,error:{code:"INTERNAL"},tool:v.name};return n.onError&&n.onError(o),d(v.name,k,$,h,w),$}finally{a=Math.max(0,a-1),b()}}let y=(E,k={})=>S(E,k||{},"tool");async function m(E){let k=t(n.columns)||[],h=Di(E,n.customRules);if(h){let x=++s;try{let $=await h.execute({input:E,data:t(n.data)||[],columns:k,executeTool:y}),I={success:!0,message:String($??u().done),tool:`rule:${h.name}`};return d(`rule:${h.name}`,{text:E},I,"ask",x),n.onResult&&n.onResult(I),I}catch($){o=Xn($),n.onError&&n.onError(o);let I={success:!1,message:u().failed,error:{code:"INTERNAL"},tool:`rule:${h.name}`};return d(`rule:${h.name}`,{text:E},I,"ask",x),I}}let w=(n.parseIntent||Zn)(E,{columns:k,locale:n.locale});if(!w){let x={success:!1,message:u().notUnderstood,error:{code:"NOT_UNDERSTOOD"}};return d("ask",{text:E},x,"ask",++s),x}if(w.kind==="tool")return S(w.tool,w.input,"ask");let v=await S("search",{query:w.text},"ask");if(!v.success)return v;let L=Array.isArray(v.data)?v.data:[];if(!L.length){let x={success:!1,message:u().noMatch(w.text),error:{code:"NOT_FOUND"},tool:v.tool};return d("open",{text:w.text},x,"ask",++s),x}return S("open",{id:ee(L[0],n.rowKey)},"ask")}function C(){l=[],i=null,o=null,b()}return{ask:m,executeTool:y,clearHistory:C,subscribe:r.subscribe,getState:f,get tools(){return p()},get loading(){return a>0},get lastResult(){return i},get lastError(){return o},get history(){return l.slice()}}}function Xt(e,t={}){let n=()=>(typeof e=="function"?e():e)||[],r=l=>{a.status=l,t.onStatusChange&&t.onStatusChange(l)},a={status:{state:"unsupported",registered:[],errors:[]},done:Promise.resolve(),unregister(){o.abort()}},i=typeof document<"u"?document.modelContext:void 0,o=new AbortController;return!i||typeof i.registerTool!="function"?(r({state:"unsupported",registered:[],errors:[]}),a):(a.done=(async()=>{r({state:"registering",registered:[],errors:[]});let l=[],s=[];for(let u of n()){if(o.signal.aborted)return;try{await i.registerTool({name:u.name,title:u.title,description:u.description,inputSchema:u.inputSchema,execute:p=>{let f=n().find(b=>b.name===u.name);return f?f.execute(p||{}):{success:!1,message:`Tool "${u.name}" is no longer available.`,error:{code:"NOT_SUPPORTED"}}}},{signal:o.signal}),l.push(u.name)}catch(p){s.push({tool:u.name,message:Xn(p).message})}}o.signal.aborted||r({state:s.length===0?"ready":l.length?"partial":"error",registered:l,errors:s})})(),a)}var Oi=/\b(trend|over time|this (week|month|quarter|year)|last (week|month|quarter|year)|compare|versus|vs)\b|\b(by|per|each|which)\b.*\b(total|average|avg|sum|drop|increase|growth|highest|lowest|most|least)\b|\b(total|average|avg|sum)\b.*\b(by|per|each)\b/i,zi={filters:[],search:[],sort:null,limit:null,notes:[],explanation:""};function Zt(e={}){let t=co(),n=e.rowKey||"id",r=e.bind||null,a=Array.isArray(e.data)?e.data:[],i=Me(e.columns||[]),o={filters:[],sort:null,highlightIds:[]},l="",s=null,u=[],p=[],f=!1,b=()=>r?r.getFilters():o.filters,d=()=>r?r.getSort():o.sort,S=()=>r?r.getHighlightIds():o.highlightIds,y=()=>r?r.getData():a,m=I=>r?r.setFilters(I):o={...o,filters:I},C=I=>r?r.setSort(I):o={...o,sort:I},E=I=>r?r.setHighlightIds(I):o={...o,highlightIds:I};function k(){return Ee(y(),i,{...zi,filters:b(),sort:d()})}let h=()=>{let I=k();return{gridData:I,highlightIds:S().slice(),filters:b().slice(),sort:d(),answer:l,kind:s,table:u.slice(),steps:p.slice(),busy:f,visibleIds:I.map(T=>ee(T,n))}},w=()=>t.emit(h()),v=()=>({get data(){return y()},columns:i,rowKey:n,get filters(){return b()},onFiltersChange:I=>{m(I),w()},onSortChange:I=>{C(I),w()},onHighlightRows:I=>{E(I),w()},onOpenRow:e.onOpenRow,onSelectRow:I=>{r&&r.selectRow?r.selectRow(I):E([I]),w()}});async function L(I){let T=String(I??"").trim();if(!T)return h();f=!0,p=[],u=[],w();try{if(mt(T).length>1){let R=[],G=await Nt(T,v(),{onStep:N=>{R.push(N),p=R.slice(),w()}});s="tasks",l=G.summary}else if(Oi.test(T)){let R=Re(y(),i,b()),G=It(T,R,i,{referenceDate:e.referenceDate});s="insight",l=G.answer,u=G.table||[]}else{let R=Lt(T,v());s=R.kind,l=R.message}}catch(R){console.error("[yuktai] ask failed",R),s=null,l="Something went wrong while answering. Please rephrase the question."}finally{f=!1,w()}return h()}function x(){m([]),C(null),E([]),l="",s=null,u=[],p=[],w()}function $(I={}){Array.isArray(I.data)&&(a=I.data),Array.isArray(I.columns)&&(i=Me(I.columns)),w()}return{ask:L,reset:x,update:$,subscribe:t.subscribe,getState:h,get gridData(){return k()},get highlightIds(){return S().slice()},get filters(){return b().slice()},get sort(){return d()},get answer(){return l},get kind(){return s},get table(){return u.slice()},get steps(){return p.slice()},get busy(){return f},get visibleIds(){return k().map(I=>ee(I,n))}}}var Fe=()=>typeof window<"u"&&typeof document<"u";function yt(e){return String(e??"").replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function c(e,t,...n){let r=document.createElement(e);if(t)for(let[a,i]of Object.entries(t))i==null||i===!1||(a.startsWith("on")&&typeof i=="function"?r.addEventListener(a.slice(2),i):a==="html"?r.innerHTML=i:a==="text"?r.textContent=i:i===!0?r.setAttribute(a,""):r.setAttribute(a,String(i)));for(let a of n.flat())a==null||a===!1||r.append(a instanceof Node?a:document.createTextNode(String(a)));return r}var qi=0,W=(e="yv")=>`${e}-${++qi}`;function en(e,t){if(typeof e!="string"||!Fe())return t;let n=document.createElement("span");return n.style.color=e,n.style.color?e:t}var tr=()=>Fe()&&(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.hasAttribute("data-yuktai-reduce-motion")),er={accessibility:'<circle cx="12" cy="4" r="2"/><path d="M4 8l8-1 8 1M12 7v5m-5 9 5-8 5 8M7 12l-2 5m12-5 2 5"/>',contrast:'<circle cx="12" cy="12" r="9"/><path d="M12 3a9 9 0 0 0 0 18z"/>',moon:'<path d="M20 14.5A8.5 8.5 0 0 1 9.5 4 8.5 8.5 0 1 0 20 14.5z"/>',motion:'<path d="M4 12h12m-5-5 5 5-5 5M20 5v14"/>',reading:'<path d="M4 5h16M4 10h12M4 15h16M4 20h10"/>',target:'<circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="4"/>',speaker:'<path d="M4 9v6h4l5 4V5L8 9H4z"/><path d="M16 9a4 4 0 0 1 0 6M18.5 6.5a8 8 0 0 1 0 11"/>',palette:'<circle cx="12" cy="12" r="9"/><circle cx="8" cy="10" r="1.3"/><circle cx="12" cy="7.5" r="1.3"/><circle cx="16" cy="10" r="1.3"/><path d="M12 21a3 3 0 0 1 0-6h2"/>',skip:'<path d="M5 5l7 7-7 7M13 5l7 7-7 7"/>',close:'<path d="m18 6-12 12M6 6l12 12"/>',plus:'<path d="M12 5v14M5 12h14"/>',minus:'<path d="M5 12h14"/>',reset:'<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/>',search:'<circle cx="11" cy="11" r="6.5"/><path d="m16 16 5 5"/>',sort:'<path d="m8 9 4-4 4 4m-8 6 4 4 4-4"/>',sortUp:'<path d="m6 15 6-6 6 6"/>',sortDown:'<path d="m6 9 6 6 6-6"/>',chevrons:'<path d="m8 9 4-4 4 4m-8 6 4 4 4-4"/>',grid:'<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/>',cards:'<rect x="3" y="4" width="18" height="7" rx="1.5"/><rect x="3" y="13" width="18" height="7" rx="1.5"/>',chat:'<path d="M21 11.5a8.5 8.5 0 0 1-8.5 8.5 9 9 0 0 1-4-.9L3 21l1.9-5.5a9 9 0 0 1-.9-4A8.5 8.5 0 0 1 12.5 3H13a8.5 8.5 0 0 1 8 8z"/>',mic:'<rect x="9" y="2" width="6" height="12" rx="3"/><path d="M5 10a7 7 0 0 0 14 0M12 17v5m-4 0h8"/>',stop:'<rect x="6" y="6" width="12" height="12" rx="2"/>',download:'<path d="M12 3v12m-5-5 5 5 5-5M4 21h16"/>',copy:'<rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V5a2 2 0 0 1 2-2h10"/>',filter:'<path d="M4 5h16l-6 7v6l-4 2v-8z"/>',check:'<path d="m5 12 4 4L19 6"/>',left:'<path d="m15 18-6-6 6-6"/>',right:'<path d="m9 18 6-6-6-6"/>',first:'<path d="m11 18-6-6 6-6M19 18l-6-6 6-6"/>',last:'<path d="m13 18 6-6-6-6M5 18l6-6-6-6"/>',spark:'<path d="m12 3 1.9 5.8L20 11l-6.1 2.2L12 19l-1.9-5.8L4 11l6.1-2.2zM19 14l1.2 2.8L23 18l-2.8 1.2L19 22l-1.2-2.8L15 18l2.8-1.2z"/>',alert:'<path d="m12 3 10 18H2L12 3z"/><path d="M12 9v5m0 3h.01"/>',info:'<circle cx="12" cy="12" r="9"/><path d="M12 11v6m0-9h.01"/>',form:'<rect x="5" y="3" width="14" height="18" rx="2"/><path d="M9 8h6M9 12h6M9 16h3"/>',eye:'<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/>',layout:'<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 21V9"/>',wand:'<path d="m15 4 5 5L9 20H4v-5z"/><path d="m13 6 5 5"/>',undo:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 0 12h-3"/>',tools:'<path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.5 2.5-2.4-.6-.6-2.4z"/>',plug:'<path d="M9 2v6M15 2v6M6 8h12v4a6 6 0 0 1-12 0zM12 18v4"/>'},uo=Object.keys(er);function de(e,t=20,n){return`<svg ${n?`role="img" aria-label="${yt(n)}"`:'aria-hidden="true" focusable="false"'} width="${Number(t)||20}" height="${Number(t)||20}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round">${er[e]||er.spark}</svg>`}function q(e,t,n){let r=document.createElement("span");return r.className="yv-ic",r.innerHTML=de(e,t,n),r}var _e=null;function re(e){!Fe()||!e||((!_e||!document.contains(_e))&&(_e=c("div",{id:"yuktai-vanilla-live",class:"yv-sr",role:"status","aria-live":"polite","aria-atomic":"true"}),document.body.appendChild(_e)),_e.textContent="",setTimeout(()=>{_e&&(_e.textContent=String(e).slice(0,300))},30))}function vt(e,t,n="text/plain;charset=utf-8"){let r=URL.createObjectURL(new Blob([t],{type:n})),a=c("a",{href:r,download:e,hidden:!0});document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(r),1500)}async function po(e){try{return await navigator.clipboard.writeText(e),!0}catch{let t=c("textarea",{"aria-hidden":"true",style:"position:fixed;opacity:0;left:-9999px"});t.value=e,document.body.appendChild(t),t.select();let n=!1;try{n=document.execCommand("copy")}catch{n=!1}return t.remove(),n}}function nr(e){let t=String(e??"");return/^[=+\-@\t\r]/.test(t)&&(t="'"+t),'"'+t.replace(/"/g,'""')+'"'}function go(e){let t=(e||[]).map(n=>{try{return document.querySelector(n)}catch{return null}}).filter(Boolean);return t.forEach(n=>{n.setAttribute("data-yv-flash",""),setTimeout(()=>n.removeAttribute("data-yv-flash"),4e3)}),t[0]&&t[0].scrollIntoView({block:"center",behavior:tr()?"auto":"smooth"}),t.length}function tn(e,t){if(!Fe()||document.getElementById("yuktai-vanilla-css"))return;let n=document.createElement("style");n.id="yuktai-vanilla-css",n.textContent=`
|
|
401
|
+
:root{--yv-primary:${e}}
|
|
402
|
+
.yv-sr{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
|
|
403
|
+
.yv-ic{display:inline-flex;line-height:0}
|
|
404
|
+
[data-yv-flash]{outline:3px solid #d97706!important;outline-offset:3px!important;background-color:#fef3c7!important;color:#111!important}
|
|
405
|
+
.yv-grid,.yv-grid *,.yv-box,.yv-box *,.yv-fab,.yv-dialog,.yv-dialog *{box-sizing:border-box}
|
|
406
|
+
.yv-grid button,.yv-box button,.yv-dialog button,.yv-grid select,.yv-box select,.yv-dialog select,.yv-grid input,.yv-box input,.yv-dialog input,.yv-box textarea{font:inherit;color:inherit}
|
|
407
|
+
.yv-grid :focus-visible,.yv-box :focus-visible,.yv-dialog :focus-visible,.yv-fab:focus-visible{outline:3px solid #2563eb;outline-offset:2px}
|
|
408
|
+
.yv-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;min-width:44px;padding:8px 12px;border:1px solid var(--yv-border);border-radius:8px;background:var(--yv-surface);color:var(--yv-text);cursor:pointer;font-weight:600;line-height:1.2}
|
|
409
|
+
.yv-btn:hover:not(:disabled){background:var(--yv-hover)}
|
|
410
|
+
.yv-btn:disabled{opacity:.45;cursor:not-allowed}
|
|
411
|
+
.yv-btn.yv-primary{background:var(--yv-primary);border-color:var(--yv-primary);color:#fff}
|
|
412
|
+
.yv-btn.yv-icon{padding:0;width:44px}
|
|
413
|
+
.yv-btn.yv-small{min-height:36px;padding:6px 10px;font-size:.85em}
|
|
414
|
+
.yv-btn[aria-pressed=true]{background:var(--yv-accent-bg);border-color:var(--yv-primary);color:var(--yv-accent-text)}
|
|
415
|
+
.yv-input{min-height:44px;width:100%;min-width:0;padding:8px 10px;font-size:16px!important;border:1px solid var(--yv-border-strong);border-radius:8px;background:var(--yv-surface);color:var(--yv-text)}
|
|
416
|
+
.yv-muted{color:var(--yv-muted);font-size:.875em}
|
|
417
|
+
.yv-chip{display:inline-flex;align-items:center;gap:6px;min-height:36px;padding:4px 12px;border:1px solid var(--yv-border);border-radius:999px;background:var(--yv-surface);color:var(--yv-text);cursor:pointer;font-size:.85em}
|
|
418
|
+
.yv-chip:hover{background:var(--yv-hover)}
|
|
419
|
+
.yv-answer{margin-top:10px;padding:12px;border:1px solid var(--yv-border);border-radius:8px;background:var(--yv-soft);white-space:pre-wrap;overflow-wrap:anywhere}
|
|
420
|
+
.yv-answer:empty{display:none}
|
|
421
|
+
.yv-badge{display:inline-flex;align-items:center;gap:4px;padding:2px 9px;border-radius:999px;font-size:.8em;font-weight:700;border:1px solid currentColor;background:var(--yv-badge-bg,transparent)}
|
|
422
|
+
.yv-sev-critical{color:#b91c1c}.yv-sev-serious{color:#c2410c}.yv-sev-moderate{color:#a16207}.yv-sev-minor{color:#475569}
|
|
423
|
+
.yv-sev-high{color:#b91c1c}.yv-sev-medium{color:#a16207}.yv-sev-low{color:#475569}
|
|
424
|
+
|
|
425
|
+
/* themes (shared by grid, boxes and dialogs) */
|
|
426
|
+
.yv-grid,.yv-box,.yv-dialog{--yv-bg:#fff;--yv-surface:#fff;--yv-soft:#f8fafc;--yv-head:#f8fafc;--yv-hover:#f1f5f9;--yv-text:#0f172a;--yv-muted:#475569;--yv-border:#e2e8f0;--yv-border-strong:#94a3b8;--yv-accent-bg:#ccfbf1;--yv-accent-text:#115e59;--yv-hl-bg:#fef3c7;--yv-hl-edge:#b45309;--yv-sel-bg:#f0fdfa}
|
|
427
|
+
.yv-theme-dark{--yv-bg:#0f172a;--yv-surface:#111c33;--yv-soft:#16233f;--yv-head:#16233f;--yv-hover:#1e2d4d;--yv-text:#f1f5f9;--yv-muted:#cbd5e1;--yv-border:#334155;--yv-border-strong:#64748b;--yv-accent-bg:#134e4a;--yv-accent-text:#ccfbf1;--yv-hl-bg:#4a3a0c;--yv-hl-edge:#fbbf24;--yv-sel-bg:#123a3a}
|
|
428
|
+
.yv-theme-high-contrast{--yv-bg:#fff;--yv-surface:#fff;--yv-soft:#fff;--yv-head:#fff;--yv-hover:#e5e5e5;--yv-text:#000;--yv-muted:#000;--yv-border:#000;--yv-border-strong:#000;--yv-accent-bg:#000;--yv-accent-text:#fff;--yv-hl-bg:#ffff00;--yv-hl-edge:#000;--yv-sel-bg:#e5e5e5}
|
|
429
|
+
.yv-theme-high-contrast.yv-grid,.yv-theme-high-contrast .yv-btn,.yv-theme-high-contrast .yv-input{border-width:2px}
|
|
430
|
+
.yv-theme-high-contrast .yv-btn.yv-primary{background:#000;border-color:#000}
|
|
431
|
+
.yv-theme-color-blind{--yv-accent-bg:#dbeafe;--yv-accent-text:#1e3a8a;--yv-hl-bg:#ffedd5;--yv-hl-edge:#1d4ed8;--yv-sel-bg:#e0f2fe}
|
|
432
|
+
.yv-theme-color-blind tr.yv-hl td,.yv-theme-color-blind .yv-card.yv-hl{background-image:repeating-linear-gradient(135deg,transparent 0 8px,rgba(29,78,216,.10) 8px 12px)}
|
|
433
|
+
.yv-theme-dyslexia{font-family:"Atkinson Hyperlegible",Verdana,Arial,sans-serif!important;letter-spacing:.03em;word-spacing:.12em;line-height:1.75}
|
|
434
|
+
.yv-theme-dyslexia td,.yv-theme-dyslexia th{padding-top:14px;padding-bottom:14px}
|
|
435
|
+
|
|
436
|
+
/* grid */
|
|
437
|
+
.yv-grid{position:relative;width:100%;background:var(--yv-bg);color:var(--yv-text);border:1px solid var(--yv-border);border-radius:12px;overflow:hidden;font-size:15px;line-height:1.5}
|
|
438
|
+
.yv-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:10px;padding:12px;border-bottom:1px solid var(--yv-border)}
|
|
439
|
+
.yv-search{display:flex;align-items:center;gap:8px;flex:1 1 240px;min-width:0;min-height:44px;padding:0 10px;border:1px solid var(--yv-border-strong);border-radius:8px;background:var(--yv-surface)}
|
|
440
|
+
.yv-search input{flex:1;min-width:0;min-height:42px;font-size:16px!important;border:0;outline:0;background:transparent;color:inherit}
|
|
441
|
+
.yv-search:focus-within{outline:3px solid #2563eb;outline-offset:2px}
|
|
442
|
+
.yv-info{color:var(--yv-muted);font-size:.875em}
|
|
443
|
+
.yv-tools{display:flex;gap:6px;flex-wrap:wrap}
|
|
444
|
+
.yv-filterbar{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:8px 12px;border-bottom:1px solid var(--yv-border);background:var(--yv-soft)}
|
|
445
|
+
.yv-filterbar[hidden]{display:none}
|
|
446
|
+
.yv-tablewrap{width:100%;overflow:auto;max-height:var(--yv-max-height,none)}
|
|
447
|
+
.yv-table{width:100%;border-collapse:collapse;text-align:left}
|
|
448
|
+
.yv-table th,.yv-table td{padding:8px 12px;border-bottom:1px solid var(--yv-border);vertical-align:middle}
|
|
449
|
+
.yv-table th{position:sticky;top:0;z-index:1;background:var(--yv-head);color:var(--yv-text);font-size:.85em;font-weight:700;white-space:nowrap}
|
|
450
|
+
.yv-table td{white-space:nowrap}
|
|
451
|
+
.yv-wrap .yv-table td{white-space:normal;overflow-wrap:anywhere}
|
|
452
|
+
.yv-table tbody tr:hover td{background:var(--yv-hover)}
|
|
453
|
+
.yv-table [role=gridcell]:focus,.yv-table [role=columnheader]:focus{outline:3px solid #2563eb;outline-offset:-3px}
|
|
454
|
+
.yv-table tr[aria-selected=true] td{background:var(--yv-sel-bg)}
|
|
455
|
+
.yv-table tr.yv-hl td,.yv-card.yv-hl{background:var(--yv-hl-bg)!important;color:var(--yv-text)}
|
|
456
|
+
.yv-table tr.yv-hl td:first-child{box-shadow:inset 5px 0 var(--yv-hl-edge)}
|
|
457
|
+
.yv-table tr[data-yuktai-row-id]:focus{outline:3px solid #2563eb;outline-offset:-3px}
|
|
458
|
+
.yv-sortbtn{display:inline-flex;align-items:center;gap:6px;min-height:44px;padding:0 4px;border:0;background:transparent;color:inherit;font:inherit;font-weight:700;cursor:pointer}
|
|
459
|
+
.yv-align-right{text-align:right!important}.yv-align-center{text-align:center!important}
|
|
460
|
+
.yv-check{display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px;cursor:pointer}
|
|
461
|
+
.yv-check input{width:18px;height:18px;accent-color:var(--yv-primary);cursor:pointer;margin:0}
|
|
462
|
+
.yv-cellbadge{display:inline-block;padding:2px 10px;border-radius:999px;border:1px solid var(--yv-border-strong);background:var(--yv-soft);font-size:.85em;font-weight:600}
|
|
463
|
+
.yv-empty,.yv-loading{padding:28px 16px;text-align:center;color:var(--yv-muted)}
|
|
464
|
+
.yv-cards{display:grid;gap:10px;padding:12px;list-style:none;margin:0}
|
|
465
|
+
.yv-card{border:1px solid var(--yv-border);border-radius:10px;padding:10px 12px;background:var(--yv-surface)}
|
|
466
|
+
.yv-card[aria-selected=true]{background:var(--yv-sel-bg);border-color:var(--yv-primary)}
|
|
467
|
+
.yv-card.yv-hl{border-left:6px solid var(--yv-hl-edge)}
|
|
468
|
+
.yv-card:focus{outline:3px solid #2563eb;outline-offset:2px}
|
|
469
|
+
.yv-card-head{display:flex;align-items:center;justify-content:space-between;gap:8px}
|
|
470
|
+
.yv-card-title{font-weight:700;margin:0;font-size:1em;overflow-wrap:anywhere}
|
|
471
|
+
.yv-card dl{display:grid;grid-template-columns:minmax(90px,38%) 1fr;gap:4px 10px;margin:6px 0 0}
|
|
472
|
+
.yv-card dt{color:var(--yv-muted);font-size:.85em}
|
|
473
|
+
.yv-card dd{margin:0;overflow-wrap:anywhere}
|
|
474
|
+
.yv-pager{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px;padding:10px 12px;border-top:1px solid var(--yv-border)}
|
|
475
|
+
.yv-pager .yv-pages{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
|
|
476
|
+
.yv-pager select{min-height:44px;padding:6px 8px;border:1px solid var(--yv-border-strong);border-radius:8px;background:var(--yv-surface);color:var(--yv-text)}
|
|
477
|
+
|
|
478
|
+
/* boxes: assistant, agentic bar, page tools */
|
|
479
|
+
.yv-box{background:var(--yv-bg);color:var(--yv-text);border:1px solid var(--yv-border);border-radius:12px;padding:12px;font-size:15px;line-height:1.5}
|
|
480
|
+
.yv-grid .yv-box{border:0;border-bottom:1px solid var(--yv-border);border-radius:0}
|
|
481
|
+
.yv-box h2,.yv-box h3,.yv-dialog h2,.yv-dialog h3{margin:0 0 6px;font-size:1.05em}
|
|
482
|
+
.yv-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
|
|
483
|
+
.yv-row>.yv-input{flex:1 1 220px}
|
|
484
|
+
.yv-chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
|
|
485
|
+
.yv-steps{margin:8px 0 0;padding-left:22px}
|
|
486
|
+
.yv-steps li{margin:3px 0}
|
|
487
|
+
.yv-mini{width:100%;border-collapse:collapse;margin-top:10px;font-size:.9em}
|
|
488
|
+
.yv-mini th,.yv-mini td{border:1px solid var(--yv-border);padding:6px 8px;text-align:left}
|
|
489
|
+
.yv-mini th{background:var(--yv-head)}
|
|
490
|
+
.yv-history{margin-top:8px}
|
|
491
|
+
.yv-history summary{cursor:pointer;min-height:36px;display:flex;align-items:center}
|
|
492
|
+
.yv-history ol{margin:6px 0 0;padding-left:22px;font-size:.9em}
|
|
493
|
+
.yv-ok{color:#047857}.yv-fail{color:#b91c1c}
|
|
494
|
+
.yv-theme-dark .yv-ok{color:#6ee7b7}.yv-theme-dark .yv-fail{color:#fca5a5}
|
|
495
|
+
.yv-tabs{display:flex;gap:4px;overflow-x:auto;padding:4px;border-bottom:1px solid var(--yv-border);margin:-4px -4px 10px}
|
|
496
|
+
.yv-tab{white-space:nowrap;min-height:44px;padding:6px 12px;border:1px solid transparent;border-radius:8px;background:transparent;color:var(--yv-text);font-weight:700;cursor:pointer}
|
|
497
|
+
.yv-tab[aria-selected=true]{background:var(--yv-accent-bg);color:var(--yv-accent-text);border-color:var(--yv-primary)}
|
|
498
|
+
.yv-list{list-style:none;margin:8px 0 0;padding:0;display:grid;gap:8px}
|
|
499
|
+
.yv-item{border:1px solid var(--yv-border);border-radius:8px;padding:10px;background:var(--yv-surface)}
|
|
500
|
+
.yv-item p{margin:4px 0}
|
|
501
|
+
.yv-item code{font-size:.8em;overflow-wrap:anywhere}
|
|
502
|
+
.yv-score{display:flex;align-items:baseline;gap:8px;margin:6px 0}
|
|
503
|
+
.yv-score strong{font-size:2em;line-height:1}
|
|
504
|
+
.yv-meter{height:8px;border-radius:99px;background:var(--yv-border);overflow:hidden;margin:4px 0 8px}
|
|
505
|
+
.yv-meter span{display:block;height:100%;background:var(--yv-primary)}
|
|
506
|
+
.yv-cats{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:8px;margin:8px 0}
|
|
507
|
+
.yv-cat{border:1px solid var(--yv-border);border-radius:8px;padding:8px;background:var(--yv-soft)}
|
|
508
|
+
.yv-cat strong{display:block;font-size:1.3em}
|
|
509
|
+
|
|
510
|
+
/* floating buttons and dialogs */
|
|
511
|
+
.yv-fabs{position:fixed;bottom:max(16px,env(safe-area-inset-bottom));${t}:16px;display:flex;flex-direction:column;gap:10px;z-index:2147483000}
|
|
512
|
+
.yv-fab{width:56px;height:56px;display:grid;place-items:center;border:2px solid #fff;border-radius:50%;background:var(--yv-primary);color:#fff;box-shadow:0 4px 16px rgba(0,0,0,.25);cursor:pointer}
|
|
513
|
+
.yv-fab.yv-fab-alt{background:#1e293b}
|
|
514
|
+
.yv-dialog{position:fixed;bottom:max(90px,calc(env(safe-area-inset-bottom) + 84px));${t}:12px;width:min(440px,calc(100vw - 24px));max-height:calc(100dvh - 110px);overflow:auto;background:var(--yv-bg);color:var(--yv-text);border:1px solid var(--yv-border);border-radius:16px;box-shadow:0 12px 40px rgba(15,23,42,.25);z-index:2147483001;font:15px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif}
|
|
515
|
+
.yv-dialog.yv-wide{width:min(620px,calc(100vw - 24px))}
|
|
516
|
+
.yv-dialog-head{position:sticky;top:0;z-index:1;display:flex;justify-content:space-between;align-items:flex-start;gap:10px;padding:14px 16px;border-bottom:1px solid var(--yv-border);background:var(--yv-bg)}
|
|
517
|
+
.yv-dialog-head h2{margin:0;font-size:1.1em}
|
|
518
|
+
.yv-dialog-body{padding:12px 16px 16px}
|
|
519
|
+
.yv-dialog .yv-box{border:0;padding:0}
|
|
520
|
+
.yv-option{display:flex;align-items:center;gap:12px;padding:8px 0;border-bottom:1px solid var(--yv-border)}
|
|
521
|
+
.yv-option-icon{display:grid;place-items:center;width:36px;height:36px;flex:none;border-radius:9px;background:var(--yv-accent-bg);color:var(--yv-accent-text)}
|
|
522
|
+
.yv-option-copy{flex:1;min-width:0}
|
|
523
|
+
.yv-option-copy b{display:block;font-size:.95em}
|
|
524
|
+
.yv-option-copy small{display:block;color:var(--yv-muted);font-size:.8em}
|
|
525
|
+
.yv-switch{position:relative;display:inline-flex;align-items:center;justify-content:center;min-width:52px;min-height:44px;cursor:pointer}
|
|
526
|
+
.yv-switch input{position:absolute;inset:0;width:100%;height:100%;opacity:0;margin:0;cursor:pointer}
|
|
527
|
+
.yv-switch span{position:relative;pointer-events:none;width:44px;height:26px;border-radius:99px;background:#64748b;transition:background .15s}
|
|
528
|
+
.yv-switch span::after{content:"";position:absolute;top:3px;left:3px;width:20px;height:20px;border-radius:50%;background:#fff;transition:transform .15s}
|
|
529
|
+
.yv-switch input:checked+span{background:var(--yv-primary)}
|
|
530
|
+
.yv-switch input:checked+span::after{transform:translateX(18px)}
|
|
531
|
+
.yv-switch input:focus-visible+span{outline:3px solid #2563eb;outline-offset:3px}
|
|
532
|
+
.yv-steps-bar{display:flex;gap:4px;flex:1}
|
|
533
|
+
.yv-step{flex:1;min-width:0;height:28px;border:0;border-radius:6px;background:transparent;padding:0;cursor:pointer;position:relative}
|
|
534
|
+
.yv-step::after{content:"";position:absolute;left:0;right:0;top:10px;height:8px;border-radius:8px;background:#cbd5e1}
|
|
535
|
+
.yv-step[aria-pressed=true]::after{background:var(--yv-primary)}
|
|
536
|
+
.yv-status{margin:10px 0 0;padding:9px 11px;border-radius:8px;background:var(--yv-soft);border:1px solid var(--yv-border);font-size:.85em}
|
|
537
|
+
.yv-status:empty{display:none}
|
|
538
|
+
@media (max-width:560px){.yv-dialog{${t}:8px;width:calc(100vw - 16px)}.yv-toolbar{align-items:stretch}.yv-search{flex-basis:100%}}
|
|
539
|
+
@media (prefers-reduced-motion:reduce){.yv-switch span,.yv-switch span::after{transition:none}}
|
|
540
|
+
`,document.head.appendChild(n)}var Bi={query:"Grid query",anomalies:"Anomalies",summary:"Summary",insight:"BI insight",tasks:"Task steps"};function nn(e,t,n={}){let r=typeof e=="string"?document.querySelector(e):e;if(!r)throw new Error("mountAgenticGridBar: container not found");if(!t||typeof t.ask!="function")throw new Error("mountAgenticGridBar: pass the object from createAgenticGrid() or grid.agentic");let a=n.title||"Ask about this data",i=W("yv-q"),o=W("yv-qh"),l=c("input",{id:i,class:"yv-input",type:"text",autocomplete:"off",placeholder:n.placeholder||"Ask the grid\u2026 e.g. salary over 1 lakh in Hyderabad","aria-describedby":o}),s=c("button",{type:"submit",class:"yv-btn yv-primary"},q("spark",16),"Ask"),u=c("button",{type:"button",class:"yv-btn"},q("reset",16),"Show all rows"),p=c("p",{class:"yv-muted",style:"margin:10px 0 0",hidden:!0}),f=c("div",{class:"yv-answer",role:"status","aria-live":"polite"}),b=c("div"),d=n.examples||["salary over 1 lakh","anything unusual?","average salary by department","show salary over 80k, then sort by salary, then summarize"],S=c("div",{class:"yv-chips","aria-label":"Example questions"},...d.map(k=>c("button",{type:"button",class:"yv-chip","data-example":k},k))),y=c("form",{class:"yv-row",role:"search","aria-label":a},c("label",{for:i,class:"yv-sr"},a),l,s,u),m=c("section",{class:`yv-box yv-agentic-bar${n.theme?" yv-theme-"+n.theme:""}`,"aria-label":a},c("h3",null,q("spark",16)," ",a),c("p",{id:o,class:"yv-muted",style:"margin:0 0 8px"},n.hint||"Plain-English questions. Understands 10k, 1.5 lakh, 2cr. Every answer says which filters it used."),y,S,p,f,b);r.appendChild(m);function C(k){if(s.disabled=!!k.busy,m.setAttribute("aria-busy",String(!!k.busy)),!k.busy){if(f.textContent=k.answer||"",p.hidden=!k.kind,p.textContent=k.kind?`${Bi[k.kind]||k.kind} \xB7 ${k.visibleIds.length} row(s) shown`:"",b.replaceChildren(),k.table&&k.table.length){let h=Object.keys(k.table[0]),w=c("table",{class:"yv-mini"});w.innerHTML=`<caption class="yv-sr">Answer table</caption><thead><tr>${h.map(v=>`<th scope="col">${yt(v)}</th>`).join("")}</tr></thead><tbody>${k.table.map(v=>`<tr>${h.map(L=>`<td>${yt(v[L])}</td>`).join("")}</tr>`).join("")}</tbody>`,b.append(c("div",{style:"overflow-x:auto"},w))}k.steps&&k.steps.length&&b.append(c("ol",{class:"yv-steps","aria-label":"Steps"},...k.steps.map(h=>c("li",null,c("span",{class:h.success===!1?"yv-fail":"yv-ok"},h.success===!1?"\u2717 ":"\u2713 "),c("b",null,h.action),": ",h.message||h.text))))}}let E=t.subscribe(C);return y.addEventListener("submit",k=>{k.preventDefault(),t.ask(l.value)}),u.addEventListener("click",()=>{l.value="",t.reset()}),S.addEventListener("click",k=>{let h=k.target.closest("[data-example]");h&&(l.value=h.getAttribute("data-example"),t.ask(l.value))}),{element:m,ask:k=>(l.value=k,t.ask(k)),destroy(){E(),m.remove()}}}var Hi={en:{search:"Search\u2026",searchAria:"Search grid",rows:"rows",selected:"selected",loading:"Loading\u2026",noData:"No data found.",selectRow:e=>`Select row ${e}`,selectPage:"Select all rows on this page",pageSize:"Rows per page",page:(e,t)=>`Page ${e} of ${t}`,showing:(e,t,n)=>n?`Showing ${e}\u2013${t} of ${n}`:"No rows",first:"First page",previous:"Previous page",next:"Next page",last:"Last page",yes:"Yes",no:"No",sortedAsc:e=>`Sorted by ${e}, ascending`,sortedDesc:e=>`Sorted by ${e}, descending`,sortCleared:"Sorting cleared",filters:e=>`${e} filter(s) applied`,clearFilters:"Clear filters",removeFilter:e=>`Remove filter: ${e}`,export:"Export CSV",tableView:"Table view",cardView:"Card view",highlighted:"highlighted",results:e=>`${e} result(s)`,ops:{contains:"contains",equals:"is",startsWith:"starts with",endsWith:"ends with",greaterThan:">",lessThan:"<",between:"between"}},te:{search:"\u0C36\u0C4B\u0C27\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F\u2026",searchAria:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C32\u0C4B \u0C36\u0C4B\u0C27\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F",rows:"\u0C35\u0C30\u0C41\u0C38\u0C32\u0C41",selected:"\u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C41\u0C28\u0C4D\u0C28\u0C35\u0C3F",loading:"\u0C32\u0C4B\u0C21\u0C4D \u0C05\u0C35\u0C41\u0C24\u0C4B\u0C02\u0C26\u0C3F\u2026",noData:"\u0C21\u0C47\u0C1F\u0C3E \u0C15\u0C28\u0C2C\u0C21\u0C32\u0C47\u0C26\u0C41.",selectRow:e=>`\u0C35\u0C30\u0C41\u0C38 ${e} \u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C4B\u0C02\u0C21\u0C3F`,selectPage:"\u0C08 \u0C2A\u0C47\u0C1C\u0C40\u0C32\u0C4B\u0C28\u0C3F \u0C05\u0C28\u0C4D\u0C28\u0C3F \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41 \u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C4B\u0C02\u0C21\u0C3F",pageSize:"\u0C2A\u0C47\u0C1C\u0C40 \u0C2A\u0C30\u0C3F\u0C2E\u0C3E\u0C23\u0C02",page:(e,t)=>`\u0C2A\u0C47\u0C1C\u0C40 ${e} / ${t}`,showing:(e,t,n)=>n?`${n} \u0C32\u0C4B ${e}\u2013${t}`:"\u0C35\u0C30\u0C41\u0C38\u0C32\u0C41 \u0C32\u0C47\u0C35\u0C41",first:"\u0C2E\u0C4A\u0C26\u0C1F\u0C3F \u0C2A\u0C47\u0C1C\u0C40",previous:"\u0C35\u0C46\u0C28\u0C41\u0C15\u0C15\u0C41",next:"\u0C2E\u0C41\u0C02\u0C26\u0C41\u0C15\u0C41",last:"\u0C1A\u0C3F\u0C35\u0C30\u0C3F \u0C2A\u0C47\u0C1C\u0C40",yes:"\u0C05\u0C35\u0C41\u0C28\u0C41",no:"\u0C15\u0C3E\u0C26\u0C41",sortedAsc:e=>`${e} \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C06\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02`,sortedDesc:e=>`${e} \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C05\u0C35\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02`,sortCleared:"\u0C15\u0C4D\u0C30\u0C2E\u0C02 \u0C24\u0C40\u0C38\u0C47\u0C36\u0C3E\u0C30\u0C41",filters:e=>`${e} \u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D(\u0C32\u0C41) \u0C35\u0C47\u0C36\u0C3E\u0C30\u0C41`,clearFilters:"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C02\u0C21\u0C3F",removeFilter:e=>`\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C02\u0C21\u0C3F: ${e}`,export:"CSV \u0C21\u0C4C\u0C28\u0C4D\u200C\u0C32\u0C4B\u0C21\u0C4D",tableView:"\u0C2A\u0C1F\u0C4D\u0C1F\u0C3F\u0C15",cardView:"\u0C15\u0C3E\u0C30\u0C4D\u0C21\u0C41\u0C32\u0C41",highlighted:"\u0C39\u0C48\u0C32\u0C48\u0C1F\u0C4D",results:e=>`${e} \u0C2B\u0C32\u0C3F\u0C24\u0C3E\u0C32\u0C41`,ops:{contains:"\u0C32\u0C4B \u0C09\u0C02\u0C26\u0C3F",equals:"=",startsWith:"\u0C24\u0C4B \u0C2E\u0C4A\u0C26\u0C32\u0C41",endsWith:"\u0C24\u0C4B \u0C2E\u0C41\u0C17\u0C3F\u0C02\u0C2A\u0C41",greaterThan:">",lessThan:"<",between:"\u0C2E\u0C27\u0C4D\u0C2F"}}},mo=["default","high-contrast","dark","color-blind","dyslexia"],rr=e=>String(e??"").normalize("NFC").toLowerCase();function fo(e,t){return(Array.isArray(e)&&e.length?e:t[0]?Object.keys(t[0]).map(r=>({key:r,label:r})):[]).map(r=>({key:String(r.key),label:r.label==null?String(r.key):String(r.label),sortable:r.sortable!==!1,type:r.type||"text",align:r.align||(r.type==="number"?"right":"left"),render:typeof r.render=="function"?r.render:null,hiddenOnMobile:!!r.hiddenOnMobile,width:r.width}))}function ho(e,t,n,r){let a=typeof e=="string"?document.querySelector(e):e;if(!a||typeof a.appendChild!="function")throw new Error("renderGrid: container not found. Pass an element or a CSS selector.");let i=Array.isArray(t)?{...r||{},data:t,columns:n}:{...t||{}},o=i.locale||"en-IN",l=String(o).split("-")[0],s=Hi[l==="te"?"te":"en"],u=l==="te"?"te":"en",p=l==="en"||l==="te"?"en-IN":o,f=i.rowKey||"id",b=i.label||i.ariaLabel||"Data grid",d=i.pagination===!1?!1:typeof i.pagination=="object"?i.pagination:{},S=d&&d.sizeOptions||[10,20,50,100],y=i.selectable!==!1,m=i.autoScrollToHighlight!==!1,C=Number(i.mobileBreakpoint)||640,E=Array.isArray(i.data)?i.data.slice():[],k=fo(i.columns,E),h=Me(k),w=[],v=null,L="",x=1,$=Number(d&&d.pageSize||i.pageSize)||10,I=mo.includes(i.theme)?i.theme:"default",T=["table","card","auto"].includes(i.view)?i.view:"auto",R=!!i.loading,G=!1,N={r:1,c:0},F=new Set((i.selectedKeys||[]).map(String)),B=new Set((i.highlightIds||[]).map(String)),pe={grid:W("yv-grid"),title:W("yv-title"),status:W("yv-status")};S.includes($)||S.push($),S.sort((g,A)=>g-A);let j=g=>ee(g,f)||String(E.indexOf(g)),Y=g=>{let A=k.find(M=>M.type==="text")||k[0];return A?String(g[A.key]??j(g)):j(g)},Z=c("section",{class:`yv-grid yv-theme-${I}${i.wrap?" yv-wrap":""}${i.className?" "+i.className:""}`,role:"region","aria-labelledby":pe.title,lang:i.lang||(l!=="en"?o:null)});i.maxHeight&&Z.style.setProperty("--yv-max-height",typeof i.maxHeight=="number"?`${i.maxHeight}px`:i.maxHeight);let kt=c("h3",{id:pe.title,class:i.showTitle?"yv-grid-title":"yv-sr"},b);i.showTitle&&(kt.style.cssText="margin:0;padding:12px 12px 0;font-size:1.05em");let Ae=c("input",{type:"search",placeholder:s.search,"aria-label":s.searchAria,"aria-controls":pe.grid,autocomplete:"off",spellcheck:"false"}),on=i.search===!1?null:c("label",{class:"yv-search"},q("search",18),Ae),lr=c("span",{class:"yv-info","aria-hidden":"true"}),ot=c("button",{type:"button",class:"yv-btn yv-icon","data-view-toggle":""}),cr=i.exportable===!1?null:c("button",{type:"button",class:"yv-btn"},q("download",16),s.export),wo=c("div",{class:"yv-tools"},T==="auto"||i.viewToggle?ot:null,cr),xo=c("div",{class:"yv-toolbar"},on,lr,wo),Le=c("div",{class:"yv-filterbar",hidden:!0,"aria-label":s.filters(0)}),an=c("div",{class:"yv-slot"}),oe=c("div",{class:"yv-body",id:pe.grid}),At=c("div",{class:"yv-pager"}),sn=c("p",{class:"yv-sr",id:pe.status,role:"status","aria-live":"polite","aria-atomic":"true"});Z.append(kt,xo,Le,an,oe,At,sn),a.appendChild(Z);let ln=null,Tt=g=>{clearTimeout(ln),sn.textContent="",ln=setTimeout(()=>sn.textContent=g,40)};function ko(g,A,M,P){let D=g[M.key],O=A[M.key];if(D==null||D==="")return O==null||O===""?0:1;if(O==null||O==="")return-1;let _;return M.type==="number"?_=Number(D)-Number(O):M.type==="date"?_=new Date(D).getTime()-new Date(O).getTime():_=String(D).localeCompare(String(O),o,{numeric:!0,sensitivity:"base"}),Number.isFinite(_)||(_=String(D).localeCompare(String(O))),P==="desc"?-_:_}function Pe(){let g=Re(E,h,w);if(L){let A=rr(L);g=g.filter(M=>k.some(P=>rr(M[P.key]).includes(A)||rr(it(P,M[P.key])).includes(A)))}if(v&&v.key){let A=k.find(M=>M.key===v.key);A&&(g=g.slice().sort((M,P)=>ko(M,P,A,v.direction)))}return g}function it(g,A){if(A==null||A==="")return"";if(g.type==="number"&&Number.isFinite(Number(A)))return Number(A).toLocaleString(p);if(g.type==="date"){let M=new Date(A);return Number.isNaN(M.getTime())?String(A):M.toLocaleDateString(p,{year:"numeric",month:"short",day:"numeric"})}return g.type==="boolean"?A===!0||A==="true"?s.yes:s.no:String(A)}function ur(g,A,M){let P=A[g.key];if(g.render)try{let D=g.render(P,A,M);return D instanceof Node?D:document.createTextNode(D==null?"":String(D))}catch(D){return console.error("[yuktai] column render failed",g.key,D),document.createTextNode(it(g,P))}return g.type==="badge"&&P!=null&&P!==""?c("span",{class:"yv-cellbadge"},String(P)):document.createTextNode(it(g,P))}let at=()=>T==="card"||T==="auto"&&G;function Ve(g){if(d===!1)return{pages:1,start:0,end:g};let A=Math.max(1,Math.ceil(g/$));return x=Math.min(Math.max(1,x),A),{pages:A,start:(x-1)*$,end:Math.min(g,x*$)}}let ye=[];function U(){let g=Pe();ye=g;let{pages:A,start:M,end:P}=Ve(g.length),D=g.slice(M,P);Z.className=`yv-grid yv-theme-${I}${i.wrap?" yv-wrap":""}${i.className?" "+i.className:""}`,Z.setAttribute("aria-busy",String(R)),lr.textContent=`${g.length.toLocaleString(p)} ${s.rows}${y?` \xB7 ${F.size.toLocaleString(p)} ${s.selected}`:""}`,ot.innerHTML=de(at()?"grid":"cards",18),ot.setAttribute("aria-label",at()?s.tableView:s.cardView),ot.title=at()?s.tableView:s.cardView,So();let O=oe.contains(document.activeElement);oe.replaceChildren(R?c("div",{class:"yv-loading",role:"status"},s.loading):at()?To(D,M):Ao(D,M,g.length)),O&&!R&&pr(),Co(g.length,A,M,P)}function Ao(g,A,M){let P=k,D=P.length+(y?1:0),O=c("table",{class:"yv-table",role:"grid","aria-labelledby":pe.title,"aria-rowcount":M+1,"aria-colcount":D,"aria-multiselectable":y?"true":null}),_=c("tr",{role:"row","aria-rowindex":1});if(y){let H=g.length>0&&g.every(we=>F.has(j(we))),ve=g.some(we=>F.has(j(we))),J=c("input",{type:"checkbox","data-select-page":"","aria-label":s.selectPage,tabindex:-1});J.checked=H,J.indeterminate=!H&&ve,_.append(c("th",{role:"columnheader",scope:"col","aria-colindex":1,tabindex:-1,"data-col":0},c("label",{class:"yv-check"},J)))}P.forEach((H,ve)=>{let J=ve+(y?1:0),we=v&&v.key===H.key?v.direction:null,Ge=c("th",{role:"columnheader",scope:"col","aria-colindex":J+1,"aria-sort":H.sortable?we==="asc"?"ascending":we==="desc"?"descending":"none":null,class:H.align!=="left"?`yv-align-${H.align}`:null,tabindex:-1,"data-col":J});if(H.width&&(Ge.style.width=typeof H.width=="number"?`${H.width}px`:H.width),H.sortable){let Ke=c("button",{type:"button",class:"yv-sortbtn","data-sort":H.key,tabindex:-1},H.label);Ke.insertAdjacentHTML("beforeend",de(we==="asc"?"sortUp":we==="desc"?"sortDown":"sort",14)),Ge.append(Ke)}else Ge.append(H.label);_.append(Ge)});let ie=c("tbody");if(!g.length){let H=i.empty instanceof Node?i.empty.cloneNode(!0):document.createTextNode(i.empty?String(i.empty):s.noData);ie.append(c("tr",{role:"row","aria-rowindex":2},c("td",{role:"gridcell",class:"yv-empty",colspan:D,tabindex:-1,"data-col":0},H)))}g.forEach((H,ve)=>{let J=j(H),we=F.has(J),Ge=B.has(J),Ke=c("tr",{role:"row","aria-rowindex":A+ve+2,"aria-selected":y?String(we):null,"data-yuktai-row-id":J,class:Ge?"yv-hl":null});if(y){let Qe=c("input",{type:"checkbox","data-select":J,"aria-label":s.selectRow(Y(H)),tabindex:-1});Qe.checked=we,Ke.append(c("td",{role:"gridcell","aria-colindex":1,tabindex:-1,"data-col":0},c("label",{class:"yv-check"},Qe)))}P.forEach((Qe,mr)=>{let fr=mr+(y?1:0),dn=c("td",{role:"gridcell","aria-colindex":fr+1,tabindex:-1,"data-col":fr,class:Qe.align!=="left"?`yv-align-${Qe.align}`:null});dn.append(ur(Qe,H,A+ve)),mr===0&&Ge&&dn.append(c("span",{class:"yv-sr"},` (${s.highlighted})`)),Ke.append(dn)}),ie.append(Ke)}),O.append(c("thead",null,_),ie);let se=O.querySelectorAll("tr");N.r=Math.min(N.r,se.length-1);let le=dr(O,N.r,N.c)||dr(O,0,0);return le&&le.setAttribute("tabindex","0"),c("div",{class:"yv-tablewrap"},O)}function To(g,A){if(!g.length){let P=i.empty instanceof Node?i.empty.cloneNode(!0):document.createTextNode(i.empty?String(i.empty):s.noData);return c("div",{class:"yv-empty",role:"status"},P)}let M=c("ul",{class:"yv-cards","aria-labelledby":pe.title});return g.forEach((P,D)=>{let O=j(P),_=F.has(O),ie=B.has(O),se=W("yv-card"),le=c("li",{class:`yv-card${ie?" yv-hl":""}`,"data-yuktai-row-id":O,"aria-labelledby":se,"aria-selected":y?String(_):null,tabindex:-1}),H=c("div",{class:"yv-card-head"},c("p",{class:"yv-card-title",id:se},Y(P),ie?c("span",{class:"yv-sr"},` (${s.highlighted})`):null));if(y){let J=c("input",{type:"checkbox","data-select":O,"aria-label":s.selectRow(Y(P))});J.checked=_,H.append(c("label",{class:"yv-check"},J))}let ve=c("dl");k.forEach(J=>{J.hiddenOnMobile||ve.append(c("dt",null,J.label),c("dd",null,ur(J,P,A+D)))}),le.append(H,ve),typeof i.onRowClick=="function"&&le.append(c("button",{type:"button",class:"yv-btn yv-small","data-open":O,style:"margin-top:8px"},i.openLabel||(l==="te"?"\u0C24\u0C46\u0C30\u0C41\u0C35\u0C41":"Open"))),M.append(le)}),M}function So(){if(Le.replaceChildren(),!w.length){Le.hidden=!0;return}Le.hidden=!1,Le.setAttribute("aria-label",s.filters(w.length)),Le.append(c("span",{class:"yv-muted"},q("filter",15)," ",s.filters(w.length))),w.forEach((g,A)=>{let M=k.find(_=>_.key===g.key),P=Array.isArray(g.value)?g.value.map(_=>it(M||{},_)).join(" \u2013 "):M?it(M,g.value):String(g.value),D=`${M?M.label:g.key} ${s.ops[g.operator]||g.operator} ${P}`,O=c("button",{type:"button",class:"yv-chip","data-remove-filter":A,"aria-label":s.removeFilter(D)},D,q("close",14));Le.append(O)}),Le.append(c("button",{type:"button",class:"yv-btn yv-small","data-clear-filters":""},s.clearFilters))}function Co(g,A,M,P){if(At.replaceChildren(),d===!1){At.append(c("span",{class:"yv-muted"},s.results(g.toLocaleString(p))));return}let D=se=>se.toLocaleString(p),O=c("span",{class:"yv-muted"},g?s.showing(D(M+1),D(P),D(g)):s.showing(0,0,0)),_=c("div",{class:"yv-pages"});if(d.showSizeChanger!==!1){let se=W("yv-size"),le=c("select",{id:se,"data-page-size":""},...S.map(H=>c("option",{value:H,selected:H===$},String(H))));_.append(c("label",{for:se,class:"yv-muted"},s.pageSize),le)}let ie=(se,le,H,ve)=>{let J=c("button",{type:"button",class:"yv-btn yv-icon","aria-label":le,title:le,disabled:H,"data-page":ve});return J.innerHTML=de(se,18),J};_.append(ie("first",s.first,x<=1,"first"),ie("left",s.previous,x<=1,"prev"),c("span",{class:"yv-muted","aria-current":"page"},s.page(D(x),D(A))),ie("right",s.next,x>=A,"next"),ie("last",s.last,x>=A,"last")),At.append(O,_)}function dr(g,A,M){let P=g.querySelectorAll("tr")[A];if(!P)return null;let D=P.querySelectorAll("th,td");return D[Math.min(M,D.length-1)]||null}function $e(g,A){let M=oe.querySelector("table");if(!M)return;let P=M.querySelectorAll("tr");g=Math.max(0,Math.min(g,P.length-1));let D=P[g].querySelectorAll("th,td");A=Math.max(0,Math.min(A,D.length-1)),M.querySelectorAll('[tabindex="0"]').forEach(_=>_.setAttribute("tabindex","-1"));let O=D[A];O.setAttribute("tabindex","0"),N={r:g,c:A},O.focus()}function pr(){if(oe.querySelector("table"))$e(N.r,N.c);else{let A=oe.querySelector(".yv-card");A&&A.focus()}}function $o(g){let A=oe.querySelector("table"),M=g.target.closest&&g.target.closest("th,td");if(!A||!M||!A.contains(M))return;let P=M.parentElement,D=Array.prototype.indexOf.call(A.querySelectorAll("tr"),P),O=Array.prototype.indexOf.call(P.querySelectorAll("th,td"),M),_=A.querySelectorAll("tr").length-1,ie=!0;switch(g.key){case"ArrowRight":$e(D,O+1);break;case"ArrowLeft":$e(D,O-1);break;case"ArrowDown":$e(D+1,O);break;case"ArrowUp":$e(D-1,O);break;case"Home":g.ctrlKey?$e(0,0):$e(D,0);break;case"End":g.ctrlKey?$e(_,999):$e(D,999);break;case"PageDown":d!==!1&&(N={r:Math.max(1,D),c:O},We(x+1,!0));break;case"PageUp":d!==!1&&(N={r:Math.max(1,D),c:O},We(x-1,!0));break;case"Enter":case" ":{let se=M.querySelector("[data-sort]"),le=M.querySelector("input[type=checkbox]");se?gr(se.getAttribute("data-sort")):le?le.click():g.key==="Enter"&&P.hasAttribute("data-yuktai-row-id")&&typeof i.onRowClick=="function"?st(P.getAttribute("data-yuktai-row-id")):g.key===" "&&y&&P.hasAttribute("data-yuktai-row-id")?Ro(P.getAttribute("data-yuktai-row-id")):ie=!1;break}default:ie=!1}ie&&(g.preventDefault(),g.stopPropagation())}function gr(g){let A=k.find(P=>P.key===g);if(!A||!A.sortable)return;!v||v.key!==g?v={key:g,direction:"asc"}:v.direction==="asc"?v={key:g,direction:"desc"}:v=null,x=1,oe.querySelector("table")&&oe.contains(document.activeElement)&&(N={r:0,c:N.c}),U(),Tt(v?v.direction==="asc"?s.sortedAsc(A.label):s.sortedDesc(A.label):s.sortCleared),i.onSortChange&&i.onSortChange(v?{key:v.key,direction:v.direction}:null)}function je(){i.onSelectionChange&&i.onSelectionChange(Array.from(F)),Z.dispatchEvent(new CustomEvent("yuktai:selection",{detail:{keys:Array.from(F)},bubbles:!0}))}function Ro(g,A){(A===void 0?!F.has(g):A)?F.add(g):F.delete(g),U(),je()}function We(g,A){let{pages:M}=Ve(ye.length),P=Math.min(Math.max(1,g),M);P===x&&!A||(x=P,U(),Tt(s.page(x,M)),A&&oe.querySelector("table")&&pr())}function st(g){let A=E.find(M=>j(M)===String(g));return A?(typeof i.onRowClick=="function"&&i.onRowClick(A,E.indexOf(A)),typeof i.onOpenRow=="function"&&i.onOpenRow(String(g)),!0):!1}function lt(g,A=m){if(B.clear(),(g||[]).forEach(M=>B.add(typeof M=="object"&&M!==null?j(M):String(M))),A&&B.size){let M=ye.length?ye.findIndex(P=>B.has(j(P))):Pe().findIndex(P=>B.has(j(P)));M>=0&&d!==!1&&(x=Math.floor(M/$)+1)}if(U(),A&&B.size){let M=oe.querySelector(".yv-hl");M&&M.scrollIntoView&&M.scrollIntoView({block:"nearest",behavior:tr()?"auto":"smooth"})}}let cn=null;Ae.addEventListener("input",()=>{clearTimeout(cn),cn=setTimeout(()=>{L=Ae.value.trim(),x=1,U(),Tt(s.results(ye.length.toLocaleString(p)))},160)}),Z.addEventListener("click",g=>{let A=g.target.closest("button, input, tr[data-yuktai-row-id]");if(!(!A||!Z.contains(A))){if(A.matches("[data-sort]"))return gr(A.getAttribute("data-sort"));if(A.matches("[data-page]")){let M=A.getAttribute("data-page"),{pages:P}=Ve(ye.length);return We(M==="first"?1:M==="prev"?x-1:M==="next"?x+1:P)}if(A.matches("[data-remove-filter]")){w=w.filter((M,P)=>P!==Number(A.getAttribute("data-remove-filter"))),x=1,U(),i.onFiltersChange&&i.onFiltersChange(w.slice());return}if(A.matches("[data-clear-filters]"))return K.clearFilters();if(A.matches("[data-open]"))return st(A.getAttribute("data-open"));if(A===ot){T=at()?"table":"card",U();return}if(A===cr)return K.exportCSV();A.matches("tr[data-yuktai-row-id]")&&typeof i.onRowClick=="function"&&!g.target.closest("label,input,button,a")&&st(A.getAttribute("data-yuktai-row-id"))}}),Z.addEventListener("change",g=>{let A=g.target;if(A.matches("[data-select]"))A.checked?F.add(A.getAttribute("data-select")):F.delete(A.getAttribute("data-select")),U(),je();else if(A.matches("[data-select-page]")){let{start:M,end:P}=Ve(ye.length);ye.slice(M,P).forEach(D=>A.checked?F.add(j(D)):F.delete(j(D))),U(),je()}else A.matches("[data-page-size]")&&($=Number(A.value)||$,x=1,U(),oe.closest(".yv-grid").querySelector("[data-page-size]").focus())}),oe.addEventListener("keydown",$o),oe.addEventListener("focusin",g=>{let A=oe.querySelector("table"),M=g.target.closest&&g.target.closest("th,td");if(!A||!M)return;let P=M.parentElement,D=Array.prototype.indexOf.call(A.querySelectorAll("tr"),P),O=Array.prototype.indexOf.call(P.querySelectorAll("th,td"),M);D<0||O<0||(A.querySelectorAll('[tabindex="0"]').forEach(_=>_!==M&&_.setAttribute("tabindex","-1")),M.setAttribute("tabindex","0"),N={r:D,c:O})});let St=null;typeof ResizeObserver=="function"&&(St=new ResizeObserver(g=>{let A=g[0]&&g[0].contentRect.width,M=A>0&&A<C;M!==G&&(G=M,T==="auto"&&U())}),St.observe(Z));let Te={get data(){return E},get columns(){return h},rowKey:f,locale:u,get filters(){return w},onHighlightRows:g=>lt(g),onSelectRow:g=>{F.add(String(g)),lt([String(g)]),je()},onOpenRow:typeof i.onRowClick=="function"||typeof i.onOpenRow=="function"?g=>st(g):void 0,onFiltersChange:g=>{w=g.slice(),x=1,U(),i.onFiltersChange&&i.onFiltersChange(w.slice())},onSortChange:g=>{v=g?{key:g.key,direction:g.direction==="desc"?"desc":"asc"}:null,x=1,U(),i.onSortChange&&i.onSortChange(v)}},Ct=Je(Te,{name:i.toolName||"yuktai_grid",descriptions:i.toolDescriptions}),ct=Jt({tools:()=>Ct,data:()=>E,columns:()=>h.map(g=>({key:g.key,label:g.label})),rowKey:f,locale:u,customRules:i.customRules||[],parseIntent:i.parseIntent,historyLimit:i.historyLimit||20,onResult:g=>{i.onAgentResult&&i.onAgentResult({success:g.success,message:g.message,tool:g.tool})},onError:i.onAgentError}),$t={status:{state:"unsupported",registered:[],errors:[]},unregister(){}};i.webmcp&&($t=Xt(()=>Ct,{onStatusChange:g=>{i.onWebMCPStatusChange&&i.onWebMCPStatusChange(g),Z.dispatchEvent(new CustomEvent("yuktai:webmcp",{detail:g,bubbles:!0}))}}));let Ue=Zt({data:E,columns:h,rowKey:f,referenceDate:i.referenceDate,onOpenRow:Te.onOpenRow,bind:{getData:()=>E,getFilters:()=>w,getSort:()=>v,getHighlightIds:()=>Array.from(B),setFilters:g=>Te.onFiltersChange(g),setSort:g=>Te.onSortChange(g),setHighlightIds:g=>lt(g),selectRow:g=>Te.onSelectRow(g)}}),ut=null;i.ai&&(ut=or(an,ct,{locale:u,inputLanguage:i.inputLanguage||(u==="te"?"te-IN":"en-IN"),examples:i.assistantExamples,webmcp:()=>$t.status,showWebMCP:!!i.webmcp}),i.webmcp&&Z.addEventListener("yuktai:webmcp",()=>ut&&ut.refreshStatus()));let un=null;if(i.agentic){let g=typeof i.agentic=="object"?i.agentic:{};un=nn(an,Ue,g)}let K={element:Z,host:Z,get tools(){return Ct},agent:ct,agentic:Ue,get webmcpStatus(){return $t.status},refresh(g){return Array.isArray(g)&&(E=g.slice(),F.clear(),B.clear(),x=1),U(),K},setData(g,A){return Array.isArray(A)&&(k=fo(A,g||E),h=Me(k),Ct=Je(Te,{name:i.toolName||"yuktai_grid",descriptions:i.toolDescriptions})),K.refresh(g)},getData:()=>E.slice(),getRows:()=>Pe(),getPageRows(){let g=Pe(),{start:A,end:M}=Ve(g.length);return g.slice(A,M)},getSelectedRows:()=>E.filter(g=>F.has(j(g))),getSelectedKeys:()=>Array.from(F),select(g,A=!0){return[].concat(g).forEach(M=>A?F.add(String(M)):F.delete(String(M))),U(),je(),K},clearSelection(){return F.clear(),U(),je(),K},search(g){return L=String(g||"").trim(),Ae.value=L,x=1,U(),ye.length},setFilters(g){return Te.onFiltersChange(Array.isArray(g)?g:[]),K},addFilter(g){return ct.executeTool("filter",g)},getFilters:()=>w.slice(),clearFilters(){return Te.onFiltersChange([]),Tt(l==="te"?"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C36\u0C3E\u0C30\u0C41":"Filters cleared"),K},sortBy(g,A="asc"){return Te.onSortChange(g?{key:g,direction:A}:null),K},clearSort(){return Te.onSortChange(null),K},getSort:()=>v?{...v}:null,highlight(g,A){return lt(g,A===void 0?m:A),K},clearHighlight(){return lt([],!1),K},getHighlightIds:()=>Array.from(B),goToPage(g){return We(Number(g)||1),K},nextPage(){return We(x+1),K},prevPage(){return We(x-1),K},getPage:()=>({page:x,pageSize:$,pages:Ve(ye.length).pages,total:ye.length}),setPageSize(g){return $=Number(g)||$,S.includes($)||(S.push($),S.sort((A,M)=>A-M)),x=1,U(),K},setTheme(g){return I=mo.includes(g)?g:"default",U(),K},getTheme:()=>I,setView(g){return T=["table","card","auto"].includes(g)?g:"auto",U(),K},setLoading(g){return R=!!g,U(),K},openRow:g=>st(g),async ask(g){return(await Ue.ask(g)).answer},askDetailed:g=>Ue.ask(g),assistantAsk:g=>ct.ask(g),executeTool:(g,A)=>ct.executeTool(g,A),biSummary:()=>ze(Pe(),h),anomalies:()=>Oe(Pe(),h,{rowKey:f}),async runTasks(g){return(await Ue.ask(g)).answer},reset(){return Ue.reset(),L="",Ae.value="",U(),K},exportCSV(g=i.exportFileName||"yuktai-grid-export.csv"){let A=F.size?E.filter(P=>F.has(j(P))):Pe(),M="\uFEFF"+[k.map(P=>nr(P.label)).join(","),...A.map(P=>k.map(D=>nr(P[D.key])).join(","))].join(`\r
|
|
541
|
+
`);return vt(g,M,"text/csv;charset=utf-8"),re(`${A.length} row(s) exported`),A.length},destroy(){clearTimeout(cn),clearTimeout(ln),St&&St.disconnect(),$t.unregister(),ut&&ut.destroy(),un&&un.destroy(),Z.remove()}};return typeof i.onReady=="function"&&i.onReady(K),U(),K}var _i={en:{title:"Ask the grid",hint:"Type or speak: a word to search, \u201Csort by <column>\u201D, \u201Chow many\u201D, \u201Cclear filters\u201D, \u201Copen <name>\u201D.",placeholder:"Ask the grid\u2026",ask:"Ask",listen:"Speak",stop:"Stop",listening:"Listening\u2026",noVoice:"Voice input is not available in this browser. Type your question instead.",history:"History",clear:"Clear history",webmcp:{unsupported:"WebMCP: not available in this browser (no document.modelContext).",registering:"WebMCP: registering tools\u2026",ready:"WebMCP: tools ready",partial:"WebMCP: some tools failed",error:"WebMCP: registration failed"}},te:{title:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C28\u0C41 \u0C05\u0C21\u0C17\u0C02\u0C21\u0C3F",hint:"\u0C1F\u0C48\u0C2A\u0C4D \u0C1A\u0C47\u0C2F\u0C02\u0C21\u0C3F \u0C32\u0C47\u0C26\u0C3E \u0C2E\u0C3E\u0C1F\u0C4D\u0C32\u0C3E\u0C21\u0C02\u0C21\u0C3F: \u0C35\u0C46\u0C24\u0C15\u0C3E\u0C32\u0C4D\u0C38\u0C3F\u0C28 \u0C2A\u0C26\u0C02, \u201C<\u0C15\u0C3E\u0C32\u0C2E\u0C4D> \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C15\u0C4D\u0C30\u0C2E\u0C02\u201D, \u201C\u0C0E\u0C28\u0C4D\u0C28\u0C3F\u201D, \u201C\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F\u201D.",placeholder:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C28\u0C41 \u0C05\u0C21\u0C17\u0C02\u0C21\u0C3F\u2026",ask:"\u0C05\u0C21\u0C41\u0C17\u0C41",listen:"\u0C2E\u0C3E\u0C1F\u0C4D\u0C32\u0C3E\u0C21\u0C41",stop:"\u0C06\u0C2A\u0C41",listening:"\u0C35\u0C3F\u0C02\u0C1F\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41\u2026",noVoice:"\u0C08 \u0C2C\u0C4D\u0C30\u0C4C\u0C1C\u0C30\u0C4D\u200C\u0C32\u0C4B \u0C35\u0C3E\u0C2F\u0C3F\u0C38\u0C4D \u0C07\u0C28\u0C4D\u200C\u0C2A\u0C41\u0C1F\u0C4D \u0C32\u0C47\u0C26\u0C41. \u0C1F\u0C48\u0C2A\u0C4D \u0C1A\u0C47\u0C2F\u0C02\u0C21\u0C3F.",history:"\u0C1A\u0C30\u0C3F\u0C24\u0C4D\u0C30",clear:"\u0C1A\u0C30\u0C3F\u0C24\u0C4D\u0C30 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F",webmcp:{unsupported:"WebMCP: \u0C08 \u0C2C\u0C4D\u0C30\u0C4C\u0C1C\u0C30\u0C4D\u200C\u0C32\u0C4B \u0C32\u0C47\u0C26\u0C41.",registering:"WebMCP: \u0C28\u0C2E\u0C4B\u0C26\u0C41 \u0C1A\u0C47\u0C38\u0C4D\u0C24\u0C4B\u0C02\u0C26\u0C3F\u2026",ready:"WebMCP: \u0C38\u0C3F\u0C26\u0C4D\u0C27\u0C02",partial:"WebMCP: \u0C15\u0C4A\u0C28\u0C4D\u0C28\u0C3F \u0C35\u0C3F\u0C2B\u0C32\u0C02",error:"WebMCP: \u0C35\u0C3F\u0C2B\u0C32\u0C02"}}};function or(e,t,n={}){let r=_i[n.locale==="te"?"te":"en"],a=W("yv-ask"),i=W("yv-hint"),o=c("input",{id:a,class:"yv-input",type:"text",placeholder:r.placeholder,autocomplete:"off","aria-describedby":i}),l=c("button",{type:"submit",class:"yv-btn yv-primary"},q("spark",16),r.ask),s=typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition),u=c("button",{type:"button",class:"yv-btn","aria-pressed":"false"},q("mic",16),r.listen),p=c("div",{class:"yv-answer",role:"status","aria-live":"polite"}),f=c("ol"),b=c("details",{class:"yv-history"},c("summary",null,r.history),f,c("button",{type:"button",class:"yv-btn yv-small","data-clear-history":""},r.clear)),d=n.showWebMCP?c("p",{class:"yv-muted",style:"margin:8px 0 0"}):null,S=n.examples||(n.locale==="te"?["\u0C0E\u0C28\u0C4D\u0C28\u0C3F","\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F"]:["how many","clear filters","clear sort"]),y=c("div",{class:"yv-chips"},...S.map(v=>c("button",{type:"button",class:"yv-chip","data-example":v},v))),m=c("form",{class:"yv-row",role:"search","aria-label":r.title},c("label",{for:a,class:"yv-sr"},r.title),o,l,u),C=c("section",{class:"yv-box yv-assistant","aria-label":r.title},c("h3",null,q("chat",16)," ",r.title),c("p",{id:i,class:"yv-muted",style:"margin:0 0 8px"},r.hint),m,y,p,b,d);e.appendChild(C);async function E(v){let L=String(v||"").trim();if(L){l.disabled=!0;try{let x=await t.ask(L);p.textContent=x.message,p.className=`yv-answer ${x.success?"":"yv-fail"}`}finally{l.disabled=!1}}}let k=t.subscribe(v=>{f.replaceChildren(...v.history.slice().reverse().map(L=>c("li",null,c("span",{class:L.result.success?"yv-ok":"yv-fail"},L.result.success?"\u2713 ":"\u2717 "),L.result.message,c("span",{class:"yv-muted"},` (${L.tool})`)))),b.querySelector("summary").textContent=`${r.history} (${v.history.length})`});m.addEventListener("submit",v=>{v.preventDefault(),E(o.value)}),C.addEventListener("click",v=>{let L=v.target.closest("[data-example],[data-clear-history]");L&&(L.hasAttribute("data-example")?(o.value=L.getAttribute("data-example"),E(o.value)):(t.clearHistory(),p.textContent=""))});let h=null;u.addEventListener("click",()=>{if(!s){p.textContent=r.noVoice;return}if(h){h.stop();return}h=new s,h.lang=n.inputLanguage||"en-IN",h.interimResults=!1,h.maxAlternatives=1,u.setAttribute("aria-pressed","true"),u.lastChild.textContent=r.stop,p.textContent=r.listening,h.onresult=v=>{let L=v.results[0][0].transcript;o.value=L,E(L)},h.onerror=v=>{p.textContent=`${r.noVoice} (${v.error})`},h.onend=()=>{h=null,u.setAttribute("aria-pressed","false"),u.lastChild.textContent=r.listen};try{h.start()}catch(v){p.textContent=`${r.noVoice} (${v.message})`,h=null}}),s||(u.title=r.noVoice);function w(){if(!d||!n.webmcp)return;let v=n.webmcp();d.textContent=r.webmcp[v.state]+(v.registered&&v.registered.length?` (${v.registered.length})`:"")}return w(),{element:C,ask:E,refreshStatus:w,destroy(){k(),h&&h.stop(),C.remove()}}}var bo=[{id:"copilot",label:"Copilot",icon:"wand"},{id:"qa",label:"QA report",icon:"check"},{id:"forms",label:"Forms",icon:"form"},{id:"design",label:"Design",icon:"layout"},{id:"ask",label:"Ask page",icon:"chat"},{id:"voice",label:"Voice",icon:"mic"}],Vi=[["en-IN","English (India)"],["en-US","English (US)"],["te-IN","\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41 (Telugu)"],["hi-IN","\u0939\u093F\u0928\u094D\u0926\u0940 (Hindi)"],["ta-IN","\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD (Tamil)"],["kn-IN","\u0C95\u0CA8\u0CCD\u0CA8\u0CA1 (Kannada)"],["ml-IN","\u0D2E\u0D32\u0D2F\u0D3E\u0D33\u0D02 (Malayalam)"],["mr-IN","\u092E\u0930\u093E\u0920\u0940 (Marathi)"],["bn-IN","\u09AC\u09BE\u0982\u09B2\u09BE (Bengali)"],["gu-IN","\u0A97\u0AC1\u0A9C\u0AB0\u0ABE\u0AA4\u0AC0 (Gujarati)"]],ir=e=>c("span",{class:`yv-badge yv-sev-${e}`},e);function ar(e,t){return c("div",null,c("div",{class:"yv-score"},c("strong",null,String(e)),c("span",{class:"yv-muted"},"/ 100")),c("div",{class:"yv-meter",role:"img","aria-label":`Score ${e} out of 100`},c("span",{style:`width:${Math.max(0,Math.min(100,e))}%`})),c("p",{style:"margin:0 0 6px"},t))}function wt(e){let t=(e||[]).filter(Boolean);return t.length?c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>re(`${go(t)} element(s) outlined on the page`)},q("eye",14),"Show on page"):null}function rn(e,t={}){let n=e==null?null:typeof e=="string"?document.querySelector(e):e;if(e!=null&&!n)throw new Error("mountAgenticPanel: container not found");let r=W("yv-tabs"),a=c("section",{class:`yv-box yv-agentic-panel${t.theme?" yv-theme-"+t.theme:""}`,"data-yuktai-panel":"","aria-label":t.title||"Page tools"}),i=c("div",{class:"yv-tabs",role:"tablist","aria-label":"Page tools",id:r}),o={};bo.forEach(k=>{let h=`${r}-${k.id}`,w=`${h}-panel`;i.append(c("button",{type:"button",class:"yv-tab",role:"tab",id:h,"aria-controls":w,"aria-selected":"false",tabindex:-1,"data-tab":k.id},q(k.icon,15)," ",k.label)),o[k.id]=c("div",{role:"tabpanel",id:w,"aria-labelledby":h,hidden:!0,tabindex:0})}),a.append(i,...Object.values(o)),n&&n.appendChild(a);let l={},s=null;function u(k,h){o[k]||(k="qa"),s=k,i.querySelectorAll("[role=tab]").forEach(w=>{let v=w.getAttribute("data-tab")===k;w.setAttribute("aria-selected",String(v)),w.tabIndex=v?0:-1,v&&h&&w.focus()}),Object.entries(o).forEach(([w,v])=>v.hidden=w!==k),l[k]||(l[k]=!0,E[k](o[k]))}i.addEventListener("click",k=>{let h=k.target.closest("[role=tab]");h&&u(h.getAttribute("data-tab"),!0)}),i.addEventListener("keydown",k=>{let h=bo.map(x=>x.id),w=k.target.closest&&k.target.closest("[role=tab]"),v=h.indexOf(w?w.getAttribute("data-tab"):s),L=null;k.key==="ArrowRight"?L=h[(v+1)%h.length]:k.key==="ArrowLeft"?L=h[(v-1+h.length)%h.length]:k.key==="Home"?L=h[0]:k.key==="End"&&(L=h[h.length-1]),L&&(k.preventDefault(),k.stopPropagation(),u(L,!0))});let p=null;function f(k){let h=c("ul",{class:"yv-list"}),w=c("p",{class:"yv-status",role:"status","aria-live":"polite"}),v=c("div",{class:"yv-answer","aria-live":"polite"}),L=c("button",{type:"button",class:"yv-btn","aria-pressed":"false"},q("eye",16),"Watch page");p=Ot({defaultLang:t.defaultLang,debounceMs:600,onUpdate:$=>x($)});function x($){let I=$.report;L.setAttribute("aria-pressed",String($.watching)),w.textContent=I?`${I.summary} Fixes applied: ${$.appliedFixes}.${$.watching?" Watching for page changes.":""}`:"Scan the page to see issues.",h.replaceChildren(...(I?I.issues.slice(0,40):[]).map(T=>c("li",{class:"yv-item"},c("p",null,ir(T.severity)," ",c("b",null,T.message)),c("p",{class:"yv-muted"},`WCAG ${T.wcag} \xB7 `,c("code",null,T.selector)),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>v.textContent=p.explain(T.id)},q("info",14),"Explain"),T.autoFixable?c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>re(p.applyFix(T.id).message)},q("wand",14),"Fix"):null,wt([T.selector])))))}k.append(c("p",{class:"yv-muted"},"Finds accessibility problems, explains them in plain English, and applies safe fixes you can undo."),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn yv-primary",onclick:()=>p.scan()},q("search",16),"Scan page"),L,c("button",{type:"button",class:"yv-btn",onclick:()=>re(`${p.applyAllFixes().filter($=>$.applied).length} fix(es) applied`)},q("wand",16),"Apply all safe fixes"),c("button",{type:"button",class:"yv-btn",onclick:()=>re(`${p.undoAll()} change(s) undone`)},q("undo",16),"Undo all")),w,v,h),L.addEventListener("click",()=>p.getState().watching?p.stop():p.start()),x(p.getState())}function b(k){let h=c("div",{"aria-live":"polite"}),w=null,v=()=>{w=be(t.auditOptions||{});let L=w.issues;h.replaceChildren(ar(w.score,w.summary),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn yv-small",onclick:async()=>re(await po(bt(w))?"Markdown report copied":"Copy failed")},q("copy",14),"Copy Markdown"),c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>vt("yuktai-qa-report.md",bt(w),"text/markdown;charset=utf-8")},q("download",14),"Markdown"),c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>vt("yuktai-qa-report.json",Dt(w),"application/json")},q("download",14),"JSON")),c("details",{class:"yv-history"},c("summary",null,`Checks (${w.checks.filter(x=>x.passed).length}/${w.checks.length} passed)`),c("ul",{class:"yv-steps"},...w.checks.map(x=>c("li",null,c("span",{class:x.passed?"yv-ok":"yv-fail"},x.passed?"\u2713 ":"\u2717 "),x.title||x.rule,x.issueCount?` \u2014 ${x.issueCount} issue(s)`:"")))),c("ul",{class:"yv-list"},...L.slice(0,60).map(x=>c("li",{class:"yv-item"},c("p",null,ir(x.severity)," ",c("b",null,x.message)),c("p",null,c("b",null,"Fix: "),x.fix),c("p",{class:"yv-muted"},`${x.rule} \xB7 WCAG ${x.wcag} \xB7 `,c("code",null,x.selector)),wt([x.selector])))),L.length>60?c("p",{class:"yv-muted"},`${L.length-60} more issue(s) in the downloaded report.`):null),re(w.summary)};k.append(c("p",{class:"yv-muted"},"15 WCAG checks on this page with a 0\u2013100 score. Heuristic: still test with a keyboard and a screen reader."),c("button",{type:"button",class:"yv-btn yv-primary",onclick:v},q("check",16),"Run QA audit"),h)}function d(k){let h=c("input",{type:"checkbox",id:W("yv-senior"),checked:t.seniorFriendly!==!1}),w=c("div",{"aria-live":"polite"}),v=()=>{let L=Ze({seniorFriendly:h.checked,maxFieldsPerStep:t.maxFieldsPerStep||8});if(!L.length)return w.replaceChildren(c("p",{class:"yv-answer"},"There are no forms on this page.")),re("No forms found");w.replaceChildren(...L.map(x=>c("div",{class:"yv-item",style:"margin-top:10px"},ar(x.score,x.summary),c("ul",{class:"yv-steps"},...x.findings.map($=>c("li",null,c("span",{class:`yv-badge yv-sev-${$.level==="problem"?"serious":"minor"}`},$.level)," ",$.message,c("br"),c("span",{class:"yv-muted"},$.suggestion)))),wt(x.findings.map($=>$.selector))))),re(`${L.length} form(s) reviewed`)};k.append(c("p",{class:"yv-muted"},"Checks labels, autocomplete, error messages and senior-friendly tips."),c("div",{class:"yv-row"},c("label",{class:"yv-check",for:h.id},h),c("label",{for:h.id},"Senior-friendly checks"),c("button",{type:"button",class:"yv-btn yv-primary",onclick:v},q("form",16),"Review forms")),w)}function S(k){let h=W("yv-min"),w=c("input",{id:h,class:"yv-input",type:"number",min:10,max:24,value:t.minFontSize||16,style:"width:90px"}),v=c("div",{"aria-live":"polite"}),L=()=>{let x=Bt({minFontSize:Number(w.value)||16,maxLineLength:t.maxLineLength||90});v.replaceChildren(ar(x.score,x.summary),c("div",{class:"yv-cats"},...Object.entries(x.categories).map(([$,I])=>c("div",{class:"yv-cat"},c("span",{class:"yv-muted"},$),c("strong",null,String(I.score)),c("span",{class:"yv-muted"},`${I.findings} finding(s)`)))),c("ul",{class:"yv-list"},...x.findings.slice(0,40).map($=>c("li",{class:"yv-item"},c("p",null,ir($.severity)," ",c("b",null,$.category),": ",$.message),c("p",{class:"yv-muted"},$.suggestion),wt([$.selector]))))),re(x.summary)};k.append(c("p",{class:"yv-muted"},"Hierarchy, readability, interaction, clutter and consistency. Heuristic, not a visual-design certification."),c("div",{class:"yv-row"},c("label",{for:h},"Minimum text size (px)"),w,c("button",{type:"button",class:"yv-btn yv-primary",onclick:L},q("layout",16),"Review design")),v)}function y(k){let h=W("yv-pq"),w=c("input",{id:h,class:"yv-input",type:"text",placeholder:"What is this page about?",autocomplete:"off"}),v=c("div",{"aria-live":"polite"}),L=null,x=async()=>{let T=w.value.trim()||"What is this page about?",R=await zt(T,{summarize:t.summarize}),G=[c("div",{class:"yv-answer"},R.answer)];R.suggestions.length&&G.push(c("ul",{class:"yv-steps"},...R.suggestions.map(F=>c("li",null,F))));let N=wt(R.targets);if(N&&G.push(N),R.intent==="unknown"){L?L.rebuild():L=qt({includePage:!0,documents:t.documents});let F=await L.ask(T,{generate:t.generate});G.push(c("h4",{style:"margin:12px 0 4px"},F.generated?"Answer (your model)":"From the page text"),c("div",{class:"yv-answer"},F.answer))}v.replaceChildren(...G),re(R.answer)},$=c("form",{class:"yv-row"},c("label",{for:h,class:"yv-sr"},"Ask about this page"),w,c("button",{type:"submit",class:"yv-btn yv-primary"},"Ask"));$.addEventListener("submit",T=>{T.preventDefault(),x()});let I=["What is this page about?","Which fields have no label?","Which images have no alt text?","Show the page structure","How many links are there?","Tell me about the forms"];k.append(c("p",{class:"yv-muted"},"Answers from this page only, offline. Pass generate() to use your own model."),$,c("div",{class:"yv-chips"},...I.map(T=>c("button",{type:"button",class:"yv-chip",onclick:()=>(w.value=T,x())},T))),v)}let m=null;function C(k){let h=W("yv-lang"),w=c("select",{id:h,class:"yv-input",style:"width:auto"},...Vi.map(([N,F])=>c("option",{value:N,selected:N===(t.voiceLang||"en-IN")},F))),v=c("button",{type:"button",class:"yv-btn yv-primary","aria-pressed":"false"},q("mic",16),"Start listening"),L=W("yv-cmd"),x=c("input",{id:L,class:"yv-input",type:"text",placeholder:"Type a command, e.g. make text bigger",autocomplete:"off"}),$=c("div",{class:"yv-answer",role:"status","aria-live":"polite"}),I=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition),T=()=>{m&&m.stop(),m=Yt({lang:w.value,speak:t.speak!==!1,initial:t.getSettings?t.getSettings():void 0,apply:t.applySettings,onTranscript:(N,F)=>{$.textContent=`Heard: \u201C${N}\u201D
|
|
542
|
+
${F?F.say:"Not a voice command. Try: make text bigger, high contrast on, dark mode, next row, reset."}`,t.onVoiceCommand&&t.onVoiceCommand(N,F)}})};T(),w.addEventListener("change",()=>{let N=v.getAttribute("aria-pressed")==="true";T(),N&&m.start()}),v.addEventListener("click",()=>{if(v.getAttribute("aria-pressed")==="true"){m.stop(),v.setAttribute("aria-pressed","false"),v.lastChild.textContent="Start listening";return}if(!m.start()){$.textContent="Speech recognition is not available in this browser. Typed commands below still work.";return}v.setAttribute("aria-pressed","true"),v.lastChild.textContent="Stop listening",$.textContent="Listening\u2026 say \u201Cmake text bigger\u201D or \u201Cnext row\u201D."});let R=c("form",{class:"yv-row"},c("label",{for:L,class:"yv-sr"},"Type a voice command"),x,c("button",{type:"submit",class:"yv-btn"},"Run"));R.addEventListener("submit",async N=>{N.preventDefault(),x.value.trim()&&await m.handle(x.value)});let G=["make text bigger","make text smaller","high contrast on","dark mode","reduce motion","dyslexia font","next row","previous row","first row","reset","\u0C2A\u0C46\u0C26\u0C4D\u0C26 \u0C05\u0C15\u0C4D\u0C37\u0C30\u0C3E\u0C32\u0C41","\u0C39\u0C48 \u0C15\u0C3E\u0C02\u0C1F\u0C4D\u0C30\u0C3E\u0C38\u0C4D\u0C1F\u0C4D","\u0C24\u0C30\u0C4D\u0C35\u0C3E\u0C24\u0C3F \u0C35\u0C30\u0C41\u0C38"];k.append(c("p",{class:"yv-muted"},I?"Speak accessibility commands in English or Telugu. Text size moves 80\u2013130% in 10% steps.":"Your browser has no speech recognition. You can still type the same commands."),c("div",{class:"yv-row"},c("label",{for:h},"Language"),w,v),R,c("div",{class:"yv-chips"},...G.map(N=>c("button",{type:"button",class:"yv-chip",onclick:()=>(x.value=N,m.handle(N))},N))),$)}let E={copilot:f,qa:b,forms:d,design:S,ask:y,voice:C};return u(t.defaultTab||"qa",!1),{element:a,select:k=>u(k,!1),get tab(){return s},get copilot(){return p},destroy(){p&&p.stop(),m&&m.stop(),a.remove()}}}var sr="yuktai-a11y-prefs",xt=[.8,.9,1,1.1,1.2,1.3],ji=[["none","None"],["deuteranopia","Deuteranopia (red-green)"],["protanopia","Protanopia (red-green)"],["tritanopia","Tritanopia (blue-yellow)"],["achromatopsia","Achromatopsia (no colour)"]],Wi=[["highContrast","High contrast","Stronger text and borders","contrast"],["darkMode","Dark mode","Light text on a dark page","moon"],["reduceMotion","Reduce motion","Stop animations and transitions","motion"],["largeTargets","Large targets","Buttons and links at least 44\xD744","target"],["dyslexiaFont","Dyslexia-friendly font","Easier letters and wider spacing","reading"],["speechEnabled","Speak on focus","Read out each control you Tab to","speaker"],["autoFix","Auto-fix page","Add missing ARIA, labels and alt text; watch new content","wand"],["showSkipLinks","Skip links","\u201CSkip to main content\u201D on Tab","skip"]];function Ui(){try{let e=localStorage.getItem(sr);return e?JSON.parse(e):{}}catch{return{}}}function Ki(e){try{let t={};["highContrast","darkMode","reduceMotion","largeTargets","speechEnabled","colorBlindMode","dyslexiaFont","fontSizeMultiplier"].forEach(n=>t[n]=e[n]),localStorage.setItem(sr,JSON.stringify(t))}catch{}}function yo(e={}){let t={position:"left",title:"Accessibility",showPageTools:!1,...e},n=t.position==="right"?"right":"left",r=en(t.primaryColor,"#0f766e"),a={enabled:!0,autoFix:!0,showSkipLinks:!0,showPreferencePanel:!1,...rt,...t.config||{}},i={...a,...Ui()},o,l,s,u,p,f,b,d="";async function S(T,R){i={...i,...T,enabled:!0},Ki(i);try{d=await He.execute({...i}),i.autoFix||He.stopObserver()}catch(G){console.error("[yuktai] accessibility engine failed",G),d="Some settings could not be applied. See the browser console."}return C(),R||re("Accessibility settings updated"),d}async function y(){try{localStorage.removeItem(sr)}catch{}return i={...a},await S(i,!0),re("Accessibility settings reset"),i}function m(){let T=W("yv-a11y-title"),R=W("yv-font"),G=W("yv-cb"),N=c("section",{class:"yv-dialog",role:"dialog","aria-modal":"false","aria-labelledby":T,"data-yuktai-panel":""}),F=Wi.map(([j,Y,Z,kt])=>{let Ae=W("yv-opt"),on=c("input",{id:Ae,type:"checkbox",role:"switch","data-setting":j,"aria-describedby":`${Ae}-d`});return c("div",{class:"yv-option"},c("span",{class:"yv-option-icon"},q(kt,18)),c("span",{class:"yv-option-copy"},c("label",{for:Ae},c("b",null,Y)),c("small",{id:`${Ae}-d`},Z)),c("span",{class:"yv-switch"},on,c("span",{"aria-hidden":"true"})))}),B=c("div",{class:"yv-steps-bar",role:"group","aria-labelledby":R},...xt.map(j=>c("button",{type:"button",class:"yv-step","data-font":j,"aria-label":`${Math.round(j*100)} percent`,"aria-pressed":"false"}))),pe=c("select",{id:G,class:"yv-input","data-colorblind":""},...ji.map(([j,Y])=>c("option",{value:j},Y)));return N.append(c("header",{class:"yv-dialog-head"},c("div",null,c("div",{class:"yv-muted",style:"font-weight:800;font-size:.75em;letter-spacing:.05em"},"YUKTAI"),c("h2",{id:T},t.title),c("p",{class:"yv-muted",style:"margin:2px 0 0"},"Saved on this device. Works on every page.")),c("button",{type:"button",class:"yv-btn yv-icon","data-close":"","aria-label":"Close accessibility settings",html:de("close")})),c("div",{class:"yv-dialog-body"},...F,c("div",{style:"padding:12px 0;border-bottom:1px solid var(--yv-border)"},c("div",{style:"display:flex;justify-content:space-between"},c("b",{id:R},"Text size"),c("strong",{"data-font-value":""})),c("div",{class:"yv-row",style:"flex-wrap:nowrap;margin-top:6px"},c("button",{type:"button",class:"yv-btn yv-icon","data-font-step":"-1","aria-label":"Smaller text",html:de("minus",16)}),B,c("button",{type:"button",class:"yv-btn yv-icon","data-font-step":"1","aria-label":"Bigger text",html:de("plus",16)}))),c("div",{style:"padding:12px 0"},c("label",{for:G},c("b",null,"Colour-blind filter")),pe),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn","data-reset":""},q("reset",16),"Reset all"),c("button",{type:"button",class:"yv-btn yv-primary","data-close":""},q("check",16),"Done")),c("p",{class:"yv-status",role:"status","aria-live":"polite","data-status":""}))),N.addEventListener("change",j=>{let Y=j.target;Y.matches("[data-setting]")?S({[Y.getAttribute("data-setting")]:Y.checked}):Y.matches("[data-colorblind]")&&S({colorBlindMode:Y.value})}),N.addEventListener("click",j=>{let Y=j.target.closest("button");if(Y){if(Y.hasAttribute("data-close"))return w();if(Y.hasAttribute("data-reset"))return y();if(Y.hasAttribute("data-font"))return E(Number(Y.getAttribute("data-font")));if(Y.hasAttribute("data-font-step")){let Z=xt.indexOf(Number(i.fontSizeMultiplier||1));return E(xt[Math.min(xt.length-1,Math.max(0,(Z<0?2:Z)+Number(Y.getAttribute("data-font-step"))))])}}}),N.addEventListener("keydown",j=>k(j,N,w)),N}function C(){if(!u)return;u.querySelectorAll("[data-setting]").forEach(N=>N.checked=!!i[N.getAttribute("data-setting")]&&i[N.getAttribute("data-setting")]!==!1);let T=u.querySelector('[data-setting="showSkipLinks"]');T&&(T.checked=i.showSkipLinks!==!1);let R=Number(i.fontSizeMultiplier||1);u.querySelector("[data-font-value]").textContent=`${Math.round(R*100)}%`,u.querySelectorAll("[data-font]").forEach(N=>N.setAttribute("aria-pressed",String(Math.abs(Number(N.getAttribute("data-font"))-R)<.001))),u.querySelector("[data-colorblind]").value=i.colorBlindMode||"none";let G=/(\d+) fixes applied/.exec(d);u.querySelector("[data-status]").textContent=G?`${G[1]} automatic accessibility fix(es) applied on this page.`:d}function E(T){xt.some(R=>Math.abs(R-T)<.001)&&(S({fontSizeMultiplier:T},!0),re(`Text size ${Math.round(T*100)} percent`))}function k(T,R,G){if(T.key==="Escape"){T.preventDefault(),T.stopPropagation(),G();return}if(T.key!=="Tab")return;let N=Array.from(R.querySelectorAll("button,input,select,textarea,[tabindex]:not([tabindex='-1'])")).filter(F=>!F.disabled&&F.offsetParent!==null);N.length&&(T.shiftKey&&document.activeElement===N[0]?(T.preventDefault(),N[N.length-1].focus()):!T.shiftKey&&document.activeElement===N[N.length-1]&&(T.preventDefault(),N[0].focus()))}function h(){l||I(),!u&&(x(),b=document.activeElement,u=m(),$().appendChild(u),l.setAttribute("aria-expanded","true"),C(),u.querySelector("[data-close]").focus(),document.addEventListener("pointerdown",v,!0))}function w(){u&&(u.remove(),u=null,l.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",v,!0),(b&&document.contains(b)?b:l).focus())}function v(T){u&&!u.contains(T.target)&&!o.contains(T.target)&&w(),p&&!p.contains(T.target)&&!o.contains(T.target)&&x()}function L(T){if(l||I(),p){T&&f&&f.select(T);return}w(),b=document.activeElement;let R=W("yv-tools-title");p=c("section",{class:"yv-dialog yv-wide",role:"dialog","aria-modal":"false","aria-labelledby":R,"data-yuktai-panel":""});let G=c("div",{class:"yv-dialog-body"});p.append(c("header",{class:"yv-dialog-head"},c("h2",{id:R},t.toolsTitle||"Page tools"),c("button",{type:"button",class:"yv-btn yv-icon","aria-label":"Close page tools",html:de("close"),onclick:()=>x()})),G),$().appendChild(p),f=rn(G,{defaultTab:T||t.defaultTab||"qa",voiceLang:t.voiceLang,generate:t.generate,summarize:t.summarize,defaultLang:t.defaultLang,getSettings:()=>({...i}),applySettings:N=>S(N,!0)}),s&&s.setAttribute("aria-expanded","true"),p.addEventListener("keydown",N=>k(N,p,x)),p.querySelector("[role=tab][aria-selected=true]").focus(),document.addEventListener("pointerdown",v,!0)}function x(){p&&(f&&f.destroy(),f=null,p.remove(),p=null,s&&s.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",v,!0),(b&&document.contains(b)?b:s||l).focus())}let $=()=>document.documentElement||document.body;function I(){!Fe()||l||!document.body||(tn(r,n),o=c("div",{class:"yv-fabs","data-yuktai-fabs":""}),l=c("button",{type:"button",class:"yv-fab","aria-label":"Accessibility settings",title:"Accessibility settings","aria-haspopup":"dialog","aria-expanded":"false",html:de("accessibility",26)}),l.addEventListener("click",()=>u?w():h()),o.append(l),t.showPageTools&&(s=c("button",{type:"button",class:"yv-fab yv-fab-alt","aria-label":"Page tools: QA, forms, design, ask, voice",title:"Page tools","aria-haspopup":"dialog","aria-expanded":"false",html:de("tools",24)}),s.addEventListener("click",()=>p?x():L()),o.prepend(s)),$().appendChild(o),t.applyOnLoad!==!1&&S({},!0))}return{init:I,open:h,close:w,openTools:L,closeTools:x,apply:T=>S(T||{}),reset:y,getSettings:()=>({...i}),destroy(){w(),x(),o&&o.remove(),l=s=o=null}}}var vo="5.2.0";(function(){if(!Fe()||window.yuktai&&window.yuktai.__vanillaInitialized)return;let t=window.YUKTAI_CONFIG||{},n=en(t.primaryColor,"#0f766e"),r=t.position==="right"?"right":"left",a=yo(t),i=()=>tn(n,r),o=s=>(...u)=>(i(),s(...u)),l={__vanillaInitialized:!0,version:vo,init:()=>a.init(),open:()=>a.open(),close:()=>a.close(),openTools:s=>a.openTools(s),closeTools:()=>a.closeTools(),apply:s=>a.apply(s),reset:()=>a.reset(),getSettings:()=>a.getSettings(),renderGrid:o(ho),mountAgenticGridBar:o(nn),mountAgenticPanel:o(rn),mountGridAssistant:o(or),createAgenticGrid:Zt,createGridAgent:Jt,parseGridIntent:Zn,registerWebMCP:Xt,icon:de,iconNames:uo.slice(),...Jn,runPageQA:()=>be().summary,getCapabilities:()=>({version:vo,inlineSVG:!0,grid:!0,gridAssistant:!0,agenticGrid:!0,ruleBasedBI:!0,taskRunner:!0,anomalyChecks:!0,pageQA:!0,a11yCopilot:!0,formsReview:!0,designReview:!0,pageQandA:!0,localPageSearch:!0,voiceCommands:!0,voice:!!(window.SpeechRecognition||window.webkitSpeechRecognition),speech:"speechSynthesis"in window,webMCP:!!(document.modelContext&&typeof document.modelContext.registerTool=="function"),modelConnected:!1})};window.yuktai=l,t.autoInit!==!1&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>a.init(),{once:!0}):a.init())})();})();
|