@yuktishaalaa/yuktai 5.2.0 → 5.3.1
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 +923 -738
- package/dist/chunk-RQKKMYGR.mjs +1 -0
- package/dist/icons.d.mts +201 -0
- package/dist/icons.d.ts +201 -0
- package/dist/icons.js +1 -0
- package/dist/icons.mjs +1 -0
- package/dist/index.d.mts +3 -34
- package/dist/index.d.ts +3 -34
- package/dist/index.js +59 -59
- package/dist/index.mjs +24 -24
- package/dist/renderer.global.js +18 -18
- package/package.json +120 -84
- package/vanilla/README.md +162 -0
- package/vanilla/index.js +6857 -0
- package/vanilla/index.min.js +543 -0
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
/*! yuktai vanilla 5.3.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 Go=Object.defineProperty;var Oo=(e,t)=>{for(var n in t)Go(e,n,{get:t[n],enumerable:!0})};var er={};Oo(er,{AUDIT_RULES:()=>tt,DEFAULT_A11Y_SETTINGS:()=>at,FONT_MAX:()=>Jn,FONT_MIN:()=>Yn,FONT_STEP:()=>Jt,accessibleName:()=>he,aggregate:()=>He,analyzePage:()=>Gn,answerGridQuestion:()=>Nt,applyGridFilters:()=>Re,askAboutPage:()=>Ht,askInsight:()=>Pt,auditToJSON:()=>zt,auditToMarkdown:()=>wt,clearFilters:()=>xn,clearSort:()=>An,comparePeriods:()=>Mn,contrastRatio:()=>et,countGrid:()=>bn,createA11yCopilot:()=>qt,createContextIndex:()=>Bt,createGridTools:()=>Ze,createVoiceA11yController:()=>Xt,detectAnomalies:()=>ze,detectPageIntent:()=>On,executeGridQuery:()=>Ee,filterGrid:()=>wn,findMentionedColumn:()=>ge,getColumns:()=>yn,getRow:()=>vn,getRowId:()=>ee,gridPassages:()=>zn,groupBy:()=>Ln,highlightRows:()=>Xe,moveGridRowFocus:()=>Zn,openRow:()=>ht,pagePassages:()=>Dn,parseAmount:()=>bt,parseColor:()=>Ne,parseGridQuery:()=>Ie,parseVoiceA11yCommand:()=>Xn,planTasks:()=>yt,readFormFields:()=>Fn,relativeLuminance:()=>Ot,reviewDesign:()=>_t,reviewForm:()=>Pn,reviewForms:()=>nt,runGridQuery:()=>$n,runQaAudit:()=>be,runTasks:()=>Gt,searchGrid:()=>hn,selectRow:()=>ft,sortGrid:()=>kn,summarizeRows:()=>qe,toGridToolColumns:()=>Me,tokenize:()=>rt,trend:()=>In,wcagPlugin:()=>_e});var Do={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 Do[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 xr=["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 kr(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 Ar(e){if(e instanceof Date)return e.getTime();let t=new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null}function Tr(e){return(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>String(n).trim()).filter(Boolean)}function fn(e,t){let n=De(t);return e.columns.find(r=>De(r.key)===n||De(r.label)===n)}function Mt(e,t){return e.data.find(n=>ee(n,e.rowKey)===t)}function zo(e,t){return e[t]}function qo(e,t,n){let r=zo(e,n.key),a=n.type??"text";if(a==="number"||a==="date"){let l=a==="number"?kr:Ar,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 Ho(e,t){let n=t.type??"text",r=n==="date"?Ar:kr;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?Sr({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 Sr(e,t){return e.data.filter(n=>t.every(r=>{let a=fn(e,r.key);return a?qo(n,r,a):!0}))}function hn(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 bn(e){return xe(fe(e).count(e.data.length),e.data.length)}function yn(e){return xe(fe(e).columns,e.columns)}function vn(e,t){let n=fe(e),r=String(t??"").trim();if(!r)return Q("INVALID_INPUT",n.noIds);let a=Mt(e,r);return a?xe(n.rowFound,a):Q("NOT_FOUND",n.notFound(r))}function Xe(e,t){let n=fe(e),r=Tr(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=>Mt(e,i)!==void 0);return a.length===0?Q("NOT_FOUND",n.noneFound):(e.onHighlightRows(a),xe(n.highlighted(a.length),a))}function ft(e,t){let n=fe(e),r=String(t??"").trim();return r?e.onSelectRow?Mt(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 ht(e,t){let n=fe(e),r=String(t??"").trim();return r?e.onOpenRow?Mt(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 wn(e,t){let n=fe(e),r=fn(e,(t==null?void 0:t.key)??"");if(!r)return Q("INVALID_INPUT",n.unknownColumn(String((t==null?void 0:t.key)??"")));if(!xr.includes(t.operator))return Q("INVALID_INPUT",n.badOperator(String(t.operator)));let a={...t,key:r.key};if(!Ho(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=Sr(e,i).length;return e.onFiltersChange(i),xe(n.filtered(o),{filters:i,count:o})}function xn(e){let t=fe(e);return e.onFiltersChange?(e.onFiltersChange([]),xe(t.filtersCleared,[])):Q("NOT_SUPPORTED",t.notSupported("clear filters"))}function kn(e,t,n="asc"){let r=fe(e),a=fn(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 An(e){let t=fe(e);return e.onSortChange?(e.onSortChange(null),xe(t.sortCleared,null)):Q("NOT_SUPPORTED",t.notSupported("clear sort"))}var Bo={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."},wr={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 _o(e,t){try{return t()}catch{return Q("INTERNAL",fe(e).internal)}}function Ze(e,t={}){let n=t.name??"yuktai_grid",r=wr[e.locale??"en"],a=s=>{var u;return((u=t.descriptions)==null?void 0:u[s])??Bo[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=>hn(e,String(s.query??""))},{id:"count",available:!0,schema:{type:"object",properties:{}},run:()=>bn(e)},{id:"columns",available:!0,schema:{type:"object",properties:{}},run:()=>yn(e)},{id:"get_row",available:!0,schema:{type:"object",properties:i,required:["id"]},run:s=>vn(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=>Xe(e,Tr(s.ids))},{id:"select",available:!!e.onSelectRow,schema:{type:"object",properties:i,required:["id"]},run:s=>ft(e,String(s.id??""))},{id:"open",available:!!e.onOpenRow,schema:{type:"object",properties:i,required:["id"]},run:s=>ht(e,String(s.id??""))},{id:"filter",available:!!e.onFiltersChange,schema:{type:"object",properties:{key:{type:"string",enum:o},operator:{type:"string",enum:xr},value:{description:"Text or number; for 'between' an array of two numbers or dates"}},required:["key","operator","value"]},run:s=>wn(e,{key:String(s.key??""),operator:String(s.operator??""),value:s.value})},{id:"clear_filters",available:!!e.onFiltersChange,schema:{type:"object",properties:{}},run:()=>xn(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=>kn(e,String(s.key??""),s.direction==="desc"?"desc":"asc")},{id:"clear_sort",available:!!e.onSortChange,schema:{type:"object",properties:{}},run:()=>An(e)}].filter(s=>s.available).map(s=>({name:`${n}_${s.id}`,title:wr.en[s.id],description:a(s.id),label:r[s.id],inputSchema:s.schema,execute:u=>_o(e,()=>s.run(u??{}))}))}var Se=e=>String(e??"").normalize("NFC").toLowerCase().replace(/\s+/g," ").trim(),Vo=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 bt(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 Rr(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 Rr(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 Wo=/amount|balance|total|price|salary|value|due|revenue|cost|fee|sales|outstanding|paid/i;function Tn(e){let t=e.filter(n=>n.type==="number");return t.find(n=>Wo.test(`${n.key} ${n.label}`))??t[0]}var It=/(>=|=>|>|\bover\b|\babove\b|\bmore than\b|\bgreater than\b|\bexceeds?\b|\bexceeding\b|\bhigher than\b|\bat least\b|\bminimum\b|\bmin\b|కంటే ఎక్కువ)/,Sn=/(<=|=<|<|\bunder\b|\bbelow\b|\bless than\b|\blower than\b|\bat most\b|\bmaximum\b|\bmax\b|\bup to\b|కంటే తక్కువ)/,Cr=/\b(after|since|from)\b/,jo=/\b(before|until|till)\b/,Uo="(?:\\s*(?:k|thousand|lakhs?|lacs?|crores?|cr|mn|million|m|bn|billion))?",Cn=`(?:\u20B9|rs\\.?\\s*|\\$)?\\s*-?\\d[\\d,]*(?:\\.\\d+)?${Uo}`;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)??Tn(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+(${Cn}|\\d{4}-\\d{2}-\\d{2})\\s+(?:and|to|-)\\s+(${Cn}|\\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")??Tn(t),E=m?p[1]:bt(p[1]),k=m?p[2]:bt(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(Cn,"u")),k=y.match(/\d{4}-\d{2}-\d{2}/);if(k&&(Cr.test(y)||jo.test(y)||It.test(y)||Sn.test(y))){let h=((C==null?void 0:C.type)==="date"?C:void 0)??t.find(w=>w.type==="date");if(h){let w=Cr.test(y)||It.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&&(It.test(y)||Sn.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=Tn(t),h&&r.notes.push(`Assumed "${y}" refers to ${h.label}.`));let w=bt(E[0]);if(h&&w!==null){let v=/at least|minimum|\bmin\b|>=|=>|at most|maximum|\bmax\b|up to|<=|=</.test(y);It.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")}`)):Sn.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=>!Vo.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=>Rr(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 Ko(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*Ko(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 $n(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 $r(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 ze(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=$r(f,.25),d=$r(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 qe(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 Nt(e,t){var a;let n=Se(e);if(/unusual|anomal|outlier|odd|strange|suspicious|duplicate|అసాధారణ/.test(n)){let i=ze(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:qe(i,t.columns),ids:[],rows:i}}let r=$n(e,t);return{kind:"query",message:r.message,ids:r.ids,rows:r.rows}}var Ft=e=>{let t=typeof e=="number"?e:Number(String(e??"").replace(/[,₹$%\s]/g,""));return Number.isFinite(t)?t:null},Er=e=>{let t=e instanceof Date?e.getTime():new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null};function He(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 Ln(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=Ft(i[n]);s!==null&&l.push(s)}a.set(o,l)}return Array.from(a.entries()).map(([i,o])=>({group:i,value:He(o,r),count:o.length})).sort((i,o)=>o.value-i.value)}function Lr(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 En(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 Mn(e,t){let n=t.referenceDate?new Date(t.referenceDate):new Date,r=Lr(n,t.period,t.weekStartsOn),a=t.toDate===!1?En(r,t.period,1):new Date(Math.max(n.getTime()+1,r.getTime()+1)),i=En(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=Er(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:Ft(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=He(s.get(b)??[],l),S=He(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 In(e,t,n,r,a="sum"){let i=new Map;for(let o of e){let l=Er(o[t]),s=a==="count"?1:Ft(o[n]);if(l===null||s===null)continue;let u=Lr(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:He(l,a)}))}var Qo=/rate|conversion|ratio|percent|%|score|rating|margin|ctr|avg|average/i;function Yo(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}),Rn=e=>e===null?"new":`${e>0?"+":""}${e.toFixed(1)}%`;function Pt(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&&Qo.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=Yo(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?En(h,y.period,y.shift):h,L=[...Mn(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,H)=>b?F.change-H.change:H.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 %":Rn(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)}, ${Rn($.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=In(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 (${Rn(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=Ln(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=>Ft(h[o.key])).filter(h=>h!==null),E=He(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 Nr="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 yt(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+(?=(?:${Nr})\\b)`,"i"))).map(r=>r.trim()).filter(r=>r.length>1).map(r=>({action:Jo(r),text:r}))}function Jo(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 Xo(e){return e.replace(new RegExp(`^\\s*(?:${Nr}|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 Mr(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 Gt(e,t,n={}){var y,m,C,E,k,h,w,v,L;let r=yt(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=Xo($.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(H=>H.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 H=Xe(d(),F);H.success&&(u=H.data??F),T={...$,success:H.success,message:H.success?`Highlighted ${u.length} row(s)${I?` matching "${I}"`:""}.`:H.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=ze(R,a,{rowKey:t.rowKey}),N=Array.from(new Set(G.map(F=>F.rowId)));if(N.length){let F=Xe(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),H=$.action==="open"?ht(d(),F):ft(d(),F);T={...$,success:H.success,message:H.message,ids:[F]};break}case"summarize":{let R=p();T={...$,success:!0,message:`${Ir(f,R.length,o,s,u,a)}
|
|
8
|
+
${qe(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:Ir(f,S,o,s,u,a)}}function Ir(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=>Mr(p,i)).join("; ")}.`),s.length&&o.push(`Filters removed: ${s.map(p=>Mr(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 Zo="[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(Zo)&&(n.includeHidden||ei(r)))}function ei(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 ti(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=ti(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="${ni(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 ni(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function Ne(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 Nn(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 Ot(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 et(e,t){let n=t.a<1?Nn(t,{r:255,g:255,b:255,a:1}):t,r=e.a<1?Nn(e,n):e,a=Ot(r),i=Ot(n),[o,l]=a>i?[a,i]:[i,a];return Math.round((o+.05)/(l+.05)*100)/100}function Fr(e){let t=[],n=e;for(;n;){let a=window.getComputedStyle(n);if(a.backgroundImage&&a.backgroundImage!=="none")return null;let i=Ne(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=Nn(t[a],r);return r}function Pr(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 vt(e){return Array.from(e.childNodes).some(t=>t.nodeType===3&&te(t.textContent).length>0)}var Gr="a[href],button,input:not([type='hidden']),select,textarea,summary,[tabindex]:not([tabindex='-1']),[contenteditable='true']",Dt="a[href],button,input:not([type='hidden']),select,textarea,summary,[role='button'],[role='link'],[role='checkbox'],[role='tab'],[role='menuitem']";var tt={"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."}},ri={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=tt[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(!vt(m)||["SCRIPT","STYLE","NOSCRIPT","OPTION"].includes(m.tagName))continue;S++;let C=Ne(window.getComputedStyle(m).color),E=Fr(m);if(!C||!E)continue;let k=et(C,E),h=Pr(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,Dt)){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 oi(r,i,n)}function oi(e,t,n){var s;let r=Object.keys(tt).filter(u=>!n.has(u)).map(u=>{let p=e.filter(f=>f.rule===u).length;return{rule:u,title:tt[u].title,passed:p===0,issueCount:p}}),a=0;for(let u of r){let p=ri[tt[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 wt(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 zt(e){return JSON.stringify({...e,issues:e.issues.map(({element:t,...n})=>n)},null,2)}function qt(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 ii=/^(field|input|value|text|enter|details?|info|data|\*|:)$/i,ai=/^(go|ok|submit|send|click here|>|→|next)$/i,si=[[/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 li(e){let t=e.getAttribute("id");return t&&e.ownerDocument.querySelector(`label[for="${t.replace(/"/g,'\\"')}"]`)?!0:!!e.closest("label")}function Fn(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:li(t),selector:Ce(t),element:t}))}function Pn(e,t={}){var b;let n=t.seniorFriendly!==!1,r=t.maxFieldsPerStep??8,a=Fn(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):ii.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 si)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]));ai.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 nt(e={}){let t=me(e.root);return t?z(t,"form,[role='form']").map(n=>Pn(n,e)):[]}function Gn(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=ci(u,o),u}function ci(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 ui=[["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 On(e){for(let[t,n]of ui)if(n.test(e))return t;return"unknown"}async function Ht(e,t={}){var a;let n=Gn(t.root),r=On(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=nt({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 di=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 rt(e){return(e.normalize("NFC").toLowerCase().match(/[\p{L}\p{M}\p{N}]+/gu)??[]).filter(t=>t.length>1&&!di.has(t))}function Dn(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 zn(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 Bt(e={}){let t=[],n=[],r=new Map,a=0;function i(){t=[...e.includePage===!1?[]:Dn(e.root),...e.rows&&e.columns?zn(e.rows,e.columns,e.rowKey):[],...(e.documents??[]).map(s=>({id:s.id,source:"custom",text:s.text}))],n=t.map(s=>rt(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=rt(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(rt(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:rt(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 Or={high:12,medium:6,low:2};function _t(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(!vt(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 H=parseFloat(R.lineHeight);if(Number.isFinite(H)&&H/G<1.3){r("readability","low",`Line height is ${(H/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=pi();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,Dt).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,Gr).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(!vt(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+Or[f.severity]*2,0)),findings:u.length},l},{}),i=Math.max(0,100-n.reduce((l,s)=>l+Or[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 pi(){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 Dr(){var t;let e=window;return e.Rewriter||((t=e.ai)==null?void 0:t.rewriter)||null}async function qn(){try{let e=Dr();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 gi(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=Dr();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 zr(){var r;if(!await qn())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 gi(i);o.success&&o.rewritten!==i&&(a.dataset.yuktaiOriginal=i,a.innerText=o.rewritten,n++)}return{fixed:n}}function qr(){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 Hr="yuktai-summary-box";function Br(){var t;let e=window;return e.Summarizer||((t=e.ai)==null?void 0:t.summarizer)||null}async function Hn(){try{let e=Br();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 mi(){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 _r(){if(!await Hn())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=mi();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let n=Br();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(),fi(a.trim()),{success:!0,summary:a.trim()}}catch(n){return{success:!1,summary:"",error:n instanceof Error?n.message:"Summary failed"}}}function fi(e){Vt();let t=document.createElement("div");t.id=Hr,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",Vt),t.appendChild(n),t.appendChild(r),document.body.prepend(t)}function Vt(){let e=document.getElementById(Hr);e&&e.remove()}var Vr=[{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"}],Wt="en";function hi(){let e=window;return e.Translator||e.translation||null}async function bi(e){try{let t=window;if(!hi())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 yi(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 Wr(e){var n;if(e===Wt)return{success:!0,language:e,fixed:0};if(e==="en")return Bn(),Wt="en",{success:!0,language:"en",fixed:0};if(!await bi(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let r=await yi(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(),Wt=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 Bn(){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)}Wt="en"}var vi=[{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,jt=!1,ot=null;function _n(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function wi(e){let t=e.toLowerCase().trim();for(let n of vi)for(let r of n.phrases)if(t.includes(r))return{action:n.action,label:n.label};return null}function xi(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=jr(),n=t.indexOf(document.activeElement),r=t[n+1]||t[0];r&&r.focus();break}case"tab-back":{let t=jr(),n=t.indexOf(document.activeElement),r=t[n-1]||t[t.length-1];r&&r.focus();break}case"stop-voice":{Vn();break}}}function jr(){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 Ur(e){if(!_n())return!1;if(jt)return!0;e&&(ot=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=wi(r);if(a){xi(a.action);let i={success:!0,command:r,action:a.label};if(ot&&ot(i),a.action==="stop-voice")return}},ce.onend=()=>{jt&&(ce==null||ce.start())},ce.onerror=n=>{n.error!=="no-speech"&&ot&&ot({success:!1,command:"",action:"",error:`Voice error: ${n.error}`})},ce.start(),jt=!0,ki(),!0}function Vn(){jt=!1,ce&&(ce.stop(),ce=null),ot=null,Qr()}var Kr="yuktai-voice-indicator";function ki(){Qr();let e=document.createElement("div");e.id=Kr,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 Qr(){let e=document.getElementById(Kr);e&&e.remove()}var Ai=["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 Yr(){var t;let e=window;return e.Writer||((t=e.ai)==null?void 0:t.writer)||null}async function Wn(){try{let e=Yr();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 Ti(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 Si(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 Jr(){if(!await Wn())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(Ai);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let n=Yr();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=Ti(o),u=await Si(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 Xr(){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 Qt=null,Zr=null;var eo=null,jn=null,X=null,it=null,Ut=null,Un=null,ue=null,Kt={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var to=new Set(["input","select","textarea"]);var Kn={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function Qn(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 co(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:"#005A9C",border:"#003F6E",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){Qt&&(Qt.textContent=e),co(e,t),n&&Qn(e,t==="error"?"assertive":"polite")}function Ci(){if(typeof document>"u"||eo)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: #001124;
|
|
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: #005A9C;
|
|
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),eo=t}function $i(){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 Ri(){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(),Ei()),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();Qn(`${f}, ${b}`)},100)}))}function Yt(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 Ei(){if(typeof document>"u")return;if(it){it.remove(),it=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(),it=null}),e.addEventListener("keydown",r=>{r.key==="Escape"&&(e.remove(),it=null)}),document.body.appendChild(e),it=e,Yt(e),V("Keyboard shortcuts opened. Press Escape to close.","info")}function Li(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;jn&&jn.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",()=>Mi(e)),document.body.appendChild(a),jn=a}function Mi(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),Yt(n)}function uo(e){typeof document>"u"||(Un&&clearTimeout(Un),Un=setTimeout(()=>{if(Ut)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(),Ut=null,V("Session extended. You have more time.","success"),ue!=null&&ue.timeoutWarning&&uo(ue.timeoutWarning)}),r==null||r.addEventListener("click",()=>{t.remove(),Ut=null}),document.body.appendChild(t),Ut=t,Yt(t),V("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function Ii(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(#${Kt[e.colorBlindMode]})`;document.body.style.filter=n}else document.body.style.filter=""}function Ni(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function no(e){if(e){if(!await qn()){V("Plain English requires Chrome 127+","warning");return}V("Rewriting page in plain English...","info",!1);let n=await zr();V(n.error?`Plain English failed: ${n.error}`:`${n.fixed} sections rewritten in plain English`,n.error?"error":"success",!1)}else qr(),V("Original text restored","info",!1)}async function ro(e){if(e){if(!await Hn()){V("Page summariser requires Chrome 127+","warning");return}V("Generating page summary...","info",!1);let n=await _r();V(n.error?`Summary failed: ${n.error}`:"Page summary added at top",n.error?"error":"success",!1)}else Vt(),V("Page summary removed","info",!1)}async function oo(e){if(e==="en"){Bn(),V("Page restored to English","info",!1);return}V(`Translating page to ${e}...`,"info",!1);let t=await Wr(e);V(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function io(e){if(e){if(!_n()){V("Voice control not supported in this browser","warning");return}Ur(t=>{t.success&&V(`Voice: ${t.action}`,"info",!1)}),V("Voice control started. Say a command.","success",!1)}else Vn(),V("Voice control stopped","info",!1)}async function ao(e){if(e){if(!await Wn()){V("Smart labels requires Chrome 127+","warning");return}V("Generating smart labels...","info",!1);let n=await Jr();V(n.error?`Smart labels failed: ${n.error}`:`${n.fixed} elements labelled`,n.error?"error":"success",!1)}else Xr(),V("Smart labels removed","info",!1)}function Fi(){if(typeof document>"u"||Qt)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),Qt=e}function Pi(){if(typeof document>"u"||Zr)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="${Kt.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="${Kt.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="${Kt.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),Zr=e}function so(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 lo(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 _e={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";ue=e,Ni(e),Fi(),Pi(),$i(),Ri(),e.showSkipLinks!==!1&&Ci(),e.showPreferencePanel,Ii(e);let t=this.applyFixes(e);t.score=lo(t),e.showAuditBadge&&Li(t),e.timeoutWarning&&uo(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await no(!0),e.summarisePage&&await ro(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await oo(e.translateLanguage),e.voiceControl&&await io(!0),e.smartLabels&&await ao(!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(!so(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;so(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(to.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']"));Kn[l]&&!o.getAttribute("role")&&!s&&(o.setAttribute("role",Kn[l]),a(l,`role="${Kn[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),to.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=lo(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:Qn,showVisualAlert:co,trapFocus:Yt,handlePlainEnglish:no,handleSummarisePage:ro,handleTranslate:oo,handleVoiceControl:io,handleSmartLabels:ao,SUPPORTED_LANGUAGES:Vr};var Gi=/\b(off|disable|stop|remove|no more|turn off|switch off|deactivate)\b|ఆఫ్|ఆపు|తీసివేయి|बंद/i,Oi=[{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"}],Di=[[/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"]],Jt=.1,Yn=.8,Jn=1.3;function Xn(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(Jn,Math.max(Yn,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+Jt);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-Jt);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=Gi.test(n);for(let[o,l]of Di)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 Oi){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 at={highContrast:!1,darkMode:!1,reduceMotion:!1,largeTargets:!1,dyslexiaFont:!1,speechEnabled:!1,colorBlindMode:"none",fontSizeMultiplier:1};function Zn(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 Xt(e={}){let t={enabled:!0,...at,...e.initial},n=null,r=!1,a=async u=>e.apply?e.apply(u):_e.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=Xn(u,t);if((f=e.onTranscript)==null||f.call(e,u,p),!p)return null;if(p.type==="grid"){let b=Zn(p.action,{root:e.gridRoot});return i(b?p.say:"No table rows found."),p}return t=p.type==="reset"?{...t,...at}:{...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 mo(){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 tr=e=>e instanceof Error?e:new Error(String(e)),zi={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."}},po=e=>String(e??"").normalize("NFC").toLowerCase().trim(),Fe={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 qi(e,t){let n=po(e),r=null;for(let a of t)for(let i of[a.label,a.key]){let o=po(i);o&&n.includes(o)&&(!r||o.length>r.len)&&(r={key:a.key,len:o.length})}return r?r.key:null}function nr(e,t){let n=String(e??"").trim();if(!n)return null;let r=t&&t.columns||[];if(Fe.clearFilters.test(n))return{kind:"tool",tool:"clear_filters",input:{}};if(Fe.clearSort.test(n))return{kind:"tool",tool:"clear_sort",input:{}};if(Fe.count.test(n))return{kind:"tool",tool:"count",input:{}};if(Fe.sort.test(n)){let o=qi(n,r);return o?{kind:"tool",tool:"sort",input:{key:o,direction:Fe.desc.test(n)?"desc":"asc"}}:null}let a=n.match(Fe.openEn)||n.match(Fe.openTe);if(a&&a[1])return{kind:"open",text:a[1].trim()};let i=n.replace(Fe.searchFiller,"").trim();return i?{kind:"tool",tool:"search",input:{query:i}}:null}function Hi(e){return!!e&&typeof e=="object"&&typeof e.success=="boolean"&&typeof e.message=="string"}function Bi(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 _i(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 go=e=>String(e??"").normalize("NFC").trim().toLocaleLowerCase();function Vi(e,t){let n=go(e);return(t||[]).find(r=>(r.phrases||[]).some(a=>{let i=go(a);return i.length>0&&n.includes(i)}))}function Zt(e={}){let t=E=>typeof E=="function"?E():E,n={locale:"en",rowKey:"id",historyLimit:20,customRules:[],...e},r=mo(),a=0,i=null,o=null,l=[],s=0,u=()=>zi[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=_i(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=Bi(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),$=Hi(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=tr(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=Vi(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=tr($),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||nr)(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 en(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:tr(p).message})}}o.signal.aborted||r({state:s.length===0?"ready":l.length?"partial":"error",registered:l,errors:s})})(),a)}var Wi=/\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,ji={filters:[],search:[],sort:null,limit:null,notes:[],explanation:""};function tn(e={}){let t=mo(),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,{...ji,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(yt(T).length>1){let R=[],G=await Gt(T,v(),{onStep:N=>{R.push(N),p=R.slice(),w()}});s="tasks",l=G.summary}else if(Wi.test(T)){let R=Re(y(),i,b()),G=Pt(T,R,i,{referenceDate:e.referenceDate});s="insight",l=G.answer,u=G.table||[]}else{let R=Nt(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 st={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"/>'},ss=Object.keys(st);var Ui=3,rr="#ffffff",fo="#111827";function xt(e,t){let n=Ne(e),r=Ne(t);return n&&r?et(n,r):null}function or(e){let t=xt(rr,e),n=xt(fo,e);return t===null||n===null||t>=n?rr:fo}var ho=new Set;function Ki(e,t){ho.has(e)||(ho.add(e),typeof console<"u"&&console.warn(`[yuktai icons] ${t}`))}function Qi(e={}){let t=e.variant==="filled"?"filled":"outline",n=e.color||"currentColor";if(t==="outline")return{variant:t,color:n,glyph:n,contrast:null};let r=e.glyphColor||or(n),a=xt(r,n);return a!==null&&a<Ui&&Ki(`${r}|${n}`,`glyph ${r} on ${n} is ${a}:1. WCAG 1.4.11 needs at least 3:1 for icons.`),{variant:t,color:n,glyph:r,contrast:a}}var Yi="translate(3.6 3.6) scale(0.7)",Ji="@media (forced-colors: active){.yi-bg{fill:CanvasText}.yi-glyph{stroke:Canvas}}",Ve=e=>String(e).replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);function bo(e,t={}){let n=st[e]??st.spark,r=t.size??20,{variant:a,color:i,glyph:o}=Qi(t),l=t.strokeWidth??(a==="filled"?2.4:1.9),u=`<svg xmlns="http://www.w3.org/2000/svg" ${t.label?`role="img" aria-label="${Ve(t.label)}"`:'aria-hidden="true"'} focusable="false" width="${Ve(r)}" height="${Ve(r)}" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round" data-variant="${a}">`;if(a==="outline")return`${u}<g stroke="${Ve(i)}" stroke-width="${l}">${n}</g></svg>`;let p=t.shape==="circle"?`<circle class="yi-bg" cx="12" cy="12" r="12" fill="${Ve(i)}"/>`:`<rect class="yi-bg" width="24" height="24" rx="6" fill="${Ve(i)}"/>`;return`${u}<style>${Ji}</style>${p}<g class="yi-glyph" stroke="${Ve(o)}" stroke-width="${l}" transform="${Yi}">${n}</g></svg>`}var Pe=()=>typeof window<"u"&&typeof document<"u";function nn(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 Xi=0,j=(e="yv")=>`${e}-${++Xi}`;function rn(e,t){if(typeof e!="string"||!Pe())return t;let n=document.createElement("span");return n.style.color=e,n.style.color?e:t}var ir=()=>Pe()&&(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.hasAttribute("data-yuktai-reduce-motion")),yo=Object.keys(st);function de(e,t=20,n,r){let a=typeof t=="object"&&t!==null?{...t}:{...r||{},size:t,label:n};return bo(e,a)}function q(e,t,n){let r=document.createElement("span");return r.className="yv-ic",r.innerHTML=de(e,t,n),r}var We=null;function re(e){!Pe()||!e||((!We||!document.contains(We))&&(We=c("div",{id:"yuktai-vanilla-live",class:"yv-sr",role:"status","aria-live":"polite","aria-atomic":"true"}),document.body.appendChild(We)),We.textContent="",setTimeout(()=>{We&&(We.textContent=String(e).slice(0,300))},30))}function kt(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 vo(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 ar(e){let t=String(e??"");return/^[=+\-@\t\r]/.test(t)&&(t="'"+t),'"'+t.replace(/"/g,'""')+'"'}function wo(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:ir()?"auto":"smooth"}),t.length}function on(e,t){if(!Pe()||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:#E8F1F8;--yv-accent-text:#003F6E;--yv-hl-bg:#fef3c7;--yv-hl-edge:#b45309;--yv-sel-bg:#EEF5FB}
|
|
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:#0B2A4A;--yv-accent-text:#DCEBFA;--yv-hl-bg:#4a3a0c;--yv-hl-edge:#fbbf24;--yv-sel-bg:#12304f}
|
|
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:#fff;color:var(--yv-primary);border-color:var(--yv-primary)}
|
|
514
|
+
.yv-fab:hover{filter:brightness(1.08)}
|
|
515
|
+
.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}
|
|
516
|
+
.yv-dialog.yv-wide{width:min(620px,calc(100vw - 24px))}
|
|
517
|
+
.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)}
|
|
518
|
+
.yv-dialog-head h2{margin:0;font-size:1.1em}
|
|
519
|
+
.yv-dialog-body{padding:12px 16px 16px}
|
|
520
|
+
.yv-dialog .yv-box{border:0;padding:0}
|
|
521
|
+
.yv-option{display:flex;align-items:center;gap:12px;padding:8px 0;border-bottom:1px solid var(--yv-border)}
|
|
522
|
+
.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)}
|
|
523
|
+
.yv-option-copy{flex:1;min-width:0}
|
|
524
|
+
.yv-option-copy b{display:block;font-size:.95em}
|
|
525
|
+
.yv-option-copy small{display:block;color:var(--yv-muted);font-size:.8em}
|
|
526
|
+
.yv-switch{position:relative;display:inline-flex;align-items:center;justify-content:center;min-width:52px;min-height:44px;cursor:pointer}
|
|
527
|
+
.yv-switch input{position:absolute;inset:0;width:100%;height:100%;opacity:0;margin:0;cursor:pointer}
|
|
528
|
+
.yv-switch span{position:relative;pointer-events:none;width:44px;height:26px;border-radius:99px;background:#64748b;transition:background .15s}
|
|
529
|
+
.yv-switch span::after{content:"";position:absolute;top:3px;left:3px;width:20px;height:20px;border-radius:50%;background:#fff;transition:transform .15s}
|
|
530
|
+
.yv-switch input:checked+span{background:var(--yv-primary)}
|
|
531
|
+
.yv-switch input:checked+span::after{transform:translateX(18px)}
|
|
532
|
+
.yv-switch input:focus-visible+span{outline:3px solid #2563eb;outline-offset:3px}
|
|
533
|
+
.yv-steps-bar{display:flex;gap:4px;flex:1}
|
|
534
|
+
.yv-step{flex:1;min-width:0;height:28px;border:0;border-radius:6px;background:transparent;padding:0;cursor:pointer;position:relative}
|
|
535
|
+
.yv-step::after{content:"";position:absolute;left:0;right:0;top:10px;height:8px;border-radius:8px;background:#cbd5e1}
|
|
536
|
+
.yv-step[aria-pressed=true]::after{background:var(--yv-primary)}
|
|
537
|
+
.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}
|
|
538
|
+
.yv-status:empty{display:none}
|
|
539
|
+
@media (max-width:560px){.yv-dialog{${t}:8px;width:calc(100vw - 16px)}.yv-toolbar{align-items:stretch}.yv-search{flex-basis:100%}}
|
|
540
|
+
@media (prefers-reduced-motion:reduce){.yv-switch span,.yv-switch span::after{transition:none}}
|
|
541
|
+
`,document.head.appendChild(n)}var Zi={query:"Grid query",anomalies:"Anomalies",summary:"Summary",insight:"BI insight",tasks:"Task steps"};function an(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=j("yv-q"),o=j("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?`${Zi[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">${nn(v)}</th>`).join("")}</tr></thead><tbody>${k.table.map(v=>`<tr>${h.map(L=>`<td>${nn(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 ea={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"}}},xo=["default","high-contrast","dark","color-blind","dyslexia"],sr=e=>String(e??"").normalize("NFC").toLowerCase();function ko(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 Ao(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=ea[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=ko(i.columns,E),h=Me(k),w=[],v=null,L="",x=1,$=Number(d&&d.pageSize||i.pageSize)||10,I=xo.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)),H=new Set((i.highlightIds||[]).map(String)),pe={grid:j("yv-grid"),title:j("yv-title"),status:j("yv-status")};S.includes($)||S.push($),S.sort((g,A)=>g-A);let W=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]??W(g)):W(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 St=c("h3",{id:pe.title,class:i.showTitle?"yv-grid-title":"yv-sr"},b);i.showTitle&&(St.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"}),ln=i.search===!1?null:c("label",{class:"yv-search"},q("search",18),Ae),pr=c("span",{class:"yv-info","aria-hidden":"true"}),lt=c("button",{type:"button",class:"yv-btn yv-icon","data-view-toggle":""}),gr=i.exportable===!1?null:c("button",{type:"button",class:"yv-btn"},q("download",16),s.export),$o=c("div",{class:"yv-tools"},T==="auto"||i.viewToggle?lt:null,gr),Ro=c("div",{class:"yv-toolbar"},ln,pr,$o),Le=c("div",{class:"yv-filterbar",hidden:!0,"aria-label":s.filters(0)}),cn=c("div",{class:"yv-slot"}),oe=c("div",{class:"yv-body",id:pe.grid}),Ct=c("div",{class:"yv-pager"}),un=c("p",{class:"yv-sr",id:pe.status,role:"status","aria-live":"polite","aria-atomic":"true"});Z.append(St,Ro,Le,cn,oe,Ct,un),a.appendChild(Z);let dn=null,$t=g=>{clearTimeout(dn),un.textContent="",dn=setTimeout(()=>un.textContent=g,40)};function Eo(g,A,M,P){let O=g[M.key],D=A[M.key];if(O==null||O==="")return D==null||D===""?0:1;if(D==null||D==="")return-1;let _;return M.type==="number"?_=Number(O)-Number(D):M.type==="date"?_=new Date(O).getTime()-new Date(D).getTime():_=String(O).localeCompare(String(D),o,{numeric:!0,sensitivity:"base"}),Number.isFinite(_)||(_=String(O).localeCompare(String(D))),P==="desc"?-_:_}function Ge(){let g=Re(E,h,w);if(L){let A=sr(L);g=g.filter(M=>k.some(P=>sr(M[P.key]).includes(A)||sr(ct(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)=>Eo(M,P,A,v.direction)))}return g}function ct(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 mr(g,A,M){let P=A[g.key];if(g.render)try{let O=g.render(P,A,M);return O instanceof Node?O:document.createTextNode(O==null?"":String(O))}catch(O){return console.error("[yuktai] column render failed",g.key,O),document.createTextNode(ct(g,P))}return g.type==="badge"&&P!=null&&P!==""?c("span",{class:"yv-cellbadge"},String(P)):document.createTextNode(ct(g,P))}let ut=()=>T==="card"||T==="auto"&&G;function je(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=Ge();ye=g;let{pages:A,start:M,end:P}=je(g.length),O=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)),pr.textContent=`${g.length.toLocaleString(p)} ${s.rows}${y?` \xB7 ${F.size.toLocaleString(p)} ${s.selected}`:""}`,lt.innerHTML=de(ut()?"grid":"cards",18),lt.setAttribute("aria-label",ut()?s.tableView:s.cardView),lt.title=ut()?s.tableView:s.cardView,Io();let D=oe.contains(document.activeElement);oe.replaceChildren(R?c("div",{class:"yv-loading",role:"status"},s.loading):ut()?Mo(O,M):Lo(O,M,g.length)),D&&!R&&hr(),No(g.length,A,M,P)}function Lo(g,A,M){let P=k,O=P.length+(y?1:0),D=c("table",{class:"yv-table",role:"grid","aria-labelledby":pe.title,"aria-rowcount":M+1,"aria-colcount":O,"aria-multiselectable":y?"true":null}),_=c("tr",{role:"row","aria-rowindex":1});if(y){let B=g.length>0&&g.every(we=>F.has(W(we))),ve=g.some(we=>F.has(W(we))),J=c("input",{type:"checkbox","data-select-page":"","aria-label":s.selectPage,tabindex:-1});J.checked=B,J.indeterminate=!B&&ve,_.append(c("th",{role:"columnheader",scope:"col","aria-colindex":1,tabindex:-1,"data-col":0},c("label",{class:"yv-check"},J)))}P.forEach((B,ve)=>{let J=ve+(y?1:0),we=v&&v.key===B.key?v.direction:null,Oe=c("th",{role:"columnheader",scope:"col","aria-colindex":J+1,"aria-sort":B.sortable?we==="asc"?"ascending":we==="desc"?"descending":"none":null,class:B.align!=="left"?`yv-align-${B.align}`:null,tabindex:-1,"data-col":J});if(B.width&&(Oe.style.width=typeof B.width=="number"?`${B.width}px`:B.width),B.sortable){let Ye=c("button",{type:"button",class:"yv-sortbtn","data-sort":B.key,tabindex:-1},B.label);Ye.insertAdjacentHTML("beforeend",de(we==="asc"?"sortUp":we==="desc"?"sortDown":"sort",14)),Oe.append(Ye)}else Oe.append(B.label);_.append(Oe)});let ie=c("tbody");if(!g.length){let B=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:O,tabindex:-1,"data-col":0},B)))}g.forEach((B,ve)=>{let J=W(B),we=F.has(J),Oe=H.has(J),Ye=c("tr",{role:"row","aria-rowindex":A+ve+2,"aria-selected":y?String(we):null,"data-yuktai-row-id":J,class:Oe?"yv-hl":null});if(y){let Je=c("input",{type:"checkbox","data-select":J,"aria-label":s.selectRow(Y(B)),tabindex:-1});Je.checked=we,Ye.append(c("td",{role:"gridcell","aria-colindex":1,tabindex:-1,"data-col":0},c("label",{class:"yv-check"},Je)))}P.forEach((Je,yr)=>{let vr=yr+(y?1:0),mn=c("td",{role:"gridcell","aria-colindex":vr+1,tabindex:-1,"data-col":vr,class:Je.align!=="left"?`yv-align-${Je.align}`:null});mn.append(mr(Je,B,A+ve)),yr===0&&Oe&&mn.append(c("span",{class:"yv-sr"},` (${s.highlighted})`)),Ye.append(mn)}),ie.append(Ye)}),D.append(c("thead",null,_),ie);let se=D.querySelectorAll("tr");N.r=Math.min(N.r,se.length-1);let le=fr(D,N.r,N.c)||fr(D,0,0);return le&&le.setAttribute("tabindex","0"),c("div",{class:"yv-tablewrap"},D)}function Mo(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,O)=>{let D=W(P),_=F.has(D),ie=H.has(D),se=j("yv-card"),le=c("li",{class:`yv-card${ie?" yv-hl":""}`,"data-yuktai-row-id":D,"aria-labelledby":se,"aria-selected":y?String(_):null,tabindex:-1}),B=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":D,"aria-label":s.selectRow(Y(P))});J.checked=_,B.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,mr(J,P,A+O)))}),le.append(B,ve),typeof i.onRowClick=="function"&&le.append(c("button",{type:"button",class:"yv-btn yv-small","data-open":D,style:"margin-top:8px"},i.openLabel||(l==="te"?"\u0C24\u0C46\u0C30\u0C41\u0C35\u0C41":"Open"))),M.append(le)}),M}function Io(){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(_=>ct(M||{},_)).join(" \u2013 "):M?ct(M,g.value):String(g.value),O=`${M?M.label:g.key} ${s.ops[g.operator]||g.operator} ${P}`,D=c("button",{type:"button",class:"yv-chip","data-remove-filter":A,"aria-label":s.removeFilter(O)},O,q("close",14));Le.append(D)}),Le.append(c("button",{type:"button",class:"yv-btn yv-small","data-clear-filters":""},s.clearFilters))}function No(g,A,M,P){if(Ct.replaceChildren(),d===!1){Ct.append(c("span",{class:"yv-muted"},s.results(g.toLocaleString(p))));return}let O=se=>se.toLocaleString(p),D=c("span",{class:"yv-muted"},g?s.showing(O(M+1),O(P),O(g)):s.showing(0,0,0)),_=c("div",{class:"yv-pages"});if(d.showSizeChanger!==!1){let se=j("yv-size"),le=c("select",{id:se,"data-page-size":""},...S.map(B=>c("option",{value:B,selected:B===$},String(B))));_.append(c("label",{for:se,class:"yv-muted"},s.pageSize),le)}let ie=(se,le,B,ve)=>{let J=c("button",{type:"button",class:"yv-btn yv-icon","aria-label":le,title:le,disabled:B,"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(O(x),O(A))),ie("right",s.next,x>=A,"next"),ie("last",s.last,x>=A,"last")),Ct.append(D,_)}function fr(g,A,M){let P=g.querySelectorAll("tr")[A];if(!P)return null;let O=P.querySelectorAll("th,td");return O[Math.min(M,O.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 O=P[g].querySelectorAll("th,td");A=Math.max(0,Math.min(A,O.length-1)),M.querySelectorAll('[tabindex="0"]').forEach(_=>_.setAttribute("tabindex","-1"));let D=O[A];D.setAttribute("tabindex","0"),N={r:g,c:A},D.focus()}function hr(){if(oe.querySelector("table"))$e(N.r,N.c);else{let A=oe.querySelector(".yv-card");A&&A.focus()}}function Fo(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,O=Array.prototype.indexOf.call(A.querySelectorAll("tr"),P),D=Array.prototype.indexOf.call(P.querySelectorAll("th,td"),M),_=A.querySelectorAll("tr").length-1,ie=!0;switch(g.key){case"ArrowRight":$e(O,D+1);break;case"ArrowLeft":$e(O,D-1);break;case"ArrowDown":$e(O+1,D);break;case"ArrowUp":$e(O-1,D);break;case"Home":g.ctrlKey?$e(0,0):$e(O,0);break;case"End":g.ctrlKey?$e(_,999):$e(O,999);break;case"PageDown":d!==!1&&(N={r:Math.max(1,O),c:D},Ke(x+1,!0));break;case"PageUp":d!==!1&&(N={r:Math.max(1,O),c:D},Ke(x-1,!0));break;case"Enter":case" ":{let se=M.querySelector("[data-sort]"),le=M.querySelector("input[type=checkbox]");se?br(se.getAttribute("data-sort")):le?le.click():g.key==="Enter"&&P.hasAttribute("data-yuktai-row-id")&&typeof i.onRowClick=="function"?dt(P.getAttribute("data-yuktai-row-id")):g.key===" "&&y&&P.hasAttribute("data-yuktai-row-id")?Po(P.getAttribute("data-yuktai-row-id")):ie=!1;break}default:ie=!1}ie&&(g.preventDefault(),g.stopPropagation())}function br(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(),$t(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 Ue(){i.onSelectionChange&&i.onSelectionChange(Array.from(F)),Z.dispatchEvent(new CustomEvent("yuktai:selection",{detail:{keys:Array.from(F)},bubbles:!0}))}function Po(g,A){(A===void 0?!F.has(g):A)?F.add(g):F.delete(g),U(),Ue()}function Ke(g,A){let{pages:M}=je(ye.length),P=Math.min(Math.max(1,g),M);P===x&&!A||(x=P,U(),$t(s.page(x,M)),A&&oe.querySelector("table")&&hr())}function dt(g){let A=E.find(M=>W(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 pt(g,A=m){if(H.clear(),(g||[]).forEach(M=>H.add(typeof M=="object"&&M!==null?W(M):String(M))),A&&H.size){let M=ye.length?ye.findIndex(P=>H.has(W(P))):Ge().findIndex(P=>H.has(W(P)));M>=0&&d!==!1&&(x=Math.floor(M/$)+1)}if(U(),A&&H.size){let M=oe.querySelector(".yv-hl");M&&M.scrollIntoView&&M.scrollIntoView({block:"nearest",behavior:ir()?"auto":"smooth"})}}let pn=null;Ae.addEventListener("input",()=>{clearTimeout(pn),pn=setTimeout(()=>{L=Ae.value.trim(),x=1,U(),$t(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 br(A.getAttribute("data-sort"));if(A.matches("[data-page]")){let M=A.getAttribute("data-page"),{pages:P}=je(ye.length);return Ke(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 dt(A.getAttribute("data-open"));if(A===lt){T=ut()?"table":"card",U();return}if(A===gr)return K.exportCSV();A.matches("tr[data-yuktai-row-id]")&&typeof i.onRowClick=="function"&&!g.target.closest("label,input,button,a")&&dt(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(),Ue();else if(A.matches("[data-select-page]")){let{start:M,end:P}=je(ye.length);ye.slice(M,P).forEach(O=>A.checked?F.add(W(O)):F.delete(W(O))),U(),Ue()}else A.matches("[data-page-size]")&&($=Number(A.value)||$,x=1,U(),oe.closest(".yv-grid").querySelector("[data-page-size]").focus())}),oe.addEventListener("keydown",Fo),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,O=Array.prototype.indexOf.call(A.querySelectorAll("tr"),P),D=Array.prototype.indexOf.call(P.querySelectorAll("th,td"),M);O<0||D<0||(A.querySelectorAll('[tabindex="0"]').forEach(_=>_!==M&&_.setAttribute("tabindex","-1")),M.setAttribute("tabindex","0"),N={r:O,c:D})});let Rt=null;typeof ResizeObserver=="function"&&(Rt=new ResizeObserver(g=>{let A=g[0]&&g[0].contentRect.width,M=A>0&&A<C;M!==G&&(G=M,T==="auto"&&U())}),Rt.observe(Z));let Te={get data(){return E},get columns(){return h},rowKey:f,locale:u,get filters(){return w},onHighlightRows:g=>pt(g),onSelectRow:g=>{F.add(String(g)),pt([String(g)]),Ue()},onOpenRow:typeof i.onRowClick=="function"||typeof i.onOpenRow=="function"?g=>dt(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)}},Et=Ze(Te,{name:i.toolName||"yuktai_grid",descriptions:i.toolDescriptions}),gt=Zt({tools:()=>Et,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}),Lt={status:{state:"unsupported",registered:[],errors:[]},unregister(){}};i.webmcp&&(Lt=en(()=>Et,{onStatusChange:g=>{i.onWebMCPStatusChange&&i.onWebMCPStatusChange(g),Z.dispatchEvent(new CustomEvent("yuktai:webmcp",{detail:g,bubbles:!0}))}}));let Qe=tn({data:E,columns:h,rowKey:f,referenceDate:i.referenceDate,onOpenRow:Te.onOpenRow,bind:{getData:()=>E,getFilters:()=>w,getSort:()=>v,getHighlightIds:()=>Array.from(H),setFilters:g=>Te.onFiltersChange(g),setSort:g=>Te.onSortChange(g),setHighlightIds:g=>pt(g),selectRow:g=>Te.onSelectRow(g)}}),mt=null;i.ai&&(mt=lr(cn,gt,{locale:u,inputLanguage:i.inputLanguage||(u==="te"?"te-IN":"en-IN"),examples:i.assistantExamples,webmcp:()=>Lt.status,showWebMCP:!!i.webmcp}),i.webmcp&&Z.addEventListener("yuktai:webmcp",()=>mt&&mt.refreshStatus()));let gn=null;if(i.agentic){let g=typeof i.agentic=="object"?i.agentic:{};gn=an(cn,Qe,g)}let K={element:Z,host:Z,get tools(){return Et},agent:gt,agentic:Qe,get webmcpStatus(){return Lt.status},refresh(g){return Array.isArray(g)&&(E=g.slice(),F.clear(),H.clear(),x=1),U(),K},setData(g,A){return Array.isArray(A)&&(k=ko(A,g||E),h=Me(k),Et=Ze(Te,{name:i.toolName||"yuktai_grid",descriptions:i.toolDescriptions})),K.refresh(g)},getData:()=>E.slice(),getRows:()=>Ge(),getPageRows(){let g=Ge(),{start:A,end:M}=je(g.length);return g.slice(A,M)},getSelectedRows:()=>E.filter(g=>F.has(W(g))),getSelectedKeys:()=>Array.from(F),select(g,A=!0){return[].concat(g).forEach(M=>A?F.add(String(M)):F.delete(String(M))),U(),Ue(),K},clearSelection(){return F.clear(),U(),Ue(),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 gt.executeTool("filter",g)},getFilters:()=>w.slice(),clearFilters(){return Te.onFiltersChange([]),$t(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 pt(g,A===void 0?m:A),K},clearHighlight(){return pt([],!1),K},getHighlightIds:()=>Array.from(H),goToPage(g){return Ke(Number(g)||1),K},nextPage(){return Ke(x+1),K},prevPage(){return Ke(x-1),K},getPage:()=>({page:x,pageSize:$,pages:je(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=xo.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=>dt(g),async ask(g){return(await Qe.ask(g)).answer},askDetailed:g=>Qe.ask(g),assistantAsk:g=>gt.ask(g),executeTool:(g,A)=>gt.executeTool(g,A),biSummary:()=>qe(Ge(),h),anomalies:()=>ze(Ge(),h,{rowKey:f}),async runTasks(g){return(await Qe.ask(g)).answer},reset(){return Qe.reset(),L="",Ae.value="",U(),K},exportCSV(g=i.exportFileName||"yuktai-grid-export.csv"){let A=F.size?E.filter(P=>F.has(W(P))):Ge(),M="\uFEFF"+[k.map(P=>ar(P.label)).join(","),...A.map(P=>k.map(O=>ar(P[O.key])).join(","))].join(`\r
|
|
542
|
+
`);return kt(g,M,"text/csv;charset=utf-8"),re(`${A.length} row(s) exported`),A.length},destroy(){clearTimeout(pn),clearTimeout(dn),Rt&&Rt.disconnect(),Lt.unregister(),mt&&mt.destroy(),gn&&gn.destroy(),Z.remove()}};return typeof i.onReady=="function"&&i.onReady(K),U(),K}var ta={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 lr(e,t,n={}){let r=ta[n.locale==="te"?"te":"en"],a=j("yv-ask"),i=j("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 To=[{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"}],na=[["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)"]],cr=e=>c("span",{class:`yv-badge yv-sev-${e}`},e);function ur(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 At(e){let t=(e||[]).filter(Boolean);return t.length?c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>re(`${wo(t)} element(s) outlined on the page`)},q("eye",14),"Show on page"):null}function sn(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=j("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={};To.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=To.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=qt({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,cr(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,At([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(ur(w.score,w.summary),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn yv-small",onclick:async()=>re(await vo(wt(w))?"Markdown report copied":"Copy failed")},q("copy",14),"Copy Markdown"),c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>kt("yuktai-qa-report.md",wt(w),"text/markdown;charset=utf-8")},q("download",14),"Markdown"),c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>kt("yuktai-qa-report.json",zt(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,cr(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)),At([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:j("yv-senior"),checked:t.seniorFriendly!==!1}),w=c("div",{"aria-live":"polite"}),v=()=>{let L=nt({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"},ur(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)))),At(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=j("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=_t({minFontSize:Number(w.value)||16,maxLineLength:t.maxLineLength||90});v.replaceChildren(ur(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,cr($.severity)," ",c("b",null,$.category),": ",$.message),c("p",{class:"yv-muted"},$.suggestion),At([$.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=j("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 Ht(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=At(R.targets);if(N&&G.push(N),R.intent==="unknown"){L?L.rebuild():L=Bt({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=j("yv-lang"),w=c("select",{id:h,class:"yv-input",style:"width:auto"},...na.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=j("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=Xt({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
|
|
543
|
+
${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 dr="yuktai-a11y-prefs",Tt=[.8,.9,1,1.1,1.2,1.3],ra=[["none","None"],["deuteranopia","Deuteranopia (red-green)"],["protanopia","Protanopia (red-green)"],["tritanopia","Tritanopia (blue-yellow)"],["achromatopsia","Achromatopsia (no colour)"]],oa=[["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 ia(){try{let e=localStorage.getItem(dr);return e?JSON.parse(e):{}}catch{return{}}}function aa(e){try{let t={};["highContrast","darkMode","reduceMotion","largeTargets","speechEnabled","colorBlindMode","dyslexiaFont","fontSizeMultiplier"].forEach(n=>t[n]=e[n]),localStorage.setItem(dr,JSON.stringify(t))}catch{}}function So(e={}){let t={position:"left",title:"Accessibility",showPageTools:!1,...e},n=t.position==="right"?"right":"left",r=rn(t.primaryColor,"#005A9C"),a={enabled:!0,autoFix:!0,showSkipLinks:!0,showPreferencePanel:!1,...at,...t.config||{}},i={...a,...ia()},o,l,s,u,p,f,b,d="";async function S(T,R){i={...i,...T,enabled:!0},aa(i);try{d=await _e.execute({...i}),i.autoFix||_e.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(dr)}catch{}return i={...a},await S(i,!0),re("Accessibility settings reset"),i}function m(){let T=j("yv-a11y-title"),R=j("yv-font"),G=j("yv-cb"),N=c("section",{class:"yv-dialog",role:"dialog","aria-modal":"false","aria-labelledby":T,"data-yuktai-panel":""}),F=oa.map(([W,Y,Z,St])=>{let Ae=j("yv-opt"),ln=c("input",{id:Ae,type:"checkbox",role:"switch","data-setting":W,"aria-describedby":`${Ae}-d`});return c("div",{class:"yv-option"},c("span",{class:"yv-option-icon"},q(St,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"},ln,c("span",{"aria-hidden":"true"})))}),H=c("div",{class:"yv-steps-bar",role:"group","aria-labelledby":R},...Tt.map(W=>c("button",{type:"button",class:"yv-step","data-font":W,"aria-label":`${Math.round(W*100)} percent`,"aria-pressed":"false"}))),pe=c("select",{id:G,class:"yv-input","data-colorblind":""},...ra.map(([W,Y])=>c("option",{value:W},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)}),H,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",W=>{let Y=W.target;Y.matches("[data-setting]")?S({[Y.getAttribute("data-setting")]:Y.checked}):Y.matches("[data-colorblind]")&&S({colorBlindMode:Y.value})}),N.addEventListener("click",W=>{let Y=W.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=Tt.indexOf(Number(i.fontSizeMultiplier||1));return E(Tt[Math.min(Tt.length-1,Math.max(0,(Z<0?2:Z)+Number(Y.getAttribute("data-font-step"))))])}}}),N.addEventListener("keydown",W=>k(W,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){Tt.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=j("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=sn(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(){!Pe()||l||!document.body||(on(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 Co="5.3.0";(function(){if(!Pe()||window.yuktai&&window.yuktai.__vanillaInitialized)return;let t=window.YUKTAI_CONFIG||{},n=rn(t.primaryColor,"#005A9C"),r=t.position==="right"?"right":"left",a=So(t),i=()=>on(n,r),o=s=>(...u)=>(i(),s(...u)),l={__vanillaInitialized:!0,version:Co,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(Ao),mountAgenticGridBar:o(an),mountAgenticPanel:o(sn),mountGridAssistant:o(lr),createAgenticGrid:tn,createGridAgent:Zt,parseGridIntent:nr,registerWebMCP:en,icon:de,iconNames:yo.slice(),iconContrast:xt,pickGlyphColor:or,...er,runPageQA:()=>be().summary,getCapabilities:()=>({version:Co,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())})();})();
|