@360vier/ai-chat-core 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/theme.d.ts +98 -0
- package/dist/theme.js +1 -0
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ interface WidgetLocaleTexts {
|
|
|
20
20
|
emptyStateTitle?: string | undefined;
|
|
21
21
|
emptyStateSubtitle?: string | undefined;
|
|
22
22
|
teaser?: string | undefined;
|
|
23
|
+
teaserLabel?: string | undefined;
|
|
24
|
+
teaserCloseLabel?: string | undefined;
|
|
23
25
|
}
|
|
24
26
|
interface WidgetConfigDocument {
|
|
25
27
|
locales: string[];
|
|
@@ -52,6 +54,7 @@ interface WidgetConfigDocument {
|
|
|
52
54
|
frequencyDays: number;
|
|
53
55
|
scrollScreens: number;
|
|
54
56
|
};
|
|
57
|
+
linkDomains: string[];
|
|
55
58
|
tracking: {
|
|
56
59
|
enabled: boolean;
|
|
57
60
|
};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as J,b as F,c as K,d as Q,e as X,f as G}from"./chunk-45NFWKPO.js";import{z as n}from"zod";var R=/^--[A-Za-z0-9_-]{1,64}$/,v=/[;{}<>\\]|@import|(?:url|image-set|-webkit-image-set|image|cross-fade|element|src|expression)\s*\(/i;function A(i,t){return R.test(i)&&!v.test(t)}var W=n.record(n.string(),n.string()).superRefine((i,t)=>{for(let[e,r]of Object.entries(i))R.test(e)||t.addIssue({code:"custom",path:[e],message:"Token name must be -- plus 1 to 64 letters, digits, - or _"}),v.test(r)&&t.addIssue({code:"custom",path:[e],message:"Token value contains a forbidden character or function"})}),L=n.record(n.string(),n.array(n.string().max(120)).max(6)),j=n.record(n.string(),n.string().max(200)),P=n.enum(["inherit","shown","hidden"]),D=n.object({id:n.string().min(1),match:n.string().min(1).startsWith("/"),display:P.default("inherit"),questions:L.optional(),greeting:j.optional(),promptAddition:n.string().max(4e3).optional()}),N=n.object({greeting:n.string().max(200).optional(),placeholder:n.string().max(2e3).optional(),messagePlaceholder:n.string().max(2e3).optional(),footer:n.string().max(2e3).optional(),headerTitle:n.string().max(2e3).optional(),emptyStateTitle:n.string().max(2e3).optional(),emptyStateSubtitle:n.string().max(2e3).optional(),teaser:n.string().max(120).optional(),teaserLabel:n.string().max(120).optional(),teaserCloseLabel:n.string().max(120).optional()}),E=n.string().trim().min(1).max(253),$=n.string().regex(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i),p=n.url({protocol:/^https?$/}),q=n.object({locales:n.array(n.string().min(2)).min(1),display:n.enum(["shown","hidden"]).default("shown"),theme:n.object({tokens:W.default({}),backdrop:n.object({color:$.default("#000000"),opacity:n.number().int().min(0).max(100).default(15)}).default({color:"#000000",opacity:15}),autoContrast:n.boolean().default(!0),fonts:n.object({heading:p.optional(),body:p.optional()}).default({}),avatar:p.optional()}).default({tokens:{},backdrop:{color:"#000000",opacity:15},autoContrast:!0,fonts:{}}),launcher:n.object({mode:n.enum(["bubble","sticky_bar"]).default("bubble"),position:n.enum(["left","right"]).default("right"),size:n.enum(["xs","sm","md","lg","xl","2xl"]).default("lg"),showBubble:n.boolean().default(!0),icon:p.optional(),collapseAfterPx:n.number().int().min(0).max(1e5).default(400),restoreNearBottomPx:n.number().int().min(0).max(1e5).default(240)}).default({mode:"bubble",position:"right",size:"lg",showBubble:!0,collapseAfterPx:400,restoreNearBottomPx:240}),teaser:n.object({enabled:n.boolean().default(!1),delayS:n.number().int().min(0).max(120).default(5),frequencyDays:n.number().int().min(0).max(365).default(7),scrollScreens:n.number().min(0).max(20).default(0)}).default({enabled:!1,delayS:5,frequencyDays:7,scrollScreens:0}),linkDomains:n.array(E).max(100).default([]),tracking:n.object({enabled:n.boolean().default(!0)}).default({enabled:!0}),texts:n.record(n.string(),N),questions:L.default({}),messageRatingEnabled:n.boolean().default(!1),rules:n.array(D).default([]),server:n.object({useChainOfThought:n.boolean().default(!1),sourcesSimilarityThreshold:n.number().min(0).max(1).default(.7)}).default({useChainOfThought:!1,sourcesSimilarityThreshold:.7})});function C(i){let t=q.safeParse(i);return t.success?{ok:!0,value:t.data}:{ok:!1,issues:t.error.issues.map(e=>({path:e.path.map(String).join("."),message:e.message}))}}function H(i,t){let{server:e,...r}=i;return{...r,version:t,rules:i.rules.map(({promptAddition:o,...s})=>s)}}var d=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),B=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,U=[["texts.placeholder_text","placeholder"],["texts.message_placeholder","messagePlaceholder"],["texts.footer_text","footer"],["texts.header_title","headerTitle"],["texts.empty_state_title","emptyStateTitle"],["texts.empty_state_subtitle","emptyStateSubtitle"],["appearance.teaser_text","teaser",120]],g=class{constructor(t,e=""){this.data=t;this.prefix=e}data;prefix;skipped=[];raw(t){let e=this.data;for(let r of t.split("."))e=d(e)?e[r]:void 0;if(!(e===null||e===""||Array.isArray(e)&&e.length===0))return e}skip(t,e){this.skipped.push({field:this.prefix+t,reason:e})}bool(t){let e=this.raw(t);if(e===void 0)return;let r=String(e).trim().toLowerCase();return e===!0||["1","true","on","yes"].includes(r)?!0:e===!1||["0","false","off","no",""].includes(r)?!1:this.skip(t,"cannot be converted to bool")}number(t,e,r,o){let s=this.raw(t);if(s===void 0)return;let l=typeof s=="number"?s:typeof s=="string"?Number(s.trim()):NaN;if(!Number.isFinite(l))return this.skip(t,`cannot be converted to ${o?"int":"float"}`);let u=Math.min(r,Math.max(e,l));return o?Math.round(u):Math.round(u*100)/100}string(t,e){let r=this.raw(t);if(r!==void 0)return typeof r!="string"?this.skip(t,"cannot be converted to string"):e===void 0?r:[...r].slice(0,e).join("")}oneOf(t,e){let r=this.string(t);if(r!==void 0)return e.includes(r)?r:this.skip(t,`must be one of ${e.join(", ")}`)}list(t){let e=this.raw(t);if(e!==void 0)return Array.isArray(e)?e.filter(r=>typeof r=="string"):this.skip(t,"cannot be converted to list")}ids(t){let e=this.raw(t);return e===void 0?[]:Array.isArray(e)?e.map(Number).filter(r=>Number.isInteger(r)&&r>0):this.skip(t,"cannot be converted to list")??[]}};function V(i){let t=i.raw("appearance.style_config");if(t===void 0)return{};let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch{return i.skip("appearance.style_config","is not valid JSON"),{}}if(!d(e))return i.skip("appearance.style_config","is not an object"),{};let r={};for(let[o,s]of Object.entries(e)){let l=o.startsWith("--")?o:`--${o}`;if(typeof s!="string"||!A(l,s)){i.skip(`appearance.style_config.${l}`,"is not an allowed CSS custom property");continue}r[l]=s}return r}function f(i,t,e){let r=i.number(t,0,Number.MAX_SAFE_INTEGER,!0);if(r)return e.attachmentUrl(r)??i.skip(t,`attachment ${r} not found`)}function O(i){let t={};for(let[e,r,o]of U){let s=i.string(e,o);s!==void 0&&(t[r]=s)}return t}function z(i,t){let e=i.oneOf("appearance.visibility",["show","hide","show_on_selected"])??"show";if(e==="show")return{display:"shown",rules:[]};if(e==="hide")return{display:"hidden",rules:[]};let r=[];for(let o of i.ids("appearance.selected_pages")){let s=t.pagePath(o);if(!s){i.skip("appearance.selected_pages",`page ${o} not found`);continue}r.push({id:`wp-page-${o}`,match:s,display:"shown"})}return{display:"hidden",rules:r}}function M(i){let t=i.string("general.api_url");if(t===void 0)return{connector:null,clientId:null};try{let e=new URL(t),r=e.searchParams.get("clientId");return{connector:e.origin,clientId:r&&B.test(r)?r:null}}catch{return i.skip("general.api_url","is not a URL"),{connector:null,clientId:null}}}function te(i,t){let e=new g(d(i)?i:{});d(i)||e.skip("","the option is not an object");let{display:r,rules:o}=z(e,t),{connector:s,clientId:l}=M(e),u=t.locale,x={[u]:O(e)},m={},k=e.list("prompts.prompt_templates");k&&(m[u]=k);let _=[u];for(let[a,T]of Object.entries(t.languageOverrides??{})){if(a===u)continue;if(!d(T)){e.skip(a,"the language override is not an object");continue}let h=new g(T,`${a}.`);x[a]=O(h);let S=h.list("prompts.prompt_templates");S&&(m[a]=S),e.skipped.push(...h.skipped),_.push(a)}let w=[...new Set(e.list("general.allowed_domains")??[])],I=w.map(a=>a.trim()).filter(a=>a!==""&&a.length<=253).slice(0,100),c={locales:_,display:r,theme:{tokens:V(e),backdrop:{color:e.string("appearance.backdrop_color")?.toLowerCase(),opacity:e.number("appearance.backdrop_opacity",0,100,!0)},autoContrast:e.bool("appearance.auto_contrast"),fonts:{heading:f(e,"appearance.custom_font",t),body:f(e,"appearance.custom_body_font",t)},avatar:f(e,"appearance.placeholder_image",t)},launcher:{mode:e.oneOf("appearance.launcher_mode",["bubble","sticky_bar"])??"bubble",size:e.oneOf("appearance.bubble_size",["xs","sm","md","lg","xl","2xl"]),showBubble:e.bool("appearance.show_bubble"),icon:f(e,"appearance.toggle_icon",t),collapseAfterPx:e.number("appearance.launcher_collapse_after_px",0,1e5,!0),restoreNearBottomPx:e.number("appearance.launcher_restore_near_bottom_px",0,1e5,!0)},teaser:{enabled:e.bool("appearance.teaser_enabled"),delayS:e.number("appearance.teaser_delay_s",0,120,!0),frequencyDays:e.number("appearance.teaser_frequency_days",0,365,!0),scrollScreens:e.number("appearance.teaser_scroll_screens",0,20,!1)},linkDomains:I,tracking:{enabled:e.bool("general.tracking_enabled")},texts:x,questions:m,rules:o,server:{useChainOfThought:e.bool("general.use_chain_of_thought"),sourcesSimilarityThreshold:e.number("general.sources_similarity_threshold",0,1,!1)}};c.theme.backdrop.color!==void 0&&!/^#([0-9a-f]{3}|[0-9a-f]{6})$/.test(c.theme.backdrop.color)&&(e.skip("appearance.backdrop_color","must be a hex colour like #112233"),c.theme.backdrop.color=void 0);let b=C(y(c));return b.ok?{ok:!0,document:b.value,connector:s,clientId:l,allowedOrigins:w,skipped:e.skipped}:{ok:!1,issues:b.issues,skipped:e.skipped}}function y(i){return Array.isArray(i)?i.map(y):d(i)?Object.fromEntries(Object.entries(i).filter(([,t])=>t!==void 0).map(([t,e])=>[t,y(e)])):i}export{H as buildPublicSnapshot,K as compilePattern,te as importLegacyWordPress,A as isAllowedToken,X as matchPageRules,Q as matchesPattern,J as normalizePath,G as resolvePage,F as stripLocalePrefix,C as validateWidgetConfig};
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WCAG 2.x contrast helpers. Pure functions, no DOM access, shared by the
|
|
3
|
+
* admin style editor (warnings) and the frontend (runtime correction).
|
|
4
|
+
*/
|
|
5
|
+
interface Rgba {
|
|
6
|
+
r: number;
|
|
7
|
+
g: number;
|
|
8
|
+
b: number;
|
|
9
|
+
a: number;
|
|
10
|
+
}
|
|
11
|
+
type Rgb = Pick<Rgba, "r" | "g" | "b">;
|
|
12
|
+
/**
|
|
13
|
+
* Parse `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa` and `rgb()`/`rgba()` (comma or
|
|
14
|
+
* space syntax). Everything else (named colours, `transparent`, `var()`,
|
|
15
|
+
* `color-mix()`, `hsl()`, gradients, empty, non-strings) returns `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param value Candidate CSS colour.
|
|
18
|
+
*/
|
|
19
|
+
declare function parseColor(value: unknown): Rgba | null;
|
|
20
|
+
/**
|
|
21
|
+
* WCAG relative luminance of an sRGB colour.
|
|
22
|
+
*
|
|
23
|
+
* @param rgb Colour with 0-255 channels.
|
|
24
|
+
*/
|
|
25
|
+
declare function relativeLuminance(rgb: Rgb): number;
|
|
26
|
+
/**
|
|
27
|
+
* WCAG contrast ratio (1 to 21), independent of the argument order.
|
|
28
|
+
*
|
|
29
|
+
* @param a First colour.
|
|
30
|
+
* @param b Second colour.
|
|
31
|
+
*/
|
|
32
|
+
declare function contrastRatio(a: Rgb, b: Rgb): number;
|
|
33
|
+
/**
|
|
34
|
+
* Whether text of this colour on this background meets WCAG AA.
|
|
35
|
+
*
|
|
36
|
+
* @param fg Text colour.
|
|
37
|
+
* @param bg Background colour.
|
|
38
|
+
* @param large Large text only needs 3:1.
|
|
39
|
+
*/
|
|
40
|
+
declare function meetsAA(fg: Rgb, bg: Rgb, large?: boolean): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Black or white, whichever reads better on the background (white on a tie).
|
|
43
|
+
* Every opaque background reaches at least 4.58:1 with the better of the two.
|
|
44
|
+
*
|
|
45
|
+
* @param bg Background colour.
|
|
46
|
+
*/
|
|
47
|
+
declare function pickReadableText(bg: Rgb): "#000000" | "#ffffff";
|
|
48
|
+
interface ContrastPair {
|
|
49
|
+
/** Token holding the text (or ring) colour. */
|
|
50
|
+
fg: string;
|
|
51
|
+
/** Token that replaces `fg` when it is unset. */
|
|
52
|
+
fgFallback?: string;
|
|
53
|
+
/** Token holding the background colour. */
|
|
54
|
+
bg: string;
|
|
55
|
+
/** Required ratio: 4.5 for text, 3 for non-text (focus ring). */
|
|
56
|
+
min: 4.5 | 3;
|
|
57
|
+
/** The chat replaces `fg` by black or white at runtime when this pair fails. */
|
|
58
|
+
autoCorrect: boolean;
|
|
59
|
+
}
|
|
60
|
+
declare const CONTRAST_PAIRS: readonly ContrastPair[];
|
|
61
|
+
interface PairResult {
|
|
62
|
+
/**
|
|
63
|
+
* `unknown`: a colour is empty, transparent, translucent or not an
|
|
64
|
+
* `#hex`/`rgb()` value, so the pair is neither warned about nor corrected.
|
|
65
|
+
*/
|
|
66
|
+
status: "pass" | "fail" | "unknown";
|
|
67
|
+
/** Measured ratio (`pass` and `fail` only). */
|
|
68
|
+
ratio?: number;
|
|
69
|
+
/** Tokens whose non-empty value could not be evaluated (`unknown` only). */
|
|
70
|
+
unknownKeys: string[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Evaluate one pair against a (merged) token map.
|
|
74
|
+
*
|
|
75
|
+
* @param pair Pair definition.
|
|
76
|
+
* @param values Token name to CSS value.
|
|
77
|
+
*/
|
|
78
|
+
declare function checkPair(pair: ContrastPair, values: Record<string, string>): PairResult;
|
|
79
|
+
|
|
80
|
+
/** The semantic tokens and their 1.8 defaults. */
|
|
81
|
+
declare const SEMANTIC_STYLE_DEFAULTS: Readonly<Record<string, string>>;
|
|
82
|
+
/** Legacy shadcn names → semantic names (used only when the semantic name is not set). */
|
|
83
|
+
declare const LEGACY_TO_SEMANTIC: Readonly<Record<string, string>>;
|
|
84
|
+
/** Copy legacy names to their semantic successors and derive composer and heading values. */
|
|
85
|
+
declare function migrateStyleConfig(stored: Record<string, string>): Record<string, string>;
|
|
86
|
+
/** Merge the defaults and the stored tokens, migrate legacy names and derive the shadcn and body variables. */
|
|
87
|
+
declare function expandStyleConfig(stored: Record<string, string>): Record<string, string>;
|
|
88
|
+
/** The default theme: every token the widget reads, with its 1.8 value (WCFG-005). */
|
|
89
|
+
declare const DEFAULT_THEME_TOKENS: Readonly<Record<string, string>>;
|
|
90
|
+
/**
|
|
91
|
+
* Replace the text colour of the filled controls (user bubble, send button, error button) by black
|
|
92
|
+
* or white when the configured pair is below 4.5:1. Works on the merged semantic config, so legacy
|
|
93
|
+
* names and unset tokens are evaluated the way the renderer sees them. Returns a copy.
|
|
94
|
+
*/
|
|
95
|
+
declare function applyContrastCorrection(stored: Record<string, string>, autoContrast: boolean): Record<string, string>;
|
|
96
|
+
|
|
97
|
+
export { CONTRAST_PAIRS, DEFAULT_THEME_TOKENS, LEGACY_TO_SEMANTIC, SEMANTIC_STYLE_DEFAULTS, applyContrastCorrection, checkPair, contrastRatio, expandStyleConfig, meetsAA, migrateStyleConfig, parseColor, pickReadableText, relativeLuminance };
|
|
98
|
+
export type { ContrastPair, PairResult, Rgba };
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var C=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,w="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)",h=`${w}%?`,T=new RegExp(`^rgba?\\(\\s*(${h})\\s*(?:,\\s*|\\s+)(${h})\\s*(?:,\\s*|\\s+)(${h})\\s*(?:(?:,|/)\\s*(${h})\\s*)?\\)$`,"i");function y(t,r,e){return Math.min(e,Math.max(r,t))}function b(t){let r=parseFloat(t);return y(t.endsWith("%")?r/100*255:r,0,255)}function c(t){if(typeof t!="string")return null;let r=t.trim();if(C.test(r)){let a=r.slice(1);return a.length<=4&&(a=a.split("").map(s=>s+s).join("")),{r:parseInt(a.slice(0,2),16),g:parseInt(a.slice(2,4),16),b:parseInt(a.slice(4,6),16),a:a.length===8?parseInt(a.slice(6,8),16)/255:1}}let e=r.match(T);if(!e)return null;let o=e[4],n=1;if(o!==void 0){let a=parseFloat(o);n=y(o.endsWith("%")?a/100:a,0,1)}return{r:b(e[1]),g:b(e[2]),b:b(e[3]),a:n}}function d(t){let r=t/255;return r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}function p(t){return .2126*d(t.r)+.7152*d(t.g)+.0722*d(t.b)}function f(t,r){let e=p(t),o=p(r);return(Math.max(e,o)+.05)/(Math.min(e,o)+.05)}function M(t,r,e=!1){return f(t,r)>=(e?3:4.5)}function R(t){let r=f({r:255,g:255,b:255},t),e=f({r:0,g:0,b:0},t);return r>=e?"#ffffff":"#000000"}var z=[{fg:"--chat-message-user-fg",bg:"--chat-message-user-bg",min:4.5,autoCorrect:!0},{fg:"--chat-composer-submit-fg",bg:"--chat-composer-submit-bg",min:4.5,autoCorrect:!0},{fg:"--chat-error-foreground",bg:"--chat-error",min:4.5,autoCorrect:!0},{fg:"--chat-foreground",bg:"--chat-background",min:4.5,autoCorrect:!1},{fg:"--chat-message-assistant-fg",bg:"--chat-background",min:4.5,autoCorrect:!1},{fg:"--chat-message-assistant-fg",bg:"--chat-message-assistant-bg",min:4.5,autoCorrect:!1},{fg:"--chat-muted-foreground",bg:"--chat-background",min:4.5,autoCorrect:!1},{fg:"--chat-composer-fg",bg:"--chat-composer-bg",min:4.5,autoCorrect:!1},{fg:"--chat-composer-placeholder",bg:"--chat-composer-bg",min:4.5,autoCorrect:!1},{fg:"--launcher-foreground",bg:"--launcher-background",min:4.5,autoCorrect:!1},{fg:"--chat-focus-ring",fgFallback:"--chat-foreground",bg:"--chat-background",min:3,autoCorrect:!1},{fg:"--chat-focus-ring",fgFallback:"--chat-foreground",bg:"--chat-message-assistant-bg",min:3,autoCorrect:!1},{fg:"--chat-focus-ring",fgFallback:"--chat-foreground",bg:"--chat-composer-bg",min:3,autoCorrect:!1}];function x(t,r,e){if(r==="bg")return{key:t.bg,value:e[t.bg]??""};let o=e[t.fg];return t.fgFallback&&(o===void 0||o.trim()==="")?{key:t.fgFallback,value:e[t.fgFallback]??""}:{key:t.fg,value:o??""}}function A(t,r){let e=x(t,"fg",r),o=x(t,"bg",r),n=c(e.value),a=c(o.value);if(!n||!a||n.a<1||a.a<1)return{status:"unknown",unknownKeys:[e,o].filter(g=>{if(g.value.trim()==="")return!1;let l=c(g.value);return!l||l.a<1}).map(g=>g.key)};let s=f(n,a);return{status:s>=t.min?"pass":"fail",ratio:s,unknownKeys:[]}}var m={"--chat-background":"#ffffff","--chat-overlay":"#ffffff","--chat-foreground":"#252525","--chat-border":"#ebebeb","--chat-muted-foreground":"#6b6b6b","--chat-error":"#e7000b","--chat-error-foreground":"#ffffff","--chat-message-user-bg":"#343434","--chat-message-user-fg":"#ffffff","--chat-message-assistant-bg":"#f0f0f0","--chat-message-assistant-fg":"#252525","--chat-composer-bg":"#ffffff","--chat-composer-fg":"#252525","--chat-composer-border":"#ebebeb","--chat-composer-placeholder":"#6b6b6b","--chat-composer-submit-bg":"#343434","--chat-composer-submit-fg":"#ffffff","--launcher-background":"#0a0a0a","--launcher-foreground":"#fafafa","--launcher-muted":"#a3a3a3","--chat-font-size-message":"0.90625rem","--chat-font-size-heading":"1.0625rem","--chat-font-size-composer":"0.90625rem","--chat-font-size-footer":"0.75rem","--chat-font-size-code":"0.88em","--chat-font-mono":'"Geist Mono", ui-monospace, monospace',"--chat-line-height-text":"1.5","--chat-line-height-heading":"1.4","--chat-message-gap":"1.125rem","--radius":"0.625rem","--bot-placeholder-height":"10rem"},v={"--background":"--chat-background","--popover":"--chat-overlay","--foreground":"--chat-foreground","--border":"--chat-border","--muted-foreground":"--chat-muted-foreground","--destructive":"--chat-error","--destructive-foreground":"--chat-error-foreground","--primary":"--chat-message-user-bg","--primary-foreground":"--chat-message-user-fg","--muted":"--chat-message-assistant-bg","--input":"--chat-composer-border","--chat-body-font-size-p":"--chat-font-size-message","--chat-body-line-height-text":"--chat-line-height-text","--chat-body-line-height-heading":"--chat-line-height-heading","--chat-body-font-size-code":"--chat-font-size-code"};function k(t){let r={...t};for(let[o,n]of Object.entries(v)){let a=t[o];!(n in t)&&a!==void 0&&(r[n]=a)}!("--chat-message-assistant-fg"in r)&&("--foreground"in t||"--chat-foreground"in r)&&(r["--chat-message-assistant-fg"]=r["--chat-foreground"]??t["--foreground"]??"");let e=(o,n)=>{!(o in r)&&n in r&&(r[o]=r[n])};if(e("--chat-composer-bg","--chat-background"),e("--chat-composer-fg","--chat-foreground"),e("--chat-composer-submit-bg","--chat-message-user-bg"),e("--chat-composer-submit-fg","--chat-message-user-fg"),!("--chat-font-size-heading"in t))for(let o of["--chat-body-font-size-h3","--chat-body-font-size-h2","--chat-body-font-size-h1"]){let n=t[o];if(n!==void 0){r["--chat-font-size-heading"]=n;break}}return r}function u(t,r){let e=/^(-?\d*\.?\d+)rem$/.exec(t.trim());return e?`${Math.round(Number(e[1])*r*1e4)/1e4}rem`:t}function E(t){let r={...m,...k(t)},e=a=>r[a]??m[a]??"",o=e("--chat-font-size-message"),n=e("--chat-font-size-heading");return{...t,...r,"--background":e("--chat-background"),"--foreground":e("--chat-foreground"),"--card":e("--chat-background"),"--card-foreground":e("--chat-foreground"),"--popover":e("--chat-overlay"),"--popover-foreground":e("--chat-foreground"),"--primary":e("--chat-message-user-bg"),"--primary-foreground":e("--chat-message-user-fg"),"--muted":e("--chat-message-assistant-bg"),"--muted-foreground":e("--chat-muted-foreground"),"--border":e("--chat-border"),"--input":e("--chat-composer-border"),"--destructive":e("--chat-error"),"--destructive-foreground":e("--chat-error-foreground"),"--chat-body-font-size-p":o,"--chat-body-font-size-li":o,"--chat-body-font-size-blockquote":o,"--chat-body-font-size-h6":o,"--chat-body-font-size-h5":u(n,.85),"--chat-body-font-size-h4":u(n,.9),"--chat-body-font-size-h3":n,"--chat-body-font-size-h2":u(n,1.1),"--chat-body-font-size-h1":u(n,1.2),"--chat-body-font-size-code":e("--chat-font-size-code"),"--chat-font-mono":e("--chat-font-mono"),"--chat-body-line-height-text":e("--chat-line-height-text"),"--chat-body-line-height-heading":e("--chat-line-height-heading"),"--font-size-sm":e("--chat-font-size-composer"),"--font-size-xs":e("--chat-font-size-footer")}}var S={"--primary-font-family":'"Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',"--secondary-font-family":'"Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',"--chat-user-bubble-max-width":"82%","--font-size-base":"1rem","--font-size-lg":"1.125rem","--font-size-xl":"1.25rem","--font-size-2xl":"1.5rem","--font-size-3xl":"1.875rem","--font-size-4xl":"2.25rem","--font-size-5xl":"3rem","--font-size-6xl":"3.75rem","--font-size-7xl":"4.5rem","--font-size-8xl":"6rem","--font-size-9xl":"8rem","--secondary":"#666666","--secondary-foreground":"#ffffff","--accent":"#f7f7f7","--accent-foreground":"#343434","--ring":"#b5b5b5","--chart-1":"#f54900","--chart-2":"#009689","--chart-3":"#104e64","--chart-4":"#ffb900","--chart-5":"#fe9a00","--sidebar":"#fbfbfb","--sidebar-foreground":"#252525","--sidebar-primary":"#343434","--sidebar-primary-foreground":"#fbfbfb","--sidebar-accent":"#f7f7f7","--sidebar-accent-foreground":"#343434","--sidebar-border":"#ebebeb","--sidebar-ring":"#b5b5b5","--shadow-xl":"0 10px 25px 5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1)","--shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.3)","--shadow-md":"4px 4px 20px 0 rgba(0, 0, 0, 0.12)","--shadow-sm":"0 2px 4px 0 rgba(0, 0, 0, 0.3), 0 2px 12px 0 rgba(0, 0, 0, 0.3)","--shadow-xs":"0 1px 2px 0 rgba(0, 0, 0, 0.3)","--shadow-inner":"inset 0 2px 4px 0 rgba(0, 0, 0, 0.3)","--shadow-none":"none"},I=Object.freeze({...S,...E({})});function P(t,r){let e={...t};if(!r)return e;let o={...m,...k(t)};for(let n of z.filter(a=>a.autoCorrect)){let a=c(o[n.fg]),s=c(o[n.bg]);if(!(!a||!s||a.a<1||s.a<1)&&!(f(a,s)>=n.min)&&(e[n.fg]=R(s),n.fg==="--chat-message-user-fg"))for(let i of["--chat-composer-submit-bg","--chat-composer-submit-fg"])!(i in e)&&o[i]!==void 0&&(e[i]=o[i])}return e}export{z as CONTRAST_PAIRS,I as DEFAULT_THEME_TOKENS,v as LEGACY_TO_SEMANTIC,m as SEMANTIC_STYLE_DEFAULTS,P as applyContrastCorrection,A as checkPair,f as contrastRatio,E as expandStyleConfig,M as meetsAA,k as migrateStyleConfig,c as parseColor,R as pickReadableText,p as relativeLuminance};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@360vier/ai-chat-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Config schema, page-rule matcher and snapshot projection for the 360VIER AI-Chat widget.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"./rules": {
|
|
19
19
|
"types": "./dist/rules.d.ts",
|
|
20
20
|
"default": "./dist/rules.js"
|
|
21
|
+
},
|
|
22
|
+
"./theme": {
|
|
23
|
+
"types": "./dist/theme.d.ts",
|
|
24
|
+
"default": "./dist/theme.js"
|
|
21
25
|
}
|
|
22
26
|
},
|
|
23
27
|
"files": [
|