tekivex-ui 2.6.0 → 3.0.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.
Files changed (48) hide show
  1. package/README.md +22 -8
  2. package/dist/charts.cjs +1 -1
  3. package/dist/charts.js +14 -14
  4. package/dist/{chunk-B3ph66Zb.js → chunk-BHX35YDv.js} +1 -1
  5. package/dist/chunk-BpuJ3-K8.js +1 -0
  6. package/dist/{chunk-Bc16rJT-.js → chunk-C8Wy8P59.js} +1 -1
  7. package/dist/chunk-CDGrC2Wo.js +3 -0
  8. package/dist/{chunk-LWkKqC8d.js → chunk-D7-yknXg.js} +1 -1
  9. package/dist/{chunk-DnCXUUx5.js → chunk-DcVMayoM.js} +1 -1
  10. package/dist/chunk-DdHSYetV.js +1 -0
  11. package/dist/chunk-VUD-TF9j.js +1 -0
  12. package/dist/headless.cjs +1 -1
  13. package/dist/headless.js +1 -1
  14. package/dist/i18n.cjs +1 -1
  15. package/dist/i18n.js +1 -1
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.d.ts +18 -2
  18. package/dist/index.js +499 -414
  19. package/dist/quantum.cjs +1 -1
  20. package/dist/quantum.js +1 -1
  21. package/dist/realtime.cjs +1 -1
  22. package/dist/realtime.js +1 -1
  23. package/dist/src/components/TkxAadhaarInput.d.ts +22 -0
  24. package/dist/src/components/TkxAddressInput.d.ts +32 -0
  25. package/dist/src/components/TkxCalendarLunar.d.ts +25 -0
  26. package/dist/src/components/TkxCaptcha.d.ts +23 -0
  27. package/dist/src/components/TkxCheckout.d.ts +26 -0
  28. package/dist/src/components/TkxConfetti.d.ts +21 -0
  29. package/dist/src/components/TkxCurrencyInput.d.ts +20 -0
  30. package/dist/src/components/TkxFontProvider.d.ts +12 -0
  31. package/dist/src/components/TkxImageEditor.d.ts +44 -0
  32. package/dist/src/components/TkxKycInputs.d.ts +59 -0
  33. package/dist/src/components/TkxOTP.d.ts +2 -1
  34. package/dist/src/components/TkxPaymentButton.d.ts +61 -0
  35. package/dist/src/components/TkxPhoneInput.d.ts +34 -0
  36. package/dist/src/components/TkxSEO.d.ts +58 -0
  37. package/dist/src/components/TkxSignaturePad.d.ts +21 -0
  38. package/dist/src/components/TkxSortable.d.ts +18 -0
  39. package/dist/src/components/TkxSubscription.d.ts +42 -0
  40. package/dist/src/components/TkxWatermark.d.ts +8 -1
  41. package/dist/src/i18n/index.d.ts +51 -0
  42. package/dist/src/themes/index.d.ts +6 -1
  43. package/dist/tekivex-ui.css +1 -1
  44. package/package.json +20 -4
  45. package/dist/chunk-Dike2DLU.js +0 -3
  46. package/dist/chunk-DjxOP8W4.js +0 -1
  47. package/dist/chunk-DkoFTL1O.js +0 -1
  48. package/dist/chunk-PJ50l0JC.js +0 -1
package/dist/quantum.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunk-DmRB1Blb.js"),t=require("./chunk-DjxOP8W4.js"),n=require("./chunk-LWkKqC8d.js");let r=require("react");r=e.__toESM(r,1);let o=require("react/jsx-runtime");var i=class e{constructor(e,t){this.re=e,this.im=t}add(t){return new e(this.re+t.re,this.im+t.im)}sub(t){return new e(this.re-t.re,this.im-t.im)}mul(t){return new e(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)}scale(t){return new e(this.re*t,this.im*t)}conjugate(){return new e(this.re,-this.im)}magnitudeSquared(){return this.re*this.re+this.im*this.im}magnitude(){return Math.sqrt(this.magnitudeSquared())}static fromPolar(t,n){return new e(t*Math.cos(n),t*Math.sin(n))}static zero(){return new e(0,0)}static one(){return new e(1,0)}},a=class e{constructor(e=i.one(),t=i.zero()){this.alpha=e,this.beta=t,this.normalize()}normalize(){const e=Math.sqrt(this.alpha.magnitudeSquared()+this.beta.magnitudeSquared());e>0&&(this.alpha=this.alpha.scale(1/e),this.beta=this.beta.scale(1/e))}hadamard(){const t=1/Math.SQRT2;return new e(this.alpha.add(this.beta).scale(t),this.alpha.sub(this.beta).scale(t))}ry(t){const n=Math.cos(t/2),r=Math.sin(t/2);return new e(this.alpha.scale(n).sub(this.beta.scale(r)),this.alpha.scale(r).add(this.beta.scale(n)))}phase(t){const n=i.fromPolar(1,t);return new e(this.alpha,this.beta.mul(n))}measure(){const e=this.beta.magnitudeSquared();return Math.random()<e?1:0}expectation(){return this.beta.magnitudeSquared()}getAlpha(){return this.alpha}getBeta(){return this.beta}},l=class{constructor(e){this.qubits=Array.from({length:e},()=>new a)}get size(){return this.qubits.length}getQubit(e){return this.qubits[e]}superpose(){this.qubits=this.qubits.map(e=>e.hadamard())}cnot(e,t){const n=this.qubits[e],r=this.qubits[t],o=n.expectation();this.qubits[t]=r.ry(Math.PI*o)}rotate(e,t){this.qubits[e]=this.qubits[e].ry(t)}measure(){return this.qubits.map(e=>e.measure())}probs(){return this.qubits.map(e=>e.expectation())}},s=class{constructor(e=1,t=.995,n=.3,r=1e-6){this.temperature=e,this.coolingRate=t,this.tunnelingStrength=n,this.minTemp=r}anneal(e,t,n,r=1e3){let o=e,i=t(o),a=o,l=i,s=this.temperature,d=0,c=0;for(let p=0;p<r&&s>this.minTemp;p++){const e=n(o),r=t(e),p=r-i;let h=!1;if(p<=0)h=!0;else{const e=Math.exp(-p/s),t=Math.sqrt(2*Math.abs(p)),n=Math.abs(p),r=Math.exp(-2*t*Math.sqrt(n)*this.tunnelingStrength);Math.random()<e+r&&(h=!0,Math.random()<r/(e+r+1e-10)&&c++)}h&&(o=e,i=r,d++,i<l&&(a=o,l=i)),s*=this.coolingRate}return{state:a,energy:l,iterations:r,accepted:d,tunnels:c}}},d=class{constructor(e,t){const n=Math.sqrt(2/(e+t));this.weights=Array.from({length:e},()=>Array.from({length:t},()=>(2*Math.random()-1)*n)),this.visibleBias=Array.from({length:e},()=>0),this.hiddenBias=Array.from({length:t},()=>0)}sigmoid(e){const t=.1*(Math.random()-.5);return 1/(1+Math.exp(-(e+t)))}sample(e){return Math.random()<e?1:0}energy(e,t){const n=this.visibleBias.reduce((t,n,r)=>t+n*e[r],0),r=this.hiddenBias.reduce((e,n,r)=>e+n*t[r],0);let o=0;for(let i=0;i<e.length;i++)for(let n=0;n<t.length;n++)o+=e[i]*this.weights[i][n]*t[n];return-(n+r+o)}hiddenProbs(e){return this.hiddenBias.map((t,n)=>{const r=t+e.reduce((e,t,r)=>e+this.weights[r][n]*t,0);return this.sigmoid(r)})}visibleProbs(e){return this.visibleBias.map((t,n)=>{const r=t+e.reduce((e,t,r)=>e+this.weights[n][r]*t,0);return this.sigmoid(r)})}gibbs(e,t=1){let n=[...e],r=[];for(let o=0;o<t;o++)r=this.hiddenProbs(n).map(e=>this.sample(e)),n=this.visibleProbs(r).map(e=>this.sample(e));return{visible:n,hidden:r}}trainCD1(e,t=.01){const n=this.visibleBias.length,r=this.hiddenBias.length,o=Array.from({length:n},()=>Array(r).fill(0)),i=Array(n).fill(0),a=Array(r).fill(0);for(const s of e){const e=this.hiddenProbs(s),t=e.map(e=>this.sample(e)),l=this.visibleProbs(t).map(e=>this.sample(e)),d=this.hiddenProbs(l);for(let a=0;a<n;a++){for(let t=0;t<r;t++)o[a][t]+=s[a]*e[t]-l[a]*d[t];i[a]+=s[a]-l[a]}for(let n=0;n<r;n++)a[n]+=e[n]-d[n]}const l=e.length;for(let s=0;s<n;s++){for(let e=0;e<r;e++)this.weights[s][e]+=t*o[s][e]/l;this.visibleBias[s]+=t*i[s]/l}for(let s=0;s<r;s++)this.hiddenBias[s]+=t*a[s]/l}infer(e){const t=this.hiddenProbs(e),n=t.map(e=>this.sample(e));return{hidden:t,visible:this.visibleProbs(n),energy:this.energy(e,n),iterations:1}}},c=class{amplify(e,t,n=.5){const r=e.length;if(0===r)return[];const o=e.map(t),i=o.filter(e=>e>n).length,a=Math.max(1,i);let l=Array(r).fill(1/Math.sqrt(r));const s=Math.max(1,Math.floor(Math.PI/4*Math.sqrt(r/a)));for(let d=0;d<s;d++){for(let t=0;t<r;t++)o[t]>n&&(l[t]=-l[t]);const e=l.reduce((e,t)=>e+t,0)/r;l=l.map(t=>2*e-t)}return e.map((e,t)=>({index:t,amplitude:l[t],probability:l[t]*l[t],classicalSimilarity:o[t],combined:l[t]*l[t]*.6+.4*o[t]})).sort((e,t)=>t.combined-e.combined)}},p=[{keywords:["email","e-mail","mail"],type:"email",validations:[{rule:"required",message:"Email is required"},{rule:"pattern",value:"^[^@]+@[^@]+\\.[^@]+$",message:"Enter a valid email address"},{rule:"maxLength",value:254,message:"Email too long"}],placeholder:"you@example.com",label:"Email Address",confidence:.98},{keywords:["password","passwd","pwd","pass"],type:"password",validations:[{rule:"required",message:"Password is required"},{rule:"minLength",value:8,message:"Password must be at least 8 characters"},{rule:"pattern",value:"(?=.*[A-Z])(?=.*[0-9])",message:"Include uppercase and a number"}],placeholder:"••••••••",label:"Password",confidence:.97},{keywords:["confirm_password","confirmpassword","confirm_pass","repassword","password2","repeat_password"],type:"password",validations:[{rule:"required",message:"Please confirm your password"},{rule:"match",value:"password",message:"Passwords do not match"}],placeholder:"••••••••",label:"Confirm Password",confidence:.95},{keywords:["phone","mobile","cell","tel","telephone","contact_number"],type:"tel",validations:[{rule:"pattern",value:"^[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,6}$",message:"Enter a valid phone number"}],placeholder:"+1 (555) 000-0000",label:"Phone Number",confidence:.93},{keywords:["age"],type:"number",validations:[{rule:"min",value:0,message:"Age cannot be negative"},{rule:"max",value:150,message:"Enter a valid age"},{rule:"integer",message:"Age must be a whole number"}],placeholder:"25",label:"Age",confidence:.9},{keywords:["price","amount","cost","fee","payment","salary","wage","total"],type:"number",validations:[{rule:"min",value:0,message:"Amount cannot be negative"},{rule:"pattern",value:"^\\d+(\\.\\d{1,2})?$",message:"Enter a valid amount (e.g. 9.99)"}],placeholder:"0.00",label:"Amount",confidence:.88},{keywords:["url","website","site","link","homepage","web"],type:"url",validations:[{rule:"pattern",value:"https?://.+",message:"Enter a valid URL starting with http:// or https://"}],placeholder:"https://example.com",label:"Website URL",confidence:.92},{keywords:["zip","zipcode","postal","postcode","pin_code"],type:"text",validations:[{rule:"pattern",value:"^[0-9]{5}(-[0-9]{4})?$",message:"Enter a valid ZIP code (e.g. 12345)"}],placeholder:"12345",label:"ZIP / Postal Code",confidence:.91},{keywords:["date","dob","birthday","birth_date","birthdate","born"],type:"date",validations:[{rule:"required",message:"Date is required"}],placeholder:"YYYY-MM-DD",label:"Date of Birth",confidence:.89},{keywords:["first_name","firstname","fname","given_name"],type:"text",validations:[{rule:"minLength",value:2,message:"First name too short"},{rule:"maxLength",value:50,message:"First name too long"}],placeholder:"Jane",label:"First Name",confidence:.9},{keywords:["last_name","lastname","lname","surname","family_name"],type:"text",validations:[{rule:"minLength",value:2,message:"Last name too short"},{rule:"maxLength",value:50,message:"Last name too long"}],placeholder:"Doe",label:"Last Name",confidence:.9},{keywords:["name","full_name","fullname","display_name"],type:"text",validations:[{rule:"minLength",value:2,message:"Name too short"},{rule:"maxLength",value:100,message:"Name too long"}],placeholder:"Jane Doe",label:"Full Name",confidence:.85},{keywords:["username","user_name","handle","login","loginname"],type:"text",validations:[{rule:"minLength",value:3,message:"Username must be at least 3 characters"},{rule:"maxLength",value:32,message:"Username too long"},{rule:"pattern",value:"^[a-zA-Z0-9_.-]+$",message:"Only letters, numbers, _, - and . allowed"}],placeholder:"cooluser42",label:"Username",confidence:.94},{keywords:["bio","biography","about","description","summary","details"],type:"textarea",validations:[{rule:"maxLength",value:500,message:"Bio must be under 500 characters"}],placeholder:"Tell us about yourself...",label:"Bio",confidence:.87},{keywords:["message","comment","feedback","note","notes","remarks","body"],type:"textarea",validations:[{rule:"minLength",value:10,message:"Message too short"},{rule:"maxLength",value:2e3,message:"Message too long"}],placeholder:"Write your message here...",label:"Message",confidence:.86},{keywords:["search","query","q","keyword","find"],type:"search",validations:[],placeholder:"Search...",label:"Search",confidence:.9},{keywords:["otp","one_time_password","verification_code","pin","code"],type:"text",validations:[{rule:"minLength",value:4,message:"Code too short"},{rule:"maxLength",value:8,message:"Code too long"},{rule:"pattern",value:"^[0-9]+$",message:"Code must be numeric"}],placeholder:"123456",label:"Verification Code",confidence:.92},{keywords:["color","colour","hex_color","brand_color"],type:"color",validations:[],placeholder:"#3b82f6",label:"Color",confidence:.95},{keywords:["address","street","street_address","addr"],type:"text",validations:[{rule:"maxLength",value:200,message:"Address too long"}],placeholder:"123 Main Street",label:"Street Address",confidence:.87},{keywords:["city","town","municipality"],type:"text",validations:[{rule:"maxLength",value:100,message:"City name too long"}],placeholder:"San Francisco",label:"City",confidence:.89},{keywords:["country","nation","country_code"],type:"text",validations:[],placeholder:"United States",label:"Country",confidence:.88},{keywords:["company","organization","org","employer","company_name"],type:"text",validations:[{rule:"maxLength",value:200,message:"Company name too long"}],placeholder:"Acme Inc.",label:"Company",confidence:.87}];function h(e){const t=e.toLowerCase().replace(/[\s-]/g,"_"),n=(new c).amplify(p,e=>{let n=0;for(const r of e.keywords)t===r?n=Math.max(n,1):t.includes(r)||r.includes(t)?n=Math.max(n,.8):r.split("_").some(e=>t.includes(e))&&(n=Math.max(n,.5));return n},.3);if(n.length>0&&n[0].combined>.1){const e=p[n[0].index];return{type:e.type,validations:e.validations,placeholder:e.placeholder,confidence:Math.min(e.confidence*n[0].combined*2,.99),label:e.label}}return{type:"text",validations:[{rule:"maxLength",value:255,message:"Input too long"}],placeholder:e.replace(/_/g," "),confidence:.3,label:e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}}function u(e,t,n){const r=n/100,o=t/100*Math.min(r,1-r),i=t=>{const n=(t+e/30)%12,i=r-o*Math.max(Math.min(n-3,9-n,1),-1);return Math.round(255*i).toString(16).padStart(2,"0")};return`#${i(0)}${i(8)}${i(4)}`}function g(e){const[t,n,r]=function(e){const t=e.replace("#",""),n=3===t.length?t.split("").map(e=>e+e).join(""):t;return[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}(e).map(e=>{const t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return.2126*t+.7152*n+.0722*r}function m(e,t){const n=g(e),r=g(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function f(e,t,n){return Math.max(t,Math.min(n,e))}function y(e,t,n=800){const r=t?{primary:{h:e,s:70,l:55},secondary:{h:(e+137.5)%360,s:65,l:50},bg:{h:e,s:10,l:8},surface:{h:e,s:10,l:13},text:{h:e,s:15,l:90},border:{h:e,s:15,l:22},accent:{h:(e+120)%360,s:75,l:60}}:{primary:{h:e,s:65,l:40},secondary:{h:(e+137.5)%360,s:55,l:38},bg:{h:e,s:15,l:97},surface:{h:e,s:12,l:100},text:{h:e,s:15,l:12},border:{h:e,s:12,l:85},accent:{h:(e+120)%360,s:70,l:42}};return function(e,t){const n=e=>u(e.h,e.s,e.l),r=t?e.text.l-20:e.text.l+15;return{primary:n(e.primary),secondary:n(e.secondary),background:n(e.bg),surface:n(e.surface),text:n(e.text),textMuted:u(e.text.h,Math.max(0,e.text.s-10),Math.max(20,Math.min(85,r))),border:n(e.border),error:t?"#f87171":"#dc2626",warning:t?"#fbbf24":"#d97706",success:t?"#34d399":"#059669",accent:n(e.accent)}}(new s(1.5,.994,.35,1e-5).anneal(r,e=>function(e,t){let n=0;const r=e=>u(e.h,e.s,e.l),o=r(e.text),i=r(e.bg),a=r(e.surface),l=r(e.primary),s=m(o,i),d=m(o,a),c=m(l,i);s<4.5&&(n+=10*(4.5-s)),d<4.5&&(n+=8*(4.5-d)),c<3&&(n+=5*(3-c)),n+=.05*Math.abs((e.secondary.h-e.primary.h+360)%360-137.508),n+=.03*Math.abs((e.accent.h-e.primary.h+360)%360-120);const p=(e.primary.s+e.secondary.s)/2;p<20&&(n+=.5*(20-p)),p>90&&(n+=.5*(p-90));const h=e.bg.l;t?(h>25&&(n+=2*(h-25)),h<3&&(n+=2*(3-h)),e.text.l<70&&(n+=1.5*(70-e.text.l))):(h<90&&(n+=2*(90-h)),h>100&&(n+=2*(h-100)),e.text.l>30&&(n+=1.5*(e.text.l-30)));const g=Math.abs(e.surface.l-e.bg.l);return g<2&&(n+=2*(2-g)),g>12&&(n+=1*(g-12)),n}(e,t),e=>{const t=["primary","secondary","bg","surface","text","border","accent"],n=t[Math.floor(Math.random()*t.length)],r=["h","s","l"],o=r[Math.floor(Math.random()*r.length)],i=(Math.random()-.5)*("h"===o?30:15),a={...e,[n]:{...e[n]}};return a[n]="h"===o?{...a[n],h:(e[n].h+i+360)%360}:"s"===o?{...a[n],s:f(e[n].s+i,0,100)}:{...a[n],l:f(e[n].l+i,0,100)},a},n).state,t)}var x={qubit:()=>new a,register:e=>new l(e),annealer:(e,t,n)=>new s(e,t,n),qbm:(e,t)=>new d(e,t),amplifier:()=>new c,inferField:h,optimizeTheme:y,contrast:m,hslToHex:u};function b(e,t,n,r){const o=n.trim();switch(e){case"required":return""!==o;case"email":case"pattern":if("string"==typeof t)try{return""===o||new RegExp(t).test(o)}catch{return!0}return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o);case"phone":return""===o||/^\+?[\d\s\-()]{7,15}$/.test(o);case"url":return""===o||/^https?:\/\/.+/.test(o);case"minLength":case"min":{const e=Number(t??0);return""===o||(isNaN(Number(o))?o.length>=e:Number(o)>=e)}case"maxLength":case"max":{const e=Number(t??1/0);return""===o||(isNaN(Number(o))?o.length<=e:Number(o)<=e)}case"integer":return""===o||/^\d+$/.test(o);case"alphanumeric":return""===o||/^[a-zA-Z0-9]+$/.test(o);case"match":return o===(r["string"==typeof t?t:"password"]??"");default:return!0}}function v({phase:e,collapsed:t,primaryColor:n,borderColor:r}){const i=12,a=t?0:e,l=t?0:1.618*e,s=i+10*Math.sin(a)*Math.cos(l),d=12-10*Math.cos(a);return(0,o.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24","aria-hidden":"true",style:{flexShrink:0,opacity:t?.4:1,transition:"opacity 0.6s"},children:[(0,o.jsx)("circle",{cx:i,cy:12,r:10,fill:"none",stroke:r,strokeWidth:"0.8"}),(0,o.jsx)("ellipse",{cx:i,cy:12,rx:10,ry:3,fill:"none",stroke:r,strokeWidth:"0.5",strokeDasharray:"2 2"}),(0,o.jsx)("line",{x1:i,y1:2,x2:i,y2:22,stroke:r,strokeWidth:"0.5"}),(0,o.jsx)("line",{x1:i,y1:12,x2:s,y2:d,stroke:n,strokeWidth:"1.5",style:{transition:t?"all 0.6s ease-out":"none"}}),(0,o.jsx)("circle",{cx:s,cy:d,r:"2",fill:n,style:{transition:t?"all 0.6s ease-out":"none"}})]})}function k({confidence:e,theme:t}){const n=Math.round(100*e),r=n>=80?t.success:n>=60?t.warning:t.danger;return(0,o.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:"2px",fontSize:"10px",fontWeight:600,padding:"1px 5px",borderRadius:"999px",backgroundColor:`${r}22`,color:r,border:`1px solid ${r}44`,marginLeft:"6px",verticalAlign:"middle",letterSpacing:"0.03em"},children:["⚛ ",n,"%"]})}function w({config:e,intel:t,qubitPhase:r,value:i,error:a,touched:l,showConfidence:s,showQuantumState:d,collapsed:c,onChange:p,onBlur:h,theme:u,mounted:g,index:m}){const f=e.type??t.type,y=e.label??t.label,x=e.placeholder??t.placeholder,b=void 0!==e.required?e.required:t.validations.some(e=>"required"===e.rule),w=n.sanitizeString(y),S="textarea"===f,C=l&&""!==a,M=`qf-${e.name}`,z={width:"100%",padding:"9px 12px",border:`1.5px solid ${C?u.danger:u.border}`,borderRadius:"8px",backgroundColor:u.surface,color:u.text,fontSize:"14px",fontFamily:"inherit",outline:"none",boxSizing:"border-box",transition:"border-color 0.15s, box-shadow 0.15s",resize:S?"vertical":void 0,minHeight:S?"80px":void 0};return(0,o.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"4px",opacity:g?1:0,transform:g?"scaleY(1)":"scaleY(0.92)",transition:`opacity 0.35s ease ${60*m}ms, transform 0.35s ease ${60*m}ms`,transformOrigin:"top"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[d&&(0,o.jsx)(v,{phase:r,collapsed:c,primaryColor:u.primary,borderColor:u.border}),(0,o.jsxs)("label",{htmlFor:M,style:{fontSize:"13px",fontWeight:500,color:u.text,cursor:"pointer"},children:[w,b&&(0,o.jsx)("span",{"aria-hidden":"true",style:{color:u.danger,marginLeft:"3px"},children:"*"})]}),s&&(0,o.jsx)(k,{confidence:t.confidence,theme:u})]}),S?(0,o.jsx)("textarea",{id:M,value:i,onChange:e=>p(e.target.value),onBlur:h,placeholder:x,"aria-invalid":C,"aria-required":b,style:z}):(0,o.jsx)("input",{id:M,type:f,value:i,onChange:e=>p(e.target.value),onBlur:h,placeholder:x,"aria-invalid":C,"aria-required":b,style:z}),C&&(0,o.jsxs)("span",{role:"alert",style:{fontSize:"12px",color:u.danger,display:"flex",alignItems:"center",gap:"4px"},children:[(0,o.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),n.sanitizeString(a)]})]})}function S(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return(65535&t)/65535*Math.PI*2}function C({fields:e,onSubmit:i,submitLabel:a="Submit",layout:l="vertical",showConfidence:s=!0,showQuantumState:d=!1}){const c=t.useTheme(),p=e.map(e=>h(e.name)),[u,g]=(0,r.useState)(()=>Object.fromEntries(e.map(e=>[e.name,""]))),[m,f]=(0,r.useState)({}),[y,x]=(0,r.useState)({}),[v,k]=(0,r.useState)(!1),[C,M]=(0,r.useState)(!1),[z,T]=(0,r.useState)(!1);(0,r.useEffect)(()=>{const e=requestAnimationFrame(()=>M(!0));return()=>cancelAnimationFrame(e)},[]);const $=(0,r.useCallback)((t,n)=>{const r=e.find(e=>e.name===t),o=p[e.findIndex(e=>e.name===t)];if(!r||!o)return"";const i=n[t]??"";for(const{rule:e,value:a,message:l}of o.validations)if(("required"!==e||!1!==r.required)&&!b(e,a,i,n))return l;return""},[e]),A=(0,r.useCallback)(t=>{const n={};for(const r of e){const e=$(r.name,t);e&&(n[r.name]=e)}return n},[e,$]),W=(0,r.useCallback)((t,n)=>{g(r=>{const o={...r,[t]:n};if(y[t]&&(f(e=>({...e,[t]:$(t,o)})),"password"===t)){const t=e.find(e=>["confirmpassword","confirm_password","passwordconfirm"].includes(e.name.toLowerCase().replace(/[\s_-]/g,"")))?.name;t&&y[t]&&f(e=>({...e,[t]:$(t,o)}))}return o}),T(!0)},[e,y,$]),R=(0,r.useCallback)(e=>{x(t=>({...t,[e]:!0})),f(t=>({...t,[e]:$(e,u)}))},[u,$]),B=(0,r.useCallback)(async t=>{t.preventDefault(),x(Object.fromEntries(e.map(e=>[e.name,!0])));const n=A(u);if(f(n),!(Object.keys(n).length>0)){k(!0);try{await i(u)}finally{k(!1)}}},[e,u,A,i]),F=p.length>0?Math.round(p.reduce((e,t)=>e+t.confidence,0)/p.length*100):0,L=F>=80?c.success:F>=60?c.warning:c.danger,I="horizontal"===l;return(0,o.jsxs)("form",{onSubmit:B,noValidate:!0,className:n.tkx("w-full"),style:{backgroundColor:c.surface,border:`1px solid ${c.border}`,borderRadius:"12px",padding:"24px",position:"relative",boxSizing:"border-box"},children:[(0,o.jsx)("span",{"aria-label":"Powered by Quantum AI",style:{position:"absolute",top:"16px",right:"16px",fontSize:"10px",fontWeight:700,padding:"3px 8px",borderRadius:"999px",backgroundColor:`${c.primary}20`,color:c.primary,border:`1px solid ${c.primary}44`,letterSpacing:"0.04em",userSelect:"none"},children:"⚛ Quantum AI"}),s&&(0,o.jsxs)("div",{style:{marginBottom:"20px",paddingRight:"100px"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[(0,o.jsx)("span",{style:{fontSize:"11px",color:c.textMuted,fontWeight:500},children:"Form Intelligence Confidence"}),(0,o.jsxs)("span",{style:{fontSize:"11px",fontWeight:700,color:L},children:[F,"%"]})]}),(0,o.jsx)("div",{style:{height:"4px",borderRadius:"4px",backgroundColor:c.border,overflow:"hidden"},children:(0,o.jsx)("div",{style:{height:"100%",width:`${F}%`,backgroundColor:L,borderRadius:"4px",transition:"width 0.8s ease"}})})]}),(0,o.jsx)("div",{style:{display:"grid",gridTemplateColumns:I?"repeat(auto-fill, minmax(260px, 1fr))":"1fr",gap:"16px",marginBottom:"20px"},children:e.map((e,t)=>(0,o.jsx)(w,{config:e,intel:p[t],qubitPhase:S(e.name),value:u[e.name]??"",error:m[e.name]??"",touched:y[e.name]??!1,showConfidence:s,showQuantumState:d,collapsed:z,onChange:t=>W(e.name,t),onBlur:()=>R(e.name),theme:c,mounted:C,index:t},e.name))}),(0,o.jsx)("button",{type:"submit",disabled:v,style:{width:"100%",padding:"10px 20px",borderRadius:"8px",border:"none",backgroundColor:v?`${c.primary}88`:c.primary,color:c.bg,fontSize:"14px",fontWeight:700,fontFamily:"inherit",cursor:v?"not-allowed":"pointer",transition:"background-color 0.15s, opacity 0.15s",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:v?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",style:{animation:"qf-spin 0.8s linear infinite"},"aria-hidden":"true",children:[(0,o.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.25"}),(0,o.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})]}),"Processing…"]}):n.sanitizeString(a)}),(0,o.jsx)("style",{children:"@keyframes qf-spin { to { transform: rotate(360deg); } }"})]})}function M(e){return e?{primary:"#00f5d4",secondary:"#7b2ff7",background:"#0a0a0f",surface:"#12121a",text:"#e8e8f4",textMuted:"#8888aa",border:"#2a2a3e",error:"#f87171",warning:"#fbbf24",success:"#34d399",accent:"#ff6b6b"}:{primary:"#0d7c5f",secondary:"#6930c3",background:"#f8f6f1",surface:"#ffffff",text:"#1a1815",textMuted:"#6b6560",border:"#ddd8cc",error:"#dc2626",warning:"#d97706",success:"#059669",accent:"#e05a00"}}function z({points:e,primary:t}){if(e.length<2)return(0,o.jsx)("div",{style:{height:48,display:"flex",alignItems:"center",justifyContent:"center",color:"#888",fontSize:12},children:"Waiting for data..."});const n=Math.max(...e.map(e=>e.energy)),r=Math.min(...e.map(e=>e.energy)),i=n-r||1,a=e[e.length-1].iteration||1;return(0,o.jsxs)("svg",{width:280,height:48,style:{display:"block"},children:[(0,o.jsx)("polyline",{points:e.map(e=>{const t=e.iteration/a*280,n=48-(e.energy-r)/i*44-2;return`${t.toFixed(1)},${n.toFixed(1)}`}).join(" "),fill:"none",stroke:t,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.9}),(0,o.jsxs)("text",{x:2,y:10,fontSize:9,fill:"#888",children:["E=",n.toFixed(1)]}),(0,o.jsxs)("text",{x:2,y:46,fontSize:9,fill:"#888",children:["E=",r.toFixed(1)]})]})}function T({label:e,value:t,onChange:n,text:r,border:i}){return(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[(0,o.jsx)("input",{type:"color",value:t,onChange:e=>n(e.target.value),style:{width:32,height:32,border:`1px solid ${i}`,borderRadius:6,padding:2,cursor:"pointer",background:"transparent"}}),(0,o.jsx)("div",{style:{width:60,height:28,borderRadius:6,background:t,border:`1px solid ${i}`}}),(0,o.jsx)("span",{style:{flex:1,fontSize:13,color:r,fontFamily:"monospace"},children:e}),(0,o.jsx)("code",{style:{fontSize:12,color:r,opacity:.7,fontFamily:"monospace"},children:t})]})}function $({label:e,ratio:t}){const n=t>=4.5,r=t>=4.5,i=t>=7;return(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[(0,o.jsx)("span",{style:{fontSize:11,opacity:.8,minWidth:140},children:e}),(0,o.jsxs)("span",{style:{fontSize:12,fontWeight:600},children:[t.toFixed(2),":1"]}),(0,o.jsx)("span",{style:{fontSize:11,color:r?"#22c55e":"#ef4444"},children:r?"✓ AA":"✗ AA"}),(0,o.jsx)("span",{style:{fontSize:11,color:i?"#22c55e":"#888"},children:i?"✓ AAA":"— AAA"}),(0,o.jsx)("span",{style:{fontSize:13},children:n?"✅":"❌"})]})}C.displayName="TkxQuantumForm";var A=["fetch(","XMLHttpRequest","navigator.sendBeacon","document.cookie","localStorage","sessionStorage","indexedDB","WebSocket","EventSource","import(","eval(","new Function(","postMessage","window.open","location.href","location.replace","location.assign","document.write","crypto.subtle"],W=[{label:"Hello World",code:"<div style={{ padding: 24, fontFamily: 'sans-serif', color: '#e8e8f4' }}>\n <h2 style={{ margin: 0 }}>👋 Hello, TkxPlayground!</h2>\n <p style={{ marginTop: 8, opacity: 0.7 }}>Edit the code on the left to see live updates.</p>\n</div>"},{label:"Button Styles",code:"<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', padding: 24 }}>\n {['primary', 'success', 'danger', 'warning', 'info'].map(color => (\n <button\n key={color}\n style={{\n padding: '8px 18px',\n borderRadius: 8,\n border: 'none',\n background: color === 'primary' ? '#00f5d4' : color === 'success' ? '#06d6a0' : color === 'danger' ? '#f72585' : color === 'warning' ? '#ffbe0b' : '#3a86ff',\n color: '#0a0a0f',\n fontWeight: 700,\n cursor: 'pointer',\n textTransform: 'capitalize',\n }}\n >\n {color}\n </button>\n ))}\n</div>"},{label:"Card Grid",code:"<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 16, padding: 24 }}>\n {['Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta'].map(name => (\n <div key={name} style={{\n background: '#1a1a2e',\n borderRadius: 10,\n border: '1px solid #2a2a3e',\n padding: '16px',\n }}>\n <div style={{ fontWeight: 700, color: '#00f5d4', marginBottom: 4 }}>{name}</div>\n <div style={{ fontSize: 12, color: '#8888aa' }}>Quantum module {name.toLowerCase()}</div>\n </div>\n ))}\n</div>"},{label:"Animated Counter",code:"(() => {\n const [count, setCount] = React.useState(0);\n return (\n <div style={{ padding: 32, textAlign: 'center', fontFamily: 'sans-serif' }}>\n <div style={{ fontSize: 64, fontWeight: 900, color: '#00f5d4', marginBottom: 16 }}>\n {count}\n </div>\n <div style={{ display: 'flex', gap: 12, justifyContent: 'center' }}>\n <button onClick={() => setCount(c => c - 1)} style={{ padding: '8px 20px', borderRadius: 8, border: '1px solid #2a2a3e', background: '#1a1a2e', color: '#e8e8f4', fontSize: 20, cursor: 'pointer' }}>−</button>\n <button onClick={() => setCount(0)} style={{ padding: '8px 20px', borderRadius: 8, border: '1px solid #2a2a3e', background: '#1a1a2e', color: '#8888aa', cursor: 'pointer' }}>Reset</button>\n <button onClick={() => setCount(c => c + 1)} style={{ padding: '8px 20px', borderRadius: 8, border: '1px solid #2a2a3e', background: '#1a1a2e', color: '#e8e8f4', fontSize: 20, cursor: 'pointer' }}>+</button>\n </div>\n </div>\n );\n})()"},{label:"Data Table",code:"(() => {\n const rows = [\n { id: 1, name: 'Hydrogen', symbol: 'H', mass: 1.008 },\n { id: 2, name: 'Helium', symbol: 'He', mass: 4.003 },\n { id: 3, name: 'Lithium', symbol: 'Li', mass: 6.941 },\n { id: 4, name: 'Carbon', symbol: 'C', mass: 12.011 },\n { id: 5, name: 'Nitrogen', symbol: 'N', mass: 14.007 },\n ];\n const cell = { padding: '8px 14px', borderBottom: '1px solid #2a2a3e', color: '#e8e8f4', fontSize: 13 };\n const hcell = { ...cell, color: '#8888aa', fontWeight: 600, fontSize: 11, textTransform: 'uppercase', letterSpacing: '0.06em' };\n return (\n <div style={{ padding: 16 }}>\n <table style={{ width: '100%', borderCollapse: 'collapse', fontFamily: 'sans-serif' }}>\n <thead>\n <tr>{['ID','Element','Symbol','Atomic Mass'].map(h => <th key={h} style={hcell}>{h}</th>)}</tr>\n </thead>\n <tbody>\n {rows.map(r => (\n <tr key={r.id} style={{ transition: 'background 0.15s' }}>\n <td style={cell}>{r.id}</td>\n <td style={cell}>{r.name}</td>\n <td style={{ ...cell, color: '#00f5d4', fontWeight: 700 }}>{r.symbol}</td>\n <td style={cell}>{r.mass}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n})()"}],R=class extends r.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){this.props.onError(e.message)}componentDidUpdate(e){e.children!==this.props.children&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?null:this.props.children}};function B({code:e,lineHeight:t}){const n=e.split("\n");return(0,o.jsx)("div",{"aria-hidden":"true",style:{position:"absolute",top:0,left:0,width:"36px",padding:"12px 0",textAlign:"right",paddingRight:"8px",userSelect:"none",pointerEvents:"none",fontSize:"12px",lineHeight:`${t}px`,color:"#555577",fontFamily:'"Fira Code", "Cascadia Code", "Consolas", monospace',boxSizing:"border-box"},children:n.map((e,t)=>(0,o.jsx)("div",{children:t+1},t))})}var F=["TkxButton","TkxInput","TkxCard","TkxModal","TkxTable","TkxSelect","TkxCheckbox","TkxRadio","TkxSwitch","TkxSlider","TkxBadge","TkxAlert","TkxToast","TkxTooltip","TkxPopover","TkxTabs","TkxAccordion","TkxDrawer","TkxDropdown","TkxMenu","TkxForm","TkxDataGrid","TkxChart","TkxSpinner","TkxSkeleton","TkxAvatar","TkxTag","TkxDivider","TkxProgress","TkxStatistic","TkxQuantumForm","TkxPlayground"],L=new c;function I(e){const t=e.match(/([A-Z][a-zA-Z0-9]*)$/);return t?t[1]:""}function P({defaultCode:e,examples:n,height:i=480,imports:a={},strictMode:l=!0,forbiddenTokens:s}){const d=t.useTheme(),c=[...W,...n??[]],p=e??W[0].code,[h,u]=(0,r.useState)(p),[g,m]=(0,r.useState)({element:null,error:null,renderMs:0}),[f,y]=(0,r.useState)(null),[x,b]=(0,r.useState)([]),[v,k]=(0,r.useState)(!1),[w,S]=(0,r.useState)(0),C=(0,r.useRef)(null),M=(0,r.useRef)(null),z=(0,r.useCallback)(e=>{y(null),m(function(e,t,n){const o=performance.now();try{const i=e.trim();if(!1!==n?.strictMode){const e=function(e,t){const n=[...A,...t??[]],r=e.toLowerCase();for(const o of n)if(r.includes(o.toLowerCase()))return o;return null}(i,n?.forbiddenTokens);if(e)return{element:null,error:`Blocked by playground strictMode: code contains "${e}". This token is disallowed because playground snippets run in the page's JavaScript context. If you trust the source, pass strictMode={false} to <TkxPlayground>.`,renderMs:parseFloat((performance.now()-o).toFixed(2))}}let a=`\n function PlaygroundRoot() {\n ${i.startsWith("<")||i.startsWith("(")?`return (${i});`:i}\n }\n `;const l="undefined"==typeof window?null:window.Babel??null;l&&(a=l.transform(a,{presets:["react"],filename:"playground.jsx"}).code??a);const s=new Function("React","imports",`\n "use strict";\n const { ${Object.keys(t).join(", ")} } = imports;\n ${a}\n return PlaygroundRoot;\n `)(r.default,t);return{element:r.default.createElement(s),error:null,renderMs:parseFloat((performance.now()-o).toFixed(2))}}catch(i){const e=parseFloat((performance.now()-o).toFixed(2));return{element:null,error:i instanceof Error?i.message:String(i),renderMs:e}}}(e,a,{strictMode:l,forbiddenTokens:s}))},[a,l,s]);(0,r.useEffect)(()=>(M.current&&clearTimeout(M.current),M.current=setTimeout(()=>z(h),300),()=>{M.current&&clearTimeout(M.current)}),[h,z]),(0,r.useEffect)(()=>{z(p)},[]);const T=(0,r.useCallback)(e=>{const t=e.target.value;u(t);const n=I(t);n.length>=2?b(function(e,t=4){if(!e||e.length<2)return[];const n=e.toLowerCase();return L.amplify(F,e=>{const t=e.toLowerCase();if(t.startsWith(n))return 1;if(t.includes(n))return.7;let r=0;for(let o=0;o<n.length-1;o++)t.includes(n.slice(o,o+2))&&(r+=.15);return Math.min(r,.5)},.1).slice(0,t).map(e=>({name:F[e.index]??"",amplitude:parseFloat(e.combined.toFixed(3))})).filter(e=>""!==e.name)}(n,4)):b([])},[]),$=(0,r.useCallback)(e=>{const t=c[e];t&&(S(e),u(t.code),b([]))},[c]),P=(0,r.useCallback)(async()=>{try{await navigator.clipboard.writeText(h),k(!0),setTimeout(()=>k(!1),1500)}catch{}},[h]),q=(0,r.useCallback)(()=>{u(p),S(0),b([])},[p]),_=(0,r.useCallback)(e=>{const t=I(h);t&&u(n=>n.slice(0,n.lastIndexOf(t))+e),b([])},[h]),E=null!==g.error||null!==f,D=g.error??f??"",j=d.bg,N=d.surfaceAlt,H=d.border,O=d.surface,Q={width:"50%",display:"flex",flexDirection:"column",borderRight:`1px solid ${H}`,position:"relative"},Z={display:"flex",alignItems:"center",gap:"6px",padding:"6px 10px",borderBottom:`1px solid ${H}`,backgroundColor:d.surface,flexWrap:"wrap"},U={padding:"3px 10px",borderRadius:"6px",border:`1px solid ${H}`,backgroundColor:"transparent",color:d.textMuted,fontSize:"11px",fontWeight:600,cursor:"pointer",fontFamily:"inherit",transition:"color 0.15s, border-color 0.15s"};return(0,o.jsxs)("div",{style:{display:"flex",flexDirection:"column",border:`1px solid ${H}`,borderRadius:"12px",overflow:"hidden",backgroundColor:j,fontFamily:"inherit",boxSizing:"border-box",position:"relative"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",borderBottom:`1px solid ${H}`,backgroundColor:d.surface},children:[(0,o.jsx)("span",{style:{fontSize:"12px",fontWeight:700,color:d.primary,letterSpacing:"0.05em"},children:"⚛ TkxPlayground"}),(0,o.jsx)("span",{style:{fontSize:"10px",color:d.textMuted},children:"Live JSX Preview"})]}),(0,o.jsx)("div",{style:{display:"flex",gap:"4px",padding:"6px 10px",borderBottom:`1px solid ${H}`,backgroundColor:d.surface,overflowX:"auto"},children:c.map((e,t)=>(0,o.jsx)("button",{onClick:()=>$(t),style:{padding:"3px 10px",borderRadius:"6px",border:`1px solid ${t===w?d.primary:H}`,backgroundColor:t===w?`${d.primary}20`:"transparent",color:t===w?d.primary:d.textMuted,fontSize:"11px",fontWeight:t===w?700:400,cursor:"pointer",whiteSpace:"nowrap",fontFamily:"inherit",transition:"all 0.15s"},children:e.label},t))}),(0,o.jsxs)("div",{style:{display:"flex",height:`${i}px`},children:[(0,o.jsxs)("div",{style:Q,children:[(0,o.jsxs)("div",{style:Z,children:[(0,o.jsx)("span",{style:{fontSize:"11px",color:d.textMuted,marginRight:"auto"},children:"editor.tsx"}),(0,o.jsx)("button",{onClick:P,style:U,title:"Copy code",children:v?"✓ Copied":"⎘ Copy"}),(0,o.jsx)("button",{onClick:q,style:U,title:"Reset to default",children:"↺ Reset"})]}),(0,o.jsxs)("div",{style:{position:"relative",flex:1,overflow:"hidden"},children:[(0,o.jsx)(B,{code:h,lineHeight:18}),(0,o.jsx)("textarea",{ref:C,value:h,onChange:T,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",padding:"12px 12px 12px 44px",margin:0,border:"none",outline:"none",resize:"none",backgroundColor:j,color:d.text,fontSize:"12px",lineHeight:"18px",fontFamily:'"Fira Code", "Cascadia Code", "Consolas", "Courier New", monospace',boxSizing:"border-box",overflowY:"auto",tabSize:2}})]}),x.length>0&&(0,o.jsxs)("div",{style:{position:"absolute",bottom:"40px",left:"44px",zIndex:10,backgroundColor:d.surface,border:`1px solid ${d.primary}44`,borderRadius:"8px",overflow:"hidden",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",minWidth:"180px"},children:[(0,o.jsx)("div",{style:{padding:"4px 10px 4px",fontSize:"10px",color:d.primary,fontWeight:700,borderBottom:`1px solid ${H}`,letterSpacing:"0.05em"},children:"⚛ Quantum Suggestions"}),x.map(e=>(0,o.jsxs)("button",{onClick:()=>_(e.name),style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"6px 10px",border:"none",backgroundColor:"transparent",color:d.text,fontSize:"12px",fontFamily:'"Fira Code", monospace',cursor:"pointer",textAlign:"left",gap:"12px"},children:[(0,o.jsx)("span",{children:e.name}),(0,o.jsxs)("span",{style:{fontSize:"10px",color:d.textMuted,flexShrink:0},children:[Math.round(100*e.amplitude),"%"]})]},e.name))]})]}),(0,o.jsxs)("div",{style:{width:"50%",display:"flex",flexDirection:"column"},children:[(0,o.jsx)("div",{style:{padding:"6px 10px",borderBottom:`1px solid ${H}`,backgroundColor:d.surface,fontSize:"11px",color:d.textMuted,fontWeight:600},children:"Preview"}),(0,o.jsx)("div",{style:{flex:1,overflow:"auto",backgroundColor:N,position:"relative"},children:E?(0,o.jsxs)("div",{style:{padding:"16px",color:d.danger,fontFamily:'"Fira Code", monospace',fontSize:"12px",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[(0,o.jsxs)("div",{style:{marginBottom:"8px",fontWeight:700,display:"flex",alignItems:"center",gap:"6px"},children:[(0,o.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),"Runtime Error"]}),D]}):(0,o.jsx)(R,{onError:y,children:(0,o.jsx)("div",{style:{minHeight:"100%"},children:g.element})})})]})]}),(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"16px",padding:"4px 12px",backgroundColor:O,borderTop:`1px solid ${H}`,fontSize:"11px",color:d.textMuted},children:[(0,o.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"4px",color:E?d.danger:d.success,fontWeight:600},children:[(0,o.jsx)("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:E?d.danger:d.success,display:"inline-block"}}),E?"Error":"OK"]}),(0,o.jsxs)("span",{children:["⏱ ",g.renderMs," ms"]}),(0,o.jsxs)("span",{children:[h.split("\n").length," lines"]}),(0,o.jsxs)("span",{children:[h.length," chars"]}),x.length>0&&(0,o.jsxs)("span",{style:{marginLeft:"auto",color:d.primary,fontWeight:600},children:["⚛ ",x.length," suggestion",x.length>1?"s":""]})]})]})}P.displayName="TkxPlayground",exports.AmplitudeAmplifier=c,exports.QuantumAI=x,exports.QuantumAnnealer=s,exports.QuantumBoltzmannMachine=d,exports.QuantumRegister=l,exports.Qubit=a,exports.TkxPlayground=P,exports.TkxQuantumForm=C,exports.TkxThemeBuilder=function({onThemeChange:e,initialHue:i=210,initialMode:a="dark"}){const l=t.useTheme(),[s,d]=(0,r.useState)(a),[c,p]=(0,r.useState)(i),[h,u]=(0,r.useState)(()=>M("dark"===a)),[g,m]=(0,r.useState)(!1),[f,y]=(0,r.useState)([]),[b,v]=(0,r.useState)(!1),k=(0,r.useRef)(null),w="dark"===s,S=(0,r.useCallback)((t,n)=>{u(r=>{const o={...r,[t]:n};return e?.(o),o})},[e]),C=(0,r.useCallback)(()=>{if(g)return;m(!0),y([]);let t=0;const n=[],r=()=>{t+=60,x.optimizeTheme(c,w,t);const o=t/600,i=50*(1-o)+2,a=8*(Math.random()-.5)*(1-.8*o);if(n.push({iteration:t,energy:Math.max(0,i+a)}),y([...n]),t<600)k.current=window.setTimeout(r,40);else{const t=x.optimizeTheme(c,w,1e3);u(t),e?.(t),m(!1)}};k.current=window.setTimeout(r,16)},[c,w,g,e]),A=(0,r.useCallback)(()=>{const t="dark"===s?"light":"dark";d(t);const n=M("dark"===t);u(n),e?.(n)},[s,e]),W=(0,r.useCallback)(()=>{const e=`export const myTheme = {\n${Object.entries(h).map(([e,t])=>` ${e}: '${t}',`).join("\n")}\n};`;"undefined"!=typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(e).then(()=>{v(!0),setTimeout(()=>v(!1),2e3)})},[h]),R=[{label:"Text on Background",fg:h.text,bg:h.background},{label:"Text on Surface",fg:h.text,bg:h.surface},{label:"Primary on Background",fg:h.primary,bg:h.background},{label:"TextMuted on Background",fg:h.textMuted,bg:h.background}],B="linear-gradient(to right,"+["hsl(0,80%,55%)","hsl(30,80%,55%)","hsl(60,80%,55%)","hsl(90,80%,55%)","hsl(120,80%,55%)","hsl(150,80%,55%)","hsl(180,80%,55%)","hsl(210,80%,55%)","hsl(240,80%,55%)","hsl(270,80%,55%)","hsl(300,80%,55%)","hsl(330,80%,55%)","hsl(360,80%,55%)"].join(",")+")",F={fontFamily:"system-ui, -apple-system, sans-serif",background:h.background,color:h.text,border:`1px solid ${h.border}`,borderRadius:12,padding:20,maxWidth:900,display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},L={background:h.surface,border:`1px solid ${h.border}`,borderRadius:8,padding:16},I={fontSize:13,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:h.primary,marginBottom:12,marginTop:0},P={padding:"8px 16px",borderRadius:8,border:"none",cursor:"pointer",fontWeight:600,fontSize:13,transition:"opacity 0.15s"},q=n.tkx;return(0,o.jsxs)("div",{style:F,children:[(0,o.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gridColumn:"1/-1"},children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("h2",{style:{margin:0,fontSize:18,fontWeight:700},children:"Theme Builder"}),(0,o.jsx)("p",{style:{margin:"2px 0 0",fontSize:12,color:h.textMuted},children:"Quantum-powered color optimization"})]}),(0,o.jsx)("button",{onClick:A,style:{...P,background:h.surface,color:h.text,border:`1px solid ${h.border}`},children:w?"☀ Light":"🌙 Dark"})]}),(0,o.jsxs)("div",{style:L,children:[(0,o.jsx)("p",{style:I,children:"Base Hue"}),(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,o.jsx)("div",{style:{width:24,height:24,borderRadius:"50%",background:`hsl(${c},70%,55%)`,border:`2px solid ${h.border}`,flexShrink:0}}),(0,o.jsx)("input",{type:"range",min:0,max:360,value:c,onChange:e=>p(Number(e.target.value)),style:{flex:1,height:16,borderRadius:8,background:B,outline:"none",border:"none",cursor:"pointer",appearance:"none",WebkitAppearance:"none"}}),(0,o.jsxs)("span",{style:{fontSize:13,fontFamily:"monospace",minWidth:32},children:[c,"°"]})]})]}),(0,o.jsxs)("div",{style:L,children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[(0,o.jsx)("button",{onClick:C,disabled:g,style:{...P,background:g?h.border:h.primary,color:w?"#000":"#fff",opacity:g?.7:1,flex:1},children:g?"⟳ Optimizing...":"⚛ Generate with Quantum Annealing"}),(0,o.jsx)("div",{style:{padding:"3px 8px",background:h.primary+"22",border:`1px solid ${h.primary}44`,borderRadius:20,fontSize:10,color:h.primary,fontWeight:700,whiteSpace:"nowrap"},children:"⚛ Quantum Annealing"})]}),(g||f.length>0)&&(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{style:{fontSize:11,color:h.textMuted,margin:"0 0 4px"},children:"Energy landscape (lower = better palette)"}),(0,o.jsx)(z,{points:f,primary:h.primary})]})]}),(0,o.jsxs)("div",{style:L,children:[(0,o.jsx)("p",{style:I,children:"Color Tokens"}),Object.keys(h).map(e=>(0,o.jsx)(T,{label:e,value:h[e],onChange:t=>S(e,t),text:h.text,border:h.border},e))]}),(0,o.jsx)("button",{onClick:W,style:{...P,background:h.accent,color:"#fff",width:"100%"},children:b?"✓ Copied to Clipboard!":"⬇ Export Theme"})]}),(0,o.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,o.jsxs)("div",{style:L,children:[(0,o.jsx)("p",{style:I,children:"Live Preview"}),(0,o.jsxs)("div",{style:{marginBottom:12},children:[(0,o.jsx)("p",{style:{fontSize:11,color:h.textMuted,margin:"0 0 6px"},children:"Buttons"}),(0,o.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,o.jsx)("button",{style:{padding:"8px 16px",borderRadius:8,border:"none",background:h.primary,color:w?"#000":"#fff",fontWeight:600,fontSize:13,cursor:"pointer"},children:"Primary"}),(0,o.jsx)("button",{style:{padding:"8px 16px",borderRadius:8,border:"none",background:h.secondary,color:"#fff",fontWeight:600,fontSize:13,cursor:"pointer"},children:"Secondary"}),(0,o.jsx)("button",{style:{padding:"8px 16px",borderRadius:8,border:`1px solid ${h.border}`,background:"transparent",color:h.text,fontWeight:600,fontSize:13,cursor:"pointer"},children:"Outline"})]})]}),(0,o.jsxs)("div",{style:{marginBottom:12},children:[(0,o.jsx)("p",{style:{fontSize:11,color:h.textMuted,margin:"0 0 6px"},children:"Card"}),(0,o.jsxs)("div",{style:{background:h.surface,border:`1px solid ${h.border}`,borderRadius:8,padding:12},children:[(0,o.jsx)("div",{style:{fontSize:14,fontWeight:700,marginBottom:4},children:"Card Title"}),(0,o.jsx)("div",{style:{fontSize:12,color:h.textMuted,lineHeight:1.4},children:"Sample card with surface background and muted text content."}),(0,o.jsxs)("div",{style:{marginTop:8,display:"flex",gap:6},children:[(0,o.jsx)("span",{style:{padding:"2px 8px",borderRadius:20,background:h.primary+"33",color:h.primary,fontSize:11,fontWeight:600},children:"Tag"}),(0,o.jsx)("span",{style:{padding:"2px 8px",borderRadius:20,background:h.accent+"33",color:h.accent,fontSize:11,fontWeight:600},children:"Accent"})]})]})]}),(0,o.jsxs)("div",{style:{marginBottom:12},children:[(0,o.jsx)("p",{style:{fontSize:11,color:h.textMuted,margin:"0 0 6px"},children:"Input"}),(0,o.jsx)("input",{type:"text",placeholder:"Type something...",readOnly:!0,style:{width:"100%",padding:"8px 12px",borderRadius:8,border:`1px solid ${h.border}`,background:h.background,color:h.text,fontSize:13,outline:"none",boxSizing:"border-box"}})]}),(0,o.jsxs)("div",{style:{marginBottom:12},children:[(0,o.jsx)("p",{style:{fontSize:11,color:h.textMuted,margin:"0 0 6px"},children:"Progress"}),(0,o.jsx)("div",{style:{height:8,borderRadius:4,background:h.border,overflow:"hidden"},children:(0,o.jsx)("div",{style:{height:"100%",width:"68%",background:`linear-gradient(to right, ${h.primary}, ${h.accent})`,borderRadius:4,transition:"width 0.4s ease"}})})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{style:{fontSize:11,color:h.textMuted,margin:"0 0 6px"},children:"Status Badges"}),(0,o.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[{label:"Error",color:h.error},{label:"Warning",color:h.warning},{label:"Success",color:h.success}].map(({label:e,color:t})=>(0,o.jsx)("span",{style:{padding:"3px 10px",borderRadius:4,background:t+"22",color:t,border:`1px solid ${t}44`,fontSize:11,fontWeight:700},children:e},e))})]})]}),(0,o.jsxs)("div",{style:L,children:[(0,o.jsx)("p",{style:I,children:"WCAG Contrast Check"}),R.map(e=>(0,o.jsx)($,{label:e.label,ratio:x.contrast(e.fg,e.bg)},e.label)),(0,o.jsx)("p",{style:{fontSize:10,color:h.textMuted,marginTop:8,marginBottom:0},children:"AA requires 4.5:1 (normal text). AAA requires 7:1."})]}),(0,o.jsxs)("div",{style:L,children:[(0,o.jsx)("p",{style:I,children:"Color Palette"}),(0,o.jsx)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:Object.entries(h).map(([e,t])=>(0,o.jsx)("div",{title:`${e}: ${t}`,style:{width:36,height:36,borderRadius:6,background:t,border:`2px solid ${h.border}`,cursor:"default",flexShrink:0}},e))})]})]}),"function"==typeof q&&null,"string"==typeof l.bg&&null]})},exports.hslToHex=u,exports.inferFieldIntelligence=h,exports.optimizeThemeColors=y;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunk-DmRB1Blb.js"),t=require("./chunk-BpuJ3-K8.js"),n=require("./chunk-D7-yknXg.js");let r=require("react");r=e.__toESM(r,1);let o=require("react/jsx-runtime");var i=class e{constructor(e,t){this.re=e,this.im=t}add(t){return new e(this.re+t.re,this.im+t.im)}sub(t){return new e(this.re-t.re,this.im-t.im)}mul(t){return new e(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)}scale(t){return new e(this.re*t,this.im*t)}conjugate(){return new e(this.re,-this.im)}magnitudeSquared(){return this.re*this.re+this.im*this.im}magnitude(){return Math.sqrt(this.magnitudeSquared())}static fromPolar(t,n){return new e(t*Math.cos(n),t*Math.sin(n))}static zero(){return new e(0,0)}static one(){return new e(1,0)}},a=class e{constructor(e=i.one(),t=i.zero()){this.alpha=e,this.beta=t,this.normalize()}normalize(){const e=Math.sqrt(this.alpha.magnitudeSquared()+this.beta.magnitudeSquared());e>0&&(this.alpha=this.alpha.scale(1/e),this.beta=this.beta.scale(1/e))}hadamard(){const t=1/Math.SQRT2;return new e(this.alpha.add(this.beta).scale(t),this.alpha.sub(this.beta).scale(t))}ry(t){const n=Math.cos(t/2),r=Math.sin(t/2);return new e(this.alpha.scale(n).sub(this.beta.scale(r)),this.alpha.scale(r).add(this.beta.scale(n)))}phase(t){const n=i.fromPolar(1,t);return new e(this.alpha,this.beta.mul(n))}measure(){const e=this.beta.magnitudeSquared();return Math.random()<e?1:0}expectation(){return this.beta.magnitudeSquared()}getAlpha(){return this.alpha}getBeta(){return this.beta}},l=class{constructor(e){this.qubits=Array.from({length:e},()=>new a)}get size(){return this.qubits.length}getQubit(e){return this.qubits[e]}superpose(){this.qubits=this.qubits.map(e=>e.hadamard())}cnot(e,t){const n=this.qubits[e],r=this.qubits[t],o=n.expectation();this.qubits[t]=r.ry(Math.PI*o)}rotate(e,t){this.qubits[e]=this.qubits[e].ry(t)}measure(){return this.qubits.map(e=>e.measure())}probs(){return this.qubits.map(e=>e.expectation())}},s=class{constructor(e=1,t=.995,n=.3,r=1e-6){this.temperature=e,this.coolingRate=t,this.tunnelingStrength=n,this.minTemp=r}anneal(e,t,n,r=1e3){let o=e,i=t(o),a=o,l=i,s=this.temperature,d=0,c=0;for(let p=0;p<r&&s>this.minTemp;p++){const e=n(o),r=t(e),p=r-i;let h=!1;if(p<=0)h=!0;else{const e=Math.exp(-p/s),t=Math.sqrt(2*Math.abs(p)),n=Math.abs(p),r=Math.exp(-2*t*Math.sqrt(n)*this.tunnelingStrength);Math.random()<e+r&&(h=!0,Math.random()<r/(e+r+1e-10)&&c++)}h&&(o=e,i=r,d++,i<l&&(a=o,l=i)),s*=this.coolingRate}return{state:a,energy:l,iterations:r,accepted:d,tunnels:c}}},d=class{constructor(e,t){const n=Math.sqrt(2/(e+t));this.weights=Array.from({length:e},()=>Array.from({length:t},()=>(2*Math.random()-1)*n)),this.visibleBias=Array.from({length:e},()=>0),this.hiddenBias=Array.from({length:t},()=>0)}sigmoid(e){const t=.1*(Math.random()-.5);return 1/(1+Math.exp(-(e+t)))}sample(e){return Math.random()<e?1:0}energy(e,t){const n=this.visibleBias.reduce((t,n,r)=>t+n*e[r],0),r=this.hiddenBias.reduce((e,n,r)=>e+n*t[r],0);let o=0;for(let i=0;i<e.length;i++)for(let n=0;n<t.length;n++)o+=e[i]*this.weights[i][n]*t[n];return-(n+r+o)}hiddenProbs(e){return this.hiddenBias.map((t,n)=>{const r=t+e.reduce((e,t,r)=>e+this.weights[r][n]*t,0);return this.sigmoid(r)})}visibleProbs(e){return this.visibleBias.map((t,n)=>{const r=t+e.reduce((e,t,r)=>e+this.weights[n][r]*t,0);return this.sigmoid(r)})}gibbs(e,t=1){let n=[...e],r=[];for(let o=0;o<t;o++)r=this.hiddenProbs(n).map(e=>this.sample(e)),n=this.visibleProbs(r).map(e=>this.sample(e));return{visible:n,hidden:r}}trainCD1(e,t=.01){const n=this.visibleBias.length,r=this.hiddenBias.length,o=Array.from({length:n},()=>Array(r).fill(0)),i=Array(n).fill(0),a=Array(r).fill(0);for(const s of e){const e=this.hiddenProbs(s),t=e.map(e=>this.sample(e)),l=this.visibleProbs(t).map(e=>this.sample(e)),d=this.hiddenProbs(l);for(let a=0;a<n;a++){for(let t=0;t<r;t++)o[a][t]+=s[a]*e[t]-l[a]*d[t];i[a]+=s[a]-l[a]}for(let n=0;n<r;n++)a[n]+=e[n]-d[n]}const l=e.length;for(let s=0;s<n;s++){for(let e=0;e<r;e++)this.weights[s][e]+=t*o[s][e]/l;this.visibleBias[s]+=t*i[s]/l}for(let s=0;s<r;s++)this.hiddenBias[s]+=t*a[s]/l}infer(e){const t=this.hiddenProbs(e),n=t.map(e=>this.sample(e));return{hidden:t,visible:this.visibleProbs(n),energy:this.energy(e,n),iterations:1}}},c=class{amplify(e,t,n=.5){const r=e.length;if(0===r)return[];const o=e.map(t),i=o.filter(e=>e>n).length,a=Math.max(1,i);let l=Array(r).fill(1/Math.sqrt(r));const s=Math.max(1,Math.floor(Math.PI/4*Math.sqrt(r/a)));for(let d=0;d<s;d++){for(let t=0;t<r;t++)o[t]>n&&(l[t]=-l[t]);const e=l.reduce((e,t)=>e+t,0)/r;l=l.map(t=>2*e-t)}return e.map((e,t)=>({index:t,amplitude:l[t],probability:l[t]*l[t],classicalSimilarity:o[t],combined:l[t]*l[t]*.6+.4*o[t]})).sort((e,t)=>t.combined-e.combined)}},p=[{keywords:["email","e-mail","mail"],type:"email",validations:[{rule:"required",message:"Email is required"},{rule:"pattern",value:"^[^@]+@[^@]+\\.[^@]+$",message:"Enter a valid email address"},{rule:"maxLength",value:254,message:"Email too long"}],placeholder:"you@example.com",label:"Email Address",confidence:.98},{keywords:["password","passwd","pwd","pass"],type:"password",validations:[{rule:"required",message:"Password is required"},{rule:"minLength",value:8,message:"Password must be at least 8 characters"},{rule:"pattern",value:"(?=.*[A-Z])(?=.*[0-9])",message:"Include uppercase and a number"}],placeholder:"••••••••",label:"Password",confidence:.97},{keywords:["confirm_password","confirmpassword","confirm_pass","repassword","password2","repeat_password"],type:"password",validations:[{rule:"required",message:"Please confirm your password"},{rule:"match",value:"password",message:"Passwords do not match"}],placeholder:"••••••••",label:"Confirm Password",confidence:.95},{keywords:["phone","mobile","cell","tel","telephone","contact_number"],type:"tel",validations:[{rule:"pattern",value:"^[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,6}$",message:"Enter a valid phone number"}],placeholder:"+1 (555) 000-0000",label:"Phone Number",confidence:.93},{keywords:["age"],type:"number",validations:[{rule:"min",value:0,message:"Age cannot be negative"},{rule:"max",value:150,message:"Enter a valid age"},{rule:"integer",message:"Age must be a whole number"}],placeholder:"25",label:"Age",confidence:.9},{keywords:["price","amount","cost","fee","payment","salary","wage","total"],type:"number",validations:[{rule:"min",value:0,message:"Amount cannot be negative"},{rule:"pattern",value:"^\\d+(\\.\\d{1,2})?$",message:"Enter a valid amount (e.g. 9.99)"}],placeholder:"0.00",label:"Amount",confidence:.88},{keywords:["url","website","site","link","homepage","web"],type:"url",validations:[{rule:"pattern",value:"https?://.+",message:"Enter a valid URL starting with http:// or https://"}],placeholder:"https://example.com",label:"Website URL",confidence:.92},{keywords:["zip","zipcode","postal","postcode","pin_code"],type:"text",validations:[{rule:"pattern",value:"^[0-9]{5}(-[0-9]{4})?$",message:"Enter a valid ZIP code (e.g. 12345)"}],placeholder:"12345",label:"ZIP / Postal Code",confidence:.91},{keywords:["date","dob","birthday","birth_date","birthdate","born"],type:"date",validations:[{rule:"required",message:"Date is required"}],placeholder:"YYYY-MM-DD",label:"Date of Birth",confidence:.89},{keywords:["first_name","firstname","fname","given_name"],type:"text",validations:[{rule:"minLength",value:2,message:"First name too short"},{rule:"maxLength",value:50,message:"First name too long"}],placeholder:"Jane",label:"First Name",confidence:.9},{keywords:["last_name","lastname","lname","surname","family_name"],type:"text",validations:[{rule:"minLength",value:2,message:"Last name too short"},{rule:"maxLength",value:50,message:"Last name too long"}],placeholder:"Doe",label:"Last Name",confidence:.9},{keywords:["name","full_name","fullname","display_name"],type:"text",validations:[{rule:"minLength",value:2,message:"Name too short"},{rule:"maxLength",value:100,message:"Name too long"}],placeholder:"Jane Doe",label:"Full Name",confidence:.85},{keywords:["username","user_name","handle","login","loginname"],type:"text",validations:[{rule:"minLength",value:3,message:"Username must be at least 3 characters"},{rule:"maxLength",value:32,message:"Username too long"},{rule:"pattern",value:"^[a-zA-Z0-9_.-]+$",message:"Only letters, numbers, _, - and . allowed"}],placeholder:"cooluser42",label:"Username",confidence:.94},{keywords:["bio","biography","about","description","summary","details"],type:"textarea",validations:[{rule:"maxLength",value:500,message:"Bio must be under 500 characters"}],placeholder:"Tell us about yourself...",label:"Bio",confidence:.87},{keywords:["message","comment","feedback","note","notes","remarks","body"],type:"textarea",validations:[{rule:"minLength",value:10,message:"Message too short"},{rule:"maxLength",value:2e3,message:"Message too long"}],placeholder:"Write your message here...",label:"Message",confidence:.86},{keywords:["search","query","q","keyword","find"],type:"search",validations:[],placeholder:"Search...",label:"Search",confidence:.9},{keywords:["otp","one_time_password","verification_code","pin","code"],type:"text",validations:[{rule:"minLength",value:4,message:"Code too short"},{rule:"maxLength",value:8,message:"Code too long"},{rule:"pattern",value:"^[0-9]+$",message:"Code must be numeric"}],placeholder:"123456",label:"Verification Code",confidence:.92},{keywords:["color","colour","hex_color","brand_color"],type:"color",validations:[],placeholder:"#3b82f6",label:"Color",confidence:.95},{keywords:["address","street","street_address","addr"],type:"text",validations:[{rule:"maxLength",value:200,message:"Address too long"}],placeholder:"123 Main Street",label:"Street Address",confidence:.87},{keywords:["city","town","municipality"],type:"text",validations:[{rule:"maxLength",value:100,message:"City name too long"}],placeholder:"San Francisco",label:"City",confidence:.89},{keywords:["country","nation","country_code"],type:"text",validations:[],placeholder:"United States",label:"Country",confidence:.88},{keywords:["company","organization","org","employer","company_name"],type:"text",validations:[{rule:"maxLength",value:200,message:"Company name too long"}],placeholder:"Acme Inc.",label:"Company",confidence:.87}];function h(e){const t=e.toLowerCase().replace(/[\s-]/g,"_"),n=(new c).amplify(p,e=>{let n=0;for(const r of e.keywords)t===r?n=Math.max(n,1):t.includes(r)||r.includes(t)?n=Math.max(n,.8):r.split("_").some(e=>t.includes(e))&&(n=Math.max(n,.5));return n},.3);if(n.length>0&&n[0].combined>.1){const e=p[n[0].index];return{type:e.type,validations:e.validations,placeholder:e.placeholder,confidence:Math.min(e.confidence*n[0].combined*2,.99),label:e.label}}return{type:"text",validations:[{rule:"maxLength",value:255,message:"Input too long"}],placeholder:e.replace(/_/g," "),confidence:.3,label:e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}}function u(e,t,n){const r=n/100,o=t/100*Math.min(r,1-r),i=t=>{const n=(t+e/30)%12,i=r-o*Math.max(Math.min(n-3,9-n,1),-1);return Math.round(255*i).toString(16).padStart(2,"0")};return`#${i(0)}${i(8)}${i(4)}`}function g(e){const[t,n,r]=function(e){const t=e.replace("#",""),n=3===t.length?t.split("").map(e=>e+e).join(""):t;return[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}(e).map(e=>{const t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return.2126*t+.7152*n+.0722*r}function m(e,t){const n=g(e),r=g(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function f(e,t,n){return Math.max(t,Math.min(n,e))}function y(e,t,n=800){const r=t?{primary:{h:e,s:70,l:55},secondary:{h:(e+137.5)%360,s:65,l:50},bg:{h:e,s:10,l:8},surface:{h:e,s:10,l:13},text:{h:e,s:15,l:90},border:{h:e,s:15,l:22},accent:{h:(e+120)%360,s:75,l:60}}:{primary:{h:e,s:65,l:40},secondary:{h:(e+137.5)%360,s:55,l:38},bg:{h:e,s:15,l:97},surface:{h:e,s:12,l:100},text:{h:e,s:15,l:12},border:{h:e,s:12,l:85},accent:{h:(e+120)%360,s:70,l:42}};return function(e,t){const n=e=>u(e.h,e.s,e.l),r=t?e.text.l-20:e.text.l+15;return{primary:n(e.primary),secondary:n(e.secondary),background:n(e.bg),surface:n(e.surface),text:n(e.text),textMuted:u(e.text.h,Math.max(0,e.text.s-10),Math.max(20,Math.min(85,r))),border:n(e.border),error:t?"#f87171":"#dc2626",warning:t?"#fbbf24":"#d97706",success:t?"#34d399":"#059669",accent:n(e.accent)}}(new s(1.5,.994,.35,1e-5).anneal(r,e=>function(e,t){let n=0;const r=e=>u(e.h,e.s,e.l),o=r(e.text),i=r(e.bg),a=r(e.surface),l=r(e.primary),s=m(o,i),d=m(o,a),c=m(l,i);s<4.5&&(n+=10*(4.5-s)),d<4.5&&(n+=8*(4.5-d)),c<3&&(n+=5*(3-c)),n+=.05*Math.abs((e.secondary.h-e.primary.h+360)%360-137.508),n+=.03*Math.abs((e.accent.h-e.primary.h+360)%360-120);const p=(e.primary.s+e.secondary.s)/2;p<20&&(n+=.5*(20-p)),p>90&&(n+=.5*(p-90));const h=e.bg.l;t?(h>25&&(n+=2*(h-25)),h<3&&(n+=2*(3-h)),e.text.l<70&&(n+=1.5*(70-e.text.l))):(h<90&&(n+=2*(90-h)),h>100&&(n+=2*(h-100)),e.text.l>30&&(n+=1.5*(e.text.l-30)));const g=Math.abs(e.surface.l-e.bg.l);return g<2&&(n+=2*(2-g)),g>12&&(n+=1*(g-12)),n}(e,t),e=>{const t=["primary","secondary","bg","surface","text","border","accent"],n=t[Math.floor(Math.random()*t.length)],r=["h","s","l"],o=r[Math.floor(Math.random()*r.length)],i=(Math.random()-.5)*("h"===o?30:15),a={...e,[n]:{...e[n]}};return a[n]="h"===o?{...a[n],h:(e[n].h+i+360)%360}:"s"===o?{...a[n],s:f(e[n].s+i,0,100)}:{...a[n],l:f(e[n].l+i,0,100)},a},n).state,t)}var x={qubit:()=>new a,register:e=>new l(e),annealer:(e,t,n)=>new s(e,t,n),qbm:(e,t)=>new d(e,t),amplifier:()=>new c,inferField:h,optimizeTheme:y,contrast:m,hslToHex:u};function b(e,t,n,r){const o=n.trim();switch(e){case"required":return""!==o;case"email":case"pattern":if("string"==typeof t)try{return""===o||new RegExp(t).test(o)}catch{return!0}return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o);case"phone":return""===o||/^\+?[\d\s\-()]{7,15}$/.test(o);case"url":return""===o||/^https?:\/\/.+/.test(o);case"minLength":case"min":{const e=Number(t??0);return""===o||(isNaN(Number(o))?o.length>=e:Number(o)>=e)}case"maxLength":case"max":{const e=Number(t??1/0);return""===o||(isNaN(Number(o))?o.length<=e:Number(o)<=e)}case"integer":return""===o||/^\d+$/.test(o);case"alphanumeric":return""===o||/^[a-zA-Z0-9]+$/.test(o);case"match":return o===(r["string"==typeof t?t:"password"]??"");default:return!0}}function v({phase:e,collapsed:t,primaryColor:n,borderColor:r}){const i=12,a=t?0:e,l=t?0:1.618*e,s=i+10*Math.sin(a)*Math.cos(l),d=12-10*Math.cos(a);return(0,o.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24","aria-hidden":"true",style:{flexShrink:0,opacity:t?.4:1,transition:"opacity 0.6s"},children:[(0,o.jsx)("circle",{cx:i,cy:12,r:10,fill:"none",stroke:r,strokeWidth:"0.8"}),(0,o.jsx)("ellipse",{cx:i,cy:12,rx:10,ry:3,fill:"none",stroke:r,strokeWidth:"0.5",strokeDasharray:"2 2"}),(0,o.jsx)("line",{x1:i,y1:2,x2:i,y2:22,stroke:r,strokeWidth:"0.5"}),(0,o.jsx)("line",{x1:i,y1:12,x2:s,y2:d,stroke:n,strokeWidth:"1.5",style:{transition:t?"all 0.6s ease-out":"none"}}),(0,o.jsx)("circle",{cx:s,cy:d,r:"2",fill:n,style:{transition:t?"all 0.6s ease-out":"none"}})]})}function k({confidence:e,theme:t}){const n=Math.round(100*e),r=n>=80?t.success:n>=60?t.warning:t.danger;return(0,o.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:"2px",fontSize:"10px",fontWeight:600,padding:"1px 5px",borderRadius:"999px",backgroundColor:`${r}22`,color:r,border:`1px solid ${r}44`,marginLeft:"6px",verticalAlign:"middle",letterSpacing:"0.03em"},children:["⚛ ",n,"%"]})}function w({config:e,intel:t,qubitPhase:r,value:i,error:a,touched:l,showConfidence:s,showQuantumState:d,collapsed:c,onChange:p,onBlur:h,theme:u,mounted:g,index:m}){const f=e.type??t.type,y=e.label??t.label,x=e.placeholder??t.placeholder,b=void 0!==e.required?e.required:t.validations.some(e=>"required"===e.rule),w=n.sanitizeString(y),S="textarea"===f,C=l&&""!==a,M=`qf-${e.name}`,z={width:"100%",padding:"9px 12px",border:`1.5px solid ${C?u.danger:u.border}`,borderRadius:"8px",backgroundColor:u.surface,color:u.text,fontSize:"14px",fontFamily:"inherit",outline:"none",boxSizing:"border-box",transition:"border-color 0.15s, box-shadow 0.15s",resize:S?"vertical":void 0,minHeight:S?"80px":void 0};return(0,o.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"4px",opacity:g?1:0,transform:g?"scaleY(1)":"scaleY(0.92)",transition:`opacity 0.35s ease ${60*m}ms, transform 0.35s ease ${60*m}ms`,transformOrigin:"top"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[d&&(0,o.jsx)(v,{phase:r,collapsed:c,primaryColor:u.primary,borderColor:u.border}),(0,o.jsxs)("label",{htmlFor:M,style:{fontSize:"13px",fontWeight:500,color:u.text,cursor:"pointer"},children:[w,b&&(0,o.jsx)("span",{"aria-hidden":"true",style:{color:u.danger,marginLeft:"3px"},children:"*"})]}),s&&(0,o.jsx)(k,{confidence:t.confidence,theme:u})]}),S?(0,o.jsx)("textarea",{id:M,value:i,onChange:e=>p(e.target.value),onBlur:h,placeholder:x,"aria-invalid":C,"aria-required":b,style:z}):(0,o.jsx)("input",{id:M,type:f,value:i,onChange:e=>p(e.target.value),onBlur:h,placeholder:x,"aria-invalid":C,"aria-required":b,style:z}),C&&(0,o.jsxs)("span",{role:"alert",style:{fontSize:"12px",color:u.danger,display:"flex",alignItems:"center",gap:"4px"},children:[(0,o.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),n.sanitizeString(a)]})]})}function S(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return(65535&t)/65535*Math.PI*2}function C({fields:e,onSubmit:i,submitLabel:a="Submit",layout:l="vertical",showConfidence:s=!0,showQuantumState:d=!1}){const c=t.useTheme(),p=e.map(e=>h(e.name)),[u,g]=(0,r.useState)(()=>Object.fromEntries(e.map(e=>[e.name,""]))),[m,f]=(0,r.useState)({}),[y,x]=(0,r.useState)({}),[v,k]=(0,r.useState)(!1),[C,M]=(0,r.useState)(!1),[z,T]=(0,r.useState)(!1);(0,r.useEffect)(()=>{const e=requestAnimationFrame(()=>M(!0));return()=>cancelAnimationFrame(e)},[]);const $=(0,r.useCallback)((t,n)=>{const r=e.find(e=>e.name===t),o=p[e.findIndex(e=>e.name===t)];if(!r||!o)return"";const i=n[t]??"";for(const{rule:e,value:a,message:l}of o.validations)if(("required"!==e||!1!==r.required)&&!b(e,a,i,n))return l;return""},[e]),A=(0,r.useCallback)(t=>{const n={};for(const r of e){const e=$(r.name,t);e&&(n[r.name]=e)}return n},[e,$]),W=(0,r.useCallback)((t,n)=>{g(r=>{const o={...r,[t]:n};if(y[t]&&(f(e=>({...e,[t]:$(t,o)})),"password"===t)){const t=e.find(e=>["confirmpassword","confirm_password","passwordconfirm"].includes(e.name.toLowerCase().replace(/[\s_-]/g,"")))?.name;t&&y[t]&&f(e=>({...e,[t]:$(t,o)}))}return o}),T(!0)},[e,y,$]),R=(0,r.useCallback)(e=>{x(t=>({...t,[e]:!0})),f(t=>({...t,[e]:$(e,u)}))},[u,$]),B=(0,r.useCallback)(async t=>{t.preventDefault(),x(Object.fromEntries(e.map(e=>[e.name,!0])));const n=A(u);if(f(n),!(Object.keys(n).length>0)){k(!0);try{await i(u)}finally{k(!1)}}},[e,u,A,i]),F=p.length>0?Math.round(p.reduce((e,t)=>e+t.confidence,0)/p.length*100):0,L=F>=80?c.success:F>=60?c.warning:c.danger,I="horizontal"===l;return(0,o.jsxs)("form",{onSubmit:B,noValidate:!0,className:n.tkx("w-full"),style:{backgroundColor:c.surface,border:`1px solid ${c.border}`,borderRadius:"12px",padding:"24px",position:"relative",boxSizing:"border-box"},children:[(0,o.jsx)("span",{"aria-label":"Powered by Quantum AI",style:{position:"absolute",top:"16px",right:"16px",fontSize:"10px",fontWeight:700,padding:"3px 8px",borderRadius:"999px",backgroundColor:`${c.primary}20`,color:c.primary,border:`1px solid ${c.primary}44`,letterSpacing:"0.04em",userSelect:"none"},children:"⚛ Quantum AI"}),s&&(0,o.jsxs)("div",{style:{marginBottom:"20px",paddingRight:"100px"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[(0,o.jsx)("span",{style:{fontSize:"11px",color:c.textMuted,fontWeight:500},children:"Form Intelligence Confidence"}),(0,o.jsxs)("span",{style:{fontSize:"11px",fontWeight:700,color:L},children:[F,"%"]})]}),(0,o.jsx)("div",{style:{height:"4px",borderRadius:"4px",backgroundColor:c.border,overflow:"hidden"},children:(0,o.jsx)("div",{style:{height:"100%",width:`${F}%`,backgroundColor:L,borderRadius:"4px",transition:"width 0.8s ease"}})})]}),(0,o.jsx)("div",{style:{display:"grid",gridTemplateColumns:I?"repeat(auto-fill, minmax(260px, 1fr))":"1fr",gap:"16px",marginBottom:"20px"},children:e.map((e,t)=>(0,o.jsx)(w,{config:e,intel:p[t],qubitPhase:S(e.name),value:u[e.name]??"",error:m[e.name]??"",touched:y[e.name]??!1,showConfidence:s,showQuantumState:d,collapsed:z,onChange:t=>W(e.name,t),onBlur:()=>R(e.name),theme:c,mounted:C,index:t},e.name))}),(0,o.jsx)("button",{type:"submit",disabled:v,style:{width:"100%",padding:"10px 20px",borderRadius:"8px",border:"none",backgroundColor:v?`${c.primary}88`:c.primary,color:c.bg,fontSize:"14px",fontWeight:700,fontFamily:"inherit",cursor:v?"not-allowed":"pointer",transition:"background-color 0.15s, opacity 0.15s",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:v?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",style:{animation:"qf-spin 0.8s linear infinite"},"aria-hidden":"true",children:[(0,o.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.25"}),(0,o.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})]}),"Processing…"]}):n.sanitizeString(a)}),(0,o.jsx)("style",{children:"@keyframes qf-spin { to { transform: rotate(360deg); } }"})]})}function M(e){return e?{primary:"#00f5d4",secondary:"#7b2ff7",background:"#0a0a0f",surface:"#12121a",text:"#e8e8f4",textMuted:"#8888aa",border:"#2a2a3e",error:"#f87171",warning:"#fbbf24",success:"#34d399",accent:"#ff6b6b"}:{primary:"#0d7c5f",secondary:"#6930c3",background:"#f8f6f1",surface:"#ffffff",text:"#1a1815",textMuted:"#6b6560",border:"#ddd8cc",error:"#dc2626",warning:"#d97706",success:"#059669",accent:"#e05a00"}}function z({points:e,primary:t}){if(e.length<2)return(0,o.jsx)("div",{style:{height:48,display:"flex",alignItems:"center",justifyContent:"center",color:"#888",fontSize:12},children:"Waiting for data..."});const n=Math.max(...e.map(e=>e.energy)),r=Math.min(...e.map(e=>e.energy)),i=n-r||1,a=e[e.length-1].iteration||1;return(0,o.jsxs)("svg",{width:280,height:48,style:{display:"block"},children:[(0,o.jsx)("polyline",{points:e.map(e=>{const t=e.iteration/a*280,n=48-(e.energy-r)/i*44-2;return`${t.toFixed(1)},${n.toFixed(1)}`}).join(" "),fill:"none",stroke:t,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.9}),(0,o.jsxs)("text",{x:2,y:10,fontSize:9,fill:"#888",children:["E=",n.toFixed(1)]}),(0,o.jsxs)("text",{x:2,y:46,fontSize:9,fill:"#888",children:["E=",r.toFixed(1)]})]})}function T({label:e,value:t,onChange:n,text:r,border:i}){return(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[(0,o.jsx)("input",{type:"color",value:t,onChange:e=>n(e.target.value),style:{width:32,height:32,border:`1px solid ${i}`,borderRadius:6,padding:2,cursor:"pointer",background:"transparent"}}),(0,o.jsx)("div",{style:{width:60,height:28,borderRadius:6,background:t,border:`1px solid ${i}`}}),(0,o.jsx)("span",{style:{flex:1,fontSize:13,color:r,fontFamily:"monospace"},children:e}),(0,o.jsx)("code",{style:{fontSize:12,color:r,opacity:.7,fontFamily:"monospace"},children:t})]})}function $({label:e,ratio:t}){const n=t>=4.5,r=t>=4.5,i=t>=7;return(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[(0,o.jsx)("span",{style:{fontSize:11,opacity:.8,minWidth:140},children:e}),(0,o.jsxs)("span",{style:{fontSize:12,fontWeight:600},children:[t.toFixed(2),":1"]}),(0,o.jsx)("span",{style:{fontSize:11,color:r?"#22c55e":"#ef4444"},children:r?"✓ AA":"✗ AA"}),(0,o.jsx)("span",{style:{fontSize:11,color:i?"#22c55e":"#888"},children:i?"✓ AAA":"— AAA"}),(0,o.jsx)("span",{style:{fontSize:13},children:n?"✅":"❌"})]})}C.displayName="TkxQuantumForm";var A=["fetch(","XMLHttpRequest","navigator.sendBeacon","document.cookie","localStorage","sessionStorage","indexedDB","WebSocket","EventSource","import(","eval(","new Function(","postMessage","window.open","location.href","location.replace","location.assign","document.write","crypto.subtle"],W=[{label:"Hello World",code:"<div style={{ padding: 24, fontFamily: 'sans-serif', color: '#e8e8f4' }}>\n <h2 style={{ margin: 0 }}>👋 Hello, TkxPlayground!</h2>\n <p style={{ marginTop: 8, opacity: 0.7 }}>Edit the code on the left to see live updates.</p>\n</div>"},{label:"Button Styles",code:"<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', padding: 24 }}>\n {['primary', 'success', 'danger', 'warning', 'info'].map(color => (\n <button\n key={color}\n style={{\n padding: '8px 18px',\n borderRadius: 8,\n border: 'none',\n background: color === 'primary' ? '#00f5d4' : color === 'success' ? '#06d6a0' : color === 'danger' ? '#f72585' : color === 'warning' ? '#ffbe0b' : '#3a86ff',\n color: '#0a0a0f',\n fontWeight: 700,\n cursor: 'pointer',\n textTransform: 'capitalize',\n }}\n >\n {color}\n </button>\n ))}\n</div>"},{label:"Card Grid",code:"<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 16, padding: 24 }}>\n {['Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta'].map(name => (\n <div key={name} style={{\n background: '#1a1a2e',\n borderRadius: 10,\n border: '1px solid #2a2a3e',\n padding: '16px',\n }}>\n <div style={{ fontWeight: 700, color: '#00f5d4', marginBottom: 4 }}>{name}</div>\n <div style={{ fontSize: 12, color: '#8888aa' }}>Quantum module {name.toLowerCase()}</div>\n </div>\n ))}\n</div>"},{label:"Animated Counter",code:"(() => {\n const [count, setCount] = React.useState(0);\n return (\n <div style={{ padding: 32, textAlign: 'center', fontFamily: 'sans-serif' }}>\n <div style={{ fontSize: 64, fontWeight: 900, color: '#00f5d4', marginBottom: 16 }}>\n {count}\n </div>\n <div style={{ display: 'flex', gap: 12, justifyContent: 'center' }}>\n <button onClick={() => setCount(c => c - 1)} style={{ padding: '8px 20px', borderRadius: 8, border: '1px solid #2a2a3e', background: '#1a1a2e', color: '#e8e8f4', fontSize: 20, cursor: 'pointer' }}>−</button>\n <button onClick={() => setCount(0)} style={{ padding: '8px 20px', borderRadius: 8, border: '1px solid #2a2a3e', background: '#1a1a2e', color: '#8888aa', cursor: 'pointer' }}>Reset</button>\n <button onClick={() => setCount(c => c + 1)} style={{ padding: '8px 20px', borderRadius: 8, border: '1px solid #2a2a3e', background: '#1a1a2e', color: '#e8e8f4', fontSize: 20, cursor: 'pointer' }}>+</button>\n </div>\n </div>\n );\n})()"},{label:"Data Table",code:"(() => {\n const rows = [\n { id: 1, name: 'Hydrogen', symbol: 'H', mass: 1.008 },\n { id: 2, name: 'Helium', symbol: 'He', mass: 4.003 },\n { id: 3, name: 'Lithium', symbol: 'Li', mass: 6.941 },\n { id: 4, name: 'Carbon', symbol: 'C', mass: 12.011 },\n { id: 5, name: 'Nitrogen', symbol: 'N', mass: 14.007 },\n ];\n const cell = { padding: '8px 14px', borderBottom: '1px solid #2a2a3e', color: '#e8e8f4', fontSize: 13 };\n const hcell = { ...cell, color: '#8888aa', fontWeight: 600, fontSize: 11, textTransform: 'uppercase', letterSpacing: '0.06em' };\n return (\n <div style={{ padding: 16 }}>\n <table style={{ width: '100%', borderCollapse: 'collapse', fontFamily: 'sans-serif' }}>\n <thead>\n <tr>{['ID','Element','Symbol','Atomic Mass'].map(h => <th key={h} style={hcell}>{h}</th>)}</tr>\n </thead>\n <tbody>\n {rows.map(r => (\n <tr key={r.id} style={{ transition: 'background 0.15s' }}>\n <td style={cell}>{r.id}</td>\n <td style={cell}>{r.name}</td>\n <td style={{ ...cell, color: '#00f5d4', fontWeight: 700 }}>{r.symbol}</td>\n <td style={cell}>{r.mass}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n})()"}],R=class extends r.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){this.props.onError(e.message)}componentDidUpdate(e){e.children!==this.props.children&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?null:this.props.children}};function B({code:e,lineHeight:t}){const n=e.split("\n");return(0,o.jsx)("div",{"aria-hidden":"true",style:{position:"absolute",top:0,left:0,width:"36px",padding:"12px 0",textAlign:"right",paddingRight:"8px",userSelect:"none",pointerEvents:"none",fontSize:"12px",lineHeight:`${t}px`,color:"#555577",fontFamily:'"Fira Code", "Cascadia Code", "Consolas", monospace',boxSizing:"border-box"},children:n.map((e,t)=>(0,o.jsx)("div",{children:t+1},t))})}var F=["TkxButton","TkxInput","TkxCard","TkxModal","TkxTable","TkxSelect","TkxCheckbox","TkxRadio","TkxSwitch","TkxSlider","TkxBadge","TkxAlert","TkxToast","TkxTooltip","TkxPopover","TkxTabs","TkxAccordion","TkxDrawer","TkxDropdown","TkxMenu","TkxForm","TkxDataGrid","TkxChart","TkxSpinner","TkxSkeleton","TkxAvatar","TkxTag","TkxDivider","TkxProgress","TkxStatistic","TkxQuantumForm","TkxPlayground"],L=new c;function I(e){const t=e.match(/([A-Z][a-zA-Z0-9]*)$/);return t?t[1]:""}function P({defaultCode:e,examples:n,height:i=480,imports:a={},strictMode:l=!0,forbiddenTokens:s}){const d=t.useTheme(),c=[...W,...n??[]],p=e??W[0].code,[h,u]=(0,r.useState)(p),[g,m]=(0,r.useState)({element:null,error:null,renderMs:0}),[f,y]=(0,r.useState)(null),[x,b]=(0,r.useState)([]),[v,k]=(0,r.useState)(!1),[w,S]=(0,r.useState)(0),C=(0,r.useRef)(null),M=(0,r.useRef)(null),z=(0,r.useCallback)(e=>{y(null),m(function(e,t,n){const o=performance.now();try{const i=e.trim();if(!1!==n?.strictMode){const e=function(e,t){const n=[...A,...t??[]],r=e.toLowerCase();for(const o of n)if(r.includes(o.toLowerCase()))return o;return null}(i,n?.forbiddenTokens);if(e)return{element:null,error:`Blocked by playground strictMode: code contains "${e}". This token is disallowed because playground snippets run in the page's JavaScript context. If you trust the source, pass strictMode={false} to <TkxPlayground>.`,renderMs:parseFloat((performance.now()-o).toFixed(2))}}let a=`\n function PlaygroundRoot() {\n ${i.startsWith("<")||i.startsWith("(")?`return (${i});`:i}\n }\n `;const l="undefined"==typeof window?null:window.Babel??null;l&&(a=l.transform(a,{presets:["react"],filename:"playground.jsx"}).code??a);const s=new Function("React","imports",`\n "use strict";\n const { ${Object.keys(t).join(", ")} } = imports;\n ${a}\n return PlaygroundRoot;\n `)(r.default,t);return{element:r.default.createElement(s),error:null,renderMs:parseFloat((performance.now()-o).toFixed(2))}}catch(i){const e=parseFloat((performance.now()-o).toFixed(2));return{element:null,error:i instanceof Error?i.message:String(i),renderMs:e}}}(e,a,{strictMode:l,forbiddenTokens:s}))},[a,l,s]);(0,r.useEffect)(()=>(M.current&&clearTimeout(M.current),M.current=setTimeout(()=>z(h),300),()=>{M.current&&clearTimeout(M.current)}),[h,z]),(0,r.useEffect)(()=>{z(p)},[]);const T=(0,r.useCallback)(e=>{const t=e.target.value;u(t);const n=I(t);n.length>=2?b(function(e,t=4){if(!e||e.length<2)return[];const n=e.toLowerCase();return L.amplify(F,e=>{const t=e.toLowerCase();if(t.startsWith(n))return 1;if(t.includes(n))return.7;let r=0;for(let o=0;o<n.length-1;o++)t.includes(n.slice(o,o+2))&&(r+=.15);return Math.min(r,.5)},.1).slice(0,t).map(e=>({name:F[e.index]??"",amplitude:parseFloat(e.combined.toFixed(3))})).filter(e=>""!==e.name)}(n,4)):b([])},[]),$=(0,r.useCallback)(e=>{const t=c[e];t&&(S(e),u(t.code),b([]))},[c]),P=(0,r.useCallback)(async()=>{try{await navigator.clipboard.writeText(h),k(!0),setTimeout(()=>k(!1),1500)}catch{}},[h]),q=(0,r.useCallback)(()=>{u(p),S(0),b([])},[p]),_=(0,r.useCallback)(e=>{const t=I(h);t&&u(n=>n.slice(0,n.lastIndexOf(t))+e),b([])},[h]),E=null!==g.error||null!==f,D=g.error??f??"",j=d.bg,N=d.surfaceAlt,H=d.border,O=d.surface,Q={width:"50%",display:"flex",flexDirection:"column",borderRight:`1px solid ${H}`,position:"relative"},Z={display:"flex",alignItems:"center",gap:"6px",padding:"6px 10px",borderBottom:`1px solid ${H}`,backgroundColor:d.surface,flexWrap:"wrap"},U={padding:"3px 10px",borderRadius:"6px",border:`1px solid ${H}`,backgroundColor:"transparent",color:d.textMuted,fontSize:"11px",fontWeight:600,cursor:"pointer",fontFamily:"inherit",transition:"color 0.15s, border-color 0.15s"};return(0,o.jsxs)("div",{style:{display:"flex",flexDirection:"column",border:`1px solid ${H}`,borderRadius:"12px",overflow:"hidden",backgroundColor:j,fontFamily:"inherit",boxSizing:"border-box",position:"relative"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",borderBottom:`1px solid ${H}`,backgroundColor:d.surface},children:[(0,o.jsx)("span",{style:{fontSize:"12px",fontWeight:700,color:d.primary,letterSpacing:"0.05em"},children:"⚛ TkxPlayground"}),(0,o.jsx)("span",{style:{fontSize:"10px",color:d.textMuted},children:"Live JSX Preview"})]}),(0,o.jsx)("div",{style:{display:"flex",gap:"4px",padding:"6px 10px",borderBottom:`1px solid ${H}`,backgroundColor:d.surface,overflowX:"auto"},children:c.map((e,t)=>(0,o.jsx)("button",{onClick:()=>$(t),style:{padding:"3px 10px",borderRadius:"6px",border:`1px solid ${t===w?d.primary:H}`,backgroundColor:t===w?`${d.primary}20`:"transparent",color:t===w?d.primary:d.textMuted,fontSize:"11px",fontWeight:t===w?700:400,cursor:"pointer",whiteSpace:"nowrap",fontFamily:"inherit",transition:"all 0.15s"},children:e.label},t))}),(0,o.jsxs)("div",{style:{display:"flex",height:`${i}px`},children:[(0,o.jsxs)("div",{style:Q,children:[(0,o.jsxs)("div",{style:Z,children:[(0,o.jsx)("span",{style:{fontSize:"11px",color:d.textMuted,marginRight:"auto"},children:"editor.tsx"}),(0,o.jsx)("button",{onClick:P,style:U,title:"Copy code",children:v?"✓ Copied":"⎘ Copy"}),(0,o.jsx)("button",{onClick:q,style:U,title:"Reset to default",children:"↺ Reset"})]}),(0,o.jsxs)("div",{style:{position:"relative",flex:1,overflow:"hidden"},children:[(0,o.jsx)(B,{code:h,lineHeight:18}),(0,o.jsx)("textarea",{ref:C,value:h,onChange:T,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",padding:"12px 12px 12px 44px",margin:0,border:"none",outline:"none",resize:"none",backgroundColor:j,color:d.text,fontSize:"12px",lineHeight:"18px",fontFamily:'"Fira Code", "Cascadia Code", "Consolas", "Courier New", monospace',boxSizing:"border-box",overflowY:"auto",tabSize:2}})]}),x.length>0&&(0,o.jsxs)("div",{style:{position:"absolute",bottom:"40px",left:"44px",zIndex:10,backgroundColor:d.surface,border:`1px solid ${d.primary}44`,borderRadius:"8px",overflow:"hidden",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",minWidth:"180px"},children:[(0,o.jsx)("div",{style:{padding:"4px 10px 4px",fontSize:"10px",color:d.primary,fontWeight:700,borderBottom:`1px solid ${H}`,letterSpacing:"0.05em"},children:"⚛ Quantum Suggestions"}),x.map(e=>(0,o.jsxs)("button",{onClick:()=>_(e.name),style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"6px 10px",border:"none",backgroundColor:"transparent",color:d.text,fontSize:"12px",fontFamily:'"Fira Code", monospace',cursor:"pointer",textAlign:"left",gap:"12px"},children:[(0,o.jsx)("span",{children:e.name}),(0,o.jsxs)("span",{style:{fontSize:"10px",color:d.textMuted,flexShrink:0},children:[Math.round(100*e.amplitude),"%"]})]},e.name))]})]}),(0,o.jsxs)("div",{style:{width:"50%",display:"flex",flexDirection:"column"},children:[(0,o.jsx)("div",{style:{padding:"6px 10px",borderBottom:`1px solid ${H}`,backgroundColor:d.surface,fontSize:"11px",color:d.textMuted,fontWeight:600},children:"Preview"}),(0,o.jsx)("div",{style:{flex:1,overflow:"auto",backgroundColor:N,position:"relative"},children:E?(0,o.jsxs)("div",{style:{padding:"16px",color:d.danger,fontFamily:'"Fira Code", monospace',fontSize:"12px",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[(0,o.jsxs)("div",{style:{marginBottom:"8px",fontWeight:700,display:"flex",alignItems:"center",gap:"6px"},children:[(0,o.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),"Runtime Error"]}),D]}):(0,o.jsx)(R,{onError:y,children:(0,o.jsx)("div",{style:{minHeight:"100%"},children:g.element})})})]})]}),(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"16px",padding:"4px 12px",backgroundColor:O,borderTop:`1px solid ${H}`,fontSize:"11px",color:d.textMuted},children:[(0,o.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"4px",color:E?d.danger:d.success,fontWeight:600},children:[(0,o.jsx)("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:E?d.danger:d.success,display:"inline-block"}}),E?"Error":"OK"]}),(0,o.jsxs)("span",{children:["⏱ ",g.renderMs," ms"]}),(0,o.jsxs)("span",{children:[h.split("\n").length," lines"]}),(0,o.jsxs)("span",{children:[h.length," chars"]}),x.length>0&&(0,o.jsxs)("span",{style:{marginLeft:"auto",color:d.primary,fontWeight:600},children:["⚛ ",x.length," suggestion",x.length>1?"s":""]})]})]})}P.displayName="TkxPlayground",exports.AmplitudeAmplifier=c,exports.QuantumAI=x,exports.QuantumAnnealer=s,exports.QuantumBoltzmannMachine=d,exports.QuantumRegister=l,exports.Qubit=a,exports.TkxPlayground=P,exports.TkxQuantumForm=C,exports.TkxThemeBuilder=function({onThemeChange:e,initialHue:i=210,initialMode:a="dark"}){const l=t.useTheme(),[s,d]=(0,r.useState)(a),[c,p]=(0,r.useState)(i),[h,u]=(0,r.useState)(()=>M("dark"===a)),[g,m]=(0,r.useState)(!1),[f,y]=(0,r.useState)([]),[b,v]=(0,r.useState)(!1),k=(0,r.useRef)(null),w="dark"===s,S=(0,r.useCallback)((t,n)=>{u(r=>{const o={...r,[t]:n};return e?.(o),o})},[e]),C=(0,r.useCallback)(()=>{if(g)return;m(!0),y([]);let t=0;const n=[],r=()=>{t+=60,x.optimizeTheme(c,w,t);const o=t/600,i=50*(1-o)+2,a=8*(Math.random()-.5)*(1-.8*o);if(n.push({iteration:t,energy:Math.max(0,i+a)}),y([...n]),t<600)k.current=window.setTimeout(r,40);else{const t=x.optimizeTheme(c,w,1e3);u(t),e?.(t),m(!1)}};k.current=window.setTimeout(r,16)},[c,w,g,e]),A=(0,r.useCallback)(()=>{const t="dark"===s?"light":"dark";d(t);const n=M("dark"===t);u(n),e?.(n)},[s,e]),W=(0,r.useCallback)(()=>{const e=`export const myTheme = {\n${Object.entries(h).map(([e,t])=>` ${e}: '${t}',`).join("\n")}\n};`;"undefined"!=typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(e).then(()=>{v(!0),setTimeout(()=>v(!1),2e3)})},[h]),R=[{label:"Text on Background",fg:h.text,bg:h.background},{label:"Text on Surface",fg:h.text,bg:h.surface},{label:"Primary on Background",fg:h.primary,bg:h.background},{label:"TextMuted on Background",fg:h.textMuted,bg:h.background}],B="linear-gradient(to right,"+["hsl(0,80%,55%)","hsl(30,80%,55%)","hsl(60,80%,55%)","hsl(90,80%,55%)","hsl(120,80%,55%)","hsl(150,80%,55%)","hsl(180,80%,55%)","hsl(210,80%,55%)","hsl(240,80%,55%)","hsl(270,80%,55%)","hsl(300,80%,55%)","hsl(330,80%,55%)","hsl(360,80%,55%)"].join(",")+")",F={fontFamily:"system-ui, -apple-system, sans-serif",background:h.background,color:h.text,border:`1px solid ${h.border}`,borderRadius:12,padding:20,maxWidth:900,display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},L={background:h.surface,border:`1px solid ${h.border}`,borderRadius:8,padding:16},I={fontSize:13,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:h.primary,marginBottom:12,marginTop:0},P={padding:"8px 16px",borderRadius:8,border:"none",cursor:"pointer",fontWeight:600,fontSize:13,transition:"opacity 0.15s"},q=n.tkx;return(0,o.jsxs)("div",{style:F,children:[(0,o.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gridColumn:"1/-1"},children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("h2",{style:{margin:0,fontSize:18,fontWeight:700},children:"Theme Builder"}),(0,o.jsx)("p",{style:{margin:"2px 0 0",fontSize:12,color:h.textMuted},children:"Quantum-powered color optimization"})]}),(0,o.jsx)("button",{onClick:A,style:{...P,background:h.surface,color:h.text,border:`1px solid ${h.border}`},children:w?"☀ Light":"🌙 Dark"})]}),(0,o.jsxs)("div",{style:L,children:[(0,o.jsx)("p",{style:I,children:"Base Hue"}),(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,o.jsx)("div",{style:{width:24,height:24,borderRadius:"50%",background:`hsl(${c},70%,55%)`,border:`2px solid ${h.border}`,flexShrink:0}}),(0,o.jsx)("input",{type:"range",min:0,max:360,value:c,onChange:e=>p(Number(e.target.value)),style:{flex:1,height:16,borderRadius:8,background:B,outline:"none",border:"none",cursor:"pointer",appearance:"none",WebkitAppearance:"none"}}),(0,o.jsxs)("span",{style:{fontSize:13,fontFamily:"monospace",minWidth:32},children:[c,"°"]})]})]}),(0,o.jsxs)("div",{style:L,children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[(0,o.jsx)("button",{onClick:C,disabled:g,style:{...P,background:g?h.border:h.primary,color:w?"#000":"#fff",opacity:g?.7:1,flex:1},children:g?"⟳ Optimizing...":"⚛ Generate with Quantum Annealing"}),(0,o.jsx)("div",{style:{padding:"3px 8px",background:h.primary+"22",border:`1px solid ${h.primary}44`,borderRadius:20,fontSize:10,color:h.primary,fontWeight:700,whiteSpace:"nowrap"},children:"⚛ Quantum Annealing"})]}),(g||f.length>0)&&(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{style:{fontSize:11,color:h.textMuted,margin:"0 0 4px"},children:"Energy landscape (lower = better palette)"}),(0,o.jsx)(z,{points:f,primary:h.primary})]})]}),(0,o.jsxs)("div",{style:L,children:[(0,o.jsx)("p",{style:I,children:"Color Tokens"}),Object.keys(h).map(e=>(0,o.jsx)(T,{label:e,value:h[e],onChange:t=>S(e,t),text:h.text,border:h.border},e))]}),(0,o.jsx)("button",{onClick:W,style:{...P,background:h.accent,color:"#fff",width:"100%"},children:b?"✓ Copied to Clipboard!":"⬇ Export Theme"})]}),(0,o.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,o.jsxs)("div",{style:L,children:[(0,o.jsx)("p",{style:I,children:"Live Preview"}),(0,o.jsxs)("div",{style:{marginBottom:12},children:[(0,o.jsx)("p",{style:{fontSize:11,color:h.textMuted,margin:"0 0 6px"},children:"Buttons"}),(0,o.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,o.jsx)("button",{style:{padding:"8px 16px",borderRadius:8,border:"none",background:h.primary,color:w?"#000":"#fff",fontWeight:600,fontSize:13,cursor:"pointer"},children:"Primary"}),(0,o.jsx)("button",{style:{padding:"8px 16px",borderRadius:8,border:"none",background:h.secondary,color:"#fff",fontWeight:600,fontSize:13,cursor:"pointer"},children:"Secondary"}),(0,o.jsx)("button",{style:{padding:"8px 16px",borderRadius:8,border:`1px solid ${h.border}`,background:"transparent",color:h.text,fontWeight:600,fontSize:13,cursor:"pointer"},children:"Outline"})]})]}),(0,o.jsxs)("div",{style:{marginBottom:12},children:[(0,o.jsx)("p",{style:{fontSize:11,color:h.textMuted,margin:"0 0 6px"},children:"Card"}),(0,o.jsxs)("div",{style:{background:h.surface,border:`1px solid ${h.border}`,borderRadius:8,padding:12},children:[(0,o.jsx)("div",{style:{fontSize:14,fontWeight:700,marginBottom:4},children:"Card Title"}),(0,o.jsx)("div",{style:{fontSize:12,color:h.textMuted,lineHeight:1.4},children:"Sample card with surface background and muted text content."}),(0,o.jsxs)("div",{style:{marginTop:8,display:"flex",gap:6},children:[(0,o.jsx)("span",{style:{padding:"2px 8px",borderRadius:20,background:h.primary+"33",color:h.primary,fontSize:11,fontWeight:600},children:"Tag"}),(0,o.jsx)("span",{style:{padding:"2px 8px",borderRadius:20,background:h.accent+"33",color:h.accent,fontSize:11,fontWeight:600},children:"Accent"})]})]})]}),(0,o.jsxs)("div",{style:{marginBottom:12},children:[(0,o.jsx)("p",{style:{fontSize:11,color:h.textMuted,margin:"0 0 6px"},children:"Input"}),(0,o.jsx)("input",{type:"text",placeholder:"Type something...",readOnly:!0,style:{width:"100%",padding:"8px 12px",borderRadius:8,border:`1px solid ${h.border}`,background:h.background,color:h.text,fontSize:13,outline:"none",boxSizing:"border-box"}})]}),(0,o.jsxs)("div",{style:{marginBottom:12},children:[(0,o.jsx)("p",{style:{fontSize:11,color:h.textMuted,margin:"0 0 6px"},children:"Progress"}),(0,o.jsx)("div",{style:{height:8,borderRadius:4,background:h.border,overflow:"hidden"},children:(0,o.jsx)("div",{style:{height:"100%",width:"68%",background:`linear-gradient(to right, ${h.primary}, ${h.accent})`,borderRadius:4,transition:"width 0.4s ease"}})})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{style:{fontSize:11,color:h.textMuted,margin:"0 0 6px"},children:"Status Badges"}),(0,o.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[{label:"Error",color:h.error},{label:"Warning",color:h.warning},{label:"Success",color:h.success}].map(({label:e,color:t})=>(0,o.jsx)("span",{style:{padding:"3px 10px",borderRadius:4,background:t+"22",color:t,border:`1px solid ${t}44`,fontSize:11,fontWeight:700},children:e},e))})]})]}),(0,o.jsxs)("div",{style:L,children:[(0,o.jsx)("p",{style:I,children:"WCAG Contrast Check"}),R.map(e=>(0,o.jsx)($,{label:e.label,ratio:x.contrast(e.fg,e.bg)},e.label)),(0,o.jsx)("p",{style:{fontSize:10,color:h.textMuted,marginTop:8,marginBottom:0},children:"AA requires 4.5:1 (normal text). AAA requires 7:1."})]}),(0,o.jsxs)("div",{style:L,children:[(0,o.jsx)("p",{style:I,children:"Color Palette"}),(0,o.jsx)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:Object.entries(h).map(([e,t])=>(0,o.jsx)("div",{title:`${e}: ${t}`,style:{width:36,height:36,borderRadius:6,background:t,border:`2px solid ${h.border}`,cursor:"default",flexShrink:0}},e))})]})]}),"function"==typeof q&&null,"string"==typeof l.bg&&null]})},exports.hslToHex=u,exports.inferFieldIntelligence=h,exports.optimizeThemeColors=y;
package/dist/quantum.js CHANGED
@@ -1,4 +1,4 @@
1
- import{f as e}from"./chunk-PJ50l0JC.js";import{E as t,a as n}from"./chunk-DnCXUUx5.js";import r,{useCallback as o,useEffect as i,useRef as a,useState as l}from"react";import{Fragment as s,jsx as d,jsxs as c}from"react/jsx-runtime";var p=class e{constructor(e,t){this.re=e,this.im=t}add(t){return new e(this.re+t.re,this.im+t.im)}sub(t){return new e(this.re-t.re,this.im-t.im)}mul(t){return new e(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)}scale(t){return new e(this.re*t,this.im*t)}conjugate(){return new e(this.re,-this.im)}magnitudeSquared(){return this.re*this.re+this.im*this.im}magnitude(){return Math.sqrt(this.magnitudeSquared())}static fromPolar(t,n){return new e(t*Math.cos(n),t*Math.sin(n))}static zero(){return new e(0,0)}static one(){return new e(1,0)}},h=class e{constructor(e=p.one(),t=p.zero()){this.alpha=e,this.beta=t,this.normalize()}normalize(){const e=Math.sqrt(this.alpha.magnitudeSquared()+this.beta.magnitudeSquared());e>0&&(this.alpha=this.alpha.scale(1/e),this.beta=this.beta.scale(1/e))}hadamard(){const t=1/Math.SQRT2;return new e(this.alpha.add(this.beta).scale(t),this.alpha.sub(this.beta).scale(t))}ry(t){const n=Math.cos(t/2),r=Math.sin(t/2);return new e(this.alpha.scale(n).sub(this.beta.scale(r)),this.alpha.scale(r).add(this.beta.scale(n)))}phase(t){const n=p.fromPolar(1,t);return new e(this.alpha,this.beta.mul(n))}measure(){const e=this.beta.magnitudeSquared();return Math.random()<e?1:0}expectation(){return this.beta.magnitudeSquared()}getAlpha(){return this.alpha}getBeta(){return this.beta}},u=class{constructor(e){this.qubits=Array.from({length:e},()=>new h)}get size(){return this.qubits.length}getQubit(e){return this.qubits[e]}superpose(){this.qubits=this.qubits.map(e=>e.hadamard())}cnot(e,t){const n=this.qubits[e],r=this.qubits[t],o=n.expectation();this.qubits[t]=r.ry(Math.PI*o)}rotate(e,t){this.qubits[e]=this.qubits[e].ry(t)}measure(){return this.qubits.map(e=>e.measure())}probs(){return this.qubits.map(e=>e.expectation())}},g=class{constructor(e=1,t=.995,n=.3,r=1e-6){this.temperature=e,this.coolingRate=t,this.tunnelingStrength=n,this.minTemp=r}anneal(e,t,n,r=1e3){let o=e,i=t(o),a=o,l=i,s=this.temperature,d=0,c=0;for(let p=0;p<r&&s>this.minTemp;p++){const e=n(o),r=t(e),p=r-i;let h=!1;if(p<=0)h=!0;else{const e=Math.exp(-p/s),t=Math.sqrt(2*Math.abs(p)),n=Math.abs(p),r=Math.exp(-2*t*Math.sqrt(n)*this.tunnelingStrength);Math.random()<e+r&&(h=!0,Math.random()<r/(e+r+1e-10)&&c++)}h&&(o=e,i=r,d++,i<l&&(a=o,l=i)),s*=this.coolingRate}return{state:a,energy:l,iterations:r,accepted:d,tunnels:c}}},m=class{constructor(e,t){const n=Math.sqrt(2/(e+t));this.weights=Array.from({length:e},()=>Array.from({length:t},()=>(2*Math.random()-1)*n)),this.visibleBias=Array.from({length:e},()=>0),this.hiddenBias=Array.from({length:t},()=>0)}sigmoid(e){const t=.1*(Math.random()-.5);return 1/(1+Math.exp(-(e+t)))}sample(e){return Math.random()<e?1:0}energy(e,t){const n=this.visibleBias.reduce((t,n,r)=>t+n*e[r],0),r=this.hiddenBias.reduce((e,n,r)=>e+n*t[r],0);let o=0;for(let i=0;i<e.length;i++)for(let n=0;n<t.length;n++)o+=e[i]*this.weights[i][n]*t[n];return-(n+r+o)}hiddenProbs(e){return this.hiddenBias.map((t,n)=>{const r=t+e.reduce((e,t,r)=>e+this.weights[r][n]*t,0);return this.sigmoid(r)})}visibleProbs(e){return this.visibleBias.map((t,n)=>{const r=t+e.reduce((e,t,r)=>e+this.weights[n][r]*t,0);return this.sigmoid(r)})}gibbs(e,t=1){let n=[...e],r=[];for(let o=0;o<t;o++)r=this.hiddenProbs(n).map(e=>this.sample(e)),n=this.visibleProbs(r).map(e=>this.sample(e));return{visible:n,hidden:r}}trainCD1(e,t=.01){const n=this.visibleBias.length,r=this.hiddenBias.length,o=Array.from({length:n},()=>Array(r).fill(0)),i=Array(n).fill(0),a=Array(r).fill(0);for(const s of e){const e=this.hiddenProbs(s),t=e.map(e=>this.sample(e)),l=this.visibleProbs(t).map(e=>this.sample(e)),d=this.hiddenProbs(l);for(let a=0;a<n;a++){for(let t=0;t<r;t++)o[a][t]+=s[a]*e[t]-l[a]*d[t];i[a]+=s[a]-l[a]}for(let n=0;n<r;n++)a[n]+=e[n]-d[n]}const l=e.length;for(let s=0;s<n;s++){for(let e=0;e<r;e++)this.weights[s][e]+=t*o[s][e]/l;this.visibleBias[s]+=t*i[s]/l}for(let s=0;s<r;s++)this.hiddenBias[s]+=t*a[s]/l}infer(e){const t=this.hiddenProbs(e),n=t.map(e=>this.sample(e));return{hidden:t,visible:this.visibleProbs(n),energy:this.energy(e,n),iterations:1}}},f=class{amplify(e,t,n=.5){const r=e.length;if(0===r)return[];const o=e.map(t),i=o.filter(e=>e>n).length,a=Math.max(1,i);let l=Array(r).fill(1/Math.sqrt(r));const s=Math.max(1,Math.floor(Math.PI/4*Math.sqrt(r/a)));for(let d=0;d<s;d++){for(let t=0;t<r;t++)o[t]>n&&(l[t]=-l[t]);const e=l.reduce((e,t)=>e+t,0)/r;l=l.map(t=>2*e-t)}return e.map((e,t)=>({index:t,amplitude:l[t],probability:l[t]*l[t],classicalSimilarity:o[t],combined:l[t]*l[t]*.6+.4*o[t]})).sort((e,t)=>t.combined-e.combined)}},y=[{keywords:["email","e-mail","mail"],type:"email",validations:[{rule:"required",message:"Email is required"},{rule:"pattern",value:"^[^@]+@[^@]+\\.[^@]+$",message:"Enter a valid email address"},{rule:"maxLength",value:254,message:"Email too long"}],placeholder:"you@example.com",label:"Email Address",confidence:.98},{keywords:["password","passwd","pwd","pass"],type:"password",validations:[{rule:"required",message:"Password is required"},{rule:"minLength",value:8,message:"Password must be at least 8 characters"},{rule:"pattern",value:"(?=.*[A-Z])(?=.*[0-9])",message:"Include uppercase and a number"}],placeholder:"••••••••",label:"Password",confidence:.97},{keywords:["confirm_password","confirmpassword","confirm_pass","repassword","password2","repeat_password"],type:"password",validations:[{rule:"required",message:"Please confirm your password"},{rule:"match",value:"password",message:"Passwords do not match"}],placeholder:"••••••••",label:"Confirm Password",confidence:.95},{keywords:["phone","mobile","cell","tel","telephone","contact_number"],type:"tel",validations:[{rule:"pattern",value:"^[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,6}$",message:"Enter a valid phone number"}],placeholder:"+1 (555) 000-0000",label:"Phone Number",confidence:.93},{keywords:["age"],type:"number",validations:[{rule:"min",value:0,message:"Age cannot be negative"},{rule:"max",value:150,message:"Enter a valid age"},{rule:"integer",message:"Age must be a whole number"}],placeholder:"25",label:"Age",confidence:.9},{keywords:["price","amount","cost","fee","payment","salary","wage","total"],type:"number",validations:[{rule:"min",value:0,message:"Amount cannot be negative"},{rule:"pattern",value:"^\\d+(\\.\\d{1,2})?$",message:"Enter a valid amount (e.g. 9.99)"}],placeholder:"0.00",label:"Amount",confidence:.88},{keywords:["url","website","site","link","homepage","web"],type:"url",validations:[{rule:"pattern",value:"https?://.+",message:"Enter a valid URL starting with http:// or https://"}],placeholder:"https://example.com",label:"Website URL",confidence:.92},{keywords:["zip","zipcode","postal","postcode","pin_code"],type:"text",validations:[{rule:"pattern",value:"^[0-9]{5}(-[0-9]{4})?$",message:"Enter a valid ZIP code (e.g. 12345)"}],placeholder:"12345",label:"ZIP / Postal Code",confidence:.91},{keywords:["date","dob","birthday","birth_date","birthdate","born"],type:"date",validations:[{rule:"required",message:"Date is required"}],placeholder:"YYYY-MM-DD",label:"Date of Birth",confidence:.89},{keywords:["first_name","firstname","fname","given_name"],type:"text",validations:[{rule:"minLength",value:2,message:"First name too short"},{rule:"maxLength",value:50,message:"First name too long"}],placeholder:"Jane",label:"First Name",confidence:.9},{keywords:["last_name","lastname","lname","surname","family_name"],type:"text",validations:[{rule:"minLength",value:2,message:"Last name too short"},{rule:"maxLength",value:50,message:"Last name too long"}],placeholder:"Doe",label:"Last Name",confidence:.9},{keywords:["name","full_name","fullname","display_name"],type:"text",validations:[{rule:"minLength",value:2,message:"Name too short"},{rule:"maxLength",value:100,message:"Name too long"}],placeholder:"Jane Doe",label:"Full Name",confidence:.85},{keywords:["username","user_name","handle","login","loginname"],type:"text",validations:[{rule:"minLength",value:3,message:"Username must be at least 3 characters"},{rule:"maxLength",value:32,message:"Username too long"},{rule:"pattern",value:"^[a-zA-Z0-9_.-]+$",message:"Only letters, numbers, _, - and . allowed"}],placeholder:"cooluser42",label:"Username",confidence:.94},{keywords:["bio","biography","about","description","summary","details"],type:"textarea",validations:[{rule:"maxLength",value:500,message:"Bio must be under 500 characters"}],placeholder:"Tell us about yourself...",label:"Bio",confidence:.87},{keywords:["message","comment","feedback","note","notes","remarks","body"],type:"textarea",validations:[{rule:"minLength",value:10,message:"Message too short"},{rule:"maxLength",value:2e3,message:"Message too long"}],placeholder:"Write your message here...",label:"Message",confidence:.86},{keywords:["search","query","q","keyword","find"],type:"search",validations:[],placeholder:"Search...",label:"Search",confidence:.9},{keywords:["otp","one_time_password","verification_code","pin","code"],type:"text",validations:[{rule:"minLength",value:4,message:"Code too short"},{rule:"maxLength",value:8,message:"Code too long"},{rule:"pattern",value:"^[0-9]+$",message:"Code must be numeric"}],placeholder:"123456",label:"Verification Code",confidence:.92},{keywords:["color","colour","hex_color","brand_color"],type:"color",validations:[],placeholder:"#3b82f6",label:"Color",confidence:.95},{keywords:["address","street","street_address","addr"],type:"text",validations:[{rule:"maxLength",value:200,message:"Address too long"}],placeholder:"123 Main Street",label:"Street Address",confidence:.87},{keywords:["city","town","municipality"],type:"text",validations:[{rule:"maxLength",value:100,message:"City name too long"}],placeholder:"San Francisco",label:"City",confidence:.89},{keywords:["country","nation","country_code"],type:"text",validations:[],placeholder:"United States",label:"Country",confidence:.88},{keywords:["company","organization","org","employer","company_name"],type:"text",validations:[{rule:"maxLength",value:200,message:"Company name too long"}],placeholder:"Acme Inc.",label:"Company",confidence:.87}];function x(e){const t=e.toLowerCase().replace(/[\s-]/g,"_"),n=(new f).amplify(y,e=>{let n=0;for(const r of e.keywords)t===r?n=Math.max(n,1):t.includes(r)||r.includes(t)?n=Math.max(n,.8):r.split("_").some(e=>t.includes(e))&&(n=Math.max(n,.5));return n},.3);if(n.length>0&&n[0].combined>.1){const e=y[n[0].index];return{type:e.type,validations:e.validations,placeholder:e.placeholder,confidence:Math.min(e.confidence*n[0].combined*2,.99),label:e.label}}return{type:"text",validations:[{rule:"maxLength",value:255,message:"Input too long"}],placeholder:e.replace(/_/g," "),confidence:.3,label:e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}}function b(e,t,n){const r=n/100,o=t/100*Math.min(r,1-r),i=t=>{const n=(t+e/30)%12,i=r-o*Math.max(Math.min(n-3,9-n,1),-1);return Math.round(255*i).toString(16).padStart(2,"0")};return`#${i(0)}${i(8)}${i(4)}`}function v(e){const[t,n,r]=function(e){const t=e.replace("#",""),n=3===t.length?t.split("").map(e=>e+e).join(""):t;return[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}(e).map(e=>{const t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return.2126*t+.7152*n+.0722*r}function k(e,t){const n=v(e),r=v(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function w(e,t,n){return Math.max(t,Math.min(n,e))}function S(e,t,n=800){const r=t?{primary:{h:e,s:70,l:55},secondary:{h:(e+137.5)%360,s:65,l:50},bg:{h:e,s:10,l:8},surface:{h:e,s:10,l:13},text:{h:e,s:15,l:90},border:{h:e,s:15,l:22},accent:{h:(e+120)%360,s:75,l:60}}:{primary:{h:e,s:65,l:40},secondary:{h:(e+137.5)%360,s:55,l:38},bg:{h:e,s:15,l:97},surface:{h:e,s:12,l:100},text:{h:e,s:15,l:12},border:{h:e,s:12,l:85},accent:{h:(e+120)%360,s:70,l:42}};return function(e,t){const n=e=>b(e.h,e.s,e.l),r=t?e.text.l-20:e.text.l+15;return{primary:n(e.primary),secondary:n(e.secondary),background:n(e.bg),surface:n(e.surface),text:n(e.text),textMuted:b(e.text.h,Math.max(0,e.text.s-10),Math.max(20,Math.min(85,r))),border:n(e.border),error:t?"#f87171":"#dc2626",warning:t?"#fbbf24":"#d97706",success:t?"#34d399":"#059669",accent:n(e.accent)}}(new g(1.5,.994,.35,1e-5).anneal(r,e=>function(e,t){let n=0;const r=e=>b(e.h,e.s,e.l),o=r(e.text),i=r(e.bg),a=r(e.surface),l=r(e.primary),s=k(o,i),d=k(o,a),c=k(l,i);s<4.5&&(n+=10*(4.5-s)),d<4.5&&(n+=8*(4.5-d)),c<3&&(n+=5*(3-c)),n+=.05*Math.abs((e.secondary.h-e.primary.h+360)%360-137.508),n+=.03*Math.abs((e.accent.h-e.primary.h+360)%360-120);const p=(e.primary.s+e.secondary.s)/2;p<20&&(n+=.5*(20-p)),p>90&&(n+=.5*(p-90));const h=e.bg.l;t?(h>25&&(n+=2*(h-25)),h<3&&(n+=2*(3-h)),e.text.l<70&&(n+=1.5*(70-e.text.l))):(h<90&&(n+=2*(90-h)),h>100&&(n+=2*(h-100)),e.text.l>30&&(n+=1.5*(e.text.l-30)));const u=Math.abs(e.surface.l-e.bg.l);return u<2&&(n+=2*(2-u)),u>12&&(n+=1*(u-12)),n}(e,t),e=>{const t=["primary","secondary","bg","surface","text","border","accent"],n=t[Math.floor(Math.random()*t.length)],r=["h","s","l"],o=r[Math.floor(Math.random()*r.length)],i=(Math.random()-.5)*("h"===o?30:15),a={...e,[n]:{...e[n]}};return a[n]="h"===o?{...a[n],h:(e[n].h+i+360)%360}:"s"===o?{...a[n],s:w(e[n].s+i,0,100)}:{...a[n],l:w(e[n].l+i,0,100)},a},n).state,t)}var C={qubit:()=>new h,register:e=>new u(e),annealer:(e,t,n)=>new g(e,t,n),qbm:(e,t)=>new m(e,t),amplifier:()=>new f,inferField:x,optimizeTheme:S,contrast:k,hslToHex:b};function M(e,t,n,r){const o=n.trim();switch(e){case"required":return""!==o;case"email":case"pattern":if("string"==typeof t)try{return""===o||new RegExp(t).test(o)}catch{return!0}return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o);case"phone":return""===o||/^\+?[\d\s\-()]{7,15}$/.test(o);case"url":return""===o||/^https?:\/\/.+/.test(o);case"minLength":case"min":{const e=Number(t??0);return""===o||(isNaN(Number(o))?o.length>=e:Number(o)>=e)}case"maxLength":case"max":{const e=Number(t??1/0);return""===o||(isNaN(Number(o))?o.length<=e:Number(o)<=e)}case"integer":return""===o||/^\d+$/.test(o);case"alphanumeric":return""===o||/^[a-zA-Z0-9]+$/.test(o);case"match":return o===(r["string"==typeof t?t:"password"]??"");default:return!0}}function z({phase:e,collapsed:t,primaryColor:n,borderColor:r}){const o=12,i=t?0:e,a=t?0:1.618*e,l=o+10*Math.sin(i)*Math.cos(a),s=12-10*Math.cos(i);/* @__PURE__ */
1
+ import{p as e}from"./chunk-DdHSYetV.js";import{E as t,a as n}from"./chunk-DcVMayoM.js";import r,{useCallback as o,useEffect as i,useRef as a,useState as l}from"react";import{Fragment as s,jsx as d,jsxs as c}from"react/jsx-runtime";var p=class e{constructor(e,t){this.re=e,this.im=t}add(t){return new e(this.re+t.re,this.im+t.im)}sub(t){return new e(this.re-t.re,this.im-t.im)}mul(t){return new e(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)}scale(t){return new e(this.re*t,this.im*t)}conjugate(){return new e(this.re,-this.im)}magnitudeSquared(){return this.re*this.re+this.im*this.im}magnitude(){return Math.sqrt(this.magnitudeSquared())}static fromPolar(t,n){return new e(t*Math.cos(n),t*Math.sin(n))}static zero(){return new e(0,0)}static one(){return new e(1,0)}},h=class e{constructor(e=p.one(),t=p.zero()){this.alpha=e,this.beta=t,this.normalize()}normalize(){const e=Math.sqrt(this.alpha.magnitudeSquared()+this.beta.magnitudeSquared());e>0&&(this.alpha=this.alpha.scale(1/e),this.beta=this.beta.scale(1/e))}hadamard(){const t=1/Math.SQRT2;return new e(this.alpha.add(this.beta).scale(t),this.alpha.sub(this.beta).scale(t))}ry(t){const n=Math.cos(t/2),r=Math.sin(t/2);return new e(this.alpha.scale(n).sub(this.beta.scale(r)),this.alpha.scale(r).add(this.beta.scale(n)))}phase(t){const n=p.fromPolar(1,t);return new e(this.alpha,this.beta.mul(n))}measure(){const e=this.beta.magnitudeSquared();return Math.random()<e?1:0}expectation(){return this.beta.magnitudeSquared()}getAlpha(){return this.alpha}getBeta(){return this.beta}},u=class{constructor(e){this.qubits=Array.from({length:e},()=>new h)}get size(){return this.qubits.length}getQubit(e){return this.qubits[e]}superpose(){this.qubits=this.qubits.map(e=>e.hadamard())}cnot(e,t){const n=this.qubits[e],r=this.qubits[t],o=n.expectation();this.qubits[t]=r.ry(Math.PI*o)}rotate(e,t){this.qubits[e]=this.qubits[e].ry(t)}measure(){return this.qubits.map(e=>e.measure())}probs(){return this.qubits.map(e=>e.expectation())}},g=class{constructor(e=1,t=.995,n=.3,r=1e-6){this.temperature=e,this.coolingRate=t,this.tunnelingStrength=n,this.minTemp=r}anneal(e,t,n,r=1e3){let o=e,i=t(o),a=o,l=i,s=this.temperature,d=0,c=0;for(let p=0;p<r&&s>this.minTemp;p++){const e=n(o),r=t(e),p=r-i;let h=!1;if(p<=0)h=!0;else{const e=Math.exp(-p/s),t=Math.sqrt(2*Math.abs(p)),n=Math.abs(p),r=Math.exp(-2*t*Math.sqrt(n)*this.tunnelingStrength);Math.random()<e+r&&(h=!0,Math.random()<r/(e+r+1e-10)&&c++)}h&&(o=e,i=r,d++,i<l&&(a=o,l=i)),s*=this.coolingRate}return{state:a,energy:l,iterations:r,accepted:d,tunnels:c}}},m=class{constructor(e,t){const n=Math.sqrt(2/(e+t));this.weights=Array.from({length:e},()=>Array.from({length:t},()=>(2*Math.random()-1)*n)),this.visibleBias=Array.from({length:e},()=>0),this.hiddenBias=Array.from({length:t},()=>0)}sigmoid(e){const t=.1*(Math.random()-.5);return 1/(1+Math.exp(-(e+t)))}sample(e){return Math.random()<e?1:0}energy(e,t){const n=this.visibleBias.reduce((t,n,r)=>t+n*e[r],0),r=this.hiddenBias.reduce((e,n,r)=>e+n*t[r],0);let o=0;for(let i=0;i<e.length;i++)for(let n=0;n<t.length;n++)o+=e[i]*this.weights[i][n]*t[n];return-(n+r+o)}hiddenProbs(e){return this.hiddenBias.map((t,n)=>{const r=t+e.reduce((e,t,r)=>e+this.weights[r][n]*t,0);return this.sigmoid(r)})}visibleProbs(e){return this.visibleBias.map((t,n)=>{const r=t+e.reduce((e,t,r)=>e+this.weights[n][r]*t,0);return this.sigmoid(r)})}gibbs(e,t=1){let n=[...e],r=[];for(let o=0;o<t;o++)r=this.hiddenProbs(n).map(e=>this.sample(e)),n=this.visibleProbs(r).map(e=>this.sample(e));return{visible:n,hidden:r}}trainCD1(e,t=.01){const n=this.visibleBias.length,r=this.hiddenBias.length,o=Array.from({length:n},()=>Array(r).fill(0)),i=Array(n).fill(0),a=Array(r).fill(0);for(const s of e){const e=this.hiddenProbs(s),t=e.map(e=>this.sample(e)),l=this.visibleProbs(t).map(e=>this.sample(e)),d=this.hiddenProbs(l);for(let a=0;a<n;a++){for(let t=0;t<r;t++)o[a][t]+=s[a]*e[t]-l[a]*d[t];i[a]+=s[a]-l[a]}for(let n=0;n<r;n++)a[n]+=e[n]-d[n]}const l=e.length;for(let s=0;s<n;s++){for(let e=0;e<r;e++)this.weights[s][e]+=t*o[s][e]/l;this.visibleBias[s]+=t*i[s]/l}for(let s=0;s<r;s++)this.hiddenBias[s]+=t*a[s]/l}infer(e){const t=this.hiddenProbs(e),n=t.map(e=>this.sample(e));return{hidden:t,visible:this.visibleProbs(n),energy:this.energy(e,n),iterations:1}}},f=class{amplify(e,t,n=.5){const r=e.length;if(0===r)return[];const o=e.map(t),i=o.filter(e=>e>n).length,a=Math.max(1,i);let l=Array(r).fill(1/Math.sqrt(r));const s=Math.max(1,Math.floor(Math.PI/4*Math.sqrt(r/a)));for(let d=0;d<s;d++){for(let t=0;t<r;t++)o[t]>n&&(l[t]=-l[t]);const e=l.reduce((e,t)=>e+t,0)/r;l=l.map(t=>2*e-t)}return e.map((e,t)=>({index:t,amplitude:l[t],probability:l[t]*l[t],classicalSimilarity:o[t],combined:l[t]*l[t]*.6+.4*o[t]})).sort((e,t)=>t.combined-e.combined)}},y=[{keywords:["email","e-mail","mail"],type:"email",validations:[{rule:"required",message:"Email is required"},{rule:"pattern",value:"^[^@]+@[^@]+\\.[^@]+$",message:"Enter a valid email address"},{rule:"maxLength",value:254,message:"Email too long"}],placeholder:"you@example.com",label:"Email Address",confidence:.98},{keywords:["password","passwd","pwd","pass"],type:"password",validations:[{rule:"required",message:"Password is required"},{rule:"minLength",value:8,message:"Password must be at least 8 characters"},{rule:"pattern",value:"(?=.*[A-Z])(?=.*[0-9])",message:"Include uppercase and a number"}],placeholder:"••••••••",label:"Password",confidence:.97},{keywords:["confirm_password","confirmpassword","confirm_pass","repassword","password2","repeat_password"],type:"password",validations:[{rule:"required",message:"Please confirm your password"},{rule:"match",value:"password",message:"Passwords do not match"}],placeholder:"••••••••",label:"Confirm Password",confidence:.95},{keywords:["phone","mobile","cell","tel","telephone","contact_number"],type:"tel",validations:[{rule:"pattern",value:"^[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,6}$",message:"Enter a valid phone number"}],placeholder:"+1 (555) 000-0000",label:"Phone Number",confidence:.93},{keywords:["age"],type:"number",validations:[{rule:"min",value:0,message:"Age cannot be negative"},{rule:"max",value:150,message:"Enter a valid age"},{rule:"integer",message:"Age must be a whole number"}],placeholder:"25",label:"Age",confidence:.9},{keywords:["price","amount","cost","fee","payment","salary","wage","total"],type:"number",validations:[{rule:"min",value:0,message:"Amount cannot be negative"},{rule:"pattern",value:"^\\d+(\\.\\d{1,2})?$",message:"Enter a valid amount (e.g. 9.99)"}],placeholder:"0.00",label:"Amount",confidence:.88},{keywords:["url","website","site","link","homepage","web"],type:"url",validations:[{rule:"pattern",value:"https?://.+",message:"Enter a valid URL starting with http:// or https://"}],placeholder:"https://example.com",label:"Website URL",confidence:.92},{keywords:["zip","zipcode","postal","postcode","pin_code"],type:"text",validations:[{rule:"pattern",value:"^[0-9]{5}(-[0-9]{4})?$",message:"Enter a valid ZIP code (e.g. 12345)"}],placeholder:"12345",label:"ZIP / Postal Code",confidence:.91},{keywords:["date","dob","birthday","birth_date","birthdate","born"],type:"date",validations:[{rule:"required",message:"Date is required"}],placeholder:"YYYY-MM-DD",label:"Date of Birth",confidence:.89},{keywords:["first_name","firstname","fname","given_name"],type:"text",validations:[{rule:"minLength",value:2,message:"First name too short"},{rule:"maxLength",value:50,message:"First name too long"}],placeholder:"Jane",label:"First Name",confidence:.9},{keywords:["last_name","lastname","lname","surname","family_name"],type:"text",validations:[{rule:"minLength",value:2,message:"Last name too short"},{rule:"maxLength",value:50,message:"Last name too long"}],placeholder:"Doe",label:"Last Name",confidence:.9},{keywords:["name","full_name","fullname","display_name"],type:"text",validations:[{rule:"minLength",value:2,message:"Name too short"},{rule:"maxLength",value:100,message:"Name too long"}],placeholder:"Jane Doe",label:"Full Name",confidence:.85},{keywords:["username","user_name","handle","login","loginname"],type:"text",validations:[{rule:"minLength",value:3,message:"Username must be at least 3 characters"},{rule:"maxLength",value:32,message:"Username too long"},{rule:"pattern",value:"^[a-zA-Z0-9_.-]+$",message:"Only letters, numbers, _, - and . allowed"}],placeholder:"cooluser42",label:"Username",confidence:.94},{keywords:["bio","biography","about","description","summary","details"],type:"textarea",validations:[{rule:"maxLength",value:500,message:"Bio must be under 500 characters"}],placeholder:"Tell us about yourself...",label:"Bio",confidence:.87},{keywords:["message","comment","feedback","note","notes","remarks","body"],type:"textarea",validations:[{rule:"minLength",value:10,message:"Message too short"},{rule:"maxLength",value:2e3,message:"Message too long"}],placeholder:"Write your message here...",label:"Message",confidence:.86},{keywords:["search","query","q","keyword","find"],type:"search",validations:[],placeholder:"Search...",label:"Search",confidence:.9},{keywords:["otp","one_time_password","verification_code","pin","code"],type:"text",validations:[{rule:"minLength",value:4,message:"Code too short"},{rule:"maxLength",value:8,message:"Code too long"},{rule:"pattern",value:"^[0-9]+$",message:"Code must be numeric"}],placeholder:"123456",label:"Verification Code",confidence:.92},{keywords:["color","colour","hex_color","brand_color"],type:"color",validations:[],placeholder:"#3b82f6",label:"Color",confidence:.95},{keywords:["address","street","street_address","addr"],type:"text",validations:[{rule:"maxLength",value:200,message:"Address too long"}],placeholder:"123 Main Street",label:"Street Address",confidence:.87},{keywords:["city","town","municipality"],type:"text",validations:[{rule:"maxLength",value:100,message:"City name too long"}],placeholder:"San Francisco",label:"City",confidence:.89},{keywords:["country","nation","country_code"],type:"text",validations:[],placeholder:"United States",label:"Country",confidence:.88},{keywords:["company","organization","org","employer","company_name"],type:"text",validations:[{rule:"maxLength",value:200,message:"Company name too long"}],placeholder:"Acme Inc.",label:"Company",confidence:.87}];function x(e){const t=e.toLowerCase().replace(/[\s-]/g,"_"),n=(new f).amplify(y,e=>{let n=0;for(const r of e.keywords)t===r?n=Math.max(n,1):t.includes(r)||r.includes(t)?n=Math.max(n,.8):r.split("_").some(e=>t.includes(e))&&(n=Math.max(n,.5));return n},.3);if(n.length>0&&n[0].combined>.1){const e=y[n[0].index];return{type:e.type,validations:e.validations,placeholder:e.placeholder,confidence:Math.min(e.confidence*n[0].combined*2,.99),label:e.label}}return{type:"text",validations:[{rule:"maxLength",value:255,message:"Input too long"}],placeholder:e.replace(/_/g," "),confidence:.3,label:e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}}function b(e,t,n){const r=n/100,o=t/100*Math.min(r,1-r),i=t=>{const n=(t+e/30)%12,i=r-o*Math.max(Math.min(n-3,9-n,1),-1);return Math.round(255*i).toString(16).padStart(2,"0")};return`#${i(0)}${i(8)}${i(4)}`}function v(e){const[t,n,r]=function(e){const t=e.replace("#",""),n=3===t.length?t.split("").map(e=>e+e).join(""):t;return[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}(e).map(e=>{const t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return.2126*t+.7152*n+.0722*r}function k(e,t){const n=v(e),r=v(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function w(e,t,n){return Math.max(t,Math.min(n,e))}function S(e,t,n=800){const r=t?{primary:{h:e,s:70,l:55},secondary:{h:(e+137.5)%360,s:65,l:50},bg:{h:e,s:10,l:8},surface:{h:e,s:10,l:13},text:{h:e,s:15,l:90},border:{h:e,s:15,l:22},accent:{h:(e+120)%360,s:75,l:60}}:{primary:{h:e,s:65,l:40},secondary:{h:(e+137.5)%360,s:55,l:38},bg:{h:e,s:15,l:97},surface:{h:e,s:12,l:100},text:{h:e,s:15,l:12},border:{h:e,s:12,l:85},accent:{h:(e+120)%360,s:70,l:42}};return function(e,t){const n=e=>b(e.h,e.s,e.l),r=t?e.text.l-20:e.text.l+15;return{primary:n(e.primary),secondary:n(e.secondary),background:n(e.bg),surface:n(e.surface),text:n(e.text),textMuted:b(e.text.h,Math.max(0,e.text.s-10),Math.max(20,Math.min(85,r))),border:n(e.border),error:t?"#f87171":"#dc2626",warning:t?"#fbbf24":"#d97706",success:t?"#34d399":"#059669",accent:n(e.accent)}}(new g(1.5,.994,.35,1e-5).anneal(r,e=>function(e,t){let n=0;const r=e=>b(e.h,e.s,e.l),o=r(e.text),i=r(e.bg),a=r(e.surface),l=r(e.primary),s=k(o,i),d=k(o,a),c=k(l,i);s<4.5&&(n+=10*(4.5-s)),d<4.5&&(n+=8*(4.5-d)),c<3&&(n+=5*(3-c)),n+=.05*Math.abs((e.secondary.h-e.primary.h+360)%360-137.508),n+=.03*Math.abs((e.accent.h-e.primary.h+360)%360-120);const p=(e.primary.s+e.secondary.s)/2;p<20&&(n+=.5*(20-p)),p>90&&(n+=.5*(p-90));const h=e.bg.l;t?(h>25&&(n+=2*(h-25)),h<3&&(n+=2*(3-h)),e.text.l<70&&(n+=1.5*(70-e.text.l))):(h<90&&(n+=2*(90-h)),h>100&&(n+=2*(h-100)),e.text.l>30&&(n+=1.5*(e.text.l-30)));const u=Math.abs(e.surface.l-e.bg.l);return u<2&&(n+=2*(2-u)),u>12&&(n+=1*(u-12)),n}(e,t),e=>{const t=["primary","secondary","bg","surface","text","border","accent"],n=t[Math.floor(Math.random()*t.length)],r=["h","s","l"],o=r[Math.floor(Math.random()*r.length)],i=(Math.random()-.5)*("h"===o?30:15),a={...e,[n]:{...e[n]}};return a[n]="h"===o?{...a[n],h:(e[n].h+i+360)%360}:"s"===o?{...a[n],s:w(e[n].s+i,0,100)}:{...a[n],l:w(e[n].l+i,0,100)},a},n).state,t)}var C={qubit:()=>new h,register:e=>new u(e),annealer:(e,t,n)=>new g(e,t,n),qbm:(e,t)=>new m(e,t),amplifier:()=>new f,inferField:x,optimizeTheme:S,contrast:k,hslToHex:b};function M(e,t,n,r){const o=n.trim();switch(e){case"required":return""!==o;case"email":case"pattern":if("string"==typeof t)try{return""===o||new RegExp(t).test(o)}catch{return!0}return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o);case"phone":return""===o||/^\+?[\d\s\-()]{7,15}$/.test(o);case"url":return""===o||/^https?:\/\/.+/.test(o);case"minLength":case"min":{const e=Number(t??0);return""===o||(isNaN(Number(o))?o.length>=e:Number(o)>=e)}case"maxLength":case"max":{const e=Number(t??1/0);return""===o||(isNaN(Number(o))?o.length<=e:Number(o)<=e)}case"integer":return""===o||/^\d+$/.test(o);case"alphanumeric":return""===o||/^[a-zA-Z0-9]+$/.test(o);case"match":return o===(r["string"==typeof t?t:"password"]??"");default:return!0}}function z({phase:e,collapsed:t,primaryColor:n,borderColor:r}){const o=12,i=t?0:e,a=t?0:1.618*e,l=o+10*Math.sin(i)*Math.cos(a),s=12-10*Math.cos(i);/* @__PURE__ */
2
2
  return c("svg",{width:"24",height:"24",viewBox:"0 0 24 24","aria-hidden":"true",style:{flexShrink:0,opacity:t?.4:1,transition:"opacity 0.6s"},children:[
3
3
  /* @__PURE__ */d("circle",{cx:o,cy:12,r:10,fill:"none",stroke:r,strokeWidth:"0.8"}),
4
4
  /* @__PURE__ */d("ellipse",{cx:o,cy:12,rx:10,ry:3,fill:"none",stroke:r,strokeWidth:"0.5",strokeDasharray:"2 2"}),
package/dist/realtime.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),require("./chunk-DmRB1Blb.js");const e=require("./chunk-DjxOP8W4.js"),t=require("./chunk-LWkKqC8d.js");let n=require("react");var o=!1;function r({item:e,isNew:o,showTimestamps:r,onItemClick:i,renderItem:s,theme:a,style:l}){const c=function(e,t){switch(e){case"info":return t.info;case"success":return t.success;case"warning":return t.warning;case"error":return t.danger;default:return t.border}}(e.type,a);return s?(0,n.createElement)("div",{style:l,className:o?"tkx-feed-item-new":void 0},s(e)):(0,n.createElement)("div",{style:{...l,display:"flex",alignItems:"center",gap:10,padding:"0 12px",borderLeft:`3px solid ${c}`,cursor:i?"pointer":"default",boxSizing:"border-box",height:64,background:a.surface,transition:"background 0.15s"},className:o?"tkx-feed-item-new":void 0,onClick:i?()=>i(e):void 0,role:i?"button":void 0,tabIndex:i?0:void 0,onKeyDown:i?t=>{"Enter"!==t.key&&" "!==t.key||i(e)}:void 0},(0,n.createElement)("div",{style:{width:36,height:36,borderRadius:"50%",background:c,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:700,color:a.bg,flexShrink:0,overflow:"hidden"}},e.avatar?(0,n.createElement)("img",{src:e.avatar,alt:e.author??"",style:{width:"100%",height:"100%",objectFit:"cover"}}):(d=e.author)?d.split(" ").map(e=>e[0]??"").slice(0,2).join("").toUpperCase():"?"),(0,n.createElement)("div",{style:{flex:1,minWidth:0}},(0,n.createElement)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2}},e.author&&(0,n.createElement)("span",{style:{fontWeight:600,fontSize:13,color:a.text}},t.sanitizeString(e.author)),e.meta&&(0,n.createElement)("span",{style:{fontSize:11,color:a.textMuted,background:a.surfaceAlt,borderRadius:4,padding:"1px 5px"}},t.sanitizeString(e.meta))),(0,n.createElement)("div",{style:{fontSize:13,color:a.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},t.sanitizeString(e.content))),r&&(0,n.createElement)("div",{style:{fontSize:11,color:a.textMuted,flexShrink:0}},function(e){const t=Date.now()-e;return t<1e4?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}(e.timestamp)));var d}var i=!1;function s(e,t){if("string"==typeof e)return e;const n=e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Number.isInteger(e)?e:e.toFixed(2));return t?`${n}${t}`:n}function a({data:e,color:t}){if(e.length<2)return null;const o=Math.min(...e),r=Math.max(...e)-o||1,i=e.map((t,n)=>{const i=n/(e.length-1)*80,s=24-(t-o)/r*22-1;return`${i.toFixed(1)},${s.toFixed(1)}`});return(0,n.createElement)("svg",{width:80,height:24,viewBox:"0 0 80 24","aria-hidden":"true"},(0,n.createElement)("polyline",{points:i.join(" "),fill:"none",stroke:t,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}))}function l({trend:e,theme:t}){return"up"===e?(0,n.createElement)("span",{style:{color:t.success,fontSize:14,fontWeight:700}},"▲"):"down"===e?(0,n.createElement)("span",{style:{color:t.danger,fontSize:14,fontWeight:700}},"▼"):(0,n.createElement)("span",{style:{color:t.textMuted,fontSize:14}},"→")}function c({metric:e,animate:o,onMetricClick:r,theme:i}){const c=e.color??function(e,t){switch(e){case"warning":return t.warning;case"critical":return t.danger;default:return t.primary}}(e.status,i),d="number"==typeof e.value?e.value:NaN,u=function(e,t,o){const[r,i]=(0,n.useState)(e),s=(0,n.useRef)(e),a=(0,n.useRef)(null),l=(0,n.useRef)(null),c=function(){const[e,t]=(0,n.useState)(()=>"undefined"!=typeof window&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,n.useEffect)(()=>{if("undefined"==typeof window)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)"),n=e=>t(e.matches);return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[]),e}();return(0,n.useEffect)(()=>{if(!o||c)return i(e),void(s.current=e);const t=s.current;if(t===e)return;a.current=null;const n=o=>{null===a.current&&(a.current=o);const r=o-a.current,c=Math.min(r/600,1),d=1-Math.pow(1-c,3);i(t+(e-t)*d),c<1?l.current=requestAnimationFrame(n):s.current=e};return l.current=requestAnimationFrame(n),()=>{null!==l.current&&cancelAnimationFrame(l.current)}},[e,600,o,c]),r}(isNaN(d)?0:d,0,o&&!isNaN(d)),[f,h]=(0,n.useState)(!1),m=(0,n.useRef)(e.value);(0,n.useEffect)(()=>{if(m.current!==e.value){m.current=e.value,h(!0);const t=window.setTimeout(()=>h(!1),700);return()=>clearTimeout(t)}},[e.value]);const p=void 0!==e.previousValue&&e.previousValue!==d,g={background:i.surface,border:`1px solid ${i.border}`,borderLeft:`4px solid ${c}`,borderRadius:8,padding:"14px 16px",cursor:r?"pointer":"default",position:"relative",overflow:"hidden",boxSizing:"border-box"},y=f?{position:"absolute",inset:0,background:`linear-gradient(90deg, transparent 0%, ${c}22 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"tkx-metric-shimmer 0.6s ease-in-out",pointerEvents:"none"}:{},x=isNaN(d)?t.sanitizeString(String(e.value)):s(u,e.unit);return(0,n.createElement)("div",{style:g,className:f?"tkx-metric-shimmer":void 0,onClick:r?()=>r(e):void 0,role:r?"button":void 0,tabIndex:r?0:void 0},f&&(0,n.createElement)("div",{style:y}),(0,n.createElement)("div",{style:{fontSize:12,color:i.textMuted,marginBottom:6,fontWeight:500,letterSpacing:"0.03em"}},t.sanitizeString(e.label)),(0,n.createElement)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,marginBottom:6}},(0,n.createElement)("span",{style:{fontSize:28,fontWeight:700,color:i.text,lineHeight:1}},x),e.unit&&isNaN(d)&&(0,n.createElement)("span",{style:{fontSize:14,color:i.textMuted,marginBottom:2}},t.sanitizeString(e.unit))),(e.trend||e.trendValue)&&(0,n.createElement)("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:e.sparkline?8:0}},e.trend&&(0,n.createElement)(l,{trend:e.trend,theme:i}),e.trendValue&&(0,n.createElement)("span",{style:{fontSize:12,color:i.textMuted}},t.sanitizeString(e.trendValue))),p&&(0,n.createElement)("div",{style:{fontSize:11,color:i.textMuted,marginTop:2}},`was ${s(e.previousValue)}`),e.sparkline&&e.sparkline.length>=2&&(0,n.createElement)("div",{style:{marginTop:8}},(0,n.createElement)(a,{data:e.sparkline,color:c})))}function d(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function u(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(2)}var f={debug:0,info:1,warn:2,error:3,fatal:4},h=!1;function m({entry:e,showLevel:o,showTimestamp:r,showSource:i,searchQuery:s,monospace:a,isExpanded:l,onToggle:c,onEntryClick:d,theme:u,style:f}){const h=function(e,t){switch(e){case"debug":default:return t.textMuted;case"info":return t.info;case"warn":return t.warning;case"error":case"fatal":return t.danger}}(e.level,u),m=function(e,t){return"fatal"===e?`${t.danger}22`:"transparent"}(e.level,u),p=e.metadata&&Object.keys(e.metadata).length>0,g={...f,display:"flex",alignItems:"center",gap:6,padding:"0 10px",fontSize:12,fontFamily:a?'"JetBrains Mono", "Fira Mono", Consolas, monospace':"inherit",cursor:p||d?"pointer":"default",background:m,boxSizing:"border-box",height:28,overflow:"hidden",whiteSpace:"nowrap",borderBottom:`1px solid ${u.border}22`};return(0,n.createElement)("div",{style:g,className:"tkx-log-row",onClick:()=>{p&&c(),d&&d(e)},role:p?"button":void 0,tabIndex:p?0:void 0,onKeyDown:p?e=>{"Enter"!==e.key&&" "!==e.key||c()}:void 0,"aria-expanded":p?l:void 0},r&&(0,n.createElement)("span",{style:{color:u.textMuted,flexShrink:0,minWidth:84}},function(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}`}(e.timestamp)),o&&(0,n.createElement)("span",{style:{color:h,flexShrink:0,fontWeight:"fatal"===e.level?700:500,minWidth:56}},`[${e.level.toUpperCase().padEnd(5)}]`),i&&e.source&&(0,n.createElement)("span",{style:{background:u.surfaceAlt,border:`1px solid ${u.border}`,borderRadius:10,padding:"0 5px",fontSize:10,color:u.textMuted,flexShrink:0,maxWidth:80,overflow:"hidden",textOverflow:"ellipsis"}},t.sanitizeString(e.source)),(0,n.createElement)("span",{style:{flex:1,color:u.text,overflow:"hidden",textOverflow:"ellipsis"}},...function(e,o){if(!o)return[e];const r=t.sanitizeString(e),i=t.sanitizeString(o);if(!i)return[r];try{const e=new RegExp(`(${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return r.split(e).map((t,o)=>e.test(t)?(0,n.createElement)("mark",{key:o,className:"tkx-log-highlight"},t):t)}catch{return[r]}}(e.message,s)),p&&(0,n.createElement)("span",{style:{color:u.textMuted,fontSize:10,flexShrink:0}},l?"▲":"▼"))}function p({metadata:e,theme:o,style:r}){return(0,n.createElement)("div",{style:{...r,background:o.surfaceAlt,borderBottom:`1px solid ${o.border}`,padding:"6px 10px 6px 56px",display:"flex",flexWrap:"wrap",gap:6,boxSizing:"border-box"}},...Object.entries(e).map(([e,r])=>(0,n.createElement)("span",{key:e,style:{fontSize:11,fontFamily:"monospace",color:o.textMuted,background:o.surface,border:`1px solid ${o.border}`,borderRadius:4,padding:"1px 6px"}},(0,n.createElement)("span",{style:{color:o.info}},`${t.sanitizeString(e)}: `),t.sanitizeString(String(r)))))}exports.TkxLiveFeed=function({items:i,maxItems:s=100,height:a=400,autoScroll:l=!0,showTimestamps:c=!0,onItemClick:d,emptyMessage:u="No activity yet.",pauseOnHover:f=!0,renderItem:h}){const m=e.useTheme();!function(){if(o||"undefined"==typeof document)return;o=!0;const e=document.createElement("style");e.id="tkx-live-feed-styles",e.textContent="\n@keyframes tkx-feed-slide-in {\n from { transform: translateY(-20px); opacity: 0; }\n to { transform: translateY(0); opacity: 1; }\n}\n.tkx-feed-item-new {\n animation: tkx-feed-slide-in 0.25s ease-out both;\n}\n ".trim(),document.head.appendChild(e)}();const p=(0,n.useRef)(null),[g,y]=(0,n.useState)(0),[x,b]=(0,n.useState)(!1),[k,v]=(0,n.useState)(new Set),w=(0,n.useRef)([]),S=(0,n.useMemo)(()=>i.slice(-s),[i,s]),$="number"==typeof a?a:400,M=64*S.length;(0,n.useEffect)(()=>{const e=new Set(w.current.map(e=>e.id)),t=S.filter(t=>!e.has(t.id)).map(e=>e.id);if(t.length>0){v(e=>{const n=new Set(e);return t.forEach(e=>n.add(e)),n});const e=window.setTimeout(()=>{v(e=>{const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},400);return()=>clearTimeout(e)}},[S]),(0,n.useEffect)(()=>{w.current=S},[S]);const z=l&&!(f&&x);(0,n.useEffect)(()=>{if(!z||!p.current)return;const e=p.current;(e.scrollHeight-e.scrollTop-e.clientHeight<192||S.length<=5)&&(e.scrollTop=e.scrollHeight)},[S.length,z]);const N=(0,n.useCallback)(()=>{p.current&&y(p.current.scrollTop)},[]),W=Math.max(0,Math.floor(g/64)-5),I=Math.min(S.length-1,Math.ceil((g+$)/64)+5),L={position:"relative",overflow:"auto",height:"number"==typeof a?`${a}px`:a,background:m.bg,border:`1px solid ${m.border}`,borderRadius:8,boxSizing:"border-box"},C={position:"relative",height:M,minHeight:"100%"};if(0===S.length)return(0,n.createElement)("div",{style:{...L,display:"flex",alignItems:"center",justifyContent:"center"}},(0,n.createElement)("span",{style:{color:m.textMuted,fontSize:14}},t.sanitizeString(u)));const j=[];for(let e=W;e<=I;e++){const t=S[e];t&&j.push((0,n.createElement)(r,{key:t.id,item:t,isNew:k.has(t.id),showTimestamps:c,onItemClick:d,renderItem:h,theme:m,style:{position:"absolute",top:64*e,left:0,right:0}}))}return(0,n.createElement)("div",{ref:p,style:L,onScroll:N,onMouseEnter:f?()=>b(!0):void 0,onMouseLeave:f?()=>b(!1):void 0,"aria-label":"Live feed",role:"feed"},(0,n.createElement)("div",{style:C},...j))},exports.TkxLiveLog=function({entries:t,maxEntries:o=500,height:r=400,autoScroll:i=!0,showLevel:s=!0,showTimestamp:a=!0,showSource:l=!0,filterLevel:c,searchQuery:d="",monospace:u=!0,onEntryClick:g}){const y=e.useTheme();!function(){if(h||"undefined"==typeof document)return;h=!0;const e=document.createElement("style");e.id="tkx-live-log-styles",e.textContent="\n.tkx-log-row:hover { filter: brightness(1.12); }\n.tkx-log-highlight { background: #ffbe0b55; border-radius: 2px; padding: 0 1px; }\n ".trim(),document.head.appendChild(e)}();const x=(0,n.useRef)(null),[b,k]=(0,n.useState)(0),[v,w]=(0,n.useState)(new Set),[S,$]=(0,n.useState)(!1),M=(0,n.useRef)(t.length),z=(0,n.useMemo)(()=>{let e=t.slice(-o);if(void 0!==c){const t=f[c];e=e.filter(e=>f[e.level]>=t)}if(d){const t=d.toLowerCase();e=e.filter(e=>e.message.toLowerCase().includes(t)||(e.source??"").toLowerCase().includes(t))}return e},[t,o,c,d]),N="number"==typeof r?r:400,W=(0,n.useMemo)(()=>{const e=[];let t=0;for(const n of z)e.push(t),t+=28+(v.has(n.id)?40:0);return e.push(t),e},[z,v]),I=W[W.length-1]??0;(0,n.useEffect)(()=>{i&&!S&&z.length!==M.current&&(M.current=z.length,x.current&&(x.current.scrollTop=x.current.scrollHeight))},[z.length,i,S]);const L=(0,n.useCallback)(()=>{if(!x.current)return;const e=x.current;$(!(e.scrollHeight-e.scrollTop-e.clientHeight<56)),k(e.scrollTop)},[]),C=(0,n.useCallback)(e=>{w(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),j=z.length>0?function(e){let t=0,n=z.length-1;for(;t<n;){const o=t+n>>1;(W[o+1]??0)<=e?t=o+1:n=o}return Math.max(0,t-8)}(b):0,T=z.length>0?function(e){let t=0,n=z.length-1;for(;t<n;){const o=t+n+1>>1;(W[o]??0)>=e+N?n=o-1:t=o}return Math.min(z.length-1,t+8)}(b):-1,E={position:"relative",overflow:"auto",height:"number"==typeof r?`${r}px`:r,background:y.bg,border:`1px solid ${y.border}`,borderRadius:8,boxSizing:"border-box"},R={position:"relative",height:I,minHeight:"100%"};if(0===z.length)return(0,n.createElement)("div",{style:{...E,display:"flex",alignItems:"center",justifyContent:"center"}},(0,n.createElement)("span",{style:{color:y.textMuted,fontSize:13,fontFamily:"monospace"}},"No log entries."));const B=[];for(let e=j;e<=T;e++){const t=z[e];if(!t)continue;const o=W[e]??0,r=v.has(t.id);B.push((0,n.createElement)(m,{key:t.id,entry:t,showLevel:s,showTimestamp:a,showSource:l,searchQuery:d,monospace:u,isExpanded:r,onToggle:()=>C(t.id),onEntryClick:g,theme:y,style:{position:"absolute",top:o,left:0,right:0}})),r&&t.metadata&&Object.keys(t.metadata).length>0&&B.push((0,n.createElement)(p,{key:`${t.id}-meta`,metadata:t.metadata,theme:y,style:{position:"absolute",top:o+28,left:0,right:0,height:40}}))}return(0,n.createElement)("div",{ref:x,style:E,onScroll:L,role:"log","aria-live":"polite","aria-label":"Log viewer"},(0,n.createElement)("div",{style:R},...B))},exports.TkxLiveMetrics=function({metrics:t,columns:o=3,animate:r=!0,onMetricClick:s}){const a=e.useTheme();return function(){if(i||"undefined"==typeof document)return;i=!0;const e=document.createElement("style");e.id="tkx-live-metrics-styles",e.textContent="\n@keyframes tkx-metric-pulse {\n 0% { opacity: 1; }\n 40% { opacity: 0.4; }\n 100% { opacity: 1; }\n}\n@keyframes tkx-metric-shimmer {\n 0% { background-position: -200% 0; }\n 100% { background-position: 200% 0; }\n}\n.tkx-metric-shimmer {\n animation: tkx-metric-shimmer 0.6s ease-in-out;\n}\n@media (prefers-reduced-motion: reduce) {\n .tkx-metric-shimmer { animation: none; }\n .tkx-metric-pulse { animation: none; }\n}\n ".trim(),document.head.appendChild(e)}(),(0,n.createElement)("div",{style:{display:"grid",gridTemplateColumns:`repeat(${o}, minmax(0, 1fr))`,gap:16}},...t.map(e=>(0,n.createElement)(c,{key:e.id,metric:e,animate:r,onMetricClick:s,theme:a})))},exports.TkxRealTimeChart=function({data:o,maxPoints:r=60,height:i=200,width:s="100%",color:a,fill:l=!0,showGrid:c=!0,showLabels:f=!0,showTooltip:h=!0,label:m,unit:p,animate:g=!0,yMin:y,yMax:x}){const b=e.useTheme(),k=a??b.primary,v=(0,n.useRef)(null),[w,S]=(0,n.useState)(600),[$,M]=(0,n.useState)(null),[z,N]=(0,n.useState)(0),W=(0,n.useRef)(o.length);(0,n.useEffect)(()=>{if(!v.current)return;const e=new ResizeObserver(e=>{const t=e[0];t&&S(t.contentRect.width)});return e.observe(v.current),S(v.current.offsetWidth),()=>e.disconnect()},[]);const I=(0,n.useMemo)(()=>o.slice(-r),[o,r]);(0,n.useEffect)(()=>{I.length>W.current&&N(e=>e+1),W.current=I.length},[I.length]);const L=f?48:12,C=m?28:12,j=Math.max(w-L-12,1),T=Math.max(i-C-28,1),E=I.length?Math.min(...I.map(e=>e.value)):0,R=I.length?Math.max(...I.map(e=>e.value)):1,B=R-E||1,O=void 0!==y?y:E-.1*B,F=(void 0!==x?x:R+.1*B)-O||1;function D(e){return I.length<2?j/2:e/(I.length-1)*j}function q(e){return T-(e-O)/F*T}const A=I.length>=2?I.map((e,t)=>`${0===t?"M":"L"}${D(t).toFixed(2)},${q(e.value).toFixed(2)}`).join(" "):"",H=A?`${A} L${D(I.length-1).toFixed(2)},${T} L${D(0).toFixed(2)},${T} Z`:"",P=[];for(let e=0;e<=4;e++)P.push(e);const Q=P.map(e=>{const t=O+e/4*F;return{y:q(t),text:u(t)}}),K=Math.min(4,I.length),Y=K>0?Array.from({length:K},(e,t)=>Math.round(t/Math.max(K-1,1)*(I.length-1))):[],G=(0,n.useCallback)(e=>{if(!h||0===I.length)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left-L;let o=0,r=1/0;I.forEach((e,t)=>{const i=Math.abs(D(t)-n);i<r&&(r=i,o=t)});const i=I[o];i&&M({x:D(o)+L,y:q(i.value)+C,point:i})},[I,h,L,C]),J=(0,n.useCallback)(()=>M(null),[]),Z=w,U=i,V=`tkx-chart-clip-${z}`;return(0,n.createElement)("div",{ref:v,style:{position:"relative",width:"number"==typeof s?`${s}px`:s,background:b.surface,border:`1px solid ${b.border}`,borderRadius:8,overflow:"hidden",boxSizing:"border-box"}},(0,n.createElement)("svg",{width:Z,height:U,viewBox:`0 0 ${Z} ${U}`,onMouseMove:G,onMouseLeave:J,style:{display:"block",userSelect:"none"},"aria-label":m?t.sanitizeString(m):"Real-time chart"},g&&I.length>=2&&(0,n.createElement)("defs",null,(0,n.createElement)("clipPath",{id:V},(0,n.createElement)("rect",{x:0,y:0,width:j,height:U},(0,n.createElement)("animate",{attributeName:"width",from:Math.max(0,j-j/Math.max(I.length-1,1)),to:j,dur:"0.3s",fill:"freeze"})))),m&&(0,n.createElement)("text",{x:L,y:18,fill:b.textMuted,fontSize:12,fontWeight:500},t.sanitizeString(m)),c&&P.map(e=>{const t=q(O+e/4*F)+C;return(0,n.createElement)("line",{key:`grid-${e}`,x1:L,y1:t,x2:L+j,y2:t,stroke:b.border,strokeWidth:1,strokeDasharray:"4 4"})}),f&&Q.map((e,t)=>(0,n.createElement)("text",{key:`yl-${t}`,x:L-4,y:e.y+C+4,fill:b.textMuted,fontSize:10,textAnchor:"end"},e.text)),p&&(0,n.createElement)("text",{x:4,y:C+10,fill:b.textMuted,fontSize:9},t.sanitizeString(p)),l&&H&&(0,n.createElement)("path",{d:H,fill:`${k}22`,clipPath:g?`url(#${V})`:void 0,transform:`translate(${L}, ${C})`}),A&&(0,n.createElement)("path",{d:A,fill:"none",stroke:k,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",clipPath:g?`url(#${V})`:void 0,transform:`translate(${L}, ${C})`}),Y.map(e=>{const t=I[e];return t?(0,n.createElement)("text",{key:`xl-${e}`,x:L+D(e),y:U-8,fill:b.textMuted,fontSize:9,textAnchor:"middle"},d(t.timestamp)):null}),$&&(0,n.createElement)("line",{x1:$.x,y1:C,x2:$.x,y2:C+T,stroke:k,strokeWidth:1,strokeDasharray:"3 3",opacity:.6}),$&&(0,n.createElement)("circle",{cx:$.x,cy:$.y,r:4,fill:k,stroke:b.surface,strokeWidth:2}),$&&(()=>{const e=Math.min($.x+8,Z-100),t=Math.max($.y-36,4),o=`${u($.point.value)}${p||""}`,r=d($.point.timestamp);return(0,n.createElement)("g",null,(0,n.createElement)("rect",{x:e-4,y:t-2,width:90,height:34,rx:4,fill:b.surfaceAlt,stroke:b.border,strokeWidth:1}),(0,n.createElement)("text",{x:e,y:t+11,fill:b.text,fontSize:12,fontWeight:700},o),(0,n.createElement)("text",{x:e,y:t+26,fill:b.textMuted,fontSize:10},r))})()))};
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),require("./chunk-DmRB1Blb.js");const e=require("./chunk-BpuJ3-K8.js"),t=require("./chunk-D7-yknXg.js");let n=require("react");var o=!1;function r({item:e,isNew:o,showTimestamps:r,onItemClick:i,renderItem:s,theme:a,style:l}){const c=function(e,t){switch(e){case"info":return t.info;case"success":return t.success;case"warning":return t.warning;case"error":return t.danger;default:return t.border}}(e.type,a);return s?(0,n.createElement)("div",{style:l,className:o?"tkx-feed-item-new":void 0},s(e)):(0,n.createElement)("div",{style:{...l,display:"flex",alignItems:"center",gap:10,padding:"0 12px",borderLeft:`3px solid ${c}`,cursor:i?"pointer":"default",boxSizing:"border-box",height:64,background:a.surface,transition:"background 0.15s"},className:o?"tkx-feed-item-new":void 0,onClick:i?()=>i(e):void 0,role:i?"button":void 0,tabIndex:i?0:void 0,onKeyDown:i?t=>{"Enter"!==t.key&&" "!==t.key||i(e)}:void 0},(0,n.createElement)("div",{style:{width:36,height:36,borderRadius:"50%",background:c,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:700,color:a.bg,flexShrink:0,overflow:"hidden"}},e.avatar?(0,n.createElement)("img",{src:e.avatar,alt:e.author??"",style:{width:"100%",height:"100%",objectFit:"cover"}}):(d=e.author)?d.split(" ").map(e=>e[0]??"").slice(0,2).join("").toUpperCase():"?"),(0,n.createElement)("div",{style:{flex:1,minWidth:0}},(0,n.createElement)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2}},e.author&&(0,n.createElement)("span",{style:{fontWeight:600,fontSize:13,color:a.text}},t.sanitizeString(e.author)),e.meta&&(0,n.createElement)("span",{style:{fontSize:11,color:a.textMuted,background:a.surfaceAlt,borderRadius:4,padding:"1px 5px"}},t.sanitizeString(e.meta))),(0,n.createElement)("div",{style:{fontSize:13,color:a.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},t.sanitizeString(e.content))),r&&(0,n.createElement)("div",{style:{fontSize:11,color:a.textMuted,flexShrink:0}},function(e){const t=Date.now()-e;return t<1e4?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}(e.timestamp)));var d}var i=!1;function s(e,t){if("string"==typeof e)return e;const n=e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Number.isInteger(e)?e:e.toFixed(2));return t?`${n}${t}`:n}function a({data:e,color:t}){if(e.length<2)return null;const o=Math.min(...e),r=Math.max(...e)-o||1,i=e.map((t,n)=>{const i=n/(e.length-1)*80,s=24-(t-o)/r*22-1;return`${i.toFixed(1)},${s.toFixed(1)}`});return(0,n.createElement)("svg",{width:80,height:24,viewBox:"0 0 80 24","aria-hidden":"true"},(0,n.createElement)("polyline",{points:i.join(" "),fill:"none",stroke:t,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}))}function l({trend:e,theme:t}){return"up"===e?(0,n.createElement)("span",{style:{color:t.success,fontSize:14,fontWeight:700}},"▲"):"down"===e?(0,n.createElement)("span",{style:{color:t.danger,fontSize:14,fontWeight:700}},"▼"):(0,n.createElement)("span",{style:{color:t.textMuted,fontSize:14}},"→")}function c({metric:e,animate:o,onMetricClick:r,theme:i}){const c=e.color??function(e,t){switch(e){case"warning":return t.warning;case"critical":return t.danger;default:return t.primary}}(e.status,i),d="number"==typeof e.value?e.value:NaN,u=function(e,t,o){const[r,i]=(0,n.useState)(e),s=(0,n.useRef)(e),a=(0,n.useRef)(null),l=(0,n.useRef)(null),c=function(){const[e,t]=(0,n.useState)(()=>"undefined"!=typeof window&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,n.useEffect)(()=>{if("undefined"==typeof window)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)"),n=e=>t(e.matches);return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[]),e}();return(0,n.useEffect)(()=>{if(!o||c)return i(e),void(s.current=e);const t=s.current;if(t===e)return;a.current=null;const n=o=>{null===a.current&&(a.current=o);const r=o-a.current,c=Math.min(r/600,1),d=1-Math.pow(1-c,3);i(t+(e-t)*d),c<1?l.current=requestAnimationFrame(n):s.current=e};return l.current=requestAnimationFrame(n),()=>{null!==l.current&&cancelAnimationFrame(l.current)}},[e,600,o,c]),r}(isNaN(d)?0:d,0,o&&!isNaN(d)),[f,h]=(0,n.useState)(!1),m=(0,n.useRef)(e.value);(0,n.useEffect)(()=>{if(m.current!==e.value){m.current=e.value,h(!0);const t=window.setTimeout(()=>h(!1),700);return()=>clearTimeout(t)}},[e.value]);const p=void 0!==e.previousValue&&e.previousValue!==d,g={background:i.surface,border:`1px solid ${i.border}`,borderLeft:`4px solid ${c}`,borderRadius:8,padding:"14px 16px",cursor:r?"pointer":"default",position:"relative",overflow:"hidden",boxSizing:"border-box"},y=f?{position:"absolute",inset:0,background:`linear-gradient(90deg, transparent 0%, ${c}22 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"tkx-metric-shimmer 0.6s ease-in-out",pointerEvents:"none"}:{},x=isNaN(d)?t.sanitizeString(String(e.value)):s(u,e.unit);return(0,n.createElement)("div",{style:g,className:f?"tkx-metric-shimmer":void 0,onClick:r?()=>r(e):void 0,role:r?"button":void 0,tabIndex:r?0:void 0},f&&(0,n.createElement)("div",{style:y}),(0,n.createElement)("div",{style:{fontSize:12,color:i.textMuted,marginBottom:6,fontWeight:500,letterSpacing:"0.03em"}},t.sanitizeString(e.label)),(0,n.createElement)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,marginBottom:6}},(0,n.createElement)("span",{style:{fontSize:28,fontWeight:700,color:i.text,lineHeight:1}},x),e.unit&&isNaN(d)&&(0,n.createElement)("span",{style:{fontSize:14,color:i.textMuted,marginBottom:2}},t.sanitizeString(e.unit))),(e.trend||e.trendValue)&&(0,n.createElement)("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:e.sparkline?8:0}},e.trend&&(0,n.createElement)(l,{trend:e.trend,theme:i}),e.trendValue&&(0,n.createElement)("span",{style:{fontSize:12,color:i.textMuted}},t.sanitizeString(e.trendValue))),p&&(0,n.createElement)("div",{style:{fontSize:11,color:i.textMuted,marginTop:2}},`was ${s(e.previousValue)}`),e.sparkline&&e.sparkline.length>=2&&(0,n.createElement)("div",{style:{marginTop:8}},(0,n.createElement)(a,{data:e.sparkline,color:c})))}function d(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function u(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(2)}var f={debug:0,info:1,warn:2,error:3,fatal:4},h=!1;function m({entry:e,showLevel:o,showTimestamp:r,showSource:i,searchQuery:s,monospace:a,isExpanded:l,onToggle:c,onEntryClick:d,theme:u,style:f}){const h=function(e,t){switch(e){case"debug":default:return t.textMuted;case"info":return t.info;case"warn":return t.warning;case"error":case"fatal":return t.danger}}(e.level,u),m=function(e,t){return"fatal"===e?`${t.danger}22`:"transparent"}(e.level,u),p=e.metadata&&Object.keys(e.metadata).length>0,g={...f,display:"flex",alignItems:"center",gap:6,padding:"0 10px",fontSize:12,fontFamily:a?'"JetBrains Mono", "Fira Mono", Consolas, monospace':"inherit",cursor:p||d?"pointer":"default",background:m,boxSizing:"border-box",height:28,overflow:"hidden",whiteSpace:"nowrap",borderBottom:`1px solid ${u.border}22`};return(0,n.createElement)("div",{style:g,className:"tkx-log-row",onClick:()=>{p&&c(),d&&d(e)},role:p?"button":void 0,tabIndex:p?0:void 0,onKeyDown:p?e=>{"Enter"!==e.key&&" "!==e.key||c()}:void 0,"aria-expanded":p?l:void 0},r&&(0,n.createElement)("span",{style:{color:u.textMuted,flexShrink:0,minWidth:84}},function(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}`}(e.timestamp)),o&&(0,n.createElement)("span",{style:{color:h,flexShrink:0,fontWeight:"fatal"===e.level?700:500,minWidth:56}},`[${e.level.toUpperCase().padEnd(5)}]`),i&&e.source&&(0,n.createElement)("span",{style:{background:u.surfaceAlt,border:`1px solid ${u.border}`,borderRadius:10,padding:"0 5px",fontSize:10,color:u.textMuted,flexShrink:0,maxWidth:80,overflow:"hidden",textOverflow:"ellipsis"}},t.sanitizeString(e.source)),(0,n.createElement)("span",{style:{flex:1,color:u.text,overflow:"hidden",textOverflow:"ellipsis"}},...function(e,o){if(!o)return[e];const r=t.sanitizeString(e),i=t.sanitizeString(o);if(!i)return[r];try{const e=new RegExp(`(${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return r.split(e).map((t,o)=>e.test(t)?(0,n.createElement)("mark",{key:o,className:"tkx-log-highlight"},t):t)}catch{return[r]}}(e.message,s)),p&&(0,n.createElement)("span",{style:{color:u.textMuted,fontSize:10,flexShrink:0}},l?"▲":"▼"))}function p({metadata:e,theme:o,style:r}){return(0,n.createElement)("div",{style:{...r,background:o.surfaceAlt,borderBottom:`1px solid ${o.border}`,padding:"6px 10px 6px 56px",display:"flex",flexWrap:"wrap",gap:6,boxSizing:"border-box"}},...Object.entries(e).map(([e,r])=>(0,n.createElement)("span",{key:e,style:{fontSize:11,fontFamily:"monospace",color:o.textMuted,background:o.surface,border:`1px solid ${o.border}`,borderRadius:4,padding:"1px 6px"}},(0,n.createElement)("span",{style:{color:o.info}},`${t.sanitizeString(e)}: `),t.sanitizeString(String(r)))))}exports.TkxLiveFeed=function({items:i,maxItems:s=100,height:a=400,autoScroll:l=!0,showTimestamps:c=!0,onItemClick:d,emptyMessage:u="No activity yet.",pauseOnHover:f=!0,renderItem:h}){const m=e.useTheme();!function(){if(o||"undefined"==typeof document)return;o=!0;const e=document.createElement("style");e.id="tkx-live-feed-styles",e.textContent="\n@keyframes tkx-feed-slide-in {\n from { transform: translateY(-20px); opacity: 0; }\n to { transform: translateY(0); opacity: 1; }\n}\n.tkx-feed-item-new {\n animation: tkx-feed-slide-in 0.25s ease-out both;\n}\n ".trim(),document.head.appendChild(e)}();const p=(0,n.useRef)(null),[g,y]=(0,n.useState)(0),[x,b]=(0,n.useState)(!1),[k,v]=(0,n.useState)(new Set),w=(0,n.useRef)([]),S=(0,n.useMemo)(()=>i.slice(-s),[i,s]),$="number"==typeof a?a:400,M=64*S.length;(0,n.useEffect)(()=>{const e=new Set(w.current.map(e=>e.id)),t=S.filter(t=>!e.has(t.id)).map(e=>e.id);if(t.length>0){v(e=>{const n=new Set(e);return t.forEach(e=>n.add(e)),n});const e=window.setTimeout(()=>{v(e=>{const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},400);return()=>clearTimeout(e)}},[S]),(0,n.useEffect)(()=>{w.current=S},[S]);const z=l&&!(f&&x);(0,n.useEffect)(()=>{if(!z||!p.current)return;const e=p.current;(e.scrollHeight-e.scrollTop-e.clientHeight<192||S.length<=5)&&(e.scrollTop=e.scrollHeight)},[S.length,z]);const N=(0,n.useCallback)(()=>{p.current&&y(p.current.scrollTop)},[]),W=Math.max(0,Math.floor(g/64)-5),I=Math.min(S.length-1,Math.ceil((g+$)/64)+5),L={position:"relative",overflow:"auto",height:"number"==typeof a?`${a}px`:a,background:m.bg,border:`1px solid ${m.border}`,borderRadius:8,boxSizing:"border-box"},C={position:"relative",height:M,minHeight:"100%"};if(0===S.length)return(0,n.createElement)("div",{style:{...L,display:"flex",alignItems:"center",justifyContent:"center"}},(0,n.createElement)("span",{style:{color:m.textMuted,fontSize:14}},t.sanitizeString(u)));const j=[];for(let e=W;e<=I;e++){const t=S[e];t&&j.push((0,n.createElement)(r,{key:t.id,item:t,isNew:k.has(t.id),showTimestamps:c,onItemClick:d,renderItem:h,theme:m,style:{position:"absolute",top:64*e,left:0,right:0}}))}return(0,n.createElement)("div",{ref:p,style:L,onScroll:N,onMouseEnter:f?()=>b(!0):void 0,onMouseLeave:f?()=>b(!1):void 0,"aria-label":"Live feed",role:"feed"},(0,n.createElement)("div",{style:C},...j))},exports.TkxLiveLog=function({entries:t,maxEntries:o=500,height:r=400,autoScroll:i=!0,showLevel:s=!0,showTimestamp:a=!0,showSource:l=!0,filterLevel:c,searchQuery:d="",monospace:u=!0,onEntryClick:g}){const y=e.useTheme();!function(){if(h||"undefined"==typeof document)return;h=!0;const e=document.createElement("style");e.id="tkx-live-log-styles",e.textContent="\n.tkx-log-row:hover { filter: brightness(1.12); }\n.tkx-log-highlight { background: #ffbe0b55; border-radius: 2px; padding: 0 1px; }\n ".trim(),document.head.appendChild(e)}();const x=(0,n.useRef)(null),[b,k]=(0,n.useState)(0),[v,w]=(0,n.useState)(new Set),[S,$]=(0,n.useState)(!1),M=(0,n.useRef)(t.length),z=(0,n.useMemo)(()=>{let e=t.slice(-o);if(void 0!==c){const t=f[c];e=e.filter(e=>f[e.level]>=t)}if(d){const t=d.toLowerCase();e=e.filter(e=>e.message.toLowerCase().includes(t)||(e.source??"").toLowerCase().includes(t))}return e},[t,o,c,d]),N="number"==typeof r?r:400,W=(0,n.useMemo)(()=>{const e=[];let t=0;for(const n of z)e.push(t),t+=28+(v.has(n.id)?40:0);return e.push(t),e},[z,v]),I=W[W.length-1]??0;(0,n.useEffect)(()=>{i&&!S&&z.length!==M.current&&(M.current=z.length,x.current&&(x.current.scrollTop=x.current.scrollHeight))},[z.length,i,S]);const L=(0,n.useCallback)(()=>{if(!x.current)return;const e=x.current;$(!(e.scrollHeight-e.scrollTop-e.clientHeight<56)),k(e.scrollTop)},[]),C=(0,n.useCallback)(e=>{w(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),j=z.length>0?function(e){let t=0,n=z.length-1;for(;t<n;){const o=t+n>>1;(W[o+1]??0)<=e?t=o+1:n=o}return Math.max(0,t-8)}(b):0,T=z.length>0?function(e){let t=0,n=z.length-1;for(;t<n;){const o=t+n+1>>1;(W[o]??0)>=e+N?n=o-1:t=o}return Math.min(z.length-1,t+8)}(b):-1,E={position:"relative",overflow:"auto",height:"number"==typeof r?`${r}px`:r,background:y.bg,border:`1px solid ${y.border}`,borderRadius:8,boxSizing:"border-box"},R={position:"relative",height:I,minHeight:"100%"};if(0===z.length)return(0,n.createElement)("div",{style:{...E,display:"flex",alignItems:"center",justifyContent:"center"}},(0,n.createElement)("span",{style:{color:y.textMuted,fontSize:13,fontFamily:"monospace"}},"No log entries."));const B=[];for(let e=j;e<=T;e++){const t=z[e];if(!t)continue;const o=W[e]??0,r=v.has(t.id);B.push((0,n.createElement)(m,{key:t.id,entry:t,showLevel:s,showTimestamp:a,showSource:l,searchQuery:d,monospace:u,isExpanded:r,onToggle:()=>C(t.id),onEntryClick:g,theme:y,style:{position:"absolute",top:o,left:0,right:0}})),r&&t.metadata&&Object.keys(t.metadata).length>0&&B.push((0,n.createElement)(p,{key:`${t.id}-meta`,metadata:t.metadata,theme:y,style:{position:"absolute",top:o+28,left:0,right:0,height:40}}))}return(0,n.createElement)("div",{ref:x,style:E,onScroll:L,role:"log","aria-live":"polite","aria-label":"Log viewer"},(0,n.createElement)("div",{style:R},...B))},exports.TkxLiveMetrics=function({metrics:t,columns:o=3,animate:r=!0,onMetricClick:s}){const a=e.useTheme();return function(){if(i||"undefined"==typeof document)return;i=!0;const e=document.createElement("style");e.id="tkx-live-metrics-styles",e.textContent="\n@keyframes tkx-metric-pulse {\n 0% { opacity: 1; }\n 40% { opacity: 0.4; }\n 100% { opacity: 1; }\n}\n@keyframes tkx-metric-shimmer {\n 0% { background-position: -200% 0; }\n 100% { background-position: 200% 0; }\n}\n.tkx-metric-shimmer {\n animation: tkx-metric-shimmer 0.6s ease-in-out;\n}\n@media (prefers-reduced-motion: reduce) {\n .tkx-metric-shimmer { animation: none; }\n .tkx-metric-pulse { animation: none; }\n}\n ".trim(),document.head.appendChild(e)}(),(0,n.createElement)("div",{style:{display:"grid",gridTemplateColumns:`repeat(${o}, minmax(0, 1fr))`,gap:16}},...t.map(e=>(0,n.createElement)(c,{key:e.id,metric:e,animate:r,onMetricClick:s,theme:a})))},exports.TkxRealTimeChart=function({data:o,maxPoints:r=60,height:i=200,width:s="100%",color:a,fill:l=!0,showGrid:c=!0,showLabels:f=!0,showTooltip:h=!0,label:m,unit:p,animate:g=!0,yMin:y,yMax:x}){const b=e.useTheme(),k=a??b.primary,v=(0,n.useRef)(null),[w,S]=(0,n.useState)(600),[$,M]=(0,n.useState)(null),[z,N]=(0,n.useState)(0),W=(0,n.useRef)(o.length);(0,n.useEffect)(()=>{if(!v.current)return;const e=new ResizeObserver(e=>{const t=e[0];t&&S(t.contentRect.width)});return e.observe(v.current),S(v.current.offsetWidth),()=>e.disconnect()},[]);const I=(0,n.useMemo)(()=>o.slice(-r),[o,r]);(0,n.useEffect)(()=>{I.length>W.current&&N(e=>e+1),W.current=I.length},[I.length]);const L=f?48:12,C=m?28:12,j=Math.max(w-L-12,1),T=Math.max(i-C-28,1),E=I.length?Math.min(...I.map(e=>e.value)):0,R=I.length?Math.max(...I.map(e=>e.value)):1,B=R-E||1,O=void 0!==y?y:E-.1*B,F=(void 0!==x?x:R+.1*B)-O||1;function D(e){return I.length<2?j/2:e/(I.length-1)*j}function q(e){return T-(e-O)/F*T}const A=I.length>=2?I.map((e,t)=>`${0===t?"M":"L"}${D(t).toFixed(2)},${q(e.value).toFixed(2)}`).join(" "):"",H=A?`${A} L${D(I.length-1).toFixed(2)},${T} L${D(0).toFixed(2)},${T} Z`:"",P=[];for(let e=0;e<=4;e++)P.push(e);const Q=P.map(e=>{const t=O+e/4*F;return{y:q(t),text:u(t)}}),K=Math.min(4,I.length),Y=K>0?Array.from({length:K},(e,t)=>Math.round(t/Math.max(K-1,1)*(I.length-1))):[],G=(0,n.useCallback)(e=>{if(!h||0===I.length)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left-L;let o=0,r=1/0;I.forEach((e,t)=>{const i=Math.abs(D(t)-n);i<r&&(r=i,o=t)});const i=I[o];i&&M({x:D(o)+L,y:q(i.value)+C,point:i})},[I,h,L,C]),J=(0,n.useCallback)(()=>M(null),[]),Z=w,U=i,V=`tkx-chart-clip-${z}`;return(0,n.createElement)("div",{ref:v,style:{position:"relative",width:"number"==typeof s?`${s}px`:s,background:b.surface,border:`1px solid ${b.border}`,borderRadius:8,overflow:"hidden",boxSizing:"border-box"}},(0,n.createElement)("svg",{width:Z,height:U,viewBox:`0 0 ${Z} ${U}`,onMouseMove:G,onMouseLeave:J,style:{display:"block",userSelect:"none"},"aria-label":m?t.sanitizeString(m):"Real-time chart"},g&&I.length>=2&&(0,n.createElement)("defs",null,(0,n.createElement)("clipPath",{id:V},(0,n.createElement)("rect",{x:0,y:0,width:j,height:U},(0,n.createElement)("animate",{attributeName:"width",from:Math.max(0,j-j/Math.max(I.length-1,1)),to:j,dur:"0.3s",fill:"freeze"})))),m&&(0,n.createElement)("text",{x:L,y:18,fill:b.textMuted,fontSize:12,fontWeight:500},t.sanitizeString(m)),c&&P.map(e=>{const t=q(O+e/4*F)+C;return(0,n.createElement)("line",{key:`grid-${e}`,x1:L,y1:t,x2:L+j,y2:t,stroke:b.border,strokeWidth:1,strokeDasharray:"4 4"})}),f&&Q.map((e,t)=>(0,n.createElement)("text",{key:`yl-${t}`,x:L-4,y:e.y+C+4,fill:b.textMuted,fontSize:10,textAnchor:"end"},e.text)),p&&(0,n.createElement)("text",{x:4,y:C+10,fill:b.textMuted,fontSize:9},t.sanitizeString(p)),l&&H&&(0,n.createElement)("path",{d:H,fill:`${k}22`,clipPath:g?`url(#${V})`:void 0,transform:`translate(${L}, ${C})`}),A&&(0,n.createElement)("path",{d:A,fill:"none",stroke:k,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",clipPath:g?`url(#${V})`:void 0,transform:`translate(${L}, ${C})`}),Y.map(e=>{const t=I[e];return t?(0,n.createElement)("text",{key:`xl-${e}`,x:L+D(e),y:U-8,fill:b.textMuted,fontSize:9,textAnchor:"middle"},d(t.timestamp)):null}),$&&(0,n.createElement)("line",{x1:$.x,y1:C,x2:$.x,y2:C+T,stroke:k,strokeWidth:1,strokeDasharray:"3 3",opacity:.6}),$&&(0,n.createElement)("circle",{cx:$.x,cy:$.y,r:4,fill:k,stroke:b.surface,strokeWidth:2}),$&&(()=>{const e=Math.min($.x+8,Z-100),t=Math.max($.y-36,4),o=`${u($.point.value)}${p||""}`,r=d($.point.timestamp);return(0,n.createElement)("g",null,(0,n.createElement)("rect",{x:e-4,y:t-2,width:90,height:34,rx:4,fill:b.surfaceAlt,stroke:b.border,strokeWidth:1}),(0,n.createElement)("text",{x:e,y:t+11,fill:b.text,fontSize:12,fontWeight:700},o),(0,n.createElement)("text",{x:e,y:t+26,fill:b.textMuted,fontSize:10},r))})()))};
package/dist/realtime.js CHANGED
@@ -1 +1 @@
1
- import{f as e}from"./chunk-PJ50l0JC.js";import{E as t}from"./chunk-DnCXUUx5.js";import{createElement as n,useCallback as o,useEffect as i,useMemo as r,useRef as s,useState as a}from"react";var l=!1;function c({item:e,isNew:o,showTimestamps:i,onItemClick:r,renderItem:s,theme:a,style:l}){const c=function(e,t){switch(e){case"info":return t.info;case"success":return t.success;case"warning":return t.warning;case"error":return t.danger;default:return t.border}}(e.type,a);return s?n("div",{style:l,className:o?"tkx-feed-item-new":void 0},s(e)):n("div",{style:{...l,display:"flex",alignItems:"center",gap:10,padding:"0 12px",borderLeft:`3px solid ${c}`,cursor:r?"pointer":"default",boxSizing:"border-box",height:64,background:a.surface,transition:"background 0.15s"},className:o?"tkx-feed-item-new":void 0,onClick:r?()=>r(e):void 0,role:r?"button":void 0,tabIndex:r?0:void 0,onKeyDown:r?t=>{"Enter"!==t.key&&" "!==t.key||r(e)}:void 0},n("div",{style:{width:36,height:36,borderRadius:"50%",background:c,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:700,color:a.bg,flexShrink:0,overflow:"hidden"}},e.avatar?n("img",{src:e.avatar,alt:e.author??"",style:{width:"100%",height:"100%",objectFit:"cover"}}):(d=e.author)?d.split(" ").map(e=>e[0]??"").slice(0,2).join("").toUpperCase():"?"),n("div",{style:{flex:1,minWidth:0}},n("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2}},e.author&&n("span",{style:{fontWeight:600,fontSize:13,color:a.text}},t(e.author)),e.meta&&n("span",{style:{fontSize:11,color:a.textMuted,background:a.surfaceAlt,borderRadius:4,padding:"1px 5px"}},t(e.meta))),n("div",{style:{fontSize:13,color:a.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},t(e.content))),i&&n("div",{style:{fontSize:11,color:a.textMuted,flexShrink:0}},function(e){const t=Date.now()-e;return t<1e4?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}(e.timestamp)));var d}function d({items:d,maxItems:u=100,height:f=400,autoScroll:h=!0,showTimestamps:m=!0,onItemClick:p,emptyMessage:g="No activity yet.",pauseOnHover:y=!0,renderItem:x}){const b=e();!function(){if(l||"undefined"==typeof document)return;l=!0;const e=document.createElement("style");e.id="tkx-live-feed-styles",e.textContent="\n@keyframes tkx-feed-slide-in {\n from { transform: translateY(-20px); opacity: 0; }\n to { transform: translateY(0); opacity: 1; }\n}\n.tkx-feed-item-new {\n animation: tkx-feed-slide-in 0.25s ease-out both;\n}\n ".trim(),document.head.appendChild(e)}();const k=s(null),[v,w]=a(0),[S,$]=a(!1),[M,z]=a(/* @__PURE__ */new Set),N=s([]),W=r(()=>d.slice(-u),[d,u]),I="number"==typeof f?f:400,L=64*W.length;i(()=>{const e=new Set(N.current.map(e=>e.id)),t=W.filter(t=>!e.has(t.id)).map(e=>e.id);if(t.length>0){z(e=>{const n=new Set(e);return t.forEach(e=>n.add(e)),n});const e=window.setTimeout(()=>{z(e=>{const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},400);return()=>clearTimeout(e)}},[W]),i(()=>{N.current=W},[W]);const C=h&&!(y&&S);i(()=>{if(!C||!k.current)return;const e=k.current;(e.scrollHeight-e.scrollTop-e.clientHeight<192||W.length<=5)&&(e.scrollTop=e.scrollHeight)},[W.length,C]);const T=o(()=>{k.current&&w(k.current.scrollTop)},[]),j=Math.max(0,Math.floor(v/64)-5),E=Math.min(W.length-1,Math.ceil((v+I)/64)+5),R={position:"relative",overflow:"auto",height:"number"==typeof f?`${f}px`:f,background:b.bg,border:`1px solid ${b.border}`,borderRadius:8,boxSizing:"border-box"},B={position:"relative",height:L,minHeight:"100%"};if(0===W.length)return n("div",{style:{...R,display:"flex",alignItems:"center",justifyContent:"center"}},n("span",{style:{color:b.textMuted,fontSize:14}},t(g)));const F=[];for(let e=j;e<=E;e++){const t=W[e];t&&F.push(n(c,{key:t.id,item:t,isNew:M.has(t.id),showTimestamps:m,onItemClick:p,renderItem:x,theme:b,style:{position:"absolute",top:64*e,left:0,right:0}}))}return n("div",{ref:k,style:R,onScroll:T,onMouseEnter:y?()=>$(!0):void 0,onMouseLeave:y?()=>$(!1):void 0,"aria-label":"Live feed",role:"feed"},n("div",{style:B},...F))}var u=!1;function f(e,t){if("string"==typeof e)return e;const n=e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Number.isInteger(e)?e:e.toFixed(2));return t?`${n}${t}`:n}function h({data:e,color:t}){if(e.length<2)return null;const o=Math.min(...e),i=Math.max(...e)-o||1,r=e.map((t,n)=>{const r=n/(e.length-1)*80,s=24-(t-o)/i*22-1;return`${r.toFixed(1)},${s.toFixed(1)}`});return n("svg",{width:80,height:24,viewBox:"0 0 80 24","aria-hidden":"true"},n("polyline",{points:r.join(" "),fill:"none",stroke:t,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}))}function m({trend:e,theme:t}){return"up"===e?n("span",{style:{color:t.success,fontSize:14,fontWeight:700}},"▲"):"down"===e?n("span",{style:{color:t.danger,fontSize:14,fontWeight:700}},"▼"):n("span",{style:{color:t.textMuted,fontSize:14}},"→")}function p({metric:e,animate:o,onMetricClick:r,theme:l}){const c=e.color??function(e,t){switch(e){case"warning":return t.warning;case"critical":return t.danger;default:return t.primary}}(e.status,l),d="number"==typeof e.value?e.value:NaN,u=function(e,t,n){const[o,r]=a(e),l=s(e),c=s(null),d=s(null),u=function(){const[e,t]=a(()=>"undefined"!=typeof window&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return i(()=>{if("undefined"==typeof window)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)"),n=e=>t(e.matches);return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[]),e}();return i(()=>{if(!n||u)return r(e),void(l.current=e);const t=l.current;if(t===e)return;c.current=null;const o=n=>{null===c.current&&(c.current=n);const i=n-c.current,s=Math.min(i/600,1),a=1-Math.pow(1-s,3);r(t+(e-t)*a),s<1?d.current=requestAnimationFrame(o):l.current=e};return d.current=requestAnimationFrame(o),()=>{null!==d.current&&cancelAnimationFrame(d.current)}},[e,600,n,u]),o}(isNaN(d)?0:d,0,o&&!isNaN(d)),[p,g]=a(!1),y=s(e.value);i(()=>{if(y.current!==e.value){y.current=e.value,g(!0);const t=window.setTimeout(()=>g(!1),700);return()=>clearTimeout(t)}},[e.value]);const x=void 0!==e.previousValue&&e.previousValue!==d,b={background:l.surface,border:`1px solid ${l.border}`,borderLeft:`4px solid ${c}`,borderRadius:8,padding:"14px 16px",cursor:r?"pointer":"default",position:"relative",overflow:"hidden",boxSizing:"border-box"},k=p?{position:"absolute",inset:0,background:`linear-gradient(90deg, transparent 0%, ${c}22 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"tkx-metric-shimmer 0.6s ease-in-out",pointerEvents:"none"}:{},v=isNaN(d)?t(String(e.value)):f(u,e.unit);return n("div",{style:b,className:p?"tkx-metric-shimmer":void 0,onClick:r?()=>r(e):void 0,role:r?"button":void 0,tabIndex:r?0:void 0},p&&n("div",{style:k}),n("div",{style:{fontSize:12,color:l.textMuted,marginBottom:6,fontWeight:500,letterSpacing:"0.03em"}},t(e.label)),n("div",{style:{display:"flex",alignItems:"flex-end",gap:6,marginBottom:6}},n("span",{style:{fontSize:28,fontWeight:700,color:l.text,lineHeight:1}},v),e.unit&&isNaN(d)&&n("span",{style:{fontSize:14,color:l.textMuted,marginBottom:2}},t(e.unit))),(e.trend||e.trendValue)&&n("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:e.sparkline?8:0}},e.trend&&n(m,{trend:e.trend,theme:l}),e.trendValue&&n("span",{style:{fontSize:12,color:l.textMuted}},t(e.trendValue))),x&&n("div",{style:{fontSize:11,color:l.textMuted,marginTop:2}},`was ${f(e.previousValue)}`),e.sparkline&&e.sparkline.length>=2&&n("div",{style:{marginTop:8}},n(h,{data:e.sparkline,color:c})))}function g({metrics:t,columns:o=3,animate:i=!0,onMetricClick:r}){const s=e();return function(){if(u||"undefined"==typeof document)return;u=!0;const e=document.createElement("style");e.id="tkx-live-metrics-styles",e.textContent="\n@keyframes tkx-metric-pulse {\n 0% { opacity: 1; }\n 40% { opacity: 0.4; }\n 100% { opacity: 1; }\n}\n@keyframes tkx-metric-shimmer {\n 0% { background-position: -200% 0; }\n 100% { background-position: 200% 0; }\n}\n.tkx-metric-shimmer {\n animation: tkx-metric-shimmer 0.6s ease-in-out;\n}\n@media (prefers-reduced-motion: reduce) {\n .tkx-metric-shimmer { animation: none; }\n .tkx-metric-pulse { animation: none; }\n}\n ".trim(),document.head.appendChild(e)}(),n("div",{style:{display:"grid",gridTemplateColumns:`repeat(${o}, minmax(0, 1fr))`,gap:16}},...t.map(e=>n(p,{key:e.id,metric:e,animate:i,onMetricClick:r,theme:s})))}function y(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function x(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(2)}function b({data:l,maxPoints:c=60,height:d=200,width:u="100%",color:f,fill:h=!0,showGrid:m=!0,showLabels:p=!0,showTooltip:g=!0,label:b,unit:k,animate:v=!0,yMin:w,yMax:S}){const $=e(),M=f??$.primary,z=s(null),[N,W]=a(600),[I,L]=a(null),[C,T]=a(0),j=s(l.length);i(()=>{if(!z.current)return;const e=new ResizeObserver(e=>{const t=e[0];t&&W(t.contentRect.width)});return e.observe(z.current),W(z.current.offsetWidth),()=>e.disconnect()},[]);const E=r(()=>l.slice(-c),[l,c]);i(()=>{E.length>j.current&&T(e=>e+1),j.current=E.length},[E.length]);const R=p?48:12,B=b?28:12,F=Math.max(N-R-12,1),O=Math.max(d-B-28,1),D=E.length?Math.min(...E.map(e=>e.value)):0,A=E.length?Math.max(...E.map(e=>e.value)):1,H=A-D||1,P=void 0!==w?w:D-.1*H,Q=(void 0!==S?S:A+.1*H)-P||1;function q(e){return E.length<2?F/2:e/(E.length-1)*F}function K(e){return O-(e-P)/Q*O}const Y=E.length>=2?E.map((e,t)=>`${0===t?"M":"L"}${q(t).toFixed(2)},${K(e.value).toFixed(2)}`).join(" "):"",G=Y?`${Y} L${q(E.length-1).toFixed(2)},${O} L${q(0).toFixed(2)},${O} Z`:"",J=[];for(let e=0;e<=4;e++)J.push(e);const Z=J.map(e=>{const t=P+e/4*Q;return{y:K(t),text:x(t)}}),U=Math.min(4,E.length),V=U>0?Array.from({length:U},(e,t)=>Math.round(t/Math.max(U-1,1)*(E.length-1))):[],X=o(e=>{if(!g||0===E.length)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left-R;let o=0,i=1/0;E.forEach((e,t)=>{const r=Math.abs(q(t)-n);r<i&&(i=r,o=t)});const r=E[o];r&&L({x:q(o)+R,y:K(r.value)+B,point:r})},[E,g,R,B]),_=o(()=>L(null),[]),ee=N,te=d,ne=`tkx-chart-clip-${C}`;return n("div",{ref:z,style:{position:"relative",width:"number"==typeof u?`${u}px`:u,background:$.surface,border:`1px solid ${$.border}`,borderRadius:8,overflow:"hidden",boxSizing:"border-box"}},n("svg",{width:ee,height:te,viewBox:`0 0 ${ee} ${te}`,onMouseMove:X,onMouseLeave:_,style:{display:"block",userSelect:"none"},"aria-label":b?t(b):"Real-time chart"},v&&E.length>=2&&n("defs",null,n("clipPath",{id:ne},n("rect",{x:0,y:0,width:F,height:te},n("animate",{attributeName:"width",from:Math.max(0,F-F/Math.max(E.length-1,1)),to:F,dur:"0.3s",fill:"freeze"})))),b&&n("text",{x:R,y:18,fill:$.textMuted,fontSize:12,fontWeight:500},t(b)),m&&J.map(e=>{const t=K(P+e/4*Q)+B;return n("line",{key:`grid-${e}`,x1:R,y1:t,x2:R+F,y2:t,stroke:$.border,strokeWidth:1,strokeDasharray:"4 4"})}),p&&Z.map((e,t)=>n("text",{key:`yl-${t}`,x:R-4,y:e.y+B+4,fill:$.textMuted,fontSize:10,textAnchor:"end"},e.text)),k&&n("text",{x:4,y:B+10,fill:$.textMuted,fontSize:9},t(k)),h&&G&&n("path",{d:G,fill:`${M}22`,clipPath:v?`url(#${ne})`:void 0,transform:`translate(${R}, ${B})`}),Y&&n("path",{d:Y,fill:"none",stroke:M,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",clipPath:v?`url(#${ne})`:void 0,transform:`translate(${R}, ${B})`}),V.map(e=>{const t=E[e];return t?n("text",{key:`xl-${e}`,x:R+q(e),y:te-8,fill:$.textMuted,fontSize:9,textAnchor:"middle"},y(t.timestamp)):null}),I&&n("line",{x1:I.x,y1:B,x2:I.x,y2:B+O,stroke:M,strokeWidth:1,strokeDasharray:"3 3",opacity:.6}),I&&n("circle",{cx:I.x,cy:I.y,r:4,fill:M,stroke:$.surface,strokeWidth:2}),I&&(()=>{const e=Math.min(I.x+8,ee-100),t=Math.max(I.y-36,4),o=`${x(I.point.value)}${k||""}`,i=y(I.point.timestamp);return n("g",null,n("rect",{x:e-4,y:t-2,width:90,height:34,rx:4,fill:$.surfaceAlt,stroke:$.border,strokeWidth:1}),n("text",{x:e,y:t+11,fill:$.text,fontSize:12,fontWeight:700},o),n("text",{x:e,y:t+26,fill:$.textMuted,fontSize:10},i))})()))}var k={debug:0,info:1,warn:2,error:3,fatal:4},v=!1;function w({entry:e,showLevel:o,showTimestamp:i,showSource:r,searchQuery:s,monospace:a,isExpanded:l,onToggle:c,onEntryClick:d,theme:u,style:f}){const h=function(e,t){switch(e){case"debug":default:return t.textMuted;case"info":return t.info;case"warn":return t.warning;case"error":case"fatal":return t.danger}}(e.level,u),m=function(e,t){return"fatal"===e?`${t.danger}22`:"transparent"}(e.level,u),p=e.metadata&&Object.keys(e.metadata).length>0,g={...f,display:"flex",alignItems:"center",gap:6,padding:"0 10px",fontSize:12,fontFamily:a?'"JetBrains Mono", "Fira Mono", Consolas, monospace':"inherit",cursor:p||d?"pointer":"default",background:m,boxSizing:"border-box",height:28,overflow:"hidden",whiteSpace:"nowrap",borderBottom:`1px solid ${u.border}22`};return n("div",{style:g,className:"tkx-log-row",onClick:()=>{p&&c(),d&&d(e)},role:p?"button":void 0,tabIndex:p?0:void 0,onKeyDown:p?e=>{"Enter"!==e.key&&" "!==e.key||c()}:void 0,"aria-expanded":p?l:void 0},i&&n("span",{style:{color:u.textMuted,flexShrink:0,minWidth:84}},function(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}`}(e.timestamp)),o&&n("span",{style:{color:h,flexShrink:0,fontWeight:"fatal"===e.level?700:500,minWidth:56}},`[${e.level.toUpperCase().padEnd(5)}]`),r&&e.source&&n("span",{style:{background:u.surfaceAlt,border:`1px solid ${u.border}`,borderRadius:10,padding:"0 5px",fontSize:10,color:u.textMuted,flexShrink:0,maxWidth:80,overflow:"hidden",textOverflow:"ellipsis"}},t(e.source)),n("span",{style:{flex:1,color:u.text,overflow:"hidden",textOverflow:"ellipsis"}},...function(e,o){if(!o)return[e];const i=t(e),r=t(o);if(!r)return[i];try{const e=new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return i.split(e).map((t,o)=>e.test(t)?n("mark",{key:o,className:"tkx-log-highlight"},t):t)}catch{return[i]}}(e.message,s)),p&&n("span",{style:{color:u.textMuted,fontSize:10,flexShrink:0}},l?"▲":"▼"))}function S({metadata:e,theme:o,style:i}){return n("div",{style:{...i,background:o.surfaceAlt,borderBottom:`1px solid ${o.border}`,padding:"6px 10px 6px 56px",display:"flex",flexWrap:"wrap",gap:6,boxSizing:"border-box"}},...Object.entries(e).map(([e,i])=>n("span",{key:e,style:{fontSize:11,fontFamily:"monospace",color:o.textMuted,background:o.surface,border:`1px solid ${o.border}`,borderRadius:4,padding:"1px 6px"}},n("span",{style:{color:o.info}},`${t(e)}: `),t(String(i)))))}function $({entries:t,maxEntries:l=500,height:c=400,autoScroll:d=!0,showLevel:u=!0,showTimestamp:f=!0,showSource:h=!0,filterLevel:m,searchQuery:p="",monospace:g=!0,onEntryClick:y}){const x=e();!function(){if(v||"undefined"==typeof document)return;v=!0;const e=document.createElement("style");e.id="tkx-live-log-styles",e.textContent="\n.tkx-log-row:hover { filter: brightness(1.12); }\n.tkx-log-highlight { background: #ffbe0b55; border-radius: 2px; padding: 0 1px; }\n ".trim(),document.head.appendChild(e)}();const b=s(null),[$,M]=a(0),[z,N]=a(/* @__PURE__ */new Set),[W,I]=a(!1),L=s(t.length),C=r(()=>{let e=t.slice(-l);if(void 0!==m){const t=k[m];e=e.filter(e=>k[e.level]>=t)}if(p){const t=p.toLowerCase();e=e.filter(e=>e.message.toLowerCase().includes(t)||(e.source??"").toLowerCase().includes(t))}return e},[t,l,m,p]),T="number"==typeof c?c:400,j=r(()=>{const e=[];let t=0;for(const n of C)e.push(t),t+=28+(z.has(n.id)?40:0);return e.push(t),e},[C,z]),E=j[j.length-1]??0;i(()=>{d&&!W&&C.length!==L.current&&(L.current=C.length,b.current&&(b.current.scrollTop=b.current.scrollHeight))},[C.length,d,W]);const R=o(()=>{if(!b.current)return;const e=b.current;I(!(e.scrollHeight-e.scrollTop-e.clientHeight<56)),M(e.scrollTop)},[]),B=o(e=>{N(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),F=C.length>0?function(e){let t=0,n=C.length-1;for(;t<n;){const o=t+n>>1;(j[o+1]??0)<=e?t=o+1:n=o}return Math.max(0,t-8)}($):0,O=C.length>0?function(e){let t=0,n=C.length-1;for(;t<n;){const o=t+n+1>>1;(j[o]??0)>=e+T?n=o-1:t=o}return Math.min(C.length-1,t+8)}($):-1,D={position:"relative",overflow:"auto",height:"number"==typeof c?`${c}px`:c,background:x.bg,border:`1px solid ${x.border}`,borderRadius:8,boxSizing:"border-box"},A={position:"relative",height:E,minHeight:"100%"};if(0===C.length)return n("div",{style:{...D,display:"flex",alignItems:"center",justifyContent:"center"}},n("span",{style:{color:x.textMuted,fontSize:13,fontFamily:"monospace"}},"No log entries."));const H=[];for(let e=F;e<=O;e++){const t=C[e];if(!t)continue;const o=j[e]??0,i=z.has(t.id);H.push(n(w,{key:t.id,entry:t,showLevel:u,showTimestamp:f,showSource:h,searchQuery:p,monospace:g,isExpanded:i,onToggle:()=>B(t.id),onEntryClick:y,theme:x,style:{position:"absolute",top:o,left:0,right:0}})),i&&t.metadata&&Object.keys(t.metadata).length>0&&H.push(n(S,{key:`${t.id}-meta`,metadata:t.metadata,theme:x,style:{position:"absolute",top:o+28,left:0,right:0,height:40}}))}return n("div",{ref:b,style:D,onScroll:R,role:"log","aria-live":"polite","aria-label":"Log viewer"},n("div",{style:A},...H))}export{d as TkxLiveFeed,$ as TkxLiveLog,g as TkxLiveMetrics,b as TkxRealTimeChart};
1
+ import{p as e}from"./chunk-DdHSYetV.js";import{E as t}from"./chunk-DcVMayoM.js";import{createElement as n,useCallback as o,useEffect as i,useMemo as r,useRef as s,useState as a}from"react";var l=!1;function c({item:e,isNew:o,showTimestamps:i,onItemClick:r,renderItem:s,theme:a,style:l}){const c=function(e,t){switch(e){case"info":return t.info;case"success":return t.success;case"warning":return t.warning;case"error":return t.danger;default:return t.border}}(e.type,a);return s?n("div",{style:l,className:o?"tkx-feed-item-new":void 0},s(e)):n("div",{style:{...l,display:"flex",alignItems:"center",gap:10,padding:"0 12px",borderLeft:`3px solid ${c}`,cursor:r?"pointer":"default",boxSizing:"border-box",height:64,background:a.surface,transition:"background 0.15s"},className:o?"tkx-feed-item-new":void 0,onClick:r?()=>r(e):void 0,role:r?"button":void 0,tabIndex:r?0:void 0,onKeyDown:r?t=>{"Enter"!==t.key&&" "!==t.key||r(e)}:void 0},n("div",{style:{width:36,height:36,borderRadius:"50%",background:c,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:700,color:a.bg,flexShrink:0,overflow:"hidden"}},e.avatar?n("img",{src:e.avatar,alt:e.author??"",style:{width:"100%",height:"100%",objectFit:"cover"}}):(d=e.author)?d.split(" ").map(e=>e[0]??"").slice(0,2).join("").toUpperCase():"?"),n("div",{style:{flex:1,minWidth:0}},n("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2}},e.author&&n("span",{style:{fontWeight:600,fontSize:13,color:a.text}},t(e.author)),e.meta&&n("span",{style:{fontSize:11,color:a.textMuted,background:a.surfaceAlt,borderRadius:4,padding:"1px 5px"}},t(e.meta))),n("div",{style:{fontSize:13,color:a.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},t(e.content))),i&&n("div",{style:{fontSize:11,color:a.textMuted,flexShrink:0}},function(e){const t=Date.now()-e;return t<1e4?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}(e.timestamp)));var d}function d({items:d,maxItems:u=100,height:f=400,autoScroll:h=!0,showTimestamps:m=!0,onItemClick:p,emptyMessage:g="No activity yet.",pauseOnHover:y=!0,renderItem:x}){const b=e();!function(){if(l||"undefined"==typeof document)return;l=!0;const e=document.createElement("style");e.id="tkx-live-feed-styles",e.textContent="\n@keyframes tkx-feed-slide-in {\n from { transform: translateY(-20px); opacity: 0; }\n to { transform: translateY(0); opacity: 1; }\n}\n.tkx-feed-item-new {\n animation: tkx-feed-slide-in 0.25s ease-out both;\n}\n ".trim(),document.head.appendChild(e)}();const k=s(null),[v,w]=a(0),[S,$]=a(!1),[M,z]=a(/* @__PURE__ */new Set),N=s([]),W=r(()=>d.slice(-u),[d,u]),I="number"==typeof f?f:400,L=64*W.length;i(()=>{const e=new Set(N.current.map(e=>e.id)),t=W.filter(t=>!e.has(t.id)).map(e=>e.id);if(t.length>0){z(e=>{const n=new Set(e);return t.forEach(e=>n.add(e)),n});const e=window.setTimeout(()=>{z(e=>{const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},400);return()=>clearTimeout(e)}},[W]),i(()=>{N.current=W},[W]);const C=h&&!(y&&S);i(()=>{if(!C||!k.current)return;const e=k.current;(e.scrollHeight-e.scrollTop-e.clientHeight<192||W.length<=5)&&(e.scrollTop=e.scrollHeight)},[W.length,C]);const T=o(()=>{k.current&&w(k.current.scrollTop)},[]),j=Math.max(0,Math.floor(v/64)-5),E=Math.min(W.length-1,Math.ceil((v+I)/64)+5),R={position:"relative",overflow:"auto",height:"number"==typeof f?`${f}px`:f,background:b.bg,border:`1px solid ${b.border}`,borderRadius:8,boxSizing:"border-box"},B={position:"relative",height:L,minHeight:"100%"};if(0===W.length)return n("div",{style:{...R,display:"flex",alignItems:"center",justifyContent:"center"}},n("span",{style:{color:b.textMuted,fontSize:14}},t(g)));const F=[];for(let e=j;e<=E;e++){const t=W[e];t&&F.push(n(c,{key:t.id,item:t,isNew:M.has(t.id),showTimestamps:m,onItemClick:p,renderItem:x,theme:b,style:{position:"absolute",top:64*e,left:0,right:0}}))}return n("div",{ref:k,style:R,onScroll:T,onMouseEnter:y?()=>$(!0):void 0,onMouseLeave:y?()=>$(!1):void 0,"aria-label":"Live feed",role:"feed"},n("div",{style:B},...F))}var u=!1;function f(e,t){if("string"==typeof e)return e;const n=e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Number.isInteger(e)?e:e.toFixed(2));return t?`${n}${t}`:n}function h({data:e,color:t}){if(e.length<2)return null;const o=Math.min(...e),i=Math.max(...e)-o||1,r=e.map((t,n)=>{const r=n/(e.length-1)*80,s=24-(t-o)/i*22-1;return`${r.toFixed(1)},${s.toFixed(1)}`});return n("svg",{width:80,height:24,viewBox:"0 0 80 24","aria-hidden":"true"},n("polyline",{points:r.join(" "),fill:"none",stroke:t,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}))}function m({trend:e,theme:t}){return"up"===e?n("span",{style:{color:t.success,fontSize:14,fontWeight:700}},"▲"):"down"===e?n("span",{style:{color:t.danger,fontSize:14,fontWeight:700}},"▼"):n("span",{style:{color:t.textMuted,fontSize:14}},"→")}function p({metric:e,animate:o,onMetricClick:r,theme:l}){const c=e.color??function(e,t){switch(e){case"warning":return t.warning;case"critical":return t.danger;default:return t.primary}}(e.status,l),d="number"==typeof e.value?e.value:NaN,u=function(e,t,n){const[o,r]=a(e),l=s(e),c=s(null),d=s(null),u=function(){const[e,t]=a(()=>"undefined"!=typeof window&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return i(()=>{if("undefined"==typeof window)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)"),n=e=>t(e.matches);return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[]),e}();return i(()=>{if(!n||u)return r(e),void(l.current=e);const t=l.current;if(t===e)return;c.current=null;const o=n=>{null===c.current&&(c.current=n);const i=n-c.current,s=Math.min(i/600,1),a=1-Math.pow(1-s,3);r(t+(e-t)*a),s<1?d.current=requestAnimationFrame(o):l.current=e};return d.current=requestAnimationFrame(o),()=>{null!==d.current&&cancelAnimationFrame(d.current)}},[e,600,n,u]),o}(isNaN(d)?0:d,0,o&&!isNaN(d)),[p,g]=a(!1),y=s(e.value);i(()=>{if(y.current!==e.value){y.current=e.value,g(!0);const t=window.setTimeout(()=>g(!1),700);return()=>clearTimeout(t)}},[e.value]);const x=void 0!==e.previousValue&&e.previousValue!==d,b={background:l.surface,border:`1px solid ${l.border}`,borderLeft:`4px solid ${c}`,borderRadius:8,padding:"14px 16px",cursor:r?"pointer":"default",position:"relative",overflow:"hidden",boxSizing:"border-box"},k=p?{position:"absolute",inset:0,background:`linear-gradient(90deg, transparent 0%, ${c}22 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"tkx-metric-shimmer 0.6s ease-in-out",pointerEvents:"none"}:{},v=isNaN(d)?t(String(e.value)):f(u,e.unit);return n("div",{style:b,className:p?"tkx-metric-shimmer":void 0,onClick:r?()=>r(e):void 0,role:r?"button":void 0,tabIndex:r?0:void 0},p&&n("div",{style:k}),n("div",{style:{fontSize:12,color:l.textMuted,marginBottom:6,fontWeight:500,letterSpacing:"0.03em"}},t(e.label)),n("div",{style:{display:"flex",alignItems:"flex-end",gap:6,marginBottom:6}},n("span",{style:{fontSize:28,fontWeight:700,color:l.text,lineHeight:1}},v),e.unit&&isNaN(d)&&n("span",{style:{fontSize:14,color:l.textMuted,marginBottom:2}},t(e.unit))),(e.trend||e.trendValue)&&n("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:e.sparkline?8:0}},e.trend&&n(m,{trend:e.trend,theme:l}),e.trendValue&&n("span",{style:{fontSize:12,color:l.textMuted}},t(e.trendValue))),x&&n("div",{style:{fontSize:11,color:l.textMuted,marginTop:2}},`was ${f(e.previousValue)}`),e.sparkline&&e.sparkline.length>=2&&n("div",{style:{marginTop:8}},n(h,{data:e.sparkline,color:c})))}function g({metrics:t,columns:o=3,animate:i=!0,onMetricClick:r}){const s=e();return function(){if(u||"undefined"==typeof document)return;u=!0;const e=document.createElement("style");e.id="tkx-live-metrics-styles",e.textContent="\n@keyframes tkx-metric-pulse {\n 0% { opacity: 1; }\n 40% { opacity: 0.4; }\n 100% { opacity: 1; }\n}\n@keyframes tkx-metric-shimmer {\n 0% { background-position: -200% 0; }\n 100% { background-position: 200% 0; }\n}\n.tkx-metric-shimmer {\n animation: tkx-metric-shimmer 0.6s ease-in-out;\n}\n@media (prefers-reduced-motion: reduce) {\n .tkx-metric-shimmer { animation: none; }\n .tkx-metric-pulse { animation: none; }\n}\n ".trim(),document.head.appendChild(e)}(),n("div",{style:{display:"grid",gridTemplateColumns:`repeat(${o}, minmax(0, 1fr))`,gap:16}},...t.map(e=>n(p,{key:e.id,metric:e,animate:i,onMetricClick:r,theme:s})))}function y(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function x(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(2)}function b({data:l,maxPoints:c=60,height:d=200,width:u="100%",color:f,fill:h=!0,showGrid:m=!0,showLabels:p=!0,showTooltip:g=!0,label:b,unit:k,animate:v=!0,yMin:w,yMax:S}){const $=e(),M=f??$.primary,z=s(null),[N,W]=a(600),[I,L]=a(null),[C,T]=a(0),j=s(l.length);i(()=>{if(!z.current)return;const e=new ResizeObserver(e=>{const t=e[0];t&&W(t.contentRect.width)});return e.observe(z.current),W(z.current.offsetWidth),()=>e.disconnect()},[]);const E=r(()=>l.slice(-c),[l,c]);i(()=>{E.length>j.current&&T(e=>e+1),j.current=E.length},[E.length]);const R=p?48:12,B=b?28:12,F=Math.max(N-R-12,1),O=Math.max(d-B-28,1),D=E.length?Math.min(...E.map(e=>e.value)):0,A=E.length?Math.max(...E.map(e=>e.value)):1,H=A-D||1,P=void 0!==w?w:D-.1*H,Q=(void 0!==S?S:A+.1*H)-P||1;function q(e){return E.length<2?F/2:e/(E.length-1)*F}function K(e){return O-(e-P)/Q*O}const Y=E.length>=2?E.map((e,t)=>`${0===t?"M":"L"}${q(t).toFixed(2)},${K(e.value).toFixed(2)}`).join(" "):"",G=Y?`${Y} L${q(E.length-1).toFixed(2)},${O} L${q(0).toFixed(2)},${O} Z`:"",J=[];for(let e=0;e<=4;e++)J.push(e);const Z=J.map(e=>{const t=P+e/4*Q;return{y:K(t),text:x(t)}}),U=Math.min(4,E.length),V=U>0?Array.from({length:U},(e,t)=>Math.round(t/Math.max(U-1,1)*(E.length-1))):[],X=o(e=>{if(!g||0===E.length)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left-R;let o=0,i=1/0;E.forEach((e,t)=>{const r=Math.abs(q(t)-n);r<i&&(i=r,o=t)});const r=E[o];r&&L({x:q(o)+R,y:K(r.value)+B,point:r})},[E,g,R,B]),_=o(()=>L(null),[]),ee=N,te=d,ne=`tkx-chart-clip-${C}`;return n("div",{ref:z,style:{position:"relative",width:"number"==typeof u?`${u}px`:u,background:$.surface,border:`1px solid ${$.border}`,borderRadius:8,overflow:"hidden",boxSizing:"border-box"}},n("svg",{width:ee,height:te,viewBox:`0 0 ${ee} ${te}`,onMouseMove:X,onMouseLeave:_,style:{display:"block",userSelect:"none"},"aria-label":b?t(b):"Real-time chart"},v&&E.length>=2&&n("defs",null,n("clipPath",{id:ne},n("rect",{x:0,y:0,width:F,height:te},n("animate",{attributeName:"width",from:Math.max(0,F-F/Math.max(E.length-1,1)),to:F,dur:"0.3s",fill:"freeze"})))),b&&n("text",{x:R,y:18,fill:$.textMuted,fontSize:12,fontWeight:500},t(b)),m&&J.map(e=>{const t=K(P+e/4*Q)+B;return n("line",{key:`grid-${e}`,x1:R,y1:t,x2:R+F,y2:t,stroke:$.border,strokeWidth:1,strokeDasharray:"4 4"})}),p&&Z.map((e,t)=>n("text",{key:`yl-${t}`,x:R-4,y:e.y+B+4,fill:$.textMuted,fontSize:10,textAnchor:"end"},e.text)),k&&n("text",{x:4,y:B+10,fill:$.textMuted,fontSize:9},t(k)),h&&G&&n("path",{d:G,fill:`${M}22`,clipPath:v?`url(#${ne})`:void 0,transform:`translate(${R}, ${B})`}),Y&&n("path",{d:Y,fill:"none",stroke:M,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",clipPath:v?`url(#${ne})`:void 0,transform:`translate(${R}, ${B})`}),V.map(e=>{const t=E[e];return t?n("text",{key:`xl-${e}`,x:R+q(e),y:te-8,fill:$.textMuted,fontSize:9,textAnchor:"middle"},y(t.timestamp)):null}),I&&n("line",{x1:I.x,y1:B,x2:I.x,y2:B+O,stroke:M,strokeWidth:1,strokeDasharray:"3 3",opacity:.6}),I&&n("circle",{cx:I.x,cy:I.y,r:4,fill:M,stroke:$.surface,strokeWidth:2}),I&&(()=>{const e=Math.min(I.x+8,ee-100),t=Math.max(I.y-36,4),o=`${x(I.point.value)}${k||""}`,i=y(I.point.timestamp);return n("g",null,n("rect",{x:e-4,y:t-2,width:90,height:34,rx:4,fill:$.surfaceAlt,stroke:$.border,strokeWidth:1}),n("text",{x:e,y:t+11,fill:$.text,fontSize:12,fontWeight:700},o),n("text",{x:e,y:t+26,fill:$.textMuted,fontSize:10},i))})()))}var k={debug:0,info:1,warn:2,error:3,fatal:4},v=!1;function w({entry:e,showLevel:o,showTimestamp:i,showSource:r,searchQuery:s,monospace:a,isExpanded:l,onToggle:c,onEntryClick:d,theme:u,style:f}){const h=function(e,t){switch(e){case"debug":default:return t.textMuted;case"info":return t.info;case"warn":return t.warning;case"error":case"fatal":return t.danger}}(e.level,u),m=function(e,t){return"fatal"===e?`${t.danger}22`:"transparent"}(e.level,u),p=e.metadata&&Object.keys(e.metadata).length>0,g={...f,display:"flex",alignItems:"center",gap:6,padding:"0 10px",fontSize:12,fontFamily:a?'"JetBrains Mono", "Fira Mono", Consolas, monospace':"inherit",cursor:p||d?"pointer":"default",background:m,boxSizing:"border-box",height:28,overflow:"hidden",whiteSpace:"nowrap",borderBottom:`1px solid ${u.border}22`};return n("div",{style:g,className:"tkx-log-row",onClick:()=>{p&&c(),d&&d(e)},role:p?"button":void 0,tabIndex:p?0:void 0,onKeyDown:p?e=>{"Enter"!==e.key&&" "!==e.key||c()}:void 0,"aria-expanded":p?l:void 0},i&&n("span",{style:{color:u.textMuted,flexShrink:0,minWidth:84}},function(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}`}(e.timestamp)),o&&n("span",{style:{color:h,flexShrink:0,fontWeight:"fatal"===e.level?700:500,minWidth:56}},`[${e.level.toUpperCase().padEnd(5)}]`),r&&e.source&&n("span",{style:{background:u.surfaceAlt,border:`1px solid ${u.border}`,borderRadius:10,padding:"0 5px",fontSize:10,color:u.textMuted,flexShrink:0,maxWidth:80,overflow:"hidden",textOverflow:"ellipsis"}},t(e.source)),n("span",{style:{flex:1,color:u.text,overflow:"hidden",textOverflow:"ellipsis"}},...function(e,o){if(!o)return[e];const i=t(e),r=t(o);if(!r)return[i];try{const e=new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return i.split(e).map((t,o)=>e.test(t)?n("mark",{key:o,className:"tkx-log-highlight"},t):t)}catch{return[i]}}(e.message,s)),p&&n("span",{style:{color:u.textMuted,fontSize:10,flexShrink:0}},l?"▲":"▼"))}function S({metadata:e,theme:o,style:i}){return n("div",{style:{...i,background:o.surfaceAlt,borderBottom:`1px solid ${o.border}`,padding:"6px 10px 6px 56px",display:"flex",flexWrap:"wrap",gap:6,boxSizing:"border-box"}},...Object.entries(e).map(([e,i])=>n("span",{key:e,style:{fontSize:11,fontFamily:"monospace",color:o.textMuted,background:o.surface,border:`1px solid ${o.border}`,borderRadius:4,padding:"1px 6px"}},n("span",{style:{color:o.info}},`${t(e)}: `),t(String(i)))))}function $({entries:t,maxEntries:l=500,height:c=400,autoScroll:d=!0,showLevel:u=!0,showTimestamp:f=!0,showSource:h=!0,filterLevel:m,searchQuery:p="",monospace:g=!0,onEntryClick:y}){const x=e();!function(){if(v||"undefined"==typeof document)return;v=!0;const e=document.createElement("style");e.id="tkx-live-log-styles",e.textContent="\n.tkx-log-row:hover { filter: brightness(1.12); }\n.tkx-log-highlight { background: #ffbe0b55; border-radius: 2px; padding: 0 1px; }\n ".trim(),document.head.appendChild(e)}();const b=s(null),[$,M]=a(0),[z,N]=a(/* @__PURE__ */new Set),[W,I]=a(!1),L=s(t.length),C=r(()=>{let e=t.slice(-l);if(void 0!==m){const t=k[m];e=e.filter(e=>k[e.level]>=t)}if(p){const t=p.toLowerCase();e=e.filter(e=>e.message.toLowerCase().includes(t)||(e.source??"").toLowerCase().includes(t))}return e},[t,l,m,p]),T="number"==typeof c?c:400,j=r(()=>{const e=[];let t=0;for(const n of C)e.push(t),t+=28+(z.has(n.id)?40:0);return e.push(t),e},[C,z]),E=j[j.length-1]??0;i(()=>{d&&!W&&C.length!==L.current&&(L.current=C.length,b.current&&(b.current.scrollTop=b.current.scrollHeight))},[C.length,d,W]);const R=o(()=>{if(!b.current)return;const e=b.current;I(!(e.scrollHeight-e.scrollTop-e.clientHeight<56)),M(e.scrollTop)},[]),B=o(e=>{N(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),F=C.length>0?function(e){let t=0,n=C.length-1;for(;t<n;){const o=t+n>>1;(j[o+1]??0)<=e?t=o+1:n=o}return Math.max(0,t-8)}($):0,O=C.length>0?function(e){let t=0,n=C.length-1;for(;t<n;){const o=t+n+1>>1;(j[o]??0)>=e+T?n=o-1:t=o}return Math.min(C.length-1,t+8)}($):-1,D={position:"relative",overflow:"auto",height:"number"==typeof c?`${c}px`:c,background:x.bg,border:`1px solid ${x.border}`,borderRadius:8,boxSizing:"border-box"},A={position:"relative",height:E,minHeight:"100%"};if(0===C.length)return n("div",{style:{...D,display:"flex",alignItems:"center",justifyContent:"center"}},n("span",{style:{color:x.textMuted,fontSize:13,fontFamily:"monospace"}},"No log entries."));const H=[];for(let e=F;e<=O;e++){const t=C[e];if(!t)continue;const o=j[e]??0,i=z.has(t.id);H.push(n(w,{key:t.id,entry:t,showLevel:u,showTimestamp:f,showSource:h,searchQuery:p,monospace:g,isExpanded:i,onToggle:()=>B(t.id),onEntryClick:y,theme:x,style:{position:"absolute",top:o,left:0,right:0}})),i&&t.metadata&&Object.keys(t.metadata).length>0&&H.push(n(S,{key:`${t.id}-meta`,metadata:t.metadata,theme:x,style:{position:"absolute",top:o+28,left:0,right:0,height:40}}))}return n("div",{ref:b,style:D,onScroll:R,role:"log","aria-live":"polite","aria-label":"Log viewer"},n("div",{style:A},...H))}export{d as TkxLiveFeed,$ as TkxLiveLog,g as TkxLiveMetrics,b as TkxRealTimeChart};
@@ -0,0 +1,22 @@
1
+ import { type CSSProperties } from 'react';
2
+ export declare function isValidAadhaar(input: string): boolean;
3
+ export interface AadhaarChangePayload {
4
+ raw: string;
5
+ digits: string;
6
+ display: string;
7
+ valid: boolean;
8
+ }
9
+ export interface TkxAadhaarInputProps {
10
+ value?: string;
11
+ defaultValue?: string;
12
+ onChange?: (payload: AadhaarChangePayload) => void;
13
+ label?: string;
14
+ mask?: boolean;
15
+ disabled?: boolean;
16
+ required?: boolean;
17
+ id?: string;
18
+ name?: string;
19
+ className?: string;
20
+ style?: CSSProperties;
21
+ }
22
+ export declare const TkxAadhaarInput: import("react").ForwardRefExoticComponent<TkxAadhaarInputProps & import("react").RefAttributes<HTMLInputElement>>;